@pithyjs/core 0.1.0-beta.15 → 0.1.0-beta.16

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 (77) hide show
  1. package/README.md +4 -0
  2. package/dist/compile/binds/bindBoundAttributes.d.ts +4 -0
  3. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
  4. package/dist/compile/binds/bindBoundAttributes.js +63 -3
  5. package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
  6. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  7. package/dist/compile/binds/bindClassDirectives.js +3 -2
  8. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  9. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  10. package/dist/compile/binds/bindComponentsTags.js +15 -1
  11. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  12. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
  13. package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
  14. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
  15. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -1
  16. package/dist/compile/binds/bindDeferDirectives.js +17 -15
  17. package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
  18. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  19. package/dist/compile/binds/bindErrorBoundary.js +6 -4
  20. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  21. package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -1
  22. package/dist/compile/binds/bindEventHandlers.js +2 -1
  23. package/dist/compile/binds/bindEventHandlers.js.map +1 -1
  24. package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -1
  25. package/dist/compile/binds/bindRefDirectives.js +2 -1
  26. package/dist/compile/binds/bindRefDirectives.js.map +1 -1
  27. package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -1
  28. package/dist/compile/binds/bindStyleDirectives.js +2 -1
  29. package/dist/compile/binds/bindStyleDirectives.js.map +1 -1
  30. package/dist/compile/binds/bindTextInterpolations.d.ts +2 -1
  31. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
  32. package/dist/compile/binds/bindTextInterpolations.js +25 -14
  33. package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
  34. package/dist/compile/binds/declaredDirective.d.ts +12 -0
  35. package/dist/compile/binds/declaredDirective.d.ts.map +1 -0
  36. package/dist/compile/binds/declaredDirective.js +42 -0
  37. package/dist/compile/binds/declaredDirective.js.map +1 -0
  38. package/dist/compile/binds/forwardedAttrs.d.ts +4 -2
  39. package/dist/compile/binds/forwardedAttrs.d.ts.map +1 -1
  40. package/dist/compile/binds/forwardedAttrs.js +10 -2
  41. package/dist/compile/binds/forwardedAttrs.js.map +1 -1
  42. package/dist/compile/binds/staleRowProps.d.ts +9 -0
  43. package/dist/compile/binds/staleRowProps.d.ts.map +1 -0
  44. package/dist/compile/binds/staleRowProps.js +86 -0
  45. package/dist/compile/binds/staleRowProps.js.map +1 -0
  46. package/dist/compile/forLoops/loopSignals.d.ts.map +1 -1
  47. package/dist/compile/forLoops/loopSignals.js +15 -1
  48. package/dist/compile/forLoops/loopSignals.js.map +1 -1
  49. package/dist/compile/nodeExpando.d.ts +6 -0
  50. package/dist/compile/nodeExpando.d.ts.map +1 -1
  51. package/dist/compile/nodeExpando.js.map +1 -1
  52. package/dist/compile/pithyTreeToDom.js +1 -0
  53. package/dist/compile/pithyTreeToDom.js.map +1 -1
  54. package/dist/compile/renderChildren.d.ts.map +1 -1
  55. package/dist/compile/renderChildren.js +1 -1
  56. package/dist/compile/renderChildren.js.map +1 -1
  57. package/dist/runtime/applyBindings.d.ts.map +1 -1
  58. package/dist/runtime/applyBindings.js +3 -1
  59. package/dist/runtime/applyBindings.js.map +1 -1
  60. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
  61. package/dist/runtime/bindings/applyComponent.js +9 -0
  62. package/dist/runtime/bindings/applyComponent.js.map +1 -1
  63. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -1
  64. package/dist/runtime/bindings/applyDefer.js +10 -9
  65. package/dist/runtime/bindings/applyDefer.js.map +1 -1
  66. package/dist/runtime/bindings/applySimple.d.ts +2 -0
  67. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  68. package/dist/runtime/bindings/applySimple.js +48 -8
  69. package/dist/runtime/bindings/applySimple.js.map +1 -1
  70. package/dist/runtime/bindings/helpers.d.ts.map +1 -1
  71. package/dist/runtime/bindings/helpers.js +2 -0
  72. package/dist/runtime/bindings/helpers.js.map +1 -1
  73. package/dist/runtime/bindings/index.d.ts +1 -1
  74. package/dist/runtime/bindings/index.d.ts.map +1 -1
  75. package/dist/runtime/bindings/index.js +1 -1
  76. package/dist/runtime/bindings/index.js.map +1 -1
  77. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"forwardedAttrs.js","sourceRoot":"","sources":["../../../src/compile/binds/forwardedAttrs.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,oFAAoF;AACpF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACxD,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAE3E;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9E,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,C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IAAI,CAC3G,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { DIRECTIVE_ATTR_PREFIXES, isDirectiveAttr } from '@pithyjs/compiler';\n\nconst FORWARDED_DIRECTIVE_ATTRS = new Set(['data-classes']);\n\n// Runtime-owned attributes: forwarding them would give the rendered root the\n// component tag's node identity, its parent's style scope, or its loop/defer state.\nconst RUNTIME_ATTRS = new Set(['data-pid', 'data-for']);\nconst RUNTIME_ATTR_PREFIXES = ['data-scope-', 'data-defer-', 'data-loop-'];\n\n/**\n * Whether a `data-*` attribute on a component tag belongs on the rendered root.\n *\n * Shared by both compilation paths — the JIT binder (`bindComponentTags`) and\n * the AOT binder (`applyComponent`) — so a plain `data-testid` cannot survive\n * `pnpm dev` and vanish in a production build.\n */\nfunction isForwardableAttr(name: string): boolean {\n if (!name.startsWith('data-') || name.length === 'data-'.length) return false;\n if (DIRECTIVE_ATTR_PREFIXES.some(prefix => name.startsWith(prefix))) {\n return true;\n }\n if (FORWARDED_DIRECTIVE_ATTRS.has(name)) return true;\n if (isDirectiveAttr(name)) return false;\n if (RUNTIME_ATTRS.has(name)) return false;\n return !RUNTIME_ATTR_PREFIXES.some(prefix => name.startsWith(prefix));\n}\n\n/** Collect the `data-*` attributes to carry from a component tag to its rendered root. */\nexport function collectForwardedAttrs(el: Element): Array<[string, string]> {\n const forwarded: Array<[string, string]> = [];\n for (const attr of Array.from(el.attributes)) {\n if (isForwardableAttr(attr.name)) {\n forwarded.push([attr.name, attr.value]);\n }\n }\n return forwarded;\n}\n\n/**\n * Write collected attributes onto the rendered root.\n *\n * A forwarded `data-*` REPLACES the component's own value, where a forwarded\n * `class` merges into it — the asymmetry is invisible at the call site, and\n * ui-kit drives styling from `data-variant`/`data-color`/`data-size`, so an\n * author who copies one out of devtools silently overrides the prop that set\n * it. The DEV warning surfaces that collision without picking a winner.\n *\n * Shared by both binders so the two paths cannot drift.\n */\nexport function applyForwardedAttrs(\n target: Element,\n forwarded: Array<[string, string]>,\n tag: string\n): void {\n for (const [name, value] of forwarded) {\n if (\n import.meta.env?.DEV &&\n target.hasAttribute(name) &&\n target.getAttribute(name) !== value\n ) {\n console.warn(\n `[PithyJS] <${tag}> forwarded ${name}=\"${value}\" over the component's own \"${target.getAttribute(name)}\".`\n );\n }\n target.setAttribute(name, value);\n }\n}\n"]}
1
+ {"version":3,"file":"forwardedAttrs.js","sourceRoot":"","sources":["../../../src/compile/binds/forwardedAttrs.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,oFAAoF;AACpF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACxD,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAE3E;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9E,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAA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ACJ,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,OAAC,WAAW,CAAC,MAAM,CAAC,EAAC,qBAAqB,QAArB,qBAAqB,GAAK,IAAI,GAAG,EAAE,EAAC,CAAC;QAC1E,IAAI,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;;YAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.components\",\n \"title\": \"Component Tag Binding System\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { DIRECTIVE_ATTR_PREFIXES, isDirectiveAttr } from '@pithyjs/compiler';\nimport { nodeExpando } from '../nodeExpando';\nimport { isDeclaredDirective } from './declaredDirective';\n\nconst FORWARDED_DIRECTIVE_ATTRS = new Set(['data-classes']);\n\n// Runtime-owned attributes: forwarding them would give the rendered root the\n// component tag's node identity, its parent's style scope, or its loop/defer state.\nconst RUNTIME_ATTRS = new Set(['data-pid', 'data-for']);\nconst RUNTIME_ATTR_PREFIXES = ['data-scope-', 'data-defer-', 'data-loop-'];\n\n/**\n * Whether a `data-*` attribute on a component tag belongs on the rendered root.\n *\n * Shared by both compilation paths — the JIT binder (`bindComponentTags`) and\n * the AOT binder (`applyComponent`) — so a plain `data-testid` cannot survive\n * `pnpm dev` and vanish in a production build.\n */\nfunction isForwardableAttr(name: string): boolean {\n if (!name.startsWith('data-') || name.length === 'data-'.length) return false;\n if (DIRECTIVE_ATTR_PREFIXES.some(prefix => name.startsWith(prefix))) {\n return true;\n }\n if (FORWARDED_DIRECTIVE_ATTRS.has(name)) return true;\n if (isDirectiveAttr(name)) return false;\n if (RUNTIME_ATTRS.has(name)) return false;\n return !RUNTIME_ATTR_PREFIXES.some(prefix => name.startsWith(prefix));\n}\n\n/** Collect the `data-*` attributes to carry from a component tag to its rendered root. */\nexport function collectForwardedAttrs(el: Element): ForwardedAttr[] {\n const forwarded: ForwardedAttr[] = [];\n for (const attr of Array.from(el.attributes)) {\n if (isForwardableAttr(attr.name)) {\n forwarded.push([attr.name, attr.value, isDeclaredDirective(attr)]);\n }\n }\n return forwarded;\n}\n\n/** Name, value, and whether the tag's template wrote that value. */\nexport type ForwardedAttr = [name: string, value: string, declared: boolean];\n\n/**\n * Write collected attributes onto the rendered root.\n *\n * A forwarded `data-*` REPLACES the component's own value, where a forwarded\n * `class` merges into it — the asymmetry is invisible at the call site, and\n * ui-kit drives styling from `data-variant`/`data-color`/`data-size`, so an\n * author who copies one out of devtools silently overrides the prop that set\n * it. The DEV warning surfaces that collision without picking a winner.\n *\n * Shared by both binders so the two paths cannot drift.\n */\nexport function applyForwardedAttrs(\n target: Element,\n forwarded: ForwardedAttr[],\n tag: string\n): void {\n for (const [name, value, declared] of forwarded) {\n if (\n import.meta.env?.DEV &&\n target.hasAttribute(name) &&\n target.getAttribute(name) !== value\n ) {\n console.warn(\n `[PithyJS] <${tag}> forwarded ${name}=\"${value}\" over the component's own \"${target.getAttribute(name)}\".`\n );\n }\n target.setAttribute(name, value);\n const records = (nodeExpando(target).__forwardedDirectives ??= new Map());\n if (declared) records.set(name, value);\n else records.delete(name);\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export type RowLocals = Map<string, () => unknown>;
2
+ export declare function rowLocalsOf(ctx: Record<string, unknown>): RowLocals | undefined;
3
+ /**
4
+ * Warns when a component prop in a kept `@for` row would now read differently.
5
+ * Objects are skipped: a list can rebuild them on every write while the
6
+ * component reads live values through them, as Studio's `PropEditor` does.
7
+ */
8
+ export declare function watchStaleRowProp(ctx: Record<string, unknown>, site: object, tag: string, prop: string, expr: string, value: unknown, read: () => unknown, disposers: (() => void)[]): void;
9
+ //# sourceMappingURL=staleRowProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleRowProps.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/staleRowProps.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC;AAKnD,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,SAAS,GAAG,SAAS,CAIvB;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,OAAO,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAmDN"}
@@ -0,0 +1,86 @@
1
+ import { effect, untrack } from '@pithyjs/signals';
2
+ import { isSSRMode } from '../ssrMode.js';
3
+ const warned = new WeakMap();
4
+ // `in` first: a context can be a proxy that warns on reading a missing key.
5
+ export function rowLocalsOf(ctx) {
6
+ return '__pithyRowLocals' in ctx
7
+ ? ctx.__pithyRowLocals
8
+ : undefined;
9
+ }
10
+ function callsLocal(expr, name) {
11
+ const escaped = name.replace(/\$/g, '\\$');
12
+ return new RegExp(`(?<![\\w$.])${escaped}\\s*(\\?\\.\\s*)?\\(`).test(expr);
13
+ }
14
+ // Must not throw: a throw here reaches the loop's catch, which clears the list.
15
+ function describe(value) {
16
+ if (typeof value === 'string')
17
+ return JSON.stringify(value);
18
+ if (typeof value === 'object' && value !== null)
19
+ return 'an object';
20
+ if (typeof value === 'function')
21
+ return 'a function';
22
+ return String(value);
23
+ }
24
+ /**
25
+ * Warns when a component prop in a kept `@for` row would now read differently.
26
+ * Objects are skipped: a list can rebuild them on every write while the
27
+ * component reads live values through them, as Studio's `PropEditor` does.
28
+ */
29
+ export function watchStaleRowProp(ctx, site, tag, prop, expr, value, read, disposers) {
30
+ const locals = rowLocalsOf(ctx);
31
+ if (!locals || isSSRMode())
32
+ return;
33
+ if (typeof value === 'function')
34
+ return;
35
+ if (typeof value === 'object' && value !== null)
36
+ return;
37
+ const used = [...locals].filter(([name]) => callsLocal(expr, name));
38
+ if (used.length === 0)
39
+ return;
40
+ let subscribed = false;
41
+ let queued = false;
42
+ let disposed = false;
43
+ const compare = () => {
44
+ queued = false;
45
+ if (disposed)
46
+ return;
47
+ let next;
48
+ try {
49
+ next = untrack(read);
50
+ }
51
+ catch {
52
+ return;
53
+ }
54
+ if (Object.is(next, value))
55
+ return;
56
+ let props = warned.get(site);
57
+ if (!props)
58
+ warned.set(site, (props = new Set()));
59
+ if (props.has(prop))
60
+ return;
61
+ props.add(prop);
62
+ console.warn(`[PithyJS] <${tag} ${prop}="${expr}"> in an @for row still shows ` +
63
+ `${describe(value)}, not ${describe(next)}: a component ` +
64
+ `reads this value once, and a list write kept the row. Pass an ` +
65
+ `accessor (${prop}="() => ${expr}") if the component accepts one, ` +
66
+ `or use a track value that changes with the item.`);
67
+ };
68
+ const stop = effect(() => {
69
+ for (const [, accessor] of used)
70
+ accessor();
71
+ if (!subscribed) {
72
+ subscribed = true;
73
+ return;
74
+ }
75
+ if (queued)
76
+ return;
77
+ queued = true;
78
+ // Not inline: this effect can run between two loops' syncs in one flush.
79
+ queueMicrotask(compare);
80
+ });
81
+ disposers.push(() => {
82
+ disposed = true;
83
+ stop();
84
+ });
85
+ }
86
+ //# sourceMappingURL=staleRowProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleRowProps.js","sourceRoot":"","sources":["../../../src/compile/binds/staleRowProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAuB,CAAC;AAElD,4EAA4E;AAC5E,MAAM,UAAU,WAAW,C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AI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,yEAAyE;QACzE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { effect, untrack } from '@pithyjs/signals';\nimport { isSSRMode } from '../ssrMode';\n\nexport type RowLocals = Map<string, () => unknown>;\n\nconst warned = new WeakMap<object, Set<string>>();\n\n// `in` first: a context can be a proxy that warns on reading a missing key.\nexport function rowLocalsOf(\n ctx: Record<string, unknown>\n): RowLocals | undefined {\n return '__pithyRowLocals' in ctx\n ? (ctx.__pithyRowLocals as RowLocals)\n : undefined;\n}\n\nfunction callsLocal(expr: string, name: string): boolean {\n const escaped = name.replace(/\\$/g, '\\\\$');\n return new RegExp(`(?<![\\\\w$.])${escaped}\\\\s*(\\\\?\\\\.\\\\s*)?\\\\(`).test(expr);\n}\n\n// Must not throw: a throw here reaches the loop's catch, which clears the list.\nfunction describe(value: unknown): string {\n if (typeof value === 'string') return JSON.stringify(value);\n if (typeof value === 'object' && value !== null) return 'an object';\n if (typeof value === 'function') return 'a function';\n return String(value);\n}\n\n/**\n * Warns when a component prop in a kept `@for` row would now read differently.\n * Objects are skipped: a list can rebuild them on every write while the\n * component reads live values through them, as Studio's `PropEditor` does.\n */\nexport function watchStaleRowProp(\n ctx: Record<string, unknown>,\n site: object,\n tag: string,\n prop: string,\n expr: string,\n value: unknown,\n read: () => unknown,\n disposers: (() => void)[]\n): void {\n const locals = rowLocalsOf(ctx);\n if (!locals || isSSRMode()) return;\n if (typeof value === 'function') return;\n if (typeof value === 'object' && value !== null) return;\n\n const used = [...locals].filter(([name]) => callsLocal(expr, name));\n if (used.length === 0) return;\n\n let subscribed = false;\n let queued = false;\n let disposed = false;\n\n const compare = () => {\n queued = false;\n if (disposed) return;\n let next: unknown;\n try {\n next = untrack(read);\n } catch {\n return;\n }\n if (Object.is(next, value)) return;\n let props = warned.get(site);\n if (!props) warned.set(site, (props = new Set()));\n if (props.has(prop)) return;\n props.add(prop);\n console.warn(\n `[PithyJS] <${tag} ${prop}=\"${expr}\"> in an @for row still shows ` +\n `${describe(value)}, not ${describe(next)}: a component ` +\n `reads this value once, and a list write kept the row. Pass an ` +\n `accessor (${prop}=\"() => ${expr}\") if the component accepts one, ` +\n `or use a track value that changes with the item.`\n );\n };\n\n const stop = effect(() => {\n for (const [, accessor] of used) accessor();\n if (!subscribed) {\n subscribed = true;\n return;\n }\n if (queued) return;\n queued = true;\n // Not inline: this effect can run between two loops' syncs in one flush.\n queueMicrotask(compare);\n });\n disposers.push(() => {\n disposed = true;\n stop();\n });\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;AAEzD,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;A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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
- return {
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;AAYzD,gLAAgL;AAChL;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAO,EACP,GAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAErC,OAAO;QACL,OAAO;QACP,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,OAAO;QACP,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAED,mLAAmL;AACnL;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAoB,EACpB,GAAW,EACX,KAAa;IAEb,KAAK,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QAChC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;QACvC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,6UAA6U;AAC7U;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAkC,EAClC,OAAoB,EACpB,OAAe,EACf,QAAiB,EACjB,QAAQ,GAAG,OAAO,EAClB,QAAQ,GAAG,OAAO,EAClB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,MAAM,EAChB,MAAM,GAAG,KAAK;IAEd,OAAO;QACL,GAAG,SAAS;QACZ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ;QAC5B,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ;QAC5B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM;QACxB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO;QAC1B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.directive.loop-signals\",\n \"title\": \"Loop Reactive Signals\", \n \"category\": \"directive\"\n}\n*/\n\nimport { batch, signal, Signal } from '@pithyjs/signals';\n\nexport interface LoopSignals {\n itemSig: Signal<unknown>;\n countSig: Signal<number>;\n idxSig: Signal<number>;\n firstSig: Signal<boolean>;\n lastSig: Signal<boolean>;\n evenSig: Signal<boolean>;\n oddSig: Signal<boolean>;\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"createLoopSignals\",\"stability\":\"stable\",\"signature\":\"<T>(item: T, idx: number, total: number) => LoopSignals\"} */\n/**\n * Creates all the reactive signals needed for a loop item\n */\nexport function createLoopSignals<T>(\n item: T,\n idx: number,\n total: number\n): LoopSignals {\n const itemSig = signal<unknown>(item);\n const countSig = signal(total);\n const idxSig = signal(idx);\n const firstSig = signal(idx === 0);\n const lastSig = signal(idx === total - 1);\n const evenSig = signal(idx % 2 === 0);\n const oddSig = signal(idx % 2 === 1);\n\n return {\n itemSig,\n countSig,\n idxSig,\n firstSig,\n lastSig,\n evenSig,\n oddSig,\n };\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"updateLoopSignals\",\"stability\":\"stable\",\"signature\":\"(signals: LoopSignals, idx: number, total: number) => void\"} */\n/**\n * Updates all positional signals for a loop item (idx, first, last, even, odd, count)\n * Uses batch() for optimal performance\n */\nexport function updateLoopSignals(\n signals: LoopSignals,\n idx: number,\n total: number\n): void {\n batch(() => {\n signals.countSig.set(total);\n signals.idxSig.set(idx);\n signals.firstSig.set(idx === 0);\n signals.lastSig.set(idx === total - 1);\n signals.evenSig.set(idx % 2 === 0);\n signals.oddSig.set(idx % 2 === 1);\n });\n}\n\n/** @codexApi {\"parent\":\"pithy.directive.loop-signals\",\"name\":\"createLoopContext\",\"stability\":\"stable\",\"signature\":\"(parentCtx: Record<string, unknown>, signals: LoopSignals, itemVar: string, indexVar?: string, countVar?: string, firstVar?: string, lastVar?: string, evenVar?: string, oddVar?: string) => Record<string, unknown>\"} */\n/**\n * Creates the context object for a loop item with all necessary signals.\n * Helper signal names (count, first, last, even, odd) can be aliased to\n * avoid shadowing in nested loops.\n */\nexport function createLoopContext(\n parentCtx: Record<string, unknown>,\n signals: LoopSignals,\n itemVar: string,\n indexVar?: string,\n countVar = 'count',\n firstVar = 'first',\n lastVar = 'last',\n evenVar = 'even',\n oddVar = 'odd'\n): Record<string, unknown> {\n return {\n ...parentCtx,\n [countVar]: signals.countSig,\n [firstVar]: signals.firstSig,\n [lastVar]: signals.lastSig,\n [evenVar]: signals.evenSig,\n [oddVar]: signals.oddSig,\n [itemVar]: signals.itemSig,\n ...(indexVar ? { [indexVar]: signals.idxSig } : {}),\n };\n}\n"]}
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;AACzD,OAAO,EAAE,WAAW,EAAkB,MAAM,wBAAwB,CAAC;AAYrE,gLAAgL;AAChL;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAO,EACP,GAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAErC,OAAO;QACL,OAAO;QACP,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,OAAO;QACP,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAED,mLAAmL;AACnL;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAo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,CAAC;KACpD,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;QACzB,MAAM,MAAM,GAAc,IAAI,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,OAAO,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"]}
@@ -1,4 +1,8 @@
1
1
  import type { PithyNode } from '@pithyjs/compiler';
2
+ export interface StyleOwners {
3
+ strings: string[];
4
+ props: Map<string, [value: string, priority: string]>;
5
+ }
2
6
  export interface NodeExpando {
3
7
  __pithyCtx?: Record<string, unknown>;
4
8
  __pithyNode?: PithyNode;
@@ -12,7 +16,9 @@ export interface NodeExpando {
12
16
  /** Renders a build's placeholder; returns the nodes that replaced it. */
13
17
  __pithyAotMount?: (disposers: (() => void)[]) => Node[];
14
18
  __styleProps?: string[];
19
+ __styleOwners?: StyleOwners;
15
20
  __classToggles?: string[];
21
+ __forwardedDirectives?: Map<string, string>;
16
22
  }
17
23
  export declare function nodeExpando<T extends Node>(node: T): T & NodeExpando;
18
24
  //# sourceMappingURL=nodeExpando.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeExpando.d.ts","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,g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K,IAAI,EAAE,CAAC;IACxD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,WAAW,CAEpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"nodeExpando.js","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,WAAW,CAAiB,IAAO;IACjD,OAAO,IAAuB,CAAC;AACjC,CAAC","sourcesContent":["import type { PithyNode } from '@pithyjs/compiler';\n\nexport interface NodeExpando {\n __pithyCtx?: Record<string, unknown>;\n __pithyNode?: PithyNode;\n __nodeId?: string;\n __slotName?: string;\n __fallbackFactory?: () => DocumentFragment;\n __nested?: boolean;\n __pithySkipText?: boolean;\n __pithyComponentDom?: boolean;\n /** A build's component placeholder: renders it through the AOT binder. */\n /** Renders a build's placeholder; returns the nodes that replaced it. */\n __pithyAotMount?: (disposers: (() => void)[]) => Node[];\n __styleProps?: string[];\n __classToggles?: string[];\n}\n\nexport function nodeExpando<T extends Node>(node: T): T & NodeExpando {\n return node as T & NodeExpando;\n}\n"]}
1
+ {"version":3,"file":"nodeExpando.js","sourceRoot":"","sources":["../../src/compile/nodeExpando.ts"],"names":[],"mappings":"AAyBA,MAAM,UAAU,WAAW,CAAiB,IAAO;IACjD,OAAO,IAAuB,CAAC;AACjC,CAAC","sourcesContent":["import type { PithyNode } from '@pithyjs/compiler';\n\nexport interface StyleOwners {\n strings: string[];\n props: Map<string, [value: string, priority: string]>;\n}\n\nexport interface NodeExpando {\n __pithyCtx?: Record<string, unknown>;\n __pithyNode?: PithyNode;\n __nodeId?: string;\n __slotName?: string;\n __fallbackFactory?: () => DocumentFragment;\n __nested?: boolean;\n __pithySkipText?: boolean;\n __pithyComponentDom?: boolean;\n /** A build's component placeholder: renders it through the AOT binder. */\n /** Renders a build's placeholder; returns the nodes that replaced it. */\n __pithyAotMount?: (disposers: (() => void)[]) => Node[];\n __styleProps?: string[];\n __styleOwners?: StyleOwners;\n __classToggles?: string[];\n __forwardedDirectives?: Map<string, string>;\n}\n\nexport function nodeExpando<T extends Node>(node: T): T & NodeExpando {\n return node as T & NodeExpando;\n}\n"]}
@@ -28,6 +28,7 @@ function createDomNodeFromPithy(node, context) {
28
28
  if (node.type === 'text') {
29
29
  const textNode = document.createTextNode(node.textContent ?? '');
30
30
  nodeExpando(textNode).__pithyCtx = context;
31
+ nodeExpando(textNode).__pithyNode = node;
31
32
  return textNode;
32
33
  }
33
34
  if (node.type === 'slot') {
@@ -1 +1 @@
1
- {"version":3,"file":"pithyTreeToDom.js","sourceRoot":"","sources":["../../src/compile/pithyTreeToDom.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,QAAQ,EACR,MAAM,EACN,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;GAIG;AACH,uLAAuL;AACvL,MAAM,UAAU,cAAc,CAC5B,KAAkB,EAClB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,OAAO,EAAE,CAAC;YACZ,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,uLAAuL;AACvL,SAAS,sBAAsB,CAC7B,IAAe,EACf,OAAgC;IAEhC,IAAI,I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AAI,CAAC;AACd,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.compiler.dom-tree\",\n \"title\": \"PithyNode to DOM Tree Converter\",\n \"category\": \"compiler\"\n}\n*/\n\nimport {\n SVG_TAGS,\n SVG_NS,\n forEachDirectiveAttr,\n type PithyNode,\n} from '@pithyjs/compiler';\nimport { nodeExpando } from './nodeExpando';\n\n/**\n * Converts a list of PithyNodes into a DocumentFragment of real DOM nodes.\n * Component tags (isComponent: true) are rendered as placeholder elements.\n * No bindings or reactivity are applied here — those are handled in bind*() functions.\n */\n/** @codexApi {\"parent\":\"pithy.compiler.dom-tree\",\"name\":\"pithyTreeToDom\",\"stability\":\"stable\",\"signature\":\"(nodes: PithyNode[], context: Record<string, any>) => DocumentFragment\"} */\nexport function pithyTreeToDom(\n nodes: PithyNode[],\n context: Record<string, unknown>\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n\n for (const node of nodes) {\n const domNode = createDomNodeFromPithy(node, context);\n if (domNode) {\n fragment.appendChild(domNode);\n }\n }\n\n return fragment;\n}\n\n/** @codexApi {\"parent\":\"pithy.compiler.dom-tree\",\"name\":\"createDomNodeFromPithy\",\"stability\":\"stable\",\"signature\":\"(node: PithyNode, context: Record<string, any>) => Node | null\"} */\nfunction createDomNodeFromPithy(\n node: PithyNode,\n context: Record<string, unknown>\n): Node | null {\n if (node.type === 'text') {\n const textNode = document.createTextNode(node.textContent ?? '');\n nodeExpando(textNode).__pithyCtx = context;\n return textNode;\n }\n\n if (node.type === 'slot') {\n // Create comment anchor for slot\n const slotName = node.slotName || '';\n const anchor = document.createComment(\n `slot:${slotName} pid=\"${node.nodeId}\"`\n );\n\n // Store slot metadata for runtime stitching\n nodeExpando(anchor).__pithyCtx = context;\n nodeExpando(anchor).__nodeId = node.nodeId;\n nodeExpando(anchor).__slotName = slotName;\n nodeExpando(anchor).__pithyNode = node;\n\n // Create fallback fragment factory if fallback content exists\n if (node.fallbackChildren && node.fallbackChildren.length > 0) {\n nodeExpando(anchor).__fallbackFactory = () => {\n return pithyTreeToDom(node.fallbackChildren!, context);\n };\n }\n\n return anchor;\n }\n\n if (node.type === 'element') {\n // For components, create placeholder element (to be upgraded later)\n const tag = node.originalTagName ?? node.tagName ?? 'div';\n\n // SVG elements need to be created in the SVG namespace\n const el = SVG_TAGS.has(tag.toLowerCase())\n ? document.createElementNS(SVG_NS, tag)\n : document.createElement(tag);\n\n nodeExpando(el).__pithyCtx = context;\n\n // Store the PithyNode data for component binding to access:\n // - isComponent flag (to distinguish native elements from components)\n // - original attribute names (for prop name normalization)\n nodeExpando(el).__pithyNode = node;\n\n // Set static attributes\n for (const [name, value] of Object.entries(node.attrs ?? {})) {\n if (name.startsWith('@') || name.startsWith('[')) {\n continue; // Skip PithyJS directive attributes — handled in bind* functions\n }\n // Use original attribute name casing (important for SVG attributes like viewBox)\n const originalName = node.originalAttrs?.[name] || name;\n el.setAttribute(originalName, value);\n }\n\n // @for loop - REPLACE element with anchor\n if (node.directives?.for) {\n // Create a comment node as placeholder\n const placeholder = document.createComment(\n `Placeholder for loop items pid=\"${node.nodeId}\"`\n );\n nodeExpando(placeholder).__pithyCtx = context;\n\n // Store the nodeId on the comment for bindForLoops to find it\n if (node.nodeId) {\n nodeExpando(placeholder).__nodeId = node.nodeId;\n // Loop placeholders are comment nodes — discovered via __nodeId walk, not querySelectorAll (data-pid is for element nodes only)\n }\n\n // Store the original PithyNode structure for nested processing\n nodeExpando(placeholder).__pithyNode = node;\n\n return placeholder;\n }\n\n // Apply directive data-* attributes for runtime binders.\n // Uses the shared mapping from @pithyjs/compiler to stay in sync with AOT codegen.\n if (node.directives) {\n forEachDirectiveAttr(node.directives, (attr, value) => {\n el.setAttribute(attr, value);\n });\n\n // Preserve `slot` as a standard HTML attribute.\n // forEachDirectiveAttr intentionally skips slot (it's consumed by content\n // projection via directives.slot), but downstream binders like\n // bindDeferDirectives need it as a DOM attribute for querySelector lookups\n // (e.g., '[slot=\"placeholder\"]', '[slot=\"error\"]').\n if (node.directives.slot && !el.hasAttribute('slot')) {\n el.setAttribute('slot', node.directives.slot);\n }\n }\n\n // Optional: add dev/debug node ID\n if (node.nodeId) {\n el.setAttribute('data-pid', node.nodeId);\n } else if (node.attrs?.['data-pid']) {\n // Preserve existing data-pid from the original HTML\n el.setAttribute('data-pid', node.attrs['data-pid']);\n }\n\n // Recursively process children\n for (const child of node.children ?? []) {\n const childDom = createDomNodeFromPithy(child, context);\n if (childDom) el.appendChild(childDom);\n }\n\n return el;\n }\n\n return null;\n}\n"]}
1
+ {"version":3,"file":"pithyTreeToDom.js","sourceRoot":"","sources":["../../src/compile/pithyTreeToDom.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,QAAQ,EACR,MAAM,EACN,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;GAIG;AACH,uLAAuL;AACvL,MAAM,UAAU,cAAc,CAC5B,KAAkB,EAClB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,OAAO,EAAE,CAAC;YACZ,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,uLAAuL;AACvL,SAAS,sBAAsB,CAC7B,IAAe,EACf,OAAgC;IAEhC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QACjE,WAAW,CAAC,QAAQ,CAAC,CAAC,UAAU,GAAG,OAAO,CAAC;QAC3C,WAAW,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,\n SVG_NS,\n forEachDirectiveAttr,\n type PithyNode,\n} from '@pithyjs/compiler';\nimport { nodeExpando } from './nodeExpando';\n\n/**\n * Converts a list of PithyNodes into a DocumentFragment of real DOM nodes.\n * Component tags (isComponent: true) are rendered as placeholder elements.\n * No bindings or reactivity are applied here — those are handled in bind*() functions.\n */\n/** @codexApi {\"parent\":\"pithy.compiler.dom-tree\",\"name\":\"pithyTreeToDom\",\"stability\":\"stable\",\"signature\":\"(nodes: PithyNode[], context: Record<string, any>) => DocumentFragment\"} */\nexport function pithyTreeToDom(\n nodes: PithyNode[],\n context: Record<string, unknown>\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n\n for (const node of nodes) {\n const domNode = createDomNodeFromPithy(node, context);\n if (domNode) {\n fragment.appendChild(domNode);\n }\n }\n\n return fragment;\n}\n\n/** @codexApi {\"parent\":\"pithy.compiler.dom-tree\",\"name\":\"createDomNodeFromPithy\",\"stability\":\"stable\",\"signature\":\"(node: PithyNode, context: Record<string, any>) => Node | null\"} */\nfunction createDomNodeFromPithy(\n node: PithyNode,\n context: Record<string, unknown>\n): Node | null {\n if (node.type === 'text') {\n const textNode = document.createTextNode(node.textContent ?? '');\n nodeExpando(textNode).__pithyCtx = context;\n nodeExpando(textNode).__pithyNode = node;\n return textNode;\n }\n\n if (node.type === 'slot') {\n // Create comment anchor for slot\n const slotName = node.slotName || '';\n const anchor = document.createComment(\n `slot:${slotName} pid=\"${node.nodeId}\"`\n );\n\n // Store slot metadata for runtime stitching\n nodeExpando(anchor).__pithyCtx = context;\n nodeExpando(anchor).__nodeId = node.nodeId;\n nodeExpando(anchor).__slotName = slotName;\n nodeExpando(anchor).__pithyNode = node;\n\n // Create fallback fragment factory if fallback content exists\n if (node.fallbackChildren && node.fallbackChildren.length > 0) {\n nodeExpando(anchor).__fallbackFactory = () => {\n return pithyTreeToDom(node.fallbackChildren!, context);\n };\n }\n\n return anchor;\n }\n\n if (node.type === 'element') {\n // For components, create placeholder element (to be upgraded later)\n const tag = node.originalTagName ?? node.tagName ?? 'div';\n\n // SVG elements need to be created in the SVG namespace\n const el = SVG_TAGS.has(tag.toLowerCase())\n ? document.createElementNS(SVG_NS, tag)\n : document.createElement(tag);\n\n nodeExpando(el).__pithyCtx = context;\n\n // Store the PithyNode data for component binding to access:\n // - isComponent flag (to distinguish native elements from components)\n // - original attribute names (for prop name normalization)\n nodeExpando(el).__pithyNode = node;\n\n // Set static attributes\n for (const [name, value] of Object.entries(node.attrs ?? {})) {\n if (name.startsWith('@') || name.startsWith('[')) {\n continue; // Skip PithyJS directive attributes — handled in bind* functions\n }\n // Use original attribute name casing (important for SVG attributes like viewBox)\n const originalName = node.originalAttrs?.[name] || name;\n el.setAttribute(originalName, value);\n }\n\n // @for loop - REPLACE element with anchor\n if (node.directives?.for) {\n // Create a comment node as placeholder\n const placeholder = document.createComment(\n `Placeholder for loop items pid=\"${node.nodeId}\"`\n );\n nodeExpando(placeholder).__pithyCtx = context;\n\n // Store the nodeId on the comment for bindForLoops to find it\n if (node.nodeId) {\n nodeExpando(placeholder).__nodeId = node.nodeId;\n // Loop placeholders are comment nodes — discovered via __nodeId walk, not querySelectorAll (data-pid is for element nodes only)\n }\n\n // Store the original PithyNode structure for nested processing\n nodeExpando(placeholder).__pithyNode = node;\n\n return placeholder;\n }\n\n // Apply directive data-* attributes for runtime binders.\n // Uses the shared mapping from @pithyjs/compiler to stay in sync with AOT codegen.\n if (node.directives) {\n forEachDirectiveAttr(node.directives, (attr, value) => {\n el.setAttribute(attr, value);\n });\n\n // Preserve `slot` as a standard HTML attribute.\n // forEachDirectiveAttr intentionally skips slot (it's consumed by content\n // projection via directives.slot), but downstream binders like\n // bindDeferDirectives need it as a DOM attribute for querySelector lookups\n // (e.g., '[slot=\"placeholder\"]', '[slot=\"error\"]').\n if (node.directives.slot && !el.hasAttribute('slot')) {\n el.setAttribute('slot', node.directives.slot);\n }\n }\n\n // Optional: add dev/debug node ID\n if (node.nodeId) {\n el.setAttribute('data-pid', node.nodeId);\n } else if (node.attrs?.['data-pid']) {\n // Preserve existing data-pid from the original HTML\n el.setAttribute('data-pid', node.attrs['data-pid']);\n }\n\n // Recursively process children\n for (const child of node.children ?? []) {\n const childDom = createDomNodeFromPithy(child, context);\n if (childDom) el.appendChild(childDom);\n }\n\n return el;\n }\n\n return null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGjE,KAAK,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,wBAAgB,cAAc,IAAI;IAChC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CA6CA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,yKAAyK;AACzK,wBAAgB,eAAe,IAAI;IACjC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CASA;AASD,+IAA+I;AAC/I,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,+IAA+I;AAC/I,wBAAgB,gBAAgB,IAAI,YAAY,CAa/C"}
1
+ {"version":3,"file":"renderChildren.d.ts","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGjE,KAAK,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,wBAAgB,cAAc,IAAI;IAChC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CA+CA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,yKAAyK;AACzK,wBAAgB,eAAe,IAAI;IACjC,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CASA;AASD,+IAA+I;AAC/I,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,+IAA+I;AAC/I,wBAAgB,gBAAgB,IAAI,YAAY,CAa/C"}
@@ -51,7 +51,7 @@ export function renderChildren() {
51
51
  const childAstNodes = componentCtx?.__childAstNodes ?? [];
52
52
  // Strip internal __ properties, keep parent scope (includes components, signals, etc.)
53
53
  const parentCtx = componentCtx
54
- ? Object.fromEntries(Object.entries(componentCtx).filter(([k]) => !k.startsWith('__')))
54
+ ? Object.fromEntries(Object.entries(componentCtx).filter(([k]) => !k.startsWith('__') || k === '__pithyRowLocals'))
55
55
  : {};
56
56
  // What a `<slot>` among the children receives.
57
57
  const outer = outerSlotMap(componentCtx?.__slotMap);
@@ -1 +1 @@
1
- {"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAA8B,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAgB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,MAAM,UAAU,cAAc;IAI5B,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,wBAAwB,CAAC;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,wBAAwB,GAAG,SAAS,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,YAAY,GAAG,YAAY,EAAE,CAAC,uBAAuB,CAAC;IAC5D,MAAM,IAAI,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,SAAS,GAAmB,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,OAAO;YACL,EAAE;YACF,OAAO,EAAE,GAAG,EAAE;gBACZ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AO,GAAG,CAAC,CAAC,uBAAuB,CAAC;IAC1C,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,sDAAsD;IACtD,qEAAqE;IACrE,iEAAiE;IACjE,CAAC,CAAC,uBAAuB,GAAG,OAAO,EAAE,wBAAwB,IAAI,SAAS,CAAC;IAC3E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uEAAuE;AACvE,SAAS,gBAAgB,CAAC,GAAsC;IAC9D,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,GAAG,CAAC,cAAc;QACvD,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC;QACxB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAcD;;;;;GAKG;AACH,+IAA+I;AAC/I,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,CAAC,uBAAuB,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,EAAE,cAAc,CAAC;IACxC,MAAM,GAAG,GAAG,OAAO,EAAE,eAAe,CAAC;IACrC,OAAO;QACL,OAAO;QACP,OAAO;QACP,QAAQ,EAAE,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC7D,SAAS,EAAE,CAAC,CAAC,wBAAwB;QACrC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC;QAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import { compileNodes } from './compileNodes';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyGlobals, type PithyComponentContext } from '../types/globals';\nimport type { ChildFactory } from '../runtime/bindings/types';\nimport { outerSlotMap, type SlotMap } from './contentProjection';\nimport { withSlotBoundary } from './binds/bindErrorBoundary';\n\ntype SlotRenderer = NonNullable<ReturnType<SlotMap['get']>>;\n\n/**\n * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a\n * `DocumentFragment` of already-rendered slot children), returns and clears it —\n * single-consume, so the first caller wins. This delivers construction-time\n * children on the registry path. The registry path has no AST fallback, so a\n * second `renderChildren()`/`captureChildren()` call returns an empty fragment.\n *\n * A build-compiled parent's default slot is rendered afresh on every call.\n *\n * Otherwise compiles child AST nodes from the current component context through\n * the full pipeline (structural + non-structural directives). This enables\n * nested components inside projected content — unlike `<slot>`, which inserts\n * DOM after `bindComponentTags` has already run.\n *\n * Use inside component functions (Stack, Grid, etc.) that need to compile\n * their children without named slots or fallback content.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"renderChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function renderChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const globalScope = pithyGlobals();\n const injected = globalScope.__pithyProjectedChildren;\n if (injected) {\n globalScope.__pithyProjectedChildren = undefined;\n return { el: injected, destroy: () => {} };\n }\n\n const componentCtx = pithyGlobals().__pithyComponentContext;\n const slot = buildDefaultSlot(componentCtx);\n if (slot) {\n const disposers: (() => void)[] = [];\n const el = slot(disposers);\n return {\n el,\n destroy: () => {\n for (let i = disposers.length - 1; i >= 0; i--) disposers[i]();\n disposers.length = 0;\n },\n };\n }\n\n // A parent composing atoms by direct call after captureChildren() cleared its\n // context is still mid-render (`rendering` truthy) — not the misuse this guards\n // against, so a consumed context alone must not trigger the warning.\n const rendering = pithyGlobals().__pithyRenderingComponent;\n if (import.meta.env?.DEV && !componentCtx && !rendering) {\n console.warn('[renderChildren] Called outside component render context');\n }\n\n const childAstNodes: PithyNode[] = componentCtx?.__childAstNodes ?? [];\n\n // Strip internal __ properties, keep parent scope (includes components, signals, etc.)\n const parentCtx: Record<string, unknown> = componentCtx\n ? Object.fromEntries(\n Object.entries(componentCtx).filter(([k]) => !k.startsWith('__'))\n )\n : {};\n // What a `<slot>` among the children receives.\n const outer = outerSlotMap(componentCtx?.__slotMap);\n if (outer) parentCtx.__slotMap = outer;\n\n return withSlotBoundary(undefined, componentCtx?.__slotHost, () =>\n compileNodes(childAstNodes, parentCtx)\n );\n}\n\n/**\n * Captures projected children and clears the component context so\n * inner component calls (e.g. `Heading()`, `Text()`) don't consume\n * the outer component's children.\n *\n * After capture, the current component's context on `globalThis` is\n * reset to the value of `__parentComponentContext` if present, or\n * otherwise to `undefined`. In the current core implementation,\n * `__parentComponentContext` is not set by the runtime, so this\n * effectively clears the active component context to prevent child\n * leakage into inner component calls.\n *\n * **Important invariant:** This function must be called exactly once per\n * component, before any inner component function calls. It consumes the\n * current context's children — a second call would return an empty fragment.\n * After this call, the caller must not rely on reading its own context\n * properties from `globalThis.__pithyComponentContext`.\n *\n * For 3+ levels of nesting (e.g., section A → section B → atoms), each\n * level should call `captureChildren()` independently. Any multi-level\n * parent restoration depends on `__parentComponentContext` being managed\n * by external tooling; the core library only performs a best-effort reset\n * from that property when present.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"captureChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function captureChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const g = pithyGlobals();\n const prevCtx = g.__pithyComponentContext;\n const result = renderChildren();\n // Clear context so inner component calls start fresh.\n // If there was a parent context, it will be restored by the parent's\n // own render cycle — we only need to prevent child leakage here.\n g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;\n return result;\n}\n\n/** Default-slot renderer of a build-compiled parent; it has no AST. */\nfunction buildDefaultSlot(ctx: PithyComponentContext | undefined) {\n return ctx && !ctx.__childAstNodes && !ctx.__childFactory\n ? ctx.__slotMap?.get('')\n : undefined;\n}\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildPayload\",\"stability\":\"experimental\",\"signature\":\"interface ChildPayload\"} */\nexport interface ChildPayload {\n context: PithyComponentContext | undefined;\n factory?: ChildFactory;\n astNodes?: PithyNode[];\n projected?: DocumentFragment;\n /** A build's default slot, rendered by `renderChildren()` on each call. */\n slot?: SlotRenderer;\n /** What a `<slot>` among `astNodes` receives. */\n outer?: SlotMap;\n}\n\n/**\n * Reads the children addressed to the component being rendered, without\n * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child\n * factory wins, because a JIT parent's AST can reach an AOT component's context\n * through `mergeContexts`, never the reverse.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"readChildPayload\",\"stability\":\"experimental\",\"signature\":\"() => ChildPayload\"} */\nexport function readChildPayload(): ChildPayload {\n const g = pithyGlobals();\n const context = g.__pithyComponentContext;\n const factory = context?.__childFactory;\n const ast = context?.__childAstNodes;\n return {\n context,\n factory,\n astNodes: !factory && ast && ast.length > 0 ? ast : undefined,\n projected: g.__pithyProjectedChildren,\n slot: buildDefaultSlot(context),\n outer: outerSlotMap(context?.__slotMap),\n };\n}\n"]}
1
+ {"version":3,"file":"renderChildren.js","sourceRoot":"","sources":["../../src/compile/renderChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAA8B,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAgB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D;;;;;;;;;;;;;;;;GAgBG;AACH,wKAAwK;AACxK,MAAM,UAAU,cAAc;IAI5B,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,wBAAwB,CAAC;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,wBAAwB,GAAG,SAAS,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,QAAQ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GAAG,CAAC,CAAC,CAAC,SAAS;QAC7D,SAAS,EAAE,CAAC,CAAC,wBAAwB;QACrC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC;QAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import { compileNodes } from './compileNodes';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport { pithyGlobals, type PithyComponentContext } from '../types/globals';\nimport type { ChildFactory } from '../runtime/bindings/types';\nimport { outerSlotMap, type SlotMap } from './contentProjection';\nimport { withSlotBoundary } from './binds/bindErrorBoundary';\n\ntype SlotRenderer = NonNullable<ReturnType<SlotMap['get']>>;\n\n/**\n * If the registry renderer has set `globalThis.__pithyProjectedChildren` (a\n * `DocumentFragment` of already-rendered slot children), returns and clears it —\n * single-consume, so the first caller wins. This delivers construction-time\n * children on the registry path. The registry path has no AST fallback, so a\n * second `renderChildren()`/`captureChildren()` call returns an empty fragment.\n *\n * A build-compiled parent's default slot is rendered afresh on every call.\n *\n * Otherwise compiles child AST nodes from the current component context through\n * the full pipeline (structural + non-structural directives). This enables\n * nested components inside projected content — unlike `<slot>`, which inserts\n * DOM after `bindComponentTags` has already run.\n *\n * Use inside component functions (Stack, Grid, etc.) that need to compile\n * their children without named slots or fallback content.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"renderChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function renderChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const globalScope = pithyGlobals();\n const injected = globalScope.__pithyProjectedChildren;\n if (injected) {\n globalScope.__pithyProjectedChildren = undefined;\n return { el: injected, destroy: () => {} };\n }\n\n const componentCtx = pithyGlobals().__pithyComponentContext;\n const slot = buildDefaultSlot(componentCtx);\n if (slot) {\n const disposers: (() => void)[] = [];\n const el = slot(disposers);\n return {\n el,\n destroy: () => {\n for (let i = disposers.length - 1; i >= 0; i--) disposers[i]();\n disposers.length = 0;\n },\n };\n }\n\n // A parent composing atoms by direct call after captureChildren() cleared its\n // context is still mid-render (`rendering` truthy) — not the misuse this guards\n // against, so a consumed context alone must not trigger the warning.\n const rendering = pithyGlobals().__pithyRenderingComponent;\n if (import.meta.env?.DEV && !componentCtx && !rendering) {\n console.warn('[renderChildren] Called outside component render context');\n }\n\n const childAstNodes: PithyNode[] = componentCtx?.__childAstNodes ?? [];\n\n // Strip internal __ properties, keep parent scope (includes components, signals, etc.)\n const parentCtx: Record<string, unknown> = componentCtx\n ? Object.fromEntries(\n Object.entries(componentCtx).filter(\n ([k]) => !k.startsWith('__') || k === '__pithyRowLocals'\n )\n )\n : {};\n // What a `<slot>` among the children receives.\n const outer = outerSlotMap(componentCtx?.__slotMap);\n if (outer) parentCtx.__slotMap = outer;\n\n return withSlotBoundary(undefined, componentCtx?.__slotHost, () =>\n compileNodes(childAstNodes, parentCtx)\n );\n}\n\n/**\n * Captures projected children and clears the component context so\n * inner component calls (e.g. `Heading()`, `Text()`) don't consume\n * the outer component's children.\n *\n * After capture, the current component's context on `globalThis` is\n * reset to the value of `__parentComponentContext` if present, or\n * otherwise to `undefined`. In the current core implementation,\n * `__parentComponentContext` is not set by the runtime, so this\n * effectively clears the active component context to prevent child\n * leakage into inner component calls.\n *\n * **Important invariant:** This function must be called exactly once per\n * component, before any inner component function calls. It consumes the\n * current context's children — a second call would return an empty fragment.\n * After this call, the caller must not rely on reading its own context\n * properties from `globalThis.__pithyComponentContext`.\n *\n * For 3+ levels of nesting (e.g., section A → section B → atoms), each\n * level should call `captureChildren()` independently. Any multi-level\n * parent restoration depends on `__parentComponentContext` being managed\n * by external tooling; the core library only performs a best-effort reset\n * from that property when present.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"captureChildren\",\"stability\":\"stable\",\"signature\":\"() => { el: DocumentFragment; destroy: () => void }\"} */\nexport function captureChildren(): {\n el: DocumentFragment;\n destroy: () => void;\n} {\n const g = pithyGlobals();\n const prevCtx = g.__pithyComponentContext;\n const result = renderChildren();\n // Clear context so inner component calls start fresh.\n // If there was a parent context, it will be restored by the parent's\n // own render cycle — we only need to prevent child leakage here.\n g.__pithyComponentContext = prevCtx?.__parentComponentContext ?? undefined;\n return result;\n}\n\n/** Default-slot renderer of a build-compiled parent; it has no AST. */\nfunction buildDefaultSlot(ctx: PithyComponentContext | undefined) {\n return ctx && !ctx.__childAstNodes && !ctx.__childFactory\n ? ctx.__slotMap?.get('')\n : undefined;\n}\n\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"ChildPayload\",\"stability\":\"experimental\",\"signature\":\"interface ChildPayload\"} */\nexport interface ChildPayload {\n context: PithyComponentContext | undefined;\n factory?: ChildFactory;\n astNodes?: PithyNode[];\n projected?: DocumentFragment;\n /** A build's default slot, rendered by `renderChildren()` on each call. */\n slot?: SlotRenderer;\n /** What a `<slot>` among `astNodes` receives. */\n outer?: SlotMap;\n}\n\n/**\n * Reads the children addressed to the component being rendered, without\n * consuming them. `factory` and `astNodes` are mutually exclusive: an AOT child\n * factory wins, because a JIT parent's AST can reach an AOT component's context\n * through `mergeContexts`, never the reverse.\n */\n/** @codexApi {\"parent\":\"pithy.runtime.compile-nodes\",\"name\":\"readChildPayload\",\"stability\":\"experimental\",\"signature\":\"() => ChildPayload\"} */\nexport function readChildPayload(): ChildPayload {\n const g = pithyGlobals();\n const context = g.__pithyComponentContext;\n const factory = context?.__childFactory;\n const ast = context?.__childAstNodes;\n return {\n context,\n factory,\n astNodes: !factory && ast && ast.length > 0 ? ast : undefined,\n projected: g.__pithyProjectedChildren,\n slot: buildDefaultSlot(context),\n outer: outerSlotMap(context?.__slotMap),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAOF,OAAO,EAoBL,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,IAAI,EACJ,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,GACX,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8RAA8R;AAC9R,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,IAAI,EAAE,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,oBAAoB,UAAO,GAC1B;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA0L/C"}
1
+ {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAOF,OAAO,EAqBL,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,IAAI,EACJ,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,GACX,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8RAA8R;AAC9R,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,IAAI,EAAE,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,oBAAoB,UAAO,GAC1B;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA4L/C"}
@@ -10,7 +10,7 @@ import { clearSSRRenderCrash } from '../compile/ssrCrashes.js';
10
10
  import { nodeExpando } from '../compile/nodeExpando.js';
11
11
  import { orderByDocument } from '../compile/disposeOrder.js';
12
12
  import { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry.js';
13
- import { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, applyRef, applyError, applyProjection, applyComponent, applyBind, applyInterpolation, applyEvent, applyClass, applyClasses, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings/index.js';
13
+ import { buildPidMap, buildCommentMap, mergeContexts, nearestCtx, applyRef, applyError, applyProjection, applyComponent, applyBind, applyInterpolation, markSkeletonText, applyEvent, applyClass, applyClasses, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings/index.js';
14
14
  // ─── Main entry point ─────────────────────────────────────────────────────────
15
15
  /**
16
16
  * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
@@ -57,6 +57,8 @@ export function __applyBindings(fragment, bindings, context, ownsDestroyCallback
57
57
  }
58
58
  return bindingsResult(fragment, disposers, destroyCallbacks);
59
59
  }
60
+ if (bindings.some(d => d.t === 'interp'))
61
+ markSkeletonText(fragment);
60
62
  // Build lookup maps
61
63
  const pidMap = buildPidMap(fragment);
62
64
  const commentMap = buildCommentMap(fragment);
@@ -1 +1 @@
1
- {"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GAiBX,MAAM,YAAY,CAAC;AAsBpB,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8RAA8R;AAC9R,MAAM,UAAU,eAAe,CAC7B,QAA0B,EAC1B,QAAgB,EAChB,OAAgC,EAChC,oBAAoB,GAAG,IAAI;IAE3B,4EAA4E;IAC5E,4EAA4E;IAC5E,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7E,MAAM,SAAS,GAAmB,EAAE,CAAC;IAErC,+EAA+E;IAC/E,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEnC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,6BAA6B,CAAC,QAAQ,EAAE,GAAG,EA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SAAyB,EACzB,gBAAgC;IAEhC,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,OAAO;YACL,mEAAmE;YACnE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,IAAI,CAAC;oBACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,8DAA8D;YAC9D,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport { clearSSRRenderCrash } from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport { orderByDocument } from '../compile/disposeOrder';\nimport { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\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};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder that reaches a runtime-compiled component's binder (slot\n // content serialized into a descriptor without `slots`, or a failed\n // render left in place) is rendered through this hook, in the context it\n // was written in.\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first. One this pass already\n // rendered is never retried (`true`).\n const failedIn = new Map<CompDesc, ParentNode | null | true>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n const failed = failedIn.get(d);\n if (failed === true || (failed && el.parentNode === failed)) return [];\n const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);\n failedIn.set(d, nodes ? null : el.parentNode);\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n if (!applyComponent(d, el, ctx, disposers, pidMap))\n failedIn.set(d, true);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n clearSSRRenderCrash(el);\n }\n }\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n orderByDocument(disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,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AC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.runtime.apply-bindings\",\n \"title\": \"AOT Binding Applicator\",\n \"category\": \"runtime\"\n}\n*/\n\nimport { drainDestroyCallbacks } from './onDestroy';\nimport { clearSSRRenderCrash } from '../compile/ssrCrashes';\nimport { nodeExpando } from '../compile/nodeExpando';\nimport { orderByDocument } from '../compile/disposeOrder';\nimport { executeCustomDirectiveBinders } from '../compile/binds/directiveRegistry';\nimport {\n buildPidMap,\n buildCommentMap,\n mergeContexts,\n nearestCtx,\n applyRef,\n applyError,\n applyProjection,\n applyComponent,\n applyBind,\n applyInterpolation,\n markSkeletonText,\n applyEvent,\n applyClass,\n applyClasses,\n applyStyle,\n applyBound,\n applyIf,\n applyFor,\n applySwitch,\n applyDefer,\n type Desc,\n type EventDesc,\n type InterpDesc,\n type ClassDesc,\n type ClassesDesc,\n type StyleDesc,\n type BoundDesc,\n type RefDesc,\n type BindDesc,\n type CompDesc,\n type DeferDesc,\n type ErrorDesc,\n type ProjDesc,\n type IfDesc,\n type ForDesc,\n type SwitchDesc,\n} from './bindings';\n\n// Re-export types for external consumers\nexport type {\n Desc,\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};\n\n// ─── Main entry point ─────────────────────────────────────────────────────────\n\n/**\n * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.\n *\n * This is the Phase 5 runtime binder — the counterpart to the build-time\n * codegen (Phases 1-4). It processes descriptor arrays emitted by\n * generateDomFactory + generateBindings and wires reactive effects,\n * event handlers, component mounts, and structural directive logic.\n *\n * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:\n * 1. Structural: switch → if → for\n * 2. Non-structural: ref → error → projection → component → bind →\n * interpolation → event → class → classes → style → bound attr →\n * custom directives → defer\n *\n * Differences from JIT bindTemplateDirectives:\n * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)\n *\n * Custom directives (registered via `registerDirectiveBinder`, e.g. the\n * router's `@routerLink`) run even when `bindings` is empty: codegen emits no\n * descriptor for them, only the `data-*` marker attribute.\n *\n * @param fragment - DOM fragment created by the AOT factory function\n * @param bindings - Array of binding descriptors from codegen\n * @param context - Reactive context object with signals, methods, components\n */\n/** @codexApi {\"parent\":\"pithy.runtime.apply-bindings\",\"name\":\"__applyBindings\",\"stability\":\"experimental\",\"signature\":\"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>, ownsDestroyCallbacks?: boolean) => { el: DocumentFragment; destroy: () => void }\"} */\nexport function __applyBindings(\n fragment: DocumentFragment,\n bindings: Desc[],\n context: Record<string, unknown>,\n ownsDestroyCallbacks = true\n): { el: DocumentFragment; destroy: () => void } {\n // Drain onDestroy() callbacks BEFORE processing bindings — child components\n // instantiated during binding will drain their own callbacks independently.\n const destroyCallbacks = ownsDestroyCallbacks ? drainDestroyCallbacks() : [];\n\n const disposers: (() => void)[] = [];\n\n // Merge parent component + async (SSR) contexts — AOT factories bypass html().\n // Before the empty-bindings branch: custom binders must see the same context\n // whether or not the template also carries an ordinary descriptor.\n const ctx = mergeContexts(context);\n\n if (bindings.length === 0) {\n try {\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n return bindingsResult(fragment, disposers, destroyCallbacks);\n }\n\n if (bindings.some(d => d.t === 'interp')) markSkeletonText(fragment);\n\n // Build lookup maps\n const pidMap = buildPidMap(fragment);\n const commentMap = buildCommentMap(fragment);\n\n // Group descriptors by type for ordered processing\n const byType = new Map<string, Desc[]>();\n for (const d of bindings as Desc[]) {\n const list = byType.get(d.t) ?? [];\n list.push(d);\n byType.set(d.t, list);\n }\n\n try {\n // ─── Phase 1: Structural directives (shape-changing) ─────────────────\n // Order: switch → if → for (matches bindStructuralDirectives)\n\n for (const d of (byType.get('switch') ?? []) as SwitchDesc[]) {\n applySwitch(d, pidMap, ctx, disposers);\n }\n for (const d of (byType.get('if') ?? []) as IfDesc[]) {\n applyIf(d, commentMap, ctx, disposers);\n }\n for (const d of (byType.get('for') ?? []) as ForDesc[]) {\n applyFor(d, commentMap, ctx, disposers);\n }\n\n // ─── Phase 2: Non-structural bindings ────────────────────────────────\n // Order matches bindTemplateDirectives: ref → error → proj → comp →\n // bind → interp → event → class → classes → style → bound → defer\n\n for (const d of (byType.get('ref') ?? []) as RefDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyRef(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('error') ?? []) as ErrorDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyError(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('proj') ?? []) as ProjDesc[]) {\n applyProjection(d, commentMap, ctx, disposers);\n }\n\n // A placeholder that reaches a runtime-compiled component's binder (slot\n // content serialized into a descriptor without `slots`, or a failed\n // render left in place) is rendered through this hook, in the context it\n // was written in.\n const comps = (byType.get('comp') ?? []) as CompDesc[];\n const mounted = new Set<CompDesc>();\n // A hooked tag's forwarded bindings live on its latest root, owned by the\n // disposers of whoever rendered it, and are replayed on every mount.\n type Bind = (el: Element, ds: (() => void)[]) => void;\n const binds = new Map<string, Bind[]>();\n const live = new Map<string, { root: Element; ds: (() => void)[] }>();\n // A placeholder that failed stays put, and every enclosing slot's pass\n // finds it again; a re-mount moves it first. One this pass already\n // rendered is never retried (`true`).\n const failedIn = new Map<CompDesc, ParentNode | null | true>();\n for (const d of comps) {\n const el = pidMap.get(d.pid);\n if (!el) continue;\n const scope = nearestCtx(el, ctx);\n binds.set(d.pid, []);\n nodeExpando(el).__pithyAotMount = slotDisposers => {\n mounted.add(d);\n const failed = failedIn.get(d);\n if (failed === true || (failed && el.parentNode === failed)) return [];\n const nodes = applyComponent(d, el, ctx, slotDisposers, pidMap, scope);\n failedIn.set(d, nodes ? null : el.parentNode);\n // On failure `pidMap` still holds the previous root.\n const root = nodes && pidMap.get(d.pid);\n if (!nodes || !root) return nodes ?? [];\n const mount = { root, ds: slotDisposers };\n live.set(d.pid, mount);\n // A slot closed before a later binding is queued must not receive it.\n slotDisposers.push(() => {\n if (live.get(d.pid) === mount) live.delete(d.pid);\n });\n for (const bind of binds.get(d.pid) ?? []) bind(root, slotDisposers);\n return nodes;\n };\n }\n const forwarded = (pid: string, bind: Bind) => {\n const stored = binds.get(pid);\n const mount = live.get(pid);\n stored?.push(bind);\n if (mount) bind(mount.root, mount.ds);\n else if (!stored) {\n const el = pidMap.get(pid);\n if (el) bind(el, disposers);\n }\n };\n\n for (const d of comps) {\n if (mounted.has(d)) continue;\n const el = pidMap.get(d.pid);\n // `pidMap` is built once, up front. An activated `@error-boundary`\n // detaches its normal children, so a later sibling's placeholder can\n // still be in the map while no longer being in the tree. Rendering it is\n // pointless — and because it can no longer resolve the boundary that\n // already handled the failure, recording its crash would fail a route\n // whose fallback rendered perfectly well. Mirrors the `scope.contains(el)`\n // guard in `bindComponentTags`.\n //\n // This does not affect a structural branch factory binding a detached\n // subtree: that calls `applyBindings` with the branch's OWN fragment as\n // `fragment`, so its placeholders are inside it and still bind.\n if (el && fragment.contains(el)) {\n if (!applyComponent(d, el, ctx, disposers, pidMap))\n failedIn.set(d, true);\n binds.delete(d.pid);\n } else if (el) {\n // Left the tree, so it contributes nothing to the output — and any crash\n // recorded for it on an earlier detached pass is stale. Same reasoning\n // as the `scope.contains(el)` skip in `bindComponentTags`.\n clearSSRRenderCrash(el);\n }\n }\n\n for (const d of (byType.get('bind') ?? []) as BindDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyBind(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('interp') ?? []) as InterpDesc[]) {\n // pid === '' means root-level text node (no parent element with data-pid)\n const el = d.pid === '' ? fragment : pidMap.get(d.pid);\n if (el) applyInterpolation(d, el, ctx, disposers);\n }\n\n for (const d of (byType.get('event') ?? []) as EventDesc[]) {\n forwarded(d.pid, (el, ds) => applyEvent(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('class') ?? []) as ClassDesc[]) {\n forwarded(d.pid, (el, ds) => applyClass(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('classes') ?? []) as ClassesDesc[]) {\n forwarded(d.pid, (el, ds) => applyClasses(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('style') ?? []) as StyleDesc[]) {\n forwarded(d.pid, (el, ds) => applyStyle(d, el, ctx, ds));\n }\n\n for (const d of (byType.get('bound') ?? []) as BoundDesc[]) {\n forwarded(d.pid, (el, ds) => applyBound(d, el, ctx, ds));\n }\n\n executeCustomDirectiveBinders(fragment, ctx, disposers);\n\n for (const d of (byType.get('defer') ?? []) as DeferDesc[]) {\n const el = pidMap.get(d.pid);\n if (el) applyDefer(d, el as HTMLElement, ctx, disposers);\n }\n orderByDocument(disposers);\n } catch (err) {\n unwind(disposers, destroyCallbacks);\n throw err;\n }\n\n return bindingsResult(fragment, disposers, destroyCallbacks);\n}\n\n/** Runs everything registered so far after a partial bind fails. */\nfunction unwind(\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): void {\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore */\n }\n }\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction bindingsResult(\n fragment: DocumentFragment,\n disposers: (() => void)[],\n destroyCallbacks: (() => void)[]\n): { el: DocumentFragment; destroy: () => void } {\n return {\n el: fragment,\n destroy() {\n // Reverse order: child disposers (pushed later) run before parents\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n disposers[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n disposers.length = 0;\n // onDestroy callbacks in LIFO order, after template disposers\n for (let i = destroyCallbacks.length - 1; i >= 0; i--) {\n try {\n destroyCallbacks[i]();\n } catch {\n /* ignore disposal errors */\n }\n }\n destroyCallbacks.length = 0;\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAwItE,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc,GACrB,IAAI,EAAE,GAAG,SAAS,CAsPpB"}
1
+ {"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAyItE,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,CAAC,EAAE,cAAc,GACrB,IAAI,EAAE,GAAG,SAAS,CAwQpB"}
@@ -12,6 +12,7 @@ import { isRenderableComponentEl } from '../../compile/componentResult.js';
12
12
  import { clearSSRRenderCrash, reportComponentFailure, } from '../../compile/ssrCrashes.js';
13
13
  import { isolateDestroyCallbacks } from '../onDestroy.js';
14
14
  import { parsePropNames } from '../../compile/binds/propNames.js';
15
+ import { watchStaleRowProp } from '../../compile/binds/staleRowProps.js';
15
16
  import { nodeExpando } from '../../compile/nodeExpando.js';
16
17
  import { anchorDisposer, componentDisposer } from '../../compile/disposeOrder.js';
17
18
  /** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */
@@ -155,11 +156,16 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
155
156
  const expectedProps = extractExpectedPropNames(componentFn);
156
157
  // Evaluate prop expressions with prop name normalization
157
158
  const props = {};
159
+ const staleWatchers = [];
158
160
  for (const [rawName, expr] of Object.entries(d.props)) {
159
161
  const propName = normalizePropName(rawName, expectedProps);
160
162
  try {
161
163
  const fn = compileExpression(expr, localCtx);
162
164
  props[propName] = untrack(fn);
165
+ if (import.meta.env?.DEV) {
166
+ const value = props[propName];
167
+ staleWatchers.push(() => watchStaleRowProp(localCtx, d, d.tag, propName, expr, value, fn, disposers));
168
+ }
163
169
  }
164
170
  catch {
165
171
  // Leave undefined — child uses defaults
@@ -315,6 +321,9 @@ export function applyComponent(d, el, ctx, disposers, pidMap, scope) {
315
321
  }
316
322
  pidMap.delete(d.pid);
317
323
  }
324
+ if (replaced)
325
+ for (const watch of staleWatchers)
326
+ watch();
318
327
  const teardown = componentDisposer(destroy, disposeSetup, nodes[0] ?? (replaced ? null : el));
319
328
  if (teardown)
320
329
  disposers.push(teardown);