@dicebear/core 10.0.0-rc.4 → 10.0.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/Resolver.js CHANGED
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Resolver_instances, _Resolver_style, _Resolver_options, _Resolver_prng, _Resolver_colorResolving, _Resolver_result, _Resolver_probability, _Resolver_isVisible, _Resolver_resolveColor, _Resolver_colorFillStops, _Resolver_pickFloat, _Resolver_memo;
12
+ var _Resolver_instances, _Resolver_style, _Resolver_options, _Resolver_prng, _Resolver_colorResolving, _Resolver_result, _Resolver_probability, _Resolver_isVisible, _Resolver_resolveColor, _Resolver_colorFillStops, _Resolver_memoFloat, _Resolver_memo;
13
13
  import { Prng } from './Prng.js';
14
14
  import { Color } from './Utils/Color.js';
15
15
  import { CircularColorReferenceError } from './Error/CircularColorReferenceError.js';
@@ -17,8 +17,10 @@ import { CircularColorReferenceError } from './Error/CircularColorReferenceError
17
17
  * Bundles the three inputs needed to derive any deterministic value for an
18
18
  * avatar — the {@link Style}, the validated user {@link Options}, and a
19
19
  * seeded {@link Prng} — and exposes them as named accessors. Each accessor
20
- * memoizes its result so that repeated calls cannot drift, and the memo
21
- * doubles as the snapshot returned by {@link resolved}.
20
+ * memoizes its result so that repeated calls cannot drift. The memo also
21
+ * serves as the informational snapshot returned by {@link resolved} — every
22
+ * value the resolver picks during one resolution lands there, except for
23
+ * the raw seed.
22
24
  */
23
25
  export class Resolver {
24
26
  constructor(style, options) {
@@ -33,7 +35,8 @@ export class Resolver {
33
35
  __classPrivateFieldSet(this, _Resolver_prng, new Prng(this.seed()), "f");
34
36
  }
35
37
  seed() {
36
- // Not memoized so the raw seed stays out of {@link resolved}.
38
+ // Deliberately not memoized the seed is the only input we keep out of
39
+ // the {@link resolved} snapshot, so a serialized avatar never leaks it.
37
40
  return __classPrivateFieldGet(this, _Resolver_options, "f").seed() ?? '';
38
41
  }
39
42
  size() {
@@ -49,33 +52,35 @@ export class Resolver {
49
52
  return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'flip', () => __classPrivateFieldGet(this, _Resolver_prng, "f").pick('flip', __classPrivateFieldGet(this, _Resolver_options, "f").flip()) ?? 'none');
50
53
  }
51
54
  fontFamily() {
52
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'fontFamily', () => __classPrivateFieldGet(this, _Resolver_prng, "f").pick('fontFamily', __classPrivateFieldGet(this, _Resolver_options, "f").fontFamily()) ?? 'system-ui');
55
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'fontFamily', () => __classPrivateFieldGet(this, _Resolver_prng, "f").pick('fontFamily', __classPrivateFieldGet(this, _Resolver_options, "f").fontFamily()) ??
56
+ 'system-ui');
53
57
  }
54
58
  fontWeight() {
55
59
  return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'fontWeight', () => __classPrivateFieldGet(this, _Resolver_prng, "f").pick('fontWeight', __classPrivateFieldGet(this, _Resolver_options, "f").fontWeight()) ?? 400);
56
60
  }
57
61
  scale() {
58
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'scale', () => __classPrivateFieldGet(this, _Resolver_prng, "f").float('scale', __classPrivateFieldGet(this, _Resolver_options, "f").scale()) ?? 1);
62
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, 'scale', __classPrivateFieldGet(this, _Resolver_options, "f").scale(), 1);
59
63
  }
60
64
  borderRadius() {
61
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'borderRadius', () => __classPrivateFieldGet(this, _Resolver_prng, "f").float('borderRadius', __classPrivateFieldGet(this, _Resolver_options, "f").borderRadius()) ?? 0);
65
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, 'borderRadius', __classPrivateFieldGet(this, _Resolver_options, "f").borderRadius(), 0);
62
66
  }
63
67
  rotate() {
64
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'rotate', () => __classPrivateFieldGet(this, _Resolver_prng, "f").float('rotate', __classPrivateFieldGet(this, _Resolver_options, "f").rotate()) ?? 0);
68
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, 'rotate', __classPrivateFieldGet(this, _Resolver_options, "f").rotate(), 0);
65
69
  }
66
70
  translateX() {
67
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'translateX', () => __classPrivateFieldGet(this, _Resolver_prng, "f").float('translateX', __classPrivateFieldGet(this, _Resolver_options, "f").translateX()) ?? 0);
71
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, 'translateX', __classPrivateFieldGet(this, _Resolver_options, "f").translateX(), 0);
68
72
  }
69
73
  translateY() {
70
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'translateY', () => __classPrivateFieldGet(this, _Resolver_prng, "f").float('translateY', __classPrivateFieldGet(this, _Resolver_options, "f").translateY()) ?? 0);
74
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, 'translateY', __classPrivateFieldGet(this, _Resolver_options, "f").translateY(), 0);
71
75
  }
72
76
  /**
73
77
  * Selects a variant for the given component. Depending on what was passed
74
78
  * as `${name}Variant` in the input data:
75
79
  *
76
80
  * - `undefined`: PRNG picks from all style variants using their weights.
77
- * - `string` or `string[]`: PRNG picks from the given subset (weight 1 each).
78
- * - `Record<string, number>`: PRNG picks using the provided weights.
81
+ * - otherwise: PRNG picks using the user-supplied weighted map (a bare
82
+ * string or string list is normalized to weight `1` each in
83
+ * {@link Options.componentVariant}).
79
84
  *
80
85
  * Only variants that exist in the style definition are considered.
81
86
  */
@@ -87,22 +92,20 @@ export class Resolver {
87
92
  }
88
93
  const raw = __classPrivateFieldGet(this, _Resolver_options, "f").componentVariant(component.sourceName());
89
94
  const variants = component.variants();
90
- let entries;
95
+ const weights = {};
91
96
  if (raw === undefined) {
92
- entries = Array.from(variants).map(([v, variant]) => [
93
- v,
94
- variant.weight(),
95
- ]);
96
- }
97
- else if (Array.isArray(raw)) {
98
- entries = raw
99
- .filter((v) => variants.has(v))
100
- .map((v) => [v, 1]);
97
+ for (const [v, variant] of variants) {
98
+ weights[v] = variant.weight();
99
+ }
101
100
  }
102
101
  else {
103
- entries = Object.entries(raw).filter(([v]) => variants.has(v));
102
+ for (const [v, w] of Object.entries(raw)) {
103
+ if (variants.has(v)) {
104
+ weights[v] = w;
105
+ }
106
+ }
104
107
  }
105
- return __classPrivateFieldGet(this, _Resolver_prng, "f").weightedPick(`${name}Variant`, entries);
108
+ return __classPrivateFieldGet(this, _Resolver_prng, "f").weightedPick(`${name}Variant`, weights);
106
109
  });
107
110
  }
108
111
  color(name) {
@@ -113,28 +116,34 @@ export class Resolver {
113
116
  'solid');
114
117
  }
115
118
  colorAngle(name) {
116
- return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, `${name}ColorAngle`, () => __classPrivateFieldGet(this, _Resolver_prng, "f").float(`${name}ColorAngle`, __classPrivateFieldGet(this, _Resolver_options, "f").colorAngle(name)) ?? 0);
119
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}ColorAngle`, __classPrivateFieldGet(this, _Resolver_options, "f").colorAngle(name), 0);
117
120
  }
118
121
  /**
119
- * Per-component transform values are render-time decorations derived per
120
- * `<use>` reference, not user-input options that should round-trip. They
121
- * are intentionally not memoized and so never appear in {@link resolved}.
122
+ * Picks the rotate/translateX/translateY/scale values for a single
123
+ * component. Memoized per `name`, so the four values land in
124
+ * {@link resolved} as `${name}Rotate` / `${name}TranslateX` /
125
+ * `${name}TranslateY` / `${name}Scale` for downstream introspection.
122
126
  */
123
127
  componentTransform(name) {
124
128
  const component = __classPrivateFieldGet(this, _Resolver_style, "f").components().get(name);
125
129
  return {
126
- rotate: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_pickFloat).call(this, name, 'Rotate', component?.rotate() ?? [], 0),
127
- translateX: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_pickFloat).call(this, name, 'TranslateX', component?.translate().x() ?? [], 0),
128
- translateY: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_pickFloat).call(this, name, 'TranslateY', component?.translate().y() ?? [], 0),
129
- scale: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_pickFloat).call(this, name, 'Scale', component?.scale() ?? [], 1),
130
+ rotate: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}Rotate`, component?.rotate(), 0),
131
+ translateX: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}TranslateX`, component?.translate().x(), 0),
132
+ translateY: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}TranslateY`, component?.translate().y(), 0),
133
+ scale: __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}Scale`, component?.scale(), 1),
130
134
  };
131
135
  }
132
136
  /**
133
- * Returns every value that has been touched during this resolution. Only
134
- * memoized entries are included; unset options remain `undefined` and
135
- * disappear on `JSON.stringify()`. Per-component transform values from
136
- * {@link componentTransform} and the user-supplied {@link seed} are
137
- * intentionally not memoized and therefore do not appear in the snapshot.
137
+ * Returns an informational snapshot of every value the resolver picked.
138
+ * Includes top-level options (scale/rotate/translate/…), per-component
139
+ * variants/probabilities/colors, and per-component transform picks. The
140
+ * raw seed is deliberately excluded.
141
+ *
142
+ * The snapshot is NOT a round-trip-able options object — extra keys like
143
+ * `${name}Rotate` are not part of {@link StyleOptions} and feeding the
144
+ * snapshot back into a new {@link Avatar} is not supported. Callers that
145
+ * need to reproduce an avatar should pass the original `seed` and
146
+ * user-supplied options.
138
147
  *
139
148
  * The returned object aliases the internal cache; callers that need
140
149
  * isolation (e.g. {@link Avatar.toJSON}) clone it themselves.
@@ -191,9 +200,10 @@ _Resolver_style = new WeakMap(), _Resolver_options = new WeakMap(), _Resolver_pr
191
200
  : __classPrivateFieldGet(this, _Resolver_prng, "f").shuffle(`${name}Color`, candidates);
192
201
  return ordered.slice(0, stops);
193
202
  }, _Resolver_colorFillStops = function _Resolver_colorFillStops(name) {
194
- return (__classPrivateFieldGet(this, _Resolver_prng, "f").integer(`${name}ColorFillStops`, __classPrivateFieldGet(this, _Resolver_options, "f").colorFillStops(name)) ?? 2);
195
- }, _Resolver_pickFloat = function _Resolver_pickFloat(name, suffix, range, fallback) {
196
- return __classPrivateFieldGet(this, _Resolver_prng, "f").float(`${name}${suffix}`, range) ?? fallback;
203
+ const range = __classPrivateFieldGet(this, _Resolver_options, "f").colorFillStops(name);
204
+ return range ? __classPrivateFieldGet(this, _Resolver_prng, "f").integer(`${name}ColorFillStops`, range) : 2;
205
+ }, _Resolver_memoFloat = function _Resolver_memoFloat(key, range, fallback) {
206
+ return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, key, () => range ? __classPrivateFieldGet(this, _Resolver_prng, "f").float(key, range) : fallback);
197
207
  }, _Resolver_memo = function _Resolver_memo(key, compute) {
198
208
  if (key in __classPrivateFieldGet(this, _Resolver_result, "f")) {
199
209
  return __classPrivateFieldGet(this, _Resolver_result, "f")[key];
@@ -1,4 +1,4 @@
1
- import type { StyleDefinitionComponent } from '../StyleDefinition.js';
1
+ import type { Range, StyleDefinitionComponent } from '../StyleDefinition.js';
2
2
  import { ComponentTranslate } from './ComponentTranslate.js';
3
3
  import { ComponentVariant } from './ComponentVariant.js';
4
4
  /**
@@ -43,13 +43,15 @@ export declare class Component {
43
43
  */
44
44
  probability(): number;
45
45
  /**
46
- * Returns the rotation range definition. Aliases delegate to the source.
46
+ * Returns the rotation range, or `undefined` when unset.
47
+ * Aliases delegate to the source.
47
48
  */
48
- rotate(): readonly number[];
49
+ rotate(): Range | undefined;
49
50
  /**
50
- * Returns the scale range definition. Aliases delegate to the source.
51
+ * Returns the scale range, or `undefined` when unset.
52
+ * Aliases delegate to the source.
51
53
  */
52
- scale(): readonly number[];
54
+ scale(): Range | undefined;
53
55
  /**
54
56
  * Returns the translate descriptor. Aliases delegate to the source.
55
57
  */
@@ -78,22 +78,18 @@ export class Component {
78
78
  return __classPrivateFieldGet(this, _Component_instances, "m", _Component_asBase).call(this).probability ?? 100;
79
79
  }
80
80
  /**
81
- * Returns the rotation range definition. Aliases delegate to the source.
81
+ * Returns the rotation range, or `undefined` when unset.
82
+ * Aliases delegate to the source.
82
83
  */
83
84
  rotate() {
84
- if (__classPrivateFieldGet(this, _Component_source, "f")) {
85
- return __classPrivateFieldGet(this, _Component_source, "f").rotate();
86
- }
87
- return __classPrivateFieldGet(this, _Component_instances, "m", _Component_asBase).call(this).rotate ?? [];
85
+ return __classPrivateFieldGet(this, _Component_source, "f") ? __classPrivateFieldGet(this, _Component_source, "f").rotate() : __classPrivateFieldGet(this, _Component_instances, "m", _Component_asBase).call(this).rotate;
88
86
  }
89
87
  /**
90
- * Returns the scale range definition. Aliases delegate to the source.
88
+ * Returns the scale range, or `undefined` when unset.
89
+ * Aliases delegate to the source.
91
90
  */
92
91
  scale() {
93
- if (__classPrivateFieldGet(this, _Component_source, "f")) {
94
- return __classPrivateFieldGet(this, _Component_source, "f").scale();
95
- }
96
- return __classPrivateFieldGet(this, _Component_instances, "m", _Component_asBase).call(this).scale ?? [];
92
+ return __classPrivateFieldGet(this, _Component_source, "f") ? __classPrivateFieldGet(this, _Component_source, "f").scale() : __classPrivateFieldGet(this, _Component_instances, "m", _Component_asBase).call(this).scale;
97
93
  }
98
94
  /**
99
95
  * Returns the translate descriptor. Aliases delegate to the source.
@@ -1,4 +1,4 @@
1
- import type { StyleDefinitionComponentTranslate } from '../StyleDefinition.js';
1
+ import type { Range, StyleDefinitionComponentTranslate } from '../StyleDefinition.js';
2
2
  /**
3
3
  * Read-only view over a component's `translate` block, providing the X and Y
4
4
  * offset ranges.
@@ -6,12 +6,6 @@ import type { StyleDefinitionComponentTranslate } from '../StyleDefinition.js';
6
6
  export declare class ComponentTranslate {
7
7
  #private;
8
8
  constructor(data: StyleDefinitionComponentTranslate);
9
- /**
10
- * Returns the horizontal offset range, or an empty list when unset.
11
- */
12
- x(): readonly number[];
13
- /**
14
- * Returns the vertical offset range, or an empty list when unset.
15
- */
16
- y(): readonly number[];
9
+ x(): Range | undefined;
10
+ y(): Range | undefined;
17
11
  }
@@ -19,17 +19,11 @@ export class ComponentTranslate {
19
19
  _ComponentTranslate_data.set(this, void 0);
20
20
  __classPrivateFieldSet(this, _ComponentTranslate_data, data, "f");
21
21
  }
22
- /**
23
- * Returns the horizontal offset range, or an empty list when unset.
24
- */
25
22
  x() {
26
- return __classPrivateFieldGet(this, _ComponentTranslate_data, "f").x ?? [];
23
+ return __classPrivateFieldGet(this, _ComponentTranslate_data, "f").x;
27
24
  }
28
- /**
29
- * Returns the vertical offset range, or an empty list when unset.
30
- */
31
25
  y() {
32
- return __classPrivateFieldGet(this, _ComponentTranslate_data, "f").y ?? [];
26
+ return __classPrivateFieldGet(this, _ComponentTranslate_data, "f").y;
33
27
  }
34
28
  }
35
29
  _ComponentTranslate_data = new WeakMap();
@@ -55,9 +55,20 @@ export interface StyleDefinitionColor {
55
55
  readonly notEqualTo?: readonly string[];
56
56
  readonly contrastTo?: string;
57
57
  }
58
+ /**
59
+ * A closed numeric range. `min === max` represents a fixed value. `step`
60
+ * (consumed by {@link Prng.float}; ignored by {@link Prng.integer}) quantizes
61
+ * the range to multiples of `step` starting at `min`; non-positive or absent
62
+ * step means continuous.
63
+ */
64
+ export interface Range {
65
+ readonly min: number;
66
+ readonly max: number;
67
+ readonly step?: number;
68
+ }
58
69
  export interface StyleDefinitionComponentTranslate {
59
- readonly x?: readonly number[];
60
- readonly y?: readonly number[];
70
+ readonly x?: Range;
71
+ readonly y?: Range;
61
72
  }
62
73
  export interface StyleDefinitionComponentVariant {
63
74
  readonly elements: readonly StyleDefinitionElement[];
@@ -67,8 +78,8 @@ export interface StyleDefinitionComponentBase {
67
78
  readonly width: number;
68
79
  readonly height: number;
69
80
  readonly probability?: number;
70
- readonly rotate?: readonly number[];
71
- readonly scale?: readonly number[];
81
+ readonly rotate?: Range;
82
+ readonly scale?: Range;
72
83
  readonly translate?: StyleDefinitionComponentTranslate;
73
84
  readonly variants: Readonly<Record<string, StyleDefinitionComponentVariant>>;
74
85
  }
@@ -2,7 +2,7 @@ import { OptionsValidationError } from '../Error/OptionsValidationError.js';
2
2
  function ucs2length(str) { let n = 0; for (const _ of str)
3
3
  n++; return n; }
4
4
  "use strict";
5
- const schema11 = { "$id": "https://cdn.hopjs.net/npm/@dicebear/schema@0.14.1/dist/options.min.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "DiceBear options schema", "type": "object", "definitions": { "flip": { "type": "string", "enum": ["none", "horizontal", "vertical", "both"] }, "rotate": { "type": "number", "minimum": -360, "maximum": 360 }, "scale": { "type": "number", "minimum": 0, "maximum": 10 }, "translate": { "type": "number", "minimum": -1000, "maximum": 1000 }, "borderRadius": { "type": "number", "minimum": 0, "maximum": 50 }, "color": { "type": "string", "pattern": "^#?([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$" }, "colorFill": { "type": "string", "enum": ["solid", "linear", "radial"] }, "colorFillStops": { "type": "integer", "minimum": 2 }, "fontFamilyName": { "type": "string", "pattern": "^[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*(, ?[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*)*$", "maxLength": 256 }, "fontWeight": { "type": "integer", "minimum": 1, "maximum": 1000 }, "variantName": { "type": "string", "pattern": "^[a-z][a-zA-Z0-9]*$", "maxLength": 64 }, "rotateOption": { "anyOf": [{ "$ref": "#/definitions/rotate" }, { "type": "array", "items": { "$ref": "#/definitions/rotate" }, "minItems": 0, "maxItems": 2 }] }, "translateOption": { "anyOf": [{ "$ref": "#/definitions/translate" }, { "type": "array", "items": { "$ref": "#/definitions/translate" }, "minItems": 0, "maxItems": 2 }] }, "scaleOption": { "anyOf": [{ "$ref": "#/definitions/scale" }, { "type": "array", "items": { "$ref": "#/definitions/scale" }, "minItems": 0, "maxItems": 2 }] } }, "properties": { "seed": { "type": "string", "description": "The starting value for the pseudorandom number generator (PRNG) used in the avatar generation process. This option is essential for creating unique and consistent avatars. By setting a specific seed, you ensure that the same sequence of random characteristics is applied, allowing identical avatars to be reproduced. This is especially valuable for maintaining consistency across sessions and allowing users to share or recreate their personalized avatars.", "maxLength": 1024 }, "size": { "type": "integer", "description": "Specifies the dimensions of the avatar in pixels. If no size is specified, the avatar defaults to a responsive design or scales to 100% of its container. This flexibility allows the avatar to seamlessly adapt to different screen sizes and layouts, ensuring optimal display across devices and environments.", "minimum": 1, "maximum": 4096 }, "idRandomization": { "type": "boolean", "description": "Generates random values for all IDs present in the SVG. This process ensures that while the avatar appears visually identical, the underlying code remains unique. This is particularly useful for embedding the same avatar multiple times in a document without running into duplicate ID conflicts that can interfere with styles and scripts." }, "title": { "type": "string", "description": "Specifies an accessible title for the avatar. When set, the SVG will include a <title> element and an aria-label attribute, allowing screen readers and other assistive technologies to describe the avatar to users.", "maxLength": 256 }, "flip": { "description": "Specifies how the avatar will be flipped. Options include `none` for no flip, `horizontal` for a left-to-right flip, `vertical` for an upside-down flip, and `both` for a complete flip. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/flip" }, { "type": "array", "items": { "$ref": "#/definitions/flip" }, "minItems": 0, "maxItems": 128 }] }, "fontFamily": { "description": "Specifies the font family used for text rendering. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/fontFamilyName" }, { "type": "array", "items": { "$ref": "#/definitions/fontFamilyName" }, "minItems": 0, "maxItems": 128 }] }, "fontWeight": { "description": "Specifies the font weight used for text rendering. The value must be an integer between 1 and 1000. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/fontWeight" }, { "type": "array", "items": { "$ref": "#/definitions/fontWeight" }, "minItems": 0, "maxItems": 128 }] }, "scale": { "description": "Sets the scaling of the avatar. A value of `1` corresponds to the original size of the avatar. This setting affects the size of the avatar itself, but not the size of the avatar container; any excess content will be clipped. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/scaleOption" }] }, "borderRadius": { "description": "This is the radius of the corners of the avatar. This value can be a float or an integer. A value of 0 means that the avatar has sharp corners, while larger values result in more rounded corners. The maximum value is 50, which turns the avatar into a complete circle. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "anyOf": [{ "$ref": "#/definitions/borderRadius" }, { "type": "array", "items": { "$ref": "#/definitions/borderRadius" }, "minItems": 0, "maxItems": 2 }] } }, "patternProperties": { "^[a-z][a-zA-Z0-9]*Probability$": { "type": "number", "description": "Represents the probability that a component of the avatar will be displayed. The value can be either a float or an integer, but is interpreted as a percentage. For example, a value of 0 means the part will never be displayed, while a value of 100 means it will always be displayed.", "minimum": 0, "maximum": 100 }, "^[a-z][a-zA-Z0-9]*Variant$": { "description": "Specifies which variants of the avatar part can be selected by the PRNG and their relative weights. A string or array of strings filters which variants the PRNG can choose from. An object maps variant names to non-negative weights, simultaneously filtering and weighting selection. Variant names must be camelCase identifiers.", "anyOf": [{ "$ref": "#/definitions/variantName" }, { "type": "array", "items": { "$ref": "#/definitions/variantName" }, "minItems": 0, "maxItems": 128 }, { "type": "object", "propertyNames": { "$ref": "#/definitions/variantName" }, "additionalProperties": { "type": "number", "minimum": 0 }, "minProperties": 1, "maxProperties": 512 }] }, "^[a-z][a-zA-Z0-9]*Color$": { "description": "Specifies which colors for the avatar component can be selected by the PRNG. If specified as a string or array with only one value, the value is fixed. However, if specified as an array with multiple values, the PRNG will choose from the available options. The color must be specified as a hex value.", "anyOf": [{ "$ref": "#/definitions/color" }, { "type": "array", "items": { "$ref": "#/definitions/color" }, "minItems": 0, "maxItems": 128 }] }, "^[a-z][a-zA-Z0-9]*ColorFill$": { "description": "Specifies the color fill method for the avatar component. Options include `solid` for a flat color, `linear` for a linear gradient, and `radial` for a radial gradient. If specified as a string or array with only one value, the value is fixed. However, if specified as an array with multiple values, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/colorFill" }, { "type": "array", "items": { "$ref": "#/definitions/colorFill" }, "minItems": 0, "maxItems": 128 }] }, "^[a-z][a-zA-Z0-9]*ColorFillStops$": { "description": "Specifies the number of color stops for gradient fills. This value is only relevant when the color fill method is set to `linear` or `radial`. The minimum value is 2. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "anyOf": [{ "$ref": "#/definitions/colorFillStops" }, { "type": "array", "items": { "$ref": "#/definitions/colorFillStops" }, "minItems": 0, "maxItems": 2 }] }, "^[a-z][a-zA-Z0-9]*ColorAngle$": { "description": "Specifies the angle for the color gradient. This value can be an integer or a float. A value of 0 results in no rotation, while values between -360 and 360 define the degree of rotation. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/rotateOption" }] }, "^rotate$": { "description": "This is the rotation angle for the entire avatar. This value can be an integer or a float. A value of 0 results in no rotation, while values between -360 and 360 define the degree of rotation in both directions. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/rotateOption" }] }, "^translateY$": { "description": "This is the vertical translation of the entire avatar. This value can be an integer or a float. A value of 0 results in no translation, while positive values move the avatar down and negative values move it up. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/translateOption" }] }, "^translateX$": { "description": "This is the horizontal translation of the entire avatar. This value can be an integer or a float. A value of 0 results in no translation, while positive values move the avatar to the right and negative values move it to the left. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/translateOption" }] } }, "propertyNames": { "maxLength": 128 }, "additionalProperties": false, "maxProperties": 512 };
5
+ const schema11 = { "$id": "https://cdn.hopjs.net/npm/@dicebear/schema@1.0.0/dist/options.min.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "DiceBear options schema", "type": "object", "definitions": { "flip": { "type": "string", "enum": ["none", "horizontal", "vertical", "both"] }, "rotate": { "type": "number", "minimum": -360, "maximum": 360 }, "scale": { "type": "number", "minimum": 0, "maximum": 10 }, "translate": { "type": "number", "minimum": -1000, "maximum": 1000 }, "borderRadius": { "type": "number", "minimum": 0, "maximum": 50 }, "color": { "type": "string", "pattern": "^#?([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$" }, "colorFill": { "type": "string", "enum": ["solid", "linear", "radial"] }, "colorFillStops": { "type": "integer", "minimum": 2 }, "fontFamilyName": { "type": "string", "pattern": "^[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*(, ?[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*)*$", "maxLength": 256 }, "fontWeight": { "type": "integer", "minimum": 1, "maximum": 1000 }, "variantName": { "type": "string", "pattern": "^[a-z][a-zA-Z0-9]*$", "maxLength": 64 }, "rotateOption": { "anyOf": [{ "$ref": "#/definitions/rotate" }, { "type": "array", "items": { "$ref": "#/definitions/rotate" }, "minItems": 0, "maxItems": 2 }] }, "translateOption": { "anyOf": [{ "$ref": "#/definitions/translate" }, { "type": "array", "items": { "$ref": "#/definitions/translate" }, "minItems": 0, "maxItems": 2 }] }, "scaleOption": { "anyOf": [{ "$ref": "#/definitions/scale" }, { "type": "array", "items": { "$ref": "#/definitions/scale" }, "minItems": 0, "maxItems": 2 }] } }, "properties": { "seed": { "type": "string", "description": "The starting value for the pseudorandom number generator (PRNG) used in the avatar generation process. This option is essential for creating unique and consistent avatars. By setting a specific seed, you ensure that the same sequence of random characteristics is applied, allowing identical avatars to be reproduced. This is especially valuable for maintaining consistency across sessions and allowing users to share or recreate their personalized avatars.", "maxLength": 1024 }, "size": { "type": "integer", "description": "Specifies the dimensions of the avatar in pixels. If no size is specified, the avatar defaults to a responsive design or scales to 100% of its container. This flexibility allows the avatar to seamlessly adapt to different screen sizes and layouts, ensuring optimal display across devices and environments.", "minimum": 1, "maximum": 4096 }, "idRandomization": { "type": "boolean", "description": "Generates random values for all IDs present in the SVG. This process ensures that while the avatar appears visually identical, the underlying code remains unique. This is particularly useful for embedding the same avatar multiple times in a document without running into duplicate ID conflicts that can interfere with styles and scripts." }, "title": { "type": "string", "description": "Specifies an accessible title for the avatar. When set, the SVG will include a <title> element and an aria-label attribute, allowing screen readers and other assistive technologies to describe the avatar to users.", "maxLength": 256 }, "flip": { "description": "Specifies how the avatar will be flipped. Options include `none` for no flip, `horizontal` for a left-to-right flip, `vertical` for an upside-down flip, and `both` for a complete flip. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/flip" }, { "type": "array", "items": { "$ref": "#/definitions/flip" }, "minItems": 0, "maxItems": 4 }] }, "fontFamily": { "description": "Specifies the font family used for text rendering. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/fontFamilyName" }, { "type": "array", "items": { "$ref": "#/definitions/fontFamilyName" }, "minItems": 0, "maxItems": 128 }] }, "fontWeight": { "description": "Specifies the font weight used for text rendering. The value must be an integer between 1 and 1000. If specified as an array, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/fontWeight" }, { "type": "array", "items": { "$ref": "#/definitions/fontWeight" }, "minItems": 0, "maxItems": 128 }] }, "scale": { "description": "Sets the scaling of the avatar. A value of `1` corresponds to the original size of the avatar. This setting affects the size of the avatar itself, but not the size of the avatar container; any excess content will be clipped. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/scaleOption" }] }, "borderRadius": { "description": "This is the radius of the corners of the avatar. This value can be a float or an integer. A value of 0 means that the avatar has sharp corners, while larger values result in more rounded corners. The maximum value is 50, which turns the avatar into a complete circle. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "anyOf": [{ "$ref": "#/definitions/borderRadius" }, { "type": "array", "items": { "$ref": "#/definitions/borderRadius" }, "minItems": 0, "maxItems": 2 }] } }, "patternProperties": { "^[a-z][a-zA-Z0-9]*Probability$": { "type": "number", "description": "Represents the probability that a component of the avatar will be displayed. The value can be either a float or an integer, but is interpreted as a percentage. For example, a value of 0 means the part will never be displayed, while a value of 100 means it will always be displayed.", "minimum": 0, "maximum": 100 }, "^[a-z][a-zA-Z0-9]*Variant$": { "description": "Specifies which variants of the avatar part can be selected by the PRNG and their relative weights. A string or array of strings filters which variants the PRNG can choose from. An object maps variant names to non-negative weights, simultaneously filtering and weighting selection. Variant names must be camelCase identifiers.", "anyOf": [{ "$ref": "#/definitions/variantName" }, { "type": "array", "items": { "$ref": "#/definitions/variantName" }, "minItems": 0, "maxItems": 128 }, { "type": "object", "propertyNames": { "$ref": "#/definitions/variantName" }, "additionalProperties": { "type": "number", "minimum": 0 }, "minProperties": 1, "maxProperties": 512 }] }, "^[a-z][a-zA-Z0-9]*Color$": { "description": "Specifies which colors for the avatar component can be selected by the PRNG. If specified as a string or array with only one value, the value is fixed. However, if specified as an array with multiple values, the PRNG will choose from the available options. The color must be specified as a hex value.", "anyOf": [{ "$ref": "#/definitions/color" }, { "type": "array", "items": { "$ref": "#/definitions/color" }, "minItems": 0, "maxItems": 128 }] }, "^[a-z][a-zA-Z0-9]*ColorFill$": { "description": "Specifies the color fill method for the avatar component. Options include `solid` for a flat color, `linear` for a linear gradient, and `radial` for a radial gradient. If specified as a string or array with only one value, the value is fixed. However, if specified as an array with multiple values, the PRNG will choose from the available options.", "anyOf": [{ "$ref": "#/definitions/colorFill" }, { "type": "array", "items": { "$ref": "#/definitions/colorFill" }, "minItems": 0, "maxItems": 128 }] }, "^[a-z][a-zA-Z0-9]*ColorFillStops$": { "description": "Specifies the number of color stops for gradient fills. This value is only relevant when the color fill method is set to `linear` or `radial`. The minimum value is 2. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "anyOf": [{ "$ref": "#/definitions/colorFillStops" }, { "type": "array", "items": { "$ref": "#/definitions/colorFillStops" }, "minItems": 0, "maxItems": 2 }] }, "^[a-z][a-zA-Z0-9]*ColorAngle$": { "description": "Specifies the angle for the color gradient. This value can be an integer or a float. A value of 0 results in no rotation, while values between -360 and 360 define the degree of rotation. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/rotateOption" }] }, "^rotate$": { "description": "This is the rotation angle for the entire avatar. This value can be an integer or a float. A value of 0 results in no rotation, while values between -360 and 360 define the degree of rotation in both directions. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/rotateOption" }] }, "^translateY$": { "description": "This is the vertical translation of the entire avatar. This value can be an integer or a float. A value of 0 results in no translation, while positive values move the avatar down and negative values move it up. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/translateOption" }] }, "^translateX$": { "description": "This is the horizontal translation of the entire avatar. This value can be an integer or a float. A value of 0 results in no translation, while positive values move the avatar to the right and negative values move it to the left. If specified as an array, the PRNG will select a value within the specified range, including the values themselves.", "allOf": [{ "$ref": "#/definitions/translateOption" }] } }, "propertyNames": { "maxLength": 128 }, "additionalProperties": false, "maxProperties": 512 };
6
6
  const schema12 = { "type": "string", "enum": ["none", "horizontal", "vertical", "both"] };
7
7
  const schema14 = { "type": "string", "pattern": "^[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*(, ?[a-zA-Z0-9_\\-]+( [a-zA-Z0-9_\\-]+)*)*$", "maxLength": 256 };
8
8
  const schema16 = { "type": "integer", "minimum": 1, "maximum": 1000 };
@@ -472,7 +472,7 @@ else {
472
472
  }
473
473
  }
474
474
  } validate16.errors = vErrors; return errors === 0; }
475
- function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { /*# sourceURL="https://cdn.hopjs.net/npm/@dicebear/schema@0.14.1/dist/options.min.json" */ ; let vErrors = null; let errors = 0; if (errors === 0) {
475
+ function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { /*# sourceURL="https://cdn.hopjs.net/npm/@dicebear/schema@1.0.0/dist/options.min.json" */ ; let vErrors = null; let errors = 0; if (errors === 0) {
476
476
  if (data && typeof data == "object" && !Array.isArray(data)) {
477
477
  if (Object.keys(data).length > 512) {
478
478
  validate10.errors = [{ instancePath, schemaPath: "#/maxProperties", keyword: "maxProperties", params: { limit: 512 }, message: "must NOT have more than 512 properties" }];
@@ -631,8 +631,8 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
631
631
  const _errs16 = errors;
632
632
  if (errors === _errs16) {
633
633
  if (Array.isArray(data4)) {
634
- if (data4.length > 128) {
635
- const err4 = { instancePath: instancePath + "/flip", schemaPath: "#/properties/flip/anyOf/1/maxItems", keyword: "maxItems", params: { limit: 128 }, message: "must NOT have more than 128 items" };
634
+ if (data4.length > 4) {
635
+ const err4 = { instancePath: instancePath + "/flip", schemaPath: "#/properties/flip/anyOf/1/maxItems", keyword: "maxItems", params: { limit: 4 }, message: "must NOT have more than 4 items" };
636
636
  if (vErrors === null) {
637
637
  vErrors = [err4];
638
638
  }