import { n as WarningLog, r as Adapter } from "./logger-Byc7DAuP.mjs"; import { API, FileInfo, Options } from "jscodeshift"; //#region src/internal/prepass/typescript-analysis.d.ts interface TypeScriptPrepassMetadata { version: 1; files: TypeScriptFileMetadata[]; } interface TypeScriptFileMetadata { filePath: string; components: TypeScriptComponentMetadata[]; functions: TypeScriptFunctionMetadata[]; } interface TypeScriptComponentMetadata { name: string; kind: "styled" | "react"; exported: boolean; defaultExport: boolean; typeParameters: string[]; propType: TypeScriptTypeMetadata | null; props: TypeScriptPropMetadata[]; explicitPropNames: string[]; parameters: TypeScriptParameterMetadata[]; restProps: TypeScriptRestPropMetadata[]; hasIndexSignature: boolean; supportsSxProp: boolean; sxTarget?: "root" | "inner"; sxExcludedProperties: string[]; sxAllowedProperties?: string[]; } interface TypeScriptFunctionMetadata { name: string; exported: boolean; defaultExport: boolean; typeParameters: string[]; parameters: TypeScriptParameterMetadata[]; } interface TypeScriptTypeMetadata { text: string; inheritedTypes: string[]; intersectionTypes: string[]; unionTypes: string[]; } interface TypeScriptPropMetadata { name: string; optional: boolean; readonly: boolean; type: string; } interface TypeScriptParameterMetadata { name: string; optional: boolean; rest: boolean; type: string; } interface TypeScriptRestPropMetadata { name: string; source: "parameter" | "destructure"; } //#endregion //#region src/internal/transform-types.d.ts /** A sidecar .stylex.ts file containing defineMarker() declarations. */ interface SidecarFile { content: string; /** Absolute file path for writing. Undefined = default local sidecar next to the source file. */ filePath?: string; } interface LocalStylexVarsSidecarFile { content: string; importPath: string; } /** * Result of the transform including any log entries */ interface TransformResult { code: string | null; warnings: WarningLog[]; /** Sidecar .stylex.ts files (defineMarker declarations). Multiple entries when a file has * both cross-file markers (adapter.markerFile) and internal markers (local sidecar). */ sidecarFiles?: SidecarFile[]; /** Bridge components emitted for unconverted consumer selectors. */ bridgeResults?: BridgeComponentResult[]; /** Transient prop renames for exported components, keyed by export name. */ transientPropRenames?: TransientPropRenameResult[]; /** Local styled component names that were actually converted in this file. */ transformedComponentNames?: string[]; localStylexVarsSidecarFile?: LocalStylexVarsSidecarFile; } /** Describes a transient prop rename on an exported component for consumer patching. */ interface TransientPropRenameResult { exportName: string; renames: Record; } /** Describes a bridge className emitted for a component targeted by unconverted consumer selectors. */ interface BridgeComponentResult { componentName: string; /** The export name (e.g. "default" for default exports, or the named export identifier). */ exportName?: string; className: string; globalSelectorVarName: string; } /** * Options for the transform */ interface TransformOptions extends Options { /** * Adapter for customizing the transform. * Controls value resolution and resolver-provided imports. */ adapter: Adapter; /** * Cross-file selector information from the prepass. * When present, enables cross-file component selector handling. */ crossFileInfo?: CrossFileInfo; /** * When true, individual declarations that hit an unsupported pattern are left * as-is while the rest of the file is transformed. When false (default), any * per-decl bail escalates to a whole-file bail. */ allowPartialMigration?: boolean; /** * Module resolver used by cross-file transform checks (`resolve(fromFile, specifier)`). * Set by runTransform. */ resolveModule?: (fromFile: string, specifier: string) => string | undefined; /** * In-memory outputs for files already converted in this run. Used during dry-run * so same-run dependency checks see the same source a real run would write. */ transformedFileSources?: ReadonlyMap; } /** * Cross-file selector info passed from the prepass to the per-file transform. * Kept minimal: only what the transform needs to know about this specific file. */ interface CrossFileInfo { /** Cross-file selector usages where this file is the consumer */ selectorUsages: CrossFileSelectorUsage[]; /** Component names in this file that need a global selector bridge className (consumer not transformed) */ bridgeComponentNames?: Set; /** Styled component prop usage inventory from the prepass, keyed by local component name. */ propUsageByComponent?: Map; /** Global map: files that define styled-components → set of local names. Used for cascade conflict detection. */ styledDefFiles?: Map>; /** Global map: files that export components already using StyleX → set of export names. */ stylexComponentFiles?: Map>; /** Files successfully converted in the current transform run. Used to avoid bailing on same-run bases. */ transformedFiles?: Set; /** File → local styled component names successfully converted in the current transform run. */ transformedComponents?: Map>; /** Opt-in TypeScript compiler metadata from the prepass. */ typeScriptMetadata?: TypeScriptPrepassMetadata; } interface CrossFileSelectorUsage { /** Local name in the consumer file (e.g. "CollapseArrowIcon") */ localName: string; /** Raw import specifier (e.g. "./lib/collapse-arrow-icon") */ importSource: string; /** Imported binding name ("default" for default imports, otherwise named) */ importedName: string; /** Absolute path of the target module */ resolvedPath: string; /** Original component name for bridge GlobalSelector (e.g., "Foo" for "FooGlobalSelector") */ bridgeComponentName?: string; /** Local name of the actual component in the consumer file (for JSX matching) */ bridgeComponentLocalName?: string; } type StaticPropValue = string | number | boolean; interface PropUsageValueInfo { values: StaticPropValue[]; hasUnknown: boolean; usageCount: number; omittedCount: number; } interface ComponentPropUsageInfo { componentName: string; usageCount: number; hasUnknownUsage: boolean; props: Record; } //#endregion //#region src/transform.d.ts /** * Transform styled-components to StyleX * * This is a sample transform that serves as a starting point. * You'll need to implement the actual transformation logic based on your needs. */ declare function transform(file: FileInfo, api: API, options: Options): string | null; /** * Transform with detailed warnings returned (for testing) */ declare function transformWithWarnings(file: FileInfo, api: API, options: TransformOptions): TransformResult; //#endregion export { type BridgeComponentResult, type TransformOptions, type TransformResult, transform as default, transformWithWarnings };