@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
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @stylexjs/babel-plugin
2
+
3
+ StyleX expects you to transform all `js`/`ts`/`tsx` files with `@stylexjs/babel-plugin`.
4
+ In addition to transforming JS code, this plugin also produces an Array of CSS rules. All the CSS rules
5
+ generated from all JS files within your project should be concatenated together and converted to a CSS
6
+ file using the `processStyles` function which is also exported from the same module.
7
+
8
+ `@stylexjs/babel-plugin` is fairly lightweight. It pre-computes `stylex` related functions like
9
+ `create` and `keyframes` by converting the argument AST to a JS object and transforming them
10
+ by passing them to the functions of the corresponding names within `@stylex/shared`
11
+
12
+
13
+ ## Babel Metadata
14
+
15
+ The StyleX Babel plugin does more than transform JavaScript (or TypeScript) files. It also returns a list of injected styles. The way that such a value can be returned while transforming a JS file is by using Babel's `metadata` API.
16
+
17
+ An example of this can be seen in some of the tests, but the result of using Babel's `transform(...)` function returns an object contains at least two keys:
18
+
19
+ 1. `code` which is the transformed JS code
20
+ 2. `metadata` is an object of metadata that the plugin may want to return as a side-effect.
21
+
22
+ e.g.
23
+
24
+ ```js
25
+ const result = transformSync(sourceCode, {
26
+ filename: opts.filename,
27
+ parserOpts: { flow: { all: true } },
28
+ plugins: [stylexPlugin, opts],
29
+ });
30
+
31
+ const transformedCode = result.code;
32
+ const injectedStyles = result.metadata.stylex;
33
+ ```