@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,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
+
12
+ import * as t from '../../flow_modules/@babel/types';
13
+ import StateManager from '../utils/state-manager';
14
+
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.
22
+ declare export default function transformStyleXDefineConsts(
23
+ callExpressionPath: NodePath<t.CallExpression>,
24
+ state: StateManager,
25
+ ): 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
  declare function transformStyleXDefineVars(
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.defineVars` calls and transforms them.
14
14
  /// 1. It finds the first argument to `stylex.defineVars` and validates it.
@@ -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 transformStyleXKeyframes(
14
14
  path: NodePath<t.VariableDeclarator>,
@@ -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.keyframes` calls and transforms them.
14
14
  /// 1. It finds the first argument to `stylex.keyframes` and validates it.
@@ -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
+ import type { NodePath } from '@babel/traverse';
11
+ import * as t from '@babel/types';
12
+ import StateManager from '../utils/state-manager';
13
+ declare function transformStyleXPositionTry(
14
+ path: NodePath<t.VariableDeclarator>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXPositionTry;
@@ -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
+ * @flow strict
8
+ */
9
+
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
+ /// This function looks for `stylex.positionTry` calls within variable declarations and transforms them.
14
+ /// 1. It finds the first argument to `stylex.positionTry` and validates it.
15
+ /// 2. It evaluates the style object to get a JS object. This also handles local constants automatically.
16
+ /// 3. The actual transformation is done by `stylexPositionTry` from `../shared`
17
+ /// 4. The results are replaced, and generated CSS rules are injected as needed.
18
+
19
+ declare export default function transformStyleXPositionTry(
20
+ path: NodePath<t.VariableDeclarator>,
21
+ state: StateManager,
22
+ ): void;
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
- "repository": "https://github.com/facebook/stylex",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/facebook/stylex.git"
9
+ },
7
10
  "license": "MIT",
8
11
  "scripts": {
9
12
  "prebuild": "gen-types -i src/ -o lib/",
10
13
  "build": "rollup --config ./rollup.config.mjs",
11
14
  "build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
12
15
  "build-watch": "rollup --config ./rollup.config.mjs --watch",
13
- "test": "jest"
16
+ "test": "jest --coverage"
14
17
  },
15
18
  "dependencies": {
16
19
  "@babel/helper-module-imports": "^7.25.9",
@@ -18,8 +21,8 @@
18
21
  "@babel/traverse": "^7.26.8",
19
22
  "@babel/types": "^7.26.8",
20
23
  "@dual-bundle/import-meta-resolve": "^4.1.0",
21
- "@stylexjs/shared": "0.11.1",
22
- "@stylexjs/stylex": "0.11.1"
24
+ "@stylexjs/stylex": "0.13.0",
25
+ "postcss-value-parser": "^4.1.0"
23
26
  },
24
27
  "devDependencies": {
25
28
  "@rollup/plugin-alias": "^5.1.1",
@@ -28,13 +31,9 @@
28
31
  "@rollup/plugin-json": "^6.1.0",
29
32
  "@rollup/plugin-node-resolve": "^15.3.0",
30
33
  "@rollup/plugin-replace": "^6.0.1",
31
- "rollup": "^4.24.0"
32
- },
33
- "jest": {
34
- "verbose": true,
35
- "snapshotFormat": {
36
- "printBasicPrototype": false
37
- }
34
+ "babel-plugin-syntax-hermes-parser": "^0.26.0",
35
+ "rollup": "^4.24.0",
36
+ "scripts": "0.13.0"
38
37
  },
39
38
  "files": [
40
39
  "flow_modules/*",