@tamagui/compiler-core 3.0.0-beta.924.1 → 3.0.1

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.
package/dist/cjs/ast.cjs CHANGED
@@ -42,8 +42,9 @@ function isAstNode(value) {
42
42
  }
43
43
  function walkAst(node, visitor, parent = null, key = null) {
44
44
  visitor(node, parent, key);
45
- for (const [childKey, value] of Object.entries(node)) {
45
+ for (const childKey of Object.keys(node)) {
46
46
  if (ignoredKeys.has(childKey)) continue;
47
+ const value = node[childKey];
47
48
  if (isAstNode(value)) {
48
49
  walkAst(value, visitor, node, childKey);
49
50
  } else if (Array.isArray(value)) {
@@ -55,14 +56,27 @@ function walkAst(node, visitor, parent = null, key = null) {
55
56
  }
56
57
  }
57
58
  }
58
- function findAstNode(root, predicate) {
59
- let found = null;
60
- walkAst(root, (node, parent, key) => {
61
- if (!found && predicate(node, parent, key)) {
62
- found = node;
59
+ function findAstNode(root, predicate, span) {
60
+ function visit(node, parent, key) {
61
+ if (span && (node.start > span.start || node.end < span.end)) return null;
62
+ if (predicate(node, parent, key)) return node;
63
+ for (const childKey of Object.keys(node)) {
64
+ if (ignoredKeys.has(childKey)) continue;
65
+ const value = node[childKey];
66
+ if (isAstNode(value)) {
67
+ const found = visit(value, node, childKey);
68
+ if (found) return found;
69
+ } else if (Array.isArray(value)) {
70
+ for (const child of value) {
71
+ if (!isAstNode(child)) continue;
72
+ const found = visit(child, node, childKey);
73
+ if (found) return found;
74
+ }
75
+ }
63
76
  }
64
- });
65
- return found;
77
+ return null;
78
+ }
79
+ return visit(root, null, null);
66
80
  }
67
81
  function childNode(node, key) {
68
82
  const value = node[key];
@@ -360,7 +360,7 @@ function evaluateDynamicNode(resolver, id, input, state) {
360
360
  const expression = expressions[position];
361
361
  if (!expression) continue;
362
362
  const part = evaluateDynamicNode(resolver, id, expression, state);
363
- if (!part?.values) return null;
363
+ if (!part?.values) return { type: "string" };
364
364
  const next = [];
365
365
  for (const value of values) {
366
366
  for (const primitive of part.values) {
@@ -368,7 +368,7 @@ function evaluateDynamicNode(resolver, id, input, state) {
368
368
  if (!next.includes(joined)) next.push(joined);
369
369
  }
370
370
  }
371
- if (next.length > 32) return null;
371
+ if (next.length > 32) return { type: "string" };
372
372
  values = next;
373
373
  }
374
374
  return {
@@ -26,7 +26,7 @@ __export(lower_exports, {
26
26
  module.exports = __toCommonJS(lower_exports);
27
27
  var import_diagnostics = require("./diagnostics.cjs");
28
28
  var import_output = require("./output.cjs");
29
- const LOWERED_MODULE_PLAN_VERSION = 3;
29
+ const LOWERED_MODULE_PLAN_VERSION = 5;
30
30
  function compareCodeUnits(left, right) {
31
31
  return left < right ? -1 : left > right ? 1 : 0;
32
32
  }
@@ -53,13 +53,13 @@ function unsafeEntry(element, entry, component, host) {
53
53
  if (entry.kind === "spread" && entry.value.kind !== "static") {
54
54
  return diagnostic("local/unsafe-style-spread", element, "Unevaluated spread may change style and duplicate-prop precedence");
55
55
  }
56
- if (entry.kind === "prop" && host.isStyleProp(entry.name, component) && (entry.value.kind === "bailout" || entry.value.kind === "conditional") && !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind)) {
56
+ if (entry.kind === "prop" && host.isStyleProp(entry.name, component) && (entry.value.kind === "bailout" || entry.value.kind === "conditional") && !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind, entry.value.kind === "bailout" ? entry.value.dynamic : null)) {
57
57
  return diagnostic("local/dynamic-style-value", element, `Style prop ${entry.name} could not be evaluated`, entry.name);
58
58
  }
59
59
  if (entry.kind === "prop" && entry.value.kind === "object") {
60
60
  for (const member of entry.value.members) {
61
61
  if (member.value.kind !== "bailout" && member.value.kind !== "conditional") continue;
62
- if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind)) {
62
+ if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind, member.value.kind === "bailout" ? member.value.dynamic : null)) {
63
63
  return diagnostic("local/dynamic-style-value", element, `Style prop ${member.name} could not be evaluated`, member.name);
64
64
  }
65
65
  }
@@ -46,19 +46,21 @@ function finalizeElement(base, entries, bailouts) {
46
46
  bailouts
47
47
  };
48
48
  }
49
- function definitionFromDeclaration(id, name, program, declaration) {
49
+ function definitionFromDeclaration(id, name, declaration, parentOf) {
50
50
  let identifier = declaration;
51
51
  let initializer = null;
52
52
  let constant = false;
53
53
  if (declaration.type === "VariableDeclarator") {
54
54
  identifier = (0, import_ast.childNode)(declaration, "id") ?? declaration;
55
55
  initializer = (0, import_ast.childNode)(declaration, "init");
56
- constant = !!(0, import_ast.findAstNode)(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && (0, import_ast.childNodes)(node, "declarations").some((candidate) => candidate.start === declaration.start));
56
+ const parent = parentOf(declaration);
57
+ constant = parent?.type === "VariableDeclaration" && parent.kind === "const";
57
58
  } else if (declaration.type === "Identifier") {
58
- const declarator = (0, import_ast.findAstNode)(program, (node) => node.type === "VariableDeclarator" && (0, import_ast.childNode)(node, "id")?.start === declaration.start);
59
- if (declarator) {
59
+ const declarator = parentOf(declaration);
60
+ if (declarator?.type === "VariableDeclarator" && (0, import_ast.childNode)(declarator, "id")?.start === declaration.start) {
60
61
  initializer = (0, import_ast.childNode)(declarator, "init");
61
- constant = !!(0, import_ast.findAstNode)(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && (0, import_ast.childNodes)(node, "declarations").some((candidate) => candidate.start === declarator.start));
62
+ const parent = parentOf(declarator);
63
+ constant = parent?.type === "VariableDeclaration" && parent.kind === "const";
62
64
  }
63
65
  }
64
66
  return {
@@ -615,7 +617,10 @@ function normalizeElements(candidate, rawId, imports = []) {
615
617
  };
616
618
  }
617
619
  function nodeAtSpan(program, start, end) {
618
- return (0, import_ast.findAstNode)(program, (node) => node.start === start && node.end === end);
620
+ return (0, import_ast.findAstNode)(program, (node) => node.start === start && node.end === end, {
621
+ start,
622
+ end
623
+ });
619
624
  }
620
625
  function asAstNode(value, label) {
621
626
  if (!(0, import_ast.isAstNode)(value)) throw new Error(`${label} is not an AST node`);
package/dist/cjs/yuku.cjs CHANGED
@@ -63,8 +63,7 @@ var YukuCandidate = class {
63
63
  #definitionSite(symbol) {
64
64
  const declaration = symbol.declarations[0];
65
65
  if (!declaration) return null;
66
- const program = (0, import_normalize.asAstNode)(symbol.module.ast, `${symbol.module.path} program`);
67
- return (0, import_normalize.definitionFromDeclaration)(symbol.module.path, symbol.name, program, (0, import_normalize.asAstNode)(declaration, `${symbol.name} declaration`));
66
+ return (0, import_normalize.definitionFromDeclaration)(symbol.module.path, symbol.name, (0, import_normalize.asAstNode)(declaration, `${symbol.name} declaration`), (node) => symbol.module.parentOf(node));
68
67
  }
69
68
  definitionOf(id, localName) {
70
69
  const symbol = this.#canonicalSymbol(id, localName);
@@ -143,6 +142,7 @@ const yukuFactory = {
143
142
  if (node.type !== "ImportDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "ExportAllDeclaration" && node.type !== "ImportExpression") {
144
143
  return;
145
144
  }
145
+ if (node.importKind === "type" || node.exportKind === "type") return;
146
146
  const sourceNode = (0, import_ast.childNode)(node, "source");
147
147
  if (sourceNode && typeof sourceNode.value === "string") {
148
148
  found.push({
package/dist/esm/ast.mjs CHANGED
@@ -10,8 +10,9 @@ function isAstNode(value) {
10
10
  }
11
11
  function walkAst(node, visitor, parent = null, key = null) {
12
12
  visitor(node, parent, key);
13
- for (const [childKey, value] of Object.entries(node)) {
13
+ for (const childKey of Object.keys(node)) {
14
14
  if (ignoredKeys.has(childKey)) continue;
15
+ const value = node[childKey];
15
16
  if (isAstNode(value)) {
16
17
  walkAst(value, visitor, node, childKey);
17
18
  } else if (Array.isArray(value)) {
@@ -23,14 +24,27 @@ function walkAst(node, visitor, parent = null, key = null) {
23
24
  }
24
25
  }
25
26
  }
26
- function findAstNode(root, predicate) {
27
- let found = null;
28
- walkAst(root, (node, parent, key) => {
29
- if (!found && predicate(node, parent, key)) {
30
- found = node;
27
+ function findAstNode(root, predicate, span) {
28
+ function visit(node, parent, key) {
29
+ if (span && (node.start > span.start || node.end < span.end)) return null;
30
+ if (predicate(node, parent, key)) return node;
31
+ for (const childKey of Object.keys(node)) {
32
+ if (ignoredKeys.has(childKey)) continue;
33
+ const value = node[childKey];
34
+ if (isAstNode(value)) {
35
+ const found = visit(value, node, childKey);
36
+ if (found) return found;
37
+ } else if (Array.isArray(value)) {
38
+ for (const child of value) {
39
+ if (!isAstNode(child)) continue;
40
+ const found = visit(child, node, childKey);
41
+ if (found) return found;
42
+ }
43
+ }
31
44
  }
32
- });
33
- return found;
45
+ return null;
46
+ }
47
+ return visit(root, null, null);
34
48
  }
35
49
  function childNode(node, key) {
36
50
  const value = node[key];
@@ -1 +1 @@
1
- {"version":3,"file":"ast.js","names":[],"sources":["esm/ast.js"],"sourcesContent":["const ignoredKeys = /* @__PURE__ */ new Set([\"loc\", \"range\", \"parent\", \"comments\", \"tokens\"]);\nfunction isAstNode(value) {\n return typeof value === \"object\" && value !== null && typeof value.type === \"string\" && typeof value.start === \"number\" && typeof value.end === \"number\";\n}\nfunction walkAst(node, visitor, parent = null, key = null) {\n visitor(node, parent, key);\n for (const [childKey, value] of Object.entries(node)) {\n if (ignoredKeys.has(childKey)) continue;\n if (isAstNode(value)) {\n walkAst(value, visitor, node, childKey);\n } else if (Array.isArray(value)) {\n for (const child of value) {\n if (isAstNode(child)) {\n walkAst(child, visitor, node, childKey);\n }\n }\n }\n }\n}\nfunction findAstNode(root, predicate) {\n let found = null;\n walkAst(root, (node, parent, key) => {\n if (!found && predicate(node, parent, key)) {\n found = node;\n }\n });\n return found;\n}\nfunction childNode(node, key) {\n const value = node[key];\n return isAstNode(value) ? value : null;\n}\nfunction childNodes(node, key) {\n const value = node[key];\n return Array.isArray(value) ? value.filter(isAstNode) : [];\n}\nfunction identifierName(node) {\n if (!node || node.type !== \"Identifier\" && node.type !== \"JSXIdentifier\") return null;\n return typeof node.name === \"string\" ? node.name : null;\n}\nfunction literalValue(node) {\n if (!node) return void 0;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n return node.value;\n }\n return void 0;\n}\nfunction unwrapExpression(node) {\n let current = node;\n while (current.type === \"TSAsExpression\" || current.type === \"TSSatisfiesExpression\" || current.type === \"TSNonNullExpression\" || current.type === \"ParenthesizedExpression\") {\n const expression = childNode(current, \"expression\");\n if (!expression) break;\n current = expression;\n }\n return current;\n}\nexport {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n literalValue,\n unwrapExpression,\n walkAst\n};\n//# sourceMappingURL=ast.js.map\n"],"mappings":";AAAA,MAAM,8BAA8B,IAAI,IAAI;CAAC;CAAO;CAAS;CAAU;CAAY;AAAQ,CAAC;AAC5F,SAAS,UAAU,OAAO;CACxB,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,UAAU,YAAY,OAAO,MAAM,QAAQ;AAClJ;AACA,SAAS,QAAQ,MAAM,SAAS,SAAS,MAAM,MAAM,MAAM;CACzD,QAAQ,MAAM,QAAQ,GAAG;CACzB,KAAK,MAAM,CAAC,UAAU,UAAU,OAAO,QAAQ,IAAI,GAAG;EACpD,IAAI,YAAY,IAAI,QAAQ,GAAG;EAC/B,IAAI,UAAU,KAAK,GAAG;GACpB,QAAQ,OAAO,SAAS,MAAM,QAAQ;EACxC,OAAO,IAAI,MAAM,QAAQ,KAAK,GAAG;GAC/B,KAAK,MAAM,SAAS,OAAO;IACzB,IAAI,UAAU,KAAK,GAAG;KACpB,QAAQ,OAAO,SAAS,MAAM,QAAQ;IACxC;GACF;EACF;CACF;AACF;AACA,SAAS,YAAY,MAAM,WAAW;CACpC,IAAI,QAAQ;CACZ,QAAQ,OAAO,MAAM,QAAQ,QAAQ;EACnC,IAAI,CAAC,SAAS,UAAU,MAAM,QAAQ,GAAG,GAAG;GAC1C,QAAQ;EACV;CACF,CAAC;CACD,OAAO;AACT;AACA,SAAS,UAAU,MAAM,KAAK;CAC5B,MAAM,QAAQ,KAAK;CACnB,OAAO,UAAU,KAAK,IAAI,QAAQ;AACpC;AACA,SAAS,WAAW,MAAM,KAAK;CAC7B,MAAM,QAAQ,KAAK;CACnB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,SAAS,IAAI,CAAC;AAC3D;AACA,SAAS,eAAe,MAAM;CAC5B,IAAI,CAAC,QAAQ,KAAK,SAAS,gBAAgB,KAAK,SAAS,iBAAiB,OAAO;CACjF,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;AACA,SAAS,aAAa,MAAM;CAC1B,IAAI,CAAC,MAAM,OAAO,KAAK;CACvB,IAAI,KAAK,SAAS,aAAa,KAAK,KAAK,SAAS,SAAS,GAAG;EAC5D,OAAO,KAAK;CACd;CACA,OAAO,KAAK;AACd;AACA,SAAS,iBAAiB,MAAM;CAC9B,IAAI,UAAU;CACd,OAAO,QAAQ,SAAS,oBAAoB,QAAQ,SAAS,2BAA2B,QAAQ,SAAS,yBAAyB,QAAQ,SAAS,2BAA2B;EAC5K,MAAM,aAAa,UAAU,SAAS,YAAY;EAClD,IAAI,CAAC,YAAY;EACjB,UAAU;CACZ;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"ast.js","names":[],"sources":["esm/ast.js"],"sourcesContent":["const ignoredKeys = /* @__PURE__ */ new Set([\"loc\", \"range\", \"parent\", \"comments\", \"tokens\"]);\nfunction isAstNode(value) {\n return typeof value === \"object\" && value !== null && typeof value.type === \"string\" && typeof value.start === \"number\" && typeof value.end === \"number\";\n}\nfunction walkAst(node, visitor, parent = null, key = null) {\n visitor(node, parent, key);\n for (const childKey of Object.keys(node)) {\n if (ignoredKeys.has(childKey)) continue;\n const value = node[childKey];\n if (isAstNode(value)) {\n walkAst(value, visitor, node, childKey);\n } else if (Array.isArray(value)) {\n for (const child of value) {\n if (isAstNode(child)) {\n walkAst(child, visitor, node, childKey);\n }\n }\n }\n }\n}\nfunction findAstNode(root, predicate, span) {\n function visit(node, parent, key) {\n if (span && (node.start > span.start || node.end < span.end)) return null;\n if (predicate(node, parent, key)) return node;\n for (const childKey of Object.keys(node)) {\n if (ignoredKeys.has(childKey)) continue;\n const value = node[childKey];\n if (isAstNode(value)) {\n const found = visit(value, node, childKey);\n if (found) return found;\n } else if (Array.isArray(value)) {\n for (const child of value) {\n if (!isAstNode(child)) continue;\n const found = visit(child, node, childKey);\n if (found) return found;\n }\n }\n }\n return null;\n }\n return visit(root, null, null);\n}\nfunction childNode(node, key) {\n const value = node[key];\n return isAstNode(value) ? value : null;\n}\nfunction childNodes(node, key) {\n const value = node[key];\n return Array.isArray(value) ? value.filter(isAstNode) : [];\n}\nfunction identifierName(node) {\n if (!node || node.type !== \"Identifier\" && node.type !== \"JSXIdentifier\") return null;\n return typeof node.name === \"string\" ? node.name : null;\n}\nfunction literalValue(node) {\n if (!node) return void 0;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n return node.value;\n }\n return void 0;\n}\nfunction unwrapExpression(node) {\n let current = node;\n while (current.type === \"TSAsExpression\" || current.type === \"TSSatisfiesExpression\" || current.type === \"TSNonNullExpression\" || current.type === \"ParenthesizedExpression\") {\n const expression = childNode(current, \"expression\");\n if (!expression) break;\n current = expression;\n }\n return current;\n}\nexport {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n literalValue,\n unwrapExpression,\n walkAst\n};\n//# sourceMappingURL=ast.js.map\n"],"mappings":";AAAA,MAAM,8BAA8B,IAAI,IAAI;CAAC;CAAO;CAAS;CAAU;CAAY;AAAQ,CAAC;AAC5F,SAAS,UAAU,OAAO;CACxB,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,UAAU,YAAY,OAAO,MAAM,QAAQ;AAClJ;AACA,SAAS,QAAQ,MAAM,SAAS,SAAS,MAAM,MAAM,MAAM;CACzD,QAAQ,MAAM,QAAQ,GAAG;CACzB,KAAK,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AS,eAAe,MAAM;CAC5B,IAAI,CAAC,QAAQ,KAAK,SAAS,gBAAgB,KAAK,SAAS,iBAAiB,OAAO;CACjF,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;AACA,SAAS,aAAa,MAAM;CAC1B,IAAI,CAAC,MAAM,OAAO,KAAK;CACvB,IAAI,KAAK,SAAS,aAAa,KAAK,KAAK,SAAS,SAAS,GAAG;EAC5D,OAAO,KAAK;CACd;CACA,OAAO,KAAK;AACd;AACA,SAAS,iBAAiB,MAAM;CAC9B,IAAI,UAAU;CACd,OAAO,QAAQ,SAAS,oBAAoB,QAAQ,SAAS,2BAA2B,QAAQ,SAAS,yBAAyB,QAAQ,SAAS,2BAA2B;EAC5K,MAAM,aAAa,UAAU,SAAS,YAAY;EAClD,IAAI,CAAC,YAAY;EACjB,UAAU;CACZ;CACA,OAAO;AACT"}
@@ -331,7 +331,7 @@ function evaluateDynamicNode(resolver, id, input, state) {
331
331
  const expression = expressions[position];
332
332
  if (!expression) continue;
333
333
  const part = evaluateDynamicNode(resolver, id, expression, state);
334
- if (!part?.values) return null;
334
+ if (!part?.values) return { type: "string" };
335
335
  const next = [];
336
336
  for (const value of values) {
337
337
  for (const primitive of part.values) {
@@ -339,7 +339,7 @@ function evaluateDynamicNode(resolver, id, input, state) {
339
339
  if (!next.includes(joined)) next.push(joined);
340
340
  }
341
341
  }
342
- if (next.length > 32) return null;
342
+ if (next.length > 32) return { type: "string" };
343
343
  values = next;
344
344
  }
345
345
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","names":[],"sources":["esm/evaluate.js"],"sourcesContent":["import { childNode, childNodes, identifierName, isAstNode, unwrapExpression } from \"./ast\";\nimport { expressionReference, spanOf } from \"./contracts\";\nimport { linkedBailout, localBailout } from \"./diagnostics\";\nfunction success(value) {\n return { ok: true, value };\n}\nfunction literal(node) {\n if (node.type === \"NullLiteral\") return null;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n const value = node.value;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null) {\n return value;\n }\n }\n return void 0;\n}\nfunction unsupported(id, node, detail = `Expression ${node.type} is not statically supported`) {\n return {\n ok: false,\n bailout: localBailout(\"local/unsupported-expression\", spanOf(id, node), detail)\n };\n}\nfunction evaluateDefinition(resolver, definition, useSpan, state) {\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) {\n return {\n ok: false,\n bailout: localBailout(\n \"local/static-evaluation-cycle\",\n useSpan,\n `Static evaluation cycle reached ${definition.name}`\n )\n };\n }\n if (!definition.initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n useSpan,\n `Binding ${definition.name} has no static initializer`,\n definition.id\n )\n };\n }\n if (!definition.constant) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n useSpan,\n `Binding ${definition.name} is mutable and cannot be statically evaluated`,\n definition.id\n )\n };\n }\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n useSpan,\n `Binding ${definition.name} initializer is outside the linked graph`,\n definition.id\n )\n };\n }\n state.dependencies.add(definition.id);\n state.activeDefinitions.add(key);\n try {\n return evaluateNode(resolver, definition.id, initializer, state);\n } finally {\n state.activeDefinitions.delete(key);\n }\n}\nfunction evaluateObject(resolver, id, node, state) {\n const output = {};\n for (const property of childNodes(node, \"properties\")) {\n if (property.type === \"SpreadElement\") {\n const argument = childNode(property, \"argument\");\n if (!argument) return unsupported(id, property);\n const spread = evaluateNode(resolver, id, argument, state);\n if (!spread.ok) return spread;\n if (!spread.value || typeof spread.value !== \"object\" || Array.isArray(spread.value)) {\n return {\n ok: false,\n bailout: localBailout(\n \"local/non-object-spread\",\n spanOf(id, property),\n \"Static object spread did not evaluate to an object\"\n )\n };\n }\n Object.assign(output, spread.value);\n continue;\n }\n if (property.type !== \"Property\" && property.type !== \"ObjectProperty\") {\n return unsupported(id, property);\n }\n const keyNode = childNode(property, \"key\");\n const valueNode = childNode(property, \"value\");\n if (!keyNode || !valueNode) return unsupported(id, property);\n let key = identifierName(keyNode) ?? void 0;\n if (property.computed === true || key === void 0) {\n const evaluatedKey = evaluateNode(resolver, id, keyNode, state);\n if (!evaluatedKey.ok) return evaluatedKey;\n key = evaluatedKey.value;\n }\n if (typeof key !== \"string\" && typeof key !== \"number\") {\n return unsupported(id, keyNode, \"Static object key is not a string or number\");\n }\n const value = evaluateNode(resolver, id, valueNode, state);\n if (!value.ok) return value;\n output[String(key)] = value.value;\n }\n return success(output);\n}\nfunction evaluateArray(resolver, id, node, state) {\n const output = [];\n const rawElements = node.elements;\n if (!Array.isArray(rawElements) || rawElements.some((element) => element === null || !isAstNode(element))) {\n return unsupported(id, node, \"Sparse arrays are not statically supported\");\n }\n for (const element of rawElements.filter(isAstNode)) {\n if (element.type === \"SpreadElement\") {\n const argument = childNode(element, \"argument\");\n if (!argument) return unsupported(id, element);\n const spread = evaluateNode(resolver, id, argument, state);\n if (!spread.ok) return spread;\n if (!Array.isArray(spread.value)) {\n return unsupported(\n id,\n element,\n \"Static array spread did not evaluate to an array\"\n );\n }\n output.push(...spread.value);\n continue;\n }\n const value = evaluateNode(resolver, id, element, state);\n if (!value.ok) return value;\n output.push(value.value);\n }\n return success(output);\n}\nfunction evaluateNode(resolver, id, input, state) {\n const node = unwrapExpression(input);\n const literalValue = literal(node);\n if (literalValue !== void 0) return success(literalValue);\n switch (node.type) {\n case \"Identifier\": {\n const name = identifierName(node);\n if (!name) return unsupported(id, node);\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n spanOf(id, node),\n `Binding ${name} has no host-linked definition`\n )\n };\n }\n return evaluateDefinition(resolver, definition, spanOf(id, node), state);\n }\n case \"ObjectExpression\":\n return evaluateObject(resolver, id, node, state);\n case \"ArrayExpression\":\n return evaluateArray(resolver, id, node, state);\n case \"MemberExpression\": {\n const objectNode = childNode(node, \"object\");\n const propertyNode = childNode(node, \"property\");\n if (!objectNode || !propertyNode) return unsupported(id, node);\n const object = evaluateNode(resolver, id, objectNode, state);\n if (!object.ok) return object;\n let property = identifierName(propertyNode);\n if (node.computed === true || property === null) {\n const evaluatedProperty = evaluateNode(resolver, id, propertyNode, state);\n if (!evaluatedProperty.ok) return evaluatedProperty;\n property = evaluatedProperty.value;\n }\n if ((typeof object.value !== \"object\" || object.value === null) && typeof object.value !== \"string\") {\n return unsupported(id, node, \"Static member target is not indexable\");\n }\n if (typeof property !== \"string\" && typeof property !== \"number\") {\n return unsupported(\n id,\n propertyNode,\n \"Static member key is not a string or number\"\n );\n }\n const value = object.value[String(property)];\n return value === void 0 ? unsupported(id, node, `Static member ${String(property)} does not exist`) : success(value);\n }\n case \"UnaryExpression\": {\n const argument = childNode(node, \"argument\");\n if (!argument) return unsupported(id, node);\n const value = evaluateNode(resolver, id, argument, state);\n if (!value.ok) return value;\n if (node.operator === \"-\" && typeof value.value === \"number\") {\n return success(-value.value);\n }\n if (node.operator === \"+\" && typeof value.value === \"number\") {\n return success(value.value);\n }\n if (node.operator === \"!\") return success(!value.value);\n return unsupported(\n id,\n node,\n `Unary operator ${String(node.operator)} is unsupported`\n );\n }\n case \"BinaryExpression\":\n case \"LogicalExpression\": {\n const leftNode = childNode(node, \"left\");\n const rightNode = childNode(node, \"right\");\n if (!leftNode || !rightNode) return unsupported(id, node);\n const left = evaluateNode(resolver, id, leftNode, state);\n if (!left.ok) return left;\n if (node.type === \"LogicalExpression\") {\n if (node.operator === \"&&\" && !left.value) return left;\n if (node.operator === \"||\" && left.value) return left;\n if (node.operator === \"??\" && left.value !== null) return left;\n }\n const right = evaluateNode(resolver, id, rightNode, state);\n if (!right.ok) return right;\n switch (node.operator) {\n case \"+\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value + right.value);\n }\n if (typeof left.value === \"string\" || typeof right.value === \"string\") {\n return success(String(left.value) + String(right.value));\n }\n break;\n case \"-\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value - right.value);\n }\n break;\n case \"*\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value * right.value);\n }\n break;\n case \"/\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value / right.value);\n }\n break;\n case \"&&\":\n case \"||\":\n case \"??\":\n return right;\n }\n return unsupported(\n id,\n node,\n `Binary operator ${String(node.operator)} is unsupported`\n );\n }\n case \"ConditionalExpression\": {\n const testNode = childNode(node, \"test\");\n const consequent = childNode(node, \"consequent\");\n const alternate = childNode(node, \"alternate\");\n if (!testNode || !consequent || !alternate) return unsupported(id, node);\n const test = evaluateNode(resolver, id, testNode, state);\n if (!test.ok) return test;\n return evaluateNode(resolver, id, test.value ? consequent : alternate, state);\n }\n case \"TemplateLiteral\": {\n const quasis = childNodes(node, \"quasis\");\n const expressions = childNodes(node, \"expressions\");\n let output = \"\";\n for (let index = 0; index < quasis.length; index++) {\n output += quasiText(quasis[index]);\n const expression = expressions[index];\n if (expression) {\n const value = evaluateNode(resolver, id, expression, state);\n if (!value.ok) return value;\n output += String(value.value);\n }\n }\n return success(output);\n }\n default:\n return unsupported(id, node);\n }\n}\nfunction quasiText(quasi) {\n const cooked = quasi?.value?.cooked;\n const raw = quasi?.value?.raw;\n return typeof cooked === \"string\" ? cooked : typeof raw === \"string\" ? raw : \"\";\n}\nfunction dynamicPrimitive(value) {\n if (value === null) return \"null\";\n if (typeof value === \"number\") return \"number\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"boolean\") return \"boolean\";\n return null;\n}\nfunction evaluateDynamicNode(resolver, id, input, state) {\n const exact = evaluateNode(resolver, id, input, state);\n if (exact.ok) {\n const type = dynamicPrimitive(exact.value);\n return type ? { type, values: [exact.value] } : null;\n }\n const node = unwrapExpression(input);\n if (node.type === \"Identifier\") {\n if (!identifierName(node)) return null;\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition?.constant || !definition.initializer) return null;\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) return null;\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) return null;\n state.dependencies.add(definition.id);\n state.activeDefinitions.add(key);\n try {\n return evaluateDynamicNode(resolver, definition.id, initializer, state);\n } finally {\n state.activeDefinitions.delete(key);\n }\n }\n if (node.type === \"MemberExpression\") {\n const objectNode = childNode(node, \"object\");\n const propertyNode = childNode(node, \"property\");\n if (!objectNode || !propertyNode) return null;\n const object = evaluateNode(resolver, id, objectNode, state);\n if (!object.ok || !Array.isArray(object.value)) return null;\n const property = evaluateDynamicNode(resolver, id, propertyNode, state);\n if (property?.type !== \"number\" || object.value.length > 32) return null;\n const values = [];\n let type = null;\n for (const value of object.value) {\n const nextType = dynamicPrimitive(value);\n if (!nextType || type && type !== nextType) return null;\n type = nextType;\n const primitive = value;\n if (!values.includes(primitive)) values.push(primitive);\n }\n return type ? { type, values } : null;\n }\n if (node.type === \"BinaryExpression\") {\n const leftNode = childNode(node, \"left\");\n const rightNode = childNode(node, \"right\");\n if (!leftNode || !rightNode) return null;\n const left = evaluateDynamicNode(resolver, id, leftNode, state);\n const right = evaluateDynamicNode(resolver, id, rightNode, state);\n if (node.operator === \"+\") {\n return left?.type === \"number\" && right?.type === \"number\" ? { type: \"number\" } : null;\n }\n if (node.operator === \"-\" || node.operator === \"*\" || node.operator === \"/\" || node.operator === \"%\" || node.operator === \"**\") {\n if (left?.type === \"number\" || right?.type === \"number\") {\n return { type: \"number\" };\n }\n }\n }\n if (node.type === \"TemplateLiteral\") {\n const quasis = childNodes(node, \"quasis\");\n const expressions = childNodes(node, \"expressions\");\n let values = [\"\"];\n for (let position = 0; position < quasis.length; position++) {\n const text = quasiText(quasis[position]);\n values = values.map((value) => value + text);\n const expression = expressions[position];\n if (!expression) continue;\n const part = evaluateDynamicNode(resolver, id, expression, state);\n if (!part?.values) return null;\n const next = [];\n for (const value of values) {\n for (const primitive of part.values) {\n const joined = value + String(primitive);\n if (!next.includes(joined)) next.push(joined);\n }\n }\n if (next.length > 32) return null;\n values = next;\n }\n return { type: \"string\", values };\n }\n return null;\n}\nfunction collectLeaves(node) {\n if (node.kind === \"leaf\") return [node];\n return [...collectLeaves(node.whenTrue), ...collectLeaves(node.whenFalse)];\n}\nfunction collectBranchDependencies(node) {\n if (node.kind === \"leaf\") return node.dependencies;\n return [\n .../* @__PURE__ */ new Set([\n ...collectBranchDependencies(node.whenTrue),\n ...collectBranchDependencies(node.whenFalse)\n ])\n ].sort();\n}\nfunction evaluateBranchChild(resolver, id, node, depth, state, sourceId) {\n const leafState = {\n activeDefinitions: new Set(state.activeDefinitions),\n dependencies: new Set(state.dependencies)\n };\n const leafRes = evaluateNode(resolver, id, node, leafState);\n if (leafRes.ok) {\n return {\n kind: \"leaf\",\n value: leafRes.value,\n dependencies: [...leafState.dependencies].sort()\n };\n }\n return evaluateBranchesNode(resolver, id, node, depth + 1, leafState, sourceId);\n}\nfunction evaluateBranchesNode(resolver, id, input, depth, state, sourceId) {\n const node = unwrapExpression(input);\n if (!isAstNode(node)) return null;\n if (node.type === \"Identifier\") {\n if (!identifierName(node)) return null;\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition || !definition.constant || !definition.initializer) return null;\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) return null;\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) return null;\n state.activeDefinitions.add(key);\n state.dependencies.add(definition.id);\n try {\n return evaluateBranchesNode(\n resolver,\n definition.id,\n initializer,\n depth,\n state,\n sourceId\n );\n } finally {\n state.activeDefinitions.delete(key);\n }\n }\n if (depth >= 3) return null;\n if (node.type === \"ConditionalExpression\") {\n const testNode = childNode(node, \"test\");\n const consequent = childNode(node, \"consequent\");\n const alternate = childNode(node, \"alternate\");\n if (!testNode || !consequent || !alternate) return null;\n const test = spanOf(id, testNode);\n if (test.id !== sourceId) return null;\n const whenTrue = evaluateBranchChild(resolver, id, consequent, depth, state, sourceId);\n if (!whenTrue) return null;\n const whenFalse = evaluateBranchChild(resolver, id, alternate, depth, state, sourceId);\n if (!whenFalse) return null;\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n if (node.type === \"TemplateLiteral\") {\n return templateBranchesNode(\n resolver,\n id,\n childNodes(node, \"quasis\"),\n childNodes(node, \"expressions\"),\n 0,\n \"\",\n depth,\n state,\n sourceId\n );\n }\n if (node.type === \"LogicalExpression\") {\n const left = childNode(node, \"left\");\n const right = childNode(node, \"right\");\n if (!left || !right) return null;\n if (node.operator === \"&&\") {\n const test = spanOf(id, left);\n if (test.id !== sourceId) return null;\n const whenTrue = evaluateBranchChild(resolver, id, right, depth, state, sourceId);\n if (!whenTrue) return null;\n const whenFalse = {\n kind: \"leaf\",\n value: void 0,\n dependencies: [...state.dependencies].sort()\n };\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n if (node.operator === \"||\" || node.operator === \"??\") {\n const test = spanOf(id, left);\n if (test.id !== sourceId) return null;\n const leftState = {\n activeDefinitions: new Set(state.activeDefinitions),\n dependencies: new Set(state.dependencies)\n };\n const leftRes = evaluateNode(resolver, id, left, leftState);\n if (!leftRes.ok) return null;\n const whenTrue = {\n kind: \"leaf\",\n value: leftRes.value,\n dependencies: [...leftState.dependencies].sort()\n };\n const whenFalse = evaluateBranchChild(resolver, id, right, depth, state, sourceId);\n if (!whenFalse) return null;\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n }\n return null;\n}\nfunction mapBranchLeaves(node, map) {\n if (node.kind === \"leaf\") return map(node);\n const whenTrue = mapBranchLeaves(node.whenTrue, map);\n if (!whenTrue) return null;\n const whenFalse = mapBranchLeaves(node.whenFalse, map);\n if (!whenFalse) return null;\n return { kind: \"branch\", test: node.test, whenTrue, whenFalse };\n}\nfunction templateBranchesNode(resolver, id, quasis, expressions, index, prefix, depth, state, sourceId) {\n let text = prefix;\n for (let position = index; position < quasis.length; position++) {\n text += quasiText(quasis[position]);\n const expression = expressions[position];\n if (!expression) continue;\n const exact = evaluateNode(resolver, id, expression, state);\n if (exact.ok) {\n const interpolated = templateInterpolation(exact.value);\n if (interpolated === null) return null;\n text += interpolated;\n continue;\n }\n const tree = evaluateBranchesNode(\n resolver,\n id,\n expression,\n depth + 1,\n state,\n sourceId\n );\n if (!tree) return null;\n return mapBranchLeaves(tree, (leaf) => {\n if (leaf.value === void 0) return null;\n const interpolated = templateInterpolation(leaf.value);\n if (interpolated === null) return null;\n return templateBranchesNode(\n resolver,\n id,\n quasis,\n expressions,\n position + 1,\n text + interpolated,\n depth + 1,\n state,\n sourceId\n );\n });\n }\n return { kind: \"leaf\", value: text, dependencies: [...state.dependencies].sort() };\n}\nfunction templateInterpolation(value) {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n return null;\n}\nfunction evaluateBranches(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) return null;\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const tree = evaluateBranchesNode(resolver, reference.id, node, 0, state, reference.id);\n return tree?.kind === \"branch\" ? tree : null;\n}\nfunction evaluateExpression(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n reference,\n \"Expression is outside the linked project graph\",\n reference.id\n )\n };\n }\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const result = evaluateNode(resolver, reference.id, node, state);\n return result.ok ? {\n ok: true,\n value: result.value,\n dependencies: [...state.dependencies].sort()\n } : result;\n}\nfunction evaluateDynamicExpression(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) return null;\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const result = evaluateDynamicNode(resolver, reference.id, node, state);\n return result ? { ...result, dependencies: [...state.dependencies].sort() } : null;\n}\nfunction evaluateBinding(resolver, id, localName) {\n const definition = resolver.resolveBinding(id, localName);\n if (!definition) {\n const emptySpan = { id, start: 0, end: 0 };\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n emptySpan,\n `Binding ${localName} has no host-linked definition`\n )\n };\n }\n if (!definition.initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n definition.span,\n `Binding ${localName} has no static initializer`,\n definition.id\n )\n };\n }\n return evaluateExpression(\n resolver,\n expressionReference(definition.id, definition.initializer)\n );\n}\nexport {\n collectBranchDependencies,\n collectLeaves,\n evaluateBinding,\n evaluateBranches,\n evaluateDynamicExpression,\n evaluateExpression\n};\n//# sourceMappingURL=evaluate.js.map\n"],"mappings":";;;;;AAGA,SAAS,QAAQ,OAAO;CACtB,OAAO;EAAE,IAAI;EAAM;CAAM;AAC3B;AACA,SAAS,QAAQ,MAAM;CACrB,IAAI,KAAK,SAAS,eAAe,OAAO;CACxC,IAAI,KAAK,SAAS,aAAa,KAAK,KAAK,SAAS,SAAS,GAAG;EAC5D,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,UAAU,MAAM;GAC1G,OAAO;EACT;CACF;CACA,OAAO,KAAK;AACd;AACA,SAAS,YAAY,IAAI,MAAM,SAAS,cAAc,KAAK,KAAK,+BAA+B;CAC7F,OAAO;EACL,IAAI;EACJ,SAAS,aAAa,gCAAgC,OAAO,IAAI,IAAI,GAAG,MAAM;CAChF;AACF;AACA,SAAS,mBAAmB,UAAU,YAAY,SAAS,OAAO;CAChE,MAAM,MAAM,GAAG,WAAW,GAAG,GAAG,WAAW,KAAK;CAChD,IAAI,MAAM,kBAAkB,IAAI,GAAG,GAAG;EACpC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kDACA,UAAU,EACZ;EACF;CACF;CACA,MAAM,QAAQ;EACZ,mCAAmC,IAAI,IAAI;EAC3C,8BAA8B,IAAI,IAAI;CACxC;CACA,MAAM,SAAS,aAAa,UAAU,UAAU,IAAI,MAAM,KAAK;CAC/D,OAAO,OAAO,KAAK;EACjB,IAAI;EACJ,OAAO,OAAO;EACd,cAAc,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,KAAK;CAC7C,IAAI;AACN;AACA,SAAS,0BAA0B,UAAU,WAAW;CACtD,MAAM,OAAO,SAAS,eAAe,SAAS;CAC9C,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,QAAQ;EACZ,mCAAmC,IAAI,IAAI;EAC3C,8BAA8B,IAAI,IAAI;CACxC;CACA,MAAM,SAAS,oBAAoB,UAAU,UAAU,IAAI,MAAM,KAAK;CACtE,OAAO,SAAS;EAAE,GAAG;EAAQ,cAAc,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,KAAK;CAAE,IAAI;AAChF;AACA,SAAS,gBAAgB,UAAU,IAAI,WAAW;CAChD,MAAM,aAAa,SAAS,eAAe,IAAI,SAAS;CACxD,IAAI,CAAC,YAAY;EACf,MAAM,YAAY;GAAE;GAAI,OAAO;GAAG,KAAK;EAAE;EACzC,OAAO;GACL,IAAI;GACJ,SAAS,cACP,6BACA,WACA,WAAW,UAAU,+BACvB;EACF;CACF;CACA,IAAI,CAAC,WAAW,aAAa;EAC3B,OAAO;GACL,IAAI;GACJ,SAAS,cACP,8BACA,WAAW,MACX,WAAW,UAAU,6BACrB,WAAW,EACb;EACF;CACF;CACA,OAAO,mBACL,UACA,oBAAoB,WAAW,IAAI,WAAW,WAAW,CAC3D;AACF"}
1
+ {"version":3,"file":"evaluate.js","names":[],"sources":["esm/evaluate.js"],"sourcesContent":["import { childNode, childNodes, identifierName, isAstNode, unwrapExpression } from \"./ast\";\nimport { expressionReference, spanOf } from \"./contracts\";\nimport { linkedBailout, localBailout } from \"./diagnostics\";\nfunction success(value) {\n return { ok: true, value };\n}\nfunction literal(node) {\n if (node.type === \"NullLiteral\") return null;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n const value = node.value;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null) {\n return value;\n }\n }\n return void 0;\n}\nfunction unsupported(id, node, detail = `Expression ${node.type} is not statically supported`) {\n return {\n ok: false,\n bailout: localBailout(\"local/unsupported-expression\", spanOf(id, node), detail)\n };\n}\nfunction evaluateDefinition(resolver, definition, useSpan, state) {\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) {\n return {\n ok: false,\n bailout: localBailout(\n \"local/static-evaluation-cycle\",\n useSpan,\n `Static evaluation cycle reached ${definition.name}`\n )\n };\n }\n if (!definition.initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n useSpan,\n `Binding ${definition.name} has no static initializer`,\n definition.id\n )\n };\n }\n if (!definition.constant) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n useSpan,\n `Binding ${definition.name} is mutable and cannot be statically evaluated`,\n definition.id\n )\n };\n }\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n useSpan,\n `Binding ${definition.name} initializer is outside the linked graph`,\n definition.id\n )\n };\n }\n state.dependencies.add(definition.id);\n state.activeDefinitions.add(key);\n try {\n return evaluateNode(resolver, definition.id, initializer, state);\n } finally {\n state.activeDefinitions.delete(key);\n }\n}\nfunction evaluateObject(resolver, id, node, state) {\n const output = {};\n for (const property of childNodes(node, \"properties\")) {\n if (property.type === \"SpreadElement\") {\n const argument = childNode(property, \"argument\");\n if (!argument) return unsupported(id, property);\n const spread = evaluateNode(resolver, id, argument, state);\n if (!spread.ok) return spread;\n if (!spread.value || typeof spread.value !== \"object\" || Array.isArray(spread.value)) {\n return {\n ok: false,\n bailout: localBailout(\n \"local/non-object-spread\",\n spanOf(id, property),\n \"Static object spread did not evaluate to an object\"\n )\n };\n }\n Object.assign(output, spread.value);\n continue;\n }\n if (property.type !== \"Property\" && property.type !== \"ObjectProperty\") {\n return unsupported(id, property);\n }\n const keyNode = childNode(property, \"key\");\n const valueNode = childNode(property, \"value\");\n if (!keyNode || !valueNode) return unsupported(id, property);\n let key = identifierName(keyNode) ?? void 0;\n if (property.computed === true || key === void 0) {\n const evaluatedKey = evaluateNode(resolver, id, keyNode, state);\n if (!evaluatedKey.ok) return evaluatedKey;\n key = evaluatedKey.value;\n }\n if (typeof key !== \"string\" && typeof key !== \"number\") {\n return unsupported(id, keyNode, \"Static object key is not a string or number\");\n }\n const value = evaluateNode(resolver, id, valueNode, state);\n if (!value.ok) return value;\n output[String(key)] = value.value;\n }\n return success(output);\n}\nfunction evaluateArray(resolver, id, node, state) {\n const output = [];\n const rawElements = node.elements;\n if (!Array.isArray(rawElements) || rawElements.some((element) => element === null || !isAstNode(element))) {\n return unsupported(id, node, \"Sparse arrays are not statically supported\");\n }\n for (const element of rawElements.filter(isAstNode)) {\n if (element.type === \"SpreadElement\") {\n const argument = childNode(element, \"argument\");\n if (!argument) return unsupported(id, element);\n const spread = evaluateNode(resolver, id, argument, state);\n if (!spread.ok) return spread;\n if (!Array.isArray(spread.value)) {\n return unsupported(\n id,\n element,\n \"Static array spread did not evaluate to an array\"\n );\n }\n output.push(...spread.value);\n continue;\n }\n const value = evaluateNode(resolver, id, element, state);\n if (!value.ok) return value;\n output.push(value.value);\n }\n return success(output);\n}\nfunction evaluateNode(resolver, id, input, state) {\n const node = unwrapExpression(input);\n const literalValue = literal(node);\n if (literalValue !== void 0) return success(literalValue);\n switch (node.type) {\n case \"Identifier\": {\n const name = identifierName(node);\n if (!name) return unsupported(id, node);\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n spanOf(id, node),\n `Binding ${name} has no host-linked definition`\n )\n };\n }\n return evaluateDefinition(resolver, definition, spanOf(id, node), state);\n }\n case \"ObjectExpression\":\n return evaluateObject(resolver, id, node, state);\n case \"ArrayExpression\":\n return evaluateArray(resolver, id, node, state);\n case \"MemberExpression\": {\n const objectNode = childNode(node, \"object\");\n const propertyNode = childNode(node, \"property\");\n if (!objectNode || !propertyNode) return unsupported(id, node);\n const object = evaluateNode(resolver, id, objectNode, state);\n if (!object.ok) return object;\n let property = identifierName(propertyNode);\n if (node.computed === true || property === null) {\n const evaluatedProperty = evaluateNode(resolver, id, propertyNode, state);\n if (!evaluatedProperty.ok) return evaluatedProperty;\n property = evaluatedProperty.value;\n }\n if ((typeof object.value !== \"object\" || object.value === null) && typeof object.value !== \"string\") {\n return unsupported(id, node, \"Static member target is not indexable\");\n }\n if (typeof property !== \"string\" && typeof property !== \"number\") {\n return unsupported(\n id,\n propertyNode,\n \"Static member key is not a string or number\"\n );\n }\n const value = object.value[String(property)];\n return value === void 0 ? unsupported(id, node, `Static member ${String(property)} does not exist`) : success(value);\n }\n case \"UnaryExpression\": {\n const argument = childNode(node, \"argument\");\n if (!argument) return unsupported(id, node);\n const value = evaluateNode(resolver, id, argument, state);\n if (!value.ok) return value;\n if (node.operator === \"-\" && typeof value.value === \"number\") {\n return success(-value.value);\n }\n if (node.operator === \"+\" && typeof value.value === \"number\") {\n return success(value.value);\n }\n if (node.operator === \"!\") return success(!value.value);\n return unsupported(\n id,\n node,\n `Unary operator ${String(node.operator)} is unsupported`\n );\n }\n case \"BinaryExpression\":\n case \"LogicalExpression\": {\n const leftNode = childNode(node, \"left\");\n const rightNode = childNode(node, \"right\");\n if (!leftNode || !rightNode) return unsupported(id, node);\n const left = evaluateNode(resolver, id, leftNode, state);\n if (!left.ok) return left;\n if (node.type === \"LogicalExpression\") {\n if (node.operator === \"&&\" && !left.value) return left;\n if (node.operator === \"||\" && left.value) return left;\n if (node.operator === \"??\" && left.value !== null) return left;\n }\n const right = evaluateNode(resolver, id, rightNode, state);\n if (!right.ok) return right;\n switch (node.operator) {\n case \"+\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value + right.value);\n }\n if (typeof left.value === \"string\" || typeof right.value === \"string\") {\n return success(String(left.value) + String(right.value));\n }\n break;\n case \"-\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value - right.value);\n }\n break;\n case \"*\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value * right.value);\n }\n break;\n case \"/\":\n if (typeof left.value === \"number\" && typeof right.value === \"number\") {\n return success(left.value / right.value);\n }\n break;\n case \"&&\":\n case \"||\":\n case \"??\":\n return right;\n }\n return unsupported(\n id,\n node,\n `Binary operator ${String(node.operator)} is unsupported`\n );\n }\n case \"ConditionalExpression\": {\n const testNode = childNode(node, \"test\");\n const consequent = childNode(node, \"consequent\");\n const alternate = childNode(node, \"alternate\");\n if (!testNode || !consequent || !alternate) return unsupported(id, node);\n const test = evaluateNode(resolver, id, testNode, state);\n if (!test.ok) return test;\n return evaluateNode(resolver, id, test.value ? consequent : alternate, state);\n }\n case \"TemplateLiteral\": {\n const quasis = childNodes(node, \"quasis\");\n const expressions = childNodes(node, \"expressions\");\n let output = \"\";\n for (let index = 0; index < quasis.length; index++) {\n output += quasiText(quasis[index]);\n const expression = expressions[index];\n if (expression) {\n const value = evaluateNode(resolver, id, expression, state);\n if (!value.ok) return value;\n output += String(value.value);\n }\n }\n return success(output);\n }\n default:\n return unsupported(id, node);\n }\n}\nfunction quasiText(quasi) {\n const cooked = quasi?.value?.cooked;\n const raw = quasi?.value?.raw;\n return typeof cooked === \"string\" ? cooked : typeof raw === \"string\" ? raw : \"\";\n}\nfunction dynamicPrimitive(value) {\n if (value === null) return \"null\";\n if (typeof value === \"number\") return \"number\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"boolean\") return \"boolean\";\n return null;\n}\nfunction evaluateDynamicNode(resolver, id, input, state) {\n const exact = evaluateNode(resolver, id, input, state);\n if (exact.ok) {\n const type = dynamicPrimitive(exact.value);\n return type ? { type, values: [exact.value] } : null;\n }\n const node = unwrapExpression(input);\n if (node.type === \"Identifier\") {\n if (!identifierName(node)) return null;\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition?.constant || !definition.initializer) return null;\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) return null;\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) return null;\n state.dependencies.add(definition.id);\n state.activeDefinitions.add(key);\n try {\n return evaluateDynamicNode(resolver, definition.id, initializer, state);\n } finally {\n state.activeDefinitions.delete(key);\n }\n }\n if (node.type === \"MemberExpression\") {\n const objectNode = childNode(node, \"object\");\n const propertyNode = childNode(node, \"property\");\n if (!objectNode || !propertyNode) return null;\n const object = evaluateNode(resolver, id, objectNode, state);\n if (!object.ok || !Array.isArray(object.value)) return null;\n const property = evaluateDynamicNode(resolver, id, propertyNode, state);\n if (property?.type !== \"number\" || object.value.length > 32) return null;\n const values = [];\n let type = null;\n for (const value of object.value) {\n const nextType = dynamicPrimitive(value);\n if (!nextType || type && type !== nextType) return null;\n type = nextType;\n const primitive = value;\n if (!values.includes(primitive)) values.push(primitive);\n }\n return type ? { type, values } : null;\n }\n if (node.type === \"BinaryExpression\") {\n const leftNode = childNode(node, \"left\");\n const rightNode = childNode(node, \"right\");\n if (!leftNode || !rightNode) return null;\n const left = evaluateDynamicNode(resolver, id, leftNode, state);\n const right = evaluateDynamicNode(resolver, id, rightNode, state);\n if (node.operator === \"+\") {\n return left?.type === \"number\" && right?.type === \"number\" ? { type: \"number\" } : null;\n }\n if (node.operator === \"-\" || node.operator === \"*\" || node.operator === \"/\" || node.operator === \"%\" || node.operator === \"**\") {\n if (left?.type === \"number\" || right?.type === \"number\") {\n return { type: \"number\" };\n }\n }\n }\n if (node.type === \"TemplateLiteral\") {\n const quasis = childNodes(node, \"quasis\");\n const expressions = childNodes(node, \"expressions\");\n let values = [\"\"];\n for (let position = 0; position < quasis.length; position++) {\n const text = quasiText(quasis[position]);\n values = values.map((value) => value + text);\n const expression = expressions[position];\n if (!expression) continue;\n const part = evaluateDynamicNode(resolver, id, expression, state);\n if (!part?.values) return { type: \"string\" };\n const next = [];\n for (const value of values) {\n for (const primitive of part.values) {\n const joined = value + String(primitive);\n if (!next.includes(joined)) next.push(joined);\n }\n }\n if (next.length > 32) return { type: \"string\" };\n values = next;\n }\n return { type: \"string\", values };\n }\n return null;\n}\nfunction collectLeaves(node) {\n if (node.kind === \"leaf\") return [node];\n return [...collectLeaves(node.whenTrue), ...collectLeaves(node.whenFalse)];\n}\nfunction collectBranchDependencies(node) {\n if (node.kind === \"leaf\") return node.dependencies;\n return [\n .../* @__PURE__ */ new Set([\n ...collectBranchDependencies(node.whenTrue),\n ...collectBranchDependencies(node.whenFalse)\n ])\n ].sort();\n}\nfunction evaluateBranchChild(resolver, id, node, depth, state, sourceId) {\n const leafState = {\n activeDefinitions: new Set(state.activeDefinitions),\n dependencies: new Set(state.dependencies)\n };\n const leafRes = evaluateNode(resolver, id, node, leafState);\n if (leafRes.ok) {\n return {\n kind: \"leaf\",\n value: leafRes.value,\n dependencies: [...leafState.dependencies].sort()\n };\n }\n return evaluateBranchesNode(resolver, id, node, depth + 1, leafState, sourceId);\n}\nfunction evaluateBranchesNode(resolver, id, input, depth, state, sourceId) {\n const node = unwrapExpression(input);\n if (!isAstNode(node)) return null;\n if (node.type === \"Identifier\") {\n if (!identifierName(node)) return null;\n const definition = resolver.resolveReference(expressionReference(id, node));\n if (!definition || !definition.constant || !definition.initializer) return null;\n const initializer = resolver.expressionNode(definition.initializer);\n if (!initializer) return null;\n const key = `${definition.id}:${definition.span.start}`;\n if (state.activeDefinitions.has(key)) return null;\n state.activeDefinitions.add(key);\n state.dependencies.add(definition.id);\n try {\n return evaluateBranchesNode(\n resolver,\n definition.id,\n initializer,\n depth,\n state,\n sourceId\n );\n } finally {\n state.activeDefinitions.delete(key);\n }\n }\n if (depth >= 3) return null;\n if (node.type === \"ConditionalExpression\") {\n const testNode = childNode(node, \"test\");\n const consequent = childNode(node, \"consequent\");\n const alternate = childNode(node, \"alternate\");\n if (!testNode || !consequent || !alternate) return null;\n const test = spanOf(id, testNode);\n if (test.id !== sourceId) return null;\n const whenTrue = evaluateBranchChild(resolver, id, consequent, depth, state, sourceId);\n if (!whenTrue) return null;\n const whenFalse = evaluateBranchChild(resolver, id, alternate, depth, state, sourceId);\n if (!whenFalse) return null;\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n if (node.type === \"TemplateLiteral\") {\n return templateBranchesNode(\n resolver,\n id,\n childNodes(node, \"quasis\"),\n childNodes(node, \"expressions\"),\n 0,\n \"\",\n depth,\n state,\n sourceId\n );\n }\n if (node.type === \"LogicalExpression\") {\n const left = childNode(node, \"left\");\n const right = childNode(node, \"right\");\n if (!left || !right) return null;\n if (node.operator === \"&&\") {\n const test = spanOf(id, left);\n if (test.id !== sourceId) return null;\n const whenTrue = evaluateBranchChild(resolver, id, right, depth, state, sourceId);\n if (!whenTrue) return null;\n const whenFalse = {\n kind: \"leaf\",\n value: void 0,\n dependencies: [...state.dependencies].sort()\n };\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n if (node.operator === \"||\" || node.operator === \"??\") {\n const test = spanOf(id, left);\n if (test.id !== sourceId) return null;\n const leftState = {\n activeDefinitions: new Set(state.activeDefinitions),\n dependencies: new Set(state.dependencies)\n };\n const leftRes = evaluateNode(resolver, id, left, leftState);\n if (!leftRes.ok) return null;\n const whenTrue = {\n kind: \"leaf\",\n value: leftRes.value,\n dependencies: [...leftState.dependencies].sort()\n };\n const whenFalse = evaluateBranchChild(resolver, id, right, depth, state, sourceId);\n if (!whenFalse) return null;\n return {\n kind: \"branch\",\n test,\n whenTrue,\n whenFalse\n };\n }\n }\n return null;\n}\nfunction mapBranchLeaves(node, map) {\n if (node.kind === \"leaf\") return map(node);\n const whenTrue = mapBranchLeaves(node.whenTrue, map);\n if (!whenTrue) return null;\n const whenFalse = mapBranchLeaves(node.whenFalse, map);\n if (!whenFalse) return null;\n return { kind: \"branch\", test: node.test, whenTrue, whenFalse };\n}\nfunction templateBranchesNode(resolver, id, quasis, expressions, index, prefix, depth, state, sourceId) {\n let text = prefix;\n for (let position = index; position < quasis.length; position++) {\n text += quasiText(quasis[position]);\n const expression = expressions[position];\n if (!expression) continue;\n const exact = evaluateNode(resolver, id, expression, state);\n if (exact.ok) {\n const interpolated = templateInterpolation(exact.value);\n if (interpolated === null) return null;\n text += interpolated;\n continue;\n }\n const tree = evaluateBranchesNode(\n resolver,\n id,\n expression,\n depth + 1,\n state,\n sourceId\n );\n if (!tree) return null;\n return mapBranchLeaves(tree, (leaf) => {\n if (leaf.value === void 0) return null;\n const interpolated = templateInterpolation(leaf.value);\n if (interpolated === null) return null;\n return templateBranchesNode(\n resolver,\n id,\n quasis,\n expressions,\n position + 1,\n text + interpolated,\n depth + 1,\n state,\n sourceId\n );\n });\n }\n return { kind: \"leaf\", value: text, dependencies: [...state.dependencies].sort() };\n}\nfunction templateInterpolation(value) {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n return null;\n}\nfunction evaluateBranches(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) return null;\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const tree = evaluateBranchesNode(resolver, reference.id, node, 0, state, reference.id);\n return tree?.kind === \"branch\" ? tree : null;\n}\nfunction evaluateExpression(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n reference,\n \"Expression is outside the linked project graph\",\n reference.id\n )\n };\n }\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const result = evaluateNode(resolver, reference.id, node, state);\n return result.ok ? {\n ok: true,\n value: result.value,\n dependencies: [...state.dependencies].sort()\n } : result;\n}\nfunction evaluateDynamicExpression(resolver, reference) {\n const node = resolver.expressionNode(reference);\n if (!node) return null;\n const state = {\n activeDefinitions: /* @__PURE__ */ new Set(),\n dependencies: /* @__PURE__ */ new Set()\n };\n const result = evaluateDynamicNode(resolver, reference.id, node, state);\n return result ? { ...result, dependencies: [...state.dependencies].sort() } : null;\n}\nfunction evaluateBinding(resolver, id, localName) {\n const definition = resolver.resolveBinding(id, localName);\n if (!definition) {\n const emptySpan = { id, start: 0, end: 0 };\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/unresolved-binding\",\n emptySpan,\n `Binding ${localName} has no host-linked definition`\n )\n };\n }\n if (!definition.initializer) {\n return {\n ok: false,\n bailout: linkedBailout(\n \"linked/missing-initializer\",\n definition.span,\n `Binding ${localName} has no static initializer`,\n definition.id\n )\n };\n }\n return evaluateExpression(\n resolver,\n expressionReference(definition.id, definition.initializer)\n );\n}\nexport {\n collectBranchDependencies,\n collectLeaves,\n evaluateBinding,\n evaluateBranches,\n evaluateDynamicExpression,\n evaluateExpression\n};\n//# sourceMappingURL=evaluate.js.map\n"],"mappings":";;;;;AAGA,SAAS,QAAQ,OAAO;CACtB,OAAO;EAAE,IAAI;EAAM;CAAM;AAC3B;AACA,SAAS,QAAQ,MAAM;CACrB,IAAI,KAAK,SAAS,eAAe,OAAO;CACxC,IAAI,KAAK,SAAS,aAAa,KAAK,KAAK,SAAS,SAAS,GAAG;EAC5D,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,UAAU,MAAM;GAC1G,OAAO;EACT;CACF;CACA,OAAO,KAAK;AACd;AACA,SAAS,YAAY,IAAI,MAAM,SAAS,cAAc,KAAK,KAAK,+BAA+B;CAC7F,OAAO;EACL,IAAI;EACJ,SAAS,aAAa,gCAAgC,OAAO,IAAI,IAAI,GAAG,MAAM;CAChF;AACF;AACA,SAAS,mBAAmB,UAAU,YA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  import { localBailout } from "./diagnostics.mjs";
2
2
  import { sourceContentHash, validateSourceEdits } from "./output.mjs";
3
3
 
4
- const LOWERED_MODULE_PLAN_VERSION = 3;
4
+ const LOWERED_MODULE_PLAN_VERSION = 5;
5
5
  function compareCodeUnits(left, right) {
6
6
  return left < right ? -1 : left > right ? 1 : 0;
7
7
  }
@@ -28,13 +28,13 @@ function unsafeEntry(element, entry, component, host) {
28
28
  if (entry.kind === "spread" && entry.value.kind !== "static") {
29
29
  return diagnostic("local/unsafe-style-spread", element, "Unevaluated spread may change style and duplicate-prop precedence");
30
30
  }
31
- if (entry.kind === "prop" && host.isStyleProp(entry.name, component) && (entry.value.kind === "bailout" || entry.value.kind === "conditional") && !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind)) {
31
+ if (entry.kind === "prop" && host.isStyleProp(entry.name, component) && (entry.value.kind === "bailout" || entry.value.kind === "conditional") && !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind, entry.value.kind === "bailout" ? entry.value.dynamic : null)) {
32
32
  return diagnostic("local/dynamic-style-value", element, `Style prop ${entry.name} could not be evaluated`, entry.name);
33
33
  }
34
34
  if (entry.kind === "prop" && entry.value.kind === "object") {
35
35
  for (const member of entry.value.members) {
36
36
  if (member.value.kind !== "bailout" && member.value.kind !== "conditional") continue;
37
- if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind)) {
37
+ if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind, member.value.kind === "bailout" ? member.value.dynamic : null)) {
38
38
  return diagnostic("local/dynamic-style-value", element, `Style prop ${member.name} could not be evaluated`, member.name);
39
39
  }
40
40
  }
@@ -191,7 +191,7 @@ function lowerModule({ module, source, target, host, options, structuralPass })
191
191
  });
192
192
  }
193
193
  return {
194
- version: 3,
194
+ version: 5,
195
195
  id: module.id,
196
196
  target,
197
197
  inputHash: module.inputHash,
@@ -1 +1 @@
1
- {"version":3,"file":"lower.js","names":[],"sources":["esm/lower.js"],"sourcesContent":["import { localBailout } from \"./diagnostics\";\nimport {\n sourceContentHash,\n validateSourceEdits\n} from \"./output\";\nconst LOWERED_MODULE_PLAN_VERSION = 3;\nfunction compareCodeUnits(left, right) {\n return left < right ? -1 : left > right ? 1 : 0;\n}\nfunction blocking(reason) {\n return { ...reason, blocking: true };\n}\nfunction diagnostic(code, element, message, prop) {\n return {\n ...localBailout(code, element.span, message),\n component: element.component.name,\n specifier: element.component.provenance?.specifier,\n prop\n };\n}\nfunction styledDefinitionFor(module, element) {\n const definition = element.component.definition;\n if (!definition) return null;\n return module.styledDefinitions.find(\n (candidate) => candidate.id === definition.id && candidate.name === definition.name\n ) ?? null;\n}\nfunction unsafeEntry(element, entry, component, host) {\n if (entry.kind === \"spread\" && entry.value.kind !== \"static\") {\n return diagnostic(\n \"local/unsafe-style-spread\",\n element,\n \"Unevaluated spread may change style and duplicate-prop precedence\"\n );\n }\n if (entry.kind === \"prop\" && host.isStyleProp(entry.name, component) && (entry.value.kind === \"bailout\" || entry.value.kind === \"conditional\") && !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind)) {\n return diagnostic(\n \"local/dynamic-style-value\",\n element,\n `Style prop ${entry.name} could not be evaluated`,\n entry.name\n );\n }\n if (entry.kind === \"prop\" && entry.value.kind === \"object\") {\n for (const member of entry.value.members) {\n if (member.value.kind !== \"bailout\" && member.value.kind !== \"conditional\") continue;\n if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind)) {\n return diagnostic(\n \"local/dynamic-style-value\",\n element,\n `Style prop ${member.name} could not be evaluated`,\n member.name\n );\n }\n }\n }\n return null;\n}\nfunction editsAreCandidateLocal(element, edits) {\n return edits.every(\n (edit) => edit.origin.id === element.id && edit.start >= element.span.start && edit.end <= element.span.end\n );\n}\nfunction overlapsCommitted(edits, committed) {\n return edits.some(\n (edit) => committed.some((existing) => {\n if (edit.start === edit.end) {\n return edit.start > existing.start && edit.start < existing.end;\n }\n if (existing.start === existing.end) {\n return existing.start > edit.start && existing.start < edit.end;\n }\n return edit.start < existing.end && existing.start < edit.end;\n })\n );\n}\nfunction lowerModule({\n module,\n source,\n target,\n host,\n options,\n structuralPass\n}) {\n const stats = {\n found: 0,\n lowered: 0,\n flattened: 0,\n styled: 0,\n bailed: 0\n };\n const structural = structuralPass ? structuralPass.transform({ module, source, target }) : {\n module,\n edits: [],\n imports: [],\n diagnostics: [],\n dependencies: []\n };\n if (structural.module.id !== module.id) {\n throw new Error(\n `Structural pass changed module identity from ${module.id} to ${structural.module.id}`\n );\n }\n if (structuralPass && !structuralPass.versionHash) {\n throw new Error(\"Structural pass must provide a non-empty version hash\");\n }\n module = structural.module;\n validateSourceEdits(source, structural.edits);\n const edits = [...structural.edits];\n const css = /* @__PURE__ */ new Set();\n const diagnostics = [...module.diagnostics, ...structural.diagnostics];\n const dependencies = /* @__PURE__ */ new Set([...module.dependencies, ...structural.dependencies]);\n const imports = new Map(\n structural.imports.map((candidateImport) => [\n candidateImport.content,\n candidateImport\n ])\n );\n for (const element of module.elements) {\n const styledDefinition = styledDefinitionFor(module, element);\n const component = host.resolveComponent(element, styledDefinition);\n if (!component) continue;\n stats.found++;\n const input = {\n id: module.id,\n source,\n target,\n module,\n element,\n styledDefinition,\n component\n };\n const commitDevelopmentDebug = (result2) => {\n const debugEdits = host.developmentDebugInstrumentation?.(input, result2);\n if (!debugEdits) return;\n validateSourceEdits(source, debugEdits);\n if (!editsAreCandidateLocal(element, debugEdits) || overlapsCommitted(debugEdits, edits)) {\n throw new Error(\"Development debug instrumentation must stay candidate-local\");\n }\n edits.push(...debugEdits);\n };\n if (!element.complete || styledDefinition && !styledDefinition.complete) {\n const reasons = [\n ...element.bailouts.map(blocking),\n ...(styledDefinition?.bailouts ?? []).map(blocking)\n ];\n diagnostics.push(...reasons);\n const reason = reasons[0];\n if (reason) commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n const unsafe = element.entries.map((entry) => unsafeEntry(element, entry, component, host)).find((result2) => result2 !== null);\n if (unsafe) {\n diagnostics.push(blocking(unsafe));\n commitDevelopmentDebug({ ok: false, bailout: blocking(unsafe) });\n stats.bailed++;\n continue;\n }\n let result;\n try {\n result = host.lowerCandidate(input);\n } catch (error) {\n result = {\n ok: false,\n bailout: diagnostic(\n \"local/style-resolution-failed\",\n element,\n `Style resolution failed: ${error instanceof Error ? error.message : String(error)}`\n )\n };\n }\n if (!result.ok) {\n diagnostics.push(blocking(result.bailout));\n commitDevelopmentDebug(result);\n stats.bailed++;\n continue;\n }\n try {\n validateSourceEdits(source, result.edits);\n } catch (error) {\n const reason = blocking(\n diagnostic(\n \"local/overlapping-edit\",\n element,\n error instanceof Error ? error.message : String(error)\n )\n );\n diagnostics.push(reason);\n commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n if (!editsAreCandidateLocal(element, result.edits) || overlapsCommitted(result.edits, edits)) {\n const reason = blocking(\n diagnostic(\n \"local/overlapping-edit\",\n element,\n \"Candidate edits overlap another candidate or escape the element span\"\n )\n );\n diagnostics.push(reason);\n commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n diagnostics.push(...result.diagnostics ?? []);\n edits.push(...result.edits);\n commitDevelopmentDebug(result);\n for (const rule of result.css) css.add(rule);\n for (const candidateImport of result.imports) {\n if (!imports.has(candidateImport.content)) {\n imports.set(candidateImport.content, candidateImport);\n }\n }\n for (const dependency of result.dependencies ?? []) dependencies.add(dependency);\n stats.lowered++;\n if (result.flattened) stats.flattened++;\n if (styledDefinition) stats.styled++;\n }\n for (const candidateImport of imports.values()) {\n edits.push({\n start: source.length,\n end: source.length,\n content: candidateImport.content,\n origin: candidateImport.origin\n });\n }\n return {\n version: LOWERED_MODULE_PLAN_VERSION,\n id: module.id,\n target,\n inputHash: module.inputHash,\n sourceHash: sourceContentHash(source),\n projectGeneration: options.projectGeneration,\n structuralPassHash: structuralPass?.versionHash ?? `${target}-noop-v1`,\n edits,\n css: [...css].join(\"\"),\n diagnostics,\n dependencies: [...dependencies].sort(compareCodeUnits),\n stats\n };\n}\nexport {\n LOWERED_MODULE_PLAN_VERSION,\n lowerModule\n};\n//# sourceMappingURL=lower.js.map\n"],"mappings":";;;;AAKA,MAAM,8BAA8B;AACpC,SAAS,iBAAiB,MAAM,OAAO;CACrC,OAAO,OAAO,QAAQ,CAAC,IAAI,OAAO,QAAQ,IAAI;AAChD;AACA,SAAS,SAAS,QAAQ;CACxB,OAAO;EAAE,GAAG;EAAQ,UAAU;CAAK;AACrC;AACA,SAAS,WAAW,MAAM,SAAS,SAAS,MAAM;CAChD,OAAO;EACL,GAAG,aAAa,MAAM,QAAQ,MAAM,OAAO;EAC3C,WAAW,QAAQ,UAAU;EAC7B,WAAW,QAAQ,UAAU,YAAY;EACzC;CACF;AACF;AACA,SAAS,oBAAoB,QAAQ,SAAS;CAC5C,MAAM,aAAa,QAAQ,UAAU;CACrC,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,OAAO,kBAAkB,MAC7B,cAAc,UAAU,OAAO,WAAW,MAAM,UAAU,SAAS,WAAW,IACjF,KAAK;AACP;AACA,SAAS,YAAY,SAAS,OAAO,WAAW,MAAM;CACpD,IAAI,MAAM,SAAS,YAAY,MAAM,MAAM,SAAS,UAAU;EAC5D,OAAO,WACL,6BACA,SACA,mEACF;CACF;CACA,IAAI,MAAM,SAAS,UAAU,KAAK,YAAY,MAAM,MAAM,SAAS,MAAM,MAAM,MAAM,SAAS,aAAa,MAAM,MAAM,SAAS,kBAAkB,CAAC,KAAK,2BAA2B,MAAM,MAAM,WAAW,MAAM,MAAM,IAAI,GAAG;EAC3N,OAAO,WACL,6BACA,SACA,cAAc,MAAM,KAAK,0BACzB,MAAM,IACR;CACF;CACA,IAAI,MAAM,SAAS,UAAU,MAAM,MAAM,SAAS,UAAU;EAC1D,KAAK,MAAM,UAAU,MAAM,MAAM,SAAS;GACxC,IAAI,O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AI,gBAAgB,OAAO,GAAG;IACzC,QAAQ,IAAI,gBAAgB,SAAS,eAAe;GACtD;EACF;EACA,KAAK,MAAM,cAAc,OAAO,gBAAgB,CAAC,GAAG,aAAa,IAAI,UAAU;EAC/E,MAAM;EACN,IAAI,OAAO,WAAW,MAAM;EAC5B,IAAI,kBAAkB,MAAM;CAC9B;CACA,KAAK,MAAM,mBAAmB,QAAQ,OAAO,GAAG;EAC9C,MAAM,KAAK;GACT,OAAO,OAAO;GACd,KAAK,OAAO;GACZ,SAAS,gBAAgB;GACzB,QAAQ,gBAAgB;EAC1B,CAAC;CACH;CACA,OAAO;EACL;EACA,IAAI,OAAO;EACX;EACA,WAAW,OAAO;EAClB,YAAY,kBAAkB,MAAM;EACpC,mBAAmB,QAAQ;EAC3B,oBAAoB,gBAAgB,eAAe,GAAG,OAAO;EAC7D;EACA,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE;EACrB;EACA,cAAc,CAAC,GAAG,YAAY,CAAC,CAAC,KAAK,gBAAgB;EACrD;CACF;AACF"}
1
+ {"version":3,"file":"lower.js","names":[],"sources":["esm/lower.js"],"sourcesContent":["import { localBailout } from \"./diagnostics\";\nimport {\n sourceContentHash,\n validateSourceEdits\n} from \"./output\";\nconst LOWERED_MODULE_PLAN_VERSION = 5;\nfunction compareCodeUnits(left, right) {\n return left < right ? -1 : left > right ? 1 : 0;\n}\nfunction blocking(reason) {\n return { ...reason, blocking: true };\n}\nfunction diagnostic(code, element, message, prop) {\n return {\n ...localBailout(code, element.span, message),\n component: element.component.name,\n specifier: element.component.provenance?.specifier,\n prop\n };\n}\nfunction styledDefinitionFor(module, element) {\n const definition = element.component.definition;\n if (!definition) return null;\n return module.styledDefinitions.find(\n (candidate) => candidate.id === definition.id && candidate.name === definition.name\n ) ?? null;\n}\nfunction unsafeEntry(element, entry, component, host) {\n if (entry.kind === \"spread\" && entry.value.kind !== \"static\") {\n return diagnostic(\n \"local/unsafe-style-spread\",\n element,\n \"Unevaluated spread may change style and duplicate-prop precedence\"\n );\n }\n if (entry.kind === \"prop\" && host.isStyleProp(entry.name, component) && (entry.value.kind === \"bailout\" || entry.value.kind === \"conditional\") && !host.canLowerDynamicStyleProp?.(\n entry.name,\n component,\n entry.value.kind,\n entry.value.kind === \"bailout\" ? entry.value.dynamic : null\n )) {\n return diagnostic(\n \"local/dynamic-style-value\",\n element,\n `Style prop ${entry.name} could not be evaluated`,\n entry.name\n );\n }\n if (entry.kind === \"prop\" && entry.value.kind === \"object\") {\n for (const member of entry.value.members) {\n if (member.value.kind !== \"bailout\" && member.value.kind !== \"conditional\") continue;\n if (!host.isStyleProp(member.name, component) || !host.canLowerDynamicStyleProp?.(\n member.name,\n component,\n member.value.kind,\n member.value.kind === \"bailout\" ? member.value.dynamic : null\n )) {\n return diagnostic(\n \"local/dynamic-style-value\",\n element,\n `Style prop ${member.name} could not be evaluated`,\n member.name\n );\n }\n }\n }\n return null;\n}\nfunction editsAreCandidateLocal(element, edits) {\n return edits.every(\n (edit) => edit.origin.id === element.id && edit.start >= element.span.start && edit.end <= element.span.end\n );\n}\nfunction overlapsCommitted(edits, committed) {\n return edits.some(\n (edit) => committed.some((existing) => {\n if (edit.start === edit.end) {\n return edit.start > existing.start && edit.start < existing.end;\n }\n if (existing.start === existing.end) {\n return existing.start > edit.start && existing.start < edit.end;\n }\n return edit.start < existing.end && existing.start < edit.end;\n })\n );\n}\nfunction lowerModule({\n module,\n source,\n target,\n host,\n options,\n structuralPass\n}) {\n const stats = {\n found: 0,\n lowered: 0,\n flattened: 0,\n styled: 0,\n bailed: 0\n };\n const structural = structuralPass ? structuralPass.transform({ module, source, target }) : {\n module,\n edits: [],\n imports: [],\n diagnostics: [],\n dependencies: []\n };\n if (structural.module.id !== module.id) {\n throw new Error(\n `Structural pass changed module identity from ${module.id} to ${structural.module.id}`\n );\n }\n if (structuralPass && !structuralPass.versionHash) {\n throw new Error(\"Structural pass must provide a non-empty version hash\");\n }\n module = structural.module;\n validateSourceEdits(source, structural.edits);\n const edits = [...structural.edits];\n const css = /* @__PURE__ */ new Set();\n const diagnostics = [...module.diagnostics, ...structural.diagnostics];\n const dependencies = /* @__PURE__ */ new Set([...module.dependencies, ...structural.dependencies]);\n const imports = new Map(\n structural.imports.map((candidateImport) => [\n candidateImport.content,\n candidateImport\n ])\n );\n for (const element of module.elements) {\n const styledDefinition = styledDefinitionFor(module, element);\n const component = host.resolveComponent(element, styledDefinition);\n if (!component) continue;\n stats.found++;\n const input = {\n id: module.id,\n source,\n target,\n module,\n element,\n styledDefinition,\n component\n };\n const commitDevelopmentDebug = (result2) => {\n const debugEdits = host.developmentDebugInstrumentation?.(input, result2);\n if (!debugEdits) return;\n validateSourceEdits(source, debugEdits);\n if (!editsAreCandidateLocal(element, debugEdits) || overlapsCommitted(debugEdits, edits)) {\n throw new Error(\"Development debug instrumentation must stay candidate-local\");\n }\n edits.push(...debugEdits);\n };\n if (!element.complete || styledDefinition && !styledDefinition.complete) {\n const reasons = [\n ...element.bailouts.map(blocking),\n ...(styledDefinition?.bailouts ?? []).map(blocking)\n ];\n diagnostics.push(...reasons);\n const reason = reasons[0];\n if (reason) commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n const unsafe = element.entries.map((entry) => unsafeEntry(element, entry, component, host)).find((result2) => result2 !== null);\n if (unsafe) {\n diagnostics.push(blocking(unsafe));\n commitDevelopmentDebug({ ok: false, bailout: blocking(unsafe) });\n stats.bailed++;\n continue;\n }\n let result;\n try {\n result = host.lowerCandidate(input);\n } catch (error) {\n result = {\n ok: false,\n bailout: diagnostic(\n \"local/style-resolution-failed\",\n element,\n `Style resolution failed: ${error instanceof Error ? error.message : String(error)}`\n )\n };\n }\n if (!result.ok) {\n diagnostics.push(blocking(result.bailout));\n commitDevelopmentDebug(result);\n stats.bailed++;\n continue;\n }\n try {\n validateSourceEdits(source, result.edits);\n } catch (error) {\n const reason = blocking(\n diagnostic(\n \"local/overlapping-edit\",\n element,\n error instanceof Error ? error.message : String(error)\n )\n );\n diagnostics.push(reason);\n commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n if (!editsAreCandidateLocal(element, result.edits) || overlapsCommitted(result.edits, edits)) {\n const reason = blocking(\n diagnostic(\n \"local/overlapping-edit\",\n element,\n \"Candidate edits overlap another candidate or escape the element span\"\n )\n );\n diagnostics.push(reason);\n commitDevelopmentDebug({ ok: false, bailout: reason });\n stats.bailed++;\n continue;\n }\n diagnostics.push(...result.diagnostics ?? []);\n edits.push(...result.edits);\n commitDevelopmentDebug(result);\n for (const rule of result.css) css.add(rule);\n for (const candidateImport of result.imports) {\n if (!imports.has(candidateImport.content)) {\n imports.set(candidateImport.content, candidateImport);\n }\n }\n for (const dependency of result.dependencies ?? []) dependencies.add(dependency);\n stats.lowered++;\n if (result.flattened) stats.flattened++;\n if (styledDefinition) stats.styled++;\n }\n for (const candidateImport of imports.values()) {\n edits.push({\n start: source.length,\n end: source.length,\n content: candidateImport.content,\n origin: candidateImport.origin\n });\n }\n return {\n version: LOWERED_MODULE_PLAN_VERSION,\n id: module.id,\n target,\n inputHash: module.inputHash,\n sourceHash: sourceContentHash(source),\n projectGeneration: options.projectGeneration,\n structuralPassHash: structuralPass?.versionHash ?? `${target}-noop-v1`,\n edits,\n css: [...css].join(\"\"),\n diagnostics,\n dependencies: [...dependencies].sort(compareCodeUnits),\n stats\n };\n}\nexport {\n LOWERED_MODULE_PLAN_VERSION,\n lowerModule\n};\n//# sourceMappingURL=lower.js.map\n"],"mappings":";;;;AAKA,MAAM,8BAA8B;AACpC,SAAS,iBAAiB,MAAM,OAAO;CACrC,OAAO,OAAO,QAAQ,CAAC,IAAI,OAAO,QAAQ,IAAI;AAChD;AACA,SAAS,SAAS,QAAQ;CACxB,OAAO;EAAE,GAAG;EAAQ,UAAU;CAAK;AACrC;AACA,SAAS,WAAW,MAAM,SAAS,SAAS,MAAM;CAChD,OAAO;EACL,GAAG,aAAa,MAAM,QAAQ,MAAM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A,OAAO;EACL;EACA,IAAI,OAAO;EACX;EACA,WAAW,OAAO;EAClB,YAAY,kBAAkB,MAAM;EACpC,mBAAmB,QAAQ;EAC3B,oBAAoB,gBAAgB,eAAe,GAAG,OAAO;EAC7D;EACA,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE;EACrB;EACA,cAAc,CAAC,GAAG,YAAY,CAAC,CAAC,KAAK,gBAAgB;EACrD;CACF;AACF"}
@@ -19,19 +19,21 @@ function finalizeElement(base, entries, bailouts) {
19
19
  bailouts
20
20
  };
21
21
  }
22
- function definitionFromDeclaration(id, name, program, declaration) {
22
+ function definitionFromDeclaration(id, name, declaration, parentOf) {
23
23
  let identifier = declaration;
24
24
  let initializer = null;
25
25
  let constant = false;
26
26
  if (declaration.type === "VariableDeclarator") {
27
27
  identifier = childNode(declaration, "id") ?? declaration;
28
28
  initializer = childNode(declaration, "init");
29
- constant = !!findAstNode(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && childNodes(node, "declarations").some((candidate) => candidate.start === declaration.start));
29
+ const parent = parentOf(declaration);
30
+ constant = parent?.type === "VariableDeclaration" && parent.kind === "const";
30
31
  } else if (declaration.type === "Identifier") {
31
- const declarator = findAstNode(program, (node) => node.type === "VariableDeclarator" && childNode(node, "id")?.start === declaration.start);
32
- if (declarator) {
32
+ const declarator = parentOf(declaration);
33
+ if (declarator?.type === "VariableDeclarator" && childNode(declarator, "id")?.start === declaration.start) {
33
34
  initializer = childNode(declarator, "init");
34
- constant = !!findAstNode(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && childNodes(node, "declarations").some((candidate) => candidate.start === declarator.start));
35
+ const parent = parentOf(declarator);
36
+ constant = parent?.type === "VariableDeclaration" && parent.kind === "const";
35
37
  }
36
38
  }
37
39
  return {
@@ -588,7 +590,10 @@ function normalizeElements(candidate, rawId, imports = []) {
588
590
  };
589
591
  }
590
592
  function nodeAtSpan(program, start, end) {
591
- return findAstNode(program, (node) => node.start === start && node.end === end);
593
+ return findAstNode(program, (node) => node.start === start && node.end === end, {
594
+ start,
595
+ end
596
+ });
592
597
  }
593
598
  function asAstNode(value, label) {
594
599
  if (!isAstNode(value)) throw new Error(`${label} is not an AST node`);
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","names":[],"sources":["esm/normalize.js"],"sourcesContent":["import {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n walkAst\n} from \"./ast\";\nimport {\n expressionReference,\n resolvedModuleId,\n spanOf\n} from \"./contracts\";\nimport { linkedBailout, localBailout } from \"./diagnostics\";\nimport { hostImportProvenance } from \"./ir\";\nfunction finalizeElement(base, entries, bailouts) {\n if (bailouts.length === 0) {\n return { ...base, complete: true, entries, bailouts: [] };\n }\n return {\n ...base,\n complete: false,\n bailedEntries: entries,\n bailouts\n };\n}\nfunction definitionFromDeclaration(id, name, program, declaration) {\n let identifier = declaration;\n let initializer = null;\n let constant = false;\n if (declaration.type === \"VariableDeclarator\") {\n identifier = childNode(declaration, \"id\") ?? declaration;\n initializer = childNode(declaration, \"init\");\n constant = !!findAstNode(\n program,\n (node) => node.type === \"VariableDeclaration\" && node.kind === \"const\" && childNodes(node, \"declarations\").some(\n (candidate) => candidate.start === declaration.start\n )\n );\n } else if (declaration.type === \"Identifier\") {\n const declarator = findAstNode(\n program,\n (node) => node.type === \"VariableDeclarator\" && childNode(node, \"id\")?.start === declaration.start\n );\n if (declarator) {\n initializer = childNode(declarator, \"init\");\n constant = !!findAstNode(\n program,\n (node) => node.type === \"VariableDeclaration\" && node.kind === \"const\" && childNodes(node, \"declarations\").some(\n (candidate) => candidate.start === declarator.start\n )\n );\n }\n }\n return {\n id: resolvedModuleId(id),\n name,\n start: identifier.start,\n end: identifier.end,\n initializer,\n constant\n };\n}\nfunction importBinding(program, localName) {\n for (const statement of childNodes(program, \"body\")) {\n if (statement.type !== \"ImportDeclaration\") continue;\n const source = childNode(statement, \"source\");\n const sourceValue = source && typeof source.value === \"string\" ? source.value : null;\n if (!sourceValue) continue;\n for (const specifier of childNodes(statement, \"specifiers\")) {\n if (identifierName(childNode(specifier, \"local\")) !== localName) continue;\n if (specifier.type === \"ImportDefaultSpecifier\") {\n return { source: sourceValue, imported: \"default\" };\n }\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n return { source: sourceValue, imported: \"*\" };\n }\n const imported = childNode(specifier, \"imported\");\n const importedName = identifierName(imported) ?? (typeof imported?.value === \"string\" ? imported.value : null);\n return importedName ? { source: sourceValue, imported: importedName } : null;\n }\n }\n return null;\n}\nfunction asStaticValue(node) {\n if (!node) return void 0;\n if (node.type === \"NullLiteral\") return null;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n const value = node.value;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null) {\n return value;\n }\n }\n return void 0;\n}\nfunction elementValue(id, node) {\n const staticValue = asStaticValue(node);\n return staticValue === void 0 ? expressionReference(id, node) : { kind: \"static\", value: staticValue, span: spanOf(id, node) };\n}\nfunction symbolDefinition(definition) {\n if (!definition) return null;\n return {\n id: definition.id,\n name: definition.name,\n span: {\n id: definition.id,\n start: definition.start,\n end: definition.end\n },\n initializer: definition.initializer ? expressionReference(definition.id, definition.initializer) : null,\n constant: definition.constant\n };\n}\nfunction componentFromNode(candidate, id, program, imports, node, bailouts) {\n const literal = asStaticValue(node);\n if (typeof literal === \"string\") {\n return {\n kind: \"intrinsic\",\n name: literal,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: null\n };\n }\n if ((node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") && node.computed !== true) {\n const objectName = identifierName(childNode(node, \"object\"));\n const memberName = identifierName(childNode(node, \"property\"));\n const binding2 = objectName ? importBinding(program, objectName) : null;\n if (memberName && binding2?.imported === \"html\") {\n const provenance2 = hostImportProvenance(imports, binding2.source, binding2.imported);\n if (provenance2) {\n return {\n kind: \"binding\",\n name: memberName,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: provenance2\n };\n }\n }\n }\n const name = identifierName(node);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-element-name\",\n spanOf(id, node),\n `Element target ${node.type} is not a stable identifier or intrinsic tag`\n )\n );\n return null;\n }\n const intrinsic = /^[a-z]/.test(name);\n const binding = intrinsic ? null : importBinding(program, name);\n const provenance = binding ? hostImportProvenance(imports, binding.source, binding.imported) : null;\n const definition = intrinsic ? null : symbolDefinition(candidate.definitionOf(id, name));\n if (!intrinsic && !definition && !provenance) {\n bailouts.push(\n linkedBailout(\n \"linked/unresolved-component-binding\",\n spanOf(id, node),\n `Component binding ${name} has no linked definition`\n )\n );\n }\n return {\n kind: intrinsic ? \"intrinsic\" : \"binding\",\n name,\n span: spanOf(id, node),\n closingSpan: null,\n definition,\n provenance\n };\n}\nfunction jsxComponentNode(opening) {\n return childNode(opening, \"name\");\n}\nfunction jsxEntries(id, element, opening, bailouts) {\n const entries = [];\n for (const attribute of childNodes(opening, \"attributes\")) {\n if (attribute.type === \"JSXSpreadAttribute\") {\n const argument = childNode(attribute, \"argument\");\n if (argument) {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, attribute),\n value: expressionReference(id, argument)\n });\n }\n continue;\n }\n if (attribute.type !== \"JSXAttribute\") continue;\n const nameNode = childNode(attribute, \"name\");\n const name = identifierName(nameNode);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, attribute),\n \"Namespaced JSX attributes are not statically supported\"\n )\n );\n continue;\n }\n const rawValue = childNode(attribute, \"value\");\n let value;\n if (!rawValue) {\n value = { kind: \"static\", value: true, span: spanOf(id, attribute) };\n } else if (rawValue.type === \"JSXExpressionContainer\") {\n const expression = childNode(rawValue, \"expression\");\n if (!expression || expression.type === \"JSXEmptyExpression\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-expression\",\n spanOf(id, rawValue),\n `JSX prop ${name} has no expression`\n )\n );\n continue;\n }\n value = elementValue(id, expression);\n } else {\n value = elementValue(id, rawValue);\n }\n entries.push({ kind: \"prop\", name, span: spanOf(id, attribute), value });\n }\n for (const child of childNodes(element, \"children\")) {\n let value;\n if (child.type === \"JSXText\") {\n if (typeof child.value !== \"string\" || child.value.trim() === \"\") continue;\n value = {\n kind: \"static\",\n value: child.value,\n span: spanOf(id, child)\n };\n } else if (child.type === \"JSXExpressionContainer\") {\n const expression = childNode(child, \"expression\");\n value = !expression || expression.type === \"JSXEmptyExpression\" ? { kind: \"empty\", span: spanOf(id, child) } : elementValue(id, expression);\n } else if (child.type === \"JSXElement\" || child.type === \"JSXFragment\") {\n value = { kind: \"element\", span: spanOf(id, child) };\n } else {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n `JSX child ${child.type} cannot be normalized`\n )\n );\n continue;\n }\n entries.push({ kind: \"child\", span: spanOf(id, child), value });\n }\n return entries.sort((left, right) => left.span.start - right.span.start);\n}\nfunction propertyName(property) {\n if (property.computed === true) return null;\n const key = childNode(property, \"key\");\n const name = identifierName(key);\n if (name) return name;\n const literal = asStaticValue(key);\n return typeof literal === \"string\" || typeof literal === \"number\" ? String(literal) : null;\n}\nfunction runtimeChildEntries(id, program, node, bailouts) {\n const rawNodes = node.type === \"ArrayExpression\" ? node.elements : null;\n if (Array.isArray(rawNodes) && rawNodes.some((child) => child === null || !isAstNode(child))) {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, node),\n \"Sparse compiled children cannot be normalized without changing order\"\n )\n );\n return [];\n }\n const nodes = Array.isArray(rawNodes) ? rawNodes.filter(isAstNode) : [node];\n return nodes.flatMap((child) => {\n if (child.type === \"SpreadElement\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n \"Spread children cannot be statically ordered\"\n )\n );\n return [];\n }\n if (child.type === \"CallExpression\" && runtimeCall(program, child)) {\n return [\n {\n kind: \"child\",\n span: spanOf(id, child),\n value: { kind: \"element\", span: spanOf(id, child) }\n }\n ];\n }\n return [{ kind: \"child\", span: spanOf(id, child), value: elementValue(id, child) }];\n });\n}\nfunction objectEntries(id, program, object, bailouts) {\n const entries = [];\n for (const property of childNodes(object, \"properties\")) {\n if (property.type === \"SpreadElement\") {\n const argument = childNode(property, \"argument\");\n if (argument) {\n const spread = {\n kind: \"spread\",\n span: spanOf(id, property),\n value: expressionReference(id, argument)\n };\n entries.push(spread);\n }\n continue;\n }\n if (property.type !== \"Property\" && property.type !== \"ObjectProperty\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n `Runtime props entry ${property.type} is not a data property`\n )\n );\n continue;\n }\n const name = propertyName(property);\n const valueNode = childNode(property, \"value\");\n if (!name || !valueNode) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n \"Computed runtime prop keys are not statically supported\"\n )\n );\n continue;\n }\n if (name === \"children\") {\n entries.push(...runtimeChildEntries(id, program, valueNode, bailouts));\n continue;\n }\n const prop = {\n kind: \"prop\",\n name,\n span: spanOf(id, property),\n value: elementValue(id, valueNode)\n };\n entries.push(prop);\n }\n return entries;\n}\nfunction runtimeCall(program, call) {\n const callee = childNode(call, \"callee\");\n if (!callee) return null;\n const directName = identifierName(callee);\n if (directName) {\n const provenance2 = importBinding(program, directName);\n if (provenance2?.source === \"react/jsx-runtime\" && (provenance2.imported === \"jsx\" || provenance2.imported === \"jsxs\")) {\n return { form: \"jsx-runtime\" };\n }\n if (provenance2?.source === \"react\" && provenance2.imported === \"createElement\") {\n return { form: \"create-element\" };\n }\n }\n if (callee.type !== \"MemberExpression\" || callee.computed === true) return null;\n const objectName = identifierName(childNode(callee, \"object\"));\n const propertyName2 = identifierName(childNode(callee, \"property\"));\n if (propertyName2 !== \"createElement\" || !objectName) return null;\n const provenance = importBinding(program, objectName);\n return provenance?.source === \"react\" && (provenance.imported === \"default\" || provenance.imported === \"*\") ? { form: \"create-element\" } : null;\n}\nfunction normalizeRuntimeElement(candidate, id, program, imports, call, runtime, bailouts) {\n const bailoutStart = bailouts.length;\n const args = childNodes(call, \"arguments\");\n const target = args[0];\n if (!target) {\n bailouts.push(\n localBailout(\n \"local/invalid-element-call\",\n spanOf(id, call),\n `${runtime.form} call has no element target`\n )\n );\n return null;\n }\n const component = componentFromNode(candidate, id, program, imports, target, bailouts);\n if (!component) return null;\n const entries = [];\n const props = args[1];\n if (props && asStaticValue(props) !== null) {\n if (props.type === \"ObjectExpression\") {\n entries.push(...objectEntries(id, program, props, bailouts));\n } else {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, props),\n value: expressionReference(id, props)\n });\n }\n }\n if (runtime.form === \"create-element\") {\n for (const child of args.slice(2)) {\n entries.push(...runtimeChildEntries(id, program, child, bailouts));\n }\n }\n return finalizeElement(\n {\n kind: \"element\",\n form: runtime.form,\n id,\n span: spanOf(id, call),\n propsSpan: props ? spanOf(id, props) : null,\n component\n },\n entries.sort((left, right) => left.span.start - right.span.start),\n bailouts.slice(bailoutStart)\n );\n}\nfunction styledDefinitions(candidate, id, program, imports, bailouts) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"styled\") return;\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n if (!factory) return;\n const definitionBailouts = [];\n const args = childNodes(call, \"arguments\");\n const baseNode = args[0];\n const objectForm = args[1]?.type === \"ObjectExpression\";\n const optionsNode = objectForm ? args[1] : args.length >= 3 ? args[2] : args[1];\n if (!baseNode || !optionsNode) {\n definitionBailouts.push(\n localBailout(\n \"local/unsupported-styled-definition\",\n spanOf(id, call),\n `styled definition ${name} must provide a base and options object`\n )\n );\n bailouts.push(...definitionBailouts);\n return;\n }\n const base = componentFromNode(\n candidate,\n id,\n program,\n imports,\n baseNode,\n definitionBailouts\n );\n if (!base) {\n bailouts.push(...definitionBailouts);\n return;\n }\n const baseClassNode = objectForm ? null : args.length >= 3 ? args[1] : null;\n const staticConfigNode = objectForm && args.length >= 3 ? args[2] : null;\n const baseDefinition = {\n kind: \"styled-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n base,\n baseClassName: baseClassNode ? elementValue(id, baseClassNode) : null,\n options: expressionReference(id, optionsNode),\n staticConfig: staticConfigNode ? expressionReference(id, staticConfigNode) : null\n };\n definitions.push(\n definitionBailouts.length === 0 ? { ...baseDefinition, complete: true, bailouts: [] } : {\n ...baseDefinition,\n complete: false,\n bailouts: definitionBailouts\n }\n );\n bailouts.push(...definitionBailouts);\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nconst DOM_STYLE_FRONTENDS = /* @__PURE__ */ new Set([\n \"tamagui/dom\",\n \"@tamagui/core/dom\",\n \"@tamagui/tailwind\"\n]);\nconst STYLE_FRONTENDS = /* @__PURE__ */ new Set([\n ...DOM_STYLE_FRONTENDS,\n \"tamagui\",\n \"@tamagui/core\",\n \"@tamagui/web\"\n]);\nfunction domStyleDefinitions(id, program, imports) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !STYLE_FRONTENDS.has(binding.source)) {\n return;\n }\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n const value = childNodes(call, \"arguments\")[0];\n if (!factory || !value) return;\n definitions.push({\n kind: \"dom-style-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n value: expressionReference(id, value)\n });\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nfunction domStyleArgument(candidate, id, program, node) {\n let call = node;\n if (node.type === \"Identifier\") {\n const name = identifierName(node);\n const definition = name ? candidate.definitionOf(id, name) : null;\n if (!definition?.constant || !definition.initializer) return null;\n call = definition.initializer;\n }\n if (call.type !== \"CallExpression\") return null;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return null;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !STYLE_FRONTENDS.has(binding.source)) {\n return null;\n }\n return childNodes(call, \"arguments\")[0] ?? null;\n}\nfunction domStyleProgram(candidate, id, program, node) {\n if (node.type !== \"ArrayExpression\" || !Array.isArray(node.elements)) {\n const argument = domStyleArgument(candidate, id, program, node);\n return argument ? {\n kind: \"dom-style\",\n span: spanOf(id, node),\n items: [{ condition: null, value: expressionReference(id, argument) }]\n } : null;\n }\n const items = [];\n for (const rawItem of node.elements) {\n if (!isAstNode(rawItem)) return null;\n let item = rawItem;\n let condition = null;\n if (item.type === \"LogicalExpression\" && item.operator === \"&&\") {\n const left = childNode(item, \"left\");\n const right = childNode(item, \"right\");\n if (!left || !right) return null;\n condition = expressionReference(id, left);\n item = right;\n }\n const argument = domStyleArgument(candidate, id, program, item);\n if (!argument) {\n const staticValue = asStaticValue(item);\n if (staticValue === false || staticValue === null) continue;\n return null;\n }\n items.push({ condition, value: expressionReference(id, argument) });\n }\n return { kind: \"dom-style\", span: spanOf(id, node), items };\n}\nfunction normalizeElements(candidate, rawId, imports = []) {\n const id = resolvedModuleId(rawId);\n const program = candidate.programOf(id);\n const elements = [];\n const bailouts = [];\n walkAst(program, (node) => {\n if (node.type === \"JSXElement\") {\n const bailoutStart = bailouts.length;\n const opening = childNode(node, \"openingElement\");\n const target = opening && jsxComponentNode(opening);\n if (!opening || !target) return;\n const component = componentFromNode(\n candidate,\n id,\n program,\n imports,\n target,\n bailouts\n );\n if (!component) return;\n const closingElement = childNode(node, \"closingElement\");\n const closingName = closingElement && childNode(closingElement, \"name\");\n if (closingName) component.closingSpan = spanOf(id, closingName);\n const entries = jsxEntries(id, node, opening, bailouts);\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(\n finalizeElement(\n {\n kind: \"element\",\n form: \"jsx\",\n id,\n span: spanOf(id, node),\n propsSpan: spanOf(id, opening),\n component\n },\n entries,\n bailouts.slice(bailoutStart)\n )\n );\n return;\n }\n if (node.type !== \"CallExpression\") return;\n const runtime = runtimeCall(program, node);\n if (!runtime) return;\n const element = normalizeRuntimeElement(\n candidate,\n id,\n program,\n imports,\n node,\n runtime,\n bailouts\n );\n if (element) {\n const entries = element.complete ? element.entries : element.bailedEntries;\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(element);\n }\n });\n return {\n elements: elements.sort((left, right) => left.span.start - right.span.start),\n styledDefinitions: styledDefinitions(candidate, id, program, imports, bailouts),\n domStyleDefinitions: domStyleDefinitions(id, program, imports),\n bailouts: bailouts.sort((left, right) => left.span.start - right.span.start)\n };\n}\nfunction nodeAtSpan(program, start, end) {\n return findAstNode(program, (node) => node.start === start && node.end === end);\n}\nfunction asAstNode(value, label) {\n if (!isAstNode(value)) throw new Error(`${label} is not an AST node`);\n return value;\n}\nexport {\n asAstNode,\n definitionFromDeclaration,\n nodeAtSpan,\n normalizeElements\n};\n//# sourceMappingURL=normalize.js.map\n"],"mappings":";;;;;;AAeA,SAAS,gBAAgB,MAAM,SAAS,UAAU;CAChD,IAAI,SAAS,WAAW,GAAG;EACzB,OAAO;GAAE,GAAG;GAAM,UAAU;GAAM;GAAS,UAAU,CAAC;EAAE;CAC1D;CACA,OAAO;EACL,GAAG;EACH,UAAU;EACV,eAAe;EACf;CACF;AACF;AACA,SAAS,0BAA0B,IAAI,MAAM,SAAS,aAAa;CACjE,IAAI,aAAa;CACjB,IAAI,cAAc;CAClB,IAAI,WAAW;CACf,IAAI,YAAY,SAAS,sBAAsB;EAC7C,aAAa,UAAU,aAAa,IAAI,KAAK;EAC7C,cAAc,UAAU,aAAa,MAAM;EAC3C,WAAW,CAAC,CAAC,YACX,UACC,SAAS,KAAK,SAAS,yBAAyB,KAAK,SAAS,WAAW,WAAW,MAAM,cAAc,CAAC,CAAC,MACxG,cAAc,UAAU,UAAU,YAAY,KACjD,CACF;CACF,OAAO,IAAI,YAAY,SAAS,cAAc;EAC5C,MAAM,aAAa,YACjB,UACC,SAAS,KAAK,SAAS,wBAAwB,UAAU,MAAM,IAAI,CAAC,EAAE,UAAU,YAAY,KAC/F;EACA,IAAI,YAAY;GACd,cAAc,UAAU,YAAY,MAAM;GAC1C,WAAW,CAAC,CAAC,YACX,UACC,SAAS,KAAK,SAAS,yBAAyB,KAAK,SAAS,WAAW,WAAW,MAAM,cAAc,CAAC,CAAC,MACxG,cAAc,UAAU,UAAU,WAAW,KAChD,CACF;EACF;CACF;CACA,OAAO;EACL,IAAI,iBAAiB,EAAE;EACvB;EACA,OAAO,WAAW;EAClB,KAAK,WAAW;EAChB;EACA;CACF;AACF;AACA,SAAS,cAAc,SAAS,WAAW;CACzC,KAAK,MAAM,aAAa,WAAW,SAAS,MAAM,GAAG;EACnD,IAAI,UAAU,SAAS,qBAAqB;EAC5C,MAAM,SAAS,UAAU,WAAW,QAAQ;EAC5C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GAAG,MAAM,oBAAoB;CACpE,OAAO;AACT"}
1
+ {"version":3,"file":"normalize.js","names":[],"sources":["esm/normalize.js"],"sourcesContent":["import {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n walkAst\n} from \"./ast\";\nimport {\n expressionReference,\n resolvedModuleId,\n spanOf\n} from \"./contracts\";\nimport { linkedBailout, localBailout } from \"./diagnostics\";\nimport { hostImportProvenance } from \"./ir\";\nfunction finalizeElement(base, entries, bailouts) {\n if (bailouts.length === 0) {\n return { ...base, complete: true, entries, bailouts: [] };\n }\n return {\n ...base,\n complete: false,\n bailedEntries: entries,\n bailouts\n };\n}\nfunction definitionFromDeclaration(id, name, declaration, parentOf) {\n let identifier = declaration;\n let initializer = null;\n let constant = false;\n if (declaration.type === \"VariableDeclarator\") {\n identifier = childNode(declaration, \"id\") ?? declaration;\n initializer = childNode(declaration, \"init\");\n const parent = parentOf(declaration);\n constant = parent?.type === \"VariableDeclaration\" && parent.kind === \"const\";\n } else if (declaration.type === \"Identifier\") {\n const declarator = parentOf(declaration);\n if (declarator?.type === \"VariableDeclarator\" && childNode(declarator, \"id\")?.start === declaration.start) {\n initializer = childNode(declarator, \"init\");\n const parent = parentOf(declarator);\n constant = parent?.type === \"VariableDeclaration\" && parent.kind === \"const\";\n }\n }\n return {\n id: resolvedModuleId(id),\n name,\n start: identifier.start,\n end: identifier.end,\n initializer,\n constant\n };\n}\nfunction importBinding(program, localName) {\n for (const statement of childNodes(program, \"body\")) {\n if (statement.type !== \"ImportDeclaration\") continue;\n const source = childNode(statement, \"source\");\n const sourceValue = source && typeof source.value === \"string\" ? source.value : null;\n if (!sourceValue) continue;\n for (const specifier of childNodes(statement, \"specifiers\")) {\n if (identifierName(childNode(specifier, \"local\")) !== localName) continue;\n if (specifier.type === \"ImportDefaultSpecifier\") {\n return { source: sourceValue, imported: \"default\" };\n }\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n return { source: sourceValue, imported: \"*\" };\n }\n const imported = childNode(specifier, \"imported\");\n const importedName = identifierName(imported) ?? (typeof imported?.value === \"string\" ? imported.value : null);\n return importedName ? { source: sourceValue, imported: importedName } : null;\n }\n }\n return null;\n}\nfunction asStaticValue(node) {\n if (!node) return void 0;\n if (node.type === \"NullLiteral\") return null;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n const value = node.value;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null) {\n return value;\n }\n }\n return void 0;\n}\nfunction elementValue(id, node) {\n const staticValue = asStaticValue(node);\n return staticValue === void 0 ? expressionReference(id, node) : { kind: \"static\", value: staticValue, span: spanOf(id, node) };\n}\nfunction symbolDefinition(definition) {\n if (!definition) return null;\n return {\n id: definition.id,\n name: definition.name,\n span: {\n id: definition.id,\n start: definition.start,\n end: definition.end\n },\n initializer: definition.initializer ? expressionReference(definition.id, definition.initializer) : null,\n constant: definition.constant\n };\n}\nfunction componentFromNode(candidate, id, program, imports, node, bailouts) {\n const literal = asStaticValue(node);\n if (typeof literal === \"string\") {\n return {\n kind: \"intrinsic\",\n name: literal,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: null\n };\n }\n if ((node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") && node.computed !== true) {\n const objectName = identifierName(childNode(node, \"object\"));\n const memberName = identifierName(childNode(node, \"property\"));\n const binding2 = objectName ? importBinding(program, objectName) : null;\n if (memberName && binding2?.imported === \"html\") {\n const provenance2 = hostImportProvenance(imports, binding2.source, binding2.imported);\n if (provenance2) {\n return {\n kind: \"binding\",\n name: memberName,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: provenance2\n };\n }\n }\n }\n const name = identifierName(node);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-element-name\",\n spanOf(id, node),\n `Element target ${node.type} is not a stable identifier or intrinsic tag`\n )\n );\n return null;\n }\n const intrinsic = /^[a-z]/.test(name);\n const binding = intrinsic ? null : importBinding(program, name);\n const provenance = binding ? hostImportProvenance(imports, binding.source, binding.imported) : null;\n const definition = intrinsic ? null : symbolDefinition(candidate.definitionOf(id, name));\n if (!intrinsic && !definition && !provenance) {\n bailouts.push(\n linkedBailout(\n \"linked/unresolved-component-binding\",\n spanOf(id, node),\n `Component binding ${name} has no linked definition`\n )\n );\n }\n return {\n kind: intrinsic ? \"intrinsic\" : \"binding\",\n name,\n span: spanOf(id, node),\n closingSpan: null,\n definition,\n provenance\n };\n}\nfunction jsxComponentNode(opening) {\n return childNode(opening, \"name\");\n}\nfunction jsxEntries(id, element, opening, bailouts) {\n const entries = [];\n for (const attribute of childNodes(opening, \"attributes\")) {\n if (attribute.type === \"JSXSpreadAttribute\") {\n const argument = childNode(attribute, \"argument\");\n if (argument) {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, attribute),\n value: expressionReference(id, argument)\n });\n }\n continue;\n }\n if (attribute.type !== \"JSXAttribute\") continue;\n const nameNode = childNode(attribute, \"name\");\n const name = identifierName(nameNode);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, attribute),\n \"Namespaced JSX attributes are not statically supported\"\n )\n );\n continue;\n }\n const rawValue = childNode(attribute, \"value\");\n let value;\n if (!rawValue) {\n value = { kind: \"static\", value: true, span: spanOf(id, attribute) };\n } else if (rawValue.type === \"JSXExpressionContainer\") {\n const expression = childNode(rawValue, \"expression\");\n if (!expression || expression.type === \"JSXEmptyExpression\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-expression\",\n spanOf(id, rawValue),\n `JSX prop ${name} has no expression`\n )\n );\n continue;\n }\n value = elementValue(id, expression);\n } else {\n value = elementValue(id, rawValue);\n }\n entries.push({ kind: \"prop\", name, span: spanOf(id, attribute), value });\n }\n for (const child of childNodes(element, \"children\")) {\n let value;\n if (child.type === \"JSXText\") {\n if (typeof child.value !== \"string\" || child.value.trim() === \"\") continue;\n value = {\n kind: \"static\",\n value: child.value,\n span: spanOf(id, child)\n };\n } else if (child.type === \"JSXExpressionContainer\") {\n const expression = childNode(child, \"expression\");\n value = !expression || expression.type === \"JSXEmptyExpression\" ? { kind: \"empty\", span: spanOf(id, child) } : elementValue(id, expression);\n } else if (child.type === \"JSXElement\" || child.type === \"JSXFragment\") {\n value = { kind: \"element\", span: spanOf(id, child) };\n } else {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n `JSX child ${child.type} cannot be normalized`\n )\n );\n continue;\n }\n entries.push({ kind: \"child\", span: spanOf(id, child), value });\n }\n return entries.sort((left, right) => left.span.start - right.span.start);\n}\nfunction propertyName(property) {\n if (property.computed === true) return null;\n const key = childNode(property, \"key\");\n const name = identifierName(key);\n if (name) return name;\n const literal = asStaticValue(key);\n return typeof literal === \"string\" || typeof literal === \"number\" ? String(literal) : null;\n}\nfunction runtimeChildEntries(id, program, node, bailouts) {\n const rawNodes = node.type === \"ArrayExpression\" ? node.elements : null;\n if (Array.isArray(rawNodes) && rawNodes.some((child) => child === null || !isAstNode(child))) {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, node),\n \"Sparse compiled children cannot be normalized without changing order\"\n )\n );\n return [];\n }\n const nodes = Array.isArray(rawNodes) ? rawNodes.filter(isAstNode) : [node];\n return nodes.flatMap((child) => {\n if (child.type === \"SpreadElement\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n \"Spread children cannot be statically ordered\"\n )\n );\n return [];\n }\n if (child.type === \"CallExpression\" && runtimeCall(program, child)) {\n return [\n {\n kind: \"child\",\n span: spanOf(id, child),\n value: { kind: \"element\", span: spanOf(id, child) }\n }\n ];\n }\n return [{ kind: \"child\", span: spanOf(id, child), value: elementValue(id, child) }];\n });\n}\nfunction objectEntries(id, program, object, bailouts) {\n const entries = [];\n for (const property of childNodes(object, \"properties\")) {\n if (property.type === \"SpreadElement\") {\n const argument = childNode(property, \"argument\");\n if (argument) {\n const spread = {\n kind: \"spread\",\n span: spanOf(id, property),\n value: expressionReference(id, argument)\n };\n entries.push(spread);\n }\n continue;\n }\n if (property.type !== \"Property\" && property.type !== \"ObjectProperty\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n `Runtime props entry ${property.type} is not a data property`\n )\n );\n continue;\n }\n const name = propertyName(property);\n const valueNode = childNode(property, \"value\");\n if (!name || !valueNode) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n \"Computed runtime prop keys are not statically supported\"\n )\n );\n continue;\n }\n if (name === \"children\") {\n entries.push(...runtimeChildEntries(id, program, valueNode, bailouts));\n continue;\n }\n const prop = {\n kind: \"prop\",\n name,\n span: spanOf(id, property),\n value: elementValue(id, valueNode)\n };\n entries.push(prop);\n }\n return entries;\n}\nfunction runtimeCall(program, call) {\n const callee = childNode(call, \"callee\");\n if (!callee) return null;\n const directName = identifierName(callee);\n if (directName) {\n const provenance2 = importBinding(program, directName);\n if (provenance2?.source === \"react/jsx-runtime\" && (provenance2.imported === \"jsx\" || provenance2.imported === \"jsxs\")) {\n return { form: \"jsx-runtime\" };\n }\n if (provenance2?.source === \"react\" && provenance2.imported === \"createElement\") {\n return { form: \"create-element\" };\n }\n }\n if (callee.type !== \"MemberExpression\" || callee.computed === true) return null;\n const objectName = identifierName(childNode(callee, \"object\"));\n const propertyName2 = identifierName(childNode(callee, \"property\"));\n if (propertyName2 !== \"createElement\" || !objectName) return null;\n const provenance = importBinding(program, objectName);\n return provenance?.source === \"react\" && (provenance.imported === \"default\" || provenance.imported === \"*\") ? { form: \"create-element\" } : null;\n}\nfunction normalizeRuntimeElement(candidate, id, program, imports, call, runtime, bailouts) {\n const bailoutStart = bailouts.length;\n const args = childNodes(call, \"arguments\");\n const target = args[0];\n if (!target) {\n bailouts.push(\n localBailout(\n \"local/invalid-element-call\",\n spanOf(id, call),\n `${runtime.form} call has no element target`\n )\n );\n return null;\n }\n const component = componentFromNode(candidate, id, program, imports, target, bailouts);\n if (!component) return null;\n const entries = [];\n const props = args[1];\n if (props && asStaticValue(props) !== null) {\n if (props.type === \"ObjectExpression\") {\n entries.push(...objectEntries(id, program, props, bailouts));\n } else {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, props),\n value: expressionReference(id, props)\n });\n }\n }\n if (runtime.form === \"create-element\") {\n for (const child of args.slice(2)) {\n entries.push(...runtimeChildEntries(id, program, child, bailouts));\n }\n }\n return finalizeElement(\n {\n kind: \"element\",\n form: runtime.form,\n id,\n span: spanOf(id, call),\n propsSpan: props ? spanOf(id, props) : null,\n component\n },\n entries.sort((left, right) => left.span.start - right.span.start),\n bailouts.slice(bailoutStart)\n );\n}\nfunction styledDefinitions(candidate, id, program, imports, bailouts) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"styled\") return;\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n if (!factory) return;\n const definitionBailouts = [];\n const args = childNodes(call, \"arguments\");\n const baseNode = args[0];\n const objectForm = args[1]?.type === \"ObjectExpression\";\n const optionsNode = objectForm ? args[1] : args.length >= 3 ? args[2] : args[1];\n if (!baseNode || !optionsNode) {\n definitionBailouts.push(\n localBailout(\n \"local/unsupported-styled-definition\",\n spanOf(id, call),\n `styled definition ${name} must provide a base and options object`\n )\n );\n bailouts.push(...definitionBailouts);\n return;\n }\n const base = componentFromNode(\n candidate,\n id,\n program,\n imports,\n baseNode,\n definitionBailouts\n );\n if (!base) {\n bailouts.push(...definitionBailouts);\n return;\n }\n const baseClassNode = objectForm ? null : args.length >= 3 ? args[1] : null;\n const staticConfigNode = objectForm && args.length >= 3 ? args[2] : null;\n const baseDefinition = {\n kind: \"styled-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n base,\n baseClassName: baseClassNode ? elementValue(id, baseClassNode) : null,\n options: expressionReference(id, optionsNode),\n staticConfig: staticConfigNode ? expressionReference(id, staticConfigNode) : null\n };\n definitions.push(\n definitionBailouts.length === 0 ? { ...baseDefinition, complete: true, bailouts: [] } : {\n ...baseDefinition,\n complete: false,\n bailouts: definitionBailouts\n }\n );\n bailouts.push(...definitionBailouts);\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nconst DOM_STYLE_FRONTENDS = /* @__PURE__ */ new Set([\n \"tamagui/dom\",\n \"@tamagui/core/dom\",\n \"@tamagui/tailwind\"\n]);\nconst STYLE_FRONTENDS = /* @__PURE__ */ new Set([\n ...DOM_STYLE_FRONTENDS,\n \"tamagui\",\n \"@tamagui/core\",\n \"@tamagui/web\"\n]);\nfunction domStyleDefinitions(id, program, imports) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !STYLE_FRONTENDS.has(binding.source)) {\n return;\n }\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n const value = childNodes(call, \"arguments\")[0];\n if (!factory || !value) return;\n definitions.push({\n kind: \"dom-style-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n value: expressionReference(id, value)\n });\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nfunction domStyleArgument(candidate, id, program, node) {\n let call = node;\n if (node.type === \"Identifier\") {\n const name = identifierName(node);\n const definition = name ? candidate.definitionOf(id, name) : null;\n if (!definition?.constant || !definition.initializer) return null;\n call = definition.initializer;\n }\n if (call.type !== \"CallExpression\") return null;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return null;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !STYLE_FRONTENDS.has(binding.source)) {\n return null;\n }\n return childNodes(call, \"arguments\")[0] ?? null;\n}\nfunction domStyleProgram(candidate, id, program, node) {\n if (node.type !== \"ArrayExpression\" || !Array.isArray(node.elements)) {\n const argument = domStyleArgument(candidate, id, program, node);\n return argument ? {\n kind: \"dom-style\",\n span: spanOf(id, node),\n items: [{ condition: null, value: expressionReference(id, argument) }]\n } : null;\n }\n const items = [];\n for (const rawItem of node.elements) {\n if (!isAstNode(rawItem)) return null;\n let item = rawItem;\n let condition = null;\n if (item.type === \"LogicalExpression\" && item.operator === \"&&\") {\n const left = childNode(item, \"left\");\n const right = childNode(item, \"right\");\n if (!left || !right) return null;\n condition = expressionReference(id, left);\n item = right;\n }\n const argument = domStyleArgument(candidate, id, program, item);\n if (!argument) {\n const staticValue = asStaticValue(item);\n if (staticValue === false || staticValue === null) continue;\n return null;\n }\n items.push({ condition, value: expressionReference(id, argument) });\n }\n return { kind: \"dom-style\", span: spanOf(id, node), items };\n}\nfunction normalizeElements(candidate, rawId, imports = []) {\n const id = resolvedModuleId(rawId);\n const program = candidate.programOf(id);\n const elements = [];\n const bailouts = [];\n walkAst(program, (node) => {\n if (node.type === \"JSXElement\") {\n const bailoutStart = bailouts.length;\n const opening = childNode(node, \"openingElement\");\n const target = opening && jsxComponentNode(opening);\n if (!opening || !target) return;\n const component = componentFromNode(\n candidate,\n id,\n program,\n imports,\n target,\n bailouts\n );\n if (!component) return;\n const closingElement = childNode(node, \"closingElement\");\n const closingName = closingElement && childNode(closingElement, \"name\");\n if (closingName) component.closingSpan = spanOf(id, closingName);\n const entries = jsxEntries(id, node, opening, bailouts);\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(\n finalizeElement(\n {\n kind: \"element\",\n form: \"jsx\",\n id,\n span: spanOf(id, node),\n propsSpan: spanOf(id, opening),\n component\n },\n entries,\n bailouts.slice(bailoutStart)\n )\n );\n return;\n }\n if (node.type !== \"CallExpression\") return;\n const runtime = runtimeCall(program, node);\n if (!runtime) return;\n const element = normalizeRuntimeElement(\n candidate,\n id,\n program,\n imports,\n node,\n runtime,\n bailouts\n );\n if (element) {\n const entries = element.complete ? element.entries : element.bailedEntries;\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(element);\n }\n });\n return {\n elements: elements.sort((left, right) => left.span.start - right.span.start),\n styledDefinitions: styledDefinitions(candidate, id, program, imports, bailouts),\n domStyleDefinitions: domStyleDefinitions(id, program, imports),\n bailouts: bailouts.sort((left, right) => left.span.start - right.span.start)\n };\n}\nfunction nodeAtSpan(program, start, end) {\n return findAstNode(program, (node) => node.start === start && node.end === end, {\n start,\n end\n });\n}\nfunction asAstNode(value, label) {\n if (!isAstNode(value)) throw new Error(`${label} is not an AST node`);\n return value;\n}\nexport {\n asAstNode,\n definitionFromDeclaration,\n nodeAtSpan,\n normalizeElements\n};\n//# sourceMappingURL=normalize.js.map\n"],"mappings":";;;;;;AAeA,SAAS,gBAAgB,MAAM,SAAS,UAAU;CAChD,IAAI,SAAS,WAAW,GAAG;EACzB,OAAO;GAAE,GAAG;GAAM,UAAU;GAAM;GAAS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,KAAK,MAAM,SAAS,SAAS;IAC3B,IAAI,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS;IACrD,MAAM,MAAM,MAAM,MAAM,SAAS,eAAe,WAAW,SAAS,MAAM,MAAM,OAAO,MAAM,MAAM,GAAG,IAAI;IAC1G,MAAM,eAAe,OAAO,gBAAgB,WAAW,IAAI,SAAS,GAAG;IACvE,MAAM,WAAW,OAAO,iBAAiB,WAAW,IAAI,SAAS,GAAG;IACpE,IAAI,cAAc,MAAM,QAAQ;SAC3B,IAAI,UAAU,MAAM,QAAQ,oBAAoB,IAAI,QAAQ;GACnE;GACA,SAAS,KAAK,OAAO;EACvB;CACF,CAAC;CACD,OAAO;EACL,UAAU,SAAS,MAAM,MAAM,UAAU,KAAK,KAAK,QAAQ,MAAM,KAAK,KAAK;EAC3E,mBAAmB,kBAAkB,WAAW,IAAI,SAAS,SAAS,QAAQ;EAC9E,qBAAqB,oBAAoB,IAAI,SAAS,OAAO;EAC7D,UAAU,SAAS,MAAM,MAAM,UAAU,KAAK,KAAK,QAAQ,MAAM,KAAK,KAAK;CAC7E;AACF;AACA,SAAS,WAAW,SAAS,OAAO,KAAK;CACvC,OAAO,YAAY,UAAU,SAAS,KAAK,UAAU,SAAS,KAAK,QAAQ,KAAK;EAC9E;EACA;CACF,CAAC;AACH;AACA,SAAS,UAAU,OAAO,OAAO;CAC/B,IAAI,CAAC,UAAU,KAAK,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,oBAAoB;CACpE,OAAO;AACT"}
package/dist/esm/yuku.mjs CHANGED
@@ -38,8 +38,7 @@ var YukuCandidate = class {
38
38
  #definitionSite(symbol) {
39
39
  const declaration = symbol.declarations[0];
40
40
  if (!declaration) return null;
41
- const program = asAstNode(symbol.module.ast, `${symbol.module.path} program`);
42
- return definitionFromDeclaration(symbol.module.path, symbol.name, program, asAstNode(declaration, `${symbol.name} declaration`));
41
+ return definitionFromDeclaration(symbol.module.path, symbol.name, asAstNode(declaration, `${symbol.name} declaration`), (node) => symbol.module.parentOf(node));
43
42
  }
44
43
  definitionOf(id, localName) {
45
44
  const symbol = this.#canonicalSymbol(id, localName);
@@ -118,6 +117,7 @@ const yukuFactory = {
118
117
  if (node.type !== "ImportDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "ExportAllDeclaration" && node.type !== "ImportExpression") {
119
118
  return;
120
119
  }
120
+ if (node.importKind === "type" || node.exportKind === "type") return;
121
121
  const sourceNode = childNode(node, "source");
122
122
  if (sourceNode && typeof sourceNode.value === "string") {
123
123
  found.push({
@@ -1 +1 @@
1
- {"version":3,"file":"yuku.js","names":["#analyzer","#parseCounts","#module","#canonicalSymbol","#definitionSite"],"sources":["esm/yuku.js"],"sourcesContent":["import { Analyzer } from \"yuku-analyzer\";\nimport { resolveFromHost, resolvedModuleId } from \"./contracts\";\nimport { childNode, walkAst } from \"./ast\";\nimport { asAstNode, definitionFromDeclaration, nodeAtSpan } from \"./normalize\";\nclass YukuCandidate {\n constructor(project) {\n this.project = project;\n this.#analyzer = new Analyzer({\n resolve: (specifier, importer) => resolveFromHost(this.project.resolutions, specifier, importer)\n });\n for (const [id, source] of project.files) this.addFile(id, source);\n }\n project;\n name = \"yuku\";\n #analyzer;\n #parseCounts = /* @__PURE__ */ new Map();\n addFile(id, source) {\n this.#analyzer.addFile(id, source, { preserveParens: true, sourceType: \"module\" });\n this.#parseCounts.set(id, (this.#parseCounts.get(id) ?? 0) + 1);\n }\n removeFile(id) {\n return this.#analyzer.removeFile(id);\n }\n link() {\n this.#analyzer.link();\n }\n #module(id) {\n const module = this.#analyzer.module(id);\n if (!module) throw new Error(`yuku: unknown module ${id}`);\n return module;\n }\n #canonicalSymbol(id, localName) {\n const symbol = this.#module(id).resolve(localName);\n return symbol ? this.#analyzer.definitionOf(symbol)?.symbol ?? null : null;\n }\n #definitionSite(symbol) {\n const declaration = symbol.declarations[0];\n if (!declaration) return null;\n const program = asAstNode(symbol.module.ast, `${symbol.module.path} program`);\n return definitionFromDeclaration(\n symbol.module.path,\n symbol.name,\n program,\n asAstNode(declaration, `${symbol.name} declaration`)\n );\n }\n definitionOf(id, localName) {\n const symbol = this.#canonicalSymbol(id, localName);\n return symbol ? this.#definitionSite(symbol) : null;\n }\n definitionAt(id, start, end) {\n const module = this.#module(id);\n const node = nodeAtSpan(asAstNode(module.ast, `${module.path} program`), start, end);\n if (!node) return null;\n const symbol = module.symbolOf(node);\n const definition = symbol && this.#analyzer.definitionOf(symbol)?.symbol;\n return definition ? this.#definitionSite(definition) : null;\n }\n referencesOf(definition) {\n const symbol = this.#canonicalSymbol(definition.id, definition.name);\n if (!symbol) return [];\n return this.#analyzer.referencesOf(symbol).map(({ module, reference }) => ({\n id: resolvedModuleId(module.path),\n name: reference.name,\n start: reference.node.start,\n end: reference.node.end\n }));\n }\n dependenciesOf(id) {\n return this.#module(id).dependencies.map((module) => module.path).sort();\n }\n dependentsOf(id) {\n return this.#module(id).dependents.map((module) => module.path).sort();\n }\n affectedBy(id) {\n const affected = /* @__PURE__ */ new Set([id]);\n const queue = [id];\n while (queue.length) {\n const current = queue.shift();\n for (const dependent of this.dependentsOf(current)) {\n if (!affected.has(dependent)) {\n affected.add(dependent);\n queue.push(dependent);\n }\n }\n }\n return [...affected].sort();\n }\n programOf(id) {\n return asAstNode(this.#module(id).ast, `${id} program`);\n }\n sourceOf(id) {\n return this.#module(id).source;\n }\n parseCount(id) {\n return this.#parseCounts.get(id) ?? 0;\n }\n diagnostics() {\n const parseDiagnostics = [...this.#analyzer.modules.values()].flatMap(\n (module) => module.diagnostics.map((diagnostic) => ({\n kind: \"parse\",\n id: resolvedModuleId(module.path),\n message: diagnostic.message\n }))\n );\n return [\n ...parseDiagnostics,\n ...this.#analyzer.diagnostics.map((diagnostic) => ({\n kind: \"link\",\n id: resolvedModuleId(diagnostic.module),\n message: diagnostic.message\n }))\n ];\n }\n}\nconst yukuFactory = {\n name: \"yuku\",\n create: (project) => new YukuCandidate(project),\n scanImports(id, source) {\n const candidate = new YukuCandidate({\n files: /* @__PURE__ */ new Map([[id, source]]),\n resolutions: /* @__PURE__ */ new Map()\n });\n const found = [];\n walkAst(candidate.programOf(id), (node) => {\n if (node.type !== \"ImportDeclaration\" && node.type !== \"ExportNamedDeclaration\" && node.type !== \"ExportAllDeclaration\" && node.type !== \"ImportExpression\") {\n return;\n }\n const sourceNode = childNode(node, \"source\");\n if (sourceNode && typeof sourceNode.value === \"string\") {\n found.push({ start: node.start, specifier: sourceNode.value });\n }\n });\n return [\n ...new Set(\n found.sort((left, right) => left.start - right.start).map(({ specifier }) => specifier)\n )\n ];\n }\n};\nfunction parseModuleAst(source, id = \"/tamagui/compiler-module.tsx\") {\n const candidate = yukuFactory.create({\n files: /* @__PURE__ */ new Map([[id, source]]),\n resolutions: /* @__PURE__ */ new Map()\n });\n const diagnostics = candidate.diagnostics().filter((diagnostic) => diagnostic.kind === \"parse\");\n if (diagnostics.length) {\n throw new Error(\n `Unable to parse ${id}: ${diagnostics.map(({ message }) => message).join(\"; \")}`\n );\n }\n return candidate.programOf(id);\n}\nexport {\n parseModuleAst,\n yukuFactory\n};\n//# sourceMappingURL=yuku.js.map\n"],"mappings":";;;;;;AAIA,IAAM,gBAAN,MAAoB;CAClB,YAAY,SAAS;EACnB,KAAK,UAAU;EACf,KAAKA,YAAY,IAAI,SAAS,EAC5B,UAAU,WAAW,aAAa,gBAAgB,KAAK,QAAQ,aAAa,WAAW,QAAQ,EACjG,CAAC;EACD,KAAK,MAAM,CAAC,IAAI,WAAW,QAAQ,OAAO,KAAK,QAAQ,IAAI,MAAM;CACnE;CACA;CACA,OAAO;CACP;CACA,+BAA+B,IAAI,IAAI;CACvC,QAAQ,IAAI,QAAQ;EAClB,KAAKA,UAAU,QAAQ,IAAI,QAAQ;GAAE,gBAAgB;GAAM,YAAY;EAAS,CAAC;EACjF,KAAKC,aAAa,IAAI,KAAK,KAAKA,aAAa,IAAI,EAAE,KAAK,KAAK,CAAC;CAChE;CACA,WAAW,IAAI;EACb,OAAO,KAAKD,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"yuku.js","names":["#analyzer","#parseCounts","#module","#canonicalSymbol","#definitionSite"],"sources":["esm/yuku.js"],"sourcesContent":["import { Analyzer } from \"yuku-analyzer\";\nimport { resolveFromHost, resolvedModuleId } from \"./contracts\";\nimport { childNode, walkAst } from \"./ast\";\nimport { asAstNode, definitionFromDeclaration, nodeAtSpan } from \"./normalize\";\nclass YukuCandidate {\n constructor(project) {\n this.project = project;\n this.#analyzer = new Analyzer({\n resolve: (specifier, importer) => resolveFromHost(this.project.resolutions, specifier, importer)\n });\n for (const [id, source] of project.files) this.addFile(id, source);\n }\n project;\n name = \"yuku\";\n #analyzer;\n #parseCounts = /* @__PURE__ */ new Map();\n addFile(id, source) {\n this.#analyzer.addFile(id, source, { preserveParens: true, sourceType: \"module\" });\n this.#parseCounts.set(id, (this.#parseCounts.get(id) ?? 0) + 1);\n }\n removeFile(id) {\n return this.#analyzer.removeFile(id);\n }\n link() {\n this.#analyzer.link();\n }\n #module(id) {\n const module = this.#analyzer.module(id);\n if (!module) throw new Error(`yuku: unknown module ${id}`);\n return module;\n }\n #canonicalSymbol(id, localName) {\n const symbol = this.#module(id).resolve(localName);\n return symbol ? this.#analyzer.definitionOf(symbol)?.symbol ?? null : null;\n }\n #definitionSite(symbol) {\n const declaration = symbol.declarations[0];\n if (!declaration) return null;\n return definitionFromDeclaration(\n symbol.module.path,\n symbol.name,\n asAstNode(declaration, `${symbol.name} declaration`),\n (node) => symbol.module.parentOf(node)\n );\n }\n definitionOf(id, localName) {\n const symbol = this.#canonicalSymbol(id, localName);\n return symbol ? this.#definitionSite(symbol) : null;\n }\n definitionAt(id, start, end) {\n const module = this.#module(id);\n const node = nodeAtSpan(asAstNode(module.ast, `${module.path} program`), start, end);\n if (!node) return null;\n const symbol = module.symbolOf(node);\n const definition = symbol && this.#analyzer.definitionOf(symbol)?.symbol;\n return definition ? this.#definitionSite(definition) : null;\n }\n referencesOf(definition) {\n const symbol = this.#canonicalSymbol(definition.id, definition.name);\n if (!symbol) return [];\n return this.#analyzer.referencesOf(symbol).map(({ module, reference }) => ({\n id: resolvedModuleId(module.path),\n name: reference.name,\n start: reference.node.start,\n end: reference.node.end\n }));\n }\n dependenciesOf(id) {\n return this.#module(id).dependencies.map((module) => module.path).sort();\n }\n dependentsOf(id) {\n return this.#module(id).dependents.map((module) => module.path).sort();\n }\n affectedBy(id) {\n const affected = /* @__PURE__ */ new Set([id]);\n const queue = [id];\n while (queue.length) {\n const current = queue.shift();\n for (const dependent of this.dependentsOf(current)) {\n if (!affected.has(dependent)) {\n affected.add(dependent);\n queue.push(dependent);\n }\n }\n }\n return [...affected].sort();\n }\n programOf(id) {\n return asAstNode(this.#module(id).ast, `${id} program`);\n }\n sourceOf(id) {\n return this.#module(id).source;\n }\n parseCount(id) {\n return this.#parseCounts.get(id) ?? 0;\n }\n diagnostics() {\n const parseDiagnostics = [...this.#analyzer.modules.values()].flatMap(\n (module) => module.diagnostics.map((diagnostic) => ({\n kind: \"parse\",\n id: resolvedModuleId(module.path),\n message: diagnostic.message\n }))\n );\n return [\n ...parseDiagnostics,\n ...this.#analyzer.diagnostics.map((diagnostic) => ({\n kind: \"link\",\n id: resolvedModuleId(diagnostic.module),\n message: diagnostic.message\n }))\n ];\n }\n}\nconst yukuFactory = {\n name: \"yuku\",\n create: (project) => new YukuCandidate(project),\n scanImports(id, source) {\n const candidate = new YukuCandidate({\n files: /* @__PURE__ */ new Map([[id, source]]),\n resolutions: /* @__PURE__ */ new Map()\n });\n const found = [];\n walkAst(candidate.programOf(id), (node) => {\n if (node.type !== \"ImportDeclaration\" && node.type !== \"ExportNamedDeclaration\" && node.type !== \"ExportAllDeclaration\" && node.type !== \"ImportExpression\") {\n return;\n }\n if (node.importKind === \"type\" || node.exportKind === \"type\") return;\n const sourceNode = childNode(node, \"source\");\n if (sourceNode && typeof sourceNode.value === \"string\") {\n found.push({ start: node.start, specifier: sourceNode.value });\n }\n });\n return [\n ...new Set(\n found.sort((left, right) => left.start - right.start).map(({ specifier }) => specifier)\n )\n ];\n }\n};\nfunction parseModuleAst(source, id = \"/tamagui/compiler-module.tsx\") {\n const candidate = yukuFactory.create({\n files: /* @__PURE__ */ new Map([[id, source]]),\n resolutions: /* @__PURE__ */ new Map()\n });\n const diagnostics = candidate.diagnostics().filter((diagnostic) => diagnostic.kind === \"parse\");\n if (diagnostics.length) {\n throw new Error(\n `Unable to parse ${id}: ${diagnostics.map(({ message }) => message).join(\"; \")}`\n );\n }\n return candidate.programOf(id);\n}\nexport {\n parseModuleAst,\n yukuFactory\n};\n//# sourceMappingURL=yuku.js.map\n"],"mappings":";;;;;;AAIA,IAAM,gBAAN,MAAoB;CAClB,YAAY,SAAS;EACnB,KAAK,UAAU;EACf,KAAKA,YAAY,IAAI,SAAS,EAC5B,UAAU,WAAW,aAAa,gBAAgB,KAAK,QAAQ,aAAa,WAAW,QAAQ,EACjG,CAAC;EACD,KAAK,MAAM,CAAC,IAAI,WAAW,QAAQ,OAAO,KAAK,QAAQ,IAAI,MAAM;CACnE;CACA;CACA,OAAO;CACP;CACA,+BAA+B,IAAI,IAAI;CACvC,QAAQ,IAAI,QAAQ;EAClB,KAAKA,UAAU,QAAQ,IAAI,QAAQ;GAAE,gBAAgB;GAAM,YAAY;EAAS,CAAC;EACjF,KAAKC,aAAa,IAAI,KAAK,KAAKA,aAAa,IAAI,EAAE,KAAK,KAAK,CAAC;CAChE;CACA,WAAW,IAAI;EACb,OAAO,KAAKD,UAAU,WAAW,EAAE;CACrC;CACA,OAAO;EACL,KAAKA,UAAU,KAAK;CACtB;CACA,QAAQ,IAAI;EACV,MAAM,SAAS,KAAKA,UAAU,OAAO,EAAE;EACvC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,wBAAwB,IAAI;EACzD,OAAO;CACT;CACA,iBAAiB,IAAI,WAAW;EAC9B,MAAM,SAAS,KAAKE,QAAQ,EAAE,CAAC,CAAC,QAAQ,SAAS;EACjD,OAAO,SAAS,KAAKF,UAAU,aAAa,MAAM,CAAC,EAAE,UAAU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C,IAAI,KAAK,SAAS,uBAAuB,KAAK,SAAS,4BAA4B,KAAK,SAAS,0BAA0B,KAAK,SAAS,oBAAoB;IAC3J;GACF;GACA,IAAI,KAAK,eAAe,UAAU,KAAK,eAAe,QAAQ;GAC9D,MAAM,aAAa,UAAU,MAAM,QAAQ;GAC3C,IAAI,cAAc,OAAO,WAAW,UAAU,UAAU;IACtD,MAAM,KAAK;KAAE,OAAO,KAAK;KAAO,WAAW,WAAW;IAAM,CAAC;GAC/D;EACF,CAAC;EACD,OAAO,CACL,GAAG,IAAI,IACL,MAAM,MAAM,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,gBAAgB,SAAS,CACxF,CACF;CACF;AACF;AACA,SAAS,eAAe,QAAQ,KAAK,gCAAgC;CACnE,MAAM,YAAY,YAAY,OAAO;EACnC,uBAAuB,IAAI,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;EAC7C,6BAA6B,IAAI,IAAI;CACvC,CAAC;CACD,MAAM,cAAc,UAAU,YAAY,CAAC,CAAC,QAAQ,eAAe,WAAW,SAAS,OAAO;CAC9F,IAAI,YAAY,QAAQ;EACtB,MAAM,IAAI,MACR,mBAAmB,GAAG,IAAI,YAAY,KAAK,EAAE,cAAc,OAAO,CAAC,CAAC,KAAK,IAAI,GAC/E;CACF;CACA,OAAO,UAAU,UAAU,EAAE;AAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/compiler-core",
3
- "version": "3.0.0-beta.924.1",
3
+ "version": "3.0.1",
4
4
  "description": "Shared parser-independent Tamagui compiler graph and element IR",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,12 +40,13 @@
40
40
  "yuku-analyzer": "0.6.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@tamagui/build": "3.0.0-beta.924.1",
44
- "typescript": "~6.0.3"
43
+ "@tamagui/build": "3.0.1",
44
+ "typescript": "7.0.2"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
48
48
  "url": "git+https://github.com/tamagui/tamagui.git",
49
49
  "directory": "code/compiler/compiler-core"
50
- }
50
+ },
51
+ "releaseSourceCommit": "c156b7cc55e5a6cc5883ebc8189720850ac32dbd"
51
52
  }
package/src/ast.ts CHANGED
@@ -20,8 +20,9 @@ export function walkAst(
20
20
  ): void {
21
21
  visitor(node, parent, key)
22
22
 
23
- for (const [childKey, value] of Object.entries(node)) {
23
+ for (const childKey of Object.keys(node)) {
24
24
  if (ignoredKeys.has(childKey)) continue
25
+ const value = node[childKey]
25
26
  if (isAstNode(value)) {
26
27
  walkAst(value, visitor, node, childKey)
27
28
  } else if (Array.isArray(value)) {
@@ -34,17 +35,36 @@ export function walkAst(
34
35
  }
35
36
  }
36
37
 
38
+ /** With a source range, only descend into nodes that contain that range. */
37
39
  export function findAstNode(
38
40
  root: AstNode,
39
- predicate: (node: AstNode, parent: AstNode | null, key: string | null) => boolean
41
+ predicate: (node: AstNode, parent: AstNode | null, key: string | null) => boolean,
42
+ span?: Pick<AstNode, 'start' | 'end'>
40
43
  ): AstNode | null {
41
- let found: AstNode | null = null
42
- walkAst(root, (node, parent, key) => {
43
- if (!found && predicate(node, parent, key)) {
44
- found = node
44
+ function visit(
45
+ node: AstNode,
46
+ parent: AstNode | null,
47
+ key: string | null
48
+ ): AstNode | null {
49
+ if (span && (node.start > span.start || node.end < span.end)) return null
50
+ if (predicate(node, parent, key)) return node
51
+ for (const childKey of Object.keys(node)) {
52
+ if (ignoredKeys.has(childKey)) continue
53
+ const value = node[childKey]
54
+ if (isAstNode(value)) {
55
+ const found = visit(value, node, childKey)
56
+ if (found) return found
57
+ } else if (Array.isArray(value)) {
58
+ for (const child of value) {
59
+ if (!isAstNode(child)) continue
60
+ const found = visit(child, node, childKey)
61
+ if (found) return found
62
+ }
63
+ }
45
64
  }
46
- })
47
- return found
65
+ return null
66
+ }
67
+ return visit(root, null, null)
48
68
  }
49
69
 
50
70
  export function childNode(node: AstNode, key: string): AstNode | null {
package/src/evaluate.ts CHANGED
@@ -481,8 +481,8 @@ function evaluateDynamicNode(
481
481
  }
482
482
  }
483
483
 
484
- // a template whose every interpolation takes finitely many primitives takes
485
- // finitely many strings: `w-6 ${colors[index % 2]}` is two class strings
484
+ // templates always produce strings. retain the finite values when every
485
+ // interpolation is bounded: `w-6 ${colors[index % 2]}` is two class strings.
486
486
  if (node.type === 'TemplateLiteral') {
487
487
  const quasis = childNodes(node, 'quasis')
488
488
  const expressions = childNodes(node, 'expressions')
@@ -493,7 +493,7 @@ function evaluateDynamicNode(
493
493
  const expression = expressions[position]
494
494
  if (!expression) continue
495
495
  const part = evaluateDynamicNode(resolver, id, expression, state)
496
- if (!part?.values) return null
496
+ if (!part?.values) return { type: 'string' }
497
497
  const next: string[] = []
498
498
  for (const value of values) {
499
499
  for (const primitive of part.values) {
@@ -501,7 +501,7 @@ function evaluateDynamicNode(
501
501
  if (!next.includes(joined)) next.push(joined)
502
502
  }
503
503
  }
504
- if (next.length > 32) return null
504
+ if (next.length > 32) return { type: 'string' }
505
505
  values = next
506
506
  }
507
507
  return { type: 'string', values }
@@ -700,7 +700,7 @@ function mapBranchLeaves(
700
700
 
701
701
  /**
702
702
  * A template literal is a decision tree once every value it interpolates is:
703
- * `${active ? 'red10' : 'blue10'}` names the same two strings the bare ternary
703
+ * `${active ? 'red-10' : 'blue-10'}` names the same two strings the bare ternary
704
704
  * does, and the quasis around it are constants. Each interpolated tree
705
705
  * multiplies the leaves, so every step spends a level of the shared depth
706
706
  * budget and a wide template refuses instead of expanding.
package/src/lower.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ResolvedModuleId, SourceSpan } from './contracts'
2
+ import type { DynamicEvaluation } from './evaluate'
2
3
  import { localBailout, type BailoutReason } from './diagnostics'
3
4
  import type {
4
5
  MaterializedElement,
@@ -13,7 +14,7 @@ import {
13
14
  type SourceEdit,
14
15
  } from './output'
15
16
 
16
- export const LOWERED_MODULE_PLAN_VERSION = 3
17
+ export const LOWERED_MODULE_PLAN_VERSION = 5
17
18
 
18
19
  export type CompilerTarget = 'web' | 'native'
19
20
 
@@ -73,7 +74,9 @@ export interface CompilerLoweringHost {
73
74
  canLowerDynamicStyleProp?(
74
75
  name: string,
75
76
  component: LoweringComponent,
76
- valueKind?: 'bailout' | 'conditional'
77
+ valueKind?: 'bailout' | 'conditional',
78
+ /** what the evaluator proved about an opaque value: its type and finite domain */
79
+ dynamic?: DynamicEvaluation | null
77
80
  ): boolean
78
81
  lowerCandidate(input: LoweringCandidateInput): LoweringCandidateResult
79
82
  /** Development-only source instrumentation for an existing component debug channel. */
@@ -184,7 +187,12 @@ function unsafeEntry(
184
187
  entry.kind === 'prop' &&
185
188
  host.isStyleProp(entry.name, component) &&
186
189
  (entry.value.kind === 'bailout' || entry.value.kind === 'conditional') &&
187
- !host.canLowerDynamicStyleProp?.(entry.name, component, entry.value.kind)
190
+ !host.canLowerDynamicStyleProp?.(
191
+ entry.name,
192
+ component,
193
+ entry.value.kind,
194
+ entry.value.kind === 'bailout' ? entry.value.dynamic : null
195
+ )
188
196
  ) {
189
197
  return diagnostic(
190
198
  'local/dynamic-style-value',
@@ -199,7 +207,12 @@ function unsafeEntry(
199
207
  if (member.value.kind !== 'bailout' && member.value.kind !== 'conditional') continue
200
208
  if (
201
209
  !host.isStyleProp(member.name, component) ||
202
- !host.canLowerDynamicStyleProp?.(member.name, component, member.value.kind)
210
+ !host.canLowerDynamicStyleProp?.(
211
+ member.name,
212
+ component,
213
+ member.value.kind,
214
+ member.value.kind === 'bailout' ? member.value.dynamic : null
215
+ )
203
216
  ) {
204
217
  return diagnostic(
205
218
  'local/dynamic-style-value',
package/src/normalize.ts CHANGED
@@ -54,8 +54,8 @@ function finalizeElement(
54
54
  export function definitionFromDeclaration(
55
55
  id: string,
56
56
  name: string,
57
- program: AstNode,
58
- declaration: AstNode
57
+ declaration: AstNode,
58
+ parentOf: (node: AstNode) => AstNode | null
59
59
  ): DefinitionSite {
60
60
  let identifier = declaration
61
61
  let initializer: AstNode | null = null
@@ -64,33 +64,17 @@ export function definitionFromDeclaration(
64
64
  if (declaration.type === 'VariableDeclarator') {
65
65
  identifier = childNode(declaration, 'id') ?? declaration
66
66
  initializer = childNode(declaration, 'init')
67
- constant = !!findAstNode(
68
- program,
69
- (node) =>
70
- node.type === 'VariableDeclaration' &&
71
- node.kind === 'const' &&
72
- childNodes(node, 'declarations').some(
73
- (candidate) => candidate.start === declaration.start
74
- )
75
- )
67
+ const parent = parentOf(declaration)
68
+ constant = parent?.type === 'VariableDeclaration' && parent.kind === 'const'
76
69
  } else if (declaration.type === 'Identifier') {
77
- const declarator = findAstNode(
78
- program,
79
- (node) =>
80
- node.type === 'VariableDeclarator' &&
81
- childNode(node, 'id')?.start === declaration.start
82
- )
83
- if (declarator) {
70
+ const declarator = parentOf(declaration)
71
+ if (
72
+ declarator?.type === 'VariableDeclarator' &&
73
+ childNode(declarator, 'id')?.start === declaration.start
74
+ ) {
84
75
  initializer = childNode(declarator, 'init')
85
- constant = !!findAstNode(
86
- program,
87
- (node) =>
88
- node.type === 'VariableDeclaration' &&
89
- node.kind === 'const' &&
90
- childNodes(node, 'declarations').some(
91
- (candidate) => candidate.start === declarator.start
92
- )
93
- )
76
+ const parent = parentOf(declarator)
77
+ constant = parent?.type === 'VariableDeclaration' && parent.kind === 'const'
94
78
  }
95
79
  }
96
80
 
@@ -838,7 +822,10 @@ export function normalizeElements(
838
822
  }
839
823
 
840
824
  export function nodeAtSpan(program: AstNode, start: number, end: number): AstNode | null {
841
- return findAstNode(program, (node) => node.start === start && node.end === end)
825
+ return findAstNode(program, (node) => node.start === start && node.end === end, {
826
+ start,
827
+ end,
828
+ })
842
829
  }
843
830
 
844
831
  export function asAstNode(value: unknown, label: string): AstNode {
package/src/yuku.ts CHANGED
@@ -53,12 +53,11 @@ class YukuCandidate implements AnalyzerCandidate {
53
53
  #definitionSite(symbol: YukuSymbol): DefinitionSite | null {
54
54
  const declaration = symbol.declarations[0]
55
55
  if (!declaration) return null
56
- const program = asAstNode(symbol.module.ast, `${symbol.module.path} program`)
57
56
  return definitionFromDeclaration(
58
57
  symbol.module.path,
59
58
  symbol.name,
60
- program,
61
- asAstNode(declaration, `${symbol.name} declaration`)
59
+ asAstNode(declaration, `${symbol.name} declaration`),
60
+ (node) => symbol.module.parentOf(node as any) as AstNode | null
62
61
  )
63
62
  }
64
63
 
@@ -163,6 +162,8 @@ export const yukuFactory: CandidateFactory = {
163
162
  ) {
164
163
  return
165
164
  }
165
+ // type-only imports erase at build time, so there is nothing to resolve
166
+ if (node.importKind === 'type' || node.exportKind === 'type') return
166
167
  const sourceNode = childNode(node, 'source')
167
168
  if (sourceNode && typeof sourceNode.value === 'string') {
168
169
  found.push({ start: node.start, specifier: sourceNode.value })
package/types/ast.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { AstNode } from './contracts';
2
2
  export declare function isAstNode(value: unknown): value is AstNode;
3
3
  export declare function walkAst(node: AstNode, visitor: (node: AstNode, parent: AstNode | null, key: string | null) => void, parent?: AstNode | null, key?: string | null): void;
4
- export declare function findAstNode(root: AstNode, predicate: (node: AstNode, parent: AstNode | null, key: string | null) => boolean): AstNode | null;
4
+ /** With a source range, only descend into nodes that contain that range. */
5
+ export declare function findAstNode(root: AstNode, predicate: (node: AstNode, parent: AstNode | null, key: string | null) => boolean, span?: Pick<AstNode, 'start' | 'end'>): AstNode | null;
5
6
  export declare function childNode(node: AstNode, key: string): AstNode | null;
6
7
  export declare function childNodes(node: AstNode, key: string): AstNode[];
7
8
  export declare function identifierName(node: AstNode | null): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAQ1D;AAED,wBAAgB,OAAO,CACrB,I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M,GAAE,OAAO,GAAG,IAAW,EAC7B,GAAG,GAAE,MAAM,GAAG,IAAW,GACxB,IAAI,CAgBN;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CACzB,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,EACjF,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,GACpC,OAAO,GAAG,IAAI,CAyBhB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAGpE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAGhE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAM1D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAavD"}
package/types/lower.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { ResolvedModuleId, SourceSpan } from './contracts';
2
+ import type { DynamicEvaluation } from './evaluate';
2
3
  import { type BailoutReason } from './diagnostics';
3
4
  import type { MaterializedElement, MaterializedModule, MaterializedStyledDefinition } from './materialize';
4
5
  import { type ApplicableLoweredModulePlan, type SourceEdit } from './output';
5
- export declare const LOWERED_MODULE_PLAN_VERSION = 3;
6
+ export declare const LOWERED_MODULE_PLAN_VERSION = 5;
6
7
  export type CompilerTarget = 'web' | 'native';
7
8
  export interface LoweredModuleStats {
8
9
  found: number;
@@ -50,7 +51,9 @@ export interface CompilerLoweringHost {
50
51
  resolveComponent(element: MaterializedElement, styledDefinition: MaterializedStyledDefinition | null): LoweringComponent | null;
51
52
  isStyleProp(name: string, component: LoweringComponent): boolean;
52
53
  /** The host can retain this dynamic prop while committing other safe candidate edits. */
53
- canLowerDynamicStyleProp?(name: string, component: LoweringComponent, valueKind?: 'bailout' | 'conditional'): boolean;
54
+ canLowerDynamicStyleProp?(name: string, component: LoweringComponent, valueKind?: 'bailout' | 'conditional',
55
+ /** what the evaluator proved about an opaque value: its type and finite domain */
56
+ dynamic?: DynamicEvaluation | null): boolean;
54
57
  lowerCandidate(input: LoweringCandidateInput): LoweringCandidateResult;
55
58
  /** Development-only source instrumentation for an existing component debug channel. */
56
59
  developmentDebugInstrumentation?(input: LoweringCandidateInput, result: LoweringCandidateResult): SourceEdit[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"lower.d.ts","sourceRoot":"","sources":["../src/lower.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EACV,mBAAmB,EAEnB,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,KAAK,2BAA2B,EAChC,KAAK,UAAU,EAChB,MAAM,UAAU,CAAA;AAEjB,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE7C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,OAAO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,EAAE,UAAU,EAAE,CAAA;IACnB,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,WAAW,EAAE,aAAa,EAAE,CAAA;IAC5B,YAAY,EAAE,gBAAgB,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,KAAK,EAAE;QACf,MAAM,EAAE,kBAAkB,CAAA;QAC1B,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,cAAc,CAAA;KACvB,GAAG,0BAA0B,CAAA;CAC/B;AAED,MAAM,WAAW,iBAAkB,SAAQ,2BAA2B;IACpE,OAAO,EAAE,OAAO,2BAA2B,CAAA;IAC3C,MAAM,EAAE,cAAc,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,aAAa,EAAE,CAAA;IAC5B,YAAY,EAAE,gBAAgB,EAAE,CAAA;IAChC,KAAK,EAAE,kBAAkB,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,kBAAkB,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,cAAc,CAAA;IACtB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,OAAO,EAAE,kBAAkB,CAAA;IAC3B,cAAc,CAAC,EAAE,oBAAoB,CAAA;CACtC;AA+HD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,cAAc,GACf,EAAE,gBAAgB,GAAG,iBAAiB,CAsLtC"}
@@ -1,6 +1,6 @@
1
1
  import { type AnalyzerCandidate, type AstNode, type DefinitionSite, type HostResolvedImport } from './contracts';
2
2
  import type { ElementIRResult } from './ir';
3
- export declare function definitionFromDeclaration(id: string, name: string, program: AstNode, declaration: AstNode): DefinitionSite;
3
+ export declare function definitionFromDeclaration(id: string, name: string, declaration: AstNode, parentOf: (node: AstNode) => AstNode | null): DefinitionSite;
4
4
  export declare function normalizeElements(candidate: AnalyzerCandidate, rawId: string, imports?: readonly HostResolvedImport[]): ElementIRResult;
5
5
  export declare function nodeAtSpan(program: AstNode, start: number, end: number): AstNode | null;
6
6
  export declare function asAstNode(value: unknown, label: string): AstNode;
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAMV,eAAe,EAQhB,MAAM,MAAM,CAAA;AAmBb,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,OAAO,GACnB,cAAc,CA8ChB;AAioBD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,SAAS,kBAAkB,EAAO,GAC1C,eAAe,CAwFjB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAEvF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGhE"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAMV,eAAe,EAQhB,MAAM,MAAM,CAAA;AAmBb,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAC1C,cAAc,CA8BhB;AAioBD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,SAAS,kBAAkB,EAAO,GAC1C,eAAe,CAwFjB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAKvF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"yuku.d.ts","sourceRoot":"","sources":["../src/yuku.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,OAAO,EACP,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AAyIpB,eAAO,MAAM,WAAW,EAAE,gBA+BzB,CAAA;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,EAAE,SAAiC,GAClC,OAAO,CAcT"}
1
+ {"version":3,"file":"yuku.d.ts","sourceRoot":"","sources":["../src/yuku.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,OAAO,EACP,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AAwIpB,eAAO,MAAM,WAAW,EAAE,gBAiCzB,CAAA;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,EAAE,SAAiC,GAClC,OAAO,CAcT"}