styled-components-to-stylex-codemod 0.0.21 → 0.0.23

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
@@ -34,6 +34,8 @@ const adapter = defineAdapter({
34
34
  },
35
35
  // Optional: use a helper for merging StyleX styles with external className/style
36
36
  styleMerger: null,
37
+ // Emit sx={} JSX attributes instead of {...stylex.props()} spreads (requires StyleX ≥0.18)
38
+ useSxProp: false,
37
39
  // Optional: customize the runtime theme hook import/call used for theme conditionals
38
40
  // Defaults to { functionName: "useTheme", importSource: { kind: "specifier", value: "styled-components" } }
39
41
  themeHook: {
@@ -164,6 +166,12 @@ const adapter = defineAdapter({
164
166
  importSource: { kind: "specifier", value: "./lib/mergedSx" },
165
167
  },
166
168
 
169
+ /**
170
+ * Emit sx={} JSX attributes instead of {...stylex.props()} spreads.
171
+ * Requires @stylexjs/babel-plugin ≥0.18 with sxPropName enabled.
172
+ */
173
+ useSxProp: false,
174
+
167
175
  /**
168
176
  * Optional: customize the runtime theme hook used when wrappers need theme booleans.
169
177
  * Defaults to useTheme from styled-components.
@@ -1,4 +1,4 @@
1
- import { n as escapeRegex } from "./string-utils-Dmym5IkG.mjs";
1
+ import { n as escapeRegex } from "./string-utils-J3iaDsXd.mjs";
2
2
  import { resolve } from "node:path";
3
3
  import { readFileSync, realpathSync } from "node:fs";
4
4
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineAdapter, i as AdapterInput, t as CollectedWarning } from "./logger-tKRY0yOA.mjs";
1
+ import { a as defineAdapter, i as AdapterInput, t as CollectedWarning } from "./logger-Cml101qs.mjs";
2
2
 
3
3
  //#region src/run.d.ts
4
4
  interface RunTransformOptions {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as assertValidAdapterInput, o as describeValue, r as defineAdapter, t as Logger } from "./logger-Bi5-MGBs.mjs";
1
+ import { a as assertValidAdapterInput, o as describeValue, r as defineAdapter, t as Logger } from "./logger-StI3W9gi.mjs";
2
2
  import { run } from "jscodeshift/src/Runner.js";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { dirname, join, resolve } from "node:path";
@@ -143,7 +143,7 @@ async function runTransform(options) {
143
143
  ].join("\n"));
144
144
  const { createModuleResolver } = await import("./resolve-imports-4bFqrkrQ.mjs");
145
145
  const sharedResolver = createModuleResolver();
146
- const { runPrepass } = await import("./run-prepass-BuYfEK4M.mjs");
146
+ const { runPrepass } = await import("./run-prepass-DV-4A_Ci.mjs");
147
147
  const absoluteFiles = filePaths.map((f) => resolve(f));
148
148
  const absoluteConsumers = consumerFilePaths.map((f) => resolve(f));
149
149
  let prepassResult;
@@ -195,6 +195,7 @@ async function runTransform(options) {
195
195
  const adapterWithLogging = {
196
196
  styleMerger: resolvedAdapter.styleMerger,
197
197
  themeHook: resolvedAdapter.themeHook,
198
+ useSxProp: resolvedAdapter.useSxProp,
198
199
  externalInterface(ctx) {
199
200
  return resolvedAdapter.externalInterface(ctx);
200
201
  },
@@ -218,6 +219,7 @@ async function runTransform(options) {
218
219
  const sidecarFiles = /* @__PURE__ */ new Map();
219
220
  const bridgeResults = /* @__PURE__ */ new Map();
220
221
  const transformedFiles = /* @__PURE__ */ new Set();
222
+ const transientPropRenames = /* @__PURE__ */ new Map();
221
223
  const result = await run(transformPath, filePaths, {
222
224
  parser,
223
225
  dry: dryRun,
@@ -227,6 +229,7 @@ async function runTransform(options) {
227
229
  sidecarFiles,
228
230
  bridgeResults,
229
231
  transformedFiles,
232
+ transientPropRenames,
230
233
  runInBand: true
231
234
  });
232
235
  if (sidecarFiles.size > 0 && !dryRun) for (const [sidecarPath, content] of sidecarFiles) await writeFile(sidecarPath, mergeSidecarContent(sidecarPath, content), "utf-8");
@@ -244,7 +247,7 @@ async function runTransform(options) {
244
247
  if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
245
248
  }
246
249
  if (prepassResult.forwardedAsConsumers.size > 0 && !dryRun) {
247
- const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-GPnjkzc_.mjs");
250
+ const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-CIOAJ-51.mjs");
248
251
  const forwardedAsReplacements = buildForwardedAsReplacements(prepassResult.forwardedAsConsumers, transformedFiles);
249
252
  const patchedFiles = [];
250
253
  for (const [consumerPath, entries] of forwardedAsReplacements) {
@@ -256,6 +259,20 @@ async function runTransform(options) {
256
259
  }
257
260
  if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
258
261
  }
262
+ if (transientPropRenames.size > 0 && !dryRun) {
263
+ const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-iofVVX40.mjs");
264
+ const patches = collectTransientPropPatches({
265
+ transientPropRenames,
266
+ consumerFilePaths: consumerFilePaths.map((p) => resolve(p)),
267
+ resolver: sharedResolver
268
+ });
269
+ const patchedFiles = [];
270
+ for (const { consumerPath, patched } of patches) {
271
+ await writeFile(consumerPath, patched, "utf-8");
272
+ patchedFiles.push(consumerPath);
273
+ }
274
+ if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
275
+ }
259
276
  if (formatterCommands && formatterCommands.length > 0 && result.ok > 0 && !dryRun) await runFormatters(formatterCommands, filePaths);
260
277
  const report = Logger.createReport();
261
278
  report.print();
@@ -378,6 +378,25 @@ type SelectorResolveResult = {
378
378
  * Import statements required by `styleSelectorExpr`.
379
379
  */
380
380
  imports: ImportSpec[];
381
+ } | {
382
+ kind: "pseudoExpand";
383
+ /**
384
+ * List of pseudo-classes to expand into a single merged style object.
385
+ * Each pseudo can optionally be wrapped in a condition (e.g., a `defineConsts` media query).
386
+ *
387
+ * Example: `[{ pseudo: "active" }, { pseudo: "hover", condition: { expr: "$interaction.canHover", imports: [...] } }]`
388
+ */
389
+ expansions: Array<{
390
+ /** Pseudo-class name without leading colon (e.g., "active", "hover") */pseudo: string; /** Optional condition wrapping this pseudo entry (e.g., a defineConsts key) */
391
+ condition?: {
392
+ /** JS expression string (e.g., "$interaction.canHover") */expr: string; /** Imports required by the condition expression */
393
+ imports: ImportSpec[];
394
+ };
395
+ }>;
396
+ /**
397
+ * Shared imports for the overall expansion (not per-condition).
398
+ */
399
+ imports: ImportSpec[];
381
400
  };
382
401
  interface ExternalInterfaceContext {
383
402
  /** Absolute path of the file being transformed */
@@ -527,6 +546,18 @@ interface Adapter {
527
546
  * `{ functionName: "useTheme", importSource: { kind: "specifier", value: "styled-components" } }`
528
547
  */
529
548
  themeHook?: ThemeHookConfig;
549
+ /**
550
+ * Emit `sx={...}` JSX attributes instead of `{...stylex.props(...)}` spreads
551
+ * on intrinsic elements. Requires `@stylexjs/babel-plugin` ≥0.18 with the
552
+ * `sxPropName` option (defaults to `"sx"`).
553
+ *
554
+ * When enabled, the codemod produces shorter output:
555
+ * `<div sx={styles.base} />` instead of `<div {...stylex.props(styles.base)} />`
556
+ *
557
+ * Only applies to simple cases without className/style merging.
558
+ *
559
+ */
560
+ useSxProp: boolean;
530
561
  }
531
562
  /**
532
563
  * User-facing adapter input type accepted by `defineAdapter()`.
@@ -551,6 +582,7 @@ interface AdapterInput {
551
582
  externalInterface: "auto" | Adapter["externalInterface"];
552
583
  styleMerger: Adapter["styleMerger"];
553
584
  themeHook?: Adapter["themeHook"];
585
+ useSxProp: Adapter["useSxProp"];
554
586
  }
555
587
  /**
556
588
  * Helper for nicer user authoring + type inference.
@@ -602,6 +634,9 @@ interface AdapterInput {
602
634
  * // Optional: provide a custom merger, or use `null` for the default verbose merge output
603
635
  * styleMerger: null,
604
636
  *
637
+ * // Emit sx={} JSX attributes instead of {...stylex.props()} spreads (requires StyleX ≥0.18)
638
+ * useSxProp: false,
639
+ *
605
640
  * // Optional: customize runtime theme hook import/call used by emitted wrappers
606
641
  * themeHook: {
607
642
  * functionName: "useTheme",
@@ -613,7 +648,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
613
648
  //#endregion
614
649
  //#region src/internal/logger.d.ts
615
650
  type Severity = "info" | "warning" | "error";
616
- 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 contains unresolvable interpolation" | "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" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Dynamic styles inside pseudo elements (::before/::after) are not supported by StyleX. See https://github.com/facebook/stylex/issues/1396" | "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 contains unresolvable interpolation" | "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: 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: grouped reverse selector references different components" | "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" | "Sibling selector broadened: & + & (adjacent) becomes general sibling (~) in StyleX — interleaved non-matching elements will no longer block the match" | "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";
651
+ 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" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Dynamic styles inside pseudo elements (::before/::after) are not supported by StyleX. See https://github.com/facebook/stylex/issues/1396" | "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: 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: grouped reverse selector references different components" | "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" | "Sibling selector broadened: & + & (adjacent) becomes general sibling (~) in StyleX — interleaved non-matching elements will no longer block the match" | "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";
617
652
  interface WarningLog {
618
653
  severity: Severity;
619
654
  type: WarningType;
@@ -91,7 +91,7 @@ function assertAdapterShape(candidate, where, allowAutoExtIf) {
91
91
  "",
92
92
  "Adapter shape:",
93
93
  " {",
94
- " resolveSelector(context) { return { kind: \"media\" | \"pseudoAlias\", ... } | undefined }",
94
+ " resolveSelector(context) { return { kind: \"media\" | \"pseudoAlias\" | \"pseudoExpand\", ... } | undefined }",
95
95
  " }",
96
96
  "",
97
97
  `Docs/examples: ${ADAPTER_DOCS_URL}`
@@ -239,6 +239,9 @@ const DEFAULT_THEME_HOOK = {
239
239
  * // Optional: provide a custom merger, or use `null` for the default verbose merge output
240
240
  * styleMerger: null,
241
241
  *
242
+ * // Emit sx={} JSX attributes instead of {...stylex.props()} spreads (requires StyleX ≥0.18)
243
+ * useSxProp: false,
244
+ *
242
245
  * // Optional: customize runtime theme hook import/call used by emitted wrappers
243
246
  * themeHook: {
244
247
  * functionName: "useTheme",
@@ -1,4 +1,4 @@
1
- import { t as PLACEHOLDER_RE } from "./styled-css-DBryFqQM.mjs";
1
+ import { t as PLACEHOLDER_RE } from "./styled-css-BJH7gntu.mjs";
2
2
  import { t as isSelectorContext } from "./selector-context-heuristic-Cki9_tTH.mjs";
3
3
  import path, { relative, resolve } from "node:path";
4
4
  import { readFileSync, realpathSync } from "node:fs";
@@ -575,13 +575,20 @@ async function runPrepass(options) {
575
575
  wrappedName: m[2]
576
576
  });
577
577
  }
578
- if (hasAsProp) {
579
- JSX_AS_COMPONENT_RE.lastIndex = 0;
580
- for (const m of source.matchAll(JSX_AS_COMPONENT_RE)) if (m[1]) addToSetMap(asUsages, m[1], filePath);
581
- }
582
- if (hasRefProp) {
583
- JSX_REF_COMPONENT_RE.lastIndex = 0;
584
- for (const m of source.matchAll(JSX_REF_COMPONENT_RE)) if (m[1]) addToSetMap(refUsages, m[1], filePath);
578
+ if (hasAsProp || hasRefProp) {
579
+ let aliasMap;
580
+ const resolveTagName = (tagName) => {
581
+ aliasMap ??= buildLocalToImportedMap(source);
582
+ return aliasMap.get(tagName) ?? tagName;
583
+ };
584
+ if (hasAsProp) {
585
+ JSX_AS_COMPONENT_RE.lastIndex = 0;
586
+ for (const m of source.matchAll(JSX_AS_COMPONENT_RE)) if (m[1]) addToSetMap(asUsages, resolveTagName(m[1]), filePath);
587
+ }
588
+ if (hasRefProp) {
589
+ JSX_REF_COMPONENT_RE.lastIndex = 0;
590
+ for (const m of source.matchAll(JSX_REF_COMPONENT_RE)) if (m[1]) addToSetMap(refUsages, resolveTagName(m[1]), filePath);
591
+ }
585
592
  }
586
593
  }
587
594
  const styledFileCount = fileContents.size;
@@ -746,11 +753,14 @@ const IMPORT_ALIAS_ENTRY_RE = /\b(\w+)\s+as\s+(\w+)/g;
746
753
  /**
747
754
  * Build a mapping from local alias names to original imported names for a source file.
748
755
  * Only includes PascalCase names that differ from their original (actual aliases).
756
+ * Scans only import declarations to avoid false positives from TypeScript `as` casts
757
+ * (e.g., `foo as Button` would incorrectly map `Button → foo`).
749
758
  */
750
759
  function buildLocalToImportedMap(source) {
760
+ const importText = collectImportDeclarationText(source);
751
761
  const map = /* @__PURE__ */ new Map();
752
762
  IMPORT_ALIAS_ENTRY_RE.lastIndex = 0;
753
- for (const m of source.matchAll(IMPORT_ALIAS_ENTRY_RE)) {
763
+ for (const m of importText.matchAll(IMPORT_ALIAS_ENTRY_RE)) {
754
764
  const original = m[1];
755
765
  const local = m[2];
756
766
  if (original !== local && /^[A-Z]/.test(local)) map.set(local, original);
@@ -42,6 +42,7 @@ function sanitizeIdentifier(s) {
42
42
  * @example looksLikeLength("auto") => false
43
43
  */
44
44
  function looksLikeLength(token) {
45
+ if (token === "thin" || token === "medium" || token === "thick") return true;
45
46
  return /^-?\d*\.?\d+(px|rem|em|vh|vw|vmin|vmax|ch|ex|lh|svh|svw|dvh|dvw|cqw|cqh|%)?$/.test(token);
46
47
  }
47
48
  /**
@@ -62,6 +63,13 @@ function escapeRegex(s) {
62
63
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
63
64
  }
64
65
  /**
66
+ * Returns true if a comment body (without delimiters) is a prettier-ignore directive.
67
+ * These are formatting tool directives that should not be transferred to the output.
68
+ */
69
+ function isPrettierIgnoreComment(body) {
70
+ return /^\s*prettier-ignore\s*$/.test(body);
71
+ }
72
+ /**
65
73
  * Normalizes whitespace in a CSS value string.
66
74
  * Collapses all sequences of whitespace (including newlines) to single spaces
67
75
  * and trims leading/trailing whitespace.
@@ -77,4 +85,4 @@ function normalizeWhitespace(s) {
77
85
  }
78
86
 
79
87
  //#endregion
80
- export { looksLikeLength as a, sanitizeIdentifier as c, kebabToCamelCase as i, escapeRegex as n, lowerFirst as o, isBackgroundImageValue as r, normalizeWhitespace as s, capitalize as t };
88
+ export { kebabToCamelCase as a, normalizeWhitespace as c, isPrettierIgnoreComment as i, sanitizeIdentifier as l, escapeRegex as n, looksLikeLength as o, isBackgroundImageValue as r, lowerFirst as s, capitalize as t };
@@ -1,4 +1,4 @@
1
- import { n as WarningLog, r as Adapter } from "./logger-tKRY0yOA.mjs";
1
+ import { n as WarningLog, r as Adapter } from "./logger-Cml101qs.mjs";
2
2
  import "stylis";
3
3
  import { API, FileInfo, Options } from "jscodeshift";
4
4
 
@@ -13,6 +13,13 @@ interface TransformResult {
13
13
  sidecarContent?: string;
14
14
  /** Bridge components emitted for unconverted consumer selectors. */
15
15
  bridgeResults?: BridgeComponentResult[];
16
+ /** Transient prop renames for exported components, keyed by export name. */
17
+ transientPropRenames?: TransientPropRenameResult[];
18
+ }
19
+ /** Describes a transient prop rename on an exported component for consumer patching. */
20
+ interface TransientPropRenameResult {
21
+ exportName: string;
22
+ renames: Record<string, string>;
16
23
  }
17
24
  /** Describes a bridge className emitted for a component targeted by unconverted consumer selectors. */
18
25
  interface BridgeComponentResult {