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

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 (114) hide show
  1. package/README.md +25 -0
  2. package/dist/compile/bindSwitchCases.js +5 -2
  3. package/dist/compile/bindSwitchCases.js.map +1 -1
  4. package/dist/compile/binds/bindClassDirectives.d.ts +2 -0
  5. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  6. package/dist/compile/binds/bindClassDirectives.js +18 -15
  7. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  8. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  9. package/dist/compile/binds/bindComponentsTags.js +90 -33
  10. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  11. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  12. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  13. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  14. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
  15. package/dist/compile/binds/bindDeferDirectives.js +41 -11
  16. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  17. package/dist/compile/binds/bindErrorBoundary.d.ts +13 -2
  18. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  19. package/dist/compile/binds/bindErrorBoundary.js +20 -10
  20. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  21. package/dist/compile/binds/bindTextInterpolations.js +1 -1
  22. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  23. package/dist/compile/binds/forwardedAttrs.d.ts +22 -0
  24. package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -0
  25. package/dist/compile/binds/forwardedAttrs.js +66 -0
  26. package/dist/compile/binds/forwardedAttrs.js.map +1 -0
  27. package/dist/compile/componentResult.d.ts +100 -0
  28. package/dist/compile/componentResult.d.ts.map +1 -0
  29. package/dist/compile/componentResult.js +138 -0
  30. package/dist/compile/componentResult.js.map +1 -0
  31. package/dist/compile/contentProjection.d.ts.map +1 -1
  32. package/dist/compile/contentProjection.js +4 -10
  33. package/dist/compile/contentProjection.js.map +1 -1
  34. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
  35. package/dist/compile/forLoops/bindForLoops.js +2 -13
  36. package/dist/compile/forLoops/bindForLoops.js.map +1 -1
  37. package/dist/compile/forLoops/createLoopManager.d.ts +4 -1
  38. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  39. package/dist/compile/forLoops/createLoopManager.js +143 -104
  40. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  41. package/dist/compile/forLoops/loopHelpers.d.ts +6 -0
  42. package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -1
  43. package/dist/compile/forLoops/loopHelpers.js +17 -0
  44. package/dist/compile/forLoops/loopHelpers.js.map +1 -1
  45. package/dist/compile/forLoops/loopSignals.js +2 -2
  46. package/dist/compile/forLoops/loopSignals.js.map +1 -1
  47. package/dist/compile/handleConditionalChain.d.ts.map +1 -1
  48. package/dist/compile/handleConditionalChain.js +21 -18
  49. package/dist/compile/handleConditionalChain.js.map +1 -1
  50. package/dist/compile/index.d.ts +6 -3
  51. package/dist/compile/index.d.ts.map +1 -1
  52. package/dist/compile/index.js +19 -3
  53. package/dist/compile/index.js.map +1 -1
  54. package/dist/compile/renderChildren.d.ts +17 -0
  55. package/dist/compile/renderChildren.d.ts.map +1 -1
  56. package/dist/compile/renderChildren.js +20 -1
  57. package/dist/compile/renderChildren.js.map +1 -1
  58. package/dist/compile/ssrCrashes.d.ts +116 -0
  59. package/dist/compile/ssrCrashes.d.ts.map +1 -0
  60. package/dist/compile/ssrCrashes.js +173 -0
  61. package/dist/compile/ssrCrashes.js.map +1 -0
  62. package/dist/runtime/applyBindings.d.ts +3 -3
  63. package/dist/runtime/applyBindings.d.ts.map +1 -1
  64. package/dist/runtime/applyBindings.js +28 -4
  65. package/dist/runtime/applyBindings.js.map +1 -1
  66. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  67. package/dist/runtime/bindings/applyComponent.js +102 -13
  68. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  69. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
  70. package/dist/runtime/bindings/applyDefer.js +40 -12
  71. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  72. package/dist/runtime/bindings/applySimple.d.ts +2 -1
  73. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  74. package/dist/runtime/bindings/applySimple.js +27 -3
  75. package/dist/runtime/bindings/applySimple.js.map +1 -1
  76. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  77. package/dist/runtime/bindings/applyStructural.js +44 -62
  78. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  79. package/dist/runtime/bindings/index.d.ts +2 -2
  80. package/dist/runtime/bindings/index.d.ts.map +1 -1
  81. package/dist/runtime/bindings/index.js +1 -1
  82. package/dist/runtime/bindings/index.js.map +1 -1
  83. package/dist/runtime/bindings/types.d.ts +12 -1
  84. package/dist/runtime/bindings/types.d.ts.map +1 -1
  85. package/dist/runtime/index.d.ts +1 -0
  86. package/dist/runtime/index.d.ts.map +1 -1
  87. package/dist/runtime/index.js +2 -0
  88. package/dist/runtime/index.js.map +1 -1
  89. package/dist/runtime/resource/createAction.d.ts +44 -0
  90. package/dist/runtime/resource/createAction.d.ts.map +1 -0
  91. package/dist/runtime/resource/createAction.js +102 -0
  92. package/dist/runtime/resource/createAction.js.map +1 -0
  93. package/dist/runtime/resource/createResource.d.ts +56 -0
  94. package/dist/runtime/resource/createResource.d.ts.map +1 -0
  95. package/dist/runtime/resource/createResource.js +103 -0
  96. package/dist/runtime/resource/createResource.js.map +1 -0
  97. package/dist/runtime/resource/engine.d.ts +136 -0
  98. package/dist/runtime/resource/engine.d.ts.map +1 -0
  99. package/dist/runtime/resource/engine.js +363 -0
  100. package/dist/runtime/resource/engine.js.map +1 -0
  101. package/dist/runtime/resource/index.d.ts +19 -0
  102. package/dist/runtime/resource/index.d.ts.map +1 -0
  103. package/dist/runtime/resource/index.js +18 -0
  104. package/dist/runtime/resource/index.js.map +1 -0
  105. package/dist/runtime/resource/types.d.ts +240 -0
  106. package/dist/runtime/resource/types.d.ts.map +1 -0
  107. package/dist/runtime/resource/types.js +9 -0
  108. package/dist/runtime/resource/types.js.map +1 -0
  109. package/dist/types/globals.d.ts +9 -0
  110. package/dist/types/globals.d.ts.map +1 -1
  111. package/dist/types/globals.js.map +1 -1
  112. package/dist/types/index.d.ts +15 -1
  113. package/dist/types/index.d.ts.map +1 -1
  114. package/package.json +5 -5
@@ -0,0 +1,138 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.compile.component-result",
4
+ "title": "Component Result Validation",
5
+ "category": "compiler",
6
+ "risk": "high"
7
+ }
8
+ */
9
+ /**
10
+ * Is `value` something a binder can actually put into the document?
11
+ *
12
+ * A component contract is `{ el, destroy }`, and both binders used to accept it
13
+ * on the strength of `'el' in out` alone. That is a presence check, not a type
14
+ * check: `{ el: null }` satisfies it, and `el.replaceWith(null)` does not throw
15
+ * — the DOM stringifies the argument, so the page ships the literal text
16
+ * `null` where the component should have been.
17
+ *
18
+ * Measured before this guard existed, in SSR:
19
+ *
20
+ * ```
21
+ * records = 0 html = <div ...>null</div>
22
+ * ```
23
+ *
24
+ * Zero crashes reported, exit 0, and visible garbage in the output — worse than
25
+ * the raw unrendered tag BUG-018 was about, because that at least renders as
26
+ * nothing. TypeScript does not help: an app can be JavaScript, or can cast.
27
+ *
28
+ * `nodeType` alone is not enough, because it is just a property any object can
29
+ * have. `{ nodeType: 1, toString: () => 'BROKEN' }` passed an earlier version of
30
+ * this guard, and `replaceWith` then stringified it into the page exactly like
31
+ * `null` did:
32
+ *
33
+ * ```
34
+ * records = 0 html = <div ...>BROKEN</div>
35
+ * ```
36
+ *
37
+ * So the value must also really be a `Node`. That check has to work ACROSS
38
+ * realms, because a component may legitimately return a node built by another
39
+ * `Window` — an iframe's `contentDocument`, or a module-level `document`
40
+ * captured under a previous route's happy-dom window. A plain
41
+ * `instanceof Node` rejects those, and since both binders run this guard in the
42
+ * browser too, that would turn working components into "invalid render result".
43
+ *
44
+ * Two checks, in order of strength:
45
+ *
46
+ * 1. `instanceof` against the `Node` of `reference`'s realm — the placeholder
47
+ * the binder is replacing, which is by construction a real node in the
48
+ * document being rendered. This is the common case and the strongest
49
+ * signal. The realm comes from `reference` and NEVER from `value`: an
50
+ * earlier version read `value.ownerDocument.defaultView.Node`, which let the
51
+ * candidate nominate its own validator (`{ Node: Object }` passes trivially).
52
+ *
53
+ * 2. Failing that, a structural brand that survives realm boundaries. Real
54
+ * nodes expose `nodeType`, `nodeName` and `cloneNode` through their
55
+ * prototype; a hand-made object carries them as OWN properties, which is
56
+ * what separates a foreign `HTMLSpanElement` from
57
+ * `{ nodeType: 1, toString: () => 'BROKEN' }` — measured, both branches are
58
+ * tested.
59
+ *
60
+ * KNOWN LIMIT, stated rather than glossed: this is defeated by a deliberate
61
+ * forgery. `Object.create({ nodeType: 1, nodeName: 'SPAN', cloneNode() {} })`
62
+ * puts the whole shape on the prototype, so the own-vs-inherited test says
63
+ * "real node", and `replaceWith` then stringifies it into the page.
64
+ *
65
+ * The guard is not escalated further because every stronger static test is
66
+ * worse: `instanceof` alone rejects genuine foreign nodes, and `Symbol.toStringTag`
67
+ * defeats a `[object HTMLDivElement]` brand just as easily. The one check that
68
+ * cannot be forged is observing whether the node actually landed after
69
+ * `replaceWith` — that was implemented and REVERTED, because the JIT binds a
70
+ * structural branch on a detached tree first, where `replaceWith` legitimately
71
+ * does nothing and the retry does the real work: the observation could not tell
72
+ * that apart from stringification and failed `apps/gliora-dashboard`'s `/login`
73
+ * route, whose emitted HTML is in fact complete (4 form-field elements, 2 labels,
74
+ * 2 inputs, no raw tags).
75
+ *
76
+ * So the scope here is ACCIDENT, not adversary: a component returning the wrong
77
+ * shape by mistake — `{ el: null }`, `{ el: undefined }`, a bare options object —
78
+ * which is the failure that actually occurs. A component in your own app that
79
+ * deliberately forges DOM internals is not a threat this layer can address, and
80
+ * pretending otherwise would cost working pages. Tracked in docs/BACKLOG.md.
81
+ *
82
+ * Deliberately **not** an allowlist of node types. The question here is "is this
83
+ * a node at all", not "is it a node I like": a component returning
84
+ * `document.createTextNode('hi')` renders correctly through `replaceWith`, and
85
+ * an earlier version that admitted only elements and fragments silently narrowed
86
+ * the contract and dropped such a subtree. Anything that is a real node but
87
+ * cannot actually be inserted — a `Document`, say — throws inside `replaceWith`,
88
+ * which is already recorded as a failed replacement and gives a truthful error.
89
+ *
90
+ * Fails **open** when nothing can be resolved to check against. A guard that
91
+ * cannot check must not reject everything: with neither a realm on `reference`
92
+ * nor an ambient `Node`, rejecting would record a crash for every component and
93
+ * fail every route — far worse than the malformed output this guards against.
94
+ *
95
+ * @param value - the `el` a component returned
96
+ * @param reference - a node known to be real, whose realm defines `Node`
97
+ */
98
+ /** @codexApi {"parent":"pithy.compile.component-result","name":"isRenderableComponentEl","stability":"internal","signature":"(value: unknown, reference?: Node | null) => boolean"} */
99
+ export function isRenderableComponentEl(value, reference) {
100
+ if (!value || typeof value !== 'object')
101
+ return false;
102
+ if (typeof value.nodeType !== 'number') {
103
+ return false;
104
+ }
105
+ const NodeCtor = trustedNodeConstructor(reference);
106
+ if (typeof NodeCtor !== 'function')
107
+ return true;
108
+ if (value instanceof NodeCtor)
109
+ return true;
110
+ return hasCrossRealmNodeBrand(value);
111
+ }
112
+ /**
113
+ * Does `value` carry the DOM's own shape rather than a hand-made imitation of
114
+ * it? Used only for nodes from another realm, where `instanceof` cannot help.
115
+ *
116
+ * The discriminator is *own* versus *inherited*: a real node — local or foreign
117
+ * — gets these from `Node.prototype`, so `hasOwnProperty` is false for all of
118
+ * them, while an object literal has to declare each one itself.
119
+ */
120
+ function hasCrossRealmNodeBrand(value) {
121
+ const own = (key) => Object.prototype.hasOwnProperty.call(value, key);
122
+ if (own('nodeType') || own('nodeName') || own('cloneNode'))
123
+ return false;
124
+ const candidate = value;
125
+ return (typeof candidate.nodeName === 'string' &&
126
+ typeof candidate.cloneNode === 'function');
127
+ }
128
+ /**
129
+ * The `Node` constructor from `reference`'s realm, falling back to the ambient
130
+ * global. Deliberately never reads anything off the value being validated.
131
+ */
132
+ function trustedNodeConstructor(reference) {
133
+ const view = reference?.ownerDocument?.defaultView?.Node;
134
+ if (typeof view === 'function')
135
+ return view;
136
+ return globalThis.Node;
137
+ }
138
+ //# sourceMappingURL=componentResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentResult.js","sourceRoot":"","sources":["../../src/compile/componentResult.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,uLAAuL;AACvL,MAAM,UAAU,uBAAuB,CACrC,KAAc,EACd,SAAuB;IAEvB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,OAAQ,KAAgC,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACnE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACnD,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3C,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,KAAa;IAC3C,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9E,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,GA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nB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAyJN"}
1
+ {"version":3,"file":"contentProjection.d.ts","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE/E,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAaD,gMAAgM;AAChM,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,OAAO,CAiET;AAED,oKAAoK;AACpK,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA6BrE;AAED,qMAAqM;AACrM,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAqJN"}
@@ -151,18 +151,12 @@ export function mountProjection(slotDefs, slotMap, disposers) {
151
151
  current.textContent?.startsWith('slot:')) {
152
152
  break;
153
153
  }
154
- // Only remove nodes that belong to this slot
155
- if (expando(current).__slotName === name) {
156
- existingNodes.push(current);
157
- }
158
- else if (existingNodes.length === 0) {
159
- // First content after anchor should belong to this slot
160
- existingNodes.push(current);
161
- }
162
- else {
163
- // Hit content from different slot
154
+ // A sibling no projection marked is the component's own markup.
155
+ const meta = expando(current);
156
+ if (meta.__projectedContent === undefined || meta.__slotName !== name) {
164
157
  break;
165
158
  }
159
+ existingNodes.push(current);
166
160
  current = current.nextSibling;
167
161
  }
168
162
  // Simple diffing: only replace if content appears different
@@ -1 +1 @@
1
- {"version":3,"file":"contentProjection.js","sourceRoot":"","sources":["../../src/compile/contentProjection.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BhD,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO,IAAgC,CAAC;AAC1C,CAAC;AAED,gMAAgM;AAChM,MAAM,UAAU,cAAc,CAC5B,QAAqB,EACrB,aAAsC;IAEtC,MAAM,OAAO,GAAY,IAAI,GAAG,EAAE,CAAC;IACnC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAElD,mCAAmC;IACnC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,oCAAoC;QAEnF,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,kCAAkC;IAClC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CACrC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,UAAU,CAAC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AAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;gBAClE,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,GAAG,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC,sBAAsB,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CACT,6CAA6C,aAAa,CAAC,MAAM,oBAAoB,IAAI,GAAG,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,sEAAsE;IACtE,uEAAuE;IACvE,qEAAqE;IACrE,gDAAgD;AAClD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bindForLoops.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/bindForLoops.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQnD;;;;;;;;;GASG;AACH,yQAAyQ;AACzQ,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,WAAW,GAAG,gBAAgB,EACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,EAC9B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,GACxC,IAAI,CAuJN"}
1
+ {"version":3,"file":"bindForLoops.d.ts","sourceRoot":"","sources":["../../../src/compile/forLoops/bindForLoops.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AASnD;;;;;;;;;GASG;AACH,yQAAyQ;AACzQ,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,WAAW,GAAG,gBAAgB,EACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,EAC9B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,GACxC,IAAI,CAkIN"}
@@ -11,6 +11,7 @@ import { effect } from '@pithyjs/signals';
11
11
  import { findAllNestedLoopNodes } from './loopTraversal';
12
12
  import { isSSRMode } from '../ssrMode';
13
13
  import { nodeExpando } from '../nodeExpando';
14
+ import { compileTrackBy } from './loopHelpers';
14
15
  /**
15
16
  * Bind all @for loops found under `rootEl` using the parsed AST nodes.
16
17
  *
@@ -88,19 +89,7 @@ export function bindForLoops(nodes, rootEl, ctx, disposers = [], processedNodeId
88
89
  const trackExpr = node.directives.for.trackBy || node.attrs?.track;
89
90
  // Compile collection getter once (closes over ctx)
90
91
  const getCollection = compileExpression(collectionExpr, ctx);
91
- // Compile trackBy once, avoiding TDZ by using internal param names (__it/__idx)
92
- const getTrackBy = trackExpr
93
- ? (() => {
94
- // Returns a stable string key for each (item, index)
95
- // eslint-disable-next-line no-new-func -- trackBy key compilation is a core framework feature
96
- const fn = new Function('ctx', '__it', '__idx', `with (ctx) {
97
- const ${itemVar} = __it;
98
- ${indexVar ? `const ${indexVar} = __idx;` : ''}
99
- return (${trackExpr});
100
- }`);
101
- return (item, idx) => String(fn(ctx, item, idx));
102
- })()
103
- : (_item, idx) => String(idx);
92
+ const getTrackBy = compileTrackBy(trackExpr, itemVar, indexVar, ctx);
104
93
  // Create a loop manager for this loop anchor
105
94
  const loopManager = createLoopManager({
106
95
  anchor,
@@ -1 +1 @@
1
- {"version":3,"file":"bindForLoops.js","sourceRoot":"","sources":["../../../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ACpD,SAAS,iBAAiB;YACxB,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACN,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;wBACzB,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,IAAI,EAAE;4BAC/D,IAAI;yBACL,CAAC,CAAC;oBACL,CAAC;oBACD,WAAW,CAAC,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;QACtB,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,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -19,7 +19,9 @@
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';
22
23
  import { LoopSignals } from './loopSignals';
24
+ export type { ChildFactory };
23
25
  export interface LoopItem {
24
26
  key: string;
25
27
  fragment: DocumentFragment | HTMLElement;
@@ -41,11 +43,12 @@ export interface LoopManagerOptions<T> {
41
43
  evenVar?: string;
42
44
  oddVar?: string;
43
45
  templateNodes?: PithyNode[];
46
+ itemFactory?: ChildFactory;
44
47
  }
45
48
  export interface LoopManager<T = unknown> {
46
49
  update: (collection: T[], node?: PithyNode) => void;
47
50
  destroyAll: () => void;
48
51
  }
49
52
  /** @codexApi {"parent":"pithy.directive.loop-manager","name":"createLoopManager","stability":"stable","signature":"<T>(options: LoopManagerOptions<T>) => LoopManager<T>"} */
50
- export declare function createLoopManager<T>({ anchor, trackByFn, parentCtx, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar, templateNodes, }: LoopManagerOptions<T>): LoopManager<T>;
53
+ export declare function createLoopManager<T>({ anchor, trackByFn, parentCtx, itemVar, indexVar, countVar, firstVar, lastVar, evenVar, oddVar, templateNodes, itemFactory, }: LoopManagerOptions<T>): LoopManager<T>;
51
54
  //# sourceMappingURL=createLoopManager.d.ts.map
@@ -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;AAQnD,OAAO,EACL,WAAW,EAIZ,MAAM,eAAe,CAAC;AAwHvB,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,gBAAgB,GAAG,WAAW,CAAC;IACzC,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WA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AW,GACZ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAuYxC"}
@@ -5,7 +5,7 @@
5
5
  "category": "directive"
6
6
  }
7
7
  */
8
- import { batch } from '@pithyjs/signals';
8
+ import { batch, createRoot, untrack } from '@pithyjs/signals';
9
9
  import { pithyTreeToDom } from '../pithyTreeToDom';
10
10
  import { bindForLoops } from './bindForLoops';
11
11
  import { flashUpdate } from '../binds/bindTextInterpolations';
@@ -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,125 @@ 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.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) Bind switch/case statements FIRST
388
+ // IMPORTANT: bindSwitchCases must run BEFORE bindConditionals!
389
+ // Switch cases clone their content from DOM - if bindConditionals runs first,
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);
399
+ // 5c) Bind nested loops (pass processedNodeIds to skip loops inside conditionals)
400
+ const nestedLoopDisposers = [];
401
+ bindForLoops(allNestedLoopNodes, fragmentFromNode, ctx, nestedLoopDisposers, conditionalProcessedIds);
402
+ disposers.push(...nestedLoopDisposers);
403
+ // 5d) Bind template directives (text interpolations, events, etc.)
404
+ bindTemplateDirectives(fragmentFromNode, ctx, disposers);
405
+ // 5e) Mark top-level elements to prevent parent from re-binding their text content
406
+ for (const n of Array.from(fragmentFromNode.childNodes)) {
407
+ if (n.nodeType === Node.ELEMENT_NODE) {
408
+ nodeExpando(n).__pithySkipText = true;
409
+ }
372
410
  }
411
+ // 7) Wrap the whole item in [start..end] comments so we can move/remove it as a unit
412
+ const { start, end } = createItemRange(key);
413
+ const grouped = wrapInRange(start, fragmentFromNode, end);
414
+ // 8) Cleanup function: unsubscribe effects/listeners and detach DOM range
415
+ const destroy = () => {
416
+ for (const d of disposers)
417
+ d();
418
+ disposeRoot();
419
+ detachRange(start, end);
420
+ };
421
+ return { key, fragment: grouped, node, signals, start, end, destroy };
373
422
  }
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
423
  }
385
424
  function destroyAll() {
386
425
  items.forEach(item => item.destroy());