@stylexjs/babel-plugin 0.13.1 → 0.14.1
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/index.js +544 -179
- package/lib/shared/common-types.d.ts +1 -0
- package/lib/shared/common-types.js.flow +1 -0
- package/lib/shared/messages.d.ts +2 -0
- package/lib/shared/messages.js.flow +3 -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/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-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
|
@@ -15,6 +15,7 @@ export declare const nonStaticValue: (fn: string) => string;
|
|
|
15
15
|
export declare const nonStyleObject: (fn: string) => string;
|
|
16
16
|
export declare const nonExportNamedDeclaration: (fn: string) => string;
|
|
17
17
|
export declare const unboundCallValue: (fn: string) => string;
|
|
18
|
+
export declare const cannotGenerateHash: (fn: string) => string;
|
|
18
19
|
export declare const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
19
20
|
export declare const ESCAPED_STYLEX_VALUE: 'Escaping a create() value is not allowed.';
|
|
20
21
|
export declare const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
|
|
@@ -33,3 +34,4 @@ export declare const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only nam
|
|
|
33
34
|
export declare const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a program.';
|
|
34
35
|
export declare const UNKNOWN_PROP_KEY: 'Unknown property key';
|
|
35
36
|
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)';
|
|
37
|
+
export declare const VIEW_TRANSITION_CLASS_INVALID_PROPERTY: 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
|
|
@@ -18,6 +18,7 @@ declare export const nonStaticValue: (fn: string) => string;
|
|
|
18
18
|
declare export const nonStyleObject: (fn: string) => string;
|
|
19
19
|
declare export const nonExportNamedDeclaration: (fn: string) => string;
|
|
20
20
|
declare export const unboundCallValue: (fn: string) => string;
|
|
21
|
+
declare export const cannotGenerateHash: (fn: string) => string;
|
|
21
22
|
|
|
22
23
|
declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
23
24
|
declare export const ESCAPED_STYLEX_VALUE: 'Escaping a create() value is not allowed.';
|
|
@@ -38,3 +39,5 @@ declare export const ONLY_TOP_LEVEL: 'create() is only allowed at the root of a
|
|
|
38
39
|
declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
|
|
39
40
|
|
|
40
41
|
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)';
|
|
42
|
+
|
|
43
|
+
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];
|
|
@@ -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,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.1",
|
|
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.1",
|
|
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.1"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"flow_modules/*",
|