@pithyjs/core 0.1.0-beta.2 → 0.1.0-beta.20

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.
Files changed (239) hide show
  1. package/README.md +46 -8
  2. package/dist/a11y/focus-trap.d.ts +11 -3
  3. package/dist/a11y/focus-trap.d.ts.map +1 -1
  4. package/dist/a11y/focus-trap.js +55 -10
  5. package/dist/a11y/focus-trap.js.map +1 -1
  6. package/dist/a11y/index.d.ts +4 -4
  7. package/dist/a11y/index.js +4 -4
  8. package/dist/a11y/index.js.map +1 -1
  9. package/dist/a11y/keyboard-utils.js.map +1 -1
  10. package/dist/a11y/roving-tabindex.js.map +1 -1
  11. package/dist/a11y/skip-link.js.map +1 -1
  12. package/dist/compile/bindSwitchCases.d.ts +8 -3
  13. package/dist/compile/bindSwitchCases.d.ts.map +1 -1
  14. package/dist/compile/bindSwitchCases.js +137 -183
  15. package/dist/compile/bindSwitchCases.js.map +1 -1
  16. package/dist/compile/binds/bindAfterComponents.d.ts +4 -0
  17. package/dist/compile/binds/bindAfterComponents.d.ts.map +1 -0
  18. package/dist/compile/binds/bindAfterComponents.js +26 -0
  19. package/dist/compile/binds/bindAfterComponents.js.map +1 -0
  20. package/dist/compile/binds/bindAfterProjection.d.ts +7 -0
  21. package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -0
  22. package/dist/compile/binds/bindAfterProjection.js +15 -0
  23. package/dist/compile/binds/bindAfterProjection.js.map +1 -0
  24. package/dist/compile/binds/bindBoundAttributes.d.ts +8 -0
  25. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
  26. package/dist/compile/binds/bindBoundAttributes.js +224 -21
  27. package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
  28. package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
  29. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  30. package/dist/compile/binds/bindClassDirectives.js +58 -21
  31. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  32. package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
  33. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  34. package/dist/compile/binds/bindComponentsTags.js +186 -74
  35. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  36. package/dist/compile/binds/bindConditionals.d.ts +2 -2
  37. package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
  38. package/dist/compile/binds/bindConditionals.js +22 -5
  39. package/dist/compile/binds/bindConditionals.js.map +1 -1
  40. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  41. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  42. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  43. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
  44. package/dist/compile/binds/bindDeferDirectives.js +21 -19
  45. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  46. package/dist/compile/binds/bindErrorBoundary.d.ts +61 -0
  47. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  48. package/dist/compile/binds/bindErrorBoundary.js +272 -16
  49. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  50. package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
  51. package/dist/compile/binds/bindEventHandlers.js +15 -5
  52. package/dist/compile/binds/bindEventHandlers.js.map +1 -1
  53. package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
  54. package/dist/compile/binds/bindRefDirectives.js +2 -1
  55. package/dist/compile/binds/bindRefDirectives.js.map +1 -1
  56. package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
  57. package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
  58. package/dist/compile/binds/bindStyleDirectives.js +48 -0
  59. package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
  60. package/dist/compile/binds/bindTextInterpolations.d.ts +4 -2
  61. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
  62. package/dist/compile/binds/bindTextInterpolations.js +86 -35
  63. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  64. package/dist/compile/binds/declaredDirective.d.ts +12 -0
  65. package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
  66. package/dist/compile/binds/declaredDirective.js +42 -0
  67. package/dist/compile/binds/declaredDirective.js.map +1 -0
  68. package/dist/compile/binds/directiveRegistry.js.map +1 -1
  69. package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
  70. package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
  71. package/dist/compile/binds/forwardedAttrs.js +10 -2
  72. package/dist/compile/binds/forwardedAttrs.js.map +1 -1
  73. package/dist/compile/binds/propNames.d.ts +14 -0
  74. package/dist/compile/binds/propNames.d.ts.map +1 -0
  75. package/dist/compile/binds/propNames.js +116 -0
  76. package/dist/compile/binds/propNames.js.map +1 -0
  77. package/dist/compile/binds/staleRowProps.d.ts +9 -0
  78. package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
  79. package/dist/compile/binds/staleRowProps.js +86 -0
  80. package/dist/compile/binds/staleRowProps.js.map +1 -0
  81. package/dist/compile/compileExpression.js.map +1 -1
  82. package/dist/compile/compileNodes.d.ts.map +1 -1
  83. package/dist/compile/compileNodes.js +16 -7
  84. package/dist/compile/compileNodes.js.map +1 -1
  85. package/dist/compile/compileTemplate.d.ts +3 -4
  86. package/dist/compile/compileTemplate.d.ts.map +1 -1
  87. package/dist/compile/compileTemplate.js +36 -54
  88. package/dist/compile/compileTemplate.js.map +1 -1
  89. package/dist/compile/componentResult.js.map +1 -1
  90. package/dist/compile/contentProjection.d.ts +15 -3
  91. package/dist/compile/contentProjection.d.ts.map +1 -1
  92. package/dist/compile/contentProjection.js +90 -9
  93. package/dist/compile/contentProjection.js.map +1 -1
  94. package/dist/compile/disposeOrder.d.ts +35 -0
  95. package/dist/compile/disposeOrder.d.ts.map +1 -0
  96. package/dist/compile/disposeOrder.js +81 -0
  97. package/dist/compile/disposeOrder.js.map +1 -0
  98. package/dist/compile/evalDiagnostics.d.ts +7 -0
  99. package/dist/compile/evalDiagnostics.d.ts.map +1 -0
  100. package/dist/compile/evalDiagnostics.js +8 -0
  101. package/dist/compile/evalDiagnostics.js.map +1 -0
  102. package/dist/compile/forLoops/bindForLoops.d.ts +3 -3
  103. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
  104. package/dist/compile/forLoops/bindForLoops.js +18 -13
  105. package/dist/compile/forLoops/bindForLoops.js.map +1 -1
  106. package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
  107. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  108. package/dist/compile/forLoops/createLoopManager.js +39 -26
  109. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  110. package/dist/compile/forLoops/index.d.ts +5 -5
  111. package/dist/compile/forLoops/index.js +5 -5
  112. package/dist/compile/forLoops/index.js.map +1 -1
  113. package/dist/compile/forLoops/loopHelpers.js.map +1 -1
  114. package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
  115. package/dist/compile/forLoops/loopSignals.js +15 -1
  116. package/dist/compile/forLoops/loopSignals.js.map +1 -1
  117. package/dist/compile/forLoops/loopTraversal.js +2 -2
  118. package/dist/compile/forLoops/loopTraversal.js.map +1 -1
  119. package/dist/compile/handleConditionalChain.d.ts +2 -2
  120. package/dist/compile/handleConditionalChain.d.ts.map +1 -1
  121. package/dist/compile/handleConditionalChain.js +23 -89
  122. package/dist/compile/handleConditionalChain.js.map +1 -1
  123. package/dist/compile/index.d.ts +17 -17
  124. package/dist/compile/index.js +14 -14
  125. package/dist/compile/index.js.map +1 -1
  126. package/dist/compile/injectScopedStyle.js.map +1 -1
  127. package/dist/compile/nodeExpando.d.ts +28 -0
  128. package/dist/compile/nodeExpando.d.ts.map +1 -1
  129. package/dist/compile/nodeExpando.js +12 -0
  130. package/dist/compile/nodeExpando.js.map +1 -1
  131. package/dist/compile/parseHtml.d.ts.map +1 -1
  132. package/dist/compile/parseHtml.js +4 -3
  133. package/dist/compile/parseHtml.js.map +1 -1
  134. package/dist/compile/pithyTreeToDom.js +2 -1
  135. package/dist/compile/pithyTreeToDom.js.map +1 -1
  136. package/dist/compile/renderBranch.d.ts +13 -0
  137. package/dist/compile/renderBranch.d.ts.map +1 -0
  138. package/dist/compile/renderBranch.js +72 -0
  139. package/dist/compile/renderBranch.js.map +1 -0
  140. package/dist/compile/renderChildren.d.ts +12 -2
  141. package/dist/compile/renderChildren.d.ts.map +1 -1
  142. package/dist/compile/renderChildren.js +33 -4
  143. package/dist/compile/renderChildren.js.map +1 -1
  144. package/dist/compile/ssrCrashes.d.ts +65 -37
  145. package/dist/compile/ssrCrashes.d.ts.map +1 -1
  146. package/dist/compile/ssrCrashes.js +344 -39
  147. package/dist/compile/ssrCrashes.js.map +1 -1
  148. package/dist/compile/ssrMode.js +1 -1
  149. package/dist/compile/ssrMode.js.map +1 -1
  150. package/dist/compile/textValue.js.map +1 -1
  151. package/dist/compile/trimBlankEdges.d.ts +2 -0
  152. package/dist/compile/trimBlankEdges.d.ts.map +1 -0
  153. package/dist/compile/trimBlankEdges.js +15 -0
  154. package/dist/compile/trimBlankEdges.js.map +1 -0
  155. package/dist/config/index.js.map +1 -1
  156. package/dist/index.d.ts +6 -6
  157. package/dist/index.js +6 -6
  158. package/dist/index.js.map +1 -1
  159. package/dist/interfaces/index.d.ts +2 -2
  160. package/dist/interfaces/index.js +2 -2
  161. package/dist/interfaces/index.js.map +1 -1
  162. package/dist/interfaces/ref-signal.interface.js.map +1 -1
  163. package/dist/interfaces/ref.interface.js.map +1 -1
  164. package/dist/runtime/applyBindings.d.ts +9 -5
  165. package/dist/runtime/applyBindings.d.ts.map +1 -1
  166. package/dist/runtime/applyBindings.js +130 -43
  167. package/dist/runtime/applyBindings.js.map +1 -1
  168. package/dist/runtime/bindings/applyComponent.d.ts +2 -2
  169. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  170. package/dist/runtime/bindings/applyComponent.js +143 -87
  171. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  172. package/dist/runtime/bindings/applyDefer.d.ts +1 -1
  173. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
  174. package/dist/runtime/bindings/applyDefer.js +16 -15
  175. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  176. package/dist/runtime/bindings/applySimple.d.ts +10 -1
  177. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  178. package/dist/runtime/bindings/applySimple.js +117 -46
  179. package/dist/runtime/bindings/applySimple.js.map +1 -1
  180. package/dist/runtime/bindings/applyStructural.d.ts +1 -1
  181. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  182. package/dist/runtime/bindings/applyStructural.js +140 -124
  183. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  184. package/dist/runtime/bindings/helpers.d.ts +8 -1
  185. package/dist/runtime/bindings/helpers.d.ts.map +1 -1
  186. package/dist/runtime/bindings/helpers.js +36 -2
  187. package/dist/runtime/bindings/helpers.js.map +1 -1
  188. package/dist/runtime/bindings/index.d.ts +6 -6
  189. package/dist/runtime/bindings/index.d.ts.map +1 -1
  190. package/dist/runtime/bindings/index.js +5 -5
  191. package/dist/runtime/bindings/index.js.map +1 -1
  192. package/dist/runtime/bindings/types.d.ts +2 -0
  193. package/dist/runtime/bindings/types.d.ts.map +1 -1
  194. package/dist/runtime/bindings/types.js.map +1 -1
  195. package/dist/runtime/bootstrap.d.ts +1 -1
  196. package/dist/runtime/bootstrap.js +1 -1
  197. package/dist/runtime/bootstrap.js.map +1 -1
  198. package/dist/runtime/createContextProxy.js.map +1 -1
  199. package/dist/runtime/deferHelpers.d.ts +1 -1
  200. package/dist/runtime/deferHelpers.js.map +1 -1
  201. package/dist/runtime/html.js +7 -7
  202. package/dist/runtime/html.js.map +1 -1
  203. package/dist/runtime/index.d.ts +6 -6
  204. package/dist/runtime/index.js +6 -6
  205. package/dist/runtime/index.js.map +1 -1
  206. package/dist/runtime/lazy.js +1 -1
  207. package/dist/runtime/lazy.js.map +1 -1
  208. package/dist/runtime/module-cache.js.map +1 -1
  209. package/dist/runtime/onDestroy.d.ts +7 -0
  210. package/dist/runtime/onDestroy.d.ts.map +1 -1
  211. package/dist/runtime/onDestroy.js +16 -1
  212. package/dist/runtime/onDestroy.js.map +1 -1
  213. package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
  214. package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
  215. package/dist/runtime/resource/createAction.d.ts +1 -1
  216. package/dist/runtime/resource/createAction.js +1 -1
  217. package/dist/runtime/resource/createAction.js.map +1 -1
  218. package/dist/runtime/resource/createResource.d.ts +1 -1
  219. package/dist/runtime/resource/createResource.d.ts.map +1 -1
  220. package/dist/runtime/resource/createResource.js +3 -4
  221. package/dist/runtime/resource/createResource.js.map +1 -1
  222. package/dist/runtime/resource/engine.d.ts +1 -1
  223. package/dist/runtime/resource/engine.js.map +1 -1
  224. package/dist/runtime/resource/index.d.ts +3 -3
  225. package/dist/runtime/resource/index.js +2 -2
  226. package/dist/runtime/resource/index.js.map +1 -1
  227. package/dist/runtime/resource/types.js.map +1 -1
  228. package/dist/types/globals.d.ts +10 -2
  229. package/dist/types/globals.d.ts.map +1 -1
  230. package/dist/types/globals.js.map +1 -1
  231. package/dist/types/index.js.map +1 -1
  232. package/dist/utilities/index.d.ts +2 -2
  233. package/dist/utilities/index.js +2 -2
  234. package/dist/utilities/index.js.map +1 -1
  235. package/dist/utilities/ref-signal.utility.d.ts +1 -1
  236. package/dist/utilities/ref-signal.utility.js.map +1 -1
  237. package/dist/utilities/ref.untility.d.ts +1 -1
  238. package/dist/utilities/ref.untility.js.map +1 -1
  239. package/package.json +11 -6
@@ -1 +1 @@
1
- {"version":3,"file":"compileTemplate.js","sourceRoot":"","sources":["../../src/compile/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,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IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,8EAA8E;IAC9E,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.renderer\",\n \"title\": \"Template Compiler & Renderer\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { parseHtml } from './parseHtml';\nimport { withinRender } from './ssrCrashes';\nimport { injectScopedStyle } from './injectScopedStyle';\nimport { bindConditionals } from './binds/bindConditionals';\nimport { bindRefDirectives } from './binds/bindRefDirectives';\nimport { bindErrorBoundary } from './binds/bindErrorBoundary';\nimport { bindForLoops } from './forLoops/bindForLoops';\nimport { bindSwitchCases } from './bindSwitchCases';\nimport {\n extractSlotDefs,\n mountProjection,\n type SlotMap,\n} from './contentProjection';\nimport { bindAfterProjection } from './binds/bindAfterProjection';\nimport { orderByDocument } from './disposeOrder';\n\n/**\n * Runs all structural directive bindings on a fragment.\n *\n * Ordering:\n * 1) Switch cases first — they claim their case subtrees before conditionals walk the DOM\n * 2) Conditionals (@if/@else) — each branch binds its own nested switches\n * 3) For loops — skips nodes already processed by switches and conditionals\n */\nexport function bindStructuralDirectives(\n nodes: import('@pithyjs/compiler').PithyNode[],\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n const processed = bindSwitchCases(\n nodes,\n fragment,\n context,\n new Set(),\n disposers\n );\n bindConditionals(nodes, fragment, context, processed, disposers);\n bindForLoops(nodes, fragment, context, disposers, processed);\n}\n\n/**\n * Compiles a raw HTML template into live DOM nodes with signal bindings,\n * event handlers, and optional styles.\n *\n * Pipeline overview:\n * 1) parseHtml → returns a DocumentFragment + AST nodes (pithyNodes)\n * 2) structural directives first: @if/@else, @switch, @for (they shape the DOM)\n * 3) inject CSS (scoped)\n * 4) run remaining binders in an order that avoids double-binding and cross-contamination:\n * - refs (so later passes can access refs if needed)\n * - components (instantiate/replace custom tags BEFORE binding into their subtree)\n * - two-way (default model bindings for inputs)\n * - text interpolations\n * - events\n * - classes\n * - bound attributes\n *\n * @param html - Raw HTML template string\n * @param context - Reactive context object (signals, methods, components)\n * @param css - Optional CSS string to scope and inject\n * @param scopeId - Optional scope id for CSS scoping\n * @param importedIdentifiers - Optional set of ids exposed to expressions\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"compileTemplate\",\"stability\":\"stable\",\"signature\":\"(html: string, context: Record<string, any>, css?: string, scopeId?: string, importedIdentifiers?: Set<string>) => { el: HTMLElement | DocumentFragment; destroy: () => void }\"} */\nexport function compileTemplate(\n html: string,\n context: Record<string, unknown>,\n css?: string,\n scopeId?: string,\n importedIdentifiers?: Set<string>\n): { el: HTMLElement | DocumentFragment; destroy: () => void } {\n const id = scopeId ?? `pithy-${Math.random().toString(36).slice(2, 8)}`;\n const disposers: (() => void)[] = [];\n\n let fragment: DocumentFragment;\n try {\n // Parse into fragment + AST\n const parsed = parseHtml(html, id, context, importedIdentifiers);\n fragment = parsed.fragment;\n\n const built = fragment;\n withinRender(() => {\n // Structural transforms first (they change the DOM shape and add anchors)\n bindStructuralDirectives(parsed.pithyNodes, built, context, disposers);\n\n // Scoped CSS after structure is stable\n if (css) {\n injectScopedStyle(css, id);\n }\n\n // Remaining directives/bindings in carefully chosen order\n bindTemplateDirectives(built, context, disposers);\n });\n orderByDocument(disposers);\n } catch (err) {\n // Clean up any disposers registered during partial compilation\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n throw err;\n }\n\n return {\n el: fragment,\n destroy() {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n disposers.length = 0;\n },\n };\n}\n\n/**\n * Applies all non-structural bindings to the compiled fragment.\n *\n * Ordering rationale:\n * - refs: collected early, sometimes needed by subsequent binders\n * - error boundaries: register boundaries before components render (enables error capture)\n * - projection: mount projected content into slot anchors BEFORE component binding,\n * so nested component tags in projected content get processed\n * - components: instantiate/replace custom tags (including those in projected content);\n * prevents parent binders from walking into raw component tags\n * - two-way: attach default v-model-ish behavior on real inputs (not inside components)\n * - text: {{ ... }} bindings (skips nested loops / component subtrees via flags)\n * - events: add listeners (idempotent; supports modifiers; nearest ctx; $event/$el)\n * - classes: dynamic class toggles\n * - attributes: remaining [attr]=\"...\" bindings\n */\n/** @codexApi {\"parent\":\"pithy.runtime.renderer\",\"name\":\"bindTemplateDirectives\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, context: Record<string, any>, disposers: (() => void)[]) => void\"} */\nexport function bindTemplateDirectives(\n fragment: DocumentFragment,\n context: Record<string, unknown>,\n disposers: (() => void)[]\n): void {\n // 1) refs first — enables grabbing component roots/elements if needed\n bindRefDirectives(fragment, context, disposers);\n\n // 2) error boundaries — register before components so they can catch component errors\n bindErrorBoundary(fragment, context, disposers);\n\n // 3) content projection — mount projected content into slot anchors BEFORE components.\n // Projected content may contain component tags (e.g., nested <Show> inside <Show>).\n // If components ran first, those nested component tags would never be processed.\n // Without a SlotMap (a component called directly) slots still get their fallback.\n // Use 'in' operator to check via Proxy's has() trap without triggering the get() warning\n const slotMap = ('__slotMap' in context ? context.__slotMap : undefined) as\n | SlotMap\n | undefined;\n const slotDefs = extractSlotDefs(fragment);\n if (slotDefs.length > 0) {\n mountProjection(slotDefs, slotMap ?? new Map(), disposers);\n }\n\n // 4-11) components, two-way, text, events, classes, attributes, custom, defer\n bindAfterProjection(fragment, context, disposers);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"componentResult.js","sourceRoot":"","sources":["../../src/compile/componentResult.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,uLAAuL;AACvL,MAAM,UAAU,uBAA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E5C,OAAQ,UAAiC,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.compile.component-result\",\n \"title\": \"Component Result Validation\",\n \"category\": \"compiler\",\n \"risk\": \"high\"\n}\n*/\n\n/**\n * Is `value` something a binder can actually put into the document?\n *\n * A component contract is `{ el, destroy }`, and both binders used to accept it\n * on the strength of `'el' in out` alone. That is a presence check, not a type\n * check: `{ el: null }` satisfies it, and `el.replaceWith(null)` does not throw\n * — the DOM stringifies the argument, so the page ships the literal text\n * `null` where the component should have been.\n *\n * Measured before this guard existed, in SSR:\n *\n * ```\n * records = 0 html = <div ...>null</div>\n * ```\n *\n * Zero crashes reported, exit 0, and visible garbage in the output — worse than\n * the raw unrendered tag BUG-018 was about, because that at least renders as\n * nothing. TypeScript does not help: an app can be JavaScript, or can cast.\n *\n * `nodeType` alone is not enough, because it is just a property any object can\n * have. `{ nodeType: 1, toString: () => 'BROKEN' }` passed an earlier version of\n * this guard, and `replaceWith` then stringified it into the page exactly like\n * `null` did:\n *\n * ```\n * records = 0 html = <div ...>BROKEN</div>\n * ```\n *\n * So the value must also really be a `Node`. That check has to work ACROSS\n * realms, because a component may legitimately return a node built by another\n * `Window` — an iframe's `contentDocument`, or a module-level `document`\n * captured under a previous route's happy-dom window. A plain\n * `instanceof Node` rejects those, and since both binders run this guard in the\n * browser too, that would turn working components into \"invalid render result\".\n *\n * Two checks, in order of strength:\n *\n * 1. `instanceof` against the `Node` of `reference`'s realm — the placeholder\n * the binder is replacing, which is by construction a real node in the\n * document being rendered. This is the common case and the strongest\n * signal. The realm comes from `reference` and NEVER from `value`: an\n * earlier version read `value.ownerDocument.defaultView.Node`, which let the\n * candidate nominate its own validator (`{ Node: Object }` passes trivially).\n *\n * 2. Failing that, a structural brand that survives realm boundaries. Real\n * nodes expose `nodeType`, `nodeName` and `cloneNode` through their\n * prototype; a hand-made object carries them as OWN properties, which is\n * what separates a foreign `HTMLSpanElement` from\n * `{ nodeType: 1, toString: () => 'BROKEN' }` — measured, both branches are\n * tested.\n *\n * KNOWN LIMIT, stated rather than glossed: this is defeated by a deliberate\n * forgery. `Object.create({ nodeType: 1, nodeName: 'SPAN', cloneNode() {} })`\n * puts the whole shape on the prototype, so the own-vs-inherited test says\n * \"real node\", and `replaceWith` then stringifies it into the page.\n *\n * The guard is not escalated further because every stronger static test is\n * worse: `instanceof` alone rejects genuine foreign nodes, and `Symbol.toStringTag`\n * defeats a `[object HTMLDivElement]` brand just as easily. The one check that\n * cannot be forged is observing whether the node actually landed after\n * `replaceWith` — that was implemented and REVERTED, because the JIT binds a\n * structural branch on a detached tree first, where `replaceWith` legitimately\n * does nothing and the retry does the real work: the observation could not tell\n * that apart from stringification and failed `apps/gliora-dashboard`'s `/login`\n * route, whose emitted HTML is in fact complete (4 form-field elements, 2 labels,\n * 2 inputs, no raw tags).\n *\n * So the scope here is ACCIDENT, not adversary: a component returning the wrong\n * shape by mistake — `{ el: null }`, `{ el: undefined }`, a bare options object —\n * which is the failure that actually occurs. A component in your own app that\n * deliberately forges DOM internals is not a threat this layer can address, and\n * pretending otherwise would cost working pages. Tracked in docs/BACKLOG.md.\n *\n * Deliberately **not** an allowlist of node types. The question here is \"is this\n * a node at all\", not \"is it a node I like\": a component returning\n * `document.createTextNode('hi')` renders correctly through `replaceWith`, and\n * an earlier version that admitted only elements and fragments silently narrowed\n * the contract and dropped such a subtree. Anything that is a real node but\n * cannot actually be inserted — a `Document`, say — throws inside `replaceWith`,\n * which is already recorded as a failed replacement and gives a truthful error.\n *\n * Fails **open** when nothing can be resolved to check against. A guard that\n * cannot check must not reject everything: with neither a realm on `reference`\n * nor an ambient `Node`, rejecting would record a crash for every component and\n * fail every route — far worse than the malformed output this guards against.\n *\n * @param value - the `el` a component returned\n * @param reference - a node known to be real, whose realm defines `Node`\n */\n/** @codexApi {\"parent\":\"pithy.compile.component-result\",\"name\":\"isRenderableComponentEl\",\"stability\":\"internal\",\"signature\":\"(value: unknown, reference?: Node | null) => boolean\"} */\nexport function isRenderableComponentEl(\n value: unknown,\n reference?: Node | null\n): boolean {\n if (!value || typeof value !== 'object') return false;\n if (typeof (value as { nodeType?: unknown }).nodeType !== 'number') {\n return false;\n }\n\n const NodeCtor = trustedNodeConstructor(reference);\n if (typeof NodeCtor !== 'function') return true;\n if (value instanceof NodeCtor) return true;\n\n return hasCrossRealmNodeBrand(value);\n}\n\n/**\n * Does `value` carry the DOM's own shape rather than a hand-made imitation of\n * it? Used only for nodes from another realm, where `instanceof` cannot help.\n *\n * The discriminator is *own* versus *inherited*: a real node — local or foreign\n * — gets these from `Node.prototype`, so `hasOwnProperty` is false for all of\n * them, while an object literal has to declare each one itself.\n */\nfunction hasCrossRealmNodeBrand(value: object): boolean {\n const own = (key: string) => Object.prototype.hasOwnProperty.call(value, key);\n if (own('nodeType') || own('nodeName') || own('cloneNode')) return false;\n\n const candidate = value as { nodeName?: unknown; cloneNode?: unknown };\n return (\n typeof candidate.nodeName === 'string' &&\n typeof candidate.cloneNode === 'function'\n );\n}\n\n/**\n * The `Node` constructor from `reference`'s realm, falling back to the ambient\n * global. Deliberately never reads anything off the value being validated.\n */\nfunction trustedNodeConstructor(reference?: Node | null): unknown {\n const view = (\n reference as { ownerDocument?: { defaultView?: { Node?: unknown } } | null }\n )?.ownerDocument?.defaultView?.Node;\n if (typeof view === 'function') return view;\n\n return (globalThis as { Node?: unknown }).Node;\n}\n"]}
@@ -10,7 +10,7 @@ import { PithyNode } from '@pithyjs/compiler';
10
10
  * SlotMap contains renderer functions for each slot name.
11
11
  * Each entry is a factory that returns a DocumentFragment of the slot's content.
12
12
  */
13
- export type SlotMap = Map<string, () => DocumentFragment>;
13
+ export type SlotMap = Map<string, (disposers?: (() => void)[], anchor?: Node) => DocumentFragment>;
14
14
  /**
15
15
  * SlotDef describes a slot anchor and its fallback content
16
16
  */
@@ -20,10 +20,22 @@ export interface SlotDef {
20
20
  anchor: Comment;
21
21
  fallbackFactory?: FallbackFactory;
22
22
  }
23
- /** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>) => SlotMap"} */
24
- export declare function collectSlotMap(children: PithyNode[], parentContext: Record<string, unknown>): SlotMap;
23
+ /**
24
+ * The slot map of the template the children behind `slotMap` were written in:
25
+ * what a `<slot>` among those children receives.
26
+ */
27
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"outerSlotMap","stability":"internal","signature":"(slotMap: SlotMap | undefined) => SlotMap | undefined"} */
28
+ export declare function outerSlotMap(slotMap: SlotMap | undefined): SlotMap | undefined;
29
+ /** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */
30
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"linkOuterSlotMap","stability":"internal","signature":"(slotMap: SlotMap, ctx: Record<string, unknown>) => void"} */
31
+ export declare function linkOuterSlotMap(slotMap: SlotMap, ctx: Record<string, unknown>): void;
32
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>, host?: Element) => SlotMap"} */
33
+ export declare function collectSlotMap(children: PithyNode[], parentContext: Record<string, unknown>, host?: Element): SlotMap;
25
34
  /** @codexApi {"parent":"pithy.feature.content-projection","name":"extractSlotDefs","stability":"stable","signature":"(fragment: DocumentFragment) => SlotDef[]"} */
26
35
  export declare function extractSlotDefs(fragment: DocumentFragment): SlotDef[];
36
+ /** Whether `node` is inside content a `<slot>` projected. */
37
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"inProjectedContent","stability":"internal","signature":"(node: Node) => boolean"} */
38
+ export declare function inProjectedContent(node: Node): boolean;
27
39
  /** @codexApi {"parent":"pithy.feature.content-projection","name":"mountProjection","stability":"stable","signature":"(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]) => void"} */
28
40
  export declare function mountProjection(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]): void;
29
41
  //# sourceMappingURL=contentProjection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAaD,gMAAgM;AAChM,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,OAAO,CAiET;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA6BrE;AAED,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAqJN"}
1
+ {"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAc9C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CACvB,MAAM,EACN,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,gBAAgB,CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAqBD;;;GAGG;AACH,+KAA+K;AAC/K,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,GAAG,SAAS,GAC3B,OAAO,GAAG,SAAS,CAErB;AAED,uFAAuF;AACvF,sLAAsL;AACtL,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,IAAI,CAGN;AAED,gNAAgN;AAChN,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAiGT;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA+BrE;AAED,6DAA6D;AAC7D,uJAAuJ;AACvJ,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAItD;AAQD,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAGN"}
@@ -5,15 +5,41 @@
5
5
  "category": "feature"
6
6
  }
7
7
  */
8
- import { pithyTreeToDom } from './pithyTreeToDom';
9
- import { pithyGlobals } from '../types/globals';
8
+ import { pithyTreeToDom } from './pithyTreeToDom.js';
9
+ import { bindStructuralDirectives } from './compileTemplate.js';
10
+ import { nodeExpando } from './nodeExpando.js';
11
+ import { bindErrorBoundary, insertBesideHidden, withSlotBoundary, isHiddenByBoundary, } from './binds/bindErrorBoundary.js';
12
+ import { pithyGlobals } from '../types/globals.js';
13
+ import { trimBlankEdges } from './trimBlankEdges.js';
14
+ import { withinRender } from './ssrCrashes.js';
10
15
  function expando(node) {
11
16
  return node;
12
17
  }
13
- /** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>) => SlotMap"} */
14
- export function collectSlotMap(children, parentContext) {
18
+ const outerSlotMaps = new WeakMap();
19
+ function slotMapOf(ctx) {
20
+ return ('__slotMap' in ctx ? ctx.__slotMap : undefined);
21
+ }
22
+ /**
23
+ * The slot map of the template the children behind `slotMap` were written in:
24
+ * what a `<slot>` among those children receives.
25
+ */
26
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"outerSlotMap","stability":"internal","signature":"(slotMap: SlotMap | undefined) => SlotMap | undefined"} */
27
+ export function outerSlotMap(slotMap) {
28
+ return slotMap && outerSlotMaps.get(slotMap);
29
+ }
30
+ /** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */
31
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"linkOuterSlotMap","stability":"internal","signature":"(slotMap: SlotMap, ctx: Record<string, unknown>) => void"} */
32
+ export function linkOuterSlotMap(slotMap, ctx) {
33
+ const outer = slotMapOf(ctx);
34
+ if (outer)
35
+ outerSlotMaps.set(slotMap, outer);
36
+ }
37
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"collectSlotMap","stability":"stable","signature":"(children: PithyNode[], parentContext: Record<string, any>, host?: Element) => SlotMap"} */
38
+ export function collectSlotMap(children, parentContext, host) {
15
39
  const slotMap = new Map();
16
40
  const slotGroups = new Map();
41
+ linkOuterSlotMap(slotMap, parentContext);
42
+ const outer = slotMapOf(parentContext);
17
43
  // Group children by slot attribute
18
44
  for (const child of children) {
19
45
  const slotName = child.directives?.slot || ''; // default slot if no slot attribute
@@ -22,6 +48,14 @@ export function collectSlotMap(children, parentContext) {
22
48
  }
23
49
  slotGroups.get(slotName).push(child);
24
50
  }
51
+ const defaultSlot = slotGroups.get('');
52
+ if (defaultSlot) {
53
+ const content = trimBlankEdges(defaultSlot, node => node.type === 'text' ? (node.textContent ?? '') : null);
54
+ if (content.length)
55
+ slotGroups.set('', content);
56
+ else
57
+ slotGroups.delete('');
58
+ }
25
59
  // Validate slot usage in DEV mode
26
60
  if (import.meta.env?.DEV) {
27
61
  const slotNames = Array.from(slotGroups.keys());
@@ -45,11 +79,24 @@ export function collectSlotMap(children, parentContext) {
45
79
  // Capture nodes and context in closure for stable reference
46
80
  const capturedNodes = nodes;
47
81
  const capturedContext = parentContext;
48
- const render = () => {
82
+ const render = (disposers = [], at) => {
49
83
  if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {
50
84
  console.log(`[PithyJS:Projection] Rendering slot "${slotName}" with ${capturedNodes.length} nodes`);
51
85
  }
52
- return pithyTreeToDom(capturedNodes, capturedContext);
86
+ const fragment = pithyTreeToDom(capturedNodes, capturedContext);
87
+ // As the AOT renderer does: a branch in the content then finds a boundary
88
+ // the receiver wraps its `<slot>` in.
89
+ withSlotBoundary(at, host, () => withinRender(() => {
90
+ bindStructuralDirectives(capturedNodes, fragment, capturedContext, disposers);
91
+ bindErrorBoundary(fragment, capturedContext, disposers);
92
+ return fragment;
93
+ }));
94
+ // A `<slot>` passed through: the receiving component has already looked for its slots.
95
+ const passed = extractSlotDefs(fragment);
96
+ if (passed.length)
97
+ mountProjection(passed, outer ?? new Map(), disposers);
98
+ nodeExpando(fragment).__pithyCtx = capturedContext;
99
+ return fragment;
53
100
  };
54
101
  slotMap.set(slotName, render);
55
102
  }
@@ -71,6 +118,9 @@ export function extractSlotDefs(fragment) {
71
118
  });
72
119
  let node;
73
120
  while ((node = walker.nextNode())) {
121
+ // Inside a component tag, the slot is that component's content to place.
122
+ if (inComponentTag(node))
123
+ continue;
74
124
  const slotName = expando(node).__slotName || '';
75
125
  const fallbackFactory = expando(node).__fallbackFactory;
76
126
  slotDefs.push({
@@ -84,8 +134,26 @@ export function extractSlotDefs(fragment) {
84
134
  }
85
135
  return slotDefs;
86
136
  }
137
+ /** Whether `node` is inside content a `<slot>` projected. */
138
+ /** @codexApi {"parent":"pithy.feature.content-projection","name":"inProjectedContent","stability":"internal","signature":"(node: Node) => boolean"} */
139
+ export function inProjectedContent(node) {
140
+ for (let n = node; n; n = n.parentNode)
141
+ if (expando(n).__projectedContent)
142
+ return true;
143
+ return false;
144
+ }
145
+ function inComponentTag(node) {
146
+ for (let el = node.parentElement; el; el = el.parentElement)
147
+ if (nodeExpando(el).__pithyNode?.isComponent)
148
+ return true;
149
+ return false;
150
+ }
87
151
  /** @codexApi {"parent":"pithy.feature.content-projection","name":"mountProjection","stability":"stable","signature":"(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]) => void"} */
88
152
  export function mountProjection(slotDefs, slotMap, disposers) {
153
+ // A slot's content is rendered and then inserted: one render transaction.
154
+ withinRender(() => mountSlots(slotDefs, slotMap, disposers));
155
+ }
156
+ function mountSlots(slotDefs, slotMap, disposers) {
89
157
  for (const slotDef of slotDefs) {
90
158
  const { name, anchor, fallbackFactory } = slotDef;
91
159
  const renderer = slotMap.get(name);
@@ -96,7 +164,8 @@ export function mountProjection(slotDefs, slotMap, disposers) {
96
164
  // Mark this slot as processed to prevent multiple passes
97
165
  expando(anchor).__projectionProcessed = true;
98
166
  const parent = anchor.parentNode;
99
- if (!parent) {
167
+ // A crash in an earlier slot can have hidden this anchor behind a fallback.
168
+ if (!parent && !isHiddenByBoundary(anchor)) {
100
169
  if (import.meta.env?.DEV) {
101
170
  console.warn(`[ContentProjection] Slot anchor "${name}" has no parent node - skipping`);
102
171
  }
@@ -107,7 +176,7 @@ export function mountProjection(slotDefs, slotMap, disposers) {
107
176
  let isProjectedContent = false;
108
177
  if (renderer) {
109
178
  // Use projected content
110
- contentFragment = renderer();
179
+ contentFragment = renderer(disposers, anchor);
111
180
  isProjectedContent = true;
112
181
  if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {
113
182
  console.log(`[PithyJS:Projection] Mounting projected content for slot "${name}"`);
@@ -116,6 +185,17 @@ export function mountProjection(slotDefs, slotMap, disposers) {
116
185
  else if (fallbackFactory) {
117
186
  // Use fallback content
118
187
  contentFragment = fallbackFactory() ?? null;
188
+ const slotNode = nodeExpando(anchor).__pithyNode;
189
+ if (contentFragment instanceof DocumentFragment &&
190
+ slotNode?.fallbackChildren) {
191
+ const fallbackCtx = nodeExpando(anchor).__pithyCtx ?? {};
192
+ const fallbackFragment = contentFragment;
193
+ const fallbackNodes = slotNode.fallbackChildren;
194
+ withinRender(() => {
195
+ bindStructuralDirectives(fallbackNodes, fallbackFragment, fallbackCtx, disposers);
196
+ bindErrorBoundary(fallbackFragment, fallbackCtx, disposers);
197
+ });
198
+ }
119
199
  if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {
120
200
  console.log(`[PithyJS:Projection] Mounting fallback content for slot "${name}"`);
121
201
  }
@@ -176,7 +256,8 @@ export function mountProjection(slotDefs, slotMap, disposers) {
176
256
  }
177
257
  }
178
258
  // Insert new content after the anchor comment
179
- parent.insertBefore(contentFragment, anchor.nextSibling);
259
+ if (!insertBesideHidden(anchor, contentFragment))
260
+ parent?.insertBefore(contentFragment, anchor.nextSibling);
180
261
  // Track cleanup - remove projected nodes when component unmounts
181
262
  disposers.push(() => {
182
263
  for (const node of nodesToInsert) {
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BhD,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO,IAAgC,CAAC;AAC1C,CAAC;AAED,gMAAgM;AAChM,MAAM,UAAU,cAAc,CAC5B,QAAqB,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CAA0C,IAAI,oCAAoC,CACnF,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QAED,0BAA0B;QAC1B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAEzD,iEAAiE;QACjE,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;gBACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;gBAClE,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,GAAG,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CACT,6CAA6C,aAAa,CAAC,MAAM,oBAAoB,IAAI,GAAG,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,sEAAsE;IACtE,uEAAuE;IACvE,qEAAqE;IACrE,gDAAgD;AAClD,CAAC"}
1
+ {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,cAAc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AA0B;QAC1B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC;YAC9C,MAAM,EAAE,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAE5D,iEAAiE;QACjE,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;gBACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;gBAClE,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,GAAG,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CACT,6CAA6C,aAAa,CAAC,MAAM,oBAAoB,IAAI,GAAG,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,sEAAsE;IACtE,uEAAuE;IACvE,qEAAqE;IACrE,gDAAgD;AAClD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.feature.content-projection\",\n \"title\": \"Content Projection System\",\n \"category\": \"feature\"\n}\n*/\n\nimport { PithyNode } from '@pithyjs/compiler';\nimport { pithyTreeToDom } from './pithyTreeToDom';\nimport { bindStructuralDirectives } from './compileTemplate';\nimport { nodeExpando } from './nodeExpando';\nimport {\n bindErrorBoundary,\n insertBesideHidden,\n withSlotBoundary,\n isHiddenByBoundary,\n} from './binds/bindErrorBoundary';\nimport { pithyGlobals } from '../types/globals';\nimport { trimBlankEdges } from './trimBlankEdges';\nimport { withinRender } from './ssrCrashes';\n\n/**\n * SlotMap contains renderer functions for each slot name.\n * Each entry is a factory that returns a DocumentFragment of the slot's content.\n */\nexport type SlotMap = Map<\n string,\n (disposers?: (() => void)[], anchor?: Node) => DocumentFragment\n>;\n\n/**\n * SlotDef describes a slot anchor and its fallback content\n */\nexport type FallbackFactory = () => HTMLElement | DocumentFragment | undefined;\n\nexport interface SlotDef {\n name: string;\n anchor: Comment;\n fallbackFactory?: FallbackFactory;\n}\n\ninterface ProjectionExpando {\n __slotName?: string;\n __fallbackFactory?: FallbackFactory;\n __projectionProcessed?: boolean;\n __projectedContent?: boolean;\n}\n\nfunction expando(node: Node): ProjectionExpando {\n return node as Node & ProjectionExpando;\n}\n\nconst outerSlotMaps = new WeakMap<SlotMap, SlotMap>();\n\nfunction slotMapOf(ctx: Record<string, unknown>): SlotMap | undefined {\n return ('__slotMap' in ctx ? ctx.__slotMap : undefined) as\n | SlotMap\n | undefined;\n}\n\n/**\n * The slot map of the template the children behind `slotMap` were written in:\n * what a `<slot>` among those children receives.\n */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"outerSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap | undefined) => SlotMap | undefined\"} */\nexport function outerSlotMap(\n slotMap: SlotMap | undefined\n): SlotMap | undefined {\n return slotMap && outerSlotMaps.get(slotMap);\n}\n\n/** Records `ctx`'s slot map as what a `<slot>` among `slotMap`'s children receives. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"linkOuterSlotMap\",\"stability\":\"internal\",\"signature\":\"(slotMap: SlotMap, ctx: Record<string, unknown>) => void\"} */\nexport function linkOuterSlotMap(\n slotMap: SlotMap,\n ctx: Record<string, unknown>\n): void {\n const outer = slotMapOf(ctx);\n if (outer) outerSlotMaps.set(slotMap, outer);\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"collectSlotMap\",\"stability\":\"stable\",\"signature\":\"(children: PithyNode[], parentContext: Record<string, any>, host?: Element) => SlotMap\"} */\nexport function collectSlotMap(\n children: PithyNode[],\n parentContext: Record<string, unknown>,\n host?: Element\n): SlotMap {\n const slotMap: SlotMap = new Map();\n const slotGroups = new Map<string, PithyNode[]>();\n linkOuterSlotMap(slotMap, parentContext);\n const outer = slotMapOf(parentContext);\n\n // Group children by slot attribute\n for (const child of children) {\n const slotName = child.directives?.slot || ''; // default slot if no slot attribute\n\n if (!slotGroups.has(slotName)) {\n slotGroups.set(slotName, []);\n }\n slotGroups.get(slotName)!.push(child);\n }\n const defaultSlot = slotGroups.get('');\n if (defaultSlot) {\n const content = trimBlankEdges(defaultSlot, node =>\n node.type === 'text' ? (node.textContent ?? '') : null\n );\n if (content.length) slotGroups.set('', content);\n else slotGroups.delete('');\n }\n\n // Validate slot usage in DEV mode\n if (import.meta.env?.DEV) {\n const slotNames = Array.from(slotGroups.keys());\n const duplicateSlots = slotNames.filter(\n name => name !== '' && slotGroups.get(name)!.length > 1\n );\n if (duplicateSlots.length > 0) {\n console.warn(\n `[ContentProjection] Multiple content nodes targeting the same slot. This is allowed but may indicate a mistake:`,\n duplicateSlots\n );\n }\n }\n\n // Create renderer functions for each slot group.\n // NOTE: We intentionally do NOT cache or clone DocumentFragments here.\n // Using fragment caching + cloneNode(true) would strip custom JS properties\n // like __pithyCtx that binders rely on to resolve projected content\n // expressions (including interpolation, [class], and [attr] bindings)\n // against the *parent* component's context.\n //\n // This behavior is relied upon by regression tests that exercise projected\n // nodes containing such bindings; changing this to reuse or clone\n // fragments will cause those tests to fail and break content projection.\n // pithyTreeToDom is cheap (just creates DOM nodes), so recreating is fine.\n\n for (const [slotName, nodes] of slotGroups) {\n // Capture nodes and context in closure for stable reference\n const capturedNodes = nodes;\n const capturedContext = parentContext;\n\n const render = (\n disposers: (() => void)[] = [],\n at?: Node\n ): DocumentFragment => {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Rendering slot \"${slotName}\" with ${capturedNodes.length} nodes`\n );\n }\n\n const fragment = pithyTreeToDom(capturedNodes, capturedContext);\n // As the AOT renderer does: a branch in the content then finds a boundary\n // the receiver wraps its `<slot>` in.\n withSlotBoundary(at, host, () =>\n withinRender(() => {\n bindStructuralDirectives(\n capturedNodes,\n fragment,\n capturedContext,\n disposers\n );\n bindErrorBoundary(fragment, capturedContext, disposers);\n return fragment;\n })\n );\n // A `<slot>` passed through: the receiving component has already looked for its slots.\n const passed = extractSlotDefs(fragment);\n if (passed.length) mountProjection(passed, outer ?? new Map(), disposers);\n nodeExpando(fragment).__pithyCtx = capturedContext;\n return fragment;\n };\n\n slotMap.set(slotName, render);\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Collected SlotMap with slots:`,\n Array.from(slotMap.keys())\n );\n }\n return slotMap;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"extractSlotDefs\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment) => SlotDef[]\"} */\nexport function extractSlotDefs(fragment: DocumentFragment): SlotDef[] {\n const slotDefs: SlotDef[] = [];\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_COMMENT, {\n acceptNode: node => {\n const comment = node as Comment;\n return comment.textContent?.startsWith('slot:')\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT;\n },\n });\n\n let node: Comment | null;\n while ((node = walker.nextNode() as Comment | null)) {\n // Inside a component tag, the slot is that component's content to place.\n if (inComponentTag(node)) continue;\n const slotName = expando(node).__slotName || '';\n const fallbackFactory = expando(node).__fallbackFactory;\n\n slotDefs.push({\n name: slotName,\n anchor: node,\n fallbackFactory,\n });\n }\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Extracted ${slotDefs.length} slot definitions`\n );\n }\n return slotDefs;\n}\n\n/** Whether `node` is inside content a `<slot>` projected. */\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"inProjectedContent\",\"stability\":\"internal\",\"signature\":\"(node: Node) => boolean\"} */\nexport function inProjectedContent(node: Node): boolean {\n for (let n: Node | null = node; n; n = n.parentNode)\n if (expando(n).__projectedContent) return true;\n return false;\n}\n\nfunction inComponentTag(node: Node): boolean {\n for (let el = node.parentElement; el; el = el.parentElement)\n if (nodeExpando(el).__pithyNode?.isComponent) return true;\n return false;\n}\n\n/** @codexApi {\"parent\":\"pithy.feature.content-projection\",\"name\":\"mountProjection\",\"stability\":\"stable\",\"signature\":\"(slotDefs: SlotDef[], slotMap: SlotMap, disposers: (() => void)[]) => void\"} */\nexport function mountProjection(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n // A slot's content is rendered and then inserted: one render transaction.\n withinRender(() => mountSlots(slotDefs, slotMap, disposers));\n}\n\nfunction mountSlots(\n slotDefs: SlotDef[],\n slotMap: SlotMap,\n disposers: (() => void)[]\n): void {\n for (const slotDef of slotDefs) {\n const { name, anchor, fallbackFactory } = slotDef;\n const renderer = slotMap.get(name);\n\n // Skip if this slot has already been processed\n if (expando(anchor).__projectionProcessed) {\n continue;\n }\n\n // Mark this slot as processed to prevent multiple passes\n expando(anchor).__projectionProcessed = true;\n\n const parent = anchor.parentNode;\n // A crash in an earlier slot can have hidden this anchor behind a fallback.\n if (!parent && !isHiddenByBoundary(anchor)) {\n if (import.meta.env?.DEV) {\n console.warn(\n `[ContentProjection] Slot anchor \"${name}\" has no parent node - skipping`\n );\n }\n continue;\n }\n\n // Determine which content to render\n let contentFragment: HTMLElement | DocumentFragment | null = null;\n let isProjectedContent = false;\n\n if (renderer) {\n // Use projected content\n contentFragment = renderer(disposers, anchor);\n isProjectedContent = true;\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting projected content for slot \"${name}\"`\n );\n }\n } else if (fallbackFactory) {\n // Use fallback content\n contentFragment = fallbackFactory() ?? null;\n const slotNode = nodeExpando(anchor).__pithyNode;\n if (\n contentFragment instanceof DocumentFragment &&\n slotNode?.fallbackChildren\n ) {\n const fallbackCtx = nodeExpando(anchor).__pithyCtx ?? {};\n const fallbackFragment = contentFragment;\n const fallbackNodes = slotNode.fallbackChildren;\n withinRender(() => {\n bindStructuralDirectives(\n fallbackNodes,\n fallbackFragment,\n fallbackCtx,\n disposers\n );\n bindErrorBoundary(fallbackFragment, fallbackCtx, disposers);\n });\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Mounting fallback content for slot \"${name}\"`\n );\n }\n } else {\n // No content to mount\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] No content for slot \"${name}\"`);\n }\n continue;\n }\n\n // Validate content\n if (!contentFragment || contentFragment.childNodes.length === 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Empty content for slot \"${name}\" - skipping`\n );\n }\n continue;\n }\n\n // CRITICAL: Collect nodes BEFORE inserting into DOM (for cleanup tracking)\n // Once inserted, the fragment's childNodes will be empty\n const nodesToInsert: Node[] = Array.from(contentFragment.childNodes);\n\n // Mark nodes for tracking\n for (const node of nodesToInsert) {\n expando(node).__projectedContent = isProjectedContent;\n expando(node).__slotName = name;\n }\n\n // Find and remove any existing content for this slot\n const existingNodes: Node[] = [];\n let current = anchor.nextSibling;\n\n while (current) {\n // Stop if we hit another slot anchor\n if (\n current.nodeType === Node.COMMENT_NODE &&\n (current as Comment).textContent?.startsWith('slot:')\n ) {\n break;\n }\n\n // A sibling no projection marked is the component's own markup.\n const meta = expando(current);\n if (meta.__projectedContent === undefined || meta.__slotName !== name) {\n break;\n }\n existingNodes.push(current);\n\n current = current.nextSibling;\n }\n\n // Simple diffing: only replace if content appears different\n // Compare node count and types as a basic heuristic\n const shouldReplace =\n existingNodes.length !== nodesToInsert.length ||\n existingNodes.some(\n (node, i) => node.nodeType !== nodesToInsert[i]?.nodeType\n );\n\n if (!shouldReplace && existingNodes.length > 0) {\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Content for slot \"${name}\" unchanged - skipping replacement`\n );\n }\n continue;\n }\n\n // Remove existing content\n for (const node of existingNodes) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n\n // Insert new content after the anchor comment\n if (!insertBesideHidden(anchor, contentFragment))\n parent?.insertBefore(contentFragment, anchor.nextSibling);\n\n // Track cleanup - remove projected nodes when component unmounts\n disposers.push(() => {\n for (const node of nodesToInsert) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(`[PithyJS:Projection] Cleaned up slot \"${name}\"`);\n }\n });\n\n if (import.meta.env?.DEV && pithyGlobals().PITHY_DEBUG_PROJECTION) {\n console.log(\n `[PithyJS:Projection] Successfully mounted ${nodesToInsert.length} nodes for slot \"${name}\"`\n );\n }\n }\n\n // DEV: Validate slot usage\n // NOTE: We intentionally do NOT warn about unmatched projected slots here.\n // When a component uses @if/@else with different <slot> elements in each\n // branch (e.g., Show has <slot> in @if and <slot name=\"fallback\"> in @else),\n // the currently-rendered branch may not include all slot targets. The\n // projected \"fallback\" content is legitimate — it will be mounted when\n // the @else branch activates. Warnings here would be false positives\n // and fire repeatedly on every reactive toggle.\n}\n"]}
@@ -0,0 +1,35 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.runtime.dispose-order",
4
+ "title": "Teardown Order",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ /**
9
+ * Marks `dispose` as tearing down what renders at `node`: a component's first
10
+ * node, or a control-flow block's anchor. `orderByDocument` sorts by it.
11
+ */
12
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"anchorDisposer","stability":"internal","signature":"<T extends () => void>(dispose: T, node: Node | null | undefined) => T"} */
13
+ export declare function anchorDisposer<T extends () => void>(dispose: T, node: Node | null | undefined): T;
14
+ /**
15
+ * Puts the anchored entries of `disposers` in document order, each in a slot
16
+ * an anchored entry held, so running the list backwards destroys later
17
+ * siblings first and children before parents. The binding passes register
18
+ * components and control flow separately, so registration order is not
19
+ * document order. Unanchored entries keep their place.
20
+ */
21
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"orderByDocument","stability":"internal","signature":"(disposers: (() => void)[]) => void"} */
22
+ export declare function orderByDocument(disposers: (() => void)[]): void;
23
+ /**
24
+ * A control-flow block's teardown as one anchored entry: stops its watcher,
25
+ * then clears its content, so a write during the clear cannot re-enter it.
26
+ */
27
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"blockDisposer","stability":"internal","signature":"(stop: () => void, clear: () => void, node: Node | null | undefined) => () => void"} */
28
+ export declare function blockDisposer(stop: () => void, clear: () => void, node: Node | null | undefined): () => void;
29
+ /**
30
+ * A rendered component's teardown as one anchored entry: its `destroy()`,
31
+ * then its setup root, which must not move apart when the list is sorted.
32
+ */
33
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"componentDisposer","stability":"internal","signature":"(destroy: unknown, disposeSetup: (() => void) | undefined, node: Node | null | undefined) => (() => void) | undefined"} */
34
+ export declare function componentDisposer(destroy: unknown, disposeSetup: (() => void) | undefined, node: Node | null | undefined): (() => void) | undefined;
35
+ //# sourceMappingURL=disposeOrder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disposeOrder.d.ts","sourceRoot":"","sources":["../../src/compile/disposeOrder.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;;GAGG;AACH,6LAA6L;AAC7L,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,EACjD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAC5B,CAAC,CAGH;AAED;;;;;;GAMG;AACH,2JAA2J;AAC3J,wBAAgB,eAAe,CAAC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,IAAI,CAiB/D;AAED;;;GAGG;AACH,wMAAwM;AACxM,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,IAAI,EAChB,KAAK,EAAE,MAAM,IAAI,EACjB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAC5B,MAAM,IAAI,CAQZ;AAED;;;GAGG;AACH,+OAA+O;AAC/O,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EACtC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAC5B,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAU1B"}
@@ -0,0 +1,81 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.runtime.dispose-order",
4
+ "title": "Teardown Order",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ const anchors = new WeakMap();
9
+ /**
10
+ * Marks `dispose` as tearing down what renders at `node`: a component's first
11
+ * node, or a control-flow block's anchor. `orderByDocument` sorts by it.
12
+ */
13
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"anchorDisposer","stability":"internal","signature":"<T extends () => void>(dispose: T, node: Node | null | undefined) => T"} */
14
+ export function anchorDisposer(dispose, node) {
15
+ if (node)
16
+ anchors.set(dispose, node);
17
+ return dispose;
18
+ }
19
+ /**
20
+ * Puts the anchored entries of `disposers` in document order, each in a slot
21
+ * an anchored entry held, so running the list backwards destroys later
22
+ * siblings first and children before parents. The binding passes register
23
+ * components and control flow separately, so registration order is not
24
+ * document order. Unanchored entries keep their place.
25
+ */
26
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"orderByDocument","stability":"internal","signature":"(disposers: (() => void)[]) => void"} */
27
+ export function orderByDocument(disposers) {
28
+ const slots = [];
29
+ const entries = [];
30
+ disposers.forEach((dispose, i) => {
31
+ const at = anchors.get(dispose);
32
+ if (!at)
33
+ return;
34
+ slots.push(i);
35
+ entries.push({ dispose, at });
36
+ });
37
+ if (slots.length < 2)
38
+ return;
39
+ entries.sort((a, b) => {
40
+ if (a.at === b.at)
41
+ return 0;
42
+ return a.at.compareDocumentPosition(b.at) & Node.DOCUMENT_POSITION_FOLLOWING
43
+ ? -1
44
+ : 1;
45
+ });
46
+ slots.forEach((slot, k) => (disposers[slot] = entries[k].dispose));
47
+ }
48
+ /**
49
+ * A control-flow block's teardown as one anchored entry: stops its watcher,
50
+ * then clears its content, so a write during the clear cannot re-enter it.
51
+ */
52
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"blockDisposer","stability":"internal","signature":"(stop: () => void, clear: () => void, node: Node | null | undefined) => () => void"} */
53
+ export function blockDisposer(stop, clear, node) {
54
+ return anchorDisposer(() => {
55
+ try {
56
+ stop();
57
+ }
58
+ finally {
59
+ clear();
60
+ }
61
+ }, node);
62
+ }
63
+ /**
64
+ * A rendered component's teardown as one anchored entry: its `destroy()`,
65
+ * then its setup root, which must not move apart when the list is sorted.
66
+ */
67
+ /** @codexApi {"parent":"pithy.runtime.dispose-order","name":"componentDisposer","stability":"internal","signature":"(destroy: unknown, disposeSetup: (() => void) | undefined, node: Node | null | undefined) => (() => void) | undefined"} */
68
+ export function componentDisposer(destroy, disposeSetup, node) {
69
+ const own = typeof destroy === 'function' ? destroy : null;
70
+ if (!own && !disposeSetup)
71
+ return undefined;
72
+ return anchorDisposer(() => {
73
+ try {
74
+ own?.();
75
+ }
76
+ finally {
77
+ disposeSetup?.();
78
+ }
79
+ }, node);
80
+ }
81
+ //# sourceMappingURL=disposeOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disposeOrder.js","sourceRoot":"","sources":["../../src/compile/disposeOrder.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAoB,CAAC;AAEhD;;;GAGG;AACH,6LAA6L;AAC7L,MAAM,UAAU,cAAc,CAC5B,OAAU,EACV,IAA6B;IAE7B,IAAI,IAAI;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,2JAA2J;AAC3J,MAAM,UAAU,eAAe,CAAC,SAAyB;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAwC,EAAE,CAAC;IACxD,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;QAC/B,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE;YAAE,OAAO;QAChB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpB,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,2BAA2B;YAC1E,CAAC,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,wMAAwM;AACxM,MAAM,UAAU,aAAa,CAC3B,IAAgB,EAChB,KAAiB,EACjB,IAA6B;IAE7B,OAAO,cAAc,CAAC,GAAG,EAAE;QACzB,IAAI,CAAC;YACH,IAAI,EAAE,CAAC;QACT,CAAC;gBAAS,CAAC;YACT,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,+OAA+O;AAC/O,MAAM,UAAU,iBAAiB,CAC/B,OAAgB,EAChB,YAAsC,EACtC,IAA6B;IAE7B,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAE,OAAsB,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,IAAI,CAAC,GAAG,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,cAAc,CAAC,GAAG,EAAE;QACzB,IAAI,CAAC;YACH,GAAG,EAAE,EAAE,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,YAAY,EAAE,EAAE,CAAC;QACnB,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.dispose-order\",\n \"title\": \"Teardown Order\",\n \"category\": \"runtime\"\n}\n*/\n\nconst anchors = new WeakMap<() => void, Node>();\n\n/**\n * Marks `dispose` as tearing down what renders at `node`: a component's first\n * node, or a control-flow block's anchor. `orderByDocument` sorts by it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.dispose-order\",\"name\":\"anchorDisposer\",\"stability\":\"internal\",\"signature\":\"<T extends () => void>(dispose: T, node: Node | null | undefined) => T\"} */\nexport function anchorDisposer<T extends () => void>(\n dispose: T,\n node: Node | null | undefined\n): T {\n if (node) anchors.set(dispose, node);\n return dispose;\n}\n\n/**\n * Puts the anchored entries of `disposers` in document order, each in a slot\n * an anchored entry held, so running the list backwards destroys later\n * siblings first and children before parents. The binding passes register\n * components and control flow separately, so registration order is not\n * document order. Unanchored entries keep their place.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.dispose-order\",\"name\":\"orderByDocument\",\"stability\":\"internal\",\"signature\":\"(disposers: (() => void)[]) => void\"} */\nexport function orderByDocument(disposers: (() => void)[]): void {\n const slots: number[] = [];\n const entries: { dispose: () => void; at: Node }[] = [];\n disposers.forEach((dispose, i) => {\n const at = anchors.get(dispose);\n if (!at) return;\n slots.push(i);\n entries.push({ dispose, at });\n });\n if (slots.length < 2) return;\n entries.sort((a, b) => {\n if (a.at === b.at) return 0;\n return a.at.compareDocumentPosition(b.at) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n });\n slots.forEach((slot, k) => (disposers[slot] = entries[k].dispose));\n}\n\n/**\n * A control-flow block's teardown as one anchored entry: stops its watcher,\n * then clears its content, so a write during the clear cannot re-enter it.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.dispose-order\",\"name\":\"blockDisposer\",\"stability\":\"internal\",\"signature\":\"(stop: () => void, clear: () => void, node: Node | null | undefined) => () => void\"} */\nexport function blockDisposer(\n stop: () => void,\n clear: () => void,\n node: Node | null | undefined\n): () => void {\n return anchorDisposer(() => {\n try {\n stop();\n } finally {\n clear();\n }\n }, node);\n}\n\n/**\n * A rendered component's teardown as one anchored entry: its `destroy()`,\n * then its setup root, which must not move apart when the list is sorted.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.dispose-order\",\"name\":\"componentDisposer\",\"stability\":\"internal\",\"signature\":\"(destroy: unknown, disposeSetup: (() => void) | undefined, node: Node | null | undefined) => (() => void) | undefined\"} */\nexport function componentDisposer(\n destroy: unknown,\n disposeSetup: (() => void) | undefined,\n node: Node | null | undefined\n): (() => void) | undefined {\n const own = typeof destroy === 'function' ? (destroy as () => void) : null;\n if (!own && !disposeSetup) return undefined;\n return anchorDisposer(() => {\n try {\n own?.();\n } finally {\n disposeSetup?.();\n }\n }, node);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const textEvalMessage: (expr: string) => string;
2
+ export declare const classesEvalMessage = "[PithyJS] \u26A0\uFE0F Failed to evaluate [classes]:";
3
+ export declare const propEvalMessage: (prop: string, expr: string) => string;
4
+ export declare const invalidRenderMessage: (tag: string) => string;
5
+ /** The error a boundary or an SSR crash record receives. */
6
+ export declare const invalidRenderError: (tag: string) => Error;
7
+ //# sourceMappingURL=evalDiagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evalDiagnostics.d.ts","sourceRoot":"","sources":["../../src/compile/evalDiagnostics.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,WACF,CAAC;AAE3C,eAAO,MAAM,kBAAkB,yDAA+C,CAAC;AAE/E,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,WACI,CAAC;AAE/D,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,WAC6B,CAAC;AAE9E,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,UAC8B,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Shared by the dev and build binders, so both paths word these the same way.
2
+ export const textEvalMessage = (expr) => `[PithyJS] ❌ Error evaluating '${expr}'`;
3
+ export const classesEvalMessage = '[PithyJS] ⚠️ Failed to evaluate [classes]:';
4
+ export const propEvalMessage = (prop, expr) => `[PithyJS] ⚠️ Failed to evaluate prop "${prop}" = "${expr}"`;
5
+ export const invalidRenderMessage = (tag) => `[PithyJS] ❌ Invalid render result from <${tag}>. Expected { el, destroy }`;
6
+ /** The error a boundary or an SSR crash record receives. */
7
+ export const invalidRenderError = (tag) => new Error(`Invalid render result from <${tag}>; expected { el, destroy }`);
8
+ //# sourceMappingURL=evalDiagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evalDiagnostics.js","sourceRoot":"","sources":["../../src/compile/evalDiagnostics.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAC9C,iCAAiC,IAAI,GAAG,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAC5D,yCAAyC,IAAI,QAAQ,IAAI,GAAG,CAAC;AAE/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,EAAE,CAClD,2CAA2C,GAAG,6BAA6B,CAAC;AAE9E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,EAAE,CAChD,IAAI,KAAK,CAAC,+BAA+B,GAAG,6BAA6B,CAAC,CAAC","sourcesContent":["// Shared by the dev and build binders, so both paths word these the same way.\n\nexport const textEvalMessage = (expr: string) =>\n `[PithyJS] ❌ Error evaluating '${expr}'`;\n\nexport const classesEvalMessage = '[PithyJS] ⚠️ Failed to evaluate [classes]:';\n\nexport const propEvalMessage = (prop: string, expr: string) =>\n `[PithyJS] ⚠️ Failed to evaluate prop \"${prop}\" = \"${expr}\"`;\n\nexport const invalidRenderMessage = (tag: string) =>\n `[PithyJS] ❌ Invalid render result from <${tag}>. Expected { el, destroy }`;\n\n/** The error a boundary or an SSR crash record receives. */\nexport const invalidRenderError = (tag: string) =>\n new Error(`Invalid render result from <${tag}>; expected { el, destroy }`);\n"]}
@@ -5,7 +5,7 @@
5
5
  "category": "directive"
6
6
  }
7
7
  */
8
- import type { PithyNode } from '@pithyjs/compiler';
8
+ import { type PithyNode } from '@pithyjs/compiler';
9
9
  /**
10
10
  * Bind all @for loops found under `rootEl` using the parsed AST nodes.
11
11
  *
@@ -16,6 +16,6 @@ import type { PithyNode } from '@pithyjs/compiler';
16
16
  * - trackBy is compiled once per loop node and re-used.
17
17
  * - Each loop gets its own LoopManager which does minimal DOM moves and cleanup on dispose.
18
18
  */
19
- /** @codexApi {"parent":"pithy.directive.for","name":"bindForLoops","stability":"stable","signature":"(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>) => void"} */
20
- export declare function bindForLoops(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>): void;
19
+ /** @codexApi {"parent":"pithy.directive.for","name":"bindForLoops","stability":"stable","signature":"(nodes: PithyNode[], rootEl: Element | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>) => void"} */
20
+ export declare function bindForLoops(nodes: PithyNode[], rootEl: Element | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>): void;
21
21
  //# sourceMappingURL=bindForLoops.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindForLoops.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/bindForLoops.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AASnD;;;;;;;;;GASG;AACH,yQAAyQ;AACzQ,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,WAAW,GAAG,gBAAgB,EACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,EAC9B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,GACxC,IAAI,CAkIN"}
1
+ {"version":3,"file":"bindForLoops.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/bindForLoops.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYxE;;;;;;;;;GASG;AACH,qQAAqQ;AACrQ,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,OAAO,GAAG,gBAAgB,EAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,EAC9B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,GACxC,IAAI,CAwIN"}