design-token-library 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -5,7 +5,66 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
8
+ ## [0.2.0] - 2026-10-28
9
+
10
+ ### Added
11
+
12
+ - `isRef(value)` tells whether a value is a ref, also one made by another copy of the package, and `pathOf(ref)` is the path of its token, as a readonly array of names (#93). An add-on that keeps a ref, instead of letting the library resolve it to its token's value, needs them, as an expression that writes a token as a `var()` does. `isRef()` narrows a value to a `Library.Ref<unknown, never>`, which a ref of any library is.
13
+ - `ref("colors.primary")` and `refs<T>()` make a ref to a token, by its dotted path or by a ref for each token of a shape: `$value: ref("colors.primary")` or `$value: $.colors.primary`. They make the same ref, which is data, the path of its token, and has the token's value type. `ref()` takes its types from where it's used, so a path that isn't a token, or a token of the wrong type, is a compile error. Adds the `Library.Ref`, `Library.Refs`, `Library.TokenValues`, `Library.TokenValue`, `Library.TokenPath` and `Library.DeepValue` types.
14
+ - A custom value can be any type, including a class instance, an object with methods or function properties, or a function, and the library never calls its functions: `DesignToken.Custom<"palette", Palette>`. `DesignToken.HasFunction`, which rejected a value type with a function in it, is removed.
15
+ - `recipes({ ... })` makes a recipe of each function of an object, named by its key. A recipe takes its function's arguments as values, refs, computed values, or values with them in them, and returns a computed value, as in `$value: Recipes.darken(ref("colors.primary"), 0.2)`. A computed value is data: the recipe and its arguments. The function is called when the token is read, and again when a token it read changes. It gets its arguments as tokens get their values, so a ref's value and a copy of plain data are frozen, and its parameters are typed readonly, as in `DesignToken.Values.Readonly.Color`. It may return a readonly value, which is copied and frozen like any token value. A recipe whose function takes an object builds a class value from named fields. A set of recipes is extended by spreading it. Adds the `Library.Computed`, `Library.Recipe`, `Library.RecipeArguments` and `Library.Recipes` types.
16
+ - `extend(config, { recipes: [override(recipe, fn)] })` replaces a recipe's function in the extended library, for every token that uses it, including the ones it doesn't restate. `override()` checks that `fn` takes the recipe's arguments and returns its result's type. Adds the `Library.ExtendOptions` and `Library.RecipeOverride` types.
17
+ - A custom type's converter in `toCSS` can be `false`, which leaves tokens of that type out of the CSS (#58). `toProperties` accepts the same `converters` option and leaves out those tokens. Every custom type still needs an entry, so a forgotten converter is still an error. Adds the `CSSConverterEntries` and `ToPropertiesOptions` types.
18
+ - `convert(type, value)` converts a value of a standard type to CSS, the way `toCSS` does for a token of the type, for a converter of a custom type that has values of standard types (#65). `DesignToken.ValueByType`, the value of each standard type keyed by its name, like `color`, is public.
19
+ - `toCSS` takes a converter for a standard type in `converters`, which is used in place of the one of the library (#65). A library without custom types takes converters for the standard types, and no others.
20
+ - `$root` as a token in its group, and not at the top level of a library (its CSS custom property is named for the group), `$deprecated` on tokens, and group metadata (`$description`, `$extensions`, `$deprecated`) that survives `extend()`. A circular reference throws a `CircularReferenceError`, whose `chain` and message list the tokens in the cycle (`a → b → a`), instead of overflowing the stack.
21
+ - Custom token types via `DesignToken.Custom<Name, Value>`, with static values, aliases, deep aliases, group type inheritance, `set()` and `extend()` support. Reserved DTCG type names are rejected at compile time.
22
+ - `toCSS(library, options)` accepts `options.converters`, a converter for each custom type that receives the value and the token. It's required for every custom type in the library. At runtime `toCSS` throws for a custom type without a converter.
23
+ - `Library.TokensOf`, `Library.TokenRecord`, `Library.GroupType`, `CSSOptions`, `CSSConverter`, `CSSConverters` and `CustomTokensOf` types.
24
+ - `Token.toString()` returns a JSON representation of the token's `name`, `$type`, resolved `$value`, `$description`, `$extensions` and `$deprecated`. It throws a `CircularReferenceError` for a token in a cycle. It was declared but stringified as `[object Object]`.
25
+
26
+ ### Changed
27
+
28
+ - **Breaking:** a token's value is deeply readonly (#24). It's frozen, including nested objects, arrays and their items, and `Token.$value` is typed `DesignToken.ReadonlyValueByToken`, so subscriber records and converter arguments are readonly too. `convert()` and the converters for the standard types take the readonly values, and `set()` takes them as well, so `set(other.$value)` compiles. The config passed to `create()` isn't frozen, and a class instance or function in a value isn't copied, so it isn't frozen. Adds the `DesignToken.Values.Readonly` types, `DesignToken.ReadonlyValueByType` and `DesignToken.DeepReadonly`.
29
+ - **Breaking:** an alias is a ref, `$value: ref("colors.primary")`, instead of a function given the library's tokens, and a function in a value is never called. `Library.Context`, `Library.ValueAlias`, `Library.Alias`, `Library.ValueSource` and `Library.DeepAlias` are removed, and `Token.set()` takes the same values as a config, including deep refs.
30
+ - A token's value is a copy of plain data, made from its own properties: symbol-keyed and non-enumerable properties are kept, an object that is in the value twice, or in itself, has one copy, and a getter is read once into a data property. Plain data is an array that isn't a subclass of `Array`, or an object whose prototype chain has at most one link, including an object literal from another realm. Anything else, including a function, is returned as it is.
31
+ - **Breaking:** token values use the [DTCG 2025.10](https://www.designtokens.org/tr/2025.10/format/) shapes. A color is `{ colorSpace, components, alpha?, hex? }`, a dimension is `{ value, unit: "px" | "rem" }` and a duration is `{ value, unit: "ms" | "s" }`. A shadow may be an array of layers and may be `inset`, the font weight keyword `"smi-bold"` is corrected to `"semi-bold"`, and a list inside a value (such as a stroke style's dash array) can contain aliases.
32
+ - `toCSS` and `toProperties` convert the new shapes: sRGB colors become hex and other color spaces the CSS color function, font weight keywords become numbers, `cubic-bezier()` and transition shorthand order are corrected, and a standard type with no converter is written as JSON instead of `[object Object]`.
33
+ - **Breaking:** tokens and groups use the DTCG property names: `$value`, `$type`, `$description`, `$extensions` and `$deprecated` on tokens, and `$type`, `$description`, `$extensions` and `$deprecated` on groups, both in a config and on `library.tokens`. `name`, `set()` and `toString()` are unchanged. A token is told apart from a group by having a `$value`.
34
+ - Group type inheritance is checked at compile time: a token may omit `type` in a config only when its nearest ancestor group declares a single, required, literal `type` that matches. Groups declared with `type: DesignToken.Type`, a union, or an optional `type` no longer let their tokens omit `type`.
35
+ - `type` is required on standard token types (e.g. `DesignToken.Color`). It may still be omitted in a `Library.Config` when inherited.
36
+ - Aliases are typed by value: an alias may return any value, or any token, whose value matches. Replaces the internal `TokenByValue`, `TokenByType` and `ValueByType` types.
37
+ - `Library.Subscriber` records are a union of the library's tokens, discriminated by `type`, instead of `Token<DesignToken.Any>`.
38
+ - Token values that are plain objects with a `value` key are no longer unwrapped as tokens; only library tokens are.
39
+ - Array values resolve faster: they are copied with an indexed loop instead of `for...in`. Holes in a sparse array value now resolve to `undefined` elements.
40
+ - Recomputing a token keeps its subscriptions to the dependencies it reads again, instead of unsubscribing from all of them and subscribing again, which makes updates faster.
41
+ - `Library.extend()` config is typed with the new `Library.ExtendConfig` and its type parameter defaults to `{}` instead of `any`.
42
+
43
+ ### Fixed
44
+
45
+ - A token's value, which is readonly, can be the `$value` of a token in `create()` or `extend()`, and the argument of a recipe, as it can be given to `set()` (#92). A value whose objects or arrays are readonly is accepted too, also with refs in it. `Library.DeepValue` makes the properties and elements of a value readonly.
46
+ - `set()` on a token of a library that extends an extended library changes that token, and not the token of the library it extends (#91).
47
+ - `Token.set()` with the value the token already has, by `Object.is`, doesn't notify subscribers or resolve the token again (#22). On an extended token it still detaches the token from its source.
48
+ - `extend()` throws, naming the token, when an override's `$type` differs from the source token's type, including a type the source token inherits from its group (#16). Restating the same type is allowed.
49
+ - `extend()` accepts a group's `$type` when it's the group's own type, so a shared group config that sets it can be given to `extend()`, and throws, naming the group, when it's different (#95). A different group type was ignored, and restating the same one was a compile error.
50
+ - A value that isn't plain data, such as a class instance, a `Date`, a `Map` or a `Set`, is returned as it is. It was copied to a plain object, which lost its prototype and internal state, and a function property of it was called as an alias (#55). A cyclic value no longer overflows the stack.
51
+ - `extend()` has an overload for a config that only has values of tokens, which has no tokens to infer (#62). A new token with a value of the wrong type is reported for the call, as no overload matching, instead of for the token.
52
+ - A custom token type with a value type that contains itself, like a tree, compiles (#61).
53
+ - `DeepAlias` accepts aliases inside Gradient stops (#28).
54
+ - Resolving a token of an extended library no longer disconnects its source token from its dependencies, which left the source token reported as changed when a dependency it no longer used changed.
55
+ - Number aliases in a CubicBezier accept Number tokens (#29).
56
+ - `Library.extend()` no longer throws when the source library contains groups.
57
+ - `Library.extend()` supports adding new groups, and new tokens inherit the type of their ancestor group.
58
+ - `Library.extend()` accepts alias values when overriding existing tokens, and resolves them against the extending library.
59
+ - `Library.extend()` throws when a new token has no type and no ancestor group type, matching `Library.create()`.
60
+ - `Library.extend()` shallow-merges `$extensions` overrides into the source token's, with override keys winning. An extended token's `$extensions` is always a new object, so mutating it no longer changes the source token.
61
+ - Library groups expose their declared `type` (non-enumerable), matching the `TokenLibrary` type.
62
+ - `Library.create()` and `extend()` configs accept `null` and `undefined` entries, which are ignored at runtime like other non-token entries.
63
+ - The root of `library.tokens` (for created and extended libraries) and the object returned by `toProperties` are frozen, like nested groups. Adding or deleting a top-level key throws in strict mode.
64
+ - A token's `$extensions` is a shallow copy of the config's at `Library.create()`, so adding, removing or replacing a top-level key in the config no longer changes the token. Nested values are shared with the config.
65
+ - Array entries in `Library.create()` and `extend()` configs are ignored like other non-token entries, instead of creating an empty group (which `toProperties` also emitted).
66
+ - A library subscriber that throws no longer stops later subscribers from being notified. Every subscriber is called, then each error is re-thrown as the same instance in its own microtask, so it surfaces as an uncaught error, like a DOM event listener's.
67
+ - Tokens in a config whose shape is inferred (no type argument to `Library.create()` or `extend()`) are checked against their `$type`, and their `$value` and `set()` use that type's value instead of the widened literal. Their `$type` keeps its literal type, including a custom type's name. A token with a child (a key without a `$` prefix), which `create()` throws for, is a type error. Custom types and tokens that inherit a group's type are not checked. `Library.ConfigValueCheck` and `Library.ConfigTypeHint` are added. Requires TypeScript 5.4 or later (`NoInfer`).
9
68
 
10
69
  ## [0.1.0] - 2023-05-16
11
70
 
package/README.md CHANGED
@@ -1,4 +1,40 @@
1
- ![CI](https://github.com/nicholasrice/design-token-library/actions/workflows/ci.yml/badge.svg)
2
- ![Docs](https://github.com/nicholasrice/design-token-library/actions/workflows/deploy.yml/badge.svg)
1
+ # design-token-library
3
2
 
4
- [API Documentation](https://nicholasrice.github.io/design-token-library/)
3
+ [![CI](https://github.com/nicholasrice/design-token-library/actions/workflows/ci.yml/badge.svg)](https://github.com/nicholasrice/design-token-library/actions/workflows/ci.yml)
4
+ [![Docs](https://github.com/nicholasrice/design-token-library/actions/workflows/deploy.yml/badge.svg)](https://github.com/nicholasrice/design-token-library/actions/workflows/deploy.yml)
5
+
6
+ A TypeScript library for managing [design tokens](https://www.designtokens.org/). The API follows the [Design Token Community Group (DTCG)](https://www.designtokens.org/) format and focuses on type safety, lazy evaluation, and runtime-agnostic behavior.
7
+
8
+ ## Features
9
+
10
+ - Token aliasing and refs with compile-time path checking
11
+ - Computed values (recipes) and library extension
12
+ - Change subscription and CSS / custom-property export
13
+ - [DTCG 2025.10](https://www.designtokens.org/tr/2025.10/format/) value shapes
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install design-token-library
19
+ ```
20
+
21
+ Requires **Node.js 22+** (see `engines` in `package.json`).
22
+
23
+ ## Documentation
24
+
25
+ - [Getting started & API reference](https://nicholasrice.github.io/design-token-library/) (GitHub Pages)
26
+ - [Changelog](./CHANGELOG.md)
27
+
28
+ ## Development
29
+
30
+ ```bash
31
+ npm ci
32
+ npm run build
33
+ npm test
34
+ ```
35
+
36
+ Contributing guidelines, changelog conventions, and the release process are documented in [CONTRIBUTING.md](./CONTRIBUTING.md).
37
+
38
+ ## License
39
+
40
+ [MIT](./LICENSE)
@@ -1,9 +1,117 @@
1
1
  import { DesignToken } from "./design-token.js";
2
2
  import { Library } from "./library.js";
3
3
  /**
4
+ * Converts a token value to a CSS value.
5
+ *
4
6
  * @public
5
7
  */
6
- export declare function toCSS(library: Library.Library<any, any>): string;
8
+ export type CSSConverter<V, T extends DesignToken.Shape = DesignToken.Shape> = (value: V, token: Library.Token<T, {}>) => string;
9
+ /**
10
+ * A union of the custom tokens in a library of shape `T`: tokens whose
11
+ * type is not defined by {@link https://www.designtokens.org/tr/2025.10/format/#types}.
12
+ *
13
+ * @public
14
+ */
15
+ export type CustomTokensOf<T> = Exclude<Library.TokensOf<T>, {
16
+ $type?: DesignToken.Type;
17
+ }>;
18
+ /**
19
+ * A {@link CSSConverter} for each custom token type in a library of shape `T`,
20
+ * keyed by type name.
21
+ *
22
+ * @public
23
+ */
24
+ export type CSSConverters<T> = ConvertersOf<CustomTokensOf<T>>;
25
+ type ConvertersOf<C> = {
26
+ [N in C extends {
27
+ $type: infer N extends string;
28
+ } ? N : never]: C extends {
29
+ $type: N;
30
+ } ? C extends DesignToken.Shape ? CSSConverter<DesignToken.ReadonlyValueByToken<C>, C> : never : never;
31
+ };
32
+ /**
33
+ * A converter for any of the standard types, which is used in place of the one
34
+ * of the library.
35
+ */
36
+ type StandardConverters = {
37
+ [N in keyof DesignToken.ReadonlyValueByType]?: CSSConverter<DesignToken.ReadonlyValueByType[N], Extract<DesignToken.Standard, {
38
+ $type: N;
39
+ }>>;
40
+ };
41
+ /**
42
+ * What a library of shape `T` accepts for each custom token type: a
43
+ * {@link CSSConverter}, or `false` for a type that is not serialized.
44
+ *
45
+ * @public
46
+ */
47
+ export type CSSConverterEntries<T> = {
48
+ [N in keyof CSSConverters<T>]: CSSConverters<T>[N] | false;
49
+ };
50
+ /**
51
+ * Options that control how custom properties are named.
52
+ *
53
+ * @public
54
+ */
55
+ export interface CSSPropertiesOptions {
56
+ /**
57
+ * Derives a token's custom property name, without the leading `--`.
58
+ *
59
+ * @remarks
60
+ * Defaults to the token's name with `.` replaced by `-`. Pass the same
61
+ * function to {@link toCSS} and {@link toProperties} to keep the names
62
+ * aligned.
63
+ */
64
+ name?(token: Library.Token<any, any>): string;
65
+ }
66
+ /**
67
+ * Options accepted by {@link toProperties}.
68
+ *
69
+ * @public
70
+ */
71
+ export interface ToPropertiesOptions extends CSSPropertiesOptions {
72
+ /**
73
+ * The converters given to {@link toCSS}. A token whose custom type is `false`
74
+ * isn't written by `toCSS`, so it has no custom property and is left out.
75
+ */
76
+ converters?: {
77
+ readonly [type: string]: ((value: any, token: any) => string) | false;
78
+ };
79
+ }
80
+ /**
81
+ * Options accepted by {@link toCSS}.
82
+ *
83
+ * @remarks
84
+ * `converters` is required when the library contains custom token types,
85
+ * and must have an entry for each of them: a converter, or `false` for a type
86
+ * whose tokens are not written to CSS.
87
+ * It can have a converter for a standard type as well, which is used in place
88
+ * of the one of the library, see {@link convert} for what it does.
89
+ *
90
+ * @public
91
+ */
92
+ export type CSSOptions<T> = CSSPropertiesOptions & ([CustomTokensOf<T>] extends [never] ? {
93
+ converters?: StandardConverters;
94
+ } : {
95
+ converters: CSSConverterEntries<T> & StandardConverters;
96
+ });
97
+ /**
98
+ * The trailing arguments of {@link toCSS}: {@link CSSOptions} are
99
+ * required when the library contains custom token types.
100
+ *
101
+ * @public
102
+ */
103
+ export type ToCSSArgs<T> = [CustomTokensOf<T>] extends [never] ? [options?: CSSOptions<T>] : [options: CSSOptions<T>];
104
+ /**
105
+ * Convert a library to CSS custom property declarations.
106
+ *
107
+ * @remarks
108
+ * Libraries with custom token types must provide a converter for each
109
+ * custom type, or `false` to leave tokens of that type out of the CSS.
110
+ * A converter for a standard type is used in place of the one of the library.
111
+ *
112
+ * @public
113
+ */
114
+ export declare function toCSS<T extends {}, R extends {}>(library: Library.Library<T, R>, ...[options]: ToCSSArgs<NoInfer<T>>): string;
7
115
  interface CSSPropertyValues {
8
116
  readonly var: `var(--${string})`;
9
117
  readonly property: `--${string}`;
@@ -14,11 +122,43 @@ interface CSSPropertyValues {
14
122
  * @public
15
123
  */
16
124
  export type CSSPropertiesLibrary<T extends {}> = {
17
- [K in keyof Readonly<T>]: T[K] extends DesignToken.Any ? CSSPropertyValues : K extends "type" ? DesignToken.Type : T[K] extends {} ? CSSPropertiesLibrary<T[K]> : never;
125
+ [K in keyof Readonly<T>]: T[K] extends DesignToken.Shape ? CSSPropertyValues : K extends keyof DesignToken.Group ? T[K] : T[K] extends {} ? CSSPropertiesLibrary<T[K]> : never;
18
126
  };
19
127
  /**
20
128
  * Construct an {@link CSSPropertiesLibrary} from a {@link Library.Library<any>}.
129
+ *
130
+ * @remarks
131
+ * Pass the same `converters` given to {@link toCSS} to leave out the tokens it does
132
+ * not write (a custom type whose converter is `false`). They are still in the
133
+ * {@link CSSPropertiesLibrary} type, but missing at runtime.
134
+ *
135
+ * @public
136
+ */
137
+ export declare function toProperties<T extends Library.Library<any>>(library: T, options?: ToPropertiesOptions): CSSPropertiesLibrary<T["tokens"]>;
138
+ /**
139
+ * Converts a value of a standard type to CSS, the way {@link toCSS} does for a
140
+ * token of the type, without a converter for the type in `converters`.
141
+ *
142
+ * @remarks
143
+ * A converter for a custom type that has values of standard types uses it for
144
+ * each of them, and a converter for a standard type can use it for what it
145
+ * keeps.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * toCSS(library, {
150
+ * converters: {
151
+ * elevation: (value) =>
152
+ * `${convert("dimension", value.offset)} ${convert("color", value.color)}`,
153
+ * },
154
+ * });
155
+ * ```
156
+ *
157
+ * @param type - The type, like `"color"`
158
+ * @param value - The value of a token of the type
159
+ * @returns The value as it is written to CSS
160
+ *
21
161
  * @public
22
162
  */
23
- export declare function toProperties<T extends Library.Library<any>>(library: T): CSSPropertiesLibrary<T["tokens"]>;
163
+ export declare function convert<Name extends keyof DesignToken.ReadonlyValueByType>(type: Name, value: DesignToken.ReadonlyValueByType[Name]): string;
24
164
  export {};
@@ -1,21 +1,47 @@
1
1
  import { DesignToken } from "./design-token.js";
2
+ import { isToken } from "./utilities.js";
2
3
  /**
4
+ * Convert a library to CSS custom property declarations.
5
+ *
6
+ * @remarks
7
+ * Libraries with custom token types must provide a converter for each
8
+ * custom type, or `false` to leave tokens of that type out of the CSS.
9
+ * A converter for a standard type is used in place of the one of the library.
10
+ *
3
11
  * @public
4
12
  */
5
- export function toCSS(library) {
6
- return recurseToCss(library.tokens);
13
+ export function toCSS(library, ...[options]) {
14
+ // Converters are checked by `ToCSSArgs`; at runtime they're keyed by type.
15
+ const converters = options?.converters ?? {};
16
+ return recurseToCss(library.tokens, converters, options?.name ?? defaultName);
7
17
  }
18
+ /**
19
+ * `$` cannot begin a CSS identifier, so a group's `$root` token is named for
20
+ * the group: `color.$root` is `--color`.
21
+ */
22
+ const defaultName = (token) => token.name.replace(/\.\$root$/, "").replaceAll(".", "-");
8
23
  /**
9
24
  * Construct an {@link CSSPropertiesLibrary} from a {@link Library.Library<any>}.
25
+ *
26
+ * @remarks
27
+ * Pass the same `converters` given to {@link toCSS} to leave out the tokens it does
28
+ * not write (a custom type whose converter is `false`). They are still in the
29
+ * {@link CSSPropertiesLibrary} type, but missing at runtime.
30
+ *
10
31
  * @public
11
32
  */
12
- export function toProperties(library) {
33
+ export function toProperties(library, options = {}) {
34
+ const getName = options.name ?? defaultName;
35
+ const converters = options.converters ?? {};
13
36
  const recurse = (section, properties) => {
14
37
  for (const key in section) {
15
38
  const sectionValue = section[key];
16
39
  if (isToken(sectionValue)) {
17
- // TODO add a strategy for name conversion
18
- const property = `--${sectionValue.name.replaceAll(".", "-")}`;
40
+ // `toCSS` doesn't write a token whose type is `false`.
41
+ if (converters[sectionValue.$type] === false) {
42
+ continue;
43
+ }
44
+ const property = `--${getName(sectionValue)}`;
19
45
  const propertyValue = Object.freeze({
20
46
  var: `var(${property})`,
21
47
  property,
@@ -37,37 +63,85 @@ export function toProperties(library) {
37
63
  };
38
64
  const properties = {};
39
65
  recurse(library.tokens, properties);
40
- return properties;
66
+ return Object.freeze(properties);
41
67
  }
42
- const isToken = (value) => {
43
- return "value" in value;
44
- };
45
- const recurseToCss = (librarySection) => {
68
+ const standardTypes = new Set(Object.values(DesignToken.Type));
69
+ const recurseToCss = (librarySection, customConverters, getName) => {
46
70
  let result = "";
47
71
  for (const key in librarySection) {
48
72
  const tokenOrGroup = librarySection[key];
49
73
  if (isToken(tokenOrGroup)) {
50
- let value = tokenOrGroup.value;
51
- if (tokenOrGroup.type !== undefined &&
52
- Reflect.has(TokenConverters, tokenOrGroup.type)) {
53
- value = Reflect.get(TokenConverters, tokenOrGroup.type)(value);
74
+ const { $type: type, name } = tokenOrGroup;
75
+ let value = tokenOrGroup.$value;
76
+ if (Reflect.has(customConverters, type)) {
77
+ const converter = customConverters[type];
78
+ if (converter === false) {
79
+ continue;
80
+ }
81
+ value = converter(value, tokenOrGroup);
54
82
  }
55
- result += `--${tokenOrGroup.name}:${value};`;
83
+ else if (Reflect.has(TokenConverters, type)) {
84
+ value = Reflect.get(TokenConverters, type)(value);
85
+ }
86
+ else if (!standardTypes.has(type)) {
87
+ throw new Error(`No CSS converter provided for custom type '${type}' of token '${name}'.`);
88
+ }
89
+ result += `--${getName(tokenOrGroup)}:${value};`;
56
90
  }
57
91
  else {
58
- result = recurseToCss(tokenOrGroup);
92
+ result += recurseToCss(tokenOrGroup, customConverters, getName);
59
93
  }
60
94
  }
61
95
  return result;
62
96
  };
63
- const joiner = (value) => {
64
- return value.join(" ");
97
+ const dimensionConverter = (value) => {
98
+ return `${value.value}${value.unit}`;
99
+ };
100
+ const durationConverter = (value) => {
101
+ return `${value.value}${value.unit}`;
102
+ };
103
+ const percent = (component) => {
104
+ return component === "none" ? "none" : `${component}%`;
105
+ };
106
+ const hexByte = (component) => {
107
+ const byte = Math.min(255, Math.max(0, Math.round(component * 255)));
108
+ return byte.toString(16).padStart(2, "0");
109
+ };
110
+ /**
111
+ * Convert a color to CSS. An sRGB color becomes hex, and the other color
112
+ * spaces become the CSS color function for the space.
113
+ */
114
+ const colorConverter = (value) => {
115
+ const alpha = value.alpha ?? 1;
116
+ const components = value.components;
117
+ const slash = alpha === 1 ? "" : ` / ${alpha}`;
118
+ const [a, b, c] = components;
119
+ switch (value.colorSpace) {
120
+ case "srgb":
121
+ if (components.every((component) => component !== "none")) {
122
+ return `#${components.map(hexByte).join("")}${alpha === 1 ? "" : hexByte(alpha)}`;
123
+ }
124
+ break;
125
+ case "hsl":
126
+ return `hsl(${a} ${percent(b)} ${percent(c)}${slash})`;
127
+ case "hwb":
128
+ return `hwb(${a} ${percent(b)} ${percent(c)}${slash})`;
129
+ case "lab":
130
+ case "lch":
131
+ case "oklab":
132
+ case "oklch":
133
+ return `${value.colorSpace}(${components.join(" ")}${slash})`;
134
+ }
135
+ return `color(${value.colorSpace} ${components.join(" ")}${slash})`;
65
136
  };
66
137
  /**
67
138
  * Convert a border value to CSS
68
139
  */
69
140
  const borderConverter = (value) => {
70
- return `${value.width} ${value.style} ${value.color}`;
141
+ return `${dimensionConverter(value.width)} ${strokeStyleConverter(value.style)} ${colorConverter(value.color)}`;
142
+ };
143
+ const cubicBezierConverter = (value) => {
144
+ return `cubic-bezier(${value.join(", ")})`;
71
145
  };
72
146
  const fontFamilyConverter = (value) => {
73
147
  return typeof value === "string"
@@ -82,29 +156,97 @@ const fontFamilyQuoter = (value) => {
82
156
  }
83
157
  return value.includes(" ") ? `"${value}"` : value;
84
158
  };
159
+ const fontWeights = {
160
+ thin: 100,
161
+ hairline: 100,
162
+ "extra-light": 200,
163
+ "ultra-light": 200,
164
+ light: 300,
165
+ normal: 400,
166
+ regular: 400,
167
+ book: 400,
168
+ medium: 500,
169
+ "semi-bold": 600,
170
+ "demi-bold": 600,
171
+ bold: 700,
172
+ "extra-bold": 800,
173
+ "ultra-bold": 800,
174
+ black: 900,
175
+ heavy: 900,
176
+ "extra-black": 950,
177
+ "ultra-black": 950,
178
+ };
179
+ const fontWeightConverter = (value) => {
180
+ return String(typeof value === "number" ? value : fontWeights[value]);
181
+ };
85
182
  const gradientReducer = (accumulated, value) => {
86
- return accumulated + `${value.color} ${value.position * 100}%,`;
183
+ // Round away float artifacts, e.g. 0.07 * 100 is 7.000000000000001.
184
+ const position = Number((value.position * 100).toPrecision(12));
185
+ return accumulated + `${colorConverter(value.color)} ${position}%,`;
87
186
  };
88
187
  const gradientConverter = (value) => {
89
188
  return value.reduce(gradientReducer, "").replace(/,$/, "");
90
189
  };
91
190
  const shadowConverter = (value) => {
92
- return `${value.offsetX} ${value.offsetY} ${value.blur} ${value.spread} ${value.color}`;
191
+ return (Array.isArray(value) ? value : [value])
192
+ .map((layer) => `${layer.inset ? "inset " : ""}${dimensionConverter(layer.offsetX)} ${dimensionConverter(layer.offsetY)} ${dimensionConverter(layer.blur)} ${dimensionConverter(layer.spread)} ${colorConverter(layer.color)}`)
193
+ .join(", ");
93
194
  };
94
195
  const strokeStyleConverter = (value) => {
95
196
  // CSS doesn't support customizing dashed borders at the time of authoring.
96
197
  return typeof value === "string" ? value : "dashed";
97
198
  };
98
199
  const transitionConverter = (value) => {
99
- return `${value.duration} ${value.delay} ${value.timingFunction}`;
200
+ return `${durationConverter(value.duration)} ${cubicBezierConverter(value.timingFunction)} ${durationConverter(value.delay)}`;
201
+ };
202
+ /**
203
+ * Convert typography to the CSS `font` shorthand. `letterSpacing` cannot be
204
+ * expressed in the shorthand, so it is omitted.
205
+ */
206
+ const typographyConverter = (value) => {
207
+ return `${fontWeightConverter(value.fontWeight)} ${dimensionConverter(value.fontSize)}/${value.lineHeight} ${fontFamilyConverter(value.fontFamily)}`;
100
208
  };
101
209
  const TokenConverters = {
102
210
  [DesignToken.Type.Border]: borderConverter,
103
- [DesignToken.Type.CubicBezier]: joiner,
211
+ [DesignToken.Type.Color]: colorConverter,
212
+ [DesignToken.Type.CubicBezier]: cubicBezierConverter,
213
+ [DesignToken.Type.Dimension]: dimensionConverter,
214
+ [DesignToken.Type.Duration]: durationConverter,
104
215
  [DesignToken.Type.FontFamily]: fontFamilyConverter,
216
+ [DesignToken.Type.FontWeight]: fontWeightConverter,
105
217
  [DesignToken.Type.Gradient]: gradientConverter,
106
218
  [DesignToken.Type.Shadow]: shadowConverter,
107
219
  [DesignToken.Type.StrokeStyle]: strokeStyleConverter,
108
220
  [DesignToken.Type.Transition]: transitionConverter,
221
+ [DesignToken.Type.Typography]: typographyConverter,
109
222
  };
223
+ /**
224
+ * Converts a value of a standard type to CSS, the way {@link toCSS} does for a
225
+ * token of the type, without a converter for the type in `converters`.
226
+ *
227
+ * @remarks
228
+ * A converter for a custom type that has values of standard types uses it for
229
+ * each of them, and a converter for a standard type can use it for what it
230
+ * keeps.
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * toCSS(library, {
235
+ * converters: {
236
+ * elevation: (value) =>
237
+ * `${convert("dimension", value.offset)} ${convert("color", value.color)}`,
238
+ * },
239
+ * });
240
+ * ```
241
+ *
242
+ * @param type - The type, like `"color"`
243
+ * @param value - The value of a token of the type
244
+ * @returns The value as it is written to CSS
245
+ *
246
+ * @public
247
+ */
248
+ export function convert(type, value) {
249
+ const converter = TokenConverters[type];
250
+ return converter ? converter(value) : String(value);
251
+ }
110
252
  //# sourceMappingURL=css-reflector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"css-reflector.js","sourceRoot":"","sources":["../../src/lib/css-reflector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,OAAkC;IACtD,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAsBD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAU;IAEV,MAAM,OAAO,GAAG,CACd,OAAkC,EAClC,UAAqC,EACrC,EAAE;QACF,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAElC,IAAI,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC1B,0CAA0C;gBAC1C,MAAM,QAAQ,GAAG,KAAK,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC/D,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;oBAClC,GAAG,EAAE,OAAO,QAAQ,GAAG;oBACvB,QAAQ;iBACT,CAAC,CAAC;gBACH,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE;oBACtC,KAAK,EAAE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