@dicebear/core 11.0.0-rc.4 → 11.1.0-rc.1

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/index.d.ts CHANGED
@@ -1,22 +1,27 @@
1
1
  import { Style as StyleBase, type StyleDefinition } from './Style.js';
2
2
  import { Avatar as AvatarBase } from './Avatar.js';
3
- import type { StyleOptions } from './StyleOptions.js';
3
+ import type { NoInferStyle, StyleOptions } from './StyleOptions.js';
4
4
  /**
5
- * A style whose definition is checked against the definition schema before
6
- * it is parsed. `@dicebear/core/lite` exports the same class without the
7
- * check, for definitions that come from your own code.
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 are checked against the options schema before it
14
- * renders. `@dicebear/core/lite` exports the same class without the check,
15
- * for options that come from your own code.
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
- constructor(style: StyleBase<D>, optionsInput?: StyleOptions<D>);
18
+ constructor(style: StyleBase<D>, optionsInput?: StyleOptions<NoInferStyle<D>>);
19
19
  }
20
20
  export type { StyleDefinition };
21
21
  export { OptionsDescriptor } from './OptionsDescriptor.js';
22
22
  export type { StyleOptions } from './StyleOptions.js';
23
+ export { ValidationError } from './Error/ValidationError.js';
24
+ export type { ValidationErrorDetail } from './Error/ValidationError.js';
25
+ export { StyleValidationError } from './Error/StyleValidationError.js';
26
+ export { OptionsValidationError } from './Error/OptionsValidationError.js';
27
+ export { CircularColorReferenceError } from './Error/CircularColorReferenceError.js';
package/lib/index.js CHANGED
@@ -2,35 +2,30 @@ 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
5
  /**
9
- * A style whose definition is checked against the definition schema before
10
- * it is parsed. `@dicebear/core/lite` exports the same class without the
11
- * check, for definitions that come from your own code.
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.
12
9
  */
13
10
  export class Style extends StyleBase {
14
11
  constructor(data) {
15
- if (Depth.exceeds(data)) {
16
- throw new StyleValidationError([{ message: Depth.MESSAGE }]);
17
- }
18
12
  StyleValidator.validate(data);
19
13
  super(data);
20
14
  }
21
15
  }
22
16
  /**
23
- * An avatar whose options are checked against the options schema before it
24
- * renders. `@dicebear/core/lite` exports the same class without the check,
25
- * for options that come from your own code.
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.
26
20
  */
27
21
  export class Avatar extends AvatarBase {
28
22
  constructor(style, optionsInput) {
29
- if (Depth.exceeds(optionsInput)) {
30
- throw new OptionsValidationError([{ message: Depth.MESSAGE }]);
31
- }
32
- OptionsValidator.validate(optionsInput ?? {});
23
+ OptionsValidator.validate(optionsInput);
33
24
  super(style, optionsInput);
34
25
  }
35
26
  }
36
27
  export { OptionsDescriptor } from './OptionsDescriptor.js';
28
+ export { ValidationError } from './Error/ValidationError.js';
29
+ export { StyleValidationError } from './Error/StyleValidationError.js';
30
+ export { OptionsValidationError } from './Error/OptionsValidationError.js';
31
+ export { CircularColorReferenceError } from './Error/CircularColorReferenceError.js';
package/lib/lite.d.ts CHANGED
@@ -2,3 +2,8 @@ export { Style, type StyleDefinition } from './Style.js';
2
2
  export { Avatar } from './Avatar.js';
3
3
  export { OptionsDescriptor } from './OptionsDescriptor.js';
4
4
  export type { StyleOptions } from './StyleOptions.js';
5
+ export { ValidationError } from './Error/ValidationError.js';
6
+ export type { ValidationErrorDetail } from './Error/ValidationError.js';
7
+ export { StyleValidationError } from './Error/StyleValidationError.js';
8
+ export { OptionsValidationError } from './Error/OptionsValidationError.js';
9
+ export { CircularColorReferenceError } from './Error/CircularColorReferenceError.js';
package/lib/lite.js CHANGED
@@ -1,8 +1,14 @@
1
- // The same API as the package root, without the schema validators. A
2
- // bundle that imports this entry leaves the two compiled validators out,
3
- // which is about half of the library. Use it when the style definitions and
4
- // the options come from your own code, and stay on the root entry when
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';
9
+ // The lite entry validates nothing, but the circular color check still runs,
10
+ // and code shared with the root entry may catch the validation errors.
11
+ export { ValidationError } from './Error/ValidationError.js';
12
+ export { StyleValidationError } from './Error/StyleValidationError.js';
13
+ export { OptionsValidationError } from './Error/OptionsValidationError.js';
14
+ export { CircularColorReferenceError } from './Error/CircularColorReferenceError.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dicebear/core",
3
- "version": "11.0.0-rc.4",
3
+ "version": "11.1.0-rc.1",
4
4
  "description": "Unique avatars from dozens of styles — deterministic, customizable, vector-based.",
5
5
  "keywords": [
6
6
  "avatar",
@@ -27,6 +27,13 @@
27
27
  "./lite": "./lib/lite.js"
28
28
  },
29
29
  "types": "./lib/index.d.ts",
30
+ "typesVersions": {
31
+ "*": {
32
+ "lite": [
33
+ "./lib/lite.d.ts"
34
+ ]
35
+ }
36
+ },
30
37
  "sideEffects": false,
31
38
  "files": [
32
39
  "LICENSE",
@@ -42,7 +49,7 @@
42
49
  "test": "node --test"
43
50
  },
44
51
  "devDependencies": {
45
- "@dicebear/schema": "^3.0.0-rc.1",
52
+ "@dicebear/schema": "^3.1.0-rc.1",
46
53
  "@exodus/schemasafe": "^1.3.0",
47
54
  "@tsconfig/recommended": "^1.0.13",
48
55
  "del-cli": "^7.0.0",