@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.
Files changed (121) hide show
  1. package/lib/index.d.ts +2 -1
  2. package/lib/index.js +3797 -2229
  3. package/lib/index.js.flow +11 -1
  4. package/lib/shared/common-types.d.ts +57 -0
  5. package/lib/shared/common-types.js.flow +71 -0
  6. package/lib/shared/hash.d.ts +12 -0
  7. package/lib/shared/hash.js.flow +12 -0
  8. package/lib/shared/index.d.ts +57 -0
  9. package/lib/shared/index.js.flow +66 -0
  10. package/lib/shared/messages.d.ts +35 -0
  11. package/lib/shared/messages.js.flow +40 -0
  12. package/lib/shared/physical-rtl/generate-ltr.d.ts +13 -0
  13. package/lib/shared/physical-rtl/generate-ltr.js.flow +12 -0
  14. package/lib/shared/physical-rtl/generate-rtl.d.ts +13 -0
  15. package/lib/shared/physical-rtl/generate-rtl.js.flow +12 -0
  16. package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
  17. package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
  18. package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
  19. package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
  20. package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
  21. package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
  22. package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  23. package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  24. package/lib/shared/preprocess-rules/index.d.ts +18 -0
  25. package/lib/shared/preprocess-rules/index.js.flow +22 -0
  26. package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +165 -0
  27. package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +144 -0
  28. package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
  29. package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
  30. package/lib/shared/stylex-consts-utils.d.ts +11 -0
  31. package/lib/shared/stylex-consts-utils.js.flow +14 -0
  32. package/lib/shared/stylex-create-theme.d.ts +26 -0
  33. package/lib/shared/stylex-create-theme.js.flow +19 -0
  34. package/lib/shared/stylex-create.d.ts +27 -0
  35. package/lib/shared/stylex-create.js.flow +37 -0
  36. package/lib/shared/stylex-define-consts.d.ts +23 -0
  37. package/lib/shared/stylex-define-consts.js.flow +19 -0
  38. package/lib/shared/stylex-define-vars.d.ts +28 -0
  39. package/lib/shared/stylex-define-vars.js.flow +26 -0
  40. package/lib/shared/stylex-first-that-works.d.ts +13 -0
  41. package/lib/shared/stylex-first-that-works.js.flow +12 -0
  42. package/lib/shared/stylex-keyframes.d.ts +17 -0
  43. package/lib/shared/stylex-keyframes.js.flow +20 -0
  44. package/lib/shared/stylex-position-try.d.ts +15 -0
  45. package/lib/shared/stylex-position-try.js.flow +18 -0
  46. package/lib/shared/stylex-vars-utils.d.ts +27 -0
  47. package/lib/shared/stylex-vars-utils.js.flow +31 -0
  48. package/lib/shared/types/index.d.ts +240 -0
  49. package/lib/shared/types/index.js.flow +280 -0
  50. package/lib/shared/utils/Rule.d.ts +58 -0
  51. package/lib/shared/utils/Rule.js.flow +64 -0
  52. package/lib/shared/utils/convert-to-className.d.ts +21 -0
  53. package/lib/shared/utils/convert-to-className.js.flow +29 -0
  54. package/lib/shared/utils/dashify.d.ts +11 -0
  55. package/lib/shared/utils/dashify.js.flow +10 -0
  56. package/lib/shared/utils/default-options.d.ts +11 -0
  57. package/lib/shared/utils/default-options.js.flow +12 -0
  58. package/lib/shared/utils/file-based-identifier.d.ts +15 -0
  59. package/lib/shared/utils/file-based-identifier.js.flow +14 -0
  60. package/lib/shared/utils/generate-css-rule.d.ts +18 -0
  61. package/lib/shared/utils/generate-css-rule.js.flow +19 -0
  62. package/lib/shared/utils/normalize-value.d.ts +16 -0
  63. package/lib/shared/utils/normalize-value.js.flow +16 -0
  64. package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  65. package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  66. package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  67. package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  68. package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  69. package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  70. package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
  71. package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
  72. package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
  73. package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
  74. package/lib/shared/utils/normalizers/timings.d.ts +18 -0
  75. package/lib/shared/utils/normalizers/timings.js.flow +17 -0
  76. package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
  77. package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
  78. package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
  79. package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
  80. package/lib/shared/utils/object-utils.d.ts +66 -0
  81. package/lib/shared/utils/object-utils.js.flow +78 -0
  82. package/lib/shared/utils/property-priorities.d.ts +17 -0
  83. package/lib/shared/utils/property-priorities.js.flow +78 -0
  84. package/lib/shared/utils/rule-utils.d.ts +15 -0
  85. package/lib/shared/utils/rule-utils.js.flow +16 -0
  86. package/lib/shared/utils/split-css-value.d.ts +14 -0
  87. package/lib/shared/utils/split-css-value.js.flow +15 -0
  88. package/lib/shared/utils/transform-value.d.ts +22 -0
  89. package/lib/shared/utils/transform-value.js.flow +25 -0
  90. package/lib/shared/validate.d.ts +12 -0
  91. package/lib/shared/validate.js.flow +12 -0
  92. package/lib/utils/add-sourcemap-data.d.ts +1 -1
  93. package/lib/utils/add-sourcemap-data.js.flow +1 -1
  94. package/lib/utils/dev-classname.d.ts +1 -1
  95. package/lib/utils/dev-classname.js.flow +2 -1
  96. package/lib/utils/evaluate-path.d.ts +19 -0
  97. package/lib/utils/evaluate-path.js.flow +26 -0
  98. package/lib/utils/js-to-ast.d.ts +1 -1
  99. package/lib/utils/js-to-ast.js.flow +1 -1
  100. package/lib/utils/state-manager.d.ts +36 -6
  101. package/lib/utils/state-manager.js.flow +35 -5
  102. package/lib/visitors/imports.d.ts +1 -1
  103. package/lib/visitors/imports.js.flow +2 -1
  104. package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts} +2 -2
  105. package/lib/visitors/{stylex-create/parse-stylex-create-arg.js.flow → parse-stylex-create-arg.js.flow} +5 -4
  106. package/lib/visitors/stylex-create-theme.d.ts +1 -1
  107. package/lib/visitors/stylex-create-theme.js.flow +1 -1
  108. package/lib/visitors/{stylex-create/index.d.ts → stylex-create.d.ts} +2 -2
  109. package/lib/visitors/{stylex-create/index.js.flow → stylex-create.js.flow} +3 -3
  110. package/lib/visitors/{stylex-attrs.d.ts → stylex-define-consts.d.ts} +3 -7
  111. package/lib/visitors/stylex-define-consts.js.flow +25 -0
  112. package/lib/visitors/stylex-define-vars.d.ts +1 -1
  113. package/lib/visitors/stylex-define-vars.js.flow +1 -1
  114. package/lib/visitors/stylex-keyframes.d.ts +1 -1
  115. package/lib/visitors/stylex-keyframes.js.flow +1 -1
  116. package/lib/visitors/stylex-position-try.d.ts +17 -0
  117. package/lib/visitors/stylex-position-try.js.flow +22 -0
  118. package/package.json +11 -12
  119. package/lib/babel-path-utils.d.ts +0 -1100
  120. package/lib/babel-path-utils.js.flow +0 -1108
  121. 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,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,
@@ -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,7 +45,8 @@ export type StyleXOptions = Readonly<
45
45
  enableDebugClassNames?: boolean;
46
46
  enableDebugDataProp?: boolean;
47
47
  enableDevClassNames?: boolean;
48
- genConditionalClasses: boolean;
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
- genConditionalClasses: boolean;
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(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;
162
180
  registerStyles(
163
181
  styles: ReadonlyArray<
164
- [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
+ ]
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 '@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,7 +47,8 @@ export type StyleXOptions = $ReadOnly<{
46
47
  enableDebugClassNames?: boolean,
47
48
  enableDebugDataProp?: boolean,
48
49
  enableDevClassNames?: boolean,
49
- genConditionalClasses: boolean,
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(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;
120
138
  registerStyles(
121
139
  styles: $ReadOnlyArray<
122
- [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
+ ],
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
@@ -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)
@@ -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
- export declare function skipStylexAttrsChildren(
14
- path: NodePath<t.CallExpression>,
13
+ declare function transformStyleXDefineConsts(
14
+ callExpressionPath: NodePath<t.CallExpression>,
15
15
  state: StateManager,
16
16
  ): void;
17
- declare function transformStylexAttrs(
18
- path: NodePath<t.CallExpression>,
19
- state: StateManager,
20
- ): void;
21
- export default transformStylexAttrs;
17
+ export default transformStyleXDefineConsts;