@dicebear/core 11.0.0 → 11.1.0-rc.2
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 -2
- package/lib/OptionsDescriptor.d.ts +1 -0
- package/lib/OptionsDescriptor.js +4 -0
- package/lib/Resolver.js +12 -6
- package/lib/Style/Color.d.ts +5 -0
- package/lib/Style/Color.js +7 -0
- package/lib/Style.d.ts +4 -3
- package/lib/Style.js +6 -57
- package/lib/StyleDefinition.d.ts +1 -0
- package/lib/Utils/Color.d.ts +12 -0
- package/lib/Utils/Color.js +38 -4
- package/lib/Validator/OptionsSchemaValidator.d.ts +3 -0
- package/lib/Validator/OptionsSchemaValidator.js +1659 -0
- package/lib/Validator/OptionsValidator.d.ts +11 -2
- package/lib/Validator/OptionsValidator.js +21 -1653
- package/lib/Validator/StyleSchemaValidator.d.ts +3 -0
- package/lib/Validator/StyleSchemaValidator.js +5178 -0
- package/lib/Validator/StyleValidator.d.ts +13 -2
- package/lib/Validator/StyleValidator.js +165 -5113
- package/lib/index.d.ts +6 -6
- package/lib/index.js +7 -23
- package/lib/lite.js +5 -5
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ import { Style as StyleBase, type StyleDefinition } from './Style.js';
|
|
|
2
2
|
import { Avatar as AvatarBase } from './Avatar.js';
|
|
3
3
|
import type { NoInferStyle, StyleOptions } from './StyleOptions.js';
|
|
4
4
|
/**
|
|
5
|
-
* A style whose definition
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A style whose definition passes {@link StyleValidator} before it is parsed.
|
|
6
|
+
* `@dicebear/core/lite` exports the same class without the validation, for
|
|
7
|
+
* definitions that come from your own code.
|
|
8
8
|
*/
|
|
9
9
|
export declare class Style<D = unknown> extends StyleBase<D> {
|
|
10
10
|
constructor(data: D);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* An avatar whose options
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* An avatar whose options pass {@link OptionsValidator} before it renders.
|
|
14
|
+
* `@dicebear/core/lite` exports the same class without the validation, for
|
|
15
|
+
* options that come from your own code.
|
|
16
16
|
*/
|
|
17
17
|
export declare class Avatar<D = unknown> extends AvatarBase<D> {
|
|
18
18
|
constructor(style: StyleBase<D>, optionsInput?: StyleOptions<NoInferStyle<D>>);
|
package/lib/index.js
CHANGED
|
@@ -2,41 +2,25 @@ 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';
|
|
8
|
-
import { Finite } from './Utils/Finite.js';
|
|
9
5
|
/**
|
|
10
|
-
* A style whose definition
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* A style whose definition passes {@link StyleValidator} before it is parsed.
|
|
7
|
+
* `@dicebear/core/lite` exports the same class without the validation, for
|
|
8
|
+
* definitions that come from your own code.
|
|
13
9
|
*/
|
|
14
10
|
export class Style extends StyleBase {
|
|
15
11
|
constructor(data) {
|
|
16
|
-
if (Depth.exceeds(data)) {
|
|
17
|
-
throw new StyleValidationError([{ message: Depth.MESSAGE }]);
|
|
18
|
-
}
|
|
19
12
|
StyleValidator.validate(data);
|
|
20
13
|
super(data);
|
|
21
14
|
}
|
|
22
15
|
}
|
|
23
16
|
/**
|
|
24
|
-
* An avatar whose options
|
|
25
|
-
*
|
|
26
|
-
*
|
|
17
|
+
* An avatar whose options pass {@link OptionsValidator} before it renders.
|
|
18
|
+
* `@dicebear/core/lite` exports the same class without the validation, for
|
|
19
|
+
* options that come from your own code.
|
|
27
20
|
*/
|
|
28
21
|
export class Avatar extends AvatarBase {
|
|
29
22
|
constructor(style, optionsInput) {
|
|
30
|
-
|
|
31
|
-
throw new OptionsValidationError([{ message: Depth.MESSAGE }]);
|
|
32
|
-
}
|
|
33
|
-
OptionsValidator.validate(optionsInput ?? {});
|
|
34
|
-
const nonFinite = Finite.find(optionsInput);
|
|
35
|
-
if (nonFinite !== undefined) {
|
|
36
|
-
throw new OptionsValidationError([
|
|
37
|
-
{ instancePath: nonFinite, keyword: 'type', message: Finite.MESSAGE },
|
|
38
|
-
]);
|
|
39
|
-
}
|
|
23
|
+
OptionsValidator.validate(optionsInput);
|
|
40
24
|
super(style, optionsInput);
|
|
41
25
|
}
|
|
42
26
|
}
|
package/lib/lite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// The same API as the package root, without the
|
|
2
|
-
//
|
|
3
|
-
// which is about half of the library.
|
|
4
|
-
// the options come from your own code,
|
|
5
|
-
// either arrives from outside.
|
|
1
|
+
// The same API as the package root, without the validators. A bundle that
|
|
2
|
+
// imports this entry leaves `StyleValidator` and `OptionsValidator` out, and
|
|
3
|
+
// with them the two compiled schemas, which is about half of the library.
|
|
4
|
+
// Use it when the style definitions and the options come from your own code,
|
|
5
|
+
// and stay on the root entry when either arrives from outside.
|
|
6
6
|
export { Style } from './Style.js';
|
|
7
7
|
export { Avatar } from './Avatar.js';
|
|
8
8
|
export { OptionsDescriptor } from './OptionsDescriptor.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/core",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.1.0-rc.2",
|
|
4
4
|
"description": "Unique avatars from dozens of styles — deterministic, customizable, vector-based.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"avatar",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"test": "node --test"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@dicebear/schema": "^3.
|
|
52
|
+
"@dicebear/schema": "^3.1.0",
|
|
53
53
|
"@exodus/schemasafe": "^1.3.0",
|
|
54
54
|
"@tsconfig/recommended": "^1.0.13",
|
|
55
55
|
"del-cli": "^7.0.0",
|