styled-components-to-stylex-codemod 0.0.58 → 0.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ImportSource, i as AdapterInput, o as MarkerFileContext, s as defineAdapter, t as CollectedWarning } from "./logger-B9VD--XI.mjs";
1
+ import { a as ImportSource, i as AdapterInput, o as MarkerFileContext, s as defineAdapter, t as CollectedWarning } from "./logger-Byc7DAuP.mjs";
2
2
 
3
3
  //#region src/run.d.ts
4
4
  interface RunTransformOptions {
@@ -125,7 +125,8 @@ type CallResolveContext = {
125
125
  /**
126
126
  * Call arguments.
127
127
  * - literals are surfaced precisely
128
- * - theme member access can be surfaced as `{ kind: "theme", path }`
128
+ * - theme object/member access can be surfaced as `{ kind: "theme", path }`
129
+ * (`path === ""` means the whole theme object)
129
130
  * - everything else is `unknown`
130
131
  */
131
132
  args: Array<{
@@ -958,7 +959,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
958
959
  //#endregion
959
960
  //#region src/internal/logger.d.ts
960
961
  type Severity = "info" | "warning" | "error";
961
- type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolved an imported helper call as StyleX styles without replacing the RuleSet helper" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | "Adapter resolved imported StyleX value under nested selectors/at-rules but did not provide cssText for property expansion — add cssText to resolveValue result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | 'Adapter resolveValue cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Imported constant cannot be referenced inside stylex.create() — move it into a `.stylex` defineConsts/defineVars group (or map it via adapter.resolveValue)" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: unsupported or mixed @-rules require manual handling" | "CSS block contains unsupported at-rule (only @media, @container, and @supports are supported; mixed nested at-rules require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: finite ternary before a later overlapping declaration requires manual source-order handling" | "Conditional `css` block: runtime pseudo-alias styles are not supported" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Unsupported background shorthand: multiple components cannot be mapped to a single StyleX longhand" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported .attrs() callback pattern" | "Unsupported .attrs() object value" | "Unsupported .attrs() object/array value on a styled component sharing a multi-declarator statement" | "Unsupported .attrs() object/array value on a styled component whose name is shadowed in another scope" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "css helper with prop-based interpolation cannot be reused as a mixin" | "Unsupported interpolation: member expression" | "Unsupported interpolation: multiple dynamic slots in one declaration" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | `Unsupported CSS property "${string}" cannot be emitted in StyleX` | "Dynamic logical scroll shorthand cannot be expanded — bind a specific longhand (e.g. scroll-padding-inline-start) instead" | "Imported runtime condition root collides with a component prop of the same name" | "Mixed logical and physical scroll properties cannot be normalized without a known writing-mode" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: adjacent sibling combinator" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: conditional css block inside pseudo-element selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: pseudo-class on pseudo-element selector" | "Unsupported selector: unsupported pseudo-element" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in attribute selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: unresolved interpolation in cross-component sibling selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: computed media query inside ancestor attribute selector" | "Unsupported selector: computed media query inside cross-component sibling selector" | "Unsupported selector: computed media query inside sibling selector" | "Unsupported selector: computed media query inside :has() component selector" | "Unsupported: a property combines a computed at-rule key (from resolveSelector) with a static at-rule key on the same property — StyleX emits computed keys last, so the original cascade order between the at-rules cannot be preserved" | "Unsupported selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component selector" | "Unsupported selector: component selector with child pseudo" | "Unsupported selector: component selector target has no patchable JSX usage under selector parent" | "Unsupported selector: compound pseudo selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "Partial migration left styled-components declarations unconverted" | "styled(ImportedComponent) wraps a component whose file uses styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Partial transform would have a StyleX leaf wrap a styled-components base — the extending component was transformed but its base was not, so the leaf's StyleX overrides cannot reliably beat the base's styled-components styles" | "Partial transform would leave a StyleX child reveal targeting a styled-components ancestor — the component-selector ancestor was not converted, so it cannot render the marker the child's stylex.when.ancestor() reveal needs; the child is preserved as styled-components to keep the reveal working" | "Conditional StyleX default would override an unproven earlier style for the same property" | "Flat StyleX value would erase earlier conditional property states" | "Forwarded sx conditional default would override an unproven wrapped component base style" | "Wrapped component does not accept className or sx for generated StyleX styles" | "Wrapped component sx prop targets an inner element for a root style property" | "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly" | "Wrapped component sx prop does not accept generated StyleX property" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names" | "Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens" | "animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead";
962
+ type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolved an imported helper call as StyleX styles without replacing the RuleSet helper" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved className-only helper cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | "Adapter resolved imported StyleX value under nested selectors/at-rules but did not provide cssText for property expansion — add cssText to resolveValue result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | 'Adapter resolveValue cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Imported constant cannot be referenced inside stylex.create() — move it into a `.stylex` defineConsts/defineVars group (or map it via adapter.resolveValue)" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: unsupported or mixed @-rules require manual handling" | "CSS block contains unsupported at-rule (only @media, @container, and @supports are supported; mixed nested at-rules require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: finite ternary before a later overlapping declaration requires manual source-order handling" | "Conditional `css` block: runtime pseudo-alias styles are not supported" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Unsupported background shorthand: multiple components cannot be mapped to a single StyleX longhand" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported .attrs() callback pattern" | "Unsupported .attrs() object value" | "Unsupported .attrs() object/array value on a styled component sharing a multi-declarator statement" | "Unsupported .attrs() object/array value on a styled component whose name is shadowed in another scope" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "css helper with prop-based interpolation cannot be reused as a mixin" | "Unsupported interpolation: member expression" | "Unsupported interpolation: multiple dynamic slots in one declaration" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | `Unsupported CSS property "${string}" cannot be emitted in StyleX` | "Dynamic logical scroll shorthand cannot be expanded — bind a specific longhand (e.g. scroll-padding-inline-start) instead" | "Prop-dependent dynamic style function cannot also carry a computed media-query override for the same property — split into static conditional styles or bind the media value separately" | "Imported runtime condition root collides with a component prop of the same name" | "Mixed logical and physical scroll properties cannot be normalized without a known writing-mode" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: adjacent sibling combinator" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: conditional css block inside pseudo-element selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: pseudo-class on pseudo-element selector" | "Unsupported selector: unsupported pseudo-element" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in attribute selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: unresolved interpolation in cross-component sibling selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: computed media query inside ancestor attribute selector" | "Unsupported selector: computed media query inside cross-component sibling selector" | "Unsupported selector: computed media query inside sibling selector" | "Unsupported selector: computed media query inside :has() component selector" | "Unsupported: a property combines a computed at-rule key (from resolveSelector) with a static at-rule key on the same property — StyleX emits computed keys last, so the original cascade order between the at-rules cannot be preserved" | "Unsupported selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component selector" | "Unsupported selector: component selector with child pseudo" | "Unsupported selector: component selector target has no patchable JSX usage under selector parent" | "Unsupported selector: compound pseudo selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "Partial migration left styled-components declarations unconverted" | "styled(ImportedComponent) wraps a component whose file uses styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Partial transform would have a StyleX leaf wrap a styled-components base — the extending component was transformed but its base was not, so the leaf's StyleX overrides cannot reliably beat the base's styled-components styles" | "Partial transform would leave a StyleX child reveal targeting a styled-components ancestor — the component-selector ancestor was not converted, so it cannot render the marker the child's stylex.when.ancestor() reveal needs; the child is preserved as styled-components to keep the reveal working" | "Conditional StyleX default would override an unproven earlier style for the same property" | "Flat StyleX value would erase earlier conditional property states" | "Forwarded sx conditional default would override an unproven wrapped component base style" | "Wrapped component does not accept className or sx for generated StyleX styles" | "Wrapped component sx prop targets an inner element for a root style property" | "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly" | "Wrapped component sx prop does not accept generated StyleX property" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names" | "Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens" | "animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead";
962
963
  interface WarningLog {
963
964
  severity: Severity;
964
965
  type: WarningType;
@@ -1,4 +1,4 @@
1
- import { n as WarningLog, r as Adapter } from "./logger-B9VD--XI.mjs";
1
+ import { n as WarningLog, r as Adapter } from "./logger-Byc7DAuP.mjs";
2
2
  import { API, FileInfo, Options } from "jscodeshift";
3
3
  //#region src/internal/prepass/typescript-analysis.d.ts
4
4
  interface TypeScriptPrepassMetadata {
@@ -2940,6 +2940,49 @@ function isSlotBindingOrJsxTagReference(idNode, parent) {
2940
2940
  }
2941
2941
  }
2942
2942
  //#endregion
2943
+ //#region src/internal/utilities/import-source.ts
2944
+ /**
2945
+ * Helpers for converting an `ImportSource` into the textual specifier used in
2946
+ * an emitted `import` declaration, and into a writable absolute file path.
2947
+ */
2948
+ /**
2949
+ * Convert an `ImportSource` to a module specifier string for use in import declarations.
2950
+ * - `kind: "specifier"` → returned as-is.
2951
+ * - `kind: "absolutePath"` → returned as a relative path from `filePath`'s directory,
2952
+ * prefixed with `./` when needed.
2953
+ *
2954
+ * Pass `stripTsExtension: true` to drop a trailing `.ts`/`.tsx` from the relative
2955
+ * specifier (e.g. when emitting an import to a sidecar `.stylex.ts` file).
2956
+ */
2957
+ function importSourceToModuleSpecifier(source, filePath, options = {}) {
2958
+ if (source.kind === "specifier") return source.value;
2959
+ let rel = relative(dirname(filePath), source.value).split(sep).join("/");
2960
+ if (options.stripTsExtension) rel = rel.replace(/\.tsx?$/, "");
2961
+ if (!rel.startsWith(".")) rel = `./${rel}`;
2962
+ return rel;
2963
+ }
2964
+ /**
2965
+ * Resolve an `ImportSource` to an absolute file path for writing the sidecar file.
2966
+ * - `kind: "absolutePath"` → returned as-is.
2967
+ * - `kind: "specifier"` → resolved relative to `filePath`'s directory; appends `.ts`
2968
+ * when the result has no `.{j,t}sx?` extension.
2969
+ */
2970
+ function importSourceToAbsolutePath(source, filePath) {
2971
+ if (source.kind === "absolutePath") return source.value;
2972
+ let resolved = join(dirname(filePath), source.value);
2973
+ if (!/\.[jt]sx?$/.test(resolved)) resolved += ".ts";
2974
+ return resolved;
2975
+ }
2976
+ /**
2977
+ * Throws if `source` is structurally invalid for use as a module reference,
2978
+ * with a `label` prefixed for caller context. Used by the merger import step
2979
+ * which validates user-provided adapter configuration at use-time.
2980
+ */
2981
+ function assertValidImportSource(source, label) {
2982
+ if (typeof source.value !== "string" || source.value.trim() === "") throw new Error(`Invalid ${label}: expected non-empty string, got ${JSON.stringify(source.value)}`);
2983
+ if (source.kind === "absolutePath" && !isAbsolute(source.value)) throw new Error(`Invalid ${label}: expected absolute path, got ${JSON.stringify(source.value)}`);
2984
+ }
2985
+ //#endregion
2943
2986
  //#region src/internal/utilities/component-value-references.ts
2944
2987
  /**
2945
2988
  * True when this Identifier path is a non-JSX value reference to a styled component (not its
@@ -3261,17 +3304,21 @@ function getCalleeIdentName(callee) {
3261
3304
  function callArgFromNode(node, propsParamName, themeBindingName) {
3262
3305
  if (!node || typeof node !== "object") return { kind: "unknown" };
3263
3306
  const type = node.type;
3307
+ if (type === "Identifier" && typeof themeBindingName === "string" && themeBindingName && node.name === themeBindingName) return {
3308
+ kind: "theme",
3309
+ path: ""
3310
+ };
3264
3311
  if (type === "MemberExpression") {
3265
3312
  if (typeof propsParamName === "string" && propsParamName) {
3266
3313
  const parts = getMemberPathFromIdentifier(node, propsParamName);
3267
- if (parts && parts[0] === "theme" && parts.length > 1) return {
3314
+ if (parts && parts[0] === "theme") return {
3268
3315
  kind: "theme",
3269
3316
  path: parts.slice(1).join(".")
3270
3317
  };
3271
3318
  }
3272
3319
  if (typeof themeBindingName === "string" && themeBindingName) {
3273
3320
  const parts = getMemberPathFromIdentifier(node, themeBindingName);
3274
- if (parts && parts.length > 0) return {
3321
+ if (parts) return {
3275
3322
  kind: "theme",
3276
3323
  path: parts.join(".")
3277
3324
  };
@@ -5530,7 +5577,7 @@ function collectStylexCreateMaps(ast, moduleBindings) {
5530
5577
  for (const node of Array.isArray(declaration.declarations) ? declaration.declarations : []) {
5531
5578
  if (!isRecord(node) || node.type !== "VariableDeclarator") continue;
5532
5579
  const id = node.id;
5533
- const init = node.init;
5580
+ const init = unwrapExpression(node.init);
5534
5581
  if (!isIdentifier(id) || !isRecord(init) || !isStylexCreateCall$1(init)) continue;
5535
5582
  const stylesArg = getCallArguments(init)[0];
5536
5583
  if (!isObjectExpression$1(stylesArg)) continue;
@@ -5588,11 +5635,14 @@ function readStyleObjectProps(styleObject, moduleBindings, dynamicValueNames = /
5588
5635
  const resolution = resolveConstReference(property.value, moduleBindings);
5589
5636
  if (resolution.kind === "unresolved") {
5590
5637
  if (dynamicValueNames.has(resolution.name)) props.set(key, { kind: "dynamic" });
5591
- else complete = false;
5638
+ else props.set(key, { kind: "unknownConditionalMap" });
5592
5639
  continue;
5593
5640
  }
5594
5641
  const valueNode = resolution.node;
5595
- if (isObjectExpression$1(valueNode) && objectExpressionHasUnreadProperties(valueNode)) complete = false;
5642
+ if (isObjectExpression$1(valueNode) && objectExpressionHasUnreadProperties(valueNode)) {
5643
+ props.set(key, { kind: "unknownConditionalMap" });
5644
+ continue;
5645
+ }
5596
5646
  const value = readAstPropertyShape(valueNode, moduleBindings);
5597
5647
  if (value.kind !== "absent") props.set(key, value);
5598
5648
  }
@@ -5971,6 +6021,10 @@ function analyzeStyleEntry(styleEntry, prop, called) {
5971
6021
  };
5972
6022
  const value = styleEntry.props.get(prop);
5973
6023
  if (!value) return { kind: "absent" };
6024
+ if (value.kind === "unknownConditionalMap") return {
6025
+ kind: "variableConditionalMap",
6026
+ conditionKeys: []
6027
+ };
5974
6028
  if (styleEntry.kind === "function" || called || value.kind === "dynamic") return value.kind === "conditionalMap" ? {
5975
6029
  kind: "variableConditionalMap",
5976
6030
  conditionKeys: value.conditionKeys
@@ -6232,7 +6286,7 @@ function isSxExpression(node, sxBindings) {
6232
6286
  }
6233
6287
  function unwrapExpression(node) {
6234
6288
  let current = node;
6235
- while (isRecord(current) && (current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "ParenthesizedExpression")) current = current.expression;
6289
+ while (isRecord(current) && (current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "TSSatisfiesExpression" || current.type === "ParenthesizedExpression")) current = current.expression;
6236
6290
  return current;
6237
6291
  }
6238
6292
  function unwrapAssignmentPattern(node) {
@@ -6279,10 +6333,22 @@ function getFunctionParams(node) {
6279
6333
  }
6280
6334
  function readPropertyKey$1(property) {
6281
6335
  const key = property.key;
6336
+ if (property.computed === true) return readComputedPropertyKey(key);
6282
6337
  if (isIdentifier(key)) return key.name;
6283
6338
  if (isRecord(key) && (key.type === "StringLiteral" || key.type === "Literal")) return typeof key.value === "string" ? key.value : null;
6284
6339
  return null;
6285
6340
  }
6341
+ function readComputedPropertyKey(key) {
6342
+ const literalKey = readStringLiteralKey(key);
6343
+ if (literalKey) return literalKey;
6344
+ if (!isRecord(key) || key.type !== "MemberExpression") return null;
6345
+ const memberKey = readStringLiteralKey(key.property);
6346
+ return memberKey?.startsWith("--") ? memberKey : null;
6347
+ }
6348
+ function readStringLiteralKey(key) {
6349
+ if (!isRecord(key) || key.type !== "StringLiteral" && key.type !== "Literal") return null;
6350
+ return typeof key.value === "string" ? key.value : null;
6351
+ }
6286
6352
  function isStaticValue(value) {
6287
6353
  return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
6288
6354
  }
@@ -9879,17 +9945,24 @@ function analyzeBeforeEmitStep(ctx) {
9879
9945
  if (j(p).closest(j.TaggedTemplateExpression).filter((tp) => ctx.isStyledTag(tp.node.tag)).size() > 0) return false;
9880
9946
  return true;
9881
9947
  }).size() > 0;
9882
- const existingImportLocals = /* @__PURE__ */ new Set();
9948
+ const existingImportBindings = /* @__PURE__ */ new Map();
9883
9949
  root.find(j.ImportDeclaration).forEach((p) => {
9884
9950
  const specs = p.node.specifiers ?? [];
9951
+ const sourceValue = typeof p.node.source?.value === "string" ? p.node.source.value : null;
9885
9952
  for (const s of specs) {
9886
9953
  if (s?.importKind === "type") continue;
9887
9954
  const local = s?.local?.type === "Identifier" ? s.local.name : s?.type === "ImportDefaultSpecifier" && s.local?.type === "Identifier" ? s.local.name : s?.type === "ImportNamespaceSpecifier" && s.local?.type === "Identifier" ? s.local.name : null;
9888
- if (local && isUsedOutsideStyledTemplates(local)) existingImportLocals.add(local);
9955
+ if (local && isUsedOutsideStyledTemplates(local)) {
9956
+ const imported = s?.type === "ImportDefaultSpecifier" ? "default" : s?.type === "ImportNamespaceSpecifier" ? "*" : s?.imported?.name ?? s?.imported?.value ?? null;
9957
+ existingImportBindings.set(local, sourceValue !== null && typeof imported === "string" ? {
9958
+ imported,
9959
+ source: sourceValue
9960
+ } : null);
9961
+ }
9889
9962
  }
9890
9963
  });
9891
9964
  const resolverImportAliases = /* @__PURE__ */ new Map();
9892
- const usedLocals = new Set(existingImportLocals);
9965
+ const usedLocals = new Set(existingImportBindings.keys());
9893
9966
  const makeUniqueLocal = (base) => {
9894
9967
  let candidate = base;
9895
9968
  let i = 1;
@@ -9903,7 +9976,10 @@ function analyzeBeforeEmitStep(ctx) {
9903
9976
  for (const imp of ctx.resolverImports.values()) for (const n of imp.names ?? []) {
9904
9977
  const desired = n.local ?? n.imported;
9905
9978
  if (!desired) continue;
9906
- if (existingImportLocals.has(desired)) {
9979
+ if (existingImportBindings.has(desired)) {
9980
+ const existingBinding = existingImportBindings.get(desired);
9981
+ const resolverModuleSpecifier = importSourceToModuleSpecifier(imp.from, file.path, { stripTsExtension: true });
9982
+ if (existingBinding && existingBinding.imported === n.imported && existingBinding.source === resolverModuleSpecifier) continue;
9907
9983
  const alias = makeUniqueLocal(`${desired}Vars`);
9908
9984
  resolverImportAliases.set(desired, alias);
9909
9985
  n.local = alias;
@@ -13254,20 +13330,44 @@ function findStylexCreateBlockEnd(code, blockStart) {
13254
13330
  let blockEnd = blockStart;
13255
13331
  let inString = null;
13256
13332
  let escaped = false;
13333
+ let inLineComment = false;
13334
+ let inBlockComment = false;
13257
13335
  for (let i = blockStart; i < code.length && depth > 0; i++) {
13258
13336
  const ch = code[i];
13259
- if (escaped) {
13260
- escaped = false;
13337
+ const next = code[i + 1];
13338
+ if (inLineComment) {
13339
+ if (ch === "\n") inLineComment = false;
13261
13340
  continue;
13262
13341
  }
13263
- if (ch === "\\") {
13264
- escaped = true;
13342
+ if (inBlockComment) {
13343
+ if (ch === "*" && next === "/") {
13344
+ inBlockComment = false;
13345
+ i++;
13346
+ }
13265
13347
  continue;
13266
13348
  }
13267
13349
  if (inString) {
13350
+ if (escaped) {
13351
+ escaped = false;
13352
+ continue;
13353
+ }
13354
+ if (ch === "\\") {
13355
+ escaped = true;
13356
+ continue;
13357
+ }
13268
13358
  if (ch === inString) inString = null;
13269
13359
  continue;
13270
13360
  }
13361
+ if (ch === "/" && next === "/") {
13362
+ inLineComment = true;
13363
+ i++;
13364
+ continue;
13365
+ }
13366
+ if (ch === "/" && next === "*") {
13367
+ inBlockComment = true;
13368
+ i++;
13369
+ continue;
13370
+ }
13271
13371
  if (ch === "\"" || ch === "'" || ch === "`") {
13272
13372
  inString = ch;
13273
13373
  continue;
@@ -13303,10 +13403,79 @@ function transformStylexCreateBlocks(code, transformBlock) {
13303
13403
  /**
13304
13404
  * Remove blank lines inside stylex.create({...}) blocks.
13305
13405
  * Finds each `stylex.create({` and tracks brace depth to the matching `})`,
13306
- * then removes blank lines between properties within that region.
13406
+ * then drops every blank line within that region so style entries stay adjacent.
13407
+ * Blank lines inside multiline template-literal values are preserved, since they
13408
+ * are part of the CSS value and removing them would not be lossless.
13307
13409
  */
13308
13410
  function removeBlankLinesInStylexCreate(code) {
13309
- return transformStylexCreateBlocks(code, (blockContent) => blockContent.replace(/(\n\s*\},)\n\n+(\s+(?:[a-zA-Z_$][a-zA-Z0-9_$]*|["'].*?["']|\d+|::[a-zA-Z-]+|@[a-zA-Z-]+|:[a-zA-Z-]+)\s*:)/g, "$1\n$2").replace(/,\n\n+(\s+(?:[a-zA-Z_$"']|\/\/|\/\*))/g, ",\n$1").replace(/content:\s+"\\"([\s\S]*?)\\""/g, "content: '\"$1\"'").replace(/content:\s+"'\s*([\s\S]*?)\s*'"/g, "content: '\"$1\"'"));
13411
+ return transformStylexCreateBlocks(code, (blockContent) => {
13412
+ const lines = blockContent.split("\n");
13413
+ const protectedLines = protectedLineStarts(blockContent, lines.length);
13414
+ const kept = [];
13415
+ for (let i = 0; i < lines.length; i++) {
13416
+ const line = lines[i] ?? "";
13417
+ if (!protectedLines[i] && line.trim() === "") continue;
13418
+ kept.push(line);
13419
+ }
13420
+ return kept.join("\n").replace(/content:\s+"\\"([\s\S]*?)\\""/g, "content: '\"$1\"'").replace(/content:\s+"'\s*([\s\S]*?)\s*'"/g, "content: '\"$1\"'");
13421
+ });
13422
+ }
13423
+ /**
13424
+ * Returns, per line, whether that line *starts* inside a region where blank
13425
+ * lines are content and must be preserved: a multiline template-literal value or
13426
+ * a multiline block comment. Backticks inside comments or other string literals
13427
+ * are ignored, so an unmatched backtick in a preserved comment cannot flip the
13428
+ * template state and corrupt a following template value.
13429
+ */
13430
+ function protectedLineStarts(code, lineCount) {
13431
+ const protectedLines = Array.from({ length: lineCount }).fill(false);
13432
+ let inString = null;
13433
+ let inLineComment = false;
13434
+ let inBlockComment = false;
13435
+ let escaped = false;
13436
+ let line = 0;
13437
+ for (let i = 0; i < code.length; i++) {
13438
+ const ch = code[i];
13439
+ const next = code[i + 1];
13440
+ if (ch === "\n") {
13441
+ line++;
13442
+ inLineComment = false;
13443
+ if (line < lineCount) protectedLines[line] = inString === "`" || inBlockComment;
13444
+ continue;
13445
+ }
13446
+ if (inLineComment) continue;
13447
+ if (inBlockComment) {
13448
+ if (ch === "*" && next === "/") {
13449
+ inBlockComment = false;
13450
+ i++;
13451
+ }
13452
+ continue;
13453
+ }
13454
+ if (inString) {
13455
+ if (escaped) {
13456
+ escaped = false;
13457
+ continue;
13458
+ }
13459
+ if (ch === "\\") {
13460
+ escaped = true;
13461
+ continue;
13462
+ }
13463
+ if (ch === inString) inString = null;
13464
+ continue;
13465
+ }
13466
+ if (ch === "/" && next === "/") {
13467
+ inLineComment = true;
13468
+ i++;
13469
+ continue;
13470
+ }
13471
+ if (ch === "/" && next === "*") {
13472
+ inBlockComment = true;
13473
+ i++;
13474
+ continue;
13475
+ }
13476
+ if (ch === "\"" || ch === "'" || ch === "`") inString = ch;
13477
+ }
13478
+ return protectedLines;
13310
13479
  }
13311
13480
  /**
13312
13481
  * Indents lines inside multiline template literal object values so each continuation
@@ -17914,49 +18083,6 @@ function rewriteCssHelpersStep(ctx) {
17914
18083
  return CONTINUE;
17915
18084
  }
17916
18085
  //#endregion
17917
- //#region src/internal/utilities/import-source.ts
17918
- /**
17919
- * Helpers for converting an `ImportSource` into the textual specifier used in
17920
- * an emitted `import` declaration, and into a writable absolute file path.
17921
- */
17922
- /**
17923
- * Convert an `ImportSource` to a module specifier string for use in import declarations.
17924
- * - `kind: "specifier"` → returned as-is.
17925
- * - `kind: "absolutePath"` → returned as a relative path from `filePath`'s directory,
17926
- * prefixed with `./` when needed.
17927
- *
17928
- * Pass `stripTsExtension: true` to drop a trailing `.ts`/`.tsx` from the relative
17929
- * specifier (e.g. when emitting an import to a sidecar `.stylex.ts` file).
17930
- */
17931
- function importSourceToModuleSpecifier(source, filePath, options = {}) {
17932
- if (source.kind === "specifier") return source.value;
17933
- let rel = relative(dirname(filePath), source.value).split(sep).join("/");
17934
- if (options.stripTsExtension) rel = rel.replace(/\.tsx?$/, "");
17935
- if (!rel.startsWith(".")) rel = `./${rel}`;
17936
- return rel;
17937
- }
17938
- /**
17939
- * Resolve an `ImportSource` to an absolute file path for writing the sidecar file.
17940
- * - `kind: "absolutePath"` → returned as-is.
17941
- * - `kind: "specifier"` → resolved relative to `filePath`'s directory; appends `.ts`
17942
- * when the result has no `.{j,t}sx?` extension.
17943
- */
17944
- function importSourceToAbsolutePath(source, filePath) {
17945
- if (source.kind === "absolutePath") return source.value;
17946
- let resolved = join(dirname(filePath), source.value);
17947
- if (!/\.[jt]sx?$/.test(resolved)) resolved += ".ts";
17948
- return resolved;
17949
- }
17950
- /**
17951
- * Throws if `source` is structurally invalid for use as a module reference,
17952
- * with a `label` prefixed for caller context. Used by the merger import step
17953
- * which validates user-provided adapter configuration at use-time.
17954
- */
17955
- function assertValidImportSource(source, label) {
17956
- if (typeof source.value !== "string" || source.value.trim() === "") throw new Error(`Invalid ${label}: expected non-empty string, got ${JSON.stringify(source.value)}`);
17957
- if (source.kind === "absolutePath" && !isAbsolute(source.value)) throw new Error(`Invalid ${label}: expected absolute path, got ${JSON.stringify(source.value)}`);
17958
- }
17959
- //#endregion
17960
18086
  //#region src/internal/utilities/import-insertion.ts
17961
18087
  /**
17962
18088
  * Return the index of the LAST top-level `ImportDeclaration` in `body`, or -1
@@ -29143,8 +29269,8 @@ function extractThemePath(memberExpr, info) {
29143
29269
  return parts.join(".");
29144
29270
  }
29145
29271
  function tryResolveArrowFnHelperCallWithThemeArg(node, ctx) {
29146
- const expr = getPropArrowFn(node);
29147
- if (!expr) return null;
29272
+ if (!isArrowFunctionExpression(node.expr)) return null;
29273
+ const expr = node.expr;
29148
29274
  const info = getArrowFnThemeParamInfo(expr);
29149
29275
  if (!info) return null;
29150
29276
  const body = getFunctionBodyExpr(expr);
@@ -29154,15 +29280,14 @@ function tryResolveArrowFnHelperCallWithThemeArg(node, ctx) {
29154
29280
  const propsParamName = info.kind === "propsParam" ? info.propsName : void 0;
29155
29281
  const themeBindingName = info.kind === "themeBinding" ? info.themeName : void 0;
29156
29282
  if (!args.some((arg) => {
29157
- if (!arg || arg.type !== "MemberExpression") return false;
29283
+ if (!arg) return false;
29284
+ if (arg.type === "Identifier" && typeof themeBindingName === "string" && arg.name === themeBindingName) return true;
29285
+ if (arg.type !== "MemberExpression") return false;
29158
29286
  if (propsParamName) {
29159
29287
  const parts = getMemberPathFromIdentifier(arg, propsParamName);
29160
- return parts !== null && parts[0] === "theme" && parts.length > 1;
29161
- }
29162
- if (themeBindingName) {
29163
- const parts = getMemberPathFromIdentifier(arg, themeBindingName);
29164
- return parts !== null && parts.length > 0;
29288
+ return parts !== null && parts[0] === "theme";
29165
29289
  }
29290
+ if (themeBindingName) return getMemberPathFromIdentifier(arg, themeBindingName) !== null;
29166
29291
  return false;
29167
29292
  })) return null;
29168
29293
  const simple = resolveImportedHelperCall$1(body, ctx, propsParamName, node.css.property, themeBindingName);
@@ -38259,13 +38384,12 @@ function preScanCssHelperPlaceholders(ctx) {
38259
38384
  } else {
38260
38385
  const importEntry = importMap?.get(calleeName);
38261
38386
  if (importEntry) {
38262
- const resolved = resolveCall({
38387
+ if (!isResolvedImportedHelperForPreScan(resolveCall({
38263
38388
  callSiteFilePath: filePath,
38264
38389
  calleeImportedName: importEntry.importedName,
38265
38390
  calleeSource: importEntry.source,
38266
38391
  args: []
38267
- });
38268
- if (!resolved || !("expr" in resolved)) {
38392
+ }), rule)) {
38269
38393
  hasImportedCssHelper = true;
38270
38394
  importedCssHelperLoc ??= getNodeLocStart(expr);
38271
38395
  }
@@ -38298,6 +38422,12 @@ function preScanCssHelperPlaceholders(ctx) {
38298
38422
  }
38299
38423
  return true;
38300
38424
  }
38425
+ function isResolvedImportedHelperForPreScan(resolved, rule) {
38426
+ if (!resolved) return false;
38427
+ if ("expr" in resolved) return true;
38428
+ if ("extraClassNames" in resolved) return rule.selector.trim() === "&" && (rule.atRuleStack ?? []).length === 0;
38429
+ return false;
38430
+ }
38301
38431
  //#endregion
38302
38432
  //#region src/internal/lower-rules/borders.ts
38303
38433
  function tryHandleInterpolatedBorder(ctx, args) {
@@ -42036,9 +42166,13 @@ function calleeKey(callee) {
42036
42166
  //#endregion
42037
42167
  //#region src/internal/lower-rules/resolved-style-function-handlers.ts
42038
42168
  function tryHandleResolvedStyleFunctionNode(rc) {
42039
- const { ctx, d, media, pseudos, res, slotId, loc, avoidNames, flags, addResolverImports, bailUnsupportedLocal, annotateScalarParams, tryEmitIdentityVariantBuckets, tryEmitTransformedObservedVariantBuckets, shouldPreserveNumericCssTextForProp } = rc;
42169
+ const { ctx, d, media, pseudos, resolvedSelectorMedia, res, slotId, loc, avoidNames, flags, addResolverImports, bailUnsupportedLocal, annotateScalarParams, tryEmitIdentityVariantBuckets, tryEmitTransformedObservedVariantBuckets, shouldPreserveNumericCssTextForProp } = rc;
42040
42170
  const { state, decl, styleObj, styleFnFromProps, styleFnDecls, inlineStyleProps, annotateParamFromJsxProp } = ctx;
42041
42171
  const { j, filePath, warnings, parseExpr, resolveCall, warnPropInlineStyle, resolveImportInScope, resolveImportForExpr } = state;
42172
+ if (resolvedSelectorMedia && d.property && (decl.shouldForwardProp || res?.type === "emitStyleFunctionFromPropsObject" || res?.type === "emitStyleFunctionWithDefault" || res?.type === "emitStyleFunction")) {
42173
+ bailUnsupportedLocal(decl, "Prop-dependent dynamic style function cannot also carry a computed media-query override for the same property — split into static conditional styles or bind the media value separately");
42174
+ return true;
42175
+ }
42042
42176
  if (res && res.type === "emitStyleFunctionFromPropsObject") if (!d.property) {} else {
42043
42177
  const e = decl.templateExpressions[slotId];
42044
42178
  if (e?.type !== "ArrowFunctionExpression" && e?.type !== "FunctionExpression") {
@@ -42565,13 +42699,36 @@ function tryHandleResolvedDynamicNode(rc) {
42565
42699
  expr: exprAst,
42566
42700
  afterBase: hasStaticPropsBefore
42567
42701
  });
42702
+ if (resolvedStylesUsesThemeArg(res)) markDeclNeedsUseThemeHook(decl);
42568
42703
  if (res.extraClassNames) collectExtraClassNames(res.extraClassNames);
42569
42704
  notifyResolvedStylesArg();
42570
42705
  decl.needsWrapperComponent = true;
42571
42706
  return true;
42572
42707
  }
42573
42708
  if (res && res.type === "resolvedClassNames") {
42709
+ if (rule.selector.trim() !== "&" || (rule.atRuleStack ?? []).length) {
42710
+ const resolveCallMeta = res.resolveCallContext && res.resolveCallResult ? {
42711
+ resolveCallContext: res.resolveCallContext,
42712
+ resolveCallResult: res.resolveCallResult
42713
+ } : void 0;
42714
+ warnings.push({
42715
+ severity: "warning",
42716
+ type: "Adapter resolved className-only helper cannot be applied under nested selectors/at-rules",
42717
+ loc,
42718
+ context: resolveCallMeta ? {
42719
+ selector: rule.selector,
42720
+ atRuleStack: rule.atRuleStack,
42721
+ ...resolveCallMeta
42722
+ } : {
42723
+ selector: rule.selector,
42724
+ atRuleStack: rule.atRuleStack
42725
+ }
42726
+ });
42727
+ flags.bail = true;
42728
+ return true;
42729
+ }
42574
42730
  collectExtraClassNames(res.extraClassNames);
42731
+ if (resolvedStylesUsesThemeArg(res)) markDeclNeedsUseThemeHook(decl);
42575
42732
  decl.needsWrapperComponent = true;
42576
42733
  return true;
42577
42734
  }
@@ -43090,6 +43247,9 @@ function tryHandleResolvedDynamicNode(rc) {
43090
43247
  }
43091
43248
  return tryHandleResolvedStyleFunctionNode(rc);
43092
43249
  }
43250
+ function resolvedStylesUsesThemeArg(res) {
43251
+ return res.resolveCallContext?.args?.some((arg) => arg.kind === "theme") ?? false;
43252
+ }
43093
43253
  //#endregion
43094
43254
  //#region src/internal/lower-rules/rule-interpolated-declaration.ts
43095
43255
  function handleInterpolatedDeclaration(args) {
@@ -43105,7 +43265,7 @@ function handleInterpolatedDeclaration(args) {
43105
43265
  if (isJsxPropOptional(propName)) addUndefinedToParamType(j, param);
43106
43266
  });
43107
43267
  };
43108
- const { api, j, filePath, warnings, resolverImports, keyframesNames, parseExpr, resolveValue, resolveCall, importMap, cssHelperNames, cssHelperObjectMembers, declByLocalName, cssHelperValuesByKey, staticPropertyValues, applyCssHelperMixin, hasLocalThemeBinding, resolveThemeValue, resolveThemeValueFromFn, getOrCreateLocalStylexVar } = state;
43268
+ const { api, j, filePath, warnings, resolverImports, keyframesNames, parseExpr, resolveValue, resolveCall, importMap, cssHelperNames, cssHelperObjectMembers, declByLocalName, cssHelperValuesByKey, staticPropertyValues, localFunctionIdentifierNames, applyCssHelperMixin, hasLocalThemeBinding, resolveThemeValue, resolveThemeValueFromFn, getOrCreateLocalStylexVar } = state;
43109
43269
  const avoidNames = new Set(importMap.keys());
43110
43270
  if (state.bail) return;
43111
43271
  if (d.value.kind !== "interpolated") return;
@@ -43146,6 +43306,15 @@ function handleInterpolatedDeclaration(args) {
43146
43306
  flags
43147
43307
  });
43148
43308
  for (let _i = 0; _i < 1; _i++) {
43309
+ if (flags.bail) break;
43310
+ for (const part of d.value.parts ?? []) {
43311
+ if (part?.kind !== "slot" || part.slotId === void 0) continue;
43312
+ const slotExpr = decl.templateExpressions[part.slotId];
43313
+ if (slotExpr?.type === "Identifier" && slotExpr.name && localFunctionIdentifierNames.has(slotExpr.name)) {
43314
+ bailUnsupportedLocal(decl, "Unsupported interpolation: identifier");
43315
+ break;
43316
+ }
43317
+ }
43149
43318
  if (flags.bail) break;
43150
43319
  if (tryHandleMappedFunctionColor(d)) continue;
43151
43320
  if (tryHandleAnimation({
@@ -46176,10 +46345,13 @@ function createLowerRulesState(ctx) {
46176
46345
  };
46177
46346
  const staticPropertyValues = /* @__PURE__ */ new Map();
46178
46347
  const staticIdentifierValues = /* @__PURE__ */ new Map();
46348
+ const localFunctionIdentifierNames = /* @__PURE__ */ new Set();
46179
46349
  root.find(j.VariableDeclarator).forEach((p) => {
46180
46350
  if (!isTopLevelConstDeclarator(p)) return;
46181
46351
  const node = p.node;
46182
46352
  if (node.id?.type !== "Identifier" || !node.id.name) return;
46353
+ const initType = node.init?.type;
46354
+ if (initType === "ArrowFunctionExpression" || initType === "FunctionExpression") localFunctionIdentifierNames.add(node.id.name);
46183
46355
  const staticValue = literalToStaticValue(node.init, { allowStaticArrowFunctions: false });
46184
46356
  if (staticValue !== null) staticIdentifierValues.set(node.id.name, staticValue);
46185
46357
  });
@@ -46308,6 +46480,7 @@ function createLowerRulesState(ctx) {
46308
46480
  mixinValuesByKey,
46309
46481
  staticPropertyValues,
46310
46482
  staticIdentifierValues,
46483
+ localFunctionIdentifierNames,
46311
46484
  usedCssHelperFunctions: /* @__PURE__ */ new Set(),
46312
46485
  warnPropInlineStyle,
46313
46486
  applyCssHelperMixin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-components-to-stylex-codemod",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "Codemod to transform styled-components to StyleX",
5
5
  "keywords": [
6
6
  "codemod",