@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.
Files changed (90) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -3
  3. package/lib/colors/accessories.d.ts +2 -0
  4. package/lib/colors/accessories.js +7 -0
  5. package/lib/colors/clothes.d.ts +2 -0
  6. package/lib/colors/clothes.js +14 -0
  7. package/lib/colors/glasses.d.ts +2 -0
  8. package/lib/colors/glasses.js +8 -0
  9. package/lib/colors/hair.d.ts +2 -0
  10. package/lib/colors/hair.js +12 -0
  11. package/lib/colors/hat.d.ts +2 -0
  12. package/lib/colors/hat.js +9 -0
  13. package/lib/colors/index.d.ts +7 -0
  14. package/lib/colors/index.js +7 -0
  15. package/lib/colors/mouth.d.ts +2 -0
  16. package/lib/colors/mouth.js +6 -0
  17. package/lib/colors/skin.d.ts +2 -0
  18. package/lib/colors/skin.js +10 -0
  19. package/lib/components/accessories.d.ts +2 -0
  20. package/lib/components/accessories.js +6 -0
  21. package/lib/components/beard.d.ts +2 -0
  22. package/lib/components/beard.js +6 -0
  23. package/lib/components/clothing.d.ts +2 -0
  24. package/lib/components/clothing.js +27 -0
  25. package/lib/components/eyebrows.d.ts +2 -0
  26. package/lib/components/eyebrows.js +15 -0
  27. package/lib/components/eyes.d.ts +2 -0
  28. package/lib/components/eyes.js +15 -0
  29. package/lib/components/glasses.d.ts +2 -0
  30. package/lib/components/glasses.js +9 -0
  31. package/lib/components/hair.d.ts +2 -0
  32. package/lib/components/hair.js +28 -0
  33. package/lib/components/hat.d.ts +2 -0
  34. package/lib/components/hat.js +14 -0
  35. package/lib/components/index.d.ts +9 -0
  36. package/lib/components/index.js +9 -0
  37. package/lib/components/mouth.d.ts +2 -0
  38. package/lib/components/mouth.js +22 -0
  39. package/lib/core.d.ts +3 -0
  40. package/lib/core.js +63 -0
  41. package/{dist → lib}/hooks/onPostCreate.d.ts +11 -11
  42. package/lib/hooks/onPostCreate.js +3 -0
  43. package/lib/hooks/onPreCreate.d.ts +9 -0
  44. package/lib/hooks/onPreCreate.js +3 -0
  45. package/lib/index.d.ts +13 -0
  46. package/lib/index.js +13 -0
  47. package/lib/meta/components.d.ts +4 -0
  48. package/lib/meta/components.js +38 -0
  49. package/lib/schema.d.ts +2 -0
  50. package/lib/schema.js +640 -0
  51. package/lib/types.d.ts +39 -0
  52. package/lib/types.js +1 -0
  53. package/lib/utils/getColors.d.ts +8 -0
  54. package/lib/utils/getColors.js +40 -0
  55. package/lib/utils/getComponents.d.ts +8 -0
  56. package/lib/utils/getComponents.js +63 -0
  57. package/lib/utils/pickColor.d.ts +9 -0
  58. package/lib/utils/pickColor.js +13 -0
  59. package/lib/utils/pickComponent.d.ts +9 -0
  60. package/lib/utils/pickComponent.js +14 -0
  61. package/package.json +18 -21
  62. package/dist/colors/accessories.d.ts +0 -2
  63. package/dist/colors/clothes.d.ts +0 -2
  64. package/dist/colors/glasses.d.ts +0 -2
  65. package/dist/colors/hair.d.ts +0 -2
  66. package/dist/colors/hat.d.ts +0 -2
  67. package/dist/colors/index.d.ts +0 -7
  68. package/dist/colors/mouth.d.ts +0 -2
  69. package/dist/colors/skin.d.ts +0 -2
  70. package/dist/components/accessories.d.ts +0 -2
  71. package/dist/components/beard.d.ts +0 -2
  72. package/dist/components/clothing.d.ts +0 -2
  73. package/dist/components/eyebrows.d.ts +0 -2
  74. package/dist/components/eyes.d.ts +0 -2
  75. package/dist/components/glasses.d.ts +0 -2
  76. package/dist/components/hair.d.ts +0 -2
  77. package/dist/components/hat.d.ts +0 -2
  78. package/dist/components/index.d.ts +0 -9
  79. package/dist/components/mouth.d.ts +0 -2
  80. package/dist/core.d.ts +0 -3
  81. package/dist/hooks/onPreCreate.d.ts +0 -8
  82. package/dist/index.d.ts +0 -15
  83. package/dist/index.es.js +0 -578
  84. package/dist/index.js +0 -585
  85. package/dist/index.umd.js +0 -10
  86. package/dist/options.d.ts +0 -49
  87. package/dist/schema.d.ts +0 -2
  88. package/dist/static-types.d.ts +0 -16
  89. package/dist/utils/pickColor.d.ts +0 -3
  90. 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": "4.10.2",
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
- "source": "src/index.ts",
17
- "main": "dist/index.js",
18
- "module": "dist/index.es.js",
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
- "README.md",
24
- "dist"
21
+ "lib",
22
+ "README.md"
25
23
  ],
26
24
  "scripts": {
27
- "test": "jest",
25
+ "prebuild": "del-cli lib",
26
+ "build": "tsc",
28
27
  "prepublishOnly": "npm run build",
29
- "prebuild": "shx rm -rf dist",
30
- "build": "dicebear-project build DiceBear.PixelArt"
28
+ "test": "uvu tests"
31
29
  },
32
30
  "devDependencies": {
33
- "@dicebear/avatars": "^4.10.2",
31
+ "@dicebear/core": "^5.0.0-alpha.11",
34
32
  "@tsconfig/recommended": "^1.0.0",
35
33
  "@types/jest": "^26.0.22",
36
- "@types/node": "^10.11.6",
37
- "dicebear-project": "^4.10.2",
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"
34
+ "del-cli": "^4.0.1",
35
+ "typescript": "^4.5.2",
36
+ "uvu": "^0.5.2"
43
37
  },
44
38
  "peerDependencies": {
45
- "@dicebear/avatars": "^4.6.0"
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": "28ffc2046de961f814b3c5804c562dd318821a7b"
47
+ "gitHead": "93e6f1be9fff392ded1f18c8320b6a0ca8e695c1"
51
48
  }
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const accessories: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const clothes: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const glasses: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const hair: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const hat: ColorGroup;
@@ -1,7 +0,0 @@
1
- export { skin } from './skin';
2
- export { hair } from './hair';
3
- export { accessories } from './accessories';
4
- export { mouth } from './mouth';
5
- export { clothes } from './clothes';
6
- export { hat } from './hat';
7
- export { glasses } from './glasses';
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const mouth: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ColorGroup } from "../static-types";
2
- export declare const skin: ColorGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const accessories: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const beard: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const clothing: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const eyebrows: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const eyes: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const glasses: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const hair: ComponentGroup;
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const hat: ComponentGroup;
@@ -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';
@@ -1,2 +0,0 @@
1
- import type { ComponentGroup } from '../static-types';
2
- export declare const mouth: ComponentGroup;
package/dist/core.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Style } from '@dicebear/avatars';
2
- import type { Options } from './options';
3
- export declare const style: Style<Options>;
@@ -1,8 +0,0 @@
1
- import { Prng, StyleOptions } from "@dicebear/avatars";
2
- import { Options } from "../options";
3
- declare type Props = {
4
- prng: Prng;
5
- options: StyleOptions<Options>;
6
- };
7
- export declare function onPreCreate({ prng, options }: Props): void;
8
- export {};
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;