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

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 (51) hide show
  1. package/README.md +6 -2
  2. package/dist/compile/bindSwitchCases.d.ts +7 -2
  3. package/dist/compile/bindSwitchCases.d.ts.map +1 -1
  4. package/dist/compile/bindSwitchCases.js +123 -149
  5. package/dist/compile/bindSwitchCases.js.map +1 -1
  6. package/dist/compile/binds/bindClassDirectives.d.ts +2 -2
  7. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
  8. package/dist/compile/binds/bindClassDirectives.js +32 -11
  9. package/dist/compile/binds/bindClassDirectives.js.map +1 -1
  10. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
  11. package/dist/compile/binds/bindComponentsTags.js +3 -0
  12. package/dist/compile/binds/bindComponentsTags.js.map +1 -1
  13. package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
  14. package/dist/compile/binds/bindConditionals.js +4 -0
  15. package/dist/compile/binds/bindConditionals.js.map +1 -1
  16. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
  17. package/dist/compile/binds/bindErrorBoundary.js +5 -0
  18. package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
  19. package/dist/compile/binds/bindStyleDirectives.d.ts +15 -0
  20. package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
  21. package/dist/compile/binds/bindStyleDirectives.js +41 -0
  22. package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
  23. package/dist/compile/compileTemplate.d.ts +3 -4
  24. package/dist/compile/compileTemplate.d.ts.map +1 -1
  25. package/dist/compile/compileTemplate.js +11 -15
  26. package/dist/compile/compileTemplate.js.map +1 -1
  27. package/dist/compile/contentProjection.d.ts +1 -1
  28. package/dist/compile/contentProjection.d.ts.map +1 -1
  29. package/dist/compile/contentProjection.js +16 -3
  30. package/dist/compile/contentProjection.js.map +1 -1
  31. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
  32. package/dist/compile/forLoops/createLoopManager.js +5 -14
  33. package/dist/compile/forLoops/createLoopManager.js.map +1 -1
  34. package/dist/compile/forLoops/loopTraversal.js +2 -2
  35. package/dist/compile/forLoops/loopTraversal.js.map +1 -1
  36. package/dist/compile/handleConditionalChain.d.ts.map +1 -1
  37. package/dist/compile/handleConditionalChain.js +11 -8
  38. package/dist/compile/handleConditionalChain.js.map +1 -1
  39. package/dist/compile/nodeExpando.d.ts +1 -0
  40. package/dist/compile/nodeExpando.d.ts.map +1 -1
  41. package/dist/compile/nodeExpando.js.map +1 -1
  42. package/dist/compile/parseHtml.d.ts.map +1 -1
  43. package/dist/compile/parseHtml.js +1 -1
  44. package/dist/compile/parseHtml.js.map +1 -1
  45. package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
  46. package/dist/runtime/bindings/applySimple.js +17 -3
  47. package/dist/runtime/bindings/applySimple.js.map +1 -1
  48. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
  49. package/dist/runtime/bindings/applyStructural.js +12 -4
  50. package/dist/runtime/bindings/applyStructural.js.map +1 -1
  51. package/package.json +4 -4
package/README.md CHANGED
@@ -296,10 +296,11 @@ The `@for` directive provides keyed, reactive list rendering with:
296
296
  | onDestroy | onDestroy | `(fn: () => void) => void` | stable | - |
297
297
  | bindBoundAttributes | attributes | `(root: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
298
298
  | bindClassDirectives | classes | `(root: Element | DocumentFragment, ctx: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
299
- | applyClassGroup | classes | `(el: Element, result: unknown) => void` | internal | - |
299
+ | applyClassGroup | classes | `(el: Element, result: unknown, owned: Set<string>) => void` | internal | - |
300
300
  | bindComponentTags | components | `(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
301
301
  | bindDefaultTwoWay | two-way-binding | `(fragment: Element | DocumentFragment, context: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
302
302
  | bindEventHandlers | events | `(root: Element | DocumentFragment, rootCtx: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
303
+ | bindStyleProperties | styles | `(el: Element, ctx: Record<string, unknown>, disposers: (() => void)[]) => void` | internal | Binds `[style.prop]="expr"`, which the parser emits as `data-style-prop`, through the same `applyStyle` a build uses. Only names the element declared are bound; an author's own `data-style-*` attribute is left alone. |
303
304
  | bindTextInterpolations | interpolations | `(root: Element | DocumentFragment, ctx: Record<string, unknown>, disposers: (() => void)[]) => void` | stable | - |
304
305
  | buildPidMap | binding-helpers | `(fragment: DocumentFragment) => Map<string, Element>` | internal | - |
305
306
  | buildCommentMap | binding-helpers | `(fragment: DocumentFragment) => Map<string, Comment>` | internal | - |
@@ -313,7 +314,8 @@ The `@for` directive provides keyed, reactive list rendering with:
313
314
  <!-- @codex:auto api="pithy.directive.**" format="table" -->
314
315
  | API | Component | Signature | Stability | Description |
315
316
  | --- | --- | --- | --- | --- |
316
- | bindSwitchCases | switch | `(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => void` | stable | - |
317
+ | bindSwitchCases | switch | `(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>` | stable | - |
318
+ | bindSwitchBlock | switch | `(switchNode: PithyNode, parentElement: HTMLElement, ctx: Record<string, unknown>, processedNodeIds: Set<string>, disposers: (() => void)[]) => boolean` | experimental | - |
317
319
  | handleConditionalChain | conditional-chain | `(domChain: HTMLElement[], astChain: PithyNode[], ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>` | stable | - |
318
320
  | bindConditionals | if | `(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>` | stable | - |
319
321
  | bindForLoops | for | `(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, disposers?: (() => void)[], processedNodeIds?: Set<string>) => void` | stable | - |
@@ -424,6 +426,7 @@ pnpm test -- --watch # Watch mode
424
426
  | bindComponentTags | - | - | - | Missing unit, integration, e2e |
425
427
  | bindDefaultTwoWay | - | - | - | Missing unit, integration, e2e |
426
428
  | bindEventHandlers | - | - | - | Missing unit, integration, e2e |
429
+ | bindStyleProperties | - | - | - | Missing unit, integration, e2e |
427
430
  | bindTextInterpolations | - | - | - | Missing unit, integration, e2e |
428
431
  | buildPidMap | - | - | - | Missing unit, integration, e2e |
429
432
  | buildCommentMap | - | - | - | Missing unit, integration, e2e |
@@ -436,6 +439,7 @@ pnpm test -- --watch # Watch mode
436
439
  | Feature | Unit | Integration | E2E | Status |
437
440
  | --- | --- | --- | --- | --- |
438
441
  | bindSwitchCases | - | - | - | Missing unit, integration |
442
+ | bindSwitchBlock | - | - | - | Missing unit, integration |
439
443
  | handleConditionalChain | - | - | - | Missing unit, integration |
440
444
  | bindConditionals | - | - | - | Missing unit, integration |
441
445
  | bindForLoops | - | - | - | Missing unit, integration |
@@ -10,7 +10,12 @@ import { type PithyNode } from '@pithyjs/compiler';
10
10
  * Processes switch case directives (@switch, @case, @default) in the template.
11
11
  * Identifies switch blocks and delegates their handling to handleSwitchBlock.
12
12
  */
13
- /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchCases","stability":"stable","signature":"(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => void"} */
13
+ /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchCases","stability":"stable","signature":"(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>"} */
14
14
  export declare function bindSwitchCases(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, // Track already processed nodes
15
- disposers?: (() => void)[]): void;
15
+ disposers?: (() => void)[]): Set<string>;
16
+ /**
17
+ * Binds one @switch element whose DOM is already built.
18
+ */
19
+ /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchBlock","stability":"experimental","signature":"(switchNode: PithyNode, parentElement: HTMLElement, ctx: Record<string, unknown>, processedNodeIds: Set<string>, disposers: (() => void)[]) => boolean"} */
20
+ export declare function bindSwitchBlock(switchNode: PithyNode, parentElement: HTMLElement, ctx: Record<string, unknown>, processedNodeIds: Set<string>, disposers: (() => void)[]): boolean;
16
21
  //# sourceMappingURL=bindSwitchCases.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindSwitchCases.d.ts","sourceRoot":"","sources":["../../src/compile/bindSwitchCases.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOlE;;;GAGG;AACH,+QAA+Q;AAC/Q,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,WAAW,GAAG,gBAAgB,EACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,EAAE,gCAAgC;AAC3E,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,GAC7B,IAAI,CAyHN"}
1
+ {"version":3,"file":"bindSwitchCases.d.ts","sourceRoot":"","sources":["../../src/compile/bindSwitchCases.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYlE;;;GAGG;AACH,sRAAsR;AACtR,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,WAAW,GAAG,gBAAgB,EACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,EAAE,gCAAgC;AAC3E,SAAS,GAAE,CAAC,MAAM,IAAI,CAAC,EAAO,GAC7B,GAAG,CAAC,MAAM,CAAC,CA0Db;AAUD;;GAEG;AACH,6QAA6Q;AAC7Q,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,WAAW,EAC1B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,OAAO,CAwCT"}
@@ -10,12 +10,17 @@ import { createRoot, effect } from '@pithyjs/signals';
10
10
  import { compileExpression } from './compileExpression';
11
11
  import { bindConditionals } from './binds/bindConditionals';
12
12
  import { flashUpdate } from './binds/bindTextInterpolations';
13
+ import { bindTemplateDirectives } from './compileTemplate';
14
+ import { bindForLoops } from './forLoops/bindForLoops';
15
+ import { findAllNestedLoopNodes } from './forLoops/loopTraversal';
16
+ import { nodeExpando } from './nodeExpando';
17
+ import { pithyTreeToDom } from './pithyTreeToDom';
13
18
  import { isSSRMode } from './ssrMode';
14
19
  /**
15
20
  * Processes switch case directives (@switch, @case, @default) in the template.
16
21
  * Identifies switch blocks and delegates their handling to handleSwitchBlock.
17
22
  */
18
- /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchCases","stability":"stable","signature":"(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => void"} */
23
+ /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchCases","stability":"stable","signature":"(nodes: PithyNode[], rootEl: HTMLElement | DocumentFragment, ctx: Record<string, unknown>, processedNodeIds?: Set<string>, disposers?: (() => void)[]) => Set<string>"} */
19
24
  export function bindSwitchCases(nodes, rootEl, ctx, processedNodeIds = new Set(), // Track already processed nodes
20
25
  disposers = [] // Collect disposers for cleanup
21
26
  ) {
@@ -31,79 +36,104 @@ disposers = [] // Collect disposers for cleanup
31
36
  }
32
37
  });
33
38
  }
34
- // First, identify all switch blocks
35
- const switchBlocks = [];
36
- // Iterate through all nodes to identify switch blocks
37
- for (let i = 0; i < nodes.length; i++) {
38
- const node = nodes[i];
39
- // Check if this node has an @switch directive
40
- if (node.type === 'element' && node.directives?.switch !== undefined) {
41
- // Found a switch block, collect its children
42
- if (node.children && node.children.length > 0) {
43
- // Filter children to only include those with @case or @default directives
44
- const caseNodes = node.children.filter(child => child.type === 'element' &&
45
- (child.directives?.case !== undefined || isDefaultCase(child)));
46
- if (caseNodes.length > 0) {
47
- switchBlocks.push({ parent: node, children: caseNodes });
48
- }
49
- }
50
- }
51
- }
52
- // Process each switch block
53
- switchBlocks.forEach(block => {
54
- // Mark all nodes in this block as processed
55
- if (block.parent.nodeId) {
56
- processedNodeIds.add(block.parent.nodeId);
39
+ const switchIds = new Set();
40
+ for (const node of nodes) {
41
+ if (node.type !== 'element' || node.directives?.switch === undefined) {
42
+ continue;
57
43
  }
58
- block.children.forEach(node => {
59
- if (node.nodeId) {
60
- processedNodeIds.add(node.nodeId);
61
- }
62
- });
63
- // Find the DOM elements for this switch block
64
- const parentElement = block.parent.nodeId
65
- ? elMap.get(block.parent.nodeId)
66
- : null;
44
+ if (isConditionalBranch(node))
45
+ continue;
46
+ const parentElement = node.nodeId ? elMap.get(node.nodeId) : null;
67
47
  if (!parentElement) {
68
48
  console.error('[bindSwitchCases] Could not find parent element for switch block');
69
- return;
70
- }
71
- const caseElements = block.children
72
- .map(node => {
73
- if (!node.nodeId) {
74
- return null;
75
- }
76
- // Use the Map for O(1) lookup
77
- const element = elMap.get(node.nodeId);
78
- if (!element) {
79
- return null;
80
- }
81
- return element;
82
- })
83
- .filter((el) => el !== null);
84
- // Verify we found all DOM elements
85
- if (caseElements.length !== block.children.length) {
86
- console.error('[bindSwitchCases] Could not find all case elements');
87
- return;
88
- }
89
- handleSwitchBlock(parentElement, caseElements, block.parent, block.children, ctx, disposers);
90
- });
91
- // Recursively process children of all nodes, skipping those already processed in switch blocks
92
- for (let i = 0; i < nodes.length; i++) {
93
- const node = nodes[i];
94
- // Skip nodes that were already processed as part of a switch block
95
- if (node.nodeId && processedNodeIds.has(node.nodeId)) {
96
49
  continue;
97
50
  }
51
+ if (bindSwitchBlock(node, parentElement, ctx, processedNodeIds, disposers) &&
52
+ node.nodeId)
53
+ switchIds.add(node.nodeId);
54
+ }
55
+ for (const node of nodes) {
56
+ if (node.nodeId && switchIds.has(node.nodeId))
57
+ continue;
58
+ if (node.nodeId && processedNodeIds.has(node.nodeId))
59
+ continue;
60
+ if (isConditionalBranch(node))
61
+ continue;
62
+ if (node.isComponent)
63
+ continue;
98
64
  if (node.type === 'element' && node.children?.length) {
99
- // Use the Map for O(1) lookup
100
65
  const element = node.nodeId ? elMap.get(node.nodeId) : null;
101
66
  if (element instanceof HTMLElement) {
102
- // Pass the processedNodeIds Set and disposers to avoid duplicate processing
103
67
  bindSwitchCases(node.children, element, ctx, processedNodeIds, disposers);
104
68
  }
105
69
  }
106
70
  }
71
+ return processedNodeIds;
72
+ }
73
+ function isConditionalBranch(node) {
74
+ return (node.directives?.if !== undefined ||
75
+ node.directives?.elseIf !== undefined ||
76
+ node.directives?.else !== undefined);
77
+ }
78
+ /**
79
+ * Binds one @switch element whose DOM is already built.
80
+ */
81
+ /** @codexApi {"parent":"pithy.directive.switch","name":"bindSwitchBlock","stability":"experimental","signature":"(switchNode: PithyNode, parentElement: HTMLElement, ctx: Record<string, unknown>, processedNodeIds: Set<string>, disposers: (() => void)[]) => boolean"} */
82
+ export function bindSwitchBlock(switchNode, parentElement, ctx, processedNodeIds, disposers) {
83
+ const caseNodes = (switchNode.children || []).filter(child => child.type === 'element' &&
84
+ (child.directives?.case !== undefined || isDefaultCase(child)));
85
+ if (caseNodes.length === 0)
86
+ return false;
87
+ for (const node of caseNodes) {
88
+ if (node.nodeId)
89
+ processedNodeIds.add(node.nodeId);
90
+ for (const loopNode of findAllNestedLoopNodes(node)) {
91
+ if (loopNode.nodeId)
92
+ processedNodeIds.add(loopNode.nodeId);
93
+ }
94
+ }
95
+ const childByPid = new Map();
96
+ for (const child of Array.from(parentElement.children)) {
97
+ const pid = child.getAttribute('data-pid');
98
+ if (pid)
99
+ childByPid.set(pid, child);
100
+ }
101
+ const caseElements = caseNodes
102
+ .map(node => (node.nodeId ? childByPid.get(node.nodeId) : undefined))
103
+ .filter((el) => el !== undefined);
104
+ if (caseElements.length !== caseNodes.length) {
105
+ console.error('[bindSwitchCases] Could not find all case elements');
106
+ return true;
107
+ }
108
+ removeNonCaseChildren(parentElement, caseElements, switchNode);
109
+ handleSwitchBlock(parentElement, caseElements, switchNode, caseNodes, ctx, disposers);
110
+ return true;
111
+ }
112
+ const warnedSwitches = new WeakSet();
113
+ function removeNonCaseChildren(parentElement, caseElements, switchNode) {
114
+ const cases = new Set(caseElements);
115
+ let dropped;
116
+ for (const child of Array.from(parentElement.childNodes)) {
117
+ if (cases.has(child))
118
+ continue;
119
+ if (child.nodeType === Node.TEXT_NODE && !child.textContent?.trim()) {
120
+ continue;
121
+ }
122
+ const node = nodeExpando(child).__pithyNode;
123
+ if (child.nodeType === Node.TEXT_NODE)
124
+ dropped ?? (dropped = JSON.stringify(child.textContent?.trim()));
125
+ else if (node?.type === 'slot')
126
+ dropped ?? (dropped = '<slot>');
127
+ else if (node)
128
+ dropped ?? (dropped = `<${node.originalTagName ?? node.tagName}>`);
129
+ else if (child.nodeType === Node.ELEMENT_NODE)
130
+ dropped ?? (dropped = `<${child.localName}>`);
131
+ child.remove();
132
+ }
133
+ if (dropped && import.meta.env?.DEV && !warnedSwitches.has(switchNode)) {
134
+ warnedSwitches.add(switchNode);
135
+ console.warn(`[bindSwitchCases] @switch renders only its @case/@default children; ${dropped} is dropped, as in a build`);
136
+ }
107
137
  }
108
138
  /**
109
139
  * Handles rendering and reactivity for an @switch/@case/@default block.
@@ -119,13 +149,7 @@ function handleSwitchBlock(parentElement, caseElements, switchNode, caseNodes, c
119
149
  for (const el of caseElements) {
120
150
  el.remove();
121
151
  }
122
- // Store original elements and create a pool of reusable elements
123
- const originalElements = caseElements.map(el => el.cloneNode(true));
124
- // Create a pool of elements for reuse to preserve internal state
125
- const elementPool = Array(caseElements.length).fill(null);
126
- // Keep track of the currently displayed element and its index
127
152
  let currentElement = null;
128
- let currentCaseIndex = -1;
129
153
  // Track disposers for the current case
130
154
  let currentDisposers = [];
131
155
  // Cache for compiled expressions to avoid recompiling on each change
@@ -163,20 +187,18 @@ function handleSwitchBlock(parentElement, caseElements, switchNode, caseNodes, c
163
187
  return undefined;
164
188
  }
165
189
  }
166
- // Create a function to clean up the current element and its bindings
167
190
  function cleanupCurrentElement() {
168
- // Run all disposers to clean up event handlers and other bindings
169
- currentDisposers.forEach(disposer => disposer());
191
+ for (const dispose of currentDisposers) {
192
+ try {
193
+ dispose();
194
+ }
195
+ catch {
196
+ /* ignore */
197
+ }
198
+ }
170
199
  currentDisposers = [];
171
200
  if (currentElement && currentElement.parentNode) {
172
201
  currentElement.remove();
173
- // Clear the pool slot so we clone a fresh element next time
174
- // This is necessary because bindConditionals modifies the DOM structure
175
- // (replaces @if/@else elements with placeholder comments), so reusing
176
- // the pooled element would cause binding to fail on subsequent renders
177
- if (currentCaseIndex >= 0) {
178
- elementPool[currentCaseIndex] = null;
179
- }
180
202
  currentElement = null;
181
203
  return true;
182
204
  }
@@ -202,7 +224,8 @@ function handleSwitchBlock(parentElement, caseElements, switchNode, caseNodes, c
202
224
  }
203
225
  else if (isDefaultCase(node)) {
204
226
  // This is a @default node, remember its index but continue checking other cases
205
- defaultIndex = i;
227
+ if (defaultIndex === -1)
228
+ defaultIndex = i;
206
229
  }
207
230
  }
208
231
  // If no case matched but we have a default, use that
@@ -211,83 +234,34 @@ function handleSwitchBlock(parentElement, caseElements, switchNode, caseNodes, c
211
234
  }
212
235
  return matchIndex;
213
236
  }
214
- // Shared logic for rendering the matched case
215
237
  function renderMatchedCase(matchIndex) {
216
- // If we found a match, insert the corresponding element
217
238
  if (matchIndex < 0 || !placeholder.parentNode)
218
239
  return;
219
- let elementToUse;
220
- // Check if we have a reusable element in the pool
221
- if (elementPool[matchIndex]) {
222
- // Reuse the existing element from the pool
223
- elementToUse = elementPool[matchIndex];
224
- }
225
- else {
226
- // Create a new element and add it to the pool
227
- elementToUse = originalElements[matchIndex].cloneNode(true);
228
- elementPool[matchIndex] = elementToUse;
229
- }
230
- // Insert the element after the placeholder
231
- placeholder.parentNode.insertBefore(elementToUse, placeholder.nextSibling);
232
- // Update our current element reference and index
233
- currentElement = elementToUse;
234
- currentCaseIndex = matchIndex;
235
- // Process children of the matched element and collect disposers
236
240
  const matchedAst = caseNodes[matchIndex];
237
- // Create a new array to collect disposers for this case
238
- const caseDisposers = [];
239
- // Bind conditionals and collect their disposers
241
+ const rebuiltElement = pithyTreeToDom([matchedAst], ctx)
242
+ .firstChild;
243
+ if (!rebuiltElement)
244
+ return;
245
+ currentElement = rebuiltElement;
246
+ currentDisposers = [];
247
+ const children = matchedAst.isComponent ? [] : matchedAst.children || [];
240
248
  createRoot(disposeRoot => {
241
- caseDisposers.push(disposeRoot);
242
- bindConditionals(matchedAst.children || [], elementToUse, ctx, new Set(), caseDisposers);
249
+ currentDisposers.push(disposeRoot);
250
+ const processed = new Set();
251
+ if (matchedAst.directives?.switch !== undefined &&
252
+ !matchedAst.isComponent)
253
+ bindSwitchBlock(matchedAst, rebuiltElement, ctx, processed, currentDisposers);
254
+ else
255
+ bindSwitchCases(children, rebuiltElement, ctx, processed, currentDisposers);
256
+ bindConditionals(children, rebuiltElement, ctx, processed, currentDisposers);
257
+ bindForLoops(children, rebuiltElement, ctx, currentDisposers, processed);
258
+ const tempFragment = document.createDocumentFragment();
259
+ tempFragment.appendChild(rebuiltElement);
260
+ bindTemplateDirectives(tempFragment, ctx, currentDisposers);
243
261
  });
244
- // Bind event handlers and collect their disposers (skip during SSR - no user interaction)
245
- if (!isSSRMode()) {
246
- const eventDisposers = [];
247
- elementToUse.querySelectorAll('*').forEach((el) => {
248
- Array.from(el.attributes).forEach((attr) => {
249
- if (!attr.name.startsWith('data-on-'))
250
- return;
251
- const eventName = attr.name.replace('data-on-', '');
252
- const handlerExpr = attr.value.trim();
253
- let handler;
254
- // If expression is a simple identifier, resolve it from context
255
- const isSimpleFunction = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(handlerExpr);
256
- if (isSimpleFunction) {
257
- const fn = ctx[handlerExpr];
258
- if (typeof fn === 'function') {
259
- handler = fn;
260
- }
261
- else {
262
- console.warn(`[Switch-${switchId}] Context does not contain a function '${handlerExpr}'`);
263
- return;
264
- }
265
- }
266
- else {
267
- // Complex expression: compile it
268
- try {
269
- handler = compileExpression(handlerExpr, ctx);
270
- }
271
- catch (err) {
272
- console.warn(`[Switch-${switchId}] Failed to compile expression @${eventName}="${handlerExpr}"`, err);
273
- return;
274
- }
275
- }
276
- // Bind event and store unbind disposer
277
- el.addEventListener(eventName, handler);
278
- eventDisposers.push(() => el.removeEventListener(eventName, handler));
279
- });
280
- });
281
- // Add event disposers to our case disposers
282
- caseDisposers.push(() => {
283
- eventDisposers.forEach(dispose => dispose());
284
- });
285
- }
286
- // Store the disposers for this case
287
- currentDisposers = caseDisposers;
288
- // Defer flashUpdate via queueMicrotask to prevent blocking
262
+ placeholder.parentNode.insertBefore(rebuiltElement, placeholder.nextSibling);
289
263
  if (!isSSRMode()) {
290
- queueMicrotask(() => flashUpdate(elementToUse));
264
+ queueMicrotask(() => flashUpdate(rebuiltElement));
291
265
  }
292
266
  }
293
267
  if (isSSRMode()) {
@@ -1 +1 @@
1
- {"version":3,"file":"bindSwitchCases.js","sourceRoot":"","sources":["../../src/compile/bindSwitchCases.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,aAAa,EAAkB,MAAM,mBAAmB,C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AU,CAAC,YAAY,CACjC,cAAc,EACd,WAAW,CAAC,WAAW,CACxB,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACjB,cAAc,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,IAAI,SAAS,EAAE,EAAE,CAAC;QAChB,6DAA6D;QAC7D,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;QACtC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9B,iEAAiE;QACjE,gEAAgE;QAChE,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,mDAAmD;QACnD,qEAAqE;QACrE,IAAI,kBAAkB,GAAG,CAAC,CAAC,CAAC;QAE5B,2DAA2D;QAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,EAAE;YAC7B,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;YAEtC,4CAA4C;YAC5C,IAAI,UAAU,KAAK,kBAAkB,EAAE,CAAC;gBACtC,OAAO;YACT,CAAC;YAED,wDAAwD;YACxD,qBAAqB,EAAE,CAAC;YACxB,kCAAkC;YAClC,kBAAkB,GAAG,UAAU,CAAC;YAChC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YAE9B,4DAA4D;YAC5D,iEAAiE;YACjE,oEAAoE;QACtE,CAAC,CAAC,CAAC;QAEH,2EAA2E;QAC3E,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACtC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -17,6 +17,6 @@
17
17
  */
18
18
  /** @codexApi {"parent":"pithy.runtime.classes","name":"bindClassDirectives","stability":"stable","signature":"(root: Element | DocumentFragment, ctx: Record<string, unknown>, disposers: (() => void)[]) => void"} */
19
19
  export declare function bindClassDirectives(root: Element | DocumentFragment, ctx: Record<string, unknown>, disposers: (() => void)[]): void;
20
- /** @codexApi {"parent":"pithy.runtime.classes","name":"applyClassGroup","stability":"internal","signature":"(el: Element, result: unknown) => void"} */
21
- export declare function applyClassGroup(el: Element, result: unknown): void;
20
+ /** @codexApi {"parent":"pithy.runtime.classes","name":"applyClassGroup","stability":"internal","signature":"(el: Element, result: unknown, owned: Set<string>) => void"} */
21
+ export declare function applyClassGroup(el: Element, result: unknown, owned: Set<string>): void;
22
22
  //# sourceMappingURL=bindClassDirectives.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindClassDirectives.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindClassDirectives.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAMF;;;;;;;;;GASG;AACH,uNAAuN;AACvN,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAsEN;AAED,wJAAwJ;AACxJ,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAYlE"}
1
+ {"version":3,"file":"bindClassDirectives.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindClassDirectives.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAOF;;;;;;;;;GASG;AACH,uNAAuN;AACvN,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA0EN;AAED,4KAA4K;AAC5K,wBAAgB,eAAe,CAC7B,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GACjB,IAAI,CAwBN"}
@@ -8,6 +8,7 @@
8
8
  import { effect } from '@pithyjs/signals';
9
9
  import { compileExpression } from '../compileExpression';
10
10
  import { nodeExpando } from '../nodeExpando';
11
+ import { bindStyleProperties } from './bindStyleDirectives';
11
12
  /**
12
13
  * Binds class directives like:
13
14
  * • [class.active]="isActive"
@@ -65,9 +66,10 @@ export function bindClassDirectives(root, ctx, disposers) {
65
66
  console.warn(`[PithyJS] ⚠️ Failed to compile [classes]="${classGroupExpr}"`, err);
66
67
  return;
67
68
  }
69
+ const owned = new Set();
68
70
  const stop = effect(() => {
69
71
  try {
70
- applyClassGroup(el, evaluate());
72
+ applyClassGroup(el, evaluate(), owned);
71
73
  }
72
74
  catch (err) {
73
75
  console.warn('[PithyJS] ⚠️ Failed to evaluate [classes]:', err);
@@ -75,23 +77,42 @@ export function bindClassDirectives(root, ctx, disposers) {
75
77
  });
76
78
  disposers.push(stop);
77
79
  }
80
+ // After the classes, so the attributes serialise in the build's order.
81
+ bindStyleProperties(el, elCtx, disposers);
78
82
  });
79
83
  }
80
- /** @codexApi {"parent":"pithy.runtime.classes","name":"applyClassGroup","stability":"internal","signature":"(el: Element, result: unknown) => void"} */
81
- export function applyClassGroup(el, result) {
84
+ /** @codexApi {"parent":"pithy.runtime.classes","name":"applyClassGroup","stability":"internal","signature":"(el: Element, result: unknown, owned: Set<string>) => void"} */
85
+ export function applyClassGroup(el, result, owned) {
86
+ const named = new Map();
87
+ const name = (classes, on) => {
88
+ for (const c of classes.split(/[\t\n\f\r ]+/))
89
+ if (c)
90
+ named.set(c, on);
91
+ };
82
92
  if (Array.isArray(result)) {
83
- for (const cls of result) {
93
+ for (const cls of result)
84
94
  if (typeof cls === 'string')
85
- el.classList.add(cls);
86
- }
95
+ name(cls, true);
87
96
  }
88
97
  else if (result && typeof result === 'object') {
89
- for (const [cls, on] of Object.entries(result)) {
90
- for (const c of cls.split(/\s+/)) {
91
- if (c)
92
- el.classList.toggle(c, !!on);
93
- }
98
+ for (const [cls, on] of Object.entries(result))
99
+ name(cls, !!on);
100
+ }
101
+ // `owned` is this binding's own record, not the element's: a component's
102
+ // root `[classes]` and one forwarded from its tag share the element, and
103
+ // each may only remove the classes it added.
104
+ const previous = new Set(owned);
105
+ owned.clear();
106
+ for (const [c, on] of named) {
107
+ if (!on)
108
+ el.classList.remove(c);
109
+ else if (previous.has(c) || !el.classList.contains(c)) {
110
+ el.classList.add(c);
111
+ owned.add(c);
94
112
  }
95
113
  }
114
+ for (const c of previous)
115
+ if (!named.has(c))
116
+ el.classList.remove(c);
96
117
  }
97
118
  //# sourceMappingURL=bindClassDirectives.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindClassDirectives.js","sourceRoot":"","sources":["../../../src/compile/binds/bindClassDirectives.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;GASG;AACH,uNAAuN;AACvN,MAAM,UAAU,mBAAmB,CACjC,IAAgC,EAChC,GAA4B,EAC5B,SAAyB;IAEzB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QACtC,sEAAsE;QACtE,6DAA6D;QAC7D,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,UAAU,IAAI,GAAG,CAAC;QAEhD,uDAAuD;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC;gBAAE,SAAS;YAE1D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;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CAAC;YAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bindComponentsTags.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AA4JF;;;;;;GAMG;AACH,4NAA4N;AAC5N,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA4UN"}
1
+ {"version":3,"file":"bindComponentsTags.d.ts","sourceRoot":"","sources":["../../../src/compile/binds/bindComponentsTags.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AA4JF;;;;;;GAMG;AACH,4NAA4N;AAC5N,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,GAAG,gBAAgB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CA+UN"}
@@ -400,6 +400,9 @@ export function bindComponentTags(root, rootCtx, disposers) {
400
400
  // Forward captured attributes so subsequent binders can attach the bindings
401
401
  if (forwardedAttrs.length > 0 && forwardTarget) {
402
402
  applyForwardedAttrs(forwardTarget, forwardedAttrs, tag);
403
+ const styleProps = Object.keys(pithyNode?.directives?.styleMap ?? {});
404
+ if (styleProps.length)
405
+ nodeExpando(forwardTarget).__styleProps = styleProps;
403
406
  }
404
407
  if (disposeSetup) {
405
408
  disposers.push(disposeSetup);