@stylexjs/shared 0.2.0-beta.9 → 0.3.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 (182) hide show
  1. package/lib/common-types.d.ts +50 -0
  2. package/lib/common-types.js.flow +65 -0
  3. package/lib/convert-to-className.d.ts +16 -0
  4. package/lib/convert-to-className.js +17 -26
  5. package/lib/convert-to-className.js.flow +23 -0
  6. package/lib/generate-css-rule.d.ts +17 -0
  7. package/lib/generate-css-rule.js +6 -17
  8. package/lib/generate-css-rule.js.flow +17 -0
  9. package/lib/hash.d.ts +11 -0
  10. package/lib/hash.js +3 -27
  11. package/lib/hash.js.flow +10 -0
  12. package/lib/index.d.ts +42 -85
  13. package/lib/index.js +19 -27
  14. package/lib/index.js.flow +57 -3
  15. package/lib/messages.d.ts +36 -0
  16. package/lib/messages.js +28 -53
  17. package/lib/messages.js.flow +39 -0
  18. package/lib/physical-rtl/generate-ltr.d.ts +11 -0
  19. package/lib/physical-rtl/generate-ltr.js +18 -46
  20. package/lib/physical-rtl/generate-ltr.js.flow +12 -0
  21. package/lib/physical-rtl/generate-rtl.d.ts +13 -0
  22. package/lib/physical-rtl/generate-rtl.js +18 -50
  23. package/lib/physical-rtl/generate-rtl.js.flow +12 -0
  24. package/lib/preprocess-rules/PreRule.d.ts +52 -0
  25. package/lib/preprocess-rules/PreRule.js +87 -0
  26. package/lib/preprocess-rules/PreRule.js.flow +64 -0
  27. package/lib/preprocess-rules/application-order.d.ts +290 -0
  28. package/lib/preprocess-rules/application-order.js +59 -125
  29. package/lib/preprocess-rules/application-order.js.flow +241 -0
  30. package/lib/preprocess-rules/basic-validation.d.ts +13 -0
  31. package/lib/preprocess-rules/basic-validation.js +83 -0
  32. package/lib/preprocess-rules/basic-validation.js.flow +13 -0
  33. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
  34. package/lib/preprocess-rules/flatten-raw-style-obj.js +120 -0
  35. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
  36. package/lib/preprocess-rules/index.d.ts +18 -0
  37. package/lib/preprocess-rules/index.js +0 -9
  38. package/lib/preprocess-rules/index.js.flow +19 -0
  39. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +200 -0
  40. package/lib/preprocess-rules/legacy-expand-shorthands.js +90 -123
  41. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +179 -0
  42. package/lib/preprocess-rules/property-specificity.d.ts +89 -0
  43. package/lib/preprocess-rules/property-specificity.js +46 -74
  44. package/lib/preprocess-rules/property-specificity.js.flow +98 -0
  45. package/lib/properties/CSS Animations.json +445 -0
  46. package/lib/properties/CSS Backgrounds and Borders.json +1085 -0
  47. package/lib/properties/CSS Basic User Interface.json +365 -0
  48. package/lib/properties/CSS Box Alignment.json +245 -0
  49. package/lib/properties/CSS Box Model.json +501 -0
  50. package/lib/properties/CSS Color.json +100 -0
  51. package/lib/properties/CSS Columns.json +185 -0
  52. package/lib/properties/CSS Containment.json +203 -0
  53. package/lib/properties/CSS Counter Styles.json +56 -0
  54. package/lib/properties/CSS Display.json +20 -0
  55. package/lib/properties/CSS Flexible Box Layout.json +167 -0
  56. package/lib/properties/CSS Fonts.json +684 -0
  57. package/lib/properties/CSS Fragmentation.json +110 -0
  58. package/lib/properties/CSS Generated Content.json +38 -0
  59. package/lib/properties/CSS Grid Layout.json +500 -0
  60. package/lib/properties/CSS Images.json +91 -0
  61. package/lib/properties/CSS Inline.json +38 -0
  62. package/lib/properties/CSS Lists and Counters.json +86 -0
  63. package/lib/properties/CSS Logical Properties.json +1086 -0
  64. package/lib/properties/CSS Masking.json +399 -0
  65. package/lib/properties/CSS Miscellaneous.json +38 -0
  66. package/lib/properties/CSS Motion Path.json +132 -0
  67. package/lib/properties/CSS Overflow.json +216 -0
  68. package/lib/properties/CSS Pages.json +83 -0
  69. package/lib/properties/CSS Positioning.json +166 -0
  70. package/lib/properties/CSS Ruby.json +55 -0
  71. package/lib/properties/CSS Scroll Anchoring.json +19 -0
  72. package/lib/properties/CSS Scroll Snap.json +604 -0
  73. package/lib/properties/CSS Scrollbars.json +38 -0
  74. package/lib/properties/CSS Shapes.json +56 -0
  75. package/lib/properties/CSS Speech.json +20 -0
  76. package/lib/properties/CSS Table.json +115 -0
  77. package/lib/properties/CSS Text Decoration.json +312 -0
  78. package/lib/properties/CSS Text.json +415 -0
  79. package/lib/properties/CSS Transforms.json +188 -0
  80. package/lib/properties/CSS Transitions.json +122 -0
  81. package/lib/properties/CSS Variables.json +20 -0
  82. package/lib/properties/CSS View Transitions.json +20 -0
  83. package/lib/properties/CSS Will Change.json +20 -0
  84. package/lib/properties/CSS Writing Modes.json +92 -0
  85. package/lib/properties/Compositing and Blending.json +62 -0
  86. package/lib/properties/Filter Effects.json +38 -0
  87. package/lib/properties/MathML.json +56 -0
  88. package/lib/properties/Microsoft Extensions.json +885 -0
  89. package/lib/properties/Mozilla Extensions.json +607 -0
  90. package/lib/properties/Pointer Events.json +20 -0
  91. package/lib/properties/WebKit Extensions.json +707 -0
  92. package/lib/properties.json +10122 -0
  93. package/lib/stylex-create-theme.d.ts +26 -0
  94. package/lib/stylex-create-theme.js +62 -0
  95. package/lib/stylex-create-theme.js.flow +19 -0
  96. package/lib/stylex-create.d.ts +23 -0
  97. package/lib/stylex-create.js +30 -146
  98. package/lib/stylex-create.js.flow +30 -0
  99. package/lib/stylex-define-vars.d.ts +36 -0
  100. package/lib/stylex-define-vars.js +72 -0
  101. package/lib/stylex-define-vars.js.flow +28 -0
  102. package/lib/stylex-first-that-works.d.ts +13 -0
  103. package/lib/stylex-first-that-works.js +0 -10
  104. package/lib/stylex-first-that-works.js.flow +12 -0
  105. package/lib/stylex-include.d.ts +18 -0
  106. package/lib/stylex-include.js +0 -10
  107. package/lib/stylex-include.js.flow +20 -0
  108. package/lib/stylex-keyframes.d.ts +17 -0
  109. package/lib/stylex-keyframes.js +6 -26
  110. package/lib/stylex-keyframes.js.flow +20 -0
  111. package/lib/transform-value.d.ts +22 -0
  112. package/lib/transform-value.js +9 -23
  113. package/lib/transform-value.js.flow +25 -0
  114. package/lib/types/index.d.ts +205 -0
  115. package/lib/types/index.js +191 -0
  116. package/lib/types/index.js.flow +241 -0
  117. package/lib/utils/Rule.d.ts +58 -0
  118. package/lib/utils/Rule.js +0 -21
  119. package/lib/utils/Rule.js.flow +64 -0
  120. package/lib/utils/dashify.d.ts +11 -0
  121. package/lib/utils/dashify.js +0 -8
  122. package/lib/utils/dashify.js.flow +10 -0
  123. package/lib/utils/default-options.d.ts +11 -0
  124. package/lib/utils/default-options.js +14 -0
  125. package/lib/utils/default-options.js.flow +25 -0
  126. package/lib/utils/file-based-identifier.d.ts +15 -0
  127. package/lib/utils/file-based-identifier.js +14 -0
  128. package/lib/utils/file-based-identifier.js.flow +14 -0
  129. package/lib/utils/genCSSRule.d.ts +15 -0
  130. package/lib/utils/genCSSRule.js +9 -18
  131. package/lib/utils/genCSSRule.js.flow +15 -0
  132. package/lib/utils/normalize-value.d.ts +16 -0
  133. package/lib/utils/normalize-value.js +8 -15
  134. package/lib/utils/normalize-value.js.flow +16 -0
  135. package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +14 -0
  136. package/lib/utils/normalizers/convert-camel-case-transition-props.js +23 -0
  137. package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +13 -0
  138. package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  139. package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
  140. package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  141. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  142. package/lib/utils/normalizers/detect-unclosed-fns.js +0 -12
  143. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  144. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  145. package/lib/utils/normalizers/font-size-px-to-rem.js +9 -19
  146. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  147. package/lib/utils/normalizers/leading-zero.d.ts +17 -0
  148. package/lib/utils/normalizers/leading-zero.js +0 -12
  149. package/lib/utils/normalizers/leading-zero.js.flow +16 -0
  150. package/lib/utils/normalizers/quotes.d.ts +18 -0
  151. package/lib/utils/normalizers/quotes.js +0 -13
  152. package/lib/utils/normalizers/quotes.js.flow +17 -0
  153. package/lib/utils/normalizers/timings.d.ts +18 -0
  154. package/lib/utils/normalizers/timings.js +0 -14
  155. package/lib/utils/normalizers/timings.js.flow +17 -0
  156. package/lib/utils/normalizers/whitespace.d.ts +19 -0
  157. package/lib/utils/normalizers/whitespace.js +0 -15
  158. package/lib/utils/normalizers/whitespace.js.flow +18 -0
  159. package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
  160. package/lib/utils/normalizers/zero-dimensions.js +0 -15
  161. package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
  162. package/lib/utils/object-utils.d.ts +66 -0
  163. package/lib/utils/object-utils.js +21 -13
  164. package/lib/utils/object-utils.js.flow +77 -0
  165. package/lib/utils/property-priorities.d.ts +11 -0
  166. package/lib/utils/property-priorities.js +516 -101
  167. package/lib/utils/property-priorities.js.flow +10 -0
  168. package/lib/utils/split-css-value.d.ts +14 -0
  169. package/lib/utils/split-css-value.js +0 -14
  170. package/lib/utils/split-css-value.js.flow +15 -0
  171. package/lib/validate.d.ts +12 -0
  172. package/lib/validate.js +1 -10
  173. package/lib/validate.js.flow +12 -0
  174. package/package.json +4 -5
  175. package/lib/expand-shorthands.d.ts +0 -5
  176. package/lib/expand-shorthands.js +0 -330
  177. package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
  178. package/lib/namespace-transforms/preflatten.js +0 -89
  179. package/lib/preprocess-rules/expand-shorthands.js +0 -156
  180. package/lib/preprocess-rules/null-out-longhand.js +0 -310
  181. package/lib/preprocess-rules/react-native-web.js +0 -142
  182. package/lib/stylex-defaultValue.js +0 -397
package/lib/messages.js CHANGED
@@ -1,58 +1,33 @@
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
1
  'use strict';
10
2
 
11
- // This file contains constants to be used within Error messages.
12
- // The URLs within will eventually be replaced by links to the documenation website for Stylex.
13
3
  Object.defineProperty(exports, "__esModule", {
14
4
  value: true
15
5
  });
16
- exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL = exports.NO_PARENT_PATH = exports.NO_CONDITIONAL_SHORTHAND = exports.NON_STATIC_VALUE = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.LOCAL_ONLY = exports.LINT_UNCLOSED_FUNCTION = exports.INVALID_SPREAD = exports.INVALID_PSEUDO = exports.ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_ARGUMENT_LENGTH = exports.EXPECTED_FUNCTION_CALL = exports.ESCAPED_STYLEX_VALUE = void 0;
17
- const ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
18
- exports.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
19
- const NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
20
- exports.NON_STATIC_VALUE = NON_STATIC_VALUE;
21
- const ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
22
- exports.ESCAPED_STYLEX_VALUE = ESCAPED_STYLEX_VALUE;
23
- const UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
24
- exports.UNBOUND_STYLEX_CALL_VALUE = UNBOUND_STYLEX_CALL_VALUE;
25
- const ONLY_TOP_LEVEL = 'stylex.create() is only allowed at the root of a program.';
26
- exports.ONLY_TOP_LEVEL = ONLY_TOP_LEVEL;
27
- const NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
28
- exports.NON_OBJECT_FOR_STYLEX_CALL = NON_OBJECT_FOR_STYLEX_CALL;
29
- const UNKNOWN_PROP_KEY = 'Unknown property key';
30
- exports.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
31
- const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
32
- exports.INVALID_PSEUDO = INVALID_PSEUDO;
33
- const NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
34
- exports.NO_CONDITIONAL_SHORTHAND = NO_CONDITIONAL_SHORTHAND;
35
- const ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
36
- exports.ILLEGAL_NAMESPACE_TYPE = ILLEGAL_NAMESPACE_TYPE;
37
- const UNKNOWN_NAMESPACE = 'Unknown namespace';
38
- exports.UNKNOWN_NAMESPACE = UNKNOWN_NAMESPACE;
39
- const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
40
- exports.ILLEGAL_NESTED_PSEUDO = ILLEGAL_NESTED_PSEUDO;
41
- const ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
42
- exports.ILLEGAL_PROP_VALUE = ILLEGAL_PROP_VALUE;
43
- const ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
44
- exports.ILLEGAL_PROP_ARRAY_VALUE = ILLEGAL_PROP_ARRAY_VALUE;
45
- const ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
46
- exports.ILLEGAL_NAMESPACE_VALUE = ILLEGAL_NAMESPACE_VALUE;
47
- const INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
48
- exports.INVALID_SPREAD = INVALID_SPREAD;
49
- const LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
50
- exports.LINT_UNCLOSED_FUNCTION = LINT_UNCLOSED_FUNCTION;
51
- const LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
52
- exports.LOCAL_ONLY = LOCAL_ONLY;
53
- const UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
54
- exports.UNEXPECTED_ARGUMENT = UNEXPECTED_ARGUMENT;
55
- const EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
56
- exports.EXPECTED_FUNCTION_CALL = EXPECTED_FUNCTION_CALL;
57
- const NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
58
- exports.NO_PARENT_PATH = NO_PARENT_PATH;
6
+ exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL_INLCUDES = exports.ONLY_TOP_LEVEL = exports.NO_PROJECT_ROOT_DIRECTORY = exports.NO_PARENT_PATH = exports.NO_CONDITIONAL_SHORTHAND = exports.NON_STATIC_VALUE = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.NON_EXPORT_NAMED_DECLARATION = exports.LOCAL_ONLY = exports.LINT_UNCLOSED_FUNCTION = exports.INVALID_SPREAD = exports.INVALID_PSEUDO_OR_AT_RULE = exports.INVALID_PSEUDO = exports.ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_ARGUMENT_LENGTH = exports.EXPECTED_FUNCTION_CALL = exports.ESCAPED_STYLEX_VALUE = exports.DUPLICATE_CONDITIONAL = exports.ANONYMOUS_THEME = void 0;
7
+ const ILLEGAL_ARGUMENT_LENGTH = exports.ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
8
+ const NON_STATIC_VALUE = exports.NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
9
+ const ESCAPED_STYLEX_VALUE = exports.ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
10
+ const UNBOUND_STYLEX_CALL_VALUE = exports.UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
11
+ const ONLY_TOP_LEVEL = exports.ONLY_TOP_LEVEL = 'stylex.create() is only allowed at the root of a program.';
12
+ const NON_OBJECT_FOR_STYLEX_CALL = exports.NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
13
+ const UNKNOWN_PROP_KEY = exports.UNKNOWN_PROP_KEY = 'Unknown property key';
14
+ const INVALID_PSEUDO = exports.INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
15
+ const INVALID_PSEUDO_OR_AT_RULE = exports.INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
16
+ const NO_CONDITIONAL_SHORTHAND = exports.NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
17
+ const ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
18
+ const UNKNOWN_NAMESPACE = exports.UNKNOWN_NAMESPACE = 'Unknown namespace';
19
+ const ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
20
+ const ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
21
+ const ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
22
+ const ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
23
+ const INVALID_SPREAD = exports.INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
24
+ const LINT_UNCLOSED_FUNCTION = exports.LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
25
+ const LOCAL_ONLY = exports.LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
26
+ const UNEXPECTED_ARGUMENT = exports.UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
27
+ const EXPECTED_FUNCTION_CALL = exports.EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
28
+ const NO_PARENT_PATH = exports.NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
29
+ const ONLY_TOP_LEVEL_INLCUDES = exports.ONLY_TOP_LEVEL_INLCUDES = 'stylex.include() is only at the top level of a style definition object.';
30
+ const DUPLICATE_CONDITIONAL = exports.DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
31
+ const NO_PROJECT_ROOT_DIRECTORY = exports.NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
32
+ const NON_EXPORT_NAMED_DECLARATION = exports.NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.defineVars() must be bound to a named export.';
33
+ const ANONYMOUS_THEME = exports.ANONYMOUS_THEME = 'stylex.createTheme() must be bound to a named constant.';
@@ -0,0 +1,39 @@
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
+ // This file contains constants to be used within Error messages.
11
+ // The URLs within will eventually be replaced by links to the documenation website for Stylex.
12
+
13
+ declare export const ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
14
+ declare export const NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
15
+ declare export const ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
16
+ declare export const UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
17
+ declare export const ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
18
+ declare export const NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
19
+ declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
20
+ declare export const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
21
+ declare export const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
22
+ declare export const NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
23
+ declare export const ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
24
+ declare export const UNKNOWN_NAMESPACE: 'Unknown namespace';
25
+ declare export const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
26
+ declare export const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
27
+ declare export const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
28
+ declare export const ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
29
+ declare export const INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
30
+ declare export const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
31
+ declare export const LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
32
+ declare export const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
33
+ declare export const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
34
+ declare export const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
35
+ declare export const ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
36
+ declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
37
+ declare export const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
38
+ declare export const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.defineVars() must be bound to a named export.';
39
+ declare export const ANONYMOUS_THEME: 'stylex.createTheme() must be bound to a named constant.';
@@ -0,0 +1,11 @@
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
+ declare function generateLTR(pair: [string, string]): [string, string];
11
+ export default generateLTR;
@@ -4,101 +4,75 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = generateLTR;
7
- /**
8
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- *
14
- *
15
- */
16
-
17
7
  const logicalToPhysical = {
18
8
  start: 'left',
19
9
  end: 'right'
20
10
  };
21
11
  const propertyToLTR = {
22
12
  'margin-start': _ref => {
23
- let [key, val] = _ref;
13
+ let [_key, val] = _ref;
24
14
  return ['margin-left', val];
25
15
  },
26
- // 'margin-inline-start': ([key, val]) => ['margin-left', val],
27
16
  'margin-end': _ref2 => {
28
- let [key, val] = _ref2;
17
+ let [_key, val] = _ref2;
29
18
  return ['margin-right', val];
30
19
  },
31
- // 'margin-inline-end': ([key, val]: [string, string]) => ['margin-right', val],
32
20
  'padding-start': _ref3 => {
33
- let [key, val] = _ref3;
21
+ let [_key, val] = _ref3;
34
22
  return ['padding-left', val];
35
23
  },
36
- // 'padding-inline-start': ([key, val]: [string, string]) => ['padding-left', val],
37
24
  'padding-end': _ref4 => {
38
- let [key, val] = _ref4;
25
+ let [_key, val] = _ref4;
39
26
  return ['padding-right', val];
40
27
  },
41
- // 'padding-inline-end': ([key, val]: [string, string]) => ['padding-right', val],
42
28
  'border-start': _ref5 => {
43
- let [key, val] = _ref5;
29
+ let [_key, val] = _ref5;
44
30
  return ['border-left', val];
45
31
  },
46
- // 'border-inline-start': ([key, val]: [string, string]) => ['border-left', val],
47
32
  'border-end': _ref6 => {
48
- let [key, val] = _ref6;
33
+ let [_key, val] = _ref6;
49
34
  return ['border-right', val];
50
35
  },
51
- // 'border-inline-end': ([key, val]: [string, string]) => ['border-right', val],
52
36
  'border-start-width': _ref7 => {
53
- let [key, val] = _ref7;
37
+ let [_key, val] = _ref7;
54
38
  return ['border-left-width', val];
55
39
  },
56
- // 'border-inline-start-width': ([key, val]: [string, string]) => ['border-left-width', val],
57
40
  'border-end-width': _ref8 => {
58
- let [key, val] = _ref8;
41
+ let [_key, val] = _ref8;
59
42
  return ['border-right-width', val];
60
43
  },
61
- // 'border-inline-end-width': ([key, val]: [string, string]) => ['border-right-width', val],
62
44
  'border-start-color': _ref9 => {
63
- let [key, val] = _ref9;
45
+ let [_key, val] = _ref9;
64
46
  return ['border-left-color', val];
65
47
  },
66
- // 'border-inline-start-color': ([key, val]: [string, string]) => ['border-left-color', val],
67
48
  'border-end-color': _ref10 => {
68
- let [key, val] = _ref10;
49
+ let [_key, val] = _ref10;
69
50
  return ['border-right-color', val];
70
51
  },
71
- // 'border-inline-end-color': ([key, val]: [string, string]) => ['border-right-color', val],
72
52
  'border-start-style': _ref11 => {
73
- let [key, val] = _ref11;
53
+ let [_key, val] = _ref11;
74
54
  return ['border-left-style', val];
75
55
  },
76
- // 'border-inline-start-style': ([key, val]: [string, string]) => ['border-left-style', val],
77
56
  'border-end-style': _ref12 => {
78
- let [key, val] = _ref12;
57
+ let [_key, val] = _ref12;
79
58
  return ['border-right-style', val];
80
59
  },
81
- // 'border-inline-end-style': ([key, val]: [string, string]) => ['border-right-style', val],
82
60
  'border-top-start-radius': _ref13 => {
83
- let [key, val] = _ref13;
61
+ let [_key, val] = _ref13;
84
62
  return ['border-top-left-radius', val];
85
63
  },
86
- // 'border-start-start-radius': ([key, val]: [string, string]) => ['border-top-left-radius', val],
87
64
  'border-bottom-start-radius': _ref14 => {
88
- let [key, val] = _ref14;
65
+ let [_key, val] = _ref14;
89
66
  return ['border-bottom-left-radius', val];
90
67
  },
91
- // 'border-end-start-radius': ([key, val]: [string, string]) => ['border-bottom-left-radius', val],
92
68
  'border-top-end-radius': _ref15 => {
93
- let [key, val] = _ref15;
69
+ let [_key, val] = _ref15;
94
70
  return ['border-top-right-radius', val];
95
71
  },
96
- // 'border-start-end-radius': ([key, val]: [string, string]) => ['border-top-right-radius', val],
97
72
  'border-bottom-end-radius': _ref16 => {
98
- let [key, val] = _ref16;
73
+ let [_key, val] = _ref16;
99
74
  return ['border-bottom-right-radius', val];
100
75
  },
101
- // 'border-end-end-radius': ([key, val]: [string, string]) => ['border-bottom-right-radius', val],
102
76
  'text-align': _ref17 => {
103
77
  let [key, val] = _ref17;
104
78
  return [key, logicalToPhysical[val] ?? val];
@@ -112,15 +86,13 @@ const propertyToLTR = {
112
86
  return [key, logicalToPhysical[val] ?? val];
113
87
  },
114
88
  start: _ref20 => {
115
- let [key, val] = _ref20;
89
+ let [_key, val] = _ref20;
116
90
  return ['left', val];
117
91
  },
118
- // 'inset-inline-start': ([key, val]: [string, string]) => ['left', val],
119
92
  end: _ref21 => {
120
- let [key, val] = _ref21;
93
+ let [_key, val] = _ref21;
121
94
  return ['right', val];
122
95
  },
123
- // 'inset-inline-end': ([key, val]) => ['right', val],
124
96
  'background-position': _ref22 => {
125
97
  let [key, val] = _ref22;
126
98
  return [key, val.split(' ').map(word => word === 'start' ? 'left' : word === 'end' ? 'right' : word).join(' ')];
@@ -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
+ declare export default function generateLTR(
11
+ pair: [string, string],
12
+ ): [string, string];
@@ -0,0 +1,13 @@
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
+ declare function generateRTL(
11
+ $$PARAM_0$$: [string, string],
12
+ ): null | undefined | [string, string];
13
+ export default generateRTL;
@@ -6,16 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = generateRTL;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- * Copyright (c) Meta Platforms, Inc. and affiliates.
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- *
15
- *
16
- *
17
- */
18
-
19
9
  const cursorFlip = {
20
10
  'e-resize': 'w-resize',
21
11
  'w-resize': 'e-resize',
@@ -70,10 +60,6 @@ function flipShadow(value) {
70
60
  return rtl;
71
61
  }
72
62
  }
73
-
74
- // Should we be flipping shadows at all?
75
- // I think the better approach would be to let engineers use
76
- // CSS-vars directly.
77
63
  const shadowsFlip = {
78
64
  'box-shadow': _ref => {
79
65
  let [key, val] = _ref;
@@ -92,85 +78,69 @@ const logicalToPhysical = {
92
78
  };
93
79
  const propertyToRTL = {
94
80
  'margin-start': _ref3 => {
95
- let [key, val] = _ref3;
81
+ let [_key, val] = _ref3;
96
82
  return ['margin-right', val];
97
83
  },
98
- // 'margin-inline-start': ([key, val]: [string, string]) => ['margin-right', val],
99
84
  'margin-end': _ref4 => {
100
- let [key, val] = _ref4;
85
+ let [_key, val] = _ref4;
101
86
  return ['margin-left', val];
102
87
  },
103
- // 'margin-inline-end': ([key, val]: [string, string]) => ['margin-left', val],
104
88
  'padding-start': _ref5 => {
105
- let [key, val] = _ref5;
89
+ let [_key, val] = _ref5;
106
90
  return ['padding-right', val];
107
91
  },
108
- // 'padding-inline-start': ([key, val]: [string, string]) => ['padding-right', val],
109
92
  'padding-end': _ref6 => {
110
- let [key, val] = _ref6;
93
+ let [_key, val] = _ref6;
111
94
  return ['padding-left', val];
112
95
  },
113
- // 'padding-inline-end': ([key, val]: [string, string]) => ['padding-left', val],
114
96
  'border-start': _ref7 => {
115
- let [key, val] = _ref7;
97
+ let [_key, val] = _ref7;
116
98
  return ['border-right', val];
117
99
  },
118
- // 'border-inline-start': ([key, val]: [string, string]) => ['border-right', val],
119
100
  'border-end': _ref8 => {
120
- let [key, val] = _ref8;
101
+ let [_key, val] = _ref8;
121
102
  return ['border-left', val];
122
103
  },
123
- // 'border-inline-end': ([key, val]: [string, string]) => ['border-left', val],
124
104
  'border-start-width': _ref9 => {
125
- let [key, val] = _ref9;
105
+ let [_key, val] = _ref9;
126
106
  return ['border-right-width', val];
127
107
  },
128
- // 'border-inline-start-width': ([key, val]: [string, string]) => ['border-right-width', val],
129
108
  'border-end-width': _ref10 => {
130
- let [key, val] = _ref10;
109
+ let [_key, val] = _ref10;
131
110
  return ['border-left-width', val];
132
111
  },
133
- // 'border-inline-end-width': ([key, val]: [string, string]) => ['border-left-width', val],
134
112
  'border-start-color': _ref11 => {
135
- let [key, val] = _ref11;
113
+ let [_key, val] = _ref11;
136
114
  return ['border-right-color', val];
137
115
  },
138
- // 'border-inline-start-color': ([key, val]: [string, string]) => ['border-right-color', val],
139
116
  'border-end-color': _ref12 => {
140
- let [key, val] = _ref12;
117
+ let [_key, val] = _ref12;
141
118
  return ['border-left-color', val];
142
119
  },
143
- // 'border-inline-end-color': ([key, val]: [string, string]) => ['border-left-color', val],
144
120
  'border-start-style': _ref13 => {
145
- let [key, val] = _ref13;
121
+ let [_key, val] = _ref13;
146
122
  return ['border-right-style', val];
147
123
  },
148
- // 'border-inline-start-style': ([key, val]: [string, string]) => ['border-right-style', val],
149
124
  'border-end-style': _ref14 => {
150
- let [key, val] = _ref14;
125
+ let [_key, val] = _ref14;
151
126
  return ['border-left-style', val];
152
127
  },
153
- // 'border-inline-end-style': ([key, val]: [string, string]) => ['border-left-style', val],
154
128
  'border-top-start-radius': _ref15 => {
155
- let [key, val] = _ref15;
129
+ let [_key, val] = _ref15;
156
130
  return ['border-top-right-radius', val];
157
131
  },
158
- // 'border-start-start-radius': ([key, val]: [string, string]) => ['border-top-right-radius', val],
159
132
  'border-bottom-start-radius': _ref16 => {
160
- let [key, val] = _ref16;
133
+ let [_key, val] = _ref16;
161
134
  return ['border-bottom-right-radius', val];
162
135
  },
163
- // 'border-end-start-radius': ([key, val]: [string, string]) => ['border-bottom-right-radius', val],
164
136
  'border-top-end-radius': _ref17 => {
165
- let [key, val] = _ref17;
137
+ let [_key, val] = _ref17;
166
138
  return ['border-top-left-radius', val];
167
139
  },
168
- // 'border-start-end-radius': ([key, val]: [string, string]) => ['border-top-left-radius', val],
169
140
  'border-bottom-end-radius': _ref18 => {
170
- let [key, val] = _ref18;
141
+ let [_key, val] = _ref18;
171
142
  return ['border-bottom-left-radius', val];
172
143
  },
173
- // 'border-end-end-radius': ([key, val]: [string, string]) => ['border-bottom-left-radius', val],
174
144
  'text-align': _ref19 => {
175
145
  let [key, val] = _ref19;
176
146
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
@@ -184,15 +154,13 @@ const propertyToRTL = {
184
154
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
185
155
  },
186
156
  start: _ref22 => {
187
- let [key, val] = _ref22;
157
+ let [_key, val] = _ref22;
188
158
  return ['right', val];
189
159
  },
190
- // 'inset-inline-start': ([key, val]: [string, string]) => ['right', val],
191
160
  end: _ref23 => {
192
- let [key, val] = _ref23;
161
+ let [_key, val] = _ref23;
193
162
  return ['left', val];
194
163
  },
195
- // 'inset-inline-end': ([key, val]: [string, string]) => ['left', val],
196
164
  'background-position': _ref24 => {
197
165
  let [key, val] = _ref24;
198
166
  const words = val.split(' ');
@@ -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
+ declare export default function generateRTL(
11
+ [string, string],
12
+ ): ?[string, string];
@@ -0,0 +1,52 @@
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 { InjectableStyle, StyleXOptions } from '../common-types';
11
+ import type { IncludedStyles } from '../stylex-include';
12
+ export type ComputedStyle = null | Readonly<[string, InjectableStyle]>;
13
+ export interface IPreRule {
14
+ compiled(
15
+ options: StyleXOptions,
16
+ ): IncludedStyles | ReadonlyArray<ComputedStyle>;
17
+ equals(other: IPreRule): boolean;
18
+ }
19
+ export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
20
+ export declare class NullPreRule implements IPreRule {
21
+ compiled(_options: StyleXOptions): [null];
22
+ equals(other: IPreRule): boolean;
23
+ }
24
+ export declare class PreIncludedStylesRule implements IPreRule {
25
+ readonly includedStyles: IncludedStyles;
26
+ constructor(IncludedStyles: IncludedStyles);
27
+ equals(other: IPreRule): boolean;
28
+ compiled(_options: StyleXOptions): IncludedStyles;
29
+ }
30
+ export declare class PreRule implements IPreRule {
31
+ readonly property: string;
32
+ readonly value: string | number | ReadonlyArray<string | number>;
33
+ readonly pseudos: ReadonlyArray<string>;
34
+ readonly atRules: ReadonlyArray<string>;
35
+ constructor(
36
+ property: string,
37
+ value: string | number | ReadonlyArray<string | number>,
38
+ pseudos?: null | undefined | ReadonlyArray<string>,
39
+ atRules?: null | undefined | ReadonlyArray<string>,
40
+ );
41
+ compiled(options: StyleXOptions): ReadonlyArray<[string, InjectableStyle]>;
42
+ equals(other: IPreRule): boolean;
43
+ }
44
+ export declare class PreRuleSet implements IPreRule {
45
+ readonly rules: ReadonlyArray<PreRule | NullPreRule>;
46
+ constructor(rules: ReadonlyArray<PreRule | NullPreRule>);
47
+ static create(
48
+ rules: ReadonlyArray<PreRule | NullPreRule | PreRuleSet>,
49
+ ): AnyPreRule;
50
+ compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
51
+ equals(other: IPreRule): boolean;
52
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PreRuleSet = exports.PreRule = exports.PreIncludedStylesRule = exports.NullPreRule = void 0;
7
+ var _convertToClassName = require("../convert-to-className");
8
+ var _objectUtils = require("../utils/object-utils");
9
+ class NullPreRule {
10
+ compiled(_options) {
11
+ return [null];
12
+ }
13
+ equals(other) {
14
+ return other instanceof NullPreRule;
15
+ }
16
+ }
17
+ exports.NullPreRule = NullPreRule;
18
+ class PreIncludedStylesRule {
19
+ constructor(IncludedStyles) {
20
+ this.includedStyles = IncludedStyles;
21
+ }
22
+ equals(other) {
23
+ return other instanceof PreIncludedStylesRule && this.includedStyles === other.includedStyles;
24
+ }
25
+ compiled(_options) {
26
+ return this.includedStyles;
27
+ }
28
+ }
29
+ exports.PreIncludedStylesRule = PreIncludedStylesRule;
30
+ const stringComparator = (a, b) => {
31
+ if (a === 'default') {
32
+ return -1;
33
+ }
34
+ if (b === 'default') {
35
+ return 1;
36
+ }
37
+ return a.localeCompare(b);
38
+ };
39
+ class PreRule {
40
+ constructor(property, value, pseudos, atRules) {
41
+ this.property = property;
42
+ this.value = value;
43
+ this.pseudos = pseudos ? (0, _objectUtils.arraySort)(pseudos, stringComparator) : [];
44
+ this.atRules = atRules ? (0, _objectUtils.arraySort)(atRules) : [];
45
+ }
46
+ compiled(options) {
47
+ const [_key, className, rule] = (0, _convertToClassName.convertStyleToClassName)([this.property, this.value], this.pseudos ?? [], this.atRules ?? [], options);
48
+ return [[className, rule]];
49
+ }
50
+ equals(other) {
51
+ if (!(other instanceof PreRule)) {
52
+ return false;
53
+ }
54
+ const valuesEqual = Array.isArray(this.value) && Array.isArray(other.value) ? (0, _objectUtils.arrayEquals)(this.value, other.value) : this.value === other.value;
55
+ return this.property === other.property && valuesEqual && (0, _objectUtils.arrayEquals)(this.pseudos, other.pseudos) && (0, _objectUtils.arrayEquals)(this.atRules, other.atRules);
56
+ }
57
+ }
58
+ exports.PreRule = PreRule;
59
+ class PreRuleSet {
60
+ constructor(rules) {
61
+ this.rules = rules;
62
+ }
63
+ static create(rules) {
64
+ const flatRules = rules.flatMap(rule => rule instanceof PreRuleSet ? rule.rules : [rule]);
65
+ if (flatRules.length === 0) {
66
+ return new NullPreRule();
67
+ }
68
+ if (flatRules.length === 1) {
69
+ return flatRules[0];
70
+ }
71
+ return new PreRuleSet(flatRules);
72
+ }
73
+ compiled(options) {
74
+ const styleTuple = this.rules.flatMap(rule => rule.compiled(options)).filter(Boolean);
75
+ return styleTuple.length > 0 ? styleTuple : [null];
76
+ }
77
+ equals(other) {
78
+ if (!(other instanceof PreRuleSet)) {
79
+ return false;
80
+ }
81
+ if (this.rules.length !== other.rules.length) {
82
+ return false;
83
+ }
84
+ return (0, _objectUtils.arrayEquals)(this.rules, other.rules, (a, b) => a.equals(b));
85
+ }
86
+ }
87
+ exports.PreRuleSet = PreRuleSet;