styled-components-to-stylex-codemod 0.0.34 → 0.0.35

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/README.md CHANGED
@@ -36,6 +36,13 @@ const adapter = defineAdapter({
36
36
  styleMerger: null,
37
37
  // Emit sx={} JSX attributes instead of {...stylex.props()} spreads (requires StyleX ≥0.18)
38
38
  useSxProp: false,
39
+ // Optional override for sx-aware wrapped components. Auto-detection is on by
40
+ // default when `useSxProp: true` — the codemod scans the imported component's
41
+ // prop type for an `sx?:` member. Use this hook to override (e.g. for package
42
+ // imports that cannot be resolved to source on disk).
43
+ wrappedComponentInterface(ctx) {
44
+ return undefined;
45
+ },
39
46
  // Optional: customize the runtime theme hook import/call used for theme conditionals
40
47
  // Defaults to { functionName: "useTheme", importSource: { kind: "specifier", value: "styled-components" } }
41
48
  themeHook: {
@@ -172,6 +179,27 @@ const adapter = defineAdapter({
172
179
  */
173
180
  useSxProp: false,
174
181
 
182
+ /**
183
+ * Optional override for sx-aware wrapped components.
184
+ *
185
+ * When `useSxProp: true`, the codemod auto-detects whether an imported
186
+ * component accepts an `sx` prop by walking its declared prop type
187
+ * (intersections, type aliases, and interfaces in the same file). When
188
+ * `styled(Component)` wraps an sx-aware component, the codemod emits
189
+ * `<Component sx={styles.x} />` instead of `<Component {...stylex.props(styles.x)} />`
190
+ * and lets the wrapped component merge className/style itself.
191
+ *
192
+ * Use this hook to override auto-detection for cases it can't see, such as
193
+ * unresolvable package imports or components whose sx support is added by a
194
+ * HOC at runtime. Returning `undefined` falls through to auto-detection.
195
+ */
196
+ wrappedComponentInterface(ctx) {
197
+ if (ctx.importSource.startsWith("@company/ui/")) {
198
+ return { acceptsSx: true };
199
+ }
200
+ return undefined;
201
+ },
202
+
175
203
  /**
176
204
  * Optional: customize the runtime theme hook used when wrappers need theme booleans.
177
205
  * Defaults to useTheme from styled-components.
@@ -203,6 +231,7 @@ Adapters are the main extension point, see full example above. They let you cont
203
231
  - how helper calls are resolved (via `resolveCall({ ... })` returning `{ expr, imports }`, or `{ preserveRuntimeCall: true }` to keep only the original helper runtime call; `null`/`undefined` bails the file)
204
232
  - which exported components should support external className/style extension and/or polymorphic `as` prop (`externalInterface`)
205
233
  - how className/style merging is handled for components accepting external styling (`styleMerger`)
234
+ - which imported components already accept a StyleX `sx` prop (auto-detected from the imported component's prop type when `useSxProp: true`; can be overridden via `wrappedComponentInterface`). When detected, the codemod emits `sx={styles.x}` on the wrapped component instead of `{...stylex.props(styles.x)}`.
206
235
  - which runtime theme hook import/call to use for emitted wrapper theme conditionals (`themeHook`)
207
236
  - how `styled(ImportedComponent)` wrapping an external base component can be inlined into an intrinsic element with static StyleX styles (`resolveBaseComponent`)
208
237
 
@@ -306,6 +335,7 @@ resolveBaseComponent(ctx) {
306
335
  When the codemod encounters an interpolation inside a styled template literal, it runs an internal dynamic resolution pipeline which covers common cases like:
307
336
 
308
337
  - theme access (`props.theme...`) via `resolveValue({ kind: "theme", path })`
338
+ - indexed theme lookups (`props.theme.color[props.$bg]`) — when `ctx.indexedLookup` is true, return `{ usage: "props", dynamicArgUsage: "memberAccess" }` to emit a prebuilt per-property mixin map (e.g., `$colorMixins.backgroundColor[bg]`) instead of a dynamic style function
309
339
  - imported value access (`import { zIndex } ...; ${zIndex.popover}`) via `resolveValue({ kind: "importedValue", importedName, source, path })`
310
340
  - prop access (`props.foo`) and conditionals (`props.foo ? "a" : "b"`, `props.foo && "color: red;"`)
311
341
  - helper calls (`transitionSpeed("slowTransition")`) via `resolveCall({ ... })` — the codemod infers usage from context:
@@ -1,6 +1,6 @@
1
- import { n as escapeRegex } from "./string-utils-5EMAWj3q.mjs";
2
- import { t as toRealPath } from "./path-utils-BlOXGcCF.mjs";
3
- import { t as isSelectorContext } from "./selector-context-heuristic-Dualf7ac.mjs";
1
+ import { r as escapeRegex } from "./string-utils-Bq7DbB2x.mjs";
2
+ import { n as toRealPath } from "./path-utils-GG-vEb5-.mjs";
3
+ import { t as isSelectorContext } from "./selector-context-heuristic-DE3JAmpc.mjs";
4
4
  import { readFileSync } from "node:fs";
5
5
  //#region src/internal/bridge-consumer-patcher.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { n as escapeRegex } from "./string-utils-5EMAWj3q.mjs";
2
- import { t as toRealPath } from "./path-utils-BlOXGcCF.mjs";
1
+ import { r as escapeRegex } from "./string-utils-Bq7DbB2x.mjs";
2
+ import { n as toRealPath } from "./path-utils-GG-vEb5-.mjs";
3
3
  import { readFileSync } from "node:fs";
4
4
  //#region src/internal/forwarded-as-consumer-patcher.ts
5
5
  /**
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-xD1SimCA.mjs";
1
+ import { a as ImportSource, i as AdapterInput, o as MarkerFileContext, s as defineAdapter, t as CollectedWarning } from "./logger-BoGU2nCP.mjs";
2
2
 
3
3
  //#region src/run.d.ts
4
4
  interface RunTransformOptions {
@@ -64,6 +64,18 @@ interface RunTransformOptions {
64
64
  * @default false
65
65
  */
66
66
  silent?: boolean;
67
+ /**
68
+ * When true, allow the codemod to leave individual styled declarations as-is when
69
+ * they hit an unsupported pattern while transforming the rest of the file. This
70
+ * enables incremental migration: a file with one unconvertible component still
71
+ * produces useful output for the others.
72
+ *
73
+ * When false (default), any per-decl bail escalates to a whole-file bail — the
74
+ * safer/stricter behavior matching the pre-partial-migration semantics.
75
+ *
76
+ * @default false
77
+ */
78
+ allowPartialMigration?: boolean;
67
79
  }
68
80
  interface RunTransformResult {
69
81
  /** Number of files that had errors */
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { o as assertValidAdapterInput, r as defineAdapter, s as describeValue, t as mergeMarkerDeclarations } from "./merge-markers-B58_cRdA.mjs";
2
- import { t as Logger } from "./logger-C2O81VeU.mjs";
1
+ import { o as assertValidAdapterInput, r as defineAdapter, s as describeValue, t as mergeMarkerDeclarations } from "./merge-markers-Bp-ELxFV.mjs";
2
+ import { t as Logger } from "./logger-fIHHMZYO.mjs";
3
3
  import { run } from "jscodeshift/src/Runner.js";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { dirname, join, resolve } from "node:path";
@@ -141,9 +141,9 @@ async function runTransform(options) {
141
141
  `Pattern(s): ${consumerPatterns.join(", ")}`,
142
142
  "Check that the glob pattern is correct and files exist."
143
143
  ].join("\n"));
144
- const { createModuleResolver } = await import("./resolve-imports-DKohVjNI.mjs");
144
+ const { createModuleResolver } = await import("./resolve-imports-BlxKezSJ.mjs").then((n) => n.n);
145
145
  const sharedResolver = createModuleResolver();
146
- const { runPrepass } = await import("./run-prepass-4gxoyZ8y.mjs");
146
+ const { runPrepass } = await import("./run-prepass-DUxB6hxo.mjs");
147
147
  const absoluteFiles = filePaths.map((f) => resolve(f));
148
148
  const absoluteConsumers = consumerFilePaths.map((f) => resolve(f));
149
149
  let prepassResult;
@@ -205,6 +205,7 @@ async function runTransform(options) {
205
205
  resolveSelector: resolveSelectorWithLogging,
206
206
  resolveBaseComponent: adapterInput.resolveBaseComponent ? resolveBaseComponentWithLogging : void 0,
207
207
  resolveThemeCall: resolvedAdapter.resolveThemeCall,
208
+ wrappedComponentInterface: resolvedAdapter.wrappedComponentInterface,
208
209
  markerFile: resolvedAdapter.markerFile
209
210
  };
210
211
  const transformPath = (() => {
@@ -233,12 +234,13 @@ async function runTransform(options) {
233
234
  bridgeResults,
234
235
  transformedFiles,
235
236
  transientPropRenames,
237
+ allowPartialMigration: options.allowPartialMigration ?? false,
236
238
  runInBand: true,
237
239
  silent: options.silent ?? false
238
240
  });
239
241
  if (sidecarFiles.size > 0 && !dryRun) for (const [sidecarPath, content] of sidecarFiles) await writeFile(sidecarPath, mergeSidecarContent(sidecarPath, content), "utf-8");
240
242
  if (bridgeResults.size > 0 && !dryRun) {
241
- const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-BbjyGr2R.mjs");
243
+ const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-DbMPzKPE.mjs");
242
244
  const consumerReplacements = buildConsumerReplacements(crossFilePrepassResult.selectorUsages, bridgeResults, transformedFiles);
243
245
  const patchedFiles = [];
244
246
  for (const [consumerPath, replacements] of consumerReplacements) {
@@ -251,7 +253,7 @@ async function runTransform(options) {
251
253
  if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
252
254
  }
253
255
  if (prepassResult.forwardedAsConsumers.size > 0 && !dryRun) {
254
- const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-Rd7QcRNR.mjs");
256
+ const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-CXfXrvkk.mjs");
255
257
  const forwardedAsReplacements = buildForwardedAsReplacements(prepassResult.forwardedAsConsumers, transformedFiles);
256
258
  const patchedFiles = [];
257
259
  for (const [consumerPath, entries] of forwardedAsReplacements) {
@@ -264,7 +266,7 @@ async function runTransform(options) {
264
266
  if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
265
267
  }
266
268
  if (transientPropRenames.size > 0 && !dryRun) {
267
- const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-CeMJEJG9.mjs");
269
+ const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-C5KQ2iFe.mjs");
268
270
  const patches = collectTransientPropPatches({
269
271
  transientPropRenames,
270
272
  consumerFilePaths: consumerFilePaths.map((p) => resolve(p)),
@@ -25,6 +25,13 @@ type ThemeResolveContext = {
25
25
  * Example: "padding", "margin", "border"
26
26
  */
27
27
  cssProperty?: string;
28
+ /**
29
+ * When true, this resolution is for an indexed (bracket) lookup like
30
+ * `props.theme.color[props.$bg]`. The adapter can use this to return a
31
+ * CSS-property-aware prebuilt mixin map (`usage: "props"`) instead of a
32
+ * raw token object used in `stylex.create()`.
33
+ */
34
+ indexedLookup?: boolean;
28
35
  };
29
36
  type CssVariableResolveContext = {
30
37
  kind: "cssVariable";
@@ -200,12 +207,22 @@ type ResolveValueResult = {
200
207
  /**
201
208
  * Disambiguates how the resolved expression is used:
202
209
  * - "props": a StyleX style object suitable for passing to `stylex.props(...)`.
203
- * Use this when resolving imported styled component mixins to their StyleX equivalent.
210
+ * Use this when resolving imported styled component mixins to their StyleX equivalent,
211
+ * or for indexed theme lookups that resolve to prebuilt per-property mixin maps.
204
212
  * - undefined (default): a value that can be used inside `stylex.create(...)`.
205
213
  *
206
- * Note: Only meaningful for `{ kind: "importedValue" }`.
214
+ * Meaningful for `{ kind: "importedValue" }` and `{ kind: "theme" }` with `indexedLookup`.
207
215
  */
208
216
  usage?: "props";
217
+ /**
218
+ * When `usage` is `"props"` and the resolved expression should be indexed with a
219
+ * dynamic prop value (e.g., `$colorMixins.backgroundColor[propValue]`):
220
+ * - `"memberAccess"`: the codemod applies `expr[propValue]` computed member access
221
+ *
222
+ * Only meaningful when `usage` is `"props"` and the resolution context is an indexed
223
+ * theme lookup (`indexedLookup: true`).
224
+ */
225
+ dynamicArgUsage?: "memberAccess";
209
226
  };
210
227
  type CallResolveResultWithExpr = {
211
228
  /**
@@ -504,6 +521,41 @@ interface MarkerFileContext {
504
521
  /** Absolute path of the file being transformed */
505
522
  filePath: string;
506
523
  }
524
+ /**
525
+ * Context for `adapter.wrappedComponentInterface(...)`.
526
+ *
527
+ * Called for each `styled(Component)` declaration where `Component` is
528
+ * imported from another module. Lets the adapter declare that the wrapped
529
+ * component already accepts a StyleX `sx` prop so the codemod can emit
530
+ * `sx={style}` instead of `{...stylex.props(style)}`.
531
+ */
532
+ interface WrappedComponentInterfaceContext {
533
+ /**
534
+ * Import source for the wrapped base component.
535
+ * - package import: e.g. `"@company/ui"`
536
+ * - relative import: resolved absolute path
537
+ */
538
+ importSource: string;
539
+ /**
540
+ * Imported binding name for the wrapped base component.
541
+ * Example: `import { Button as UiButton } ...` -> importedName: "Button"
542
+ */
543
+ importedName: string;
544
+ /**
545
+ * Absolute path of the file currently being transformed.
546
+ */
547
+ filePath: string;
548
+ }
549
+ /**
550
+ * Result for `adapter.wrappedComponentInterface(...)`.
551
+ *
552
+ * - `acceptsSx: true` — the wrapped component accepts an `sx` prop. The codemod
553
+ * emits `sx={style}` instead of `{...stylex.props(style)}` and skips
554
+ * className/style merging in the wrapper (the wrapped component owns that).
555
+ */
556
+ interface WrappedComponentInterfaceResult {
557
+ acceptsSx: boolean;
558
+ }
507
559
  /**
508
560
  * Configuration for a custom style merger function that combines stylex.props()
509
561
  * results with external className/style props.
@@ -663,13 +715,40 @@ interface Adapter {
663
715
  * @default false
664
716
  */
665
717
  usePhysicalProperties?: boolean;
718
+ /**
719
+ * Optional override for sx-aware wrapped component detection.
720
+ *
721
+ * When `useSxProp: true`, the codemod auto-detects whether an imported
722
+ * component accepts a StyleX `sx` prop by reading its definition file and
723
+ * walking its declared prop type (intersections, type aliases, interfaces
724
+ * in the same file). When detected, `styled(Component)` emits
725
+ * `<Component sx={styles.x} />` instead of
726
+ * `<Component {...stylex.props(styles.x)} />`.
727
+ *
728
+ * Use this hook to override auto-detection for cases it cannot see — for
729
+ * example unresolvable package imports or components whose sx support is
730
+ * added by a HOC at runtime.
731
+ *
732
+ * Return:
733
+ * - `{ acceptsSx: true }` to force the `sx={...}` path
734
+ * - `{ acceptsSx: false }` to force the `{...stylex.props(...)}` path
735
+ * - `undefined` to fall through to auto-detection (default)
736
+ *
737
+ * Only consulted for `styled(ImportedComponent)` declarations.
738
+ */
739
+ wrappedComponentInterface?: (context: WrappedComponentInterfaceContext) => WrappedComponentInterfaceResult | undefined;
666
740
  /**
667
741
  * Optional function to customize where marker sidecar files (`stylex.defineMarker()`)
668
742
  * are written. By default, markers are placed in a `.stylex.ts` file next to the source.
669
743
  *
670
744
  * When provided, the function receives the source file path and returns an `ImportSource`
671
745
  * that determines both the import path in the transformed file and the file path where
672
- * markers are written.
746
+ * markers are written. Return `undefined` to fall back to the default behavior (local
747
+ * sidecar file next to the source).
748
+ *
749
+ * Only consulted when a file has cross-file marker relations. Files that only
750
+ * reference markers internally (e.g., sibling selectors within the same file)
751
+ * always use a local sidecar file regardless of this setting.
673
752
  *
674
753
  * Example:
675
754
  * ```typescript
@@ -678,7 +757,7 @@ interface Adapter {
678
757
  * }
679
758
  * ```
680
759
  */
681
- markerFile?: (context: MarkerFileContext) => ImportSource;
760
+ markerFile?: (context: MarkerFileContext) => ImportSource | undefined;
682
761
  }
683
762
  /**
684
763
  * User-facing adapter input type accepted by `defineAdapter()`.
@@ -706,6 +785,7 @@ interface AdapterInput {
706
785
  themeHook?: Adapter["themeHook"];
707
786
  useSxProp: Adapter["useSxProp"];
708
787
  usePhysicalProperties?: Adapter["usePhysicalProperties"];
788
+ wrappedComponentInterface?: Adapter["wrappedComponentInterface"];
709
789
  markerFile?: Adapter["markerFile"];
710
790
  }
711
791
  /**
@@ -784,7 +864,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
784
864
  //#endregion
785
865
  //#region src/internal/logger.d.ts
786
866
  type Severity = "info" | "warning" | "error";
787
- 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 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 resolveCall 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" | "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: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. 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: 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" | "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 shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "Unsupported interpolation: member expression" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | "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: descendant/child/sibling selector" | "Unsupported selector: interpolated pseudo selector" | "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 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 selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component 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" | "styled(ImportedComponent) wraps a component whose file contains internal styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "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";
867
+ 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 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 resolveCall 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" | "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: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. 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: 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" | "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 shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "Unsupported interpolation: member expression" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | "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: interpolated pseudo selector" | "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 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 selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component 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" | "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" | "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";
788
868
  interface WarningLog {
789
869
  severity: Severity;
790
870
  type: WarningType;
@@ -141,6 +141,15 @@ function assertAdapterShape(candidate, where, allowAutoExtIf) {
141
141
  "Expected signature:",
142
142
  " markerFile(ctx: { filePath: string }) => { kind: \"specifier\" | \"absolutePath\", value: string }"
143
143
  ].join("\n"));
144
+ const wrappedComponentInterface = obj?.wrappedComponentInterface;
145
+ if (wrappedComponentInterface !== void 0 && wrappedComponentInterface !== null && typeof wrappedComponentInterface !== "function") throw new Error([
146
+ `${where}: adapter.wrappedComponentInterface must be a function when provided.`,
147
+ `Received: wrappedComponentInterface=${describeValue(wrappedComponentInterface)}`,
148
+ "",
149
+ "Expected signature:",
150
+ " wrappedComponentInterface(ctx: { importSource: string; importedName: string; filePath: string })",
151
+ " => { acceptsSx: boolean } | undefined"
152
+ ].join("\n"));
144
153
  const themeHook = obj?.themeHook;
145
154
  if (themeHook !== null && themeHook !== void 0) {
146
155
  if (typeof themeHook !== "object") throw new Error([
@@ -0,0 +1,30 @@
1
+ import { resolve } from "node:path";
2
+ import { realpathSync } from "node:fs";
3
+ //#region src/internal/utilities/path-utils.ts
4
+ /**
5
+ * Shared path utilities for symlink resolution and path normalization.
6
+ */
7
+ /**
8
+ * Resolve a file path to its real (symlink-resolved) absolute path.
9
+ * Falls back to pathResolve if realpathSync fails (e.g. file doesn't exist yet).
10
+ */
11
+ function toRealPath(filePath) {
12
+ const resolved = resolve(filePath);
13
+ try {
14
+ return realpathSync(resolved);
15
+ } catch {
16
+ return resolved;
17
+ }
18
+ }
19
+ /**
20
+ * Returns `true` for ESM/CJS module specifiers that should be resolved
21
+ * relative to the importing file (e.g. `./foo`, `../bar`, `.`, `..`). Bare
22
+ * specifiers like `react` or `@scope/pkg` return `false`. Backslash-prefixed
23
+ * forms are accepted to match how authoring tools sometimes emit Windows
24
+ * paths into source.
25
+ */
26
+ function isRelativeSpecifier(specifier) {
27
+ return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith(".\\") || specifier.startsWith("..\\");
28
+ }
29
+ //#endregion
30
+ export { toRealPath as n, isRelativeSpecifier as t };
@@ -1,4 +1,16 @@
1
1
  import { ResolverFactory } from "oxc-resolver";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ //#endregion
2
14
  //#region src/internal/prepass/resolve-imports.ts
3
15
  /**
4
16
  * Module resolution using oxc-resolver.
@@ -10,6 +22,7 @@ import { ResolverFactory } from "oxc-resolver";
10
22
  * - Package exports field
11
23
  * - Symlink resolution (pnpm/Yarn workspaces)
12
24
  */
25
+ var resolve_imports_exports = /* @__PURE__ */ __exportAll({ createModuleResolver: () => createModuleResolver });
13
26
  /**
14
27
  * Shared resolver config for TypeScript projects.
15
28
  *
@@ -61,4 +74,4 @@ function createModuleResolver(config = DEFAULT_CONFIG) {
61
74
  } };
62
75
  }
63
76
  //#endregion
64
- export { createModuleResolver };
77
+ export { resolve_imports_exports as n, createModuleResolver as t };
@@ -1,7 +1,7 @@
1
- import { t as Logger } from "./logger-C2O81VeU.mjs";
2
- import { n as escapeRegex } from "./string-utils-5EMAWj3q.mjs";
3
- import { t as PLACEHOLDER_RE } from "./styled-css-C3QKH6Od.mjs";
4
- import { t as isSelectorContext } from "./selector-context-heuristic-Dualf7ac.mjs";
1
+ import { t as Logger } from "./logger-fIHHMZYO.mjs";
2
+ import { r as escapeRegex } from "./string-utils-Bq7DbB2x.mjs";
3
+ import { t as PLACEHOLDER_RE } from "./styled-css-Bu2bjAUW.mjs";
4
+ import { t as isSelectorContext } from "./selector-context-heuristic-DE3JAmpc.mjs";
5
5
  import path, { relative, resolve } from "node:path";
6
6
  import { readFileSync, realpathSync } from "node:fs";
7
7
  import { execSync } from "node:child_process";
@@ -665,12 +665,14 @@ async function runPrepass(options) {
665
665
  {
666
666
  const seen = /* @__PURE__ */ new Set();
667
667
  for (const { file, name } of styledCallUsages) {
668
- const importInfo = findImportSource(cachedRead(file), name);
669
- if (!importInfo) continue;
670
- const { source: importSource, exportedName } = importInfo;
671
- let defFile = resolve$1(importSource, file);
672
- if (!defFile) continue;
673
- defFile = resolveBarrelReExport(defFile, exportedName, resolve$1, cachedRead) ?? defFile;
668
+ const def = resolveDefinitionFile({
669
+ file,
670
+ localName: name,
671
+ cachedRead,
672
+ resolve: resolve$1
673
+ });
674
+ if (!def) continue;
675
+ const { defFile, exportedName } = def;
674
676
  const key = `${defFile}:${exportedName}`;
675
677
  if (seen.has(key)) continue;
676
678
  seen.add(key);
@@ -689,12 +691,14 @@ async function runPrepass(options) {
689
691
  const forwardedAsConsumers = /* @__PURE__ */ new Map();
690
692
  if (createExternalInterface && styledWrapperUsages.length > 0) for (const { file, localStyledName, wrappedName } of styledWrapperUsages) {
691
693
  if (transformSet.has(file)) continue;
692
- const importInfo = findImportSource(cachedRead(file), wrappedName);
693
- if (!importInfo) continue;
694
- const { source: importSource, exportedName } = importInfo;
695
- let defFile = resolve$1(importSource, file);
696
- if (!defFile) continue;
697
- defFile = resolveBarrelReExport(defFile, exportedName, resolve$1, cachedRead) ?? defFile;
694
+ const def = resolveDefinitionFile({
695
+ file,
696
+ localName: wrappedName,
697
+ cachedRead,
698
+ resolve: resolve$1
699
+ });
700
+ if (!def) continue;
701
+ const { defFile } = def;
698
702
  if (!transformSet.has(defFile)) continue;
699
703
  let entries = forwardedAsConsumers.get(file);
700
704
  if (!entries) {
@@ -1005,5 +1009,22 @@ function logPrepassDebug(scannedFiles, info, consumerAnalysis) {
1005
1009
  if (consumerAnalysis) lines.push(` Consumer analysis: ${consumerAnalysis.size} entries`);
1006
1010
  process.stderr.write(lines.join("\n") + "\n");
1007
1011
  }
1012
+ /**
1013
+ * Resolve a local identifier in `file` to the absolute path of the module that
1014
+ * defines it, following barrel re-exports. Returns `null` when the import
1015
+ * cannot be located on disk.
1016
+ */
1017
+ function resolveDefinitionFile(args) {
1018
+ const { file, localName, cachedRead, resolve } = args;
1019
+ const importInfo = findImportSource(cachedRead(file), localName);
1020
+ if (!importInfo) return null;
1021
+ const { source: importSource, exportedName } = importInfo;
1022
+ const initialDefFile = resolve(importSource, file);
1023
+ if (!initialDefFile) return null;
1024
+ return {
1025
+ defFile: resolveBarrelReExport(initialDefFile, exportedName, resolve, cachedRead) ?? initialDefFile,
1026
+ exportedName
1027
+ };
1028
+ }
1008
1029
  //#endregion
1009
1030
  export { runPrepass };
@@ -29,6 +29,18 @@ function kebabToCamelCase(s) {
29
29
  return s.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
30
30
  }
31
31
  /**
32
+ * Converts a camelCase string to kebab-case.
33
+ * Preserves CSS custom property prefixes (`--foo`). React uses leading uppercase
34
+ * to indicate vendor prefixes (e.g. `WebkitAppearance` → `-webkit-appearance`).
35
+ * @example camelToKebabCase("backgroundColor") => "background-color"
36
+ * @example camelToKebabCase("padding") => "padding"
37
+ * @example camelToKebabCase("WebkitAppearance") => "-webkit-appearance"
38
+ */
39
+ function camelToKebabCase(s) {
40
+ if (s.startsWith("--")) return s;
41
+ return s.replace(/([A-Z])/g, (_, ch) => `-${ch.toLowerCase()}`);
42
+ }
43
+ /**
32
44
  * Lowercases the first character of a string.
33
45
  * @example lowerFirst("Hello") => "hello"
34
46
  */
@@ -93,4 +105,4 @@ function normalizeWhitespace(s) {
93
105
  return s.replace(/\s+/g, " ").trim();
94
106
  }
95
107
  //#endregion
96
- export { isValidIdentifierName as a, lowerFirst as c, isPrettierIgnoreComment as i, normalizeWhitespace as l, escapeRegex as n, kebabToCamelCase as o, isBackgroundImageValue as r, looksLikeLength as s, capitalize as t, sanitizeIdentifier as u };
108
+ export { isPrettierIgnoreComment as a, looksLikeLength as c, sanitizeIdentifier as d, isBackgroundImageValue as i, lowerFirst as l, capitalize as n, isValidIdentifierName as o, escapeRegex as r, kebabToCamelCase as s, camelToKebabCase as t, normalizeWhitespace as u };
@@ -1,17 +1,22 @@
1
- import { n as WarningLog, r as Adapter } from "./logger-xD1SimCA.mjs";
1
+ import { n as WarningLog, r as Adapter } from "./logger-BoGU2nCP.mjs";
2
2
  import { API, FileInfo, Options } from "jscodeshift";
3
3
 
4
4
  //#region src/internal/transform-types.d.ts
5
+ /** A sidecar .stylex.ts file containing defineMarker() declarations. */
6
+ interface SidecarFile {
7
+ content: string;
8
+ /** Absolute file path for writing. Undefined = default local sidecar next to the source file. */
9
+ filePath?: string;
10
+ }
5
11
  /**
6
12
  * Result of the transform including any log entries
7
13
  */
8
14
  interface TransformResult {
9
15
  code: string | null;
10
16
  warnings: WarningLog[];
11
- /** Content for the sidecar .stylex.ts file (defineMarker declarations). Undefined when no markers needed. */
12
- sidecarContent?: string;
13
- /** Absolute file path for the sidecar file, when adapter.markerFile provides a custom location. */
14
- sidecarFilePath?: string;
17
+ /** Sidecar .stylex.ts files (defineMarker declarations). Multiple entries when a file has
18
+ * both cross-file markers (adapter.markerFile) and internal markers (local sidecar). */
19
+ sidecarFiles?: SidecarFile[];
15
20
  /** Bridge components emitted for unconverted consumer selectors. */
16
21
  bridgeResults?: BridgeComponentResult[];
17
22
  /** Transient prop renames for exported components, keyed by export name. */
@@ -44,6 +49,12 @@ interface TransformOptions extends Options {
44
49
  * When present, enables cross-file component selector handling.
45
50
  */
46
51
  crossFileInfo?: CrossFileInfo;
52
+ /**
53
+ * When true, individual declarations that hit an unsupported pattern are left
54
+ * as-is while the rest of the file is transformed. When false (default), any
55
+ * per-decl bail escalates to a whole-file bail.
56
+ */
57
+ allowPartialMigration?: boolean;
47
58
  }
48
59
  /**
49
60
  * Cross-file selector info passed from the prepass to the per-file transform.