@weasel-js/prefs 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/{chunk-5KB3WBJZ.js → chunk-ASSX3JHY.js} +363 -46
- package/dist/chunk-ASSX3JHY.js.map +1 -0
- package/dist/index.d.ts +99 -3
- package/dist/index.js +172 -37
- package/dist/index.js.map +1 -1
- package/dist/{open-BEY-aOGe.d.ts → open-C83pU7Va.d.ts} +112 -10
- package/dist/react.d.ts +8 -3
- package/dist/react.js +11 -3
- package/dist/react.js.map +1 -1
- package/package.json +5 -4
- package/dist/chunk-5KB3WBJZ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { prefLeafHoldingIn, prefLeafHolding, prefSchemaHolding, UNSEEN, prefConditionHolds, prefValueAtPath, isPrefSection, prefSectionLeaves, isPrefLeaf, prefLeafAt, prefAliasTarget, prefAliasedLeaf, pairRowsOf, prefConditionReadsItem, visiblePrefSubtree } from './chunk-
|
|
2
|
-
export { PREF_KINDS, VERSION_RECORD, checkPrefCondition, checkPrefConditions, filterPrefSubtree, flattenPrefValues, isBuiltinPref, isPrefCondition, isPrefLeaf, isPrefLinearUnit, isPrefSection, mapPrefConditionPaths, openPrefs, openPrefsSync, pairRowsOf, prefAliasName, prefAliasTarget, prefAliasedLeaf, prefConditionHolds, prefConditionPaths, prefConditionReadsItem, prefDisplayBounds, prefHoldsValue, prefIsEnabled, prefIsShown, prefLeafAt, prefLeaves, prefSchemaHolding, prefSectionLeaves, prefUnit, prefValueAtPath, prefVariantDefault, prefVariantOf, repairPrefValue, resolvePrefUnit, visiblePrefSubtree } from './chunk-
|
|
1
|
+
import { prefLeafHoldingIn, prefLeafHolding, prefSchemaHolding, UNSEEN, prefConditionHolds, prefValueAtPath, isPrefSection, prefSectionLeaves, isPrefLeaf, prefLeafAt, prefLeaves, prefHoldsValue, prefSelectors, prefAliasTarget, prefAliasedLeaf, isBuiltinPref, pairRowsOf, prefConditionReadsItem, visiblePrefSubtree, resolvePrefUnit, isPrefLocus } from './chunk-ASSX3JHY.js';
|
|
2
|
+
export { PREF_BLENDS, PREF_KINDS, VERSION_RECORD, checkPrefCondition, checkPrefConditions, checkPrefSplits, filterPrefSubtree, flattenPrefValues, isBuiltinPref, isPrefCondition, isPrefLeaf, isPrefLinearUnit, isPrefLocus, isPrefSection, mapPrefConditionPaths, openPrefs, openPrefsSync, pairRowsOf, prefAliasName, prefAliasTarget, prefAliasedLeaf, prefConditionHolds, prefConditionPaths, prefConditionReadsItem, prefDisplayBounds, prefHoldsValue, prefIsEnabled, prefIsShown, prefLeafAt, prefLeaves, memberAt as prefLocusMember, locusSelectors as prefLocusSelectors, prefSchemaHolding, prefSectionLeaves, prefUnit, prefValueAtPath, prefVariantDefault, prefVariantOf, repairPrefValue, resolvePrefUnit, visiblePrefSubtree } from './chunk-ASSX3JHY.js';
|
|
3
3
|
|
|
4
4
|
// src/tabRuns.ts
|
|
5
5
|
function prefTabRuns(items, isTab) {
|
|
@@ -19,9 +19,9 @@ function prefTabRuns(items, isTab) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// src/shown.ts
|
|
22
|
-
function prefShownValue(
|
|
23
|
-
if (
|
|
24
|
-
const { encoding } =
|
|
22
|
+
function prefShownValue(leaf2, stored, siblings) {
|
|
23
|
+
if (leaf2.kind !== "boolean" && leaf2.kind !== "enum") return stored;
|
|
24
|
+
const { encoding } = leaf2;
|
|
25
25
|
return encoding ? encoding.read(stored, siblings) : stored;
|
|
26
26
|
}
|
|
27
27
|
function prefShownReader(schema, read, item, over) {
|
|
@@ -55,9 +55,9 @@ function prefReader(schema, values, over) {
|
|
|
55
55
|
if (held !== void 0) return held;
|
|
56
56
|
if (beyond && prefSchemaHolding(schema, path, over) === over) return beyond(path);
|
|
57
57
|
if (isPrefSection(schema)) {
|
|
58
|
-
for (const [key,
|
|
59
|
-
if (path === key) return
|
|
60
|
-
if (path.startsWith(`${key}.`)) return prefValueAtPath(
|
|
58
|
+
for (const [key, leaf2] of prefSectionLeaves(schema.members)) {
|
|
59
|
+
if (path === key) return leaf2.default;
|
|
60
|
+
if (path.startsWith(`${key}.`)) return prefValueAtPath(leaf2.default, path.slice(key.length + 1));
|
|
61
61
|
}
|
|
62
62
|
return void 0;
|
|
63
63
|
}
|
|
@@ -91,18 +91,18 @@ function scopeAmong(held, rest, above, holds) {
|
|
|
91
91
|
}
|
|
92
92
|
return void 0;
|
|
93
93
|
}
|
|
94
|
-
function scopeInside(
|
|
95
|
-
if (
|
|
96
|
-
if (
|
|
97
|
-
const { item } =
|
|
94
|
+
function scopeInside(leaf2, rest, scope, holds) {
|
|
95
|
+
if (leaf2.kind === "object") return scopeAmong(leaf2.children, rest, scope, holds) ?? scope;
|
|
96
|
+
if (leaf2.kind === "list" || leaf2.kind === "map") {
|
|
97
|
+
const { item } = leaf2;
|
|
98
98
|
if (item === void 0) return scope;
|
|
99
99
|
const inItem = deferEntryConditions(holds);
|
|
100
100
|
const entry = prefScopeUnder(scope, { enableIf: item.enableIf }, inItem);
|
|
101
101
|
const dot = rest.indexOf(".");
|
|
102
102
|
return dot < 0 ? entry : scopeInside(item, rest.slice(dot + 1), entry, inItem);
|
|
103
103
|
}
|
|
104
|
-
if (
|
|
105
|
-
for (const variant of Object.values(
|
|
104
|
+
if (leaf2.kind !== "union") return scope;
|
|
105
|
+
for (const variant of Object.values(leaf2.variants)) {
|
|
106
106
|
const found = scopeAmong(variant.children, rest, scope, holds);
|
|
107
107
|
if (found) return found;
|
|
108
108
|
}
|
|
@@ -133,8 +133,8 @@ function prefAliasScope(own, alias, over, holds) {
|
|
|
133
133
|
}
|
|
134
134
|
function prefScopeAt(schema, path, holds, { aliasOver, aliasHolds } = {}) {
|
|
135
135
|
const own = scopeAt(schema, path, holds);
|
|
136
|
-
const
|
|
137
|
-
return
|
|
136
|
+
const leaf2 = prefLeafAt(schema, path);
|
|
137
|
+
return leaf2?.kind === "alias" ? prefAliasScope(own, leaf2, aliasOver ?? schema, aliasHolds ?? holds) : own;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// src/scope.ts
|
|
@@ -142,7 +142,7 @@ var under = (prefix, key) => prefix === "" ? key : `${prefix}.${key}`;
|
|
|
142
142
|
function leafWalk({ keepEmpty, keepHidden, inItem, aliasOver, aliasHolds }) {
|
|
143
143
|
const disabled = /* @__PURE__ */ new Set();
|
|
144
144
|
const hidden = /* @__PURE__ */ new Set();
|
|
145
|
-
const
|
|
145
|
+
const leaf2 = (node, path, above, holds) => {
|
|
146
146
|
const own = prefScopeUnder(above, node, holds);
|
|
147
147
|
const scope = node.kind === "alias" && aliasOver ? prefAliasScope(own, node, aliasOver, aliasHolds ?? holds) : own;
|
|
148
148
|
return scope.shown || keepHidden ? inside(node, path, scope, holds) : null;
|
|
@@ -175,7 +175,7 @@ function leafWalk({ keepEmpty, keepHidden, inItem, aliasOver, aliasHolds }) {
|
|
|
175
175
|
let changed = false;
|
|
176
176
|
const out = {};
|
|
177
177
|
for (const [key, child] of Object.entries(held)) {
|
|
178
|
-
const kept = isPrefLeaf(child) ?
|
|
178
|
+
const kept = isPrefLeaf(child) ? leaf2(child, under(prefix, key), above, holds) : section(child, prefix, above, holds);
|
|
179
179
|
changed ||= kept !== child;
|
|
180
180
|
if (kept !== null) out[key] = kept;
|
|
181
181
|
}
|
|
@@ -188,7 +188,7 @@ function leafWalk({ keepEmpty, keepHidden, inItem, aliasOver, aliasHolds }) {
|
|
|
188
188
|
if (kept === node.members) return node;
|
|
189
189
|
return Object.keys(kept).length === 0 && !keepEmpty ? null : { ...node, members: kept };
|
|
190
190
|
};
|
|
191
|
-
return { disabled, hidden, leaf, inside, members };
|
|
191
|
+
return { disabled, hidden, leaf: leaf2, inside, members };
|
|
192
192
|
}
|
|
193
193
|
function applyPrefConditions(schema, holds, { keepEmpty = false, keepHidden = false, aliasOver, aliasHolds } = {}) {
|
|
194
194
|
const walk = leafWalk({ keepEmpty, keepHidden, inItem: deferEntryConditions(holds), aliasOver: aliasOver ?? schema, aliasHolds });
|
|
@@ -223,11 +223,133 @@ function applyPrefEntryConditions(item, path, holds, { keepEmpty = false, keepHi
|
|
|
223
223
|
return { item: walk.inside(item, path, scope, asked), disabled: walk.disabled, hidden: walk.hidden };
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
// src/build.ts
|
|
227
|
+
var leaf = (kind, name, def, rest) => ({ kind, name, description: "", default: def, ...rest });
|
|
228
|
+
var labeled = (value) => value === "" ? value : value[0].toUpperCase() + value.slice(1);
|
|
229
|
+
var pref = {
|
|
230
|
+
/** A group: `children` nest under its key, which is a segment of their paths. */
|
|
231
|
+
group(name, children, options) {
|
|
232
|
+
return { name, ...options, children };
|
|
233
|
+
},
|
|
234
|
+
/** A section: a heading over `members`, whose key adds nothing to their paths. */
|
|
235
|
+
section(name, members, options) {
|
|
236
|
+
return { name, ...options, members };
|
|
237
|
+
},
|
|
238
|
+
number: (name, def, rest) => leaf("number", name, def, rest),
|
|
239
|
+
boolean: (name, def, rest) => leaf("boolean", name, def, rest),
|
|
240
|
+
string: (name, def, rest) => leaf("string", name, def, rest),
|
|
241
|
+
color: (name, def, rest) => leaf("color", name, def, rest),
|
|
242
|
+
/** A fixed set of choices. An option given as its value alone is labeled with that value, its first letter raised. */
|
|
243
|
+
enum(name, def, options, rest) {
|
|
244
|
+
const full = options.map((option) => typeof option === "string" ? { value: option, label: labeled(option) } : option);
|
|
245
|
+
return { kind: "enum", name, description: "", default: def, ...rest, options: full };
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/css.ts
|
|
250
|
+
var kebab = (path) => path.replace(/\./g, "-").replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
251
|
+
var CSS_UNITS = {
|
|
252
|
+
px: "px",
|
|
253
|
+
"%": "%",
|
|
254
|
+
em: "em",
|
|
255
|
+
rem: "rem",
|
|
256
|
+
ch: "ch",
|
|
257
|
+
pt: "pt",
|
|
258
|
+
vw: "vw",
|
|
259
|
+
vh: "vh",
|
|
260
|
+
ms: "ms",
|
|
261
|
+
s: "s",
|
|
262
|
+
"\xB0": "deg",
|
|
263
|
+
deg: "deg",
|
|
264
|
+
rad: "rad",
|
|
265
|
+
turn: "turn"
|
|
266
|
+
};
|
|
267
|
+
var IDENT = /^-?[A-Za-z_][\w-]*$/;
|
|
268
|
+
var quoted = (text) => `'${text.replace(/[\\']/g, "\\$&")}'`;
|
|
269
|
+
function cssValue(leaf2, value) {
|
|
270
|
+
switch (leaf2.kind) {
|
|
271
|
+
case "number": {
|
|
272
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
273
|
+
const { unit } = leaf2;
|
|
274
|
+
const resolved = unit ? resolvePrefUnit(unit) : void 0;
|
|
275
|
+
const shown = resolved ? resolved.toDisplay(value) : value;
|
|
276
|
+
const suffix = resolved?.suffix !== void 0 && Object.hasOwn(CSS_UNITS, resolved.suffix) ? CSS_UNITS[resolved.suffix] : "";
|
|
277
|
+
return `${Number(shown.toFixed(6))}${suffix}`;
|
|
278
|
+
}
|
|
279
|
+
case "boolean":
|
|
280
|
+
return typeof value === "boolean" ? value ? "1" : "0" : null;
|
|
281
|
+
case "color":
|
|
282
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
283
|
+
case "enum":
|
|
284
|
+
if (typeof value !== "string" || leaf2.encoding) return null;
|
|
285
|
+
return IDENT.test(value) ? value : quoted(value);
|
|
286
|
+
case "string":
|
|
287
|
+
return typeof value === "string" ? quoted(value) : null;
|
|
288
|
+
default:
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function toldApart(held, optionsOf, absent) {
|
|
293
|
+
const out = [];
|
|
294
|
+
const walk = (value, under2) => {
|
|
295
|
+
if (!isPrefLocus(value)) {
|
|
296
|
+
out.push({ under: under2, value });
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
for (const option of optionsOf(value.$by)) {
|
|
300
|
+
walk(Object.hasOwn(value.$of, option) ? value.$of[option] : absent, [...under2, [value.$by, option]]);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
walk(held, []);
|
|
304
|
+
return out;
|
|
305
|
+
}
|
|
306
|
+
function prefsCss(store, options = {}) {
|
|
307
|
+
const root = options.root ?? ":root";
|
|
308
|
+
const property = options.property ?? ((path) => `--${kebab(path)}`);
|
|
309
|
+
const attribute = options.attribute ?? ((selector) => `data-${kebab(selector)}`);
|
|
310
|
+
const leaves = new Map([...prefLeaves(store.schema)].filter(([, leaf2]) => prefHoldsValue(leaf2)));
|
|
311
|
+
const selectors = prefSelectors(leaves);
|
|
312
|
+
const defaults = Object.fromEntries([...selectors.keys()].map((path) => [path, leaves.get(path).default]));
|
|
313
|
+
const base = store.values({ at: defaults });
|
|
314
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
315
|
+
const declare = (under2, path, leaf2, value) => {
|
|
316
|
+
const name = property(path, leaf2);
|
|
317
|
+
if (name === null) return;
|
|
318
|
+
const given = options.value?.(value, leaf2, path);
|
|
319
|
+
const text = given === void 0 ? cssValue(leaf2, value) : given;
|
|
320
|
+
if (text === null) return;
|
|
321
|
+
const key = under2.map(([selector, option]) => `${selector}=${option}`).join("&");
|
|
322
|
+
if (!blocks.has(key)) blocks.set(key, { under: under2, lines: [] });
|
|
323
|
+
blocks.get(key).lines.push(` ${name}: ${text};`);
|
|
324
|
+
};
|
|
325
|
+
for (const [path, leaf2] of leaves) {
|
|
326
|
+
declare([], path, leaf2, prefValueAtPath(base, path));
|
|
327
|
+
const own = selectors.get(path);
|
|
328
|
+
if (own) for (const option of own) declare([[path, option]], path, leaf2, option);
|
|
329
|
+
const held = store.locus(path);
|
|
330
|
+
if (!held) continue;
|
|
331
|
+
for (const { under: under2, value } of toldApart(held, (selector) => selectors.get(selector) ?? [], leaf2.default)) {
|
|
332
|
+
declare(under2, path, leaf2, value);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return [...blocks.values()].map((block, i) => ({ ...block, i })).sort((a, b) => a.under.length - b.under.length || a.i - b.i).map(({ under: under2, lines }) => {
|
|
336
|
+
const matched = under2.map(([selector, option]) => `[${attribute(selector)}=${quoted(option)}]`).join("");
|
|
337
|
+
return `:where(${root}${matched}) {
|
|
338
|
+
${lines.join("\n")}
|
|
339
|
+
}`;
|
|
340
|
+
}).join("\n\n");
|
|
341
|
+
}
|
|
342
|
+
function prefsCssAttributes(store, options = {}) {
|
|
343
|
+
const attribute = options.attribute ?? ((selector) => `data-${kebab(selector)}`);
|
|
344
|
+
const leaves = prefLeaves(store.schema);
|
|
345
|
+
return Object.fromEntries([...prefSelectors(leaves).keys()].map((path) => [attribute(path), store.get(path)]));
|
|
346
|
+
}
|
|
347
|
+
|
|
226
348
|
// src/aliasTargets.ts
|
|
227
|
-
function visibleFieldsOf(
|
|
228
|
-
if (
|
|
229
|
-
const shown = visiblePrefSubtree({ ...
|
|
230
|
-
return { ...
|
|
349
|
+
function visibleFieldsOf(leaf2) {
|
|
350
|
+
if (leaf2.kind !== "object") return leaf2;
|
|
351
|
+
const shown = visiblePrefSubtree({ ...leaf2, hidden: false }, false, true);
|
|
352
|
+
return { ...leaf2, children: shown.children };
|
|
231
353
|
}
|
|
232
354
|
function prefAliasTargets(over, judge, { showHidden = false, markHidden = false } = {}) {
|
|
233
355
|
const holds = judge();
|
|
@@ -235,8 +357,8 @@ function prefAliasTargets(over, judge, { showHidden = false, markHidden = false
|
|
|
235
357
|
const get = () => applied ??= applyPrefConditions(over, holds, { keepEmpty: true, keepHidden: markHidden });
|
|
236
358
|
const leafAt = (path) => {
|
|
237
359
|
const { shown } = get();
|
|
238
|
-
const
|
|
239
|
-
return
|
|
360
|
+
const leaf2 = shown === null ? void 0 : prefLeafAt(shown, path);
|
|
361
|
+
return leaf2 === void 0 || showHidden ? leaf2 : visibleFieldsOf(leaf2);
|
|
240
362
|
};
|
|
241
363
|
return {
|
|
242
364
|
holds,
|
|
@@ -253,20 +375,20 @@ function prefAliasTargets(over, judge, { showHidden = false, markHidden = false
|
|
|
253
375
|
|
|
254
376
|
// src/object.ts
|
|
255
377
|
var isObject = (v) => typeof v === "object" && v !== null;
|
|
256
|
-
function prefObjectBase(
|
|
378
|
+
function prefObjectBase(pref2, held) {
|
|
257
379
|
if (isObject(held)) return held;
|
|
258
|
-
return
|
|
380
|
+
return pref2.fromScalar?.(held) ?? (isObject(pref2.default) ? pref2.default : {});
|
|
259
381
|
}
|
|
260
|
-
function prefObjectWithField(
|
|
261
|
-
const base = prefObjectBase(
|
|
382
|
+
function prefObjectWithField(pref2, held, key, value) {
|
|
383
|
+
const base = prefObjectBase(pref2, held);
|
|
262
384
|
if (value !== void 0) return { ...base, [key]: value };
|
|
263
385
|
const { [key]: _dropped, ...rest } = base;
|
|
264
386
|
return rest;
|
|
265
387
|
}
|
|
266
388
|
|
|
267
389
|
// src/type.ts
|
|
268
|
-
function prefType(name,
|
|
269
|
-
return { ...
|
|
390
|
+
function prefType(name, leaf2) {
|
|
391
|
+
return { ...leaf2, type: name };
|
|
270
392
|
}
|
|
271
393
|
|
|
272
394
|
// src/groups.ts
|
|
@@ -274,6 +396,19 @@ function prefGroupIsPage(group) {
|
|
|
274
396
|
return group.as === void 0 || group.as === "page";
|
|
275
397
|
}
|
|
276
398
|
|
|
399
|
+
// src/heading.ts
|
|
400
|
+
function prefFitsHeading(leaf2) {
|
|
401
|
+
return (leaf2.kind === "boolean" || leaf2.kind === "enum") && isBuiltinPref(leaf2);
|
|
402
|
+
}
|
|
403
|
+
function prefHeadingKey(node) {
|
|
404
|
+
if (node.name === "") return void 0;
|
|
405
|
+
const held = "members" in node ? node.members : node.children;
|
|
406
|
+
for (const [key, child] of Object.entries(held)) {
|
|
407
|
+
if (isPrefLeaf(child) && child.heading === true && prefFitsHeading(child)) return key;
|
|
408
|
+
}
|
|
409
|
+
return void 0;
|
|
410
|
+
}
|
|
411
|
+
|
|
277
412
|
// src/pair.ts
|
|
278
413
|
function pairRuns(items, leafOf) {
|
|
279
414
|
const leaves = items.map(leafOf);
|
|
@@ -310,14 +445,14 @@ var PREF_KIND_TRAITS = {
|
|
|
310
445
|
label: ONE,
|
|
311
446
|
separator: ONE
|
|
312
447
|
};
|
|
313
|
-
var traitsOf = (
|
|
314
|
-
function prefIsCompound(
|
|
315
|
-
return traitsOf(
|
|
448
|
+
var traitsOf = (leaf2) => Object.hasOwn(PREF_KIND_TRAITS, leaf2.kind) ? PREF_KIND_TRAITS[leaf2.kind] : ONE;
|
|
449
|
+
function prefIsCompound(leaf2) {
|
|
450
|
+
return traitsOf(leaf2).compound;
|
|
316
451
|
}
|
|
317
|
-
function prefDrawsSeveral(
|
|
318
|
-
return traitsOf(
|
|
452
|
+
function prefDrawsSeveral(leaf2) {
|
|
453
|
+
return traitsOf(leaf2).several;
|
|
319
454
|
}
|
|
320
455
|
|
|
321
|
-
export { PREF_ENTRY, PREF_KIND_TRAITS, PREF_SCOPE, applyPrefConditions, applyPrefEntryConditions, pairRuns, prefAliasTargets, prefDrawsSeveral, prefGroupIsPage, prefIsCompound, prefJudge, prefObjectBase, prefObjectWithField, prefReader, prefScopeAt, prefScopeUnder, prefShownReader, prefShownValue, prefTabRuns, prefType };
|
|
456
|
+
export { PREF_ENTRY, PREF_KIND_TRAITS, PREF_SCOPE, applyPrefConditions, applyPrefEntryConditions, pairRuns, pref, prefAliasTargets, prefDrawsSeveral, prefFitsHeading, prefGroupIsPage, prefHeadingKey, prefIsCompound, prefJudge, prefObjectBase, prefObjectWithField, prefReader, prefScopeAt, prefScopeUnder, prefShownReader, prefShownValue, prefTabRuns, prefType, prefsCss, prefsCssAttributes };
|
|
322
457
|
//# sourceMappingURL=index.js.map
|
|
323
458
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tabRuns.ts","../src/shown.ts","../src/judge.ts","../src/scopeAt.ts","../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AAK,GAAI,EAAE,KAAA,EAAO,CAAC,MAAM,CAAC,CAAE,GAAG,CAAA;AACjF,IAAA,CAAA,GAAI,CAAA;AAAA,EACN;AACA,EAAA,OAAO,IAAA;AACT;;;ACnBA,IAAM,GAAA,GAAsB,EAAE,QAAA,EAAU,KAAA,EAAO,SAAS,KAAA,EAAM;AAC9D,IAAM,IAAA,GAAuB,EAAE,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AAQtD,IAAM,gBAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,GAAA;AAAA,EACR,OAAA,EAAS,GAAA;AAAA,EACT,MAAA,EAAQ,GAAA;AAAA,EACR,IAAA,EAAM,GAAA;AAAA,EACN,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,IAAA,EAAM,IAAA;AAAA,EACN,GAAA,EAAK,IAAA;AAAA,EACL,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,MAAA,EAAQ,EAAE,QAAA,EAAU,KAAA,EAAO,SAAS,IAAA,EAAK;AAAA,EACzC,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,SAAA,EAAW;AACb;AAEA,IAAM,QAAA,GAAW,CAAC,IAAA,KACf,MAAA,CAAO,MAAA,CAAO,gBAAA,EAAkB,IAAA,CAAK,IAAI,CAAA,GAAI,gBAAA,CAAiB,IAAA,CAAK,IAAgB,CAAA,GAAI,GAAA;AAGnF,SAAS,eAAe,IAAA,EAAiC;AAC9D,EAAA,OAAO,QAAA,CAAS,IAAI,CAAA,CAAE,QAAA;AACxB;AAGO,SAAS,iBAAiB,IAAA,EAAiC;AAChE,EAAA,OAAO,QAAA,CAAS,IAAI,CAAA,CAAE,OAAA;AACxB","file":"index.js","sourcesContent":["/** One step of a walk over a group's children: a child on its own, or the neighboring `tab` children that share one strip. */\nexport type PrefTabRun<T> = { item: T; tabs?: undefined } | { tabs: readonly T[]; item?: undefined };\n\n/**\n * `items` in order, each run of neighbors `isTab` holds for folded into one step. What a surface leaves out of\n * `items` neither joins a run nor ends one, and what it keeps and then declines to draw still holds its run together.\n */\nexport function prefTabRuns<T>(items: readonly T[], isTab: (item: T) => boolean): PrefTabRun<T>[] {\n const out: PrefTabRun<T>[] = [];\n let run: T[] | undefined;\n for (const item of items) {\n if (!isTab(item)) {\n run = undefined;\n out.push({ item });\n } else if (run) {\n run.push(item);\n } else {\n out.push({ tabs: (run = [item]) });\n }\n }\n return out;\n}\n","// A stored value as the control over its leaf shows it. A condition compares\n// that, and not the stored form: a person writes \"is on\" about an Italic\n// toggle, whatever string the toggle stores.\n\nimport type { PrefConditionReader } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { prefLeafHolding, prefLeafHoldingIn, prefSchemaHolding, UNSEEN } from './holding';\nimport type { PrefBoolean, PrefEnum, PrefLeaf } from './schema';\n\ntype Siblings = Record<string, unknown> | undefined;\n\n/** What the control over `leaf` shows for `stored`: what its `encoding` reads it as, else `stored` itself.\n * `siblings` is the object the leaf is a field of. */\nexport function prefShownValue(leaf: PrefLeaf, stored: unknown, siblings?: Record<string, unknown>): unknown {\n if (leaf.kind !== 'boolean' && leaf.kind !== 'enum') return stored;\n const { encoding } = leaf as PrefBoolean | PrefEnum;\n return encoding ? (encoding.read as (stored: unknown, siblings: Siblings) => unknown)(stored, siblings) : stored;\n}\n\n/**\n * `read` with each value handed back as {@link prefShownValue} gives it, for\n * the leaf of `schema` at that path, a field of an `object` or a `union` leaf\n * included. A field's siblings are what `read` finds at its leaf's path. A\n * path read from the entry is held to `item`, the leaf describing that entry.\n * A path no leaf of `schema` holds is held to `over`, the schema it is drawn\n * over.\n */\nexport function prefShownReader(\n schema: PrefGroup | PrefSection, read: PrefConditionReader, item?: PrefLeaf, over?: PrefGroup | PrefSection,\n): PrefConditionReader {\n return (path, from) => {\n const stored = read(path, from);\n const held = from === 'item' ? item && prefLeafHoldingIn(item, path) : prefLeafHolding(prefSchemaHolding(schema, path, over), path);\n if (held === undefined || held === UNSEEN) return stored;\n const object = held.within === undefined ? undefined : read(held.within, from);\n return prefShownValue(held.leaf, stored, typeof object === 'object' && object !== null ? (object as Siblings) : undefined);\n };\n}\n","// Who answers a condition: a judge, made from a way to read values.\n\nimport { prefConditionHolds, prefConditionReadsItem, type PrefCondition, type PrefConditionReader } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefSectionLeaves, prefValueAtPath } from './helpers';\nimport { prefSchemaHolding } from './holding';\nimport type { PrefLeaf } from './schema';\nimport { prefShownReader } from './shown';\n\n/** Which of a node's two conditions a {@link PrefConditionJudge} is asked about. */\nexport type PrefConditionField = 'showIf' | 'enableIf';\n\n/**\n * Says whether one condition holds. {@link prefJudge} makes one from a value\n * reader; a surface drawing several values at once writes its own, to say\n * what a condition that holds for some and not for others comes to.\n */\nexport type PrefConditionJudge = (condition: PrefCondition, field: PrefConditionField) => boolean;\n\n/** One entry of a list or a map: the `item` leaf describing it, and what it holds. */\nexport interface PrefEntry {\n item: PrefLeaf;\n value: unknown;\n}\n\n/** What `entry` holds at `path`, the empty path being the entry itself: its own value, else that part of the item's default. */\nfunction entryValue({ item, value }: PrefEntry, path: string): unknown {\n if (path === '') return value !== undefined ? value : item.default;\n const held = prefValueAtPath(value, path);\n return held !== undefined ? held : prefValueAtPath(item.default, path);\n}\n\n/**\n * A judge over one set of values, read by path. A condition compares each\n * value as the control over its leaf in `schema` shows it\n * ({@link prefShownReader}), so `read` hands back what is stored. A test\n * that reads from the entry (`from: 'item'`) reads `entry`, and finds nothing\n * held where none is given. `over` is the schema `schema` is drawn over: a\n * path no leaf of `schema` holds is compared as the leaf of `over` there\n * shows it.\n */\nexport function prefJudge(\n schema: PrefGroup | PrefSection, read: (path: string) => unknown, entry?: PrefEntry, over?: PrefGroup | PrefSection,\n): PrefConditionJudge {\n const stored: PrefConditionReader = (path, from) => (from === 'item' ? entry && entryValue(entry, path) : read(path));\n const shown = prefShownReader(schema, stored, entry?.item, over);\n return (condition) => prefConditionHolds(condition, shown);\n}\n\n/**\n * `holds` for every condition but one that reads the entry, which is left\n * unanswered, which is to say holding: what a walk with no entry in hand\n * asks inside the item of a list or a map.\n */\nexport function deferEntryConditions(holds: PrefConditionJudge): PrefConditionJudge {\n return (condition, field) => prefConditionReadsItem(condition) || holds(condition, field);\n}\n\n/**\n * Reads a value by path the way a form over `schema` shows it: what `values`\n * holds there, else the default of the leaf at that path, or the part of a\n * leaf's default the rest of the path names. `over` is the schema `schema`\n * is drawn over: a path no leaf of `schema` holds takes its default there.\n */\nexport function prefReader(schema: PrefGroup | PrefSection, values: unknown, over?: PrefGroup | PrefSection): (path: string) => unknown {\n const beyond = over && prefReader(over, values);\n return (path) => {\n const held = prefValueAtPath(values, path);\n if (held !== undefined) return held;\n if (beyond && prefSchemaHolding(schema, path, over) === over) return beyond(path);\n if (isPrefSection(schema)) {\n for (const [key, leaf] of prefSectionLeaves(schema.members)) {\n if (path === key) return leaf.default;\n if (path.startsWith(`${key}.`)) return prefValueAtPath(leaf.default, path.slice(key.length + 1));\n }\n return undefined;\n }\n const steps = path.split('.');\n let node: PrefGroup = schema;\n for (let i = 0; i < steps.length; i++) {\n if (!Object.hasOwn(node.children, steps[i]!)) return undefined;\n const child: PrefLeaf | PrefGroup = node.children[steps[i]!]!;\n if (!isPrefLeaf(child)) node = child;\n else return i === steps.length - 1 ? child.default : prefValueAtPath(child.default, steps.slice(i + 1).join('.'));\n }\n return undefined;\n };\n}\n","// The scope of one node: whether it is drawn and whether it takes input,\n// with everything above it counted.\n\nimport { prefAliasTarget, type PrefAlias } from './alias';\nimport type { PrefCondition } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefLeafAt } from './helpers';\nimport { deferEntryConditions, type PrefConditionJudge } from './judge';\nimport type { PrefList } from './list';\nimport type { PrefMap } from './map';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport type { PrefUnion } from './union';\n\n/** Whether a node is drawn and whether it takes input, with what is above it counted. */\nexport interface PrefScope {\n shown: boolean;\n enabled: boolean;\n}\n\n/** The step that stands for any entry of a `list` or a `map` in a path: `'phases.*.hold'` answers for that field of\n * each, by every condition that comes to the same for every entry. */\nexport const PREF_ENTRY = '*';\n\n/** The scope a schema's root sits in. */\nexport const PREF_SCOPE: PrefScope = Object.freeze({ shown: true, enabled: true });\n\n/** The scope of `node`, which sits directly under something whose scope is `above`. */\nexport function prefScopeUnder(\n above: PrefScope,\n node: { showIf?: PrefCondition; enableIf?: PrefCondition },\n holds: PrefConditionJudge,\n): PrefScope {\n const shown = above.shown && (node.showIf === undefined || holds(node.showIf, 'showIf'));\n const enabled = above.enabled && (node.enableIf === undefined || holds(node.enableIf, 'enableIf'));\n return shown === above.shown && enabled === above.enabled ? above : { shown, enabled };\n}\n\n/** The scope of the field at `rest` among an object leaf's children, or `undefined` when none is there. */\nfunction scopeAmong(\n held: PrefSection['members'], rest: string, above: PrefScope, holds: PrefConditionJudge,\n): PrefScope | undefined {\n for (const [key, child] of Object.entries(held)) {\n if (!isPrefLeaf(child)) {\n const found = scopeAmong(child.members, rest, prefScopeUnder(above, child, holds), holds);\n if (found) return found;\n } else if (rest === key) return prefScopeUnder(above, child, holds);\n else if (rest.startsWith(`${key}.`)) return scopeInside(child, rest.slice(key.length + 1), prefScopeUnder(above, child, holds), holds);\n }\n return undefined;\n}\n\n/** The scope at `rest` inside `leaf`, whose own scope is `scope`: that of a field, or the leaf's where `rest` names none. */\nfunction scopeInside(leaf: PrefLeaf, rest: string, scope: PrefScope, holds: PrefConditionJudge): PrefScope {\n if (leaf.kind === 'object') return scopeAmong((leaf as PrefObject).children, rest, scope, holds) ?? scope;\n if (leaf.kind === 'list' || leaf.kind === 'map') {\n const { item } = leaf as Partial<PrefList | PrefMap>;\n if (item === undefined) return scope;\n const inItem = deferEntryConditions(holds);\n const entry = prefScopeUnder(scope, { enableIf: item.enableIf }, inItem);\n const dot = rest.indexOf('.');\n return dot < 0 ? entry : scopeInside(item, rest.slice(dot + 1), entry, inItem);\n }\n if (leaf.kind !== 'union') return scope;\n for (const variant of Object.values((leaf as PrefUnion).variants)) {\n const found = scopeAmong(variant.children, rest, scope, holds);\n if (found) return found;\n }\n return scope;\n}\n\nfunction scopeAt(schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge): PrefScope {\n let scope = prefScopeUnder(PREF_SCOPE, schema, holds);\n if (path === '') return scope;\n if (isPrefSection(schema)) return scopeAmong(schema.members, path, scope, holds) ?? scope;\n let node: PrefGroup = schema;\n const steps = path.split('.');\n for (let i = 0; i < steps.length; i++) {\n if (!Object.hasOwn(node.children, steps[i]!)) return scope;\n const child: PrefLeaf | PrefGroup = node.children[steps[i]!]!;\n scope = prefScopeUnder(scope, child, holds);\n if (isPrefLeaf(child)) return i === steps.length - 1 ? scope : scopeInside(child, steps.slice(i + 1).join('.'), scope, holds);\n node = child;\n }\n return scope;\n}\n\n/** `own`, an alias's scope by its own conditions, narrowed by that of the leaf it shows in `over`, as `holds` judges `over`. */\nexport function prefAliasScope(own: PrefScope, alias: PrefAlias, over: PrefGroup | PrefSection, holds: PrefConditionJudge): PrefScope {\n const target = prefAliasTarget(alias, (path) => prefLeafAt(over, path));\n if (target === undefined) return own;\n const theirs = scopeAt(over, target.path, holds);\n const shown = own.shown && theirs.shown;\n const enabled = own.enabled && theirs.enabled;\n return shown === own.shown && enabled === own.enabled ? own : { shown, enabled };\n}\n\n/** What {@link prefScopeAt} is told beyond the schema. */\nexport interface PrefScopeAtOptions {\n /** The schema an alias's `of` names a leaf of. Default: the schema asked. */\n aliasOver?: PrefGroup | PrefSection;\n /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */\n aliasHolds?: PrefConditionJudge;\n}\n\n/**\n * The scope of the node at `path`: a group, a leaf, a field of an `object`\n * or a `union` leaf, or an entry of a `list` or a `map`, whose step may be\n * any key. Under a {@link PrefSection} schema a leaf's key is its whole\n * path. A path that runs past the schema answers for the last node it\n * reaches. An alias answers for itself and for the leaf it shows, as\n * `applyPrefConditions` has it. Inside an entry, a condition that reads the\n * entry (`from: 'item'`) is not asked and counts as holding, there being no\n * entry here to read: `applyPrefEntryConditions` answers it.\n */\nexport function prefScopeAt(\n schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge, { aliasOver, aliasHolds }: PrefScopeAtOptions = {},\n): PrefScope {\n const own = scopeAt(schema, path, holds);\n const leaf = prefLeafAt(schema, path);\n return leaf?.kind === 'alias' ? prefAliasScope(own, leaf as PrefAlias, aliasOver ?? schema, aliasHolds ?? holds) : own;\n}\n","// What a schema's conditions come to once nesting is counted: a node is drawn\n// only while it and everything above it is shown, and takes input only while\n// it and everything above it is enabled. Every surface that draws a schema\n// asks here.\n\nimport type { PrefAlias } from './alias';\nimport { prefConditionReadsItem } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection } from './helpers';\nimport { deferEntryConditions, type PrefConditionJudge } from './judge';\nimport type { PrefList } from './list';\nimport type { PrefMap } from './map';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport { PREF_ENTRY, PREF_SCOPE, prefAliasScope, prefScopeUnder, type PrefScope } from './scopeAt';\nimport type { PrefUnion } from './union';\n\nexport { prefJudge, prefReader, type PrefConditionField, type PrefConditionJudge, type PrefEntry } from './judge';\nexport { PREF_ENTRY, PREF_SCOPE, prefScopeAt, prefScopeUnder, type PrefScope, type PrefScopeAtOptions } from './scopeAt';\n\nconst under = (prefix: string, key: string): string => (prefix === '' ? key : `${prefix}.${key}`);\n\n/** A schema with its conditions applied. */\nexport interface PrefConditionsApplied<T> {\n /** The schema without the nodes that are not shown. The schema itself when\n * that is all of it, and `null` when its root is not shown. */\n shown: T | null;\n /**\n * The value path of every leaf that is disabled, a field of an `object` or\n * a `union` leaf included (`'stroke.width'`), and under a {@link PrefGroup}\n * schema the path of every group that is. A `list`'s or a `map`'s item is\n * named once for every entry, with {@link PREF_ENTRY} as the entry's step:\n * `'phases.*'`, and `'phases.*.hold'` for a field of it.\n */\n disabled: ReadonlySet<string>;\n /**\n * With `keepHidden`, the path of everything `shown` holds that is not\n * shown, named as `disabled` names what is disabled. Empty without it,\n * since `shown` then holds none.\n */\n hidden: ReadonlySet<string>;\n}\n\n/** How {@link applyPrefConditions} treats what it would leave out. */\nexport interface PrefConditionsOptions {\n /** Keep a group or a section that leaves with nothing to draw. */\n keepEmpty?: boolean;\n /**\n * Keep every node whose `showIf` fails, and name it in `hidden`: for a\n * surface that edits the schema, where a node not drawn cannot be picked.\n */\n keepHidden?: boolean;\n /** The schema an alias's `of` names a leaf of. Default: the schema walked. */\n aliasOver?: PrefGroup | PrefSection;\n /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */\n aliasHolds?: PrefConditionJudge;\n}\n\ninterface WalkOptions {\n keepEmpty: boolean;\n keepHidden: boolean;\n /** Asked inside the item of a list or a map met on the way, whose entries the walk does not have. */\n inItem: PrefConditionJudge;\n aliasOver?: PrefGroup | PrefSection;\n aliasHolds?: PrefConditionJudge;\n}\n\n/** The walk over leaves and what is inside them, which the schema's pass and an entry's share. */\nfunction leafWalk({ keepEmpty, keepHidden, inItem, aliasOver, aliasHolds }: WalkOptions) {\n const disabled = new Set<string>();\n const hidden = new Set<string>();\n\n const leaf = (node: PrefLeaf, path: string, above: PrefScope, holds: PrefConditionJudge): PrefLeaf | null => {\n const own = prefScopeUnder(above, node, holds);\n const scope = node.kind === 'alias' && aliasOver ? prefAliasScope(own, node as PrefAlias, aliasOver, aliasHolds ?? holds) : own;\n return scope.shown || keepHidden ? inside(node, path, scope, holds) : null;\n };\n\n /** `node`, whose scope is `scope`, without what its own value hides: a field, or part of a list's or a map's item. */\n const inside = (node: PrefLeaf, path: string, scope: PrefScope, holds: PrefConditionJudge): PrefLeaf => {\n if (!scope.shown) hidden.add(path);\n if (!scope.enabled) disabled.add(path);\n if (node.kind === 'object') {\n const children = members((node as PrefObject).children, path, scope, holds);\n return children === (node as PrefObject).children ? node : ({ ...node, children } as PrefLeaf);\n }\n if (node.kind === 'list' || node.kind === 'map') {\n const { item } = node as Partial<PrefList | PrefMap>;\n // A leaf an app's renderer draws under a built-in's kind may hold no item.\n if (item === undefined) return node;\n // An item is drawn with its entry, so its own `showIf` is not asked.\n const entry = inside(item, under(path, PREF_ENTRY), prefScopeUnder(scope, { enableIf: item.enableIf }, inItem), inItem);\n return entry === item ? node : ({ ...node, item: entry } as PrefLeaf);\n }\n if (node.kind !== 'union') return node;\n const { variants } = node as PrefUnion;\n let changed = false;\n const next: PrefUnion['variants'] = {};\n for (const [key, variant] of Object.entries(variants)) {\n const children = members(variant.children, path, scope, holds);\n changed ||= children !== variant.children;\n next[key] = children === variant.children ? variant : { ...variant, children };\n }\n return changed ? ({ ...node, variants: next } as PrefLeaf) : node;\n };\n\n /** A section's members or an object leaf's children. `prefix` is the object leaf's path, empty in a section schema. */\n const members = (held: PrefSection['members'], prefix: string, above: PrefScope, holds: PrefConditionJudge): PrefSection['members'] => {\n let changed = false;\n const out: PrefSection['members'] = {};\n for (const [key, child] of Object.entries(held)) {\n const kept = isPrefLeaf(child) ? leaf(child, under(prefix, key), above, holds) : section(child, prefix, above, holds);\n changed ||= kept !== child;\n if (kept !== null) out[key] = kept;\n }\n return changed ? out : held;\n };\n\n const section = (node: PrefSection, prefix: string, above: PrefScope, holds: PrefConditionJudge): PrefSection | null => {\n const scope = prefScopeUnder(above, node, holds);\n if (!scope.shown && !keepHidden) return null;\n const kept = members(node.members, prefix, scope, holds);\n if (kept === node.members) return node;\n return Object.keys(kept).length === 0 && !keepEmpty ? null : { ...node, members: kept };\n };\n\n return { disabled, hidden, leaf, inside, members };\n}\n\n/**\n * `schema` as it is drawn while `holds` says which conditions hold. A node\n * whose `showIf` fails is dropped with everything under it, unless\n * `keepHidden`, and so is a group or a section that leaves with nothing to\n * draw, unless `keepEmpty`. A node\n * whose `enableIf` fails is disabled with everything under it. The item of\n * a `list` or a `map` is walked as its entries are drawn: its fields hide and\n * disable by their conditions, and its own `enableIf` disables every entry.\n * A condition there that reads the entry (`from: 'item'`) has no one answer\n * for every entry and is left holding: {@link applyPrefEntryConditions}\n * answers it for each.\n * An alias is shown only while it and the leaf it shows both are, and enabled\n * only while both are, with everything above that leaf counted. That leaf is\n * looked for in `aliasOver`, and its side is asked of `aliasHolds`.\n * Parts with nothing dropped come back as the objects they were.\n */\nexport function applyPrefConditions<T extends PrefGroup | PrefSection>(\n schema: T,\n holds: PrefConditionJudge,\n { keepEmpty = false, keepHidden = false, aliasOver, aliasHolds }: PrefConditionsOptions = {},\n): PrefConditionsApplied<T> {\n const walk = leafWalk({ keepEmpty, keepHidden, inItem: deferEntryConditions(holds), aliasOver: aliasOver ?? schema, aliasHolds });\n const { disabled, hidden } = walk;\n\n const group = (node: PrefGroup, path: string, above: PrefScope): PrefGroup | null => {\n const scope = prefScopeUnder(above, node, holds);\n if (!scope.shown && !keepHidden) return null;\n if (!scope.shown && path !== '') hidden.add(path);\n if (!scope.enabled && path !== '') disabled.add(path);\n let changed = false;\n const children: PrefGroup['children'] = {};\n for (const [key, child] of Object.entries(node.children)) {\n const at = under(path, key);\n const kept = isPrefLeaf(child) ? walk.leaf(child, at, scope, holds) : group(child, at, scope);\n changed ||= kept !== child;\n if (kept !== null) children[key] = kept;\n }\n if (!changed) return node;\n return Object.keys(children).length === 0 && !keepEmpty && path !== '' ? null : { ...node, children };\n };\n\n if (!isPrefSection(schema)) return { shown: group(schema, '', PREF_SCOPE) as T | null, disabled, hidden };\n const scope = prefScopeUnder(PREF_SCOPE, schema, holds);\n if (!scope.shown && !keepHidden) return { shown: null, disabled, hidden };\n const kept = walk.members(schema.members, '', scope, holds);\n return { shown: kept === schema.members ? schema : { ...schema, members: kept }, disabled, hidden };\n}\n\n/** One entry of a list or a map with the conditions that read it applied. */\nexport interface PrefEntryApplied {\n /** The item as this entry draws it: without the fields not shown, and the item itself when that is all of them. */\n item: PrefLeaf;\n /** The path of the entry, and of every field in it, that is disabled, named as {@link PrefConditionsApplied} names them. */\n disabled: ReadonlySet<string>;\n /** With `keepHidden`, the path of every field of the entry that is not shown. */\n hidden: ReadonlySet<string>;\n}\n\nconst ALWAYS: PrefConditionJudge = () => true;\n\n/**\n * The conditions {@link applyPrefConditions} leaves unanswered, answered for\n * one entry: `item`, as that pass left it, drawn for the entry at `path`\n * (`'phases.2'`) while `holds` says which conditions hold. `holds` reads the\n * entry: `prefJudge` given it. Only a condition that reads the entry is\n * asked, the rest being applied already, and one inside a list or a map\n * within the entry is left for that one's own entries.\n */\nexport function applyPrefEntryConditions(\n item: PrefLeaf,\n path: string,\n holds: PrefConditionJudge,\n { keepEmpty = false, keepHidden = false }: Pick<PrefConditionsOptions, 'keepEmpty' | 'keepHidden'> = {},\n): PrefEntryApplied {\n const asked: PrefConditionJudge = (condition, field) => !prefConditionReadsItem(condition) || holds(condition, field);\n const walk = leafWalk({ keepEmpty, keepHidden, inItem: ALWAYS });\n const scope = prefScopeUnder(PREF_SCOPE, { enableIf: item.enableIf }, asked);\n return { item: walk.inside(item, path, scope, asked), disabled: walk.disabled, hidden: walk.hidden };\n}\n","// The leaves a surface's aliases show: the schema they point into, as that\n// schema's own conditions leave it. Every surface that draws an alias asks\n// here, whether the schema is its own or another's.\n\nimport { prefAliasedLeaf, prefAliasTarget, type PrefAlias } from './alias';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { prefLeafAt, visiblePrefSubtree } from './helpers';\nimport type { PrefConditionJudge, PrefEntry } from './judge';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport { applyPrefConditions, applyPrefEntryConditions, type PrefConditionsApplied, type PrefEntryApplied } from './scope';\n\n/** What an alias row reads of the leaf it shows: the schema that leaf is in, as that schema's own conditions leave it. */\nexport interface PrefAliasTargets {\n /** Says which conditions of that schema hold. */\n holds: PrefConditionJudge;\n /** The leaf at a path of that schema, without the fields the surface would leave out of the leaf's own row: one\n * marked `hidden`, and one a `showIf` hides, unless the surface draws those. */\n leafAt: (path: string) => PrefLeaf | undefined;\n /** The leaf `alias` is drawn as, under the alias's own name and description where it gives them, and the path\n * its value is read and written at. `undefined` for an alias of nothing. */\n shown: (alias: PrefAlias) => { path: string; leaf: PrefLeaf } | undefined;\n /** Whether the field at a path of that schema is one an `enableIf` disables. */\n disabledAt: (path: string) => boolean;\n /** Whether the field at a path of that schema is one a `showIf` hides, on a surface that draws those. */\n hiddenAt?: (path: string) => boolean;\n /** An entry of a list or a map of that schema, as the conditions that read the entry leave it. */\n entryAt: (item: PrefLeaf, path: string, value: unknown) => PrefEntryApplied;\n}\n\n/** What a surface draws beyond the default, which its alias rows follow. */\nexport interface PrefAliasTargetsOptions {\n /** The surface draws fields marked `hidden`. */\n showHidden?: boolean;\n /** The surface draws what a `showIf` hides, marked. */\n markHidden?: boolean;\n}\n\n/** `leaf` without its fields marked `hidden`. The leaf's own mark is not asked: an alias shows a leaf the surface leaves out. */\nfunction visibleFieldsOf(leaf: PrefLeaf): PrefLeaf {\n if (leaf.kind !== 'object') return leaf;\n const shown = visiblePrefSubtree({ ...leaf, hidden: false }, false, true) as PrefObject;\n return { ...leaf, children: shown.children } as PrefLeaf;\n}\n\n/**\n * {@link PrefAliasTargets} over `over`, the schema a surface's aliases point\n * into: the surface's own, or another's. `judge` answers `over`'s conditions\n * as the surface reads values, for one entry of a list or a map where it is\n * given one: `prefJudge` over `over`. A surface's own pass drops a leaf it\n * leaves out and keeps no path of another schema, so the leaves aliases show\n * are conditioned here, the first time one is asked for.\n */\nexport function prefAliasTargets(\n over: PrefGroup | PrefSection,\n judge: (entry?: PrefEntry) => PrefConditionJudge,\n { showHidden = false, markHidden = false }: PrefAliasTargetsOptions = {},\n): PrefAliasTargets {\n const holds = judge();\n let applied: PrefConditionsApplied<PrefGroup | PrefSection> | undefined;\n const get = (): PrefConditionsApplied<PrefGroup | PrefSection> =>\n (applied ??= applyPrefConditions(over, holds, { keepEmpty: true, keepHidden: markHidden }));\n const leafAt = (path: string): PrefLeaf | undefined => {\n const { shown } = get();\n const leaf = shown === null ? undefined : prefLeafAt(shown, path);\n return leaf === undefined || showHidden ? leaf : visibleFieldsOf(leaf);\n };\n return {\n holds,\n leafAt,\n shown: (alias) => {\n const target = prefAliasTarget(alias, leafAt);\n return target && { path: target.path, leaf: prefAliasedLeaf(alias, target.leaf) };\n },\n disabledAt: (path) => get().disabled.has(path),\n ...(markHidden ? { hiddenAt: (path: string) => get().hidden.has(path) } : {}),\n entryAt: (item, path, value) => applyPrefEntryConditions(item, path, judge({ item, value }), { keepHidden: markHidden }),\n };\n}\n","import type { PrefObject } from './schema';\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null;\n\n/**\n * The object a write to one field of an `object` leaf starts from: `held` itself where it is one. Where it is\n * not, the write has to make a whole object, so it starts from the scalar lifted by the leaf's `fromScalar`, else\n * from the leaf's `default`: one field on its own is a stroke with a width and no paint.\n */\nexport function prefObjectBase(pref: PrefObject, held: unknown): Record<string, unknown> {\n if (isObject(held)) return held;\n return pref.fromScalar?.(held) ?? (isObject(pref.default) ? pref.default : {});\n}\n\n/** The object an `object` leaf holds after one of its fields is set: {@link prefObjectBase} with `key` at\n * `value`, or without the key for `undefined`. */\nexport function prefObjectWithField(pref: PrefObject, held: unknown, key: string, value: unknown): Record<string, unknown> {\n const base = prefObjectBase(pref, held);\n if (value !== undefined) return { ...base, [key]: value };\n const { [key]: _dropped, ...rest } = base;\n return rest;\n}\n","import type { PrefLeaf } from './schema';\n\n/**\n * `leaf` as a named type: the same leaf carrying `name` in its `type` field.\n * Declared once beside the code that reads its value and used wherever a\n * schema wants one, spread with what that place sets for itself\n * (`{ ...GradientStop, name: 'First stop' }`), or as a list's or a map's\n * `item`. `name` is the identifier the type is exported under, which a schema\n * editor prints in place of the leaf's literal.\n */\nexport function prefType<L extends PrefLeaf>(name: string, leaf: L): L & { type: string } {\n return { ...leaf, type: name };\n}\n","// The two branch nodes of a schema. They differ in whether a key is part of\n// the path a leaf's value lives at, and each holds its members under its own\n// property, so a schema of one kind is neither assignable to nor walkable as\n// the other.\n\nimport type { PrefCondition } from './condition';\nimport type { PrefLeaf } from './schema';\n\n/**\n * How a {@link PrefGroup} is drawn: `page` gets an entry in a form's rail and\n * a pane of its own; `tab` shares a tab strip with the `tab` groups beside it;\n * `panel` is a bordered, titled box; `section` is a heading over its rows;\n * `fragment` draws nothing of its own, so its rows sit among its neighbors'\n * as though they were written there. A fragment exists to hold things\n * together: one key for their values to nest under, one node to move.\n */\nexport type PrefGroupAs = 'page' | 'tab' | 'panel' | 'section' | 'fragment' | 'bar';\n\n/** How a {@link PrefSection} is drawn. */\nexport type PrefSectionAs = Exclude<PrefGroupAs, 'page'>;\n\n/**\n * A group whose key is a path segment: `view` > `gridDensity` is the leaf at\n * `view.gridDensity`, and its value nests the same way. The shape of a\n * preferences schema — what `openPrefs` stores, `PrefsForm` renders, and a\n * tool declares its options as. A key holds no `.`.\n */\nexport interface PrefGroup {\n /** Heading for the group's rows. **Empty means no heading** — for a group\n * that exists to organize, not to name: one whose children are themselves\n * groups carrying the labels a reader needs. Give it a name whenever the\n * name is the referent (a `Border` group over `Top` / `Right` / `Bottom`\n * reads as nothing without it). */\n name: string;\n description?: string;\n /** How the group is drawn. Unset, its depth decides: a top-level group is a\n * `page`, and one inside another is a `section`. */\n as?: PrefGroupAs;\n /** Drawn, with everything under it, only while this holds. */\n showIf?: PrefCondition;\n /** Everything under it is disabled while this does not hold. */\n enableIf?: PrefCondition;\n children: Record<string, PrefLeaf | PrefGroup>;\n}\n\n/**\n * A heading over leaves that adds nothing to their paths: each member is\n * addressed by its own key alone, and the section's key only identifies the\n * section. The shape of a node's property schema, where a leaf's key is the\n * whole dotted node path (`pose.x`, `data.fill`), and of the headings inside\n * a {@link PrefObject}, where a key is relative to the object.\n */\nexport interface PrefSection {\n /** Heading for the section's rows. Empty means no heading, as for a\n * {@link PrefGroup}. */\n name: string;\n description?: string;\n /** How the section is drawn, as a {@link PrefGroup}'s `as` — without\n * `page`, since nothing that draws sections has a rail. Unset: a heading\n * over its rows. */\n as?: PrefSectionAs;\n /** As a {@link PrefGroup}'s. */\n showIf?: PrefCondition;\n /** As a {@link PrefGroup}'s. */\n enableIf?: PrefCondition;\n members: Record<string, PrefLeaf | PrefSection>;\n}\n\n/** Whether a top-level group gets a page of its own, and not a place on the page of the root's own leaves. */\nexport function prefGroupIsPage(group: PrefGroup): boolean {\n return group.as === undefined || group.as === 'page';\n}\n","import { pairRowsOf, type PrefLeaf } from './schema';\n\n/** Neighboring items one row draws, in {@link pairRuns}' answer. */\nexport interface PairRun<T> {\n items: T[];\n /** The pairing the items share: the path of the leaf that declared it, and what the row reads. Absent on a\n * run of one, which is no pair. */\n pair?: { key: string; label: string };\n}\n\n/**\n * `items` as the rows they draw, in order: each leaf a `pair` names joins the row of the leaf naming it where\n * the two are neighbors, and every other item is a run of its own. `leafOf` gives an item's leaf and the path a\n * `pair` would name it by, or nothing for an item that shares no row, which ends a run.\n */\nexport function pairRuns<T>(\n items: readonly T[],\n leafOf: (item: T) => readonly [path: string, leaf: PrefLeaf] | undefined,\n): PairRun<T>[] {\n const leaves = items.map(leafOf);\n const pairs = pairRowsOf(leaves.filter((entry) => entry !== undefined));\n const keys = leaves.map((entry) => (entry === undefined ? undefined : pairs.get(entry[0])));\n const runs: PairRun<T>[] = [];\n for (let i = 0; i < items.length; ) {\n const pair = keys[i];\n let j = i + 1;\n while (pair !== undefined && keys[j]?.key === pair.key) j += 1;\n runs.push(j - i > 1 ? { items: items.slice(i, j), pair } : { items: [items[i]!] });\n i = j;\n }\n return runs;\n}\n","import type { PrefKind } from './schema';\n\n/** What a surface has to know about a kind before it can lay its control out. */\nexport interface PrefKindTraits {\n /** Its value is made of other leaves' values: too much for one control on a\n * line, so a bar opens it in a popover and a compact panel in a dialog. */\n compound: boolean;\n /** Its control is several controls, or a button. A row drawn as a `<label>`\n * would hand a click on its text to the first of them. */\n several: boolean;\n}\n\nconst ONE: PrefKindTraits = { compound: false, several: false };\nconst MANY: PrefKindTraits = { compound: true, several: true };\n\n/**\n * The traits of every built-in kind. A `Record` over {@link PrefKind}, so a\n * kind added to the union does not compile until it says what it is here:\n * a plain set of kind names lets a new one through to draw inline in a\n * `<label>`, on a bar's line, and with no dialog row.\n */\nexport const PREF_KIND_TRAITS: Record<PrefKind, PrefKindTraits> = {\n number: ONE,\n boolean: ONE,\n string: ONE,\n enum: ONE,\n color: ONE,\n paint: ONE,\n object: MANY,\n list: MANY,\n map: MANY,\n union: MANY,\n field: ONE,\n action: { compound: false, several: true },\n alias: ONE,\n label: ONE,\n separator: ONE,\n};\n\nconst traitsOf = (leaf: { kind: string }): PrefKindTraits =>\n (Object.hasOwn(PREF_KIND_TRAITS, leaf.kind) ? PREF_KIND_TRAITS[leaf.kind as PrefKind] : ONE);\n\n/** Whether a leaf's value is made of other leaves' values. An app-defined kind is not: its renderer is one control. */\nexport function prefIsCompound(leaf: { kind: string }): boolean {\n return traitsOf(leaf).compound;\n}\n\n/** Whether a leaf's control is several controls or a button. */\nexport function prefDrawsSeveral(leaf: { kind: string }): boolean {\n return traitsOf(leaf).several;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/tabRuns.ts","../src/shown.ts","../src/judge.ts","../src/scopeAt.ts","../src/scope.ts","../src/build.ts","../src/css.ts","../src/aliasTargets.ts","../src/object.ts","../src/type.ts","../src/groups.ts","../src/heading.ts","../src/pair.ts","../src/kinds.ts"],"names":["leaf","scope","kept","under","pref"],"mappings":";;;;AAOO,SAAS,WAAA,CAAe,OAAqB,KAAA,EAA8C;AAChG,EAAA,MAAM,MAAuB,EAAC;AAC9B,EAAA,IAAI,GAAA;AACJ,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,CAAC,KAAA,CAAM,IAAI,CAAA,EAAG;AAChB,MAAA,GAAA,GAAM,MAAA;AACN,MAAA,GAAA,CAAI,IAAA,CAAK,EAAE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AA;AAAA,EACN;AACA,EAAA,OAAO,IAAA;AACT;;;ACnBA,IAAM,GAAA,GAAsB,EAAE,QAAA,EAAU,KAAA,EAAO,SAAS,KAAA,EAAM;AAC9D,IAAM,IAAA,GAAuB,EAAE,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AAQtD,IAAM,gBAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,GAAA;AAAA,EACR,OAAA,EAAS,GAAA;AAAA,EACT,MAAA,EAAQ,GAAA;AAAA,EACR,IAAA,EAAM,GAAA;AAAA,EACN,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,IAAA,EAAM,IAAA;AAAA,EACN,GAAA,EAAK,IAAA;AAAA,EACL,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,MAAA,EAAQ,EAAE,QAAA,EAAU,KAAA,EAAO,SAAS,IAAA,EAAK;AAAA,EACzC,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,GAAA;AAAA,EACP,SAAA,EAAW;AACb;AAEA,IAAM,QAAA,GAAW,CAACA,KAAAA,KACf,MAAA,CAAO,MAAA,CAAO,gBAAA,EAAkBA,KAAAA,CAAK,IAAI,CAAA,GAAI,gBAAA,CAAiBA,KAAAA,CAAK,IAAgB,CAAA,GAAI,GAAA;AAGnF,SAAS,eAAeA,KAAAA,EAAiC;AAC9D,EAAA,OAAO,QAAA,CAASA,KAAI,CAAA,CAAE,QAAA;AACxB;AAGO,SAAS,iBAAiBA,KAAAA,EAAiC;AAChE,EAAA,OAAO,QAAA,CAASA,KAAI,CAAA,CAAE,OAAA;AACxB","file":"index.js","sourcesContent":["/** One step of a walk over a group's children: a child on its own, or the neighboring `tab` children that share one strip. */\nexport type PrefTabRun<T> = { item: T; tabs?: undefined } | { tabs: readonly T[]; item?: undefined };\n\n/**\n * `items` in order, each run of neighbors `isTab` holds for folded into one step. What a surface leaves out of\n * `items` neither joins a run nor ends one, and what it keeps and then declines to draw still holds its run together.\n */\nexport function prefTabRuns<T>(items: readonly T[], isTab: (item: T) => boolean): PrefTabRun<T>[] {\n const out: PrefTabRun<T>[] = [];\n let run: T[] | undefined;\n for (const item of items) {\n if (!isTab(item)) {\n run = undefined;\n out.push({ item });\n } else if (run) {\n run.push(item);\n } else {\n out.push({ tabs: (run = [item]) });\n }\n }\n return out;\n}\n","// A stored value as the control over its leaf shows it. A condition compares\n// that, and not the stored form: a person writes \"is on\" about an Italic\n// toggle, whatever string the toggle stores.\n\nimport type { PrefConditionReader } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { prefLeafHolding, prefLeafHoldingIn, prefSchemaHolding, UNSEEN } from './holding';\nimport type { PrefBoolean, PrefEnum, PrefLeaf } from './schema';\n\ntype Siblings = Record<string, unknown> | undefined;\n\n/** What the control over `leaf` shows for `stored`: what its `encoding` reads it as, else `stored` itself.\n * `siblings` is the object the leaf is a field of. */\nexport function prefShownValue(leaf: PrefLeaf, stored: unknown, siblings?: Record<string, unknown>): unknown {\n if (leaf.kind !== 'boolean' && leaf.kind !== 'enum') return stored;\n const { encoding } = leaf as PrefBoolean | PrefEnum;\n return encoding ? (encoding.read as (stored: unknown, siblings: Siblings) => unknown)(stored, siblings) : stored;\n}\n\n/**\n * `read` with each value handed back as {@link prefShownValue} gives it, for\n * the leaf of `schema` at that path, a field of an `object` or a `union` leaf\n * included. A field's siblings are what `read` finds at its leaf's path. A\n * path read from the entry is held to `item`, the leaf describing that entry.\n * A path no leaf of `schema` holds is held to `over`, the schema it is drawn\n * over.\n */\nexport function prefShownReader(\n schema: PrefGroup | PrefSection, read: PrefConditionReader, item?: PrefLeaf, over?: PrefGroup | PrefSection,\n): PrefConditionReader {\n return (path, from) => {\n const stored = read(path, from);\n const held = from === 'item' ? item && prefLeafHoldingIn(item, path) : prefLeafHolding(prefSchemaHolding(schema, path, over), path);\n if (held === undefined || held === UNSEEN) return stored;\n const object = held.within === undefined ? undefined : read(held.within, from);\n return prefShownValue(held.leaf, stored, typeof object === 'object' && object !== null ? (object as Siblings) : undefined);\n };\n}\n","// Who answers a condition: a judge, made from a way to read values.\n\nimport { prefConditionHolds, prefConditionReadsItem, type PrefCondition, type PrefConditionReader } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefSectionLeaves, prefValueAtPath } from './helpers';\nimport { prefSchemaHolding } from './holding';\nimport type { PrefLeaf } from './schema';\nimport { prefShownReader } from './shown';\n\n/** Which of a node's two conditions a {@link PrefConditionJudge} is asked about. */\nexport type PrefConditionField = 'showIf' | 'enableIf';\n\n/**\n * Says whether one condition holds. {@link prefJudge} makes one from a value\n * reader; a surface drawing several values at once writes its own, to say\n * what a condition that holds for some and not for others comes to.\n */\nexport type PrefConditionJudge = (condition: PrefCondition, field: PrefConditionField) => boolean;\n\n/** One entry of a list or a map: the `item` leaf describing it, and what it holds. */\nexport interface PrefEntry {\n item: PrefLeaf;\n value: unknown;\n}\n\n/** What `entry` holds at `path`, the empty path being the entry itself: its own value, else that part of the item's default. */\nfunction entryValue({ item, value }: PrefEntry, path: string): unknown {\n if (path === '') return value !== undefined ? value : item.default;\n const held = prefValueAtPath(value, path);\n return held !== undefined ? held : prefValueAtPath(item.default, path);\n}\n\n/**\n * A judge over one set of values, read by path. A condition compares each\n * value as the control over its leaf in `schema` shows it\n * ({@link prefShownReader}), so `read` hands back what is stored. A test\n * that reads from the entry (`from: 'item'`) reads `entry`, and finds nothing\n * held where none is given. `over` is the schema `schema` is drawn over: a\n * path no leaf of `schema` holds is compared as the leaf of `over` there\n * shows it.\n */\nexport function prefJudge(\n schema: PrefGroup | PrefSection, read: (path: string) => unknown, entry?: PrefEntry, over?: PrefGroup | PrefSection,\n): PrefConditionJudge {\n const stored: PrefConditionReader = (path, from) => (from === 'item' ? entry && entryValue(entry, path) : read(path));\n const shown = prefShownReader(schema, stored, entry?.item, over);\n return (condition) => prefConditionHolds(condition, shown);\n}\n\n/**\n * `holds` for every condition but one that reads the entry, which is left\n * unanswered, which is to say holding: what a walk with no entry in hand\n * asks inside the item of a list or a map.\n */\nexport function deferEntryConditions(holds: PrefConditionJudge): PrefConditionJudge {\n return (condition, field) => prefConditionReadsItem(condition) || holds(condition, field);\n}\n\n/**\n * Reads a value by path the way a form over `schema` shows it: what `values`\n * holds there, else the default of the leaf at that path, or the part of a\n * leaf's default the rest of the path names. `over` is the schema `schema`\n * is drawn over: a path no leaf of `schema` holds takes its default there.\n */\nexport function prefReader(schema: PrefGroup | PrefSection, values: unknown, over?: PrefGroup | PrefSection): (path: string) => unknown {\n const beyond = over && prefReader(over, values);\n return (path) => {\n const held = prefValueAtPath(values, path);\n if (held !== undefined) return held;\n if (beyond && prefSchemaHolding(schema, path, over) === over) return beyond(path);\n if (isPrefSection(schema)) {\n for (const [key, leaf] of prefSectionLeaves(schema.members)) {\n if (path === key) return leaf.default;\n if (path.startsWith(`${key}.`)) return prefValueAtPath(leaf.default, path.slice(key.length + 1));\n }\n return undefined;\n }\n const steps = path.split('.');\n let node: PrefGroup = schema;\n for (let i = 0; i < steps.length; i++) {\n if (!Object.hasOwn(node.children, steps[i]!)) return undefined;\n const child: PrefLeaf | PrefGroup = node.children[steps[i]!]!;\n if (!isPrefLeaf(child)) node = child;\n else return i === steps.length - 1 ? child.default : prefValueAtPath(child.default, steps.slice(i + 1).join('.'));\n }\n return undefined;\n };\n}\n","// The scope of one node: whether it is drawn and whether it takes input,\n// with everything above it counted.\n\nimport { prefAliasTarget, type PrefAlias } from './alias';\nimport type { PrefCondition } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefLeafAt } from './helpers';\nimport { deferEntryConditions, type PrefConditionJudge } from './judge';\nimport type { PrefList } from './list';\nimport type { PrefMap } from './map';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport type { PrefUnion } from './union';\n\n/** Whether a node is drawn and whether it takes input, with what is above it counted. */\nexport interface PrefScope {\n shown: boolean;\n enabled: boolean;\n}\n\n/** The step that stands for any entry of a `list` or a `map` in a path: `'phases.*.hold'` answers for that field of\n * each, by every condition that comes to the same for every entry. */\nexport const PREF_ENTRY = '*';\n\n/** The scope a schema's root sits in. */\nexport const PREF_SCOPE: PrefScope = Object.freeze({ shown: true, enabled: true });\n\n/** The scope of `node`, which sits directly under something whose scope is `above`. */\nexport function prefScopeUnder(\n above: PrefScope,\n node: { showIf?: PrefCondition; enableIf?: PrefCondition },\n holds: PrefConditionJudge,\n): PrefScope {\n const shown = above.shown && (node.showIf === undefined || holds(node.showIf, 'showIf'));\n const enabled = above.enabled && (node.enableIf === undefined || holds(node.enableIf, 'enableIf'));\n return shown === above.shown && enabled === above.enabled ? above : { shown, enabled };\n}\n\n/** The scope of the field at `rest` among an object leaf's children, or `undefined` when none is there. */\nfunction scopeAmong(\n held: PrefSection['members'], rest: string, above: PrefScope, holds: PrefConditionJudge,\n): PrefScope | undefined {\n for (const [key, child] of Object.entries(held)) {\n if (!isPrefLeaf(child)) {\n const found = scopeAmong(child.members, rest, prefScopeUnder(above, child, holds), holds);\n if (found) return found;\n } else if (rest === key) return prefScopeUnder(above, child, holds);\n else if (rest.startsWith(`${key}.`)) return scopeInside(child, rest.slice(key.length + 1), prefScopeUnder(above, child, holds), holds);\n }\n return undefined;\n}\n\n/** The scope at `rest` inside `leaf`, whose own scope is `scope`: that of a field, or the leaf's where `rest` names none. */\nfunction scopeInside(leaf: PrefLeaf, rest: string, scope: PrefScope, holds: PrefConditionJudge): PrefScope {\n if (leaf.kind === 'object') return scopeAmong((leaf as PrefObject).children, rest, scope, holds) ?? scope;\n if (leaf.kind === 'list' || leaf.kind === 'map') {\n const { item } = leaf as Partial<PrefList | PrefMap>;\n if (item === undefined) return scope;\n const inItem = deferEntryConditions(holds);\n const entry = prefScopeUnder(scope, { enableIf: item.enableIf }, inItem);\n const dot = rest.indexOf('.');\n return dot < 0 ? entry : scopeInside(item, rest.slice(dot + 1), entry, inItem);\n }\n if (leaf.kind !== 'union') return scope;\n for (const variant of Object.values((leaf as PrefUnion).variants)) {\n const found = scopeAmong(variant.children, rest, scope, holds);\n if (found) return found;\n }\n return scope;\n}\n\nfunction scopeAt(schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge): PrefScope {\n let scope = prefScopeUnder(PREF_SCOPE, schema, holds);\n if (path === '') return scope;\n if (isPrefSection(schema)) return scopeAmong(schema.members, path, scope, holds) ?? scope;\n let node: PrefGroup = schema;\n const steps = path.split('.');\n for (let i = 0; i < steps.length; i++) {\n if (!Object.hasOwn(node.children, steps[i]!)) return scope;\n const child: PrefLeaf | PrefGroup = node.children[steps[i]!]!;\n scope = prefScopeUnder(scope, child, holds);\n if (isPrefLeaf(child)) return i === steps.length - 1 ? scope : scopeInside(child, steps.slice(i + 1).join('.'), scope, holds);\n node = child;\n }\n return scope;\n}\n\n/** `own`, an alias's scope by its own conditions, narrowed by that of the leaf it shows in `over`, as `holds` judges `over`. */\nexport function prefAliasScope(own: PrefScope, alias: PrefAlias, over: PrefGroup | PrefSection, holds: PrefConditionJudge): PrefScope {\n const target = prefAliasTarget(alias, (path) => prefLeafAt(over, path));\n if (target === undefined) return own;\n const theirs = scopeAt(over, target.path, holds);\n const shown = own.shown && theirs.shown;\n const enabled = own.enabled && theirs.enabled;\n return shown === own.shown && enabled === own.enabled ? own : { shown, enabled };\n}\n\n/** What {@link prefScopeAt} is told beyond the schema. */\nexport interface PrefScopeAtOptions {\n /** The schema an alias's `of` names a leaf of. Default: the schema asked. */\n aliasOver?: PrefGroup | PrefSection;\n /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */\n aliasHolds?: PrefConditionJudge;\n}\n\n/**\n * The scope of the node at `path`: a group, a leaf, a field of an `object`\n * or a `union` leaf, or an entry of a `list` or a `map`, whose step may be\n * any key. Under a {@link PrefSection} schema a leaf's key is its whole\n * path. A path that runs past the schema answers for the last node it\n * reaches. An alias answers for itself and for the leaf it shows, as\n * `applyPrefConditions` has it. Inside an entry, a condition that reads the\n * entry (`from: 'item'`) is not asked and counts as holding, there being no\n * entry here to read: `applyPrefEntryConditions` answers it.\n */\nexport function prefScopeAt(\n schema: PrefGroup | PrefSection, path: string, holds: PrefConditionJudge, { aliasOver, aliasHolds }: PrefScopeAtOptions = {},\n): PrefScope {\n const own = scopeAt(schema, path, holds);\n const leaf = prefLeafAt(schema, path);\n return leaf?.kind === 'alias' ? prefAliasScope(own, leaf as PrefAlias, aliasOver ?? schema, aliasHolds ?? holds) : own;\n}\n","// What a schema's conditions come to once nesting is counted: a node is drawn\n// only while it and everything above it is shown, and takes input only while\n// it and everything above it is enabled. Every surface that draws a schema\n// asks here.\n\nimport type { PrefAlias } from './alias';\nimport { prefConditionReadsItem } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection } from './helpers';\nimport { deferEntryConditions, type PrefConditionJudge } from './judge';\nimport type { PrefList } from './list';\nimport type { PrefMap } from './map';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport { PREF_ENTRY, PREF_SCOPE, prefAliasScope, prefScopeUnder, type PrefScope } from './scopeAt';\nimport type { PrefUnion } from './union';\n\nexport { prefJudge, prefReader, type PrefConditionField, type PrefConditionJudge, type PrefEntry } from './judge';\nexport { PREF_ENTRY, PREF_SCOPE, prefScopeAt, prefScopeUnder, type PrefScope, type PrefScopeAtOptions } from './scopeAt';\n\nconst under = (prefix: string, key: string): string => (prefix === '' ? key : `${prefix}.${key}`);\n\n/** A schema with its conditions applied. */\nexport interface PrefConditionsApplied<T> {\n /** The schema without the nodes that are not shown. The schema itself when\n * that is all of it, and `null` when its root is not shown. */\n shown: T | null;\n /**\n * The value path of every leaf that is disabled, a field of an `object` or\n * a `union` leaf included (`'stroke.width'`), and under a {@link PrefGroup}\n * schema the path of every group that is. A `list`'s or a `map`'s item is\n * named once for every entry, with {@link PREF_ENTRY} as the entry's step:\n * `'phases.*'`, and `'phases.*.hold'` for a field of it.\n */\n disabled: ReadonlySet<string>;\n /**\n * With `keepHidden`, the path of everything `shown` holds that is not\n * shown, named as `disabled` names what is disabled. Empty without it,\n * since `shown` then holds none.\n */\n hidden: ReadonlySet<string>;\n}\n\n/** How {@link applyPrefConditions} treats what it would leave out. */\nexport interface PrefConditionsOptions {\n /** Keep a group or a section that leaves with nothing to draw. */\n keepEmpty?: boolean;\n /**\n * Keep every node whose `showIf` fails, and name it in `hidden`: for a\n * surface that edits the schema, where a node not drawn cannot be picked.\n */\n keepHidden?: boolean;\n /** The schema an alias's `of` names a leaf of. Default: the schema walked. */\n aliasOver?: PrefGroup | PrefSection;\n /** Says which conditions of `aliasOver` hold, where its values are not the ones `holds` reads. Default: `holds`. */\n aliasHolds?: PrefConditionJudge;\n}\n\ninterface WalkOptions {\n keepEmpty: boolean;\n keepHidden: boolean;\n /** Asked inside the item of a list or a map met on the way, whose entries the walk does not have. */\n inItem: PrefConditionJudge;\n aliasOver?: PrefGroup | PrefSection;\n aliasHolds?: PrefConditionJudge;\n}\n\n/** The walk over leaves and what is inside them, which the schema's pass and an entry's share. */\nfunction leafWalk({ keepEmpty, keepHidden, inItem, aliasOver, aliasHolds }: WalkOptions) {\n const disabled = new Set<string>();\n const hidden = new Set<string>();\n\n const leaf = (node: PrefLeaf, path: string, above: PrefScope, holds: PrefConditionJudge): PrefLeaf | null => {\n const own = prefScopeUnder(above, node, holds);\n const scope = node.kind === 'alias' && aliasOver ? prefAliasScope(own, node as PrefAlias, aliasOver, aliasHolds ?? holds) : own;\n return scope.shown || keepHidden ? inside(node, path, scope, holds) : null;\n };\n\n /** `node`, whose scope is `scope`, without what its own value hides: a field, or part of a list's or a map's item. */\n const inside = (node: PrefLeaf, path: string, scope: PrefScope, holds: PrefConditionJudge): PrefLeaf => {\n if (!scope.shown) hidden.add(path);\n if (!scope.enabled) disabled.add(path);\n if (node.kind === 'object') {\n const children = members((node as PrefObject).children, path, scope, holds);\n return children === (node as PrefObject).children ? node : ({ ...node, children } as PrefLeaf);\n }\n if (node.kind === 'list' || node.kind === 'map') {\n const { item } = node as Partial<PrefList | PrefMap>;\n // A leaf an app's renderer draws under a built-in's kind may hold no item.\n if (item === undefined) return node;\n // An item is drawn with its entry, so its own `showIf` is not asked.\n const entry = inside(item, under(path, PREF_ENTRY), prefScopeUnder(scope, { enableIf: item.enableIf }, inItem), inItem);\n return entry === item ? node : ({ ...node, item: entry } as PrefLeaf);\n }\n if (node.kind !== 'union') return node;\n const { variants } = node as PrefUnion;\n let changed = false;\n const next: PrefUnion['variants'] = {};\n for (const [key, variant] of Object.entries(variants)) {\n const children = members(variant.children, path, scope, holds);\n changed ||= children !== variant.children;\n next[key] = children === variant.children ? variant : { ...variant, children };\n }\n return changed ? ({ ...node, variants: next } as PrefLeaf) : node;\n };\n\n /** A section's members or an object leaf's children. `prefix` is the object leaf's path, empty in a section schema. */\n const members = (held: PrefSection['members'], prefix: string, above: PrefScope, holds: PrefConditionJudge): PrefSection['members'] => {\n let changed = false;\n const out: PrefSection['members'] = {};\n for (const [key, child] of Object.entries(held)) {\n const kept = isPrefLeaf(child) ? leaf(child, under(prefix, key), above, holds) : section(child, prefix, above, holds);\n changed ||= kept !== child;\n if (kept !== null) out[key] = kept;\n }\n return changed ? out : held;\n };\n\n const section = (node: PrefSection, prefix: string, above: PrefScope, holds: PrefConditionJudge): PrefSection | null => {\n const scope = prefScopeUnder(above, node, holds);\n if (!scope.shown && !keepHidden) return null;\n const kept = members(node.members, prefix, scope, holds);\n if (kept === node.members) return node;\n return Object.keys(kept).length === 0 && !keepEmpty ? null : { ...node, members: kept };\n };\n\n return { disabled, hidden, leaf, inside, members };\n}\n\n/**\n * `schema` as it is drawn while `holds` says which conditions hold. A node\n * whose `showIf` fails is dropped with everything under it, unless\n * `keepHidden`, and so is a group or a section that leaves with nothing to\n * draw, unless `keepEmpty`. A node\n * whose `enableIf` fails is disabled with everything under it. The item of\n * a `list` or a `map` is walked as its entries are drawn: its fields hide and\n * disable by their conditions, and its own `enableIf` disables every entry.\n * A condition there that reads the entry (`from: 'item'`) has no one answer\n * for every entry and is left holding: {@link applyPrefEntryConditions}\n * answers it for each.\n * An alias is shown only while it and the leaf it shows both are, and enabled\n * only while both are, with everything above that leaf counted. That leaf is\n * looked for in `aliasOver`, and its side is asked of `aliasHolds`.\n * Parts with nothing dropped come back as the objects they were.\n */\nexport function applyPrefConditions<T extends PrefGroup | PrefSection>(\n schema: T,\n holds: PrefConditionJudge,\n { keepEmpty = false, keepHidden = false, aliasOver, aliasHolds }: PrefConditionsOptions = {},\n): PrefConditionsApplied<T> {\n const walk = leafWalk({ keepEmpty, keepHidden, inItem: deferEntryConditions(holds), aliasOver: aliasOver ?? schema, aliasHolds });\n const { disabled, hidden } = walk;\n\n const group = (node: PrefGroup, path: string, above: PrefScope): PrefGroup | null => {\n const scope = prefScopeUnder(above, node, holds);\n if (!scope.shown && !keepHidden) return null;\n if (!scope.shown && path !== '') hidden.add(path);\n if (!scope.enabled && path !== '') disabled.add(path);\n let changed = false;\n const children: PrefGroup['children'] = {};\n for (const [key, child] of Object.entries(node.children)) {\n const at = under(path, key);\n const kept = isPrefLeaf(child) ? walk.leaf(child, at, scope, holds) : group(child, at, scope);\n changed ||= kept !== child;\n if (kept !== null) children[key] = kept;\n }\n if (!changed) return node;\n return Object.keys(children).length === 0 && !keepEmpty && path !== '' ? null : { ...node, children };\n };\n\n if (!isPrefSection(schema)) return { shown: group(schema, '', PREF_SCOPE) as T | null, disabled, hidden };\n const scope = prefScopeUnder(PREF_SCOPE, schema, holds);\n if (!scope.shown && !keepHidden) return { shown: null, disabled, hidden };\n const kept = walk.members(schema.members, '', scope, holds);\n return { shown: kept === schema.members ? schema : { ...schema, members: kept }, disabled, hidden };\n}\n\n/** One entry of a list or a map with the conditions that read it applied. */\nexport interface PrefEntryApplied {\n /** The item as this entry draws it: without the fields not shown, and the item itself when that is all of them. */\n item: PrefLeaf;\n /** The path of the entry, and of every field in it, that is disabled, named as {@link PrefConditionsApplied} names them. */\n disabled: ReadonlySet<string>;\n /** With `keepHidden`, the path of every field of the entry that is not shown. */\n hidden: ReadonlySet<string>;\n}\n\nconst ALWAYS: PrefConditionJudge = () => true;\n\n/**\n * The conditions {@link applyPrefConditions} leaves unanswered, answered for\n * one entry: `item`, as that pass left it, drawn for the entry at `path`\n * (`'phases.2'`) while `holds` says which conditions hold. `holds` reads the\n * entry: `prefJudge` given it. Only a condition that reads the entry is\n * asked, the rest being applied already, and one inside a list or a map\n * within the entry is left for that one's own entries.\n */\nexport function applyPrefEntryConditions(\n item: PrefLeaf,\n path: string,\n holds: PrefConditionJudge,\n { keepEmpty = false, keepHidden = false }: Pick<PrefConditionsOptions, 'keepEmpty' | 'keepHidden'> = {},\n): PrefEntryApplied {\n const asked: PrefConditionJudge = (condition, field) => !prefConditionReadsItem(condition) || holds(condition, field);\n const walk = leafWalk({ keepEmpty, keepHidden, inItem: ALWAYS });\n const scope = prefScopeUnder(PREF_SCOPE, { enableIf: item.enableIf }, asked);\n return { item: walk.inside(item, path, scope, asked), disabled: walk.disabled, hidden: walk.hidden };\n}\n","// Short forms for writing a schema by hand. Each returns the plain data a\n// literal would: nothing reads a schema differently for how it was written.\n\nimport type { PrefGroup, PrefSection } from './groups';\nimport type { PrefBoolean, PrefColor, PrefEnumBase, PrefLeaf, PrefNumber, PrefString } from './schema';\n\n/** What a builder takes after the leaf's name and default: any of the leaf's other fields. */\ntype Rest<L> = Partial<Omit<L, 'kind' | 'name' | 'default'>>;\n\n/** One option of an enum, or its value alone, which is labeled with the value's first letter raised. */\ntype OptionOf<T extends string> = T | PrefEnumBase<T>['options'][number];\n\nconst leaf = <L extends PrefLeaf>(kind: L['kind'], name: string, def: unknown, rest: object | undefined): L =>\n ({ kind, name, description: '', default: def, ...rest }) as L;\n\nconst labeled = (value: string): string => (value === '' ? value : value[0]!.toUpperCase() + value.slice(1));\n\n/**\n * Builders for a preferences schema, each returning what the literal would\n * hold. `pref.group('View', { grid: pref.boolean('Grid', true) })` is\n * `{ name: 'View', children: { grid: { kind: 'boolean', name: 'Grid', description: '', default: true } } }`,\n * and its paths and value types are read from it the same way.\n */\nexport const pref = {\n /** A group: `children` nest under its key, which is a segment of their paths. */\n group<const C extends Record<string, PrefLeaf | PrefGroup>>(\n name: string,\n children: C,\n options?: Omit<PrefGroup, 'name' | 'children'>,\n ): Omit<PrefGroup, 'children'> & { children: C } {\n return { name, ...options, children };\n },\n\n /** A section: a heading over `members`, whose key adds nothing to their paths. */\n section<const M extends Record<string, PrefLeaf | PrefSection>>(\n name: string,\n members: M,\n options?: Omit<PrefSection, 'name' | 'members'>,\n ): Omit<PrefSection, 'members'> & { members: M } {\n return { name, ...options, members };\n },\n\n number: (name: string, def: number, rest?: Rest<PrefNumber>): PrefNumber => leaf('number', name, def, rest),\n boolean: (name: string, def: boolean, rest?: Rest<PrefBoolean>): PrefBoolean => leaf('boolean', name, def, rest),\n string: (name: string, def: string, rest?: Rest<PrefString>): PrefString => leaf('string', name, def, rest),\n color: (name: string, def: string, rest?: Rest<PrefColor>): PrefColor => leaf('color', name, def, rest),\n\n /** A fixed set of choices. An option given as its value alone is labeled with that value, its first letter raised. */\n enum<const T extends string>(\n name: string,\n def: NoInfer<T>,\n options: readonly OptionOf<T>[],\n rest?: Omit<Rest<PrefEnumBase<T>>, 'options'>,\n ): PrefEnumBase<T> & { default: T; clearable?: false } {\n const full = options.map((option) => (typeof option === 'string' ? { value: option, label: labeled(option) } : option));\n return { kind: 'enum', name, description: '', default: def, ...rest, options: full };\n },\n};\n","// A store's values as CSS custom properties: one block for what every choice\n// of the selectors shares, and one for each choice a split value tells apart.\n\nimport type { PrefGroup } from './groups';\nimport { prefHoldsValue, prefLeaves, prefValueAtPath } from './helpers';\nimport { isPrefLocus, type PrefLocus, type PrefSelection } from './locus';\nimport type { PrefEnum, PrefLeaf, PrefNumber } from './schema';\nimport { prefSelectors } from './splitCheck';\nimport { resolvePrefUnit } from './unit';\n\n/** How {@link prefsCss} names and writes things. */\nexport interface PrefsCssOptions {\n /** The selector of the element the properties are set on, and the selectors' attributes read from. Default `:root`. */\n root?: string;\n /** The custom property a leaf is written as, or `null` to leave the leaf out. Default: `--`, then the path with\n * each `.` and each capital turned into a `-` (`look.gridGap` is `--look-grid-gap`). */\n property?: (path: string, leaf: PrefLeaf) => string | null;\n /** The attribute a selector's option is read from. Default: `data-`, then the path as a property spells it. */\n attribute?: (selector: string) => string;\n /** The CSS text of a value, `null` to leave it out, or `undefined` for what its kind writes by itself. */\n value?: (value: unknown, leaf: PrefLeaf, path: string) => string | null | undefined;\n}\n\n/** What {@link prefsCss} reads of a store: any `PrefsStore` is one. */\nexport interface PrefsCssSource {\n schema: PrefGroup;\n values(read?: { at?: PrefSelection }): Record<string, unknown>;\n locus(path: string): PrefLocus | undefined;\n get(path: string): unknown;\n}\n\nconst kebab = (path: string): string => path.replace(/\\./g, '-').replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\n/** The CSS unit a number leaf's suffix names, for the suffixes that name one. */\nconst CSS_UNITS: Readonly<Record<string, string>> = {\n px: 'px', '%': '%', em: 'em', rem: 'rem', ch: 'ch', pt: 'pt', vw: 'vw', vh: 'vh',\n ms: 'ms', s: 's', '°': 'deg', deg: 'deg', rad: 'rad', turn: 'turn',\n};\n\nconst IDENT = /^-?[A-Za-z_][\\w-]*$/;\nconst quoted = (text: string): string => `'${text.replace(/[\\\\']/g, '\\\\$&')}'`;\n\n/** What a value of a built-in kind is written as, `null` for one with no CSS form. */\nfunction cssValue(leaf: PrefLeaf, value: unknown): string | null {\n switch (leaf.kind) {\n case 'number': {\n if (typeof value !== 'number' || !Number.isFinite(value)) return null;\n const { unit } = leaf as PrefNumber;\n const resolved = unit ? resolvePrefUnit(unit) : undefined;\n const shown = resolved ? resolved.toDisplay(value) : value;\n const suffix = resolved?.suffix !== undefined && Object.hasOwn(CSS_UNITS, resolved.suffix) ? CSS_UNITS[resolved.suffix] : '';\n return `${Number(shown.toFixed(6))}${suffix}`;\n }\n case 'boolean':\n return typeof value === 'boolean' ? (value ? '1' : '0') : null;\n case 'color':\n return typeof value === 'string' && value !== '' ? value : null;\n case 'enum':\n if (typeof value !== 'string' || (leaf as PrefEnum).encoding) return null;\n return IDENT.test(value) ? value : quoted(value);\n case 'string':\n return typeof value === 'string' ? quoted(value) : null;\n default:\n return null;\n }\n}\n\n/** One choice of options, a selector's path and its option per step, and the value read under it. */\ntype Told = { under: [selector: string, option: string][]; value: unknown };\n\n/** Every choice of options a held value tells apart, outermost selector first. */\nfunction toldApart(held: unknown, optionsOf: (selector: string) => readonly string[], absent: unknown): Told[] {\n const out: Told[] = [];\n const walk = (value: unknown, under: Told['under']): void => {\n if (!isPrefLocus(value)) {\n out.push({ under, value });\n return;\n }\n for (const option of optionsOf(value.$by)) {\n walk(Object.hasOwn(value.$of, option) ? value.$of[option] : absent, [...under, [value.$by, option]]);\n }\n };\n walk(held, []);\n return out;\n}\n\n/**\n * The store's values as CSS custom properties.\n *\n * The first block sets every leaf on `root`, a split one at the member the\n * selectors' defaults name, so a page that sets no attribute still has a\n * value for each. A block follows for each choice of options some value tells\n * apart, matched by an attribute per selector on that same element; a selector\n * is written under each of its own options too. Every block is inside\n * `:where()`, so none outranks another by how many attributes it names, and a\n * rule of the page's own wins. Blocks naming more selectors come later.\n *\n * A number is written in its display unit where the unit's suffix is a CSS\n * unit, and bare otherwise; a boolean as `1` or `0`; a color as it is held; an\n * enum's option as an identifier; a string quoted. A leaf of any other kind is\n * left out unless `value` writes it.\n */\nexport function prefsCss(store: PrefsCssSource, options: PrefsCssOptions = {}): string {\n const root = options.root ?? ':root';\n const property = options.property ?? ((path: string): string => `--${kebab(path)}`);\n const attribute = options.attribute ?? ((selector: string): string => `data-${kebab(selector)}`);\n const leaves = new Map([...prefLeaves(store.schema)].filter(([, leaf]) => prefHoldsValue(leaf)));\n const selectors = prefSelectors(leaves);\n const defaults = Object.fromEntries([...selectors.keys()].map((path) => [path, leaves.get(path)!.default as string]));\n const base = store.values({ at: defaults });\n\n const blocks = new Map<string, { under: Told['under']; lines: string[] }>();\n const declare = (under: Told['under'], path: string, leaf: PrefLeaf, value: unknown): void => {\n const name = property(path, leaf);\n if (name === null) return;\n const given = options.value?.(value, leaf, path);\n const text = given === undefined ? cssValue(leaf, value) : given;\n if (text === null) return;\n const key = under.map(([selector, option]) => `${selector}=${option}`).join('&');\n if (!blocks.has(key)) blocks.set(key, { under, lines: [] });\n blocks.get(key)!.lines.push(` ${name}: ${text};`);\n };\n\n for (const [path, leaf] of leaves) {\n declare([], path, leaf, prefValueAtPath(base, path));\n const own = selectors.get(path);\n if (own) for (const option of own) declare([[path, option]], path, leaf, option);\n const held = store.locus(path);\n if (!held) continue;\n for (const { under, value } of toldApart(held, (selector) => selectors.get(selector) ?? [], leaf.default)) {\n declare(under, path, leaf, value);\n }\n }\n\n return [...blocks.values()]\n .map((block, i) => ({ ...block, i }))\n .sort((a, b) => a.under.length - b.under.length || a.i - b.i)\n .map(({ under, lines }) => {\n const matched = under.map(([selector, option]) => `[${attribute(selector)}=${quoted(option)}]`).join('');\n return `:where(${root}${matched}) {\\n${lines.join('\\n')}\\n}`;\n })\n .join('\\n\\n');\n}\n\n/**\n * The attribute for each selector and the option it is set to: what to set\n * on the `root` element for the blocks of {@link prefsCss} to match the\n * store's own choice.\n */\nexport function prefsCssAttributes(store: Pick<PrefsCssSource, 'schema' | 'get'>, options: Pick<PrefsCssOptions, 'attribute'> = {}): Record<string, string> {\n const attribute = options.attribute ?? ((selector: string): string => `data-${kebab(selector)}`);\n const leaves = prefLeaves(store.schema);\n return Object.fromEntries([...prefSelectors(leaves).keys()].map((path) => [attribute(path), store.get(path) as string]));\n}\n","// The leaves a surface's aliases show: the schema they point into, as that\n// schema's own conditions leave it. Every surface that draws an alias asks\n// here, whether the schema is its own or another's.\n\nimport { prefAliasedLeaf, prefAliasTarget, type PrefAlias } from './alias';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { prefLeafAt, visiblePrefSubtree } from './helpers';\nimport type { PrefConditionJudge, PrefEntry } from './judge';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport { applyPrefConditions, applyPrefEntryConditions, type PrefConditionsApplied, type PrefEntryApplied } from './scope';\n\n/** What an alias row reads of the leaf it shows: the schema that leaf is in, as that schema's own conditions leave it. */\nexport interface PrefAliasTargets {\n /** Says which conditions of that schema hold. */\n holds: PrefConditionJudge;\n /** The leaf at a path of that schema, without the fields the surface would leave out of the leaf's own row: one\n * marked `hidden`, and one a `showIf` hides, unless the surface draws those. */\n leafAt: (path: string) => PrefLeaf | undefined;\n /** The leaf `alias` is drawn as, under the alias's own name and description where it gives them, and the path\n * its value is read and written at. `undefined` for an alias of nothing. */\n shown: (alias: PrefAlias) => { path: string; leaf: PrefLeaf } | undefined;\n /** Whether the field at a path of that schema is one an `enableIf` disables. */\n disabledAt: (path: string) => boolean;\n /** Whether the field at a path of that schema is one a `showIf` hides, on a surface that draws those. */\n hiddenAt?: (path: string) => boolean;\n /** An entry of a list or a map of that schema, as the conditions that read the entry leave it. */\n entryAt: (item: PrefLeaf, path: string, value: unknown) => PrefEntryApplied;\n}\n\n/** What a surface draws beyond the default, which its alias rows follow. */\nexport interface PrefAliasTargetsOptions {\n /** The surface draws fields marked `hidden`. */\n showHidden?: boolean;\n /** The surface draws what a `showIf` hides, marked. */\n markHidden?: boolean;\n}\n\n/** `leaf` without its fields marked `hidden`. The leaf's own mark is not asked: an alias shows a leaf the surface leaves out. */\nfunction visibleFieldsOf(leaf: PrefLeaf): PrefLeaf {\n if (leaf.kind !== 'object') return leaf;\n const shown = visiblePrefSubtree({ ...leaf, hidden: false }, false, true) as PrefObject;\n return { ...leaf, children: shown.children } as PrefLeaf;\n}\n\n/**\n * {@link PrefAliasTargets} over `over`, the schema a surface's aliases point\n * into: the surface's own, or another's. `judge` answers `over`'s conditions\n * as the surface reads values, for one entry of a list or a map where it is\n * given one: `prefJudge` over `over`. A surface's own pass drops a leaf it\n * leaves out and keeps no path of another schema, so the leaves aliases show\n * are conditioned here, the first time one is asked for.\n */\nexport function prefAliasTargets(\n over: PrefGroup | PrefSection,\n judge: (entry?: PrefEntry) => PrefConditionJudge,\n { showHidden = false, markHidden = false }: PrefAliasTargetsOptions = {},\n): PrefAliasTargets {\n const holds = judge();\n let applied: PrefConditionsApplied<PrefGroup | PrefSection> | undefined;\n const get = (): PrefConditionsApplied<PrefGroup | PrefSection> =>\n (applied ??= applyPrefConditions(over, holds, { keepEmpty: true, keepHidden: markHidden }));\n const leafAt = (path: string): PrefLeaf | undefined => {\n const { shown } = get();\n const leaf = shown === null ? undefined : prefLeafAt(shown, path);\n return leaf === undefined || showHidden ? leaf : visibleFieldsOf(leaf);\n };\n return {\n holds,\n leafAt,\n shown: (alias) => {\n const target = prefAliasTarget(alias, leafAt);\n return target && { path: target.path, leaf: prefAliasedLeaf(alias, target.leaf) };\n },\n disabledAt: (path) => get().disabled.has(path),\n ...(markHidden ? { hiddenAt: (path: string) => get().hidden.has(path) } : {}),\n entryAt: (item, path, value) => applyPrefEntryConditions(item, path, judge({ item, value }), { keepHidden: markHidden }),\n };\n}\n","import type { PrefObject } from './schema';\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null;\n\n/**\n * The object a write to one field of an `object` leaf starts from: `held` itself where it is one. Where it is\n * not, the write has to make a whole object, so it starts from the scalar lifted by the leaf's `fromScalar`, else\n * from the leaf's `default`: one field on its own is a stroke with a width and no paint.\n */\nexport function prefObjectBase(pref: PrefObject, held: unknown): Record<string, unknown> {\n if (isObject(held)) return held;\n return pref.fromScalar?.(held) ?? (isObject(pref.default) ? pref.default : {});\n}\n\n/** The object an `object` leaf holds after one of its fields is set: {@link prefObjectBase} with `key` at\n * `value`, or without the key for `undefined`. */\nexport function prefObjectWithField(pref: PrefObject, held: unknown, key: string, value: unknown): Record<string, unknown> {\n const base = prefObjectBase(pref, held);\n if (value !== undefined) return { ...base, [key]: value };\n const { [key]: _dropped, ...rest } = base;\n return rest;\n}\n","import type { PrefLeaf } from './schema';\n\n/**\n * `leaf` as a named type: the same leaf carrying `name` in its `type` field.\n * Declared once beside the code that reads its value and used wherever a\n * schema wants one, spread with what that place sets for itself\n * (`{ ...GradientStop, name: 'First stop' }`), or as a list's or a map's\n * `item`. `name` is the identifier the type is exported under, which a schema\n * editor prints in place of the leaf's literal.\n */\nexport function prefType<L extends PrefLeaf>(name: string, leaf: L): L & { type: string } {\n return { ...leaf, type: name };\n}\n","// The two branch nodes of a schema. They differ in whether a key is part of\n// the path a leaf's value lives at, and each holds its members under its own\n// property, so a schema of one kind is neither assignable to nor walkable as\n// the other.\n\nimport type { PrefCondition } from './condition';\nimport type { PrefLeaf } from './schema';\n\n/**\n * How a {@link PrefGroup} is drawn: `page` gets an entry in a form's rail and\n * a pane of its own; `tab` shares a tab strip with the `tab` groups beside it;\n * `panel` is a bordered, titled box; `section` is a heading over its rows;\n * `fragment` draws nothing of its own, so its rows sit among its neighbors'\n * as though they were written there. A fragment exists to hold things\n * together: one key for their values to nest under, one node to move.\n */\nexport type PrefGroupAs = 'page' | 'tab' | 'panel' | 'section' | 'fragment' | 'bar';\n\n/**\n * What a group or a section drawn `as: 'bar'` does with cells its line has no\n * room for: `scroll` keeps them all on it, and `menu` opens the ones past its\n * end from a button there. A bar set to `menu` takes all the room its host\n * has along the line, which is why it is asked for and not the default.\n */\nexport type PrefBarOverflow = 'scroll' | 'menu';\n\n/** How a {@link PrefSection} is drawn. */\nexport type PrefSectionAs = Exclude<PrefGroupAs, 'page'>;\n\n/**\n * A group whose key is a path segment: `view` > `gridDensity` is the leaf at\n * `view.gridDensity`, and its value nests the same way. The shape of a\n * preferences schema — what `openPrefs` stores, `PrefsForm` renders, and a\n * tool declares its options as. A key holds no `.`.\n */\nexport interface PrefGroup {\n /** Heading for the group's rows. **Empty means no heading** — for a group\n * that exists to organize, not to name: one whose children are themselves\n * groups carrying the labels a reader needs. Give it a name whenever the\n * name is the referent (a `Border` group over `Top` / `Right` / `Bottom`\n * reads as nothing without it). */\n name: string;\n description?: string;\n /** How the group is drawn. Unset, its depth decides: a top-level group is a\n * `page`, and one inside another is a `section`. */\n as?: PrefGroupAs;\n /** Drawn `as: 'bar'`: what happens to the cells its line has no room for.\n * Unset: `scroll`. A surface that takes drops keeps every cell on the line\n * whatever this says, so each is there to drop beside. */\n overflow?: PrefBarOverflow;\n /** Drawn, with everything under it, only while this holds. */\n showIf?: PrefCondition;\n /** Everything under it is disabled while this does not hold. */\n enableIf?: PrefCondition;\n children: Record<string, PrefLeaf | PrefGroup>;\n}\n\n/**\n * A heading over leaves that adds nothing to their paths: each member is\n * addressed by its own key alone, and the section's key only identifies the\n * section. The shape of a node's property schema, where a leaf's key is the\n * whole dotted node path (`pose.x`, `data.fill`), and of the headings inside\n * a {@link PrefObject}, where a key is relative to the object.\n */\nexport interface PrefSection {\n /** Heading for the section's rows. Empty means no heading, as for a\n * {@link PrefGroup}. */\n name: string;\n description?: string;\n /** How the section is drawn, as a {@link PrefGroup}'s `as` — without\n * `page`, since nothing that draws sections has a rail. Unset: a heading\n * over its rows. */\n as?: PrefSectionAs;\n /** As a {@link PrefGroup}'s. */\n overflow?: PrefBarOverflow;\n /** As a {@link PrefGroup}'s. */\n showIf?: PrefCondition;\n /** As a {@link PrefGroup}'s. */\n enableIf?: PrefCondition;\n members: Record<string, PrefLeaf | PrefSection>;\n}\n\n/** Whether a top-level group gets a page of its own, and not a place on the page of the root's own leaves. */\nexport function prefGroupIsPage(group: PrefGroup): boolean {\n return group.as === undefined || group.as === 'page';\n}\n","import type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf } from './helpers';\nimport { isBuiltinPref, type PrefLeaf } from './schema';\n\n/** Whether a leaf's control fits beside a heading's words: a built-in `boolean`'s or `enum`'s does. */\nexport function prefFitsHeading(leaf: PrefLeaf): boolean {\n return (leaf.kind === 'boolean' || leaf.kind === 'enum') && isBuiltinPref(leaf);\n}\n\n/**\n * The key of the leaf a group or a section draws in its heading: the first\n * directly in it that is marked `heading` and whose control fits there.\n * Undefined for a node with no name, which has no heading to draw it in.\n */\nexport function prefHeadingKey(node: PrefGroup | PrefSection): string | undefined {\n if (node.name === '') return undefined;\n const held = 'members' in node ? node.members : node.children;\n for (const [key, child] of Object.entries(held)) {\n if (isPrefLeaf(child) && child.heading === true && prefFitsHeading(child)) return key;\n }\n return undefined;\n}\n","import { pairRowsOf, type PrefLeaf } from './schema';\n\n/** Neighboring items one row draws, in {@link pairRuns}' answer. */\nexport interface PairRun<T> {\n items: T[];\n /** The pairing the items share: the path of the leaf that declared it, and what the row reads. Absent on a\n * run of one, which is no pair. */\n pair?: { key: string; label: string };\n}\n\n/**\n * `items` as the rows they draw, in order: each leaf a `pair` names joins the row of the leaf naming it where\n * the two are neighbors, and every other item is a run of its own. `leafOf` gives an item's leaf and the path a\n * `pair` would name it by, or nothing for an item that shares no row, which ends a run.\n */\nexport function pairRuns<T>(\n items: readonly T[],\n leafOf: (item: T) => readonly [path: string, leaf: PrefLeaf] | undefined,\n): PairRun<T>[] {\n const leaves = items.map(leafOf);\n const pairs = pairRowsOf(leaves.filter((entry) => entry !== undefined));\n const keys = leaves.map((entry) => (entry === undefined ? undefined : pairs.get(entry[0])));\n const runs: PairRun<T>[] = [];\n for (let i = 0; i < items.length; ) {\n const pair = keys[i];\n let j = i + 1;\n while (pair !== undefined && keys[j]?.key === pair.key) j += 1;\n runs.push(j - i > 1 ? { items: items.slice(i, j), pair } : { items: [items[i]!] });\n i = j;\n }\n return runs;\n}\n","import type { PrefKind } from './schema';\n\n/** What a surface has to know about a kind before it can lay its control out. */\nexport interface PrefKindTraits {\n /** Its value is made of other leaves' values: too much for one control on a\n * line, so a bar opens it in a popover and a compact panel in a dialog. */\n compound: boolean;\n /** Its control is several controls, or a button. A row drawn as a `<label>`\n * would hand a click on its text to the first of them. */\n several: boolean;\n}\n\nconst ONE: PrefKindTraits = { compound: false, several: false };\nconst MANY: PrefKindTraits = { compound: true, several: true };\n\n/**\n * The traits of every built-in kind. A `Record` over {@link PrefKind}, so a\n * kind added to the union does not compile until it says what it is here:\n * a plain set of kind names lets a new one through to draw inline in a\n * `<label>`, on a bar's line, and with no dialog row.\n */\nexport const PREF_KIND_TRAITS: Record<PrefKind, PrefKindTraits> = {\n number: ONE,\n boolean: ONE,\n string: ONE,\n enum: ONE,\n color: ONE,\n paint: ONE,\n object: MANY,\n list: MANY,\n map: MANY,\n union: MANY,\n field: ONE,\n action: { compound: false, several: true },\n alias: ONE,\n label: ONE,\n separator: ONE,\n};\n\nconst traitsOf = (leaf: { kind: string }): PrefKindTraits =>\n (Object.hasOwn(PREF_KIND_TRAITS, leaf.kind) ? PREF_KIND_TRAITS[leaf.kind as PrefKind] : ONE);\n\n/** Whether a leaf's value is made of other leaves' values. An app-defined kind is not: its renderer is one control. */\nexport function prefIsCompound(leaf: { kind: string }): boolean {\n return traitsOf(leaf).compound;\n}\n\n/** Whether a leaf's control is several controls or a button. */\nexport function prefDrawsSeveral(leaf: { kind: string }): boolean {\n return traitsOf(leaf).several;\n}\n"]}
|