@dicebear/core 11.0.0-rc.2 → 11.0.0-rc.4
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/Options.d.ts +10 -0
- package/lib/Options.js +18 -3
- package/lib/OptionsDescriptor.js +1 -0
- package/lib/Renderer.js +12 -2
- package/lib/Resolver.d.ts +6 -0
- package/lib/Resolver.js +8 -0
- package/lib/StyleOptions.d.ts +1 -0
- package/lib/Utils/Depth.d.ts +26 -0
- package/lib/Utils/Depth.js +47 -0
- package/lib/Utils/Text.d.ts +16 -0
- package/lib/Utils/Text.js +34 -0
- package/lib/Validator/OptionsValidator.js +9 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +9 -1
- package/lib/lite.d.ts +0 -1
- package/lib/lite.js +0 -1
- package/package.json +2 -2
package/lib/Options.d.ts
CHANGED
|
@@ -13,9 +13,18 @@ import type { StyleOptions, StyleOptionsFlipValue, StyleOptionsColorFillValue, S
|
|
|
13
13
|
export declare class Options<D = unknown> {
|
|
14
14
|
#private;
|
|
15
15
|
constructor(data?: StyleOptions<D>);
|
|
16
|
+
/**
|
|
17
|
+
* The seed, with every lone surrogate replaced by U+FFFD: ill-formed text
|
|
18
|
+
* has no meaning another port could reproduce, so the hash and the initials
|
|
19
|
+
* read the same text everywhere.
|
|
20
|
+
*/
|
|
16
21
|
seed(): string | undefined;
|
|
17
22
|
size(): number | undefined;
|
|
18
23
|
idRandomization(): boolean | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The title, with every lone surrogate replaced by U+FFFD, so no ill-formed
|
|
26
|
+
* text reaches the SVG.
|
|
27
|
+
*/
|
|
19
28
|
title(): string | undefined;
|
|
20
29
|
flip(): readonly StyleOptionsFlipValue[];
|
|
21
30
|
fontFamily(): readonly string[];
|
|
@@ -38,6 +47,7 @@ export declare class Options<D = unknown> {
|
|
|
38
47
|
*/
|
|
39
48
|
animationSpeedFor(name: string): Range | undefined;
|
|
40
49
|
animationDelay(): Range | undefined;
|
|
50
|
+
animationRespectReducedMotion(): boolean | undefined;
|
|
41
51
|
/**
|
|
42
52
|
* Returns the `${name}AnimationDelay` option for one animation name as a
|
|
43
53
|
* range, or `undefined` when unset.
|
package/lib/Options.js
CHANGED
|
@@ -9,7 +9,8 @@ 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 _Options_instances, _Options_data, _Options_tags, _Options_dynamic, _Options_asArray, _Options_toRange;
|
|
12
|
+
var _Options_instances, _Options_data, _Options_tags, _Options_dynamic, _Options_asArray, _Options_wellFormed, _Options_toRange;
|
|
13
|
+
import { Text } from './Utils/Text.js';
|
|
13
14
|
/**
|
|
14
15
|
* Validates the raw user-supplied options and exposes them through typed
|
|
15
16
|
* accessors. Each accessor returns the user's input in a normalized form
|
|
@@ -27,8 +28,13 @@ export class Options {
|
|
|
27
28
|
_Options_tags.set(this, void 0);
|
|
28
29
|
__classPrivateFieldSet(this, _Options_data, structuredClone(data), "f");
|
|
29
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The seed, with every lone surrogate replaced by U+FFFD: ill-formed text
|
|
33
|
+
* has no meaning another port could reproduce, so the hash and the initials
|
|
34
|
+
* read the same text everywhere.
|
|
35
|
+
*/
|
|
30
36
|
seed() {
|
|
31
|
-
return __classPrivateFieldGet(this, _Options_data, "f").seed;
|
|
37
|
+
return __classPrivateFieldGet(this, _Options_instances, "m", _Options_wellFormed).call(this, __classPrivateFieldGet(this, _Options_data, "f").seed);
|
|
32
38
|
}
|
|
33
39
|
size() {
|
|
34
40
|
return __classPrivateFieldGet(this, _Options_data, "f").size;
|
|
@@ -36,8 +42,12 @@ export class Options {
|
|
|
36
42
|
idRandomization() {
|
|
37
43
|
return __classPrivateFieldGet(this, _Options_data, "f").idRandomization;
|
|
38
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The title, with every lone surrogate replaced by U+FFFD, so no ill-formed
|
|
47
|
+
* text reaches the SVG.
|
|
48
|
+
*/
|
|
39
49
|
title() {
|
|
40
|
-
return __classPrivateFieldGet(this, _Options_data, "f").title;
|
|
50
|
+
return __classPrivateFieldGet(this, _Options_instances, "m", _Options_wellFormed).call(this, __classPrivateFieldGet(this, _Options_data, "f").title);
|
|
41
51
|
}
|
|
42
52
|
flip() {
|
|
43
53
|
return __classPrivateFieldGet(this, _Options_instances, "m", _Options_asArray).call(this, __classPrivateFieldGet(this, _Options_data, "f").flip);
|
|
@@ -86,6 +96,9 @@ export class Options {
|
|
|
86
96
|
animationDelay() {
|
|
87
97
|
return __classPrivateFieldGet(this, _Options_instances, "m", _Options_toRange).call(this, __classPrivateFieldGet(this, _Options_data, "f").animationDelay);
|
|
88
98
|
}
|
|
99
|
+
animationRespectReducedMotion() {
|
|
100
|
+
return __classPrivateFieldGet(this, _Options_data, "f").animationRespectReducedMotion;
|
|
101
|
+
}
|
|
89
102
|
/**
|
|
90
103
|
* Returns the `${name}AnimationDelay` option for one animation name as a
|
|
91
104
|
* range, or `undefined` when unset.
|
|
@@ -166,6 +179,8 @@ _Options_data = new WeakMap(), _Options_tags = new WeakMap(), _Options_instances
|
|
|
166
179
|
return value;
|
|
167
180
|
}
|
|
168
181
|
return [value];
|
|
182
|
+
}, _Options_wellFormed = function _Options_wellFormed(value) {
|
|
183
|
+
return typeof value === 'string' ? Text.wellFormed(value) : value;
|
|
169
184
|
}, _Options_toRange = function _Options_toRange(value) {
|
|
170
185
|
if (value === undefined) {
|
|
171
186
|
return undefined;
|
package/lib/OptionsDescriptor.js
CHANGED
|
@@ -115,6 +115,7 @@ _a = OptionsDescriptor, _OptionsDescriptor_descriptor = new WeakMap(), _OptionsD
|
|
|
115
115
|
result.animation = { type: 'boolean' };
|
|
116
116
|
result.animationSpeed = { type: 'range', min: 0.1, max: 10 };
|
|
117
117
|
result.animationDelay = { type: 'range', min: -3600, max: 3600 };
|
|
118
|
+
result.animationRespectReducedMotion = { type: 'boolean' };
|
|
118
119
|
for (const name of __classPrivateFieldGet(this, _OptionsDescriptor_style, "f").animationNames()) {
|
|
119
120
|
result[`${name}Animation`] = { type: 'boolean' };
|
|
120
121
|
result[`${name}AnimationSpeed`] = { type: 'range', min: 0.1, max: 10 };
|
package/lib/Renderer.js
CHANGED
|
@@ -245,7 +245,7 @@ _a = Renderer, _Renderer_style = new WeakMap(), _Renderer_resolver = new WeakMap
|
|
|
245
245
|
mergedAttributes = { ...userAttributes, transform: allParts.join(' ') };
|
|
246
246
|
}
|
|
247
247
|
const attrs = __classPrivateFieldGet(this, _Renderer_instances, "m", _Renderer_renderAttributes).call(this, mergedAttributes);
|
|
248
|
-
return __classPrivateFieldGet(this, _Renderer_instances, "m", _Renderer_applyAnimations).call(this, `<use${attrs} href="#${id}"/>`, element, active);
|
|
248
|
+
return __classPrivateFieldGet(this, _Renderer_instances, "m", _Renderer_applyAnimations).call(this, `<use${attrs} href="#${id}" data-dicebear-component="${componentName}"/>`, element, active);
|
|
249
249
|
}, _Renderer_buildTransforms = function _Renderer_buildTransforms(component) {
|
|
250
250
|
const { rotate, translateX, translateY, scale } = __classPrivateFieldGet(this, _Renderer_resolver, "f").componentTransform(component.name());
|
|
251
251
|
if (translateX === 0 && translateY === 0 && rotate === 0 && scale === 1) {
|
|
@@ -356,6 +356,12 @@ _a = Renderer, _Renderer_style = new WeakMap(), _Renderer_resolver = new WeakMap
|
|
|
356
356
|
? `${name}:${Number.format(__classPrivateFieldGet(this, _Renderer_resolver, "f").animationSpeedFor(name))}:${Number.format(__classPrivateFieldGet(this, _Renderer_resolver, "f").animationDelayFor(name))}`
|
|
357
357
|
: `${name}:off`);
|
|
358
358
|
const named = states.length > 0 ? ':' + states.join(',') : '';
|
|
359
|
+
// Without the media query the rules apply to every viewer. A render that
|
|
360
|
+
// keeps the query must not pick them up on the same page, so the two get
|
|
361
|
+
// different names. The default adds nothing and leaves the hash as it was.
|
|
362
|
+
const motion = __classPrivateFieldGet(this, _Renderer_resolver, "f").animationRespectReducedMotion()
|
|
363
|
+
? ''
|
|
364
|
+
: ':nomotionquery';
|
|
359
365
|
return (__classPrivateFieldSet(this, _Renderer_cachedAnimationHash, Fnv1a.hex((__classPrivateFieldGet(this, _Renderer_style, "f").meta().source().name() ?? '') +
|
|
360
366
|
':' +
|
|
361
367
|
__classPrivateFieldGet(this, _Renderer_resolver, "f").seed() +
|
|
@@ -364,6 +370,7 @@ _a = Renderer, _Renderer_style = new WeakMap(), _Renderer_resolver = new WeakMap
|
|
|
364
370
|
':' +
|
|
365
371
|
Number.format(__classPrivateFieldGet(this, _Renderer_resolver, "f").animationDelay()) +
|
|
366
372
|
named +
|
|
373
|
+
motion +
|
|
367
374
|
random), "f"));
|
|
368
375
|
}, _Renderer_activeAnimations = function _Renderer_activeAnimations(element) {
|
|
369
376
|
const animations = element.animations();
|
|
@@ -495,7 +502,10 @@ _a = Renderer, _Renderer_style = new WeakMap(), _Renderer_resolver = new WeakMap
|
|
|
495
502
|
while (__classPrivateFieldGet(this, _Renderer_defs, "f").has(key)) {
|
|
496
503
|
key += '-';
|
|
497
504
|
}
|
|
498
|
-
|
|
505
|
+
const css = __classPrivateFieldGet(this, _Renderer_keyframesCss, "f").join('') + __classPrivateFieldGet(this, _Renderer_animationCss, "f").join('');
|
|
506
|
+
__classPrivateFieldGet(this, _Renderer_defs, "f").set(key, __classPrivateFieldGet(this, _Renderer_resolver, "f").animationRespectReducedMotion()
|
|
507
|
+
? `<style>@media (prefers-reduced-motion:no-preference){${css}}</style>`
|
|
508
|
+
: `<style>${css}</style>`);
|
|
499
509
|
};
|
|
500
510
|
/**
|
|
501
511
|
* The canonical track order, outermost wrapper to innermost. It mirrors the
|
package/lib/Resolver.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ export declare class Resolver<D = unknown> {
|
|
|
40
40
|
* always follow the global offset.
|
|
41
41
|
*/
|
|
42
42
|
animationDelayFor(name: string | undefined): number;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the animation CSS sits inside a `prefers-reduced-motion` media
|
|
45
|
+
* query. On by default. Renderers that ignore media queries need it off,
|
|
46
|
+
* and the app then decides about `animation` from the system setting.
|
|
47
|
+
*/
|
|
48
|
+
animationRespectReducedMotion(): boolean;
|
|
43
49
|
title(): string | undefined;
|
|
44
50
|
flip(): StyleOptionsFlipValue;
|
|
45
51
|
fontFamily(): string;
|
package/lib/Resolver.js
CHANGED
|
@@ -97,6 +97,14 @@ export class Resolver {
|
|
|
97
97
|
}
|
|
98
98
|
return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memoFloat).call(this, `${name}AnimationDelay`, range, 0);
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Whether the animation CSS sits inside a `prefers-reduced-motion` media
|
|
102
|
+
* query. On by default. Renderers that ignore media queries need it off,
|
|
103
|
+
* and the app then decides about `animation` from the system setting.
|
|
104
|
+
*/
|
|
105
|
+
animationRespectReducedMotion() {
|
|
106
|
+
return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'animationRespectReducedMotion', () => __classPrivateFieldGet(this, _Resolver_options, "f").animationRespectReducedMotion() ?? true);
|
|
107
|
+
}
|
|
100
108
|
title() {
|
|
101
109
|
return __classPrivateFieldGet(this, _Resolver_instances, "m", _Resolver_memo).call(this, 'title', () => __classPrivateFieldGet(this, _Resolver_options, "f").title());
|
|
102
110
|
}
|
package/lib/StyleOptions.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export interface StyleOptionsBase {
|
|
|
46
46
|
readonly animation?: boolean;
|
|
47
47
|
readonly animationSpeed?: number | readonly [number, number];
|
|
48
48
|
readonly animationDelay?: number | readonly [number, number];
|
|
49
|
+
readonly animationRespectReducedMotion?: boolean;
|
|
49
50
|
}
|
|
50
51
|
type ComponentVariantOption<D, K extends string> = VariantNames<D, K> | readonly VariantNames<D, K>[] | Readonly<Partial<Record<VariantNames<D, K>, number>>>;
|
|
51
52
|
type IsAlias<D, C extends string> = D extends {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nesting limit for style definitions and options.
|
|
3
|
+
*
|
|
4
|
+
* A port may turn down a value nested deeper than {@link Depth.MAX} levels
|
|
5
|
+
* before it runs the schema, and some must: their schema validators run out of
|
|
6
|
+
* stack on a few thousand levels. Every port applies the same limit, so a
|
|
7
|
+
* definition renders in all of them or in none. Valid options nest two levels
|
|
8
|
+
* and the deepest style definition uses less than a quarter of the limit.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Depth {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* How many levels of objects and arrays a value may nest, counting the value
|
|
14
|
+
* itself as the first.
|
|
15
|
+
*/
|
|
16
|
+
static readonly MAX = 64;
|
|
17
|
+
/**
|
|
18
|
+
* What a validator reports when {@link Depth.exceeds} holds.
|
|
19
|
+
*/
|
|
20
|
+
static readonly MESSAGE: string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns whether `value` nests objects and arrays deeper than
|
|
23
|
+
* {@link Depth.MAX} levels. A value that contains itself does.
|
|
24
|
+
*/
|
|
25
|
+
static exceeds(value: unknown): boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
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");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _a, _Depth_exceeds;
|
|
7
|
+
/**
|
|
8
|
+
* The nesting limit for style definitions and options.
|
|
9
|
+
*
|
|
10
|
+
* A port may turn down a value nested deeper than {@link Depth.MAX} levels
|
|
11
|
+
* before it runs the schema, and some must: their schema validators run out of
|
|
12
|
+
* stack on a few thousand levels. Every port applies the same limit, so a
|
|
13
|
+
* definition renders in all of them or in none. Valid options nest two levels
|
|
14
|
+
* and the deepest style definition uses less than a quarter of the limit.
|
|
15
|
+
*/
|
|
16
|
+
export class Depth {
|
|
17
|
+
/**
|
|
18
|
+
* Returns whether `value` nests objects and arrays deeper than
|
|
19
|
+
* {@link Depth.MAX} levels. A value that contains itself does.
|
|
20
|
+
*/
|
|
21
|
+
static exceeds(value) {
|
|
22
|
+
return __classPrivateFieldGet(_a, _a, "m", _Depth_exceeds).call(_a, value, 1, new Map());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_a = Depth, _Depth_exceeds = function _Depth_exceeds(value, depth, checked) {
|
|
26
|
+
if (value === null || typeof value !== 'object') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (depth > _a.MAX) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if ((checked.get(value) ?? 0) >= depth) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
checked.set(value, depth);
|
|
36
|
+
const items = Array.isArray(value) ? value : Object.values(value);
|
|
37
|
+
return items.some((item) => __classPrivateFieldGet(_a, _a, "m", _Depth_exceeds).call(_a, item, depth + 1, checked));
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* How many levels of objects and arrays a value may nest, counting the value
|
|
41
|
+
* itself as the first.
|
|
42
|
+
*/
|
|
43
|
+
Depth.MAX = 64;
|
|
44
|
+
/**
|
|
45
|
+
* What a validator reports when {@link Depth.exceeds} holds.
|
|
46
|
+
*/
|
|
47
|
+
Depth.MESSAGE = `nesting is deeper than the ${_a.MAX} levels this port reads`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes user text well-formed before the core reads it.
|
|
3
|
+
*
|
|
4
|
+
* A JS string can hold a lone UTF-16 surrogate, for example half of an emoji
|
|
5
|
+
* cut off by a slice. Ports that keep strings as UTF-8 can hold ill-formed
|
|
6
|
+
* bytes instead. Neither has a meaning another port could reproduce, so every
|
|
7
|
+
* port replaces them with U+FFFD first. Here that is each lone surrogate, the
|
|
8
|
+
* same as `String.prototype.toWellFormed()`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Text {
|
|
11
|
+
/**
|
|
12
|
+
* Returns `value` with every lone surrogate replaced by U+FFFD. A
|
|
13
|
+
* well-formed string comes back unchanged.
|
|
14
|
+
*/
|
|
15
|
+
static wellFormed(value: string): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes user text well-formed before the core reads it.
|
|
3
|
+
*
|
|
4
|
+
* A JS string can hold a lone UTF-16 surrogate, for example half of an emoji
|
|
5
|
+
* cut off by a slice. Ports that keep strings as UTF-8 can hold ill-formed
|
|
6
|
+
* bytes instead. Neither has a meaning another port could reproduce, so every
|
|
7
|
+
* port replaces them with U+FFFD first. Here that is each lone surrogate, the
|
|
8
|
+
* same as `String.prototype.toWellFormed()`.
|
|
9
|
+
*/
|
|
10
|
+
export class Text {
|
|
11
|
+
/**
|
|
12
|
+
* Returns `value` with every lone surrogate replaced by U+FFFD. A
|
|
13
|
+
* well-formed string comes back unchanged.
|
|
14
|
+
*/
|
|
15
|
+
static wellFormed(value) {
|
|
16
|
+
let result = '';
|
|
17
|
+
let start = 0;
|
|
18
|
+
for (let i = 0; i < value.length; i++) {
|
|
19
|
+
const unit = value.charCodeAt(i);
|
|
20
|
+
if (unit < 0xd800 || unit > 0xdfff) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const next = i + 1 < value.length ? value.charCodeAt(i + 1) : 0;
|
|
24
|
+
if (unit <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
|
|
25
|
+
// A valid pair: keep both units.
|
|
26
|
+
i++;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
result += value.slice(start, i) + '�';
|
|
30
|
+
start = i + 1;
|
|
31
|
+
}
|
|
32
|
+
return start === 0 ? value : result + value.slice(start);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1192,6 +1192,14 @@ const validate = (function () {
|
|
|
1192
1192
|
errorCount++;
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
|
+
if (data.animationRespectReducedMotion !== undefined && hasOwn(data, "animationRespectReducedMotion")) {
|
|
1196
|
+
if (!(typeof data.animationRespectReducedMotion === "boolean")) {
|
|
1197
|
+
if (validate.errors === null)
|
|
1198
|
+
validate.errors = [];
|
|
1199
|
+
validate.errors.push({ keywordLocation: "#/properties/animationRespectReducedMotion/type", instanceLocation: "#/animationRespectReducedMotion" });
|
|
1200
|
+
errorCount++;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1195
1203
|
if (errorCount === prev0) {
|
|
1196
1204
|
for (const key1 of Object.keys(data)) {
|
|
1197
1205
|
if (pattern2.test(key1)) {
|
|
@@ -1592,7 +1600,7 @@ const validate = (function () {
|
|
|
1592
1600
|
}
|
|
1593
1601
|
}
|
|
1594
1602
|
for (const key4 of Object.keys(data)) {
|
|
1595
|
-
if (key4 !== "seed" && key4 !== "size" && key4 !== "idRandomization" && key4 !== "title" && key4 !== "flip" && key4 !== "rotate" && key4 !== "scale" && key4 !== "translateX" && key4 !== "translateY" && key4 !== "borderRadius" && key4 !== "fontFamily" && key4 !== "fontWeight" && key4 !== "tags" && key4 !== "animation" && key4 !== "animationSpeed" && key4 !== "animationDelay" && !pattern2.test(key4) && !pattern4.test(key4) && !pattern5.test(key4) && !pattern7.test(key4) && !pattern8.test(key4) && !pattern9.test(key4) && !pattern10.test(key4) && !pattern11.test(key4) && !pattern12.test(key4) && !pattern13.test(key4)) {
|
|
1603
|
+
if (key4 !== "seed" && key4 !== "size" && key4 !== "idRandomization" && key4 !== "title" && key4 !== "flip" && key4 !== "rotate" && key4 !== "scale" && key4 !== "translateX" && key4 !== "translateY" && key4 !== "borderRadius" && key4 !== "fontFamily" && key4 !== "fontWeight" && key4 !== "tags" && key4 !== "animation" && key4 !== "animationSpeed" && key4 !== "animationDelay" && key4 !== "animationRespectReducedMotion" && !pattern2.test(key4) && !pattern4.test(key4) && !pattern5.test(key4) && !pattern7.test(key4) && !pattern8.test(key4) && !pattern9.test(key4) && !pattern10.test(key4) && !pattern11.test(key4) && !pattern12.test(key4) && !pattern13.test(key4)) {
|
|
1596
1604
|
if (validate.errors === null)
|
|
1597
1605
|
validate.errors = [];
|
|
1598
1606
|
validate.errors.push({ keywordLocation: "#/additionalProperties", instanceLocation: "#/" + pointerPart(key4) });
|
package/lib/index.d.ts
CHANGED
|
@@ -18,6 +18,5 @@ export declare class Avatar<D = unknown> extends AvatarBase<D> {
|
|
|
18
18
|
constructor(style: StyleBase<D>, optionsInput?: StyleOptions<D>);
|
|
19
19
|
}
|
|
20
20
|
export type { StyleDefinition };
|
|
21
|
-
export { Color } from './Utils/Color.js';
|
|
22
21
|
export { OptionsDescriptor } from './OptionsDescriptor.js';
|
|
23
22
|
export type { StyleOptions } from './StyleOptions.js';
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,9 @@ import { Style as StyleBase } from './Style.js';
|
|
|
2
2
|
import { Avatar as AvatarBase } from './Avatar.js';
|
|
3
3
|
import { StyleValidator } from './Validator/StyleValidator.js';
|
|
4
4
|
import { OptionsValidator } from './Validator/OptionsValidator.js';
|
|
5
|
+
import { StyleValidationError } from './Error/StyleValidationError.js';
|
|
6
|
+
import { OptionsValidationError } from './Error/OptionsValidationError.js';
|
|
7
|
+
import { Depth } from './Utils/Depth.js';
|
|
5
8
|
/**
|
|
6
9
|
* A style whose definition is checked against the definition schema before
|
|
7
10
|
* it is parsed. `@dicebear/core/lite` exports the same class without the
|
|
@@ -9,6 +12,9 @@ import { OptionsValidator } from './Validator/OptionsValidator.js';
|
|
|
9
12
|
*/
|
|
10
13
|
export class Style extends StyleBase {
|
|
11
14
|
constructor(data) {
|
|
15
|
+
if (Depth.exceeds(data)) {
|
|
16
|
+
throw new StyleValidationError([{ message: Depth.MESSAGE }]);
|
|
17
|
+
}
|
|
12
18
|
StyleValidator.validate(data);
|
|
13
19
|
super(data);
|
|
14
20
|
}
|
|
@@ -20,9 +26,11 @@ export class Style extends StyleBase {
|
|
|
20
26
|
*/
|
|
21
27
|
export class Avatar extends AvatarBase {
|
|
22
28
|
constructor(style, optionsInput) {
|
|
29
|
+
if (Depth.exceeds(optionsInput)) {
|
|
30
|
+
throw new OptionsValidationError([{ message: Depth.MESSAGE }]);
|
|
31
|
+
}
|
|
23
32
|
OptionsValidator.validate(optionsInput ?? {});
|
|
24
33
|
super(style, optionsInput);
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
|
-
export { Color } from './Utils/Color.js';
|
|
28
36
|
export { OptionsDescriptor } from './OptionsDescriptor.js';
|
package/lib/lite.d.ts
CHANGED
package/lib/lite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/core",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.4",
|
|
4
4
|
"description": "Unique avatars from dozens of styles — deterministic, customizable, vector-based.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"avatar",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"test": "node --test"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@dicebear/schema": "^
|
|
45
|
+
"@dicebear/schema": "^3.0.0-rc.1",
|
|
46
46
|
"@exodus/schemasafe": "^1.3.0",
|
|
47
47
|
"@tsconfig/recommended": "^1.0.13",
|
|
48
48
|
"del-cli": "^7.0.0",
|