@weasel-js/prefs 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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,IAAA,EAAM,CAAA;AAAA,IACnB,WAAW,GAAA,EAAK;AACd,MAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,IACf,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,KAAK,EAAE,IAAA,EAAO,MAAM,CAAC,IAAI,GAAI,CAAA;AAAA,IACnC;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;;;ACRO,SAAS,cAAA,CAAeA,KAAAA,EAAgB,MAAA,EAAiB,QAAA,EAA6C;AAC3G,EAAA,IAAIA,MAAK,IAAA,KAAS,SAAA,IAAaA,KAAAA,CAAK,IAAA,KAAS,QAAQ,OAAO,MAAA;AAC5D,EAAA,MAAM,EAAE,UAAS,GAAIA,KAAAA;AACrB,EAAA,OAAO,QAAA,GAAY,QAAA,CAAS,IAAA,CAA0D,MAAA,EAAQ,QAAQ,CAAA,GAAI,MAAA;AAC5G;AAUO,SAAS,eAAA,CACd,MAAA,EAAiC,IAAA,EAA2B,IA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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"]}
1
+ {"version":3,"sources":["../src/tabRuns.ts","../src/tags.ts","../src/shown.ts","../src/judge.ts","../src/scopeAt.ts","../src/scope.ts","../src/build.ts","../src/aliasTargets.ts","../src/object.ts","../src/type.ts","../src/groups.ts","../src/heading.ts","../src/pair.ts","../src/kinds.ts","../src/merge.ts"],"names":["leaf","scope","kept","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,IAAA,EAAM,CAAA;AAAA,IACnB,WAAW,GAAA,EAAK;AACd,MAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,IACf,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,KAAK,EAAE,IAAA,EAAO,MAAM,CAAC,IAAI,GAAI,CAAA;AAAA,IACnC;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;ACdA,SAAS,aAAa,MAAA,EAA4F;AAChH,EAAA,MAAM,MAA+C,EAAC;AACtD,EAAA,MAAM,IAAA,GAAO,CAAC,IAAA,EAA+B,MAAA,EAAgB,KAAA,KAAmC;AAC9F,IAAA,MAAM,OAAA,GAAU,cAAc,IAAI,CAAA;AAClC,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,MAAA,CAAO,OAAA,CAAQ,OAAA,GAAU,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,QAAQ,CAAA,EAAG;AACjF,MAAA,MAAM,IAAA,GAAO,WAAW,MAAA,KAAW,EAAA,GAAK,MAAM,CAAA,EAAG,MAAM,IAAI,GAAG,CAAA,CAAA;AAC9D,MAAA,MAAM,IAAA,G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,CAAK,QAAA,EAAS;AACpC,MAAA,aAAA,CAAc,QAAA,EAAU,KAAA,CAAM,QAAA,EAAU,IAAI,CAAA;AAC5C,MAAA,IAAA,CAAK,GAAG,CAAA,GAAI,EAAE,GAAG,MAAM,QAAA,EAAS;AAAA,IAClC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,IAAI,CAAA,4BAAA,CAA8B,CAAA;AAAA,IACzF;AAAA,EACF;AACF;AAQO,SAAS,eAAA,CAAgB,SAAiB,MAAA,EAAyC;AACxF,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ,aAAA,CAAc,QAAA,EAAU,KAAA,CAAM,UAAU,EAAE,CAAA;AACtE,EAAA,OAAO,EAAE,MAAM,QAAA,EAAS;AAC1B","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","import { hasTag } from '@weasel-js/registry';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection } from './helpers';\nimport type { PrefLeaf } from './schema';\n\n/** Every leaf with the tags it carries: those of each group or section above\n * it, outermost first, then its own. Keyed as `prefLeafAt` reads paths. */\nfunction taggedLeaves(schema: PrefGroup | PrefSection): [path: string, leaf: PrefLeaf, tags: readonly string[]][] {\n const out: [string, PrefLeaf, readonly string[]][] = [];\n const walk = (node: PrefGroup | PrefSection, prefix: string, above: readonly string[]): void => {\n const section = isPrefSection(node);\n for (const [key, child] of Object.entries(section ? node.members : node.children)) {\n const path = section || prefix === '' ? key : `${prefix}.${key}`;\n const tags = child.tags ? [...above, ...child.tags] : above;\n if (isPrefLeaf(child)) out.push([path, child, tags]);\n else walk(child, section ? prefix : path, tags);\n }\n };\n walk(schema, '', schema.tags ?? []);\n return out;\n}\n\n/** The leaves carrying `tag`, themselves or through a group above them, by\n * path, in schema order. */\nexport function prefLeavesTagged(schema: PrefGroup | PrefSection, tag: string): Map<string, PrefLeaf> {\n return new Map(taggedLeaves(schema).filter(([, , tags]) => hasTag(tags, tag)).map(([path, leaf]) => [path, leaf]));\n}\n\n/** The tags the leaf at `path` carries: each group's above it, outermost\n * first, then its own. Empty for a path that names no leaf. */\nexport function prefLeafTags(schema: PrefGroup | PrefSection, path: string): readonly string[] {\n return taggedLeaves(schema).find(([p]) => p === path)?.[2] ?? [];\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 { PrefAction, PrefActions } from './action';\nimport type { PrefGroup, PrefSection } from './groups';\nimport type { PrefLabel, PrefSeparator } from './label';\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. */\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 & { default: number } =>\n leaf('number', name, def, rest) as PrefNumber & { default: number },\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 (T | PrefEnumBase<T>['options'][number])[],\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 button firing the registered action `action` (`id` or `id:variant`). Its name defaults to empty, which shows the action's own label. */\n action: (action: string, rest?: Partial<Omit<PrefAction, 'kind' | 'default' | 'action'>>): PrefAction =>\n leaf('action', '', undefined, { action, ...rest }),\n /** Every action registered in the action group `group`. */\n actions: (group: string, rest?: Partial<Omit<PrefActions, 'kind' | 'default' | 'group'>>): PrefActions =>\n leaf('actions', '', undefined, { group, ...rest }),\n label: (name: string, rest?: Rest<PrefLabel>): PrefLabel => leaf('label', name, undefined, rest),\n separator: (): PrefSeparator => leaf('separator', '', undefined, undefined),\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 { IconRef } from '@weasel-js/icons';\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 * `bar` puts its prefs on one line in their bar forms. `menu` is drawn as\n * a menu wherever a menu fits: on a bar, a button opening its contents as a\n * menu; in a menu, a submenu; in a panel, a titled box as `panel` is.\n */\nexport type PrefGroupAs = 'page' | 'tab' | 'panel' | 'section' | 'fragment' | 'bar' | 'menu';\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/** What a bar's line starts with, ahead of its cells: `label` puts the bar's name there, and `icon` its `icon`. */\nexport type PrefBarLead = 'label' | 'icon';\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 /** Tags every leaf under the group carries besides its own. A settings\n * search matching one keeps the whole group, as matching its name does. */\n tags?: readonly 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 `as: 'bar'`: what its line starts with. Unset: its first cell. */\n lead?: PrefBarLead;\n /** Glyph naming the group, as a leaf's `icon` names the leaf. A bar drawn\n * with `lead: 'icon'` starts its line with it; the button a bar opens the\n * group from and its submenu row in a menu carry it beside its name. */\n icon?: IconRef;\n /** The letter that picks this in a menu, and with the menu bar's chord opens a top-level menu. One character; supported, never required. */\n access?: string;\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 /** As a {@link PrefGroup}'s. */\n tags?: readonly 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 lead?: PrefBarLead;\n /** As a {@link PrefGroup}'s. */\n icon?: IconRef;\n /** As a {@link PrefGroup}'s. */\n access?: string;\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 panel draws a group or a section drawn `as` this in a bordered, titled box: a `panel`, and a `menu`,\n * which a panel has no menu to open as. */\nexport function prefAsBox(as: PrefGroupAs | undefined): boolean {\n return as === 'panel' || as === 'menu';\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 actions: { 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","import type { PrefGroup } from './groups';\nimport { isPrefLeaf } from './helpers';\nimport type { PrefLeaf } from './schema';\n\ntype Child = PrefLeaf | PrefGroup;\n\nfunction mergeChildren(into: Record<string, Child>, from: Record<string, Child>, at: string): void {\n for (const [key, child] of Object.entries(from)) {\n const path = at === '' ? key : `${at}.${key}`;\n const held = into[key];\n if (held === undefined) {\n into[key] = child;\n } else if (!isPrefLeaf(held) && !isPrefLeaf(child)) {\n const children = { ...held.children };\n mergeChildren(children, child.children, path);\n into[key] = { ...held, children };\n } else {\n throw new Error(`mergePrefGroups: two groups give \"${path}\", and one of them is a leaf`);\n }\n }\n}\n\n/**\n * One group named `name` holding every child of `groups`. Groups at the same\n * key merge, the first one's own fields kept; a leaf meeting anything at the\n * same key throws. Composes schemas that each add to the same areas, such as\n * the kit settings groups that `ui` and `core` both give a `targets` group.\n */\nexport function mergePrefGroups(name: string, ...groups: readonly PrefGroup[]): PrefGroup {\n const children: Record<string, Child> = {};\n for (const group of groups) mergeChildren(children, group.children, '');\n return { name, children };\n}\n"]}
@@ -0,0 +1,203 @@
1
+ import { StorageAdapter, SyncStorageAdapter } from '@weasel-js/storage';
2
+ import { Z as PrefWeighted, P as PrefLeaf, a as PrefGroup, _ as PrefWeights, M as PrefLocus, U as PrefSelection } from './groups-BDZC-ywb.js';
3
+
4
+ /**
5
+ * Folds a split value's alternatives into the one value read. `members` holds
6
+ * two or more, each weighing more than nothing, and their weights need not
7
+ * sum to 1.
8
+ */
9
+ type PrefBlend = (members: readonly PrefWeighted[], leaf: PrefLeaf) => unknown;
10
+ /** The blends of the built-in kinds that have one. Every other kind takes its heaviest member. */
11
+ declare const PREF_BLENDS: Readonly<Record<string, PrefBlend>>;
12
+
13
+ type Join<A extends string, B extends string> = A extends '' ? B : `${A}.${B}`;
14
+ /** Every value's dotted path in a `PrefGroup` schema, where a group's key is a
15
+ * segment; an `object` leaf is one path, its fields are not, and an `action`,
16
+ * `actions`, `alias`, `label`, or `separator` leaf, holding no value, has none. A `PrefSection`
17
+ * has no such paths: each of its leaves is addressed by its own key. */
18
+ type PrefPath<G, Prefix extends string = ''> = G extends {
19
+ children: infer C;
20
+ } ? string extends keyof C ? Join<Prefix, string> : {
21
+ [K in keyof C & string]: C[K] extends {
22
+ kind: string;
23
+ } ? C[K] extends {
24
+ kind: 'action' | 'actions' | 'alias' | 'label' | 'separator';
25
+ } ? never : Join<Prefix, K> : C[K] extends {
26
+ children: Record<string, unknown>;
27
+ } ? PrefPath<C[K], Join<Prefix, K>> : never;
28
+ }[keyof C & string] : never;
29
+ /** The leaf at `P`. `unknown` under a group whose keys are not literal, as a
30
+ * schema built at run time has them: nothing says which leaf is there, so
31
+ * its value reads as `unknown`. */
32
+ type PrefAtPath<G, P extends string> = G extends {
33
+ children: infer C;
34
+ } ? string extends keyof C ? unknown : P extends `${infer H}.${infer Rest}` ? H extends keyof C ? C[H] extends {
35
+ kind: string;
36
+ } ? never : PrefAtPath<C[H], Rest> : never : P extends keyof C ? C[P] extends {
37
+ kind: string;
38
+ } ? C[P] : never : never : never;
39
+ type AllOf<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
40
+ /** The fields an `object` leaf's `children` describe, sections folded in. Each is optional: an object may omit any. */
41
+ type PrefFieldsOf<C> = {
42
+ [K in keyof C as C[K] extends {
43
+ kind: string;
44
+ } ? K : never]?: PrefValueOf<C[K]>;
45
+ } & AllOf<{
46
+ [K in keyof C]: C[K] extends {
47
+ members: infer M;
48
+ } ? PrefFieldsOf<M> : never;
49
+ }[keyof C]>;
50
+ /** What a leaf holds: its kind's value type for a built-in kind, the type of
51
+ * its `default` for an app-defined one. A list holds an array of what its
52
+ * `item` holds, a map a record of it, and a union one variant's fields
53
+ * under that variant's tag — where the schema keeps `tag` a literal
54
+ * (`tag: 'type' as const`); one widened to `string` is typed by its default. */
55
+ type PrefValueOf<L> = L extends {
56
+ kind: 'number';
57
+ } ? number : L extends {
58
+ kind: 'boolean';
59
+ } ? boolean : L extends {
60
+ kind: 'string' | 'color' | 'field';
61
+ } ? string : L extends {
62
+ kind: 'paint';
63
+ } ? unknown : L extends {
64
+ kind: 'enum';
65
+ options: readonly {
66
+ value: infer T;
67
+ }[];
68
+ } ? L extends {
69
+ clearable: true;
70
+ } ? T | undefined : T : L extends {
71
+ kind: 'list';
72
+ item: infer I;
73
+ } ? PrefValueOf<I>[] : L extends {
74
+ kind: 'map';
75
+ item: infer I;
76
+ } ? Record<string, PrefValueOf<I>> : L extends {
77
+ kind: 'union';
78
+ tag: infer T extends string;
79
+ variants: infer V;
80
+ default: infer D;
81
+ } ? string extends keyof V | T ? D : {
82
+ [K in keyof V & string]: {
83
+ [P in T]: K;
84
+ } & (V[K] extends {
85
+ children: infer C;
86
+ } ? PrefFieldsOf<C> : unknown);
87
+ }[keyof V & string] : L extends {
88
+ default: infer D;
89
+ } ? D : unknown;
90
+ /** What the leaf at `P` holds. */
91
+ type PrefValueAt<G, P extends string> = PrefValueOf<PrefAtPath<G, P>>;
92
+
93
+ /** Takes stored values from one version to the next: rename, transform or
94
+ * delete entries in `records`, keyed by leaf path. It sees the values, not
95
+ * the stamps they are stored under, and only those at its own version. */
96
+ type PrefsMigration = (records: Map<string, unknown>) => void;
97
+
98
+ /** Decides what a stored value reads as for one kind of leaf: the value to
99
+ * read, or `undefined` for "invalid, read the default". */
100
+ type PrefValidator = (stored: unknown, leaf: PrefLeaf) => unknown;
101
+ /** What `stored` reads as for `leaf`. Never writes anything back: a schema
102
+ * rolled back finds the original still in storage. */
103
+ declare function repairPrefValue(leaf: PrefLeaf, stored: unknown, validators?: Readonly<Record<string, PrefValidator>>): unknown;
104
+
105
+ /** One leaf changing, as a store subscriber hears it: the value readers now
106
+ * see, and whether this store or another writer made the change. */
107
+ interface PrefChange {
108
+ path: string;
109
+ value: unknown;
110
+ origin: 'local' | 'remote';
111
+ }
112
+ /** Values for one schema, held in memory and persisted behind. */
113
+ interface PrefsStore<S extends PrefGroup> {
114
+ readonly schema: S;
115
+ /**
116
+ * The leaf's value, repaired against the schema; its default when unset. A
117
+ * split value is folded: under the selectors' own values it is the member
118
+ * they name, and under `weights` it is the blend its kind makes of the
119
+ * members that weigh something. A selector `weights` leaves out keeps its
120
+ * own value.
121
+ */
122
+ get<P extends PrefPath<S>>(path: P, read?: {
123
+ weights?: PrefWeights;
124
+ }): PrefValueAt<S, P>;
125
+ /** On a split leaf, writes the member the selectors' own values name, or
126
+ * with `at` the one named with each selector there set to the option given.
127
+ * A {@link PrefLocus} given as the value replaces the whole of what is held. */
128
+ set<P extends PrefPath<S>>(path: P, value: PrefValueAt<S, P> | PrefLocus, write?: {
129
+ at?: PrefSelection;
130
+ }): void;
131
+ /** Hold the leaf's value once per option of the selector at `by`, one of
132
+ * the leaf's `splitBy`, each option starting as the value it had. */
133
+ split(path: PrefPath<S>, by: string): void;
134
+ /** Stop splitting the leaf's value by the selector at `by`, keeping the
135
+ * member that selector's own value names. */
136
+ join(path: PrefPath<S>, by: string): void;
137
+ /** What the leaf holds where its value is split, each member repaired. */
138
+ locus(path: PrefPath<S>): PrefLocus | undefined;
139
+ /** What every split leaf holds, by its path. The same map until something changes. */
140
+ loci(): ReadonlyMap<string, PrefLocus>;
141
+ /** Unset every leaf at or under `path`; with no path, all. */
142
+ reset(path?: string): void;
143
+ /** Whether the leaf has a value of its own rather than following its default. */
144
+ isSet(path: PrefPath<S>): boolean;
145
+ /** Every leaf's value as a nested tree. The same object until something
146
+ * changes. With `at`, the tree as it would read with each selector named
147
+ * there set to the option given, built for the call. */
148
+ values(read?: {
149
+ at?: PrefSelection;
150
+ }): Record<string, unknown>;
151
+ /** The leaves following their default. The same set until something changes. */
152
+ unset(): ReadonlySet<string>;
153
+ /** Every stored record as a nested tree, unrepaired, including records no
154
+ * leaf describes. The same object until something changes. */
155
+ stored(): Record<string, unknown>;
156
+ /** `changes` is empty when only records no leaf describes changed. A
157
+ * selector changing is a change to every leaf split by it. */
158
+ subscribe(listener: (changes: PrefChange[]) => void): () => void;
159
+ /** False while the store cannot persist: storage has not been read yet, or
160
+ * was written by a newer schema. Changes still apply for this session, and
161
+ * ones made before a late read lands are persisted when it does. False for
162
+ * good once the store is closed. */
163
+ readonly writable: boolean;
164
+ /** True once `close` was called. A write after that changes what this store
165
+ * reads and reaches neither storage nor its subscribers, and the first one
166
+ * warns. */
167
+ readonly closed: boolean;
168
+ /** Try again now to read storage that could not be read at open, ahead of
169
+ * the store's own retries. Resolves whether storage has been read. */
170
+ read(): Promise<boolean>;
171
+ /** Resolves once storage has been read: at once for a store that opened
172
+ * with its values, and when a later read lands for one that could not. */
173
+ whenRead(): Promise<void>;
174
+ /** Resolves true when every queued write reached storage. */
175
+ flush(): Promise<boolean>;
176
+ close(): Promise<void>;
177
+ }
178
+
179
+ /** Options for `openPrefs` and `openPrefsSync`. */
180
+ interface PrefsOptions {
181
+ storage: StorageAdapter;
182
+ /** Prepended to every record's key: `'myapp.prefs.'`. */
183
+ prefix: string;
184
+ /** `migrations[i]` takes stored records from version `i` to `i + 1`. The
185
+ * current version is `migrations.length`. */
186
+ migrations?: readonly PrefsMigration[];
187
+ /** Validators for app-defined kinds, keyed by `kind`. One given for a
188
+ * built-in kind replaces that kind's own rule. */
189
+ validators?: Readonly<Record<string, PrefValidator>>;
190
+ /** How a split value's alternatives fold into one for app-defined kinds,
191
+ * keyed by `kind`. One given for a built-in kind replaces that kind's
192
+ * own. A kind with none takes its heaviest alternative. */
193
+ blends?: Readonly<Record<string, PrefBlend>>;
194
+ }
195
+ /** Load every stored value for `schema`, migrate it, and return the store. */
196
+ declare function openPrefs<S extends PrefGroup>(schema: S, options: PrefsOptions): Promise<PrefsStore<S>>;
197
+ /** `openPrefs` for an adapter that reads synchronously: the store is ready
198
+ * on return, so values can be read before anything renders. */
199
+ declare function openPrefsSync<S extends PrefGroup>(schema: S, options: PrefsOptions & {
200
+ storage: SyncStorageAdapter;
201
+ }): PrefsStore<S>;
202
+
203
+ export { PREF_BLENDS as P, type PrefAtPath as a, type PrefBlend as b, type PrefChange as c, type PrefPath as d, type PrefValidator as e, type PrefValueAt as f, type PrefValueOf as g, type PrefsMigration as h, type PrefsOptions as i, type PrefsStore as j, openPrefsSync as k, openPrefs as o, repairPrefValue as r };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { a as PrefGroup, S as PrefPath, a3 as PrefsStore, Z as PrefValueAt, m as PrefLocus, l as PrefSelection, a2 as PrefsOptions } from './open-C83pU7Va.js';
1
+ import { d as PrefPath, j as PrefsStore, f as PrefValueAt, i as PrefsOptions } from './open-VJ1zlFJz.js';
2
+ import { a as PrefGroup, M as PrefLocus, U as PrefSelection } from './groups-BDZC-ywb.js';
2
3
  import { SyncStorageAdapter } from '@weasel-js/storage';
4
+ import { ReactNode } from 'react';
5
+ import '@weasel-js/icons';
3
6
  import '@weasel-js/quantity';
4
7
 
5
8
  /** One leaf of `store`, as React state. */
@@ -23,7 +26,8 @@ declare function usePrefsValues<S extends PrefGroup>(store: PrefsStore<S>): {
23
26
  setAt: (path: string, value: unknown, at: PrefSelection) => void;
24
27
  };
25
28
 
26
- type SyncOptions = PrefsOptions & {
29
+ /** The store options `usePrefsStore` takes: a store's, with the synchronous storage it reads at once. */
30
+ type UsePrefsStoreOptions = PrefsOptions & {
27
31
  storage: SyncStorageAdapter;
28
32
  };
29
33
  /**
@@ -44,6 +48,25 @@ type SyncOptions = PrefsOptions & {
44
48
  * object itself may be new every render: `migrations` and `validators` are
45
49
  * read when a store opens, and a change to either alone opens nothing.
46
50
  */
47
- declare function usePrefsStore<S extends PrefGroup>(schema: S, options: SyncOptions): PrefsStore<S>;
51
+ declare function usePrefsStore<S extends PrefGroup>(schema: S, options: UsePrefsStoreOptions): PrefsStore<S>;
48
52
 
49
- export { usePref, usePrefsStore, usePrefsValues };
53
+ /**
54
+ * Kit settings from a prefs store: everything inside reads the store's values
55
+ * at `at` (the whole store without it) through `useKitSetting`, kept current
56
+ * as the store changes.
57
+ *
58
+ * With `css`, the same subtree is written as `--wzl-kit-*` custom properties
59
+ * (`kitSettingsCssOptions(at)`) into a sheet of the document or shadow root
60
+ * the component renders in, and the selectors' attributes are set on that
61
+ * root's element — `<html>`, or the shadow host, matched as `:root` or
62
+ * `:host`. That root is found from a hidden `<span>` rendered ahead of the
63
+ * children. Both are rewritten on every store change and removed on unmount.
64
+ */
65
+ declare function KitSettingsFromPrefs<S extends PrefGroup>({ store, at, css, children, }: {
66
+ store: PrefsStore<S>;
67
+ at?: string;
68
+ css?: boolean;
69
+ children?: ReactNode;
70
+ }): ReactNode;
71
+
72
+ export { KitSettingsFromPrefs, type UsePrefsStoreOptions, usePref, usePrefsStore, usePrefsValues };