styled-components-to-stylex-codemod 0.0.45 → 0.0.46

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 CollectedWarning, c as MarkerFileContext, l as defineAdapter, n as TransformMode, o as AdapterInput, s as ImportSource } from "./transform-types-CQjiY4Yp.mjs";
1
+ import { a as CollectedWarning, c as MarkerFileContext, l as defineAdapter, n as TransformMode, o as AdapterInput, s as ImportSource } from "./transform-types-_s0eXWNM.mjs";
2
2
 
3
3
  //#region src/run.d.ts
4
4
  interface RunTransformOptions {
package/dist/index.mjs CHANGED
@@ -149,7 +149,7 @@ async function runTransform(options) {
149
149
  const { createModuleResolver } = await import("./resolve-imports-DgSAddIF.mjs").then((n) => n.n);
150
150
  const sharedResolver = createModuleResolver();
151
151
  filePaths = orderFilesByLocalImportDependencies(filePaths, sharedResolver, toRealPath);
152
- const { runPrepass } = await import("./run-prepass-COJ2IOPl.mjs");
152
+ const { runPrepass } = await import("./run-prepass-u7NeybrS.mjs");
153
153
  const absoluteFiles = filePaths.map((f) => resolve(f));
154
154
  const absoluteConsumers = consumerFilePaths.map((f) => resolve(f));
155
155
  let prepassResult;
@@ -252,7 +252,11 @@ async function runTransform(options) {
252
252
  const autoInterfaceNames = ctx.importedName === "default" ? [ctx.localName, ctx.importedName] : [ctx.importedName];
253
253
  const styledDefinitionNames = getStyledDefinitionNames(definitionSourcePath);
254
254
  const sourceComponentNames = ctx.importedName === "default" ? [ctx.localName, getDefaultExportedName(definitionSourcePath)].filter((name) => typeof name === "string") : [ctx.importedName];
255
- if (findTypedComponentMetadata(prepassResult.typeScriptMetadata, definitionSourcePath, sourceComponentNames)?.supportsSxProp === true) return { acceptsSx: true };
255
+ const typedComponent = findTypedComponentMetadata(prepassResult.typeScriptMetadata, definitionSourcePath, sourceComponentNames);
256
+ if (typedComponent?.supportsSxProp === true) return {
257
+ acceptsSx: true,
258
+ sxExcludedProperties: typedComponent.sxExcludedProperties
259
+ };
256
260
  if (transformedComponentAcceptsSx({
257
261
  absolutePath: definitionSourcePath,
258
262
  componentNames: sourceComponentNames,
@@ -755,7 +755,7 @@ function isTypeScriptParser(parserName) {
755
755
  }
756
756
  async function loadTypeScriptAnalysis() {
757
757
  try {
758
- return await import("./typescript-analysis-UWX_ePX0.mjs");
758
+ return await import("./typescript-analysis-9qBUYSi7.mjs");
759
759
  } catch (err) {
760
760
  const message = err instanceof Error ? err.message : String(err);
761
761
  if (message.includes("typescript") && (message.includes("Cannot find") || message.includes("ERR_MODULE_NOT_FOUND"))) throw new Error(["TypeScript parser runs require the optional `typescript` package for compiler metadata.", "Install TypeScript in the project (supported range: >=5.0.0 <6), or use a non-TypeScript parser."].join("\n"));
@@ -377,7 +377,7 @@ interface ResolveBaseComponentContext {
377
377
  importSource: string;
378
378
  /**
379
379
  * Imported binding name for the wrapped base component.
380
- * Example: `import { Flex as OrbiterFlex } ...` -> importedName: "Flex"
380
+ * Example: `import { Flex as DesignSystemFlex } ...` -> importedName: "Flex"
381
381
  */
382
382
  importedName: string;
383
383
  /**
@@ -606,6 +606,14 @@ interface WrappedComponentInterfaceContext {
606
606
  */
607
607
  interface WrappedComponentInterfaceResult {
608
608
  acceptsSx: boolean;
609
+ /**
610
+ * CSS property names that the wrapped component's `sx` prop explicitly rejects.
611
+ *
612
+ * Some components accept `sx`, but narrow it with `StyleXStylesWithout<...>` to
613
+ * reserve properties that the component owns internally. The transform can still
614
+ * use `sx` if it rewrites generated styles away from those excluded properties.
615
+ */
616
+ sxExcludedProperties?: string[];
609
617
  }
610
618
  /**
611
619
  * Configuration for a custom style merger function that combines stylex.props()
@@ -921,7 +929,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
921
929
  //#endregion
922
930
  //#region src/internal/logger.d.ts
923
931
  type Severity = "info" | "warning" | "error";
924
- 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 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" | "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 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: 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 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" | "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";
932
+ 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 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" | "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 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: 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 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" | "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" | "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly" | "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";
925
933
  interface WarningLog {
926
934
  severity: Severity;
927
935
  type: WarningType;
@@ -958,6 +966,7 @@ interface TypeScriptComponentMetadata {
958
966
  restProps: TypeScriptRestPropMetadata[];
959
967
  hasIndexSignature: boolean;
960
968
  supportsSxProp: boolean;
969
+ sxExcludedProperties: string[];
961
970
  }
962
971
  interface TypeScriptFunctionMetadata {
963
972
  name: string;
@@ -1,4 +1,4 @@
1
- import { i as TransformResult, r as TransformOptions, t as BridgeComponentResult } from "./transform-types-CQjiY4Yp.mjs";
1
+ import { i as TransformResult, r as TransformOptions, t as BridgeComponentResult } from "./transform-types-_s0eXWNM.mjs";
2
2
  import { API, FileInfo, Options } from "jscodeshift";
3
3
 
4
4
  //#region src/transform.d.ts
@@ -30,6 +30,50 @@ const STYLEX_LONGHAND_ONLY_SHORTHANDS = new Set([
30
30
  "scroll-margin",
31
31
  "scroll-padding"
32
32
  ]);
33
+ /** Mapping from CSS shorthand to the longhands that conflict with it. */
34
+ const SHORTHAND_LONGHANDS = {
35
+ margin: {
36
+ physical: [
37
+ "marginTop",
38
+ "marginRight",
39
+ "marginBottom",
40
+ "marginLeft"
41
+ ],
42
+ logical: ["marginBlock", "marginInline"]
43
+ },
44
+ padding: {
45
+ physical: [
46
+ "paddingTop",
47
+ "paddingRight",
48
+ "paddingBottom",
49
+ "paddingLeft"
50
+ ],
51
+ logical: ["paddingBlock", "paddingInline"]
52
+ },
53
+ scrollMargin: {
54
+ physical: [
55
+ "scrollMarginTop",
56
+ "scrollMarginRight",
57
+ "scrollMarginBottom",
58
+ "scrollMarginLeft"
59
+ ],
60
+ logical: ["scrollMarginBlock", "scrollMarginInline"]
61
+ },
62
+ scrollPadding: {
63
+ physical: [
64
+ "scrollPaddingTop",
65
+ "scrollPaddingRight",
66
+ "scrollPaddingBottom",
67
+ "scrollPaddingLeft"
68
+ ],
69
+ logical: ["scrollPaddingBlock", "scrollPaddingInline"]
70
+ }
71
+ };
72
+ /**
73
+ * Mapping from logical longhands to their physical equivalents, derived from SHORTHAND_LONGHANDS.
74
+ * `marginBlock` -> `["marginTop", "marginBottom"]`
75
+ */
76
+ const LOGICAL_TO_PHYSICAL = Object.fromEntries(Object.values(SHORTHAND_LONGHANDS).flatMap(({ physical, logical }) => [[logical[0], [physical[0], physical[2]]], [logical[1], [physical[1], physical[3]]]]));
33
77
  function isStylexLonghandOnlyShorthand(prop) {
34
78
  return STYLEX_LONGHAND_ONLY_SHORTHANDS.has(prop);
35
79
  }
@@ -4498,6 +4542,40 @@ function buildChildStyleObjectList(childKeys, resolvedStyleObjects) {
4498
4542
  return childStyleObjects;
4499
4543
  }
4500
4544
  //#endregion
4545
+ //#region src/internal/utilities/wrapped-component-interface.ts
4546
+ function wrappedComponentInterfaceFor(ctx, componentLocalName) {
4547
+ if (!ctx.adapter.useSxProp) return;
4548
+ const importInfo = ctx.importMap?.get(componentLocalName);
4549
+ if (importInfo) {
4550
+ const typedInterface = importInfo.source.kind === "absolutePath" ? typedComponentInterfaceFor(ctx, importInfo.source.value, importInfo.importedName === "default" ? [componentLocalName, importInfo.importedName] : [importInfo.importedName]) : void 0;
4551
+ const adapterResult = ctx.adapter.wrappedComponentInterface?.({
4552
+ localName: componentLocalName,
4553
+ importSource: importInfo.source.value,
4554
+ importedName: importInfo.importedName,
4555
+ filePath: ctx.file.path
4556
+ });
4557
+ if (adapterResult !== void 0) {
4558
+ if (adapterResult.acceptsSx && typedInterface?.sxExcludedProperties?.length) return {
4559
+ ...adapterResult,
4560
+ sxExcludedProperties: mergeUniqueStrings(adapterResult.sxExcludedProperties, typedInterface.sxExcludedProperties)
4561
+ };
4562
+ return adapterResult;
4563
+ }
4564
+ return typedInterface;
4565
+ }
4566
+ return typedComponentInterfaceFor(ctx, ctx.file.path, [componentLocalName]);
4567
+ }
4568
+ function typedComponentInterfaceFor(ctx, filePath, componentNames) {
4569
+ const typedComponent = findTypeScriptComponentMetadata(ctx.options.crossFileInfo?.typeScriptMetadata, filePath, componentNames);
4570
+ if (typedComponent?.supportsSxProp) return {
4571
+ acceptsSx: true,
4572
+ sxExcludedProperties: typedComponent.sxExcludedProperties
4573
+ };
4574
+ }
4575
+ function mergeUniqueStrings(first, second) {
4576
+ return [...new Set([...first ?? [], ...second])];
4577
+ }
4578
+ //#endregion
4501
4579
  //#region src/internal/transform-steps/analyze-before-emit.ts
4502
4580
  const INLINE_USAGE_THRESHOLD = 1;
4503
4581
  /**
@@ -5069,6 +5147,10 @@ function analyzeBeforeEmitStep(ctx) {
5069
5147
  }
5070
5148
  else ctx.resolvedStyleObjects.set(entry.styleKey, entry.styleValue);
5071
5149
  }
5150
+ if (!validateSxRestrictedWrappedComponentStyles(ctx, styledDecls)) return returnResult({
5151
+ code: null,
5152
+ warnings: ctx.warnings
5153
+ }, "bail");
5072
5154
  const existingStylexTarget = findExistingStylexStylesTarget({
5073
5155
  ctx,
5074
5156
  styledDeclNames,
@@ -5682,6 +5764,7 @@ function renameStaticAttrKeys(attrs, renames) {
5682
5764
  */
5683
5765
  function collectAllStyleKeysForDecl(decl) {
5684
5766
  const keys = [decl.styleKey];
5767
+ if (decl.adjacentSiblingStyleKey) keys.push(decl.adjacentSiblingStyleKey);
5685
5768
  for (const key of Object.values(decl.variantStyleKeys ?? {})) keys.push(key);
5686
5769
  for (const sf of decl.styleFnFromProps ?? []) keys.push(sf.fnKey);
5687
5770
  for (const key of decl.extraStyleKeys ?? []) keys.push(key);
@@ -5692,7 +5775,21 @@ function collectAllStyleKeysForDecl(decl) {
5692
5775
  for (const c of decl.enumVariant.cases) keys.push(c.styleKey);
5693
5776
  }
5694
5777
  for (const sbv of decl.staticBooleanVariants ?? []) keys.push(sbv.styleKey);
5778
+ for (const cs of decl.callSiteCombinedStyles ?? []) keys.push(cs.styleKey);
5779
+ for (const ps of decl.promotedStyleProps ?? []) if (!ps.mergeIntoBase) keys.push(ps.styleKey);
5695
5780
  for (const pas of decl.pseudoAliasSelectors ?? []) keys.push(...pas.styleKeys);
5781
+ for (const pes of decl.pseudoExpandSelectors ?? []) keys.push(pes.styleKey);
5782
+ if (decl.attrWrapper) {
5783
+ const aw = decl.attrWrapper;
5784
+ for (const k of [
5785
+ aw.checkboxKey,
5786
+ aw.radioKey,
5787
+ aw.readonlyKey,
5788
+ aw.externalKey,
5789
+ aw.httpsKey,
5790
+ aw.pdfKey
5791
+ ]) if (k) keys.push(k);
5792
+ }
5696
5793
  return keys;
5697
5794
  }
5698
5795
  const AST_METADATA_KEYS = new Set([
@@ -6846,6 +6943,80 @@ function mergeAttrEntriesByAttrName(baseEntries, ownEntries) {
6846
6943
  for (const entry of ownEntries ?? []) byAttrName.set(entry.attrName, entry);
6847
6944
  return [...byAttrName.values()];
6848
6945
  }
6946
+ function validateSxRestrictedWrappedComponentStyles(ctx, styledDecls) {
6947
+ if (!ctx.adapter.useSxProp || !ctx.resolvedStyleObjects) return true;
6948
+ for (const decl of styledDecls) {
6949
+ if (decl.skipTransform || decl.base.kind !== "component") continue;
6950
+ const componentInterface = wrappedComponentInterfaceFor(ctx, decl.base.ident);
6951
+ const excludedProperties = componentInterface?.sxExcludedProperties;
6952
+ if (componentInterface?.acceptsSx !== true || !excludedProperties?.length) continue;
6953
+ const excluded = new Set(excludedProperties);
6954
+ for (const styleKey of collectAllStyleKeysForDecl(decl)) {
6955
+ const style = ctx.resolvedStyleObjects.get(styleKey);
6956
+ if (!style || typeof style !== "object") continue;
6957
+ const rejectedProperty = findSxExcludedStyleProperty(style, excluded);
6958
+ if (!rejectedProperty) continue;
6959
+ ctx.warnings.push({
6960
+ severity: "error",
6961
+ type: "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly",
6962
+ loc: decl.loc,
6963
+ context: {
6964
+ localName: decl.localName,
6965
+ wrappedComponent: decl.base.ident,
6966
+ styleKey,
6967
+ property: rejectedProperty
6968
+ }
6969
+ });
6970
+ return false;
6971
+ }
6972
+ }
6973
+ return true;
6974
+ }
6975
+ function staticObjectPropertyName(prop) {
6976
+ if (!prop || typeof prop !== "object") return null;
6977
+ const p = prop;
6978
+ if (p.type !== "Property" && p.type !== "ObjectProperty" || p.computed) return null;
6979
+ const key = p.key;
6980
+ if (!key) return null;
6981
+ if (key.type === "Identifier") return key.name ?? null;
6982
+ if (key.type === "Literal" || key.type === "StringLiteral") return typeof key.value === "string" ? key.value : null;
6983
+ return null;
6984
+ }
6985
+ function findSxExcludedStyleProperty(style, excludedProperties) {
6986
+ if (isAstNode(style)) return findSxExcludedStylePropertyInAstNode(style, excludedProperties);
6987
+ for (const [key, value] of Object.entries(style)) {
6988
+ if (excludedProperties.has(key)) return key;
6989
+ if (value && typeof value === "object") {
6990
+ const nested = findSxExcludedStyleProperty(value, excludedProperties);
6991
+ if (nested) return nested;
6992
+ }
6993
+ }
6994
+ return null;
6995
+ }
6996
+ function findSxExcludedStylePropertyInAstNode(node, excludedProperties) {
6997
+ const n = node;
6998
+ if (n.type === "ObjectExpression") {
6999
+ for (const prop of n.properties ?? []) {
7000
+ const name = staticObjectPropertyName(prop);
7001
+ if (name && excludedProperties.has(name)) return name;
7002
+ const value = prop.value;
7003
+ if (value && typeof value === "object") {
7004
+ const nested = findSxExcludedStylePropertyInAstNode(value, excludedProperties);
7005
+ if (nested) return nested;
7006
+ }
7007
+ }
7008
+ return null;
7009
+ }
7010
+ if (n.type === "ArrowFunctionExpression" && n.body && typeof n.body === "object") return findSxExcludedStylePropertyInAstNode(n.body, excludedProperties);
7011
+ if (n.type === "BlockStatement" && Array.isArray(n.body)) for (const statement of n.body ?? []) {
7012
+ const s = statement;
7013
+ if (s.type === "ReturnStatement" && s.argument && typeof s.argument === "object") {
7014
+ const nested = findSxExcludedStylePropertyInAstNode(s.argument, excludedProperties);
7015
+ if (nested) return nested;
7016
+ }
7017
+ }
7018
+ return null;
7019
+ }
6849
7020
  //#endregion
6850
7021
  //#region src/internal/policy.ts
6851
7022
  function collectCreateGlobalStyleWarnings(styledImports) {
@@ -13530,50 +13701,6 @@ function isFiniteNumericString(s) {
13530
13701
  const n = Number(s);
13531
13702
  return Number.isFinite(n) && String(n) === s;
13532
13703
  }
13533
- /** Mapping from CSS shorthand to the longhands that conflict with it */
13534
- const SHORTHAND_LONGHANDS = {
13535
- margin: {
13536
- physical: [
13537
- "marginTop",
13538
- "marginRight",
13539
- "marginBottom",
13540
- "marginLeft"
13541
- ],
13542
- logical: ["marginBlock", "marginInline"]
13543
- },
13544
- padding: {
13545
- physical: [
13546
- "paddingTop",
13547
- "paddingRight",
13548
- "paddingBottom",
13549
- "paddingLeft"
13550
- ],
13551
- logical: ["paddingBlock", "paddingInline"]
13552
- },
13553
- scrollMargin: {
13554
- physical: [
13555
- "scrollMarginTop",
13556
- "scrollMarginRight",
13557
- "scrollMarginBottom",
13558
- "scrollMarginLeft"
13559
- ],
13560
- logical: ["scrollMarginBlock", "scrollMarginInline"]
13561
- },
13562
- scrollPadding: {
13563
- physical: [
13564
- "scrollPaddingTop",
13565
- "scrollPaddingRight",
13566
- "scrollPaddingBottom",
13567
- "scrollPaddingLeft"
13568
- ],
13569
- logical: ["scrollPaddingBlock", "scrollPaddingInline"]
13570
- }
13571
- };
13572
- /**
13573
- * Mapping from logical longhands to their physical equivalents, derived from SHORTHAND_LONGHANDS.
13574
- * `marginBlock` → `["marginTop", "marginBottom"]`
13575
- */
13576
- const LOGICAL_TO_PHYSICAL = Object.fromEntries(Object.values(SHORTHAND_LONGHANDS).flatMap(({ physical, logical }) => [[logical[0], [physical[0], physical[2]]], [logical[1], [physical[1], physical[3]]]]));
13577
13704
  /** Type guard: value is a simple string or number (not a conditional object) */
13578
13705
  function isSimpleStyleValue(value) {
13579
13706
  return typeof value === "string" || typeof value === "number";
@@ -15713,7 +15840,10 @@ var WrapperEmitter = class {
15713
15840
  * configure the hook.
15714
15841
  */
15715
15842
  wrappedComponentAcceptsSxProp(componentLocalName) {
15716
- if (!this.useSxProp) return false;
15843
+ return this.wrappedComponentInterfaceFor(componentLocalName)?.acceptsSx === true;
15844
+ }
15845
+ wrappedComponentInterfaceFor(componentLocalName) {
15846
+ if (!this.useSxProp) return;
15717
15847
  const importInfo = this.importMap.get(componentLocalName);
15718
15848
  if (importInfo) {
15719
15849
  const adapterResult = this.wrappedComponentInterface?.({
@@ -15722,18 +15852,21 @@ var WrapperEmitter = class {
15722
15852
  importedName: importInfo.importedName,
15723
15853
  filePath: this.filePath
15724
15854
  });
15725
- if (adapterResult !== void 0) return adapterResult.acceptsSx === true;
15855
+ if (adapterResult !== void 0) return adapterResult;
15726
15856
  }
15727
15857
  const typedComponent = this.typeScriptComponentMetadataFor(componentLocalName);
15728
15858
  if (typedComponent) {
15729
- if (typedComponent.supportsSxProp) return true;
15730
- if (!this.hasSourceOverrideFor(componentLocalName)) return false;
15859
+ if (typedComponent.supportsSxProp) return {
15860
+ acceptsSx: true,
15861
+ sxExcludedProperties: typedComponent.sxExcludedProperties
15862
+ };
15863
+ if (!this.hasSourceOverrideFor(componentLocalName)) return { acceptsSx: false };
15731
15864
  }
15732
15865
  return importInfo?.source.kind === "absolutePath" && transformedComponentAcceptsSx({
15733
15866
  absolutePath: importInfo.source.value,
15734
15867
  componentNames: importInfo.importedName === "default" ? [componentLocalName, importInfo.importedName] : [importInfo.importedName],
15735
15868
  sourceOverrides: this.sourceOverrides
15736
- });
15869
+ }) ? { acceptsSx: true } : void 0;
15737
15870
  }
15738
15871
  propsTypeNameFor(localName) {
15739
15872
  return `${localName}Props`;
@@ -16582,7 +16715,8 @@ var WrapperEmitter = class {
16582
16715
  }
16583
16716
  }
16584
16717
  const literal = lines.length > 0 ? `{ ${lines.join(", ")} }` : "{}";
16585
- const baseMaybeOmitted = omitted.length ? `Omit<${base}, ${omitted.join(" | ")}>` : base;
16718
+ const omittedUnique = [...new Set(omitted)];
16719
+ const baseMaybeOmitted = omittedUnique.length ? `Omit<${base}, ${omittedUnique.join(" | ")}>` : base;
16586
16720
  return this.joinIntersection(literal !== "{}" ? literal : null, baseMaybeOmitted, ...renamedPropTypes);
16587
16721
  }
16588
16722
  isPropRequiredInPropsTypeLiteral(propsType, propName) {
@@ -36405,7 +36539,7 @@ function lowerRules(ctx) {
36405
36539
  }
36406
36540
  const snapshot = snapshotStateForDecl(state);
36407
36541
  state.currentDecl = decl;
36408
- const outcome = processOneDecl(state, decl);
36542
+ const outcome = processOneDecl(ctx, state, decl);
36409
36543
  state.currentDecl = null;
36410
36544
  if (outcome === "skip") {
36411
36545
  restoreStateSnapshot(state, snapshot);
@@ -36461,16 +36595,24 @@ function lowerRules(ctx) {
36461
36595
  * Returns `"skip"` if the decl marked itself skipped (per-decl bail), `"bail"` if
36462
36596
  * something set the file-level bail, or `"ok"` on success.
36463
36597
  */
36464
- function processOneDecl(state, decl) {
36465
- const declState = createDeclProcessingState(state, decl);
36466
- if (!preScanCssHelperPlaceholders(declState)) return decl.skipTransform ? "skip" : "bail";
36467
- processDeclRules(declState);
36468
- if (decl.skipTransform) return "skip";
36469
- if (state.bail) return "bail";
36470
- finalizeDeclProcessing(declState);
36471
- if (decl.skipTransform) return "skip";
36472
- if (state.bail) return "bail";
36473
- return "ok";
36598
+ function processOneDecl(ctx, state, decl) {
36599
+ const previousUseLogicalProperties = getUseLogicalProperties();
36600
+ const componentInterface = decl.base.kind === "component" ? wrappedComponentInterfaceFor(ctx, decl.base.ident) : void 0;
36601
+ const forcePhysicalDirectionalShorthands = componentInterface?.acceptsSx === true && componentInterface.sxExcludedProperties?.some((prop) => LOGICAL_TO_PHYSICAL[prop]) === true;
36602
+ if (forcePhysicalDirectionalShorthands) setUseLogicalProperties(false);
36603
+ try {
36604
+ const declState = createDeclProcessingState(state, decl);
36605
+ if (!preScanCssHelperPlaceholders(declState)) return decl.skipTransform ? "skip" : "bail";
36606
+ processDeclRules(declState);
36607
+ if (decl.skipTransform) return "skip";
36608
+ if (state.bail) return "bail";
36609
+ finalizeDeclProcessing(declState);
36610
+ if (decl.skipTransform) return "skip";
36611
+ if (state.bail) return "bail";
36612
+ return "ok";
36613
+ } finally {
36614
+ if (forcePhysicalDirectionalShorthands) setUseLogicalProperties(previousUseLogicalProperties);
36615
+ }
36474
36616
  }
36475
36617
  function markPartialImportedComponentRoots(ctx, state) {
36476
36618
  for (const decl of state.styledDecls) if (shouldSkipPartialImportedComponentRoot(ctx, decl)) decl.skipTransform = true;
@@ -127,6 +127,7 @@ function buildComponentMetadata(args) {
127
127
  const props = propType ? readPropsFromType(propType, args.checker, args.location) : [];
128
128
  const explicitPropNames = args.propTypeNode ? collectExplicitPropNames(args.propTypeNode, args.checker) : [];
129
129
  const supportsResolvedSxProp = props.some((prop) => prop.name === "sx") && args.propTypeNode !== void 0 && typeNodeHasResolvableSxSurface(args.propTypeNode, args.checker, /* @__PURE__ */ new Set());
130
+ const sxExcludedProperties = args.propTypeNode !== void 0 ? collectSxExcludedProperties(args.propTypeNode, args.checker, /* @__PURE__ */ new Set()) : [];
130
131
  return {
131
132
  name: args.name,
132
133
  kind: args.kind,
@@ -139,7 +140,8 @@ function buildComponentMetadata(args) {
139
140
  parameters: args.parameters,
140
141
  restProps: args.restProps,
141
142
  hasIndexSignature: propType ? hasIndexSignature(propType, args.checker) : false,
142
- supportsSxProp: explicitPropNames.includes("sx") || supportsResolvedSxProp || args.bodySupportsSxProp === true
143
+ supportsSxProp: explicitPropNames.includes("sx") || supportsResolvedSxProp || args.bodySupportsSxProp === true,
144
+ sxExcludedProperties
143
145
  };
144
146
  }
145
147
  function readPropsFromType(type, checker, location) {
@@ -235,6 +237,27 @@ function collectExplicitPropNamesInto(names, typeNode, checker, visited) {
235
237
  return;
236
238
  }
237
239
  if (!ts.isTypeReferenceNode(typeNode) || isIntrinsicReactPropReference(typeNode)) return;
240
+ const utilityType = readUtilityTypeReference(typeNode);
241
+ if (utilityType.name === "Pick") {
242
+ if (utilityType.typeArgs[0]) {
243
+ const pickedNames = /* @__PURE__ */ new Set();
244
+ collectExplicitPropNamesInto(pickedNames, utilityType.typeArgs[0], checker, visited);
245
+ for (const name of pickedNames) if (typeNodeKeyIncludes(utilityType.typeArgs[1], name)) names.add(name);
246
+ }
247
+ return;
248
+ }
249
+ if (utilityType.name === "Omit") {
250
+ if (utilityType.typeArgs[0]) {
251
+ const omittedNames = /* @__PURE__ */ new Set();
252
+ collectExplicitPropNamesInto(omittedNames, utilityType.typeArgs[0], checker, visited);
253
+ for (const name of omittedNames) if (!typeNodeKeyIncludes(utilityType.typeArgs[1], name)) names.add(name);
254
+ }
255
+ return;
256
+ }
257
+ if (isTransparentUtilityTypeName(utilityType.name)) {
258
+ if (utilityType.typeArgs[0]) collectExplicitPropNamesInto(names, utilityType.typeArgs[0], checker, visited);
259
+ return;
260
+ }
238
261
  const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(typeNode.typeName), checker);
239
262
  for (const declaration of symbol?.declarations ?? []) collectExplicitPropNamesFromDeclaration(names, declaration, checker, visited);
240
263
  }
@@ -243,23 +266,168 @@ function typeNodeHasResolvableSxSurface(typeNode, checker, visited) {
243
266
  if (ts.isIntersectionTypeNode(typeNode)) return typeNode.types.some((part) => typeNodeHasResolvableSxSurface(part, checker, visited));
244
267
  if (ts.isUnionTypeNode(typeNode)) return typeNode.types.every((part) => typeNodeHasResolvableSxSurface(part, checker, visited));
245
268
  if (!ts.isTypeReferenceNode(typeNode) || isIntrinsicReactPropReference(typeNode)) return false;
246
- const utilityTypeName = typeNode.typeName.getText();
247
- const typeArgs = typeNode.typeArguments ?? [];
248
- if (utilityTypeName === "Pick") return typeArgs.length >= 2 && typeNodeKeyIncludes(typeArgs[1], "sx");
249
- if (utilityTypeName === "Omit") {
250
- const baseType = typeArgs[0];
251
- return baseType !== void 0 && typeArgs.length >= 2 && !typeNodeKeyIncludes(typeArgs[1], "sx") && typeNodeHasResolvableSxSurface(baseType, checker, visited);
252
- }
253
- if ([
254
- "Partial",
255
- "Required",
256
- "Readonly"
257
- ].includes(utilityTypeName)) {
258
- const baseType = typeArgs[0];
269
+ const utilityType = readUtilityTypeReference(typeNode);
270
+ if (utilityType.name === "Pick") return utilityType.typeArgs.length >= 2 && typeNodeKeyIncludes(utilityType.typeArgs[1], "sx");
271
+ if (utilityType.name === "Omit") {
272
+ const baseType = utilityType.typeArgs[0];
273
+ return baseType !== void 0 && utilityType.typeArgs.length >= 2 && !typeNodeKeyIncludes(utilityType.typeArgs[1], "sx") && typeNodeHasResolvableSxSurface(baseType, checker, visited);
274
+ }
275
+ if (isTransparentUtilityTypeName(utilityType.name)) {
276
+ const baseType = utilityType.typeArgs[0];
259
277
  return baseType !== void 0 && typeNodeHasResolvableSxSurface(baseType, checker, visited);
260
278
  }
261
279
  return (resolveAliasedSymbol(checker.getSymbolAtLocation(typeNode.typeName), checker)?.declarations ?? []).some((declaration) => declarationHasResolvableSxSurface(declaration, checker, visited));
262
280
  }
281
+ function readUtilityTypeReference(typeNode) {
282
+ return {
283
+ name: typeNode.typeName.getText(),
284
+ typeArgs: typeNode.typeArguments ?? []
285
+ };
286
+ }
287
+ function isTransparentUtilityTypeName(typeName) {
288
+ return typeName === "Partial" || typeName === "Required" || typeName === "Readonly";
289
+ }
290
+ function collectSxExcludedProperties(typeNode, checker, visited) {
291
+ const names = /* @__PURE__ */ new Set();
292
+ collectSxExcludedPropertiesInto(names, typeNode, checker, visited);
293
+ return [...names].sort();
294
+ }
295
+ function collectSxExcludedPropertiesInto(names, typeNode, checker, visited) {
296
+ if (ts.isTypeLiteralNode(typeNode)) {
297
+ for (const member of typeNode.members) {
298
+ if (!ts.isPropertySignature(member) || propertyNameText(member.name) !== "sx" || !member.type) continue;
299
+ collectStyleXStylesWithoutKeys(names, member.type, checker, visited);
300
+ }
301
+ return;
302
+ }
303
+ if (ts.isIntersectionTypeNode(typeNode) || ts.isUnionTypeNode(typeNode)) {
304
+ for (const part of typeNode.types) collectSxExcludedPropertiesInto(names, part, checker, visited);
305
+ return;
306
+ }
307
+ if (!ts.isTypeReferenceNode(typeNode) || isIntrinsicReactPropReference(typeNode)) return;
308
+ const utilityType = readUtilityTypeReference(typeNode);
309
+ if (utilityType.name === "Pick") {
310
+ if (utilityType.typeArgs.length >= 2 && typeNodeKeyIncludes(utilityType.typeArgs[1], "sx") && utilityType.typeArgs[0]) collectSxExcludedPropertiesInto(names, utilityType.typeArgs[0], checker, visited);
311
+ return;
312
+ }
313
+ if (utilityType.name === "Omit") {
314
+ if (utilityType.typeArgs.length >= 2 && !typeNodeKeyIncludes(utilityType.typeArgs[1], "sx") && utilityType.typeArgs[0]) collectSxExcludedPropertiesInto(names, utilityType.typeArgs[0], checker, visited);
315
+ return;
316
+ }
317
+ if (isTransparentUtilityTypeName(utilityType.name)) {
318
+ if (utilityType.typeArgs[0]) collectSxExcludedPropertiesInto(names, utilityType.typeArgs[0], checker, visited);
319
+ return;
320
+ }
321
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(typeNode.typeName), checker);
322
+ for (const declaration of symbol?.declarations ?? []) collectSxExcludedPropertiesFromDeclaration(names, declaration, checker, visited);
323
+ }
324
+ function collectSxExcludedPropertiesFromDeclaration(names, declaration, checker, visited) {
325
+ if (visited.has(declaration)) return;
326
+ visited.add(declaration);
327
+ if (ts.isTypeAliasDeclaration(declaration)) {
328
+ collectSxExcludedPropertiesInto(names, declaration.type, checker, visited);
329
+ return;
330
+ }
331
+ if (!ts.isInterfaceDeclaration(declaration)) return;
332
+ for (const member of declaration.members) if (ts.isPropertySignature(member) && propertyNameText(member.name) === "sx" && member.type) collectStyleXStylesWithoutKeys(names, member.type, checker, visited);
333
+ for (const clause of declaration.heritageClauses ?? []) for (const heritageType of clause.types) {
334
+ if (isIntrinsicReactHeritageReference(heritageType)) continue;
335
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(heritageType.expression), checker);
336
+ for (const inheritedDeclaration of symbol?.declarations ?? []) collectSxExcludedPropertiesFromDeclaration(names, inheritedDeclaration, checker, visited);
337
+ }
338
+ }
339
+ function collectStyleXStylesWithoutKeys(names, typeNode, checker, visited) {
340
+ if (ts.isTypeReferenceNode(typeNode)) {
341
+ if (typeNode.typeName.getText().endsWith("StyleXStylesWithout")) {
342
+ collectPropertyKeysFromTypeNode(names, typeNode.typeArguments?.[0], checker, visited);
343
+ return;
344
+ }
345
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(typeNode.typeName), checker);
346
+ for (const declaration of symbol?.declarations ?? []) {
347
+ if (visited.has(declaration)) continue;
348
+ visited.add(declaration);
349
+ if (ts.isTypeAliasDeclaration(declaration)) collectStyleXStylesWithoutKeys(names, declaration.type, checker, visited);
350
+ else if (ts.isInterfaceDeclaration(declaration)) collectStyleXStylesWithoutKeysFromInterface(names, declaration, checker, visited);
351
+ }
352
+ return;
353
+ }
354
+ if (ts.isIntersectionTypeNode(typeNode) || ts.isUnionTypeNode(typeNode)) for (const part of typeNode.types) collectStyleXStylesWithoutKeys(names, part, checker, visited);
355
+ }
356
+ function collectStyleXStylesWithoutKeysFromInterface(names, declaration, checker, visited) {
357
+ for (const clause of declaration.heritageClauses ?? []) for (const heritageType of clause.types) {
358
+ if (isIntrinsicReactHeritageReference(heritageType)) continue;
359
+ if (heritageType.expression.getText().endsWith("StyleXStylesWithout")) {
360
+ collectPropertyKeysFromTypeNode(names, heritageType.typeArguments?.[0], checker, visited);
361
+ continue;
362
+ }
363
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(heritageType.expression), checker);
364
+ for (const inheritedDeclaration of symbol?.declarations ?? []) {
365
+ if (visited.has(inheritedDeclaration)) continue;
366
+ visited.add(inheritedDeclaration);
367
+ if (ts.isTypeAliasDeclaration(inheritedDeclaration)) collectStyleXStylesWithoutKeys(names, inheritedDeclaration.type, checker, visited);
368
+ else if (ts.isInterfaceDeclaration(inheritedDeclaration)) collectStyleXStylesWithoutKeysFromInterface(names, inheritedDeclaration, checker, visited);
369
+ }
370
+ }
371
+ }
372
+ function collectPropertyKeysFromTypeNode(names, typeNode, checker, visited) {
373
+ if (!typeNode) return;
374
+ if (ts.isTypeLiteralNode(typeNode)) {
375
+ for (const member of typeNode.members) if (ts.isPropertySignature(member)) {
376
+ const name = propertyNameText(member.name);
377
+ if (name) names.add(name);
378
+ }
379
+ return;
380
+ }
381
+ if (ts.isIntersectionTypeNode(typeNode) || ts.isUnionTypeNode(typeNode)) {
382
+ for (const part of typeNode.types) collectPropertyKeysFromTypeNode(names, part, checker, visited);
383
+ return;
384
+ }
385
+ if (!ts.isTypeReferenceNode(typeNode)) return;
386
+ const utilityType = readUtilityTypeReference(typeNode);
387
+ if (utilityType.name === "Pick") {
388
+ if (utilityType.typeArgs[0]) {
389
+ const pickedNames = /* @__PURE__ */ new Set();
390
+ collectPropertyKeysFromTypeNode(pickedNames, utilityType.typeArgs[0], checker, visited);
391
+ for (const name of pickedNames) if (typeNodeKeyIncludes(utilityType.typeArgs[1], name)) names.add(name);
392
+ }
393
+ return;
394
+ }
395
+ if (utilityType.name === "Omit") {
396
+ if (utilityType.typeArgs[0]) {
397
+ const omittedNames = /* @__PURE__ */ new Set();
398
+ collectPropertyKeysFromTypeNode(omittedNames, utilityType.typeArgs[0], checker, visited);
399
+ for (const name of omittedNames) if (!typeNodeKeyIncludes(utilityType.typeArgs[1], name)) names.add(name);
400
+ }
401
+ return;
402
+ }
403
+ if (isTransparentUtilityTypeName(utilityType.name)) {
404
+ if (utilityType.typeArgs[0]) collectPropertyKeysFromTypeNode(names, utilityType.typeArgs[0], checker, visited);
405
+ return;
406
+ }
407
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(typeNode.typeName), checker);
408
+ for (const declaration of symbol?.declarations ?? []) {
409
+ if (visited.has(declaration)) continue;
410
+ visited.add(declaration);
411
+ if (ts.isTypeAliasDeclaration(declaration)) collectPropertyKeysFromTypeNode(names, declaration.type, checker, visited);
412
+ else if (ts.isInterfaceDeclaration(declaration)) collectPropertyKeysFromInterfaceDeclaration(names, declaration, checker, visited);
413
+ }
414
+ }
415
+ function collectPropertyKeysFromInterfaceDeclaration(names, declaration, checker, visited) {
416
+ for (const member of declaration.members) if (ts.isPropertySignature(member)) {
417
+ const name = propertyNameText(member.name);
418
+ if (name) names.add(name);
419
+ }
420
+ for (const clause of declaration.heritageClauses ?? []) for (const heritageType of clause.types) {
421
+ if (isIntrinsicReactHeritageReference(heritageType)) continue;
422
+ const symbol = resolveAliasedSymbol(checker.getSymbolAtLocation(heritageType.expression), checker);
423
+ for (const inheritedDeclaration of symbol?.declarations ?? []) {
424
+ if (visited.has(inheritedDeclaration)) continue;
425
+ visited.add(inheritedDeclaration);
426
+ if (ts.isInterfaceDeclaration(inheritedDeclaration)) collectPropertyKeysFromInterfaceDeclaration(names, inheritedDeclaration, checker, visited);
427
+ else if (ts.isTypeAliasDeclaration(inheritedDeclaration)) collectPropertyKeysFromTypeNode(names, inheritedDeclaration.type, checker, visited);
428
+ }
429
+ }
430
+ }
263
431
  function declarationHasResolvableSxSurface(declaration, checker, visited) {
264
432
  if (visited.has(declaration)) return false;
265
433
  visited.add(declaration);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-components-to-stylex-codemod",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "Codemod to transform styled-components to StyleX",
5
5
  "keywords": [
6
6
  "codemod",