@velarscript/web 0.33.0 → 0.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @velarscript/web
2
2
 
3
- **VelarScript 0.33.0 · Web surface `web@0.14`.** The counter is what a project
3
+ **VelarScript 0.33.1 · Web surface `web@0.14`.** The counter is what a project
4
4
  declares in `velar.json`'s `surfaces` and what a mismatch is refused by; the
5
5
  release number every toolchain package steps to says only what you installed.
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-sources.generated.d.ts","sourceRoot":"","sources":["../src/runtime-sources.generated.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,gt+BAAgt+B,CAAC;AAElv+B,kFAAkF;AAClF,eAAO,MAAM,2BAA2B,0vWAA0vW,CAAC;AAEnyW,eAAO,MAAM,2BAA2B,kkDAAkkD,CAAC;AAE3mD,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,QAAyE,CAAC;AAE7G,eAAO,MAAM,mBAAmB,QAAos5E,CAAC;AAEru5E;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAyH,CAAC;AAE7J;;;GAGG;AACH,eAAO,MAAM,mCAAmC,QAA8H,CAAC;AAE/K;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,idAAid,CAAC;AAEtf,eAAO,MAAM,kBAAkB,QAAiC,CAAC;AAEjE,yFAAyF;AACzF,eAAO,MAAM,6BAA6B,+1HAA01H,CAAC;AAEr4H,4DAA4D;AAC5D,eAAO,MAAM,wCAAwC,8vEAA8vE,CAAC;AAEpzE,gHAAgH;AAChH,eAAO,MAAM,mCAAmC,QAAolB,CAAC;AAEroB,eAAO,MAAM,wBAAwB,orfAAorf,CAAC;AAE1tf,eAAO,MAAM,2BAA2B,i/VAAi/V,CAAC;AAE1hW,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,wntBAAwntB,CAAC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jC,CAAC;AAE5kC,eAAO,MAAM,iBAAiB,QAA2qB,CAAC;AAE1sB,eAAO,MAAM,cAAc,QAAq44C,CAAC;AAEj64C,eAAO,MAAM,gBAAgB,QAA8n/B,CAAC;AAE5p/B,eAAO,MAAM,eAAe,QAA84hC,CAAC;AAE36hC,eAAO,MAAM,kBAAkB,QAAyxqB,CAAC;AAEzzqB,eAAO,MAAM,kBAAkB,QAAwy2B,CAAC;AAEx02B,eAAO,MAAM,gBAAgB,QAAgrN,CAAC;AAE9sN,eAAO,MAAM,mBAAmB,QAAgxN,CAAC;AAEjzN,eAAO,MAAM,eAAe,kuFAAkuF,CAAC;AAE/vF,sGAAsG;AACtG,eAAO,MAAM,qBAAqB,qYAAqY,CAAC;AAExa,eAAO,MAAM,iCAAiC,+GAA+G,CAAC;AAE9J,eAAO,MAAM,4CAA4C,owCAAowC,CAAC;AAE9zC,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,soHAAsoH,CAAC;AAE3qH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAo9nG,CAAC"}
@@ -12,7 +12,7 @@ export const WEB_REACTIVITY_HOST_RUNTIME = "const __velarGraphNativeObject = glo
12
12
  export const WEB_ERROR_HOST_RUNTIME_BODY = "const __velarWebErrorNativeObject = globalThis.Object;\nconst __velarWebErrorNativeNumber = globalThis.Number;\nconst __velarWebErrorNativePromise = globalThis.Promise;\nconst __velarWebErrorOwnSymbolsOperation = Object.getOwnPropertyDescriptor(Object, \"getOwnPropertySymbols\")?.value;\nconst __velarWebErrorFreezeOperation = Object.getOwnPropertyDescriptor(Object, \"freeze\")?.value;\nconst __velarWebErrorFiniteOperation = Object.getOwnPropertyDescriptor(Number, \"isFinite\")?.value;\nconst __velarWebErrorPromisePrototype = Object.getOwnPropertyDescriptor(__velarWebErrorNativePromise, \"prototype\")?.value;\nconst __velarWebErrorThenOperation = __velarWebErrorPromisePrototype\n ? Object.getOwnPropertyDescriptor(__velarWebErrorPromisePrototype, \"then\")?.value\n : null;\nfunction __velarWebErrorOwnSymbols(value) {\n return __velarErrorApply(__velarWebErrorOwnSymbolsOperation, __velarWebErrorNativeObject, [value], \"Object.getOwnPropertySymbols\");\n}\nfunction __velarWebErrorFreeze(value) {\n return __velarErrorApply(__velarWebErrorFreezeOperation, __velarWebErrorNativeObject, [value], \"Object.freeze\");\n}\nfunction __velarWebErrorFinite(value) {\n return __velarErrorApply(__velarWebErrorFiniteOperation, __velarWebErrorNativeNumber, [value], \"Number.isFinite\");\n}\nfunction __velarObservePromise(value, onRejected) {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) return null;\n try { return __velarErrorApply(__velarWebErrorThenOperation, value, [undefined, onRejected], \"Promise.then\"); }\n catch { return null; }\n}\n";
13
13
  /** Error normalization plus the Web-owned promise and freeze operations layered on it. */
14
14
  export const WEB_ERROR_HOST_RUNTIME = VELAR_ERROR_NORMALIZATION_RUNTIME + "\n" + WEB_ERROR_HOST_RUNTIME_BODY;
15
- export const WEB_FOUNDATION_BODY = "const __velarRuntimeKey = Symbol.for(\"velar.runtime.v1\");\nconst __velarFoundationReflectApply = Object.getOwnPropertyDescriptor(Reflect, \"apply\")?.value;\nconst __velarFoundationQueueMicrotask = globalThis.queueMicrotask;\nconst __velarFoundationSetTimeout = globalThis.setTimeout;\nconst __velarFoundationDate = globalThis.Date;\nconst __velarFoundationDateNow = typeof __velarFoundationDate === \"function\"\n ? Object.getOwnPropertyDescriptor(__velarFoundationDate, \"now\")?.value\n : null;\nconst __velarFoundationConsole = globalThis.console ?? null;\nconst __velarFoundationConsoleError = __velarFoundationConsole !== null\n ? Object.getOwnPropertyDescriptor(__velarFoundationConsole, \"error\")?.value ?? null\n : null;\n// D114 WB-D1 (CO-I6 on the Web face): the host-frame policy has one\n// implementation, `__velarHostErrorTrace` in packages/compiler/runtime/error.js,\n// and this is one of its callers rather than a third writer of the same\n// sentence. Reading `error.stack` here printed exactly the two classes of frame\n// that policy exists to hide -- the runtime's own `__velar` helpers and Node's\n// internals -- with no \"(N frames hidden; ...)\" line and no answer to\n// `velar run --stack`, which is the launcher path's promise repeated on a\n// channel that did not keep it. The message-only fallback this used to spell a\n// second time is that function's own second answer.\n//\n// The name arrives with the error-normalization runtime: an inlined Web program\n// carries it in `WEB_ERROR_HOST_RUNTIME`, and a project build imports it beside\n// `normalizeError` (packages/web/src/emit/runtime-imports.ts).\nfunction __velarFoundationTrace(error) {\n if (typeof __velarFoundationConsoleError !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") return;\n let trace = \"An unhandled VelarScript failure was reported\";\n try { trace = __velarHostErrorTrace(error, trace); } catch {}\n try { __velarFoundationReflectApply(__velarFoundationConsoleError, __velarFoundationConsole, [\"Unhandled VelarScript error report: \" + trace]); } catch {}\n}\nfunction __velarEnqueue(callback) {\n if (typeof __velarFoundationQueueMicrotask !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") {\n throw new TypeError(\"The browser queueMicrotask API is unavailable\");\n }\n return __velarFoundationReflectApply(__velarFoundationQueueMicrotask, globalThis, [callback]);\n}\nfunction __velarNow() {\n if (typeof __velarFoundationDateNow !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") {\n throw new TypeError(\"The browser Date.now API is unavailable\");\n }\n return __velarFoundationReflectApply(__velarFoundationDateNow, __velarFoundationDate, []);\n}\nconst __velarRuntimeFields = Object.freeze([\n \"version\", \"domQueue\", \"watchQueue\", \"flushPending\", \"activeObserver\", \"errorHandlers\",\n \"actionFailures\", \"unhandledFailures\", \"lookSources\", \"classSources\", \"dependencies\", \"rawToProxy\", \"proxyToRaw\",\n \"versions\", \"parents\", \"toRaw\", \"reactive\", \"track\", \"trackDeep\", \"trigger\", \"versionOf\",\n \"collectionRead\", \"collectionTrigger\", \"collectionUnlink\", \"trackSubscribers\", \"runTracked\", \"cleanupObserver\", \"computed\",\n \"schedule\", \"report\", \"applyLook\", \"installLook\",\n]);\n\nfunction __velarRuntimeCollection(value, kind) {\n try {\n if (kind === \"Set\") __velarGraphSetContains(value, value);\n else if (kind === \"WeakSet\") __velarGraphWeakSetContains(value, value);\n else __velarGraphWeakMapContains(value, value);\n return true;\n } catch { return false; }\n}\n\nfunction __velarReportOptions(value) {\n if (value === undefined) value = {};\n if (!value || typeof value !== \"object\" || __velarGraphIsList(value) || !__velarGraphIsRecord(value)\n || __velarWebErrorOwnSymbols(value).length > 0) {\n throw new TypeError(\"VelarScript error report options must be a record\");\n }\n const allowed = __velarGraphCreateSet([\"phase\", \"detail\", \"component\", \"unhandled\"]);\n const output = { phase: \"runtime\", detail: \"\", component: \"\", unhandled: false };\n for (const name of __velarGraphOwnNames(value)) {\n if (!__velarGraphSetContains(allowed, name)) throw new TypeError(\"Unknown VelarScript error report option '\" + name + \"'\");\n const descriptor = __velarGraphOwnDescriptor(value, name);\n if (!descriptor || !(\"value\" in descriptor)) throw new TypeError(\"VelarScript error report options cannot use accessors\");\n const next = descriptor.value;\n if (name === \"unhandled\") {\n if (typeof next !== \"boolean\") throw new TypeError(\"VelarScript error report unhandled must be bool\");\n output.unhandled = next;\n } else {\n if (typeof next !== \"string\") throw new TypeError(\"VelarScript error report \" + name + \" must be a string\");\n const maximum = name === \"phase\" ? 256 : name === \"component\" ? 1024 : 65536;\n if (next.length > maximum) throw new RangeError(\"VelarScript error report \" + name + \" is too long\");\n output[name] = next;\n }\n }\n return output;\n}\n\n// D90 R21: the number stamped on each observer when it is created, and the\n// order the flush runs the watch tier in -- execution order is the order the\n// author wrote the watches, and \"wrote\" spans more than one file: watches of\n// one module register as that module initializes, instances of one component\n// register as they mount, and modules register in the order the import graph\n// initializes them. Every one of those is registration order, so one counter\n// answers all three.\n//\n// It has to be application-wide, not per module. Each emitted module carries\n// its own copy of this runtime, so a module-scope counter would restart at zero\n// in the second module and the two modules' watches would compare equal. The\n// counter therefore lives on one global slot every copy reads, the same way the\n// runtime registry itself does.\nconst __velarObserverSequenceKey = Symbol.for(\"velar.web.observer.sequence.v1\");\nconst __velarObserverSequenceCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarObserverSequenceKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web observer sequence ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0];\n __velarGraphDefine(globalThis, __velarObserverSequenceKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\nfunction __velarNextObserverSequence() {\n __velarObserverSequenceCell[0] += 1;\n return __velarObserverSequenceCell[0];\n}\n\n\n// D114 P6 item 4 (LC-C1): how many `tick()` promises are waiting on the flush\n// right now.\n//\n// The charter says an unowned flush failure surfaces at `tick()`. That was only\n// true off the browser: in a browser the runtime threw the failure from a\n// microtask, which the host error event catches and the page survives, and the\n// awaiting `tick()` resolved as though the update had been fine -- so\n// `velar/web-test` stepped silently over a broken update in the one host\n// `tick()` is documented for. An awaiting caller is a claimant: when one is\n// waiting, the failure is parked for it and it rejects; when none is, the\n// failure goes to the host as before.\n//\n// The count lives on one global slot for the reason the observer sequence does:\n// each emitted module carries its own copy of this runtime, the `tick()` that\n// waits and the flush that fails can be in two of them, and a module-scope\n// counter would let the second copy answer \"nobody is waiting\" while the first\n// one is.\nconst __velarTickWaitKey = Symbol.for(\"velar.web.tick.waiters.v1\");\nconst __velarTickWaitCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarTickWaitKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web tick ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0];\n __velarGraphDefine(globalThis, __velarTickWaitKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\nfunction __velarTickWaiting() {\n return __velarTickWaitCell[0] > 0;\n}\n\nfunction __velarEnterTickWait() {\n __velarTickWaitCell[0] += 1;\n}\n\nfunction __velarLeaveTickWait() {\n if (__velarTickWaitCell[0] > 0) __velarTickWaitCell[0] -= 1;\n}\n" + "// D114 W/A1, as narrowed by W2: the identity a flush stamps its run counts\n// with, and the budget those runs spend. They belong to one host *task* -- but\n// the window follows work an observer started, and nothing else.\n//\n// A cycle that crosses a microtask boundary -- 'watch x: detach step()', where\n// 'step' awaits an already-resolved Promise and then writes 'x' -- is a fresh\n// flush every round, so a budget that reset per flush never saw it: two\n// observer runs, well inside 100,000, forever. Flushes chained through\n// microtasks therefore share one token, one budget and one leaders list, and\n// the macrotask sentinel below closes the window. Work that resumes after a\n// timer, an event or network I/O is a new task and opens a fresh window, which\n// is what keeps an animation that writes state every frame from being stopped.\n//\n// W2: a flush continues the open window only once an observer run inside it has\n// started asynchronous work -- a 'detach' statement, or an 'action' call, made\n// while an observer was running. Those are the two ways a synchronous observer\n// body reaches a later microtask, so they are the only ways the ring above can\n// be closed; a chain of flushes with none of them in it has no cycle to find. A\n// bulk import loop that writes a progress counter and awaits promise-only work\n// per row runs millions of observers in one uninterrupted task and is not a\n// runaway, so each of its flushes gets the fresh budget it had before W. The\n// sentinel still closes every window at the task boundary, so the animation\n// case is protected either way.\n//\n// The overrun's carried token is the same rule seen from one flush earlier: an\n// overrun schedules its continuation as a microtask, so that continuation is\n// this same task and continues these same counts by construction. It carries\n// them whether or not an observer started anything, because the continuation is\n// the overrun's own unfinished work rather than a new write.\nconst __velarFlushBudgetPerTask = 100000;\nlet __velarFlushToken = null;\nlet __velarFlushBudget = 0;\n// One-shot, consumed by the next settle: the flush an overrun scheduled\n// continues the window it was scheduled from, whatever that window recorded.\nlet __velarFlushCarried = false;\n// One sentinel is enough for a window: the first one to fire closes it, and\n// arming a second on every flush would leave a timer per flush behind.\nlet __velarTaskSentinelArmed = false;\n\n// The two facts W2 needs live on one global slot, for the same reason the\n// observer sequence above does: every emitted module carries its own copy of\n// this runtime, and the two ends of the question are in different copies. The\n// settle that asks it belongs to whichever copy created the registry -- in an\n// application that imports velar/app, that is velar/app's -- while the places\n// that answer it, a 'detach' statement's detached-task helper and an action's\n// run, are emitted into the application module. Two module-scope variables\n// would never meet.\n//\n// Slot 0 is how deep the settle currently is inside 'observer.run()'. It is a\n// depth rather than a flag because an observer created by a running one runs\n// nested. '__velarRuntime.activeObserver' cannot stand in for it: a watch body\n// runs untracked, precisely so its own reads do not become dependencies of the\n// watched expression, so the active observer is null exactly where the 'detach'\n// that closes a cycle is written.\n//\n// Slot 1 is the fact recorded on the open window: an observer run in it started\n// asynchronous work.\nconst __velarAsyncWorkKey = Symbol.for(\"velar.web.observer.asyncwork.v1\");\nconst __velarAsyncWorkCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarAsyncWorkKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web observer async-work ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0, false];\n __velarGraphDefine(globalThis, __velarAsyncWorkKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\n// What the two compiler-owned lowering points call: the detached-task helper a\n// 'detach' statement lowers to, where a detached Promise enters the runtime,\n// and an action's run, where an action call does. Outside an observer run there\n// is nothing to record -- an action a handler or '@main' starts is the host\n// task's own work, not a ring an observer closed -- so the same unconditional\n// call is correct at both sites.\nfunction __velarNoteAsyncWork() {\n if (__velarAsyncWorkCell[0] > 0) __velarAsyncWorkCell[1] = true;\n return null;\n}\n\nfunction __velarCloseTaskWindow() {\n __velarTaskSentinelArmed = false;\n __velarFlushToken = null;\n __velarAsyncWorkCell[1] = false;\n return null;\n}\n\n// The macrotask boundary the run-count window ends at. 'setTimeout' is the one\n// scheduling operation every host this runtime supports publishes -- page,\n// worker, and the Node process a 'velar test' run drives the emitted runtime\n// in -- and it is captured at module initialization like every other ambient\n// operation here. A host that publishes none is not left without a gate: the\n// window then closes as soon as the flush chain comes to rest, which is the\n// per-flush budget this runtime had before, so the synchronous cycles stay\n// covered and only the asynchronous one goes back to being invisible.\nfunction __velarArmTaskSentinel() {\n if (__velarTaskSentinelArmed) return true;\n if (typeof __velarFoundationSetTimeout !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") return false;\n __velarTaskSentinelArmed = true;\n try { __velarFoundationReflectApply(__velarFoundationSetTimeout, globalThis, [__velarCloseTaskWindow, 0]); }\n catch { __velarTaskSentinelArmed = false; return false; }\n return true;\n}\n\n// The three observers that have run most in the task window running now, kept\n// as the run counts are stamped rather than reconstructed afterwards: the queue at\n// the moment the budget runs out holds only whichever half of a cycle has not\n// just run, so it cannot name the ring on its own. An observer that has run\n// once is not a candidate, which is every observer of an ordinary flush.\nconst __velarFlushLeaders = [];\n\nfunction __velarFlushLead(observer) {\n let kept = 0;\n for (let index = 0; index < __velarFlushLeaders.length; index += 1) {\n if (__velarFlushLeaders[index] === observer) continue;\n __velarFlushLeaders[kept] = __velarFlushLeaders[index];\n kept += 1;\n }\n __velarFlushLeaders.length = kept;\n let position = kept;\n while (position > 0 && __velarFlushLeaders[position - 1].flushRuns < observer.flushRuns) {\n __velarFlushLeaders[position] = __velarFlushLeaders[position - 1];\n position -= 1;\n }\n __velarFlushLeaders[position] = observer;\n if (__velarFlushLeaders.length > 3) __velarFlushLeaders.length = 3;\n}\n\n// D90 R21: compile time no longer refuses two watches that write one state, so\n// this budget is the only gate left against a mutual-write cycle -- and a\n// report that names nobody hands the author a number with no line to go to.\n// The observers that ran most in this flush chain are the cycle; flushRuns\n// already counts exactly that, so the highest few are named. A watch's label is\n// its subject as the author spelled it, which in a write cycle is also the\n// state each watch is reacting to, and the scope it was registered in supplies\n// the component the report has always had a field for.\n//\n// Nothing here asks who wrote what. That question is gone from the language,\n// and answering it would need the write frames R21 deleted.\nfunction __velarFlushRunaway(stalled, token) {\n const ranked = [];\n const seen = __velarGraphCreateSet();\n const consider = (observer) => {\n if (observer.flushToken !== token || __velarGraphSetContains(seen, observer)) return;\n __velarGraphSetInsert(seen, observer);\n ranked[ranked.length] = observer;\n };\n // A cycle alternates, so the queue at the instant the budget ran out holds\n // only the half of the ring that has not just run. The leaders carry the\n // other half.\n for (let index = 0; index < __velarFlushLeaders.length; index += 1) consider(__velarFlushLeaders[index]);\n for (let index = 0; index < stalled.length; index += 1) consider(stalled[index]);\n __velarGraphOrder(ranked, (left, right) => right.flushRuns - left.flushRuns);\n const limit = ranked.length < 3 ? ranked.length : 3;\n let detail = \"\";\n let component = \"\";\n for (let index = 0; index < limit; index += 1) {\n const observer = ranked[index];\n const named = observer.mode === \"watch\" && typeof observer.label === \"string\" && observer.label !== \"\"\n ? \"the watch on '\" + observer.label + \"'\"\n : \"a \" + observer.mode + \" observer\";\n detail += (detail === \"\" ? \"Ran most in this task: \" : \", \") + named\n + \" (\" + observer.flushRuns + (observer.flushRuns === 1 ? \" run)\" : \" runs)\");\n if (component === \"\" && typeof observer.component === \"string\") component = observer.component;\n }\n return { detail, component };\n}\n\nfunction __velarScheduleFlush() {\n if (__velarRuntime.flushPending) return;\n __velarRuntime.flushPending = true;\n __velarEnqueue(__velarFlush);\n}\n\n// Only the observers that actually re-entered the queue during the overrun\n// belong to the runaway cycle. An observer queued once by an unrelated write\n// in the same turn is innocent, and stopping it is irreversible, so it is\n// put back for the next microtask instead.\n//\n// Every overrun must still remove something, or the requeue turns the\n// microtask chain into the freeze the budget exists to end: a cycle spread\n// across more observers than the budget can run four times over re-enters\n// none of them four times, so a fixed threshold of four stops nobody and the\n// next flush repeats it forever. Two rules make the progress unconditional.\n// The threshold falls to the highest run count actually present, so any\n// queued observer this flush chain has already run is stopped; and the token\n// is carried into the flush the overrun schedules, so run counts accumulate\n// across the chain and the observers the chain has not reached yet are a\n// pool that only shrinks.\nfunction __velarFlushOverflow(token) {\n const stalled = [];\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) stalled[stalled.length] = observer;\n for (const observer of __velarGraphSetItems(__velarRuntime.watchQueue)) stalled[stalled.length] = observer;\n __velarGraphSetEmpty(__velarRuntime.domQueue);\n __velarGraphSetEmpty(__velarRuntime.watchQueue);\n let threshold = 0;\n for (let index = 0; index < stalled.length; index += 1) {\n const observer = stalled[index];\n if (observer.flushToken === token && observer.flushRuns > threshold) threshold = observer.flushRuns;\n }\n if (threshold > 4) threshold = 4;\n let requeued = false;\n for (let index = 0; index < stalled.length; index += 1) {\n const observer = stalled[index];\n if (threshold > 0 && observer.flushToken === token && observer.flushRuns >= threshold) {\n if (typeof observer.stop === \"function\") observer.stop();\n else observer.stopped = true;\n continue;\n }\n if (observer.stopped) continue;\n __velarGraphSetInsert(observer.mode === \"watch\" ? __velarRuntime.watchQueue : __velarRuntime.domQueue, observer);\n requeued = true;\n }\n const runaway = __velarFlushRunaway(stalled, token);\n // The window keeps its token and its run counts -- the requeued flush is one\n // more flush of the same task, and the pool of observers it has not reached\n // yet only shrinks -- but the budget is granted again. Without that, the\n // exhausted count would trip the very next flush of the same task, and the\n // observers stopped for it would be whatever was queued at that moment: the\n // innocent ones this overrun just put back, or an unrelated later write.\n __velarFlushBudget = __velarFlushBudgetPerTask;\n __velarFlushCarried = requeued;\n __velarRuntime.report(new RangeError(\"Reactive updates cannot run more than \" + __velarFlushBudgetPerTask + \" observers in one task\"),\n { phase: \"update\", detail: runaway.detail, component: runaway.component, unhandled: true });\n if (requeued) __velarScheduleFlush();\n}\n\n// The one entry point: the microtask __velarScheduleFlush enqueues, and the\n// synchronous drain the emitted tick() performs. It used to open and close D90\n// R1-a-scope's flush-scoped writer registry around the settle; R21 deleted the\n// registry with the referee that read it, so the name is all that remains and\n// it remains because __velarEnqueue and tick() both hold it.\n//\n// D114 W/A1: it is also where the task window is closed or handed on. Both\n// entries pass through here, including tick()'s drain, so the sentinel is armed\n// once per window however the flush was reached, and a host without a timer\n// falls back to closing the window here, one flush at a time.\nfunction __velarFlush() {\n try { __velarFlushSettle(); }\n // Without a timer the window closes as soon as the chain comes to rest,\n // which is the per-flush budget this runtime had before -- except that a\n // flush already scheduled keeps it open, so an overrun's carried counts and\n // the queues a settle could not finish reach the flush that continues them.\n finally { if (!__velarArmTaskSentinel() && !__velarRuntime.flushPending) __velarCloseTaskWindow(); }\n}\n\n// Glitch-free order: every derived value and every watch settles to a fixed\n// point before a single DOM node is written, so no watch and no rendered\n// position can read a half-updated world and no corrective watch can push an\n// invalid value through the DOM first. That is D90 R1 and it is unchanged.\n//\n// D90 R21 changed the other axis. Within the settle the watches run in\n// registration order -- source order in a module, mount order across instances\n// of one component, module-initialization order across modules -- and a watch\n// that writes state is not promoted ahead of one that only observes. Whoever is\n// written first runs first, two watches writing one state both take effect in\n// that order, and a later write that clobbers an earlier one is the author's.\n//\n// Queue insertion order is not registration order and cannot stand in for it:\n// two watches on two different states, both dirtied by one action, enter the\n// queue in the order the action wrote the states. So each pass takes the queue\n// as it stands and runs it by sequence number. Watches queued by this pass are\n// picked up by the next one, in their own order.\n//\n// D114 W/A1, narrowed by W2: a flush that starts while the task window is still\n// open continues it -- the same token, so flushRuns keeps accumulating on every\n// observer, the same leaders, and the same remaining budget -- but only when an\n// observer run in that window started asynchronous work, or when the overrun\n// itself scheduled this flush. Every other flush opens a new window, which is\n// the per-flush budget this runtime had before W.\nfunction __velarFlushSettle() {\n __velarRuntime.flushPending = false;\n const carried = __velarFlushCarried;\n __velarFlushCarried = false;\n if (__velarFlushToken === null || !(carried || __velarAsyncWorkCell[1])) {\n __velarFlushToken = {};\n __velarFlushBudget = __velarFlushBudgetPerTask;\n __velarFlushLeaders.length = 0;\n __velarAsyncWorkCell[1] = false;\n }\n const token = __velarFlushToken;\n const step = (observer) => {\n __velarGraphSetRemove(observer.mode === \"watch\" ? __velarRuntime.watchQueue : __velarRuntime.domQueue, observer);\n if (observer.flushToken === token) observer.flushRuns += 1;\n else { observer.flushToken = token; observer.flushRuns = 1; }\n if (observer.flushRuns > 1) __velarFlushLead(observer);\n // The span the two lowering points ask about. It is the run itself rather\n // than the whole settle: work started by the flush's own bookkeeping is\n // not an observer's, and a nested observer created by a running one is.\n __velarAsyncWorkCell[0] += 1;\n try { observer.run(); }\n finally { __velarAsyncWorkCell[0] -= 1; }\n };\n while (__velarGraphSetCount(__velarRuntime.domQueue) || __velarGraphSetCount(__velarRuntime.watchQueue)) {\n while (true) {\n let ran = false;\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) {\n if (observer.mode !== \"computed\") continue;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n ran = true;\n }\n if (ran) continue;\n const pending = [];\n for (const observer of __velarGraphSetItems(__velarRuntime.watchQueue)) pending[pending.length] = observer;\n __velarGraphOrder(pending, (left, right) => left.sequence - right.sequence);\n for (let index = 0; index < pending.length; index += 1) {\n const observer = pending[index];\n // A watch this pass already re-ran or stopped is no longer queued; the\n // snapshot is a plan, and the queue is what says whether it still owes\n // a run.\n if (observer.stopped || !__velarGraphSetContains(__velarRuntime.watchQueue, observer)) continue;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n ran = true;\n }\n if (!ran) break;\n }\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) {\n if (observer.mode === \"computed\") break;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n }\n }\n if (__velarGraphSetCount(__velarRuntime.domQueue) || __velarGraphSetCount(__velarRuntime.watchQueue)) __velarScheduleFlush();\n}\n\n" + "function __velarCreateRuntime() {\n const runtime = Object.create(null);\n const domQueue = Object.freeze(__velarGraphCreateSet());\n const watchQueue = Object.freeze(__velarGraphCreateSet());\n const errorHandlers = Object.freeze(__velarGraphCreateSet());\n const unhandledFailures = Object.freeze(__velarGraphCreateSet());\n const actionFailures = Object.freeze(__velarGraphCreateWeakSet());\n const lookSources = Object.freeze(__velarGraphCreateWeakMap());\n const classSources = Object.freeze(__velarGraphCreateWeakMap());\n const dependencies = Object.freeze(__velarGraphCreateWeakMap());\n const rawToProxy = Object.freeze(__velarGraphCreateWeakMap());\n const proxyToRaw = Object.freeze(__velarGraphCreateWeakMap());\n const versions = Object.freeze(__velarGraphCreateWeakMap());\n const parents = Object.freeze(__velarGraphCreateWeakMap());\n const subscriptionStops = __velarGraphCreateWeakMap();\n const collectionBrands = __velarGraphCreateWeakMap();\n const iterateKey = Symbol.for(\"velar.reactive.iterate.v1\");\n const structureKey = Symbol.for(\"velar.reactive.structure.v1\");\n const deepKey = Symbol.for(\"velar.reactive.deep.v1\");\n let lookImplementation = null;\n const toRaw = (value) => {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) return value;\n return __velarGraphWeakMapRead(proxyToRaw, value) ?? value;\n };\n const trackSubscribers = (subscribers) => {\n const observer = runtime.activeObserver;\n if (!observer || observer.stopped) return;\n __velarGraphSetInsert(subscribers, observer);\n __velarGraphSetInsert(observer.dependencies, subscribers);\n };\n const runTracked = (observer, read) => {\n const previousDependencies = observer.dependencies;\n // Every run needs a second dependency set to diff against, and an observer\n // that re-runs thousands of times per second would otherwise allocate one\n // per run. The emptied previous set is kept as the next run's buffer.\n const spare = observer.spareDependencies;\n observer.spareDependencies = null;\n observer.dependencies = spare ?? __velarGraphCreateSet();\n const previousObserver = runtime.activeObserver;\n runtime.activeObserver = observer;\n try { return read(); }\n finally {\n runtime.activeObserver = previousObserver;\n for (const subscribers of __velarGraphSetItems(previousDependencies)) {\n if (__velarGraphSetContains(observer.dependencies, subscribers)) continue;\n // A stop fires exactly when an actual removal empties the set. Firing\n // on an already-empty set would let two detaching computeds whose\n // cleanups have not yet emptied their dependency sets re-trigger each\n // other without bound.\n if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {\n const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);\n if (stop) stop();\n }\n }\n __velarGraphSetEmpty(previousDependencies);\n observer.spareDependencies = previousDependencies;\n }\n };\n const cleanupObserver = (observer) => {\n for (const subscribers of __velarGraphSetItems(observer.dependencies)) {\n if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {\n const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);\n if (stop) stop();\n }\n }\n __velarGraphSetEmpty(observer.dependencies);\n };\n const track = (target, key) => {\n target = toRaw(target);\n if ((typeof target !== \"object\" && typeof target !== \"function\") || target === null) return;\n let byKey = __velarGraphWeakMapRead(dependencies, target);\n if (!byKey) { byKey = __velarGraphCreateMap(); __velarGraphWeakMapWrite(dependencies, target, byKey); }\n let subscribers = __velarGraphMapRead(byKey, key);\n if (!subscribers) {\n subscribers = __velarGraphCreateSet();\n __velarGraphMapWrite(byKey, key, subscribers);\n const ownedSubscribers = subscribers;\n __velarGraphWeakMapWrite(subscriptionStops, subscribers, () => {\n if (__velarGraphMapRead(byKey, key) !== ownedSubscribers) return;\n __velarGraphMapRemove(byKey, key);\n if (__velarGraphMapCount(byKey) === 0) __velarGraphWeakMapRemove(dependencies, target);\n });\n }\n trackSubscribers(subscribers);\n };\n // P2b-9: the path a write travelled, in the words the author would recognise.\n // Only the shape is named -- never a value -- because this reaches a report.\n // The kind travels beside the phrase rather than being read back out of it:\n // the reader of this is the runaway report, and it decides which remedy to\n // give from the kind, not by looking inside a sentence.\n const describeSubject = (target, key) => {\n const container = __velarGraphIsList(target) ? \"List\" : __velarGraphIsRecord(target) ? \"record\" : \"collection\";\n if (key === iterateKey || key === structureKey) return { kind: \"collection\", text: \"the size or contents of a \" + container };\n if (key === deepKey) return { kind: \"value\", text: \"a nested value of a \" + container };\n if (typeof key === \"number\") return { kind: \"value\", text: \"element \" + key + \" of a \" + container };\n if (typeof key === \"string\") return { kind: \"value\", text: \"field '\" + key + \"'\" };\n return { kind: \"value\", text: \"a tracked value\" };\n };\n const notify = (target, key) => {\n const byKey = __velarGraphWeakMapRead(dependencies, target);\n const subscribers = byKey ? __velarGraphMapRead(byKey, key) : null;\n if (subscribers) for (const observer of __velarGraphSetItems(subscribers)) {\n // A write that lands while its own reader is still running is the\n // self-invalidating shape, and it is the only one whose path is worth\n // describing -- so the description is built there and nowhere else, which\n // keeps every ordinary write to one property read on this path. The\n // observer's own budget owns the report; this only tells it what to name.\n if (observer.running) {\n const subject = describeSubject(target, key);\n observer.selfInvalidationSubject = subject.text;\n observer.selfInvalidationKind = subject.kind;\n }\n observer.notify();\n }\n };\n const bump = (target) => {\n __velarGraphWeakMapWrite(versions, target, (__velarGraphWeakMapRead(versions, target) ?? 0) + 1);\n };\n const trigger = (target, key, iterate = false, structure = false, indexFrom = null, allKeys = false) => {\n target = toRaw(target);\n if ((typeof target !== \"object\" && typeof target !== \"function\") || target === null) return;\n bump(target);\n notify(target, key);\n if (allKeys || indexFrom !== null) {\n const byKey = __velarGraphWeakMapRead(dependencies, target);\n if (byKey) for (const candidate of __velarGraphMapKeyItems(byKey)) {\n if (candidate === key) continue;\n if (allKeys || (typeof candidate === \"number\" && candidate >= indexFrom)) notify(target, candidate);\n }\n }\n if (iterate) notify(target, iterateKey);\n if (structure) notify(target, structureKey);\n notify(target, deepKey);\n const owners = __velarGraphWeakMapRead(parents, target);\n // A mutation of an unowned value -- the overwhelmingly common case -- must\n // not pay for the cycle bookkeeping that only an ancestor walk needs.\n if (!owners) return;\n const visited = __velarGraphCreateSet();\n __velarGraphSetInsert(visited, target);\n const bubble = (current) => {\n if (__velarGraphSetContains(visited, current)) return;\n __velarGraphSetInsert(visited, current);\n bump(current);\n notify(current, deepKey);\n const next = __velarGraphWeakMapRead(parents, current);\n if (next) for (const owner of __velarGraphSetItems(next)) bubble(owner);\n };\n for (const owner of __velarGraphSetItems(owners)) bubble(owner);\n };\n const link = (child, parent) => {\n if (child === null || (typeof child !== \"object\" && typeof child !== \"function\")) return;\n linkOwner(toRaw(child), parent, true);\n };\n // 'structural' separates a slot being filled from a slot merely being read.\n // A read proves the child is in the parent right now; only a write adds an\n // occurrence, and only a write can create the duplicate the running count\n // cannot see for itself.\n const linkOwner = (child, parent, structural = false) => {\n parent = toRaw(parent);\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\") || child === parent) return;\n let owners = __velarGraphWeakMapRead(parents, child);\n if (!owners) { owners = __velarGraphCreateSet(); __velarGraphWeakMapWrite(parents, child, owners); }\n const known = __velarGraphSetContains(owners, parent);\n __velarGraphSetInsert(owners, parent);\n const counts = __velarGraphWeakMapRead(containment, parent);\n if (!counts) return;\n if (structural && known) { __velarGraphWeakMapRemove(containment, parent); return; }\n if ((__velarGraphMapRead(counts, child) ?? 0) < 1) __velarGraphMapWrite(counts, child, 1);\n };\n // Removing the last owner of a value detaches everything only that value\n // owned. Without the cascade, replacing a state root leaves every surviving\n // descendant pointing at the dead root: the root stays strongly reachable\n // and each later deep mutation walks one more generation.\n const release = (root) => {\n const pending = [root];\n let index = 0;\n while (index < pending.length) {\n const current = pending[index];\n index += 1;\n forEachOwnedValue(current, (value) => {\n const owners = __velarGraphWeakMapRead(parents, value);\n if (!owners || !__velarGraphSetContains(owners, current)) return;\n __velarGraphSetRemove(owners, current);\n if (__velarGraphSetCount(owners) > 0) return;\n __velarGraphWeakMapRemove(parents, value);\n pending[pending.length] = value;\n });\n }\n };\n const unlink = (child, parent) => {\n child = toRaw(child);\n parent = toRaw(parent);\n const owners = child !== null && (typeof child === \"object\" || typeof child === \"function\")\n ? __velarGraphWeakMapRead(parents, child)\n : null;\n if (!owners) return;\n __velarGraphSetRemove(owners, parent);\n if (__velarGraphSetCount(owners) > 0) return;\n __velarGraphWeakMapRemove(parents, child);\n release(child);\n };\n // Map and Set membership is decided once per value and remembered: the only\n // cross-realm test JavaScript offers is invoking a prototype accessor and\n // catching, and a record write must not pay two thrown exceptions per field.\n const collectionBrand = (value) => {\n const known = __velarGraphWeakMapRead(collectionBrands, value);\n if (known !== undefined) return known;\n let brand = 0;\n try { __velarGraphMapCount(value); brand = 1; }\n catch {\n try { __velarGraphSetCount(value); brand = 2; }\n catch { brand = 0; }\n }\n __velarGraphWeakMapWrite(collectionBrands, value, brand);\n return brand;\n };\n const forEachOwnedValue = (parent, visit) => {\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\")) return;\n if (__velarGraphIsList(parent)) {\n for (let index = 0; index < parent.length; index += 1) {\n const value = toRaw(__velarGraphOwnDescriptor(parent, index)?.value);\n if (value !== null && (typeof value === \"object\" || typeof value === \"function\")) visit(value);\n }\n return;\n }\n const brand = collectionBrand(parent);\n if (brand === 1) {\n for (const value of __velarGraphMapItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n // A Map key is linked to its Map exactly like a value, so releasing the\n // Map has to release object keys too.\n for (const value of __velarGraphMapKeyItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n return;\n }\n if (brand === 2) {\n for (const value of __velarGraphSetItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n return;\n }\n if (typeof parent !== \"object\") return;\n for (const name of __velarGraphOwnNames(parent)) {\n const descriptor = __velarGraphOwnDescriptor(parent, name);\n if (!descriptor || !(\"value\" in descriptor)) continue;\n const value = toRaw(descriptor.value);\n if (value !== null && (typeof value === \"object\" || typeof value === \"function\")) visit(value);\n }\n };\n // Containment used to be re-derived by scanning the whole container on every\n // element write, which made one assignment into a rendered List cost O(list\n // length). The occurrence index answers the same question -- does the parent\n // still reference this child anywhere? -- in constant time: it is built once\n // from the container's real contents and then maintained by the same link and\n // release calls that change them.\n const containment = __velarGraphCreateWeakMap();\n const countOccurrence = (counts, value) => {\n value = toRaw(value);\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) return;\n __velarGraphMapWrite(counts, value, (__velarGraphMapRead(counts, value) ?? 0) + 1);\n };\n // Mirrors exactly what the old scan looked at, Map keys included as owned\n // values are, so the index cannot answer a question the scan answered\n // differently.\n const buildContainment = (parent) => {\n const counts = __velarGraphCreateMap();\n if (__velarGraphIsList(parent)) {\n for (let index = 0; index < parent.length; index += 1) countOccurrence(counts, __velarGraphOwnDescriptor(parent, index)?.value);\n return counts;\n }\n const brand = collectionBrand(parent);\n if (brand === 1) {\n for (const value of __velarGraphMapItems(parent)) countOccurrence(counts, value);\n return counts;\n }\n if (brand === 2) {\n for (const value of __velarGraphSetItems(parent)) countOccurrence(counts, value);\n return counts;\n }\n if (!parent || typeof parent !== \"object\") return counts;\n for (const name of __velarGraphOwnNames(parent)) {\n const descriptor = __velarGraphOwnDescriptor(parent, name);\n if (descriptor && \"value\" in descriptor) countOccurrence(counts, descriptor.value);\n }\n return counts;\n };\n // The one guard every detach path shares: a primitive was never linked, and\n // an object with no owners has nothing to release, so neither may reach the\n // containment bookkeeping.\n const releaseChild = (parent, child) => {\n if (child === null || (typeof child !== \"object\" && typeof child !== \"function\")\n || !__velarGraphWeakMapContains(parents, child)) return;\n parent = toRaw(parent);\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\")) return;\n child = toRaw(child);\n // A freshly built index already reflects the slot that was just cleared;\n // a maintained one still counts it, so only that one takes the decrement.\n let counts = __velarGraphWeakMapRead(containment, parent);\n let remaining;\n if (counts) remaining = (__velarGraphMapRead(counts, child) ?? 0) - 1;\n else {\n counts = buildContainment(parent);\n __velarGraphWeakMapWrite(containment, parent, counts);\n remaining = __velarGraphMapRead(counts, child) ?? 0;\n }\n if (remaining > 0) { __velarGraphMapWrite(counts, child, remaining); return; }\n __velarGraphMapRemove(counts, child);\n unlink(child, parent);\n };\n // The registry operation stays exactly two parameters wide; 'structural'\n // belongs to the internal call, which knows whether a slot is being filled or\n // merely read, and every caller outside this file fills one.\n const reactive = (value, parent = null) => reactiveValue(value, parent, true);\n const reactiveValue = (value, parent, structural) => {\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) return value;\n value = toRaw(value);\n if (parent !== null) linkOwner(value, parent, structural);\n if (typeof value !== \"object\" || __velarGraphIsList(value) || !__velarGraphIsExtensible(value)) return value;\n if (!__velarGraphIsRecord(value)) {\n // D114 P6 item 7 (ST-U4): the one place an unwrapped class instance is\n // handed back out of a state graph. In a development host its fields are\n // observed from here so a `computed` or `watch` that reads one is told\n // the read can never update; in a production build the detector's hooks\n // (stale-class.js) are null and this is one already-false test on the hot\n // path. The owner is handed over rather than the cell's name, because the\n // report names the path from the cell down to the instance.\n if (__velarStaleClassHooks !== null && parent !== null) __velarObserveClassFields(value, parent);\n return value;\n }\n let proxy = __velarGraphWeakMapRead(rawToProxy, value);\n if (proxy) return proxy;\n proxy = new __velarGraphNativeProxy(value, {\n get(target, key) {\n track(target, key);\n return reactiveValue(__velarGraphGet(target, key, target), target, false);\n },\n set(target, key, next) {\n next = toRaw(next);\n const present = __velarGraphHas(target, key);\n const previous = toRaw(__velarGraphGet(target, key, target));\n // Creating an absent key is a structural change even when the value\n // written equals the absent key's 'undefined' reading.\n const changed = !present || !__velarGraphSame(previous, next);\n const written = __velarGraphSet(target, key, next, target);\n if (!written || !changed) return written;\n link(next, target);\n releaseChild(target, previous);\n trigger(target, key, true, !present);\n return true;\n },\n has(target, key) { track(target, key); return __velarGraphHas(target, key); },\n deleteProperty(target, key) {\n if (!__velarGraphHas(target, key)) return true;\n const previous = toRaw(__velarGraphGet(target, key, target));\n const deleted = __velarGraphDelete(target, key);\n if (deleted) {\n releaseChild(target, previous);\n trigger(target, key, true, true);\n }\n return deleted;\n },\n });\n __velarGraphWeakMapWrite(rawToProxy, value, proxy);\n __velarGraphWeakMapWrite(proxyToRaw, proxy, value);\n return proxy;\n };\n const trackDeep = (value) => { value = toRaw(value); track(value, deepKey); return value; };\n const versionOf = (value) => {\n value = toRaw(value);\n return value && (typeof value === \"object\" || typeof value === \"function\")\n ? __velarGraphWeakMapRead(versions, value) ?? 0\n : 0;\n };\n const collectionRead = (value, key, child) => {\n value = toRaw(value);\n track(value, key);\n // Only containers already connected to a state graph own children read\n // through them. Fresh derived Lists (filter/map/etc.) stay ephemeral and\n // cannot become strongly retained parents of every item merely by being\n // iterated during rendering.\n return reactiveValue(child, __velarGraphWeakMapContains(parents, value) ? value : null, false);\n };\n const collectionTrigger = (value, key, iterate = true, structure = false, indexFrom = null, allKeys = false) => trigger(toRaw(value), key, iterate, structure, indexFrom, allKeys);\n const collectionUnlink = (value, child) => {\n releaseChild(toRaw(value), toRaw(child));\n };\n const computed = (read) => {\n if (typeof read !== \"function\") throw new TypeError(\"computed requires a function\");\n let dirty = true;\n let evaluating = false;\n let recursed = false;\n let initialized = false;\n let value;\n let failed = false;\n let failure;\n const subscribers = __velarGraphCreateSet();\n const notifyDependents = (skip = null) => {\n for (const dependent of __velarGraphSetItems(subscribers)) if (dependent !== skip) dependent.notify();\n };\n const invalidateComputedDependents = () => {\n for (const dependent of __velarGraphSetItems(subscribers)) {\n if (dependent.mode === \"computed\") dependent.notify();\n }\n };\n const observer = {\n mode: \"computed\",\n stopped: false,\n running: false,\n selfInvalidations: 0,\n // P2b-9: filled in by the graph's notify when a write lands while this\n // value is still being derived, so the runaway report names the path.\n selfInvalidationSubject: \"\",\n selfInvalidationKind: \"\",\n dependencies: __velarGraphCreateSet(),\n notify() {\n // Stopping is shared discipline with DOM and watch observers: a flush\n // overflow marks queued computed observers stopped, and a stopped\n // observer must go inert instead of re-entering the storm on the next\n // write.\n if (observer.stopped) return;\n // The 100 self-invalidation cap covers computed observers too. A\n // computed whose own turn (evaluation plus dependent notification)\n // keeps invalidating it is stopped with the same owned report a\n // render or watch observer gets, instead of running to the whole\n // flush budget.\n if (observer.running) {\n observer.selfInvalidations += 1;\n if (observer.selfInvalidations > 100) {\n observer.stopped = true;\n cleanupObserver(observer);\n reportUntracked(new RangeError(\"A computed value cannot invalidate itself more than 100 times\"\n + (observer.selfInvalidationSubject ? \": it writes \" + observer.selfInvalidationSubject + \" while reading it\" : \"\")));\n return;\n }\n } else {\n observer.selfInvalidations = 0;\n }\n if (dirty) return;\n dirty = true;\n if (__velarGraphSetCount(subscribers) === 0) {\n cleanupObserver(observer);\n return;\n }\n schedule(observer);\n // A downstream computed must become dirty immediately so a same-turn\n // read cannot observe its cached result while an upstream dependency\n // is already stale. DOM and watch observers still wait for evaluation\n // to prove that the public result actually changed.\n invalidateComputedDependents();\n },\n run() {\n if (observer.stopped || !dirty || __velarGraphSetCount(subscribers) === 0) return;\n observer.running = true;\n try {\n if (evaluate(false)) notifyDependents();\n } finally { observer.running = false; }\n },\n };\n const detach = () => {\n cleanupObserver(observer);\n dirty = true;\n };\n __velarGraphWeakMapWrite(subscriptionStops, subscribers, detach);\n const evaluate = (throwFailure) => {\n if (evaluating) {\n recursed = true;\n throw new RangeError(\"A computed value cannot read itself recursively\");\n }\n const previous = value;\n const previouslyFailed = failed;\n const previousFailure = failure;\n const hadValue = initialized;\n evaluating = true;\n recursed = false;\n failed = false;\n failure = undefined;\n try { value = runTracked(observer, read); }\n catch (error) { failed = true; failure = error; }\n finally {\n evaluating = false;\n initialized = true;\n dirty = false;\n }\n // A computed that failed because its own recursion guard tripped sits on\n // a dependency cycle. The failure is cached and served, but the cyclic\n // edges must not persist: two failed computeds that keep notifying each\n // other would otherwise ping-pong the next flush into the whole-flush\n // budget. Detaching unwinds the cycle (a peer whose last subscriber\n // leaves detaches with it) and a later read simply re-attempts.\n if (failed && recursed) detach();\n else if (__velarGraphSetCount(subscribers) === 0) detach();\n recursed = false;\n const changed = !hadValue || previouslyFailed !== failed || (failed ? previousFailure !== failure : !__velarGraphSame(previous, value));\n if (throwFailure && failed) throw failure;\n return changed;\n };\n const access = () => {\n const consumer = runtime.activeObserver;\n if (consumer !== observer) trackSubscribers(subscribers);\n if (dirty && !observer.stopped) {\n // A cyclic read re-enters access while the outer evaluation is still\n // running, so the running span is restored, never cleared.\n const wasRunning = observer.running;\n observer.running = true;\n try {\n const changed = evaluate(false);\n if (changed && initialized) notifyDependents(consumer);\n } finally { observer.running = wasRunning; }\n }\n if (failed) throw failure;\n return value;\n };\n return __velarGraphFreeze(access);\n };\n // The loud channel for a failure nothing owns.\n //\n // D114 P6 item 4 (LC-C1) and F9-web (WB-C1): every `tick()` waiting on the\n // flush is a claimant, in every host. A caller waiting on the flush is the\n // one place a failure nobody handled can be delivered *to somebody*, so the\n // flush's first unowned failure is parked and every pending `tick()` rejects\n // with it -- the promise that awaiting `tick()` cannot step over a broken\n // update is one the second concurrent awaiter has to keep too.\n //\n // Everything else goes to the host, and there is no second channel beside a\n // claimant: a later failure in the same flush, whose claimants are already\n // spoken for, and every failure raised with nobody waiting at all. In a\n // browser that is the microtask throw the host error event catches and the\n // page survives; in a non-browser host (a headless 'velar test' process, a\n // worker) the same throw would terminate the process, which the runtime\n // boundary forbids, so there it is traced to the report channel. Nothing is\n // parked for a `tick()` that is not yet waiting, because a caller who arrives\n // after the flush was never waiting on it.\n const escalate = (error) => {\n if (__velarTickWaiting() && __velarGraphSetCount(unhandledFailures) === 0) {\n __velarGraphSetInsert(unhandledFailures, error);\n return;\n }\n if (__velarDomDocument !== null) {\n __velarEnqueue(() => { throw error; });\n return;\n }\n __velarFoundationTrace(error);\n };\n const report = (value, options) => {\n const error = __velarNormalizeError(value);\n const checked = __velarReportOptions(options);\n const timestamp = __velarNow();\n if (!__velarWebErrorFinite(timestamp)) throw new TypeError(\"The browser returned an invalid error timestamp\");\n const errorReport = __velarWebErrorFreeze({\n error,\n phase: checked.phase,\n detail: checked.detail,\n component: checked.component,\n timestamp,\n });\n let handled = false;\n for (const handler of __velarGraphSetItems(errorHandlers)) {\n handled = true;\n try {\n const result = handler(errorReport);\n __velarObservePromise(result, (failure) => escalate(__velarNormalizeError(failure)));\n } catch (failure) { escalate(__velarNormalizeError(failure)); }\n }\n if (checked.unhandled && !handled) escalate(error);\n return errorReport;\n };\n // A report raised from inside a tracked evaluation (the computed cap) must\n // not let handler reads become dependencies of the failing observer.\n const reportUntracked = (error) => {\n const previousObserver = runtime.activeObserver;\n runtime.activeObserver = null;\n try { report(error, { phase: \"update\", detail: \"\", component: \"\", unhandled: true }); }\n finally { runtime.activeObserver = previousObserver; }\n };\n // The queue insert stays on the registry -- computed observers are created by\n // whichever module stamped it first (velar/app under ESM import order, or the\n // application prelude) and must schedule correctly whichever that was -- but\n // the drain it calls is the module-scope one below, and there is now exactly\n // one of those. A queue that outgrows its bound is the flush budget's failure\n // to own, not an exception thrown out of the assignment that happened to\n // cross the line: throwing here left the writing cell's subscriber walk half\n // finished, with the remaining observers subscribed and never notified again.\n const schedule = (observer) => {\n __velarGraphSetInsert(observer.mode === \"watch\" ? watchQueue : domQueue, observer);\n __velarScheduleFlush();\n };\n const applyLook = (...arguments_) => {\n if (!lookImplementation) throw new TypeError(\"Link Look requires the VelarScript Web runtime\");\n return lookImplementation(...arguments_);\n };\n const installLook = (implementation) => {\n if (typeof implementation !== \"function\") throw new TypeError(\"VelarScript Look integration requires a function\");\n lookImplementation ??= implementation;\n return null;\n };\n const fields = {\n version: \"0.12\", domQueue, watchQueue, flushPending: false, activeObserver: null, errorHandlers,\n actionFailures, unhandledFailures, lookSources, classSources, dependencies, rawToProxy, proxyToRaw, versions, parents,\n toRaw, reactive, track, trackDeep, trigger, versionOf, collectionRead, collectionTrigger, collectionUnlink,\n trackSubscribers, runTracked, cleanupObserver, computed,\n schedule, report, applyLook, installLook,\n };\n for (const name of __velarRuntimeFields) Object.defineProperty(runtime, name, {\n value: fields[name],\n enumerable: false,\n configurable: false,\n writable: name === \"flushPending\" || name === \"activeObserver\",\n });\n return Object.preventExtensions(runtime);\n}\n\nfunction __velarRequireRuntime(value) {\n if (!value || typeof value !== \"object\") throw new TypeError(\"VelarScript Web runtime ownership is invalid\");\n // The schema comparison comes first, ahead of ownership and the field roster:\n // a schema bump normally changes the roster too, so leaving it last reported\n // \"fields are invalid\" and never named the one fact that identifies the\n // cause. The version is read through its descriptor rather than the property\n // so an unvalidated object cannot answer it with a getter.\n const __velarVersionDescriptor = Object.getOwnPropertyDescriptor(value, \"version\");\n const __velarVersion = __velarVersionDescriptor && \"value\" in __velarVersionDescriptor ? __velarVersionDescriptor.value : undefined;\n if (__velarVersion !== \"0.12\") {\n throw new TypeError(\"VelarScript Web runtime schema \" + (typeof __velarVersion === \"string\" ? __velarVersion : \"(unknown)\") + \" does not match this module's schema 0.12; one build mixed two generations of @velarscript/* — run 'npm ls @velarscript/compiler' and pin one version\");\n }\n if (Object.getPrototypeOf(value) !== null || Object.isExtensible(value)\n || Object.getOwnPropertySymbols(value).length > 0) throw new TypeError(\"VelarScript Web runtime ownership is invalid\");\n const names = Object.getOwnPropertyNames(value);\n if (names.length !== __velarRuntimeFields.length || __velarRuntimeFields.some((name) => !names.includes(name))) {\n throw new TypeError(\"VelarScript Web runtime fields are invalid\");\n }\n for (const name of __velarRuntimeFields) {\n const descriptor = Object.getOwnPropertyDescriptor(value, name);\n const mutable = name === \"flushPending\" || name === \"activeObserver\";\n if (!descriptor || !(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable !== mutable) {\n throw new TypeError(\"VelarScript Web runtime field '\" + name + \"' is invalid\");\n }\n }\n if (!__velarRuntimeCollection(value.domQueue, \"Set\") || !__velarRuntimeCollection(value.watchQueue, \"Set\")\n || typeof value.flushPending !== \"boolean\" || (value.activeObserver !== null && typeof value.activeObserver !== \"object\")\n || !__velarRuntimeCollection(value.errorHandlers, \"Set\") || !__velarRuntimeCollection(value.actionFailures, \"WeakSet\")\n || !__velarRuntimeCollection(value.unhandledFailures, \"Set\")\n || !__velarRuntimeCollection(value.lookSources, \"WeakMap\") || !__velarRuntimeCollection(value.classSources, \"WeakMap\")\n || !__velarRuntimeCollection(value.dependencies, \"WeakMap\") || !__velarRuntimeCollection(value.rawToProxy, \"WeakMap\")\n || !__velarRuntimeCollection(value.proxyToRaw, \"WeakMap\") || !__velarRuntimeCollection(value.versions, \"WeakMap\")\n || !__velarRuntimeCollection(value.parents, \"WeakMap\")\n || typeof value.toRaw !== \"function\" || typeof value.reactive !== \"function\" || typeof value.track !== \"function\"\n || typeof value.trackDeep !== \"function\" || typeof value.trigger !== \"function\" || typeof value.versionOf !== \"function\"\n || typeof value.collectionRead !== \"function\" || typeof value.collectionTrigger !== \"function\" || typeof value.collectionUnlink !== \"function\"\n || typeof value.trackSubscribers !== \"function\" || typeof value.runTracked !== \"function\"\n || typeof value.cleanupObserver !== \"function\" || typeof value.computed !== \"function\" || typeof value.schedule !== \"function\"\n || typeof value.report !== \"function\" || typeof value.applyLook !== \"function\" || typeof value.installLook !== \"function\") {\n throw new TypeError(\"VelarScript Web runtime values are invalid\");\n }\n return value;\n}\n\nconst __velarRuntime = (() => {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, __velarRuntimeKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {\n throw new TypeError(\"VelarScript Web runtime registry ownership is invalid\");\n }\n return __velarRequireRuntime(descriptor.value);\n }\n const runtime = __velarCreateRuntime();\n Object.defineProperty(globalThis, __velarRuntimeKey, {\n value: runtime,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return runtime;\n})();\n" + "/**\n * D114 P6 item 7 (ST-U4), completed by F9-web (WB-I3 / WB-I4 / WB-U4): the\n * development host's detector for a `computed`, a `watch` subject or a DOM\n * interpolation that reads a field of a class instance held in `state`.\n *\n * web-api's rule stands and is not changing: classes are never wrapped, because\n * a proxy over an instance would change what `self` is and what identity means.\n * The consequence had no name: `state box = Counter()` with\n * `computed shown = box.value` compiles clean, renders once, and never updates\n * again, because `box.bump()` writes a field nothing is watching. Only\n * replacing the cell publishes. `<p>{box.value}</p>` is the same fact one step\n * closer to the page -- the text node is written once and never again -- so the\n * three readers are one rule and earn one sentence.\n *\n * So the instance's own data fields are observed while a development host is\n * present -- the same trade the frozen-read detector makes, in the same\n * channel. The instance is not replaced: an accessor pair over the value it\n * already held keeps its identity, its prototype, and what `self` means inside\n * its own methods, which a proxy could not. A production build publishes no\n * hooks, so none of this exists there.\n *\n * Three things this file owns that the report did not have before:\n *\n * - **What to write instead (WB-I3).** The remedy used to be spelled\n * `cell = Class(...)` whatever shape the value was in, and the walk that\n * finds the cell climbs through records and Lists -- so `state holder =\n * {box: Box()}` was told to write `holder = Box(...)`, which does not\n * compile. The walk now carries the path it climbed, and the remedy is\n * written for the shape that actually holds the instance.\n * - **When the read has actually gone stale (WB-I4).** A `const` field is one\n * nothing can change, so a read of it can never go stale and the sentence\n * \"changing 'value' publishes nothing\" describes something that will not\n * happen. The emitted class makes `const` and `let` the same ordinary data\n * property, so the runtime cannot tell them apart by looking -- but it does\n * not have to: the report is made when the field is **written** under a\n * reader that cannot see it, which is the frozen-read detector's own rule\n * (\"a report is made when one of them later changes -- never when it is\n * read\"). A field nothing writes is never reported, and `const` is exactly\n * the case where nothing can.\n * - **The member the line reads (WB-U4).** `get shown()` backed by a field\n * `inner` was reported as `inner`, a name the author's line never contains\n * and may not know exists. A read that enters through the class's own\n * getter or method records that member for as long as it runs, so the\n * report can name both.\n */\nconst __velarStaleClassHooks = (() => {\n const hooks = globalThis.__velarDevelopmentHooks;\n return hooks && typeof hooks.frozenRead === \"function\" ? hooks : null;\n})();\nconst __velarStaleClassSeen = __velarStaleClassHooks === null ? null : __velarGraphCreateWeakSet();\nconst __velarStaleClassWrapped = __velarStaleClassHooks === null ? null : __velarGraphCreateWeakSet();\nconst __velarStaleClassReported = __velarStaleClassHooks === null ? null : __velarGraphCreateSet();\n// The class member a read is currently inside, or null when the reading line\n// names the field itself. Outermost wins: a method that reads through a getter\n// of its own is still entered as the method the author wrote.\nlet __velarStaleClassMember = null;\n\n/** The written class name, or null where the value is not an instance of one. */\nfunction __velarStaleClassName(instance) {\n const prototype = __velarGraphPrototype(instance);\n if (prototype === null) return null;\n const constructor = __velarGraphOwnDescriptor(prototype, \"constructor\");\n const value = constructor && \"value\" in constructor ? constructor.value : null;\n if (typeof value !== \"function\") return null;\n const named = __velarGraphOwnDescriptor(value, \"name\");\n const name = named && \"value\" in named ? named.value : null;\n return typeof name === \"string\" && name !== \"\" ? name : null;\n}\n\n/**\n * Which slot of `owner` holds `child`: a record field, a List index, or null\n * where the owner is a shape whose slot has no spelling an author can write --\n * a `Map`, a `Set`, or an owner that no longer references the child at all. A\n * slot that cannot be named is a remedy that cannot be written, and the report\n * says so rather than inventing one.\n */\nfunction __velarStaleClassSlot(owner, child) {\n if (owner === null || typeof owner !== \"object\") return null;\n if (__velarGraphIsList(owner)) {\n for (let index = 0; index < owner.length; index += 1) {\n const descriptor = __velarGraphOwnDescriptor(owner, index);\n if (descriptor && \"value\" in descriptor && descriptor.value === child) return { index, field: null };\n }\n return null;\n }\n if (!__velarGraphIsRecord(owner)) return null;\n for (const name of __velarGraphOwnNames(owner)) {\n const descriptor = __velarGraphOwnDescriptor(owner, name);\n if (descriptor && \"value\" in descriptor && descriptor.value === child) return { index: -1, field: name };\n }\n return null;\n}\n\n/**\n * The `state` cell a value was reached through and the path from that cell down\n * to it, or null when no cell is above it. The walk is bounded and\n * breadth-first over the same ownership graph a deep change bubbles up, so a\n * class instance held one or two records below a state cell is found -- and a\n * value that is not under one is not reported about at all, because the report\n * has to name the place whose replacement publishes.\n *\n * `steps` is null when some owner on the path holds the value in a slot with no\n * written spelling; the cell is still named, and the remedy drops to the one\n * sentence that is true for every shape.\n */\nfunction __velarStaleClassLocation(instance, parent) {\n const seen = __velarGraphCreateSet();\n let frontier = [{ value: parent, child: instance, steps: [] }];\n for (let depth = 0; depth < 8 && frontier.length > 0; depth += 1) {\n const next = [];\n for (const entry of frontier) {\n const candidate = entry.value;\n if (candidate === null || (typeof candidate !== \"object\" && typeof candidate !== \"function\")) continue;\n if (__velarGraphSetContains(seen, candidate)) continue;\n __velarGraphSetInsert(seen, candidate);\n const descriptor = __velarGraphOwnDescriptor(candidate, \"velarStateName\");\n const name = descriptor && \"value\" in descriptor ? descriptor.value : null;\n // A cell holds its value in a closure rather than in a slot, so the step\n // into it is the cell itself and the path collected so far is complete.\n if (typeof name === \"string\" && name !== \"\") return { cell: name, steps: entry.steps };\n const owners = __velarGraphWeakMapRead(__velarRuntime.parents, candidate);\n if (!owners) continue;\n const slot = __velarStaleClassSlot(candidate, entry.child);\n let steps = null;\n if (slot !== null && entry.steps !== null) {\n steps = [slot];\n for (let index = 0; index < entry.steps.length; index += 1) steps[steps.length] = entry.steps[index];\n }\n for (const above of __velarGraphSetItems(owners)) next[next.length] = { value: above, child: candidate, steps };\n }\n frontier = next;\n }\n return null;\n}\n\n/** `holder.box`, `boxes[0]`, `groups[0].box` -- the path an author can read the value through. */\nfunction __velarStaleClassPath(cell, steps, count) {\n let text = cell;\n for (let index = 0; index < count; index += 1) {\n const step = steps[index];\n text += step.field === null ? \"[\" + step.index + \"]\" : \".\" + step.field;\n }\n return text;\n}\n\n/**\n * The write that publishes, for the shape the instance is actually in. The flat\n * case replaces the cell; a record below it is replaced with the field written\n * over, which is the update every other record in `state` takes; a List element\n * is replaced by index.\n */\nfunction __velarStaleClassRemedy(location, className) {\n const steps = location.steps;\n if (steps === null) return \"only replacing the value in state '\" + location.cell + \"' that holds it publishes.\";\n if (steps.length === 0) return \"only replacing the cell -- '\" + location.cell + \" = \" + className + \"(...)' -- publishes.\";\n const last = steps[steps.length - 1];\n const owner = __velarStaleClassPath(location.cell, steps, steps.length - 1);\n if (last.field === null) {\n return \"only replacing the element -- '\" + owner + \"[\" + last.index + \"] = \" + className + \"(...)' -- publishes.\";\n }\n return \"only replacing it -- '\" + owner + \" = {...\" + owner + \", \" + last.field + \": \" + className + \"(...)}' -- publishes.\";\n}\n\n/** The reading line, captured where the read happens rather than where the report is made. */\nfunction __velarStaleClassSite() {\n const site = new Error(\"velar stale class read\");\n try { return typeof site.stack === \"string\" ? site.stack : \"\"; } catch { return \"\"; }\n}\n\n/**\n * One mistake, one sentence, once per place, class and field -- whichever of\n * the three readers reached it first. Only the words that name the reader\n * change: a `computed` and a `watch` subject are a reactive value, and a\n * position in the document is the interpolation that wrote it.\n */\nfunction __velarReportStaleClassField(location, className, field, member, mode, stack) {\n const named = typeof member === \"string\" && member !== \"\" && member !== field ? member : null;\n const path = location.steps === null || location.steps.length === 0\n ? \"\" : \" at '\" + __velarStaleClassPath(location.cell, location.steps, location.steps.length) + \"'\";\n // Keyed by the place and the field, not by the member: two members that read\n // one field are two lines about one field that does not publish, and the\n // report names whichever reader reached it first, as it always has.\n const key = location.cell + \"|\" + path + \"|\" + className + \"|\" + field;\n if (__velarGraphSetContains(__velarStaleClassReported, key)) return;\n __velarGraphSetInsert(__velarStaleClassReported, key);\n const reader = mode === \"dom\" ? \"interpolation\" : \"value\";\n __velarStaleClassHooks.frozenRead({\n message: \"This \" + (mode === \"dom\" ? \"interpolation\" : \"reactive value\") + \" reads '\" + (named ?? field) + \"' on the \"\n + className + \" held in state '\" + location.cell + \"'\" + path + \".\"\n + (named === null ? \"\" : \" '\" + named + \"' reads the field '\" + field + \"'.\")\n + \" A class instance is never wrapped, so changing '\" + field\n + \"' publishes nothing and this \" + reader + \" stays as it is: \"\n + __velarStaleClassRemedy(location, className)\n + \" Hold the field in its own 'state' if it is meant to be followed.\",\n stack,\n });\n}\n\n/**\n * Observes one instance's own writable data fields. Fields the class did not\n * declare as plain values -- a getter it wrote itself, a sealed field -- are\n * left exactly as they are: this detector may not change what the program does,\n * only notice what it cannot see.\n *\n * The report is made when a reader that cannot follow the field meets a real\n * change to it, in whichever order the two arrive: a read that is already stale\n * reports on the spot, and a read of a value that changes later reports at the\n * change, on the line the read was made. A field that never changes is never\n * reported, which is what keeps a `const` field silent (WB-I4).\n */\nfunction __velarObserveClassFields(instance, parent) {\n if (__velarGraphWeakSetContains(__velarStaleClassSeen, instance)) return;\n __velarGraphWeakSetInsert(__velarStaleClassSeen, instance);\n const className = __velarStaleClassName(instance);\n if (className === null) return;\n const location = __velarStaleClassLocation(instance, parent);\n if (location === null) return;\n let observed = false;\n for (const field of __velarGraphOwnNames(instance)) {\n const descriptor = __velarGraphOwnDescriptor(instance, field);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.writable || !descriptor.configurable) continue;\n observed = true;\n let held = descriptor.value;\n let waiting = null;\n let moved = false;\n __velarGraphDefine(instance, field, {\n enumerable: descriptor.enumerable,\n configurable: true,\n // Named, not shorthand, for the frozen-read detector's reason: the\n // development host walks past its own frames to find the reading line,\n // and every engine spells an anonymous accessor differently.\n get: function __velarStaleClassFieldRead() {\n const observer = __velarRuntime.activeObserver;\n // Every mode an observer has is a reader that re-runs only when a\n // dependency it tracked changes, and this field is never one: the\n // rendering tier (\"dom\") is as stuck as the derivation tier.\n if (observer !== null && (observer.mode === \"computed\" || observer.mode === \"watch\" || observer.mode === \"dom\")) {\n if (moved) __velarReportStaleClassField(location, className, field, __velarStaleClassMember, observer.mode, __velarStaleClassSite());\n else if (waiting === null) waiting = { mode: observer.mode, member: __velarStaleClassMember, site: __velarStaleClassSite() };\n }\n return held;\n },\n set: function __velarStaleClassFieldWrite(next) {\n if (__velarGraphSame(held, next)) return;\n held = next;\n moved = true;\n if (waiting === null) return;\n const claim = waiting;\n waiting = null;\n __velarReportStaleClassField(location, className, field, claim.member, claim.mode, claim.site);\n },\n });\n }\n if (observed) __velarObserveClassMembers(instance);\n}\n\n/**\n * Records which of the class's own members a read entered through, so a report\n * can name the one the author's line contains as well as the field underneath\n * it. Only the prototype of an instance whose fields this detector already took\n * over is touched, and only in a development host: an object it observes\n * nothing on is one it has no report to make about either.\n */\nfunction __velarObserveClassMembers(instance) {\n const prototype = __velarGraphPrototype(instance);\n if (prototype === null || __velarGraphWeakSetContains(__velarStaleClassWrapped, prototype)) return;\n __velarGraphWeakSetInsert(__velarStaleClassWrapped, prototype);\n for (const member of __velarGraphOwnNames(prototype)) {\n // The compiler owns its own contracts -- `@dispose:` emits `__velar:dispose`\n // -- and a member the author did not write is not one their line names.\n if (member === \"constructor\" || member.indexOf(\"__velar\") === 0 || member.indexOf(\":\") >= 0) continue;\n const descriptor = __velarGraphOwnDescriptor(prototype, member);\n if (!descriptor || !descriptor.configurable) continue;\n if (typeof descriptor.get === \"function\" && descriptor.set === undefined) {\n const read = descriptor.get;\n __velarGraphDefine(prototype, member, {\n enumerable: descriptor.enumerable,\n configurable: true,\n get: function __velarStaleClassMemberRead() { return __velarStaleClassEnter(member, read, this, []); },\n });\n continue;\n }\n if (!(\"value\" in descriptor) || typeof descriptor.value !== \"function\") continue;\n const call = descriptor.value;\n __velarGraphDefine(prototype, member, {\n enumerable: descriptor.enumerable,\n configurable: true,\n writable: descriptor.writable,\n value: function __velarStaleClassMemberCall(...values) { return __velarStaleClassEnter(member, call, this, values); },\n });\n }\n}\n\nfunction __velarStaleClassEnter(member, operation, receiver, values) {\n const outer = __velarStaleClassMember;\n if (outer === null) __velarStaleClassMember = member;\n try { return __velarGraphApply(operation, receiver, values, \"class member\"); }\n finally { __velarStaleClassMember = outer; }\n}\n";
15
+ export const WEB_FOUNDATION_BODY = "const __velarRuntimeKey = Symbol.for(\"velar.runtime.v1\");\nconst __velarFoundationReflectApply = Object.getOwnPropertyDescriptor(Reflect, \"apply\")?.value;\nconst __velarFoundationQueueMicrotask = globalThis.queueMicrotask;\nconst __velarFoundationSetTimeout = globalThis.setTimeout;\nconst __velarFoundationDate = globalThis.Date;\nconst __velarFoundationDateNow = typeof __velarFoundationDate === \"function\"\n ? Object.getOwnPropertyDescriptor(__velarFoundationDate, \"now\")?.value\n : null;\nconst __velarFoundationConsole = globalThis.console ?? null;\nconst __velarFoundationConsoleError = __velarFoundationConsole !== null\n ? Object.getOwnPropertyDescriptor(__velarFoundationConsole, \"error\")?.value ?? null\n : null;\n// D114 WB-D1 (CO-I6 on the Web face): the host-frame policy has one\n// implementation, `__velarHostErrorTrace` in packages/compiler/runtime/error.js,\n// and this is one of its callers rather than a third writer of the same\n// sentence. Reading `error.stack` here printed exactly the two classes of frame\n// that policy exists to hide -- the runtime's own `__velar` helpers and Node's\n// internals -- with no \"(N frames hidden; ...)\" line and no answer to\n// `velar run --stack`, which is the launcher path's promise repeated on a\n// channel that did not keep it. The message-only fallback this used to spell a\n// second time is that function's own second answer.\n//\n// The name arrives with the error-normalization runtime: an inlined Web program\n// carries it in `WEB_ERROR_HOST_RUNTIME`, and a project build imports it beside\n// `normalizeError` (packages/web/src/emit/runtime-imports.ts).\nfunction __velarFoundationTrace(error) {\n if (typeof __velarFoundationConsoleError !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") return;\n let trace = \"An unhandled VelarScript failure was reported\";\n try { trace = __velarHostErrorTrace(error, trace); } catch {}\n try { __velarFoundationReflectApply(__velarFoundationConsoleError, __velarFoundationConsole, [\"Unhandled VelarScript error report: \" + trace]); } catch {}\n}\nfunction __velarEnqueue(callback) {\n if (typeof __velarFoundationQueueMicrotask !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") {\n throw new TypeError(\"The browser queueMicrotask API is unavailable\");\n }\n return __velarFoundationReflectApply(__velarFoundationQueueMicrotask, globalThis, [callback]);\n}\nfunction __velarNow() {\n if (typeof __velarFoundationDateNow !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") {\n throw new TypeError(\"The browser Date.now API is unavailable\");\n }\n return __velarFoundationReflectApply(__velarFoundationDateNow, __velarFoundationDate, []);\n}\nconst __velarRuntimeFields = Object.freeze([\n \"version\", \"domQueue\", \"watchQueue\", \"flushPending\", \"activeObserver\", \"errorHandlers\",\n \"actionFailures\", \"unhandledFailures\", \"lookSources\", \"classSources\", \"dependencies\", \"rawToProxy\", \"proxyToRaw\",\n \"versions\", \"parents\", \"toRaw\", \"reactive\", \"track\", \"trackDeep\", \"trigger\", \"versionOf\",\n \"collectionRead\", \"collectionTrigger\", \"collectionUnlink\", \"trackSubscribers\", \"runTracked\", \"cleanupObserver\", \"computed\",\n \"schedule\", \"report\", \"applyLook\", \"installLook\",\n]);\n\nfunction __velarRuntimeCollection(value, kind) {\n try {\n if (kind === \"Set\") __velarGraphSetContains(value, value);\n else if (kind === \"WeakSet\") __velarGraphWeakSetContains(value, value);\n else __velarGraphWeakMapContains(value, value);\n return true;\n } catch { return false; }\n}\n\nfunction __velarReportOptions(value) {\n if (value === undefined) value = {};\n if (!value || typeof value !== \"object\" || __velarGraphIsList(value) || !__velarGraphIsRecord(value)\n || __velarWebErrorOwnSymbols(value).length > 0) {\n throw new TypeError(\"VelarScript error report options must be a record\");\n }\n const allowed = __velarGraphCreateSet([\"phase\", \"detail\", \"component\", \"unhandled\"]);\n const output = { phase: \"runtime\", detail: \"\", component: \"\", unhandled: false };\n for (const name of __velarGraphOwnNames(value)) {\n if (!__velarGraphSetContains(allowed, name)) throw new TypeError(\"Unknown VelarScript error report option '\" + name + \"'\");\n const descriptor = __velarGraphOwnDescriptor(value, name);\n if (!descriptor || !(\"value\" in descriptor)) throw new TypeError(\"VelarScript error report options cannot use accessors\");\n const next = descriptor.value;\n if (name === \"unhandled\") {\n if (typeof next !== \"boolean\") throw new TypeError(\"VelarScript error report unhandled must be bool\");\n output.unhandled = next;\n } else {\n if (typeof next !== \"string\") throw new TypeError(\"VelarScript error report \" + name + \" must be a string\");\n const maximum = name === \"phase\" ? 256 : name === \"component\" ? 1024 : 65536;\n if (next.length > maximum) throw new RangeError(\"VelarScript error report \" + name + \" is too long\");\n output[name] = next;\n }\n }\n return output;\n}\n\n// D90 R21: the number stamped on each observer when it is created, and the\n// order the flush runs the watch tier in -- execution order is the order the\n// author wrote the watches, and \"wrote\" spans more than one file: watches of\n// one module register as that module initializes, instances of one component\n// register as they mount, and modules register in the order the import graph\n// initializes them. Every one of those is registration order, so one counter\n// answers all three.\n//\n// It has to be application-wide, not per module. Each emitted module carries\n// its own copy of this runtime, so a module-scope counter would restart at zero\n// in the second module and the two modules' watches would compare equal. The\n// counter therefore lives on one global slot every copy reads, the same way the\n// runtime registry itself does.\nconst __velarObserverSequenceKey = Symbol.for(\"velar.web.observer.sequence.v1\");\nconst __velarObserverSequenceCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarObserverSequenceKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web observer sequence ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0];\n __velarGraphDefine(globalThis, __velarObserverSequenceKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\nfunction __velarNextObserverSequence() {\n __velarObserverSequenceCell[0] += 1;\n return __velarObserverSequenceCell[0];\n}\n\n\n// D114 P6 item 4 (LC-C1): how many `tick()` promises are waiting on the flush\n// right now.\n//\n// The charter says an unowned flush failure surfaces at `tick()`. That was only\n// true off the browser: in a browser the runtime threw the failure from a\n// microtask, which the host error event catches and the page survives, and the\n// awaiting `tick()` resolved as though the update had been fine -- so\n// `velar/web-test` stepped silently over a broken update in the one host\n// `tick()` is documented for. An awaiting caller is a claimant: when one is\n// waiting, the failure is parked for it and it rejects; when none is, the\n// failure goes to the host as before.\n//\n// The count lives on one global slot for the reason the observer sequence does:\n// each emitted module carries its own copy of this runtime, the `tick()` that\n// waits and the flush that fails can be in two of them, and a module-scope\n// counter would let the second copy answer \"nobody is waiting\" while the first\n// one is.\nconst __velarTickWaitKey = Symbol.for(\"velar.web.tick.waiters.v1\");\nconst __velarTickWaitCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarTickWaitKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web tick ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0];\n __velarGraphDefine(globalThis, __velarTickWaitKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\nfunction __velarTickWaiting() {\n return __velarTickWaitCell[0] > 0;\n}\n\nfunction __velarEnterTickWait() {\n __velarTickWaitCell[0] += 1;\n}\n\nfunction __velarLeaveTickWait() {\n if (__velarTickWaitCell[0] > 0) __velarTickWaitCell[0] -= 1;\n}\n" + "// D114 W/A1, as narrowed by W2: the identity a flush stamps its run counts\n// with, and the budget those runs spend. They belong to one host *task* -- but\n// the window follows work an observer started, and nothing else.\n//\n// A cycle that crosses a microtask boundary -- 'watch x: detach step()', where\n// 'step' awaits an already-resolved Promise and then writes 'x' -- is a fresh\n// flush every round, so a budget that reset per flush never saw it: two\n// observer runs, well inside 100,000, forever. Flushes chained through\n// microtasks therefore share one token, one budget and one leaders list, and\n// the macrotask sentinel below closes the window. Work that resumes after a\n// timer, an event or network I/O is a new task and opens a fresh window, which\n// is what keeps an animation that writes state every frame from being stopped.\n//\n// W2: a flush continues the open window only once an observer run inside it has\n// started asynchronous work -- a 'detach' statement, or an 'action' call, made\n// while an observer was running. Those are the two ways a synchronous observer\n// body reaches a later microtask, so they are the only ways the ring above can\n// be closed; a chain of flushes with none of them in it has no cycle to find. A\n// bulk import loop that writes a progress counter and awaits promise-only work\n// per row runs millions of observers in one uninterrupted task and is not a\n// runaway, so each of its flushes gets the fresh budget it had before W. The\n// sentinel still closes every window at the task boundary, so the animation\n// case is protected either way.\n//\n// The overrun's carried token is the same rule seen from one flush earlier: an\n// overrun schedules its continuation as a microtask, so that continuation is\n// this same task and continues these same counts by construction. It carries\n// them whether or not an observer started anything, because the continuation is\n// the overrun's own unfinished work rather than a new write.\nconst __velarFlushBudgetPerTask = 100000;\nlet __velarFlushToken = null;\nlet __velarFlushBudget = 0;\n// One-shot, consumed by the next settle: the flush an overrun scheduled\n// continues the window it was scheduled from, whatever that window recorded.\nlet __velarFlushCarried = false;\n// One sentinel is enough for a window: the first one to fire closes it, and\n// arming a second on every flush would leave a timer per flush behind.\nlet __velarTaskSentinelArmed = false;\n\n// The two facts W2 needs live on one global slot, for the same reason the\n// observer sequence above does: every emitted module carries its own copy of\n// this runtime, and the two ends of the question are in different copies. The\n// settle that asks it belongs to whichever copy created the registry -- in an\n// application that imports velar/app, that is velar/app's -- while the places\n// that answer it, a 'detach' statement's detached-task helper and an action's\n// run, are emitted into the application module. Two module-scope variables\n// would never meet.\n//\n// Slot 0 is how deep the settle currently is inside 'observer.run()'. It is a\n// depth rather than a flag because an observer created by a running one runs\n// nested. '__velarRuntime.activeObserver' cannot stand in for it: a watch body\n// runs untracked, precisely so its own reads do not become dependencies of the\n// watched expression, so the active observer is null exactly where the 'detach'\n// that closes a cycle is written.\n//\n// Slot 1 is the fact recorded on the open window: an observer run in it started\n// asynchronous work.\nconst __velarAsyncWorkKey = Symbol.for(\"velar.web.observer.asyncwork.v1\");\nconst __velarAsyncWorkCell = (() => {\n const descriptor = __velarGraphOwnDescriptor(globalThis, __velarAsyncWorkKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable\n || !__velarGraphIsList(descriptor.value)) {\n throw new TypeError(\"VelarScript Web observer async-work ownership is invalid\");\n }\n return descriptor.value;\n }\n const cell = [0, false];\n __velarGraphDefine(globalThis, __velarAsyncWorkKey, {\n value: cell,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return cell;\n})();\n\n// What the two compiler-owned lowering points call: the detached-task helper a\n// 'detach' statement lowers to, where a detached Promise enters the runtime,\n// and an action's run, where an action call does. Outside an observer run there\n// is nothing to record -- an action a handler or '@main' starts is the host\n// task's own work, not a ring an observer closed -- so the same unconditional\n// call is correct at both sites.\nfunction __velarNoteAsyncWork() {\n if (__velarAsyncWorkCell[0] > 0) __velarAsyncWorkCell[1] = true;\n return null;\n}\n\nfunction __velarCloseTaskWindow() {\n __velarTaskSentinelArmed = false;\n __velarFlushToken = null;\n __velarAsyncWorkCell[1] = false;\n return null;\n}\n\n// The macrotask boundary the run-count window ends at. 'setTimeout' is the one\n// scheduling operation every host this runtime supports publishes -- page,\n// worker, and the Node process a 'velar test' run drives the emitted runtime\n// in -- and it is captured at module initialization like every other ambient\n// operation here. A host that publishes none is not left without a gate: the\n// window then closes as soon as the flush chain comes to rest, which is the\n// per-flush budget this runtime had before, so the synchronous cycles stay\n// covered and only the asynchronous one goes back to being invisible.\nfunction __velarArmTaskSentinel() {\n if (__velarTaskSentinelArmed) return true;\n if (typeof __velarFoundationSetTimeout !== \"function\" || typeof __velarFoundationReflectApply !== \"function\") return false;\n __velarTaskSentinelArmed = true;\n try { __velarFoundationReflectApply(__velarFoundationSetTimeout, globalThis, [__velarCloseTaskWindow, 0]); }\n catch { __velarTaskSentinelArmed = false; return false; }\n return true;\n}\n\n// The three observers that have run most in the task window running now, kept\n// as the run counts are stamped rather than reconstructed afterwards: the queue at\n// the moment the budget runs out holds only whichever half of a cycle has not\n// just run, so it cannot name the ring on its own. An observer that has run\n// once is not a candidate, which is every observer of an ordinary flush.\nconst __velarFlushLeaders = [];\n\nfunction __velarFlushLead(observer) {\n let kept = 0;\n for (let index = 0; index < __velarFlushLeaders.length; index += 1) {\n if (__velarFlushLeaders[index] === observer) continue;\n __velarFlushLeaders[kept] = __velarFlushLeaders[index];\n kept += 1;\n }\n __velarFlushLeaders.length = kept;\n let position = kept;\n while (position > 0 && __velarFlushLeaders[position - 1].flushRuns < observer.flushRuns) {\n __velarFlushLeaders[position] = __velarFlushLeaders[position - 1];\n position -= 1;\n }\n __velarFlushLeaders[position] = observer;\n if (__velarFlushLeaders.length > 3) __velarFlushLeaders.length = 3;\n}\n\n// D90 R21: compile time no longer refuses two watches that write one state, so\n// this budget is the only gate left against a mutual-write cycle -- and a\n// report that names nobody hands the author a number with no line to go to.\n// The observers that ran most in this flush chain are the cycle; flushRuns\n// already counts exactly that, so the highest few are named. A watch's label is\n// its subject as the author spelled it, which in a write cycle is also the\n// state each watch is reacting to, and the scope it was registered in supplies\n// the component the report has always had a field for.\n//\n// Nothing here asks who wrote what. That question is gone from the language,\n// and answering it would need the write frames R21 deleted.\nfunction __velarFlushRunaway(stalled, token) {\n const ranked = [];\n const seen = __velarGraphCreateSet();\n const consider = (observer) => {\n if (observer.flushToken !== token || __velarGraphSetContains(seen, observer)) return;\n __velarGraphSetInsert(seen, observer);\n ranked[ranked.length] = observer;\n };\n // A cycle alternates, so the queue at the instant the budget ran out holds\n // only the half of the ring that has not just run. The leaders carry the\n // other half.\n for (let index = 0; index < __velarFlushLeaders.length; index += 1) consider(__velarFlushLeaders[index]);\n for (let index = 0; index < stalled.length; index += 1) consider(stalled[index]);\n __velarGraphOrder(ranked, (left, right) => right.flushRuns - left.flushRuns);\n const limit = ranked.length < 3 ? ranked.length : 3;\n let detail = \"\";\n let component = \"\";\n for (let index = 0; index < limit; index += 1) {\n const observer = ranked[index];\n const named = observer.mode === \"watch\" && typeof observer.label === \"string\" && observer.label !== \"\"\n ? \"the watch on '\" + observer.label + \"'\"\n : \"a \" + observer.mode + \" observer\";\n detail += (detail === \"\" ? \"Ran most in this task: \" : \", \") + named\n + \" (\" + observer.flushRuns + (observer.flushRuns === 1 ? \" run)\" : \" runs)\");\n if (component === \"\" && typeof observer.component === \"string\") component = observer.component;\n }\n return { detail, component };\n}\n\nfunction __velarScheduleFlush() {\n if (__velarRuntime.flushPending) return;\n __velarRuntime.flushPending = true;\n __velarEnqueue(__velarFlush);\n}\n\n// Only the observers that actually re-entered the queue during the overrun\n// belong to the runaway cycle. An observer queued once by an unrelated write\n// in the same turn is innocent, and stopping it is irreversible, so it is\n// put back for the next microtask instead.\n//\n// Every overrun must still remove something, or the requeue turns the\n// microtask chain into the freeze the budget exists to end: a cycle spread\n// across more observers than the budget can run four times over re-enters\n// none of them four times, so a fixed threshold of four stops nobody and the\n// next flush repeats it forever. Two rules make the progress unconditional.\n// The threshold falls to the highest run count actually present, so any\n// queued observer this flush chain has already run is stopped; and the token\n// is carried into the flush the overrun schedules, so run counts accumulate\n// across the chain and the observers the chain has not reached yet are a\n// pool that only shrinks.\nfunction __velarFlushOverflow(token) {\n const stalled = [];\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) stalled[stalled.length] = observer;\n for (const observer of __velarGraphSetItems(__velarRuntime.watchQueue)) stalled[stalled.length] = observer;\n __velarGraphSetEmpty(__velarRuntime.domQueue);\n __velarGraphSetEmpty(__velarRuntime.watchQueue);\n let threshold = 0;\n for (let index = 0; index < stalled.length; index += 1) {\n const observer = stalled[index];\n if (observer.flushToken === token && observer.flushRuns > threshold) threshold = observer.flushRuns;\n }\n if (threshold > 4) threshold = 4;\n let requeued = false;\n for (let index = 0; index < stalled.length; index += 1) {\n const observer = stalled[index];\n if (threshold > 0 && observer.flushToken === token && observer.flushRuns >= threshold) {\n if (typeof observer.stop === \"function\") observer.stop();\n else observer.stopped = true;\n continue;\n }\n if (observer.stopped) continue;\n __velarGraphSetInsert(observer.mode === \"watch\" ? __velarRuntime.watchQueue : __velarRuntime.domQueue, observer);\n requeued = true;\n }\n const runaway = __velarFlushRunaway(stalled, token);\n // The window keeps its token and its run counts -- the requeued flush is one\n // more flush of the same task, and the pool of observers it has not reached\n // yet only shrinks -- but the budget is granted again. Without that, the\n // exhausted count would trip the very next flush of the same task, and the\n // observers stopped for it would be whatever was queued at that moment: the\n // innocent ones this overrun just put back, or an unrelated later write.\n __velarFlushBudget = __velarFlushBudgetPerTask;\n __velarFlushCarried = requeued;\n __velarRuntime.report(new RangeError(\"Reactive updates cannot run more than \" + __velarFlushBudgetPerTask + \" observers in one task\"),\n { phase: \"update\", detail: runaway.detail, component: runaway.component, unhandled: true });\n if (requeued) __velarScheduleFlush();\n}\n\n// The one entry point: the microtask __velarScheduleFlush enqueues, and the\n// synchronous drain the emitted tick() performs. It used to open and close D90\n// R1-a-scope's flush-scoped writer registry around the settle; R21 deleted the\n// registry with the referee that read it, so the name is all that remains and\n// it remains because __velarEnqueue and tick() both hold it.\n//\n// D114 W/A1: it is also where the task window is closed or handed on. Both\n// entries pass through here, including tick()'s drain, so the sentinel is armed\n// once per window however the flush was reached, and a host without a timer\n// falls back to closing the window here, one flush at a time.\nfunction __velarFlush() {\n try { __velarFlushSettle(); }\n // Without a timer the window closes as soon as the chain comes to rest,\n // which is the per-flush budget this runtime had before -- except that a\n // flush already scheduled keeps it open, so an overrun's carried counts and\n // the queues a settle could not finish reach the flush that continues them.\n finally { if (!__velarArmTaskSentinel() && !__velarRuntime.flushPending) __velarCloseTaskWindow(); }\n}\n\n// Glitch-free order: every derived value and every watch settles to a fixed\n// point before a single DOM node is written, so no watch and no rendered\n// position can read a half-updated world and no corrective watch can push an\n// invalid value through the DOM first. That is D90 R1 and it is unchanged.\n//\n// D90 R21 changed the other axis. Within the settle the watches run in\n// registration order -- source order in a module, mount order across instances\n// of one component, module-initialization order across modules -- and a watch\n// that writes state is not promoted ahead of one that only observes. Whoever is\n// written first runs first, two watches writing one state both take effect in\n// that order, and a later write that clobbers an earlier one is the author's.\n//\n// Queue insertion order is not registration order and cannot stand in for it:\n// two watches on two different states, both dirtied by one action, enter the\n// queue in the order the action wrote the states. So each pass takes the queue\n// as it stands and runs it by sequence number. Watches queued by this pass are\n// picked up by the next one, in their own order.\n//\n// D114 W/A1, narrowed by W2: a flush that starts while the task window is still\n// open continues it -- the same token, so flushRuns keeps accumulating on every\n// observer, the same leaders, and the same remaining budget -- but only when an\n// observer run in that window started asynchronous work, or when the overrun\n// itself scheduled this flush. Every other flush opens a new window, which is\n// the per-flush budget this runtime had before W.\nfunction __velarFlushSettle() {\n __velarRuntime.flushPending = false;\n const carried = __velarFlushCarried;\n __velarFlushCarried = false;\n if (__velarFlushToken === null || !(carried || __velarAsyncWorkCell[1])) {\n __velarFlushToken = {};\n __velarFlushBudget = __velarFlushBudgetPerTask;\n __velarFlushLeaders.length = 0;\n __velarAsyncWorkCell[1] = false;\n }\n const token = __velarFlushToken;\n const step = (observer) => {\n __velarGraphSetRemove(observer.mode === \"watch\" ? __velarRuntime.watchQueue : __velarRuntime.domQueue, observer);\n if (observer.flushToken === token) observer.flushRuns += 1;\n else { observer.flushToken = token; observer.flushRuns = 1; }\n if (observer.flushRuns > 1) __velarFlushLead(observer);\n // The span the two lowering points ask about. It is the run itself rather\n // than the whole settle: work started by the flush's own bookkeeping is\n // not an observer's, and a nested observer created by a running one is.\n __velarAsyncWorkCell[0] += 1;\n try { observer.run(); }\n finally { __velarAsyncWorkCell[0] -= 1; }\n };\n while (__velarGraphSetCount(__velarRuntime.domQueue) || __velarGraphSetCount(__velarRuntime.watchQueue)) {\n while (true) {\n let ran = false;\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) {\n if (observer.mode !== \"computed\") continue;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n ran = true;\n }\n if (ran) continue;\n const pending = [];\n for (const observer of __velarGraphSetItems(__velarRuntime.watchQueue)) pending[pending.length] = observer;\n __velarGraphOrder(pending, (left, right) => left.sequence - right.sequence);\n for (let index = 0; index < pending.length; index += 1) {\n const observer = pending[index];\n // A watch this pass already re-ran or stopped is no longer queued; the\n // snapshot is a plan, and the queue is what says whether it still owes\n // a run.\n if (observer.stopped || !__velarGraphSetContains(__velarRuntime.watchQueue, observer)) continue;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n ran = true;\n }\n if (!ran) break;\n }\n for (const observer of __velarGraphSetItems(__velarRuntime.domQueue)) {\n if (observer.mode === \"computed\") break;\n if ((__velarFlushBudget -= 1) < 0) { __velarFlushOverflow(token); return; }\n step(observer);\n }\n }\n if (__velarGraphSetCount(__velarRuntime.domQueue) || __velarGraphSetCount(__velarRuntime.watchQueue)) __velarScheduleFlush();\n}\n\n" + "function __velarCreateRuntime() {\n const runtime = Object.create(null);\n const domQueue = Object.freeze(__velarGraphCreateSet());\n const watchQueue = Object.freeze(__velarGraphCreateSet());\n const errorHandlers = Object.freeze(__velarGraphCreateSet());\n const unhandledFailures = Object.freeze(__velarGraphCreateSet());\n const actionFailures = Object.freeze(__velarGraphCreateWeakSet());\n const lookSources = Object.freeze(__velarGraphCreateWeakMap());\n const classSources = Object.freeze(__velarGraphCreateWeakMap());\n const dependencies = Object.freeze(__velarGraphCreateWeakMap());\n const rawToProxy = Object.freeze(__velarGraphCreateWeakMap());\n const proxyToRaw = Object.freeze(__velarGraphCreateWeakMap());\n const versions = Object.freeze(__velarGraphCreateWeakMap());\n const parents = Object.freeze(__velarGraphCreateWeakMap());\n const subscriptionStops = __velarGraphCreateWeakMap();\n const collectionBrands = __velarGraphCreateWeakMap();\n const iterateKey = Symbol.for(\"velar.reactive.iterate.v1\");\n const structureKey = Symbol.for(\"velar.reactive.structure.v1\");\n const deepKey = Symbol.for(\"velar.reactive.deep.v1\");\n let lookImplementation = null;\n const toRaw = (value) => {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) return value;\n return __velarGraphWeakMapRead(proxyToRaw, value) ?? value;\n };\n const trackSubscribers = (subscribers) => {\n const observer = runtime.activeObserver;\n if (!observer || observer.stopped) return;\n __velarGraphSetInsert(subscribers, observer);\n __velarGraphSetInsert(observer.dependencies, subscribers);\n };\n const runTracked = (observer, read) => {\n const previousDependencies = observer.dependencies;\n // Every run needs a second dependency set to diff against, and an observer\n // that re-runs thousands of times per second would otherwise allocate one\n // per run. The emptied previous set is kept as the next run's buffer.\n const spare = observer.spareDependencies;\n observer.spareDependencies = null;\n observer.dependencies = spare ?? __velarGraphCreateSet();\n const previousObserver = runtime.activeObserver;\n runtime.activeObserver = observer;\n try { return read(); }\n finally {\n runtime.activeObserver = previousObserver;\n for (const subscribers of __velarGraphSetItems(previousDependencies)) {\n if (__velarGraphSetContains(observer.dependencies, subscribers)) continue;\n // A stop fires exactly when an actual removal empties the set. Firing\n // on an already-empty set would let two detaching computeds whose\n // cleanups have not yet emptied their dependency sets re-trigger each\n // other without bound.\n if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {\n const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);\n if (stop) stop();\n }\n }\n __velarGraphSetEmpty(previousDependencies);\n observer.spareDependencies = previousDependencies;\n }\n };\n const cleanupObserver = (observer) => {\n for (const subscribers of __velarGraphSetItems(observer.dependencies)) {\n if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {\n const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);\n if (stop) stop();\n }\n }\n __velarGraphSetEmpty(observer.dependencies);\n };\n const track = (target, key) => {\n const observer = runtime.activeObserver;\n if (!observer || observer.stopped) return;\n target = toRaw(target);\n if ((typeof target !== \"object\" && typeof target !== \"function\") || target === null) return;\n let byKey = __velarGraphWeakMapRead(dependencies, target);\n if (!byKey) { byKey = __velarGraphCreateMap(); __velarGraphWeakMapWrite(dependencies, target, byKey); }\n let subscribers = __velarGraphMapRead(byKey, key);\n if (!subscribers) {\n subscribers = __velarGraphCreateSet();\n __velarGraphMapWrite(byKey, key, subscribers);\n const ownedSubscribers = subscribers;\n __velarGraphWeakMapWrite(subscriptionStops, subscribers, () => {\n if (__velarGraphMapRead(byKey, key) !== ownedSubscribers) return;\n __velarGraphMapRemove(byKey, key);\n if (__velarGraphMapCount(byKey) === 0) __velarGraphWeakMapRemove(dependencies, target);\n });\n }\n trackSubscribers(subscribers);\n };\n // P2b-9: the path a write travelled, in the words the author would recognise.\n // Only the shape is named -- never a value -- because this reaches a report.\n // The kind travels beside the phrase rather than being read back out of it:\n // the reader of this is the runaway report, and it decides which remedy to\n // give from the kind, not by looking inside a sentence.\n const describeSubject = (target, key) => {\n const container = __velarGraphIsList(target) ? \"List\" : __velarGraphIsRecord(target) ? \"record\" : \"collection\";\n if (key === iterateKey || key === structureKey) return { kind: \"collection\", text: \"the size or contents of a \" + container };\n if (key === deepKey) return { kind: \"value\", text: \"a nested value of a \" + container };\n if (typeof key === \"number\") return { kind: \"value\", text: \"element \" + key + \" of a \" + container };\n if (typeof key === \"string\") return { kind: \"value\", text: \"field '\" + key + \"'\" };\n return { kind: \"value\", text: \"a tracked value\" };\n };\n const notify = (target, key) => {\n const byKey = __velarGraphWeakMapRead(dependencies, target);\n const subscribers = byKey ? __velarGraphMapRead(byKey, key) : null;\n if (subscribers) for (const observer of __velarGraphSetItems(subscribers)) {\n // A write that lands while its own reader is still running is the\n // self-invalidating shape, and it is the only one whose path is worth\n // describing -- so the description is built there and nowhere else, which\n // keeps every ordinary write to one property read on this path. The\n // observer's own budget owns the report; this only tells it what to name.\n if (observer.running) {\n const subject = describeSubject(target, key);\n observer.selfInvalidationSubject = subject.text;\n observer.selfInvalidationKind = subject.kind;\n }\n observer.notify();\n }\n };\n const bump = (target) => {\n __velarGraphWeakMapWrite(versions, target, (__velarGraphWeakMapRead(versions, target) ?? 0) + 1);\n };\n const trigger = (target, key, iterate = false, structure = false, indexFrom = null, allKeys = false) => {\n target = toRaw(target);\n if ((typeof target !== \"object\" && typeof target !== \"function\") || target === null) return;\n bump(target);\n notify(target, key);\n if (allKeys || indexFrom !== null) {\n const byKey = __velarGraphWeakMapRead(dependencies, target);\n if (byKey) for (const candidate of __velarGraphMapKeyItems(byKey)) {\n if (candidate === key) continue;\n if (allKeys || (typeof candidate === \"number\" && candidate >= indexFrom)) notify(target, candidate);\n }\n }\n if (iterate) notify(target, iterateKey);\n if (structure) notify(target, structureKey);\n notify(target, deepKey);\n const owners = __velarGraphWeakMapRead(parents, target);\n // A mutation of an unowned value -- the overwhelmingly common case -- must\n // not pay for the cycle bookkeeping that only an ancestor walk needs.\n if (!owners) return;\n const visited = __velarGraphCreateSet();\n __velarGraphSetInsert(visited, target);\n const bubble = (current) => {\n if (__velarGraphSetContains(visited, current)) return;\n __velarGraphSetInsert(visited, current);\n bump(current);\n notify(current, deepKey);\n const next = __velarGraphWeakMapRead(parents, current);\n if (next) for (const owner of __velarGraphSetItems(next)) bubble(owner);\n };\n for (const owner of __velarGraphSetItems(owners)) bubble(owner);\n };\n const link = (child, parent) => {\n if (child === null || (typeof child !== \"object\" && typeof child !== \"function\")) return;\n linkOwner(toRaw(child), parent, true);\n };\n // 'structural' separates a slot being filled from a slot merely being read.\n // A read proves the child is in the parent right now; only a write adds an\n // occurrence, and only a write can create the duplicate the running count\n // cannot see for itself.\n const linkOwner = (child, parent, structural = false) => {\n parent = toRaw(parent);\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\") || child === parent) return;\n let owners = __velarGraphWeakMapRead(parents, child);\n if (!owners) { owners = __velarGraphCreateSet(); __velarGraphWeakMapWrite(parents, child, owners); }\n const known = __velarGraphSetContains(owners, parent);\n __velarGraphSetInsert(owners, parent);\n const counts = __velarGraphWeakMapRead(containment, parent);\n if (!counts) return;\n if (structural && known) { __velarGraphWeakMapRemove(containment, parent); return; }\n if ((__velarGraphMapRead(counts, child) ?? 0) < 1) __velarGraphMapWrite(counts, child, 1);\n };\n // Removing the last owner of a value detaches everything only that value\n // owned. Without the cascade, replacing a state root leaves every surviving\n // descendant pointing at the dead root: the root stays strongly reachable\n // and each later deep mutation walks one more generation.\n const release = (root) => {\n const pending = [root];\n let index = 0;\n while (index < pending.length) {\n const current = pending[index];\n index += 1;\n forEachOwnedValue(current, (value) => {\n const owners = __velarGraphWeakMapRead(parents, value);\n if (!owners || !__velarGraphSetContains(owners, current)) return;\n __velarGraphSetRemove(owners, current);\n if (__velarGraphSetCount(owners) > 0) return;\n __velarGraphWeakMapRemove(parents, value);\n pending[pending.length] = value;\n });\n }\n };\n const unlink = (child, parent) => {\n child = toRaw(child);\n parent = toRaw(parent);\n const owners = child !== null && (typeof child === \"object\" || typeof child === \"function\")\n ? __velarGraphWeakMapRead(parents, child)\n : null;\n if (!owners) return;\n __velarGraphSetRemove(owners, parent);\n if (__velarGraphSetCount(owners) > 0) return;\n __velarGraphWeakMapRemove(parents, child);\n release(child);\n };\n // Map and Set membership is decided once per value and remembered: the only\n // cross-realm test JavaScript offers is invoking a prototype accessor and\n // catching, and a record write must not pay two thrown exceptions per field.\n const collectionBrand = (value) => {\n const known = __velarGraphWeakMapRead(collectionBrands, value);\n if (known !== undefined) return known;\n let brand = 0;\n try { __velarGraphMapCount(value); brand = 1; }\n catch {\n try { __velarGraphSetCount(value); brand = 2; }\n catch { brand = 0; }\n }\n __velarGraphWeakMapWrite(collectionBrands, value, brand);\n return brand;\n };\n const forEachOwnedValue = (parent, visit) => {\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\")) return;\n if (__velarGraphIsList(parent)) {\n for (let index = 0; index < parent.length; index += 1) {\n const value = toRaw(__velarGraphOwnDescriptor(parent, index)?.value);\n if (value !== null && (typeof value === \"object\" || typeof value === \"function\")) visit(value);\n }\n return;\n }\n const brand = collectionBrand(parent);\n if (brand === 1) {\n for (const value of __velarGraphMapItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n // A Map key is linked to its Map exactly like a value, so releasing the\n // Map has to release object keys too.\n for (const value of __velarGraphMapKeyItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n return;\n }\n if (brand === 2) {\n for (const value of __velarGraphSetItems(parent)) {\n const owned = toRaw(value);\n if (owned !== null && (typeof owned === \"object\" || typeof owned === \"function\")) visit(owned);\n }\n return;\n }\n if (typeof parent !== \"object\") return;\n for (const name of __velarGraphOwnNames(parent)) {\n const descriptor = __velarGraphOwnDescriptor(parent, name);\n if (!descriptor || !(\"value\" in descriptor)) continue;\n const value = toRaw(descriptor.value);\n if (value !== null && (typeof value === \"object\" || typeof value === \"function\")) visit(value);\n }\n };\n // Containment used to be re-derived by scanning the whole container on every\n // element write, which made one assignment into a rendered List cost O(list\n // length). The occurrence index answers the same question -- does the parent\n // still reference this child anywhere? -- in constant time: it is built once\n // from the container's real contents and then maintained by the same link and\n // release calls that change them.\n const containment = __velarGraphCreateWeakMap();\n const countOccurrence = (counts, value) => {\n value = toRaw(value);\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) return;\n __velarGraphMapWrite(counts, value, (__velarGraphMapRead(counts, value) ?? 0) + 1);\n };\n // Mirrors exactly what the old scan looked at, Map keys included as owned\n // values are, so the index cannot answer a question the scan answered\n // differently.\n const buildContainment = (parent) => {\n const counts = __velarGraphCreateMap();\n if (__velarGraphIsList(parent)) {\n for (let index = 0; index < parent.length; index += 1) countOccurrence(counts, __velarGraphOwnDescriptor(parent, index)?.value);\n return counts;\n }\n const brand = collectionBrand(parent);\n if (brand === 1) {\n for (const value of __velarGraphMapItems(parent)) countOccurrence(counts, value);\n return counts;\n }\n if (brand === 2) {\n for (const value of __velarGraphSetItems(parent)) countOccurrence(counts, value);\n return counts;\n }\n if (!parent || typeof parent !== \"object\") return counts;\n for (const name of __velarGraphOwnNames(parent)) {\n const descriptor = __velarGraphOwnDescriptor(parent, name);\n if (descriptor && \"value\" in descriptor) countOccurrence(counts, descriptor.value);\n }\n return counts;\n };\n // The one guard every detach path shares: a primitive was never linked, and\n // an object with no owners has nothing to release, so neither may reach the\n // containment bookkeeping.\n const releaseChild = (parent, child) => {\n if (child === null || (typeof child !== \"object\" && typeof child !== \"function\")\n || !__velarGraphWeakMapContains(parents, child)) return;\n parent = toRaw(parent);\n if (parent === null || (typeof parent !== \"object\" && typeof parent !== \"function\")) return;\n child = toRaw(child);\n // A freshly built index already reflects the slot that was just cleared;\n // a maintained one still counts it, so only that one takes the decrement.\n let counts = __velarGraphWeakMapRead(containment, parent);\n let remaining;\n if (counts) remaining = (__velarGraphMapRead(counts, child) ?? 0) - 1;\n else {\n counts = buildContainment(parent);\n __velarGraphWeakMapWrite(containment, parent, counts);\n remaining = __velarGraphMapRead(counts, child) ?? 0;\n }\n if (remaining > 0) { __velarGraphMapWrite(counts, child, remaining); return; }\n __velarGraphMapRemove(counts, child);\n unlink(child, parent);\n };\n // The registry operation stays exactly two parameters wide; 'structural'\n // belongs to the internal call, which knows whether a slot is being filled or\n // merely read, and every caller outside this file fills one.\n const reactive = (value, parent = null) => reactiveValue(value, parent, true);\n const reactiveValue = (value, parent, structural) => {\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) return value;\n value = toRaw(value);\n if (parent !== null) linkOwner(value, parent, structural);\n if (typeof value !== \"object\" || __velarGraphIsList(value) || !__velarGraphIsExtensible(value)) return value;\n if (!__velarGraphIsRecord(value)) {\n // D114 P6 item 7 (ST-U4): the one place an unwrapped class instance is\n // handed back out of a state graph. In a development host its fields are\n // observed from here so a `computed` or `watch` that reads one is told\n // the read can never update; in a production build the detector's hooks\n // (stale-class.js) are null and this is one already-false test on the hot\n // path. The owner is handed over rather than the cell's name, because the\n // report names the path from the cell down to the instance.\n if (__velarStaleClassHooks !== null && parent !== null) __velarObserveClassFields(value, parent);\n return value;\n }\n let proxy = __velarGraphWeakMapRead(rawToProxy, value);\n if (proxy) return proxy;\n proxy = new __velarGraphNativeProxy(value, {\n get(target, key) {\n track(target, key);\n return reactiveValue(__velarGraphGet(target, key, target), target, false);\n },\n set(target, key, next) {\n next = toRaw(next);\n const present = __velarGraphHas(target, key);\n const previous = toRaw(__velarGraphGet(target, key, target));\n // Creating an absent key is a structural change even when the value\n // written equals the absent key's 'undefined' reading.\n const changed = !present || !__velarGraphSame(previous, next);\n const written = __velarGraphSet(target, key, next, target);\n if (!written || !changed) return written;\n link(next, target);\n releaseChild(target, previous);\n trigger(target, key, true, !present);\n return true;\n },\n has(target, key) { track(target, key); return __velarGraphHas(target, key); },\n deleteProperty(target, key) {\n if (!__velarGraphHas(target, key)) return true;\n const previous = toRaw(__velarGraphGet(target, key, target));\n const deleted = __velarGraphDelete(target, key);\n if (deleted) {\n releaseChild(target, previous);\n trigger(target, key, true, true);\n }\n return deleted;\n },\n });\n __velarGraphWeakMapWrite(rawToProxy, value, proxy);\n __velarGraphWeakMapWrite(proxyToRaw, proxy, value);\n return proxy;\n };\n const trackDeep = (value) => { value = toRaw(value); track(value, deepKey); return value; };\n const versionOf = (value) => {\n value = toRaw(value);\n return value && (typeof value === \"object\" || typeof value === \"function\")\n ? __velarGraphWeakMapRead(versions, value) ?? 0\n : 0;\n };\n const collectionRead = (value, key, child) => {\n value = toRaw(value);\n track(value, key);\n // Only containers already connected to a state graph own children read\n // through them. Fresh derived Lists (filter/map/etc.) stay ephemeral and\n // cannot become strongly retained parents of every item merely by being\n // iterated during rendering.\n return reactiveValue(child, __velarGraphWeakMapContains(parents, value) ? value : null, false);\n };\n const collectionTrigger = (value, key, iterate = true, structure = false, indexFrom = null, allKeys = false) => trigger(toRaw(value), key, iterate, structure, indexFrom, allKeys);\n const collectionUnlink = (value, child) => {\n releaseChild(toRaw(value), toRaw(child));\n };\n const computed = (read) => {\n if (typeof read !== \"function\") throw new TypeError(\"computed requires a function\");\n let dirty = true;\n let evaluating = false;\n let recursed = false;\n let initialized = false;\n let value;\n let failed = false;\n let failure;\n const subscribers = __velarGraphCreateSet();\n const notifyDependents = (skip = null) => {\n for (const dependent of __velarGraphSetItems(subscribers)) if (dependent !== skip) dependent.notify();\n };\n const invalidateComputedDependents = () => {\n for (const dependent of __velarGraphSetItems(subscribers)) {\n if (dependent.mode === \"computed\") dependent.notify();\n }\n };\n const observer = {\n mode: \"computed\",\n stopped: false,\n running: false,\n selfInvalidations: 0,\n // P2b-9: filled in by the graph's notify when a write lands while this\n // value is still being derived, so the runaway report names the path.\n selfInvalidationSubject: \"\",\n selfInvalidationKind: \"\",\n dependencies: __velarGraphCreateSet(),\n notify() {\n // Stopping is shared discipline with DOM and watch observers: a flush\n // overflow marks queued computed observers stopped, and a stopped\n // observer must go inert instead of re-entering the storm on the next\n // write.\n if (observer.stopped) return;\n // The 100 self-invalidation cap covers computed observers too. A\n // computed whose own turn (evaluation plus dependent notification)\n // keeps invalidating it is stopped with the same owned report a\n // render or watch observer gets, instead of running to the whole\n // flush budget.\n if (observer.running) {\n observer.selfInvalidations += 1;\n if (observer.selfInvalidations > 100) {\n observer.stopped = true;\n cleanupObserver(observer);\n reportUntracked(new RangeError(\"A computed value cannot invalidate itself more than 100 times\"\n + (observer.selfInvalidationSubject ? \": it writes \" + observer.selfInvalidationSubject + \" while reading it\" : \"\")));\n return;\n }\n } else {\n observer.selfInvalidations = 0;\n }\n if (dirty) return;\n dirty = true;\n if (__velarGraphSetCount(subscribers) === 0) {\n cleanupObserver(observer);\n return;\n }\n schedule(observer);\n // A downstream computed must become dirty immediately so a same-turn\n // read cannot observe its cached result while an upstream dependency\n // is already stale. DOM and watch observers still wait for evaluation\n // to prove that the public result actually changed.\n invalidateComputedDependents();\n },\n run() {\n if (observer.stopped || !dirty || __velarGraphSetCount(subscribers) === 0) return;\n observer.running = true;\n try {\n if (evaluate(false)) notifyDependents();\n } finally { observer.running = false; }\n },\n };\n const detach = () => {\n cleanupObserver(observer);\n dirty = true;\n };\n __velarGraphWeakMapWrite(subscriptionStops, subscribers, detach);\n const evaluate = (throwFailure) => {\n if (evaluating) {\n recursed = true;\n throw new RangeError(\"A computed value cannot read itself recursively\");\n }\n const previous = value;\n const previouslyFailed = failed;\n const previousFailure = failure;\n const hadValue = initialized;\n evaluating = true;\n recursed = false;\n failed = false;\n failure = undefined;\n try { value = runTracked(observer, read); }\n catch (error) { failed = true; failure = error; }\n finally {\n evaluating = false;\n initialized = true;\n dirty = false;\n }\n // A computed that failed because its own recursion guard tripped sits on\n // a dependency cycle. The failure is cached and served, but the cyclic\n // edges must not persist: two failed computeds that keep notifying each\n // other would otherwise ping-pong the next flush into the whole-flush\n // budget. Detaching unwinds the cycle (a peer whose last subscriber\n // leaves detaches with it) and a later read simply re-attempts.\n if (failed && recursed) detach();\n else if (__velarGraphSetCount(subscribers) === 0) detach();\n recursed = false;\n const changed = !hadValue || previouslyFailed !== failed || (failed ? previousFailure !== failure : !__velarGraphSame(previous, value));\n if (throwFailure && failed) throw failure;\n return changed;\n };\n const access = () => {\n const consumer = runtime.activeObserver;\n if (consumer !== observer) trackSubscribers(subscribers);\n if (dirty && !observer.stopped) {\n // A cyclic read re-enters access while the outer evaluation is still\n // running, so the running span is restored, never cleared.\n const wasRunning = observer.running;\n observer.running = true;\n try {\n const changed = evaluate(false);\n if (changed && initialized) notifyDependents(consumer);\n } finally { observer.running = wasRunning; }\n }\n if (failed) throw failure;\n return value;\n };\n return __velarGraphFreeze(access);\n };\n // The loud channel for a failure nothing owns.\n //\n // D114 P6 item 4 (LC-C1) and F9-web (WB-C1): every `tick()` waiting on the\n // flush is a claimant, in every host. A caller waiting on the flush is the\n // one place a failure nobody handled can be delivered *to somebody*, so the\n // flush's first unowned failure is parked and every pending `tick()` rejects\n // with it -- the promise that awaiting `tick()` cannot step over a broken\n // update is one the second concurrent awaiter has to keep too.\n //\n // Everything else goes to the host, and there is no second channel beside a\n // claimant: a later failure in the same flush, whose claimants are already\n // spoken for, and every failure raised with nobody waiting at all. In a\n // browser that is the microtask throw the host error event catches and the\n // page survives; in a non-browser host (a headless 'velar test' process, a\n // worker) the same throw would terminate the process, which the runtime\n // boundary forbids, so there it is traced to the report channel. Nothing is\n // parked for a `tick()` that is not yet waiting, because a caller who arrives\n // after the flush was never waiting on it.\n const escalate = (error) => {\n if (__velarTickWaiting() && __velarGraphSetCount(unhandledFailures) === 0) {\n __velarGraphSetInsert(unhandledFailures, error);\n return;\n }\n if (__velarDomDocument !== null) {\n __velarEnqueue(() => { throw error; });\n return;\n }\n __velarFoundationTrace(error);\n };\n const report = (value, options) => {\n const error = __velarNormalizeError(value);\n const checked = __velarReportOptions(options);\n const timestamp = __velarNow();\n if (!__velarWebErrorFinite(timestamp)) throw new TypeError(\"The browser returned an invalid error timestamp\");\n const errorReport = __velarWebErrorFreeze({\n error,\n phase: checked.phase,\n detail: checked.detail,\n component: checked.component,\n timestamp,\n });\n let handled = false;\n for (const handler of __velarGraphSetItems(errorHandlers)) {\n handled = true;\n try {\n const result = handler(errorReport);\n __velarObservePromise(result, (failure) => escalate(__velarNormalizeError(failure)));\n } catch (failure) { escalate(__velarNormalizeError(failure)); }\n }\n if (checked.unhandled && !handled) escalate(error);\n return errorReport;\n };\n // A report raised from inside a tracked evaluation (the computed cap) must\n // not let handler reads become dependencies of the failing observer.\n const reportUntracked = (error) => {\n const previousObserver = runtime.activeObserver;\n runtime.activeObserver = null;\n try { report(error, { phase: \"update\", detail: \"\", component: \"\", unhandled: true }); }\n finally { runtime.activeObserver = previousObserver; }\n };\n // The queue insert stays on the registry -- computed observers are created by\n // whichever module stamped it first (velar/app under ESM import order, or the\n // application prelude) and must schedule correctly whichever that was -- but\n // the drain it calls is the module-scope one below, and there is now exactly\n // one of those. A queue that outgrows its bound is the flush budget's failure\n // to own, not an exception thrown out of the assignment that happened to\n // cross the line: throwing here left the writing cell's subscriber walk half\n // finished, with the remaining observers subscribed and never notified again.\n const schedule = (observer) => {\n __velarGraphSetInsert(observer.mode === \"watch\" ? watchQueue : domQueue, observer);\n __velarScheduleFlush();\n };\n const applyLook = (...arguments_) => {\n if (!lookImplementation) throw new TypeError(\"Link Look requires the VelarScript Web runtime\");\n return lookImplementation(...arguments_);\n };\n const installLook = (implementation) => {\n if (typeof implementation !== \"function\") throw new TypeError(\"VelarScript Look integration requires a function\");\n lookImplementation ??= implementation;\n return null;\n };\n const fields = {\n version: \"0.12\", domQueue, watchQueue, flushPending: false, activeObserver: null, errorHandlers,\n actionFailures, unhandledFailures, lookSources, classSources, dependencies, rawToProxy, proxyToRaw, versions, parents,\n toRaw, reactive, track, trackDeep, trigger, versionOf, collectionRead, collectionTrigger, collectionUnlink,\n trackSubscribers, runTracked, cleanupObserver, computed,\n schedule, report, applyLook, installLook,\n };\n for (const name of __velarRuntimeFields) Object.defineProperty(runtime, name, {\n value: fields[name],\n enumerable: false,\n configurable: false,\n writable: name === \"flushPending\" || name === \"activeObserver\",\n });\n return Object.preventExtensions(runtime);\n}\n\nfunction __velarRequireRuntime(value) {\n if (!value || typeof value !== \"object\") throw new TypeError(\"VelarScript Web runtime ownership is invalid\");\n // The schema comparison comes first, ahead of ownership and the field roster:\n // a schema bump normally changes the roster too, so leaving it last reported\n // \"fields are invalid\" and never named the one fact that identifies the\n // cause. The version is read through its descriptor rather than the property\n // so an unvalidated object cannot answer it with a getter.\n const __velarVersionDescriptor = Object.getOwnPropertyDescriptor(value, \"version\");\n const __velarVersion = __velarVersionDescriptor && \"value\" in __velarVersionDescriptor ? __velarVersionDescriptor.value : undefined;\n if (__velarVersion !== \"0.12\") {\n throw new TypeError(\"VelarScript Web runtime schema \" + (typeof __velarVersion === \"string\" ? __velarVersion : \"(unknown)\") + \" does not match this module's schema 0.12; one build mixed two generations of @velarscript/* — run 'npm ls @velarscript/compiler' and pin one version\");\n }\n if (Object.getPrototypeOf(value) !== null || Object.isExtensible(value)\n || Object.getOwnPropertySymbols(value).length > 0) throw new TypeError(\"VelarScript Web runtime ownership is invalid\");\n const names = Object.getOwnPropertyNames(value);\n if (names.length !== __velarRuntimeFields.length || __velarRuntimeFields.some((name) => !names.includes(name))) {\n throw new TypeError(\"VelarScript Web runtime fields are invalid\");\n }\n for (const name of __velarRuntimeFields) {\n const descriptor = Object.getOwnPropertyDescriptor(value, name);\n const mutable = name === \"flushPending\" || name === \"activeObserver\";\n if (!descriptor || !(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable !== mutable) {\n throw new TypeError(\"VelarScript Web runtime field '\" + name + \"' is invalid\");\n }\n }\n if (!__velarRuntimeCollection(value.domQueue, \"Set\") || !__velarRuntimeCollection(value.watchQueue, \"Set\")\n || typeof value.flushPending !== \"boolean\" || (value.activeObserver !== null && typeof value.activeObserver !== \"object\")\n || !__velarRuntimeCollection(value.errorHandlers, \"Set\") || !__velarRuntimeCollection(value.actionFailures, \"WeakSet\")\n || !__velarRuntimeCollection(value.unhandledFailures, \"Set\")\n || !__velarRuntimeCollection(value.lookSources, \"WeakMap\") || !__velarRuntimeCollection(value.classSources, \"WeakMap\")\n || !__velarRuntimeCollection(value.dependencies, \"WeakMap\") || !__velarRuntimeCollection(value.rawToProxy, \"WeakMap\")\n || !__velarRuntimeCollection(value.proxyToRaw, \"WeakMap\") || !__velarRuntimeCollection(value.versions, \"WeakMap\")\n || !__velarRuntimeCollection(value.parents, \"WeakMap\")\n || typeof value.toRaw !== \"function\" || typeof value.reactive !== \"function\" || typeof value.track !== \"function\"\n || typeof value.trackDeep !== \"function\" || typeof value.trigger !== \"function\" || typeof value.versionOf !== \"function\"\n || typeof value.collectionRead !== \"function\" || typeof value.collectionTrigger !== \"function\" || typeof value.collectionUnlink !== \"function\"\n || typeof value.trackSubscribers !== \"function\" || typeof value.runTracked !== \"function\"\n || typeof value.cleanupObserver !== \"function\" || typeof value.computed !== \"function\" || typeof value.schedule !== \"function\"\n || typeof value.report !== \"function\" || typeof value.applyLook !== \"function\" || typeof value.installLook !== \"function\") {\n throw new TypeError(\"VelarScript Web runtime values are invalid\");\n }\n return value;\n}\n\nconst __velarRuntime = (() => {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, __velarRuntimeKey);\n if (descriptor) {\n if (!(\"value\" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {\n throw new TypeError(\"VelarScript Web runtime registry ownership is invalid\");\n }\n return __velarRequireRuntime(descriptor.value);\n }\n const runtime = __velarCreateRuntime();\n Object.defineProperty(globalThis, __velarRuntimeKey, {\n value: runtime,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return runtime;\n})();\n" + "/**\n * D114 P6 item 7 (ST-U4), completed by F9-web (WB-I3 / WB-I4 / WB-U4): the\n * development host's detector for a `computed`, a `watch` subject or a DOM\n * interpolation that reads a field of a class instance held in `state`.\n *\n * web-api's rule stands and is not changing: classes are never wrapped, because\n * a proxy over an instance would change what `self` is and what identity means.\n * The consequence had no name: `state box = Counter()` with\n * `computed shown = box.value` compiles clean, renders once, and never updates\n * again, because `box.bump()` writes a field nothing is watching. Only\n * replacing the cell publishes. `<p>{box.value}</p>` is the same fact one step\n * closer to the page -- the text node is written once and never again -- so the\n * three readers are one rule and earn one sentence.\n *\n * So the instance's own data fields are observed while a development host is\n * present -- the same trade the frozen-read detector makes, in the same\n * channel. The instance is not replaced: an accessor pair over the value it\n * already held keeps its identity, its prototype, and what `self` means inside\n * its own methods, which a proxy could not. A production build publishes no\n * hooks, so none of this exists there.\n *\n * Three things this file owns that the report did not have before:\n *\n * - **What to write instead (WB-I3).** The remedy used to be spelled\n * `cell = Class(...)` whatever shape the value was in, and the walk that\n * finds the cell climbs through records and Lists -- so `state holder =\n * {box: Box()}` was told to write `holder = Box(...)`, which does not\n * compile. The walk now carries the path it climbed, and the remedy is\n * written for the shape that actually holds the instance.\n * - **When the read has actually gone stale (WB-I4).** A `const` field is one\n * nothing can change, so a read of it can never go stale and the sentence\n * \"changing 'value' publishes nothing\" describes something that will not\n * happen. The emitted class makes `const` and `let` the same ordinary data\n * property, so the runtime cannot tell them apart by looking -- but it does\n * not have to: the report is made when the field is **written** under a\n * reader that cannot see it, which is the frozen-read detector's own rule\n * (\"a report is made when one of them later changes -- never when it is\n * read\"). A field nothing writes is never reported, and `const` is exactly\n * the case where nothing can.\n * - **The member the line reads (WB-U4).** `get shown()` backed by a field\n * `inner` was reported as `inner`, a name the author's line never contains\n * and may not know exists. A read that enters through the class's own\n * getter or method records that member for as long as it runs, so the\n * report can name both.\n */\nconst __velarStaleClassHooks = (() => {\n const hooks = globalThis.__velarDevelopmentHooks;\n return hooks && typeof hooks.frozenRead === \"function\" ? hooks : null;\n})();\nconst __velarStaleClassSeen = __velarStaleClassHooks === null ? null : __velarGraphCreateWeakSet();\nconst __velarStaleClassWrapped = __velarStaleClassHooks === null ? null : __velarGraphCreateWeakSet();\nconst __velarStaleClassReported = __velarStaleClassHooks === null ? null : __velarGraphCreateSet();\n// The class member a read is currently inside, or null when the reading line\n// names the field itself. Outermost wins: a method that reads through a getter\n// of its own is still entered as the method the author wrote.\nlet __velarStaleClassMember = null;\n\n/** The written class name, or null where the value is not an instance of one. */\nfunction __velarStaleClassName(instance) {\n const prototype = __velarGraphPrototype(instance);\n if (prototype === null) return null;\n const constructor = __velarGraphOwnDescriptor(prototype, \"constructor\");\n const value = constructor && \"value\" in constructor ? constructor.value : null;\n if (typeof value !== \"function\") return null;\n const named = __velarGraphOwnDescriptor(value, \"name\");\n const name = named && \"value\" in named ? named.value : null;\n return typeof name === \"string\" && name !== \"\" ? name : null;\n}\n\n/**\n * Which slot of `owner` holds `child`: a record field, a List index, or null\n * where the owner is a shape whose slot has no spelling an author can write --\n * a `Map`, a `Set`, or an owner that no longer references the child at all. A\n * slot that cannot be named is a remedy that cannot be written, and the report\n * says so rather than inventing one.\n */\nfunction __velarStaleClassSlot(owner, child) {\n if (owner === null || typeof owner !== \"object\") return null;\n if (__velarGraphIsList(owner)) {\n for (let index = 0; index < owner.length; index += 1) {\n const descriptor = __velarGraphOwnDescriptor(owner, index);\n if (descriptor && \"value\" in descriptor && descriptor.value === child) return { index, field: null };\n }\n return null;\n }\n if (!__velarGraphIsRecord(owner)) return null;\n for (const name of __velarGraphOwnNames(owner)) {\n const descriptor = __velarGraphOwnDescriptor(owner, name);\n if (descriptor && \"value\" in descriptor && descriptor.value === child) return { index: -1, field: name };\n }\n return null;\n}\n\n/**\n * The `state` cell a value was reached through and the path from that cell down\n * to it, or null when no cell is above it. The walk is bounded and\n * breadth-first over the same ownership graph a deep change bubbles up, so a\n * class instance held one or two records below a state cell is found -- and a\n * value that is not under one is not reported about at all, because the report\n * has to name the place whose replacement publishes.\n *\n * `steps` is null when some owner on the path holds the value in a slot with no\n * written spelling; the cell is still named, and the remedy drops to the one\n * sentence that is true for every shape.\n */\nfunction __velarStaleClassLocation(instance, parent) {\n const seen = __velarGraphCreateSet();\n let frontier = [{ value: parent, child: instance, steps: [] }];\n for (let depth = 0; depth < 8 && frontier.length > 0; depth += 1) {\n const next = [];\n for (const entry of frontier) {\n const candidate = entry.value;\n if (candidate === null || (typeof candidate !== \"object\" && typeof candidate !== \"function\")) continue;\n if (__velarGraphSetContains(seen, candidate)) continue;\n __velarGraphSetInsert(seen, candidate);\n const descriptor = __velarGraphOwnDescriptor(candidate, \"velarStateName\");\n const name = descriptor && \"value\" in descriptor ? descriptor.value : null;\n // A cell holds its value in a closure rather than in a slot, so the step\n // into it is the cell itself and the path collected so far is complete.\n if (typeof name === \"string\" && name !== \"\") return { cell: name, steps: entry.steps };\n const owners = __velarGraphWeakMapRead(__velarRuntime.parents, candidate);\n if (!owners) continue;\n const slot = __velarStaleClassSlot(candidate, entry.child);\n let steps = null;\n if (slot !== null && entry.steps !== null) {\n steps = [slot];\n for (let index = 0; index < entry.steps.length; index += 1) steps[steps.length] = entry.steps[index];\n }\n for (const above of __velarGraphSetItems(owners)) next[next.length] = { value: above, child: candidate, steps };\n }\n frontier = next;\n }\n return null;\n}\n\n/** `holder.box`, `boxes[0]`, `groups[0].box` -- the path an author can read the value through. */\nfunction __velarStaleClassPath(cell, steps, count) {\n let text = cell;\n for (let index = 0; index < count; index += 1) {\n const step = steps[index];\n text += step.field === null ? \"[\" + step.index + \"]\" : \".\" + step.field;\n }\n return text;\n}\n\n/**\n * The write that publishes, for the shape the instance is actually in. The flat\n * case replaces the cell; a record below it is replaced with the field written\n * over, which is the update every other record in `state` takes; a List element\n * is replaced by index.\n */\nfunction __velarStaleClassRemedy(location, className) {\n const steps = location.steps;\n if (steps === null) return \"only replacing the value in state '\" + location.cell + \"' that holds it publishes.\";\n if (steps.length === 0) return \"only replacing the cell -- '\" + location.cell + \" = \" + className + \"(...)' -- publishes.\";\n const last = steps[steps.length - 1];\n const owner = __velarStaleClassPath(location.cell, steps, steps.length - 1);\n if (last.field === null) {\n return \"only replacing the element -- '\" + owner + \"[\" + last.index + \"] = \" + className + \"(...)' -- publishes.\";\n }\n return \"only replacing it -- '\" + owner + \" = {...\" + owner + \", \" + last.field + \": \" + className + \"(...)}' -- publishes.\";\n}\n\n/** The reading line, captured where the read happens rather than where the report is made. */\nfunction __velarStaleClassSite() {\n const site = new Error(\"velar stale class read\");\n try { return typeof site.stack === \"string\" ? site.stack : \"\"; } catch { return \"\"; }\n}\n\n/**\n * One mistake, one sentence, once per place, class and field -- whichever of\n * the three readers reached it first. Only the words that name the reader\n * change: a `computed` and a `watch` subject are a reactive value, and a\n * position in the document is the interpolation that wrote it.\n */\nfunction __velarReportStaleClassField(location, className, field, member, mode, stack) {\n const named = typeof member === \"string\" && member !== \"\" && member !== field ? member : null;\n const path = location.steps === null || location.steps.length === 0\n ? \"\" : \" at '\" + __velarStaleClassPath(location.cell, location.steps, location.steps.length) + \"'\";\n // Keyed by the place and the field, not by the member: two members that read\n // one field are two lines about one field that does not publish, and the\n // report names whichever reader reached it first, as it always has.\n const key = location.cell + \"|\" + path + \"|\" + className + \"|\" + field;\n if (__velarGraphSetContains(__velarStaleClassReported, key)) return;\n __velarGraphSetInsert(__velarStaleClassReported, key);\n const reader = mode === \"dom\" ? \"interpolation\" : \"value\";\n __velarStaleClassHooks.frozenRead({\n message: \"This \" + (mode === \"dom\" ? \"interpolation\" : \"reactive value\") + \" reads '\" + (named ?? field) + \"' on the \"\n + className + \" held in state '\" + location.cell + \"'\" + path + \".\"\n + (named === null ? \"\" : \" '\" + named + \"' reads the field '\" + field + \"'.\")\n + \" A class instance is never wrapped, so changing '\" + field\n + \"' publishes nothing and this \" + reader + \" stays as it is: \"\n + __velarStaleClassRemedy(location, className)\n + \" Hold the field in its own 'state' if it is meant to be followed.\",\n stack,\n });\n}\n\n/**\n * Observes one instance's own writable data fields. Fields the class did not\n * declare as plain values -- a getter it wrote itself, a sealed field -- are\n * left exactly as they are: this detector may not change what the program does,\n * only notice what it cannot see.\n *\n * The report is made when a reader that cannot follow the field meets a real\n * change to it, in whichever order the two arrive: a read that is already stale\n * reports on the spot, and a read of a value that changes later reports at the\n * change, on the line the read was made. A field that never changes is never\n * reported, which is what keeps a `const` field silent (WB-I4).\n */\nfunction __velarObserveClassFields(instance, parent) {\n if (__velarGraphWeakSetContains(__velarStaleClassSeen, instance)) return;\n __velarGraphWeakSetInsert(__velarStaleClassSeen, instance);\n const className = __velarStaleClassName(instance);\n if (className === null) return;\n const location = __velarStaleClassLocation(instance, parent);\n if (location === null) return;\n let observed = false;\n for (const field of __velarGraphOwnNames(instance)) {\n const descriptor = __velarGraphOwnDescriptor(instance, field);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.writable || !descriptor.configurable) continue;\n observed = true;\n let held = descriptor.value;\n let waiting = null;\n let moved = false;\n __velarGraphDefine(instance, field, {\n enumerable: descriptor.enumerable,\n configurable: true,\n // Named, not shorthand, for the frozen-read detector's reason: the\n // development host walks past its own frames to find the reading line,\n // and every engine spells an anonymous accessor differently.\n get: function __velarStaleClassFieldRead() {\n const observer = __velarRuntime.activeObserver;\n // Every mode an observer has is a reader that re-runs only when a\n // dependency it tracked changes, and this field is never one: the\n // rendering tier (\"dom\") is as stuck as the derivation tier.\n if (observer !== null && (observer.mode === \"computed\" || observer.mode === \"watch\" || observer.mode === \"dom\")) {\n if (moved) __velarReportStaleClassField(location, className, field, __velarStaleClassMember, observer.mode, __velarStaleClassSite());\n else if (waiting === null) waiting = { mode: observer.mode, member: __velarStaleClassMember, site: __velarStaleClassSite() };\n }\n return held;\n },\n set: function __velarStaleClassFieldWrite(next) {\n if (__velarGraphSame(held, next)) return;\n held = next;\n moved = true;\n if (waiting === null) return;\n const claim = waiting;\n waiting = null;\n __velarReportStaleClassField(location, className, field, claim.member, claim.mode, claim.site);\n },\n });\n }\n if (observed) __velarObserveClassMembers(instance);\n}\n\n/**\n * Records which of the class's own members a read entered through, so a report\n * can name the one the author's line contains as well as the field underneath\n * it. Only the prototype of an instance whose fields this detector already took\n * over is touched, and only in a development host: an object it observes\n * nothing on is one it has no report to make about either.\n */\nfunction __velarObserveClassMembers(instance) {\n const prototype = __velarGraphPrototype(instance);\n if (prototype === null || __velarGraphWeakSetContains(__velarStaleClassWrapped, prototype)) return;\n __velarGraphWeakSetInsert(__velarStaleClassWrapped, prototype);\n for (const member of __velarGraphOwnNames(prototype)) {\n // The compiler owns its own contracts -- `@dispose:` emits `__velar:dispose`\n // -- and a member the author did not write is not one their line names.\n if (member === \"constructor\" || member.indexOf(\"__velar\") === 0 || member.indexOf(\":\") >= 0) continue;\n const descriptor = __velarGraphOwnDescriptor(prototype, member);\n if (!descriptor || !descriptor.configurable) continue;\n if (typeof descriptor.get === \"function\" && descriptor.set === undefined) {\n const read = descriptor.get;\n __velarGraphDefine(prototype, member, {\n enumerable: descriptor.enumerable,\n configurable: true,\n get: function __velarStaleClassMemberRead() { return __velarStaleClassEnter(member, read, this, []); },\n });\n continue;\n }\n if (!(\"value\" in descriptor) || typeof descriptor.value !== \"function\") continue;\n const call = descriptor.value;\n __velarGraphDefine(prototype, member, {\n enumerable: descriptor.enumerable,\n configurable: true,\n writable: descriptor.writable,\n value: function __velarStaleClassMemberCall(...values) { return __velarStaleClassEnter(member, call, this, values); },\n });\n }\n}\n\nfunction __velarStaleClassEnter(member, operation, receiver, values) {\n const outer = __velarStaleClassMember;\n if (outer === null) __velarStaleClassMember = member;\n try { return __velarGraphApply(operation, receiver, values, \"class member\"); }\n finally { __velarStaleClassMember = outer; }\n}\n";
16
16
  /**
17
17
  * The reactive runtime an application installs once: the captured host ABI,
18
18
  * the flush budget and its runaway report, and the dependency graph itself.
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-sources.generated.js","sourceRoot":"","sources":["../src/runtime-sources.generated.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,iEAAiE;AACjE,2EAA2E;AAC3E,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AAExE,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAEtN,yGAAyG;AACzG,MAAM,CAAC,MAAM,oBAAoB,GAAG,6s+BAA6s+B,CAAC;AAElv+B,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,uvWAAuvW,CAAC;AAEnyW,MAAM,CAAC,MAAM,2BAA2B,GAAG,+jDAA+jD,CAAC;AAE3mD,0FAA0F;AAC1F,MAAM,CAAC,MAAM,sBAAsB,GAAG,iCAAiC,GAAG,IAAI,GAAG,2BAA2B,CAAC;AAE7G,MAAM,CAAC,MAAM,mBAAmB,GAAG,yqRAAyqR,GAAG,+zjBAA+zjB,GAAG,yskCAAyskC,GAAG,uggBAAuggB,CAAC;AAEru5E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,GAAG,IAAI,GAAG,oBAAoB,GAAG,IAAI,GAAG,sBAAsB,GAAG,IAAI,GAAG,mBAAmB,CAAC;AAE7J;;;G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AiC,GAAG,4GAA4G,CAAC;AAE9J,MAAM,CAAC,MAAM,4CAA4C,GAAG,iwCAAiwC,CAAC;AAE9zC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,moHAAmoH,CAAC;AAE3qH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2iGAA2iG,GAAG,gyeAAgye,GAAG,wrKAAwrK,GAAG,66HAA66H,GAAG,yiUAAyiU,GAAG,ksWAAksW,GAAG,0yJAA0yJ,GAAG,ojvBAAojvB,GAAG,ihPAAihP,GAAG,m6LAAm6L,GAAG,wnOAAwnO,GAAG,24EAA24E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velarscript/web",
3
- "version": "0.33.0",
3
+ "version": "0.33.1",
4
4
  "description": "The official VelarScript Web framework contract and browser runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@velarscript/compiler": "0.33.0"
36
+ "@velarscript/compiler": "0.33.1"
37
37
  },
38
38
  "exports": {
39
39
  ".": {