@stylexjs/babel-plugin 0.11.1 → 0.13.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/lib/index.d.ts +2 -1
- package/lib/index.js +3797 -2229
- package/lib/index.js.flow +11 -1
- package/lib/shared/common-types.d.ts +57 -0
- package/lib/shared/common-types.js.flow +71 -0
- package/lib/shared/hash.d.ts +12 -0
- package/lib/shared/hash.js.flow +12 -0
- package/lib/shared/index.d.ts +57 -0
- package/lib/shared/index.js.flow +66 -0
- package/lib/shared/messages.d.ts +35 -0
- package/lib/shared/messages.js.flow +40 -0
- package/lib/shared/physical-rtl/generate-ltr.d.ts +13 -0
- package/lib/shared/physical-rtl/generate-ltr.js.flow +12 -0
- package/lib/shared/physical-rtl/generate-rtl.d.ts +13 -0
- package/lib/shared/physical-rtl/generate-rtl.js.flow +12 -0
- package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
- package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
- package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
- package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
- package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
- package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
- package/lib/shared/preprocess-rules/index.d.ts +18 -0
- package/lib/shared/preprocess-rules/index.js.flow +22 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +165 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +144 -0
- package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
- package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
- package/lib/shared/stylex-consts-utils.d.ts +11 -0
- package/lib/shared/stylex-consts-utils.js.flow +14 -0
- package/lib/shared/stylex-create-theme.d.ts +26 -0
- package/lib/shared/stylex-create-theme.js.flow +19 -0
- package/lib/shared/stylex-create.d.ts +27 -0
- package/lib/shared/stylex-create.js.flow +37 -0
- package/lib/shared/stylex-define-consts.d.ts +23 -0
- package/lib/shared/stylex-define-consts.js.flow +19 -0
- package/lib/shared/stylex-define-vars.d.ts +28 -0
- package/lib/shared/stylex-define-vars.js.flow +26 -0
- package/lib/shared/stylex-first-that-works.d.ts +13 -0
- package/lib/shared/stylex-first-that-works.js.flow +12 -0
- package/lib/shared/stylex-keyframes.d.ts +17 -0
- package/lib/shared/stylex-keyframes.js.flow +20 -0
- package/lib/shared/stylex-position-try.d.ts +15 -0
- package/lib/shared/stylex-position-try.js.flow +18 -0
- package/lib/shared/stylex-vars-utils.d.ts +27 -0
- package/lib/shared/stylex-vars-utils.js.flow +31 -0
- package/lib/shared/types/index.d.ts +240 -0
- package/lib/shared/types/index.js.flow +280 -0
- package/lib/shared/utils/Rule.d.ts +58 -0
- package/lib/shared/utils/Rule.js.flow +64 -0
- package/lib/shared/utils/convert-to-className.d.ts +21 -0
- package/lib/shared/utils/convert-to-className.js.flow +29 -0
- package/lib/shared/utils/dashify.d.ts +11 -0
- package/lib/shared/utils/dashify.js.flow +10 -0
- package/lib/shared/utils/default-options.d.ts +11 -0
- package/lib/shared/utils/default-options.js.flow +12 -0
- package/lib/shared/utils/file-based-identifier.d.ts +15 -0
- package/lib/shared/utils/file-based-identifier.js.flow +14 -0
- package/lib/shared/utils/generate-css-rule.d.ts +18 -0
- package/lib/shared/utils/generate-css-rule.js.flow +19 -0
- package/lib/shared/utils/normalize-value.d.ts +16 -0
- package/lib/shared/utils/normalize-value.js.flow +16 -0
- package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
- package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
- package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
- package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
- package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
- package/lib/shared/utils/normalizers/timings.d.ts +18 -0
- package/lib/shared/utils/normalizers/timings.js.flow +17 -0
- package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
- package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
- package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/shared/utils/object-utils.d.ts +66 -0
- package/lib/shared/utils/object-utils.js.flow +78 -0
- package/lib/shared/utils/property-priorities.d.ts +17 -0
- package/lib/shared/utils/property-priorities.js.flow +78 -0
- package/lib/shared/utils/rule-utils.d.ts +15 -0
- package/lib/shared/utils/rule-utils.js.flow +16 -0
- package/lib/shared/utils/split-css-value.d.ts +14 -0
- package/lib/shared/utils/split-css-value.js.flow +15 -0
- package/lib/shared/utils/transform-value.d.ts +22 -0
- package/lib/shared/utils/transform-value.js.flow +25 -0
- package/lib/shared/validate.d.ts +12 -0
- package/lib/shared/validate.js.flow +12 -0
- package/lib/utils/add-sourcemap-data.d.ts +1 -1
- package/lib/utils/add-sourcemap-data.js.flow +1 -1
- package/lib/utils/dev-classname.d.ts +1 -1
- package/lib/utils/dev-classname.js.flow +2 -1
- package/lib/utils/evaluate-path.d.ts +19 -0
- package/lib/utils/evaluate-path.js.flow +26 -0
- package/lib/utils/js-to-ast.d.ts +1 -1
- package/lib/utils/js-to-ast.js.flow +1 -1
- package/lib/utils/state-manager.d.ts +36 -6
- package/lib/utils/state-manager.js.flow +35 -5
- package/lib/visitors/imports.d.ts +1 -1
- package/lib/visitors/imports.js.flow +2 -1
- package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts} +2 -2
- package/lib/visitors/{stylex-create/parse-stylex-create-arg.js.flow → parse-stylex-create-arg.js.flow} +5 -4
- package/lib/visitors/stylex-create-theme.d.ts +1 -1
- package/lib/visitors/stylex-create-theme.js.flow +1 -1
- package/lib/visitors/{stylex-create/index.d.ts → stylex-create.d.ts} +2 -2
- package/lib/visitors/{stylex-create/index.js.flow → stylex-create.js.flow} +3 -3
- package/lib/visitors/{stylex-attrs.d.ts → stylex-define-consts.d.ts} +3 -7
- package/lib/visitors/stylex-define-consts.js.flow +25 -0
- package/lib/visitors/stylex-define-vars.d.ts +1 -1
- package/lib/visitors/stylex-define-vars.js.flow +1 -1
- package/lib/visitors/stylex-keyframes.d.ts +1 -1
- package/lib/visitors/stylex-keyframes.js.flow +1 -1
- package/lib/visitors/stylex-position-try.d.ts +17 -0
- package/lib/visitors/stylex-position-try.js.flow +22 -0
- package/package.json +11 -12
- package/lib/babel-path-utils.d.ts +0 -1100
- package/lib/babel-path-utils.js.flow +0 -1108
- package/lib/visitors/stylex-attrs.js.flow +0 -25
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
// type PseudoClassPriorities = {
|
|
11
|
+
// ':is': 40,
|
|
12
|
+
// ':where': 40,
|
|
13
|
+
// ':not': 40,
|
|
14
|
+
// ':has': 45,
|
|
15
|
+
// ':dir': 50,
|
|
16
|
+
// ':lang': 51,
|
|
17
|
+
// ':first-child': 52,
|
|
18
|
+
// ':first-of-type': 53,
|
|
19
|
+
// ':last-child': 54,
|
|
20
|
+
// ':last-of-type': 55,
|
|
21
|
+
// ':only-child': 56,
|
|
22
|
+
// ':only-of-type': 57,
|
|
23
|
+
// ':nth-child': 60,
|
|
24
|
+
// ':nth-last-child': 61,
|
|
25
|
+
// ':nth-of-type': 62,
|
|
26
|
+
// ':nth-last-of-type': 63, // 'nth-last-of-type' is the same priority as 'nth-of-type
|
|
27
|
+
// ':empty': 70,
|
|
28
|
+
// ':link': 80,
|
|
29
|
+
// ':any-link': 81,
|
|
30
|
+
// ':local-link': 82,
|
|
31
|
+
// ':target-within': 83,
|
|
32
|
+
// ':target': 84,
|
|
33
|
+
// ':visited': 85,
|
|
34
|
+
// ':enabled': 91,
|
|
35
|
+
// ':disabled': 92,
|
|
36
|
+
// ':required': 93,
|
|
37
|
+
// ':optional': 94,
|
|
38
|
+
// ':read-only': 95,
|
|
39
|
+
// ':read-write': 96,
|
|
40
|
+
// ':placeholder-shown': 97,
|
|
41
|
+
// ':in-range': 98,
|
|
42
|
+
// ':out-of-range': 99,
|
|
43
|
+
// ':default': 100,
|
|
44
|
+
// ':checked': 101,
|
|
45
|
+
// ':indeterminate': 101,
|
|
46
|
+
// ':blank': 102,
|
|
47
|
+
// ':valid': 103,
|
|
48
|
+
// ':invalid': 104,
|
|
49
|
+
// ':user-invalid': 105,
|
|
50
|
+
// ':autofill': 110,
|
|
51
|
+
// ':picture-in-picture': 120,
|
|
52
|
+
// ':modal': 121,
|
|
53
|
+
// ':fullscreen': 122,
|
|
54
|
+
// ':paused': 123,
|
|
55
|
+
// ':playing': 124,
|
|
56
|
+
// ':current': 125,
|
|
57
|
+
// ':past': 126,
|
|
58
|
+
// ':future': 127,
|
|
59
|
+
// ':hover': 130,
|
|
60
|
+
// ':focusWithin': 140,
|
|
61
|
+
// ':focus': 150,
|
|
62
|
+
// ':focusVisible': 160,
|
|
63
|
+
// ':active': 170,
|
|
64
|
+
// };
|
|
65
|
+
|
|
66
|
+
declare export const PSEUDO_CLASS_PRIORITIES: $ReadOnly<{ [string]: number }>;
|
|
67
|
+
|
|
68
|
+
type AtRulePriorities = {
|
|
69
|
+
'@supports': 30,
|
|
70
|
+
'@media': 200,
|
|
71
|
+
'@container': 300,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare export const AT_RULE_PRIORITIES: $ReadOnly<AtRulePriorities>;
|
|
75
|
+
|
|
76
|
+
declare export const PSEUDO_ELEMENT_PRIORITY: number;
|
|
77
|
+
|
|
78
|
+
declare export default function getPriority(key: string): number;
|
|
@@ -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 const sortPseudos: (
|
|
11
|
+
pseudos: ReadonlyArray<string>,
|
|
12
|
+
) => ReadonlyArray<string>;
|
|
13
|
+
export declare const sortAtRules: (
|
|
14
|
+
atRules: ReadonlyArray<string>,
|
|
15
|
+
) => ReadonlyArray<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 const sortPseudos: (
|
|
11
|
+
pseudos: $ReadOnlyArray<string>,
|
|
12
|
+
) => $ReadOnlyArray<string>;
|
|
13
|
+
|
|
14
|
+
declare export const sortAtRules: (
|
|
15
|
+
atRules: $ReadOnlyArray<string>,
|
|
16
|
+
) => $ReadOnlyArray<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { TStyleValue } from '../common-types';
|
|
11
|
+
declare function splitValue(
|
|
12
|
+
str: TStyleValue,
|
|
13
|
+
): ReadonlyArray<number | string | null>;
|
|
14
|
+
export default splitValue;
|
|
@@ -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
|
+
import type { TStyleValue } from '../common-types';
|
|
11
|
+
|
|
12
|
+
// Using split(' ') Isn't enough because of values like calc.
|
|
13
|
+
declare export default function splitValue(
|
|
14
|
+
str: TStyleValue,
|
|
15
|
+
): $ReadOnlyArray<number | string | null>;
|
|
@@ -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 { StyleXOptions } from '../common-types';
|
|
11
|
+
/**
|
|
12
|
+
* Convert a CSS value in JS to the final CSS string value
|
|
13
|
+
*/
|
|
14
|
+
declare function transformValue(
|
|
15
|
+
key: string,
|
|
16
|
+
rawValue: string | number,
|
|
17
|
+
options: StyleXOptions,
|
|
18
|
+
): string;
|
|
19
|
+
export default transformValue;
|
|
20
|
+
export declare function getNumberSuffix(key: string): string;
|
|
21
|
+
export declare const timeUnits: Set<string>;
|
|
22
|
+
export declare const lengthUnits: Set<string>;
|
|
@@ -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 { StyleXOptions } from '../common-types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convert a CSS value in JS to the final CSS string value
|
|
14
|
+
*/
|
|
15
|
+
declare export default function transformValue(
|
|
16
|
+
key: string,
|
|
17
|
+
rawValue: string | number,
|
|
18
|
+
options: StyleXOptions,
|
|
19
|
+
): string;
|
|
20
|
+
|
|
21
|
+
declare export function getNumberSuffix(key: string): string;
|
|
22
|
+
|
|
23
|
+
declare export const timeUnits: Set<string>;
|
|
24
|
+
|
|
25
|
+
declare export const lengthUnits: Set<string>;
|
|
@@ -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
|
+
import type { TRawValue } from './common-types';
|
|
11
|
+
declare function validateEntry($$PARAM_0$$: [string, TRawValue]): void;
|
|
12
|
+
export default validateEntry;
|
|
@@ -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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { TRawValue } from './common-types';
|
|
11
|
+
|
|
12
|
+
declare export default function validateEntry([string, TRawValue]): void;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
|
-
import type { CompiledNamespaces } from '
|
|
11
|
+
import type { CompiledNamespaces } from '../shared';
|
|
12
12
|
import * as t from '@babel/types';
|
|
13
13
|
import StateManager from './state-manager';
|
|
14
14
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
11
|
-
import type { CompiledNamespaces } from '
|
|
11
|
+
import type { CompiledNamespaces } from '../shared';
|
|
12
12
|
|
|
13
13
|
import * as t from '../../flow_modules/@babel/types';
|
|
14
14
|
import StateManager from './state-manager';
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { CompiledNamespaces } from '
|
|
10
|
+
import type { CompiledNamespaces } from '../shared';
|
|
11
|
+
|
|
11
12
|
import StateManager from './state-manager';
|
|
12
13
|
|
|
13
14
|
// TODO: We will need to maintain the full path to the file eventually
|
|
@@ -7,7 +7,22 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* This is a extended version of the path evaluation code from Babel.
|
|
12
|
+
*
|
|
13
|
+
* The original can be found at:
|
|
14
|
+
* https://github.com/babel/babel/blob/main/packages/babel-traverse/src/path/evaluation.ts
|
|
15
|
+
*
|
|
16
|
+
* The following extensions were made:
|
|
17
|
+
* - It can accept a mapping from variable names to functions
|
|
18
|
+
* which when encountered will be evaluated instead of deopting.
|
|
19
|
+
* - The functions can be configured to accept the raw path instead of
|
|
20
|
+
* static values to handle dynamic values.
|
|
21
|
+
* - It can handle object spreads when the spread value itself is statically evaluated.
|
|
22
|
+
*/
|
|
23
|
+
|
|
10
24
|
import type { NodePath } from '@babel/traverse';
|
|
25
|
+
import * as t from '@babel/types';
|
|
11
26
|
import StateManager from './state-manager';
|
|
12
27
|
export type FunctionConfig = {
|
|
13
28
|
identifiers: { [fnName: string]: any };
|
|
@@ -20,10 +35,14 @@ export type FunctionConfig = {
|
|
|
20
35
|
};
|
|
21
36
|
};
|
|
22
37
|
};
|
|
38
|
+
type Result =
|
|
39
|
+
| { resolved: true; value: any }
|
|
40
|
+
| { resolved: false; reason: string };
|
|
23
41
|
export declare function evaluate(
|
|
24
42
|
path: NodePath,
|
|
25
43
|
traversalState: StateManager,
|
|
26
44
|
functions: FunctionConfig,
|
|
45
|
+
seen: Map<t.Node, Result>,
|
|
27
46
|
): Readonly<{
|
|
28
47
|
confident: boolean;
|
|
29
48
|
value: any;
|
|
@@ -7,7 +7,23 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* This is a extended version of the path evaluation code from Babel.
|
|
12
|
+
*
|
|
13
|
+
* The original can be found at:
|
|
14
|
+
* https://github.com/babel/babel/blob/main/packages/babel-traverse/src/path/evaluation.ts
|
|
15
|
+
*
|
|
16
|
+
* The following extensions were made:
|
|
17
|
+
* - It can accept a mapping from variable names to functions
|
|
18
|
+
* which when encountered will be evaluated instead of deopting.
|
|
19
|
+
* - The functions can be configured to accept the raw path instead of
|
|
20
|
+
* static values to handle dynamic values.
|
|
21
|
+
* - It can handle object spreads when the spread value itself is statically evaluated.
|
|
22
|
+
*/
|
|
23
|
+
|
|
10
24
|
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
25
|
+
|
|
26
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
11
27
|
import StateManager from './state-manager';
|
|
12
28
|
export type FunctionConfig = {
|
|
13
29
|
identifiers: {
|
|
@@ -23,10 +39,20 @@ export type FunctionConfig = {
|
|
|
23
39
|
},
|
|
24
40
|
};
|
|
25
41
|
|
|
42
|
+
type Result =
|
|
43
|
+
| {
|
|
44
|
+
resolved: true,
|
|
45
|
+
value: any,
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
resolved: false,
|
|
49
|
+
reason: string,
|
|
50
|
+
};
|
|
26
51
|
declare export function evaluate(
|
|
27
52
|
path: NodePath<>,
|
|
28
53
|
traversalState: StateManager,
|
|
29
54
|
functions: FunctionConfig,
|
|
55
|
+
seen: Map<t.Node, Result>,
|
|
30
56
|
): $ReadOnly<{
|
|
31
57
|
confident: boolean,
|
|
32
58
|
value: any,
|
package/lib/utils/js-to-ast.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { FlatCompiledStyles } from '
|
|
10
|
+
import type { FlatCompiledStyles } from '../shared/common-types';
|
|
11
11
|
import * as t from '@babel/types';
|
|
12
12
|
type NestedStringObject = Readonly<{
|
|
13
13
|
[key: string]: string | number | null | boolean | NestedStringObject;
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '@babel/types';
|
|
11
10
|
import type { PluginPass } from '@babel/core';
|
|
12
11
|
import type { NodePath } from '@babel/traverse';
|
|
13
12
|
import type {
|
|
14
13
|
CompiledNamespaces,
|
|
15
14
|
StyleXOptions as RuntimeOptions,
|
|
16
|
-
} from '
|
|
15
|
+
} from '../shared';
|
|
17
16
|
import type { ImportOptions } from '@babel/helper-module-imports';
|
|
17
|
+
import * as t from '@babel/types';
|
|
18
18
|
type ImportAdditionOptions = Omit<
|
|
19
19
|
Partial<ImportOptions>,
|
|
20
20
|
'ensureLiveReference' | 'ensureNoContext'
|
|
@@ -45,7 +45,8 @@ export type StyleXOptions = Readonly<
|
|
|
45
45
|
enableDebugClassNames?: boolean;
|
|
46
46
|
enableDebugDataProp?: boolean;
|
|
47
47
|
enableDevClassNames?: boolean;
|
|
48
|
-
|
|
48
|
+
enableInlinedConditionalMerge: boolean;
|
|
49
|
+
enableMinifiedKeys?: boolean;
|
|
49
50
|
importSources: ReadonlyArray<
|
|
50
51
|
string | Readonly<{ from: string; as: string }>
|
|
51
52
|
>;
|
|
@@ -65,7 +66,8 @@ export type StyleXOptions = Readonly<
|
|
|
65
66
|
enableDebugClassNames?: boolean;
|
|
66
67
|
enableDebugDataProp?: boolean;
|
|
67
68
|
enableDevClassNames?: boolean;
|
|
68
|
-
|
|
69
|
+
enableInlinedConditionalMerge: boolean;
|
|
70
|
+
enableMinifiedKeys?: boolean;
|
|
69
71
|
importSources: ReadonlyArray<
|
|
70
72
|
string | Readonly<{ from: string; as: string }>
|
|
71
73
|
>;
|
|
@@ -112,7 +114,9 @@ declare class StateManager {
|
|
|
112
114
|
readonly stylexIncludeImport: Set<string>;
|
|
113
115
|
readonly stylexFirstThatWorksImport: Set<string>;
|
|
114
116
|
readonly stylexKeyframesImport: Set<string>;
|
|
117
|
+
readonly stylexPositionTryImport: Set<string>;
|
|
115
118
|
readonly stylexDefineVarsImport: Set<string>;
|
|
119
|
+
readonly stylexDefineConstsImport: Set<string>;
|
|
116
120
|
readonly stylexCreateThemeImport: Set<string>;
|
|
117
121
|
readonly stylexTypesImport: Set<string>;
|
|
118
122
|
injectImportInserted: null | undefined | t.Identifier;
|
|
@@ -158,10 +162,36 @@ declare class StateManager {
|
|
|
158
162
|
): null | readonly [packageName: string, packageDir: string];
|
|
159
163
|
getCanonicalFilePath(filePath: string): string;
|
|
160
164
|
importPathResolver(importPath: string): ImportPathResolution;
|
|
161
|
-
addStyle(
|
|
165
|
+
addStyle(
|
|
166
|
+
style: [
|
|
167
|
+
string,
|
|
168
|
+
(
|
|
169
|
+
| { ltr: string; rtl?: string | null }
|
|
170
|
+
| {
|
|
171
|
+
constKey: string;
|
|
172
|
+
constVal: string | number;
|
|
173
|
+
rtl?: string | null;
|
|
174
|
+
ltr: string;
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
number,
|
|
178
|
+
],
|
|
179
|
+
): void;
|
|
162
180
|
registerStyles(
|
|
163
181
|
styles: ReadonlyArray<
|
|
164
|
-
[
|
|
182
|
+
[
|
|
183
|
+
string,
|
|
184
|
+
(
|
|
185
|
+
| { ltr: string; rtl?: string | null }
|
|
186
|
+
| {
|
|
187
|
+
constKey: string;
|
|
188
|
+
constVal: string | number;
|
|
189
|
+
rtl?: string | null;
|
|
190
|
+
ltr: string;
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
number,
|
|
194
|
+
]
|
|
165
195
|
>,
|
|
166
196
|
path?: null | undefined | NodePath,
|
|
167
197
|
): void;
|
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '../../flow_modules/@babel/types';
|
|
11
10
|
import type { PluginPass } from '../../flow_modules/@babel/core';
|
|
12
11
|
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
13
12
|
import type {
|
|
14
13
|
CompiledNamespaces,
|
|
15
14
|
StyleXOptions as RuntimeOptions,
|
|
16
|
-
} from '
|
|
15
|
+
} from '../shared';
|
|
17
16
|
import type { ImportOptions } from '../../flow_modules/@babel/helper-module-imports';
|
|
17
|
+
|
|
18
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
18
19
|
type ImportAdditionOptions = Omit<
|
|
19
20
|
Partial<ImportOptions>,
|
|
20
21
|
'ensureLiveReference' | 'ensureNoContext',
|
|
@@ -46,7 +47,8 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
46
47
|
enableDebugClassNames?: boolean,
|
|
47
48
|
enableDebugDataProp?: boolean,
|
|
48
49
|
enableDevClassNames?: boolean,
|
|
49
|
-
|
|
50
|
+
enableInlinedConditionalMerge: boolean,
|
|
51
|
+
enableMinifiedKeys?: boolean,
|
|
50
52
|
importSources: $ReadOnlyArray<
|
|
51
53
|
string | $ReadOnly<{ from: string, as: string }>,
|
|
52
54
|
>,
|
|
@@ -75,7 +77,9 @@ declare export default class StateManager {
|
|
|
75
77
|
+stylexIncludeImport: Set<string>;
|
|
76
78
|
+stylexFirstThatWorksImport: Set<string>;
|
|
77
79
|
+stylexKeyframesImport: Set<string>;
|
|
80
|
+
+stylexPositionTryImport: Set<string>;
|
|
78
81
|
+stylexDefineVarsImport: Set<string>;
|
|
82
|
+
+stylexDefineConstsImport: Set<string>;
|
|
79
83
|
+stylexCreateThemeImport: Set<string>;
|
|
80
84
|
+stylexTypesImport: Set<string>;
|
|
81
85
|
injectImportInserted: ?t.Identifier;
|
|
@@ -116,10 +120,36 @@ declare export default class StateManager {
|
|
|
116
120
|
): null | [+packageName: string, +packageDir: string];
|
|
117
121
|
getCanonicalFilePath(filePath: string): string;
|
|
118
122
|
importPathResolver(importPath: string): ImportPathResolution;
|
|
119
|
-
addStyle(
|
|
123
|
+
addStyle(
|
|
124
|
+
style: [
|
|
125
|
+
string,
|
|
126
|
+
(
|
|
127
|
+
| { ltr: string, rtl?: string | null }
|
|
128
|
+
| {
|
|
129
|
+
constKey: string,
|
|
130
|
+
constVal: string | number,
|
|
131
|
+
rtl?: string | null,
|
|
132
|
+
ltr: string,
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
number,
|
|
136
|
+
],
|
|
137
|
+
): void;
|
|
120
138
|
registerStyles(
|
|
121
139
|
styles: $ReadOnlyArray<
|
|
122
|
-
[
|
|
140
|
+
[
|
|
141
|
+
string,
|
|
142
|
+
(
|
|
143
|
+
| { ltr: string, rtl?: string | null }
|
|
144
|
+
| {
|
|
145
|
+
constKey: string,
|
|
146
|
+
constVal: string | number,
|
|
147
|
+
rtl?: string | null,
|
|
148
|
+
ltr: string,
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
number,
|
|
152
|
+
],
|
|
123
153
|
>,
|
|
124
154
|
path?: ?NodePath<>,
|
|
125
155
|
): void;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '@babel/types';
|
|
11
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
12
|
import StateManager from '../utils/state-manager';
|
|
13
13
|
export declare function readImportDeclarations(
|
|
14
14
|
path: NodePath<t.ImportDeclaration>,
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '../../flow_modules/@babel/types';
|
|
11
10
|
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
11
|
+
|
|
12
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
12
13
|
import StateManager from '../utils/state-manager';
|
|
13
14
|
|
|
14
15
|
// Read imports of react and remember the name of the local variables for later
|
package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts}
RENAMED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
|
+
import type { FunctionConfig } from '../utils/evaluate-path';
|
|
11
12
|
import * as t from '@babel/types';
|
|
12
|
-
import StateManager from '
|
|
13
|
-
import { type FunctionConfig } from '../../utils/evaluate-path';
|
|
13
|
+
import StateManager from '../utils/state-manager';
|
|
14
14
|
type TInlineStyles = {
|
|
15
15
|
[$$Key$$: string]: {
|
|
16
16
|
readonly path: ReadonlyArray<string>;
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/* eslint-disable no-unused-vars */
|
|
11
|
-
import type { NodePath } from '
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import
|
|
11
|
+
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
12
|
+
import type { FunctionConfig } from '../utils/evaluate-path';
|
|
13
|
+
|
|
14
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
15
|
+
import StateManager from '../utils/state-manager';
|
|
15
16
|
type TInlineStyles = {
|
|
16
17
|
[string]: {
|
|
17
18
|
+path: $ReadOnlyArray<string>,
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '@babel/types';
|
|
11
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
12
|
import StateManager from '../utils/state-manager';
|
|
13
13
|
declare function transformStyleXCreateTheme(
|
|
14
14
|
callExpressionPath: NodePath<t.CallExpression>,
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '../../flow_modules/@babel/types';
|
|
11
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
|
/// This function looks for `stylex.createTheme` calls and transforms them.
|
|
14
14
|
/// 1. It finds the first two arguments to `stylex.createTheme` and validates those.
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import * as t from '@babel/types';
|
|
11
10
|
import type { NodePath } from '@babel/traverse';
|
|
12
|
-
import
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
13
|
declare function transformStyleXCreate(
|
|
14
14
|
path: NodePath<t.CallExpression>,
|
|
15
15
|
state: StateManager,
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import StateManager from '
|
|
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
13
|
/// This function looks for `stylex.create` calls and transforms them.
|
|
14
14
|
/// 1. It finds the first argument to `stylex.create` and validates it.
|
|
15
15
|
/// 2. It pre-processes valid-dynamic parts of style object such as custom presets (spreads)
|
|
@@ -10,12 +10,8 @@
|
|
|
10
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
11
|
import * as t from '@babel/types';
|
|
12
12
|
import StateManager from '../utils/state-manager';
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
declare function transformStyleXDefineConsts(
|
|
14
|
+
callExpressionPath: NodePath<t.CallExpression>,
|
|
15
15
|
state: StateManager,
|
|
16
16
|
): void;
|
|
17
|
-
|
|
18
|
-
path: NodePath<t.CallExpression>,
|
|
19
|
-
state: StateManager,
|
|
20
|
-
): void;
|
|
21
|
-
export default transformStylexAttrs;
|
|
17
|
+
export default transformStyleXDefineConsts;
|