@dicebear/core 10.0.0-rc.4 → 10.0.0-rc.5
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/README.md +2 -1
- package/lib/Options.d.ts +8 -7
- package/lib/Options.js +16 -8
- package/lib/Prng/Mulberry32.js +1 -1
- package/lib/Prng.d.ts +24 -12
- package/lib/Prng.js +64 -27
- package/lib/Renderer.js +11 -2
- package/lib/Resolver.d.ts +18 -10
- package/lib/Resolver.js +37 -26
- package/lib/Style/Component.d.ts +7 -5
- package/lib/Style/Component.js +6 -10
- package/lib/Style/ComponentTranslate.d.ts +3 -9
- package/lib/Style/ComponentTranslate.js +2 -8
- package/lib/StyleDefinition.d.ts +15 -4
- package/lib/Validator/OptionsValidator.js +4 -4
- package/lib/Validator/StyleValidator.js +694 -327
- package/package.json +2 -2
package/lib/StyleDefinition.d.ts
CHANGED
|
@@ -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?:
|
|
60
|
-
readonly y?:
|
|
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?:
|
|
71
|
-
readonly scale?:
|
|
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.
|
|
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.
|
|
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 >
|
|
635
|
-
const err4 = { instancePath: instancePath + "/flip", schemaPath: "#/properties/flip/anyOf/1/maxItems", keyword: "maxItems", params: { limit:
|
|
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
|
}
|