@dicebear/open-peeps 4.10.2 → 5.0.0-alpha.11
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/README.md +6 -5
- package/lib/colors/clothing.d.ts +2 -0
- package/lib/colors/clothing.js +9 -0
- package/lib/colors/hair.d.ts +2 -0
- package/lib/colors/hair.js +12 -0
- package/lib/colors/index.d.ts +3 -0
- package/lib/colors/index.js +3 -0
- package/lib/colors/skin.d.ts +2 -0
- package/lib/colors/skin.js +7 -0
- package/lib/components/accessories.d.ts +2 -0
- package/lib/components/accessories.js +10 -0
- package/lib/components/face.d.ts +2 -0
- package/lib/components/face.js +32 -0
- package/lib/components/facialHair.d.ts +2 -0
- package/lib/components/facialHair.js +18 -0
- package/lib/components/head.d.ts +2 -0
- package/lib/components/head.js +50 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/mask.d.ts +2 -0
- package/lib/components/mask.js +4 -0
- package/lib/core.d.ts +3 -0
- package/lib/core.js +64 -0
- package/lib/hooks/onPostCreate.d.ts +11 -0
- package/lib/hooks/onPostCreate.js +3 -0
- package/lib/hooks/onPreCreate.d.ts +9 -0
- package/lib/hooks/onPreCreate.js +3 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +13 -0
- package/lib/meta/components.d.ts +4 -0
- package/lib/meta/components.js +22 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +457 -0
- package/lib/types.d.ts +29 -0
- package/lib/types.js +1 -0
- package/lib/utils/getColors.d.ts +8 -0
- package/lib/utils/getColors.js +20 -0
- package/lib/utils/getComponents.d.ts +8 -0
- package/lib/utils/getComponents.js +39 -0
- package/lib/utils/pickColor.d.ts +9 -0
- package/lib/utils/pickColor.js +13 -0
- package/lib/utils/pickComponent.d.ts +9 -0
- package/lib/utils/pickComponent.js +14 -0
- package/package.json +21 -19
- package/dist/colors/clothing.d.ts +0 -2
- package/dist/colors/hair.d.ts +0 -2
- package/dist/colors/index.d.ts +0 -3
- package/dist/colors/skin.d.ts +0 -2
- package/dist/components/accessories.d.ts +0 -2
- package/dist/components/face.d.ts +0 -2
- package/dist/components/facialHair.d.ts +0 -2
- package/dist/components/head.d.ts +0 -2
- package/dist/components/index.d.ts +0 -5
- package/dist/components/mask.d.ts +0 -2
- package/dist/core.d.ts +0 -3
- package/dist/index.d.ts +0 -16
- package/dist/index.es.js +0 -380
- package/dist/index.js +0 -387
- package/dist/index.umd.js +0 -11
- package/dist/options.d.ts +0 -29
- package/dist/schema.d.ts +0 -2
- package/dist/static-types.d.ts +0 -16
- package/dist/utils/pickColor.d.ts +0 -3
- package/dist/utils/pickComponent.d.ts +0 -3
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Open Peeps (@dicebear/open-peeps)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT License.
|
|
5
|
+
* Copyright (c) 2021 Florian Körner
|
|
6
|
+
*
|
|
7
|
+
* Design "Open Peeps" by Pablo Stanley licensed under CC0 1.0.
|
|
8
|
+
* Source: https://www.openpeeps.com/
|
|
9
|
+
* License: https://creativecommons.org/publicdomain/zero/1.0/
|
|
10
|
+
*/
|
|
11
|
+
declare const create: import("@dicebear/core").StyleCreate<import("./types.js").Options>, preview: import("@dicebear/core").StylePreview<import("./types.js").Options> | undefined, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
|
|
12
|
+
export { create, preview, meta, schema };
|
|
13
|
+
export type { Options } from './types.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Open Peeps (@dicebear/open-peeps)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT License.
|
|
5
|
+
* Copyright (c) 2021 Florian Körner
|
|
6
|
+
*
|
|
7
|
+
* Design "Open Peeps" by Pablo Stanley licensed under CC0 1.0.
|
|
8
|
+
* Source: https://www.openpeeps.com/
|
|
9
|
+
* License: https://creativecommons.org/publicdomain/zero/1.0/
|
|
10
|
+
*/
|
|
11
|
+
import { style } from './core.js';
|
|
12
|
+
const { create, preview, meta, schema } = style;
|
|
13
|
+
export { create, preview, meta, schema };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const dimensions = {
|
|
2
|
+
head: {
|
|
3
|
+
width: 474,
|
|
4
|
+
height: 567,
|
|
5
|
+
},
|
|
6
|
+
face: {
|
|
7
|
+
width: 289,
|
|
8
|
+
height: 293,
|
|
9
|
+
},
|
|
10
|
+
facialHair: {
|
|
11
|
+
width: 280,
|
|
12
|
+
height: 230,
|
|
13
|
+
},
|
|
14
|
+
mask: {
|
|
15
|
+
width: 397,
|
|
16
|
+
height: 228,
|
|
17
|
+
},
|
|
18
|
+
accessories: {
|
|
19
|
+
width: 392,
|
|
20
|
+
height: 138,
|
|
21
|
+
},
|
|
22
|
+
};
|
package/lib/schema.d.ts
ADDED
package/lib/schema.js
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
export const schema = {
|
|
2
|
+
title: 'Options',
|
|
3
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
4
|
+
properties: {
|
|
5
|
+
accessories: {
|
|
6
|
+
type: 'array',
|
|
7
|
+
items: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
enum: [
|
|
10
|
+
'eyepatch',
|
|
11
|
+
'glasses',
|
|
12
|
+
'glasses2',
|
|
13
|
+
'glasses3',
|
|
14
|
+
'glasses4',
|
|
15
|
+
'glasses5',
|
|
16
|
+
'sunglasses',
|
|
17
|
+
'sunglasses2',
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
default: [
|
|
21
|
+
'eyepatch',
|
|
22
|
+
'glasses',
|
|
23
|
+
'glasses2',
|
|
24
|
+
'glasses3',
|
|
25
|
+
'glasses4',
|
|
26
|
+
'glasses5',
|
|
27
|
+
'sunglasses',
|
|
28
|
+
'sunglasses2',
|
|
29
|
+
],
|
|
30
|
+
examples: [
|
|
31
|
+
['eyepatch'],
|
|
32
|
+
['glasses'],
|
|
33
|
+
['glasses2'],
|
|
34
|
+
['glasses3'],
|
|
35
|
+
['glasses4'],
|
|
36
|
+
['glasses5'],
|
|
37
|
+
['sunglasses'],
|
|
38
|
+
['sunglasses2'],
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
accessoriesProbability: {
|
|
42
|
+
type: 'integer',
|
|
43
|
+
minimum: 0,
|
|
44
|
+
maximum: 100,
|
|
45
|
+
default: 20,
|
|
46
|
+
},
|
|
47
|
+
clothingColor: {
|
|
48
|
+
type: 'array',
|
|
49
|
+
items: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
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})$',
|
|
52
|
+
},
|
|
53
|
+
default: [
|
|
54
|
+
'red01',
|
|
55
|
+
'orange01',
|
|
56
|
+
'yellow01',
|
|
57
|
+
'green01',
|
|
58
|
+
'tail01',
|
|
59
|
+
'blue01',
|
|
60
|
+
'pink01',
|
|
61
|
+
],
|
|
62
|
+
examples: [
|
|
63
|
+
['red01'],
|
|
64
|
+
['orange01'],
|
|
65
|
+
['yellow01'],
|
|
66
|
+
['green01'],
|
|
67
|
+
['tail01'],
|
|
68
|
+
['blue01'],
|
|
69
|
+
['pink01'],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
face: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
items: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
enum: [
|
|
77
|
+
'angryWithFang',
|
|
78
|
+
'awe',
|
|
79
|
+
'blank',
|
|
80
|
+
'calm',
|
|
81
|
+
'cheeky',
|
|
82
|
+
'concerned',
|
|
83
|
+
'concernedFear',
|
|
84
|
+
'contempt',
|
|
85
|
+
'cute',
|
|
86
|
+
'cyclops',
|
|
87
|
+
'driven',
|
|
88
|
+
'eatingHappy',
|
|
89
|
+
'explaining',
|
|
90
|
+
'eyesClosed',
|
|
91
|
+
'fear',
|
|
92
|
+
'hectic',
|
|
93
|
+
'lovingGrin1',
|
|
94
|
+
'lovingGrin2',
|
|
95
|
+
'monster',
|
|
96
|
+
'old',
|
|
97
|
+
'rage',
|
|
98
|
+
'serious',
|
|
99
|
+
'smile',
|
|
100
|
+
'smileBig',
|
|
101
|
+
'smileLOL',
|
|
102
|
+
'smileTeethGap',
|
|
103
|
+
'solemn',
|
|
104
|
+
'suspicious',
|
|
105
|
+
'tired',
|
|
106
|
+
'veryAngry',
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
default: [
|
|
110
|
+
'angryWithFang',
|
|
111
|
+
'awe',
|
|
112
|
+
'blank',
|
|
113
|
+
'calm',
|
|
114
|
+
'cheeky',
|
|
115
|
+
'concerned',
|
|
116
|
+
'concernedFear',
|
|
117
|
+
'contempt',
|
|
118
|
+
'cute',
|
|
119
|
+
'cyclops',
|
|
120
|
+
'driven',
|
|
121
|
+
'eatingHappy',
|
|
122
|
+
'explaining',
|
|
123
|
+
'eyesClosed',
|
|
124
|
+
'fear',
|
|
125
|
+
'hectic',
|
|
126
|
+
'lovingGrin1',
|
|
127
|
+
'lovingGrin2',
|
|
128
|
+
'monster',
|
|
129
|
+
'old',
|
|
130
|
+
'rage',
|
|
131
|
+
'serious',
|
|
132
|
+
'smile',
|
|
133
|
+
'smileBig',
|
|
134
|
+
'smileLOL',
|
|
135
|
+
'smileTeethGap',
|
|
136
|
+
'solemn',
|
|
137
|
+
'suspicious',
|
|
138
|
+
'tired',
|
|
139
|
+
'veryAngry',
|
|
140
|
+
],
|
|
141
|
+
examples: [
|
|
142
|
+
['angryWithFang'],
|
|
143
|
+
['awe'],
|
|
144
|
+
['blank'],
|
|
145
|
+
['calm'],
|
|
146
|
+
['cheeky'],
|
|
147
|
+
['concerned'],
|
|
148
|
+
['concernedFear'],
|
|
149
|
+
['contempt'],
|
|
150
|
+
['cute'],
|
|
151
|
+
['cyclops'],
|
|
152
|
+
['driven'],
|
|
153
|
+
['eatingHappy'],
|
|
154
|
+
['explaining'],
|
|
155
|
+
['eyesClosed'],
|
|
156
|
+
['fear'],
|
|
157
|
+
['hectic'],
|
|
158
|
+
['lovingGrin1'],
|
|
159
|
+
['lovingGrin2'],
|
|
160
|
+
['monster'],
|
|
161
|
+
['old'],
|
|
162
|
+
['rage'],
|
|
163
|
+
['serious'],
|
|
164
|
+
['smile'],
|
|
165
|
+
['smileBig'],
|
|
166
|
+
['smileLOL'],
|
|
167
|
+
['smileTeethGap'],
|
|
168
|
+
['solemn'],
|
|
169
|
+
['suspicious'],
|
|
170
|
+
['tired'],
|
|
171
|
+
['veryAngry'],
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
facialHair: {
|
|
175
|
+
type: 'array',
|
|
176
|
+
items: {
|
|
177
|
+
type: 'string',
|
|
178
|
+
enum: [
|
|
179
|
+
'chin',
|
|
180
|
+
'full',
|
|
181
|
+
'full2',
|
|
182
|
+
'full3',
|
|
183
|
+
'full4',
|
|
184
|
+
'goatee1',
|
|
185
|
+
'goatee2',
|
|
186
|
+
'moustache1',
|
|
187
|
+
'moustache2',
|
|
188
|
+
'moustache3',
|
|
189
|
+
'moustache4',
|
|
190
|
+
'moustache5',
|
|
191
|
+
'moustache6',
|
|
192
|
+
'moustache7',
|
|
193
|
+
'moustache8',
|
|
194
|
+
'moustache9',
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
default: [
|
|
198
|
+
'chin',
|
|
199
|
+
'full',
|
|
200
|
+
'full2',
|
|
201
|
+
'full3',
|
|
202
|
+
'full4',
|
|
203
|
+
'goatee1',
|
|
204
|
+
'goatee2',
|
|
205
|
+
'moustache1',
|
|
206
|
+
'moustache2',
|
|
207
|
+
'moustache3',
|
|
208
|
+
'moustache4',
|
|
209
|
+
'moustache5',
|
|
210
|
+
'moustache6',
|
|
211
|
+
'moustache7',
|
|
212
|
+
'moustache8',
|
|
213
|
+
'moustache9',
|
|
214
|
+
],
|
|
215
|
+
examples: [
|
|
216
|
+
['chin'],
|
|
217
|
+
['full'],
|
|
218
|
+
['full2'],
|
|
219
|
+
['full3'],
|
|
220
|
+
['full4'],
|
|
221
|
+
['goatee1'],
|
|
222
|
+
['goatee2'],
|
|
223
|
+
['moustache1'],
|
|
224
|
+
['moustache2'],
|
|
225
|
+
['moustache3'],
|
|
226
|
+
['moustache4'],
|
|
227
|
+
['moustache5'],
|
|
228
|
+
['moustache6'],
|
|
229
|
+
['moustache7'],
|
|
230
|
+
['moustache8'],
|
|
231
|
+
['moustache9'],
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
facialHairProbability: {
|
|
235
|
+
type: 'integer',
|
|
236
|
+
minimum: 0,
|
|
237
|
+
maximum: 100,
|
|
238
|
+
default: 10,
|
|
239
|
+
},
|
|
240
|
+
hairColor: {
|
|
241
|
+
type: 'array',
|
|
242
|
+
items: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
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})$',
|
|
245
|
+
},
|
|
246
|
+
default: [
|
|
247
|
+
'variant01',
|
|
248
|
+
'variant02',
|
|
249
|
+
'variant03',
|
|
250
|
+
'variant04',
|
|
251
|
+
'variant05',
|
|
252
|
+
'variant06',
|
|
253
|
+
'variant07',
|
|
254
|
+
'variant08',
|
|
255
|
+
'variant09',
|
|
256
|
+
'variant10',
|
|
257
|
+
],
|
|
258
|
+
examples: [
|
|
259
|
+
['variant01'],
|
|
260
|
+
['variant02'],
|
|
261
|
+
['variant03'],
|
|
262
|
+
['variant04'],
|
|
263
|
+
['variant05'],
|
|
264
|
+
['variant06'],
|
|
265
|
+
['variant07'],
|
|
266
|
+
['variant08'],
|
|
267
|
+
['variant09'],
|
|
268
|
+
['variant10'],
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
head: {
|
|
272
|
+
type: 'array',
|
|
273
|
+
items: {
|
|
274
|
+
type: 'string',
|
|
275
|
+
enum: [
|
|
276
|
+
'afro',
|
|
277
|
+
'bangs',
|
|
278
|
+
'bangs2',
|
|
279
|
+
'bantuKnots',
|
|
280
|
+
'bear',
|
|
281
|
+
'bun',
|
|
282
|
+
'bun2',
|
|
283
|
+
'buns',
|
|
284
|
+
'cornrows',
|
|
285
|
+
'cornrows2',
|
|
286
|
+
'dreads1',
|
|
287
|
+
'dreads2',
|
|
288
|
+
'flatTop',
|
|
289
|
+
'flatTopLong',
|
|
290
|
+
'grayBun',
|
|
291
|
+
'grayMedium',
|
|
292
|
+
'grayShort',
|
|
293
|
+
'hatBeanie',
|
|
294
|
+
'hatHip',
|
|
295
|
+
'hijab',
|
|
296
|
+
'long',
|
|
297
|
+
'longAfro',
|
|
298
|
+
'longBangs',
|
|
299
|
+
'longCurly',
|
|
300
|
+
'medium1',
|
|
301
|
+
'medium2',
|
|
302
|
+
'medium3',
|
|
303
|
+
'mediumBangs',
|
|
304
|
+
'mediumBangs2',
|
|
305
|
+
'mediumBangs3',
|
|
306
|
+
'mediumStraight',
|
|
307
|
+
'mohawk',
|
|
308
|
+
'mohawk2',
|
|
309
|
+
'noHair1',
|
|
310
|
+
'noHair2',
|
|
311
|
+
'noHair3',
|
|
312
|
+
'pomp',
|
|
313
|
+
'shaved1',
|
|
314
|
+
'shaved2',
|
|
315
|
+
'shaved3',
|
|
316
|
+
'short1',
|
|
317
|
+
'short2',
|
|
318
|
+
'short3',
|
|
319
|
+
'short4',
|
|
320
|
+
'short5',
|
|
321
|
+
'turban',
|
|
322
|
+
'twists',
|
|
323
|
+
'twists2',
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
default: [
|
|
327
|
+
'afro',
|
|
328
|
+
'bangs',
|
|
329
|
+
'bangs2',
|
|
330
|
+
'bantuKnots',
|
|
331
|
+
'bear',
|
|
332
|
+
'bun',
|
|
333
|
+
'bun2',
|
|
334
|
+
'buns',
|
|
335
|
+
'cornrows',
|
|
336
|
+
'cornrows2',
|
|
337
|
+
'dreads1',
|
|
338
|
+
'dreads2',
|
|
339
|
+
'flatTop',
|
|
340
|
+
'flatTopLong',
|
|
341
|
+
'grayBun',
|
|
342
|
+
'grayMedium',
|
|
343
|
+
'grayShort',
|
|
344
|
+
'hatBeanie',
|
|
345
|
+
'hatHip',
|
|
346
|
+
'hijab',
|
|
347
|
+
'long',
|
|
348
|
+
'longAfro',
|
|
349
|
+
'longBangs',
|
|
350
|
+
'longCurly',
|
|
351
|
+
'medium1',
|
|
352
|
+
'medium2',
|
|
353
|
+
'medium3',
|
|
354
|
+
'mediumBangs',
|
|
355
|
+
'mediumBangs2',
|
|
356
|
+
'mediumBangs3',
|
|
357
|
+
'mediumStraight',
|
|
358
|
+
'mohawk',
|
|
359
|
+
'mohawk2',
|
|
360
|
+
'noHair1',
|
|
361
|
+
'noHair2',
|
|
362
|
+
'noHair3',
|
|
363
|
+
'pomp',
|
|
364
|
+
'shaved1',
|
|
365
|
+
'shaved2',
|
|
366
|
+
'shaved3',
|
|
367
|
+
'short1',
|
|
368
|
+
'short2',
|
|
369
|
+
'short3',
|
|
370
|
+
'short4',
|
|
371
|
+
'short5',
|
|
372
|
+
'turban',
|
|
373
|
+
'twists',
|
|
374
|
+
'twists2',
|
|
375
|
+
],
|
|
376
|
+
examples: [
|
|
377
|
+
['afro'],
|
|
378
|
+
['bangs'],
|
|
379
|
+
['bangs2'],
|
|
380
|
+
['bantuKnots'],
|
|
381
|
+
['bear'],
|
|
382
|
+
['bun'],
|
|
383
|
+
['bun2'],
|
|
384
|
+
['buns'],
|
|
385
|
+
['cornrows'],
|
|
386
|
+
['cornrows2'],
|
|
387
|
+
['dreads1'],
|
|
388
|
+
['dreads2'],
|
|
389
|
+
['flatTop'],
|
|
390
|
+
['flatTopLong'],
|
|
391
|
+
['grayBun'],
|
|
392
|
+
['grayMedium'],
|
|
393
|
+
['grayShort'],
|
|
394
|
+
['hatBeanie'],
|
|
395
|
+
['hatHip'],
|
|
396
|
+
['hijab'],
|
|
397
|
+
['long'],
|
|
398
|
+
['longAfro'],
|
|
399
|
+
['longBangs'],
|
|
400
|
+
['longCurly'],
|
|
401
|
+
['medium1'],
|
|
402
|
+
['medium2'],
|
|
403
|
+
['medium3'],
|
|
404
|
+
['mediumBangs'],
|
|
405
|
+
['mediumBangs2'],
|
|
406
|
+
['mediumBangs3'],
|
|
407
|
+
['mediumStraight'],
|
|
408
|
+
['mohawk'],
|
|
409
|
+
['mohawk2'],
|
|
410
|
+
['noHair1'],
|
|
411
|
+
['noHair2'],
|
|
412
|
+
['noHair3'],
|
|
413
|
+
['pomp'],
|
|
414
|
+
['shaved1'],
|
|
415
|
+
['shaved2'],
|
|
416
|
+
['shaved3'],
|
|
417
|
+
['short1'],
|
|
418
|
+
['short2'],
|
|
419
|
+
['short3'],
|
|
420
|
+
['short4'],
|
|
421
|
+
['short5'],
|
|
422
|
+
['turban'],
|
|
423
|
+
['twists'],
|
|
424
|
+
['twists2'],
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
mask: {
|
|
428
|
+
type: 'array',
|
|
429
|
+
items: { type: 'string', enum: ['medicalMask', 'respirator'] },
|
|
430
|
+
default: ['medicalMask', 'respirator'],
|
|
431
|
+
examples: [['medicalMask'], ['respirator']],
|
|
432
|
+
},
|
|
433
|
+
maskProbability: { type: 'integer', minimum: 0, maximum: 100, default: 5 },
|
|
434
|
+
skinColor: {
|
|
435
|
+
type: 'array',
|
|
436
|
+
items: {
|
|
437
|
+
type: 'string',
|
|
438
|
+
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})$',
|
|
439
|
+
},
|
|
440
|
+
default: [
|
|
441
|
+
'variant01',
|
|
442
|
+
'variant02',
|
|
443
|
+
'variant03',
|
|
444
|
+
'variant04',
|
|
445
|
+
'variant05',
|
|
446
|
+
],
|
|
447
|
+
examples: [
|
|
448
|
+
['variant01'],
|
|
449
|
+
['variant02'],
|
|
450
|
+
['variant03'],
|
|
451
|
+
['variant04'],
|
|
452
|
+
['variant05'],
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
additionalProperties: false,
|
|
457
|
+
};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
head?: ('afro' | 'bangs' | 'bangs2' | 'bantuKnots' | 'bear' | 'bun' | 'bun2' | 'buns' | 'cornrows' | 'cornrows2' | 'dreads1' | 'dreads2' | 'flatTop' | 'flatTopLong' | 'grayBun' | 'grayMedium' | 'grayShort' | 'hatBeanie' | 'hatHip' | 'hijab' | 'long' | 'longAfro' | 'longBangs' | 'longCurly' | 'medium1' | 'medium2' | 'medium3' | 'mediumBangs' | 'mediumBangs2' | 'mediumBangs3' | 'mediumStraight' | 'mohawk' | 'mohawk2' | 'noHair1' | 'noHair2' | 'noHair3' | 'pomp' | 'shaved1' | 'shaved2' | 'shaved3' | 'short1' | 'short2' | 'short3' | 'short4' | 'short5' | 'turban' | 'twists' | 'twists2')[];
|
|
3
|
+
face?: ('angryWithFang' | 'awe' | 'blank' | 'calm' | 'cheeky' | 'concerned' | 'concernedFear' | 'contempt' | 'cute' | 'cyclops' | 'driven' | 'eatingHappy' | 'explaining' | 'eyesClosed' | 'fear' | 'hectic' | 'lovingGrin1' | 'lovingGrin2' | 'monster' | 'old' | 'rage' | 'serious' | 'smile' | 'smileBig' | 'smileLOL' | 'smileTeethGap' | 'solemn' | 'suspicious' | 'tired' | 'veryAngry')[];
|
|
4
|
+
facialHair?: ('chin' | 'full' | 'full2' | 'full3' | 'full4' | 'goatee1' | 'goatee2' | 'moustache1' | 'moustache2' | 'moustache3' | 'moustache4' | 'moustache5' | 'moustache6' | 'moustache7' | 'moustache8' | 'moustache9')[];
|
|
5
|
+
facialHairProbability?: number;
|
|
6
|
+
mask?: ('medicalMask' | 'respirator')[];
|
|
7
|
+
maskProbability?: number;
|
|
8
|
+
accessories?: ('eyepatch' | 'glasses' | 'glasses2' | 'glasses3' | 'glasses4' | 'glasses5' | 'sunglasses' | 'sunglasses2')[];
|
|
9
|
+
accessoriesProbability?: number;
|
|
10
|
+
skinColor?: string[];
|
|
11
|
+
clothingColor?: string[];
|
|
12
|
+
hairColor?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare type ColorGroup = Record<string, ColorGroupItem>;
|
|
15
|
+
export declare type ColorGroupCollection = Record<string, ColorGroup>;
|
|
16
|
+
export declare type ColorGroupItem = string;
|
|
17
|
+
export declare type ColorPickCollection = Record<string, ColorPick>;
|
|
18
|
+
export declare type ColorPick = {
|
|
19
|
+
name: string;
|
|
20
|
+
value: ColorGroupItem;
|
|
21
|
+
};
|
|
22
|
+
export declare type ComponentGroup = Record<string, ComponentGroupItem>;
|
|
23
|
+
export declare type ComponentGroupCollection = Record<string, ComponentGroup>;
|
|
24
|
+
export declare type ComponentGroupItem = (components: ComponentPickCollection, colors: ColorPickCollection) => string;
|
|
25
|
+
export declare type ComponentPickCollection = Record<string, ComponentPick>;
|
|
26
|
+
export declare type ComponentPick = {
|
|
27
|
+
name: string;
|
|
28
|
+
value: ComponentGroupItem;
|
|
29
|
+
} | undefined;
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
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,20 @@
|
|
|
1
|
+
import { pickColor } from './pickColor.js';
|
|
2
|
+
export function getColors({ prng, options }) {
|
|
3
|
+
return {
|
|
4
|
+
skin: pickColor({
|
|
5
|
+
prng,
|
|
6
|
+
group: 'skin',
|
|
7
|
+
values: options.skinColor,
|
|
8
|
+
}),
|
|
9
|
+
clothing: pickColor({
|
|
10
|
+
prng,
|
|
11
|
+
group: 'clothing',
|
|
12
|
+
values: options.clothingColor,
|
|
13
|
+
}),
|
|
14
|
+
hair: pickColor({
|
|
15
|
+
prng,
|
|
16
|
+
group: 'hair',
|
|
17
|
+
values: options.hairColor,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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,39 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const headComponent = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'head',
|
|
6
|
+
values: options.head,
|
|
7
|
+
});
|
|
8
|
+
const faceComponent = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'face',
|
|
11
|
+
values: options.face,
|
|
12
|
+
});
|
|
13
|
+
const facialHairComponent = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'facialHair',
|
|
16
|
+
values: options.facialHair,
|
|
17
|
+
});
|
|
18
|
+
const maskComponent = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'mask',
|
|
21
|
+
values: options.mask,
|
|
22
|
+
});
|
|
23
|
+
const accessoriesComponent = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'accessories',
|
|
26
|
+
values: options.accessories,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
head: headComponent,
|
|
30
|
+
face: faceComponent,
|
|
31
|
+
facialHair: prng.bool(options.facialHairProbability)
|
|
32
|
+
? facialHairComponent
|
|
33
|
+
: undefined,
|
|
34
|
+
mask: prng.bool(options.maskProbability) ? maskComponent : undefined,
|
|
35
|
+
accessories: prng.bool(options.accessoriesProbability)
|
|
36
|
+
? accessoriesComponent
|
|
37
|
+
: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|