@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,30 @@
|
|
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 {
|
11
|
+
RawStyles,
|
12
|
+
InjectableStyle,
|
13
|
+
StyleXOptions,
|
14
|
+
FlatCompiledStyles,
|
15
|
+
} from './common-types';
|
16
|
+
|
17
|
+
// This takes the object of styles passed to `stylex.create` and transforms it.
|
18
|
+
// The transformation replaces style values with classNames.
|
19
|
+
//
|
20
|
+
// It also collects all injected styles along the way.
|
21
|
+
// It then returns a tuple of the transformed style Object and an object of injected styles.
|
22
|
+
//
|
23
|
+
// This function does some basic validation, and then uses `styleXCreateNamespace` to transform
|
24
|
+
// each namespace within,
|
25
|
+
//
|
26
|
+
// Before returning, it ensures that there are no duplicate styles being injected.
|
27
|
+
declare export default function styleXCreateSet(
|
28
|
+
namespaces: { +[string]: RawStyles },
|
29
|
+
options?: StyleXOptions
|
30
|
+
): [{ [string]: FlatCompiledStyles }, { [string]: InjectableStyle }];
|
@@ -0,0 +1,14 @@
|
|
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
|
+
declare function stylexFirstThatWorks<T>(
|
12
|
+
...args: ReadonlyArray<T>
|
13
|
+
): ReadonlyArray<T>;
|
14
|
+
export default stylexFirstThatWorks;
|
@@ -0,0 +1,13 @@
|
|
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
|
+
declare export default function stylexFirstThatWorks<T>(
|
12
|
+
...args: $ReadOnlyArray<T>
|
13
|
+
): $ReadOnlyArray<T>;
|
@@ -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
|
+
export declare class IncludedStyles {
|
12
|
+
astNode: any;
|
13
|
+
constructor(astNode: any);
|
14
|
+
}
|
15
|
+
declare function stylexInclude(
|
16
|
+
firstArg: any,
|
17
|
+
...styles: any
|
18
|
+
): { [key: string]: IncludedStyles };
|
19
|
+
export default stylexInclude;
|
@@ -0,0 +1,21 @@
|
|
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
|
+
declare export class IncludedStyles {
|
12
|
+
astNode: any;
|
13
|
+
constructor(astNode: any): void;
|
14
|
+
}
|
15
|
+
|
16
|
+
declare export default function stylexInclude(
|
17
|
+
firstArg: any,
|
18
|
+
...styles: any
|
19
|
+
): {
|
20
|
+
[key: string]: IncludedStyles,
|
21
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
|
+
declare function styleXKeyframes(
|
12
|
+
frames: {
|
13
|
+
readonly [$$Key$$: string]: { readonly [$$Key$$: string]: string | number };
|
14
|
+
},
|
15
|
+
options: StyleXOptions
|
16
|
+
): [string, InjectableStyle];
|
17
|
+
export default styleXKeyframes;
|
@@ -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
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
|
+
|
12
|
+
// Similar to `stylex.create` it takes an object of keyframes
|
13
|
+
// and returns a string after hashing it.
|
14
|
+
//
|
15
|
+
// It also expands shorthand properties to maintain parity with
|
16
|
+
// `stylex.create`.
|
17
|
+
declare export default function styleXKeyframes(
|
18
|
+
frames: { +[string]: { +[string]: string | number } },
|
19
|
+
options: StyleXOptions
|
20
|
+
): [string, InjectableStyle];
|
@@ -0,0 +1,13 @@
|
|
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
|
+
* Convert a CSS value in JS to the final CSS string value
|
11
|
+
*/
|
12
|
+
declare function transformValue(key: string, rawValue: string | number): string;
|
13
|
+
export default transformValue;
|
@@ -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
|
+
* @flow strict
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Convert a CSS value in JS to the final CSS string value
|
11
|
+
*/
|
12
|
+
declare export default function transformValue(
|
13
|
+
key: string,
|
14
|
+
rawValue: string | number
|
15
|
+
): string;
|
@@ -0,0 +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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This could be an interface, but we use a class so that we can
|
12
|
+
* use instanceof to check for it.
|
13
|
+
*/
|
14
|
+
export declare class Rule<V> {}
|
15
|
+
/**
|
16
|
+
* This is a class that represents a raw style rule.
|
17
|
+
*
|
18
|
+
* It exists to track the actual CSS rule that should be compiled
|
19
|
+
* even as we transform the structure of the RawStyles object.
|
20
|
+
*/
|
21
|
+
export declare class RawRule<V> extends Rule<V> {
|
22
|
+
readonly key: string;
|
23
|
+
readonly value: V;
|
24
|
+
readonly psuedos: null | undefined | ReadonlyArray<string>;
|
25
|
+
readonly atRules: null | undefined | ReadonlyArray<string>;
|
26
|
+
constructor(
|
27
|
+
key: string,
|
28
|
+
value: V,
|
29
|
+
psuedos: null | undefined | ReadonlyArray<string>,
|
30
|
+
atRules: null | undefined | ReadonlyArray<string>
|
31
|
+
);
|
32
|
+
}
|
33
|
+
export declare class RawRuleList<V> extends Rule<V> {
|
34
|
+
readonly rules: ReadonlyArray<Rule<V>>;
|
35
|
+
constructor(rules: ReadonlyArray<Rule<V>>);
|
36
|
+
}
|
37
|
+
export declare class RawRuleRTLTuple<V1, V2> extends Rule<V1 | V2> {
|
38
|
+
readonly rules: [RawRule<V1>, RawRule<V2>];
|
39
|
+
constructor(rule1: RawRule<V1>, rule2: RawRule<V2>);
|
40
|
+
}
|
41
|
+
export declare class CompiledRule<V> extends Rule<V> {
|
42
|
+
readonly key: string;
|
43
|
+
readonly value: V;
|
44
|
+
readonly psuedos: null | undefined | ReadonlyArray<string>;
|
45
|
+
readonly atRules: null | undefined | ReadonlyArray<string>;
|
46
|
+
readonly className: string;
|
47
|
+
constructor(
|
48
|
+
key: string,
|
49
|
+
value: V,
|
50
|
+
psuedos: null | undefined | ReadonlyArray<string>,
|
51
|
+
atRules: null | undefined | ReadonlyArray<string>,
|
52
|
+
className: string
|
53
|
+
);
|
54
|
+
}
|
55
|
+
export declare class CompiledRuleTuple2<V1, V2> extends Rule<V1 | V2> {
|
56
|
+
readonly rules: [CompiledRule<V1>, CompiledRule<V2>];
|
57
|
+
constructor(rule1: CompiledRule<V1>, rule2: CompiledRule<V2>);
|
58
|
+
}
|
@@ -0,0 +1,64 @@
|
|
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
|
+
* This could be an interface, but we use a class so that we can
|
12
|
+
* use instanceof to check for it.
|
13
|
+
*/
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
15
|
+
declare export class Rule<+V> {}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* This is a class that represents a raw style rule.
|
19
|
+
*
|
20
|
+
* It exists to track the actual CSS rule that should be compiled
|
21
|
+
* even as we transform the structure of the RawStyles object.
|
22
|
+
*/
|
23
|
+
declare export class RawRule<V> extends Rule<V> {
|
24
|
+
+key: string;
|
25
|
+
+value: V;
|
26
|
+
+psuedos: ?$ReadOnlyArray<string>;
|
27
|
+
+atRules: ?$ReadOnlyArray<string>;
|
28
|
+
constructor(
|
29
|
+
key: string,
|
30
|
+
value: V,
|
31
|
+
psuedos: ?$ReadOnlyArray<string>,
|
32
|
+
atRules: ?$ReadOnlyArray<string>
|
33
|
+
): void;
|
34
|
+
}
|
35
|
+
|
36
|
+
declare export class RawRuleList<V> extends Rule<V> {
|
37
|
+
+rules: $ReadOnlyArray<Rule<V>>;
|
38
|
+
constructor(rules: $ReadOnlyArray<Rule<V>>): void;
|
39
|
+
}
|
40
|
+
|
41
|
+
declare export class RawRuleRTLTuple<V1, V2> extends Rule<V1 | V2> {
|
42
|
+
+rules: [RawRule<V1>, RawRule<V2>];
|
43
|
+
constructor(rule1: RawRule<V1>, rule2: RawRule<V2>): void;
|
44
|
+
}
|
45
|
+
|
46
|
+
declare export class CompiledRule<V> extends Rule<V> {
|
47
|
+
+key: string;
|
48
|
+
+value: V;
|
49
|
+
+psuedos: ?$ReadOnlyArray<string>;
|
50
|
+
+atRules: ?$ReadOnlyArray<string>;
|
51
|
+
+className: string;
|
52
|
+
constructor(
|
53
|
+
key: string,
|
54
|
+
value: V,
|
55
|
+
psuedos: ?$ReadOnlyArray<string>,
|
56
|
+
atRules: ?$ReadOnlyArray<string>,
|
57
|
+
className: string
|
58
|
+
): void;
|
59
|
+
}
|
60
|
+
|
61
|
+
declare export class CompiledRuleTuple2<V1, V2> extends Rule<V1 | V2> {
|
62
|
+
+rules: [CompiledRule<V1>, CompiledRule<V2>];
|
63
|
+
constructor(rule1: CompiledRule<V1>, rule2: CompiledRule<V2>): void;
|
64
|
+
}
|
@@ -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
|
+
*/
|
8
|
+
|
9
|
+
declare function dashify(str: string): string;
|
10
|
+
export default dashify;
|
@@ -0,0 +1,9 @@
|
|
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
|
+
* @flow strict
|
7
|
+
*/
|
8
|
+
|
9
|
+
declare export default function dashify(str: string): string;
|
@@ -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
|
+
*/
|
8
|
+
|
9
|
+
import type { StyleXOptions } from '../common-types';
|
10
|
+
export declare var defaultOptions: StyleXOptions;
|
@@ -0,0 +1,24 @@
|
|
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
|
+
* @flow strict
|
7
|
+
*/
|
8
|
+
|
9
|
+
import type { StyleXOptions } from '../common-types';
|
10
|
+
|
11
|
+
// {
|
12
|
+
// ...options,
|
13
|
+
// dev: !!(options as any).dev,
|
14
|
+
// test: !!(options as any).test,
|
15
|
+
// stylexSheetName: (options as any).stylexSheetName ?? undefined,
|
16
|
+
// classNamePrefix: (options as any).classNamePrefix ?? 'x',
|
17
|
+
// importSources: (options as any).importSources ?? [name, 'stylex'],
|
18
|
+
// definedStylexCSSVariables:
|
19
|
+
// (options as any).definedStylexCSSVariables ?? {},
|
20
|
+
// genConditionalClasses: !!(options as any).genConditionalClasses,
|
21
|
+
// skipShorthandExpansion: !!(options as any).skipShorthandExpansion,
|
22
|
+
// } as StyleXOptions;
|
23
|
+
|
24
|
+
declare export var defaultOptions: StyleXOptions;
|
@@ -0,0 +1,14 @@
|
|
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
|
+
declare function genFileBasedIdentifier($$PARAM_0$$: {
|
10
|
+
readonly fileName: string;
|
11
|
+
readonly exportName: string;
|
12
|
+
readonly key?: string;
|
13
|
+
}): string;
|
14
|
+
export default genFileBasedIdentifier;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = genFileBasedIdentifier;
|
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
|
+
function genFileBasedIdentifier(_ref) {
|
16
|
+
let {
|
17
|
+
fileName,
|
18
|
+
exportName,
|
19
|
+
key
|
20
|
+
} = _ref;
|
21
|
+
return `${fileName}//${exportName}${key != null ? `.${key}` : ''}`;
|
22
|
+
}
|
@@ -0,0 +1,13 @@
|
|
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
|
+
* @flow strict
|
7
|
+
*/
|
8
|
+
|
9
|
+
declare export default function genFileBasedIdentifier({
|
10
|
+
+fileName: string,
|
11
|
+
+exportName: string,
|
12
|
+
+key?: string,
|
13
|
+
}): string;
|
@@ -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
|
+
*
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
export declare function genCSSRule(
|
12
|
+
className: string,
|
13
|
+
decls: string,
|
14
|
+
pseudos: ReadonlyArray<string>,
|
15
|
+
atRules: ReadonlyArray<string>
|
16
|
+
): string;
|
@@ -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
|
+
declare export function genCSSRule(
|
12
|
+
className: string,
|
13
|
+
decls: string,
|
14
|
+
pseudos: $ReadOnlyArray<string>,
|
15
|
+
atRules: $ReadOnlyArray<string>
|
16
|
+
): string;
|
@@ -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
|
+
|
11
|
+
declare function normalizeValue(value: string, key: string): string;
|
12
|
+
export default normalizeValue;
|
@@ -0,0 +1,14 @@
|
|
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
|
+
declare export default function normalizeValue(
|
12
|
+
value: string,
|
13
|
+
key: string
|
14
|
+
): string;
|
@@ -0,0 +1,17 @@
|
|
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 leading zeros from numbers
|
12
|
+
*/
|
13
|
+
declare function detectUnclosedFns(
|
14
|
+
ast: PostCSSValueAST,
|
15
|
+
_: unknown
|
16
|
+
): PostCSSValueAST;
|
17
|
+
export default detectUnclosedFns;
|
@@ -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
|
+
* Remove leading zeros from numbers
|
12
|
+
*/
|
13
|
+
declare export default function detectUnclosedFns(
|
14
|
+
ast: PostCSSValueAST,
|
15
|
+
_: mixed
|
16
|
+
): 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
|
+
* Convert font sizes from absolute unit `px` to relative unit `rem`.
|
12
|
+
* This will allow developers to continue thinking and using what's familiar
|
13
|
+
* while we output font sizes that are adjustable
|
14
|
+
*/
|
15
|
+
declare function convertFontSizeToRem(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
key: string
|
18
|
+
): PostCSSValueAST;
|
19
|
+
export default convertFontSizeToRem;
|
@@ -9,7 +9,12 @@
|
|
9
9
|
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
|
12
|
+
Object.defineProperty(exports, "__esModule", {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
exports.default = convertFontSizeToRem;
|
16
|
+
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
18
|
const ROOT_FONT_SIZE = 16;
|
14
19
|
|
15
20
|
/**
|
@@ -17,7 +22,7 @@ const ROOT_FONT_SIZE = 16;
|
|
17
22
|
* This will allow developers to continue thinking and using what's familiar
|
18
23
|
* while we output font sizes that are adjustable
|
19
24
|
*/
|
20
|
-
|
25
|
+
function convertFontSizeToRem(ast, key) {
|
21
26
|
if (key !== 'fontSize') {
|
22
27
|
return ast;
|
23
28
|
}
|
@@ -25,10 +30,10 @@ module.exports = function convertFontSizeToRem(ast, key) {
|
|
25
30
|
if (node.type !== 'word') {
|
26
31
|
return;
|
27
32
|
}
|
28
|
-
const dimension =
|
33
|
+
const dimension = _postcssValueParser.default.unit(node.value);
|
29
34
|
if (dimension && dimension.unit === 'px') {
|
30
35
|
node.value = `${parseFloat(dimension.number) / ROOT_FONT_SIZE}rem`;
|
31
36
|
}
|
32
37
|
});
|
33
38
|
return ast;
|
34
|
-
}
|
39
|
+
}
|
@@ -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
|
+
* Convert font sizes from absolute unit `px` to relative unit `rem`.
|
12
|
+
* This will allow developers to continue thinking and using what's familiar
|
13
|
+
* while we output font sizes that are adjustable
|
14
|
+
*/
|
15
|
+
declare export default function convertFontSizeToRem(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
key: string
|
18
|
+
): PostCSSValueAST;
|
@@ -0,0 +1,17 @@
|
|
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 leading zeros from numbers
|
12
|
+
*/
|
13
|
+
declare function normalizeLeadingZero(
|
14
|
+
ast: PostCSSValueAST,
|
15
|
+
_: unknown
|
16
|
+
): PostCSSValueAST;
|
17
|
+
export default normalizeLeadingZero;
|
@@ -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
|
+
* Remove leading zeros from numbers
|
12
|
+
*/
|
13
|
+
declare export default function normalizeLeadingZero(
|
14
|
+
ast: PostCSSValueAST,
|
15
|
+
_: mixed
|
16
|
+
): 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
|
+
/**
|
12
|
+
* Make empty strings use consistent double quotes
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare function normalizeQuotes(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: unknown
|
18
|
+
): PostCSSValueAST;
|
19
|
+
export default normalizeQuotes;
|
@@ -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
|
+
* Make empty strings use consistent double quotes
|
13
|
+
*/
|
14
|
+
|
15
|
+
declare export default function normalizeQuotes(
|
16
|
+
ast: PostCSSValueAST,
|
17
|
+
_: mixed
|
18
|
+
): PostCSSValueAST;
|