/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ import type { PluginPass } from '@babel/core'; import type { NodePath } from '@babel/traverse'; import type { CompiledNamespaces, StyleXOptions as RuntimeOptions, } from '../shared'; import type { FunctionConfig } from './evaluate-path'; import * as t from '@babel/types'; export type ImportPathResolution = | false | ['themeNameRef' | 'filePath', string]; type ModuleResolution = | Readonly<{ type: 'commonJS'; rootDir?: null | undefined | string; themeFileExtension?: null | undefined | string; }> | Readonly<{ type: 'haste'; themeFileExtension?: null | undefined | string }> | Readonly<{ type: 'experimental_crossFileParsing'; rootDir?: string; themeFileExtension?: null | undefined | string; }> | Readonly<{ type: 'custom'; themeFileExtension?: null | undefined | string; filePathResolver: ( importPath: string, sourceFilePath: string, aliases: | null | undefined | Readonly<{ [$$Key$$: string]: ReadonlyArray }>, ) => string | void; getCanonicalFilePath: (filePath: string) => string; }>; export type StyleXOptions = Readonly< Omit< RuntimeOptions, | keyof { aliases?: | null | undefined | Readonly<{ [$$Key$$: string]: string | ReadonlyArray }>; propertyValidationMode?: 'throw' | 'warn' | 'silent'; enableDebugClassNames?: boolean; enableDebugDataProp?: boolean; enableDevClassNames?: boolean; enableInlinedConditionalMerge?: boolean; enableMediaQueryOrder?: boolean; enableLegacyValueFlipping?: boolean; enableLogicalStylesPolyfill?: boolean; enableLTRRTLComments?: boolean; enableMinifiedKeys?: boolean; sxPropName?: string | false; importSources: ReadonlyArray< string | Readonly<{ from: string; as: string }> >; rewriteAliases?: boolean; runtimeInjection: | boolean | (null | undefined | string) | Readonly<{ from: string; as: string }>; treeshakeCompensation?: boolean; unstable_moduleResolution?: null | undefined | ModuleResolution; debugFilePath?: (filePath: string) => string; } > & { aliases?: | null | undefined | Readonly<{ [$$Key$$: string]: string | ReadonlyArray }>; propertyValidationMode?: 'throw' | 'warn' | 'silent'; enableDebugClassNames?: boolean; enableDebugDataProp?: boolean; enableDevClassNames?: boolean; enableInlinedConditionalMerge?: boolean; enableMediaQueryOrder?: boolean; enableLegacyValueFlipping?: boolean; enableLogicalStylesPolyfill?: boolean; enableLTRRTLComments?: boolean; enableMinifiedKeys?: boolean; sxPropName?: string | false; importSources: ReadonlyArray< string | Readonly<{ from: string; as: string }> >; rewriteAliases?: boolean; runtimeInjection: | boolean | (null | undefined | string) | Readonly<{ from: string; as: string }>; treeshakeCompensation?: boolean; unstable_moduleResolution?: null | undefined | ModuleResolution; debugFilePath?: (filePath: string) => string; } >; type StyleXStateOptions = Readonly< Omit< StyleXOptions, | keyof { env: Readonly<{ [$$Key$$: string]: any }>; runtimeInjection: | (null | undefined | string) | Readonly<{ from: string; as: null | undefined | string }>; aliases?: | null | undefined | Readonly<{ [$$Key$$: string]: ReadonlyArray }>; rewriteAliases: boolean; } > & { env: Readonly<{ [$$Key$$: string]: any }>; runtimeInjection: | (null | undefined | string) | Readonly<{ from: string; as: null | undefined | string }>; aliases?: | null | undefined | Readonly<{ [$$Key$$: string]: ReadonlyArray }>; rewriteAliases: boolean; } >; declare class StateManager { readonly _state: PluginPass; readonly importPaths: Set; readonly stylexImport: Set; readonly stylexPropsImport: Set; readonly stylexAttrsImport: Set; readonly stylexCreateImport: Set; readonly stylexIncludeImport: Set; readonly stylexFirstThatWorksImport: Set; readonly stylexKeyframesImport: Set; readonly stylexPositionTryImport: Set; readonly stylexDefineVarsImport: Set; readonly stylexDefineMarkerImport: Set; readonly stylexDefineConstsImport: Set; readonly stylexCreateThemeImport: Set; readonly stylexTypesImport: Set; readonly stylexViewTransitionClassImport: Set; readonly stylexDefaultMarkerImport: Set; readonly stylexWhenImport: Set; readonly stylexEnvImport: Set; readonly stylexDefineVarsNestedImport: Set; readonly stylexDefineConstsNestedImport: Set; readonly stylexCreateThemeNestedImport: Set; readonly stylexConditionalImport: Set; injectImportInserted: null | undefined | t.Identifier; readonly styleMap: Map; readonly styleVars: Map; readonly styleVarsToKeep: Set<[string, true | string, true | Array]>; inStyleXCreate: boolean; readonly options: StyleXStateOptions; constructor(state: PluginPass); setOptions(options: { readonly [$$Key$$: string]: unknown; }): StyleXStateOptions; get importPathString(): string; get importSources(): ReadonlyArray; importAs(source: string): null | string; applyStylexEnv(identifiers: FunctionConfig['identifiers']): void; get canReferenceTheme(): boolean; get metadata(): { [key: string]: any }; get runtimeInjection(): | null | undefined | Readonly<{ from: string; as?: null | undefined | string }>; get opts(): StyleXStateOptions; get isDebug(): boolean; get isDev(): boolean; get isTest(): boolean; get filename(): string | void; get cssVars(): any; get treeshakeCompensation(): boolean; get fileNameForHashing(): null | string; getPackageNameAndPath( filepath: string, ): null | readonly [packageName: string, packageDir: string]; getCanonicalFilePath(filePath: string): string; importPathResolver(importPath: string): ImportPathResolution; addStyle( style: Readonly< [ string, ( | Readonly<{ ltr: string; rtl?: string | null }> | Readonly<{ constKey: string; constVal: string | number; rtl?: string | null; ltr: string; }> ), number, ] >, ): void; registerStyles( styles: ReadonlyArray< Readonly< [ string, ( | Readonly<{ ltr: string; rtl?: string | null }> | Readonly<{ constKey: string; constVal: string | number; rtl?: string | null; ltr: string; }> ), number, ] > >, path?: null | undefined | NodePath, ): void; markComposedNamespace( memberExpression: [string, true | string, true | Array], ): void; } export default StateManager; export declare const filePathResolver: ( relativeFilePath: string, sourceFilePath: string, aliases: StyleXStateOptions['aliases'], ) => null | undefined | string; export declare type filePathResolver = typeof filePathResolver; export declare const EXTENSIONS: any; export declare type EXTENSIONS = typeof EXTENSIONS; export declare const matchesFileSuffix: ( $$PARAM_0$$: string, ) => ($$PARAM_0$$: string) => boolean; export declare type matchesFileSuffix = typeof matchesFileSuffix; export declare function getRelativePath(from: string, to: string): string;