@stylexjs/shared 0.2.0-beta.10 → 0.2.0-beta.12
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/common-types.d.ts +49 -0
- package/lib/common-types.js.flow +64 -0
- package/lib/convert-to-className.d.ts +16 -0
- package/lib/convert-to-className.js.flow +23 -0
- package/lib/generate-css-rule.d.ts +17 -0
- package/lib/generate-css-rule.js.flow +17 -0
- package/lib/hash.d.ts +11 -0
- package/lib/hash.js.flow +12 -0
- package/lib/index.d.ts +32 -95
- package/lib/index.js.flow +46 -3
- package/lib/messages.d.ts +32 -0
- package/lib/messages.js.flow +35 -0
- package/lib/physical-rtl/generate-ltr.d.ts +12 -0
- package/lib/physical-rtl/generate-ltr.js.flow +13 -0
- package/lib/physical-rtl/generate-rtl.d.ts +14 -0
- package/lib/physical-rtl/generate-rtl.js.flow +13 -0
- package/lib/preprocess-rules/PreRule.d.ts +52 -0
- package/lib/preprocess-rules/PreRule.js.flow +64 -0
- package/lib/preprocess-rules/application-order.d.ts +253 -0
- package/lib/preprocess-rules/application-order.js.flow +206 -0
- package/lib/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/preprocess-rules/basic-validation.js +3 -3
- package/lib/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js +5 -5
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
- package/lib/preprocess-rules/index.d.ts +18 -0
- package/lib/preprocess-rules/index.js.flow +19 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +122 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -139
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +101 -0
- package/lib/preprocess-rules/property-specificity.d.ts +76 -0
- package/lib/preprocess-rules/property-specificity.js.flow +87 -0
- package/lib/stylex-create-vars.d.ts +27 -0
- package/lib/stylex-create-vars.js +59 -0
- package/lib/stylex-create-vars.js.flow +22 -0
- package/lib/stylex-create.d.ts +23 -0
- package/lib/stylex-create.js.flow +30 -0
- package/lib/stylex-first-that-works.d.ts +14 -0
- package/lib/stylex-first-that-works.js.flow +13 -0
- package/lib/stylex-include.d.ts +19 -0
- package/lib/stylex-include.js.flow +21 -0
- package/lib/stylex-keyframes.d.ts +17 -0
- package/lib/stylex-keyframes.js.flow +20 -0
- package/lib/transform-value.d.ts +13 -0
- package/lib/transform-value.js.flow +15 -0
- package/lib/utils/Rule.d.ts +58 -0
- package/lib/utils/Rule.js.flow +64 -0
- package/lib/utils/dashify.d.ts +10 -0
- package/lib/utils/dashify.js.flow +9 -0
- package/lib/utils/default-options.d.ts +10 -0
- package/lib/utils/default-options.js.flow +24 -0
- package/lib/utils/file-based-identifier.d.ts +14 -0
- package/lib/utils/file-based-identifier.js +22 -0
- package/lib/utils/file-based-identifier.js.flow +13 -0
- package/lib/utils/genCSSRule.d.ts +16 -0
- package/lib/utils/genCSSRule.js.flow +16 -0
- package/lib/utils/normalize-value.d.ts +12 -0
- package/lib/utils/normalize-value.js.flow +14 -0
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/utils/normalizers/font-size-px-to-rem.js +9 -4
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/utils/normalizers/quotes.d.ts +19 -0
- package/lib/utils/normalizers/quotes.js.flow +18 -0
- package/lib/utils/normalizers/timings.d.ts +19 -0
- package/lib/utils/normalizers/timings.js.flow +18 -0
- package/lib/utils/normalizers/whitespace.d.ts +20 -0
- package/lib/utils/normalizers/whitespace.js.flow +19 -0
- package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/utils/object-utils.d.ts +61 -0
- package/lib/utils/object-utils.js.flow +81 -0
- package/lib/utils/property-priorities.d.ts +11 -0
- package/lib/utils/property-priorities.js.flow +10 -0
- package/lib/utils/split-css-value.d.ts +15 -0
- package/lib/utils/split-css-value.js.flow +16 -0
- package/lib/validate.d.ts +12 -0
- package/lib/validate.js.flow +12 -0
- package/package.json +4 -4
- package/lib/expand-shorthands.d.ts +0 -5
- package/lib/expand-shorthands.js +0 -330
- package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
- package/lib/namespace-transforms/preflatten.js +0 -89
- package/lib/preprocess-rules/expand-shorthands.js +0 -156
- package/lib/preprocess-rules/null-out-longhand.js +0 -310
- package/lib/preprocess-rules/react-native-web.js +0 -142
- package/lib/stylex-defaultValue.js +0 -397
@@ -0,0 +1,19 @@
|
|
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
|
+
|
11
|
+
/**
|
12
|
+
* Turn millisecond values to seconds (shorter), except when < 10ms
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare function normalizeTimings(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: unknown
|
18
|
+
): PostCSSValueAST;
|
19
|
+
export default normalizeTimings;
|
@@ -0,0 +1,18 @@
|
|
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
|
+
|
11
|
+
/**
|
12
|
+
* Turn millisecond values to seconds (shorter), except when < 10ms
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare export default function normalizeTimings(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: mixed
|
18
|
+
): PostCSSValueAST;
|
@@ -0,0 +1,20 @@
|
|
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
|
+
|
11
|
+
/**
|
12
|
+
* Use single spaces and remove spaces when not needed: around functions,
|
13
|
+
* commas. But preserve spece around + and - as they are required in calc()
|
14
|
+
*/
|
15
|
+
|
16
|
+
declare function normalizeWhitespace(
|
17
|
+
ast: PostCSSValueAST,
|
18
|
+
_: unknown
|
19
|
+
): PostCSSValueAST;
|
20
|
+
export default normalizeWhitespace;
|
@@ -0,0 +1,19 @@
|
|
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
|
+
|
11
|
+
/**
|
12
|
+
* Use single spaces and remove spaces when not needed: around functions,
|
13
|
+
* commas. But preserve spece around + and - as they are required in calc()
|
14
|
+
*/
|
15
|
+
|
16
|
+
declare export default function normalizeWhitespace(
|
17
|
+
ast: PostCSSValueAST,
|
18
|
+
_: mixed
|
19
|
+
): PostCSSValueAST;
|
@@ -0,0 +1,19 @@
|
|
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
|
+
/**
|
11
|
+
* Remove units in zero values, except when required: in angles and timings,
|
12
|
+
* in which case make them consistent 0deg and 0s.
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare function normalizeZeroDimensions(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: unknown
|
18
|
+
): PostCSSValueAST;
|
19
|
+
export default normalizeZeroDimensions;
|
@@ -0,0 +1,18 @@
|
|
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
|
+
/**
|
11
|
+
* Remove units in zero values, except when required: in angles and timings,
|
12
|
+
* in which case make them consistent 0deg and 0s.
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare export default function normalizeZeroDimensions(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: mixed
|
18
|
+
): PostCSSValueAST;
|
@@ -0,0 +1,61 @@
|
|
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 { CompiledStyles } from '../common-types';
|
11
|
+
import { IncludedStyles } from '../stylex-include';
|
12
|
+
export declare function isPlainObject(obj: unknown): boolean;
|
13
|
+
export declare function flattenObject(obj: CompiledStyles): {
|
14
|
+
readonly [$$Key$$: string]: null | string | IncludedStyles;
|
15
|
+
};
|
16
|
+
export declare function objEntries<Obj extends {}>(
|
17
|
+
obj: Obj
|
18
|
+
): ReadonlyArray<[keyof Obj, Obj[keyof Obj]]>;
|
19
|
+
export declare function objValues<Obj extends {}>(
|
20
|
+
obj: Obj
|
21
|
+
): ReadonlyArray<Obj[keyof Obj]>;
|
22
|
+
export declare function objFromEntries<K extends string | number, V>(
|
23
|
+
entries: ReadonlyArray<Readonly<[K, V]>>
|
24
|
+
): { [$$Key$$: K]: V };
|
25
|
+
export declare function objMapKeys<
|
26
|
+
V,
|
27
|
+
K1 extends string | number = string,
|
28
|
+
K2 extends string | number = string
|
29
|
+
>(
|
30
|
+
obj: { readonly [$$Key$$: K1]: V },
|
31
|
+
mapper: ($$PARAM_0$$: K1) => K2
|
32
|
+
): { readonly [$$Key$$: K2]: V };
|
33
|
+
export declare function objMapEntry<
|
34
|
+
V,
|
35
|
+
V2,
|
36
|
+
K1 extends string | number = string,
|
37
|
+
K2 extends string | number = string
|
38
|
+
>(
|
39
|
+
obj: { readonly [$$Key$$: K1]: V },
|
40
|
+
mapper: ($$PARAM_0$$: [K1, V]) => [K2, V2]
|
41
|
+
): { readonly [$$Key$$: K2]: V2 };
|
42
|
+
export declare function objMap<V, V2, K extends string | number = string>(
|
43
|
+
obj: { readonly [$$Key$$: K]: V },
|
44
|
+
mapper: ($$PARAM_0$$: V, $$PARAM_1$$: K) => V2
|
45
|
+
): { readonly [$$Key$$: K]: V2 };
|
46
|
+
export declare class Pipe<T> {
|
47
|
+
value: T;
|
48
|
+
constructor(val: T);
|
49
|
+
pipe<T2>(mapper: ($$PARAM_0$$: T) => T2): Pipe<T2>;
|
50
|
+
done(): T;
|
51
|
+
static create(val: T): Pipe<T>;
|
52
|
+
}
|
53
|
+
export declare var arraySort: <T>(
|
54
|
+
arr: ReadonlyArray<T>,
|
55
|
+
fn?: ($$PARAM_0$$: T, $$PARAM_1$$: T) => number
|
56
|
+
) => ReadonlyArray<T>;
|
57
|
+
export declare var arrayEquals: <T>(
|
58
|
+
arr1: ReadonlyArray<T>,
|
59
|
+
arr2: ReadonlyArray<T>,
|
60
|
+
equals: ($$PARAM_0$$: T, $$PARAM_1$$: T) => boolean
|
61
|
+
) => boolean;
|
@@ -0,0 +1,81 @@
|
|
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
|
+
// A bunch of object utils with better Flow types
|
11
|
+
|
12
|
+
import type { CompiledStyles } from '../common-types';
|
13
|
+
|
14
|
+
import { IncludedStyles } from '../stylex-include';
|
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);
|
22
|
+
|
23
|
+
declare export function flattenObject(obj: CompiledStyles): {
|
24
|
+
+[string]: null | string | IncludedStyles,
|
25
|
+
};
|
26
|
+
|
27
|
+
declare export function objEntries<Obj: { ... }>(
|
28
|
+
obj: Obj
|
29
|
+
): $ReadOnlyArray<[$Keys<Obj>, Obj[$Keys<Obj>]]>;
|
30
|
+
|
31
|
+
declare export function objValues<Obj: { ... }>(
|
32
|
+
obj: Obj
|
33
|
+
): $ReadOnlyArray<Obj[$Keys<Obj>]>;
|
34
|
+
|
35
|
+
declare export function objFromEntries<K: string | number, V>(
|
36
|
+
entries: $ReadOnlyArray<$ReadOnly<[K, V]>>
|
37
|
+
): { [K]: V };
|
38
|
+
|
39
|
+
declare export function objMapKeys<
|
40
|
+
V,
|
41
|
+
K1: string | number = string,
|
42
|
+
K2: string | number = string
|
43
|
+
>(
|
44
|
+
obj: { +[K1]: V },
|
45
|
+
mapper: (K1) => K2
|
46
|
+
): { +[K2]: V };
|
47
|
+
|
48
|
+
declare export function objMapEntry<
|
49
|
+
V,
|
50
|
+
V2,
|
51
|
+
K1: string | number = string,
|
52
|
+
K2: string | number = string
|
53
|
+
>(
|
54
|
+
obj: { +[K1]: V },
|
55
|
+
mapper: ([K1, V]) => [K2, V2]
|
56
|
+
): { +[K2]: V2 };
|
57
|
+
|
58
|
+
declare export function objMap<V, V2, K: string | number = string>(
|
59
|
+
obj: { +[K]: V },
|
60
|
+
mapper: (V, K) => V2
|
61
|
+
): { +[K]: V2 };
|
62
|
+
|
63
|
+
declare export class Pipe<T> {
|
64
|
+
value: T;
|
65
|
+
constructor(val: T): void;
|
66
|
+
pipe<T2>(mapper: (T) => T2): Pipe<T2>;
|
67
|
+
done(): T;
|
68
|
+
static create(val: T): Pipe<T>;
|
69
|
+
}
|
70
|
+
|
71
|
+
// Function that sorts an array without mutating it and returns a new array
|
72
|
+
declare export var arraySort: <T>(
|
73
|
+
arr: $ReadOnlyArray<T>,
|
74
|
+
fn?: (T, T) => number
|
75
|
+
) => $ReadOnlyArray<T>;
|
76
|
+
|
77
|
+
declare export var arrayEquals: <T>(
|
78
|
+
arr1: $ReadOnlyArray<T>,
|
79
|
+
arr2: $ReadOnlyArray<T>,
|
80
|
+
equals: (T, T) => boolean
|
81
|
+
) => boolean;
|
@@ -0,0 +1,11 @@
|
|
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 getPriority(key: string): number;
|
11
|
+
export default getPriority;
|
@@ -0,0 +1,10 @@
|
|
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 getPriority(key: string): number;
|
@@ -0,0 +1,15 @@
|
|
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
|
+
|
11
|
+
import type { TStyleValue } from '../common-types';
|
12
|
+
declare function splitValue(
|
13
|
+
str: TStyleValue
|
14
|
+
): ReadonlyArray<number | string | null>;
|
15
|
+
export default splitValue;
|
@@ -0,0 +1,16 @@
|
|
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
|
+
|
11
|
+
import type { TStyleValue } from '../common-types';
|
12
|
+
|
13
|
+
// Using split(' ') Isn't enough bcause of values like calc.
|
14
|
+
declare export default function splitValue(
|
15
|
+
str: TStyleValue
|
16
|
+
): $ReadOnlyArray<number | string | null>;
|
@@ -0,0 +1,12 @@
|
|
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 { TRawValue } from './common-types';
|
11
|
+
declare function validateEntry($$PARAM_0$$: [string, TRawValue]): void;
|
12
|
+
export default validateEntry;
|
@@ -0,0 +1,12 @@
|
|
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 { TRawValue } from './common-types';
|
11
|
+
|
12
|
+
declare export default function validateEntry([string, TRawValue]): void;
|
package/package.json
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.2.0-beta.
|
4
|
-
"description": "Shared Code for Stylex compile and runtime.",
|
3
|
+
"version": "0.2.0-beta.12",
|
5
4
|
"main": "lib/index.js",
|
6
|
-
"repository": "https://www.github.com/
|
7
|
-
"author": "Naman Goel <nmn@fb.com>",
|
5
|
+
"repository": "https://www.github.com/facebook/stylex",
|
8
6
|
"license": "MIT",
|
9
7
|
"scripts": {
|
8
|
+
"prebuild": "gen-types -i src/ -o lib/",
|
10
9
|
"build": "babel src/ --out-dir lib/ --copy-files",
|
11
10
|
"test": "jest"
|
12
11
|
},
|
@@ -14,6 +13,7 @@
|
|
14
13
|
"postcss-value-parser": "^4.1.0"
|
15
14
|
},
|
16
15
|
"devDependencies": {
|
16
|
+
"@stylexjs/scripts": "0.2.0-beta.12",
|
17
17
|
"typescript": "^4.7.4"
|
18
18
|
},
|
19
19
|
"jest": {
|