@pithyjs/vite-plugin 0.2.0-beta.11 → 0.2.0-beta.13

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.
@@ -13,7 +13,7 @@
13
13
  }
14
14
  }
15
15
  */
16
- import type { PithyNode } from '@pithyjs/compiler';
16
+ import { type PithyNode } from '@pithyjs/compiler';
17
17
  export interface AotCodegenResult {
18
18
  /** Complete JS code for the factory function + bindings const (includes sub-factory code) */
19
19
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"generateDomFactory.d.ts","sourceRoot":"","sources":["../../src/aotCodegen/generateDomFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAsBnD,MAAM,WAAW,gBAAgB;IAC/B,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,uOAAuO;AACvO,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAAE,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CAoGlB"}
1
+ {"version":3,"file":"generateDomFactory.d.ts","sourceRoot":"","sources":["../../src/aotCodegen/generateDomFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAsB3B,MAAM,WAAW,gBAAgB;IAC/B,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,uOAAuO;AACvO,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAAE,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CAoGlB"}
@@ -13,6 +13,7 @@
13
13
  }
14
14
  }
15
15
  */
16
+ import { componentChildDirectiveMessage, componentChildDirectives, } from '@pithyjs/compiler';
16
17
  import { createSerializeContext, serializeNode, } from './serializeNode.js';
17
18
  import { generateBindings, serializeBindings, } from './generateBindings.js';
18
19
  import { collectIfChain, stripStructuralDirective, isDefaultCase, } from './structuralCodegen.js';
@@ -179,6 +180,8 @@ function processNodes(nodes, ctx, safeHash, scopeId, subFactoryCodeBlocks, struc
179
180
  if (node.directives?.elseIf !== undefined ||
180
181
  node.directives?.else !== undefined)
181
182
  console.warn(`[pithy:aot] ${node.directives.elseIf !== undefined ? '@else-if' : '@else'} has no @if directly before it; <${node.originalTagName ?? node.tagName}> is dropped`);
183
+ else
184
+ console.warn(`[pithy:aot] ${node.directives?.case !== undefined ? '@case' : '@default'} has no @switch parent, or its @switch is on a @for element (BUG-070); <${node.originalTagName ?? node.tagName}> is dropped`);
182
185
  continue;
183
186
  }
184
187
  // ─── @for loop ───────────────────────────────────────────────────
@@ -294,7 +297,11 @@ function processNodes(nodes, ctx, safeHash, scopeId, subFactoryCodeBlocks, struc
294
297
  // Generate sub-factory for fallback content if present
295
298
  if (node.fallbackChildren && node.fallbackChildren.length > 0) {
296
299
  const fbHash = `${safeHash}_slot_${pid}`;
297
- const sub = generateDomFactory(node.fallbackChildren, fbHash, scopeId, {
300
+ // Roots of the fallback factory, so bare text binds at its root.
301
+ const roots = node.fallbackChildren.map(child => child.parentId === node.nodeId
302
+ ? { ...child, parentId: undefined }
303
+ : child);
304
+ const sub = generateDomFactory(roots, fbHash, scopeId, {
298
305
  ...options,
299
306
  sub: true,
300
307
  });
@@ -313,6 +320,8 @@ function processNodes(nodes, ctx, safeHash, scopeId, subFactoryCodeBlocks, struc
313
320
  if (!result)
314
321
  continue;
315
322
  const tag = node.originalTagName ?? node.tagName ?? '';
323
+ for (const name of componentChildDirectives(node))
324
+ console.warn(`[pithy:aot] ${componentChildDirectiveMessage(tag, name)}`);
316
325
  if (node.isComponent &&
317
326
  node.nodeId &&
318
327
  node.children?.length &&
@@ -1 +1 @@
1
- {"version":3,"file":"generateDomFactory.js","sourceRoot":"","sources":["../../src/aotCodegen/generateDomFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAGF,OAAO,EACL,sBAAsB,EACtB,aAAa,GAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAkBnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,uOAAuO;AACvO,MAAM,UAAU,kBAAkB,CAChC,KAAkB,EAClB,IAAY,EACZ,OAAgB,E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AU,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAC3B,CAAuC;IAEvC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QACjC,CAAC,CAAE,IAAgC;QACnC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.aot.generate-dom-factory\",\n \"title\": \"AOT DOM Factory Generator\",\n \"category\": \"compiler\",\n \"description\": \"Generates a DOM factory function from parsed template nodes, producing static HTML with binding placeholders.\",\n \"since\": \"0.0.1\",\n \"stability\": \"experimental\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"aotCodegen.test.ts\" },\n \"integration\": { \"required\": false, \"covered\": false },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport type { PithyNode } from '@pithyjs/compiler';\nimport {\n createSerializeContext,\n serializeNode,\n type SerializeContext,\n} from './serializeNode';\nimport {\n generateBindings,\n serializeBindings,\n type BindingDescriptor,\n type IfDescriptor,\n type ForDescriptor,\n type SwitchDescriptor,\n type ProjectionDescriptor,\n} from './generateBindings';\nimport {\n collectIfChain,\n stripStructuralDirective,\n isDefaultCase,\n} from './structuralCodegen';\nimport { escapeJS } from './utils';\n\nexport interface AotCodegenResult {\n /** Complete JS code for the factory function + bindings const (includes sub-factory code) */\n code: string;\n /** The factory function name (e.g. \"__f_a7f3\") */\n factoryName: string;\n /** The bindings variable name (e.g. \"__b_a7f3\") */\n bindingsName: string;\n}\n\nexport interface AotCodegenOptions {\n templateComponents?: ReadonlySet<string>;\n wrappable?: boolean;\n anchorSlots?: ReadonlyMap<string, string>;\n sub?: boolean;\n}\n\n/**\n * Generate AOT code from a PithyNode tree.\n *\n * Produces:\n * 1. Sub-factory code for structural directives (@if branches, @for bodies, @switch cases)\n * 2. A bindings descriptor array (const __b_{hash} = [...])\n * 3. A DOM factory function (function __f_{hash}(__ctx) { ... })\n *\n * The factory creates DOM nodes via createElement/createTextNode,\n * sets static attributes, and calls __applyBindings with the\n * pre-extracted descriptors.\n *\n * Structural directives generate sub-factory functions (via recursive calls)\n * and comment placeholders in the parent factory. Sub-factory code is prepended\n * to the output so function references resolve correctly.\n *\n * **Phase 5 gap:** AOT factories do not set runtime-only DOM properties that\n * `pithyTreeToDom` assigns (`__pithyCtx`, `__pithyNode`, `__nodeId`,\n * `__slotName`, `__fallbackFactory`). Phase 5's `applyBindings()` will need\n * to set these on the factory-created DOM before wiring reactive effects.\n *\n * @param nodes - Parsed PithyNode tree (from parse5ToPithyTree)\n * @param hash - Unique identifier for this template (used in names)\n * @param scopeId - CSS scope ID (e.g. \"pithy-abc123\")\n *\n * @example\n * ```typescript\n * const result = generateDomFactory(pithyNodes, 'a7f3', 'pithy-abc');\n * // result.code contains the full factory + bindings code\n * // result.factoryName is \"__f_a7f3\"\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.aot.generate-dom-factory\",\"name\":\"generateDomFactory\",\"stability\":\"experimental\",\"signature\":\"(nodes: PithyNode[], hash: string, scopeId?: string, options?: AotCodegenOptions) => AotCodegenResult\"} */\nexport function generateDomFactory(\n nodes: PithyNode[],\n hash: string,\n scopeId?: string,\n options: AotCodegenOptions = {}\n): AotCodegenResult {\n // Validate scopeId — it's interpolated into an attribute name (data-scope-{id}),\n // so it must contain only characters valid in HTML attribute names.\n if (scopeId && !/^[a-zA-Z0-9_-]+$/.test(scopeId)) {\n throw new Error(\n `AOT: invalid scopeId \"${scopeId}\" — must contain only alphanumeric, hyphen, or underscore characters.`\n );\n }\n\n // Sanitize hash to ensure valid JS identifiers (replace non-alphanumeric with _)\n const safeHash = hash.replace(/[^a-zA-Z0-9_$]/g, '_');\n const factoryName = `__f_${safeHash}`;\n const bindingsName = `__b_${safeHash}`;\n\n // Accumulate sub-factory code blocks (emitted before this factory)\n const subFactoryCodeBlocks: string[] = [];\n\n // Accumulate structural descriptors (merged with Phase 1 descriptors)\n const structuralDescriptors: BindingDescriptor[] = [];\n\n const childFactories = new Map<string, string>();\n const slotFactories = new Map<string, Record<string, string>>();\n const subOptions: AotCodegenOptions = {\n templateComponents: options.templateComponents,\n anchorSlots: options.anchorSlots,\n };\n\n // Generate DOM factory body\n const ctx = createSerializeContext(scopeId);\n\n // Process all nodes recursively, handling structural directives at every level\n const topLevelVarNames = processNodes(\n nodes,\n ctx,\n safeHash,\n scopeId,\n subFactoryCodeBlocks,\n structuralDescriptors,\n subOptions,\n childFactories,\n slotFactories\n );\n\n // Generate Phase 1 binding descriptors (non-structural)\n const phase1Descriptors = generateBindings(\n nodes,\n childFactories,\n slotFactories\n );\n\n // Merge all descriptors: structural first, then Phase 1\n const allDescriptors = [...structuralDescriptors, ...phase1Descriptors];\n const bindingsCode = serializeBindings(allDescriptors);\n\n // Build factory function body\n const bodyLines: string[] = [];\n bodyLines.push(`const f=document.createDocumentFragment();`);\n\n // Add all serialized node creation code\n bodyLines.push(...ctx.lines);\n\n // Append top-level nodes to fragment\n if (topLevelVarNames.length === 1) {\n bodyLines.push(`f.appendChild(${topLevelVarNames[0]});`);\n } else if (topLevelVarNames.length > 1) {\n bodyLines.push(`f.append(${topLevelVarNames.join(',')});`);\n }\n\n const fragment = options.wrappable ? '(__wrap?__wrap(f):f)' : 'f';\n const bindingsArg = allDescriptors.length > 0 ? bindingsName : '[]';\n const drainArg = options.sub ? ',false' : '';\n bodyLines.push(\n `return __applyBindings(${fragment},${bindingsArg},__ctx${drainArg});`\n );\n\n // Assemble final code: sub-factories first, then this factory\n const codeLines: string[] = [];\n\n // Sub-factory code blocks (from structural directives)\n for (const block of subFactoryCodeBlocks) {\n codeLines.push(block);\n }\n\n // Bindings constant (only if non-empty)\n if (allDescriptors.length > 0) {\n codeLines.push(`const ${bindingsName}=${bindingsCode};`);\n }\n\n // Factory function\n codeLines.push(\n `function ${factoryName}(__ctx${options.wrappable ? ',__wrap' : ''}){`\n );\n codeLines.push(...bodyLines);\n codeLines.push(`}`);\n\n return {\n code: codeLines.join('\\n'),\n factoryName,\n bindingsName,\n };\n}\n\n// ─── Internal: recursive tree processing with structural awareness ───────────\n\n/**\n * Process an array of sibling nodes, handling structural directives at every level.\n * Returns the varNames of the processed top-level nodes (for parent.append()).\n *\n * This function replaces the simple for-of loop over serializeNode calls.\n * It detects structural directives (which span siblings for @if chains)\n * and delegates to sub-factory generation, creating comment placeholders\n * in the current factory for the structural nodes.\n *\n * For non-structural elements, it serializes the element shell (no children)\n * via serializeNode, then recursively processes children here.\n */\nfunction processNodes(\n nodes: PithyNode[],\n ctx: SerializeContext,\n safeHash: string,\n scopeId: string | undefined,\n subFactoryCodeBlocks: string[],\n structuralDescriptors: BindingDescriptor[],\n options: AotCodegenOptions,\n childFactories: Map<string, string>,\n slotFactories: Map<string, Record<string, string>>\n): string[] {\n const varNames: string[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n\n // ─── @if/@else-if/@else chain ────────────────────────────────────\n if (node.type === 'element' && node.directives?.if !== undefined) {\n const chain = collectIfChain(nodes, i);\n const pid = node.nodeId ?? `_${i}`;\n i += chain.length - 1; // Skip consumed siblings\n\n // Generate sub-factory for each branch\n const branches: IfDescriptor['branches'] = [];\n for (let b = 0; b < chain.length; b++) {\n const branchNode = chain[b];\n const branchHash = `${safeHash}_if_${pid}_${b}`;\n const stripped = stripStructuralDirective(branchNode);\n if (branchNode.directives?.switch !== undefined)\n stripped.directives = {\n ...stripped.directives,\n switch: branchNode.directives.switch,\n };\n const sub = generateDomFactory([stripped], branchHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const branch: IfDescriptor['branches'][0] = {\n factory: sub.factoryName,\n };\n if (branchNode.directives?.if !== undefined)\n branch.expr = branchNode.directives.if;\n else if (branchNode.directives?.elseIf !== undefined)\n branch.expr = branchNode.directives.elseIf;\n branches.push(branch);\n }\n\n // Emit comment placeholder\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('if:${escapeJS(pid)}');`\n );\n markAnchorSlot(ctx, commentVar, options.anchorSlots?.get(pid));\n varNames.push(commentVar);\n\n structuralDescriptors.push({ t: 'if', pid, branches });\n continue;\n }\n\n // ─── Orphaned @else-if, @else, @case, @default ────────────────────\n if (\n node.type === 'element' &&\n (node.directives?.elseIf !== undefined ||\n node.directives?.else !== undefined ||\n node.directives?.case !== undefined ||\n isDefaultCase(node))\n ) {\n if (\n node.directives?.elseIf !== undefined ||\n node.directives?.else !== undefined\n )\n console.warn(\n `[pithy:aot] ${node.directives.elseIf !== undefined ? '@else-if' : '@else'} has no @if directly before it; <${node.originalTagName ?? node.tagName}> is dropped`\n );\n continue;\n }\n\n // ─── @for loop ───────────────────────────────────────────────────\n if (node.type === 'element' && node.directives?.for) {\n const pid = node.nodeId ?? `_${i}`;\n const forHash = `${safeHash}_for_${pid}`;\n const stripped = stripStructuralDirective(node);\n const sub = generateDomFactory([stripped], forHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('for:${escapeJS(pid)}');`\n );\n markAnchorSlot(ctx, commentVar, options.anchorSlots?.get(pid));\n varNames.push(commentVar);\n\n const forDir = node.directives.for;\n const desc: ForDescriptor = {\n t: 'for',\n pid,\n item: forDir.itemVar,\n expr: forDir.collectionExpr,\n factory: sub.factoryName,\n };\n if (forDir.indexVar) desc.index = forDir.indexVar;\n if (forDir.trackBy) desc.trackBy = forDir.trackBy;\n structuralDescriptors.push(desc);\n continue;\n }\n\n // ─── @switch block ───────────────────────────────────────────────\n if (node.type === 'element' && node.directives?.switch !== undefined) {\n const pid = node.nodeId ?? `_${i}`;\n // Ensure the original node has nodeId so generateBindings can find it too\n if (!node.nodeId) node.nodeId = pid;\n\n // Serialize the switch container (without children, without @switch directive).\n // nodeId is guaranteed set above, so data-pid is always emitted.\n const switchShell: PithyNode = {\n ...node,\n children: [],\n directives: stripSwitchDirective(node.directives),\n };\n const shellResult = serializeNode(switchShell, ctx);\n if (shellResult) varNames.push(shellResult.varName);\n\n // Generate sub-factory for each @case/@default child\n const cases: SwitchDescriptor['cases'] = [];\n let dropped: string | undefined;\n for (let c = 0; c < (node.children ?? []).length; c++) {\n const caseNode = node.children![c];\n if (\n caseNode.type !== 'element' ||\n (caseNode.directives?.case === undefined && !isDefaultCase(caseNode))\n ) {\n if (caseNode.type === 'element')\n dropped ??= `<${caseNode.originalTagName ?? caseNode.tagName}>`;\n else if (caseNode.type === 'slot') dropped ??= '<slot>';\n else if (caseNode.type === 'text' && caseNode.textContent?.trim())\n dropped ??= JSON.stringify(caseNode.textContent.trim());\n continue;\n }\n\n const caseHash = `${safeHash}_sw_${pid}_${c}`;\n const stripped = stripStructuralDirective(caseNode);\n if (caseNode.directives?.switch !== undefined)\n stripped.directives = {\n ...stripped.directives,\n switch: caseNode.directives.switch,\n };\n const sub = generateDomFactory([stripped], caseHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const caseDesc: SwitchDescriptor['cases'][0] = {\n factory: sub.factoryName,\n };\n if (caseNode.directives?.case !== undefined)\n caseDesc.val = caseNode.directives.case;\n cases.push(caseDesc);\n }\n\n if (dropped)\n console.warn(\n `[pithy:aot] @switch renders only its @case/@default children; ${dropped} is dropped`\n );\n\n structuralDescriptors.push({\n t: 'switch',\n pid,\n expr: node.directives.switch,\n cases,\n });\n continue;\n }\n\n // ─── Text nodes ─────────────────────────────────────────────────\n if (node.type === 'text') {\n const result = serializeNode(node, ctx);\n if (result) varNames.push(result.varName);\n continue;\n }\n\n // ─── Slot nodes (content projection) ─────────────────────────────\n if (node.type === 'slot') {\n const slotName = node.slotName ?? '';\n const pid = node.nodeId ?? `_slot_${ctx.commentCount}`;\n\n // Emit comment anchor for the slot\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('slot:${escapeJS(slotName)}');`\n );\n varNames.push(commentVar);\n\n // Build projection descriptor\n const projDesc: ProjectionDescriptor = {\n t: 'proj',\n pid,\n name: slotName,\n };\n\n // Generate sub-factory for fallback content if present\n if (node.fallbackChildren && node.fallbackChildren.length > 0) {\n const fbHash = `${safeHash}_slot_${pid}`;\n const sub = generateDomFactory(node.fallbackChildren, fbHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n projDesc.fallback = sub.factoryName;\n }\n\n structuralDescriptors.push(projDesc);\n continue;\n }\n\n // ─── Regular element (no structural directive on THIS node) ──────\n // Serialize element shell (without children) via serializeNode,\n // then process children recursively with structural awareness.\n if (node.type === 'element') {\n const shell: PithyNode = { ...node, children: [] };\n const result = serializeNode(shell, ctx);\n if (!result) continue;\n\n const tag = node.originalTagName ?? node.tagName ?? '';\n if (\n node.isComponent &&\n node.nodeId &&\n node.children?.length &&\n options.templateComponents?.has(tag)\n ) {\n const { children, anchorSlots } = asTemplateRoots(\n node.children,\n node.nodeId,\n tag\n );\n const sub = generateDomFactory(\n children,\n `${safeHash}_tpl_${node.nodeId}`,\n scopeId,\n { ...options, wrappable: true, anchorSlots }\n );\n subFactoryCodeBlocks.push(sub.code);\n childFactories.set(node.nodeId, sub.factoryName);\n varNames.push(result.varName);\n continue;\n }\n\n // Each slot mount renders and binds its content afresh, as dev does.\n if (node.isComponent && node.nodeId && node.children?.length) {\n const slots: Record<string, string> = Object.create(null);\n let n = 0;\n for (const [name, group] of groupSlots(\n node.children,\n node.nodeId,\n tag\n )) {\n const sub = generateDomFactory(\n group,\n `${safeHash}_cs_${node.nodeId}_${n++}`,\n scopeId,\n { ...options, sub: true }\n );\n subFactoryCodeBlocks.push(sub.code);\n slots[name] = sub.factoryName;\n }\n slotFactories.set(node.nodeId, slots);\n varNames.push(result.varName);\n continue;\n }\n\n // Recursively process children (handles nested structural directives)\n const childVarNames = processNodes(\n node.children ?? [],\n ctx,\n safeHash,\n scopeId,\n subFactoryCodeBlocks,\n structuralDescriptors,\n options,\n childFactories,\n slotFactories\n );\n\n // Append children to this element\n if (childVarNames.length === 1) {\n ctx.lines.push(`${result.varName}.appendChild(${childVarNames[0]});`);\n } else if (childVarNames.length > 1) {\n ctx.lines.push(`${result.varName}.append(${childVarNames.join(',')});`);\n }\n\n varNames.push(result.varName);\n continue;\n }\n }\n\n return varNames;\n}\n\nfunction markAnchorSlot(\n ctx: SerializeContext,\n commentVar: string,\n slot: string | undefined\n): void {\n if (slot === undefined) return;\n ctx.lines.push(`${commentVar}.__pithyAnchorSlot='${escapeJS(slot)}';`);\n}\n\nconst BLANK = /^[ \\t\\n\\f\\r]*$/;\n\nfunction warnMixedChainSlots(\n nodes: PithyNode[],\n ownerTag: string,\n outcome: string\n): void {\n let chainSlot: string | undefined;\n let inChain = false;\n let chainWarned = false;\n for (const { directives: d } of nodes) {\n const isBranch = d?.elseIf !== undefined || d?.else !== undefined;\n if (d?.if !== undefined) {\n inChain = true;\n chainSlot = d.slot;\n chainWarned = false;\n } else if (!isBranch) {\n inChain = false;\n }\n if (isBranch && inChain && d.slot !== chainSlot && !chainWarned) {\n chainWarned = true;\n console.warn(\n `[pithy:aot] <${ownerTag}>: the branches of an @if chain carry different slots ` +\n `(${chainSlot ?? 'none'} and ${d.slot ?? 'none'}). ${outcome}`\n );\n }\n if (d?.else !== undefined) inChain = false;\n }\n}\n\n/** Groups a component's children by slot name, as `collectSlotMap` does. */\nfunction groupSlots(\n nodes: PithyNode[],\n ownerId: string,\n ownerTag: string\n): Map<string, PithyNode[]> {\n warnMixedChainSlots(\n nodes,\n ownerTag,\n 'Each slot keeps only the branches that name it; a branch cut off from its @if is dropped.'\n );\n const groups = new Map<string, PithyNode[]>();\n for (const child of nodes) {\n const name = child.directives?.slot || '';\n const root =\n child.parentId === ownerId ? { ...child, parentId: undefined } : child;\n const group = groups.get(name);\n if (group) group.push(root);\n else groups.set(name, [root]);\n }\n const blank = (n: PithyNode) =>\n n.type === 'text' && BLANK.test(n.textContent ?? '');\n const main = groups.get('');\n if (main) {\n let start = 0;\n let end = main.length;\n while (start < end && blank(main[start])) start++;\n while (end > start && blank(main[end - 1])) end--;\n if (start < end) groups.set('', main.slice(start, end));\n else groups.delete('');\n }\n return groups;\n}\n\nfunction asTemplateRoots(\n nodes: PithyNode[],\n ownerId: string,\n ownerTag: string\n): { children: PithyNode[]; anchorSlots: Map<string, string> } {\n const anchorSlots = new Map<string, string>();\n warnMixedChainSlots(\n nodes,\n ownerTag,\n 'The whole chain is placed by its first branch.'\n );\n\n const children = nodes.map(child => {\n const root =\n child.parentId === ownerId ? { ...child, parentId: undefined } : child;\n const d = root.directives;\n const isHead = d?.if !== undefined;\n const isBranch = d?.elseIf !== undefined || d?.else !== undefined;\n const isLoop = d?.for !== undefined;\n\n if (!d || d.slot === undefined || !(isHead || isBranch || isLoop))\n return root;\n\n if (root.nodeId && (isHead || isLoop)) anchorSlots.set(root.nodeId, d.slot);\n const { slot: _slot, ...directives } = d;\n return { ...root, directives };\n });\n\n return { children, anchorSlots };\n}\n\n/**\n * Remove the `switch` field from a ParsedDirectives object.\n * Used to serialize the switch container element without the @switch directive\n * (since the directive is captured in the SwitchDescriptor instead).\n */\nfunction stripSwitchDirective(\n d: NonNullable<PithyNode['directives']>\n): PithyNode['directives'] {\n const { switch: _switch, ...rest } = d;\n return Object.keys(rest).length > 0\n ? (rest as PithyNode['directives'])\n : undefined;\n}\n"]}
1
+ {"version":3,"file":"generateDomFactory.js","sourceRoot":"","sources":["../../src/aotCodegen/generateDomFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,GAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,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CAAC,CAAC,MAAM,GAAG,CAAC;QACjC,CAAC,CAAE,IAAgC;QACnC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.aot.generate-dom-factory\",\n \"title\": \"AOT DOM Factory Generator\",\n \"category\": \"compiler\",\n \"description\": \"Generates a DOM factory function from parsed template nodes, producing static HTML with binding placeholders.\",\n \"since\": \"0.0.1\",\n \"stability\": \"experimental\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"aotCodegen.test.ts\" },\n \"integration\": { \"required\": false, \"covered\": false },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport {\n componentChildDirectiveMessage,\n componentChildDirectives,\n type PithyNode,\n} from '@pithyjs/compiler';\nimport {\n createSerializeContext,\n serializeNode,\n type SerializeContext,\n} from './serializeNode';\nimport {\n generateBindings,\n serializeBindings,\n type BindingDescriptor,\n type IfDescriptor,\n type ForDescriptor,\n type SwitchDescriptor,\n type ProjectionDescriptor,\n} from './generateBindings';\nimport {\n collectIfChain,\n stripStructuralDirective,\n isDefaultCase,\n} from './structuralCodegen';\nimport { escapeJS } from './utils';\n\nexport interface AotCodegenResult {\n /** Complete JS code for the factory function + bindings const (includes sub-factory code) */\n code: string;\n /** The factory function name (e.g. \"__f_a7f3\") */\n factoryName: string;\n /** The bindings variable name (e.g. \"__b_a7f3\") */\n bindingsName: string;\n}\n\nexport interface AotCodegenOptions {\n templateComponents?: ReadonlySet<string>;\n wrappable?: boolean;\n anchorSlots?: ReadonlyMap<string, string>;\n sub?: boolean;\n}\n\n/**\n * Generate AOT code from a PithyNode tree.\n *\n * Produces:\n * 1. Sub-factory code for structural directives (@if branches, @for bodies, @switch cases)\n * 2. A bindings descriptor array (const __b_{hash} = [...])\n * 3. A DOM factory function (function __f_{hash}(__ctx) { ... })\n *\n * The factory creates DOM nodes via createElement/createTextNode,\n * sets static attributes, and calls __applyBindings with the\n * pre-extracted descriptors.\n *\n * Structural directives generate sub-factory functions (via recursive calls)\n * and comment placeholders in the parent factory. Sub-factory code is prepended\n * to the output so function references resolve correctly.\n *\n * **Phase 5 gap:** AOT factories do not set runtime-only DOM properties that\n * `pithyTreeToDom` assigns (`__pithyCtx`, `__pithyNode`, `__nodeId`,\n * `__slotName`, `__fallbackFactory`). Phase 5's `applyBindings()` will need\n * to set these on the factory-created DOM before wiring reactive effects.\n *\n * @param nodes - Parsed PithyNode tree (from parse5ToPithyTree)\n * @param hash - Unique identifier for this template (used in names)\n * @param scopeId - CSS scope ID (e.g. \"pithy-abc123\")\n *\n * @example\n * ```typescript\n * const result = generateDomFactory(pithyNodes, 'a7f3', 'pithy-abc');\n * // result.code contains the full factory + bindings code\n * // result.factoryName is \"__f_a7f3\"\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.aot.generate-dom-factory\",\"name\":\"generateDomFactory\",\"stability\":\"experimental\",\"signature\":\"(nodes: PithyNode[], hash: string, scopeId?: string, options?: AotCodegenOptions) => AotCodegenResult\"} */\nexport function generateDomFactory(\n nodes: PithyNode[],\n hash: string,\n scopeId?: string,\n options: AotCodegenOptions = {}\n): AotCodegenResult {\n // Validate scopeId — it's interpolated into an attribute name (data-scope-{id}),\n // so it must contain only characters valid in HTML attribute names.\n if (scopeId && !/^[a-zA-Z0-9_-]+$/.test(scopeId)) {\n throw new Error(\n `AOT: invalid scopeId \"${scopeId}\" — must contain only alphanumeric, hyphen, or underscore characters.`\n );\n }\n\n // Sanitize hash to ensure valid JS identifiers (replace non-alphanumeric with _)\n const safeHash = hash.replace(/[^a-zA-Z0-9_$]/g, '_');\n const factoryName = `__f_${safeHash}`;\n const bindingsName = `__b_${safeHash}`;\n\n // Accumulate sub-factory code blocks (emitted before this factory)\n const subFactoryCodeBlocks: string[] = [];\n\n // Accumulate structural descriptors (merged with Phase 1 descriptors)\n const structuralDescriptors: BindingDescriptor[] = [];\n\n const childFactories = new Map<string, string>();\n const slotFactories = new Map<string, Record<string, string>>();\n const subOptions: AotCodegenOptions = {\n templateComponents: options.templateComponents,\n anchorSlots: options.anchorSlots,\n };\n\n // Generate DOM factory body\n const ctx = createSerializeContext(scopeId);\n\n // Process all nodes recursively, handling structural directives at every level\n const topLevelVarNames = processNodes(\n nodes,\n ctx,\n safeHash,\n scopeId,\n subFactoryCodeBlocks,\n structuralDescriptors,\n subOptions,\n childFactories,\n slotFactories\n );\n\n // Generate Phase 1 binding descriptors (non-structural)\n const phase1Descriptors = generateBindings(\n nodes,\n childFactories,\n slotFactories\n );\n\n // Merge all descriptors: structural first, then Phase 1\n const allDescriptors = [...structuralDescriptors, ...phase1Descriptors];\n const bindingsCode = serializeBindings(allDescriptors);\n\n // Build factory function body\n const bodyLines: string[] = [];\n bodyLines.push(`const f=document.createDocumentFragment();`);\n\n // Add all serialized node creation code\n bodyLines.push(...ctx.lines);\n\n // Append top-level nodes to fragment\n if (topLevelVarNames.length === 1) {\n bodyLines.push(`f.appendChild(${topLevelVarNames[0]});`);\n } else if (topLevelVarNames.length > 1) {\n bodyLines.push(`f.append(${topLevelVarNames.join(',')});`);\n }\n\n const fragment = options.wrappable ? '(__wrap?__wrap(f):f)' : 'f';\n const bindingsArg = allDescriptors.length > 0 ? bindingsName : '[]';\n const drainArg = options.sub ? ',false' : '';\n bodyLines.push(\n `return __applyBindings(${fragment},${bindingsArg},__ctx${drainArg});`\n );\n\n // Assemble final code: sub-factories first, then this factory\n const codeLines: string[] = [];\n\n // Sub-factory code blocks (from structural directives)\n for (const block of subFactoryCodeBlocks) {\n codeLines.push(block);\n }\n\n // Bindings constant (only if non-empty)\n if (allDescriptors.length > 0) {\n codeLines.push(`const ${bindingsName}=${bindingsCode};`);\n }\n\n // Factory function\n codeLines.push(\n `function ${factoryName}(__ctx${options.wrappable ? ',__wrap' : ''}){`\n );\n codeLines.push(...bodyLines);\n codeLines.push(`}`);\n\n return {\n code: codeLines.join('\\n'),\n factoryName,\n bindingsName,\n };\n}\n\n// ─── Internal: recursive tree processing with structural awareness ───────────\n\n/**\n * Process an array of sibling nodes, handling structural directives at every level.\n * Returns the varNames of the processed top-level nodes (for parent.append()).\n *\n * This function replaces the simple for-of loop over serializeNode calls.\n * It detects structural directives (which span siblings for @if chains)\n * and delegates to sub-factory generation, creating comment placeholders\n * in the current factory for the structural nodes.\n *\n * For non-structural elements, it serializes the element shell (no children)\n * via serializeNode, then recursively processes children here.\n */\nfunction processNodes(\n nodes: PithyNode[],\n ctx: SerializeContext,\n safeHash: string,\n scopeId: string | undefined,\n subFactoryCodeBlocks: string[],\n structuralDescriptors: BindingDescriptor[],\n options: AotCodegenOptions,\n childFactories: Map<string, string>,\n slotFactories: Map<string, Record<string, string>>\n): string[] {\n const varNames: string[] = [];\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n\n // ─── @if/@else-if/@else chain ────────────────────────────────────\n if (node.type === 'element' && node.directives?.if !== undefined) {\n const chain = collectIfChain(nodes, i);\n const pid = node.nodeId ?? `_${i}`;\n i += chain.length - 1; // Skip consumed siblings\n\n // Generate sub-factory for each branch\n const branches: IfDescriptor['branches'] = [];\n for (let b = 0; b < chain.length; b++) {\n const branchNode = chain[b];\n const branchHash = `${safeHash}_if_${pid}_${b}`;\n const stripped = stripStructuralDirective(branchNode);\n if (branchNode.directives?.switch !== undefined)\n stripped.directives = {\n ...stripped.directives,\n switch: branchNode.directives.switch,\n };\n const sub = generateDomFactory([stripped], branchHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const branch: IfDescriptor['branches'][0] = {\n factory: sub.factoryName,\n };\n if (branchNode.directives?.if !== undefined)\n branch.expr = branchNode.directives.if;\n else if (branchNode.directives?.elseIf !== undefined)\n branch.expr = branchNode.directives.elseIf;\n branches.push(branch);\n }\n\n // Emit comment placeholder\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('if:${escapeJS(pid)}');`\n );\n markAnchorSlot(ctx, commentVar, options.anchorSlots?.get(pid));\n varNames.push(commentVar);\n\n structuralDescriptors.push({ t: 'if', pid, branches });\n continue;\n }\n\n // ─── Orphaned @else-if, @else, @case, @default ────────────────────\n if (\n node.type === 'element' &&\n (node.directives?.elseIf !== undefined ||\n node.directives?.else !== undefined ||\n node.directives?.case !== undefined ||\n isDefaultCase(node))\n ) {\n if (\n node.directives?.elseIf !== undefined ||\n node.directives?.else !== undefined\n )\n console.warn(\n `[pithy:aot] ${node.directives.elseIf !== undefined ? '@else-if' : '@else'} has no @if directly before it; <${node.originalTagName ?? node.tagName}> is dropped`\n );\n else\n console.warn(\n `[pithy:aot] ${node.directives?.case !== undefined ? '@case' : '@default'} has no @switch parent, or its @switch is on a @for element (BUG-070); <${node.originalTagName ?? node.tagName}> is dropped`\n );\n continue;\n }\n\n // ─── @for loop ───────────────────────────────────────────────────\n if (node.type === 'element' && node.directives?.for) {\n const pid = node.nodeId ?? `_${i}`;\n const forHash = `${safeHash}_for_${pid}`;\n const stripped = stripStructuralDirective(node);\n const sub = generateDomFactory([stripped], forHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('for:${escapeJS(pid)}');`\n );\n markAnchorSlot(ctx, commentVar, options.anchorSlots?.get(pid));\n varNames.push(commentVar);\n\n const forDir = node.directives.for;\n const desc: ForDescriptor = {\n t: 'for',\n pid,\n item: forDir.itemVar,\n expr: forDir.collectionExpr,\n factory: sub.factoryName,\n };\n if (forDir.indexVar) desc.index = forDir.indexVar;\n if (forDir.trackBy) desc.trackBy = forDir.trackBy;\n structuralDescriptors.push(desc);\n continue;\n }\n\n // ─── @switch block ───────────────────────────────────────────────\n if (node.type === 'element' && node.directives?.switch !== undefined) {\n const pid = node.nodeId ?? `_${i}`;\n // Ensure the original node has nodeId so generateBindings can find it too\n if (!node.nodeId) node.nodeId = pid;\n\n // Serialize the switch container (without children, without @switch directive).\n // nodeId is guaranteed set above, so data-pid is always emitted.\n const switchShell: PithyNode = {\n ...node,\n children: [],\n directives: stripSwitchDirective(node.directives),\n };\n const shellResult = serializeNode(switchShell, ctx);\n if (shellResult) varNames.push(shellResult.varName);\n\n // Generate sub-factory for each @case/@default child\n const cases: SwitchDescriptor['cases'] = [];\n let dropped: string | undefined;\n for (let c = 0; c < (node.children ?? []).length; c++) {\n const caseNode = node.children![c];\n if (\n caseNode.type !== 'element' ||\n (caseNode.directives?.case === undefined && !isDefaultCase(caseNode))\n ) {\n if (caseNode.type === 'element')\n dropped ??= `<${caseNode.originalTagName ?? caseNode.tagName}>`;\n else if (caseNode.type === 'slot') dropped ??= '<slot>';\n else if (caseNode.type === 'text' && caseNode.textContent?.trim())\n dropped ??= JSON.stringify(caseNode.textContent.trim());\n continue;\n }\n\n const caseHash = `${safeHash}_sw_${pid}_${c}`;\n const stripped = stripStructuralDirective(caseNode);\n if (caseNode.directives?.switch !== undefined)\n stripped.directives = {\n ...stripped.directives,\n switch: caseNode.directives.switch,\n };\n const sub = generateDomFactory([stripped], caseHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n\n const caseDesc: SwitchDescriptor['cases'][0] = {\n factory: sub.factoryName,\n };\n if (caseNode.directives?.case !== undefined)\n caseDesc.val = caseNode.directives.case;\n cases.push(caseDesc);\n }\n\n if (dropped)\n console.warn(\n `[pithy:aot] @switch renders only its @case/@default children; ${dropped} is dropped`\n );\n\n structuralDescriptors.push({\n t: 'switch',\n pid,\n expr: node.directives.switch,\n cases,\n });\n continue;\n }\n\n // ─── Text nodes ─────────────────────────────────────────────────\n if (node.type === 'text') {\n const result = serializeNode(node, ctx);\n if (result) varNames.push(result.varName);\n continue;\n }\n\n // ─── Slot nodes (content projection) ─────────────────────────────\n if (node.type === 'slot') {\n const slotName = node.slotName ?? '';\n const pid = node.nodeId ?? `_slot_${ctx.commentCount}`;\n\n // Emit comment anchor for the slot\n const commentVar = `c${ctx.commentCount++}`;\n ctx.lines.push(\n `const ${commentVar}=document.createComment('slot:${escapeJS(slotName)}');`\n );\n varNames.push(commentVar);\n\n // Build projection descriptor\n const projDesc: ProjectionDescriptor = {\n t: 'proj',\n pid,\n name: slotName,\n };\n\n // Generate sub-factory for fallback content if present\n if (node.fallbackChildren && node.fallbackChildren.length > 0) {\n const fbHash = `${safeHash}_slot_${pid}`;\n // Roots of the fallback factory, so bare text binds at its root.\n const roots = node.fallbackChildren.map(child =>\n child.parentId === node.nodeId\n ? { ...child, parentId: undefined }\n : child\n );\n const sub = generateDomFactory(roots, fbHash, scopeId, {\n ...options,\n sub: true,\n });\n subFactoryCodeBlocks.push(sub.code);\n projDesc.fallback = sub.factoryName;\n }\n\n structuralDescriptors.push(projDesc);\n continue;\n }\n\n // ─── Regular element (no structural directive on THIS node) ──────\n // Serialize element shell (without children) via serializeNode,\n // then process children recursively with structural awareness.\n if (node.type === 'element') {\n const shell: PithyNode = { ...node, children: [] };\n const result = serializeNode(shell, ctx);\n if (!result) continue;\n\n const tag = node.originalTagName ?? node.tagName ?? '';\n for (const name of componentChildDirectives(node))\n console.warn(\n `[pithy:aot] ${componentChildDirectiveMessage(tag, name)}`\n );\n if (\n node.isComponent &&\n node.nodeId &&\n node.children?.length &&\n options.templateComponents?.has(tag)\n ) {\n const { children, anchorSlots } = asTemplateRoots(\n node.children,\n node.nodeId,\n tag\n );\n const sub = generateDomFactory(\n children,\n `${safeHash}_tpl_${node.nodeId}`,\n scopeId,\n { ...options, wrappable: true, anchorSlots }\n );\n subFactoryCodeBlocks.push(sub.code);\n childFactories.set(node.nodeId, sub.factoryName);\n varNames.push(result.varName);\n continue;\n }\n\n // Each slot mount renders and binds its content afresh, as dev does.\n if (node.isComponent && node.nodeId && node.children?.length) {\n const slots: Record<string, string> = Object.create(null);\n let n = 0;\n for (const [name, group] of groupSlots(\n node.children,\n node.nodeId,\n tag\n )) {\n const sub = generateDomFactory(\n group,\n `${safeHash}_cs_${node.nodeId}_${n++}`,\n scopeId,\n { ...options, sub: true }\n );\n subFactoryCodeBlocks.push(sub.code);\n slots[name] = sub.factoryName;\n }\n slotFactories.set(node.nodeId, slots);\n varNames.push(result.varName);\n continue;\n }\n\n // Recursively process children (handles nested structural directives)\n const childVarNames = processNodes(\n node.children ?? [],\n ctx,\n safeHash,\n scopeId,\n subFactoryCodeBlocks,\n structuralDescriptors,\n options,\n childFactories,\n slotFactories\n );\n\n // Append children to this element\n if (childVarNames.length === 1) {\n ctx.lines.push(`${result.varName}.appendChild(${childVarNames[0]});`);\n } else if (childVarNames.length > 1) {\n ctx.lines.push(`${result.varName}.append(${childVarNames.join(',')});`);\n }\n\n varNames.push(result.varName);\n continue;\n }\n }\n\n return varNames;\n}\n\nfunction markAnchorSlot(\n ctx: SerializeContext,\n commentVar: string,\n slot: string | undefined\n): void {\n if (slot === undefined) return;\n ctx.lines.push(`${commentVar}.__pithyAnchorSlot='${escapeJS(slot)}';`);\n}\n\nconst BLANK = /^[ \\t\\n\\f\\r]*$/;\n\nfunction warnMixedChainSlots(\n nodes: PithyNode[],\n ownerTag: string,\n outcome: string\n): void {\n let chainSlot: string | undefined;\n let inChain = false;\n let chainWarned = false;\n for (const { directives: d } of nodes) {\n const isBranch = d?.elseIf !== undefined || d?.else !== undefined;\n if (d?.if !== undefined) {\n inChain = true;\n chainSlot = d.slot;\n chainWarned = false;\n } else if (!isBranch) {\n inChain = false;\n }\n if (isBranch && inChain && d.slot !== chainSlot && !chainWarned) {\n chainWarned = true;\n console.warn(\n `[pithy:aot] <${ownerTag}>: the branches of an @if chain carry different slots ` +\n `(${chainSlot ?? 'none'} and ${d.slot ?? 'none'}). ${outcome}`\n );\n }\n if (d?.else !== undefined) inChain = false;\n }\n}\n\n/** Groups a component's children by slot name, as `collectSlotMap` does. */\nfunction groupSlots(\n nodes: PithyNode[],\n ownerId: string,\n ownerTag: string\n): Map<string, PithyNode[]> {\n warnMixedChainSlots(\n nodes,\n ownerTag,\n 'Each slot keeps only the branches that name it; a branch cut off from its @if is dropped.'\n );\n const groups = new Map<string, PithyNode[]>();\n for (const child of nodes) {\n const name = child.directives?.slot || '';\n const root =\n child.parentId === ownerId ? { ...child, parentId: undefined } : child;\n const group = groups.get(name);\n if (group) group.push(root);\n else groups.set(name, [root]);\n }\n const blank = (n: PithyNode) =>\n n.type === 'text' && BLANK.test(n.textContent ?? '');\n const main = groups.get('');\n if (main) {\n let start = 0;\n let end = main.length;\n while (start < end && blank(main[start])) start++;\n while (end > start && blank(main[end - 1])) end--;\n if (start < end) groups.set('', main.slice(start, end));\n else groups.delete('');\n }\n return groups;\n}\n\nfunction asTemplateRoots(\n nodes: PithyNode[],\n ownerId: string,\n ownerTag: string\n): { children: PithyNode[]; anchorSlots: Map<string, string> } {\n const anchorSlots = new Map<string, string>();\n warnMixedChainSlots(\n nodes,\n ownerTag,\n 'The whole chain is placed by its first branch.'\n );\n\n const children = nodes.map(child => {\n const root =\n child.parentId === ownerId ? { ...child, parentId: undefined } : child;\n const d = root.directives;\n const isHead = d?.if !== undefined;\n const isBranch = d?.elseIf !== undefined || d?.else !== undefined;\n const isLoop = d?.for !== undefined;\n\n if (!d || d.slot === undefined || !(isHead || isBranch || isLoop))\n return root;\n\n if (root.nodeId && (isHead || isLoop)) anchorSlots.set(root.nodeId, d.slot);\n const { slot: _slot, ...directives } = d;\n return { ...root, directives };\n });\n\n return { children, anchorSlots };\n}\n\n/**\n * Remove the `switch` field from a ParsedDirectives object.\n * Used to serialize the switch container element without the @switch directive\n * (since the directive is captured in the SwitchDescriptor instead).\n */\nfunction stripSwitchDirective(\n d: NonNullable<PithyNode['directives']>\n): PithyNode['directives'] {\n const { switch: _switch, ...rest } = d;\n return Object.keys(rest).length > 0\n ? (rest as PithyNode['directives'])\n : undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"extractUsedIdentifiers.d.ts","sourceRoot":"","sources":["../../src/babelPlugin/extractUsedIdentifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAG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MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,iQAAiQ;AACjQ,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,SAAS,EACf,eAAe,CAAC,EAAE,kBAAkB,EACpC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GACtD,GAAG,CAAC,MAAM,CAAC,CAkTb"}
@@ -276,6 +276,8 @@ export function extractUsedIdentifiers(root, componentScopes, onComponentAttr) {
276
276
  const added = pushScoped(childScopeNames);
277
277
  if (node.children)
278
278
  node.children.forEach(walk);
279
+ if (node.fallbackChildren)
280
+ node.fallbackChildren.forEach(walk);
279
281
  popScoped(added);
280
282
  popScoped(addedLoop);
281
283
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extractUsedIdentifiers.js","sourceRoot":"","sources":["../../src/babelPlugin/extractUsedIdentifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAqBtD,iQAAiQ;AACjQ,MAAM,UAAU,sBAAsB,CACpC,IAAe,EACf,eAAoC,EACpC,eAAuD;IAEvD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/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AO,SAAS,CAAC;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3C,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.babel.identifier-extractor\",\n \"title\": \"Babel Identifier Extractor\",\n \"category\": \"plugin\",\n \"description\": \"Extracts used identifiers from parsed template ASTs for tree-shaking and scope analysis.\",\n \"since\": \"0.0.1\",\n \"stability\": \"stable\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"extractUsedIdentifiers.test.ts\" },\n \"integration\": { \"required\": false, \"covered\": false },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport * as traverse from '@babel/traverse';\nimport { PithyNode } from '@pithyjs/compiler';\nimport { NodePath } from '@babel/traverse';\nimport { isValidJsIdentifier } from '@pithyjs/shared';\n\n/** Richer config: default scope vars + optional attribute-based aliases */\nexport type ComponentScopeConfig = {\n vars: string[];\n aliases?: Record<string, string>; // attribute name → default var name it replaces\n};\n\n/** Map of component names to the variables they inject into children's scope */\nexport type ComponentScopesMap = Record<string, ComponentScopeConfig>;\n\nexport type ComponentAttrReport = {\n tag: string;\n attr: string;\n value: string;\n names: string[];\n parsed: boolean;\n expression: t.Expression | null;\n error?: string;\n};\n\n/** @codexApi {\"parent\":\"pithy.babel.identifier-extractor\",\"name\":\"extractUsedIdentifiers\",\"stability\":\"stable\",\"signature\":\"(root: PithyNode, componentScopes?: ComponentScopesMap, onComponentAttr?: (report: ComponentAttrReport) => void) => Set<string>\"} */\nexport function extractUsedIdentifiers(\n root: PithyNode,\n componentScopes?: ComponentScopesMap,\n onComponentAttr?: (report: ComponentAttrReport) => void\n): Set<string> {\n const vars = new Set<string>();\n\n // Track loop-local variables so we can exclude them\n const scopedLoopVars = new Set<string>();\n\n const extractFromExpr = (\n expr: string,\n quiet = false\n ): {\n names: string[];\n parsed: boolean;\n expression: t.Expression | null;\n error?: string;\n } => {\n const names: string[] = [];\n if (!expr || expr.trim() === '')\n return { names, parsed: true, expression: null };\n let expression: t.Expression | null = null;\n let jsError: unknown;\n const parseError = (err: unknown) =>\n (err instanceof Error ? err.message : String(err)).replace(\n / \\(\\d+:\\d+\\)$/,\n ''\n );\n\n try {\n // Parse with the grammar that will actually RUN this string.\n // `compileExpression()` hands the expression to `new Function`, which uses\n // plain JavaScript — and the two grammars disagree about real code:\n // `foo<Bar>(x)` is a call with type arguments to TypeScript, but to\n // JavaScript it is `foo < Bar > (x)`, three comparisons in which `Bar` is\n // a genuine value dependency. Parsing TS-first classified `Bar` as a type\n // and dropped it from the context, so a valid template resolved an\n // unrelated global or threw.\n //\n // TypeScript is the fallback, not the default. It is only reached for\n // expressions JavaScript cannot parse at all — `x as Foo`,\n // `a satisfies Baz` — which therefore can never execute either, so the\n // type-position guard below only ever fires on syntax that was already\n // doomed. There it still matters: see the guard's own comment.\n let ast;\n try {\n ast = parse(`(${expr})`, { sourceType: 'module' });\n } catch (err) {\n jsError = err;\n ast = parse(`(${expr})`, {\n sourceType: 'module',\n plugins: ['typescript'],\n });\n }\n\n type TraverseFn = typeof traverse.default;\n const interop = (traverse as { default: unknown }).default as\n | TraverseFn\n | { default: TraverseFn };\n const realTraverse =\n typeof interop === 'function' ? interop : interop.default;\n\n const [statement] = ast.program.body;\n if (t.isExpressionStatement(statement)) expression = statement.expression;\n\n realTraverse(ast, {\n Identifier(path: NodePath<t.Identifier>) {\n // Cast to t.Node to avoid version mismatch between @babel/types\n // and @types/babel__traverse bundled type copies.\n const parent = path.parent as t.Node;\n\n // `a?.b` parses as an OptionalMemberExpression, a distinct node type\n // from MemberExpression. Checking only the latter let every optional\n // access leak its property name as a free identifier: `a?.b?.c`\n // collected `a`, `b` and `c`. The generated scope then referenced a\n // bare `b`, which a browser silently resolves against `window` — so\n // `actions?.length` read `window.length`, i.e. 0 — while a server DOM\n // throws `ReferenceError` and the component's subtree is dropped.\n const isProp =\n (t.isMemberExpression(parent) ||\n t.isOptionalMemberExpression(parent)) &&\n parent.property === path.node &&\n !parent.computed;\n\n const isObjectKey =\n (t.isObjectProperty(parent) || t.isObjectMethod(parent)) &&\n parent.key === path.node &&\n !parent.computed;\n\n // TypeScript syntax in a template expression is NOT supported — the\n // expression string is handed to `new Function` verbatim, so\n // `(value as Item).done` is a SyntaxError there and falls back\n // whatever this does. The guard is about the blast radius, not about\n // making it work.\n //\n // A collected name becomes a shorthand property in the emitted\n // context object (`babelPlugin.ts`, `{ Item }`). A type is erased at\n // emit, so that reference has no binding and the **whole module**\n // fails to load with `ReferenceError: Item is not defined` — every\n // component in it gone, not just the one bad expression. Worse when\n // the name collides with a global: `{ Event }` loads silently and\n // binds the DOM constructor.\n //\n // So this downgrades \"module dies\" to \"one expression falls back\".\n //\n // Only reachable through the TypeScript fallback above, which is why\n // `foo<Bar>(x)` is NOT affected: JavaScript parses it, so it never\n // reaches that fallback and `Bar` is collected as the value it is.\n //\n // Supporting TS in templates would mean transpiling before emitting\n // descriptors. That is a feature, and deliberately not attempted here.\n const isTypePosition =\n path.findParent(\n (p: NodePath) =>\n t.isTSType(p.node) ||\n t.isTSTypeAnnotation(p.node) ||\n t.isTSTypeParameterInstantiation(p.node)\n ) !== null;\n\n const name = path.node.name;\n\n // Exclude loop-scoped vars\n if (\n !isProp &&\n !isObjectKey &&\n !isTypePosition &&\n !scopedLoopVars.has(name)\n ) {\n vars.add(name);\n names.push(name);\n }\n },\n });\n } catch (err) {\n if (!quiet) {\n console.warn('[pithy] Failed to parse expression:', expr, err);\n }\n return { names, parsed: false, expression: null, error: parseError(err) };\n }\n if (jsError !== undefined)\n return {\n names,\n parsed: false,\n expression: null,\n error: parseError(jsError),\n };\n return { names, parsed: true, expression };\n };\n\n /**\n * Push names into scopedLoopVars, returning only the ones that were\n * genuinely new (so the caller can pop exactly those later).\n */\n const pushScoped = (names: string[]): string[] => {\n const added: string[] = [];\n for (const name of names) {\n if (!scopedLoopVars.has(name)) {\n added.push(name);\n }\n scopedLoopVars.add(name);\n }\n return added;\n };\n\n const popScoped = (added: string[]) => {\n for (const name of added) {\n scopedLoopVars.delete(name);\n }\n };\n\n const walk = (node: PithyNode) => {\n // ── 1. Extract the expressions that run in the *parent's* scope ──\n\n if (node.type === 'text') {\n for (const i of node.interpolations ?? []) {\n extractFromExpr(i.expression);\n }\n }\n\n const d = node.directives;\n\n if (d) {\n if (d.if) extractFromExpr(d.if);\n if (d.elseIf) extractFromExpr(d.elseIf);\n if (d.switch) extractFromExpr(d.switch);\n if (d.case) extractFromExpr(d.case);\n if (d.for) extractFromExpr(d.for.collectionExpr);\n }\n\n const loopNames: string[] = [];\n if (d?.for) {\n const { itemVar, indexVar } = d.for;\n if (itemVar) loopNames.push(itemVar);\n if (indexVar) loopNames.push(indexVar);\n loopNames.push('count', 'first', 'last', 'even', 'odd');\n }\n const addedLoop = pushScoped(loopNames);\n\n if (node.type === 'element' && node.isComponent && node.attrs) {\n for (const [attrName, attrValue] of Object.entries(node.attrs)) {\n if (\n attrName.startsWith('data-') ||\n attrName.startsWith('class') ||\n attrName.startsWith('@') ||\n attrName.startsWith('[')\n )\n continue;\n const { names, parsed, expression, error } = extractFromExpr(\n attrValue,\n onComponentAttr !== undefined\n );\n if (attrName === 'style' || attrName === 'slot') continue;\n onComponentAttr?.({\n tag: node.originalTagName ?? node.tagName ?? '',\n attr: node.originalAttrs?.[attrName] ?? attrName,\n value: attrValue,\n names,\n parsed,\n expression,\n error,\n });\n }\n }\n\n if (d) {\n if (d.bound) Object.values(d.bound).forEach(v => extractFromExpr(v));\n if (d.classMap)\n Object.values(d.classMap).forEach(v => extractFromExpr(v));\n if (d.styleMap)\n Object.values(d.styleMap).forEach(v => extractFromExpr(v));\n if (d.classes) extractFromExpr(d.classes);\n if (d.ref) extractFromExpr(d.ref);\n if (d.bind) extractFromExpr(d.bind);\n if (d.error) extractFromExpr(d.error);\n if (d.events) Object.values(d.events).forEach(v => extractFromExpr(v));\n\n // @defer directive related expressions\n if (d.load) extractFromExpr(d.load);\n if (d.when) extractFromExpr(d.when);\n if (d.placeholder) extractFromExpr(d.placeholder);\n\n // trackBy uses the loop variable (e.g. item.id) so it runs in child scope\n if (d.for?.trackBy) extractFromExpr(d.for.trackBy);\n }\n\n // ── 2. Collect child-scope variables ──\n // These are injected *into children* by this node. They must not\n // affect the node's own expressions (handled above) and must be\n // popped when leaving the subtree.\n\n const childScopeNames: string[] = [];\n\n // componentScopes config (e.g. ui-kit <For>, <Show>, etc.)\n if (\n componentScopes &&\n node.type === 'element' &&\n node.isComponent &&\n node.originalTagName\n ) {\n const config = componentScopes[node.originalTagName];\n if (config) {\n const resolved = [...config.vars];\n\n if (config.aliases && node.attrs) {\n // Build a reverse map: originalName → lowercaseName\n // node.attrs keys are lowercased by parse5; originalAttrs maps low → original\n const originalToLower = new Map<string, string>();\n if (node.originalAttrs) {\n for (const [lower, original] of Object.entries(\n node.originalAttrs\n )) {\n originalToLower.set(original, lower);\n }\n }\n // Also map identity for already-lowercase alias names\n for (const key of Object.keys(node.attrs)) {\n if (!originalToLower.has(key)) originalToLower.set(key, key);\n }\n\n for (const [attr, defaultVar] of Object.entries(config.aliases)) {\n const lowerKey = originalToLower.get(attr) ?? attr.toLowerCase();\n const attrVal = node.attrs[lowerKey];\n const aliasName = extractIdentifierLiteral(attrVal);\n if (aliasName) {\n const idx = resolved.indexOf(defaultVar);\n if (idx !== -1) resolved[idx] = aliasName;\n }\n }\n }\n\n for (const v of resolved) {\n childScopeNames.push(v);\n }\n }\n }\n\n // ── 3. Push child scope, walk children, pop ──\n\n const added = pushScoped(childScopeNames);\n\n if (node.children) node.children.forEach(walk);\n\n popScoped(added);\n popScoped(addedLoop);\n };\n\n walk(root);\n return vars;\n}\n\n/** Extract a valid JS identifier from a quoted string literal (e.g. `'fruit'` → `fruit`).\n * Returns undefined for empty strings, non-identifiers (e.g. `'123'`), reserved words,\n * or non-literal expressions. */\nfunction extractIdentifierLiteral(\n expr: string | undefined\n): string | undefined {\n if (!expr) return undefined;\n const trimmed = expr.trim();\n const m = trimmed.match(/^(['\"])(.*?)\\1$/);\n if (!m) return undefined;\n return isValidJsIdentifier(m[2]) ? m[2] : undefined;\n}\n"]}
1
+ {"version":3,"file":"extractUsedIdentifiers.js","sourceRoot":"","sources":["../../src/babelPlugin/extractUsedIdentifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAqBtD,iQAAiQ;AACjQ,MAAM,UAAU,sBAAsB,CACpC,IAAe,EACf,eAAoC,EACpC,eAAuD;IAEvD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,oDAAoD;IACpD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC,MAAM,eAAe,GAAG,CACtB,IAAY,EACZ,KAAK,GAAG,KAAK,EAMb,EAAE;QACF,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACnD,IAAI,UAAU,GAAwB,IAAI,CAAC;QAC3C,IAAI,OAAgB,CAAC;QACrB,MAAM,UAAU,GAAG,CAAC,GAAY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D,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.babel.identifier-extractor\",\n \"title\": \"Babel Identifier Extractor\",\n \"category\": \"plugin\",\n \"description\": \"Extracts used identifiers from parsed template ASTs for tree-shaking and scope analysis.\",\n \"since\": \"0.0.1\",\n \"stability\": \"stable\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"extractUsedIdentifiers.test.ts\" },\n \"integration\": { \"required\": false, \"covered\": false },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport * as traverse from '@babel/traverse';\nimport { PithyNode } from '@pithyjs/compiler';\nimport { NodePath } from '@babel/traverse';\nimport { isValidJsIdentifier } from '@pithyjs/shared';\n\n/** Richer config: default scope vars + optional attribute-based aliases */\nexport type ComponentScopeConfig = {\n vars: string[];\n aliases?: Record<string, string>; // attribute name → default var name it replaces\n};\n\n/** Map of component names to the variables they inject into children's scope */\nexport type ComponentScopesMap = Record<string, ComponentScopeConfig>;\n\nexport type ComponentAttrReport = {\n tag: string;\n attr: string;\n value: string;\n names: string[];\n parsed: boolean;\n expression: t.Expression | null;\n error?: string;\n};\n\n/** @codexApi {\"parent\":\"pithy.babel.identifier-extractor\",\"name\":\"extractUsedIdentifiers\",\"stability\":\"stable\",\"signature\":\"(root: PithyNode, componentScopes?: ComponentScopesMap, onComponentAttr?: (report: ComponentAttrReport) => void) => Set<string>\"} */\nexport function extractUsedIdentifiers(\n root: PithyNode,\n componentScopes?: ComponentScopesMap,\n onComponentAttr?: (report: ComponentAttrReport) => void\n): Set<string> {\n const vars = new Set<string>();\n\n // Track loop-local variables so we can exclude them\n const scopedLoopVars = new Set<string>();\n\n const extractFromExpr = (\n expr: string,\n quiet = false\n ): {\n names: string[];\n parsed: boolean;\n expression: t.Expression | null;\n error?: string;\n } => {\n const names: string[] = [];\n if (!expr || expr.trim() === '')\n return { names, parsed: true, expression: null };\n let expression: t.Expression | null = null;\n let jsError: unknown;\n const parseError = (err: unknown) =>\n (err instanceof Error ? err.message : String(err)).replace(\n / \\(\\d+:\\d+\\)$/,\n ''\n );\n\n try {\n // Parse with the grammar that will actually RUN this string.\n // `compileExpression()` hands the expression to `new Function`, which uses\n // plain JavaScript — and the two grammars disagree about real code:\n // `foo<Bar>(x)` is a call with type arguments to TypeScript, but to\n // JavaScript it is `foo < Bar > (x)`, three comparisons in which `Bar` is\n // a genuine value dependency. Parsing TS-first classified `Bar` as a type\n // and dropped it from the context, so a valid template resolved an\n // unrelated global or threw.\n //\n // TypeScript is the fallback, not the default. It is only reached for\n // expressions JavaScript cannot parse at all — `x as Foo`,\n // `a satisfies Baz` — which therefore can never execute either, so the\n // type-position guard below only ever fires on syntax that was already\n // doomed. There it still matters: see the guard's own comment.\n let ast;\n try {\n ast = parse(`(${expr})`, { sourceType: 'module' });\n } catch (err) {\n jsError = err;\n ast = parse(`(${expr})`, {\n sourceType: 'module',\n plugins: ['typescript'],\n });\n }\n\n type TraverseFn = typeof traverse.default;\n const interop = (traverse as { default: unknown }).default as\n | TraverseFn\n | { default: TraverseFn };\n const realTraverse =\n typeof interop === 'function' ? interop : interop.default;\n\n const [statement] = ast.program.body;\n if (t.isExpressionStatement(statement)) expression = statement.expression;\n\n realTraverse(ast, {\n Identifier(path: NodePath<t.Identifier>) {\n // Cast to t.Node to avoid version mismatch between @babel/types\n // and @types/babel__traverse bundled type copies.\n const parent = path.parent as t.Node;\n\n // `a?.b` parses as an OptionalMemberExpression, a distinct node type\n // from MemberExpression. Checking only the latter let every optional\n // access leak its property name as a free identifier: `a?.b?.c`\n // collected `a`, `b` and `c`. The generated scope then referenced a\n // bare `b`, which a browser silently resolves against `window` — so\n // `actions?.length` read `window.length`, i.e. 0 — while a server DOM\n // throws `ReferenceError` and the component's subtree is dropped.\n const isProp =\n (t.isMemberExpression(parent) ||\n t.isOptionalMemberExpression(parent)) &&\n parent.property === path.node &&\n !parent.computed;\n\n const isObjectKey =\n (t.isObjectProperty(parent) || t.isObjectMethod(parent)) &&\n parent.key === path.node &&\n !parent.computed;\n\n // TypeScript syntax in a template expression is NOT supported — the\n // expression string is handed to `new Function` verbatim, so\n // `(value as Item).done` is a SyntaxError there and falls back\n // whatever this does. The guard is about the blast radius, not about\n // making it work.\n //\n // A collected name becomes a shorthand property in the emitted\n // context object (`babelPlugin.ts`, `{ Item }`). A type is erased at\n // emit, so that reference has no binding and the **whole module**\n // fails to load with `ReferenceError: Item is not defined` — every\n // component in it gone, not just the one bad expression. Worse when\n // the name collides with a global: `{ Event }` loads silently and\n // binds the DOM constructor.\n //\n // So this downgrades \"module dies\" to \"one expression falls back\".\n //\n // Only reachable through the TypeScript fallback above, which is why\n // `foo<Bar>(x)` is NOT affected: JavaScript parses it, so it never\n // reaches that fallback and `Bar` is collected as the value it is.\n //\n // Supporting TS in templates would mean transpiling before emitting\n // descriptors. That is a feature, and deliberately not attempted here.\n const isTypePosition =\n path.findParent(\n (p: NodePath) =>\n t.isTSType(p.node) ||\n t.isTSTypeAnnotation(p.node) ||\n t.isTSTypeParameterInstantiation(p.node)\n ) !== null;\n\n const name = path.node.name;\n\n // Exclude loop-scoped vars\n if (\n !isProp &&\n !isObjectKey &&\n !isTypePosition &&\n !scopedLoopVars.has(name)\n ) {\n vars.add(name);\n names.push(name);\n }\n },\n });\n } catch (err) {\n if (!quiet) {\n console.warn('[pithy] Failed to parse expression:', expr, err);\n }\n return { names, parsed: false, expression: null, error: parseError(err) };\n }\n if (jsError !== undefined)\n return {\n names,\n parsed: false,\n expression: null,\n error: parseError(jsError),\n };\n return { names, parsed: true, expression };\n };\n\n /**\n * Push names into scopedLoopVars, returning only the ones that were\n * genuinely new (so the caller can pop exactly those later).\n */\n const pushScoped = (names: string[]): string[] => {\n const added: string[] = [];\n for (const name of names) {\n if (!scopedLoopVars.has(name)) {\n added.push(name);\n }\n scopedLoopVars.add(name);\n }\n return added;\n };\n\n const popScoped = (added: string[]) => {\n for (const name of added) {\n scopedLoopVars.delete(name);\n }\n };\n\n const walk = (node: PithyNode) => {\n // ── 1. Extract the expressions that run in the *parent's* scope ──\n\n if (node.type === 'text') {\n for (const i of node.interpolations ?? []) {\n extractFromExpr(i.expression);\n }\n }\n\n const d = node.directives;\n\n if (d) {\n if (d.if) extractFromExpr(d.if);\n if (d.elseIf) extractFromExpr(d.elseIf);\n if (d.switch) extractFromExpr(d.switch);\n if (d.case) extractFromExpr(d.case);\n if (d.for) extractFromExpr(d.for.collectionExpr);\n }\n\n const loopNames: string[] = [];\n if (d?.for) {\n const { itemVar, indexVar } = d.for;\n if (itemVar) loopNames.push(itemVar);\n if (indexVar) loopNames.push(indexVar);\n loopNames.push('count', 'first', 'last', 'even', 'odd');\n }\n const addedLoop = pushScoped(loopNames);\n\n if (node.type === 'element' && node.isComponent && node.attrs) {\n for (const [attrName, attrValue] of Object.entries(node.attrs)) {\n if (\n attrName.startsWith('data-') ||\n attrName.startsWith('class') ||\n attrName.startsWith('@') ||\n attrName.startsWith('[')\n )\n continue;\n const { names, parsed, expression, error } = extractFromExpr(\n attrValue,\n onComponentAttr !== undefined\n );\n if (attrName === 'style' || attrName === 'slot') continue;\n onComponentAttr?.({\n tag: node.originalTagName ?? node.tagName ?? '',\n attr: node.originalAttrs?.[attrName] ?? attrName,\n value: attrValue,\n names,\n parsed,\n expression,\n error,\n });\n }\n }\n\n if (d) {\n if (d.bound) Object.values(d.bound).forEach(v => extractFromExpr(v));\n if (d.classMap)\n Object.values(d.classMap).forEach(v => extractFromExpr(v));\n if (d.styleMap)\n Object.values(d.styleMap).forEach(v => extractFromExpr(v));\n if (d.classes) extractFromExpr(d.classes);\n if (d.ref) extractFromExpr(d.ref);\n if (d.bind) extractFromExpr(d.bind);\n if (d.error) extractFromExpr(d.error);\n if (d.events) Object.values(d.events).forEach(v => extractFromExpr(v));\n\n // @defer directive related expressions\n if (d.load) extractFromExpr(d.load);\n if (d.when) extractFromExpr(d.when);\n if (d.placeholder) extractFromExpr(d.placeholder);\n\n // trackBy uses the loop variable (e.g. item.id) so it runs in child scope\n if (d.for?.trackBy) extractFromExpr(d.for.trackBy);\n }\n\n // ── 2. Collect child-scope variables ──\n // These are injected *into children* by this node. They must not\n // affect the node's own expressions (handled above) and must be\n // popped when leaving the subtree.\n\n const childScopeNames: string[] = [];\n\n // componentScopes config (e.g. ui-kit <For>, <Show>, etc.)\n if (\n componentScopes &&\n node.type === 'element' &&\n node.isComponent &&\n node.originalTagName\n ) {\n const config = componentScopes[node.originalTagName];\n if (config) {\n const resolved = [...config.vars];\n\n if (config.aliases && node.attrs) {\n // Build a reverse map: originalName → lowercaseName\n // node.attrs keys are lowercased by parse5; originalAttrs maps low → original\n const originalToLower = new Map<string, string>();\n if (node.originalAttrs) {\n for (const [lower, original] of Object.entries(\n node.originalAttrs\n )) {\n originalToLower.set(original, lower);\n }\n }\n // Also map identity for already-lowercase alias names\n for (const key of Object.keys(node.attrs)) {\n if (!originalToLower.has(key)) originalToLower.set(key, key);\n }\n\n for (const [attr, defaultVar] of Object.entries(config.aliases)) {\n const lowerKey = originalToLower.get(attr) ?? attr.toLowerCase();\n const attrVal = node.attrs[lowerKey];\n const aliasName = extractIdentifierLiteral(attrVal);\n if (aliasName) {\n const idx = resolved.indexOf(defaultVar);\n if (idx !== -1) resolved[idx] = aliasName;\n }\n }\n }\n\n for (const v of resolved) {\n childScopeNames.push(v);\n }\n }\n }\n\n // ── 3. Push child scope, walk children, pop ──\n\n const added = pushScoped(childScopeNames);\n\n if (node.children) node.children.forEach(walk);\n if (node.fallbackChildren) node.fallbackChildren.forEach(walk);\n\n popScoped(added);\n popScoped(addedLoop);\n };\n\n walk(root);\n return vars;\n}\n\n/** Extract a valid JS identifier from a quoted string literal (e.g. `'fruit'` → `fruit`).\n * Returns undefined for empty strings, non-identifiers (e.g. `'123'`), reserved words,\n * or non-literal expressions. */\nfunction extractIdentifierLiteral(\n expr: string | undefined\n): string | undefined {\n if (!expr) return undefined;\n const trimmed = expr.trim();\n const m = trimmed.match(/^(['\"])(.*?)\\1$/);\n if (!m) return undefined;\n return isValidJsIdentifier(m[2]) ? m[2] : undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"channelVars.d.ts","sourceRoot":"","sources":["../../src/designSystemPlugin/channelVars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAKF,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AA6KxC;;;;;;GAMG;AACH,2KAA2K;AAC3K,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAIzD,CAAC;AA2QF;;;;;;;;;;;GAWG;AACH,gLAAgL;AAChL,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAMzE;AAED;;;;;;;;;;;;GAYG;AACH,+LAA+L;AAC/L,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,GAAG,SAAK,GACP,GAAG,CAAC,aAAa,CAAC,CAapB;AAED,8EAA8E;AAC9E,iLAAiL;AACjL,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAoBhE;AAED,mFAAmF;AACnF,oKAAoK;AACpK,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,4EAA4E;IAC5E,gBAAgB,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AA+SD,oEAAoE;AACpE,sKAAsK;AACtK,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,+EAA+E;AAC/E,sKAAsK;AACtK,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,uEAAu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EAAE,eAAe,GAAG,cAAc,CA+FxE;AAED,8CAA8C;AAC9C,8KAA8K;AAC9K,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACnC;AAED,6EAA6E;AAC7E,oKAAoK;AACpK,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;IAC1D,4EAA4E;IAC5E,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnB;AAsBD,gMAAgM;AAChM,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,mBAAmB,GACzB,cAAc,CAiFhB"}
@@ -75,8 +75,7 @@ const CHANNEL_REF_RE = new RegExp(String.raw `[Vv][Aa][Rr]\(\s*(--[A-Za-z0-9_-]*
75
75
  // The TRAILING fragment needed the same treatment and did not get it: it
76
76
  // excluded whitespace, so a second interpolation containing a space — a SCSS
77
77
  // map lookup, a ternary, anything Prettier wrapped — matched nothing. This is
78
- // load-bearing: all 142 surviving channel declarations rest on this regex
79
- // matching `_color-utilities.scss`.
78
+ // load-bearing: a built name it misses has its whole family dropped.
80
79
  const DYNAMIC_CHANNEL_REF_RE = new RegExp(String.raw `[Vv][Aa][Rr]\(\s*(?:--)?[A-Za-z0-9_-]*(?:#\{[^}]{0,500}\}|\$\{[^}]{0,500}\})[^;]{0,200}?-(${SUFFIX_ALT})\b`, 'g');
81
80
  /**
82
81
  * A channel name assembled by string concatenation rather than interpolation