@stylexjs/babel-plugin 0.2.0-beta.9 → 0.3.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 (40) hide show
  1. package/README.md +1 -1
  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/parser/index.js.flow +253 -0
  5. package/flow_modules/@babel/traverse/index.js.flow +1002 -0
  6. package/flow_modules/@babel/types/index.js.flow +5224 -0
  7. package/lib/babel-path-utils.d.ts +1100 -0
  8. package/lib/babel-path-utils.js.flow +1108 -0
  9. package/lib/index.d.ts +33 -0
  10. package/lib/index.js +3824 -2584
  11. package/lib/index.js.flow +34 -0
  12. package/lib/utils/dev-classname.d.ts +26 -0
  13. package/lib/utils/dev-classname.js.flow +31 -0
  14. package/lib/utils/evaluate-path.d.ts +29 -0
  15. package/lib/utils/evaluate-path.js.flow +37 -0
  16. package/lib/utils/helpers.d.ts +12 -0
  17. package/lib/utils/helpers.js.flow +10 -0
  18. package/lib/utils/js-to-ast.d.ts +23 -0
  19. package/lib/utils/js-to-ast.js.flow +25 -0
  20. package/lib/utils/state-manager.d.ts +73 -0
  21. package/lib/utils/state-manager.js.flow +76 -0
  22. package/lib/visitors/imports.d.ts +20 -0
  23. package/lib/visitors/imports.js.flow +24 -0
  24. package/lib/visitors/stylex-create/index.d.ts +17 -0
  25. package/lib/visitors/stylex-create/index.js.flow +24 -0
  26. package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +28 -0
  27. package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +30 -0
  28. package/lib/visitors/stylex-create-theme.d.ts +17 -0
  29. package/lib/visitors/stylex-create-theme.js.flow +23 -0
  30. package/lib/visitors/stylex-define-vars.d.ts +17 -0
  31. package/lib/visitors/stylex-define-vars.js.flow +23 -0
  32. package/lib/visitors/stylex-keyframes.d.ts +17 -0
  33. package/lib/visitors/stylex-keyframes.js.flow +23 -0
  34. package/lib/visitors/stylex-merge.d.ts +21 -0
  35. package/lib/visitors/stylex-merge.js.flow +25 -0
  36. package/lib/visitors/stylex-override-vars.d.ts +17 -0
  37. package/lib/visitors/stylex-override-vars.js.flow +23 -0
  38. package/lib/visitors/stylex-props.d.ts +21 -0
  39. package/lib/visitors/stylex-props.js.flow +25 -0
  40. package/package.json +12 -7
@@ -0,0 +1,34 @@
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 export default function styleXTransform(): PluginObj<>;
18
+
19
+ /**
20
+ *
21
+ * @param rules An array of CSS rules that has been generated and collected from all JS files
22
+ * in a project
23
+ * @returns A string that represets the final CSS file.
24
+ *
25
+ * This function take an Array of CSS rules, de-duplicates them, sorts them priority and generates
26
+ * a final CSS file.
27
+ *
28
+ * When Stylex is correctly configured, the babel plugin will return an array of CSS rule objects.
29
+ * You're expected to concatenate all the Rules into a single Array and use this function to convert
30
+ * that into the final CSS file.
31
+ *
32
+ * End-users can choose to not use this function and use their own logic instead.
33
+ */
34
+ export type Rule = [string, { ltr: string, rtl?: null | string }, number];
@@ -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,73 @@
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 { PluginPass } from '@babel/core';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import type {
13
+ CompiledNamespaces,
14
+ StyleXOptions as RuntimeOptions,
15
+ } from '@stylexjs/shared';
16
+ export type ImportPathResolution =
17
+ | false
18
+ | ['themeNameRef' | 'filePath', string];
19
+ type ModuleResolution =
20
+ | { type: 'commonJS'; rootDir: string; themeFileExtension?: string }
21
+ | { type: 'haste'; themeFileExtension?: string }
22
+ | {
23
+ type: 'experimental_crossFileParsing';
24
+ rootDir: string;
25
+ themeFileExtension?: string;
26
+ };
27
+ export type StyleXOptions = Omit<
28
+ RuntimeOptions,
29
+ keyof ({
30
+ importSources: Array<string>;
31
+ treeshakeCompensation?: boolean;
32
+ genConditionalClasses: boolean;
33
+ unstable_moduleResolution: void | ModuleResolution;
34
+ })
35
+ > & {
36
+ importSources: Array<string>;
37
+ treeshakeCompensation?: boolean;
38
+ genConditionalClasses: boolean;
39
+ unstable_moduleResolution: void | ModuleResolution;
40
+ };
41
+ declare class StateManager {
42
+ readonly _state: PluginPass;
43
+ readonly importPaths: Set<string>;
44
+ readonly stylexImport: Set<string>;
45
+ readonly stylexPropsImport: Set<string>;
46
+ readonly stylexCreateImport: Set<string>;
47
+ readonly stylexIncludeImport: Set<string>;
48
+ readonly stylexFirstThatWorksImport: Set<string>;
49
+ readonly stylexKeyframesImport: Set<string>;
50
+ readonly stylexDefineVarsImport: Set<string>;
51
+ readonly stylexCreateThemeImport: Set<string>;
52
+ readonly stylexTypesImport: Set<string>;
53
+ readonly styleMap: Map<string, CompiledNamespaces>;
54
+ readonly styleVars: Map<string, NodePath>;
55
+ readonly styleVarsToKeep: Set<[string, null | string]>;
56
+ inStyleXCreate: boolean;
57
+ constructor(state: PluginPass);
58
+ get options(): StyleXOptions;
59
+ get importPathString(): string;
60
+ get canReferenceTheme(): boolean;
61
+ get metadata(): { [key: string]: any };
62
+ get runtimeInjection(): boolean;
63
+ get isDev(): boolean;
64
+ get isTest(): boolean;
65
+ get filename(): string | void;
66
+ get cssVars(): any;
67
+ get treeshakeCompensation(): boolean;
68
+ get fileNameForHashing(): null | string;
69
+ importPathResolver(importPath: string): ImportPathResolution;
70
+ addStyle(style: [string, { ltr: string; rtl?: string | null }, number]): void;
71
+ markComposedNamespace(memberExpression: [string, null | string]): void;
72
+ }
73
+ export default StateManager;
@@ -0,0 +1,76 @@
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 { PluginPass } from '../../flow_modules/@babel/core';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
+ import type {
13
+ CompiledNamespaces,
14
+ StyleXOptions as RuntimeOptions,
15
+ } from '@stylexjs/shared';
16
+ export type ImportPathResolution =
17
+ | false
18
+ | ['themeNameRef' | 'filePath', string];
19
+
20
+ type ModuleResolution =
21
+ | {
22
+ type: 'commonJS',
23
+ rootDir: string,
24
+ themeFileExtension?: string,
25
+ }
26
+ | {
27
+ type: 'haste',
28
+ themeFileExtension?: string,
29
+ }
30
+ | {
31
+ type: 'experimental_crossFileParsing',
32
+ rootDir: string,
33
+ themeFileExtension?: string,
34
+ };
35
+
36
+ export type StyleXOptions = {
37
+ ...RuntimeOptions,
38
+ importSources: Array<string>,
39
+ treeshakeCompensation?: boolean,
40
+ genConditionalClasses: boolean,
41
+ unstable_moduleResolution: void | ModuleResolution,
42
+ ...
43
+ };
44
+
45
+ declare export default class StateManager {
46
+ +_state: PluginPass;
47
+ +importPaths: Set<string>;
48
+ +stylexImport: Set<string>;
49
+ +stylexPropsImport: Set<string>;
50
+ +stylexCreateImport: Set<string>;
51
+ +stylexIncludeImport: Set<string>;
52
+ +stylexFirstThatWorksImport: Set<string>;
53
+ +stylexKeyframesImport: Set<string>;
54
+ +stylexDefineVarsImport: Set<string>;
55
+ +stylexCreateThemeImport: Set<string>;
56
+ +stylexTypesImport: Set<string>;
57
+ +styleMap: Map<string, CompiledNamespaces>;
58
+ +styleVars: Map<string, NodePath<>>;
59
+ +styleVarsToKeep: Set<[string, null | string]>;
60
+ inStyleXCreate: boolean;
61
+ constructor(state: PluginPass): void;
62
+ get options(): StyleXOptions;
63
+ get importPathString(): string;
64
+ get canReferenceTheme(): boolean;
65
+ get metadata(): { [key: string]: any };
66
+ get runtimeInjection(): boolean;
67
+ get isDev(): boolean;
68
+ get isTest(): boolean;
69
+ get filename(): string | void;
70
+ get cssVars(): any;
71
+ get treeshakeCompensation(): boolean;
72
+ get fileNameForHashing(): null | string;
73
+ importPathResolver(importPath: string): ImportPathResolution;
74
+ addStyle(style: [string, { ltr: string, rtl?: string | null }, number]): void;
75
+ markComposedNamespace(memberExpression: [string, null | string]): void;
76
+ }
@@ -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;
@@ -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.defineVars` calls and transforms them.
14
+ //. 1. It finds the first argument to `stylex.defineVars` and validates it.
15
+ /// 2. It envalues the style object to get a JS object. This also handles local constants automatically.
16
+ /// 4. It uses the `stylexDefineVars` 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 transformStyleXDefineVars(
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 transformStyleXKeyframes(
14
+ path: NodePath<t.VariableDeclarator>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXKeyframes;
@@ -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.keyframes` calls and transforms them.
14
+ //. 1. It finds the first argument to `stylex.keyframes` and validates it.
15
+ /// 2. It envalues the style object to get a JS object. This also handles local constants automatically.
16
+ /// 4. It uses the `stylexKeyframes` 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 transformStyleXKeyframes(
21
+ path: NodePath<t.VariableDeclarator>,
22
+ state: StateManager,
23
+ ): void;