@dicebear/core 5.2.0 → 5.3.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/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
- // Reduces the occurrence of ID collisions when rendering multiple avatars on one HTML page.
39
- result.body = svgUtils.randomizeIds(result, prng.seed);
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
@@ -73,5 +73,10 @@ export const schema = {
73
73
  type: 'boolean',
74
74
  default: true,
75
75
  },
76
+ randomizeIds: {
77
+ type: 'boolean',
78
+ default: false,
79
+ examples: [true, false],
80
+ },
76
81
  },
77
82
  };
package/lib/types.d.ts CHANGED
@@ -27,6 +27,7 @@ export interface Options {
27
27
  translateX?: number;
28
28
  translateY?: number;
29
29
  clip?: boolean;
30
+ randomizeIds?: boolean;
30
31
  }
31
32
  export interface Exif {
32
33
  [key: string]: string;
@@ -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, seed: string): string;
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, seed) {
73
- const prng = createPrng(JSON.stringify({
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.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "An avatar library for designers and developers.",
5
5
  "keywords": [
6
6
  "avatar",
@@ -32,7 +32,7 @@
32
32
  "test": "uvu tests"
33
33
  },
34
34
  "dependencies": {
35
- "@dicebear/converter": "^5.2.0"
35
+ "@dicebear/converter": "^5.3.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@tsconfig/recommended": "^1.0.1",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "c4014d98787e729af307842b449cf82741d4ba8c"
49
+ "gitHead": "cf8ca88db00485bb24c6f299ca86296de5001113"
50
50
  }