@pithyjs/core 0.1.0-beta.22 → 0.1.0-beta.23
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 +4 -0
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +2 -1
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +20 -68
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +2 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +13 -5
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/propNames.d.ts +5 -1
- package/dist/compile/binds/propNames.d.ts.map +1 -1
- package/dist/compile/binds/propNames.js +36 -1
- package/dist/compile/binds/propNames.js.map +1 -1
- package/dist/compile/binds/propWarnings.d.ts +11 -0
- package/dist/compile/binds/propWarnings.d.ts.map +1 -0
- package/dist/compile/binds/propWarnings.js +43 -0
- package/dist/compile/binds/propWarnings.js.map +1 -0
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +6 -6
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/evalDiagnostics.d.ts +5 -0
- package/dist/compile/evalDiagnostics.d.ts.map +1 -1
- package/dist/compile/evalDiagnostics.js +5 -0
- package/dist/compile/evalDiagnostics.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts +3 -1
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +9 -5
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +6 -0
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +17 -1
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/runtime/applyBindings.js +7 -2
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts +3 -1
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +11 -3
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +19 -5
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/types.d.ts +2 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/types/globals.d.ts +2 -0
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssrCrashes.js","sourceRoot":"","sources":["../../src/compile/ssrCrashes.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,2BAA2B,CAAC;AAcnC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa;IACpB,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,CAAC,CAAC,iBAAiB,KAAnB,CAAC,CAAC,iBAAiB,GAAK,IAAI,GAAG,EAAE,EAAiC,CAAC;AAC7E,CAAC;A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,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,4EAA4E;YAC5E,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBAAE,oBAAoB,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;;gBACnD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;QACvB,CAAC;;YAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IACD,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,iJAAiJ;AACjJ,MAAM,UAAU,qBAAqB,CAAC,EAAW;IAC/C,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM;QAAE,OAAO;IACnD,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,KAAK;QAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-crashes\",\n \"title\": \"SSR Unhandled Component Crash Collector\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\nimport { untrack } from '@pithyjs/signals';\nimport { pithyGlobals } from '../types/globals';\nimport { isSSRMode } from './ssrMode';\nimport {\n boundaryContext,\n findParentBoundary,\n isInHiddenContent,\n registeredClosest,\n setBoundaryError,\n slotOwnerOf,\n type BoundaryInfo,\n} from './binds/bindErrorBoundary';\n\n/**\n * A component render crash recorded during a static/server render.\n */\nexport interface SSRRenderCrash {\n /** The custom-element placeholder the crashed component was to replace. */\n el: Element;\n /** Authored tag name, for the failure message. */\n tag: string;\n /** The error the component threw. */\n error: Error;\n}\n\n/**\n * Crashes recorded during the current server render, keyed by the placeholder\n * element so a later binding pass over the same element can retract its own\n * earlier record (see `clearSSRRenderCrash`).\n *\n * Held on `globalThis`, not in this module. `@pithyjs/ssr` depends on\n * `@pithyjs/core` as a regular dependency, so an app and the SSR package can\n * resolve two physical copies: `html()` would record into the app's copy while\n * `renderToString()` collected and reset the SSR package's, reintroducing\n * BUG-018 *and* leaking the app copy's DOM records for the life of the process.\n * The same reasoning already puts `__PITHY_SSR__` and `__getComponentContext`\n * on this bridge.\n *\n * A `Map` (not a `WeakMap`) because the collector must be enumerable at flush\n * time. `resetSSRRenderCrashes()` is what keeps it from retaining DOM across\n * renders — the SSR renderer calls it in a `finally`.\n */\nfunction crashRegistry(): Map<Element, SSRRenderCrash> {\n const g = pithyGlobals();\n return (g.__pithySSRCrashes ??= new Map()) as Map<Element, SSRRenderCrash>;\n}\n\n/**\n * Forget any crash previously recorded for `el`.\n *\n * Called only at points where the record is provably no longer the outcome, and\n * NEVER before invoking a component. Retracting eagerly at the top of an attempt\n * hides a failed retry: a component that throws detached and then returns\n * something unusable would have its only record erased, shipping a page with a\n * missing subtree and a green build. The three call sites are:\n *\n * 1. A boundary ACCEPTING the error (`setBoundaryError()` returning `true`).\n * A boundary merely being in scope is not enough — an already-active one\n * with no free ancestor rejects the error, and that is as unhandled as\n * having no boundary at all.\n * 2. A component returning a usable node that then successfully reaches the\n * document, i.e. after `replaceWith` has not thrown.\n * 3. An element that has left the tree being bound (`scope.contains(el)` in\n * `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can\n * no longer contribute to the output, so any record for it is stale.\n *\n * Every one of these is mutation-tested; removing any of them turns a correct\n * render into a failed route, or a broken one into a silent success.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"clearSSRRenderCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function clearSSRRenderCrash(el: Element): void {\n crashRegistry().delete(el);\n}\n\n/**\n * Record a component failure that no error boundary took ownership of.\n *\n * The precondition is **not** \"no boundary was in scope\". It is that no boundary\n * ACCEPTED the error, which is a strictly weaker thing: `setBoundaryError()`\n * rejects an error when the nearest boundary is already showing one and no\n * ancestor is free, and both binders call this on that path with a boundary\n * very much present. Getting the two confused is what this whole module exists\n * to prevent.\n *\n * Nor is \"crash\" limited to a thrown error. The binders also record a component\n * that returned an unusable result, and one whose rendered node failed to reach\n * the document — both leave the raw tag exactly where a throw would, which is\n * the same content loss from the page's point of view.\n *\n * Callers must have established `isSSRMode()` themselves; this does not\n * re-check.\n */\nfunction recordSSRRenderCrash(el: Element, tag: string, error: unknown): void {\n crashRegistry().set(el, {\n el,\n tag,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n}\n\n/**\n * Drop every recorded crash. Called by the SSR renderer before a render starts\n * and again in its `finally`, so one route's crash can never fail the next.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resetSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function resetSSRRenderCrashes(): void {\n crashRegistry().clear();\n const g = pithyGlobals();\n g.__pithyAttributedCrashes = [];\n g.__pithyRenderDepth = 0;\n}\n\n/**\n * An element that left the tree being bound contributes nothing to the output:\n * its recorded crash is stale, and an attributed one is only logged.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"forgetCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function forgetCrash(el: Element): void {\n clearSSRRenderCrash(el);\n const crash = takeAttributedCrash(el);\n if (crash) logCrash(crash);\n}\n\nfunction takeAttributedCrash(el: Element): AttributedCrash | undefined {\n const list = heldCrashes();\n const at = list?.findIndex(crash => crash.el === el) ?? -1;\n return at >= 0 ? list?.splice(at, 1)[0] : undefined;\n}\n\n/**\n * Return the crashes still recorded once the render has finished, and empty\n * the collector.\n *\n * Every surviving record is a failure. A record is only ever retracted by\n * `clearSSRRenderCrash`, i.e. by a genuine re-attempt at the same element that\n * then went better — never by inspecting the finished tree.\n *\n * An earlier draft re-resolved each record's boundary here, dropping any crash\n * whose element had ended up inside an `@error-boundary`. That is unsound,\n * because a boundary *existing* above an element is not the same as that\n * boundary having *handled* the crash. A crash that a boundary rejected, or\n * that ran where no boundary resolved, is placed under one afterwards just the\n * same. Re-resolution dropped such a record: the boundary signal stayed null,\n * its fallback never activated, the raw component tag shipped, and the build\n * went green — the exact BUG-018 symptom, reintroduced by its own fix.\n *\n * A crash in a branch, slot or component built detached is attributed to its\n * boundary instead (`deferCrash`); whatever is still attributed here is\n * recorded.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"collectUnhandledSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => SSRRenderCrash[]\"} */\nexport function collectUnhandledSSRRenderCrashes(): SSRRenderCrash[] {\n resolveAttributedCrashes('collect');\n const registry = crashRegistry();\n const unhandled = [...registry.values()];\n registry.clear();\n return unhandled;\n}\n\n/**\n * Hand a component failure to its `@error-boundary`, or record it if none takes\n * it. Returns whether a boundary accepted ownership.\n *\n * The single funnel for every way a component can fail to produce content: a\n * thrown error, an unusable return value, and a rendered node that never reached\n * the document. They were handled in five separate places and drifted — the\n * throw paths consulted the boundary while the malformed paths recorded\n * directly, so a component under `@error-boundary` that returned garbage left\n * the boundary signal null, rendered no fallback, and failed the route, even\n * though the code called it \"the same content loss as a crash\".\n *\n * With no `boundary`, a failure in a branch, slot or component built detached\n * is attributed to the boundary its render sits under (`deferCrash`) and counts\n * as handled here; `attribution` says how it is logged if no boundary takes it.\n *\n * Callers still do their own logging, since the wording differs per failure.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"reportComponentFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean\"} */\nexport function reportComponentFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n if (!boundary && deferCrash(el, tag, error, attribution)) return true;\n return settleFailure(el, tag, error, boundary);\n}\n\n/** How an attributed crash is logged: `message` if no boundary takes it, `onCaptured` if one does. */\nexport interface Attribution {\n message?: string | null;\n onCaptured?: () => void;\n}\n\nfunction settleFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null\n): boolean {\n // A boundary in scope is not a boundary that accepted: an already-active one\n // with no free ancestor rejects, and that is as unhandled as having none.\n const accepted = boundary ? setBoundaryError(boundary, error) : false;\n\n if (isSSRMode()) {\n if (accepted) clearSSRRenderCrash(el);\n else recordSSRRenderCrash(el, tag, error);\n }\n\n return accepted;\n}\n\n/** A crash raised where no boundary was reachable, owned by the boundary its render sat under. */\ninterface AttributedCrash extends SSRRenderCrash {\n /** The boundary the branch, slot or component was built for: the crash waits until it is inside. */\n boundaryEl: Element;\n message: string | null;\n onCaptured?: () => void;\n ops: CrashOps;\n /** The outermost render it was attributed in; `0` outside any. */\n render: number;\n}\n\n/** The copy of core that attributed a crash answers these, against its own boundaries. */\ninterface CrashOps {\n locate: (el: Element) => BoundaryInfo | null;\n owner: (node: Node) => Element | null;\n hidden: (node: Node) => boolean;\n parent: (boundary: BoundaryInfo) => BoundaryInfo | null;\n settle: typeof settleFailure;\n}\n\nconst ops: CrashOps = {\n locate: registeredClosest,\n owner: slotOwnerOf,\n hidden: isInHiddenContent,\n parent: findParentBoundary,\n settle: settleFailure,\n};\n\nlet taskEndQueued = false;\n\n// A crash that is neither in place nor hidden when a render ends may belong to\n// content its caller inserts right after (a slot rendered from an effect): it\n// waits once, to the end of the task, before it is reported.\nfunction resolveAtTaskEnd(): void {\n if (taskEndQueued) return;\n taskEndQueued = true;\n queueMicrotask(() => {\n taskEndQueued = false;\n resolveAttributedCrashes('task');\n });\n}\n\n// Shared on `globalThis` for the reason the registry is: a second copy of core\n// must neither miss these nor resolve them in the middle of a render.\n\nfunction heldCrashes(): AttributedCrash[] | undefined {\n return pithyGlobals().__pithyAttributedCrashes as\n | AttributedCrash[]\n | undefined;\n}\n\nfunction renderDepth(change = 0): number {\n const g = pithyGlobals();\n return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);\n}\n\nfunction currentRender(): number {\n return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;\n}\n\nfunction crashedElements(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyCrashedElements ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"hasCrashed\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function hasCrashed(el: Element): boolean {\n return crashedElements().has(el);\n}\n\n/**\n * Brackets a render transaction: a template bind, or one structural update\n * that builds a branch and inserts it. Attributed crashes are resolved when the\n * outermost one ends, so a boundary hides its content only once everything in\n * it is bound and in place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"withinRender\",\"stability\":\"internal\",\"signature\":\"<T>(fn: () => T) => T\"} */\nexport function withinRender<T>(fn: () => T): T {\n const g = pithyGlobals();\n if (renderDepth() === 0) g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;\n const render = g.__pithyRenderId ?? 0;\n renderDepth(1);\n let failed = false;\n try {\n return fn();\n } catch (err) {\n failed = true;\n throw err;\n } finally {\n renderDepth(-1);\n // Never throws, so a failed render keeps its own error. Its caller disposes\n // what it bound, boundaries included, so its own crashes are only reported.\n if (failed && renderDepth() === 0) reportCrashesOf(render);\n else resolveAttributedCrashes();\n }\n}\n\n/**\n * Attributes a crash that reached no boundary through the DOM to the boundary\n * its render sits under (`boundaryContext`): a branch, slot or component built\n * detached. Returns `false` with no such context, so the caller handles the\n * crash as before.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"deferCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean\"} */\nexport function deferCrash(\n el: Element,\n tag: string,\n error: Error,\n { message = null, onCaptured }: Attribution = {}\n): boolean {\n const boundaryEl = boundaryContext();\n if (!boundaryEl) return false;\n crashedElements().add(el);\n takeAttributedCrash(el);\n (pithyGlobals().__pithyAttributedCrashes ??= []).push({\n el,\n tag,\n error,\n boundaryEl,\n message,\n onCaptured,\n ops,\n render: currentRender(),\n });\n if (renderDepth() === 0) resolveAtTaskEnd();\n return true;\n}\n\nfunction reportCrashesOf(render: number): void {\n const list = heldCrashes();\n if (!list?.length) return;\n for (const crash of list.splice(0)) {\n if (crash.render !== render) list.push(crash);\n else\n try {\n unhandled(crash);\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n}\n\nfunction logCrash(crash: AttributedCrash): void {\n if (crash.message) console.error(crash.message, crash.error);\n}\n\nfunction unhandled(crash: AttributedCrash): void {\n crash.ops.settle(crash.el, crash.tag, crash.error, null);\n logCrash(crash);\n}\n\n/**\n * Resolves attributed crashes once they are in place. Each goes to the nearest\n * registered boundary at its final position, exactly as a crash placed there\n * would, and within one resolution a boundary takes at most one error. In the\n * browser this waits for the\n * outermost render to end. A static render binds text once, so there the\n * component pass of the template that owns a boundary resolves its crashes\n * (`scope`), before that template's text is bound and after its components\n * ran. `task` runs at the end of the task; `collect` after the HTML is\n * serialized, and only records.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveAttributedCrashes\",\"stability\":\"internal\",\"signature\":\"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void\"} */\nexport function resolveAttributedCrashes(\n mode: 'render' | 'task' | 'collect' = 'render',\n scope?: ParentNode\n): void {\n const list = heldCrashes();\n if (!list?.length) return;\n const midRender = mode === 'render' && renderDepth() > 0;\n if (midRender && (!scope || !isSSRMode())) return;\n const groups = new Map<BoundaryInfo, AttributedCrash[]>();\n const into = (boundary: BoundaryInfo, crash: AttributedCrash) => {\n const group = groups.get(boundary);\n if (group) group.push(crash);\n else groups.set(boundary, [crash]);\n };\n let waiting = false;\n for (const crash of list.splice(0)) {\n try {\n if (mode === 'collect') {\n unhandled(crash);\n continue;\n }\n if (midRender && !scope?.contains(crash.boundaryEl)) {\n list.push(crash);\n continue;\n }\n const target = placedAt(crash);\n if (partOfShown(crash, target)) {\n logCrash(crash);\n continue;\n }\n if (target) into(target, crash);\n // In its boundary with no registered one around it, or out of time.\n else if (\n mode === 'task' ||\n (!midRender && crash.boundaryEl.contains(crash.el))\n )\n unhandled(crash);\n else {\n // Not inserted yet: its caller may insert it right after.\n list.push(crash);\n waiting ||= !midRender;\n }\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n if (waiting) resolveAtTaskEnd();\n const innermostFirst = [...groups.entries()]\n .map(entry => ({ entry, depth: depthOf(entry[0].element) }))\n .sort((a, b) => b.depth - a.depth)\n .map(({ entry }) => entry);\n const handled = new Set<BoundaryInfo>();\n for (const [boundary, group] of innermostFirst) {\n try {\n resolveGroup(boundary, group, handled);\n } catch (err) {\n reportResolveFailure(group, err);\n }\n }\n}\n\nfunction reportResolveFailure(crashes: AttributedCrash[], err: unknown): void {\n for (const crash of crashes)\n if (isSSRMode()) recordSSRRenderCrash(crash.el, crash.tag, crash.error);\n console.error('❌ Resolving a component crash failed:', err);\n}\n\nfunction depthOf(node: Node): number {\n let depth = 0;\n for (let at = node.parentNode; at; at = at.parentNode) depth++;\n return depth;\n}\n\n/**\n * One boundary's crashes, content before fallback, so the outcome does not\n * depend on the order they happened in. Each is handled as a crash placed there\n * directly: a content crash goes to the boundary, a fallback crash too unless\n * the boundary already shows its fallback, in which case it goes further out.\n */\nfunction resolveGroup(\n boundary: BoundaryInfo,\n group: AttributedCrash[],\n handled: Set<BoundaryInfo>\n): void {\n const inFallback = (crash: AttributedCrash) =>\n !!boundary.fallbackElement?.contains(crash.el);\n for (const crash of group.filter(crash => !inFallback(crash)))\n if (partOfShown(crash, boundary)) logCrash(crash);\n else deliver(crash, boundary, handled);\n for (const crash of group.filter(inFallback)) {\n if (partOfShown(crash, boundary)) logCrash(crash);\n else\n deliver(\n crash,\n showsError(boundary) ? crash.ops.parent(boundary) : boundary,\n handled\n );\n }\n}\n\n// Slot content a portal moves out of its boundary goes to that boundary, as a\n// component crash in it does through the slot frame. Only the nodes a slot\n// rendered carry an owner: a root a component mounts during setup has none.\nfunction placedAt(crash: AttributedCrash): BoundaryInfo | null {\n const { el, ops } = crash;\n const at = ops.locate(el);\n if (at || !el.isConnected) return at;\n const owner = ops.owner(el);\n return owner && !owner.contains(el) ? ops.locate(owner) : null;\n}\n\n// A delivery earlier in the resolution can hide it. A nearest boundary still\n// free takes it, though an ancestor hides both, as it would a crash placed there.\nfunction partOfShown(\n crash: AttributedCrash,\n nearest: BoundaryInfo | null\n): boolean {\n return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));\n}\n\n// As `setBoundaryError` decides: by the signal, which a `batch()` sets before\n// the boundary's effect updates `isActive`.\nfunction showsError(boundary: BoundaryInfo): boolean {\n return untrack(() => boundary.errorSignal()) !== null;\n}\n\n/**\n * Hands a crash to the first boundary from `from` outward that is not already\n * showing an error, as `setBoundaryError` escalates a crash placed there. One\n * that reaches a boundary showing an error from this resolution is part of it.\n */\nfunction deliver(\n crash: AttributedCrash,\n from: BoundaryInfo | null,\n handled: Set<BoundaryInfo>\n): void {\n for (let at = from; at; at = crash.ops.parent(at)) {\n if (handled.has(at)) {\n logCrash(crash);\n return;\n }\n if (showsError(at)) continue;\n let accepted = false;\n try {\n accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);\n } catch (err) {\n // An effect of the boundary threw; the crash is settled only if it took it.\n if (!showsError(at)) reportResolveFailure([crash], err);\n else console.error('❌ Resolving a component crash failed:', err);\n handled.add(at);\n return;\n }\n if (accepted) {\n handled.add(at);\n crash.onCaptured?.();\n } else logCrash(crash);\n return;\n }\n unhandled(crash);\n}\n\n/**\n * Before a component inside a boundary's fallback renders in a static render,\n * that boundary takes its crashes, so content the component renders from the\n * error (text is bound once there) has it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveBeforeFallback\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function resolveBeforeFallback(el: Element): void {\n if (!isSSRMode() || !heldCrashes()?.length) return;\n const owner = el.closest('[data-fallback]')?.closest('[data-error]');\n if (owner) resolveAttributedCrashes('render', owner);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ssrCrashes.js","sourceRoot":"","sources":["../../src/compile/ssrCrashes.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,2BAA2B,CAAC;AAcnC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa;IACpB,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,CAAC,CAAC,iBAAiB,KAAnB,CAAC,CAAC,iBAAiB,GAAK,IAAI,GAAG,EAAE,EAAiC,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+IAA+I;AAC/I,MAAM,UAAU,mBAAmB,CAAC,EAAW;IAC7C,aAAa,EAAE,CAAC,MAAM,CAAC,E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AC,OAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,IAAI,KAAK;QAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.ssr-crashes\",\n \"title\": \"SSR Unhandled Component Crash Collector\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\nimport { untrack } from '@pithyjs/signals';\nimport { pithyGlobals } from '../types/globals';\nimport { isSSRMode } from './ssrMode';\nimport {\n boundaryContext,\n findParentBoundary,\n inBranch,\n isInHiddenContent,\n registeredClosest,\n setBoundaryError,\n slotOwnerOf,\n type BoundaryInfo,\n} from './binds/bindErrorBoundary';\n\n/**\n * A component render crash recorded during a static/server render.\n */\nexport interface SSRRenderCrash {\n /** The custom-element placeholder the crashed component was to replace. */\n el: Element;\n /** Authored tag name, for the failure message. */\n tag: string;\n /** The error the component threw. */\n error: Error;\n}\n\n/**\n * Crashes recorded during the current server render, keyed by the placeholder\n * element so a later binding pass over the same element can retract its own\n * earlier record (see `clearSSRRenderCrash`).\n *\n * Held on `globalThis`, not in this module. `@pithyjs/ssr` depends on\n * `@pithyjs/core` as a regular dependency, so an app and the SSR package can\n * resolve two physical copies: `html()` would record into the app's copy while\n * `renderToString()` collected and reset the SSR package's, reintroducing\n * BUG-018 *and* leaking the app copy's DOM records for the life of the process.\n * The same reasoning already puts `__PITHY_SSR__` and `__getComponentContext`\n * on this bridge.\n *\n * A `Map` (not a `WeakMap`) because the collector must be enumerable at flush\n * time. `resetSSRRenderCrashes()` is what keeps it from retaining DOM across\n * renders — the SSR renderer calls it in a `finally`.\n */\nfunction crashRegistry(): Map<Element, SSRRenderCrash> {\n const g = pithyGlobals();\n return (g.__pithySSRCrashes ??= new Map()) as Map<Element, SSRRenderCrash>;\n}\n\n/**\n * Forget any crash previously recorded for `el`.\n *\n * Called only at points where the record is provably no longer the outcome, and\n * NEVER before invoking a component. Retracting eagerly at the top of an attempt\n * hides a failed retry: a component that throws detached and then returns\n * something unusable would have its only record erased, shipping a page with a\n * missing subtree and a green build. The three call sites are:\n *\n * 1. A boundary ACCEPTING the error (`setBoundaryError()` returning `true`).\n * A boundary merely being in scope is not enough — an already-active one\n * with no free ancestor rejects the error, and that is as unhandled as\n * having no boundary at all.\n * 2. A component returning a usable node that then successfully reaches the\n * document, i.e. after `replaceWith` has not thrown.\n * 3. An element that has left the tree being bound (`scope.contains(el)` in\n * `bindComponentTags`, `fragment.contains(el)` in `applyBindings`). It can\n * no longer contribute to the output, so any record for it is stale.\n *\n * Every one of these is mutation-tested; removing any of them turns a correct\n * render into a failed route, or a broken one into a silent success.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"clearSSRRenderCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function clearSSRRenderCrash(el: Element): void {\n crashRegistry().delete(el);\n}\n\n/**\n * Record a component failure that no error boundary took ownership of.\n *\n * The precondition is **not** \"no boundary was in scope\". It is that no boundary\n * ACCEPTED the error, which is a strictly weaker thing: `setBoundaryError()`\n * rejects an error when the nearest boundary is already showing one and no\n * ancestor is free, and both binders call this on that path with a boundary\n * very much present. Getting the two confused is what this whole module exists\n * to prevent.\n *\n * Nor is \"crash\" limited to a thrown error. The binders also record a component\n * that returned an unusable result, and one whose rendered node failed to reach\n * the document — both leave the raw tag exactly where a throw would, which is\n * the same content loss from the page's point of view.\n *\n * Callers must have established `isSSRMode()` themselves; this does not\n * re-check.\n */\nfunction recordSSRRenderCrash(el: Element, tag: string, error: unknown): void {\n crashRegistry().set(el, {\n el,\n tag,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n}\n\n/**\n * Drop every recorded crash. Called by the SSR renderer before a render starts\n * and again in its `finally`, so one route's crash can never fail the next.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resetSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => void\"} */\nexport function resetSSRRenderCrashes(): void {\n crashRegistry().clear();\n const g = pithyGlobals();\n g.__pithyAttributedCrashes = [];\n g.__pithyRenderDepth = 0;\n}\n\n/**\n * An element that left the tree being bound contributes nothing to the output:\n * its recorded crash is stale, and an attributed one is only logged.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"forgetCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function forgetCrash(el: Element): void {\n clearSSRRenderCrash(el);\n const crash = takeAttributedCrash(el);\n if (crash) logCrash(crash);\n}\n\nfunction takeAttributedCrash(el: Element): AttributedCrash | undefined {\n const list = heldCrashes();\n const at = list?.findIndex(crash => crash.el === el) ?? -1;\n return at >= 0 ? list?.splice(at, 1)[0] : undefined;\n}\n\n/**\n * Return the crashes still recorded once the render has finished, and empty\n * the collector.\n *\n * Every surviving record is a failure. A record is only ever retracted by\n * `clearSSRRenderCrash`, i.e. by a genuine re-attempt at the same element that\n * then went better — never by inspecting the finished tree.\n *\n * An earlier draft re-resolved each record's boundary here, dropping any crash\n * whose element had ended up inside an `@error-boundary`. That is unsound,\n * because a boundary *existing* above an element is not the same as that\n * boundary having *handled* the crash. A crash that a boundary rejected, or\n * that ran where no boundary resolved, is placed under one afterwards just the\n * same. Re-resolution dropped such a record: the boundary signal stayed null,\n * its fallback never activated, the raw component tag shipped, and the build\n * went green — the exact BUG-018 symptom, reintroduced by its own fix.\n *\n * A crash in a branch, slot or component built detached is attributed to its\n * boundary instead (`deferCrash`); whatever is still attributed here is\n * recorded.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"collectUnhandledSSRRenderCrashes\",\"stability\":\"stable\",\"signature\":\"() => SSRRenderCrash[]\"} */\nexport function collectUnhandledSSRRenderCrashes(): SSRRenderCrash[] {\n resolveAttributedCrashes('collect');\n const registry = crashRegistry();\n const unhandled = [...registry.values()];\n registry.clear();\n return unhandled;\n}\n\n/**\n * Hand a component failure to its `@error-boundary`, or record it if none takes\n * it. Returns whether a boundary accepted ownership.\n *\n * The single funnel for every way a component can fail to produce content: a\n * thrown error, an unusable return value, and a rendered node that never reached\n * the document. They were handled in five separate places and drifted — the\n * throw paths consulted the boundary while the malformed paths recorded\n * directly, so a component under `@error-boundary` that returned garbage left\n * the boundary signal null, rendered no fallback, and failed the route, even\n * though the code called it \"the same content loss as a crash\".\n *\n * With no `boundary`, a failure in a branch, slot or component built detached\n * is attributed to the boundary its render sits under (`deferCrash`) and counts\n * as handled here; `attribution` says how it is logged if no boundary takes it.\n *\n * Callers still do their own logging, since the wording differs per failure.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"reportComponentFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, boundary: BoundaryInfo | null, attribution?: Attribution) => boolean\"} */\nexport function reportComponentFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null,\n attribution: Attribution = {}\n): boolean {\n if (!boundary && deferCrash(el, tag, error, attribution)) return true;\n return settleFailure(el, tag, error, boundary);\n}\n\n/** How an attributed crash is logged: `message` if no boundary takes it, `onCaptured` if one does. */\nexport interface Attribution {\n message?: string | null;\n onCaptured?: () => void;\n}\n\nfunction settleFailure(\n el: Element,\n tag: string,\n error: Error,\n boundary: BoundaryInfo | null\n): boolean {\n // A boundary in scope is not a boundary that accepted: an already-active one\n // with no free ancestor rejects, and that is as unhandled as having none.\n const accepted = boundary ? setBoundaryError(boundary, error) : false;\n\n if (isSSRMode()) {\n if (accepted) clearSSRRenderCrash(el);\n else recordSSRRenderCrash(el, tag, error);\n }\n\n return accepted;\n}\n\n/** A crash raised where no boundary was reachable, owned by the boundary its render sat under. */\ninterface AttributedCrash extends SSRRenderCrash {\n /** The boundary the branch, slot or component was built for: the crash waits until it is inside. */\n boundaryEl: Element;\n message: string | null;\n onCaptured?: () => void;\n ops: CrashOps;\n /** The outermost render it was attributed in; `0` outside any. */\n render: number;\n}\n\n/** The copy of core that attributed a crash answers these, against its own boundaries. */\ninterface CrashOps {\n locate: (el: Element) => BoundaryInfo | null;\n owner: (node: Node) => Element | null;\n hidden: (node: Node) => boolean;\n parent: (boundary: BoundaryInfo) => BoundaryInfo | null;\n settle: typeof settleFailure;\n}\n\nconst ops: CrashOps = {\n locate: registeredClosest,\n owner: slotOwnerOf,\n hidden: isInHiddenContent,\n parent: findParentBoundary,\n settle: settleFailure,\n};\n\nlet taskEndQueued = false;\n\n// A crash that is neither in place nor hidden when a render ends may belong to\n// content its caller inserts right after (a slot rendered from an effect): it\n// waits once, to the end of the task, before it is reported.\nfunction resolveAtTaskEnd(): void {\n if (taskEndQueued) return;\n taskEndQueued = true;\n queueMicrotask(() => {\n taskEndQueued = false;\n resolveAttributedCrashes('task');\n });\n}\n\n// Shared on `globalThis` for the reason the registry is: a second copy of core\n// must neither miss these nor resolve them in the middle of a render.\n\nfunction heldCrashes(): AttributedCrash[] | undefined {\n return pithyGlobals().__pithyAttributedCrashes as\n | AttributedCrash[]\n | undefined;\n}\n\nfunction renderDepth(change = 0): number {\n const g = pithyGlobals();\n return (g.__pithyRenderDepth = (g.__pithyRenderDepth ?? 0) + change);\n}\n\nfunction currentRender(): number {\n return renderDepth() > 0 ? (pithyGlobals().__pithyRenderId ?? 0) : 0;\n}\n\nfunction crashedElements(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyCrashedElements ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Whether `el` crashed and was attributed; a retry would run its setup twice, which a build never does. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"hasCrashed\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function hasCrashed(el: Element): boolean {\n return crashedElements().has(el);\n}\n\n/**\n * Brackets a render transaction: a template bind, or one structural update\n * that builds a branch and inserts it. Attributed crashes are resolved when the\n * outermost one ends, so a boundary hides its content only once everything in\n * it is bound and in place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"withinRender\",\"stability\":\"internal\",\"signature\":\"<T>(fn: () => T) => T\"} */\nexport function withinRender<T>(fn: () => T): T {\n const g = pithyGlobals();\n if (renderDepth() === 0) g.__pithyRenderId = (g.__pithyRenderId ?? 0) + 1;\n const render = g.__pithyRenderId ?? 0;\n renderDepth(1);\n let failed = false;\n try {\n return fn();\n } catch (err) {\n failed = true;\n throw err;\n } finally {\n renderDepth(-1);\n // Never throws, so a failed render keeps its own error. Its caller disposes\n // what it bound, boundaries included, so its own crashes are only reported.\n if (failed && renderDepth() === 0) reportCrashesOf(render);\n else resolveAttributedCrashes();\n }\n}\n\nfunction branchFailures(): WeakSet<Element> {\n const g = pithyGlobals();\n return (g.__pithyBranchFailures ??= new WeakSet()) as WeakSet<Element>;\n}\n\n/** Logs a component failure, and marks `el` when it failed in a branch. */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"logFailure\",\"stability\":\"internal\",\"signature\":\"(el: Element, log: () => void) => void\"} */\nexport function logFailure(el: Element, log: () => void): void {\n if (inBranch()) branchFailures().add(el);\n log();\n}\n\n/** Whether `el` failed while its branch was built; the pass that binds the inserted branch would retry it (BUG-161). */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"failedInBranch\",\"stability\":\"internal\",\"signature\":\"(el: Element) => boolean\"} */\nexport function failedInBranch(el: Element): boolean {\n return branchFailures().has(el);\n}\n\n/**\n * Attributes a crash that reached no boundary through the DOM to the boundary\n * its render sits under (`boundaryContext`): a branch, slot or component built\n * detached. Returns `false` with no such context, so the caller handles the\n * crash as before.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"deferCrash\",\"stability\":\"internal\",\"signature\":\"(el: Element, tag: string, error: Error, attribution?: Attribution) => boolean\"} */\nexport function deferCrash(\n el: Element,\n tag: string,\n error: Error,\n { message = null, onCaptured }: Attribution = {}\n): boolean {\n const boundaryEl = boundaryContext();\n if (!boundaryEl) return false;\n crashedElements().add(el);\n takeAttributedCrash(el);\n (pithyGlobals().__pithyAttributedCrashes ??= []).push({\n el,\n tag,\n error,\n boundaryEl,\n message,\n onCaptured,\n ops,\n render: currentRender(),\n });\n if (renderDepth() === 0) resolveAtTaskEnd();\n return true;\n}\n\nfunction reportCrashesOf(render: number): void {\n const list = heldCrashes();\n if (!list?.length) return;\n for (const crash of list.splice(0)) {\n if (crash.render !== render) list.push(crash);\n else\n try {\n unhandled(crash);\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n}\n\nfunction logCrash(crash: AttributedCrash): void {\n if (crash.message) console.error(crash.message, crash.error);\n}\n\nfunction unhandled(crash: AttributedCrash): void {\n crash.ops.settle(crash.el, crash.tag, crash.error, null);\n logCrash(crash);\n}\n\n/**\n * Resolves attributed crashes once they are in place. Each goes to the nearest\n * registered boundary at its final position, exactly as a crash placed there\n * would, and within one resolution a boundary takes at most one error. In the\n * browser this waits for the\n * outermost render to end. A static render binds text once, so there the\n * component pass of the template that owns a boundary resolves its crashes\n * (`scope`), before that template's text is bound and after its components\n * ran. `task` runs at the end of the task; `collect` after the HTML is\n * serialized, and only records.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveAttributedCrashes\",\"stability\":\"internal\",\"signature\":\"(mode?: 'render' | 'task' | 'collect', scope?: ParentNode) => void\"} */\nexport function resolveAttributedCrashes(\n mode: 'render' | 'task' | 'collect' = 'render',\n scope?: ParentNode\n): void {\n const list = heldCrashes();\n if (!list?.length) return;\n const midRender = mode === 'render' && renderDepth() > 0;\n if (midRender && (!scope || !isSSRMode())) return;\n const groups = new Map<BoundaryInfo, AttributedCrash[]>();\n const into = (boundary: BoundaryInfo, crash: AttributedCrash) => {\n const group = groups.get(boundary);\n if (group) group.push(crash);\n else groups.set(boundary, [crash]);\n };\n let waiting = false;\n for (const crash of list.splice(0)) {\n try {\n if (mode === 'collect') {\n unhandled(crash);\n continue;\n }\n if (midRender && !scope?.contains(crash.boundaryEl)) {\n list.push(crash);\n continue;\n }\n const target = placedAt(crash);\n if (partOfShown(crash, target)) {\n logCrash(crash);\n continue;\n }\n if (target) into(target, crash);\n // In its boundary with no registered one around it, or out of time.\n else if (\n mode === 'task' ||\n (!midRender && crash.boundaryEl.contains(crash.el))\n )\n unhandled(crash);\n else {\n // Not inserted yet: its caller may insert it right after.\n list.push(crash);\n waiting ||= !midRender;\n }\n } catch (err) {\n reportResolveFailure([crash], err);\n }\n }\n if (waiting) resolveAtTaskEnd();\n const innermostFirst = [...groups.entries()]\n .map(entry => ({ entry, depth: depthOf(entry[0].element) }))\n .sort((a, b) => b.depth - a.depth)\n .map(({ entry }) => entry);\n const handled = new Set<BoundaryInfo>();\n for (const [boundary, group] of innermostFirst) {\n try {\n resolveGroup(boundary, group, handled);\n } catch (err) {\n reportResolveFailure(group, err);\n }\n }\n}\n\nfunction reportResolveFailure(crashes: AttributedCrash[], err: unknown): void {\n for (const crash of crashes)\n if (isSSRMode()) recordSSRRenderCrash(crash.el, crash.tag, crash.error);\n console.error('❌ Resolving a component crash failed:', err);\n}\n\nfunction depthOf(node: Node): number {\n let depth = 0;\n for (let at = node.parentNode; at; at = at.parentNode) depth++;\n return depth;\n}\n\n/**\n * One boundary's crashes, content before fallback, so the outcome does not\n * depend on the order they happened in. Each is handled as a crash placed there\n * directly: a content crash goes to the boundary, a fallback crash too unless\n * the boundary already shows its fallback, in which case it goes further out.\n */\nfunction resolveGroup(\n boundary: BoundaryInfo,\n group: AttributedCrash[],\n handled: Set<BoundaryInfo>\n): void {\n const inFallback = (crash: AttributedCrash) =>\n !!boundary.fallbackElement?.contains(crash.el);\n for (const crash of group.filter(crash => !inFallback(crash)))\n if (partOfShown(crash, boundary)) logCrash(crash);\n else deliver(crash, boundary, handled);\n for (const crash of group.filter(inFallback)) {\n if (partOfShown(crash, boundary)) logCrash(crash);\n else\n deliver(\n crash,\n showsError(boundary) ? crash.ops.parent(boundary) : boundary,\n handled\n );\n }\n}\n\n// Slot content a portal moves out of its boundary goes to that boundary, as a\n// component crash in it does through the slot frame. Only the nodes a slot\n// rendered carry an owner: a root a component mounts during setup has none.\nfunction placedAt(crash: AttributedCrash): BoundaryInfo | null {\n const { el, ops } = crash;\n const at = ops.locate(el);\n if (at || !el.isConnected) return at;\n const owner = ops.owner(el);\n return owner && !owner.contains(el) ? ops.locate(owner) : null;\n}\n\n// A delivery earlier in the resolution can hide it. A nearest boundary still\n// free takes it, though an ancestor hides both, as it would a crash placed there.\nfunction partOfShown(\n crash: AttributedCrash,\n nearest: BoundaryInfo | null\n): boolean {\n return crash.ops.hidden(crash.el) && (!nearest || showsError(nearest));\n}\n\n// As `setBoundaryError` decides: by the signal, which a `batch()` sets before\n// the boundary's effect updates `isActive`.\nfunction showsError(boundary: BoundaryInfo): boolean {\n return untrack(() => boundary.errorSignal()) !== null;\n}\n\n/**\n * Hands a crash to the first boundary from `from` outward that is not already\n * showing an error, as `setBoundaryError` escalates a crash placed there. One\n * that reaches a boundary showing an error from this resolution is part of it.\n */\nfunction deliver(\n crash: AttributedCrash,\n from: BoundaryInfo | null,\n handled: Set<BoundaryInfo>\n): void {\n for (let at = from; at; at = crash.ops.parent(at)) {\n if (handled.has(at)) {\n logCrash(crash);\n return;\n }\n if (showsError(at)) continue;\n let accepted = false;\n try {\n accepted = crash.ops.settle(crash.el, crash.tag, crash.error, at);\n } catch (err) {\n // An effect of the boundary threw; the crash is settled only if it took it.\n if (!showsError(at)) reportResolveFailure([crash], err);\n else console.error('❌ Resolving a component crash failed:', err);\n handled.add(at);\n return;\n }\n if (accepted) {\n handled.add(at);\n crash.onCaptured?.();\n } else logCrash(crash);\n return;\n }\n unhandled(crash);\n}\n\n/**\n * Before a component inside a boundary's fallback renders in a static render,\n * that boundary takes its crashes, so content the component renders from the\n * error (text is bound once there) has it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.ssr-crashes\",\"name\":\"resolveBeforeFallback\",\"stability\":\"internal\",\"signature\":\"(el: Element) => void\"} */\nexport function resolveBeforeFallback(el: Element): void {\n if (!isSSRMode() || !heldCrashes()?.length) return;\n const owner = el.closest('[data-fallback]')?.closest('[data-error]');\n if (owner) resolveAttributedCrashes('render', owner);\n}\n"]}
|
|
@@ -111,6 +111,11 @@ function applyBindings(fragment, bindings, context, ownsDestroyCallbacks) {
|
|
|
111
111
|
// render left in place) is rendered through this hook, in the context it
|
|
112
112
|
// was written in.
|
|
113
113
|
const comps = (byType.get('comp') ?? []);
|
|
114
|
+
const boundOn = (pid) => import.meta.env?.DEV
|
|
115
|
+
? (byType.get('bound') ?? [])
|
|
116
|
+
.filter(b => b.pid === pid)
|
|
117
|
+
.map(b => b.attr)
|
|
118
|
+
: [];
|
|
114
119
|
const mounted = new Set();
|
|
115
120
|
const binds = new Map();
|
|
116
121
|
const live = new Map();
|
|
@@ -129,7 +134,7 @@ function applyBindings(fragment, bindings, context, ownsDestroyCallbacks) {
|
|
|
129
134
|
const failed = failedIn.get(d);
|
|
130
135
|
if (failed === true || (failed && el.parentNode === failed))
|
|
131
136
|
return [];
|
|
132
|
-
const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);
|
|
137
|
+
const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope, boundOn(d.pid));
|
|
133
138
|
failedIn.set(d, nodes ? null : el.parentNode);
|
|
134
139
|
// On failure `pidMap` still holds the previous root.
|
|
135
140
|
const root = nodes && pidMap.get(d.pid);
|
|
@@ -175,7 +180,7 @@ function applyBindings(fragment, bindings, context, ownsDestroyCallbacks) {
|
|
|
175
180
|
// subtree: that calls `applyBindings` with the branch's OWN fragment as
|
|
176
181
|
// `fragment`, so its placeholders are inside it and still bind.
|
|
177
182
|
if (el && fragment.contains(el)) {
|
|
178
|
-
if (!applyComponent(d, el, ctx, disposers, pidMap))
|
|
183
|
+
if (!applyComponent(d, el, ctx, disposers, pidMap, undefined, boundOn(d.pid)))
|
|
179
184
|
failedIn.set(d, true);
|
|
180
185
|
binds.delete(d.pid);
|
|
181
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8RAA8R;AAC9R,MAAM,UAAU,eAAe,CAC7B,QAA0B,EAC1B,QAAgB,EAChB,OAAgC,EAChC,oBAAoB,GAAG,IAAI;IAE3B,OAAO,YAAY,CAAC,GAAG,EAAE,CACvB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,CAAC,CACjE,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,QAA0B,EAC1B,QAAgB,EAChB,OAAgC,EAChC,oBAA6B;IAE7B,4EAA4E;IAC5E,4EAA4E;IAC5E,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7E,MAAM,SAAS,GAA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gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport {\n forgetCrash,\n resolveAttributedCrashes,\n withinRender,\n} from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport { orderByDocument } from '../compile/disposeOrder';\nimport { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n markBoundary,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n return withinRender(() =>\n applyBindings(fragment, bindings, context, ownsDestroyCallbacks)\n );\n}\n\nfunction applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks: boolean\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\n\n if (bindings.some(d => d.t === 'interp')) markSkeletonText(fragment);\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n // Marked, not registered: a branch built below must `closest()` its boundary.\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) markBoundary(d, el);\n }\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder that reaches a runtime-compiled component's binder (slot\n // content serialized into a descriptor without `slots`, or a failed\n // render left in place) is rendered through this hook, in the context it\n // was written in.\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first. One this pass already\n // rendered is never retried (`true`).\n const failedIn = new Map<CompDesc, ParentNode | null | true>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n const failed = failedIn.get(d);\n if (failed === true || (failed && el.parentNode === failed)) return [];\n const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);\n failedIn.set(d, nodes ? null : el.parentNode);\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n if (!applyComponent(d, el, ctx, disposers, pidMap))\n failedIn.set(d, true);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n forgetCrash(el);\n }\n }\n\n resolveAttributedCrashes('render', fragment);\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n orderByDocument(disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;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AAC;YACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,IAAI,CAAC;YACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CACrB,QAA0B,EAC1B,SAAyB,EACzB,gBAAgC;IAEhC,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,OAAO;YACL,mEAAmE;YACnE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,IAAI,CAAC;oBACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,8DAA8D;YAC9D,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport {\n forgetCrash,\n resolveAttributedCrashes,\n withinRender,\n} from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport { orderByDocument } from '../compile/disposeOrder';\nimport { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n markBoundary,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n return withinRender(() =>\n applyBindings(fragment, bindings, context, ownsDestroyCallbacks)\n );\n}\n\nfunction applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks: boolean\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\n\n if (bindings.some(d => d.t === 'interp')) markSkeletonText(fragment);\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n // Marked, not registered: a branch built below must `closest()` its boundary.\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) markBoundary(d, el);\n }\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder that reaches a runtime-compiled component's binder (slot\n // content serialized into a descriptor without `slots`, or a failed\n // render left in place) is rendered through this hook, in the context it\n // was written in.\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const boundOn = (pid: string) =>\n import.meta.env?.DEV\n ? ((byType.get('bound') ?? []) as BoundDesc[])\n .filter(b => b.pid === pid)\n .map(b => b.attr)\n : [];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first. One this pass already\n // rendered is never retried (`true`).\n const failedIn = new Map<CompDesc, ParentNode | null | true>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n const failed = failedIn.get(d);\n if (failed === true || (failed && el.parentNode === failed)) return [];\n const nodes = applyComponent(\n d,\n el,\n ctx,\n slotDisposers,\n pidMap,\n scope,\n boundOn(d.pid)\n );\n failedIn.set(d, nodes ? null : el.parentNode);\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n if (\n !applyComponent(\n d,\n el,\n ctx,\n disposers,\n pidMap,\n undefined,\n boundOn(d.pid)\n )\n )\n failedIn.set(d, true);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n forgetCrash(el);\n }\n }\n\n resolveAttributedCrashes('render', fragment);\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n orderByDocument(disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { CompDesc, BindingContext } from './types.js';
|
|
2
|
-
export declare function applyComponent(d: CompDesc, el: Element, ctx: BindingContext, disposers: (() => void)[], pidMap: Map<string, Element>, scope?: BindingContext
|
|
2
|
+
export declare function applyComponent(d: CompDesc, el: Element, ctx: BindingContext, disposers: (() => void)[], pidMap: Map<string, Element>, scope?: BindingContext,
|
|
3
|
+
/** The `[attr]` names on the tag; DEV only. */
|
|
4
|
+
bound?: string[]): Node[] | undefined;
|
|
3
5
|
//# sourceMappingURL=applyComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAmJtE,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc;AACtB,+CAA+C;AAC/C,KAAK,GAAE,MAAM,EAAO,GACnB,IAAI,EAAE,GAAG,SAAS,CAiQpB"}
|
|
@@ -11,7 +11,8 @@ import { isSSRMode } from '../../compile/ssrMode.js';
|
|
|
11
11
|
import { isRenderableComponentEl } from '../../compile/componentResult.js';
|
|
12
12
|
import { clearSSRRenderCrash, reportComponentFailure, resolveBeforeFallback, } from '../../compile/ssrCrashes.js';
|
|
13
13
|
import { isolateDestroyCallbacks } from '../onDestroy.js';
|
|
14
|
-
import {
|
|
14
|
+
import { readPropNames } from '../../compile/binds/propNames.js';
|
|
15
|
+
import { warnBoundProps, warnUnexpectedProps, } from '../../compile/binds/propWarnings.js';
|
|
15
16
|
import { watchStaleRowProp } from '../../compile/binds/staleRowProps.js';
|
|
16
17
|
import { markForwardTarget, nodeExpando } from '../../compile/nodeExpando.js';
|
|
17
18
|
import { anchorDisposer, componentDisposer } from '../../compile/disposeOrder.js';
|
|
@@ -38,7 +39,7 @@ function extractExpectedPropNames(fn) {
|
|
|
38
39
|
if (cached)
|
|
39
40
|
return cached;
|
|
40
41
|
try {
|
|
41
|
-
const parsed =
|
|
42
|
+
const parsed = readPropNames(fn);
|
|
42
43
|
const names = parsed.fromParam ? parsed.names : [];
|
|
43
44
|
// Detect likely minification: single-char names suggest mangled output
|
|
44
45
|
if (import.meta.env?.DEV &&
|
|
@@ -115,7 +116,9 @@ function slotsFromChildren(el, slotMap) {
|
|
|
115
116
|
}
|
|
116
117
|
return injection;
|
|
117
118
|
}
|
|
118
|
-
export function applyComponent(d, el, ctx, disposers, pidMap, scope
|
|
119
|
+
export function applyComponent(d, el, ctx, disposers, pidMap, scope,
|
|
120
|
+
/** The `[attr]` names on the tag; DEV only. */
|
|
121
|
+
bound = []) {
|
|
119
122
|
// Skip native HTML elements — prevents <div> matching a `div` in context.
|
|
120
123
|
// Only apply when the authored tag is already lowercase; PascalCase tags like
|
|
121
124
|
// <Button> are valid components even though "button" is a native tag.
|
|
@@ -175,6 +178,11 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
|
|
|
175
178
|
// Leave undefined — child uses defaults
|
|
176
179
|
}
|
|
177
180
|
}
|
|
181
|
+
if (import.meta.env?.DEV) {
|
|
182
|
+
const names = readPropNames(componentFn);
|
|
183
|
+
warnUnexpectedProps(names, props, d.tag);
|
|
184
|
+
warnBoundProps(names.names, bound, d.tag);
|
|
185
|
+
}
|
|
178
186
|
const slotMap = new Map();
|
|
179
187
|
linkOuterSlotMap(slotMap, localCtx);
|
|
180
188
|
let injection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyComponent.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,C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,cAAc;gBACb,cAAc,CAAC,MAAM,GAAG,CAAC;gBACzB,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAC/C,CAAC;YACD,OAAO,CAAC,IAAI,CACV,UAAU,CAAC,CAAC,GAAG,qGAAqG,CACrH,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QAAE,KAAK,MAAM,KAAK,IAAI,aAAa;YAAE,KAAK,EAAE,CAAC;IAEzD,MAAM,QAAQ,GAAG,iBAAiB,CAChC,OAAO,EACP,YAAY,EACZ,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CACnC,CAAC;IACF,IAAI,QAAQ;QAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { compileExpression } from '../../compile/compileExpression';\nimport {\n boundaryForElement,\n replaceHidden,\n runWithBoundary,\n withSlotBoundary,\n slotContentHidden,\n} from '../../compile/binds/bindErrorBoundary';\nimport {\n linkOuterSlotMap,\n type SlotMap,\n} from '../../compile/contentProjection';\nimport {\n collectForwardedAttrs,\n applyForwardedAttrs,\n} from '../../compile/binds/forwardedAttrs';\nimport { nativeTags } from '@pithyjs/compiler';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport type { CompDesc, BindingContext, ChildFactory } from './types';\nimport { nearestCtx } from './helpers';\nimport { trimBlankEdges } from '../../compile/trimBlankEdges';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { isRenderableComponentEl } from '../../compile/componentResult';\nimport {\n clearSSRRenderCrash,\n reportComponentFailure,\n resolveBeforeFallback,\n} from '../../compile/ssrCrashes';\nimport { isolateDestroyCallbacks } from '../onDestroy';\nimport { parsePropNames } from '../../compile/binds/propNames';\nimport { watchStaleRowProp } from '../../compile/binds/staleRowProps';\nimport { markForwardTarget, nodeExpando } from '../../compile/nodeExpando';\nimport { anchorDisposer, componentDisposer } from '../../compile/disposeOrder';\nimport {\n invalidRenderError,\n invalidRenderMessage,\n propEvalMessage,\n} from '../../compile/evalDiagnostics';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */\nfunction normalizePropName(authored: string, expectedProps: string[]): string {\n if (expectedProps.includes(authored)) return authored;\n const lower = authored.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authored;\n}\n\n/** Cache for extractExpectedPropNames to avoid re-parsing the same function. */\nconst propNamesCache = new WeakMap<ComponentFn, string[]>();\n\n/**\n * Extract destructured prop names from component function signature.\n * NOTE: Uses fn.toString() which may return mangled names under aggressive\n * minification (Terser). In that case, prop name normalization becomes a\n * no-op and props are passed as-is (kebab/lowered). This is acceptable\n * because Vite's default esbuild minifier preserves parameter names.\n */\nfunction extractExpectedPropNames(fn: ComponentFn): string[] {\n const cached = propNamesCache.get(fn);\n if (cached) return cached;\n try {\n const parsed = parsePropNames(fn.toString());\n const names = parsed.fromParam ? parsed.names : [];\n // Detect likely minification: single-char names suggest mangled output\n if (\n import.meta.env?.DEV &&\n names.length > 0 &&\n names.every(n => n.length === 1)\n ) {\n console.warn(\n `[AOT] extractExpectedPropNames: detected single-char names (${names.join(',')}) — prop normalization may not work under minification`\n );\n }\n propNamesCache.set(fn, names);\n return names;\n } catch {\n return [];\n }\n}\n\n/** Runs a slot factory against the parent's context, owned by the mount's disposers. */\nfunction renderSlot(\n factory: ChildFactory,\n ctx: BindingContext,\n disposers: (() => void)[],\n anchor?: Node,\n host?: Element\n): DocumentFragment {\n const g = pithyGlobals();\n const rendering = g.__pithyComponentContext;\n // Otherwise mergeContexts would read the child's names into the slot's context.\n g.__pithyComponentContext = undefined;\n try {\n const { el, destroy } = withSlotBoundary(anchor, host, () =>\n isolateDestroyCallbacks(() => factory(ctx))\n );\n disposers.push(anchorDisposer(destroy, anchor ?? el.firstChild));\n // Bound already: a runtime-compiled child's binders must not bind it again.\n el.childNodes.forEach(\n node => (nodeExpando(node).__pithyComponentDom = true)\n );\n return el;\n } finally {\n g.__pithyComponentContext = rendering;\n }\n}\n\n/**\n * Slot content serialized into the placeholder, from a descriptor without\n * `slots`. The nodes are moved, so each slot can be mounted only once.\n */\nfunction slotsFromChildren(\n el: Element,\n slotMap: SlotMap\n): DocumentFragment | undefined {\n const slotGroups = new Map<string, Node[]>();\n for (const child of Array.from(el.childNodes)) {\n const slotName =\n child.nodeType === Node.ELEMENT_NODE\n ? (child as Element).getAttribute('slot') || ''\n : '';\n const group = slotGroups.get(slotName);\n if (group) group.push(child);\n else slotGroups.set(slotName, [child]);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.nodeType === Node.TEXT_NODE ? node.textContent : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n // `renderChildren()` and `<slot>` must share one fragment, or the later\n // consumer steals the nodes out of the first.\n let injection: DocumentFragment | undefined;\n for (const [slotName, nodes] of slotGroups) {\n if (slotName === '') {\n injection = document.createDocumentFragment();\n for (const node of nodes) injection.appendChild(node);\n const shared = injection;\n slotMap.set('', () => shared);\n continue;\n }\n slotMap.set(slotName, () => {\n const frag = document.createDocumentFragment();\n for (const node of nodes) frag.appendChild(node);\n return frag;\n });\n }\n return injection;\n}\n\nexport function applyComponent(\n d: CompDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[],\n pidMap: Map<string, Element>,\n scope?: BindingContext\n): Node[] | undefined {\n // Skip native HTML elements — prevents <div> matching a `div` in context.\n // Only apply when the authored tag is already lowercase; PascalCase tags like\n // <Button> are valid components even though \"button\" is a native tag.\n const tagLower = d.tag.toLowerCase();\n if (d.tag === tagLower && nativeTags.has(tagLower)) return;\n resolveBeforeFallback(el);\n\n // Exact case first: the context holds the template's own locals alongside its\n // components, so a prop named `icon` sits next to the `Icon` component and\n // collides case-insensitively. The JIT path lowercases into a Map, where the\n // components — appended last — overwrite the locals; matching that ordering is\n // why `<Icon>` resolves in dev, and breaking on the first match is why it did\n // not in a build. Falling back last-wins keeps the two paths agreeing.\n let candidate: unknown = Object.prototype.hasOwnProperty.call(ctx, d.tag)\n ? ctx[d.tag]\n : undefined;\n if (candidate === undefined) {\n for (const key of Object.keys(ctx)) {\n if (key.toLowerCase() === tagLower) candidate = ctx[key];\n }\n }\n if (!candidate) return;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') return;\n // Hidden like a sibling an activated boundary detached: never rendered.\n if (slotContentHidden(el)) return;\n\n const componentFn = candidate as ComponentFn;\n const localCtx = scope ?? nearestCtx(el, ctx);\n\n // Extract expected props for case-insensitive normalization\n const expectedProps = extractExpectedPropNames(componentFn);\n\n // Evaluate prop expressions with prop name normalization\n const props: Record<string, unknown> = {};\n const staleWatchers: (() => void)[] = [];\n for (const [rawName, expr] of Object.entries(d.props)) {\n const propName = normalizePropName(rawName, expectedProps);\n try {\n const fn = compileExpression(expr, localCtx);\n props[propName] = untrack(fn);\n if (import.meta.env?.DEV) {\n const value = props[propName];\n staleWatchers.push(() =>\n watchStaleRowProp(\n localCtx,\n d,\n d.tag,\n propName,\n expr,\n value,\n fn,\n disposers\n )\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.warn(propEvalMessage(propName, expr), err);\n // Leave undefined — child uses defaults\n }\n }\n\n const slotMap: SlotMap = new Map();\n linkOuterSlotMap(slotMap, localCtx);\n let injection: DocumentFragment | undefined;\n if (d.slots) {\n for (const [name, factory] of Object.entries(d.slots))\n slotMap.set(name, (ds = disposers, at) =>\n renderSlot(factory, localCtx, ds, at, el)\n );\n } else {\n injection = slotsFromChildren(el, slotMap);\n }\n\n let invoking = true;\n const childrenFactory = d.children;\n const childFactory: ChildFactory | undefined = childrenFactory\n ? (ctx, wrap) =>\n invoking\n ? childrenFactory(ctx, wrap)\n : isolateDestroyCallbacks(() => childrenFactory(ctx, wrap))\n : undefined;\n\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: undefined,\n __childFactory: childFactory,\n __slotHost: el,\n };\n\n // Find nearest error boundary\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(boundary, () => {\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n const prevInjection = g.__pithyProjectedChildren;\n g.__pithyComponentContext = componentContext;\n g.__pithyRenderingComponent = true;\n g.__pithyProjectedChildren = injection;\n try {\n return createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n } finally {\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n g.__pithyProjectedChildren = prevInjection;\n invoking = false;\n }\n });\n } catch (err) {\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // See `setBoundaryError`: an already-active boundary with no free ancestor\n // drops the error rather than taking it, which is the normal case for a\n // component rendering inside that boundary's `@fallback`.\n reportComponentFailure(el, d.tag, error, boundary);\n return;\n }\n\n // No boundary reachable through the DOM. A branch, slot or component\n // built detached knows the one it will sit under (`deferCrash`).\n // Otherwise degrade in both modes — throwing would only be swallowed by\n // the structural handler's own catch (`applyStructural.ts`).\n //\n // A static/server render records the crash instead: dropping the component\n // silently shipped HTML with <${d.tag}> left raw while `pithy-ssg` counted\n // the route as rendered and exited 0 (BUG-018). Anything still recorded\n // when the render finishes fails the route.\n const error = err instanceof Error ? err : new Error(String(err));\n const message = `[AOT] Component <${d.tag}> crashed:`;\n if (!reportComponentFailure(el, d.tag, error, null, { message }))\n console.error(message, err);\n return;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n // Not a throw, but the same outcome: the raw <${d.tag}> is left in place\n // and the subtree never renders, which under SSR is content silently\n // missing from the emitted HTML. Recorded exactly like a crash (BUG-018).\n // Same funnel as a throw — see `bindComponentTags`. Recording without\n // offering it to the boundary left an AOT component under `@error-boundary`\n // failing its route with the boundary signal unset.\n reportComponentFailure(el, d.tag, invalidRenderError(d.tag), boundary);\n if (import.meta.env?.DEV) console.warn(invalidRenderMessage(d.tag));\n disposeSetup?.();\n return;\n }\n\n const { el: renderedEl, destroy } = out;\n\n // Capture rendered root element before fragment is consumed by replaceWith\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n const renderedRoot: Element | null =\n renderedEl instanceof DocumentFragment\n ? renderedEl.firstElementChild\n : renderedEl instanceof Element\n ? renderedEl\n : null;\n\n const nodes =\n renderedEl instanceof DocumentFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n let replaced = true;\n try {\n // A boundary that caught a crash in this render may have hidden `el`.\n if (!replaceHidden(el, nodes)) el.replaceWith(...nodes);\n } catch (err) {\n // The raw <${d.tag}> is left exactly where a crash would have left it, so\n // this is the same content loss and is recorded the same way.\n replaced = false;\n const error = err instanceof Error ? err : new Error(String(err));\n reportComponentFailure(el, d.tag, error, boundary);\n console.error(`[AOT] Failed to replace <${d.tag}>:`, err);\n }\n\n // Retracted only here, and in the boundary catch above. This is the point at\n // which the component is known to have produced a usable node AND to have\n // reached the document.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n if (forwardedClass && renderedRoot) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) renderedRoot.classList.add(cls);\n }\n }\n\n if (forwardedAttrs.length > 0 && renderedRoot) {\n applyForwardedAttrs(renderedRoot, forwardedAttrs, d.tag);\n }\n\n // Re-target the component pid to the rendered root so subsequent binding\n // passes (event, bound, class, style) apply to the component's actual DOM\n // element. This matches the JIT path where data-on-* attributes are\n // forwarded from the placeholder to the rendered root.\n if (renderedRoot) {\n pidMap.set(d.pid, renderedRoot);\n markForwardTarget(\n renderedRoot,\n localCtx,\n new Set(forwardedAttrs.map(([name]) => name))\n );\n } else {\n if (\n import.meta.env?.DEV &&\n (forwardedClass ||\n forwardedAttrs.length > 0 ||\n (d.props && Object.keys(d.props).length > 0))\n ) {\n console.warn(\n `[AOT] <${d.tag}> has forwarded attributes but returns a fragment with no single root element — forwarding skipped.`\n );\n }\n pidMap.delete(d.pid);\n }\n\n if (replaced) for (const watch of staleWatchers) watch();\n\n const teardown = componentDisposer(\n destroy,\n disposeSetup,\n nodes[0] ?? (replaced ? null : el)\n );\n if (teardown) disposers.push(teardown);\n return replaced ? nodes : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"applyComponent.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,E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CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { compileExpression } from '../../compile/compileExpression';\nimport {\n boundaryForElement,\n replaceHidden,\n runWithBoundary,\n withSlotBoundary,\n slotContentHidden,\n} from '../../compile/binds/bindErrorBoundary';\nimport {\n linkOuterSlotMap,\n type SlotMap,\n} from '../../compile/contentProjection';\nimport {\n collectForwardedAttrs,\n applyForwardedAttrs,\n} from '../../compile/binds/forwardedAttrs';\nimport { nativeTags } from '@pithyjs/compiler';\nimport { createRoot, untrack } from '@pithyjs/signals';\nimport type { CompDesc, BindingContext, ChildFactory } from './types';\nimport { nearestCtx } from './helpers';\nimport { trimBlankEdges } from '../../compile/trimBlankEdges';\nimport { pithyGlobals } from '../../types/globals';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { isRenderableComponentEl } from '../../compile/componentResult';\nimport {\n clearSSRRenderCrash,\n reportComponentFailure,\n resolveBeforeFallback,\n} from '../../compile/ssrCrashes';\nimport { isolateDestroyCallbacks } from '../onDestroy';\nimport { readPropNames } from '../../compile/binds/propNames';\nimport {\n warnBoundProps,\n warnUnexpectedProps,\n} from '../../compile/binds/propWarnings';\nimport { watchStaleRowProp } from '../../compile/binds/staleRowProps';\nimport { markForwardTarget, nodeExpando } from '../../compile/nodeExpando';\nimport { anchorDisposer, componentDisposer } from '../../compile/disposeOrder';\nimport {\n invalidRenderError,\n invalidRenderMessage,\n propEvalMessage,\n} from '../../compile/evalDiagnostics';\n\ninterface ComponentResult {\n /** Any DOM node — see the `Component` type for why this is not narrower. */\n el: Node;\n destroy?: () => void;\n}\ntype ComponentFn = (props: Record<string, unknown>) => ComponentResult;\n\n/** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */\nfunction normalizePropName(authored: string, expectedProps: string[]): string {\n if (expectedProps.includes(authored)) return authored;\n const lower = authored.toLowerCase();\n const matches = expectedProps.filter(p => p.toLowerCase() === lower);\n return matches.length === 1 ? matches[0] : authored;\n}\n\n/** Cache for extractExpectedPropNames to avoid re-parsing the same function. */\nconst propNamesCache = new WeakMap<ComponentFn, string[]>();\n\n/**\n * Extract destructured prop names from component function signature.\n * NOTE: Uses fn.toString() which may return mangled names under aggressive\n * minification (Terser). In that case, prop name normalization becomes a\n * no-op and props are passed as-is (kebab/lowered). This is acceptable\n * because Vite's default esbuild minifier preserves parameter names.\n */\nfunction extractExpectedPropNames(fn: ComponentFn): string[] {\n const cached = propNamesCache.get(fn);\n if (cached) return cached;\n try {\n const parsed = readPropNames(fn);\n const names = parsed.fromParam ? parsed.names : [];\n // Detect likely minification: single-char names suggest mangled output\n if (\n import.meta.env?.DEV &&\n names.length > 0 &&\n names.every(n => n.length === 1)\n ) {\n console.warn(\n `[AOT] extractExpectedPropNames: detected single-char names (${names.join(',')}) — prop normalization may not work under minification`\n );\n }\n propNamesCache.set(fn, names);\n return names;\n } catch {\n return [];\n }\n}\n\n/** Runs a slot factory against the parent's context, owned by the mount's disposers. */\nfunction renderSlot(\n factory: ChildFactory,\n ctx: BindingContext,\n disposers: (() => void)[],\n anchor?: Node,\n host?: Element\n): DocumentFragment {\n const g = pithyGlobals();\n const rendering = g.__pithyComponentContext;\n // Otherwise mergeContexts would read the child's names into the slot's context.\n g.__pithyComponentContext = undefined;\n try {\n const { el, destroy } = withSlotBoundary(anchor, host, () =>\n isolateDestroyCallbacks(() => factory(ctx))\n );\n disposers.push(anchorDisposer(destroy, anchor ?? el.firstChild));\n // Bound already: a runtime-compiled child's binders must not bind it again.\n el.childNodes.forEach(\n node => (nodeExpando(node).__pithyComponentDom = true)\n );\n return el;\n } finally {\n g.__pithyComponentContext = rendering;\n }\n}\n\n/**\n * Slot content serialized into the placeholder, from a descriptor without\n * `slots`. The nodes are moved, so each slot can be mounted only once.\n */\nfunction slotsFromChildren(\n el: Element,\n slotMap: SlotMap\n): DocumentFragment | undefined {\n const slotGroups = new Map<string, Node[]>();\n for (const child of Array.from(el.childNodes)) {\n const slotName =\n child.nodeType === Node.ELEMENT_NODE\n ? (child as Element).getAttribute('slot') || ''\n : '';\n const group = slotGroups.get(slotName);\n if (group) group.push(child);\n else slotGroups.set(slotName, [child]);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.nodeType === Node.TEXT_NODE ? node.textContent : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n // `renderChildren()` and `<slot>` must share one fragment, or the later\n // consumer steals the nodes out of the first.\n let injection: DocumentFragment | undefined;\n for (const [slotName, nodes] of slotGroups) {\n if (slotName === '') {\n injection = document.createDocumentFragment();\n for (const node of nodes) injection.appendChild(node);\n const shared = injection;\n slotMap.set('', () => shared);\n continue;\n }\n slotMap.set(slotName, () => {\n const frag = document.createDocumentFragment();\n for (const node of nodes) frag.appendChild(node);\n return frag;\n });\n }\n return injection;\n}\n\nexport function applyComponent(\n d: CompDesc,\n el: Element,\n ctx: BindingContext,\n disposers: (() => void)[],\n pidMap: Map<string, Element>,\n scope?: BindingContext,\n /** The `[attr]` names on the tag; DEV only. */\n bound: string[] = []\n): Node[] | undefined {\n // Skip native HTML elements — prevents <div> matching a `div` in context.\n // Only apply when the authored tag is already lowercase; PascalCase tags like\n // <Button> are valid components even though \"button\" is a native tag.\n const tagLower = d.tag.toLowerCase();\n if (d.tag === tagLower && nativeTags.has(tagLower)) return;\n resolveBeforeFallback(el);\n\n // Exact case first: the context holds the template's own locals alongside its\n // components, so a prop named `icon` sits next to the `Icon` component and\n // collides case-insensitively. The JIT path lowercases into a Map, where the\n // components — appended last — overwrite the locals; matching that ordering is\n // why `<Icon>` resolves in dev, and breaking on the first match is why it did\n // not in a build. Falling back last-wins keeps the two paths agreeing.\n let candidate: unknown = Object.prototype.hasOwnProperty.call(ctx, d.tag)\n ? ctx[d.tag]\n : undefined;\n if (candidate === undefined) {\n for (const key of Object.keys(ctx)) {\n if (key.toLowerCase() === tagLower) candidate = ctx[key];\n }\n }\n if (!candidate) return;\n\n // Support default exports\n if (\n candidate &&\n typeof candidate === 'object' &&\n 'default' in candidate &&\n typeof candidate.default === 'function'\n ) {\n candidate = candidate.default;\n }\n if (typeof candidate !== 'function') return;\n // Hidden like a sibling an activated boundary detached: never rendered.\n if (slotContentHidden(el)) return;\n\n const componentFn = candidate as ComponentFn;\n const localCtx = scope ?? nearestCtx(el, ctx);\n\n // Extract expected props for case-insensitive normalization\n const expectedProps = extractExpectedPropNames(componentFn);\n\n // Evaluate prop expressions with prop name normalization\n const props: Record<string, unknown> = {};\n const staleWatchers: (() => void)[] = [];\n for (const [rawName, expr] of Object.entries(d.props)) {\n const propName = normalizePropName(rawName, expectedProps);\n try {\n const fn = compileExpression(expr, localCtx);\n props[propName] = untrack(fn);\n if (import.meta.env?.DEV) {\n const value = props[propName];\n staleWatchers.push(() =>\n watchStaleRowProp(\n localCtx,\n d,\n d.tag,\n propName,\n expr,\n value,\n fn,\n disposers\n )\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.warn(propEvalMessage(propName, expr), err);\n // Leave undefined — child uses defaults\n }\n }\n\n if (import.meta.env?.DEV) {\n const names = readPropNames(componentFn);\n warnUnexpectedProps(names, props, d.tag);\n warnBoundProps(names.names, bound, d.tag);\n }\n\n const slotMap: SlotMap = new Map();\n linkOuterSlotMap(slotMap, localCtx);\n let injection: DocumentFragment | undefined;\n if (d.slots) {\n for (const [name, factory] of Object.entries(d.slots))\n slotMap.set(name, (ds = disposers, at) =>\n renderSlot(factory, localCtx, ds, at, el)\n );\n } else {\n injection = slotsFromChildren(el, slotMap);\n }\n\n let invoking = true;\n const childrenFactory = d.children;\n const childFactory: ChildFactory | undefined = childrenFactory\n ? (ctx, wrap) =>\n invoking\n ? childrenFactory(ctx, wrap)\n : isolateDestroyCallbacks(() => childrenFactory(ctx, wrap))\n : undefined;\n\n const componentContext = {\n ...localCtx,\n __slotMap: slotMap,\n __childAstNodes: undefined,\n __childFactory: childFactory,\n __slotHost: el,\n };\n\n // Find nearest error boundary\n const boundaryEl = el.closest('[data-error]') as Element | null;\n const boundary = boundaryForElement(boundaryEl);\n\n let out: ComponentResult | undefined;\n let disposeSetup: (() => void) | undefined;\n try {\n out = runWithBoundary(boundary, () => {\n const g = pithyGlobals();\n const originalContext = g.__pithyComponentContext;\n const wasRendering = g.__pithyRenderingComponent;\n const prevInjection = g.__pithyProjectedChildren;\n g.__pithyComponentContext = componentContext;\n g.__pithyRenderingComponent = true;\n g.__pithyProjectedChildren = injection;\n try {\n return createRoot(disposeRoot => {\n disposeSetup = disposeRoot;\n return componentFn(props);\n });\n } finally {\n g.__pithyComponentContext = originalContext;\n g.__pithyRenderingComponent = wasRendering;\n g.__pithyProjectedChildren = prevInjection;\n invoking = false;\n }\n });\n } catch (err) {\n if (boundary) {\n const error = err instanceof Error ? err : new Error(String(err));\n // See `setBoundaryError`: an already-active boundary with no free ancestor\n // drops the error rather than taking it, which is the normal case for a\n // component rendering inside that boundary's `@fallback`.\n reportComponentFailure(el, d.tag, error, boundary);\n return;\n }\n\n // No boundary reachable through the DOM. A branch, slot or component\n // built detached knows the one it will sit under (`deferCrash`).\n // Otherwise degrade in both modes — throwing would only be swallowed by\n // the structural handler's own catch (`applyStructural.ts`).\n //\n // A static/server render records the crash instead: dropping the component\n // silently shipped HTML with <${d.tag}> left raw while `pithy-ssg` counted\n // the route as rendered and exited 0 (BUG-018). Anything still recorded\n // when the render finishes fails the route.\n const error = err instanceof Error ? err : new Error(String(err));\n const message = `[AOT] Component <${d.tag}> crashed:`;\n if (!reportComponentFailure(el, d.tag, error, null, { message }))\n console.error(message, err);\n return;\n }\n\n if (\n !out ||\n typeof out !== 'object' ||\n !('el' in out) ||\n !isRenderableComponentEl(out.el, el)\n ) {\n // Not a throw, but the same outcome: the raw <${d.tag}> is left in place\n // and the subtree never renders, which under SSR is content silently\n // missing from the emitted HTML. Recorded exactly like a crash (BUG-018).\n // Same funnel as a throw — see `bindComponentTags`. Recording without\n // offering it to the boundary left an AOT component under `@error-boundary`\n // failing its route with the boundary signal unset.\n reportComponentFailure(el, d.tag, invalidRenderError(d.tag), boundary);\n if (import.meta.env?.DEV) console.warn(invalidRenderMessage(d.tag));\n disposeSetup?.();\n return;\n }\n\n const { el: renderedEl, destroy } = out;\n\n // Capture rendered root element before fragment is consumed by replaceWith\n const forwardedClass = el.getAttribute('class');\n const forwardedAttrs = collectForwardedAttrs(el);\n const renderedRoot: Element | null =\n renderedEl instanceof DocumentFragment\n ? renderedEl.firstElementChild\n : renderedEl instanceof Element\n ? renderedEl\n : null;\n\n const nodes =\n renderedEl instanceof DocumentFragment\n ? Array.from(renderedEl.childNodes)\n : [renderedEl];\n let replaced = true;\n try {\n // A boundary that caught a crash in this render may have hidden `el`.\n if (!replaceHidden(el, nodes)) el.replaceWith(...nodes);\n } catch (err) {\n // The raw <${d.tag}> is left exactly where a crash would have left it, so\n // this is the same content loss and is recorded the same way.\n replaced = false;\n const error = err instanceof Error ? err : new Error(String(err));\n reportComponentFailure(el, d.tag, error, boundary);\n console.error(`[AOT] Failed to replace <${d.tag}>:`, err);\n }\n\n // Retracted only here, and in the boundary catch above. This is the point at\n // which the component is known to have produced a usable node AND to have\n // reached the document.\n if (isSSRMode() && replaced) clearSSRRenderCrash(el);\n\n if (forwardedClass && renderedRoot) {\n for (const cls of forwardedClass.split(/\\s+/)) {\n if (cls) renderedRoot.classList.add(cls);\n }\n }\n\n if (forwardedAttrs.length > 0 && renderedRoot) {\n applyForwardedAttrs(renderedRoot, forwardedAttrs, d.tag);\n }\n\n // Re-target the component pid to the rendered root so subsequent binding\n // passes (event, bound, class, style) apply to the component's actual DOM\n // element. This matches the JIT path where data-on-* attributes are\n // forwarded from the placeholder to the rendered root.\n if (renderedRoot) {\n pidMap.set(d.pid, renderedRoot);\n markForwardTarget(\n renderedRoot,\n localCtx,\n new Set(forwardedAttrs.map(([name]) => name))\n );\n } else {\n if (\n import.meta.env?.DEV &&\n (forwardedClass ||\n forwardedAttrs.length > 0 ||\n (d.props && Object.keys(d.props).length > 0))\n ) {\n console.warn(\n `[AOT] <${d.tag}> has forwarded attributes but returns a fragment with no single root element — forwarding skipped.`\n );\n }\n pidMap.delete(d.pid);\n }\n\n if (replaced) for (const watch of staleWatchers) watch();\n\n const teardown = componentDisposer(\n destroy,\n disposeSetup,\n nodes[0] ?? (replaced ? null : el)\n );\n if (teardown) disposers.push(teardown);\n return replaced ? nodes : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyStructural.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"applyStructural.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI3E,wBAAgB,OAAO,CACrB,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA0HN;AAED,wBAAgB,QAAQ,CACtB,CAAC,EAAE,OAAO,EACV,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA2EN;AAiBD,wBAAgB,WAAW,CACzB,CAAC,EAAE,UAAU,EACb,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAiIN"}
|
|
@@ -6,6 +6,7 @@ import { compileTrackBy } from '../../compile/forLoops/loopHelpers.js';
|
|
|
6
6
|
import { anchorDisposer, blockDisposer } from '../../compile/disposeOrder.js';
|
|
7
7
|
import { withBranchBoundary } from '../../compile/binds/bindErrorBoundary.js';
|
|
8
8
|
import { withinRender } from '../../compile/ssrCrashes.js';
|
|
9
|
+
import { switchEvalMessage } from '../../compile/evalDiagnostics.js';
|
|
9
10
|
import { createLoopContext, createLoopSignals, } from '../../compile/forLoops/loopSignals.js';
|
|
10
11
|
// ─── Structural directive handlers ────────────────────────────────────────────
|
|
11
12
|
export function applyIf(d, commentMap, ctx, disposers) {
|
|
@@ -164,6 +165,7 @@ export function applyFor(d, commentMap, ctx, disposers) {
|
|
|
164
165
|
parentCtx: ctx,
|
|
165
166
|
itemVar: d.item,
|
|
166
167
|
indexVar: d.index,
|
|
168
|
+
tag: d.tag,
|
|
167
169
|
itemFactory: itemCtx => {
|
|
168
170
|
const result = d.factory(itemCtx);
|
|
169
171
|
const el = document.createDocumentFragment();
|
|
@@ -213,7 +215,7 @@ export function applySwitch(d, pidMap, ctx, disposers) {
|
|
|
213
215
|
currentNodes = [];
|
|
214
216
|
}
|
|
215
217
|
if (isSSRMode()) {
|
|
216
|
-
const switchVal = compileExpression(d.expr, ctx)
|
|
218
|
+
const switchVal = evaluate(compileExpression(d.expr, ctx), '@switch', d.expr);
|
|
217
219
|
let matchIndex = -1;
|
|
218
220
|
let defaultIndex = -1;
|
|
219
221
|
for (let i = 0; i < d.cases.length; i++) {
|
|
@@ -223,7 +225,7 @@ export function applySwitch(d, pidMap, ctx, disposers) {
|
|
|
223
225
|
defaultIndex = i;
|
|
224
226
|
continue;
|
|
225
227
|
}
|
|
226
|
-
const caseVal = compileExpression(c.val, ctx)
|
|
228
|
+
const caseVal = evaluate(compileExpression(c.val, ctx), '@case', c.val);
|
|
227
229
|
if (caseVal === switchVal) {
|
|
228
230
|
matchIndex = i;
|
|
229
231
|
break;
|
|
@@ -258,16 +260,17 @@ export function applySwitch(d, pidMap, ctx, disposers) {
|
|
|
258
260
|
const caseEvals = d.cases.map(c => c.val !== undefined ? compileExpression(c.val, ctx) : null);
|
|
259
261
|
let previousMatchIndex = -1;
|
|
260
262
|
const stopEffect = effect(() => {
|
|
261
|
-
const switchVal = switchEval
|
|
263
|
+
const switchVal = evaluate(switchEval, '@switch', d.expr);
|
|
262
264
|
let matchIndex = -1;
|
|
263
265
|
let defaultIndex = -1;
|
|
264
266
|
for (let i = 0; i < d.cases.length; i++) {
|
|
265
|
-
|
|
267
|
+
const caseEval = caseEvals[i];
|
|
268
|
+
if (caseEval === null) {
|
|
266
269
|
if (defaultIndex === -1)
|
|
267
270
|
defaultIndex = i;
|
|
268
271
|
continue;
|
|
269
272
|
}
|
|
270
|
-
if (
|
|
273
|
+
if (evaluate(caseEval, '@case', d.cases[i].val ?? '') === switchVal) {
|
|
271
274
|
matchIndex = i;
|
|
272
275
|
break;
|
|
273
276
|
}
|
|
@@ -307,4 +310,15 @@ export function applySwitch(d, pidMap, ctx, disposers) {
|
|
|
307
310
|
});
|
|
308
311
|
disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));
|
|
309
312
|
}
|
|
313
|
+
/** A throwing `@switch` or `@case` reads as `undefined`, as in dev. */
|
|
314
|
+
function evaluate(fn, kind, expr) {
|
|
315
|
+
try {
|
|
316
|
+
return fn();
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
if (import.meta.env?.DEV)
|
|
320
|
+
console.error(switchEvalMessage(kind, expr), err);
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
310
324
|
//# sourceMappingURL=applyStructural.js.map
|