@dicebear/shapes 5.0.0-alpha.8 → 5.2.0
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 +14 -2
- package/README.md +21 -3
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +9 -0
- package/lib/components/shape1.d.ts +8 -0
- package/lib/components/shape1.js +16 -0
- package/lib/components/shape2.d.ts +8 -0
- package/lib/components/shape2.js +16 -0
- package/lib/components/shape3.d.ts +8 -0
- package/lib/components/shape3.js +16 -0
- package/lib/hooks/onPreCreate.d.ts +14 -0
- package/lib/hooks/onPreCreate.js +24 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +44 -0
- package/lib/schema.d.ts +8 -0
- package/lib/schema.js +249 -0
- package/lib/types.d.ts +36 -0
- package/lib/types.js +7 -0
- package/lib/utils/convertColor.d.ts +7 -0
- package/lib/utils/convertColor.js +9 -0
- package/lib/utils/getColors.d.ts +14 -0
- package/lib/utils/getColors.js +16 -0
- package/lib/utils/getComponents.d.ts +14 -0
- package/lib/utils/getComponents.js +40 -0
- package/lib/utils/pickComponent.d.ts +18 -0
- package/lib/utils/pickComponent.js +33 -0
- package/package.json +20 -28
- package/dist/index.d.ts +0 -20
- package/dist/index.d.ts.map +0 -1
- package/dist/index.es.js +0 -475
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -479
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not change this file manually! This file was generated with the "Dicebear Exporter"-Plugin for Figma.
|
|
3
|
+
*
|
|
4
|
+
* Plugin: https://www.figma.com/community/plugin/1005765655729342787
|
|
5
|
+
* File: https://www.figma.com/file/bX8ZT8jK2fo5Uy8G6j2Qic/%40dicebear%2Fshapes
|
|
6
|
+
*/
|
|
7
|
+
import { pickComponent } from './pickComponent.js';
|
|
8
|
+
export function getComponents({ prng, options }) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10
|
+
const shape1Component = pickComponent({
|
|
11
|
+
prng,
|
|
12
|
+
group: 'shape1',
|
|
13
|
+
values: options.shape1,
|
|
14
|
+
rotation: ((_a = options.shape1Rotation) === null || _a === void 0 ? void 0 : _a.length) ? options.shape1Rotation : [0],
|
|
15
|
+
offsetX: ((_b = options.shape1OffsetX) === null || _b === void 0 ? void 0 : _b.length) ? options.shape1OffsetX : [0],
|
|
16
|
+
offsetY: ((_c = options.shape1OffsetY) === null || _c === void 0 ? void 0 : _c.length) ? options.shape1OffsetY : [0],
|
|
17
|
+
});
|
|
18
|
+
const shape2Component = pickComponent({
|
|
19
|
+
prng,
|
|
20
|
+
group: 'shape2',
|
|
21
|
+
values: options.shape2,
|
|
22
|
+
rotation: ((_d = options.shape2Rotation) === null || _d === void 0 ? void 0 : _d.length) ? options.shape2Rotation : [0],
|
|
23
|
+
offsetX: ((_e = options.shape2OffsetX) === null || _e === void 0 ? void 0 : _e.length) ? options.shape2OffsetX : [0],
|
|
24
|
+
offsetY: ((_f = options.shape2OffsetY) === null || _f === void 0 ? void 0 : _f.length) ? options.shape2OffsetY : [0],
|
|
25
|
+
});
|
|
26
|
+
const shape3Component = pickComponent({
|
|
27
|
+
prng,
|
|
28
|
+
group: 'shape3',
|
|
29
|
+
values: options.shape3,
|
|
30
|
+
rotation: ((_g = options.shape3Rotation) === null || _g === void 0 ? void 0 : _g.length) ? options.shape3Rotation : [0],
|
|
31
|
+
offsetX: ((_h = options.shape3OffsetX) === null || _h === void 0 ? void 0 : _h.length) ? options.shape3OffsetX : [0],
|
|
32
|
+
offsetY: ((_j = options.shape3OffsetY) === null || _j === void 0 ? void 0 : _j.length) ? options.shape3OffsetY : [0],
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
'shape1': shape1Component,
|
|
36
|
+
'shape2': shape2Component,
|
|
37
|
+
'shape3': shape3Component,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not change this file manually! This file was generated with the "Dicebear Exporter"-Plugin for Figma.
|
|
3
|
+
*
|
|
4
|
+
* Plugin: https://www.figma.com/community/plugin/1005765655729342787
|
|
5
|
+
* File: https://www.figma.com/file/bX8ZT8jK2fo5Uy8G6j2Qic/%40dicebear%2Fshapes
|
|
6
|
+
*/
|
|
7
|
+
import type { Prng } from '@dicebear/core';
|
|
8
|
+
import type { ComponentPick } from '../types.js';
|
|
9
|
+
type Props = {
|
|
10
|
+
prng: Prng;
|
|
11
|
+
group: string;
|
|
12
|
+
values?: string[];
|
|
13
|
+
rotation: number[];
|
|
14
|
+
offsetX: number[];
|
|
15
|
+
offsetY: number[];
|
|
16
|
+
};
|
|
17
|
+
export declare function pickComponent({ prng, group, values, rotation, offsetX, offsetY }: Props): ComponentPick;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not change this file manually! This file was generated with the "Dicebear Exporter"-Plugin for Figma.
|
|
3
|
+
*
|
|
4
|
+
* Plugin: https://www.figma.com/community/plugin/1005765655729342787
|
|
5
|
+
* File: https://www.figma.com/file/bX8ZT8jK2fo5Uy8G6j2Qic/%40dicebear%2Fshapes
|
|
6
|
+
*/
|
|
7
|
+
import * as components from '../components/index.js';
|
|
8
|
+
export function pickComponent({ prng, group, values = [], rotation, offsetX, offsetY }) {
|
|
9
|
+
const componentCollection = components;
|
|
10
|
+
const key = prng.pick(values);
|
|
11
|
+
const pickedRotation = prng.integer(Math.min(...rotation), Math.max(...rotation));
|
|
12
|
+
const pickedOffsetX = prng.integer(Math.min(...offsetX), Math.max(...offsetX));
|
|
13
|
+
const pickedOffsetY = prng.integer(Math.min(...offsetY), Math.max(...offsetY));
|
|
14
|
+
if (key && componentCollection[group][key]) {
|
|
15
|
+
return {
|
|
16
|
+
name: key,
|
|
17
|
+
value(components, colors) {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
let result = componentCollection[group][key](components, colors);
|
|
20
|
+
if (this.rotation || this.offsetX || this.offsetY) {
|
|
21
|
+
result = `<g transform="translate(${((_a = this.offsetX) !== null && _a !== void 0 ? _a : 0)}, ${(_b = this.offsetY) !== null && _b !== void 0 ? _b : 0}) rotate(${(_c = this.rotation) !== null && _c !== void 0 ? _c : 0} 50 50)">${result}</g>`;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
},
|
|
25
|
+
rotation: pickedRotation,
|
|
26
|
+
offsetX: pickedOffsetX,
|
|
27
|
+
offsetY: pickedOffsetY,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/shapes",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -13,44 +13,36 @@
|
|
|
13
13
|
"url": "git+https://github.com/dicebear/dicebear.git"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"types": "dist/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./lib/index.js",
|
|
18
|
+
"exports": "./lib/index.js",
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
21
20
|
"files": [
|
|
22
21
|
"LICENSE",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
22
|
+
"lib",
|
|
23
|
+
"README.md"
|
|
25
24
|
],
|
|
26
25
|
"scripts": {
|
|
27
|
-
"
|
|
26
|
+
"prebuild": "del-cli lib",
|
|
27
|
+
"build": "tsc",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
|
-
"
|
|
30
|
-
"build": "npm-run-all build:*",
|
|
31
|
-
"build:schema": "json2ts src/schema.json src/options.ts",
|
|
32
|
-
"build:parcel": "parcel build"
|
|
29
|
+
"test": "uvu tests"
|
|
33
30
|
},
|
|
34
31
|
"devDependencies": {
|
|
35
|
-
"@dicebear/core": "^5.
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"@types/node": "^10.11.6",
|
|
41
|
-
"jest": "^26.6.3",
|
|
42
|
-
"json-schema-to-typescript": "^10.1.5",
|
|
43
|
-
"npm-run-all": "^4.1.5",
|
|
44
|
-
"parcel": "^2.0.1",
|
|
45
|
-
"shx": "^0.3.3",
|
|
46
|
-
"ts-jest": "^26.5.4",
|
|
47
|
-
"typescript": "^4.5.2"
|
|
32
|
+
"@dicebear/core": "^5.2.0",
|
|
33
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
34
|
+
"del-cli": "^4.0.1",
|
|
35
|
+
"typescript": "^4.6.3",
|
|
36
|
+
"uvu": "^0.5.3"
|
|
48
37
|
},
|
|
49
38
|
"peerDependencies": {
|
|
50
|
-
"@dicebear/core": "^5.0.0
|
|
39
|
+
"@dicebear/core": "^5.0.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
51
43
|
},
|
|
52
44
|
"publishConfig": {
|
|
53
45
|
"access": "public"
|
|
54
46
|
},
|
|
55
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c4014d98787e729af307842b449cf82741d4ba8c"
|
|
56
48
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
-
*/
|
|
6
|
-
export interface Options {
|
|
7
|
-
baseColor?: (string | ("amber" | "blue" | "cyan" | "deepOrange" | "deepPurple" | "green" | "indigo" | "lightBlue" | "lightGreen" | "lime" | "orange" | "pink" | "purple" | "red" | "teal" | "yellow"))[];
|
|
8
|
-
center?: ("shape1Inverted" | "shape1" | "shape2Inverted" | "shape2" | "shape3Inverted" | "shape3" | "shape4Inverted" | "shape4" | "shape5Inverted" | "shape5" | "shape6Inverted" | "shape6" | "shape7Inverted" | "shape7" | "shape8" | "shape9")[];
|
|
9
|
-
centerModifier?: ("none" | "lightGray" | "gray" | "lighten")[];
|
|
10
|
-
centerWrapper?: "default"[];
|
|
11
|
-
corners?: ("shape10" | "shape09" | "shape08" | "shape07" | "shape06" | "shape05" | "shape04" | "shape03" | "shape02" | "shape01")[];
|
|
12
|
-
cornersModifier?: ("none" | "lightGray" | "gray" | "lighten")[];
|
|
13
|
-
cornersWrapper?: "default"[];
|
|
14
|
-
sides?: ("shape10" | "shape09" | "shape08" | "shape07" | "shape06" | "shape05" | "shape04" | "shape03" | "shape02" | "shape01")[];
|
|
15
|
-
sidesModifier?: ("none" | "lightGray" | "gray" | "lighten")[];
|
|
16
|
-
sidesWrapper?: "default"[];
|
|
17
|
-
}
|
|
18
|
-
export const 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;
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AACA;;;;GAIG;AAEH;IACE,SAAS,CAAC,EAAE,CACR,MAAM,GACN,CACI,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,MAAM,GACN,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,KAAK,GACL,MAAM,GACN,QAAQ,CACX,CACJ,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,CACL,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,gBAAgB,GAChB,QAAQ,GACR,QAAQ,GACR,QAAQ,CACX,EAAE,CAAC;IACJ,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC/D,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,CACN,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CACZ,EAAE,CAAC;IACJ,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAChE,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,CACJ,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CACZ,EAAE,CAAC;IACJ,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9D,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC;CAC5B;AsB/DD,OAAA,yPAA+C,CAAC","sources":["packages/@dicebear/shapes/src/src/options.ts","packages/@dicebear/shapes/src/src/static-types.ts","packages/@dicebear/shapes/src/src/components/centerModifier.ts","packages/@dicebear/shapes/src/src/components/cornersModifier.ts","packages/@dicebear/shapes/src/src/components/sidesModifier.ts","packages/@dicebear/shapes/src/src/components/sidesWrapper.ts","packages/@dicebear/shapes/src/src/components/sides.ts","packages/@dicebear/shapes/src/src/components/cornersWrapper.ts","packages/@dicebear/shapes/src/src/components/corners.ts","packages/@dicebear/shapes/src/src/components/centerWrapper.ts","packages/@dicebear/shapes/src/src/components/center.ts","packages/@dicebear/shapes/src/src/components/index.ts","packages/@dicebear/shapes/src/src/utils/pickComponent.ts","packages/@dicebear/shapes/src/src/utils/getComponents.ts","packages/@dicebear/shapes/src/src/colors/base.ts","packages/@dicebear/shapes/src/src/colors/index.ts","packages/@dicebear/shapes/src/src/utils/pickColor.ts","packages/@dicebear/shapes/src/src/utils/getColors.ts","packages/@dicebear/shapes/src/src/hooks/onPreCreate.ts","packages/@dicebear/shapes/src/src/hooks/onPostCreate.ts","packages/@dicebear/shapes/src/src/meta/components.ts","packages/@dicebear/shapes/src/src/core.ts","packages/@dicebear/shapes/src/src/index.ts","packages/@dicebear/shapes/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*!\n * Shapes (@dicebear/shapes)\n *\n * Code licensed under MIT License.\n * Copyright (c) 2021 Florian Körner\n * Copyright (c) 2021 Daniel Mester Pirttijärvi\n *\n * Design \"Jdenticon\" by Daniel Mester Pirttijärvi licensed under MIT.\n * Source: https://github.com/dmester/jdenticon\n * License: https://github.com/dicebear/dicebear/blob/main/packages/%40dicebear/shapes/LICENSE\n */\n\nimport { style } from './core';\n\nconst { create, preview, meta, schema } = style;\n\nexport { create, preview, meta, schema };\nexport type { Options } from './options';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|