@weasel-js/prefs-schema 0.0.0-stage → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +30 -2
- package/dist/chunk-DVHFV6JS.js +596 -0
- package/dist/chunk-DVHFV6JS.js.map +1 -0
- package/dist/index.d.ts +395 -0
- package/dist/index.js +488 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-DMioFJDY.d.ts +1041 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/alias.ts","../src/unit.ts","../src/helpers.ts","../src/condition.ts","../src/schema.ts","../src/holding.ts","../src/scope.ts","../src/scopeSpec.ts"],"names":["setOwn","isPlainObject","getOwn","under","read"],"mappings":";;;;AAoBO,SAAS,eAAA,CACd,OACA,MAAA,EAC8C;AAC9C,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAY;AAC/B,EAAA,IAAI,OAAO,KAAA,CAAM,EAAA;AACjB,EAAA,WAAS;AACP,IAAA,IAAI,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA,EAAG,OAAO,MAAA;AAC7B,IAAA,MAAA,CAAO,IAAI,IAAI,CAAA;AACf,IAAA,MAAM,IAAA,GAAO,OAAO,IAAI,CAAA;AACxB,IAAA,IAAI,IAAA,KAAS,QAAW,OAAO,MAAA;AAC/B,IAAA,IAAI,KAAK,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,MAAM,IAAA,EAAK;AAC/C,IAAA,IAAA,GAAQ,IAAA,CAAmB,EAAA;AAAA,EAC7B;AACF;AAOO,SAAS,aAAA,CAAc,OAAkB,MAAA,EAA2B;AACzE,EAAA,IAAI,KAAA,CAAM,IAAA,KAAS,EAAA,EAAI,OAAO,KAAA,CAAM,IAAA;AACpC,EAAA,OAAO,MAAA,KAAW,MAAA,GA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ACJ,EAAA,KAAA,MAAW,KAAA,IAAS,CAAC,GAAG,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ,EAAG,KAAA,GAAQ,KAAA,KAAU,MAAA,GAAY,EAAE,GAAA,EAAK,KAAA,CAAM,UAAU,GAAA,EAAK,IAAG,GAAI,QAAA,CAAS,KAAA,CAAM,QAAA,EAAU,KAAK,CAAA;AAC/I,EAAA,OAAO,KAAA;AACT","file":"chunk-DVHFV6JS.js","sourcesContent":["import type { PrefBase, PrefLeaf } from './schema';\n\n/**\n * A second place for another leaf: its row draws that leaf's control and\n * reads and writes that leaf's value, so one setting can sit on two pages.\n * It holds no value of its own. A store neither reads nor writes one, and\n * its path is not a {@link PrefPath}.\n *\n * `name` and `description` left empty are the target's.\n */\nexport interface PrefAlias extends PrefBase<'alias', undefined> {\n /** The leaf shown here, by the full path its value is read and written at (`'view.grid'`). */\n of: string;\n}\n\n/**\n * The leaf an alias stands for and the path its value lives at, following an\n * alias of an alias to its end. `undefined` when a path along the way names\n * no leaf, or the aliases lead back to one already passed.\n */\nexport function prefAliasTarget(\n alias: PrefAlias,\n leafAt: (path: string) => PrefLeaf | undefined,\n): { path: string; leaf: PrefLeaf } | undefined {\n const passed = new Set<string>();\n let path = alias.of;\n for (;;) {\n if (passed.has(path)) return undefined;\n passed.add(path);\n const leaf = leafAt(path);\n if (leaf === undefined) return undefined;\n if (leaf.kind !== 'alias') return { path, leaf };\n path = (leaf as PrefAlias).of;\n }\n}\n\n/**\n * What an alias is called wherever one is drawn or named: its own name, else\n * that of `target`, the leaf it shows, else `Alias` for one that shows\n * nothing.\n */\nexport function prefAliasName(alias: PrefAlias, target?: PrefLeaf): string {\n if (alias.name !== '') return alias.name;\n return target === undefined ? 'Alias' : target.name;\n}\n\n/** A leaf drawn through an alias: the target, under the alias's own name, description and access letter where it gives them. */\nexport function prefAliasedLeaf(alias: PrefAlias, target: PrefLeaf): PrefLeaf {\n return {\n ...target,\n name: prefAliasName(alias, target),\n description: alias.description === '' ? target.description : alias.description,\n ...(alias.access ? { access: alias.access } : {}),\n ...(alias.tags ? { tags: [...(target.tags ?? []), ...alias.tags] } : {}),\n };\n}\n","// A number leaf's display unit: the stored value stays canonical (radians, millimeters), and a UI converts\n// at its edge. A unit is data where the conversion is linear, and a pair of functions where it is not.\n\nimport { setOwn } from '@weasel-js/registry';\nimport { decimal, decimalPlaces, formatUnit, unitScale, unitSymbol, type Display, type Unit, type UnitEntry, type UnitScale, type UnitSystem, type UnitTable } from '@weasel-js/quantity';\n\n/** What both forms of a unit say about the text around the number. */\nexport interface PrefUnitText {\n /** The unit shown after the input, as the unit catalog writes it: `'deg'` and `'°'` both show `°`,\n * and text the catalog does not know shows as given. */\n suffix?: string;\n /** Show the unit's compact form, where it has one: `″` for `in`. */\n compact?: boolean;\n /** Suffixes a person may type, each mapped to the scale that turns a\n * number in that unit into a display number: `{ mm: 0.1, cm: 1 }` for a\n * field showing centimeters. A unit that disagrees with the display unit\n * about zero carries an `offset` as well. */\n accepts?: Readonly<Record<string, UnitEntry>>;\n}\n\n/**\n * A display unit as data, for a conversion that is linear: `stored = display * scale + offset`, the direction a\n * `UnitEntry` runs toward its base, so `scale` is what one display unit is worth in stored units. Degrees shown\n * over radians stored is `{ suffix: '°', scale: Math.PI / 180 }`, and `{ scale: 1 }` changes nothing. Being data,\n * it is written to JSON, printed in a schema literal, and edited in `PrefSchemaEditor` like any other attribute.\n */\nexport interface PrefLinearUnit extends PrefUnitText {\n /** Stored units per display unit. Never 0. */\n scale: number;\n /** The stored value a display of 0 stands for. Absent is 0. */\n offset?: number;\n /** Decimal places the shown value is rounded and padded to, so `1.5` at 2 shows `1.50`. Absent, the value\n * shows unrounded and formats to two places, trailing zeros trimmed.\n * What is typed is stored unrounded either way: a decimal typed at a decimal `scale` is stored as the\n * decimal the two multiply to, without the dust of multiplying them in binary. */\n places?: number;\n}\n\n/** A display unit as code, for a conversion that is not linear. It cannot be written to JSON or edited as data. */\nexport interface PrefFunctionUnit extends PrefUnitText {\n toDisplay: (stored: number) => number;\n fromDisplay: (display: number) => number;\n /** The stored value as display text, suffix included. */\n format?: (stored: number) => string;\n}\n\n/** Display-unit conversion for number leaves whose stored value uses a\n * canonical unit the user shouldn't see (e.g. radians stored, degrees\n * shown). Read one through {@link resolvePrefUnit}, which answers for both forms. */\nexport type PrefNumberUnit = PrefLinearUnit | PrefFunctionUnit;\n\n/** A unit of either form as the functions that convert and format with it. Its `suffix` is the text a field\n * shows, the catalog's form of the one written. */\nexport interface ResolvedPrefUnit extends PrefFunctionUnit {\n format: (stored: number) => string;\n /** How a field shows the display number, where the unit fixes its places. */\n display?: Display;\n /** The decimal places `toDisplay` rounds to, where the unit fixes them. */\n places?: number;\n /** `toDisplay` before any rounding to `places`. */\n toDisplayExact: (stored: number) => number;\n}\n\n/** What a unit leaf's field reads as typed text: its `accepts` table, and its\n * `suffix` as the display unit itself. */\nexport function prefUnitAccepts(unit: PrefNumberUnit): Readonly<UnitTable> {\n return unit.suffix === undefined ? { ...unit.accepts } : { [unit.suffix]: 1, ...unit.accepts };\n}\n\n/** Whether `unit` is the data form, and so can be written out and edited. */\nexport function isPrefLinearUnit(unit: PrefNumberUnit): unit is PrefLinearUnit {\n return typeof (unit as PrefFunctionUnit).toDisplay !== 'function';\n}\n\n/** The name `formatUnit` is asked for a linear unit's one unit by. */\nconst SHOWN = 'shown';\n\n/** Beyond this many places a number is not a decimal someone wrote, and the product is left as computed. */\nconst DECIMAL_PLACES = 12;\n\n/**\n * `shown * scale + offset` as the decimal it is, where all three are short decimals: 33.3 at a scale of 0.01\n * is 0.333, where the product computed in binary is 0.33299999999999996. Nothing is rounded away: the places\n * kept are every place the exact answer has.\n */\nfunction storedOf(shown: number, scale: number, offset: number): number {\n const raw = shown * scale + offset;\n if (!Number.isFinite(raw)) return raw;\n const places = Math.max(decimalPlaces(shown) + decimalPlaces(scale), decimalPlaces(offset));\n return places > DECIMAL_PLACES ? raw : Number(raw.toFixed(places));\n}\n\n/** How to convert and format with `unit`, whichever form it was written in. */\nexport function resolvePrefUnit(unit: PrefNumberUnit): ResolvedPrefUnit {\n const suffix = unit.suffix === undefined ? undefined : unitSymbol(unit.suffix, { compact: unit.compact }).text;\n if (!isPrefLinearUnit(unit)) {\n return {\n ...unit,\n ...(suffix === undefined ? {} : { suffix }),\n toDisplayExact: unit.toDisplay,\n format: unit.format ?? ((stored) => `${unit.toDisplay(stored)}${suffix ?? ''}`),\n };\n }\n const { scale, offset = 0, places, accepts } = unit;\n const system: UnitSystem = { base: 'stored', units: { [SHOWN]: { factor: scale, offset } } };\n const toDisplayExact = (stored: number): number => (stored - offset) / scale;\n return {\n toDisplay: (stored) => {\n const shown = toDisplayExact(stored);\n return places === undefined ? shown : Number(shown.toFixed(places));\n },\n toDisplayExact,\n fromDisplay: (shown) => storedOf(shown, scale, offset),\n format: (stored) =>\n `${formatUnit(stored, SHOWN, system, { places: places ?? 2, suffix: false, pad: places !== undefined })}${suffix ?? ''}`,\n ...(places === undefined ? {} : { places, display: decimal({ places, grouping: false }) }),\n ...(suffix === undefined ? {} : { suffix }),\n ...(accepts === undefined ? {} : { accepts }),\n };\n}\n\n/**\n * A display unit built from a {@link UnitSystem}: values are stored in the\n * system's base and shown in `display`, rounded to `places` decimal places when\n * given, and every unit in the system is accepted as typed text. `suffix`\n * defaults to the unit's name and is accepted too. Every unit of a system is\n * linear, so what comes back is data.\n */\nexport function prefUnit(\n system: UnitSystem,\n display: Unit,\n opts?: { places?: number; suffix?: string; compact?: boolean },\n): PrefLinearUnit {\n let self: Required<UnitScale>;\n try {\n self = unitScale(system, display);\n } catch (e) {\n throw new Error(`prefUnit: ${e instanceof Error ? e.message : String(e)}`);\n }\n const suffix = opts?.suffix ?? display;\n const accepts: Record<string, UnitEntry> = { [suffix]: 1 };\n for (const name of Object.keys(system.units)) {\n const other = unitScale(system, name);\n // A number typed in `name` reaches display units through base:\n // `(n * factor + offset - self.offset) / self.factor`.\n const factor = other.factor / self.factor;\n const offset = (other.offset - self.offset) / self.factor;\n setOwn(accepts, name, offset === 0 ? factor : { factor, offset });\n }\n return {\n suffix,\n scale: self.factor,\n ...(self.offset === 0 ? {} : { offset: self.offset }),\n accepts,\n ...(opts?.places === undefined ? {} : { places: opts.places }),\n ...(opts?.compact ? { compact: true } : {}),\n };\n}\n\n/** A length stored and shown in CSS pixels: what a leaf keyed `…Px` carries, a brush radius or a click's reach\n * measured on screen rather than in world units. */\nexport const PX_UNIT: PrefLinearUnit = { scale: 1, suffix: 'px' };\n","import type { Endless } from '@weasel-js/quantity';\nimport { getOwn, matchQuery, setOwn } from '@weasel-js/registry';\nimport { prefAliasedLeaf, prefAliasTarget, type PrefAlias } from './alias';\nimport type { PrefGroup, PrefSection } from './groups';\nimport type { PrefLeaf, PrefNumber, PrefObject } from './schema';\nimport { resolvePrefUnit } from './unit';\n\n/**\n * A number leaf's bounds in the unit it is displayed in.\n *\n * Only what the leaf declares converts: an omitted bound has no stored\n * counterpart to put through the conversion, and its fallback — 0..100 for a\n * slider's track, a step of 1 — is a display-space number already. `min` and\n * `max` are points, so they convert the way the value does; `step` is a\n * distance, and a unit with an offset maps zero somewhere else, so converting\n * it as a point would scale it wrong; under a unit's `places` it is rounded\n * up to the smallest step that changes the shown value; `stops` are points. A decreasing\n * conversion swaps which end is the lower one, and which end is `endless`.\n */\nexport function prefDisplayBounds(\n p: PrefNumber,\n): { min?: number; max?: number; step: number; endless?: Endless; stops?: readonly number[] } {\n const ends = p.endless === undefined ? {} : { endless: p.endless };\n if (!p.unit) return { min: p.min, max: p.max, step: p.step ?? 1, ...ends, ...(p.stops ? { stops: p.stops } : {}) };\n const { toDisplay, toDisplayExact, places } = resolvePrefUnit(p.unit);\n const backward = toDisplayExact(1) < toDisplayExact(0);\n const lo = p.min === undefined ? undefined : toDisplay(p.min);\n const hi = p.max === undefined ? undefined : toDisplay(p.max);\n const step = p.step === undefined ? 1 : displayStep(Math.abs(toDisplayExact(p.step) - toDisplayExact(0)), places);\n const flip = { min: 'max', max: 'min', both: 'both' } as const;\n const endless = backward && p.endless !== undefined ? flip[p.endless] : p.endless;\n const stops = p.stops?.map(toDisplay);\n return {\n min: backward ? hi : lo,\n max: backward ? lo : hi,\n step,\n ...(endless === undefined ? {} : { endless }),\n ...(stops ? { stops } : {}),\n };\n}\n\n/** `exact` rounded up to a whole number of the last place `places` shows, so a step always changes what is shown. */\nfunction displayStep(exact: number, places: number | undefined): number {\n if (places === undefined) return exact;\n const quantum = 10 ** -places;\n // The quotient is rounded first so binary dust (1.1 / 0.1 = 11.000000000000002) does not ceil a step up.\n const quanta = Math.max(1, Math.ceil(Number((exact / quantum).toFixed(9))));\n return Number((quanta * quantum).toFixed(places));\n}\n\n/** Distinguishes a leaf from a group or a section while walking a schema tree. */\nexport function isPrefLeaf(node: PrefLeaf | PrefGroup | PrefSection): node is PrefLeaf {\n return 'kind' in node;\n}\n\nconst VALUELESS: ReadonlySet<string> = new Set(['action', 'actions', 'alias', 'label', 'separator']);\n\n/** Whether a leaf has a value to store: an `action` is a button and holds none, nor does an `actions` run of them, an `alias` shows another leaf's,\n * and a `label` and a `separator` are text and a rule. */\nexport function prefHoldsValue(leaf: PrefLeaf): boolean {\n return !VALUELESS.has(leaf.kind);\n}\n\n/** Distinguishes a section, whose key adds nothing to a path, from a group, whose key is a segment. */\nexport function isPrefSection(node: PrefLeaf | PrefGroup | PrefSection): node is PrefSection {\n return !isPrefLeaf(node) && 'members' in node;\n}\n\n/**\n * Every leaf under a section's `members` or an object leaf's `children`, in\n * schema order, by its own key: the sections between contribute nothing.\n */\nexport function prefSectionLeaves(members: PrefSection['members']): [key: string, leaf: PrefLeaf][] {\n return Object.entries(members).flatMap(([key, child]): [string, PrefLeaf][] =>\n isPrefLeaf(child) ? [[key, child]] : prefSectionLeaves(child.members),\n );\n}\n\n/**\n * The leaf whose value lives at `path`, as the schema's own shape builds\n * paths: a segment per key under a {@link PrefGroup}, the leaf's own key\n * under a {@link PrefSection}. `undefined` for a path that names a group, a\n * field inside an `object` leaf, or nothing.\n */\nexport function prefLeafAt(schema: PrefGroup | PrefSection, path: string): PrefLeaf | undefined {\n if (isPrefSection(schema)) return prefSectionLeaves(schema.members).find(([key]) => key === path)?.[1];\n let node: PrefLeaf | PrefGroup = schema;\n for (const seg of path.split('.')) {\n if (isPrefLeaf(node) || !Object.hasOwn(node.children, seg)) return undefined;\n node = node.children[seg]!;\n }\n return isPrefLeaf(node) ? node : undefined;\n}\n\n/** Get the value at a dotted path inside a nested value tree. Returns\n * `undefined` when a segment is missing or hits a non-object. */\nexport function prefValueAt(values: unknown, path: string): unknown {\n let cur: unknown = values;\n for (const seg of path.split('.')) {\n if (cur == null || typeof cur !== 'object' || !Object.hasOwn(cur, seg)) return undefined;\n cur = (cur as Record<string, unknown>)[seg];\n }\n return cur;\n}\n\n/** An object leaf's fields without the `hidden` ones, and without the sections that leaves empty (unless `keepEmpty`). */\nfunction visibleFields(fields: PrefObject['children'], keepEmpty: boolean): PrefObject['children'] {\n const out: PrefObject['children'] = {};\n for (const [key, child] of Object.entries(fields)) {\n if (isPrefLeaf(child)) {\n const kept = visiblePrefSubtree(child, false, keepEmpty);\n if (kept) setOwnPrefValue(out, key, kept);\n continue;\n }\n const members = visibleFields(child.members, keepEmpty);\n if (Object.keys(members).length > 0 || keepEmpty) setOwnPrefValue(out, key, { ...child, members });\n }\n return out;\n}\n\n/**\n * Recursively drop `hidden` leaves (unless `showHidden`), an object leaf's\n * hidden fields among them, pruning groups\n * that end up empty (unless `keepEmpty`). Returns null when the entire\n * subtree is pruned.\n */\nexport function visiblePrefSubtree<T extends PrefLeaf | PrefGroup>(\n node: T,\n showHidden: boolean,\n keepEmpty = false,\n): T | null {\n if (isPrefLeaf(node)) {\n if (node.hidden && !showHidden) return null;\n if (showHidden || node.kind !== 'object') return node;\n return { ...node, children: visibleFields((node as PrefObject).children, keepEmpty) };\n }\n const group = node as PrefGroup;\n const children: Record<string, PrefLeaf | PrefGroup> = {};\n for (const [key, child] of Object.entries(group.children)) {\n const kept = visiblePrefSubtree(child, showHidden, keepEmpty);\n if (kept) setOwnPrefValue(children, key, kept);\n }\n if (Object.keys(children).length === 0 && !keepEmpty) return null;\n return { ...node, children };\n}\n\n/** The record holding the schema version the stored values were written at.\n * Reserved: no top-level schema key may take its name. */\nexport const VERSION_RECORD = '$version';\n\n/** Every leaf under `schema`, by dotted path, in schema order. A group's key\n * is a segment; {@link prefSectionLeaves} is the walk for a section. */\nexport function prefLeaves(schema: PrefGroup): Map<string, PrefLeaf> {\n const out = new Map<string, PrefLeaf>();\n const walk = (group: PrefGroup, prefix: string): void => {\n for (const [key, child] of Object.entries(group.children)) {\n if (key.includes('.')) {\n throw new Error(`[prefs] schema key \"${key}\" contains \".\"; group keys are path segments`);\n }\n if (prefix === '' && key === VERSION_RECORD) {\n throw new Error(`[prefs] schema key \"${VERSION_RECORD}\" is reserved`);\n }\n const path = prefix === '' ? key : `${prefix}.${key}`;\n if (isPrefLeaf(child)) out.set(path, child);\n else walk(child, path);\n }\n };\n walk(schema, '');\n return out;\n}\n\n/** Set `key` on `tree` itself. Plain assignment to `__proto__` replaces the\n * tree's prototype instead, and a schema key or a record name may be one. */\nexport function setOwnPrefValue(tree: Record<string, unknown>, key: string, value: unknown): void {\n setOwn(tree, key, value);\n}\n\n/** Set `value` at the dotted `path` in `root` itself, creating missing branches and replacing a branch that holds no object. */\nexport function assignPrefValueAt(root: Record<string, unknown>, path: string, value: unknown): void {\n const parts = path.split('.');\n let cursor = root;\n for (const part of parts.slice(0, -1)) {\n const branch = getOwn(cursor, part);\n if (typeof branch !== 'object' || branch === null) setOwnPrefValue(cursor, part, {});\n cursor = getOwn(cursor, part) as Record<string, unknown>;\n }\n setOwnPrefValue(cursor, parts[parts.length - 1]!, value);\n}\n\n/** Values keyed by dotted path, as `PrefsBar` and `BarMenu` take them, as the\n * nested tree `PrefsForm` reads: the inverse of {@link flattenPrefValues}. */\nexport function nestPrefValues(values: Readonly<Record<string, unknown>> | undefined): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n for (const [path, value] of Object.entries(values ?? {})) assignPrefValueAt(tree, path, value);\n return tree;\n}\n\n/** Each of `schema`'s leaves that `tree` holds a value for, as a path and\n * that value — the inverse of building a tree from per-leaf records. */\nexport function flattenPrefValues(schema: PrefGroup, tree: unknown): [string, unknown][] {\n const out: [string, unknown][] = [];\n for (const path of prefLeaves(schema).keys()) {\n const value = prefValueAt(tree, path);\n if (value !== undefined) out.push([path, value]);\n }\n return out;\n}\n\n/** Whether one leaf answers to a filter query, by name, description, path or tag. */\nfunction prefLeafMatches(pref: PrefLeaf, path: string, query: string): boolean {\n return matchQuery(query, { text: [pref.name, pref.description, path], tags: pref.tags }) !== null;\n}\n\n/**\n * Drop every leaf that does not answer to `query`, pruning groups left empty.\n * A group whose own name or tag matches keeps all of its leaves. An empty or\n * whitespace query matches everything.\n *\n * An alias answers as the row it draws: its target's name and description\n * where it gives none. That target is looked for in `over`, and in `node`\n * without it; pass the whole schema when `node` is a part of it.\n */\nexport function filterPrefSubtree<T extends PrefLeaf | PrefGroup>(\n node: T,\n query: string,\n path = '',\n over?: PrefGroup | PrefSection,\n): T | null {\n const q = query.trim().toLowerCase();\n if (q === '') return node;\n const within = over ?? (isPrefLeaf(node) ? undefined : (node as PrefGroup));\n const find = (p: string): PrefLeaf | undefined => within && prefLeafAt(within, p);\n if (isPrefLeaf(node)) {\n const target = node.kind === 'alias' ? prefAliasTarget(node as PrefAlias, find) : undefined;\n const drawn = target ? prefAliasedLeaf(node as PrefAlias, target.leaf) : node;\n return prefLeafMatches(drawn, path, q) ? node : null;\n }\n const group = node as PrefGroup;\n if (matchQuery(q, { text: [group.name], tags: group.tags }) !== null) return node;\n const children: Record<string, PrefLeaf | PrefGroup> = {};\n for (const [key, child] of Object.entries(group.children)) {\n const kept = filterPrefSubtree(child, q, path === '' ? key : `${path}.${key}`, within);\n if (kept) setOwnPrefValue(children, key, kept);\n }\n if (Object.keys(children).length === 0) return null;\n return { ...node, children };\n}\n","// A condition over other leaves' values, held as data so a schema carrying\n// one still exports as a literal and survives a draft.\n\nimport { isPlainObject } from '@weasel-js/registry';\n\n/** What a condition can compare a leaf's value against. `null` stands for\n * nothing held: a missing value as well as a stored `null`. */\nexport type PrefConditionValue = string | number | boolean | null;\n\n/**\n * One leaf's value, tested. `path` is the full path the value is read and\n * written at (`'windows.paging'`), a field of an `object` or `union` leaf\n * included (`'stroke.width'`, `'fill.type'`). With `from: 'item'` the path is\n * read from the entry the test's node is drawn in instead: the entry of the\n * nearest list or map the node is the `item` of, or sits inside the item of.\n * `{ from: 'item', path: 'mode' }` on a field of a list's item reads `mode`\n * of the same entry, and an empty path is the entry itself. With `from: 'group'` the path is\n * read from the group the test's node is declared in, so a group can be mounted anywhere:\n * `{ from: 'group', path: 'on' }` on `view.feature.axis` reads `view.feature.on`. The value compared is the one\n * the leaf's control shows, where an `encoding` stores another. With\n * several operators it holds while all of them do, so\n * `{ path: 'count', atLeast: 1, below: 10 }` is a range.\n *\n * With no operator it holds while the value is set, which by kind is:\n * a `boolean` that is on; a `number` other than 0; a `string`, a `color`, a\n * `field`, or an `enum`'s option that is not the empty string; a `paint`\n * that is not `null`; a `list` with an entry; a `map` with a key; an\n * `object` or a `union` holding a field. Nothing held is never set, and the\n * value of an app-defined kind is set by whichever of those its shape is,\n * else while it is truthy.\n */\nexport interface PrefTest {\n path: string;\n /** Where `path` is read from: the entry the node is drawn in, or the group it is declared in. Unset: the schema\n * root. */\n from?: PrefConditionFrom;\n is?: PrefConditionValue;\n isNot?: PrefConditionValue;\n /** Holds while the value is any of these. */\n in?: readonly PrefConditionValue[];\n /** The ordering operators hold only for a number. */\n above?: number;\n below?: number;\n atLeast?: number;\n atMost?: number;\n}\n\n/** Where a test's path is read from, when not from the schema root. */\nexport type PrefConditionFrom = 'item' | 'group';\n\n/** A condition a schema node holds in `showIf` or `enableIf`. An empty `all`\n * holds and an empty `any` does not. */\nexport type PrefCondition =\n | PrefTest\n | { all: readonly PrefCondition[] }\n | { any: readonly PrefCondition[] }\n | { not: PrefCondition };\n\n/** Reads the value a test compares: at `path` from the schema root, or with `from`, from the entry being drawn. */\nexport type PrefConditionReader = (path: string, from?: PrefConditionFrom) => unknown;\n\n/** The `PrefTest` keys that compare a number by order. */\nexport const ORDERINGS = ['above', 'below', 'atLeast', 'atMost'] as const;\nconst TEST_KEYS: ReadonlySet<string> = new Set(['path', 'from', 'is', 'isNot', 'in', ...ORDERINGS]);\n\nconst isValue = (v: unknown): v is PrefConditionValue =>\n v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';\n\n/** Which shape a condition takes: all of its parts, any of them, the negation of one, or a single test. */\nexport type Form = 'all' | 'any' | 'not' | 'test';\n\n/** Which form `value` is, judged on its own keys and not on what it holds. */\nexport function formOf(value: unknown): Form | undefined {\n if (!isPlainObject(value)) return undefined;\n const keys = Object.keys(value);\n if (keys.length === 1 && (keys[0] === 'all' || keys[0] === 'any')) return Array.isArray(value[keys[0]]) ? keys[0] : undefined;\n if (keys.length === 1 && keys[0] === 'not') return 'not';\n if (typeof value.path !== 'string' || !keys.every((key) => TEST_KEYS.has(key))) return undefined;\n if (value.from !== undefined && value.from !== 'item' && value.from !== 'group') return undefined;\n if (value.is !== undefined && !isValue(value.is)) return undefined;\n if (value.isNot !== undefined && !isValue(value.isNot)) return undefined;\n if (value.in !== undefined && !(Array.isArray(value.in) && value.in.every(isValue))) return undefined;\n return ORDERINGS.every((op) => value[op] === undefined || typeof value[op] === 'number') ? 'test' : undefined;\n}\n\n/** The conditions directly inside a combinator; none for a test. */\nexport function partsOf(condition: unknown, form: Form): readonly unknown[] {\n const held = condition as Record<string, unknown>;\n return form === 'test' ? [] : form === 'not' ? [held.not] : (held[form] as unknown[]);\n}\n\n/** Whether `value` is a well-formed condition, all the way down. */\nexport function isPrefCondition(value: unknown): value is PrefCondition {\n const form = formOf(value);\n return form !== undefined && partsOf(value, form).every(isPrefCondition);\n}\n\nconst same = (held: unknown, value: PrefConditionValue): boolean => (value === null ? held == null : held === value);\n\nfunction isSet(held: unknown): boolean {\n if (Array.isArray(held)) return held.length > 0;\n if (isPlainObject(held)) return Object.keys(held).length > 0;\n return Boolean(held);\n}\n\nfunction testHolds(test: PrefTest, held: unknown): boolean {\n const ops = Object.keys(test).filter((key) => key !== 'path' && key !== 'from' && test[key as keyof PrefTest] !== undefined);\n if (ops.length === 0) return isSet(held);\n if (test.is !== undefined && !same(held, test.is)) return false;\n if (test.isNot !== undefined && same(held, test.isNot)) return false;\n if (test.in !== undefined && !test.in.some((value) => same(held, value))) return false;\n if (!ORDERINGS.some((op) => test[op] !== undefined)) return true;\n if (typeof held !== 'number') return false;\n return (\n (test.above === undefined || held > test.above) &&\n (test.below === undefined || held < test.below) &&\n (test.atLeast === undefined || held >= test.atLeast) &&\n (test.atMost === undefined || held <= test.atMost)\n );\n}\n\n/** Whether `condition` holds, given the value `read` finds at each path it names. */\nexport function prefConditionHolds(condition: PrefCondition, read: PrefConditionReader): boolean {\n if ('all' in condition) return condition.all.every((part) => prefConditionHolds(part, read));\n if ('any' in condition) return condition.any.some((part) => prefConditionHolds(part, read));\n if ('not' in condition) return !prefConditionHolds(condition.not, read);\n if (condition.from === 'group') warnUnresolved(condition.path);\n return testHolds(condition, read(condition.path, condition.from));\n}\n\nconst warned = new Set<string>();\n\n/** A test read from its group reaching a reader means the schema was not put through `resolvePrefGroupConditions`:\n * its path would be read from the root. */\nfunction warnUnresolved(path: string): void {\n if (warned.has(path)) return;\n warned.add(path);\n console.warn(`weasel prefs: a condition reads \"${path}\" from its group, but nothing resolved it to a path from the root; resolve the schema with resolvePrefGroupConditions`);\n}\n\n/** Whether a node is drawn: its `showIf` holds, or it has none. A node\n * answers for itself only; one inside a group that is not shown is not\n * drawn either. */\nexport function prefIsShown(node: { showIf?: PrefCondition }, read: PrefConditionReader): boolean {\n return node.showIf === undefined || prefConditionHolds(node.showIf, read);\n}\n\n/** Whether a node's controls take input: its `enableIf` holds, or it has\n * none. As {@link prefIsShown}, a node answers for itself only. */\nexport function prefIsEnabled(node: { enableIf?: PrefCondition }, read: PrefConditionReader): boolean {\n return node.enableIf === undefined || prefConditionHolds(node.enableIf, read);\n}\n\n/** Every path `condition` reads from the schema root, or with `from`, from the entry or the group, once each, in the order met. */\nexport function prefConditionPaths(condition: PrefCondition, from?: PrefConditionFrom): string[] {\n const out = new Set<string>();\n const walk = (c: PrefCondition): void => {\n if ('all' in c) c.all.forEach(walk);\n else if ('any' in c) c.any.forEach(walk);\n else if ('not' in c) walk(c.not);\n else if (c.from === from) out.add(c.path);\n };\n walk(condition);\n return [...out];\n}\n\n/** Whether any test of `condition` reads from the entry, so that it has no answer until an entry is drawn. */\nexport function prefConditionReadsItem(condition: PrefCondition): boolean {\n if ('all' in condition) return condition.all.some(prefConditionReadsItem);\n if ('any' in condition) return condition.any.some(prefConditionReadsItem);\n if ('not' in condition) return prefConditionReadsItem(condition.not);\n return condition.from === 'item';\n}\n\n/**\n * `condition` with every path it reads put through `move`, for following a\n * key that was renamed or a leaf that moved. `move` is told where a path is\n * read from, and what it hands back is read from there too. A condition none\n * of whose paths change comes back as the object it was given, and so does\n * each part of one.\n */\nexport function mapPrefConditionPaths(condition: PrefCondition, move: (path: string, from?: PrefConditionFrom) => string): PrefCondition {\n const each = (parts: readonly PrefCondition[]): readonly PrefCondition[] => {\n const next = parts.map((part) => mapPrefConditionPaths(part, move));\n return next.every((part, i) => part === parts[i]) ? parts : next;\n };\n if ('all' in condition) {\n const all = each(condition.all);\n return all === condition.all ? condition : { all };\n }\n if ('any' in condition) {\n const any = each(condition.any);\n return any === condition.any ? condition : { any };\n }\n if ('not' in condition) {\n const not = mapPrefConditionPaths(condition.not, move);\n return not === condition.not ? condition : { not };\n }\n const path = move(condition.path, condition.from);\n return path === condition.path ? condition : { ...condition, path };\n}\n\n/**\n * `condition` with every test read from its group read from the schema root instead, `group` being the path of the\n * group its node is declared in (empty at the root). Comes back as the object it was given where no test reads from\n * its group, and so does each part of it.\n */\nexport function prefConditionInGroup(condition: PrefCondition, group: string): PrefCondition {\n const each = (parts: readonly PrefCondition[]): readonly PrefCondition[] => {\n const next = parts.map((part) => prefConditionInGroup(part, group));\n return next.every((part, i) => part === parts[i]) ? parts : next;\n };\n if ('all' in condition) {\n const all = each(condition.all);\n return all === condition.all ? condition : { all };\n }\n if ('any' in condition) {\n const any = each(condition.any);\n return any === condition.any ? condition : { any };\n }\n if ('not' in condition) {\n const not = prefConditionInGroup(condition.not, group);\n return not === condition.not ? condition : { not };\n }\n if (condition.from !== 'group') return condition;\n const { from: _from, ...rest } = condition;\n const path = group === '' ? condition.path : condition.path === '' ? group : `${group}.${condition.path}`;\n return { ...rest, path };\n}\n","// The preferences schema's typed leaves. `groups.ts` holds the branch nodes\n// that arrange them: tools declare their options as a `PrefGroup`, and apps\n// compose those into one registry, which `PrefsForm` renders and `openPrefs`\n// stores.\n\nimport type { IconSpec } from '@weasel-js/icons';\nimport type { PrefAction, PrefActions } from './action';\nimport type { PrefAlias } from './alias';\nimport type { PrefCondition } from './condition';\nimport type { PrefSection } from './groups';\nimport type { PrefLabel, PrefSeparator } from './label';\nimport type { PrefList } from './list';\nimport type { PrefScope } from './scope';\nimport type { PrefMap } from './map';\nimport type { PrefScopeSpec } from './scopeSpec';\nimport type { PrefUnion } from './union';\nimport type { PrefNumber } from './number';\n\nexport type { PrefNumber, PrefNumberBase, PrefNumberControl, PrefNumberScale } from './number';\n\n/** The value types a built-in pref leaf can hold. */\nexport type PrefKind =\n | 'number' | 'boolean' | 'string' | 'enum' | 'color' | 'paint' | 'object' | 'list' | 'map' | 'union' | 'field' | 'action' | 'actions' | 'alias' | 'label' | 'separator';\n\n/** Leaves that share one row in a compact property UI, declared on the first\n * of them. Purely presentational. */\nexport interface PrefPair {\n /** The other leaves on the row, by the full path their values are read and\n * written at (`'pose.y'`, `'camera.type'`), in order. Each must follow the\n * one before it among its siblings. */\n with: string | readonly string[];\n /** What the row reads. Default: the declaring leaf's `name`. */\n label?: string;\n}\n\n/** The fields every leaf pref shares, keyed by its `kind` and typed by its stored value. */\nexport interface PrefBase<K extends string, Value> {\n kind: K;\n /** Human-readable label. */\n name: string;\n /** Longer help text — shown in tooltips / a settings pane. */\n description: string;\n /** Fallback when nothing is persisted. */\n default: Value;\n /** Words the leaf is also found by and gathered under: a settings search\n * matches them as it matches `name`, and `prefLeavesTagged` gathers every\n * leaf carrying one. A leaf also carries the tags of every group above it\n * (`prefLeafTags`). Unrelated to a union leaf's `tag`, which names the\n * field its value's variant is read from. */\n tags?: readonly string[];\n /** The consumer's own data on this leaf, carried and never read by the kit: no search matches it and nothing\n * draws it. Plain data, so a schema that exports keeps it. Unlike `tags`, it is the leaf's own and does not\n * come down from the groups above. */\n meta?: Readonly<Record<string, unknown>>;\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 /** Hide from a host app's settings UI by default. */\n hidden?: boolean;\n /** Drawn only while this holds. Presentational: the value stays stored\n * and readable while the leaf is not drawn. */\n showIf?: PrefCondition;\n /** Drawn, and disabled while this does not hold. */\n enableIf?: PrefCondition;\n /** Why the leaf is disabled, in words, read in its tooltip while it is: what has to change to enable it. */\n disabledReason?: string;\n /** Nothing held where this leaf's value is read means `default`, because\n * whoever reads the value takes it that way (`pose.rotation ?? 0`). A\n * surface over sparse settings reads every leaf so already. One over a\n * scene node, where a missing key otherwise means the node has no such\n * property, shows the default only for a leaf that says this, and still\n * writes nothing until an edit. */\n absentIsDefault?: boolean;\n /** Render full-width with no label row in schema-driven settings UIs\n * (weasel-ui `PrefsForm` honors this for leaves whose control brings\n * its own chrome). */\n block?: boolean;\n /** Draw the control in the heading of the group or section holding the\n * leaf, in place of a row of its own. Only a built-in `boolean` or `enum`\n * fits there (`prefFitsHeading`); any other leaf stays a row. Honored by\n * weasel-ui `PrefsForm` and labkit's `ControlPanel`. A group whose\n * `enableIf` reads this leaf is switched by it: see `PrefGroup.enableIf`. */\n heading?: boolean;\n /** Glyph naming this leaf. A name from `@weasel-js/icons`; this package draws\n * nothing. Read where a leaf's `name` has nowhere to go — a\n * `pair`ed row is labeled by the pair, so its fields have only the glyph\n * to tell them apart. */\n icon?: IconSpec;\n /** Puts this leaf and the ones it names on one row. */\n pair?: PrefPair;\n /** Shorter forms of `name`, longest first. A surface short of room for\n * `name` — a strip of controls on one line, a segment in a `pair`ed row —\n * shows the longest of them that fits. `name` stays the accessible name, so\n * these abbreviate without costing anything. */\n short?: readonly string[];\n /** Opts the leaf into being auto: unpinned, reading what its owner computes (`prefAutoValue`), never its\n * `default`. Unset, the leaf can never be auto. A store and every surface honor it alike. */\n auto?: PrefAuto<Value>;\n /** The name of the type this leaf was made from, set by `namedPrefType`. A\n * schema editor shows such a leaf as one closed thing and prints the name\n * in place of its literal. */\n type?: string;\n /** The selectors this pref's value is kept separately for, one entry each,\n * outermost first ({@link PrefScopeSpec}). Each names an `enum` pref by its full\n * path, which must be plain: not `clearable`, with no `encoding`, and not\n * scoped itself; or a selector the schema's root `admits`. The\n * stored value is a {@link PrefScope} whose shared value holds the next\n * entry in; an option's own value stops there and is not split further.\n * An open entry (no `overrides`) starts as one value, which a reader may\n * split and join again. */\n scopes?: readonly PrefScopeSpec[];\n /** What the leaf holds while nothing is stored for it, where that is a\n * split value: a default that differs by option. Split only by selectors\n * `scopes` names; without it, the default is an empty scope per entry,\n * nested. `default` stays what a value it leaves out reads as, and\n * what the leaf's value type is read from. */\n defaultScope?: PrefScope;\n}\n\n/** How a leaf that opts into auto is auto; `{}` opts in and says neither. */\nexport interface PrefAuto<Value = unknown> {\n /** Starts auto, unpinned, where it would start pinned at `default`; a reset puts it back so. */\n on?: boolean;\n /** What it reads while auto, where its owner computes nothing; on a leaf with `scopes`, a split value as\n * `defaultScope` is one. Unset, `undefined`: never its `default`. */\n value?: Value | PrefScope;\n}\n\n/** The fields every leaf holding a value shares, besides {@link PrefBase}'s. */\nexport interface PrefValueBase<K extends string, Value> extends PrefBase<K, Value> {\n /** Drawn showing its value but not editable. */\n readout?: boolean;\n}\n\n/** How a schema-driven UI should present a boolean pref. */\nexport type PrefBooleanControl = 'checkbox' | 'switch' | 'toggle';\n/** How a schema-driven UI should present a string pref. */\nexport type PrefStringControl = 'input' | 'textarea';\n/** How a schema-driven UI should present an enum pref. */\nexport type PrefEnumControl = 'select' | 'radio' | 'toggle' | 'menu';\n\n/**\n * Stored-value bridge for a boolean leaf whose field is not a boolean — the\n * flag counterpart of {@link PrefEnumEncoding}. `TextStyle.fontStyle` is\n * the case: it stores `'italic'`, and the control is an Italic toggle.\n */\nexport interface PrefBooleanEncoding {\n /** Whether `stored` reads as on. */\n read: (stored: unknown, siblings: Record<string, unknown> | undefined) => boolean;\n /** What to store for `on`. `undefined` removes the field. */\n write: (on: boolean, siblings: Record<string, unknown> | undefined) => unknown;\n}\n\n/** An on/off pref. */\nexport interface PrefBoolean extends PrefValueBase<'boolean', boolean> {\n control?: PrefBooleanControl;\n encoding?: PrefBooleanEncoding;\n}\n/** A free-text pref. */\nexport interface PrefString extends PrefValueBase<'string', string> {\n control?: PrefStringControl;\n /** What an empty field shows in its place: the value something else falls back to, as a file name does. */\n placeholder?: string;\n /** The most characters the field takes, counted as an `<input>`'s `maxLength` counts them. A longer stored\n * value reads cut to this length, or one shorter where that would split a surrogate pair. */\n maxLength?: number;\n}\n/**\n * Stored-value bridge for an enum leaf whose value is not the option string —\n * the counterpart of {@link PrefNumberUnit}, which does the same for a\n * number stored in a canonical unit.\n *\n * A dash array is the case that needs it: `Stroke.dash` stores lengths, and\n * the thing a person chooses is a style. The presets scale by the stroke's\n * width, so both directions are given the object's other fields.\n */\nexport interface PrefEnumEncoding<T extends string = string> {\n /**\n * The option `stored` reads as, or `undefined` for none — which a UI shows\n * the way it shows a mixed selection, by selecting nothing.\n *\n * `siblings` is the object the leaf is a field of, or `undefined` when the\n * node does not hold that object (and for a top-level leaf, which has none).\n */\n read: (stored: unknown, siblings: Record<string, unknown> | undefined) => T | undefined;\n /** What to store for `option`. `undefined` removes the field. */\n write: (option: T, siblings: Record<string, unknown> | undefined) => unknown;\n}\n\n/** One choice of an enum leaf: see {@link PrefEnumBase.options}. */\nexport interface PrefEnumOption<T extends string = string> {\n value: T;\n label: string;\n short?: readonly string[];\n icon?: IconSpec;\n /** Help for the option, read in its tooltip. */\n description?: string;\n disabled?: boolean;\n /** Why it is disabled, read in its tooltip. */\n disabledReason?: string;\n}\n\n/** What every enum leaf carries; {@link PrefEnum} adds `clearable`. */\nexport interface PrefEnumBase<T extends string = string>\n extends PrefValueBase<'enum', T | undefined> {\n /** `short` holds shorter forms of `label`, longest first, for a segmented\n * control too narrow for the full one — down to a capital or two. `icon`\n * names a glyph, drawn in place of any text form where it resolves. A name\n * from `@weasel-js/icons`; this package draws nothing. The full `label` stays the accessible name, so neither the abbreviation nor the glyph becomes the only thing naming\n * the option.\n *\n * `disabled` marks an option a control reports but cannot author — the\n * value a stored form reads as when it matches nothing offered. Dropping it\n * from the list instead would leave the control selecting nothing and\n * claiming the field is unset. `disabledReason` says why, in the option's\n * tooltip, and `description` is that tooltip while it is choosable. */\n options: readonly PrefEnumOption<T>[];\n control?: PrefEnumControl;\n encoding?: PrefEnumEncoding<T>;\n}\n\n/**\n * A pref with a fixed set of labeled choices.\n *\n * `clearable` says the field may hold none of the options, and that absence\n * is a state of its own rather than a missing value — a script that is\n * neither super nor sub. A toggle control then lets the chosen segment be\n * clicked off, which removes the field. Such a leaf's `default` is\n * `undefined`: a missing value is the only stored form of cleared, so a\n * default would bring an option back the moment the field was cleared.\n */\nexport type PrefEnum<T extends string = string> = PrefEnumBase<T> & (\n | { clearable?: false }\n | { clearable: true; default: undefined }\n);\n\n/** A single color, stored as a hex string. For a value that may also be a\n * gradient or a pattern, use {@link PrefPaint} instead. */\nexport interface PrefColor extends PrefValueBase<'color', string> {\n /** Value is `#rrggbb`, or `#rrggbbaa` when `alpha` is set (UIs then\n * offer an opacity control). */\n alpha?: boolean;\n}\n\n/**\n * Open leaf: any node with a `kind` outside the built-ins. Schema-driven\n * UIs dispatch it to an app-supplied renderer. Deliberately NOT\n * index-signatured so concrete app interfaces stay assignable.\n */\nexport type PrefCustom = PrefValueBase<string, unknown>;\n\n/**\n * A whole `Paint`, not a color inside one. Use it wherever the value is\n * the tagged paint union — a solid color, a pattern, a gradient — rather\n * than a hex string.\n *\n * Addressing `…fill.color` instead reads `undefined` off a gradient (so the\n * control shows its default and claims the text is black) and writes a\n * hybrid `{ fill: 'gradient', stops, color }` that the renderer's structural\n * `'color' in paint` checks then paint flat solid. The union has to be\n * edited as a union.\n */\nexport interface PrefPaint extends PrefValueBase<'paint', unknown> {\n /** Offer an opacity control alongside the color. */\n alpha?: boolean;\n}\n\n/**\n * A leaf whose value is one object, with its own fields hanging off it as\n * `children`; every edit commits the parent object whole. Sibling leaves\n * addressing into the value (`data.stroke.width`, `data.stroke.cap`) would\n * each write one field of a value they can only half see, and writing into\n * something that is not an object yet corrupts it.\n *\n * `children` paths are relative to the object. They are ordinary leaves, so a\n * field that is itself a union (a stroke's `paint`) declares the kind that\n * edits that union. A child may also be a {@link PrefSection}, which\n * organizes the fields under a heading without contributing to the path.\n */\nexport interface PrefObject extends PrefValueBase<'object', unknown> {\n children: Record<string, PrefLeaf | PrefSection>;\n /**\n * Lift a non-object value into the object form, for a consumer field that\n * may also be held as a scalar. Called before a child edit is applied;\n * without it a scalar-valued leaf shows its children empty, and an edit\n * starts from the leaf's `default`.\n */\n fromScalar?: (value: unknown) => Record<string, unknown>;\n}\n\n/**\n * A reference to another field of the same schema, held as the full path its\n * value is read and written at (`'camera.type'`) — the currency fields refer\n * to each other in. A surface offers the fields it draws as the choices.\n */\nexport interface PrefField extends PrefValueBase<'field', string> {\n /** Only fields of these kinds may be named. Default: any leaf. */\n kinds?: readonly string[];\n}\n\n/** One built-in pref leaf. `PrefLeaf` widens this to include\n * app-defined kinds. */\nexport type BuiltinPref =\n | PrefNumber\n | PrefBoolean\n | PrefString\n | PrefEnum\n | PrefColor\n | PrefPaint\n | PrefObject\n | PrefList\n | PrefMap\n | PrefUnion\n | PrefField\n | PrefAction\n | PrefActions\n | PrefAlias\n | PrefLabel\n | PrefSeparator;\n\n// Compile-time tie: every built-in leaf kind must appear in PrefKind\n// and vice versa (PrefBase's K is open for PrefCustom's sake, so\n// the union no longer enforces it).\ntype _BuiltinKindsExact = [BuiltinPref['kind']] extends [PrefKind]\n ? [PrefKind] extends [BuiltinPref['kind']] ? true : never\n : never;\nconst _builtinKindsExact: _BuiltinKindsExact = true;\nvoid _builtinKindsExact;\n\n/**\n * The built-in kinds, as a table. A kind added to {@link PrefKind} is a\n * compile error here, and from here it is one in every renderer's `never`\n * guard.\n */\nexport const PREF_KINDS: Record<PrefKind, true> = {\n number: true,\n boolean: true,\n string: true,\n enum: true,\n color: true,\n paint: true,\n object: true,\n list: true,\n map: true,\n union: true,\n field: true,\n action: true,\n actions: true,\n alias: true,\n label: true,\n separator: true,\n};\n\n/** Which row each pairing among `leaves` puts a path on: a `key` the row's\n * members share (the declaring leaf's path) and the `label` it reads. A\n * path no `pair` names is absent. `leaves` are given by the path each\n * surface reads and writes them at, so references resolve in its terms. */\nexport function prefPairRows(\n leaves: Iterable<readonly [path: string, leaf: PrefLeaf]>,\n): Map<string, { key: string; label: string }> {\n const rows = new Map<string, { key: string; label: string }>();\n for (const [path, leaf] of leaves) {\n if (!leaf.pair || rows.has(path)) continue;\n const row = { key: path, label: leaf.pair.label ?? leaf.name };\n rows.set(path, row);\n const partners = typeof leaf.pair.with === 'string' ? [leaf.pair.with] : leaf.pair.with;\n for (const partner of partners) if (!rows.has(partner)) rows.set(partner, row);\n }\n return rows;\n}\n\n/**\n * Narrows a leaf to the built-in union, so a renderer's switch discriminates\n * on {@link PrefKind} instead of the open `string` that\n * {@link PrefCustom} widens `kind` to. An app-defined kind answers false\n * and belongs to the renderer's custom-renderer path.\n */\nexport function isBuiltinPref(leaf: PrefLeaf): leaf is BuiltinPref {\n return Object.hasOwn(PREF_KINDS, leaf.kind);\n}\n\n/** Built-in or app-defined leaf. */\nexport type PrefLeaf = BuiltinPref | PrefCustom;\n","// Which leaf describes the value at a path, looking inside the leaves whose\n// values are made of fields. What reads a condition's paths against a schema\n// asks here.\n\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefSectionLeaves } from './helpers';\nimport { isBuiltinPref, type PrefEnum, type PrefLeaf, type PrefObject } from './schema';\nimport type { PrefUnion } from './union';\n\n/** A value the schema says nothing about: an entry of a list, a field of an app-defined kind. */\nexport const UNSEEN = Symbol('unseen');\n\n/** What describes a union's field under a variant that reaches it only through a value the schema says nothing about. */\nexport const UNSEEN_LEAF: PrefLeaf = { kind: 'unseen', name: '', description: '', default: undefined };\n\n/** A union on the way to a value, and the variant the value is read under. */\nexport interface PrefHeldVariant {\n /** The union leaf's path. */\n at: string;\n tag: string;\n key: string;\n}\n\n/** The leaf describing a value, and the path of the `object` or `union` leaf it is a field of, when it is one. */\nexport interface PrefHeld {\n leaf: PrefLeaf;\n within?: string;\n /** The variants the value is a field of, outermost first: it is described by `leaf` only while each union holds its variant. */\n variants?: readonly PrefHeldVariant[];\n}\n\n/** What a path resolves to among a schema's leaves: the leaves holding it, `UNSEEN` when no leaf's key reaches it, or undefined. */\nexport type PrefLeavesFound = PrefHeld[] | typeof UNSEEN | undefined;\n\nconst under = (at: string, key: string): string => (at === '' ? key : `${at}.${key}`);\n\n/** `at` is the path of the leaf the fields belong to, `undefined` for a section schema's own leaves. */\nfunction amongFields(fields: [key: string, leaf: PrefLeaf][], path: string, at: string | undefined): PrefLeavesFound {\n const exact = fields.find(([key]) => key === path);\n if (exact) return [{ leaf: exact[1], ...(at === undefined ? {} : { within: at }) }];\n const outer = fields.find(([key]) => path.startsWith(`${key}.`));\n return outer && insideLeaf(outer[1], path.slice(outer[0].length + 1), under(at ?? '', outer[0]));\n}\n\nfunction insideLeaf(leaf: PrefLeaf, rest: string, at: string): PrefLeavesFound {\n if (leaf.kind === 'object') return amongFields(prefSectionLeaves((leaf as PrefObject).children), rest, at);\n if (leaf.kind === 'union') {\n const { tag, variants } = leaf as PrefUnion;\n if (rest === tag) {\n const options = Object.keys(variants).map((value) => ({ value, label: variants[value]!.name }));\n return [{ leaf: { kind: 'enum', name: tag, description: '', default: undefined, options } as PrefEnum, within: at }];\n }\n // Variants may each describe the same field differently, so each one's is kept.\n const out: PrefHeld[] = [];\n for (const [key, variant] of Object.entries(variants)) {\n const found = amongFields(prefSectionLeaves(variant.children), rest, at);\n const held = found === UNSEEN ? [{ leaf: UNSEEN_LEAF }] : (found ?? []);\n for (const each of held) out.push({ ...each, variants: [{ at, tag, key }, ...(each.variants ?? [])] });\n }\n if (out.length && out.every((each) => each.leaf === UNSEEN_LEAF)) return UNSEEN;\n return out.length ? out : undefined;\n }\n return !isBuiltinPref(leaf) || leaf.kind === 'list' || leaf.kind === 'map' || leaf.kind === 'paint' ? UNSEEN : undefined;\n}\n\n/**\n * Every leaf describing the value at `path`, looking inside `object` and\n * `union` leaves: one, or one per variant holding the field where it sits in\n * a union.\n */\nexport function prefLeavesHolding(schema: PrefGroup | PrefSection, path: string): PrefLeavesFound {\n if (isPrefSection(schema)) return amongFields(prefSectionLeaves(schema.members), path, undefined);\n const steps = path.split('.');\n let node: PrefLeaf | PrefGroup = schema;\n for (let i = 0; i < steps.length; i++) {\n if (isPrefLeaf(node)) return insideLeaf(node, steps.slice(i).join('.'), steps.slice(0, i).join('.'));\n if (!Object.hasOwn(node.children, steps[i]!)) return undefined;\n node = node.children[steps[i]!]!;\n }\n return isPrefLeaf(node) ? [{ leaf: node }] : undefined;\n}\n\n/** {@link prefLeavesHolding} inside one entry of a list or a map whose `item` this is; the empty path is the entry itself. */\nexport function prefLeavesHoldingIn(item: PrefLeaf, path: string): PrefLeavesFound {\n return path === '' ? [{ leaf: item }] : insideLeaf(item, path, '');\n}\n\n/**\n * The schema that answers for the value at `path`: `schema` where a leaf of\n * it describes that value, else `over`, the schema `schema` is drawn over.\n * So a path both hold is `schema`'s. Every reader of a condition's paths\n * that takes a second schema asks here which one to read.\n */\nexport function prefSchemaHolding(\n schema: PrefGroup | PrefSection, path: string, over?: PrefGroup | PrefSection,\n): PrefGroup | PrefSection {\n return over === undefined || prefLeavesHolding(schema, path) !== undefined ? schema : over;\n}\n","// A value held once per option of an enum leaf: the stored shape, and what\n// reads and rewrites it. Nothing here knows a schema; the store supplies the\n// options, the order, which options keep their own value, and how a value\n// is repaired and blended.\n\nimport { getOwn, isPlainObject, setOwn } from '@weasel-js/registry';\n\n/** The key of a scope's shared value: what every option without a value of its own reads and writes. */\nexport const PREF_ELSE = '$else';\n\n/**\n * A pref's value split by another leaf: one value for each option of the\n * `enum` leaf at `$by`, or of a selector that is no leaf, whose option the app names.\n * A value may itself be a scope, by a second selector. The alternatives are\n * folded by weight when the value is read, and a plain setting of the\n * selector gives one of them all of it.\n */\nexport interface PrefScope {\n /** The full path of the selector whose options key `$in`. */\n $by: string;\n $in: Record<string, unknown>;\n /** The value shared by every option that keeps none of its own. */\n [PREF_ELSE]?: unknown;\n}\n\n/**\n * One override list of a pref's scope: the options of its selector that keep\n * a value of their own, by name, or by name with the value each reads before\n * one is written. A selector given one is closed; every option it leaves out\n * shares the scope's {@link PREF_ELSE} value. A selector given none is open:\n * once split, an option keeps a value of its own once one is written for it.\n */\nexport type PrefOverrides = readonly string[] | Readonly<Record<string, unknown>>;\n\n/** A pref's override list for each selector, where it gives one. */\nexport type PrefOverridesLookup = (selector: string) => PrefOverrides | undefined;\n\nconst named = (overrides: PrefOverrides): overrides is readonly string[] => Array.isArray(overrides);\n\n/** The options an override list names. */\nexport function prefOverrideOptions(overrides: PrefOverrides): readonly string[] {\n return named(overrides) ? overrides : Object.keys(overrides);\n}\n\n/** A value for each selector a read is made under: its path, then the option chosen. */\nexport type PrefSelection = Readonly<Record<string, string>>;\n\n/** A weight for each option of each selector, by the selector's path. An option left out weighs nothing. */\nexport type PrefWeights = Readonly<Record<string, Readonly<Record<string, number>>>>;\n\n/** One alternative of a split value, and its share of the whole. */\nexport interface PrefWeighted {\n value: unknown;\n weight: number;\n}\n\nconst hasRest = (scope: PrefScope): boolean => Object.hasOwn(scope, PREF_ELSE);\nconst restOr = (scope: PrefScope, absent: unknown): unknown => (hasRest(scope) ? scope[PREF_ELSE] : absent);\nconst withRest = (scope: PrefScope, rest: unknown): PrefScope => ({ ...scope, [PREF_ELSE]: rest });\n\n/** Whether `value` is a {@link PrefScope}: an object of `$by` and `$in`, and the shared value if any, and nothing else. */\nexport function isPrefScope(value: unknown): value is PrefScope {\n if (!isPlainObject(value)) return false;\n const keys = Object.keys(value).length - (Object.hasOwn(value, PREF_ELSE) ? 1 : 0);\n return keys === 2 && typeof value.$by === 'string' && isPlainObject(value.$in);\n}\n\n/**\n * `value` with every scope in it that was stored as `{ $by, $of }`, the shape\n * before the values' key was renamed, in the current shape. The same value\n * when it holds none.\n */\nexport function upgradeScope(value: unknown): unknown {\n if (isPrefScope(value)) return mapMembers(value, upgradeScope);\n const old = isPlainObject(value) && Object.keys(value).length === 2 && typeof value.$by === 'string' && isPlainObject(value.$of);\n return old ? mapMembers({ $by: value.$by as string, $in: value.$of as Record<string, unknown> }, upgradeScope) : value;\n}\n\n/** The weights a plain selection amounts to: all of each selector's on the option chosen. */\nexport function selectionWeights(selection: PrefSelection): PrefWeights {\n return Object.fromEntries(Object.entries(selection).map(([path, option]) => [path, { [option]: 1 }]));\n}\n\n/** Whether `option` of the scope's selector is one a closed list leaves out, which shares the shared value. */\nconst shares = (scope: PrefScope, option: string, overridesOf: PrefOverridesLookup | undefined): boolean => {\n const overrides = overridesOf?.(scope.$by);\n return overrides !== undefined && !prefOverrideOptions(overrides).includes(option);\n};\n\n/**\n * What one option of the scope's own selector reads: its own value where it\n * has one and may (an option a closed list leaves out never does); else,\n * for an option a closed list proposes a value for, that; else the shared\n * value. No option named reads the shared value too. Whatever is held\n * nothing for reads as `absent`.\n */\nexport function prefScopeOptionValue(scope: PrefScope, option: string | undefined, absent: unknown, overridesOf?: PrefOverridesLookup): unknown {\n if (option === undefined || shares(scope, option, overridesOf)) return restOr(scope, absent);\n if (Object.hasOwn(scope.$in, option)) return scope.$in[option];\n const overrides = overridesOf?.(scope.$by);\n return overrides && !named(overrides) && Object.hasOwn(overrides, option) ? overrides[option] : restOr(scope, absent);\n}\n\n/**\n * Every alternative of `stored` that weighs something under `weights`, each\n * with its share: the product of the weights on the way down to it. An option\n * the scope holds nothing for reads as `absent`, and a selector `weights`\n * leaves out reads the shared value, or nothing where there is none. Members come in the order `weights`\n * lists each selector's options.\n */\nexport function weighScope(stored: unknown, weights: PrefWeights, absent: unknown, overridesOf?: PrefOverridesLookup): PrefWeighted[] {\n const out: PrefWeighted[] = [];\n const walk = (value: unknown, weight: number): void => {\n if (!isPrefScope(value)) {\n out.push({ value, weight });\n return;\n }\n const given = getOwn(weights, value.$by);\n if (given === undefined) {\n if (hasRest(value)) walk(value[PREF_ELSE], weight);\n return;\n }\n for (const [option, share] of Object.entries(given)) {\n if (share > 0) walk(prefScopeOptionValue(value, option, absent, overridesOf), weight * share);\n }\n };\n walk(stored, 1);\n return out;\n}\n\n/** The one value `selection` names. A selector it leaves out reads the shared value; an option the scope holds nothing for reads as `absent`. */\nexport function prefScopeValue(stored: unknown, selection: PrefSelection, absent: unknown, overridesOf?: PrefOverridesLookup): unknown {\n let value = stored;\n while (isPrefScope(value)) value = prefScopeOptionValue(value, getOwn(selection, value.$by), absent, overridesOf);\n return value;\n}\n\n/** `stored` without the values of options a closed list leaves out, which no read reaches, at any depth. The same value when there are none. */\nexport function dropUnlisted(stored: unknown, overridesOf: PrefOverridesLookup | undefined): unknown {\n if (!overridesOf || !isPrefScope(stored)) return stored;\n const overrides = overridesOf(stored.$by);\n const list = overrides && prefOverrideOptions(overrides);\n const stale = list ? Object.keys(stored.$in).filter((option) => !list.includes(option)) : [];\n const kept = stale.length ? { ...stored, $in: Object.fromEntries(Object.entries(stored.$in).filter(([option]) => list!.includes(option))) } : stored;\n return mapMembers(kept, (inner) => dropUnlisted(inner, overridesOf));\n}\n\n/**\n * `stored` written as `selectors`, the pref's scopes outermost first, declare\n * it, with the value `under` names replaced by `next`. Each scope on the way\n * down is made the declared one first, so nothing reads differently for it:\n * a plain value becomes the shared value of the scope it stands in for, and\n * a value split by any other selector becomes the shared value it reads under\n * `now`, the selection the reader sees. An option's own value is plain, and\n * a write replaces it whole, unless it is split already by the next selector\n * in, as a nested default holds it: then the write goes on into that.\n */\nexport function writeDeclared(\n stored: unknown, selectors: readonly string[], under: PrefSelection, now: PrefSelection, next: unknown, absent: unknown,\n overridesOf?: PrefOverridesLookup, held = true,\n): unknown {\n const [by, ...inner] = selectors;\n if (by === undefined) return next;\n let scope: PrefScope;\n if (isPrefScope(stored) && stored.$by === by) scope = stored;\n else {\n const shared = isPrefScope(stored) ? prefScopeValue(stored, now, absent, overridesOf) : stored;\n scope = held ? { $by: by, $in: {}, [PREF_ELSE]: shared } : { $by: by, $in: {} };\n }\n const option = getOwn(under, by);\n if (option === undefined || shares(scope, option, overridesOf)) {\n return withRest(scope, writeDeclared(scope[PREF_ELSE], inner, under, now, next, absent, overridesOf, hasRest(scope)));\n }\n const own = getOwn(scope.$in, option);\n const kept = isPrefScope(own) && own.$by === inner[0] ? writeDeclared(own, inner, under, now, next, absent, overridesOf) : next;\n return { ...scope, $in: { ...scope.$in, [option]: kept } };\n}\n\nfunction mapMembers(scope: PrefScope, fn: (member: unknown) => unknown): PrefScope {\n let out: Record<string, unknown> | undefined;\n for (const [option, value] of Object.entries(scope.$in)) {\n const next = fn(value);\n if (next !== value) setOwn((out ??= { ...scope.$in }), option, next);\n }\n const mapped = out ? { ...scope, $in: out } : scope;\n if (!hasRest(scope)) return mapped;\n const rest = fn(scope[PREF_ELSE]);\n return rest === scope[PREF_ELSE] ? mapped : withRest(mapped, rest);\n}\n\n/** `stored` with each alternative mapped, at any depth. The same value when no value changed. */\nexport function mapScopeValues(stored: unknown, fn: (value: unknown) => unknown): unknown {\n return isPrefScope(stored) ? mapMembers(stored, (inner) => mapScopeValues(inner, fn)) : fn(stored);\n}\n\n/** The path of every selector `stored` is split by, outermost first. */\nexport function prefStoredSelectors(stored: unknown): Set<string> {\n const out = new Set<string>();\n const walk = (value: unknown): void => {\n if (!isPrefScope(value)) return;\n out.add(value.$by);\n for (const inner of Object.values(value.$in)) walk(inner);\n if (hasRest(value)) walk(value[PREF_ELSE]);\n };\n walk(stored);\n return out;\n}\n\n/**\n * What a stored scope reads as: each value repaired, and left out a key that\n * is none of its selector's options or one a closed list leaves out.\n * `optionsOf` gives a selector's options, `null` for a selector that is no leaf, whose\n * keys are all kept. `undefined` when it is split by a selector not in\n * `allowed`, by one `optionsOf` has no options for, or by the same one twice\n * on the way to a value.\n */\nexport function repairScope(\n stored: unknown,\n allowed: readonly string[],\n optionsOf: (path: string) => readonly string[] | null | undefined,\n repairMember: (value: unknown) => unknown,\n overridesOf?: PrefOverridesLookup,\n): unknown {\n const BAD = Symbol('bad');\n const walk = (value: unknown, met: readonly string[]): unknown => {\n if (!isPrefScope(value)) return repairMember(value);\n const options = allowed.includes(value.$by) && !met.includes(value.$by) ? optionsOf(value.$by) : undefined;\n if (options === undefined) return BAD;\n const inner = [...met, value.$by];\n const kept: [string, unknown][] = [];\n for (const option of options ?? Object.keys(value.$in)) {\n if (!Object.hasOwn(value.$in, option) || shares(value, option, overridesOf)) continue;\n const read = walk(value.$in[option], inner);\n if (read === BAD) return BAD;\n kept.push([option, read]);\n }\n const out: PrefScope = { $by: value.$by, $in: Object.fromEntries(kept) };\n if (!hasRest(value)) return out;\n const rest = walk(value[PREF_ELSE], inner);\n return rest === BAD ? BAD : withRest(out, rest);\n };\n const read = walk(stored, []);\n return read === BAD ? undefined : read;\n}\n","// A pref's `scopes`: the selectors its value is kept separately for, read\n// into what the scope functions take.\n\nimport { createPart } from '@weasel-js/registry';\nimport { PREF_ELSE, type PrefOverridesLookup, type PrefOverrides, type PrefScope } from './scope';\nimport type { PrefLeaf } from './schema';\n\n/**\n * One selector a pref's value is kept separately for, as `.per(selector,\n * overrides?)` declares it. `selector` is the full path of an `enum` pref,\n * or of a selector the schema's root `admits`, whose option the app names as\n * it reads and writes (`at`).\n *\n * With `overrides` the selector is closed, and without, open: see\n * {@link PrefOverrides}. Scopes are the declaration's to say: a reader never\n * splits or joins a pref.\n */\nexport interface PrefScopeSpec {\n selector: string;\n overrides?: PrefOverrides;\n}\n\n/** The selectors a pref's value is kept separately for, outermost first. */\nexport function prefScopesOf(pref: PrefLeaf): readonly PrefScopeSpec[] {\n return pref.scopes ?? [];\n}\n\n/** The override list a pref gives the selector at `selector`, where it is closed. */\nexport function prefOverridesOf(pref: PrefLeaf, selector: string): PrefOverrides | undefined {\n return pref.scopes?.find((scope) => scope.selector === selector)?.overrides;\n}\n\n/** The paths of a pref's selectors, outermost first, where it has any. */\nexport function declaredSelectorsOf(pref: PrefLeaf): readonly string[] | undefined {\n return pref.scopes?.length ? pref.scopes.map((scope) => scope.selector) : undefined;\n}\n\n/** {@link prefOverridesOf} for one pref, as the scope functions take it: none where no selector is closed. */\nexport const prefOverridesLookup = createPart((pref: PrefLeaf): PrefOverridesLookup | undefined =>\n pref.scopes?.some((scope) => scope.overrides !== undefined) ? (selector) => prefOverridesOf(pref, selector) : undefined,\n);\n\nconst withElse = (by: string, shared: PrefScope): PrefScope => ({ $by: by, $in: {}, [PREF_ELSE]: shared });\n\n/**\n * What a pref holds while nothing is stored for it: its `defaultScope`, or\n * else one scope per selector, outermost first, each holding no value of its\n * own and the next one in as its shared value, the last with none so it\n * reads `default`.\n */\nexport function prefScopedDefault(pref: PrefLeaf): PrefScope | undefined {\n if (!pref.scopes?.length) return undefined;\n if (pref.defaultScope !== undefined) return pref.defaultScope;\n let inner: PrefScope | undefined;\n for (const scope of [...pref.scopes].reverse()) inner = inner === undefined ? { $by: scope.selector, $in: {} } : withElse(scope.selector, inner);\n return inner;\n}\n\n"]}
|