@stylexjs/shared 0.2.0-beta.15 → 0.2.0-beta.17
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/convert-to-className.d.ts +1 -1
- package/lib/convert-to-className.js +6 -22
- package/lib/convert-to-className.js.flow +1 -1
- package/lib/generate-css-rule.d.ts +1 -1
- package/lib/generate-css-rule.js +3 -14
- package/lib/generate-css-rule.js.flow +1 -1
- package/lib/hash.d.ts +2 -2
- package/lib/hash.js +9 -33
- package/lib/hash.js.flow +1 -3
- package/lib/index.d.ts +9 -9
- package/lib/index.js +0 -14
- package/lib/index.js.flow +9 -9
- package/lib/messages.d.ts +26 -26
- package/lib/messages.js +26 -36
- package/lib/messages.js.flow +26 -26
- package/lib/physical-rtl/generate-ltr.js +39 -67
- package/lib/physical-rtl/generate-ltr.js.flow +1 -1
- package/lib/physical-rtl/generate-rtl.d.ts +1 -2
- package/lib/physical-rtl/generate-rtl.js +57 -89
- package/lib/physical-rtl/generate-rtl.js.flow +1 -2
- package/lib/preprocess-rules/PreRule.d.ts +3 -3
- package/lib/preprocess-rules/PreRule.js +3 -17
- package/lib/preprocess-rules/PreRule.js.flow +3 -3
- package/lib/preprocess-rules/application-order.d.ts +8 -5
- package/lib/preprocess-rules/application-order.js +121 -160
- package/lib/preprocess-rules/application-order.js.flow +6 -5
- package/lib/preprocess-rules/basic-validation.d.ts +1 -1
- package/lib/preprocess-rules/basic-validation.js +6 -15
- package/lib/preprocess-rules/basic-validation.js.flow +1 -1
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +2 -2
- package/lib/preprocess-rules/flatten-raw-style-obj.js +14 -43
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +2 -2
- package/lib/preprocess-rules/index.d.ts +2 -2
- package/lib/preprocess-rules/index.js +6 -15
- package/lib/preprocess-rules/index.js.flow +2 -2
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -2
- package/lib/preprocess-rules/legacy-expand-shorthands.js +14 -33
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +2 -2
- package/lib/preprocess-rules/property-specificity.d.ts +8 -5
- package/lib/preprocess-rules/property-specificity.js +54 -76
- package/lib/preprocess-rules/property-specificity.js.flow +6 -5
- package/lib/stylex-create-vars.d.ts +17 -8
- package/lib/stylex-create-vars.js +30 -17
- package/lib/stylex-create-vars.js.flow +10 -4
- package/lib/stylex-create.d.ts +2 -2
- package/lib/stylex-create.js +1 -20
- package/lib/stylex-create.js.flow +1 -1
- package/lib/stylex-first-that-works.js +0 -10
- package/lib/stylex-include.js +0 -10
- package/lib/stylex-keyframes.d.ts +1 -1
- package/lib/stylex-keyframes.js +7 -27
- package/lib/stylex-keyframes.js.flow +1 -1
- package/lib/stylex-override-vars.d.ts +11 -4
- package/lib/stylex-override-vars.js +32 -18
- package/lib/stylex-override-vars.js.flow +3 -3
- package/lib/transform-value.js +11 -29
- package/lib/transform-value.js.flow +1 -1
- package/lib/utils/Rule.d.ts +2 -2
- package/lib/utils/Rule.js +0 -21
- package/lib/utils/Rule.js.flow +2 -2
- package/lib/utils/dashify.js +1 -9
- package/lib/utils/default-options.d.ts +1 -1
- package/lib/utils/default-options.js +2 -23
- package/lib/utils/default-options.js.flow +1 -1
- package/lib/utils/file-based-identifier.js +1 -9
- package/lib/utils/genCSSRule.d.ts +1 -1
- package/lib/utils/genCSSRule.js +6 -16
- package/lib/utils/genCSSRule.js.flow +1 -1
- package/lib/utils/normalize-value.js +1 -13
- package/lib/utils/normalize-value.js.flow +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.js +2 -14
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.js +4 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +1 -1
- package/lib/utils/normalizers/leading-zero.d.ts +1 -1
- package/lib/utils/normalizers/leading-zero.js +3 -15
- package/lib/utils/normalizers/leading-zero.js.flow +1 -1
- package/lib/utils/normalizers/quotes.d.ts +1 -1
- package/lib/utils/normalizers/quotes.js +4 -17
- package/lib/utils/normalizers/quotes.js.flow +1 -1
- package/lib/utils/normalizers/timings.d.ts +1 -1
- package/lib/utils/normalizers/timings.js +4 -18
- package/lib/utils/normalizers/timings.js.flow +1 -1
- package/lib/utils/normalizers/whitespace.d.ts +1 -1
- package/lib/utils/normalizers/whitespace.js +12 -27
- package/lib/utils/normalizers/whitespace.js.flow +1 -1
- package/lib/utils/normalizers/zero-dimensions.d.ts +1 -1
- package/lib/utils/normalizers/zero-dimensions.js +8 -23
- package/lib/utils/normalizers/zero-dimensions.js.flow +1 -1
- package/lib/utils/object-utils.d.ts +28 -20
- package/lib/utils/object-utils.js +2 -15
- package/lib/utils/object-utils.js.flow +23 -27
- package/lib/utils/property-priorities.js +68 -83
- package/lib/utils/split-css-value.d.ts +1 -1
- package/lib/utils/split-css-value.js +8 -22
- package/lib/utils/split-css-value.js.flow +1 -1
- package/lib/validate.js +2 -11
- package/package.json +2 -3
@@ -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 =
|
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 ||
|
43
|
-
const stringToHash = Array.isArray(value) ? dashedKey + value.join(
|
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];
|
package/lib/generate-css-rule.js
CHANGED
@@ -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(
|
27
|
-
const rtlDecls = pairs.map(_generateRtl.default).filter(Boolean).map(pair => pair.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);
|
package/lib/hash.d.ts
CHANGED
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) &
|
39
|
-
k = (k &
|
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 &
|
42
|
-
h = (h &
|
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) &
|
24
|
+
h ^= (str.charCodeAt(i + 2) & 255) << 16;
|
49
25
|
case 2:
|
50
|
-
h ^= (str.charCodeAt(i + 1) &
|
26
|
+
h ^= (str.charCodeAt(i + 1) & 255) << 8;
|
51
27
|
case 1:
|
52
|
-
h ^= str.charCodeAt(i) &
|
53
|
-
h = (h &
|
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 &
|
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
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
|
35
|
-
export declare
|
36
|
-
export declare
|
37
|
-
export declare
|
38
|
-
export declare
|
39
|
-
export declare
|
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
|
44
|
-
export declare
|
45
|
-
export declare
|
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
|
43
|
-
declare export
|
44
|
-
declare export
|
45
|
-
declare export
|
46
|
-
declare export
|
47
|
-
declare export
|
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
|
52
|
-
declare export
|
53
|
-
declare export
|
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
|
10
|
-
export declare
|
11
|
-
export declare
|
12
|
-
export declare
|
13
|
-
export declare
|
14
|
-
export declare
|
15
|
-
export declare
|
16
|
-
export declare
|
17
|
-
export declare
|
18
|
-
export declare
|
19
|
-
export declare
|
20
|
-
export declare
|
21
|
-
export declare
|
22
|
-
export declare
|
23
|
-
export declare
|
24
|
-
export declare
|
25
|
-
export declare
|
26
|
-
export declare
|
27
|
-
export declare
|
28
|
-
export declare
|
29
|
-
export declare
|
30
|
-
export declare
|
31
|
-
export declare
|
32
|
-
export declare
|
33
|
-
export declare
|
34
|
-
export declare
|
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 =
|
7
|
+
const ILLEGAL_ARGUMENT_LENGTH = "stylex() should have 1 argument.";
|
18
8
|
exports.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
|
19
|
-
const NON_STATIC_VALUE =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
19
|
+
const UNKNOWN_PROP_KEY = "Unknown property key";
|
30
20
|
exports.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
|
31
|
-
const INVALID_PSEUDO =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
41
|
+
const LINT_UNCLOSED_FUNCTION = "Rule contains an unclosed function";
|
52
42
|
exports.LINT_UNCLOSED_FUNCTION = LINT_UNCLOSED_FUNCTION;
|
53
|
-
const LOCAL_ONLY =
|
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 =
|
45
|
+
const UNEXPECTED_ARGUMENT = "Unexpected argument passed to the stylex() function.";
|
56
46
|
exports.UNEXPECTED_ARGUMENT = UNEXPECTED_ARGUMENT;
|
57
|
-
const EXPECTED_FUNCTION_CALL =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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;
|
package/lib/messages.js.flow
CHANGED
@@ -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
|
13
|
-
declare export
|
14
|
-
declare export
|
15
|
-
declare export
|
16
|
-
declare export
|
17
|
-
declare export
|
18
|
-
declare export
|
19
|
-
declare export
|
20
|
-
declare export
|
21
|
-
declare export
|
22
|
-
declare export
|
23
|
-
declare export
|
24
|
-
declare export
|
25
|
-
declare export
|
26
|
-
declare export
|
27
|
-
declare export
|
28
|
-
declare export
|
29
|
-
declare export
|
30
|
-
declare export
|
31
|
-
declare export
|
32
|
-
declare export
|
33
|
-
declare export
|
34
|
-
declare export
|
35
|
-
declare export
|
36
|
-
declare export
|
37
|
-
declare 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.';
|