@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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/condition.ts","../src/schema.ts","../src/holding.ts","../src/conditionCheck.ts","../src/kitCss.ts","../src/migrate.ts","../src/storeWrites.ts","../src/store.ts","../src/open.ts"],"names":["under"],"mappings":";;;;AAuDO,IAAM,SAAA,GAAY,CAAC,OAAA,EAAS,OAAA,EAAS,WAAW,QAAQ,CAAA;AAC/D,IAAM,SAAA,mBAAiC,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,GAAG,SAAS,CAAC,CAAA;AAElG,IAAM,OAAA,GAAU,CAAC,CAAA,KACf,CAAA,KAAM,IAAA,IAAQ,OAAO,CAAA,KAAM,QAAA,IAAY,OAAO,CAAA,KAAM,QAAA,IAAY,OAAO,CAAA,KAAM,SAAA;AAKxE,SAAS,OAAO,KAAA,EAAkC;AACvD,EAAA,IAAI,CAAC,aAAA,CAAc,KAAK,CAAA,EAAG,OAAO,MAAA;AAClC,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AAC9B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,KAAM,IAAA,CAAK,CAAC,CAAA,KAAM,KAAA,IAAS,IAAA,CAAK,CAAC,CAAA,KAAM,KAAA,CAAA,SAAe,KAAA,CAAM,OAAA,CAAQ,MAAM,IAAA,CAAK,CAAC,CAAC,CAAC,CAAA,GAAI,IAAA,CAAK,CAAC,CAAA,GAAI,MAAA;AACpH,EAAA,IAAI,KAAK,MAAA,KAAW,CAAA,IAAK,KAAK,CAAC,CAAA,KAAM,OAAO,OAAO,KAAA;AACnD,EAAA,IAAI,OAAO,KAAA,CAAM,IAAA,KAAS,QAAA,IAAY,CAAC,IAAA,CAAK,KAAA,CAAM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Q,CAAA;AACpF,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,EAAO,OAAO,CAAA;AACjC,EAAA,IAAI,kBAAA,CAAmB,OAAO,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAA,EAAG,MAAM,KAAA,CAAM,KAAA,EAAM;AAC3E,EAAA,OAAO,gBAAA,CAAiB,MAAA,EAAQ,KAAA,EAAO,OAAA,CAAQ,UAAA,EAAY,IAAA,EAAM,OAAA,CAAQ,UAAA,EAAY,MAAA,IAAU,CAAA,EAAG,OAAA,CAAQ,MAAM,CAAA;AAClH;AAIO,SAAS,aAAA,CACd,QACA,OAAA,EACe;AACf,EAAA,MAAM,EAAE,KAAA,EAAO,IAAA,EAAK,GAAI,mBAAmB,OAAO,CAAA;AAClD,EAAA,OAAO,gBAAA,CAAiB,MAAA,EAAQ,KAAA,EAAO,OAAA,CAAQ,UAAA,EAAY,IAAA,EAAM,OAAA,CAAQ,UAAA,EAAY,MAAA,IAAU,CAAA,EAAG,OAAA,CAAQ,MAAM,CAAA;AAClH;AAIO,SAAS,mBACd,OAAA,EAC+C;AAC/C,EAAA,MAAM,KAAA,GAAQ,gBAAgB,EAAE,OAAA,EAAS,QAAQ,OAAA,EAAS,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAQ,CAAA;AAClF,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,EAAO,OAAO,CAAA;AACjC,EAAA,IAAI,kBAAA,CAAmB,OAAO,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAA,EAAG,KAAK,KAAA,CAAM,KAAA,EAAM;AAC1E,EAAA,OAAO,EAAE,OAAO,IAAA,EAAK;AACvB;AAKA,IAAM,KAAA,GAAQ,CAAC,KAAA,EAAyB,OAAA,KACtC,kBAAkB,KAAA,EAAO,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAA","file":"chunk-WN6QQICK.js","sourcesContent":["// 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. 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. Unset: the schema root. */\n from?: 'item';\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/** 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?: 'item') => unknown;\n\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\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') 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 return testHolds(condition, read(condition.path, condition.from));\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, once each, in the order met. */\nexport function prefConditionPaths(condition: PrefCondition, from?: 'item'): 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?: 'item') => 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","// 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 { IconRef } from '@weasel-js/icons';\nimport type { PrefAction, PrefActions } from './action';\nimport type { PrefAlias } from './alias';\nimport type { PrefBoundAt } from './bounds';\nimport type { PrefCondition } from './condition';\nimport type { PrefSection } from './groups';\nimport type { PrefLabel, PrefSeparator } from './label';\nimport type { PrefList } from './list';\nimport type { PrefLocus } from './locus';\nimport type { PrefMap } from './map';\nimport type { PrefUnion } from './union';\nimport type { PrefNumberUnit } from './unit';\nimport type { Display, InfinityText } from '@weasel-js/quantity';\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 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 /** 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`. */\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?: IconRef;\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 /** Never auto. A surface that lets a leaf be left for its owner to decide\n * (weasel-ui `PrefsForm`'s `onAutoChange`, labkit's `ControlPanel`) gives\n * this one no way to. */\n manual?: boolean;\n /** Starts auto, where it would start pinned at `default`. */\n unpinned?: boolean;\n /** What the leaf reads while it is auto, where its owner computes nothing\n * for it. Unset, an auto leaf has no value. */\n autoValue?: Value;\n /** The name of the type this leaf was made from, set by `prefType`. 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 `enum` leaves this one's value may be split by, each by the full\n * path its value is read at: the value may then be held once per option\n * of any of them (a {@link PrefLocus}), which the store folds into the one\n * value read. Whether it is split is the stored value's to say. The\n * order is the order a value split by several is stored in, the first\n * outermost. Each must be a plain `enum`: not `clearable`, with no\n * `encoding`, and not split itself. */\n splitBy?: readonly string[];\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 entries of\n * `splitBy`. `default` stays what a member it leaves out reads as, and\n * what the leaf's value type is read from. */\n defaultLocus?: PrefLocus;\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 number pref. */\nexport type PrefNumberControl = 'input' | 'slider';\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/** What every number leaf carries; {@link PrefNumber} adds `clearable`. */\nexport interface PrefNumberBase extends PrefValueBase<'number', number | undefined> {\n min?: number;\n max?: number;\n /** A lower bound read from where the value is held — a scene node's own\n * minimum — taken with `min`, the larger winning. A surface resolves it\n * per holder with `prefNumberAt`. */\n minAt?: PrefBoundAt;\n /** The upper counterpart of `minAt`, taken with `max`, the smaller winning. */\n maxAt?: PrefBoundAt;\n step?: number;\n control?: PrefNumberControl;\n /** How the value shows, speaks and reads back when typed — `compact()`\n * reads `2.00M`. Presentation only: the stored value stays a number. */\n display?: Display;\n unit?: PrefNumberUnit;\n /** Which end of a slider gets a stop for ±Infinity, one step beyond the range. */\n endless?: 'min' | 'max' | 'both';\n /** The word infinity shows as — `'never'`, `'uncapped'`. Default `∞`. */\n infinity?: InfinityText;\n}\n\n/**\n * A numeric pref, optionally bounded and stepped, and optionally stored in a\n * different unit from the one shown.\n *\n * `clearable` says the field may hold no number, which a person sets by\n * emptying it: the value is then `undefined`, which the owner reads as unset,\n * and its default may be too.\n */\nexport type PrefNumber = PrefNumberBase & ({ clearable?: false; default: number } | { clearable: true });\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}\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/** 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. */\n options: readonly {\n value: T;\n label: string;\n short?: readonly string[];\n icon?: IconRef;\n disabled?: boolean;\n }[];\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 pairRowsOf(\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/** 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}\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): PrefHeld | typeof UNSEEN | undefined {\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): PrefHeld | typeof UNSEEN | undefined {\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 for (const variant of Object.values(variants)) {\n const found = amongFields(prefSectionLeaves(variant.children), rest, at);\n if (found !== undefined) return found;\n }\n return undefined;\n }\n return !isBuiltinPref(leaf) || leaf.kind === 'list' || leaf.kind === 'map' || leaf.kind === 'paint' ? UNSEEN : undefined;\n}\n\n/** The leaf describing the value at `path`, looking inside `object` and `union` leaves. */\nexport function prefLeafHolding(schema: PrefGroup | PrefSection, path: string): PrefHeld | typeof UNSEEN | undefined {\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/**\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 || prefLeafHolding(schema, path) !== undefined ? schema : over;\n}\n\n/**\n * The leaf describing the value at `path` inside one entry of a list or a\n * map whose `item` this is; the empty path is the entry itself. `within` is\n * a path inside the entry too, empty for the entry.\n */\nexport function prefLeafHoldingIn(item: PrefLeaf, path: string): PrefHeld | typeof UNSEEN | undefined {\n return path === '' ? { leaf: item } : insideLeaf(item, path, '');\n}\n","// What is wrong with a condition as one of a schema's: what a store warns of\n// and a schema editor marks.\n\nimport { formOf, ORDERINGS, partsOf, type PrefConditionValue, type PrefTest } from './condition';\nimport type { PrefGroup, PrefSection } from './groups';\nimport { isPrefLeaf, isPrefSection, prefHoldsValue } from './helpers';\nimport { prefLeafHolding, prefLeafHoldingIn, prefSchemaHolding, UNSEEN } from './holding';\nimport type { PrefList } from './list';\nimport type { PrefMap } from './map';\nimport { isBuiltinPref, type PrefEnum, type PrefLeaf, type PrefObject } from './schema';\nimport type { PrefUnion } from './union';\n\n/** One thing wrong with a condition: it is not one, it reads a path no leaf\n * holds a value at, it compares a leaf against a value it never holds — an\n * enum against a string none of its options is being `option`, which a\n * surface may take as a test that never matches — it\n * never holds whatever the leaf does, as an `in` of no values, it is the\n * `showIf` of a list's or a map's item, which is drawn with each entry, or\n * it reads from the entry on a node that no list or map draws. */\nexport interface PrefConditionProblem {\n code: 'malformed' | 'no-leaf' | 'no-value' | 'value' | 'option' | 'never' | 'item-show' | 'no-item';\n /** The path read, where the problem is with one. */\n path?: string;\n problem: string;\n}\n\n/** A {@link PrefConditionProblem} and the node whose condition has it. */\nexport interface PrefSchemaConditionProblem extends PrefConditionProblem {\n /**\n * Where the node sits: a key per step from the root, `''` for the root\n * itself. An object leaf's fields and sections, a union's variants, and a\n * list's or a map's `item` are steps too, so this is not always a path a\n * value is read at.\n */\n at: string;\n field: 'showIf' | 'enableIf';\n}\n\n/** Where the node holding a condition sits, for what a condition alone does not say. */\nexport interface PrefConditionSite {\n /** The nearest list or map the node is inside an entry of: the one it is the `item` of, or one above it. */\n within?: PrefList | PrefMap;\n /** The condition is the `showIf` of that list's or map's `item` itself. */\n itemShowIf?: boolean;\n}\n\nconst show = (value: unknown): string => (typeof value === 'string' ? `'${value}'` : String(value));\n\n/** Why `leaf` never holds `value`; `undefined` when it may. */\nfunction neverHolds(leaf: PrefLeaf, value: PrefConditionValue): string | undefined {\n if (value === null || !isBuiltinPref(leaf)) return undefined;\n switch (leaf.kind) {\n case 'number':\n return typeof value === 'number' ? undefined : 'it is a number';\n case 'boolean':\n return typeof value === 'boolean' ? undefined : 'it is a boolean';\n case 'string':\n case 'color':\n case 'field':\n return typeof value === 'string' ? undefined : `it is a ${leaf.kind === 'string' ? 'string' : `${leaf.kind}, held as a string`}`;\n case 'enum': {\n const { options } = leaf as PrefEnum;\n if (options.some((option) => option.value === value)) return undefined;\n return `its options are ${options.map((option) => show(option.value)).join(', ')}`;\n }\n case 'object':\n return (leaf as PrefObject).fromScalar ? undefined : 'it is an object';\n default:\n return `it is a ${leaf.kind}`;\n }\n}\n\ntype Schema = PrefGroup | PrefSection;\n\nfunction testProblems(test: PrefTest, schema: Schema, site: PrefConditionSite, over: Schema | undefined): PrefConditionProblem[] {\n const { path } = test;\n if (test.from === 'item' && site.within === undefined) {\n return [{ code: 'no-item', path, problem: `\"${path}\" is read from an entry, and this is inside no list or map` }];\n }\n const found = leafProblems(test, schema, site, over);\n if (test.in?.length !== 0) return found;\n return [...found, { code: 'never', path, problem: `\"${path}\" is one of nothing, which never holds` }];\n}\n\nfunction leafProblems(test: PrefTest, schema: Schema, site: PrefConditionSite, over: Schema | undefined): PrefConditionProblem[] {\n const { path } = test;\n const inEntry = test.from === 'item';\n const held = inEntry ? prefLeafHoldingIn(site.within!.item, path) : prefLeafHolding(prefSchemaHolding(schema, path, over), path);\n if (held === undefined) return [{ code: 'no-leaf', path, problem: `no leaf holds a value at \"${path}\"${inEntry ? ' in the entry' : ''}` }];\n if (held === UNSEEN) return [];\n const { leaf } = held;\n const named = inEntry ? (path === '' ? 'the entry' : `the entry's \"${path}\"`) : `\"${path}\"`;\n if (!prefHoldsValue(leaf)) return [{ code: 'no-value', path, problem: `${named} is a${leaf.kind === 'separator' || leaf.kind === 'label' ? '' : 'n'} ${leaf.kind === 'actions' ? 'actions leaf' : leaf.kind}, which holds no value` }];\n const out: PrefConditionProblem[] = [];\n const compared = [test.is, test.isNot, ...(test.in ?? [])].filter((value) => value !== undefined);\n for (const value of compared) {\n const why = neverHolds(leaf, value);\n if (why === undefined) continue;\n const code = leaf.kind === 'enum' && typeof value === 'string' ? 'option' : 'value';\n out.push({ code, path, problem: `${named} never holds ${show(value)}: ${why}` });\n }\n const ordering = ORDERINGS.find((op) => test[op] !== undefined);\n if (ordering !== undefined && isBuiltinPref(leaf) && leaf.kind !== 'number') {\n out.push({ code: 'value', path, problem: `${named} is a${leaf.kind === 'object' || leaf.kind === 'enum' ? 'n' : ''} ${leaf.kind}, and \"${ordering}\" compares numbers` });\n }\n return out;\n}\n\n/**\n * What is wrong with `condition` as one of `schema`'s: every part of it that\n * is not a condition, every path it reads that no leaf holds a value at,\n * every comparison against a value the leaf's kind or options rule out, and\n * every `in` of no values.\n * `null` is never ruled out, and neither is anything under an app-defined\n * kind or inside a list, a map, or a paint, which the schema does not\n * describe. Takes `unknown`, since a schema read from JSON or built without\n * types may hold anything where a condition goes. `site` says where the\n * condition's node sits; without it the node is taken to be outside every\n * list and map. A path read from the entry is held to the `item` of\n * `site.within`, and is a problem where there is none. `over` is the schema\n * `schema` is drawn over: a path no leaf of `schema` holds is held to it,\n * and is a problem only where it holds none either.\n */\nexport function checkPrefCondition(\n condition: unknown,\n schema: PrefGroup | PrefSection,\n site: PrefConditionSite = {},\n over?: PrefGroup | PrefSection,\n): PrefConditionProblem[] {\n if (site.itemShowIf && site.within) {\n const { kind } = site.within;\n const problem = `a ${kind}'s item is drawn with each entry and is never hidden: put the condition on the entry's fields, or on the ${kind}`;\n return [{ code: 'item-show', problem }, ...checkPrefCondition(condition, schema, { within: site.within }, over)];\n }\n const form = formOf(condition);\n if (form === undefined) {\n const shown = typeof condition === 'function' ? 'a function' : JSON.stringify(condition);\n return [{ code: 'malformed', problem: `not a condition: ${shown}` }];\n }\n if (form === 'test') return testProblems(condition as PrefTest, schema, site, over);\n return partsOf(condition, form).flatMap((part) => checkPrefCondition(part, schema, site, over));\n}\n\ntype Conditioned = { showIf?: unknown; enableIf?: unknown };\n\n/** {@link checkPrefCondition} over every `showIf` and `enableIf` in `schema`, in schema order, each held to `over` as well. */\nexport function checkPrefConditions(\n schema: PrefGroup | PrefSection,\n over?: PrefGroup | PrefSection,\n): PrefSchemaConditionProblem[] {\n const out: PrefSchemaConditionProblem[] = [];\n const own = (node: Conditioned, at: string, within: PrefList | PrefMap | undefined, isItem = false): void => {\n for (const field of ['showIf', 'enableIf'] as const) {\n if (node[field] === undefined) continue;\n const site = { ...(within ? { within } : {}), ...(isItem && field === 'showIf' ? { itemShowIf: true } : {}) };\n for (const problem of checkPrefCondition(node[field], schema, site, over)) out.push({ ...problem, at, field });\n }\n };\n const under = (at: string, key: string): string => (at === '' ? key : `${at}.${key}`);\n const leaf = (node: PrefLeaf, at: string, within: PrefList | PrefMap | undefined, isItem = false): void => {\n own(node, at, within, isItem);\n if (node.kind === 'object') members((node as PrefObject).children, at, true, within);\n else if (node.kind === 'list' || node.kind === 'map') {\n const holder = node as PrefList | PrefMap;\n // A leaf an app's renderer draws under a built-in's kind may hold no item.\n if (holder.item !== undefined) leaf(holder.item, under(at, 'item'), holder, true);\n } else if (node.kind === 'union') {\n for (const [key, variant] of Object.entries((node as PrefUnion).variants)) leaf(variant, under(at, key), within);\n }\n };\n /** `nested`: inside an object leaf, where a key is relative to it; a section schema's own keys are whole. */\n const members = (held: PrefSection['members'], at: string, nested: boolean, within: PrefList | PrefMap | undefined): void => {\n for (const [key, child] of Object.entries(held)) {\n const here = nested ? under(at, key) : key;\n if (isPrefLeaf(child)) leaf(child, here, within);\n else {\n own(child, here, within);\n members(child.members, nested ? at : '', nested, within);\n }\n }\n };\n const group = (node: PrefGroup, at: string): void => {\n own(node, at, undefined);\n for (const [key, child] of Object.entries(node.children)) {\n if (isPrefLeaf(child)) leaf(child, under(at, key), undefined);\n else group(child, under(at, key));\n }\n };\n if (isPrefSection(schema)) {\n own(schema, '', undefined);\n members(schema.members, '', false, undefined);\n } else group(schema, '');\n return out;\n}\n","import { kebab, type PrefsCssOptions } from './css';\n\n/**\n * `prefsCss` names for the kit's own settings: `tree.typeaheadMs` writes as\n * `--wzl-kit-tree-typeahead-ms`, clear of theme tokens. With `at`, only the\n * leaves under it are written, each named from below it; a selector outside\n * `at` keeps its whole path in its attribute name.\n */\nexport function kitSettingsCssOptions(at?: string): PrefsCssOptions {\n const under = (path: string): string | null => {\n if (at === undefined || at === '') return path;\n return path.startsWith(`${at}.`) ? path.slice(at.length + 1) : null;\n };\n return {\n property: (path) => {\n const rest = under(path);\n return rest === null ? null : `--wzl-kit-${kebab(rest)}`;\n },\n attribute: (selector) => `data-wzl-kit-${kebab(under(selector) ?? selector)}`,\n };\n}\n","import type { OwnedRecordCache } from '@weasel-js/storage';\nimport { VERSION_RECORD } from './helpers';\nimport { readRecord, stampRecord } from './stamp';\n\nconst isVersion = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 0;\n\n/** Takes stored values from one version to the next: rename, transform or\n * delete entries in `records`, keyed by leaf path. It sees the values, not\n * the stamps they are stored under, and only those at its own version. */\nexport type PrefsMigration = (records: Map<string, unknown>) => void;\n\n/**\n * Bring `cache` up to `migrations.length`, the current version. Each record\n * is migrated from the version it is stamped with, so one already in this\n * build's shape is left alone and one an older writer left is caught up,\n * whatever the store's version record says. A migration is handed the\n * records that are at its version; every one it leaves is written back\n * stamped with the version reached, so it may replace values or mutate them\n * in place. Stops writing, and writes nothing, when the store or a record is\n * newer than this build knows or a migration throws. Returns whether it wrote.\n *\n * `stampAll` also stamps the records that needed no migration and carry no\n * stamp. An open does that; a watcher does not, since an unstamped record\n * arriving from another writer may be in a version it has yet to announce.\n */\nexport function runPrefsMigrations(\n cache: OwnedRecordCache,\n migrations: readonly PrefsMigration[],\n { stampAll = true }: { stampAll?: boolean } = {},\n): boolean {\n const target = migrations.length;\n const raw = cache.get(VERSION_RECORD);\n if (cache.has(VERSION_RECORD) && !isVersion(raw)) {\n console.warn(\n `[prefs] \"${cache.prefix}\" has an unreadable ${VERSION_RECORD} (${JSON.stringify(raw)}); opening read-only`,\n );\n cache.stopWriting();\n return false;\n }\n const stored = cache.has(VERSION_RECORD) ? (raw as number) : 0;\n const held = cache\n .entries()\n .filter(([name]) => name !== VERSION_RECORD)\n .map(([name, record]) => ({ name, ...readRecord(record, Math.min(stored, target)) }));\n const newest = Math.max(stored, ...held.map((r) => r.at));\n if (newest > target) {\n console.warn(\n `[prefs] \"${cache.prefix}\" was written at version ${newest}, newer than this build's ${target}; opening read-only`,\n );\n cache.stopWriting();\n return false;\n }\n if (!cache.writable) return false;\n\n // Where each record now stands, and the records that are behind.\n const at = new Map(held.filter((r) => r.at < target).map((r) => [r.name, r.at]));\n const records = new Map(held.filter((r) => at.has(r.name)).map((r): [string, unknown] => [r.name, structuredClone(r.value)]));\n for (let v = Math.min(target, ...at.values()); v < target; v++) {\n const due = new Map([...records].filter(([name]) => at.get(name)! <= v));\n const before = [...due.keys()];\n try {\n migrations[v]!(due);\n } catch (error) {\n console.warn(\n `[prefs] migration ${v} → ${v + 1} for \"${cache.prefix}\" threw; opening read-only on the unmigrated records`,\n error,\n );\n cache.stopWriting();\n return false;\n }\n for (const name of before) if (!due.has(name)) records.delete(name);\n for (const [name, value] of due) {\n records.set(name, value);\n at.set(name, v + 1);\n }\n }\n let wrote = false;\n for (const r of held) {\n if (at.has(r.name)) {\n if (!records.has(r.name)) cache.delete(r.name);\n wrote = true;\n } else if (stampAll && !r.stamped) {\n cache.set(r.name, stampRecord(r.value, target));\n wrote = true;\n }\n }\n for (const [name, value] of records) {\n if (value === undefined) cache.delete(name);\n else cache.set(name, stampRecord(value, target));\n }\n if (stored !== target) {\n cache.set(VERSION_RECORD, target);\n wrote = true;\n }\n return wrote;\n}\n\n/**\n * Keep `cache` at this build's version while other writers change it. A\n * version past `migrations.length`, from a newer build in another tab, stops\n * persisting: this build would otherwise keep writing the old shape. A record\n * another writer leaves is migrated from the version it is stamped with, as\n * soon as it arrives; one with no stamp, from a build that wrote none, from\n * the version record that writer leaves with it. A version record another\n * writer deleted, a cleared store, is written back. Returns the unsubscribe.\n */\nexport function watchPrefsVersion(\n cache: OwnedRecordCache,\n migrations: readonly PrefsMigration[],\n): () => void {\n const target = migrations.length;\n // Once this cache has held a version, the records it holds are this\n // build's shape, and a missing version record is a cleared store.\n let versioned = cache.has(VERSION_RECORD);\n let stopped = false;\n const migrate = (): void => {\n const cleared = versioned && !cache.has(VERSION_RECORD);\n if (cleared) cache.set(VERSION_RECORD, target);\n else if (!runPrefsMigrations(cache, migrations, { stampAll: false })) return;\n versioned = true;\n void cache.flush();\n };\n // A late first read that finds nothing reports no change to migrate on.\n void cache.whenRead().then(() => {\n if (!stopped && cache.writable) migrate();\n });\n const heard = (version: unknown): void => {\n if (!isVersion(version)) {\n console.warn(\n `[prefs] \"${cache.prefix}\" has an unreadable ${VERSION_RECORD} (${JSON.stringify(version)}) from another writer; no longer persisting`,\n );\n cache.stopWriting();\n } else if (version > target) {\n console.warn(\n `[prefs] \"${cache.prefix}\" was migrated to version ${version} by another writer; this build knows ${target}; no longer persisting`,\n );\n cache.stopWriting();\n }\n };\n // A newer version counts even where this cache kept its own write over it.\n const stopOverruled = cache.onOverruled((changes) => {\n for (const [name, value] of changes) if (name === VERSION_RECORD && value !== undefined) heard(value);\n });\n const stopChanges = cache.subscribe((changes) => {\n const remote = changes.filter((change) => change.origin === 'remote');\n for (const change of remote) {\n if (change.name === VERSION_RECORD && change.value !== undefined) heard(change.value);\n }\n if (remote.length > 0 && cache.writable) migrate();\n versioned ||= cache.has(VERSION_RECORD);\n });\n return () => {\n stopped = true;\n stopOverruled();\n stopChanges();\n };\n}\n","// What a store writes: a value encoded for storage, into the member the\n// selectors name where the leaf is split, and a value split or joined.\n\nimport type { OwnedRecordCache } from '@weasel-js/storage';\nimport { prefSectionLeaves } from './helpers';\nimport type { PrefList } from './list';\nimport { isPrefLocus, joinLocus, mapLocusMembers, repairLocus, splitLocus, writeMember, type PrefSelection } from './locus';\nimport type { PrefMap } from './map';\nimport type { PrefLeaf, PrefObject } from './schema';\nimport { selectionAt } from './snapshot';\nimport { recordValue, stampRecord } from './stamp';\nimport { prefVariantOf, type PrefUnion } from './union';\n\n/** JSON storage cannot keep an infinity; `repairPrefValue` reads these back. */\nconst encodeInfinity = (leaf: PrefLeaf, value: unknown): unknown => {\n if (leaf.kind === 'number') return value === Infinity || value === -Infinity ? String(value) : value;\n if (leaf.kind === 'list' && Array.isArray(value)) {\n const { item } = leaf as PrefList;\n return value.map((entry) => encodeInfinity(item, entry));\n }\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return value;\n const held = value as Record<string, unknown>;\n if (leaf.kind === 'map') {\n const { item } = leaf as PrefMap;\n return Object.fromEntries(Object.entries(held).map(([key, entry]) => [key, encodeInfinity(item, entry)]));\n }\n const fields = leaf.kind === 'union' ? prefVariantOf(leaf as PrefUnion, held)?.[1] : leaf;\n if (fields?.kind !== 'object') return value;\n let out: Record<string, unknown> | undefined;\n for (const [key, field] of prefSectionLeaves((fields as PrefObject).children)) {\n if (!Object.hasOwn(held, key)) continue;\n const encoded = encodeInfinity(field, held[key]);\n if (encoded !== held[key]) (out ??= { ...held })[key] = encoded;\n }\n return out ?? value;\n};\n\n/** What the writes of a store are made over. */\nexport interface PrefWritesSource {\n leaves: ReadonlyMap<string, PrefLeaf>;\n cache: OwnedRecordCache;\n /** The options of each leaf a value may be split by. */\n selectors: ReadonlyMap<string, readonly string[]>;\n /** The schema version a value written is in, stamped on its record. */\n version: number;\n /** The option each selector is set to, read as a write is made. */\n selection: () => PrefSelection;\n warnIfClosed: (path: string | undefined) => void;\n}\n\n/** A store's `set`, `split`, and `join`. */\nexport function prefWrites({ leaves, cache, selectors, version, selection, warnIfClosed }: PrefWritesSource): {\n set: (path: string, value: unknown, write?: { at?: PrefSelection }) => void;\n split: (path: string, by: string) => void;\n join: (path: string, by: string) => void;\n} {\n /** The leaf's split default as stored, where it has one it can hold. */\n const unsetLocus = (leaf: PrefLeaf): unknown => {\n if (leaf.defaultLocus === undefined || !leaf.splitBy?.length) return undefined;\n return repairLocus(leaf.defaultLocus, leaf.splitBy, (by) => selectors.get(by), (member) => encodeInfinity(leaf, member));\n };\n /** What the leaf holds in storage, unrepaired; its default, as stored, where it holds nothing. */\n const rawAt = (path: string, leaf: PrefLeaf): unknown =>\n (cache.has(path) ? recordValue(cache.get(path)) : unsetLocus(leaf) ?? encodeInfinity(leaf, leaf.default));\n const store = (path: string, stored: unknown): void => {\n // Unset is stored as nothing, which a stamp would turn into something.\n cache.set(path, stored === undefined ? undefined : stampRecord(stored, version));\n };\n /** The leaf and the selector's options, for a leaf that may be split by it. */\n const splitOf = (path: string, by: string): { leaf: PrefLeaf; options: readonly string[] } | undefined => {\n warnIfClosed(path);\n const leaf = leaves.get(path);\n const options = selectors.get(by);\n if (leaf?.splitBy?.includes(by) && options) return { leaf, options };\n console.warn(`[prefs] \"${path}\" cannot be split by \"${by}\"; ignoring`);\n return undefined;\n };\n\n const set = (path: string, value: unknown, write?: { at?: PrefSelection }): void => {\n warnIfClosed(path);\n const leaf = leaves.get(path);\n if (!leaf) {\n console.warn(`[prefs] no leaf at \"${path}\"; ignoring the write`);\n return;\n }\n if (leaf.splitBy?.length && isPrefLocus(value)) {\n store(path, mapLocusMembers(value, (member) => encodeInfinity(leaf, member)));\n return;\n }\n const stored = encodeInfinity(leaf, value);\n const had = cache.has(path) ? recordValue(cache.get(path)) : unsetLocus(leaf);\n const intoMember = stored !== undefined && leaf.splitBy?.length && isPrefLocus(had);\n const under = write?.at ? selectionAt(selectors, selection(), write.at) : selection();\n store(path, intoMember ? writeMember(had, under, stored) : stored);\n };\n const split = (path: string, by: string): void => {\n const found = splitOf(path, by);\n if (!found) return;\n const had = rawAt(path, found.leaf);\n const next = splitLocus(had, by, found.options, found.leaf.splitBy!);\n if (next !== had) store(path, next);\n };\n const join = (path: string, by: string): void => {\n const found = splitOf(path, by);\n if (!found) return;\n const had = rawAt(path, found.leaf);\n const next = joinLocus(had, by, selection(), encodeInfinity(found.leaf, found.leaf.default));\n if (next !== had) store(path, next);\n };\n return { set, split, join };\n}\n","import { createEmitter } from '@weasel-js/registry';\nimport type { OwnedRecordCache } from '@weasel-js/storage';\nimport type { PrefBlend } from './blend';\nimport { checkPrefConditions } from './conditionCheck';\nimport { recordValue } from './stamp';\nimport { assignPrefValueAtPath, prefHoldsValue, prefLeaves, setOwnPrefValue, VERSION_RECORD } from './helpers';\nimport { isPrefLocus, selectionWeights, type PrefLocus, type PrefSelection, type PrefWeights } from './locus';\nimport { createSnapshots, resolveHeld, selectionAt, weightsUnder, type SnapshotSource } from './snapshot';\nimport { checkPrefSplits, prefSelectors } from './splitCheck';\nimport type { PrefPath, PrefValueAt } from './paths';\nimport type { PrefValidator } from './repair';\nimport type { PrefGroup } from './groups';\nimport { prefWrites } from './storeWrites';\n\n/** One leaf changing, as a store subscriber hears it: the value readers now\n * see, and whether this store or another writer made the change. */\nexport interface PrefChange {\n path: string;\n value: unknown;\n origin: 'local' | 'remote';\n}\n\n/** Values for one schema, held in memory and persisted behind. */\nexport interface PrefsStore<S extends PrefGroup> {\n readonly schema: S;\n /**\n * The leaf's value, repaired against the schema; its default when unset. A\n * split value is folded: under the selectors' own values it is the member\n * they name, and under `weights` it is the blend its kind makes of the\n * members that weigh something. A selector `weights` leaves out keeps its\n * own value.\n */\n get<P extends PrefPath<S>>(path: P, read?: { weights?: PrefWeights }): PrefValueAt<S, P>;\n /** On a split leaf, writes the member the selectors' own values name, or\n * with `at` the one named with each selector there set to the option given.\n * A {@link PrefLocus} given as the value replaces the whole of what is held. */\n set<P extends PrefPath<S>>(path: P, value: PrefValueAt<S, P> | PrefLocus, write?: { at?: PrefSelection }): void;\n /** Hold the leaf's value once per option of the selector at `by`, one of\n * the leaf's `splitBy`, each option starting as the value it had. */\n split(path: PrefPath<S>, by: string): void;\n /** Stop splitting the leaf's value by the selector at `by`, keeping the\n * member that selector's own value names. */\n join(path: PrefPath<S>, by: string): void;\n /** What the leaf holds where its value is split, each member repaired. */\n locus(path: PrefPath<S>): PrefLocus | undefined;\n /** What every split leaf holds, by its path. The same map until something changes. */\n loci(): ReadonlyMap<string, PrefLocus>;\n /** Unset every leaf at or under `path`; with no path, all. */\n reset(path?: string): void;\n /** Whether the leaf has a value of its own rather than following its default. */\n isSet(path: PrefPath<S>): boolean;\n /** Every leaf's value as a nested tree. The same object until something\n * changes. With `at`, the tree as it would read with each selector named\n * there set to the option given, built for the call. */\n values(read?: { at?: PrefSelection }): Record<string, unknown>;\n /** The leaves following their default. The same set until something changes. */\n unset(): ReadonlySet<string>;\n /** Every stored record as a nested tree, unrepaired, including records no\n * leaf describes. The same object until something changes. */\n stored(): Record<string, unknown>;\n /** `changes` is empty when only records no leaf describes changed. A\n * selector changing is a change to every leaf split by it. */\n subscribe(listener: (changes: PrefChange[]) => void): () => void;\n /** False while the store cannot persist: storage has not been read yet, or\n * was written by a newer schema. Changes still apply for this session, and\n * ones made before a late read lands are persisted when it does. False for\n * good once the store is closed. */\n readonly writable: boolean;\n /** True once `close` was called. A write after that changes what this store\n * reads and reaches neither storage nor its subscribers, and the first one\n * warns. */\n readonly closed: boolean;\n /** Try again now to read storage that could not be read at open, ahead of\n * the store's own retries. Resolves whether storage has been read. */\n read(): Promise<boolean>;\n /** Resolves once storage has been read: at once for a store that opened\n * with its values, and when a later read lands for one that could not. */\n whenRead(): Promise<void>;\n /** Resolves true when every queued write reached storage. */\n flush(): Promise<boolean>;\n close(): Promise<void>;\n}\n\n/** Every record of `cache` but the version's, as a nested tree of unrepaired values. */\nfunction storedRecords(cache: OwnedRecordCache): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n const branches = new WeakSet<object>([tree]);\n for (const [name, record] of cache.entries()) {\n if (name === VERSION_RECORD) continue;\n const value = recordValue(record);\n const parts = name.split('.');\n let cursor = tree;\n for (const part of parts.slice(0, -1)) {\n const next = cursor[part];\n // A record's own value is never descended into: one named `a` and\n // another `a.b` cannot both show, and the branch wins.\n if (typeof next === 'object' && next !== null && branches.has(next)) {\n cursor = next as Record<string, unknown>;\n } else {\n const branch: Record<string, unknown> = {};\n branches.add(branch);\n setOwnPrefValue(cursor, part, branch);\n cursor = branch;\n }\n }\n const last = parts[parts.length - 1]!;\n if (!branches.has(cursor[last] as object)) setOwnPrefValue(cursor, last, value);\n }\n return tree;\n}\n\n/** A store over an open cache. `openPrefs` / `openPrefsSync` are the usual\n * way in; they run migrations first. */\nexport function createPrefsStore<S extends PrefGroup>(\n schema: S,\n cache: OwnedRecordCache,\n validators?: Readonly<Record<string, PrefValidator>>,\n onClose?: () => void,\n /** The schema version a value set here is in, stamped on its record. */\n version = 0,\n blends?: Readonly<Record<string, PrefBlend>>,\n): PrefsStore<S> {\n const leaves = new Map([...prefLeaves(schema)].filter(([, leaf]) => prefHoldsValue(leaf)));\n for (const { field, at, problem } of checkPrefConditions(schema)) {\n console.warn(`[prefs] ${field} of ${at === '' ? 'the schema' : `\"${at}\"`}: ${problem}`);\n }\n for (const { at, problem } of checkPrefSplits(schema)) console.warn(`[prefs] splitBy of \"${at}\": ${problem}`);\n const source: SnapshotSource = { leaves, cache, selectors: prefSelectors(leaves), validators, blends };\n const { current, peek, drop } = createSnapshots(source);\n\n let storedTree: Record<string, unknown> | null = null;\n\n let changed = createEmitter<[PrefChange[]]>();\n const stopCache = cache.subscribe((changes) => {\n const records = changes.filter((c) => c.name !== VERSION_RECORD);\n if (records.length === 0) return;\n storedTree = null;\n const mine = records.filter((c) => leaves.has(c.name));\n const before = peek();\n if (mine.length > 0) drop();\n const now = current();\n const origins = new Map(mine.map((c) => [c.name, c.origin]));\n for (const c of mine) {\n for (const path of [...(before?.splitBy.get(c.name) ?? []), ...(now.splitBy.get(c.name) ?? [])]) {\n if (!origins.has(path)) origins.set(path, c.origin);\n }\n }\n changed.emit([...origins].map(([path, origin]): PrefChange => ({ path, value: now.byPath.get(path), origin })));\n });\n\n let closed = false;\n let warned = false;\n const warnIfClosed = (path: string | undefined): void => {\n if (!closed || warned) return;\n warned = true;\n console.warn(`[prefs] write to a closed store${path === undefined ? '' : ` at \"${path}\"`}; it will not persist`);\n };\n return {\n schema,\n ...prefWrites({ leaves, cache, selectors: source.selectors, version, selection: () => current().selection, warnIfClosed }),\n get: (path, read) => {\n const now = current();\n if (!read?.weights) return now.byPath.get(path) as never;\n const leaf = leaves.get(path);\n const weights = weightsUnder(source.selectors, now.selection, read.weights);\n return (leaf ? resolveHeld(source, leaf, now.held.get(path), weights) : undefined) as never;\n },\n locus: (path) => {\n const held = current().held.get(path);\n return isPrefLocus(held) ? held : undefined;\n },\n loci: () => current().loci,\n reset: (path) => {\n warnIfClosed(path);\n for (const p of leaves.keys()) {\n if (path === undefined || p === path || p.startsWith(`${path}.`)) cache.delete(p);\n }\n },\n isSet: (path) => cache.has(path),\n values: (read) => {\n const now = current();\n if (!read?.at) return now.tree;\n const selection = selectionAt(source.selectors, now.selection, read.at);\n const weights = selectionWeights(selection);\n const tree: Record<string, unknown> = {};\n for (const [path, leaf] of leaves) {\n const set = source.selectors.has(path) ? selection[path] : resolveHeld(source, leaf, now.held.get(path), weights);\n assignPrefValueAtPath(tree, path, set);\n }\n return tree;\n },\n unset: () => current().unset,\n stored: () => (storedTree ??= storedRecords(cache)),\n subscribe: (listener) => changed.subscribe(listener),\n get writable() {\n return !closed && cache.writable;\n },\n get closed() {\n return closed;\n },\n read: () => cache.read(),\n whenRead: () => cache.whenRead(),\n flush: () => cache.flush(),\n close: async () => {\n closed = true;\n onClose?.();\n stopCache();\n changed = createEmitter();\n await cache.close();\n },\n };\n}\n","import {\n openRecords,\n openRecordsSync,\n type OwnedRecordCache,\n type StorageAdapter,\n type SyncStorageAdapter,\n} from '@weasel-js/storage';\nimport type { PrefBlend } from './blend';\nimport { type PrefsMigration, runPrefsMigrations, watchPrefsVersion } from './migrate';\nimport type { PrefValidator } from './repair';\nimport type { PrefGroup } from './groups';\nimport { createPrefsStore, type PrefsStore } from './store';\n\n/** Options for `openPrefs` and `openPrefsSync`. */\nexport interface PrefsOptions {\n storage: StorageAdapter;\n /** Prepended to every record's key: `'myapp.prefs.'`. */\n prefix: string;\n /** `migrations[i]` takes stored records from version `i` to `i + 1`. The\n * current version is `migrations.length`. */\n migrations?: readonly PrefsMigration[];\n /** Validators for app-defined kinds, keyed by `kind`. One given for a\n * built-in kind replaces that kind's own rule. */\n validators?: Readonly<Record<string, PrefValidator>>;\n /** How a split value's alternatives fold into one for app-defined kinds,\n * keyed by `kind`. One given for a built-in kind replaces that kind's\n * own. A kind with none takes its heaviest alternative. */\n blends?: Readonly<Record<string, PrefBlend>>;\n}\n\n/** Load every stored value for `schema`, migrate it, and return the store. */\nexport async function openPrefs<S extends PrefGroup>(\n schema: S,\n options: PrefsOptions,\n): Promise<PrefsStore<S>> {\n const cache = await openRecords({ storage: options.storage, prefix: options.prefix });\n const stop = watch(cache, options);\n if (runPrefsMigrations(cache, options.migrations ?? [])) await cache.flush();\n return createPrefsStore(schema, cache, options.validators, stop, options.migrations?.length ?? 0, options.blends);\n}\n\n/** `openPrefs` for an adapter that reads synchronously: the store is ready\n * on return, so values can be read before anything renders. */\nexport function openPrefsSync<S extends PrefGroup>(\n schema: S,\n options: PrefsOptions & { storage: SyncStorageAdapter },\n): PrefsStore<S> {\n const { cache, stop } = openPrefsCacheSync(options);\n return createPrefsStore(schema, cache, options.validators, stop, options.migrations?.length ?? 0, options.blends);\n}\n\n/** The migrated cache `openPrefsSync` builds its store over, and what stops\n * its version watch. */\nexport function openPrefsCacheSync(\n options: PrefsOptions & { storage: SyncStorageAdapter },\n): { cache: OwnedRecordCache; stop: () => void } {\n const cache = openRecordsSync({ storage: options.storage, prefix: options.prefix });\n const stop = watch(cache, options);\n if (runPrefsMigrations(cache, options.migrations ?? [])) void cache.flush();\n return { cache, stop };\n}\n\n/** Attached before migrations run, so a peer's version bump during the open's\n * own flush is heard, and on an unread cache too, whose late read reports\n * its records' version the same way. */\nconst watch = (cache: OwnedRecordCache, options: PrefsOptions): (() => void) =>\n watchPrefsVersion(cache, options.migrations ?? []);\n"]}
@@ -0,0 +1,32 @@
1
+ import { prefLeaves, prefHoldsValue, prefSelectors, readStored, isPrefLocus, selectionAt, assignPrefValueAtPath, resolveHeld, selectionWeights } from './chunk-OZFER7VN.js';
2
+
3
+ // src/defaultsSource.ts
4
+ function prefsDefaultsSource(schema) {
5
+ const leaves = new Map([...prefLeaves(schema)].filter(([, leaf]) => prefHoldsValue(leaf)));
6
+ const selectors = prefSelectors(leaves);
7
+ const held = new Map([...leaves].map(([path, leaf]) => [path, leaf.defaultLocus === void 0 ? leaf.default : readStored({ selectors }, leaf, leaf.defaultLocus)]));
8
+ const own = Object.fromEntries([...selectors.keys()].map((path) => [path, held.get(path)]));
9
+ const read = (path, selection) => {
10
+ const leaf = leaves.get(path);
11
+ if (!leaf) return void 0;
12
+ return selectors.has(path) ? selection[path] : resolveHeld({}, leaf, held.get(path), selectionWeights(selection));
13
+ };
14
+ return {
15
+ schema,
16
+ values: (options) => {
17
+ const selection = options?.at ? selectionAt(selectors, own, options.at) : own;
18
+ const tree = {};
19
+ for (const path of leaves.keys()) assignPrefValueAtPath(tree, path, read(path, selection));
20
+ return tree;
21
+ },
22
+ locus: (path) => {
23
+ const value = held.get(path);
24
+ return isPrefLocus(value) ? value : void 0;
25
+ },
26
+ get: (path) => read(path, own)
27
+ };
28
+ }
29
+
30
+ export { prefsDefaultsSource };
31
+ //# sourceMappingURL=chunk-ZLXZRX73.js.map
32
+ //# sourceMappingURL=chunk-ZLXZRX73.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/defaultsSource.ts"],"names":[],"mappings":";;;AAYO,SAAS,oBAAoB,MAAA,EAAmC;AACrE,EAAA,MAAM,SAAS,IAAI,GAAA,CAAI,CAAC,GAAG,UAAA,CAAW,MAAM,CAAC,CAAA,CAAE,MAAA,CAAO,CAAC,GAAG,IAAI,MAAM,cAAA,CAAe,IAAI,CAAC,CAAC,CAAA;AACzF,EAAA,MAAM,SAAA,GAAY,cAAc,MAAM,CAAA;AACtC,EAAA,MAAM,IAAA,GAAO,IAAI,GAAA,CAAI,CAAC,GAAG,MAAM,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,IAAI,CAAA,KAAM,CAAC,IAAA,EAAM,IAAA,CAAK,YAAA,KAAiB,MAAA,GAAY,IAAA,CAAK,OAAA,GAAU,UAAA,CAAW,EAAE,SAAA,EAAU,EAAG,IAAA,EAAM,IAAA,CAAK,YAAY,CAAC,CAAC,CAAC,CAAA;AACnK,EAAA,MAAM,MAAqB,MAAA,CAAO,WAAA,CAAY,CAAC,GAAG,SAAA,CAAU,MAAM,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from './groups';\nimport { assignPrefValueAtPath, prefHoldsValue, prefLeaves } from './helpers';\nimport { isPrefLocus, selectionWeights, type PrefSelection } from './locus';\nimport { readStored, resolveHeld, selectionAt } from './snapshot';\nimport { prefSelectors } from './splitCheck';\n\n/**\n * A schema's defaults read the way a store at defaults reads them, a split\n * default by its `defaultLocus` — what `prefsCss` needs to write a schema's\n * stylesheet with no store and no storage, at build time say.\n */\nexport function prefsDefaultsSource(schema: PrefGroup): PrefsCssSource {\n const leaves = new Map([...prefLeaves(schema)].filter(([, leaf]) => prefHoldsValue(leaf)));\n const selectors = prefSelectors(leaves);\n const held = new Map([...leaves].map(([path, leaf]) => [path, leaf.defaultLocus === undefined ? leaf.default : readStored({ selectors }, leaf, leaf.defaultLocus)]));\n const own: PrefSelection = Object.fromEntries([...selectors.keys()].map((path) => [path, held.get(path) as string]));\n\n const read = (path: string, selection: PrefSelection): unknown => {\n const leaf = leaves.get(path);\n if (!leaf) return undefined;\n return selectors.has(path) ? selection[path] : resolveHeld({}, leaf, held.get(path), selectionWeights(selection));\n };\n\n return {\n schema,\n values: (options) => {\n const selection = options?.at ? selectionAt(selectors, own, options.at) : own;\n const tree: Record<string, unknown> = {};\n for (const path of leaves.keys()) assignPrefValueAtPath(tree, path, read(path, selection));\n return tree;\n },\n locus: (path) => {\n const value = held.get(path);\n return isPrefLocus(value) ? value : undefined;\n },\n get: (path) => read(path, own),\n };\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { P as PrefLeaf, a as PrefGroup, U as PrefSelection, M as PrefLocus } from './groups-BDZC-ywb.js';
2
+
3
+ /** How {@link prefsCss} names and writes things. */
4
+ interface PrefsCssOptions {
5
+ /** The selector of the element the properties are set on, and the selectors' attributes read from. Default `:root`;
6
+ * `:host` matches the attributes the way a shadow root's sheet has to, as `:host([…])`. */
7
+ root?: string;
8
+ /** The custom property a leaf is written as, or `null` to leave the leaf out. Default: `--`, then the path with
9
+ * each `.` and each capital turned into a `-` (`look.gridGap` is `--look-grid-gap`). */
10
+ property?: (path: string, leaf: PrefLeaf) => string | null;
11
+ /** The attribute a selector's option is read from. Default: `data-`, then the path as a property spells it. */
12
+ attribute?: (selector: string) => string;
13
+ /** The CSS text of a value, `null` to leave it out, or `undefined` for what its kind writes by itself. */
14
+ value?: (value: unknown, leaf: PrefLeaf, path: string) => string | null | undefined;
15
+ }
16
+ /** What {@link prefsCss} reads of a store: any `PrefsStore` is one. */
17
+ interface PrefsCssSource {
18
+ schema: PrefGroup;
19
+ values(read?: {
20
+ at?: PrefSelection;
21
+ }): Record<string, unknown>;
22
+ locus(path: string): PrefLocus | undefined;
23
+ get(path: string): unknown;
24
+ }
25
+ /**
26
+ * The store's values as CSS custom properties.
27
+ *
28
+ * The first block sets every leaf on `root`, a split one at the member the
29
+ * selectors' defaults name, so a page that sets no attribute still has a
30
+ * value for each. A block follows for each choice of options some value tells
31
+ * apart, matched by an attribute per selector on that same element; a selector
32
+ * is written under each of its own options too. Every block is inside
33
+ * `:where()`, so none outranks another by how many attributes it names, and a
34
+ * rule of the page's own wins. Blocks naming more selectors come later.
35
+ *
36
+ * A number is written in its display unit where the unit's suffix is a CSS
37
+ * unit, and bare otherwise; a boolean as `1` or `0`; a color as it is held; an
38
+ * enum's option as an identifier; a string quoted. A leaf of any other kind is
39
+ * left out unless `value` writes it.
40
+ */
41
+ declare function prefsCss(store: PrefsCssSource, options?: PrefsCssOptions): string;
42
+ /**
43
+ * The attribute for each selector and the option it is set to: what to set
44
+ * on the `root` element for the blocks of {@link prefsCss} to match the
45
+ * store's own choice.
46
+ */
47
+ declare function prefsCssAttributes(store: Pick<PrefsCssSource, 'schema' | 'get'>, options?: Pick<PrefsCssOptions, 'attribute'>): Record<string, string>;
48
+
49
+ export { type PrefsCssSource as P, type PrefsCssOptions as a, prefsCssAttributes as b, prefsCss as p };