styled-components-to-stylex-codemod 0.0.58 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ImportSource, i as AdapterInput, o as MarkerFileContext, s as defineAdapter, t as CollectedWarning } from "./logger-
|
|
1
|
+
import { a as ImportSource, i as AdapterInput, o as MarkerFileContext, s as defineAdapter, t as CollectedWarning } from "./logger-BdLa-hBH.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/run.d.ts
|
|
4
4
|
interface RunTransformOptions {
|
|
@@ -125,7 +125,8 @@ type CallResolveContext = {
|
|
|
125
125
|
/**
|
|
126
126
|
* Call arguments.
|
|
127
127
|
* - literals are surfaced precisely
|
|
128
|
-
* - theme member access can be surfaced as `{ kind: "theme", path }`
|
|
128
|
+
* - theme object/member access can be surfaced as `{ kind: "theme", path }`
|
|
129
|
+
* (`path === ""` means the whole theme object)
|
|
129
130
|
* - everything else is `unknown`
|
|
130
131
|
*/
|
|
131
132
|
args: Array<{
|
|
@@ -958,7 +959,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
|
|
|
958
959
|
//#endregion
|
|
959
960
|
//#region src/internal/logger.d.ts
|
|
960
961
|
type Severity = "info" | "warning" | "error";
|
|
961
|
-
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolved an imported helper call as StyleX styles without replacing the RuleSet helper" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | "Adapter resolved imported StyleX value under nested selectors/at-rules but did not provide cssText for property expansion — add cssText to resolveValue result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | 'Adapter resolveValue cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Imported constant cannot be referenced inside stylex.create() — move it into a `.stylex` defineConsts/defineVars group (or map it via adapter.resolveValue)" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: unsupported or mixed @-rules require manual handling" | "CSS block contains unsupported at-rule (only @media, @container, and @supports are supported; mixed nested at-rules require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: finite ternary before a later overlapping declaration requires manual source-order handling" | "Conditional `css` block: runtime pseudo-alias styles are not supported" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Unsupported background shorthand: multiple components cannot be mapped to a single StyleX longhand" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported .attrs() callback pattern" | "Unsupported .attrs() object value" | "Unsupported .attrs() object/array value on a styled component sharing a multi-declarator statement" | "Unsupported .attrs() object/array value on a styled component whose name is shadowed in another scope" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "css helper with prop-based interpolation cannot be reused as a mixin" | "Unsupported interpolation: member expression" | "Unsupported interpolation: multiple dynamic slots in one declaration" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | `Unsupported CSS property "${string}" cannot be emitted in StyleX` | "Dynamic logical scroll shorthand cannot be expanded — bind a specific longhand (e.g. scroll-padding-inline-start) instead" | "Imported runtime condition root collides with a component prop of the same name" | "Mixed logical and physical scroll properties cannot be normalized without a known writing-mode" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: adjacent sibling combinator" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: conditional css block inside pseudo-element selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: pseudo-class on pseudo-element selector" | "Unsupported selector: unsupported pseudo-element" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in attribute selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: unresolved interpolation in cross-component sibling selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: computed media query inside ancestor attribute selector" | "Unsupported selector: computed media query inside cross-component sibling selector" | "Unsupported selector: computed media query inside sibling selector" | "Unsupported selector: computed media query inside :has() component selector" | "Unsupported: a property combines a computed at-rule key (from resolveSelector) with a static at-rule key on the same property — StyleX emits computed keys last, so the original cascade order between the at-rules cannot be preserved" | "Unsupported selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component selector" | "Unsupported selector: component selector with child pseudo" | "Unsupported selector: component selector target has no patchable JSX usage under selector parent" | "Unsupported selector: compound pseudo selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "Partial migration left styled-components declarations unconverted" | "styled(ImportedComponent) wraps a component whose file uses styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Partial transform would have a StyleX leaf wrap a styled-components base — the extending component was transformed but its base was not, so the leaf's StyleX overrides cannot reliably beat the base's styled-components styles" | "Partial transform would leave a StyleX child reveal targeting a styled-components ancestor — the component-selector ancestor was not converted, so it cannot render the marker the child's stylex.when.ancestor() reveal needs; the child is preserved as styled-components to keep the reveal working" | "Conditional StyleX default would override an unproven earlier style for the same property" | "Flat StyleX value would erase earlier conditional property states" | "Forwarded sx conditional default would override an unproven wrapped component base style" | "Wrapped component does not accept className or sx for generated StyleX styles" | "Wrapped component sx prop targets an inner element for a root style property" | "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly" | "Wrapped component sx prop does not accept generated StyleX property" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names" | "Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens" | "animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead";
|
|
962
|
+
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolved an imported helper call as StyleX styles without replacing the RuleSet helper" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved className-only helper cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | "Adapter resolved imported StyleX value under nested selectors/at-rules but did not provide cssText for property expansion — add cssText to resolveValue result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | 'Adapter resolveValue cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Imported constant cannot be referenced inside stylex.create() — move it into a `.stylex` defineConsts/defineVars group (or map it via adapter.resolveValue)" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: unsupported or mixed @-rules require manual handling" | "CSS block contains unsupported at-rule (only @media, @container, and @supports are supported; mixed nested at-rules require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: finite ternary before a later overlapping declaration requires manual source-order handling" | "Conditional `css` block: runtime pseudo-alias styles are not supported" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Unsupported background shorthand: multiple components cannot be mapped to a single StyleX longhand" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported .attrs() callback pattern" | "Unsupported .attrs() object value" | "Unsupported .attrs() object/array value on a styled component sharing a multi-declarator statement" | "Unsupported .attrs() object/array value on a styled component whose name is shadowed in another scope" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "css helper with prop-based interpolation cannot be reused as a mixin" | "Unsupported interpolation: member expression" | "Unsupported interpolation: multiple dynamic slots in one declaration" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | `Unsupported CSS property "${string}" cannot be emitted in StyleX` | "Dynamic logical scroll shorthand cannot be expanded — bind a specific longhand (e.g. scroll-padding-inline-start) instead" | "Imported runtime condition root collides with a component prop of the same name" | "Mixed logical and physical scroll properties cannot be normalized without a known writing-mode" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: adjacent sibling combinator" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: conditional css block inside pseudo-element selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: pseudo-class on pseudo-element selector" | "Unsupported selector: unsupported pseudo-element" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in attribute selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: unresolved interpolation in cross-component sibling selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: computed media query inside ancestor attribute selector" | "Unsupported selector: computed media query inside cross-component sibling selector" | "Unsupported selector: computed media query inside sibling selector" | "Unsupported selector: computed media query inside :has() component selector" | "Unsupported: a property combines a computed at-rule key (from resolveSelector) with a static at-rule key on the same property — StyleX emits computed keys last, so the original cascade order between the at-rules cannot be preserved" | "Unsupported selector: cross-file :has() component selector not yet supported" | "Unsupported selector: unresolved interpolation in :has() component selector" | "Unsupported selector: unknown component selector" | "Unsupported selector: component selector with child pseudo" | "Unsupported selector: component selector target has no patchable JSX usage under selector parent" | "Unsupported selector: compound pseudo selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "Partial migration left styled-components declarations unconverted" | "styled(ImportedComponent) wraps a component whose file uses styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Partial transform would have a StyleX leaf wrap a styled-components base — the extending component was transformed but its base was not, so the leaf's StyleX overrides cannot reliably beat the base's styled-components styles" | "Partial transform would leave a StyleX child reveal targeting a styled-components ancestor — the component-selector ancestor was not converted, so it cannot render the marker the child's stylex.when.ancestor() reveal needs; the child is preserved as styled-components to keep the reveal working" | "Conditional StyleX default would override an unproven earlier style for the same property" | "Flat StyleX value would erase earlier conditional property states" | "Forwarded sx conditional default would override an unproven wrapped component base style" | "Wrapped component does not accept className or sx for generated StyleX styles" | "Wrapped component sx prop targets an inner element for a root style property" | "Wrapped component sx prop rejects logical CSS properties that cannot be preserved losslessly" | "Wrapped component sx prop does not accept generated StyleX property" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names" | "Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens" | "animation shorthand contains a var() with no classifiable fallback — its longhand position cannot be determined statically; bind the variable to a specific longhand (e.g. animation-duration: var(--x)) instead";
|
|
962
963
|
interface WarningLog {
|
|
963
964
|
severity: Severity;
|
|
964
965
|
type: WarningType;
|
package/dist/transform.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as WarningLog, r as Adapter } from "./logger-
|
|
1
|
+
import { n as WarningLog, r as Adapter } from "./logger-BdLa-hBH.mjs";
|
|
2
2
|
import { API, FileInfo, Options } from "jscodeshift";
|
|
3
3
|
//#region src/internal/prepass/typescript-analysis.d.ts
|
|
4
4
|
interface TypeScriptPrepassMetadata {
|
package/dist/transform.mjs
CHANGED
|
@@ -3261,17 +3261,21 @@ function getCalleeIdentName(callee) {
|
|
|
3261
3261
|
function callArgFromNode(node, propsParamName, themeBindingName) {
|
|
3262
3262
|
if (!node || typeof node !== "object") return { kind: "unknown" };
|
|
3263
3263
|
const type = node.type;
|
|
3264
|
+
if (type === "Identifier" && typeof themeBindingName === "string" && themeBindingName && node.name === themeBindingName) return {
|
|
3265
|
+
kind: "theme",
|
|
3266
|
+
path: ""
|
|
3267
|
+
};
|
|
3264
3268
|
if (type === "MemberExpression") {
|
|
3265
3269
|
if (typeof propsParamName === "string" && propsParamName) {
|
|
3266
3270
|
const parts = getMemberPathFromIdentifier(node, propsParamName);
|
|
3267
|
-
if (parts && parts[0] === "theme"
|
|
3271
|
+
if (parts && parts[0] === "theme") return {
|
|
3268
3272
|
kind: "theme",
|
|
3269
3273
|
path: parts.slice(1).join(".")
|
|
3270
3274
|
};
|
|
3271
3275
|
}
|
|
3272
3276
|
if (typeof themeBindingName === "string" && themeBindingName) {
|
|
3273
3277
|
const parts = getMemberPathFromIdentifier(node, themeBindingName);
|
|
3274
|
-
if (parts
|
|
3278
|
+
if (parts) return {
|
|
3275
3279
|
kind: "theme",
|
|
3276
3280
|
path: parts.join(".")
|
|
3277
3281
|
};
|
|
@@ -5530,7 +5534,7 @@ function collectStylexCreateMaps(ast, moduleBindings) {
|
|
|
5530
5534
|
for (const node of Array.isArray(declaration.declarations) ? declaration.declarations : []) {
|
|
5531
5535
|
if (!isRecord(node) || node.type !== "VariableDeclarator") continue;
|
|
5532
5536
|
const id = node.id;
|
|
5533
|
-
const init = node.init;
|
|
5537
|
+
const init = unwrapExpression(node.init);
|
|
5534
5538
|
if (!isIdentifier(id) || !isRecord(init) || !isStylexCreateCall$1(init)) continue;
|
|
5535
5539
|
const stylesArg = getCallArguments(init)[0];
|
|
5536
5540
|
if (!isObjectExpression$1(stylesArg)) continue;
|
|
@@ -5588,11 +5592,14 @@ function readStyleObjectProps(styleObject, moduleBindings, dynamicValueNames = /
|
|
|
5588
5592
|
const resolution = resolveConstReference(property.value, moduleBindings);
|
|
5589
5593
|
if (resolution.kind === "unresolved") {
|
|
5590
5594
|
if (dynamicValueNames.has(resolution.name)) props.set(key, { kind: "dynamic" });
|
|
5591
|
-
else
|
|
5595
|
+
else props.set(key, { kind: "unknownConditionalMap" });
|
|
5592
5596
|
continue;
|
|
5593
5597
|
}
|
|
5594
5598
|
const valueNode = resolution.node;
|
|
5595
|
-
if (isObjectExpression$1(valueNode) && objectExpressionHasUnreadProperties(valueNode))
|
|
5599
|
+
if (isObjectExpression$1(valueNode) && objectExpressionHasUnreadProperties(valueNode)) {
|
|
5600
|
+
props.set(key, { kind: "unknownConditionalMap" });
|
|
5601
|
+
continue;
|
|
5602
|
+
}
|
|
5596
5603
|
const value = readAstPropertyShape(valueNode, moduleBindings);
|
|
5597
5604
|
if (value.kind !== "absent") props.set(key, value);
|
|
5598
5605
|
}
|
|
@@ -5971,6 +5978,10 @@ function analyzeStyleEntry(styleEntry, prop, called) {
|
|
|
5971
5978
|
};
|
|
5972
5979
|
const value = styleEntry.props.get(prop);
|
|
5973
5980
|
if (!value) return { kind: "absent" };
|
|
5981
|
+
if (value.kind === "unknownConditionalMap") return {
|
|
5982
|
+
kind: "variableConditionalMap",
|
|
5983
|
+
conditionKeys: []
|
|
5984
|
+
};
|
|
5974
5985
|
if (styleEntry.kind === "function" || called || value.kind === "dynamic") return value.kind === "conditionalMap" ? {
|
|
5975
5986
|
kind: "variableConditionalMap",
|
|
5976
5987
|
conditionKeys: value.conditionKeys
|
|
@@ -6232,7 +6243,7 @@ function isSxExpression(node, sxBindings) {
|
|
|
6232
6243
|
}
|
|
6233
6244
|
function unwrapExpression(node) {
|
|
6234
6245
|
let current = node;
|
|
6235
|
-
while (isRecord(current) && (current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "ParenthesizedExpression")) current = current.expression;
|
|
6246
|
+
while (isRecord(current) && (current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "TSSatisfiesExpression" || current.type === "ParenthesizedExpression")) current = current.expression;
|
|
6236
6247
|
return current;
|
|
6237
6248
|
}
|
|
6238
6249
|
function unwrapAssignmentPattern(node) {
|
|
@@ -6279,10 +6290,22 @@ function getFunctionParams(node) {
|
|
|
6279
6290
|
}
|
|
6280
6291
|
function readPropertyKey$1(property) {
|
|
6281
6292
|
const key = property.key;
|
|
6293
|
+
if (property.computed === true) return readComputedPropertyKey(key);
|
|
6282
6294
|
if (isIdentifier(key)) return key.name;
|
|
6283
6295
|
if (isRecord(key) && (key.type === "StringLiteral" || key.type === "Literal")) return typeof key.value === "string" ? key.value : null;
|
|
6284
6296
|
return null;
|
|
6285
6297
|
}
|
|
6298
|
+
function readComputedPropertyKey(key) {
|
|
6299
|
+
const literalKey = readStringLiteralKey(key);
|
|
6300
|
+
if (literalKey) return literalKey;
|
|
6301
|
+
if (!isRecord(key) || key.type !== "MemberExpression") return null;
|
|
6302
|
+
const memberKey = readStringLiteralKey(key.property);
|
|
6303
|
+
return memberKey?.startsWith("--") ? memberKey : null;
|
|
6304
|
+
}
|
|
6305
|
+
function readStringLiteralKey(key) {
|
|
6306
|
+
if (!isRecord(key) || key.type !== "StringLiteral" && key.type !== "Literal") return null;
|
|
6307
|
+
return typeof key.value === "string" ? key.value : null;
|
|
6308
|
+
}
|
|
6286
6309
|
function isStaticValue(value) {
|
|
6287
6310
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
|
|
6288
6311
|
}
|
|
@@ -29143,8 +29166,8 @@ function extractThemePath(memberExpr, info) {
|
|
|
29143
29166
|
return parts.join(".");
|
|
29144
29167
|
}
|
|
29145
29168
|
function tryResolveArrowFnHelperCallWithThemeArg(node, ctx) {
|
|
29146
|
-
|
|
29147
|
-
|
|
29169
|
+
if (!isArrowFunctionExpression(node.expr)) return null;
|
|
29170
|
+
const expr = node.expr;
|
|
29148
29171
|
const info = getArrowFnThemeParamInfo(expr);
|
|
29149
29172
|
if (!info) return null;
|
|
29150
29173
|
const body = getFunctionBodyExpr(expr);
|
|
@@ -29154,15 +29177,14 @@ function tryResolveArrowFnHelperCallWithThemeArg(node, ctx) {
|
|
|
29154
29177
|
const propsParamName = info.kind === "propsParam" ? info.propsName : void 0;
|
|
29155
29178
|
const themeBindingName = info.kind === "themeBinding" ? info.themeName : void 0;
|
|
29156
29179
|
if (!args.some((arg) => {
|
|
29157
|
-
if (!arg
|
|
29180
|
+
if (!arg) return false;
|
|
29181
|
+
if (arg.type === "Identifier" && typeof themeBindingName === "string" && arg.name === themeBindingName) return true;
|
|
29182
|
+
if (arg.type !== "MemberExpression") return false;
|
|
29158
29183
|
if (propsParamName) {
|
|
29159
29184
|
const parts = getMemberPathFromIdentifier(arg, propsParamName);
|
|
29160
|
-
return parts !== null && parts[0] === "theme"
|
|
29161
|
-
}
|
|
29162
|
-
if (themeBindingName) {
|
|
29163
|
-
const parts = getMemberPathFromIdentifier(arg, themeBindingName);
|
|
29164
|
-
return parts !== null && parts.length > 0;
|
|
29185
|
+
return parts !== null && parts[0] === "theme";
|
|
29165
29186
|
}
|
|
29187
|
+
if (themeBindingName) return getMemberPathFromIdentifier(arg, themeBindingName) !== null;
|
|
29166
29188
|
return false;
|
|
29167
29189
|
})) return null;
|
|
29168
29190
|
const simple = resolveImportedHelperCall$1(body, ctx, propsParamName, node.css.property, themeBindingName);
|
|
@@ -38259,13 +38281,12 @@ function preScanCssHelperPlaceholders(ctx) {
|
|
|
38259
38281
|
} else {
|
|
38260
38282
|
const importEntry = importMap?.get(calleeName);
|
|
38261
38283
|
if (importEntry) {
|
|
38262
|
-
|
|
38284
|
+
if (!isResolvedImportedHelperForPreScan(resolveCall({
|
|
38263
38285
|
callSiteFilePath: filePath,
|
|
38264
38286
|
calleeImportedName: importEntry.importedName,
|
|
38265
38287
|
calleeSource: importEntry.source,
|
|
38266
38288
|
args: []
|
|
38267
|
-
})
|
|
38268
|
-
if (!resolved || !("expr" in resolved)) {
|
|
38289
|
+
}), rule)) {
|
|
38269
38290
|
hasImportedCssHelper = true;
|
|
38270
38291
|
importedCssHelperLoc ??= getNodeLocStart(expr);
|
|
38271
38292
|
}
|
|
@@ -38298,6 +38319,12 @@ function preScanCssHelperPlaceholders(ctx) {
|
|
|
38298
38319
|
}
|
|
38299
38320
|
return true;
|
|
38300
38321
|
}
|
|
38322
|
+
function isResolvedImportedHelperForPreScan(resolved, rule) {
|
|
38323
|
+
if (!resolved) return false;
|
|
38324
|
+
if ("expr" in resolved) return true;
|
|
38325
|
+
if ("extraClassNames" in resolved) return rule.selector.trim() === "&" && (rule.atRuleStack ?? []).length === 0;
|
|
38326
|
+
return false;
|
|
38327
|
+
}
|
|
38301
38328
|
//#endregion
|
|
38302
38329
|
//#region src/internal/lower-rules/borders.ts
|
|
38303
38330
|
function tryHandleInterpolatedBorder(ctx, args) {
|
|
@@ -42565,13 +42592,36 @@ function tryHandleResolvedDynamicNode(rc) {
|
|
|
42565
42592
|
expr: exprAst,
|
|
42566
42593
|
afterBase: hasStaticPropsBefore
|
|
42567
42594
|
});
|
|
42595
|
+
if (resolvedStylesUsesThemeArg(res)) markDeclNeedsUseThemeHook(decl);
|
|
42568
42596
|
if (res.extraClassNames) collectExtraClassNames(res.extraClassNames);
|
|
42569
42597
|
notifyResolvedStylesArg();
|
|
42570
42598
|
decl.needsWrapperComponent = true;
|
|
42571
42599
|
return true;
|
|
42572
42600
|
}
|
|
42573
42601
|
if (res && res.type === "resolvedClassNames") {
|
|
42602
|
+
if (rule.selector.trim() !== "&" || (rule.atRuleStack ?? []).length) {
|
|
42603
|
+
const resolveCallMeta = res.resolveCallContext && res.resolveCallResult ? {
|
|
42604
|
+
resolveCallContext: res.resolveCallContext,
|
|
42605
|
+
resolveCallResult: res.resolveCallResult
|
|
42606
|
+
} : void 0;
|
|
42607
|
+
warnings.push({
|
|
42608
|
+
severity: "warning",
|
|
42609
|
+
type: "Adapter resolved className-only helper cannot be applied under nested selectors/at-rules",
|
|
42610
|
+
loc,
|
|
42611
|
+
context: resolveCallMeta ? {
|
|
42612
|
+
selector: rule.selector,
|
|
42613
|
+
atRuleStack: rule.atRuleStack,
|
|
42614
|
+
...resolveCallMeta
|
|
42615
|
+
} : {
|
|
42616
|
+
selector: rule.selector,
|
|
42617
|
+
atRuleStack: rule.atRuleStack
|
|
42618
|
+
}
|
|
42619
|
+
});
|
|
42620
|
+
flags.bail = true;
|
|
42621
|
+
return true;
|
|
42622
|
+
}
|
|
42574
42623
|
collectExtraClassNames(res.extraClassNames);
|
|
42624
|
+
if (resolvedStylesUsesThemeArg(res)) markDeclNeedsUseThemeHook(decl);
|
|
42575
42625
|
decl.needsWrapperComponent = true;
|
|
42576
42626
|
return true;
|
|
42577
42627
|
}
|
|
@@ -43090,6 +43140,9 @@ function tryHandleResolvedDynamicNode(rc) {
|
|
|
43090
43140
|
}
|
|
43091
43141
|
return tryHandleResolvedStyleFunctionNode(rc);
|
|
43092
43142
|
}
|
|
43143
|
+
function resolvedStylesUsesThemeArg(res) {
|
|
43144
|
+
return res.resolveCallContext?.args?.some((arg) => arg.kind === "theme") ?? false;
|
|
43145
|
+
}
|
|
43093
43146
|
//#endregion
|
|
43094
43147
|
//#region src/internal/lower-rules/rule-interpolated-declaration.ts
|
|
43095
43148
|
function handleInterpolatedDeclaration(args) {
|