@lynstack/recipe 1.8.1 → 1.9.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 +114 -161
- package/dist/index.d.ts +48 -33
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,204 +4,157 @@ All notable changes to `@lynstack/recipe`. Each version is published on
|
|
|
4
4
|
npm and as a [GitHub release](https://github.com/lynstack/recipe/releases)
|
|
5
5
|
tagged `recipe@<version>`.
|
|
6
6
|
|
|
7
|
+
## 1.9.0 — 2026-10-09
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `InheritedSlot` and `InheritedDefaultedName`: the slots and the
|
|
12
|
+
defaulted variants that a recipe inherits from the recipes it composes,
|
|
13
|
+
for libraries that wrap composable recipes.
|
|
14
|
+
- `UnknownSlot`, the type that errors show for a slot a recipe does not
|
|
15
|
+
declare.
|
|
16
|
+
|
|
7
17
|
## 1.8.1 — 2026-10-09
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
options' values, and so do the declarations of exported recipes.
|
|
19
|
-
- A slot that an option of a slot recipe's variants names without
|
|
20
|
-
declaring it is an error that names it and the recipe's slots, as
|
|
21
|
-
`UnknownSlot<"lable", "label" | "root">`. Before, the error said
|
|
22
|
-
"not assignable to type 'never'", and also marked the other slots of
|
|
23
|
-
the option.
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Editors complete the variant names in `defaultVariants`, and the slot
|
|
22
|
+
names in the options of a slot recipe.
|
|
23
|
+
- Editors, errors, and declarations show the values a variant accepts by
|
|
24
|
+
name, such as `"sm" | "md"`, instead of `VariantOption<…>`.
|
|
25
|
+
- A slot that an option names without declaring it is reported as
|
|
26
|
+
`UnknownSlot<"lable", "label" | "root">`, not as "not assignable to type
|
|
27
|
+
'never'" on every slot of the option.
|
|
24
28
|
|
|
25
29
|
## 1.8.0 — 2026-10-08
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
about a default or a compound variant that names a variant or an option
|
|
39
|
-
that no config of the recipe declares, and, in a slot recipe, about a
|
|
40
|
-
value for a slot that no config lists in `slots`. The recipe ignores
|
|
41
|
-
such names, as before; TypeScript does not report every one in a config
|
|
42
|
-
declared before the call, as `isolatedDeclarations` requires.
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Creating a recipe warns once, with `console.warn`, about a default, a
|
|
34
|
+
compound variant, or a slot that names something no config declares,
|
|
35
|
+
which TypeScript misses in a config declared before the call.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- A function generic over the slot recipe it composes can name its own
|
|
40
|
+
slots, and declarations print the slots of `base` and of compound
|
|
41
|
+
variants by name.
|
|
43
42
|
|
|
44
43
|
## 1.7.0 — 2026-10-08
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
the names of its defaults were a type parameter.
|
|
61
|
-
- The declaration of a slot recipe that composes others lists the names
|
|
62
|
-
of its slots, instead of the types of the slot recipes it composes, so
|
|
63
|
-
that it grows linearly with the level of composition. Before, it grew
|
|
64
|
-
about 2.4 times with each level.
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- `KindRecipeOf` and `KindSlotRecipeOf`, the types of the recipe of a
|
|
48
|
+
config declared `as const`, to annotate exported recipes under
|
|
49
|
+
`isolatedDeclarations`.
|
|
50
|
+
- `KindSelection`, so that a function generic over a config can return
|
|
51
|
+
`KindRecipe<KindSelection<Variants, DefaultedName>, Result>`.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- A function generic over a config can return its recipe again, which
|
|
56
|
+
failed since 1.3.0 while the names of its defaults were generic.
|
|
57
|
+
- The declaration of a composed slot recipe grows linearly with each level
|
|
58
|
+
of composition, not about 2.4 times.
|
|
65
59
|
|
|
66
60
|
## 1.6.0 — 2026-10-07
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
runs once, when the recipe is created.
|
|
81
|
-
- `NoUnknownSlots` is exported: a library intersects the variants of its
|
|
82
|
-
slot recipes' configs with it, as the engine's own config does, so that
|
|
83
|
-
a value for a slot that `slots` does not name is a type error.
|
|
62
|
+
### Added
|
|
63
|
+
|
|
64
|
+
- Creating a recipe checks the shape of its config and throws a
|
|
65
|
+
`TypeError` that names the part to fix, such as a missing `variants` or
|
|
66
|
+
a compound variant without `variants`.
|
|
67
|
+
- `NoUnknownSlots`, so that a library's slot recipe configs reject a slot
|
|
68
|
+
that `slots` does not name.
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
|
|
72
|
+
- A compound variant without `variants` no longer matches every
|
|
73
|
+
selection; it throws.
|
|
84
74
|
|
|
85
75
|
## 1.5.0 — 2026-10-07
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
in the order of the config.
|
|
96
|
-
- Every recipe and slot recipe has `defaultVariants`, the option each
|
|
97
|
-
variant uses when a selection leaves it out, as a string: its default,
|
|
98
|
-
or `"false"` for a variant whose only options are `"true"` and
|
|
99
|
-
`"false"`. A variant without a default is not in it.
|
|
100
|
-
- Both are frozen, keyed in the order of `variantKeys`, and typed with
|
|
101
|
-
the names of the options of each variant. A recipe that composes others
|
|
102
|
-
lists the variants, options, and defaults of the one config it stands
|
|
103
|
-
for.
|
|
104
|
-
- `KindRecipe` has the two properties, so a type that implements it by
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- `variantOptions` and `defaultVariants` on every recipe: the options of
|
|
80
|
+
each variant and the default each uses, as frozen, typed lists of names.
|
|
81
|
+
|
|
82
|
+
### Changed
|
|
83
|
+
|
|
84
|
+
- `KindRecipe` has these two properties, so a type that implements it by
|
|
105
85
|
hand needs them too.
|
|
106
86
|
|
|
107
87
|
## 1.4.0 — 2026-10-07
|
|
108
88
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
`first` then `second` gives what reducing `combine(first, second)`
|
|
122
|
-
gives, and `initial(base)` gives what reducing `base` into
|
|
123
|
-
`initial(undefined)` gives.
|
|
124
|
-
- Without `combine`, a composed recipe returns what it returned before.
|
|
125
|
-
When no option or compound variant has values from several configs, it
|
|
126
|
-
now compiles as one config too, and builds its results as fast.
|
|
127
|
-
- 1.3.0 said that a composed recipe is as fast as its one config. That
|
|
128
|
-
holds for cached calls; a result built without the cache cost more when
|
|
129
|
-
several configs gave values to one option or had a base. With
|
|
130
|
-
`combine`, it costs what the one config costs.
|
|
89
|
+
### Added
|
|
90
|
+
|
|
91
|
+
- `combine(first, second)` on a recipe kind, optional: a recipe that
|
|
92
|
+
composes others merges the values of its configs into one when it is
|
|
93
|
+
created, so that it builds its results as fast as one config.
|
|
94
|
+
`combine` must not change its arguments, and must give what reducing
|
|
95
|
+
`first` then `second` gives.
|
|
96
|
+
|
|
97
|
+
### Changed
|
|
98
|
+
|
|
99
|
+
- A composed recipe without overlapping values compiles as one config,
|
|
100
|
+
with or without `combine`.
|
|
131
101
|
|
|
132
102
|
## 1.3.0 — 2026-10-07
|
|
133
103
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
the order of the recipes, their compound variants first, and the last
|
|
140
|
-
default given for each variant. A slot recipe has the slots of the slot
|
|
141
|
-
recipes it composes, theirs first. A recipe composed several times
|
|
142
|
-
counts once.
|
|
143
|
-
- A recipe composes recipes of any kind whose values have the type of its
|
|
144
|
-
own. Composing anything else, or a slot recipe in a recipe, is a type
|
|
145
|
-
error and throws a `TypeError` when the recipe is created.
|
|
146
|
-
- The configs are merged when the recipe is created: a composed recipe is
|
|
147
|
-
as fast as the one config it stands for.
|
|
148
|
-
- A recipe's type carries what it passes on to the recipes that compose
|
|
149
|
-
it, under a `~composition` property that exists in the type only.
|
|
150
|
-
`KindRecipe` takes it as a third, optional type parameter.
|
|
151
|
-
- New types for libraries built on the engine: `RecipeComposition`,
|
|
104
|
+
### Added
|
|
105
|
+
|
|
106
|
+
- `composes`: a recipe or slot recipe builds on other recipes of any kind
|
|
107
|
+
whose values have its type, as if their configs and its own were one.
|
|
108
|
+
- Types for libraries built on the engine: `RecipeComposition`,
|
|
152
109
|
`Composable`, `ComposableKindRecipe`, `ComposableKindSlotRecipe`,
|
|
153
110
|
`ComposedVariants`, `ComposedDefaultedName`, and `ComposedSlot`.
|
|
154
111
|
|
|
112
|
+
### Changed
|
|
113
|
+
|
|
114
|
+
- `KindRecipe` takes an optional third type parameter, what the recipe
|
|
115
|
+
passes on to the recipes that compose it.
|
|
116
|
+
|
|
155
117
|
## 1.2.0 — 2026-10-06
|
|
156
118
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
-
|
|
165
|
-
types, and an ES2022 runtime.
|
|
119
|
+
### Added
|
|
120
|
+
|
|
121
|
+
- `cache` in a recipe's config, which overrides the kind's, to turn off
|
|
122
|
+
the cache of a recipe whose variants come from untrusted input.
|
|
123
|
+
|
|
124
|
+
### Fixed
|
|
125
|
+
|
|
126
|
+
- A slot recipe keeps a slot named `__proto__` in its result.
|
|
166
127
|
|
|
167
128
|
## 1.1.2 — 2026-10-05
|
|
168
129
|
|
|
169
|
-
|
|
130
|
+
### Fixed
|
|
170
131
|
|
|
171
|
-
- `package.json` declares `main
|
|
172
|
-
|
|
132
|
+
- `package.json` declares `main`, for bundlers that ignore `exports`, such
|
|
133
|
+
as the one of Expo Snack.
|
|
173
134
|
|
|
174
135
|
## 1.1.1 — 2026-10-05
|
|
175
136
|
|
|
176
|
-
|
|
177
|
-
|
|
137
|
+
### Fixed
|
|
138
|
+
|
|
139
|
+
- A recipe whose kind returns `undefined` caches that result.
|
|
178
140
|
|
|
179
141
|
## 1.1.0 — 2026-10-05
|
|
180
142
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
slot's result, cached for each declared selection.
|
|
189
|
-
- New types for slot recipes: `CreateKindSlotRecipe`,
|
|
190
|
-
`KindSlotRecipeConfig`, `KindSlotVariants`, `KindSlotCompoundVariant`,
|
|
191
|
-
and `SlotValues`.
|
|
192
|
-
- `VariantsOf` returns the variants a recipe accepts, to type the props of
|
|
193
|
-
a component built on it, and `VariantKey` names the variants of a
|
|
194
|
-
selection.
|
|
143
|
+
### Added
|
|
144
|
+
|
|
145
|
+
- `createSlotRecipeKind`, which creates slot recipes: a selection maps to
|
|
146
|
+
the result of each of several slots.
|
|
147
|
+
- Types for slot recipes: `CreateKindSlotRecipe`, `KindSlotRecipeConfig`,
|
|
148
|
+
`KindSlotVariants`, `KindSlotCompoundVariant`, and `SlotValues`.
|
|
149
|
+
- `VariantsOf`, the variants a recipe accepts, and `VariantKey`.
|
|
195
150
|
|
|
196
151
|
## 1.0.0 — 2026-10-04
|
|
197
152
|
|
|
198
|
-
|
|
199
|
-
|
|
153
|
+
First release.
|
|
154
|
+
|
|
155
|
+
### Added
|
|
200
156
|
|
|
201
|
-
- `createRecipeKind
|
|
202
|
-
such as class names or style objects
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
boolean variants, list their variants in `variantKeys`, and cache the
|
|
206
|
-
result of each declared selection.
|
|
207
|
-
- No dependencies; ES modules only.
|
|
157
|
+
- `createRecipeKind`, which defines a kind of recipe by how it reduces
|
|
158
|
+
values, such as class names or style objects.
|
|
159
|
+
- Variants, compound variants, default variants, boolean variants,
|
|
160
|
+
`variantKeys`, and a cache for each declared selection.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,7 @@ type BooleanVariantName<Variants> = { [Name in keyof Variants]: [OptionName<Vari
|
|
|
13
13
|
* The values accepted for one variant: the names of its options, as
|
|
14
14
|
* strings or, for numeric names, as numbers, plus `true`, `false`, `"true"`,
|
|
15
15
|
* and `"false"` when it declares an option named `"true"` or `"false"`.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* Written as a conditional type so that editors and errors show the names,
|
|
19
|
-
* such as `"sm" | "md"`, rather than the options they come from.
|
|
16
|
+
* Editors and errors show them by name, such as `"sm" | "md"`.
|
|
20
17
|
*
|
|
21
18
|
* @typeParam Options - The options of the variant, keyed by option name.
|
|
22
19
|
*/
|
|
@@ -172,8 +169,12 @@ interface RecipeKind<Value, Accumulator, Result> {
|
|
|
172
169
|
*/
|
|
173
170
|
type NoUnknownSlots<Variants, Slot extends string> = NoUnknownComposedSlots<Variants, Slot, never>;
|
|
174
171
|
/**
|
|
175
|
-
* The type
|
|
176
|
-
* `Slot
|
|
172
|
+
* The type that {@link NoUnknownSlots} gives a key of an option that is not
|
|
173
|
+
* one of the slots `Slot`. No value is assignable to it, so the error names
|
|
174
|
+
* both the key and the slots, as `UnknownSlot<"lable", "label" | "root">`.
|
|
175
|
+
*
|
|
176
|
+
* @typeParam Name - The key that names no slot.
|
|
177
|
+
* @typeParam Slot - The names of the slots.
|
|
177
178
|
*/
|
|
178
179
|
interface UnknownSlot<Name, Slot extends string> {
|
|
179
180
|
readonly "~unknownSlot": Name;
|
|
@@ -181,8 +182,9 @@ interface UnknownSlot<Name, Slot extends string> {
|
|
|
181
182
|
}
|
|
182
183
|
/**
|
|
183
184
|
* Rejects the slots of the variants' options that are neither `Slot` nor
|
|
184
|
-
* `InheritedSlot`.
|
|
185
|
-
* are accepted even when the inherited slots are
|
|
185
|
+
* `InheritedSlot`. The recipe's own slots are checked before the inherited
|
|
186
|
+
* ones, so that they are accepted even when the inherited slots are
|
|
187
|
+
* generic.
|
|
186
188
|
*/
|
|
187
189
|
type NoUnknownComposedSlots<Variants, Slot extends string, InheritedSlot extends string> = { readonly [Name in keyof Variants]: { readonly [Option in keyof Variants[Name]]: string extends keyof Variants[Name][Option] ? unknown : { readonly [Unknown in Exclude<Exclude<keyof Variants[Name][Option], Slot>, InheritedSlot>]?: UnknownSlot<Unknown, Slot | InheritedSlot>; }; }; };
|
|
188
190
|
//#endregion
|
|
@@ -288,9 +290,10 @@ type CreateKindSlotRecipe<Value, Result> = <const Slot extends string, const Var
|
|
|
288
290
|
* in the order of `slots`. With the cache, a slot recipe builds it once for
|
|
289
291
|
* each declared selection and returns the same object for the same
|
|
290
292
|
* variants. The `cache` of a slot recipe's config overrides the kind's.
|
|
291
|
-
* Variants, boolean variants, undeclared options, the
|
|
292
|
-
* undeclared names, and the
|
|
293
|
-
* `defaultVariants` properties are as
|
|
293
|
+
* Variants, boolean variants, undeclared options, the `TypeError` for a
|
|
294
|
+
* config with the wrong shape, the warning about undeclared names, and the
|
|
295
|
+
* `variantKeys`, `variantOptions`, and `defaultVariants` properties are as
|
|
296
|
+
* in {@link createRecipeKind}. It also
|
|
294
297
|
* warns about a value for a slot that no config lists in `slots`, which is
|
|
295
298
|
* ignored.
|
|
296
299
|
*
|
|
@@ -384,16 +387,17 @@ type KindCompoundCondition<Variants> = string extends keyof Variants ? AnySelect
|
|
|
384
387
|
type KindDefaultVariants<Variants, DefaultedName extends keyof Variants> = string extends keyof Variants ? AnySelection : DefaultVariants<Variants, DefaultedName>;
|
|
385
388
|
/**
|
|
386
389
|
* The type of `defaultVariants`: the defaults as written, checked. While an
|
|
387
|
-
* editor completes them, TypeScript has not inferred their names and
|
|
388
|
-
* `never`, which would allow no name
|
|
390
|
+
* editor completes them, TypeScript has not yet inferred their names and
|
|
391
|
+
* takes `never`, which would allow no name, so the type then takes an
|
|
392
|
+
* optional default for each variant.
|
|
389
393
|
*/
|
|
390
394
|
type WrittenKindDefaults<Variants, DefaultedName extends keyof Variants> = [DefaultedName] extends [never] ? { readonly [Name in keyof Variants]?: VariantOption<NoInfer<Variants>[Name]>; } : KindDefaultVariants<Variants, DefaultedName>;
|
|
391
395
|
/**
|
|
392
396
|
* The check of the variants of a slot recipe: it rejects the slots that are
|
|
393
397
|
* neither `Slot` nor `InheritedSlot`, and lists every slot in each option,
|
|
394
|
-
* so that an editor completes their names and values. It leaves out
|
|
395
|
-
*
|
|
396
|
-
* option that does not give
|
|
398
|
+
* so that an editor completes their names and values. It leaves out a slot
|
|
399
|
+
* named after a property that every object has, such as `toString`: an
|
|
400
|
+
* option that does not give it would still have it, with another type.
|
|
397
401
|
*/
|
|
398
402
|
type SlotVariantsCheck<Variants, Slot extends string, InheritedSlot extends string, Value> = NoUnknownComposedSlots<Variants, Slot, InheritedSlot> & { readonly [Name in keyof Variants]: { readonly [Option in keyof Variants[Name]]: string extends keyof Variants[Name][Option] ? unknown : SlotValues<Exclude<Slot | InheritedSlot, keyof typeof Object.prototype>, Value>; }; };
|
|
399
403
|
//#endregion
|
|
@@ -461,9 +465,13 @@ type ComposedDefaultedName<Composed extends readonly unknown[], DefaultedName> =
|
|
|
461
465
|
/**
|
|
462
466
|
* The names of the variants that the recipes of `Composed` give a default,
|
|
463
467
|
* among the variants of a recipe that composes them with its own
|
|
464
|
-
* `Variants`.
|
|
465
|
-
*
|
|
466
|
-
* generic
|
|
468
|
+
* `Variants`. A library adds them to the recipe's own `DefaultedName`,
|
|
469
|
+
* rather than passing that to {@link ComposedDefaultedName}, so that a
|
|
470
|
+
* function generic over a config can return the recipe, and a recipe that
|
|
471
|
+
* composes nothing has exactly its own defaulted names.
|
|
472
|
+
*
|
|
473
|
+
* @typeParam Composed - The types of the recipes composed.
|
|
474
|
+
* @typeParam Variants - The variant definitions of the recipe's own config.
|
|
467
475
|
*/
|
|
468
476
|
type InheritedDefaultedName<Composed extends readonly unknown[], Variants> = Extract<ComposedPart<Composed, "defaultedName">, keyof ComposedVariants<Composed, Variants>>;
|
|
469
477
|
/**
|
|
@@ -475,9 +483,12 @@ type InheritedDefaultedName<Composed extends readonly unknown[], Variants> = Ext
|
|
|
475
483
|
*/
|
|
476
484
|
type ComposedSlot<Composed extends readonly unknown[], Slot extends string> = Slot | SlotOf<ComposedPart<Composed, "slots">>;
|
|
477
485
|
/**
|
|
478
|
-
* The slots of the slot recipes of `Composed
|
|
479
|
-
*
|
|
480
|
-
*
|
|
486
|
+
* The slots of the slot recipes of `Composed`. Unlike
|
|
487
|
+
* {@link ComposedSlot}, TypeScript relates a config to them while
|
|
488
|
+
* `Composed` is generic, so a library types the slots of a config's `base`
|
|
489
|
+
* and compound variants as `Slot | InheritedSlot<Composed>`.
|
|
490
|
+
*
|
|
491
|
+
* @typeParam Composed - The types of the slot recipes composed.
|
|
481
492
|
*/
|
|
482
493
|
type InheritedSlot<Composed extends readonly ComposableKindSlotRecipe<unknown>[]> = NonNullable<Composed[number]["~composition"]>["slots"][number];
|
|
483
494
|
type SlotOf<Slots> = Slots extends readonly (infer Slot extends string)[] ? Slot : never;
|
|
@@ -628,10 +639,13 @@ type CreateKindRecipe<Value, Result> = <const Variants extends KindVariants<Valu
|
|
|
628
639
|
* each, and `defaultVariants` the option each uses when a selection leaves
|
|
629
640
|
* it out, so that a library can list every selection of a recipe.
|
|
630
641
|
*
|
|
631
|
-
* Creating a recipe
|
|
642
|
+
* Creating a recipe from a config with the wrong shape, such as one without
|
|
643
|
+
* `variants`, throws a `TypeError` that names what is wrong. Creating a
|
|
644
|
+
* recipe also warns once, with `console.warn`, about a default or a
|
|
632
645
|
* compound variant's condition that names a variant or an option that no
|
|
633
|
-
* config of the recipe declares. Such a default is ignored
|
|
634
|
-
*
|
|
646
|
+
* config of the recipe declares. Such a default is ignored. A condition on
|
|
647
|
+
* such a variant never matches, and such an option in a condition's list
|
|
648
|
+
* of options is ignored.
|
|
635
649
|
*
|
|
636
650
|
* With the cache, a recipe builds the result of each declared selection
|
|
637
651
|
* once, and calling it again with the same variants returns the same
|
|
@@ -735,9 +749,10 @@ interface KindRecipeConfigParts<Value> {
|
|
|
735
749
|
* `isolatedDeclarations`, which cannot infer the type of a call. A config
|
|
736
750
|
* that lists `composes` is rejected, so that the type cannot leave out the
|
|
737
751
|
* recipes it composes.
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
752
|
+
*
|
|
753
|
+
* It needs a config whose type is known. In a function generic over the
|
|
754
|
+
* whole config, the recipe's creator cannot infer the variants, so make
|
|
755
|
+
* such a function generic over the variants instead.
|
|
741
756
|
*
|
|
742
757
|
* @typeParam Value - The value of an option, as in `CreateKindRecipe`.
|
|
743
758
|
* @typeParam Result - What a recipe of the kind returns, as in
|
|
@@ -790,10 +805,10 @@ interface KindSlotRecipeConfigParts<Value> {
|
|
|
790
805
|
* on its own, as with `isolatedDeclarations`, which cannot infer the type
|
|
791
806
|
* of a call. A config that lists `composes` is rejected, so that the type
|
|
792
807
|
* cannot leave out the slot recipes it composes.
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
* instead.
|
|
808
|
+
*
|
|
809
|
+
* It needs a config whose type is known. In a function generic over the
|
|
810
|
+
* whole config, the slot recipe's creator cannot infer the variants, so
|
|
811
|
+
* make such a function generic over the variants instead.
|
|
797
812
|
*
|
|
798
813
|
* @typeParam Value - The value of a slot, as in `CreateKindSlotRecipe`.
|
|
799
814
|
* @typeParam Result - What a slot recipe of the kind returns for each
|
|
@@ -831,5 +846,5 @@ interface KindSlotRecipeConfigParts<Value> {
|
|
|
831
846
|
*/
|
|
832
847
|
type KindSlotRecipeOf<Value, Result, Config extends KindSlotRecipeConfigParts<Value>, Composed extends readonly ComposableKindSlotRecipe<Value>[] = readonly []> = ComposedKindRecipe<ComposedVariants<Composed, Config["variants"]>, DefaultedNameOf<Config, Composed> | InheritedDefaultedName<Composed, Config["variants"]>, Value, Readonly<Record<Config["slots"][number] | Exclude<Composed[number]["~composition"], undefined>["slots"][number], Result>>, readonly (Config["slots"][number] | Exclude<Composed[number]["~composition"], undefined>["slots"][number])[]>;
|
|
833
848
|
//#endregion
|
|
834
|
-
export { type Composable, type ComposableKindRecipe, type ComposableKindSlotRecipe, type ComposedDefaultedName, type ComposedSlot, type ComposedVariants, type CompoundCondition, type CreateKindRecipe, type CreateKindSlotRecipe, type DefaultVariants, type KindCompoundVariant, type KindRecipe, type KindRecipeConfig, type KindRecipeOf, type KindSelection, type KindSlotCompoundVariant, type KindSlotRecipeConfig, type KindSlotRecipeOf, type KindSlotVariants, type KindVariants, type NoUnknownSlots, type RecipeComposition, type RecipeFunction, type RecipeKind, type SlotValues, type VariantKey, type VariantOption, type VariantSelection, type VariantsOf, createRecipeKind, createSlotRecipeKind };
|
|
849
|
+
export { type Composable, type ComposableKindRecipe, type ComposableKindSlotRecipe, type ComposedDefaultedName, type ComposedSlot, type ComposedVariants, type CompoundCondition, type CreateKindRecipe, type CreateKindSlotRecipe, type DefaultVariants, type InheritedDefaultedName, type InheritedSlot, type KindCompoundVariant, type KindRecipe, type KindRecipeConfig, type KindRecipeOf, type KindSelection, type KindSlotCompoundVariant, type KindSlotRecipeConfig, type KindSlotRecipeOf, type KindSlotVariants, type KindVariants, type NoUnknownSlots, type RecipeComposition, type RecipeFunction, type RecipeKind, type SlotValues, type UnknownSlot, type VariantKey, type VariantOption, type VariantSelection, type VariantsOf, createRecipeKind, createSlotRecipeKind };
|
|
835
850
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ const noProps = Object.freeze({});
|
|
|
3
3
|
* Prepares variants for selecting values. A variant that declares an option
|
|
4
4
|
* named `"true"` or `"false"` also declares the other one, with
|
|
5
5
|
* `config.noValue`, and a variant whose only options are those defaults to
|
|
6
|
-
* `"false"`.
|
|
7
|
-
*
|
|
6
|
+
* `"false"`. An undeclared option in a compound variant's list is ignored,
|
|
7
|
+
* and a compound variant that names an undeclared variant, or no declared
|
|
8
|
+
* option of a variant, never matches and is left out.
|
|
8
9
|
*/
|
|
9
10
|
function compileVariants(config) {
|
|
10
11
|
const names = Object.keys(config.variants);
|
|
@@ -48,7 +49,7 @@ function product(numbers) {
|
|
|
48
49
|
return numbers.reduce((result, number) => result * number, 1);
|
|
49
50
|
}
|
|
50
51
|
function withBooleanOptions(valuesByOption, noValue) {
|
|
51
|
-
if (!Object.keys(valuesByOption).some((option) => isBooleanName
|
|
52
|
+
if (!Object.keys(valuesByOption).some((option) => isBooleanName(option))) return valuesByOption;
|
|
52
53
|
return {
|
|
53
54
|
false: noValue,
|
|
54
55
|
true: noValue,
|
|
@@ -69,7 +70,7 @@ function compileCondition(indexByOption, variant, value) {
|
|
|
69
70
|
return [variant, toOptionNames(value).map((option) => indexes?.get(option)).filter((index) => index !== void 0)];
|
|
70
71
|
}
|
|
71
72
|
function isBooleanVariant(indexByOption) {
|
|
72
|
-
return indexByOption !== void 0 && indexByOption.size > 0 && [...indexByOption.keys()].every((option) => isBooleanName
|
|
73
|
+
return indexByOption !== void 0 && indexByOption.size > 0 && [...indexByOption.keys()].every((option) => isBooleanName(option));
|
|
73
74
|
}
|
|
74
75
|
function toOptionName(value) {
|
|
75
76
|
if (typeof value === "string") return value;
|
|
@@ -104,7 +105,7 @@ function defaultVariantsOf(compiled) {
|
|
|
104
105
|
});
|
|
105
106
|
return Object.fromEntries(entries);
|
|
106
107
|
}
|
|
107
|
-
function isBooleanName
|
|
108
|
+
function isBooleanName(option) {
|
|
108
109
|
return option === "true" || option === "false";
|
|
109
110
|
}
|
|
110
111
|
//#endregion
|
|
@@ -410,9 +411,6 @@ function declaredOptionsOf(layers) {
|
|
|
410
411
|
}
|
|
411
412
|
return optionsByName;
|
|
412
413
|
}
|
|
413
|
-
function isBooleanName(option) {
|
|
414
|
-
return option === "true" || option === "false";
|
|
415
|
-
}
|
|
416
414
|
function unknownDefaults(defaultVariants, declared) {
|
|
417
415
|
return Object.entries(defaultVariants).flatMap(([name, value]) => {
|
|
418
416
|
if (value === void 0) return [];
|
|
@@ -445,7 +443,8 @@ function unknownSlots(own, slots) {
|
|
|
445
443
|
* Returns the names in a recipe's own config that none of its layers
|
|
446
444
|
* declares: a variant or option in its defaults or compound variants, and,
|
|
447
445
|
* for a slot recipe, a slot that a value is given to. Such a default or
|
|
448
|
-
* value is left out,
|
|
446
|
+
* value is left out, an undeclared option in a compound variant's list is
|
|
447
|
+
* ignored, and any other such compound variant never matches. Each layer
|
|
449
448
|
* was checked when its own recipe was created, so only `own` is checked.
|
|
450
449
|
*/
|
|
451
450
|
function unknownNames(own, layers, isSlotRecipe) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isBooleanName","listOf","asResult"],"sources":["../src/variants.ts","../src/reduce-values.ts","../src/compose.ts","../src/build-recipe.ts","../src/check-config.ts","../src/selector.ts","../src/check-names.ts","../src/recipe-kind.ts","../src/slots.ts","../src/slot-recipe-kind.ts"],"sourcesContent":["/**\n * Variant definitions in the loose shape the runtime works with: for each\n * variant name, the value of each of its options.\n */\ntype LooseVariants<Value> = Readonly<\n Record<string, Readonly<Record<string, Value>>>\n>;\n\n/** A selection in the loose shape the runtime works with. */\ntype SelectedVariants = Readonly<Record<string, unknown>>;\n\n/** A compound variant in the loose shape the runtime works with. */\ninterface LooseCompoundVariant<Value> {\n readonly variants: SelectedVariants;\n readonly value: Value;\n}\n\n/** The variant's index and the option indexes that a condition matches. */\ntype CompoundCondition = readonly [number, readonly number[]];\n\n/** A compound variant prepared for matching. */\ninterface Compound<Value> {\n readonly conditions: readonly CompoundCondition[];\n readonly value: Value;\n}\n\n/** What {@link compileVariants} prepares. */\ninterface VariantsConfig<Value> {\n readonly variants: LooseVariants<Value>;\n readonly defaultVariants: SelectedVariants;\n readonly compoundVariants: readonly LooseCompoundVariant<Value>[];\n /**\n * The value of a variant without a selected option, and of a boolean\n * option that the variant does not declare.\n */\n readonly noValue: Value;\n}\n\n/**\n * Variants prepared for selecting values. Each variant numbers its options\n * from 1, and 0 stands for no option, so a selection is a list of option\n * indexes. Read together as the digits of a mixed-radix number, they form\n * the selection's key.\n */\ninterface CompiledVariants<Value> {\n readonly names: readonly string[];\n readonly defaultOptions: readonly (string | undefined)[];\n readonly indexByOption: readonly ReadonlyMap<string, number>[];\n /** The value of each variant's options, by option index. */\n readonly valuesByIndex: readonly (readonly Value[])[];\n readonly strides: readonly number[];\n readonly compounds: readonly Compound<Value>[];\n /** Whether every selection's key is a safe integer. */\n readonly isCacheable: boolean;\n}\n\n/** The option index of a variant without a selected option. */\nconst noOption = 0;\n\n/** The key of a selection with an option that a variant does not declare. */\nconst undeclared = -1;\n\nconst noProps: SelectedVariants = Object.freeze({});\n\n/**\n * Prepares variants for selecting values. A variant that declares an option\n * named `\"true\"` or `\"false\"` also declares the other one, with\n * `config.noValue`, and a variant whose only options are those defaults to\n * `\"false\"`. A compound variant that names an undeclared variant or option,\n * or lists no option for a variant, never matches and is left out.\n */\nfunction compileVariants<Value>(\n config: VariantsConfig<Value>,\n): CompiledVariants<Value> {\n const names = Object.keys(config.variants);\n const optionValues = names.map((name) =>\n withBooleanOptions(config.variants[name] ?? {}, config.noValue),\n );\n const indexByOption: readonly ReadonlyMap<string, number>[] =\n optionValues.map(\n (valuesByOption) =>\n new Map(\n Object.keys(valuesByOption).map((option, index) => [\n option,\n index + 1,\n ]),\n ),\n );\n const radixes = indexByOption.map((indexes) => indexes.size + 1);\n\n return {\n compounds: compileCompounds(config.compoundVariants, names, indexByOption),\n defaultOptions: names.map(\n (name, index) =>\n toOptionName(config.defaultVariants[name]) ??\n (isBooleanVariant(indexByOption[index]) ? \"false\" : undefined),\n ),\n indexByOption,\n isCacheable: product(radixes) <= Number.MAX_SAFE_INTEGER,\n names,\n strides: radixes.map((_radix, index) => product(radixes.slice(0, index))),\n valuesByIndex: valuesByIndexOf(optionValues, config.noValue),\n };\n}\n\n/**\n * Writes the option index of each variant for `selected` into `indexes`\n * and returns the selection's key, or {@link undeclared} when an option is\n * not declared.\n */\nfunction select(\n compiled: CompiledVariants<unknown>,\n selected: SelectedVariants,\n indexes: Int32Array,\n): number {\n let key = 0;\n for (let variant = 0; variant < compiled.names.length; variant += 1) {\n const index = selectIndex(compiled, selected, variant);\n indexes[variant] = index ?? noOption;\n key =\n index === undefined || key === undeclared\n ? undeclared\n : key + index * (compiled.strides[variant] ?? 0);\n }\n return key;\n}\n\nfunction selectIndex(\n compiled: CompiledVariants<unknown>,\n selected: SelectedVariants,\n variant: number,\n): number | undefined {\n const option =\n toOptionName(selected[compiled.names[variant] ?? \"\"]) ??\n compiled.defaultOptions[variant];\n return option === undefined\n ? noOption\n : compiled.indexByOption[variant]?.get(option);\n}\n\nfunction valuesByIndexOf<Value>(\n optionValues: readonly Readonly<Record<string, Value>>[],\n noValue: Value,\n): Value[][] {\n const valuesByIndex: Value[][] = [];\n for (const valuesByOption of optionValues) {\n valuesByIndex.push([noValue, ...Object.values(valuesByOption)]);\n }\n return valuesByIndex;\n}\n\nfunction product(numbers: readonly number[]): number {\n return numbers.reduce((result, number) => result * number, 1);\n}\n\nfunction withBooleanOptions<Value>(\n valuesByOption: Readonly<Record<string, Value>>,\n noValue: Value,\n): Readonly<Record<string, Value>> {\n const optionNames = Object.keys(valuesByOption);\n if (!optionNames.some((option) => isBooleanName(option))) {\n return valuesByOption;\n }\n return { false: noValue, true: noValue, ...valuesByOption };\n}\n\nfunction compileCompounds<Value>(\n compoundVariants: readonly LooseCompoundVariant<Value>[],\n names: readonly string[],\n indexByOption: readonly ReadonlyMap<string, number>[],\n): Compound<Value>[] {\n return compoundVariants.flatMap(({ variants, value }) => {\n const conditions = Object.keys(variants)\n .filter((name) => variants[name] !== undefined)\n .map((name) =>\n compileCondition(indexByOption, names.indexOf(name), variants[name]),\n );\n return conditions.every(([, indexes]) => indexes.length > 0)\n ? [{ conditions, value }]\n : [];\n });\n}\n\nfunction compileCondition(\n indexByOption: readonly ReadonlyMap<string, number>[],\n variant: number,\n value: unknown,\n): CompoundCondition {\n const indexes = indexByOption[variant];\n return [\n variant,\n toOptionNames(value)\n .map((option) => indexes?.get(option))\n .filter((index): index is number => index !== undefined),\n ];\n}\n\nfunction isBooleanVariant(\n indexByOption: ReadonlyMap<string, number> | undefined,\n): boolean {\n return (\n indexByOption !== undefined &&\n indexByOption.size > 0 &&\n [...indexByOption.keys()].every((option) => isBooleanName(option))\n );\n}\n\nfunction toOptionName(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n return typeof value === \"number\" || typeof value === \"boolean\"\n ? String(value)\n : undefined;\n}\n\nfunction toOptionNames(value: unknown): readonly string[] {\n const values: readonly unknown[] = Array.isArray(value) ? value : [value];\n return values\n .map((option) => toOptionName(option))\n .filter((option): option is string => option !== undefined);\n}\n\n/** A recipe function with the names, options, and defaults of its variants. */\ntype WithVariants<Recipe> = Recipe & {\n readonly variantKeys: readonly string[];\n readonly variantOptions: Readonly<Record<string, readonly string[]>>;\n readonly defaultVariants: Readonly<Record<string, string>>;\n};\n\n/**\n * Adds the names of the compiled variants to `recipe` as `variantKeys`,\n * the names of their options as `variantOptions`, and the option each\n * variant uses when a selection leaves it out as `defaultVariants`.\n */\nfunction withVariants<Recipe extends object>(\n recipe: Recipe,\n compiled: CompiledVariants<unknown>,\n): WithVariants<Recipe> {\n return Object.assign(recipe, {\n defaultVariants: Object.freeze(defaultVariantsOf(compiled)),\n variantKeys: Object.freeze([...compiled.names]),\n variantOptions: Object.freeze(variantOptionsOf(compiled)),\n });\n}\n\nfunction variantOptionsOf(\n compiled: CompiledVariants<unknown>,\n): Record<string, readonly string[]> {\n const entries = compiled.names.map((name, index) => {\n const options = compiled.indexByOption[index]?.keys() ?? [];\n return [name, Object.freeze([...options])] as const;\n });\n return Object.fromEntries(entries);\n}\n\nfunction defaultVariantsOf(\n compiled: CompiledVariants<unknown>,\n): Record<string, string> {\n const entries = compiled.names.flatMap((name, index) => {\n const option = compiled.defaultOptions[index];\n return option === undefined ? [] : [[name, option] as const];\n });\n return Object.fromEntries(entries);\n}\n\nfunction isBooleanName(option: string): boolean {\n return option === \"true\" || option === \"false\";\n}\n\nexport {\n compileVariants,\n noOption,\n noProps,\n select,\n toOptionName,\n toOptionNames,\n undeclared,\n withVariants,\n};\nexport type {\n CompiledVariants,\n Compound,\n LooseCompoundVariant,\n LooseVariants,\n SelectedVariants,\n WithVariants,\n};\n","import type { CompiledVariants, Compound } from \"./variants.js\";\nimport { noOption } from \"./variants.js\";\n\n/** Whether every condition of `compound` matches the selected indexes. */\nfunction matches(compound: Compound<unknown>, indexes: Int32Array): boolean {\n for (const [variant, matchingIndexes] of compound.conditions) {\n if (!matchingIndexes.includes(indexes[variant] ?? noOption)) {\n return false;\n }\n }\n return true;\n}\n\n/** Reduces the values of a selection to an accumulator. */\ninterface Reducer<Value, Accumulator> {\n /** Returns the accumulator to start from. */\n readonly initial: () => Accumulator;\n /** Adds a value to the accumulator and returns the accumulator. */\n readonly reduce: (accumulator: Accumulator, value: Value) => Accumulator;\n}\n\n/**\n * Reduces the values that apply to a selection, in order of precedence: the\n * value of each variant's option, then the value of each matching compound\n * variant. A value that is undefined adds nothing.\n */\nfunction reduceValues<Value, Accumulator>(\n compiled: CompiledVariants<Value | undefined>,\n indexes: Int32Array,\n reducer: Reducer<Value, Accumulator>,\n): Accumulator {\n const { reduce } = reducer;\n let accumulator = reducer.initial();\n for (let variant = 0; variant < compiled.valuesByIndex.length; variant += 1) {\n const value =\n compiled.valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n if (value !== undefined) {\n accumulator = reduce(accumulator, value);\n }\n }\n for (const compound of compiled.compounds) {\n if (compound.value !== undefined && matches(compound, indexes)) {\n accumulator = reduce(accumulator, compound.value);\n }\n }\n return accumulator;\n}\n\n/**\n * Reduces the values that apply to a selection, as {@link reduceValues}\n * does, when each option and compound variant has a list of values, which\n * are reduced in order.\n */\nfunction reduceValueLists<Value, Accumulator>(\n compiled: CompiledVariants<readonly Value[]>,\n indexes: Int32Array,\n reducer: Reducer<Value, Accumulator>,\n): Accumulator {\n const { reduce } = reducer;\n let accumulator = reducer.initial();\n for (let variant = 0; variant < compiled.valuesByIndex.length; variant += 1) {\n const values =\n compiled.valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n accumulator = reduceEach(accumulator, values ?? [], reduce);\n }\n for (const compound of compiled.compounds) {\n if (matches(compound, indexes)) {\n accumulator = reduceEach(accumulator, compound.value, reduce);\n }\n }\n return accumulator;\n}\n\n/** Reduces `values` into `accumulator`, in order. */\nfunction reduceEach<Value, Accumulator>(\n accumulator: Accumulator,\n values: readonly Value[],\n reduce: Reducer<Value, Accumulator>[\"reduce\"],\n): Accumulator {\n let result = accumulator;\n for (const value of values) {\n result = reduce(result, value);\n }\n return result;\n}\n\nexport { matches, reduceEach, reduceValueLists, reduceValues };\n","import type {\n LooseCompoundVariant,\n LooseVariants,\n SelectedVariants,\n} from \"./variants.js\";\n\n/** Whether a recipe has slots, which decides the recipes it composes. */\ntype RecipeType = \"recipe\" | \"slot recipe\";\n\n/**\n * The values of one config that a recipe is made of: its own config, or\n * that of a recipe it composes.\n */\ninterface Layer<Value> {\n readonly slots: readonly string[];\n readonly base: Value | undefined;\n readonly variants: LooseVariants<Value>;\n readonly compoundVariants: readonly LooseCompoundVariant<Value>[];\n readonly defaultVariants: SelectedVariants;\n}\n\n/** What a recipe's config gives for its layer. */\ninterface LayerConfig<Value> {\n readonly base?: Value | undefined;\n readonly variants: LooseVariants<Value>;\n readonly compoundVariants?:\n readonly LooseCompoundVariant<Value>[] | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n}\n\n/**\n * Returns the layer of a recipe's own config, with copies of its records,\n * so that changing the config later changes no recipe that composes it.\n */\nfunction layerOf<Value>(\n config: LayerConfig<Value>,\n slots: readonly string[],\n): Layer<Value> {\n return {\n base: config.base,\n compoundVariants: (config.compoundVariants ?? []).map(\n ({ variants, value }) => ({ value, variants: { ...variants } }),\n ),\n defaultVariants: { ...config.defaultVariants },\n slots: [...slots],\n variants: Object.fromEntries(\n Object.entries(config.variants).map(\n ([name, options]: readonly [\n string,\n Readonly<Record<string, Value>>,\n ]) => [name, { ...options }],\n ),\n ),\n };\n}\n\n/** The layers of the recipes of one type, which the engine created. */\ninterface Registry<Value> {\n /**\n * Returns the layers of a recipe: those of each recipe it composes, in\n * order, each only at its first occurrence, then its own.\n *\n * @throws TypeError when a recipe it composes is not in the registry.\n */\n readonly layersOf: (\n composes: readonly unknown[],\n own: Layer<Value>,\n ) => readonly Layer<Value>[];\n /** Records the layers of `recipe`, so that other recipes can compose it. */\n readonly withLayers: <Recipe extends object>(\n recipe: Recipe,\n layers: readonly Layer<Value>[],\n ) => Recipe;\n}\n\n/** Returns an empty registry of recipes of type `type`. */\nfunction createRegistry<Value>(type: RecipeType): Registry<Value> {\n const layersByRecipe = new WeakMap<object, readonly Layer<Value>[]>();\n\n const layersOfRecipe = (recipe: unknown): readonly Layer<Value>[] => {\n const layers =\n typeof recipe === \"function\" ? layersByRecipe.get(recipe) : undefined;\n if (layers === undefined) {\n throw new TypeError(\n `A ${type} composes only ${type}s created by @lynstack/recipe. ` +\n \"Check that the app installs one copy of @lynstack/recipe.\",\n );\n }\n return layers;\n };\n\n return {\n layersOf: (composes, own) => [\n ...new Set([\n ...composes.flatMap((recipe) => layersOfRecipe(recipe)),\n own,\n ]),\n ],\n withLayers: (recipe, layers) => {\n layersByRecipe.set(recipe, layers);\n return recipe;\n },\n };\n}\n\n/**\n * The layers of a recipe merged into one config, in which every option and\n * compound variant has the list of its values, in the order of the layers.\n */\ninterface MergedLayers<Value> {\n /** The slots of every layer, each once, in order. */\n readonly slots: readonly string[];\n /** The base of each layer that has one. */\n readonly bases: readonly Value[];\n readonly variants: LooseVariants<readonly Value[]>;\n readonly compoundVariants: readonly LooseCompoundVariant<readonly Value[]>[];\n readonly defaultVariants: SelectedVariants;\n}\n\n/**\n * Merges layers into one config: the union of their slots, of their\n * variants, and of the options of each, the values of each option in the\n * order of the layers, their compound variants in order, and the default\n * of each variant from the last layer that gives one.\n */\nfunction mergeLayers<Value>(\n layers: readonly Layer<Value>[],\n): MergedLayers<Value> {\n const variantNames = unique(\n layers.flatMap((layer) => Object.keys(layer.variants)),\n );\n return {\n bases: layers.flatMap(({ base }) => listOf(base)),\n compoundVariants: layers.flatMap((layer) =>\n layer.compoundVariants.map(({ variants, value }) => ({\n value: listOf(value),\n variants,\n })),\n ),\n defaultVariants: Object.fromEntries(\n layers.flatMap((layer) =>\n Object.entries(layer.defaultVariants).filter(\n ([, option]: readonly [string, unknown]) => option !== undefined,\n ),\n ),\n ),\n slots: unique(layers.flatMap(({ slots }) => slots)),\n variants: Object.fromEntries(\n variantNames.map((name) => [name, mergeOptions(layers, name)]),\n ),\n };\n}\n\n/** The options of the variant `name` in any layer, with their values. */\nfunction mergeOptions<Value>(\n layers: readonly Layer<Value>[],\n name: string,\n): Readonly<Record<string, readonly Value[]>> {\n const optionsOfLayers = layers.map(\n (layer) => ownValue(layer.variants, name) ?? {},\n );\n const optionNames = unique(\n optionsOfLayers.flatMap((options) => Object.keys(options)),\n );\n return Object.fromEntries(\n optionNames.map((option) => [\n option,\n optionsOfLayers.flatMap((options) => listOf(ownValue(options, option))),\n ]),\n );\n}\n\n/**\n * Combines values, none of them undefined, into one with `combine`, in\n * order, or returns undefined when there are none.\n */\nfunction combineValues<Value>(\n values: readonly Value[],\n combine: (first: Value, second: Value) => Value,\n): Value | undefined {\n let combined: Value | undefined = undefined;\n for (const value of values) {\n combined = combined === undefined ? value : combine(combined, value);\n }\n return combined;\n}\n\nfunction ownValue<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Value | undefined {\n return Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nfunction listOf<Value>(value: Value | undefined): readonly Value[] {\n return value === undefined ? [] : [value];\n}\n\nfunction unique(names: readonly string[]): readonly string[] {\n return [...new Set(names)];\n}\n\nexport { combineValues, createRegistry, layerOf, mergeLayers };\nexport type { Layer, MergedLayers, Registry };\n","import type { CompiledVariants, SelectedVariants } from \"./variants.js\";\nimport type { Layer, MergedLayers } from \"./compose.js\";\nimport { reduceEach, reduceValueLists, reduceValues } from \"./reduce-values.js\";\nimport type { KindVariants } from \"./recipe-kind.js\";\nimport { combineValues } from \"./compose.js\";\nimport { compileVariants } from \"./variants.js\";\n\n/** A recipe kind in the loose shape the runtime works with. */\ninterface LooseRecipeKind {\n readonly initial: (base: unknown) => unknown;\n readonly reduce: (accumulator: unknown, value: unknown) => unknown;\n readonly combine?: ((first: unknown, second: unknown) => unknown) | undefined;\n readonly finish?: ((accumulator: unknown) => unknown) | undefined;\n readonly cache?: boolean | undefined;\n}\n\ninterface LooseKindRecipeConfig {\n readonly composes?: readonly unknown[] | undefined;\n readonly base?: unknown;\n readonly variants: KindVariants<unknown>;\n readonly compoundVariants?:\n | readonly {\n readonly variants: SelectedVariants;\n readonly value: unknown;\n }[]\n | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n readonly cache?: boolean | undefined;\n}\n\n/** The variants of a recipe, and how it builds the result of a selection. */\ninterface CompiledRecipe {\n readonly compiled: CompiledVariants<unknown>;\n readonly build: (indexes: Int32Array) => unknown;\n}\n\nconst asResult = (accumulator: unknown): unknown => accumulator;\n\nconst noValues: readonly unknown[] = Object.freeze([]);\n\nconst firstValue = (values: readonly unknown[]): unknown => values[0];\n\n/** Compiles a recipe that composes no other recipe. */\nfunction compileLayer(\n kind: LooseRecipeKind,\n layer: Layer<unknown>,\n): CompiledRecipe {\n const { initial, reduce, finish } = kind;\n const { base } = layer;\n const compiled = compileVariants<unknown>({ ...layer, noValue: undefined });\n const reducer = { initial: (): unknown => initial(base), reduce };\n const build =\n finish === undefined\n ? (indexes: Int32Array): unknown =>\n reduceValues(compiled, indexes, reducer)\n : (indexes: Int32Array): unknown =>\n finish(reduceValues(compiled, indexes, reducer));\n return { build, compiled };\n}\n\n/**\n * Compiles a recipe from the merged layers of the recipes it composes and\n * its own. With `kind.combine`, it combines the bases and the values of\n * each option and compiles them as one config. Without it, its accumulator\n * starts from the first base, and the other bases are reduced into it\n * first; when no option or compound variant has more than one value, it\n * compiles them as one config.\n */\nfunction compileMergedLayers(\n kind: LooseRecipeKind,\n merged: MergedLayers<unknown>,\n): CompiledRecipe {\n const { combine } = kind;\n if (combine !== undefined) {\n const combined = (values: readonly unknown[]): unknown =>\n combineValues(values, combine);\n return compileLayer(\n kind,\n layerOfMerged(merged, combined(merged.bases), combined),\n );\n }\n const [base, ...otherBases] = merged.bases;\n const kindOfBases =\n otherBases.length === 0\n ? kind\n : {\n ...kind,\n initial: (): unknown =>\n reduceEach(kind.initial(base), otherBases, kind.reduce),\n };\n return isSingleValued(merged)\n ? compileLayer(kindOfBases, layerOfMerged(merged, base, firstValue))\n : compileValueLists(kindOfBases, merged, base);\n}\n\n/** Whether no option or compound variant has more than one value. */\nfunction isSingleValued(merged: MergedLayers<unknown>): boolean {\n const optionValues = Object.values(merged.variants).flatMap((options) =>\n Object.values(options),\n );\n return (\n optionValues.every((values) => hasOneValueAtMost(values)) &&\n merged.compoundVariants.every(({ value }) => hasOneValueAtMost(value))\n );\n}\n\n/**\n * Returns the merged layers as one config with `base`, the value of each\n * option and compound variant made by `valueOf` from its values.\n */\nfunction layerOfMerged(\n merged: MergedLayers<unknown>,\n base: unknown,\n valueOf: (values: readonly unknown[]) => unknown,\n): Layer<unknown> {\n return {\n base,\n compoundVariants: merged.compoundVariants.map(({ variants, value }) => ({\n value: valueOf(value),\n variants,\n })),\n defaultVariants: merged.defaultVariants,\n slots: [],\n variants: Object.fromEntries(\n Object.entries(merged.variants).map(\n ([name, options]: readonly [\n string,\n Readonly<Record<string, readonly unknown[]>>,\n ]) => [\n name,\n Object.fromEntries(\n Object.entries(options).map(\n ([option, values]: readonly [string, readonly unknown[]]) => [\n option,\n valueOf(values),\n ],\n ),\n ),\n ],\n ),\n ),\n };\n}\n\nfunction hasOneValueAtMost(values: readonly unknown[]): boolean {\n return values.length <= 1;\n}\n\n/** Compiles a recipe whose options or compound variants have value lists. */\nfunction compileValueLists(\n kind: LooseRecipeKind,\n merged: MergedLayers<unknown>,\n base: unknown,\n): CompiledRecipe {\n const { initial, reduce, finish = asResult } = kind;\n const compiled = compileVariants<readonly unknown[]>({\n ...merged,\n noValue: noValues,\n });\n const reducer = { initial: (): unknown => initial(base), reduce };\n const build = (indexes: Int32Array): unknown =>\n finish(reduceValueLists(compiled, indexes, reducer));\n return { build, compiled };\n}\n\nexport { compileLayer, compileMergedLayers };\nexport type { LooseKindRecipeConfig, LooseRecipeKind };\n","type UncheckedRecord = Readonly<Record<string, unknown>>;\n\n/** Checks a value of a slot recipe, such as an option's value. */\ntype CheckValue = (value: unknown, describe: () => string) => void;\n\nconst anyValue: CheckValue = () => {\n // A recipe's values have the type of its kind, which the engine cannot check.\n};\n\nfunction isRecord(value: unknown): value is UncheckedRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Checks a value of a slot recipe: undefined, or a value for each slot. */\nconst slotValues: CheckValue = (value, describe) => {\n if (value !== undefined && !isRecord(value)) {\n throw new TypeError(\n `${describe()} needs an object of the value of each slot.`,\n );\n }\n};\n\nfunction checkVariants(variants: unknown, checkValue: CheckValue): void {\n if (!isRecord(variants)) {\n throw new TypeError(\n \"A recipe's config needs `variants`, an object of the options of each variant. Use `variants: {}` for a recipe without variants.\",\n );\n }\n for (const [name, options] of Object.entries(variants)) {\n if (!isRecord(options)) {\n throw new TypeError(\n `The variant \"${name}\" needs an object of its options.`,\n );\n }\n for (const [option, value] of Object.entries(options)) {\n checkValue(\n value,\n () => `The option \"${option}\" of the variant \"${name}\"`,\n );\n }\n }\n}\n\nfunction checkCompoundVariants(\n compoundVariants: unknown,\n checkValue: CheckValue,\n): void {\n if (compoundVariants === undefined) {\n return;\n }\n if (!Array.isArray(compoundVariants)) {\n throw new TypeError(\n \"`compoundVariants` needs an array of compound variants.\",\n );\n }\n for (const [index, compound] of compoundVariants.entries()) {\n const { variants, value }: UncheckedRecord = isRecord(compound)\n ? compound\n : {};\n if (!isRecord(variants)) {\n throw new TypeError(\n `Compound variant ${String(index)} needs \\`variants\\`, an object of the options it matches.`,\n );\n }\n checkValue(\n value,\n () => `The \\`value\\` of compound variant ${String(index)}`,\n );\n }\n}\n\nfunction checkLayer(config: unknown, checkValue: CheckValue): UncheckedRecord {\n if (!isRecord(config)) {\n throw new TypeError(\"A recipe needs a config object.\");\n }\n const { variants, compoundVariants } = config;\n checkVariants(variants, checkValue);\n checkCompoundVariants(compoundVariants, checkValue);\n return config;\n}\n\n/**\n * Checks the shape of a recipe's config, which its types already check, so\n * that a config from untyped code fails when the recipe is created, with a\n * message that names what is wrong.\n *\n * @returns The config.\n * @throws {TypeError} When `variants` or a compound variant's `variants` is\n * not an object.\n */\nfunction checkRecipeConfig<Config>(config: Config): Config {\n checkLayer(config, anyValue);\n return config;\n}\n\n/**\n * Checks the shape of a slot recipe's config, as {@link checkRecipeConfig}\n * does, and that `slots` is an array and each value is an object of the\n * value of each slot.\n *\n * @returns The config.\n * @throws {TypeError} When a part of the config has the wrong shape.\n */\nfunction checkSlotRecipeConfig<Config>(config: Config): Config {\n const { slots, base } = checkLayer(config, slotValues);\n if (!Array.isArray(slots)) {\n throw new TypeError(\n \"A slot recipe's config needs `slots`, an array of the names of its slots.\",\n );\n }\n slotValues(base, () => \"The `base` of a slot recipe\");\n return config;\n}\n\nexport { checkRecipeConfig, checkSlotRecipeConfig };\n","import type { CompiledVariants, SelectedVariants } from \"./variants.js\";\nimport { noProps, select, undeclared } from \"./variants.js\";\n\n/** How a selector computes its results. */\ninterface SelectorOptions {\n /** Whether to cache the result of each declared selection. */\n readonly cache: boolean;\n}\n\n/** Whether `results` holds `result`, read at `key`, even if it is undefined. */\nfunction isCached<Result>(\n results: ReadonlyMap<number, Result>,\n key: number,\n result: Result | undefined,\n): result is Result {\n return result !== undefined || results.has(key);\n}\n\n/**\n * Returns a function that builds the result of a selection from the option\n * index of each variant, and treats a missing selection as an empty one.\n * With `options.cache`, it builds the result of each declared selection\n * once and caches it by the selection's key.\n */\nfunction createSelector<Result>(\n compiled: CompiledVariants<unknown>,\n build: (indexes: Int32Array) => Result,\n options: SelectorOptions,\n): (selected?: SelectedVariants | null) => Result {\n const indexes = new Int32Array(compiled.names.length);\n const results =\n options.cache && compiled.isCacheable\n ? new Map<number, Result>()\n : undefined;\n\n return (selected) => {\n const key = select(compiled, selected ?? noProps, indexes);\n if (key !== undeclared && results !== undefined) {\n const cachedResult = results.get(key);\n if (isCached(results, key, cachedResult)) {\n return cachedResult;\n }\n }\n const result = build(indexes);\n if (key !== undeclared) {\n results?.set(key, result);\n }\n return result;\n };\n}\n\nexport { createSelector };\nexport type { SelectorOptions };\n","import { toOptionName, toOptionNames } from \"./variants.js\";\nimport type { Layer } from \"./compose.js\";\n\n/**\n * The console, which every runtime that runs the packages has, and which\n * the ES2022 library does not declare.\n */\ndeclare const console: { readonly warn: (message: string) => void };\n\n/** The options of each variant that the layers of a recipe declare. */\ntype DeclaredOptions = ReadonlyMap<string, readonly string[]>;\n\nfunction declaredOptionsOf<Value>(\n layers: readonly Layer<Value>[],\n): DeclaredOptions {\n const optionsByName = new Map<string, readonly string[]>();\n for (const { variants } of layers) {\n for (const [name, options] of Object.entries(variants)) {\n const declared = [\n ...(optionsByName.get(name) ?? []),\n ...Object.keys(options),\n ];\n optionsByName.set(\n name,\n declared.some((option) => isBooleanName(option))\n ? [...declared, \"true\", \"false\"]\n : declared,\n );\n }\n }\n return optionsByName;\n}\n\nfunction isBooleanName(option: string): boolean {\n return option === \"true\" || option === \"false\";\n}\n\nfunction unknownDefaults(\n defaultVariants: Readonly<Record<string, unknown>>,\n declared: ReadonlyMap<string, readonly string[]>,\n): string[] {\n return Object.entries(defaultVariants).flatMap(\n ([name, value]: readonly [string, unknown]) => {\n if (value === undefined) {\n return [];\n }\n const options = declared.get(name);\n if (options === undefined) {\n return [`\\`defaultVariants\\` names the variant \"${name}\".`];\n }\n const option = toOptionName(value);\n return option !== undefined && options.includes(option)\n ? []\n : [\n `\\`defaultVariants\\` gives \"${name}\" the option ${JSON.stringify(value)}.`,\n ];\n },\n );\n}\n\nfunction unknownConditions<Value>(\n own: Layer<Value>,\n declared: ReadonlyMap<string, readonly string[]>,\n): string[] {\n return own.compoundVariants.flatMap(({ variants }, index) =>\n Object.entries(variants).flatMap(\n ([name, value]: readonly [string, unknown]) => {\n if (value === undefined) {\n return [];\n }\n const options = declared.get(name);\n if (options === undefined) {\n return [\n `Compound variant ${String(index)} names the variant \"${name}\".`,\n ];\n }\n return toOptionNames(value)\n .filter((option) => !options.includes(option))\n .map(\n (option) =>\n `Compound variant ${String(index)} names the option \"${option}\" of \"${name}\".`,\n );\n },\n ),\n );\n}\n\nfunction unknownSlotsIn(\n value: unknown,\n slots: readonly string[],\n where: string,\n): string[] {\n if (typeof value !== \"object\" || value === null) {\n return [];\n }\n return Object.keys(value)\n .filter((slot) => !slots.includes(slot))\n .map((slot) => `${where} gives a value to the slot \"${slot}\".`);\n}\n\nfunction unknownSlots<Value>(\n own: Layer<Value>,\n slots: readonly string[],\n): string[] {\n return [\n ...unknownSlotsIn(own.base, slots, \"`base`\"),\n ...Object.entries(own.variants).flatMap(\n ([name, options]: readonly [string, Readonly<Record<string, Value>>]) =>\n Object.entries(options).flatMap(\n ([option, value]: readonly [string, Value]) =>\n unknownSlotsIn(value, slots, `The option \"${option}\" of \"${name}\"`),\n ),\n ),\n ...own.compoundVariants.flatMap(({ value }, index) =>\n unknownSlotsIn(value, slots, `Compound variant ${String(index)}`),\n ),\n ];\n}\n\n/**\n * Returns the names in a recipe's own config that none of its layers\n * declares: a variant or option in its defaults or compound variants, and,\n * for a slot recipe, a slot that a value is given to. Such a default or\n * value is left out, and such a compound variant never matches. Each layer\n * was checked when its own recipe was created, so only `own` is checked.\n */\nfunction unknownNames<Value>(\n own: Layer<Value>,\n layers: readonly Layer<Value>[],\n isSlotRecipe: boolean,\n): string[] {\n const declared = declaredOptionsOf(layers);\n return [\n ...unknownDefaults(own.defaultVariants, declared),\n ...unknownConditions(own, declared),\n ...(isSlotRecipe\n ? unknownSlots(\n own,\n layers.flatMap(({ slots }) => slots),\n )\n : []),\n ];\n}\n\nconst warned = new Set<string>();\n\n/**\n * Warns once about the names that {@link unknownNames} returns, if any. A\n * warning already given is not repeated, so that a recipe created again\n * with the same config, such as a themed recipe for each theme, warns once.\n */\nfunction warnUnknownNames<Value>(\n own: Layer<Value>,\n layers: readonly Layer<Value>[],\n isSlotRecipe: boolean,\n): void {\n const problems = unknownNames(own, layers, isSlotRecipe);\n if (problems.length === 0) {\n return;\n }\n const warning = `A recipe's config names variants, options, or slots that it does not declare, so they add nothing:\\n- ${problems.join(\"\\n- \")}`;\n if (!warned.has(warning)) {\n warned.add(warning);\n console.warn(warning);\n }\n}\n\nexport { unknownNames, warnUnknownNames };\n","import type {\n Composable,\n ComposableKindRecipe,\n ComposedKindRecipe,\n ComposedVariants,\n InheritedDefaultedName,\n} from \"./composition.js\";\nimport type {\n KindCompoundCondition,\n WrittenKindDefaults,\n} from \"./kind-selection.js\";\nimport type { LooseKindRecipeConfig, LooseRecipeKind } from \"./build-recipe.js\";\nimport type {\n LooseVariants,\n SelectedVariants,\n WithVariants,\n} from \"./variants.js\";\nimport type {\n RecipeFunction,\n RecipeKind,\n SelectionDefaults,\n VariantKey,\n VariantOptions,\n} from \"./types.js\";\nimport { compileLayer, compileMergedLayers } from \"./build-recipe.js\";\nimport { createRegistry, layerOf, mergeLayers } from \"./compose.js\";\nimport { checkRecipeConfig } from \"./check-config.js\";\nimport { createSelector } from \"./selector.js\";\nimport { warnUnknownNames } from \"./check-names.js\";\nimport { withVariants } from \"./variants.js\";\n\nconst recipes = createRegistry<unknown>(\"recipe\");\n\n/**\n * The variants of a {@link KindRecipeConfig}: for each variant name, the\n * value of each of its options.\n *\n * @typeParam Value - The value of an option.\n */\ntype KindVariants<Value> = LooseVariants<Value>;\n\n/**\n * A value added when several variants have particular options at the same\n * time.\n *\n * @typeParam Variants - The variant definitions of the recipe.\n * @typeParam Value - The value of an option.\n */\ninterface KindCompoundVariant<Variants, Value> {\n /**\n * The options that must all be selected for\n * {@link KindCompoundVariant.value} to apply.\n */\n readonly variants: KindCompoundCondition<Variants>;\n /** The value added when the condition matches. */\n readonly value: Value;\n}\n\n/**\n * The configuration of a recipe made from a {@link RecipeKind}.\n *\n * @typeParam Value - The value of an option.\n * @typeParam Variants - The variant definitions, keyed by variant name.\n * @typeParam DefaultedName - The names of the variants that have a default.\n * @typeParam Composed - The types of the recipes that the recipe composes.\n */\ninterface KindRecipeConfig<\n Value,\n Variants extends KindVariants<Value>,\n DefaultedName extends keyof ComposedVariants<Composed, Variants>,\n Composed extends readonly ComposableKindRecipe<Value>[] = readonly [],\n> {\n /**\n * Recipes whose config the recipe adds to its own, in order, as if it\n * were written in one config: their bases first, the values of each of\n * their options before its own, and their compound variants first. A\n * recipe composed several times counts once.\n */\n readonly composes?: Composed | undefined;\n /** The value that the values of every selection are added to. */\n readonly base?: Value | undefined;\n /** For each variant name, the value of each of its options. */\n readonly variants: Variants;\n /**\n * Values added when several variants have particular options at the same\n * time, applied in order after the values of the variants' options.\n */\n readonly compoundVariants?:\n | readonly KindCompoundVariant<\n NoInfer<ComposedVariants<Composed, Variants>>,\n Value\n >[]\n | undefined;\n /** The option each variant uses when the recipe is called without it. */\n readonly defaultVariants?:\n | WrittenKindDefaults<ComposedVariants<Composed, Variants>, DefaultedName>\n | undefined;\n /** Whether the recipe caches its results. Defaults to the kind's `cache`. */\n readonly cache?: boolean | undefined;\n}\n\n/**\n * A recipe made from a {@link RecipeKind}: a function that returns the\n * result of a selection of variants, with the names of those variants in\n * `variantKeys`, the names of their options in `variantOptions`, and the\n * option each uses when a selection leaves it out in `defaultVariants`.\n *\n * @typeParam Selection - The variants the recipe accepts.\n * @typeParam Result - What the recipe returns.\n * @typeParam Composition - What the recipe passes on to the recipes that\n * compose it, a `RecipeComposition`. Without it, the type does not\n * allow composing the recipe.\n */\ntype KindRecipe<Selection, Result, Composition = unknown> = RecipeFunction<\n Selection,\n Result\n> & {\n /**\n * The names of the recipe's variants, in the order of\n * `Object.keys(config.variants)`, after those of the recipes it\n * composes.\n */\n readonly variantKeys: readonly VariantKey<Selection>[];\n /**\n * The names of the options of each variant, as strings, in the order in\n * which the recipe numbers them: integer names first, then `\"false\"` and\n * `\"true\"`, which a variant that declares either one has, then the\n * others in the order of the config. A frozen object, keyed in the order\n * of `variantKeys`.\n */\n readonly variantOptions: VariantOptions<Selection>;\n /**\n * The option, as a string, that each variant uses when a selection\n * leaves it out: its default, or `\"false\"` for a variant whose only\n * options are `\"true\"` and `\"false\"`. A frozen object, keyed in the\n * order of `variantKeys`, without the variants that have no default.\n */\n readonly defaultVariants: SelectionDefaults<Selection>;\n} & Composable<Composition>;\n\n/**\n * Creates recipes of one kind, the function that {@link createRecipeKind}\n * returns.\n *\n * @typeParam Value - The value of an option.\n * @typeParam Result - What a recipe of this kind returns.\n * @param config - The base value, variants, compound variants, and default\n * variants of the recipe, and whether it caches its results.\n * @returns The recipe.\n */\ntype CreateKindRecipe<Value, Result> = <\n const Variants extends KindVariants<Value>,\n const DefaultedName extends keyof ComposedVariants<Composed, Variants> =\n never,\n const Composed extends readonly ComposableKindRecipe<Value>[] = readonly [],\n>(\n config: KindRecipeConfig<Value, Variants, DefaultedName, Composed>,\n) => ComposedKindRecipe<\n ComposedVariants<Composed, Variants>,\n DefaultedName | InheritedDefaultedName<Composed, Variants>,\n Value,\n Result,\n undefined\n>;\n\ntype LooseKindRecipe = WithVariants<\n (selection?: SelectedVariants | null) => unknown\n>;\n\n/**\n * Creates a kind of recipe from how it turns the values of a selection into\n * its result, and returns the function that creates recipes of that kind.\n * A recipe maps a selection of variants to a result, as `cva` of\n * `@lynstack/class-recipe` does for class names, for values of any type,\n * such as style objects.\n *\n * @remarks\n * For each selection, a recipe reduces the value of each variant's selected\n * option and the value of each matching compound variant, with\n * `kind.reduce`, into the accumulator that `kind.initial` returns for the\n * recipe's base, then passes it to `kind.finish`. A variant whose only\n * options are `\"true\"` and `\"false\"` defaults to `false`, an option that the\n * config does not declare adds no value, and properties of the selection\n * that are not variants are ignored. A recipe's `variantKeys` property lists\n * the names of its variants, `variantOptions` the names of the options of\n * each, and `defaultVariants` the option each uses when a selection leaves\n * it out, so that a library can list every selection of a recipe.\n *\n * Creating a recipe warns once, with `console.warn`, about a default or a\n * compound variant's condition that names a variant or an option that no\n * config of the recipe declares. Such a default is ignored, and such a\n * condition never matches.\n *\n * With the cache, a recipe builds the result of each declared selection\n * once, and calling it again with the same variants returns the same\n * result. Freeze an object result in `kind.finish` so that callers cannot\n * change a result that later calls share. A selection with an undeclared\n * option is built on every call. A recipe keeps up to one result for each\n * combination of declared options; set `cache: false` in the config of a\n * recipe whose variants come from untrusted input, which overrides the kind.\n *\n * When the variant names are not known at compile time, as in a library\n * that passes on a config it received, a recipe accepts any selection.\n *\n * A recipe composes the recipes listed in its config's `composes`, of any\n * kind whose values have its type, as if their configs and its own were one:\n * the accumulator starts from the first base, and the other bases are\n * reduced first; every option of each is declared, with its values reduced\n * in the order of the recipes; their compound variants come before its own;\n * and a variant's default is the last one given. A recipe composed several\n * times counts once. With `kind.combine`, the bases, and the values that\n * the recipes give one option, are combined into one when the recipe is\n * created, so that it reduces one value for each.\n *\n * @typeParam Value - The value of an option, inferred from the `value`\n * parameter of `kind.reduce` or the `base` parameter of `kind.initial`.\n * @typeParam Accumulator - What the values are reduced to, inferred from\n * `kind.initial`.\n * @typeParam Result - What a recipe returns, inferred from `kind.finish`,\n * or the accumulator without it.\n * @param kind - How a recipe turns the values of a selection into its\n * result, and whether it caches the result.\n * @returns The function that creates recipes of this kind.\n *\n * @example\n * ```ts\n * type Style = Readonly<Record<string, string | number>>;\n *\n * const styleRecipe = createRecipeKind({\n * initial: (base?: Style): Record<string, string | number> => ({ ...base }),\n * reduce: (style, value: Style) => Object.assign(style, value),\n * combine: (first, second) => ({ ...first, ...second }),\n * finish: (style): Style => Object.freeze(style),\n * });\n *\n * const text = styleRecipe({\n * base: { color: \"black\" },\n * variants: {\n * size: { sm: { fontSize: 12 }, lg: { fontSize: 24 } },\n * muted: { true: { opacity: 0.6 } },\n * },\n * compoundVariants: [\n * { variants: { size: \"lg\", muted: true }, value: { fontWeight: 300 } },\n * ],\n * defaultVariants: { size: \"sm\" },\n * });\n *\n * text(); // => { color: \"black\", fontSize: 12 }\n *\n * text({ size: \"lg\", muted: true });\n * // => { color: \"black\", fontSize: 24, opacity: 0.6, fontWeight: 300 }\n *\n * text.variantKeys; // => [\"size\", \"muted\"]\n * text.variantOptions; // => { size: [\"sm\", \"lg\"], muted: [\"false\", \"true\"] }\n * text.defaultVariants; // => { size: \"sm\", muted: \"false\" }\n *\n * const heading = styleRecipe({\n * composes: [text],\n * base: { fontWeight: 700 },\n * variants: { size: { xl: { fontSize: 32 } } },\n * });\n *\n * heading({ size: \"xl\" });\n * // => { color: \"black\", fontWeight: 700, fontSize: 32 }\n * ```\n */\nfunction createRecipeKind<Value, Accumulator, Result = Accumulator>(\n kind: RecipeKind<Value, Accumulator, Result>,\n): CreateKindRecipe<Value, Result>;\n\nfunction createRecipeKind(kind: LooseRecipeKind): unknown {\n const kindCache = kind.cache ?? true;\n\n return (config: LooseKindRecipeConfig): LooseKindRecipe => {\n const own = layerOf(checkRecipeConfig(config), []);\n const layers = recipes.layersOf(config.composes ?? [], own);\n warnUnknownNames(own, layers, false);\n const { compiled, build } =\n layers.length === 1\n ? compileLayer(kind, own)\n : compileMergedLayers(kind, mergeLayers(layers));\n const options = { cache: config.cache ?? kindCache };\n const recipe = createSelector(compiled, build, options);\n return recipes.withLayers(withVariants(recipe, compiled), layers);\n };\n}\n\nexport { createRecipeKind };\nexport type {\n CreateKindRecipe,\n KindCompoundVariant,\n KindRecipe,\n KindRecipeConfig,\n KindVariants,\n};\n","import type { CompiledVariants, Compound } from \"./variants.js\";\nimport { combineValues } from \"./compose.js\";\nimport { matches } from \"./reduce-values.js\";\nimport { noOption } from \"./variants.js\";\n\n/** Values for some slots, keyed by slot name, as the runtime takes them. */\ntype LooseSlotValues = Readonly<Record<string, unknown>>;\n\n/** The values of the `false` option a boolean variant of a slot recipe adds. */\nconst noSlotValues: readonly LooseSlotValues[] = Object.freeze([]);\n\n/** How the values of each slot are reduced, as a recipe kind gives it. */\ninterface SlotsKind {\n readonly initial: (base: unknown) => unknown;\n readonly reduce: (accumulator: unknown, value: unknown) => unknown;\n readonly combine?: ((first: unknown, second: unknown) => unknown) | undefined;\n readonly finish?: ((accumulator: unknown) => unknown) | undefined;\n}\n\n/** The slots of a slot recipe and their bases, in the order of its layers. */\ninterface SlotsConfig {\n readonly slots: readonly string[];\n readonly bases: readonly LooseSlotValues[];\n}\n\n/**\n * The values that one option or compound variant adds to its slots: the\n * index of each slot it gives a value, and that value at the same position.\n * Slots without a value are left out, so reducing skips them.\n */\ninterface SlotEntries {\n readonly slots: readonly number[];\n readonly values: readonly unknown[];\n}\n\n/**\n * The accumulator of each slot while a selection is reduced, which\n * {@link addEntries} updates in place.\n */\ninterface SlotAccumulators {\n readonly length: number;\n [slot: number]: unknown;\n}\n\nfunction valueOfSlot(\n values: LooseSlotValues | undefined,\n slot: string,\n): unknown {\n return values !== undefined && Object.hasOwn(values, slot)\n ? values[slot]\n : undefined;\n}\n\n/**\n * Returns the values of each slot in a list of values for some slots, in\n * the order of the list, combined into one with `combine` when the kind\n * has it.\n */\nfunction slotValuesOf(\n slots: readonly string[],\n valuesList: readonly LooseSlotValues[],\n combine: SlotsKind[\"combine\"],\n): readonly (readonly unknown[])[] {\n return slots.map((slot) => {\n const values = valuesList.flatMap((each) =>\n listOf(valueOfSlot(each, slot)),\n );\n return combine === undefined\n ? values\n : listOf(combineValues(values, combine));\n });\n}\n\n/**\n * Returns the entries of the values of each slot, by slot index, or\n * undefined when no slot has one.\n */\nfunction entriesBySlot(\n valuesBySlot: readonly (readonly unknown[])[],\n): SlotEntries | undefined {\n const slotIndexes = valuesBySlot.flatMap((values, slot) =>\n values.map(() => slot),\n );\n return slotIndexes.length === 0\n ? undefined\n : { slots: slotIndexes, values: valuesBySlot.flat() };\n}\n\nfunction listOf(value: unknown): readonly unknown[] {\n return value === undefined ? [] : [value];\n}\n\n/** Turns the slot values of each option and compound variant into entries. */\nfunction compileEntries(\n compiled: CompiledVariants<readonly LooseSlotValues[]>,\n slots: readonly string[],\n combine: SlotsKind[\"combine\"],\n): CompiledVariants<SlotEntries | undefined> {\n const entriesOf = (\n valuesList: readonly LooseSlotValues[],\n ): SlotEntries | undefined =>\n entriesBySlot(slotValuesOf(slots, valuesList, combine));\n return {\n ...compiled,\n compounds: compiled.compounds\n .map((compound): Compound<SlotEntries | undefined> => ({\n conditions: compound.conditions,\n value: entriesOf(compound.value),\n }))\n .filter((compound) => compound.value !== undefined),\n valuesByIndex: compiled.valuesByIndex.map((valuesOfVariant) =>\n valuesOfVariant.map((values) => entriesOf(values)),\n ),\n };\n}\n\n/** Reduces the values of `added` into the accumulators of their slots. */\nfunction addEntries(\n accumulators: SlotAccumulators,\n added: SlotEntries,\n reduce: SlotsKind[\"reduce\"],\n): void {\n const { slots, values } = added;\n for (let entry = 0; entry < slots.length; entry += 1) {\n const slot = slots[entry] ?? 0;\n accumulators[slot] = reduce(accumulators[slot], values[entry]);\n }\n}\n\n/**\n * The names of a slot recipe's slots, and an object with a property for\n * each, which results copy so that assigning a slot named `__proto__` sets\n * that property instead of the prototype.\n */\ninterface SlotNames {\n readonly names: readonly string[];\n readonly template: Readonly<Record<string, unknown>>;\n}\n\n/** Returns the frozen result of each slot, keyed by slot name. */\nfunction resultsBySlot(\n slots: SlotNames,\n accumulators: SlotAccumulators,\n finish: (accumulator: unknown) => unknown,\n): Readonly<Record<string, unknown>> {\n const { names } = slots;\n const results: Record<string, unknown> = { ...slots.template };\n for (let slot = 0; slot < names.length; slot += 1) {\n results[names[slot] ?? \"\"] = finish(accumulators[slot]);\n }\n return Object.freeze(results);\n}\n\nconst asResult = (accumulator: unknown): unknown => accumulator;\n\n/**\n * Returns the function that builds the result of a selection for each slot\n * of a slot recipe: each slot reduces its own values with `kind`, and the\n * results are frozen in an object keyed by slot name.\n *\n * It reduces the values in a loop of its own instead of through\n * `reduceValues`, which recipes share, so that its calls to `kind.reduce`\n * see only the reducers of slot recipes and can be inlined.\n */\nfunction createSlotsBuilder(\n kind: SlotsKind,\n compiled: CompiledVariants<readonly LooseSlotValues[]>,\n config: SlotsConfig,\n): (indexes: Int32Array) => Readonly<Record<string, unknown>> {\n const { initial, reduce, combine, finish = asResult } = kind;\n const names = [...config.slots];\n const slotNames: SlotNames = {\n names,\n template: Object.fromEntries(names.map((slot) => [slot, undefined])),\n };\n const basesBySlot = slotValuesOf(names, config.bases, combine);\n const bases = basesBySlot.map(([base]: readonly unknown[]) => base);\n const otherBases = entriesBySlot(\n basesBySlot.map(([, ...others]: readonly unknown[]) => others),\n );\n const { valuesByIndex, compounds } = compileEntries(compiled, names, combine);\n\n /** Returns the accumulator of each slot, with every base reduced. */\n const initialAccumulators = (): SlotAccumulators => {\n const accumulators = bases.map((base) => initial(base));\n if (otherBases !== undefined) {\n addEntries(accumulators, otherBases, reduce);\n }\n return accumulators;\n };\n\n return (indexes) => {\n const accumulators = initialAccumulators();\n for (let variant = 0; variant < valuesByIndex.length; variant += 1) {\n const added = valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n if (added !== undefined) {\n addEntries(accumulators, added, reduce);\n }\n }\n for (const compound of compounds) {\n if (compound.value !== undefined && matches(compound, indexes)) {\n addEntries(accumulators, compound.value, reduce);\n }\n }\n return resultsBySlot(slotNames, accumulators, finish);\n };\n}\n\nexport { createSlotsBuilder, noSlotValues };\nexport type { LooseSlotValues, SlotsKind };\n","import type {\n ComposableKindSlotRecipe,\n ComposedKindRecipe,\n ComposedVariants,\n InheritedDefaultedName,\n InheritedSlot,\n} from \"./composition.js\";\nimport type {\n KindCompoundCondition,\n SlotVariantsCheck,\n WrittenKindDefaults,\n} from \"./kind-selection.js\";\nimport type { LooseSlotValues, SlotsKind } from \"./slots.js\";\nimport type { SelectedVariants, WithVariants } from \"./variants.js\";\nimport { compileVariants, withVariants } from \"./variants.js\";\nimport { createRegistry, layerOf, mergeLayers } from \"./compose.js\";\nimport { createSlotsBuilder, noSlotValues } from \"./slots.js\";\nimport type { KindVariants } from \"./recipe-kind.js\";\nimport type { RecipeKind } from \"./types.js\";\nimport { checkSlotRecipeConfig } from \"./check-config.js\";\nimport { createSelector } from \"./selector.js\";\nimport { warnUnknownNames } from \"./check-names.js\";\n\nconst slotRecipes = createRegistry<LooseSlotValues>(\"slot recipe\");\n\n/**\n * Values for some of a slot recipe's slots, keyed by slot name.\n *\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n */\ntype SlotValues<Slot extends string, Value> = {\n readonly [Name in Slot]?: Value | undefined;\n};\n\n/**\n * The variants of a {@link KindSlotRecipeConfig}: for each variant name,\n * the values of each slot for each of its options.\n *\n * @typeParam Value - The value of a slot.\n */\ntype KindSlotVariants<Value> = KindVariants<SlotValues<string, Value>>;\n\n/**\n * Values added to some slots when several variants have particular options\n * at the same time.\n *\n * @typeParam Variants - The variant definitions of the slot recipe.\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n */\ninterface KindSlotCompoundVariant<Variants, Slot extends string, Value> {\n /**\n * The options that must all be selected for\n * {@link KindSlotCompoundVariant.value} to apply.\n */\n readonly variants: KindCompoundCondition<Variants>;\n /** The value added to each slot when the condition matches. */\n readonly value: SlotValues<Slot, Value>;\n}\n\n/**\n * The configuration of a slot recipe made from a {@link RecipeKind}.\n *\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n * @typeParam Variants - The variant definitions, keyed by variant name.\n * @typeParam DefaultedName - The names of the variants that have a default.\n */\ninterface KindSlotRecipeConfig<\n Slot extends string,\n Value,\n Variants extends KindSlotVariants<Value>,\n DefaultedName extends keyof ComposedVariants<Composed, Variants>,\n Composed extends readonly ComposableKindSlotRecipe<Value>[] = readonly [],\n> {\n /**\n * Slot recipes whose config the recipe adds to its own, in order, as if\n * it were written in one config: their slots and bases first, the values\n * of each of their options before its own, and their compound variants\n * first. A slot recipe composed several times counts once.\n */\n readonly composes?: Composed | undefined;\n /**\n * The names of the slots, in the order of the recipe's result, after\n * those of the slot recipes it composes. A name of a property that every\n * object has, such as `toString`, is not supported.\n */\n readonly slots: readonly Slot[];\n /** The value of each slot that the values of every selection are added to. */\n readonly base?:\n SlotValues<NoInfer<Slot> | InheritedSlot<Composed>, Value> | undefined;\n /** For each variant name, the values of each slot for each of its options. */\n readonly variants: Variants &\n SlotVariantsCheck<Variants, NoInfer<Slot>, InheritedSlot<Composed>, Value>;\n /**\n * Values added to some slots when several variants have particular\n * options at the same time, applied in order after the values of the\n * variants' options.\n */\n readonly compoundVariants?:\n | readonly KindSlotCompoundVariant<\n NoInfer<ComposedVariants<Composed, Variants>>,\n NoInfer<Slot> | InheritedSlot<Composed>,\n Value\n >[]\n | undefined;\n /** The option each variant uses when the recipe is called without it. */\n readonly defaultVariants?:\n | WrittenKindDefaults<ComposedVariants<Composed, Variants>, DefaultedName>\n | undefined;\n /** Whether the recipe caches its results. Defaults to the kind's `cache`. */\n readonly cache?: boolean | undefined;\n}\n\n/**\n * Creates slot recipes of one kind, the function that\n * {@link createSlotRecipeKind} returns.\n *\n * @typeParam Value - The value of a slot.\n * @typeParam Result - What a recipe of this kind returns for each slot.\n * @param config - The slot recipes it composes, and the slots, base values,\n * variants, compound variants, and default variants of the slot recipe,\n * and whether it caches its results.\n * @returns The slot recipe.\n */\ntype CreateKindSlotRecipe<Value, Result> = <\n const Slot extends string,\n const Variants extends KindSlotVariants<Value>,\n const DefaultedName extends keyof ComposedVariants<Composed, Variants> =\n never,\n const Composed extends readonly ComposableKindSlotRecipe<Value>[] =\n readonly [],\n>(\n config: KindSlotRecipeConfig<Slot, Value, Variants, DefaultedName, Composed>,\n) => ComposedKindRecipe<\n ComposedVariants<Composed, Variants>,\n DefaultedName | InheritedDefaultedName<Composed, Variants>,\n Value,\n // Not ComposedSlot, which declarations print with each composed type.\n Readonly<\n Record<\n | Slot\n | Exclude<Composed[number][\"~composition\"], undefined>[\"slots\"][number],\n Result\n >\n >,\n readonly (\n Slot | Exclude<Composed[number][\"~composition\"], undefined>[\"slots\"][number]\n )[]\n>;\n\ninterface LooseRecipeKind extends SlotsKind {\n readonly cache?: boolean | undefined;\n}\n\ninterface LooseSlotRecipeConfig {\n readonly composes?: readonly unknown[] | undefined;\n readonly slots: readonly string[];\n readonly base?: LooseSlotValues | undefined;\n readonly variants: KindSlotVariants<unknown>;\n readonly compoundVariants?:\n | readonly {\n readonly variants: SelectedVariants;\n readonly value: LooseSlotValues;\n }[]\n | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n readonly cache?: boolean | undefined;\n}\n\ntype LooseSlotRecipe = WithVariants<\n (selection?: SelectedVariants | null) => Readonly<Record<string, unknown>>\n>;\n\n/**\n * Creates a kind of slot recipe from how it turns the values of each slot\n * into that slot's result, and returns the function that creates slot\n * recipes of that kind. A slot recipe maps a selection of variants to the\n * result of each of several slots, such as the class names or the styles of\n * the elements of a component, as `sva` of `@lynstack/class-recipe` does.\n *\n * @remarks\n * A slot recipe reduces the values of each slot as a recipe of the same\n * kind from {@link createRecipeKind} would: `kind.initial` returns the\n * accumulator for the slot's base value, `kind.reduce` adds the slot's\n * value of each variant's selected option, in the order of `variants`, and\n * of each matching compound variant, in the order of `compoundVariants`,\n * and `kind.finish` turns the accumulator into the slot's result. A slot\n * without values gets the result of its accumulator for an `undefined`\n * base, so every slot is in the result.\n *\n * The result is a frozen object of each slot's result, keyed by slot name\n * in the order of `slots`. With the cache, a slot recipe builds it once for\n * each declared selection and returns the same object for the same\n * variants. The `cache` of a slot recipe's config overrides the kind's.\n * Variants, boolean variants, undeclared options, the warning about\n * undeclared names, and the `variantKeys`, `variantOptions`, and\n * `defaultVariants` properties are as in {@link createRecipeKind}. It also\n * warns about a value for a slot that no config lists in `slots`, which is\n * ignored.\n *\n * A slot recipe composes the slot recipes listed in `composes` as a recipe\n * composes recipes, and has the slots of each, theirs first. With\n * `kind.combine`, the values of each slot are combined as a recipe's are.\n *\n * @typeParam Value - The value of a slot, inferred from the `value`\n * parameter of `kind.reduce` or the `base` parameter of `kind.initial`.\n * @typeParam Accumulator - What the values of a slot are reduced to,\n * inferred from `kind.initial`.\n * @typeParam Result - What a slot recipe returns for each slot, inferred\n * from `kind.finish`, or the accumulator without it.\n * @param kind - How a slot recipe turns the values of each slot into its\n * result, and whether it caches its results. The same kind can create\n * recipes with {@link createRecipeKind}.\n * @returns The function that creates slot recipes of this kind.\n *\n * @example\n * ```ts\n * type Style = Readonly<Record<string, string | number>>;\n *\n * const styleKind = {\n * initial: (base?: Style): Record<string, string | number> => ({ ...base }),\n * reduce: (style: Record<string, string | number>, value: Style) =>\n * Object.assign(style, value),\n * finish: (style: Record<string, string | number>): Style =>\n * Object.freeze(style),\n * };\n *\n * const slotStyleRecipe = createSlotRecipeKind(styleKind);\n *\n * const card = slotStyleRecipe({\n * slots: [\"root\", \"title\"],\n * base: { root: { padding: 16 }, title: { fontSize: 18 } },\n * variants: {\n * tone: {\n * light: { root: { backgroundColor: \"white\" } },\n * dark: { root: { backgroundColor: \"black\" }, title: { color: \"white\" } },\n * },\n * },\n * compoundVariants: [\n * { variants: { tone: \"dark\" }, value: { title: { fontWeight: 600 } } },\n * ],\n * defaultVariants: { tone: \"light\" },\n * });\n *\n * card();\n * // => { root: { padding: 16, backgroundColor: \"white\" }, title: { fontSize: 18 } }\n *\n * card({ tone: \"dark\" });\n * // => {\n * // root: { padding: 16, backgroundColor: \"black\" },\n * // title: { fontSize: 18, color: \"white\", fontWeight: 600 },\n * // }\n *\n * card.variantOptions; // => { tone: [\"light\", \"dark\"] }\n * card.defaultVariants; // => { tone: \"light\" }\n *\n * const dialog = slotStyleRecipe({\n * composes: [card],\n * slots: [\"footer\"],\n * variants: { tone: { dark: { footer: { borderColor: \"white\" } } } },\n * });\n *\n * dialog({ tone: \"dark\" }).footer; // => { borderColor: \"white\" }\n * ```\n */\nfunction createSlotRecipeKind<Value, Accumulator, Result = Accumulator>(\n kind: RecipeKind<Value, Accumulator, Result>,\n): CreateKindSlotRecipe<Value, Result>;\n\nfunction createSlotRecipeKind(kind: LooseRecipeKind): unknown {\n const kindCache = kind.cache ?? true;\n\n return (config: LooseSlotRecipeConfig): LooseSlotRecipe => {\n const own = layerOf(checkSlotRecipeConfig(config), config.slots);\n const layers = slotRecipes.layersOf(config.composes ?? [], own);\n warnUnknownNames(own, layers, true);\n const merged = mergeLayers(layers);\n const compiled = compileVariants<readonly LooseSlotValues[]>({\n ...merged,\n noValue: noSlotValues,\n });\n const build = createSlotsBuilder(kind, compiled, merged);\n const options = { cache: config.cache ?? kindCache };\n const recipe = createSelector(compiled, build, options);\n return slotRecipes.withLayers(withVariants(recipe, compiled), layers);\n };\n}\n\nexport { createSlotRecipeKind };\nexport type {\n CreateKindSlotRecipe,\n KindSlotCompoundVariant,\n KindSlotRecipeConfig,\n KindSlotVariants,\n SlotValues,\n};\n"],"mappings":"AA8DA,MAAM,UAA4B,OAAO,OAAO,CAAC,CAAC;;;;;;;;AASlD,SAAS,gBACP,QACyB;CACzB,MAAM,QAAQ,OAAO,KAAK,OAAO,QAAQ;CACzC,MAAM,eAAe,MAAM,KAAK,SAC9B,mBAAmB,OAAO,SAAS,SAAS,CAAC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AAO,cAAc,WAAW,cAAc,MAAM;CACtD;AACF;;;ACvLA,MAAM,cAAc,eAAgC,aAAa;AAwPjE,SAAS,qBAAqB,MAAgC;CAC5D,MAAM,YAAY,KAAK,SAAS;CAEhC,QAAQ,WAAmD;EACzD,MAAM,MAAM,QAAQ,sBAAsB,MAAM,GAAG,OAAO,KAAK;EAC/D,MAAM,SAAS,YAAY,SAAS,OAAO,YAAY,CAAC,GAAG,GAAG;EAC9D,iBAAiB,KAAK,QAAQ,IAAI;EAClC,MAAM,SAAS,YAAY,MAAM;EACjC,MAAM,WAAW,gBAA4C;GAC3D,GAAG;GACH,SAAS;EACX,CAAC;EAGD,MAAM,SAAS,eAAe,UAFhB,mBAAmB,MAAM,UAAU,MAET,GAAO,EAD7B,OAAO,OAAO,SAAS,UACM,CAAO;EACtD,OAAO,YAAY,WAAW,aAAa,QAAQ,QAAQ,GAAG,MAAM;CACtE;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["listOf","asResult"],"sources":["../src/variants.ts","../src/reduce-values.ts","../src/compose.ts","../src/build-recipe.ts","../src/check-config.ts","../src/selector.ts","../src/check-names.ts","../src/recipe-kind.ts","../src/slots.ts","../src/slot-recipe-kind.ts"],"sourcesContent":["/**\n * Variant definitions in the loose shape the runtime works with: for each\n * variant name, the value of each of its options.\n */\ntype LooseVariants<Value> = Readonly<\n Record<string, Readonly<Record<string, Value>>>\n>;\n\n/** A selection in the loose shape the runtime works with. */\ntype SelectedVariants = Readonly<Record<string, unknown>>;\n\n/** A compound variant in the loose shape the runtime works with. */\ninterface LooseCompoundVariant<Value> {\n readonly variants: SelectedVariants;\n readonly value: Value;\n}\n\n/** The variant's index and the option indexes that a condition matches. */\ntype CompoundCondition = readonly [number, readonly number[]];\n\n/** A compound variant prepared for matching. */\ninterface Compound<Value> {\n readonly conditions: readonly CompoundCondition[];\n readonly value: Value;\n}\n\n/** What {@link compileVariants} prepares. */\ninterface VariantsConfig<Value> {\n readonly variants: LooseVariants<Value>;\n readonly defaultVariants: SelectedVariants;\n readonly compoundVariants: readonly LooseCompoundVariant<Value>[];\n /**\n * The value of a variant without a selected option, and of a boolean\n * option that the variant does not declare.\n */\n readonly noValue: Value;\n}\n\n/**\n * Variants prepared for selecting values. Each variant numbers its options\n * from 1, and 0 stands for no option, so a selection is a list of option\n * indexes. Read together as the digits of a mixed-radix number, they form\n * the selection's key.\n */\ninterface CompiledVariants<Value> {\n readonly names: readonly string[];\n readonly defaultOptions: readonly (string | undefined)[];\n readonly indexByOption: readonly ReadonlyMap<string, number>[];\n /** The value of each variant's options, by option index. */\n readonly valuesByIndex: readonly (readonly Value[])[];\n readonly strides: readonly number[];\n readonly compounds: readonly Compound<Value>[];\n /** Whether every selection's key is a safe integer. */\n readonly isCacheable: boolean;\n}\n\n/** The option index of a variant without a selected option. */\nconst noOption = 0;\n\n/** The key of a selection with an option that a variant does not declare. */\nconst undeclared = -1;\n\nconst noProps: SelectedVariants = Object.freeze({});\n\n/**\n * Prepares variants for selecting values. A variant that declares an option\n * named `\"true\"` or `\"false\"` also declares the other one, with\n * `config.noValue`, and a variant whose only options are those defaults to\n * `\"false\"`. An undeclared option in a compound variant's list is ignored,\n * and a compound variant that names an undeclared variant, or no declared\n * option of a variant, never matches and is left out.\n */\nfunction compileVariants<Value>(\n config: VariantsConfig<Value>,\n): CompiledVariants<Value> {\n const names = Object.keys(config.variants);\n const optionValues = names.map((name) =>\n withBooleanOptions(config.variants[name] ?? {}, config.noValue),\n );\n const indexByOption: readonly ReadonlyMap<string, number>[] =\n optionValues.map(\n (valuesByOption) =>\n new Map(\n Object.keys(valuesByOption).map((option, index) => [\n option,\n index + 1,\n ]),\n ),\n );\n const radixes = indexByOption.map((indexes) => indexes.size + 1);\n\n return {\n compounds: compileCompounds(config.compoundVariants, names, indexByOption),\n defaultOptions: names.map(\n (name, index) =>\n toOptionName(config.defaultVariants[name]) ??\n (isBooleanVariant(indexByOption[index]) ? \"false\" : undefined),\n ),\n indexByOption,\n isCacheable: product(radixes) <= Number.MAX_SAFE_INTEGER,\n names,\n strides: radixes.map((_radix, index) => product(radixes.slice(0, index))),\n valuesByIndex: valuesByIndexOf(optionValues, config.noValue),\n };\n}\n\n/**\n * Writes the option index of each variant for `selected` into `indexes`\n * and returns the selection's key, or {@link undeclared} when an option is\n * not declared.\n */\nfunction select(\n compiled: CompiledVariants<unknown>,\n selected: SelectedVariants,\n indexes: Int32Array,\n): number {\n let key = 0;\n for (let variant = 0; variant < compiled.names.length; variant += 1) {\n const index = selectIndex(compiled, selected, variant);\n indexes[variant] = index ?? noOption;\n key =\n index === undefined || key === undeclared\n ? undeclared\n : key + index * (compiled.strides[variant] ?? 0);\n }\n return key;\n}\n\nfunction selectIndex(\n compiled: CompiledVariants<unknown>,\n selected: SelectedVariants,\n variant: number,\n): number | undefined {\n const option =\n toOptionName(selected[compiled.names[variant] ?? \"\"]) ??\n compiled.defaultOptions[variant];\n return option === undefined\n ? noOption\n : compiled.indexByOption[variant]?.get(option);\n}\n\nfunction valuesByIndexOf<Value>(\n optionValues: readonly Readonly<Record<string, Value>>[],\n noValue: Value,\n): Value[][] {\n const valuesByIndex: Value[][] = [];\n for (const valuesByOption of optionValues) {\n valuesByIndex.push([noValue, ...Object.values(valuesByOption)]);\n }\n return valuesByIndex;\n}\n\nfunction product(numbers: readonly number[]): number {\n return numbers.reduce((result, number) => result * number, 1);\n}\n\nfunction withBooleanOptions<Value>(\n valuesByOption: Readonly<Record<string, Value>>,\n noValue: Value,\n): Readonly<Record<string, Value>> {\n const optionNames = Object.keys(valuesByOption);\n if (!optionNames.some((option) => isBooleanName(option))) {\n return valuesByOption;\n }\n return { false: noValue, true: noValue, ...valuesByOption };\n}\n\nfunction compileCompounds<Value>(\n compoundVariants: readonly LooseCompoundVariant<Value>[],\n names: readonly string[],\n indexByOption: readonly ReadonlyMap<string, number>[],\n): Compound<Value>[] {\n return compoundVariants.flatMap(({ variants, value }) => {\n const conditions = Object.keys(variants)\n .filter((name) => variants[name] !== undefined)\n .map((name) =>\n compileCondition(indexByOption, names.indexOf(name), variants[name]),\n );\n return conditions.every(([, indexes]) => indexes.length > 0)\n ? [{ conditions, value }]\n : [];\n });\n}\n\nfunction compileCondition(\n indexByOption: readonly ReadonlyMap<string, number>[],\n variant: number,\n value: unknown,\n): CompoundCondition {\n const indexes = indexByOption[variant];\n return [\n variant,\n toOptionNames(value)\n .map((option) => indexes?.get(option))\n .filter((index): index is number => index !== undefined),\n ];\n}\n\nfunction isBooleanVariant(\n indexByOption: ReadonlyMap<string, number> | undefined,\n): boolean {\n return (\n indexByOption !== undefined &&\n indexByOption.size > 0 &&\n [...indexByOption.keys()].every((option) => isBooleanName(option))\n );\n}\n\nfunction toOptionName(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n return typeof value === \"number\" || typeof value === \"boolean\"\n ? String(value)\n : undefined;\n}\n\nfunction toOptionNames(value: unknown): readonly string[] {\n const values: readonly unknown[] = Array.isArray(value) ? value : [value];\n return values\n .map((option) => toOptionName(option))\n .filter((option): option is string => option !== undefined);\n}\n\n/** A recipe function with the names, options, and defaults of its variants. */\ntype WithVariants<Recipe> = Recipe & {\n readonly variantKeys: readonly string[];\n readonly variantOptions: Readonly<Record<string, readonly string[]>>;\n readonly defaultVariants: Readonly<Record<string, string>>;\n};\n\n/**\n * Adds the names of the compiled variants to `recipe` as `variantKeys`,\n * the names of their options as `variantOptions`, and the option each\n * variant uses when a selection leaves it out as `defaultVariants`.\n */\nfunction withVariants<Recipe extends object>(\n recipe: Recipe,\n compiled: CompiledVariants<unknown>,\n): WithVariants<Recipe> {\n return Object.assign(recipe, {\n defaultVariants: Object.freeze(defaultVariantsOf(compiled)),\n variantKeys: Object.freeze([...compiled.names]),\n variantOptions: Object.freeze(variantOptionsOf(compiled)),\n });\n}\n\nfunction variantOptionsOf(\n compiled: CompiledVariants<unknown>,\n): Record<string, readonly string[]> {\n const entries = compiled.names.map((name, index) => {\n const options = compiled.indexByOption[index]?.keys() ?? [];\n return [name, Object.freeze([...options])] as const;\n });\n return Object.fromEntries(entries);\n}\n\nfunction defaultVariantsOf(\n compiled: CompiledVariants<unknown>,\n): Record<string, string> {\n const entries = compiled.names.flatMap((name, index) => {\n const option = compiled.defaultOptions[index];\n return option === undefined ? [] : [[name, option] as const];\n });\n return Object.fromEntries(entries);\n}\n\nfunction isBooleanName(option: string): boolean {\n return option === \"true\" || option === \"false\";\n}\n\nexport {\n compileVariants,\n isBooleanName,\n noOption,\n noProps,\n select,\n toOptionName,\n toOptionNames,\n undeclared,\n withVariants,\n};\nexport type {\n CompiledVariants,\n Compound,\n LooseCompoundVariant,\n LooseVariants,\n SelectedVariants,\n WithVariants,\n};\n","import type { CompiledVariants, Compound } from \"./variants.js\";\nimport { noOption } from \"./variants.js\";\n\n/** Whether every condition of `compound` matches the selected indexes. */\nfunction matches(compound: Compound<unknown>, indexes: Int32Array): boolean {\n for (const [variant, matchingIndexes] of compound.conditions) {\n if (!matchingIndexes.includes(indexes[variant] ?? noOption)) {\n return false;\n }\n }\n return true;\n}\n\n/** Reduces the values of a selection to an accumulator. */\ninterface Reducer<Value, Accumulator> {\n /** Returns the accumulator to start from. */\n readonly initial: () => Accumulator;\n /** Adds a value to the accumulator and returns the accumulator. */\n readonly reduce: (accumulator: Accumulator, value: Value) => Accumulator;\n}\n\n/**\n * Reduces the values that apply to a selection, in order of precedence: the\n * value of each variant's option, then the value of each matching compound\n * variant. A value that is undefined adds nothing.\n */\nfunction reduceValues<Value, Accumulator>(\n compiled: CompiledVariants<Value | undefined>,\n indexes: Int32Array,\n reducer: Reducer<Value, Accumulator>,\n): Accumulator {\n const { reduce } = reducer;\n let accumulator = reducer.initial();\n for (let variant = 0; variant < compiled.valuesByIndex.length; variant += 1) {\n const value =\n compiled.valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n if (value !== undefined) {\n accumulator = reduce(accumulator, value);\n }\n }\n for (const compound of compiled.compounds) {\n if (compound.value !== undefined && matches(compound, indexes)) {\n accumulator = reduce(accumulator, compound.value);\n }\n }\n return accumulator;\n}\n\n/**\n * Reduces the values that apply to a selection, as {@link reduceValues}\n * does, when each option and compound variant has a list of values, which\n * are reduced in order.\n */\nfunction reduceValueLists<Value, Accumulator>(\n compiled: CompiledVariants<readonly Value[]>,\n indexes: Int32Array,\n reducer: Reducer<Value, Accumulator>,\n): Accumulator {\n const { reduce } = reducer;\n let accumulator = reducer.initial();\n for (let variant = 0; variant < compiled.valuesByIndex.length; variant += 1) {\n const values =\n compiled.valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n accumulator = reduceEach(accumulator, values ?? [], reduce);\n }\n for (const compound of compiled.compounds) {\n if (matches(compound, indexes)) {\n accumulator = reduceEach(accumulator, compound.value, reduce);\n }\n }\n return accumulator;\n}\n\n/** Reduces `values` into `accumulator`, in order. */\nfunction reduceEach<Value, Accumulator>(\n accumulator: Accumulator,\n values: readonly Value[],\n reduce: Reducer<Value, Accumulator>[\"reduce\"],\n): Accumulator {\n let result = accumulator;\n for (const value of values) {\n result = reduce(result, value);\n }\n return result;\n}\n\nexport { matches, reduceEach, reduceValueLists, reduceValues };\n","import type {\n LooseCompoundVariant,\n LooseVariants,\n SelectedVariants,\n} from \"./variants.js\";\n\n/** Whether a recipe has slots, which decides the recipes it composes. */\ntype RecipeType = \"recipe\" | \"slot recipe\";\n\n/**\n * The values of one config that a recipe is made of: its own config, or\n * that of a recipe it composes.\n */\ninterface Layer<Value> {\n readonly slots: readonly string[];\n readonly base: Value | undefined;\n readonly variants: LooseVariants<Value>;\n readonly compoundVariants: readonly LooseCompoundVariant<Value>[];\n readonly defaultVariants: SelectedVariants;\n}\n\n/** What a recipe's config gives for its layer. */\ninterface LayerConfig<Value> {\n readonly base?: Value | undefined;\n readonly variants: LooseVariants<Value>;\n readonly compoundVariants?:\n readonly LooseCompoundVariant<Value>[] | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n}\n\n/**\n * Returns the layer of a recipe's own config, with copies of its records,\n * so that changing the config later changes no recipe that composes it.\n */\nfunction layerOf<Value>(\n config: LayerConfig<Value>,\n slots: readonly string[],\n): Layer<Value> {\n return {\n base: config.base,\n compoundVariants: (config.compoundVariants ?? []).map(\n ({ variants, value }) => ({ value, variants: { ...variants } }),\n ),\n defaultVariants: { ...config.defaultVariants },\n slots: [...slots],\n variants: Object.fromEntries(\n Object.entries(config.variants).map(\n ([name, options]: readonly [\n string,\n Readonly<Record<string, Value>>,\n ]) => [name, { ...options }],\n ),\n ),\n };\n}\n\n/** The layers of the recipes of one type, which the engine created. */\ninterface Registry<Value> {\n /**\n * Returns the layers of a recipe: those of each recipe it composes, in\n * order, each only at its first occurrence, then its own.\n *\n * @throws TypeError when a recipe it composes is not in the registry.\n */\n readonly layersOf: (\n composes: readonly unknown[],\n own: Layer<Value>,\n ) => readonly Layer<Value>[];\n /** Records the layers of `recipe`, so that other recipes can compose it. */\n readonly withLayers: <Recipe extends object>(\n recipe: Recipe,\n layers: readonly Layer<Value>[],\n ) => Recipe;\n}\n\n/** Returns an empty registry of recipes of type `type`. */\nfunction createRegistry<Value>(type: RecipeType): Registry<Value> {\n const layersByRecipe = new WeakMap<object, readonly Layer<Value>[]>();\n\n const layersOfRecipe = (recipe: unknown): readonly Layer<Value>[] => {\n const layers =\n typeof recipe === \"function\" ? layersByRecipe.get(recipe) : undefined;\n if (layers === undefined) {\n throw new TypeError(\n `A ${type} composes only ${type}s created by @lynstack/recipe. ` +\n \"Check that the app installs one copy of @lynstack/recipe.\",\n );\n }\n return layers;\n };\n\n return {\n layersOf: (composes, own) => [\n ...new Set([\n ...composes.flatMap((recipe) => layersOfRecipe(recipe)),\n own,\n ]),\n ],\n withLayers: (recipe, layers) => {\n layersByRecipe.set(recipe, layers);\n return recipe;\n },\n };\n}\n\n/**\n * The layers of a recipe merged into one config, in which every option and\n * compound variant has the list of its values, in the order of the layers.\n */\ninterface MergedLayers<Value> {\n /** The slots of every layer, each once, in order. */\n readonly slots: readonly string[];\n /** The base of each layer that has one. */\n readonly bases: readonly Value[];\n readonly variants: LooseVariants<readonly Value[]>;\n readonly compoundVariants: readonly LooseCompoundVariant<readonly Value[]>[];\n readonly defaultVariants: SelectedVariants;\n}\n\n/**\n * Merges layers into one config: the union of their slots, of their\n * variants, and of the options of each, the values of each option in the\n * order of the layers, their compound variants in order, and the default\n * of each variant from the last layer that gives one.\n */\nfunction mergeLayers<Value>(\n layers: readonly Layer<Value>[],\n): MergedLayers<Value> {\n const variantNames = unique(\n layers.flatMap((layer) => Object.keys(layer.variants)),\n );\n return {\n bases: layers.flatMap(({ base }) => listOf(base)),\n compoundVariants: layers.flatMap((layer) =>\n layer.compoundVariants.map(({ variants, value }) => ({\n value: listOf(value),\n variants,\n })),\n ),\n defaultVariants: Object.fromEntries(\n layers.flatMap((layer) =>\n Object.entries(layer.defaultVariants).filter(\n ([, option]: readonly [string, unknown]) => option !== undefined,\n ),\n ),\n ),\n slots: unique(layers.flatMap(({ slots }) => slots)),\n variants: Object.fromEntries(\n variantNames.map((name) => [name, mergeOptions(layers, name)]),\n ),\n };\n}\n\n/** The options of the variant `name` in any layer, with their values. */\nfunction mergeOptions<Value>(\n layers: readonly Layer<Value>[],\n name: string,\n): Readonly<Record<string, readonly Value[]>> {\n const optionsOfLayers = layers.map(\n (layer) => ownValue(layer.variants, name) ?? {},\n );\n const optionNames = unique(\n optionsOfLayers.flatMap((options) => Object.keys(options)),\n );\n return Object.fromEntries(\n optionNames.map((option) => [\n option,\n optionsOfLayers.flatMap((options) => listOf(ownValue(options, option))),\n ]),\n );\n}\n\n/**\n * Combines values, none of them undefined, into one with `combine`, in\n * order, or returns undefined when there are none.\n */\nfunction combineValues<Value>(\n values: readonly Value[],\n combine: (first: Value, second: Value) => Value,\n): Value | undefined {\n let combined: Value | undefined = undefined;\n for (const value of values) {\n combined = combined === undefined ? value : combine(combined, value);\n }\n return combined;\n}\n\nfunction ownValue<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Value | undefined {\n return Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nfunction listOf<Value>(value: Value | undefined): readonly Value[] {\n return value === undefined ? [] : [value];\n}\n\nfunction unique(names: readonly string[]): readonly string[] {\n return [...new Set(names)];\n}\n\nexport { combineValues, createRegistry, layerOf, mergeLayers };\nexport type { Layer, MergedLayers, Registry };\n","import type { CompiledVariants, SelectedVariants } from \"./variants.js\";\nimport type { Layer, MergedLayers } from \"./compose.js\";\nimport { reduceEach, reduceValueLists, reduceValues } from \"./reduce-values.js\";\nimport type { KindVariants } from \"./recipe-kind.js\";\nimport { combineValues } from \"./compose.js\";\nimport { compileVariants } from \"./variants.js\";\n\n/** A recipe kind in the loose shape the runtime works with. */\ninterface LooseRecipeKind {\n readonly initial: (base: unknown) => unknown;\n readonly reduce: (accumulator: unknown, value: unknown) => unknown;\n readonly combine?: ((first: unknown, second: unknown) => unknown) | undefined;\n readonly finish?: ((accumulator: unknown) => unknown) | undefined;\n readonly cache?: boolean | undefined;\n}\n\ninterface LooseKindRecipeConfig {\n readonly composes?: readonly unknown[] | undefined;\n readonly base?: unknown;\n readonly variants: KindVariants<unknown>;\n readonly compoundVariants?:\n | readonly {\n readonly variants: SelectedVariants;\n readonly value: unknown;\n }[]\n | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n readonly cache?: boolean | undefined;\n}\n\n/** The variants of a recipe, and how it builds the result of a selection. */\ninterface CompiledRecipe {\n readonly compiled: CompiledVariants<unknown>;\n readonly build: (indexes: Int32Array) => unknown;\n}\n\nconst asResult = (accumulator: unknown): unknown => accumulator;\n\nconst noValues: readonly unknown[] = Object.freeze([]);\n\nconst firstValue = (values: readonly unknown[]): unknown => values[0];\n\n/** Compiles a recipe that composes no other recipe. */\nfunction compileLayer(\n kind: LooseRecipeKind,\n layer: Layer<unknown>,\n): CompiledRecipe {\n const { initial, reduce, finish } = kind;\n const { base } = layer;\n const compiled = compileVariants<unknown>({ ...layer, noValue: undefined });\n const reducer = { initial: (): unknown => initial(base), reduce };\n const build =\n finish === undefined\n ? (indexes: Int32Array): unknown =>\n reduceValues(compiled, indexes, reducer)\n : (indexes: Int32Array): unknown =>\n finish(reduceValues(compiled, indexes, reducer));\n return { build, compiled };\n}\n\n/**\n * Compiles a recipe from the merged layers of the recipes it composes and\n * its own. With `kind.combine`, it combines the bases and the values of\n * each option and compiles them as one config. Without it, its accumulator\n * starts from the first base, and the other bases are reduced into it\n * first; when no option or compound variant has more than one value, it\n * compiles them as one config.\n */\nfunction compileMergedLayers(\n kind: LooseRecipeKind,\n merged: MergedLayers<unknown>,\n): CompiledRecipe {\n const { combine } = kind;\n if (combine !== undefined) {\n const combined = (values: readonly unknown[]): unknown =>\n combineValues(values, combine);\n return compileLayer(\n kind,\n layerOfMerged(merged, combined(merged.bases), combined),\n );\n }\n const [base, ...otherBases] = merged.bases;\n const kindOfBases =\n otherBases.length === 0\n ? kind\n : {\n ...kind,\n initial: (): unknown =>\n reduceEach(kind.initial(base), otherBases, kind.reduce),\n };\n return isSingleValued(merged)\n ? compileLayer(kindOfBases, layerOfMerged(merged, base, firstValue))\n : compileValueLists(kindOfBases, merged, base);\n}\n\n/** Whether no option or compound variant has more than one value. */\nfunction isSingleValued(merged: MergedLayers<unknown>): boolean {\n const optionValues = Object.values(merged.variants).flatMap((options) =>\n Object.values(options),\n );\n return (\n optionValues.every((values) => hasOneValueAtMost(values)) &&\n merged.compoundVariants.every(({ value }) => hasOneValueAtMost(value))\n );\n}\n\n/**\n * Returns the merged layers as one config with `base`, the value of each\n * option and compound variant made by `valueOf` from its values.\n */\nfunction layerOfMerged(\n merged: MergedLayers<unknown>,\n base: unknown,\n valueOf: (values: readonly unknown[]) => unknown,\n): Layer<unknown> {\n return {\n base,\n compoundVariants: merged.compoundVariants.map(({ variants, value }) => ({\n value: valueOf(value),\n variants,\n })),\n defaultVariants: merged.defaultVariants,\n slots: [],\n variants: Object.fromEntries(\n Object.entries(merged.variants).map(\n ([name, options]: readonly [\n string,\n Readonly<Record<string, readonly unknown[]>>,\n ]) => [\n name,\n Object.fromEntries(\n Object.entries(options).map(\n ([option, values]: readonly [string, readonly unknown[]]) => [\n option,\n valueOf(values),\n ],\n ),\n ),\n ],\n ),\n ),\n };\n}\n\nfunction hasOneValueAtMost(values: readonly unknown[]): boolean {\n return values.length <= 1;\n}\n\n/** Compiles a recipe whose options or compound variants have value lists. */\nfunction compileValueLists(\n kind: LooseRecipeKind,\n merged: MergedLayers<unknown>,\n base: unknown,\n): CompiledRecipe {\n const { initial, reduce, finish = asResult } = kind;\n const compiled = compileVariants<readonly unknown[]>({\n ...merged,\n noValue: noValues,\n });\n const reducer = { initial: (): unknown => initial(base), reduce };\n const build = (indexes: Int32Array): unknown =>\n finish(reduceValueLists(compiled, indexes, reducer));\n return { build, compiled };\n}\n\nexport { compileLayer, compileMergedLayers };\nexport type { LooseKindRecipeConfig, LooseRecipeKind };\n","type UncheckedRecord = Readonly<Record<string, unknown>>;\n\n/** Checks a value of a slot recipe, such as an option's value. */\ntype CheckValue = (value: unknown, describe: () => string) => void;\n\nconst anyValue: CheckValue = () => {\n // A recipe's values have the type of its kind, which the engine cannot check.\n};\n\nfunction isRecord(value: unknown): value is UncheckedRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Checks a value of a slot recipe: undefined, or a value for each slot. */\nconst slotValues: CheckValue = (value, describe) => {\n if (value !== undefined && !isRecord(value)) {\n throw new TypeError(\n `${describe()} needs an object of the value of each slot.`,\n );\n }\n};\n\nfunction checkVariants(variants: unknown, checkValue: CheckValue): void {\n if (!isRecord(variants)) {\n throw new TypeError(\n \"A recipe's config needs `variants`, an object of the options of each variant. Use `variants: {}` for a recipe without variants.\",\n );\n }\n for (const [name, options] of Object.entries(variants)) {\n if (!isRecord(options)) {\n throw new TypeError(\n `The variant \"${name}\" needs an object of its options.`,\n );\n }\n for (const [option, value] of Object.entries(options)) {\n checkValue(\n value,\n () => `The option \"${option}\" of the variant \"${name}\"`,\n );\n }\n }\n}\n\nfunction checkCompoundVariants(\n compoundVariants: unknown,\n checkValue: CheckValue,\n): void {\n if (compoundVariants === undefined) {\n return;\n }\n if (!Array.isArray(compoundVariants)) {\n throw new TypeError(\n \"`compoundVariants` needs an array of compound variants.\",\n );\n }\n for (const [index, compound] of compoundVariants.entries()) {\n const { variants, value }: UncheckedRecord = isRecord(compound)\n ? compound\n : {};\n if (!isRecord(variants)) {\n throw new TypeError(\n `Compound variant ${String(index)} needs \\`variants\\`, an object of the options it matches.`,\n );\n }\n checkValue(\n value,\n () => `The \\`value\\` of compound variant ${String(index)}`,\n );\n }\n}\n\nfunction checkLayer(config: unknown, checkValue: CheckValue): UncheckedRecord {\n if (!isRecord(config)) {\n throw new TypeError(\"A recipe needs a config object.\");\n }\n const { variants, compoundVariants } = config;\n checkVariants(variants, checkValue);\n checkCompoundVariants(compoundVariants, checkValue);\n return config;\n}\n\n/**\n * Checks the shape of a recipe's config, which its types already check, so\n * that a config from untyped code fails when the recipe is created, with a\n * message that names what is wrong.\n *\n * @returns The config.\n * @throws {TypeError} When `variants` or a compound variant's `variants` is\n * not an object.\n */\nfunction checkRecipeConfig<Config>(config: Config): Config {\n checkLayer(config, anyValue);\n return config;\n}\n\n/**\n * Checks the shape of a slot recipe's config, as {@link checkRecipeConfig}\n * does, and that `slots` is an array and each value is an object of the\n * value of each slot.\n *\n * @returns The config.\n * @throws {TypeError} When a part of the config has the wrong shape.\n */\nfunction checkSlotRecipeConfig<Config>(config: Config): Config {\n const { slots, base } = checkLayer(config, slotValues);\n if (!Array.isArray(slots)) {\n throw new TypeError(\n \"A slot recipe's config needs `slots`, an array of the names of its slots.\",\n );\n }\n slotValues(base, () => \"The `base` of a slot recipe\");\n return config;\n}\n\nexport { checkRecipeConfig, checkSlotRecipeConfig };\n","import type { CompiledVariants, SelectedVariants } from \"./variants.js\";\nimport { noProps, select, undeclared } from \"./variants.js\";\n\n/** How a selector computes its results. */\ninterface SelectorOptions {\n /** Whether to cache the result of each declared selection. */\n readonly cache: boolean;\n}\n\n/** Whether `results` holds `result`, read at `key`, even if it is undefined. */\nfunction isCached<Result>(\n results: ReadonlyMap<number, Result>,\n key: number,\n result: Result | undefined,\n): result is Result {\n return result !== undefined || results.has(key);\n}\n\n/**\n * Returns a function that builds the result of a selection from the option\n * index of each variant, and treats a missing selection as an empty one.\n * With `options.cache`, it builds the result of each declared selection\n * once and caches it by the selection's key.\n */\nfunction createSelector<Result>(\n compiled: CompiledVariants<unknown>,\n build: (indexes: Int32Array) => Result,\n options: SelectorOptions,\n): (selected?: SelectedVariants | null) => Result {\n const indexes = new Int32Array(compiled.names.length);\n const results =\n options.cache && compiled.isCacheable\n ? new Map<number, Result>()\n : undefined;\n\n return (selected) => {\n const key = select(compiled, selected ?? noProps, indexes);\n if (key !== undeclared && results !== undefined) {\n const cachedResult = results.get(key);\n if (isCached(results, key, cachedResult)) {\n return cachedResult;\n }\n }\n const result = build(indexes);\n if (key !== undeclared) {\n results?.set(key, result);\n }\n return result;\n };\n}\n\nexport { createSelector };\nexport type { SelectorOptions };\n","import { isBooleanName, toOptionName, toOptionNames } from \"./variants.js\";\nimport type { Layer } from \"./compose.js\";\n\n/**\n * The console, which every runtime that runs the packages has, and which\n * the ES2022 library does not declare.\n */\ndeclare const console: { readonly warn: (message: string) => void };\n\n/** The options of each variant that the layers of a recipe declare. */\ntype DeclaredOptions = ReadonlyMap<string, readonly string[]>;\n\nfunction declaredOptionsOf<Value>(\n layers: readonly Layer<Value>[],\n): DeclaredOptions {\n const optionsByName = new Map<string, readonly string[]>();\n for (const { variants } of layers) {\n for (const [name, options] of Object.entries(variants)) {\n const declared = [\n ...(optionsByName.get(name) ?? []),\n ...Object.keys(options),\n ];\n optionsByName.set(\n name,\n declared.some((option) => isBooleanName(option))\n ? [...declared, \"true\", \"false\"]\n : declared,\n );\n }\n }\n return optionsByName;\n}\n\nfunction unknownDefaults(\n defaultVariants: Readonly<Record<string, unknown>>,\n declared: ReadonlyMap<string, readonly string[]>,\n): string[] {\n return Object.entries(defaultVariants).flatMap(\n ([name, value]: readonly [string, unknown]) => {\n if (value === undefined) {\n return [];\n }\n const options = declared.get(name);\n if (options === undefined) {\n return [`\\`defaultVariants\\` names the variant \"${name}\".`];\n }\n const option = toOptionName(value);\n return option !== undefined && options.includes(option)\n ? []\n : [\n `\\`defaultVariants\\` gives \"${name}\" the option ${JSON.stringify(value)}.`,\n ];\n },\n );\n}\n\nfunction unknownConditions<Value>(\n own: Layer<Value>,\n declared: ReadonlyMap<string, readonly string[]>,\n): string[] {\n return own.compoundVariants.flatMap(({ variants }, index) =>\n Object.entries(variants).flatMap(\n ([name, value]: readonly [string, unknown]) => {\n if (value === undefined) {\n return [];\n }\n const options = declared.get(name);\n if (options === undefined) {\n return [\n `Compound variant ${String(index)} names the variant \"${name}\".`,\n ];\n }\n return toOptionNames(value)\n .filter((option) => !options.includes(option))\n .map(\n (option) =>\n `Compound variant ${String(index)} names the option \"${option}\" of \"${name}\".`,\n );\n },\n ),\n );\n}\n\nfunction unknownSlotsIn(\n value: unknown,\n slots: readonly string[],\n where: string,\n): string[] {\n if (typeof value !== \"object\" || value === null) {\n return [];\n }\n return Object.keys(value)\n .filter((slot) => !slots.includes(slot))\n .map((slot) => `${where} gives a value to the slot \"${slot}\".`);\n}\n\nfunction unknownSlots<Value>(\n own: Layer<Value>,\n slots: readonly string[],\n): string[] {\n return [\n ...unknownSlotsIn(own.base, slots, \"`base`\"),\n ...Object.entries(own.variants).flatMap(\n ([name, options]: readonly [string, Readonly<Record<string, Value>>]) =>\n Object.entries(options).flatMap(\n ([option, value]: readonly [string, Value]) =>\n unknownSlotsIn(value, slots, `The option \"${option}\" of \"${name}\"`),\n ),\n ),\n ...own.compoundVariants.flatMap(({ value }, index) =>\n unknownSlotsIn(value, slots, `Compound variant ${String(index)}`),\n ),\n ];\n}\n\n/**\n * Returns the names in a recipe's own config that none of its layers\n * declares: a variant or option in its defaults or compound variants, and,\n * for a slot recipe, a slot that a value is given to. Such a default or\n * value is left out, an undeclared option in a compound variant's list is\n * ignored, and any other such compound variant never matches. Each layer\n * was checked when its own recipe was created, so only `own` is checked.\n */\nfunction unknownNames<Value>(\n own: Layer<Value>,\n layers: readonly Layer<Value>[],\n isSlotRecipe: boolean,\n): string[] {\n const declared = declaredOptionsOf(layers);\n return [\n ...unknownDefaults(own.defaultVariants, declared),\n ...unknownConditions(own, declared),\n ...(isSlotRecipe\n ? unknownSlots(\n own,\n layers.flatMap(({ slots }) => slots),\n )\n : []),\n ];\n}\n\nconst warned = new Set<string>();\n\n/**\n * Warns once about the names that {@link unknownNames} returns, if any. A\n * warning already given is not repeated, so that a recipe created again\n * with the same config, such as a themed recipe for each theme, warns once.\n */\nfunction warnUnknownNames<Value>(\n own: Layer<Value>,\n layers: readonly Layer<Value>[],\n isSlotRecipe: boolean,\n): void {\n const problems = unknownNames(own, layers, isSlotRecipe);\n if (problems.length === 0) {\n return;\n }\n const warning = `A recipe's config names variants, options, or slots that it does not declare, so they add nothing:\\n- ${problems.join(\"\\n- \")}`;\n if (!warned.has(warning)) {\n warned.add(warning);\n console.warn(warning);\n }\n}\n\nexport { unknownNames, warnUnknownNames };\n","import type {\n Composable,\n ComposableKindRecipe,\n ComposedKindRecipe,\n ComposedVariants,\n InheritedDefaultedName,\n} from \"./composition.js\";\nimport type {\n KindCompoundCondition,\n WrittenKindDefaults,\n} from \"./kind-selection.js\";\nimport type { LooseKindRecipeConfig, LooseRecipeKind } from \"./build-recipe.js\";\nimport type {\n LooseVariants,\n SelectedVariants,\n WithVariants,\n} from \"./variants.js\";\nimport type {\n RecipeFunction,\n RecipeKind,\n SelectionDefaults,\n VariantKey,\n VariantOptions,\n} from \"./types.js\";\nimport { compileLayer, compileMergedLayers } from \"./build-recipe.js\";\nimport { createRegistry, layerOf, mergeLayers } from \"./compose.js\";\nimport { checkRecipeConfig } from \"./check-config.js\";\nimport { createSelector } from \"./selector.js\";\nimport { warnUnknownNames } from \"./check-names.js\";\nimport { withVariants } from \"./variants.js\";\n\nconst recipes = createRegistry<unknown>(\"recipe\");\n\n/**\n * The variants of a {@link KindRecipeConfig}: for each variant name, the\n * value of each of its options.\n *\n * @typeParam Value - The value of an option.\n */\ntype KindVariants<Value> = LooseVariants<Value>;\n\n/**\n * A value added when several variants have particular options at the same\n * time.\n *\n * @typeParam Variants - The variant definitions of the recipe.\n * @typeParam Value - The value of an option.\n */\ninterface KindCompoundVariant<Variants, Value> {\n /**\n * The options that must all be selected for\n * {@link KindCompoundVariant.value} to apply.\n */\n readonly variants: KindCompoundCondition<Variants>;\n /** The value added when the condition matches. */\n readonly value: Value;\n}\n\n/**\n * The configuration of a recipe made from a {@link RecipeKind}.\n *\n * @typeParam Value - The value of an option.\n * @typeParam Variants - The variant definitions, keyed by variant name.\n * @typeParam DefaultedName - The names of the variants that have a default.\n * @typeParam Composed - The types of the recipes that the recipe composes.\n */\ninterface KindRecipeConfig<\n Value,\n Variants extends KindVariants<Value>,\n DefaultedName extends keyof ComposedVariants<Composed, Variants>,\n Composed extends readonly ComposableKindRecipe<Value>[] = readonly [],\n> {\n /**\n * Recipes whose config the recipe adds to its own, in order, as if it\n * were written in one config: their bases first, the values of each of\n * their options before its own, and their compound variants first. A\n * recipe composed several times counts once.\n */\n readonly composes?: Composed | undefined;\n /** The value that the values of every selection are added to. */\n readonly base?: Value | undefined;\n /** For each variant name, the value of each of its options. */\n readonly variants: Variants;\n /**\n * Values added when several variants have particular options at the same\n * time, applied in order after the values of the variants' options.\n */\n readonly compoundVariants?:\n | readonly KindCompoundVariant<\n NoInfer<ComposedVariants<Composed, Variants>>,\n Value\n >[]\n | undefined;\n /** The option each variant uses when the recipe is called without it. */\n readonly defaultVariants?:\n | WrittenKindDefaults<ComposedVariants<Composed, Variants>, DefaultedName>\n | undefined;\n /** Whether the recipe caches its results. Defaults to the kind's `cache`. */\n readonly cache?: boolean | undefined;\n}\n\n/**\n * A recipe made from a {@link RecipeKind}: a function that returns the\n * result of a selection of variants, with the names of those variants in\n * `variantKeys`, the names of their options in `variantOptions`, and the\n * option each uses when a selection leaves it out in `defaultVariants`.\n *\n * @typeParam Selection - The variants the recipe accepts.\n * @typeParam Result - What the recipe returns.\n * @typeParam Composition - What the recipe passes on to the recipes that\n * compose it, a `RecipeComposition`. Without it, the type does not\n * allow composing the recipe.\n */\ntype KindRecipe<Selection, Result, Composition = unknown> = RecipeFunction<\n Selection,\n Result\n> & {\n /**\n * The names of the recipe's variants, in the order of\n * `Object.keys(config.variants)`, after those of the recipes it\n * composes.\n */\n readonly variantKeys: readonly VariantKey<Selection>[];\n /**\n * The names of the options of each variant, as strings, in the order in\n * which the recipe numbers them: integer names first, then `\"false\"` and\n * `\"true\"`, which a variant that declares either one has, then the\n * others in the order of the config. A frozen object, keyed in the order\n * of `variantKeys`.\n */\n readonly variantOptions: VariantOptions<Selection>;\n /**\n * The option, as a string, that each variant uses when a selection\n * leaves it out: its default, or `\"false\"` for a variant whose only\n * options are `\"true\"` and `\"false\"`. A frozen object, keyed in the\n * order of `variantKeys`, without the variants that have no default.\n */\n readonly defaultVariants: SelectionDefaults<Selection>;\n} & Composable<Composition>;\n\n/**\n * Creates recipes of one kind, the function that {@link createRecipeKind}\n * returns.\n *\n * @typeParam Value - The value of an option.\n * @typeParam Result - What a recipe of this kind returns.\n * @param config - The base value, variants, compound variants, and default\n * variants of the recipe, and whether it caches its results.\n * @returns The recipe.\n */\ntype CreateKindRecipe<Value, Result> = <\n const Variants extends KindVariants<Value>,\n const DefaultedName extends keyof ComposedVariants<Composed, Variants> =\n never,\n const Composed extends readonly ComposableKindRecipe<Value>[] = readonly [],\n>(\n config: KindRecipeConfig<Value, Variants, DefaultedName, Composed>,\n) => ComposedKindRecipe<\n ComposedVariants<Composed, Variants>,\n DefaultedName | InheritedDefaultedName<Composed, Variants>,\n Value,\n Result,\n undefined\n>;\n\ntype LooseKindRecipe = WithVariants<\n (selection?: SelectedVariants | null) => unknown\n>;\n\n/**\n * Creates a kind of recipe from how it turns the values of a selection into\n * its result, and returns the function that creates recipes of that kind.\n * A recipe maps a selection of variants to a result, as `cva` of\n * `@lynstack/class-recipe` does for class names, for values of any type,\n * such as style objects.\n *\n * @remarks\n * For each selection, a recipe reduces the value of each variant's selected\n * option and the value of each matching compound variant, with\n * `kind.reduce`, into the accumulator that `kind.initial` returns for the\n * recipe's base, then passes it to `kind.finish`. A variant whose only\n * options are `\"true\"` and `\"false\"` defaults to `false`, an option that the\n * config does not declare adds no value, and properties of the selection\n * that are not variants are ignored. A recipe's `variantKeys` property lists\n * the names of its variants, `variantOptions` the names of the options of\n * each, and `defaultVariants` the option each uses when a selection leaves\n * it out, so that a library can list every selection of a recipe.\n *\n * Creating a recipe from a config with the wrong shape, such as one without\n * `variants`, throws a `TypeError` that names what is wrong. Creating a\n * recipe also warns once, with `console.warn`, about a default or a\n * compound variant's condition that names a variant or an option that no\n * config of the recipe declares. Such a default is ignored. A condition on\n * such a variant never matches, and such an option in a condition's list\n * of options is ignored.\n *\n * With the cache, a recipe builds the result of each declared selection\n * once, and calling it again with the same variants returns the same\n * result. Freeze an object result in `kind.finish` so that callers cannot\n * change a result that later calls share. A selection with an undeclared\n * option is built on every call. A recipe keeps up to one result for each\n * combination of declared options; set `cache: false` in the config of a\n * recipe whose variants come from untrusted input, which overrides the kind.\n *\n * When the variant names are not known at compile time, as in a library\n * that passes on a config it received, a recipe accepts any selection.\n *\n * A recipe composes the recipes listed in its config's `composes`, of any\n * kind whose values have its type, as if their configs and its own were one:\n * the accumulator starts from the first base, and the other bases are\n * reduced first; every option of each is declared, with its values reduced\n * in the order of the recipes; their compound variants come before its own;\n * and a variant's default is the last one given. A recipe composed several\n * times counts once. With `kind.combine`, the bases, and the values that\n * the recipes give one option, are combined into one when the recipe is\n * created, so that it reduces one value for each.\n *\n * @typeParam Value - The value of an option, inferred from the `value`\n * parameter of `kind.reduce` or the `base` parameter of `kind.initial`.\n * @typeParam Accumulator - What the values are reduced to, inferred from\n * `kind.initial`.\n * @typeParam Result - What a recipe returns, inferred from `kind.finish`,\n * or the accumulator without it.\n * @param kind - How a recipe turns the values of a selection into its\n * result, and whether it caches the result.\n * @returns The function that creates recipes of this kind.\n *\n * @example\n * ```ts\n * type Style = Readonly<Record<string, string | number>>;\n *\n * const styleRecipe = createRecipeKind({\n * initial: (base?: Style): Record<string, string | number> => ({ ...base }),\n * reduce: (style, value: Style) => Object.assign(style, value),\n * combine: (first, second) => ({ ...first, ...second }),\n * finish: (style): Style => Object.freeze(style),\n * });\n *\n * const text = styleRecipe({\n * base: { color: \"black\" },\n * variants: {\n * size: { sm: { fontSize: 12 }, lg: { fontSize: 24 } },\n * muted: { true: { opacity: 0.6 } },\n * },\n * compoundVariants: [\n * { variants: { size: \"lg\", muted: true }, value: { fontWeight: 300 } },\n * ],\n * defaultVariants: { size: \"sm\" },\n * });\n *\n * text(); // => { color: \"black\", fontSize: 12 }\n *\n * text({ size: \"lg\", muted: true });\n * // => { color: \"black\", fontSize: 24, opacity: 0.6, fontWeight: 300 }\n *\n * text.variantKeys; // => [\"size\", \"muted\"]\n * text.variantOptions; // => { size: [\"sm\", \"lg\"], muted: [\"false\", \"true\"] }\n * text.defaultVariants; // => { size: \"sm\", muted: \"false\" }\n *\n * const heading = styleRecipe({\n * composes: [text],\n * base: { fontWeight: 700 },\n * variants: { size: { xl: { fontSize: 32 } } },\n * });\n *\n * heading({ size: \"xl\" });\n * // => { color: \"black\", fontWeight: 700, fontSize: 32 }\n * ```\n */\nfunction createRecipeKind<Value, Accumulator, Result = Accumulator>(\n kind: RecipeKind<Value, Accumulator, Result>,\n): CreateKindRecipe<Value, Result>;\n\nfunction createRecipeKind(kind: LooseRecipeKind): unknown {\n const kindCache = kind.cache ?? true;\n\n return (config: LooseKindRecipeConfig): LooseKindRecipe => {\n const own = layerOf(checkRecipeConfig(config), []);\n const layers = recipes.layersOf(config.composes ?? [], own);\n warnUnknownNames(own, layers, false);\n const { compiled, build } =\n layers.length === 1\n ? compileLayer(kind, own)\n : compileMergedLayers(kind, mergeLayers(layers));\n const options = { cache: config.cache ?? kindCache };\n const recipe = createSelector(compiled, build, options);\n return recipes.withLayers(withVariants(recipe, compiled), layers);\n };\n}\n\nexport { createRecipeKind };\nexport type {\n CreateKindRecipe,\n KindCompoundVariant,\n KindRecipe,\n KindRecipeConfig,\n KindVariants,\n};\n","import type { CompiledVariants, Compound } from \"./variants.js\";\nimport { combineValues } from \"./compose.js\";\nimport { matches } from \"./reduce-values.js\";\nimport { noOption } from \"./variants.js\";\n\n/** Values for some slots, keyed by slot name, as the runtime takes them. */\ntype LooseSlotValues = Readonly<Record<string, unknown>>;\n\n/** The values of the `false` option a boolean variant of a slot recipe adds. */\nconst noSlotValues: readonly LooseSlotValues[] = Object.freeze([]);\n\n/** How the values of each slot are reduced, as a recipe kind gives it. */\ninterface SlotsKind {\n readonly initial: (base: unknown) => unknown;\n readonly reduce: (accumulator: unknown, value: unknown) => unknown;\n readonly combine?: ((first: unknown, second: unknown) => unknown) | undefined;\n readonly finish?: ((accumulator: unknown) => unknown) | undefined;\n}\n\n/** The slots of a slot recipe and their bases, in the order of its layers. */\ninterface SlotsConfig {\n readonly slots: readonly string[];\n readonly bases: readonly LooseSlotValues[];\n}\n\n/**\n * The values that one option or compound variant adds to its slots: the\n * index of each slot it gives a value, and that value at the same position.\n * Slots without a value are left out, so reducing skips them.\n */\ninterface SlotEntries {\n readonly slots: readonly number[];\n readonly values: readonly unknown[];\n}\n\n/**\n * The accumulator of each slot while a selection is reduced, which\n * {@link addEntries} updates in place.\n */\ninterface SlotAccumulators {\n readonly length: number;\n [slot: number]: unknown;\n}\n\nfunction valueOfSlot(\n values: LooseSlotValues | undefined,\n slot: string,\n): unknown {\n return values !== undefined && Object.hasOwn(values, slot)\n ? values[slot]\n : undefined;\n}\n\n/**\n * Returns the values of each slot in a list of values for some slots, in\n * the order of the list, combined into one with `combine` when the kind\n * has it.\n */\nfunction slotValuesOf(\n slots: readonly string[],\n valuesList: readonly LooseSlotValues[],\n combine: SlotsKind[\"combine\"],\n): readonly (readonly unknown[])[] {\n return slots.map((slot) => {\n const values = valuesList.flatMap((each) =>\n listOf(valueOfSlot(each, slot)),\n );\n return combine === undefined\n ? values\n : listOf(combineValues(values, combine));\n });\n}\n\n/**\n * Returns the entries of the values of each slot, by slot index, or\n * undefined when no slot has one.\n */\nfunction entriesBySlot(\n valuesBySlot: readonly (readonly unknown[])[],\n): SlotEntries | undefined {\n const slotIndexes = valuesBySlot.flatMap((values, slot) =>\n values.map(() => slot),\n );\n return slotIndexes.length === 0\n ? undefined\n : { slots: slotIndexes, values: valuesBySlot.flat() };\n}\n\nfunction listOf(value: unknown): readonly unknown[] {\n return value === undefined ? [] : [value];\n}\n\n/** Turns the slot values of each option and compound variant into entries. */\nfunction compileEntries(\n compiled: CompiledVariants<readonly LooseSlotValues[]>,\n slots: readonly string[],\n combine: SlotsKind[\"combine\"],\n): CompiledVariants<SlotEntries | undefined> {\n const entriesOf = (\n valuesList: readonly LooseSlotValues[],\n ): SlotEntries | undefined =>\n entriesBySlot(slotValuesOf(slots, valuesList, combine));\n return {\n ...compiled,\n compounds: compiled.compounds\n .map((compound): Compound<SlotEntries | undefined> => ({\n conditions: compound.conditions,\n value: entriesOf(compound.value),\n }))\n .filter((compound) => compound.value !== undefined),\n valuesByIndex: compiled.valuesByIndex.map((valuesOfVariant) =>\n valuesOfVariant.map((values) => entriesOf(values)),\n ),\n };\n}\n\n/** Reduces the values of `added` into the accumulators of their slots. */\nfunction addEntries(\n accumulators: SlotAccumulators,\n added: SlotEntries,\n reduce: SlotsKind[\"reduce\"],\n): void {\n const { slots, values } = added;\n for (let entry = 0; entry < slots.length; entry += 1) {\n const slot = slots[entry] ?? 0;\n accumulators[slot] = reduce(accumulators[slot], values[entry]);\n }\n}\n\n/**\n * The names of a slot recipe's slots, and an object with a property for\n * each, which results copy so that assigning a slot named `__proto__` sets\n * that property instead of the prototype.\n */\ninterface SlotNames {\n readonly names: readonly string[];\n readonly template: Readonly<Record<string, unknown>>;\n}\n\n/** Returns the frozen result of each slot, keyed by slot name. */\nfunction resultsBySlot(\n slots: SlotNames,\n accumulators: SlotAccumulators,\n finish: (accumulator: unknown) => unknown,\n): Readonly<Record<string, unknown>> {\n const { names } = slots;\n const results: Record<string, unknown> = { ...slots.template };\n for (let slot = 0; slot < names.length; slot += 1) {\n results[names[slot] ?? \"\"] = finish(accumulators[slot]);\n }\n return Object.freeze(results);\n}\n\nconst asResult = (accumulator: unknown): unknown => accumulator;\n\n/**\n * Returns the function that builds the result of a selection for each slot\n * of a slot recipe: each slot reduces its own values with `kind`, and the\n * results are frozen in an object keyed by slot name.\n *\n * It reduces the values in a loop of its own instead of through\n * `reduceValues`, which recipes share, so that its calls to `kind.reduce`\n * see only the reducers of slot recipes and can be inlined.\n */\nfunction createSlotsBuilder(\n kind: SlotsKind,\n compiled: CompiledVariants<readonly LooseSlotValues[]>,\n config: SlotsConfig,\n): (indexes: Int32Array) => Readonly<Record<string, unknown>> {\n const { initial, reduce, combine, finish = asResult } = kind;\n const names = [...config.slots];\n const slotNames: SlotNames = {\n names,\n template: Object.fromEntries(names.map((slot) => [slot, undefined])),\n };\n const basesBySlot = slotValuesOf(names, config.bases, combine);\n const bases = basesBySlot.map(([base]: readonly unknown[]) => base);\n const otherBases = entriesBySlot(\n basesBySlot.map(([, ...others]: readonly unknown[]) => others),\n );\n const { valuesByIndex, compounds } = compileEntries(compiled, names, combine);\n\n /** Returns the accumulator of each slot, with every base reduced. */\n const initialAccumulators = (): SlotAccumulators => {\n const accumulators = bases.map((base) => initial(base));\n if (otherBases !== undefined) {\n addEntries(accumulators, otherBases, reduce);\n }\n return accumulators;\n };\n\n return (indexes) => {\n const accumulators = initialAccumulators();\n for (let variant = 0; variant < valuesByIndex.length; variant += 1) {\n const added = valuesByIndex[variant]?.[indexes[variant] ?? noOption];\n if (added !== undefined) {\n addEntries(accumulators, added, reduce);\n }\n }\n for (const compound of compounds) {\n if (compound.value !== undefined && matches(compound, indexes)) {\n addEntries(accumulators, compound.value, reduce);\n }\n }\n return resultsBySlot(slotNames, accumulators, finish);\n };\n}\n\nexport { createSlotsBuilder, noSlotValues };\nexport type { LooseSlotValues, SlotsKind };\n","import type {\n ComposableKindSlotRecipe,\n ComposedKindRecipe,\n ComposedVariants,\n InheritedDefaultedName,\n InheritedSlot,\n} from \"./composition.js\";\nimport type {\n KindCompoundCondition,\n SlotVariantsCheck,\n WrittenKindDefaults,\n} from \"./kind-selection.js\";\nimport type { LooseSlotValues, SlotsKind } from \"./slots.js\";\nimport type { SelectedVariants, WithVariants } from \"./variants.js\";\nimport { compileVariants, withVariants } from \"./variants.js\";\nimport { createRegistry, layerOf, mergeLayers } from \"./compose.js\";\nimport { createSlotsBuilder, noSlotValues } from \"./slots.js\";\nimport type { KindVariants } from \"./recipe-kind.js\";\nimport type { RecipeKind } from \"./types.js\";\nimport { checkSlotRecipeConfig } from \"./check-config.js\";\nimport { createSelector } from \"./selector.js\";\nimport { warnUnknownNames } from \"./check-names.js\";\n\nconst slotRecipes = createRegistry<LooseSlotValues>(\"slot recipe\");\n\n/**\n * Values for some of a slot recipe's slots, keyed by slot name.\n *\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n */\ntype SlotValues<Slot extends string, Value> = {\n readonly [Name in Slot]?: Value | undefined;\n};\n\n/**\n * The variants of a {@link KindSlotRecipeConfig}: for each variant name,\n * the values of each slot for each of its options.\n *\n * @typeParam Value - The value of a slot.\n */\ntype KindSlotVariants<Value> = KindVariants<SlotValues<string, Value>>;\n\n/**\n * Values added to some slots when several variants have particular options\n * at the same time.\n *\n * @typeParam Variants - The variant definitions of the slot recipe.\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n */\ninterface KindSlotCompoundVariant<Variants, Slot extends string, Value> {\n /**\n * The options that must all be selected for\n * {@link KindSlotCompoundVariant.value} to apply.\n */\n readonly variants: KindCompoundCondition<Variants>;\n /** The value added to each slot when the condition matches. */\n readonly value: SlotValues<Slot, Value>;\n}\n\n/**\n * The configuration of a slot recipe made from a {@link RecipeKind}.\n *\n * @typeParam Slot - The names of the slots.\n * @typeParam Value - The value of a slot.\n * @typeParam Variants - The variant definitions, keyed by variant name.\n * @typeParam DefaultedName - The names of the variants that have a default.\n */\ninterface KindSlotRecipeConfig<\n Slot extends string,\n Value,\n Variants extends KindSlotVariants<Value>,\n DefaultedName extends keyof ComposedVariants<Composed, Variants>,\n Composed extends readonly ComposableKindSlotRecipe<Value>[] = readonly [],\n> {\n /**\n * Slot recipes whose config the recipe adds to its own, in order, as if\n * it were written in one config: their slots and bases first, the values\n * of each of their options before its own, and their compound variants\n * first. A slot recipe composed several times counts once.\n */\n readonly composes?: Composed | undefined;\n /**\n * The names of the slots, in the order of the recipe's result, after\n * those of the slot recipes it composes. A name of a property that every\n * object has, such as `toString`, is not supported.\n */\n readonly slots: readonly Slot[];\n /** The value of each slot that the values of every selection are added to. */\n readonly base?:\n SlotValues<NoInfer<Slot> | InheritedSlot<Composed>, Value> | undefined;\n /** For each variant name, the values of each slot for each of its options. */\n readonly variants: Variants &\n SlotVariantsCheck<Variants, NoInfer<Slot>, InheritedSlot<Composed>, Value>;\n /**\n * Values added to some slots when several variants have particular\n * options at the same time, applied in order after the values of the\n * variants' options.\n */\n readonly compoundVariants?:\n | readonly KindSlotCompoundVariant<\n NoInfer<ComposedVariants<Composed, Variants>>,\n NoInfer<Slot> | InheritedSlot<Composed>,\n Value\n >[]\n | undefined;\n /** The option each variant uses when the recipe is called without it. */\n readonly defaultVariants?:\n | WrittenKindDefaults<ComposedVariants<Composed, Variants>, DefaultedName>\n | undefined;\n /** Whether the recipe caches its results. Defaults to the kind's `cache`. */\n readonly cache?: boolean | undefined;\n}\n\n/**\n * Creates slot recipes of one kind, the function that\n * {@link createSlotRecipeKind} returns.\n *\n * @typeParam Value - The value of a slot.\n * @typeParam Result - What a recipe of this kind returns for each slot.\n * @param config - The slot recipes it composes, and the slots, base values,\n * variants, compound variants, and default variants of the slot recipe,\n * and whether it caches its results.\n * @returns The slot recipe.\n */\ntype CreateKindSlotRecipe<Value, Result> = <\n const Slot extends string,\n const Variants extends KindSlotVariants<Value>,\n const DefaultedName extends keyof ComposedVariants<Composed, Variants> =\n never,\n const Composed extends readonly ComposableKindSlotRecipe<Value>[] =\n readonly [],\n>(\n config: KindSlotRecipeConfig<Slot, Value, Variants, DefaultedName, Composed>,\n) => ComposedKindRecipe<\n ComposedVariants<Composed, Variants>,\n DefaultedName | InheritedDefaultedName<Composed, Variants>,\n Value,\n // Not ComposedSlot, which declarations print with each composed type.\n Readonly<\n Record<\n | Slot\n | Exclude<Composed[number][\"~composition\"], undefined>[\"slots\"][number],\n Result\n >\n >,\n readonly (\n Slot | Exclude<Composed[number][\"~composition\"], undefined>[\"slots\"][number]\n )[]\n>;\n\ninterface LooseRecipeKind extends SlotsKind {\n readonly cache?: boolean | undefined;\n}\n\ninterface LooseSlotRecipeConfig {\n readonly composes?: readonly unknown[] | undefined;\n readonly slots: readonly string[];\n readonly base?: LooseSlotValues | undefined;\n readonly variants: KindSlotVariants<unknown>;\n readonly compoundVariants?:\n | readonly {\n readonly variants: SelectedVariants;\n readonly value: LooseSlotValues;\n }[]\n | undefined;\n readonly defaultVariants?: SelectedVariants | undefined;\n readonly cache?: boolean | undefined;\n}\n\ntype LooseSlotRecipe = WithVariants<\n (selection?: SelectedVariants | null) => Readonly<Record<string, unknown>>\n>;\n\n/**\n * Creates a kind of slot recipe from how it turns the values of each slot\n * into that slot's result, and returns the function that creates slot\n * recipes of that kind. A slot recipe maps a selection of variants to the\n * result of each of several slots, such as the class names or the styles of\n * the elements of a component, as `sva` of `@lynstack/class-recipe` does.\n *\n * @remarks\n * A slot recipe reduces the values of each slot as a recipe of the same\n * kind from {@link createRecipeKind} would: `kind.initial` returns the\n * accumulator for the slot's base value, `kind.reduce` adds the slot's\n * value of each variant's selected option, in the order of `variants`, and\n * of each matching compound variant, in the order of `compoundVariants`,\n * and `kind.finish` turns the accumulator into the slot's result. A slot\n * without values gets the result of its accumulator for an `undefined`\n * base, so every slot is in the result.\n *\n * The result is a frozen object of each slot's result, keyed by slot name\n * in the order of `slots`. With the cache, a slot recipe builds it once for\n * each declared selection and returns the same object for the same\n * variants. The `cache` of a slot recipe's config overrides the kind's.\n * Variants, boolean variants, undeclared options, the `TypeError` for a\n * config with the wrong shape, the warning about undeclared names, and the\n * `variantKeys`, `variantOptions`, and `defaultVariants` properties are as\n * in {@link createRecipeKind}. It also\n * warns about a value for a slot that no config lists in `slots`, which is\n * ignored.\n *\n * A slot recipe composes the slot recipes listed in `composes` as a recipe\n * composes recipes, and has the slots of each, theirs first. With\n * `kind.combine`, the values of each slot are combined as a recipe's are.\n *\n * @typeParam Value - The value of a slot, inferred from the `value`\n * parameter of `kind.reduce` or the `base` parameter of `kind.initial`.\n * @typeParam Accumulator - What the values of a slot are reduced to,\n * inferred from `kind.initial`.\n * @typeParam Result - What a slot recipe returns for each slot, inferred\n * from `kind.finish`, or the accumulator without it.\n * @param kind - How a slot recipe turns the values of each slot into its\n * result, and whether it caches its results. The same kind can create\n * recipes with {@link createRecipeKind}.\n * @returns The function that creates slot recipes of this kind.\n *\n * @example\n * ```ts\n * type Style = Readonly<Record<string, string | number>>;\n *\n * const styleKind = {\n * initial: (base?: Style): Record<string, string | number> => ({ ...base }),\n * reduce: (style: Record<string, string | number>, value: Style) =>\n * Object.assign(style, value),\n * finish: (style: Record<string, string | number>): Style =>\n * Object.freeze(style),\n * };\n *\n * const slotStyleRecipe = createSlotRecipeKind(styleKind);\n *\n * const card = slotStyleRecipe({\n * slots: [\"root\", \"title\"],\n * base: { root: { padding: 16 }, title: { fontSize: 18 } },\n * variants: {\n * tone: {\n * light: { root: { backgroundColor: \"white\" } },\n * dark: { root: { backgroundColor: \"black\" }, title: { color: \"white\" } },\n * },\n * },\n * compoundVariants: [\n * { variants: { tone: \"dark\" }, value: { title: { fontWeight: 600 } } },\n * ],\n * defaultVariants: { tone: \"light\" },\n * });\n *\n * card();\n * // => { root: { padding: 16, backgroundColor: \"white\" }, title: { fontSize: 18 } }\n *\n * card({ tone: \"dark\" });\n * // => {\n * // root: { padding: 16, backgroundColor: \"black\" },\n * // title: { fontSize: 18, color: \"white\", fontWeight: 600 },\n * // }\n *\n * card.variantOptions; // => { tone: [\"light\", \"dark\"] }\n * card.defaultVariants; // => { tone: \"light\" }\n *\n * const dialog = slotStyleRecipe({\n * composes: [card],\n * slots: [\"footer\"],\n * variants: { tone: { dark: { footer: { borderColor: \"white\" } } } },\n * });\n *\n * dialog({ tone: \"dark\" }).footer; // => { borderColor: \"white\" }\n * ```\n */\nfunction createSlotRecipeKind<Value, Accumulator, Result = Accumulator>(\n kind: RecipeKind<Value, Accumulator, Result>,\n): CreateKindSlotRecipe<Value, Result>;\n\nfunction createSlotRecipeKind(kind: LooseRecipeKind): unknown {\n const kindCache = kind.cache ?? true;\n\n return (config: LooseSlotRecipeConfig): LooseSlotRecipe => {\n const own = layerOf(checkSlotRecipeConfig(config), config.slots);\n const layers = slotRecipes.layersOf(config.composes ?? [], own);\n warnUnknownNames(own, layers, true);\n const merged = mergeLayers(layers);\n const compiled = compileVariants<readonly LooseSlotValues[]>({\n ...merged,\n noValue: noSlotValues,\n });\n const build = createSlotsBuilder(kind, compiled, merged);\n const options = { cache: config.cache ?? kindCache };\n const recipe = createSelector(compiled, build, options);\n return slotRecipes.withLayers(withVariants(recipe, compiled), layers);\n };\n}\n\nexport { createSlotRecipeKind };\nexport type {\n CreateKindSlotRecipe,\n KindSlotCompoundVariant,\n KindSlotRecipeConfig,\n KindSlotVariants,\n SlotValues,\n};\n"],"mappings":"AA8DA,MAAM,UAA4B,OAAO,OAAO,CAAC,CAAC;;;;;;;;;AAUlD,SAAS,gBACP,QACyB;CACzB,MAAM,QAAQ,OAAO,KAAK,OAAO,QAAQ;CACzC,MAAM,eAAe,MAAM,KAAK,SAC9B,mBAAmB,OAAO,SAAS,SAAS,CAAC,GAAG,OAAO,OAAO,CAChE;CACA,MAAM,gBACJ,aAAa,KACV,mBACC,IAAI,IACF,OAAO,KAAK,cAAc,CAAC,CAAC,KAAK,QAAQ,U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,sBAAsB,MAAM,GAAG,OAAO,KAAK;EAC/D,MAAM,SAAS,YAAY,SAAS,OAAO,YAAY,CAAC,GAAG,GAAG;EAC9D,iBAAiB,KAAK,QAAQ,IAAI;EAClC,MAAM,SAAS,YAAY,MAAM;EACjC,MAAM,WAAW,gBAA4C;GAC3D,GAAG;GACH,SAAS;EACX,CAAC;EAGD,MAAM,SAAS,eAAe,UAFhB,mBAAmB,MAAM,UAAU,MAET,GAAO,EAD7B,OAAO,OAAO,SAAS,UACM,CAAO;EACtD,OAAO,YAAY,WAAW,aAAa,QAAQ,QAAQ,GAAG,MAAM;CACtE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynstack/recipe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Fast, type-safe recipes for values of any type: define how a kind of recipe combines values, such as class names or styles, then create recipes of that kind.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"recipe",
|