styled-components-to-stylex-codemod 0.0.55 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/{ast-walk-C226poBl.mjs → ast-walk-DVmYZ2mK.mjs} +376 -36
- package/dist/{bridge-consumer-patcher-DDcYZM_G.mjs → bridge-consumer-patcher-jeeDUlId.mjs} +1 -1
- package/dist/index.d.mts +92 -14
- package/dist/index.mjs +622 -35
- package/dist/{transform-types-BGGNjb8R.d.mts → logger-ByYsVkrB.d.mts} +1 -198
- package/dist/{prop-usage-Bs2F3Wke.mjs → prop-usage-D1dECkkb.mjs} +93 -354
- package/dist/{run-prepass-D3Ti1ryc.mjs → run-prepass-CGL_ugPB.mjs} +29 -109
- package/dist/{sx-surface-Cth8EesU.mjs → sx-surface-Kv8zK8L4.mjs} +31 -1
- package/dist/transform.d.mts +180 -2
- package/dist/transform.mjs +600 -861
- package/package.json +1 -1
- package/dist/compute-leaf-set-Cu4lMMQ9.mjs +0 -239
- /package/dist/{forwarded-as-consumer-patcher-Bva_36Gy.mjs → forwarded-as-consumer-patcher-Do4PI4Qs.mjs} +0 -0
- /package/dist/{selector-context-heuristic-LVizWWOR.mjs → selector-context-heuristic-Dptd93Xe.mjs} +0 -0
- /package/dist/{transient-prop-consumer-patcher-DSd7uVA6.mjs → transient-prop-consumer-patcher-D-iqO8-T.mjs} +0 -0
- /package/dist/{typescript-analysis-BLyx4wAJ.mjs → typescript-analysis-eRPqsZ2z.mjs} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { API, FileInfo, Options } from "jscodeshift";
|
|
2
1
|
//#region src/adapter.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Adapter entry point for customizing the codemod.
|
|
@@ -973,200 +972,4 @@ interface CollectedWarning extends WarningLog {
|
|
|
973
972
|
filePath: string;
|
|
974
973
|
}
|
|
975
974
|
//#endregion
|
|
976
|
-
|
|
977
|
-
interface TypeScriptPrepassMetadata {
|
|
978
|
-
version: 1;
|
|
979
|
-
files: TypeScriptFileMetadata[];
|
|
980
|
-
}
|
|
981
|
-
interface TypeScriptFileMetadata {
|
|
982
|
-
filePath: string;
|
|
983
|
-
components: TypeScriptComponentMetadata[];
|
|
984
|
-
functions: TypeScriptFunctionMetadata[];
|
|
985
|
-
}
|
|
986
|
-
interface TypeScriptComponentMetadata {
|
|
987
|
-
name: string;
|
|
988
|
-
kind: "styled" | "react";
|
|
989
|
-
exported: boolean;
|
|
990
|
-
defaultExport: boolean;
|
|
991
|
-
typeParameters: string[];
|
|
992
|
-
propType: TypeScriptTypeMetadata | null;
|
|
993
|
-
props: TypeScriptPropMetadata[];
|
|
994
|
-
explicitPropNames: string[];
|
|
995
|
-
parameters: TypeScriptParameterMetadata[];
|
|
996
|
-
restProps: TypeScriptRestPropMetadata[];
|
|
997
|
-
hasIndexSignature: boolean;
|
|
998
|
-
supportsSxProp: boolean;
|
|
999
|
-
sxTarget?: "root" | "inner";
|
|
1000
|
-
sxExcludedProperties: string[];
|
|
1001
|
-
sxAllowedProperties?: string[];
|
|
1002
|
-
}
|
|
1003
|
-
interface TypeScriptFunctionMetadata {
|
|
1004
|
-
name: string;
|
|
1005
|
-
exported: boolean;
|
|
1006
|
-
defaultExport: boolean;
|
|
1007
|
-
typeParameters: string[];
|
|
1008
|
-
parameters: TypeScriptParameterMetadata[];
|
|
1009
|
-
}
|
|
1010
|
-
interface TypeScriptTypeMetadata {
|
|
1011
|
-
text: string;
|
|
1012
|
-
inheritedTypes: string[];
|
|
1013
|
-
intersectionTypes: string[];
|
|
1014
|
-
unionTypes: string[];
|
|
1015
|
-
}
|
|
1016
|
-
interface TypeScriptPropMetadata {
|
|
1017
|
-
name: string;
|
|
1018
|
-
optional: boolean;
|
|
1019
|
-
readonly: boolean;
|
|
1020
|
-
type: string;
|
|
1021
|
-
}
|
|
1022
|
-
interface TypeScriptParameterMetadata {
|
|
1023
|
-
name: string;
|
|
1024
|
-
optional: boolean;
|
|
1025
|
-
rest: boolean;
|
|
1026
|
-
type: string;
|
|
1027
|
-
}
|
|
1028
|
-
interface TypeScriptRestPropMetadata {
|
|
1029
|
-
name: string;
|
|
1030
|
-
source: "parameter" | "destructure";
|
|
1031
|
-
}
|
|
1032
|
-
//#endregion
|
|
1033
|
-
//#region src/internal/transform-types.d.ts
|
|
1034
|
-
/** A sidecar .stylex.ts file containing defineMarker() declarations. */
|
|
1035
|
-
interface SidecarFile {
|
|
1036
|
-
content: string;
|
|
1037
|
-
/** Absolute file path for writing. Undefined = default local sidecar next to the source file. */
|
|
1038
|
-
filePath?: string;
|
|
1039
|
-
}
|
|
1040
|
-
interface LocalStylexVarsSidecarFile {
|
|
1041
|
-
content: string;
|
|
1042
|
-
importPath: string;
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* Result of the transform including any log entries
|
|
1046
|
-
*/
|
|
1047
|
-
interface TransformResult {
|
|
1048
|
-
code: string | null;
|
|
1049
|
-
warnings: WarningLog[];
|
|
1050
|
-
/** Sidecar .stylex.ts files (defineMarker declarations). Multiple entries when a file has
|
|
1051
|
-
* both cross-file markers (adapter.markerFile) and internal markers (local sidecar). */
|
|
1052
|
-
sidecarFiles?: SidecarFile[];
|
|
1053
|
-
/** Bridge components emitted for unconverted consumer selectors. */
|
|
1054
|
-
bridgeResults?: BridgeComponentResult[];
|
|
1055
|
-
/** Transient prop renames for exported components, keyed by export name. */
|
|
1056
|
-
transientPropRenames?: TransientPropRenameResult[];
|
|
1057
|
-
/** Local styled component names that were actually converted in this file. */
|
|
1058
|
-
transformedComponentNames?: string[];
|
|
1059
|
-
localStylexVarsSidecarFile?: LocalStylexVarsSidecarFile;
|
|
1060
|
-
}
|
|
1061
|
-
/** Describes a transient prop rename on an exported component for consumer patching. */
|
|
1062
|
-
interface TransientPropRenameResult {
|
|
1063
|
-
exportName: string;
|
|
1064
|
-
renames: Record<string, string>;
|
|
1065
|
-
}
|
|
1066
|
-
/** Describes a bridge className emitted for a component targeted by unconverted consumer selectors. */
|
|
1067
|
-
interface BridgeComponentResult {
|
|
1068
|
-
componentName: string;
|
|
1069
|
-
/** The export name (e.g. "default" for default exports, or the named export identifier). */
|
|
1070
|
-
exportName?: string;
|
|
1071
|
-
className: string;
|
|
1072
|
-
globalSelectorVarName: string;
|
|
1073
|
-
}
|
|
1074
|
-
type TransformMode = "all" | "leavesOnly";
|
|
1075
|
-
/**
|
|
1076
|
-
* Options for the transform
|
|
1077
|
-
*/
|
|
1078
|
-
interface TransformOptions extends Options {
|
|
1079
|
-
/**
|
|
1080
|
-
* Adapter for customizing the transform.
|
|
1081
|
-
* Controls value resolution and resolver-provided imports.
|
|
1082
|
-
*/
|
|
1083
|
-
adapter: Adapter;
|
|
1084
|
-
/**
|
|
1085
|
-
* Cross-file selector information from the prepass.
|
|
1086
|
-
* When present, enables cross-file component selector handling.
|
|
1087
|
-
*/
|
|
1088
|
-
crossFileInfo?: CrossFileInfo;
|
|
1089
|
-
/**
|
|
1090
|
-
* When true, individual declarations that hit an unsupported pattern are left
|
|
1091
|
-
* as-is while the rest of the file is transformed. When false (default), any
|
|
1092
|
-
* per-decl bail escalates to a whole-file bail.
|
|
1093
|
-
*/
|
|
1094
|
-
allowPartialMigration?: boolean;
|
|
1095
|
-
/**
|
|
1096
|
-
* Controls which styled declarations are eligible for conversion.
|
|
1097
|
-
* - "all" (default): transform every supported styled declaration.
|
|
1098
|
-
* - "leavesOnly": only transform styled declarations whose render base is
|
|
1099
|
-
* intrinsic after adapter resolution, or that wrap another leaf styled
|
|
1100
|
-
* declaration in the transform run (including cross-file imports).
|
|
1101
|
-
*/
|
|
1102
|
-
transformMode?: TransformMode;
|
|
1103
|
-
/**
|
|
1104
|
-
* From prepass when leaves-only mode is on: keys `${realpath}:${bindingName}` for leaf
|
|
1105
|
-
* styled definitions. An empty set means no leaf bindings were found (per-decl policy
|
|
1106
|
-
* treats all `styled(Component)` bases like missing keys). Used internally by the runner.
|
|
1107
|
-
*/
|
|
1108
|
-
globalLeafKeys?: Set<string>;
|
|
1109
|
-
/**
|
|
1110
|
-
* Module resolver for leaves-only import→definition lookup (`resolve(fromFile, specifier)`).
|
|
1111
|
-
* Set by runTransform.
|
|
1112
|
-
*/
|
|
1113
|
-
resolveModule?: (fromFile: string, specifier: string) => string | undefined;
|
|
1114
|
-
/**
|
|
1115
|
-
* In-memory outputs for files already converted in this run. Used during dry-run
|
|
1116
|
-
* so same-run dependency checks see the same source a real run would write.
|
|
1117
|
-
*/
|
|
1118
|
-
transformedFileSources?: ReadonlyMap<string, string>;
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* Cross-file selector info passed from the prepass to the per-file transform.
|
|
1122
|
-
* Kept minimal: only what the transform needs to know about this specific file.
|
|
1123
|
-
*/
|
|
1124
|
-
interface CrossFileInfo {
|
|
1125
|
-
/** Cross-file selector usages where this file is the consumer */
|
|
1126
|
-
selectorUsages: CrossFileSelectorUsage[];
|
|
1127
|
-
/** Component names in this file that need a global selector bridge className (consumer not transformed) */
|
|
1128
|
-
bridgeComponentNames?: Set<string>;
|
|
1129
|
-
/** Styled component prop usage inventory from the prepass, keyed by local component name. */
|
|
1130
|
-
propUsageByComponent?: Map<string, ComponentPropUsageInfo>;
|
|
1131
|
-
/** Global map: files that define styled-components → set of local names. Used for cascade conflict detection. */
|
|
1132
|
-
styledDefFiles?: Map<string, Set<string>>;
|
|
1133
|
-
/** Global map: files that export components already using StyleX → set of export names. */
|
|
1134
|
-
stylexComponentFiles?: Map<string, Set<string>>;
|
|
1135
|
-
/** Global leaf keys from prepass when leaves-only mode is enabled. */
|
|
1136
|
-
globalLeafKeys?: Set<string>;
|
|
1137
|
-
/** Files successfully converted in the current transform run. Used to avoid bailing on same-run bases. */
|
|
1138
|
-
transformedFiles?: Set<string>;
|
|
1139
|
-
/** File → local styled component names successfully converted in the current transform run. */
|
|
1140
|
-
transformedComponents?: Map<string, Set<string>>;
|
|
1141
|
-
/** Opt-in TypeScript compiler metadata from the prepass. */
|
|
1142
|
-
typeScriptMetadata?: TypeScriptPrepassMetadata;
|
|
1143
|
-
}
|
|
1144
|
-
interface CrossFileSelectorUsage {
|
|
1145
|
-
/** Local name in the consumer file (e.g. "CollapseArrowIcon") */
|
|
1146
|
-
localName: string;
|
|
1147
|
-
/** Raw import specifier (e.g. "./lib/collapse-arrow-icon") */
|
|
1148
|
-
importSource: string;
|
|
1149
|
-
/** Imported binding name ("default" for default imports, otherwise named) */
|
|
1150
|
-
importedName: string;
|
|
1151
|
-
/** Absolute path of the target module */
|
|
1152
|
-
resolvedPath: string;
|
|
1153
|
-
/** Original component name for bridge GlobalSelector (e.g., "Foo" for "FooGlobalSelector") */
|
|
1154
|
-
bridgeComponentName?: string;
|
|
1155
|
-
/** Local name of the actual component in the consumer file (for JSX matching) */
|
|
1156
|
-
bridgeComponentLocalName?: string;
|
|
1157
|
-
}
|
|
1158
|
-
type StaticPropValue = string | number | boolean;
|
|
1159
|
-
interface PropUsageValueInfo {
|
|
1160
|
-
values: StaticPropValue[];
|
|
1161
|
-
hasUnknown: boolean;
|
|
1162
|
-
usageCount: number;
|
|
1163
|
-
omittedCount: number;
|
|
1164
|
-
}
|
|
1165
|
-
interface ComponentPropUsageInfo {
|
|
1166
|
-
componentName: string;
|
|
1167
|
-
usageCount: number;
|
|
1168
|
-
hasUnknownUsage: boolean;
|
|
1169
|
-
props: Record<string, PropUsageValueInfo>;
|
|
1170
|
-
}
|
|
1171
|
-
//#endregion
|
|
1172
|
-
export { CollectedWarning as a, MarkerFileContext as c, TransformResult as i, defineAdapter as l, TransformMode as n, AdapterInput as o, TransformOptions as r, ImportSource as s, BridgeComponentResult as t };
|
|
975
|
+
export { ImportSource as a, AdapterInput as i, WarningLog as n, MarkerFileContext as o, Adapter as r, defineAdapter as s, CollectedWarning as t };
|