@stylexjs/shared 0.11.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/lib/index.d.ts +10 -36
  2. package/lib/index.js +8 -25
  3. package/lib/index.js.flow +10 -43
  4. package/lib/utils/property-priorities.d.ts +4 -0
  5. package/lib/utils/property-priorities.js +54 -8
  6. package/lib/utils/property-priorities.js.flow +8 -0
  7. package/package.json +9 -22
  8. package/README.md +0 -81
  9. package/lib/common-types.d.ts +0 -47
  10. package/lib/common-types.js +0 -1
  11. package/lib/common-types.js.flow +0 -60
  12. package/lib/convert-to-className.d.ts +0 -20
  13. package/lib/convert-to-className.js +0 -66
  14. package/lib/convert-to-className.js.flow +0 -27
  15. package/lib/generate-css-rule.d.ts +0 -17
  16. package/lib/generate-css-rule.js +0 -25
  17. package/lib/generate-css-rule.js.flow +0 -17
  18. package/lib/hash.d.ts +0 -11
  19. package/lib/hash.js +0 -37
  20. package/lib/hash.js.flow +0 -10
  21. package/lib/messages.d.ts +0 -41
  22. package/lib/messages.js +0 -38
  23. package/lib/messages.js.flow +0 -44
  24. package/lib/physical-rtl/generate-ltr.d.ts +0 -13
  25. package/lib/physical-rtl/generate-ltr.js +0 -103
  26. package/lib/physical-rtl/generate-ltr.js.flow +0 -12
  27. package/lib/physical-rtl/generate-rtl.d.ts +0 -13
  28. package/lib/physical-rtl/generate-rtl.js +0 -177
  29. package/lib/physical-rtl/generate-rtl.js.flow +0 -12
  30. package/lib/preprocess-rules/PreRule.d.ts +0 -50
  31. package/lib/preprocess-rules/PreRule.js +0 -76
  32. package/lib/preprocess-rules/PreRule.js.flow +0 -62
  33. package/lib/preprocess-rules/application-order.d.ts +0 -183
  34. package/lib/preprocess-rules/application-order.js +0 -186
  35. package/lib/preprocess-rules/application-order.js.flow +0 -134
  36. package/lib/preprocess-rules/basic-validation.d.ts +0 -13
  37. package/lib/preprocess-rules/basic-validation.js +0 -73
  38. package/lib/preprocess-rules/basic-validation.js.flow +0 -13
  39. package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +0 -20
  40. package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -98
  41. package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +0 -23
  42. package/lib/preprocess-rules/index.d.ts +0 -18
  43. package/lib/preprocess-rules/index.js +0 -33
  44. package/lib/preprocess-rules/index.js.flow +0 -22
  45. package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +0 -165
  46. package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -147
  47. package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +0 -144
  48. package/lib/preprocess-rules/property-specificity.d.ts +0 -78
  49. package/lib/preprocess-rules/property-specificity.js +0 -107
  50. package/lib/preprocess-rules/property-specificity.js.flow +0 -87
  51. package/lib/stylex-create-theme.d.ts +0 -26
  52. package/lib/stylex-create-theme.js +0 -58
  53. package/lib/stylex-create-theme.js.flow +0 -19
  54. package/lib/stylex-create.d.ts +0 -27
  55. package/lib/stylex-create.js +0 -57
  56. package/lib/stylex-create.js.flow +0 -38
  57. package/lib/stylex-define-vars.d.ts +0 -28
  58. package/lib/stylex-define-vars.js +0 -94
  59. package/lib/stylex-define-vars.js.flow +0 -27
  60. package/lib/stylex-first-that-works.d.ts +0 -13
  61. package/lib/stylex-first-that-works.js +0 -26
  62. package/lib/stylex-first-that-works.js.flow +0 -12
  63. package/lib/stylex-include.d.ts +0 -18
  64. package/lib/stylex-include.js +0 -28
  65. package/lib/stylex-include.js.flow +0 -20
  66. package/lib/stylex-keyframes.d.ts +0 -17
  67. package/lib/stylex-keyframes.js +0 -55
  68. package/lib/stylex-keyframes.js.flow +0 -20
  69. package/lib/stylex-vars-utils.d.ts +0 -27
  70. package/lib/stylex-vars-utils.js +0 -69
  71. package/lib/stylex-vars-utils.js.flow +0 -31
  72. package/lib/transform-value.d.ts +0 -22
  73. package/lib/transform-value.js +0 -50
  74. package/lib/transform-value.js.flow +0 -25
  75. package/lib/types/index.d.ts +0 -240
  76. package/lib/types/index.js +0 -147
  77. package/lib/types/index.js.flow +0 -280
  78. package/lib/utils/Rule.d.ts +0 -58
  79. package/lib/utils/Rule.js +0 -50
  80. package/lib/utils/Rule.js.flow +0 -64
  81. package/lib/utils/dashify.d.ts +0 -11
  82. package/lib/utils/dashify.js +0 -9
  83. package/lib/utils/dashify.js.flow +0 -10
  84. package/lib/utils/default-options.d.ts +0 -11
  85. package/lib/utils/default-options.js +0 -15
  86. package/lib/utils/default-options.js.flow +0 -12
  87. package/lib/utils/file-based-identifier.d.ts +0 -15
  88. package/lib/utils/file-based-identifier.js +0 -14
  89. package/lib/utils/file-based-identifier.js.flow +0 -14
  90. package/lib/utils/genCSSRule.d.ts +0 -15
  91. package/lib/utils/genCSSRule.js +0 -15
  92. package/lib/utils/genCSSRule.js.flow +0 -15
  93. package/lib/utils/normalize-value.d.ts +0 -16
  94. package/lib/utils/normalize-value.js +0 -28
  95. package/lib/utils/normalize-value.js.flow +0 -16
  96. package/lib/utils/normalizers/convert-camel-case-values.d.ts +0 -14
  97. package/lib/utils/normalizers/convert-camel-case-values.js +0 -23
  98. package/lib/utils/normalizers/convert-camel-case-values.js.flow +0 -13
  99. package/lib/utils/normalizers/detect-unclosed-fns.d.ts +0 -17
  100. package/lib/utils/normalizers/detect-unclosed-fns.js +0 -17
  101. package/lib/utils/normalizers/detect-unclosed-fns.js.flow +0 -16
  102. package/lib/utils/normalizers/font-size-px-to-rem.d.ts +0 -19
  103. package/lib/utils/normalizers/font-size-px-to-rem.js +0 -24
  104. package/lib/utils/normalizers/font-size-px-to-rem.js.flow +0 -18
  105. package/lib/utils/normalizers/leading-zero.d.ts +0 -17
  106. package/lib/utils/normalizers/leading-zero.js +0 -24
  107. package/lib/utils/normalizers/leading-zero.js.flow +0 -16
  108. package/lib/utils/normalizers/quotes.d.ts +0 -18
  109. package/lib/utils/normalizers/quotes.js +0 -17
  110. package/lib/utils/normalizers/quotes.js.flow +0 -17
  111. package/lib/utils/normalizers/timings.d.ts +0 -18
  112. package/lib/utils/normalizers/timings.js +0 -25
  113. package/lib/utils/normalizers/timings.js.flow +0 -17
  114. package/lib/utils/normalizers/whitespace.d.ts +0 -19
  115. package/lib/utils/normalizers/whitespace.js +0 -54
  116. package/lib/utils/normalizers/whitespace.js.flow +0 -18
  117. package/lib/utils/normalizers/zero-dimensions.d.ts +0 -19
  118. package/lib/utils/normalizers/zero-dimensions.js +0 -42
  119. package/lib/utils/normalizers/zero-dimensions.js.flow +0 -18
  120. package/lib/utils/object-utils.d.ts +0 -66
  121. package/lib/utils/object-utils.js +0 -99
  122. package/lib/utils/object-utils.js.flow +0 -78
  123. package/lib/utils/rule-utils.d.ts +0 -15
  124. package/lib/utils/rule-utils.js +0 -41
  125. package/lib/utils/rule-utils.js.flow +0 -16
  126. package/lib/utils/split-css-value.d.ts +0 -14
  127. package/lib/utils/split-css-value.js +0 -33
  128. package/lib/utils/split-css-value.js.flow +0 -15
  129. package/lib/validate.d.ts +0 -12
  130. package/lib/validate.js +0 -21
  131. package/lib/validate.js.flow +0 -12
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = normalizeQuotes;
7
- function normalizeQuotes(ast, _) {
8
- ast.walk(node => {
9
- if (node.type !== 'string') {
10
- return;
11
- }
12
- if (node.value === '') {
13
- node.quote = '"';
14
- }
15
- });
16
- return ast;
17
- }
@@ -1,17 +0,0 @@
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
- * Make empty strings use consistent double quotes
12
- */
13
-
14
- declare export default function normalizeQuotes(
15
- ast: PostCSSValueAST,
16
- _: mixed,
17
- ): PostCSSValueAST;
@@ -1,18 +0,0 @@
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
- * Turn millisecond values to seconds (shorter), except when < 10ms
12
- */
13
-
14
- declare function normalizeTimings(
15
- ast: PostCSSValueAST,
16
- _: unknown,
17
- ): PostCSSValueAST;
18
- export default normalizeTimings;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = normalizeTimings;
7
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- function normalizeTimings(ast, _) {
10
- ast.walk(node => {
11
- if (node.type !== 'word') {
12
- return;
13
- }
14
- const value = Number.parseFloat(node.value);
15
- if (Number.isNaN(value)) {
16
- return;
17
- }
18
- const dimension = _postcssValueParser.default.unit(node.value);
19
- if (!dimension || dimension.unit !== 'ms' || value < 10) {
20
- return;
21
- }
22
- node.value = value / 1000 + 's';
23
- });
24
- return ast;
25
- }
@@ -1,17 +0,0 @@
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
- * Turn millisecond values to seconds (shorter), except when < 10ms
12
- */
13
-
14
- declare export default function normalizeTimings(
15
- ast: PostCSSValueAST,
16
- _: mixed,
17
- ): PostCSSValueAST;
@@ -1,19 +0,0 @@
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
- * Use single spaces and remove spaces when not needed: around functions,
12
- * commas. But preserve space around + and - as they are required in calc()
13
- */
14
-
15
- declare function normalizeWhitespace(
16
- ast: PostCSSValueAST,
17
- _: unknown,
18
- ): PostCSSValueAST;
19
- export default normalizeWhitespace;
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = normalizeWhitespace;
7
- function normalizeWhitespace(ast, _) {
8
- if (ast.nodes[0].type === 'space') {
9
- ast.nodes.shift();
10
- }
11
- if (ast.nodes[ast.nodes.length - 1].type === 'space') {
12
- ast.nodes.pop();
13
- }
14
- ast.walk((node, idx) => {
15
- switch (node.type) {
16
- case 'space':
17
- {
18
- node.value = ' ';
19
- break;
20
- }
21
- case 'div':
22
- {
23
- if (node.value === ',') {
24
- node.before = '';
25
- node.after = '';
26
- } else {
27
- node.before = ' ';
28
- node.after = ' ';
29
- }
30
- break;
31
- }
32
- case 'function':
33
- {
34
- node.before = '';
35
- node.after = '';
36
- break;
37
- }
38
- case 'word':
39
- {
40
- if (node.value === '!important') {
41
- if (ast.nodes[idx - 1] && ast.nodes[idx - 1].type === 'space') {
42
- ast.nodes.splice(idx - 1, 1);
43
- }
44
- }
45
- break;
46
- }
47
- default:
48
- {
49
- break;
50
- }
51
- }
52
- });
53
- return ast;
54
- }
@@ -1,18 +0,0 @@
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
- * Use single spaces and remove spaces when not needed: around functions,
12
- * commas. But preserve space around + and - as they are required in calc()
13
- */
14
-
15
- declare export default function normalizeWhitespace(
16
- ast: PostCSSValueAST,
17
- _: mixed,
18
- ): PostCSSValueAST;
@@ -1,19 +0,0 @@
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, timings, fractions, and percentages,
12
- * in which case make them consistent 0deg, 0s, 0fr, and 0%.
13
- */
14
-
15
- declare function normalizeZeroDimensions(
16
- ast: PostCSSValueAST,
17
- _: unknown,
18
- ): PostCSSValueAST;
19
- export default normalizeZeroDimensions;
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = normalizeZeroDimensions;
7
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const angles = ['deg', 'grad', 'turn', 'rad'];
10
- const timings = ['ms', 's'];
11
- const fraction = 'fr';
12
- const percentage = '%';
13
- function normalizeZeroDimensions(ast, _) {
14
- let endFunction = 0;
15
- ast.walk(node => {
16
- if (node.type === 'function' && !endFunction) {
17
- endFunction = node.sourceEndIndex ?? 0;
18
- }
19
- if (endFunction > 0 && node.sourceIndex > endFunction) {
20
- endFunction = 0;
21
- }
22
- if (node.type !== 'word') {
23
- return;
24
- }
25
- const dimension = _postcssValueParser.default.unit(node.value);
26
- if (!dimension || dimension.number !== '0') {
27
- return;
28
- }
29
- if (angles.indexOf(dimension.unit) !== -1) {
30
- node.value = '0deg';
31
- } else if (timings.indexOf(dimension.unit) !== -1) {
32
- node.value = '0s';
33
- } else if (dimension.unit === fraction) {
34
- node.value = '0fr';
35
- } else if (dimension.unit === percentage) {
36
- node.value = '0%';
37
- } else if (!endFunction) {
38
- node.value = '0';
39
- }
40
- });
41
- return ast;
42
- }
@@ -1,18 +0,0 @@
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, timings, fractions, and percentages,
12
- * in which case make them consistent 0deg, 0s, 0fr, and 0%.
13
- */
14
-
15
- declare export default function normalizeZeroDimensions(
16
- ast: PostCSSValueAST,
17
- _: mixed,
18
- ): PostCSSValueAST;
@@ -1,66 +0,0 @@
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
- type AnyObject = { readonly [$$Key$$: string]: unknown };
12
- export declare function isPlainObject(obj: unknown): obj is AnyObject;
13
- export declare function flattenObject(obj: CompiledStyles): {
14
- readonly [$$Key$$: string]: null | string;
15
- };
16
- type _ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> = {
17
- [Key in keyof Obj]: [Key, Obj[Key]];
18
- };
19
- type ObjectEntries<Obj extends { readonly [$$Key$$: string]: unknown }> =
20
- _ObjectEntries<Obj>[keyof _ObjectEntries<Obj>];
21
- export declare function objEntries<
22
- Obj extends { readonly [$$Key$$: string]: unknown },
23
- >(obj: Obj): ReadonlyArray<ObjectEntries<Obj>>;
24
- export declare function objValues<
25
- Obj extends { readonly [$$Key$$: string]: unknown },
26
- >(obj: Obj): ReadonlyArray<Obj[keyof Obj]>;
27
- export declare function objFromEntries<K extends string | number, V>(
28
- entries: ReadonlyArray<Readonly<[K, V]>>,
29
- ): { [$$Key$$: K]: V };
30
- export declare function objMapKeys<
31
- V,
32
- K1 extends string = string,
33
- K2 extends string = string,
34
- >(
35
- obj: { readonly [$$Key$$: K1]: V },
36
- mapper: ($$PARAM_0$$: K1) => K2,
37
- ): { readonly [$$Key$$: K2]: V };
38
- export declare function objMapEntry<
39
- V,
40
- V2,
41
- K1 extends string = string,
42
- K2 extends string = string,
43
- >(
44
- obj: { readonly [$$Key$$: K1]: V },
45
- mapper: ($$PARAM_0$$: Readonly<[K1, V]>) => Readonly<[K2, V2]>,
46
- ): { readonly [$$Key$$: K2]: V2 };
47
- export declare function objMap<V, V2, K extends string = string>(
48
- obj: { readonly [$$Key$$: K]: V },
49
- mapper: ($$PARAM_0$$: V, $$PARAM_1$$: K) => V2,
50
- ): { readonly [$$Key$$: K]: V2 };
51
- export declare class Pipe<T> {
52
- value: T;
53
- constructor(val: T);
54
- pipe<T2>(mapper: ($$PARAM_0$$: T) => T2): Pipe<T2>;
55
- done(): T;
56
- static create(val: T): Pipe<T>;
57
- }
58
- export declare const arraySort: <T>(
59
- arr: ReadonlyArray<T>,
60
- fn?: ($$PARAM_0$$: T, $$PARAM_1$$: T) => number,
61
- ) => ReadonlyArray<T>;
62
- export declare const arrayEquals: <T>(
63
- arr1: ReadonlyArray<T>,
64
- arr2: ReadonlyArray<T>,
65
- equals: ($$PARAM_0$$: T, $$PARAM_1$$: T) => boolean,
66
- ) => boolean;
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.arraySort = exports.arrayEquals = exports.Pipe = void 0;
7
- exports.flattenObject = flattenObject;
8
- exports.isPlainObject = isPlainObject;
9
- exports.objEntries = objEntries;
10
- exports.objFromEntries = objFromEntries;
11
- exports.objMap = objMap;
12
- exports.objMapEntry = objMapEntry;
13
- exports.objMapKeys = objMapKeys;
14
- exports.objValues = objValues;
15
- function isPlainObject(obj) {
16
- return typeof obj === 'object' && obj != null && !Array.isArray(obj) && obj?.constructor === Object;
17
- }
18
- function flattenObject(obj) {
19
- const result = {};
20
- for (const [key, value] of objEntries(obj)) {
21
- if (typeof value === 'string' || value == null) {
22
- result[key] = value;
23
- } else {
24
- for (const [subKey, subValue] of objEntries(value)) {
25
- result[`${key}_${subKey}`] = subValue;
26
- }
27
- }
28
- }
29
- return result;
30
- }
31
- function objEntries(obj) {
32
- const retVal = [];
33
- for (const key of Object.keys(obj)) {
34
- retVal.push([key, obj[key]]);
35
- }
36
- return retVal;
37
- }
38
- function objValues(obj) {
39
- const retVal = [];
40
- for (const key of Object.keys(obj)) {
41
- retVal.push(obj[key]);
42
- }
43
- return retVal;
44
- }
45
- function objFromEntries(entries) {
46
- const retVal = {};
47
- for (const [key, value] of entries) {
48
- retVal[key] = value;
49
- }
50
- return retVal;
51
- }
52
- function objMapKeys(obj, mapper) {
53
- return objFromEntries(objEntries(obj).map(_ref => {
54
- let [key, value] = _ref;
55
- return [mapper(key), value];
56
- }));
57
- }
58
- function objMapEntry(obj, mapper) {
59
- return objFromEntries(objEntries(obj).map(_ref2 => {
60
- let [key, value] = _ref2;
61
- return mapper([key, value]);
62
- }));
63
- }
64
- function objMap(obj, mapper) {
65
- return objFromEntries(objEntries(obj).map(_ref3 => {
66
- let [key, value] = _ref3;
67
- return [key, mapper(value, key)];
68
- }));
69
- }
70
- class Pipe {
71
- constructor(val) {
72
- this.value = val;
73
- }
74
- pipe(mapper) {
75
- return new Pipe(mapper(this.value));
76
- }
77
- done() {
78
- return this.value;
79
- }
80
- static create(val) {
81
- return new Pipe(val);
82
- }
83
- }
84
- exports.Pipe = Pipe;
85
- const arraySort = (arr, fn) => [...arr].sort(fn);
86
- exports.arraySort = arraySort;
87
- const arrayEquals = function (arr1, arr2) {
88
- let equals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (a, b) => a === b;
89
- if (arr1.length !== arr2.length) {
90
- return false;
91
- }
92
- for (let i = 0; i < arr1.length; i++) {
93
- if (!equals(arr1[i], arr2[i])) {
94
- return false;
95
- }
96
- }
97
- return true;
98
- };
99
- exports.arrayEquals = arrayEquals;
@@ -1,78 +0,0 @@
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
- // eslint-disable-next-line no-unused-vars
15
- type AnyObject = { +[string]: mixed };
16
-
17
- declare export function isPlainObject(obj: mixed): implies obj is AnyObject;
18
-
19
- declare export function flattenObject(obj: CompiledStyles): {
20
- +[string]: null | string,
21
- };
22
-
23
- type _ObjectEntries<Obj: { +[string]: mixed }> = {
24
- [Key in keyof Obj]: [Key, Obj[Key]],
25
- };
26
- type ObjectEntries<Obj: { +[string]: mixed }> = $Values<_ObjectEntries<Obj>>;
27
-
28
- declare export function objEntries<Obj: { +[string]: mixed }>(
29
- obj: Obj,
30
- ): $ReadOnlyArray<ObjectEntries<Obj>>;
31
-
32
- declare export function objValues<Obj: { +[string]: mixed }>(
33
- obj: Obj,
34
- ): $ReadOnlyArray<Obj[$Keys<Obj>]>;
35
-
36
- declare export function objFromEntries<K: string | number, V>(
37
- entries: $ReadOnlyArray<$ReadOnly<[K, V]>>,
38
- ): { [K]: V };
39
-
40
- declare export function objMapKeys<V, K1: string = string, K2: string = string>(
41
- obj: { +[K1]: V },
42
- mapper: (K1) => K2,
43
- ): { +[K2]: V };
44
-
45
- declare export function objMapEntry<
46
- V,
47
- V2,
48
- K1: string = string,
49
- K2: string = string,
50
- >(
51
- obj: { +[K1]: V },
52
- mapper: ($ReadOnly<[K1, V]>) => $ReadOnly<[K2, V2]>,
53
- ): { +[K2]: V2 };
54
-
55
- declare export function objMap<V, V2, K: string = string>(
56
- obj: { +[K]: V },
57
- mapper: (V, K) => V2,
58
- ): { +[K]: V2 };
59
-
60
- declare export class Pipe<T> {
61
- value: T;
62
- constructor(val: T): void;
63
- pipe<T2>(mapper: (T) => T2): Pipe<T2>;
64
- done(): T;
65
- static create(val: T): Pipe<T>;
66
- }
67
-
68
- // Function that sorts an array without mutating it and returns a new array
69
- declare export const arraySort: <T>(
70
- arr: $ReadOnlyArray<T>,
71
- fn?: (T, T) => number,
72
- ) => $ReadOnlyArray<T>;
73
-
74
- declare export const arrayEquals: <T>(
75
- arr1: $ReadOnlyArray<T>,
76
- arr2: $ReadOnlyArray<T>,
77
- equals: (T, T) => boolean,
78
- ) => boolean;
@@ -1,15 +0,0 @@
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
- export declare const sortPseudos: (
11
- pseudos: ReadonlyArray<string>,
12
- ) => ReadonlyArray<string>;
13
- export declare const sortAtRules: (
14
- atRules: ReadonlyArray<string>,
15
- ) => ReadonlyArray<string>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sortPseudos = exports.sortAtRules = void 0;
7
- var _objectUtils = require("./object-utils");
8
- const sortPseudos = pseudos => {
9
- if (pseudos.length < 2) {
10
- return pseudos;
11
- }
12
- return pseudos.reduce((acc, pseudo) => {
13
- if (pseudo.startsWith('::')) {
14
- return [...acc, pseudo];
15
- }
16
- const lastElement = acc[acc.length - 1];
17
- const allButLast = acc.slice(0, acc.length - 1);
18
- if (Array.isArray(lastElement)) {
19
- return [...allButLast, [...lastElement, pseudo]];
20
- } else {
21
- return [...allButLast, lastElement, [pseudo]].filter(Boolean);
22
- }
23
- }, []).flatMap(pseudo => {
24
- if (Array.isArray(pseudo)) {
25
- return (0, _objectUtils.arraySort)(pseudo, stringComparator);
26
- }
27
- return [pseudo];
28
- });
29
- };
30
- exports.sortPseudos = sortPseudos;
31
- const sortAtRules = atRules => (0, _objectUtils.arraySort)(atRules);
32
- exports.sortAtRules = sortAtRules;
33
- const stringComparator = (a, b) => {
34
- if (a === 'default') {
35
- return -1;
36
- }
37
- if (b === 'default') {
38
- return 1;
39
- }
40
- return a.localeCompare(b);
41
- };
@@ -1,16 +0,0 @@
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 const sortPseudos: (
11
- pseudos: $ReadOnlyArray<string>,
12
- ) => $ReadOnlyArray<string>;
13
-
14
- declare export const sortAtRules: (
15
- atRules: $ReadOnlyArray<string>,
16
- ) => $ReadOnlyArray<string>;
@@ -1,14 +0,0 @@
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 { TStyleValue } from '../common-types';
11
- declare function splitValue(
12
- str: TStyleValue,
13
- ): ReadonlyArray<number | string | null>;
14
- export default splitValue;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = splitValue;
7
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- function printNode(node) {
10
- switch (node.type) {
11
- case 'word':
12
- case 'string':
13
- return `${node.value}`;
14
- case 'function':
15
- return `${node.value}(${node.nodes.map(printNode).join('')})`;
16
- default:
17
- return node.value;
18
- }
19
- }
20
- function splitValue(str) {
21
- if (str == null || typeof str === 'number') {
22
- return [str];
23
- }
24
- if (Array.isArray(str)) {
25
- return str;
26
- }
27
- const parsed = (0, _postcssValueParser.default)(str.trim());
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');
31
- }
32
- return nodes;
33
- }
@@ -1,15 +0,0 @@
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 { TStyleValue } from '../common-types';
11
-
12
- // Using split(' ') Isn't enough because of values like calc.
13
- declare export default function splitValue(
14
- str: TStyleValue,
15
- ): $ReadOnlyArray<number | string | null>;
package/lib/validate.d.ts DELETED
@@ -1,12 +0,0 @@
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;