@stylexjs/babel-plugin 0.12.0 → 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.
Files changed (120) hide show
  1. package/lib/index.js +3758 -2215
  2. package/lib/index.js.flow +11 -1
  3. package/lib/shared/common-types.d.ts +57 -0
  4. package/lib/shared/common-types.js.flow +71 -0
  5. package/lib/shared/hash.d.ts +12 -0
  6. package/lib/shared/hash.js.flow +12 -0
  7. package/lib/shared/index.d.ts +57 -0
  8. package/lib/shared/index.js.flow +66 -0
  9. package/lib/shared/messages.d.ts +35 -0
  10. package/lib/shared/messages.js.flow +40 -0
  11. package/lib/shared/physical-rtl/generate-ltr.d.ts +13 -0
  12. package/lib/shared/physical-rtl/generate-ltr.js.flow +12 -0
  13. package/lib/shared/physical-rtl/generate-rtl.d.ts +13 -0
  14. package/lib/shared/physical-rtl/generate-rtl.js.flow +12 -0
  15. package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
  16. package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
  17. package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
  18. package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
  19. package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
  20. package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
  21. package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  22. package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  23. package/lib/shared/preprocess-rules/index.d.ts +18 -0
  24. package/lib/shared/preprocess-rules/index.js.flow +22 -0
  25. package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +165 -0
  26. package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +144 -0
  27. package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
  28. package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
  29. package/lib/shared/stylex-consts-utils.d.ts +11 -0
  30. package/lib/shared/stylex-consts-utils.js.flow +14 -0
  31. package/lib/shared/stylex-create-theme.d.ts +26 -0
  32. package/lib/shared/stylex-create-theme.js.flow +19 -0
  33. package/lib/shared/stylex-create.d.ts +27 -0
  34. package/lib/shared/stylex-create.js.flow +37 -0
  35. package/lib/shared/stylex-define-consts.d.ts +23 -0
  36. package/lib/shared/stylex-define-consts.js.flow +19 -0
  37. package/lib/shared/stylex-define-vars.d.ts +28 -0
  38. package/lib/shared/stylex-define-vars.js.flow +26 -0
  39. package/lib/shared/stylex-first-that-works.d.ts +13 -0
  40. package/lib/shared/stylex-first-that-works.js.flow +12 -0
  41. package/lib/shared/stylex-keyframes.d.ts +17 -0
  42. package/lib/shared/stylex-keyframes.js.flow +20 -0
  43. package/lib/shared/stylex-position-try.d.ts +15 -0
  44. package/lib/shared/stylex-position-try.js.flow +18 -0
  45. package/lib/shared/stylex-vars-utils.d.ts +27 -0
  46. package/lib/shared/stylex-vars-utils.js.flow +31 -0
  47. package/lib/shared/types/index.d.ts +240 -0
  48. package/lib/shared/types/index.js.flow +280 -0
  49. package/lib/shared/utils/Rule.d.ts +58 -0
  50. package/lib/shared/utils/Rule.js.flow +64 -0
  51. package/lib/shared/utils/convert-to-className.d.ts +21 -0
  52. package/lib/shared/utils/convert-to-className.js.flow +29 -0
  53. package/lib/shared/utils/dashify.d.ts +11 -0
  54. package/lib/shared/utils/dashify.js.flow +10 -0
  55. package/lib/shared/utils/default-options.d.ts +11 -0
  56. package/lib/shared/utils/default-options.js.flow +12 -0
  57. package/lib/shared/utils/file-based-identifier.d.ts +15 -0
  58. package/lib/shared/utils/file-based-identifier.js.flow +14 -0
  59. package/lib/shared/utils/generate-css-rule.d.ts +18 -0
  60. package/lib/shared/utils/generate-css-rule.js.flow +19 -0
  61. package/lib/shared/utils/normalize-value.d.ts +16 -0
  62. package/lib/shared/utils/normalize-value.js.flow +16 -0
  63. package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  64. package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  65. package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  66. package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  67. package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  68. package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  69. package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
  70. package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
  71. package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
  72. package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
  73. package/lib/shared/utils/normalizers/timings.d.ts +18 -0
  74. package/lib/shared/utils/normalizers/timings.js.flow +17 -0
  75. package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
  76. package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
  77. package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
  78. package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
  79. package/lib/shared/utils/object-utils.d.ts +66 -0
  80. package/lib/shared/utils/object-utils.js.flow +78 -0
  81. package/lib/shared/utils/property-priorities.d.ts +17 -0
  82. package/lib/shared/utils/property-priorities.js.flow +78 -0
  83. package/lib/shared/utils/rule-utils.d.ts +15 -0
  84. package/lib/shared/utils/rule-utils.js.flow +16 -0
  85. package/lib/shared/utils/split-css-value.d.ts +14 -0
  86. package/lib/shared/utils/split-css-value.js.flow +15 -0
  87. package/lib/shared/utils/transform-value.d.ts +22 -0
  88. package/lib/shared/utils/transform-value.js.flow +25 -0
  89. package/lib/shared/validate.d.ts +12 -0
  90. package/lib/shared/validate.js.flow +12 -0
  91. package/lib/utils/add-sourcemap-data.d.ts +1 -1
  92. package/lib/utils/add-sourcemap-data.js.flow +1 -1
  93. package/lib/utils/dev-classname.d.ts +1 -1
  94. package/lib/utils/dev-classname.js.flow +2 -1
  95. package/lib/utils/evaluate-path.d.ts +14 -0
  96. package/lib/utils/evaluate-path.js.flow +15 -0
  97. package/lib/utils/js-to-ast.d.ts +1 -1
  98. package/lib/utils/js-to-ast.js.flow +1 -1
  99. package/lib/utils/state-manager.d.ts +34 -6
  100. package/lib/utils/state-manager.js.flow +34 -5
  101. package/lib/visitors/imports.d.ts +1 -1
  102. package/lib/visitors/imports.js.flow +2 -1
  103. package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts} +2 -2
  104. package/lib/visitors/{stylex-create/parse-stylex-create-arg.js.flow → parse-stylex-create-arg.js.flow} +5 -4
  105. package/lib/visitors/stylex-create-theme.d.ts +1 -1
  106. package/lib/visitors/stylex-create-theme.js.flow +1 -1
  107. package/lib/visitors/{stylex-create/index.d.ts → stylex-create.d.ts} +2 -2
  108. package/lib/visitors/{stylex-create/index.js.flow → stylex-create.js.flow} +3 -3
  109. package/lib/visitors/stylex-define-consts.d.ts +1 -14
  110. package/lib/visitors/stylex-define-consts.js.flow +9 -14
  111. package/lib/visitors/stylex-define-vars.d.ts +1 -1
  112. package/lib/visitors/stylex-define-vars.js.flow +1 -1
  113. package/lib/visitors/stylex-keyframes.d.ts +1 -1
  114. package/lib/visitors/stylex-keyframes.js.flow +1 -1
  115. package/lib/visitors/{stylex-attrs.d.ts → stylex-position-try.d.ts} +3 -7
  116. package/lib/visitors/stylex-position-try.js.flow +22 -0
  117. package/package.json +7 -11
  118. package/lib/babel-path-utils.d.ts +0 -1100
  119. package/lib/babel-path-utils.js.flow +0 -1108
  120. 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 '@stylexjs/shared';
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 '@stylexjs/shared';
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,7 @@
7
7
  *
8
8
  */
9
9
 
10
- import type { CompiledNamespaces } from '@stylexjs/shared';
10
+ import type { CompiledNamespaces } from '../shared';
11
11
  import StateManager from './state-manager';
12
12
  export declare function namespaceToDevClassName(
13
13
  namespace: string,
@@ -7,7 +7,8 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type { CompiledNamespaces } from '@stylexjs/shared';
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 = {
@@ -7,7 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
- import type { FlatCompiledStyles } from '../../../shared/src/common-types';
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,7 +7,7 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type { FlatCompiledStyles } from '../../../shared/src/common-types';
10
+ import type { FlatCompiledStyles } from '../shared/common-types';
11
11
 
12
12
  import * as t from '../../flow_modules/@babel/types';
13
13
 
@@ -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 '@stylexjs/shared';
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(style: [string, { ltr: string; rtl?: string | null }, number]): void;
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
- [string, { ltr: string; rtl?: string | null }, number]
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 '@stylexjs/shared';
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(style: [string, { ltr: string, rtl?: string | null }, number]): void;
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
- [string, { ltr: string, rtl?: string | null }, number],
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
@@ -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 '../../utils/state-manager';
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 '../../../flow_modules/@babel/traverse';
12
- import * as t from '../../../flow_modules/@babel/types';
13
- import StateManager from '../../utils/state-manager';
14
- import { type FunctionConfig } from '../../utils/evaluate-path';
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 StateManager from '../../utils/state-manager';
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 * as t from '../../../flow_modules/@babel/types';
11
- import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
- import StateManager from '../../utils/state-manager';
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)
@@ -7,22 +7,9 @@
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
- /**
14
- * This function looks for `stylex.defineConsts` calls and transforms them.
15
- *
16
- * 1. It finds the first argument to `stylex.defineConsts` and validates it.
17
- * 2. It evaluates the constants object to get a JS object.
18
- * 3. It uses `styleXDefineConsts` to transform the object into a structured format.
19
- * 4. It converts the resulting object back into an AST and replaces the function call with it.
20
- * 5. The transformed constants are stored in metadata and used during rule processing.
21
- * 6. During CSS rule generation, any references to `var(--keyhash)` (or `var(--keyhash, fallback)`)
22
- * are replaced with their corresponding `constVal` from `defineConsts`.
23
- * 7. Unlike `stylex.defineVars`, `defineConsts` does not generate runtime CSS variables but instead
24
- * directly inlines the resolved values into the final CSS output.
25
- */
26
13
  declare function transformStyleXDefineConsts(
27
14
  callExpressionPath: NodePath<t.CallExpression>,
28
15
  state: StateManager,
@@ -7,23 +7,18 @@
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
- * This function looks for `stylex.defineConsts` calls and transforms them.
16
- *
17
- * 1. It finds the first argument to `stylex.defineConsts` and validates it.
18
- * 2. It evaluates the constants object to get a JS object.
19
- * 3. It uses `styleXDefineConsts` to transform the object into a structured format.
20
- * 4. It converts the resulting object back into an AST and replaces the function call with it.
21
- * 5. The transformed constants are stored in metadata and used during rule processing.
22
- * 6. During CSS rule generation, any references to `var(--keyhash)` (or `var(--keyhash, fallback)`)
23
- * are replaced with their corresponding `constVal` from `defineConsts`.
24
- * 7. Unlike `stylex.defineVars`, `defineConsts` does not generate runtime CSS variables but instead
25
- * directly inlines the resolved values into the final CSS output.
26
- */
15
+ /// This function looks for `stylex.defineConsts` calls and transforms them.
16
+ /// 1. It finds and validates the first argument to `stylex.defineConsts`.
17
+ /// 2. It evaluates the style const object to a JS value, erroring on non-static or non-object values.
18
+ /// 3. It generates a theme name from the filename and export name for hashing.
19
+ /// 4. It invokes `stylexDefineConsts` to transform the JS object and collect injected styles.
20
+ /// 5. It creates a map of key-value pairs of constants to be inlined.
21
+ /// 6. It replaces the call with the transformed AST and registers the styles in state.
27
22
  declare export default function transformStyleXDefineConsts(
28
23
  callExpressionPath: NodePath<t.CallExpression>,
29
24
  state: StateManager,