@pyreon/compiler 0.12.7 → 0.12.9

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.
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
5386
5386
  </script>
5387
5387
  <script>
5388
5388
  /*<!--*/
5389
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"5e8656db-1","name":"jsx.ts"},{"uid":"5e8656db-3","name":"project-scanner.ts"},{"uid":"5e8656db-5","name":"react-intercept.ts"},{"uid":"5e8656db-7","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"5e8656db-1":{"renderedLength":34317,"gzipLength":9205,"brotliLength":0,"metaUid":"5e8656db-0"},"5e8656db-3":{"renderedLength":4762,"gzipLength":1730,"brotliLength":0,"metaUid":"5e8656db-2"},"5e8656db-5":{"renderedLength":27692,"gzipLength":6920,"brotliLength":0,"metaUid":"5e8656db-4"},"5e8656db-7":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"5e8656db-6"}},"nodeMetas":{"5e8656db-0":{"id":"/src/jsx.ts","moduleParts":{"index.js":"5e8656db-1"},"imported":[{"uid":"5e8656db-8"}],"importedBy":[{"uid":"5e8656db-6"}]},"5e8656db-2":{"id":"/src/project-scanner.ts","moduleParts":{"index.js":"5e8656db-3"},"imported":[{"uid":"5e8656db-9"},{"uid":"5e8656db-10"}],"importedBy":[{"uid":"5e8656db-6"}]},"5e8656db-4":{"id":"/src/react-intercept.ts","moduleParts":{"index.js":"5e8656db-5"},"imported":[{"uid":"5e8656db-8"}],"importedBy":[{"uid":"5e8656db-6"}]},"5e8656db-6":{"id":"/src/index.ts","moduleParts":{"index.js":"5e8656db-7"},"imported":[{"uid":"5e8656db-0"},{"uid":"5e8656db-2"},{"uid":"5e8656db-4"}],"importedBy":[],"isEntry":true},"5e8656db-8":{"id":"typescript","moduleParts":{},"imported":[],"importedBy":[{"uid":"5e8656db-0"},{"uid":"5e8656db-4"}]},"5e8656db-9":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"5e8656db-2"}]},"5e8656db-10":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"5e8656db-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"1afeff4f-1","name":"jsx.ts"},{"uid":"1afeff4f-3","name":"project-scanner.ts"},{"uid":"1afeff4f-5","name":"react-intercept.ts"},{"uid":"1afeff4f-7","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"1afeff4f-1":{"renderedLength":34308,"gzipLength":9245,"brotliLength":0,"metaUid":"1afeff4f-0"},"1afeff4f-3":{"renderedLength":4762,"gzipLength":1730,"brotliLength":0,"metaUid":"1afeff4f-2"},"1afeff4f-5":{"renderedLength":27692,"gzipLength":6920,"brotliLength":0,"metaUid":"1afeff4f-4"},"1afeff4f-7":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"1afeff4f-6"}},"nodeMetas":{"1afeff4f-0":{"id":"/src/jsx.ts","moduleParts":{"index.js":"1afeff4f-1"},"imported":[{"uid":"1afeff4f-8"}],"importedBy":[{"uid":"1afeff4f-6"}]},"1afeff4f-2":{"id":"/src/project-scanner.ts","moduleParts":{"index.js":"1afeff4f-3"},"imported":[{"uid":"1afeff4f-9"},{"uid":"1afeff4f-10"}],"importedBy":[{"uid":"1afeff4f-6"}]},"1afeff4f-4":{"id":"/src/react-intercept.ts","moduleParts":{"index.js":"1afeff4f-5"},"imported":[{"uid":"1afeff4f-8"}],"importedBy":[{"uid":"1afeff4f-6"}]},"1afeff4f-6":{"id":"/src/index.ts","moduleParts":{"index.js":"1afeff4f-7"},"imported":[{"uid":"1afeff4f-0"},{"uid":"1afeff4f-2"},{"uid":"1afeff4f-4"}],"importedBy":[],"isEntry":true},"1afeff4f-8":{"id":"typescript","moduleParts":{},"imported":[],"importedBy":[{"uid":"1afeff4f-0"},{"uid":"1afeff4f-4"}]},"1afeff4f-9":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"1afeff4f-2"}]},"1afeff4f-10":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"1afeff4f-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;
package/lib/index.js CHANGED
@@ -105,11 +105,10 @@ function transformJSX(code, filename = "input.tsx") {
105
105
  function wrap(expr) {
106
106
  const start = expr.getStart(sf);
107
107
  const end = expr.getEnd();
108
- const exprText = inlineVarsInText(code.slice(start, end));
109
108
  replacements.push({
110
109
  start,
111
110
  end,
112
- text: `() => ${exprText}`
111
+ text: `() => ${sliceExpr(expr)}`
113
112
  });
114
113
  }
115
114
  /** Try to hoist or wrap an expression, pushing a replacement if needed. */
@@ -180,7 +179,7 @@ function transformJSX(code, filename = "input.tsx") {
180
179
  replacements.push({
181
180
  start,
182
181
  end,
183
- text: `_rp(() => ${inlineVarsInText(code.slice(start, end))})`
182
+ text: `_rp(() => ${sliceExpr(expr)})`
184
183
  });
185
184
  needsRpImport = true;
186
185
  }
@@ -207,7 +206,8 @@ function transformJSX(code, filename = "input.tsx") {
207
206
  }
208
207
  /** Names that refer to the props object or splitProps results. */
209
208
  const propsNames = /* @__PURE__ */ new Set();
210
- /** Map of variable name → source text of the original expression. */
209
+ /** Map of variable name → AST node of the original expression.
210
+ * Using AST nodes instead of text avoids all string manipulation edge cases. */
211
211
  const propDerivedVars = /* @__PURE__ */ new Map();
212
212
  /** Check if an expression reads from a tracked props-like object. */
213
213
  function readsFromProps(node) {
@@ -264,11 +264,7 @@ function transformJSX(code, filename = "input.tsx") {
264
264
  if (!(node.declarationList.flags & ts.NodeFlags.Const)) continue;
265
265
  if (_callbackDepth > 0) continue;
266
266
  if (ts.isIdentifier(decl.name) && decl.initializer) {
267
- if (readsFromProps(decl.initializer)) {
268
- const varName = decl.name.text;
269
- const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd());
270
- propDerivedVars.set(varName, exprText);
271
- }
267
+ if (readsFromProps(decl.initializer)) propDerivedVars.set(decl.name.text, decl.initializer);
272
268
  }
273
269
  }
274
270
  ts.forEachChild(node, scanForPropDerivedVars);
@@ -298,40 +294,32 @@ function transformJSX(code, filename = "input.tsx") {
298
294
  ts.forEachChild(n, check);
299
295
  });
300
296
  if (usesPropVar) {
301
- const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd());
302
- propDerivedVars.set(varName, exprText);
297
+ propDerivedVars.set(varName, decl.initializer);
303
298
  changed = true;
304
299
  }
305
300
  }
306
301
  });
307
302
  }
308
- for (const [varName, expr] of propDerivedVars) {
309
- let resolved = expr;
310
- for (const [depName, depExpr] of propDerivedVars) {
311
- if (depName === varName) continue;
312
- const re = new RegExp(`(?<![.\\w])${depName}(?![\\w:=])`, "g");
313
- if (re.test(resolved)) resolved = resolved.replace(re, `(${depExpr})`);
314
- }
315
- if (resolved !== expr) propDerivedVars.set(varName, resolved);
303
+ function resolveExprTransitive(node, excludeVar) {
304
+ return ts.visitNode(node, function visit(n) {
305
+ if (ts.isIdentifier(n) && propDerivedVars.has(n.text) && n.text !== excludeVar) {
306
+ const parent = n.parent;
307
+ if (parent && ts.isPropertyAccessExpression(parent) && parent.name === n) return n;
308
+ if (parent && ts.isJsxAttribute(parent) && parent.name === n) return n;
309
+ if (parent && ts.isShorthandPropertyAssignment(parent)) return n;
310
+ const resolved = propDerivedVars.get(n.text);
311
+ return ts.factory.createParenthesizedExpression(resolveExprTransitive(resolved, n.text));
312
+ }
313
+ return ts.visitEachChild(n, visit, void 0);
314
+ });
316
315
  }
316
+ /** Print an AST expression back to source text. */
317
+ const printer = ts.createPrinter({ removeComments: false });
317
318
  /**
318
319
  * Enhanced dynamic check — combines containsCall with props awareness.
319
320
  * Returns true if an expression is reactive (contains signal calls,
320
321
  * accesses props members, or references prop-derived variables).
321
322
  */
322
- /**
323
- * Replace prop-derived variable names in a source text with their original expressions.
324
- * Simple regex-based replacement — safe because variable names are identifiers.
325
- */
326
- function inlineVarsInText(text) {
327
- if (propDerivedVars.size === 0) return text;
328
- let result = text;
329
- for (const [varName, expr] of propDerivedVars) {
330
- const re = new RegExp(`(?<![.\\w])${varName}(?![\\w:=])`, "g");
331
- result = result.replace(re, `(${expr})`);
332
- }
333
- return result;
334
- }
335
323
  function isDynamic(node) {
336
324
  if (containsCall(node)) return true;
337
325
  return accessesProps(node);
@@ -634,7 +622,7 @@ function transformJSX(code, filename = "input.tsx") {
634
622
  } else {
635
623
  needsBindImportGlobal = true;
636
624
  const d = nextDisp();
637
- bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${inlineVarsInText(expr)} })`);
625
+ bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${expr} })`);
638
626
  }
639
627
  return needsPlaceholder ? "<!>" : "";
640
628
  }
@@ -699,7 +687,7 @@ function transformJSX(code, filename = "input.tsx") {
699
687
  if (reactiveBindExprs.length > 0) {
700
688
  needsBindImportGlobal = true;
701
689
  const combinedName = nextDisp();
702
- const combinedBody = reactiveBindExprs.map(inlineVarsInText).join("; ");
690
+ const combinedBody = reactiveBindExprs.join("; ");
703
691
  bindLines.push(`const ${combinedName} = _bind(() => { ${combinedBody} })`);
704
692
  }
705
693
  if (bindLines.length === 0 && disposerNames.length === 0) return `_tpl("${escaped}", () => null)`;
@@ -774,8 +762,14 @@ function transformJSX(code, filename = "input.tsx") {
774
762
  if (ts.isJsxElement(node)) return node.children.some((c) => ts.isJsxExpression(c) && c.expression !== void 0);
775
763
  return false;
776
764
  }
777
- /** Slice expression source from the original code */
765
+ /** Slice expression source from the original code.
766
+ * Resolves any prop-derived identifiers found anywhere in the expression
767
+ * via AST transformation — handles template literals, ternaries, etc. */
778
768
  function sliceExpr(expr) {
769
+ if (propDerivedVars.size > 0 && accessesProps(expr)) {
770
+ const resolved = resolveExprTransitive(expr);
771
+ return printer.printNode(ts.EmitHint.Expression, resolved, sf);
772
+ }
779
773
  return code.slice(expr.getStart(sf), expr.getEnd());
780
774
  }
781
775
  /** Get tag name string */
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/jsx.ts","../src/project-scanner.ts","../src/react-intercept.ts"],"sourcesContent":["/**\n * JSX transform — wraps dynamic JSX expressions in `() =>` so the Pyreon runtime\n * receives reactive getters instead of eagerly-evaluated snapshot values.\n *\n * Rules:\n * - `<div>{expr}</div>` → `<div>{() => expr}</div>` (child)\n * - `<div class={expr}>` → `<div class={() => expr}>` (prop)\n * - `<button onClick={fn}>` → unchanged (event handler)\n * - `<div>{() => expr}</div>` → unchanged (already wrapped)\n * - `<div>{\"literal\"}</div>` → unchanged (static)\n *\n * Static VNode hoisting:\n * - Fully static JSX in expression containers is hoisted to module scope:\n * `{<span>Hello</span>}` → `const _$h0 = <span>Hello</span>` + `{_$h0}`\n * - Hoisted nodes are created ONCE at module initialisation, not per-instance.\n * - A JSX node is static if: all props are string literals / booleans / static\n * values, and all children are text nodes or other static JSX nodes.\n *\n * Template emission:\n * - JSX element trees with ≥ 2 DOM elements (no components, no spread attrs)\n * are compiled to `_tpl(html, bindFn)` calls instead of nested `h()` calls.\n * - The HTML string is parsed once via <template>.innerHTML, then cloneNode(true)\n * for each instance (~5-10x faster than sequential createElement calls).\n * - Static attributes are baked into the HTML string; dynamic attributes and\n * text content use renderEffect in the bind function.\n *\n * Implementation: TypeScript parser for positions + magic-string replacements.\n * No extra runtime dependencies — `typescript` is already in devDependencies.\n *\n * Known limitation (v0): expressions inside *nested* JSX within a child\n * expression container are not individually wrapped. They are still reactive\n * because the outer wrapper re-evaluates the whole subtree, just at a coarser\n * granularity. Fine-grained nested wrapping is planned for a future pass.\n */\n\nimport ts from 'typescript'\n\nexport interface CompilerWarning {\n /** Warning message */\n message: string\n /** Source file line number (1-based) */\n line: number\n /** Source file column number (0-based) */\n column: number\n /** Warning code for filtering */\n code: 'signal-call-in-jsx' | 'missing-key-on-for' | 'signal-in-static-prop'\n}\n\nexport interface TransformResult {\n /** Transformed source code (JSX preserved, only expression containers modified) */\n code: string\n /** Whether the output uses _tpl/_re template helpers (needs auto-import) */\n usesTemplates?: boolean\n /** Compiler warnings for common mistakes */\n warnings: CompilerWarning[]\n}\n\n// Props that should never be wrapped in a reactive getter\nconst SKIP_PROPS = new Set(['key', 'ref'])\n// Event handler pattern: onClick, onInput, onMouseEnter, …\nconst EVENT_RE = /^on[A-Z]/\n// Events delegated to the container — must match runtime DELEGATED_EVENTS set\nconst DELEGATED_EVENTS = new Set([\n 'click',\n 'dblclick',\n 'contextmenu',\n 'focusin',\n 'focusout',\n 'input',\n 'change',\n 'keydown',\n 'keyup',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseover',\n 'mouseout',\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'pointerover',\n 'pointerout',\n 'touchstart',\n 'touchend',\n 'touchmove',\n 'submit',\n])\n\nexport function transformJSX(code: string, filename = 'input.tsx'): TransformResult {\n const scriptKind =\n filename.endsWith('.tsx') || filename.endsWith('.jsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TSX // default to TSX so JSX is always parsed\n\n const sf = ts.createSourceFile(\n filename,\n code,\n ts.ScriptTarget.ESNext,\n /* setParentNodes */ true,\n scriptKind,\n )\n\n type Replacement = { start: number; end: number; text: string }\n const replacements: Replacement[] = []\n const warnings: CompilerWarning[] = []\n\n function warn(node: ts.Node, message: string, warnCode: CompilerWarning['code']): void {\n const { line, character } = sf.getLineAndCharacterOfPosition(node.getStart(sf))\n warnings.push({ message, line: line + 1, column: character, code: warnCode })\n }\n\n // ── Static hoisting state ─────────────────────────────────────────────────\n type Hoist = { name: string; text: string }\n const hoists: Hoist[] = []\n let hoistIdx = 0\n let needsTplImport = false\n let needsRpImport = false\n let needsBindTextImportGlobal = false\n let needsBindDirectImportGlobal = false\n let needsBindImportGlobal = false\n let needsApplyPropsImportGlobal = false\n\n /**\n * If `node` is a fully-static JSX element/fragment, register a module-scope\n * hoist for it and return the generated variable name. Otherwise return null.\n */\n function maybeHoist(node: ts.Node): string | null {\n if (\n (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) &&\n isStaticJSXNode(node as ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment)\n ) {\n const name = `_$h${hoistIdx++}`\n const text = code.slice(node.getStart(sf), node.getEnd())\n hoists.push({ name, text })\n return name\n }\n return null\n }\n\n function wrap(expr: ts.Expression): void {\n const start = expr.getStart(sf)\n const end = expr.getEnd()\n const exprText = inlineVarsInText(code.slice(start, end))\n replacements.push({ start, end, text: `() => ${exprText}` })\n }\n\n /** Try to hoist or wrap an expression, pushing a replacement if needed. */\n function hoistOrWrap(expr: ts.Expression): void {\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n } else if (shouldWrap(expr)) {\n wrap(expr)\n }\n }\n\n // ── walk sub-handlers ───────────────────────────────────────────────────────\n\n /** Try to emit a template for a JsxElement. Returns true if handled. */\n function tryTemplateEmit(node: ts.JsxElement): boolean {\n const elemCount = templateElementCount(node, /* isRoot */ true)\n if (elemCount < 1) return false\n const tplCall = buildTemplateCall(node)\n if (!tplCall) return false\n const start = node.getStart(sf)\n const end = node.getEnd()\n const parent = node.parent\n const needsBraces = parent && (ts.isJsxElement(parent) || ts.isJsxFragment(parent))\n replacements.push({ start, end, text: needsBraces ? `{${tplCall}}` : tplCall })\n needsTplImport = true\n return true\n }\n\n /** Emit warnings for common JSX mistakes (e.g. <For> without by). */\n function checkForWarnings(node: ts.JsxElement | ts.JsxSelfClosingElement): void {\n const opening = ts.isJsxElement(node) ? node.openingElement : node\n const tagName = ts.isIdentifier(opening.tagName) ? opening.tagName.text : ''\n if (tagName !== 'For') return\n const hasBy = opening.attributes.properties.some(\n (p) => ts.isJsxAttribute(p) && ts.isIdentifier(p.name) && p.name.text === 'by',\n )\n if (!hasBy) {\n warn(\n opening.tagName,\n `<For> without a \"by\" prop will use index-based diffing, which is slower and may cause bugs with stateful children. Add by={(item) => item.id} for efficient keyed reconciliation.`,\n 'missing-key-on-for',\n )\n }\n }\n\n /** Handle a JSX attribute node — wrap or hoist its value if needed.\n *\n * Both DOM and component props are processed:\n * - DOM props: () => expr — applyProp creates renderEffect\n * - Component props: _rp(() => expr) — makeReactiveProps converts to getters\n *\n * The _rp() brand distinguishes compiler wrappers from user-written accessor\n * props (like Show's when, For's each) so makeReactiveProps only converts\n * compiler-emitted wrappers.\n */\n function handleJsxAttribute(node: ts.JsxAttribute): void {\n const name = ts.isIdentifier(node.name) ? node.name.text : ''\n if (SKIP_PROPS.has(name) || EVENT_RE.test(name)) return\n if (!node.initializer || !ts.isJsxExpression(node.initializer)) return\n const expr = node.initializer.expression\n if (!expr) return\n\n const openingEl = node.parent.parent as ts.JsxOpeningElement | ts.JsxSelfClosingElement\n const tagName = ts.isIdentifier(openingEl.tagName) ? openingEl.tagName.text : ''\n const isComponent = tagName.length > 0 && tagName.charAt(0) !== tagName.charAt(0).toLowerCase()\n\n if (isComponent) {\n // Component prop: wrap with _rp() brand so makeReactiveProps recognizes it.\n //\n // EXCEPTION: If the expression is a single JSX element (not a conditional),\n // do NOT wrap the outer expression. The JSX element is created once (stable VNode).\n // Its own inner props will be wrapped individually via recursive walk().\n // This prevents remounting: <Icon name={x()} /> stays one Icon instance,\n // only its name prop updates reactively.\n const isSingleJsx = ts.isJsxElement(expr) || ts.isJsxSelfClosingElement(expr)\n if (isSingleJsx) {\n // Don't wrap — recurse into the JSX element's attributes instead\n ts.forEachChild(expr, walk)\n return\n }\n\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n } else if (shouldWrap(expr)) {\n const start = expr.getStart(sf)\n const end = expr.getEnd()\n replacements.push({ start, end, text: `_rp(() => ${inlineVarsInText(code.slice(start, end))})` })\n needsRpImport = true\n }\n } else {\n // DOM prop: standard () => expr wrapping\n hoistOrWrap(expr)\n }\n }\n\n /** Handle a JSX expression in child position — wrap, hoist, or recurse. */\n function handleJsxExpression(node: ts.JsxExpression): void {\n const expr = node.expression\n if (!expr) return\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n return\n }\n if (shouldWrap(expr)) {\n wrap(expr)\n return\n }\n // Not hoisted, not wrapped (e.g., arrow function in For callback).\n // Recurse into the expression body to find nested JSX elements\n // that should be compiled to _tpl() calls.\n ts.forEachChild(expr, walk)\n }\n\n // ── Prop-derived variable tracking ─────────────────────────────────────────\n // Pre-pass: find variables derived from props/splitProps results inside\n // component functions. These are inlined at JSX use sites so the compiler's\n // existing wrapping makes them reactive.\n //\n // Example:\n // const align = props.alignX ?? 'left'\n // return <div class={align}> ← inlined to: class={props.alignX ?? 'left'}\n // ← compiler wraps: class={() => props.alignX ?? 'left'}\n\n /** Names that refer to the props object or splitProps results. */\n const propsNames = new Set<string>()\n\n /** Map of variable name → source text of the original expression. */\n const propDerivedVars = new Map<string, string>()\n\n /** Check if an expression reads from a tracked props-like object. */\n function readsFromProps(node: ts.Node): boolean {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {\n return propsNames.has(node.expression.text)\n }\n if (ts.isElementAccessExpression(node) && ts.isIdentifier(node.expression)) {\n return propsNames.has(node.expression.text)\n }\n // Check children recursively — e.g. props.x ?? 'default'\n let found = false\n ts.forEachChild(node, (child) => {\n if (found) return\n if (readsFromProps(child)) found = true\n })\n return found\n }\n\n /** Pre-pass: scan a function body for prop-derived variable declarations.\n * callbackDepth tracks nesting inside callback arguments (map, filter, etc.)\n * to avoid tracking variables declared inside callbacks as prop-derived. */\n let _callbackDepth = 0\n function scanForPropDerivedVars(node: ts.Node): void {\n // Track callback nesting — don't track vars inside callbacks\n if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node))) {\n const parent = node.parent\n if (parent && ts.isCallExpression(parent) && parent.arguments.includes(node as any)) {\n _callbackDepth++\n ts.forEachChild(node, scanForPropDerivedVars)\n _callbackDepth--\n return\n }\n }\n // Track the function's first parameter as a props name.\n // Only for COMPONENT functions — not callbacks like .map(item => <div>...)\n // Heuristic: component functions are named declarations, const assignments,\n // or export defaults — NOT inline arguments to calls like .map(), .filter().\n if ((ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node))\n && node.parameters.length > 0) {\n\n // Skip functions that are arguments to a call (map/filter callbacks)\n const parent = node.parent\n if (parent && ts.isCallExpression(parent) && parent.arguments.includes(node as any)) {\n ts.forEachChild(node, scanForPropDerivedVars)\n return\n }\n\n const firstParam = node.parameters[0]!\n if (ts.isIdentifier(firstParam.name)) {\n // Check if this function returns JSX (is a component)\n let hasJSX = false\n ts.forEachChild(node, function checkJSX(n) {\n if (hasJSX) return\n if (ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n)) {\n hasJSX = true\n return\n }\n ts.forEachChild(n, checkJSX)\n })\n if (hasJSX) propsNames.add(firstParam.name.text)\n }\n }\n\n // Track splitProps results: const [own, rest] = splitProps(props, [...])\n if (ts.isVariableStatement(node)) {\n for (const decl of node.declarationList.declarations) {\n if (ts.isArrayBindingPattern(decl.name) && decl.initializer\n && ts.isCallExpression(decl.initializer)) {\n const callee = decl.initializer.expression\n if (ts.isIdentifier(callee) && callee.text === 'splitProps') {\n for (const el of decl.name.elements) {\n if (ts.isBindingElement(el) && ts.isIdentifier(el.name)) {\n propsNames.add(el.name.text)\n }\n }\n }\n }\n\n // Track: const x = props.y ?? z OR const x = own.y\n // Skip let/var — mutable variables can be reassigned, unsafe to inline\n // Skip declarations inside callbacks (map, filter, etc.)\n if (!(node.declarationList.flags & ts.NodeFlags.Const)) continue\n if (_callbackDepth > 0) continue\n if (ts.isIdentifier(decl.name) && decl.initializer) {\n if (readsFromProps(decl.initializer)) {\n const varName = decl.name.text\n const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd())\n propDerivedVars.set(varName, exprText)\n }\n }\n }\n }\n\n ts.forEachChild(node, scanForPropDerivedVars)\n }\n\n // Run pre-pass\n scanForPropDerivedVars(sf)\n\n // Transitive resolution: if const b = a + 1 where a is prop-derived,\n // then b is also prop-derived. Inline b → (a + 1) → ((props.x) + 1).\n // Fixed-point iteration until no new variables are added.\n let changed = true\n while (changed) {\n changed = false\n sf.forEachChild(function scanTransitive(node) {\n if (!ts.isVariableStatement(node)) { ts.forEachChild(node, scanTransitive); return }\n for (const decl of node.declarationList.declarations) {\n if (!ts.isIdentifier(decl.name) || !decl.initializer) continue\n const varName = decl.name.text\n if (propDerivedVars.has(varName)) continue // already tracked\n if (node.declarationList.flags & ts.NodeFlags.Let) continue // skip let\n // Check if the initializer references any existing prop-derived var\n let usesPropVar = false\n ts.forEachChild(decl.initializer, function check(n) {\n if (usesPropVar) return\n if (ts.isIdentifier(n) && propDerivedVars.has(n.text)) {\n const parent = n.parent\n if (parent && ts.isPropertyAccessExpression(parent) && parent.name === n) return\n usesPropVar = true\n }\n ts.forEachChild(n, check)\n })\n if (usesPropVar) {\n const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd())\n propDerivedVars.set(varName, exprText)\n changed = true\n }\n }\n })\n }\n\n // Resolve transitive inlining: if b's expr references a, replace a with its expr\n for (const [varName, expr] of propDerivedVars) {\n let resolved = expr\n for (const [depName, depExpr] of propDerivedVars) {\n if (depName === varName) continue\n const re = new RegExp(`(?<![.\\\\w])${depName}(?![\\\\w:=])`, 'g')\n if (re.test(resolved)) {\n resolved = resolved.replace(re, `(${depExpr})`)\n }\n }\n if (resolved !== expr) propDerivedVars.set(varName, resolved)\n }\n\n /**\n * Enhanced dynamic check — combines containsCall with props awareness.\n * Returns true if an expression is reactive (contains signal calls,\n * accesses props members, or references prop-derived variables).\n */\n /**\n * Replace prop-derived variable names in a source text with their original expressions.\n * Simple regex-based replacement — safe because variable names are identifiers.\n */\n function inlineVarsInText(text: string): string {\n if (propDerivedVars.size === 0) return text\n let result = text\n for (const [varName, expr] of propDerivedVars) {\n // Replace standalone variable references only.\n // Must NOT match:\n // - property access: obj.varName (preceded by .)\n // - property name in object: { varName: ... } (followed by :)\n // - part of longer identifier: varNameExtra\n // Lookbehind ensures not preceded by . or alphanumeric\n // Lookahead ensures not followed by alphanumeric, :, or = (JSX attr name)\n const re = new RegExp(`(?<![.\\\\w])${varName}(?![\\\\w:=])`, 'g')\n result = result.replace(re, `(${expr})`)\n }\n return result\n }\n\n function isDynamic(node: ts.Node): boolean {\n if (containsCall(node)) return true\n return accessesProps(node)\n }\n\n /** Check if an expression accesses a tracked props object or a prop-derived variable. */\n function accessesProps(node: ts.Node): boolean {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {\n if (propsNames.has(node.expression.text)) return true\n }\n if (ts.isIdentifier(node) && propDerivedVars.has(node.text)) {\n const parent = node.parent\n if (parent && ts.isPropertyAccessExpression(parent) && parent.name === node) return false\n return true\n }\n let found = false\n ts.forEachChild(node, (child) => {\n if (found) return\n if (ts.isArrowFunction(child) || ts.isFunctionExpression(child)) return\n if (accessesProps(child)) found = true\n })\n return found\n }\n\n function shouldWrap(node: ts.Expression): boolean {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) return false\n if (isStatic(node)) return false\n if (ts.isCallExpression(node) && isPureStaticCall(node)) return false\n return isDynamic(node)\n }\n\n function walk(node: ts.Node): void {\n if (ts.isJsxElement(node) && tryTemplateEmit(node)) return\n if (ts.isJsxSelfClosingElement(node) || ts.isJsxElement(node)) checkForWarnings(node)\n if (ts.isJsxAttribute(node)) {\n handleJsxAttribute(node)\n return\n }\n if (ts.isJsxExpression(node)) {\n handleJsxExpression(node)\n return\n }\n ts.forEachChild(node, walk)\n }\n\n walk(sf)\n\n if (replacements.length === 0 && hoists.length === 0) return { code, warnings }\n\n // Apply replacements left-to-right via string builder — O(n) single join\n replacements.sort((a, b) => a.start - b.start)\n\n const parts: string[] = []\n let lastPos = 0\n for (const r of replacements) {\n parts.push(code.slice(lastPos, r.start))\n parts.push(r.text)\n lastPos = r.end\n }\n parts.push(code.slice(lastPos))\n let result = parts.join('')\n\n // Prepend module-scope hoisted static VNode declarations\n if (hoists.length > 0) {\n const preamble = hoists.map((h) => `const ${h.name} = /*@__PURE__*/ ${h.text}\\n`).join('')\n result = preamble + result\n }\n\n // Prepend template imports if _tpl() was emitted\n if (needsTplImport) {\n const runtimeDomImports = ['_tpl']\n if (needsBindDirectImportGlobal) runtimeDomImports.push('_bindDirect')\n if (needsBindTextImportGlobal) runtimeDomImports.push('_bindText')\n if (needsApplyPropsImportGlobal) runtimeDomImports.push('_applyProps')\n const reactivityImports = needsBindImportGlobal\n ? `\\nimport { _bind } from \"@pyreon/reactivity\";`\n : ''\n result =\n `import { ${runtimeDomImports.join(', ')} } from \"@pyreon/runtime-dom\";${reactivityImports}\\n` +\n result\n }\n\n // Prepend _rp import if reactive component props were emitted\n if (needsRpImport) {\n result = `import { _rp } from \"@pyreon/core\";\\n` + result\n }\n\n return { code: result, usesTemplates: needsTplImport, warnings }\n\n // ── Template emission helpers (closures over sf, code) ──────────────────────\n\n /**\n * Check if attributes prevent template emission.\n * - `key` always bails (VNode reconciliation prop)\n * - Spread on inner elements bails (too complex to merge in _bind)\n * - Spread on root element is allowed — applied via applyProps in _bind\n */\n function hasBailAttr(node: ts.JsxElement | ts.JsxSelfClosingElement, isRoot = false): boolean {\n for (const attr of jsxAttrs(node)) {\n if (ts.isJsxSpreadAttribute(attr)) {\n // Allow spread on root element — handled in buildTemplateCall\n if (isRoot) continue\n return true\n }\n if (ts.isJsxAttribute(attr) && ts.isIdentifier(attr.name) && attr.name.text === 'key')\n return true\n }\n return false\n }\n\n /**\n * Count template-eligible elements for a single JSX child.\n * Returns 0 for skippable children, -1 for bail, positive for element count.\n */\n function countChildForTemplate(child: ts.JsxChild): number {\n if (ts.isJsxText(child)) return 0\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child))\n return templateElementCount(child)\n if (ts.isJsxExpression(child)) {\n if (!child.expression) return 0\n return containsJSXInExpr(child.expression) ? -1 : 0\n }\n if (ts.isJsxFragment(child)) return templateFragmentCount(child)\n return -1\n }\n\n /**\n * Count DOM elements in a JSX subtree. Returns -1 if the tree is not\n * eligible for template emission.\n */\n function templateElementCount(\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n isRoot = false,\n ): number {\n const tag = jsxTagName(node)\n if (!tag || !isLowerCase(tag)) return -1\n if (hasBailAttr(node, isRoot)) return -1\n if (!ts.isJsxElement(node)) return 1\n\n let count = 1\n for (const child of node.children) {\n const c = countChildForTemplate(child)\n if (c === -1) return -1\n count += c\n }\n return count\n }\n\n /** Count template-eligible elements inside a fragment. */\n function templateFragmentCount(frag: ts.JsxFragment): number {\n let count = 0\n for (const child of frag.children) {\n const c = countChildForTemplate(child)\n if (c === -1) return -1\n count += c\n }\n return count\n }\n\n /**\n * Build the complete `_tpl(\"html\", (__root) => { ... })` call string\n * for a template-eligible JSX element tree. Returns null if codegen fails.\n */\n function buildTemplateCall(node: ts.JsxElement | ts.JsxSelfClosingElement): string | null {\n const bindLines: string[] = []\n const disposerNames: string[] = []\n let varIdx = 0\n let dispIdx = 0\n // Reactive expressions that will be combined into a single _bind call\n const reactiveBindExprs: string[] = []\n let needsBindTextImport = false\n let needsBindDirectImport = false\n let needsApplyPropsImport = false\n\n function nextVar(): string {\n return `__e${varIdx++}`\n }\n function nextDisp(): string {\n const name = `__d${dispIdx++}`\n disposerNames.push(name)\n return name\n }\n function nextTextVar(): string {\n return `__t${varIdx++}`\n }\n\n /** Resolve the variable name for an element given its accessor path. */\n function resolveElementVar(accessor: string, hasDynamic: boolean): string {\n if (accessor === '__root') return '__root'\n if (hasDynamic) {\n const v = nextVar()\n bindLines.push(`const ${v} = ${accessor}`)\n return v\n }\n return accessor\n }\n\n /** Emit bind line for a ref attribute. */\n function emitRef(attr: ts.JsxAttribute, varName: string): void {\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return\n if (!attr.initializer.expression) return\n bindLines.push(`${sliceExpr(attr.initializer.expression)}.current = ${varName}`)\n }\n\n /** Emit event handler bind line — delegated (expando) or addEventListener. */\n function emitEventListener(attr: ts.JsxAttribute, attrName: string, varName: string): void {\n const eventName = (attrName[2] ?? '').toLowerCase() + attrName.slice(3)\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return\n if (!attr.initializer.expression) return\n const handler = sliceExpr(attr.initializer.expression)\n if (DELEGATED_EVENTS.has(eventName)) {\n // Delegated: store handler as expando property — container listener picks it up\n bindLines.push(`${varName}.__ev_${eventName} = ${handler}`)\n } else {\n bindLines.push(`${varName}.addEventListener(\"${eventName}\", ${handler})`)\n }\n }\n\n /** Return HTML string for a static attribute expression, or null if not static. */\n function staticAttrToHtml(exprNode: ts.Expression, htmlAttrName: string): string | null {\n if (!isStatic(exprNode)) return null\n if (ts.isStringLiteral(exprNode)) return ` ${htmlAttrName}=\"${escapeHtmlAttr(exprNode.text)}\"`\n if (ts.isNumericLiteral(exprNode)) return ` ${htmlAttrName}=\"${exprNode.text}\"`\n if (exprNode.kind === ts.SyntaxKind.TrueKeyword) return ` ${htmlAttrName}`\n return '' // false/null/undefined → omit\n }\n\n /**\n * Try to extract a direct signal reference from an expression.\n * Returns the callee text (e.g. \"count\" or \"row.label\") if the expression\n * is a single call with no arguments, otherwise null.\n */\n function tryDirectSignalRef(exprNode: ts.Expression): string | null {\n let inner = exprNode\n // Unwrap concise arrow: () => expr\n if (ts.isArrowFunction(inner) && !ts.isBlock(inner.body)) {\n inner = inner.body as ts.Expression\n }\n if (!ts.isCallExpression(inner)) return null\n if (inner.arguments.length > 0) return null\n const callee = inner.expression\n // Only match simple identifiers: count() → _bindText(count, node)\n // Property access like obj.method() is NOT safe — detaching the method\n // loses `this` context (e.g. value.toLocaleString becomes unbound).\n if (ts.isIdentifier(callee)) {\n return sliceExpr(callee)\n }\n return null\n }\n\n /** Unwrap a reactive accessor expression for use inside _bind(). */\n function unwrapAccessor(exprNode: ts.Expression): { expr: string; isReactive: boolean } {\n // Concise arrow: () => value() → unwrap to \"value()\"\n if (ts.isArrowFunction(exprNode) && !ts.isBlock(exprNode.body)) {\n return { expr: sliceExpr(exprNode.body as ts.Expression), isReactive: true }\n }\n // Block-body arrow/function: invoke it\n if (ts.isArrowFunction(exprNode) || ts.isFunctionExpression(exprNode)) {\n return { expr: `(${sliceExpr(exprNode)})()`, isReactive: true }\n }\n return { expr: sliceExpr(exprNode), isReactive: isDynamic(exprNode) }\n }\n\n /** Build a setter expression for an attribute. */\n function attrSetter(htmlAttrName: string, varName: string, expr: string): string {\n if (htmlAttrName === 'class') return `${varName}.className = ${expr}`\n if (htmlAttrName === 'style') return `${varName}.style.cssText = ${expr}`\n return `${varName}.setAttribute(\"${htmlAttrName}\", ${expr})`\n }\n\n /** Emit bind line for a dynamic (non-static) attribute. */\n function emitDynamicAttr(\n _expr: string,\n exprNode: ts.Expression,\n htmlAttrName: string,\n varName: string,\n ): void {\n const { expr, isReactive } = unwrapAccessor(exprNode)\n\n if (!isReactive) {\n bindLines.push(attrSetter(htmlAttrName, varName, expr))\n return\n }\n\n // Direct signal binding for bare signal calls (e.g. class={() => active()})\n const directRef = tryDirectSignalRef(exprNode)\n if (directRef) {\n needsBindDirectImport = true\n const d = nextDisp()\n const updater =\n htmlAttrName === 'class'\n ? `(v) => { ${varName}.className = v == null ? \"\" : String(v) }`\n : htmlAttrName === 'style'\n ? `(v) => { if (typeof v === \"string\") ${varName}.style.cssText = v; else if (v) Object.assign(${varName}.style, v) }`\n : `(v) => { ${varName}.setAttribute(\"${htmlAttrName}\", v == null ? \"\" : String(v)) }`\n bindLines.push(`const ${d} = _bindDirect(${directRef}, ${updater})`)\n return\n }\n\n reactiveBindExprs.push(attrSetter(htmlAttrName, varName, expr))\n }\n\n /** Emit bind line or HTML for an expression attribute value. */\n function emitAttrExpression(\n exprNode: ts.Expression,\n htmlAttrName: string,\n varName: string,\n ): string {\n const staticHtml = staticAttrToHtml(exprNode, htmlAttrName)\n if (staticHtml !== null) return staticHtml\n\n // style={{...}} → Object.assign(el.style, {...}) for object expressions\n if (htmlAttrName === 'style' && ts.isObjectLiteralExpression(exprNode)) {\n bindLines.push(`Object.assign(${varName}.style, ${sliceExpr(exprNode)})`)\n return ''\n }\n\n emitDynamicAttr(sliceExpr(exprNode), exprNode, htmlAttrName, varName)\n return ''\n }\n\n /** Emit side-effects for special attrs (ref, event). Returns true if handled. */\n function tryEmitSpecialAttr(attr: ts.JsxAttribute, attrName: string, varName: string): boolean {\n if (attrName === 'ref') {\n emitRef(attr, varName)\n return true\n }\n if (EVENT_RE.test(attrName)) {\n emitEventListener(attr, attrName, varName)\n return true\n }\n return false\n }\n\n /** Convert an attribute initializer to HTML. Returns empty string for side-effect-only attrs. */\n function attrInitializerToHtml(\n attr: ts.JsxAttribute,\n htmlAttrName: string,\n varName: string,\n ): string {\n if (!attr.initializer) return ` ${htmlAttrName}`\n if (ts.isStringLiteral(attr.initializer))\n return ` ${htmlAttrName}=\"${escapeHtmlAttr(attr.initializer.text)}\"`\n if (ts.isJsxExpression(attr.initializer) && attr.initializer.expression)\n return emitAttrExpression(attr.initializer.expression, htmlAttrName, varName)\n return ''\n }\n\n /** Process a single attribute, returning HTML to append. */\n function processOneAttr(attr: ts.JsxAttributeLike, varName: string): string {\n // Spread attribute: apply all props at runtime\n if (ts.isJsxSpreadAttribute(attr)) {\n const expr = sliceExpr(attr.expression)\n // Use runtime-dom's applyProps which handles class, style, events, etc.\n needsApplyPropsImport = true\n if (isDynamic(attr.expression)) {\n reactiveBindExprs.push(`_applyProps(${varName}, ${expr})`)\n } else {\n bindLines.push(`_applyProps(${varName}, ${expr})`)\n }\n return ''\n }\n if (!ts.isJsxAttribute(attr)) return ''\n const attrName = ts.isIdentifier(attr.name) ? attr.name.text : ''\n if (attrName === 'key') return ''\n if (tryEmitSpecialAttr(attr, attrName, varName)) return ''\n return attrInitializerToHtml(attr, JSX_TO_HTML_ATTR[attrName] ?? attrName, varName)\n }\n\n /** Process all attributes on an element, returning the HTML attribute string. */\n function processAttrs(el: ts.JsxElement | ts.JsxSelfClosingElement, varName: string): string {\n let htmlAttrs = ''\n for (const attr of jsxAttrs(el)) htmlAttrs += processOneAttr(attr, varName)\n return htmlAttrs\n }\n\n /** Emit bind lines for a reactive text expression child. */\n function emitReactiveTextChild(\n expr: string,\n exprNode: ts.Expression,\n varName: string,\n parentRef: string,\n childNodeIdx: number,\n needsPlaceholder: boolean,\n ): string {\n const tVar = nextTextVar()\n bindLines.push(`const ${tVar} = document.createTextNode(\"\")`)\n if (needsPlaceholder) {\n bindLines.push(\n `${parentRef}.replaceChild(${tVar}, ${parentRef}.childNodes[${childNodeIdx}])`,\n )\n } else {\n bindLines.push(`${varName}.appendChild(${tVar})`)\n }\n // Direct signal binding: bypass effect system entirely\n const directRef = tryDirectSignalRef(exprNode)\n if (directRef) {\n needsBindTextImport = true\n const d = nextDisp()\n bindLines.push(`const ${d} = _bindText(${directRef}, ${tVar})`)\n } else {\n // Each reactive text child gets its own _bind — independent tracking.\n // When r.name() changes, r.email()'s _bind doesn't re-run.\n needsBindImportGlobal = true\n const d = nextDisp()\n bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${inlineVarsInText(expr)} })`)\n }\n return needsPlaceholder ? '<!>' : ''\n }\n\n /** Emit bind lines for a static text expression child. */\n function emitStaticTextChild(\n expr: string,\n varName: string,\n parentRef: string,\n childNodeIdx: number,\n needsPlaceholder: boolean,\n ): string {\n if (needsPlaceholder) {\n const tVar = nextTextVar()\n bindLines.push(`const ${tVar} = document.createTextNode(${expr})`)\n bindLines.push(\n `${parentRef}.replaceChild(${tVar}, ${parentRef}.childNodes[${childNodeIdx}])`,\n )\n return '<!>'\n }\n bindLines.push(`${varName}.textContent = ${expr}`)\n return ''\n }\n\n /** Process a single flat child, returning the HTML contribution or null on failure. */\n function processOneChild(\n child: FlatChild,\n varName: string,\n parentRef: string,\n useMixed: boolean,\n useMultiExpr: boolean,\n childNodeIdx: number,\n ): string | null {\n if (child.kind === 'text') return escapeHtmlText(child.text)\n if (child.kind === 'element') {\n const childAccessor = useMixed\n ? `${parentRef}.childNodes[${childNodeIdx}]`\n : `${parentRef}.children[${child.elemIdx}]`\n return processElement(child.node, childAccessor)\n }\n // expression\n const needsPlaceholder = useMixed || useMultiExpr\n const { expr, isReactive } = unwrapAccessor(child.expression)\n if (isReactive) {\n return emitReactiveTextChild(\n expr,\n child.expression,\n varName,\n parentRef,\n childNodeIdx,\n needsPlaceholder,\n )\n }\n return emitStaticTextChild(expr, varName, parentRef, childNodeIdx, needsPlaceholder)\n }\n\n /** Process children of a JsxElement, returning the children HTML. */\n function processChildren(el: ts.JsxElement, varName: string, accessor: string): string | null {\n const flatChildren = flattenChildren(el.children)\n const { useMixed, useMultiExpr } = analyzeChildren(flatChildren)\n const parentRef = accessor === '__root' ? '__root' : varName\n\n let html = ''\n let childNodeIdx = 0\n\n for (const child of flatChildren) {\n const childHtml = processOneChild(\n child,\n varName,\n parentRef,\n useMixed,\n useMultiExpr,\n childNodeIdx,\n )\n if (childHtml === null) return null\n html += childHtml\n childNodeIdx++\n }\n\n return html\n }\n\n /** Process a single DOM element for template emission. Returns the HTML string or null. */\n function processElement(\n el: ts.JsxElement | ts.JsxSelfClosingElement,\n accessor: string,\n ): string | null {\n const tag = jsxTagName(el)\n if (!tag) return null\n\n const varName = resolveElementVar(accessor, elementHasDynamic(el))\n const htmlAttrs = processAttrs(el, varName)\n let html = `<${tag}${htmlAttrs}>`\n\n if (ts.isJsxElement(el)) {\n const childHtml = processChildren(el, varName, accessor)\n if (childHtml === null) return null\n html += childHtml\n }\n\n if (!VOID_ELEMENTS.has(tag)) html += `</${tag}>`\n return html\n }\n\n const html = processElement(node, '__root')\n if (html === null) return null\n\n if (needsBindTextImport) needsBindTextImportGlobal = true\n if (needsBindDirectImport) needsBindDirectImportGlobal = true\n if (needsApplyPropsImport) needsApplyPropsImportGlobal = true\n\n // Build bind function body\n const escaped = html.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n\n // Emit combined _bind for reactive attribute/text expressions that\n // weren't handled by _bindText. This merges N separate _bind calls into\n // one — saving N-1 closures + deps arrays per template instance.\n // Emit a single combined _bind for all reactive attribute/text expressions\n // that weren't handled by _bindText. Merges N separate _bind calls into one —\n // saving N-1 closures + deps arrays per template instance.\n if (reactiveBindExprs.length > 0) {\n needsBindImportGlobal = true\n const combinedName = nextDisp()\n const combinedBody = reactiveBindExprs.map(inlineVarsInText).join('; ')\n bindLines.push(`const ${combinedName} = _bind(() => { ${combinedBody} })`)\n }\n\n if (bindLines.length === 0 && disposerNames.length === 0) {\n return `_tpl(\"${escaped}\", () => null)`\n }\n\n let body = bindLines.map((l) => ` ${l}`).join('\\n')\n if (disposerNames.length > 0) {\n body += `\\n return () => { ${disposerNames.map((d) => `${d}()`).join('; ')} }`\n } else {\n body += '\\n return null'\n }\n\n return `_tpl(\"${escaped}\", (__root) => {\\n${body}\\n})`\n }\n\n /** Flat child descriptor for template children processing */\n type FlatChild =\n | { kind: 'text'; text: string }\n | { kind: 'element'; node: ts.JsxElement | ts.JsxSelfClosingElement; elemIdx: number }\n | { kind: 'expression'; expression: ts.Expression }\n\n /** Classify a single JSX child into a FlatChild descriptor. */\n function classifyJsxChild(\n child: ts.JsxChild,\n out: FlatChild[],\n elemIdxRef: { value: number },\n recurse: (kids: ts.NodeArray<ts.JsxChild>) => void,\n ): void {\n if (ts.isJsxText(child)) {\n const trimmed = child.text.replace(/\\n\\s*/g, '').trim()\n if (trimmed) out.push({ kind: 'text', text: trimmed })\n return\n }\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {\n out.push({ kind: 'element', node: child, elemIdx: elemIdxRef.value++ })\n return\n }\n if (ts.isJsxExpression(child)) {\n if (child.expression) out.push({ kind: 'expression', expression: child.expression })\n return\n }\n if (ts.isJsxFragment(child)) recurse(child.children)\n }\n\n /**\n * Flatten JSX children, inlining fragment children and stripping whitespace-only text.\n * Returns a flat array of child descriptors with element indices pre-computed.\n */\n function flattenChildren(children: ts.NodeArray<ts.JsxChild>): FlatChild[] {\n const flatList: FlatChild[] = []\n const elemIdxRef = { value: 0 }\n\n function addChildren(kids: ts.NodeArray<ts.JsxChild>): void {\n for (const child of kids) classifyJsxChild(child, flatList, elemIdxRef, addChildren)\n }\n\n addChildren(children)\n return flatList\n }\n\n /** Analyze flat children to determine indexing strategy. */\n function analyzeChildren(flatChildren: FlatChild[]): {\n useMixed: boolean\n useMultiExpr: boolean\n } {\n const hasElem = flatChildren.some((c) => c.kind === 'element')\n const hasNonElem = flatChildren.some((c) => c.kind !== 'element')\n const exprCount = flatChildren.filter((c) => c.kind === 'expression').length\n return { useMixed: hasElem && hasNonElem, useMultiExpr: exprCount > 1 }\n }\n\n /** Check if a single attribute is dynamic (has ref, event, or non-static expression). */\n function attrIsDynamic(attr: ts.JsxAttributeLike): boolean {\n if (!ts.isJsxAttribute(attr)) return false\n const name = ts.isIdentifier(attr.name) ? attr.name.text : ''\n if (name === 'ref') return true\n if (EVENT_RE.test(name)) return true\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return false\n const expr = attr.initializer.expression\n return expr ? !isStatic(expr) : false\n }\n\n /** Check if an element has any dynamic attributes, events, ref, or expression children */\n function elementHasDynamic(node: ts.JsxElement | ts.JsxSelfClosingElement): boolean {\n if (jsxAttrs(node).some(attrIsDynamic)) return true\n if (ts.isJsxElement(node)) {\n return node.children.some((c) => ts.isJsxExpression(c) && c.expression !== undefined)\n }\n return false\n }\n\n /** Slice expression source from the original code */\n function sliceExpr(expr: ts.Expression): string {\n return code.slice(expr.getStart(sf), expr.getEnd())\n }\n\n /** Get tag name string */\n function jsxTagName(node: ts.JsxElement | ts.JsxSelfClosingElement): string {\n const tag = ts.isJsxElement(node) ? node.openingElement.tagName : node.tagName\n return ts.isIdentifier(tag) ? tag.text : ''\n }\n\n /** Get attribute list */\n function jsxAttrs(\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n ): ts.NodeArray<ts.JsxAttributeLike> {\n return ts.isJsxElement(node)\n ? node.openingElement.attributes.properties\n : node.attributes.properties\n }\n}\n\n// ─── Template constants ──────────────────────────────────────────────────────\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n])\n\nconst JSX_TO_HTML_ATTR: Record<string, string> = {\n className: 'class',\n htmlFor: 'for',\n}\n\nfunction isLowerCase(s: string): boolean {\n return s.length > 0 && s[0] === s[0]?.toLowerCase()\n}\n\n/** Check if an expression subtree contains JSX nodes */\nfunction containsJSXInExpr(node: ts.Node): boolean {\n if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node))\n return true\n return ts.forEachChild(node, containsJSXInExpr) ?? false\n}\n\nfunction escapeHtmlAttr(s: string): string {\n return s.replace(/&/g, '&amp;').replace(/\"/g, '&quot;')\n}\n\nfunction escapeHtmlText(s: string): string {\n return s.replace(/&/g, '&amp;').replace(/</g, '&lt;')\n}\n\n// ─── Static JSX analysis ──────────────────────────────────────────────────────\n\ntype StaticJSXNode = ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment\n\nfunction isStaticJSXNode(node: StaticJSXNode): boolean {\n if (ts.isJsxSelfClosingElement(node)) {\n return isStaticAttrs(node.attributes)\n }\n if (ts.isJsxFragment(node)) {\n return node.children.every(isStaticChild)\n }\n // JsxElement\n return isStaticAttrs(node.openingElement.attributes) && node.children.every(isStaticChild)\n}\n\nfunction isStaticAttrs(attrs: ts.JsxAttributes): boolean {\n return attrs.properties.every((prop) => {\n // Spread attribute — always dynamic\n if (!ts.isJsxAttribute(prop)) return false\n // Boolean shorthand: <input disabled />\n if (!prop.initializer) return true\n // String literal: class=\"foo\"\n if (ts.isStringLiteral(prop.initializer)) return true\n // Must be JsxExpression — the only remaining JsxAttributeValue type\n const expr = (prop.initializer as ts.JsxExpression).expression\n return expr ? isStatic(expr) : true\n })\n}\n\nfunction isStaticChild(child: ts.JsxChild): boolean {\n // Plain text content\n if (ts.isJsxText(child)) return true\n // Nested JSX elements\n if (ts.isJsxSelfClosingElement(child)) return isStaticJSXNode(child)\n if (ts.isJsxElement(child)) return isStaticJSXNode(child)\n if (ts.isJsxFragment(child)) return isStaticJSXNode(child)\n // Must be JsxExpression — the only remaining JsxChild type\n const expr = (child as ts.JsxExpression).expression\n return expr ? isStatic(expr) : true\n}\n\n// ─── General helpers ──────────────────────────────────────────────────────────\n\nfunction isStatic(node: ts.Expression): boolean {\n return (\n ts.isStringLiteral(node) ||\n ts.isNumericLiteral(node) ||\n ts.isNoSubstitutionTemplateLiteral(node) ||\n node.kind === ts.SyntaxKind.TrueKeyword ||\n node.kind === ts.SyntaxKind.FalseKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword ||\n node.kind === ts.SyntaxKind.UndefinedKeyword\n )\n // Note: object/array literals are NOT static — they need runtime application\n // (e.g., style={{ color: \"red\" }} requires Object.assign at runtime).\n}\n\n/** Known pure global functions that don't read signals. */\nconst PURE_CALLS = new Set([\n 'Math.max', 'Math.min', 'Math.abs', 'Math.floor', 'Math.ceil', 'Math.round',\n 'Math.pow', 'Math.sqrt', 'Math.random', 'Math.trunc', 'Math.sign',\n 'Number.parseInt', 'Number.parseFloat', 'Number.isNaN', 'Number.isFinite',\n 'parseInt', 'parseFloat', 'isNaN', 'isFinite',\n 'String.fromCharCode', 'String.fromCodePoint',\n 'Object.keys', 'Object.values', 'Object.entries', 'Object.assign',\n 'Object.freeze', 'Object.create',\n 'Array.from', 'Array.isArray', 'Array.of',\n 'JSON.stringify', 'JSON.parse',\n 'encodeURIComponent', 'decodeURIComponent', 'encodeURI', 'decodeURI',\n 'Date.now',\n])\n\n/** Check if a call expression calls a known pure function with static args. */\nfunction isPureStaticCall(node: ts.CallExpression): boolean {\n const callee = node.expression\n let name = ''\n\n if (ts.isIdentifier(callee)) {\n name = callee.text\n } else if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression)) {\n name = `${callee.expression.text}.${callee.name.text}`\n }\n\n if (!PURE_CALLS.has(name)) return false\n // Pure call with all static arguments → result is static\n return node.arguments.every((arg) => !ts.isSpreadElement(arg) && isStatic(arg))\n}\n\nfunction containsCall(node: ts.Node): boolean {\n if (ts.isCallExpression(node)) {\n // Skip pure calls with static args\n if (isPureStaticCall(node as ts.CallExpression)) return false\n return true\n }\n if (ts.isTaggedTemplateExpression(node)) return true\n // Don't recurse into nested functions — they're self-contained\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) return false\n return ts.forEachChild(node, containsCall) ?? false\n}\n","/**\n * Project scanner — extracts route, component, and island information from source files.\n */\n\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\n\nexport interface RouteInfo {\n path: string\n name?: string | undefined\n component?: string | undefined\n hasLoader: boolean\n hasGuard: boolean\n params: string[]\n}\n\nexport interface ComponentInfo {\n name: string\n file: string\n hasSignals: boolean\n signalNames: string[]\n props: string[]\n}\n\nexport interface IslandInfo {\n name: string\n file: string\n hydrate: string\n}\n\nexport interface ProjectContext {\n framework: 'pyreon'\n version: string\n generatedAt: string\n routes: RouteInfo[]\n components: ComponentInfo[]\n islands: IslandInfo[]\n}\n\nexport function generateContext(cwd: string): ProjectContext {\n const files = collectSourceFiles(cwd)\n const version = readVersion(cwd)\n\n return {\n framework: 'pyreon',\n version,\n generatedAt: new Date().toISOString(),\n routes: extractRoutes(files, cwd),\n components: extractComponents(files, cwd),\n islands: extractIslands(files, cwd),\n }\n}\n\nfunction collectSourceFiles(cwd: string): string[] {\n const results: string[] = []\n const extensions = new Set(['.tsx', '.jsx', '.ts', '.js'])\n const ignoreDirs = new Set(['node_modules', 'dist', 'lib', '.pyreon', '.git', 'build'])\n\n function walk(dir: string): void {\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.isDirectory()) continue\n if (ignoreDirs.has(entry.name) && entry.isDirectory()) continue\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n walk(fullPath)\n } else if (entry.isFile() && extensions.has(path.extname(entry.name))) {\n results.push(fullPath)\n }\n }\n }\n\n walk(cwd)\n return results\n}\n\nfunction extractRoutes(files: string[], _cwd: string): RouteInfo[] {\n const routes: RouteInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const routeArrayRe =\n /(?:createRouter\\s*\\(\\s*\\[|(?:const|let)\\s+routes\\s*(?::\\s*RouteRecord\\[\\])?\\s*=\\s*\\[)([\\s\\S]*?)\\]/g\n let match: RegExpExecArray | null\n for (match = routeArrayRe.exec(code); match; match = routeArrayRe.exec(code)) {\n const block = match[1] ?? ''\n const routeObjRe = /path\\s*:\\s*[\"']([^\"']+)[\"']/g\n let routeMatch: RegExpExecArray | null\n for (routeMatch = routeObjRe.exec(block); routeMatch; routeMatch = routeObjRe.exec(block)) {\n const routePath = routeMatch[1] ?? ''\n const surroundingStart = Math.max(0, routeMatch.index - 50)\n const surroundingEnd = Math.min(block.length, routeMatch.index + 200)\n const surrounding = block.slice(surroundingStart, surroundingEnd)\n\n routes.push({\n path: routePath,\n name: surrounding.match(/name\\s*:\\s*[\"']([^\"']+)[\"']/)?.[1],\n hasLoader: /loader\\s*:/.test(surrounding),\n hasGuard: /beforeEnter\\s*:|beforeLeave\\s*:/.test(surrounding),\n params: extractParams(routePath),\n })\n }\n }\n }\n\n return routes\n}\n\nfunction extractComponents(files: string[], cwd: string): ComponentInfo[] {\n const components: ComponentInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const componentRe =\n /(?:export\\s+)?(?:const|function)\\s+([A-Z]\\w*)\\s*(?::\\s*ComponentFn<[^>]+>\\s*)?=?\\s*\\(?(?:\\s*\\{?\\s*([^)]*?)\\s*\\}?\\s*)?\\)?\\s*(?:=>|{)/g\n let match: RegExpExecArray | null\n\n for (match = componentRe.exec(code); match; match = componentRe.exec(code)) {\n const name = match[1] ?? 'Unknown'\n const propsStr = match[2] ?? ''\n const props = propsStr\n .split(/[,;]/)\n .map((p) => p.trim().replace(/[{}]/g, '').trim().split(':')[0]?.split('=')[0]?.trim() ?? '')\n .filter((p) => p && p !== 'props')\n\n const bodyStart = match.index + match[0].length\n const body = code.slice(bodyStart, Math.min(code.length, bodyStart + 2000))\n const signalNames: string[] = []\n const signalRe = /(?:const|let)\\s+(\\w+)\\s*=\\s*signal\\s*[<(]/g\n let sigMatch: RegExpExecArray | null\n for (sigMatch = signalRe.exec(body); sigMatch; sigMatch = signalRe.exec(body)) {\n if (sigMatch[1]) signalNames.push(sigMatch[1])\n }\n\n components.push({\n name,\n file: path.relative(cwd, file),\n hasSignals: signalNames.length > 0,\n signalNames,\n props,\n })\n }\n }\n\n return components\n}\n\nfunction extractIslands(files: string[], cwd: string): IslandInfo[] {\n const islands: IslandInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const islandRe =\n /island\\s*\\(\\s*\\(\\)\\s*=>\\s*import\\(.+?\\)\\s*,\\s*\\{[^}]*name\\s*:\\s*[\"']([^\"']+)[\"'][^}]*?(?:hydrate\\s*:\\s*[\"']([^\"']+)[\"'])?[^}]*\\}/g\n let match: RegExpExecArray | null\n for (match = islandRe.exec(code); match; match = islandRe.exec(code)) {\n if (match[1]) {\n islands.push({\n name: match[1],\n file: path.relative(cwd, file),\n hydrate: match[2] ?? 'load',\n })\n }\n }\n }\n\n return islands\n}\n\nfunction extractParams(routePath: string): string[] {\n const params: string[] = []\n const paramRe = /:(\\w+)\\??/g\n let match: RegExpExecArray | null\n for (match = paramRe.exec(routePath); match; match = paramRe.exec(routePath)) {\n if (match[1]) params.push(match[1])\n }\n return params\n}\n\nfunction readVersion(cwd: string): string {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'))\n const deps: Record<string, unknown> = { ...pkg.dependencies, ...pkg.devDependencies }\n for (const [name, ver] of Object.entries(deps)) {\n if (name.startsWith('@pyreon/') && typeof ver === 'string') return ver.replace(/^[\\^~]/, '')\n }\n return (pkg.version as string) || 'unknown'\n } catch {\n return 'unknown'\n }\n}\n","/**\n * React Pattern Interceptor — detects React/Vue patterns in code and provides\n * structured diagnostics with exact fix suggestions for AI-assisted migration.\n *\n * Two modes:\n * - `detectReactPatterns(code)` — returns diagnostics only (non-destructive)\n * - `migrateReactCode(code)` — applies auto-fixes and returns transformed code\n *\n * Designed for three consumers:\n * 1. Compiler pre-pass (warnings during build)\n * 2. CLI `pyreon doctor` (project-wide scanning)\n * 3. MCP server `migrate_react` / `validate` tools (AI agent integration)\n */\n\nimport ts from 'typescript'\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════════\n\nexport type ReactDiagnosticCode =\n | 'react-import'\n | 'react-dom-import'\n | 'react-router-import'\n | 'use-state'\n | 'use-effect-mount'\n | 'use-effect-deps'\n | 'use-effect-no-deps'\n | 'use-memo'\n | 'use-callback'\n | 'use-ref-dom'\n | 'use-ref-box'\n | 'use-reducer'\n | 'use-layout-effect'\n | 'memo-wrapper'\n | 'forward-ref'\n | 'class-name-prop'\n | 'html-for-prop'\n | 'on-change-input'\n | 'dangerously-set-inner-html'\n | 'dot-value-signal'\n | 'array-map-jsx'\n | 'key-on-for-child'\n | 'create-context-import'\n | 'use-context-import'\n\nexport interface ReactDiagnostic {\n /** Machine-readable code for filtering and programmatic handling */\n code: ReactDiagnosticCode\n /** Human-readable message explaining the issue */\n message: string\n /** 1-based line number */\n line: number\n /** 0-based column */\n column: number\n /** The code as written */\n current: string\n /** The suggested Pyreon equivalent */\n suggested: string\n /** Whether migrateReactCode can auto-fix this */\n fixable: boolean\n}\n\nexport interface MigrationChange {\n type: 'replace' | 'remove' | 'add'\n line: number\n description: string\n}\n\nexport interface MigrationResult {\n /** Transformed source code */\n code: string\n /** All detected patterns (including unfixable ones) */\n diagnostics: ReactDiagnostic[]\n /** Description of changes applied */\n changes: MigrationChange[]\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// React Hook → Pyreon mapping\n// ═══════════════════════════════════════════════════════════════════════════════\n\ninterface HookMapping {\n pyreonFn: string\n pyreonImport: string\n description: string\n example: string\n}\n\nconst _REACT_HOOK_MAP: Record<string, HookMapping> = {\n useState: {\n pyreonFn: 'signal',\n pyreonImport: '@pyreon/reactivity',\n description: 'Signals are callable functions — read: count(), write: count.set(5)',\n example:\n 'const count = signal(0)\\n// Read: count() Write: count.set(5) Update: count.update(n => n + 1)',\n },\n useEffect: {\n pyreonFn: 'effect',\n pyreonImport: '@pyreon/reactivity',\n description: 'Effects auto-track signal dependencies — no dependency array needed',\n example: 'effect(() => {\\n console.log(count()) // auto-subscribes to count\\n})',\n },\n useLayoutEffect: {\n pyreonFn: 'effect',\n pyreonImport: '@pyreon/reactivity',\n description: 'Pyreon effects run synchronously after signal updates',\n example: 'effect(() => {\\n // runs sync after signal changes\\n})',\n },\n useMemo: {\n pyreonFn: 'computed',\n pyreonImport: '@pyreon/reactivity',\n description: 'Computed values auto-track dependencies and memoize',\n example: 'const doubled = computed(() => count() * 2)',\n },\n useCallback: {\n pyreonFn: '(plain function)',\n pyreonImport: '',\n description:\n 'Not needed — Pyreon components run once, so closures never go stale. Use a plain function',\n example: 'const handleClick = () => doSomething(count())',\n },\n useReducer: {\n pyreonFn: 'signal',\n pyreonImport: '@pyreon/reactivity',\n description: 'Use signal with update() for reducer-like patterns',\n example:\n 'const state = signal(initialState)\\nconst dispatch = (action) => state.update(s => reducer(s, action))',\n },\n}\n\n/** React import sources → Pyreon equivalents */\nconst IMPORT_REWRITES: Record<string, string | null> = {\n react: '@pyreon/core',\n 'react-dom': '@pyreon/runtime-dom',\n 'react-dom/client': '@pyreon/runtime-dom',\n 'react-dom/server': '@pyreon/runtime-server',\n 'react-router': '@pyreon/router',\n 'react-router-dom': '@pyreon/router',\n}\n\n/** React specifiers that map to specific Pyreon imports */\nconst SPECIFIER_REWRITES: Record<string, { name: string; from: string }> = {\n useState: { name: 'signal', from: '@pyreon/reactivity' },\n useEffect: { name: 'effect', from: '@pyreon/reactivity' },\n useLayoutEffect: { name: 'effect', from: '@pyreon/reactivity' },\n useMemo: { name: 'computed', from: '@pyreon/reactivity' },\n useReducer: { name: 'signal', from: '@pyreon/reactivity' },\n useRef: { name: 'signal', from: '@pyreon/reactivity' },\n createContext: { name: 'createContext', from: '@pyreon/core' },\n useContext: { name: 'useContext', from: '@pyreon/core' },\n Fragment: { name: 'Fragment', from: '@pyreon/core' },\n Suspense: { name: 'Suspense', from: '@pyreon/core' },\n lazy: { name: 'lazy', from: '@pyreon/core' },\n memo: { name: '', from: '' }, // removed, not needed\n forwardRef: { name: '', from: '' }, // removed, not needed\n createRoot: { name: 'mount', from: '@pyreon/runtime-dom' },\n hydrateRoot: { name: 'hydrateRoot', from: '@pyreon/runtime-dom' },\n // React Router\n useNavigate: { name: 'useRouter', from: '@pyreon/router' },\n useParams: { name: 'useRoute', from: '@pyreon/router' },\n useLocation: { name: 'useRoute', from: '@pyreon/router' },\n Link: { name: 'RouterLink', from: '@pyreon/router' },\n NavLink: { name: 'RouterLink', from: '@pyreon/router' },\n Outlet: { name: 'RouterView', from: '@pyreon/router' },\n useSearchParams: { name: 'useSearchParams', from: '@pyreon/router' },\n}\n\n/** JSX attribute rewrites (React → standard HTML) */\nconst JSX_ATTR_REWRITES: Record<string, string> = {\n className: 'class',\n htmlFor: 'for',\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Detection (diagnostic-only, no modifications)\n// ═══════════════════════════════════════════════════════════════════════════════\n\ninterface DetectContext {\n sf: ts.SourceFile\n code: string\n diagnostics: ReactDiagnostic[]\n reactImportedHooks: Set<string>\n}\n\nfunction detectGetNodeText(ctx: DetectContext, node: ts.Node): string {\n return ctx.code.slice(node.getStart(ctx.sf), node.getEnd())\n}\n\nfunction detectDiag(\n ctx: DetectContext,\n node: ts.Node,\n diagCode: ReactDiagnosticCode,\n message: string,\n current: string,\n suggested: string,\n fixable: boolean,\n): void {\n const { line, character } = ctx.sf.getLineAndCharacterOfPosition(node.getStart(ctx.sf))\n ctx.diagnostics.push({\n code: diagCode,\n message,\n line: line + 1,\n column: character,\n current: current.trim(),\n suggested: suggested.trim(),\n fixable,\n })\n}\n\nfunction detectImportDeclaration(ctx: DetectContext, node: ts.ImportDeclaration): void {\n if (!node.moduleSpecifier) return\n const source = (node.moduleSpecifier as ts.StringLiteral).text\n const pyreonSource = IMPORT_REWRITES[source]\n\n if (pyreonSource !== undefined) {\n if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const spec of node.importClause.namedBindings.elements) {\n ctx.reactImportedHooks.add(spec.name.text)\n }\n }\n\n const diagCode = source.startsWith('react-router')\n ? 'react-router-import'\n : source.startsWith('react-dom')\n ? 'react-dom-import'\n : 'react-import'\n\n detectDiag(\n ctx,\n node,\n diagCode,\n `Import from '${source}' is a React package. Use Pyreon equivalent.`,\n detectGetNodeText(ctx, node),\n pyreonSource\n ? `import { ... } from \"${pyreonSource}\"`\n : 'Remove this import — not needed in Pyreon',\n true,\n )\n }\n}\n\nfunction detectUseState(ctx: DetectContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (\n ts.isVariableDeclaration(parent) &&\n parent.name &&\n ts.isArrayBindingPattern(parent.name) &&\n parent.name.elements.length >= 1\n ) {\n const firstEl = parent.name.elements[0]\n const valueName =\n firstEl && ts.isBindingElement(firstEl) ? (firstEl.name as ts.Identifier).text : 'value'\n const initArg = node.arguments[0] ? detectGetNodeText(ctx, node.arguments[0]) : 'undefined'\n\n detectDiag(\n ctx,\n node,\n 'use-state',\n `useState is a React API. In Pyreon, use signal(). Read: ${valueName}(), Write: ${valueName}.set(x)`,\n detectGetNodeText(ctx, parent),\n `${valueName} = signal(${initArg})`,\n true,\n )\n } else {\n detectDiag(\n ctx,\n node,\n 'use-state',\n 'useState is a React API. In Pyreon, use signal().',\n detectGetNodeText(ctx, node),\n 'signal(initialValue)',\n true,\n )\n }\n}\n\nfunction callbackHasCleanup(callbackArg: ts.Expression): boolean {\n if (!ts.isArrowFunction(callbackArg) && !ts.isFunctionExpression(callbackArg)) return false\n const body = callbackArg.body\n if (!ts.isBlock(body)) return false\n for (const stmt of body.statements) {\n if (ts.isReturnStatement(stmt) && stmt.expression) return true\n }\n return false\n}\n\nfunction detectUseEffect(ctx: DetectContext, node: ts.CallExpression): void {\n const hookName = (node.expression as ts.Identifier).text\n const depsArg = node.arguments[1]\n const callbackArg = node.arguments[0]\n\n if (depsArg && ts.isArrayLiteralExpression(depsArg) && depsArg.elements.length === 0) {\n const hasCleanup = callbackArg ? callbackHasCleanup(callbackArg) : false\n\n detectDiag(\n ctx,\n node,\n 'use-effect-mount',\n `${hookName} with empty deps [] means \"run once on mount\". Use onMount() in Pyreon.`,\n detectGetNodeText(ctx, node),\n hasCleanup\n ? 'onMount(() => {\\n // setup...\\n return () => { /* cleanup */ }\\n})'\n : 'onMount(() => {\\n // setup...\\n})',\n true,\n )\n } else if (depsArg && ts.isArrayLiteralExpression(depsArg)) {\n detectDiag(\n ctx,\n node,\n 'use-effect-deps',\n `${hookName} with dependency array. In Pyreon, effect() auto-tracks dependencies — no array needed.`,\n detectGetNodeText(ctx, node),\n 'effect(() => {\\n // reads are auto-tracked\\n})',\n true,\n )\n } else if (!depsArg) {\n detectDiag(\n ctx,\n node,\n 'use-effect-no-deps',\n `${hookName} with no dependency array. In Pyreon, use effect() — it auto-tracks signal reads.`,\n detectGetNodeText(ctx, node),\n 'effect(() => {\\n // runs when accessed signals change\\n})',\n true,\n )\n }\n}\n\nfunction detectUseMemo(ctx: DetectContext, node: ts.CallExpression): void {\n const computeFn = node.arguments[0]\n const computeText = computeFn ? detectGetNodeText(ctx, computeFn) : '() => value'\n\n detectDiag(\n ctx,\n node,\n 'use-memo',\n 'useMemo is a React API. In Pyreon, use computed() — dependencies auto-tracked.',\n detectGetNodeText(ctx, node),\n `computed(${computeText})`,\n true,\n )\n}\n\nfunction detectUseCallback(ctx: DetectContext, node: ts.CallExpression): void {\n const callbackFn = node.arguments[0]\n const callbackText = callbackFn ? detectGetNodeText(ctx, callbackFn) : '() => {}'\n\n detectDiag(\n ctx,\n node,\n 'use-callback',\n 'useCallback is not needed in Pyreon. Components run once, so closures never go stale. Use a plain function.',\n detectGetNodeText(ctx, node),\n callbackText,\n true,\n )\n}\n\nfunction detectUseRef(ctx: DetectContext, node: ts.CallExpression): void {\n const arg = node.arguments[0]\n const isNullInit =\n arg &&\n (arg.kind === ts.SyntaxKind.NullKeyword || (ts.isIdentifier(arg) && arg.text === 'undefined'))\n\n if (isNullInit) {\n detectDiag(\n ctx,\n node,\n 'use-ref-dom',\n 'useRef(null) for DOM refs. In Pyreon, use createRef() from @pyreon/core.',\n detectGetNodeText(ctx, node),\n 'createRef()',\n true,\n )\n } else {\n const initText = arg ? detectGetNodeText(ctx, arg) : 'undefined'\n detectDiag(\n ctx,\n node,\n 'use-ref-box',\n 'useRef for mutable values. In Pyreon, use signal() — it works the same way but is reactive.',\n detectGetNodeText(ctx, node),\n `signal(${initText})`,\n true,\n )\n }\n}\n\nfunction detectUseReducer(ctx: DetectContext, node: ts.CallExpression): void {\n detectDiag(\n ctx,\n node,\n 'use-reducer',\n 'useReducer is a React API. In Pyreon, use signal() with update() for reducer patterns.',\n detectGetNodeText(ctx, node),\n 'const state = signal(initialState)\\nconst dispatch = (action) => state.update(s => reducer(s, action))',\n false,\n )\n}\n\nfunction isCallToReactDot(callee: ts.Expression, methodName: string): boolean {\n return (\n ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text === 'React' &&\n callee.name.text === methodName\n )\n}\n\nfunction detectMemoWrapper(ctx: DetectContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isMemo =\n (ts.isIdentifier(callee) && callee.text === 'memo') || isCallToReactDot(callee, 'memo')\n\n if (isMemo) {\n const inner = node.arguments[0]\n const innerText = inner ? detectGetNodeText(ctx, inner) : 'Component'\n\n detectDiag(\n ctx,\n node,\n 'memo-wrapper',\n 'memo() is not needed in Pyreon. Components run once — only signals trigger updates, not re-renders.',\n detectGetNodeText(ctx, node),\n innerText,\n true,\n )\n }\n}\n\nfunction detectForwardRef(ctx: DetectContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isForwardRef =\n (ts.isIdentifier(callee) && callee.text === 'forwardRef') ||\n isCallToReactDot(callee, 'forwardRef')\n\n if (isForwardRef) {\n detectDiag(\n ctx,\n node,\n 'forward-ref',\n 'forwardRef is not needed in Pyreon. Pass ref as a regular prop.',\n detectGetNodeText(ctx, node),\n '// Just pass ref as a prop:\\nconst MyInput = (props) => <input ref={props.ref} />',\n true,\n )\n }\n}\n\nfunction detectJsxAttributes(ctx: DetectContext, node: ts.JsxAttribute): void {\n const attrName = (node.name as ts.Identifier).text\n\n if (attrName in JSX_ATTR_REWRITES) {\n const htmlAttr = JSX_ATTR_REWRITES[attrName] as string\n detectDiag(\n ctx,\n node,\n attrName === 'className' ? 'class-name-prop' : 'html-for-prop',\n `'${attrName}' is a React JSX attribute. Use '${htmlAttr}' in Pyreon (standard HTML).`,\n detectGetNodeText(ctx, node),\n detectGetNodeText(ctx, node).replace(attrName, htmlAttr),\n true,\n )\n }\n\n if (attrName === 'onChange') {\n const jsxElement = findParentJsxElement(node)\n if (jsxElement) {\n const tagName = getJsxTagName(jsxElement)\n if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {\n detectDiag(\n ctx,\n node,\n 'on-change-input',\n `onChange on <${tagName}> fires on blur in Pyreon (native DOM behavior). For keypress-by-keypress updates, use onInput.`,\n detectGetNodeText(ctx, node),\n detectGetNodeText(ctx, node).replace('onChange', 'onInput'),\n true,\n )\n }\n }\n }\n\n if (attrName === 'dangerouslySetInnerHTML') {\n detectDiag(\n ctx,\n node,\n 'dangerously-set-inner-html',\n 'dangerouslySetInnerHTML is React-specific. Use innerHTML prop in Pyreon.',\n detectGetNodeText(ctx, node),\n 'innerHTML={htmlString}',\n true,\n )\n }\n}\n\nfunction detectDotValueSignal(ctx: DetectContext, node: ts.PropertyAccessExpression): void {\n const varName = (node.expression as ts.Identifier).text\n const parent = node.parent\n if (ts.isBinaryExpression(parent) && parent.left === node) {\n detectDiag(\n ctx,\n node,\n 'dot-value-signal',\n `'${varName}.value' looks like a Vue ref pattern. Pyreon signals are callable functions. Use ${varName}.set(x) to write.`,\n detectGetNodeText(ctx, parent),\n `${varName}.set(${detectGetNodeText(ctx, parent.right)})`,\n false,\n )\n }\n}\n\nfunction detectArrayMapJsx(ctx: DetectContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (ts.isJsxExpression(parent)) {\n const arrayExpr = detectGetNodeText(\n ctx,\n (node.expression as ts.PropertyAccessExpression).expression,\n )\n const mapCallback = node.arguments[0]\n const mapCallbackText = mapCallback\n ? detectGetNodeText(ctx, mapCallback)\n : 'item => <li>{item}</li>'\n\n detectDiag(\n ctx,\n node,\n 'array-map-jsx',\n 'Array.map() in JSX is not reactive in Pyreon. Use <For> for efficient keyed list rendering.',\n detectGetNodeText(ctx, node),\n `<For each={${arrayExpr}} by={item => item.id}>\\n {${mapCallbackText}}\\n</For>`,\n false,\n )\n }\n}\n\nfunction isCallToHook(node: ts.Node, hookName: string): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === hookName\n )\n}\n\nfunction isCallToEffectHook(node: ts.Node): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n (node.expression.text === 'useEffect' || node.expression.text === 'useLayoutEffect')\n )\n}\n\nfunction isMapCallExpression(node: ts.Node): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n ts.isIdentifier(node.expression.name) &&\n node.expression.name.text === 'map'\n )\n}\n\nfunction isDotValueAccess(node: ts.Node): node is ts.PropertyAccessExpression {\n return (\n ts.isPropertyAccessExpression(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === 'value' &&\n ts.isIdentifier(node.expression)\n )\n}\n\nfunction detectVisitNode(ctx: DetectContext, node: ts.Node): void {\n if (ts.isImportDeclaration(node)) detectImportDeclaration(ctx, node)\n if (isCallToHook(node, 'useState')) detectUseState(ctx, node)\n if (isCallToEffectHook(node)) detectUseEffect(ctx, node)\n if (isCallToHook(node, 'useMemo')) detectUseMemo(ctx, node)\n if (isCallToHook(node, 'useCallback')) detectUseCallback(ctx, node)\n if (isCallToHook(node, 'useRef')) detectUseRef(ctx, node)\n if (isCallToHook(node, 'useReducer')) detectUseReducer(ctx, node)\n if (ts.isCallExpression(node)) detectMemoWrapper(ctx, node)\n if (ts.isCallExpression(node)) detectForwardRef(ctx, node)\n if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) detectJsxAttributes(ctx, node)\n if (isDotValueAccess(node)) detectDotValueSignal(ctx, node)\n if (isMapCallExpression(node)) detectArrayMapJsx(ctx, node)\n}\n\nfunction detectVisit(ctx: DetectContext, node: ts.Node): void {\n ts.forEachChild(node, (child) => {\n detectVisitNode(ctx, child)\n detectVisit(ctx, child)\n })\n}\n\nexport function detectReactPatterns(code: string, filename = 'input.tsx'): ReactDiagnostic[] {\n const sf = ts.createSourceFile(filename, code, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TSX)\n const ctx: DetectContext = {\n sf,\n code,\n diagnostics: [],\n reactImportedHooks: new Set<string>(),\n }\n\n detectVisit(ctx, sf)\n return ctx.diagnostics\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Migration (detection + auto-fix)\n// ═══════════════════════════════════════════════════════════════════════════════\n\ntype Replacement = { start: number; end: number; text: string }\n\ninterface MigrateContext {\n sf: ts.SourceFile\n code: string\n replacements: Replacement[]\n changes: MigrationChange[]\n pyreonImports: Map<string, Set<string>>\n importsToRemove: Set<ts.ImportDeclaration>\n specifierRewrites: Map<ts.ImportSpecifier, { name: string; from: string }>\n}\n\nfunction migrateAddImport(ctx: MigrateContext, source: string, specifier: string): void {\n if (!source || !specifier) return\n let specs = ctx.pyreonImports.get(source)\n if (!specs) {\n specs = new Set()\n ctx.pyreonImports.set(source, specs)\n }\n specs.add(specifier)\n}\n\nfunction migrateReplace(ctx: MigrateContext, node: ts.Node, text: string): void {\n ctx.replacements.push({ start: node.getStart(ctx.sf), end: node.getEnd(), text })\n}\n\nfunction migrateGetNodeText(ctx: MigrateContext, node: ts.Node): string {\n return ctx.code.slice(node.getStart(ctx.sf), node.getEnd())\n}\n\nfunction migrateGetLine(ctx: MigrateContext, node: ts.Node): number {\n return ctx.sf.getLineAndCharacterOfPosition(node.getStart(ctx.sf)).line + 1\n}\n\nfunction migrateImportDeclaration(ctx: MigrateContext, node: ts.ImportDeclaration): void {\n if (!node.moduleSpecifier) return\n const source = (node.moduleSpecifier as ts.StringLiteral).text\n if (!(source in IMPORT_REWRITES)) return\n\n if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const spec of node.importClause.namedBindings.elements) {\n const name = spec.name.text\n const rewrite = SPECIFIER_REWRITES[name]\n if (rewrite) {\n if (rewrite.name) {\n migrateAddImport(ctx, rewrite.from, rewrite.name)\n }\n ctx.specifierRewrites.set(spec, rewrite)\n }\n }\n }\n ctx.importsToRemove.add(node)\n}\n\nfunction migrateUseState(ctx: MigrateContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (\n ts.isVariableDeclaration(parent) &&\n parent.name &&\n ts.isArrayBindingPattern(parent.name) &&\n parent.name.elements.length >= 1\n ) {\n const firstEl = parent.name.elements[0]\n const valueName =\n firstEl && ts.isBindingElement(firstEl) ? (firstEl.name as ts.Identifier).text : 'value'\n const initArg = node.arguments[0] ? migrateGetNodeText(ctx, node.arguments[0]) : 'undefined'\n\n const declStart = parent.getStart(ctx.sf)\n const declEnd = parent.getEnd()\n ctx.replacements.push({\n start: declStart,\n end: declEnd,\n text: `${valueName} = signal(${initArg})`,\n })\n migrateAddImport(ctx, '@pyreon/reactivity', 'signal')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `useState → signal: ${valueName}`,\n })\n }\n}\n\nfunction migrateUseEffect(ctx: MigrateContext, node: ts.CallExpression): void {\n const depsArg = node.arguments[1]\n const callbackArg = node.arguments[0]\n const hookName = (node.expression as ts.Identifier).text\n\n if (\n depsArg &&\n ts.isArrayLiteralExpression(depsArg) &&\n depsArg.elements.length === 0 &&\n callbackArg\n ) {\n const callbackText = migrateGetNodeText(ctx, callbackArg)\n migrateReplace(ctx, node, `onMount(${callbackText})`)\n migrateAddImport(ctx, '@pyreon/core', 'onMount')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${hookName}(fn, []) → onMount(fn)`,\n })\n } else if (callbackArg) {\n const callbackText = migrateGetNodeText(ctx, callbackArg)\n migrateReplace(ctx, node, `effect(${callbackText})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'effect')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${hookName} → effect (auto-tracks deps)`,\n })\n }\n}\n\nfunction migrateUseMemo(ctx: MigrateContext, node: ts.CallExpression): void {\n const computeFn = node.arguments[0]\n if (computeFn) {\n migrateReplace(ctx, node, `computed(${migrateGetNodeText(ctx, computeFn)})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'computed')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useMemo → computed (auto-tracks deps)',\n })\n }\n}\n\nfunction migrateUseCallback(ctx: MigrateContext, node: ts.CallExpression): void {\n const callbackFn = node.arguments[0]\n if (callbackFn) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, callbackFn))\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useCallback → plain function (not needed in Pyreon)',\n })\n }\n}\n\nfunction migrateUseRef(ctx: MigrateContext, node: ts.CallExpression): void {\n const arg = node.arguments[0]\n const isNullInit =\n arg &&\n (arg.kind === ts.SyntaxKind.NullKeyword || (ts.isIdentifier(arg) && arg.text === 'undefined'))\n\n if (isNullInit || !arg) {\n migrateReplace(ctx, node, 'createRef()')\n migrateAddImport(ctx, '@pyreon/core', 'createRef')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useRef(null) → createRef()',\n })\n } else {\n migrateReplace(ctx, node, `signal(${migrateGetNodeText(ctx, arg)})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'signal')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useRef(value) → signal(value)',\n })\n }\n}\n\nfunction migrateMemoWrapper(ctx: MigrateContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isMemo =\n (ts.isIdentifier(callee) && callee.text === 'memo') || isCallToReactDot(callee, 'memo')\n\n if (isMemo && node.arguments[0]) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, node.arguments[0]))\n ctx.changes.push({\n type: 'remove',\n line: migrateGetLine(ctx, node),\n description: 'Removed memo() wrapper (not needed in Pyreon)',\n })\n }\n}\n\nfunction migrateForwardRef(ctx: MigrateContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isForwardRef =\n (ts.isIdentifier(callee) && callee.text === 'forwardRef') ||\n isCallToReactDot(callee, 'forwardRef')\n\n if (isForwardRef && node.arguments[0]) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, node.arguments[0]))\n ctx.changes.push({\n type: 'remove',\n line: migrateGetLine(ctx, node),\n description: 'Removed forwardRef wrapper (pass ref as normal prop in Pyreon)',\n })\n }\n}\n\nfunction migrateJsxAttributes(ctx: MigrateContext, node: ts.JsxAttribute): void {\n const attrName = (node.name as ts.Identifier).text\n\n if (attrName in JSX_ATTR_REWRITES) {\n const htmlAttr = JSX_ATTR_REWRITES[attrName] as string\n ctx.replacements.push({\n start: node.name.getStart(ctx.sf),\n end: node.name.getEnd(),\n text: htmlAttr,\n })\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${attrName} → ${htmlAttr}`,\n })\n }\n\n if (attrName === 'onChange') {\n const jsxElement = findParentJsxElement(node)\n if (jsxElement) {\n const tagName = getJsxTagName(jsxElement)\n if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {\n ctx.replacements.push({\n start: node.name.getStart(ctx.sf),\n end: node.name.getEnd(),\n text: 'onInput',\n })\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `onChange on <${tagName}> → onInput (native DOM events)`,\n })\n }\n }\n }\n\n if (attrName === 'dangerouslySetInnerHTML') {\n migrateDangerouslySetInnerHTML(ctx, node)\n }\n}\n\nfunction migrateDangerouslySetInnerHTML(ctx: MigrateContext, node: ts.JsxAttribute): void {\n if (!node.initializer || !ts.isJsxExpression(node.initializer) || !node.initializer.expression) {\n return\n }\n const expr = node.initializer.expression\n if (!ts.isObjectLiteralExpression(expr)) return\n\n const htmlProp = expr.properties.find(\n (p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === '__html',\n ) as ts.PropertyAssignment | undefined\n\n if (htmlProp) {\n const valueText = migrateGetNodeText(ctx, htmlProp.initializer)\n migrateReplace(ctx, node, `innerHTML={${valueText}}`)\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'dangerouslySetInnerHTML → innerHTML',\n })\n }\n}\n\nfunction applyReplacements(code: string, ctx: MigrateContext): string {\n // Remove React import declarations\n for (const imp of ctx.importsToRemove) {\n ctx.replacements.push({ start: imp.getStart(ctx.sf), end: imp.getEnd(), text: '' })\n ctx.changes.push({\n type: 'remove',\n line: ctx.sf.getLineAndCharacterOfPosition(imp.getStart(ctx.sf)).line + 1,\n description: 'Removed React import',\n })\n }\n\n // Sort descending for dedup (outermost replacements win over inner overlapping ones)\n ctx.replacements.sort((a, b) => b.start - a.start)\n\n // Deduplicate overlapping replacements (keep the outermost / first added)\n const applied = new Set<string>()\n const deduped: Replacement[] = []\n for (const r of ctx.replacements) {\n const key = `${r.start}:${r.end}`\n let overlaps = false\n for (const d of deduped) {\n if (r.start < d.end && r.end > d.start) {\n overlaps = true\n break\n }\n }\n if (!overlaps && !applied.has(key)) {\n applied.add(key)\n deduped.push(r)\n }\n }\n\n // Re-sort ascending for string builder — O(n) single join\n deduped.sort((a, b) => a.start - b.start)\n const parts: string[] = []\n let lastPos = 0\n for (const r of deduped) {\n parts.push(code.slice(lastPos, r.start))\n parts.push(r.text)\n lastPos = r.end\n }\n parts.push(code.slice(lastPos))\n return parts.join('')\n}\n\nfunction insertPyreonImports(code: string, pyreonImports: Map<string, Set<string>>): string {\n if (pyreonImports.size === 0) return code\n\n const importLines: string[] = []\n const sorted = [...pyreonImports.entries()].sort(([a], [b]) => a.localeCompare(b))\n for (const [source, specs] of sorted) {\n const specList = [...specs].sort().join(', ')\n importLines.push(`import { ${specList} } from \"${source}\"`)\n }\n const importBlock = importLines.join('\\n')\n\n const lastImportEnd = findLastImportEnd(code)\n if (lastImportEnd > 0) {\n return `${code.slice(0, lastImportEnd)}\\n${importBlock}${code.slice(lastImportEnd)}`\n }\n return `${importBlock}\\n\\n${code}`\n}\n\nfunction migrateVisitNode(ctx: MigrateContext, node: ts.Node): void {\n if (ts.isImportDeclaration(node)) migrateImportDeclaration(ctx, node)\n if (isCallToHook(node, 'useState')) migrateUseState(ctx, node)\n if (isCallToEffectHook(node)) migrateUseEffect(ctx, node)\n if (isCallToHook(node, 'useMemo')) migrateUseMemo(ctx, node)\n if (isCallToHook(node, 'useCallback')) migrateUseCallback(ctx, node)\n if (isCallToHook(node, 'useRef')) migrateUseRef(ctx, node)\n if (ts.isCallExpression(node)) migrateMemoWrapper(ctx, node)\n if (ts.isCallExpression(node)) migrateForwardRef(ctx, node)\n if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) migrateJsxAttributes(ctx, node)\n}\n\nfunction migrateVisit(ctx: MigrateContext, node: ts.Node): void {\n ts.forEachChild(node, (child) => {\n migrateVisitNode(ctx, child)\n migrateVisit(ctx, child)\n })\n}\n\nexport function migrateReactCode(code: string, filename = 'input.tsx'): MigrationResult {\n const sf = ts.createSourceFile(filename, code, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TSX)\n const diagnostics = detectReactPatterns(code, filename)\n\n const ctx: MigrateContext = {\n sf,\n code,\n replacements: [],\n changes: [],\n pyreonImports: new Map(),\n importsToRemove: new Set(),\n specifierRewrites: new Map(),\n }\n\n migrateVisit(ctx, sf)\n\n let result = applyReplacements(code, ctx)\n result = insertPyreonImports(result, ctx.pyreonImports)\n\n // Clean up empty lines from removed imports\n result = result.replace(/\\n{3,}/g, '\\n\\n')\n\n return { code: result, diagnostics, changes: ctx.changes }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Helpers\n// ═══════════════════════════════════════════════════════════════════════════════\n\nfunction findParentJsxElement(\n node: ts.Node,\n): ts.JsxOpeningElement | ts.JsxSelfClosingElement | null {\n let current = node.parent\n while (current) {\n if (ts.isJsxOpeningElement(current) || ts.isJsxSelfClosingElement(current)) {\n return current\n }\n // Don't cross component boundaries\n if (ts.isJsxElement(current)) {\n return current.openingElement\n }\n if (ts.isArrowFunction(current) || ts.isFunctionExpression(current)) {\n return null\n }\n current = current.parent\n }\n return null\n}\n\nfunction getJsxTagName(node: ts.JsxOpeningElement | ts.JsxSelfClosingElement): string {\n const tagName = node.tagName\n if (ts.isIdentifier(tagName)) {\n return tagName.text\n }\n return ''\n}\n\nfunction findLastImportEnd(code: string): number {\n const importRe = /^import\\s.+$/gm\n let lastEnd = 0\n let match: RegExpExecArray | null\n while (true) {\n match = importRe.exec(code)\n if (!match) break\n lastEnd = match.index + match[0].length\n }\n return lastEnd\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Quick scan (regex-based, for fast pre-filtering)\n// ═══════════════════════════════════════════════════════════════════════════════\n\n/** Fast regex check — returns true if code likely contains React patterns worth analyzing */\nexport function hasReactPatterns(code: string): boolean {\n return (\n /\\bfrom\\s+['\"]react/.test(code) ||\n /\\bfrom\\s+['\"]react-dom/.test(code) ||\n /\\bfrom\\s+['\"]react-router/.test(code) ||\n /\\buseState\\s*[<(]/.test(code) ||\n /\\buseEffect\\s*\\(/.test(code) ||\n /\\buseMemo\\s*\\(/.test(code) ||\n /\\buseCallback\\s*\\(/.test(code) ||\n /\\buseRef\\s*[<(]/.test(code) ||\n /\\buseReducer\\s*[<(]/.test(code) ||\n /\\bReact\\.memo\\b/.test(code) ||\n /\\bforwardRef\\s*[<(]/.test(code) ||\n /\\bclassName[=\\s]/.test(code) ||\n /\\bhtmlFor[=\\s]/.test(code) ||\n /\\.value\\s*=/.test(code)\n )\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Error pattern database (for MCP diagnose tool)\n// ═══════════════════════════════════════════════════════════════════════════════\n\nexport interface ErrorDiagnosis {\n cause: string\n fix: string\n fixCode?: string | undefined\n related?: string | undefined\n}\n\ninterface ErrorPattern {\n pattern: RegExp\n diagnose: (match: RegExpMatchArray) => ErrorDiagnosis\n}\n\nconst ERROR_PATTERNS: ErrorPattern[] = [\n {\n pattern: /Cannot read properties of undefined \\(reading '(set|update|peek|subscribe)'\\)/,\n diagnose: (m) => ({\n cause: `Calling .${m[1]}() on undefined. The signal variable is likely out of scope, misspelled, or not yet initialized.`,\n fix: 'Check that the signal is defined and in scope. Signals must be created with signal() before use.',\n fixCode: `const mySignal = signal(initialValue)\\nmySignal.${m[1]}(newValue)`,\n }),\n },\n {\n pattern: /(\\w+) is not a function/,\n diagnose: (m) => ({\n cause: `'${m[1]}' is not callable. If this is a signal, you need to call it: ${m[1]}()`,\n fix: 'Pyreon signals are callable functions. Read: signal(), Write: signal.set(value)',\n fixCode: `// Read value:\\nconst value = ${m[1]}()\\n// Set value:\\n${m[1]}.set(newValue)`,\n }),\n },\n {\n pattern: /Cannot find module '(@pyreon\\/\\w[\\w-]*)'/,\n diagnose: (m) => ({\n cause: `Package ${m[1]} is not installed.`,\n fix: `Run: bun add ${m[1]}`,\n fixCode: `bun add ${m[1]}`,\n }),\n },\n {\n pattern: /Cannot find module 'react'/,\n diagnose: () => ({\n cause: \"Importing from 'react' in a Pyreon project.\",\n fix: 'Replace React imports with Pyreon equivalents.',\n fixCode:\n '// Instead of:\\nimport { useState } from \"react\"\\n// Use:\\nimport { signal } from \"@pyreon/reactivity\"',\n }),\n },\n {\n pattern: /Property '(\\w+)' does not exist on type 'Signal<\\w+>'/,\n diagnose: (m) => ({\n cause: `Accessing .${m[1]} on a signal. Pyreon signals don't have a .${m[1]} property.`,\n fix:\n m[1] === 'value'\n ? 'Pyreon signals are callable functions, not .value getters. Call signal() to read, signal.set() to write.'\n : `Signals have these methods: .set(), .update(), .peek(), .subscribe(). '${m[1]}' is not one of them.`,\n fixCode:\n m[1] === 'value' ? '// Read: mySignal()\\n// Write: mySignal.set(newValue)' : undefined,\n }),\n },\n {\n pattern: /Type '(\\w+)' is not assignable to type 'VNode'/,\n diagnose: (m) => ({\n cause: `Component returned ${m[1]} instead of VNode. Components must return JSX, null, or a string.`,\n fix: 'Make sure your component returns a JSX element, null, or a string.',\n fixCode: 'const MyComponent = (props) => {\\n return <div>{props.children}</div>\\n}',\n }),\n },\n {\n pattern: /onMount callback must return/,\n diagnose: () => ({\n cause: 'onMount expects a callback that optionally returns a CleanupFn.',\n fix: 'Return a cleanup function, or return nothing.',\n fixCode: 'onMount(() => {\\n // setup code\\n})',\n }),\n },\n {\n pattern: /Expected 'by' prop on <For>/,\n diagnose: () => ({\n cause: \"<For> requires a 'by' prop for efficient keyed reconciliation.\",\n fix: 'Add a by prop that returns a unique key for each item.',\n fixCode:\n '<For each={items()} by={item => item.id}>\\n {item => <li>{item.name}</li>}\\n</For>',\n }),\n },\n {\n pattern: /useHook.*outside.*component/i,\n diagnose: () => ({\n cause:\n 'Hook called outside a component function. Pyreon hooks must be called during component setup.',\n fix: 'Move the hook call inside a component function body.',\n }),\n },\n {\n pattern: /Hydration mismatch/,\n diagnose: () => ({\n cause: \"Server-rendered HTML doesn't match client-rendered output.\",\n fix: 'Ensure SSR and client render the same initial content. Check for browser-only APIs (window, document) in SSR code.',\n related: \"Use typeof window !== 'undefined' checks or onMount() for client-only code.\",\n }),\n },\n]\n\n/** Diagnose an error message and return structured fix information */\nexport function diagnoseError(error: string): ErrorDiagnosis | null {\n for (const { pattern, diagnose } of ERROR_PATTERNS) {\n const match = error.match(pattern)\n if (match) {\n return diagnose(match)\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,aAAa,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC;AAE1C,MAAM,WAAW;AAEjB,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,aAAa,MAAc,WAAW,aAA8B;CAClF,MAAM,aACJ,SAAS,SAAS,OAAO,IAAI,SAAS,SAAS,OAAO,GAAG,GAAG,WAAW,MAAM,GAAG,WAAW;CAE7F,MAAM,KAAK,GAAG,iBACZ,UACA,MACA,GAAG,aAAa,QACK,MACrB,WACD;CAGD,MAAM,eAA8B,EAAE;CACtC,MAAM,WAA8B,EAAE;CAEtC,SAAS,KAAK,MAAe,SAAiB,UAAyC;EACrF,MAAM,EAAE,MAAM,cAAc,GAAG,8BAA8B,KAAK,SAAS,GAAG,CAAC;AAC/E,WAAS,KAAK;GAAE;GAAS,MAAM,OAAO;GAAG,QAAQ;GAAW,MAAM;G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ClE,MAAK,MAAM,EAAE,SAAS,cAAc,gBAAgB;EAClD,MAAM,QAAQ,MAAM,MAAM,QAAQ;AAClC,MAAI,MACF,QAAO,SAAS,MAAM;;AAG1B,QAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/jsx.ts","../src/project-scanner.ts","../src/react-intercept.ts"],"sourcesContent":["/**\n * JSX transform — wraps dynamic JSX expressions in `() =>` so the Pyreon runtime\n * receives reactive getters instead of eagerly-evaluated snapshot values.\n *\n * Rules:\n * - `<div>{expr}</div>` → `<div>{() => expr}</div>` (child)\n * - `<div class={expr}>` → `<div class={() => expr}>` (prop)\n * - `<button onClick={fn}>` → unchanged (event handler)\n * - `<div>{() => expr}</div>` → unchanged (already wrapped)\n * - `<div>{\"literal\"}</div>` → unchanged (static)\n *\n * Static VNode hoisting:\n * - Fully static JSX in expression containers is hoisted to module scope:\n * `{<span>Hello</span>}` → `const _$h0 = <span>Hello</span>` + `{_$h0}`\n * - Hoisted nodes are created ONCE at module initialisation, not per-instance.\n * - A JSX node is static if: all props are string literals / booleans / static\n * values, and all children are text nodes or other static JSX nodes.\n *\n * Template emission:\n * - JSX element trees with ≥ 2 DOM elements (no components, no spread attrs)\n * are compiled to `_tpl(html, bindFn)` calls instead of nested `h()` calls.\n * - The HTML string is parsed once via <template>.innerHTML, then cloneNode(true)\n * for each instance (~5-10x faster than sequential createElement calls).\n * - Static attributes are baked into the HTML string; dynamic attributes and\n * text content use renderEffect in the bind function.\n *\n * Implementation: TypeScript parser for positions + magic-string replacements.\n * No extra runtime dependencies — `typescript` is already in devDependencies.\n *\n * Known limitation (v0): expressions inside *nested* JSX within a child\n * expression container are not individually wrapped. They are still reactive\n * because the outer wrapper re-evaluates the whole subtree, just at a coarser\n * granularity. Fine-grained nested wrapping is planned for a future pass.\n */\n\nimport ts from 'typescript'\n\nexport interface CompilerWarning {\n /** Warning message */\n message: string\n /** Source file line number (1-based) */\n line: number\n /** Source file column number (0-based) */\n column: number\n /** Warning code for filtering */\n code: 'signal-call-in-jsx' | 'missing-key-on-for' | 'signal-in-static-prop'\n}\n\nexport interface TransformResult {\n /** Transformed source code (JSX preserved, only expression containers modified) */\n code: string\n /** Whether the output uses _tpl/_re template helpers (needs auto-import) */\n usesTemplates?: boolean\n /** Compiler warnings for common mistakes */\n warnings: CompilerWarning[]\n}\n\n// Props that should never be wrapped in a reactive getter\nconst SKIP_PROPS = new Set(['key', 'ref'])\n// Event handler pattern: onClick, onInput, onMouseEnter, …\nconst EVENT_RE = /^on[A-Z]/\n// Events delegated to the container — must match runtime DELEGATED_EVENTS set\nconst DELEGATED_EVENTS = new Set([\n 'click',\n 'dblclick',\n 'contextmenu',\n 'focusin',\n 'focusout',\n 'input',\n 'change',\n 'keydown',\n 'keyup',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseover',\n 'mouseout',\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'pointerover',\n 'pointerout',\n 'touchstart',\n 'touchend',\n 'touchmove',\n 'submit',\n])\n\nexport function transformJSX(code: string, filename = 'input.tsx'): TransformResult {\n const scriptKind =\n filename.endsWith('.tsx') || filename.endsWith('.jsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TSX // default to TSX so JSX is always parsed\n\n const sf = ts.createSourceFile(\n filename,\n code,\n ts.ScriptTarget.ESNext,\n /* setParentNodes */ true,\n scriptKind,\n )\n\n type Replacement = { start: number; end: number; text: string }\n const replacements: Replacement[] = []\n const warnings: CompilerWarning[] = []\n\n function warn(node: ts.Node, message: string, warnCode: CompilerWarning['code']): void {\n const { line, character } = sf.getLineAndCharacterOfPosition(node.getStart(sf))\n warnings.push({ message, line: line + 1, column: character, code: warnCode })\n }\n\n // ── Static hoisting state ─────────────────────────────────────────────────\n type Hoist = { name: string; text: string }\n const hoists: Hoist[] = []\n let hoistIdx = 0\n let needsTplImport = false\n let needsRpImport = false\n let needsBindTextImportGlobal = false\n let needsBindDirectImportGlobal = false\n let needsBindImportGlobal = false\n let needsApplyPropsImportGlobal = false\n\n /**\n * If `node` is a fully-static JSX element/fragment, register a module-scope\n * hoist for it and return the generated variable name. Otherwise return null.\n */\n function maybeHoist(node: ts.Node): string | null {\n if (\n (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) &&\n isStaticJSXNode(node as ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment)\n ) {\n const name = `_$h${hoistIdx++}`\n const text = code.slice(node.getStart(sf), node.getEnd())\n hoists.push({ name, text })\n return name\n }\n return null\n }\n\n function wrap(expr: ts.Expression): void {\n const start = expr.getStart(sf)\n const end = expr.getEnd()\n replacements.push({ start, end, text: `() => ${sliceExpr(expr)}` })\n }\n\n /** Try to hoist or wrap an expression, pushing a replacement if needed. */\n function hoistOrWrap(expr: ts.Expression): void {\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n } else if (shouldWrap(expr)) {\n wrap(expr)\n }\n }\n\n // ── walk sub-handlers ───────────────────────────────────────────────────────\n\n /** Try to emit a template for a JsxElement. Returns true if handled. */\n function tryTemplateEmit(node: ts.JsxElement): boolean {\n const elemCount = templateElementCount(node, /* isRoot */ true)\n if (elemCount < 1) return false\n const tplCall = buildTemplateCall(node)\n if (!tplCall) return false\n const start = node.getStart(sf)\n const end = node.getEnd()\n const parent = node.parent\n const needsBraces = parent && (ts.isJsxElement(parent) || ts.isJsxFragment(parent))\n replacements.push({ start, end, text: needsBraces ? `{${tplCall}}` : tplCall })\n needsTplImport = true\n return true\n }\n\n /** Emit warnings for common JSX mistakes (e.g. <For> without by). */\n function checkForWarnings(node: ts.JsxElement | ts.JsxSelfClosingElement): void {\n const opening = ts.isJsxElement(node) ? node.openingElement : node\n const tagName = ts.isIdentifier(opening.tagName) ? opening.tagName.text : ''\n if (tagName !== 'For') return\n const hasBy = opening.attributes.properties.some(\n (p) => ts.isJsxAttribute(p) && ts.isIdentifier(p.name) && p.name.text === 'by',\n )\n if (!hasBy) {\n warn(\n opening.tagName,\n `<For> without a \"by\" prop will use index-based diffing, which is slower and may cause bugs with stateful children. Add by={(item) => item.id} for efficient keyed reconciliation.`,\n 'missing-key-on-for',\n )\n }\n }\n\n /** Handle a JSX attribute node — wrap or hoist its value if needed.\n *\n * Both DOM and component props are processed:\n * - DOM props: () => expr — applyProp creates renderEffect\n * - Component props: _rp(() => expr) — makeReactiveProps converts to getters\n *\n * The _rp() brand distinguishes compiler wrappers from user-written accessor\n * props (like Show's when, For's each) so makeReactiveProps only converts\n * compiler-emitted wrappers.\n */\n function handleJsxAttribute(node: ts.JsxAttribute): void {\n const name = ts.isIdentifier(node.name) ? node.name.text : ''\n if (SKIP_PROPS.has(name) || EVENT_RE.test(name)) return\n if (!node.initializer || !ts.isJsxExpression(node.initializer)) return\n const expr = node.initializer.expression\n if (!expr) return\n\n const openingEl = node.parent.parent as ts.JsxOpeningElement | ts.JsxSelfClosingElement\n const tagName = ts.isIdentifier(openingEl.tagName) ? openingEl.tagName.text : ''\n const isComponent = tagName.length > 0 && tagName.charAt(0) !== tagName.charAt(0).toLowerCase()\n\n if (isComponent) {\n // Component prop: wrap with _rp() brand so makeReactiveProps recognizes it.\n //\n // EXCEPTION: If the expression is a single JSX element (not a conditional),\n // do NOT wrap the outer expression. The JSX element is created once (stable VNode).\n // Its own inner props will be wrapped individually via recursive walk().\n // This prevents remounting: <Icon name={x()} /> stays one Icon instance,\n // only its name prop updates reactively.\n const isSingleJsx = ts.isJsxElement(expr) || ts.isJsxSelfClosingElement(expr)\n if (isSingleJsx) {\n // Don't wrap — recurse into the JSX element's attributes instead\n ts.forEachChild(expr, walk)\n return\n }\n\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n } else if (shouldWrap(expr)) {\n const start = expr.getStart(sf)\n const end = expr.getEnd()\n replacements.push({ start, end, text: `_rp(() => ${sliceExpr(expr)})` })\n needsRpImport = true\n }\n } else {\n // DOM prop: standard () => expr wrapping\n hoistOrWrap(expr)\n }\n }\n\n /** Handle a JSX expression in child position — wrap, hoist, or recurse. */\n function handleJsxExpression(node: ts.JsxExpression): void {\n const expr = node.expression\n if (!expr) return\n const hoistName = maybeHoist(expr)\n if (hoistName) {\n replacements.push({ start: expr.getStart(sf), end: expr.getEnd(), text: hoistName })\n return\n }\n if (shouldWrap(expr)) {\n wrap(expr)\n return\n }\n // Not hoisted, not wrapped (e.g., arrow function in For callback).\n // Recurse into the expression body to find nested JSX elements\n // that should be compiled to _tpl() calls.\n ts.forEachChild(expr, walk)\n }\n\n // ── Prop-derived variable tracking ─────────────────────────────────────────\n // Pre-pass: find variables derived from props/splitProps results inside\n // component functions. These are inlined at JSX use sites so the compiler's\n // existing wrapping makes them reactive.\n //\n // Example:\n // const align = props.alignX ?? 'left'\n // return <div class={align}> ← inlined to: class={props.alignX ?? 'left'}\n // ← compiler wraps: class={() => props.alignX ?? 'left'}\n\n /** Names that refer to the props object or splitProps results. */\n const propsNames = new Set<string>()\n\n /** Map of variable name → AST node of the original expression.\n * Using AST nodes instead of text avoids all string manipulation edge cases. */\n const propDerivedVars = new Map<string, ts.Expression>()\n\n /** Check if an expression reads from a tracked props-like object. */\n function readsFromProps(node: ts.Node): boolean {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {\n return propsNames.has(node.expression.text)\n }\n if (ts.isElementAccessExpression(node) && ts.isIdentifier(node.expression)) {\n return propsNames.has(node.expression.text)\n }\n // Check children recursively — e.g. props.x ?? 'default'\n let found = false\n ts.forEachChild(node, (child) => {\n if (found) return\n if (readsFromProps(child)) found = true\n })\n return found\n }\n\n /** Pre-pass: scan a function body for prop-derived variable declarations.\n * callbackDepth tracks nesting inside callback arguments (map, filter, etc.)\n * to avoid tracking variables declared inside callbacks as prop-derived. */\n let _callbackDepth = 0\n function scanForPropDerivedVars(node: ts.Node): void {\n // Track callback nesting — don't track vars inside callbacks\n if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node))) {\n const parent = node.parent\n if (parent && ts.isCallExpression(parent) && parent.arguments.includes(node as any)) {\n _callbackDepth++\n ts.forEachChild(node, scanForPropDerivedVars)\n _callbackDepth--\n return\n }\n }\n // Track the function's first parameter as a props name.\n // Only for COMPONENT functions — not callbacks like .map(item => <div>...)\n // Heuristic: component functions are named declarations, const assignments,\n // or export defaults — NOT inline arguments to calls like .map(), .filter().\n if ((ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node))\n && node.parameters.length > 0) {\n\n // Skip functions that are arguments to a call (map/filter callbacks)\n const parent = node.parent\n if (parent && ts.isCallExpression(parent) && parent.arguments.includes(node as any)) {\n ts.forEachChild(node, scanForPropDerivedVars)\n return\n }\n\n const firstParam = node.parameters[0]!\n if (ts.isIdentifier(firstParam.name)) {\n // Check if this function returns JSX (is a component)\n let hasJSX = false\n ts.forEachChild(node, function checkJSX(n) {\n if (hasJSX) return\n if (ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n)) {\n hasJSX = true\n return\n }\n ts.forEachChild(n, checkJSX)\n })\n if (hasJSX) propsNames.add(firstParam.name.text)\n }\n }\n\n // Track splitProps results: const [own, rest] = splitProps(props, [...])\n if (ts.isVariableStatement(node)) {\n for (const decl of node.declarationList.declarations) {\n if (ts.isArrayBindingPattern(decl.name) && decl.initializer\n && ts.isCallExpression(decl.initializer)) {\n const callee = decl.initializer.expression\n if (ts.isIdentifier(callee) && callee.text === 'splitProps') {\n for (const el of decl.name.elements) {\n if (ts.isBindingElement(el) && ts.isIdentifier(el.name)) {\n propsNames.add(el.name.text)\n }\n }\n }\n }\n\n // Track: const x = props.y ?? z OR const x = own.y\n // Skip let/var — mutable variables can be reassigned, unsafe to inline\n // Skip declarations inside callbacks (map, filter, etc.)\n if (!(node.declarationList.flags & ts.NodeFlags.Const)) continue\n if (_callbackDepth > 0) continue\n if (ts.isIdentifier(decl.name) && decl.initializer) {\n if (readsFromProps(decl.initializer)) {\n propDerivedVars.set(decl.name.text, decl.initializer)\n }\n }\n }\n }\n\n ts.forEachChild(node, scanForPropDerivedVars)\n }\n\n // Run pre-pass\n scanForPropDerivedVars(sf)\n\n // Transitive resolution: if const b = a + 1 where a is prop-derived,\n // then b is also prop-derived. Store its AST node.\n // Fixed-point iteration until no new variables are added.\n let changed = true\n while (changed) {\n changed = false\n sf.forEachChild(function scanTransitive(node) {\n if (!ts.isVariableStatement(node)) { ts.forEachChild(node, scanTransitive); return }\n for (const decl of node.declarationList.declarations) {\n if (!ts.isIdentifier(decl.name) || !decl.initializer) continue\n const varName = decl.name.text\n if (propDerivedVars.has(varName)) continue\n if (node.declarationList.flags & ts.NodeFlags.Let) continue\n let usesPropVar = false\n ts.forEachChild(decl.initializer, function check(n) {\n if (usesPropVar) return\n if (ts.isIdentifier(n) && propDerivedVars.has(n.text)) {\n const parent = n.parent\n if (parent && ts.isPropertyAccessExpression(parent) && parent.name === n) return\n usesPropVar = true\n }\n ts.forEachChild(n, check)\n })\n if (usesPropVar) {\n propDerivedVars.set(varName, decl.initializer)\n changed = true\n }\n }\n })\n }\n\n // Resolve transitive AST: for each prop-derived var, recursively replace\n // references to other prop-derived vars in its AST with their resolved nodes.\n // Uses ts.visitNode for correct AST transformation — no string manipulation.\n function resolveExprTransitive(node: ts.Expression, excludeVar?: string): ts.Expression {\n return ts.visitNode(node, function visit(n: ts.Node): ts.Node {\n if (ts.isIdentifier(n) && propDerivedVars.has(n.text) && n.text !== excludeVar) {\n const parent = n.parent\n // Skip property name after dot: obj.sizes\n if (parent && ts.isPropertyAccessExpression(parent) && parent.name === n) {\n return n\n }\n // Skip JSX attribute name: sizes={...}\n if (parent && ts.isJsxAttribute(parent) && parent.name === n) {\n return n\n }\n // Skip shorthand property assignment: { sizes }\n if (parent && ts.isShorthandPropertyAssignment(parent)) {\n return n\n }\n const resolved = propDerivedVars.get(n.text)!\n return ts.factory.createParenthesizedExpression(\n resolveExprTransitive(resolved, n.text),\n )\n }\n return ts.visitEachChild(n, visit, undefined as any)\n }) as ts.Expression\n }\n\n /** Print an AST expression back to source text. */\n const printer = ts.createPrinter({ removeComments: false })\n\n /**\n * Enhanced dynamic check — combines containsCall with props awareness.\n * Returns true if an expression is reactive (contains signal calls,\n * accesses props members, or references prop-derived variables).\n */\n function isDynamic(node: ts.Node): boolean {\n if (containsCall(node)) return true\n return accessesProps(node)\n }\n\n /** Check if an expression accesses a tracked props object or a prop-derived variable. */\n function accessesProps(node: ts.Node): boolean {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {\n if (propsNames.has(node.expression.text)) return true\n }\n if (ts.isIdentifier(node) && propDerivedVars.has(node.text)) {\n const parent = node.parent\n if (parent && ts.isPropertyAccessExpression(parent) && parent.name === node) return false\n return true\n }\n let found = false\n ts.forEachChild(node, (child) => {\n if (found) return\n if (ts.isArrowFunction(child) || ts.isFunctionExpression(child)) return\n if (accessesProps(child)) found = true\n })\n return found\n }\n\n function shouldWrap(node: ts.Expression): boolean {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) return false\n if (isStatic(node)) return false\n if (ts.isCallExpression(node) && isPureStaticCall(node)) return false\n return isDynamic(node)\n }\n\n function walk(node: ts.Node): void {\n if (ts.isJsxElement(node) && tryTemplateEmit(node)) return\n if (ts.isJsxSelfClosingElement(node) || ts.isJsxElement(node)) checkForWarnings(node)\n if (ts.isJsxAttribute(node)) {\n handleJsxAttribute(node)\n return\n }\n if (ts.isJsxExpression(node)) {\n handleJsxExpression(node)\n return\n }\n ts.forEachChild(node, walk)\n }\n\n walk(sf)\n\n if (replacements.length === 0 && hoists.length === 0) return { code, warnings }\n\n // Apply replacements left-to-right via string builder — O(n) single join\n replacements.sort((a, b) => a.start - b.start)\n\n const parts: string[] = []\n let lastPos = 0\n for (const r of replacements) {\n parts.push(code.slice(lastPos, r.start))\n parts.push(r.text)\n lastPos = r.end\n }\n parts.push(code.slice(lastPos))\n let result = parts.join('')\n\n // Prepend module-scope hoisted static VNode declarations\n if (hoists.length > 0) {\n const preamble = hoists.map((h) => `const ${h.name} = /*@__PURE__*/ ${h.text}\\n`).join('')\n result = preamble + result\n }\n\n // Prepend template imports if _tpl() was emitted\n if (needsTplImport) {\n const runtimeDomImports = ['_tpl']\n if (needsBindDirectImportGlobal) runtimeDomImports.push('_bindDirect')\n if (needsBindTextImportGlobal) runtimeDomImports.push('_bindText')\n if (needsApplyPropsImportGlobal) runtimeDomImports.push('_applyProps')\n const reactivityImports = needsBindImportGlobal\n ? `\\nimport { _bind } from \"@pyreon/reactivity\";`\n : ''\n result =\n `import { ${runtimeDomImports.join(', ')} } from \"@pyreon/runtime-dom\";${reactivityImports}\\n` +\n result\n }\n\n // Prepend _rp import if reactive component props were emitted\n if (needsRpImport) {\n result = `import { _rp } from \"@pyreon/core\";\\n` + result\n }\n\n return { code: result, usesTemplates: needsTplImport, warnings }\n\n // ── Template emission helpers (closures over sf, code) ──────────────────────\n\n /**\n * Check if attributes prevent template emission.\n * - `key` always bails (VNode reconciliation prop)\n * - Spread on inner elements bails (too complex to merge in _bind)\n * - Spread on root element is allowed — applied via applyProps in _bind\n */\n function hasBailAttr(node: ts.JsxElement | ts.JsxSelfClosingElement, isRoot = false): boolean {\n for (const attr of jsxAttrs(node)) {\n if (ts.isJsxSpreadAttribute(attr)) {\n // Allow spread on root element — handled in buildTemplateCall\n if (isRoot) continue\n return true\n }\n if (ts.isJsxAttribute(attr) && ts.isIdentifier(attr.name) && attr.name.text === 'key')\n return true\n }\n return false\n }\n\n /**\n * Count template-eligible elements for a single JSX child.\n * Returns 0 for skippable children, -1 for bail, positive for element count.\n */\n function countChildForTemplate(child: ts.JsxChild): number {\n if (ts.isJsxText(child)) return 0\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child))\n return templateElementCount(child)\n if (ts.isJsxExpression(child)) {\n if (!child.expression) return 0\n return containsJSXInExpr(child.expression) ? -1 : 0\n }\n if (ts.isJsxFragment(child)) return templateFragmentCount(child)\n return -1\n }\n\n /**\n * Count DOM elements in a JSX subtree. Returns -1 if the tree is not\n * eligible for template emission.\n */\n function templateElementCount(\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n isRoot = false,\n ): number {\n const tag = jsxTagName(node)\n if (!tag || !isLowerCase(tag)) return -1\n if (hasBailAttr(node, isRoot)) return -1\n if (!ts.isJsxElement(node)) return 1\n\n let count = 1\n for (const child of node.children) {\n const c = countChildForTemplate(child)\n if (c === -1) return -1\n count += c\n }\n return count\n }\n\n /** Count template-eligible elements inside a fragment. */\n function templateFragmentCount(frag: ts.JsxFragment): number {\n let count = 0\n for (const child of frag.children) {\n const c = countChildForTemplate(child)\n if (c === -1) return -1\n count += c\n }\n return count\n }\n\n /**\n * Build the complete `_tpl(\"html\", (__root) => { ... })` call string\n * for a template-eligible JSX element tree. Returns null if codegen fails.\n */\n function buildTemplateCall(node: ts.JsxElement | ts.JsxSelfClosingElement): string | null {\n const bindLines: string[] = []\n const disposerNames: string[] = []\n let varIdx = 0\n let dispIdx = 0\n // Reactive expressions that will be combined into a single _bind call\n const reactiveBindExprs: string[] = []\n let needsBindTextImport = false\n let needsBindDirectImport = false\n let needsApplyPropsImport = false\n\n function nextVar(): string {\n return `__e${varIdx++}`\n }\n function nextDisp(): string {\n const name = `__d${dispIdx++}`\n disposerNames.push(name)\n return name\n }\n function nextTextVar(): string {\n return `__t${varIdx++}`\n }\n\n /** Resolve the variable name for an element given its accessor path. */\n function resolveElementVar(accessor: string, hasDynamic: boolean): string {\n if (accessor === '__root') return '__root'\n if (hasDynamic) {\n const v = nextVar()\n bindLines.push(`const ${v} = ${accessor}`)\n return v\n }\n return accessor\n }\n\n /** Emit bind line for a ref attribute. */\n function emitRef(attr: ts.JsxAttribute, varName: string): void {\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return\n if (!attr.initializer.expression) return\n bindLines.push(`${sliceExpr(attr.initializer.expression)}.current = ${varName}`)\n }\n\n /** Emit event handler bind line — delegated (expando) or addEventListener. */\n function emitEventListener(attr: ts.JsxAttribute, attrName: string, varName: string): void {\n const eventName = (attrName[2] ?? '').toLowerCase() + attrName.slice(3)\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return\n if (!attr.initializer.expression) return\n const handler = sliceExpr(attr.initializer.expression)\n if (DELEGATED_EVENTS.has(eventName)) {\n // Delegated: store handler as expando property — container listener picks it up\n bindLines.push(`${varName}.__ev_${eventName} = ${handler}`)\n } else {\n bindLines.push(`${varName}.addEventListener(\"${eventName}\", ${handler})`)\n }\n }\n\n /** Return HTML string for a static attribute expression, or null if not static. */\n function staticAttrToHtml(exprNode: ts.Expression, htmlAttrName: string): string | null {\n if (!isStatic(exprNode)) return null\n if (ts.isStringLiteral(exprNode)) return ` ${htmlAttrName}=\"${escapeHtmlAttr(exprNode.text)}\"`\n if (ts.isNumericLiteral(exprNode)) return ` ${htmlAttrName}=\"${exprNode.text}\"`\n if (exprNode.kind === ts.SyntaxKind.TrueKeyword) return ` ${htmlAttrName}`\n return '' // false/null/undefined → omit\n }\n\n /**\n * Try to extract a direct signal reference from an expression.\n * Returns the callee text (e.g. \"count\" or \"row.label\") if the expression\n * is a single call with no arguments, otherwise null.\n */\n function tryDirectSignalRef(exprNode: ts.Expression): string | null {\n let inner = exprNode\n // Unwrap concise arrow: () => expr\n if (ts.isArrowFunction(inner) && !ts.isBlock(inner.body)) {\n inner = inner.body as ts.Expression\n }\n if (!ts.isCallExpression(inner)) return null\n if (inner.arguments.length > 0) return null\n const callee = inner.expression\n // Only match simple identifiers: count() → _bindText(count, node)\n // Property access like obj.method() is NOT safe — detaching the method\n // loses `this` context (e.g. value.toLocaleString becomes unbound).\n if (ts.isIdentifier(callee)) {\n return sliceExpr(callee)\n }\n return null\n }\n\n /** Unwrap a reactive accessor expression for use inside _bind(). */\n function unwrapAccessor(exprNode: ts.Expression): { expr: string; isReactive: boolean } {\n // Concise arrow: () => value() → unwrap to \"value()\"\n if (ts.isArrowFunction(exprNode) && !ts.isBlock(exprNode.body)) {\n return { expr: sliceExpr(exprNode.body as ts.Expression), isReactive: true }\n }\n // Block-body arrow/function: invoke it\n if (ts.isArrowFunction(exprNode) || ts.isFunctionExpression(exprNode)) {\n return { expr: `(${sliceExpr(exprNode)})()`, isReactive: true }\n }\n return { expr: sliceExpr(exprNode), isReactive: isDynamic(exprNode) }\n }\n\n /** Build a setter expression for an attribute. */\n function attrSetter(htmlAttrName: string, varName: string, expr: string): string {\n if (htmlAttrName === 'class') return `${varName}.className = ${expr}`\n if (htmlAttrName === 'style') return `${varName}.style.cssText = ${expr}`\n return `${varName}.setAttribute(\"${htmlAttrName}\", ${expr})`\n }\n\n /** Emit bind line for a dynamic (non-static) attribute. */\n function emitDynamicAttr(\n _expr: string,\n exprNode: ts.Expression,\n htmlAttrName: string,\n varName: string,\n ): void {\n const { expr, isReactive } = unwrapAccessor(exprNode)\n\n if (!isReactive) {\n bindLines.push(attrSetter(htmlAttrName, varName, expr))\n return\n }\n\n // Direct signal binding for bare signal calls (e.g. class={() => active()})\n const directRef = tryDirectSignalRef(exprNode)\n if (directRef) {\n needsBindDirectImport = true\n const d = nextDisp()\n const updater =\n htmlAttrName === 'class'\n ? `(v) => { ${varName}.className = v == null ? \"\" : String(v) }`\n : htmlAttrName === 'style'\n ? `(v) => { if (typeof v === \"string\") ${varName}.style.cssText = v; else if (v) Object.assign(${varName}.style, v) }`\n : `(v) => { ${varName}.setAttribute(\"${htmlAttrName}\", v == null ? \"\" : String(v)) }`\n bindLines.push(`const ${d} = _bindDirect(${directRef}, ${updater})`)\n return\n }\n\n reactiveBindExprs.push(attrSetter(htmlAttrName, varName, expr))\n }\n\n /** Emit bind line or HTML for an expression attribute value. */\n function emitAttrExpression(\n exprNode: ts.Expression,\n htmlAttrName: string,\n varName: string,\n ): string {\n const staticHtml = staticAttrToHtml(exprNode, htmlAttrName)\n if (staticHtml !== null) return staticHtml\n\n // style={{...}} → Object.assign(el.style, {...}) for object expressions\n if (htmlAttrName === 'style' && ts.isObjectLiteralExpression(exprNode)) {\n bindLines.push(`Object.assign(${varName}.style, ${sliceExpr(exprNode)})`)\n return ''\n }\n\n emitDynamicAttr(sliceExpr(exprNode), exprNode, htmlAttrName, varName)\n return ''\n }\n\n /** Emit side-effects for special attrs (ref, event). Returns true if handled. */\n function tryEmitSpecialAttr(attr: ts.JsxAttribute, attrName: string, varName: string): boolean {\n if (attrName === 'ref') {\n emitRef(attr, varName)\n return true\n }\n if (EVENT_RE.test(attrName)) {\n emitEventListener(attr, attrName, varName)\n return true\n }\n return false\n }\n\n /** Convert an attribute initializer to HTML. Returns empty string for side-effect-only attrs. */\n function attrInitializerToHtml(\n attr: ts.JsxAttribute,\n htmlAttrName: string,\n varName: string,\n ): string {\n if (!attr.initializer) return ` ${htmlAttrName}`\n if (ts.isStringLiteral(attr.initializer))\n return ` ${htmlAttrName}=\"${escapeHtmlAttr(attr.initializer.text)}\"`\n if (ts.isJsxExpression(attr.initializer) && attr.initializer.expression)\n return emitAttrExpression(attr.initializer.expression, htmlAttrName, varName)\n return ''\n }\n\n /** Process a single attribute, returning HTML to append. */\n function processOneAttr(attr: ts.JsxAttributeLike, varName: string): string {\n // Spread attribute: apply all props at runtime\n if (ts.isJsxSpreadAttribute(attr)) {\n const expr = sliceExpr(attr.expression)\n // Use runtime-dom's applyProps which handles class, style, events, etc.\n needsApplyPropsImport = true\n if (isDynamic(attr.expression)) {\n reactiveBindExprs.push(`_applyProps(${varName}, ${expr})`)\n } else {\n bindLines.push(`_applyProps(${varName}, ${expr})`)\n }\n return ''\n }\n if (!ts.isJsxAttribute(attr)) return ''\n const attrName = ts.isIdentifier(attr.name) ? attr.name.text : ''\n if (attrName === 'key') return ''\n if (tryEmitSpecialAttr(attr, attrName, varName)) return ''\n return attrInitializerToHtml(attr, JSX_TO_HTML_ATTR[attrName] ?? attrName, varName)\n }\n\n /** Process all attributes on an element, returning the HTML attribute string. */\n function processAttrs(el: ts.JsxElement | ts.JsxSelfClosingElement, varName: string): string {\n let htmlAttrs = ''\n for (const attr of jsxAttrs(el)) htmlAttrs += processOneAttr(attr, varName)\n return htmlAttrs\n }\n\n /** Emit bind lines for a reactive text expression child. */\n function emitReactiveTextChild(\n expr: string,\n exprNode: ts.Expression,\n varName: string,\n parentRef: string,\n childNodeIdx: number,\n needsPlaceholder: boolean,\n ): string {\n const tVar = nextTextVar()\n bindLines.push(`const ${tVar} = document.createTextNode(\"\")`)\n if (needsPlaceholder) {\n bindLines.push(\n `${parentRef}.replaceChild(${tVar}, ${parentRef}.childNodes[${childNodeIdx}])`,\n )\n } else {\n bindLines.push(`${varName}.appendChild(${tVar})`)\n }\n // Direct signal binding: bypass effect system entirely\n const directRef = tryDirectSignalRef(exprNode)\n if (directRef) {\n needsBindTextImport = true\n const d = nextDisp()\n bindLines.push(`const ${d} = _bindText(${directRef}, ${tVar})`)\n } else {\n // Each reactive text child gets its own _bind — independent tracking.\n // When r.name() changes, r.email()'s _bind doesn't re-run.\n needsBindImportGlobal = true\n const d = nextDisp()\n bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${expr} })`)\n }\n return needsPlaceholder ? '<!>' : ''\n }\n\n /** Emit bind lines for a static text expression child. */\n function emitStaticTextChild(\n expr: string,\n varName: string,\n parentRef: string,\n childNodeIdx: number,\n needsPlaceholder: boolean,\n ): string {\n if (needsPlaceholder) {\n const tVar = nextTextVar()\n bindLines.push(`const ${tVar} = document.createTextNode(${expr})`)\n bindLines.push(\n `${parentRef}.replaceChild(${tVar}, ${parentRef}.childNodes[${childNodeIdx}])`,\n )\n return '<!>'\n }\n bindLines.push(`${varName}.textContent = ${expr}`)\n return ''\n }\n\n /** Process a single flat child, returning the HTML contribution or null on failure. */\n function processOneChild(\n child: FlatChild,\n varName: string,\n parentRef: string,\n useMixed: boolean,\n useMultiExpr: boolean,\n childNodeIdx: number,\n ): string | null {\n if (child.kind === 'text') return escapeHtmlText(child.text)\n if (child.kind === 'element') {\n const childAccessor = useMixed\n ? `${parentRef}.childNodes[${childNodeIdx}]`\n : `${parentRef}.children[${child.elemIdx}]`\n return processElement(child.node, childAccessor)\n }\n // expression\n const needsPlaceholder = useMixed || useMultiExpr\n const { expr, isReactive } = unwrapAccessor(child.expression)\n if (isReactive) {\n return emitReactiveTextChild(\n expr,\n child.expression,\n varName,\n parentRef,\n childNodeIdx,\n needsPlaceholder,\n )\n }\n return emitStaticTextChild(expr, varName, parentRef, childNodeIdx, needsPlaceholder)\n }\n\n /** Process children of a JsxElement, returning the children HTML. */\n function processChildren(el: ts.JsxElement, varName: string, accessor: string): string | null {\n const flatChildren = flattenChildren(el.children)\n const { useMixed, useMultiExpr } = analyzeChildren(flatChildren)\n const parentRef = accessor === '__root' ? '__root' : varName\n\n let html = ''\n let childNodeIdx = 0\n\n for (const child of flatChildren) {\n const childHtml = processOneChild(\n child,\n varName,\n parentRef,\n useMixed,\n useMultiExpr,\n childNodeIdx,\n )\n if (childHtml === null) return null\n html += childHtml\n childNodeIdx++\n }\n\n return html\n }\n\n /** Process a single DOM element for template emission. Returns the HTML string or null. */\n function processElement(\n el: ts.JsxElement | ts.JsxSelfClosingElement,\n accessor: string,\n ): string | null {\n const tag = jsxTagName(el)\n if (!tag) return null\n\n const varName = resolveElementVar(accessor, elementHasDynamic(el))\n const htmlAttrs = processAttrs(el, varName)\n let html = `<${tag}${htmlAttrs}>`\n\n if (ts.isJsxElement(el)) {\n const childHtml = processChildren(el, varName, accessor)\n if (childHtml === null) return null\n html += childHtml\n }\n\n if (!VOID_ELEMENTS.has(tag)) html += `</${tag}>`\n return html\n }\n\n const html = processElement(node, '__root')\n if (html === null) return null\n\n if (needsBindTextImport) needsBindTextImportGlobal = true\n if (needsBindDirectImport) needsBindDirectImportGlobal = true\n if (needsApplyPropsImport) needsApplyPropsImportGlobal = true\n\n // Build bind function body\n const escaped = html.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n\n // Emit combined _bind for reactive attribute/text expressions that\n // weren't handled by _bindText. This merges N separate _bind calls into\n // one — saving N-1 closures + deps arrays per template instance.\n // Emit a single combined _bind for all reactive attribute/text expressions\n // that weren't handled by _bindText. Merges N separate _bind calls into one —\n // saving N-1 closures + deps arrays per template instance.\n if (reactiveBindExprs.length > 0) {\n needsBindImportGlobal = true\n const combinedName = nextDisp()\n const combinedBody = reactiveBindExprs.join('; ')\n bindLines.push(`const ${combinedName} = _bind(() => { ${combinedBody} })`)\n }\n\n if (bindLines.length === 0 && disposerNames.length === 0) {\n return `_tpl(\"${escaped}\", () => null)`\n }\n\n let body = bindLines.map((l) => ` ${l}`).join('\\n')\n if (disposerNames.length > 0) {\n body += `\\n return () => { ${disposerNames.map((d) => `${d}()`).join('; ')} }`\n } else {\n body += '\\n return null'\n }\n\n return `_tpl(\"${escaped}\", (__root) => {\\n${body}\\n})`\n }\n\n /** Flat child descriptor for template children processing */\n type FlatChild =\n | { kind: 'text'; text: string }\n | { kind: 'element'; node: ts.JsxElement | ts.JsxSelfClosingElement; elemIdx: number }\n | { kind: 'expression'; expression: ts.Expression }\n\n /** Classify a single JSX child into a FlatChild descriptor. */\n function classifyJsxChild(\n child: ts.JsxChild,\n out: FlatChild[],\n elemIdxRef: { value: number },\n recurse: (kids: ts.NodeArray<ts.JsxChild>) => void,\n ): void {\n if (ts.isJsxText(child)) {\n const trimmed = child.text.replace(/\\n\\s*/g, '').trim()\n if (trimmed) out.push({ kind: 'text', text: trimmed })\n return\n }\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {\n out.push({ kind: 'element', node: child, elemIdx: elemIdxRef.value++ })\n return\n }\n if (ts.isJsxExpression(child)) {\n if (child.expression) out.push({ kind: 'expression', expression: child.expression })\n return\n }\n if (ts.isJsxFragment(child)) recurse(child.children)\n }\n\n /**\n * Flatten JSX children, inlining fragment children and stripping whitespace-only text.\n * Returns a flat array of child descriptors with element indices pre-computed.\n */\n function flattenChildren(children: ts.NodeArray<ts.JsxChild>): FlatChild[] {\n const flatList: FlatChild[] = []\n const elemIdxRef = { value: 0 }\n\n function addChildren(kids: ts.NodeArray<ts.JsxChild>): void {\n for (const child of kids) classifyJsxChild(child, flatList, elemIdxRef, addChildren)\n }\n\n addChildren(children)\n return flatList\n }\n\n /** Analyze flat children to determine indexing strategy. */\n function analyzeChildren(flatChildren: FlatChild[]): {\n useMixed: boolean\n useMultiExpr: boolean\n } {\n const hasElem = flatChildren.some((c) => c.kind === 'element')\n const hasNonElem = flatChildren.some((c) => c.kind !== 'element')\n const exprCount = flatChildren.filter((c) => c.kind === 'expression').length\n return { useMixed: hasElem && hasNonElem, useMultiExpr: exprCount > 1 }\n }\n\n /** Check if a single attribute is dynamic (has ref, event, or non-static expression). */\n function attrIsDynamic(attr: ts.JsxAttributeLike): boolean {\n if (!ts.isJsxAttribute(attr)) return false\n const name = ts.isIdentifier(attr.name) ? attr.name.text : ''\n if (name === 'ref') return true\n if (EVENT_RE.test(name)) return true\n if (!attr.initializer || !ts.isJsxExpression(attr.initializer)) return false\n const expr = attr.initializer.expression\n return expr ? !isStatic(expr) : false\n }\n\n /** Check if an element has any dynamic attributes, events, ref, or expression children */\n function elementHasDynamic(node: ts.JsxElement | ts.JsxSelfClosingElement): boolean {\n if (jsxAttrs(node).some(attrIsDynamic)) return true\n if (ts.isJsxElement(node)) {\n return node.children.some((c) => ts.isJsxExpression(c) && c.expression !== undefined)\n }\n return false\n }\n\n /** Slice expression source from the original code.\n * Resolves any prop-derived identifiers found anywhere in the expression\n * via AST transformation — handles template literals, ternaries, etc. */\n function sliceExpr(expr: ts.Expression): string {\n // Quick check: does this expression contain any prop-derived references?\n if (propDerivedVars.size > 0 && accessesProps(expr)) {\n const resolved = resolveExprTransitive(expr)\n return printer.printNode(ts.EmitHint.Expression, resolved, sf)\n }\n return code.slice(expr.getStart(sf), expr.getEnd())\n }\n\n /** Get tag name string */\n function jsxTagName(node: ts.JsxElement | ts.JsxSelfClosingElement): string {\n const tag = ts.isJsxElement(node) ? node.openingElement.tagName : node.tagName\n return ts.isIdentifier(tag) ? tag.text : ''\n }\n\n /** Get attribute list */\n function jsxAttrs(\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n ): ts.NodeArray<ts.JsxAttributeLike> {\n return ts.isJsxElement(node)\n ? node.openingElement.attributes.properties\n : node.attributes.properties\n }\n}\n\n// ─── Template constants ──────────────────────────────────────────────────────\n\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n])\n\nconst JSX_TO_HTML_ATTR: Record<string, string> = {\n className: 'class',\n htmlFor: 'for',\n}\n\nfunction isLowerCase(s: string): boolean {\n return s.length > 0 && s[0] === s[0]?.toLowerCase()\n}\n\n/** Check if an expression subtree contains JSX nodes */\nfunction containsJSXInExpr(node: ts.Node): boolean {\n if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node))\n return true\n return ts.forEachChild(node, containsJSXInExpr) ?? false\n}\n\nfunction escapeHtmlAttr(s: string): string {\n return s.replace(/&/g, '&amp;').replace(/\"/g, '&quot;')\n}\n\nfunction escapeHtmlText(s: string): string {\n return s.replace(/&/g, '&amp;').replace(/</g, '&lt;')\n}\n\n// ─── Static JSX analysis ──────────────────────────────────────────────────────\n\ntype StaticJSXNode = ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment\n\nfunction isStaticJSXNode(node: StaticJSXNode): boolean {\n if (ts.isJsxSelfClosingElement(node)) {\n return isStaticAttrs(node.attributes)\n }\n if (ts.isJsxFragment(node)) {\n return node.children.every(isStaticChild)\n }\n // JsxElement\n return isStaticAttrs(node.openingElement.attributes) && node.children.every(isStaticChild)\n}\n\nfunction isStaticAttrs(attrs: ts.JsxAttributes): boolean {\n return attrs.properties.every((prop) => {\n // Spread attribute — always dynamic\n if (!ts.isJsxAttribute(prop)) return false\n // Boolean shorthand: <input disabled />\n if (!prop.initializer) return true\n // String literal: class=\"foo\"\n if (ts.isStringLiteral(prop.initializer)) return true\n // Must be JsxExpression — the only remaining JsxAttributeValue type\n const expr = (prop.initializer as ts.JsxExpression).expression\n return expr ? isStatic(expr) : true\n })\n}\n\nfunction isStaticChild(child: ts.JsxChild): boolean {\n // Plain text content\n if (ts.isJsxText(child)) return true\n // Nested JSX elements\n if (ts.isJsxSelfClosingElement(child)) return isStaticJSXNode(child)\n if (ts.isJsxElement(child)) return isStaticJSXNode(child)\n if (ts.isJsxFragment(child)) return isStaticJSXNode(child)\n // Must be JsxExpression — the only remaining JsxChild type\n const expr = (child as ts.JsxExpression).expression\n return expr ? isStatic(expr) : true\n}\n\n// ─── General helpers ──────────────────────────────────────────────────────────\n\nfunction isStatic(node: ts.Expression): boolean {\n return (\n ts.isStringLiteral(node) ||\n ts.isNumericLiteral(node) ||\n ts.isNoSubstitutionTemplateLiteral(node) ||\n node.kind === ts.SyntaxKind.TrueKeyword ||\n node.kind === ts.SyntaxKind.FalseKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword ||\n node.kind === ts.SyntaxKind.UndefinedKeyword\n )\n // Note: object/array literals are NOT static — they need runtime application\n // (e.g., style={{ color: \"red\" }} requires Object.assign at runtime).\n}\n\n/** Known pure global functions that don't read signals. */\nconst PURE_CALLS = new Set([\n 'Math.max', 'Math.min', 'Math.abs', 'Math.floor', 'Math.ceil', 'Math.round',\n 'Math.pow', 'Math.sqrt', 'Math.random', 'Math.trunc', 'Math.sign',\n 'Number.parseInt', 'Number.parseFloat', 'Number.isNaN', 'Number.isFinite',\n 'parseInt', 'parseFloat', 'isNaN', 'isFinite',\n 'String.fromCharCode', 'String.fromCodePoint',\n 'Object.keys', 'Object.values', 'Object.entries', 'Object.assign',\n 'Object.freeze', 'Object.create',\n 'Array.from', 'Array.isArray', 'Array.of',\n 'JSON.stringify', 'JSON.parse',\n 'encodeURIComponent', 'decodeURIComponent', 'encodeURI', 'decodeURI',\n 'Date.now',\n])\n\n/** Check if a call expression calls a known pure function with static args. */\nfunction isPureStaticCall(node: ts.CallExpression): boolean {\n const callee = node.expression\n let name = ''\n\n if (ts.isIdentifier(callee)) {\n name = callee.text\n } else if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression)) {\n name = `${callee.expression.text}.${callee.name.text}`\n }\n\n if (!PURE_CALLS.has(name)) return false\n // Pure call with all static arguments → result is static\n return node.arguments.every((arg) => !ts.isSpreadElement(arg) && isStatic(arg))\n}\n\nfunction containsCall(node: ts.Node): boolean {\n if (ts.isCallExpression(node)) {\n // Skip pure calls with static args\n if (isPureStaticCall(node as ts.CallExpression)) return false\n return true\n }\n if (ts.isTaggedTemplateExpression(node)) return true\n // Don't recurse into nested functions — they're self-contained\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) return false\n return ts.forEachChild(node, containsCall) ?? false\n}\n","/**\n * Project scanner — extracts route, component, and island information from source files.\n */\n\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\n\nexport interface RouteInfo {\n path: string\n name?: string | undefined\n component?: string | undefined\n hasLoader: boolean\n hasGuard: boolean\n params: string[]\n}\n\nexport interface ComponentInfo {\n name: string\n file: string\n hasSignals: boolean\n signalNames: string[]\n props: string[]\n}\n\nexport interface IslandInfo {\n name: string\n file: string\n hydrate: string\n}\n\nexport interface ProjectContext {\n framework: 'pyreon'\n version: string\n generatedAt: string\n routes: RouteInfo[]\n components: ComponentInfo[]\n islands: IslandInfo[]\n}\n\nexport function generateContext(cwd: string): ProjectContext {\n const files = collectSourceFiles(cwd)\n const version = readVersion(cwd)\n\n return {\n framework: 'pyreon',\n version,\n generatedAt: new Date().toISOString(),\n routes: extractRoutes(files, cwd),\n components: extractComponents(files, cwd),\n islands: extractIslands(files, cwd),\n }\n}\n\nfunction collectSourceFiles(cwd: string): string[] {\n const results: string[] = []\n const extensions = new Set(['.tsx', '.jsx', '.ts', '.js'])\n const ignoreDirs = new Set(['node_modules', 'dist', 'lib', '.pyreon', '.git', 'build'])\n\n function walk(dir: string): void {\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n if (entry.name.startsWith('.') && entry.isDirectory()) continue\n if (ignoreDirs.has(entry.name) && entry.isDirectory()) continue\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n walk(fullPath)\n } else if (entry.isFile() && extensions.has(path.extname(entry.name))) {\n results.push(fullPath)\n }\n }\n }\n\n walk(cwd)\n return results\n}\n\nfunction extractRoutes(files: string[], _cwd: string): RouteInfo[] {\n const routes: RouteInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const routeArrayRe =\n /(?:createRouter\\s*\\(\\s*\\[|(?:const|let)\\s+routes\\s*(?::\\s*RouteRecord\\[\\])?\\s*=\\s*\\[)([\\s\\S]*?)\\]/g\n let match: RegExpExecArray | null\n for (match = routeArrayRe.exec(code); match; match = routeArrayRe.exec(code)) {\n const block = match[1] ?? ''\n const routeObjRe = /path\\s*:\\s*[\"']([^\"']+)[\"']/g\n let routeMatch: RegExpExecArray | null\n for (routeMatch = routeObjRe.exec(block); routeMatch; routeMatch = routeObjRe.exec(block)) {\n const routePath = routeMatch[1] ?? ''\n const surroundingStart = Math.max(0, routeMatch.index - 50)\n const surroundingEnd = Math.min(block.length, routeMatch.index + 200)\n const surrounding = block.slice(surroundingStart, surroundingEnd)\n\n routes.push({\n path: routePath,\n name: surrounding.match(/name\\s*:\\s*[\"']([^\"']+)[\"']/)?.[1],\n hasLoader: /loader\\s*:/.test(surrounding),\n hasGuard: /beforeEnter\\s*:|beforeLeave\\s*:/.test(surrounding),\n params: extractParams(routePath),\n })\n }\n }\n }\n\n return routes\n}\n\nfunction extractComponents(files: string[], cwd: string): ComponentInfo[] {\n const components: ComponentInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const componentRe =\n /(?:export\\s+)?(?:const|function)\\s+([A-Z]\\w*)\\s*(?::\\s*ComponentFn<[^>]+>\\s*)?=?\\s*\\(?(?:\\s*\\{?\\s*([^)]*?)\\s*\\}?\\s*)?\\)?\\s*(?:=>|{)/g\n let match: RegExpExecArray | null\n\n for (match = componentRe.exec(code); match; match = componentRe.exec(code)) {\n const name = match[1] ?? 'Unknown'\n const propsStr = match[2] ?? ''\n const props = propsStr\n .split(/[,;]/)\n .map((p) => p.trim().replace(/[{}]/g, '').trim().split(':')[0]?.split('=')[0]?.trim() ?? '')\n .filter((p) => p && p !== 'props')\n\n const bodyStart = match.index + match[0].length\n const body = code.slice(bodyStart, Math.min(code.length, bodyStart + 2000))\n const signalNames: string[] = []\n const signalRe = /(?:const|let)\\s+(\\w+)\\s*=\\s*signal\\s*[<(]/g\n let sigMatch: RegExpExecArray | null\n for (sigMatch = signalRe.exec(body); sigMatch; sigMatch = signalRe.exec(body)) {\n if (sigMatch[1]) signalNames.push(sigMatch[1])\n }\n\n components.push({\n name,\n file: path.relative(cwd, file),\n hasSignals: signalNames.length > 0,\n signalNames,\n props,\n })\n }\n }\n\n return components\n}\n\nfunction extractIslands(files: string[], cwd: string): IslandInfo[] {\n const islands: IslandInfo[] = []\n\n for (const file of files) {\n let code: string\n try {\n code = fs.readFileSync(file, 'utf-8')\n } catch {\n continue\n }\n\n const islandRe =\n /island\\s*\\(\\s*\\(\\)\\s*=>\\s*import\\(.+?\\)\\s*,\\s*\\{[^}]*name\\s*:\\s*[\"']([^\"']+)[\"'][^}]*?(?:hydrate\\s*:\\s*[\"']([^\"']+)[\"'])?[^}]*\\}/g\n let match: RegExpExecArray | null\n for (match = islandRe.exec(code); match; match = islandRe.exec(code)) {\n if (match[1]) {\n islands.push({\n name: match[1],\n file: path.relative(cwd, file),\n hydrate: match[2] ?? 'load',\n })\n }\n }\n }\n\n return islands\n}\n\nfunction extractParams(routePath: string): string[] {\n const params: string[] = []\n const paramRe = /:(\\w+)\\??/g\n let match: RegExpExecArray | null\n for (match = paramRe.exec(routePath); match; match = paramRe.exec(routePath)) {\n if (match[1]) params.push(match[1])\n }\n return params\n}\n\nfunction readVersion(cwd: string): string {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'))\n const deps: Record<string, unknown> = { ...pkg.dependencies, ...pkg.devDependencies }\n for (const [name, ver] of Object.entries(deps)) {\n if (name.startsWith('@pyreon/') && typeof ver === 'string') return ver.replace(/^[\\^~]/, '')\n }\n return (pkg.version as string) || 'unknown'\n } catch {\n return 'unknown'\n }\n}\n","/**\n * React Pattern Interceptor — detects React/Vue patterns in code and provides\n * structured diagnostics with exact fix suggestions for AI-assisted migration.\n *\n * Two modes:\n * - `detectReactPatterns(code)` — returns diagnostics only (non-destructive)\n * - `migrateReactCode(code)` — applies auto-fixes and returns transformed code\n *\n * Designed for three consumers:\n * 1. Compiler pre-pass (warnings during build)\n * 2. CLI `pyreon doctor` (project-wide scanning)\n * 3. MCP server `migrate_react` / `validate` tools (AI agent integration)\n */\n\nimport ts from 'typescript'\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════════\n\nexport type ReactDiagnosticCode =\n | 'react-import'\n | 'react-dom-import'\n | 'react-router-import'\n | 'use-state'\n | 'use-effect-mount'\n | 'use-effect-deps'\n | 'use-effect-no-deps'\n | 'use-memo'\n | 'use-callback'\n | 'use-ref-dom'\n | 'use-ref-box'\n | 'use-reducer'\n | 'use-layout-effect'\n | 'memo-wrapper'\n | 'forward-ref'\n | 'class-name-prop'\n | 'html-for-prop'\n | 'on-change-input'\n | 'dangerously-set-inner-html'\n | 'dot-value-signal'\n | 'array-map-jsx'\n | 'key-on-for-child'\n | 'create-context-import'\n | 'use-context-import'\n\nexport interface ReactDiagnostic {\n /** Machine-readable code for filtering and programmatic handling */\n code: ReactDiagnosticCode\n /** Human-readable message explaining the issue */\n message: string\n /** 1-based line number */\n line: number\n /** 0-based column */\n column: number\n /** The code as written */\n current: string\n /** The suggested Pyreon equivalent */\n suggested: string\n /** Whether migrateReactCode can auto-fix this */\n fixable: boolean\n}\n\nexport interface MigrationChange {\n type: 'replace' | 'remove' | 'add'\n line: number\n description: string\n}\n\nexport interface MigrationResult {\n /** Transformed source code */\n code: string\n /** All detected patterns (including unfixable ones) */\n diagnostics: ReactDiagnostic[]\n /** Description of changes applied */\n changes: MigrationChange[]\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// React Hook → Pyreon mapping\n// ═══════════════════════════════════════════════════════════════════════════════\n\ninterface HookMapping {\n pyreonFn: string\n pyreonImport: string\n description: string\n example: string\n}\n\nconst _REACT_HOOK_MAP: Record<string, HookMapping> = {\n useState: {\n pyreonFn: 'signal',\n pyreonImport: '@pyreon/reactivity',\n description: 'Signals are callable functions — read: count(), write: count.set(5)',\n example:\n 'const count = signal(0)\\n// Read: count() Write: count.set(5) Update: count.update(n => n + 1)',\n },\n useEffect: {\n pyreonFn: 'effect',\n pyreonImport: '@pyreon/reactivity',\n description: 'Effects auto-track signal dependencies — no dependency array needed',\n example: 'effect(() => {\\n console.log(count()) // auto-subscribes to count\\n})',\n },\n useLayoutEffect: {\n pyreonFn: 'effect',\n pyreonImport: '@pyreon/reactivity',\n description: 'Pyreon effects run synchronously after signal updates',\n example: 'effect(() => {\\n // runs sync after signal changes\\n})',\n },\n useMemo: {\n pyreonFn: 'computed',\n pyreonImport: '@pyreon/reactivity',\n description: 'Computed values auto-track dependencies and memoize',\n example: 'const doubled = computed(() => count() * 2)',\n },\n useCallback: {\n pyreonFn: '(plain function)',\n pyreonImport: '',\n description:\n 'Not needed — Pyreon components run once, so closures never go stale. Use a plain function',\n example: 'const handleClick = () => doSomething(count())',\n },\n useReducer: {\n pyreonFn: 'signal',\n pyreonImport: '@pyreon/reactivity',\n description: 'Use signal with update() for reducer-like patterns',\n example:\n 'const state = signal(initialState)\\nconst dispatch = (action) => state.update(s => reducer(s, action))',\n },\n}\n\n/** React import sources → Pyreon equivalents */\nconst IMPORT_REWRITES: Record<string, string | null> = {\n react: '@pyreon/core',\n 'react-dom': '@pyreon/runtime-dom',\n 'react-dom/client': '@pyreon/runtime-dom',\n 'react-dom/server': '@pyreon/runtime-server',\n 'react-router': '@pyreon/router',\n 'react-router-dom': '@pyreon/router',\n}\n\n/** React specifiers that map to specific Pyreon imports */\nconst SPECIFIER_REWRITES: Record<string, { name: string; from: string }> = {\n useState: { name: 'signal', from: '@pyreon/reactivity' },\n useEffect: { name: 'effect', from: '@pyreon/reactivity' },\n useLayoutEffect: { name: 'effect', from: '@pyreon/reactivity' },\n useMemo: { name: 'computed', from: '@pyreon/reactivity' },\n useReducer: { name: 'signal', from: '@pyreon/reactivity' },\n useRef: { name: 'signal', from: '@pyreon/reactivity' },\n createContext: { name: 'createContext', from: '@pyreon/core' },\n useContext: { name: 'useContext', from: '@pyreon/core' },\n Fragment: { name: 'Fragment', from: '@pyreon/core' },\n Suspense: { name: 'Suspense', from: '@pyreon/core' },\n lazy: { name: 'lazy', from: '@pyreon/core' },\n memo: { name: '', from: '' }, // removed, not needed\n forwardRef: { name: '', from: '' }, // removed, not needed\n createRoot: { name: 'mount', from: '@pyreon/runtime-dom' },\n hydrateRoot: { name: 'hydrateRoot', from: '@pyreon/runtime-dom' },\n // React Router\n useNavigate: { name: 'useRouter', from: '@pyreon/router' },\n useParams: { name: 'useRoute', from: '@pyreon/router' },\n useLocation: { name: 'useRoute', from: '@pyreon/router' },\n Link: { name: 'RouterLink', from: '@pyreon/router' },\n NavLink: { name: 'RouterLink', from: '@pyreon/router' },\n Outlet: { name: 'RouterView', from: '@pyreon/router' },\n useSearchParams: { name: 'useSearchParams', from: '@pyreon/router' },\n}\n\n/** JSX attribute rewrites (React → standard HTML) */\nconst JSX_ATTR_REWRITES: Record<string, string> = {\n className: 'class',\n htmlFor: 'for',\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Detection (diagnostic-only, no modifications)\n// ═══════════════════════════════════════════════════════════════════════════════\n\ninterface DetectContext {\n sf: ts.SourceFile\n code: string\n diagnostics: ReactDiagnostic[]\n reactImportedHooks: Set<string>\n}\n\nfunction detectGetNodeText(ctx: DetectContext, node: ts.Node): string {\n return ctx.code.slice(node.getStart(ctx.sf), node.getEnd())\n}\n\nfunction detectDiag(\n ctx: DetectContext,\n node: ts.Node,\n diagCode: ReactDiagnosticCode,\n message: string,\n current: string,\n suggested: string,\n fixable: boolean,\n): void {\n const { line, character } = ctx.sf.getLineAndCharacterOfPosition(node.getStart(ctx.sf))\n ctx.diagnostics.push({\n code: diagCode,\n message,\n line: line + 1,\n column: character,\n current: current.trim(),\n suggested: suggested.trim(),\n fixable,\n })\n}\n\nfunction detectImportDeclaration(ctx: DetectContext, node: ts.ImportDeclaration): void {\n if (!node.moduleSpecifier) return\n const source = (node.moduleSpecifier as ts.StringLiteral).text\n const pyreonSource = IMPORT_REWRITES[source]\n\n if (pyreonSource !== undefined) {\n if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const spec of node.importClause.namedBindings.elements) {\n ctx.reactImportedHooks.add(spec.name.text)\n }\n }\n\n const diagCode = source.startsWith('react-router')\n ? 'react-router-import'\n : source.startsWith('react-dom')\n ? 'react-dom-import'\n : 'react-import'\n\n detectDiag(\n ctx,\n node,\n diagCode,\n `Import from '${source}' is a React package. Use Pyreon equivalent.`,\n detectGetNodeText(ctx, node),\n pyreonSource\n ? `import { ... } from \"${pyreonSource}\"`\n : 'Remove this import — not needed in Pyreon',\n true,\n )\n }\n}\n\nfunction detectUseState(ctx: DetectContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (\n ts.isVariableDeclaration(parent) &&\n parent.name &&\n ts.isArrayBindingPattern(parent.name) &&\n parent.name.elements.length >= 1\n ) {\n const firstEl = parent.name.elements[0]\n const valueName =\n firstEl && ts.isBindingElement(firstEl) ? (firstEl.name as ts.Identifier).text : 'value'\n const initArg = node.arguments[0] ? detectGetNodeText(ctx, node.arguments[0]) : 'undefined'\n\n detectDiag(\n ctx,\n node,\n 'use-state',\n `useState is a React API. In Pyreon, use signal(). Read: ${valueName}(), Write: ${valueName}.set(x)`,\n detectGetNodeText(ctx, parent),\n `${valueName} = signal(${initArg})`,\n true,\n )\n } else {\n detectDiag(\n ctx,\n node,\n 'use-state',\n 'useState is a React API. In Pyreon, use signal().',\n detectGetNodeText(ctx, node),\n 'signal(initialValue)',\n true,\n )\n }\n}\n\nfunction callbackHasCleanup(callbackArg: ts.Expression): boolean {\n if (!ts.isArrowFunction(callbackArg) && !ts.isFunctionExpression(callbackArg)) return false\n const body = callbackArg.body\n if (!ts.isBlock(body)) return false\n for (const stmt of body.statements) {\n if (ts.isReturnStatement(stmt) && stmt.expression) return true\n }\n return false\n}\n\nfunction detectUseEffect(ctx: DetectContext, node: ts.CallExpression): void {\n const hookName = (node.expression as ts.Identifier).text\n const depsArg = node.arguments[1]\n const callbackArg = node.arguments[0]\n\n if (depsArg && ts.isArrayLiteralExpression(depsArg) && depsArg.elements.length === 0) {\n const hasCleanup = callbackArg ? callbackHasCleanup(callbackArg) : false\n\n detectDiag(\n ctx,\n node,\n 'use-effect-mount',\n `${hookName} with empty deps [] means \"run once on mount\". Use onMount() in Pyreon.`,\n detectGetNodeText(ctx, node),\n hasCleanup\n ? 'onMount(() => {\\n // setup...\\n return () => { /* cleanup */ }\\n})'\n : 'onMount(() => {\\n // setup...\\n})',\n true,\n )\n } else if (depsArg && ts.isArrayLiteralExpression(depsArg)) {\n detectDiag(\n ctx,\n node,\n 'use-effect-deps',\n `${hookName} with dependency array. In Pyreon, effect() auto-tracks dependencies — no array needed.`,\n detectGetNodeText(ctx, node),\n 'effect(() => {\\n // reads are auto-tracked\\n})',\n true,\n )\n } else if (!depsArg) {\n detectDiag(\n ctx,\n node,\n 'use-effect-no-deps',\n `${hookName} with no dependency array. In Pyreon, use effect() — it auto-tracks signal reads.`,\n detectGetNodeText(ctx, node),\n 'effect(() => {\\n // runs when accessed signals change\\n})',\n true,\n )\n }\n}\n\nfunction detectUseMemo(ctx: DetectContext, node: ts.CallExpression): void {\n const computeFn = node.arguments[0]\n const computeText = computeFn ? detectGetNodeText(ctx, computeFn) : '() => value'\n\n detectDiag(\n ctx,\n node,\n 'use-memo',\n 'useMemo is a React API. In Pyreon, use computed() — dependencies auto-tracked.',\n detectGetNodeText(ctx, node),\n `computed(${computeText})`,\n true,\n )\n}\n\nfunction detectUseCallback(ctx: DetectContext, node: ts.CallExpression): void {\n const callbackFn = node.arguments[0]\n const callbackText = callbackFn ? detectGetNodeText(ctx, callbackFn) : '() => {}'\n\n detectDiag(\n ctx,\n node,\n 'use-callback',\n 'useCallback is not needed in Pyreon. Components run once, so closures never go stale. Use a plain function.',\n detectGetNodeText(ctx, node),\n callbackText,\n true,\n )\n}\n\nfunction detectUseRef(ctx: DetectContext, node: ts.CallExpression): void {\n const arg = node.arguments[0]\n const isNullInit =\n arg &&\n (arg.kind === ts.SyntaxKind.NullKeyword || (ts.isIdentifier(arg) && arg.text === 'undefined'))\n\n if (isNullInit) {\n detectDiag(\n ctx,\n node,\n 'use-ref-dom',\n 'useRef(null) for DOM refs. In Pyreon, use createRef() from @pyreon/core.',\n detectGetNodeText(ctx, node),\n 'createRef()',\n true,\n )\n } else {\n const initText = arg ? detectGetNodeText(ctx, arg) : 'undefined'\n detectDiag(\n ctx,\n node,\n 'use-ref-box',\n 'useRef for mutable values. In Pyreon, use signal() — it works the same way but is reactive.',\n detectGetNodeText(ctx, node),\n `signal(${initText})`,\n true,\n )\n }\n}\n\nfunction detectUseReducer(ctx: DetectContext, node: ts.CallExpression): void {\n detectDiag(\n ctx,\n node,\n 'use-reducer',\n 'useReducer is a React API. In Pyreon, use signal() with update() for reducer patterns.',\n detectGetNodeText(ctx, node),\n 'const state = signal(initialState)\\nconst dispatch = (action) => state.update(s => reducer(s, action))',\n false,\n )\n}\n\nfunction isCallToReactDot(callee: ts.Expression, methodName: string): boolean {\n return (\n ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text === 'React' &&\n callee.name.text === methodName\n )\n}\n\nfunction detectMemoWrapper(ctx: DetectContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isMemo =\n (ts.isIdentifier(callee) && callee.text === 'memo') || isCallToReactDot(callee, 'memo')\n\n if (isMemo) {\n const inner = node.arguments[0]\n const innerText = inner ? detectGetNodeText(ctx, inner) : 'Component'\n\n detectDiag(\n ctx,\n node,\n 'memo-wrapper',\n 'memo() is not needed in Pyreon. Components run once — only signals trigger updates, not re-renders.',\n detectGetNodeText(ctx, node),\n innerText,\n true,\n )\n }\n}\n\nfunction detectForwardRef(ctx: DetectContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isForwardRef =\n (ts.isIdentifier(callee) && callee.text === 'forwardRef') ||\n isCallToReactDot(callee, 'forwardRef')\n\n if (isForwardRef) {\n detectDiag(\n ctx,\n node,\n 'forward-ref',\n 'forwardRef is not needed in Pyreon. Pass ref as a regular prop.',\n detectGetNodeText(ctx, node),\n '// Just pass ref as a prop:\\nconst MyInput = (props) => <input ref={props.ref} />',\n true,\n )\n }\n}\n\nfunction detectJsxAttributes(ctx: DetectContext, node: ts.JsxAttribute): void {\n const attrName = (node.name as ts.Identifier).text\n\n if (attrName in JSX_ATTR_REWRITES) {\n const htmlAttr = JSX_ATTR_REWRITES[attrName] as string\n detectDiag(\n ctx,\n node,\n attrName === 'className' ? 'class-name-prop' : 'html-for-prop',\n `'${attrName}' is a React JSX attribute. Use '${htmlAttr}' in Pyreon (standard HTML).`,\n detectGetNodeText(ctx, node),\n detectGetNodeText(ctx, node).replace(attrName, htmlAttr),\n true,\n )\n }\n\n if (attrName === 'onChange') {\n const jsxElement = findParentJsxElement(node)\n if (jsxElement) {\n const tagName = getJsxTagName(jsxElement)\n if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {\n detectDiag(\n ctx,\n node,\n 'on-change-input',\n `onChange on <${tagName}> fires on blur in Pyreon (native DOM behavior). For keypress-by-keypress updates, use onInput.`,\n detectGetNodeText(ctx, node),\n detectGetNodeText(ctx, node).replace('onChange', 'onInput'),\n true,\n )\n }\n }\n }\n\n if (attrName === 'dangerouslySetInnerHTML') {\n detectDiag(\n ctx,\n node,\n 'dangerously-set-inner-html',\n 'dangerouslySetInnerHTML is React-specific. Use innerHTML prop in Pyreon.',\n detectGetNodeText(ctx, node),\n 'innerHTML={htmlString}',\n true,\n )\n }\n}\n\nfunction detectDotValueSignal(ctx: DetectContext, node: ts.PropertyAccessExpression): void {\n const varName = (node.expression as ts.Identifier).text\n const parent = node.parent\n if (ts.isBinaryExpression(parent) && parent.left === node) {\n detectDiag(\n ctx,\n node,\n 'dot-value-signal',\n `'${varName}.value' looks like a Vue ref pattern. Pyreon signals are callable functions. Use ${varName}.set(x) to write.`,\n detectGetNodeText(ctx, parent),\n `${varName}.set(${detectGetNodeText(ctx, parent.right)})`,\n false,\n )\n }\n}\n\nfunction detectArrayMapJsx(ctx: DetectContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (ts.isJsxExpression(parent)) {\n const arrayExpr = detectGetNodeText(\n ctx,\n (node.expression as ts.PropertyAccessExpression).expression,\n )\n const mapCallback = node.arguments[0]\n const mapCallbackText = mapCallback\n ? detectGetNodeText(ctx, mapCallback)\n : 'item => <li>{item}</li>'\n\n detectDiag(\n ctx,\n node,\n 'array-map-jsx',\n 'Array.map() in JSX is not reactive in Pyreon. Use <For> for efficient keyed list rendering.',\n detectGetNodeText(ctx, node),\n `<For each={${arrayExpr}} by={item => item.id}>\\n {${mapCallbackText}}\\n</For>`,\n false,\n )\n }\n}\n\nfunction isCallToHook(node: ts.Node, hookName: string): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === hookName\n )\n}\n\nfunction isCallToEffectHook(node: ts.Node): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n (node.expression.text === 'useEffect' || node.expression.text === 'useLayoutEffect')\n )\n}\n\nfunction isMapCallExpression(node: ts.Node): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n ts.isIdentifier(node.expression.name) &&\n node.expression.name.text === 'map'\n )\n}\n\nfunction isDotValueAccess(node: ts.Node): node is ts.PropertyAccessExpression {\n return (\n ts.isPropertyAccessExpression(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === 'value' &&\n ts.isIdentifier(node.expression)\n )\n}\n\nfunction detectVisitNode(ctx: DetectContext, node: ts.Node): void {\n if (ts.isImportDeclaration(node)) detectImportDeclaration(ctx, node)\n if (isCallToHook(node, 'useState')) detectUseState(ctx, node)\n if (isCallToEffectHook(node)) detectUseEffect(ctx, node)\n if (isCallToHook(node, 'useMemo')) detectUseMemo(ctx, node)\n if (isCallToHook(node, 'useCallback')) detectUseCallback(ctx, node)\n if (isCallToHook(node, 'useRef')) detectUseRef(ctx, node)\n if (isCallToHook(node, 'useReducer')) detectUseReducer(ctx, node)\n if (ts.isCallExpression(node)) detectMemoWrapper(ctx, node)\n if (ts.isCallExpression(node)) detectForwardRef(ctx, node)\n if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) detectJsxAttributes(ctx, node)\n if (isDotValueAccess(node)) detectDotValueSignal(ctx, node)\n if (isMapCallExpression(node)) detectArrayMapJsx(ctx, node)\n}\n\nfunction detectVisit(ctx: DetectContext, node: ts.Node): void {\n ts.forEachChild(node, (child) => {\n detectVisitNode(ctx, child)\n detectVisit(ctx, child)\n })\n}\n\nexport function detectReactPatterns(code: string, filename = 'input.tsx'): ReactDiagnostic[] {\n const sf = ts.createSourceFile(filename, code, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TSX)\n const ctx: DetectContext = {\n sf,\n code,\n diagnostics: [],\n reactImportedHooks: new Set<string>(),\n }\n\n detectVisit(ctx, sf)\n return ctx.diagnostics\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Migration (detection + auto-fix)\n// ═══════════════════════════════════════════════════════════════════════════════\n\ntype Replacement = { start: number; end: number; text: string }\n\ninterface MigrateContext {\n sf: ts.SourceFile\n code: string\n replacements: Replacement[]\n changes: MigrationChange[]\n pyreonImports: Map<string, Set<string>>\n importsToRemove: Set<ts.ImportDeclaration>\n specifierRewrites: Map<ts.ImportSpecifier, { name: string; from: string }>\n}\n\nfunction migrateAddImport(ctx: MigrateContext, source: string, specifier: string): void {\n if (!source || !specifier) return\n let specs = ctx.pyreonImports.get(source)\n if (!specs) {\n specs = new Set()\n ctx.pyreonImports.set(source, specs)\n }\n specs.add(specifier)\n}\n\nfunction migrateReplace(ctx: MigrateContext, node: ts.Node, text: string): void {\n ctx.replacements.push({ start: node.getStart(ctx.sf), end: node.getEnd(), text })\n}\n\nfunction migrateGetNodeText(ctx: MigrateContext, node: ts.Node): string {\n return ctx.code.slice(node.getStart(ctx.sf), node.getEnd())\n}\n\nfunction migrateGetLine(ctx: MigrateContext, node: ts.Node): number {\n return ctx.sf.getLineAndCharacterOfPosition(node.getStart(ctx.sf)).line + 1\n}\n\nfunction migrateImportDeclaration(ctx: MigrateContext, node: ts.ImportDeclaration): void {\n if (!node.moduleSpecifier) return\n const source = (node.moduleSpecifier as ts.StringLiteral).text\n if (!(source in IMPORT_REWRITES)) return\n\n if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n for (const spec of node.importClause.namedBindings.elements) {\n const name = spec.name.text\n const rewrite = SPECIFIER_REWRITES[name]\n if (rewrite) {\n if (rewrite.name) {\n migrateAddImport(ctx, rewrite.from, rewrite.name)\n }\n ctx.specifierRewrites.set(spec, rewrite)\n }\n }\n }\n ctx.importsToRemove.add(node)\n}\n\nfunction migrateUseState(ctx: MigrateContext, node: ts.CallExpression): void {\n const parent = node.parent\n if (\n ts.isVariableDeclaration(parent) &&\n parent.name &&\n ts.isArrayBindingPattern(parent.name) &&\n parent.name.elements.length >= 1\n ) {\n const firstEl = parent.name.elements[0]\n const valueName =\n firstEl && ts.isBindingElement(firstEl) ? (firstEl.name as ts.Identifier).text : 'value'\n const initArg = node.arguments[0] ? migrateGetNodeText(ctx, node.arguments[0]) : 'undefined'\n\n const declStart = parent.getStart(ctx.sf)\n const declEnd = parent.getEnd()\n ctx.replacements.push({\n start: declStart,\n end: declEnd,\n text: `${valueName} = signal(${initArg})`,\n })\n migrateAddImport(ctx, '@pyreon/reactivity', 'signal')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `useState → signal: ${valueName}`,\n })\n }\n}\n\nfunction migrateUseEffect(ctx: MigrateContext, node: ts.CallExpression): void {\n const depsArg = node.arguments[1]\n const callbackArg = node.arguments[0]\n const hookName = (node.expression as ts.Identifier).text\n\n if (\n depsArg &&\n ts.isArrayLiteralExpression(depsArg) &&\n depsArg.elements.length === 0 &&\n callbackArg\n ) {\n const callbackText = migrateGetNodeText(ctx, callbackArg)\n migrateReplace(ctx, node, `onMount(${callbackText})`)\n migrateAddImport(ctx, '@pyreon/core', 'onMount')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${hookName}(fn, []) → onMount(fn)`,\n })\n } else if (callbackArg) {\n const callbackText = migrateGetNodeText(ctx, callbackArg)\n migrateReplace(ctx, node, `effect(${callbackText})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'effect')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${hookName} → effect (auto-tracks deps)`,\n })\n }\n}\n\nfunction migrateUseMemo(ctx: MigrateContext, node: ts.CallExpression): void {\n const computeFn = node.arguments[0]\n if (computeFn) {\n migrateReplace(ctx, node, `computed(${migrateGetNodeText(ctx, computeFn)})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'computed')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useMemo → computed (auto-tracks deps)',\n })\n }\n}\n\nfunction migrateUseCallback(ctx: MigrateContext, node: ts.CallExpression): void {\n const callbackFn = node.arguments[0]\n if (callbackFn) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, callbackFn))\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useCallback → plain function (not needed in Pyreon)',\n })\n }\n}\n\nfunction migrateUseRef(ctx: MigrateContext, node: ts.CallExpression): void {\n const arg = node.arguments[0]\n const isNullInit =\n arg &&\n (arg.kind === ts.SyntaxKind.NullKeyword || (ts.isIdentifier(arg) && arg.text === 'undefined'))\n\n if (isNullInit || !arg) {\n migrateReplace(ctx, node, 'createRef()')\n migrateAddImport(ctx, '@pyreon/core', 'createRef')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useRef(null) → createRef()',\n })\n } else {\n migrateReplace(ctx, node, `signal(${migrateGetNodeText(ctx, arg)})`)\n migrateAddImport(ctx, '@pyreon/reactivity', 'signal')\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'useRef(value) → signal(value)',\n })\n }\n}\n\nfunction migrateMemoWrapper(ctx: MigrateContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isMemo =\n (ts.isIdentifier(callee) && callee.text === 'memo') || isCallToReactDot(callee, 'memo')\n\n if (isMemo && node.arguments[0]) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, node.arguments[0]))\n ctx.changes.push({\n type: 'remove',\n line: migrateGetLine(ctx, node),\n description: 'Removed memo() wrapper (not needed in Pyreon)',\n })\n }\n}\n\nfunction migrateForwardRef(ctx: MigrateContext, node: ts.CallExpression): void {\n const callee = node.expression\n const isForwardRef =\n (ts.isIdentifier(callee) && callee.text === 'forwardRef') ||\n isCallToReactDot(callee, 'forwardRef')\n\n if (isForwardRef && node.arguments[0]) {\n migrateReplace(ctx, node, migrateGetNodeText(ctx, node.arguments[0]))\n ctx.changes.push({\n type: 'remove',\n line: migrateGetLine(ctx, node),\n description: 'Removed forwardRef wrapper (pass ref as normal prop in Pyreon)',\n })\n }\n}\n\nfunction migrateJsxAttributes(ctx: MigrateContext, node: ts.JsxAttribute): void {\n const attrName = (node.name as ts.Identifier).text\n\n if (attrName in JSX_ATTR_REWRITES) {\n const htmlAttr = JSX_ATTR_REWRITES[attrName] as string\n ctx.replacements.push({\n start: node.name.getStart(ctx.sf),\n end: node.name.getEnd(),\n text: htmlAttr,\n })\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `${attrName} → ${htmlAttr}`,\n })\n }\n\n if (attrName === 'onChange') {\n const jsxElement = findParentJsxElement(node)\n if (jsxElement) {\n const tagName = getJsxTagName(jsxElement)\n if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {\n ctx.replacements.push({\n start: node.name.getStart(ctx.sf),\n end: node.name.getEnd(),\n text: 'onInput',\n })\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: `onChange on <${tagName}> → onInput (native DOM events)`,\n })\n }\n }\n }\n\n if (attrName === 'dangerouslySetInnerHTML') {\n migrateDangerouslySetInnerHTML(ctx, node)\n }\n}\n\nfunction migrateDangerouslySetInnerHTML(ctx: MigrateContext, node: ts.JsxAttribute): void {\n if (!node.initializer || !ts.isJsxExpression(node.initializer) || !node.initializer.expression) {\n return\n }\n const expr = node.initializer.expression\n if (!ts.isObjectLiteralExpression(expr)) return\n\n const htmlProp = expr.properties.find(\n (p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === '__html',\n ) as ts.PropertyAssignment | undefined\n\n if (htmlProp) {\n const valueText = migrateGetNodeText(ctx, htmlProp.initializer)\n migrateReplace(ctx, node, `innerHTML={${valueText}}`)\n ctx.changes.push({\n type: 'replace',\n line: migrateGetLine(ctx, node),\n description: 'dangerouslySetInnerHTML → innerHTML',\n })\n }\n}\n\nfunction applyReplacements(code: string, ctx: MigrateContext): string {\n // Remove React import declarations\n for (const imp of ctx.importsToRemove) {\n ctx.replacements.push({ start: imp.getStart(ctx.sf), end: imp.getEnd(), text: '' })\n ctx.changes.push({\n type: 'remove',\n line: ctx.sf.getLineAndCharacterOfPosition(imp.getStart(ctx.sf)).line + 1,\n description: 'Removed React import',\n })\n }\n\n // Sort descending for dedup (outermost replacements win over inner overlapping ones)\n ctx.replacements.sort((a, b) => b.start - a.start)\n\n // Deduplicate overlapping replacements (keep the outermost / first added)\n const applied = new Set<string>()\n const deduped: Replacement[] = []\n for (const r of ctx.replacements) {\n const key = `${r.start}:${r.end}`\n let overlaps = false\n for (const d of deduped) {\n if (r.start < d.end && r.end > d.start) {\n overlaps = true\n break\n }\n }\n if (!overlaps && !applied.has(key)) {\n applied.add(key)\n deduped.push(r)\n }\n }\n\n // Re-sort ascending for string builder — O(n) single join\n deduped.sort((a, b) => a.start - b.start)\n const parts: string[] = []\n let lastPos = 0\n for (const r of deduped) {\n parts.push(code.slice(lastPos, r.start))\n parts.push(r.text)\n lastPos = r.end\n }\n parts.push(code.slice(lastPos))\n return parts.join('')\n}\n\nfunction insertPyreonImports(code: string, pyreonImports: Map<string, Set<string>>): string {\n if (pyreonImports.size === 0) return code\n\n const importLines: string[] = []\n const sorted = [...pyreonImports.entries()].sort(([a], [b]) => a.localeCompare(b))\n for (const [source, specs] of sorted) {\n const specList = [...specs].sort().join(', ')\n importLines.push(`import { ${specList} } from \"${source}\"`)\n }\n const importBlock = importLines.join('\\n')\n\n const lastImportEnd = findLastImportEnd(code)\n if (lastImportEnd > 0) {\n return `${code.slice(0, lastImportEnd)}\\n${importBlock}${code.slice(lastImportEnd)}`\n }\n return `${importBlock}\\n\\n${code}`\n}\n\nfunction migrateVisitNode(ctx: MigrateContext, node: ts.Node): void {\n if (ts.isImportDeclaration(node)) migrateImportDeclaration(ctx, node)\n if (isCallToHook(node, 'useState')) migrateUseState(ctx, node)\n if (isCallToEffectHook(node)) migrateUseEffect(ctx, node)\n if (isCallToHook(node, 'useMemo')) migrateUseMemo(ctx, node)\n if (isCallToHook(node, 'useCallback')) migrateUseCallback(ctx, node)\n if (isCallToHook(node, 'useRef')) migrateUseRef(ctx, node)\n if (ts.isCallExpression(node)) migrateMemoWrapper(ctx, node)\n if (ts.isCallExpression(node)) migrateForwardRef(ctx, node)\n if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) migrateJsxAttributes(ctx, node)\n}\n\nfunction migrateVisit(ctx: MigrateContext, node: ts.Node): void {\n ts.forEachChild(node, (child) => {\n migrateVisitNode(ctx, child)\n migrateVisit(ctx, child)\n })\n}\n\nexport function migrateReactCode(code: string, filename = 'input.tsx'): MigrationResult {\n const sf = ts.createSourceFile(filename, code, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TSX)\n const diagnostics = detectReactPatterns(code, filename)\n\n const ctx: MigrateContext = {\n sf,\n code,\n replacements: [],\n changes: [],\n pyreonImports: new Map(),\n importsToRemove: new Set(),\n specifierRewrites: new Map(),\n }\n\n migrateVisit(ctx, sf)\n\n let result = applyReplacements(code, ctx)\n result = insertPyreonImports(result, ctx.pyreonImports)\n\n // Clean up empty lines from removed imports\n result = result.replace(/\\n{3,}/g, '\\n\\n')\n\n return { code: result, diagnostics, changes: ctx.changes }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Helpers\n// ═══════════════════════════════════════════════════════════════════════════════\n\nfunction findParentJsxElement(\n node: ts.Node,\n): ts.JsxOpeningElement | ts.JsxSelfClosingElement | null {\n let current = node.parent\n while (current) {\n if (ts.isJsxOpeningElement(current) || ts.isJsxSelfClosingElement(current)) {\n return current\n }\n // Don't cross component boundaries\n if (ts.isJsxElement(current)) {\n return current.openingElement\n }\n if (ts.isArrowFunction(current) || ts.isFunctionExpression(current)) {\n return null\n }\n current = current.parent\n }\n return null\n}\n\nfunction getJsxTagName(node: ts.JsxOpeningElement | ts.JsxSelfClosingElement): string {\n const tagName = node.tagName\n if (ts.isIdentifier(tagName)) {\n return tagName.text\n }\n return ''\n}\n\nfunction findLastImportEnd(code: string): number {\n const importRe = /^import\\s.+$/gm\n let lastEnd = 0\n let match: RegExpExecArray | null\n while (true) {\n match = importRe.exec(code)\n if (!match) break\n lastEnd = match.index + match[0].length\n }\n return lastEnd\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Quick scan (regex-based, for fast pre-filtering)\n// ═══════════════════════════════════════════════════════════════════════════════\n\n/** Fast regex check — returns true if code likely contains React patterns worth analyzing */\nexport function hasReactPatterns(code: string): boolean {\n return (\n /\\bfrom\\s+['\"]react/.test(code) ||\n /\\bfrom\\s+['\"]react-dom/.test(code) ||\n /\\bfrom\\s+['\"]react-router/.test(code) ||\n /\\buseState\\s*[<(]/.test(code) ||\n /\\buseEffect\\s*\\(/.test(code) ||\n /\\buseMemo\\s*\\(/.test(code) ||\n /\\buseCallback\\s*\\(/.test(code) ||\n /\\buseRef\\s*[<(]/.test(code) ||\n /\\buseReducer\\s*[<(]/.test(code) ||\n /\\bReact\\.memo\\b/.test(code) ||\n /\\bforwardRef\\s*[<(]/.test(code) ||\n /\\bclassName[=\\s]/.test(code) ||\n /\\bhtmlFor[=\\s]/.test(code) ||\n /\\.value\\s*=/.test(code)\n )\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// Error pattern database (for MCP diagnose tool)\n// ═══════════════════════════════════════════════════════════════════════════════\n\nexport interface ErrorDiagnosis {\n cause: string\n fix: string\n fixCode?: string | undefined\n related?: string | undefined\n}\n\ninterface ErrorPattern {\n pattern: RegExp\n diagnose: (match: RegExpMatchArray) => ErrorDiagnosis\n}\n\nconst ERROR_PATTERNS: ErrorPattern[] = [\n {\n pattern: /Cannot read properties of undefined \\(reading '(set|update|peek|subscribe)'\\)/,\n diagnose: (m) => ({\n cause: `Calling .${m[1]}() on undefined. The signal variable is likely out of scope, misspelled, or not yet initialized.`,\n fix: 'Check that the signal is defined and in scope. Signals must be created with signal() before use.',\n fixCode: `const mySignal = signal(initialValue)\\nmySignal.${m[1]}(newValue)`,\n }),\n },\n {\n pattern: /(\\w+) is not a function/,\n diagnose: (m) => ({\n cause: `'${m[1]}' is not callable. If this is a signal, you need to call it: ${m[1]}()`,\n fix: 'Pyreon signals are callable functions. Read: signal(), Write: signal.set(value)',\n fixCode: `// Read value:\\nconst value = ${m[1]}()\\n// Set value:\\n${m[1]}.set(newValue)`,\n }),\n },\n {\n pattern: /Cannot find module '(@pyreon\\/\\w[\\w-]*)'/,\n diagnose: (m) => ({\n cause: `Package ${m[1]} is not installed.`,\n fix: `Run: bun add ${m[1]}`,\n fixCode: `bun add ${m[1]}`,\n }),\n },\n {\n pattern: /Cannot find module 'react'/,\n diagnose: () => ({\n cause: \"Importing from 'react' in a Pyreon project.\",\n fix: 'Replace React imports with Pyreon equivalents.',\n fixCode:\n '// Instead of:\\nimport { useState } from \"react\"\\n// Use:\\nimport { signal } from \"@pyreon/reactivity\"',\n }),\n },\n {\n pattern: /Property '(\\w+)' does not exist on type 'Signal<\\w+>'/,\n diagnose: (m) => ({\n cause: `Accessing .${m[1]} on a signal. Pyreon signals don't have a .${m[1]} property.`,\n fix:\n m[1] === 'value'\n ? 'Pyreon signals are callable functions, not .value getters. Call signal() to read, signal.set() to write.'\n : `Signals have these methods: .set(), .update(), .peek(), .subscribe(). '${m[1]}' is not one of them.`,\n fixCode:\n m[1] === 'value' ? '// Read: mySignal()\\n// Write: mySignal.set(newValue)' : undefined,\n }),\n },\n {\n pattern: /Type '(\\w+)' is not assignable to type 'VNode'/,\n diagnose: (m) => ({\n cause: `Component returned ${m[1]} instead of VNode. Components must return JSX, null, or a string.`,\n fix: 'Make sure your component returns a JSX element, null, or a string.',\n fixCode: 'const MyComponent = (props) => {\\n return <div>{props.children}</div>\\n}',\n }),\n },\n {\n pattern: /onMount callback must return/,\n diagnose: () => ({\n cause: 'onMount expects a callback that optionally returns a CleanupFn.',\n fix: 'Return a cleanup function, or return nothing.',\n fixCode: 'onMount(() => {\\n // setup code\\n})',\n }),\n },\n {\n pattern: /Expected 'by' prop on <For>/,\n diagnose: () => ({\n cause: \"<For> requires a 'by' prop for efficient keyed reconciliation.\",\n fix: 'Add a by prop that returns a unique key for each item.',\n fixCode:\n '<For each={items()} by={item => item.id}>\\n {item => <li>{item.name}</li>}\\n</For>',\n }),\n },\n {\n pattern: /useHook.*outside.*component/i,\n diagnose: () => ({\n cause:\n 'Hook called outside a component function. Pyreon hooks must be called during component setup.',\n fix: 'Move the hook call inside a component function body.',\n }),\n },\n {\n pattern: /Hydration mismatch/,\n diagnose: () => ({\n cause: \"Server-rendered HTML doesn't match client-rendered output.\",\n fix: 'Ensure SSR and client render the same initial content. Check for browser-only APIs (window, document) in SSR code.',\n related: \"Use typeof window !== 'undefined' checks or onMount() for client-only code.\",\n }),\n },\n]\n\n/** Diagnose an error message and return structured fix information */\nexport function diagnoseError(error: string): ErrorDiagnosis | null {\n for (const { pattern, diagnose } of ERROR_PATTERNS) {\n const match = error.match(pattern)\n if (match) {\n return diagnose(match)\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,aAAa,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC;AAE1C,MAAM,WAAW;AAEjB,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,aAAa,MAAc,WAAW,aAA8B;CAClF,MAAM,aACJ,SAAS,SAAS,OAAO,IAAI,SAAS,SAAS,OAAO,GAAG,GAAG,WAAW,MAAM,GAAG,WAAW;CAE7F,MAAM,KAAK,GAAG,iBACZ,UACA,MACA,GAAG,aAAa,QACK,MACrB,WACD;CAGD,MAAM,eAA8B,EAAE;CACtC,MAAM,WAA8B,EAAE;CAEtC,SAAS,KAAK,MAAe,SAAiB,UAAyC;EACrF,MAAM,EAAE,MAAM,cAAc,GAAG,8BAA8B,KAAK,SAAS,GAAG,CAAC;AAC/E,WAAS,KAAK;GAAE;GAAS,MAAM,OAAO;GAAG,QAAQ;GAAW,MAAM;GAAU,CAAC;;CAK/E,MAAM,SAAkB,EAAE;CAC1B,IAAI,WAAW;CACf,IA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;EACT,WAAW,OAAO;GAChB,OAAO,YAAY,EAAE,GAAG;GACxB,KAAK;GACL,SAAS,mDAAmD,EAAE,GAAG;GAClE;EACF;CACD;EACE,SAAS;EACT,WAAW,OAAO;GAChB,OAAO,IAAI,EAAE,GAAG,+DAA+D,EAAE,GAAG;GACpF,KAAK;GACL,SAAS,iCAAiC,EAAE,GAAG,qBAAqB,EAAE,GAAG;GAC1E;EACF;CACD;EACE,SAAS;EACT,WAAW,OAAO;GAChB,OAAO,WAAW,EAAE,GAAG;GACvB,KAAK,gBAAgB,EAAE;GACvB,SAAS,WAAW,EAAE;GACvB;EACF;CACD;EACE,SAAS;EACT,iBAAiB;GACf,OAAO;GACP,KAAK;GACL,SACE;GACH;EACF;CACD;EACE,SAAS;EACT,WAAW,OAAO;GAChB,OAAO,cAAc,EAAE,GAAG,6CAA6C,EAAE,GAAG;GAC5E,KACE,EAAE,OAAO,UACL,6GACA,0EAA0E,EAAE,GAAG;GACrF,SACE,EAAE,OAAO,UAAU,0DAA0D;GAChF;EACF;CACD;EACE,SAAS;EACT,WAAW,OAAO;GAChB,OAAO,sBAAsB,EAAE,GAAG;GAClC,KAAK;GACL,SAAS;GACV;EACF;CACD;EACE,SAAS;EACT,iBAAiB;GACf,OAAO;GACP,KAAK;GACL,SAAS;GACV;EACF;CACD;EACE,SAAS;EACT,iBAAiB;GACf,OAAO;GACP,KAAK;GACL,SACE;GACH;EACF;CACD;EACE,SAAS;EACT,iBAAiB;GACf,OACE;GACF,KAAK;GACN;EACF;CACD;EACE,SAAS;EACT,iBAAiB;GACf,OAAO;GACP,KAAK;GACL,SAAS;GACV;EACF;CACF;;AAGD,SAAgB,cAAc,OAAsC;AAClE,MAAK,MAAM,EAAE,SAAS,cAAc,gBAAgB;EAClD,MAAM,QAAQ,MAAM,MAAM,QAAQ;AAClC,MAAI,MACF,QAAO,SAAS,MAAM;;AAG1B,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/compiler",
3
- "version": "0.12.7",
3
+ "version": "0.12.9",
4
4
  "description": "Template and JSX compiler for Pyreon",
5
5
  "homepage": "https://github.com/pyreon/pyreon/tree/main/packages/compiler#readme",
6
6
  "bugs": {
package/src/jsx.ts CHANGED
@@ -138,8 +138,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
138
138
  function wrap(expr: ts.Expression): void {
139
139
  const start = expr.getStart(sf)
140
140
  const end = expr.getEnd()
141
- const exprText = inlineVarsInText(code.slice(start, end))
142
- replacements.push({ start, end, text: `() => ${exprText}` })
141
+ replacements.push({ start, end, text: `() => ${sliceExpr(expr)}` })
143
142
  }
144
143
 
145
144
  /** Try to hoist or wrap an expression, pushing a replacement if needed. */
@@ -228,7 +227,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
228
227
  } else if (shouldWrap(expr)) {
229
228
  const start = expr.getStart(sf)
230
229
  const end = expr.getEnd()
231
- replacements.push({ start, end, text: `_rp(() => ${inlineVarsInText(code.slice(start, end))})` })
230
+ replacements.push({ start, end, text: `_rp(() => ${sliceExpr(expr)})` })
232
231
  needsRpImport = true
233
232
  }
234
233
  } else {
@@ -269,8 +268,9 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
269
268
  /** Names that refer to the props object or splitProps results. */
270
269
  const propsNames = new Set<string>()
271
270
 
272
- /** Map of variable name → source text of the original expression. */
273
- const propDerivedVars = new Map<string, string>()
271
+ /** Map of variable name → AST node of the original expression.
272
+ * Using AST nodes instead of text avoids all string manipulation edge cases. */
273
+ const propDerivedVars = new Map<string, ts.Expression>()
274
274
 
275
275
  /** Check if an expression reads from a tracked props-like object. */
276
276
  function readsFromProps(node: ts.Node): boolean {
@@ -356,9 +356,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
356
356
  if (_callbackDepth > 0) continue
357
357
  if (ts.isIdentifier(decl.name) && decl.initializer) {
358
358
  if (readsFromProps(decl.initializer)) {
359
- const varName = decl.name.text
360
- const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd())
361
- propDerivedVars.set(varName, exprText)
359
+ propDerivedVars.set(decl.name.text, decl.initializer)
362
360
  }
363
361
  }
364
362
  }
@@ -371,7 +369,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
371
369
  scanForPropDerivedVars(sf)
372
370
 
373
371
  // Transitive resolution: if const b = a + 1 where a is prop-derived,
374
- // then b is also prop-derived. Inline b (a + 1) → ((props.x) + 1).
372
+ // then b is also prop-derived. Store its AST node.
375
373
  // Fixed-point iteration until no new variables are added.
376
374
  let changed = true
377
375
  while (changed) {
@@ -381,9 +379,8 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
381
379
  for (const decl of node.declarationList.declarations) {
382
380
  if (!ts.isIdentifier(decl.name) || !decl.initializer) continue
383
381
  const varName = decl.name.text
384
- if (propDerivedVars.has(varName)) continue // already tracked
385
- if (node.declarationList.flags & ts.NodeFlags.Let) continue // skip let
386
- // Check if the initializer references any existing prop-derived var
382
+ if (propDerivedVars.has(varName)) continue
383
+ if (node.declarationList.flags & ts.NodeFlags.Let) continue
387
384
  let usesPropVar = false
388
385
  ts.forEachChild(decl.initializer, function check(n) {
389
386
  if (usesPropVar) return
@@ -395,53 +392,49 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
395
392
  ts.forEachChild(n, check)
396
393
  })
397
394
  if (usesPropVar) {
398
- const exprText = code.slice(decl.initializer.getStart(sf), decl.initializer.getEnd())
399
- propDerivedVars.set(varName, exprText)
395
+ propDerivedVars.set(varName, decl.initializer)
400
396
  changed = true
401
397
  }
402
398
  }
403
399
  })
404
400
  }
405
401
 
406
- // Resolve transitive inlining: if b's expr references a, replace a with its expr
407
- for (const [varName, expr] of propDerivedVars) {
408
- let resolved = expr
409
- for (const [depName, depExpr] of propDerivedVars) {
410
- if (depName === varName) continue
411
- const re = new RegExp(`(?<![.\\w])${depName}(?![\\w:=])`, 'g')
412
- if (re.test(resolved)) {
413
- resolved = resolved.replace(re, `(${depExpr})`)
402
+ // Resolve transitive AST: for each prop-derived var, recursively replace
403
+ // references to other prop-derived vars in its AST with their resolved nodes.
404
+ // Uses ts.visitNode for correct AST transformation — no string manipulation.
405
+ function resolveExprTransitive(node: ts.Expression, excludeVar?: string): ts.Expression {
406
+ return ts.visitNode(node, function visit(n: ts.Node): ts.Node {
407
+ if (ts.isIdentifier(n) && propDerivedVars.has(n.text) && n.text !== excludeVar) {
408
+ const parent = n.parent
409
+ // Skip property name after dot: obj.sizes
410
+ if (parent && ts.isPropertyAccessExpression(parent) && parent.name === n) {
411
+ return n
412
+ }
413
+ // Skip JSX attribute name: sizes={...}
414
+ if (parent && ts.isJsxAttribute(parent) && parent.name === n) {
415
+ return n
416
+ }
417
+ // Skip shorthand property assignment: { sizes }
418
+ if (parent && ts.isShorthandPropertyAssignment(parent)) {
419
+ return n
420
+ }
421
+ const resolved = propDerivedVars.get(n.text)!
422
+ return ts.factory.createParenthesizedExpression(
423
+ resolveExprTransitive(resolved, n.text),
424
+ )
414
425
  }
415
- }
416
- if (resolved !== expr) propDerivedVars.set(varName, resolved)
426
+ return ts.visitEachChild(n, visit, undefined as any)
427
+ }) as ts.Expression
417
428
  }
418
429
 
430
+ /** Print an AST expression back to source text. */
431
+ const printer = ts.createPrinter({ removeComments: false })
432
+
419
433
  /**
420
434
  * Enhanced dynamic check — combines containsCall with props awareness.
421
435
  * Returns true if an expression is reactive (contains signal calls,
422
436
  * accesses props members, or references prop-derived variables).
423
437
  */
424
- /**
425
- * Replace prop-derived variable names in a source text with their original expressions.
426
- * Simple regex-based replacement — safe because variable names are identifiers.
427
- */
428
- function inlineVarsInText(text: string): string {
429
- if (propDerivedVars.size === 0) return text
430
- let result = text
431
- for (const [varName, expr] of propDerivedVars) {
432
- // Replace standalone variable references only.
433
- // Must NOT match:
434
- // - property access: obj.varName (preceded by .)
435
- // - property name in object: { varName: ... } (followed by :)
436
- // - part of longer identifier: varNameExtra
437
- // Lookbehind ensures not preceded by . or alphanumeric
438
- // Lookahead ensures not followed by alphanumeric, :, or = (JSX attr name)
439
- const re = new RegExp(`(?<![.\\w])${varName}(?![\\w:=])`, 'g')
440
- result = result.replace(re, `(${expr})`)
441
- }
442
- return result
443
- }
444
-
445
438
  function isDynamic(node: ts.Node): boolean {
446
439
  if (containsCall(node)) return true
447
440
  return accessesProps(node)
@@ -847,7 +840,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
847
840
  // When r.name() changes, r.email()'s _bind doesn't re-run.
848
841
  needsBindImportGlobal = true
849
842
  const d = nextDisp()
850
- bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${inlineVarsInText(expr)} })`)
843
+ bindLines.push(`const ${d} = _bind(() => { ${tVar}.data = ${expr} })`)
851
844
  }
852
845
  return needsPlaceholder ? '<!>' : ''
853
846
  }
@@ -971,7 +964,7 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
971
964
  if (reactiveBindExprs.length > 0) {
972
965
  needsBindImportGlobal = true
973
966
  const combinedName = nextDisp()
974
- const combinedBody = reactiveBindExprs.map(inlineVarsInText).join('; ')
967
+ const combinedBody = reactiveBindExprs.join('; ')
975
968
  bindLines.push(`const ${combinedName} = _bind(() => { ${combinedBody} })`)
976
969
  }
977
970
 
@@ -1065,8 +1058,15 @@ export function transformJSX(code: string, filename = 'input.tsx'): TransformRes
1065
1058
  return false
1066
1059
  }
1067
1060
 
1068
- /** Slice expression source from the original code */
1061
+ /** Slice expression source from the original code.
1062
+ * Resolves any prop-derived identifiers found anywhere in the expression
1063
+ * via AST transformation — handles template literals, ternaries, etc. */
1069
1064
  function sliceExpr(expr: ts.Expression): string {
1065
+ // Quick check: does this expression contain any prop-derived references?
1066
+ if (propDerivedVars.size > 0 && accessesProps(expr)) {
1067
+ const resolved = resolveExprTransitive(expr)
1068
+ return printer.printNode(ts.EmitHint.Expression, resolved, sf)
1069
+ }
1070
1070
  return code.slice(expr.getStart(sf), expr.getEnd())
1071
1071
  }
1072
1072
 
@@ -1365,3 +1365,56 @@ describe('JSX transform — transitive prop derivation', () => {
1365
1365
  expect(matches?.length).toBeGreaterThanOrEqual(2)
1366
1366
  })
1367
1367
  })
1368
+
1369
+ // ─── AST-based inlining edge cases ──────────────────────────────────────────
1370
+
1371
+ describe('JSX transform — AST inlining (template literals, ternaries)', () => {
1372
+ test('template literal with prop-derived var is inlined', () => {
1373
+ const result = t('function C(props) { const x = props.name; return <div>{`hello ${x}`}</div> }')
1374
+ expect(result).toContain('props.name')
1375
+ expect(result).toContain('_bind')
1376
+ })
1377
+
1378
+ test('ternary with prop-derived var is inlined', () => {
1379
+ const result = t('function C(props) { const v = props.x; return <div>{v ? "yes" : "no"}</div> }')
1380
+ expect(result).toContain('props.x')
1381
+ expect(result).toContain('? "yes" : "no"')
1382
+ })
1383
+
1384
+ test('both branches of ternary inlined when both are prop-derived', () => {
1385
+ const result = t('function C(props) { const a = props.x; const b = props.y; return <div>{a ? b : "none"}</div> }')
1386
+ expect(result).toContain('props.x')
1387
+ expect(result).toContain('props.y')
1388
+ })
1389
+
1390
+ test('concatenation with prop-derived inlined', () => {
1391
+ const result = t('function C(props) { const x = props.cls; return <div class={x + " extra"}></div> }')
1392
+ expect(result).toContain('props.cls')
1393
+ expect(result).toContain('" extra"')
1394
+ })
1395
+
1396
+ test('object property access on prop-derived NOT confused', () => {
1397
+ const result = t('function C(props) { const data = props.data; return <div>{data.name}</div> }')
1398
+ // data.name → (props.data).name — the .name is preserved, not replaced
1399
+ expect(result).toContain('props.data')
1400
+ expect(result).toContain('.name')
1401
+ })
1402
+
1403
+ test('deep transitive: c = b * 2, b = a + 1, a = props.x via AST', () => {
1404
+ const result = t('function C(props) { const a = props.x; const b = a + 1; const c = b * 2; return <div>{c}</div> }')
1405
+ expect(result).toContain('props.x')
1406
+ // Full chain resolved via AST visitor
1407
+ expect(result).toContain('_bind')
1408
+ })
1409
+
1410
+ test('array destructuring NOT tracked (only simple identifier)', () => {
1411
+ const result = t('function C(props) { const [a, b] = props.items; return <div>{a}</div> }')
1412
+ // Array destructuring is not a simple identifier — not tracked
1413
+ expect(result).not.toContain('(props.items)')
1414
+ })
1415
+
1416
+ test('computed property not confused with prop-derived', () => {
1417
+ const result = t('function C(props) { const key = props.key; return <div>{obj[key]}</div> }')
1418
+ expect(result).toContain('props.key')
1419
+ })
1420
+ })