@dicebear/micah 5.0.0-alpha.3 → 5.0.0-alpha.32
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/components/base.d.ts +2 -0
- package/lib/components/base.js +7 -0
- package/lib/components/earrings.d.ts +2 -0
- package/lib/components/earrings.js +5 -0
- package/lib/components/ears.d.ts +2 -0
- package/lib/components/ears.js +11 -0
- package/lib/components/eyebrows.d.ts +2 -0
- package/lib/components/eyebrows.js +7 -0
- package/lib/components/eyes.d.ts +2 -0
- package/lib/components/eyes.js +19 -0
- package/lib/components/facialHair.d.ts +2 -0
- package/lib/components/facialHair.js +4 -0
- package/lib/components/glasses.d.ts +2 -0
- package/lib/components/glasses.js +5 -0
- package/lib/components/hair.d.ts +2 -0
- package/lib/components/hair.js +11 -0
- package/lib/components/index.d.ts +11 -0
- package/lib/components/index.js +11 -0
- package/lib/components/mouth.d.ts +2 -0
- package/lib/components/mouth.js +11 -0
- package/lib/components/nose.d.ts +2 -0
- package/lib/components/nose.js +5 -0
- package/lib/components/shirt.d.ts +2 -0
- package/lib/components/shirt.js +6 -0
- package/{dist → lib}/core.d.ts +3 -3
- package/lib/core.js +33 -0
- package/{dist → lib}/hooks/onPostCreate.d.ts +10 -12
- package/lib/hooks/onPostCreate.js +6 -0
- package/lib/hooks/onPreCreate.d.ts +8 -0
- package/lib/hooks/onPreCreate.js +26 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +13 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +303 -0
- package/lib/types.d.ts +39 -0
- package/lib/types.js +1 -0
- package/{dist → lib}/utils/getColors.d.ts +8 -9
- package/lib/utils/getColors.js +15 -0
- package/{dist → lib}/utils/getComponents.d.ts +8 -9
- package/lib/utils/getComponents.js +77 -0
- package/{dist → lib}/utils/pickComponent.d.ts +9 -9
- package/lib/utils/pickComponent.js +11 -0
- package/package.json +45 -49
- package/dist/colors/base.d.ts +0 -2
- package/dist/colors/earring.d.ts +0 -2
- package/dist/colors/eyeShadow.d.ts +0 -2
- package/dist/colors/eyebrow.d.ts +0 -2
- package/dist/colors/eyes.d.ts +0 -2
- package/dist/colors/facialHair.d.ts +0 -2
- package/dist/colors/glasses.d.ts +0 -2
- package/dist/colors/hair.d.ts +0 -2
- package/dist/colors/index.d.ts +0 -10
- package/dist/colors/mouth.d.ts +0 -2
- package/dist/colors/shirt.d.ts +0 -2
- package/dist/components/base.d.ts +0 -2
- package/dist/components/earrings.d.ts +0 -2
- package/dist/components/ears.d.ts +0 -2
- package/dist/components/eyebrows.d.ts +0 -2
- package/dist/components/eyes.d.ts +0 -2
- package/dist/components/facialHair.d.ts +0 -2
- package/dist/components/glasses.d.ts +0 -2
- package/dist/components/hair.d.ts +0 -2
- package/dist/components/index.d.ts +0 -11
- package/dist/components/mouth.d.ts +0 -2
- package/dist/components/nose.d.ts +0 -2
- package/dist/components/shirt.d.ts +0 -2
- package/dist/hooks/onPreCreate.d.ts +0 -9
- package/dist/index.d.ts +0 -13
- package/dist/index.es.js +0 -1247
- package/dist/index.js +0 -1254
- package/dist/index.umd.js +0 -12
- package/dist/meta/components.d.ts +0 -4
- package/dist/options.d.ts +0 -32
- package/dist/static-types.d.ts +0 -16
- package/dist/utils/pickColor.d.ts +0 -9
package/lib/schema.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
export const schema = {
|
|
2
|
+
title: 'Options',
|
|
3
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
4
|
+
properties: {
|
|
5
|
+
base: {
|
|
6
|
+
type: 'array',
|
|
7
|
+
items: { type: 'string', enum: ['standard'] },
|
|
8
|
+
default: ['standard'],
|
|
9
|
+
examples: [['standard']],
|
|
10
|
+
},
|
|
11
|
+
baseColor: {
|
|
12
|
+
type: 'array',
|
|
13
|
+
items: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
16
|
+
},
|
|
17
|
+
default: ['f9c9b6', 'ac6651', '77311d'],
|
|
18
|
+
},
|
|
19
|
+
earringColor: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
24
|
+
},
|
|
25
|
+
default: [
|
|
26
|
+
'f9c9b6',
|
|
27
|
+
'd2eff3',
|
|
28
|
+
'000000',
|
|
29
|
+
'e0ddff',
|
|
30
|
+
'f4d150',
|
|
31
|
+
'ac6651',
|
|
32
|
+
'9287ff',
|
|
33
|
+
'ffeba4',
|
|
34
|
+
'fc909f',
|
|
35
|
+
'ffedef',
|
|
36
|
+
'6bd9e9',
|
|
37
|
+
'77311d',
|
|
38
|
+
'ffffff',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
earrings: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: 'string', enum: ['hoop', 'stud'] },
|
|
44
|
+
default: ['hoop', 'stud'],
|
|
45
|
+
examples: [['hoop'], ['stud']],
|
|
46
|
+
},
|
|
47
|
+
earringsProbability: {
|
|
48
|
+
type: 'integer',
|
|
49
|
+
minimum: 0,
|
|
50
|
+
maximum: 100,
|
|
51
|
+
default: 30,
|
|
52
|
+
examples: [0, 100],
|
|
53
|
+
},
|
|
54
|
+
ears: {
|
|
55
|
+
type: 'array',
|
|
56
|
+
items: { type: 'string', enum: ['attached', 'detached'] },
|
|
57
|
+
default: ['attached', 'detached'],
|
|
58
|
+
examples: [['attached'], ['detached']],
|
|
59
|
+
},
|
|
60
|
+
eyeShadowColor: {
|
|
61
|
+
type: 'array',
|
|
62
|
+
items: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
65
|
+
},
|
|
66
|
+
default: ['d2eff3', 'e0ddff', 'ffeba4', 'ffedef', 'ffffff'],
|
|
67
|
+
},
|
|
68
|
+
eyebrows: {
|
|
69
|
+
type: 'array',
|
|
70
|
+
items: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
enum: ['up', 'down', 'eyelashesUp', 'eyelashesDown'],
|
|
73
|
+
},
|
|
74
|
+
default: ['up', 'down', 'eyelashesUp', 'eyelashesDown'],
|
|
75
|
+
examples: [['up'], ['down'], ['eyelashesUp'], ['eyelashesDown']],
|
|
76
|
+
},
|
|
77
|
+
eyebrowsColor: {
|
|
78
|
+
type: 'array',
|
|
79
|
+
items: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
82
|
+
},
|
|
83
|
+
default: ['000000'],
|
|
84
|
+
},
|
|
85
|
+
eyes: {
|
|
86
|
+
type: 'array',
|
|
87
|
+
items: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
enum: ['eyes', 'round', 'eyesShadow', 'smiling'],
|
|
90
|
+
},
|
|
91
|
+
default: ['eyes', 'round', 'eyesShadow', 'smiling'],
|
|
92
|
+
examples: [['eyes'], ['round'], ['eyesShadow'], ['smiling']],
|
|
93
|
+
},
|
|
94
|
+
eyesColor: {
|
|
95
|
+
type: 'array',
|
|
96
|
+
items: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
99
|
+
},
|
|
100
|
+
default: ['000000'],
|
|
101
|
+
},
|
|
102
|
+
facialHair: {
|
|
103
|
+
type: 'array',
|
|
104
|
+
items: { type: 'string', enum: ['beard', 'scruff'] },
|
|
105
|
+
default: ['beard', 'scruff'],
|
|
106
|
+
examples: [['beard'], ['scruff']],
|
|
107
|
+
},
|
|
108
|
+
facialHairColor: {
|
|
109
|
+
type: 'array',
|
|
110
|
+
items: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
113
|
+
},
|
|
114
|
+
default: ['77311d'],
|
|
115
|
+
},
|
|
116
|
+
facialHairProbability: {
|
|
117
|
+
type: 'integer',
|
|
118
|
+
minimum: 0,
|
|
119
|
+
maximum: 100,
|
|
120
|
+
default: 10,
|
|
121
|
+
examples: [0, 100],
|
|
122
|
+
},
|
|
123
|
+
glasses: {
|
|
124
|
+
type: 'array',
|
|
125
|
+
items: { type: 'string', enum: ['round', 'square'] },
|
|
126
|
+
default: ['round', 'square'],
|
|
127
|
+
examples: [['round'], ['square']],
|
|
128
|
+
},
|
|
129
|
+
glassesColor: {
|
|
130
|
+
type: 'array',
|
|
131
|
+
items: {
|
|
132
|
+
type: 'string',
|
|
133
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
134
|
+
},
|
|
135
|
+
default: [
|
|
136
|
+
'f9c9b6',
|
|
137
|
+
'd2eff3',
|
|
138
|
+
'000000',
|
|
139
|
+
'e0ddff',
|
|
140
|
+
'f4d150',
|
|
141
|
+
'ac6651',
|
|
142
|
+
'9287ff',
|
|
143
|
+
'ffeba4',
|
|
144
|
+
'fc909f',
|
|
145
|
+
'ffedef',
|
|
146
|
+
'6bd9e9',
|
|
147
|
+
'77311d',
|
|
148
|
+
'ffffff',
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
glassesProbability: {
|
|
152
|
+
type: 'integer',
|
|
153
|
+
minimum: 0,
|
|
154
|
+
maximum: 100,
|
|
155
|
+
default: 30,
|
|
156
|
+
examples: [0, 100],
|
|
157
|
+
},
|
|
158
|
+
hair: {
|
|
159
|
+
type: 'array',
|
|
160
|
+
items: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
enum: [
|
|
163
|
+
'fonze',
|
|
164
|
+
'mrT',
|
|
165
|
+
'dougFunny',
|
|
166
|
+
'mrClean',
|
|
167
|
+
'dannyPhantom',
|
|
168
|
+
'full',
|
|
169
|
+
'turban',
|
|
170
|
+
'pixie',
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
default: [
|
|
174
|
+
'fonze',
|
|
175
|
+
'mrT',
|
|
176
|
+
'dougFunny',
|
|
177
|
+
'mrClean',
|
|
178
|
+
'dannyPhantom',
|
|
179
|
+
'full',
|
|
180
|
+
'turban',
|
|
181
|
+
'pixie',
|
|
182
|
+
],
|
|
183
|
+
examples: [
|
|
184
|
+
['fonze'],
|
|
185
|
+
['mrT'],
|
|
186
|
+
['dougFunny'],
|
|
187
|
+
['mrClean'],
|
|
188
|
+
['dannyPhantom'],
|
|
189
|
+
['full'],
|
|
190
|
+
['turban'],
|
|
191
|
+
['pixie'],
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
hairColor: {
|
|
195
|
+
type: 'array',
|
|
196
|
+
items: {
|
|
197
|
+
type: 'string',
|
|
198
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
199
|
+
},
|
|
200
|
+
default: [
|
|
201
|
+
'f9c9b6',
|
|
202
|
+
'd2eff3',
|
|
203
|
+
'000000',
|
|
204
|
+
'e0ddff',
|
|
205
|
+
'f4d150',
|
|
206
|
+
'ac6651',
|
|
207
|
+
'9287ff',
|
|
208
|
+
'ffeba4',
|
|
209
|
+
'fc909f',
|
|
210
|
+
'ffedef',
|
|
211
|
+
'6bd9e9',
|
|
212
|
+
'77311d',
|
|
213
|
+
'ffffff',
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
hairProbability: {
|
|
217
|
+
type: 'integer',
|
|
218
|
+
minimum: 0,
|
|
219
|
+
maximum: 100,
|
|
220
|
+
default: 100,
|
|
221
|
+
examples: [0, 100],
|
|
222
|
+
},
|
|
223
|
+
mouth: {
|
|
224
|
+
type: 'array',
|
|
225
|
+
items: {
|
|
226
|
+
type: 'string',
|
|
227
|
+
enum: [
|
|
228
|
+
'surprised',
|
|
229
|
+
'laughing',
|
|
230
|
+
'nervous',
|
|
231
|
+
'smile',
|
|
232
|
+
'sad',
|
|
233
|
+
'pucker',
|
|
234
|
+
'frown',
|
|
235
|
+
'smirk',
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
default: [
|
|
239
|
+
'surprised',
|
|
240
|
+
'laughing',
|
|
241
|
+
'nervous',
|
|
242
|
+
'smile',
|
|
243
|
+
'sad',
|
|
244
|
+
'pucker',
|
|
245
|
+
'frown',
|
|
246
|
+
'smirk',
|
|
247
|
+
],
|
|
248
|
+
examples: [
|
|
249
|
+
['surprised'],
|
|
250
|
+
['laughing'],
|
|
251
|
+
['nervous'],
|
|
252
|
+
['smile'],
|
|
253
|
+
['sad'],
|
|
254
|
+
['pucker'],
|
|
255
|
+
['frown'],
|
|
256
|
+
['smirk'],
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
mouthColor: {
|
|
260
|
+
type: 'array',
|
|
261
|
+
items: {
|
|
262
|
+
type: 'string',
|
|
263
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
264
|
+
},
|
|
265
|
+
default: ['000000'],
|
|
266
|
+
},
|
|
267
|
+
nose: {
|
|
268
|
+
type: 'array',
|
|
269
|
+
items: { type: 'string', enum: ['curve', 'pointed', 'tound'] },
|
|
270
|
+
default: ['curve', 'pointed', 'tound'],
|
|
271
|
+
examples: [['curve'], ['pointed'], ['tound']],
|
|
272
|
+
},
|
|
273
|
+
shirt: {
|
|
274
|
+
type: 'array',
|
|
275
|
+
items: { type: 'string', enum: ['open', 'crew', 'collared'] },
|
|
276
|
+
default: ['open', 'crew', 'collared'],
|
|
277
|
+
examples: [['open'], ['crew'], ['collared']],
|
|
278
|
+
},
|
|
279
|
+
shirtColor: {
|
|
280
|
+
type: 'array',
|
|
281
|
+
items: {
|
|
282
|
+
type: 'string',
|
|
283
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
284
|
+
},
|
|
285
|
+
default: [
|
|
286
|
+
'f9c9b6',
|
|
287
|
+
'd2eff3',
|
|
288
|
+
'000000',
|
|
289
|
+
'e0ddff',
|
|
290
|
+
'f4d150',
|
|
291
|
+
'ac6651',
|
|
292
|
+
'9287ff',
|
|
293
|
+
'ffeba4',
|
|
294
|
+
'fc909f',
|
|
295
|
+
'ffedef',
|
|
296
|
+
'6bd9e9',
|
|
297
|
+
'77311d',
|
|
298
|
+
'ffffff',
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
additionalProperties: false,
|
|
303
|
+
};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
base?: ('standard')[];
|
|
3
|
+
mouth?: ('surprised' | 'laughing' | 'nervous' | 'smile' | 'sad' | 'pucker' | 'frown' | 'smirk')[];
|
|
4
|
+
eyebrows?: ('up' | 'down' | 'eyelashesUp' | 'eyelashesDown')[];
|
|
5
|
+
hair?: ('fonze' | 'mrT' | 'dougFunny' | 'mrClean' | 'dannyPhantom' | 'full' | 'turban' | 'pixie')[];
|
|
6
|
+
hairProbability?: number;
|
|
7
|
+
eyes?: ('eyes' | 'round' | 'eyesShadow' | 'smiling')[];
|
|
8
|
+
nose?: ('curve' | 'pointed' | 'tound')[];
|
|
9
|
+
ears?: ('attached' | 'detached')[];
|
|
10
|
+
shirt?: ('open' | 'crew' | 'collared')[];
|
|
11
|
+
earrings?: ('hoop' | 'stud')[];
|
|
12
|
+
earringsProbability?: number;
|
|
13
|
+
glasses?: ('round' | 'square')[];
|
|
14
|
+
glassesProbability?: number;
|
|
15
|
+
facialHair?: ('beard' | 'scruff')[];
|
|
16
|
+
facialHairProbability?: number;
|
|
17
|
+
baseColor?: string[];
|
|
18
|
+
earringColor?: string[];
|
|
19
|
+
eyeShadowColor?: string[];
|
|
20
|
+
eyebrowsColor?: string[];
|
|
21
|
+
facialHairColor?: string[];
|
|
22
|
+
glassesColor?: string[];
|
|
23
|
+
hairColor?: string[];
|
|
24
|
+
mouthColor?: string[];
|
|
25
|
+
shirtColor?: string[];
|
|
26
|
+
eyesColor?: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare type ColorGroup = Record<string, ColorGroupItem>;
|
|
29
|
+
export declare type ColorGroupCollection = Record<string, ColorGroup>;
|
|
30
|
+
export declare type ColorGroupItem = string;
|
|
31
|
+
export declare type ColorPickCollection = Record<string, string>;
|
|
32
|
+
export declare type ComponentGroup = Record<string, ComponentGroupItem>;
|
|
33
|
+
export declare type ComponentGroupCollection = Record<string, ComponentGroup>;
|
|
34
|
+
export declare type ComponentGroupItem = (components: ComponentPickCollection, colors: ColorPickCollection) => string;
|
|
35
|
+
export declare type ComponentPickCollection = Record<string, ComponentPick>;
|
|
36
|
+
export declare type ComponentPick = {
|
|
37
|
+
name: string;
|
|
38
|
+
value: ComponentGroupItem;
|
|
39
|
+
} | 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 {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getColors({ prng, options }) {
|
|
2
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3
|
+
return {
|
|
4
|
+
base: (_b = prng.pick((_a = options.baseColor) !== null && _a !== void 0 ? _a : [])) !== null && _b !== void 0 ? _b : 'transparent',
|
|
5
|
+
earring: (_d = prng.pick((_c = options.earringColor) !== null && _c !== void 0 ? _c : [])) !== null && _d !== void 0 ? _d : 'transparent',
|
|
6
|
+
eyeShadow: (_f = prng.pick((_e = options.eyeShadowColor) !== null && _e !== void 0 ? _e : [])) !== null && _f !== void 0 ? _f : 'transparent',
|
|
7
|
+
eyebrows: (_h = prng.pick((_g = options.eyebrowsColor) !== null && _g !== void 0 ? _g : [])) !== null && _h !== void 0 ? _h : 'transparent',
|
|
8
|
+
facialHair: (_k = prng.pick((_j = options.facialHairColor) !== null && _j !== void 0 ? _j : [])) !== null && _k !== void 0 ? _k : 'transparent',
|
|
9
|
+
glasses: (_m = prng.pick((_l = options.glassesColor) !== null && _l !== void 0 ? _l : [])) !== null && _m !== void 0 ? _m : 'transparent',
|
|
10
|
+
hair: (_p = prng.pick((_o = options.hairColor) !== null && _o !== void 0 ? _o : [])) !== null && _p !== void 0 ? _p : 'transparent',
|
|
11
|
+
mouth: (_r = prng.pick((_q = options.mouthColor) !== null && _q !== void 0 ? _q : [])) !== null && _r !== void 0 ? _r : 'transparent',
|
|
12
|
+
shirt: (_t = prng.pick((_s = options.shirtColor) !== null && _s !== void 0 ? _s : [])) !== null && _t !== void 0 ? _t : 'transparent',
|
|
13
|
+
eyes: (_v = prng.pick((_u = options.eyesColor) !== null && _u !== void 0 ? _u : [])) !== null && _v !== void 0 ? _v : 'transparent',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -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,77 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const baseComponent = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'base',
|
|
6
|
+
values: options.base,
|
|
7
|
+
});
|
|
8
|
+
const mouthComponent = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'mouth',
|
|
11
|
+
values: options.mouth,
|
|
12
|
+
});
|
|
13
|
+
const eyebrowsComponent = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'eyebrows',
|
|
16
|
+
values: options.eyebrows,
|
|
17
|
+
});
|
|
18
|
+
const hairComponent = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'hair',
|
|
21
|
+
values: options.hair,
|
|
22
|
+
});
|
|
23
|
+
const eyesComponent = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'eyes',
|
|
26
|
+
values: options.eyes,
|
|
27
|
+
});
|
|
28
|
+
const noseComponent = pickComponent({
|
|
29
|
+
prng,
|
|
30
|
+
group: 'nose',
|
|
31
|
+
values: options.nose,
|
|
32
|
+
});
|
|
33
|
+
const earsComponent = pickComponent({
|
|
34
|
+
prng,
|
|
35
|
+
group: 'ears',
|
|
36
|
+
values: options.ears,
|
|
37
|
+
});
|
|
38
|
+
const shirtComponent = pickComponent({
|
|
39
|
+
prng,
|
|
40
|
+
group: 'shirt',
|
|
41
|
+
values: options.shirt,
|
|
42
|
+
});
|
|
43
|
+
const earringsComponent = pickComponent({
|
|
44
|
+
prng,
|
|
45
|
+
group: 'earrings',
|
|
46
|
+
values: options.earrings,
|
|
47
|
+
});
|
|
48
|
+
const glassesComponent = pickComponent({
|
|
49
|
+
prng,
|
|
50
|
+
group: 'glasses',
|
|
51
|
+
values: options.glasses,
|
|
52
|
+
});
|
|
53
|
+
const facialHairComponent = pickComponent({
|
|
54
|
+
prng,
|
|
55
|
+
group: 'facialHair',
|
|
56
|
+
values: options.facialHair,
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
base: baseComponent,
|
|
60
|
+
mouth: mouthComponent,
|
|
61
|
+
eyebrows: eyebrowsComponent,
|
|
62
|
+
hair: prng.bool(options.hairProbability) ? hairComponent : undefined,
|
|
63
|
+
eyes: eyesComponent,
|
|
64
|
+
nose: noseComponent,
|
|
65
|
+
ears: earsComponent,
|
|
66
|
+
shirt: shirtComponent,
|
|
67
|
+
earrings: prng.bool(options.earringsProbability)
|
|
68
|
+
? earringsComponent
|
|
69
|
+
: undefined,
|
|
70
|
+
glasses: prng.bool(options.glassesProbability)
|
|
71
|
+
? glassesComponent
|
|
72
|
+
: undefined,
|
|
73
|
+
facialHair: prng.bool(options.facialHairProbability)
|
|
74
|
+
? facialHairComponent
|
|
75
|
+
: undefined,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -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,11 @@
|
|
|
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 (key && componentCollection[group][key]) {
|
|
6
|
+
return { name: key, value: componentCollection[group][key] };
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
49
|
-
},
|
|
50
|
-
"gitHead": "58ad93754978edcb8f0928e5cd3af2f4d06186da"
|
|
2
|
+
"name": "@dicebear/micah",
|
|
3
|
+
"version": "5.0.0-alpha.32",
|
|
4
|
+
"description": "Avatar style for DiceBear",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dicebear"
|
|
7
|
+
],
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/dicebear/dicebear/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/dicebear/dicebear.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": "./lib/index.js",
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"lib",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prebuild": "del-cli lib",
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"prepublishOnly": "npm run build",
|
|
28
|
+
"test": "uvu tests"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@dicebear/core": "^5.0.0-alpha.32",
|
|
32
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
33
|
+
"del-cli": "^4.0.1",
|
|
34
|
+
"typescript": "^4.6.3",
|
|
35
|
+
"uvu": "^0.5.3"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@dicebear/core": "^5.0.0-alpha.21"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "5a4a06cbb8aca42a5d19da8e704b3a7b3a45d755"
|
|
51
47
|
}
|
package/dist/colors/base.d.ts
DELETED
package/dist/colors/earring.d.ts
DELETED
package/dist/colors/eyebrow.d.ts
DELETED
package/dist/colors/eyes.d.ts
DELETED
package/dist/colors/glasses.d.ts
DELETED
package/dist/colors/hair.d.ts
DELETED
package/dist/colors/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { base } from './base';
|
|
2
|
-
export { earring } from './earring';
|
|
3
|
-
export { eyeShadow } from './eyeShadow';
|
|
4
|
-
export { eyebrow } from './eyebrow';
|
|
5
|
-
export { facialHair } from './facialHair';
|
|
6
|
-
export { glasses } from './glasses';
|
|
7
|
-
export { hair } from './hair';
|
|
8
|
-
export { mouth } from './mouth';
|
|
9
|
-
export { shirt } from './shirt';
|
|
10
|
-
export { eyes } from './eyes';
|
package/dist/colors/mouth.d.ts
DELETED
package/dist/colors/shirt.d.ts
DELETED