init
This commit is contained in:
@@ -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);
|
||||
59
jdenticon-js/test/types/module-browser/module-test.ts
Normal file
59
jdenticon-js/test/types/module-browser/module-test.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { configure, drawIcon, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon";
|
||||
|
||||
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);
|
||||
10
jdenticon-js/test/types/module-browser/tsconfig.json
Normal file
10
jdenticon-js/test/types/module-browser/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": [],
|
||||
"lib": ["es6", "dom"],
|
||||
},
|
||||
"include": [
|
||||
"./*.ts"
|
||||
]
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
47
jdenticon-js/test/types/module-node14/module-test.ts
Normal file
47
jdenticon-js/test/types/module-node14/module-test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { configure, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon";
|
||||
|
||||
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);
|
||||
|
||||
10
jdenticon-js/test/types/module-node14/tsconfig.json
Normal file
10
jdenticon-js/test/types/module-node14/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": [ "node14" ],
|
||||
"lib": [ "es6" ],
|
||||
},
|
||||
"include": [
|
||||
"./*.ts"
|
||||
]
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
47
jdenticon-js/test/types/module-node16/module-test.ts
Normal file
47
jdenticon-js/test/types/module-node16/module-test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { configure, update, updateSvg, updateCanvas, toPng, toSvg, JdenticonConfig } from "jdenticon";
|
||||
|
||||
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);
|
||||
|
||||
10
jdenticon-js/test/types/module-node16/tsconfig.json
Normal file
10
jdenticon-js/test/types/module-node16/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": [ "node16" ],
|
||||
"lib": [ "es6" ],
|
||||
},
|
||||
"include": [
|
||||
"./*.ts"
|
||||
]
|
||||
}
|
||||
19
jdenticon-js/test/types/tsconfig.json
Normal file
19
jdenticon-js/test/types/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"typeRoots": [
|
||||
"../../node_modules/@types"
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"compileOnSave": false
|
||||
}
|
||||
60
jdenticon-js/test/types/umd/global-test.ts
Normal file
60
jdenticon-js/test/types/umd/global-test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
const config: 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 = config;
|
||||
|
||||
jdenticon.configure(config);
|
||||
|
||||
jdenticon.toPng("value to hash", 100);
|
||||
jdenticon.toSvg("value to hash", 100);
|
||||
|
||||
jdenticon.toPng("value to hash", 100, 0.08);
|
||||
jdenticon.toSvg("value to hash", 100, 0.08);
|
||||
|
||||
jdenticon.toPng("value to hash", 100, config);
|
||||
jdenticon.toSvg("value to hash", 100, config);
|
||||
|
||||
var el = document.createElement("canvas");
|
||||
jdenticon.update(el, "value");
|
||||
jdenticon.update(el, "value", 0.08);
|
||||
jdenticon.update(el, "value", config);
|
||||
jdenticon.update("#selector", "value");
|
||||
jdenticon.update("#selector", "value", 0.08);
|
||||
jdenticon.update("#selector", "value", config);
|
||||
|
||||
jdenticon.updateSvg("#selector", "value", config);
|
||||
jdenticon.updateCanvas("#selector", "value", config);
|
||||
|
||||
jdenticon();
|
||||
|
||||
var ctx = el.getContext("2d");
|
||||
if (ctx) {
|
||||
jdenticon.drawIcon(ctx, "value", 100);
|
||||
jdenticon.drawIcon(ctx, "value", 100, 0.08);
|
||||
jdenticon.drawIcon(ctx, "value", 100, config);
|
||||
}
|
||||
|
||||
// Ensure Jdenticon dodn't leak Node typings.
|
||||
// setTimeout returns a NodeJS.Timeout when the Node typings are loaded.
|
||||
const timeoutRef1: number = setTimeout(() => { }, 100);
|
||||
24
jdenticon-js/test/types/umd/jquery-test.ts
Normal file
24
jdenticon-js/test/types/umd/jquery-test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/// <reference types="jquery" />
|
||||
|
||||
const jqueryConfig: 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"
|
||||
};
|
||||
|
||||
$("canvas").jdenticon("value");
|
||||
$("canvas").jdenticon("value", 0.08);
|
||||
$("canvas").jdenticon("value", jqueryConfig);
|
||||
|
||||
// Ensure Jdenticon dodn't leak Node typings.
|
||||
// setTimeout returns a NodeJS.Timeout when the Node typings are loaded.
|
||||
const timeoutRef2: number = setTimeout(() => { }, 100);
|
||||
59
jdenticon-js/test/types/umd/module-test.ts
Normal file
59
jdenticon-js/test/types/umd/module-test.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { configure, drawIcon, update, updateSvg, updateCanvas, toPng, toSvg } from "jdenticon/standalone";
|
||||
|
||||
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 timeoutRef3: number = setTimeout(() => { }, 100);
|
||||
12
jdenticon-js/test/types/umd/tsconfig.json
Normal file
12
jdenticon-js/test/types/umd/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": [
|
||||
"jdenticon/standalone"
|
||||
],
|
||||
"lib": ["es6", "dom"],
|
||||
},
|
||||
"include": [
|
||||
"./*.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user