@weasel-js/prefs-schema 0.0.0-stage → 1.19.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/LICENSE +21 -0
- package/README.md +30 -2
- package/dist/chunk-SGUOG5QO.js +570 -0
- package/dist/chunk-SGUOG5QO.js.map +1 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.js +434 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-Ad6SCtbG.d.ts +1032 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,1032 @@
|
|
|
1
|
+
import { UnitEntry, Display, UnitSystem, Unit, UnitTable, InfinityText, Endless } from '@weasel-js/quantity';
|
|
2
|
+
import { IconSpec } from '@weasel-js/icons';
|
|
3
|
+
|
|
4
|
+
/** What a condition can compare a leaf's value against. `null` stands for
|
|
5
|
+
* nothing held: a missing value as well as a stored `null`. */
|
|
6
|
+
type PrefConditionValue = string | number | boolean | null;
|
|
7
|
+
/**
|
|
8
|
+
* One leaf's value, tested. `path` is the full path the value is read and
|
|
9
|
+
* written at (`'windows.paging'`), a field of an `object` or `union` leaf
|
|
10
|
+
* included (`'stroke.width'`, `'fill.type'`). With `from: 'item'` the path is
|
|
11
|
+
* read from the entry the test's node is drawn in instead: the entry of the
|
|
12
|
+
* nearest list or map the node is the `item` of, or sits inside the item of.
|
|
13
|
+
* `{ from: 'item', path: 'mode' }` on a field of a list's item reads `mode`
|
|
14
|
+
* of the same entry, and an empty path is the entry itself. The value compared is the one
|
|
15
|
+
* the leaf's control shows, where an `encoding` stores another. With
|
|
16
|
+
* several operators it holds while all of them do, so
|
|
17
|
+
* `{ path: 'count', atLeast: 1, below: 10 }` is a range.
|
|
18
|
+
*
|
|
19
|
+
* With no operator it holds while the value is set, which by kind is:
|
|
20
|
+
* a `boolean` that is on; a `number` other than 0; a `string`, a `color`, a
|
|
21
|
+
* `field`, or an `enum`'s option that is not the empty string; a `paint`
|
|
22
|
+
* that is not `null`; a `list` with an entry; a `map` with a key; an
|
|
23
|
+
* `object` or a `union` holding a field. Nothing held is never set, and the
|
|
24
|
+
* value of an app-defined kind is set by whichever of those its shape is,
|
|
25
|
+
* else while it is truthy.
|
|
26
|
+
*/
|
|
27
|
+
interface PrefTest {
|
|
28
|
+
path: string;
|
|
29
|
+
/** Where `path` is read from: the entry the node is drawn in. Unset: the schema root. */
|
|
30
|
+
from?: 'item';
|
|
31
|
+
is?: PrefConditionValue;
|
|
32
|
+
isNot?: PrefConditionValue;
|
|
33
|
+
/** Holds while the value is any of these. */
|
|
34
|
+
in?: readonly PrefConditionValue[];
|
|
35
|
+
/** The ordering operators hold only for a number. */
|
|
36
|
+
above?: number;
|
|
37
|
+
below?: number;
|
|
38
|
+
atLeast?: number;
|
|
39
|
+
atMost?: number;
|
|
40
|
+
}
|
|
41
|
+
/** A condition a schema node holds in `showIf` or `enableIf`. An empty `all`
|
|
42
|
+
* holds and an empty `any` does not. */
|
|
43
|
+
type PrefCondition = PrefTest | {
|
|
44
|
+
all: readonly PrefCondition[];
|
|
45
|
+
} | {
|
|
46
|
+
any: readonly PrefCondition[];
|
|
47
|
+
} | {
|
|
48
|
+
not: PrefCondition;
|
|
49
|
+
};
|
|
50
|
+
/** Reads the value a test compares: at `path` from the schema root, or with `from`, from the entry being drawn. */
|
|
51
|
+
type PrefConditionReader = (path: string, from?: 'item') => unknown;
|
|
52
|
+
/** The `PrefTest` keys that compare a number by order. */
|
|
53
|
+
declare const ORDERINGS: readonly ["above", "below", "atLeast", "atMost"];
|
|
54
|
+
/** Which shape a condition takes: all of its parts, any of them, the negation of one, or a single test. */
|
|
55
|
+
type Form = 'all' | 'any' | 'not' | 'test';
|
|
56
|
+
/** Which form `value` is, judged on its own keys and not on what it holds. */
|
|
57
|
+
declare function formOf(value: unknown): Form | undefined;
|
|
58
|
+
/** The conditions directly inside a combinator; none for a test. */
|
|
59
|
+
declare function partsOf(condition: unknown, form: Form): readonly unknown[];
|
|
60
|
+
/** Whether `value` is a well-formed condition, all the way down. */
|
|
61
|
+
declare function isPrefCondition(value: unknown): value is PrefCondition;
|
|
62
|
+
/** Whether `condition` holds, given the value `read` finds at each path it names. */
|
|
63
|
+
declare function prefConditionHolds(condition: PrefCondition, read: PrefConditionReader): boolean;
|
|
64
|
+
/** Whether a node is drawn: its `showIf` holds, or it has none. A node
|
|
65
|
+
* answers for itself only; one inside a group that is not shown is not
|
|
66
|
+
* drawn either. */
|
|
67
|
+
declare function prefIsShown(node: {
|
|
68
|
+
showIf?: PrefCondition;
|
|
69
|
+
}, read: PrefConditionReader): boolean;
|
|
70
|
+
/** Whether a node's controls take input: its `enableIf` holds, or it has
|
|
71
|
+
* none. As {@link prefIsShown}, a node answers for itself only. */
|
|
72
|
+
declare function prefIsEnabled(node: {
|
|
73
|
+
enableIf?: PrefCondition;
|
|
74
|
+
}, read: PrefConditionReader): boolean;
|
|
75
|
+
/** Every path `condition` reads from the schema root, or with `from`, from the entry, once each, in the order met. */
|
|
76
|
+
declare function prefConditionPaths(condition: PrefCondition, from?: 'item'): string[];
|
|
77
|
+
/** Whether any test of `condition` reads from the entry, so that it has no answer until an entry is drawn. */
|
|
78
|
+
declare function prefConditionReadsItem(condition: PrefCondition): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* `condition` with every path it reads put through `move`, for following a
|
|
81
|
+
* key that was renamed or a leaf that moved. `move` is told where a path is
|
|
82
|
+
* read from, and what it hands back is read from there too. A condition none
|
|
83
|
+
* of whose paths change comes back as the object it was given, and so does
|
|
84
|
+
* each part of one.
|
|
85
|
+
*/
|
|
86
|
+
declare function mapPrefConditionPaths(condition: PrefCondition, move: (path: string, from?: 'item') => string): PrefCondition;
|
|
87
|
+
|
|
88
|
+
/** How serious pressing an action is: `danger` draws it as destructive. The same values as `Grade` in
|
|
89
|
+
* `@weasel-js/theme`, which this package, a dependency of core, cannot depend on. */
|
|
90
|
+
type PrefGrade = 'info' | 'success' | 'warn' | 'danger';
|
|
91
|
+
/** What a {@link PrefAction}'s `run` is told. */
|
|
92
|
+
interface PrefActionContext {
|
|
93
|
+
/** The path the action sits at on the surface drawing it. */
|
|
94
|
+
path: string;
|
|
95
|
+
}
|
|
96
|
+
/** How a schema-driven UI should present an action leaf. */
|
|
97
|
+
type PrefActionControl = 'button' | 'icon';
|
|
98
|
+
/**
|
|
99
|
+
* A leaf that holds no value: a button among the rows or in a bar. A store
|
|
100
|
+
* neither reads nor writes one, and its path is not a {@link PrefPath}.
|
|
101
|
+
*
|
|
102
|
+
* It fires one of two things. `action` names an action the host registered,
|
|
103
|
+
* by key, which keeps the leaf plain data: it survives JSON, so a layout
|
|
104
|
+
* holding it can be saved and exported. `run` is code the schema carries.
|
|
105
|
+
* A leaf with both fires `action`. While a promise `run` returned is
|
|
106
|
+
* pending, the button is disabled.
|
|
107
|
+
*/
|
|
108
|
+
interface PrefAction extends PrefBase<'action', undefined> {
|
|
109
|
+
/** The key of a registered action to fire: its id, or `id:variant` for one
|
|
110
|
+
* variant of a parametric action. The leaf's `name` and `icon` are what
|
|
111
|
+
* the button shows, over the registered action's own. */
|
|
112
|
+
action?: string;
|
|
113
|
+
/** What to call when no `action` is named. */
|
|
114
|
+
run?: (ctx: PrefActionContext) => void | Promise<void>;
|
|
115
|
+
/** The button's text. Default: the leaf's `name`. */
|
|
116
|
+
label?: string;
|
|
117
|
+
/** `button` reads its label; `icon` is the icon alone, with the label in
|
|
118
|
+
* its tooltip. Unset: a button in a row, an icon in a bar. */
|
|
119
|
+
control?: PrefActionControl;
|
|
120
|
+
/** How serious pressing it is: `'danger'` for one that destroys something, as a "Clear all" does. */
|
|
121
|
+
grade?: PrefGrade;
|
|
122
|
+
/** The keys that fire it, as the tooltip and a menu's row show them (`⌘⌫`). Shown only: binding them is the
|
|
123
|
+
* host's. Unset: the registered action's, for a leaf naming an `action`. */
|
|
124
|
+
shortcut?: string;
|
|
125
|
+
/** Drawn pressed while this holds, as a toggle that is on is: the state its button latches into. Read as
|
|
126
|
+
* `enableIf` is, so it survives JSON. Unset: the registered action's own pressed state, for a leaf naming an
|
|
127
|
+
* `action`; none for one with only `run`. */
|
|
128
|
+
activeIf?: PrefCondition;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Every action the host registered in the action group `group`, in registry
|
|
132
|
+
* order, each drawn as an {@link PrefAction} naming it would be: an action
|
|
133
|
+
* registered later appears without the schema changing. Holds no value, as
|
|
134
|
+
* an `action` holds none.
|
|
135
|
+
*/
|
|
136
|
+
interface PrefActions extends PrefBase<'actions', undefined> {
|
|
137
|
+
/** The registry action group whose actions are drawn. */
|
|
138
|
+
group: string;
|
|
139
|
+
/** Action keys in the order to draw them; one not named goes at the end. */
|
|
140
|
+
order?: readonly string[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A second place for another leaf: its row draws that leaf's control and
|
|
145
|
+
* reads and writes that leaf's value, so one setting can sit on two pages.
|
|
146
|
+
* It holds no value of its own. A store neither reads nor writes one, and
|
|
147
|
+
* its path is not a {@link PrefPath}.
|
|
148
|
+
*
|
|
149
|
+
* `name` and `description` left empty are the target's.
|
|
150
|
+
*/
|
|
151
|
+
interface PrefAlias extends PrefBase<'alias', undefined> {
|
|
152
|
+
/** The leaf shown here, by the full path its value is read and written at (`'view.grid'`). */
|
|
153
|
+
of: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The leaf an alias stands for and the path its value lives at, following an
|
|
157
|
+
* alias of an alias to its end. `undefined` when a path along the way names
|
|
158
|
+
* no leaf, or the aliases lead back to one already passed.
|
|
159
|
+
*/
|
|
160
|
+
declare function prefAliasTarget(alias: PrefAlias, leafAt: (path: string) => PrefLeaf | undefined): {
|
|
161
|
+
path: string;
|
|
162
|
+
leaf: PrefLeaf;
|
|
163
|
+
} | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* What an alias is called wherever one is drawn or named: its own name, else
|
|
166
|
+
* that of `target`, the leaf it shows, else `Alias` for one that shows
|
|
167
|
+
* nothing.
|
|
168
|
+
*/
|
|
169
|
+
declare function prefAliasName(alias: PrefAlias, target?: PrefLeaf): string;
|
|
170
|
+
/** A leaf drawn through an alias: the target, under the alias's own name, description and access letter where it gives them. */
|
|
171
|
+
declare function prefAliasedLeaf(alias: PrefAlias, target: PrefLeaf): PrefLeaf;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A line of text among the rows, holding no value: `name` is the line and
|
|
175
|
+
* `description` the note under it. A store neither reads nor writes one, and
|
|
176
|
+
* its path is not a {@link PrefPath}.
|
|
177
|
+
*/
|
|
178
|
+
type PrefLabel = PrefBase<'label', undefined>;
|
|
179
|
+
/** A rule drawn between the rows, holding no value and drawing none of its own text. */
|
|
180
|
+
type PrefSeparator = PrefBase<'separator', undefined>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A leaf whose value is an array, every entry described by `item`.
|
|
184
|
+
*
|
|
185
|
+
* `item` is an ordinary leaf, built-in or app-defined, so a list of objects,
|
|
186
|
+
* of lists or of a custom kind is declared the way a list of numbers is, and
|
|
187
|
+
* each entry is validated and drawn as that leaf would be on its own. Its
|
|
188
|
+
* `default` is what a new entry starts as, and its `name` names one entry
|
|
189
|
+
* (`'Phase'` under a list named `'Phases'`).
|
|
190
|
+
*/
|
|
191
|
+
interface PrefList extends PrefValueBase<'list', readonly unknown[]> {
|
|
192
|
+
item: PrefLeaf;
|
|
193
|
+
/** A stored list shorter than this reads as the default, and a UI stops removing at it. */
|
|
194
|
+
minItems?: number;
|
|
195
|
+
/** A stored list longer than this reads cut to it, and a UI stops adding at it. */
|
|
196
|
+
maxItems?: number;
|
|
197
|
+
control?: PrefListControl;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* How a schema-driven UI should present a list whose entries are plain text: a field per entry, one under another,
|
|
201
|
+
* or `tokens`, a chip per entry in a row that wraps, for entries short enough to read as one. A list of anything else
|
|
202
|
+
* is drawn a control per entry whatever this says.
|
|
203
|
+
*/
|
|
204
|
+
type PrefListControl = 'list' | 'tokens';
|
|
205
|
+
|
|
206
|
+
/** The key of a scope's shared value: what every option without a value of its own reads and writes. */
|
|
207
|
+
declare const PREF_ELSE = "$else";
|
|
208
|
+
/**
|
|
209
|
+
* A pref's value split by another leaf: one value for each option of the
|
|
210
|
+
* `enum` leaf at `$by`, or of a selector that is no leaf, whose option the app names.
|
|
211
|
+
* A value may itself be a scope, by a second selector. The alternatives are
|
|
212
|
+
* folded by weight when the value is read, and a plain setting of the
|
|
213
|
+
* selector gives one of them all of it.
|
|
214
|
+
*/
|
|
215
|
+
interface PrefScope {
|
|
216
|
+
/** The full path of the selector whose options key `$in`. */
|
|
217
|
+
$by: string;
|
|
218
|
+
$in: Record<string, unknown>;
|
|
219
|
+
/** The value shared by every option that keeps none of its own. */
|
|
220
|
+
[PREF_ELSE]?: unknown;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* One override list of a pref's scope: the options of its selector that keep
|
|
224
|
+
* a value of their own, by name, or by name with the value each reads before
|
|
225
|
+
* one is written. A selector given one is closed; every option it leaves out
|
|
226
|
+
* shares the scope's {@link PREF_ELSE} value. A selector given none is open:
|
|
227
|
+
* once split, an option keeps a value of its own once one is written for it.
|
|
228
|
+
*/
|
|
229
|
+
type PrefOverrides = readonly string[] | Readonly<Record<string, unknown>>;
|
|
230
|
+
/** A pref's override list for each selector, where it gives one. */
|
|
231
|
+
type PrefOverridesLookup = (selector: string) => PrefOverrides | undefined;
|
|
232
|
+
/** The options an override list names. */
|
|
233
|
+
declare function overrideOptions(overrides: PrefOverrides): readonly string[];
|
|
234
|
+
/** A value for each selector a read is made under: its path, then the option chosen. */
|
|
235
|
+
type PrefSelection = Readonly<Record<string, string>>;
|
|
236
|
+
/** A weight for each option of each selector, by the selector's path. An option left out weighs nothing. */
|
|
237
|
+
type PrefWeights = Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
238
|
+
/** One alternative of a split value, and its share of the whole. */
|
|
239
|
+
interface PrefWeighted {
|
|
240
|
+
value: unknown;
|
|
241
|
+
weight: number;
|
|
242
|
+
}
|
|
243
|
+
/** Whether `value` is a {@link PrefScope}: an object of `$by` and `$in`, and the shared value if any, and nothing else. */
|
|
244
|
+
declare function isPrefScope(value: unknown): value is PrefScope;
|
|
245
|
+
/**
|
|
246
|
+
* `value` with every scope in it that was stored as `{ $by, $of }`, the shape
|
|
247
|
+
* before the values' key was renamed, in the current shape. The same value
|
|
248
|
+
* when it holds none.
|
|
249
|
+
*/
|
|
250
|
+
declare function upgradeScope(value: unknown): unknown;
|
|
251
|
+
/** The weights a plain selection amounts to: all of each selector's on the option chosen. */
|
|
252
|
+
declare function selectionWeights(selection: PrefSelection): PrefWeights;
|
|
253
|
+
/**
|
|
254
|
+
* What one option of the scope's own selector reads: its own value where it
|
|
255
|
+
* has one and may (an option a closed list leaves out never does); else,
|
|
256
|
+
* for an option a closed list proposes a value for, that; else the shared
|
|
257
|
+
* value. No option named reads the shared value too. Whatever is held
|
|
258
|
+
* nothing for reads as `absent`.
|
|
259
|
+
*/
|
|
260
|
+
declare function scopeOptionValue(scope: PrefScope, option: string | undefined, absent: unknown, overridesOf?: PrefOverridesLookup): unknown;
|
|
261
|
+
/**
|
|
262
|
+
* Every alternative of `stored` that weighs something under `weights`, each
|
|
263
|
+
* with its share: the product of the weights on the way down to it. An option
|
|
264
|
+
* the scope holds nothing for reads as `absent`, and a selector `weights`
|
|
265
|
+
* leaves out reads the shared value, or nothing where there is none. Members come in the order `weights`
|
|
266
|
+
* lists each selector's options.
|
|
267
|
+
*/
|
|
268
|
+
declare function weighScope(stored: unknown, weights: PrefWeights, absent: unknown, overridesOf?: PrefOverridesLookup): PrefWeighted[];
|
|
269
|
+
/** The one value `selection` names. A selector it leaves out reads the shared value; an option the scope holds nothing for reads as `absent`. */
|
|
270
|
+
declare function memberAt(stored: unknown, selection: PrefSelection, absent: unknown, overridesOf?: PrefOverridesLookup): unknown;
|
|
271
|
+
/** `stored` without the values of options a closed list leaves out, which no read reaches, at any depth. The same value when there are none. */
|
|
272
|
+
declare function dropUnlisted(stored: unknown, overridesOf: PrefOverridesLookup | undefined): unknown;
|
|
273
|
+
/**
|
|
274
|
+
* `stored` written as `selectors`, the pref's scopes outermost first, declare
|
|
275
|
+
* it, with the value `under` names replaced by `next`. Each scope on the way
|
|
276
|
+
* down is made the declared one first, so nothing reads differently for it:
|
|
277
|
+
* a plain value becomes the shared value of the scope it stands in for, and
|
|
278
|
+
* a value split by any other selector becomes the shared value it reads under
|
|
279
|
+
* `now`, the selection the reader sees. An option's own value is plain, and
|
|
280
|
+
* a write replaces it whole, unless it is split already by the next selector
|
|
281
|
+
* in, as a nested default holds it: then the write goes on into that.
|
|
282
|
+
*/
|
|
283
|
+
declare function writeDeclared(stored: unknown, selectors: readonly string[], under: PrefSelection, now: PrefSelection, next: unknown, absent: unknown, overridesOf?: PrefOverridesLookup, held?: boolean): unknown;
|
|
284
|
+
/** `stored` with each alternative mapped, at any depth. The same value when no value changed. */
|
|
285
|
+
declare function mapScopeValues(stored: unknown, fn: (value: unknown) => unknown): unknown;
|
|
286
|
+
/** The path of every selector `stored` is split by, outermost first. */
|
|
287
|
+
declare function scopeSelectors(stored: unknown): Set<string>;
|
|
288
|
+
/**
|
|
289
|
+
* What a stored scope reads as: each value repaired, and left out a key that
|
|
290
|
+
* is none of its selector's options or one a closed list leaves out.
|
|
291
|
+
* `optionsOf` gives a selector's options, `null` for a selector that is no leaf, whose
|
|
292
|
+
* keys are all kept. `undefined` when it is split by a selector not in
|
|
293
|
+
* `allowed`, by one `optionsOf` has no options for, or by the same one twice
|
|
294
|
+
* on the way to a value.
|
|
295
|
+
*/
|
|
296
|
+
declare function repairScope(stored: unknown, allowed: readonly string[], optionsOf: (path: string) => readonly string[] | null | undefined, repairMember: (value: unknown) => unknown, overridesOf?: PrefOverridesLookup): unknown;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* A leaf whose value is an object keyed by strings nobody declared, every
|
|
300
|
+
* value described by `item`: the keyed counterpart of a {@link PrefList}.
|
|
301
|
+
* `item` is an ordinary leaf of any kind; its `default` is what a new entry
|
|
302
|
+
* starts as, and its `name` names one entry's value.
|
|
303
|
+
*/
|
|
304
|
+
interface PrefMap extends PrefValueBase<'map', Readonly<Record<string, unknown>>> {
|
|
305
|
+
item: PrefLeaf;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* One selector a pref's value is kept separately for, as `.per(selector,
|
|
310
|
+
* overrides?)` declares it. `selector` is the full path of an `enum` pref,
|
|
311
|
+
* or of a selector the schema's root `admits`, whose option the app names as
|
|
312
|
+
* it reads and writes (`at`).
|
|
313
|
+
*
|
|
314
|
+
* With `overrides` the selector is closed, and without, open: see
|
|
315
|
+
* {@link PrefOverrides}. Scopes are the declaration's to say: a reader never
|
|
316
|
+
* splits or joins a pref.
|
|
317
|
+
*/
|
|
318
|
+
interface PrefScopeSpec {
|
|
319
|
+
selector: string;
|
|
320
|
+
overrides?: PrefOverrides;
|
|
321
|
+
}
|
|
322
|
+
/** The selectors a pref's value is kept separately for, outermost first. */
|
|
323
|
+
declare function prefScopesOf(pref: PrefLeaf): readonly PrefScopeSpec[];
|
|
324
|
+
/** The override list a pref gives the selector at `selector`, where it is closed. */
|
|
325
|
+
declare function prefOverridesOf(pref: PrefLeaf, selector: string): PrefOverrides | undefined;
|
|
326
|
+
/** The paths of a pref's selectors, outermost first, where it has any. */
|
|
327
|
+
declare function scopeSelectorsOf(pref: PrefLeaf): readonly string[] | undefined;
|
|
328
|
+
/** {@link prefOverridesOf} for one pref, as the scope functions take it: none where no selector is closed. */
|
|
329
|
+
declare function overridesOfPref(pref: PrefLeaf): PrefOverridesLookup | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* What a pref holds while nothing is stored for it: its `defaultScope`, or
|
|
332
|
+
* else one scope per selector, outermost first, each holding no value of its
|
|
333
|
+
* own and the next one in as its shared value, the last with none so it
|
|
334
|
+
* reads `default`.
|
|
335
|
+
*/
|
|
336
|
+
declare function prefScopedDefault(pref: PrefLeaf): PrefScope | undefined;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* A leaf whose value is one of several object shapes, told apart by the
|
|
340
|
+
* string its `tag` field holds: `{ type: 'linear', angle: 90 }` or
|
|
341
|
+
* `{ type: 'radial', radius: 1 }` under `tag: 'type'`.
|
|
342
|
+
*
|
|
343
|
+
* Each variant is an `object` leaf keyed by its tag value. Its `children`
|
|
344
|
+
* are the fields beside the tag, its `name` is what a person chooses, and
|
|
345
|
+
* its `default` (without the tag) is what the value becomes when they choose
|
|
346
|
+
* it. A stored value whose tag names no variant reads as the leaf's default.
|
|
347
|
+
*/
|
|
348
|
+
interface PrefUnion extends PrefValueBase<'union', unknown> {
|
|
349
|
+
/** The field of the value that names its variant. Not one of `tags`. */
|
|
350
|
+
tag: string;
|
|
351
|
+
variants: Record<string, PrefObject>;
|
|
352
|
+
}
|
|
353
|
+
/** The variant `value` is, or `undefined` when its tag names none. */
|
|
354
|
+
declare function prefVariantOf(leaf: PrefUnion, value: unknown): [key: string, variant: PrefObject] | undefined;
|
|
355
|
+
/** The value a union takes on switching to the variant at `key`: that variant's default, tagged. */
|
|
356
|
+
declare function prefVariantDefault(leaf: PrefUnion, key: string): Record<string, unknown>;
|
|
357
|
+
|
|
358
|
+
/** Reads a value held beside a number leaf, by the path a condition there would name. */
|
|
359
|
+
type PrefBoundReader = (path: string) => unknown;
|
|
360
|
+
/**
|
|
361
|
+
* A number leaf's bound where its value is held: `undefined` for none. Asked
|
|
362
|
+
* per holder, so each scene node a panel edits can have its own.
|
|
363
|
+
*/
|
|
364
|
+
type PrefBoundAt = (read: PrefBoundReader) => number | undefined;
|
|
365
|
+
/**
|
|
366
|
+
* `leaf` with its `minAt` and `maxAt` read against `read` and folded into
|
|
367
|
+
* `min` and `max`, whichever is tighter. The leaf itself when it has neither.
|
|
368
|
+
*/
|
|
369
|
+
declare function prefNumberAt(leaf: PrefNumber, read: PrefBoundReader): PrefNumber;
|
|
370
|
+
/** `n` held to `leaf`'s `min` and `max`, except an infinity an `endless` end stands for. */
|
|
371
|
+
declare function prefClampNumber(leaf: PrefNumber, n: number): number;
|
|
372
|
+
|
|
373
|
+
/** What both forms of a unit say about the text around the number. */
|
|
374
|
+
interface PrefUnitText {
|
|
375
|
+
/** The unit shown after the input, as the unit catalog writes it: `'deg'` and `'°'` both show `°`,
|
|
376
|
+
* and text the catalog does not know shows as given. */
|
|
377
|
+
suffix?: string;
|
|
378
|
+
/** Show the unit's compact form, where it has one: `″` for `in`. */
|
|
379
|
+
compact?: boolean;
|
|
380
|
+
/** Suffixes a person may type, each mapped to the scale that turns a
|
|
381
|
+
* number in that unit into a display number: `{ mm: 0.1, cm: 1 }` for a
|
|
382
|
+
* field showing centimeters. A unit that disagrees with the display unit
|
|
383
|
+
* about zero carries an `offset` as well. */
|
|
384
|
+
accepts?: Readonly<Record<string, UnitEntry>>;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* A display unit as data, for a conversion that is linear: `stored = display * scale + offset`, the direction a
|
|
388
|
+
* `UnitEntry` runs toward its base, so `scale` is what one display unit is worth in stored units. Degrees shown
|
|
389
|
+
* over radians stored is `{ suffix: '°', scale: Math.PI / 180 }`, and `{ scale: 1 }` changes nothing. Being data,
|
|
390
|
+
* it is written to JSON, printed in a schema literal, and edited in `PrefSchemaEditor` like any other attribute.
|
|
391
|
+
*/
|
|
392
|
+
interface PrefLinearUnit extends PrefUnitText {
|
|
393
|
+
/** Stored units per display unit. Never 0. */
|
|
394
|
+
scale: number;
|
|
395
|
+
/** The stored value a display of 0 stands for. Absent is 0. */
|
|
396
|
+
offset?: number;
|
|
397
|
+
/** Decimal places the shown value is rounded and padded to, so `1.5` at 2 shows `1.50`. Absent, the value
|
|
398
|
+
* shows unrounded and formats to two places, trailing zeros trimmed.
|
|
399
|
+
* What is typed is stored unrounded either way: a decimal typed at a decimal `scale` is stored as the
|
|
400
|
+
* decimal the two multiply to, without the dust of multiplying them in binary. */
|
|
401
|
+
precision?: number;
|
|
402
|
+
}
|
|
403
|
+
/** A display unit as code, for a conversion that is not linear. It cannot be written to JSON or edited as data. */
|
|
404
|
+
interface PrefFunctionUnit extends PrefUnitText {
|
|
405
|
+
toDisplay: (stored: number) => number;
|
|
406
|
+
fromDisplay: (display: number) => number;
|
|
407
|
+
/** The stored value as display text, suffix included. */
|
|
408
|
+
format?: (stored: number) => string;
|
|
409
|
+
}
|
|
410
|
+
/** Display-unit conversion for number leaves whose stored value uses a
|
|
411
|
+
* canonical unit the user shouldn't see (e.g. radians stored, degrees
|
|
412
|
+
* shown). Read one through {@link resolvePrefUnit}, which answers for both forms. */
|
|
413
|
+
type PrefNumberUnit = PrefLinearUnit | PrefFunctionUnit;
|
|
414
|
+
/** A unit of either form as the functions that convert and format with it. Its `suffix` is the text a field
|
|
415
|
+
* shows, the catalog's form of the one written. */
|
|
416
|
+
interface ResolvedPrefUnit extends PrefFunctionUnit {
|
|
417
|
+
format: (stored: number) => string;
|
|
418
|
+
/** How a field shows the display number, where the unit fixes its places. */
|
|
419
|
+
display?: Display;
|
|
420
|
+
/** The decimal places `toDisplay` rounds to, where the unit fixes them. */
|
|
421
|
+
precision?: number;
|
|
422
|
+
/** `toDisplay` before any rounding to `precision`. */
|
|
423
|
+
toDisplayExact: (stored: number) => number;
|
|
424
|
+
}
|
|
425
|
+
/** What a unit leaf's field reads as typed text: its `accepts` table, and its
|
|
426
|
+
* `suffix` as the display unit itself. */
|
|
427
|
+
declare function prefUnitAccepts(unit: PrefNumberUnit): Readonly<UnitTable>;
|
|
428
|
+
/** Whether `unit` is the data form, and so can be written out and edited. */
|
|
429
|
+
declare function isPrefLinearUnit(unit: PrefNumberUnit): unit is PrefLinearUnit;
|
|
430
|
+
/** How to convert and format with `unit`, whichever form it was written in. */
|
|
431
|
+
declare function resolvePrefUnit(unit: PrefNumberUnit): ResolvedPrefUnit;
|
|
432
|
+
/**
|
|
433
|
+
* A display unit built from a {@link UnitSystem}: values are stored in the
|
|
434
|
+
* system's base and shown in `display`, rounded to `precision` places when
|
|
435
|
+
* given, and every unit in the system is accepted as typed text. `suffix`
|
|
436
|
+
* defaults to the unit's name and is accepted too. Every unit of a system is
|
|
437
|
+
* linear, so what comes back is data.
|
|
438
|
+
*/
|
|
439
|
+
declare function prefUnit(system: UnitSystem, display: Unit, opts?: {
|
|
440
|
+
precision?: number;
|
|
441
|
+
suffix?: string;
|
|
442
|
+
compact?: boolean;
|
|
443
|
+
}): PrefLinearUnit;
|
|
444
|
+
/** A length stored and shown in CSS pixels: what a leaf keyed `…Px` carries, a brush radius or a click's reach
|
|
445
|
+
* measured on screen rather than in world units. */
|
|
446
|
+
declare const PX_UNIT: PrefLinearUnit;
|
|
447
|
+
|
|
448
|
+
/** How a schema-driven UI should present a number pref. */
|
|
449
|
+
type PrefNumberControl = 'input' | 'slider';
|
|
450
|
+
/**
|
|
451
|
+
* How a slider spaces values along its track: `'linear'`, the default;
|
|
452
|
+
* `'log'`, even ratios at even distances, for a range above zero; `'sqrt'`,
|
|
453
|
+
* which spreads out the low end less than a log does and takes zero and
|
|
454
|
+
* negatives; or `to` and `from`, a warp the track is linear in and its inverse.
|
|
455
|
+
*/
|
|
456
|
+
type PrefNumberScale = 'linear' | 'log' | 'sqrt' | {
|
|
457
|
+
to(value: number): number;
|
|
458
|
+
from(warped: number): number;
|
|
459
|
+
};
|
|
460
|
+
/** What every number leaf carries; {@link PrefNumber} adds `clearable`. */
|
|
461
|
+
interface PrefNumberBase extends PrefValueBase<'number', number | undefined> {
|
|
462
|
+
min?: number;
|
|
463
|
+
max?: number;
|
|
464
|
+
/** A lower bound read from where the value is held — a scene node's own
|
|
465
|
+
* minimum — taken with `min`, the larger winning. A surface resolves it
|
|
466
|
+
* per holder with `prefNumberAt`. */
|
|
467
|
+
minAt?: PrefBoundAt;
|
|
468
|
+
/** The upper counterpart of `minAt`, taken with `max`, the smaller winning. */
|
|
469
|
+
maxAt?: PrefBoundAt;
|
|
470
|
+
step?: number;
|
|
471
|
+
control?: PrefNumberControl;
|
|
472
|
+
/** What an empty field shows: what an unset value stands for, on a `clearable` leaf. */
|
|
473
|
+
placeholder?: string;
|
|
474
|
+
/** How the value shows, speaks and reads back when typed — `compact()`
|
|
475
|
+
* reads `2.00M`. Presentation only: the stored value stays a number. */
|
|
476
|
+
display?: Display;
|
|
477
|
+
unit?: PrefNumberUnit;
|
|
478
|
+
/** What the number measures. `'length'` is a length stored in world units: a
|
|
479
|
+
* surface showing a scene node's field gives it the unit of the unit scopes
|
|
480
|
+
* the node sits in (`prefLeafInScopes`). A `unit` of the leaf's own wins. */
|
|
481
|
+
measure?: 'length';
|
|
482
|
+
/** The values a slider's drag catches on, in the stored unit like `min` and
|
|
483
|
+
* `max`: each is drawn on the track, a drag passing near one lands on it
|
|
484
|
+
* (alt held passes it by), and a key step crossing one stops there. */
|
|
485
|
+
stops?: readonly number[];
|
|
486
|
+
/** How the slider spaces values along its track — `.range(1, 1000)` with
|
|
487
|
+
* `'log'` gives 1–10, 10–100 and 100–1000 a third each. It changes only
|
|
488
|
+
* where a value sits on the track: the typed value, `step`, `stops`, the
|
|
489
|
+
* arrow keys and the stored value stay in the value's own units. Under a
|
|
490
|
+
* `unit` the slider runs in the shown unit, so the scale spaces shown
|
|
491
|
+
* values. A `'log'` track over a range not above zero warns once in
|
|
492
|
+
* development and is drawn linear. */
|
|
493
|
+
scale?: PrefNumberScale;
|
|
494
|
+
/** Which end of a slider gets a stop for ±Infinity, one step beyond the range. */
|
|
495
|
+
endless?: 'min' | 'max' | 'both';
|
|
496
|
+
/** The word infinity shows as — `'never'`, `'uncapped'`. Default `∞`. */
|
|
497
|
+
infinity?: InfinityText;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* A numeric pref, optionally bounded and stepped, and optionally stored in a
|
|
501
|
+
* different unit from the one shown.
|
|
502
|
+
*
|
|
503
|
+
* `clearable` says the field may hold no number, which a person sets by
|
|
504
|
+
* emptying it: the value is then `undefined`, which the owner reads as unset,
|
|
505
|
+
* and its default may be too.
|
|
506
|
+
*/
|
|
507
|
+
type PrefNumber = PrefNumberBase & ({
|
|
508
|
+
clearable?: false;
|
|
509
|
+
default: number;
|
|
510
|
+
} | {
|
|
511
|
+
clearable: true;
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
/** The value types a built-in pref leaf can hold. */
|
|
515
|
+
type PrefKind = 'number' | 'boolean' | 'string' | 'enum' | 'color' | 'paint' | 'object' | 'list' | 'map' | 'union' | 'field' | 'action' | 'actions' | 'alias' | 'label' | 'separator';
|
|
516
|
+
/** Leaves that share one row in a compact property UI, declared on the first
|
|
517
|
+
* of them. Purely presentational. */
|
|
518
|
+
interface PrefPair {
|
|
519
|
+
/** The other leaves on the row, by the full path their values are read and
|
|
520
|
+
* written at (`'pose.y'`, `'camera.type'`), in order. Each must follow the
|
|
521
|
+
* one before it among its siblings. */
|
|
522
|
+
with: string | readonly string[];
|
|
523
|
+
/** What the row reads. Default: the declaring leaf's `name`. */
|
|
524
|
+
label?: string;
|
|
525
|
+
}
|
|
526
|
+
/** The fields every leaf pref shares, keyed by its `kind` and typed by its stored value. */
|
|
527
|
+
interface PrefBase<K extends string, Value> {
|
|
528
|
+
kind: K;
|
|
529
|
+
/** Human-readable label. */
|
|
530
|
+
name: string;
|
|
531
|
+
/** Longer help text — shown in tooltips / a settings pane. */
|
|
532
|
+
description: string;
|
|
533
|
+
/** Fallback when nothing is persisted. */
|
|
534
|
+
default: Value;
|
|
535
|
+
/** Words the leaf is also found by and gathered under: a settings search
|
|
536
|
+
* matches them as it matches `name`, and `prefLeavesTagged` gathers every
|
|
537
|
+
* leaf carrying one. A leaf also carries the tags of every group above it
|
|
538
|
+
* (`prefLeafTags`). Unrelated to a union leaf's `tag`, which names the
|
|
539
|
+
* field its value's variant is read from. */
|
|
540
|
+
tags?: readonly string[];
|
|
541
|
+
/** The consumer's own data on this leaf, carried and never read by the kit: no search matches it and nothing
|
|
542
|
+
* draws it. Plain data, so a schema that exports keeps it. Unlike `tags`, it is the leaf's own and does not
|
|
543
|
+
* come down from the groups above. */
|
|
544
|
+
meta?: Readonly<Record<string, unknown>>;
|
|
545
|
+
/** The letter that picks this in a menu, and with the menu bar's chord opens a top-level menu. One character; supported, never required. */
|
|
546
|
+
access?: string;
|
|
547
|
+
/** Hide from a host app's settings UI by default. */
|
|
548
|
+
hidden?: boolean;
|
|
549
|
+
/** Drawn only while this holds. Presentational: the value stays stored
|
|
550
|
+
* and readable while the leaf is not drawn. */
|
|
551
|
+
showIf?: PrefCondition;
|
|
552
|
+
/** Drawn, and disabled while this does not hold. */
|
|
553
|
+
enableIf?: PrefCondition;
|
|
554
|
+
/** Why the leaf is disabled, in words, read in its tooltip while it is: what has to change to enable it. */
|
|
555
|
+
disabledReason?: string;
|
|
556
|
+
/** Nothing held where this leaf's value is read means `default`, because
|
|
557
|
+
* whoever reads the value takes it that way (`pose.rotation ?? 0`). A
|
|
558
|
+
* surface over sparse settings reads every leaf so already. One over a
|
|
559
|
+
* scene node, where a missing key otherwise means the node has no such
|
|
560
|
+
* property, shows the default only for a leaf that says this, and still
|
|
561
|
+
* writes nothing until an edit. */
|
|
562
|
+
absentIsDefault?: boolean;
|
|
563
|
+
/** Render full-width with no label row in schema-driven settings UIs
|
|
564
|
+
* (weasel-ui `PrefsForm` honors this for leaves whose control brings
|
|
565
|
+
* its own chrome). */
|
|
566
|
+
block?: boolean;
|
|
567
|
+
/** Draw the control in the heading of the group or section holding the
|
|
568
|
+
* leaf, in place of a row of its own. Only a built-in `boolean` or `enum`
|
|
569
|
+
* fits there (`prefFitsHeading`); any other leaf stays a row. Honored by
|
|
570
|
+
* weasel-ui `PrefsForm` and labkit's `ControlPanel`. A group whose
|
|
571
|
+
* `enableIf` reads this leaf is switched by it: see `PrefGroup.enableIf`. */
|
|
572
|
+
heading?: boolean;
|
|
573
|
+
/** Glyph naming this leaf. A name from `@weasel-js/icons`; this package draws
|
|
574
|
+
* nothing. Read where a leaf's `name` has nowhere to go — a
|
|
575
|
+
* `pair`ed row is labeled by the pair, so its fields have only the glyph
|
|
576
|
+
* to tell them apart. */
|
|
577
|
+
icon?: IconSpec;
|
|
578
|
+
/** Puts this leaf and the ones it names on one row. */
|
|
579
|
+
pair?: PrefPair;
|
|
580
|
+
/** Shorter forms of `name`, longest first. A surface short of room for
|
|
581
|
+
* `name` — a strip of controls on one line, a segment in a `pair`ed row —
|
|
582
|
+
* shows the longest of them that fits. `name` stays the accessible name, so
|
|
583
|
+
* these abbreviate without costing anything. */
|
|
584
|
+
short?: readonly string[];
|
|
585
|
+
/** Opts the leaf into being auto: unpinned, reading what its owner computes (`prefAutoValue`), never its
|
|
586
|
+
* `default`. Unset, the leaf can never be auto. A store and every surface honor it alike. */
|
|
587
|
+
auto?: PrefAuto<Value>;
|
|
588
|
+
/** The name of the type this leaf was made from, set by `prefType`. A
|
|
589
|
+
* schema editor shows such a leaf as one closed thing and prints the name
|
|
590
|
+
* in place of its literal. */
|
|
591
|
+
type?: string;
|
|
592
|
+
/** The selectors this pref's value is kept separately for, one entry each,
|
|
593
|
+
* outermost first ({@link PrefScopeSpec}). Each names an `enum` pref by its full
|
|
594
|
+
* path, which must be plain: not `clearable`, with no `encoding`, and not
|
|
595
|
+
* scoped itself; or a selector the schema's root `admits`. The
|
|
596
|
+
* stored value is a {@link PrefScope} whose shared value holds the next
|
|
597
|
+
* entry in; an option's own value stops there and is not split further.
|
|
598
|
+
* An open entry (no `overrides`) starts as one value, which a reader may
|
|
599
|
+
* split and join again. */
|
|
600
|
+
scopes?: readonly PrefScopeSpec[];
|
|
601
|
+
/** What the leaf holds while nothing is stored for it, where that is a
|
|
602
|
+
* split value: a default that differs by option. Split only by selectors
|
|
603
|
+
* `scopes` names; without it, the default is an empty scope per entry,
|
|
604
|
+
* nested. `default` stays what a value it leaves out reads as, and
|
|
605
|
+
* what the leaf's value type is read from. */
|
|
606
|
+
defaultScope?: PrefScope;
|
|
607
|
+
}
|
|
608
|
+
/** How a leaf that opts into auto is auto; `{}` opts in and says neither. */
|
|
609
|
+
interface PrefAuto<Value = unknown> {
|
|
610
|
+
/** Starts auto, unpinned, where it would start pinned at `default`; a reset puts it back so. */
|
|
611
|
+
on?: boolean;
|
|
612
|
+
/** What it reads while auto, where its owner computes nothing; on a leaf with `scopes`, a split value as
|
|
613
|
+
* `defaultScope` is one. Unset, `undefined`: never its `default`. */
|
|
614
|
+
value?: Value | PrefScope;
|
|
615
|
+
}
|
|
616
|
+
/** The fields every leaf holding a value shares, besides {@link PrefBase}'s. */
|
|
617
|
+
interface PrefValueBase<K extends string, Value> extends PrefBase<K, Value> {
|
|
618
|
+
/** Drawn showing its value but not editable. */
|
|
619
|
+
readout?: boolean;
|
|
620
|
+
}
|
|
621
|
+
/** How a schema-driven UI should present a boolean pref. */
|
|
622
|
+
type PrefBooleanControl = 'checkbox' | 'switch' | 'toggle';
|
|
623
|
+
/** How a schema-driven UI should present a string pref. */
|
|
624
|
+
type PrefStringControl = 'input' | 'textarea';
|
|
625
|
+
/** How a schema-driven UI should present an enum pref. */
|
|
626
|
+
type PrefEnumControl = 'select' | 'radio' | 'toggle' | 'menu';
|
|
627
|
+
/**
|
|
628
|
+
* Stored-value bridge for a boolean leaf whose field is not a boolean — the
|
|
629
|
+
* flag counterpart of {@link PrefEnumEncoding}. `TextStyle.fontStyle` is
|
|
630
|
+
* the case: it stores `'italic'`, and the control is an Italic toggle.
|
|
631
|
+
*/
|
|
632
|
+
interface PrefBooleanEncoding {
|
|
633
|
+
/** Whether `stored` reads as on. */
|
|
634
|
+
read: (stored: unknown, siblings: Record<string, unknown> | undefined) => boolean;
|
|
635
|
+
/** What to store for `on`. `undefined` removes the field. */
|
|
636
|
+
write: (on: boolean, siblings: Record<string, unknown> | undefined) => unknown;
|
|
637
|
+
}
|
|
638
|
+
/** An on/off pref. */
|
|
639
|
+
interface PrefBoolean extends PrefValueBase<'boolean', boolean> {
|
|
640
|
+
control?: PrefBooleanControl;
|
|
641
|
+
encoding?: PrefBooleanEncoding;
|
|
642
|
+
}
|
|
643
|
+
/** A free-text pref. */
|
|
644
|
+
interface PrefString extends PrefValueBase<'string', string> {
|
|
645
|
+
control?: PrefStringControl;
|
|
646
|
+
/** What an empty field shows in its place: the value something else falls back to, as a file name does. */
|
|
647
|
+
placeholder?: string;
|
|
648
|
+
/** The most characters the field takes, counted as an `<input>`'s `maxLength` counts them. A longer stored
|
|
649
|
+
* value reads cut to this length, or one shorter where that would split a surrogate pair. */
|
|
650
|
+
maxLength?: number;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Stored-value bridge for an enum leaf whose value is not the option string —
|
|
654
|
+
* the counterpart of {@link PrefNumberUnit}, which does the same for a
|
|
655
|
+
* number stored in a canonical unit.
|
|
656
|
+
*
|
|
657
|
+
* A dash array is the case that needs it: `Stroke.dash` stores lengths, and
|
|
658
|
+
* the thing a person chooses is a style. The presets scale by the stroke's
|
|
659
|
+
* width, so both directions are given the object's other fields.
|
|
660
|
+
*/
|
|
661
|
+
interface PrefEnumEncoding<T extends string = string> {
|
|
662
|
+
/**
|
|
663
|
+
* The option `stored` reads as, or `undefined` for none — which a UI shows
|
|
664
|
+
* the way it shows a mixed selection, by selecting nothing.
|
|
665
|
+
*
|
|
666
|
+
* `siblings` is the object the leaf is a field of, or `undefined` when the
|
|
667
|
+
* node does not hold that object (and for a top-level leaf, which has none).
|
|
668
|
+
*/
|
|
669
|
+
read: (stored: unknown, siblings: Record<string, unknown> | undefined) => T | undefined;
|
|
670
|
+
/** What to store for `option`. `undefined` removes the field. */
|
|
671
|
+
write: (option: T, siblings: Record<string, unknown> | undefined) => unknown;
|
|
672
|
+
}
|
|
673
|
+
/** One choice of an enum leaf: see {@link PrefEnumBase.options}. */
|
|
674
|
+
interface PrefEnumOption<T extends string = string> {
|
|
675
|
+
value: T;
|
|
676
|
+
label: string;
|
|
677
|
+
short?: readonly string[];
|
|
678
|
+
icon?: IconSpec;
|
|
679
|
+
/** Help for the option, read in its tooltip. */
|
|
680
|
+
description?: string;
|
|
681
|
+
disabled?: boolean;
|
|
682
|
+
/** Why it is disabled, read in its tooltip. */
|
|
683
|
+
disabledReason?: string;
|
|
684
|
+
}
|
|
685
|
+
/** What every enum leaf carries; {@link PrefEnum} adds `clearable`. */
|
|
686
|
+
interface PrefEnumBase<T extends string = string> extends PrefValueBase<'enum', T | undefined> {
|
|
687
|
+
/** `short` holds shorter forms of `label`, longest first, for a segmented
|
|
688
|
+
* control too narrow for the full one — down to a capital or two. `icon`
|
|
689
|
+
* names a glyph, drawn in place of any text form where it resolves. A name
|
|
690
|
+
* from `@weasel-js/icons`; this package draws nothing. The full `label` stays the accessible name, so neither the abbreviation nor the glyph becomes the only thing naming
|
|
691
|
+
* the option.
|
|
692
|
+
*
|
|
693
|
+
* `disabled` marks an option a control reports but cannot author — the
|
|
694
|
+
* value a stored form reads as when it matches nothing offered. Dropping it
|
|
695
|
+
* from the list instead would leave the control selecting nothing and
|
|
696
|
+
* claiming the field is unset. `disabledReason` says why, in the option's
|
|
697
|
+
* tooltip, and `description` is that tooltip while it is choosable. */
|
|
698
|
+
options: readonly PrefEnumOption<T>[];
|
|
699
|
+
control?: PrefEnumControl;
|
|
700
|
+
encoding?: PrefEnumEncoding<T>;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* A pref with a fixed set of labeled choices.
|
|
704
|
+
*
|
|
705
|
+
* `clearable` says the field may hold none of the options, and that absence
|
|
706
|
+
* is a state of its own rather than a missing value — a script that is
|
|
707
|
+
* neither super nor sub. A toggle control then lets the chosen segment be
|
|
708
|
+
* clicked off, which removes the field. Such a leaf's `default` is
|
|
709
|
+
* `undefined`: a missing value is the only stored form of cleared, so a
|
|
710
|
+
* default would bring an option back the moment the field was cleared.
|
|
711
|
+
*/
|
|
712
|
+
type PrefEnum<T extends string = string> = PrefEnumBase<T> & ({
|
|
713
|
+
clearable?: false;
|
|
714
|
+
} | {
|
|
715
|
+
clearable: true;
|
|
716
|
+
default: undefined;
|
|
717
|
+
});
|
|
718
|
+
/** A single color, stored as a hex string. For a value that may also be a
|
|
719
|
+
* gradient or a pattern, use {@link PrefPaint} instead. */
|
|
720
|
+
interface PrefColor extends PrefValueBase<'color', string> {
|
|
721
|
+
/** Value is `#rrggbb`, or `#rrggbbaa` when `alpha` is set (UIs then
|
|
722
|
+
* offer an opacity control). */
|
|
723
|
+
alpha?: boolean;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Open leaf: any node with a `kind` outside the built-ins. Schema-driven
|
|
727
|
+
* UIs dispatch it to an app-supplied renderer. Deliberately NOT
|
|
728
|
+
* index-signatured so concrete app interfaces stay assignable.
|
|
729
|
+
*/
|
|
730
|
+
type PrefCustom = PrefValueBase<string, unknown>;
|
|
731
|
+
/**
|
|
732
|
+
* A whole `Paint`, not a color inside one. Use it wherever the value is
|
|
733
|
+
* the tagged paint union — a solid color, a pattern, a gradient — rather
|
|
734
|
+
* than a hex string.
|
|
735
|
+
*
|
|
736
|
+
* Addressing `…fill.color` instead reads `undefined` off a gradient (so the
|
|
737
|
+
* control shows its default and claims the text is black) and writes a
|
|
738
|
+
* hybrid `{ fill: 'gradient', stops, color }` that the renderer's structural
|
|
739
|
+
* `'color' in paint` checks then paint flat solid. The union has to be
|
|
740
|
+
* edited as a union.
|
|
741
|
+
*/
|
|
742
|
+
interface PrefPaint extends PrefValueBase<'paint', unknown> {
|
|
743
|
+
/** Offer an opacity control alongside the color. */
|
|
744
|
+
alpha?: boolean;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* A leaf whose value is one object, with its own fields hanging off it as
|
|
748
|
+
* `children`; every edit commits the parent object whole. Sibling leaves
|
|
749
|
+
* addressing into the value (`data.stroke.width`, `data.stroke.cap`) would
|
|
750
|
+
* each write one field of a value they can only half see, and writing into
|
|
751
|
+
* something that is not an object yet corrupts it.
|
|
752
|
+
*
|
|
753
|
+
* `children` paths are relative to the object. They are ordinary leaves, so a
|
|
754
|
+
* field that is itself a union (a stroke's `paint`) declares the kind that
|
|
755
|
+
* edits that union. A child may also be a {@link PrefSection}, which
|
|
756
|
+
* organizes the fields under a heading without contributing to the path.
|
|
757
|
+
*/
|
|
758
|
+
interface PrefObject extends PrefValueBase<'object', unknown> {
|
|
759
|
+
children: Record<string, PrefLeaf | PrefSection>;
|
|
760
|
+
/**
|
|
761
|
+
* Lift a non-object value into the object form, for a consumer field that
|
|
762
|
+
* may also be held as a scalar. Called before a child edit is applied;
|
|
763
|
+
* without it a scalar-valued leaf shows its children empty, and an edit
|
|
764
|
+
* starts from the leaf's `default`.
|
|
765
|
+
*/
|
|
766
|
+
fromScalar?: (value: unknown) => Record<string, unknown>;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* A reference to another field of the same schema, held as the full path its
|
|
770
|
+
* value is read and written at (`'camera.type'`) — the currency fields refer
|
|
771
|
+
* to each other in. A surface offers the fields it draws as the choices.
|
|
772
|
+
*/
|
|
773
|
+
interface PrefField extends PrefValueBase<'field', string> {
|
|
774
|
+
/** Only fields of these kinds may be named. Default: any leaf. */
|
|
775
|
+
kinds?: readonly string[];
|
|
776
|
+
}
|
|
777
|
+
/** One built-in pref leaf. `PrefLeaf` widens this to include
|
|
778
|
+
* app-defined kinds. */
|
|
779
|
+
type BuiltinPref = PrefNumber | PrefBoolean | PrefString | PrefEnum | PrefColor | PrefPaint | PrefObject | PrefList | PrefMap | PrefUnion | PrefField | PrefAction | PrefActions | PrefAlias | PrefLabel | PrefSeparator;
|
|
780
|
+
/**
|
|
781
|
+
* The built-in kinds, as a table. A kind added to {@link PrefKind} is a
|
|
782
|
+
* compile error here, and from here it is one in every renderer's `never`
|
|
783
|
+
* guard.
|
|
784
|
+
*/
|
|
785
|
+
declare const PREF_KINDS: Record<PrefKind, true>;
|
|
786
|
+
/** Which row each pairing among `leaves` puts a path on: a `key` the row's
|
|
787
|
+
* members share (the declaring leaf's path) and the `label` it reads. A
|
|
788
|
+
* path no `pair` names is absent. `leaves` are given by the path each
|
|
789
|
+
* surface reads and writes them at, so references resolve in its terms. */
|
|
790
|
+
declare function pairRowsOf(leaves: Iterable<readonly [path: string, leaf: PrefLeaf]>): Map<string, {
|
|
791
|
+
key: string;
|
|
792
|
+
label: string;
|
|
793
|
+
}>;
|
|
794
|
+
/**
|
|
795
|
+
* Narrows a leaf to the built-in union, so a renderer's switch discriminates
|
|
796
|
+
* on {@link PrefKind} instead of the open `string` that
|
|
797
|
+
* {@link PrefCustom} widens `kind` to. An app-defined kind answers false
|
|
798
|
+
* and belongs to the renderer's custom-renderer path.
|
|
799
|
+
*/
|
|
800
|
+
declare function isBuiltinPref(leaf: PrefLeaf): leaf is BuiltinPref;
|
|
801
|
+
/** Built-in or app-defined leaf. */
|
|
802
|
+
type PrefLeaf = BuiltinPref | PrefCustom;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* How a {@link PrefGroup} is drawn: `page` gets an entry in a form's rail and
|
|
806
|
+
* a pane of its own; `tab` shares a tab strip with the `tab` groups beside it;
|
|
807
|
+
* `panel` is a bordered, titled box; `section` is a heading over its rows;
|
|
808
|
+
* `fragment` draws nothing of its own, so its rows sit among its neighbors'
|
|
809
|
+
* as though they were written there. A fragment exists to hold things
|
|
810
|
+
* together: one key for their values to nest under, one node to move.
|
|
811
|
+
* `bar` puts its prefs on one line in their bar forms. `menu` is drawn as
|
|
812
|
+
* a menu wherever a menu fits: on a bar, a button opening its contents as a
|
|
813
|
+
* menu; in a menu, a submenu; in a panel, a titled box as `panel` is.
|
|
814
|
+
*/
|
|
815
|
+
type PrefGroupAs = 'page' | 'tab' | 'panel' | 'section' | 'fragment' | 'bar' | 'menu';
|
|
816
|
+
/**
|
|
817
|
+
* What a group or a section drawn `as: 'bar'` does with cells its line has no
|
|
818
|
+
* room for: `scroll` keeps them all on it, and `menu` opens the ones past its
|
|
819
|
+
* end from a button there. A bar set to `menu` asks for its natural length,
|
|
820
|
+
* its lead and every cell, sits at that length where its row is sized to its
|
|
821
|
+
* content, opens the menu only once squeezed shorter, and takes cells back as
|
|
822
|
+
* room returns.
|
|
823
|
+
*/
|
|
824
|
+
type PrefBarOverflow = 'scroll' | 'menu';
|
|
825
|
+
/** What a bar's line starts with, ahead of its cells: `label` puts the bar's name there, and `icon` its `icon`. */
|
|
826
|
+
type PrefBarLead = 'label' | 'icon';
|
|
827
|
+
/** How a {@link PrefSection} is drawn. */
|
|
828
|
+
type PrefSectionAs = Exclude<PrefGroupAs, 'page'>;
|
|
829
|
+
/**
|
|
830
|
+
* A group whose key is a path segment: `view` > `gridDensity` is the leaf at
|
|
831
|
+
* `view.gridDensity`, and its value nests the same way. The shape of a
|
|
832
|
+
* preferences schema — what `openPrefs` stores, `PrefsForm` renders, and a
|
|
833
|
+
* tool declares its options as. A key holds no `.`.
|
|
834
|
+
*/
|
|
835
|
+
interface PrefGroup {
|
|
836
|
+
/** Heading for the group's rows. **Empty means no heading** — for a group
|
|
837
|
+
* that exists to organize, not to name: one whose children are themselves
|
|
838
|
+
* groups carrying the labels a reader needs. Give it a name whenever the
|
|
839
|
+
* name is the referent (a `Border` group over `Top` / `Right` / `Bottom`
|
|
840
|
+
* reads as nothing without it). */
|
|
841
|
+
name: string;
|
|
842
|
+
description?: string;
|
|
843
|
+
/** Tags every leaf under the group carries besides its own. A settings
|
|
844
|
+
* search matching one keeps the whole group, as matching its name does. */
|
|
845
|
+
tags?: readonly string[];
|
|
846
|
+
/** How the group is drawn. Unset, its depth decides: a top-level group is a
|
|
847
|
+
* `page`, and one inside another is a `section`. */
|
|
848
|
+
as?: PrefGroupAs;
|
|
849
|
+
/** Drawn `as: 'bar'`: what happens to the cells its line has no room for.
|
|
850
|
+
* Unset: `scroll`. A surface that takes drops keeps every cell on the line
|
|
851
|
+
* whatever this says, so each is there to drop beside. */
|
|
852
|
+
overflow?: PrefBarOverflow;
|
|
853
|
+
/** Drawn `as: 'bar'`: what its line starts with. Unset: its first cell. */
|
|
854
|
+
lead?: PrefBarLead;
|
|
855
|
+
/** Glyph naming the group, as a leaf's `icon` names the leaf. A bar drawn
|
|
856
|
+
* with `lead: 'icon'` starts its line with it; the button a bar opens the
|
|
857
|
+
* group from and its submenu row in a menu carry it beside its name. */
|
|
858
|
+
icon?: IconSpec;
|
|
859
|
+
/** The name of the motif its frame is drawn in, where a form draws it framed, defined by an app's `<DefaultMotif
|
|
860
|
+
* named>` (`@weasel-js/ui`). Unset, or a name nothing defines, the form's own look. */
|
|
861
|
+
motif?: string;
|
|
862
|
+
/** The letter that picks this in a menu, and with the menu bar's chord opens a top-level menu. One character; supported, never required. */
|
|
863
|
+
access?: string;
|
|
864
|
+
/** Read on a schema's root only: the selectors a pref's scopes may name
|
|
865
|
+
* that are no pref of the schema, whose option the app names as it reads
|
|
866
|
+
* and writes (`at`): a document, a layout from a server. A scope naming a
|
|
867
|
+
* path that is neither a pref nor admitted here is a schema problem. */
|
|
868
|
+
admits?: readonly string[];
|
|
869
|
+
/** Drawn, with everything under it, only while this holds. */
|
|
870
|
+
showIf?: PrefCondition;
|
|
871
|
+
/** Everything under it is disabled while this does not hold, except a leaf directly in it that this reads: that
|
|
872
|
+
* leaf is the group's switch, often the one marked `heading`, and stays live so the group can be turned back on. */
|
|
873
|
+
enableIf?: PrefCondition;
|
|
874
|
+
/** Its heading offers a reset of every leaf under it, back to what the schema says (`prefResets`). Every
|
|
875
|
+
* leaf's row offers its own reset whether or not this is set. */
|
|
876
|
+
resettable?: boolean;
|
|
877
|
+
children: Record<string, PrefLeaf | PrefGroup>;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* A heading over leaves that adds nothing to their paths: each member is
|
|
881
|
+
* addressed by its own key alone, and the section's key only identifies the
|
|
882
|
+
* section. The shape of a node's property schema, where a leaf's key is the
|
|
883
|
+
* whole dotted node path (`pose.x`, `data.fill`), and of the headings inside
|
|
884
|
+
* a {@link PrefObject}, where a key is relative to the object.
|
|
885
|
+
*/
|
|
886
|
+
interface PrefSection {
|
|
887
|
+
/** Heading for the section's rows. Empty means no heading, as for a
|
|
888
|
+
* {@link PrefGroup}. */
|
|
889
|
+
name: string;
|
|
890
|
+
description?: string;
|
|
891
|
+
/** As a {@link PrefGroup}'s. */
|
|
892
|
+
tags?: readonly string[];
|
|
893
|
+
/** How the section is drawn, as a {@link PrefGroup}'s `as` — without
|
|
894
|
+
* `page`, since nothing that draws sections has a rail. Unset: a heading
|
|
895
|
+
* over its rows. */
|
|
896
|
+
as?: PrefSectionAs;
|
|
897
|
+
/** As a {@link PrefGroup}'s. */
|
|
898
|
+
overflow?: PrefBarOverflow;
|
|
899
|
+
/** As a {@link PrefGroup}'s. */
|
|
900
|
+
lead?: PrefBarLead;
|
|
901
|
+
/** As a {@link PrefGroup}'s. */
|
|
902
|
+
icon?: IconSpec;
|
|
903
|
+
/** As a {@link PrefGroup}'s. */
|
|
904
|
+
access?: string;
|
|
905
|
+
/** As a {@link PrefGroup}'s. */
|
|
906
|
+
motif?: string;
|
|
907
|
+
/** As a {@link PrefGroup}'s. */
|
|
908
|
+
showIf?: PrefCondition;
|
|
909
|
+
/** As a {@link PrefGroup}'s. */
|
|
910
|
+
enableIf?: PrefCondition;
|
|
911
|
+
/** As a {@link PrefGroup}'s. */
|
|
912
|
+
resettable?: boolean;
|
|
913
|
+
members: Record<string, PrefLeaf | PrefSection>;
|
|
914
|
+
}
|
|
915
|
+
/** Whether a panel draws a group or a section drawn `as` this in a bordered, titled box: a `panel`, and a `menu`,
|
|
916
|
+
* which a panel has no menu to open as. */
|
|
917
|
+
declare function prefAsBox(as: PrefGroupAs | undefined): boolean;
|
|
918
|
+
/** Whether a top-level group gets a page of its own, and not a place on the page of the root's own leaves. */
|
|
919
|
+
declare function prefGroupIsPage(group: PrefGroup): boolean;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* A number leaf's bounds in the unit it is displayed in.
|
|
923
|
+
*
|
|
924
|
+
* Only what the leaf declares converts: an omitted bound has no stored
|
|
925
|
+
* counterpart to put through the conversion, and its fallback — 0..100 for a
|
|
926
|
+
* slider's track, a step of 1 — is a display-space number already. `min` and
|
|
927
|
+
* `max` are points, so they convert the way the value does; `step` is a
|
|
928
|
+
* distance, and a unit with an offset maps zero somewhere else, so converting
|
|
929
|
+
* it as a point would scale it wrong; under a unit's `precision` it is rounded
|
|
930
|
+
* up to the smallest step that changes the shown value; `stops` are points. A decreasing
|
|
931
|
+
* conversion swaps which end is the lower one, and which end is `endless`.
|
|
932
|
+
*/
|
|
933
|
+
declare function prefDisplayBounds(p: PrefNumber): {
|
|
934
|
+
min?: number;
|
|
935
|
+
max?: number;
|
|
936
|
+
step: number;
|
|
937
|
+
endless?: Endless;
|
|
938
|
+
stops?: readonly number[];
|
|
939
|
+
};
|
|
940
|
+
/** Distinguishes a leaf from a group or a section while walking a schema tree. */
|
|
941
|
+
declare function isPrefLeaf(node: PrefLeaf | PrefGroup | PrefSection): node is PrefLeaf;
|
|
942
|
+
/** Whether a leaf has a value to store: an `action` is a button and holds none, nor does an `actions` run of them, an `alias` shows another leaf's,
|
|
943
|
+
* and a `label` and a `separator` are text and a rule. */
|
|
944
|
+
declare function prefHoldsValue(leaf: PrefLeaf): boolean;
|
|
945
|
+
/** Distinguishes a section, whose key adds nothing to a path, from a group, whose key is a segment. */
|
|
946
|
+
declare function isPrefSection(node: PrefLeaf | PrefGroup | PrefSection): node is PrefSection;
|
|
947
|
+
/**
|
|
948
|
+
* Every leaf under a section's `members` or an object leaf's `children`, in
|
|
949
|
+
* schema order, by its own key: the sections between contribute nothing.
|
|
950
|
+
*/
|
|
951
|
+
declare function prefSectionLeaves(members: PrefSection['members']): [key: string, leaf: PrefLeaf][];
|
|
952
|
+
/**
|
|
953
|
+
* The leaf whose value lives at `path`, as the schema's own shape builds
|
|
954
|
+
* paths: a segment per key under a {@link PrefGroup}, the leaf's own key
|
|
955
|
+
* under a {@link PrefSection}. `undefined` for a path that names a group, a
|
|
956
|
+
* field inside an `object` leaf, or nothing.
|
|
957
|
+
*/
|
|
958
|
+
declare function prefLeafAt(schema: PrefGroup | PrefSection, path: string): PrefLeaf | undefined;
|
|
959
|
+
/** Get the value at a dotted path inside a nested value tree. Returns
|
|
960
|
+
* `undefined` when a segment is missing or hits a non-object. */
|
|
961
|
+
declare function prefValueAtPath(values: unknown, path: string): unknown;
|
|
962
|
+
/**
|
|
963
|
+
* Recursively drop `hidden` leaves (unless `showHidden`), an object leaf's
|
|
964
|
+
* hidden fields among them, pruning groups
|
|
965
|
+
* that end up empty (unless `keepEmpty`). Returns null when the entire
|
|
966
|
+
* subtree is pruned.
|
|
967
|
+
*/
|
|
968
|
+
declare function visiblePrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, showHidden: boolean, keepEmpty?: boolean): T | null;
|
|
969
|
+
/** The record holding the schema version the stored values were written at.
|
|
970
|
+
* Reserved: no top-level schema key may take its name. */
|
|
971
|
+
declare const VERSION_RECORD = "$version";
|
|
972
|
+
/** Every leaf under `schema`, by dotted path, in schema order. A group's key
|
|
973
|
+
* is a segment; {@link prefSectionLeaves} is the walk for a section. */
|
|
974
|
+
declare function prefLeaves(schema: PrefGroup): Map<string, PrefLeaf>;
|
|
975
|
+
/** Set `key` on `tree` itself. Plain assignment to `__proto__` replaces the
|
|
976
|
+
* tree's prototype instead, and a schema key or a record name may be one. */
|
|
977
|
+
declare function setOwnPrefValue(tree: Record<string, unknown>, key: string, value: unknown): void;
|
|
978
|
+
/** Set `value` at the dotted `path` in `root` itself, creating missing branches. */
|
|
979
|
+
declare function assignPrefValueAtPath(root: Record<string, unknown>, path: string, value: unknown): void;
|
|
980
|
+
/** Values keyed by dotted path, as `PrefsBar` and `BarMenu` take them, as the
|
|
981
|
+
* nested tree `PrefsForm` reads: the inverse of {@link flattenPrefValues}. */
|
|
982
|
+
declare function nestPrefValues(values: Readonly<Record<string, unknown>> | undefined): Record<string, unknown>;
|
|
983
|
+
/** Each of `schema`'s leaves that `tree` holds a value for, as a path and
|
|
984
|
+
* that value — the inverse of building a tree from per-leaf records. */
|
|
985
|
+
declare function flattenPrefValues(schema: PrefGroup, tree: unknown): [string, unknown][];
|
|
986
|
+
/**
|
|
987
|
+
* Drop every leaf that does not answer to `query`, pruning groups left empty.
|
|
988
|
+
* A group whose own name or tag matches keeps all of its leaves. An empty or
|
|
989
|
+
* whitespace query matches everything.
|
|
990
|
+
*
|
|
991
|
+
* An alias answers as the row it draws: its target's name and description
|
|
992
|
+
* where it gives none. That target is looked for in `over`, and in `node`
|
|
993
|
+
* without it; pass the whole schema when `node` is a part of it.
|
|
994
|
+
*/
|
|
995
|
+
declare function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, query: string, path?: string, over?: PrefGroup | PrefSection): T | null;
|
|
996
|
+
|
|
997
|
+
/** A value the schema says nothing about: an entry of a list, a field of an app-defined kind. */
|
|
998
|
+
declare const UNSEEN: unique symbol;
|
|
999
|
+
/** A union on the way to a value, and the variant the value is read under. */
|
|
1000
|
+
interface PrefHeldVariant {
|
|
1001
|
+
/** The union leaf's path. */
|
|
1002
|
+
at: string;
|
|
1003
|
+
tag: string;
|
|
1004
|
+
key: string;
|
|
1005
|
+
}
|
|
1006
|
+
/** The leaf describing a value, and the path of the `object` or `union` leaf it is a field of, when it is one. */
|
|
1007
|
+
interface PrefHeld {
|
|
1008
|
+
leaf: PrefLeaf;
|
|
1009
|
+
within?: string;
|
|
1010
|
+
/** The variants the value is a field of, outermost first: it is described by `leaf` only while each union holds its variant. */
|
|
1011
|
+
variants?: readonly PrefHeldVariant[];
|
|
1012
|
+
}
|
|
1013
|
+
/** What a path resolves to among a schema's leaves: the leaves holding it, `UNSEEN` when no leaf's key reaches it, or undefined. */
|
|
1014
|
+
type PrefLeavesFound = PrefHeld[] | typeof UNSEEN | undefined;
|
|
1015
|
+
/**
|
|
1016
|
+
* Every leaf describing the value at `path`, looking inside `object` and
|
|
1017
|
+
* `union` leaves: one, or one per variant holding the field where it sits in
|
|
1018
|
+
* a union.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function prefLeavesHolding(schema: PrefGroup | PrefSection, path: string): PrefLeavesFound;
|
|
1021
|
+
/** {@link prefLeavesHolding} inside one entry of a list or a map whose `item` this is; the empty path is the entry itself. */
|
|
1022
|
+
declare function prefLeavesHoldingIn(item: PrefLeaf, path: string): PrefLeavesFound;
|
|
1023
|
+
/**
|
|
1024
|
+
* The schema that answers for the value at `path`: `schema` where a leaf of
|
|
1025
|
+
* it describes that value, else `over`, the schema `schema` is drawn over.
|
|
1026
|
+
* So a path both hold is `schema`'s. Every reader of a condition's paths
|
|
1027
|
+
* that takes a second schema asks here which one to read.
|
|
1028
|
+
*/
|
|
1029
|
+
declare function prefSchemaHolding(schema: PrefGroup | PrefSection, path: string, over?: PrefGroup | PrefSection): PrefGroup | PrefSection;
|
|
1030
|
+
|
|
1031
|
+
export { formOf as a$, prefLeafAt as aA, prefLeaves as aB, prefNumberAt as aC, overrideOptions as aD, prefOverridesOf as aE, prefSchemaHolding as aF, scopeOptionValue as aG, scopeSelectors as aH, memberAt as aI, prefScopedDefault as aJ, prefScopesOf as aK, prefSectionLeaves as aL, prefUnit as aM, prefUnitAccepts as aN, prefValueAtPath as aO, prefVariantDefault as aP, prefVariantOf as aQ, resolvePrefUnit as aR, visiblePrefSubtree as aS, ORDERINGS as aU, UNSEEN as aY, assignPrefValueAtPath as aZ, dropUnlisted as a_, VERSION_RECORD as ab, filterPrefSubtree as ac, flattenPrefValues as ad, isBuiltinPref as ae, isPrefCondition as af, isPrefLeaf as ag, isPrefLinearUnit as ah, isPrefScope as ai, isPrefSection as aj, mapPrefConditionPaths as ak, nestPrefValues as al, pairRowsOf as am, prefAliasName as an, prefAliasTarget as ao, prefAliasedLeaf as ap, prefAsBox as aq, prefClampNumber as ar, prefConditionHolds as as, prefConditionPaths as at, prefConditionReadsItem as au, prefDisplayBounds as av, prefGroupIsPage as aw, prefHoldsValue as ax, prefIsEnabled as ay, prefIsShown as az, mapScopeValues as b0, overridesOfPref as b1, partsOf as b2, prefLeavesHolding as b3, prefLeavesHoldingIn as b4, repairScope as b5, scopeSelectorsOf as b6, selectionWeights as b7, setOwnPrefValue as b8, upgradeScope as b9, weighScope as ba, writeDeclared as bb, PREF_ELSE as o, PREF_KINDS as p, PX_UNIT as q };
|
|
1032
|
+
export type { PrefScope as $, PrefBoundAt as A, BuiltinPref as B, PrefBoundReader as C, PrefConditionValue as D, PrefCustom as E, PrefEnum as F, PrefEnumControl as G, PrefEnumEncoding as H, PrefEnumOption as I, PrefField as J, PrefFunctionUnit as K, PrefGrade as L, PrefGroupAs as M, PrefKind as N, PrefLinearUnit as O, PrefCondition as P, PrefList as Q, PrefListControl as R, PrefMap as S, PrefNumberBase as T, PrefNumberControl as U, PrefNumberScale as V, PrefNumberUnit as W, PrefOverrides as X, PrefOverridesLookup as Y, PrefPaint as Z, PrefPair as _, PrefLeaf as a, PrefScopeSpec as a0, PrefSectionAs as a1, PrefSelection as a2, PrefStringControl as a3, PrefTest as a4, PrefUnion as a5, PrefUnitText as a6, PrefValueBase as a7, PrefWeighted as a8, PrefWeights as a9, Form as aT, PrefHeld as aV, PrefHeldVariant as aW, PrefLeavesFound as aX, ResolvedPrefUnit as aa, PrefGroup as b, PrefSection as c, PrefConditionReader as d, PrefNumber as e, PrefBoolean as f, PrefString as g, PrefColor as h, PrefEnumBase as i, PrefAction as j, PrefActions as k, PrefLabel as l, PrefSeparator as m, PrefObject as n, PrefActionContext as r, PrefActionControl as s, PrefAlias as t, PrefAuto as u, PrefBarLead as v, PrefBarOverflow as w, PrefBase as x, PrefBooleanControl as y, PrefBooleanEncoding as z };
|