@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.
- 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
@@ -13,51 +13,47 @@ import type { CompiledStyles } from '../common-types';
|
|
13
13
|
|
14
14
|
import { IncludedStyles } from '../stylex-include';
|
15
15
|
|
16
|
-
declare export function isPlainObject(
|
17
|
-
obj: mixed
|
18
|
-
): boolean %checks(typeof obj === 'object' &&
|
19
|
-
obj != null &&
|
20
|
-
!Array.isArray(obj) &&
|
21
|
-
obj?.constructor === Object);
|
16
|
+
declare export function isPlainObject(obj: mixed): void;
|
22
17
|
|
23
18
|
declare export function flattenObject(obj: CompiledStyles): {
|
24
19
|
+[string]: null | string | IncludedStyles,
|
25
20
|
};
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
type _ObjectEntries<Obj: { +[string]: mixed }> = {
|
23
|
+
[Key in keyof Obj]: [Key, Obj[Key]],
|
24
|
+
};
|
25
|
+
type ObjectEntries<Obj: { +[string]: mixed }> = $Values<_ObjectEntries<Obj>>;
|
26
|
+
|
27
|
+
declare export function objEntries<Obj: { +[string]: mixed }>(
|
28
|
+
obj: Obj,
|
29
|
+
): $ReadOnlyArray<ObjectEntries<Obj>>;
|
30
30
|
|
31
|
-
declare export function objValues<Obj: {
|
32
|
-
obj: Obj
|
31
|
+
declare export function objValues<Obj: { +[string]: mixed }>(
|
32
|
+
obj: Obj,
|
33
33
|
): $ReadOnlyArray<Obj[$Keys<Obj>]>;
|
34
34
|
|
35
35
|
declare export function objFromEntries<K: string | number, V>(
|
36
|
-
entries: $ReadOnlyArray<$ReadOnly<[K, V]
|
36
|
+
entries: $ReadOnlyArray<$ReadOnly<[K, V]>>,
|
37
37
|
): { [K]: V };
|
38
38
|
|
39
|
-
declare export function objMapKeys<
|
40
|
-
V,
|
41
|
-
K1: string | number = string,
|
42
|
-
K2: string | number = string
|
43
|
-
>(
|
39
|
+
declare export function objMapKeys<V, K1: string = string, K2: string = string>(
|
44
40
|
obj: { +[K1]: V },
|
45
|
-
mapper: (K1) => K2
|
41
|
+
mapper: (K1) => K2,
|
46
42
|
): { +[K2]: V };
|
47
43
|
|
48
44
|
declare export function objMapEntry<
|
49
45
|
V,
|
50
46
|
V2,
|
51
|
-
K1: string
|
52
|
-
K2: string
|
47
|
+
K1: string = string,
|
48
|
+
K2: string = string,
|
53
49
|
>(
|
54
50
|
obj: { +[K1]: V },
|
55
|
-
mapper: ([K1, V]) => [K2, V2]
|
51
|
+
mapper: ([K1, V]) => [K2, V2],
|
56
52
|
): { +[K2]: V2 };
|
57
53
|
|
58
|
-
declare export function objMap<V, V2, K: string
|
54
|
+
declare export function objMap<V, V2, K: string = string>(
|
59
55
|
obj: { +[K]: V },
|
60
|
-
mapper: (V, K) => V2
|
56
|
+
mapper: (V, K) => V2,
|
61
57
|
): { +[K]: V2 };
|
62
58
|
|
63
59
|
declare export class Pipe<T> {
|
@@ -69,13 +65,13 @@ declare export class Pipe<T> {
|
|
69
65
|
}
|
70
66
|
|
71
67
|
// Function that sorts an array without mutating it and returns a new array
|
72
|
-
declare export
|
68
|
+
declare export const arraySort: <T>(
|
73
69
|
arr: $ReadOnlyArray<T>,
|
74
|
-
fn?: (T, T) => number
|
70
|
+
fn?: (T, T) => number,
|
75
71
|
) => $ReadOnlyArray<T>;
|
76
72
|
|
77
|
-
declare export
|
73
|
+
declare export const arrayEquals: <T>(
|
78
74
|
arr1: $ReadOnlyArray<T>,
|
79
75
|
arr2: $ReadOnlyArray<T>,
|
80
|
-
equals: (T, T) => boolean
|
76
|
+
equals: (T, T) => boolean,
|
81
77
|
) => boolean;
|
@@ -4,112 +4,97 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = getPriority;
|
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
7
|
const PRIORITIES = {
|
17
|
-
// These should never exist at runtime:
|
18
8
|
border: 1,
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
// End of never-exist-at-runtime properties.
|
28
|
-
|
29
|
-
// These are shorthands of shorthands:
|
9
|
+
"border-block-end": 2,
|
10
|
+
"border-block-start": 2,
|
11
|
+
"border-top": 2.1,
|
12
|
+
"border-bottom": 2.1,
|
13
|
+
"border-inline-end": 2,
|
14
|
+
"border-inline-start": 2,
|
15
|
+
"border-left": 2,
|
16
|
+
"border-right": 2,
|
30
17
|
grid: 2,
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
'border-radius': 3,
|
18
|
+
"grid-area": 2,
|
19
|
+
"border-color": 3,
|
20
|
+
"border-style": 3,
|
21
|
+
"border-width": 3,
|
22
|
+
"border-image": 3,
|
23
|
+
"border-radius": 3,
|
38
24
|
animation: 3,
|
39
25
|
background: 3,
|
40
|
-
|
26
|
+
"column-rule": 3,
|
41
27
|
columns: 3,
|
42
28
|
flex: 3,
|
43
|
-
|
29
|
+
"flex-flow": 3,
|
44
30
|
font: 3,
|
45
31
|
gap: 3,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
"grid-column": 3,
|
33
|
+
"grid-row": 3,
|
34
|
+
"grid-template": 3,
|
35
|
+
"list-style": 3,
|
50
36
|
margin: 3,
|
51
37
|
mask: 3,
|
52
38
|
offset: 3,
|
53
39
|
outline: 3,
|
54
40
|
overflow: 3,
|
55
41
|
padding: 3,
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
42
|
+
"place-content": 3,
|
43
|
+
"place-items": 3,
|
44
|
+
"place-self": 3,
|
45
|
+
"scroll-margin": 3,
|
46
|
+
"scroll-padding": 3,
|
47
|
+
"text-decoration": 3,
|
48
|
+
"text-emphasis": 3,
|
63
49
|
transition: 3,
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
50
|
+
":has": 4.5,
|
51
|
+
":dir": 5,
|
52
|
+
":lang": 5.1,
|
53
|
+
":first-child": 5.2,
|
54
|
+
":last-child": 5.3,
|
55
|
+
":only-child": 5.4,
|
56
|
+
":nth-child": 6,
|
57
|
+
":nth-of-type": 6.1,
|
58
|
+
":only-of-type": 6.2,
|
59
|
+
":empty": 7,
|
60
|
+
":link": 8,
|
61
|
+
":any-link": 8.1,
|
62
|
+
":target": 8.2,
|
63
|
+
":visited": 8.3,
|
64
|
+
":enabled": 9.1,
|
65
|
+
":disabled": 9.2,
|
66
|
+
":required": 9.3,
|
67
|
+
":optional": 9.4,
|
68
|
+
":read-only": 9.5,
|
69
|
+
":read-write": 9.6,
|
70
|
+
":placeholder-shown": 9.7,
|
71
|
+
":default": 10,
|
72
|
+
":checked": 10.1,
|
73
|
+
":indeterminate": 10.1,
|
74
|
+
":blank": 10.2,
|
75
|
+
":valid": 10.3,
|
76
|
+
":invalid": 10.4,
|
77
|
+
":autofill": 11,
|
78
|
+
":picture-in-picture": 12,
|
79
|
+
":fullscreen": 12.1,
|
80
|
+
":paused": 12.2,
|
81
|
+
":playing": 12.3,
|
82
|
+
":hover": 13,
|
83
|
+
":focusWithin": 14,
|
84
|
+
":focusVisible": 15,
|
85
|
+
":focus": 16,
|
86
|
+
":active": 17
|
101
87
|
};
|
102
88
|
function getPriority(key) {
|
103
|
-
if (key.startsWith(
|
89
|
+
if (key.startsWith("@supports")) {
|
104
90
|
return 20;
|
105
91
|
}
|
106
|
-
if (key.startsWith(
|
92
|
+
if (key.startsWith("@media")) {
|
107
93
|
return 21;
|
108
94
|
}
|
109
|
-
const prop = key.startsWith(
|
95
|
+
const prop = key.startsWith(":") && key.includes("(") ? key.slice(0, key.indexOf("(")) : key;
|
110
96
|
let priority = PRIORITIES[prop] ?? 4;
|
111
|
-
if (key.toLowerCase().includes(
|
112
|
-
// Bump priority for physical left/right values.
|
97
|
+
if (key.toLowerCase().includes("left") || key.toLowerCase().includes("right")) {
|
113
98
|
priority += 0.1;
|
114
99
|
}
|
115
100
|
return priority;
|
@@ -6,42 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = splitValue;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
-
/**
|
10
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
11
|
-
*
|
12
|
-
* This source code is licensed under the MIT license found in the
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
9
|
function printNode(node) {
|
20
10
|
switch (node.type) {
|
21
|
-
case
|
22
|
-
case
|
11
|
+
case "word":
|
12
|
+
case "string":
|
23
13
|
return `${node.value}`;
|
24
|
-
case
|
25
|
-
return `${node.value}(${node.nodes.map(printNode).join(
|
14
|
+
case "function":
|
15
|
+
return `${node.value}(${node.nodes.map(printNode).join("")})`;
|
26
16
|
default:
|
27
17
|
return node.value;
|
28
18
|
}
|
29
19
|
}
|
30
|
-
|
31
|
-
// Using split(' ') Isn't enough bcause of values like calc.
|
32
20
|
function splitValue(str) {
|
33
|
-
if (str == null || typeof str ===
|
21
|
+
if (str == null || typeof str === "number") {
|
34
22
|
return [str];
|
35
23
|
}
|
36
|
-
|
37
|
-
// This will never happen, but keeping here for Flow.
|
38
24
|
if (Array.isArray(str)) {
|
39
25
|
return str;
|
40
26
|
}
|
41
27
|
const parsed = (0, _postcssValueParser.default)(str.trim());
|
42
|
-
const nodes = parsed.nodes.filter(node => node.type !==
|
43
|
-
if (nodes.length > 1 && nodes[nodes.length - 1].toLowerCase() ===
|
44
|
-
return nodes.slice(0, nodes.length - 1).map(node => node +
|
28
|
+
const nodes = parsed.nodes.filter(node => node.type !== "space" && node.type !== "div").map(printNode);
|
29
|
+
if (nodes.length > 1 && nodes[nodes.length - 1].toLowerCase() === "!important") {
|
30
|
+
return nodes.slice(0, nodes.length - 1).map(node => node + " !important");
|
45
31
|
}
|
46
32
|
return nodes;
|
47
33
|
}
|
package/lib/validate.js
CHANGED
@@ -4,15 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = validateEntry;
|
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
7
|
function validateEntry(_ref) {
|
17
8
|
let [key, value] = _ref;
|
18
9
|
if (Array.isArray(value)) {
|
@@ -24,7 +15,7 @@ function validateEntry(_ref) {
|
|
24
15
|
function validateSimplyEntry(_ref2) {
|
25
16
|
let [key, _value] = _ref2;
|
26
17
|
if (BANNED_KEYS.has(key)) {
|
27
|
-
throw new Error(
|
18
|
+
throw new Error("Banned key: " + key);
|
28
19
|
}
|
29
20
|
}
|
30
|
-
const BANNED_KEYS = new Set([
|
21
|
+
const BANNED_KEYS = new Set(["background", "transition", "grid"]);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.2.0-beta.
|
3
|
+
"version": "0.2.0-beta.17",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"repository": "https://www.github.com/facebook/stylex",
|
6
6
|
"license": "MIT",
|
@@ -13,8 +13,7 @@
|
|
13
13
|
"postcss-value-parser": "^4.1.0"
|
14
14
|
},
|
15
15
|
"devDependencies": {
|
16
|
-
"@stylexjs/scripts": "0.2.0-beta.
|
17
|
-
"typescript": "^4.7.4"
|
16
|
+
"@stylexjs/scripts": "0.2.0-beta.17"
|
18
17
|
},
|
19
18
|
"jest": {
|
20
19
|
"snapshotFormat": {
|