@weasel-js/prefs-schema 0.0.0-stage → 2.0.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/LICENSE +21 -0
- package/README.md +30 -2
- package/dist/chunk-DVHFV6JS.js +596 -0
- package/dist/chunk-DVHFV6JS.js.map +1 -0
- package/dist/index.d.ts +395 -0
- package/dist/index.js +488 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-DMioFJDY.d.ts +1041 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/package.json +55 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { P as PrefGroup, a as PrefSection, b as PrefCondition, c as PrefLeaf, d as PrefConditionReader, e as PrefNumberBase, f as PrefBoolean, g as PrefString, h as PrefColor, i as PrefEnumBase, j as PrefAction, k as PrefActions, l as PrefLabel, m as PrefSeparator, n as PrefObject } from './internal-DMioFJDY.js';
|
|
2
|
+
export { B as BuiltinPref, o as PREF_ELSE, p as PREF_KINDS, q as PX_UNIT, r as PrefActionContext, s as PrefActionControl, t as PrefAlias, u as PrefAuto, v as PrefBarLead, w as PrefBarOverflow, x as PrefBase, y as PrefBooleanControl, z as PrefBooleanEncoding, A as PrefBoundAt, C as PrefBoundReader, D as PrefConditionFrom, E as PrefConditionValue, F as PrefCustom, G as PrefEnum, H as PrefEnumControl, I as PrefEnumEncoding, J as PrefEnumOption, K as PrefField, L as PrefFunctionUnit, M as PrefGroupAs, N as PrefKind, O as PrefLinearUnit, Q as PrefList, R as PrefListControl, S as PrefMap, T as PrefNumber, U as PrefNumberControl, V as PrefNumberScale, W as PrefNumberUnit, X as PrefOverrides, Y as PrefOverridesLookup, Z as PrefPaint, _ as PrefPair, $ as PrefScope, a0 as PrefScopeSpec, a1 as PrefSectionAs, a2 as PrefSelection, a3 as PrefStringControl, a4 as PrefTest, a5 as PrefUnion, a6 as PrefUnitText, a7 as PrefValueBase, a8 as PrefWeighted, a9 as PrefWeights, aa as ResolvedPrefUnit, ab as VERSION_RECORD, ac as filterPrefSubtree, ad as flattenPrefValues, ae as isBuiltinPref, af as isPrefCondition, ag as isPrefLeaf, ah as isPrefLinearUnit, ai as isPrefScope, aj as isPrefSection, ak as mapPrefConditionPaths, al as nestPrefValues, am as prefAliasName, an as prefAliasTarget, ao as prefAliasedLeaf, ap as prefBoundedNumber, aq as prefClampNumber, ar as prefConditionHolds, as as prefConditionInGroup, at as prefConditionPaths, au as prefConditionReadsItem, av as prefDisplayBounds, aw as prefDrawsAsBox, ax as prefGroupIsPage, ay as prefHoldsValue, az as prefIsEnabled, aA as prefIsShown, aB as prefLeafAt, aC as prefLeaves, aD as prefOverrideOptions, aE as prefOverridesOf, aF as prefPairRows, aG as prefSchemaHolding, aH as prefScopeOptionValue, aI as prefScopeValue, aJ as prefScopedDefault, aK as prefScopesOf, aL as prefSectionLeaves, aM as prefStoredSelectors, aN as prefUnit, aO as prefUnitAccepts, aP as prefValueAt, aQ as prefVariantDefault, aR as prefVariantOf, aS as resolvePrefUnit, aT as visiblePrefSubtree } from './internal-DMioFJDY.js';
|
|
3
|
+
import '@weasel-js/quantity';
|
|
4
|
+
import '@weasel-js/icons';
|
|
5
|
+
import '@weasel-js/registry';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `schema` with every condition test read from its node's group (`from: 'group'`) read from the root instead: the
|
|
9
|
+
* form the condition readers, the status walks and the store's checks take. The same object comes back for the same
|
|
10
|
+
* schema, and the schema itself where no test reads from its group.
|
|
11
|
+
*/
|
|
12
|
+
declare function resolvePrefGroupConditions<T extends PrefGroup | PrefSection>(schema: T): T;
|
|
13
|
+
|
|
14
|
+
/** Every field a schema node holds a {@link PrefCondition} in. `activeIf` is an action leaf's alone. */
|
|
15
|
+
declare const PREF_CONDITION_FIELDS: readonly ["showIf", "enableIf", "activeIf"];
|
|
16
|
+
/** Which of a node's conditions a {@link PrefConditionJudge} is asked about. */
|
|
17
|
+
type PrefConditionField = (typeof PREF_CONDITION_FIELDS)[number];
|
|
18
|
+
/**
|
|
19
|
+
* Says whether one condition holds. {@link prefJudge} makes one from a value
|
|
20
|
+
* reader; a surface drawing several values at once writes its own, to say
|
|
21
|
+
* what a condition that holds for some and not for others comes to.
|
|
22
|
+
*/
|
|
23
|
+
type PrefConditionJudge = (condition: PrefCondition, field: PrefConditionField) => boolean;
|
|
24
|
+
/** One entry of a list or a map: the `item` leaf describing it, and what it holds. */
|
|
25
|
+
interface PrefEntry {
|
|
26
|
+
item: PrefLeaf;
|
|
27
|
+
value: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A judge over one set of values, read by path. A condition compares each
|
|
31
|
+
* value as the control over its leaf in `schema` shows it
|
|
32
|
+
* ({@link prefShownReader}), so `read` hands back what is stored. A test
|
|
33
|
+
* that reads from the entry (`from: 'item'`) reads `entry`, and finds nothing
|
|
34
|
+
* held where none is given. `over` is the schema `schema` is drawn over: a
|
|
35
|
+
* path no leaf of `schema` holds is compared as the leaf of `over` there
|
|
36
|
+
* shows it.
|
|
37
|
+
*/
|
|
38
|
+
declare function prefJudge(schema: PrefGroup | PrefSection, read: (path: string) => unknown, entry?: PrefEntry, over?: PrefGroup | PrefSection): PrefConditionJudge;
|
|
39
|
+
/**
|
|
40
|
+
* Reads a value by path the way a form over `schema` shows it: what `values`
|
|
41
|
+
* holds there, else the default of the leaf at that path, or the part of a
|
|
42
|
+
* leaf's default the rest of the path names. `over` is the schema `schema`
|
|
43
|
+
* is drawn over: a path no leaf of `schema` holds takes its default there.
|
|
44
|
+
*/
|
|
45
|
+
declare function prefReader(schema: PrefGroup | PrefSection, values: unknown, over?: PrefGroup | PrefSection): (path: string) => unknown;
|
|
46
|
+
|
|
47
|
+
/** Whether a node is drawn and whether it takes input, with what is above it counted. */
|
|
48
|
+
interface PrefStatus {
|
|
49
|
+
shown: boolean;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** The step that stands for any entry of a `list` or a `map` in a path: `'phases.*.hold'` answers for that field of
|
|
53
|
+
* each, by every condition that comes to the same for every entry. */
|
|
54
|
+
declare const PREF_ENTRY = "*";
|
|
55
|
+
/**
|
|
56
|
+
* The path a section is named by where a set of paths names it, such as `applyPrefConditions`'s `disabled`: `at`, the
|
|
57
|
+
* path of what holds it, then its key marked so no value path can be the same. `at` is the path of the `object`
|
|
58
|
+
* leaf holding it, empty at a section root, or the path of the section holding it: `'stroke.#edge'`,
|
|
59
|
+
* `'#look.#more'`.
|
|
60
|
+
*/
|
|
61
|
+
declare const prefSectionPath: (at: string, key: string) => string;
|
|
62
|
+
/** The status a schema's root sits in. */
|
|
63
|
+
declare const ROOT_PREF_STATUS: PrefStatus;
|
|
64
|
+
/** The status of `node`, which sits directly under something whose status is `above`. */
|
|
65
|
+
declare function prefStatusUnder(above: PrefStatus, node: {
|
|
66
|
+
showIf?: PrefCondition;
|
|
67
|
+
enableIf?: PrefCondition;
|
|
68
|
+
}, holds: PrefConditionJudge): PrefStatus;
|
|
69
|
+
/** What holds a node: a group, a section, or a leaf with fields, with its own status and the status it sits in. */
|
|
70
|
+
interface PrefOwner {
|
|
71
|
+
node: {
|
|
72
|
+
showIf?: PrefCondition;
|
|
73
|
+
enableIf?: PrefCondition;
|
|
74
|
+
};
|
|
75
|
+
status: PrefStatus;
|
|
76
|
+
above: PrefStatus;
|
|
77
|
+
/** The path of the list's or the map's entry the owner sits in (`'phases.2'`), under which a condition that reads
|
|
78
|
+
* the entry (`from: 'item'`) names its paths. Unset outside an entry, or where it has no one path. */
|
|
79
|
+
entry?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The status a leaf at `path` directly in `owner` sits in: the owner's, except
|
|
83
|
+
* that the owner's own `enableIf` does not disable a leaf it reads. That leaf
|
|
84
|
+
* is the owner's switch, and disabled by its own condition it could never be
|
|
85
|
+
* turned back on. A test that reads the entry reads the leaf at its path
|
|
86
|
+
* under `owner.entry`.
|
|
87
|
+
*/
|
|
88
|
+
declare function prefStatusIn(owner: PrefOwner, path: string, holds: PrefConditionJudge): PrefStatus;
|
|
89
|
+
/** What {@link prefStatusAt} is told beyond the schema. */
|
|
90
|
+
interface PrefStatusAtOptions {
|
|
91
|
+
/** The schema an alias's `of` names a leaf of. Default: the schema asked. */
|
|
92
|
+
aliasOver?: PrefGroup | PrefSection;
|
|
93
|
+
/** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */
|
|
94
|
+
aliasHolds?: PrefConditionJudge;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The status of the node at `path`: a group, a leaf, a field of an `object`
|
|
98
|
+
* or a `union` leaf, or an entry of a `list` or a `map`, whose step may be
|
|
99
|
+
* any key. Under a {@link PrefSection} schema a leaf's key is its whole
|
|
100
|
+
* path. A path that runs past the schema answers for the last node it
|
|
101
|
+
* reaches. An alias answers for itself and for the leaf it shows, as
|
|
102
|
+
* `applyPrefConditions` has it. Inside an entry, a condition that reads the
|
|
103
|
+
* entry (`from: 'item'`) is not asked and counts as holding, there being no
|
|
104
|
+
* entry here to read: `applyPrefEntryConditions` answers it.
|
|
105
|
+
*/
|
|
106
|
+
declare function prefStatusAt(schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge, { aliasOver, aliasHolds }?: PrefStatusAtOptions): PrefStatus;
|
|
107
|
+
|
|
108
|
+
/** A schema with its conditions applied. */
|
|
109
|
+
interface PrefConditionsApplied<T> {
|
|
110
|
+
/** The schema without the nodes that are not shown. The schema itself when
|
|
111
|
+
* that is all of it, and `null` when its root is not shown. */
|
|
112
|
+
shown: T | null;
|
|
113
|
+
/**
|
|
114
|
+
* The value path of every leaf that is disabled, a field of an `object` or
|
|
115
|
+
* a `union` leaf included (`'stroke.width'`), and under a {@link PrefGroup}
|
|
116
|
+
* schema the path of every group that is, and of every section by
|
|
117
|
+
* {@link prefSectionPath}. A `list`'s or a `map`'s item is
|
|
118
|
+
* named once for every entry, with {@link PREF_ENTRY} as the entry's step:
|
|
119
|
+
* `'phases.*'`, and `'phases.*.hold'` for a field of it.
|
|
120
|
+
*/
|
|
121
|
+
disabled: ReadonlySet<string>;
|
|
122
|
+
/**
|
|
123
|
+
* With `keepHidden`, the path of everything `shown` holds that is not
|
|
124
|
+
* shown, named as `disabled` names what is disabled. Empty without it,
|
|
125
|
+
* since `shown` then holds none.
|
|
126
|
+
*/
|
|
127
|
+
hidden: ReadonlySet<string>;
|
|
128
|
+
/** The value path of every `action` leaf whose `activeIf` holds, named as `disabled` names what is disabled. */
|
|
129
|
+
active: ReadonlySet<string>;
|
|
130
|
+
}
|
|
131
|
+
/** How {@link applyPrefConditions} treats what it would leave out. */
|
|
132
|
+
interface PrefConditionsOptions {
|
|
133
|
+
/** Keep a group or a section that leaves with nothing to draw. */
|
|
134
|
+
keepEmpty?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Keep every node whose `showIf` fails, and name it in `hidden`: for a
|
|
137
|
+
* surface that edits the schema, where a node not drawn cannot be picked.
|
|
138
|
+
*/
|
|
139
|
+
keepHidden?: boolean;
|
|
140
|
+
/** The schema an alias's `of` names a leaf of. Default: the schema walked. */
|
|
141
|
+
aliasOver?: PrefGroup | PrefSection;
|
|
142
|
+
/** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */
|
|
143
|
+
aliasHolds?: PrefConditionJudge;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* `schema` as it is drawn while `holds` says which conditions hold. A node
|
|
147
|
+
* whose `showIf` fails is dropped with everything under it, unless
|
|
148
|
+
* `keepHidden`, and so is a group or a section that leaves with nothing to
|
|
149
|
+
* draw, unless `keepEmpty`. A node
|
|
150
|
+
* whose `enableIf` fails is disabled with everything under it. The item of
|
|
151
|
+
* a `list` or a `map` is walked as its entries are drawn: its fields hide and
|
|
152
|
+
* disable by their conditions, and its own `enableIf` disables every entry.
|
|
153
|
+
* A condition there that reads the entry (`from: 'item'`) has no one answer
|
|
154
|
+
* for every entry and is left holding: {@link applyPrefEntryConditions}
|
|
155
|
+
* answers it for each.
|
|
156
|
+
* An alias is shown only while it and the leaf it shows both are, and enabled
|
|
157
|
+
* only while both are, with everything above that leaf counted. That leaf is
|
|
158
|
+
* looked for in `aliasOver`, and its side is asked of `aliasHolds`.
|
|
159
|
+
* Parts with nothing dropped come back as the objects they were.
|
|
160
|
+
*/
|
|
161
|
+
declare function applyPrefConditions<T extends PrefGroup | PrefSection>(schema: T, holds: PrefConditionJudge, { keepEmpty, keepHidden, aliasOver: overGiven, aliasHolds }?: PrefConditionsOptions): PrefConditionsApplied<T>;
|
|
162
|
+
/** One entry of a list or a map with the conditions that read it applied. */
|
|
163
|
+
interface PrefEntryApplied {
|
|
164
|
+
/** The item as this entry draws it: without the fields not shown, and the item itself when that is all of them. */
|
|
165
|
+
item: PrefLeaf;
|
|
166
|
+
/** The path of the entry, and of every field in it, that is disabled, named as {@link PrefConditionsApplied} names them. */
|
|
167
|
+
disabled: ReadonlySet<string>;
|
|
168
|
+
/** With `keepHidden`, the path of every field of the entry that is not shown. */
|
|
169
|
+
hidden: ReadonlySet<string>;
|
|
170
|
+
/** The path of every action in the entry whose `activeIf`, which reads the entry, holds. */
|
|
171
|
+
active: ReadonlySet<string>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The conditions {@link applyPrefConditions} leaves unanswered, answered for
|
|
175
|
+
* one entry: `item`, as that pass left it, drawn for the entry at `path`
|
|
176
|
+
* (`'phases.2'`) while `holds` says which conditions hold. `holds` reads the
|
|
177
|
+
* entry: `prefJudge` given it. Only a condition that reads the entry is
|
|
178
|
+
* asked, the rest being applied already, and one inside a list or a map
|
|
179
|
+
* within the entry is left for that one's own entries.
|
|
180
|
+
*/
|
|
181
|
+
declare function applyPrefEntryConditions(item: PrefLeaf, path: string, holds: PrefConditionJudge, { keepEmpty, keepHidden }?: Pick<PrefConditionsOptions, 'keepEmpty' | 'keepHidden'>): PrefEntryApplied;
|
|
182
|
+
|
|
183
|
+
/** What the control over `leaf` shows for `stored`: what its `encoding` reads it as, else `stored` itself.
|
|
184
|
+
* `siblings` is the object the leaf is a field of. */
|
|
185
|
+
declare function prefDecodedValue(leaf: PrefLeaf, stored: unknown, siblings?: Record<string, unknown>): unknown;
|
|
186
|
+
/**
|
|
187
|
+
* `read` with each value handed back as {@link prefDecodedValue} gives it, for
|
|
188
|
+
* the leaf of `schema` at that path, a field of an `object` or a `union` leaf
|
|
189
|
+
* included. A field's siblings are what `read` finds at its leaf's path. A
|
|
190
|
+
* path read from the entry is held to `item`, the leaf describing that entry.
|
|
191
|
+
* A path no leaf of `schema` holds is held to `over`, the schema it is drawn
|
|
192
|
+
* over.
|
|
193
|
+
*/
|
|
194
|
+
declare function prefShownReader(schema: PrefGroup | PrefSection, read: PrefConditionReader, item?: PrefLeaf, over?: PrefGroup | PrefSection): PrefConditionReader;
|
|
195
|
+
|
|
196
|
+
/** Whether `held` is no value at all for `leaf`: `undefined`, or `null` except a paint's, which is "no paint". */
|
|
197
|
+
declare function prefValueAbsent(leaf: PrefLeaf, held: unknown): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* What a params surface shows for the value held at `leaf`: that value, else
|
|
200
|
+
* the leaf's default. A clearable leaf holding nothing is cleared, and shows
|
|
201
|
+
* nothing. `unset` is for a surface where holding nothing means the owner has
|
|
202
|
+
* no such property, a scene node's: it shows nothing there too.
|
|
203
|
+
*/
|
|
204
|
+
declare function prefValueOrDefault(leaf: PrefLeaf, held: unknown, { unset }?: {
|
|
205
|
+
unset?: boolean;
|
|
206
|
+
}): unknown;
|
|
207
|
+
|
|
208
|
+
/** What a builder takes after the leaf's name and default: any of the leaf's other fields. */
|
|
209
|
+
type PrefLeafRest<L> = Partial<Omit<L, 'kind' | 'name' | 'default'>>;
|
|
210
|
+
/**
|
|
211
|
+
* Builders for a preferences schema, each returning what the literal would
|
|
212
|
+
* hold. `pref.group('View', { grid: pref.boolean('Grid', true) })` is
|
|
213
|
+
* `{ name: 'View', children: { grid: { kind: 'boolean', name: 'Grid', description: '', default: true } } }`,
|
|
214
|
+
* and its paths and value types are read from it the same way.
|
|
215
|
+
*/
|
|
216
|
+
declare const pref: {
|
|
217
|
+
/** A group: `children` nest under its key, which is a segment of their paths. */
|
|
218
|
+
group<const C extends Record<string, PrefLeaf | PrefGroup>>(name: string, children: C, options?: Omit<PrefGroup, "name" | "children">): Omit<PrefGroup, "children"> & {
|
|
219
|
+
children: C;
|
|
220
|
+
};
|
|
221
|
+
/** A section: a heading over `members`, whose key adds nothing to their paths. */
|
|
222
|
+
section<const M extends Record<string, PrefLeaf | PrefSection>>(name: string, members: M, options?: Omit<PrefSection, "name" | "members">): Omit<PrefSection, "members"> & {
|
|
223
|
+
members: M;
|
|
224
|
+
};
|
|
225
|
+
number: (name: string, def: number, rest?: PrefLeafRest<PrefNumberBase>) => PrefNumberBase & {
|
|
226
|
+
default: number;
|
|
227
|
+
clearable?: false;
|
|
228
|
+
};
|
|
229
|
+
boolean: (name: string, def: boolean, rest?: PrefLeafRest<PrefBoolean>) => PrefBoolean;
|
|
230
|
+
string: (name: string, def: string, rest?: PrefLeafRest<PrefString>) => PrefString;
|
|
231
|
+
color: (name: string, def: string, rest?: PrefLeafRest<PrefColor>) => PrefColor;
|
|
232
|
+
/** A fixed set of choices. An option given as its value alone is labeled with that value, its first letter raised. */
|
|
233
|
+
enum<const T extends string>(name: string, def: NoInfer<T>, options: readonly (T | PrefEnumBase<T>["options"][number])[], rest?: Omit<PrefLeafRest<PrefEnumBase<T>>, "options">): PrefEnumBase<T> & {
|
|
234
|
+
default: T;
|
|
235
|
+
clearable?: false;
|
|
236
|
+
};
|
|
237
|
+
/** A button firing the registered action `action` (`id` or `id:variant`). Its name defaults to empty, which shows the action's own label. */
|
|
238
|
+
action: (action: string, rest?: Partial<Omit<PrefAction, "kind" | "default" | "action">>) => PrefAction;
|
|
239
|
+
/** Every action registered in the action group `group`. */
|
|
240
|
+
actions: (group: string, rest?: Partial<Omit<PrefActions, "kind" | "default" | "group">>) => PrefActions;
|
|
241
|
+
label: (name: string, rest?: PrefLeafRest<PrefLabel>) => PrefLabel;
|
|
242
|
+
separator: () => PrefSeparator;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The object a write to one field of an `object` leaf starts from: `held` itself where it is one. Where it is
|
|
247
|
+
* not, the write has to make a whole object, so it starts from a held scalar lifted by the leaf's `fromScalar`,
|
|
248
|
+
* else from the leaf's `default`: one field on its own is a stroke with a width and no paint.
|
|
249
|
+
*/
|
|
250
|
+
declare function prefObjectBase(pref: PrefObject, held: unknown): Record<string, unknown>;
|
|
251
|
+
/** The value of the field `key` in `held`. A dotted key (`'nib.angle'`) names a field of a field. */
|
|
252
|
+
declare function prefObjectField(held: Record<string, unknown> | undefined, key: string): unknown;
|
|
253
|
+
/** The object an `object` leaf holds after one of its fields is set: {@link prefObjectBase} with `key` at
|
|
254
|
+
* `value`, or without the key for `undefined`. A dotted key sets a field of a field, making the objects on
|
|
255
|
+
* the way, and clearing one drops an object it leaves empty. */
|
|
256
|
+
declare function prefObjectWithField(pref: PrefObject, held: unknown, key: string, value: unknown): Record<string, unknown>;
|
|
257
|
+
|
|
258
|
+
/** Decides what a stored value reads as for one kind of leaf: the value to
|
|
259
|
+
* read, or `undefined` for "invalid, read the default". */
|
|
260
|
+
type PrefValidator = (stored: unknown, leaf: PrefLeaf) => unknown;
|
|
261
|
+
/** What `stored` reads as for `leaf`. Never writes anything back: a schema
|
|
262
|
+
* rolled back finds the original still in storage. */
|
|
263
|
+
declare function repairPrefValue(leaf: PrefLeaf, stored: unknown, validators?: Readonly<Record<string, PrefValidator>>): unknown;
|
|
264
|
+
|
|
265
|
+
/** One feature preset as data: what it holds by id, for a tool that lists or rearranges presets. Core's
|
|
266
|
+
* `describePresets` makes these from a canvas's presets. */
|
|
267
|
+
interface PresetDescription {
|
|
268
|
+
id: string;
|
|
269
|
+
label: string;
|
|
270
|
+
/** The package that ships it, as `describePresets` was told. */
|
|
271
|
+
package: string;
|
|
272
|
+
/** It has a role beyond actions, built-in tools, and includes, so its parts only work together. */
|
|
273
|
+
atom: boolean;
|
|
274
|
+
/** Its own action ids, in registration order. */
|
|
275
|
+
actions: readonly string[];
|
|
276
|
+
/** Its own tools' ids: built-ins with their sets opened, then tools of its own. */
|
|
277
|
+
tools: readonly string[];
|
|
278
|
+
/** The ids of the presets it includes. */
|
|
279
|
+
includes: readonly string[];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Every value's dotted path in a `PrefGroup` schema, where a group's key is a
|
|
283
|
+
* segment; an `object` leaf is one path, its fields are not, and an `action`,
|
|
284
|
+
* `actions`, `alias`, `label`, or `separator` leaf, holding no value, has none. A `PrefSection`
|
|
285
|
+
* has no such paths: each of its leaves is addressed by its own key. */
|
|
286
|
+
type PrefPath<G, Prefix extends string = ''> = G extends {
|
|
287
|
+
children: infer C;
|
|
288
|
+
} ? string extends keyof C ? Prefix extends '' ? string : `${Prefix}.${string}` : {
|
|
289
|
+
[K in keyof C & string]: C[K] extends {
|
|
290
|
+
kind: string;
|
|
291
|
+
} ? C[K] extends {
|
|
292
|
+
kind: 'action' | 'actions' | 'alias' | 'label' | 'separator';
|
|
293
|
+
} ? never : Prefix extends '' ? K : `${Prefix}.${K}` : C[K] extends {
|
|
294
|
+
children: Record<string, unknown>;
|
|
295
|
+
} ? PrefPath<C[K], Prefix extends '' ? K : `${Prefix}.${K}`> : never;
|
|
296
|
+
}[keyof C & string] : never;
|
|
297
|
+
/** The leaf at `P`. `unknown` under a group whose keys are not literal, as a
|
|
298
|
+
* schema built at run time has them: nothing says which leaf is there, so
|
|
299
|
+
* its value reads as `unknown`. */
|
|
300
|
+
type PrefAtPath<G, P extends string> = G extends {
|
|
301
|
+
children: infer C;
|
|
302
|
+
} ? string extends keyof C ? unknown : P extends `${infer H}.${infer Rest}` ? H extends keyof C ? C[H] extends {
|
|
303
|
+
kind: string;
|
|
304
|
+
} ? never : PrefAtPath<C[H], Rest> : never : P extends keyof C ? C[P] extends {
|
|
305
|
+
kind: string;
|
|
306
|
+
} ? C[P] : never : never : never;
|
|
307
|
+
/** The fields an `object` leaf's `children` describe, sections folded in. Each is optional: an object may omit any. */
|
|
308
|
+
type PrefFieldsOf<C> = {
|
|
309
|
+
[K in keyof C as C[K] extends {
|
|
310
|
+
kind: string;
|
|
311
|
+
} ? K : never]?: PrefValueOf<C[K]>;
|
|
312
|
+
} & (({
|
|
313
|
+
[K in keyof C]: C[K] extends {
|
|
314
|
+
members: infer M;
|
|
315
|
+
} ? (x: PrefFieldsOf<M>) => void : never;
|
|
316
|
+
}[keyof C]) extends (x: infer I) => void ? I : never);
|
|
317
|
+
/** What a leaf holds: its kind's value type for a built-in kind, the type of
|
|
318
|
+
* its `default` for an app-defined one. A list holds an array of what its
|
|
319
|
+
* `item` holds, a map a record of it, and a union one variant's fields
|
|
320
|
+
* under that variant's tag — where the schema keeps `tag` a literal
|
|
321
|
+
* (`tag: 'type' as const`); one widened to `string` is typed by its default. */
|
|
322
|
+
type PrefValueOf<L> = L extends {
|
|
323
|
+
kind: 'number';
|
|
324
|
+
} ? L extends {
|
|
325
|
+
clearable: true;
|
|
326
|
+
} ? number | undefined : number : L extends {
|
|
327
|
+
kind: 'boolean';
|
|
328
|
+
} ? boolean : L extends {
|
|
329
|
+
kind: 'string' | 'color' | 'field';
|
|
330
|
+
} ? string : L extends {
|
|
331
|
+
kind: 'paint';
|
|
332
|
+
} ? unknown : L extends {
|
|
333
|
+
kind: 'enum';
|
|
334
|
+
options: readonly {
|
|
335
|
+
value: infer T;
|
|
336
|
+
}[];
|
|
337
|
+
} ? L extends {
|
|
338
|
+
clearable: true;
|
|
339
|
+
} ? T | undefined : T : L extends {
|
|
340
|
+
kind: 'list';
|
|
341
|
+
item: infer I;
|
|
342
|
+
} ? PrefValueOf<I>[] : L extends {
|
|
343
|
+
kind: 'map';
|
|
344
|
+
item: infer I;
|
|
345
|
+
} ? Record<string, PrefValueOf<I>> : L extends {
|
|
346
|
+
kind: 'union';
|
|
347
|
+
tag: infer T extends string;
|
|
348
|
+
variants: infer V;
|
|
349
|
+
default: infer D;
|
|
350
|
+
} ? string extends keyof V | T ? D : {
|
|
351
|
+
[K in keyof V & string]: {
|
|
352
|
+
[P in T]: K;
|
|
353
|
+
} & (V[K] extends {
|
|
354
|
+
children: infer C;
|
|
355
|
+
} ? PrefFieldsOf<C> : unknown);
|
|
356
|
+
}[keyof V & string] : L extends {
|
|
357
|
+
default: infer D;
|
|
358
|
+
} ? D : unknown;
|
|
359
|
+
/** What the leaf at `P` holds. */
|
|
360
|
+
type PrefValueAt<G, P extends string> = PrefValueOf<PrefAtPath<G, P>>;
|
|
361
|
+
/** Every group's dotted path in a `PrefGroup` schema: the paths `PrefValuesOf` can be read at. */
|
|
362
|
+
type PrefGroupPath<G, Prefix extends string = ''> = G extends {
|
|
363
|
+
children: infer C;
|
|
364
|
+
} ? string extends keyof C ? Prefix extends '' ? string : `${Prefix}.${string}` : {
|
|
365
|
+
[K in keyof C & string]: C[K] extends {
|
|
366
|
+
kind: string;
|
|
367
|
+
} ? never : C[K] extends {
|
|
368
|
+
children: Record<string, unknown>;
|
|
369
|
+
} ? (Prefix extends '' ? K : `${Prefix}.${K}`) | PrefGroupPath<C[K], Prefix extends '' ? K : `${Prefix}.${K}`> : never;
|
|
370
|
+
}[keyof C & string] : never;
|
|
371
|
+
/** The group at `P`. */
|
|
372
|
+
type PrefGroupAt<G, P extends string> = G extends {
|
|
373
|
+
children: infer C;
|
|
374
|
+
} ? P extends `${infer H}.${infer Rest}` ? H extends keyof C ? PrefGroupAt<C[H], Rest> : never : P extends keyof C ? (C[P] extends {
|
|
375
|
+
kind: string;
|
|
376
|
+
} ? never : C[P]) : never : never;
|
|
377
|
+
/** What a group holds: an object keyed like its `children`, with each leaf's value
|
|
378
|
+
* at its key and each nested group's values under its own. A leaf that holds no
|
|
379
|
+
* value (an action, an alias, a label, a separator) gets no key. */
|
|
380
|
+
type PrefValuesOf<G> = G extends {
|
|
381
|
+
children: infer C;
|
|
382
|
+
} ? {
|
|
383
|
+
-readonly [K in keyof C as C[K] extends {
|
|
384
|
+
kind: 'action' | 'actions' | 'alias' | 'label' | 'separator';
|
|
385
|
+
} ? never : C[K] extends {
|
|
386
|
+
kind: string;
|
|
387
|
+
} | {
|
|
388
|
+
children: unknown;
|
|
389
|
+
} ? K : never]: C[K] extends {
|
|
390
|
+
kind: string;
|
|
391
|
+
} ? PrefValueOf<C[K]> : PrefValuesOf<C[K]>;
|
|
392
|
+
} : never;
|
|
393
|
+
|
|
394
|
+
export { PREF_CONDITION_FIELDS, PREF_ENTRY, PrefAction, PrefActions, PrefBoolean, PrefColor, PrefCondition, PrefConditionReader, PrefEnumBase, PrefGroup, PrefLabel, PrefLeaf, PrefNumberBase, PrefObject, PrefSection, PrefSeparator, PrefString, ROOT_PREF_STATUS, applyPrefConditions, applyPrefEntryConditions, pref, prefDecodedValue, prefJudge, prefObjectBase, prefObjectField, prefObjectWithField, prefReader, prefSectionPath, prefShownReader, prefStatusAt, prefStatusIn, prefStatusUnder, prefValueAbsent, prefValueOrDefault, repairPrefValue, resolvePrefGroupConditions };
|
|
395
|
+
export type { PrefAtPath, PrefConditionField, PrefConditionJudge, PrefConditionsApplied, PrefConditionsOptions, PrefEntry, PrefEntryApplied, PrefFieldsOf, PrefGroupAt, PrefGroupPath, PrefLeafRest, PrefOwner, PrefPath, PrefStatus, PrefStatusAtOptions, PrefValidator, PrefValueAt, PrefValueOf, PrefValuesOf, PresetDescription };
|