@dicebear/personas 5.0.0-alpha.2 → 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 +1 -1
- 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 +9 -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 +10 -0
- package/lib/components/body.d.ts +2 -0
- package/lib/components/body.js +6 -0
- package/lib/components/eyes.d.ts +2 -0
- package/lib/components/eyes.js +8 -0
- package/lib/components/facialHair.d.ts +2 -0
- package/lib/components/facialHair.js +8 -0
- package/lib/components/hair.d.ts +2 -0
- package/lib/components/hair.js +22 -0
- package/lib/components/index.d.ts +6 -0
- package/lib/components/index.js +6 -0
- package/lib/components/mouth.d.ts +2 -0
- package/lib/components/mouth.js +9 -0
- package/lib/components/nose.d.ts +2 -0
- package/lib/components/nose.js +5 -0
- package/{dist → lib}/core.d.ts +3 -3
- package/lib/core.js +32 -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 +13 -0
- package/lib/index.js +13 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +251 -0
- package/lib/types.d.ts +28 -0
- package/lib/types.js +1 -0
- package/{dist → lib}/utils/getColors.d.ts +8 -9
- package/lib/utils/getColors.js +20 -0
- package/{dist → lib}/utils/getComponents.d.ts +8 -9
- package/lib/utils/getComponents.js +43 -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/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/body.d.ts +0 -2
- package/dist/components/eyes.d.ts +0 -2
- package/dist/components/facialHair.d.ts +0 -2
- package/dist/components/hair.d.ts +0 -2
- package/dist/components/index.d.ts +0 -6
- package/dist/components/mouth.d.ts +0 -2
- package/dist/components/nose.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 -618
- package/dist/index.js +0 -625
- package/dist/index.umd.js +0 -12
- package/dist/meta/components.d.ts +0 -4
- package/dist/options.d.ts +0 -17
- package/dist/static-types.d.ts +0 -16
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,20 @@
|
|
|
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
|
+
clothing: pickColor({
|
|
10
|
+
prng,
|
|
11
|
+
group: 'clothing',
|
|
12
|
+
values: options.clothingColor,
|
|
13
|
+
}),
|
|
14
|
+
skin: pickColor({
|
|
15
|
+
prng,
|
|
16
|
+
group: 'skin',
|
|
17
|
+
values: options.skinColor,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -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,43 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const eyesComponent = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'eyes',
|
|
6
|
+
values: options.eyes,
|
|
7
|
+
});
|
|
8
|
+
const hairComponent = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'hair',
|
|
11
|
+
values: options.hair,
|
|
12
|
+
});
|
|
13
|
+
const bodyComponent = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'body',
|
|
16
|
+
values: options.body,
|
|
17
|
+
});
|
|
18
|
+
const mouthComponent = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'mouth',
|
|
21
|
+
values: options.mouth,
|
|
22
|
+
});
|
|
23
|
+
const noseComponent = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'nose',
|
|
26
|
+
values: options.nose,
|
|
27
|
+
});
|
|
28
|
+
const facialHairComponent = pickComponent({
|
|
29
|
+
prng,
|
|
30
|
+
group: 'facialHair',
|
|
31
|
+
values: options.facialHair,
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
eyes: eyesComponent,
|
|
35
|
+
hair: hairComponent,
|
|
36
|
+
body: bodyComponent,
|
|
37
|
+
mouth: mouthComponent,
|
|
38
|
+
nose: noseComponent,
|
|
39
|
+
facialHair: prng.bool(options.facialHairProbability)
|
|
40
|
+
? facialHairComponent
|
|
41
|
+
: undefined,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/personas",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
4
4
|
"description": "Avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -13,39 +13,35 @@
|
|
|
13
13
|
"url": "git+https://github.com/dicebear/dicebear.git"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"browser": "dist/index.umd.js",
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": "./lib/index.js",
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
21
19
|
"files": [
|
|
22
20
|
"LICENSE",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
21
|
+
"lib",
|
|
22
|
+
"README.md"
|
|
25
23
|
],
|
|
26
24
|
"scripts": {
|
|
27
|
-
"
|
|
25
|
+
"prebuild": "del-cli lib",
|
|
26
|
+
"build": "tsc",
|
|
28
27
|
"prepublishOnly": "npm run build",
|
|
29
|
-
"
|
|
30
|
-
"build": "dicebear-project build DiceBear.Personas"
|
|
28
|
+
"test": "uvu tests"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
34
|
-
"@tsconfig/recommended": "^1.0.
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"jest": "^26.6.3",
|
|
39
|
-
"shx": "^0.3.3",
|
|
40
|
-
"ts-jest": "^26.5.4",
|
|
41
|
-
"typescript": "^4.2.3",
|
|
42
|
-
"utility-types": "^3.10.0"
|
|
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"
|
|
43
36
|
},
|
|
44
37
|
"peerDependencies": {
|
|
45
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
38
|
+
"@dicebear/core": "^5.0.0-alpha.16"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
46
42
|
},
|
|
47
43
|
"publishConfig": {
|
|
48
44
|
"access": "public"
|
|
49
45
|
},
|
|
50
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "6b1c2bd64294365be21d0a133a362ede5ed62b5a"
|
|
51
47
|
}
|
package/dist/colors/hair.d.ts
DELETED
package/dist/colors/index.d.ts
DELETED
package/dist/colors/skin.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Prng, StyleOptions } from '@dicebear/core';
|
|
2
|
-
import { Options } from '../options';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
prng: Prng;
|
|
5
|
-
options: StyleOptions<Options>;
|
|
6
|
-
preview: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function onPreCreate({ prng, options, preview }: Props): void;
|
|
9
|
-
export {};
|
package/dist/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Personas (@dicebear/personas)
|
|
3
|
-
*
|
|
4
|
-
* Code licensed under MIT License.
|
|
5
|
-
* Copyright (c) 2021 Florian Körner
|
|
6
|
-
*
|
|
7
|
-
* Design "Personas by Draftbit" by Draftbit - draftbit.com licensed under CC BY 4.0.
|
|
8
|
-
* Source: https://personas.draftbit.com/
|
|
9
|
-
* License: https://creativecommons.org/licenses/by/4.0/
|
|
10
|
-
*/
|
|
11
|
-
declare let create: import("@dicebear/core").StyleCreate<import("./options").Options>, preview: import("@dicebear/core").StylePreview<import("./options").Options> | undefined, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
|
|
12
|
-
export { create, preview, meta, schema };
|
|
13
|
-
export { Options } from './options';
|