design-token-library 0.3.0 → 0.4.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 +38 -0
- package/dist/lib/css-reflector.d.ts +32 -24
- package/dist/lib/css-reflector.js +10 -26
- package/dist/lib/css-reflector.js.map +1 -1
- package/dist/lib/equality.d.ts +16 -0
- package/dist/lib/equality.js +90 -0
- package/dist/lib/equality.js.map +1 -0
- package/dist/lib/graph.d.ts +58 -0
- package/dist/lib/graph.js +104 -0
- package/dist/lib/graph.js.map +1 -0
- package/dist/lib/index.d.ts +4 -2
- package/dist/lib/index.js +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/library.d.ts +221 -10
- package/dist/lib/library.js +1256 -258
- package/dist/lib/library.js.map +1 -1
- package/dist/lib/notifier.d.ts +0 -15
- package/dist/lib/notifier.js +0 -23
- package/dist/lib/notifier.js.map +1 -1
- package/dist/lib/parse-document.d.ts +21 -0
- package/dist/lib/parse-document.js +31 -0
- package/dist/lib/parse-document.js.map +1 -0
- package/dist/lib/parse-expression.d.ts +45 -0
- package/dist/lib/parse-expression.js +148 -0
- package/dist/lib/parse-expression.js.map +1 -0
- package/dist/lib/parse-extension.d.ts +24 -0
- package/dist/lib/parse-extension.js +68 -0
- package/dist/lib/parse-extension.js.map +1 -0
- package/dist/lib/parse-resolve.d.ts +16 -0
- package/dist/lib/parse-resolve.js +281 -0
- package/dist/lib/parse-resolve.js.map +1 -0
- package/dist/lib/parse-value.d.ts +35 -0
- package/dist/lib/parse-value.js +330 -0
- package/dist/lib/parse-value.js.map +1 -0
- package/dist/lib/parse.d.ts +103 -0
- package/dist/lib/parse.js +562 -0
- package/dist/lib/parse.js.map +1 -0
- package/dist/lib/queue.d.ts +13 -2
- package/dist/lib/queue.js +18 -2
- package/dist/lib/queue.js.map +1 -1
- package/dist/lib/ref.d.ts +18 -1
- package/dist/lib/ref.js +22 -4
- package/dist/lib/ref.js.map +1 -1
- package/dist/lib/standard-values.d.ts +50 -0
- package/dist/lib/standard-values.js +73 -0
- package/dist/lib/standard-values.js.map +1 -0
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/utilities.d.ts +6 -0
- package/dist/lib/utilities.js +7 -1
- package/dist/lib/utilities.js.map +1 -1
- package/package.json +9 -5
- package/dist/lib/public.d.ts +0 -1405
- package/dist/lib/tsdoc-metadata.json +0 -11
- package/dist/lib/watcher.d.ts +0 -12
- package/dist/lib/watcher.js +0 -25
- package/dist/lib/watcher.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,18 +5,56 @@ 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.4.0] - 2026-11-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- A library with a subscriber keeps a token's value when the token resolves again to an equal value, so an unchanged value is the same object. Each DTCG type has its own equality: a dimension or duration by number and unit, a color by color space, components and alpha (not `hex`), composite types part by part, and arrays in order. An optional part, such as `alpha` or `inset`, is compared as written. A library without a subscriber keeps no previous values.
|
|
13
|
+
- `ownTokensOf(library)`, which lists an extension's own tokens in library order, for a first render that writes only them: those it gives a value, those that are set or new in it, those that call a recipe it overrides, and those that depend on one of them, including through a ref in a recipe's result. It lists every token of a library made by `create()`.
|
|
14
|
+
- `subscribe(subscriber, { origin })`: which tokens of an extension a subscriber is told of, by where their values come from: `"own"` (the default), `"ancestor"`, or `"all"`. With `"ancestor"` or `"all"`, the extension also resolves its ancestor's tokens, and the subscriber is told of those whose values change. `Library.SubscribeOptions` and `Library.Change` are exported.
|
|
15
|
+
- `Subscriber.onError(error)`, optional, which is given each error that a token of a subscribed library throws as the library resolves it on its own: as it's subscribed, or after a change. The error is a `TokenResolutionError`, exported, with the `tokenName` of the token that threw, a `phase` of `"isEqual"` (its type's `isEqual` threw) or `"resolve"`, and the error thrown as its `cause`. An error is given once in a microtask, after the batch, and the subscriber is still told of later changes. An error that no subscriber with `onError` is told of is thrown from a microtask, so it isn't lost. A custom type's `isEqual` that threw there was lost before. Reading a token still throws the error itself.
|
|
16
|
+
- `types` option of `Library.create()` and `extend()`, which registers each custom type with an `isEqual(previous, next)`. Its arguments are typed by the values of the type's tokens. `Library.TypeOptions`, `Library.Types`, `Library.CreateOptions`, `Library.CustomTypeNamesOf`, `Library.ValueOfType`, `Library.TypesOf`, `Library.CreateArgs` and `Library.ExtendArgs` are exported.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Breaking:** A library with a subscriber resolves its tokens when it's first subscribed, and a `set()` reaches every token that depends on the token set, read or not. When the batch is delivered, a reached token is resolved again only if a token it depends on changed, and a batch has only the tokens whose values changed: a token set to an equal value, set and set back before the batch, or resolved again to an equal value isn't in it. Before, a batch had the token set and the tokens that had been read and depended on it, whether their values changed or not. A library without a subscriber is lazy, as before, and the last `unsubscribe()` makes it lazy again.
|
|
21
|
+
- **Breaking:** A subscribed extension resolves only its own tokens: those it gives a value, those that call a recipe it overrides, directly or in a recipe's result, those whose recipe's result refers to one of its own tokens, and those that depend on them. To find them whatever its source has read, its first `subscribe()` resolves each of the source's tokens that calls a recipe. Its other tokens are its source's values, the same objects, and its subscribers aren't told of a change to them.
|
|
22
|
+
- **Breaking:** `Subscriber.onChange` is called with `Library.Change` entries, `{ token, valueChanged, origin, originChanged }`, instead of tokens. A token of an extension that becomes its own, by a `set()` even to the value it had or by depending on one that does, is reported with `originChanged`, and with `valueChanged` only if its value changed.
|
|
23
|
+
- `subscribe()` and `set()` don't throw when a token throws as it resolves. The token throws when it's read, and a token that starts or stops throwing is in the batch.
|
|
24
|
+
- **Breaking:** Every custom type must be registered in `types`. `create()` and `extend()` throw for a token whose custom type isn't registered, and a config whose shape has a custom type doesn't compile without the registration. Registering a DTCG type, or a custom type that a library being extended registers, throws and doesn't compile. An extension inherits the types of the library it extends.
|
|
25
|
+
- A library finds which tokens depend on which from their configured values, rather than by watching what each token reads as it resolves. Each token's edges are added when it is resolved, so a `set()` invalidates the tokens that were read without walking the library, and `dependentsOf()` completes the graph once and keeps it up to date as tokens are set. An extension shares the graph of the library it extends and adds only its own tokens', so `dependentsOf()` on one of its tokens makes only the tokens it lists, not every token. A change to a token of a source reaches its extensions through their libraries, once each, rather than through a link on each of their tokens, so `subscribe()` on an extension no longer costs a link per token, and an extension that is read holds about half the memory.
|
|
26
|
+
- What a subscriber of an extension is told of follows the extension's own tokens. A `set()` on a source's token that the extension has a value of its own for no longer tells it of the extension's tokens that depend on it, whose values don't change, and which of its tokens it is told of no longer depends on which tokens of the source have been read.
|
|
27
|
+
- `dependentsOf()` no longer throws when another token of the library has a ref to a token it doesn't have. Reading that token's `$value` still does.
|
|
28
|
+
- **Breaking:** Reading a token's `$value` in a recipe's function or a getter in a value, such as a token of a library it closes over, throws. Such a read isn't followed, so the value that read it wouldn't change with the token. The error names the token being resolved, the token it read and the recipe, and says to pass the token as a ref. A ref that a recipe's function returns is still followed.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Reading a token of an extension no longer changes what its source token depends on (#19). The test of it, which was skipped, runs.
|
|
33
|
+
|
|
34
|
+
## [0.3.1] - 2026-11-04
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- The published typings (`types` / `exports.types`) are `dist/lib/index.d.ts` again, as in 0.2.0. In 0.3.0 they were the API Extractor rollup `dist/lib/public.d.ts`, trimmed to what is tagged `@public`, which left out the `@internal` types that public types are written in terms of (`DesignToken.Shape`, `ValueByToken`, the `REF` key of a ref). Their uses didn't resolve, so `refs<T>()` of a group had no members, any object was a `Ref`, and `Library.create`, which the rollup hides, was missing.
|
|
39
|
+
|
|
8
40
|
## [0.3.0] - 2026-11-03
|
|
9
41
|
|
|
10
42
|
### Added
|
|
11
43
|
|
|
44
|
+
- `toCSS(library, { filter })` writes only the tokens `filter` accepts. A token it leaves out isn't converted, so its value isn't read and its type needs no converter. A tool that knows which tokens a `set()` changed, with `dependentsOf()`, writes the CSS of those, for an extension that changes a few of the tokens it extends.
|
|
12
45
|
- `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
46
|
- `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
47
|
- `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
48
|
- `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
49
|
- 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.
|
|
50
|
+
- `parse(document, { types })` reads a tokens document, as JSON text or parsed, and returns the config it describes, to give to `Library.create`. It reads the [DTCG 2025.10](https://www.designtokens.org/tr/2025.10/format/) format and color module: every standard type and its value shapes and ranges, group `$type` inheritance, metadata, `$root`, `$extends`, and `$ref` JSON Pointers. A reference, such as `"{color.blue}"`, becomes a ref, as a whole value or inside a composite value, and is checked to name a token of the type its position needs. A custom type is read when it is registered in `types`, the object that `create()` and `extend()` take, so pass the same one to both, and a reference anywhere in its value is a ref. A document with problems throws a `ParseError` whose `issues` list each problem with its path. `$extends` and `$ref` copy what they name, so a document that expands to more than a million nodes, or is nested deeper than the stack allows, is an error, not an unbounded wait or a `RangeError`. Adds the `ParseError`, `ParseIssue` and `ParseOptions` types.
|
|
51
|
+
- `parse(document, { recipes })` reads a recipe call, an extension of this library for writing tokens in JSON: `"$value": "darken({color.blue}, 0.2)"` is the computed value `Recipes.darken(ref("color.blue"), 0.2)`. A call can be a whole value, a position of a composite value that takes a reference, or anywhere in a custom value. Its arguments are references, JSON values (whose arrays and objects may hold references and calls) and other calls. A string is a call only when it calls one of `recipes`, by the recipe's name, so a string such as `"calc(100% - 4px)"` stays a string. A token with a call needs a `$type`, its own or its group's. Two different recipes with the same name throw.
|
|
52
|
+
- `parse()` reads a document in the DTCG form that keeps what DTCG can't express in `$extensions["design-token-library"]`: a token's own `$type` and `$value`, such as a custom type or a recipe call, and a group's own `$type`. Those are read in place of the DTCG ones, which are still checked, and the extension is removed from the token's `$extensions`. A `$ref` in it is resolved.
|
|
53
|
+
- `parse(document, { extends: library })` reads a document that extends a library, such as a theme, and checks it against the library: a token it restates keeps its type and is checked as it, a group keeps its `$type`, a token can't become a group or a group a token, a reference may name the library's tokens and is checked by their types, and the library's custom types are known. Its config is a `Library.ExtendConfig` of the library, so `library.extend(parse(text, { extends: library }))` is typed. Adds the `ParseExtendOptions` type.
|
|
17
54
|
|
|
18
55
|
### Changed
|
|
19
56
|
|
|
57
|
+
- **Breaking:** the CSS types are named for what they are. `CSSOptions<T>` is `ToCSSOptions<T>`, `CSSPropertiesOptions` (the `name` option both functions share) is `CSSNameOptions`, `PropertiesConverters` (converters by type, as `toProperties()` takes them) is `CSSConverterMap`, and `CSSPropertyValues` (the `var` and `property` of a token) is `CSSCustomProperty`, so it isn't taken for `CSSValues`, which a converter returns. `ConvertersOf` is removed, and `CSSConverters<T>` is made without it.
|
|
20
58
|
- 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
59
|
- **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
60
|
- `package.json` sets `"sideEffects": false` so bundlers can tree-shake unused exports from the package.
|
|
@@ -45,16 +45,10 @@ export type CustomTokensOf<T> = Exclude<Library.TokensOf<T>, {
|
|
|
45
45
|
*
|
|
46
46
|
* @public
|
|
47
47
|
*/
|
|
48
|
-
export type CSSConverters<T> =
|
|
49
|
-
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
export type ConvertersOf<C> = {
|
|
53
|
-
[N in C extends {
|
|
48
|
+
export type CSSConverters<T> = {
|
|
49
|
+
[C in CustomTokensOf<T> as C extends {
|
|
54
50
|
$type: infer N extends string;
|
|
55
|
-
} ? N : never]: C extends
|
|
56
|
-
$type: N;
|
|
57
|
-
} ? C extends DesignToken.Shape ? CSSConverter<DesignToken.ReadonlyValueByToken<C>, C> : never : never;
|
|
51
|
+
} ? N : never]: C extends DesignToken.Shape ? CSSConverter<DesignToken.ReadonlyValueByToken<C>, C> : never;
|
|
58
52
|
};
|
|
59
53
|
/**
|
|
60
54
|
* A converter for any of the standard types, which is used in place of the one
|
|
@@ -77,11 +71,12 @@ export type CSSConverterEntries<T> = {
|
|
|
77
71
|
[N in keyof CSSConverters<T>]: CSSConverters<T>[N] | false;
|
|
78
72
|
};
|
|
79
73
|
/**
|
|
80
|
-
* Options that control how custom properties are named
|
|
74
|
+
* Options that control how custom properties are named, which {@link toCSS}
|
|
75
|
+
* and {@link toProperties} share.
|
|
81
76
|
*
|
|
82
77
|
* @public
|
|
83
78
|
*/
|
|
84
|
-
export interface
|
|
79
|
+
export interface CSSNameOptions {
|
|
85
80
|
/**
|
|
86
81
|
* Derives a token's custom property name, without the leading `--`.
|
|
87
82
|
*
|
|
@@ -93,11 +88,14 @@ export interface CSSPropertiesOptions {
|
|
|
93
88
|
name?(token: Library.Token<any, any>): string;
|
|
94
89
|
}
|
|
95
90
|
/**
|
|
96
|
-
*
|
|
91
|
+
* Converters by token type, as the functions of this module read them at
|
|
92
|
+
* run time: a converter, or `false` for a type that isn't written.
|
|
93
|
+
* {@link ToCSSOptions} checks them against the library; this is the shape
|
|
94
|
+
* that {@link toProperties} takes, to read the keys of what they return.
|
|
97
95
|
*
|
|
98
96
|
* @public
|
|
99
97
|
*/
|
|
100
|
-
export type
|
|
98
|
+
export type CSSConverterMap = {
|
|
101
99
|
readonly [type: string]: ((value: any, token: any) => CSSValue) | false;
|
|
102
100
|
};
|
|
103
101
|
/**
|
|
@@ -105,7 +103,7 @@ export type PropertiesConverters = {
|
|
|
105
103
|
*
|
|
106
104
|
* @public
|
|
107
105
|
*/
|
|
108
|
-
export interface ToPropertiesOptions<C extends
|
|
106
|
+
export interface ToPropertiesOptions<C extends CSSConverterMap = CSSConverterMap> extends CSSNameOptions {
|
|
109
107
|
/**
|
|
110
108
|
* The converters given to {@link toCSS}. A token whose custom type is `false`
|
|
111
109
|
* isn't written by `toCSS`, so it has no custom property and is left out.
|
|
@@ -126,18 +124,28 @@ export interface ToPropertiesOptions<C extends PropertiesConverters = Properties
|
|
|
126
124
|
*
|
|
127
125
|
* @public
|
|
128
126
|
*/
|
|
129
|
-
export type
|
|
127
|
+
export type ToCSSOptions<T> = CSSNameOptions & {
|
|
128
|
+
/**
|
|
129
|
+
* Whether a token is written. A token it returns `false` for isn't
|
|
130
|
+
* converted, so its value isn't read, and its type needs no converter.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* A tool that knows which tokens changed, such as with
|
|
134
|
+
* `dependentsOf()`, writes only those.
|
|
135
|
+
*/
|
|
136
|
+
filter?(token: Library.Token<any, any>): boolean;
|
|
137
|
+
} & ([CustomTokensOf<T>] extends [never] ? {
|
|
130
138
|
converters?: StandardConverters;
|
|
131
139
|
} : {
|
|
132
140
|
converters: CSSConverterEntries<T> & StandardConverters;
|
|
133
141
|
});
|
|
134
142
|
/**
|
|
135
|
-
* The trailing arguments of {@link toCSS}: {@link
|
|
143
|
+
* The trailing arguments of {@link toCSS}: {@link ToCSSOptions} are
|
|
136
144
|
* required when the library contains custom token types.
|
|
137
145
|
*
|
|
138
146
|
* @public
|
|
139
147
|
*/
|
|
140
|
-
export type ToCSSArgs<T> = [CustomTokensOf<T>] extends [never] ? [options?:
|
|
148
|
+
export type ToCSSArgs<T> = [CustomTokensOf<T>] extends [never] ? [options?: ToCSSOptions<T>] : [options: ToCSSOptions<T>];
|
|
141
149
|
/**
|
|
142
150
|
* Convert a library to CSS custom property declarations.
|
|
143
151
|
*
|
|
@@ -152,12 +160,12 @@ export declare function toCSS<T extends {}, R extends {}>(library: Library.Libra
|
|
|
152
160
|
/**
|
|
153
161
|
* @public
|
|
154
162
|
*/
|
|
155
|
-
export interface
|
|
163
|
+
export interface CSSCustomProperty {
|
|
156
164
|
readonly var: `var(--${string})`;
|
|
157
165
|
readonly property: `--${string}`;
|
|
158
166
|
}
|
|
159
167
|
/**
|
|
160
|
-
* The {@link
|
|
168
|
+
* The {@link CSSCustomProperty} of a token of shape `T`, given the
|
|
161
169
|
* converters `C`: one for its property, or one for each key of the
|
|
162
170
|
* {@link CSSValues} its converter returns, where `""` is the token's own.
|
|
163
171
|
*
|
|
@@ -170,11 +178,11 @@ export interface CSSPropertyValues {
|
|
|
170
178
|
*/
|
|
171
179
|
export type CSSPropertiesOf<T, C = {}> = T extends {
|
|
172
180
|
$type: infer N extends keyof C;
|
|
173
|
-
} ? C[N] extends (...args: any[]) => infer V ? V extends string ?
|
|
174
|
-
readonly [P in Exclude<keyof V, "">]:
|
|
175
|
-
} :
|
|
181
|
+
} ? C[N] extends (...args: any[]) => infer V ? V extends string ? CSSCustomProperty : string extends keyof V ? CSSCustomProperty : ("" extends keyof V ? CSSCustomProperty : {}) & {
|
|
182
|
+
readonly [P in Exclude<keyof V, "">]: CSSCustomProperty;
|
|
183
|
+
} : CSSCustomProperty : CSSCustomProperty;
|
|
176
184
|
/**
|
|
177
|
-
* A collection of {@link
|
|
185
|
+
* A collection of {@link CSSCustomProperty} (`var` and `property` per token) that mirrors the
|
|
178
186
|
* structure of the source {@link (Library:namespace).Library}.
|
|
179
187
|
*
|
|
180
188
|
* @remarks
|
|
@@ -216,7 +224,7 @@ export type CSSPropertiesLibrary<T extends {}, C = {}> = {
|
|
|
216
224
|
*
|
|
217
225
|
* @public
|
|
218
226
|
*/
|
|
219
|
-
export declare function toProperties<T extends Library.Library<any>, C extends
|
|
227
|
+
export declare function toProperties<T extends Library.Library<any>, C extends CSSConverterMap = {}>(library: T, options?: ToPropertiesOptions<C>): CSSPropertiesLibrary<T["tokens"], C>;
|
|
220
228
|
/**
|
|
221
229
|
* Converts a value of a standard type to CSS, the way {@link toCSS} does for a
|
|
222
230
|
* token of the type, without a converter for the type in `converters`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DesignToken } from "./design-token.js";
|
|
2
|
-
import {
|
|
2
|
+
import { FONT_WEIGHTS } from "./standard-values.js";
|
|
3
|
+
import { isObject, isToken } from "./utilities.js";
|
|
3
4
|
/**
|
|
4
5
|
* Convert a library to CSS custom property declarations.
|
|
5
6
|
*
|
|
@@ -13,7 +14,7 @@ import { isToken } from "./utilities.js";
|
|
|
13
14
|
export function toCSS(library, ...[options]) {
|
|
14
15
|
// Converters are checked by `ToCSSArgs`; at runtime they're keyed by type.
|
|
15
16
|
const converters = options?.converters ?? {};
|
|
16
|
-
return recurseToCss(library.tokens, converters, options?.name ?? defaultName);
|
|
17
|
+
return recurseToCss(library.tokens, converters, options?.name ?? defaultName, options?.filter);
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* `$` cannot begin a CSS identifier, so a group's `$root` token is named for
|
|
@@ -27,7 +28,7 @@ const defaultName = (token) => token.name.replace(/\.\$root$/, "").replaceAll(".
|
|
|
27
28
|
*/
|
|
28
29
|
const valuesOf = (value) => isValues(value) ? value : { "": String(value) };
|
|
29
30
|
// A converter's result is typed by `CSSConverter`, so an object is a record.
|
|
30
|
-
const isValues = (value) =>
|
|
31
|
+
const isValues = (value) => isObject(value);
|
|
31
32
|
/**
|
|
32
33
|
* The custom property of a token named `name` for a key of its
|
|
33
34
|
* {@link CSSValues}.
|
|
@@ -109,11 +110,14 @@ export function toProperties(library, options = {}) {
|
|
|
109
110
|
return Object.freeze(properties);
|
|
110
111
|
}
|
|
111
112
|
const standardTypes = new Set(Object.values(DesignToken.Type));
|
|
112
|
-
const recurseToCss = (librarySection, customConverters, getName) => {
|
|
113
|
+
const recurseToCss = (librarySection, customConverters, getName, filter) => {
|
|
113
114
|
let result = "";
|
|
114
115
|
for (const key in librarySection) {
|
|
115
116
|
const tokenOrGroup = librarySection[key];
|
|
116
117
|
if (isToken(tokenOrGroup)) {
|
|
118
|
+
if (filter?.(tokenOrGroup) === false) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
117
121
|
const { $type: type, name } = tokenOrGroup;
|
|
118
122
|
let value = tokenOrGroup.$value;
|
|
119
123
|
if (Reflect.has(customConverters, type)) {
|
|
@@ -135,7 +139,7 @@ const recurseToCss = (librarySection, customConverters, getName) => {
|
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
else {
|
|
138
|
-
result += recurseToCss(tokenOrGroup, customConverters, getName);
|
|
142
|
+
result += recurseToCss(tokenOrGroup, customConverters, getName, filter);
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
return result;
|
|
@@ -202,28 +206,8 @@ const fontFamilyQuoter = (value) => {
|
|
|
202
206
|
}
|
|
203
207
|
return value.includes(" ") ? `"${value}"` : value;
|
|
204
208
|
};
|
|
205
|
-
const fontWeights = {
|
|
206
|
-
thin: 100,
|
|
207
|
-
hairline: 100,
|
|
208
|
-
"extra-light": 200,
|
|
209
|
-
"ultra-light": 200,
|
|
210
|
-
light: 300,
|
|
211
|
-
normal: 400,
|
|
212
|
-
regular: 400,
|
|
213
|
-
book: 400,
|
|
214
|
-
medium: 500,
|
|
215
|
-
"semi-bold": 600,
|
|
216
|
-
"demi-bold": 600,
|
|
217
|
-
bold: 700,
|
|
218
|
-
"extra-bold": 800,
|
|
219
|
-
"ultra-bold": 800,
|
|
220
|
-
black: 900,
|
|
221
|
-
heavy: 900,
|
|
222
|
-
"extra-black": 950,
|
|
223
|
-
"ultra-black": 950,
|
|
224
|
-
};
|
|
225
209
|
const fontWeightConverter = (value) => {
|
|
226
|
-
return String(typeof value === "number" ? value :
|
|
210
|
+
return String(typeof value === "number" ? value : FONT_WEIGHTS[value]);
|
|
227
211
|
};
|
|
228
212
|
const gradientReducer = (accumulated, value) => {
|
|
229
213
|
// Round away float artifacts, e.g. 0.07 * 100 is 7.000000000000001.
|
|
@@ -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,CAAC;
|
|
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,YAAY,EAAE,MAAM,sBAAsB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C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe;IAC1C,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,cAAc;IACxC,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,oBAAoB;IACpD,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,kBAAkB;IAChD,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,iBAAiB;IAC9C,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB;IAClD,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB;IAClD,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,iBAAiB;IAC9C,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe;IAC1C,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,oBAAoB;IACpD,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB;IAClD,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB;CACrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DesignToken } from "./design-token.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tells whether two values of a type are equal.
|
|
4
|
+
*/
|
|
5
|
+
export type Equality = (a: unknown, b: unknown) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The equality of each DTCG type. Members are compared by their own types,
|
|
8
|
+
* so a dimension is equal to another of the same number and unit, and a
|
|
9
|
+
* color to another of the same color space, components and alpha.
|
|
10
|
+
*/
|
|
11
|
+
export declare const standardEquality: Readonly<Record<DesignToken.Type, Equality>>;
|
|
12
|
+
/**
|
|
13
|
+
* Tells whether a type name is one of DTCG's, which a custom type can't
|
|
14
|
+
* take.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isStandardType: (name: string) => name is DesignToken.Type;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DesignToken } from "./design-token.js";
|
|
2
|
+
import { isObject } from "./utilities.js";
|
|
3
|
+
const T = DesignToken.Type;
|
|
4
|
+
/**
|
|
5
|
+
* Compares two objects member by member, each with its own equality. An
|
|
6
|
+
* optional member is compared as it is written: one that's missing is equal
|
|
7
|
+
* only to one that's missing.
|
|
8
|
+
*/
|
|
9
|
+
const members = (required, optional = {}) => (a, b) => {
|
|
10
|
+
if (!isObject(a) ||
|
|
11
|
+
!isObject(b) ||
|
|
12
|
+
Array.isArray(a) !== Array.isArray(b)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
for (const key in required) {
|
|
16
|
+
if (!required[key](Reflect.get(a, key), Reflect.get(b, key))) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const key in optional) {
|
|
21
|
+
const inA = Object.hasOwn(a, key);
|
|
22
|
+
if (inA !== Object.hasOwn(b, key)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (inA &&
|
|
26
|
+
!optional[key](Reflect.get(a, key), Reflect.get(b, key))) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Compares two arrays element by element, in order.
|
|
34
|
+
*/
|
|
35
|
+
const inOrder = (element) => (a, b) => Array.isArray(a) &&
|
|
36
|
+
Array.isArray(b) &&
|
|
37
|
+
a.length === b.length &&
|
|
38
|
+
a.every((value, i) => element(value, b[i]));
|
|
39
|
+
const same = Object.is;
|
|
40
|
+
/** Two values of either form, each compared by its own equality. */
|
|
41
|
+
const either = (isA, a, b) => (x, y) => isA(x) ? isA(y) && a(x, y) : !isA(y) && b(x, y);
|
|
42
|
+
const measure = members({ value: same, unit: same });
|
|
43
|
+
// The hex of a color is a fallback for its components, so it isn't compared.
|
|
44
|
+
const color = members({ colorSpace: same, components: inOrder(same) }, { alpha: same });
|
|
45
|
+
const strokeStyle = either((value) => typeof value === "string", same, members({ dashArray: inOrder(measure), lineCap: same }));
|
|
46
|
+
const fontFamily = either(Array.isArray, inOrder(same), same);
|
|
47
|
+
const cubicBezier = inOrder(same);
|
|
48
|
+
const shadowLayer = members({
|
|
49
|
+
color,
|
|
50
|
+
offsetX: measure,
|
|
51
|
+
offsetY: measure,
|
|
52
|
+
blur: measure,
|
|
53
|
+
spread: measure,
|
|
54
|
+
}, { inset: same });
|
|
55
|
+
/**
|
|
56
|
+
* The equality of each DTCG type. Members are compared by their own types,
|
|
57
|
+
* so a dimension is equal to another of the same number and unit, and a
|
|
58
|
+
* color to another of the same color space, components and alpha.
|
|
59
|
+
*/
|
|
60
|
+
export const standardEquality = {
|
|
61
|
+
[T.Border]: members({ color, width: measure, style: strokeStyle }),
|
|
62
|
+
[T.Color]: color,
|
|
63
|
+
[T.CubicBezier]: cubicBezier,
|
|
64
|
+
[T.Dimension]: measure,
|
|
65
|
+
[T.Duration]: measure,
|
|
66
|
+
[T.FontFamily]: fontFamily,
|
|
67
|
+
[T.FontWeight]: same,
|
|
68
|
+
[T.Gradient]: inOrder(members({ color, position: same })),
|
|
69
|
+
[T.Number]: same,
|
|
70
|
+
[T.Shadow]: either(Array.isArray, inOrder(shadowLayer), shadowLayer),
|
|
71
|
+
[T.StrokeStyle]: strokeStyle,
|
|
72
|
+
[T.Transition]: members({
|
|
73
|
+
duration: measure,
|
|
74
|
+
delay: measure,
|
|
75
|
+
timingFunction: cubicBezier,
|
|
76
|
+
}),
|
|
77
|
+
[T.Typography]: members({
|
|
78
|
+
fontFamily,
|
|
79
|
+
fontSize: measure,
|
|
80
|
+
fontWeight: same,
|
|
81
|
+
letterSpacing: measure,
|
|
82
|
+
lineHeight: same,
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Tells whether a type name is one of DTCG's, which a custom type can't
|
|
87
|
+
* take.
|
|
88
|
+
*/
|
|
89
|
+
export const isStandardType = (name) => Object.hasOwn(standardEquality, name);
|
|
90
|
+
//# sourceMappingURL=equality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equality.js","sourceRoot":"","sources":["../../src/lib/equality.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC;AAE3B;;;;GAIG;AACH,MAAM,OAAO,GACT,CACI,QAA4C,EAC5C,WAA+C,EAAE,EACzC,EAAE,CACd,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACL,IACI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACZ,CAAC,QAAQ,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EACvC,CAAC;QACC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;YAC3D,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACD,KAAK,MAAM,G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,EAAE,OAAO;IACrB,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU;IAC1B,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI;IACpB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI;IAChB,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACpE,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW;IAC5B,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,OAAO;QACd,cAAc,EAAE,WAAW;KAC9B,CAAC;IACF,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU;QACV,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAI;KACnB,CAAC;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAA4B,EAAE,CACrE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tokens that refer to each token of a library, by name, found in their
|
|
3
|
+
* configured values.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A library made by `create()` has the edges of all of its tokens. A library
|
|
7
|
+
* made by `extend()` has the edges of its own tokens only, those with a value
|
|
8
|
+
* of their own, and takes the rest from its source's graph: a token it
|
|
9
|
+
* inherits has its source token's configured value, and the refs in it are
|
|
10
|
+
* paths, which it resolves in its own library. So an extension costs the
|
|
11
|
+
* tokens it gives a value, and a set of its source's token changes the
|
|
12
|
+
* extension's graph too.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare class Graph {
|
|
17
|
+
private readonly parent;
|
|
18
|
+
private readonly isOwn;
|
|
19
|
+
private readonly edges;
|
|
20
|
+
/**
|
|
21
|
+
* The tokens whose edges the graph has, with the tokens they refer to:
|
|
22
|
+
* the same edges as `edges`, from the other end.
|
|
23
|
+
*/
|
|
24
|
+
private readonly dependencies;
|
|
25
|
+
private changes;
|
|
26
|
+
/**
|
|
27
|
+
* @param parent - The graph of the library this one extends.
|
|
28
|
+
* @param isOwn - Whether a token has a value of its own, so its edges are
|
|
29
|
+
* this graph's rather than the parent's.
|
|
30
|
+
*/
|
|
31
|
+
constructor(parent: Graph | null, isOwn: (name: string) => boolean);
|
|
32
|
+
/**
|
|
33
|
+
* Whether the graph has the edges of `dependent`.
|
|
34
|
+
*/
|
|
35
|
+
has(dependent: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The tokens that `dependent` refers to, if the graph has its edges.
|
|
38
|
+
*/
|
|
39
|
+
dependenciesOf(dependent: string): ReadonlySet<string> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Adds the edges of `dependent` to each of `dependencies`, unless the
|
|
42
|
+
* graph has its edges.
|
|
43
|
+
*/
|
|
44
|
+
add(dependent: string, dependencies: ReadonlySet<string>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Drops the edges of `dependent`, and says whether the graph had them.
|
|
47
|
+
*/
|
|
48
|
+
remove(dependent: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Changes with any edge of this graph or of the graphs it is on, so what
|
|
51
|
+
* is found from it can be kept until it does.
|
|
52
|
+
*/
|
|
53
|
+
get version(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Calls `visit` with each token that refers to `name`, once.
|
|
56
|
+
*/
|
|
57
|
+
dependentsOf(name: string, visit: (dependent: string) => void): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tokens that refer to each token of a library, by name, found in their
|
|
3
|
+
* configured values.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A library made by `create()` has the edges of all of its tokens. A library
|
|
7
|
+
* made by `extend()` has the edges of its own tokens only, those with a value
|
|
8
|
+
* of their own, and takes the rest from its source's graph: a token it
|
|
9
|
+
* inherits has its source token's configured value, and the refs in it are
|
|
10
|
+
* paths, which it resolves in its own library. So an extension costs the
|
|
11
|
+
* tokens it gives a value, and a set of its source's token changes the
|
|
12
|
+
* extension's graph too.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export class Graph {
|
|
17
|
+
parent;
|
|
18
|
+
isOwn;
|
|
19
|
+
edges = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* The tokens whose edges the graph has, with the tokens they refer to:
|
|
22
|
+
* the same edges as `edges`, from the other end.
|
|
23
|
+
*/
|
|
24
|
+
dependencies = new Map();
|
|
25
|
+
changes = 0;
|
|
26
|
+
/**
|
|
27
|
+
* @param parent - The graph of the library this one extends.
|
|
28
|
+
* @param isOwn - Whether a token has a value of its own, so its edges are
|
|
29
|
+
* this graph's rather than the parent's.
|
|
30
|
+
*/
|
|
31
|
+
constructor(parent, isOwn) {
|
|
32
|
+
this.parent = parent;
|
|
33
|
+
this.isOwn = isOwn;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether the graph has the edges of `dependent`.
|
|
37
|
+
*/
|
|
38
|
+
has(dependent) {
|
|
39
|
+
return this.dependencies.has(dependent);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The tokens that `dependent` refers to, if the graph has its edges.
|
|
43
|
+
*/
|
|
44
|
+
dependenciesOf(dependent) {
|
|
45
|
+
return this.dependencies.get(dependent);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adds the edges of `dependent` to each of `dependencies`, unless the
|
|
49
|
+
* graph has its edges.
|
|
50
|
+
*/
|
|
51
|
+
add(dependent, dependencies) {
|
|
52
|
+
if (this.dependencies.has(dependent)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.changes++;
|
|
56
|
+
this.dependencies.set(dependent, dependencies);
|
|
57
|
+
for (const dependency of dependencies) {
|
|
58
|
+
let dependents = this.edges.get(dependency);
|
|
59
|
+
if (dependents === undefined) {
|
|
60
|
+
dependents = new Set();
|
|
61
|
+
this.edges.set(dependency, dependents);
|
|
62
|
+
}
|
|
63
|
+
dependents.add(dependent);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Drops the edges of `dependent`, and says whether the graph had them.
|
|
68
|
+
*/
|
|
69
|
+
remove(dependent) {
|
|
70
|
+
const dependencies = this.dependencies.get(dependent);
|
|
71
|
+
if (dependencies === undefined) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
this.changes++;
|
|
75
|
+
this.dependencies.delete(dependent);
|
|
76
|
+
for (const dependency of dependencies) {
|
|
77
|
+
const dependents = this.edges.get(dependency);
|
|
78
|
+
dependents?.delete(dependent);
|
|
79
|
+
if (dependents?.size === 0) {
|
|
80
|
+
this.edges.delete(dependency);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Changes with any edge of this graph or of the graphs it is on, so what
|
|
87
|
+
* is found from it can be kept until it does.
|
|
88
|
+
*/
|
|
89
|
+
get version() {
|
|
90
|
+
return this.changes + (this.parent?.version ?? 0);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Calls `visit` with each token that refers to `name`, once.
|
|
94
|
+
*/
|
|
95
|
+
dependentsOf(name, visit) {
|
|
96
|
+
this.parent?.dependentsOf(name, (dependent) => {
|
|
97
|
+
if (!this.isOwn(dependent)) {
|
|
98
|
+
visit(dependent);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.edges.get(name)?.forEach((dependent) => visit(dependent));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/lib/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,KAAK;IAeO;IACA;IAfJ,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IACxD;;;OAGG;IACc,YAAY,GAAG,IAAI,GAAG,EAA+B,CAAC;IAC/D,OAAO,GAAG,CAAC,CAAC;IAEpB;;;;OAIG;IACH,YACqB,MAAoB,EACpB,KAAgC;QADhC,WAAM,GAAN,MAAM,CAAc;QACpB,UAAK,GAAL,KAAK,CAA2B;IAClD,CAAC;IAEJ;;OAEG;IACI,GAAG,CAAC,SAAiB;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,SAAiB;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,SAAiB,EAAE,YAAiC;QAC3D,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAC/C,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;YACpC,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC3B,UAAU,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H,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACnE,CAAC;CACJ"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { DesignToken } from "./design-token.js";
|
|
2
|
-
export { CircularReferenceError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, } from "./library.js";
|
|
2
|
+
export { CircularReferenceError, TokenResolutionError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, ownTokensOf, } from "./library.js";
|
|
3
3
|
export { isComputed, override, recipes } from "./recipe.js";
|
|
4
|
+
export { parse, ParseError } from "./parse.js";
|
|
5
|
+
export type { ParseExtendOptions, ParseIssue, ParseOptions } from "./parse.js";
|
|
4
6
|
export { isRef, pathOf, ref, refs } from "./ref.js";
|
|
5
|
-
export { convert, toCSS, toProperties, type CSSConverter, type CSSPropertiesOf, type CSSValue, type CSSValues, type
|
|
7
|
+
export { convert, toCSS, toProperties, type CSSConverter, type CSSPropertiesOf, type CSSValue, type CSSValues, type CSSConverterMap, type CSSConverterEntries, type CSSConverters, type ToCSSOptions, type CSSPropertiesLibrary, type CSSCustomProperty, type CSSNameOptions, type CustomTokensOf, type StandardConverters, type ToCSSArgs, type ToPropertiesOptions, } from "./css-reflector.js";
|
|
6
8
|
export { hex, ms, px, rem, s } from "./values.js";
|
package/dist/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { DesignToken } from "./design-token.js";
|
|
2
|
-
export { CircularReferenceError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, } from "./library.js";
|
|
2
|
+
export { CircularReferenceError, TokenResolutionError, Library, configuredValueOf, entriesOf, dependenciesOf, dependentsOf, ownTokensOf, } from "./library.js";
|
|
3
3
|
export { isComputed, override, recipes } from "./recipe.js";
|
|
4
|
+
export { parse, ParseError } from "./parse.js";
|
|
4
5
|
export { isRef, pathOf, ref, refs } from "./ref.js";
|
|
5
6
|
export { convert, toCSS, toProperties, } from "./css-reflector.js";
|
|
6
7
|
export { hex, ms, px, rem, s } from "./values.js";
|