@dicebear/pixel-art 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/LICENSE +1 -1
- package/README.md +4 -3
- package/lib/colors/accessories.d.ts +2 -0
- package/lib/colors/accessories.js +7 -0
- package/lib/colors/clothes.d.ts +2 -0
- package/lib/colors/clothes.js +14 -0
- package/lib/colors/glasses.d.ts +2 -0
- package/lib/colors/glasses.js +8 -0
- package/lib/colors/hair.d.ts +2 -0
- package/lib/colors/hair.js +12 -0
- package/lib/colors/hat.d.ts +2 -0
- package/lib/colors/hat.js +9 -0
- package/lib/colors/index.d.ts +7 -0
- package/lib/colors/index.js +7 -0
- package/lib/colors/mouth.d.ts +2 -0
- package/lib/colors/mouth.js +6 -0
- package/lib/colors/skin.d.ts +2 -0
- package/lib/colors/skin.js +10 -0
- package/lib/components/accessories.d.ts +2 -0
- package/lib/components/accessories.js +6 -0
- package/lib/components/beard.d.ts +2 -0
- package/lib/components/beard.js +6 -0
- package/lib/components/clothing.d.ts +2 -0
- package/lib/components/clothing.js +27 -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 +15 -0
- package/lib/components/glasses.d.ts +2 -0
- package/lib/components/glasses.js +9 -0
- package/lib/components/hair.d.ts +2 -0
- package/lib/components/hair.js +28 -0
- package/lib/components/hat.d.ts +2 -0
- package/lib/components/hat.js +14 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +9 -0
- package/lib/components/mouth.d.ts +2 -0
- package/lib/components/mouth.js +22 -0
- package/lib/core.d.ts +3 -0
- package/lib/core.js +63 -0
- package/{dist → lib}/hooks/onPostCreate.d.ts +11 -11
- 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 +38 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +640 -0
- package/lib/types.d.ts +39 -0
- package/lib/types.js +1 -0
- package/lib/utils/getColors.d.ts +8 -0
- package/lib/utils/getColors.js +40 -0
- package/lib/utils/getComponents.d.ts +8 -0
- package/lib/utils/getComponents.js +63 -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 +18 -21
- package/dist/colors/accessories.d.ts +0 -2
- package/dist/colors/clothes.d.ts +0 -2
- package/dist/colors/glasses.d.ts +0 -2
- package/dist/colors/hair.d.ts +0 -2
- package/dist/colors/hat.d.ts +0 -2
- package/dist/colors/index.d.ts +0 -7
- package/dist/colors/mouth.d.ts +0 -2
- package/dist/colors/skin.d.ts +0 -2
- package/dist/components/accessories.d.ts +0 -2
- package/dist/components/beard.d.ts +0 -2
- package/dist/components/clothing.d.ts +0 -2
- package/dist/components/eyebrows.d.ts +0 -2
- package/dist/components/eyes.d.ts +0 -2
- package/dist/components/glasses.d.ts +0 -2
- package/dist/components/hair.d.ts +0 -2
- package/dist/components/hat.d.ts +0 -2
- package/dist/components/index.d.ts +0 -9
- package/dist/components/mouth.d.ts +0 -2
- package/dist/core.d.ts +0 -3
- package/dist/hooks/onPreCreate.d.ts +0 -8
- package/dist/index.d.ts +0 -15
- package/dist/index.es.js +0 -578
- package/dist/index.js +0 -585
- package/dist/index.umd.js +0 -10
- package/dist/options.d.ts +0 -49
- 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
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
hair: pickColor({
|
|
10
|
+
prng,
|
|
11
|
+
group: 'hair',
|
|
12
|
+
values: options.hairColor,
|
|
13
|
+
}),
|
|
14
|
+
accessories: pickColor({
|
|
15
|
+
prng,
|
|
16
|
+
group: 'accessories',
|
|
17
|
+
values: options.accessoriesColor,
|
|
18
|
+
}),
|
|
19
|
+
mouth: pickColor({
|
|
20
|
+
prng,
|
|
21
|
+
group: 'mouth',
|
|
22
|
+
values: options.mouthColor,
|
|
23
|
+
}),
|
|
24
|
+
clothes: pickColor({
|
|
25
|
+
prng,
|
|
26
|
+
group: 'clothes',
|
|
27
|
+
values: options.clothesColor,
|
|
28
|
+
}),
|
|
29
|
+
hat: pickColor({
|
|
30
|
+
prng,
|
|
31
|
+
group: 'hat',
|
|
32
|
+
values: options.hatColor,
|
|
33
|
+
}),
|
|
34
|
+
glasses: pickColor({
|
|
35
|
+
prng,
|
|
36
|
+
group: 'glasses',
|
|
37
|
+
values: options.glassesColor,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -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,63 @@
|
|
|
1
|
+
import { pickComponent } from './pickComponent.js';
|
|
2
|
+
export function getComponents({ prng, options, }) {
|
|
3
|
+
const beardComponent = pickComponent({
|
|
4
|
+
prng,
|
|
5
|
+
group: 'beard',
|
|
6
|
+
values: options.beard,
|
|
7
|
+
});
|
|
8
|
+
const eyesComponent = pickComponent({
|
|
9
|
+
prng,
|
|
10
|
+
group: 'eyes',
|
|
11
|
+
values: options.eyes,
|
|
12
|
+
});
|
|
13
|
+
const eyebrowsComponent = pickComponent({
|
|
14
|
+
prng,
|
|
15
|
+
group: 'eyebrows',
|
|
16
|
+
values: options.eyebrows,
|
|
17
|
+
});
|
|
18
|
+
const mouthComponent = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'mouth',
|
|
21
|
+
values: options.mouth,
|
|
22
|
+
});
|
|
23
|
+
const hairComponent = pickComponent({
|
|
24
|
+
prng,
|
|
25
|
+
group: 'hair',
|
|
26
|
+
values: options.hair,
|
|
27
|
+
});
|
|
28
|
+
const accessoriesComponent = pickComponent({
|
|
29
|
+
prng,
|
|
30
|
+
group: 'accessories',
|
|
31
|
+
values: options.accessories,
|
|
32
|
+
});
|
|
33
|
+
const glassesComponent = pickComponent({
|
|
34
|
+
prng,
|
|
35
|
+
group: 'glasses',
|
|
36
|
+
values: options.glasses,
|
|
37
|
+
});
|
|
38
|
+
const hatComponent = pickComponent({
|
|
39
|
+
prng,
|
|
40
|
+
group: 'hat',
|
|
41
|
+
values: options.hat,
|
|
42
|
+
});
|
|
43
|
+
const clothingComponent = pickComponent({
|
|
44
|
+
prng,
|
|
45
|
+
group: 'clothing',
|
|
46
|
+
values: options.clothing,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
beard: prng.bool(options.beardProbability) ? beardComponent : undefined,
|
|
50
|
+
eyes: eyesComponent,
|
|
51
|
+
eyebrows: eyebrowsComponent,
|
|
52
|
+
mouth: mouthComponent,
|
|
53
|
+
hair: prng.bool(options.hairProbability) ? hairComponent : undefined,
|
|
54
|
+
accessories: prng.bool(options.accessoriesProbability)
|
|
55
|
+
? accessoriesComponent
|
|
56
|
+
: undefined,
|
|
57
|
+
glasses: prng.bool(options.glassesProbability)
|
|
58
|
+
? glassesComponent
|
|
59
|
+
: undefined,
|
|
60
|
+
hat: prng.bool(options.hatProbability) ? hatComponent : undefined,
|
|
61
|
+
clothing: clothingComponent,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/pixel-art",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.11",
|
|
4
4
|
"description": "Avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -13,39 +13,36 @@
|
|
|
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.PixelArt"
|
|
28
|
+
"test": "uvu tests"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"@dicebear/
|
|
31
|
+
"@dicebear/core": "^5.0.0-alpha.11",
|
|
34
32
|
"@tsconfig/recommended": "^1.0.0",
|
|
35
33
|
"@types/jest": "^26.0.22",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"shx": "^0.3.3",
|
|
40
|
-
"ts-jest": "^26.5.4",
|
|
41
|
-
"typescript": "^4.2.3",
|
|
42
|
-
"utility-types": "^3.10.0"
|
|
34
|
+
"del-cli": "^4.0.1",
|
|
35
|
+
"typescript": "^4.5.2",
|
|
36
|
+
"uvu": "^0.5.2"
|
|
43
37
|
},
|
|
44
38
|
"peerDependencies": {
|
|
45
|
-
"@dicebear/
|
|
39
|
+
"@dicebear/core": "^5.0.0-alpha.10"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
46
43
|
},
|
|
47
44
|
"publishConfig": {
|
|
48
45
|
"access": "public"
|
|
49
46
|
},
|
|
50
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "93e6f1be9fff392ded1f18c8320b6a0ca8e695c1"
|
|
51
48
|
}
|
package/dist/colors/clothes.d.ts
DELETED
package/dist/colors/glasses.d.ts
DELETED
package/dist/colors/hair.d.ts
DELETED
package/dist/colors/hat.d.ts
DELETED
package/dist/colors/index.d.ts
DELETED
package/dist/colors/mouth.d.ts
DELETED
package/dist/colors/skin.d.ts
DELETED
package/dist/components/hat.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { beard } from './beard';
|
|
2
|
-
export { eyes } from './eyes';
|
|
3
|
-
export { eyebrows } from './eyebrows';
|
|
4
|
-
export { mouth } from './mouth';
|
|
5
|
-
export { hair } from './hair';
|
|
6
|
-
export { accessories } from './accessories';
|
|
7
|
-
export { glasses } from './glasses';
|
|
8
|
-
export { hat } from './hat';
|
|
9
|
-
export { clothing } from './clothing';
|
package/dist/core.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Pixel Art (@dicebear/pixel-art)
|
|
3
|
-
*
|
|
4
|
-
* Code licensed under MIT License.
|
|
5
|
-
* Copyright (c) 2021 Florian Körner
|
|
6
|
-
*
|
|
7
|
-
* Design "8biticon" by Plastic Jam licensed under MIT.
|
|
8
|
-
* License: https://github.com/dicebear/dicebear/blob/main/packages/%40dicebear/pixel-art/LICENSE
|
|
9
|
-
*/
|
|
10
|
-
declare let create: import("@dicebear/avatars").StyleCreate<import("./options").Options>, meta: import("@dicebear/avatars").StyleMeta, schema: import("json-schema").JSONSchema7;
|
|
11
|
-
export { create, meta, schema };
|
|
12
|
-
export { Options } from './options';
|
|
13
|
-
declare const _default: import("@dicebear/avatars").SpriteCollection<import("./options").Options>;
|
|
14
|
-
/** @deprecated will be removed in Version 5.0 */
|
|
15
|
-
export default _default;
|