@stylexjs/babel-plugin 0.16.2 → 0.16.3
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/lib/index.d.ts +5 -5
- package/lib/index.js +58 -14
- package/lib/index.js.flow +1 -1
- package/lib/shared/common-types.d.ts +3 -4
- package/lib/shared/stylex-create-theme.d.ts +1 -1
- package/lib/shared/stylex-define-vars.d.ts +3 -3
- package/lib/shared/types/index.js.flow +11 -11
- package/lib/utils/add-sourcemap-data.js.flow +2 -2
- package/lib/utils/ast-helpers.js.flow +3 -3
- package/lib/utils/evaluate-path.js.flow +2 -2
- package/lib/utils/js-to-ast.js.flow +1 -1
- package/lib/utils/state-manager.d.ts +36 -19
- package/lib/utils/state-manager.js.flow +36 -22
- package/lib/utils/validate.d.ts +1 -0
- package/lib/utils/validate.js.flow +2 -0
- package/lib/visitors/imports.js.flow +2 -2
- package/lib/visitors/parse-stylex-create-arg.js.flow +2 -2
- package/lib/visitors/stylex-create-theme.js.flow +2 -2
- package/lib/visitors/stylex-create.js.flow +2 -2
- package/lib/visitors/stylex-default-marker.js.flow +2 -2
- package/lib/visitors/stylex-define-consts.js.flow +2 -2
- package/lib/visitors/stylex-define-vars.js.flow +2 -2
- package/lib/visitors/stylex-keyframes.js.flow +2 -2
- package/lib/visitors/stylex-merge.js.flow +2 -2
- package/lib/visitors/stylex-position-try.js.flow +2 -2
- package/lib/visitors/stylex-props.js.flow +2 -2
- package/lib/visitors/stylex-view-transition-class.js.flow +2 -2
- package/package.json +3 -3
- package/flow_modules/@babel/core/index.js.flow +0 -854
- package/flow_modules/@babel/generator/index.js.flow +0 -216
- package/flow_modules/@babel/helper-module-imports/index.js.flow +0 -182
- package/flow_modules/@babel/parser/index.js.flow +0 -253
- package/flow_modules/@babel/traverse/index.js.flow +0 -1007
- package/flow_modules/@babel/types/index.js.flow +0 -5225
|
@@ -1,216 +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
|
-
* @flow strict
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as t from '../types';
|
|
10
|
-
|
|
11
|
-
export interface GeneratorOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Optional string to add as a block comment at the start of the output file.
|
|
14
|
-
*/
|
|
15
|
-
+auxiliaryCommentBefore?: string | void;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Optional string to add as a block comment at the end of the output file.
|
|
19
|
-
*/
|
|
20
|
-
+auxiliaryCommentAfter?: string | void;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Function that takes a comment (as a string) and returns true if the comment should be included in the output.
|
|
24
|
-
* By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment
|
|
25
|
-
* contains `@preserve` or `@license`.
|
|
26
|
-
*/
|
|
27
|
-
+shouldPrintComment?: (comment: string) => boolean;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces).
|
|
31
|
-
* Defaults to `false`.
|
|
32
|
-
*/
|
|
33
|
-
+retainLines?: boolean | void;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Retain parens around function expressions (could be used to change engine parsing behavior)
|
|
37
|
-
* Defaults to `false`.
|
|
38
|
-
*/
|
|
39
|
-
+retainFunctionParens?: boolean | void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Should comments be included in output? Defaults to `true`.
|
|
43
|
-
*/
|
|
44
|
-
comments?: boolean | void;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Set to true to avoid adding whitespace for formatting. Defaults to the value of `opts.minified`.
|
|
48
|
-
*/
|
|
49
|
-
compact?: boolean | 'auto' | void;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Should the output be minified. Defaults to `false`.
|
|
53
|
-
*/
|
|
54
|
-
minified?: boolean | void;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
|
|
58
|
-
*/
|
|
59
|
-
concise?: boolean | void;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Used in warning messages
|
|
63
|
-
*/
|
|
64
|
-
filename?: string | void;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Enable generating source maps. Defaults to `false`.
|
|
68
|
-
*/
|
|
69
|
-
sourceMaps?: boolean | void;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A root for all relative URLs in the source map.
|
|
73
|
-
*/
|
|
74
|
-
sourceRoot?: string | void;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The filename for the source code (i.e. the code in the `code` argument).
|
|
78
|
-
* This will only be used if `code` is a string.
|
|
79
|
-
*/
|
|
80
|
-
sourceFileName?: string | void;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
|
|
84
|
-
*/
|
|
85
|
-
jsonCompatibleStrings?: boolean | void;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Set to true to enable support for experimental decorators syntax before module exports.
|
|
89
|
-
* Defaults to `false`.
|
|
90
|
-
*/
|
|
91
|
-
decoratorsBeforeExport?: boolean | void;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Options for outputting jsesc representation.
|
|
95
|
-
*/
|
|
96
|
-
jsescOption?: {
|
|
97
|
-
/**
|
|
98
|
-
* The default value for the quotes option is 'single'. This means that any occurrences of ' in the input
|
|
99
|
-
* string are escaped as \', so that the output can be used in a string literal wrapped in single quotes.
|
|
100
|
-
*/
|
|
101
|
-
quotes?: 'single' | 'double' | 'backtick' | void,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The default value for the numbers option is 'decimal'. This means that any numeric values are represented
|
|
105
|
-
* using decimal integer literals. Other valid options are binary, octal, and hexadecimal, which result in
|
|
106
|
-
* binary integer literals, octal integer literals, and hexadecimal integer literals, respectively.
|
|
107
|
-
*/
|
|
108
|
-
numbers?: 'binary' | 'octal' | 'decimal' | 'hexadecimal' | void,
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The wrap option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
|
|
112
|
-
* output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be specified through
|
|
113
|
-
* the quotes setting.
|
|
114
|
-
*/
|
|
115
|
-
wrap?: boolean | void,
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* The es6 option takes a boolean value (true or false), and defaults to false (disabled). When enabled, any
|
|
119
|
-
* astral Unicode symbols in the input are escaped using ECMAScript 6 Unicode code point escape sequences
|
|
120
|
-
* instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5
|
|
121
|
-
* environments is a concern, don’t enable this setting. If the json setting is enabled, the value for the es6
|
|
122
|
-
* setting is ignored (as if it was false).
|
|
123
|
-
*/
|
|
124
|
-
es6?: boolean | void,
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The escapeEverything option takes a boolean value (true or false), and defaults to false (disabled). When
|
|
128
|
-
* enabled, all the symbols in the output are escaped — even printable ASCII symbols.
|
|
129
|
-
*/
|
|
130
|
-
escapeEverything?: boolean | void,
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The minimal option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
|
|
134
|
-
* only a limited set of symbols in the output are escaped: \0, \b, \t, \n, \f, \r, \\, \u2028, \u2029.
|
|
135
|
-
*/
|
|
136
|
-
minimal?: boolean | void,
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The isScriptContext option takes a boolean value (true or false), and defaults to false (disabled). When
|
|
140
|
-
* enabled, occurrences of </script and </style in the output are escaped as <\/script and <\/style, and <!--
|
|
141
|
-
* is escaped as \x3C!-- (or \u003C!-- when the json option is enabled). This setting is useful when jsesc’s
|
|
142
|
-
* output ends up as part of a <script> or <style> element in an HTML document.
|
|
143
|
-
*/
|
|
144
|
-
isScriptContext?: boolean | void,
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The compact option takes a boolean value (true or false), and defaults to true (enabled). When enabled,
|
|
148
|
-
* the output for arrays and objects is as compact as possible; it’s not formatted nicely.
|
|
149
|
-
*/
|
|
150
|
-
compact?: boolean | void,
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* The indent option takes a string value, and defaults to '\t'. When the compact setting is enabled (true),
|
|
154
|
-
* the value of the indent option is used to format the output for arrays and objects.
|
|
155
|
-
*/
|
|
156
|
-
indent?: string | void,
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The indentLevel option takes a numeric value, and defaults to 0. It represents the current indentation level,
|
|
160
|
-
* i.e. the number of times the value of the indent option is repeated.
|
|
161
|
-
*/
|
|
162
|
-
indentLevel?: number | void,
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* The json option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
|
|
166
|
-
* output is valid JSON. Hexadecimal character escape sequences and the \v or \0 escape sequences are not used.
|
|
167
|
-
* Setting json: true implies quotes: 'double', wrap: true, es6: false, although these values can still be
|
|
168
|
-
* overridden if needed — but in such cases, the output won’t be valid JSON anymore.
|
|
169
|
-
*/
|
|
170
|
-
json?: boolean | void,
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* The lowercaseHex option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
|
|
174
|
-
* any alphabetical hexadecimal digits in escape sequences as well as any hexadecimal integer literals (see the
|
|
175
|
-
* numbers option) in the output are in lowercase.
|
|
176
|
-
*/
|
|
177
|
-
lowercaseHex?: boolean | void,
|
|
178
|
-
} | void;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare export class CodeGenerator {
|
|
182
|
-
constructor(
|
|
183
|
-
ast: t.Node,
|
|
184
|
-
opts?: GeneratorOptions,
|
|
185
|
-
code?: string,
|
|
186
|
-
): CodeGenerator;
|
|
187
|
-
generate(): GeneratorResult;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.
|
|
192
|
-
* @param ast - the abstract syntax tree from which to generate output code.
|
|
193
|
-
* @param opts - used for specifying options for code generation.
|
|
194
|
-
* @param code - the original source code, used for source maps.
|
|
195
|
-
* @returns - an object containing the output code and source map.
|
|
196
|
-
*/
|
|
197
|
-
declare function generate(
|
|
198
|
-
ast: t.Node,
|
|
199
|
-
opts?: GeneratorOptions,
|
|
200
|
-
code?: string | { [filename: string]: string },
|
|
201
|
-
): GeneratorResult;
|
|
202
|
-
|
|
203
|
-
export default generate;
|
|
204
|
-
|
|
205
|
-
export interface GeneratorResult {
|
|
206
|
-
code: string;
|
|
207
|
-
map: {
|
|
208
|
-
version: number,
|
|
209
|
-
sources: string[],
|
|
210
|
-
names: string[],
|
|
211
|
-
sourceRoot?: string | void,
|
|
212
|
-
sourcesContent?: Array<string> | void,
|
|
213
|
-
mappings: string,
|
|
214
|
-
file: string,
|
|
215
|
-
} | null;
|
|
216
|
-
}
|
|
@@ -1,182 +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 * as t from '../types';
|
|
11
|
-
import type { NodePath } from '@babel/traverse';
|
|
12
|
-
|
|
13
|
-
export type ImportOptions = $ReadOnly<{
|
|
14
|
-
/**
|
|
15
|
-
* The module being referenced.
|
|
16
|
-
*/
|
|
17
|
-
importedSource: string | null,
|
|
18
|
-
/**
|
|
19
|
-
* The type of module being imported:
|
|
20
|
-
*
|
|
21
|
-
* * 'es6' - An ES6 module.
|
|
22
|
-
* * 'commonjs' - A CommonJS module. (Default)
|
|
23
|
-
*/
|
|
24
|
-
importedType: 'es6' | 'commonjs',
|
|
25
|
-
/**
|
|
26
|
-
* The type of interop behavior for namespace/default/named when loading
|
|
27
|
-
* CommonJS modules.
|
|
28
|
-
*
|
|
29
|
-
* ## 'babel' (Default)
|
|
30
|
-
*
|
|
31
|
-
* Load using Babel's interop.
|
|
32
|
-
*
|
|
33
|
-
* If '.__esModule' is true, treat as 'compiled', else:
|
|
34
|
-
*
|
|
35
|
-
* * Namespace: A copy of the module.exports with .default
|
|
36
|
-
* populated by the module.exports object.
|
|
37
|
-
* * Default: The module.exports value.
|
|
38
|
-
* * Named: The .named property of module.exports.
|
|
39
|
-
*
|
|
40
|
-
* The 'ensureLiveReference' has no effect on the liveness of these.
|
|
41
|
-
*
|
|
42
|
-
* ## 'compiled'
|
|
43
|
-
*
|
|
44
|
-
* Assume the module is ES6 compiled to CommonJS. Useful to avoid injecting
|
|
45
|
-
* interop logic if you are confident that the module is a certain format.
|
|
46
|
-
*
|
|
47
|
-
* * Namespace: The root module.exports object.
|
|
48
|
-
* * Default: The .default property of the namespace.
|
|
49
|
-
* * Named: The .named property of the namespace.
|
|
50
|
-
*
|
|
51
|
-
* Will return erroneous results if the imported module is _not_ compiled
|
|
52
|
-
* from ES6 with Babel.
|
|
53
|
-
*
|
|
54
|
-
* ## 'uncompiled'
|
|
55
|
-
*
|
|
56
|
-
* Assume the module is _not_ ES6 compiled to CommonJS. Used a simplified
|
|
57
|
-
* access pattern that doesn't require additional function calls.
|
|
58
|
-
*
|
|
59
|
-
* Will return erroneous results if the imported module _is_ compiled
|
|
60
|
-
* from ES6 with Babel.
|
|
61
|
-
*
|
|
62
|
-
* * Namespace: The module.exports object.
|
|
63
|
-
* * Default: The module.exports object.
|
|
64
|
-
* * Named: The .named property of module.exports.
|
|
65
|
-
*/
|
|
66
|
-
importedInterop: 'babel' | 'node' | 'compiled' | 'uncompiled',
|
|
67
|
-
/**
|
|
68
|
-
* The type of CommonJS interop included in the environment that will be
|
|
69
|
-
* loading the output code.
|
|
70
|
-
*
|
|
71
|
-
* * 'babel' - CommonJS modules load with Babel's interop. (Default)
|
|
72
|
-
* * 'node' - CommonJS modules load with Node's interop.
|
|
73
|
-
*
|
|
74
|
-
* See descriptions in 'importedInterop' for more details.
|
|
75
|
-
*/
|
|
76
|
-
importingInterop: 'babel' | 'node',
|
|
77
|
-
/**
|
|
78
|
-
* Define whether we explicitly care that the import be a live reference.
|
|
79
|
-
* Only applies when importing default and named imports, not the namespace.
|
|
80
|
-
*
|
|
81
|
-
* * true - Force imported values to be live references.
|
|
82
|
-
* * false - No particular requirements. Keeps the code simplest. (Default)
|
|
83
|
-
*/
|
|
84
|
-
ensureLiveReference: boolean,
|
|
85
|
-
/**
|
|
86
|
-
* Define if we explicitly care that the result not be a property reference.
|
|
87
|
-
*
|
|
88
|
-
* * true - Force calls to exclude context. Useful if the value is going to
|
|
89
|
-
* be used as function callee.
|
|
90
|
-
* * false - No particular requirements for context of the access. (Default)
|
|
91
|
-
*/
|
|
92
|
-
ensureNoContext: boolean,
|
|
93
|
-
/**
|
|
94
|
-
* Define whether the import should be loaded before or after the existing imports.
|
|
95
|
-
* "after" is only allowed inside ECMAScript modules, since it's not possible to
|
|
96
|
-
* reliably pick the location _after_ require() calls but _before_ other code in CJS.
|
|
97
|
-
*/
|
|
98
|
-
importPosition: 'before' | 'after',
|
|
99
|
-
|
|
100
|
-
nameHint?: string,
|
|
101
|
-
blockHoist?: number,
|
|
102
|
-
}>;
|
|
103
|
-
|
|
104
|
-
declare export function addDefault(
|
|
105
|
-
path: NodePath<>,
|
|
106
|
-
importedSource: string,
|
|
107
|
-
opts?: Partial<ImportOptions>,
|
|
108
|
-
): t.Identifier;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* add a named import to the program path of given path
|
|
112
|
-
*
|
|
113
|
-
* @param path The starting path to find a program path
|
|
114
|
-
* @param name The name of the generated binding. Babel will prefix it with `_`
|
|
115
|
-
* @param importedSource The source of the import
|
|
116
|
-
* @param [opts]
|
|
117
|
-
* @returns If opts.ensureNoContext is true, returns a SequenceExpression,
|
|
118
|
-
* else if opts.ensureLiveReference is true, returns a MemberExpression, else returns an Identifier
|
|
119
|
-
*/
|
|
120
|
-
declare export const addNamed: (
|
|
121
|
-
path: NodePath<>,
|
|
122
|
-
name: string,
|
|
123
|
-
importedSource: string,
|
|
124
|
-
opts?: Omit<
|
|
125
|
-
Partial<ImportOptions>,
|
|
126
|
-
'ensureLiveReference' | 'ensureNoContext',
|
|
127
|
-
>,
|
|
128
|
-
) => t.Identifier;
|
|
129
|
-
|
|
130
|
-
// declare export function addNamed(
|
|
131
|
-
// path: NodePath<>,
|
|
132
|
-
// name: string,
|
|
133
|
-
// importedSource: string,
|
|
134
|
-
// opts?: Omit<Partial<ImportOptions>, "ensureLiveReference"> & {
|
|
135
|
-
// ensureLiveReference: true;
|
|
136
|
-
// },
|
|
137
|
-
// ): t.MemberExpression;
|
|
138
|
-
// declare export function addNamed(
|
|
139
|
-
// path: NodePath,
|
|
140
|
-
// name: string,
|
|
141
|
-
// importedSource: string,
|
|
142
|
-
// opts?: Omit<Partial<ImportOptions>, "ensureNoContext"> & {
|
|
143
|
-
// ensureNoContext: true;
|
|
144
|
-
// },
|
|
145
|
-
// ): t.SequenceExpression;
|
|
146
|
-
|
|
147
|
-
declare export function addNamespace(
|
|
148
|
-
path: NodePath<>,
|
|
149
|
-
importedSource: string,
|
|
150
|
-
opts?: Partial<ImportOptions>,
|
|
151
|
-
): t.Identifier;
|
|
152
|
-
|
|
153
|
-
// declare export function addSideEffect(
|
|
154
|
-
// path: NodePath<>,
|
|
155
|
-
// importedSource: string,
|
|
156
|
-
// opts?: Partial<ImportOptions>,
|
|
157
|
-
// ): void;
|
|
158
|
-
|
|
159
|
-
declare export function isModule(path: NodePath<t.Program>): boolean;
|
|
160
|
-
|
|
161
|
-
// declare export class ImportInjector {
|
|
162
|
-
// constructor(
|
|
163
|
-
// path: NodePath<>,
|
|
164
|
-
// importedSource?: string,
|
|
165
|
-
// opts?: Partial<ImportOptions>,
|
|
166
|
-
// ): ImportInjector;
|
|
167
|
-
|
|
168
|
-
// addDefault(
|
|
169
|
-
// importedSourceIn: string,
|
|
170
|
-
// opts: Partial<ImportOptions>,
|
|
171
|
-
// ): t.Identifier;
|
|
172
|
-
// addNamed(
|
|
173
|
-
// importName: string,
|
|
174
|
-
// importedSourceIn: string,
|
|
175
|
-
// opts: Partial<ImportOptions>,
|
|
176
|
-
// ): t.Identifier;
|
|
177
|
-
// addNamespace(
|
|
178
|
-
// importedSourceIn: string,
|
|
179
|
-
// opts: Partial<ImportOptions>,
|
|
180
|
-
// ): t.Identifier;
|
|
181
|
-
// addSideEffect(importedSourceIn: string, opts: Partial<ImportOptions>): void;
|
|
182
|
-
// }
|
|
@@ -1,253 +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
|
-
* @flow strict
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as t from '../types';
|
|
10
|
-
|
|
11
|
-
type Plugin =
|
|
12
|
-
| 'asyncDoExpressions'
|
|
13
|
-
| 'asyncGenerators'
|
|
14
|
-
| 'bigInt'
|
|
15
|
-
| 'classPrivateMethods'
|
|
16
|
-
| 'classPrivateProperties'
|
|
17
|
-
| 'classProperties'
|
|
18
|
-
| 'classStaticBlock' // Enabled by default
|
|
19
|
-
| 'decimal'
|
|
20
|
-
| 'decorators-legacy'
|
|
21
|
-
| 'decoratorAutoAccessors'
|
|
22
|
-
| 'destructuringPrivate'
|
|
23
|
-
| 'doExpressions'
|
|
24
|
-
| 'dynamicImport'
|
|
25
|
-
| 'explicitResourceManagement'
|
|
26
|
-
| 'exportDefaultFrom'
|
|
27
|
-
| 'exportNamespaceFrom' // deprecated
|
|
28
|
-
| 'flow'
|
|
29
|
-
| 'flowComments'
|
|
30
|
-
| 'functionBind'
|
|
31
|
-
| 'functionSent'
|
|
32
|
-
| 'importMeta'
|
|
33
|
-
| 'jsx'
|
|
34
|
-
| 'logicalAssignment'
|
|
35
|
-
| 'importAssertions' // deprecated
|
|
36
|
-
| 'importAttributes'
|
|
37
|
-
| 'importReflection'
|
|
38
|
-
| 'moduleBlocks'
|
|
39
|
-
| 'moduleStringNames'
|
|
40
|
-
| 'nullishCoalescingOperator'
|
|
41
|
-
| 'numericSeparator'
|
|
42
|
-
| 'objectRestSpread'
|
|
43
|
-
| 'optionalCatchBinding'
|
|
44
|
-
| 'optionalChaining'
|
|
45
|
-
| 'partialApplication'
|
|
46
|
-
| 'placeholders'
|
|
47
|
-
| 'privateIn' // Enabled by default
|
|
48
|
-
| 'regexpUnicodeSets' // Enabled by default
|
|
49
|
-
| 'throwExpressions'
|
|
50
|
-
| 'topLevelAwait'
|
|
51
|
-
| 'v8intrinsic'
|
|
52
|
-
| 'decorators'
|
|
53
|
-
| 'estree'
|
|
54
|
-
| 'importAttributes'
|
|
55
|
-
| 'moduleAttributes'
|
|
56
|
-
| 'pipelineOperator'
|
|
57
|
-
| 'recordAndTuple'
|
|
58
|
-
| 'flow'
|
|
59
|
-
| 'typescript';
|
|
60
|
-
|
|
61
|
-
export type ParserPluginWithOptions =
|
|
62
|
-
| ['decorators', DecoratorsPluginOptions]
|
|
63
|
-
| ['estree', { classFeatures?: boolean }]
|
|
64
|
-
| ['importAttributes', { deprecatedAssertSyntax: boolean }]
|
|
65
|
-
// // @deprecated
|
|
66
|
-
// | ["moduleAttributes", { version: "may-2020" }]
|
|
67
|
-
| ['pipelineOperator', PipelineOperatorPluginOptions]
|
|
68
|
-
| ['recordAndTuple', RecordAndTuplePluginOptions]
|
|
69
|
-
| ['flow', FlowPluginOptions]
|
|
70
|
-
| ['typescript', TypeScriptPluginOptions];
|
|
71
|
-
|
|
72
|
-
type PluginConfig = Plugin | ParserPluginWithOptions;
|
|
73
|
-
|
|
74
|
-
export interface DecoratorsPluginOptions {
|
|
75
|
-
decoratorsBeforeExport?: boolean;
|
|
76
|
-
allowCallParenthesized?: boolean;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface PipelineOperatorPluginOptions {
|
|
80
|
-
proposal: 'minimal' | 'fsharp' | 'hack' | 'smart';
|
|
81
|
-
topicToken?: '%' | '#' | '@@' | '^^' | '^';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface RecordAndTuplePluginOptions {
|
|
85
|
-
syntaxType: 'bar' | 'hash';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface FlowPluginOptions {
|
|
89
|
-
all?: boolean;
|
|
90
|
-
enums?: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface TypeScriptPluginOptions {
|
|
94
|
-
dts?: boolean;
|
|
95
|
-
disallowAmbiguousJSXLike?: boolean;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Type definitions for @babel/parser
|
|
99
|
-
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
|
100
|
-
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
|
101
|
-
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
|
102
|
-
// Avi Vahl <https://github.com/AviVahl>
|
|
103
|
-
// TypeScript Version: 2.9
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Parse the provided code as an entire ECMAScript program.
|
|
107
|
-
*/
|
|
108
|
-
declare export function parse(
|
|
109
|
-
input: string,
|
|
110
|
-
options?: ParserOptions,
|
|
111
|
-
): ParseResult<t.File>;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Parse the provided code as a single expression.
|
|
115
|
-
*/
|
|
116
|
-
declare export function parseExpression(
|
|
117
|
-
input: string,
|
|
118
|
-
options?: ParserOptions,
|
|
119
|
-
): ParseResult<t.Expression>;
|
|
120
|
-
|
|
121
|
-
export interface ParserOptions {
|
|
122
|
-
/**
|
|
123
|
-
* By default, import and export declarations can only appear at a program's top level.
|
|
124
|
-
* Setting this option to true allows them anywhere where a statement is allowed.
|
|
125
|
-
*/
|
|
126
|
-
allowImportExportEverywhere?: boolean;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* By default, await use is not allowed outside of an async function.
|
|
130
|
-
* Set this to true to accept such code.
|
|
131
|
-
*/
|
|
132
|
-
allowAwaitOutsideFunction?: boolean;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* By default, a return statement at the top level raises an error.
|
|
136
|
-
* Set this to true to accept such code.
|
|
137
|
-
*/
|
|
138
|
-
allowReturnOutsideFunction?: boolean;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* By default, new.target use is not allowed outside of a function or class.
|
|
142
|
-
* Set this to true to accept such code.
|
|
143
|
-
*/
|
|
144
|
-
allowNewTargetOutsideFunction?: boolean;
|
|
145
|
-
|
|
146
|
-
allowSuperOutsideMethod?: boolean;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* By default, exported identifiers must refer to a declared variable.
|
|
150
|
-
* Set this to true to allow export statements to reference undeclared variables.
|
|
151
|
-
*/
|
|
152
|
-
allowUndeclaredExports?: boolean;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* By default, Babel parser JavaScript code according to Annex B syntax.
|
|
156
|
-
* Set this to `false` to disable such behavior.
|
|
157
|
-
*/
|
|
158
|
-
annexB?: boolean;
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* By default, Babel attaches comments to adjacent AST nodes.
|
|
162
|
-
* When this option is set to false, comments are not attached.
|
|
163
|
-
* It can provide up to 30% performance improvement when the input code has many comments.
|
|
164
|
-
* @babel/eslint-parser will set it for you.
|
|
165
|
-
* It is not recommended to use attachComment: false with Babel transform,
|
|
166
|
-
* as doing so removes all the comments in output code, and renders annotations such as
|
|
167
|
-
* /* istanbul ignore next *\/ nonfunctional.
|
|
168
|
-
*/
|
|
169
|
-
attachComment?: boolean;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* By default, Babel always throws an error when it finds some invalid code.
|
|
173
|
-
* When this option is set to true, it will store the parsing error and
|
|
174
|
-
* try to continue parsing the invalid input file.
|
|
175
|
-
*/
|
|
176
|
-
errorRecovery?: boolean;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Indicate the mode the code should be parsed in.
|
|
180
|
-
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
|
|
181
|
-
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
|
182
|
-
* of ES6 import or export statements.
|
|
183
|
-
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
|
184
|
-
*/
|
|
185
|
-
sourceType?: 'script' | 'module' | 'unambiguous';
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Correlate output AST nodes with their source filename.
|
|
189
|
-
* Useful when generating code and source maps from the ASTs of multiple input files.
|
|
190
|
-
*/
|
|
191
|
-
sourceFilename?: string;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* By default, the first line of code parsed is treated as line 1.
|
|
195
|
-
* You can provide a line number to alternatively start with.
|
|
196
|
-
* Useful for integration with other source tools.
|
|
197
|
-
*/
|
|
198
|
-
startLine?: number;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* By default, the parsed code is treated as if it starts from line 1, column 0.
|
|
202
|
-
* You can provide a column number to alternatively start with.
|
|
203
|
-
* Useful for integration with other source tools.
|
|
204
|
-
*/
|
|
205
|
-
startColumn?: number;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Array containing the plugins that you want to enable.
|
|
209
|
-
*/
|
|
210
|
-
plugins?: ParserPlugin[];
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Should the parser work in strict mode.
|
|
214
|
-
* Defaults to true if sourceType === 'module'. Otherwise, false.
|
|
215
|
-
*/
|
|
216
|
-
strictMode?: boolean;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Adds a ranges property to each node: [node.start, node.end]
|
|
220
|
-
*/
|
|
221
|
-
ranges?: boolean;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Adds all parsed tokens to a tokens property on the File node.
|
|
225
|
-
*/
|
|
226
|
-
tokens?: boolean;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* By default, the parser adds information about parentheses by setting
|
|
230
|
-
* `extra.parenthesized` to `true` as needed.
|
|
231
|
-
* When this option is `true` the parser creates `ParenthesizedExpression`
|
|
232
|
-
* AST nodes instead of using the `extra` property.
|
|
233
|
-
*/
|
|
234
|
-
createParenthesizedExpressions?: boolean;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export type ParserPlugin = PluginConfig;
|
|
238
|
-
|
|
239
|
-
declare export var tokTypes: {
|
|
240
|
-
// todo(flow->ts) real token type
|
|
241
|
-
[name: string]: any,
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type ParseError = {
|
|
245
|
-
code: string,
|
|
246
|
-
reasonCode: string,
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export type ParseResult<Result: t.Node = t.Node> =
|
|
250
|
-
| Result
|
|
251
|
-
| {
|
|
252
|
-
+errors: $ReadOnlyArray<ParseError>,
|
|
253
|
-
};
|