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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +13 -1
  2. package/dist/compile/binds/bindAfterProjection.d.ts.map +1 -1
  3. package/dist/compile/binds/bindAfterProjection.js +2 -0
  4. package/dist/compile/binds/bindAfterProjection.js.map +1 -1
  5. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  6. package/dist/compile/binds/bindClassDirectives.js +2 -1
  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 +36 -21
  10. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  11. package/dist/compile/binds/bindErrorBoundary.d.ts +31 -0
  12. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  13. package/dist/compile/binds/bindErrorBoundary.js +110 -13
  14. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  15. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
  16. package/dist/compile/binds/bindTextInterpolations.js +7 -5
  17. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  18. package/dist/compile/compileNodes.d.ts.map +1 -1
  19. package/dist/compile/compileNodes.js +8 -4
  20. package/dist/compile/compileNodes.js.map +1 -1
  21. package/dist/compile/compileTemplate.d.ts.map +1 -1
  22. package/dist/compile/compileTemplate.js +12 -8
  23. package/dist/compile/compileTemplate.js.map +1 -1
  24. package/dist/compile/contentProjection.d.ts +2 -2
  25. package/dist/compile/contentProjection.d.ts.map +1 -1
  26. package/dist/compile/contentProjection.js +22 -8
  27. package/dist/compile/contentProjection.js.map +1 -1
  28. package/dist/compile/evalDiagnostics.d.ts +7 -0
  29. package/dist/compile/evalDiagnostics.d.ts.map +1 -0
  30. package/dist/compile/evalDiagnostics.js +8 -0
  31. package/dist/compile/evalDiagnostics.js.map +1 -0
  32. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  33. package/dist/compile/forLoops/createLoopManager.js +5 -0
  34. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  35. package/dist/compile/nodeExpando.d.ts +2 -0
  36. package/dist/compile/nodeExpando.d.ts.map +1 -1
  37. package/dist/compile/nodeExpando.js.map +1 -1
  38. package/dist/compile/renderBranch.d.ts.map +1 -1
  39. package/dist/compile/renderBranch.js +7 -2
  40. package/dist/compile/renderBranch.js.map +1 -1
  41. package/dist/compile/ssrCrashes.d.ts +64 -36
  42. package/dist/compile/ssrCrashes.d.ts.map +1 -1
  43. package/dist/compile/ssrCrashes.js +342 -37
  44. package/dist/compile/ssrCrashes.js.map +1 -1
  45. package/dist/runtime/applyBindings.d.ts.map +1 -1
  46. package/dist/runtime/applyBindings.js +13 -3
  47. package/dist/runtime/applyBindings.js.map +1 -1
  48. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  49. package/dist/runtime/bindings/applyComponent.js +19 -17
  50. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  51. package/dist/runtime/bindings/applySimple.d.ts +7 -0
  52. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  53. package/dist/runtime/bindings/applySimple.js +22 -10
  54. package/dist/runtime/bindings/applySimple.js.map +1 -1
  55. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  56. package/dist/runtime/bindings/applyStructural.js +115 -105
  57. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  58. package/dist/runtime/bindings/index.d.ts +1 -1
  59. package/dist/runtime/bindings/index.d.ts.map +1 -1
  60. package/dist/runtime/bindings/index.js +1 -1
  61. package/dist/runtime/bindings/index.js.map +1 -1
  62. package/dist/types/globals.d.ts +6 -0
  63. package/dist/types/globals.d.ts.map +1 -1
  64. package/dist/types/globals.js.map +1 -1
  65. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"applyStructural.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI3E,wBAAgB,OAAO,CACrB,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAuHN;AAED,wBAAgB,QAAQ,CACtB,CAAC,EAAE,OAAO,EACV,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAoEN;AAiBD,wBAAgB,WAAW,CACzB,CAAC,EAAE,UAAU,EACb,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAqHN"}
1
+ {"version":3,"file":"applyStructural.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI3E,wBAAgB,OAAO,CACrB,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA0HN;AAED,wBAAgB,QAAQ,CACtB,CAAC,EAAE,OAAO,EACV,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA0EN;AAiBD,wBAAgB,WAAW,CACzB,CAAC,EAAE,UAAU,EACb,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA4HN"}
@@ -4,6 +4,8 @@ import { isSSRMode } from '../../compile/ssrMode.js';
4
4
  import { createLoopManager } from '../../compile/forLoops/createLoopManager.js';
5
5
  import { compileTrackBy } from '../../compile/forLoops/loopHelpers.js';
6
6
  import { anchorDisposer, blockDisposer } from '../../compile/disposeOrder.js';
7
+ import { withBranchBoundary } from '../../compile/binds/bindErrorBoundary.js';
8
+ import { withinRender } from '../../compile/ssrCrashes.js';
7
9
  import { createLoopContext, createLoopSignals, } from '../../compile/forLoops/loopSignals.js';
8
10
  // ─── Structural directive handlers ────────────────────────────────────────────
9
11
  export function applyIf(d, commentMap, ctx, disposers) {
@@ -43,28 +45,30 @@ export function applyIf(d, commentMap, ctx, disposers) {
43
45
  break;
44
46
  }
45
47
  }
46
- if (matchIndex >= 0) {
47
- try {
48
- const result = d.branches[matchIndex].factory(ctx);
49
- if (result?.el) {
50
- const nodes = result.el instanceof DocumentFragment
51
- ? Array.from(result.el.childNodes)
52
- : [result.el];
53
- const parent = anchor.parentNode;
54
- if (parent) {
55
- const insertRef = anchor.nextSibling;
56
- for (const node of nodes)
57
- parent.insertBefore(node, insertRef);
48
+ if (matchIndex >= 0)
49
+ withinRender(() => {
50
+ try {
51
+ const { factory } = d.branches[matchIndex];
52
+ const result = withBranchBoundary(anchor, () => factory(ctx));
53
+ if (result?.el) {
54
+ const nodes = result.el instanceof DocumentFragment
55
+ ? Array.from(result.el.childNodes)
56
+ : [result.el];
57
+ const parent = anchor.parentNode;
58
+ if (parent) {
59
+ const insertRef = anchor.nextSibling;
60
+ for (const node of nodes)
61
+ parent.insertBefore(node, insertRef);
62
+ }
63
+ if (typeof result.destroy === 'function')
64
+ disposers.push(anchorDisposer(result.destroy, anchor));
58
65
  }
59
- if (typeof result.destroy === 'function')
60
- disposers.push(anchorDisposer(result.destroy, anchor));
61
66
  }
62
- }
63
- catch (err) {
64
- if (import.meta.env?.DEV)
65
- console.error(`[AOT @if] Factory error:`, err);
66
- }
67
- }
67
+ catch (err) {
68
+ if (import.meta.env?.DEV)
69
+ console.error(`[AOT @if] Factory error:`, err);
70
+ }
71
+ });
68
72
  return;
69
73
  }
70
74
  // Pre-compile branch expressions once outside effect
@@ -86,35 +90,36 @@ export function applyIf(d, commentMap, ctx, disposers) {
86
90
  return;
87
91
  previousMatchIndex = matchIndex;
88
92
  clearCurrent();
89
- if (matchIndex >= 0) {
90
- try {
91
- const { factory } = d.branches[matchIndex];
92
- const result = createRoot(disposeRoot => {
93
- currentDisposers.push(disposeRoot);
94
- return factory(ctx);
95
- });
96
- if (result?.el) {
97
- const nodes = result.el instanceof DocumentFragment
98
- ? Array.from(result.el.childNodes)
99
- : [result.el];
100
- const parent = anchor.parentNode;
101
- if (parent) {
102
- const insertRef = anchor.nextSibling;
103
- for (const node of nodes)
104
- parent.insertBefore(node, insertRef);
93
+ if (matchIndex >= 0)
94
+ withinRender(() => {
95
+ try {
96
+ const { factory } = d.branches[matchIndex];
97
+ const result = createRoot(disposeRoot => {
98
+ currentDisposers.push(disposeRoot);
99
+ return withBranchBoundary(anchor, () => factory(ctx));
100
+ });
101
+ if (result?.el) {
102
+ const nodes = result.el instanceof DocumentFragment
103
+ ? Array.from(result.el.childNodes)
104
+ : [result.el];
105
+ const parent = anchor.parentNode;
106
+ if (parent) {
107
+ const insertRef = anchor.nextSibling;
108
+ for (const node of nodes)
109
+ parent.insertBefore(node, insertRef);
110
+ }
111
+ currentNodes = nodes;
112
+ if (typeof result.destroy === 'function')
113
+ currentDisposers.push(result.destroy);
114
+ else if (import.meta.env?.DEV)
115
+ console.warn('[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
105
116
  }
106
- currentNodes = nodes;
107
- if (typeof result.destroy === 'function')
108
- currentDisposers.push(result.destroy);
109
- else if (import.meta.env?.DEV)
110
- console.warn('[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
111
117
  }
112
- }
113
- catch (err) {
114
- if (import.meta.env?.DEV)
115
- console.error(`[AOT @if] Factory error:`, err);
116
- }
117
- }
118
+ catch (err) {
119
+ if (import.meta.env?.DEV)
120
+ console.error(`[AOT @if] Factory error:`, err);
121
+ }
122
+ });
118
123
  });
119
124
  disposers.push(blockDisposer(stopEffect, clearCurrent, anchor));
120
125
  }
@@ -129,25 +134,27 @@ export function applyFor(d, commentMap, ctx, disposers) {
129
134
  if (!parent)
130
135
  return;
131
136
  const insertBefore = anchor.nextSibling;
132
- for (let i = 0; i < collection.length; i++) {
133
- const itemCtx = buildItemContext(ctx, d, collection[i], i, collection.length);
134
- try {
135
- const result = d.factory(itemCtx);
136
- if (result?.el) {
137
- const nodes = result.el instanceof DocumentFragment
138
- ? Array.from(result.el.childNodes)
139
- : [result.el];
140
- for (const node of nodes)
141
- parent.insertBefore(node, insertBefore);
142
- if (typeof result.destroy === 'function')
143
- disposers.push(anchorDisposer(result.destroy, nodes[0] ?? anchor));
137
+ withinRender(() => withBranchBoundary(anchor, () => {
138
+ for (let i = 0; i < collection.length; i++) {
139
+ const itemCtx = buildItemContext(ctx, d, collection[i], i, collection.length);
140
+ try {
141
+ const result = d.factory(itemCtx);
142
+ if (result?.el) {
143
+ const nodes = result.el instanceof DocumentFragment
144
+ ? Array.from(result.el.childNodes)
145
+ : [result.el];
146
+ for (const node of nodes)
147
+ parent.insertBefore(node, insertBefore);
148
+ if (typeof result.destroy === 'function')
149
+ disposers.push(anchorDisposer(result.destroy, nodes[0] ?? anchor));
150
+ }
151
+ }
152
+ catch (err) {
153
+ if (import.meta.env?.DEV)
154
+ console.error(`[AOT @for] Factory error at index ${i}:`, err);
144
155
  }
145
156
  }
146
- catch (err) {
147
- if (import.meta.env?.DEV)
148
- console.error(`[AOT @for] Factory error at index ${i}:`, err);
149
- }
150
- }
157
+ }));
151
158
  return;
152
159
  }
153
160
  const collFn = compileExpression(d.expr, ctx, []);
@@ -224,24 +231,26 @@ export function applySwitch(d, pidMap, ctx, disposers) {
224
231
  }
225
232
  if (matchIndex === -1)
226
233
  matchIndex = defaultIndex;
227
- if (matchIndex >= 0) {
228
- try {
229
- const result = d.cases[matchIndex].factory(ctx);
230
- if (result?.el) {
231
- const nodes = result.el instanceof DocumentFragment
232
- ? Array.from(result.el.childNodes)
233
- : [result.el];
234
- for (const node of nodes)
235
- containerEl.appendChild(node);
236
- if (typeof result.destroy === 'function')
237
- disposers.push(anchorDisposer(result.destroy, containerEl));
234
+ if (matchIndex >= 0)
235
+ withinRender(() => {
236
+ try {
237
+ const { factory } = d.cases[matchIndex];
238
+ const result = withBranchBoundary(containerEl, () => factory(ctx), true);
239
+ if (result?.el) {
240
+ const nodes = result.el instanceof DocumentFragment
241
+ ? Array.from(result.el.childNodes)
242
+ : [result.el];
243
+ for (const node of nodes)
244
+ containerEl.appendChild(node);
245
+ if (typeof result.destroy === 'function')
246
+ disposers.push(anchorDisposer(result.destroy, containerEl));
247
+ }
238
248
  }
239
- }
240
- catch (err) {
241
- if (import.meta.env?.DEV)
242
- console.error(`[AOT @switch] Factory error:`, err);
243
- }
244
- }
249
+ catch (err) {
250
+ if (import.meta.env?.DEV)
251
+ console.error(`[AOT @switch] Factory error:`, err);
252
+ }
253
+ });
245
254
  return;
246
255
  }
247
256
  // Pre-compile switch expression and case values once outside effect
@@ -269,31 +278,32 @@ export function applySwitch(d, pidMap, ctx, disposers) {
269
278
  return;
270
279
  previousMatchIndex = matchIndex;
271
280
  clearCurrent();
272
- if (matchIndex >= 0) {
273
- try {
274
- const { factory } = d.cases[matchIndex];
275
- const result = createRoot(disposeRoot => {
276
- currentDisposers.push(disposeRoot);
277
- return factory(ctx);
278
- });
279
- if (result?.el) {
280
- const nodes = result.el instanceof DocumentFragment
281
- ? Array.from(result.el.childNodes)
282
- : [result.el];
283
- for (const node of nodes)
284
- containerEl.appendChild(node);
285
- currentNodes = nodes;
286
- if (typeof result.destroy === 'function')
287
- currentDisposers.push(result.destroy);
288
- else if (import.meta.env?.DEV)
289
- console.warn('[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
281
+ if (matchIndex >= 0)
282
+ withinRender(() => {
283
+ try {
284
+ const { factory } = d.cases[matchIndex];
285
+ const result = createRoot(disposeRoot => {
286
+ currentDisposers.push(disposeRoot);
287
+ return withBranchBoundary(containerEl, () => factory(ctx), true);
288
+ });
289
+ if (result?.el) {
290
+ const nodes = result.el instanceof DocumentFragment
291
+ ? Array.from(result.el.childNodes)
292
+ : [result.el];
293
+ for (const node of nodes)
294
+ containerEl.appendChild(node);
295
+ currentNodes = nodes;
296
+ if (typeof result.destroy === 'function')
297
+ currentDisposers.push(result.destroy);
298
+ else if (import.meta.env?.DEV)
299
+ console.warn('[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch');
300
+ }
290
301
  }
291
- }
292
- catch (err) {
293
- if (import.meta.env?.DEV)
294
- console.error(`[AOT @switch] Factory error:`, err);
295
- }
296
- }
302
+ catch (err) {
303
+ if (import.meta.env?.DEV)
304
+ console.error(`[AOT @switch] Factory error:`, err);
305
+ }
306
+ });
297
307
  });
298
308
  disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));
299
309
  }
@@ -1 +1 @@
1
- {"version":3,"file":"applyStructural.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,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CAAC,GAAG,EAAE,GAAG;wBAC3B,OAAO,CAAC,IAAI,CACV,kHAAkH,CACnH,CAAC;gBACN,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;oBACtB,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { createRoot, effect } from '@pithyjs/signals';\nimport { compileExpression } from '../../compile/compileExpression';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { createLoopManager } from '../../compile/forLoops/createLoopManager';\nimport { compileTrackBy } from '../../compile/forLoops/loopHelpers';\nimport { anchorDisposer, blockDisposer } from '../../compile/disposeOrder';\nimport {\n createLoopContext,\n createLoopSignals,\n} from '../../compile/forLoops/loopSignals';\nimport type { IfDesc, ForDesc, SwitchDesc, BindingContext } from './types';\n\n// ─── Structural directive handlers ────────────────────────────────────────────\n\nexport function applyIf(\n d: IfDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`if:${d.pid}`);\n if (!anchor) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n // SSR: evaluate once synchronously\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n const b = d.branches[i];\n if (b.expr === undefined) {\n matchIndex = i;\n break;\n }\n const fn = compileExpression(b.expr, ctx, false);\n if (fn()) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex >= 0) {\n try {\n const result = d.branches[matchIndex].factory(ctx);\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, anchor));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n }\n return;\n }\n\n // Pre-compile branch expressions once outside effect\n const branchEvaluators = d.branches.map(b =>\n b.expr !== undefined ? compileExpression(b.expr, ctx, false) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n if (branchEvaluators[i] === null) {\n matchIndex = i;\n break;\n }\n if (branchEvaluators[i]!()) {\n matchIndex = i;\n break;\n }\n }\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0) {\n try {\n const { factory } = d.branches[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return factory(ctx);\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n }\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, anchor));\n}\n\nexport function applyFor(\n d: ForDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`for:${d.pid}`);\n if (!anchor) return;\n\n if (isSSRMode()) {\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const collection = collFn() ?? [];\n const parent = anchor.parentNode;\n if (!parent) return;\n\n const insertBefore: Node | null = anchor.nextSibling;\n for (let i = 0; i < collection.length; i++) {\n const itemCtx = buildItemContext(\n ctx,\n d,\n collection[i],\n i,\n collection.length\n );\n try {\n const result = d.factory(itemCtx);\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) parent.insertBefore(node, insertBefore);\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, nodes[0] ?? anchor));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @for] Factory error at index ${i}:`, err);\n }\n }\n return;\n }\n\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const loopManager = createLoopManager({\n anchor,\n trackByFn: compileTrackBy(d.trackBy, d.item, d.index, ctx),\n parentCtx: ctx,\n itemVar: d.item,\n indexVar: d.index,\n itemFactory: itemCtx => {\n const result = d.factory(itemCtx);\n const el = document.createDocumentFragment();\n if (result?.el) el.append(result.el);\n return { el, destroy: result?.destroy ?? (() => {}) };\n },\n });\n\n const stopEffect = effect(() => {\n try {\n const collection = collFn();\n if (!Array.isArray(collection) && import.meta.env?.DEV)\n console.warn('[AOT @for] collection is not an array:', collection);\n loopManager.update(Array.isArray(collection) ? collection : []);\n } catch (err) {\n if (import.meta.env?.DEV) console.error('[AOT @for] update failed:', err);\n loopManager.update([]);\n }\n });\n\n disposers.push(\n blockDisposer(stopEffect, () => loopManager.destroyAll(), anchor)\n );\n}\n\nfunction buildItemContext(\n parentCtx: BindingContext,\n d: ForDesc,\n item: unknown,\n index: number,\n length: number\n): BindingContext {\n return createLoopContext(\n parentCtx,\n createLoopSignals(item, index, length),\n d.item,\n d.index\n );\n}\n\nexport function applySwitch(\n d: SwitchDesc,\n pidMap: Map<string, Element>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const containerEl = pidMap.get(d.pid);\n if (!containerEl) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n const switchVal = compileExpression(d.expr, ctx)();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n const c = d.cases[i];\n if (c.val === undefined) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n const caseVal = compileExpression(c.val, ctx)();\n if (caseVal === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n if (matchIndex >= 0) {\n try {\n const result = d.cases[matchIndex].factory(ctx);\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, containerEl));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n }\n return;\n }\n\n // Pre-compile switch expression and case values once outside effect\n const switchEval = compileExpression(d.expr, ctx);\n const caseEvals = d.cases.map(c =>\n c.val !== undefined ? compileExpression(c.val, ctx) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n const switchVal = switchEval();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n if (caseEvals[i] === null) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n if (caseEvals[i]!() === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0) {\n try {\n const { factory } = d.cases[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return factory(ctx);\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n }\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));\n}\n"]}
1
+ {"version":3,"file":"applyStructural.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyStructural.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAG5C,iFAAiF;AAEjF,MAAM,UAAU,OAAO,CACr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AAM,CAAC,EAAE,CAAC,UAAU,CAAC;4BAClC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBAClB,KAAK,MAAM,IAAI,IAAI,KAAK;4BAAE,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBACxD,YAAY,GAAG,KAAK,CAAC;wBACrB,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU;4BACtC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;6BACnC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;4BAC3B,OAAO,CAAC,IAAI,CACV,kHAAkH,CACnH,CAAC;oBACN,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;wBACtB,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { createRoot, effect } from '@pithyjs/signals';\nimport { compileExpression } from '../../compile/compileExpression';\nimport { isSSRMode } from '../../compile/ssrMode';\nimport { createLoopManager } from '../../compile/forLoops/createLoopManager';\nimport { compileTrackBy } from '../../compile/forLoops/loopHelpers';\nimport { anchorDisposer, blockDisposer } from '../../compile/disposeOrder';\nimport { withBranchBoundary } from '../../compile/binds/bindErrorBoundary';\nimport { withinRender } from '../../compile/ssrCrashes';\nimport {\n createLoopContext,\n createLoopSignals,\n} from '../../compile/forLoops/loopSignals';\nimport type { IfDesc, ForDesc, SwitchDesc, BindingContext } from './types';\n\n// ─── Structural directive handlers ────────────────────────────────────────────\n\nexport function applyIf(\n d: IfDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`if:${d.pid}`);\n if (!anchor) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n // SSR: evaluate once synchronously\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n const b = d.branches[i];\n if (b.expr === undefined) {\n matchIndex = i;\n break;\n }\n const fn = compileExpression(b.expr, ctx, false);\n if (fn()) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.branches[matchIndex];\n const result = withBranchBoundary(anchor, () => factory(ctx));\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, anchor));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n });\n return;\n }\n\n // Pre-compile branch expressions once outside effect\n const branchEvaluators = d.branches.map(b =>\n b.expr !== undefined ? compileExpression(b.expr, ctx, false) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n let matchIndex = -1;\n for (let i = 0; i < d.branches.length; i++) {\n if (branchEvaluators[i] === null) {\n matchIndex = i;\n break;\n }\n if (branchEvaluators[i]!()) {\n matchIndex = i;\n break;\n }\n }\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.branches[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return withBranchBoundary(anchor, () => factory(ctx));\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n const parent = anchor.parentNode;\n if (parent) {\n const insertRef = anchor.nextSibling;\n for (const node of nodes) parent.insertBefore(node, insertRef);\n }\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @if] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @if] Factory error:`, err);\n }\n });\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, anchor));\n}\n\nexport function applyFor(\n d: ForDesc,\n commentMap: Map<string, Comment>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const anchor = commentMap.get(`for:${d.pid}`);\n if (!anchor) return;\n\n if (isSSRMode()) {\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const collection = collFn() ?? [];\n const parent = anchor.parentNode;\n if (!parent) return;\n\n const insertBefore: Node | null = anchor.nextSibling;\n withinRender(() =>\n withBranchBoundary(anchor, () => {\n for (let i = 0; i < collection.length; i++) {\n const itemCtx = buildItemContext(\n ctx,\n d,\n collection[i],\n i,\n collection.length\n );\n try {\n const result = d.factory(itemCtx);\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) parent.insertBefore(node, insertBefore);\n if (typeof result.destroy === 'function')\n disposers.push(\n anchorDisposer(result.destroy, nodes[0] ?? anchor)\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @for] Factory error at index ${i}:`, err);\n }\n }\n })\n );\n return;\n }\n\n const collFn = compileExpression<unknown[]>(d.expr, ctx, []);\n const loopManager = createLoopManager({\n anchor,\n trackByFn: compileTrackBy(d.trackBy, d.item, d.index, ctx),\n parentCtx: ctx,\n itemVar: d.item,\n indexVar: d.index,\n itemFactory: itemCtx => {\n const result = d.factory(itemCtx);\n const el = document.createDocumentFragment();\n if (result?.el) el.append(result.el);\n return { el, destroy: result?.destroy ?? (() => {}) };\n },\n });\n\n const stopEffect = effect(() => {\n try {\n const collection = collFn();\n if (!Array.isArray(collection) && import.meta.env?.DEV)\n console.warn('[AOT @for] collection is not an array:', collection);\n loopManager.update(Array.isArray(collection) ? collection : []);\n } catch (err) {\n if (import.meta.env?.DEV) console.error('[AOT @for] update failed:', err);\n loopManager.update([]);\n }\n });\n\n disposers.push(\n blockDisposer(stopEffect, () => loopManager.destroyAll(), anchor)\n );\n}\n\nfunction buildItemContext(\n parentCtx: BindingContext,\n d: ForDesc,\n item: unknown,\n index: number,\n length: number\n): BindingContext {\n return createLoopContext(\n parentCtx,\n createLoopSignals(item, index, length),\n d.item,\n d.index\n );\n}\n\nexport function applySwitch(\n d: SwitchDesc,\n pidMap: Map<string, Element>,\n ctx: BindingContext,\n disposers: (() => void)[]\n): void {\n const containerEl = pidMap.get(d.pid);\n if (!containerEl) return;\n\n let currentNodes: Node[] = [];\n let currentDisposers: (() => void)[] = [];\n\n function clearCurrent() {\n for (let i = currentDisposers.length - 1; i >= 0; i--) {\n try {\n currentDisposers[i]();\n } catch {\n /* ignore */\n }\n }\n currentDisposers = [];\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n currentNodes = [];\n }\n\n if (isSSRMode()) {\n const switchVal = compileExpression(d.expr, ctx)();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n const c = d.cases[i];\n if (c.val === undefined) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n const caseVal = compileExpression(c.val, ctx)();\n if (caseVal === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.cases[matchIndex];\n const result = withBranchBoundary(\n containerEl,\n () => factory(ctx),\n true\n );\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n if (typeof result.destroy === 'function')\n disposers.push(anchorDisposer(result.destroy, containerEl));\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n });\n return;\n }\n\n // Pre-compile switch expression and case values once outside effect\n const switchEval = compileExpression(d.expr, ctx);\n const caseEvals = d.cases.map(c =>\n c.val !== undefined ? compileExpression(c.val, ctx) : null\n );\n\n let previousMatchIndex = -1;\n\n const stopEffect = effect(() => {\n const switchVal = switchEval();\n let matchIndex = -1;\n let defaultIndex = -1;\n for (let i = 0; i < d.cases.length; i++) {\n if (caseEvals[i] === null) {\n if (defaultIndex === -1) defaultIndex = i;\n continue;\n }\n if (caseEvals[i]!() === switchVal) {\n matchIndex = i;\n break;\n }\n }\n if (matchIndex === -1) matchIndex = defaultIndex;\n\n if (matchIndex === previousMatchIndex) return;\n previousMatchIndex = matchIndex;\n\n clearCurrent();\n\n if (matchIndex >= 0)\n withinRender(() => {\n try {\n const { factory } = d.cases[matchIndex];\n const result = createRoot(disposeRoot => {\n currentDisposers.push(disposeRoot);\n return withBranchBoundary(containerEl, () => factory(ctx), true);\n });\n if (result?.el) {\n const nodes =\n result.el instanceof DocumentFragment\n ? Array.from(result.el.childNodes)\n : [result.el];\n for (const node of nodes) containerEl.appendChild(node);\n currentNodes = nodes;\n if (typeof result.destroy === 'function')\n currentDisposers.push(result.destroy);\n else if (import.meta.env?.DEV)\n console.warn(\n '[AOT @switch] branch factory returned no destroy(); effects its nested directives create will outlive the branch'\n );\n }\n } catch (err) {\n if (import.meta.env?.DEV)\n console.error(`[AOT @switch] Factory error:`, err);\n }\n });\n });\n\n disposers.push(blockDisposer(stopEffect, clearCurrent, containerEl));\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export type { EventDesc, InterpDesc, ClassDesc, ClassesDesc, StyleDesc, BoundDesc, RefDesc, BindDesc, CompDesc, DeferDesc, ErrorDesc, ProjDesc, IfDesc, ForDesc, SwitchDesc, Desc, } from './types.js';
2
2
  export { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, } from './helpers.js';
3
- export { applyRef, applyError, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
3
+ export { applyRef, applyError, markBoundary, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
4
4
  export { applyComponent } from './applyComponent.js';
5
5
  export { applyIf, applyFor, applySwitch } from './applyStructural.js';
6
6
  export { applyDefer } from './applyDefer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,EACV,IAAI,GACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,EACV,IAAI,GACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, } from './helpers.js';
2
- export { applyRef, applyError, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
2
+ export { applyRef, applyError, markBoundary, applyProjection, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, } from './applySimple.js';
3
3
  export { applyComponent } from './applyComponent.js';
4
4
  export { applyIf, applyFor, applySwitch } from './applyStructural.js';
5
5
  export { applyDefer } from './applyDefer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type {\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n Desc,\n} from './types';\n\nexport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n} from './helpers';\n\nexport {\n applyRef,\n applyError,\n applyProjection,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n} from './applySimple';\n\nexport { applyComponent } from './applyComponent';\n\nexport { applyIf, applyFor, applySwitch } from './applyStructural';\n\nexport { applyDefer } from './applyDefer';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/bindings/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type {\n EventDesc,\n InterpDesc,\n ClassDesc,\n ClassesDesc,\n StyleDesc,\n BoundDesc,\n RefDesc,\n BindDesc,\n CompDesc,\n DeferDesc,\n ErrorDesc,\n ProjDesc,\n IfDesc,\n ForDesc,\n SwitchDesc,\n Desc,\n} from './types';\n\nexport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n} from './helpers';\n\nexport {\n applyRef,\n applyError,\n markBoundary,\n applyProjection,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n} from './applySimple';\n\nexport { applyComponent } from './applyComponent';\n\nexport { applyIf, applyFor, applySwitch } from './applyStructural';\n\nexport { applyDefer } from './applyDefer';\n"]}
@@ -16,6 +16,12 @@ export interface PithyGlobals {
16
16
  * `@pithyjs/core` still share one — see `compile/ssrCrashes.ts`.
17
17
  */
18
18
  __pithySSRCrashes?: Map<Element, unknown>;
19
+ /** Crashes attributed to a boundary, resolved when the render ends; shared like the registry. */
20
+ __pithyAttributedCrashes?: unknown[];
21
+ __pithyRenderDepth?: number;
22
+ __pithyRenderId?: number;
23
+ __pithyCrashedElements?: WeakSet<Element>;
24
+ __pithyBoundaryContext?: Element | null;
19
25
  PITHY_DEBUG_PROJECTION?: boolean;
20
26
  __PITHY_SSR__?: boolean;
21
27
  __getComponentContext?: () => Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK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Y;IAC1B,OAAO,UAA8C,CAAC;AACxD,CAAC","sourcesContent":["import type { SlotMap } from '../compile/contentProjection';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport type { ChildFactory } from '../runtime/bindings/types';\n\nexport interface PithyComponentContext extends Record<string, unknown> {\n __parentComponentContext?: PithyComponentContext;\n __slotMap?: SlotMap;\n __childAstNodes?: PithyNode[];\n __childFactory?: ChildFactory;\n /** The component placeholder this context renders, while it is in the tree. */\n __slotHost?: Element;\n}\n\nexport interface PithyGlobals {\n /**\n * SSR component-crash registry. Lives on `globalThis` rather than in a module\n * so that an app and `@pithyjs/ssr` resolving two physical copies of\n * `@pithyjs/core` still share one — see `compile/ssrCrashes.ts`.\n */\n __pithySSRCrashes?: Map<Element, unknown>;\n PITHY_DEBUG_PROJECTION?: boolean;\n __PITHY_SSR__?: boolean;\n __getComponentContext?: () => Record<string, unknown> | undefined;\n __pithyComponentContext?: PithyComponentContext;\n __pithyProjectedChildren?: DocumentFragment;\n __pithyRenderingComponent?: boolean;\n __pithyGetDestroyCallbacks?: () => (() => void)[] | undefined;\n __pithySetDestroyCallbacks?: (cbs: (() => void)[]) => void;\n}\n\nexport function pithyGlobals(): typeof globalThis & PithyGlobals {\n return globalThis as typeof globalThis & PithyGlobals;\n}\n"]}
1
+ {"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AAoCA,MAAM,UAAU,YAAY;IAC1B,OAAO,UAA8C,CAAC;AACxD,CAAC","sourcesContent":["import type { SlotMap } from '../compile/contentProjection';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport type { ChildFactory } from '../runtime/bindings/types';\n\nexport interface PithyComponentContext extends Record<string, unknown> {\n __parentComponentContext?: PithyComponentContext;\n __slotMap?: SlotMap;\n __childAstNodes?: PithyNode[];\n __childFactory?: ChildFactory;\n /** The component placeholder this context renders, while it is in the tree. */\n __slotHost?: Element;\n}\n\nexport interface PithyGlobals {\n /**\n * SSR component-crash registry. Lives on `globalThis` rather than in a module\n * so that an app and `@pithyjs/ssr` resolving two physical copies of\n * `@pithyjs/core` still share one — see `compile/ssrCrashes.ts`.\n */\n __pithySSRCrashes?: Map<Element, unknown>;\n /** Crashes attributed to a boundary, resolved when the render ends; shared like the registry. */\n __pithyAttributedCrashes?: unknown[];\n __pithyRenderDepth?: number;\n __pithyRenderId?: number;\n __pithyCrashedElements?: WeakSet<Element>;\n __pithyBoundaryContext?: Element | null;\n PITHY_DEBUG_PROJECTION?: boolean;\n __PITHY_SSR__?: boolean;\n __getComponentContext?: () => Record<string, unknown> | undefined;\n __pithyComponentContext?: PithyComponentContext;\n __pithyProjectedChildren?: DocumentFragment;\n __pithyRenderingComponent?: boolean;\n __pithyGetDestroyCallbacks?: () => (() => void)[] | undefined;\n __pithySetDestroyCallbacks?: (cbs: (() => void)[]) => void;\n}\n\nexport function pithyGlobals(): typeof globalThis & PithyGlobals {\n return globalThis as typeof globalThis & PithyGlobals;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pithyjs/core",
3
- "version": "0.1.0-beta.19",
3
+ "version": "0.1.0-beta.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/PithyJS/pithyjs.git",
@@ -27,7 +27,7 @@
27
27
  "@pithyjs/shared": "0.1.0-beta.4",
28
28
  "@pithyjs/signals": "0.1.0-beta.2",
29
29
  "@pithyjs/compiler": "0.1.0-beta.8",
30
- "@pithyjs/design-system": "0.1.0-beta.10"
30
+ "@pithyjs/design-system": "0.1.0-beta.11"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "parse5": ">=7.0.0"