design-token-library 0.2.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/CHANGELOG.md +19 -0
- package/dist/lib/css-reflector.d.ts +96 -15
- package/dist/lib/css-reflector.js +55 -9
- package/dist/lib/css-reflector.js.map +1 -1
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +4 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/library.d.ts +227 -1
- package/dist/lib/library.js +372 -33
- package/dist/lib/library.js.map +1 -1
- package/dist/lib/public.d.ts +1405 -0
- package/dist/lib/recipe.d.ts +20 -3
- package/dist/lib/recipe.js +19 -2
- package/dist/lib/recipe.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/tsdoc-metadata.json +11 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ 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
|
+
## [0.3.0] - 2026-11-03
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `configuredValueOf(token)` is a token's value as configured, or as last given to `set()`, with its refs and computed values unresolved (#106). A token of an extended library that isn't given a value has its source token's. `isComputed(value)` tells whether a value is a recipe's result, also one made by another copy of the package, as `isRef()` does for a ref. A tool tells a given token from a derived one by whether its configured value has a ref or a computed value at any depth, and a converter reads a ref in a value to write it as a `var()`.
|
|
13
|
+
- `dependenciesOf(token)` is the tokens a token's value refers to, through refs anywhere in its configured value, including the arguments of its recipes, in the token's own library (#106).
|
|
14
|
+
- `entriesOf(library)` lists the tokens and groups of a library, each with its path, in the order of the config, for a tool that visits every token without restating the library's rules for what is a token or a group (#105). It walks as a DOM `TreeWalker` does: `whatToShow` is `"token"`, `"group"` or `"all"`, and a `filter` leaves an entry out, or `"reject"` leaves out a group and what is under it.
|
|
15
|
+
- `dependentsOf(token)` is the tokens whose configured values refer to a token, directly, in the token's own library: the reverse of `dependenciesOf()` (#110). It reads no token's value, so a tool finds what a `set()` may change, for an extension that hasn't been read, without reading the library. The index is made once for a library and again after a token is set to a different value.
|
|
16
|
+
- A CSS converter can return a record to write a token as more than one custom property, such as a value for each state of a component or a property for each field of a typography (#64). A key is added to the name of the token's property with `-`, and `""` is the token's own: `{ "": rest, hover }` for `fill` writes `--fill` and `--fill-hover`. A string is the same as `{ "": value }`, and an empty record writes nothing. `toProperties()` has a `{ var, property }` for each key, at `properties.fill.hover`, typed by the keys a converter returns when its return type is inferred; so it calls a converter it's given, and reads the values of those tokens. Adds the `CSSValue`, `CSSValues`, `CSSPropertiesOf` and `PropertiesConverters` types. `ToPropertiesOptions` and `CSSPropertiesLibrary` take the converters as a type parameter, with a default.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- An extension makes its tokens when they are first read, or up front for those its config gives, rather than one for every token of the library when `extend()` is called (#113). The library an extension extends holds it weakly, so an extension that nothing refers to is collected, with its subscribers. With 600 tokens, `extend({})` takes about a fifth of the time, and 200 dropped extensions keep 0.1 MB rather than 93 MB. Walking an extension with `entriesOf()`, writing its CSS or `dependentsOf()` still makes all of its tokens.
|
|
21
|
+
- **Breaking:** `CSSConverter` returns `CSSValue` (`string | CSSValues`) rather than `string`. A converter that returns a string is still one, but code that calls a value typed `CSSConverter` gets the union (#64).
|
|
22
|
+
- `package.json` sets `"sideEffects": false` so bundlers can tree-shake unused exports from the package.
|
|
23
|
+
- Package entry uses explicit named exports instead of `export *`. Exported `ConvertersOf`, `StandardConverters`, and `CSSPropertyValues` so the public CSS types resolve without forgotten-export errors.
|
|
24
|
+
- Published typings (`types` / `exports.types`) come from the API Extractor public `.d.ts` rollup at `dist/lib/public.d.ts` (generated at the end of `npm run build`). `dist/lib/index.d.ts` stays the TypeScript barrel used as the extractor entry point.
|
|
25
|
+
- A ref resolves to its token's value, which is resolved and frozen already, rather than to a copy of it. A recipe whose argument refers to a large value, like a palette of many colors, no longer copies it each time the recipe is computed.
|
|
26
|
+
|
|
8
27
|
## [0.2.0] - 2026-10-28
|
|
9
28
|
|
|
10
29
|
### Added
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import { DesignToken } from "./design-token.js";
|
|
2
2
|
import { Library } from "./library.js";
|
|
3
|
+
/**
|
|
4
|
+
* The values of the custom properties of a token, by what is added to the
|
|
5
|
+
* name of the token's property with `-`: `""` is the token's own property,
|
|
6
|
+
* and `hover` is `--fill-hover` for a token named `fill`.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type CSSValues = {
|
|
11
|
+
readonly [suffix: string]: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* What a {@link CSSConverter} returns: the value of the token's custom
|
|
15
|
+
* property, or {@link CSSValues} for a token written as more than one.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type CSSValue = string | CSSValues;
|
|
3
20
|
/**
|
|
4
21
|
* Converts a token value to a CSS value.
|
|
5
22
|
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* A string is the value of the token's custom property, and is the same as
|
|
25
|
+
* `{ "": value }`. A converter returns {@link CSSValues} to write a token as
|
|
26
|
+
* more than one property, such as a value for each state of a component, or
|
|
27
|
+
* a typography value as a property for each of its fields. An empty record
|
|
28
|
+
* writes none.
|
|
29
|
+
*
|
|
6
30
|
* @public
|
|
7
31
|
*/
|
|
8
|
-
export type CSSConverter<V, T extends DesignToken.Shape = DesignToken.Shape> = (value: V, token: Library.Token<T, {}>) =>
|
|
32
|
+
export type CSSConverter<V, T extends DesignToken.Shape = DesignToken.Shape> = (value: V, token: Library.Token<T, {}>) => CSSValue;
|
|
9
33
|
/**
|
|
10
34
|
* A union of the custom tokens in a library of shape `T`: tokens whose
|
|
11
35
|
* type is not defined by {@link https://www.designtokens.org/tr/2025.10/format/#types}.
|
|
@@ -22,7 +46,10 @@ export type CustomTokensOf<T> = Exclude<Library.TokensOf<T>, {
|
|
|
22
46
|
* @public
|
|
23
47
|
*/
|
|
24
48
|
export type CSSConverters<T> = ConvertersOf<CustomTokensOf<T>>;
|
|
25
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export type ConvertersOf<C> = {
|
|
26
53
|
[N in C extends {
|
|
27
54
|
$type: infer N extends string;
|
|
28
55
|
} ? N : never]: C extends {
|
|
@@ -32,8 +59,10 @@ type ConvertersOf<C> = {
|
|
|
32
59
|
/**
|
|
33
60
|
* A converter for any of the standard types, which is used in place of the one
|
|
34
61
|
* of the library.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
35
64
|
*/
|
|
36
|
-
type StandardConverters = {
|
|
65
|
+
export type StandardConverters = {
|
|
37
66
|
[N in keyof DesignToken.ReadonlyValueByType]?: CSSConverter<DesignToken.ReadonlyValueByType[N], Extract<DesignToken.Standard, {
|
|
38
67
|
$type: N;
|
|
39
68
|
}>>;
|
|
@@ -63,19 +92,27 @@ export interface CSSPropertiesOptions {
|
|
|
63
92
|
*/
|
|
64
93
|
name?(token: Library.Token<any, any>): string;
|
|
65
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The converters that {@link toProperties} takes, by type.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export type PropertiesConverters = {
|
|
101
|
+
readonly [type: string]: ((value: any, token: any) => CSSValue) | false;
|
|
102
|
+
};
|
|
66
103
|
/**
|
|
67
104
|
* Options accepted by {@link toProperties}.
|
|
68
105
|
*
|
|
69
106
|
* @public
|
|
70
107
|
*/
|
|
71
|
-
export interface ToPropertiesOptions extends CSSPropertiesOptions {
|
|
108
|
+
export interface ToPropertiesOptions<C extends PropertiesConverters = PropertiesConverters> extends CSSPropertiesOptions {
|
|
72
109
|
/**
|
|
73
110
|
* The converters given to {@link toCSS}. A token whose custom type is `false`
|
|
74
111
|
* isn't written by `toCSS`, so it has no custom property and is left out.
|
|
112
|
+
* A token whose converter returns {@link CSSValues} has a property for
|
|
113
|
+
* each of its keys.
|
|
75
114
|
*/
|
|
76
|
-
converters?:
|
|
77
|
-
readonly [type: string]: ((value: any, token: any) => string) | false;
|
|
78
|
-
};
|
|
115
|
+
converters?: C;
|
|
79
116
|
}
|
|
80
117
|
/**
|
|
81
118
|
* Options accepted by {@link toCSS}.
|
|
@@ -112,29 +149,74 @@ export type ToCSSArgs<T> = [CustomTokensOf<T>] extends [never] ? [options?: CSSO
|
|
|
112
149
|
* @public
|
|
113
150
|
*/
|
|
114
151
|
export declare function toCSS<T extends {}, R extends {}>(library: Library.Library<T, R>, ...[options]: ToCSSArgs<NoInfer<T>>): string;
|
|
115
|
-
|
|
152
|
+
/**
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export interface CSSPropertyValues {
|
|
116
156
|
readonly var: `var(--${string})`;
|
|
117
157
|
readonly property: `--${string}`;
|
|
118
158
|
}
|
|
119
159
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
160
|
+
* The {@link CSSPropertyValues} of a token of shape `T`, given the
|
|
161
|
+
* converters `C`: one for its property, or one for each key of the
|
|
162
|
+
* {@link CSSValues} its converter returns, where `""` is the token's own.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* The keys are known when the return type of the converter is inferred.
|
|
166
|
+
* When it isn't, such as for a converter typed {@link CSSConverter}, the
|
|
167
|
+
* token has the property of its own in the type, and the others at runtime.
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
export type CSSPropertiesOf<T, C = {}> = T extends {
|
|
172
|
+
$type: infer N extends keyof C;
|
|
173
|
+
} ? C[N] extends (...args: any[]) => infer V ? V extends string ? CSSPropertyValues : string extends keyof V ? CSSPropertyValues : ("" extends keyof V ? CSSPropertyValues : {}) & {
|
|
174
|
+
readonly [P in Exclude<keyof V, "">]: CSSPropertyValues;
|
|
175
|
+
} : CSSPropertyValues : CSSPropertyValues;
|
|
176
|
+
/**
|
|
177
|
+
* A collection of {@link CSSPropertyValues} (`var` and `property` per token) that mirrors the
|
|
178
|
+
* structure of the source {@link (Library:namespace).Library}.
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* `C` is the converters given to {@link toProperties}, which name the
|
|
182
|
+
* properties of a token written as more than one, see {@link CSSPropertiesOf}.
|
|
183
|
+
*
|
|
122
184
|
* @public
|
|
123
185
|
*/
|
|
124
|
-
export type CSSPropertiesLibrary<T extends {}> = {
|
|
125
|
-
[K in keyof Readonly<T>]: T[K] extends DesignToken.Shape ?
|
|
186
|
+
export type CSSPropertiesLibrary<T extends {}, C = {}> = {
|
|
187
|
+
[K in keyof Readonly<T>]: T[K] extends DesignToken.Shape ? CSSPropertiesOf<T[K], C> : K extends keyof DesignToken.Group ? T[K] : T[K] extends {} ? CSSPropertiesLibrary<T[K], C> : never;
|
|
126
188
|
};
|
|
127
189
|
/**
|
|
128
|
-
* Construct an {@link CSSPropertiesLibrary} from a {@link Library.Library
|
|
190
|
+
* Construct an {@link CSSPropertiesLibrary} from a {@link (Library:namespace).Library}.
|
|
129
191
|
*
|
|
130
192
|
* @remarks
|
|
131
193
|
* Pass the same `converters` given to {@link toCSS} to leave out the tokens it does
|
|
132
194
|
* not write (a custom type whose converter is `false`). They are still in the
|
|
133
195
|
* {@link CSSPropertiesLibrary} type, but missing at runtime.
|
|
134
196
|
*
|
|
197
|
+
* A token whose type has a converter in `converters` has a property for each
|
|
198
|
+
* key of the {@link CSSValues} it returns, so this reads the token's value to
|
|
199
|
+
* call it. Its own property is `var` and `property`, as for any token, and
|
|
200
|
+
* the one for `hover` is at `hover`, so a converter's keys can't be `var` or
|
|
201
|
+
* `property`.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const properties = toProperties(library, {
|
|
206
|
+
* converters: {
|
|
207
|
+
* states: (value: States) => ({
|
|
208
|
+
* "": convert("color", value.rest),
|
|
209
|
+
* hover: convert("color", value.hover),
|
|
210
|
+
* }),
|
|
211
|
+
* },
|
|
212
|
+
* });
|
|
213
|
+
* properties.fill.var; // "var(--fill)"
|
|
214
|
+
* properties.fill.hover.var; // "var(--fill-hover)"
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
135
217
|
* @public
|
|
136
218
|
*/
|
|
137
|
-
export declare function toProperties<T extends Library.Library<any
|
|
219
|
+
export declare function toProperties<T extends Library.Library<any>, C extends PropertiesConverters = {}>(library: T, options?: ToPropertiesOptions<C>): CSSPropertiesLibrary<T["tokens"], C>;
|
|
138
220
|
/**
|
|
139
221
|
* Converts a value of a standard type to CSS, the way {@link toCSS} does for a
|
|
140
222
|
* token of the type, without a converter for the type in `converters`.
|
|
@@ -161,4 +243,3 @@ export declare function toProperties<T extends Library.Library<any>>(library: T,
|
|
|
161
243
|
* @public
|
|
162
244
|
*/
|
|
163
245
|
export declare function convert<Name extends keyof DesignToken.ReadonlyValueByType>(type: Name, value: DesignToken.ReadonlyValueByType[Name]): string;
|
|
164
|
-
export {};
|
|
@@ -21,13 +21,46 @@ export function toCSS(library, ...[options]) {
|
|
|
21
21
|
*/
|
|
22
22
|
const defaultName = (token) => token.name.replace(/\.\$root$/, "").replaceAll(".", "-");
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* The values of a token's properties. A value that isn't a record, such as a
|
|
25
|
+
* number, which a standard type without a converter has, is written as a
|
|
26
|
+
* string, as it was before a converter could return a record.
|
|
27
|
+
*/
|
|
28
|
+
const valuesOf = (value) => isValues(value) ? value : { "": String(value) };
|
|
29
|
+
// A converter's result is typed by `CSSConverter`, so an object is a record.
|
|
30
|
+
const isValues = (value) => typeof value === "object" && value !== null;
|
|
31
|
+
/**
|
|
32
|
+
* The custom property of a token named `name` for a key of its
|
|
33
|
+
* {@link CSSValues}.
|
|
34
|
+
*/
|
|
35
|
+
const propertyName = (name, suffix) => suffix === "" ? `--${name}` : `--${name}-${suffix}`;
|
|
36
|
+
/**
|
|
37
|
+
* Construct an {@link CSSPropertiesLibrary} from a {@link (Library:namespace).Library}.
|
|
25
38
|
*
|
|
26
39
|
* @remarks
|
|
27
40
|
* Pass the same `converters` given to {@link toCSS} to leave out the tokens it does
|
|
28
41
|
* not write (a custom type whose converter is `false`). They are still in the
|
|
29
42
|
* {@link CSSPropertiesLibrary} type, but missing at runtime.
|
|
30
43
|
*
|
|
44
|
+
* A token whose type has a converter in `converters` has a property for each
|
|
45
|
+
* key of the {@link CSSValues} it returns, so this reads the token's value to
|
|
46
|
+
* call it. Its own property is `var` and `property`, as for any token, and
|
|
47
|
+
* the one for `hover` is at `hover`, so a converter's keys can't be `var` or
|
|
48
|
+
* `property`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const properties = toProperties(library, {
|
|
53
|
+
* converters: {
|
|
54
|
+
* states: (value: States) => ({
|
|
55
|
+
* "": convert("color", value.rest),
|
|
56
|
+
* hover: convert("color", value.hover),
|
|
57
|
+
* }),
|
|
58
|
+
* },
|
|
59
|
+
* });
|
|
60
|
+
* properties.fill.var; // "var(--fill)"
|
|
61
|
+
* properties.fill.hover.var; // "var(--fill-hover)"
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
31
64
|
* @public
|
|
32
65
|
*/
|
|
33
66
|
export function toProperties(library, options = {}) {
|
|
@@ -37,17 +70,27 @@ export function toProperties(library, options = {}) {
|
|
|
37
70
|
for (const key in section) {
|
|
38
71
|
const sectionValue = section[key];
|
|
39
72
|
if (isToken(sectionValue)) {
|
|
73
|
+
const converter = converters[sectionValue.$type];
|
|
40
74
|
// `toCSS` doesn't write a token whose type is `false`.
|
|
41
|
-
if (
|
|
75
|
+
if (converter === false) {
|
|
42
76
|
continue;
|
|
43
77
|
}
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
78
|
+
const tokenName = getName(sectionValue);
|
|
79
|
+
const values = valuesOf(converter?.(sectionValue.$value, sectionValue) ?? "");
|
|
80
|
+
const propertyValues = {};
|
|
81
|
+
for (const suffix of Object.keys(values)) {
|
|
82
|
+
if (suffix === "var" || suffix === "property") {
|
|
83
|
+
throw new Error(`The converter of '${sectionValue.$type}' returns a value for '${suffix}' for token '${sectionValue.name}', which is the name of a field of its properties.`);
|
|
84
|
+
}
|
|
85
|
+
const name = propertyName(tokenName, suffix);
|
|
86
|
+
propertyValues[suffix] = Object.freeze({
|
|
87
|
+
var: `var(${name})`,
|
|
88
|
+
property: name,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const { "": own, ...others } = propertyValues;
|
|
49
92
|
Reflect.defineProperty(properties, key, {
|
|
50
|
-
value:
|
|
93
|
+
value: Object.freeze({ ...own, ...others }),
|
|
51
94
|
enumerable: true,
|
|
52
95
|
});
|
|
53
96
|
}
|
|
@@ -86,7 +129,10 @@ const recurseToCss = (librarySection, customConverters, getName) => {
|
|
|
86
129
|
else if (!standardTypes.has(type)) {
|
|
87
130
|
throw new Error(`No CSS converter provided for custom type '${type}' of token '${name}'.`);
|
|
88
131
|
}
|
|
89
|
-
|
|
132
|
+
const tokenName = getName(tokenOrGroup);
|
|
133
|
+
for (const [suffix, declared] of Object.entries(valuesOf(value))) {
|
|
134
|
+
result += `${propertyName(tokenName, suffix)}:${declared};`;
|
|
135
|
+
}
|
|
90
136
|
}
|
|
91
137
|
else {
|
|
92
138
|
result += recurseToCss(tokenOrGroup, customConverters, getName);
|
|
@@ -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;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAA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;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,OAAO,CACnB,IAAU,EACV,KAA4C;IAE5C,MAAM,SAAS,GACX,eACH,CAAC,IAAI,CAAC,CAAC;IAER,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DesignToken } from "./design-token.js";
|
|
2
|
-
export { CircularReferenceError, Library } from "./library.js";
|
|
3
|
-
export { override, recipes } from "./recipe.js";
|
|
2
|
+
export { CircularReferenceError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, } from "./library.js";
|
|
3
|
+
export { isComputed, override, recipes } from "./recipe.js";
|
|
4
4
|
export { isRef, pathOf, ref, refs } from "./ref.js";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export { convert, toCSS, toProperties, type CSSConverter, type CSSPropertiesOf, type CSSValue, type CSSValues, type PropertiesConverters, type CSSConverterEntries, type CSSConverters, type CSSOptions, type CSSPropertiesLibrary, type CSSPropertyValues, type CSSPropertiesOptions, type ConvertersOf, type CustomTokensOf, type StandardConverters, type ToCSSArgs, type ToPropertiesOptions, } from "./css-reflector.js";
|
|
6
|
+
export { hex, ms, px, rem, s } from "./values.js";
|
package/dist/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { DesignToken } from "./design-token.js";
|
|
2
|
-
export { CircularReferenceError, Library } from "./library.js";
|
|
3
|
-
export { override, recipes } from "./recipe.js";
|
|
2
|
+
export { CircularReferenceError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, } from "./library.js";
|
|
3
|
+
export { isComputed, override, recipes } from "./recipe.js";
|
|
4
4
|
export { isRef, pathOf, ref, refs } from "./ref.js";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export { convert, toCSS, toProperties, } from "./css-reflector.js";
|
|
6
|
+
export { hex, ms, px, rem, s } from "./values.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACH,sBAAsB,EACtB,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACH,OAAO,EACP,KAAK,EACL,YAAY,GAiBf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/lib/library.d.ts
CHANGED
|
@@ -31,11 +31,20 @@ export declare namespace Library {
|
|
|
31
31
|
* @remarks
|
|
32
32
|
* This has no tokens to add, so a value is checked against the type
|
|
33
33
|
* of its token wherever the token is.
|
|
34
|
+
*
|
|
35
|
+
* A token of the extension is made when it is first read, and an
|
|
36
|
+
* extension that nothing refers to is collected, along with its
|
|
37
|
+
* subscribers.
|
|
34
38
|
*/
|
|
35
39
|
extend(config: ExtendConfig<T, R>, options?: ExtendOptions): Library<T, R>;
|
|
36
40
|
/**
|
|
37
41
|
* Creates a library with the values of tokens replaced, new tokens,
|
|
38
42
|
* and recipes overridden.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* A token of the extension is made when it is first read, and an
|
|
46
|
+
* extension that nothing refers to is collected, along with its
|
|
47
|
+
* subscribers.
|
|
39
48
|
*/
|
|
40
49
|
extend<K extends NoRoot<K> = {}>(config: ExtendConfig<T, R & NewTokens<K, T>> & Config<K, R & NewTokens<K, T>, never, T> & NoInfer<ConfigValueCheck<K, R & NewTokens<K, T>>> & (ConfigTypeHint | {}), options?: ExtendOptions): Library<T & NewTokens<K, T>, R & NewTokens<K, T>>;
|
|
41
50
|
}
|
|
@@ -58,6 +67,64 @@ export declare namespace Library {
|
|
|
58
67
|
export type NoRoot<T> = {
|
|
59
68
|
[K in keyof T]: K extends "$root" ? never : T[K];
|
|
60
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Which entries of a library {@link (entriesOf:3)} lists: its tokens, its
|
|
72
|
+
* groups, or both. Each is the `kind` of the entries it lists.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export type Show = "all" | "token" | "group";
|
|
77
|
+
/**
|
|
78
|
+
* A token of a library, with the path of keys that leads to it from the
|
|
79
|
+
* root. The path of a group's own token ends with `$root`.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export interface TokenEntry<R extends {}> {
|
|
84
|
+
readonly kind: "token";
|
|
85
|
+
readonly path: readonly string[];
|
|
86
|
+
readonly token: TokenRecord<R>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A group of a library, with the path of keys that leads to it from the
|
|
90
|
+
* root. The group has the `$`-prefixed properties it was configured with.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export interface GroupEntry {
|
|
95
|
+
readonly kind: "group";
|
|
96
|
+
readonly path: readonly string[];
|
|
97
|
+
readonly group: Readonly<DesignToken.Group>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The entries that {@link (entriesOf:3)} lists for `S`.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export type EntryOf<S extends Show, R extends {}> = S extends "token" ? TokenEntry<R> : S extends "group" ? GroupEntry : TokenEntry<R> | GroupEntry;
|
|
105
|
+
/**
|
|
106
|
+
* What a {@link (entriesOf:3)} filter returns for an entry: `true` lists it,
|
|
107
|
+
* `false` leaves it out, and `"reject"` leaves it out along with
|
|
108
|
+
* everything under it.
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export type FilterResult = boolean | "reject";
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export interface EntriesOptions<S extends Show, R extends {}> {
|
|
117
|
+
/**
|
|
118
|
+
* The kind of entries to list. Groups are visited, and their tokens
|
|
119
|
+
* listed, whichever it is. By default, all.
|
|
120
|
+
*/
|
|
121
|
+
readonly whatToShow?: S;
|
|
122
|
+
/**
|
|
123
|
+
* Called with each entry of the kinds shown, before its children are
|
|
124
|
+
* visited.
|
|
125
|
+
*/
|
|
126
|
+
filter?(entry: EntryOf<S, R>): FilterResult;
|
|
127
|
+
}
|
|
61
128
|
export interface Subscriber<R extends {}> {
|
|
62
129
|
onChange(records: ReadonlyArray<Library.TokenRecord<R>>): void;
|
|
63
130
|
}
|
|
@@ -370,7 +437,7 @@ export declare namespace Library {
|
|
|
370
437
|
readonly [key: string]: ConfigTypeHint | DesignToken.Type | (string & {}) | number | boolean | object | null | undefined;
|
|
371
438
|
};
|
|
372
439
|
/**
|
|
373
|
-
* A configuration object provided to {@link (Library:namespace).Library.extend}.
|
|
440
|
+
* A configuration object provided to {@link (Library:namespace).Library.(extend:1)}.
|
|
374
441
|
* All tokens and groups of the source library are optional, and token
|
|
375
442
|
* values may be static values, refs or computed values. Token types are inherited
|
|
376
443
|
* from the source library.
|
|
@@ -404,4 +471,163 @@ export declare class CircularReferenceError extends Error {
|
|
|
404
471
|
readonly chain: string[];
|
|
405
472
|
constructor(chain: string[]);
|
|
406
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* A token's value as it was configured, or last given to `set()`, with its
|
|
476
|
+
* refs and computed values unresolved. A token of a library made by
|
|
477
|
+
* `extend()` that isn't given a value has its source token's.
|
|
478
|
+
*
|
|
479
|
+
* @remarks
|
|
480
|
+
* A token's `$value` is resolved, so it can't tell a value that is given from
|
|
481
|
+
* one that is derived from other tokens, or say where in a value a ref is. A
|
|
482
|
+
* tool that reads how a library is configured finds the refs in this value
|
|
483
|
+
* with {@link isRef} and the computed values with {@link isComputed}: a value
|
|
484
|
+
* with neither, at any depth, is given. A converter that writes a ref as a
|
|
485
|
+
* CSS `var()`, rather than its token's value, reads the ref here and its
|
|
486
|
+
* path with {@link pathOf}.
|
|
487
|
+
*
|
|
488
|
+
* It's the value the token holds, not a copy, so it isn't frozen. Changing it
|
|
489
|
+
* doesn't change the token: give a new value to `set()`. Refs and computed
|
|
490
|
+
* values are searched for in plain data, as the library resolves them, and
|
|
491
|
+
* not in a class instance or a function.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* const isGiven = (value: unknown): boolean =>
|
|
496
|
+
* !isRef(value) &&
|
|
497
|
+
* !isComputed(value) &&
|
|
498
|
+
* (typeof value !== "object" || value === null ||
|
|
499
|
+
* Object.values(value).every(isGiven));
|
|
500
|
+
*
|
|
501
|
+
* isGiven(configuredValueOf(library.tokens.colors.primary)); // true
|
|
502
|
+
* isGiven(configuredValueOf(library.tokens.colors.hover)); // false: a recipe
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @public
|
|
506
|
+
*/
|
|
507
|
+
export declare const configuredValueOf: <T extends DesignToken.Shape, R extends {}, G extends string = never>(token: Library.Token<T, R, G>) => Library.ConfigTokenValue<T, R> | DesignToken.ReadonlyValueByToken<T>;
|
|
508
|
+
/**
|
|
509
|
+
* The tokens that a token's value refers to, through refs anywhere in its
|
|
510
|
+
* configured value, including the arguments of the recipes it's computed
|
|
511
|
+
* with, in the token's library. Each token is listed once, in the order its
|
|
512
|
+
* first ref is in the value.
|
|
513
|
+
*
|
|
514
|
+
* @remarks
|
|
515
|
+
* These are the tokens the value is made from, and not theirs in turn: a
|
|
516
|
+
* tool follows each with `dependenciesOf()` for the whole chain. A value
|
|
517
|
+
* computed by a recipe from literal arguments only has no dependencies,
|
|
518
|
+
* though it's derived: {@link configuredValueOf} tells that apart.
|
|
519
|
+
*
|
|
520
|
+
* It throws when a ref's path isn't a token of the library, as reading the
|
|
521
|
+
* token's `$value` does.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* // hover: { $value: Recipes.darken(theme.colors.primary, 0.2) }
|
|
526
|
+
* dependenciesOf(library.tokens.colors.hover).map((token) => token.name);
|
|
527
|
+
* // ["colors.primary"]
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @public
|
|
531
|
+
*/
|
|
532
|
+
export declare const dependenciesOf: <T extends DesignToken.Shape, R extends {}, G extends string = never>(token: Library.Token<T, R, G>) => ReadonlyArray<Library.TokenRecord<R>>;
|
|
533
|
+
/**
|
|
534
|
+
* The tokens and groups of a library, each with its path, in the order of
|
|
535
|
+
* the config. A group is listed before the tokens and groups in it.
|
|
536
|
+
*
|
|
537
|
+
* @remarks
|
|
538
|
+
* This is the library's own rule for what is a token and what is a group, and
|
|
539
|
+
* for which keys are children, so a tool that visits every token (an index, a
|
|
540
|
+
* report, a list of the tokens to offer for a property) doesn't walk
|
|
541
|
+
* `library.tokens` and restate it. It walks as a DOM `TreeWalker` does: an
|
|
542
|
+
* entry that `whatToShow` leaves out is not passed to `filter`, but what is
|
|
543
|
+
* under it is still visited, and `filter` can return `"reject"` to leave out
|
|
544
|
+
* a group and everything under it.
|
|
545
|
+
*
|
|
546
|
+
* The library itself isn't listed, as a `TreeWalker`'s root isn't, so its own
|
|
547
|
+
* `$`-prefixed properties are not visited. A group's own token is listed with
|
|
548
|
+
* the path of its group and `$root`.
|
|
549
|
+
*
|
|
550
|
+
* The order is the order of the keys in a JavaScript object, so a name that
|
|
551
|
+
* is an array index (`"0"`, `"123"`) is listed before the other names of its
|
|
552
|
+
* group, in ascending order, whatever its place in the config.
|
|
553
|
+
*
|
|
554
|
+
* The listing is lazy and reads the
|
|
555
|
+
* library as it goes; a token's `$value` is not read.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* // The names of every token that isn't deprecated, in a group that isn't
|
|
560
|
+
* for (const { token } of entriesOf(library, {
|
|
561
|
+
* whatToShow: "token",
|
|
562
|
+
* filter: ({ token }) => !token.$deprecated,
|
|
563
|
+
* })) {
|
|
564
|
+
* names.push(token.name);
|
|
565
|
+
* }
|
|
566
|
+
*
|
|
567
|
+
* // Everything, leaving out the deprecated groups
|
|
568
|
+
* const entries = [
|
|
569
|
+
* ...entriesOf(library, {
|
|
570
|
+
* filter: (entry) =>
|
|
571
|
+
* entry.kind === "group" && entry.group.$deprecated
|
|
572
|
+
* ? "reject"
|
|
573
|
+
* : true,
|
|
574
|
+
* }),
|
|
575
|
+
* ];
|
|
576
|
+
* ```
|
|
577
|
+
*
|
|
578
|
+
* @public
|
|
579
|
+
*/
|
|
580
|
+
export declare function entriesOf<T extends {}, R extends {}>(library: Library.Library<T, R>, options: Library.EntriesOptions<"token", R> & {
|
|
581
|
+
whatToShow: "token";
|
|
582
|
+
}): Generator<Library.TokenEntry<R>, void, undefined>;
|
|
583
|
+
/** @public */
|
|
584
|
+
export declare function entriesOf<T extends {}, R extends {}>(library: Library.Library<T, R>, options: Library.EntriesOptions<"group", R> & {
|
|
585
|
+
whatToShow: "group";
|
|
586
|
+
}): Generator<Library.GroupEntry, void, undefined>;
|
|
587
|
+
/** @public */
|
|
588
|
+
export declare function entriesOf<T extends {}, R extends {}>(library: Library.Library<T, R>, options?: Library.EntriesOptions<"all", R>): Generator<Library.EntryOf<"all", R>, void, undefined>;
|
|
589
|
+
/**
|
|
590
|
+
* The tokens whose values refer to a token, through refs anywhere in their
|
|
591
|
+
* configured values, including the arguments of their recipes, in the
|
|
592
|
+
* token's library. It is the reverse of {@link dependenciesOf}: each token is
|
|
593
|
+
* listed once, in the order of the library.
|
|
594
|
+
*
|
|
595
|
+
* @remarks
|
|
596
|
+
* These are the tokens that refer to the token directly. A token whose value
|
|
597
|
+
* may change when this one is set is also one that refers to one of those: a
|
|
598
|
+
* tool follows each with `dependentsOf()` for the whole set, as it follows
|
|
599
|
+
* {@link dependenciesOf} for the chain the other way.
|
|
600
|
+
*
|
|
601
|
+
* This reads the configured values and not the values, so it resolves no
|
|
602
|
+
* token, and so it is known of a library whose tokens have not been read. It
|
|
603
|
+
* is found for the whole library once and kept until a token is set to a
|
|
604
|
+
* different value, so each call after the first is a lookup. A value a recipe
|
|
605
|
+
* reads other than through its arguments is not seen, as for
|
|
606
|
+
* {@link dependenciesOf}.
|
|
607
|
+
*
|
|
608
|
+
* It throws when a ref in a token of the library isn't a token of it, as
|
|
609
|
+
* reading the token's `$value` does.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```ts
|
|
613
|
+
* // hover: { $value: Recipes.darken(theme.colors.primary, 0.2) }
|
|
614
|
+
* dependentsOf(library.tokens.colors.primary).map((token) => token.name);
|
|
615
|
+
* // ["colors.hover"]
|
|
616
|
+
*
|
|
617
|
+
* // Every token that may change when a token is set
|
|
618
|
+
* const affected = new Set<Library.Token<any, any>>();
|
|
619
|
+
* const visit = (token: Library.Token<any, any>) => {
|
|
620
|
+
* for (const dependent of dependentsOf(token)) {
|
|
621
|
+
* if (!affected.has(dependent)) {
|
|
622
|
+
* affected.add(dependent);
|
|
623
|
+
* visit(dependent);
|
|
624
|
+
* }
|
|
625
|
+
* }
|
|
626
|
+
* };
|
|
627
|
+
* visit(extension.tokens.color.context);
|
|
628
|
+
* ```
|
|
629
|
+
*
|
|
630
|
+
* @public
|
|
631
|
+
*/
|
|
632
|
+
export declare const dependentsOf: <T extends DesignToken.Shape, R extends {}, G extends string = never>(token: Library.Token<T, R, G>) => ReadonlyArray<Library.TokenRecord<R>>;
|
|
407
633
|
export {};
|