@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.
- package/README.md +46 -8
- package/dist/a11y/focus-trap.d.ts +11 -3
- package/dist/a11y/focus-trap.d.ts.map +1 -1
- package/dist/a11y/focus-trap.js +55 -10
- package/dist/a11y/focus-trap.js.map +1 -1
- package/dist/a11y/index.d.ts +4 -4
- package/dist/a11y/index.js +4 -4
- package/dist/a11y/index.js.map +1 -1
- package/dist/a11y/keyboard-utils.js.map +1 -1
- package/dist/a11y/roving-tabindex.js.map +1 -1
- package/dist/a11y/skip-link.js.map +1 -1
- package/dist/compile/bindSwitchCases.d.ts +8 -3
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +137 -183
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindAfterComponents.d.ts +4 -0
- package/dist/compile/binds/bindAfterComponents.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterComponents.js +26 -0
- package/dist/compile/binds/bindAfterComponents.js.map +1 -0
- package/dist/compile/binds/bindAfterProjection.d.ts +7 -0
- package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -0
- package/dist/compile/binds/bindAfterProjection.js +15 -0
- package/dist/compile/binds/bindAfterProjection.js.map +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts +8 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.js +227 -21
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +58 -21
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +186 -74
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindConditionals.d.ts +2 -2
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
- package/dist/compile/binds/bindConditionals.js +22 -5
- package/dist/compile/binds/bindConditionals.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +21 -19
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts +61 -0
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +272 -16
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
- package/dist/compile/binds/bindEventHandlers.js +15 -5
- package/dist/compile/binds/bindEventHandlers.js.map +1 -1
- package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindRefDirectives.js +2 -1
- package/dist/compile/binds/bindRefDirectives.js.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
- package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindStyleDirectives.js +48 -0
- package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +4 -2
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +87 -35
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/binds/declaredDirective.d.ts +12 -0
- package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
- package/dist/compile/binds/declaredDirective.js +42 -0
- package/dist/compile/binds/declaredDirective.js.map +1 -0
- package/dist/compile/binds/directiveRegistry.js.map +1 -1
- package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
- package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
- package/dist/compile/binds/forwardedAttrs.js +10 -2
- package/dist/compile/binds/forwardedAttrs.js.map +1 -1
- package/dist/compile/binds/propNames.d.ts +14 -0
- package/dist/compile/binds/propNames.d.ts.map +1 -0
- package/dist/compile/binds/propNames.js +116 -0
- package/dist/compile/binds/propNames.js.map +1 -0
- package/dist/compile/binds/staleRowProps.d.ts +9 -0
- package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
- package/dist/compile/binds/staleRowProps.js +86 -0
- package/dist/compile/binds/staleRowProps.js.map +1 -0
- package/dist/compile/compileExpression.js.map +1 -1
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +16 -7
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts +3 -4
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +36 -54
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/componentResult.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +15 -3
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +90 -9
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/disposeOrder.d.ts +35 -0
- package/dist/compile/disposeOrder.d.ts.map +1 -0
- package/dist/compile/disposeOrder.js +81 -0
- package/dist/compile/disposeOrder.js.map +1 -0
- package/dist/compile/evalDiagnostics.d.ts +7 -0
- package/dist/compile/evalDiagnostics.d.ts.map +1 -0
- package/dist/compile/evalDiagnostics.js +8 -0
- package/dist/compile/evalDiagnostics.js.map +1 -0
- package/dist/compile/forLoops/bindForLoops.d.ts +3 -3
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
- package/dist/compile/forLoops/bindForLoops.js +18 -13
- package/dist/compile/forLoops/bindForLoops.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +44 -26
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/forLoops/index.d.ts +5 -5
- package/dist/compile/forLoops/index.js +5 -5
- package/dist/compile/forLoops/index.js.map +1 -1
- package/dist/compile/forLoops/loopHelpers.js.map +1 -1
- package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
- package/dist/compile/forLoops/loopSignals.js +15 -1
- package/dist/compile/forLoops/loopSignals.js.map +1 -1
- package/dist/compile/forLoops/loopTraversal.js +2 -2
- package/dist/compile/forLoops/loopTraversal.js.map +1 -1
- package/dist/compile/handleConditionalChain.d.ts +2 -2
- package/dist/compile/handleConditionalChain.d.ts.map +1 -1
- package/dist/compile/handleConditionalChain.js +23 -89
- package/dist/compile/handleConditionalChain.js.map +1 -1
- package/dist/compile/index.d.ts +17 -17
- package/dist/compile/index.js +14 -14
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/injectScopedStyle.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +28 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js +12 -0
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/parseHtml.js +12 -6
- package/dist/compile/parseHtml.js.map +1 -1
- package/dist/compile/pithyTreeToDom.d.ts.map +1 -1
- package/dist/compile/pithyTreeToDom.js +17 -12
- package/dist/compile/pithyTreeToDom.js.map +1 -1
- package/dist/compile/renderBranch.d.ts +13 -0
- package/dist/compile/renderBranch.d.ts.map +1 -0
- package/dist/compile/renderBranch.js +72 -0
- package/dist/compile/renderBranch.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +12 -2
- package/dist/compile/renderChildren.d.ts.map +1 -1
- package/dist/compile/renderChildren.js +33 -4
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +65 -37
- package/dist/compile/ssrCrashes.d.ts.map +1 -1
- package/dist/compile/ssrCrashes.js +344 -39
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/compile/ssrMode.js +1 -1
- package/dist/compile/ssrMode.js.map +1 -1
- package/dist/compile/textValue.js.map +1 -1
- package/dist/compile/trimBlankEdges.d.ts +2 -0
- package/dist/compile/trimBlankEdges.d.ts.map +1 -0
- package/dist/compile/trimBlankEdges.js +15 -0
- package/dist/compile/trimBlankEdges.js.map +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/ref-signal.interface.js.map +1 -1
- package/dist/interfaces/ref.interface.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts +9 -5
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +130 -43
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts +2 -2
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +143 -87
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
- package/dist/runtime/bindings/applyDefer.js +16 -15
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +10 -1
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +117 -46
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +140 -124
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts +8 -1
- package/dist/runtime/bindings/helpers.d.ts.map +1 -1
- package/dist/runtime/bindings/helpers.js +36 -2
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +6 -6
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +5 -5
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/runtime/bindings/types.d.ts +2 -0
- package/dist/runtime/bindings/types.d.ts.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +1 -1
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/createContextProxy.js.map +1 -1
- package/dist/runtime/deferHelpers.d.ts +1 -1
- package/dist/runtime/deferHelpers.js.map +1 -1
- package/dist/runtime/html.js +7 -7
- package/dist/runtime/html.js.map +1 -1
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lazy.js +1 -1
- package/dist/runtime/lazy.js.map +1 -1
- package/dist/runtime/module-cache.js.map +1 -1
- package/dist/runtime/onDestroy.d.ts +7 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -1
- package/dist/runtime/onDestroy.js +16 -1
- package/dist/runtime/onDestroy.js.map +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
- package/dist/runtime/resource/createAction.d.ts +1 -1
- package/dist/runtime/resource/createAction.js +1 -1
- package/dist/runtime/resource/createAction.js.map +1 -1
- package/dist/runtime/resource/createResource.d.ts +1 -1
- package/dist/runtime/resource/createResource.d.ts.map +1 -1
- package/dist/runtime/resource/createResource.js +3 -4
- package/dist/runtime/resource/createResource.js.map +1 -1
- package/dist/runtime/resource/engine.d.ts +1 -1
- package/dist/runtime/resource/engine.js.map +1 -1
- package/dist/runtime/resource/index.d.ts +3 -3
- package/dist/runtime/resource/index.js +2 -2
- package/dist/runtime/resource/index.js.map +1 -1
- package/dist/runtime/resource/types.js.map +1 -1
- package/dist/types/globals.d.ts +10 -2
- package/dist/types/globals.d.ts.map +1 -1
- package/dist/types/globals.js.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.d.ts +2 -2
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/ref-signal.utility.d.ts +1 -1
- package/dist/utilities/ref-signal.utility.js.map +1 -1
- package/dist/utilities/ref.untility.d.ts +1 -1
- package/dist/utilities/ref.untility.js.map +1 -1
- package/package.json +11 -6
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
"category": "directive"
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { loopConflictMessage } from '@pithyjs/compiler';
|
|
9
|
+
import { compileExpression } from '../compileExpression.js';
|
|
10
|
+
import { createLoopManager } from './createLoopManager.js';
|
|
10
11
|
import { effect } from '@pithyjs/signals';
|
|
11
|
-
import { findAllNestedLoopNodes } from './loopTraversal';
|
|
12
|
-
import { isSSRMode } from '../ssrMode';
|
|
13
|
-
import { nodeExpando } from '../nodeExpando';
|
|
14
|
-
import { compileTrackBy } from './loopHelpers';
|
|
12
|
+
import { findAllNestedLoopNodes } from './loopTraversal.js';
|
|
13
|
+
import { isSSRMode } from '../ssrMode.js';
|
|
14
|
+
import { nodeExpando } from '../nodeExpando.js';
|
|
15
|
+
import { compileTrackBy } from './loopHelpers.js';
|
|
16
|
+
import { anchorDisposer, blockDisposer } from '../disposeOrder.js';
|
|
17
|
+
const warnedConflicts = new WeakSet();
|
|
15
18
|
/**
|
|
16
19
|
* Bind all @for loops found under `rootEl` using the parsed AST nodes.
|
|
17
20
|
*
|
|
@@ -22,16 +25,14 @@ import { compileTrackBy } from './loopHelpers';
|
|
|
22
25
|
* - trackBy is compiled once per loop node and re-used.
|
|
23
26
|
* - Each loop gets its own LoopManager which does minimal DOM moves and cleanup on dispose.
|
|
24
27
|
*/
|
|
25
|
-
/** @codexApi {"parent":"pithy.directive.for","name":"bindForLoops","stability":"stable","signature":"(nodes: PithyNode[], rootEl:
|
|
28
|
+
/** @codexApi {"parent":"pithy.directive.for","name":"bindForLoops","stability":"stable","signature":"(nodes: PithyNode[], rootEl: Element | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>) => void"} */
|
|
26
29
|
export function bindForLoops(nodes, rootEl, ctx, disposers = [], processedNodeIds = new Set()) {
|
|
27
30
|
// ---------------------------------------------------------------------------
|
|
28
31
|
// Build a map of nodeId -> DOM anchor (either an element with data-pid or a comment node)
|
|
29
32
|
// ---------------------------------------------------------------------------
|
|
30
33
|
const nodeMap = new Map();
|
|
31
34
|
// Elements: [data-pid="..."]
|
|
32
|
-
rootEl
|
|
33
|
-
.querySelectorAll?.('[data-pid]')
|
|
34
|
-
.forEach(el => {
|
|
35
|
+
rootEl.querySelectorAll?.('[data-pid]').forEach(el => {
|
|
35
36
|
const pid = el.getAttribute('data-pid');
|
|
36
37
|
if (pid)
|
|
37
38
|
nodeMap.set(pid, el);
|
|
@@ -85,6 +86,11 @@ export function bindForLoops(nodes, rootEl, ctx, disposers = [], processedNodeId
|
|
|
85
86
|
}
|
|
86
87
|
if (!node.directives?.for)
|
|
87
88
|
continue; // safety
|
|
89
|
+
if (import.meta.env?.DEV && !warnedConflicts.has(node)) {
|
|
90
|
+
warnedConflicts.add(node);
|
|
91
|
+
for (const name of node.loopConflicts ?? [])
|
|
92
|
+
console.warn(`[pithy] ${loopConflictMessage(node.originalTagName ?? node.tagName ?? '', name)}`);
|
|
93
|
+
}
|
|
88
94
|
const { itemVar, indexVar, collectionExpr } = node.directives.for;
|
|
89
95
|
const trackExpr = node.directives.for.trackBy || node.attrs?.track;
|
|
90
96
|
// Compile collection getter once (closes over ctx)
|
|
@@ -98,8 +104,6 @@ export function bindForLoops(nodes, rootEl, ctx, disposers = [], processedNodeId
|
|
|
98
104
|
itemVar,
|
|
99
105
|
indexVar,
|
|
100
106
|
});
|
|
101
|
-
// Ensure we can dispose everything later
|
|
102
|
-
disposers.push(() => loopManager.destroyAll());
|
|
103
107
|
// Shared logic for evaluating and updating the loop
|
|
104
108
|
function evaluateAndUpdate() {
|
|
105
109
|
try {
|
|
@@ -127,13 +131,14 @@ export function bindForLoops(nodes, rootEl, ctx, disposers = [], processedNodeId
|
|
|
127
131
|
if (isSSRMode()) {
|
|
128
132
|
// SSR mode: evaluate once synchronously, no reactive effects
|
|
129
133
|
evaluateAndUpdate();
|
|
134
|
+
disposers.push(anchorDisposer(() => loopManager.destroyAll(), anchor));
|
|
130
135
|
}
|
|
131
136
|
else {
|
|
132
137
|
// Client mode: reactive subscription for dynamic updates
|
|
133
138
|
const stop = effect(() => {
|
|
134
139
|
evaluateAndUpdate();
|
|
135
140
|
});
|
|
136
|
-
disposers.push(stop);
|
|
141
|
+
disposers.push(blockDisposer(stop, () => loopManager.destroyAll(), anchor));
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindForLoops.js","sourceRoot":"","sources":["../../../src/compile/forLoops/bindForLoops.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;;;GASG;AACH,yQAAyQ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C,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;YAAC,OAAO,GAAY,EAAE,CAAC;gBACtB,2FAA2F;gBAC3F,IACE,CAAC,CAAC,GAAG,YAAY,cAAc,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EACtE,CAAC;oBACD,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,GAAG,CAAC,CAAC;gBACnE,CAAC;gBACD,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,IAAI,SAAS,EAAE,EAAE,CAAC;YAChB,6DAA6D;YAC7D,iBAAiB,EAAE,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,yDAAyD;YACzD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE;gBACvB,iBAAiB,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,IAAI,CACZ,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.for\",\n \"title\": \"For Loop Directive\",\n \"category\": \"directive\"\n}\n*/\n\nimport { loopConflictMessage, type PithyNode } from '@pithyjs/compiler';\nimport { compileExpression } from '../compileExpression';\nimport { createLoopManager } from './createLoopManager';\nimport { effect } from '@pithyjs/signals';\nimport { findAllNestedLoopNodes } from './loopTraversal';\nimport { isSSRMode } from '../ssrMode';\nimport { nodeExpando } from '../nodeExpando';\nimport { compileTrackBy } from './loopHelpers';\nimport { anchorDisposer, blockDisposer } from '../disposeOrder';\n\nconst warnedConflicts = new WeakSet<PithyNode>();\n\n/**\n * Bind all @for loops found under `rootEl` using the parsed AST nodes.\n *\n * Key points:\n * - We build a nodeId -> DOM \"anchor\" map for both element placeholders ([data-pid]) and\n * comment anchors (set by the compiler/runtime) so we can locate the correct insertion point.\n * - We cache nested loop nodes on the AST node (`__nested`) to avoid repeated deep traversals.\n * - trackBy is compiled once per loop node and re-used.\n * - Each loop gets its own LoopManager which does minimal DOM moves and cleanup on dispose.\n */\n/** @codexApi {\"parent\":\"pithy.directive.for\",\"name\":\"bindForLoops\",\"stability\":\"stable\",\"signature\":\"(nodes: PithyNode[], rootEl: Element | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>) => void\"} */\nexport function bindForLoops(\n nodes: PithyNode[],\n rootEl: Element | DocumentFragment,\n ctx: Record<string, unknown>,\n disposers: (() => void)[] = [],\n processedNodeIds: Set<string> = new Set()\n): void {\n // ---------------------------------------------------------------------------\n // Build a map of nodeId -> DOM anchor (either an element with data-pid or a comment node)\n // ---------------------------------------------------------------------------\n const nodeMap = new Map<string, Element | Comment>();\n\n // Elements: [data-pid=\"...\"]\n rootEl.querySelectorAll?.('[data-pid]').forEach(el => {\n const pid = el.getAttribute('data-pid');\n if (pid) nodeMap.set(pid, el);\n });\n\n // Comment anchors: walk all comment nodes and read the private __nodeId we attach during compile\n const walker = document.createTreeWalker(rootEl, NodeFilter.SHOW_COMMENT);\n let comment: Comment | null;\n while ((comment = walker.nextNode() as Comment | null)) {\n const nodeId = nodeExpando(comment).__nodeId;\n if (nodeId) nodeMap.set(nodeId, comment);\n }\n\n // ---------------------------------------------------------------------------\n // Collect all loop nodes (top-level + nested) with caching per AST node\n // ---------------------------------------------------------------------------\n const allLoopNodes: PithyNode[] = [];\n\n // top-level loops - also check processedNodeIds to skip loops already handled by conditionals\n for (const node of nodes) {\n if (node.type === 'element' && node.directives?.for) {\n // Skip if this loop was already processed (e.g., by handleConditionalChain)\n if (node.nodeId && processedNodeIds.has(node.nodeId)) {\n continue;\n }\n allLoopNodes.push(node);\n }\n }\n\n // nested loops inside each node (cache once per AST node)\n // IMPORTANT: Only process nested loops for non-loop nodes (like conditionals).\n // Loops inside other loops will be handled by the parent loop's createLoopItem.\n for (const node of nodes) {\n // Skip finding nested loops if this node itself is a loop\n // (nested loops inside a loop will be handled by createLoopItem)\n if (node.type === 'element' && node.directives?.for) {\n continue;\n }\n\n const cacheNode = node as PithyNode & { __nested?: PithyNode[] };\n const nested: PithyNode[] =\n cacheNode.__nested ?? (cacheNode.__nested = findAllNestedLoopNodes(node));\n\n if (nested && nested.length) {\n // Filter out any nested loops that were already processed by conditionals\n const unprocessedNested = nested.filter(\n n => !n.nodeId || !processedNodeIds.has(n.nodeId)\n );\n\n allLoopNodes.push(...unprocessedNested);\n }\n }\n\n // ---------------------------------------------------------------------------\n // Bind each loop node found\n // ---------------------------------------------------------------------------\n for (const node of allLoopNodes) {\n const anchor = node.nodeId ? nodeMap.get(node.nodeId) : null;\n\n if (!(anchor instanceof Comment)) {\n continue; // loop anchor must be a comment\n }\n\n if (!node.directives?.for) continue; // safety\n\n if (import.meta.env?.DEV && !warnedConflicts.has(node)) {\n warnedConflicts.add(node);\n for (const name of node.loopConflicts ?? [])\n console.warn(\n `[pithy] ${loopConflictMessage(node.originalTagName ?? node.tagName ?? '', name)}`\n );\n }\n\n const { itemVar, indexVar, collectionExpr } = node.directives.for;\n const trackExpr = node.directives.for.trackBy || node.attrs?.track;\n\n // Compile collection getter once (closes over ctx)\n const getCollection = compileExpression(collectionExpr, ctx);\n\n const getTrackBy = compileTrackBy(trackExpr, itemVar, indexVar, ctx);\n\n // Create a loop manager for this loop anchor\n const loopManager = createLoopManager({\n anchor,\n trackByFn: getTrackBy,\n parentCtx: ctx,\n itemVar,\n indexVar,\n });\n\n // Shared logic for evaluating and updating the loop\n function evaluateAndUpdate() {\n try {\n const coll = getCollection();\n if (Array.isArray(coll)) {\n loopManager.update(coll, node);\n } else {\n if (import.meta.env?.DEV) {\n console.warn('[bindForLoops] collection is not an array:', coll, {\n node,\n });\n }\n loopManager.update([], node);\n }\n } catch (err: unknown) {\n // Suppress TDZ/ReferenceErrors for nested loops (they'll be bound when child ctx is ready)\n if (\n !(err instanceof ReferenceError && /is not defined/.test(err.message))\n ) {\n console.error('[bindForLoops] error evaluating collection', err);\n }\n loopManager.update([], node);\n }\n }\n\n if (isSSRMode()) {\n // SSR mode: evaluate once synchronously, no reactive effects\n evaluateAndUpdate();\n disposers.push(anchorDisposer(() => loopManager.destroyAll(), anchor));\n } else {\n // Client mode: reactive subscription for dynamic updates\n const stop = effect(() => {\n evaluateAndUpdate();\n });\n disposers.push(\n blockDisposer(stop, () => loopManager.destroyAll(), anchor)\n );\n }\n }\n}\n"]}
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
* - Dev-time duplicate key detection.
|
|
20
20
|
*/
|
|
21
21
|
import type { PithyNode } from '@pithyjs/compiler';
|
|
22
|
-
import type { ChildFactory } from '../../runtime/bindings/types';
|
|
23
|
-
import { LoopSignals } from './loopSignals';
|
|
22
|
+
import type { ChildFactory } from '../../runtime/bindings/types.js';
|
|
23
|
+
import { LoopSignals } from './loopSignals.js';
|
|
24
24
|
export type { ChildFactory };
|
|
25
25
|
export interface LoopItem {
|
|
26
26
|
key: string;
|
|
27
|
-
fragment: DocumentFragment |
|
|
27
|
+
fragment: DocumentFragment | Element;
|
|
28
28
|
signals: LoopSignals;
|
|
29
29
|
start: Comment;
|
|
30
30
|
end: Comment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLoopManager.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/createLoopManager.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAQjE,OAAO,E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G,OAAO;IACtC,MAAM,EAAE,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACpD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,8KAA8K;AAC9K,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EACnC,MAAM,EACN,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,MAAM,EACN,aAAa,EACb,WAAW,GACZ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAmZxC"}
|
|
@@ -6,16 +6,19 @@
|
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
8
|
import { batch, createRoot, untrack } 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';
|
|
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
|
+
import { orderByDocument } from '../disposeOrder.js';
|
|
20
|
+
import { withBranchBoundary } from '../binds/bindErrorBoundary.js';
|
|
21
|
+
import { withinRender } from '../ssrCrashes.js';
|
|
19
22
|
/** First real element between [start..end] to use as a flash target. */
|
|
20
23
|
function firstElInRange(start, end) {
|
|
21
24
|
let n = start.nextSibling;
|
|
@@ -103,11 +106,19 @@ function restoreNodeMetadata(source, target, ctx) {
|
|
|
103
106
|
for (let i = 0; i < srcChildren.length; i++) {
|
|
104
107
|
restoreNodeMetadata(srcChildren[i], tgtChildren[i], ctx);
|
|
105
108
|
}
|
|
109
|
+
if (isTemplate(source) && isTemplate(target))
|
|
110
|
+
restoreNodeMetadata(source.content, target.content, ctx);
|
|
111
|
+
}
|
|
112
|
+
function isTemplate(node) {
|
|
113
|
+
return node.localName === 'template' && 'content' in node;
|
|
106
114
|
}
|
|
107
115
|
/** @codexApi {"parent":"pithy.directive.loop-manager","name":"createLoopManager","stability":"stable","signature":"<T>(options: LoopManagerOptions<T>) => LoopManager<T>"} */
|
|
108
116
|
export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar, templateNodes, itemFactory, }) {
|
|
109
117
|
// Map of key -> LoopItem (stable across updates as long as key is stable)
|
|
110
118
|
const items = new Map();
|
|
119
|
+
// Row keys in on-screen order. `items` keeps insertion order, which a
|
|
120
|
+
// reorder leaves behind, and the DOM may be detached by teardown time.
|
|
121
|
+
let order = [];
|
|
111
122
|
let cachedNestedLoopNodes = null;
|
|
112
123
|
let cachedTemplateFrag = null;
|
|
113
124
|
/**
|
|
@@ -117,6 +128,9 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
117
128
|
* - Else: compute minimal moves (LIS - Longest Increasing Subsequence), update signals, and reorder DOM ranges.
|
|
118
129
|
*/
|
|
119
130
|
function update(collection, node) {
|
|
131
|
+
withinRender(() => withBranchBoundary(anchor, () => updateNow(collection, node)));
|
|
132
|
+
}
|
|
133
|
+
function updateNow(collection, node) {
|
|
120
134
|
const liveParent = anchor.parentNode;
|
|
121
135
|
// Flashing Policy
|
|
122
136
|
const FLASH_ON_INSERT = true;
|
|
@@ -155,6 +169,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
155
169
|
if (existing)
|
|
156
170
|
syncSignals(existing, item, idx, collection.length);
|
|
157
171
|
});
|
|
172
|
+
order = order.filter(k => items.has(k));
|
|
158
173
|
return;
|
|
159
174
|
}
|
|
160
175
|
// Remove items that no longer exist
|
|
@@ -207,6 +222,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
207
222
|
}
|
|
208
223
|
// Insert everything at once before the anchor
|
|
209
224
|
safeInsertBefore(liveParent, batchFrag, anchor);
|
|
225
|
+
order = newKeys.filter(k => items.has(k));
|
|
210
226
|
return;
|
|
211
227
|
}
|
|
212
228
|
// Minimal-Move Path (LIS)
|
|
@@ -282,6 +298,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
282
298
|
cursor = created.start;
|
|
283
299
|
}
|
|
284
300
|
}
|
|
301
|
+
order = newKeys.filter(k => items.has(k));
|
|
285
302
|
}
|
|
286
303
|
function syncSignals(existing, item, idx, total) {
|
|
287
304
|
const prev = untrack(existing.signals.itemSig);
|
|
@@ -358,7 +375,7 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
358
375
|
nodeExpando(n).__pithyCtx = ctx;
|
|
359
376
|
}
|
|
360
377
|
// 3) Find nested loop nodes ONCE per AST source (cache on the node or in closure)
|
|
361
|
-
const astChildren = templateNodes ?? (node.children || []);
|
|
378
|
+
const astChildren = templateNodes ?? (node?.isComponent ? [] : node.children || []);
|
|
362
379
|
const allNestedLoopNodes = templateNodes
|
|
363
380
|
? (cachedNestedLoopNodes ?? (cachedNestedLoopNodes = templateNodes.flatMap(tn => {
|
|
364
381
|
// Include root template nodes that themselves carry @for
|
|
@@ -384,24 +401,16 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
384
401
|
}
|
|
385
402
|
// 5) Bind structural directives in the same order as compileTemplate
|
|
386
403
|
const disposers = [];
|
|
387
|
-
// 5a)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
// it removes @if/@else elements and replaces them with placeholders, so the
|
|
391
|
-
// cloned switch case content would be missing the conditional elements.
|
|
392
|
-
bindSwitchCases(astChildren, fragmentFromNode, ctx, new Set(), disposers);
|
|
393
|
-
// 5b) Bind conditionals inside this loop item (with loop context)
|
|
394
|
-
// This handles @if/@else inside each loop item
|
|
395
|
-
// Pass disposers so conditional effects are properly cleaned up when item is destroyed
|
|
396
|
-
// Note: Conditionals inside switch cases are already gone from the DOM (removed by switch),
|
|
397
|
-
// so this will only process conditionals outside switch blocks.
|
|
398
|
-
const conditionalProcessedIds = bindConditionals(astChildren, fragmentFromNode, ctx, new Set(), disposers);
|
|
404
|
+
// 5a) Switch/case, then conditionals outside switch cases
|
|
405
|
+
const structuralProcessedIds = bindSwitchCases(astChildren, fragmentFromNode, ctx, new Set(), disposers);
|
|
406
|
+
bindConditionals(astChildren, fragmentFromNode, ctx, structuralProcessedIds, disposers);
|
|
399
407
|
// 5c) Bind nested loops (pass processedNodeIds to skip loops inside conditionals)
|
|
400
408
|
const nestedLoopDisposers = [];
|
|
401
|
-
bindForLoops(allNestedLoopNodes, fragmentFromNode, ctx, nestedLoopDisposers,
|
|
409
|
+
bindForLoops(allNestedLoopNodes, fragmentFromNode, ctx, nestedLoopDisposers, structuralProcessedIds);
|
|
402
410
|
disposers.push(...nestedLoopDisposers);
|
|
403
411
|
// 5d) Bind template directives (text interpolations, events, etc.)
|
|
404
412
|
bindTemplateDirectives(fragmentFromNode, ctx, disposers);
|
|
413
|
+
orderByDocument(disposers);
|
|
405
414
|
// 5e) Mark top-level elements to prevent parent from re-binding their text content
|
|
406
415
|
for (const n of Array.from(fragmentFromNode.childNodes)) {
|
|
407
416
|
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -413,17 +422,26 @@ export function createLoopManager({ anchor, trackByFn, parentCtx, itemVar, index
|
|
|
413
422
|
const grouped = wrapInRange(start, fragmentFromNode, end);
|
|
414
423
|
// 8) Cleanup function: unsubscribe effects/listeners and detach DOM range
|
|
415
424
|
const destroy = () => {
|
|
416
|
-
for (
|
|
417
|
-
|
|
425
|
+
for (let i = disposers.length - 1; i >= 0; i--)
|
|
426
|
+
disposers[i]();
|
|
418
427
|
disposeRoot();
|
|
419
428
|
detachRange(start, end);
|
|
420
429
|
};
|
|
421
430
|
return { key, fragment: grouped, node, signals, start, end, destroy };
|
|
422
431
|
}
|
|
423
432
|
}
|
|
433
|
+
// Last row first.
|
|
424
434
|
function destroyAll() {
|
|
435
|
+
for (let i = order.length - 1; i >= 0; i--) {
|
|
436
|
+
const item = items.get(order[i]);
|
|
437
|
+
if (!item)
|
|
438
|
+
continue;
|
|
439
|
+
items.delete(order[i]);
|
|
440
|
+
item.destroy();
|
|
441
|
+
}
|
|
425
442
|
items.forEach(item => item.destroy());
|
|
426
443
|
items.clear();
|
|
444
|
+
order = [];
|
|
427
445
|
}
|
|
428
446
|
return { update, destroyAll };
|
|
429
447
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLoopManager.js","sourceRoot":"","sources":["../../../src/compile/forLoops/createLoopManager.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAkBF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;A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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';\nimport { orderByDocument } from '../disposeOrder';\nimport { withBranchBoundary } from '../binds/bindErrorBoundary';\nimport { withinRender } from '../ssrCrashes';\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 if (isTemplate(source) && isTemplate(target))\n restoreNodeMetadata(source.content, target.content, ctx);\n}\n\nfunction isTemplate(node: Node): node is HTMLTemplateElement {\n return (node as Element).localName === 'template' && 'content' in node;\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 // Row keys in on-screen order. `items` keeps insertion order, which a\n // reorder leaves behind, and the DOM may be detached by teardown time.\n let order: string[] = [];\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 withinRender(() =>\n withBranchBoundary(anchor, () => updateNow(collection, node))\n );\n }\n\n function updateNow(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 order = order.filter(k => items.has(k));\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 order = newKeys.filter(k => items.has(k));\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 order = newKeys.filter(k => items.has(k));\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 orderByDocument(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 (let i = disposers.length - 1; i >= 0; i--) disposers[i]();\n disposeRoot();\n detachRange(start, end);\n };\n\n return { key, fragment: grouped, node, signals, start, end, destroy };\n }\n }\n\n // Last row first.\n function destroyAll(): void {\n for (let i = order.length - 1; i >= 0; i--) {\n const item = items.get(order[i]);\n if (!item) continue;\n items.delete(order[i]);\n item.destroy();\n }\n items.forEach(item => item.destroy());\n items.clear();\n order = [];\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopHelpers.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;GAEG;AAEH,yLAAyL;AACzL;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAY,EACZ,OAAa,EACb,aAA0B;IAE1B,IAAI,aAAa,IAAI,aAAa,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QACzD,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CACV,8EAA8E,CAC/E,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,kMAAkM;AAClM;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAA0B,EAC1B,IAAyB;IAEzB,yEAAyE;IACzE,MAAM,QAAQ,GACZ,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtC,CAAC,CAAC,eAAe,IAAI,CAAC,MAAM,mBAAmB,IAAI,CAAC,MAAM,IAAI;QAC9D,CAAC,CAAC,GAAG,CAAC;IAEV,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAC/C,EAAE,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC,CAAC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JAAyJ;AACzJ,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,GAAY;IACtD,IAAI,CAAC,GAAqB,KAAK,CAAC,WAAW,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,CAAC,CAAC;QACnB,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC;QAClB,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACrC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,SAA6B,EAC7B,OAAe,EACf,QAA4B,EAC5B,GAA4B;IAE5B,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnD,iFAAiF;IACjF,8FAA8F;IAC9F,MAAM,EAAE,GAAG,IAAI,QAAQ,CACrB,KAAK,EACL,MAAM,EACN,OAAO,EACP;cACU,OAAO;QACb,QAAQ,CAAC,CAAC,CAAC,SAAS,QAAQ,WAAW,CAAC,CAAC,CAAC,EAAE;gBACpC,SAAS;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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopSignals.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/loopSignals.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAiB,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"loopSignals.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/loopSignals.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAiB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGzD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CACzB;AAED,gLAAgL;AAChL;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,WAAW,CAkBb;AAED,mLAAmL;AACnL;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,IAAI,CASN;AAED,6UAA6U;AAC7U;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,SAAU,EAClB,QAAQ,SAAU,EAClB,OAAO,SAAS,EAChB,OAAO,SAAS,EAChB,MAAM,SAAQ,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
}
|
|
7
7
|
*/
|
|
8
8
|
import { batch, signal } from '@pithyjs/signals';
|
|
9
|
+
import { rowLocalsOf } from '../binds/staleRowProps.js';
|
|
9
10
|
/** @codexApi {"parent":"pithy.directive.loop-signals","name":"createLoopSignals","stability":"stable","signature":"<T>(item: T, idx: number, total: number) => LoopSignals"} */
|
|
10
11
|
/**
|
|
11
12
|
* Creates all the reactive signals needed for a loop item
|
|
@@ -50,7 +51,7 @@ export function updateLoopSignals(signals, idx, total) {
|
|
|
50
51
|
* avoid shadowing in nested loops.
|
|
51
52
|
*/
|
|
52
53
|
export function createLoopContext(parentCtx, signals, itemVar, indexVar, countVar = 'count', firstVar = 'first', lastVar = 'last', evenVar = 'even', oddVar = 'odd') {
|
|
53
|
-
|
|
54
|
+
const ctx = {
|
|
54
55
|
...parentCtx,
|
|
55
56
|
[countVar]: signals.countSig,
|
|
56
57
|
[firstVar]: signals.firstSig,
|
|
@@ -60,5 +61,18 @@ export function createLoopContext(parentCtx, signals, itemVar, indexVar, countVa
|
|
|
60
61
|
[itemVar]: signals.itemSig,
|
|
61
62
|
...(indexVar ? { [indexVar]: signals.idxSig } : {}),
|
|
62
63
|
};
|
|
64
|
+
if (import.meta.env?.DEV) {
|
|
65
|
+
const locals = new Map(rowLocalsOf(parentCtx));
|
|
66
|
+
locals.set(countVar, signals.countSig);
|
|
67
|
+
locals.set(firstVar, signals.firstSig);
|
|
68
|
+
locals.set(lastVar, signals.lastSig);
|
|
69
|
+
locals.set(evenVar, signals.evenSig);
|
|
70
|
+
locals.set(oddVar, signals.oddSig);
|
|
71
|
+
locals.set(itemVar, signals.itemSig);
|
|
72
|
+
if (indexVar)
|
|
73
|
+
locals.set(indexVar, signals.idxSig);
|
|
74
|
+
ctx.__pithyRowLocals = locals;
|
|
75
|
+
}
|
|
76
|
+
return ctx;
|
|
63
77
|
}
|
|
64
78
|
//# 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;
|
|
1
|
+
{"version":3,"file":"loopSignals.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopSignals.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O,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,QAAQ;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACnD,GAAG,CAAC,gBAAgB,GAAG,MAAM,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,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';\nimport { rowLocalsOf, type RowLocals } from '../binds/staleRowProps';\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 const ctx: Record<string, unknown> = {\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 if (import.meta.env?.DEV) {\n const locals: RowLocals = new Map(rowLocalsOf(parentCtx));\n locals.set(countVar, signals.countSig);\n locals.set(firstVar, signals.firstSig);\n locals.set(lastVar, signals.lastSig);\n locals.set(evenVar, signals.evenSig);\n locals.set(oddVar, signals.oddSig);\n locals.set(itemVar, signals.itemSig);\n if (indexVar) locals.set(indexVar, signals.idxSig);\n ctx.__pithyRowLocals = locals;\n }\n return ctx;\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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopTraversal.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopTraversal.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;GAEG;AAEH,gKAAgK;AAChK;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAe;IACpD,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,SAAS,QAAQ,CAAC,WAAsB;QACtC,sDAAsD;QACtD,IAAI,WAAW,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;QAED,gCAAgC;QAChC,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"loopTraversal.js","sourceRoot":"","sources":["../../../src/compile/forLoops/loopTraversal.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;GAEG;AAEH,gKAAgK;AAChK;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAe;IACpD,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,SAAS,QAAQ,CAAC,WAAsB;QACtC,sDAAsD;QACtD,IAAI,WAAW,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;QAED,gCAAgC;QAChC,IAAI,WAAW,CAAC,QAAQ,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;YACrD,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;gBACzC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,kGAAkG;IAClG,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.loop-traversal\",\n \"title\": \"Loop Node Traversal\", \n \"category\": \"directive\"\n}\n*/\n\nimport type { PithyNode } from '@pithyjs/compiler';\n\n/**\n * Node traversal utilities for loop operations\n */\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-traversal\",\"name\":\"findAllNestedLoopNodes\",\"stability\":\"stable\",\"signature\":\"(node: PithyNode) => PithyNode[]\"} */\n/**\n * Recursively finds all nested loop nodes within a given node\n * Used to process nested loops before binding to preserve data-pid references\n */\nexport function findAllNestedLoopNodes(node: PithyNode): PithyNode[] {\n const loopNodes: PithyNode[] = [];\n\n function traverse(currentNode: PithyNode) {\n // If this node has a @for directive, it's a loop node\n if (currentNode.directives?.for) {\n loopNodes.push(currentNode);\n }\n\n // Recursively traverse children\n if (currentNode.children && !currentNode.isComponent) {\n for (const child of currentNode.children) {\n traverse(child);\n }\n }\n }\n\n // Start traversal from the node's children (not the node itself, as it's already being processed)\n if (node.children && !node.isComponent) {\n for (const child of node.children) {\n traverse(child);\n }\n }\n\n return loopNodes;\n}\n"]}
|
|
@@ -10,6 +10,6 @@ import type { PithyNode } from '@pithyjs/compiler';
|
|
|
10
10
|
* Handles rendering and reactivity for an @if/@else-if/@else chain.
|
|
11
11
|
* Returns a Set of all node IDs that were processed (to avoid double-binding).
|
|
12
12
|
*/
|
|
13
|
-
/** @codexApi {"parent":"pithy.directive.conditional-chain","name":"handleConditionalChain","stability":"stable","signature":"(domChain:
|
|
14
|
-
export declare function handleConditionalChain(domChain:
|
|
13
|
+
/** @codexApi {"parent":"pithy.directive.conditional-chain","name":"handleConditionalChain","stability":"stable","signature":"(domChain: Element[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>"} */
|
|
14
|
+
export declare function handleConditionalChain(domChain: Element[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]): Set<string>;
|
|
15
15
|
//# sourceMappingURL=handleConditionalChain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleConditionalChain.d.ts","sourceRoot":"","sources":["../../src/compile/handleConditionalChain.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;
|
|
1
|
+
{"version":3,"file":"handleConditionalChain.d.ts","sourceRoot":"","sources":["../../src/compile/handleConditionalChain.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD;;;GAGG;AACH,wRAAwR;AACxR,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,EACzC,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,GAC7B,GAAG,CAAC,MAAM,CAAC,CAmHb"}
|