@homebound/truss 2.0.0-next.5 → 2.0.0-next.7
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/build/plugin/index.d.ts +3 -3
- package/build/plugin/index.js +221 -66
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.d.ts
CHANGED
|
@@ -58,9 +58,9 @@ interface TrussVitePlugin {
|
|
|
58
58
|
* Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL
|
|
59
59
|
* into file-local `stylex.create()` + `stylex.props()` calls.
|
|
60
60
|
*
|
|
61
|
-
* Also supports `.css.ts` files: a `.css.ts` file with
|
|
62
|
-
*
|
|
63
|
-
*
|
|
61
|
+
* Also supports `.css.ts` files: a `.css.ts` file with
|
|
62
|
+
* `export const css = { ".selector": Css.blue.$ }` can keep other runtime exports,
|
|
63
|
+
* while imports are supplemented with a virtual CSS side-effect module.
|
|
64
64
|
*
|
|
65
65
|
* Must be placed BEFORE the StyleX unplugin in the plugins array so that
|
|
66
66
|
* StyleX's babel plugin can process the generated `stylex.create()` calls.
|
package/build/plugin/index.js
CHANGED
|
@@ -1238,7 +1238,7 @@ function rewriteExpressionSites(options) {
|
|
|
1238
1238
|
site.path.replaceWith(t3.arrayExpression(propsArgs));
|
|
1239
1239
|
}
|
|
1240
1240
|
rewriteStyleObjectExpressions(options.ast);
|
|
1241
|
-
|
|
1241
|
+
rewriteCssAttributeExpressions(options.ast, options.stylexNamespaceName);
|
|
1242
1242
|
}
|
|
1243
1243
|
function getCssAttributePath(path) {
|
|
1244
1244
|
const parentPath = path.parentPath;
|
|
@@ -1315,34 +1315,17 @@ function buildPropsArgs(segments, options) {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
return args;
|
|
1317
1317
|
}
|
|
1318
|
-
function
|
|
1318
|
+
function rewriteCssAttributeExpressions(ast, stylexNamespaceName) {
|
|
1319
1319
|
traverse(ast, {
|
|
1320
1320
|
JSXAttribute(path) {
|
|
1321
1321
|
if (!t3.isJSXIdentifier(path.node.name, { name: "css" })) return;
|
|
1322
1322
|
const value = path.node.value;
|
|
1323
1323
|
if (!t3.isJSXExpressionContainer(value)) return;
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
const arg = el.argument;
|
|
1330
|
-
if (t3.isArrayExpression(arg)) {
|
|
1331
|
-
for (const inner of arg.elements) {
|
|
1332
|
-
if (!inner) continue;
|
|
1333
|
-
if (t3.isSpreadElement(inner)) {
|
|
1334
|
-
propsArgs.push(t3.spreadElement(inner.argument));
|
|
1335
|
-
} else {
|
|
1336
|
-
propsArgs.push(inner);
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
} else {
|
|
1340
|
-
propsArgs.push(t3.spreadElement(arg));
|
|
1341
|
-
}
|
|
1342
|
-
} else if (el) {
|
|
1343
|
-
propsArgs.push(el);
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1324
|
+
if (!t3.isExpression(value.expression)) return;
|
|
1325
|
+
const expr = normalizeStyleArrayLikeExpression(value.expression, path, /* @__PURE__ */ new Set());
|
|
1326
|
+
if (!expr) return;
|
|
1327
|
+
const propsArgs = buildStyleArrayLikePropsArgs(expr, path, /* @__PURE__ */ new Set());
|
|
1328
|
+
if (!propsArgs) return;
|
|
1346
1329
|
const propsCall = t3.callExpression(
|
|
1347
1330
|
t3.memberExpression(t3.identifier(stylexNamespaceName), t3.identifier("props")),
|
|
1348
1331
|
propsArgs
|
|
@@ -1351,6 +1334,36 @@ function rewriteCssArrayExpressions(ast, stylexNamespaceName) {
|
|
|
1351
1334
|
}
|
|
1352
1335
|
});
|
|
1353
1336
|
}
|
|
1337
|
+
function buildStyleArrayLikePropsArgs(expr, path, seen) {
|
|
1338
|
+
if (seen.has(expr)) return null;
|
|
1339
|
+
seen.add(expr);
|
|
1340
|
+
if (t3.isArrayExpression(expr)) {
|
|
1341
|
+
const propsArgs = [];
|
|
1342
|
+
for (const el of expr.elements) {
|
|
1343
|
+
if (!el) continue;
|
|
1344
|
+
if (t3.isSpreadElement(el)) {
|
|
1345
|
+
const normalizedArg = normalizeStyleArrayLikeExpression(el.argument, path, /* @__PURE__ */ new Set());
|
|
1346
|
+
if (!normalizedArg) {
|
|
1347
|
+
propsArgs.push(t3.spreadElement(el.argument));
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
const nestedArgs = buildStyleArrayLikePropsArgs(normalizedArg, path, seen);
|
|
1351
|
+
if (nestedArgs && t3.isArrayExpression(normalizedArg)) {
|
|
1352
|
+
propsArgs.push(...nestedArgs);
|
|
1353
|
+
} else {
|
|
1354
|
+
propsArgs.push(t3.spreadElement(normalizedArg));
|
|
1355
|
+
}
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
propsArgs.push(el);
|
|
1359
|
+
}
|
|
1360
|
+
return propsArgs;
|
|
1361
|
+
}
|
|
1362
|
+
if (t3.isIdentifier(expr) || t3.isMemberExpression(expr) || t3.isConditionalExpression(expr)) {
|
|
1363
|
+
return [t3.spreadElement(expr)];
|
|
1364
|
+
}
|
|
1365
|
+
return null;
|
|
1366
|
+
}
|
|
1354
1367
|
function rewriteStyleObjectExpressions(ast) {
|
|
1355
1368
|
traverse(ast, {
|
|
1356
1369
|
ObjectExpression(path) {
|
|
@@ -1368,7 +1381,7 @@ function tryBuildStyleArrayFromObject(path) {
|
|
|
1368
1381
|
if (!t3.isSpreadElement(prop)) {
|
|
1369
1382
|
return null;
|
|
1370
1383
|
}
|
|
1371
|
-
const normalizedArg =
|
|
1384
|
+
const normalizedArg = normalizeStyleArrayLikeExpression(
|
|
1372
1385
|
prop.argument,
|
|
1373
1386
|
path,
|
|
1374
1387
|
/* @__PURE__ */ new Set()
|
|
@@ -1377,7 +1390,7 @@ function tryBuildStyleArrayFromObject(path) {
|
|
|
1377
1390
|
if (!normalizedArg) {
|
|
1378
1391
|
return null;
|
|
1379
1392
|
}
|
|
1380
|
-
if (
|
|
1393
|
+
if (isStyleArrayLike(normalizedArg, path, /* @__PURE__ */ new Set())) {
|
|
1381
1394
|
sawStyleArray = true;
|
|
1382
1395
|
}
|
|
1383
1396
|
if (t3.isArrayExpression(normalizedArg)) {
|
|
@@ -1389,30 +1402,30 @@ function tryBuildStyleArrayFromObject(path) {
|
|
|
1389
1402
|
if (!sawStyleArray) return null;
|
|
1390
1403
|
return t3.arrayExpression(elements);
|
|
1391
1404
|
}
|
|
1392
|
-
function
|
|
1405
|
+
function normalizeStyleArrayLikeExpression(expr, path, seen) {
|
|
1393
1406
|
if (seen.has(expr)) return null;
|
|
1394
1407
|
seen.add(expr);
|
|
1395
1408
|
if (t3.isArrayExpression(expr)) return expr;
|
|
1396
1409
|
if (t3.isConditionalExpression(expr)) {
|
|
1397
|
-
const consequent =
|
|
1398
|
-
const alternate =
|
|
1410
|
+
const consequent = normalizeStyleArrayLikeBranch(expr.consequent, path, seen);
|
|
1411
|
+
const alternate = normalizeStyleArrayLikeBranch(expr.alternate, path, seen);
|
|
1399
1412
|
if (!consequent || !alternate) return null;
|
|
1400
1413
|
return t3.conditionalExpression(expr.test, consequent, alternate);
|
|
1401
1414
|
}
|
|
1402
1415
|
if (t3.isIdentifier(expr) || t3.isMemberExpression(expr)) {
|
|
1403
1416
|
const nestedSeen = new Set(seen);
|
|
1404
1417
|
nestedSeen.delete(expr);
|
|
1405
|
-
if (
|
|
1418
|
+
if (isStyleArrayLike(expr, path, nestedSeen)) return expr;
|
|
1406
1419
|
}
|
|
1407
1420
|
return null;
|
|
1408
1421
|
}
|
|
1409
|
-
function
|
|
1422
|
+
function normalizeStyleArrayLikeBranch(expr, path, seen) {
|
|
1410
1423
|
if (isEmptyObjectExpression(expr)) {
|
|
1411
1424
|
return t3.arrayExpression([]);
|
|
1412
1425
|
}
|
|
1413
|
-
return
|
|
1426
|
+
return normalizeStyleArrayLikeExpression(expr, path, seen);
|
|
1414
1427
|
}
|
|
1415
|
-
function
|
|
1428
|
+
function isStyleArrayLike(expr, path, seen) {
|
|
1416
1429
|
if (seen.has(expr)) return false;
|
|
1417
1430
|
seen.add(expr);
|
|
1418
1431
|
if (t3.isArrayExpression(expr)) return true;
|
|
@@ -1424,7 +1437,7 @@ function isStyleArrayLikeExpression(expr, path, seen) {
|
|
|
1424
1437
|
const bindingPath = binding?.path;
|
|
1425
1438
|
if (!bindingPath || !bindingPath.isVariableDeclarator()) return false;
|
|
1426
1439
|
const init = bindingPath.node.init;
|
|
1427
|
-
return !!(init &&
|
|
1440
|
+
return !!(init && isStyleArrayLike(init, bindingPath, seen));
|
|
1428
1441
|
}
|
|
1429
1442
|
if (t3.isMemberExpression(expr) && !expr.computed && t3.isIdentifier(expr.property)) {
|
|
1430
1443
|
const object = expr.object;
|
|
@@ -1439,13 +1452,13 @@ function isStyleArrayLikeExpression(expr, path, seen) {
|
|
|
1439
1452
|
if (!t3.isObjectProperty(prop) || prop.computed) continue;
|
|
1440
1453
|
if (!isMatchingPropertyName(prop.key, propertyName)) continue;
|
|
1441
1454
|
const value = prop.value;
|
|
1442
|
-
return t3.isExpression(value) &&
|
|
1455
|
+
return t3.isExpression(value) && isStyleArrayLike(value, bindingPath, seen);
|
|
1443
1456
|
}
|
|
1444
1457
|
}
|
|
1445
1458
|
return false;
|
|
1446
1459
|
}
|
|
1447
1460
|
function isStyleArrayLikeBranch(expr, path, seen) {
|
|
1448
|
-
return isEmptyObjectExpression(expr) ||
|
|
1461
|
+
return isEmptyObjectExpression(expr) || isStyleArrayLike(expr, path, seen);
|
|
1449
1462
|
}
|
|
1450
1463
|
function isMatchingPropertyName(key, name) {
|
|
1451
1464
|
return t3.isIdentifier(key) && key.name === name || t3.isStringLiteral(key) && key.value === name;
|
|
@@ -1587,7 +1600,72 @@ function hoistMarkerDeclarations(ast, names) {
|
|
|
1587
1600
|
|
|
1588
1601
|
// src/plugin/transform-css.ts
|
|
1589
1602
|
import { parse as parse2 } from "@babel/parser";
|
|
1603
|
+
import * as t6 from "@babel/types";
|
|
1604
|
+
|
|
1605
|
+
// src/plugin/css-ts-utils.ts
|
|
1590
1606
|
import * as t5 from "@babel/types";
|
|
1607
|
+
function collectStaticStringBindings(ast) {
|
|
1608
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
1609
|
+
let changed = true;
|
|
1610
|
+
while (changed) {
|
|
1611
|
+
changed = false;
|
|
1612
|
+
for (const node of ast.program.body) {
|
|
1613
|
+
const declaration = getTopLevelVariableDeclaration(node);
|
|
1614
|
+
if (!declaration) continue;
|
|
1615
|
+
for (const declarator of declaration.declarations) {
|
|
1616
|
+
if (!t5.isIdentifier(declarator.id) || !declarator.init) continue;
|
|
1617
|
+
if (bindings.has(declarator.id.name)) continue;
|
|
1618
|
+
const value = resolveStaticString(declarator.init, bindings);
|
|
1619
|
+
if (value === null) continue;
|
|
1620
|
+
bindings.set(declarator.id.name, value);
|
|
1621
|
+
changed = true;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return bindings;
|
|
1626
|
+
}
|
|
1627
|
+
function resolveStaticString(node, bindings) {
|
|
1628
|
+
if (!node) return null;
|
|
1629
|
+
if (t5.isStringLiteral(node)) return node.value;
|
|
1630
|
+
if (t5.isTemplateLiteral(node)) {
|
|
1631
|
+
let value = "";
|
|
1632
|
+
for (let i = 0; i < node.quasis.length; i++) {
|
|
1633
|
+
value += node.quasis[i].value.cooked ?? "";
|
|
1634
|
+
if (i >= node.expressions.length) continue;
|
|
1635
|
+
const expressionValue = resolveStaticString(node.expressions[i], bindings);
|
|
1636
|
+
if (expressionValue === null) return null;
|
|
1637
|
+
value += expressionValue;
|
|
1638
|
+
}
|
|
1639
|
+
return value;
|
|
1640
|
+
}
|
|
1641
|
+
if (t5.isIdentifier(node)) {
|
|
1642
|
+
return bindings.get(node.name) ?? null;
|
|
1643
|
+
}
|
|
1644
|
+
if (t5.isTSAsExpression(node) || t5.isTSSatisfiesExpression(node) || t5.isTSNonNullExpression(node)) {
|
|
1645
|
+
return resolveStaticString(node.expression, bindings);
|
|
1646
|
+
}
|
|
1647
|
+
if (t5.isParenthesizedExpression(node)) {
|
|
1648
|
+
return resolveStaticString(node.expression, bindings);
|
|
1649
|
+
}
|
|
1650
|
+
if (t5.isBinaryExpression(node, { operator: "+" })) {
|
|
1651
|
+
const left = resolveStaticString(node.left, bindings);
|
|
1652
|
+
const right = resolveStaticString(node.right, bindings);
|
|
1653
|
+
if (left === null || right === null) return null;
|
|
1654
|
+
return left + right;
|
|
1655
|
+
}
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
function getTopLevelVariableDeclaration(node) {
|
|
1659
|
+
if (t5.isVariableDeclaration(node)) {
|
|
1660
|
+
return node;
|
|
1661
|
+
}
|
|
1662
|
+
if (t5.isExportNamedDeclaration(node) && node.declaration && t5.isVariableDeclaration(node.declaration)) {
|
|
1663
|
+
return node.declaration;
|
|
1664
|
+
}
|
|
1665
|
+
return null;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
// src/plugin/transform-css.ts
|
|
1591
1669
|
function transformCssTs(code, filename, mapping) {
|
|
1592
1670
|
const ast = parse2(code, {
|
|
1593
1671
|
sourceType: "module",
|
|
@@ -1599,28 +1677,29 @@ function transformCssTs(code, filename, mapping) {
|
|
|
1599
1677
|
return `/* [truss] ${filename}: no Css import found */
|
|
1600
1678
|
`;
|
|
1601
1679
|
}
|
|
1602
|
-
const
|
|
1603
|
-
if (!
|
|
1604
|
-
return `/* [truss] ${filename}: expected \`export
|
|
1680
|
+
const cssExport = findNamedCssExportObject(ast);
|
|
1681
|
+
if (!cssExport) {
|
|
1682
|
+
return `/* [truss] ${filename}: expected \`export const css = { ... }\` with an object literal */
|
|
1605
1683
|
`;
|
|
1606
1684
|
}
|
|
1607
1685
|
const rules = [];
|
|
1608
|
-
|
|
1609
|
-
|
|
1686
|
+
const stringBindings = collectStaticStringBindings(ast);
|
|
1687
|
+
for (const prop of cssExport.properties) {
|
|
1688
|
+
if (t6.isSpreadElement(prop)) {
|
|
1610
1689
|
rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);
|
|
1611
1690
|
continue;
|
|
1612
1691
|
}
|
|
1613
|
-
if (!
|
|
1692
|
+
if (!t6.isObjectProperty(prop)) {
|
|
1614
1693
|
rules.push(`/* [truss] unsupported: non-property in css.ts export */`);
|
|
1615
1694
|
continue;
|
|
1616
1695
|
}
|
|
1617
|
-
const selector = objectPropertyStringKey(prop);
|
|
1696
|
+
const selector = objectPropertyStringKey(prop, stringBindings);
|
|
1618
1697
|
if (selector === null) {
|
|
1619
1698
|
rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);
|
|
1620
1699
|
continue;
|
|
1621
1700
|
}
|
|
1622
1701
|
const valueNode = prop.value;
|
|
1623
|
-
if (!
|
|
1702
|
+
if (!t6.isExpression(valueNode)) {
|
|
1624
1703
|
rules.push(`/* [truss] unsupported: "${selector}" value is not an expression */`);
|
|
1625
1704
|
continue;
|
|
1626
1705
|
}
|
|
@@ -1633,23 +1712,32 @@ function transformCssTs(code, filename, mapping) {
|
|
|
1633
1712
|
}
|
|
1634
1713
|
return rules.join("\n\n") + "\n";
|
|
1635
1714
|
}
|
|
1636
|
-
function
|
|
1715
|
+
function findNamedCssExportObject(ast) {
|
|
1637
1716
|
for (const node of ast.program.body) {
|
|
1638
|
-
if (!
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1717
|
+
if (!t6.isExportNamedDeclaration(node) || !node.declaration) continue;
|
|
1718
|
+
if (!t6.isVariableDeclaration(node.declaration)) continue;
|
|
1719
|
+
for (const declarator of node.declaration.declarations) {
|
|
1720
|
+
if (!t6.isIdentifier(declarator.id, { name: "css" })) continue;
|
|
1721
|
+
const value = unwrapObjectExpression(declarator.init);
|
|
1722
|
+
if (value) return value;
|
|
1723
|
+
}
|
|
1643
1724
|
}
|
|
1644
1725
|
return null;
|
|
1645
1726
|
}
|
|
1646
|
-
function
|
|
1647
|
-
if (
|
|
1648
|
-
if (
|
|
1727
|
+
function unwrapObjectExpression(node) {
|
|
1728
|
+
if (!node) return null;
|
|
1729
|
+
if (t6.isObjectExpression(node)) return node;
|
|
1730
|
+
if (t6.isTSAsExpression(node) || t6.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);
|
|
1731
|
+
return null;
|
|
1732
|
+
}
|
|
1733
|
+
function objectPropertyStringKey(prop, stringBindings) {
|
|
1734
|
+
if (t6.isStringLiteral(prop.key)) return prop.key.value;
|
|
1735
|
+
if (t6.isIdentifier(prop.key) && !prop.computed) return prop.key.name;
|
|
1736
|
+
if (prop.computed) return resolveStaticString(prop.key, stringBindings);
|
|
1649
1737
|
return null;
|
|
1650
1738
|
}
|
|
1651
1739
|
function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
1652
|
-
if (!
|
|
1740
|
+
if (!t6.isMemberExpression(node) || node.computed || !t6.isIdentifier(node.property, { name: "$" })) {
|
|
1653
1741
|
return { error: "value must be a Css.*.$ expression" };
|
|
1654
1742
|
}
|
|
1655
1743
|
const chain = extractChain(node.object, cssBindingName);
|
|
@@ -1718,8 +1806,61 @@ ${body}
|
|
|
1718
1806
|
}`;
|
|
1719
1807
|
}
|
|
1720
1808
|
|
|
1809
|
+
// src/plugin/rewrite-css-ts-imports.ts
|
|
1810
|
+
import { parse as parse3 } from "@babel/parser";
|
|
1811
|
+
import _generate2 from "@babel/generator";
|
|
1812
|
+
import * as t7 from "@babel/types";
|
|
1813
|
+
var generate2 = _generate2.default ?? _generate2;
|
|
1814
|
+
function rewriteCssTsImports(code, filename) {
|
|
1815
|
+
if (!code.includes(".css.ts")) {
|
|
1816
|
+
return { code, changed: false };
|
|
1817
|
+
}
|
|
1818
|
+
const ast = parse3(code, {
|
|
1819
|
+
sourceType: "module",
|
|
1820
|
+
plugins: ["typescript", "jsx"],
|
|
1821
|
+
sourceFilename: filename
|
|
1822
|
+
});
|
|
1823
|
+
const existingCssSideEffects = /* @__PURE__ */ new Set();
|
|
1824
|
+
const neededCssSideEffects = /* @__PURE__ */ new Set();
|
|
1825
|
+
let changed = false;
|
|
1826
|
+
for (const node of ast.program.body) {
|
|
1827
|
+
if (!t7.isImportDeclaration(node)) continue;
|
|
1828
|
+
if (typeof node.source.value !== "string") continue;
|
|
1829
|
+
if (!node.source.value.endsWith(".css.ts")) continue;
|
|
1830
|
+
if (node.specifiers.length === 0) {
|
|
1831
|
+
node.source = t7.stringLiteral(toVirtualCssSpecifier(node.source.value));
|
|
1832
|
+
existingCssSideEffects.add(node.source.value);
|
|
1833
|
+
changed = true;
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));
|
|
1837
|
+
}
|
|
1838
|
+
const sideEffectImports = [];
|
|
1839
|
+
for (const source of neededCssSideEffects) {
|
|
1840
|
+
if (existingCssSideEffects.has(source)) continue;
|
|
1841
|
+
sideEffectImports.push(t7.importDeclaration([], t7.stringLiteral(source)));
|
|
1842
|
+
changed = true;
|
|
1843
|
+
}
|
|
1844
|
+
if (!changed) {
|
|
1845
|
+
return { code, changed: false };
|
|
1846
|
+
}
|
|
1847
|
+
if (sideEffectImports.length > 0) {
|
|
1848
|
+
const insertIndex = findLastImportIndex(ast) + 1;
|
|
1849
|
+
ast.program.body.splice(insertIndex, 0, ...sideEffectImports);
|
|
1850
|
+
}
|
|
1851
|
+
const output = generate2(ast, {
|
|
1852
|
+
sourceFileName: filename,
|
|
1853
|
+
retainLines: false
|
|
1854
|
+
});
|
|
1855
|
+
return { code: output.code, changed: true };
|
|
1856
|
+
}
|
|
1857
|
+
function toVirtualCssSpecifier(source) {
|
|
1858
|
+
return `${source}?truss-css`;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1721
1861
|
// src/plugin/index.ts
|
|
1722
1862
|
var VIRTUAL_CSS_PREFIX = "\0truss-css:";
|
|
1863
|
+
var CSS_TS_QUERY = "?truss-css";
|
|
1723
1864
|
function trussPlugin(opts) {
|
|
1724
1865
|
let mapping = null;
|
|
1725
1866
|
let projectRoot;
|
|
@@ -1743,15 +1884,8 @@ function trussPlugin(opts) {
|
|
|
1743
1884
|
ensureMapping();
|
|
1744
1885
|
},
|
|
1745
1886
|
resolveId(source, importer) {
|
|
1746
|
-
if (!source.endsWith(
|
|
1747
|
-
|
|
1748
|
-
if (isAbsolute(source)) {
|
|
1749
|
-
absolutePath = source;
|
|
1750
|
-
} else if (importer) {
|
|
1751
|
-
absolutePath = resolve(dirname(importer), source);
|
|
1752
|
-
} else {
|
|
1753
|
-
absolutePath = resolve(projectRoot || process.cwd(), source);
|
|
1754
|
-
}
|
|
1887
|
+
if (!source.endsWith(CSS_TS_QUERY)) return null;
|
|
1888
|
+
const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);
|
|
1755
1889
|
if (!existsSync(absolutePath)) return null;
|
|
1756
1890
|
return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);
|
|
1757
1891
|
},
|
|
@@ -1763,17 +1897,38 @@ function trussPlugin(opts) {
|
|
|
1763
1897
|
},
|
|
1764
1898
|
transform(code, id) {
|
|
1765
1899
|
if (!/\.[cm]?[jt]sx?(\?|$)/.test(id)) return null;
|
|
1766
|
-
|
|
1900
|
+
const rewrittenImports = rewriteCssTsImports(code, id);
|
|
1901
|
+
const rewrittenCode = rewrittenImports.code;
|
|
1902
|
+
const hasCssDsl = rewrittenCode.includes("Css");
|
|
1903
|
+
if (!hasCssDsl && !rewrittenImports.changed) return null;
|
|
1767
1904
|
const fileId = stripQueryAndHash(id);
|
|
1768
1905
|
if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {
|
|
1769
1906
|
return null;
|
|
1770
1907
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1908
|
+
if (fileId.endsWith(".css.ts")) {
|
|
1909
|
+
return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;
|
|
1910
|
+
}
|
|
1911
|
+
if (!hasCssDsl) {
|
|
1912
|
+
return { code: rewrittenCode, map: null };
|
|
1913
|
+
}
|
|
1914
|
+
const result = transformTruss(rewrittenCode, id, ensureMapping());
|
|
1915
|
+
if (!result) {
|
|
1916
|
+
if (!rewrittenImports.changed) return null;
|
|
1917
|
+
return { code: rewrittenCode, map: null };
|
|
1918
|
+
}
|
|
1773
1919
|
return { code: result.code, map: result.map };
|
|
1774
1920
|
}
|
|
1775
1921
|
};
|
|
1776
1922
|
}
|
|
1923
|
+
function resolveImportPath(source, importer, projectRoot) {
|
|
1924
|
+
if (isAbsolute(source)) {
|
|
1925
|
+
return source;
|
|
1926
|
+
}
|
|
1927
|
+
if (importer) {
|
|
1928
|
+
return resolve(dirname(importer), source);
|
|
1929
|
+
}
|
|
1930
|
+
return resolve(projectRoot || process.cwd(), source);
|
|
1931
|
+
}
|
|
1777
1932
|
function stripQueryAndHash(id) {
|
|
1778
1933
|
const queryIndex = id.indexOf("?");
|
|
1779
1934
|
const hashIndex = id.indexOf("#");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/emit-stylex.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: { root: string }) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into file-local `stylex.create()` + `stylex.props()` calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with `export default { \".selector\": Css.blue.$ }`\n * is transformed into a virtual CSS module. Imports of `.css.ts` files are rewritten\n * to load the generated CSS.\n *\n * Must be placed BEFORE the StyleX unplugin in the plugins array so that\n * StyleX's babel plugin can process the generated `stylex.create()` calls.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n const externalPackages = opts.externalPackages ?? [];\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n return {\n name: \"truss-stylex\",\n enforce: \"pre\",\n\n configResolved(config: { root: string }) {\n projectRoot = config.root;\n },\n\n buildStart() {\n ensureMapping();\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (!source.endsWith(\".css.ts\")) return null;\n\n // Resolve the .css.ts path relative to the importer\n let absolutePath: string;\n if (isAbsolute(source)) {\n absolutePath = source;\n } else if (importer) {\n absolutePath = resolve(dirname(importer), source);\n } else {\n absolutePath = resolve(projectRoot || process.cwd(), source);\n }\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n const result = transformTruss(code, id, ensureMapping());\n if (!result) return null;\n return { code: result.code, map: result.map };\n },\n };\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n findStylexNamespaceImport,\n findLastImportIndex,\n insertStylexNamespaceImport,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectCreateData,\n buildCreateProperties,\n buildMaybeIncDeclaration,\n buildCreateDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-stylex\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into file-local\n * `stylex.create()` + `stylex.props()` calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(code: string, filename: string, mapping: TrussMapping): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n /** Error messages with source location info, to be emitted as console.error calls. */\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolvedChain = resolveFullChain(chain, mapping);\n sites.push({ path, resolvedChain });\n\n // Collect any errors from this chain with source location\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n if (sites.length === 0) return null;\n\n // Step 3: Collect stylex.create entries and helper needs\n const { createEntries, runtimeLookups, needsMaybeInc } = collectCreateData(sites.map((s) => s.resolvedChain));\n\n // Reserve local names we might inject at the top level\n // We do this up front so helper/style variable names are deterministic and\n // cannot collide with user code in the same module.\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const existingStylexNamespace = findStylexNamespaceImport(ast);\n const stylexNamespaceName = existingStylexNamespace ?? reservePreferredName(usedTopLevelNames, \"stylex\");\n const createVarName = reservePreferredName(usedTopLevelNames, \"css\", \"css_\");\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const runtimeLookupNames = new Map<string, string>();\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n const createProperties = buildCreateProperties(createEntries, stylexNamespaceName);\n\n // Step 4: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n createVarName,\n stylexNamespaceName,\n maybeIncHelperName,\n runtimeLookupNames,\n });\n\n // Step 5: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 6: Ensure namespace stylex import exists\n if (!findStylexNamespaceImport(ast)) {\n insertStylexNamespaceImport(ast, stylexNamespaceName);\n }\n\n // Step 7: Hoist marker declarations that are referenced in stylex.create entries.\n // stylex.create uses computed keys like `[stylex.when.ancestor(\":hover\", row)]`\n // which reference marker variables — these must be declared before stylex.create.\n const markerVarNames = collectReferencedMarkerNames(createEntries);\n const hoistedMarkerDecls = hoistMarkerDeclarations(ast, markerVarNames);\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n // Hoisted marker declarations go before stylex.create so they're in scope\n declarationsToInsert.push(...hoistedMarkerDecls);\n if (createProperties.length > 0) {\n declarationsToInsert.push(buildCreateDeclaration(createVarName, stylexNamespaceName, createProperties));\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, createVarName, lookup));\n }\n }\n\n // Step 8: Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n const consoleError = t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n );\n declarationsToInsert.push(consoleError);\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map };\n}\n\n/**\n * Collect the names of marker variables referenced in `whenPseudo.markerNode`\n * across all stylex.create entries. These need to be hoisted above stylex.create.\n */\nfunction collectReferencedMarkerNames(\n createEntries: Map<string, { whenPseudo?: { markerNode?: t.Node } }>,\n): Set<string> {\n const names = new Set<string>();\n for (const [, entry] of createEntries) {\n if (entry.whenPseudo?.markerNode && entry.whenPseudo.markerNode.type === \"Identifier\") {\n names.add(entry.whenPseudo.markerNode.name);\n }\n }\n return names;\n}\n\n/**\n * Find top-level variable declarations for the given names, remove them from\n * their original position in the AST, and return them for reinsertion above\n * the stylex.create call.\n *\n * This handles `const row = stylex.defineMarker()` being declared after code\n * that uses it in a Css.when() chain — the stylex.create computed key\n * `[stylex.when.ancestor(\":hover\", row)]` needs `row` to be in scope.\n */\nfunction hoistMarkerDeclarations(ast: t.File, names: Set<string>): t.Statement[] {\n if (names.size === 0) return [];\n const hoisted: t.Statement[] = [];\n const remaining = new Set(names);\n\n for (let i = ast.program.body.length - 1; i >= 0; i--) {\n if (remaining.size === 0) break;\n const node = ast.program.body[i];\n\n if (!t.isVariableDeclaration(node)) continue;\n\n // Check if any declarator in this statement matches a marker name\n const matchingDeclarators: t.VariableDeclarator[] = [];\n const otherDeclarators: t.VariableDeclarator[] = [];\n for (const decl of node.declarations) {\n if (t.isIdentifier(decl.id) && remaining.has(decl.id.name)) {\n matchingDeclarators.push(decl);\n remaining.delete(decl.id.name);\n } else {\n otherDeclarators.push(decl);\n }\n }\n\n if (matchingDeclarators.length === 0) continue;\n\n if (otherDeclarators.length === 0) {\n // Entire statement is marker declarations — remove it\n ast.program.body.splice(i, 1);\n hoisted.push(node);\n } else {\n // Split: keep non-marker declarators in place, hoist the marker ones\n node.declarations = otherDeclarators;\n hoisted.push(t.variableDeclaration(node.kind, matchingDeclarators));\n }\n }\n\n // Reverse so they appear in original source order\n hoisted.reverse();\n return hoisted;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(chain: ChainNode[], mapping: TrussMapping): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({\n type: \"unconditional\",\n segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: mergeOverlappingConditions(resolveChain(thenNodes, mapping)),\n elseSegments: mergeOverlappingConditions(resolveChain(elseNodes, mapping)),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({ type: \"unconditional\", segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)) });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(node, mapping, currentMediaQuery, currentPseudoClass, currentPseudoElement);\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"dynamic\") {\n const seg = resolveDynamicCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.dynamicProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"dynamic\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a dynamic (parameterized) call like mt(2) or mt(x). */\nfunction resolveDynamicCall(\n abbr: string,\n entry: { kind: \"dynamic\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n dynamicProps: entry.props,\n incremented: entry.incremented,\n dynamicExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"dynamic\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a dynamic entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: targetEntry.props,\n incremented: false,\n dynamicExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(prop, value)` call — arbitrary CSS property with a string literal\n * property name and either a literal or variable value.\n *\n * Only the two-argument `add(\"propName\", value)` overload is supported.\n * The object overload `add({ prop: value })` is not supported.\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `The add({...}) object overload is not supported -- use add(\"propName\", value) instead`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `add_${propName}__${keySuffix}__${suffix}` : `add_${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `add_${propName}__${suffix}` : `add_${propName}`;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no dynamicProps, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.dynamicProps || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment } from \"./types\";\n\nexport interface CreateEntrySpec {\n /**\n * The property name in the generated `stylex.create({...})` object, built from\n * the Truss abbreviation, optionally suffixed with the resolved value and/or pseudo,\n * i.e. `\"df\"`, `\"mt__16px\"`, `\"black__hover\"`. Also used as the dedup key across the file.\n */\n key: string;\n /**\n * Static CSS property-value map for this entry. Usually a single property,\n * i.e. `{ display: \"flex\" }` for `\"df\"`, but shorthand abbreviations expand to multiple,\n * i.e. `{ borderStyle: \"solid\", borderWidth: \"1px\" }` for `\"ba\"`.\n */\n defs?: Record<string, unknown>;\n /**\n * For dynamic entries where the value is a runtime variable (not a literal),\n * i.e. `{ props: [\"marginTop\"], pseudo: null }` for `Css.mt(x).$`,\n * or `{ props: [\"color\"], pseudo: \":hover\" }` for `Css.onHover.color(x).$`.\n *\n * Becomes `stylex.create({ mt: v => ({ marginTop: v }) })`\n */\n dynamic?: {\n props: string[];\n extraDefs?: Record<string, unknown>;\n mediaQuery?: string | null;\n pseudoClass?: string | null;\n pseudoElement?: string | null;\n };\n /** If set, this entry uses stylex.when.<relationship>() as the computed property key */\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string };\n}\n\nexport interface CollectedCreateData {\n createEntries: Map<string, CreateEntrySpec>;\n runtimeLookups: Map<string, RuntimeLookupSpec>;\n needsMaybeInc: boolean;\n}\n\nexport interface RuntimeLookupSpec {\n lookupKey: string;\n refsByName: Record<string, string[]>;\n}\n\n/**\n * Aggregate per-site resolved chains into file-level emission data.\n *\n * Why this exists: we emit one `stylex.create(...)` per source file, so all\n * style segments across all transformed sites must be deduplicated first.\n */\nexport function collectCreateData(chains: ResolvedChain[]): CollectedCreateData {\n const createEntries = new Map<string, CreateEntrySpec>();\n const runtimeLookups = new Map<string, RuntimeLookupSpec>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n\n for (const seg of segs) {\n // Skip error segments — they have no CSS data to emit\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n collectTypographyLookup(createEntries, runtimeLookups, seg);\n continue;\n }\n\n if (seg.dynamicProps) {\n if (!createEntries.has(seg.key)) {\n // Keyed dedupe guarantees a stable single entry for repeated usage.\n createEntries.set(seg.key, {\n key: seg.key,\n dynamic: {\n props: seg.dynamicProps,\n extraDefs: seg.dynamicExtraDefs,\n mediaQuery: seg.mediaQuery,\n pseudoClass: seg.pseudoClass,\n pseudoElement: seg.pseudoElement,\n },\n });\n }\n } else {\n if (!createEntries.has(seg.key)) {\n createEntries.set(seg.key, {\n key: seg.key,\n defs: seg.defs,\n whenPseudo: seg.whenPseudo,\n });\n }\n }\n\n if (seg.incremented && seg.dynamicProps) {\n needsMaybeInc = true;\n }\n }\n }\n }\n\n return { createEntries, runtimeLookups, needsMaybeInc };\n}\n\nfunction collectTypographyLookup(\n createEntries: Map<string, CreateEntrySpec>,\n runtimeLookups: Map<string, RuntimeLookupSpec>,\n seg: ResolvedSegment,\n): void {\n const lookup = seg.typographyLookup;\n if (!lookup) return;\n\n if (!runtimeLookups.has(lookup.lookupKey)) {\n runtimeLookups.set(lookup.lookupKey, {\n lookupKey: lookup.lookupKey,\n refsByName: Object.fromEntries(\n Object.entries(lookup.segmentsByName).map(function ([name, segments]) {\n return [\n name,\n segments.map(function (segment) {\n return segment.key;\n }),\n ];\n }),\n ),\n });\n }\n\n for (const segments of Object.values(lookup.segmentsByName)) {\n for (const segment of segments) {\n if (createEntries.has(segment.key)) continue;\n createEntries.set(segment.key, {\n key: segment.key,\n defs: segment.defs,\n whenPseudo: segment.whenPseudo,\n });\n }\n }\n}\n\n/**\n * Build the object literal properties passed to `stylex.create`.\n *\n * Handles static entries, dynamic entries (`v => ({ ... })`), and\n * ancestor-pseudo entries that use `stylex.when.ancestor(...)` keys.\n */\nexport function buildCreateProperties(\n createEntries: Map<string, CreateEntrySpec>,\n stylexNamespaceName: string,\n): t.ObjectProperty[] {\n const createProperties: t.ObjectProperty[] = [];\n\n for (const [, entry] of createEntries) {\n if (entry.dynamic) {\n const paramId = t.identifier(\"v\");\n const bodyProps: t.ObjectProperty[] = [];\n const { mediaQuery, pseudoClass } = entry.dynamic;\n\n for (const prop of entry.dynamic.props) {\n if (pseudoClass && mediaQuery) {\n // Stacked: { default: null, \":hover\": { default: null, \"@media...\": v } }\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), paramId),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), paramId),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), paramId));\n }\n }\n\n if (entry.dynamic.extraDefs) {\n for (const [prop, value] of Object.entries(entry.dynamic.extraDefs)) {\n if (pseudoClass && mediaQuery) {\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), valueToAst(value)),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), valueToAst(value)),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), valueToAst(value)));\n }\n }\n }\n\n let bodyExpr: t.Expression = t.objectExpression(bodyProps);\n if (entry.dynamic.pseudoElement) {\n // Wrap: { '::placeholder': { ...bodyProps } }\n bodyExpr = t.objectExpression([t.objectProperty(t.stringLiteral(entry.dynamic.pseudoElement), bodyExpr)]);\n }\n const arrowFn = t.arrowFunctionExpression([paramId], bodyExpr);\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), arrowFn));\n continue;\n }\n\n if (entry.whenPseudo && entry.defs) {\n const ap = entry.whenPseudo;\n const props: t.ObjectProperty[] = [];\n\n for (const [prop, value] of Object.entries(entry.defs)) {\n // `when.ancestor(...)` must remain a computed key expression so StyleX\n // can generate marker-aware selectors.\n const whenCallArgs: t.Expression[] = [t.stringLiteral(ap.pseudo)];\n if (ap.markerNode) {\n whenCallArgs.push(ap.markerNode);\n }\n\n const relationship = ap.relationship ?? \"ancestor\";\n const whenCall = t.callExpression(\n t.memberExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"when\")),\n t.identifier(relationship),\n ),\n whenCallArgs,\n );\n\n props.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(whenCall, valueToAst(value), true),\n ]),\n ),\n );\n }\n\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), t.objectExpression(props)));\n continue;\n }\n\n if (entry.defs) {\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), defsToAst(entry.defs)));\n }\n }\n\n return createProperties;\n}\n\n/**\n * Build the per-file increment helper used by dynamic incremented calls.\n *\n * The helper is only emitted when needed to keep transformed files minimal.\n */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Build `const <createVarName> = <stylexNs>.create({...})`. */\nexport function buildCreateDeclaration(\n createVarName: string,\n stylexNamespaceName: string,\n createProperties: t.ObjectProperty[],\n): t.VariableDeclaration {\n const createCall = t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"create\")), [\n t.objectExpression(createProperties),\n ]);\n return t.variableDeclaration(\"const\", [t.variableDeclarator(t.identifier(createVarName), createCall)]);\n}\n\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n createVarName: string,\n lookup: RuntimeLookupSpec,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n\n for (const [name, refs] of Object.entries(lookup.refsByName)) {\n const values = refs.map(function (refKey) {\n return t.memberExpression(t.identifier(createVarName), t.identifier(refKey));\n });\n properties.push(t.objectProperty(toPropertyKey(name), t.arrayExpression(values)));\n }\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n\n/** Convert style definitions to an AST object, recursively. */\nfunction defsToAst(defs: Record<string, unknown>): t.ObjectExpression {\n const properties: t.ObjectProperty[] = [];\n\n for (const [key, value] of Object.entries(defs)) {\n const keyNode = toPropertyKey(key);\n\n if (value === null) {\n properties.push(t.objectProperty(keyNode, t.nullLiteral()));\n } else if (typeof value === \"string\") {\n properties.push(t.objectProperty(keyNode, t.stringLiteral(value)));\n } else if (typeof value === \"number\") {\n properties.push(t.objectProperty(keyNode, t.numericLiteral(value)));\n } else if (typeof value === \"object\") {\n properties.push(t.objectProperty(keyNode, defsToAst(value as Record<string, unknown>)));\n }\n }\n\n return t.objectExpression(properties);\n}\n\n/** Convert a primitive/object style value into an AST expression node. */\nfunction valueToAst(value: unknown): t.Expression {\n if (value === null) return t.nullLiteral();\n if (typeof value === \"string\") return t.stringLiteral(value);\n if (typeof value === \"number\") return t.numericLiteral(value);\n if (typeof value === \"object\") return defsToAst(value as Record<string, unknown>);\n return t.stringLiteral(String(value));\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { ResolvedSegment } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n createVarName: string;\n stylexNamespaceName: string;\n maybeIncHelperName: string | null;\n runtimeLookupNames: Map<string, string>;\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into StyleX runtime calls.\n *\n * Why this is split out: the transform has two distinct concerns—\"what to\n * emit\" (`stylex.create`) and \"where to rewrite usage sites\" (`stylex.props`).\n * Keeping site rewrites isolated makes behavior easier to reason about.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const propsArgs = buildPropsArgsFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n\n if (cssAttrPath) {\n const propsCall = t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n\n const openingElement = cssAttrPath.parentPath;\n let existingClassNameExpr: t.Expression | null = null;\n\n if (openingElement && openingElement.isJSXOpeningElement()) {\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: \"className\" })) {\n if (t.isStringLiteral(attr.value)) {\n existingClassNameExpr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n existingClassNameExpr = attr.value.expression;\n }\n attrs.splice(i, 1);\n break;\n }\n }\n }\n\n let spreadExpr: t.Expression;\n if (existingClassNameExpr) {\n const rId = t.identifier(\"__r\");\n // Keep existing className values while appending StyleX-generated className.\n // We do this in a tiny IIFE so the generated expression remains a single\n // JSX spread without introducing extra statements.\n const mergedClassName = t.callExpression(\n t.memberExpression(\n t.binaryExpression(\n \"+\",\n t.binaryExpression(\"+\", existingClassNameExpr, t.stringLiteral(\" \")),\n t.logicalExpression(\"||\", t.memberExpression(rId, t.identifier(\"className\")), t.stringLiteral(\"\")),\n ),\n t.identifier(\"trim\"),\n ),\n [],\n );\n spreadExpr = t.callExpression(\n t.arrowFunctionExpression(\n [rId],\n t.objectExpression([t.spreadElement(rId), t.objectProperty(t.identifier(\"className\"), mergedClassName)]),\n ),\n [propsCall],\n );\n } else {\n spreadExpr = propsCall;\n }\n\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(spreadExpr));\n continue;\n }\n\n site.path.replaceWith(t.arrayExpression(propsArgs));\n }\n\n rewriteStyleObjectExpressions(options.ast);\n\n // Second pass: flatten `css={[...Css.x.$, ...xss]}`-style arrays after site rewrites.\n rewriteCssArrayExpressions(options.ast, options.stylexNamespaceName);\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n/**\n * Build arguments for `stylex.props(...)` from a resolved chain.\n *\n * Conditional segments are converted to ternaries (or spread ternaries when a\n * branch has multiple refs) so branch structure is preserved in emitted code.\n */\nfunction buildPropsArgsFromChain(\n chain: ResolvedChain,\n options: RewriteSitesOptions,\n): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const marker of chain.markers) {\n if (marker.markerNode) {\n args.push(marker.markerNode);\n } else {\n args.push(\n t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"defaultMarker\")),\n [],\n ),\n );\n }\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n args.push(...buildPropsArgs(part.segments, options));\n continue;\n }\n\n const thenArgs = buildPropsArgs(part.thenSegments, options);\n const elseArgs = buildPropsArgs(part.elseSegments, options);\n\n if (\n thenArgs.length === 1 &&\n elseArgs.length === 1 &&\n !t.isSpreadElement(thenArgs[0]) &&\n !t.isSpreadElement(elseArgs[0])\n ) {\n args.push(t.conditionalExpression(part.conditionNode, thenArgs[0], elseArgs[0]));\n } else if (thenArgs.length > 0 || elseArgs.length > 0) {\n args.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.arrayExpression(thenArgs), t.arrayExpression(elseArgs)),\n ),\n );\n }\n }\n\n return args;\n}\n\n/**\n * Convert resolved segments to style refs and dynamic invocations.\n */\nfunction buildPropsArgs(segments: ResolvedSegment[], options: RewriteSitesOptions): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const seg of segments) {\n // Skip error segments — they are logged via console.error at the top of the file\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (!lookupName) {\n continue;\n }\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n args.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.arrayExpression([]))));\n continue;\n }\n\n const ref = t.memberExpression(t.identifier(options.createVarName), t.identifier(seg.key));\n\n if (seg.dynamicProps && seg.argNode) {\n let argExpr: t.Expression;\n if (seg.incremented && options.maybeIncHelperName) {\n argExpr = t.callExpression(t.identifier(options.maybeIncHelperName), [seg.argNode]);\n } else if (seg.incremented) {\n argExpr = seg.argNode as t.Expression;\n } else {\n argExpr = t.callExpression(t.identifier(\"String\"), [seg.argNode]);\n }\n args.push(t.callExpression(ref, [argExpr]));\n } else {\n args.push(ref);\n }\n }\n\n return args;\n}\n\n/**\n * Rewrite `css={[...a, ...b]}` to `...stylex.props(...)` by flattening nested\n * arrays produced by the first rewrite pass.\n */\nfunction rewriteCssArrayExpressions(ast: t.File, stylexNamespaceName: string): void {\n traverse(ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n const expr = value.expression;\n if (!t.isArrayExpression(expr)) return;\n\n const propsArgs: (t.Expression | t.SpreadElement)[] = [];\n\n for (const el of expr.elements) {\n if (t.isSpreadElement(el)) {\n const arg = el.argument;\n if (t.isArrayExpression(arg)) {\n for (const inner of arg.elements) {\n if (!inner) continue;\n if (t.isSpreadElement(inner)) {\n propsArgs.push(t.spreadElement(inner.argument));\n } else {\n propsArgs.push(inner);\n }\n }\n } else {\n propsArgs.push(t.spreadElement(arg));\n }\n } else if (el) {\n propsArgs.push(el);\n }\n }\n\n const propsCall = t.callExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n path.replaceWith(t.jsxSpreadAttribute(propsCall));\n },\n });\n}\n\n/**\n * Rewrite object spread composition like `{ ...[css.df], ...(cond ? [css.a] : {}) }`\n * into style ref arrays so later JSX css rewrites can flatten them safely.\n */\nfunction rewriteStyleObjectExpressions(ast: t.File): void {\n traverse(ast, {\n ObjectExpression(path: NodePath<t.ObjectExpression>) {\n const rewritten = tryBuildStyleArrayFromObject(path);\n if (!rewritten) return;\n path.replaceWith(rewritten);\n },\n });\n}\n\n/** One-line detection for object spread groups that really represent style arrays. */\nfunction tryBuildStyleArrayFromObject(path: NodePath<t.ObjectExpression>): t.ArrayExpression | null {\n if (path.node.properties.length === 0) return null;\n\n let sawStyleArray = false;\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n\n for (const prop of path.node.properties) {\n if (!t.isSpreadElement(prop)) {\n return null;\n }\n\n const normalizedArg = normalizeStyleArrayExpression(\n prop.argument,\n path,\n new Set<t.Node>(), // I.e. `...Css.df.$`, `...(cond ? Css.df.$ : {})`, or `...styles.wrapper`\n );\n if (!normalizedArg) {\n return null;\n }\n\n if (isStyleArrayLikeExpression(normalizedArg, path, new Set<t.Node>())) {\n sawStyleArray = true;\n }\n\n if (t.isArrayExpression(normalizedArg)) {\n elements.push(...normalizedArg.elements);\n continue;\n }\n\n elements.push(t.spreadElement(normalizedArg));\n }\n\n if (!sawStyleArray) return null;\n return t.arrayExpression(elements);\n}\n\n/**\n * Normalize style-array conditionals so object fallback branches become arrays.\n */\nfunction normalizeStyleArrayExpression(expr: t.Expression, path: NodePath, seen: Set<t.Node>): t.Expression | null {\n if (seen.has(expr)) return null;\n seen.add(expr);\n\n if (t.isArrayExpression(expr)) return expr; // I.e. `[css.df]` or `[css.df, ...xss]`\n\n if (t.isConditionalExpression(expr)) {\n const consequent = normalizeConditionalBranch(expr.consequent, path, seen);\n const alternate = normalizeConditionalBranch(expr.alternate, path, seen);\n if (!consequent || !alternate) return null;\n return t.conditionalExpression(expr.test, consequent, alternate); // I.e. `cond ? Css.df.$ : {}`\n }\n\n if (t.isIdentifier(expr) || t.isMemberExpression(expr)) {\n const nestedSeen = new Set(seen);\n nestedSeen.delete(expr);\n if (isStyleArrayLikeExpression(expr, path, nestedSeen)) return expr; // I.e. `base` or `styles.wrapper`\n }\n\n return null;\n}\n\n/** Normalize a conditional branch inside a style-array expression. */\nfunction normalizeConditionalBranch(expr: t.Expression, path: NodePath, seen: Set<t.Node>): t.Expression | null {\n if (isEmptyObjectExpression(expr)) {\n return t.arrayExpression([]); // I.e. `cond ? Css.df.$ : {}` becomes `cond ? [css.df] : []`\n }\n\n return normalizeStyleArrayExpression(expr, path, seen);\n}\n\n/** Check whether an expression is known to evaluate to a style ref array. */\nfunction isStyleArrayLikeExpression(expr: t.Expression, path: NodePath, seen: Set<t.Node>): boolean {\n if (seen.has(expr)) return false;\n seen.add(expr);\n\n if (t.isArrayExpression(expr)) return true; // I.e. `[css.df]`\n\n if (t.isConditionalExpression(expr)) {\n return isStyleArrayLikeBranch(expr.consequent, path, seen) && isStyleArrayLikeBranch(expr.alternate, path, seen); // I.e. `cond ? [css.df] : []`\n }\n\n if (t.isIdentifier(expr)) {\n const binding = path.scope.getBinding(expr.name);\n const bindingPath = binding?.path;\n if (!bindingPath || !bindingPath.isVariableDeclarator()) return false;\n const init = bindingPath.node.init;\n return !!(init && isStyleArrayLikeExpression(init, bindingPath, seen)); // I.e. `base` where `const base = [css.df]`\n }\n\n if (t.isMemberExpression(expr) && !expr.computed && t.isIdentifier(expr.property)) {\n const object = expr.object;\n if (!t.isIdentifier(object)) return false;\n\n const binding = path.scope.getBinding(object.name);\n const bindingPath = binding?.path;\n if (!bindingPath || !bindingPath.isVariableDeclarator()) return false;\n const init = bindingPath.node.init;\n if (!init || !t.isObjectExpression(init)) return false;\n\n const propertyName = expr.property.name;\n for (const prop of init.properties) {\n if (!t.isObjectProperty(prop) || prop.computed) continue;\n if (!isMatchingPropertyName(prop.key, propertyName)) continue;\n const value = prop.value;\n return t.isExpression(value) && isStyleArrayLikeExpression(value, bindingPath, seen); // I.e. `styles.wrapper`\n }\n }\n\n return false;\n}\n\n/** Check a branch used inside a conditional style-array expression. */\nfunction isStyleArrayLikeBranch(expr: t.Expression, path: NodePath, seen: Set<t.Node>): boolean {\n return isEmptyObjectExpression(expr) || isStyleArrayLikeExpression(expr, path, seen); // I.e. `{}` or `[css.df]`\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Check for `{}` fallback branches that should become `[]`. */\nfunction isEmptyObjectExpression(expr: t.Expression): boolean {\n return t.isObjectExpression(expr) && expr.properties.length === 0;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export default {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export default { ... }` expression\n const defaultExport = findDefaultExportObject(ast);\n if (!defaultExport) {\n return `/* [truss] ${filename}: expected \\`export default { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n\n for (const prop of defaultExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export default { ... }`. */\nfunction findDefaultExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportDefaultDeclaration(node)) continue;\n const decl = node.declaration;\n // `export default { ... }`\n if (t.isObjectExpression(decl)) return decl;\n // `export default { ... } as const` or similar TSAsExpression wrapping\n if (t.isTSAsExpression(decl) && t.isObjectExpression(decl.expression)) return decl.expression;\n // `export default { ... } satisfies ...`\n if (t.isTSSatisfiesExpression(decl) && t.isObjectExpression(decl.expression)) return decl.expression;\n }\n return null;\n}\n\n/** Extract a string key from an ObjectProperty (string literal or identifier). */\nfunction objectPropertyStringKey(prop: t.ObjectProperty): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (dynamic with variable args)\n if (seg.dynamicProps && !seg.argResolved) {\n return { error: `dynamic value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,SAAS,kBAAkB;;;ACD7C,SAAS,aAAa;AACtB,OAAOA,gBAAe;AAEtB,OAAO,eAAe;AACtB,YAAYC,QAAO;;;AC6DZ,SAAS,iBAAiB,OAAoB,SAAsC;AACzF,QAAM,QAA6B,CAAC;AACpC,QAAM,UAA2B,CAAC;AAGlC,QAAM,gBAA6B,CAAC;AAEpC,QAAM,aAAuB,CAAC;AAC9B,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,KAAK,SAAS,YAAY,KAAK,SAAS,U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AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,UAA2B;AACpD,SAAO,cAAc,QAAQ,EAAE,SAAS,gBAAgB;AAC1D;AAEA,SAAS,iCAAiC,UAAkB,kBAAqC;AAC/F,QAAM,iBAAiB,cAAc,QAAQ;AAC7C,SAAO,iBAAiB,KAAK,SAAU,KAAK;AAC1C,WAAO,eAAe,SAAS,iBAAiB,GAAG,GAAG;AAAA,EACxD,CAAC;AACH;AAEA,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,GAAG;AAChC;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAM,aAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["_traverse","t","suffix","key","t","t","traverse","_traverse","parse","t","parse"]}
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/emit-stylex.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\nimport { rewriteCssTsImports } from \"./rewrite-css-ts-imports\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: { root: string }) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\nconst CSS_TS_QUERY = \"?truss-css\";\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into file-local `stylex.create()` + `stylex.props()` calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with\n * `export const css = { \".selector\": Css.blue.$ }` can keep other runtime exports,\n * while imports are supplemented with a virtual CSS side-effect module.\n *\n * Must be placed BEFORE the StyleX unplugin in the plugins array so that\n * StyleX's babel plugin can process the generated `stylex.create()` calls.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n const externalPackages = opts.externalPackages ?? [];\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n return {\n name: \"truss-stylex\",\n enforce: \"pre\",\n\n configResolved(config: { root: string }) {\n projectRoot = config.root;\n },\n\n buildStart() {\n ensureMapping();\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (!source.endsWith(CSS_TS_QUERY)) return null;\n\n const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n\n const rewrittenImports = rewriteCssTsImports(code, id);\n const rewrittenCode = rewrittenImports.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\");\n if (!hasCssDsl && !rewrittenImports.changed) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n if (fileId.endsWith(\".css.ts\")) {\n // Keep `.css.ts` modules as normal TS so named exports like class-name\n // constants still work at runtime; only return code when we injected the\n // companion `?truss-css` side-effect import.\n return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;\n }\n\n if (!hasCssDsl) {\n // Some non-`.css.ts` modules only need the import rewrite and do not have\n // any `Css.*.$` expressions for the main Truss transform to process.\n return { code: rewrittenCode, map: null };\n }\n\n // For regular JS/TS modules that still use the DSL, run the full Truss\n // transform after the import rewrite so both behaviors compose.\n const result = transformTruss(rewrittenCode, id, ensureMapping());\n if (!result) {\n if (!rewrittenImports.changed) return null;\n return { code: rewrittenCode, map: null };\n }\n return { code: result.code, map: result.map };\n },\n };\n}\n\nfunction resolveImportPath(source: string, importer: string | undefined, projectRoot: string | undefined): string {\n if (isAbsolute(source)) {\n return source;\n }\n\n if (importer) {\n return resolve(dirname(importer), source);\n }\n\n return resolve(projectRoot || process.cwd(), source);\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n findStylexNamespaceImport,\n findLastImportIndex,\n insertStylexNamespaceImport,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectCreateData,\n buildCreateProperties,\n buildMaybeIncDeclaration,\n buildCreateDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-stylex\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into file-local\n * `stylex.create()` + `stylex.props()` calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(code: string, filename: string, mapping: TrussMapping): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n /** Error messages with source location info, to be emitted as console.error calls. */\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolvedChain = resolveFullChain(chain, mapping);\n sites.push({ path, resolvedChain });\n\n // Collect any errors from this chain with source location\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n if (sites.length === 0) return null;\n\n // Step 3: Collect stylex.create entries and helper needs\n const { createEntries, runtimeLookups, needsMaybeInc } = collectCreateData(sites.map((s) => s.resolvedChain));\n\n // Reserve local names we might inject at the top level\n // We do this up front so helper/style variable names are deterministic and\n // cannot collide with user code in the same module.\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const existingStylexNamespace = findStylexNamespaceImport(ast);\n const stylexNamespaceName = existingStylexNamespace ?? reservePreferredName(usedTopLevelNames, \"stylex\");\n const createVarName = reservePreferredName(usedTopLevelNames, \"css\", \"css_\");\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const runtimeLookupNames = new Map<string, string>();\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n const createProperties = buildCreateProperties(createEntries, stylexNamespaceName);\n\n // Step 4: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n createVarName,\n stylexNamespaceName,\n maybeIncHelperName,\n runtimeLookupNames,\n });\n\n // Step 5: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 6: Ensure namespace stylex import exists\n if (!findStylexNamespaceImport(ast)) {\n insertStylexNamespaceImport(ast, stylexNamespaceName);\n }\n\n // Step 7: Hoist marker declarations that are referenced in stylex.create entries.\n // stylex.create uses computed keys like `[stylex.when.ancestor(\":hover\", row)]`\n // which reference marker variables — these must be declared before stylex.create.\n const markerVarNames = collectReferencedMarkerNames(createEntries);\n const hoistedMarkerDecls = hoistMarkerDeclarations(ast, markerVarNames);\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n // Hoisted marker declarations go before stylex.create so they're in scope\n declarationsToInsert.push(...hoistedMarkerDecls);\n if (createProperties.length > 0) {\n declarationsToInsert.push(buildCreateDeclaration(createVarName, stylexNamespaceName, createProperties));\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, createVarName, lookup));\n }\n }\n\n // Step 8: Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n const consoleError = t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n );\n declarationsToInsert.push(consoleError);\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map };\n}\n\n/**\n * Collect the names of marker variables referenced in `whenPseudo.markerNode`\n * across all stylex.create entries. These need to be hoisted above stylex.create.\n */\nfunction collectReferencedMarkerNames(\n createEntries: Map<string, { whenPseudo?: { markerNode?: t.Node } }>,\n): Set<string> {\n const names = new Set<string>();\n for (const [, entry] of createEntries) {\n if (entry.whenPseudo?.markerNode && entry.whenPseudo.markerNode.type === \"Identifier\") {\n names.add(entry.whenPseudo.markerNode.name);\n }\n }\n return names;\n}\n\n/**\n * Find top-level variable declarations for the given names, remove them from\n * their original position in the AST, and return them for reinsertion above\n * the stylex.create call.\n *\n * This handles `const row = stylex.defineMarker()` being declared after code\n * that uses it in a Css.when() chain — the stylex.create computed key\n * `[stylex.when.ancestor(\":hover\", row)]` needs `row` to be in scope.\n */\nfunction hoistMarkerDeclarations(ast: t.File, names: Set<string>): t.Statement[] {\n if (names.size === 0) return [];\n const hoisted: t.Statement[] = [];\n const remaining = new Set(names);\n\n for (let i = ast.program.body.length - 1; i >= 0; i--) {\n if (remaining.size === 0) break;\n const node = ast.program.body[i];\n\n if (!t.isVariableDeclaration(node)) continue;\n\n // Check if any declarator in this statement matches a marker name\n const matchingDeclarators: t.VariableDeclarator[] = [];\n const otherDeclarators: t.VariableDeclarator[] = [];\n for (const decl of node.declarations) {\n if (t.isIdentifier(decl.id) && remaining.has(decl.id.name)) {\n matchingDeclarators.push(decl);\n remaining.delete(decl.id.name);\n } else {\n otherDeclarators.push(decl);\n }\n }\n\n if (matchingDeclarators.length === 0) continue;\n\n if (otherDeclarators.length === 0) {\n // Entire statement is marker declarations — remove it\n ast.program.body.splice(i, 1);\n hoisted.push(node);\n } else {\n // Split: keep non-marker declarators in place, hoist the marker ones\n node.declarations = otherDeclarators;\n hoisted.push(t.variableDeclaration(node.kind, matchingDeclarators));\n }\n }\n\n // Reverse so they appear in original source order\n hoisted.reverse();\n return hoisted;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(chain: ChainNode[], mapping: TrussMapping): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({\n type: \"unconditional\",\n segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: mergeOverlappingConditions(resolveChain(thenNodes, mapping)),\n elseSegments: mergeOverlappingConditions(resolveChain(elseNodes, mapping)),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({ type: \"unconditional\", segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)) });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(node, mapping, currentMediaQuery, currentPseudoClass, currentPseudoElement);\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"dynamic\") {\n const seg = resolveDynamicCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.dynamicProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"dynamic\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a dynamic (parameterized) call like mt(2) or mt(x). */\nfunction resolveDynamicCall(\n abbr: string,\n entry: { kind: \"dynamic\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n dynamicProps: entry.props,\n incremented: entry.incremented,\n dynamicExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"dynamic\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a dynamic entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: targetEntry.props,\n incremented: false,\n dynamicExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(prop, value)` call — arbitrary CSS property with a string literal\n * property name and either a literal or variable value.\n *\n * Only the two-argument `add(\"propName\", value)` overload is supported.\n * The object overload `add({ prop: value })` is not supported.\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `The add({...}) object overload is not supported -- use add(\"propName\", value) instead`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `add_${propName}__${keySuffix}__${suffix}` : `add_${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `add_${propName}__${suffix}` : `add_${propName}`;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no dynamicProps, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.dynamicProps || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment } from \"./types\";\n\nexport interface CreateEntrySpec {\n /**\n * The property name in the generated `stylex.create({...})` object, built from\n * the Truss abbreviation, optionally suffixed with the resolved value and/or pseudo,\n * i.e. `\"df\"`, `\"mt__16px\"`, `\"black__hover\"`. Also used as the dedup key across the file.\n */\n key: string;\n /**\n * Static CSS property-value map for this entry. Usually a single property,\n * i.e. `{ display: \"flex\" }` for `\"df\"`, but shorthand abbreviations expand to multiple,\n * i.e. `{ borderStyle: \"solid\", borderWidth: \"1px\" }` for `\"ba\"`.\n */\n defs?: Record<string, unknown>;\n /**\n * For dynamic entries where the value is a runtime variable (not a literal),\n * i.e. `{ props: [\"marginTop\"], pseudo: null }` for `Css.mt(x).$`,\n * or `{ props: [\"color\"], pseudo: \":hover\" }` for `Css.onHover.color(x).$`.\n *\n * Becomes `stylex.create({ mt: v => ({ marginTop: v }) })`\n */\n dynamic?: {\n props: string[];\n extraDefs?: Record<string, unknown>;\n mediaQuery?: string | null;\n pseudoClass?: string | null;\n pseudoElement?: string | null;\n };\n /** If set, this entry uses stylex.when.<relationship>() as the computed property key */\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string };\n}\n\nexport interface CollectedCreateData {\n createEntries: Map<string, CreateEntrySpec>;\n runtimeLookups: Map<string, RuntimeLookupSpec>;\n needsMaybeInc: boolean;\n}\n\nexport interface RuntimeLookupSpec {\n lookupKey: string;\n refsByName: Record<string, string[]>;\n}\n\n/**\n * Aggregate per-site resolved chains into file-level emission data.\n *\n * Why this exists: we emit one `stylex.create(...)` per source file, so all\n * style segments across all transformed sites must be deduplicated first.\n */\nexport function collectCreateData(chains: ResolvedChain[]): CollectedCreateData {\n const createEntries = new Map<string, CreateEntrySpec>();\n const runtimeLookups = new Map<string, RuntimeLookupSpec>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n\n for (const seg of segs) {\n // Skip error segments — they have no CSS data to emit\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n collectTypographyLookup(createEntries, runtimeLookups, seg);\n continue;\n }\n\n if (seg.dynamicProps) {\n if (!createEntries.has(seg.key)) {\n // Keyed dedupe guarantees a stable single entry for repeated usage.\n createEntries.set(seg.key, {\n key: seg.key,\n dynamic: {\n props: seg.dynamicProps,\n extraDefs: seg.dynamicExtraDefs,\n mediaQuery: seg.mediaQuery,\n pseudoClass: seg.pseudoClass,\n pseudoElement: seg.pseudoElement,\n },\n });\n }\n } else {\n if (!createEntries.has(seg.key)) {\n createEntries.set(seg.key, {\n key: seg.key,\n defs: seg.defs,\n whenPseudo: seg.whenPseudo,\n });\n }\n }\n\n if (seg.incremented && seg.dynamicProps) {\n needsMaybeInc = true;\n }\n }\n }\n }\n\n return { createEntries, runtimeLookups, needsMaybeInc };\n}\n\nfunction collectTypographyLookup(\n createEntries: Map<string, CreateEntrySpec>,\n runtimeLookups: Map<string, RuntimeLookupSpec>,\n seg: ResolvedSegment,\n): void {\n const lookup = seg.typographyLookup;\n if (!lookup) return;\n\n if (!runtimeLookups.has(lookup.lookupKey)) {\n runtimeLookups.set(lookup.lookupKey, {\n lookupKey: lookup.lookupKey,\n refsByName: Object.fromEntries(\n Object.entries(lookup.segmentsByName).map(function ([name, segments]) {\n return [\n name,\n segments.map(function (segment) {\n return segment.key;\n }),\n ];\n }),\n ),\n });\n }\n\n for (const segments of Object.values(lookup.segmentsByName)) {\n for (const segment of segments) {\n if (createEntries.has(segment.key)) continue;\n createEntries.set(segment.key, {\n key: segment.key,\n defs: segment.defs,\n whenPseudo: segment.whenPseudo,\n });\n }\n }\n}\n\n/**\n * Build the object literal properties passed to `stylex.create`.\n *\n * Handles static entries, dynamic entries (`v => ({ ... })`), and\n * ancestor-pseudo entries that use `stylex.when.ancestor(...)` keys.\n */\nexport function buildCreateProperties(\n createEntries: Map<string, CreateEntrySpec>,\n stylexNamespaceName: string,\n): t.ObjectProperty[] {\n const createProperties: t.ObjectProperty[] = [];\n\n for (const [, entry] of createEntries) {\n if (entry.dynamic) {\n const paramId = t.identifier(\"v\");\n const bodyProps: t.ObjectProperty[] = [];\n const { mediaQuery, pseudoClass } = entry.dynamic;\n\n for (const prop of entry.dynamic.props) {\n if (pseudoClass && mediaQuery) {\n // Stacked: { default: null, \":hover\": { default: null, \"@media...\": v } }\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), paramId),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), paramId),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), paramId));\n }\n }\n\n if (entry.dynamic.extraDefs) {\n for (const [prop, value] of Object.entries(entry.dynamic.extraDefs)) {\n if (pseudoClass && mediaQuery) {\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), valueToAst(value)),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), valueToAst(value)),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), valueToAst(value)));\n }\n }\n }\n\n let bodyExpr: t.Expression = t.objectExpression(bodyProps);\n if (entry.dynamic.pseudoElement) {\n // Wrap: { '::placeholder': { ...bodyProps } }\n bodyExpr = t.objectExpression([t.objectProperty(t.stringLiteral(entry.dynamic.pseudoElement), bodyExpr)]);\n }\n const arrowFn = t.arrowFunctionExpression([paramId], bodyExpr);\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), arrowFn));\n continue;\n }\n\n if (entry.whenPseudo && entry.defs) {\n const ap = entry.whenPseudo;\n const props: t.ObjectProperty[] = [];\n\n for (const [prop, value] of Object.entries(entry.defs)) {\n // `when.ancestor(...)` must remain a computed key expression so StyleX\n // can generate marker-aware selectors.\n const whenCallArgs: t.Expression[] = [t.stringLiteral(ap.pseudo)];\n if (ap.markerNode) {\n whenCallArgs.push(ap.markerNode);\n }\n\n const relationship = ap.relationship ?? \"ancestor\";\n const whenCall = t.callExpression(\n t.memberExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"when\")),\n t.identifier(relationship),\n ),\n whenCallArgs,\n );\n\n props.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(whenCall, valueToAst(value), true),\n ]),\n ),\n );\n }\n\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), t.objectExpression(props)));\n continue;\n }\n\n if (entry.defs) {\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), defsToAst(entry.defs)));\n }\n }\n\n return createProperties;\n}\n\n/**\n * Build the per-file increment helper used by dynamic incremented calls.\n *\n * The helper is only emitted when needed to keep transformed files minimal.\n */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Build `const <createVarName> = <stylexNs>.create({...})`. */\nexport function buildCreateDeclaration(\n createVarName: string,\n stylexNamespaceName: string,\n createProperties: t.ObjectProperty[],\n): t.VariableDeclaration {\n const createCall = t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"create\")), [\n t.objectExpression(createProperties),\n ]);\n return t.variableDeclaration(\"const\", [t.variableDeclarator(t.identifier(createVarName), createCall)]);\n}\n\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n createVarName: string,\n lookup: RuntimeLookupSpec,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n\n for (const [name, refs] of Object.entries(lookup.refsByName)) {\n const values = refs.map(function (refKey) {\n return t.memberExpression(t.identifier(createVarName), t.identifier(refKey));\n });\n properties.push(t.objectProperty(toPropertyKey(name), t.arrayExpression(values)));\n }\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n\n/** Convert style definitions to an AST object, recursively. */\nfunction defsToAst(defs: Record<string, unknown>): t.ObjectExpression {\n const properties: t.ObjectProperty[] = [];\n\n for (const [key, value] of Object.entries(defs)) {\n const keyNode = toPropertyKey(key);\n\n if (value === null) {\n properties.push(t.objectProperty(keyNode, t.nullLiteral()));\n } else if (typeof value === \"string\") {\n properties.push(t.objectProperty(keyNode, t.stringLiteral(value)));\n } else if (typeof value === \"number\") {\n properties.push(t.objectProperty(keyNode, t.numericLiteral(value)));\n } else if (typeof value === \"object\") {\n properties.push(t.objectProperty(keyNode, defsToAst(value as Record<string, unknown>)));\n }\n }\n\n return t.objectExpression(properties);\n}\n\n/** Convert a primitive/object style value into an AST expression node. */\nfunction valueToAst(value: unknown): t.Expression {\n if (value === null) return t.nullLiteral();\n if (typeof value === \"string\") return t.stringLiteral(value);\n if (typeof value === \"number\") return t.numericLiteral(value);\n if (typeof value === \"object\") return defsToAst(value as Record<string, unknown>);\n return t.stringLiteral(String(value));\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { ResolvedSegment } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n createVarName: string;\n stylexNamespaceName: string;\n maybeIncHelperName: string | null;\n runtimeLookupNames: Map<string, string>;\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into StyleX runtime calls.\n *\n * Why this is split out: the transform has two distinct concerns—\"what to\n * emit\" (`stylex.create`) and \"where to rewrite usage sites\" (`stylex.props`).\n * Keeping site rewrites isolated makes behavior easier to reason about.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const propsArgs = buildPropsArgsFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n\n if (cssAttrPath) {\n const propsCall = t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n\n const openingElement = cssAttrPath.parentPath;\n let existingClassNameExpr: t.Expression | null = null;\n\n if (openingElement && openingElement.isJSXOpeningElement()) {\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: \"className\" })) {\n if (t.isStringLiteral(attr.value)) {\n existingClassNameExpr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n existingClassNameExpr = attr.value.expression;\n }\n attrs.splice(i, 1);\n break;\n }\n }\n }\n\n let spreadExpr: t.Expression;\n if (existingClassNameExpr) {\n const rId = t.identifier(\"__r\");\n // Keep existing className values while appending StyleX-generated className.\n // We do this in a tiny IIFE so the generated expression remains a single\n // JSX spread without introducing extra statements.\n const mergedClassName = t.callExpression(\n t.memberExpression(\n t.binaryExpression(\n \"+\",\n t.binaryExpression(\"+\", existingClassNameExpr, t.stringLiteral(\" \")),\n t.logicalExpression(\"||\", t.memberExpression(rId, t.identifier(\"className\")), t.stringLiteral(\"\")),\n ),\n t.identifier(\"trim\"),\n ),\n [],\n );\n spreadExpr = t.callExpression(\n t.arrowFunctionExpression(\n [rId],\n t.objectExpression([t.spreadElement(rId), t.objectProperty(t.identifier(\"className\"), mergedClassName)]),\n ),\n [propsCall],\n );\n } else {\n spreadExpr = propsCall;\n }\n\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(spreadExpr));\n continue;\n }\n\n site.path.replaceWith(t.arrayExpression(propsArgs));\n }\n\n rewriteStyleObjectExpressions(options.ast);\n\n // Second pass: lower any style-array-like `css={...}` expression to `stylex.props(...)`.\n rewriteCssAttributeExpressions(options.ast, options.stylexNamespaceName);\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n/**\n * Build arguments for `stylex.props(...)` from a resolved chain.\n *\n * Conditional segments are converted to ternaries (or spread ternaries when a\n * branch has multiple refs) so branch structure is preserved in emitted code.\n */\nfunction buildPropsArgsFromChain(\n chain: ResolvedChain,\n options: RewriteSitesOptions,\n): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const marker of chain.markers) {\n if (marker.markerNode) {\n args.push(marker.markerNode);\n } else {\n args.push(\n t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"defaultMarker\")),\n [],\n ),\n );\n }\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n args.push(...buildPropsArgs(part.segments, options));\n continue;\n }\n\n const thenArgs = buildPropsArgs(part.thenSegments, options);\n const elseArgs = buildPropsArgs(part.elseSegments, options);\n\n if (\n thenArgs.length === 1 &&\n elseArgs.length === 1 &&\n !t.isSpreadElement(thenArgs[0]) &&\n !t.isSpreadElement(elseArgs[0])\n ) {\n args.push(t.conditionalExpression(part.conditionNode, thenArgs[0], elseArgs[0]));\n } else if (thenArgs.length > 0 || elseArgs.length > 0) {\n args.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.arrayExpression(thenArgs), t.arrayExpression(elseArgs)),\n ),\n );\n }\n }\n\n return args;\n}\n\n/**\n * Convert resolved segments to style refs and dynamic invocations.\n */\nfunction buildPropsArgs(segments: ResolvedSegment[], options: RewriteSitesOptions): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const seg of segments) {\n // Skip error segments — they are logged via console.error at the top of the file\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (!lookupName) {\n continue;\n }\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n args.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.arrayExpression([]))));\n continue;\n }\n\n const ref = t.memberExpression(t.identifier(options.createVarName), t.identifier(seg.key));\n\n if (seg.dynamicProps && seg.argNode) {\n let argExpr: t.Expression;\n if (seg.incremented && options.maybeIncHelperName) {\n argExpr = t.callExpression(t.identifier(options.maybeIncHelperName), [seg.argNode]);\n } else if (seg.incremented) {\n argExpr = seg.argNode as t.Expression;\n } else {\n argExpr = t.callExpression(t.identifier(\"String\"), [seg.argNode]);\n }\n args.push(t.callExpression(ref, [argExpr]));\n } else {\n args.push(ref);\n }\n }\n\n return args;\n}\n\n/**\n * Rewrite style-array-like `css={...}` expressions to `...stylex.props(...)`.\n */\nfunction rewriteCssAttributeExpressions(ast: t.File, stylexNamespaceName: string): void {\n traverse(ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n if (!t.isExpression(value.expression)) return;\n const expr = normalizeStyleArrayLikeExpression(value.expression, path, new Set<t.Node>());\n if (!expr) return;\n\n const propsArgs = buildStyleArrayLikePropsArgs(expr, path, new Set<t.Node>());\n if (!propsArgs) return;\n\n const propsCall = t.callExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n path.replaceWith(t.jsxSpreadAttribute(propsCall));\n },\n });\n}\n\n// Style-array-like helpers are shared by object-spread repair and JSX css lowering.\n\n/** Convert a style-array-like expression into `stylex.props(...)` arguments. */\nfunction buildStyleArrayLikePropsArgs(\n expr: t.Expression,\n path: NodePath,\n seen: Set<t.Node>,\n): (t.Expression | t.SpreadElement)[] | null {\n if (seen.has(expr)) return null;\n seen.add(expr);\n\n if (t.isArrayExpression(expr)) {\n const propsArgs: (t.Expression | t.SpreadElement)[] = [];\n\n for (const el of expr.elements) {\n if (!el) continue;\n\n if (t.isSpreadElement(el)) {\n const normalizedArg = normalizeStyleArrayLikeExpression(el.argument, path, new Set<t.Node>()); // I.e. `...[css.df]`, `...base`, or `...(cond ? styles.hover : {})`\n if (!normalizedArg) {\n propsArgs.push(t.spreadElement(el.argument));\n continue;\n }\n\n const nestedArgs = buildStyleArrayLikePropsArgs(normalizedArg, path, seen);\n if (nestedArgs && t.isArrayExpression(normalizedArg)) {\n propsArgs.push(...nestedArgs);\n } else {\n propsArgs.push(t.spreadElement(normalizedArg));\n }\n continue;\n }\n\n propsArgs.push(el);\n }\n\n return propsArgs;\n }\n\n if (t.isIdentifier(expr) || t.isMemberExpression(expr) || t.isConditionalExpression(expr)) {\n return [t.spreadElement(expr)]; // I.e. `base`, `styles.wrapper`, or `cond ? styles.hover : []`\n }\n\n return null;\n}\n\n/**\n * Rewrite object spread composition like `{ ...[css.df], ...(cond ? [css.a] : {}) }`\n * into style ref arrays so later JSX css rewrites can flatten them safely.\n */\nfunction rewriteStyleObjectExpressions(ast: t.File): void {\n traverse(ast, {\n ObjectExpression(path: NodePath<t.ObjectExpression>) {\n const rewritten = tryBuildStyleArrayFromObject(path);\n if (!rewritten) return;\n path.replaceWith(rewritten);\n },\n });\n}\n\n/** One-line detection for object spread groups that really represent style arrays. */\nfunction tryBuildStyleArrayFromObject(path: NodePath<t.ObjectExpression>): t.ArrayExpression | null {\n if (path.node.properties.length === 0) return null;\n\n let sawStyleArray = false;\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n\n for (const prop of path.node.properties) {\n if (!t.isSpreadElement(prop)) {\n return null;\n }\n\n const normalizedArg = normalizeStyleArrayLikeExpression(\n prop.argument,\n path,\n new Set<t.Node>(), // I.e. `...Css.df.$`, `...(cond ? Css.df.$ : {})`, or `...styles.wrapper`\n );\n if (!normalizedArg) {\n return null;\n }\n\n if (isStyleArrayLike(normalizedArg, path, new Set<t.Node>())) {\n sawStyleArray = true;\n }\n\n if (t.isArrayExpression(normalizedArg)) {\n elements.push(...normalizedArg.elements);\n continue;\n }\n\n elements.push(t.spreadElement(normalizedArg));\n }\n\n if (!sawStyleArray) return null;\n return t.arrayExpression(elements);\n}\n\n/**\n * Normalize style-array conditionals so object fallback branches become arrays.\n */\nfunction normalizeStyleArrayLikeExpression(expr: t.Expression, path: NodePath, seen: Set<t.Node>): t.Expression | null {\n if (seen.has(expr)) return null;\n seen.add(expr);\n\n if (t.isArrayExpression(expr)) return expr; // I.e. `[css.df]` or `[css.df, ...xss]`\n\n if (t.isConditionalExpression(expr)) {\n const consequent = normalizeStyleArrayLikeBranch(expr.consequent, path, seen);\n const alternate = normalizeStyleArrayLikeBranch(expr.alternate, path, seen);\n if (!consequent || !alternate) return null;\n return t.conditionalExpression(expr.test, consequent, alternate); // I.e. `cond ? Css.df.$ : {}`\n }\n\n if (t.isIdentifier(expr) || t.isMemberExpression(expr)) {\n const nestedSeen = new Set(seen);\n nestedSeen.delete(expr);\n if (isStyleArrayLike(expr, path, nestedSeen)) return expr; // I.e. `base` or `styles.wrapper`\n }\n\n return null;\n}\n\n/** Normalize a conditional branch inside a style-array-like expression. */\nfunction normalizeStyleArrayLikeBranch(expr: t.Expression, path: NodePath, seen: Set<t.Node>): t.Expression | null {\n if (isEmptyObjectExpression(expr)) {\n return t.arrayExpression([]); // I.e. `cond ? Css.df.$ : {}` becomes `cond ? [css.df] : []`\n }\n\n return normalizeStyleArrayLikeExpression(expr, path, seen);\n}\n\n/** Check whether an expression is known to evaluate to a style ref array. */\nfunction isStyleArrayLike(expr: t.Expression, path: NodePath, seen: Set<t.Node>): boolean {\n if (seen.has(expr)) return false;\n seen.add(expr);\n\n if (t.isArrayExpression(expr)) return true; // I.e. `[css.df]`\n\n if (t.isConditionalExpression(expr)) {\n return isStyleArrayLikeBranch(expr.consequent, path, seen) && isStyleArrayLikeBranch(expr.alternate, path, seen); // I.e. `cond ? [css.df] : []`\n }\n\n if (t.isIdentifier(expr)) {\n const binding = path.scope.getBinding(expr.name);\n const bindingPath = binding?.path;\n if (!bindingPath || !bindingPath.isVariableDeclarator()) return false;\n const init = bindingPath.node.init;\n return !!(init && isStyleArrayLike(init, bindingPath, seen)); // I.e. `base` where `const base = [css.df]`\n }\n\n if (t.isMemberExpression(expr) && !expr.computed && t.isIdentifier(expr.property)) {\n const object = expr.object;\n if (!t.isIdentifier(object)) return false;\n\n const binding = path.scope.getBinding(object.name);\n const bindingPath = binding?.path;\n if (!bindingPath || !bindingPath.isVariableDeclarator()) return false;\n const init = bindingPath.node.init;\n if (!init || !t.isObjectExpression(init)) return false;\n\n const propertyName = expr.property.name;\n for (const prop of init.properties) {\n if (!t.isObjectProperty(prop) || prop.computed) continue;\n if (!isMatchingPropertyName(prop.key, propertyName)) continue;\n const value = prop.value;\n return t.isExpression(value) && isStyleArrayLike(value, bindingPath, seen); // I.e. `styles.wrapper`\n }\n }\n\n return false;\n}\n\n/** Check a branch used inside a conditional style-array expression. */\nfunction isStyleArrayLikeBranch(expr: t.Expression, path: NodePath, seen: Set<t.Node>): boolean {\n return isEmptyObjectExpression(expr) || isStyleArrayLike(expr, path, seen); // I.e. `{}` or `[css.df]`\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Check for `{}` fallback branches that should become `[]`. */\nfunction isEmptyObjectExpression(expr: t.Expression): boolean {\n return t.isObjectExpression(expr) && expr.properties.length === 0;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\nimport { collectStaticStringBindings, resolveStaticString } from \"./css-ts-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export const css = {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export const css = { ... }` expression\n const cssExport = findNamedCssExportObject(ast);\n if (!cssExport) {\n return `/* [truss] ${filename}: expected \\`export const css = { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n const stringBindings = collectStaticStringBindings(ast);\n\n for (const prop of cssExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop, stringBindings);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export const css = { ... }`. */\nfunction findNamedCssExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportNamedDeclaration(node) || !node.declaration) continue;\n if (!t.isVariableDeclaration(node.declaration)) continue;\n\n for (const declarator of node.declaration.declarations) {\n if (!t.isIdentifier(declarator.id, { name: \"css\" })) continue;\n const value = unwrapObjectExpression(declarator.init);\n if (value) return value;\n }\n }\n return null;\n}\n\nfunction unwrapObjectExpression(node: t.Expression | null | undefined): t.ObjectExpression | null {\n if (!node) return null;\n if (t.isObjectExpression(node)) return node;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);\n return null;\n}\n\n/** Extract a static string key from an ObjectProperty. */\nfunction objectPropertyStringKey(prop: t.ObjectProperty, stringBindings: Map<string, string>): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n if (prop.computed) return resolveStaticString(prop.key, stringBindings);\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (dynamic with variable args)\n if (seg.dynamicProps && !seg.argResolved) {\n return { error: `dynamic value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n","import * as t from \"@babel/types\";\n\n/** Resolve module-scope string constants so .css.ts selectors can reuse them. */\nexport function collectStaticStringBindings(ast: t.File): Map<string, string> {\n const bindings = new Map<string, string>();\n let changed = true;\n\n while (changed) {\n changed = false;\n\n for (const node of ast.program.body) {\n const declaration = getTopLevelVariableDeclaration(node);\n if (!declaration) continue;\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) continue;\n if (bindings.has(declarator.id.name)) continue;\n\n const value = resolveStaticString(declarator.init, bindings);\n if (value === null) continue;\n\n bindings.set(declarator.id.name, value);\n changed = true;\n }\n }\n }\n\n return bindings;\n}\n\n/** Resolve a static string expression from a literal, template, or identifier. */\nexport function resolveStaticString(node: t.Node | null | undefined, bindings: Map<string, string>): string | null {\n if (!node) return null;\n\n if (t.isStringLiteral(node)) return node.value;\n\n if (t.isTemplateLiteral(node)) {\n let value = \"\";\n for (let i = 0; i < node.quasis.length; i++) {\n value += node.quasis[i].value.cooked ?? \"\";\n if (i >= node.expressions.length) continue;\n\n const expressionValue = resolveStaticString(node.expressions[i], bindings);\n if (expressionValue === null) return null;\n value += expressionValue;\n }\n return value;\n }\n\n if (t.isIdentifier(node)) {\n return bindings.get(node.name) ?? null;\n }\n\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node) || t.isTSNonNullExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isParenthesizedExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isBinaryExpression(node, { operator: \"+\" })) {\n const left = resolveStaticString(node.left, bindings);\n const right = resolveStaticString(node.right, bindings);\n if (left === null || right === null) return null;\n return left + right;\n }\n\n return null;\n}\n\nfunction getTopLevelVariableDeclaration(node: t.Statement): t.VariableDeclaration | null {\n if (t.isVariableDeclaration(node)) {\n return node;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {\n return node.declaration;\n }\n\n return null;\n}\n","import { parse } from \"@babel/parser\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { findLastImportIndex } from \"./ast-utils\";\n\n// Babel generator is published as CJS, so normalize default interop before using it.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface RewriteCssTsImportsResult {\n code: string;\n changed: boolean;\n}\n\n/**\n * Rewrite `.css.ts` imports so runtime imports stay pointed at the real module,\n * while a separate `?truss-css` side-effect import is added for generated CSS.\n *\n * I.e. `import { foo } from \"./App.css.ts\"` becomes:\n * - `import { foo } from \"./App.css.ts\"`\n * - `import \"./App.css.ts?truss-css\"`\n *\n * Pure side-effect imports are rewritten directly to the virtual CSS import.\n */\nexport function rewriteCssTsImports(code: string, filename: string): RewriteCssTsImportsResult {\n if (!code.includes(\".css.ts\")) {\n return { code, changed: false };\n }\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const existingCssSideEffects = new Set<string>();\n const neededCssSideEffects = new Set<string>();\n let changed = false;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (typeof node.source.value !== \"string\") continue;\n if (!node.source.value.endsWith(\".css.ts\")) continue;\n\n if (node.specifiers.length === 0) {\n node.source = t.stringLiteral(toVirtualCssSpecifier(node.source.value));\n existingCssSideEffects.add(node.source.value);\n changed = true;\n continue;\n }\n\n neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));\n }\n\n const sideEffectImports: t.ImportDeclaration[] = [];\n for (const source of neededCssSideEffects) {\n if (existingCssSideEffects.has(source)) continue;\n sideEffectImports.push(t.importDeclaration([], t.stringLiteral(source)));\n changed = true;\n }\n\n if (!changed) {\n return { code, changed: false };\n }\n\n if (sideEffectImports.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...sideEffectImports);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n return { code: output.code, changed: true };\n}\n\nfunction toVirtualCssSpecifier(source: string): string {\n return `${source}?truss-css`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,SAAS,kBAAkB;;;ACD7C,SAAS,aAAa;AACtB,OAAOA,gBAAe;AAEtB,OAAO,eAAe;AACtB,YAAYC,QAAO;;;AC6DZ,SAAS,iBAAiB,OAAoB,SAAsC;AACzF,QAAM,QAA6B,CAAC;AACpC,QAAM,UAA2B,CAAC;AAGlC,QAAM,gBAA6B,CAAC;AAEpC,QAAM,aAAuB,CAAC;AA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