@stylexjs/babel-plugin 0.2.0-beta.21 → 0.2.0-beta.23

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.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
- import type { NodePath } from '@babel/traverse';
10
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
11
11
  import StateManager from './state-manager';
12
12
  export type FunctionConfig = {
13
13
  identifiers: {
@@ -7,10 +7,16 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
10
+ import * as t from '../../flow_modules/@babel/types';
11
11
  import { IncludedStyles } from '@stylexjs/shared';
12
12
  type NestedStringObject = Readonly<{
13
- [key: string]: string | null | boolean | NestedStringObject | IncludedStyles;
13
+ [key: string]:
14
+ | string
15
+ | number
16
+ | null
17
+ | boolean
18
+ | NestedStringObject
19
+ | IncludedStyles;
14
20
  }>;
15
21
  export declare function convertObjectToAST(
16
22
  obj: NestedStringObject,
@@ -11,7 +11,13 @@ import * as t from '../../flow_modules/@babel/types';
11
11
  import { IncludedStyles } from '@stylexjs/shared';
12
12
 
13
13
  type NestedStringObject = $ReadOnly<{
14
- [key: string]: string | null | boolean | NestedStringObject | IncludedStyles,
14
+ [key: string]:
15
+ | string
16
+ | number
17
+ | null
18
+ | boolean
19
+ | NestedStringObject
20
+ | IncludedStyles,
15
21
  }>;
16
22
 
17
23
  declare export function convertObjectToAST(
@@ -7,8 +7,8 @@
7
7
  *
8
8
  */
9
9
 
10
- import type { PluginPass } from '@babel/core';
11
- import type { NodePath } from '@babel/traverse';
10
+ import type { PluginPass } from '../../flow_modules/@babel/core';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import type {
13
13
  CompiledNamespaces,
14
14
  StyleXOptions as RuntimeOptions,
@@ -39,12 +39,13 @@ type StyleXOptions = Omit<
39
39
  declare class StateManager {
40
40
  readonly _state: PluginPass;
41
41
  readonly stylexImport: Set<string>;
42
+ readonly stylexPropsImport: Set<string>;
42
43
  readonly stylexCreateImport: Set<string>;
43
44
  readonly stylexIncludeImport: Set<string>;
44
45
  readonly stylexFirstThatWorksImport: Set<string>;
45
46
  readonly stylexKeyframesImport: Set<string>;
46
- readonly stylexCreateVarsImport: Set<string>;
47
- readonly stylexOverrideVarsImport: Set<string>;
47
+ readonly stylexDefineVarsImport: Set<string>;
48
+ readonly stylexCreateThemeImport: Set<string>;
48
49
  readonly stylexTypesImport: Set<string>;
49
50
  readonly styleMap: Map<string, CompiledNamespaces>;
50
51
  readonly styleVars: Map<string, NodePath>;
@@ -44,12 +44,13 @@ type StyleXOptions = {
44
44
  declare export default class StateManager {
45
45
  +_state: PluginPass;
46
46
  +stylexImport: Set<string>;
47
+ +stylexPropsImport: Set<string>;
47
48
  +stylexCreateImport: Set<string>;
48
49
  +stylexIncludeImport: Set<string>;
49
50
  +stylexFirstThatWorksImport: Set<string>;
50
51
  +stylexKeyframesImport: Set<string>;
51
- +stylexCreateVarsImport: Set<string>;
52
- +stylexOverrideVarsImport: Set<string>;
52
+ +stylexDefineVarsImport: Set<string>;
53
+ +stylexCreateThemeImport: Set<string>;
53
54
  +stylexTypesImport: Set<string>;
54
55
  +styleMap: Map<string, CompiledNamespaces>;
55
56
  +styleVars: Map<string, NodePath<>>;
@@ -7,8 +7,8 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
13
  export declare function readImportDeclarations(
14
14
  path: NodePath<t.ImportDeclaration>,
@@ -7,8 +7,8 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../../utils/state-manager';
13
13
  declare function transformStyleXCreate(
14
14
  path: NodePath<t.CallExpression>,
@@ -8,8 +8,8 @@
8
8
  * @flow strict
9
9
  */
10
10
 
11
- import type { NodePath } from '@babel/traverse';
12
- import * as t from '@babel/types';
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import * as t from '../../../flow_modules/@babel/types';
13
13
  import StateManager from '../../utils/state-manager';
14
14
  import { type FunctionConfig } from '../../utils/evaluate-path';
15
15
  export declare function evaluateStyleXCreateArg(
@@ -7,11 +7,11 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
- declare function transformStyleXCreate(
14
- path: NodePath<t.CallExpression>,
13
+ declare function transformStyleXCreateTheme(
14
+ callExpressionPath: NodePath<t.CallExpression>,
15
15
  state: StateManager,
16
16
  ): void;
17
- export default transformStyleXCreate;
17
+ export default transformStyleXCreateTheme;
@@ -10,15 +10,14 @@
10
10
  import * as t from '../../flow_modules/@babel/types';
11
11
  import type { NodePath } from '../../flow_modules/@babel/traverse';
12
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
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
18
17
  /// object and to get a list of injected styles.
19
18
  /// 5. It converts the resulting Object back into an AST and replaces the call with it.
20
19
  /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
21
- declare export default function transformStyleXCreate(
22
- path: NodePath<t.CallExpression>,
20
+ declare export default function transformStyleXCreateTheme(
21
+ callExpressionPath: NodePath<t.CallExpression>,
23
22
  state: StateManager,
24
23
  ): void;
@@ -7,11 +7,11 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
- declare function transformStyleXCreateVars(
13
+ declare function transformStyleXDefineVars(
14
14
  callExpressionPath: NodePath<t.CallExpression>,
15
15
  state: StateManager,
16
16
  ): void;
17
- export default transformStyleXCreateVars;
17
+ export default transformStyleXDefineVars;
@@ -10,14 +10,14 @@
10
10
  import * as t from '../../flow_modules/@babel/types';
11
11
  import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
- /// This function looks for `stylex.createVars` calls and transforms them.
14
- //. 1. It finds the first argument to `stylex.createVars` and validates it.
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
15
  /// 2. It envalues the style object to get a JS object. This also handles local constants automatically.
16
- /// 4. It uses the `stylexCreateVars` from `@stylexjs/shared` to transform the JS
16
+ /// 4. It uses the `stylexDefineVars` from `@stylexjs/shared` to transform the JS
17
17
  /// object and to get a list of injected styles.
18
18
  /// 5. It converts the resulting Object back into an AST and replaces the call with it.
19
19
  /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
20
- declare export default function transformStyleXCreateVars(
20
+ declare export default function transformStyleXDefineVars(
21
21
  callExpressionPath: NodePath<t.CallExpression>,
22
22
  state: StateManager,
23
23
  ): void;
@@ -7,8 +7,8 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
13
  declare function transformStyleXKeyframes(
14
14
  path: NodePath<t.VariableDeclarator>,
@@ -7,8 +7,8 @@
7
7
  *
8
8
  */
9
9
 
10
- import type { NodePath } from '@babel/traverse';
11
- import * as t from '@babel/types';
10
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
11
+ import * as t from '../../flow_modules/@babel/types';
12
12
  import StateManager from '../utils/state-manager';
13
13
  export declare function skipStylexMergeChildren(
14
14
  path: NodePath<t.CallExpression>,
@@ -7,11 +7,11 @@
7
7
  *
8
8
  */
9
9
 
10
- import * as t from '@babel/types';
11
- import type { NodePath } from '@babel/traverse';
10
+ import * as t from '../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
- declare function transformStyleXOverrideVars(
13
+ declare function transformStyleXCreateTheme(
14
14
  callExpressionPath: NodePath<t.CallExpression>,
15
15
  state: StateManager,
16
16
  ): void;
17
- export default transformStyleXOverrideVars;
17
+ export default transformStyleXCreateTheme;
@@ -10,14 +10,14 @@
10
10
  import * as t from '../../flow_modules/@babel/types';
11
11
  import type { NodePath } from '../../flow_modules/@babel/traverse';
12
12
  import StateManager from '../utils/state-manager';
13
- /// This function looks for `stylex.unstable_overrideVars` calls and transforms them.
14
- //. 1. It finds the first two arguments to `stylex.unstable_overrideVars` and validates those.
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
15
  /// 2. This handles local constants automatically.
16
- /// 4. It uses the `stylexOverrideVars` from `@stylexjs/shared` to transform the JS
16
+ /// 4. It uses the `stylexCreateTheme` from `@stylexjs/shared` to transform the JS
17
17
  /// object and to get a list of injected styles.
18
18
  /// 5. It converts the resulting Object back into an AST and replaces the call with it.
19
19
  /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
20
- declare export default function transformStyleXOverrideVars(
20
+ declare export default function transformStyleXCreateTheme(
21
21
  callExpressionPath: NodePath<t.CallExpression>,
22
22
  state: StateManager,
23
23
  ): void;
@@ -0,0 +1,21 @@
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 '../../flow_modules/@babel/traverse';
11
+ import * as t from '../../flow_modules/@babel/types';
12
+ import StateManager from '../utils/state-manager';
13
+ export declare function skipStylexPropsChildren(
14
+ path: NodePath<t.CallExpression>,
15
+ state: StateManager,
16
+ ): void;
17
+ declare function transformStylexProps(
18
+ path: NodePath<t.CallExpression>,
19
+ state: StateManager,
20
+ ): void;
21
+ export default transformStylexProps;
@@ -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 type { NodePath } from '../../flow_modules/@babel/traverse';
11
+
12
+ import * as t from '../../flow_modules/@babel/types';
13
+ import StateManager from '../utils/state-manager';
14
+ declare export function skipStylexPropsChildren(
15
+ path: NodePath<t.CallExpression>,
16
+ state: StateManager,
17
+ ): void;
18
+
19
+ // If a `stylex()` call uses styles that are all locally defined,
20
+ // This function is able to pre-compute that into a single string or
21
+ // a single expression of strings and ternary expressions.
22
+ declare export default function transformStylexProps(
23
+ path: NodePath<t.CallExpression>,
24
+ state: StateManager,
25
+ ): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.2.0-beta.21",
3
+ "version": "0.2.0-beta.23",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/facebook/stylex",
@@ -12,7 +12,7 @@
12
12
  "test": "jest"
13
13
  },
14
14
  "dependencies": {
15
- "@stylexjs/shared": "0.2.0-beta.21"
15
+ "@stylexjs/shared": "0.2.0-beta.23"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@babel/core": "^7.19.6",
@@ -1,18 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- * @flow strict
9
- */
10
-
11
- import type { NodePath } from '@babel/traverse';
12
- import StateManager from '../../utils/state-manager';
13
- import { type FunctionConfig } from '../../utils/evaluate-path';
14
- export declare function evaluateStyleFunction(
15
- path: NodePath,
16
- traversalState: StateManager,
17
- functions: FunctionConfig,
18
- ): { confident: boolean; value: any; deopt?: null | NodePath };
@@ -1,23 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- * @flow strict
9
- */
10
-
11
- import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
- import StateManager from '../../utils/state-manager';
13
- import { type FunctionConfig } from '../../utils/evaluate-path';
14
- // This
15
- declare export function evaluateStyleFunction(
16
- path: NodePath<>,
17
- traversalState: StateManager,
18
- functions: FunctionConfig,
19
- ): {
20
- confident: boolean,
21
- value: any,
22
- deopt?: null | NodePath<>,
23
- };