@stylexjs/babel-plugin 0.13.0 → 0.14.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 +1 -1
- package/lib/babel-path-utils.d.ts +1100 -0
- package/lib/babel-path-utils.js.flow +1108 -0
- package/lib/index.js +528 -175
- package/lib/shared/common-types.d.ts +1 -0
- package/lib/shared/common-types.js.flow +1 -0
- package/lib/shared/messages.d.ts +1 -0
- package/lib/shared/messages.js.flow +2 -0
- package/lib/shared/physical-rtl/generate-ltr.d.ts +2 -0
- package/lib/shared/physical-rtl/generate-ltr.js.flow +2 -0
- package/lib/shared/physical-rtl/generate-rtl.d.ts +2 -0
- package/lib/shared/physical-rtl/generate-rtl.js.flow +2 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +6 -14
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +6 -14
- package/lib/shared/stylex-view-transition-class.d.ts +22 -0
- package/lib/shared/stylex-view-transition-class.js.flow +23 -0
- package/lib/shared/utils/genCSSRule.d.ts +15 -0
- package/lib/shared/utils/genCSSRule.js.flow +15 -0
- package/lib/shared/utils/generate-css-rule.d.ts +2 -1
- package/lib/shared/utils/generate-css-rule.js.flow +2 -2
- package/lib/utils/state-manager.d.ts +5 -2
- package/lib/utils/state-manager.js.flow +3 -1
- package/lib/visitors/stylex-attrs.d.ts +21 -0
- package/lib/visitors/stylex-attrs.js.flow +25 -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 +37 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +41 -0
- package/lib/visitors/stylex-view-transition-class.d.ts +17 -0
- package/lib/visitors/stylex-view-transition-class.js.flow +22 -0
- package/package.json +3 -3
|
@@ -46,6 +46,7 @@ export type StyleXOptions = Readonly<{
|
|
|
46
46
|
enableDebugDataProp?: null | undefined | boolean;
|
|
47
47
|
enableDevClassNames?: null | undefined | boolean;
|
|
48
48
|
enableFontSizePxToRem?: null | undefined | boolean;
|
|
49
|
+
enableLogicalStylesPolyfill?: null | undefined | boolean;
|
|
49
50
|
enableMinifiedKeys?: null | undefined | boolean;
|
|
50
51
|
styleResolution:
|
|
51
52
|
| 'application-order'
|
|
@@ -52,6 +52,7 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
52
52
|
enableDebugDataProp?: ?boolean,
|
|
53
53
|
enableDevClassNames?: ?boolean,
|
|
54
54
|
enableFontSizePxToRem?: ?boolean,
|
|
55
|
+
enableLogicalStylesPolyfill?: ?boolean,
|
|
55
56
|
enableMinifiedKeys?: ?boolean,
|
|
56
57
|
styleResolution:
|
|
57
58
|
| 'application-order' // The last style applied wins.
|
package/lib/shared/messages.d.ts
CHANGED
|
@@ -33,3 +33,4 @@ export declare const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only nam
|
|
|
33
33
|
export declare const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a program.';
|
|
34
34
|
export declare const UNKNOWN_PROP_KEY: 'Unknown property key';
|
|
35
35
|
export declare const POSITION_TRY_INVALID_PROPERTY: 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
|
|
36
|
+
export declare const VIEW_TRANSITION_CLASS_INVALID_PROPERTY: 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
|
|
@@ -38,3 +38,5 @@ declare export const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a
|
|
|
38
38
|
declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
|
|
39
39
|
|
|
40
40
|
declare export const POSITION_TRY_INVALID_PROPERTY: 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
|
|
41
|
+
|
|
42
|
+
declare export const VIEW_TRANSITION_CLASS_INVALID_PROPERTY: 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
|
|
@@ -117,6 +117,8 @@ declare const aliases: {
|
|
|
117
117
|
minInlineSize: (val: TStyleValue) => TReturn;
|
|
118
118
|
maxBlockSize: (val: TStyleValue) => TReturn;
|
|
119
119
|
maxInlineSize: (val: TStyleValue) => TReturn;
|
|
120
|
+
borderStart: (val: TStyleValue) => TReturn;
|
|
121
|
+
borderEnd: (val: TStyleValue) => TReturn;
|
|
120
122
|
borderBlockWidth: any;
|
|
121
123
|
borderBlockStyle: any;
|
|
122
124
|
borderBlockColor: any;
|
|
@@ -129,16 +131,10 @@ declare const aliases: {
|
|
|
129
131
|
borderInlineWidth: any;
|
|
130
132
|
borderInlineStyle: any;
|
|
131
133
|
borderInlineColor: any;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
borderInlineEndStyle: (val: TStyleValue) => TReturn;
|
|
137
|
-
borderInlineEndColor: (val: TStyleValue) => TReturn;
|
|
138
|
-
borderStartStartRadius: (val: TStyleValue) => TReturn;
|
|
139
|
-
borderStartEndRadius: (val: TStyleValue) => TReturn;
|
|
140
|
-
borderEndStartRadius: (val: TStyleValue) => TReturn;
|
|
141
|
-
borderEndEndRadius: (val: TStyleValue) => TReturn;
|
|
134
|
+
borderTopStartRadius: (val: TStyleValue) => TReturn;
|
|
135
|
+
borderTopEndRadius: (val: TStyleValue) => TReturn;
|
|
136
|
+
borderBottomStartRadius: (val: TStyleValue) => TReturn;
|
|
137
|
+
borderBottomEndRadius: (val: TStyleValue) => TReturn;
|
|
142
138
|
gridGap: any;
|
|
143
139
|
gridRowGap: (value: TStyleValue) => TReturn;
|
|
144
140
|
gridColumnGap: (value: TStyleValue) => TReturn;
|
|
@@ -146,16 +142,12 @@ declare const aliases: {
|
|
|
146
142
|
marginBlockStart: (val: TStyleValue) => TReturn;
|
|
147
143
|
marginBlockEnd: (val: TStyleValue) => TReturn;
|
|
148
144
|
marginInline: any;
|
|
149
|
-
marginInlineStart: (val: TStyleValue) => TReturn;
|
|
150
|
-
marginInlineEnd: (val: TStyleValue) => TReturn;
|
|
151
145
|
overflowBlock: (value: TStyleValue) => TReturn;
|
|
152
146
|
overflowInline: (value: TStyleValue) => TReturn;
|
|
153
147
|
paddingBlock: any;
|
|
154
148
|
paddingBlockStart: (val: TStyleValue) => TReturn;
|
|
155
149
|
paddingBlockEnd: (val: TStyleValue) => TReturn;
|
|
156
150
|
paddingInline: any;
|
|
157
|
-
paddingInlineStart: (val: TStyleValue) => TReturn;
|
|
158
|
-
paddingInlineEnd: (val: TStyleValue) => TReturn;
|
|
159
151
|
scrollMarginBlockStart: (value: TStyleValue) => TReturn;
|
|
160
152
|
scrollMarginBlockEnd: (value: TStyleValue) => TReturn;
|
|
161
153
|
};
|
|
@@ -96,6 +96,8 @@ declare const aliases: {
|
|
|
96
96
|
minInlineSize: (val: TStyleValue) => TReturn,
|
|
97
97
|
maxBlockSize: (val: TStyleValue) => TReturn,
|
|
98
98
|
maxInlineSize: (val: TStyleValue) => TReturn,
|
|
99
|
+
borderStart: (val: TStyleValue) => TReturn,
|
|
100
|
+
borderEnd: (val: TStyleValue) => TReturn,
|
|
99
101
|
borderBlockWidth: $FlowFixMe,
|
|
100
102
|
borderBlockStyle: $FlowFixMe,
|
|
101
103
|
borderBlockColor: $FlowFixMe,
|
|
@@ -108,16 +110,10 @@ declare const aliases: {
|
|
|
108
110
|
borderInlineWidth: $FlowFixMe,
|
|
109
111
|
borderInlineStyle: $FlowFixMe,
|
|
110
112
|
borderInlineColor: $FlowFixMe,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
borderInlineEndStyle: (val: TStyleValue) => TReturn,
|
|
116
|
-
borderInlineEndColor: (val: TStyleValue) => TReturn,
|
|
117
|
-
borderStartStartRadius: (val: TStyleValue) => TReturn,
|
|
118
|
-
borderStartEndRadius: (val: TStyleValue) => TReturn,
|
|
119
|
-
borderEndStartRadius: (val: TStyleValue) => TReturn,
|
|
120
|
-
borderEndEndRadius: (val: TStyleValue) => TReturn,
|
|
113
|
+
borderTopStartRadius: (val: TStyleValue) => TReturn,
|
|
114
|
+
borderTopEndRadius: (val: TStyleValue) => TReturn,
|
|
115
|
+
borderBottomStartRadius: (val: TStyleValue) => TReturn,
|
|
116
|
+
borderBottomEndRadius: (val: TStyleValue) => TReturn,
|
|
121
117
|
gridGap: $FlowFixMe,
|
|
122
118
|
gridRowGap: (value: TStyleValue) => TReturn,
|
|
123
119
|
gridColumnGap: (value: TStyleValue) => TReturn,
|
|
@@ -125,16 +121,12 @@ declare const aliases: {
|
|
|
125
121
|
marginBlockStart: (val: TStyleValue) => TReturn,
|
|
126
122
|
marginBlockEnd: (val: TStyleValue) => TReturn,
|
|
127
123
|
marginInline: $FlowFixMe,
|
|
128
|
-
marginInlineStart: (val: TStyleValue) => TReturn,
|
|
129
|
-
marginInlineEnd: (val: TStyleValue) => TReturn,
|
|
130
124
|
overflowBlock: (value: TStyleValue) => TReturn,
|
|
131
125
|
overflowInline: (value: TStyleValue) => TReturn,
|
|
132
126
|
paddingBlock: $FlowFixMe,
|
|
133
127
|
paddingBlockStart: (val: TStyleValue) => TReturn,
|
|
134
128
|
paddingBlockEnd: (val: TStyleValue) => TReturn,
|
|
135
129
|
paddingInline: $FlowFixMe,
|
|
136
|
-
paddingInlineStart: (val: TStyleValue) => TReturn,
|
|
137
|
-
paddingInlineEnd: (val: TStyleValue) => TReturn,
|
|
138
130
|
scrollMarginBlockStart: (value: TStyleValue) => TReturn,
|
|
139
131
|
scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
|
|
140
132
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { InjectableStyle, StyleXOptions } from './common-types';
|
|
11
|
+
type StyleValue = { readonly [$$Key$$: string]: string | number };
|
|
12
|
+
type StyleObj = {
|
|
13
|
+
group?: StyleValue;
|
|
14
|
+
imagePair?: StyleValue;
|
|
15
|
+
old?: StyleValue;
|
|
16
|
+
new?: StyleValue;
|
|
17
|
+
};
|
|
18
|
+
declare function styleXViewTransitionClass(
|
|
19
|
+
styles: StyleObj,
|
|
20
|
+
options: StyleXOptions,
|
|
21
|
+
): [string, InjectableStyle];
|
|
22
|
+
export default styleXViewTransitionClass;
|
|
@@ -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 type { InjectableStyle, StyleXOptions } from './common-types';
|
|
11
|
+
|
|
12
|
+
type StyleValue = { +[string]: string | number };
|
|
13
|
+
type StyleObj = {
|
|
14
|
+
group?: StyleValue,
|
|
15
|
+
imagePair?: StyleValue,
|
|
16
|
+
old?: StyleValue,
|
|
17
|
+
new?: StyleValue,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare export default function styleXViewTransitionClass(
|
|
21
|
+
styles: StyleObj,
|
|
22
|
+
options: StyleXOptions,
|
|
23
|
+
): [string, InjectableStyle];
|
|
@@ -0,0 +1,15 @@
|
|
|
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 genCSSRule(
|
|
11
|
+
className: string,
|
|
12
|
+
decls: string,
|
|
13
|
+
pseudos: ReadonlyArray<string>,
|
|
14
|
+
atRules: ReadonlyArray<string>,
|
|
15
|
+
): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 genCSSRule(
|
|
11
|
+
className: string,
|
|
12
|
+
decls: string,
|
|
13
|
+
pseudos: $ReadOnlyArray<string>,
|
|
14
|
+
atRules: $ReadOnlyArray<string>,
|
|
15
|
+
): string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { InjectableStyle } from '../common-types';
|
|
10
|
+
import type { InjectableStyle, StyleXOptions } from '../common-types';
|
|
11
11
|
export declare function generateCSSRule(
|
|
12
12
|
className: string,
|
|
13
13
|
key: string,
|
|
@@ -15,4 +15,5 @@ export declare function generateCSSRule(
|
|
|
15
15
|
pseudos: ReadonlyArray<string>,
|
|
16
16
|
atRules: ReadonlyArray<string>,
|
|
17
17
|
constRules: ReadonlyArray<string>,
|
|
18
|
+
options: StyleXOptions,
|
|
18
19
|
): InjectableStyle;
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { InjectableStyle } from '../common-types';
|
|
11
|
-
|
|
10
|
+
import type { InjectableStyle, StyleXOptions } from '../common-types';
|
|
12
11
|
declare export function generateCSSRule(
|
|
13
12
|
className: string,
|
|
14
13
|
key: string,
|
|
@@ -16,4 +15,5 @@ declare export function generateCSSRule(
|
|
|
16
15
|
pseudos: $ReadOnlyArray<string>,
|
|
17
16
|
atRules: $ReadOnlyArray<string>,
|
|
18
17
|
constRules: $ReadOnlyArray<string>,
|
|
18
|
+
options: StyleXOptions,
|
|
19
19
|
): InjectableStyle;
|
|
@@ -45,7 +45,8 @@ export type StyleXOptions = Readonly<
|
|
|
45
45
|
enableDebugClassNames?: boolean;
|
|
46
46
|
enableDebugDataProp?: boolean;
|
|
47
47
|
enableDevClassNames?: boolean;
|
|
48
|
-
enableInlinedConditionalMerge
|
|
48
|
+
enableInlinedConditionalMerge?: boolean;
|
|
49
|
+
enableLogicalStylesPolyfill?: boolean;
|
|
49
50
|
enableMinifiedKeys?: boolean;
|
|
50
51
|
importSources: ReadonlyArray<
|
|
51
52
|
string | Readonly<{ from: string; as: string }>
|
|
@@ -66,7 +67,8 @@ export type StyleXOptions = Readonly<
|
|
|
66
67
|
enableDebugClassNames?: boolean;
|
|
67
68
|
enableDebugDataProp?: boolean;
|
|
68
69
|
enableDevClassNames?: boolean;
|
|
69
|
-
enableInlinedConditionalMerge
|
|
70
|
+
enableInlinedConditionalMerge?: boolean;
|
|
71
|
+
enableLogicalStylesPolyfill?: boolean;
|
|
70
72
|
enableMinifiedKeys?: boolean;
|
|
71
73
|
importSources: ReadonlyArray<
|
|
72
74
|
string | Readonly<{ from: string; as: string }>
|
|
@@ -119,6 +121,7 @@ declare class StateManager {
|
|
|
119
121
|
readonly stylexDefineConstsImport: Set<string>;
|
|
120
122
|
readonly stylexCreateThemeImport: Set<string>;
|
|
121
123
|
readonly stylexTypesImport: Set<string>;
|
|
124
|
+
readonly stylexViewTransitionClassImport: Set<string>;
|
|
122
125
|
injectImportInserted: null | undefined | t.Identifier;
|
|
123
126
|
readonly styleMap: Map<string, CompiledNamespaces>;
|
|
124
127
|
readonly styleVars: Map<string, NodePath>;
|
|
@@ -47,7 +47,8 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
47
47
|
enableDebugClassNames?: boolean,
|
|
48
48
|
enableDebugDataProp?: boolean,
|
|
49
49
|
enableDevClassNames?: boolean,
|
|
50
|
-
enableInlinedConditionalMerge
|
|
50
|
+
enableInlinedConditionalMerge?: boolean,
|
|
51
|
+
enableLogicalStylesPolyfill?: boolean,
|
|
51
52
|
enableMinifiedKeys?: boolean,
|
|
52
53
|
importSources: $ReadOnlyArray<
|
|
53
54
|
string | $ReadOnly<{ from: string, as: string }>,
|
|
@@ -82,6 +83,7 @@ declare export default class StateManager {
|
|
|
82
83
|
+stylexDefineConstsImport: Set<string>;
|
|
83
84
|
+stylexCreateThemeImport: Set<string>;
|
|
84
85
|
+stylexTypesImport: Set<string>;
|
|
86
|
+
+stylexViewTransitionClassImport: Set<string>;
|
|
85
87
|
injectImportInserted: ?t.Identifier;
|
|
86
88
|
+styleMap: Map<string, CompiledNamespaces>;
|
|
87
89
|
+styleVars: Map<string, NodePath<>>;
|
|
@@ -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 skipStylexAttrsChildren(
|
|
14
|
+
path: NodePath<t.CallExpression>,
|
|
15
|
+
state: StateManager,
|
|
16
|
+
): void;
|
|
17
|
+
declare function transformStylexAttrs(
|
|
18
|
+
path: NodePath<t.CallExpression>,
|
|
19
|
+
state: StateManager,
|
|
20
|
+
): void;
|
|
21
|
+
export default transformStylexAttrs;
|
|
@@ -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 skipStylexAttrsChildren(
|
|
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 transformStylexAttrs(
|
|
23
|
+
path: NodePath<t.CallExpression>,
|
|
24
|
+
state: StateManager,
|
|
25
|
+
): 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 evaluates 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,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
|
+
*
|
|
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
|
+
type TInlineStyles = {
|
|
15
|
+
[$$Key$$: string]: {
|
|
16
|
+
readonly path: ReadonlyArray<string>;
|
|
17
|
+
readonly originalExpression: t.Expression;
|
|
18
|
+
readonly expression: t.Expression | t.PatternLike;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type DynamicFns = {
|
|
22
|
+
[$$Key$$: string]: readonly [
|
|
23
|
+
params: Array<t.Identifier>,
|
|
24
|
+
inlineStyles: Readonly<TInlineStyles>,
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
export declare function evaluateStyleXCreateArg(
|
|
28
|
+
path: NodePath,
|
|
29
|
+
traversalState: StateManager,
|
|
30
|
+
functions: FunctionConfig,
|
|
31
|
+
): Readonly<{
|
|
32
|
+
confident: boolean;
|
|
33
|
+
value: any;
|
|
34
|
+
deopt?: null | NodePath;
|
|
35
|
+
reason?: string;
|
|
36
|
+
fns?: DynamicFns;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
type TInlineStyles = {
|
|
16
|
+
[string]: {
|
|
17
|
+
+path: $ReadOnlyArray<string>,
|
|
18
|
+
+originalExpression: t.Expression,
|
|
19
|
+
+expression: t.Expression | t.PatternLike,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type DynamicFns = {
|
|
24
|
+
[string]: [
|
|
25
|
+
+params: Array<t.Identifier>,
|
|
26
|
+
+inlineStyles: $ReadOnly<TInlineStyles>,
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// This
|
|
31
|
+
declare export function evaluateStyleXCreateArg(
|
|
32
|
+
path: NodePath<>,
|
|
33
|
+
traversalState: StateManager,
|
|
34
|
+
functions: FunctionConfig,
|
|
35
|
+
): $ReadOnly<{
|
|
36
|
+
confident: boolean,
|
|
37
|
+
value: any,
|
|
38
|
+
deopt?: null | NodePath<>,
|
|
39
|
+
reason?: string,
|
|
40
|
+
fns?: DynamicFns,
|
|
41
|
+
}>;
|
|
@@ -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 type { NodePath } from '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
|
+
declare function transformStyleXViewTransitionClass(
|
|
14
|
+
path: NodePath<t.VariableDeclarator>,
|
|
15
|
+
state: StateManager,
|
|
16
|
+
): void;
|
|
17
|
+
export default transformStyleXViewTransitionClass;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 * as t from '../../flow_modules/@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
|
+
/// This function looks for `stylex.viewTransitionClass` calls within variable declarations and transforms them.
|
|
14
|
+
/// 1. It finds the first argument to `stylex.viewTransitionClass` and validates it.
|
|
15
|
+
/// 2. It evaluates the style object to get a JS object. This also handles local constants automatically.
|
|
16
|
+
/// 3. The actual transform is done by `stylexViewTransitionClass` from `../shared`
|
|
17
|
+
/// 4. The results are replaced, and generated CSS rules are injected as needed.
|
|
18
|
+
|
|
19
|
+
declare export default function transformStyleXViewTransitionClass(
|
|
20
|
+
path: NodePath<t.VariableDeclarator>,
|
|
21
|
+
state: StateManager,
|
|
22
|
+
): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@babel/traverse": "^7.26.8",
|
|
22
22
|
"@babel/types": "^7.26.8",
|
|
23
23
|
"@dual-bundle/import-meta-resolve": "^4.1.0",
|
|
24
|
-
"@stylexjs/stylex": "0.
|
|
24
|
+
"@stylexjs/stylex": "0.14.0",
|
|
25
25
|
"postcss-value-parser": "^4.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@rollup/plugin-replace": "^6.0.1",
|
|
34
34
|
"babel-plugin-syntax-hermes-parser": "^0.26.0",
|
|
35
35
|
"rollup": "^4.24.0",
|
|
36
|
-
"scripts": "0.
|
|
36
|
+
"scripts": "0.14.0"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"flow_modules/*",
|