-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added named exports for browser and node implementation (#49)
- Loading branch information
Showing
9 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "../dist/jdenticon-module", | ||
"types": "../types/module.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "../dist/jdenticon-node", | ||
"types": "../types/module.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { configure, drawIcon, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon/browser"; | ||
|
||
const newConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.40, 0.80], | ||
grayscale: [0.30, 0.90] | ||
}, | ||
saturation: { | ||
color: 0.50, | ||
grayscale: 0.00 | ||
}, | ||
hues: [45, 677], | ||
padding: 0.3, | ||
replaceMode: "observe", | ||
backColor: "#86444400" | ||
}; | ||
|
||
const oldConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.4, 0.8], | ||
grayscale: [0.3, 0.9] | ||
}, | ||
saturation: 0.5 | ||
}; | ||
|
||
window.jdenticon_config = oldConfig; | ||
|
||
configure(oldConfig); | ||
|
||
toPng("value to hash", 100); | ||
toSvg("value to hash", 100); | ||
|
||
toPng("value to hash", 100, 0.08); | ||
toSvg("value to hash", 100, 0.08); | ||
|
||
toPng("value to hash", 100, newConfig); | ||
toSvg("value to hash", 100, newConfig); | ||
|
||
var el = document.createElement("canvas"); | ||
update(el, "value"); | ||
update(el, "value", 0.08); | ||
update(el, "value", newConfig); | ||
update("#selector", "value"); | ||
update("#selector", "value", 0.08); | ||
update("#selector", "value", newConfig); | ||
|
||
updateSvg("#selector", "value", newConfig); | ||
updateCanvas("#selector", "value", newConfig); | ||
|
||
var ctx = el.getContext("2d"); | ||
if (ctx) { | ||
drawIcon(ctx, "value", 100); | ||
drawIcon(ctx, "value", 100, 0.08); | ||
drawIcon(ctx, "value", 100, newConfig); | ||
} | ||
|
||
// Ensure Jdenticon dodn't leak Node typings. | ||
// setTimeout returns a NodeJS.Timeout when the Node typings are loaded. | ||
const timeoutRef: number = setTimeout(() => { }, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { configure, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon/node"; | ||
|
||
const newConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.40, 0.80], | ||
grayscale: [0.30, 0.90] | ||
}, | ||
saturation: { | ||
color: 0.50, | ||
grayscale: 0.00 | ||
}, | ||
hues: [45, 677], | ||
padding: 0.3, | ||
replaceMode: "observe", | ||
backColor: "#86444400" | ||
}; | ||
|
||
const oldConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.4, 0.8], | ||
grayscale: [0.3, 0.9] | ||
}, | ||
saturation: 0.5 | ||
}; | ||
|
||
configure(oldConfig); | ||
|
||
toPng("value to hash", 100); | ||
toSvg("value to hash", 100); | ||
|
||
toPng("value to hash", 100, 0.08); | ||
toSvg("value to hash", 100, 0.08); | ||
|
||
const buffer: Buffer = toPng("value to hash", 100, newConfig); | ||
|
||
toSvg("value to hash", 100, newConfig); | ||
|
||
// Check that Node typings are loaded | ||
buffer.swap64(); | ||
|
||
update("#selector", "value"); | ||
update("#selector", "value", 0.08); | ||
update("#selector", "value", newConfig); | ||
|
||
updateSvg("#selector", "value", newConfig); | ||
updateCanvas("#selector", "value", newConfig); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { configure, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon/node"; | ||
|
||
const newConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.40, 0.80], | ||
grayscale: [0.30, 0.90] | ||
}, | ||
saturation: { | ||
color: 0.50, | ||
grayscale: 0.00 | ||
}, | ||
hues: [45, 677], | ||
padding: 0.3, | ||
replaceMode: "observe", | ||
backColor: "#86444400" | ||
}; | ||
|
||
const oldConfig: JdenticonConfig = { | ||
lightness: { | ||
color: [0.4, 0.8], | ||
grayscale: [0.3, 0.9] | ||
}, | ||
saturation: 0.5 | ||
}; | ||
|
||
configure(oldConfig); | ||
|
||
toPng("value to hash", 100); | ||
toSvg("value to hash", 100); | ||
|
||
toPng("value to hash", 100, 0.08); | ||
toSvg("value to hash", 100, 0.08); | ||
|
||
const buffer: Buffer = toPng("value to hash", 100, newConfig); | ||
|
||
toSvg("value to hash", 100, newConfig); | ||
|
||
// Check that Node typings are loaded | ||
buffer.swap64(); | ||
|
||
update("#selector", "value"); | ||
update("#selector", "value", 0.08); | ||
update("#selector", "value", newConfig); | ||
|
||
updateSvg("#selector", "value", newConfig); | ||
updateCanvas("#selector", "value", newConfig); | ||
|