@weasel-js/prefs 1.9.4 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as PrefLeaf, a as PrefGroup, b as PrefSection, c as PrefNumber, d as PrefObject, e as PrefsStore, f as PrefKind } from './store-CNFnA_3c.js';
2
- export { B as BuiltinPref, g as PREF_KINDS, h as PrefAction, i as PrefActionContext, j as PrefActionControl, k as PrefAlias, l as PrefAtPath, m as PrefBase, n as PrefBoolean, o as PrefBooleanControl, p as PrefBooleanEncoding, q as PrefChange, r as PrefColor, s as PrefCustom, t as PrefEnum, u as PrefEnumBase, v as PrefEnumControl, w as PrefEnumEncoding, x as PrefField, y as PrefGroupAs, z as PrefLabel, A as PrefList, C as PrefMap, D as PrefNumberControl, E as PrefNumberUnit, F as PrefPaint, G as PrefPair, H as PrefPath, I as PrefSectionAs, J as PrefSeparator, K as PrefString, L as PrefStringControl, M as PrefUnion, N as PrefValueAt, O as PrefValueOf, Q as isBuiltinPref, R as pairRowsOf, S as prefAliasTarget, T as prefAliasedLeaf, U as prefGroupIsPage, V as prefUnit, W as prefVariantDefault, X as prefVariantOf } from './store-CNFnA_3c.js';
3
- import { StorageAdapter, SyncStorageAdapter } from '@weasel-js/storage';
1
+ import { P as PrefLeaf, a as PrefGroup, b as PrefSection, c as PrefNumber, d as PrefList, e as PrefMap, f as PrefCondition, g as PrefConditionReader, h as PrefBoolean, i as PrefString, j as PrefColor, k as PrefEnumBase, l as PrefSelection, m as PrefLocus, n as PrefAlias, o as PrefObject, p as PrefKind } from './open-C83pU7Va.js';
2
+ export { B as BuiltinPref, q as PREF_BLENDS, r as PREF_KINDS, s as PrefAction, t as PrefActionContext, u as PrefActionControl, v as PrefAtPath, w as PrefBarOverflow, x as PrefBase, y as PrefBlend, z as PrefBooleanControl, A as PrefBooleanEncoding, C as PrefChange, D as PrefConditionValue, E as PrefCustom, F as PrefEnum, G as PrefEnumControl, H as PrefEnumEncoding, I as PrefField, J as PrefFunctionUnit, K as PrefGroupAs, L as PrefLabel, M as PrefLinearUnit, N as PrefNumberControl, O as PrefNumberUnit, Q as PrefPaint, R as PrefPair, S as PrefPath, T as PrefSectionAs, U as PrefSeparator, V as PrefStringControl, W as PrefTest, X as PrefUnion, Y as PrefValidator, Z as PrefValueAt, _ as PrefValueOf, $ as PrefWeighted, a0 as PrefWeights, a1 as PrefsMigration, a2 as PrefsOptions, a3 as PrefsStore, a4 as ResolvedPrefUnit, a5 as isBuiltinPref, a6 as isPrefCondition, a7 as isPrefLinearUnit, a8 as isPrefLocus, a9 as mapPrefConditionPaths, aa as openPrefs, ab as openPrefsSync, ac as pairRowsOf, ad as prefAliasName, ae as prefAliasTarget, af as prefAliasedLeaf, ag as prefConditionHolds, ah as prefConditionPaths, ai as prefConditionReadsItem, aj as prefGroupIsPage, ak as prefIsEnabled, al as prefIsShown, am as prefLocusMember, an as prefLocusSelectors, ao as prefUnit, ap as prefVariantDefault, aq as prefVariantOf, ar as repairPrefValue, as as resolvePrefUnit } from './open-C83pU7Va.js';
3
+ import '@weasel-js/storage';
4
4
  import '@weasel-js/quantity';
5
5
 
6
6
  /**
@@ -59,17 +59,356 @@ declare function prefLeaves(schema: PrefGroup): Map<string, PrefLeaf>;
59
59
  declare function flattenPrefValues(schema: PrefGroup, tree: unknown): [string, unknown][];
60
60
  /**
61
61
  * Drop every leaf that does not answer to `query`, pruning groups left empty.
62
- * A group whose own name matches keeps all of its leaves — a reader who typed
63
- * the group's name is asking for the group, not for leaves repeating it.
64
- *
65
- * An empty or whitespace query matches everything, so a cleared field restores
66
- * the tree rather than emptying it.
62
+ * A group whose own name matches keeps all of its leaves. An empty or
63
+ * whitespace query matches everything.
67
64
  *
68
65
  * An alias answers as the row it draws: its target's name and description
69
- * where it gives none. `leafAt` finds that target, and defaults to looking in
70
- * `node`; pass one over the whole schema when `node` is a part of it.
66
+ * where it gives none. That target is looked for in `over`, and in `node`
67
+ * without it; pass the whole schema when `node` is a part of it.
68
+ */
69
+ declare function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, query: string, path?: string, over?: PrefGroup | PrefSection): T | null;
70
+
71
+ /** One step of a walk over a group's children: a child on its own, or the neighboring `tab` children that share one strip. */
72
+ type PrefTabRun<T> = {
73
+ item: T;
74
+ tabs?: undefined;
75
+ } | {
76
+ tabs: readonly T[];
77
+ item?: undefined;
78
+ };
79
+ /**
80
+ * `items` in order, each run of neighbors `isTab` holds for folded into one step. What a surface leaves out of
81
+ * `items` neither joins a run nor ends one, and what it keeps and then declines to draw still holds its run together.
82
+ */
83
+ declare function prefTabRuns<T>(items: readonly T[], isTab: (item: T) => boolean): PrefTabRun<T>[];
84
+
85
+ /** One thing wrong with a condition: it is not one, it reads a path no leaf
86
+ * holds a value at, it compares a leaf against a value it never holds, it
87
+ * never holds whatever the leaf does, as an `in` of no values, it is the
88
+ * `showIf` of a list's or a map's item, which is drawn with each entry, or
89
+ * it reads from the entry on a node that no list or map draws. */
90
+ interface PrefConditionProblem {
91
+ code: 'malformed' | 'no-leaf' | 'no-value' | 'value' | 'never' | 'item-show' | 'no-item';
92
+ /** The path read, where the problem is with one. */
93
+ path?: string;
94
+ problem: string;
95
+ }
96
+ /** A {@link PrefConditionProblem} and the node whose condition has it. */
97
+ interface PrefSchemaConditionProblem extends PrefConditionProblem {
98
+ /**
99
+ * Where the node sits: a key per step from the root, `''` for the root
100
+ * itself. An object leaf's fields and sections, a union's variants, and a
101
+ * list's or a map's `item` are steps too, so this is not always a path a
102
+ * value is read at.
103
+ */
104
+ at: string;
105
+ field: 'showIf' | 'enableIf';
106
+ }
107
+ /** Where the node holding a condition sits, for what a condition alone does not say. */
108
+ interface PrefConditionSite {
109
+ /** The nearest list or map the node is inside an entry of: the one it is the `item` of, or one above it. */
110
+ within?: PrefList | PrefMap;
111
+ /** The condition is the `showIf` of that list's or map's `item` itself. */
112
+ itemShowIf?: boolean;
113
+ }
114
+ /**
115
+ * What is wrong with `condition` as one of `schema`'s: every part of it that
116
+ * is not a condition, every path it reads that no leaf holds a value at,
117
+ * every comparison against a value the leaf's kind or options rule out, and
118
+ * every `in` of no values.
119
+ * `null` is never ruled out, and neither is anything under an app-defined
120
+ * kind or inside a list, a map, or a paint, which the schema does not
121
+ * describe. Takes `unknown`, since a schema read from JSON or built without
122
+ * types may hold anything where a condition goes. `site` says where the
123
+ * condition's node sits; without it the node is taken to be outside every
124
+ * list and map. A path read from the entry is held to the `item` of
125
+ * `site.within`, and is a problem where there is none. `over` is the schema
126
+ * `schema` is drawn over: a path no leaf of `schema` holds is held to it,
127
+ * and is a problem only where it holds none either.
128
+ */
129
+ declare function checkPrefCondition(condition: unknown, schema: PrefGroup | PrefSection, site?: PrefConditionSite, over?: PrefGroup | PrefSection): PrefConditionProblem[];
130
+ /** {@link checkPrefCondition} over every `showIf` and `enableIf` in `schema`, in schema order, each held to `over` as well. */
131
+ declare function checkPrefConditions(schema: PrefGroup | PrefSection, over?: PrefGroup | PrefSection): PrefSchemaConditionProblem[];
132
+
133
+ /** Which of a node's two conditions a {@link PrefConditionJudge} is asked about. */
134
+ type PrefConditionField = 'showIf' | 'enableIf';
135
+ /**
136
+ * Says whether one condition holds. {@link prefJudge} makes one from a value
137
+ * reader; a surface drawing several values at once writes its own, to say
138
+ * what a condition that holds for some and not for others comes to.
139
+ */
140
+ type PrefConditionJudge = (condition: PrefCondition, field: PrefConditionField) => boolean;
141
+ /** One entry of a list or a map: the `item` leaf describing it, and what it holds. */
142
+ interface PrefEntry {
143
+ item: PrefLeaf;
144
+ value: unknown;
145
+ }
146
+ /**
147
+ * A judge over one set of values, read by path. A condition compares each
148
+ * value as the control over its leaf in `schema` shows it
149
+ * ({@link prefShownReader}), so `read` hands back what is stored. A test
150
+ * that reads from the entry (`from: 'item'`) reads `entry`, and finds nothing
151
+ * held where none is given. `over` is the schema `schema` is drawn over: a
152
+ * path no leaf of `schema` holds is compared as the leaf of `over` there
153
+ * shows it.
154
+ */
155
+ declare function prefJudge(schema: PrefGroup | PrefSection, read: (path: string) => unknown, entry?: PrefEntry, over?: PrefGroup | PrefSection): PrefConditionJudge;
156
+ /**
157
+ * Reads a value by path the way a form over `schema` shows it: what `values`
158
+ * holds there, else the default of the leaf at that path, or the part of a
159
+ * leaf's default the rest of the path names. `over` is the schema `schema`
160
+ * is drawn over: a path no leaf of `schema` holds takes its default there.
161
+ */
162
+ declare function prefReader(schema: PrefGroup | PrefSection, values: unknown, over?: PrefGroup | PrefSection): (path: string) => unknown;
163
+
164
+ /** Whether a node is drawn and whether it takes input, with what is above it counted. */
165
+ interface PrefScope {
166
+ shown: boolean;
167
+ enabled: boolean;
168
+ }
169
+ /** The step that stands for any entry of a `list` or a `map` in a path: `'phases.*.hold'` answers for that field of
170
+ * each, by every condition that comes to the same for every entry. */
171
+ declare const PREF_ENTRY = "*";
172
+ /** The scope a schema's root sits in. */
173
+ declare const PREF_SCOPE: PrefScope;
174
+ /** The scope of `node`, which sits directly under something whose scope is `above`. */
175
+ declare function prefScopeUnder(above: PrefScope, node: {
176
+ showIf?: PrefCondition;
177
+ enableIf?: PrefCondition;
178
+ }, holds: PrefConditionJudge): PrefScope;
179
+ /** What {@link prefScopeAt} is told beyond the schema. */
180
+ interface PrefScopeAtOptions {
181
+ /** The schema an alias's `of` names a leaf of. Default: the schema asked. */
182
+ aliasOver?: PrefGroup | PrefSection;
183
+ /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */
184
+ aliasHolds?: PrefConditionJudge;
185
+ }
186
+ /**
187
+ * The scope of the node at `path`: a group, a leaf, a field of an `object`
188
+ * or a `union` leaf, or an entry of a `list` or a `map`, whose step may be
189
+ * any key. Under a {@link PrefSection} schema a leaf's key is its whole
190
+ * path. A path that runs past the schema answers for the last node it
191
+ * reaches. An alias answers for itself and for the leaf it shows, as
192
+ * `applyPrefConditions` has it. Inside an entry, a condition that reads the
193
+ * entry (`from: 'item'`) is not asked and counts as holding, there being no
194
+ * entry here to read: `applyPrefEntryConditions` answers it.
195
+ */
196
+ declare function prefScopeAt(schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge, { aliasOver, aliasHolds }?: PrefScopeAtOptions): PrefScope;
197
+
198
+ /** A schema with its conditions applied. */
199
+ interface PrefConditionsApplied<T> {
200
+ /** The schema without the nodes that are not shown. The schema itself when
201
+ * that is all of it, and `null` when its root is not shown. */
202
+ shown: T | null;
203
+ /**
204
+ * The value path of every leaf that is disabled, a field of an `object` or
205
+ * a `union` leaf included (`'stroke.width'`), and under a {@link PrefGroup}
206
+ * schema the path of every group that is. A `list`'s or a `map`'s item is
207
+ * named once for every entry, with {@link PREF_ENTRY} as the entry's step:
208
+ * `'phases.*'`, and `'phases.*.hold'` for a field of it.
209
+ */
210
+ disabled: ReadonlySet<string>;
211
+ /**
212
+ * With `keepHidden`, the path of everything `shown` holds that is not
213
+ * shown, named as `disabled` names what is disabled. Empty without it,
214
+ * since `shown` then holds none.
215
+ */
216
+ hidden: ReadonlySet<string>;
217
+ }
218
+ /** How {@link applyPrefConditions} treats what it would leave out. */
219
+ interface PrefConditionsOptions {
220
+ /** Keep a group or a section that leaves with nothing to draw. */
221
+ keepEmpty?: boolean;
222
+ /**
223
+ * Keep every node whose `showIf` fails, and name it in `hidden`: for a
224
+ * surface that edits the schema, where a node not drawn cannot be picked.
225
+ */
226
+ keepHidden?: boolean;
227
+ /** The schema an alias's `of` names a leaf of. Default: the schema walked. */
228
+ aliasOver?: PrefGroup | PrefSection;
229
+ /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */
230
+ aliasHolds?: PrefConditionJudge;
231
+ }
232
+ /**
233
+ * `schema` as it is drawn while `holds` says which conditions hold. A node
234
+ * whose `showIf` fails is dropped with everything under it, unless
235
+ * `keepHidden`, and so is a group or a section that leaves with nothing to
236
+ * draw, unless `keepEmpty`. A node
237
+ * whose `enableIf` fails is disabled with everything under it. The item of
238
+ * a `list` or a `map` is walked as its entries are drawn: its fields hide and
239
+ * disable by their conditions, and its own `enableIf` disables every entry.
240
+ * A condition there that reads the entry (`from: 'item'`) has no one answer
241
+ * for every entry and is left holding: {@link applyPrefEntryConditions}
242
+ * answers it for each.
243
+ * An alias is shown only while it and the leaf it shows both are, and enabled
244
+ * only while both are, with everything above that leaf counted. That leaf is
245
+ * looked for in `aliasOver`, and its side is asked of `aliasHolds`.
246
+ * Parts with nothing dropped come back as the objects they were.
247
+ */
248
+ declare function applyPrefConditions<T extends PrefGroup | PrefSection>(schema: T, holds: PrefConditionJudge, { keepEmpty, keepHidden, aliasOver, aliasHolds }?: PrefConditionsOptions): PrefConditionsApplied<T>;
249
+ /** One entry of a list or a map with the conditions that read it applied. */
250
+ interface PrefEntryApplied {
251
+ /** The item as this entry draws it: without the fields not shown, and the item itself when that is all of them. */
252
+ item: PrefLeaf;
253
+ /** The path of the entry, and of every field in it, that is disabled, named as {@link PrefConditionsApplied} names them. */
254
+ disabled: ReadonlySet<string>;
255
+ /** With `keepHidden`, the path of every field of the entry that is not shown. */
256
+ hidden: ReadonlySet<string>;
257
+ }
258
+ /**
259
+ * The conditions {@link applyPrefConditions} leaves unanswered, answered for
260
+ * one entry: `item`, as that pass left it, drawn for the entry at `path`
261
+ * (`'phases.2'`) while `holds` says which conditions hold. `holds` reads the
262
+ * entry: `prefJudge` given it. Only a condition that reads the entry is
263
+ * asked, the rest being applied already, and one inside a list or a map
264
+ * within the entry is left for that one's own entries.
71
265
  */
72
- declare function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, query: string, path?: string, leafAt?: (path: string) => PrefLeaf | undefined): T | null;
266
+ declare function applyPrefEntryConditions(item: PrefLeaf, path: string, holds: PrefConditionJudge, { keepEmpty, keepHidden }?: Pick<PrefConditionsOptions, 'keepEmpty' | 'keepHidden'>): PrefEntryApplied;
267
+
268
+ /** What the control over `leaf` shows for `stored`: what its `encoding` reads it as, else `stored` itself.
269
+ * `siblings` is the object the leaf is a field of. */
270
+ declare function prefShownValue(leaf: PrefLeaf, stored: unknown, siblings?: Record<string, unknown>): unknown;
271
+ /**
272
+ * `read` with each value handed back as {@link prefShownValue} gives it, for
273
+ * the leaf of `schema` at that path, a field of an `object` or a `union` leaf
274
+ * included. A field's siblings are what `read` finds at its leaf's path. A
275
+ * path read from the entry is held to `item`, the leaf describing that entry.
276
+ * A path no leaf of `schema` holds is held to `over`, the schema it is drawn
277
+ * over.
278
+ */
279
+ declare function prefShownReader(schema: PrefGroup | PrefSection, read: PrefConditionReader, item?: PrefLeaf, over?: PrefGroup | PrefSection): PrefConditionReader;
280
+
281
+ /** One thing wrong with a leaf's `splitBy`. */
282
+ interface PrefSplitProblem {
283
+ code: 'valueless' | 'no-leaf' | 'not-enum' | 'encoded' | 'clearable' | 'split' | 'twice' | 'default';
284
+ /** The path of the leaf whose `splitBy` it is. */
285
+ at: string;
286
+ /** The entry of `splitBy` the problem is with, where it is with one. */
287
+ path?: string;
288
+ problem: string;
289
+ }
290
+ /** Everything wrong with the `splitBy` lists of `schema`'s leaves, in schema order. */
291
+ declare function checkPrefSplits(schema: PrefGroup): PrefSplitProblem[];
292
+
293
+ /** What a builder takes after the leaf's name and default: any of the leaf's other fields. */
294
+ type Rest<L> = Partial<Omit<L, 'kind' | 'name' | 'default'>>;
295
+ /** One option of an enum, or its value alone, which is labeled with the value's first letter raised. */
296
+ type OptionOf<T extends string> = T | PrefEnumBase<T>['options'][number];
297
+ /**
298
+ * Builders for a preferences schema, each returning what the literal would
299
+ * hold. `pref.group('View', { grid: pref.boolean('Grid', true) })` is
300
+ * `{ name: 'View', children: { grid: { kind: 'boolean', name: 'Grid', description: '', default: true } } }`,
301
+ * and its paths and value types are read from it the same way.
302
+ */
303
+ declare const pref: {
304
+ /** A group: `children` nest under its key, which is a segment of their paths. */
305
+ group<const C extends Record<string, PrefLeaf | PrefGroup>>(name: string, children: C, options?: Omit<PrefGroup, "name" | "children">): Omit<PrefGroup, "children"> & {
306
+ children: C;
307
+ };
308
+ /** A section: a heading over `members`, whose key adds nothing to their paths. */
309
+ section<const M extends Record<string, PrefLeaf | PrefSection>>(name: string, members: M, options?: Omit<PrefSection, "name" | "members">): Omit<PrefSection, "members"> & {
310
+ members: M;
311
+ };
312
+ number: (name: string, def: number, rest?: Rest<PrefNumber>) => PrefNumber;
313
+ boolean: (name: string, def: boolean, rest?: Rest<PrefBoolean>) => PrefBoolean;
314
+ string: (name: string, def: string, rest?: Rest<PrefString>) => PrefString;
315
+ color: (name: string, def: string, rest?: Rest<PrefColor>) => PrefColor;
316
+ /** A fixed set of choices. An option given as its value alone is labeled with that value, its first letter raised. */
317
+ enum<const T extends string>(name: string, def: NoInfer<T>, options: readonly OptionOf<T>[], rest?: Omit<Rest<PrefEnumBase<T>>, "options">): PrefEnumBase<T> & {
318
+ default: T;
319
+ clearable?: false;
320
+ };
321
+ };
322
+
323
+ /** How {@link prefsCss} names and writes things. */
324
+ interface PrefsCssOptions {
325
+ /** The selector of the element the properties are set on, and the selectors' attributes read from. Default `:root`. */
326
+ root?: string;
327
+ /** The custom property a leaf is written as, or `null` to leave the leaf out. Default: `--`, then the path with
328
+ * each `.` and each capital turned into a `-` (`look.gridGap` is `--look-grid-gap`). */
329
+ property?: (path: string, leaf: PrefLeaf) => string | null;
330
+ /** The attribute a selector's option is read from. Default: `data-`, then the path as a property spells it. */
331
+ attribute?: (selector: string) => string;
332
+ /** The CSS text of a value, `null` to leave it out, or `undefined` for what its kind writes by itself. */
333
+ value?: (value: unknown, leaf: PrefLeaf, path: string) => string | null | undefined;
334
+ }
335
+ /** What {@link prefsCss} reads of a store: any `PrefsStore` is one. */
336
+ interface PrefsCssSource {
337
+ schema: PrefGroup;
338
+ values(read?: {
339
+ at?: PrefSelection;
340
+ }): Record<string, unknown>;
341
+ locus(path: string): PrefLocus | undefined;
342
+ get(path: string): unknown;
343
+ }
344
+ /**
345
+ * The store's values as CSS custom properties.
346
+ *
347
+ * The first block sets every leaf on `root`, a split one at the member the
348
+ * selectors' defaults name, so a page that sets no attribute still has a
349
+ * value for each. A block follows for each choice of options some value tells
350
+ * apart, matched by an attribute per selector on that same element; a selector
351
+ * is written under each of its own options too. Every block is inside
352
+ * `:where()`, so none outranks another by how many attributes it names, and a
353
+ * rule of the page's own wins. Blocks naming more selectors come later.
354
+ *
355
+ * A number is written in its display unit where the unit's suffix is a CSS
356
+ * unit, and bare otherwise; a boolean as `1` or `0`; a color as it is held; an
357
+ * enum's option as an identifier; a string quoted. A leaf of any other kind is
358
+ * left out unless `value` writes it.
359
+ */
360
+ declare function prefsCss(store: PrefsCssSource, options?: PrefsCssOptions): string;
361
+ /**
362
+ * The attribute for each selector and the option it is set to: what to set
363
+ * on the `root` element for the blocks of {@link prefsCss} to match the
364
+ * store's own choice.
365
+ */
366
+ declare function prefsCssAttributes(store: Pick<PrefsCssSource, 'schema' | 'get'>, options?: Pick<PrefsCssOptions, 'attribute'>): Record<string, string>;
367
+
368
+ /**
369
+ * The schema that answers for the value at `path`: `schema` where a leaf of
370
+ * it describes that value, else `over`, the schema `schema` is drawn over.
371
+ * So a path both hold is `schema`'s. Every reader of a condition's paths
372
+ * that takes a second schema asks here which one to read.
373
+ */
374
+ declare function prefSchemaHolding(schema: PrefGroup | PrefSection, path: string, over?: PrefGroup | PrefSection): PrefGroup | PrefSection;
375
+
376
+ /** What an alias row reads of the leaf it shows: the schema that leaf is in, as that schema's own conditions leave it. */
377
+ interface PrefAliasTargets {
378
+ /** Says which conditions of that schema hold. */
379
+ holds: PrefConditionJudge;
380
+ /** The leaf at a path of that schema, without the fields the surface would leave out of the leaf's own row: one
381
+ * marked `hidden`, and one a `showIf` hides, unless the surface draws those. */
382
+ leafAt: (path: string) => PrefLeaf | undefined;
383
+ /** The leaf `alias` is drawn as, under the alias's own name and description where it gives them, and the path
384
+ * its value is read and written at. `undefined` for an alias of nothing. */
385
+ shown: (alias: PrefAlias) => {
386
+ path: string;
387
+ leaf: PrefLeaf;
388
+ } | undefined;
389
+ /** Whether the field at a path of that schema is one an `enableIf` disables. */
390
+ disabledAt: (path: string) => boolean;
391
+ /** Whether the field at a path of that schema is one a `showIf` hides, on a surface that draws those. */
392
+ hiddenAt?: (path: string) => boolean;
393
+ /** An entry of a list or a map of that schema, as the conditions that read the entry leave it. */
394
+ entryAt: (item: PrefLeaf, path: string, value: unknown) => PrefEntryApplied;
395
+ }
396
+ /** What a surface draws beyond the default, which its alias rows follow. */
397
+ interface PrefAliasTargetsOptions {
398
+ /** The surface draws fields marked `hidden`. */
399
+ showHidden?: boolean;
400
+ /** The surface draws what a `showIf` hides, marked. */
401
+ markHidden?: boolean;
402
+ }
403
+ /**
404
+ * {@link PrefAliasTargets} over `over`, the schema a surface's aliases point
405
+ * into: the surface's own, or another's. `judge` answers `over`'s conditions
406
+ * as the surface reads values, for one entry of a list or a map where it is
407
+ * given one: `prefJudge` over `over`. A surface's own pass drops a leaf it
408
+ * leaves out and keeps no path of another schema, so the leaves aliases show
409
+ * are conditioned here, the first time one is asked for.
410
+ */
411
+ declare function prefAliasTargets(over: PrefGroup | PrefSection, judge: (entry?: PrefEntry) => PrefConditionJudge, { showHidden, markHidden }?: PrefAliasTargetsOptions): PrefAliasTargets;
73
412
 
74
413
  /**
75
414
  * The object a write to one field of an `object` leaf starts from: `held` itself where it is one. Where it is
@@ -93,37 +432,31 @@ declare function prefType<L extends PrefLeaf>(name: string, leaf: L): L & {
93
432
  type: string;
94
433
  };
95
434
 
96
- /** Takes stored values from one version to the next: rename, transform or
97
- * delete entries in `records`, keyed by leaf path. It sees the values, not
98
- * the stamps they are stored under, and only those at its own version. */
99
- type PrefsMigration = (records: Map<string, unknown>) => void;
100
-
101
- /** Decides what a stored value reads as for one kind of leaf: the value to
102
- * read, or `undefined` for "invalid, read the default". */
103
- type PrefValidator = (stored: unknown, leaf: PrefLeaf) => unknown;
104
- /** What `stored` reads as for `leaf`. Never writes anything back: a schema
105
- * rolled back finds the original still in storage. */
106
- declare function repairPrefValue(leaf: PrefLeaf, stored: unknown, validators?: Readonly<Record<string, PrefValidator>>): unknown;
107
-
108
- /** Options for `openPrefs` and `openPrefsSync`. */
109
- interface PrefsOptions {
110
- storage: StorageAdapter;
111
- /** Prepended to every record's key: `'myapp.prefs.'`. */
112
- prefix: string;
113
- /** `migrations[i]` takes stored records from version `i` to `i + 1`. The
114
- * current version is `migrations.length`. */
115
- migrations?: readonly PrefsMigration[];
116
- /** Validators for app-defined kinds, keyed by `kind`. One given for a
117
- * built-in kind replaces that kind's own rule. */
118
- validators?: Readonly<Record<string, PrefValidator>>;
119
- }
120
- /** Load every stored value for `schema`, migrate it, and return the store. */
121
- declare function openPrefs<S extends PrefGroup>(schema: S, options: PrefsOptions): Promise<PrefsStore<S>>;
122
- /** `openPrefs` for an adapter that reads synchronously: the store is ready
123
- * on return, so values can be read before anything renders. */
124
- declare function openPrefsSync<S extends PrefGroup>(schema: S, options: PrefsOptions & {
125
- storage: SyncStorageAdapter;
126
- }): PrefsStore<S>;
435
+ /** Whether a leaf's control fits beside a heading's words: a built-in `boolean`'s or `enum`'s does. */
436
+ declare function prefFitsHeading(leaf: PrefLeaf): boolean;
437
+ /**
438
+ * The key of the leaf a group or a section draws in its heading: the first
439
+ * directly in it that is marked `heading` and whose control fits there.
440
+ * Undefined for a node with no name, which has no heading to draw it in.
441
+ */
442
+ declare function prefHeadingKey(node: PrefGroup | PrefSection): string | undefined;
443
+
444
+ /** Neighboring items one row draws, in {@link pairRuns}' answer. */
445
+ interface PairRun<T> {
446
+ items: T[];
447
+ /** The pairing the items share: the path of the leaf that declared it, and what the row reads. Absent on a
448
+ * run of one, which is no pair. */
449
+ pair?: {
450
+ key: string;
451
+ label: string;
452
+ };
453
+ }
454
+ /**
455
+ * `items` as the rows they draw, in order: each leaf a `pair` names joins the row of the leaf naming it where
456
+ * the two are neighbors, and every other item is a run of its own. `leafOf` gives an item's leaf and the path a
457
+ * `pair` would name it by, or nothing for an item that shares no row, which ends a run.
458
+ */
459
+ declare function pairRuns<T>(items: readonly T[], leafOf: (item: T) => readonly [path: string, leaf: PrefLeaf] | undefined): PairRun<T>[];
127
460
 
128
461
  /** What a surface has to know about a kind before it can lay its control out. */
129
462
  interface PrefKindTraits {
@@ -150,4 +483,4 @@ declare function prefDrawsSeveral(leaf: {
150
483
  kind: string;
151
484
  }): boolean;
152
485
 
153
- export { PREF_KIND_TRAITS, PrefGroup, PrefKind, type PrefKindTraits, PrefLeaf, PrefNumber, PrefObject, PrefSection, type PrefValidator, type PrefsMigration, type PrefsOptions, PrefsStore, VERSION_RECORD, filterPrefSubtree, flattenPrefValues, isPrefLeaf, isPrefSection, openPrefs, openPrefsSync, prefDisplayBounds, prefDrawsSeveral, prefHoldsValue, prefIsCompound, prefLeafAt, prefLeaves, prefObjectBase, prefObjectWithField, prefSectionLeaves, prefType, prefValueAtPath, repairPrefValue, visiblePrefSubtree };
486
+ export { PREF_ENTRY, PREF_KIND_TRAITS, PREF_SCOPE, type PairRun, PrefAlias, type PrefAliasTargets, type PrefAliasTargetsOptions, PrefBoolean, PrefColor, PrefCondition, type PrefConditionField, type PrefConditionJudge, type PrefConditionProblem, PrefConditionReader, type PrefConditionSite, type PrefConditionsApplied, type PrefConditionsOptions, type PrefEntry, type PrefEntryApplied, PrefEnumBase, PrefGroup, PrefKind, type PrefKindTraits, PrefLeaf, PrefList, PrefLocus, PrefMap, PrefNumber, PrefObject, type PrefSchemaConditionProblem, type PrefScope, type PrefScopeAtOptions, PrefSection, PrefSelection, type PrefSplitProblem, PrefString, type PrefTabRun, type PrefsCssOptions, type PrefsCssSource, VERSION_RECORD, applyPrefConditions, applyPrefEntryConditions, checkPrefCondition, checkPrefConditions, checkPrefSplits, filterPrefSubtree, flattenPrefValues, isPrefLeaf, isPrefSection, pairRuns, pref, prefAliasTargets, prefDisplayBounds, prefDrawsSeveral, prefFitsHeading, prefHeadingKey, prefHoldsValue, prefIsCompound, prefJudge, prefLeafAt, prefLeaves, prefObjectBase, prefObjectWithField, prefReader, prefSchemaHolding, prefScopeAt, prefScopeUnder, prefSectionLeaves, prefShownReader, prefShownValue, prefTabRuns, prefType, prefValueAtPath, prefsCss, prefsCssAttributes, visiblePrefSubtree };