@stylexjs/shared 0.2.0-beta.16 → 0.2.0-beta.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/lib/convert-to-className.d.ts +1 -1
  2. package/lib/convert-to-className.js +6 -22
  3. package/lib/convert-to-className.js.flow +1 -1
  4. package/lib/generate-css-rule.d.ts +1 -1
  5. package/lib/generate-css-rule.js +3 -14
  6. package/lib/generate-css-rule.js.flow +1 -1
  7. package/lib/hash.d.ts +2 -2
  8. package/lib/hash.js +9 -33
  9. package/lib/hash.js.flow +1 -3
  10. package/lib/index.d.ts +9 -9
  11. package/lib/index.js +0 -14
  12. package/lib/index.js.flow +9 -9
  13. package/lib/messages.d.ts +26 -26
  14. package/lib/messages.js +26 -36
  15. package/lib/messages.js.flow +26 -26
  16. package/lib/physical-rtl/generate-ltr.js +39 -67
  17. package/lib/physical-rtl/generate-ltr.js.flow +1 -1
  18. package/lib/physical-rtl/generate-rtl.d.ts +1 -2
  19. package/lib/physical-rtl/generate-rtl.js +57 -89
  20. package/lib/physical-rtl/generate-rtl.js.flow +1 -2
  21. package/lib/preprocess-rules/PreRule.d.ts +3 -3
  22. package/lib/preprocess-rules/PreRule.js +3 -17
  23. package/lib/preprocess-rules/PreRule.js.flow +3 -3
  24. package/lib/preprocess-rules/application-order.d.ts +8 -5
  25. package/lib/preprocess-rules/application-order.js +121 -160
  26. package/lib/preprocess-rules/application-order.js.flow +6 -5
  27. package/lib/preprocess-rules/basic-validation.d.ts +1 -1
  28. package/lib/preprocess-rules/basic-validation.js +6 -15
  29. package/lib/preprocess-rules/basic-validation.js.flow +1 -1
  30. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +2 -2
  31. package/lib/preprocess-rules/flatten-raw-style-obj.js +14 -43
  32. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +2 -2
  33. package/lib/preprocess-rules/index.d.ts +2 -2
  34. package/lib/preprocess-rules/index.js +6 -15
  35. package/lib/preprocess-rules/index.js.flow +2 -2
  36. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -2
  37. package/lib/preprocess-rules/legacy-expand-shorthands.js +14 -33
  38. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +2 -2
  39. package/lib/preprocess-rules/property-specificity.d.ts +8 -5
  40. package/lib/preprocess-rules/property-specificity.js +54 -76
  41. package/lib/preprocess-rules/property-specificity.js.flow +6 -5
  42. package/lib/stylex-create-vars.d.ts +17 -8
  43. package/lib/stylex-create-vars.js +30 -17
  44. package/lib/stylex-create-vars.js.flow +10 -4
  45. package/lib/stylex-create.d.ts +2 -2
  46. package/lib/stylex-create.js +1 -20
  47. package/lib/stylex-create.js.flow +1 -1
  48. package/lib/stylex-first-that-works.js +0 -10
  49. package/lib/stylex-include.js +0 -10
  50. package/lib/stylex-keyframes.d.ts +1 -1
  51. package/lib/stylex-keyframes.js +7 -27
  52. package/lib/stylex-keyframes.js.flow +1 -1
  53. package/lib/stylex-override-vars.d.ts +11 -4
  54. package/lib/stylex-override-vars.js +32 -18
  55. package/lib/stylex-override-vars.js.flow +3 -3
  56. package/lib/transform-value.js +11 -29
  57. package/lib/transform-value.js.flow +1 -1
  58. package/lib/utils/Rule.d.ts +2 -2
  59. package/lib/utils/Rule.js +0 -21
  60. package/lib/utils/Rule.js.flow +2 -2
  61. package/lib/utils/dashify.js +1 -9
  62. package/lib/utils/default-options.d.ts +1 -1
  63. package/lib/utils/default-options.js +2 -23
  64. package/lib/utils/default-options.js.flow +1 -1
  65. package/lib/utils/file-based-identifier.js +1 -9
  66. package/lib/utils/genCSSRule.d.ts +1 -1
  67. package/lib/utils/genCSSRule.js +6 -16
  68. package/lib/utils/genCSSRule.js.flow +1 -1
  69. package/lib/utils/normalize-value.js +1 -13
  70. package/lib/utils/normalize-value.js.flow +1 -1
  71. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +1 -1
  72. package/lib/utils/normalizers/detect-unclosed-fns.js +2 -14
  73. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +1 -1
  74. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +1 -1
  75. package/lib/utils/normalizers/font-size-px-to-rem.js +4 -19
  76. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +1 -1
  77. package/lib/utils/normalizers/leading-zero.d.ts +1 -1
  78. package/lib/utils/normalizers/leading-zero.js +3 -15
  79. package/lib/utils/normalizers/leading-zero.js.flow +1 -1
  80. package/lib/utils/normalizers/quotes.d.ts +1 -1
  81. package/lib/utils/normalizers/quotes.js +4 -17
  82. package/lib/utils/normalizers/quotes.js.flow +1 -1
  83. package/lib/utils/normalizers/timings.d.ts +1 -1
  84. package/lib/utils/normalizers/timings.js +4 -18
  85. package/lib/utils/normalizers/timings.js.flow +1 -1
  86. package/lib/utils/normalizers/whitespace.d.ts +1 -1
  87. package/lib/utils/normalizers/whitespace.js +12 -27
  88. package/lib/utils/normalizers/whitespace.js.flow +1 -1
  89. package/lib/utils/normalizers/zero-dimensions.d.ts +1 -1
  90. package/lib/utils/normalizers/zero-dimensions.js +8 -23
  91. package/lib/utils/normalizers/zero-dimensions.js.flow +1 -1
  92. package/lib/utils/object-utils.d.ts +28 -20
  93. package/lib/utils/object-utils.js +2 -15
  94. package/lib/utils/object-utils.js.flow +23 -27
  95. package/lib/utils/property-priorities.js +68 -83
  96. package/lib/utils/split-css-value.d.ts +1 -1
  97. package/lib/utils/split-css-value.js +8 -22
  98. package/lib/utils/split-css-value.js.flow +1 -1
  99. package/lib/validate.js +2 -11
  100. package/package.json +2 -3
@@ -12,5 +12,5 @@ export declare function convertStyleToClassName(
12
12
  objEntry: [string, TRawValue],
13
13
  pseudos: ReadonlyArray<string>,
14
14
  atRules: ReadonlyArray<string>,
15
- $$PARAM_3$$: StyleXOptions
15
+ $$PARAM_3$$: StyleXOptions,
16
16
  ): StyleRule;
@@ -11,36 +11,20 @@ var _generateCssRule = require("./generate-css-rule");
11
11
  var _defaultOptions = require("./utils/default-options");
12
12
  var _objectUtils = require("./utils/object-utils");
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- /**
15
- * Copyright (c) Meta Platforms, Inc. and affiliates.
16
- *
17
- * This source code is licensed under the MIT license found in the
18
- * LICENSE file in the root directory of this source tree.
19
- *
20
- *
21
- */
22
-
23
- // This function takes a single style rule and transforms it into a CSS rule.
24
- // [color: 'red'] => ['color', 'classname-for-color-red', CSSRULE{ltr, rtl, priority}]
25
- //
26
- // It converts the camelCased style key to a dash-separated key.
27
- // Handles RTL-flipping
28
- // Hashes to get a className
29
- // Returns the final key, className a CSS Rule
30
14
  function convertStyleToClassName(objEntry, pseudos, atRules) {
31
15
  let {
32
- stylexSheetName = '<>',
33
- classNamePrefix = 'x'
16
+ stylexSheetName = "<>",
17
+ classNamePrefix = "x"
34
18
  } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions.defaultOptions;
35
19
  const [key, rawValue] = objEntry;
36
20
  const dashedKey = (0, _dashify.default)(key);
37
21
  const value = Array.isArray(rawValue) ? rawValue.map(eachValue => (0, _transformValue.default)(key, eachValue)) : (0, _transformValue.default)(key, rawValue);
38
22
  const sortedPseudos = (0, _objectUtils.arraySort)(pseudos ?? []);
39
23
  const sortedAtRules = (0, _objectUtils.arraySort)(atRules ?? []);
40
- const atRuleHashString = sortedPseudos.join('');
41
- const pseudoHashString = sortedAtRules.join('');
42
- const modifierHashString = atRuleHashString + pseudoHashString || 'null';
43
- const stringToHash = Array.isArray(value) ? dashedKey + value.join(', ') + modifierHashString : dashedKey + value + modifierHashString;
24
+ const atRuleHashString = sortedPseudos.join("");
25
+ const pseudoHashString = sortedAtRules.join("");
26
+ const modifierHashString = atRuleHashString + pseudoHashString || "null";
27
+ const stringToHash = Array.isArray(value) ? dashedKey + value.join(", ") + modifierHashString : dashedKey + value + modifierHashString;
44
28
  const className = classNamePrefix + (0, _hash.default)(stylexSheetName + stringToHash);
45
29
  const cssRules = (0, _generateCssRule.generateRule)(className, dashedKey, value, pseudos, atRules);
46
30
  return [key, className, cssRules];
@@ -19,5 +19,5 @@ declare export function convertStyleToClassName(
19
19
  objEntry: [string, TRawValue],
20
20
  pseudos: $ReadOnlyArray<string>,
21
21
  atRules: $ReadOnlyArray<string>,
22
- StyleXOptions
22
+ StyleXOptions,
23
23
  ): StyleRule;
@@ -13,5 +13,5 @@ export declare function generateRule(
13
13
  key: string,
14
14
  value: string | ReadonlyArray<string>,
15
15
  pseudos: ReadonlyArray<string>,
16
- atRules: ReadonlyArray<string>
16
+ atRules: ReadonlyArray<string>,
17
17
  ): InjectableStyle;
@@ -9,22 +9,11 @@ var _generateRtl = _interopRequireDefault(require("./physical-rtl/generate-rtl")
9
9
  var _genCSSRule = require("./utils/genCSSRule");
10
10
  var _propertyPriorities = _interopRequireDefault(require("./utils/property-priorities"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- /**
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- *
18
- *
19
- */
20
-
21
- function generateRule(className, key,
22
- // pre-dashed
23
- value, pseudos, atRules) {
12
+ function generateRule(className, key, value, pseudos, atRules) {
24
13
  const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
25
14
  const ltrPairs = pairs.map(_generateLtr.default);
26
- const ltrDecls = ltrPairs.map(pair => pair.join(':')).join(';');
27
- const rtlDecls = pairs.map(_generateRtl.default).filter(Boolean).map(pair => pair.join(':')).join(';');
15
+ const ltrDecls = ltrPairs.map(pair => pair.join(":")).join(";");
16
+ const rtlDecls = pairs.map(_generateRtl.default).filter(Boolean).map(pair => pair.join(":")).join(";");
28
17
  const ltrRule = (0, _genCSSRule.genCSSRule)(className, ltrDecls, pseudos, atRules);
29
18
  const rtlRule = !rtlDecls ? null : (0, _genCSSRule.genCSSRule)(className, rtlDecls, pseudos, atRules);
30
19
  const priority = (0, _propertyPriorities.default)(key) + Math.max(...pseudos.map(_propertyPriorities.default), ...atRules.map(_propertyPriorities.default), 0);
@@ -13,5 +13,5 @@ declare export function generateRule(
13
13
  key: string,
14
14
  value: string | $ReadOnlyArray<string>,
15
15
  pseudos: $ReadOnlyArray<string>,
16
- atRules: $ReadOnlyArray<string>
16
+ atRules: $ReadOnlyArray<string>,
17
17
  ): InjectableStyle;
package/lib/hash.d.ts CHANGED
@@ -7,5 +7,5 @@
7
7
  *
8
8
  */
9
9
 
10
- declare var hash: (str: string) => string;
11
- export default hash;
10
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: (str: string) => string;
11
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
package/lib/hash.js CHANGED
@@ -4,30 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
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
- /* eslint-disable default-case */
17
- /* eslint-disable no-fallthrough */
18
-
19
- /**
20
- * JS Implementation of MurmurHash2
21
- *
22
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
23
- * @see http://github.com/garycourt/murmurhash-js
24
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
25
- * @see http://sites.google.com/site/murmurhash/
26
- *
27
- * @param {string} str ASCII only
28
- * @param {number} seed Positive integer only
29
- * @return {number} 32-bit positive integer hash
30
- */
31
7
  function murmurhash2_32_gc(str) {
32
8
  let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
33
9
  let l = str.length,
@@ -35,25 +11,25 @@ function murmurhash2_32_gc(str) {
35
11
  i = 0,
36
12
  k;
37
13
  while (l >= 4) {
38
- k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
39
- k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
14
+ k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
15
+ k = (k & 65535) * 1540483477 + (((k >>> 16) * 1540483477 & 65535) << 16);
40
16
  k ^= k >>> 24;
41
- k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
42
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
17
+ k = (k & 65535) * 1540483477 + (((k >>> 16) * 1540483477 & 65535) << 16);
18
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16) ^ k;
43
19
  l -= 4;
44
20
  ++i;
45
21
  }
46
22
  switch (l) {
47
23
  case 3:
48
- h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
24
+ h ^= (str.charCodeAt(i + 2) & 255) << 16;
49
25
  case 2:
50
- h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
26
+ h ^= (str.charCodeAt(i + 1) & 255) << 8;
51
27
  case 1:
52
- h ^= str.charCodeAt(i) & 0xff;
53
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
28
+ h ^= str.charCodeAt(i) & 255;
29
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16);
54
30
  }
55
31
  h ^= h >>> 13;
56
- h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
32
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16);
57
33
  h ^= h >>> 15;
58
34
  return h >>> 0;
59
35
  }
package/lib/hash.js.flow CHANGED
@@ -7,6 +7,4 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare var hash: (str: string) => string;
11
-
12
- declare export default hash;
10
+ declare export default (str: string) => string;
package/lib/index.d.ts CHANGED
@@ -31,18 +31,18 @@ import type {
31
31
  MutableCompiledNamespaces as _MutableCompiledNamespaces,
32
32
  StyleXOptions as _StyleXOptions,
33
33
  } from './common-types';
34
- export declare var create: typeof styleXCreateSet;
35
- export declare var createVars: typeof styleXCreateVars;
36
- export declare var overrideVars: typeof styleXOverrideVars;
37
- export declare var keyframes: typeof stylexKeyframes;
38
- export declare var include: typeof stylexInclude;
39
- export declare var utils: {
34
+ export declare const create: typeof styleXCreateSet;
35
+ export declare const createVars: typeof styleXCreateVars;
36
+ export declare const overrideVars: typeof styleXOverrideVars;
37
+ export declare const keyframes: typeof stylexKeyframes;
38
+ export declare const include: typeof stylexInclude;
39
+ export declare const utils: {
40
40
  hash: typeof hash;
41
41
  genFileBasedIdentifier: typeof genFileBasedIdentifier;
42
42
  };
43
- export declare var messages: typeof m;
44
- export declare var IncludedStyles: typeof _IncludedStyles;
45
- export declare var firstThatWorks: typeof stylexFirstThatWorks;
43
+ export declare const messages: typeof m;
44
+ export declare const IncludedStyles: typeof _IncludedStyles;
45
+ export declare const firstThatWorks: typeof stylexFirstThatWorks;
46
46
  export type InjectableStyle = _InjectableStyle;
47
47
  export type CompiledNamespaces = _CompiledNamespaces;
48
48
  export type MutableCompiledNamespaces = _MutableCompiledNamespaces;
package/lib/index.js CHANGED
@@ -16,20 +16,6 @@ var m = _interopRequireWildcard(require("./messages"));
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  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; }
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
- /**
20
- * Copyright (c) Meta Platforms, Inc. and affiliates.
21
- *
22
- * This source code is licensed under the MIT license found in the
23
- * LICENSE file in the root directory of this source tree.
24
- *
25
- *
26
- */
27
-
28
- // All functions exposed from `stylex` are defined in a way that can be run
29
- // entirely in the browser.
30
-
31
- // These are the implementations of those functions.
32
-
33
19
  const create = _stylexCreate.default;
34
20
  exports.create = create;
35
21
  const createVars = _stylexCreateVars.default;
package/lib/index.js.flow CHANGED
@@ -39,18 +39,18 @@ import type {
39
39
  StyleXOptions as _StyleXOptions,
40
40
  } from './common-types';
41
41
 
42
- declare export var create: typeof styleXCreateSet;
43
- declare export var createVars: typeof styleXCreateVars;
44
- declare export var overrideVars: typeof styleXOverrideVars;
45
- declare export var keyframes: typeof stylexKeyframes;
46
- declare export var include: typeof stylexInclude;
47
- declare export var utils: {
42
+ declare export const create: typeof styleXCreateSet;
43
+ declare export const createVars: typeof styleXCreateVars;
44
+ declare export const overrideVars: typeof styleXOverrideVars;
45
+ declare export const keyframes: typeof stylexKeyframes;
46
+ declare export const include: typeof stylexInclude;
47
+ declare export const utils: {
48
48
  hash: typeof hash,
49
49
  genFileBasedIdentifier: typeof genFileBasedIdentifier,
50
50
  };
51
- declare export var messages: typeof m;
52
- declare export var IncludedStyles: typeof _IncludedStyles;
53
- declare export var firstThatWorks: typeof stylexFirstThatWorks;
51
+ declare export const messages: typeof m;
52
+ declare export const IncludedStyles: typeof _IncludedStyles;
53
+ declare export const firstThatWorks: typeof stylexFirstThatWorks;
54
54
 
55
55
  export type InjectableStyle = _InjectableStyle;
56
56
  export type CompiledNamespaces = _CompiledNamespaces;
package/lib/messages.d.ts CHANGED
@@ -6,29 +6,29 @@
6
6
  *
7
7
  */
8
8
 
9
- export declare var ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
10
- export declare var NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
11
- export declare var ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
12
- export declare var UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
13
- export declare var ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
14
- export declare var NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
15
- export declare var UNKNOWN_PROP_KEY: 'Unknown property key';
16
- export declare var INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
17
- export declare var INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
18
- export declare var NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
19
- export declare var ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
20
- export declare var UNKNOWN_NAMESPACE: 'Unknown namespace';
21
- export declare var ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
22
- export declare var ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
23
- export declare var ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
24
- export declare var ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
25
- export declare var INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
26
- export declare var LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
27
- export declare var LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
28
- export declare var UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
29
- export declare var EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
30
- export declare var NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
31
- export declare var ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
32
- export declare var DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
33
- export declare var NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
34
- export declare var NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.createVars() must be bound to a named export.';
9
+ export declare const ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
10
+ export declare const NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
11
+ export declare const ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
12
+ export declare const UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
13
+ export declare const ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
14
+ export declare const NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
15
+ export declare const UNKNOWN_PROP_KEY: 'Unknown property key';
16
+ export declare const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
17
+ export declare const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
18
+ export declare const NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
19
+ export declare const ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
20
+ export declare const UNKNOWN_NAMESPACE: 'Unknown namespace';
21
+ export declare const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
22
+ export declare const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
23
+ export declare const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
24
+ export declare const ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
25
+ export declare const INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle` to verify their type.';
26
+ export declare const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
27
+ export declare const LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
28
+ export declare const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
29
+ export declare const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
30
+ export declare const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
31
+ export declare const ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
32
+ export declare const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
33
+ export declare const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
34
+ export declare const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.createVars() must be bound to a named export.';
package/lib/messages.js CHANGED
@@ -1,68 +1,58 @@
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
- */
1
+ "use strict";
8
2
 
9
- 'use strict';
10
-
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
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 = void 0;
17
- const ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
7
+ const ILLEGAL_ARGUMENT_LENGTH = "stylex() should have 1 argument.";
18
8
  exports.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
19
- const NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
9
+ const NON_STATIC_VALUE = "Only static values are allowed inside of a stylex.create() call.";
20
10
  exports.NON_STATIC_VALUE = NON_STATIC_VALUE;
21
- const ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
11
+ const ESCAPED_STYLEX_VALUE = "Escaping a stylex.create() value is not allowed.";
22
12
  exports.ESCAPED_STYLEX_VALUE = ESCAPED_STYLEX_VALUE;
23
- const UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
13
+ const UNBOUND_STYLEX_CALL_VALUE = "stylex.create calls must be bound to a bare variable.";
24
14
  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.';
15
+ const ONLY_TOP_LEVEL = "stylex.create() is only allowed at the root of a program.";
26
16
  exports.ONLY_TOP_LEVEL = ONLY_TOP_LEVEL;
27
- const NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
17
+ const NON_OBJECT_FOR_STYLEX_CALL = "stylex.create() can only accept a style object.";
28
18
  exports.NON_OBJECT_FOR_STYLEX_CALL = NON_OBJECT_FOR_STYLEX_CALL;
29
- const UNKNOWN_PROP_KEY = 'Unknown property key';
19
+ const UNKNOWN_PROP_KEY = "Unknown property key";
30
20
  exports.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
31
- const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
21
+ const INVALID_PSEUDO = "Invalid pseudo selector, not on the whitelist.";
32
22
  exports.INVALID_PSEUDO = INVALID_PSEUDO;
33
- const INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
23
+ const INVALID_PSEUDO_OR_AT_RULE = "Invalid pseudo or at-rule.";
34
24
  exports.INVALID_PSEUDO_OR_AT_RULE = INVALID_PSEUDO_OR_AT_RULE;
35
- const NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
25
+ const NO_CONDITIONAL_SHORTHAND = "You cannot use conditional style values for a shorthand property.";
36
26
  exports.NO_CONDITIONAL_SHORTHAND = NO_CONDITIONAL_SHORTHAND;
37
- const ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
27
+ const ILLEGAL_NAMESPACE_TYPE = "Only a string literal namespace is allowed here.";
38
28
  exports.ILLEGAL_NAMESPACE_TYPE = ILLEGAL_NAMESPACE_TYPE;
39
- const UNKNOWN_NAMESPACE = 'Unknown namespace';
29
+ const UNKNOWN_NAMESPACE = "Unknown namespace";
40
30
  exports.UNKNOWN_NAMESPACE = UNKNOWN_NAMESPACE;
41
31
  const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
42
32
  exports.ILLEGAL_NESTED_PSEUDO = ILLEGAL_NESTED_PSEUDO;
43
- const ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
33
+ const ILLEGAL_PROP_VALUE = "A style value can only contain an array, string or number.";
44
34
  exports.ILLEGAL_PROP_VALUE = ILLEGAL_PROP_VALUE;
45
- const ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
35
+ const ILLEGAL_PROP_ARRAY_VALUE = "A style array value can only contain strings or numbers.";
46
36
  exports.ILLEGAL_PROP_ARRAY_VALUE = ILLEGAL_PROP_ARRAY_VALUE;
47
- const ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
37
+ const ILLEGAL_NAMESPACE_VALUE = "A stylex namespace must be an object.";
48
38
  exports.ILLEGAL_NAMESPACE_VALUE = ILLEGAL_NAMESPACE_VALUE;
49
- const INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
39
+ const INVALID_SPREAD = "Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.";
50
40
  exports.INVALID_SPREAD = INVALID_SPREAD;
51
- const LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
41
+ const LINT_UNCLOSED_FUNCTION = "Rule contains an unclosed function";
52
42
  exports.LINT_UNCLOSED_FUNCTION = LINT_UNCLOSED_FUNCTION;
53
- const LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
43
+ const LOCAL_ONLY = "The return value of stylex.create() should not be exported.";
54
44
  exports.LOCAL_ONLY = LOCAL_ONLY;
55
- const UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
45
+ const UNEXPECTED_ARGUMENT = "Unexpected argument passed to the stylex() function.";
56
46
  exports.UNEXPECTED_ARGUMENT = UNEXPECTED_ARGUMENT;
57
- const EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
47
+ const EXPECTED_FUNCTION_CALL = "Expected a simple function call but found something else.";
58
48
  exports.EXPECTED_FUNCTION_CALL = EXPECTED_FUNCTION_CALL;
59
- const NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
49
+ const NO_PARENT_PATH = "Unexpected AST node without a parent path.";
60
50
  exports.NO_PARENT_PATH = NO_PARENT_PATH;
61
- const ONLY_TOP_LEVEL_INLCUDES = 'stylex.include() is only at the top level of a style definition object.';
51
+ const ONLY_TOP_LEVEL_INLCUDES = "stylex.include() is only at the top level of a style definition object.";
62
52
  exports.ONLY_TOP_LEVEL_INLCUDES = ONLY_TOP_LEVEL_INLCUDES;
63
- const DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
53
+ const DUPLICATE_CONDITIONAL = "The same pseudo selector or at-rule cannot be used more than once.";
64
54
  exports.DUPLICATE_CONDITIONAL = DUPLICATE_CONDITIONAL;
65
- const NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
55
+ const NO_PROJECT_ROOT_DIRECTORY = "The project root directory `rootDir` is not configured.";
66
56
  exports.NO_PROJECT_ROOT_DIRECTORY = NO_PROJECT_ROOT_DIRECTORY;
67
- const NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.createVars() must be bound to a named export.';
57
+ const NON_EXPORT_NAMED_DECLARATION = "The return value of stylex.createVars() must be bound to a named export.";
68
58
  exports.NON_EXPORT_NAMED_DECLARATION = NON_EXPORT_NAMED_DECLARATION;
@@ -9,29 +9,29 @@
9
9
  // This file contains constants to be used within Error messages.
10
10
  // The URLs within will eventually be replaced by links to the documenation website for Stylex.
11
11
 
12
- declare export var ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
13
- declare export var NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
14
- declare export var ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
15
- declare export var UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
16
- declare export var ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
17
- declare export var NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
18
- declare export var UNKNOWN_PROP_KEY: 'Unknown property key';
19
- declare export var INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
20
- declare export var INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
21
- declare export var NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
22
- declare export var ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
23
- declare export var UNKNOWN_NAMESPACE: 'Unknown namespace';
24
- declare export var ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
25
- declare export var ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
26
- declare export var ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
27
- declare export var ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
28
- declare export var INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
29
- declare export var LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
30
- declare export var LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
31
- declare export var UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
32
- declare export var EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
33
- declare export var NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
34
- declare export var ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
35
- declare export var DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
36
- declare export var NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
37
- declare export var NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.createVars() must be bound to a named export.';
12
+ declare export const ILLEGAL_ARGUMENT_LENGTH: 'stylex() should have 1 argument.';
13
+ declare export const NON_STATIC_VALUE: 'Only static values are allowed inside of a stylex.create() call.';
14
+ declare export const ESCAPED_STYLEX_VALUE: 'Escaping a stylex.create() value is not allowed.';
15
+ declare export const UNBOUND_STYLEX_CALL_VALUE: 'stylex.create calls must be bound to a bare variable.';
16
+ declare export const ONLY_TOP_LEVEL: 'stylex.create() is only allowed at the root of a program.';
17
+ declare export const NON_OBJECT_FOR_STYLEX_CALL: 'stylex.create() can only accept a style object.';
18
+ declare export const UNKNOWN_PROP_KEY: 'Unknown property key';
19
+ declare export const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
20
+ declare export const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
21
+ declare export const NO_CONDITIONAL_SHORTHAND: 'You cannot use conditional style values for a shorthand property.';
22
+ declare export const ILLEGAL_NAMESPACE_TYPE: 'Only a string literal namespace is allowed here.';
23
+ declare export const UNKNOWN_NAMESPACE: 'Unknown namespace';
24
+ declare export const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more than one level deep.";
25
+ declare export const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
26
+ declare export const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
27
+ declare export const ILLEGAL_NAMESPACE_VALUE: 'A stylex namespace must be an object.';
28
+ declare export const INVALID_SPREAD: 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
29
+ declare export const LINT_UNCLOSED_FUNCTION: 'Rule contains an unclosed function';
30
+ declare export const LOCAL_ONLY: 'The return value of stylex.create() should not be exported.';
31
+ declare export const UNEXPECTED_ARGUMENT: 'Unexpected argument passed to the stylex() function.';
32
+ declare export const EXPECTED_FUNCTION_CALL: 'Expected a simple function call but found something else.';
33
+ declare export const NO_PARENT_PATH: 'Unexpected AST node without a parent path.';
34
+ declare export const ONLY_TOP_LEVEL_INLCUDES: 'stylex.include() is only at the top level of a style definition object.';
35
+ declare export const DUPLICATE_CONDITIONAL: 'The same pseudo selector or at-rule cannot be used more than once.';
36
+ declare export const NO_PROJECT_ROOT_DIRECTORY: 'The project root directory `rootDir` is not configured.';
37
+ declare export const NON_EXPORT_NAMED_DECLARATION: 'The return value of stylex.createVars() must be bound to a named export.';