@dicebear/identicon 5.0.0-alpha.3 → 5.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/colors/index.d.ts +1 -0
- package/lib/colors/index.js +1 -0
- package/lib/colors/row.d.ts +2 -0
- package/lib/colors/row.js +21 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/row1.d.ts +2 -0
- package/lib/components/row1.js +10 -0
- package/lib/components/row2.d.ts +2 -0
- package/lib/components/row2.js +10 -0
- package/lib/components/row3.d.ts +2 -0
- package/lib/components/row3.js +10 -0
- package/lib/components/row4.d.ts +2 -0
- package/lib/components/row4.js +10 -0
- package/lib/components/row5.d.ts +2 -0
- package/lib/components/row5.js +10 -0
- package/{dist → lib}/core.d.ts +3 -3
- package/lib/core.js +31 -0
- package/{dist → lib}/hooks/onPostCreate.d.ts +10 -12
- package/lib/hooks/onPostCreate.js +3 -0
- package/lib/hooks/onPreCreate.d.ts +8 -0
- package/lib/hooks/onPreCreate.js +3 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +12 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +141 -0
- package/{dist/static-types.d.ts → lib/types.d.ts} +24 -16
- package/lib/types.js +1 -0
- package/{dist → lib}/utils/getColors.d.ts +8 -9
- package/lib/utils/getColors.js +10 -0
- package/{dist → lib}/utils/getComponents.d.ts +8 -9
- package/lib/utils/getComponents.js +35 -0
- package/{dist → lib}/utils/pickColor.d.ts +9 -9
- package/lib/utils/pickColor.js +13 -0
- package/{dist → lib}/utils/pickComponent.d.ts +9 -9
- package/lib/utils/pickComponent.js +14 -0
- package/package.json +19 -23
- package/dist/colors/index.d.ts +0 -1
- package/dist/colors/row.d.ts +0 -2
- package/dist/components/index.d.ts +0 -5
- package/dist/components/row1.d.ts +0 -2
- package/dist/components/row2.d.ts +0 -2
- package/dist/components/row3.d.ts +0 -2
- package/dist/components/row4.d.ts +0 -2
- package/dist/components/row5.d.ts +0 -2
- package/dist/hooks/onPreCreate.d.ts +0 -9
- package/dist/index.d.ts +0 -12
- package/dist/index.es.js +0 -520
- package/dist/index.js +0 -527
- package/dist/index.umd.js +0 -11
- package/dist/meta/components.d.ts +0 -4
- package/dist/options.d.ts +0 -18
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { row } from './row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { row } from './row.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const row = {
|
|
2
|
+
red: 'rgba(229, 57, 53, 1)',
|
|
3
|
+
amber: 'rgba(255, 179, 0, 1)',
|
|
4
|
+
blue: 'rgba(30, 136, 229, 1)',
|
|
5
|
+
blueGray: 'rgba(84, 110, 122, 1)',
|
|
6
|
+
brown: 'rgba(109, 76, 65, 1)',
|
|
7
|
+
cyan: 'rgba(0, 172, 193, 1)',
|
|
8
|
+
deepOrange: 'rgba(244, 81, 30, 1)',
|
|
9
|
+
deepPurple: 'rgba(94, 53, 177, 1)',
|
|
10
|
+
green: 'rgba(67, 160, 71, 1)',
|
|
11
|
+
grey: 'rgba(117, 117, 117, 1)',
|
|
12
|
+
indigo: 'rgba(57, 73, 171, 1)',
|
|
13
|
+
lightBlue: 'rgba(3, 155, 229, 1)',
|
|
14
|
+
lightGreen: 'rgba(124, 179, 66, 1)',
|
|
15
|
+
lime: 'rgba(192, 202, 51, 1)',
|
|
16
|
+
orange: 'rgba(251, 140, 0, 1)',
|
|
17
|
+
pink: 'rgba(216, 27, 96, 1)',
|
|
18
|
+
purple: 'rgba(142, 36, 170, 1)',
|
|
19
|
+
teal: 'rgba(0, 137, 123, 1)',
|
|
20
|
+
yellow: 'rgba(253, 216, 53, 1)',
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { escape } from '@dicebear/core';
|
|
2
|
+
export const row1 = {
|
|
3
|
+
xooox: (components, colors) => `<path d="M1 0H0v1h1V0ZM5 0H4v1h1V0Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
4
|
+
xxoxx: (components, colors) => `<path d="M2 0H0v1h2V0ZM5 0H3v1h2V0Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
5
|
+
xoxox: (components, colors) => `<path d="M0 0h1v1H0V0ZM4 0h1v1H4V0ZM3 0H2v1h1V0Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
6
|
+
oxxxo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M1 0h3v1H1z"/>`,
|
|
7
|
+
xxxxx: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M0 0h5v1H0z"/>`,
|
|
8
|
+
oxoxo: (components, colors) => `<path d="M2 0H1v1h1V0ZM4 0H3v1h1V0Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
9
|
+
ooxoo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M2 0h1v1H2z"/>`,
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { escape } from '@dicebear/core';
|
|
2
|
+
export const row2 = {
|
|
3
|
+
xooox: (components, colors) => `<path d="M1 1H0v1h1V1ZM5 1H4v1h1V1Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
4
|
+
xxoxx: (components, colors) => `<path d="M2 1H0v1h2V1ZM5 1H3v1h2V1Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
5
|
+
xoxox: (components, colors) => `<path d="M0 1h1v1H0V1ZM4 1h1v1H4V1ZM3 1H2v1h1V1Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
6
|
+
oxxxo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M1 1h3v1H1z"/>`,
|
|
7
|
+
xxxxx: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M0 1h5v1H0z"/>`,
|
|
8
|
+
oxoxo: (components, colors) => `<path d="M2 1H1v1h1V1ZM4 1H3v1h1V1Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
9
|
+
ooxoo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M2 1h1v1H2z"/>`,
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { escape } from '@dicebear/core';
|
|
2
|
+
export const row3 = {
|
|
3
|
+
xooox: (components, colors) => `<path d="M1 2H0v1h1V2ZM5 2H4v1h1V2Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
4
|
+
xxoxx: (components, colors) => `<path d="M2 2H0v1h2V2ZM5 2H3v1h2V2Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
5
|
+
xoxox: (components, colors) => `<path d="M0 2h1v1H0V2ZM4 2h1v1H4V2ZM3 2H2v1h1V2Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
6
|
+
oxxxo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M1 2h3v1H1z"/>`,
|
|
7
|
+
xxxxx: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M0 2h5v1H0z"/>`,
|
|
8
|
+
oxoxo: (components, colors) => `<path d="M2 2H1v1h1V2ZM4 2H3v1h1V2Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
9
|
+
ooxoo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M2 2h1v1H2z"/>`,
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { escape } from '@dicebear/core';
|
|
2
|
+
export const row4 = {
|
|
3
|
+
xooox: (components, colors) => `<path d="M1 3H0v1h1V3ZM5 3H4v1h1V3Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
4
|
+
xxoxx: (components, colors) => `<path d="M2 3H0v1h2V3ZM5 3H3v1h2V3Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
5
|
+
xoxox: (components, colors) => `<path d="M0 3h1v1H0V3ZM4 3h1v1H4V3ZM3 3H2v1h1V3Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
6
|
+
oxxxo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M1 3h3v1H1z"/>`,
|
|
7
|
+
xxxxx: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M0 3h5v1H0z"/>`,
|
|
8
|
+
oxoxo: (components, colors) => `<path d="M2 3H1v1h1V3ZM4 3H3v1h1V3Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
9
|
+
ooxoo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M2 3h1v1H2z"/>`,
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { escape } from '@dicebear/core';
|
|
2
|
+
export const row5 = {
|
|
3
|
+
xooox: (components, colors) => `<path d="M1 4H0v1h1V4ZM5 4H4v1h1V4Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
4
|
+
xxoxx: (components, colors) => `<path d="M2 4H0v1h2V4ZM5 4H3v1h2V4Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
5
|
+
xoxox: (components, colors) => `<path d="M0 4h1v1H0V4ZM4 4h1v1H4V4ZM3 4H2v1h1V4Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
6
|
+
oxxxo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M1 4h3v1H1z"/>`,
|
|
7
|
+
xxxxx: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M0 4h5v1H0z"/>`,
|
|
8
|
+
oxoxo: (components, colors) => `<path d="M2 4H1v1h1V4ZM4 4H3v1h1V4Z" fill="${escape.xml(colors.row.value)}"/>`,
|
|
9
|
+
ooxoo: (components, colors) => `<path fill="${escape.xml(colors.row.value)}" d="M2 4h1v1H2z"/>`,
|
|
10
|
+
};
|
package/{dist → lib}/core.d.ts
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Style } from '@dicebear/core';
|
|
2
|
-
import type { Options } from './
|
|
3
|
-
export declare const style: Style<Options>;
|
|
1
|
+
import type { Style } from '@dicebear/core';
|
|
2
|
+
import type { Options } from './types.js';
|
|
3
|
+
export declare const style: Style<Options>;
|
package/lib/core.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { schema } from './schema.js';
|
|
2
|
+
import { getComponents } from './utils/getComponents.js';
|
|
3
|
+
import { getColors } from './utils/getColors.js';
|
|
4
|
+
import { onPreCreate } from './hooks/onPreCreate.js';
|
|
5
|
+
import { onPostCreate } from './hooks/onPostCreate.js';
|
|
6
|
+
export const style = {
|
|
7
|
+
meta: {
|
|
8
|
+
title: 'Identicon',
|
|
9
|
+
creator: 'Florian Körner',
|
|
10
|
+
license: {
|
|
11
|
+
name: 'CC0 1.0',
|
|
12
|
+
url: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
schema: schema,
|
|
16
|
+
create: ({ prng, options }) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
18
|
+
onPreCreate({ prng, options });
|
|
19
|
+
const components = getComponents({ prng, options });
|
|
20
|
+
const colors = getColors({ prng, options });
|
|
21
|
+
onPostCreate({ prng, options, components, colors });
|
|
22
|
+
return {
|
|
23
|
+
attributes: {
|
|
24
|
+
viewBox: '0 0 5 5',
|
|
25
|
+
fill: 'none',
|
|
26
|
+
'shape-rendering': 'crispEdges',
|
|
27
|
+
},
|
|
28
|
+
body: `${(_b = (_a = components.row1) === null || _a === void 0 ? void 0 : _a.value(components, colors)) !== null && _b !== void 0 ? _b : ''}${(_d = (_c = components.row2) === null || _c === void 0 ? void 0 : _c.value(components, colors)) !== null && _d !== void 0 ? _d : ''}${(_f = (_e = components.row3) === null || _e === void 0 ? void 0 : _e.value(components, colors)) !== null && _f !== void 0 ? _f : ''}${(_h = (_g = components.row4) === null || _g === void 0 ? void 0 : _g.value(components, colors)) !== null && _h !== void 0 ? _h : ''}${(_k = (_j = components.row5) === null || _j === void 0 ? void 0 : _j.value(components, colors)) !== null && _k !== void 0 ? _k : ''}`,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Prng, StyleOptions } from '@dicebear/core';
|
|
2
|
-
import { Options } from '../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export declare function onPostCreate({ prng, options, components, colors, preview, }: Props): void;
|
|
12
|
-
export {};
|
|
1
|
+
import { Prng, StyleOptions } from '@dicebear/core';
|
|
2
|
+
import { Options, ColorPickCollection, ComponentPickCollection } from '../types.js';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
prng: Prng;
|
|
5
|
+
options: StyleOptions<Options>;
|
|
6
|
+
components: ComponentPickCollection;
|
|
7
|
+
colors: ColorPickCollection;
|
|
8
|
+
};
|
|
9
|
+
export declare function onPostCreate({ prng, options, components, colors }: Props): void;
|
|
10
|
+
export {};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Identicon (@dicebear/identicon)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT License.
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
|
+
*
|
|
7
|
+
* Design "Identicon" by Florian Körner licensed under CC0 1.0.
|
|
8
|
+
* License: https://creativecommons.org/publicdomain/zero/1.0/
|
|
9
|
+
*/
|
|
10
|
+
declare const create: import("@dicebear/core").StyleCreate<import("./types.js").Options>, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
|
|
11
|
+
export { create, meta, schema };
|
|
12
|
+
export type { Options } from './types.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Identicon (@dicebear/identicon)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT License.
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
|
+
*
|
|
7
|
+
* Design "Identicon" by Florian Körner licensed under CC0 1.0.
|
|
8
|
+
* License: https://creativecommons.org/publicdomain/zero/1.0/
|
|
9
|
+
*/
|
|
10
|
+
import { style } from './core.js';
|
|
11
|
+
const { create, meta, schema } = style;
|
|
12
|
+
export { create, meta, schema };
|
package/lib/schema.d.ts
ADDED
package/lib/schema.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export const schema = {
|
|
2
|
+
title: 'Options',
|
|
3
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
4
|
+
properties: {
|
|
5
|
+
row1: {
|
|
6
|
+
type: 'array',
|
|
7
|
+
items: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
enum: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
10
|
+
},
|
|
11
|
+
default: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
12
|
+
examples: [
|
|
13
|
+
['xooox'],
|
|
14
|
+
['xxoxx'],
|
|
15
|
+
['xoxox'],
|
|
16
|
+
['oxxxo'],
|
|
17
|
+
['xxxxx'],
|
|
18
|
+
['oxoxo'],
|
|
19
|
+
['ooxoo'],
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
row2: {
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
enum: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
27
|
+
},
|
|
28
|
+
default: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
29
|
+
examples: [
|
|
30
|
+
['xooox'],
|
|
31
|
+
['xxoxx'],
|
|
32
|
+
['xoxox'],
|
|
33
|
+
['oxxxo'],
|
|
34
|
+
['xxxxx'],
|
|
35
|
+
['oxoxo'],
|
|
36
|
+
['ooxoo'],
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
row3: {
|
|
40
|
+
type: 'array',
|
|
41
|
+
items: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
enum: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
44
|
+
},
|
|
45
|
+
default: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
46
|
+
examples: [
|
|
47
|
+
['xooox'],
|
|
48
|
+
['xxoxx'],
|
|
49
|
+
['xoxox'],
|
|
50
|
+
['oxxxo'],
|
|
51
|
+
['xxxxx'],
|
|
52
|
+
['oxoxo'],
|
|
53
|
+
['ooxoo'],
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
row4: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
enum: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
61
|
+
},
|
|
62
|
+
default: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
63
|
+
examples: [
|
|
64
|
+
['xooox'],
|
|
65
|
+
['xxoxx'],
|
|
66
|
+
['xoxox'],
|
|
67
|
+
['oxxxo'],
|
|
68
|
+
['xxxxx'],
|
|
69
|
+
['oxoxo'],
|
|
70
|
+
['ooxoo'],
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
row5: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
items: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
enum: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
78
|
+
},
|
|
79
|
+
default: ['xooox', 'xxoxx', 'xoxox', 'oxxxo', 'xxxxx', 'oxoxo', 'ooxoo'],
|
|
80
|
+
examples: [
|
|
81
|
+
['xooox'],
|
|
82
|
+
['xxoxx'],
|
|
83
|
+
['xoxox'],
|
|
84
|
+
['oxxxo'],
|
|
85
|
+
['xxxxx'],
|
|
86
|
+
['oxoxo'],
|
|
87
|
+
['ooxoo'],
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
rowColor: {
|
|
91
|
+
type: 'array',
|
|
92
|
+
items: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
pattern: '^([0-9a-zA-Z]+|#[a-fA-F0-9]{3}|#[a-fA-F0-9]{4}|#[a-fA-F0-9]{6}|#[a-fA-F0-9]{8})$',
|
|
95
|
+
},
|
|
96
|
+
default: [
|
|
97
|
+
'red',
|
|
98
|
+
'amber',
|
|
99
|
+
'blue',
|
|
100
|
+
'blueGray',
|
|
101
|
+
'brown',
|
|
102
|
+
'cyan',
|
|
103
|
+
'deepOrange',
|
|
104
|
+
'deepPurple',
|
|
105
|
+
'green',
|
|
106
|
+
'grey',
|
|
107
|
+
'indigo',
|
|
108
|
+
'lightBlue',
|
|
109
|
+
'lightGreen',
|
|
110
|
+
'lime',
|
|
111
|
+
'orange',
|
|
112
|
+
'pink',
|
|
113
|
+
'purple',
|
|
114
|
+
'teal',
|
|
115
|
+
'yellow',
|
|
116
|
+
],
|
|
117
|
+
examples: [
|
|
118
|
+
['red'],
|
|
119
|
+
['amber'],
|
|
120
|
+
['blue'],
|
|
121
|
+
['blueGray'],
|
|
122
|
+
['brown'],
|
|
123
|
+
['cyan'],
|
|
124
|
+
['deepOrange'],
|
|
125
|
+
['deepPurple'],
|
|
126
|
+
['green'],
|
|
127
|
+
['grey'],
|
|
128
|
+
['indigo'],
|
|
129
|
+
['lightBlue'],
|
|
130
|
+
['lightGreen'],
|
|
131
|
+
['lime'],
|
|
132
|
+
['orange'],
|
|
133
|
+
['pink'],
|
|
134
|
+
['purple'],
|
|
135
|
+
['teal'],
|
|
136
|
+
['yellow'],
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
additionalProperties: false,
|
|
141
|
+
};
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export declare type
|
|
10
|
-
export declare type
|
|
11
|
-
export declare type
|
|
12
|
-
export declare type
|
|
13
|
-
export declare type
|
|
14
|
-
name: string;
|
|
15
|
-
value:
|
|
16
|
-
}
|
|
1
|
+
export interface Options {
|
|
2
|
+
row1?: ('xooox' | 'xxoxx' | 'xoxox' | 'oxxxo' | 'xxxxx' | 'oxoxo' | 'ooxoo')[];
|
|
3
|
+
row2?: ('xooox' | 'xxoxx' | 'xoxox' | 'oxxxo' | 'xxxxx' | 'oxoxo' | 'ooxoo')[];
|
|
4
|
+
row3?: ('xooox' | 'xxoxx' | 'xoxox' | 'oxxxo' | 'xxxxx' | 'oxoxo' | 'ooxoo')[];
|
|
5
|
+
row4?: ('xooox' | 'xxoxx' | 'xoxox' | 'oxxxo' | 'xxxxx' | 'oxoxo' | 'ooxoo')[];
|
|
6
|
+
row5?: ('xooox' | 'xxoxx' | 'xoxox' | 'oxxxo' | 'xxxxx' | 'oxoxo' | 'ooxoo')[];
|
|
7
|
+
rowColor?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare type ColorGroup = Record<string, ColorGroupItem>;
|
|
10
|
+
export declare type ColorGroupCollection = Record<string, ColorGroup>;
|
|
11
|
+
export declare type ColorGroupItem = string;
|
|
12
|
+
export declare type ColorPickCollection = Record<string, ColorPick>;
|
|
13
|
+
export declare type ColorPick = {
|
|
14
|
+
name: string;
|
|
15
|
+
value: ColorGroupItem;
|
|
16
|
+
};
|
|
17
|
+
export declare type ComponentGroup = Record<string, ComponentGroupItem>;
|
|
18
|
+
export declare type ComponentGroupCollection = Record<string, ComponentGroup>;
|
|
19
|
+
export declare type ComponentGroupItem = (components: ComponentPickCollection, colors: ColorPickCollection) => string;
|
|
20
|
+
export declare type ComponentPickCollection = Record<string, ComponentPick>;
|
|
21
|
+
export declare type ComponentPick = {
|
|
22
|
+
name: string;
|
|
23
|
+
value: ComponentGroupItem;
|
|
24
|
+
} | undefined;
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Prng } from '@dicebear/core';
|
|
2
|
-
import type { Options } from '../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export
|
|
9
|
-
export {};
|
|
1
|
+
import type { Prng } from '@dicebear/core';
|
|
2
|
+
import type { Options, ColorPickCollection } from '../types.js';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
prng: Prng;
|
|
5
|
+
options: Options;
|
|
6
|
+
};
|
|
7
|
+
export declare function getColors({ prng, options }: Props): ColorPickCollection;
|
|
8
|
+
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Prng } from '@dicebear/core';
|
|
2
|
-
import type { Options } from '../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export
|
|
9
|
-
export {};
|
|
1
|
+
import type { Prng } from '@dicebear/core';
|
|
2
|
+
import type { Options, ComponentPickCollection } from '../types.js';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
prng: Prng;
|
|
5
|
+
options: Options;
|
|
6
|
+
};
|
|
7
|
+
export declare function getComponents({ prng, options, }: Props): ComponentPickCollection;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const row1Component = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'row1',
|
|
6
|
+
values: options.row1,
|
|
7
|
+
});
|
|
8
|
+
const row2Component = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'row2',
|
|
11
|
+
values: options.row2,
|
|
12
|
+
});
|
|
13
|
+
const row3Component = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'row3',
|
|
16
|
+
values: options.row3,
|
|
17
|
+
});
|
|
18
|
+
const row4Component = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'row4',
|
|
21
|
+
values: options.row4,
|
|
22
|
+
});
|
|
23
|
+
const row5Component = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'row5',
|
|
26
|
+
values: options.row5,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
row1: row1Component,
|
|
30
|
+
row2: row2Component,
|
|
31
|
+
row3: row3Component,
|
|
32
|
+
row4: row4Component,
|
|
33
|
+
row5: row5Component,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Prng } from '@dicebear/core';
|
|
2
|
-
import type { ColorPick } from '../
|
|
3
|
-
declare type Props = {
|
|
4
|
-
prng: Prng;
|
|
5
|
-
group: string;
|
|
6
|
-
values?: string[];
|
|
7
|
-
};
|
|
8
|
-
export declare function pickColor({ prng, group, values }: Props): ColorPick;
|
|
9
|
-
export {};
|
|
1
|
+
import type { Prng } from '@dicebear/core';
|
|
2
|
+
import type { ColorPick } from '../types.js';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
prng: Prng;
|
|
5
|
+
group: string;
|
|
6
|
+
values?: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function pickColor({ prng, group, values }: Props): ColorPick;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as colors from '../colors/index.js';
|
|
2
|
+
export function pickColor({ prng, group, values = [] }) {
|
|
3
|
+
var _a;
|
|
4
|
+
const colorCollection = colors;
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
values.push('transparent');
|
|
7
|
+
}
|
|
8
|
+
const key = prng.pick(values);
|
|
9
|
+
return {
|
|
10
|
+
name: key,
|
|
11
|
+
value: (_a = colorCollection[group][key]) !== null && _a !== void 0 ? _a : key,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Prng } from '@dicebear/core';
|
|
2
|
-
import type { ComponentPick } from '../
|
|
3
|
-
declare type Props = {
|
|
4
|
-
prng: Prng;
|
|
5
|
-
group: string;
|
|
6
|
-
values?: string[];
|
|
7
|
-
};
|
|
8
|
-
export declare function pickComponent({ prng, group, values, }: Props): ComponentPick;
|
|
9
|
-
export {};
|
|
1
|
+
import type { Prng } from '@dicebear/core';
|
|
2
|
+
import type { ComponentPick } from '../types.js';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
prng: Prng;
|
|
5
|
+
group: string;
|
|
6
|
+
values?: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function pickComponent({ prng, group, values, }: Props): ComponentPick;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as components from '../components/index.js';
|
|
2
|
+
export function pickComponent({ prng, group, values = [], }) {
|
|
3
|
+
const componentCollection = components;
|
|
4
|
+
const key = prng.pick(values);
|
|
5
|
+
if (componentCollection[group][key]) {
|
|
6
|
+
return {
|
|
7
|
+
name: key,
|
|
8
|
+
value: componentCollection[group][key],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|