@stylexjs/babel-plugin 0.12.0 → 0.13.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 (120) hide show
  1. package/lib/index.js +3758 -2215
  2. package/lib/index.js.flow +11 -1
  3. package/lib/shared/common-types.d.ts +57 -0
  4. package/lib/shared/common-types.js.flow +71 -0
  5. package/lib/shared/hash.d.ts +12 -0
  6. package/lib/shared/hash.js.flow +12 -0
  7. package/lib/shared/index.d.ts +57 -0
  8. package/lib/shared/index.js.flow +66 -0
  9. package/lib/shared/messages.d.ts +35 -0
  10. package/lib/shared/messages.js.flow +40 -0
  11. package/lib/shared/physical-rtl/generate-ltr.d.ts +13 -0
  12. package/lib/shared/physical-rtl/generate-ltr.js.flow +12 -0
  13. package/lib/shared/physical-rtl/generate-rtl.d.ts +13 -0
  14. package/lib/shared/physical-rtl/generate-rtl.js.flow +12 -0
  15. package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
  16. package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
  17. package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
  18. package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
  19. package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
  20. package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
  21. package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
  22. package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
  23. package/lib/shared/preprocess-rules/index.d.ts +18 -0
  24. package/lib/shared/preprocess-rules/index.js.flow +22 -0
  25. package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +165 -0
  26. package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +144 -0
  27. package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
  28. package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
  29. package/lib/shared/stylex-consts-utils.d.ts +11 -0
  30. package/lib/shared/stylex-consts-utils.js.flow +14 -0
  31. package/lib/shared/stylex-create-theme.d.ts +26 -0
  32. package/lib/shared/stylex-create-theme.js.flow +19 -0
  33. package/lib/shared/stylex-create.d.ts +27 -0
  34. package/lib/shared/stylex-create.js.flow +37 -0
  35. package/lib/shared/stylex-define-consts.d.ts +23 -0
  36. package/lib/shared/stylex-define-consts.js.flow +19 -0
  37. package/lib/shared/stylex-define-vars.d.ts +28 -0
  38. package/lib/shared/stylex-define-vars.js.flow +26 -0
  39. package/lib/shared/stylex-first-that-works.d.ts +13 -0
  40. package/lib/shared/stylex-first-that-works.js.flow +12 -0
  41. package/lib/shared/stylex-keyframes.d.ts +17 -0
  42. package/lib/shared/stylex-keyframes.js.flow +20 -0
  43. package/lib/shared/stylex-position-try.d.ts +15 -0
  44. package/lib/shared/stylex-position-try.js.flow +18 -0
  45. package/lib/shared/stylex-vars-utils.d.ts +27 -0
  46. package/lib/shared/stylex-vars-utils.js.flow +31 -0
  47. package/lib/shared/types/index.d.ts +240 -0
  48. package/lib/shared/types/index.js.flow +280 -0
  49. package/lib/shared/utils/Rule.d.ts +58 -0
  50. package/lib/shared/utils/Rule.js.flow +64 -0
  51. package/lib/shared/utils/convert-to-className.d.ts +21 -0
  52. package/lib/shared/utils/convert-to-className.js.flow +29 -0
  53. package/lib/shared/utils/dashify.d.ts +11 -0
  54. package/lib/shared/utils/dashify.js.flow +10 -0
  55. package/lib/shared/utils/default-options.d.ts +11 -0
  56. package/lib/shared/utils/default-options.js.flow +12 -0
  57. package/lib/shared/utils/file-based-identifier.d.ts +15 -0
  58. package/lib/shared/utils/file-based-identifier.js.flow +14 -0
  59. package/lib/shared/utils/generate-css-rule.d.ts +18 -0
  60. package/lib/shared/utils/generate-css-rule.js.flow +19 -0
  61. package/lib/shared/utils/normalize-value.d.ts +16 -0
  62. package/lib/shared/utils/normalize-value.js.flow +16 -0
  63. package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
  64. package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
  65. package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
  66. package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
  67. package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
  68. package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
  69. package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
  70. package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
  71. package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
  72. package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
  73. package/lib/shared/utils/normalizers/timings.d.ts +18 -0
  74. package/lib/shared/utils/normalizers/timings.js.flow +17 -0
  75. package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
  76. package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
  77. package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
  78. package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
  79. package/lib/shared/utils/object-utils.d.ts +66 -0
  80. package/lib/shared/utils/object-utils.js.flow +78 -0
  81. package/lib/shared/utils/property-priorities.d.ts +17 -0
  82. package/lib/shared/utils/property-priorities.js.flow +78 -0
  83. package/lib/shared/utils/rule-utils.d.ts +15 -0
  84. package/lib/shared/utils/rule-utils.js.flow +16 -0
  85. package/lib/shared/utils/split-css-value.d.ts +14 -0
  86. package/lib/shared/utils/split-css-value.js.flow +15 -0
  87. package/lib/shared/utils/transform-value.d.ts +22 -0
  88. package/lib/shared/utils/transform-value.js.flow +25 -0
  89. package/lib/shared/validate.d.ts +12 -0
  90. package/lib/shared/validate.js.flow +12 -0
  91. package/lib/utils/add-sourcemap-data.d.ts +1 -1
  92. package/lib/utils/add-sourcemap-data.js.flow +1 -1
  93. package/lib/utils/dev-classname.d.ts +1 -1
  94. package/lib/utils/dev-classname.js.flow +2 -1
  95. package/lib/utils/evaluate-path.d.ts +14 -0
  96. package/lib/utils/evaluate-path.js.flow +15 -0
  97. package/lib/utils/js-to-ast.d.ts +1 -1
  98. package/lib/utils/js-to-ast.js.flow +1 -1
  99. package/lib/utils/state-manager.d.ts +34 -6
  100. package/lib/utils/state-manager.js.flow +34 -5
  101. package/lib/visitors/imports.d.ts +1 -1
  102. package/lib/visitors/imports.js.flow +2 -1
  103. package/lib/visitors/{stylex-create/parse-stylex-create-arg.d.ts → parse-stylex-create-arg.d.ts} +2 -2
  104. package/lib/visitors/{stylex-create/parse-stylex-create-arg.js.flow → parse-stylex-create-arg.js.flow} +5 -4
  105. package/lib/visitors/stylex-create-theme.d.ts +1 -1
  106. package/lib/visitors/stylex-create-theme.js.flow +1 -1
  107. package/lib/visitors/{stylex-create/index.d.ts → stylex-create.d.ts} +2 -2
  108. package/lib/visitors/{stylex-create/index.js.flow → stylex-create.js.flow} +3 -3
  109. package/lib/visitors/stylex-define-consts.d.ts +1 -14
  110. package/lib/visitors/stylex-define-consts.js.flow +9 -14
  111. package/lib/visitors/stylex-define-vars.d.ts +1 -1
  112. package/lib/visitors/stylex-define-vars.js.flow +1 -1
  113. package/lib/visitors/stylex-keyframes.d.ts +1 -1
  114. package/lib/visitors/stylex-keyframes.js.flow +1 -1
  115. package/lib/visitors/{stylex-attrs.d.ts → stylex-position-try.d.ts} +3 -7
  116. package/lib/visitors/stylex-position-try.js.flow +22 -0
  117. package/package.json +7 -11
  118. package/lib/babel-path-utils.d.ts +0 -1100
  119. package/lib/babel-path-utils.js.flow +0 -1108
  120. package/lib/visitors/stylex-attrs.js.flow +0 -25
@@ -0,0 +1,27 @@
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 { CSSType } from './types';
11
+ export type VarsConfigValue =
12
+ | string
13
+ | Readonly<{ default: VarsConfigValue; [$$Key$$: string]: VarsConfigValue }>;
14
+ export type VarsConfig = Readonly<{
15
+ [$$Key$$: string]: VarsConfigValue | CSSType;
16
+ }>;
17
+ export declare function collectVarsByAtRule(
18
+ key: string,
19
+ $$PARAM_1$$: { readonly nameHash: string; readonly value: VarsConfigValue },
20
+ collection: { [$$Key$$: string]: Array<string> },
21
+ atRules: Array<string>,
22
+ ): void;
23
+ export declare function wrapWithAtRules(ltr: string, atRule: string): string;
24
+ export declare function priorityForAtRule(atRule: string): number;
25
+ export declare function getDefaultValue(
26
+ value: VarsConfigValue,
27
+ ): null | undefined | string;
@@ -0,0 +1,31 @@
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 { CSSType } from './types';
11
+
12
+ export type VarsConfigValue =
13
+ | string
14
+ | $ReadOnly<{ default: VarsConfigValue, [string]: VarsConfigValue }>;
15
+
16
+ export type VarsConfig = $ReadOnly<{
17
+ [string]: VarsConfigValue | CSSType<>,
18
+ }>;
19
+
20
+ declare export function collectVarsByAtRule(
21
+ key: string,
22
+ { +nameHash: string, +value: VarsConfigValue },
23
+ collection: { [string]: Array<string> },
24
+ atRules: Array<string>,
25
+ ): void;
26
+
27
+ declare export function wrapWithAtRules(ltr: string, atRule: string): string;
28
+
29
+ declare export function priorityForAtRule(atRule: string): number;
30
+
31
+ declare export function getDefaultValue(value: VarsConfigValue): ?string;
@@ -0,0 +1,240 @@
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
+ type NestedWithNumbers =
11
+ | number
12
+ | string
13
+ | Readonly<{
14
+ default: NestedWithNumbers;
15
+ [$$Key$$: string]: NestedWithNumbers;
16
+ }>;
17
+ type ValueWithDefault =
18
+ | string
19
+ | Readonly<{
20
+ default: ValueWithDefault;
21
+ [$$Key$$: string]: ValueWithDefault;
22
+ }>;
23
+ type CSSSyntax =
24
+ | '*'
25
+ | '<length>'
26
+ | '<number>'
27
+ | '<percentage>'
28
+ | '<length-percentage>'
29
+ | '<color>'
30
+ | '<image>'
31
+ | '<url>'
32
+ | '<integer>'
33
+ | '<angle>'
34
+ | '<time>'
35
+ | '<resolution>'
36
+ | '<transform-function>'
37
+ | '<custom-ident>'
38
+ | '<transform-list>';
39
+ type CSSSyntaxType = CSSSyntax;
40
+ declare class BaseCSSType {
41
+ readonly value: ValueWithDefault;
42
+ readonly syntax: CSSSyntaxType;
43
+ constructor(value: ValueWithDefault);
44
+ }
45
+ export interface CSSType<_T extends string | number = string | number> {
46
+ readonly value: ValueWithDefault;
47
+ readonly syntax: CSSSyntaxType;
48
+ }
49
+ export declare const isCSSType: (
50
+ value: unknown,
51
+ ) => value is CSSType<string | number>;
52
+ type AngleValue = string;
53
+ export declare class Angle<T extends AngleValue>
54
+ extends BaseCSSType
55
+ implements CSSType<T>
56
+ {
57
+ readonly value: ValueWithDefault;
58
+ readonly syntax: CSSSyntaxType;
59
+ static readonly syntax: CSSSyntaxType;
60
+ static create<T extends AngleValue = AngleValue>(
61
+ value: ValueWithDefault,
62
+ ): Angle<T>;
63
+ }
64
+ export declare const angle: <T extends AngleValue = AngleValue>(
65
+ value: ValueWithDefault,
66
+ ) => Angle<T>;
67
+ type ColorValue = string;
68
+ export declare class Color<T extends ColorValue>
69
+ extends BaseCSSType
70
+ implements CSSType<T>
71
+ {
72
+ readonly value: ValueWithDefault;
73
+ readonly syntax: CSSSyntaxType;
74
+ static create<T extends ColorValue = ColorValue>(
75
+ value: ValueWithDefault,
76
+ ): Color<T>;
77
+ }
78
+ export declare const color: <T extends ColorValue = ColorValue>(
79
+ value: ValueWithDefault,
80
+ ) => Color<T>;
81
+ type URLValue = string;
82
+ export declare class Url<T extends URLValue>
83
+ extends BaseCSSType
84
+ implements CSSType<T>
85
+ {
86
+ readonly value: ValueWithDefault;
87
+ readonly syntax: CSSSyntaxType;
88
+ static create<T extends URLValue = URLValue>(value: ValueWithDefault): Url<T>;
89
+ }
90
+ export declare const url: <T extends URLValue = URLValue>(
91
+ value: ValueWithDefault,
92
+ ) => Url<T>;
93
+ type ImageValue = string;
94
+ export declare class Image<T extends ImageValue>
95
+ extends Url<T>
96
+ implements CSSType<T>
97
+ {
98
+ readonly value: ValueWithDefault;
99
+ readonly syntax: CSSSyntaxType;
100
+ constructor(value: ValueWithDefault);
101
+ static create<T extends ImageValue = ImageValue>(
102
+ value: ValueWithDefault,
103
+ ): Image<T>;
104
+ }
105
+ export declare const image: <T extends ImageValue = ImageValue>(
106
+ value: ValueWithDefault,
107
+ ) => Image<T>;
108
+ type IntegerValue = number;
109
+ export declare class Integer<T extends IntegerValue>
110
+ extends BaseCSSType
111
+ implements CSSType<T>
112
+ {
113
+ readonly value: ValueWithDefault;
114
+ readonly syntax: CSSSyntaxType;
115
+ static create<T extends IntegerValue = IntegerValue>(value: T): Integer<T>;
116
+ }
117
+ export declare const integer: <T extends IntegerValue = IntegerValue>(
118
+ value: T,
119
+ ) => Integer<T>;
120
+ type LengthPercentageValue = string;
121
+ export declare class LengthPercentage<_T extends LengthPercentageValue>
122
+ extends BaseCSSType
123
+ implements CSSType<string>
124
+ {
125
+ readonly value: ValueWithDefault;
126
+ readonly syntax: CSSSyntaxType;
127
+ static createLength<_T extends LengthPercentageValue | number>(
128
+ value: ValueWithDefault,
129
+ ): LengthPercentage<string>;
130
+ static createPercentage<_T extends LengthPercentageValue | number>(
131
+ value: ValueWithDefault,
132
+ ): LengthPercentage<string>;
133
+ }
134
+ export declare const lengthPercentage: <
135
+ _T extends LengthPercentageValue | number,
136
+ >(
137
+ value: ValueWithDefault,
138
+ ) => LengthPercentage<string>;
139
+ type LengthValue = number | string;
140
+ export declare class Length<_T extends LengthValue>
141
+ extends LengthPercentage<string>
142
+ implements CSSType<string>
143
+ {
144
+ readonly value: ValueWithDefault;
145
+ readonly syntax: CSSSyntaxType;
146
+ static create<T extends LengthValue = LengthValue>(
147
+ value: NestedWithNumbers,
148
+ ): Length<T>;
149
+ }
150
+ export declare const length: <T extends LengthValue = LengthValue>(
151
+ value: NestedWithNumbers,
152
+ ) => Length<T>;
153
+ type PercentageValue = string | number;
154
+ export declare class Percentage<_T extends PercentageValue>
155
+ extends LengthPercentage<string>
156
+ implements CSSType<string>
157
+ {
158
+ readonly value: ValueWithDefault;
159
+ readonly syntax: CSSSyntaxType;
160
+ static create<T extends PercentageValue = PercentageValue>(
161
+ value: NestedWithNumbers,
162
+ ): Percentage<T>;
163
+ }
164
+ export declare const percentage: <T extends PercentageValue = PercentageValue>(
165
+ value: NestedWithNumbers,
166
+ ) => Percentage<T>;
167
+ type NumberValue = number;
168
+ export declare class Num<T extends NumberValue>
169
+ extends BaseCSSType
170
+ implements CSSType<T>
171
+ {
172
+ readonly value: ValueWithDefault;
173
+ readonly syntax: CSSSyntaxType;
174
+ static create<T extends NumberValue = NumberValue>(
175
+ value: NestedWithNumbers,
176
+ ): Num<T>;
177
+ }
178
+ export declare const number: <T extends NumberValue = NumberValue>(
179
+ value: NestedWithNumbers,
180
+ ) => Num<T>;
181
+ type ResolutionValue = string | 0;
182
+ export declare class Resolution<T extends ResolutionValue>
183
+ extends BaseCSSType
184
+ implements CSSType<T>
185
+ {
186
+ readonly value: ValueWithDefault;
187
+ readonly syntax: CSSSyntaxType;
188
+ static create<T extends ResolutionValue = ResolutionValue>(
189
+ value: ValueWithDefault,
190
+ ): Resolution<T>;
191
+ }
192
+ export declare const resolution: <T extends ResolutionValue = ResolutionValue>(
193
+ value: ValueWithDefault,
194
+ ) => Resolution<T>;
195
+ type TimeValue = string | 0;
196
+ export declare class Time<T extends TimeValue>
197
+ extends BaseCSSType
198
+ implements CSSType<T>
199
+ {
200
+ readonly value: ValueWithDefault;
201
+ readonly syntax: CSSSyntaxType;
202
+ static create<T extends TimeValue = TimeValue>(
203
+ value: ValueWithDefault,
204
+ ): Time<T>;
205
+ }
206
+ export declare const time: <T extends TimeValue = TimeValue>(
207
+ value: ValueWithDefault,
208
+ ) => Time<T>;
209
+ type TransformFunctionValue = string;
210
+ export declare class TransformFunction<T extends TransformFunctionValue>
211
+ extends BaseCSSType
212
+ implements CSSType<T>
213
+ {
214
+ readonly value: ValueWithDefault;
215
+ readonly syntax: CSSSyntaxType;
216
+ static create<T extends TransformFunctionValue = TransformFunctionValue>(
217
+ value: ValueWithDefault,
218
+ ): TransformFunction<T>;
219
+ }
220
+ export declare const transformFunction: <
221
+ T extends TransformFunctionValue = TransformFunctionValue,
222
+ >(
223
+ value: ValueWithDefault,
224
+ ) => TransformFunction<T>;
225
+ type TransformListValue = string;
226
+ export declare class TransformList<T extends TransformListValue>
227
+ extends BaseCSSType
228
+ implements CSSType<T>
229
+ {
230
+ readonly value: ValueWithDefault;
231
+ readonly syntax: CSSSyntaxType;
232
+ static create<T extends TransformListValue = TransformListValue>(
233
+ value: ValueWithDefault,
234
+ ): TransformList<T>;
235
+ }
236
+ export declare const transformList: <
237
+ T extends TransformListValue = TransformListValue,
238
+ >(
239
+ value: ValueWithDefault,
240
+ ) => TransformList<T>;
@@ -0,0 +1,280 @@
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 { Color as ColorType } from './stylex-types-color';
11
+
12
+ // We want all in one file?
13
+ // option 1, create interface an implement it in the class
14
+ // why? All the types have a single base definition of props
15
+ // We want on type that defines CSS Types
16
+ // Option 2: Do a union type and make
17
+
18
+ // interface CSSType {
19
+ // toString(): string;
20
+ // }
21
+
22
+ type NestedWithNumbers =
23
+ | number
24
+ | string
25
+ | $ReadOnly<{
26
+ default: NestedWithNumbers,
27
+ [string]: NestedWithNumbers,
28
+ }>;
29
+
30
+ type ValueWithDefault =
31
+ | string
32
+ | $ReadOnly<{
33
+ default: ValueWithDefault,
34
+ [string]: ValueWithDefault,
35
+ }>;
36
+
37
+ type CSSSyntax =
38
+ | '*'
39
+ | '<length>'
40
+ | '<number>'
41
+ | '<percentage>'
42
+ | '<length-percentage>'
43
+ | '<color>'
44
+ | '<image>'
45
+ | '<url>'
46
+ | '<integer>'
47
+ | '<angle>'
48
+ | '<time>'
49
+ | '<resolution>'
50
+ | '<transform-function>'
51
+ | '<custom-ident>'
52
+ | '<transform-list>';
53
+
54
+ type CSSSyntaxType = CSSSyntax;
55
+
56
+ declare class BaseCSSType {
57
+ +value: ValueWithDefault;
58
+ +syntax: CSSSyntaxType;
59
+ constructor(value: ValueWithDefault): void;
60
+ }
61
+ export interface CSSType<+_T: string | number = string | number> {
62
+ +value: ValueWithDefault;
63
+ +syntax: CSSSyntaxType;
64
+ }
65
+
66
+ declare export const isCSSType: (
67
+ value: mixed,
68
+ ) => implies value is CSSType<string | number>;
69
+
70
+ type AngleValue = string;
71
+ declare export class Angle<+T: AngleValue>
72
+ extends BaseCSSType
73
+ implements CSSType<T>
74
+ {
75
+ +value: ValueWithDefault;
76
+ +syntax: CSSSyntaxType;
77
+ static +syntax: CSSSyntaxType;
78
+ static create<T: AngleValue = AngleValue>(value: ValueWithDefault): Angle<T>;
79
+ }
80
+ declare export const angle: <T: AngleValue = AngleValue>(
81
+ value: ValueWithDefault,
82
+ // $FlowIgnore[method-unbinding]
83
+ ) => Angle<T>;
84
+
85
+ type ColorValue = string;
86
+ declare export class Color<+T: ColorValue>
87
+ extends BaseCSSType
88
+ implements CSSType<T>
89
+ {
90
+ +value: ValueWithDefault;
91
+ +syntax: CSSSyntaxType;
92
+ static create<T: ColorValue = ColorValue>(value: ValueWithDefault): Color<T>;
93
+ }
94
+ declare export const color: <T: ColorValue = ColorValue>(
95
+ value: ValueWithDefault,
96
+ // $FlowIgnore[method-unbinding]
97
+ ) => Color<T>;
98
+
99
+ type URLValue = string;
100
+
101
+ declare export class Url<+T: URLValue>
102
+ extends BaseCSSType
103
+ implements CSSType<T>
104
+ {
105
+ +value: ValueWithDefault;
106
+ +syntax: CSSSyntaxType;
107
+ static create<T: URLValue = URLValue>(value: ValueWithDefault): Url<T>;
108
+ }
109
+ declare export const url: <T: URLValue = URLValue>(
110
+ value: ValueWithDefault,
111
+ ) => Url<T>;
112
+
113
+ type ImageValue = string;
114
+
115
+ declare export class Image<+T: ImageValue>
116
+ extends Url<T>
117
+ implements CSSType<T>
118
+ {
119
+ +value: ValueWithDefault;
120
+ +syntax: CSSSyntaxType;
121
+ constructor(value: ValueWithDefault): void;
122
+ static create<T: ImageValue = ImageValue>(value: ValueWithDefault): Image<T>;
123
+ }
124
+ declare export const image: <T: ImageValue = ImageValue>(
125
+ value: ValueWithDefault,
126
+ // $FlowIgnore[method-unbinding]
127
+ ) => Image<T>;
128
+
129
+ type IntegerValue = number;
130
+
131
+ declare export class Integer<+T: IntegerValue>
132
+ extends BaseCSSType
133
+ implements CSSType<T>
134
+ {
135
+ +value: ValueWithDefault;
136
+ +syntax: CSSSyntaxType;
137
+ static create<T: IntegerValue = IntegerValue>(value: T): Integer<T>;
138
+ }
139
+ declare export const integer: <T: IntegerValue = IntegerValue>(
140
+ value: T,
141
+ ) => Integer<T>;
142
+
143
+ type LengthPercentageValue = string;
144
+
145
+ declare export class LengthPercentage<+_T: LengthPercentageValue>
146
+ extends BaseCSSType
147
+ implements CSSType<string>
148
+ {
149
+ +value: ValueWithDefault;
150
+ +syntax: CSSSyntaxType;
151
+ static createLength<_T: LengthPercentageValue | number>(
152
+ value: ValueWithDefault,
153
+ ): LengthPercentage<string>;
154
+ static createPercentage<_T: LengthPercentageValue | number>(
155
+ value: ValueWithDefault,
156
+ ): LengthPercentage<string>;
157
+ }
158
+ declare export const lengthPercentage: <_T: LengthPercentageValue | number>(
159
+ value: ValueWithDefault,
160
+ // $FlowIgnore[method-unbinding]
161
+ ) => LengthPercentage<string>;
162
+
163
+ type LengthValue = number | string;
164
+
165
+ declare export class Length<+_T: LengthValue>
166
+ extends LengthPercentage<string>
167
+ implements CSSType<string>
168
+ {
169
+ +value: ValueWithDefault;
170
+ +syntax: CSSSyntaxType;
171
+ static create<T: LengthValue = LengthValue>(
172
+ value: NestedWithNumbers,
173
+ ): Length<T>;
174
+ }
175
+ declare export const length: <T: LengthValue = LengthValue>(
176
+ value: NestedWithNumbers,
177
+ // $FlowIgnore[method-unbinding]
178
+ ) => Length<T>;
179
+
180
+ type PercentageValue = string | number;
181
+
182
+ declare export class Percentage<+_T: PercentageValue>
183
+ extends LengthPercentage<string>
184
+ implements CSSType<string>
185
+ {
186
+ +value: ValueWithDefault;
187
+ +syntax: CSSSyntaxType;
188
+ static create<T: PercentageValue = PercentageValue>(
189
+ value: NestedWithNumbers,
190
+ ): Percentage<T>;
191
+ }
192
+ declare export const percentage: <T: PercentageValue = PercentageValue>(
193
+ value: NestedWithNumbers,
194
+ // $FlowIgnore[method-unbinding]
195
+ ) => Percentage<T>;
196
+
197
+ type NumberValue = number;
198
+
199
+ declare export class Num<+T: NumberValue>
200
+ extends BaseCSSType
201
+ implements CSSType<T>
202
+ {
203
+ +value: ValueWithDefault;
204
+ +syntax: CSSSyntaxType;
205
+ static create<T: NumberValue = NumberValue>(value: NestedWithNumbers): Num<T>;
206
+ }
207
+ declare export const number: <T: NumberValue = NumberValue>(
208
+ value: NestedWithNumbers,
209
+ // $FlowIgnore[method-unbinding]
210
+ ) => Num<T>;
211
+
212
+ type ResolutionValue = string | 0;
213
+
214
+ declare export class Resolution<+T: ResolutionValue>
215
+ extends BaseCSSType
216
+ implements CSSType<T>
217
+ {
218
+ +value: ValueWithDefault;
219
+ +syntax: CSSSyntaxType;
220
+ static create<T: ResolutionValue = ResolutionValue>(
221
+ value: ValueWithDefault,
222
+ ): Resolution<T>;
223
+ }
224
+ declare export const resolution: <T: ResolutionValue = ResolutionValue>(
225
+ value: ValueWithDefault,
226
+ // $FlowIgnore[method-unbinding]
227
+ ) => Resolution<T>;
228
+
229
+ type TimeValue = string | 0;
230
+
231
+ declare export class Time<+T: TimeValue>
232
+ extends BaseCSSType
233
+ implements CSSType<T>
234
+ {
235
+ +value: ValueWithDefault;
236
+ +syntax: CSSSyntaxType;
237
+ static create<T: TimeValue = TimeValue>(value: ValueWithDefault): Time<T>;
238
+ }
239
+ declare export const time: <T: TimeValue = TimeValue>(
240
+ value: ValueWithDefault,
241
+ // $FlowIgnore[method-unbinding]
242
+ ) => Time<T>;
243
+
244
+ type TransformFunctionValue = string;
245
+
246
+ declare export class TransformFunction<+T: TransformFunctionValue>
247
+ extends BaseCSSType
248
+ implements CSSType<T>
249
+ {
250
+ +value: ValueWithDefault;
251
+ +syntax: CSSSyntaxType;
252
+ static create<T: TransformFunctionValue = TransformFunctionValue>(
253
+ value: ValueWithDefault,
254
+ ): TransformFunction<T>;
255
+ }
256
+ declare export const transformFunction: <
257
+ T: TransformFunctionValue = TransformFunctionValue,
258
+ >(
259
+ value: ValueWithDefault,
260
+ // $FlowIgnore[method-unbinding]
261
+ ) => TransformFunction<T>;
262
+
263
+ type TransformListValue = string;
264
+
265
+ declare export class TransformList<T: TransformListValue>
266
+ extends BaseCSSType
267
+ implements CSSType<T>
268
+ {
269
+ +value: ValueWithDefault;
270
+ +syntax: CSSSyntaxType;
271
+ static create<T: TransformListValue = TransformListValue>(
272
+ value: ValueWithDefault,
273
+ ): TransformList<T>;
274
+ }
275
+ declare export const transformList: <
276
+ T: TransformListValue = TransformListValue,
277
+ >(
278
+ value: ValueWithDefault,
279
+ // $FlowIgnore[method-unbinding]
280
+ ) => TransformList<T>;
@@ -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
+ }