@weasel-js/prefs 1.9.3 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/chunk-5KB3WBJZ.js +863 -0
- package/dist/chunk-5KB3WBJZ.js.map +1 -0
- package/dist/index.d.ts +351 -42
- package/dist/index.js +283 -338
- package/dist/index.js.map +1 -1
- package/dist/open-BEY-aOGe.d.ts +724 -0
- package/dist/react.d.ts +26 -2
- package/dist/react.js +66 -2
- package/dist/react.js.map +1 -1
- package/package.json +4 -3
- package/dist/store-BU2tRX5H.d.ts +0 -353
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as PrefLeaf, a as PrefGroup, b as
|
|
2
|
-
export { B as BuiltinPref,
|
|
3
|
-
import
|
|
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 PrefAlias, i as PrefObject, j as PrefKind } from './open-BEY-aOGe.js';
|
|
2
|
+
export { B as BuiltinPref, k as PREF_KINDS, l as PrefAction, m as PrefActionContext, n as PrefActionControl, o as PrefAtPath, p as PrefBase, q as PrefBoolean, r as PrefBooleanControl, s as PrefBooleanEncoding, t as PrefChange, u as PrefColor, v as PrefConditionValue, w as PrefCustom, x as PrefEnum, y as PrefEnumBase, z as PrefEnumControl, A as PrefEnumEncoding, C as PrefField, D as PrefFunctionUnit, E as PrefGroupAs, F as PrefLabel, G as PrefLinearUnit, H as PrefNumberControl, I as PrefNumberUnit, J as PrefPaint, K as PrefPair, L as PrefPath, M as PrefSectionAs, N as PrefSeparator, O as PrefString, Q as PrefStringControl, R as PrefTest, S as PrefUnion, T as PrefValidator, U as PrefValueAt, V as PrefValueOf, W as PrefsMigration, X as PrefsOptions, Y as PrefsStore, Z as ResolvedPrefUnit, _ as isBuiltinPref, $ as isPrefCondition, a0 as isPrefLinearUnit, a1 as mapPrefConditionPaths, a2 as openPrefs, a3 as openPrefsSync, a4 as pairRowsOf, a5 as prefAliasName, a6 as prefAliasTarget, a7 as prefAliasedLeaf, a8 as prefConditionHolds, a9 as prefConditionPaths, aa as prefConditionReadsItem, ab as prefGroupIsPage, ac as prefIsEnabled, ad as prefIsShown, ae as prefUnit, af as prefVariantDefault, ag as prefVariantOf, ah as repairPrefValue, ai as resolvePrefUnit } from './open-BEY-aOGe.js';
|
|
3
|
+
import '@weasel-js/storage';
|
|
4
4
|
import '@weasel-js/quantity';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -19,63 +19,372 @@ declare function prefDisplayBounds(p: PrefNumber): {
|
|
|
19
19
|
max?: number;
|
|
20
20
|
step: number;
|
|
21
21
|
};
|
|
22
|
-
/** Distinguishes a leaf from a group while walking a schema tree. */
|
|
23
|
-
declare function isPrefLeaf(node: PrefLeaf | PrefGroup): node is PrefLeaf;
|
|
22
|
+
/** Distinguishes a leaf from a group or a section while walking a schema tree. */
|
|
23
|
+
declare function isPrefLeaf(node: PrefLeaf | PrefGroup | PrefSection): node is PrefLeaf;
|
|
24
|
+
/** Whether a leaf has a value to store: an `action` is a button and holds none, an `alias` shows another leaf's,
|
|
25
|
+
* and a `label` and a `separator` are text and a rule. */
|
|
26
|
+
declare function prefHoldsValue(leaf: PrefLeaf): boolean;
|
|
27
|
+
/** Distinguishes a section, whose key adds nothing to a path, from a group, whose key is a segment. */
|
|
28
|
+
declare function isPrefSection(node: PrefLeaf | PrefGroup | PrefSection): node is PrefSection;
|
|
29
|
+
/**
|
|
30
|
+
* Every leaf under a section's `members` or an object leaf's `children`, in
|
|
31
|
+
* schema order, by its own key: the sections between contribute nothing.
|
|
32
|
+
*/
|
|
33
|
+
declare function prefSectionLeaves(members: PrefSection['members']): [key: string, leaf: PrefLeaf][];
|
|
34
|
+
/**
|
|
35
|
+
* The leaf whose value lives at `path`, as the schema's own shape builds
|
|
36
|
+
* paths: a segment per key under a {@link PrefGroup}, the leaf's own key
|
|
37
|
+
* under a {@link PrefSection}. `undefined` for a path that names a group, a
|
|
38
|
+
* field inside an `object` leaf, or nothing.
|
|
39
|
+
*/
|
|
40
|
+
declare function prefLeafAt(schema: PrefGroup | PrefSection, path: string): PrefLeaf | undefined;
|
|
24
41
|
/** Get the value at a dotted path inside a nested value tree. Returns
|
|
25
42
|
* `undefined` when a segment is missing or hits a non-object. */
|
|
26
43
|
declare function prefValueAtPath(values: unknown, path: string): unknown;
|
|
27
44
|
/**
|
|
28
|
-
* Recursively drop `hidden` leaves (unless `showHidden`),
|
|
29
|
-
*
|
|
45
|
+
* Recursively drop `hidden` leaves (unless `showHidden`), an object leaf's
|
|
46
|
+
* hidden fields among them, pruning groups
|
|
47
|
+
* that end up empty (unless `keepEmpty`). Returns null when the entire
|
|
48
|
+
* subtree is pruned.
|
|
30
49
|
*/
|
|
31
|
-
declare function visiblePrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, showHidden: boolean): T | null;
|
|
50
|
+
declare function visiblePrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, showHidden: boolean, keepEmpty?: boolean): T | null;
|
|
32
51
|
/** The record holding the schema version the stored values were written at.
|
|
33
52
|
* Reserved: no top-level schema key may take its name. */
|
|
34
53
|
declare const VERSION_RECORD = "$version";
|
|
35
|
-
/** Every leaf under `schema`, by dotted path, in schema order.
|
|
54
|
+
/** Every leaf under `schema`, by dotted path, in schema order. A group's key
|
|
55
|
+
* is a segment; {@link prefSectionLeaves} is the walk for a section. */
|
|
36
56
|
declare function prefLeaves(schema: PrefGroup): Map<string, PrefLeaf>;
|
|
37
57
|
/** Each of `schema`'s leaves that `tree` holds a value for, as a path and
|
|
38
58
|
* that value — the inverse of building a tree from per-leaf records. */
|
|
39
59
|
declare function flattenPrefValues(schema: PrefGroup, tree: unknown): [string, unknown][];
|
|
40
60
|
/**
|
|
41
61
|
* Drop every leaf that does not answer to `query`, pruning groups left empty.
|
|
42
|
-
* A group whose own name matches keeps all of its leaves
|
|
43
|
-
*
|
|
62
|
+
* A group whose own name matches keeps all of its leaves. An empty or
|
|
63
|
+
* whitespace query matches everything.
|
|
44
64
|
*
|
|
45
|
-
* An
|
|
46
|
-
*
|
|
65
|
+
* An alias answers as the row it draws: its target's name and description
|
|
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.
|
|
47
68
|
*/
|
|
48
|
-
declare function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, query: string, path?: string): T | null;
|
|
69
|
+
declare function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(node: T, query: string, path?: string, over?: PrefGroup | PrefSection): T | null;
|
|
49
70
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
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>[];
|
|
53
84
|
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
|
|
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[];
|
|
60
132
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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>;
|
|
72
257
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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.
|
|
265
|
+
*/
|
|
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
|
+
/**
|
|
282
|
+
* The schema that answers for the value at `path`: `schema` where a leaf of
|
|
283
|
+
* it describes that value, else `over`, the schema `schema` is drawn over.
|
|
284
|
+
* So a path both hold is `schema`'s. Every reader of a condition's paths
|
|
285
|
+
* that takes a second schema asks here which one to read.
|
|
286
|
+
*/
|
|
287
|
+
declare function prefSchemaHolding(schema: PrefGroup | PrefSection, path: string, over?: PrefGroup | PrefSection): PrefGroup | PrefSection;
|
|
288
|
+
|
|
289
|
+
/** What an alias row reads of the leaf it shows: the schema that leaf is in, as that schema's own conditions leave it. */
|
|
290
|
+
interface PrefAliasTargets {
|
|
291
|
+
/** Says which conditions of that schema hold. */
|
|
292
|
+
holds: PrefConditionJudge;
|
|
293
|
+
/** The leaf at a path of that schema, without the fields the surface would leave out of the leaf's own row: one
|
|
294
|
+
* marked `hidden`, and one a `showIf` hides, unless the surface draws those. */
|
|
295
|
+
leafAt: (path: string) => PrefLeaf | undefined;
|
|
296
|
+
/** The leaf `alias` is drawn as, under the alias's own name and description where it gives them, and the path
|
|
297
|
+
* its value is read and written at. `undefined` for an alias of nothing. */
|
|
298
|
+
shown: (alias: PrefAlias) => {
|
|
299
|
+
path: string;
|
|
300
|
+
leaf: PrefLeaf;
|
|
301
|
+
} | undefined;
|
|
302
|
+
/** Whether the field at a path of that schema is one an `enableIf` disables. */
|
|
303
|
+
disabledAt: (path: string) => boolean;
|
|
304
|
+
/** Whether the field at a path of that schema is one a `showIf` hides, on a surface that draws those. */
|
|
305
|
+
hiddenAt?: (path: string) => boolean;
|
|
306
|
+
/** An entry of a list or a map of that schema, as the conditions that read the entry leave it. */
|
|
307
|
+
entryAt: (item: PrefLeaf, path: string, value: unknown) => PrefEntryApplied;
|
|
308
|
+
}
|
|
309
|
+
/** What a surface draws beyond the default, which its alias rows follow. */
|
|
310
|
+
interface PrefAliasTargetsOptions {
|
|
311
|
+
/** The surface draws fields marked `hidden`. */
|
|
312
|
+
showHidden?: boolean;
|
|
313
|
+
/** The surface draws what a `showIf` hides, marked. */
|
|
314
|
+
markHidden?: boolean;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* {@link PrefAliasTargets} over `over`, the schema a surface's aliases point
|
|
318
|
+
* into: the surface's own, or another's. `judge` answers `over`'s conditions
|
|
319
|
+
* as the surface reads values, for one entry of a list or a map where it is
|
|
320
|
+
* given one: `prefJudge` over `over`. A surface's own pass drops a leaf it
|
|
321
|
+
* leaves out and keeps no path of another schema, so the leaves aliases show
|
|
322
|
+
* are conditioned here, the first time one is asked for.
|
|
323
|
+
*/
|
|
324
|
+
declare function prefAliasTargets(over: PrefGroup | PrefSection, judge: (entry?: PrefEntry) => PrefConditionJudge, { showHidden, markHidden }?: PrefAliasTargetsOptions): PrefAliasTargets;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The object a write to one field of an `object` leaf starts from: `held` itself where it is one. Where it is
|
|
328
|
+
* not, the write has to make a whole object, so it starts from the scalar lifted by the leaf's `fromScalar`, else
|
|
329
|
+
* from the leaf's `default`: one field on its own is a stroke with a width and no paint.
|
|
330
|
+
*/
|
|
331
|
+
declare function prefObjectBase(pref: PrefObject, held: unknown): Record<string, unknown>;
|
|
332
|
+
/** The object an `object` leaf holds after one of its fields is set: {@link prefObjectBase} with `key` at
|
|
333
|
+
* `value`, or without the key for `undefined`. */
|
|
334
|
+
declare function prefObjectWithField(pref: PrefObject, held: unknown, key: string, value: unknown): Record<string, unknown>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* `leaf` as a named type: the same leaf carrying `name` in its `type` field.
|
|
338
|
+
* Declared once beside the code that reads its value and used wherever a
|
|
339
|
+
* schema wants one, spread with what that place sets for itself
|
|
340
|
+
* (`{ ...GradientStop, name: 'First stop' }`), or as a list's or a map's
|
|
341
|
+
* `item`. `name` is the identifier the type is exported under, which a schema
|
|
342
|
+
* editor prints in place of the leaf's literal.
|
|
343
|
+
*/
|
|
344
|
+
declare function prefType<L extends PrefLeaf>(name: string, leaf: L): L & {
|
|
345
|
+
type: string;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/** Neighboring items one row draws, in {@link pairRuns}' answer. */
|
|
349
|
+
interface PairRun<T> {
|
|
350
|
+
items: T[];
|
|
351
|
+
/** The pairing the items share: the path of the leaf that declared it, and what the row reads. Absent on a
|
|
352
|
+
* run of one, which is no pair. */
|
|
353
|
+
pair?: {
|
|
354
|
+
key: string;
|
|
355
|
+
label: string;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* `items` as the rows they draw, in order: each leaf a `pair` names joins the row of the leaf naming it where
|
|
360
|
+
* the two are neighbors, and every other item is a run of its own. `leafOf` gives an item's leaf and the path a
|
|
361
|
+
* `pair` would name it by, or nothing for an item that shares no row, which ends a run.
|
|
362
|
+
*/
|
|
363
|
+
declare function pairRuns<T>(items: readonly T[], leafOf: (item: T) => readonly [path: string, leaf: PrefLeaf] | undefined): PairRun<T>[];
|
|
364
|
+
|
|
365
|
+
/** What a surface has to know about a kind before it can lay its control out. */
|
|
366
|
+
interface PrefKindTraits {
|
|
367
|
+
/** Its value is made of other leaves' values: too much for one control on a
|
|
368
|
+
* line, so a bar opens it in a popover and a compact panel in a dialog. */
|
|
369
|
+
compound: boolean;
|
|
370
|
+
/** Its control is several controls, or a button. A row drawn as a `<label>`
|
|
371
|
+
* would hand a click on its text to the first of them. */
|
|
372
|
+
several: boolean;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The traits of every built-in kind. A `Record` over {@link PrefKind}, so a
|
|
376
|
+
* kind added to the union does not compile until it says what it is here:
|
|
377
|
+
* a plain set of kind names lets a new one through to draw inline in a
|
|
378
|
+
* `<label>`, on a bar's line, and with no dialog row.
|
|
379
|
+
*/
|
|
380
|
+
declare const PREF_KIND_TRAITS: Record<PrefKind, PrefKindTraits>;
|
|
381
|
+
/** Whether a leaf's value is made of other leaves' values. An app-defined kind is not: its renderer is one control. */
|
|
382
|
+
declare function prefIsCompound(leaf: {
|
|
383
|
+
kind: string;
|
|
384
|
+
}): boolean;
|
|
385
|
+
/** Whether a leaf's control is several controls or a button. */
|
|
386
|
+
declare function prefDrawsSeveral(leaf: {
|
|
387
|
+
kind: string;
|
|
388
|
+
}): boolean;
|
|
80
389
|
|
|
81
|
-
export { PrefGroup, PrefLeaf, PrefNumber, type
|
|
390
|
+
export { PREF_ENTRY, PREF_KIND_TRAITS, PREF_SCOPE, type PairRun, PrefAlias, type PrefAliasTargets, type PrefAliasTargetsOptions, PrefCondition, type PrefConditionField, type PrefConditionJudge, type PrefConditionProblem, PrefConditionReader, type PrefConditionSite, type PrefConditionsApplied, type PrefConditionsOptions, type PrefEntry, type PrefEntryApplied, PrefGroup, PrefKind, type PrefKindTraits, PrefLeaf, PrefList, PrefMap, PrefNumber, PrefObject, type PrefSchemaConditionProblem, type PrefScope, type PrefScopeAtOptions, PrefSection, type PrefTabRun, VERSION_RECORD, applyPrefConditions, applyPrefEntryConditions, checkPrefCondition, checkPrefConditions, filterPrefSubtree, flattenPrefValues, isPrefLeaf, isPrefSection, pairRuns, prefAliasTargets, prefDisplayBounds, prefDrawsSeveral, prefHoldsValue, prefIsCompound, prefJudge, prefLeafAt, prefLeaves, prefObjectBase, prefObjectWithField, prefReader, prefSchemaHolding, prefScopeAt, prefScopeUnder, prefSectionLeaves, prefShownReader, prefShownValue, prefTabRuns, prefType, prefValueAtPath, visiblePrefSubtree };
|