@dicebear/lorelei 5.0.0-alpha.20
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 +21 -0
- package/README.md +18 -0
- package/lib/colors/earrings.d.ts +2 -0
- package/lib/colors/earrings.js +3 -0
- package/lib/colors/eyebrows.d.ts +2 -0
- package/lib/colors/eyebrows.js +3 -0
- package/lib/colors/eyes.d.ts +2 -0
- package/lib/colors/eyes.js +3 -0
- package/lib/colors/freckles.d.ts +2 -0
- package/lib/colors/freckles.js +3 -0
- package/lib/colors/glasses.d.ts +2 -0
- package/lib/colors/glasses.js +3 -0
- package/lib/colors/hair.d.ts +2 -0
- package/lib/colors/hair.js +3 -0
- package/lib/colors/hairAccessories.d.ts +2 -0
- package/lib/colors/hairAccessories.js +3 -0
- package/lib/colors/index.d.ts +10 -0
- package/lib/colors/index.js +10 -0
- package/lib/colors/mouth.d.ts +2 -0
- package/lib/colors/mouth.js +3 -0
- package/lib/colors/nose.d.ts +2 -0
- package/lib/colors/nose.js +3 -0
- package/lib/colors/skin.d.ts +2 -0
- package/lib/colors/skin.js +3 -0
- package/lib/components/beard.d.ts +2 -0
- package/lib/components/beard.js +4 -0
- package/lib/components/earrings.d.ts +2 -0
- package/lib/components/earrings.js +5 -0
- package/lib/components/eyebrows.d.ts +2 -0
- package/lib/components/eyebrows.js +15 -0
- package/lib/components/eyes.d.ts +2 -0
- package/lib/components/eyes.js +26 -0
- package/lib/components/freckles.d.ts +2 -0
- package/lib/components/freckles.js +3 -0
- package/lib/components/glasses.d.ts +2 -0
- package/lib/components/glasses.js +7 -0
- package/lib/components/hair.d.ts +2 -0
- package/lib/components/hair.js +194 -0
- package/lib/components/hairAccessories.d.ts +2 -0
- package/lib/components/hairAccessories.js +3 -0
- package/lib/components/head.d.ts +2 -0
- package/lib/components/head.js +18 -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 +29 -0
- package/lib/components/nose.d.ts +2 -0
- package/lib/components/nose.js +8 -0
- package/lib/core.d.ts +3 -0
- package/lib/core.js +32 -0
- package/lib/hooks/onPostCreate.d.ts +10 -0
- package/lib/hooks/onPostCreate.js +5 -0
- package/lib/hooks/onPreCreate.d.ts +8 -0
- package/lib/hooks/onPreCreate.js +3 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +13 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +590 -0
- package/lib/types.d.ts +44 -0
- package/lib/types.js +1 -0
- package/lib/utils/getColors.d.ts +8 -0
- package/lib/utils/getColors.js +55 -0
- package/lib/utils/getComponents.d.ts +8 -0
- package/lib/utils/getComponents.js +79 -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 +47 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { pickColor } from './pickColor.js';
|
|
2
|
+
export function getColors({ prng, options }) {
|
|
3
|
+
return {
|
|
4
|
+
hair: pickColor({
|
|
5
|
+
prng,
|
|
6
|
+
group: 'hair',
|
|
7
|
+
values: options.hairColor,
|
|
8
|
+
}),
|
|
9
|
+
skin: pickColor({
|
|
10
|
+
prng,
|
|
11
|
+
group: 'skin',
|
|
12
|
+
values: options.skinColor,
|
|
13
|
+
}),
|
|
14
|
+
earrings: pickColor({
|
|
15
|
+
prng,
|
|
16
|
+
group: 'earrings',
|
|
17
|
+
values: options.earringsColor,
|
|
18
|
+
}),
|
|
19
|
+
eyebrows: pickColor({
|
|
20
|
+
prng,
|
|
21
|
+
group: 'eyebrows',
|
|
22
|
+
values: options.eyebrowsColor,
|
|
23
|
+
}),
|
|
24
|
+
eyes: pickColor({
|
|
25
|
+
prng,
|
|
26
|
+
group: 'eyes',
|
|
27
|
+
values: options.eyesColor,
|
|
28
|
+
}),
|
|
29
|
+
freckles: pickColor({
|
|
30
|
+
prng,
|
|
31
|
+
group: 'freckles',
|
|
32
|
+
values: options.frecklesColor,
|
|
33
|
+
}),
|
|
34
|
+
glasses: pickColor({
|
|
35
|
+
prng,
|
|
36
|
+
group: 'glasses',
|
|
37
|
+
values: options.glassesColor,
|
|
38
|
+
}),
|
|
39
|
+
mouth: pickColor({
|
|
40
|
+
prng,
|
|
41
|
+
group: 'mouth',
|
|
42
|
+
values: options.mouthColor,
|
|
43
|
+
}),
|
|
44
|
+
nose: pickColor({
|
|
45
|
+
prng,
|
|
46
|
+
group: 'nose',
|
|
47
|
+
values: options.noseColor,
|
|
48
|
+
}),
|
|
49
|
+
hairAccessories: pickColor({
|
|
50
|
+
prng,
|
|
51
|
+
group: 'hairAccessories',
|
|
52
|
+
values: options.hairAccessoriesColor,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -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,79 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const hairComponent = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'hair',
|
|
6
|
+
values: options.hair,
|
|
7
|
+
});
|
|
8
|
+
const hairAccessoriesComponent = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'hairAccessories',
|
|
11
|
+
values: options.hairAccessories,
|
|
12
|
+
});
|
|
13
|
+
const headComponent = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'head',
|
|
16
|
+
values: options.head,
|
|
17
|
+
});
|
|
18
|
+
const eyesComponent = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'eyes',
|
|
21
|
+
values: options.eyes,
|
|
22
|
+
});
|
|
23
|
+
const eyebrowsComponent = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'eyebrows',
|
|
26
|
+
values: options.eyebrows,
|
|
27
|
+
});
|
|
28
|
+
const earringsComponent = pickComponent({
|
|
29
|
+
prng,
|
|
30
|
+
group: 'earrings',
|
|
31
|
+
values: options.earrings,
|
|
32
|
+
});
|
|
33
|
+
const frecklesComponent = pickComponent({
|
|
34
|
+
prng,
|
|
35
|
+
group: 'freckles',
|
|
36
|
+
values: options.freckles,
|
|
37
|
+
});
|
|
38
|
+
const noseComponent = pickComponent({
|
|
39
|
+
prng,
|
|
40
|
+
group: 'nose',
|
|
41
|
+
values: options.nose,
|
|
42
|
+
});
|
|
43
|
+
const beardComponent = pickComponent({
|
|
44
|
+
prng,
|
|
45
|
+
group: 'beard',
|
|
46
|
+
values: options.beard,
|
|
47
|
+
});
|
|
48
|
+
const mouthComponent = pickComponent({
|
|
49
|
+
prng,
|
|
50
|
+
group: 'mouth',
|
|
51
|
+
values: options.mouth,
|
|
52
|
+
});
|
|
53
|
+
const glassesComponent = pickComponent({
|
|
54
|
+
prng,
|
|
55
|
+
group: 'glasses',
|
|
56
|
+
values: options.glasses,
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
hair: hairComponent,
|
|
60
|
+
hairAccessories: prng.bool(options.hairAccessoriesProbability)
|
|
61
|
+
? hairAccessoriesComponent
|
|
62
|
+
: undefined,
|
|
63
|
+
head: headComponent,
|
|
64
|
+
eyes: eyesComponent,
|
|
65
|
+
eyebrows: eyebrowsComponent,
|
|
66
|
+
earrings: prng.bool(options.earringsProbability)
|
|
67
|
+
? earringsComponent
|
|
68
|
+
: undefined,
|
|
69
|
+
freckles: prng.bool(options.frecklesProbability)
|
|
70
|
+
? frecklesComponent
|
|
71
|
+
: undefined,
|
|
72
|
+
nose: noseComponent,
|
|
73
|
+
beard: prng.bool(options.beardProbability) ? beardComponent : undefined,
|
|
74
|
+
mouth: mouthComponent,
|
|
75
|
+
glasses: prng.bool(options.glassesProbability)
|
|
76
|
+
? glassesComponent
|
|
77
|
+
: undefined,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -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
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dicebear/lorelei",
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
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.20",
|
|
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.16"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "6b1c2bd64294365be21d0a133a362ede5ed62b5a"
|
|
47
|
+
}
|