@pithyjs/core 0.1.0-beta.0 → 0.1.0-beta.10

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 (226) hide show
  1. package/README.md +37 -6
  2. package/dist/a11y/focus-trap.d.ts.map +1 -1
  3. package/dist/a11y/focus-trap.js +2 -0
  4. package/dist/a11y/focus-trap.js.map +1 -1
  5. package/dist/a11y/index.d.ts +4 -4
  6. package/dist/a11y/index.js +4 -4
  7. package/dist/a11y/index.js.map +1 -1
  8. package/dist/a11y/keyboard-utils.js.map +1 -1
  9. package/dist/a11y/roving-tabindex.js.map +1 -1
  10. package/dist/a11y/skip-link.js.map +1 -1
  11. package/dist/compile/bindSwitchCases.d.ts +8 -3
  12. package/dist/compile/bindSwitchCases.d.ts.map +1 -1
  13. package/dist/compile/bindSwitchCases.js +113 -177
  14. package/dist/compile/bindSwitchCases.js.map +1 -1
  15. package/dist/compile/binds/bindBoundAttributes.d.ts +1 -0
  16. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
  17. package/dist/compile/binds/bindBoundAttributes.js +24 -2
  18. package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
  19. package/dist/compile/binds/bindClassDirectives.d.ts +3 -0
  20. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  21. package/dist/compile/binds/bindClassDirectives.js +59 -21
  22. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  23. package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
  24. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  25. package/dist/compile/binds/bindComponentsTags.js +171 -74
  26. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  27. package/dist/compile/binds/bindConditionals.d.ts +2 -2
  28. package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
  29. package/dist/compile/binds/bindConditionals.js +22 -5
  30. package/dist/compile/binds/bindConditionals.js.map +1 -1
  31. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  32. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  33. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  34. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
  35. package/dist/compile/binds/bindDeferDirectives.js +45 -15
  36. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  37. package/dist/compile/binds/bindErrorBoundary.d.ts +13 -2
  38. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  39. package/dist/compile/binds/bindErrorBoundary.js +25 -10
  40. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  41. package/dist/compile/binds/bindEventHandlers.js +2 -2
  42. package/dist/compile/binds/bindEventHandlers.js.map +1 -1
  43. package/dist/compile/binds/bindRefDirectives.js.map +1 -1
  44. package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
  45. package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
  46. package/dist/compile/binds/bindStyleDirectives.js +47 -0
  47. package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
  48. package/dist/compile/binds/bindTextInterpolations.d.ts +2 -1
  49. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
  50. package/dist/compile/binds/bindTextInterpolations.js +55 -17
  51. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  52. package/dist/compile/binds/directiveRegistry.js.map +1 -1
  53. package/dist/compile/binds/forwardedAttrs.d.ts +22 -0
  54. package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -0
  55. package/dist/compile/binds/forwardedAttrs.js +66 -0
  56. package/dist/compile/binds/forwardedAttrs.js.map +1 -0
  57. package/dist/compile/binds/propNames.d.ts +14 -0
  58. package/dist/compile/binds/propNames.d.ts.map +1 -0
  59. package/dist/compile/binds/propNames.js +116 -0
  60. package/dist/compile/binds/propNames.js.map +1 -0
  61. package/dist/compile/compileExpression.js.map +1 -1
  62. package/dist/compile/compileNodes.d.ts.map +1 -1
  63. package/dist/compile/compileNodes.js +6 -3
  64. package/dist/compile/compileNodes.js.map +1 -1
  65. package/dist/compile/compileTemplate.d.ts +3 -4
  66. package/dist/compile/compileTemplate.d.ts.map +1 -1
  67. package/dist/compile/compileTemplate.js +28 -31
  68. package/dist/compile/compileTemplate.js.map +1 -1
  69. package/dist/compile/componentResult.d.ts +100 -0
  70. package/dist/compile/componentResult.d.ts.map +1 -0
  71. package/dist/compile/componentResult.js +138 -0
  72. package/dist/compile/componentResult.js.map +1 -0
  73. package/dist/compile/contentProjection.d.ts +1 -1
  74. package/dist/compile/contentProjection.d.ts.map +1 -1
  75. package/dist/compile/contentProjection.js +32 -15
  76. package/dist/compile/contentProjection.js.map +1 -1
  77. package/dist/compile/forLoops/bindForLoops.d.ts +2 -2
  78. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
  79. package/dist/compile/forLoops/bindForLoops.js +9 -22
  80. package/dist/compile/forLoops/bindForLoops.js.map +1 -1
  81. package/dist/compile/forLoops/createLoopManager.d.ts +6 -3
  82. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  83. package/dist/compile/forLoops/createLoopManager.js +144 -114
  84. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  85. package/dist/compile/forLoops/index.d.ts +5 -5
  86. package/dist/compile/forLoops/index.js +5 -5
  87. package/dist/compile/forLoops/index.js.map +1 -1
  88. package/dist/compile/forLoops/loopHelpers.d.ts +6 -0
  89. package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -1
  90. package/dist/compile/forLoops/loopHelpers.js +17 -0
  91. package/dist/compile/forLoops/loopHelpers.js.map +1 -1
  92. package/dist/compile/forLoops/loopSignals.js +2 -2
  93. package/dist/compile/forLoops/loopSignals.js.map +1 -1
  94. package/dist/compile/forLoops/loopTraversal.js +2 -2
  95. package/dist/compile/forLoops/loopTraversal.js.map +1 -1
  96. package/dist/compile/handleConditionalChain.d.ts +2 -2
  97. package/dist/compile/handleConditionalChain.d.ts.map +1 -1
  98. package/dist/compile/handleConditionalChain.js +21 -83
  99. package/dist/compile/handleConditionalChain.js.map +1 -1
  100. package/dist/compile/index.d.ts +17 -14
  101. package/dist/compile/index.d.ts.map +1 -1
  102. package/dist/compile/index.js +28 -12
  103. package/dist/compile/index.js.map +1 -1
  104. package/dist/compile/injectScopedStyle.js.map +1 -1
  105. package/dist/compile/nodeExpando.d.ts +6 -0
  106. package/dist/compile/nodeExpando.d.ts.map +1 -1
  107. package/dist/compile/nodeExpando.js.map +1 -1
  108. package/dist/compile/parseHtml.d.ts.map +1 -1
  109. package/dist/compile/parseHtml.js +2 -2
  110. package/dist/compile/parseHtml.js.map +1 -1
  111. package/dist/compile/pithyTreeToDom.js +1 -1
  112. package/dist/compile/pithyTreeToDom.js.map +1 -1
  113. package/dist/compile/renderBranch.d.ts +13 -0
  114. package/dist/compile/renderBranch.d.ts.map +1 -0
  115. package/dist/compile/renderBranch.js +65 -0
  116. package/dist/compile/renderBranch.js.map +1 -0
  117. package/dist/compile/renderChildren.d.ts +17 -0
  118. package/dist/compile/renderChildren.d.ts.map +1 -1
  119. package/dist/compile/renderChildren.js +22 -3
  120. package/dist/compile/renderChildren.js.map +1 -1
  121. package/dist/compile/ssrCrashes.d.ts +116 -0
  122. package/dist/compile/ssrCrashes.d.ts.map +1 -0
  123. package/dist/compile/ssrCrashes.js +173 -0
  124. package/dist/compile/ssrCrashes.js.map +1 -0
  125. package/dist/compile/ssrMode.js +1 -1
  126. package/dist/compile/ssrMode.js.map +1 -1
  127. package/dist/compile/textValue.js.map +1 -1
  128. package/dist/compile/trimBlankEdges.d.ts +2 -0
  129. package/dist/compile/trimBlankEdges.d.ts.map +1 -0
  130. package/dist/compile/trimBlankEdges.js +15 -0
  131. package/dist/compile/trimBlankEdges.js.map +1 -0
  132. package/dist/config/index.js.map +1 -1
  133. package/dist/index.d.ts +6 -6
  134. package/dist/index.js +6 -6
  135. package/dist/index.js.map +1 -1
  136. package/dist/interfaces/index.d.ts +2 -2
  137. package/dist/interfaces/index.js +2 -2
  138. package/dist/interfaces/index.js.map +1 -1
  139. package/dist/interfaces/ref-signal.interface.js.map +1 -1
  140. package/dist/interfaces/ref.interface.js.map +1 -1
  141. package/dist/runtime/applyBindings.d.ts +5 -5
  142. package/dist/runtime/applyBindings.d.ts.map +1 -1
  143. package/dist/runtime/applyBindings.js +97 -21
  144. package/dist/runtime/applyBindings.js.map +1 -1
  145. package/dist/runtime/bindings/applyComponent.d.ts +2 -2
  146. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  147. package/dist/runtime/bindings/applyComponent.js +137 -39
  148. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  149. package/dist/runtime/bindings/applyDefer.d.ts +1 -1
  150. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
  151. package/dist/runtime/bindings/applyDefer.js +46 -18
  152. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  153. package/dist/runtime/bindings/applySimple.d.ts +2 -1
  154. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  155. package/dist/runtime/bindings/applySimple.js +70 -14
  156. package/dist/runtime/bindings/applySimple.js.map +1 -1
  157. package/dist/runtime/bindings/applyStructural.d.ts +1 -1
  158. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  159. package/dist/runtime/bindings/applyStructural.js +58 -68
  160. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  161. package/dist/runtime/bindings/helpers.d.ts +1 -1
  162. package/dist/runtime/bindings/helpers.js +1 -1
  163. package/dist/runtime/bindings/helpers.js.map +1 -1
  164. package/dist/runtime/bindings/index.d.ts +6 -6
  165. package/dist/runtime/bindings/index.d.ts.map +1 -1
  166. package/dist/runtime/bindings/index.js +5 -5
  167. package/dist/runtime/bindings/index.js.map +1 -1
  168. package/dist/runtime/bindings/types.d.ts +12 -1
  169. package/dist/runtime/bindings/types.d.ts.map +1 -1
  170. package/dist/runtime/bindings/types.js.map +1 -1
  171. package/dist/runtime/bootstrap.d.ts +1 -1
  172. package/dist/runtime/bootstrap.js +1 -1
  173. package/dist/runtime/bootstrap.js.map +1 -1
  174. package/dist/runtime/createContextProxy.js.map +1 -1
  175. package/dist/runtime/deferHelpers.d.ts +1 -1
  176. package/dist/runtime/deferHelpers.js.map +1 -1
  177. package/dist/runtime/html.d.ts.map +1 -1
  178. package/dist/runtime/html.js +6 -5
  179. package/dist/runtime/html.js.map +1 -1
  180. package/dist/runtime/index.d.ts +6 -5
  181. package/dist/runtime/index.d.ts.map +1 -1
  182. package/dist/runtime/index.js +7 -5
  183. package/dist/runtime/index.js.map +1 -1
  184. package/dist/runtime/lazy.js +1 -1
  185. package/dist/runtime/lazy.js.map +1 -1
  186. package/dist/runtime/module-cache.js.map +1 -1
  187. package/dist/runtime/onDestroy.d.ts +7 -0
  188. package/dist/runtime/onDestroy.d.ts.map +1 -1
  189. package/dist/runtime/onDestroy.js +16 -1
  190. package/dist/runtime/onDestroy.js.map +1 -1
  191. package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
  192. package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
  193. package/dist/runtime/resource/createAction.d.ts +44 -0
  194. package/dist/runtime/resource/createAction.d.ts.map +1 -0
  195. package/dist/runtime/resource/createAction.js +102 -0
  196. package/dist/runtime/resource/createAction.js.map +1 -0
  197. package/dist/runtime/resource/createResource.d.ts +56 -0
  198. package/dist/runtime/resource/createResource.d.ts.map +1 -0
  199. package/dist/runtime/resource/createResource.js +102 -0
  200. package/dist/runtime/resource/createResource.js.map +1 -0
  201. package/dist/runtime/resource/engine.d.ts +136 -0
  202. package/dist/runtime/resource/engine.d.ts.map +1 -0
  203. package/dist/runtime/resource/engine.js +363 -0
  204. package/dist/runtime/resource/engine.js.map +1 -0
  205. package/dist/runtime/resource/index.d.ts +19 -0
  206. package/dist/runtime/resource/index.d.ts.map +1 -0
  207. package/dist/runtime/resource/index.js +18 -0
  208. package/dist/runtime/resource/index.js.map +1 -0
  209. package/dist/runtime/resource/types.d.ts +240 -0
  210. package/dist/runtime/resource/types.d.ts.map +1 -0
  211. package/dist/runtime/resource/types.js +9 -0
  212. package/dist/runtime/resource/types.js.map +1 -0
  213. package/dist/types/globals.d.ts +10 -1
  214. package/dist/types/globals.d.ts.map +1 -1
  215. package/dist/types/globals.js.map +1 -1
  216. package/dist/types/index.d.ts +15 -1
  217. package/dist/types/index.d.ts.map +1 -1
  218. package/dist/types/index.js.map +1 -1
  219. package/dist/utilities/index.d.ts +2 -2
  220. package/dist/utilities/index.js +2 -2
  221. package/dist/utilities/index.js.map +1 -1
  222. package/dist/utilities/ref-signal.utility.d.ts +1 -1
  223. package/dist/utilities/ref-signal.utility.js.map +1 -1
  224. package/dist/utilities/ref.untility.d.ts +1 -1
  225. package/dist/utilities/ref.untility.js.map +1 -1
  226. package/package.json +14 -9
@@ -5,17 +5,17 @@
5
5
  "category": "directive"
6
6
  }
7
7
  */
8
- import { batch } from '@pithyjs/signals';
9
- import { pithyTreeToDom } from '../pithyTreeToDom';
10
- import { bindForLoops } from './bindForLoops';
11
- import { flashUpdate } from '../binds/bindTextInterpolations';
12
- import { bindTemplateDirectives } from '..';
13
- import { bindConditionals } from '../binds/bindConditionals';
14
- import { bindSwitchCases } from '../bindSwitchCases';
15
- import { createLoopSignals, updateLoopSignals, createLoopContext, } from './loopSignals';
16
- import { safeInsertBefore, markElementsAsLoopGenerated, createItemRange, wrapInRange, detachRange, } from './loopHelpers';
17
- import { findAllNestedLoopNodes } from './loopTraversal';
18
- import { nodeExpando } from '../nodeExpando';
8
+ import { batch, createRoot, untrack } from '@pithyjs/signals';
9
+ import { pithyTreeToDom } from '../pithyTreeToDom.js';
10
+ import { bindForLoops } from './bindForLoops.js';
11
+ import { flashUpdate } from '../binds/bindTextInterpolations.js';
12
+ import { bindTemplateDirectives } from '../index.js';
13
+ import { bindConditionals } from '../binds/bindConditionals.js';
14
+ import { bindSwitchCases } from '../bindSwitchCases.js';
15
+ import { createLoopSignals, updateLoopSignals, createLoopContext, } from './loopSignals.js';
16
+ import { safeInsertBefore, markElementsAsLoopGenerated, createItemRange, wrapInRange, detachRange, } from './loopHelpers.js';
17
+ import { findAllNestedLoopNodes } from './loopTraversal.js';
18
+ import { nodeExpando } from '../nodeExpando.js';
19
19
  /** First real element between [start..end] to use as a flash target. */
20
20
  function firstElInRange(start, end) {
21
21
  let n = start.nextSibling;
@@ -105,7 +105,7 @@ function restoreNodeMetadata(source, target, ctx) {
105
105
  }
106
106
  }
107
107
  /** @codexApi {"parent":"pithy.directive.loop-manager","name":"createLoopManager","stability":"stable","signature":"<T>(options: LoopManagerOptions<T>) => LoopManager<T>"} */
108
- export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar, templateNodes, }) {
108
+ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar, templateNodes, itemFactory, }) {
109
109
  // Map of key -> LoopItem (stable across updates as long as key is stable)
110
110
  const items = new Map();
111
111
  let cachedNestedLoopNodes = null;
@@ -143,6 +143,20 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
143
143
  seen.add(k);
144
144
  }
145
145
  }
146
+ if (!liveParent) {
147
+ for (const [key, loopItem] of items) {
148
+ if (!newKeySet.has(key)) {
149
+ loopItem.destroy();
150
+ items.delete(key);
151
+ }
152
+ }
153
+ collection.forEach((item, idx) => {
154
+ const existing = items.get(newKeys[idx]);
155
+ if (existing)
156
+ syncSignals(existing, item, idx, collection.length);
157
+ });
158
+ return;
159
+ }
146
160
  // Remove items that no longer exist
147
161
  let removedCount = 0;
148
162
  items.forEach((loopItem, key) => {
@@ -168,13 +182,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
168
182
  const existing = items.get(key);
169
183
  if (existing) {
170
184
  // Update item + positional signals in a single batch to avoid double effect firing
171
- const prev = existing.signals.itemSig();
172
- batch(() => {
173
- if (prev !== item) {
174
- existing.signals.itemSig.set(item);
175
- }
176
- updateLoopSignals(existing.signals, idx, collection.length);
177
- });
185
+ const prev = syncSignals(existing, item, idx, collection.length);
178
186
  if (prev !== item && shouldFlashUpdate(FLASH_ON_UPDATE, prev, item)) {
179
187
  const el = firstElInRange(existing.start, existing.end);
180
188
  if (el)
@@ -185,7 +193,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
185
193
  }
186
194
  else {
187
195
  // Create new item
188
- if (!node && !templateNodes)
196
+ if (!node && !templateNodes && !itemFactory)
189
197
  continue;
190
198
  const created = createLoopItem(node, item, idx, collection.length, key);
191
199
  items.set(key, created);
@@ -237,13 +245,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
237
245
  const existing = items.get(key);
238
246
  if (existing) {
239
247
  // Update item + positional signals in a single batch to avoid double effect firing
240
- const prev = existing.signals.itemSig();
241
- batch(() => {
242
- if (prev !== item) {
243
- existing.signals.itemSig.set(item);
244
- }
245
- updateLoopSignals(existing.signals, idx, collection.length);
246
- });
248
+ const prev = syncSignals(existing, item, idx, collection.length);
247
249
  if (prev !== item && shouldFlashUpdate(FLASH_ON_UPDATE, prev, item)) {
248
250
  const el = firstElInRange(existing.start, existing.end);
249
251
  if (el)
@@ -267,7 +269,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
267
269
  }
268
270
  else {
269
271
  // New item: create and insert before cursor
270
- if (!node && !templateNodes)
272
+ if (!node && !templateNodes && !itemFactory)
271
273
  continue;
272
274
  const created = createLoopItem(node, item, idx, collection.length, key);
273
275
  items.set(key, created);
@@ -281,6 +283,15 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
281
283
  }
282
284
  }
283
285
  }
286
+ function syncSignals(existing, item, idx, total) {
287
+ const prev = untrack(existing.signals.itemSig);
288
+ batch(() => {
289
+ if (prev !== item)
290
+ existing.signals.itemSig.set(item);
291
+ updateLoopSignals(existing.signals, idx, total);
292
+ });
293
+ return prev;
294
+ }
284
295
  /**
285
296
  * Create a new LoopItem:
286
297
  * - Build the item's DOM from the AST node and local ctx.
@@ -290,97 +301,116 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
290
301
  * - Wrap the item range with [start..end] markers (for move/remove).
291
302
  */
292
303
  function createLoopItem(node, item, idx, total, key) {
293
- var _a;
294
- const signals = createLoopSignals(item, idx, total);
295
- const ctx = createLoopContext(parentCtx, signals, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar);
296
- // 1) Build static DOM for this item
297
- let fragmentFromNode;
298
- if (!cachedTemplateFrag) {
299
- // First item: build template from AST once and cache it.
300
- // Use parentCtx so the cached template does not retain per-item signals.
301
- // restoreNodeMetadata replaces __pithyCtx with the real per-item ctx on each clone.
302
- if (templateNodes) {
303
- cachedTemplateFrag = pithyTreeToDom(templateNodes, parentCtx);
304
+ return createRoot(disposeRoot => buildLoopItem(disposeRoot));
305
+ function buildLoopItem(disposeRoot) {
306
+ var _a;
307
+ const signals = createLoopSignals(item, idx, total);
308
+ const ctx = createLoopContext(parentCtx, signals, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar);
309
+ if (itemFactory) {
310
+ const built = itemFactory(ctx);
311
+ for (const n of Array.from(built.el.childNodes)) {
312
+ if (n.nodeType === Node.ELEMENT_NODE)
313
+ nodeExpando(n).__pithyCtx = ctx;
314
+ }
315
+ const { start, end } = createItemRange(key);
316
+ const destroy = () => {
317
+ built.destroy();
318
+ disposeRoot();
319
+ detachRange(start, end);
320
+ };
321
+ return {
322
+ key,
323
+ fragment: wrapInRange(start, built.el, end),
324
+ signals,
325
+ start,
326
+ end,
327
+ destroy,
328
+ };
329
+ }
330
+ // 1) Build static DOM for this item
331
+ let fragmentFromNode;
332
+ if (!cachedTemplateFrag) {
333
+ // First item: build template from AST once and cache it.
334
+ // Use parentCtx so the cached template does not retain per-item signals.
335
+ // restoreNodeMetadata replaces __pithyCtx with the real per-item ctx on each clone.
336
+ if (templateNodes) {
337
+ cachedTemplateFrag = pithyTreeToDom(templateNodes, parentCtx);
338
+ }
339
+ else {
340
+ const nodeForRender = {
341
+ ...node,
342
+ directives: { ...node.directives },
343
+ };
344
+ delete nodeForRender.directives.for;
345
+ cachedTemplateFrag = pithyTreeToDom([nodeForRender], parentCtx);
346
+ markElementsAsLoopGenerated(cachedTemplateFrag, node);
347
+ }
348
+ // Clone for this item (cache stays pristine)
349
+ fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);
304
350
  }
305
351
  else {
306
- const nodeForRender = { ...node, directives: { ...node.directives } };
307
- delete nodeForRender.directives.for;
308
- cachedTemplateFrag = pithyTreeToDom([nodeForRender], parentCtx);
309
- markElementsAsLoopGenerated(cachedTemplateFrag, node);
352
+ // Subsequent items: clone cached DOM + restore metadata
353
+ fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);
310
354
  }
311
- // Clone for this item (cache stays pristine)
312
- fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);
313
- }
314
- else {
315
- // Subsequent items: clone cached DOM + restore metadata
316
- fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);
317
- }
318
- // 2) Tag local context on top-level elements for nearest-ctx event resolution
319
- for (const n of Array.from(fragmentFromNode.childNodes)) {
320
- if (n.nodeType === Node.ELEMENT_NODE)
321
- nodeExpando(n).__pithyCtx = ctx;
322
- }
323
- // 3) Find nested loop nodes ONCE per AST source (cache on the node or in closure)
324
- const astChildren = templateNodes ?? (node.children || []);
325
- const allNestedLoopNodes = templateNodes
326
- ? (cachedNestedLoopNodes ?? (cachedNestedLoopNodes = templateNodes.flatMap(tn => {
327
- // Include root template nodes that themselves carry @for
328
- // (findAllNestedLoopNodes skips the root, which is correct for
329
- // the directive path but misses top-level loops in templateNodes)
330
- const nested = findAllNestedLoopNodes(tn);
331
- if (tn.directives?.for)
332
- nested.unshift(tn);
333
- return nested;
334
- })))
335
- : ((_a = node).__nested ?? (_a.__nested = findAllNestedLoopNodes(node)));
336
- // 4) Build a data-pid => element map for this fragment and tag hosts to skip text-binding
337
- const pidMap = new Map();
338
- fragmentFromNode
339
- .querySelectorAll?.('[data-pid]')
340
- .forEach(el => pidMap.set(el.getAttribute('data-pid'), el));
341
- for (const n of allNestedLoopNodes) {
342
- if (!n.nodeId)
343
- continue;
344
- const host = pidMap.get(n.nodeId);
345
- if (host)
346
- nodeExpando(host).__pithySkipText = true; // parent text binder must skip this subtree
347
- }
348
- // 5) Bind structural directives in the same order as compileTemplate
349
- const disposers = [];
350
- // 5a) Bind switch/case statements FIRST
351
- // IMPORTANT: bindSwitchCases must run BEFORE bindConditionals!
352
- // Switch cases clone their content from DOM - if bindConditionals runs first,
353
- // it removes @if/@else elements and replaces them with placeholders, so the
354
- // cloned switch case content would be missing the conditional elements.
355
- bindSwitchCases(astChildren, fragmentFromNode, ctx, new Set(), disposers);
356
- // 5b) Bind conditionals inside this loop item (with loop context)
357
- // This handles @if/@else inside each loop item
358
- // Pass disposers so conditional effects are properly cleaned up when item is destroyed
359
- // Note: Conditionals inside switch cases are already gone from the DOM (removed by switch),
360
- // so this will only process conditionals outside switch blocks.
361
- const conditionalProcessedIds = bindConditionals(astChildren, fragmentFromNode, ctx, new Set(), disposers);
362
- // 5c) Bind nested loops (pass processedNodeIds to skip loops inside conditionals)
363
- const nestedLoopDisposers = [];
364
- bindForLoops(allNestedLoopNodes, fragmentFromNode, ctx, nestedLoopDisposers, conditionalProcessedIds);
365
- disposers.push(...nestedLoopDisposers);
366
- // 5d) Bind template directives (text interpolations, events, etc.)
367
- bindTemplateDirectives(fragmentFromNode, ctx, disposers);
368
- // 5e) Mark top-level elements to prevent parent from re-binding their text content
369
- for (const n of Array.from(fragmentFromNode.childNodes)) {
370
- if (n.nodeType === Node.ELEMENT_NODE) {
371
- nodeExpando(n).__pithySkipText = true;
355
+ // 2) Tag local context on top-level elements for nearest-ctx event resolution
356
+ for (const n of Array.from(fragmentFromNode.childNodes)) {
357
+ if (n.nodeType === Node.ELEMENT_NODE)
358
+ nodeExpando(n).__pithyCtx = ctx;
359
+ }
360
+ // 3) Find nested loop nodes ONCE per AST source (cache on the node or in closure)
361
+ const astChildren = templateNodes ?? (node?.isComponent ? [] : node.children || []);
362
+ const allNestedLoopNodes = templateNodes
363
+ ? (cachedNestedLoopNodes ?? (cachedNestedLoopNodes = templateNodes.flatMap(tn => {
364
+ // Include root template nodes that themselves carry @for
365
+ // (findAllNestedLoopNodes skips the root, which is correct for
366
+ // the directive path but misses top-level loops in templateNodes)
367
+ const nested = findAllNestedLoopNodes(tn);
368
+ if (tn.directives?.for)
369
+ nested.unshift(tn);
370
+ return nested;
371
+ })))
372
+ : ((_a = node).__nested ?? (_a.__nested = findAllNestedLoopNodes(node)));
373
+ // 4) Build a data-pid => element map for this fragment and tag hosts to skip text-binding
374
+ const pidMap = new Map();
375
+ fragmentFromNode
376
+ .querySelectorAll?.('[data-pid]')
377
+ .forEach(el => pidMap.set(el.getAttribute('data-pid'), el));
378
+ for (const n of allNestedLoopNodes) {
379
+ if (!n.nodeId)
380
+ continue;
381
+ const host = pidMap.get(n.nodeId);
382
+ if (host)
383
+ nodeExpando(host).__pithySkipText = true; // parent text binder must skip this subtree
384
+ }
385
+ // 5) Bind structural directives in the same order as compileTemplate
386
+ const disposers = [];
387
+ // 5a) Switch/case, then conditionals outside switch cases
388
+ const structuralProcessedIds = bindSwitchCases(astChildren, fragmentFromNode, ctx, new Set(), disposers);
389
+ bindConditionals(astChildren, fragmentFromNode, ctx, structuralProcessedIds, disposers);
390
+ // 5c) Bind nested loops (pass processedNodeIds to skip loops inside conditionals)
391
+ const nestedLoopDisposers = [];
392
+ bindForLoops(allNestedLoopNodes, fragmentFromNode, ctx, nestedLoopDisposers, structuralProcessedIds);
393
+ disposers.push(...nestedLoopDisposers);
394
+ // 5d) Bind template directives (text interpolations, events, etc.)
395
+ bindTemplateDirectives(fragmentFromNode, ctx, disposers);
396
+ // 5e) Mark top-level elements to prevent parent from re-binding their text content
397
+ for (const n of Array.from(fragmentFromNode.childNodes)) {
398
+ if (n.nodeType === Node.ELEMENT_NODE) {
399
+ nodeExpando(n).__pithySkipText = true;
400
+ }
372
401
  }
402
+ // 7) Wrap the whole item in [start..end] comments so we can move/remove it as a unit
403
+ const { start, end } = createItemRange(key);
404
+ const grouped = wrapInRange(start, fragmentFromNode, end);
405
+ // 8) Cleanup function: unsubscribe effects/listeners and detach DOM range
406
+ const destroy = () => {
407
+ for (const d of disposers)
408
+ d();
409
+ disposeRoot();
410
+ detachRange(start, end);
411
+ };
412
+ return { key, fragment: grouped, node, signals, start, end, destroy };
373
413
  }
374
- // 7) Wrap the whole item in [start..end] comments so we can move/remove it as a unit
375
- const { start, end } = createItemRange(key);
376
- const grouped = wrapInRange(start, fragmentFromNode, end);
377
- // 8) Cleanup function: unsubscribe effects/listeners and detach DOM range
378
- const destroy = () => {
379
- for (const d of disposers)
380
- d();
381
- detachRange(start, end);
382
- };
383
- return { key, fragment: grouped, node, signals, start, end, destroy };
384
414
  }
385
415
  function destroyAll() {
386
416
  items.forEach(item => item.destroy());
@@ -1 +1 @@
1
- {"version":3,"file":"createLoopManager.js","sourceRoot":"","sources":["../../../src/compile/forLoops/createLoopManager.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAiBF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EACf,WAAW,EACX,WAAW,GAC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AC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.loop-manager\",\n \"title\": \"Advanced Loop Manager\",\n \"category\": \"directive\"\n}\n*/\n\n/**\n * createLoopManager.ts\n *\n * A keyed, range-based list renderer optimized for deep nesting and high churn.\n *\n * Highlights:\n * - Uses [start..end] comment markers to represent each item range (stable DOM, easy move/remove).\n * - Minimal-move reordering using LIS (Longest Increasing Subsequence).\n * - Rebuild fast-path for heavy churn (bulk fragment insert for big updates).\n * - Caches nested loop nodes and tags their hosts to skip parent text-binding passes.\n * - Precise (configurable) visual flashing policy for inserts/moves/updates.\n * - Dev-time duplicate key detection.\n */\n\nimport type { PithyNode } from '@pithyjs/compiler';\nimport type { ChildFactory } from '../../runtime/bindings/types';\nimport { batch, createRoot, untrack } from '@pithyjs/signals';\nimport { pithyTreeToDom } from '../pithyTreeToDom';\nimport { bindForLoops } from './bindForLoops';\nimport { flashUpdate } from '../binds/bindTextInterpolations';\nimport { bindTemplateDirectives } from '..';\nimport { bindConditionals } from '../binds/bindConditionals';\nimport { bindSwitchCases } from '../bindSwitchCases';\nimport {\n LoopSignals,\n createLoopSignals,\n updateLoopSignals,\n createLoopContext,\n} from './loopSignals';\nimport {\n safeInsertBefore,\n markElementsAsLoopGenerated,\n createItemRange,\n wrapInRange,\n detachRange,\n} from './loopHelpers';\nimport { findAllNestedLoopNodes } from './loopTraversal';\nimport { nodeExpando } from '../nodeExpando';\n\n// ── Module-scope helpers (hoisted to avoid re-allocation per update() call) ──\n\ntype FlashUpdatePolicy = 'none' | 'identity' | 'shallow-nested-ignored';\n\n/** First real element between [start..end] to use as a flash target. */\nfunction firstElInRange(start: Comment, end: Comment): Element | null {\n let n: ChildNode | null = start.nextSibling;\n while (n && n !== end) {\n if (n.nodeType === Node.ELEMENT_NODE) return n as Element;\n n = n.nextSibling;\n }\n return null;\n}\n\n/** Extract inclusive [start..end] into a fragment (moving the range intact). */\nfunction collectRange(start: Comment, end: Comment): DocumentFragment {\n const frag = document.createDocumentFragment();\n let n: ChildNode | null = start;\n while (n) {\n const next: ChildNode | null = n.nextSibling;\n frag.appendChild(n);\n if (n === end) break;\n n = next;\n }\n return frag;\n}\n\n/** Compare only shallow, non-object fields to decide if update flash is meaningful. */\nfunction shallowChangedIgnoringObjects(a: unknown, b: unknown): boolean {\n if (a === b) return false;\n if (typeof a !== 'object' || a == null || typeof b !== 'object' || b == null)\n return true;\n\n const ar = a as Record<string, unknown>;\n const br = b as Record<string, unknown>;\n const keys = new Set([...Object.keys(ar), ...Object.keys(br)]);\n for (const k of keys) {\n const va = ar[k];\n const vb = br[k];\n const objA = va && typeof va === 'object';\n const objB = vb && typeof vb === 'object';\n if (objA || objB) continue; // ignore nested objects/arrays (child loops will flash)\n if (va !== vb) return true;\n }\n return false;\n}\n\nfunction shouldFlashUpdate(\n policy: FlashUpdatePolicy,\n prevItem: unknown,\n nextItem: unknown\n): boolean {\n switch (policy) {\n case 'none':\n return false;\n case 'identity':\n return prevItem !== nextItem;\n case 'shallow-nested-ignored':\n return shallowChangedIgnoringObjects(prevItem, nextItem);\n }\n}\n\n/** Clone a cached template fragment and restore JS metadata properties via parallel walk. */\nfunction cloneFragmentWithContext(\n template: DocumentFragment,\n ctx: Record<string, unknown>\n): DocumentFragment {\n const clone = template.cloneNode(true) as DocumentFragment;\n restoreNodeMetadata(template, clone, ctx);\n return clone;\n}\n\n/**\n * Walk source and target trees in parallel, copying metadata from source to target.\n * `__pithyCtx` is set to the new `ctx` (not copied from source).\n */\nfunction restoreNodeMetadata(\n source: Node,\n target: Node,\n ctx: Record<string, unknown>\n): void {\n const src = nodeExpando(source);\n const tgt = nodeExpando(target);\n\n if (src.__pithyCtx !== undefined) tgt.__pithyCtx = ctx;\n if (src.__pithyNode !== undefined) tgt.__pithyNode = src.__pithyNode;\n if (src.__nodeId !== undefined) tgt.__nodeId = src.__nodeId;\n if (src.__slotName !== undefined) tgt.__slotName = src.__slotName;\n\n // Slot fallback factory captures context — recreate with new ctx\n const srcNode = src.__pithyNode;\n if (\n src.__fallbackFactory !== undefined &&\n srcNode?.fallbackChildren?.length\n ) {\n tgt.__fallbackFactory = () =>\n pithyTreeToDom(srcNode.fallbackChildren!, ctx);\n }\n\n // Walk children in parallel (cloneNode preserves child count/order)\n const srcChildren = source.childNodes;\n const tgtChildren = target.childNodes;\n for (let i = 0; i < srcChildren.length; i++) {\n restoreNodeMetadata(srcChildren[i], tgtChildren[i], ctx);\n }\n}\n\n// ── Interfaces ──\n\nexport type { ChildFactory };\n\nexport interface LoopItem {\n key: string;\n fragment: DocumentFragment | Element; // contains [start, ...content..., end]\n signals: LoopSignals;\n start: Comment;\n end: Comment;\n node?: PithyNode; // original AST node (for caching, diagnostics); absent in templateNodes path\n destroy: () => void;\n}\n\nexport interface LoopManagerOptions<T> {\n anchor: Comment; // DOM anchor comment for the whole loop block\n trackByFn: (item: T, index: number) => string; // stable key selector\n parentCtx: Record<string, unknown>; // parent template context\n itemVar: string; // loop item var name (e.g., \"item\")\n indexVar?: string; // loop index var name (e.g., \"i\")\n countVar?: string; // count signal alias (default: \"count\")\n firstVar?: string; // first signal alias (default: \"first\")\n lastVar?: string; // last signal alias (default: \"last\")\n evenVar?: string; // even signal alias (default: \"even\")\n oddVar?: string; // odd signal alias (default: \"odd\")\n templateNodes?: PithyNode[]; // pre-parsed AST children for component-driven loops (e.g. <For>)\n itemFactory?: ChildFactory;\n}\n\nexport interface LoopManager<T = unknown> {\n update: (collection: T[], node?: PithyNode) => void;\n destroyAll: () => void;\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-manager\",\"name\":\"createLoopManager\",\"stability\":\"stable\",\"signature\":\"<T>(options: LoopManagerOptions<T>) => LoopManager<T>\"} */\nexport function createLoopManager<T>({\n anchor,\n trackByFn,\n parentCtx,\n itemVar,\n indexVar,\n countVar,\n firstVar,\n lastVar,\n evenVar,\n oddVar,\n templateNodes,\n itemFactory,\n}: LoopManagerOptions<T>): LoopManager<T> {\n // Map of key -> LoopItem (stable across updates as long as key is stable)\n const items = new Map<string, LoopItem>();\n let cachedNestedLoopNodes: PithyNode[] | null = null;\n let cachedTemplateFrag: DocumentFragment | null = null;\n\n /**\n * Update the loop to reflect the given collection:\n * - Diff keys (remove missing, add new).\n * - If churn is heavy: rebuild in a single batch (fast path).\n * - Else: compute minimal moves (LIS - Longest Increasing Subsequence), update signals, and reorder DOM ranges.\n */\n function update(collection: T[], node?: PithyNode): void {\n const liveParent = anchor.parentNode;\n\n // Flashing Policy\n const FLASH_ON_INSERT = true as const;\n const FLASH_ON_MOVE = false as const; // moves typically aren't \"re-renders\"\n const FLASH_ON_UPDATE: FlashUpdatePolicy = 'shallow-nested-ignored';\n\n // NOTE: We intentionally do NOT wrap the entire update() in batch().\n // createLoopItem builds DOM via pithyTreeToDom which creates reactive\n // effects. If those effects are deferred by an outer batch, the flush\n // can re-trigger the parent effect (in For.ts) causing infinite recursion.\n // Per-item batch() around signal updates is safe and sufficient.\n\n // Key Diff\n const newKeys = collection.map((it, idx) => trackByFn(it, idx));\n const newKeySet = new Set(newKeys);\n\n // Dev-time guard for duplicate keys (can corrupt the map & DOM)\n if (import.meta.env?.DEV) {\n const seen = new Set<string>();\n for (const k of newKeys) {\n if (seen.has(k)) {\n console.warn('[loop] duplicate key detected:', k, {\n node,\n collection,\n });\n }\n seen.add(k);\n }\n }\n\n if (!liveParent) {\n for (const [key, loopItem] of items) {\n if (!newKeySet.has(key)) {\n loopItem.destroy();\n items.delete(key);\n }\n }\n collection.forEach((item, idx) => {\n const existing = items.get(newKeys[idx]);\n if (existing) syncSignals(existing, item, idx, collection.length);\n });\n return;\n }\n\n // Remove items that no longer exist\n let removedCount = 0;\n items.forEach((loopItem, key) => {\n if (!newKeySet.has(key)) {\n loopItem.destroy(); // unsubscribes + removes its DOM range\n items.delete(key);\n removedCount++;\n }\n });\n\n // Count additions\n const addedCount = newKeys.reduce(\n (acc, k) => acc + (items.has(k) ? 0 : 1),\n 0\n );\n\n // Churn heuristic (how much of the list changed)\n const n = newKeys.length;\n const churn = (addedCount + removedCount) / Math.max(1, n);\n\n // Rebuild Fast-Path\n // For very heavy churn, a single rebuild is often faster than many moves.\n const REBUILD_THRESHOLD = 0.5;\n if (churn > REBUILD_THRESHOLD) {\n const batchFrag = document.createDocumentFragment();\n\n for (let idx = 0; idx < collection.length; idx++) {\n const key = newKeys[idx];\n const item = collection[idx];\n const existing = items.get(key);\n\n if (existing) {\n // Update item + positional signals in a single batch to avoid double effect firing\n const prev = syncSignals(existing, item, idx, collection.length);\n if (prev !== item && shouldFlashUpdate(FLASH_ON_UPDATE, prev, item)) {\n const el = firstElInRange(existing.start, existing.end);\n if (el) flashUpdate(el);\n }\n // Move entire range into the batchFrag fragment\n batchFrag.appendChild(collectRange(existing.start, existing.end));\n } else {\n // Create new item\n if (!node && !templateNodes && !itemFactory) continue;\n const created = createLoopItem(\n node,\n item,\n idx,\n collection.length,\n key\n );\n items.set(key, created);\n batchFrag.appendChild(created.fragment);\n if (FLASH_ON_INSERT) {\n const el = firstElInRange(created.start, created.end);\n if (el) flashUpdate(el);\n }\n }\n }\n\n // Insert everything at once before the anchor\n safeInsertBefore(liveParent, batchFrag, anchor);\n return;\n }\n\n // Minimal-Move Path (LIS)\n // Goal: only move items that are out of order (items in LIS keep their place).\n\n // Current DOM order of existing items (sort by document position)\n const existingItems = Array.from(items.values());\n existingItems.sort((a, b) => {\n const pos = a.start.compareDocumentPosition(b.start);\n // if a follows b, put b first (i.e., a after b => return 1)\n if (pos & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n return 1;\n });\n const oldOrder = existingItems.map(i => i.key);\n\n // Map key -> new position\n const newPos = new Map<string, number>();\n newKeys.forEach((k, i) => newPos.set(k, i));\n\n // Sequence of positions for old items that still exist\n const seq: number[] = [];\n const seqKeys: string[] = [];\n for (const k of oldOrder) {\n const p = newPos.get(k);\n if (p != null) {\n seq.push(p);\n seqKeys.push(k);\n }\n }\n\n // Compute LIS over positions and mark keys to keep (no move)\n const lisIdxs = lis(seq); // indices into seq[]\n const keep = new Set(lisIdxs.map(i => seqKeys[i]));\n\n // Reorder by iterating the new order backwards and inserting before a moving cursor\n let cursor: ChildNode = anchor;\n\n for (let idx = collection.length - 1; idx >= 0; idx--) {\n const item = collection[idx];\n const key = newKeys[idx];\n const existing = items.get(key);\n\n if (existing) {\n // Update item + positional signals in a single batch to avoid double effect firing\n const prev = syncSignals(existing, item, idx, collection.length);\n if (prev !== item && shouldFlashUpdate(FLASH_ON_UPDATE, prev, item)) {\n const el = firstElInRange(existing.start, existing.end);\n if (el) flashUpdate(el);\n }\n\n if (keep.has(key)) {\n // Already in good relative position, don't move; just advance cursor\n cursor = existing.start;\n } else {\n // Move the entire range right before the cursor\n const rangeFrag = collectRange(existing.start, existing.end);\n safeInsertBefore(liveParent, rangeFrag, cursor);\n if (FLASH_ON_MOVE) {\n const el = firstElInRange(existing.start, existing.end);\n if (el) flashUpdate(el);\n }\n cursor = existing.start;\n }\n } else {\n // New item: create and insert before cursor\n if (!node && !templateNodes && !itemFactory) continue;\n const created = createLoopItem(node, item, idx, collection.length, key);\n items.set(key, created);\n safeInsertBefore(liveParent, created.fragment, cursor);\n if (FLASH_ON_INSERT) {\n const el = firstElInRange(created.start, created.end);\n if (el) flashUpdate(el);\n }\n cursor = created.start;\n }\n }\n }\n\n function syncSignals(\n existing: LoopItem,\n item: T,\n idx: number,\n total: number\n ): T {\n const prev = untrack(existing.signals.itemSig) as T;\n batch(() => {\n if (prev !== item) existing.signals.itemSig.set(item);\n updateLoopSignals(existing.signals, idx, total);\n });\n return prev;\n }\n\n /**\n * Create a new LoopItem:\n * - Build the item's DOM from the AST node and local ctx.\n * - Tag top-level elements with __pithyCtx (so events resolve nearest context).\n * - Cache & tag nested loop hosts to skip parent text-binding.\n * - Bind template directives first; then bind nested loops inside this item.\n * - Wrap the item range with [start..end] markers (for move/remove).\n */\n function createLoopItem(\n node: PithyNode | undefined,\n item: T,\n idx: number,\n total: number,\n key: string\n ): LoopItem {\n return createRoot(disposeRoot => buildLoopItem(disposeRoot));\n\n function buildLoopItem(disposeRoot: () => void): LoopItem {\n const signals = createLoopSignals(item, idx, total);\n const ctx = createLoopContext(\n parentCtx,\n signals,\n itemVar,\n indexVar,\n countVar,\n firstVar,\n lastVar,\n evenVar,\n oddVar\n );\n\n if (itemFactory) {\n const built = itemFactory(ctx);\n for (const n of Array.from(built.el.childNodes)) {\n if (n.nodeType === Node.ELEMENT_NODE) nodeExpando(n).__pithyCtx = ctx;\n }\n const { start, end } = createItemRange(key);\n const destroy = () => {\n built.destroy();\n disposeRoot();\n detachRange(start, end);\n };\n return {\n key,\n fragment: wrapInRange(start, built.el, end),\n signals,\n start,\n end,\n destroy,\n };\n }\n\n // 1) Build static DOM for this item\n let fragmentFromNode: DocumentFragment;\n\n if (!cachedTemplateFrag) {\n // First item: build template from AST once and cache it.\n // Use parentCtx so the cached template does not retain per-item signals.\n // restoreNodeMetadata replaces __pithyCtx with the real per-item ctx on each clone.\n if (templateNodes) {\n cachedTemplateFrag = pithyTreeToDom(templateNodes, parentCtx);\n } else {\n const nodeForRender = {\n ...node!,\n directives: { ...node!.directives },\n };\n delete nodeForRender.directives.for;\n cachedTemplateFrag = pithyTreeToDom([nodeForRender], parentCtx);\n markElementsAsLoopGenerated(cachedTemplateFrag, node!);\n }\n // Clone for this item (cache stays pristine)\n fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);\n } else {\n // Subsequent items: clone cached DOM + restore metadata\n fragmentFromNode = cloneFragmentWithContext(cachedTemplateFrag, ctx);\n }\n\n // 2) Tag local context on top-level elements for nearest-ctx event resolution\n for (const n of Array.from(fragmentFromNode.childNodes)) {\n if (n.nodeType === Node.ELEMENT_NODE) nodeExpando(n).__pithyCtx = ctx;\n }\n\n // 3) Find nested loop nodes ONCE per AST source (cache on the node or in closure)\n const astChildren =\n templateNodes ?? (node?.isComponent ? [] : node!.children || []);\n const allNestedLoopNodes: PithyNode[] = templateNodes\n ? (cachedNestedLoopNodes ??= templateNodes.flatMap(tn => {\n // Include root template nodes that themselves carry @for\n // (findAllNestedLoopNodes skips the root, which is correct for\n // the directive path but misses top-level loops in templateNodes)\n const nested = findAllNestedLoopNodes(tn);\n if (tn.directives?.for) nested.unshift(tn);\n return nested;\n }))\n : ((node as PithyNode & { __nested?: PithyNode[] }).__nested ??=\n findAllNestedLoopNodes(node!));\n\n // 4) Build a data-pid => element map for this fragment and tag hosts to skip text-binding\n const pidMap = new Map<string, Element>();\n (fragmentFromNode as Element | DocumentFragment)\n .querySelectorAll?.('[data-pid]')\n .forEach(el => pidMap.set(el.getAttribute('data-pid')!, el as Element));\n\n for (const n of allNestedLoopNodes) {\n if (!n.nodeId) continue;\n const host = pidMap.get(n.nodeId);\n if (host) nodeExpando(host).__pithySkipText = true; // parent text binder must skip this subtree\n }\n\n // 5) Bind structural directives in the same order as compileTemplate\n const disposers: (() => void)[] = [];\n\n // 5a) Switch/case, then conditionals outside switch cases\n const structuralProcessedIds = bindSwitchCases(\n astChildren,\n fragmentFromNode,\n ctx,\n new Set<string>(),\n disposers\n );\n bindConditionals(\n astChildren,\n fragmentFromNode,\n ctx,\n structuralProcessedIds,\n disposers\n );\n\n // 5c) Bind nested loops (pass processedNodeIds to skip loops inside conditionals)\n const nestedLoopDisposers: (() => void)[] = [];\n bindForLoops(\n allNestedLoopNodes,\n fragmentFromNode,\n ctx,\n nestedLoopDisposers,\n structuralProcessedIds\n );\n disposers.push(...nestedLoopDisposers);\n\n // 5d) Bind template directives (text interpolations, events, etc.)\n bindTemplateDirectives(fragmentFromNode, ctx, disposers);\n\n // 5e) Mark top-level elements to prevent parent from re-binding their text content\n for (const n of Array.from(fragmentFromNode.childNodes)) {\n if (n.nodeType === Node.ELEMENT_NODE) {\n nodeExpando(n).__pithySkipText = true;\n }\n }\n\n // 7) Wrap the whole item in [start..end] comments so we can move/remove it as a unit\n const { start, end } = createItemRange(key);\n const grouped = wrapInRange(start, fragmentFromNode, end);\n\n // 8) Cleanup function: unsubscribe effects/listeners and detach DOM range\n const destroy = () => {\n for (const d of disposers) d();\n disposeRoot();\n detachRange(start, end);\n };\n\n return { key, fragment: grouped, node, signals, start, end, destroy };\n }\n }\n\n function destroyAll(): void {\n items.forEach(item => item.destroy());\n items.clear();\n }\n\n return { update, destroyAll };\n}\n\n/**\n * O(n log n) Longest Increasing Subsequence.\n * Given an array of numbers `a`, returns the indices into `a` that form\n * a strictly increasing subsequence with maximal length.\n *\n * We use LIS on the sequence of \"new positions\" for existing items to minimize DOM moves:\n * - Items in the LIS are already in correct relative order and don't need to move.\n * - Only the remaining items are moved to their new positions.\n */\nfunction lis(a: number[]): number[] {\n const res: number[] = []; // res[k] is the index i of the smallest tail of an increasing subsequence of length k+1\n const m: number[] = []; // m[i] points to predecessor index for i in the LIS\n\n for (let i = 0; i < a.length; i++) {\n // binary search in res to find the length of the LIS that a[i] can extend\n let lo = 0,\n hi = res.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (a[res[mid]] < a[i]) lo = mid + 1;\n else hi = mid;\n }\n\n // update res and predecessor\n if (lo === res.length) res.push(i);\n else res[lo] = i;\n\n m[i] = lo ? res[lo - 1] : -1;\n }\n\n // reconstruct LIS indices from res/m\n let k = res[res.length - 1];\n const out: number[] = [];\n for (let i = res.length - 1; i >= 0; i--) {\n out[i] = k;\n k = m[k];\n }\n return out;\n}\n"]}
@@ -1,6 +1,6 @@
1
- export * from './bindForLoops';
2
- export * from './createLoopManager';
3
- export * from './loopHelpers';
4
- export * from './loopSignals';
5
- export * from './loopTraversal';
1
+ export * from './bindForLoops.js';
2
+ export * from './createLoopManager.js';
3
+ export * from './loopHelpers.js';
4
+ export * from './loopSignals.js';
5
+ export * from './loopTraversal.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
1
  // Main loop functionality
2
- export * from './bindForLoops';
3
- export * from './createLoopManager';
2
+ export * from './bindForLoops.js';
3
+ export * from './createLoopManager.js';
4
4
  // Helper utilities
5
- export * from './loopHelpers';
6
- export * from './loopSignals';
7
- export * from './loopTraversal';
5
+ export * from './loopHelpers.js';
6
+ export * from './loopSignals.js';
7
+ export * from './loopTraversal.js';
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compile/forLoops/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAEpC,mBAAmB;AACnB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compile/forLoops/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAEpC,mBAAmB;AACnB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC","sourcesContent":["// Main loop functionality\nexport * from './bindForLoops';\nexport * from './createLoopManager';\n\n// Helper utilities\nexport * from './loopHelpers';\nexport * from './loopSignals';\n\nexport * from './loopTraversal';\n"]}
@@ -30,4 +30,10 @@ export declare function createItemRange(key: string): {
30
30
  export declare function wrapInRange(start: Comment, content: DocumentFragment | HTMLElement, end: Comment): DocumentFragment;
31
31
  /** @codexApi {"parent":"pithy.directive.loop-helpers","name":"detachRange","stability":"stable","signature":"(start: Comment, end: Comment) => void"} */
32
32
  export declare function detachRange(start: Comment, end: Comment): void;
33
+ /**
34
+ * Compiles a loop's `track` expression into a key function. Inside it the loop
35
+ * variable is the RAW item, not the accessor the loop body reads. Without an
36
+ * expression, items are keyed by index.
37
+ */
38
+ export declare function compileTrackBy(trackExpr: string | undefined, itemVar: string, indexVar: string | undefined, ctx: Record<string, unknown>): (item: unknown, idx: number) => string;
33
39
  //# sourceMappingURL=loopHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loopHelpers.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/loopHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;GAEG;AAEH,yLAAyL;AACzL;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,IAAI,EACb,aAAa,EAAE,IAAI,GAAG,IAAI,GACzB,IAAI,CASN;AAED,kMAAkM;AAClM;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACxB,IAAI,CAiBN;AAED,wKAAwK;AACxK,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM;;;EAI1C;AAED,8MAA8M;AAC9M,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,gBAAgB,GAAG,WAAW,EACvC,GAAG,EAAE,OAAO,GACX,gBAAgB,CAMlB;AAED,yJAAyJ;AACzJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,QASvD"}
1
+ {"version":3,"file":"loopHelpers.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/loopHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;GAEG;AAEH,yLAAyL;AACzL;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,IAAI,EACb,aAAa,EAAE,IAAI,GAAG,IAAI,GACzB,IAAI,CASN;AAED,kMAAkM;AAClM;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACxB,IAAI,CAiBN;AAED,wKAAwK;AACxK,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM;;;EAI1C;AAED,8MAA8M;AAC9M,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,gBAAgB,GAAG,WAAW,EACvC,GAAG,EAAE,OAAO,GACX,gBAAgB,CAMlB;AAED,yJAAyJ;AACzJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,QASvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAexC"}
@@ -66,4 +66,21 @@ export function detachRange(start, end) {
66
66
  start.parentNode?.removeChild(start);
67
67
  end.parentNode?.removeChild(end);
68
68
  }
69
+ /**
70
+ * Compiles a loop's `track` expression into a key function. Inside it the loop
71
+ * variable is the RAW item, not the accessor the loop body reads. Without an
72
+ * expression, items are keyed by index.
73
+ */
74
+ export function compileTrackBy(trackExpr, itemVar, indexVar, ctx) {
75
+ if (!trackExpr)
76
+ return (_item, idx) => String(idx);
77
+ // Internal param names (__it/__idx) avoid a TDZ clash with the loop's own names.
78
+ // eslint-disable-next-line no-new-func -- trackBy key compilation is a core framework feature
79
+ const fn = new Function('ctx', '__it', '__idx', `with (ctx) {
80
+ const ${itemVar} = __it;
81
+ ${indexVar ? `const ${indexVar} = __idx;` : ''}
82
+ return (${trackExpr});
83
+ }`);
84
+ return (item, idx) => String(fn(ctx, item, idx));
85
+ }
69
86
  //# sourceMappingURL=loopHelpers.js.map
@@ -1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S;MACnB,CACsE,CAAC;IAC3E,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.loop-helpers\",\n \"title\": \"Loop Utility Functions\", \n \"category\": \"directive\"\n}\n*/\n\n/**\n * General utility functions for loop operations\n */\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-helpers\",\"name\":\"safeInsertBefore\",\"stability\":\"stable\",\"signature\":\"(parent: Node, newNode: Node, referenceNode: Node | null) => void\"} */\n/**\n * Safely inserts a node before a reference node, with fallback to appendChild\n */\nexport function safeInsertBefore(\n parent: Node,\n newNode: Node,\n referenceNode: Node | null\n): void {\n if (referenceNode && referenceNode.parentNode === parent) {\n parent.insertBefore(newNode, referenceNode);\n } else {\n console.warn(\n '[safeInsertBefore] WARNING: referenceNode is NOT in parent; appending at end'\n );\n parent.appendChild(newNode);\n }\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-helpers\",\"name\":\"markElementsAsLoopGenerated\",\"stability\":\"stable\",\"signature\":\"(fragment: DocumentFragment, node: { nodeId?: string }) => void\"} */\n/**\n * Marks all elements in a fragment as loop-generated for safe cleanup\n * Optimized to use targeted selectors when possible\n */\nexport function markElementsAsLoopGenerated(\n fragment: DocumentFragment,\n node: { nodeId?: string }\n): void {\n // Optimize: Use more targeted selector if nodeId has hierarchical format\n const selector =\n node.nodeId && node.nodeId.includes('-')\n ? `[data-pid^=\"${node.nodeId}-\"], [data-pid=\"${node.nodeId}\"]`\n : '*';\n\n fragment.querySelectorAll(selector).forEach(el => {\n el.setAttribute('data-loop-generated', 'true');\n });\n\n // Also mark any remaining elements that don't have data-pid\n if (selector !== '*') {\n fragment.querySelectorAll('*:not([data-pid])').forEach(el => {\n el.setAttribute('data-loop-generated', 'true');\n });\n }\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-helpers\",\"name\":\"createItemRange\",\"stability\":\"stable\",\"signature\":\"(key: string) => { start: Comment; end: Comment }\"} */\nexport function createItemRange(key: string) {\n const start = document.createComment(`#for:item:start key=\"${key}\"`);\n const end = document.createComment(`#for:item:end key=\"${key}\"`);\n return { start, end };\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-helpers\",\"name\":\"wrapInRange\",\"stability\":\"stable\",\"signature\":\"(start: Comment, content: DocumentFragment | HTMLElement, end: Comment) => DocumentFragment\"} */\nexport function wrapInRange(\n start: Comment,\n content: DocumentFragment | HTMLElement,\n end: Comment\n): DocumentFragment {\n const group = document.createDocumentFragment();\n group.appendChild(start);\n group.appendChild(content); // appends all children if it's a fragment\n group.appendChild(end);\n return group;\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-helpers\",\"name\":\"detachRange\",\"stability\":\"stable\",\"signature\":\"(start: Comment, end: Comment) => void\"} */\nexport function detachRange(start: Comment, end: Comment) {\n let n: ChildNode | null = start.nextSibling;\n while (n && n !== end) {\n const toRemove = n;\n n = n.nextSibling;\n toRemove.parentNode?.removeChild(toRemove);\n }\n start.parentNode?.removeChild(start);\n end.parentNode?.removeChild(end);\n}\n\n/**\n * Compiles a loop's `track` expression into a key function. Inside it the loop\n * variable is the RAW item, not the accessor the loop body reads. Without an\n * expression, items are keyed by index.\n */\nexport function compileTrackBy(\n trackExpr: string | undefined,\n itemVar: string,\n indexVar: string | undefined,\n ctx: Record<string, unknown>\n): (item: unknown, idx: number) => string {\n if (!trackExpr) return (_item, idx) => String(idx);\n // Internal param names (__it/__idx) avoid a TDZ clash with the loop's own names.\n // eslint-disable-next-line no-new-func -- trackBy key compilation is a core framework feature\n const fn = new Function(\n 'ctx',\n '__it',\n '__idx',\n `with (ctx) {\n const ${itemVar} = __it;\n ${indexVar ? `const ${indexVar} = __idx;` : ''}\n return (${trackExpr});\n }`\n ) as (ctx: Record<string, unknown>, item: unknown, idx: number) => unknown;\n return (item, idx) => String(fn(ctx, item, idx));\n}\n"]}
@@ -52,13 +52,13 @@ export function updateLoopSignals(signals, idx, total) {
52
52
  export function createLoopContext(parentCtx, signals, itemVar, indexVar, countVar = 'count', firstVar = 'first', lastVar = 'last', evenVar = 'even', oddVar = 'odd') {
53
53
  return {
54
54
  ...parentCtx,
55
- [itemVar]: signals.itemSig,
56
- ...(indexVar ? { [indexVar]: signals.idxSig } : {}),
57
55
  [countVar]: signals.countSig,
58
56
  [firstVar]: signals.firstSig,
59
57
  [lastVar]: signals.lastSig,
60
58
  [evenVar]: signals.evenSig,
61
59
  [oddVar]: signals.oddSig,
60
+ [itemVar]: signals.itemSig,
61
+ ...(indexVar ? { [indexVar]: signals.idxSig } : {}),
62
62
  };
63
63
  }
64
64
  //# sourceMappingURL=loopSignals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loopSignals.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopSignals.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,kBAAkB,CAAC;AAYzD,gLAAgL;AAChL;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAO,EACP,GAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAErC,OA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C,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QAChC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;QACvC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,6UAA6U;AAC7U;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAkC,EAClC,OAAoB,EACpB,OAAe,EACf,QAAiB,EACjB,QAAQ,GAAG,OAAO,EAClB,QAAQ,GAAG,OAAO,EAClB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,MAAM,EAChB,MAAM,GAAG,KAAK;IAEd,OAAO;QACL,GAAG,SAAS;QACZ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ;QAC5B,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ;QAC5B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM;QACxB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.loop-signals\",\n \"title\": \"Loop Reactive Signals\", \n \"category\": \"directive\"\n}\n*/\n\nimport { batch, signal, Signal } from '@pithyjs/signals';\n\nexport interface LoopSignals {\n itemSig: Signal<unknown>;\n countSig: Signal<number>;\n idxSig: Signal<number>;\n firstSig: Signal<boolean>;\n lastSig: Signal<boolean>;\n evenSig: Signal<boolean>;\n oddSig: Signal<boolean>;\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"createLoopSignals\",\"stability\":\"stable\",\"signature\":\"<T>(item: T, idx: number, total: number) => LoopSignals\"} */\n/**\n * Creates all the reactive signals needed for a loop item\n */\nexport function createLoopSignals<T>(\n item: T,\n idx: number,\n total: number\n): LoopSignals {\n const itemSig = signal<unknown>(item);\n const countSig = signal(total);\n const idxSig = signal(idx);\n const firstSig = signal(idx === 0);\n const lastSig = signal(idx === total - 1);\n const evenSig = signal(idx % 2 === 0);\n const oddSig = signal(idx % 2 === 1);\n\n return {\n itemSig,\n countSig,\n idxSig,\n firstSig,\n lastSig,\n evenSig,\n oddSig,\n };\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"updateLoopSignals\",\"stability\":\"stable\",\"signature\":\"(signals: LoopSignals, idx: number, total: number) => void\"} */\n/**\n * Updates all positional signals for a loop item (idx, first, last, even, odd, count)\n * Uses batch() for optimal performance\n */\nexport function updateLoopSignals(\n signals: LoopSignals,\n idx: number,\n total: number\n): void {\n batch(() => {\n signals.countSig.set(total);\n signals.idxSig.set(idx);\n signals.firstSig.set(idx === 0);\n signals.lastSig.set(idx === total - 1);\n signals.evenSig.set(idx % 2 === 0);\n signals.oddSig.set(idx % 2 === 1);\n });\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"createLoopContext\",\"stability\":\"stable\",\"signature\":\"(parentCtx: Record<string, unknown>, signals: LoopSignals, itemVar: string, indexVar?: string, countVar?: string, firstVar?: string, lastVar?: string, evenVar?: string, oddVar?: string) => Record<string, unknown>\"} */\n/**\n * Creates the context object for a loop item with all necessary signals.\n * Helper signal names (count, first, last, even, odd) can be aliased to\n * avoid shadowing in nested loops.\n */\nexport function createLoopContext(\n parentCtx: Record<string, unknown>,\n signals: LoopSignals,\n itemVar: string,\n indexVar?: string,\n countVar = 'count',\n firstVar = 'first',\n lastVar = 'last',\n evenVar = 'even',\n oddVar = 'odd'\n): Record<string, unknown> {\n return {\n ...parentCtx,\n [countVar]: signals.countSig,\n [firstVar]: signals.firstSig,\n [lastVar]: signals.lastSig,\n [evenVar]: signals.evenSig,\n [oddVar]: signals.oddSig,\n [itemVar]: signals.itemSig,\n ...(indexVar ? { [indexVar]: signals.idxSig } : {}),\n };\n}\n"]}
@@ -21,14 +21,14 @@ export function findAllNestedLoopNodes(node) {
21
21
  loopNodes.push(currentNode);
22
22
  }
23
23
  // Recursively traverse children
24
- if (currentNode.children) {
24
+ if (currentNode.children && !currentNode.isComponent) {
25
25
  for (const child of currentNode.children) {
26
26
  traverse(child);
27
27
  }
28
28
  }
29
29
  }
30
30
  // Start traversal from the node's children (not the node itself, as it's already being processed)
31
- if (node.children) {
31
+ if (node.children && !node.isComponent) {
32
32
  for (const child of node.children) {
33
33
  traverse(child);
34
34
  }