@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.
- package/README.md +2 -4
- package/flow_modules/@babel/core/index.js.flow +854 -0
- package/flow_modules/@babel/generator/index.js.flow +216 -0
- package/flow_modules/@babel/helper-module-imports/index.js.flow +182 -0
- package/flow_modules/@babel/parser/index.js.flow +253 -0
- package/flow_modules/@babel/traverse/index.js.flow +1003 -0
- package/flow_modules/@babel/types/index.js.flow +5224 -0
- package/lib/babel-path-utils.d.ts +1100 -0
- package/lib/babel-path-utils.js.flow +1108 -0
- package/lib/index.d.ts +46 -0
- package/lib/index.js +4082 -2822
- package/lib/index.js.flow +50 -0
- package/lib/utils/dev-classname.d.ts +26 -0
- package/lib/utils/dev-classname.js.flow +31 -0
- package/lib/utils/evaluate-path.d.ts +29 -0
- package/lib/utils/evaluate-path.js.flow +37 -0
- package/lib/utils/helpers.d.ts +12 -0
- package/lib/utils/helpers.js.flow +10 -0
- package/lib/utils/js-to-ast.d.ts +23 -0
- package/lib/utils/js-to-ast.js.flow +25 -0
- package/lib/utils/state-manager.d.ts +110 -0
- package/lib/utils/state-manager.js.flow +91 -0
- package/lib/visitors/imports.d.ts +20 -0
- package/lib/visitors/imports.js.flow +24 -0
- package/lib/visitors/stylex-create/index.d.ts +17 -0
- package/lib/visitors/stylex-create/index.js.flow +24 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +28 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +30 -0
- package/lib/visitors/stylex-create-theme.d.ts +17 -0
- package/lib/visitors/stylex-create-theme.js.flow +23 -0
- package/lib/visitors/stylex-define-vars.d.ts +17 -0
- package/lib/visitors/stylex-define-vars.js.flow +23 -0
- package/lib/visitors/stylex-keyframes.d.ts +17 -0
- package/lib/visitors/stylex-keyframes.js.flow +23 -0
- package/lib/visitors/stylex-merge.d.ts +21 -0
- package/lib/visitors/stylex-merge.js.flow +25 -0
- package/lib/visitors/stylex-props.d.ts +21 -0
- package/lib/visitors/stylex-props.js.flow +25 -0
- package/package.json +15 -13
|
@@ -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;
|
|
@@ -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 '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
|
+
export declare function skipStylexMergeChildren(
|
|
14
|
+
path: NodePath<t.CallExpression>,
|
|
15
|
+
state: StateManager,
|
|
16
|
+
): void;
|
|
17
|
+
declare function transformStyleXMerge(
|
|
18
|
+
path: NodePath<t.CallExpression>,
|
|
19
|
+
state: StateManager,
|
|
20
|
+
): void;
|
|
21
|
+
export default transformStyleXMerge;
|
|
@@ -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 skipStylexMergeChildren(
|
|
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 transformStyleXMerge(
|
|
23
|
+
path: NodePath<t.CallExpression>,
|
|
24
|
+
state: StateManager,
|
|
25
|
+
): 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 '@babel/traverse';
|
|
11
|
+
import * as t from '@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,30 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"repository": "https://github.com/
|
|
7
|
-
"author": "Naman Goel <nmn@fb.com>",
|
|
6
|
+
"repository": "https://github.com/facebook/stylex",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"scripts": {
|
|
9
|
+
"prebuild": "gen-types -i src/ -o lib/",
|
|
10
10
|
"build": "rollup --config ./rollup.config.mjs",
|
|
11
11
|
"build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
|
|
12
12
|
"test": "jest"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@
|
|
15
|
+
"@babel/helper-module-imports": "^7.22.15",
|
|
16
|
+
"@stylexjs/shared": "0.4.0",
|
|
17
|
+
"@stylexjs/stylex": "0.4.0",
|
|
18
|
+
"@babel/core": "^7.23.6",
|
|
19
|
+
"@babel/traverse": "^7.23.6",
|
|
20
|
+
"@babel/types": "^7.23.6"
|
|
16
21
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"ts-jest": "^29.0.3",
|
|
24
|
-
"ts-node": "^10.8.1",
|
|
25
|
-
"typescript": "^4.7.4"
|
|
22
|
+
"jest": {
|
|
23
|
+
"verbose": true,
|
|
24
|
+
"snapshotFormat": {
|
|
25
|
+
"printBasicPrototype": false
|
|
26
|
+
}
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
29
|
+
"flow_modules/*",
|
|
28
30
|
"lib/*"
|
|
29
31
|
]
|
|
30
32
|
}
|