@stylexjs/babel-plugin 0.2.0-beta.9 → 0.4.0

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.
Files changed (39) hide show
  1. package/README.md +2 -4
  2. package/flow_modules/@babel/core/index.js.flow +854 -0
  3. package/flow_modules/@babel/generator/index.js.flow +216 -0
  4. package/flow_modules/@babel/helper-module-imports/index.js.flow +182 -0
  5. package/flow_modules/@babel/parser/index.js.flow +253 -0
  6. package/flow_modules/@babel/traverse/index.js.flow +1003 -0
  7. package/flow_modules/@babel/types/index.js.flow +5224 -0
  8. package/lib/babel-path-utils.d.ts +1100 -0
  9. package/lib/babel-path-utils.js.flow +1108 -0
  10. package/lib/index.d.ts +46 -0
  11. package/lib/index.js +4082 -2822
  12. package/lib/index.js.flow +50 -0
  13. package/lib/utils/dev-classname.d.ts +26 -0
  14. package/lib/utils/dev-classname.js.flow +31 -0
  15. package/lib/utils/evaluate-path.d.ts +29 -0
  16. package/lib/utils/evaluate-path.js.flow +37 -0
  17. package/lib/utils/helpers.d.ts +12 -0
  18. package/lib/utils/helpers.js.flow +10 -0
  19. package/lib/utils/js-to-ast.d.ts +23 -0
  20. package/lib/utils/js-to-ast.js.flow +25 -0
  21. package/lib/utils/state-manager.d.ts +110 -0
  22. package/lib/utils/state-manager.js.flow +91 -0
  23. package/lib/visitors/imports.d.ts +20 -0
  24. package/lib/visitors/imports.js.flow +24 -0
  25. package/lib/visitors/stylex-create/index.d.ts +17 -0
  26. package/lib/visitors/stylex-create/index.js.flow +24 -0
  27. package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +28 -0
  28. package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +30 -0
  29. package/lib/visitors/stylex-create-theme.d.ts +17 -0
  30. package/lib/visitors/stylex-create-theme.js.flow +23 -0
  31. package/lib/visitors/stylex-define-vars.d.ts +17 -0
  32. package/lib/visitors/stylex-define-vars.js.flow +23 -0
  33. package/lib/visitors/stylex-keyframes.d.ts +17 -0
  34. package/lib/visitors/stylex-keyframes.js.flow +23 -0
  35. package/lib/visitors/stylex-merge.d.ts +21 -0
  36. package/lib/visitors/stylex-merge.js.flow +25 -0
  37. package/lib/visitors/stylex-props.d.ts +21 -0
  38. package/lib/visitors/stylex-props.js.flow +25 -0
  39. package/package.json +15 -13
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { PluginObj } from '../flow_modules/@babel/core';
11
+ import type { StyleXOptions } from './utils/state-manager';
12
+ export type Options = StyleXOptions;
13
+
14
+ /**
15
+ * Entry point for the StyleX babel plugin.
16
+ */
17
+ declare function styleXTransform(): PluginObj<>;
18
+
19
+ declare function stylexPluginWithOptions(
20
+ options: Partial<StyleXOptions>,
21
+ ): [typeof styleXTransform, Partial<StyleXOptions>];
22
+ /**
23
+ *
24
+ * @param rules An array of CSS rules that has been generated and collected from all JS files
25
+ * in a project
26
+ * @returns A string that represents the final CSS file.
27
+ *
28
+ * This function take an Array of CSS rules, de-duplicates them, sorts them priority and generates
29
+ * a final CSS file.
30
+ *
31
+ * When Stylex is correctly configured, the babel plugin will return an array of CSS rule objects.
32
+ * You're expected to concatenate all the Rules into a single Array and use this function to convert
33
+ * that into the final CSS file.
34
+ *
35
+ * End-users can choose to not use this function and use their own logic instead.
36
+ */
37
+ export type Rule = [string, { ltr: string, rtl?: null | string }, number];
38
+ declare function processStylexRules(
39
+ rules: Array<Rule>,
40
+ useLayers: boolean,
41
+ ): string;
42
+
43
+ export type StyleXTransformObj = $ReadOnly<{
44
+ (): PluginObj<>,
45
+ withOptions: typeof stylexPluginWithOptions,
46
+ processStylexRules: typeof processStylexRules,
47
+ ...
48
+ }>;
49
+
50
+ declare export default StyleXTransformObj;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { CompiledNamespaces } from '@stylexjs/shared';
11
+ import StateManager from './state-manager';
12
+ export declare function namespaceToDevClassName(
13
+ namespace: string,
14
+ varName: null | string,
15
+ filename: string,
16
+ ): string;
17
+ export declare function injectDevClassNames(
18
+ obj: CompiledNamespaces,
19
+ varName: null | string,
20
+ state: StateManager,
21
+ ): CompiledNamespaces;
22
+ export declare function convertToTestStyles(
23
+ obj: CompiledNamespaces,
24
+ varName: null | string,
25
+ state: StateManager,
26
+ ): CompiledNamespaces;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { CompiledNamespaces } from '@stylexjs/shared';
11
+ import StateManager from './state-manager';
12
+
13
+ // TODO: We will need to maintain the full path to the file eventually
14
+ // Perhaps this can be an option that is passed in.
15
+ declare export function namespaceToDevClassName(
16
+ namespace: string,
17
+ varName: null | string,
18
+ filename: string,
19
+ ): string;
20
+
21
+ declare export function injectDevClassNames(
22
+ obj: CompiledNamespaces,
23
+ varName: null | string,
24
+ state: StateManager,
25
+ ): CompiledNamespaces;
26
+
27
+ declare export function convertToTestStyles(
28
+ obj: CompiledNamespaces,
29
+ varName: null | string,
30
+ state: StateManager,
31
+ ): CompiledNamespaces;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+ import StateManager from './state-manager';
12
+ export type FunctionConfig = {
13
+ identifiers: {
14
+ [fnName: string]: { fn: (...args: any[]) => any; takesPath?: boolean };
15
+ };
16
+ memberExpressions: {
17
+ [key: string]: {
18
+ [memberName: string]: {
19
+ fn: (...args: any[]) => any;
20
+ takesPath?: boolean;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ export declare function evaluate(
26
+ path: NodePath,
27
+ traversalState: StateManager,
28
+ functions: FunctionConfig,
29
+ ): Readonly<{ confident: boolean; value: any; deopt?: null | NodePath }>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
11
+ import StateManager from './state-manager';
12
+ export type FunctionConfig = {
13
+ identifiers: {
14
+ [fnName: string]: {
15
+ fn: (...args: any[]) => any,
16
+ takesPath?: boolean,
17
+ },
18
+ },
19
+ memberExpressions: {
20
+ [key: string]: {
21
+ [memberName: string]: {
22
+ fn: (...args: any[]) => any,
23
+ takesPath?: boolean,
24
+ },
25
+ },
26
+ },
27
+ };
28
+
29
+ declare export function evaluate(
30
+ path: NodePath<>,
31
+ traversalState: StateManager,
32
+ functions: FunctionConfig,
33
+ ): $ReadOnly<{
34
+ confident: boolean,
35
+ value: any,
36
+ deopt?: null | NodePath<>,
37
+ }>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ export declare function removeNulls<T>(
11
+ arr: Array<null | undefined | T>,
12
+ ): Array<T>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ declare export function removeNulls<T>(arr: Array<?T>): Array<T>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import { IncludedStyles } from '@stylexjs/shared';
12
+ type NestedStringObject = Readonly<{
13
+ [key: string]:
14
+ | string
15
+ | number
16
+ | null
17
+ | boolean
18
+ | NestedStringObject
19
+ | IncludedStyles;
20
+ }>;
21
+ export declare function convertObjectToAST(
22
+ obj: NestedStringObject,
23
+ ): t.ObjectExpression;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import { IncludedStyles } from '@stylexjs/shared';
12
+
13
+ type NestedStringObject = $ReadOnly<{
14
+ [key: string]:
15
+ | string
16
+ | number
17
+ | null
18
+ | boolean
19
+ | NestedStringObject
20
+ | IncludedStyles,
21
+ }>;
22
+
23
+ declare export function convertObjectToAST(
24
+ obj: NestedStringObject,
25
+ ): t.ObjectExpression;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { PluginPass } from '@babel/core';
12
+ import type { NodePath } from '@babel/traverse';
13
+ import type {
14
+ CompiledNamespaces,
15
+ StyleXOptions as RuntimeOptions,
16
+ } from '@stylexjs/shared';
17
+ export type ImportPathResolution =
18
+ | false
19
+ | ['themeNameRef' | 'filePath', string];
20
+ type ModuleResolution =
21
+ | { type: 'commonJS'; rootDir: string; themeFileExtension?: string }
22
+ | { type: 'haste'; themeFileExtension?: string }
23
+ | {
24
+ type: 'experimental_crossFileParsing';
25
+ rootDir: string;
26
+ themeFileExtension?: string;
27
+ };
28
+ export type StyleXOptions = Readonly<
29
+ Omit<
30
+ RuntimeOptions,
31
+ keyof ({
32
+ importSources: ReadonlyArray<
33
+ string | Readonly<{ from: string; as: string }>
34
+ >;
35
+ runtimeInjection:
36
+ | boolean
37
+ | (null | undefined | string)
38
+ | Readonly<{ from: string; as: string }>;
39
+ treeshakeCompensation?: boolean;
40
+ genConditionalClasses: boolean;
41
+ unstable_moduleResolution: void | ModuleResolution;
42
+ })
43
+ > & {
44
+ importSources: ReadonlyArray<
45
+ string | Readonly<{ from: string; as: string }>
46
+ >;
47
+ runtimeInjection:
48
+ | boolean
49
+ | (null | undefined | string)
50
+ | Readonly<{ from: string; as: string }>;
51
+ treeshakeCompensation?: boolean;
52
+ genConditionalClasses: boolean;
53
+ unstable_moduleResolution: void | ModuleResolution;
54
+ }
55
+ >;
56
+ type StyleXStateOptions = Readonly<
57
+ Omit<
58
+ StyleXOptions,
59
+ keyof ({
60
+ runtimeInjection:
61
+ | (null | undefined | string)
62
+ | Readonly<{ from: string; as: string }>;
63
+ })
64
+ > & {
65
+ runtimeInjection:
66
+ | (null | undefined | string)
67
+ | Readonly<{ from: string; as: string }>;
68
+ }
69
+ >;
70
+ declare class StateManager {
71
+ readonly _state: PluginPass;
72
+ readonly importPaths: Set<string>;
73
+ readonly stylexImport: Set<string>;
74
+ readonly stylexPropsImport: Set<string>;
75
+ readonly stylexCreateImport: Set<string>;
76
+ readonly stylexIncludeImport: Set<string>;
77
+ readonly stylexFirstThatWorksImport: Set<string>;
78
+ readonly stylexKeyframesImport: Set<string>;
79
+ readonly stylexDefineVarsImport: Set<string>;
80
+ readonly stylexCreateThemeImport: Set<string>;
81
+ readonly stylexTypesImport: Set<string>;
82
+ injectImportInserted: null | undefined | t.Identifier;
83
+ readonly styleMap: Map<string, CompiledNamespaces>;
84
+ readonly styleVars: Map<string, NodePath>;
85
+ readonly styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
86
+ inStyleXCreate: boolean;
87
+ constructor(state: PluginPass);
88
+ get options(): StyleXStateOptions;
89
+ get importPathString(): string;
90
+ get importSources(): ReadonlyArray<string>;
91
+ importAs(source: string): null | string;
92
+ get canReferenceTheme(): boolean;
93
+ get metadata(): { [key: string]: any };
94
+ get runtimeInjection():
95
+ | null
96
+ | undefined
97
+ | Readonly<{ from: string; as?: string }>;
98
+ get isDev(): boolean;
99
+ get isTest(): boolean;
100
+ get filename(): string | void;
101
+ get cssVars(): any;
102
+ get treeshakeCompensation(): boolean;
103
+ get fileNameForHashing(): null | string;
104
+ importPathResolver(importPath: string): ImportPathResolution;
105
+ addStyle(style: [string, { ltr: string; rtl?: string | null }, number]): void;
106
+ markComposedNamespace(
107
+ memberExpression: [string, true | string, true | Array<string>],
108
+ ): void;
109
+ }
110
+ export default StateManager;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { PluginPass } from '../../flow_modules/@babel/core';
12
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
13
+ import type {
14
+ CompiledNamespaces,
15
+ StyleXOptions as RuntimeOptions,
16
+ } from '@stylexjs/shared';
17
+ export type ImportPathResolution =
18
+ | false
19
+ | ['themeNameRef' | 'filePath', string];
20
+
21
+ type ModuleResolution =
22
+ | {
23
+ type: 'commonJS',
24
+ rootDir: string,
25
+ themeFileExtension?: string,
26
+ }
27
+ | {
28
+ type: 'haste',
29
+ themeFileExtension?: string,
30
+ }
31
+ | {
32
+ type: 'experimental_crossFileParsing',
33
+ rootDir: string,
34
+ themeFileExtension?: string,
35
+ };
36
+
37
+ export type StyleXOptions = $ReadOnly<{
38
+ ...RuntimeOptions,
39
+ importSources: $ReadOnlyArray<
40
+ string | $ReadOnly<{ from: string, as: string }>,
41
+ >,
42
+ runtimeInjection: boolean | ?string | $ReadOnly<{ from: string, as: string }>,
43
+ treeshakeCompensation?: boolean,
44
+ genConditionalClasses: boolean,
45
+ unstable_moduleResolution: void | ModuleResolution,
46
+ ...
47
+ }>;
48
+
49
+ type StyleXStateOptions = $ReadOnly<{
50
+ ...StyleXOptions,
51
+ runtimeInjection: ?string | $ReadOnly<{ from: string, as: string }>,
52
+ ...
53
+ }>;
54
+
55
+ declare export default class StateManager {
56
+ +_state: PluginPass;
57
+ +importPaths: Set<string>;
58
+ +stylexImport: Set<string>;
59
+ +stylexPropsImport: Set<string>;
60
+ +stylexCreateImport: Set<string>;
61
+ +stylexIncludeImport: Set<string>;
62
+ +stylexFirstThatWorksImport: Set<string>;
63
+ +stylexKeyframesImport: Set<string>;
64
+ +stylexDefineVarsImport: Set<string>;
65
+ +stylexCreateThemeImport: Set<string>;
66
+ +stylexTypesImport: Set<string>;
67
+ injectImportInserted: ?t.Identifier;
68
+ +styleMap: Map<string, CompiledNamespaces>;
69
+ +styleVars: Map<string, NodePath<>>;
70
+ +styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
71
+ inStyleXCreate: boolean;
72
+ constructor(state: PluginPass): void;
73
+ get options(): StyleXStateOptions;
74
+ get importPathString(): string;
75
+ get importSources(): $ReadOnlyArray<string>;
76
+ importAs(source: string): null | string;
77
+ get canReferenceTheme(): boolean;
78
+ get metadata(): { [key: string]: any };
79
+ get runtimeInjection(): ?$ReadOnly<{ from: string, as?: string }>;
80
+ get isDev(): boolean;
81
+ get isTest(): boolean;
82
+ get filename(): string | void;
83
+ get cssVars(): any;
84
+ get treeshakeCompensation(): boolean;
85
+ get fileNameForHashing(): null | string;
86
+ importPathResolver(importPath: string): ImportPathResolution;
87
+ addStyle(style: [string, { ltr: string, rtl?: string | null }, number]): void;
88
+ markComposedNamespace(
89
+ memberExpression: [string, true | string, true | Array<string>],
90
+ ): void;
91
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../utils/state-manager';
13
+ export declare function readImportDeclarations(
14
+ path: NodePath<t.ImportDeclaration>,
15
+ state: StateManager,
16
+ ): void;
17
+ export declare function readRequires(
18
+ path: NodePath<t.VariableDeclarator>,
19
+ state: StateManager,
20
+ ): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
+ import StateManager from '../utils/state-manager';
13
+
14
+ // Read imports of react and remember the name of the local varsiables for later
15
+ declare export function readImportDeclarations(
16
+ path: NodePath<t.ImportDeclaration>,
17
+ state: StateManager,
18
+ ): void;
19
+
20
+ // Read require calls and remember the names of the variables for later
21
+ declare export function readRequires(
22
+ path: NodePath<t.VariableDeclarator>,
23
+ state: StateManager,
24
+ ): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ declare function transformStyleXCreate(
14
+ path: NodePath<t.CallExpression>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXCreate;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ /// This function looks for `stylex.create` calls and transforms them.
14
+ //. 1. It finds the first argument to `stylex.create` and validates it.
15
+ /// 2. It pre-processes valid-dynamic parts of style object such as custom presets (spreads)
16
+ /// 3. It envalues the style object to get a JS object. This also handles local constants automatically.
17
+ /// 4. It uses the `stylexCreate` from `@stylexjs/shared` to transform the JS
18
+ /// object and to get a list of injected styles.
19
+ /// 5. It converts the resulting Object back into an AST and replaces the call with it.
20
+ /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
21
+ declare export default function transformStyleXCreate(
22
+ path: NodePath<t.CallExpression>,
23
+ state: StateManager,
24
+ ): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+ import * as t from '@babel/types';
12
+ import StateManager from '../../utils/state-manager';
13
+ import { type FunctionConfig } from '../../utils/evaluate-path';
14
+ export declare function evaluateStyleXCreateArg(
15
+ path: NodePath,
16
+ traversalState: StateManager,
17
+ functions: FunctionConfig,
18
+ ): Readonly<{
19
+ confident: boolean;
20
+ value: any;
21
+ deopt?: null | NodePath;
22
+ fns?: {
23
+ [$$Key$$: string]: [
24
+ Array<t.Identifier>,
25
+ { readonly [$$Key$$: string]: t.Expression | t.PatternLike },
26
+ ];
27
+ };
28
+ }>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ /* eslint-disable no-unused-vars */
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import * as t from '../../../flow_modules/@babel/types';
13
+ import StateManager from '../../utils/state-manager';
14
+ import { type FunctionConfig } from '../../utils/evaluate-path';
15
+ // This
16
+ declare export function evaluateStyleXCreateArg(
17
+ path: NodePath<>,
18
+ traversalState: StateManager,
19
+ functions: FunctionConfig,
20
+ ): $ReadOnly<{
21
+ confident: boolean,
22
+ value: any,
23
+ deopt?: null | NodePath<>,
24
+ fns?: {
25
+ [string]: [
26
+ Array<t.Identifier>,
27
+ { +[string]: t.Expression | t.PatternLike },
28
+ ],
29
+ },
30
+ }>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../utils/state-manager';
13
+ declare function transformStyleXCreateTheme(
14
+ callExpressionPath: NodePath<t.CallExpression>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXCreateTheme;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
+ import StateManager from '../utils/state-manager';
13
+ /// This function looks for `stylex.createTheme` calls and transforms them.
14
+ //. 1. It finds the first two arguments to `stylex.createTheme` and validates those.
15
+ /// 2. This handles local constants automatically.
16
+ /// 4. It uses the `stylexCreateTheme` from `@stylexjs/shared` to transform the JS
17
+ /// object and to get a list of injected styles.
18
+ /// 5. It converts the resulting Object back into an AST and replaces the call with it.
19
+ /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
20
+ declare export default function transformStyleXCreateTheme(
21
+ callExpressionPath: NodePath<t.CallExpression>,
22
+ state: StateManager,
23
+ ): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../utils/state-manager';
13
+ declare function transformStyleXDefineVars(
14
+ callExpressionPath: NodePath<t.CallExpression>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXDefineVars;