@stylexjs/babel-plugin 0.0.0-6e16619c

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.
Files changed (151) hide show
  1. package/README.md +33 -0
  2. package/flow_modules/@babel/core/index.js.flow +854 -0
  3. package/flow_modules/@babel/generator/index.js.flow +216 -0
  4. package/flow_modules/@babel/helper-module-imports/index.js.flow +182 -0
  5. package/flow_modules/@babel/parser/index.js.flow +253 -0
  6. package/flow_modules/@babel/traverse/index.js.flow +1007 -0
  7. package/flow_modules/@babel/types/index.js.flow +5225 -0
  8. package/lib/babel-path-utils.d.ts +1100 -0
  9. package/lib/babel-path-utils.js.flow +1108 -0
  10. package/lib/index.d.ts +47 -0
  11. package/lib/index.js +8760 -0
  12. package/lib/index.js.flow +60 -0
  13. package/lib/shared/common-types.d.ts +60 -0
  14. package/lib/shared/common-types.js.flow +74 -0
  15. package/lib/shared/hash.d.ts +12 -0
  16. package/lib/shared/hash.js.flow +12 -0
  17. package/lib/shared/index.d.ts +57 -0
  18. package/lib/shared/index.js.flow +66 -0
  19. package/lib/shared/messages.d.ts +38 -0
  20. package/lib/shared/messages.js.flow +44 -0
  21. package/lib/shared/physical-rtl/generate-ltr.d.ts +15 -0
  22. package/lib/shared/physical-rtl/generate-ltr.js.flow +14 -0
  23. package/lib/shared/physical-rtl/generate-rtl.d.ts +15 -0
  24. package/lib/shared/physical-rtl/generate-rtl.js.flow +14 -0
  25. package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
  26. package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
  27. package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
  28. package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
  29. package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
  30. package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
  31. package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  32. package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  33. package/lib/shared/preprocess-rules/index.d.ts +18 -0
  34. package/lib/shared/preprocess-rules/index.js.flow +22 -0
  35. package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +157 -0
  36. package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +136 -0
  37. package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
  38. package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
  39. package/lib/shared/stylex-consts-utils.d.ts +11 -0
  40. package/lib/shared/stylex-consts-utils.js.flow +14 -0
  41. package/lib/shared/stylex-create-theme.d.ts +26 -0
  42. package/lib/shared/stylex-create-theme.js.flow +19 -0
  43. package/lib/shared/stylex-create.d.ts +27 -0
  44. package/lib/shared/stylex-create.js.flow +37 -0
  45. package/lib/shared/stylex-define-consts.d.ts +23 -0
  46. package/lib/shared/stylex-define-consts.js.flow +19 -0
  47. package/lib/shared/stylex-define-vars.d.ts +28 -0
  48. package/lib/shared/stylex-define-vars.js.flow +26 -0
  49. package/lib/shared/stylex-first-that-works.d.ts +13 -0
  50. package/lib/shared/stylex-first-that-works.js.flow +12 -0
  51. package/lib/shared/stylex-keyframes.d.ts +17 -0
  52. package/lib/shared/stylex-keyframes.js.flow +20 -0
  53. package/lib/shared/stylex-position-try.d.ts +15 -0
  54. package/lib/shared/stylex-position-try.js.flow +18 -0
  55. package/lib/shared/stylex-vars-utils.d.ts +27 -0
  56. package/lib/shared/stylex-vars-utils.js.flow +31 -0
  57. package/lib/shared/stylex-view-transition-class.d.ts +22 -0
  58. package/lib/shared/stylex-view-transition-class.js.flow +23 -0
  59. package/lib/shared/types/index.d.ts +240 -0
  60. package/lib/shared/types/index.js.flow +280 -0
  61. package/lib/shared/utils/Rule.d.ts +58 -0
  62. package/lib/shared/utils/Rule.js.flow +64 -0
  63. package/lib/shared/utils/convert-to-className.d.ts +21 -0
  64. package/lib/shared/utils/convert-to-className.js.flow +29 -0
  65. package/lib/shared/utils/dashify.d.ts +11 -0
  66. package/lib/shared/utils/dashify.js.flow +10 -0
  67. package/lib/shared/utils/default-options.d.ts +11 -0
  68. package/lib/shared/utils/default-options.js.flow +12 -0
  69. package/lib/shared/utils/file-based-identifier.d.ts +15 -0
  70. package/lib/shared/utils/file-based-identifier.js.flow +14 -0
  71. package/lib/shared/utils/genCSSRule.d.ts +15 -0
  72. package/lib/shared/utils/genCSSRule.js.flow +15 -0
  73. package/lib/shared/utils/generate-css-rule.d.ts +19 -0
  74. package/lib/shared/utils/generate-css-rule.js.flow +19 -0
  75. package/lib/shared/utils/normalize-value.d.ts +16 -0
  76. package/lib/shared/utils/normalize-value.js.flow +16 -0
  77. package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  78. package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  79. package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  80. package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  81. package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  82. package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  83. package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
  84. package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
  85. package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
  86. package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
  87. package/lib/shared/utils/normalizers/timings.d.ts +18 -0
  88. package/lib/shared/utils/normalizers/timings.js.flow +17 -0
  89. package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
  90. package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
  91. package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
  92. package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
  93. package/lib/shared/utils/object-utils.d.ts +66 -0
  94. package/lib/shared/utils/object-utils.js.flow +78 -0
  95. package/lib/shared/utils/property-priorities.d.ts +17 -0
  96. package/lib/shared/utils/property-priorities.js.flow +78 -0
  97. package/lib/shared/utils/rule-utils.d.ts +15 -0
  98. package/lib/shared/utils/rule-utils.js.flow +16 -0
  99. package/lib/shared/utils/split-css-value.d.ts +14 -0
  100. package/lib/shared/utils/split-css-value.js.flow +15 -0
  101. package/lib/shared/utils/transform-value.d.ts +22 -0
  102. package/lib/shared/utils/transform-value.js.flow +25 -0
  103. package/lib/shared/validate.d.ts +12 -0
  104. package/lib/shared/validate.js.flow +12 -0
  105. package/lib/utils/add-sourcemap-data.d.ts +23 -0
  106. package/lib/utils/add-sourcemap-data.js.flow +25 -0
  107. package/lib/utils/ast-helpers.d.ts +37 -0
  108. package/lib/utils/ast-helpers.js.flow +44 -0
  109. package/lib/utils/dev-classname.d.ts +26 -0
  110. package/lib/utils/dev-classname.js.flow +32 -0
  111. package/lib/utils/evaluate-path.d.ts +51 -0
  112. package/lib/utils/evaluate-path.js.flow +61 -0
  113. package/lib/utils/evaluation-errors.d.ts +22 -0
  114. package/lib/utils/evaluation-errors.js.flow +35 -0
  115. package/lib/utils/helpers.d.ts +12 -0
  116. package/lib/utils/helpers.js.flow +10 -0
  117. package/lib/utils/js-to-ast.d.ts +20 -0
  118. package/lib/utils/js-to-ast.js.flow +24 -0
  119. package/lib/utils/state-manager.d.ts +203 -0
  120. package/lib/utils/state-manager.js.flow +159 -0
  121. package/lib/utils/validate.d.ts +68 -0
  122. package/lib/utils/validate.js.flow +74 -0
  123. package/lib/visitors/imports.d.ts +20 -0
  124. package/lib/visitors/imports.js.flow +25 -0
  125. package/lib/visitors/parse-stylex-create-arg.d.ts +37 -0
  126. package/lib/visitors/parse-stylex-create-arg.js.flow +42 -0
  127. package/lib/visitors/stylex-attrs.d.ts +21 -0
  128. package/lib/visitors/stylex-attrs.js.flow +25 -0
  129. package/lib/visitors/stylex-create/index.d.ts +17 -0
  130. package/lib/visitors/stylex-create/index.js.flow +24 -0
  131. package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +37 -0
  132. package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +41 -0
  133. package/lib/visitors/stylex-create-theme.d.ts +17 -0
  134. package/lib/visitors/stylex-create-theme.js.flow +23 -0
  135. package/lib/visitors/stylex-create.d.ts +17 -0
  136. package/lib/visitors/stylex-create.js.flow +24 -0
  137. package/lib/visitors/stylex-define-consts.d.ts +17 -0
  138. package/lib/visitors/stylex-define-consts.js.flow +25 -0
  139. package/lib/visitors/stylex-define-vars.d.ts +17 -0
  140. package/lib/visitors/stylex-define-vars.js.flow +23 -0
  141. package/lib/visitors/stylex-keyframes.d.ts +17 -0
  142. package/lib/visitors/stylex-keyframes.js.flow +23 -0
  143. package/lib/visitors/stylex-merge.d.ts +21 -0
  144. package/lib/visitors/stylex-merge.js.flow +25 -0
  145. package/lib/visitors/stylex-position-try.d.ts +17 -0
  146. package/lib/visitors/stylex-position-try.js.flow +22 -0
  147. package/lib/visitors/stylex-props.d.ts +21 -0
  148. package/lib/visitors/stylex-props.js.flow +25 -0
  149. package/lib/visitors/stylex-view-transition-class.d.ts +17 -0
  150. package/lib/visitors/stylex-view-transition-class.js.flow +22 -0
  151. package/package.json +42 -0
@@ -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): 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;
@@ -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
+ *
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+ import type { CompiledNamespaces } from '../shared';
12
+ import * as t from '@babel/types';
13
+ import StateManager from './state-manager';
14
+ /**
15
+ * Adds sourceMap data to objects created with stylex.create.
16
+ * Populates the '$$css' property, which the runtime uses to produce a
17
+ * debug string.
18
+ */
19
+ export declare function addSourceMapData(
20
+ obj: CompiledNamespaces,
21
+ babelPath: NodePath<t.CallExpression>,
22
+ state: StateManager,
23
+ ): CompiledNamespaces;
@@ -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
+ import type { CompiledNamespaces } from '../shared';
12
+
13
+ import * as t from '../../flow_modules/@babel/types';
14
+ import StateManager from './state-manager';
15
+
16
+ /**
17
+ * Adds sourceMap data to objects created with stylex.create.
18
+ * Populates the '$$css' property, which the runtime uses to produce a
19
+ * debug string.
20
+ */
21
+ declare export function addSourceMapData(
22
+ obj: CompiledNamespaces,
23
+ babelPath: NodePath<t.CallExpression>,
24
+ state: StateManager,
25
+ ): CompiledNamespaces;
@@ -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 { ImportOptions } from '@babel/helper-module-imports';
11
+ import type { NodePath } from '@babel/traverse';
12
+ type ImportAdditionOptions = Omit<
13
+ Partial<ImportOptions>,
14
+ 'ensureLiveReference' | 'ensureNoContext'
15
+ >;
16
+ import * as t from '@babel/types';
17
+ export declare function hoistExpression(
18
+ path: NodePath,
19
+ astExpression: t.Expression,
20
+ ): t.Expression;
21
+ export declare function pathReplaceHoisted(
22
+ path: NodePath,
23
+ astExpression: t.Expression,
24
+ ): void;
25
+ export declare function addNamedImport(
26
+ statementPath: NodePath,
27
+ as: string,
28
+ from: string,
29
+ options: ImportAdditionOptions,
30
+ ): t.Identifier;
31
+ export declare function addDefaultImport(
32
+ statementPath: NodePath,
33
+ from: string,
34
+ options: ImportAdditionOptions,
35
+ ): t.Identifier;
36
+ export declare function isProgramLevel(path: NodePath): boolean;
37
+ export declare function getProgramStatement(path: NodePath): NodePath;
@@ -0,0 +1,44 @@
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 { ImportOptions } from '../../flow_modules/@babel/helper-module-imports';
11
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
12
+ type ImportAdditionOptions = Omit<
13
+ Partial<ImportOptions>,
14
+ 'ensureLiveReference' | 'ensureNoContext',
15
+ >;
16
+
17
+ import * as t from '../../flow_modules/@babel/types';
18
+
19
+ declare export function hoistExpression(
20
+ path: NodePath<>,
21
+ astExpression: t.Expression,
22
+ ): t.Expression;
23
+
24
+ declare export function pathReplaceHoisted(
25
+ path: NodePath<>,
26
+ astExpression: t.Expression,
27
+ ): void;
28
+
29
+ declare export function addNamedImport(
30
+ statementPath: NodePath<>,
31
+ as: string,
32
+ from: string,
33
+ options: ImportAdditionOptions,
34
+ ): t.Identifier;
35
+
36
+ declare export function addDefaultImport(
37
+ statementPath: NodePath<>,
38
+ from: string,
39
+ options: ImportAdditionOptions,
40
+ ): t.Identifier;
41
+
42
+ declare export function isProgramLevel(path: NodePath<>): boolean;
43
+
44
+ declare export function getProgramStatement(path: NodePath<>): NodePath<>;
@@ -0,0 +1,26 @@
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 { CompiledNamespaces } from '../shared';
11
+ import StateManager from './state-manager';
12
+ export declare function namespaceToDevClassName(
13
+ namespace: string,
14
+ varName: null | string,
15
+ filename: string,
16
+ ): string;
17
+ export declare function injectDevClassNames(
18
+ obj: CompiledNamespaces,
19
+ varName: null | string,
20
+ state: StateManager,
21
+ ): CompiledNamespaces;
22
+ export declare function convertToTestStyles(
23
+ obj: CompiledNamespaces,
24
+ varName: null | string,
25
+ state: StateManager,
26
+ ): CompiledNamespaces;
@@ -0,0 +1,32 @@
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 { CompiledNamespaces } from '../shared';
11
+
12
+ import StateManager from './state-manager';
13
+
14
+ // TODO: We will need to maintain the full path to the file eventually
15
+ // Perhaps this can be an option that is passed in.
16
+ declare export function namespaceToDevClassName(
17
+ namespace: string,
18
+ varName: null | string,
19
+ filename: string,
20
+ ): string;
21
+
22
+ declare export function injectDevClassNames(
23
+ obj: CompiledNamespaces,
24
+ varName: null | string,
25
+ state: StateManager,
26
+ ): CompiledNamespaces;
27
+
28
+ declare export function convertToTestStyles(
29
+ obj: CompiledNamespaces,
30
+ varName: null | string,
31
+ state: StateManager,
32
+ ): CompiledNamespaces;
@@ -0,0 +1,51 @@
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
+ /**
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
+
24
+ import type { NodePath } from '@babel/traverse';
25
+ import * as t from '@babel/types';
26
+ import StateManager from './state-manager';
27
+ export type FunctionConfig = {
28
+ identifiers: { [fnName: string]: any };
29
+ memberExpressions: {
30
+ [key: string]: {
31
+ [memberName: string]: {
32
+ fn: (...args: any[]) => any;
33
+ takesPath?: boolean;
34
+ };
35
+ };
36
+ };
37
+ };
38
+ type Result =
39
+ | { resolved: true; value: any }
40
+ | { resolved: false; reason: string };
41
+ export declare function evaluate(
42
+ path: NodePath,
43
+ traversalState: StateManager,
44
+ functions: FunctionConfig,
45
+ seen: Map<t.Node, Result>,
46
+ ): Readonly<{
47
+ confident: boolean;
48
+ value: any;
49
+ deopt?: null | NodePath;
50
+ reason?: string;
51
+ }>;
@@ -0,0 +1,61 @@
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
+ /**
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
+
24
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
25
+
26
+ import * as t from '../../flow_modules/@babel/types';
27
+ import StateManager from './state-manager';
28
+ export type FunctionConfig = {
29
+ identifiers: {
30
+ [fnName: string]: $FlowFixMe,
31
+ },
32
+ memberExpressions: {
33
+ [key: string]: {
34
+ [memberName: string]: {
35
+ fn: (...args: $FlowFixMe[]) => $FlowFixMe,
36
+ takesPath?: boolean,
37
+ },
38
+ },
39
+ },
40
+ };
41
+
42
+ type Result =
43
+ | {
44
+ resolved: true,
45
+ value: any,
46
+ }
47
+ | {
48
+ resolved: false,
49
+ reason: string,
50
+ };
51
+ declare export function evaluate(
52
+ path: NodePath<>,
53
+ traversalState: StateManager,
54
+ functions: FunctionConfig,
55
+ seen: Map<t.Node, Result>,
56
+ ): $ReadOnly<{
57
+ confident: boolean,
58
+ value: any,
59
+ deopt?: null | NodePath<>,
60
+ reason?: string,
61
+ }>;
@@ -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
+ export declare const IMPORT_FILE_PARSING_ERROR: any;
11
+ export declare const IMPORT_FILE_EVAL_ERROR: any;
12
+ export declare const DEFAULT_IMPORT: any;
13
+ export declare const PATH_WITHOUT_NODE: any;
14
+ export declare const UNEXPECTED_MEMBER_LOOKUP: any;
15
+ export declare const IMPORT_PATH_RESOLUTION_ERROR: any;
16
+ export declare const NON_CONSTANT: 'Referenced value is not a constant.\n\n';
17
+ export declare const USED_BEFORE_DECLARATION: 'Referenced value is used before declaration.\n\n';
18
+ export declare const UNINITIALIZED_CONST: 'Referenced constant is not initialized.\n\n';
19
+ export declare const UNDEFINED_CONST: 'Referenced constant is not defined.';
20
+ export declare const UNSUPPORTED_OPERATOR: (op: string) => string;
21
+ export declare const OBJECT_METHOD: 'Unsupported object method.\n\n';
22
+ export declare const UNSUPPORTED_EXPRESSION: (type: string) => string;
@@ -0,0 +1,35 @@
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 IMPORT_FILE_PARSING_ERROR: $FlowFixMe;
11
+
12
+ // export const
13
+ declare export const IMPORT_FILE_EVAL_ERROR: $FlowFixMe;
14
+
15
+ declare export const DEFAULT_IMPORT: $FlowFixMe;
16
+
17
+ declare export const PATH_WITHOUT_NODE: $FlowFixMe;
18
+
19
+ declare export const UNEXPECTED_MEMBER_LOOKUP: $FlowFixMe;
20
+
21
+ declare export const IMPORT_PATH_RESOLUTION_ERROR: $FlowFixMe;
22
+
23
+ declare export const NON_CONSTANT: 'Referenced value is not a constant.\n\n';
24
+
25
+ declare export const USED_BEFORE_DECLARATION: 'Referenced value is used before declaration.\n\n';
26
+
27
+ declare export const UNINITIALIZED_CONST: 'Referenced constant is not initialized.\n\n';
28
+
29
+ declare export const UNDEFINED_CONST: 'Referenced constant is not defined.';
30
+
31
+ declare export const UNSUPPORTED_OPERATOR: (op: string) => string;
32
+
33
+ declare export const OBJECT_METHOD: 'Unsupported object method.\n\n';
34
+
35
+ declare export const UNSUPPORTED_EXPRESSION: (type: string) => string;