styled-components-to-stylex-codemod 0.0.37 → 0.0.39
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/{bridge-consumer-patcher-CKOMofN8.mjs → bridge-consumer-patcher-31jI1854.mjs} +148 -3
- package/dist/compute-leaf-set-Drcu2eju.mjs +239 -0
- package/dist/{extract-external-interface-BgvS5GC0.mjs → extract-external-interface-CdHbvfxu.mjs} +12 -1
- package/dist/{forwarded-as-consumer-patcher-CqxniQIc.mjs → forwarded-as-consumer-patcher-BYCrqzRm.mjs} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +44 -10
- package/dist/{merge-markers-CJ02ZuW0.mjs → merge-markers-BC5YNB7D.mjs} +85 -8
- package/dist/prop-usage-D6ZiDfzz.mjs +136 -0
- package/dist/{run-prepass-5LTAQkG0.mjs → run-prepass-qEr_Mc3y.mjs} +177 -260
- package/dist/{string-utils-ChXtospT.mjs → string-utils-DD9wdRHW.mjs} +16 -1
- package/dist/{transform-types-CY57kiqK.d.mts → transform-types-DJpFQ5xm.d.mts} +78 -7
- package/dist/transform.d.mts +1 -1
- package/dist/transform.mjs +4741 -1406
- package/dist/{transient-prop-consumer-patcher-CKAzqPfK.mjs → transient-prop-consumer-patcher-DdIYPSFk.mjs} +26 -7
- package/package.json +4 -5
- package/dist/styled-css-DVtGPEUe.mjs +0 -36
- /package/dist/{path-utils-CMR9NmMm.mjs → path-utils-BIpoL4Ue.mjs} +0 -0
- /package/dist/{selector-context-heuristic-DE3JAmpc.mjs → selector-context-heuristic-6_jSRGkZ.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as toRealPath } from "./path-utils-
|
|
2
|
-
import { r as escapeRegex } from "./string-utils-
|
|
1
|
+
import { n as toRealPath } from "./path-utils-BIpoL4Ue.mjs";
|
|
2
|
+
import { r as escapeRegex } from "./string-utils-DD9wdRHW.mjs";
|
|
3
3
|
import { basename, dirname, relative } from "node:path";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
//#region src/internal/transient-prop-consumer-patcher.ts
|
|
@@ -51,11 +51,17 @@ function collectTransientPropPatches(args) {
|
|
|
51
51
|
function findImportedRenamedComponents(consumerSource, targetImportSources, componentRenames) {
|
|
52
52
|
const entries = [];
|
|
53
53
|
for (const { exportName, renames } of componentRenames) {
|
|
54
|
-
const localName =
|
|
55
|
-
if (localName)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const localName = findLocalImportNameForExport(consumerSource, targetImportSources, exportName);
|
|
55
|
+
if (localName) {
|
|
56
|
+
entries.push({
|
|
57
|
+
localComponentName: localName,
|
|
58
|
+
renames
|
|
59
|
+
});
|
|
60
|
+
for (const wrapperName of findStyledWrapperNames(consumerSource, localName)) entries.push({
|
|
61
|
+
localComponentName: wrapperName,
|
|
62
|
+
renames
|
|
63
|
+
});
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
return entries;
|
|
61
67
|
}
|
|
@@ -129,6 +135,19 @@ function findLocalImportName(source, targetImportSources, exportName) {
|
|
|
129
135
|
}
|
|
130
136
|
return null;
|
|
131
137
|
}
|
|
138
|
+
function findLocalImportNameForExport(source, targetImportSources, exportName) {
|
|
139
|
+
const [rootExport, ...memberPath] = exportName.split(".");
|
|
140
|
+
if (!rootExport || memberPath.length === 0) return findLocalImportName(source, targetImportSources, exportName);
|
|
141
|
+
const rootLocalName = findLocalImportName(source, targetImportSources, rootExport);
|
|
142
|
+
return rootLocalName ? [rootLocalName, ...memberPath].join(".") : null;
|
|
143
|
+
}
|
|
144
|
+
function findStyledWrapperNames(source, componentName) {
|
|
145
|
+
const escapedComponent = escapeRegex(componentName);
|
|
146
|
+
const names = [];
|
|
147
|
+
const wrapperRegex = new RegExp(`(?:const|let|var)\\s+(\\w+)\\s*=\\s*styled\\(\\s*${escapedComponent}\\s*\\)`, "g");
|
|
148
|
+
for (const match of source.matchAll(wrapperRegex)) if (match[1]) names.push(match[1]);
|
|
149
|
+
return names;
|
|
150
|
+
}
|
|
132
151
|
/**
|
|
133
152
|
* Rename `$prop` → `prop` in JSX attributes for a specific component.
|
|
134
153
|
* Matches `<ComponentName ... $propName=` and `<ComponentName ... $propName>`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "styled-components-to-stylex-codemod",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "Codemod to transform styled-components to StyleX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
41
41
|
"@emotion/is-prop-valid": "^1.4.0",
|
|
42
42
|
"@storybook/react-vite": "^10.2.19",
|
|
43
|
-
"@stylexjs/babel-plugin": "^0.18.
|
|
43
|
+
"@stylexjs/babel-plugin": "^0.18.3",
|
|
44
44
|
"@stylexjs/eslint-plugin": "^0.18.1",
|
|
45
|
-
"@stylexjs/stylex": "^0.18.
|
|
46
|
-
"@stylexjs/unplugin": "^0.18.
|
|
45
|
+
"@stylexjs/stylex": "^0.18.3",
|
|
46
|
+
"@stylexjs/unplugin": "^0.18.3",
|
|
47
47
|
"@types/jscodeshift": "^17.3.0",
|
|
48
48
|
"@types/node": "^25.6.0",
|
|
49
49
|
"@types/react": "^19.2.14",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"eslint": "^10.0.3",
|
|
59
59
|
"eslint-plugin-storybook": "10.2.19",
|
|
60
60
|
"knip": "^5.86.0",
|
|
61
|
-
"lefthook": "^2.1.6",
|
|
62
61
|
"oxfmt": "^0.34.0",
|
|
63
62
|
"oxlint": "^1.55.0",
|
|
64
63
|
"oxlint-tsgolint": "^0.16.0",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { compile } from "stylis";
|
|
2
|
-
//#region src/internal/styled-css.ts
|
|
3
|
-
/** Matches `__SC_EXPR_N__` and captures the slot index in group 1. */
|
|
4
|
-
const PLACEHOLDER_RE = /__SC_EXPR_(\d+)__/;
|
|
5
|
-
function parseStyledTemplateLiteral(template) {
|
|
6
|
-
const parts = [];
|
|
7
|
-
const slots = [];
|
|
8
|
-
for (let i = 0; i < template.quasis.length; i++) {
|
|
9
|
-
const quasi = template.quasis[i];
|
|
10
|
-
parts.push(quasi.value.raw);
|
|
11
|
-
const expr = template.expressions[i];
|
|
12
|
-
if (!expr) continue;
|
|
13
|
-
const placeholder = makeInterpolationPlaceholder(i);
|
|
14
|
-
const startOffset = parts.join("").length;
|
|
15
|
-
parts.push(placeholder);
|
|
16
|
-
const endOffset = parts.join("").length;
|
|
17
|
-
slots.push({
|
|
18
|
-
index: i,
|
|
19
|
-
placeholder,
|
|
20
|
-
expression: expr,
|
|
21
|
-
startOffset,
|
|
22
|
-
endOffset
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const rawCss = parts.join("");
|
|
26
|
-
return {
|
|
27
|
-
rawCss,
|
|
28
|
-
slots,
|
|
29
|
-
stylisAst: compile(rawCss)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function makeInterpolationPlaceholder(index) {
|
|
33
|
-
return `__SC_EXPR_${index}__`;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { parseStyledTemplateLiteral as n, PLACEHOLDER_RE as t };
|
|
File without changes
|
/package/dist/{selector-context-heuristic-DE3JAmpc.mjs → selector-context-heuristic-6_jSRGkZ.mjs}
RENAMED
|
File without changes
|