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

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 +227 -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 +87 -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 +44 -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.js +12 -6
  132. package/dist/compile/parseHtml.js.map +1 -1
  133. package/dist/compile/pithyTreeToDom.d.ts.map +1 -1
  134. package/dist/compile/pithyTreeToDom.js +17 -12
  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,9 +1,12 @@
1
1
  import { createRoot, effect } from '@pithyjs/signals';
2
- import { compileExpression } from '../../compile/compileExpression';
3
- import { isSSRMode } from '../../compile/ssrMode';
4
- import { createLoopManager } from '../../compile/forLoops/createLoopManager';
5
- import { compileTrackBy } from '../../compile/forLoops/loopHelpers';
6
- import { createLoopContext, createLoopSignals, } from '../../compile/forLoops/loopSignals';
2
+ import { compileExpression } from '../../compile/compileExpression.js';
3
+ import { isSSRMode } from '../../compile/ssrMode.js';
4
+ import { createLoopManager } from '../../compile/forLoops/createLoopManager.js';
5
+ import { compileTrackBy } from '../../compile/forLoops/loopHelpers.js';
6
+ import { anchorDisposer, blockDisposer } from '../../compile/disposeOrder.js';
7
+ import { withBranchBoundary } from '../../compile/binds/bindErrorBoundary.js';
8
+ import { withinRender } from '../../compile/ssrCrashes.js';
9
+ import { createLoopContext, createLoopSignals, } from '../../compile/forLoops/loopSignals.js';
7
10
  // ─── Structural directive handlers ────────────────────────────────────────────
8
11
  export function applyIf(d, commentMap, ctx, disposers) {
9
12
  const anchor = commentMap.get(`if:${d.pid}`);
@@ -12,9 +15,9 @@ export function applyIf(d, commentMap, ctx, disposers) {
12
15
  let currentNodes = [];
13
16
  let currentDisposers = [];
14
17
  function clearCurrent() {
15
- for (const fn of currentDisposers) {
18
+ for (let i = currentDisposers.length - 1; i >= 0; i--) {
16
19
  try {
17
- fn();
20
+ currentDisposers[i]();
18
21
  }
19
22
  catch {
20
23
  /* ignore */
@@ -42,28 +45,30 @@ export function applyIf(d, commentMap, ctx, disposers) {
42
45
  break;
43
46
  }
44
47
  }
45
- if (matchIndex >= 0) {
46
- try {
47
- const result = d.branches[matchIndex].factory(ctx);
48
- if (result?.el) {
49
- const nodes = result.el instanceof DocumentFragment
50
- ? Array.from(result.el.childNodes)
51
- : [result.el];
52
- const parent = anchor.parentNode;
53
- if (parent) {
54
- const insertRef = anchor.nextSibling;
55
- for (const node of nodes)
56
- parent.insertBefore(node, insertRef);
48
+ if (matchIndex >= 0)
49
+ withinRender(() => {
50
+ try {
51
+ const { factory } = d.branches[matchIndex];
52
+ const result = withBranchBoundary(anchor, () => factory(ctx));
53
+ if (result?.el) {
54
+ const nodes = result.el instanceof DocumentFragment
55
+ ? Array.from(result.el.childNodes)
56
+ : [result.el];
57
+ const parent = anchor.parentNode;
58
+ if (parent) {
59
+ const insertRef = anchor.nextSibling;
60
+ for (const node of nodes)
61
+ parent.insertBefore(node, insertRef);
62
+ }
63
+ if (typeof result.destroy === 'function')
64
+ disposers.push(anchorDisposer(result.destroy, anchor));
57
65
  }
58
- if (typeof result.destroy === 'function')
59
- disposers.push(result.destroy);
60
66
  }
61
- }
62
- catch (err) {
63
- if (import.meta.env?.DEV)
64
- console.error(`[AOT @if] Factory error:`, err);
65
- }
66
- }
67
+ catch (err) {
68
+ if (import.meta.env?.DEV)
69
+ console.error(`[AOT @if] Factory error:`, err);
70
+ }
71
+ });
67
72
  return;
68
73
  }
69
74
  // Pre-compile branch expressions once outside effect
@@ -85,38 +90,38 @@ export function applyIf(d, commentMap, ctx, disposers) {
85
90
  return;
86
91
  previousMatchIndex = matchIndex;
87
92
  clearCurrent();
88
- if (matchIndex >= 0) {
89
- try {
90
- const { factory } = d.branches[matchIndex];
91
- const result = createRoot(disposeRoot => {
92
- currentDisposers.push(disposeRoot);
93
- return factory(ctx);
94
- });
95
- if (result?.el) {
96
- const nodes = result.el instanceof DocumentFragment
97
- ? Array.from(result.el.childNodes)
98
- : [result.el];
99
- const parent = anchor.parentNode;
100
- if (parent) {
101
- const insertRef = anchor.nextSibling;
102
- for (const node of nodes)
103
- parent.insertBefore(node, insertRef);
93
+ if (matchIndex >= 0)
94
+ withinRender(() => {
95
+ try {
96
+ const { factory } = d.branches[matchIndex];
97
+ const result = createRoot(disposeRoot => {
98
+ currentDisposers.push(disposeRoot);
99
+ return withBranchBoundary(anchor, () => factory(ctx));
100
+ });
101
+ if (result?.el) {
102
+ const nodes = result.el instanceof DocumentFragment
103
+ ? Array.from(result.el.childNodes)
104
+ : [result.el];
105
+ const parent = anchor.parentNode;
106
+ if (parent) {
107
+ const insertRef = anchor.nextSibling;
108
+ for (const node of nodes)
109
+ parent.insertBefore(node, insertRef);
110
+ }
111
+ currentNodes = nodes;
112
+ if (typeof result.destroy === 'function')
113
+ currentDisposers.push(result.destroy);
114
+ else if (import.meta.env?.DEV)
115
+ console.warn('[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
104
116
  }
105
- currentNodes = nodes;
106
- if (typeof result.destroy === 'function')
107
- currentDisposers.push(result.destroy);
108
- else if (import.meta.env?.DEV)
109
- console.warn('[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
110
117
  }
111
- }
112
- catch (err) {
113
- if (import.meta.env?.DEV)
114
- console.error(`[AOT @if] Factory error:`, err);
115
- }
116
- }
118
+ catch (err) {
119
+ if (import.meta.env?.DEV)
120
+ console.error(`[AOT @if] Factory error:`, err);
121
+ }
122
+ });
117
123
  });
118
- disposers.push(clearCurrent);
119
- disposers.push(stopEffect);
124
+ disposers.push(blockDisposer(stopEffect, clearCurrent, anchor));
120
125
  }
121
126
  export function applyFor(d, commentMap, ctx, disposers) {
122
127
  const anchor = commentMap.get(`for:${d.pid}`);
@@ -129,25 +134,27 @@ export function applyFor(d, commentMap, ctx, disposers) {
129
134
  if (!parent)
130
135
  return;
131
136
  const insertBefore = anchor.nextSibling;
132
- for (let i = 0; i < collection.length; i++) {
133
- const itemCtx = buildItemContext(ctx, d, collection[i], i, collection.length);
134
- try {
135
- const result = d.factory(itemCtx);
136
- if (result?.el) {
137
- const nodes = result.el instanceof DocumentFragment
138
- ? Array.from(result.el.childNodes)
139
- : [result.el];
140
- for (const node of nodes)
141
- parent.insertBefore(node, insertBefore);
142
- if (typeof result.destroy === 'function')
143
- disposers.push(result.destroy);
137
+ withinRender(() => withBranchBoundary(anchor, () => {
138
+ for (let i = 0; i < collection.length; i++) {
139
+ const itemCtx = buildItemContext(ctx, d, collection[i], i, collection.length);
140
+ try {
141
+ const result = d.factory(itemCtx);
142
+ if (result?.el) {
143
+ const nodes = result.el instanceof DocumentFragment
144
+ ? Array.from(result.el.childNodes)
145
+ : [result.el];
146
+ for (const node of nodes)
147
+ parent.insertBefore(node, insertBefore);
148
+ if (typeof result.destroy === 'function')
149
+ disposers.push(anchorDisposer(result.destroy, nodes[0] ?? anchor));
150
+ }
151
+ }
152
+ catch (err) {
153
+ if (import.meta.env?.DEV)
154
+ console.error(`[AOT @for] Factory error at index ${i}:`, err);
144
155
  }
145
156
  }
146
- catch (err) {
147
- if (import.meta.env?.DEV)
148
- console.error(`[AOT @for] Factory error at index ${i}:`, err);
149
- }
150
- }
157
+ }));
151
158
  return;
152
159
  }
153
160
  const collFn = compileExpression(d.expr, ctx, []);
@@ -178,8 +185,7 @@ export function applyFor(d, commentMap, ctx, disposers) {
178
185
  loopManager.update([]);
179
186
  }
180
187
  });
181
- disposers.push(() => loopManager.destroyAll());
182
- disposers.push(stopEffect);
188
+ disposers.push(blockDisposer(stopEffect, () => loopManager.destroyAll(), anchor));
183
189
  }
184
190
  function buildItemContext(parentCtx, d, item, index, length) {
185
191
  return createLoopContext(parentCtx, createLoopSignals(item, index, length), d.item, d.index);
@@ -191,9 +197,9 @@ export function applySwitch(d, pidMap, ctx, disposers) {
191
197
  let currentNodes = [];
192
198
  let currentDisposers = [];
193
199
  function clearCurrent() {
194
- for (const fn of currentDisposers) {
200
+ for (let i = currentDisposers.length - 1; i >= 0; i--) {
195
201
  try {
196
- fn();
202
+ currentDisposers[i]();
197
203
  }
198
204
  catch {
199
205
  /* ignore */
@@ -209,11 +215,13 @@ export function applySwitch(d, pidMap, ctx, disposers) {
209
215
  if (isSSRMode()) {
210
216
  const switchVal = compileExpression(d.expr, ctx)();
211
217
  let matchIndex = -1;
218
+ let defaultIndex = -1;
212
219
  for (let i = 0; i < d.cases.length; i++) {
213
220
  const c = d.cases[i];
214
221
  if (c.val === undefined) {
215
- matchIndex = i;
216
- break;
222
+ if (defaultIndex === -1)
223
+ defaultIndex = i;
224
+ continue;
217
225
  }
218
226
  const caseVal = compileExpression(c.val, ctx)();
219
227
  if (caseVal === switchVal) {
@@ -221,24 +229,28 @@ export function applySwitch(d, pidMap, ctx, disposers) {
221
229
  break;
222
230
  }
223
231
  }
224
- if (matchIndex >= 0) {
225
- try {
226
- const result = d.cases[matchIndex].factory(ctx);
227
- if (result?.el) {
228
- const nodes = result.el instanceof DocumentFragment
229
- ? Array.from(result.el.childNodes)
230
- : [result.el];
231
- for (const node of nodes)
232
- containerEl.appendChild(node);
233
- if (typeof result.destroy === 'function')
234
- disposers.push(result.destroy);
232
+ if (matchIndex === -1)
233
+ matchIndex = defaultIndex;
234
+ if (matchIndex >= 0)
235
+ withinRender(() => {
236
+ try {
237
+ const { factory } = d.cases[matchIndex];
238
+ const result = withBranchBoundary(containerEl, () => factory(ctx), true);
239
+ if (result?.el) {
240
+ const nodes = result.el instanceof DocumentFragment
241
+ ? Array.from(result.el.childNodes)
242
+ : [result.el];
243
+ for (const node of nodes)
244
+ containerEl.appendChild(node);
245
+ if (typeof result.destroy === 'function')
246
+ disposers.push(anchorDisposer(result.destroy, containerEl));
247
+ }
235
248
  }
236
- }
237
- catch (err) {
238
- if (import.meta.env?.DEV)
239
- console.error(`[AOT @switch] Factory error:`, err);
240
- }
241
- }
249
+ catch (err) {
250
+ if (import.meta.env?.DEV)
251
+ console.error(`[AOT @switch] Factory error:`, err);
252
+ }
253
+ });
242
254
  return;
243
255
  }
244
256
  // Pre-compile switch expression and case values once outside effect
@@ -248,47 +260,51 @@ export function applySwitch(d, pidMap, ctx, disposers) {
248
260
  const stopEffect = effect(() => {
249
261
  const switchVal = switchEval();
250
262
  let matchIndex = -1;
263
+ let defaultIndex = -1;
251
264
  for (let i = 0; i < d.cases.length; i++) {
252
265
  if (caseEvals[i] === null) {
253
- matchIndex = i;
254
- break;
266
+ if (defaultIndex === -1)
267
+ defaultIndex = i;
268
+ continue;
255
269
  }
256
270
  if (caseEvals[i]() === switchVal) {
257
271
  matchIndex = i;
258
272
  break;
259
273
  }
260
274
  }
275
+ if (matchIndex === -1)
276
+ matchIndex = defaultIndex;
261
277
  if (matchIndex === previousMatchIndex)
262
278
  return;
263
279
  previousMatchIndex = matchIndex;
264
280
  clearCurrent();
265
- if (matchIndex >= 0) {
266
- try {
267
- const { factory } = d.cases[matchIndex];
268
- const result = createRoot(disposeRoot => {
269
- currentDisposers.push(disposeRoot);
270
- return factory(ctx);
271
- });
272
- if (result?.el) {
273
- const nodes = result.el instanceof DocumentFragment
274
- ? Array.from(result.el.childNodes)
275
- : [result.el];
276
- for (const node of nodes)
277
- containerEl.appendChild(node);
278
- currentNodes = nodes;
279
- if (typeof result.destroy === 'function')
280
- currentDisposers.push(result.destroy);
281
- else if (import.meta.env?.DEV)
282
- console.warn('[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
281
+ if (matchIndex >= 0)
282
+ withinRender(() => {
283
+ try {
284
+ const { factory } = d.cases[matchIndex];
285
+ const result = createRoot(disposeRoot => {
286
+ currentDisposers.push(disposeRoot);
287
+ return withBranchBoundary(containerEl, () => factory(ctx), true);
288
+ });
289
+ if (result?.el) {
290
+ const nodes = result.el instanceof DocumentFragment
291
+ ? Array.from(result.el.childNodes)
292
+ : [result.el];
293
+ for (const node of nodes)
294
+ containerEl.appendChild(node);
295
+ currentNodes = nodes;
296
+ if (typeof result.destroy === 'function')
297
+ currentDisposers.push(result.destroy);
298
+ else if (import.meta.env?.DEV)
299
+ console.warn('[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
300
+ }
283
301
  }
284
- }
285
- catch (err) {
286
- if (import.meta.env?.DEV)
287
- console.error(`[AOT @switch] Factory error:`, err);
288
- }
289
- }
302
+ catch (err) {
303
+ if (import.meta.env?.DEV)
304
+ console.error(`[AOT @switch] Factory error:`, err);
305
+ }
306
+ });
290
307
  });
291
- disposers.push(clearCurrent);
292
- disposers.push(stopEffect);
308
+ disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));
293
309
  }
294
310
  //# sourceMappingURL=applyStructural.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"applyStructural.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAA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,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { createRoot, effect } from '@pithyjs/signals';\nimport { compileExpression } from '../../compile/compileExpression';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { createLoopManager } from '../../compile/forLoops/createLoopManager';\nimport { compileTrackBy } from '../../compile/forLoops/loopHelpers';\nimport { anchorDisposer, blockDisposer } from '../../compile/disposeOrder';\nimport { withBranchBoundary } from '../../compile/binds/bindErrorBoundary';\nimport { withinRender } from '../../compile/ssrCrashes';\nimport {\n createLoopContext,\n createLoopSignals,\n} from '../../compile/forLoops/loopSignals';\nimport type { IfDesc, ForDesc, SwitchDesc, BindingContext } from './types';\n\n// ─── Structural directive handlers ────────────────────────────────────────────\n\nexport function applyIf(\n d: IfDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`if:${d.pid}`);\n if (!anchor) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n // SSR: evaluate once synchronously\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n const b = d.branches[i];\n if (b.expr === undefined) {\n matchIndex = i;\n break;\n }\n const fn = compileExpression(b.expr, ctx, false);\n if (fn()) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.branches[matchIndex];\n const result = withBranchBoundary(anchor, () => factory(ctx));\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, anchor));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n });\n return;\n }\n\n // Pre-compile branch expressions once outside effect\n const branchEvaluators = d.branches.map(b =>\n b.expr !== undefined ? compileExpression(b.expr, ctx, false) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n if (branchEvaluators[i] === null) {\n matchIndex = i;\n break;\n }\n if (branchEvaluators[i]!()) {\n matchIndex = i;\n break;\n }\n }\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.branches[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return withBranchBoundary(anchor, () => factory(ctx));\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n });\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, anchor));\n}\n\nexport function applyFor(\n d: ForDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`for:${d.pid}`);\n if (!anchor) return;\n\n if (isSSRMode()) {\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const collection = collFn() ?? [];\n const parent = anchor.parentNode;\n if (!parent) return;\n\n const insertBefore: Node | null = anchor.nextSibling;\n withinRender(() =>\n withBranchBoundary(anchor, () => {\n for (let i = 0; i < collection.length; i++) {\n const itemCtx = buildItemContext(\n ctx,\n d,\n collection[i],\n i,\n collection.length\n );\n try {\n const result = d.factory(itemCtx);\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) parent.insertBefore(node, insertBefore);\n if (typeof result.destroy === 'function')\n disposers.push(\n anchorDisposer(result.destroy, nodes[0] ?? anchor)\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @for] Factory error at index ${i}:`, err);\n }\n }\n })\n );\n return;\n }\n\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const loopManager = createLoopManager({\n anchor,\n trackByFn: compileTrackBy(d.trackBy, d.item, d.index, ctx),\n parentCtx: ctx,\n itemVar: d.item,\n indexVar: d.index,\n itemFactory: itemCtx => {\n const result = d.factory(itemCtx);\n const el = document.createDocumentFragment();\n if (result?.el) el.append(result.el);\n return { el, destroy: result?.destroy ?? (() => {}) };\n },\n });\n\n const stopEffect = effect(() => {\n try {\n const collection = collFn();\n if (!Array.isArray(collection) && import.meta.env?.DEV)\n console.warn('[AOT @for] collection is not an array:', collection);\n loopManager.update(Array.isArray(collection) ? collection : []);\n } catch (err) {\n if (import.meta.env?.DEV) console.error('[AOT @for] update failed:', err);\n loopManager.update([]);\n }\n });\n\n disposers.push(\n blockDisposer(stopEffect, () => loopManager.destroyAll(), anchor)\n );\n}\n\nfunction buildItemContext(\n parentCtx: BindingContext,\n d: ForDesc,\n item: unknown,\n index: number,\n length: number\n): BindingContext {\n return createLoopContext(\n parentCtx,\n createLoopSignals(item, index, length),\n d.item,\n d.index\n );\n}\n\nexport function applySwitch(\n d: SwitchDesc,\n pidMap: Map<string, Element>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const containerEl = pidMap.get(d.pid);\n if (!containerEl) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n const switchVal = compileExpression(d.expr, ctx)();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n const c = d.cases[i];\n if (c.val === undefined) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n const caseVal = compileExpression(c.val, ctx)();\n if (caseVal === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.cases[matchIndex];\n const result = withBranchBoundary(\n containerEl,\n () => factory(ctx),\n true\n );\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, containerEl));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n });\n return;\n }\n\n // Pre-compile switch expression and case values once outside effect\n const switchEval = compileExpression(d.expr, ctx);\n const caseEvals = d.cases.map(c =>\n c.val !== undefined ? compileExpression(c.val, ctx) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n const switchVal = switchEval();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n if (caseEvals[i] === null) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n if (caseEvals[i]!() === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.cases[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return withBranchBoundary(containerEl, () => factory(ctx), true);\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n });\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));\n}\n"]}
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @module runtime/bindings/helpers
15
15
  */
16
- import type { BindingContext } from './types';
16
+ import type { BindingContext } from './types.js';
17
17
  /**
18
18
  * Build a map of pid → Element from data-pid attributes in the fragment.
19
19
  * @param fragment - The DOM fragment to scan
@@ -37,6 +37,13 @@ export declare function buildCommentMap(fragment: DocumentFragment): Map<string,
37
37
  */
38
38
  /** @codexApi {"parent":"pithy.runtime.binding-helpers","name":"nearestCtx","stability":"internal","signature":"(el: Node, rootCtx: BindingContext) => BindingContext"} */
39
39
  export declare function nearestCtx(el: Node, rootCtx: BindingContext): BindingContext;
40
+ /**
41
+ * `{ ...a, ...b }` that copies a getter as a getter: a spread reads it once
42
+ * and stores the value, so the template would never see it change. Every
43
+ * read goes through the source, so `this` and a Proxy's `get` trap apply.
44
+ */
45
+ /** @codexApi {"parent":"pithy.runtime.binding-helpers","name":"spreadLive","stability":"internal","signature":"(...sources: (BindingContext | undefined)[]) => BindingContext"} */
46
+ export declare function spreadLive(...sources: (BindingContext | undefined)[]): BindingContext;
40
47
  /**
41
48
  * Merge parent component and async (SSR) contexts into the explicit context.
42
49
  * Single source of truth used by both `html.ts` and `applyBindings.ts`.
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;GAIG;AACH,0KAA0K;AAC1K,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAS5E;AAED;;;;GAIG;AACH,8KAA8K;AAC9K,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,GACzB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAatB;AAED;;;;;;GAMG;AACH,0KAA0K;AAC1K,wBAAgB,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,CAe5E;AAED;;;;;GAKG;AACH,mKAAmK;AACnK,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAyBrE;AAED;;;;;GAKG;AACH,qMAAqM;AACrM,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,cAAc,GAClB,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,KAAK,OAAO,CAgBrC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;GAIG;AACH,0KAA0K;AAC1K,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAS5E;AAED;;;;GAIG;AACH,8KAA8K;AAC9K,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,GACzB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAatB;AAED;;;;;;GAMG;AACH,0KAA0K;AAC1K,wBAAgB,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,CAe5E;AAED;;;;GAIG;AACH,mLAAmL;AACnL,wBAAgB,UAAU,CACxB,GAAG,OAAO,EAAE,CAAC,cAAc,GAAG,SAAS,CAAC,EAAE,GACzC,cAAc,CA2BhB;AAED;;;;;GAKG;AACH,mKAAmK;AACnK,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CA0BrE;AAED;;;;;GAKG;AACH,qMAAqM;AACrM,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,cAAc,GAClB,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,KAAK,OAAO,CAgBrC"}
@@ -5,7 +5,7 @@
5
5
  "category": "runtime"
6
6
  }
7
7
  */
8
- import { pithyGlobals } from '../../types/globals';
8
+ import { pithyGlobals } from '../../types/globals.js';
9
9
  // ─── Helpers ──────────────────────────────────────────────────────────────────
10
10
  /**
11
11
  * Build a map of pid → Element from data-pid attributes in the fragment.
@@ -69,6 +69,38 @@ export function nearestCtx(el, rootCtx) {
69
69
  }
70
70
  return rootCtx;
71
71
  }
72
+ /**
73
+ * `{ ...a, ...b }` that copies a getter as a getter: a spread reads it once
74
+ * and stores the value, so the template would never see it change. Every
75
+ * read goes through the source, so `this` and a Proxy's `get` trap apply.
76
+ */
77
+ /** @codexApi {"parent":"pithy.runtime.binding-helpers","name":"spreadLive","stability":"internal","signature":"(...sources: (BindingContext | undefined)[]) => BindingContext"} */
78
+ export function spreadLive(...sources) {
79
+ const out = {};
80
+ for (const source of sources) {
81
+ if (!source)
82
+ continue;
83
+ for (const key of Reflect.ownKeys(source)) {
84
+ const desc = Object.getOwnPropertyDescriptor(source, key);
85
+ if (!desc?.enumerable)
86
+ continue;
87
+ Object.defineProperty(out, key, 'value' in desc
88
+ ? {
89
+ value: Reflect.get(source, key),
90
+ writable: true,
91
+ enumerable: true,
92
+ configurable: true,
93
+ }
94
+ : {
95
+ get: () => Reflect.get(source, key),
96
+ set: desc.set && ((v) => Reflect.set(source, key, v)),
97
+ enumerable: true,
98
+ configurable: true,
99
+ });
100
+ }
101
+ }
102
+ return out;
103
+ }
72
104
  /**
73
105
  * Merge parent component and async (SSR) contexts into the explicit context.
74
106
  * Single source of truth used by both `html.ts` and `applyBindings.ts`.
@@ -85,6 +117,8 @@ export function mergeContexts(context) {
85
117
  if (parentComponentContext && typeof parentComponentContext === 'object') {
86
118
  parentData = {};
87
119
  for (const key of Object.keys(parentComponentContext)) {
120
+ if (key === '__pithyRowLocals')
121
+ continue;
88
122
  if (key.startsWith('__') ||
89
123
  typeof parentComponentContext[key] === 'function') {
90
124
  parentData[key] = parentComponentContext[key];
@@ -94,7 +128,7 @@ export function mergeContexts(context) {
94
128
  parentData = undefined;
95
129
  }
96
130
  if (asyncContext || parentData) {
97
- return { ...(parentData || {}), ...(asyncContext || {}), ...context };
131
+ return spreadLive(parentData, asyncContext, context);
98
132
  }
99
133
  return context;
100
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/runtime/bindings/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAYF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,iFAAiF;AAEjF;;;;GAIG;AACH,0KAA0K;AAC1K,MAAM,UAAU,WAAW,CAAC,QAA0B;IACpD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAmB,CAAC;IACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAC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,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.binding-helpers\",\n \"title\": \"AOT Binding Helpers\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Shared helper utilities for AOT binding application.\n *\n * Provides DOM lookup maps, context merging, and expression compilation\n * used by both the JIT path (`html.ts`) and the AOT path (`applyBindings.ts`).\n *\n * @module runtime/bindings/helpers\n */\n\nimport type { BindingContext } from './types';\nimport { pithyGlobals } from '../../types/globals';\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Build a map of pid → Element from data-pid attributes in the fragment.\n * @param fragment - The DOM fragment to scan\n * @returns Map from pid string to the corresponding Element\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"buildPidMap\",\"stability\":\"internal\",\"signature\":\"(fragment: DocumentFragment) => Map<string, Element>\"} */\nexport function buildPidMap(fragment: DocumentFragment): Map<string, Element> {\n const map = new Map<string, Element>();\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT);\n let node: Element | null;\n while ((node = walker.nextNode() as Element | null)) {\n const pid = node.getAttribute('data-pid');\n if (pid) map.set(pid, node);\n }\n return map;\n}\n\n/**\n * Build a map of comment anchor id → Comment for structural directives.\n * @param fragment - The DOM fragment to scan\n * @returns Map from comment text (e.g. \"if:r0\") to the Comment node\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"buildCommentMap\",\"stability\":\"internal\",\"signature\":\"(fragment: DocumentFragment) => Map<string, Comment>\"} */\nexport function buildCommentMap(\n fragment: DocumentFragment\n): Map<string, Comment> {\n const map = new Map<string, Comment>();\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_COMMENT);\n let node: Comment | null;\n while ((node = walker.nextNode() as Comment | null)) {\n const text = node.textContent ?? '';\n // Structural anchors: \"if:pid\", \"for:pid\", \"slot:name\"\n const colonIdx = text.indexOf(':');\n if (colonIdx > 0) {\n map.set(text, node);\n }\n }\n return map;\n}\n\n/**\n * Walk up the DOM to find the nearest local PithyJS context.\n * Falls back to the provided root context.\n * @param el - Starting DOM node\n * @param rootCtx - Fallback context if no local context is found\n * @returns The nearest context object\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"nearestCtx\",\"stability\":\"internal\",\"signature\":\"(el: Node, rootCtx: BindingContext) => BindingContext\"} */\nexport function nearestCtx(el: Node, rootCtx: BindingContext): BindingContext {\n // Walk parentNode (not parentElement) so context is found on Text/Comment\n // nodes — needed when JIT-projected content is slotted into AOT components.\n // NOTE: In @for loops, only Element nodes receive loop-item __pithyCtx\n // (see applyStructural.ts / createLoopManager.ts). Text nodes inside loop\n // items inherit context from their parent Element, which works correctly\n // because AOT text nodes don't have __pithyCtx set (factories use raw\n // createTextNode), and JIT text nodes are children of tagged Elements.\n let n: Node | null = el;\n while (n) {\n const local = (n as Node & { __pithyCtx?: BindingContext }).__pithyCtx;\n if (local) return local;\n n = n.parentNode;\n }\n return rootCtx;\n}\n\n/**\n * `{ ...a, ...b }` that copies a getter as a getter: a spread reads it once\n * and stores the value, so the template would never see it change. Every\n * read goes through the source, so `this` and a Proxy's `get` trap apply.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"spreadLive\",\"stability\":\"internal\",\"signature\":\"(...sources: (BindingContext | undefined)[]) => BindingContext\"} */\nexport function spreadLive(\n ...sources: (BindingContext | undefined)[]\n): BindingContext {\n const out: BindingContext = {};\n for (const source of sources) {\n if (!source) continue;\n for (const key of Reflect.ownKeys(source)) {\n const desc = Object.getOwnPropertyDescriptor(source, key);\n if (!desc?.enumerable) continue;\n Object.defineProperty(\n out,\n key,\n 'value' in desc\n ? {\n value: Reflect.get(source, key),\n writable: true,\n enumerable: true,\n configurable: true,\n }\n : {\n get: () => Reflect.get(source, key),\n set: desc.set && ((v: unknown) => Reflect.set(source, key, v)),\n enumerable: true,\n configurable: true,\n }\n );\n }\n }\n return out;\n}\n\n/**\n * Merge parent component and async (SSR) contexts into the explicit context.\n * Single source of truth used by both `html.ts` and `applyBindings.ts`.\n * @param context - The explicit context from the call site\n * @returns Merged context with parent component and async contexts\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"mergeContexts\",\"stability\":\"internal\",\"signature\":\"(context: BindingContext) => BindingContext\"} */\nexport function mergeContexts(context: BindingContext): BindingContext {\n const g = pithyGlobals();\n const getContextFn = g.__getComponentContext;\n const asyncContext =\n typeof getContextFn === 'function' ? getContextFn() : undefined;\n const parentComponentContext = g.__pithyComponentContext;\n\n let parentData: BindingContext | undefined;\n if (parentComponentContext && typeof parentComponentContext === 'object') {\n parentData = {};\n for (const key of Object.keys(parentComponentContext)) {\n if (key === '__pithyRowLocals') continue;\n if (\n key.startsWith('__') ||\n typeof parentComponentContext[key] === 'function'\n ) {\n parentData[key] = parentComponentContext[key];\n }\n }\n if (Object.keys(parentData).length === 0) parentData = undefined;\n }\n\n if (asyncContext || parentData) {\n return spreadLive(parentData, asyncContext, context);\n }\n return context;\n}\n\n/**\n * Compile expression with $event and $el support for event handlers.\n * @param expr - The expression string to compile\n * @param ctx - The reactive context for variable resolution\n * @returns A function that accepts (event, element) and evaluates the expression\n */\n/** @codexApi {\"parent\":\"pithy.runtime.binding-helpers\",\"name\":\"compileWithEvent\",\"stability\":\"internal\",\"signature\":\"(expr: string, ctx: BindingContext) => (ev: Event, el: Element) => unknown\"} */\nexport function compileWithEvent(\n expr: string,\n ctx: BindingContext\n): (ev: Event, el: Element) => unknown {\n try {\n // eslint-disable-next-line no-new-func -- JIT event-handler expression evaluation is a core framework feature\n const fn = new Function(\n 'ctx',\n '$event',\n '$el',\n `with (ctx) { return (${expr}); }`\n ) as (ctx: BindingContext, ev: Event, el: Element) => unknown;\n return (ev: Event, el: Element) => fn(ctx, ev, el);\n } catch (err) {\n if (import.meta.env?.DEV) {\n console.warn(`[AOT bindEvent] Failed to compile \"${expr}\"`, err);\n }\n return (_ev: Event, _el: Element) => undefined;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- export type { EventDesc, InterpDesc, ClassDesc, ClassesDesc, StyleDesc, BoundDesc, RefDesc, BindDesc, CompDesc, DeferDesc, ErrorDesc, ProjDesc, IfDesc, ForDesc, SwitchDesc, Desc, } from './types';
2
- export { buildPidMap, buildCommentMap, mergeContexts } from './helpers';
3
- export { applyRef, applyError, applyProjection, applyBind, applyInterpolation, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple';
4
- export { applyComponent } from './applyComponent';
5
- export { applyIf, applyFor, applySwitch } from './applyStructural';
6
- export { applyDefer } from './applyDefer';
1
+ export type { EventDesc, InterpDesc, ClassDesc, ClassesDesc, StyleDesc, BoundDesc, RefDesc, BindDesc, CompDesc, DeferDesc, ErrorDesc, ProjDesc, IfDesc, ForDesc, SwitchDesc, Desc, } from './types.js';
2
+ export { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, } from './helpers.js';
3
+ export { applyRef, applyError, markBoundary, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
4
+ export { applyComponent } from './applyComponent.js';
5
+ export { applyIf, applyFor, applySwitch } from './applyStructural.js';
6
+ export { applyDefer } from './applyDefer.js';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,EACV,IAAI,GACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,EACV,IAAI,GACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
- export { buildPidMap, buildCommentMap, mergeContexts } from './helpers';
2
- export { applyRef, applyError, applyProjection, applyBind, applyInterpolation, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple';
3
- export { applyComponent } from './applyComponent';
4
- export { applyIf, applyFor, applySwitch } from './applyStructural';
5
- export { applyDefer } from './applyDefer';
1
+ export { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, } from './helpers.js';
2
+ export { applyRef, applyError, markBoundary, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
3
+ export { applyComponent } from './applyComponent.js';
4
+ export { applyIf, applyFor, applySwitch } from './applyStructural.js';
5
+ export { applyDefer } from './applyDefer.js';
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type {\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 Desc,\n} from './types';\n\nexport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n} from './helpers';\n\nexport {\n applyRef,\n applyError,\n markBoundary,\n applyProjection,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n} from './applySimple';\n\nexport { applyComponent } from './applyComponent';\n\nexport { applyIf, applyFor, applySwitch } from './applyStructural';\n\nexport { applyDefer } from './applyDefer';\n"]}