@wcstack/state 4.6.2 → 4.7.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/README.ja.md +39 -12
- package/README.md +41 -12
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +5 -5
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/chunk-BCL75PFH.js +2 -0
- package/dist/split/chunks/chunk-BCL75PFH.js.map +1 -0
- package/dist/split/chunks/{chunk-JWRQLKOQ.js → chunk-DRSAQE4E.js} +2 -2
- package/dist/split/chunks/{chunk-GBBBRPZR.js → chunk-GQTEYSRZ.js} +2 -2
- package/dist/split/chunks/{chunk-FBBHQU7S.js → chunk-IBGHHABS.js} +2 -2
- package/dist/split/chunks/{chunk-T3FN37DU.js → chunk-P3EXTBXC.js} +2 -2
- package/dist/split/chunks/{chunk-CBMAVRYG.js → chunk-PKEAYPFR.js} +2 -2
- package/dist/split/chunks/chunk-QMOIMPIJ.js +2 -0
- package/dist/split/chunks/chunk-QMOIMPIJ.js.map +1 -0
- package/dist/split/chunks/chunk-T3KW5DZD.js +2 -0
- package/dist/split/chunks/chunk-T3KW5DZD.js.map +1 -0
- package/dist/split/chunks/chunk-UN6ADZKP.js +2 -0
- package/dist/split/chunks/{chunk-AAEFSJ6G.js.map → chunk-UN6ADZKP.js.map} +1 -1
- package/dist/split/chunks/chunk-XXVJ6J2N.js +2 -0
- package/dist/split/chunks/chunk-XXVJ6J2N.js.map +1 -0
- package/dist/split/core.d.ts +2 -0
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.d.ts +2 -0
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/devtools.js.map +1 -1
- package/dist/split/features/diagnostics.d.ts +2 -0
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.d.ts +2 -0
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/list-keys.d.ts +2 -0
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/list-keys.js.map +1 -1
- package/dist/split/features/native-commands.d.ts +2 -0
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/native-commands.js.map +1 -1
- package/dist/split/features/recursion.d.ts +2 -0
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/recursion.js.map +1 -1
- package/dist/split/features/scopes.d.ts +2 -0
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/scopes.js.map +1 -1
- package/dist/split/features/ssr.d.ts +2 -0
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/ssr.js.map +1 -1
- package/dist/split/features/temporal.d.ts +2 -0
- package/dist/split/features/temporal.js +1 -1
- package/dist/split/features/temporal.js.map +1 -1
- package/package.json +1 -1
- package/dist/split/chunks/chunk-467LYA2V.js +0 -2
- package/dist/split/chunks/chunk-467LYA2V.js.map +0 -1
- package/dist/split/chunks/chunk-AAEFSJ6G.js +0 -2
- package/dist/split/chunks/chunk-TNYNJXEC.js +0 -2
- package/dist/split/chunks/chunk-TNYNJXEC.js.map +0 -1
- package/dist/split/chunks/chunk-ULMHOGJ2.js +0 -2
- package/dist/split/chunks/chunk-ULMHOGJ2.js.map +0 -1
- package/dist/split/chunks/chunk-ZJYPRSTO.js +0 -2
- package/dist/split/chunks/chunk-ZJYPRSTO.js.map +0 -1
- /package/dist/split/chunks/{chunk-JWRQLKOQ.js.map → chunk-DRSAQE4E.js.map} +0 -0
- /package/dist/split/chunks/{chunk-GBBBRPZR.js.map → chunk-GQTEYSRZ.js.map} +0 -0
- /package/dist/split/chunks/{chunk-FBBHQU7S.js.map → chunk-IBGHHABS.js.map} +0 -0
- /package/dist/split/chunks/{chunk-T3FN37DU.js.map → chunk-P3EXTBXC.js.map} +0 -0
- /package/dist/split/chunks/{chunk-CBMAVRYG.js.map → chunk-PKEAYPFR.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["slots","WeakMap","waiting","ORPHAN","wired","WeakSet","grafted","REJECTED","NOT_RUN","PREFIX","path","config","tagNames","state","PATH_APIS","Set","live","e","element","isConnected","failed","root","w","get","Array","isArray","rootEngineCreated","engine","list","delete","v","graft","release","held","fail","message","console","error","settle","callLifecycle","name","fn","r","call","chroot","then","has","target","segs","split","at","s","hydrated","prefix","key","Proxy","_t","charCodeAt","proxy","keyPath","rest","set","value","chrootOf","data","defs","seen","o","Object","prototype","getPrototypeOf","getOwnPropertyNames","add","getOwnPropertyDescriptor","next","bind","i","length","p","pattern","slice","join","readData","write","registerAccessors","defineProperties","changed","push","el","orphan","giveUp","claimVolume","getAttribute","problem","every","test","validPath","hasAttribute","bindAttributeName","Map","other","filter","x","lenient","start","warn","Promise","resolve","engines","connected","disconnected","reset","raiseError","instances","byEngine","names","n","claimDcc","host","content","document","createDocumentFragment","childNodes","appendChild","cloneNode","mode","tag","includes","customElements","all","out","streams","$stream","keys","members","bindables","commands","d","def","states","pending","ensure","shadow","attachShadow","querySelector","inner","ready","initializePromise","queued","k","Dcc","HTMLElement","this","wcBindable","protocol","version","properties","map","event","getter","inputs","async","connectedCallback","stateElement","defineProperty","configurable","args","apply","q","define","localName","hostBindings","readonlyWiring","before","WIRED","hosts","mounts","index","registered","active","UNWIRED","INERT","headOf","fill","idx","String","hostBinding","b","ro","node","head","documentElement","removeAttribute","wiredInMarkup","heads","setAttribute","prop","values","componentScope","text","RegExp","replace","wireLate","scope","parentElement","E","getRootNode","bound","mountSubtree","warned","warnOnce","own","h","surface","findDescriptor","mountKey","m","whole","H","entries","find","parent","info","synth","C","component","hp","from","row","depth","indexesOf","rowAt","ctx","rr","readUntracked","setter","across","skip","slot","slotCount","mountUnder","outer","through","alive","was","reaches","reached","register","on","byP","byRow","size","exports","answer","exporting","exportAccessors","strategy","invalidate","schedule","cp","last","warnShadowed","exporter","found","tree","read","touch","old","direct","item","arr","resetRow","children","l","sync","syncListsUnder","hooks","written","refresh","forAllRows","lists","into","cpath","some","startsWith","rp","crow","crossed","hr","up","g","exportReached","isUnder","built","loading","loadFeatures","$recursion","current","attr","binds","nodeType","matches","kept","top","parentNode","range","anchor","headAt","nextSibling","bs","rootBindings","chain","br","branches","rootLists","view","extra","nodes","added","mustache","textContent","takesOver","reconnect","resume","Engine","DirtyStrategy","methods","f","_self","Reflect","bindMethods","independent","declared","base","onPatternCreated","made","patterns","drain","inPlace","wire","adopted","adoptScope","mount","drainBinds","watchRendered","enumerable","$stateReadyCallback","callHook","broken","claimComponent","connectedCallbackPromise","catch","watchRoot","ShadowRoot","Element","mine","load","light","a","registryOf","whenDefined","wiring","marked","wiredOnServer","stop","j","onRootFailed","Error","finally","original","queueMicrotask","star","indexOf","unregister","ds","getOwnPropertyDescriptors","frozen","isFrozen","writable","create","melt","reject","scopes","install","claim","first","taken","phase","rootMoved","dccEngineCreated","exact","dispatchEvent","CustomEvent","detail","bubbles","dccWritten","getterReached","beforeWrite","handled","_row","_value","guardAncestorWrite","guardReadonlyMount","declare","hasMounts","scopes_default"],"sources":["../../../src/scopes/volume.ts","../../../src/scopes/dcc.ts","../../../src/scopes/component.ts","../../../src/features/scopes.ts"],"sourcesContent":["/**\n * Volumes — `<wcs-state mount=\"p\">` (README \"Mounting Additional State\"). A volume is not a\n * root: its state is grafted onto the root tree at `p` by ordinary writes, its getters and\n * setters become root accessors at `p.<key>`, its methods live at `p.<method>`, and inside all\n * of them — and in its `$connectedCallback` / `$disconnectedCallback` — `this` is chrooted at\n * `p` (`this.x` is the tree's `p.x`). Load order does not matter: a volume that loads before its\n * root grafts when the root engine is created, before the page is bound; if the root fails to\n * initialize, its volumes report it and settle. A root hydrated from a server snapshot (SSR)\n * already holds the volume's data at `p`: the volume adopts it (3.x D14). A volume in a component\n * wired to its host (`data-wcs=\"state…\"`) is refused, whenever it loads (3.x left it pending).\n *\n * Not carried over from @wcstack/state 3.3 (approved simplifications, each an error rather than\n * a silent no-op): injections on the volume element (`data-wcs=\"state.k: …\"`), and a volume's\n * own `$watch` / `$listKeys` / `$renderedCallback` — declare them on the root.\n */\nimport type { Engine } from \"../engine\";\nimport type { Pattern } from \"../pattern\";\nimport type { Claimed } from \"../hooks\";\nimport type { WcsState } from \"../element\";\nimport { config } from \"../config\";\nimport { engines } from \"../dom/mount\";\nimport { raiseError } from \"../parser/raiseError\";\n\nexport interface Volume {\n readonly el: HTMLElement;\n readonly root: Node;\n readonly path: string;\n state: Record<string, any> | null;\n engine: Engine | null;\n chroot: object | null;\n /** Settles the element's connectedCallbackPromise. */\n settle: (() => void) | null;\n}\n\n/** Mount paths held on each root (reserved when a volume connects, kept once grafted). */\nconst slots = new WeakMap<Node, Map<string, Volume>>();\n/**\n * Loaded volumes waiting for their root's engine; an element: the root's `<wcs-state>` that failed\n * to initialize (what loads later fails with it while it is in the page: failed()).\n */\nconst waiting = new WeakMap<Node, Volume[] | Element>();\nconst ORPHAN = \"will not graft: the root state failed to initialize.\";\n/** The engines of components wired to their host: they read the host's tree, a volume has none to graft onto. */\nexport const wired = new WeakSet<Engine>();\n/** The volumes grafted onto each engine. */\nexport const grafted = new WeakMap<Engine, Volume[]>();\n\nconst REJECTED = [\"$stream\", \"$streams\", \"$scan\", \"$recursion\", \"$watch\", \"$listKeys\", \"$renderedCallback\", \"$updatedCallback\", \"$behavior\", \"$features\"];\nconst NOT_RUN = [\"$commandTokens\", \"$eventTokens\", \"$on\", \"$errorCallback\"];\nconst PREFIX = (path: string) => `[@wcstack/state] <${config.tagNames.state} mount=\"${path}\">`;\n\n/** `$` APIs that take a state path: inside a volume the path is relative to the mount. */\nconst PATH_APIS = new Set([\"$getAll\", \"$setAll\", \"$resolve\", \"$postUpdate\", \"$dependOn\", \"$eq\", \"$eqIndex\"]);\n\nfunction chrootOf(engine: Engine, prefix: string): object {\n const at = (key: string) => `${prefix}.${key}`;\n return new Proxy({}, {\n get(_t, key) {\n if (typeof key === \"symbol\") return undefined;\n if (key.charCodeAt(0) !== 36) return engine.proxy[at(key)];\n const v = engine.proxy[key];\n if (key === \"$eqPath\") return (path: string, keyPath: string) => v(at(path), at(keyPath));\n return PATH_APIS.has(key) && typeof v === \"function\" ? (path: string, ...rest: unknown[]) => v(at(path), ...rest) : v;\n },\n set(_t, key, value) {\n if (typeof key === \"symbol\") return false;\n engine.proxy[at(key as string)] = value;\n return true;\n },\n });\n}\n\nfunction validPath(path: string): boolean {\n return path !== \"\" && path.split(\".\").every((s) => s !== \"\" && !/[*$#@\\s]/.test(s));\n}\n\n/**\n * An engine whose `<wcs-state>` is in the page: nothing grafts onto one that is out (a root out of the\n * page lets go of its root node; a component whose `<wcs-state>` alone left stays registered).\n */\nconst live = (e: Engine | undefined): Engine | undefined => ((e?.element as Node | undefined)?.isConnected ? e : undefined);\n\n/** The root `<wcs-state>` on `root` failed to initialize, and is still in the page. */\nfunction failed(root: Node): boolean {\n const w = waiting.get(root);\n return w !== undefined && !Array.isArray(w) && w.isConnected;\n}\n\n/** The engine created on `root`: graft the volumes that were waiting for it (before its page is bound). */\nexport function rootEngineCreated(engine: Engine, root: Node): void {\n const list = waiting.get(root);\n waiting.delete(root);\n if (Array.isArray(list)) for (const v of list) graft(v, engine);\n}\n\nfunction release(v: Volume): void {\n const held = slots.get(v.root);\n if (held?.get(v.path) === v) held.delete(v.path);\n}\n\n/**\n * A root engine's `<wcs-state>` left the page (\"disconnected\"), or is back (\"back\"; a component's:\n * \"connected\"). Out, the mount paths its volumes hold let go of it (they are kept on the root node,\n * which outlives the content it bound). Back, and still its root's engine (the core holds the root\n * again unless another `<wcs-state>` bound it meanwhile), the volumes that connected meanwhile graft,\n * and its own hold their paths again — unless another volume took one meanwhile.\n */\nexport function rootMoved(engine: Engine, phase: string): void {\n const list = grafted.get(engine) ?? [];\n if (phase === \"disconnected\") for (const v of list) release(v);\n else if (phase !== \"reset\" && live(engines.get(engine.root!)) === engine) {\n rootEngineCreated(engine, engine.root!);\n for (const v of list) if (!slots.get(v.root)!.has(v.path)) slots.get(v.root)!.set(v.path, v);\n }\n}\n\n/** Reports a volume that will not graft, releases its slot and settles its promise. */\nfunction fail(v: Volume, message: string): void {\n console.error(`${PREFIX(v.path)} ${message}`);\n release(v);\n v.settle?.();\n v.settle = null;\n}\n\nfunction callLifecycle(v: Volume, name: \"$connectedCallback\" | \"$disconnectedCallback\"): void {\n const fn = v.state?.[name];\n if (typeof fn !== \"function\") return;\n try {\n const r = fn.call(v.chroot);\n if (r !== null && typeof r === \"object\" && typeof r.then === \"function\") r.then(undefined, (e: unknown) => console.error(e));\n } catch (e) {\n console.error(e);\n }\n}\n\nfunction graft(v: Volume, engine: Engine): void {\n if (wired.has(engine)) return fail(v, \"will not graft: its component is wired to its host.\");\n const state = v.state!;\n const target = engine.target;\n const segs = v.path.split(\".\");\n let at: any = target;\n for (const s of segs) at = at == null ? undefined : at[s];\n // a root hydrated from a server snapshot (ssr/ssr.ts) has the volume's data there already: adopted\n if (at !== undefined && (engine as any).hydrated !== true) return fail(v, `will not graft: the root state already has \"${v.path}\".`);\n const chroot = chrootOf(engine, v.path);\n v.chroot = chroot;\n // the data; accessors and methods (bound to the chroot) apart, as root accessors at `p.<key>`,\n // so that whatever replaces the data (the snapshot, a write of the mount path) keeps them\n const data: Record<string, unknown> = {};\n const defs: PropertyDescriptorMap = {};\n const seen = new Set<string>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const key of Object.getOwnPropertyNames(o)) {\n if (seen.has(key) || key === \"constructor\") continue;\n seen.add(key);\n const { get, set, value } = Object.getOwnPropertyDescriptor(o, key)!;\n if (get !== undefined || set !== undefined) {\n defs[`${v.path}.${key}`] = {\n get: get && function () { return get.call(chroot); },\n set: set && function (next: unknown) { set.call(chroot, next); },\n };\n } else if (key[0] === \"$\") continue;\n else if (typeof value === \"function\") {\n const fn = value.bind(chroot);\n defs[`${v.path}.${key}`] = { get: () => fn };\n } else data[key] = value;\n }\n }\n if (at === undefined) {\n // intermediate objects of a deep mount path, then the volume's own object\n for (let i = 1; i < segs.length; i++) {\n const p = engine.pattern(segs.slice(0, i).join(\".\"));\n if (engine.readData(p, null) == null) engine.write(p, null, {});\n }\n engine.write(engine.pattern(v.path), null, data);\n }\n // registered as the root's own are (a row-level getter gets its cache slot; the paths under\n // them read through them)\n (engine as any).registerAccessors(Object.defineProperties({}, defs));\n for (const path in defs) engine.changed(engine.pattern(path), null);\n v.engine = engine;\n let list = grafted.get(engine);\n if (list === undefined) grafted.set(engine, (list = []));\n list.push(v);\n if (v.el.isConnected) callLifecycle(v, \"$connectedCallback\");\n v.settle?.();\n v.settle = null;\n}\n\n/**\n * A root `<wcs-state>` (the one no claim took; asked by the last, claimComponent): if it fails to\n * initialize, the volumes waiting on `root` settle instead of waiting forever, and so do the ones\n * that load later — and the components waiting there for their wiring (onRootFailed).\n */\nexport function watchRoot(el: HTMLElement, root: Node): null {\n (el as WcsState).connectedCallbackPromise.catch(() => {\n // a root that bound the page (only its $connectedCallback failed), or a stray second one (#47)\n // beside the root that binds it: nothing failed for what waits there\n const live = engines.get(root)?.element as Element | undefined;\n if ((el as WcsState).bound || (live !== undefined && live !== el && live.isConnected)) return;\n orphan(root, el);\n for (const f of giveUp.get(root) ?? []) f();\n });\n return null;\n}\n\n/**\n * The state of `root` failed to initialize (`el`: the page's root, or a component's in its shadow\n * root): the volumes waiting there report it and settle, and so do those that load later while\n * `el` is in the page.\n */\nexport function orphan(root: Node, el: Element): void {\n const list = waiting.get(root);\n if (Array.isArray(list)) for (const v of list) fail(v, ORPHAN);\n waiting.set(root, el);\n}\n\n/** What else waits on a root node's `<wcs-state>` (a component, for the page's wiring). */\nconst giveUp = new WeakMap<Node, Set<() => void>>();\n\n/**\n * Calls `fn` when (or if) the root `<wcs-state>` on `root` fails to initialize; the function\n * returned stops waiting (what `fn` holds is not kept for as long as the page lives).\n */\nexport function onRootFailed(root: Node, fn: () => void): () => boolean {\n if (failed(root)) fn();\n const s = giveUp.get(root) ?? new Set();\n giveUp.set(root, s.add(fn));\n return () => s.delete(fn);\n}\n\n/** `<wcs-state mount=\"p\">`: claimed instead of becoming a root. */\nexport function claimVolume(el: HTMLElement, root: Node): Claimed | null {\n const path = el.getAttribute(\"mount\");\n if (path === null) return null;\n const v: Volume = { el, root, path, state: null, engine: null, chroot: null, settle: null };\n let problem: string | null = null;\n if (!validPath(path)) problem = `has an invalid mount path: it must be a static path (no \"*\", \"$\", \"#\", \"@\").`;\n else if (el.hasAttribute(config.bindAttributeName)) problem = `injections (data-wcs=\"state.<key>: …\") are not supported — read the root path in a root getter.`;\n else {\n let held = slots.get(root);\n if (held === undefined) slots.set(root, (held = new Map()));\n const other = held.get(path);\n // one grafted onto a root that left the page holds it no more, nor does one waiting for its root\n // out of the page (the page's content replaced): that one yields, and never grafts. (One out of\n // the page that no other volume asks for still grafts when its root comes.)\n if (other !== undefined && other !== v && (other.engine === null ? other.el.isConnected : live(other.engine))) {\n problem = `will not graft: another volume already holds \"${path}\".`;\n } else {\n if (other?.engine === null) {\n const list = waiting.get(root);\n if (Array.isArray(list)) waiting.set(root, list.filter((x) => x !== other));\n other.settle?.();\n other.settle = null;\n }\n held.set(path, v);\n }\n }\n return {\n // a volume that cannot load resolves its connectedCallbackPromise (3.x; it reports, as below)\n lenient: true,\n start(state): Promise<void> | void {\n if (problem !== null) return fail(v, problem);\n // (it yielded its slot while it loaded: see above)\n if (slots.get(root)!.get(path) !== v) return;\n for (const key of REJECTED) if (state[key] !== undefined) return fail(v, `${key} is not run in a volume — declare it on the root state.`);\n for (const key of NOT_RUN) if (state[key] !== undefined) console.warn(`${PREFIX(path)} ${key} is not run in a volume (it belongs to the root).`);\n v.state = state;\n return new Promise<void>((resolve) => {\n v.settle = resolve;\n const engine = live(engines.get(root));\n const list = waiting.get(root);\n if (engine !== undefined) graft(v, engine);\n else if (failed(root)) fail(v, ORPHAN);\n else waiting.set(root, [...(Array.isArray(list) ? list : []), v]);\n });\n },\n connected() {\n if (v.engine !== null) callLifecycle(v, \"$connectedCallback\");\n },\n disconnected() {\n // a grafted volume keeps its data and its slot (there is no unmount)\n if (v.engine !== null) callLifecycle(v, \"$disconnectedCallback\");\n },\n reset() {\n raiseError(`re-setting a volume is not supported: its data was copied into the root tree at \"${path}\" — write the paths under it on the root instead.`);\n },\n };\n}\n\n/** A root write that would replace an object a volume is grafted under. */\nexport function guardAncestorWrite(engine: Engine, p: Pattern): void {\n const list = grafted.get(engine);\n if (list === undefined || p.depth !== 0) return;\n for (const { path } of list) {\n if (path.startsWith(`${p.path}.`)) raiseError(`writing \"${p.path}\" would replace the volume grafted at \"${path}\"; write the paths under it instead.`);\n }\n}\n","/**\n * Declarative Custom Components (README \"DCC\"). The `<wcs-state>` inside the shadow root of a\n * `[data-wc-definition]` host is not a root: it defines the host's tag. Each instance gets a\n * copy of the definition's (untouched) shadow content, whose own `<wcs-state>` is an ordinary\n * root with a fresh state. The class's prototype reads and writes that state (writes before it\n * initializes wait for it; methods return Promises); `$bindables` / `$commands` become its\n * `static wcBindable`, and a write to a bindable (or under it, or a `$postUpdate`) dispatches\n * `<tag>:<prop>-changed` from the instance — a notification: `detail` carries the written value\n * only for a write of the member itself, and the declared getter reads the member off the element.\n *\n * The shadow is built on first use — an accessor or the connect, whichever comes first — not in\n * the constructor: a `for` row binds its elements before they are inserted, a parser-made\n * instance has no attributes in its constructor, and the definition host itself (upgraded by\n * define()) already has its shadow.\n */\nimport type { Engine } from \"../engine\";\nimport type { Pattern } from \"../pattern\";\nimport type { Claimed } from \"../hooks\";\nimport { config } from \"../config\";\nimport { raiseError } from \"../parser/raiseError\";\n\ninterface Definition {\n readonly tag: string;\n readonly bindables: readonly string[];\n}\n\n/** DCC instances by host element, and the definition of each instance's inner engine. */\nconst instances = new WeakMap<Element, Definition>();\nconst byEngine = new WeakMap<Engine, { host: Element; def: Definition }>();\n\nfunction names(state: Record<string, any>, key: string): string[] {\n const v = state[key];\n if (v === undefined) return [];\n if (!Array.isArray(v)) raiseError(`${key} must be an array of state member names.`);\n const seen = new Set<string>();\n for (const n of v) {\n if (typeof n !== \"string\" || n === \"\") raiseError(`${key} entries must be non-empty strings.`);\n if (n[0] === \"$\") raiseError(`${key} entry \"${n}\": internal ($) members are never exposed.`);\n if (seen.has(n)) raiseError(`${key} entry \"${n}\" is duplicated.`);\n seen.add(n);\n }\n return v;\n}\n\n/** Every member of the state (own and inherited), by descriptor. */\nfunction members(state: Record<string, any>): Map<string, PropertyDescriptor> {\n const out = new Map<string, PropertyDescriptor>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const key of Object.getOwnPropertyNames(o)) {\n if (key === \"constructor\" || key[0] === \"$\" || out.has(key)) continue;\n out.set(key, Object.getOwnPropertyDescriptor(o, key)!);\n }\n }\n const streams = state.$stream;\n if (streams !== null && typeof streams === \"object\") for (const n of Object.keys(streams)) if (!out.has(n)) out.set(n, { value: undefined });\n return out;\n}\n\nfunction define(tag: string, content: DocumentFragment, mode: ShadowRootMode, state: Record<string, any>): void {\n if (!tag.includes(\"-\")) raiseError(`DCC: <${tag} data-wc-definition> is not a valid custom element name.`);\n if (customElements.get(tag) !== undefined) raiseError(`DCC: <${tag}> is already defined.`);\n const all = members(state);\n const bindables = names(state, \"$bindables\");\n const commands = names(state, \"$commands\");\n for (const n of bindables) {\n const d = all.get(n);\n if (d === undefined) raiseError(`$bindables entry \"${n}\" does not exist on the state.`);\n if (typeof d.value === \"function\") raiseError(`$bindables entry \"${n}\" is a method: list it in $commands.`);\n }\n for (const n of commands) {\n const d = all.get(n);\n if (d === undefined) raiseError(`$commands entry \"${n}\" does not exist on the state.`);\n if (typeof d.value !== \"function\") raiseError(`$commands entry \"${n}\" is not a method: list it in $bindables.`);\n }\n const def: Definition = { tag, bindables };\n /** Each instance's inner `<wcs-state>` (null: a definition host, or content without one). */\n const states = new WeakMap<Element, any>();\n const pending = new WeakMap<Element, [string, unknown][]>();\n /** Builds the instance's shadow once; its inner `<wcs-state>`. */\n const ensure = (el: Element): any => {\n if (states.has(el)) return states.get(el);\n if (el.hasAttribute(\"data-wc-definition\")) return null;\n const shadow = el.attachShadow({ mode });\n shadow.appendChild(content.cloneNode(true));\n const state = shadow.querySelector(config.tagNames.state);\n states.set(el, state);\n instances.set(el, def);\n if (state === null && bindables.length > 0) {\n console.warn(`[@wcstack/state] DCC: <${tag}> declares $bindables but its content has no <${config.tagNames.state}>: no change events.`);\n }\n return state;\n };\n /** The instance's inner engine once its state initialized, else null. */\n const inner = (el: Element): any => ensure(el)?.engine ?? null;\n /** Resolves when the instance's state initialized, before its `$connectedCallback` (and lands the writes queued before). */\n const ready = (el: Element): Promise<void> => Promise.resolve(ensure(el)?.initializePromise).then(() => {\n const queued = pending.get(el);\n pending.delete(el);\n const engine = inner(el);\n if (queued !== undefined && engine !== null) for (const [k, v] of queued) engine.proxy[k] = v;\n });\n\n class Dcc extends HTMLElement {\n static wcBindable = bindables.length === 0 && commands.length === 0 ? null : {\n protocol: \"wc-bindable\", version: 1,\n properties: bindables.map((name) => ({ name, event: `${tag}:${name}-changed`, getter: (e: Event) => (e.target as any)[name] })),\n inputs: bindables.map((name) => ({ name })),\n ...(commands.length === 0 ? {} : { commands: commands.map((name) => ({ name, async: true })) }),\n };\n\n connectedCallback(): void {\n if (ensure(this) !== null) void ready(this);\n }\n\n /** The inner `<wcs-state>` (as in 3.3; builds the shadow if it is not built yet). */\n get stateElement(): HTMLElement | null {\n return ensure(this);\n }\n }\n for (const [name, d] of all) {\n if (typeof d.value === \"function\") {\n Object.defineProperty(Dcc.prototype, name, {\n configurable: true,\n value(this: Element, ...args: unknown[]) {\n return ready(this).then(() => {\n const engine = inner(this);\n return engine === null ? undefined : engine.proxy[name].apply(engine.proxy, args);\n });\n },\n });\n } else {\n Object.defineProperty(Dcc.prototype, name, {\n configurable: true,\n get(this: Element) { return inner(this)?.proxy[name]; },\n set(this: Element, value: unknown) {\n const engine = inner(this);\n if (engine !== null) engine.proxy[name] = value;\n else {\n let q = pending.get(this);\n if (q === undefined) pending.set(this, (q = []));\n q.push([name, value]);\n }\n },\n });\n }\n }\n customElements.define(tag, Dcc);\n}\n\n/** The `<wcs-state>` of a definition host: claimed to define the tag. */\nexport function claimDcc(el: HTMLElement, root: Node): Claimed | null {\n const host = (root as ShadowRoot).host;\n if (host === undefined || !host.hasAttribute(\"data-wc-definition\")) return null;\n // the definition's content, before anything touches it: every instance starts from this\n const content = document.createDocumentFragment();\n for (const n of [...root.childNodes]) content.appendChild(n.cloneNode(true));\n const mode = (root as ShadowRoot).mode;\n return {\n start(state) {\n if (el.hasAttribute(\"bind-component\")) raiseError(\"DCC: a <wcs-state bind-component> cannot define a component (use one mechanism).\");\n define(host.localName, content, mode, state);\n },\n connected() {},\n disconnected() {},\n reset() {\n raiseError(\"re-setting a DCC definition is not supported: each instance loads its own state.\");\n },\n };\n}\n\n/** A root engine was created: an instance's inner state gets its host's change events. */\nexport function dccEngineCreated(engine: Engine, root: Node): void {\n const host = (root as ShadowRoot).host;\n const def = host === undefined ? undefined : instances.get(host);\n if (def !== undefined) byEngine.set(engine, { host, def });\n}\n\n/**\n * A write at a bindable, under it, or its `$postUpdate`: `<tag>:<prop>-changed` from the\n * instance, with the written value as `detail` only for a data write of the member itself.\n */\nexport function dccWritten(engine: Engine, p: Pattern, value: unknown, direct: boolean): void {\n const info = byEngine.get(engine);\n if (info === undefined) return;\n const name = p.path.split(\".\", 1)[0];\n if (!info.def.bindables.includes(name)) return;\n const exact = direct && p.path === name;\n info.host.dispatchEvent(new CustomEvent(`${info.def.tag}:${name}-changed`, { detail: exact ? value : undefined, bubbles: true }));\n}\n","/**\n * Component mounts — `<wcs-state bind-component=\"prop\">` directly inside a custom element\n * (README \"Web Component Binding\"). Each component runs an engine of its own over its state\n * object (the host element's `prop`): its bindings, rows, `$1`, event indexes, getters and\n * private keys are the component's. The host wires it with ordinary property bindings on the\n * element (`state: user`, `state.x: path`, `state: .` in a row); those are taken over as\n * mount entries, and the component reads and writes the mounted keys through the host's\n * engine. Changes cross both ways through the `written` / `getterReached` hooks: the host's\n * reach the components mounted on them, and a component's writes under a mounted key reach\n * the host (and, from there, the other components mounted on the same data).\n *\n * Own keys stay private (rule R1): a key the component declares itself is its own, except a\n * one-segment partial entry, which wins over a data default. Unwired, a Shadow DOM component\n * owns an independent tree; a Light DOM one cannot (it shares the page) and fails loudly.\n *\n * `#ro` on an entry (`state#ro: user`) is honoured as in 3.3: a component's code writing through it\n * throws `[wcs/mount-readonly]`, an element's write-back inside the component is dropped.\n *\n * A whole mount's accessors are exported at the mount point (README \"Exported getters\"): the host\n * reads `user.display` (row by row for `state: .`) from the component mounted there, unless the\n * tree has the key.\n * A mounted component runs no temporal declaration and no `$renderedCallback`, and refuses `$recursion`.\n */\nimport { Engine, rowAt } from \"../engine\";\nimport { WILDCARD, type Pattern } from \"../pattern\";\nimport type { StateRow } from \"../list\";\nimport type { Binding } from \"../dom/view\";\nimport { hooks, loadFeatures, type Claimed } from \"../hooks\";\nimport { config } from \"../config\";\nimport { DirtyStrategy } from \"../strategy/dirty\";\nimport { engines, mount, mountSubtree } from \"../dom/mount\";\nimport { bind, drainBinds } from \"../dom/binder\";\nimport { registryOf } from \"../dom/wc\";\nimport { raiseError } from \"../parser/raiseError\";\nimport type { WcsState } from \"../element\";\nimport { onRootFailed, orphan, rootEngineCreated, watchRoot, wired } from \"./volume\";\n\ninterface Entry {\n /** The component-side path (\"\" = the whole state). */\n readonly inner: string;\n /** The host pattern and row (at the pattern's depth) it is mounted on. */\n readonly outer: Pattern;\n readonly row: StateRow | null;\n /** Mounted `#ro`: the component reads it and does not write it. */\n readonly ro: boolean;\n}\n\n/** What a host element keeps across the `<wcs-state>` elements its renders create. */\ninterface Host {\n readonly el: Element;\n readonly prop: string;\n /** The author's state object: the component's private data lives here. */\n readonly state: Record<string, any>;\n /** The host's engine (null: an unwired, independent component). */\n readonly engine: Engine | null;\n readonly entries: Entry[];\n current: Mount | null;\n}\n\ninterface Synth {\n readonly e: Entry;\n readonly p: Pattern;\n readonly row: StateRow | null;\n}\n\ninterface Mount {\n /** Its `<wcs-state>`: a new one that takes the scope over replaces it (resume). */\n el: HTMLElement;\n /** The nodes of the scope root once it was bound: still there, a new `<wcs-state>` takes the scope over. */\n nodes: ChildNode[];\n readonly component: Engine;\n readonly host: Host;\n readonly slots: { m: Mount; e: Entry }[];\n /** Component patterns that read and write the host. */\n readonly synth: Map<Pattern, Synth>;\n registered: boolean;\n /** A mounted key its setter just wrote through the host (its `written` is not forwarded again). */\n skip: Pattern | null;\n /** The entry a change of the component is crossing to the host through: its other entries still take it. */\n from: Entry | null;\n /** Exported accessors (a whole mount's): host pattern (`user.display`) → the component's accessor pattern. */\n exports: Map<Pattern, Pattern> | null;\n /**\n * It failed before its bindings were built (a markup error): what it bound before the error follows\n * the host while it is connected, as a root's does (#384), and no lifecycle hook runs — its\n * `$connectedCallback` never did.\n */\n broken?: boolean;\n}\n\ntype Slot = Mount[\"slots\"][number];\n\n/** Plain property bindings hosts made on custom elements: the candidates for wiring. */\nconst hostBindings = new WeakMap<Element, Binding[]>();\n/** Those of them written with `#ro`. */\nconst readonlyWiring = new WeakSet<Binding>();\n/** An element property's value before a host's first write to it (a mount takes the component's). */\nconst before = new WeakMap<Element, Map<string, unknown>>();\n/** Components waiting for their host to bind the wiring written in its markup. */\nconst waiting = new WeakMap<Element, () => void>();\n/**\n * SSR: a row is a clone of its plan, so the server's output carries no `data-wcs` on a row's\n * elements. A host binding made while rendering on the server writes the heads it binds here\n * instead, so a component whose class is defined before the client adopts the row still waits\n * for its wiring (as it does for `data-wcs`); the client's host binding removes it.\n */\nconst WIRED = \"data-wcs-wired\";\nconst onServer = (): boolean => document.documentElement?.hasAttribute(\"data-wcs-server\") === true;\nconst hosts = new WeakMap<Element, Host>();\nconst mounts = new WeakMap<Engine, Mount>();\n/** Mount entries by host engine, host pattern and host row. */\nconst index = new WeakMap<Engine, Map<Pattern, Map<StateRow | null, Set<Slot>>>>();\nlet registered = 0;\n/** Engines a change is crossing from: it does not come back to them. */\nconst active = new Set<Engine>();\n\nconst UNWIRED = {};\n/** Declarations a mounted component does not run (`$listKeys` runs: it keys the component's own lists). */\nconst INERT = [\"$watch\", \"$stream\", \"$renderedCallback\"];\n\nconst headOf = (path: string): string => path.split(\".\", 1)[0];\n\n/** `a.*.b.*` with [2, 5] → `a.2.b.5`. */\nfunction fill(path: string, idx: number[]): string {\n let i = 0;\n return path.split(\".\").map((s) => (s === WILDCARD ? String(idx[i++]) : s)).join(\".\");\n}\n\n/** The core's hook: a plain property binding on a custom element (before it applies). */\nexport function hostBinding(b: Binding, ro: boolean): boolean {\n const el = b.node as Element;\n const head = headOf(b.name);\n if (!onServer()) el.removeAttribute(WIRED);\n else if (!wiredInMarkup(el, head)) {\n const heads = el.getAttribute(WIRED)?.split(\" \") ?? [];\n if (!heads.includes(head)) el.setAttribute(WIRED, [...heads, head].join(\" \"));\n }\n // the component took its wiring when it loaded: a mount is not re-wired\n if (hosts.get(el)?.prop === head) {\n raiseError(`<${el.localName}>.${head} has loaded its state: the wiring \"${b.name}\" added afterwards cannot reach it — bind the host's wiring before the component loads.`);\n }\n let list = hostBindings.get(el);\n if (list === undefined) hostBindings.set(el, (list = []));\n list.push(b);\n if (ro) readonlyWiring.add(b);\n let values = before.get(el);\n if (values === undefined) before.set(el, (values = new Map()));\n if (!values.has(head)) values.set(head, (el as any)[head]);\n waiting.get(el)?.();\n return false;\n}\n\n/** The core's hook: a Light DOM component's content is bound by its own engine. */\nexport function componentScope(el: Element): boolean {\n return el.localName.includes(\"-\") && el.querySelector(`:scope > ${config.tagNames.state}[bind-component]`) !== null;\n}\n\nfunction wiredInMarkup(host: Element, prop: string): boolean {\n const text = host.getAttribute(config.bindAttributeName);\n return text !== null && new RegExp(`(^|;)\\\\s*${prop.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\s*[.#:]`).test(text);\n}\n\n/**\n * A host whose wiring is in its markup, and which the page did not bind: it was out of the page when\n * the page's state loaded, or was inserted since — by code, not by a `for:` / `if:` (which binds it\n * before inserting it) or the router (which hands it over). Its `<wcs-state>` hands it over as the\n * router does (src/dom/binder.ts): it is bound now, or once its root's state is in the page (it has not\n * loaded yet, or its `<wcs-state>` is out). In a Light DOM component, that component's engine binds it,\n * when it mounts (now, if it has). A host the page did bind is left alone (an element is walked once),\n * and so is one whose root failed before binding the page (onRootFailed refuses the component).\n */\nfunction wireLate(host: Element): void {\n let scope = host.parentElement;\n while (scope !== null && !componentScope(scope)) scope = scope.parentElement;\n const E = engines.get(scope ?? host.getRootNode());\n const el = E?.element as WcsState | undefined;\n // (the binder binds to the page's engine now, or keeps the host for when it is in the page)\n if (el?.isConnected ? el.bound : scope === null) {\n if (scope === null) bind(host);\n else mountSubtree(E!, host);\n }\n}\n\n/** The server's output says the host binds `prop` on this row element (see WIRED). */\nconst wiredOnServer = (host: Element, prop: string): boolean => host.getAttribute(WIRED)?.split(\" \").includes(prop) === true;\n\n/** A frozen author object is copied into a writable one (same prototype). */\nfunction melt(o: Record<string, any>): Record<string, any> {\n const ds = Object.getOwnPropertyDescriptors(o);\n let frozen = Object.isFrozen(o);\n for (const d of Object.values(ds)) if (\"value\" in d && d.writable === false) { d.writable = true; frozen = true; }\n return frozen ? Object.create(Object.getPrototypeOf(o), ds) : o;\n}\n\nasync function load(el: HTMLElement, prop: string, host: Element, light: boolean): Promise<Record<string, any>> {\n const tag = host.localName;\n if ([\"state\", \"src\", \"json\"].some((a) => el.hasAttribute(a)) || el.querySelector('script[type=\"module\"]') !== null) {\n raiseError(`<${config.tagNames.state} bind-component> takes its state from <${tag}>.${prop}: it cannot also load one (state / src / json / an inline script).`);\n }\n await registryOf(host).whenDefined(tag);\n let h = hosts.get(host);\n if (h !== undefined) {\n if (h.prop !== prop) raiseError(`<${tag}> already has a <${config.tagNames.state} bind-component=\"${h.prop}\">.`);\n return h.state;\n }\n const wiring = () => (hostBindings.get(host) ?? []).filter((b) => headOf(b.name) === prop);\n // the host binds its wiring when it renders the element (a row before inserting it; the page\n // when its state loads; a server-rendered row when the client adopts it), or when the\n // element's class is defined — or, written in its markup on a host the page did not bind, now\n const marked = wiredInMarkup(host, prop);\n if (marked && wiring().length === 0) wireLate(host);\n if (wiring().length === 0 && (marked || wiredOnServer(host, prop))) {\n // (if the page's state fails, its wiring never comes)\n let stop!: () => boolean;\n await new Promise<void>((r, j) => {\n waiting.set(host, r);\n stop = onRootFailed(host.getRootNode(), () => j(new Error(`[@wcstack/state] <${tag}>.${prop} will not mount: the root state failed to initialize.`)));\n }).finally(() => stop());\n }\n waiting.delete(host);\n const bs = wiring();\n const values = before.get(host);\n const original = values !== undefined && values.has(prop) ? values.get(prop) : (host as any)[prop];\n if (original === null || typeof original !== \"object\") {\n raiseError(`\"bind-component\": <${tag}>.${prop} must be an object (the component's state), got ${original === null ? \"null\" : typeof original}.`);\n }\n if (bs.length === 0 && light) {\n // reported as an uncaught error, after this element settles (as 3.3 does)\n const error = new Error(`[@wcstack/state] A plain (unwired) Light DOM \"bind-component\" is not supported. Attach a shadow root to <${tag}>, or mount it from the host (${config.bindAttributeName}=\"${prop}: path\").`);\n queueMicrotask(() => { throw error; });\n return UNWIRED;\n }\n const entries: Entry[] = [];\n for (const b of bs) {\n const inner = b.name === prop ? \"\" : b.name.slice(prop.length + 1);\n if (entries.some((e) => e.inner === inner)) raiseError(`<${tag}> maps \"${b.name}\" twice.`);\n const star = inner.split(\".\").indexOf(WILDCARD);\n if (star >= 0) {\n const list = inner.split(\".\").slice(0, star).join(\".\");\n raiseError(`<${tag}> maps \"${b.name}\": the component-side path of a mount cannot contain \"*\"${list === \"\" ? \"\" : ` — map the list itself (\"${prop}.${list}: <the host's list>\")`}.`);\n }\n entries.push({ inner, outer: b.pattern, row: b.row, ro: readonlyWiring.has(b) });\n // the component reads the host from now on: the binding no longer writes the element\n b.engine.unregister(b);\n if (inner !== \"\") delete (host as any)[b.name];\n }\n const state = bs.length === 0 ? melt(original as Record<string, any>) : original as Record<string, any>;\n hosts.set(host, (h = { el: host, prop, state, engine: bs.length === 0 ? null : bs[0].engine, entries, current: null }));\n return state;\n}\n\nconst warned = new Set<string>();\nfunction warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n console.warn(`[@wcstack/state] ${message}`);\n}\n\n/** Whether `key` is the component's own (a data default, an accessor or a method of its state). */\nconst own = (h: Host, key: string): boolean => key in h.state;\n\n/** The component's own surface for `key`: an accessor or a method (a data default is not). */\nfunction surface(h: Host, key: string): boolean {\n const d = findDescriptor(h.state, key);\n return d !== undefined && (d.get !== undefined || d.set !== undefined || typeof d.value === \"function\");\n}\n\n/**\n * The component's patterns that read and write the host: a partial entry's path, and under a\n * whole mount every top-level key the component does not declare itself.\n */\nfunction wire(m: Mount): void {\n const C = m.component;\n const h = m.host;\n const H = h.engine!;\n const tag = h.el.localName;\n const whole = h.entries.find((e) => e.inner === \"\") ?? null;\n for (const e of h.entries) {\n if (e.inner === \"\") continue;\n const head = headOf(e.inner);\n // a one-segment entry wins over a data default; the component's own surface (an accessor,\n // a method) and an own key above a deep entry win over the entry\n if (own(h, head) && (e.inner !== head || surface(h, head))) {\n warnOnce(`${tag}.${e.inner}`, `[wcs/mount-own-key-shadow] <${tag}>: \"${h.prop}.${e.inner}\" is hidden by the component's own \"${head}\"; rename one side.`);\n }\n }\n if (whole !== null) {\n const at = H.readUntracked(whole.outer, whole.row);\n if (at !== null && typeof at === \"object\") {\n for (const key of Object.keys(h.state)) {\n if (key[0] !== \"$\" && key in at && !h.entries.some((e) => e.inner === key)) {\n warnOnce(`${tag}.${key}`, `[wcs/mount-own-key-shadow] <${tag}>: its own \"${key}\" hides \"${whole.outer.path}.${key}\" — remove the default to read the tree, or rename it to keep it private.`);\n }\n }\n }\n }\n const declared = INERT.filter((k) => h.state[k] !== undefined);\n if (declared.length > 0) {\n warnOnce(`${tag}.${h.prop}$`, `[wcs/mount-dollar-declaration] <${tag}>: ${declared.join(\", \")} ${declared.length === 1 ? \"is\" : \"are\"} not run in a mounted component — declare it on the root state.`);\n }\n const base = (C as any).onPatternCreated;\n (C as any).onPatternCreated = (p: Pattern) => {\n mountKey(m, whole, p);\n base.call(C, p);\n };\n // patterns the engine made before (the parents of the component's own accessors): mounted\n // keys among them, then what now reads through them. A snapshot: both loops walk it (a pattern\n // made during the first goes through the wrapped onPatternCreated above).\n const made = [...C.patterns.all()];\n for (const p of made) mountKey(m, whole, p);\n for (const p of made) base.call(C, p);\n // a mount in a host row goes with the row (4.0 discards a removed row's element): it renders no\n // more — what it would read of the row throws (live), its own keys stay readable and writable.\n // So does a mount inside a component that went with its row: it reads the tree through that one.\n const drain = C.drain;\n C.drain = () => {\n if (inPlace(m)) drain.call(C);\n };\n}\n\n/** Every host row a mount reads through is still there: its own, and those of the components it is in. */\nfunction inPlace(m: Mount | undefined): boolean {\n for (; m !== undefined; m = mounts.get(m.host.engine!)) {\n if (m.host.entries.some((e) => e.row !== null && !e.row.alive)) return false;\n }\n return true;\n}\n\n/**\n * `element.state` is the component's proxy, handed out as an object: a function the state declares\n * (a method, or a function-valued key it starts with) read off it always runs on it, whatever `this`\n * it is called with — detached (`const { toggle } = element.state`), as a listener\n * (`button.addEventListener(\"click\", element.state.toggle)`), by a timer — as 3.x's `bind` did\n * (#331; an explicit `call(other)` is ignored, as with `bind`). It is wrapped once per function, in a\n * proxy that keeps the function's properties, statics, `new`, `name` and identity across reads; a\n * function a key comes to hold later, the tree's or its own, is returned as it is. Only reads through\n * the proxy itself are wrapped, not through a view of it (`createStateAsync(\"readonly\")`, whose\n * methods must run on the read-only view). A root's proxy is only lent to a callback, and a volume's\n * methods are bound to its chroot already.\n */\nfunction bindMethods(C: Engine, state: object): void {\n const methods = new Map<unknown, unknown>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const k of Object.getOwnPropertyNames(o)) {\n const v = Object.getOwnPropertyDescriptor(o, k)!.value;\n if (typeof v === \"function\" && k !== \"constructor\") methods.set(v, null);\n }\n }\n const apply = (f: (...a: unknown[]) => unknown, _self: unknown, args: unknown[]): unknown => Reflect.apply(f, C.proxy, args);\n C.bound = (fn) => {\n let b = methods.get(fn);\n if (b === null) methods.set(fn, (b = new Proxy(fn, { apply })));\n return b;\n };\n}\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction mountKey(m: Mount, whole: Entry | null, p: Pattern): void {\n if (p.getter !== null) return;\n const h = m.host;\n const H = h.engine!;\n const head = headOf(p.path);\n let e = h.entries.find((x) => x.inner === p.path);\n if (e === undefined && p.parent !== null) return mountUnder(m, p);\n if (p.depth !== 0) return;\n let target: Pattern;\n if (e !== undefined) {\n if (e.inner !== head ? own(h, head) : surface(h, head)) return;\n target = e.outer;\n } else if (whole !== null && p.parent === null && head[0] !== \"$\" && !own(h, head)) {\n e = whole;\n target = H.pattern(`${whole.outer.path}.${head}`);\n } else {\n return;\n }\n const row = e.row;\n const through = e;\n p.getter = () => H.readUntracked(target, live(m, row));\n p.setter = (value: unknown) => {\n across(m, through, () => H.write(target, row, value));\n m.skip = p;\n };\n m.synth.set(p, { e, p: target, row });\n}\n\n/**\n * The host row an entry is mounted on, for reading or writing through it. A removed row is gone\n * for good (4.0 never puts a removed row's element in another row): nothing of it is the\n * component's any more, and the position it had may hold another row now (3.4 #367 / #368).\n */\nfunction live(m: Mount, row: StateRow | null): StateRow | null {\n if (row !== null && !row.alive) raiseError(`The host row of <${m.host.el.localName}> was removed.`);\n return row;\n}\n\n/** Runs a change of component `m` crossing to its host through entry `e`. */\nfunction across(m: Mount, e: Entry, fn: () => void): void {\n const was = active.has(m.component);\n active.add(m.component);\n m.from = e;\n try {\n fn();\n } finally {\n if (!was) active.delete(m.component);\n m.from = null;\n }\n}\n\n/** Whether a change crossing from the component's own entry `from` (or from its host) reaches `slot`. */\nconst reaches = (slot: Slot, reached: boolean): boolean =>\n reached || !active.has(slot.m.component) || (slot.m.from !== null && slot.m.from !== slot.e);\n\n/**\n * A path under a mounted key whose host counterpart is a getter (a host getter, a recursive\n * family): read — and written, if it has a setter — through the host, row by row.\n */\nfunction mountUnder(m: Mount, p: Pattern): void {\n let s: Pattern | null = p.parent;\n let info: Synth | undefined;\n while (s !== null && (info = m.synth.get(s)) === undefined) s = s.parent;\n if (s === null || info === undefined) return;\n const C = m.component;\n const H = m.host.engine!;\n const hp = H.pattern(info.p.path + p.path.slice(s.path.length));\n if (hp.getter === null) return;\n const from = info;\n /**\n * The host row of `hp`: the entry's own row (not the row now at its position), and under it the\n * component's rows (a component path with a `*` of its own).\n */\n const at = (): StateRow | null => {\n const r = live(m, from.row);\n if (p.depth === 0) return r;\n H.resolve(fill(hp.path, [...H.indexesOf(r), ...C.indexesOf(rowAt(C.ctx, p.depth))]), null);\n return (H as any).rr as StateRow | null;\n };\n p.getter = () => {\n const r = at();\n return hp.depth > 0 && r === null ? undefined : H.readUntracked(hp, r);\n };\n if (hp.setter !== null) {\n p.setter = (value: unknown) => {\n const r = at();\n across(m, from.e, () => H.write(hp, r, value));\n m.skip = p;\n };\n }\n if (p.depth > 0) p.slot = (C as any).slotCount++;\n m.synth.set(p, { e: from.e, p: hp, row: from.row });\n}\n\nfunction register(m: Mount, on: boolean): void {\n if (m.registered === on || m.host.engine === null) return;\n m.registered = on;\n registered += on ? 1 : -1;\n const H = m.host.engine;\n let byP = index.get(H);\n if (byP === undefined) index.set(H, (byP = new Map()));\n for (const slot of m.slots) {\n let byRow = byP.get(slot.e.outer);\n if (byRow === undefined) byP.set(slot.e.outer, (byRow = new Map()));\n let set = byRow.get(slot.e.row);\n if (set === undefined) byRow.set(slot.e.row, (set = new Set()));\n if (on) set.add(slot);\n else {\n set.delete(slot);\n if (set.size === 0) byRow.delete(slot.e.row);\n }\n }\n const whole = m.host.entries.find((e) => e.inner === \"\");\n if (whole === undefined) return;\n if (m.exports === null) exportAccessors(m, whole);\n // the host's readers of the exported paths: the component answers them now (a re-set of the\n // host while it was away forgot the answer), or no longer\n for (const hp of m.exports!.keys()) {\n if (on && hp.getter === null) answer(H, hp, whole.outer);\n H.strategy.invalidate(H, hp, whole.row);\n }\n if (m.exports!.size > 0) H.schedule();\n if (on) warnShadowed(m, whole);\n}\n\n// ---------------------------------------------------------------- exported accessors\n\n/** The getters `answer` gave host patterns (a re-set of the host forgets them with its accessors). */\nconst exporting = new WeakSet<object>();\n\n/**\n * README \"Exported getters\": a whole mount's accessors (getters and setters, not methods or\n * private data, no `*` in the name) are read at the mount point. The host's own accessor there\n * wins; a key the tree has wins (`wcs/mount-export-shadowed`).\n */\nfunction exportAccessors(m: Mount, whole: Entry): void {\n const h = m.host;\n const H = h.engine!;\n m.exports = new Map();\n const seen = new Set<string>();\n for (let o: object | null = h.state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const k of Object.getOwnPropertyNames(o)) {\n if (seen.has(k)) continue;\n seen.add(k);\n const d = Object.getOwnPropertyDescriptor(o, k)!;\n if ((d.get === undefined && d.set === undefined) || k[0] === \"$\" || k.includes(WILDCARD)) continue;\n // a dotted accessor exports only from the component's own data (`form.label`), not the tree's\n const head = headOf(k);\n if (k !== head && !own(h, head)) continue;\n const hp = H.pattern(`${whole.outer.path}.${k}`);\n // the host's own accessor there wins\n if (hp.getter === null) answer(H, hp, whole.outer);\n else if (!exporting.has(hp.getter)) continue;\n m.exports.set(hp, m.component.pattern(k));\n }\n }\n}\n\n/** The mount that exports `hp` at host row `row` (the row at the mount point's depth). */\nfunction exporter(H: Engine, outer: Pattern, row: StateRow | null, hp: Pattern): Mount | null {\n const set = index.get(H)?.get(outer)?.get(row);\n if (set === undefined) return null;\n let found: Mount | null = null;\n for (const slot of set) {\n if (slot.e.inner !== \"\" || slot.m.exports?.has(hp) !== true || slot.m === found) continue;\n if (found !== null) {\n raiseError(`[wcs/mount-export-ambiguous] \"${hp.path}\" is exported by two mounted components on the same instance: <${found.host.el.localName}> and <${slot.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`);\n }\n found = slot.m;\n }\n return found;\n}\n\n/** Makes host pattern `hp` read (and write) the accessor of the component mounted at `outer`, row by row. */\nfunction answer(H: Engine, hp: Pattern, outer: Pattern): void {\n const parent = hp.parent!;\n const last = hp.last;\n /** The tree's object that has the key, or null. */\n const tree = (): any => {\n const o = H.read(parent, H.ctx) as any;\n return o !== null && typeof o === \"object\" && last in o ? o : null;\n };\n hp.getter = () => {\n const o = tree();\n if (o !== null) return o[last];\n const m = exporter(H, outer, H.ctx, hp);\n return m === null ? undefined : m.component.read(m.exports!.get(hp)!, null);\n };\n exporting.add(hp.getter);\n hp.setter = (value: unknown) => {\n const o = tree();\n const m = o === null ? exporter(H, outer, H.ctx, hp) : null;\n if (m === null) {\n // no component answers it here: the tree's own key\n const at = H.read(parent, H.ctx) as any;\n if (at !== null && typeof at === \"object\") at[last] = value;\n return;\n }\n const cp = m.exports!.get(hp)!;\n if (findDescriptor(m.host.state, cp.path)?.set === undefined) {\n raiseError(`Cannot write to \"${cp.path}\" on mounted <${m.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`);\n }\n m.component.write(cp, null, value);\n };\n if (hp.depth > 0) hp.slot = H.slotCount++;\n}\n\nfunction warnShadowed(m: Mount, whole: Entry): void {\n const H = m.host.engine!;\n for (const [hp, cp] of m.exports!) {\n const o = H.readUntracked(hp.parent!, whole.row) as any;\n if (o === null || typeof o !== \"object\" || !(hp.last in o)) continue;\n const tag = m.host.el.localName;\n warnOnce(`${tag}|${hp.path}`, `[wcs/mount-export-shadowed] <${tag}>.${m.host.prop}.${cp.path} is exported at \"${hp.path}\" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`);\n }\n}\n\n/** A component's exported accessor was reached (it may now differ): so are the host's readers of it. */\nfunction exportReached(m: Mount, g: Pattern): void {\n const whole = m.host.entries.find((e) => e.inner === \"\")!;\n const H = m.host.engine!;\n for (const [hp, cp] of m.exports!) {\n if (cp !== g) continue;\n H.strategy.invalidate(H, hp, whole.row);\n H.schedule();\n }\n}\n\n/**\n * The `beforeWrite` hook: a component's write through a `#ro` entry, or through an entry whose\n * host row is gone. Code (a method, `element.state`, `$setAll` / `$resolve`) is refused; an\n * element's write-back (a two-way input in the component) is dropped, as `#ro` on that binding\n * would (@wcstack/state 3.3).\n */\nexport function guardReadonlyMount(E: Engine, p: Pattern, element: boolean): boolean {\n const m = mounts.get(E);\n if (m === undefined) return false;\n let info: Synth | undefined;\n for (let s: Pattern | null = p; s !== null && info === undefined; s = s.parent) info = m.synth.get(s);\n if (info === undefined) return false;\n const e = info.e;\n // the host's row went away (an await outlived it): the write has nowhere to land (3.3.x)\n const gone = e.row !== null && !e.row.alive;\n if (!gone && !e.ro) return false;\n if (element) return true;\n live(m, e.row);\n raiseError(`[wcs/mount-readonly] <${m.host.el.localName}> cannot write \"${p.path}\": it is mounted read-only (\"${m.host.prop}${e.inner === \"\" ? \"\" : `.${e.inner}`}#ro: ${e.outer.path}\"). Write it on the host, or drop #ro from the mount.`);\n}\n\n/** A host engine that has components mounted on it: its state cannot be re-set. */\nexport function hasMounts(engine: Engine): boolean {\n const byP = index.get(engine);\n if (byP === undefined) return false;\n for (const byRow of byP.values()) if (byRow.size > 0) return true;\n return false;\n}\n\n/**\n * Applies a change another engine made to shared data: the lists under it re-sync (an\n * element's row takes the array's new element), hooks see it, dependents update.\n */\nfunction touch(E: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n if (p.getter !== null) {\n E.strategy.invalidate(E, p, row);\n E.schedule();\n return;\n }\n if (p.last === WILDCARD) {\n if (row === null) return;\n row.item = (row.list.arr as unknown[])[row.index];\n E.strategy.resetRow(row);\n if (row.children !== null) for (const l of row.children.values()) E.sync(l);\n } else {\n (E as any).syncListsUnder(p, row);\n }\n hooks.written?.(E, p, row, old, value, direct);\n E.changed(p, row);\n}\n\n/** The value an entry is mounted on may have been replaced: every key read through it is stale. */\nfunction refresh(slot: Slot): void {\n const C = slot.m.component;\n for (const [p, s] of slot.m.synth) {\n if (s.e !== slot.e) continue;\n if (p.depth === 0) C.strategy.invalidate(C, p, null);\n else C.forAllRows(p.lists[p.depth]!, (r) => C.strategy.invalidate(C, p, r));\n }\n C.schedule();\n}\n\n/** A host change at or under an entry: the component's path under the mounted key. */\nfunction into(slot: Slot, q: Pattern, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n const rest = p.path.slice(q.path.length);\n if (rest === \"\") return refresh(slot);\n const m = slot.m;\n const C = m.component;\n let cpath: string;\n if (slot.e.inner === \"\") {\n cpath = rest.slice(1);\n const head = headOf(cpath);\n // the component keeps it private, or a partial entry maps it elsewhere (the longest prefix wins)\n if (head[0] === \"$\" || own(m.host, head) || m.host.entries.some((x) => x.inner !== \"\" && (cpath === x.inner || cpath.startsWith(`${x.inner}.`)))) return;\n } else {\n cpath = slot.e.inner + rest;\n }\n const idx: number[] = [];\n for (let k = q.depth + 1; k <= p.depth; k++) idx.push(rowAt(row, k)!.index);\n C.resolve(fill(cpath, idx), null);\n const cp = (C as any).rp as Pattern;\n const crow = (C as any).rr as StateRow | null;\n if (cp.depth > 0 && crow === null) return;\n touch(C, cp, crow, old, value, direct);\n}\n\n/** A component's write under a mounted key: the host's path, with the host row's indexes first. */\nfunction up(m: Mount, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n let s: Pattern | null = p;\n let info: Synth | undefined;\n while (s !== null && (info = m.synth.get(s)) === undefined) s = s.parent;\n if (s === null || info === undefined) return; // private data\n const H = m.host.engine!;\n if (s === p && m.skip === p) {\n m.skip = null; // its setter wrote through the host\n return;\n }\n // its host row went away (a write there is refused; `$postUpdate` is not a write): the position\n // it had may hold another row now\n if (info.row !== null && !info.row.alive) return;\n const idx = [...H.indexesOf(info.row), ...m.component.indexesOf(row)];\n H.resolve(fill(info.p.path + p.path.slice(s.path.length), idx), null);\n const hp = (H as any).rp as Pattern;\n const hr = (H as any).rr as StateRow | null;\n if (hp.depth > 0 && hr === null) return;\n across(m, info.e, () => touch(H, hp, hr, old, value, direct));\n}\n\n/**\n * The `written` / `getterReached` hook: a change in engine E crosses to the host it is mounted\n * on (a write, not a getter reached) and to the components mounted on it. A write does not come\n * back to the engines it is crossing from; a getter reached does — it only invalidates, and the\n * components a write started in read the host's getters too.\n */\nexport function crossed(E: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean, reached: boolean): void {\n if (registered === 0) return;\n const was = active.has(E);\n active.add(E);\n try {\n const m = mounts.get(E);\n if (!reached && m !== undefined && m.registered && !active.has(m.host.engine!)) up(m, p, row, old, value, direct);\n if (reached && m !== undefined && m.registered && m.exports !== null) exportReached(m, p);\n const byP = index.get(E);\n if (byP === undefined) return;\n for (const [q, byRow] of byP) {\n if (p.isUnder(q)) {\n const set = byRow.get(q.depth === 0 ? null : rowAt(row, q.depth));\n if (set !== undefined) for (const slot of [...set]) if (reaches(slot, reached)) into(slot, q, p, row, old, value, direct);\n } else if (q.isUnder(p)) {\n for (const [r, set] of [...byRow]) {\n if (p.depth !== 0 && rowAt(r, p.depth) !== row) continue;\n for (const slot of [...set]) if (reaches(slot, reached)) refresh(slot);\n }\n }\n }\n } finally {\n if (!was) active.delete(E);\n }\n}\n\nasync function start(el: HTMLElement, host: Element, root: Node, state: Record<string, any>, built: () => void): Promise<void> {\n if (state === UNWIRED) return;\n // the add-ons its `$features` names, before anything reads the host's current mount\n const loading = loadFeatures(state);\n if (loading) await loading;\n const h = hosts.get(host)!;\n // a mounted engine is never \"mounting\": its `$recursion` would run half set up — refused, as in a volume\n if (h.engine && state.$recursion) {\n raiseError(`[wcs/mount-dollar-declaration] <${host.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);\n }\n const old = h.current;\n if (old !== null && old.el !== el && old.el.isConnected) {\n raiseError(`<${host.localName}> already has a connected <${config.tagNames.state} bind-component=\"${h.prop}\">.`);\n }\n if (old !== null) register(old, false);\n if (old !== null && takesOver(old, el, root)) return resume(old, el, root, built);\n const C = new Engine(state, new DirtyStrategy());\n C.element = el;\n (el as any).engine = C;\n bindMethods(C, state);\n const m: Mount = { el, nodes: [], component: C, host: h, slots: [], synth: new Map(), registered: false, skip: null, from: null, exports: null };\n for (const e of h.entries) m.slots.push({ m, e });\n h.current = m;\n mounts.set(C, m);\n const independent = h.engine === null;\n if (!independent) {\n wire(m);\n register(m, true);\n // the volumes in it are refused (graft), those that loaded first and those that load later\n wired.add(C);\n rootEngineCreated(C, root);\n } else {\n hooks.element?.(C, \"mounting\");\n }\n // a Light DOM component in a server-rendered page takes the server's nodes of its content (F33)\n const adopted = hooks.adoptScope?.(root, C);\n mount(C, root as ShadowRoot | Element);\n adopted?.();\n m.nodes = [...root.childNodes];\n drainBinds();\n if (independent) C.watchRendered();\n Object.defineProperty(host, h.prop, { configurable: true, enumerable: true, get: () => C.proxy });\n const ready = (host as any).$stateReadyCallback;\n if (typeof ready === \"function\") {\n try {\n const r = ready.call(host, h.prop);\n if (r !== null && typeof r === \"object\" && typeof r.then === \"function\") r.then(undefined, (e: unknown) => console.error(e));\n } catch (e) {\n console.error(e);\n }\n }\n // the bindings are built: what waits for them goes on, whatever $connectedCallback does (as a root)\n built();\n // taken out while it initialized: it hears the host, and runs `$connectedCallback`, when it is back\n if (!el.isConnected) {\n register(m, false);\n return;\n }\n await C.callHook(\"$connectedCallback\");\n if (independent && el.isConnected) hooks.element?.(C, \"connected\");\n}\n\n/**\n * Whether a new `<wcs-state bind-component>` takes the scope of the old mount `o` over (resume)\n * instead of binding its root afresh: when nodes the old engine bound or rendered are still in the\n * root (it swapped only its `<wcs-state>`). A kept `<style>`, whitespace or other nodes without\n * bindings do not count: content rendered again, its `<wcs-state>` included, is bound afresh. Nodes\n * with bindings added since next to kept bound ones (the old engine cannot take them, a new one\n * cannot take the kept ones) are reported.\n */\nfunction takesOver(o: Mount, el: Node, root: Node): boolean {\n // (a `<wcs-state>` in another root of the host finds none of the old nodes there)\n const C = o.component;\n const attr = `[${config.bindAttributeName}]`;\n const binds = (n: Node): boolean => n.nodeType === 1 && ((n as Element).matches(attr) || (n as Element).querySelector(attr) !== null);\n // the root's children the old engine binds or rendered\n const kept = new Set<Node>();\n const top = (n: Node | null): void => {\n while (n !== null && n.parentNode !== root) n = n.parentNode;\n if (n !== null) kept.add(n);\n };\n const range = (v: { headAt(n: Node): Node | null }, anchor: Node): void => {\n for (let n = v.headAt(anchor); n !== null && n !== anchor; n = n.nextSibling) top(n);\n top(anchor);\n };\n for (const bs of C.rootBindings.values()) {\n for (const b of bs) {\n if (b.chain === null) top(b.node);\n else for (const br of b.chain.branches) range(b.chain, br.anchor);\n }\n }\n for (const l of C.rootLists.values()) for (const v of [l.view, ...(l.extra ?? [])]) if (v !== null) range(v, v.anchor);\n for (const n of o.nodes) if (n.parentNode === root && binds(n)) kept.add(n);\n if (kept.size === 0) return false;\n const added = [...root.childNodes].filter((n) => n !== el && !kept.has(n) && !o.nodes.includes(n)\n && (binds(n) || (C.mustache && n.textContent!.includes(\"{{\"))));\n if (added.length > 0) {\n console.warn(`[@wcstack/state] <${o.host.el.localName}>: ${added.length} node(s) added beside the content taken over are not bound.`);\n }\n return true;\n}\n\n/**\n * A new `<wcs-state bind-component>` over the content the old one bound (a component that swapped only\n * its `<wcs-state>`): it takes the scope over, as a reconnection — the old engine's bindings, rows and\n * `{{ }}` anchors are on these nodes. Walking them again would bind nothing (an element walked once is\n * left alone) and read the text the bindings rendered as markup (3.x #417 / #419). Nodes with bindings\n * added since are not bound (takesOver reports them).\n */\nasync function resume(m: Mount, el: HTMLElement, root: Node, built: () => void): Promise<void> {\n // the old element lets go of the engine (its createState no longer reaches the scope)\n (m.el as any).engine = null;\n m.el = el;\n m.component.element = el;\n (el as any).engine = m.component;\n m.nodes = m.nodes.filter((n) => n.parentNode === root);\n // (taken out while it initialized: it hears the host when it is back, as a mount does)\n if (el.isConnected) await reconnect(m, built);\n else built();\n}\n\n/**\n * A mount connected again (or taken over, resume): it hears the host from now on, then\n * `$connectedCallback` — after `built`, for a take-over (getBindingsReady goes on as for a mount).\n */\nasync function reconnect(m: Mount, built?: () => void): Promise<void> {\n register(m, true);\n for (const slot of m.slots) refresh(slot);\n built?.();\n if (m.broken) return;\n // (async: a `$connectedCallback` that throws rejects, as one that rejects does)\n await m.component.callHook(\"$connectedCallback\");\n if (m.host.engine === null && m.el.isConnected) hooks.element?.(m.component, \"connected\");\n}\n\n/** `<wcs-state bind-component=\"prop\">`: claimed instead of becoming a root of its page. */\nexport function claimComponent(el: HTMLElement, root: Node): Claimed | null {\n const prop = el.getAttribute(\"bind-component\");\n // the last claim: a `<wcs-state>` neither a volume nor a DCC definition nor a component is a root\n if (prop === null) return watchRoot(el, root);\n const parent = el.parentNode;\n const shadow = parent instanceof ShadowRoot;\n const host = shadow ? (parent as ShadowRoot).host : parent instanceof Element ? parent : null;\n /** Its mount, from the moment it is made (`$connectedCallback` may still run, or have thrown); null once another `<wcs-state>` took it over. */\n const mine = (): Mount | null => {\n const m = host === null ? undefined : hosts.get(host)?.current;\n return m?.el === el ? m : null;\n };\n // a component that does not mount: the volumes in its shadow root have no tree to graft onto\n const failed = (e: unknown): never => {\n if (shadow) orphan(parent!, el);\n throw e;\n };\n /** Its bindings were built (it mounted, or took a scope over). */\n let bound = false;\n return {\n load() {\n return (host === null || !host.localName.includes(\"-\")\n ? Promise.reject(new Error(`[@wcstack/state] \"bind-component\" requires <${config.tagNames.state}> to be a direct child of a custom element.`))\n : load(el, prop, host, !shadow)).catch(failed);\n },\n async start(state, built) {\n await start(el, host!, shadow ? parent! : host!, state, () => {\n bound = true;\n built();\n }).catch((e) => {\n // (one whose `$connectedCallback` failed is an ordinary mount)\n const m = mine();\n if (!bound && m !== null) m.broken = true;\n return failed(e);\n });\n },\n connected() {\n // a failed `$connectedCallback` is reported as a root's on reconnect is\n const m = mine();\n if (m !== null) reconnect(m).catch((e) => console.error(e));\n // a newer `<wcs-state>` took the scope over: put back where it was, this one takes the scope over\n // again, as a new one would — once the DOM operation that put it back is done (it may take the\n // newer one out), and refused while the newer one is still in\n else if (bound) {\n void Promise.resolve().then(() => {\n if (el.parentNode === parent) return start(el, host!, shadow ? parent! : host!, hosts.get(host!)!.state, () => {});\n }).catch((e) => console.error(e));\n }\n // still waiting for its host's wiring: the host is back (wireLate)\n else if (waiting.has(host!)) wireLate(host!);\n },\n disconnected() {\n const m = mine();\n if (m === null) return;\n register(m, false);\n if (m.broken) return;\n m.component.callHook(\"$disconnectedCallback\");\n if (m.host.engine === null) hooks.element?.(m.component, \"disconnected\");\n },\n reset() {\n raiseError(`re-setting a component's state is not supported: write <${host?.localName}>.${prop} instead.`);\n },\n };\n}\n","/**\n * The scopes add-on (@wcstack/state/features/scopes): `<wcs-state>` elements that are not roots.\n * Volumes (`<wcs-state mount=\"p\">`, src/scopes/volume.ts), Declarative Custom Components\n * (`[data-wc-definition]`, src/scopes/dcc.ts) and component mounts (`<wcs-state\n * bind-component>`, src/scopes/component.ts).\n */\nimport { chain, first, handled, hooks, taken, type Feature } from \"../hooks\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { claimVolume, grafted, guardAncestorWrite, rootEngineCreated, rootMoved } from \"../scopes/volume\";\nimport { claimDcc, dccEngineCreated, dccWritten } from \"../scopes/dcc\";\nimport { claimComponent, componentScope, crossed, guardReadonlyMount, hasMounts, hostBinding } from \"../scopes/component\";\n\nexport const scopes: Feature = {\n name: \"scopes\",\n install(): void {\n hooks.claim = first(taken, hooks.claim, claimVolume);\n hooks.claim = first(taken, hooks.claim, claimDcc);\n // last: what it does not take is a root, which it watches for the volumes (watchRoot)\n hooks.claim = first(taken, hooks.claim, claimComponent);\n hooks.hostBinding = hostBinding;\n hooks.componentScope = componentScope;\n hooks.element = chain(hooks.element, (engine, phase) => {\n if (phase !== \"mounting\") return rootMoved(engine, phase);\n const root = (engine.element as Node).getRootNode();\n rootEngineCreated(engine, root);\n dccEngineCreated(engine, root);\n });\n hooks.written = chain(hooks.written, (engine, p, row, old, value, direct) => {\n dccWritten(engine, p, value, direct);\n crossed(engine, p, row, old, value, direct, false);\n });\n hooks.getterReached = chain(hooks.getterReached, (engine, g, row) => crossed(engine, g, row, undefined, undefined, false, true));\n hooks.beforeWrite = first(handled, hooks.beforeWrite, (engine, p, _row, _value, element) => {\n guardAncestorWrite(engine, p);\n return guardReadonlyMount(engine, p, element);\n });\n // first, before what is installed (in any order) replaces its runtime for the new state:\n // a refused re-set leaves the old state, its watches, streams and keys as they were\n const declared = hooks.declare;\n hooks.declare = (engine, target) => {\n const list = grafted.get(engine);\n if (list !== undefined && list.length > 0) {\n raiseError(`re-setting a root state with grafted volumes (${list.map((v) => v.path).join(\", \")}) is not supported: their data is part of the tree.`);\n }\n if (hasMounts(engine)) raiseError(\"re-setting a root state with mounted components is not supported: they read its data.\");\n declared?.(engine, target);\n };\n },\n};\nexport default scopes;\n"],"mappings":"odAmCA,IAAMA,EAAQ,IAAIC,QAKZC,EAAU,IAAID,QACdE,EAAS,uDAEFC,EAAQ,IAAIC,QAEZC,EAAU,IAAIL,QAErBM,EAAW,CAAC,UAAW,WAAY,QAAS,aAAc,SAAU,YAAa,oBAAqB,mBAAoB,YAAa,aACvIC,EAAU,CAAC,iBAAkB,eAAgB,MAAO,kBACpDC,EAAUC,GAAiB,qBAAqBC,EAAOC,SAASC,gBAAgBH,MAGhFI,EAAY,IAAIC,IAAI,CAAC,UAAW,UAAW,WAAY,cAAe,YAAa,MAAO,aA4B1FC,EAAQC,GAAgDA,GAAGC,SAA8BC,YAAcF,OAAI,EAGjH,SAASG,EAAOC,GACd,IAAMC,EAAIpB,EAAQqB,IAAIF,GACtB,YAAa,IAANC,IAAoBE,MAAMC,QAAQH,IAAMA,EAAEH,WACnD,CAGO,SAASO,EAAkBC,EAAgBN,GAChD,IAAMO,EAAO1B,EAAQqB,IAAIF,GAEzB,GAD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jT,EAAQoB,GAEvB,GAEKsW,GAAQvB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["slots","WeakMap","waiting","ORPHAN","wired","WeakSet","grafted","REJECTED","NOT_RUN","PREFIX","path","config","tagNames","state","PATH_APIS","Set","live","e","element","isConnected","failed","root","w","get","Array","isArray","rootEngineCreated","engine","list","delete","v","graft","release","held","fail","message","report","settle","callLifecycle","name","fn","r","call","chroot","then","has","target","segs","split","at","s","hydrated","prefix","key","Proxy","_t","charCodeAt","proxy","keyPath","rest","set","value","chrootOf","data","defs","seen","o","Object","prototype","getPrototypeOf","getOwnPropertyNames","add","getOwnPropertyDescriptor","next","bind","i","length","p","pattern","slice","join","readData","write","registerAccessors","defineProperties","changed","push","el","orphan","giveUp","claimVolume","getAttribute","problem","every","test","validPath","hasAttribute","bindAttributeName","Map","other","filter","x","lenient","start","console","warn","Promise","resolve","engines","connected","disconnected","reset","raiseError","instances","byEngine","names","n","claimDcc","host","content","document","createDocumentFragment","childNodes","appendChild","cloneNode","mode","tag","includes","customElements","all","out","streams","$stream","keys","members","bindables","commands","d","def","states","pending","ensure","shadow","attachShadow","querySelector","inner","ready","initializePromise","queued","k","Dcc","HTMLElement","this","wcBindable","protocol","version","properties","map","event","getter","inputs","async","connectedCallback","stateElement","defineProperty","configurable","args","apply","q","define","localName","hostBindings","readonlyWiring","before","WIRED","hosts","mounts","index","registered","active","UNWIRED","INERT","headOf","fill","idx","String","hostBinding","b","ro","node","head","documentElement","removeAttribute","wiredInMarkup","heads","setAttribute","prop","values","componentScope","text","RegExp","replace","wireLate","scope","parentElement","E","getRootNode","bound","mountSubtree","warned","warnOnce","own","h","surface","findDescriptor","mountKey","m","whole","H","entries","find","parent","info","synth","C","component","hp","from","row","depth","indexesOf","rowAt","ctx","rr","readUntracked","setter","across","skip","slot","slotCount","mountUnder","outer","through","alive","was","reaches","reached","register","on","byP","byRow","size","exports","answer","exporting","exportAccessors","strategy","invalidate","schedule","cp","last","warnShadowed","exporter","found","tree","read","touch","old","direct","item","arr","resetRow","children","l","sync","syncListsUnder","hooks","written","refresh","forAllRows","lists","into","cpath","some","startsWith","rp","crow","crossed","hr","up","g","exportReached","isUnder","built","loading","loadFeatures","$recursion","current","attr","binds","nodeType","matches","kept","top","parentNode","range","anchor","headAt","nextSibling","bs","rootBindings","chain","br","branches","rootLists","view","extra","nodes","added","mustache","textContent","takesOver","reconnect","resume","Engine","DirtyStrategy","methods","f","_self","Reflect","bindMethods","independent","declared","base","onPatternCreated","made","patterns","drain","inPlace","wire","adopted","adoptScope","mount","drainBinds","watchRendered","enumerable","$stateReadyCallback","callHook","broken","claimComponent","connectedCallbackPromise","catch","watchRoot","ShadowRoot","Element","mine","load","light","a","registryOf","whenDefined","wiring","marked","wiredOnServer","stop","j","onRootFailed","Error","finally","original","error","queueMicrotask","star","indexOf","unregister","ds","getOwnPropertyDescriptors","frozen","isFrozen","writable","create","melt","reject","scopes","install","claim","first","taken","phase","rootMoved","dccEngineCreated","exact","dispatchEvent","CustomEvent","detail","bubbles","dccWritten","getterReached","beforeWrite","handled","_row","_value","guardAncestorWrite","guardReadonlyMount","declare","hasMounts","scopes_default"],"sources":["../../../src/scopes/volume.ts","../../../src/scopes/dcc.ts","../../../src/scopes/component.ts","../../../src/features/scopes.ts"],"sourcesContent":["/**\n * Volumes — `<wcs-state mount=\"p\">` (README \"Mounting Additional State\"). A volume is not a\n * root: its state is grafted onto the root tree at `p` by ordinary writes, its getters and\n * setters become root accessors at `p.<key>`, its methods live at `p.<method>`, and inside all\n * of them — and in its `$connectedCallback` / `$disconnectedCallback` — `this` is chrooted at\n * `p` (`this.x` is the tree's `p.x`). Load order does not matter: a volume that loads before its\n * root grafts when the root engine is created, before the page is bound; if the root fails to\n * initialize, its volumes report it and settle. A root hydrated from a server snapshot (SSR)\n * already holds the volume's data at `p`: the volume adopts it (3.x D14). A volume in a component\n * wired to its host (`data-wcs=\"state…\"`) is refused, whenever it loads (3.x left it pending).\n *\n * Not carried over from @wcstack/state 3.3 (approved simplifications, each an error rather than\n * a silent no-op): injections on the volume element (`data-wcs=\"state.k: …\"`), and a volume's\n * own `$watch` / `$listKeys` / `$renderedCallback` — declare them on the root.\n */\nimport type { Engine } from \"../engine\";\nimport type { Pattern } from \"../pattern\";\nimport type { Claimed } from \"../hooks\";\nimport type { WcsState } from \"../element\";\nimport { config } from \"../config\";\nimport { engines } from \"../dom/mount\";\nimport { raiseError, report } from \"../parser/raiseError\";\n\nexport interface Volume {\n readonly el: HTMLElement;\n readonly root: Node;\n readonly path: string;\n state: Record<string, any> | null;\n engine: Engine | null;\n chroot: object | null;\n /** Settles the element's connectedCallbackPromise. */\n settle: (() => void) | null;\n}\n\n/** Mount paths held on each root (reserved when a volume connects, kept once grafted). */\nconst slots = new WeakMap<Node, Map<string, Volume>>();\n/**\n * Loaded volumes waiting for their root's engine; an element: the root's `<wcs-state>` that failed\n * to initialize (what loads later fails with it while it is in the page: failed()).\n */\nconst waiting = new WeakMap<Node, Volume[] | Element>();\nconst ORPHAN = \"will not graft: the root state failed to initialize.\";\n/** The engines of components wired to their host: they read the host's tree, a volume has none to graft onto. */\nexport const wired = new WeakSet<Engine>();\n/** The volumes grafted onto each engine. */\nexport const grafted = new WeakMap<Engine, Volume[]>();\n\nconst REJECTED = [\"$stream\", \"$streams\", \"$scan\", \"$recursion\", \"$watch\", \"$listKeys\", \"$renderedCallback\", \"$updatedCallback\", \"$behavior\", \"$features\"];\nconst NOT_RUN = [\"$commandTokens\", \"$eventTokens\", \"$on\", \"$errorCallback\"];\nconst PREFIX = (path: string) => `[@wcstack/state] <${config.tagNames.state} mount=\"${path}\">`;\n\n/** `$` APIs that take a state path: inside a volume the path is relative to the mount. */\nconst PATH_APIS = new Set([\"$getAll\", \"$setAll\", \"$resolve\", \"$postUpdate\", \"$dependOn\", \"$eq\", \"$eqIndex\"]);\n\nfunction chrootOf(engine: Engine, prefix: string): object {\n const at = (key: string) => `${prefix}.${key}`;\n return new Proxy({}, {\n get(_t, key) {\n if (typeof key === \"symbol\") return undefined;\n if (key.charCodeAt(0) !== 36) return engine.proxy[at(key)];\n const v = engine.proxy[key];\n if (key === \"$eqPath\") return (path: string, keyPath: string) => v(at(path), at(keyPath));\n return PATH_APIS.has(key) && typeof v === \"function\" ? (path: string, ...rest: unknown[]) => v(at(path), ...rest) : v;\n },\n set(_t, key, value) {\n if (typeof key === \"symbol\") return false;\n engine.proxy[at(key as string)] = value;\n return true;\n },\n });\n}\n\nfunction validPath(path: string): boolean {\n return path !== \"\" && path.split(\".\").every((s) => s !== \"\" && !/[*$#@\\s]/.test(s));\n}\n\n/**\n * An engine whose `<wcs-state>` is in the page: nothing grafts onto one that is out (a root out of the\n * page lets go of its root node; a component whose `<wcs-state>` alone left stays registered).\n */\nconst live = (e: Engine | undefined): Engine | undefined => ((e?.element as Node | undefined)?.isConnected ? e : undefined);\n\n/** The root `<wcs-state>` on `root` failed to initialize, and is still in the page. */\nfunction failed(root: Node): boolean {\n const w = waiting.get(root);\n return w !== undefined && !Array.isArray(w) && w.isConnected;\n}\n\n/** The engine created on `root`: graft the volumes that were waiting for it (before its page is bound). */\nexport function rootEngineCreated(engine: Engine, root: Node): void {\n const list = waiting.get(root);\n waiting.delete(root);\n if (Array.isArray(list)) for (const v of list) graft(v, engine);\n}\n\nfunction release(v: Volume): void {\n const held = slots.get(v.root);\n if (held?.get(v.path) === v) held.delete(v.path);\n}\n\n/**\n * A root engine's `<wcs-state>` left the page (\"disconnected\"), or is back (\"back\"; a component's:\n * \"connected\"). Out, the mount paths its volumes hold let go of it (they are kept on the root node,\n * which outlives the content it bound). Back, and still its root's engine (the core holds the root\n * again unless another `<wcs-state>` bound it meanwhile), the volumes that connected meanwhile graft,\n * and its own hold their paths again — unless another volume took one meanwhile.\n */\nexport function rootMoved(engine: Engine, phase: string): void {\n const list = grafted.get(engine) ?? [];\n if (phase === \"disconnected\") for (const v of list) release(v);\n else if (phase !== \"reset\" && live(engines.get(engine.root!)) === engine) {\n rootEngineCreated(engine, engine.root!);\n for (const v of list) if (!slots.get(v.root)!.has(v.path)) slots.get(v.root)!.set(v.path, v);\n }\n}\n\n/** Reports a volume that will not graft, releases its slot and settles its promise. */\nfunction fail(v: Volume, message: string): void {\n report(`${PREFIX(v.path)} ${message}`);\n release(v);\n v.settle?.();\n v.settle = null;\n}\n\nfunction callLifecycle(v: Volume, name: \"$connectedCallback\" | \"$disconnectedCallback\"): void {\n const fn = v.state?.[name];\n if (typeof fn !== \"function\") return;\n try {\n const r = fn.call(v.chroot);\n if (r !== null && typeof r === \"object\" && typeof r.then === \"function\") r.then(undefined, report);\n } catch (e) {\n report(e);\n }\n}\n\nfunction graft(v: Volume, engine: Engine): void {\n if (wired.has(engine)) return fail(v, \"will not graft: its component is wired to its host.\");\n const state = v.state!;\n const target = engine.target;\n const segs = v.path.split(\".\");\n let at: any = target;\n for (const s of segs) at = at == null ? undefined : at[s];\n // a root hydrated from a server snapshot (ssr/ssr.ts) has the volume's data there already: adopted\n if (at !== undefined && (engine as any).hydrated !== true) return fail(v, `will not graft: the root state already has \"${v.path}\".`);\n const chroot = chrootOf(engine, v.path);\n v.chroot = chroot;\n // the data; accessors and methods (bound to the chroot) apart, as root accessors at `p.<key>`,\n // so that whatever replaces the data (the snapshot, a write of the mount path) keeps them\n const data: Record<string, unknown> = {};\n const defs: PropertyDescriptorMap = {};\n const seen = new Set<string>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const key of Object.getOwnPropertyNames(o)) {\n if (seen.has(key) || key === \"constructor\") continue;\n seen.add(key);\n const { get, set, value } = Object.getOwnPropertyDescriptor(o, key)!;\n if (get !== undefined || set !== undefined) {\n defs[`${v.path}.${key}`] = {\n get: get && function () { return get.call(chroot); },\n set: set && function (next: unknown) { set.call(chroot, next); },\n };\n } else if (key[0] === \"$\") continue;\n else if (typeof value === \"function\") {\n const fn = value.bind(chroot);\n defs[`${v.path}.${key}`] = { get: () => fn };\n } else data[key] = value;\n }\n }\n if (at === undefined) {\n // intermediate objects of a deep mount path, then the volume's own object\n for (let i = 1; i < segs.length; i++) {\n const p = engine.pattern(segs.slice(0, i).join(\".\"));\n if (engine.readData(p, null) == null) engine.write(p, null, {});\n }\n engine.write(engine.pattern(v.path), null, data);\n }\n // registered as the root's own are (a row-level getter gets its cache slot; the paths under\n // them read through them)\n (engine as any).registerAccessors(Object.defineProperties({}, defs));\n for (const path in defs) engine.changed(engine.pattern(path), null);\n v.engine = engine;\n let list = grafted.get(engine);\n if (list === undefined) grafted.set(engine, (list = []));\n list.push(v);\n if (v.el.isConnected) callLifecycle(v, \"$connectedCallback\");\n v.settle?.();\n v.settle = null;\n}\n\n/**\n * A root `<wcs-state>` (the one no claim took; asked by the last, claimComponent): if it fails to\n * initialize, the volumes waiting on `root` settle instead of waiting forever, and so do the ones\n * that load later — and the components waiting there for their wiring (onRootFailed).\n */\nexport function watchRoot(el: HTMLElement, root: Node): null {\n (el as WcsState).connectedCallbackPromise.catch(() => {\n // a root that bound the page (only its $connectedCallback failed), or a stray second one (#47)\n // beside the root that binds it: nothing failed for what waits there\n const live = engines.get(root)?.element as Element | undefined;\n if ((el as WcsState).bound || (live !== undefined && live !== el && live.isConnected)) return;\n orphan(root, el);\n for (const f of giveUp.get(root) ?? []) f();\n });\n return null;\n}\n\n/**\n * The state of `root` failed to initialize (`el`: the page's root, or a component's in its shadow\n * root): the volumes waiting there report it and settle, and so do those that load later while\n * `el` is in the page.\n */\nexport function orphan(root: Node, el: Element): void {\n const list = waiting.get(root);\n if (Array.isArray(list)) for (const v of list) fail(v, ORPHAN);\n waiting.set(root, el);\n}\n\n/** What else waits on a root node's `<wcs-state>` (a component, for the page's wiring). */\nconst giveUp = new WeakMap<Node, Set<() => void>>();\n\n/**\n * Calls `fn` when (or if) the root `<wcs-state>` on `root` fails to initialize; the function\n * returned stops waiting (what `fn` holds is not kept for as long as the page lives).\n */\nexport function onRootFailed(root: Node, fn: () => void): () => boolean {\n if (failed(root)) fn();\n const s = giveUp.get(root) ?? new Set();\n giveUp.set(root, s.add(fn));\n return () => s.delete(fn);\n}\n\n/** `<wcs-state mount=\"p\">`: claimed instead of becoming a root. */\nexport function claimVolume(el: HTMLElement, root: Node): Claimed | null {\n const path = el.getAttribute(\"mount\");\n if (path === null) return null;\n const v: Volume = { el, root, path, state: null, engine: null, chroot: null, settle: null };\n let problem: string | null = null;\n if (!validPath(path)) problem = `has an invalid mount path: it must be a static path (no \"*\", \"$\", \"#\", \"@\").`;\n else if (el.hasAttribute(config.bindAttributeName)) problem = `injections (data-wcs=\"state.<key>: …\") are not supported — read the root path in a root getter.`;\n else {\n let held = slots.get(root);\n if (held === undefined) slots.set(root, (held = new Map()));\n const other = held.get(path);\n // one grafted onto a root that left the page holds it no more, nor does one waiting for its root\n // out of the page (the page's content replaced): that one yields, and never grafts. (One out of\n // the page that no other volume asks for still grafts when its root comes.)\n if (other !== undefined && other !== v && (other.engine === null ? other.el.isConnected : live(other.engine))) {\n problem = `will not graft: another volume already holds \"${path}\".`;\n } else {\n if (other?.engine === null) {\n const list = waiting.get(root);\n if (Array.isArray(list)) waiting.set(root, list.filter((x) => x !== other));\n other.settle?.();\n other.settle = null;\n }\n held.set(path, v);\n }\n }\n return {\n // a volume that cannot load resolves its connectedCallbackPromise (3.x; it reports, as below)\n lenient: true,\n start(state): Promise<void> | void {\n if (problem !== null) return fail(v, problem);\n // (it yielded its slot while it loaded: see above)\n if (slots.get(root)!.get(path) !== v) return;\n for (const key of REJECTED) if (state[key] !== undefined) return fail(v, `${key} is not run in a volume — declare it on the root state.`);\n for (const key of NOT_RUN) if (state[key] !== undefined) console.warn(`${PREFIX(path)} ${key} is not run in a volume (it belongs to the root).`);\n v.state = state;\n return new Promise<void>((resolve) => {\n v.settle = resolve;\n const engine = live(engines.get(root));\n const list = waiting.get(root);\n if (engine !== undefined) graft(v, engine);\n else if (failed(root)) fail(v, ORPHAN);\n else waiting.set(root, [...(Array.isArray(list) ? list : []), v]);\n });\n },\n connected() {\n if (v.engine !== null) callLifecycle(v, \"$connectedCallback\");\n },\n disconnected() {\n // a grafted volume keeps its data and its slot (there is no unmount)\n if (v.engine !== null) callLifecycle(v, \"$disconnectedCallback\");\n },\n reset() {\n raiseError(`re-setting a volume is not supported: its data was copied into the root tree at \"${path}\" — write the paths under it on the root instead.`);\n },\n };\n}\n\n/** A root write that would replace an object a volume is grafted under. */\nexport function guardAncestorWrite(engine: Engine, p: Pattern): void {\n const list = grafted.get(engine);\n if (list === undefined || p.depth !== 0) return;\n for (const { path } of list) {\n if (path.startsWith(`${p.path}.`)) raiseError(`writing \"${p.path}\" would replace the volume grafted at \"${path}\"; write the paths under it instead.`);\n }\n}\n","/**\n * Declarative Custom Components (README \"DCC\"). The `<wcs-state>` inside the shadow root of a\n * `[data-wc-definition]` host is not a root: it defines the host's tag. Each instance gets a\n * copy of the definition's (untouched) shadow content, whose own `<wcs-state>` is an ordinary\n * root with a fresh state. The class's prototype reads and writes that state (writes before it\n * initializes wait for it; methods return Promises); `$bindables` / `$commands` become its\n * `static wcBindable`, and a write to a bindable (or under it, or a `$postUpdate`) dispatches\n * `<tag>:<prop>-changed` from the instance — a notification: `detail` carries the written value\n * only for a write of the member itself, and the declared getter reads the member off the element.\n *\n * The shadow is built on first use — an accessor or the connect, whichever comes first — not in\n * the constructor: a `for` row binds its elements before they are inserted, a parser-made\n * instance has no attributes in its constructor, and the definition host itself (upgraded by\n * define()) already has its shadow.\n */\nimport type { Engine } from \"../engine\";\nimport type { Pattern } from \"../pattern\";\nimport type { Claimed } from \"../hooks\";\nimport { config } from \"../config\";\nimport { raiseError } from \"../parser/raiseError\";\n\ninterface Definition {\n readonly tag: string;\n readonly bindables: readonly string[];\n}\n\n/** DCC instances by host element, and the definition of each instance's inner engine. */\nconst instances = new WeakMap<Element, Definition>();\nconst byEngine = new WeakMap<Engine, { host: Element; def: Definition }>();\n\nfunction names(state: Record<string, any>, key: string): string[] {\n const v = state[key];\n if (v === undefined) return [];\n if (!Array.isArray(v)) raiseError(`${key} must be an array of state member names.`);\n const seen = new Set<string>();\n for (const n of v) {\n if (typeof n !== \"string\" || n === \"\") raiseError(`${key} entries must be non-empty strings.`);\n if (n[0] === \"$\") raiseError(`${key} entry \"${n}\": internal ($) members are never exposed.`);\n if (seen.has(n)) raiseError(`${key} entry \"${n}\" is duplicated.`);\n seen.add(n);\n }\n return v;\n}\n\n/** Every member of the state (own and inherited), by descriptor. */\nfunction members(state: Record<string, any>): Map<string, PropertyDescriptor> {\n const out = new Map<string, PropertyDescriptor>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const key of Object.getOwnPropertyNames(o)) {\n if (key === \"constructor\" || key[0] === \"$\" || out.has(key)) continue;\n out.set(key, Object.getOwnPropertyDescriptor(o, key)!);\n }\n }\n const streams = state.$stream;\n if (streams !== null && typeof streams === \"object\") for (const n of Object.keys(streams)) if (!out.has(n)) out.set(n, { value: undefined });\n return out;\n}\n\nfunction define(tag: string, content: DocumentFragment, mode: ShadowRootMode, state: Record<string, any>): void {\n if (!tag.includes(\"-\")) raiseError(`DCC: <${tag} data-wc-definition> is not a valid custom element name.`);\n if (customElements.get(tag) !== undefined) raiseError(`DCC: <${tag}> is already defined.`);\n const all = members(state);\n const bindables = names(state, \"$bindables\");\n const commands = names(state, \"$commands\");\n for (const n of bindables) {\n const d = all.get(n);\n if (d === undefined) raiseError(`$bindables entry \"${n}\" does not exist on the state.`);\n if (typeof d.value === \"function\") raiseError(`$bindables entry \"${n}\" is a method: list it in $commands.`);\n }\n for (const n of commands) {\n const d = all.get(n);\n if (d === undefined) raiseError(`$commands entry \"${n}\" does not exist on the state.`);\n if (typeof d.value !== \"function\") raiseError(`$commands entry \"${n}\" is not a method: list it in $bindables.`);\n }\n const def: Definition = { tag, bindables };\n /** Each instance's inner `<wcs-state>` (null: a definition host, or content without one). */\n const states = new WeakMap<Element, any>();\n const pending = new WeakMap<Element, [string, unknown][]>();\n /** Builds the instance's shadow once; its inner `<wcs-state>`. */\n const ensure = (el: Element): any => {\n if (states.has(el)) return states.get(el);\n if (el.hasAttribute(\"data-wc-definition\")) return null;\n const shadow = el.attachShadow({ mode });\n shadow.appendChild(content.cloneNode(true));\n const state = shadow.querySelector(config.tagNames.state);\n states.set(el, state);\n instances.set(el, def);\n if (state === null && bindables.length > 0) {\n console.warn(`[@wcstack/state] DCC: <${tag}> declares $bindables but its content has no <${config.tagNames.state}>: no change events.`);\n }\n return state;\n };\n /** The instance's inner engine once its state initialized, else null. */\n const inner = (el: Element): any => ensure(el)?.engine ?? null;\n /** Resolves when the instance's state initialized, before its `$connectedCallback` (and lands the writes queued before). */\n const ready = (el: Element): Promise<void> => Promise.resolve(ensure(el)?.initializePromise).then(() => {\n const queued = pending.get(el);\n pending.delete(el);\n const engine = inner(el);\n if (queued !== undefined && engine !== null) for (const [k, v] of queued) engine.proxy[k] = v;\n });\n\n class Dcc extends HTMLElement {\n static wcBindable = bindables.length === 0 && commands.length === 0 ? null : {\n protocol: \"wc-bindable\", version: 1,\n properties: bindables.map((name) => ({ name, event: `${tag}:${name}-changed`, getter: (e: Event) => (e.target as any)[name] })),\n inputs: bindables.map((name) => ({ name })),\n ...(commands.length === 0 ? {} : { commands: commands.map((name) => ({ name, async: true })) }),\n };\n\n connectedCallback(): void {\n if (ensure(this) !== null) void ready(this);\n }\n\n /** The inner `<wcs-state>` (as in 3.3; builds the shadow if it is not built yet). */\n get stateElement(): HTMLElement | null {\n return ensure(this);\n }\n }\n for (const [name, d] of all) {\n if (typeof d.value === \"function\") {\n Object.defineProperty(Dcc.prototype, name, {\n configurable: true,\n value(this: Element, ...args: unknown[]) {\n return ready(this).then(() => {\n const engine = inner(this);\n return engine === null ? undefined : engine.proxy[name].apply(engine.proxy, args);\n });\n },\n });\n } else {\n Object.defineProperty(Dcc.prototype, name, {\n configurable: true,\n get(this: Element) { return inner(this)?.proxy[name]; },\n set(this: Element, value: unknown) {\n const engine = inner(this);\n if (engine !== null) engine.proxy[name] = value;\n else {\n let q = pending.get(this);\n if (q === undefined) pending.set(this, (q = []));\n q.push([name, value]);\n }\n },\n });\n }\n }\n customElements.define(tag, Dcc);\n}\n\n/** The `<wcs-state>` of a definition host: claimed to define the tag. */\nexport function claimDcc(el: HTMLElement, root: Node): Claimed | null {\n const host = (root as ShadowRoot).host;\n if (host === undefined || !host.hasAttribute(\"data-wc-definition\")) return null;\n // the definition's content, before anything touches it: every instance starts from this\n const content = document.createDocumentFragment();\n for (const n of [...root.childNodes]) content.appendChild(n.cloneNode(true));\n const mode = (root as ShadowRoot).mode;\n return {\n start(state) {\n if (el.hasAttribute(\"bind-component\")) raiseError(\"DCC: a <wcs-state bind-component> cannot define a component (use one mechanism).\");\n define(host.localName, content, mode, state);\n },\n connected() {},\n disconnected() {},\n reset() {\n raiseError(\"re-setting a DCC definition is not supported: each instance loads its own state.\");\n },\n };\n}\n\n/** A root engine was created: an instance's inner state gets its host's change events. */\nexport function dccEngineCreated(engine: Engine, root: Node): void {\n const host = (root as ShadowRoot).host;\n const def = host === undefined ? undefined : instances.get(host);\n if (def !== undefined) byEngine.set(engine, { host, def });\n}\n\n/**\n * A write at a bindable, under it, or its `$postUpdate`: `<tag>:<prop>-changed` from the\n * instance, with the written value as `detail` only for a data write of the member itself.\n */\nexport function dccWritten(engine: Engine, p: Pattern, value: unknown, direct: boolean): void {\n const info = byEngine.get(engine);\n if (info === undefined) return;\n const name = p.path.split(\".\", 1)[0];\n if (!info.def.bindables.includes(name)) return;\n const exact = direct && p.path === name;\n info.host.dispatchEvent(new CustomEvent(`${info.def.tag}:${name}-changed`, { detail: exact ? value : undefined, bubbles: true }));\n}\n","/**\n * Component mounts — `<wcs-state bind-component=\"prop\">` directly inside a custom element\n * (README \"Web Component Binding\"). Each component runs an engine of its own over its state\n * object (the host element's `prop`): its bindings, rows, `$1`, event indexes, getters and\n * private keys are the component's. The host wires it with ordinary property bindings on the\n * element (`state: user`, `state.x: path`, `state: .` in a row); those are taken over as\n * mount entries, and the component reads and writes the mounted keys through the host's\n * engine. Changes cross both ways through the `written` / `getterReached` hooks: the host's\n * reach the components mounted on them, and a component's writes under a mounted key reach\n * the host (and, from there, the other components mounted on the same data).\n *\n * Own keys stay private (rule R1): a key the component declares itself is its own, except a\n * one-segment partial entry, which wins over a data default. Unwired, a Shadow DOM component\n * owns an independent tree; a Light DOM one cannot (it shares the page) and fails loudly.\n *\n * `#ro` on an entry (`state#ro: user`) is honoured as in 3.3: a component's code writing through it\n * throws `[wcs/mount-readonly]`, an element's write-back inside the component is dropped.\n *\n * A whole mount's accessors are exported at the mount point (README \"Exported getters\"): the host\n * reads `user.display` (row by row for `state: .`) from the component mounted there, unless the\n * tree has the key.\n * A mounted component runs no temporal declaration and no `$renderedCallback`, and refuses `$recursion`.\n */\nimport { Engine, rowAt } from \"../engine\";\nimport { WILDCARD, type Pattern } from \"../pattern\";\nimport type { StateRow } from \"../list\";\nimport type { Binding } from \"../dom/view\";\nimport { hooks, loadFeatures, type Claimed } from \"../hooks\";\nimport { config } from \"../config\";\nimport { DirtyStrategy } from \"../strategy/dirty\";\nimport { engines, mount, mountSubtree } from \"../dom/mount\";\nimport { bind, drainBinds } from \"../dom/binder\";\nimport { registryOf } from \"../dom/wc\";\nimport { raiseError, report } from \"../parser/raiseError\";\nimport type { WcsState } from \"../element\";\nimport { onRootFailed, orphan, rootEngineCreated, watchRoot, wired } from \"./volume\";\n\ninterface Entry {\n /** The component-side path (\"\" = the whole state). */\n readonly inner: string;\n /** The host pattern and row (at the pattern's depth) it is mounted on. */\n readonly outer: Pattern;\n readonly row: StateRow | null;\n /** Mounted `#ro`: the component reads it and does not write it. */\n readonly ro: boolean;\n}\n\n/** What a host element keeps across the `<wcs-state>` elements its renders create. */\ninterface Host {\n readonly el: Element;\n readonly prop: string;\n /** The author's state object: the component's private data lives here. */\n readonly state: Record<string, any>;\n /** The host's engine (null: an unwired, independent component). */\n readonly engine: Engine | null;\n readonly entries: Entry[];\n current: Mount | null;\n}\n\ninterface Synth {\n readonly e: Entry;\n readonly p: Pattern;\n readonly row: StateRow | null;\n}\n\ninterface Mount {\n /** Its `<wcs-state>`: a new one that takes the scope over replaces it (resume). */\n el: HTMLElement;\n /** The nodes of the scope root once it was bound: still there, a new `<wcs-state>` takes the scope over. */\n nodes: ChildNode[];\n readonly component: Engine;\n readonly host: Host;\n readonly slots: { m: Mount; e: Entry }[];\n /** Component patterns that read and write the host. */\n readonly synth: Map<Pattern, Synth>;\n registered: boolean;\n /** A mounted key its setter just wrote through the host (its `written` is not forwarded again). */\n skip: Pattern | null;\n /** The entry a change of the component is crossing to the host through: its other entries still take it. */\n from: Entry | null;\n /** Exported accessors (a whole mount's): host pattern (`user.display`) → the component's accessor pattern. */\n exports: Map<Pattern, Pattern> | null;\n /**\n * It failed before its bindings were built (a markup error): what it bound before the error follows\n * the host while it is connected, as a root's does (#384), and no lifecycle hook runs — its\n * `$connectedCallback` never did.\n */\n broken?: boolean;\n}\n\ntype Slot = Mount[\"slots\"][number];\n\n/** Plain property bindings hosts made on custom elements: the candidates for wiring. */\nconst hostBindings = new WeakMap<Element, Binding[]>();\n/** Those of them written with `#ro`. */\nconst readonlyWiring = new WeakSet<Binding>();\n/** An element property's value before a host's first write to it (a mount takes the component's). */\nconst before = new WeakMap<Element, Map<string, unknown>>();\n/** Components waiting for their host to bind the wiring written in its markup. */\nconst waiting = new WeakMap<Element, () => void>();\n/**\n * SSR: a row is a clone of its plan, so the server's output carries no `data-wcs` on a row's\n * elements. A host binding made while rendering on the server writes the heads it binds here\n * instead, so a component whose class is defined before the client adopts the row still waits\n * for its wiring (as it does for `data-wcs`); the client's host binding removes it.\n */\nconst WIRED = \"data-wcs-wired\";\nconst onServer = (): boolean => document.documentElement?.hasAttribute(\"data-wcs-server\") === true;\nconst hosts = new WeakMap<Element, Host>();\nconst mounts = new WeakMap<Engine, Mount>();\n/** Mount entries by host engine, host pattern and host row. */\nconst index = new WeakMap<Engine, Map<Pattern, Map<StateRow | null, Set<Slot>>>>();\nlet registered = 0;\n/** Engines a change is crossing from: it does not come back to them. */\nconst active = new Set<Engine>();\n\nconst UNWIRED = {};\n/** Declarations a mounted component does not run (`$listKeys` runs: it keys the component's own lists). */\nconst INERT = [\"$watch\", \"$stream\", \"$renderedCallback\"];\n\nconst headOf = (path: string): string => path.split(\".\", 1)[0];\n\n/** `a.*.b.*` with [2, 5] → `a.2.b.5`. */\nfunction fill(path: string, idx: number[]): string {\n let i = 0;\n return path.split(\".\").map((s) => (s === WILDCARD ? String(idx[i++]) : s)).join(\".\");\n}\n\n/** The core's hook: a plain property binding on a custom element (before it applies). */\nexport function hostBinding(b: Binding, ro: boolean): boolean {\n const el = b.node as Element;\n const head = headOf(b.name);\n if (!onServer()) el.removeAttribute(WIRED);\n else if (!wiredInMarkup(el, head)) {\n const heads = el.getAttribute(WIRED)?.split(\" \") ?? [];\n if (!heads.includes(head)) el.setAttribute(WIRED, [...heads, head].join(\" \"));\n }\n // the component took its wiring when it loaded: a mount is not re-wired\n if (hosts.get(el)?.prop === head) {\n raiseError(`<${el.localName}>.${head} has loaded its state: the wiring \"${b.name}\" added afterwards cannot reach it — bind the host's wiring before the component loads.`);\n }\n let list = hostBindings.get(el);\n if (list === undefined) hostBindings.set(el, (list = []));\n list.push(b);\n if (ro) readonlyWiring.add(b);\n let values = before.get(el);\n if (values === undefined) before.set(el, (values = new Map()));\n if (!values.has(head)) values.set(head, (el as any)[head]);\n waiting.get(el)?.();\n return false;\n}\n\n/** The core's hook: a Light DOM component's content is bound by its own engine. */\nexport function componentScope(el: Element): boolean {\n return el.localName.includes(\"-\") && el.querySelector(`:scope > ${config.tagNames.state}[bind-component]`) !== null;\n}\n\nfunction wiredInMarkup(host: Element, prop: string): boolean {\n const text = host.getAttribute(config.bindAttributeName);\n return text !== null && new RegExp(`(^|;)\\\\s*${prop.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\s*[.#:]`).test(text);\n}\n\n/**\n * A host whose wiring is in its markup, and which the page did not bind: it was out of the page when\n * the page's state loaded, or was inserted since — by code, not by a `for:` / `if:` (which binds it\n * before inserting it) or the router (which hands it over). Its `<wcs-state>` hands it over as the\n * router does (src/dom/binder.ts): it is bound now, or once its root's state is in the page (it has not\n * loaded yet, or its `<wcs-state>` is out). In a Light DOM component, that component's engine binds it,\n * when it mounts (now, if it has). A host the page did bind is left alone (an element is walked once),\n * and so is one whose root failed before binding the page (onRootFailed refuses the component).\n */\nfunction wireLate(host: Element): void {\n let scope = host.parentElement;\n while (scope !== null && !componentScope(scope)) scope = scope.parentElement;\n const E = engines.get(scope ?? host.getRootNode());\n const el = E?.element as WcsState | undefined;\n // (the binder binds to the page's engine now, or keeps the host for when it is in the page)\n if (el?.isConnected ? el.bound : scope === null) {\n if (scope === null) bind(host);\n else mountSubtree(E!, host);\n }\n}\n\n/** The server's output says the host binds `prop` on this row element (see WIRED). */\nconst wiredOnServer = (host: Element, prop: string): boolean => host.getAttribute(WIRED)?.split(\" \").includes(prop) === true;\n\n/** A frozen author object is copied into a writable one (same prototype). */\nfunction melt(o: Record<string, any>): Record<string, any> {\n const ds = Object.getOwnPropertyDescriptors(o);\n let frozen = Object.isFrozen(o);\n for (const d of Object.values(ds)) if (\"value\" in d && d.writable === false) { d.writable = true; frozen = true; }\n return frozen ? Object.create(Object.getPrototypeOf(o), ds) : o;\n}\n\nasync function load(el: HTMLElement, prop: string, host: Element, light: boolean): Promise<Record<string, any>> {\n const tag = host.localName;\n if ([\"state\", \"src\", \"json\"].some((a) => el.hasAttribute(a)) || el.querySelector('script[type=\"module\"]') !== null) {\n raiseError(`<${config.tagNames.state} bind-component> takes its state from <${tag}>.${prop}: it cannot also load one (state / src / json / an inline script).`);\n }\n await registryOf(host).whenDefined(tag);\n let h = hosts.get(host);\n if (h !== undefined) {\n if (h.prop !== prop) raiseError(`<${tag}> already has a <${config.tagNames.state} bind-component=\"${h.prop}\">.`);\n return h.state;\n }\n const wiring = () => (hostBindings.get(host) ?? []).filter((b) => headOf(b.name) === prop);\n // the host binds its wiring when it renders the element (a row before inserting it; the page\n // when its state loads; a server-rendered row when the client adopts it), or when the\n // element's class is defined — or, written in its markup on a host the page did not bind, now\n const marked = wiredInMarkup(host, prop);\n if (marked && wiring().length === 0) wireLate(host);\n if (wiring().length === 0 && (marked || wiredOnServer(host, prop))) {\n // (if the page's state fails, its wiring never comes)\n let stop!: () => boolean;\n await new Promise<void>((r, j) => {\n waiting.set(host, r);\n stop = onRootFailed(host.getRootNode(), () => j(new Error(`[@wcstack/state] <${tag}>.${prop} will not mount: the root state failed to initialize.`)));\n }).finally(() => stop());\n }\n waiting.delete(host);\n const bs = wiring();\n const values = before.get(host);\n const original = values !== undefined && values.has(prop) ? values.get(prop) : (host as any)[prop];\n if (original === null || typeof original !== \"object\") {\n raiseError(`\"bind-component\": <${tag}>.${prop} must be an object (the component's state), got ${original === null ? \"null\" : typeof original}.`);\n }\n if (bs.length === 0 && light) {\n // reported as an uncaught error, after this element settles (as 3.3 does)\n const error = new Error(`[@wcstack/state] A plain (unwired) Light DOM \"bind-component\" is not supported. Attach a shadow root to <${tag}>, or mount it from the host (${config.bindAttributeName}=\"${prop}: path\").`);\n queueMicrotask(() => { throw error; });\n return UNWIRED;\n }\n const entries: Entry[] = [];\n for (const b of bs) {\n const inner = b.name === prop ? \"\" : b.name.slice(prop.length + 1);\n if (entries.some((e) => e.inner === inner)) raiseError(`<${tag}> maps \"${b.name}\" twice.`);\n const star = inner.split(\".\").indexOf(WILDCARD);\n if (star >= 0) {\n const list = inner.split(\".\").slice(0, star).join(\".\");\n raiseError(`<${tag}> maps \"${b.name}\": the component-side path of a mount cannot contain \"*\"${list === \"\" ? \"\" : ` — map the list itself (\"${prop}.${list}: <the host's list>\")`}.`);\n }\n entries.push({ inner, outer: b.pattern, row: b.row, ro: readonlyWiring.has(b) });\n // the component reads the host from now on: the binding no longer writes the element\n b.engine.unregister(b);\n if (inner !== \"\") delete (host as any)[b.name];\n }\n const state = bs.length === 0 ? melt(original as Record<string, any>) : original as Record<string, any>;\n hosts.set(host, (h = { el: host, prop, state, engine: bs.length === 0 ? null : bs[0].engine, entries, current: null }));\n return state;\n}\n\nconst warned = new Set<string>();\nfunction warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n console.warn(`[@wcstack/state] ${message}`);\n}\n\n/** Whether `key` is the component's own (a data default, an accessor or a method of its state). */\nconst own = (h: Host, key: string): boolean => key in h.state;\n\n/** The component's own surface for `key`: an accessor or a method (a data default is not). */\nfunction surface(h: Host, key: string): boolean {\n const d = findDescriptor(h.state, key);\n return d !== undefined && (d.get !== undefined || d.set !== undefined || typeof d.value === \"function\");\n}\n\n/**\n * The component's patterns that read and write the host: a partial entry's path, and under a\n * whole mount every top-level key the component does not declare itself.\n */\nfunction wire(m: Mount): void {\n const C = m.component;\n const h = m.host;\n const H = h.engine!;\n const tag = h.el.localName;\n const whole = h.entries.find((e) => e.inner === \"\") ?? null;\n for (const e of h.entries) {\n if (e.inner === \"\") continue;\n const head = headOf(e.inner);\n // a one-segment entry wins over a data default; the component's own surface (an accessor,\n // a method) and an own key above a deep entry win over the entry\n if (own(h, head) && (e.inner !== head || surface(h, head))) {\n warnOnce(`${tag}.${e.inner}`, `[wcs/mount-own-key-shadow] <${tag}>: \"${h.prop}.${e.inner}\" is hidden by the component's own \"${head}\"; rename one side.`);\n }\n }\n if (whole !== null) {\n const at = H.readUntracked(whole.outer, whole.row);\n if (at !== null && typeof at === \"object\") {\n for (const key of Object.keys(h.state)) {\n if (key[0] !== \"$\" && key in at && !h.entries.some((e) => e.inner === key)) {\n warnOnce(`${tag}.${key}`, `[wcs/mount-own-key-shadow] <${tag}>: its own \"${key}\" hides \"${whole.outer.path}.${key}\" — remove the default to read the tree, or rename it to keep it private.`);\n }\n }\n }\n }\n const declared = INERT.filter((k) => h.state[k] !== undefined);\n if (declared.length > 0) {\n warnOnce(`${tag}.${h.prop}$`, `[wcs/mount-dollar-declaration] <${tag}>: ${declared.join(\", \")} ${declared.length === 1 ? \"is\" : \"are\"} not run in a mounted component — declare it on the root state.`);\n }\n const base = (C as any).onPatternCreated;\n (C as any).onPatternCreated = (p: Pattern) => {\n mountKey(m, whole, p);\n base.call(C, p);\n };\n // patterns the engine made before (the parents of the component's own accessors): mounted\n // keys among them, then what now reads through them. A snapshot: both loops walk it (a pattern\n // made during the first goes through the wrapped onPatternCreated above).\n const made = [...C.patterns.all()];\n for (const p of made) mountKey(m, whole, p);\n for (const p of made) base.call(C, p);\n // a mount in a host row goes with the row (4.0 discards a removed row's element): it renders no\n // more — what it would read of the row throws (live), its own keys stay readable and writable.\n // So does a mount inside a component that went with its row: it reads the tree through that one.\n const drain = C.drain;\n C.drain = () => {\n if (inPlace(m)) drain.call(C);\n };\n}\n\n/** Every host row a mount reads through is still there: its own, and those of the components it is in. */\nfunction inPlace(m: Mount | undefined): boolean {\n for (; m !== undefined; m = mounts.get(m.host.engine!)) {\n if (m.host.entries.some((e) => e.row !== null && !e.row.alive)) return false;\n }\n return true;\n}\n\n/**\n * `element.state` is the component's proxy, handed out as an object: a function the state declares\n * (a method, or a function-valued key it starts with) read off it always runs on it, whatever `this`\n * it is called with — detached (`const { toggle } = element.state`), as a listener\n * (`button.addEventListener(\"click\", element.state.toggle)`), by a timer — as 3.x's `bind` did\n * (#331; an explicit `call(other)` is ignored, as with `bind`). It is wrapped once per function, in a\n * proxy that keeps the function's properties, statics, `new`, `name` and identity across reads; a\n * function a key comes to hold later, the tree's or its own, is returned as it is. Only reads through\n * the proxy itself are wrapped, not through a view of it (`createStateAsync(\"readonly\")`, whose\n * methods must run on the read-only view). A root's proxy is only lent to a callback, and a volume's\n * methods are bound to its chroot already.\n */\nfunction bindMethods(C: Engine, state: object): void {\n const methods = new Map<unknown, unknown>();\n for (let o: object | null = state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const k of Object.getOwnPropertyNames(o)) {\n const v = Object.getOwnPropertyDescriptor(o, k)!.value;\n if (typeof v === \"function\" && k !== \"constructor\") methods.set(v, null);\n }\n }\n const apply = (f: (...a: unknown[]) => unknown, _self: unknown, args: unknown[]): unknown => Reflect.apply(f, C.proxy, args);\n C.bound = (fn) => {\n let b = methods.get(fn);\n if (b === null) methods.set(fn, (b = new Proxy(fn, { apply })));\n return b;\n };\n}\n\nfunction findDescriptor(o: object, key: string): PropertyDescriptor | undefined {\n for (let x: object | null = o; x !== null && x !== Object.prototype; x = Object.getPrototypeOf(x)) {\n const d = Object.getOwnPropertyDescriptor(x, key);\n if (d !== undefined) return d;\n }\n return undefined;\n}\n\nfunction mountKey(m: Mount, whole: Entry | null, p: Pattern): void {\n if (p.getter !== null) return;\n const h = m.host;\n const H = h.engine!;\n const head = headOf(p.path);\n let e = h.entries.find((x) => x.inner === p.path);\n if (e === undefined && p.parent !== null) return mountUnder(m, p);\n if (p.depth !== 0) return;\n let target: Pattern;\n if (e !== undefined) {\n if (e.inner !== head ? own(h, head) : surface(h, head)) return;\n target = e.outer;\n } else if (whole !== null && p.parent === null && head[0] !== \"$\" && !own(h, head)) {\n e = whole;\n target = H.pattern(`${whole.outer.path}.${head}`);\n } else {\n return;\n }\n const row = e.row;\n const through = e;\n p.getter = () => H.readUntracked(target, live(m, row));\n p.setter = (value: unknown) => {\n across(m, through, () => H.write(target, row, value));\n m.skip = p;\n };\n m.synth.set(p, { e, p: target, row });\n}\n\n/**\n * The host row an entry is mounted on, for reading or writing through it. A removed row is gone\n * for good (4.0 never puts a removed row's element in another row): nothing of it is the\n * component's any more, and the position it had may hold another row now (3.4 #367 / #368).\n */\nfunction live(m: Mount, row: StateRow | null): StateRow | null {\n if (row !== null && !row.alive) raiseError(`The host row of <${m.host.el.localName}> was removed.`);\n return row;\n}\n\n/** Runs a change of component `m` crossing to its host through entry `e`. */\nfunction across(m: Mount, e: Entry, fn: () => void): void {\n const was = active.has(m.component);\n active.add(m.component);\n m.from = e;\n try {\n fn();\n } finally {\n if (!was) active.delete(m.component);\n m.from = null;\n }\n}\n\n/** Whether a change crossing from the component's own entry `from` (or from its host) reaches `slot`. */\nconst reaches = (slot: Slot, reached: boolean): boolean =>\n reached || !active.has(slot.m.component) || (slot.m.from !== null && slot.m.from !== slot.e);\n\n/**\n * A path under a mounted key whose host counterpart is a getter (a host getter, a recursive\n * family): read — and written, if it has a setter — through the host, row by row.\n */\nfunction mountUnder(m: Mount, p: Pattern): void {\n let s: Pattern | null = p.parent;\n let info: Synth | undefined;\n while (s !== null && (info = m.synth.get(s)) === undefined) s = s.parent;\n if (s === null || info === undefined) return;\n const C = m.component;\n const H = m.host.engine!;\n const hp = H.pattern(info.p.path + p.path.slice(s.path.length));\n if (hp.getter === null) return;\n const from = info;\n /**\n * The host row of `hp`: the entry's own row (not the row now at its position), and under it the\n * component's rows (a component path with a `*` of its own).\n */\n const at = (): StateRow | null => {\n const r = live(m, from.row);\n if (p.depth === 0) return r;\n H.resolve(fill(hp.path, [...H.indexesOf(r), ...C.indexesOf(rowAt(C.ctx, p.depth))]), null);\n return (H as any).rr as StateRow | null;\n };\n p.getter = () => {\n const r = at();\n return hp.depth > 0 && r === null ? undefined : H.readUntracked(hp, r);\n };\n if (hp.setter !== null) {\n p.setter = (value: unknown) => {\n const r = at();\n across(m, from.e, () => H.write(hp, r, value));\n m.skip = p;\n };\n }\n if (p.depth > 0) p.slot = (C as any).slotCount++;\n m.synth.set(p, { e: from.e, p: hp, row: from.row });\n}\n\nfunction register(m: Mount, on: boolean): void {\n if (m.registered === on || m.host.engine === null) return;\n m.registered = on;\n registered += on ? 1 : -1;\n const H = m.host.engine;\n let byP = index.get(H);\n if (byP === undefined) index.set(H, (byP = new Map()));\n for (const slot of m.slots) {\n let byRow = byP.get(slot.e.outer);\n if (byRow === undefined) byP.set(slot.e.outer, (byRow = new Map()));\n let set = byRow.get(slot.e.row);\n if (set === undefined) byRow.set(slot.e.row, (set = new Set()));\n if (on) set.add(slot);\n else {\n set.delete(slot);\n if (set.size === 0) byRow.delete(slot.e.row);\n }\n }\n const whole = m.host.entries.find((e) => e.inner === \"\");\n if (whole === undefined) return;\n if (m.exports === null) exportAccessors(m, whole);\n // the host's readers of the exported paths: the component answers them now (a re-set of the\n // host while it was away forgot the answer), or no longer\n for (const hp of m.exports!.keys()) {\n if (on && hp.getter === null) answer(H, hp, whole.outer);\n H.strategy.invalidate(H, hp, whole.row);\n }\n if (m.exports!.size > 0) H.schedule();\n if (on) warnShadowed(m, whole);\n}\n\n// ---------------------------------------------------------------- exported accessors\n\n/** The getters `answer` gave host patterns (a re-set of the host forgets them with its accessors). */\nconst exporting = new WeakSet<object>();\n\n/**\n * README \"Exported getters\": a whole mount's accessors (getters and setters, not methods or\n * private data, no `*` in the name) are read at the mount point. The host's own accessor there\n * wins; a key the tree has wins (`wcs/mount-export-shadowed`).\n */\nfunction exportAccessors(m: Mount, whole: Entry): void {\n const h = m.host;\n const H = h.engine!;\n m.exports = new Map();\n const seen = new Set<string>();\n for (let o: object | null = h.state; o !== null && o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const k of Object.getOwnPropertyNames(o)) {\n if (seen.has(k)) continue;\n seen.add(k);\n const d = Object.getOwnPropertyDescriptor(o, k)!;\n if ((d.get === undefined && d.set === undefined) || k[0] === \"$\" || k.includes(WILDCARD)) continue;\n // a dotted accessor exports only from the component's own data (`form.label`), not the tree's\n const head = headOf(k);\n if (k !== head && !own(h, head)) continue;\n const hp = H.pattern(`${whole.outer.path}.${k}`);\n // the host's own accessor there wins\n if (hp.getter === null) answer(H, hp, whole.outer);\n else if (!exporting.has(hp.getter)) continue;\n m.exports.set(hp, m.component.pattern(k));\n }\n }\n}\n\n/** The mount that exports `hp` at host row `row` (the row at the mount point's depth). */\nfunction exporter(H: Engine, outer: Pattern, row: StateRow | null, hp: Pattern): Mount | null {\n const set = index.get(H)?.get(outer)?.get(row);\n if (set === undefined) return null;\n let found: Mount | null = null;\n for (const slot of set) {\n if (slot.e.inner !== \"\" || slot.m.exports?.has(hp) !== true || slot.m === found) continue;\n if (found !== null) {\n raiseError(`[wcs/mount-export-ambiguous] \"${hp.path}\" is exported by two mounted components on the same instance: <${found.host.el.localName}> and <${slot.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`);\n }\n found = slot.m;\n }\n return found;\n}\n\n/** Makes host pattern `hp` read (and write) the accessor of the component mounted at `outer`, row by row. */\nfunction answer(H: Engine, hp: Pattern, outer: Pattern): void {\n const parent = hp.parent!;\n const last = hp.last;\n /** The tree's object that has the key, or null. */\n const tree = (): any => {\n const o = H.read(parent, H.ctx) as any;\n return o !== null && typeof o === \"object\" && last in o ? o : null;\n };\n hp.getter = () => {\n const o = tree();\n if (o !== null) return o[last];\n const m = exporter(H, outer, H.ctx, hp);\n return m === null ? undefined : m.component.read(m.exports!.get(hp)!, null);\n };\n exporting.add(hp.getter);\n hp.setter = (value: unknown) => {\n const o = tree();\n const m = o === null ? exporter(H, outer, H.ctx, hp) : null;\n if (m === null) {\n // no component answers it here: the tree's own key\n const at = H.read(parent, H.ctx) as any;\n if (at !== null && typeof at === \"object\") at[last] = value;\n return;\n }\n const cp = m.exports!.get(hp)!;\n if (findDescriptor(m.host.state, cp.path)?.set === undefined) {\n raiseError(`Cannot write to \"${cp.path}\" on mounted <${m.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`);\n }\n m.component.write(cp, null, value);\n };\n if (hp.depth > 0) hp.slot = H.slotCount++;\n}\n\nfunction warnShadowed(m: Mount, whole: Entry): void {\n const H = m.host.engine!;\n for (const [hp, cp] of m.exports!) {\n const o = H.readUntracked(hp.parent!, whole.row) as any;\n if (o === null || typeof o !== \"object\" || !(hp.last in o)) continue;\n const tag = m.host.el.localName;\n warnOnce(`${tag}|${hp.path}`, `[wcs/mount-export-shadowed] <${tag}>.${m.host.prop}.${cp.path} is exported at \"${hp.path}\" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`);\n }\n}\n\n/** A component's exported accessor was reached (it may now differ): so are the host's readers of it. */\nfunction exportReached(m: Mount, g: Pattern): void {\n const whole = m.host.entries.find((e) => e.inner === \"\")!;\n const H = m.host.engine!;\n for (const [hp, cp] of m.exports!) {\n if (cp !== g) continue;\n H.strategy.invalidate(H, hp, whole.row);\n H.schedule();\n }\n}\n\n/**\n * The `beforeWrite` hook: a component's write through a `#ro` entry, or through an entry whose\n * host row is gone. Code (a method, `element.state`, `$setAll` / `$resolve`) is refused; an\n * element's write-back (a two-way input in the component) is dropped, as `#ro` on that binding\n * would (@wcstack/state 3.3).\n */\nexport function guardReadonlyMount(E: Engine, p: Pattern, element: boolean): boolean {\n const m = mounts.get(E);\n if (m === undefined) return false;\n let info: Synth | undefined;\n for (let s: Pattern | null = p; s !== null && info === undefined; s = s.parent) info = m.synth.get(s);\n if (info === undefined) return false;\n const e = info.e;\n // the host's row went away (an await outlived it): the write has nowhere to land (3.3.x)\n const gone = e.row !== null && !e.row.alive;\n if (!gone && !e.ro) return false;\n if (element) return true;\n live(m, e.row);\n raiseError(`[wcs/mount-readonly] <${m.host.el.localName}> cannot write \"${p.path}\": it is mounted read-only (\"${m.host.prop}${e.inner === \"\" ? \"\" : `.${e.inner}`}#ro: ${e.outer.path}\"). Write it on the host, or drop #ro from the mount.`);\n}\n\n/** A host engine that has components mounted on it: its state cannot be re-set. */\nexport function hasMounts(engine: Engine): boolean {\n const byP = index.get(engine);\n if (byP === undefined) return false;\n for (const byRow of byP.values()) if (byRow.size > 0) return true;\n return false;\n}\n\n/**\n * Applies a change another engine made to shared data: the lists under it re-sync (an\n * element's row takes the array's new element), hooks see it, dependents update.\n */\nfunction touch(E: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n if (p.getter !== null) {\n E.strategy.invalidate(E, p, row);\n E.schedule();\n return;\n }\n if (p.last === WILDCARD) {\n if (row === null) return;\n row.item = (row.list.arr as unknown[])[row.index];\n E.strategy.resetRow(row);\n if (row.children !== null) for (const l of row.children.values()) E.sync(l);\n } else {\n (E as any).syncListsUnder(p, row);\n }\n hooks.written?.(E, p, row, old, value, direct);\n E.changed(p, row);\n}\n\n/** The value an entry is mounted on may have been replaced: every key read through it is stale. */\nfunction refresh(slot: Slot): void {\n const C = slot.m.component;\n for (const [p, s] of slot.m.synth) {\n if (s.e !== slot.e) continue;\n if (p.depth === 0) C.strategy.invalidate(C, p, null);\n else C.forAllRows(p.lists[p.depth]!, (r) => C.strategy.invalidate(C, p, r));\n }\n C.schedule();\n}\n\n/** A host change at or under an entry: the component's path under the mounted key. */\nfunction into(slot: Slot, q: Pattern, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n const rest = p.path.slice(q.path.length);\n if (rest === \"\") return refresh(slot);\n const m = slot.m;\n const C = m.component;\n let cpath: string;\n if (slot.e.inner === \"\") {\n cpath = rest.slice(1);\n const head = headOf(cpath);\n // the component keeps it private, or a partial entry maps it elsewhere (the longest prefix wins)\n if (head[0] === \"$\" || own(m.host, head) || m.host.entries.some((x) => x.inner !== \"\" && (cpath === x.inner || cpath.startsWith(`${x.inner}.`)))) return;\n } else {\n cpath = slot.e.inner + rest;\n }\n const idx: number[] = [];\n for (let k = q.depth + 1; k <= p.depth; k++) idx.push(rowAt(row, k)!.index);\n C.resolve(fill(cpath, idx), null);\n const cp = (C as any).rp as Pattern;\n const crow = (C as any).rr as StateRow | null;\n if (cp.depth > 0 && crow === null) return;\n touch(C, cp, crow, old, value, direct);\n}\n\n/** A component's write under a mounted key: the host's path, with the host row's indexes first. */\nfunction up(m: Mount, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean): void {\n let s: Pattern | null = p;\n let info: Synth | undefined;\n while (s !== null && (info = m.synth.get(s)) === undefined) s = s.parent;\n if (s === null || info === undefined) return; // private data\n const H = m.host.engine!;\n if (s === p && m.skip === p) {\n m.skip = null; // its setter wrote through the host\n return;\n }\n // its host row went away (a write there is refused; `$postUpdate` is not a write): the position\n // it had may hold another row now\n if (info.row !== null && !info.row.alive) return;\n const idx = [...H.indexesOf(info.row), ...m.component.indexesOf(row)];\n H.resolve(fill(info.p.path + p.path.slice(s.path.length), idx), null);\n const hp = (H as any).rp as Pattern;\n const hr = (H as any).rr as StateRow | null;\n if (hp.depth > 0 && hr === null) return;\n across(m, info.e, () => touch(H, hp, hr, old, value, direct));\n}\n\n/**\n * The `written` / `getterReached` hook: a change in engine E crosses to the host it is mounted\n * on (a write, not a getter reached) and to the components mounted on it. A write does not come\n * back to the engines it is crossing from; a getter reached does — it only invalidates, and the\n * components a write started in read the host's getters too.\n */\nexport function crossed(E: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean, reached: boolean): void {\n if (registered === 0) return;\n const was = active.has(E);\n active.add(E);\n try {\n const m = mounts.get(E);\n if (!reached && m !== undefined && m.registered && !active.has(m.host.engine!)) up(m, p, row, old, value, direct);\n if (reached && m !== undefined && m.registered && m.exports !== null) exportReached(m, p);\n const byP = index.get(E);\n if (byP === undefined) return;\n for (const [q, byRow] of byP) {\n if (p.isUnder(q)) {\n const set = byRow.get(q.depth === 0 ? null : rowAt(row, q.depth));\n if (set !== undefined) for (const slot of [...set]) if (reaches(slot, reached)) into(slot, q, p, row, old, value, direct);\n } else if (q.isUnder(p)) {\n for (const [r, set] of [...byRow]) {\n if (p.depth !== 0 && rowAt(r, p.depth) !== row) continue;\n for (const slot of [...set]) if (reaches(slot, reached)) refresh(slot);\n }\n }\n }\n } finally {\n if (!was) active.delete(E);\n }\n}\n\nasync function start(el: HTMLElement, host: Element, root: Node, state: Record<string, any>, built: () => void): Promise<void> {\n if (state === UNWIRED) return;\n // the add-ons its `$features` names, before anything reads the host's current mount\n const loading = loadFeatures(state);\n if (loading) await loading;\n const h = hosts.get(host)!;\n // a mounted engine is never \"mounting\": its `$recursion` would run half set up — refused, as in a volume\n if (h.engine && state.$recursion) {\n raiseError(`[wcs/mount-dollar-declaration] <${host.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);\n }\n const old = h.current;\n if (old !== null && old.el !== el && old.el.isConnected) {\n raiseError(`<${host.localName}> already has a connected <${config.tagNames.state} bind-component=\"${h.prop}\">.`);\n }\n if (old !== null) register(old, false);\n if (old !== null && takesOver(old, el, root)) return resume(old, el, root, built);\n const C = new Engine(state, new DirtyStrategy());\n C.element = el;\n (el as any).engine = C;\n bindMethods(C, state);\n const m: Mount = { el, nodes: [], component: C, host: h, slots: [], synth: new Map(), registered: false, skip: null, from: null, exports: null };\n for (const e of h.entries) m.slots.push({ m, e });\n h.current = m;\n mounts.set(C, m);\n const independent = h.engine === null;\n if (!independent) {\n wire(m);\n register(m, true);\n // the volumes in it are refused (graft), those that loaded first and those that load later\n wired.add(C);\n rootEngineCreated(C, root);\n } else {\n hooks.element?.(C, \"mounting\");\n }\n // a Light DOM component in a server-rendered page takes the server's nodes of its content (F33)\n const adopted = hooks.adoptScope?.(root, C);\n mount(C, root as ShadowRoot | Element);\n adopted?.();\n m.nodes = [...root.childNodes];\n drainBinds();\n if (independent) C.watchRendered();\n Object.defineProperty(host, h.prop, { configurable: true, enumerable: true, get: () => C.proxy });\n const ready = (host as any).$stateReadyCallback;\n if (typeof ready === \"function\") {\n try {\n const r = ready.call(host, h.prop);\n if (r !== null && typeof r === \"object\" && typeof r.then === \"function\") r.then(undefined, report);\n } catch (e) {\n report(e);\n }\n }\n // the bindings are built: what waits for them goes on, whatever $connectedCallback does (as a root)\n built();\n // taken out while it initialized: it hears the host, and runs `$connectedCallback`, when it is back\n if (!el.isConnected) {\n register(m, false);\n return;\n }\n await C.callHook(\"$connectedCallback\");\n if (independent && el.isConnected) hooks.element?.(C, \"connected\");\n}\n\n/**\n * Whether a new `<wcs-state bind-component>` takes the scope of the old mount `o` over (resume)\n * instead of binding its root afresh: when nodes the old engine bound or rendered are still in the\n * root (it swapped only its `<wcs-state>`). A kept `<style>`, whitespace or other nodes without\n * bindings do not count: content rendered again, its `<wcs-state>` included, is bound afresh. Nodes\n * with bindings added since next to kept bound ones (the old engine cannot take them, a new one\n * cannot take the kept ones) are reported.\n */\nfunction takesOver(o: Mount, el: Node, root: Node): boolean {\n // (a `<wcs-state>` in another root of the host finds none of the old nodes there)\n const C = o.component;\n const attr = `[${config.bindAttributeName}]`;\n const binds = (n: Node): boolean => n.nodeType === 1 && ((n as Element).matches(attr) || (n as Element).querySelector(attr) !== null);\n // the root's children the old engine binds or rendered\n const kept = new Set<Node>();\n const top = (n: Node | null): void => {\n while (n !== null && n.parentNode !== root) n = n.parentNode;\n if (n !== null) kept.add(n);\n };\n const range = (v: { headAt(n: Node): Node | null }, anchor: Node): void => {\n for (let n = v.headAt(anchor); n !== null && n !== anchor; n = n.nextSibling) top(n);\n top(anchor);\n };\n for (const bs of C.rootBindings.values()) {\n for (const b of bs) {\n if (b.chain === null) top(b.node);\n else for (const br of b.chain.branches) range(b.chain, br.anchor);\n }\n }\n for (const l of C.rootLists.values()) for (const v of [l.view, ...(l.extra ?? [])]) if (v !== null) range(v, v.anchor);\n for (const n of o.nodes) if (n.parentNode === root && binds(n)) kept.add(n);\n if (kept.size === 0) return false;\n const added = [...root.childNodes].filter((n) => n !== el && !kept.has(n) && !o.nodes.includes(n)\n && (binds(n) || (C.mustache && n.textContent!.includes(\"{{\"))));\n if (added.length > 0) {\n console.warn(`[@wcstack/state] <${o.host.el.localName}>: ${added.length} node(s) added beside the content taken over are not bound.`);\n }\n return true;\n}\n\n/**\n * A new `<wcs-state bind-component>` over the content the old one bound (a component that swapped only\n * its `<wcs-state>`): it takes the scope over, as a reconnection — the old engine's bindings, rows and\n * `{{ }}` anchors are on these nodes. Walking them again would bind nothing (an element walked once is\n * left alone) and read the text the bindings rendered as markup (3.x #417 / #419). Nodes with bindings\n * added since are not bound (takesOver reports them).\n */\nasync function resume(m: Mount, el: HTMLElement, root: Node, built: () => void): Promise<void> {\n // the old element lets go of the engine (its createState no longer reaches the scope)\n (m.el as any).engine = null;\n m.el = el;\n m.component.element = el;\n (el as any).engine = m.component;\n m.nodes = m.nodes.filter((n) => n.parentNode === root);\n // (taken out while it initialized: it hears the host when it is back, as a mount does)\n if (el.isConnected) await reconnect(m, built);\n else built();\n}\n\n/**\n * A mount connected again (or taken over, resume): it hears the host from now on, then\n * `$connectedCallback` — after `built`, for a take-over (getBindingsReady goes on as for a mount).\n */\nasync function reconnect(m: Mount, built?: () => void): Promise<void> {\n register(m, true);\n for (const slot of m.slots) refresh(slot);\n built?.();\n if (m.broken) return;\n // (async: a `$connectedCallback` that throws rejects, as one that rejects does)\n await m.component.callHook(\"$connectedCallback\");\n if (m.host.engine === null && m.el.isConnected) hooks.element?.(m.component, \"connected\");\n}\n\n/** `<wcs-state bind-component=\"prop\">`: claimed instead of becoming a root of its page. */\nexport function claimComponent(el: HTMLElement, root: Node): Claimed | null {\n const prop = el.getAttribute(\"bind-component\");\n // the last claim: a `<wcs-state>` neither a volume nor a DCC definition nor a component is a root\n if (prop === null) return watchRoot(el, root);\n const parent = el.parentNode;\n const shadow = parent instanceof ShadowRoot;\n const host = shadow ? (parent as ShadowRoot).host : parent instanceof Element ? parent : null;\n /** Its mount, from the moment it is made (`$connectedCallback` may still run, or have thrown); null once another `<wcs-state>` took it over. */\n const mine = (): Mount | null => {\n const m = host === null ? undefined : hosts.get(host)?.current;\n return m?.el === el ? m : null;\n };\n // a component that does not mount: the volumes in its shadow root have no tree to graft onto\n const failed = (e: unknown): never => {\n if (shadow) orphan(parent!, el);\n throw e;\n };\n /** Its bindings were built (it mounted, or took a scope over). */\n let bound = false;\n return {\n load() {\n return (host === null || !host.localName.includes(\"-\")\n ? Promise.reject(new Error(`[@wcstack/state] \"bind-component\" requires <${config.tagNames.state}> to be a direct child of a custom element.`))\n : load(el, prop, host, !shadow)).catch(failed);\n },\n async start(state, built) {\n await start(el, host!, shadow ? parent! : host!, state, () => {\n bound = true;\n built();\n }).catch((e) => {\n // (one whose `$connectedCallback` failed is an ordinary mount)\n const m = mine();\n if (!bound && m !== null) m.broken = true;\n return failed(e);\n });\n },\n connected() {\n // a failed `$connectedCallback` is reported as a root's on reconnect is\n const m = mine();\n if (m !== null) reconnect(m).catch(report);\n // a newer `<wcs-state>` took the scope over: put back where it was, this one takes the scope over\n // again, as a new one would — once the DOM operation that put it back is done (it may take the\n // newer one out), and refused while the newer one is still in\n else if (bound) {\n void Promise.resolve().then(() => {\n if (el.parentNode === parent) return start(el, host!, shadow ? parent! : host!, hosts.get(host!)!.state, () => {});\n }).catch(report);\n }\n // still waiting for its host's wiring: the host is back (wireLate)\n else if (waiting.has(host!)) wireLate(host!);\n },\n disconnected() {\n const m = mine();\n if (m === null) return;\n register(m, false);\n if (m.broken) return;\n m.component.callHook(\"$disconnectedCallback\");\n if (m.host.engine === null) hooks.element?.(m.component, \"disconnected\");\n },\n reset() {\n raiseError(`re-setting a component's state is not supported: write <${host?.localName}>.${prop} instead.`);\n },\n };\n}\n","/**\n * The scopes add-on (@wcstack/state/features/scopes): `<wcs-state>` elements that are not roots.\n * Volumes (`<wcs-state mount=\"p\">`, src/scopes/volume.ts), Declarative Custom Components\n * (`[data-wc-definition]`, src/scopes/dcc.ts) and component mounts (`<wcs-state\n * bind-component>`, src/scopes/component.ts).\n */\nimport { chain, first, handled, hooks, taken, type Feature } from \"../hooks\";\nimport { raiseError } from \"../parser/raiseError\";\nimport { claimVolume, grafted, guardAncestorWrite, rootEngineCreated, rootMoved } from \"../scopes/volume\";\nimport { claimDcc, dccEngineCreated, dccWritten } from \"../scopes/dcc\";\nimport { claimComponent, componentScope, crossed, guardReadonlyMount, hasMounts, hostBinding } from \"../scopes/component\";\n\nexport const scopes: Feature = {\n name: \"scopes\",\n hooks,\n install(): void {\n hooks.claim = first(taken, hooks.claim, claimVolume);\n hooks.claim = first(taken, hooks.claim, claimDcc);\n // last: what it does not take is a root, which it watches for the volumes (watchRoot)\n hooks.claim = first(taken, hooks.claim, claimComponent);\n hooks.hostBinding = hostBinding;\n hooks.componentScope = componentScope;\n hooks.element = chain(hooks.element, (engine, phase) => {\n if (phase !== \"mounting\") return rootMoved(engine, phase);\n const root = (engine.element as Node).getRootNode();\n rootEngineCreated(engine, root);\n dccEngineCreated(engine, root);\n });\n hooks.written = chain(hooks.written, (engine, p, row, old, value, direct) => {\n dccWritten(engine, p, value, direct);\n crossed(engine, p, row, old, value, direct, false);\n });\n hooks.getterReached = chain(hooks.getterReached, (engine, g, row) => crossed(engine, g, row, undefined, undefined, false, true));\n hooks.beforeWrite = first(handled, hooks.beforeWrite, (engine, p, _row, _value, element) => {\n guardAncestorWrite(engine, p);\n return guardReadonlyMount(engine, p, element);\n });\n // first, before what is installed (in any order) replaces its runtime for the new state:\n // a refused re-set leaves the old state, its watches, streams and keys as they were\n const declared = hooks.declare;\n hooks.declare = (engine, target) => {\n const list = grafted.get(engine);\n if (list !== undefined && list.length > 0) {\n raiseError(`re-setting a root state with grafted volumes (${list.map((v) => v.path).join(\", \")}) is not supported: their data is part of the tree.`);\n }\n if (hasMounts(engine)) raiseError(\"re-setting a root state with mounted components is not supported: they read its data.\");\n declared?.(engine, target);\n };\n },\n};\nexport default scopes;\n"],"mappings":"2dAmCA,IAAMA,EAAQ,IAAIC,QAKZC,EAAU,IAAID,QACdE,EAAS,uDAEFC,EAAQ,IAAIC,QAEZC,EAAU,IAAIL,QAErBM,EAAW,CAAC,UAAW,WAAY,QAAS,aAAc,SAAU,YAAa,oBAAqB,mBAAoB,YAAa,aACvIC,EAAU,CAAC,iBAAkB,eAAgB,MAAO,kBACpDC,EAAUC,GAAiB,qBAAqBC,EAAOC,SAASC,gBAAgBH,MAGhFI,EAAY,IAAIC,IAAI,CAAC,UAAW,UAAW,WAAY,cAAe,YAAa,MAAO,aA4B1FC,EAAQC,GAAgDA,GAAGC,SAA8BC,YAAcF,OAAI,EAGjH,SAASG,EAAOC,GACd,IAAMC,EAAIpB,EAAQqB,IAAIF,GACtB,YAAa,IAANC,IAAoBE,MAAMC,QAAQH,IAAMA,EAAEH,WACnD,CAGO,SAASO,EAAkBC,EAAgBN,GAChD,IAAMO,EAAO1B,EAAQqB,IAAIF,GAEzB,GADAnB,EAAQ2B,OAAOR,GACXG,MA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CGvQMwY,CAAmBvX,EAAQkD,GDojB1B,SAA4BgI,EAAWhI,EAAY3D,GACxD,IAEI4M,EAFEN,EAAIxC,EAAOzJ,IAAIsL,GACrB,QAAU,IAANW,EAAiB,OAAO,EAE5B,QAAStK,EAAoB2B,EAAS,OAAN3B,QAAuB,IAAT4K,EAAoB5K,EAAIA,EAAE2K,EAAQC,EAAON,EAAEO,GAAMxM,IAAI2B,GACnG,QAAa,IAAT4K,EAAoB,OAAO,EAC/B,IAAM7M,EAAI6M,EAAK7M,EAGf,SADuB,OAAVA,EAAEmN,GAAiBnN,EAAEmN,EAAIe,KACxBlO,EAAE2K,QACZ1K,IACJF,GAAKwM,EAAGvM,EAAEmN,QACVpH,EAAW,yBAAyBwG,EAAElG,KAAK/B,GAAGmF,4BAA4B7F,EAAEnE,iCAAoC8M,EAAElG,KAAK8E,KAAmB,KAAZnL,EAAEgI,EAAe,GAAK,IAAIhI,EAAEgI,WAAehI,EAAEgO,GAAMvO,2DACnL,CChkBayY,CAAmBxX,EAAQkD,EAAG3D,KAIvC,IAAM0T,EAAWxD,EAAMgI,GACvBhI,EAAMgI,GAAU,CAACzX,EAAQmB,KACvB,IAAMlB,EAAOtB,EAAQiB,IAAII,QACZ,IAATC,GAAsBA,EAAKgD,OAAS,GACtCoC,EAAW,iDAAiDpF,EAAKiI,IAAK/H,GAAMA,EAAEpB,GAAMsE,KAAK,4DD2jB1F,SAAmBrD,GACxB,IAAM8N,EAAMxE,EAAM1J,IAAII,GACtB,QAAY,IAAR8N,EAAmB,OAAO,EAC9B,QAAWC,KAASD,EAAIpD,SAAU,GAAIqD,EAAMC,KAAO,EAAG,OAAO,EAC7D,OAAO,CACT,CC9jBU0J,CAAU1X,IAASqF,EAAW,yFAClC4N,IAAWjT,EAAQmB,GAEvB,GAEKwW,GAAQvB","ignoreList":[]}
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
/** An add-on entry: `installFeatures([temporal, diagnostics])` before the state is defined. */
|
|
17
17
|
interface Feature {
|
|
18
18
|
readonly name: string;
|
|
19
|
+
/** The slots of the build it comes from: it fills only those (the core checks they are its own). */
|
|
20
|
+
readonly hooks: object;
|
|
19
21
|
install(): void;
|
|
20
22
|
}
|
|
21
23
|
|