@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
@@ -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.
@@ -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 transformStyleXPositionTry(
14
+ path: NodePath<t.VariableDeclarator>,
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 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -13,7 +13,7 @@
13
13
  "build": "rollup --config ./rollup.config.mjs",
14
14
  "build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
15
15
  "build-watch": "rollup --config ./rollup.config.mjs --watch",
16
- "test": "jest"
16
+ "test": "jest --coverage"
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/helper-module-imports": "^7.25.9",
@@ -21,8 +21,8 @@
21
21
  "@babel/traverse": "^7.26.8",
22
22
  "@babel/types": "^7.26.8",
23
23
  "@dual-bundle/import-meta-resolve": "^4.1.0",
24
- "@stylexjs/shared": "0.12.0",
25
- "@stylexjs/stylex": "0.12.0"
24
+ "@stylexjs/stylex": "0.13.0",
25
+ "postcss-value-parser": "^4.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rollup/plugin-alias": "^5.1.1",
@@ -31,13 +31,9 @@
31
31
  "@rollup/plugin-json": "^6.1.0",
32
32
  "@rollup/plugin-node-resolve": "^15.3.0",
33
33
  "@rollup/plugin-replace": "^6.0.1",
34
- "rollup": "^4.24.0"
35
- },
36
- "jest": {
37
- "verbose": true,
38
- "snapshotFormat": {
39
- "printBasicPrototype": false
40
- }
34
+ "babel-plugin-syntax-hermes-parser": "^0.26.0",
35
+ "rollup": "^4.24.0",
36
+ "scripts": "0.13.0"
41
37
  },
42
38
  "files": [
43
39
  "flow_modules/*",