@stylexjs/shared 0.2.0-beta.20 → 0.2.0-beta.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/lib/convert-to-className.js +6 -6
  2. package/lib/generate-css-rule.js +3 -3
  3. package/lib/hash.js +10 -11
  4. package/lib/index.d.ts +4 -4
  5. package/lib/index.js +12 -21
  6. package/lib/index.js.flow +4 -4
  7. package/lib/messages.d.ts +2 -1
  8. package/lib/messages.js +29 -54
  9. package/lib/messages.js.flow +2 -1
  10. package/lib/physical-rtl/generate-ltr.js +39 -39
  11. package/lib/physical-rtl/generate-rtl.js +57 -57
  12. package/lib/preprocess-rules/PreRule.js +2 -2
  13. package/lib/preprocess-rules/application-order.d.ts +36 -8
  14. package/lib/preprocess-rules/application-order.js +149 -164
  15. package/lib/preprocess-rules/application-order.js.flow +35 -7
  16. package/lib/preprocess-rules/basic-validation.js +6 -6
  17. package/lib/preprocess-rules/flatten-raw-style-obj.js +10 -10
  18. package/lib/preprocess-rules/index.js +6 -6
  19. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +22 -2
  20. package/lib/preprocess-rules/legacy-expand-shorthands.js +81 -65
  21. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +22 -2
  22. package/lib/preprocess-rules/property-specificity.d.ts +29 -25
  23. package/lib/preprocess-rules/property-specificity.js +63 -75
  24. package/lib/preprocess-rules/property-specificity.js.flow +28 -24
  25. package/lib/properties/CSS Animations.json +445 -0
  26. package/lib/properties/CSS Backgrounds and Borders.json +1085 -0
  27. package/lib/properties/CSS Basic User Interface.json +365 -0
  28. package/lib/properties/CSS Box Alignment.json +245 -0
  29. package/lib/properties/CSS Box Model.json +501 -0
  30. package/lib/properties/CSS Color.json +100 -0
  31. package/lib/properties/CSS Columns.json +185 -0
  32. package/lib/properties/CSS Containment.json +203 -0
  33. package/lib/properties/CSS Counter Styles.json +56 -0
  34. package/lib/properties/CSS Display.json +20 -0
  35. package/lib/properties/CSS Flexible Box Layout.json +167 -0
  36. package/lib/properties/CSS Fonts.json +684 -0
  37. package/lib/properties/CSS Fragmentation.json +110 -0
  38. package/lib/properties/CSS Generated Content.json +38 -0
  39. package/lib/properties/CSS Grid Layout.json +500 -0
  40. package/lib/properties/CSS Images.json +91 -0
  41. package/lib/properties/CSS Inline.json +38 -0
  42. package/lib/properties/CSS Lists and Counters.json +86 -0
  43. package/lib/properties/CSS Logical Properties.json +1086 -0
  44. package/lib/properties/CSS Masking.json +399 -0
  45. package/lib/properties/CSS Miscellaneous.json +38 -0
  46. package/lib/properties/CSS Motion Path.json +132 -0
  47. package/lib/properties/CSS Overflow.json +216 -0
  48. package/lib/properties/CSS Pages.json +83 -0
  49. package/lib/properties/CSS Positioning.json +166 -0
  50. package/lib/properties/CSS Ruby.json +55 -0
  51. package/lib/properties/CSS Scroll Anchoring.json +19 -0
  52. package/lib/properties/CSS Scroll Snap.json +604 -0
  53. package/lib/properties/CSS Scrollbars.json +38 -0
  54. package/lib/properties/CSS Shapes.json +56 -0
  55. package/lib/properties/CSS Speech.json +20 -0
  56. package/lib/properties/CSS Table.json +115 -0
  57. package/lib/properties/CSS Text Decoration.json +312 -0
  58. package/lib/properties/CSS Text.json +415 -0
  59. package/lib/properties/CSS Transforms.json +188 -0
  60. package/lib/properties/CSS Transitions.json +122 -0
  61. package/lib/properties/CSS Variables.json +20 -0
  62. package/lib/properties/CSS View Transitions.json +20 -0
  63. package/lib/properties/CSS Will Change.json +20 -0
  64. package/lib/properties/CSS Writing Modes.json +92 -0
  65. package/lib/properties/Compositing and Blending.json +62 -0
  66. package/lib/properties/Filter Effects.json +38 -0
  67. package/lib/properties/MathML.json +56 -0
  68. package/lib/properties/Microsoft Extensions.json +885 -0
  69. package/lib/properties/Mozilla Extensions.json +607 -0
  70. package/lib/properties/Pointer Events.json +20 -0
  71. package/lib/properties/WebKit Extensions.json +707 -0
  72. package/lib/properties.json +10122 -0
  73. package/lib/{stylex-override-vars.d.ts → stylex-create-theme.d.ts} +2 -2
  74. package/lib/{stylex-override-vars.js → stylex-create-theme.js} +13 -13
  75. package/lib/{stylex-override-vars.js.flow → stylex-create-theme.js.flow} +1 -1
  76. package/lib/stylex-create.js +1 -1
  77. package/lib/{stylex-create-vars.d.ts → stylex-define-vars.d.ts} +4 -4
  78. package/lib/{stylex-create-vars.js → stylex-define-vars.js} +9 -9
  79. package/lib/{stylex-create-vars.js.flow → stylex-define-vars.js.flow} +4 -4
  80. package/lib/stylex-keyframes.js +6 -6
  81. package/lib/transform-value.js +13 -15
  82. package/lib/types/index.d.ts +1 -4
  83. package/lib/types/index.js +33 -46
  84. package/lib/types/index.js.flow +2 -2
  85. package/lib/utils/dashify.js +1 -1
  86. package/lib/utils/default-options.js +4 -5
  87. package/lib/utils/file-based-identifier.js +1 -1
  88. package/lib/utils/genCSSRule.js +6 -6
  89. package/lib/utils/normalize-value.js +3 -2
  90. package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +14 -0
  91. package/lib/utils/normalizers/convert-camel-case-transition-props.js +23 -0
  92. package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +13 -0
  93. package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  94. package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
  95. package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  96. package/lib/utils/normalizers/detect-unclosed-fns.js +2 -2
  97. package/lib/utils/normalizers/font-size-px-to-rem.js +4 -4
  98. package/lib/utils/normalizers/leading-zero.js +3 -3
  99. package/lib/utils/normalizers/quotes.js +4 -4
  100. package/lib/utils/normalizers/timings.js +4 -4
  101. package/lib/utils/normalizers/whitespace.js +12 -12
  102. package/lib/utils/normalizers/zero-dimensions.js +8 -8
  103. package/lib/utils/object-utils.d.ts +3 -6
  104. package/lib/utils/object-utils.js +2 -2
  105. package/lib/utils/property-priorities.js +527 -88
  106. package/lib/utils/split-css-value.js +8 -8
  107. package/lib/validate.js +2 -2
  108. package/package.json +2 -2
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ declare export default function convertCamelCasedTransitionProps(
11
+ ast: PostCSSValueAST,
12
+ key: string,
13
+ ): PostCSSValueAST;
@@ -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
+ declare function convertCamelCasedValues(
11
+ ast: PostCSSValueAST,
12
+ key: string,
13
+ ): PostCSSValueAST;
14
+ export default convertCamelCasedValues;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = convertCamelCasedValues;
7
+ var _dashify = _interopRequireDefault(require("../dashify"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function convertCamelCasedValues(ast, key) {
10
+ if (key !== 'transitionProperty' && key !== 'willChange') {
11
+ return ast;
12
+ }
13
+ const nodes = ast.nodes;
14
+ if (!nodes) {
15
+ return ast;
16
+ }
17
+ nodes.forEach(node => {
18
+ if (node.type === 'word' && !node.value.startsWith('--')) {
19
+ node.value = (0, _dashify.default)(node.value);
20
+ }
21
+ });
22
+ return ast;
23
+ }
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ declare export default function convertCamelCasedValues(
11
+ ast: PostCSSValueAST,
12
+ key: string,
13
+ ): PostCSSValueAST;
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -9,7 +9,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
9
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
10
  function detectUnclosedFns(ast, _) {
11
11
  ast.walk(node => {
12
- if (node.type === "function" && node.unclosed) {
12
+ if (node.type === 'function' && node.unclosed) {
13
13
  throw new Error(messages.LINT_UNCLOSED_FUNCTION);
14
14
  }
15
15
  });
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -8,15 +8,15 @@ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  const ROOT_FONT_SIZE = 16;
10
10
  function convertFontSizeToRem(ast, key) {
11
- if (key !== "fontSize") {
11
+ if (key !== 'fontSize') {
12
12
  return ast;
13
13
  }
14
14
  ast.walk(node => {
15
- if (node.type !== "word") {
15
+ if (node.type !== 'word') {
16
16
  return;
17
17
  }
18
18
  const dimension = _postcssValueParser.default.unit(node.value);
19
- if (dimension && dimension.unit === "px") {
19
+ if (dimension && dimension.unit === 'px') {
20
20
  node.value = `${parseFloat(dimension.number) / ROOT_FONT_SIZE}rem`;
21
21
  }
22
22
  });
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -8,7 +8,7 @@ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  function normalizeLeadingZero(ast, _) {
10
10
  ast.walk(node => {
11
- if (node.type !== "word") {
11
+ if (node.type !== 'word') {
12
12
  return;
13
13
  }
14
14
  const value = Number.parseFloat(node.value);
@@ -17,7 +17,7 @@ function normalizeLeadingZero(ast, _) {
17
17
  }
18
18
  const dimension = _postcssValueParser.default.unit(node.value);
19
19
  if (value < 1 && value >= 0) {
20
- node.value = value.toString().replace("0.", ".") + (dimension ? dimension.unit : "");
20
+ node.value = value.toString().replace('0.', '.') + (dimension ? dimension.unit : '');
21
21
  }
22
22
  });
23
23
  return ast;
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = normalizeQuotes;
7
7
  function normalizeQuotes(ast, _) {
8
8
  ast.walk(node => {
9
- if (node.type !== "string") {
9
+ if (node.type !== 'string') {
10
10
  return;
11
11
  }
12
- if (node.value === "") {
13
- node.quote = "\"";
12
+ if (node.value === '') {
13
+ node.quote = '"';
14
14
  }
15
15
  });
16
16
  return ast;
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -8,7 +8,7 @@ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  function normalizeTimings(ast, _) {
10
10
  ast.walk(node => {
11
- if (node.type !== "word") {
11
+ if (node.type !== 'word') {
12
12
  return;
13
13
  }
14
14
  const value = Number.parseFloat(node.value);
@@ -16,10 +16,10 @@ function normalizeTimings(ast, _) {
16
16
  return;
17
17
  }
18
18
  const dimension = _postcssValueParser.default.unit(node.value);
19
- if (!dimension || dimension.unit !== "ms" || value < 10) {
19
+ if (!dimension || dimension.unit !== 'ms' || value < 10) {
20
20
  return;
21
21
  }
22
- node.value = value / 1000 + "s";
22
+ node.value = value / 1000 + 's';
23
23
  });
24
24
  return ast;
25
25
  }
@@ -1,34 +1,34 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = normalizeWhitespace;
7
7
  function normalizeWhitespace(ast, _) {
8
- if (ast.nodes[0].type === "space") {
8
+ if (ast.nodes[0].type === 'space') {
9
9
  ast.nodes.shift();
10
10
  }
11
- if (ast.nodes[ast.nodes.length - 1].type === "space") {
11
+ if (ast.nodes[ast.nodes.length - 1].type === 'space') {
12
12
  ast.nodes.pop();
13
13
  }
14
14
  ast.walk((node, idx) => {
15
15
  switch (node.type) {
16
- case "space":
16
+ case 'space':
17
17
  {
18
- node.value = " ";
18
+ node.value = ' ';
19
19
  break;
20
20
  }
21
- case "div":
22
- case "function":
21
+ case 'div':
22
+ case 'function':
23
23
  {
24
- node.before = "";
25
- node.after = "";
24
+ node.before = '';
25
+ node.after = '';
26
26
  break;
27
27
  }
28
- case "word":
28
+ case 'word':
29
29
  {
30
- if (node.value === "!important") {
31
- if (ast.nodes[idx - 1] && ast.nodes[idx - 1].type === "space") {
30
+ if (node.value === '!important') {
31
+ if (ast.nodes[idx - 1] && ast.nodes[idx - 1].type === 'space') {
32
32
  ast.nodes.splice(idx - 1, 1);
33
33
  }
34
34
  }
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -6,23 +6,23 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = normalizeZeroDimensions;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const angles = ["deg", "grad", "turn", "rad"];
10
- const timings = ["ms", "s"];
9
+ const angles = ['deg', 'grad', 'turn', 'rad'];
10
+ const timings = ['ms', 's'];
11
11
  function normalizeZeroDimensions(ast, _) {
12
12
  ast.walk(node => {
13
- if (node.type !== "word") {
13
+ if (node.type !== 'word') {
14
14
  return;
15
15
  }
16
16
  const dimension = _postcssValueParser.default.unit(node.value);
17
- if (!dimension || dimension.number !== "0") {
17
+ if (!dimension || dimension.number !== '0') {
18
18
  return;
19
19
  }
20
20
  if (angles.indexOf(dimension.unit) !== -1) {
21
- node.value = "0deg";
21
+ node.value = '0deg';
22
22
  } else if (timings.indexOf(dimension.unit) !== -1) {
23
- node.value = "0s";
23
+ node.value = '0s';
24
24
  } else {
25
- node.value = "0";
25
+ node.value = '0';
26
26
  }
27
27
  });
28
28
  return ast;
@@ -13,12 +13,9 @@ export declare function isPlainObject(obj: unknown): void;
13
13
  export declare function flattenObject(obj: CompiledStyles): {
14
14
  readonly [$$Key$$: string]: null | string | IncludedStyles;
15
15
  };
16
- type _ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> =
17
- /**
18
- * > 23 | [Key in keyof Obj]: [Key, Obj[Key]],
19
- * | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object type with mapped type property" is currently not supported.
20
- **/
21
- any;
16
+ type _ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> = {
17
+ [Key in keyof Obj]: [Key, Obj[Key]];
18
+ };
22
19
  type ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> =
23
20
  _ObjectEntries<Obj>[keyof _ObjectEntries<Obj>];
24
21
  export declare function objEntries<
@@ -14,12 +14,12 @@ exports.objMapKeys = objMapKeys;
14
14
  exports.objValues = objValues;
15
15
  var _stylexInclude = require("../stylex-include");
16
16
  function isPlainObject(obj) {
17
- return typeof obj === "object" && obj != null && !Array.isArray(obj) && obj?.constructor === Object;
17
+ return typeof obj === 'object' && obj != null && !Array.isArray(obj) && obj?.constructor === Object;
18
18
  }
19
19
  function flattenObject(obj) {
20
20
  const result = {};
21
21
  for (const [key, value] of objEntries(obj)) {
22
- if (typeof value === "string" || value == null) {
22
+ if (typeof value === 'string' || value == null) {
23
23
  result[key] = value;
24
24
  } else if (value instanceof _stylexInclude.IncludedStyles) {
25
25
  result[key] = value;