@stylexjs/shared 0.12.0 → 0.17.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 (140) hide show
  1. package/lib/index.d.ts +10 -36
  2. package/lib/index.js +8 -25
  3. package/lib/index.js.flow +10 -43
  4. package/lib/utils/property-priorities.d.ts +4 -0
  5. package/lib/utils/property-priorities.js +54 -8
  6. package/lib/utils/property-priorities.js.flow +8 -0
  7. package/package.json +5 -21
  8. package/README.md +0 -81
  9. package/lib/common-types.d.ts +0 -50
  10. package/lib/common-types.js +0 -1
  11. package/lib/common-types.js.flow +0 -63
  12. package/lib/convert-to-className.d.ts +0 -20
  13. package/lib/convert-to-className.js +0 -66
  14. package/lib/convert-to-className.js.flow +0 -27
  15. package/lib/generate-css-rule.d.ts +0 -17
  16. package/lib/generate-css-rule.js +0 -25
  17. package/lib/generate-css-rule.js.flow +0 -17
  18. package/lib/hash.d.ts +0 -12
  19. package/lib/hash.js +0 -50
  20. package/lib/hash.js.flow +0 -12
  21. package/lib/messages.d.ts +0 -42
  22. package/lib/messages.js +0 -39
  23. package/lib/messages.js.flow +0 -45
  24. package/lib/physical-rtl/generate-ltr.d.ts +0 -13
  25. package/lib/physical-rtl/generate-ltr.js +0 -103
  26. package/lib/physical-rtl/generate-ltr.js.flow +0 -12
  27. package/lib/physical-rtl/generate-rtl.d.ts +0 -13
  28. package/lib/physical-rtl/generate-rtl.js +0 -177
  29. package/lib/physical-rtl/generate-rtl.js.flow +0 -12
  30. package/lib/preprocess-rules/PreRule.d.ts +0 -50
  31. package/lib/preprocess-rules/PreRule.js +0 -76
  32. package/lib/preprocess-rules/PreRule.js.flow +0 -62
  33. package/lib/preprocess-rules/application-order.d.ts +0 -183
  34. package/lib/preprocess-rules/application-order.js +0 -186
  35. package/lib/preprocess-rules/application-order.js.flow +0 -134
  36. package/lib/preprocess-rules/basic-validation.d.ts +0 -13
  37. package/lib/preprocess-rules/basic-validation.js +0 -73
  38. package/lib/preprocess-rules/basic-validation.js.flow +0 -13
  39. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +0 -20
  40. package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -98
  41. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +0 -23
  42. package/lib/preprocess-rules/index.d.ts +0 -18
  43. package/lib/preprocess-rules/index.js +0 -33
  44. package/lib/preprocess-rules/index.js.flow +0 -22
  45. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +0 -165
  46. package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -147
  47. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +0 -144
  48. package/lib/preprocess-rules/property-specificity.d.ts +0 -78
  49. package/lib/preprocess-rules/property-specificity.js +0 -107
  50. package/lib/preprocess-rules/property-specificity.js.flow +0 -87
  51. package/lib/stylex-consts-utils.d.ts +0 -11
  52. package/lib/stylex-consts-utils.js +0 -1
  53. package/lib/stylex-consts-utils.js.flow +0 -14
  54. package/lib/stylex-create-theme.d.ts +0 -26
  55. package/lib/stylex-create-theme.js +0 -58
  56. package/lib/stylex-create-theme.js.flow +0 -19
  57. package/lib/stylex-create.d.ts +0 -27
  58. package/lib/stylex-create.js +0 -64
  59. package/lib/stylex-create.js.flow +0 -37
  60. package/lib/stylex-define-consts.d.ts +0 -23
  61. package/lib/stylex-define-consts.js +0 -42
  62. package/lib/stylex-define-consts.js.flow +0 -18
  63. package/lib/stylex-define-vars.d.ts +0 -28
  64. package/lib/stylex-define-vars.js +0 -96
  65. package/lib/stylex-define-vars.js.flow +0 -27
  66. package/lib/stylex-first-that-works.d.ts +0 -13
  67. package/lib/stylex-first-that-works.js +0 -26
  68. package/lib/stylex-first-that-works.js.flow +0 -12
  69. package/lib/stylex-include.d.ts +0 -18
  70. package/lib/stylex-include.js +0 -28
  71. package/lib/stylex-include.js.flow +0 -20
  72. package/lib/stylex-keyframes.d.ts +0 -17
  73. package/lib/stylex-keyframes.js +0 -55
  74. package/lib/stylex-keyframes.js.flow +0 -20
  75. package/lib/stylex-vars-utils.d.ts +0 -27
  76. package/lib/stylex-vars-utils.js +0 -69
  77. package/lib/stylex-vars-utils.js.flow +0 -31
  78. package/lib/transform-value.d.ts +0 -22
  79. package/lib/transform-value.js +0 -50
  80. package/lib/transform-value.js.flow +0 -25
  81. package/lib/types/index.d.ts +0 -240
  82. package/lib/types/index.js +0 -147
  83. package/lib/types/index.js.flow +0 -280
  84. package/lib/utils/Rule.d.ts +0 -58
  85. package/lib/utils/Rule.js +0 -50
  86. package/lib/utils/Rule.js.flow +0 -64
  87. package/lib/utils/dashify.d.ts +0 -11
  88. package/lib/utils/dashify.js +0 -9
  89. package/lib/utils/dashify.js.flow +0 -10
  90. package/lib/utils/default-options.d.ts +0 -11
  91. package/lib/utils/default-options.js +0 -17
  92. package/lib/utils/default-options.js.flow +0 -12
  93. package/lib/utils/file-based-identifier.d.ts +0 -15
  94. package/lib/utils/file-based-identifier.js +0 -14
  95. package/lib/utils/file-based-identifier.js.flow +0 -14
  96. package/lib/utils/genCSSRule.d.ts +0 -15
  97. package/lib/utils/genCSSRule.js +0 -15
  98. package/lib/utils/genCSSRule.js.flow +0 -15
  99. package/lib/utils/media-query-transform.d.ts +0 -16
  100. package/lib/utils/media-query-transform.js +0 -53
  101. package/lib/utils/media-query-transform.js.flow +0 -20
  102. package/lib/utils/normalize-value.d.ts +0 -16
  103. package/lib/utils/normalize-value.js +0 -28
  104. package/lib/utils/normalize-value.js.flow +0 -16
  105. package/lib/utils/normalizers/convert-camel-case-values.d.ts +0 -14
  106. package/lib/utils/normalizers/convert-camel-case-values.js +0 -23
  107. package/lib/utils/normalizers/convert-camel-case-values.js.flow +0 -13
  108. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +0 -17
  109. package/lib/utils/normalizers/detect-unclosed-fns.js +0 -17
  110. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +0 -16
  111. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +0 -19
  112. package/lib/utils/normalizers/font-size-px-to-rem.js +0 -24
  113. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +0 -18
  114. package/lib/utils/normalizers/leading-zero.d.ts +0 -17
  115. package/lib/utils/normalizers/leading-zero.js +0 -24
  116. package/lib/utils/normalizers/leading-zero.js.flow +0 -16
  117. package/lib/utils/normalizers/quotes.d.ts +0 -18
  118. package/lib/utils/normalizers/quotes.js +0 -17
  119. package/lib/utils/normalizers/quotes.js.flow +0 -17
  120. package/lib/utils/normalizers/timings.d.ts +0 -18
  121. package/lib/utils/normalizers/timings.js +0 -25
  122. package/lib/utils/normalizers/timings.js.flow +0 -17
  123. package/lib/utils/normalizers/whitespace.d.ts +0 -19
  124. package/lib/utils/normalizers/whitespace.js +0 -54
  125. package/lib/utils/normalizers/whitespace.js.flow +0 -18
  126. package/lib/utils/normalizers/zero-dimensions.d.ts +0 -19
  127. package/lib/utils/normalizers/zero-dimensions.js +0 -42
  128. package/lib/utils/normalizers/zero-dimensions.js.flow +0 -18
  129. package/lib/utils/object-utils.d.ts +0 -66
  130. package/lib/utils/object-utils.js +0 -99
  131. package/lib/utils/object-utils.js.flow +0 -78
  132. package/lib/utils/rule-utils.d.ts +0 -15
  133. package/lib/utils/rule-utils.js +0 -41
  134. package/lib/utils/rule-utils.js.flow +0 -16
  135. package/lib/utils/split-css-value.d.ts +0 -14
  136. package/lib/utils/split-css-value.js +0 -33
  137. package/lib/utils/split-css-value.js.flow +0 -15
  138. package/lib/validate.d.ts +0 -12
  139. package/lib/validate.js +0 -21
  140. package/lib/validate.js.flow +0 -12
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateRule = generateRule;
7
- var _generateLtr = _interopRequireDefault(require("./physical-rtl/generate-ltr"));
8
- var _generateRtl = _interopRequireDefault(require("./physical-rtl/generate-rtl"));
9
- var _genCSSRule = require("./utils/genCSSRule");
10
- var _propertyPriorities = _interopRequireDefault(require("./utils/property-priorities"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function generateRule(className, key, value, pseudos, atRules) {
13
- const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
14
- const ltrPairs = pairs.map(_generateLtr.default);
15
- const ltrDecls = ltrPairs.map(pair => pair.join(':')).join(';');
16
- const rtlDecls = pairs.map(_generateRtl.default).filter(Boolean).map(pair => pair.join(':')).join(';');
17
- const ltrRule = (0, _genCSSRule.genCSSRule)(className, ltrDecls, pseudos, atRules);
18
- const rtlRule = !rtlDecls ? null : (0, _genCSSRule.genCSSRule)(className, rtlDecls, pseudos, atRules);
19
- const priority = (0, _propertyPriorities.default)(key) + pseudos.map(_propertyPriorities.default).reduce((a, b) => a + b, 0) + atRules.map(_propertyPriorities.default).reduce((a, b) => a + b, 0);
20
- return {
21
- priority,
22
- ltr: ltrRule,
23
- rtl: rtlRule
24
- };
25
- }
@@ -1,17 +0,0 @@
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 { InjectableStyle } from './common-types';
11
- declare export function generateRule(
12
- className: string,
13
- key: string,
14
- value: string | $ReadOnlyArray<string>,
15
- pseudos: $ReadOnlyArray<string>,
16
- atRules: $ReadOnlyArray<string>,
17
- ): InjectableStyle;
package/lib/hash.d.ts DELETED
@@ -1,12 +0,0 @@
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 const $$EXPORT_DEFAULT_DECLARATION$$: (str: string) => string;
11
- export default $$EXPORT_DEFAULT_DECLARATION$$;
12
- export declare const createShortHash: (str: string) => string;
package/lib/hash.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.createShortHash = void 0;
7
- function murmurhash2_32_gc(str) {
8
- let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
- let l = str.length,
10
- h = seed ^ l,
11
- i = 0,
12
- k;
13
- while (l >= 4) {
14
- k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
15
- k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
16
- k ^= k >>> 24;
17
- k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
18
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
19
- l -= 4;
20
- ++i;
21
- }
22
- switch (l) {
23
- case 3:
24
- h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
25
- case 2:
26
- h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
27
- case 1:
28
- h ^= str.charCodeAt(i) & 0xff;
29
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
30
- }
31
- h ^= h >>> 13;
32
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
33
- h ^= h >>> 15;
34
- return h >>> 0;
35
- }
36
- const hash = str => murmurhash2_32_gc(str, 1).toString(36);
37
- var _default = exports.default = hash;
38
- const base62Chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
39
- function toBase62(num) {
40
- let result = '';
41
- let _num = num;
42
- while (_num > 0) {
43
- const remainder = _num % 62;
44
- result = base62Chars[remainder] + result;
45
- _num = Math.floor(_num / 62);
46
- }
47
- return result;
48
- }
49
- const createShortHash = str => toBase62(murmurhash2_32_gc(str, 1) % 62 ** 5);
50
- exports.createShortHash = createShortHash;
package/lib/hash.js.flow DELETED
@@ -1,12 +0,0 @@
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 (str: string) => string;
11
-
12
- declare export const createShortHash: (str: string) => string;
package/lib/messages.d.ts DELETED
@@ -1,42 +0,0 @@
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
- export declare const ILLEGAL_ARGUMENT_LENGTH: 'stylex.create() should have 1 argument.';
11
- export declare const ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES: 'stylex.keyframes() should have 1 argument.';
12
- export declare const NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
13
- export declare const NON_STATIC_KEYFRAME_VALUE: 'Only static values are allowed inside of a stylex.keyframes() call.';
14
- export declare const ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
15
- export declare const UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
16
- export declare const ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
17
- export declare const NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
18
- export declare const NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL: 'stylex.keyframes() can only accept an object.';
19
- export declare const UNKNOWN_PROP_KEY: 'Unknown property key';
20
- export declare const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
21
- export declare const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
22
- export declare const NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
23
- export declare const ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
24
- export declare const UNKNOWN_NAMESPACE: 'Unknown namespace';
25
- export declare const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
26
- export declare const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
27
- export declare const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
28
- export declare const ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
29
- export declare const NON_OBJECT_KEYFRAME: 'Every frame within a stylex.keyframes() call must be an object.';
30
- export declare const INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle` to verify their type.';
31
- export declare const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
32
- export declare const LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
33
- export declare const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
34
- export declare const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
35
- export declare const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
36
- export declare const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
37
- export declare const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
38
- export declare const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.defineVars() must be bound to a named export.';
39
- export declare const ANONYMOUS_THEME: 'stylex.createTheme() must be bound to a named constant.';
40
- export declare const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
41
- export declare const NON_CONTIGUOUS_VARS: 'All variables passed to `stylex.firstThatWorks` must be contiguous.';
42
- export declare const NO_OBJECT_SPREADS: 'Object spreads are not allowed in stylex.create call.';
package/lib/messages.js DELETED
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL = exports.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = exports.NO_PROJECT_ROOT_DIRECTORY = exports.NO_PARENT_PATH = exports.NO_OBJECT_SPREADS = exports.NO_CONDITIONAL_SHORTHAND = exports.NON_STATIC_VALUE = exports.NON_STATIC_KEYFRAME_VALUE = exports.NON_OBJECT_KEYFRAME = exports.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.NON_EXPORT_NAMED_DECLARATION = exports.NON_CONTIGUOUS_VARS = 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_ARG_LENGTH_FOR_KEYFRAMES = 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.create() should have 1 argument.';
8
- const ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = exports.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = 'stylex.keyframes() should have 1 argument.';
9
- const NON_STATIC_VALUE = exports.NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
10
- const NON_STATIC_KEYFRAME_VALUE = exports.NON_STATIC_KEYFRAME_VALUE = 'Only static values are allowed inside of a stylex.keyframes() call.';
11
- const ESCAPED_STYLEX_VALUE = exports.ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
12
- const UNBOUND_STYLEX_CALL_VALUE = exports.UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
13
- const ONLY_TOP_LEVEL = exports.ONLY_TOP_LEVEL = 'stylex.create() is only allowed at the root of a program.';
14
- const NON_OBJECT_FOR_STYLEX_CALL = exports.NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
15
- const NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = exports.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = 'stylex.keyframes() can only accept an object.';
16
- const UNKNOWN_PROP_KEY = exports.UNKNOWN_PROP_KEY = 'Unknown property key';
17
- const INVALID_PSEUDO = exports.INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
18
- const INVALID_PSEUDO_OR_AT_RULE = exports.INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
19
- const NO_CONDITIONAL_SHORTHAND = exports.NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
20
- const ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
21
- const UNKNOWN_NAMESPACE = exports.UNKNOWN_NAMESPACE = 'Unknown namespace';
22
- const ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
23
- const ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
24
- const ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
25
- const ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
26
- const NON_OBJECT_KEYFRAME = exports.NON_OBJECT_KEYFRAME = 'Every frame within a stylex.keyframes() call must be an object.';
27
- const INVALID_SPREAD = exports.INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
28
- const LINT_UNCLOSED_FUNCTION = exports.LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
29
- const LOCAL_ONLY = exports.LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
30
- const UNEXPECTED_ARGUMENT = exports.UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
31
- const EXPECTED_FUNCTION_CALL = exports.EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
32
- const NO_PARENT_PATH = exports.NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
33
- const DUPLICATE_CONDITIONAL = exports.DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
34
- const NO_PROJECT_ROOT_DIRECTORY = exports.NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
35
- const NON_EXPORT_NAMED_DECLARATION = exports.NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.defineVars() must be bound to a named export.';
36
- const ANONYMOUS_THEME = exports.ANONYMOUS_THEME = 'stylex.createTheme() must be bound to a named constant.';
37
- const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = exports.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
38
- const NON_CONTIGUOUS_VARS = exports.NON_CONTIGUOUS_VARS = 'All variables passed to `stylex.firstThatWorks` must be contiguous.';
39
- const NO_OBJECT_SPREADS = exports.NO_OBJECT_SPREADS = 'Object spreads are not allowed in stylex.create call.';
@@ -1,45 +0,0 @@
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 documentation website for Stylex.
12
-
13
- declare export const ILLEGAL_ARGUMENT_LENGTH: 'stylex.create() should have 1 argument.';
14
- declare export const ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES: 'stylex.keyframes() should have 1 argument.';
15
- declare export const NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
16
- declare export const NON_STATIC_KEYFRAME_VALUE: 'Only static values are allowed inside of a stylex.keyframes() call.';
17
- declare export const ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
18
- declare export const UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
19
- declare export const ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
20
- declare export const NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
21
- declare export const NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL: 'stylex.keyframes() can only accept an object.';
22
- declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
23
- declare export const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
24
- declare export const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
25
- declare export const NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
26
- declare export const ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
27
- declare export const UNKNOWN_NAMESPACE: 'Unknown namespace';
28
- declare export const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
29
- declare export const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
30
- declare export const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
31
- declare export const ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
32
- declare export const NON_OBJECT_KEYFRAME: 'Every frame within a stylex.keyframes() call must be an object.';
33
- declare export const INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
34
- declare export const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
35
- declare export const LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
36
- declare export const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
37
- declare export const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
38
- declare export const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
39
- declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
40
- declare export const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
41
- declare export const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.defineVars() must be bound to a named export.';
42
- declare export const ANONYMOUS_THEME: 'stylex.createTheme() must be bound to a named constant.';
43
- declare export const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
44
- declare export const NON_CONTIGUOUS_VARS: 'All variables passed to `stylex.firstThatWorks` must be contiguous.';
45
- declare export const NO_OBJECT_SPREADS: 'Object spreads are not allowed in stylex.create call.';
@@ -1,13 +0,0 @@
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(
11
- pair: Readonly<[string, string]>,
12
- ): Readonly<[string, string]>;
13
- export default generateLTR;
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = generateLTR;
7
- const logicalToPhysical = {
8
- start: 'left',
9
- end: 'right'
10
- };
11
- const propertyToLTR = {
12
- 'margin-start': _ref => {
13
- let [_key, val] = _ref;
14
- return ['margin-left', val];
15
- },
16
- 'margin-end': _ref2 => {
17
- let [_key, val] = _ref2;
18
- return ['margin-right', val];
19
- },
20
- 'padding-start': _ref3 => {
21
- let [_key, val] = _ref3;
22
- return ['padding-left', val];
23
- },
24
- 'padding-end': _ref4 => {
25
- let [_key, val] = _ref4;
26
- return ['padding-right', val];
27
- },
28
- 'border-start': _ref5 => {
29
- let [_key, val] = _ref5;
30
- return ['border-left', val];
31
- },
32
- 'border-end': _ref6 => {
33
- let [_key, val] = _ref6;
34
- return ['border-right', val];
35
- },
36
- 'border-start-width': _ref7 => {
37
- let [_key, val] = _ref7;
38
- return ['border-left-width', val];
39
- },
40
- 'border-end-width': _ref8 => {
41
- let [_key, val] = _ref8;
42
- return ['border-right-width', val];
43
- },
44
- 'border-start-color': _ref9 => {
45
- let [_key, val] = _ref9;
46
- return ['border-left-color', val];
47
- },
48
- 'border-end-color': _ref10 => {
49
- let [_key, val] = _ref10;
50
- return ['border-right-color', val];
51
- },
52
- 'border-start-style': _ref11 => {
53
- let [_key, val] = _ref11;
54
- return ['border-left-style', val];
55
- },
56
- 'border-end-style': _ref12 => {
57
- let [_key, val] = _ref12;
58
- return ['border-right-style', val];
59
- },
60
- 'border-top-start-radius': _ref13 => {
61
- let [_key, val] = _ref13;
62
- return ['border-top-left-radius', val];
63
- },
64
- 'border-bottom-start-radius': _ref14 => {
65
- let [_key, val] = _ref14;
66
- return ['border-bottom-left-radius', val];
67
- },
68
- 'border-top-end-radius': _ref15 => {
69
- let [_key, val] = _ref15;
70
- return ['border-top-right-radius', val];
71
- },
72
- 'border-bottom-end-radius': _ref16 => {
73
- let [_key, val] = _ref16;
74
- return ['border-bottom-right-radius', val];
75
- },
76
- float: _ref17 => {
77
- let [key, val] = _ref17;
78
- return [key, logicalToPhysical[val] ?? val];
79
- },
80
- clear: _ref18 => {
81
- let [key, val] = _ref18;
82
- return [key, logicalToPhysical[val] ?? val];
83
- },
84
- start: _ref19 => {
85
- let [_key, val] = _ref19;
86
- return ['left', val];
87
- },
88
- end: _ref20 => {
89
- let [_key, val] = _ref20;
90
- return ['right', val];
91
- },
92
- 'background-position': _ref21 => {
93
- let [key, val] = _ref21;
94
- return [key, val.split(' ').map(word => word === 'start' ? 'left' : word === 'end' ? 'right' : word).join(' ')];
95
- }
96
- };
97
- function generateLTR(pair) {
98
- const [key] = pair;
99
- if (propertyToLTR[key]) {
100
- return propertyToLTR[key](pair);
101
- }
102
- return pair;
103
- }
@@ -1,12 +0,0 @@
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: $ReadOnly<[string, string]>,
12
- ): $ReadOnly<[string, string]>;
@@ -1,13 +0,0 @@
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$$: Readonly<[string, string]>,
12
- ): null | undefined | Readonly<[string, string]>;
13
- export default generateRTL;
@@ -1,177 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = generateRTL;
7
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const cursorFlip = {
10
- 'e-resize': 'w-resize',
11
- 'w-resize': 'e-resize',
12
- 'ne-resize': 'nw-resize',
13
- 'nesw-resize': 'nwse-resize',
14
- 'nw-resize': 'ne-resize',
15
- 'nwse-resize': 'nesw-resize',
16
- 'se-resize': 'sw-resize',
17
- 'sw-resize': 'se-resize'
18
- };
19
- function splitByDivisor(value) {
20
- const ast = (0, _postcssValueParser.default)(value);
21
- const groups = [];
22
- let currGroup = [];
23
- function push() {
24
- if (currGroup.length === 0) {
25
- return;
26
- }
27
- groups.push(_postcssValueParser.default.stringify(currGroup));
28
- currGroup = [];
29
- }
30
- for (const node of ast.nodes) {
31
- if (node.type === 'div') {
32
- push();
33
- } else {
34
- currGroup.push(node);
35
- }
36
- }
37
- push();
38
- return groups;
39
- }
40
- function flipSign(value) {
41
- if (value === '0') {
42
- return value;
43
- } else {
44
- return value[0] === '-' ? value.slice(1) : '-' + value;
45
- }
46
- }
47
- function flipShadow(value) {
48
- const defs = splitByDivisor(value);
49
- const builtDefs = [];
50
- for (const def of defs) {
51
- const parts = def.split(' ');
52
- const index = _postcssValueParser.default.unit(parts[0]) === false ? 1 : 0;
53
- if (index < parts.length) {
54
- parts[index] = flipSign(parts[index]);
55
- }
56
- builtDefs.push(parts.join(' '));
57
- }
58
- const rtl = builtDefs.join(', ');
59
- if (rtl !== value) {
60
- return rtl;
61
- }
62
- }
63
- const logicalToPhysical = {
64
- start: 'right',
65
- end: 'left'
66
- };
67
- const propertyToRTL = {
68
- 'margin-start': _ref => {
69
- let [_key, val] = _ref;
70
- return ['margin-right', val];
71
- },
72
- 'margin-end': _ref2 => {
73
- let [_key, val] = _ref2;
74
- return ['margin-left', val];
75
- },
76
- 'padding-start': _ref3 => {
77
- let [_key, val] = _ref3;
78
- return ['padding-right', val];
79
- },
80
- 'padding-end': _ref4 => {
81
- let [_key, val] = _ref4;
82
- return ['padding-left', val];
83
- },
84
- 'border-start': _ref5 => {
85
- let [_key, val] = _ref5;
86
- return ['border-right', val];
87
- },
88
- 'border-end': _ref6 => {
89
- let [_key, val] = _ref6;
90
- return ['border-left', val];
91
- },
92
- 'border-start-width': _ref7 => {
93
- let [_key, val] = _ref7;
94
- return ['border-right-width', val];
95
- },
96
- 'border-end-width': _ref8 => {
97
- let [_key, val] = _ref8;
98
- return ['border-left-width', val];
99
- },
100
- 'border-start-color': _ref9 => {
101
- let [_key, val] = _ref9;
102
- return ['border-right-color', val];
103
- },
104
- 'border-end-color': _ref10 => {
105
- let [_key, val] = _ref10;
106
- return ['border-left-color', val];
107
- },
108
- 'border-start-style': _ref11 => {
109
- let [_key, val] = _ref11;
110
- return ['border-right-style', val];
111
- },
112
- 'border-end-style': _ref12 => {
113
- let [_key, val] = _ref12;
114
- return ['border-left-style', val];
115
- },
116
- 'border-top-start-radius': _ref13 => {
117
- let [_key, val] = _ref13;
118
- return ['border-top-right-radius', val];
119
- },
120
- 'border-bottom-start-radius': _ref14 => {
121
- let [_key, val] = _ref14;
122
- return ['border-bottom-right-radius', val];
123
- },
124
- 'border-top-end-radius': _ref15 => {
125
- let [_key, val] = _ref15;
126
- return ['border-top-left-radius', val];
127
- },
128
- 'border-bottom-end-radius': _ref16 => {
129
- let [_key, val] = _ref16;
130
- return ['border-bottom-left-radius', val];
131
- },
132
- float: _ref17 => {
133
- let [key, val] = _ref17;
134
- return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
135
- },
136
- clear: _ref18 => {
137
- let [key, val] = _ref18;
138
- return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
139
- },
140
- start: _ref19 => {
141
- let [_key, val] = _ref19;
142
- return ['right', val];
143
- },
144
- end: _ref20 => {
145
- let [_key, val] = _ref20;
146
- return ['left', val];
147
- },
148
- 'background-position': _ref21 => {
149
- let [key, val] = _ref21;
150
- const words = val.split(' ');
151
- if (!words.includes('start') && !words.includes('end')) {
152
- return null;
153
- }
154
- return [key, words.map(word => word === 'start' ? 'right' : word === 'end' ? 'left' : word).join(' ')];
155
- },
156
- cursor: _ref22 => {
157
- let [key, val] = _ref22;
158
- return cursorFlip[val] != null ? [key, cursorFlip[val]] : null;
159
- },
160
- 'box-shadow': _ref23 => {
161
- let [key, val] = _ref23;
162
- const rtlVal = flipShadow(val);
163
- return rtlVal ? [key, rtlVal] : null;
164
- },
165
- 'text-shadow': _ref24 => {
166
- let [key, val] = _ref24;
167
- const rtlVal = flipShadow(val);
168
- return rtlVal ? [key, rtlVal] : null;
169
- }
170
- };
171
- function generateRTL(_ref25) {
172
- let [key, value] = _ref25;
173
- if (propertyToRTL[key]) {
174
- return propertyToRTL[key]([key, value]);
175
- }
176
- return null;
177
- }
@@ -1,12 +0,0 @@
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
- $ReadOnly<[string, string]>,
12
- ): ?$ReadOnly<[string, string]>;
@@ -1,50 +0,0 @@
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
- export type ClassesToOriginalPaths = {
12
- readonly [className: string]: ReadonlyArray<string>;
13
- };
14
- export type ComputedStyle = null | Readonly<
15
- [string, InjectableStyle, ClassesToOriginalPaths]
16
- >;
17
- export interface IPreRule {
18
- compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
19
- equals(other: IPreRule): boolean;
20
- }
21
- export type AnyPreRule = NullPreRule | PreRule | PreRuleSet;
22
- export declare class NullPreRule implements IPreRule {
23
- compiled(_options: StyleXOptions): [null];
24
- equals(other: IPreRule): boolean;
25
- }
26
- export declare class PreRule implements IPreRule {
27
- readonly property: string;
28
- readonly value: string | number | ReadonlyArray<string | number>;
29
- readonly keyPath: ReadonlyArray<string>;
30
- constructor(
31
- property: string,
32
- value: string | number | ReadonlyArray<string | number>,
33
- keyPath?: ReadonlyArray<string>,
34
- );
35
- get pseudos(): ReadonlyArray<string>;
36
- get atRules(): ReadonlyArray<string>;
37
- compiled(
38
- options: StyleXOptions,
39
- ): ReadonlyArray<[string, InjectableStyle, ClassesToOriginalPaths]>;
40
- equals(other: IPreRule): boolean;
41
- }
42
- export declare class PreRuleSet implements IPreRule {
43
- readonly rules: ReadonlyArray<PreRule | NullPreRule>;
44
- constructor(rules: ReadonlyArray<PreRule | NullPreRule>);
45
- static create(
46
- rules: ReadonlyArray<PreRule | NullPreRule | PreRuleSet>,
47
- ): AnyPreRule;
48
- compiled(options: StyleXOptions): ReadonlyArray<ComputedStyle>;
49
- equals(other: IPreRule): boolean;
50
- }