design-token-library 0.1.0 → 0.3.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/dist/lib/queue.js CHANGED
@@ -14,8 +14,17 @@ export class Queue extends Subscribable {
14
14
  const targets = Object.freeze(Array.from(this.targets));
15
15
  this.targets.clear();
16
16
  this.needsQueue = true;
17
+ // A throwing subscriber must not stop the others, so each error is
18
+ // re-thrown on its own, like a DOM event listener's.
17
19
  for (const subscriber of this.subscribers) {
18
- subscriber.onChange(targets);
20
+ try {
21
+ subscriber.onChange(targets);
22
+ }
23
+ catch (error) {
24
+ queueMicrotask(() => {
25
+ throw error;
26
+ });
27
+ }
19
28
  }
20
29
  });
21
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAM5D,MAAM,OAAO,KACX,SAAQ,YAA8B;IAG9B,OAAO,GAAW,IAAI,GAAG,EAAE,CAAC;IAC5B,UAAU,GAAY,IAAI,CAAC;IAE5B,GAAG,CAAC,MAAS;QAClB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,cAAc,CAAC,GAAG,EAAE;YAClB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YAEvB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC1C,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAM5D,MAAM,OAAO,KACT,SAAQ,YAA8B;IAG9B,OAAO,GAAW,IAAI,GAAG,EAAE,CAAC;IAC5B,UAAU,GAAY,IAAI,CAAC;IAE5B,GAAG,CAAC,MAAS;QAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACL,CAAC;IAEO,KAAK;QACT,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,cAAc,CAAC,GAAG,EAAE;YAChB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YAEvB,mEAAmE;YACnE,qDAAqD;YACrD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACxC,IAAI,CAAC;oBACD,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACjC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,cAAc,CAAC,GAAG,EAAE;wBAChB,MAAM,KAAK,CAAC;oBAChB,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,81 @@
1
+ import type { Library } from "./library.js";
2
+ /**
3
+ * The key of a computed value's recipe and arguments.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare const COMPUTED: unique symbol;
8
+ /**
9
+ * The key of a recipe's name and function.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare const RECIPE: unique symbol;
14
+ /**
15
+ * Makes the {@link (Library:namespace).Recipe} of each function of
16
+ * `functions`, named by its key. A recipe takes its function's arguments, any
17
+ * of which may be refs, computed values, or values with them in it, and
18
+ * returns the
19
+ * {@link (Library:namespace).Computed} result. The function is called when
20
+ * the token is read, with the values of the refs, and again when one of the
21
+ * tokens it read changes.
22
+ *
23
+ * @remarks
24
+ * Arguments are evaluated when a function is called, before the library
25
+ * exists, so a function can't be given refs itself: its recipe defers it.
26
+ * The function must be pure, because it's called only when the token's value
27
+ * is resolved again. Its arguments are frozen, as token values are, so its
28
+ * parameters are typed readonly, as in `DesignToken.Values.Readonly.Color`:
29
+ * mutating one throws. A generic function's recipe takes the arguments of its
30
+ * constraint. Recipes are extended by spreading them into a new object, and a
31
+ * recipe's function is replaced in an extended library with {@link override}.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // darkenColor(color: DesignToken.Values.Readonly.Color, amount: number)
36
+ * export const Recipes = recipes({ darken: darkenColor, lighten: lightenColor });
37
+ * export const MyRecipes = { ...Recipes, ...recipes({ tint: tintColor }) };
38
+ *
39
+ * hover: { $type: DesignToken.Type.Color, $value: Recipes.darken(ref("colors.primary"), 0.2) }
40
+ * ```
41
+ *
42
+ * @public
43
+ */
44
+ export declare const recipes: <F extends Record<string, (...args: any[]) => unknown>>(functions: F) => Library.Recipes<F>;
45
+ /**
46
+ * Replaces the function of a recipe, in a library made by
47
+ * `extend()`, for every token that computes
48
+ * its value with the recipe. `fn` takes the recipe's arguments and returns a
49
+ * value of its result's type.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const contrast = library.extend({}, { recipes: [override(Recipes.darken, darkenMore)] });
54
+ * ```
55
+ *
56
+ * @public
57
+ */
58
+ export declare const override: <A extends unknown[], V>(recipe: Library.Recipe<A, V>, fn: (...args: A) => V) => Library.RecipeOverride;
59
+ /**
60
+ * Tests whether a value is a {@link (Library:namespace).Computed} value, a
61
+ * recipe's result, also one made by another copy of this package.
62
+ *
63
+ * @remarks
64
+ * The library computes a value anywhere in a token's value. A tool that reads
65
+ * a token's value as configured, with {@link configuredValueOf}, tells a
66
+ * computed value from other values with `isComputed()`, as it tells a ref
67
+ * with {@link isRef}.
68
+ *
69
+ * A computed value is a `Computed<unknown, never>` whatever its result and
70
+ * library, so a value typed as a computed value of a library is narrowed to
71
+ * it.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * isComputed(Recipes.darken(ref("colors.primary"), 0.2)); // true
76
+ * isComputed(hex("#0000ff")); // false
77
+ * ```
78
+ *
79
+ * @public
80
+ */
81
+ export declare const isComputed: (value: unknown) => value is Library.Computed<unknown, never>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The key of a computed value's recipe and arguments.
3
+ *
4
+ * @internal
5
+ */
6
+ export const COMPUTED = Symbol.for("design-token-library.computed");
7
+ /**
8
+ * The key of a recipe's name and function.
9
+ *
10
+ * @internal
11
+ */
12
+ export const RECIPE = Symbol.for("design-token-library.recipe");
13
+ /**
14
+ * Makes the {@link (Library:namespace).Recipe} of each function of
15
+ * `functions`, named by its key. A recipe takes its function's arguments, any
16
+ * of which may be refs, computed values, or values with them in it, and
17
+ * returns the
18
+ * {@link (Library:namespace).Computed} result. The function is called when
19
+ * the token is read, with the values of the refs, and again when one of the
20
+ * tokens it read changes.
21
+ *
22
+ * @remarks
23
+ * Arguments are evaluated when a function is called, before the library
24
+ * exists, so a function can't be given refs itself: its recipe defers it.
25
+ * The function must be pure, because it's called only when the token's value
26
+ * is resolved again. Its arguments are frozen, as token values are, so its
27
+ * parameters are typed readonly, as in `DesignToken.Values.Readonly.Color`:
28
+ * mutating one throws. A generic function's recipe takes the arguments of its
29
+ * constraint. Recipes are extended by spreading them into a new object, and a
30
+ * recipe's function is replaced in an extended library with {@link override}.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // darkenColor(color: DesignToken.Values.Readonly.Color, amount: number)
35
+ * export const Recipes = recipes({ darken: darkenColor, lighten: lightenColor });
36
+ * export const MyRecipes = { ...Recipes, ...recipes({ tint: tintColor }) };
37
+ *
38
+ * hover: { $type: DesignToken.Type.Color, $value: Recipes.darken(ref("colors.primary"), 0.2) }
39
+ * ```
40
+ *
41
+ * @public
42
+ */
43
+ export const recipes = (functions) => {
44
+ const made = {};
45
+ for (const name of Object.keys(functions)) {
46
+ made[name] = recipeOf(name, functions[name]);
47
+ }
48
+ // An object built by key has the keys' types: those of `Recipes<F>`.
49
+ return Object.freeze(made);
50
+ };
51
+ const recipeOf = (name, fn) => {
52
+ const recipe = Object.assign((...args) => Object.freeze({
53
+ [COMPUTED]: Object.freeze({
54
+ recipe,
55
+ args: Object.freeze(args),
56
+ }),
57
+ }), { [RECIPE]: Object.freeze({ name, fn }) });
58
+ return Object.freeze(recipe);
59
+ };
60
+ /**
61
+ * Replaces the function of a recipe, in a library made by
62
+ * `extend()`, for every token that computes
63
+ * its value with the recipe. `fn` takes the recipe's arguments and returns a
64
+ * value of its result's type.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const contrast = library.extend({}, { recipes: [override(Recipes.darken, darkenMore)] });
69
+ * ```
70
+ *
71
+ * @public
72
+ */
73
+ export const override = (recipe, fn) => Object.freeze({ recipe, fn });
74
+ /**
75
+ * Tests whether a value is a {@link (Library:namespace).Computed} value, a
76
+ * recipe's result, also one made by another copy of this package.
77
+ *
78
+ * @remarks
79
+ * The library computes a value anywhere in a token's value. A tool that reads
80
+ * a token's value as configured, with {@link configuredValueOf}, tells a
81
+ * computed value from other values with `isComputed()`, as it tells a ref
82
+ * with {@link isRef}.
83
+ *
84
+ * A computed value is a `Computed<unknown, never>` whatever its result and
85
+ * library, so a value typed as a computed value of a library is narrowed to
86
+ * it.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * isComputed(Recipes.darken(ref("colors.primary"), 0.2)); // true
91
+ * isComputed(hex("#0000ff")); // false
92
+ * ```
93
+ *
94
+ * @public
95
+ */
96
+ export const isComputed = (value) => {
97
+ return (typeof value === "object" &&
98
+ value !== null &&
99
+ Object.hasOwn(value, COMPUTED));
100
+ };
101
+ //# sourceMappingURL=recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../src/lib/recipe.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,GAAG,CAC7C,+BAA+B,CAClC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,SAAY,EACM,EAAE;IACpB,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,qEAAqE;IACrE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAuB,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CACb,IAAY,EACZ,EAAqB,EACD,EAAE;IACtB,MAAM,MAAM,GAAyB,MAAM,CAAC,MAAM,CAC9C,CACI,GAAG,IAAmC,EAChB,EAAE,CACxB,MAAM,CAAC,MAAM,CAAC;QACV,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,MAAM;YACN,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;SAC5B,CAAC;KACL,CAAC,EACN,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,CAC5C,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACpB,MAA4B,EAC5B,EAAqB,EACC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACtB,KAAc,EAC2B,EAAE;IAC3C,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CACjC,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ import type { Library } from "./library.js";
2
+ /**
3
+ * The key of a ref's path. A registered symbol, so that a ref made by another
4
+ * copy of this package is still a ref.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare const REF: unique symbol;
9
+ /**
10
+ * Makes a {@link (Library:namespace).Ref} to the token at a dotted path. Its
11
+ * type comes from where it's used: the library must have a token at the path
12
+ * whose value has the type expected there.
13
+ *
14
+ * @remarks
15
+ * Where the shape of the library is inferred, as in `Library.create({ ... })`
16
+ * without a type argument, or for a new token in `extend()`, the path can't
17
+ * be checked, so the shape is given as a type argument, or the ref is made
18
+ * with {@link refs}.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * link: { $type: DesignToken.Type.Color, $value: ref("colors.primary") }
23
+ * ```
24
+ *
25
+ * @public
26
+ */
27
+ export declare const ref: <V, T extends {} = {}>(path: NoInfer<Library.TokenPath<T, V>>) => Library.Ref<V, T>;
28
+ /**
29
+ * Makes a {@link (Library:namespace).Ref} to each token of a library of shape
30
+ * `T`, at the token's path: `refs<Theme>().colors.primary` is the same ref as
31
+ * `ref("colors.primary")`. It needs no library, so the refs are made once,
32
+ * before the library's config, and serve every library of the shape.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const theme = refs<Theme>();
37
+ * const library = Library.create<Theme>({
38
+ * colors: {
39
+ * $type: DesignToken.Type.Color,
40
+ * primary: { $value: hex("#0000ff") },
41
+ * link: { $value: theme.colors.primary },
42
+ * },
43
+ * });
44
+ * ```
45
+ *
46
+ * @public
47
+ */
48
+ export declare const refs: <T extends {}>() => Library.Refs<T>;
49
+ /**
50
+ * Tests whether a value is a {@link (Library:namespace).Ref}, made by
51
+ * {@link ref} or {@link refs}, also by another copy of this package.
52
+ *
53
+ * @remarks
54
+ * The library resolves a ref anywhere in a value. An add-on that keeps a
55
+ * ref, rather than its token's value, tells it from other values with
56
+ * `isRef()`, and reads its path with {@link pathOf}.
57
+ *
58
+ * A ref is a `Ref<unknown, never>` whatever its token and library, so a
59
+ * value typed as a ref of a library is narrowed to that ref.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * isRef(ref("colors.primary")); // true
64
+ * isRef(hex("#0000ff")); // false
65
+ * ```
66
+ *
67
+ * @public
68
+ */
69
+ export declare const isRef: (value: unknown) => value is Library.Ref<unknown, never>;
70
+ /**
71
+ * The path of a {@link (Library:namespace).Ref}'s token, the name of each
72
+ * group and of the token: `["colors", "primary"]` for
73
+ * `ref("colors.primary")`.
74
+ *
75
+ * @remarks
76
+ * The library resolves a ref anywhere in a value to its token's value. An
77
+ * add-on that needs the token itself, such as one that writes a CSS custom
78
+ * property for it, keeps the path instead, and finds the token in the
79
+ * library when it needs the value.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // An operand of an expression keeps its token's path, so that it's
84
+ * // written as a `var()` and isn't resolved to the token's value.
85
+ * const operand = <T>(arg: number | Library.Ref<number, T>) =>
86
+ * isRef(arg) ? { token: pathOf(arg).join(".") } : arg;
87
+ * ```
88
+ *
89
+ * @public
90
+ */
91
+ export declare const pathOf: (ref: Library.Ref<unknown, never>) => readonly string[];
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The key of a ref's path. A registered symbol, so that a ref made by another
3
+ * copy of this package is still a ref.
4
+ *
5
+ * @internal
6
+ */
7
+ export const REF = Symbol.for("design-token-library.ref");
8
+ /**
9
+ * Makes a {@link (Library:namespace).Ref} to the token at a dotted path. Its
10
+ * type comes from where it's used: the library must have a token at the path
11
+ * whose value has the type expected there.
12
+ *
13
+ * @remarks
14
+ * Where the shape of the library is inferred, as in `Library.create({ ... })`
15
+ * without a type argument, or for a new token in `extend()`, the path can't
16
+ * be checked, so the shape is given as a type argument, or the ref is made
17
+ * with {@link refs}.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * link: { $type: DesignToken.Type.Color, $value: ref("colors.primary") }
22
+ * ```
23
+ *
24
+ * @public
25
+ */
26
+ export const ref = (path) => Object.freeze({ [REF]: Object.freeze(path.split(".")) });
27
+ /**
28
+ * Makes a {@link (Library:namespace).Ref} to each token of a library of shape
29
+ * `T`, at the token's path: `refs<Theme>().colors.primary` is the same ref as
30
+ * `ref("colors.primary")`. It needs no library, so the refs are made once,
31
+ * before the library's config, and serve every library of the shape.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const theme = refs<Theme>();
36
+ * const library = Library.create<Theme>({
37
+ * colors: {
38
+ * $type: DesignToken.Type.Color,
39
+ * primary: { $value: hex("#0000ff") },
40
+ * link: { $value: theme.colors.primary },
41
+ * },
42
+ * });
43
+ * ```
44
+ *
45
+ * @public
46
+ */
47
+ export const refs = () =>
48
+ // A proxy makes the ref for any path, which a type can't describe: the
49
+ // type of the path is `Refs<T>`.
50
+ refAt([]);
51
+ const refAt = (path) => {
52
+ const ref = Object.freeze({ [REF]: Object.freeze(path) });
53
+ // So that a path is always the same ref.
54
+ const children = new Map();
55
+ return new Proxy(ref, {
56
+ get(target, key) {
57
+ if (typeof key !== "string") {
58
+ return Reflect.get(target, key);
59
+ }
60
+ let child = children.get(key);
61
+ if (child === undefined) {
62
+ child = refAt([...path, key]);
63
+ children.set(key, child);
64
+ }
65
+ return child;
66
+ },
67
+ });
68
+ };
69
+ /**
70
+ * Tests whether a value is a {@link (Library:namespace).Ref}, made by
71
+ * {@link ref} or {@link refs}, also by another copy of this package.
72
+ *
73
+ * @remarks
74
+ * The library resolves a ref anywhere in a value. An add-on that keeps a
75
+ * ref, rather than its token's value, tells it from other values with
76
+ * `isRef()`, and reads its path with {@link pathOf}.
77
+ *
78
+ * A ref is a `Ref<unknown, never>` whatever its token and library, so a
79
+ * value typed as a ref of a library is narrowed to that ref.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * isRef(ref("colors.primary")); // true
84
+ * isRef(hex("#0000ff")); // false
85
+ * ```
86
+ *
87
+ * @public
88
+ */
89
+ export const isRef = (value) => {
90
+ return (typeof value === "object" && value !== null && Object.hasOwn(value, REF));
91
+ };
92
+ /**
93
+ * The path of a {@link (Library:namespace).Ref}'s token, the name of each
94
+ * group and of the token: `["colors", "primary"]` for
95
+ * `ref("colors.primary")`.
96
+ *
97
+ * @remarks
98
+ * The library resolves a ref anywhere in a value to its token's value. An
99
+ * add-on that needs the token itself, such as one that writes a CSS custom
100
+ * property for it, keeps the path instead, and finds the token in the
101
+ * library when it needs the value.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * // An operand of an expression keeps its token's path, so that it's
106
+ * // written as a `var()` and isn't resolved to the token's value.
107
+ * const operand = <T>(arg: number | Library.Ref<number, T>) =>
108
+ * isRef(arg) ? { token: pathOf(arg).join(".") } : arg;
109
+ * ```
110
+ *
111
+ * @public
112
+ */
113
+ export const pathOf = (ref) => ref[REF];
114
+ //# sourceMappingURL=ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../src/lib/ref.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAkB,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEzE;;;;;;;;;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G,CAAC,KAAc,EAAwC,EAAE;IAC1E,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAC3E,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAgC,EAAqB,EAAE,CAC1E,GAAG,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../node_modules/typescript/lib/lib.scripthost.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/typescript/lib/lib.es2022.full.d.ts","../../src/lib/design-token.ts","../../src/lib/recipe.ts","../../src/lib/ref.ts","../../src/lib/notifier.ts","../../src/lib/queue.ts","../../src/lib/utilities.ts","../../src/lib/watcher.ts","../../src/lib/library.ts","../../src/lib/css-reflector.ts","../../src/lib/values.ts","../../src/lib/index.ts","../../node_modules/@types/argparse/index.d.ts","../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../node_modules/@types/sinonjs__fake-timers/index.d.ts","../../node_modules/@types/sinon/index.d.ts"],"fileIdsList":[[77],[64,69,71],[64,65,66,71,72,73],[64,65,66,67,68,69,70],[67],[71],[64],[69]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"3cbad9a1ba4453443026ed38e4b8be018abb26565fa7c944376463ad9df07c41","impliedFormat":1},{"version":"6a55fb240497dd1953c4f7d8c2982b3ec1cc070ef816839be9ecd1b5c3af4900","signature":"fbcc432cd6b06f91426186af8970e2fb8bf9c251df49aa1c6e1c498828a8b387","impliedFormat":99},{"version":"f903b1d4b4fba5c5eb6ab5ce79c72322e7ec8cfd3c76ccbbd20dc177af8eda14","signature":"779052cd91eb7496b020d7182a83512e589cdddb486e812e2960a4e8aaec1746","impliedFormat":99},{"version":"0305b3c70398174dbb95ef33f0fc87dc5644503f4b3dc8f0bd78aa72a0cfe6e9","signature":"40e09af49f1546b607ffdf359f9227371f693f0d4b8b5e773156f36ab2a96d3b","impliedFormat":99},{"version":"30e8546a341a22a480956b0846966cc296104b49b173d7da95909b5d42bf8c16","signature":"c498ccd6bf7772889f965bbf0e34a87e6893b56beb7e546046f9ef1444398cc6","impliedFormat":99},{"version":"af19305f6c0e51db0d60b74695cbf3cdd624562ea3ecd58219223a376ae918d5","signature":"b5138c6e1eb6fbc1ee5951a5d2a30038eb29b4dc4233f275fb5946ab319947a6","impliedFormat":99},{"version":"664957d8967f2a2641e83019d4081de1eeb12fce3748f13c632a80bf99fe76cd","signature":"32387013b3f9b412bdf357ec361a91befc8901e022c535140b45bbd7c6a93d57","impliedFormat":99},{"version":"01f6443682fd37972d9ef91610fadb8b45bb4b9aed272e660cb5bc13553492cb","signature":"46afe04e8e72c08be83860c259295714fd8b48d5b5a4e0885ea6f6fd9e790ecc","impliedFormat":99},{"version":"900bcafb8331ba1c5728076f10faa731d9cc54330039d33d57bbe554e9dbb315","signature":"836a58a8a26e698f07a8d4d908c05fa9786e57b07cc390aad1624c4d59d3fe92","impliedFormat":99},{"version":"6a4c3e7b7540aeeeb72682b8b50b1ed18e747ea828994a37795b05e2d6dd88ec","signature":"2b5f1a023cb9dfeca2c555da1a13f50f88c8ef035a0ec2feeb78e731ae075127","impliedFormat":99},{"version":"1f6da71e17deea8081131e80e3d960c7c2efcefa668601c52c0a411693f0f378","signature":"0282e2dae20445d5171858e877d6ff751f11b2db385aa0a5ce750853bc1035ec","impliedFormat":99},{"version":"d5b6ea4a9e79dcc08ceae4cc81f32e0b51708493a1d2da29d773fd86ac298663","signature":"9c17f95c3d1ba2739f3fe18d459bcf9e77665b55287b39156b647ed5a05afc90","impliedFormat":99},{"version":"dc3b172ee27054dbcedcf5007b78c256021db936f6313a9ce9a3ecbb503fd646","impliedFormat":1},{"version":"035a5df183489c2e22f3cf59fc1ed2b043d27f357eecc0eb8d8e840059d44245","impliedFormat":1},{"version":"7d2a0ba1297be385a89b5515b88cd31b4a1eeef5236f710166dc1b36b1741e1b","impliedFormat":1},{"version":"c0e3c1f7e2c4aaefbfb2e5d20ccf49a0d51e1d102751dd2de4c7f197480a2b48","impliedFormat":1}],"root":[[64,74]],"options":{"composite":true,"esModuleInterop":true,"experimentalDecorators":true,"module":100,"outDir":"..","rootDir":"../../src","sourceMap":true,"strict":true,"target":9},"referencedMap":[[78,1],[72,2],[74,3],[71,4],[68,5],[65,6],[66,6],[73,7],[70,8]],"latestChangedDtsFile":"./index.d.ts","version":"5.9.3"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.59.4"
9
+ }
10
+ ]
11
+ }
@@ -1,5 +1,11 @@
1
- import { DesignToken } from "./design-token.js";
2
1
  export declare const empty: unique symbol;
3
- export type DeepPartial<T> = T extends object ? {
4
- [P in keyof T]?: T[P] extends DesignToken.Any ? T[P] : DeepPartial<T[P]>;
5
- } : T;
2
+ /**
3
+ * Tests whether a value is a token: it has a `$value`. This is the same rule for
4
+ * a token in config and for a token in a library's token tree. It cannot mistake
5
+ * a value for a token because a name cannot begin with `$` (except `$root`).
6
+ *
7
+ * @internal
8
+ */
9
+ export declare const isToken: <T>(value: T) => value is T & {
10
+ $value: any;
11
+ };
@@ -1,2 +1,12 @@
1
1
  export const empty = Symbol();
2
+ /**
3
+ * Tests whether a value is a token: it has a `$value`. This is the same rule for
4
+ * a token in config and for a token in a library's token tree. It cannot mistake
5
+ * a value for a token because a name cannot begin with `$` (except `$root`).
6
+ *
7
+ * @internal
8
+ */
9
+ export const isToken = (value) => {
10
+ return typeof value === "object" && value !== null && "$value" in value;
11
+ };
2
12
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/lib/utilities.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/lib/utilities.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAAQ,EAAgC,EAAE;IACjE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,CAAC;AAC5E,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { DesignToken } from "./design-token.js";
2
+ /**
3
+ * Builds a 2025.10 sRGB color from a hex color string: `#RGB`, `#RRGGBB` or
4
+ * `#RRGGBBAA`.
5
+ *
6
+ * @throws A `TypeError` when the string is not a hex color.
7
+ *
8
+ * @public
9
+ */
10
+ export declare const hex: (css: string) => DesignToken.Values.Color;
11
+ /**
12
+ * Builds a dimension in pixels.
13
+ *
14
+ * @public
15
+ */
16
+ export declare const px: (value: number) => DesignToken.Values.Dimension;
17
+ /**
18
+ * Builds a dimension in rems.
19
+ *
20
+ * @public
21
+ */
22
+ export declare const rem: (value: number) => DesignToken.Values.Dimension;
23
+ /**
24
+ * Builds a duration in milliseconds.
25
+ *
26
+ * @public
27
+ */
28
+ export declare const ms: (value: number) => DesignToken.Values.Duration;
29
+ /**
30
+ * Builds a duration in seconds.
31
+ *
32
+ * @public
33
+ */
34
+ export declare const s: (value: number) => DesignToken.Values.Duration;
@@ -0,0 +1,64 @@
1
+ const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
2
+ /**
3
+ * Builds a 2025.10 sRGB color from a hex color string: `#RGB`, `#RRGGBB` or
4
+ * `#RRGGBBAA`.
5
+ *
6
+ * @throws A `TypeError` when the string is not a hex color.
7
+ *
8
+ * @public
9
+ */
10
+ export const hex = (css) => {
11
+ if (!HEX.test(css)) {
12
+ throw new TypeError(`Invalid hex color: ${css}`);
13
+ }
14
+ let digits = css.slice(1);
15
+ if (digits.length === 3) {
16
+ digits = [...digits].map((digit) => digit + digit).join("");
17
+ }
18
+ const byte = (index) => parseInt(digits.slice(index, index + 2), 16);
19
+ const color = {
20
+ colorSpace: "srgb",
21
+ components: [byte(0) / 255, byte(2) / 255, byte(4) / 255],
22
+ };
23
+ if (digits.length === 8) {
24
+ color.alpha = byte(6) / 255;
25
+ }
26
+ return color;
27
+ };
28
+ /**
29
+ * Builds a dimension in pixels.
30
+ *
31
+ * @public
32
+ */
33
+ export const px = (value) => ({
34
+ value,
35
+ unit: "px",
36
+ });
37
+ /**
38
+ * Builds a dimension in rems.
39
+ *
40
+ * @public
41
+ */
42
+ export const rem = (value) => ({
43
+ value,
44
+ unit: "rem",
45
+ });
46
+ /**
47
+ * Builds a duration in milliseconds.
48
+ *
49
+ * @public
50
+ */
51
+ export const ms = (value) => ({
52
+ value,
53
+ unit: "ms",
54
+ });
55
+ /**
56
+ * Builds a duration in seconds.
57
+ *
58
+ * @public
59
+ */
60
+ export const s = (value) => ({
61
+ value,
62
+ unit: "s",
63
+ });
64
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/lib/values.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,6CAA6C,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAW,EAA4B,EAAE;IACzD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,SAAS,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAC3B,QAAQ,CAAC,MAA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