@dicebear/core 5.2.0 → 5.3.1
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/lib/core.js +4 -2
- package/lib/schema.js +5 -0
- package/lib/types.d.ts +1 -0
- package/lib/utils/svg.d.ts +1 -1
- package/lib/utils/svg.js +2 -5
- package/package.json +4 -4
package/lib/core.js
CHANGED
|
@@ -35,8 +35,10 @@ export function createAvatar(style, options = {}) {
|
|
|
35
35
|
if (options.radius || options.clip) {
|
|
36
36
|
result.body = svgUtils.addViewboxMask(result, (_e = options.radius) !== null && _e !== void 0 ? _e : 0);
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (options.randomizeIds) {
|
|
39
|
+
// Reduces the occurrence of ID collisions when rendering multiple avatars on one HTML page.
|
|
40
|
+
result.body = svgUtils.randomizeIds(result);
|
|
41
|
+
}
|
|
40
42
|
const attributes = svgUtils.createAttrString(result);
|
|
41
43
|
const metadata = license.xml(style);
|
|
42
44
|
const exif = license.exif(style);
|
package/lib/schema.js
CHANGED
package/lib/types.d.ts
CHANGED
package/lib/utils/svg.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export declare function addRotate(result: StyleCreateResult, rotate: number): st
|
|
|
12
12
|
export declare function addFlip(result: StyleCreateResult): string;
|
|
13
13
|
export declare function addViewboxMask(result: StyleCreateResult, radius: number): string;
|
|
14
14
|
export declare function createAttrString(result: StyleCreateResult): string;
|
|
15
|
-
export declare function randomizeIds(result: StyleCreateResult
|
|
15
|
+
export declare function randomizeIds(result: StyleCreateResult): string;
|
package/lib/utils/svg.js
CHANGED
|
@@ -69,11 +69,8 @@ export function createAttrString(result) {
|
|
|
69
69
|
.map((attr) => `${escape.xml(attr)}="${escape.xml(attributes[attr])}"`)
|
|
70
70
|
.join(' ');
|
|
71
71
|
}
|
|
72
|
-
export function randomizeIds(result
|
|
73
|
-
const prng = createPrng(
|
|
74
|
-
attributes: result.attributes,
|
|
75
|
-
seed,
|
|
76
|
-
}));
|
|
72
|
+
export function randomizeIds(result) {
|
|
73
|
+
const prng = createPrng();
|
|
77
74
|
const ids = {};
|
|
78
75
|
return result.body.replace(/(id="|url\(#)([a-z0-9-_]+)([")])/gi, (match, m1, m2, m3) => {
|
|
79
76
|
ids[m2] = ids[m2] || prng.string(8);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "An avatar library for designers and developers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"avatar",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"test": "uvu tests"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dicebear/converter": "^5.
|
|
35
|
+
"@dicebear/converter": "^5.3.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tsconfig/recommended": "^1.0.1",
|
|
39
|
-
"del-cli": "^
|
|
39
|
+
"del-cli": "^5.0.0",
|
|
40
40
|
"typescript": "^4.6.3",
|
|
41
41
|
"uvu": "^0.5.3"
|
|
42
42
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b3b2cfe7259f9a5bc4cbe0b3d9f8277685abe3f5"
|
|
50
50
|
}
|