@stylexjs/babel-plugin 0.0.0-6e16619c
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.
- package/README.md +33 -0
- package/flow_modules/@babel/core/index.js.flow +854 -0
- package/flow_modules/@babel/generator/index.js.flow +216 -0
- package/flow_modules/@babel/helper-module-imports/index.js.flow +182 -0
- package/flow_modules/@babel/parser/index.js.flow +253 -0
- package/flow_modules/@babel/traverse/index.js.flow +1007 -0
- package/flow_modules/@babel/types/index.js.flow +5225 -0
- package/lib/babel-path-utils.d.ts +1100 -0
- package/lib/babel-path-utils.js.flow +1108 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +8760 -0
- package/lib/index.js.flow +60 -0
- package/lib/shared/common-types.d.ts +60 -0
- package/lib/shared/common-types.js.flow +74 -0
- package/lib/shared/hash.d.ts +12 -0
- package/lib/shared/hash.js.flow +12 -0
- package/lib/shared/index.d.ts +57 -0
- package/lib/shared/index.js.flow +66 -0
- package/lib/shared/messages.d.ts +38 -0
- package/lib/shared/messages.js.flow +44 -0
- package/lib/shared/physical-rtl/generate-ltr.d.ts +15 -0
- package/lib/shared/physical-rtl/generate-ltr.js.flow +14 -0
- package/lib/shared/physical-rtl/generate-rtl.d.ts +15 -0
- package/lib/shared/physical-rtl/generate-rtl.js.flow +14 -0
- package/lib/shared/preprocess-rules/PreRule.d.ts +51 -0
- package/lib/shared/preprocess-rules/PreRule.js.flow +63 -0
- package/lib/shared/preprocess-rules/application-order.d.ts +183 -0
- package/lib/shared/preprocess-rules/application-order.js.flow +134 -0
- package/lib/shared/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/shared/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/shared/preprocess-rules/flatten-raw-style-obj.d.ts +20 -0
- package/lib/shared/preprocess-rules/flatten-raw-style-obj.js.flow +23 -0
- package/lib/shared/preprocess-rules/index.d.ts +18 -0
- package/lib/shared/preprocess-rules/index.js.flow +22 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +157 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +136 -0
- package/lib/shared/preprocess-rules/property-specificity.d.ts +78 -0
- package/lib/shared/preprocess-rules/property-specificity.js.flow +87 -0
- package/lib/shared/stylex-consts-utils.d.ts +11 -0
- package/lib/shared/stylex-consts-utils.js.flow +14 -0
- package/lib/shared/stylex-create-theme.d.ts +26 -0
- package/lib/shared/stylex-create-theme.js.flow +19 -0
- package/lib/shared/stylex-create.d.ts +27 -0
- package/lib/shared/stylex-create.js.flow +37 -0
- package/lib/shared/stylex-define-consts.d.ts +23 -0
- package/lib/shared/stylex-define-consts.js.flow +19 -0
- package/lib/shared/stylex-define-vars.d.ts +28 -0
- package/lib/shared/stylex-define-vars.js.flow +26 -0
- package/lib/shared/stylex-first-that-works.d.ts +13 -0
- package/lib/shared/stylex-first-that-works.js.flow +12 -0
- package/lib/shared/stylex-keyframes.d.ts +17 -0
- package/lib/shared/stylex-keyframes.js.flow +20 -0
- package/lib/shared/stylex-position-try.d.ts +15 -0
- package/lib/shared/stylex-position-try.js.flow +18 -0
- package/lib/shared/stylex-vars-utils.d.ts +27 -0
- package/lib/shared/stylex-vars-utils.js.flow +31 -0
- package/lib/shared/stylex-view-transition-class.d.ts +22 -0
- package/lib/shared/stylex-view-transition-class.js.flow +23 -0
- package/lib/shared/types/index.d.ts +240 -0
- package/lib/shared/types/index.js.flow +280 -0
- package/lib/shared/utils/Rule.d.ts +58 -0
- package/lib/shared/utils/Rule.js.flow +64 -0
- package/lib/shared/utils/convert-to-className.d.ts +21 -0
- package/lib/shared/utils/convert-to-className.js.flow +29 -0
- package/lib/shared/utils/dashify.d.ts +11 -0
- package/lib/shared/utils/dashify.js.flow +10 -0
- package/lib/shared/utils/default-options.d.ts +11 -0
- package/lib/shared/utils/default-options.js.flow +12 -0
- package/lib/shared/utils/file-based-identifier.d.ts +15 -0
- package/lib/shared/utils/file-based-identifier.js.flow +14 -0
- package/lib/shared/utils/genCSSRule.d.ts +15 -0
- package/lib/shared/utils/genCSSRule.js.flow +15 -0
- package/lib/shared/utils/generate-css-rule.d.ts +19 -0
- package/lib/shared/utils/generate-css-rule.js.flow +19 -0
- package/lib/shared/utils/normalize-value.d.ts +16 -0
- package/lib/shared/utils/normalize-value.js.flow +16 -0
- package/lib/shared/utils/normalizers/convert-camel-case-values.d.ts +14 -0
- package/lib/shared/utils/normalizers/convert-camel-case-values.js.flow +13 -0
- package/lib/shared/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
- package/lib/shared/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/shared/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/shared/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/shared/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/shared/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/shared/utils/normalizers/quotes.d.ts +18 -0
- package/lib/shared/utils/normalizers/quotes.js.flow +17 -0
- package/lib/shared/utils/normalizers/timings.d.ts +18 -0
- package/lib/shared/utils/normalizers/timings.js.flow +17 -0
- package/lib/shared/utils/normalizers/whitespace.d.ts +19 -0
- package/lib/shared/utils/normalizers/whitespace.js.flow +18 -0
- package/lib/shared/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/shared/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/shared/utils/object-utils.d.ts +66 -0
- package/lib/shared/utils/object-utils.js.flow +78 -0
- package/lib/shared/utils/property-priorities.d.ts +17 -0
- package/lib/shared/utils/property-priorities.js.flow +78 -0
- package/lib/shared/utils/rule-utils.d.ts +15 -0
- package/lib/shared/utils/rule-utils.js.flow +16 -0
- package/lib/shared/utils/split-css-value.d.ts +14 -0
- package/lib/shared/utils/split-css-value.js.flow +15 -0
- package/lib/shared/utils/transform-value.d.ts +22 -0
- package/lib/shared/utils/transform-value.js.flow +25 -0
- package/lib/shared/validate.d.ts +12 -0
- package/lib/shared/validate.js.flow +12 -0
- package/lib/utils/add-sourcemap-data.d.ts +23 -0
- package/lib/utils/add-sourcemap-data.js.flow +25 -0
- package/lib/utils/ast-helpers.d.ts +37 -0
- package/lib/utils/ast-helpers.js.flow +44 -0
- package/lib/utils/dev-classname.d.ts +26 -0
- package/lib/utils/dev-classname.js.flow +32 -0
- package/lib/utils/evaluate-path.d.ts +51 -0
- package/lib/utils/evaluate-path.js.flow +61 -0
- package/lib/utils/evaluation-errors.d.ts +22 -0
- package/lib/utils/evaluation-errors.js.flow +35 -0
- package/lib/utils/helpers.d.ts +12 -0
- package/lib/utils/helpers.js.flow +10 -0
- package/lib/utils/js-to-ast.d.ts +20 -0
- package/lib/utils/js-to-ast.js.flow +24 -0
- package/lib/utils/state-manager.d.ts +203 -0
- package/lib/utils/state-manager.js.flow +159 -0
- package/lib/utils/validate.d.ts +68 -0
- package/lib/utils/validate.js.flow +74 -0
- package/lib/visitors/imports.d.ts +20 -0
- package/lib/visitors/imports.js.flow +25 -0
- package/lib/visitors/parse-stylex-create-arg.d.ts +37 -0
- package/lib/visitors/parse-stylex-create-arg.js.flow +42 -0
- package/lib/visitors/stylex-attrs.d.ts +21 -0
- package/lib/visitors/stylex-attrs.js.flow +25 -0
- package/lib/visitors/stylex-create/index.d.ts +17 -0
- package/lib/visitors/stylex-create/index.js.flow +24 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +37 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +41 -0
- package/lib/visitors/stylex-create-theme.d.ts +17 -0
- package/lib/visitors/stylex-create-theme.js.flow +23 -0
- package/lib/visitors/stylex-create.d.ts +17 -0
- package/lib/visitors/stylex-create.js.flow +24 -0
- package/lib/visitors/stylex-define-consts.d.ts +17 -0
- package/lib/visitors/stylex-define-consts.js.flow +25 -0
- package/lib/visitors/stylex-define-vars.d.ts +17 -0
- package/lib/visitors/stylex-define-vars.js.flow +23 -0
- package/lib/visitors/stylex-keyframes.d.ts +17 -0
- package/lib/visitors/stylex-keyframes.js.flow +23 -0
- package/lib/visitors/stylex-merge.d.ts +21 -0
- package/lib/visitors/stylex-merge.js.flow +25 -0
- package/lib/visitors/stylex-position-try.d.ts +17 -0
- package/lib/visitors/stylex-position-try.js.flow +22 -0
- package/lib/visitors/stylex-props.d.ts +21 -0
- package/lib/visitors/stylex-props.js.flow +25 -0
- package/lib/visitors/stylex-view-transition-class.d.ts +17 -0
- package/lib/visitors/stylex-view-transition-class.js.flow +22 -0
- package/package.json +42 -0
|
@@ -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
|
+
export declare function removeNulls<T>(
|
|
11
|
+
arr: Array<null | undefined | T>,
|
|
12
|
+
): Array<T>;
|
|
@@ -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 function removeNulls<T>(arr: Array<?T>): Array<T>;
|
|
@@ -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
|
+
import type { FlatCompiledStyles } from '../shared/common-types';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
type NestedStringObject = Readonly<{
|
|
13
|
+
[key: string]: string | number | null | boolean | NestedStringObject;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function convertObjectToAST(
|
|
16
|
+
obj: NestedStringObject,
|
|
17
|
+
): t.ObjectExpression;
|
|
18
|
+
export declare function removeObjectsWithSpreads(obj: {
|
|
19
|
+
readonly [$$Key$$: string]: FlatCompiledStyles;
|
|
20
|
+
}): { readonly [$$Key$$: string]: FlatCompiledStyles };
|
|
@@ -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
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { FlatCompiledStyles } from '../shared/common-types';
|
|
11
|
+
|
|
12
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
13
|
+
|
|
14
|
+
type NestedStringObject = $ReadOnly<{
|
|
15
|
+
[key: string]: string | number | null | boolean | NestedStringObject,
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
declare export function convertObjectToAST(
|
|
19
|
+
obj: NestedStringObject,
|
|
20
|
+
): t.ObjectExpression;
|
|
21
|
+
|
|
22
|
+
declare export function removeObjectsWithSpreads(obj: {
|
|
23
|
+
+[string]: FlatCompiledStyles,
|
|
24
|
+
}): { +[string]: FlatCompiledStyles };
|
|
@@ -0,0 +1,203 @@
|
|
|
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 { PluginPass } from '@babel/core';
|
|
11
|
+
import type { NodePath } from '@babel/traverse';
|
|
12
|
+
import type {
|
|
13
|
+
CompiledNamespaces,
|
|
14
|
+
StyleXOptions as RuntimeOptions,
|
|
15
|
+
} from '../shared';
|
|
16
|
+
import * as t from '@babel/types';
|
|
17
|
+
export type ImportPathResolution =
|
|
18
|
+
| false
|
|
19
|
+
| ['themeNameRef' | 'filePath', string];
|
|
20
|
+
type ModuleResolution =
|
|
21
|
+
| Readonly<{
|
|
22
|
+
type: 'commonJS';
|
|
23
|
+
rootDir?: null | undefined | string;
|
|
24
|
+
themeFileExtension?: null | undefined | string;
|
|
25
|
+
}>
|
|
26
|
+
| Readonly<{ type: 'haste'; themeFileExtension?: null | undefined | string }>
|
|
27
|
+
| Readonly<{
|
|
28
|
+
type: 'experimental_crossFileParsing';
|
|
29
|
+
rootDir?: string;
|
|
30
|
+
themeFileExtension?: null | undefined | string;
|
|
31
|
+
}>;
|
|
32
|
+
export type StyleXOptions = Readonly<
|
|
33
|
+
Omit<
|
|
34
|
+
RuntimeOptions,
|
|
35
|
+
keyof ({
|
|
36
|
+
aliases?:
|
|
37
|
+
| null
|
|
38
|
+
| undefined
|
|
39
|
+
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
40
|
+
enableDebugClassNames?: boolean;
|
|
41
|
+
enableDebugDataProp?: boolean;
|
|
42
|
+
enableDevClassNames?: boolean;
|
|
43
|
+
enableInlinedConditionalMerge?: boolean;
|
|
44
|
+
enableMediaQueryOrder?: boolean;
|
|
45
|
+
enableLegacyValueFlipping?: boolean;
|
|
46
|
+
enableLogicalStylesPolyfill?: boolean;
|
|
47
|
+
enableMinifiedKeys?: boolean;
|
|
48
|
+
importSources: ReadonlyArray<
|
|
49
|
+
string | Readonly<{ from: string; as: string }>
|
|
50
|
+
>;
|
|
51
|
+
rewriteAliases?: boolean;
|
|
52
|
+
runtimeInjection:
|
|
53
|
+
| boolean
|
|
54
|
+
| (null | undefined | string)
|
|
55
|
+
| Readonly<{ from: string; as: string }>;
|
|
56
|
+
treeshakeCompensation?: boolean;
|
|
57
|
+
unstable_moduleResolution?: null | undefined | ModuleResolution;
|
|
58
|
+
})
|
|
59
|
+
> & {
|
|
60
|
+
aliases?:
|
|
61
|
+
| null
|
|
62
|
+
| undefined
|
|
63
|
+
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
64
|
+
enableDebugClassNames?: boolean;
|
|
65
|
+
enableDebugDataProp?: boolean;
|
|
66
|
+
enableDevClassNames?: boolean;
|
|
67
|
+
enableInlinedConditionalMerge?: boolean;
|
|
68
|
+
enableMediaQueryOrder?: boolean;
|
|
69
|
+
enableLegacyValueFlipping?: boolean;
|
|
70
|
+
enableLogicalStylesPolyfill?: boolean;
|
|
71
|
+
enableMinifiedKeys?: boolean;
|
|
72
|
+
importSources: ReadonlyArray<
|
|
73
|
+
string | Readonly<{ from: string; as: string }>
|
|
74
|
+
>;
|
|
75
|
+
rewriteAliases?: boolean;
|
|
76
|
+
runtimeInjection:
|
|
77
|
+
| boolean
|
|
78
|
+
| (null | undefined | string)
|
|
79
|
+
| Readonly<{ from: string; as: string }>;
|
|
80
|
+
treeshakeCompensation?: boolean;
|
|
81
|
+
unstable_moduleResolution?: null | undefined | ModuleResolution;
|
|
82
|
+
}
|
|
83
|
+
>;
|
|
84
|
+
type StyleXStateOptions = Readonly<
|
|
85
|
+
Omit<
|
|
86
|
+
StyleXOptions,
|
|
87
|
+
keyof ({
|
|
88
|
+
runtimeInjection:
|
|
89
|
+
| (null | undefined | string)
|
|
90
|
+
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
91
|
+
aliases?:
|
|
92
|
+
| null
|
|
93
|
+
| undefined
|
|
94
|
+
| Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
|
|
95
|
+
rewriteAliases: boolean;
|
|
96
|
+
})
|
|
97
|
+
> & {
|
|
98
|
+
runtimeInjection:
|
|
99
|
+
| (null | undefined | string)
|
|
100
|
+
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
101
|
+
aliases?:
|
|
102
|
+
| null
|
|
103
|
+
| undefined
|
|
104
|
+
| Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
|
|
105
|
+
rewriteAliases: boolean;
|
|
106
|
+
}
|
|
107
|
+
>;
|
|
108
|
+
declare class StateManager {
|
|
109
|
+
readonly _state: PluginPass;
|
|
110
|
+
readonly importPaths: Set<string>;
|
|
111
|
+
readonly stylexImport: Set<string>;
|
|
112
|
+
readonly stylexPropsImport: Set<string>;
|
|
113
|
+
readonly stylexAttrsImport: Set<string>;
|
|
114
|
+
readonly stylexCreateImport: Set<string>;
|
|
115
|
+
readonly stylexIncludeImport: Set<string>;
|
|
116
|
+
readonly stylexFirstThatWorksImport: Set<string>;
|
|
117
|
+
readonly stylexKeyframesImport: Set<string>;
|
|
118
|
+
readonly stylexPositionTryImport: Set<string>;
|
|
119
|
+
readonly stylexDefineVarsImport: Set<string>;
|
|
120
|
+
readonly stylexDefineConstsImport: Set<string>;
|
|
121
|
+
readonly stylexCreateThemeImport: Set<string>;
|
|
122
|
+
readonly stylexTypesImport: Set<string>;
|
|
123
|
+
readonly stylexViewTransitionClassImport: Set<string>;
|
|
124
|
+
injectImportInserted: null | undefined | t.Identifier;
|
|
125
|
+
readonly styleMap: Map<string, CompiledNamespaces>;
|
|
126
|
+
readonly styleVars: Map<string, NodePath>;
|
|
127
|
+
readonly styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
|
|
128
|
+
inStyleXCreate: boolean;
|
|
129
|
+
readonly options: StyleXStateOptions;
|
|
130
|
+
constructor(state: PluginPass);
|
|
131
|
+
setOptions(options: {
|
|
132
|
+
readonly [$$Key$$: string]: unknown;
|
|
133
|
+
}): StyleXStateOptions;
|
|
134
|
+
get importPathString(): string;
|
|
135
|
+
get importSources(): ReadonlyArray<string>;
|
|
136
|
+
importAs(source: string): null | string;
|
|
137
|
+
get canReferenceTheme(): boolean;
|
|
138
|
+
get metadata(): { [key: string]: any };
|
|
139
|
+
get runtimeInjection():
|
|
140
|
+
| null
|
|
141
|
+
| undefined
|
|
142
|
+
| Readonly<{ from: string; as?: null | undefined | string }>;
|
|
143
|
+
get opts(): StyleXStateOptions;
|
|
144
|
+
get isDebug(): boolean;
|
|
145
|
+
get isDev(): boolean;
|
|
146
|
+
get isTest(): boolean;
|
|
147
|
+
get filename(): string | void;
|
|
148
|
+
get cssVars(): any;
|
|
149
|
+
get treeshakeCompensation(): boolean;
|
|
150
|
+
get fileNameForHashing(): null | string;
|
|
151
|
+
getPackageNameAndPath(
|
|
152
|
+
filepath: string,
|
|
153
|
+
): null | readonly [packageName: string, packageDir: string];
|
|
154
|
+
getCanonicalFilePath(filePath: string): string;
|
|
155
|
+
importPathResolver(importPath: string): ImportPathResolution;
|
|
156
|
+
addStyle(
|
|
157
|
+
style: [
|
|
158
|
+
string,
|
|
159
|
+
(
|
|
160
|
+
| { ltr: string; rtl?: string | null }
|
|
161
|
+
| {
|
|
162
|
+
constKey: string;
|
|
163
|
+
constVal: string | number;
|
|
164
|
+
rtl?: string | null;
|
|
165
|
+
ltr: string;
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
number,
|
|
169
|
+
],
|
|
170
|
+
): void;
|
|
171
|
+
registerStyles(
|
|
172
|
+
styles: ReadonlyArray<
|
|
173
|
+
[
|
|
174
|
+
string,
|
|
175
|
+
(
|
|
176
|
+
| { ltr: string; rtl?: string | null }
|
|
177
|
+
| {
|
|
178
|
+
constKey: string;
|
|
179
|
+
constVal: string | number;
|
|
180
|
+
rtl?: string | null;
|
|
181
|
+
ltr: string;
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
number,
|
|
185
|
+
]
|
|
186
|
+
>,
|
|
187
|
+
path?: null | undefined | NodePath,
|
|
188
|
+
): void;
|
|
189
|
+
markComposedNamespace(
|
|
190
|
+
memberExpression: [string, true | string, true | Array<string>],
|
|
191
|
+
): void;
|
|
192
|
+
}
|
|
193
|
+
export default StateManager;
|
|
194
|
+
export declare const filePathResolver: (
|
|
195
|
+
relativeFilePath: string,
|
|
196
|
+
sourceFilePath: string,
|
|
197
|
+
aliases: StyleXStateOptions['aliases'],
|
|
198
|
+
) => null | undefined | string;
|
|
199
|
+
export declare const EXTENSIONS: any;
|
|
200
|
+
export declare const matchesFileSuffix: (
|
|
201
|
+
$$PARAM_0$$: string,
|
|
202
|
+
) => ($$PARAM_0$$: string) => boolean;
|
|
203
|
+
export declare function getRelativePath(from: string, to: string): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
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 { PluginPass } from '../../flow_modules/@babel/core';
|
|
11
|
+
import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
12
|
+
import type {
|
|
13
|
+
CompiledNamespaces,
|
|
14
|
+
StyleXOptions as RuntimeOptions,
|
|
15
|
+
} from '../shared';
|
|
16
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
17
|
+
export type ImportPathResolution =
|
|
18
|
+
| false
|
|
19
|
+
| ['themeNameRef' | 'filePath', string];
|
|
20
|
+
|
|
21
|
+
type ModuleResolution =
|
|
22
|
+
| $ReadOnly<{
|
|
23
|
+
type: 'commonJS',
|
|
24
|
+
rootDir?: ?string,
|
|
25
|
+
themeFileExtension?: ?string,
|
|
26
|
+
}>
|
|
27
|
+
| $ReadOnly<{
|
|
28
|
+
type: 'haste',
|
|
29
|
+
themeFileExtension?: ?string,
|
|
30
|
+
}>
|
|
31
|
+
| $ReadOnly<{
|
|
32
|
+
type: 'experimental_crossFileParsing',
|
|
33
|
+
rootDir?: string,
|
|
34
|
+
themeFileExtension?: ?string,
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export type StyleXOptions = $ReadOnly<{
|
|
38
|
+
...RuntimeOptions,
|
|
39
|
+
aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
|
|
40
|
+
enableDebugClassNames?: boolean,
|
|
41
|
+
enableDebugDataProp?: boolean,
|
|
42
|
+
enableDevClassNames?: boolean,
|
|
43
|
+
enableInlinedConditionalMerge?: boolean,
|
|
44
|
+
enableMediaQueryOrder?: boolean,
|
|
45
|
+
enableLegacyValueFlipping?: boolean,
|
|
46
|
+
enableLogicalStylesPolyfill?: boolean,
|
|
47
|
+
enableMinifiedKeys?: boolean,
|
|
48
|
+
importSources: $ReadOnlyArray<
|
|
49
|
+
string | $ReadOnly<{ from: string, as: string }>,
|
|
50
|
+
>,
|
|
51
|
+
rewriteAliases?: boolean,
|
|
52
|
+
runtimeInjection: boolean | ?string | $ReadOnly<{ from: string, as: string }>,
|
|
53
|
+
treeshakeCompensation?: boolean,
|
|
54
|
+
unstable_moduleResolution?: ?ModuleResolution,
|
|
55
|
+
...
|
|
56
|
+
}>;
|
|
57
|
+
|
|
58
|
+
type StyleXStateOptions = $ReadOnly<{
|
|
59
|
+
...StyleXOptions,
|
|
60
|
+
runtimeInjection: ?string | $ReadOnly<{ from: string, as: ?string }>,
|
|
61
|
+
aliases?: ?$ReadOnly<{ [string]: $ReadOnlyArray<string> }>,
|
|
62
|
+
rewriteAliases: boolean,
|
|
63
|
+
...
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
declare export default class StateManager {
|
|
67
|
+
+_state: PluginPass;
|
|
68
|
+
+importPaths: Set<string>;
|
|
69
|
+
+stylexImport: Set<string>;
|
|
70
|
+
+stylexPropsImport: Set<string>;
|
|
71
|
+
+stylexAttrsImport: Set<string>;
|
|
72
|
+
+stylexCreateImport: Set<string>;
|
|
73
|
+
+stylexIncludeImport: Set<string>;
|
|
74
|
+
+stylexFirstThatWorksImport: Set<string>;
|
|
75
|
+
+stylexKeyframesImport: Set<string>;
|
|
76
|
+
+stylexPositionTryImport: Set<string>;
|
|
77
|
+
+stylexDefineVarsImport: Set<string>;
|
|
78
|
+
+stylexDefineConstsImport: Set<string>;
|
|
79
|
+
+stylexCreateThemeImport: Set<string>;
|
|
80
|
+
+stylexTypesImport: Set<string>;
|
|
81
|
+
+stylexViewTransitionClassImport: Set<string>;
|
|
82
|
+
injectImportInserted: ?t.Identifier;
|
|
83
|
+
+styleMap: Map<string, CompiledNamespaces>;
|
|
84
|
+
+styleVars: Map<string, NodePath<>>;
|
|
85
|
+
+styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
|
|
86
|
+
inStyleXCreate: boolean;
|
|
87
|
+
+options: StyleXStateOptions;
|
|
88
|
+
constructor(state: PluginPass): void;
|
|
89
|
+
setOptions(options: { +[string]: mixed }): StyleXStateOptions;
|
|
90
|
+
get importPathString(): string;
|
|
91
|
+
get importSources(): $ReadOnlyArray<string>;
|
|
92
|
+
importAs(source: string): null | string;
|
|
93
|
+
get canReferenceTheme(): boolean;
|
|
94
|
+
get metadata(): { [key: string]: any };
|
|
95
|
+
get runtimeInjection(): ?$ReadOnly<{ from: string, as?: ?string }>;
|
|
96
|
+
get opts(): StyleXStateOptions;
|
|
97
|
+
get isDebug(): boolean;
|
|
98
|
+
get isDev(): boolean;
|
|
99
|
+
get isTest(): boolean;
|
|
100
|
+
get filename(): string | void;
|
|
101
|
+
get cssVars(): any;
|
|
102
|
+
get treeshakeCompensation(): boolean;
|
|
103
|
+
get fileNameForHashing(): null | string;
|
|
104
|
+
getPackageNameAndPath(
|
|
105
|
+
filepath: string,
|
|
106
|
+
): null | [+packageName: string, +packageDir: string];
|
|
107
|
+
getCanonicalFilePath(filePath: string): string;
|
|
108
|
+
importPathResolver(importPath: string): ImportPathResolution;
|
|
109
|
+
addStyle(
|
|
110
|
+
style: [
|
|
111
|
+
string,
|
|
112
|
+
(
|
|
113
|
+
| { ltr: string, rtl?: string | null }
|
|
114
|
+
| {
|
|
115
|
+
constKey: string,
|
|
116
|
+
constVal: string | number,
|
|
117
|
+
rtl?: string | null,
|
|
118
|
+
ltr: string,
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
number,
|
|
122
|
+
],
|
|
123
|
+
): void;
|
|
124
|
+
registerStyles(
|
|
125
|
+
styles: $ReadOnlyArray<
|
|
126
|
+
[
|
|
127
|
+
string,
|
|
128
|
+
(
|
|
129
|
+
| { ltr: string, rtl?: string | null }
|
|
130
|
+
| {
|
|
131
|
+
constKey: string,
|
|
132
|
+
constVal: string | number,
|
|
133
|
+
rtl?: string | null,
|
|
134
|
+
ltr: string,
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
number,
|
|
138
|
+
],
|
|
139
|
+
>,
|
|
140
|
+
path?: ?NodePath<>,
|
|
141
|
+
): void;
|
|
142
|
+
markComposedNamespace(
|
|
143
|
+
memberExpression: [string, true | string, true | Array<string>],
|
|
144
|
+
): void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// a function that resolves the absolute path of a file when given the
|
|
148
|
+
// relative path of the file from the source file
|
|
149
|
+
declare export const filePathResolver: (
|
|
150
|
+
relativeFilePath: string,
|
|
151
|
+
sourceFilePath: string,
|
|
152
|
+
aliases: StyleXStateOptions['aliases'],
|
|
153
|
+
) => ?string;
|
|
154
|
+
|
|
155
|
+
declare export const EXTENSIONS: $FlowFixMe;
|
|
156
|
+
|
|
157
|
+
declare export const matchesFileSuffix: (string) => (string) => boolean;
|
|
158
|
+
|
|
159
|
+
declare export function getRelativePath(from: string, to: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
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 type Check<T> = (val: unknown, name?: string) => Error | T;
|
|
11
|
+
export type InferCheckType<T> =
|
|
12
|
+
T extends Check<infer U>
|
|
13
|
+
? U
|
|
14
|
+
: /**
|
|
15
|
+
* > 11 | export type InferCheckType<T> = T extends Check<infer U> ? U : empty;
|
|
16
|
+
* | ^^^^^ Unsupported feature: Translating "empty type" is currently not supported.
|
|
17
|
+
**/
|
|
18
|
+
any;
|
|
19
|
+
type Msg = (value: unknown, name?: string) => string;
|
|
20
|
+
type PrimitiveChecker<T> = (message?: Msg) => Check<T>;
|
|
21
|
+
export declare const string: PrimitiveChecker<string>;
|
|
22
|
+
export declare const nullish: PrimitiveChecker<null | void>;
|
|
23
|
+
export declare const boolean: PrimitiveChecker<boolean>;
|
|
24
|
+
export declare const number: PrimitiveChecker<number>;
|
|
25
|
+
export declare const literal: <T extends string | number | boolean>(
|
|
26
|
+
$$PARAM_0$$: T,
|
|
27
|
+
msg?: Msg,
|
|
28
|
+
) => Check<T>;
|
|
29
|
+
export declare const array: <T>(
|
|
30
|
+
$$PARAM_0$$: Check<T>,
|
|
31
|
+
msg?: Msg,
|
|
32
|
+
) => Check<ReadonlyArray<T>>;
|
|
33
|
+
type ObjOfChecks<T extends { readonly [$$Key$$: string]: Check<unknown> }> =
|
|
34
|
+
Readonly<{ [K in keyof T]: InferCheckType<T[K]> }>;
|
|
35
|
+
export declare const object: <
|
|
36
|
+
T extends { readonly [$$Key$$: string]: Check<unknown> },
|
|
37
|
+
>(
|
|
38
|
+
$$PARAM_0$$: T,
|
|
39
|
+
msg?: Msg,
|
|
40
|
+
) => Check<ObjOfChecks<T>>;
|
|
41
|
+
export declare const objectOf: <T>(
|
|
42
|
+
$$PARAM_0$$: Check<T>,
|
|
43
|
+
message?: Msg,
|
|
44
|
+
) => Check<{ readonly [$$Key$$: string]: T }>;
|
|
45
|
+
export declare const unionOf: <A, B>(
|
|
46
|
+
a: Check<A>,
|
|
47
|
+
b: Check<B>,
|
|
48
|
+
message: Msg,
|
|
49
|
+
) => Check<A | B>;
|
|
50
|
+
export declare const unionOf3: <A, B, C>(
|
|
51
|
+
a: Check<A>,
|
|
52
|
+
b: Check<B>,
|
|
53
|
+
c: Check<C>,
|
|
54
|
+
message: Msg,
|
|
55
|
+
) => Check<A | B | C>;
|
|
56
|
+
export declare const unionOf4: <A, B, C, D>(
|
|
57
|
+
a: Check<A>,
|
|
58
|
+
b: Check<B>,
|
|
59
|
+
c: Check<C>,
|
|
60
|
+
d: Check<D>,
|
|
61
|
+
message: Msg,
|
|
62
|
+
) => Check<A | B | C | D>;
|
|
63
|
+
export declare const logAndDefault: <T>(
|
|
64
|
+
check: Check<T>,
|
|
65
|
+
value: unknown,
|
|
66
|
+
def: T,
|
|
67
|
+
name?: string,
|
|
68
|
+
) => T;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
export type Check<+T> = (val: mixed, name?: string) => Error | T;
|
|
11
|
+
export type InferCheckType<T> = T extends Check<infer U> ? U : empty;
|
|
12
|
+
|
|
13
|
+
type Msg = (value: mixed, name?: string) => string;
|
|
14
|
+
type PrimitiveChecker<+T> = (message?: Msg) => Check<T>;
|
|
15
|
+
|
|
16
|
+
declare export const string: PrimitiveChecker<string>;
|
|
17
|
+
|
|
18
|
+
declare export const nullish: PrimitiveChecker<null | void>;
|
|
19
|
+
|
|
20
|
+
declare export const boolean: PrimitiveChecker<boolean>;
|
|
21
|
+
|
|
22
|
+
declare export const number: PrimitiveChecker<number>;
|
|
23
|
+
|
|
24
|
+
declare export const literal: <T: string | number | boolean>(
|
|
25
|
+
T,
|
|
26
|
+
msg?: Msg,
|
|
27
|
+
) => Check<T>;
|
|
28
|
+
|
|
29
|
+
declare export const array: <T>(
|
|
30
|
+
Check<T>,
|
|
31
|
+
msg?: Msg,
|
|
32
|
+
) => Check<$ReadOnlyArray<T>>;
|
|
33
|
+
|
|
34
|
+
type ObjOfChecks<T: { +[string]: Check<mixed> }> = $ReadOnly<{
|
|
35
|
+
[K in keyof T]: InferCheckType<T[K]>,
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
declare export const object: <T: { +[string]: Check<mixed> }>(
|
|
39
|
+
T,
|
|
40
|
+
msg?: Msg,
|
|
41
|
+
) => Check<ObjOfChecks<T>>;
|
|
42
|
+
|
|
43
|
+
declare export const objectOf: <T>(
|
|
44
|
+
Check<T>,
|
|
45
|
+
message?: Msg,
|
|
46
|
+
) => Check<{ +[string]: T }>;
|
|
47
|
+
|
|
48
|
+
declare export const unionOf: <A, B>(
|
|
49
|
+
a: Check<A>,
|
|
50
|
+
b: Check<B>,
|
|
51
|
+
message: Msg,
|
|
52
|
+
) => Check<A | B>;
|
|
53
|
+
|
|
54
|
+
declare export const unionOf3: <A, B, C>(
|
|
55
|
+
a: Check<A>,
|
|
56
|
+
b: Check<B>,
|
|
57
|
+
c: Check<C>,
|
|
58
|
+
message: Msg,
|
|
59
|
+
) => Check<A | B | C>;
|
|
60
|
+
|
|
61
|
+
declare export const unionOf4: <A, B, C, D>(
|
|
62
|
+
a: Check<A>,
|
|
63
|
+
b: Check<B>,
|
|
64
|
+
c: Check<C>,
|
|
65
|
+
d: Check<D>,
|
|
66
|
+
message: Msg,
|
|
67
|
+
) => Check<A | B | C | D>;
|
|
68
|
+
|
|
69
|
+
declare export const logAndDefault: <T>(
|
|
70
|
+
check: Check<T>,
|
|
71
|
+
value: mixed,
|
|
72
|
+
def: T,
|
|
73
|
+
name?: string,
|
|
74
|
+
) => T;
|
|
@@ -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
|
+
import type { NodePath } from '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
|
+
export declare function readImportDeclarations(
|
|
14
|
+
path: NodePath<t.ImportDeclaration>,
|
|
15
|
+
state: StateManager,
|
|
16
|
+
): void;
|
|
17
|
+
export declare function readRequires(
|
|
18
|
+
path: NodePath<t.VariableDeclarator>,
|
|
19
|
+
state: StateManager,
|
|
20
|
+
): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { NodePath } from '../../flow_modules/@babel/traverse';
|
|
11
|
+
|
|
12
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
13
|
+
import StateManager from '../utils/state-manager';
|
|
14
|
+
|
|
15
|
+
// Read imports of react and remember the name of the local variables for later
|
|
16
|
+
declare export function readImportDeclarations(
|
|
17
|
+
path: NodePath<t.ImportDeclaration>,
|
|
18
|
+
state: StateManager,
|
|
19
|
+
): void;
|
|
20
|
+
|
|
21
|
+
// Read require calls and remember the names of the variables for later
|
|
22
|
+
declare export function readRequires(
|
|
23
|
+
path: NodePath<t.VariableDeclarator>,
|
|
24
|
+
state: StateManager,
|
|
25
|
+
): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { NodePath } from '@babel/traverse';
|
|
11
|
+
import type { FunctionConfig } from '../utils/evaluate-path';
|
|
12
|
+
import * as t from '@babel/types';
|
|
13
|
+
import StateManager from '../utils/state-manager';
|
|
14
|
+
type TInlineStyles = {
|
|
15
|
+
[$$Key$$: string]: {
|
|
16
|
+
readonly path: ReadonlyArray<string>;
|
|
17
|
+
readonly originalExpression: t.Expression;
|
|
18
|
+
readonly expression: t.Expression | t.PatternLike;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type DynamicFns = {
|
|
22
|
+
[$$Key$$: string]: readonly [
|
|
23
|
+
params: Array<t.Identifier>,
|
|
24
|
+
inlineStyles: Readonly<TInlineStyles>,
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
export declare function evaluateStyleXCreateArg(
|
|
28
|
+
path: NodePath,
|
|
29
|
+
traversalState: StateManager,
|
|
30
|
+
functions: FunctionConfig,
|
|
31
|
+
): Readonly<{
|
|
32
|
+
confident: boolean;
|
|
33
|
+
value: any;
|
|
34
|
+
deopt?: null | NodePath;
|
|
35
|
+
reason?: string;
|
|
36
|
+
fns?: DynamicFns;
|
|
37
|
+
}>;
|