@stylexjs/babel-plugin 0.12.0 → 0.13.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/lib/index.js +3758 -2215
- 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/genCSSRule.d.ts +15 -0
- package/lib/shared/utils/genCSSRule.js.flow +15 -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 +14 -0
- package/lib/utils/evaluate-path.js.flow +15 -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 +34 -6
- package/lib/utils/state-manager.js.flow +34 -5
- package/lib/visitors/imports.d.ts +1 -1
- package/lib/visitors/imports.js.flow +2 -1
- package/lib/visitors/parse-stylex-create-arg.d.ts +37 -0
- package/lib/visitors/parse-stylex-create-arg.js.flow +42 -0
- 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.d.ts +17 -0
- package/lib/visitors/stylex-create.js.flow +24 -0
- package/lib/visitors/stylex-define-consts.d.ts +1 -14
- package/lib/visitors/stylex-define-consts.js.flow +9 -14
- 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 +7 -11
|
@@ -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
|
+
// A bunch of object utils with better Flow types
|
|
11
|
+
|
|
12
|
+
import type { CompiledStyles } from '../common-types';
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
|
15
|
+
type AnyObject = { +[string]: mixed };
|
|
16
|
+
|
|
17
|
+
declare export function isPlainObject(obj: mixed): implies obj is AnyObject;
|
|
18
|
+
|
|
19
|
+
declare export function flattenObject(obj: CompiledStyles): {
|
|
20
|
+
+[string]: null | string,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type _ObjectEntries<Obj: { +[string]: mixed }> = {
|
|
24
|
+
[Key in keyof Obj]: [Key, Obj[Key]],
|
|
25
|
+
};
|
|
26
|
+
type ObjectEntries<Obj: { +[string]: mixed }> = $Values<_ObjectEntries<Obj>>;
|
|
27
|
+
|
|
28
|
+
declare export function objEntries<Obj: { +[string]: mixed }>(
|
|
29
|
+
obj: Obj,
|
|
30
|
+
): $ReadOnlyArray<ObjectEntries<Obj>>;
|
|
31
|
+
|
|
32
|
+
declare export function objValues<Obj: { +[string]: mixed }>(
|
|
33
|
+
obj: Obj,
|
|
34
|
+
): $ReadOnlyArray<Obj[$Keys<Obj>]>;
|
|
35
|
+
|
|
36
|
+
declare export function objFromEntries<K: string | number, V>(
|
|
37
|
+
entries: $ReadOnlyArray<$ReadOnly<[K, V]>>,
|
|
38
|
+
): { [K]: V };
|
|
39
|
+
|
|
40
|
+
declare export function objMapKeys<V, K1: string = string, K2: string = string>(
|
|
41
|
+
obj: { +[K1]: V },
|
|
42
|
+
mapper: (K1) => K2,
|
|
43
|
+
): { +[K2]: V };
|
|
44
|
+
|
|
45
|
+
declare export function objMapEntry<
|
|
46
|
+
V,
|
|
47
|
+
V2,
|
|
48
|
+
K1: string = string,
|
|
49
|
+
K2: string = string,
|
|
50
|
+
>(
|
|
51
|
+
obj: { +[K1]: V },
|
|
52
|
+
mapper: ($ReadOnly<[K1, V]>) => $ReadOnly<[K2, V2]>,
|
|
53
|
+
): { +[K2]: V2 };
|
|
54
|
+
|
|
55
|
+
declare export function objMap<V, V2, K: string = string>(
|
|
56
|
+
obj: { +[K]: V },
|
|
57
|
+
mapper: (V, K) => V2,
|
|
58
|
+
): { +[K]: V2 };
|
|
59
|
+
|
|
60
|
+
declare export class Pipe<T> {
|
|
61
|
+
value: T;
|
|
62
|
+
constructor(val: T): void;
|
|
63
|
+
pipe<T2>(mapper: (T) => T2): Pipe<T2>;
|
|
64
|
+
done(): T;
|
|
65
|
+
static create(val: T): Pipe<T>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Function that sorts an array without mutating it and returns a new array
|
|
69
|
+
declare export const arraySort: <T>(
|
|
70
|
+
arr: $ReadOnlyArray<T>,
|
|
71
|
+
fn?: (T, T) => number,
|
|
72
|
+
) => $ReadOnlyArray<T>;
|
|
73
|
+
|
|
74
|
+
declare export const arrayEquals: <T>(
|
|
75
|
+
arr1: $ReadOnlyArray<T>,
|
|
76
|
+
arr2: $ReadOnlyArray<T>,
|
|
77
|
+
equals: (T, T) => boolean,
|
|
78
|
+
) => boolean;
|
|
@@ -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
|
+
export declare const PSEUDO_CLASS_PRIORITIES: Readonly<{
|
|
11
|
+
[$$Key$$: string]: number;
|
|
12
|
+
}>;
|
|
13
|
+
type AtRulePriorities = { '@supports': 30; '@media': 200; '@container': 300 };
|
|
14
|
+
export declare const AT_RULE_PRIORITIES: Readonly<AtRulePriorities>;
|
|
15
|
+
export declare const PSEUDO_ELEMENT_PRIORITY: number;
|
|
16
|
+
declare function getPriority(key: string): number;
|
|
17
|
+
export default getPriority;
|
|
@@ -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,6 +7,20 @@
|
|
|
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';
|
|
11
25
|
import * as t from '@babel/types';
|
|
12
26
|
import StateManager from './state-manager';
|
|
@@ -7,7 +7,22 @@
|
|
|
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
|
+
|
|
11
26
|
import * as t from '../../flow_modules/@babel/types';
|
|
12
27
|
import StateManager from './state-manager';
|
|
13
28
|
export type FunctionConfig = {
|
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,8 +45,8 @@ export type StyleXOptions = Readonly<
|
|
|
45
45
|
enableDebugClassNames?: boolean;
|
|
46
46
|
enableDebugDataProp?: boolean;
|
|
47
47
|
enableDevClassNames?: boolean;
|
|
48
|
+
enableInlinedConditionalMerge: boolean;
|
|
48
49
|
enableMinifiedKeys?: boolean;
|
|
49
|
-
genConditionalClasses: boolean;
|
|
50
50
|
importSources: ReadonlyArray<
|
|
51
51
|
string | Readonly<{ from: string; as: string }>
|
|
52
52
|
>;
|
|
@@ -66,8 +66,8 @@ export type StyleXOptions = Readonly<
|
|
|
66
66
|
enableDebugClassNames?: boolean;
|
|
67
67
|
enableDebugDataProp?: boolean;
|
|
68
68
|
enableDevClassNames?: boolean;
|
|
69
|
+
enableInlinedConditionalMerge: boolean;
|
|
69
70
|
enableMinifiedKeys?: boolean;
|
|
70
|
-
genConditionalClasses: boolean;
|
|
71
71
|
importSources: ReadonlyArray<
|
|
72
72
|
string | Readonly<{ from: string; as: string }>
|
|
73
73
|
>;
|
|
@@ -114,7 +114,9 @@ declare class StateManager {
|
|
|
114
114
|
readonly stylexIncludeImport: Set<string>;
|
|
115
115
|
readonly stylexFirstThatWorksImport: Set<string>;
|
|
116
116
|
readonly stylexKeyframesImport: Set<string>;
|
|
117
|
+
readonly stylexPositionTryImport: Set<string>;
|
|
117
118
|
readonly stylexDefineVarsImport: Set<string>;
|
|
119
|
+
readonly stylexDefineConstsImport: Set<string>;
|
|
118
120
|
readonly stylexCreateThemeImport: Set<string>;
|
|
119
121
|
readonly stylexTypesImport: Set<string>;
|
|
120
122
|
injectImportInserted: null | undefined | t.Identifier;
|
|
@@ -160,10 +162,36 @@ declare class StateManager {
|
|
|
160
162
|
): null | readonly [packageName: string, packageDir: string];
|
|
161
163
|
getCanonicalFilePath(filePath: string): string;
|
|
162
164
|
importPathResolver(importPath: string): ImportPathResolution;
|
|
163
|
-
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;
|
|
164
180
|
registerStyles(
|
|
165
181
|
styles: ReadonlyArray<
|
|
166
|
-
[
|
|
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
|
+
]
|
|
167
195
|
>,
|
|
168
196
|
path?: null | undefined | NodePath,
|
|
169
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,8 +47,8 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
46
47
|
enableDebugClassNames?: boolean,
|
|
47
48
|
enableDebugDataProp?: boolean,
|
|
48
49
|
enableDevClassNames?: boolean,
|
|
50
|
+
enableInlinedConditionalMerge: boolean,
|
|
49
51
|
enableMinifiedKeys?: boolean,
|
|
50
|
-
genConditionalClasses: boolean,
|
|
51
52
|
importSources: $ReadOnlyArray<
|
|
52
53
|
string | $ReadOnly<{ from: string, as: string }>,
|
|
53
54
|
>,
|
|
@@ -76,7 +77,9 @@ declare export default class StateManager {
|
|
|
76
77
|
+stylexIncludeImport: Set<string>;
|
|
77
78
|
+stylexFirstThatWorksImport: Set<string>;
|
|
78
79
|
+stylexKeyframesImport: Set<string>;
|
|
80
|
+
+stylexPositionTryImport: Set<string>;
|
|
79
81
|
+stylexDefineVarsImport: Set<string>;
|
|
82
|
+
+stylexDefineConstsImport: Set<string>;
|
|
80
83
|
+stylexCreateThemeImport: Set<string>;
|
|
81
84
|
+stylexTypesImport: Set<string>;
|
|
82
85
|
injectImportInserted: ?t.Identifier;
|
|
@@ -117,10 +120,36 @@ declare export default class StateManager {
|
|
|
117
120
|
): null | [+packageName: string, +packageDir: string];
|
|
118
121
|
getCanonicalFilePath(filePath: string): string;
|
|
119
122
|
importPathResolver(importPath: string): ImportPathResolution;
|
|
120
|
-
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;
|
|
121
138
|
registerStyles(
|
|
122
139
|
styles: $ReadOnlyArray<
|
|
123
|
-
[
|
|
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
|
+
],
|
|
124
153
|
>,
|
|
125
154
|
path?: ?NodePath<>,
|
|
126
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
|
|
@@ -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 type { FunctionConfig } from '../utils/evaluate-path';
|
|
12
|
+
import * as t from '@babel/types';
|
|
13
|
+
import StateManager from '../utils/state-manager';
|
|
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
|
+
}>;
|