@vue/compiler-core 3.6.0-beta.1 → 3.6.0-beta.11
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/dist/compiler-core.cjs.js +4900 -6398
- package/dist/compiler-core.cjs.prod.js +4846 -6275
- package/dist/compiler-core.d.ts +860 -810
- package/dist/compiler-core.esm-bundler.js +3905 -5519
- package/package.json +5 -5
package/dist/compiler-core.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Namespace, PatchFlags,
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { ParserPlugin } from '@babel/parser';
|
|
1
|
+
import { Namespace, Namespaces, PatchFlags, generateCodeFrame } from "@vue/shared";
|
|
2
|
+
import { BlockStatement as BlockStatement$1, Function, Identifier, Node as Node$1, ObjectProperty, Program, SwitchCase } from "@babel/types";
|
|
3
|
+
import { ParserPlugin } from "@babel/parser";
|
|
5
4
|
|
|
5
|
+
//#region temp/packages/compiler-core/src/runtimeHelpers.d.ts
|
|
6
6
|
export declare const FRAGMENT: unique symbol;
|
|
7
7
|
export declare const TELEPORT: unique symbol;
|
|
8
8
|
export declare const SUSPENSE: unique symbol;
|
|
@@ -36,13 +36,13 @@ export declare const CAPITALIZE: unique symbol;
|
|
|
36
36
|
export declare const TO_HANDLER_KEY: unique symbol;
|
|
37
37
|
export declare const SET_BLOCK_TRACKING: unique symbol;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* @deprecated no longer needed in 3.5+ because we no longer hoist element nodes
|
|
40
|
+
* but kept for backwards compat
|
|
41
|
+
*/
|
|
42
42
|
export declare const PUSH_SCOPE_ID: unique symbol;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* @deprecated kept for backwards compat
|
|
45
|
+
*/
|
|
46
46
|
export declare const POP_SCOPE_ID: unique symbol;
|
|
47
47
|
export declare const WITH_CTX: unique symbol;
|
|
48
48
|
export declare const UNREF: unique symbol;
|
|
@@ -51,1008 +51,1042 @@ export declare const WITH_MEMO: unique symbol;
|
|
|
51
51
|
export declare const IS_MEMO_SAME: unique symbol;
|
|
52
52
|
export declare const helperNameMap: Record<symbol, string>;
|
|
53
53
|
export declare function registerRuntimeHelpers(helpers: Record<symbol, string>): void;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region temp/packages/compiler-core/src/parser.d.ts
|
|
56
|
+
type OptionalOptions = "decodeEntities" | "whitespace" | "isNativeTag" | "isBuiltInComponent" | "expressionPlugins" | keyof CompilerCompatOptions;
|
|
56
57
|
type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> & Pick<ParserOptions, OptionalOptions>;
|
|
57
58
|
export declare function baseParse(input: string, options?: ParserOptions): RootNode;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region temp/packages/compiler-core/src/compat/compatConfig.d.ts
|
|
61
|
+
type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | "suppress-warning">> & {
|
|
62
|
+
MODE?: 2 | 3;
|
|
61
63
|
};
|
|
62
64
|
export interface CompilerCompatOptions {
|
|
63
|
-
|
|
65
|
+
compatConfig?: CompilerCompatConfig;
|
|
64
66
|
}
|
|
65
67
|
export declare enum CompilerDeprecationTypes {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
COMPILER_IS_ON_ELEMENT = "COMPILER_IS_ON_ELEMENT",
|
|
69
|
+
COMPILER_V_BIND_SYNC = "COMPILER_V_BIND_SYNC",
|
|
70
|
+
COMPILER_V_BIND_OBJECT_ORDER = "COMPILER_V_BIND_OBJECT_ORDER",
|
|
71
|
+
COMPILER_V_ON_NATIVE = "COMPILER_V_ON_NATIVE",
|
|
72
|
+
COMPILER_V_IF_V_FOR_PRECEDENCE = "COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
73
|
+
COMPILER_NATIVE_TEMPLATE = "COMPILER_NATIVE_TEMPLATE",
|
|
74
|
+
COMPILER_INLINE_TEMPLATE = "COMPILER_INLINE_TEMPLATE",
|
|
75
|
+
COMPILER_FILTERS = "COMPILER_FILTERS"
|
|
74
76
|
}
|
|
75
77
|
export declare function checkCompatEnabled(key: CompilerDeprecationTypes, context: MergedParserOptions | TransformContext, loc: SourceLocation | null, ...args: any[]): boolean;
|
|
76
78
|
export declare function warnDeprecation(key: CompilerDeprecationTypes, context: MergedParserOptions | TransformContext, loc: SourceLocation | null, ...args: any[]): void;
|
|
77
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region temp/packages/compiler-core/src/transform.d.ts
|
|
78
81
|
export type NodeTransform = (node: RootNode | TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[];
|
|
79
82
|
export type DirectiveTransform = (dir: DirectiveNode, node: ElementNode, context: TransformContext, augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult) => DirectiveTransformResult;
|
|
80
83
|
interface DirectiveTransformResult {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
props: Property[];
|
|
85
|
+
needRuntime?: boolean | symbol;
|
|
86
|
+
ssrTagParts?: TemplateLiteral["elements"];
|
|
84
87
|
}
|
|
85
88
|
export type StructuralDirectiveTransform = (node: ElementNode, dir: DirectiveNode, context: TransformContext) => void | (() => void);
|
|
86
89
|
export interface ImportItem {
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
exp: SimpleExpressionNode;
|
|
91
|
+
path: string;
|
|
89
92
|
}
|
|
93
|
+
type IdentifierScopeType = "local" | "slot";
|
|
90
94
|
export interface TransformContext extends Required<Omit<TransformOptions, keyof CompilerCompatOptions>>, CompilerCompatOptions {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
95
|
+
selfName: string | null;
|
|
96
|
+
root: RootNode;
|
|
97
|
+
helpers: Map<symbol, number>;
|
|
98
|
+
components: Set<string>;
|
|
99
|
+
directives: Set<string>;
|
|
100
|
+
hoists: (JSChildNode | null)[];
|
|
101
|
+
imports: ImportItem[];
|
|
102
|
+
temps: number;
|
|
103
|
+
cached: (CacheExpression | null)[];
|
|
104
|
+
identifiers: {
|
|
105
|
+
[name: string]: number | undefined;
|
|
106
|
+
};
|
|
107
|
+
identifierScopes: {
|
|
108
|
+
[name: string]: IdentifierScopeType[] | undefined;
|
|
109
|
+
};
|
|
110
|
+
scopes: {
|
|
111
|
+
vFor: number;
|
|
112
|
+
vSlot: number;
|
|
113
|
+
vPre: number;
|
|
114
|
+
vOnce: number;
|
|
115
|
+
};
|
|
116
|
+
parent: ParentNode | null;
|
|
117
|
+
grandParent: ParentNode | null;
|
|
118
|
+
childIndex: number;
|
|
119
|
+
currentNode: RootNode | TemplateChildNode | null;
|
|
120
|
+
inVOnce: boolean;
|
|
121
|
+
helper<T extends symbol>(name: T): T;
|
|
122
|
+
removeHelper<T extends symbol>(name: T): void;
|
|
123
|
+
helperString(name: symbol): string;
|
|
124
|
+
replaceNode(node: TemplateChildNode): void;
|
|
125
|
+
removeNode(node?: TemplateChildNode): void;
|
|
126
|
+
onNodeRemoved(): void;
|
|
127
|
+
addIdentifiers(exp: ExpressionNode | string, type?: IdentifierScopeType): void;
|
|
128
|
+
removeIdentifiers(exp: ExpressionNode | string): void;
|
|
129
|
+
isSlotScopeIdentifier(name: string): boolean;
|
|
130
|
+
hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
|
|
131
|
+
cache(exp: JSChildNode, isVNode?: boolean, inVOnce?: boolean): CacheExpression;
|
|
132
|
+
constantCache: WeakMap<TemplateChildNode, ConstantTypes>;
|
|
133
|
+
filters?: Set<string>;
|
|
126
134
|
}
|
|
127
135
|
export declare function getSelfName(filename: string): string | null;
|
|
128
|
-
export declare function createTransformContext(root: RootNode, {
|
|
136
|
+
export declare function createTransformContext(root: RootNode, {
|
|
137
|
+
filename,
|
|
138
|
+
prefixIdentifiers,
|
|
139
|
+
hoistStatic,
|
|
140
|
+
hmr,
|
|
141
|
+
cacheHandlers,
|
|
142
|
+
nodeTransforms,
|
|
143
|
+
directiveTransforms,
|
|
144
|
+
transformHoist,
|
|
145
|
+
isBuiltInComponent,
|
|
146
|
+
isCustomElement,
|
|
147
|
+
expressionPlugins,
|
|
148
|
+
scopeId,
|
|
149
|
+
slotted,
|
|
150
|
+
ssr,
|
|
151
|
+
inSSR,
|
|
152
|
+
ssrCssVars,
|
|
153
|
+
bindingMetadata,
|
|
154
|
+
inline,
|
|
155
|
+
isTS,
|
|
156
|
+
onError,
|
|
157
|
+
onWarn,
|
|
158
|
+
compatConfig
|
|
159
|
+
}: TransformOptions): TransformContext;
|
|
129
160
|
export declare function transform(root: RootNode, options: TransformOptions): void;
|
|
130
161
|
export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
|
|
131
162
|
export declare function createStructuralDirectiveTransform(name: string | RegExp, fn: StructuralDirectiveTransform): NodeTransform;
|
|
132
|
-
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region temp/packages/compiler-core/src/transforms/transformElement.d.ts
|
|
133
165
|
export declare const transformElement: NodeTransform;
|
|
134
166
|
export declare function resolveComponentType(node: ComponentNode, context: TransformContext, ssr?: boolean): string | symbol | CallExpression;
|
|
135
167
|
export type PropsExpression = ObjectExpression | CallExpression | ExpressionNode;
|
|
136
|
-
export declare function buildProps(node: ElementNode, context: TransformContext, props: ElementNode[
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
export declare function buildProps(node: ElementNode, context: TransformContext, props: ElementNode["props"] | undefined, isComponent: boolean, isDynamicComponent: boolean, ssr?: boolean): {
|
|
169
|
+
props: PropsExpression | undefined;
|
|
170
|
+
directives: DirectiveNode[];
|
|
171
|
+
patchFlag: number;
|
|
172
|
+
dynamicPropNames: string[];
|
|
173
|
+
shouldUseBlock: boolean;
|
|
142
174
|
};
|
|
143
175
|
export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
|
|
144
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region temp/packages/compiler-core/src/ast.d.ts
|
|
145
178
|
export declare enum NodeTypes {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
179
|
+
ROOT = 0,
|
|
180
|
+
ELEMENT = 1,
|
|
181
|
+
TEXT = 2,
|
|
182
|
+
COMMENT = 3,
|
|
183
|
+
SIMPLE_EXPRESSION = 4,
|
|
184
|
+
INTERPOLATION = 5,
|
|
185
|
+
ATTRIBUTE = 6,
|
|
186
|
+
DIRECTIVE = 7,
|
|
187
|
+
COMPOUND_EXPRESSION = 8,
|
|
188
|
+
IF = 9,
|
|
189
|
+
IF_BRANCH = 10,
|
|
190
|
+
FOR = 11,
|
|
191
|
+
TEXT_CALL = 12,
|
|
192
|
+
VNODE_CALL = 13,
|
|
193
|
+
JS_CALL_EXPRESSION = 14,
|
|
194
|
+
JS_OBJECT_EXPRESSION = 15,
|
|
195
|
+
JS_PROPERTY = 16,
|
|
196
|
+
JS_ARRAY_EXPRESSION = 17,
|
|
197
|
+
JS_FUNCTION_EXPRESSION = 18,
|
|
198
|
+
JS_CONDITIONAL_EXPRESSION = 19,
|
|
199
|
+
JS_CACHE_EXPRESSION = 20,
|
|
200
|
+
JS_BLOCK_STATEMENT = 21,
|
|
201
|
+
JS_TEMPLATE_LITERAL = 22,
|
|
202
|
+
JS_IF_STATEMENT = 23,
|
|
203
|
+
JS_ASSIGNMENT_EXPRESSION = 24,
|
|
204
|
+
JS_SEQUENCE_EXPRESSION = 25,
|
|
205
|
+
JS_RETURN_STATEMENT = 26
|
|
173
206
|
}
|
|
174
207
|
export declare enum ElementTypes {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
208
|
+
ELEMENT = 0,
|
|
209
|
+
COMPONENT = 1,
|
|
210
|
+
SLOT = 2,
|
|
211
|
+
TEMPLATE = 3
|
|
179
212
|
}
|
|
180
213
|
export interface Node {
|
|
181
|
-
|
|
182
|
-
|
|
214
|
+
type: NodeTypes;
|
|
215
|
+
loc: SourceLocation;
|
|
183
216
|
}
|
|
184
217
|
export interface SourceLocation {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
218
|
+
start: Position;
|
|
219
|
+
end: Position;
|
|
220
|
+
source: string;
|
|
188
221
|
}
|
|
189
222
|
export interface Position {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
223
|
+
offset: number;
|
|
224
|
+
line: number;
|
|
225
|
+
column: number;
|
|
193
226
|
}
|
|
194
227
|
export type AllNode = ParentNode | ExpressionNode | TemplateChildNode | AttributeNode | DirectiveNode;
|
|
195
228
|
export type ParentNode = RootNode | ElementNode | IfBranchNode | ForNode;
|
|
196
229
|
export type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode;
|
|
197
230
|
export type TemplateChildNode = ElementNode | InterpolationNode | CompoundExpressionNode | TextNode | CommentNode | IfNode | IfBranchNode | ForNode | TextCallNode;
|
|
198
231
|
export interface RootNode extends Node {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
232
|
+
type: NodeTypes.ROOT;
|
|
233
|
+
source: string;
|
|
234
|
+
children: TemplateChildNode[];
|
|
235
|
+
helpers: Set<symbol>;
|
|
236
|
+
components: string[];
|
|
237
|
+
directives: string[];
|
|
238
|
+
hoists: (JSChildNode | null)[];
|
|
239
|
+
imports: ImportItem[];
|
|
240
|
+
cached: (CacheExpression | null)[];
|
|
241
|
+
temps: number;
|
|
242
|
+
ssrHelpers?: symbol[];
|
|
243
|
+
codegenNode?: TemplateChildNode | JSChildNode | BlockStatement;
|
|
244
|
+
transformed?: boolean;
|
|
245
|
+
filters?: string[];
|
|
213
246
|
}
|
|
214
247
|
export type ElementNode = PlainElementNode | ComponentNode | SlotOutletNode | TemplateNode;
|
|
215
248
|
export interface BaseElementNode extends Node {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
249
|
+
type: NodeTypes.ELEMENT;
|
|
250
|
+
ns: Namespace;
|
|
251
|
+
tag: string;
|
|
252
|
+
tagType: ElementTypes;
|
|
253
|
+
props: Array<AttributeNode | DirectiveNode>;
|
|
254
|
+
children: TemplateChildNode[];
|
|
255
|
+
isSelfClosing?: boolean;
|
|
256
|
+
innerLoc?: SourceLocation;
|
|
224
257
|
}
|
|
225
258
|
export interface PlainElementNode extends BaseElementNode {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
259
|
+
tagType: ElementTypes.ELEMENT;
|
|
260
|
+
codegenNode: VNodeCall | SimpleExpressionNode | CacheExpression | MemoExpression | undefined;
|
|
261
|
+
ssrCodegenNode?: TemplateLiteral;
|
|
229
262
|
}
|
|
230
263
|
export interface ComponentNode extends BaseElementNode {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
264
|
+
tagType: ElementTypes.COMPONENT;
|
|
265
|
+
codegenNode: VNodeCall | CacheExpression | MemoExpression | undefined;
|
|
266
|
+
ssrCodegenNode?: CallExpression;
|
|
234
267
|
}
|
|
235
268
|
export interface SlotOutletNode extends BaseElementNode {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
269
|
+
tagType: ElementTypes.SLOT;
|
|
270
|
+
codegenNode: RenderSlotCall | CacheExpression | undefined;
|
|
271
|
+
ssrCodegenNode?: CallExpression;
|
|
239
272
|
}
|
|
240
273
|
export interface TemplateNode extends BaseElementNode {
|
|
241
|
-
|
|
242
|
-
|
|
274
|
+
tagType: ElementTypes.TEMPLATE;
|
|
275
|
+
codegenNode: undefined;
|
|
243
276
|
}
|
|
244
277
|
export interface TextNode extends Node {
|
|
245
|
-
|
|
246
|
-
|
|
278
|
+
type: NodeTypes.TEXT;
|
|
279
|
+
content: string;
|
|
247
280
|
}
|
|
248
281
|
export interface CommentNode extends Node {
|
|
249
|
-
|
|
250
|
-
|
|
282
|
+
type: NodeTypes.COMMENT;
|
|
283
|
+
content: string;
|
|
251
284
|
}
|
|
252
285
|
export interface AttributeNode extends Node {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
286
|
+
type: NodeTypes.ATTRIBUTE;
|
|
287
|
+
name: string;
|
|
288
|
+
nameLoc: SourceLocation;
|
|
289
|
+
value: TextNode | undefined;
|
|
257
290
|
}
|
|
258
291
|
export interface DirectiveNode extends Node {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
292
|
+
type: NodeTypes.DIRECTIVE;
|
|
293
|
+
/**
|
|
294
|
+
* the normalized name without prefix or shorthands, e.g. "bind", "on"
|
|
295
|
+
*/
|
|
296
|
+
name: string;
|
|
297
|
+
/**
|
|
298
|
+
* the raw attribute name, preserving shorthand, and including arg & modifiers
|
|
299
|
+
* this is only used during parse.
|
|
300
|
+
*/
|
|
301
|
+
rawName?: string;
|
|
302
|
+
exp: ExpressionNode | undefined;
|
|
303
|
+
arg: ExpressionNode | undefined;
|
|
304
|
+
modifiers: SimpleExpressionNode[];
|
|
305
|
+
/**
|
|
306
|
+
* optional property to cache the expression parse result for v-for
|
|
307
|
+
*/
|
|
308
|
+
forParseResult?: ForParseResult;
|
|
276
309
|
}
|
|
277
310
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
311
|
+
* Static types have several levels.
|
|
312
|
+
* Higher levels implies lower levels. e.g. a node that can be stringified
|
|
313
|
+
* can always be hoisted and skipped for patch.
|
|
314
|
+
*/
|
|
282
315
|
export declare enum ConstantTypes {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
316
|
+
NOT_CONSTANT = 0,
|
|
317
|
+
CAN_SKIP_PATCH = 1,
|
|
318
|
+
CAN_CACHE = 2,
|
|
319
|
+
CAN_STRINGIFY = 3
|
|
287
320
|
}
|
|
288
321
|
export interface SimpleExpressionNode extends Node {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
322
|
+
type: NodeTypes.SIMPLE_EXPRESSION;
|
|
323
|
+
content: string;
|
|
324
|
+
isStatic: boolean;
|
|
325
|
+
constType: ConstantTypes;
|
|
326
|
+
/**
|
|
327
|
+
* - `null` means the expression is a simple identifier that doesn't need
|
|
328
|
+
* parsing
|
|
329
|
+
* - `false` means there was a parsing error
|
|
330
|
+
*/
|
|
331
|
+
ast?: Node$1 | null | false;
|
|
332
|
+
/**
|
|
333
|
+
* Indicates this is an identifier for a hoist vnode call and points to the
|
|
334
|
+
* hoisted node.
|
|
335
|
+
*/
|
|
336
|
+
hoisted?: JSChildNode;
|
|
337
|
+
/**
|
|
338
|
+
* an expression parsed as the params of a function will track
|
|
339
|
+
* the identifiers declared inside the function body.
|
|
340
|
+
*/
|
|
341
|
+
identifiers?: string[];
|
|
342
|
+
isHandlerKey?: boolean;
|
|
310
343
|
}
|
|
311
344
|
export interface InterpolationNode extends Node {
|
|
312
|
-
|
|
313
|
-
|
|
345
|
+
type: NodeTypes.INTERPOLATION;
|
|
346
|
+
content: ExpressionNode;
|
|
314
347
|
}
|
|
315
348
|
export interface CompoundExpressionNode extends Node {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
349
|
+
type: NodeTypes.COMPOUND_EXPRESSION;
|
|
350
|
+
/**
|
|
351
|
+
* - `null` means the expression is a simple identifier that doesn't need
|
|
352
|
+
* parsing
|
|
353
|
+
* - `false` means there was a parsing error
|
|
354
|
+
*/
|
|
355
|
+
ast?: Node$1 | null | false;
|
|
356
|
+
children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string | symbol)[];
|
|
357
|
+
/**
|
|
358
|
+
* an expression parsed as the params of a function will track
|
|
359
|
+
* the identifiers declared inside the function body.
|
|
360
|
+
*/
|
|
361
|
+
identifiers?: string[];
|
|
362
|
+
isHandlerKey?: boolean;
|
|
330
363
|
}
|
|
331
364
|
export interface IfNode extends Node {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
365
|
+
type: NodeTypes.IF;
|
|
366
|
+
branches: IfBranchNode[];
|
|
367
|
+
codegenNode?: IfConditionalExpression | CacheExpression;
|
|
335
368
|
}
|
|
336
369
|
export interface IfBranchNode extends Node {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
370
|
+
type: NodeTypes.IF_BRANCH;
|
|
371
|
+
condition: ExpressionNode | undefined;
|
|
372
|
+
children: TemplateChildNode[];
|
|
373
|
+
userKey?: AttributeNode | DirectiveNode;
|
|
374
|
+
isTemplateIf?: boolean;
|
|
342
375
|
}
|
|
343
376
|
export interface ForNode extends Node {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
377
|
+
type: NodeTypes.FOR;
|
|
378
|
+
source: ExpressionNode;
|
|
379
|
+
valueAlias: ExpressionNode | undefined;
|
|
380
|
+
keyAlias: ExpressionNode | undefined;
|
|
381
|
+
objectIndexAlias: ExpressionNode | undefined;
|
|
382
|
+
parseResult: ForParseResult;
|
|
383
|
+
children: TemplateChildNode[];
|
|
384
|
+
codegenNode?: ForCodegenNode;
|
|
352
385
|
}
|
|
353
386
|
export interface ForParseResult {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
387
|
+
source: ExpressionNode;
|
|
388
|
+
value: ExpressionNode | undefined;
|
|
389
|
+
key: ExpressionNode | undefined;
|
|
390
|
+
index: ExpressionNode | undefined;
|
|
391
|
+
finalized: boolean;
|
|
359
392
|
}
|
|
360
393
|
export interface TextCallNode extends Node {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
394
|
+
type: NodeTypes.TEXT_CALL;
|
|
395
|
+
content: TextNode | InterpolationNode | CompoundExpressionNode;
|
|
396
|
+
codegenNode: CallExpression | SimpleExpressionNode;
|
|
364
397
|
}
|
|
365
398
|
export type TemplateTextChildNode = TextNode | InterpolationNode | CompoundExpressionNode;
|
|
366
399
|
export interface VNodeCall extends Node {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
400
|
+
type: NodeTypes.VNODE_CALL;
|
|
401
|
+
tag: string | symbol | CallExpression;
|
|
402
|
+
props: PropsExpression | undefined;
|
|
403
|
+
children: TemplateChildNode[] | TemplateTextChildNode | SlotsExpression | ForRenderListExpression | SimpleExpressionNode | CacheExpression | undefined;
|
|
404
|
+
patchFlag: PatchFlags | undefined;
|
|
405
|
+
dynamicProps: string | SimpleExpressionNode | undefined;
|
|
406
|
+
directives: DirectiveArguments | undefined;
|
|
407
|
+
isBlock: boolean;
|
|
408
|
+
disableTracking: boolean;
|
|
409
|
+
isComponent: boolean;
|
|
377
410
|
}
|
|
378
411
|
export type JSChildNode = VNodeCall | CallExpression | ObjectExpression | ArrayExpression | ExpressionNode | FunctionExpression | ConditionalExpression | CacheExpression | AssignmentExpression | SequenceExpression;
|
|
379
412
|
export interface CallExpression extends Node {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
413
|
+
type: NodeTypes.JS_CALL_EXPRESSION;
|
|
414
|
+
callee: string | symbol;
|
|
415
|
+
arguments: (string | symbol | JSChildNode | SSRCodegenNode | TemplateChildNode | TemplateChildNode[])[];
|
|
383
416
|
}
|
|
384
417
|
export interface ObjectExpression extends Node {
|
|
385
|
-
|
|
386
|
-
|
|
418
|
+
type: NodeTypes.JS_OBJECT_EXPRESSION;
|
|
419
|
+
properties: Array<Property>;
|
|
387
420
|
}
|
|
388
421
|
export interface Property extends Node {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
422
|
+
type: NodeTypes.JS_PROPERTY;
|
|
423
|
+
key: ExpressionNode;
|
|
424
|
+
value: JSChildNode;
|
|
392
425
|
}
|
|
393
426
|
export interface ArrayExpression extends Node {
|
|
394
|
-
|
|
395
|
-
|
|
427
|
+
type: NodeTypes.JS_ARRAY_EXPRESSION;
|
|
428
|
+
elements: Array<string | Node>;
|
|
396
429
|
}
|
|
397
430
|
export interface FunctionExpression extends Node {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
431
|
+
type: NodeTypes.JS_FUNCTION_EXPRESSION;
|
|
432
|
+
params: ExpressionNode | string | (ExpressionNode | string)[] | undefined;
|
|
433
|
+
returns?: TemplateChildNode | TemplateChildNode[] | JSChildNode;
|
|
434
|
+
body?: BlockStatement | IfStatement;
|
|
435
|
+
newline: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* This flag is for codegen to determine whether it needs to generate the
|
|
438
|
+
* withScopeId() wrapper
|
|
439
|
+
*/
|
|
440
|
+
isSlot: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* __COMPAT__ only, indicates a slot function that should be excluded from
|
|
443
|
+
* the legacy $scopedSlots instance property.
|
|
444
|
+
*/
|
|
445
|
+
isNonScopedSlot?: boolean;
|
|
413
446
|
}
|
|
414
447
|
export interface ConditionalExpression extends Node {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
448
|
+
type: NodeTypes.JS_CONDITIONAL_EXPRESSION;
|
|
449
|
+
test: JSChildNode;
|
|
450
|
+
consequent: JSChildNode;
|
|
451
|
+
alternate: JSChildNode;
|
|
452
|
+
newline: boolean;
|
|
420
453
|
}
|
|
421
454
|
export interface CacheExpression extends Node {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
455
|
+
type: NodeTypes.JS_CACHE_EXPRESSION;
|
|
456
|
+
index: number;
|
|
457
|
+
value: JSChildNode;
|
|
458
|
+
needPauseTracking: boolean;
|
|
459
|
+
inVOnce: boolean;
|
|
460
|
+
needArraySpread: boolean;
|
|
428
461
|
}
|
|
429
462
|
export interface MemoExpression extends CallExpression {
|
|
430
|
-
|
|
431
|
-
|
|
463
|
+
callee: typeof WITH_MEMO;
|
|
464
|
+
arguments: [ExpressionNode, MemoFactory, string, string];
|
|
432
465
|
}
|
|
433
466
|
interface MemoFactory extends FunctionExpression {
|
|
434
|
-
|
|
467
|
+
returns: BlockCodegenNode;
|
|
435
468
|
}
|
|
436
469
|
export type SSRCodegenNode = BlockStatement | TemplateLiteral | IfStatement | AssignmentExpression | ReturnStatement | SequenceExpression;
|
|
437
470
|
export interface BlockStatement extends Node {
|
|
438
|
-
|
|
439
|
-
|
|
471
|
+
type: NodeTypes.JS_BLOCK_STATEMENT;
|
|
472
|
+
body: (JSChildNode | IfStatement)[];
|
|
440
473
|
}
|
|
441
474
|
export interface TemplateLiteral extends Node {
|
|
442
|
-
|
|
443
|
-
|
|
475
|
+
type: NodeTypes.JS_TEMPLATE_LITERAL;
|
|
476
|
+
elements: (string | JSChildNode)[];
|
|
444
477
|
}
|
|
445
478
|
export interface IfStatement extends Node {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
479
|
+
type: NodeTypes.JS_IF_STATEMENT;
|
|
480
|
+
test: ExpressionNode;
|
|
481
|
+
consequent: BlockStatement;
|
|
482
|
+
alternate: IfStatement | BlockStatement | ReturnStatement | undefined;
|
|
450
483
|
}
|
|
451
484
|
export interface AssignmentExpression extends Node {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
485
|
+
type: NodeTypes.JS_ASSIGNMENT_EXPRESSION;
|
|
486
|
+
left: SimpleExpressionNode;
|
|
487
|
+
right: JSChildNode;
|
|
455
488
|
}
|
|
456
489
|
export interface SequenceExpression extends Node {
|
|
457
|
-
|
|
458
|
-
|
|
490
|
+
type: NodeTypes.JS_SEQUENCE_EXPRESSION;
|
|
491
|
+
expressions: JSChildNode[];
|
|
459
492
|
}
|
|
460
493
|
export interface ReturnStatement extends Node {
|
|
461
|
-
|
|
462
|
-
|
|
494
|
+
type: NodeTypes.JS_RETURN_STATEMENT;
|
|
495
|
+
returns: TemplateChildNode | TemplateChildNode[] | JSChildNode;
|
|
463
496
|
}
|
|
464
497
|
export interface DirectiveArguments extends ArrayExpression {
|
|
465
|
-
|
|
498
|
+
elements: DirectiveArgumentNode[];
|
|
466
499
|
}
|
|
467
500
|
export interface DirectiveArgumentNode extends ArrayExpression {
|
|
468
|
-
|
|
501
|
+
elements: [string] | [string, ExpressionNode] | [string, ExpressionNode, ExpressionNode] | [string, ExpressionNode, ExpressionNode, ObjectExpression];
|
|
469
502
|
}
|
|
470
503
|
export interface RenderSlotCall extends CallExpression {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
string,
|
|
474
|
-
string | ExpressionNode,
|
|
475
|
-
PropsExpression | '{}',
|
|
476
|
-
TemplateChildNode[]
|
|
477
|
-
];
|
|
504
|
+
callee: typeof RENDER_SLOT;
|
|
505
|
+
arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [string, string | ExpressionNode, PropsExpression | "{}", TemplateChildNode[]];
|
|
478
506
|
}
|
|
479
507
|
export type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
|
|
480
508
|
export interface SlotsObjectExpression extends ObjectExpression {
|
|
481
|
-
|
|
509
|
+
properties: SlotsObjectProperty[];
|
|
482
510
|
}
|
|
483
511
|
export interface SlotsObjectProperty extends Property {
|
|
484
|
-
|
|
512
|
+
value: SlotFunctionExpression;
|
|
485
513
|
}
|
|
486
514
|
export interface SlotFunctionExpression extends FunctionExpression {
|
|
487
|
-
|
|
515
|
+
returns: TemplateChildNode[] | CacheExpression;
|
|
488
516
|
}
|
|
489
517
|
export interface DynamicSlotsExpression extends CallExpression {
|
|
490
|
-
|
|
491
|
-
|
|
518
|
+
callee: typeof CREATE_SLOTS;
|
|
519
|
+
arguments: [SlotsObjectExpression, DynamicSlotEntries];
|
|
492
520
|
}
|
|
493
521
|
export interface DynamicSlotEntries extends ArrayExpression {
|
|
494
|
-
|
|
522
|
+
elements: (ConditionalDynamicSlotNode | ListDynamicSlotNode)[];
|
|
495
523
|
}
|
|
496
524
|
export interface ConditionalDynamicSlotNode extends ConditionalExpression {
|
|
497
|
-
|
|
498
|
-
|
|
525
|
+
consequent: DynamicSlotNode;
|
|
526
|
+
alternate: DynamicSlotNode | SimpleExpressionNode;
|
|
499
527
|
}
|
|
500
528
|
export interface ListDynamicSlotNode extends CallExpression {
|
|
501
|
-
|
|
502
|
-
|
|
529
|
+
callee: typeof RENDER_LIST;
|
|
530
|
+
arguments: [ExpressionNode, ListDynamicSlotIterator];
|
|
503
531
|
}
|
|
504
532
|
export interface ListDynamicSlotIterator extends FunctionExpression {
|
|
505
|
-
|
|
533
|
+
returns: DynamicSlotNode;
|
|
506
534
|
}
|
|
507
535
|
export interface DynamicSlotNode extends ObjectExpression {
|
|
508
|
-
|
|
536
|
+
properties: [Property, DynamicSlotFnProperty];
|
|
509
537
|
}
|
|
510
538
|
export interface DynamicSlotFnProperty extends Property {
|
|
511
|
-
|
|
539
|
+
value: SlotFunctionExpression;
|
|
512
540
|
}
|
|
513
541
|
export type BlockCodegenNode = VNodeCall | RenderSlotCall;
|
|
514
542
|
export interface IfConditionalExpression extends ConditionalExpression {
|
|
515
|
-
|
|
516
|
-
|
|
543
|
+
consequent: BlockCodegenNode | MemoExpression;
|
|
544
|
+
alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression;
|
|
517
545
|
}
|
|
518
546
|
export interface ForCodegenNode extends VNodeCall {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
547
|
+
isBlock: true;
|
|
548
|
+
tag: typeof FRAGMENT;
|
|
549
|
+
props: undefined;
|
|
550
|
+
children: ForRenderListExpression;
|
|
551
|
+
patchFlag: PatchFlags;
|
|
552
|
+
disableTracking: boolean;
|
|
525
553
|
}
|
|
526
554
|
export interface ForRenderListExpression extends CallExpression {
|
|
527
|
-
|
|
528
|
-
|
|
555
|
+
callee: typeof RENDER_LIST;
|
|
556
|
+
arguments: [ExpressionNode, ForIteratorExpression];
|
|
529
557
|
}
|
|
530
558
|
export interface ForIteratorExpression extends FunctionExpression {
|
|
531
|
-
|
|
559
|
+
returns?: BlockCodegenNode;
|
|
532
560
|
}
|
|
533
561
|
export declare const locStub: SourceLocation;
|
|
534
562
|
export declare function createRoot(children: TemplateChildNode[], source?: string): RootNode;
|
|
535
|
-
export declare function createVNodeCall(context: TransformContext | null, tag: VNodeCall[
|
|
536
|
-
export declare function createArrayExpression(elements: ArrayExpression[
|
|
537
|
-
export declare function createObjectExpression(properties: ObjectExpression[
|
|
538
|
-
export declare function createObjectProperty(key: Property[
|
|
539
|
-
export declare function createSimpleExpression(content: SimpleExpressionNode[
|
|
540
|
-
export declare function createInterpolation(content: InterpolationNode[
|
|
541
|
-
export declare function createCompoundExpression(children: CompoundExpressionNode[
|
|
563
|
+
export declare function createVNodeCall(context: TransformContext | null, tag: VNodeCall["tag"], props?: VNodeCall["props"], children?: VNodeCall["children"], patchFlag?: VNodeCall["patchFlag"], dynamicProps?: VNodeCall["dynamicProps"], directives?: VNodeCall["directives"], isBlock?: VNodeCall["isBlock"], disableTracking?: VNodeCall["disableTracking"], isComponent?: VNodeCall["isComponent"], loc?: SourceLocation): VNodeCall;
|
|
564
|
+
export declare function createArrayExpression(elements: ArrayExpression["elements"], loc?: SourceLocation): ArrayExpression;
|
|
565
|
+
export declare function createObjectExpression(properties: ObjectExpression["properties"], loc?: SourceLocation): ObjectExpression;
|
|
566
|
+
export declare function createObjectProperty(key: Property["key"] | string, value: Property["value"]): Property;
|
|
567
|
+
export declare function createSimpleExpression(content: SimpleExpressionNode["content"], isStatic?: SimpleExpressionNode["isStatic"], loc?: SourceLocation, constType?: ConstantTypes): SimpleExpressionNode;
|
|
568
|
+
export declare function createInterpolation(content: InterpolationNode["content"] | string, loc: SourceLocation): InterpolationNode;
|
|
569
|
+
export declare function createCompoundExpression(children: CompoundExpressionNode["children"], loc?: SourceLocation): CompoundExpressionNode;
|
|
542
570
|
type InferCodegenNodeType<T> = T extends typeof RENDER_SLOT ? RenderSlotCall : CallExpression;
|
|
543
|
-
export declare function createCallExpression<T extends CallExpression[
|
|
544
|
-
export declare function createFunctionExpression(params: FunctionExpression[
|
|
545
|
-
export declare function createConditionalExpression(test: ConditionalExpression[
|
|
571
|
+
export declare function createCallExpression<T extends CallExpression["callee"]>(callee: T, args?: CallExpression["arguments"], loc?: SourceLocation): InferCodegenNodeType<T>;
|
|
572
|
+
export declare function createFunctionExpression(params: FunctionExpression["params"], returns?: FunctionExpression["returns"], newline?: boolean, isSlot?: boolean, loc?: SourceLocation): FunctionExpression;
|
|
573
|
+
export declare function createConditionalExpression(test: ConditionalExpression["test"], consequent: ConditionalExpression["consequent"], alternate: ConditionalExpression["alternate"], newline?: boolean): ConditionalExpression;
|
|
546
574
|
export declare function createCacheExpression(index: number, value: JSChildNode, needPauseTracking?: boolean, inVOnce?: boolean): CacheExpression;
|
|
547
|
-
export declare function createBlockStatement(body: BlockStatement[
|
|
548
|
-
export declare function createTemplateLiteral(elements: TemplateLiteral[
|
|
549
|
-
export declare function createIfStatement(test: IfStatement[
|
|
550
|
-
export declare function createAssignmentExpression(left: AssignmentExpression[
|
|
551
|
-
export declare function createSequenceExpression(expressions: SequenceExpression[
|
|
552
|
-
export declare function createReturnStatement(returns: ReturnStatement[
|
|
575
|
+
export declare function createBlockStatement(body: BlockStatement["body"]): BlockStatement;
|
|
576
|
+
export declare function createTemplateLiteral(elements: TemplateLiteral["elements"]): TemplateLiteral;
|
|
577
|
+
export declare function createIfStatement(test: IfStatement["test"], consequent: IfStatement["consequent"], alternate?: IfStatement["alternate"]): IfStatement;
|
|
578
|
+
export declare function createAssignmentExpression(left: AssignmentExpression["left"], right: AssignmentExpression["right"]): AssignmentExpression;
|
|
579
|
+
export declare function createSequenceExpression(expressions: SequenceExpression["expressions"]): SequenceExpression;
|
|
580
|
+
export declare function createReturnStatement(returns: ReturnStatement["returns"]): ReturnStatement;
|
|
553
581
|
export declare function getVNodeHelper(ssr: boolean, isComponent: boolean): typeof CREATE_VNODE | typeof CREATE_ELEMENT_VNODE;
|
|
554
582
|
export declare function getVNodeBlockHelper(ssr: boolean, isComponent: boolean): typeof CREATE_BLOCK | typeof CREATE_ELEMENT_BLOCK;
|
|
555
|
-
export declare function convertToBlock(node: VNodeCall, {
|
|
556
|
-
|
|
583
|
+
export declare function convertToBlock(node: VNodeCall, {
|
|
584
|
+
helper,
|
|
585
|
+
removeHelper,
|
|
586
|
+
inSSR
|
|
587
|
+
}: TransformContext): void;
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region temp/packages/compiler-core/src/errors.d.ts
|
|
557
590
|
export interface CompilerError extends SyntaxError {
|
|
558
|
-
|
|
559
|
-
|
|
591
|
+
code: number | string;
|
|
592
|
+
loc?: SourceLocation;
|
|
560
593
|
}
|
|
561
594
|
export interface CoreCompilerError extends CompilerError {
|
|
562
|
-
|
|
595
|
+
code: ErrorCodes;
|
|
563
596
|
}
|
|
564
597
|
export declare function defaultOnError(error: CompilerError): never;
|
|
565
598
|
export declare function defaultOnWarn(msg: CompilerError): void;
|
|
566
599
|
type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : CompilerError;
|
|
567
600
|
export declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
|
|
568
|
-
|
|
601
|
+
[code: number]: string;
|
|
569
602
|
}, additionalMessage?: string): InferCompilerError<T>;
|
|
570
603
|
export declare enum ErrorCodes {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
604
|
+
ABRUPT_CLOSING_OF_EMPTY_COMMENT = 0,
|
|
605
|
+
CDATA_IN_HTML_CONTENT = 1,
|
|
606
|
+
DUPLICATE_ATTRIBUTE = 2,
|
|
607
|
+
END_TAG_WITH_ATTRIBUTES = 3,
|
|
608
|
+
END_TAG_WITH_TRAILING_SOLIDUS = 4,
|
|
609
|
+
EOF_BEFORE_TAG_NAME = 5,
|
|
610
|
+
EOF_IN_CDATA = 6,
|
|
611
|
+
EOF_IN_COMMENT = 7,
|
|
612
|
+
EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT = 8,
|
|
613
|
+
EOF_IN_TAG = 9,
|
|
614
|
+
INCORRECTLY_CLOSED_COMMENT = 10,
|
|
615
|
+
INCORRECTLY_OPENED_COMMENT = 11,
|
|
616
|
+
INVALID_FIRST_CHARACTER_OF_TAG_NAME = 12,
|
|
617
|
+
MISSING_ATTRIBUTE_VALUE = 13,
|
|
618
|
+
MISSING_END_TAG_NAME = 14,
|
|
619
|
+
MISSING_WHITESPACE_BETWEEN_ATTRIBUTES = 15,
|
|
620
|
+
NESTED_COMMENT = 16,
|
|
621
|
+
UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME = 17,
|
|
622
|
+
UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE = 18,
|
|
623
|
+
UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME = 19,
|
|
624
|
+
UNEXPECTED_NULL_CHARACTER = 20,
|
|
625
|
+
UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME = 21,
|
|
626
|
+
UNEXPECTED_SOLIDUS_IN_TAG = 22,
|
|
627
|
+
X_INVALID_END_TAG = 23,
|
|
628
|
+
X_MISSING_END_TAG = 24,
|
|
629
|
+
X_MISSING_INTERPOLATION_END = 25,
|
|
630
|
+
X_MISSING_DIRECTIVE_NAME = 26,
|
|
631
|
+
X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END = 27,
|
|
632
|
+
X_V_IF_NO_EXPRESSION = 28,
|
|
633
|
+
X_V_IF_SAME_KEY = 29,
|
|
634
|
+
X_V_ELSE_NO_ADJACENT_IF = 30,
|
|
635
|
+
X_V_FOR_NO_EXPRESSION = 31,
|
|
636
|
+
X_V_FOR_MALFORMED_EXPRESSION = 32,
|
|
637
|
+
X_V_FOR_TEMPLATE_KEY_PLACEMENT = 33,
|
|
638
|
+
X_V_BIND_NO_EXPRESSION = 34,
|
|
639
|
+
X_V_ON_NO_EXPRESSION = 35,
|
|
640
|
+
X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET = 36,
|
|
641
|
+
X_V_SLOT_MIXED_SLOT_USAGE = 37,
|
|
642
|
+
X_V_SLOT_DUPLICATE_SLOT_NAMES = 38,
|
|
643
|
+
X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN = 39,
|
|
644
|
+
X_V_SLOT_MISPLACED = 40,
|
|
645
|
+
X_V_MODEL_NO_EXPRESSION = 41,
|
|
646
|
+
X_V_MODEL_MALFORMED_EXPRESSION = 42,
|
|
647
|
+
X_V_MODEL_ON_SCOPE_VARIABLE = 43,
|
|
648
|
+
X_V_MODEL_ON_PROPS = 44,
|
|
649
|
+
X_V_MODEL_ON_CONST = 45,
|
|
650
|
+
X_INVALID_EXPRESSION = 46,
|
|
651
|
+
X_KEEP_ALIVE_INVALID_CHILDREN = 47,
|
|
652
|
+
X_PREFIX_ID_NOT_SUPPORTED = 48,
|
|
653
|
+
X_MODULE_MODE_NOT_SUPPORTED = 49,
|
|
654
|
+
X_CACHE_HANDLER_NOT_SUPPORTED = 50,
|
|
655
|
+
X_SCOPE_ID_NOT_SUPPORTED = 51,
|
|
656
|
+
X_VNODE_HOOKS = 52,
|
|
657
|
+
X_V_BIND_INVALID_SAME_NAME_ARGUMENT = 53,
|
|
658
|
+
__EXTEND_POINT__ = 54
|
|
626
659
|
}
|
|
627
660
|
export declare const errorMessages: Record<ErrorCodes, string>;
|
|
628
|
-
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region temp/packages/compiler-core/src/options.d.ts
|
|
629
663
|
interface ErrorHandlingOptions {
|
|
630
|
-
|
|
631
|
-
|
|
664
|
+
onWarn?: (warning: CompilerError) => void;
|
|
665
|
+
onError?: (error: CompilerError) => void;
|
|
632
666
|
}
|
|
633
667
|
export interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptions {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
668
|
+
/**
|
|
669
|
+
* Base mode is platform agnostic and only parses HTML-like template syntax,
|
|
670
|
+
* treating all tags the same way. Specific tag parsing behavior can be
|
|
671
|
+
* configured by higher-level compilers.
|
|
672
|
+
*
|
|
673
|
+
* HTML mode adds additional logic for handling special parsing behavior in
|
|
674
|
+
* `<script>`, `<style>`,`<title>` and `<textarea>`.
|
|
675
|
+
* The logic is handled inside compiler-core for efficiency.
|
|
676
|
+
*
|
|
677
|
+
* SFC mode treats content of all root-level tags except `<template>` as plain
|
|
678
|
+
* text.
|
|
679
|
+
*/
|
|
680
|
+
parseMode?: "base" | "html" | "sfc";
|
|
681
|
+
/**
|
|
682
|
+
* Specify the root namespace to use when parsing a template.
|
|
683
|
+
* Defaults to `Namespaces.HTML` (0).
|
|
684
|
+
*/
|
|
685
|
+
ns?: Namespaces;
|
|
686
|
+
/**
|
|
687
|
+
* e.g. platform native elements, e.g. `<div>` for browsers
|
|
688
|
+
*/
|
|
689
|
+
isNativeTag?: (tag: string) => boolean;
|
|
690
|
+
/**
|
|
691
|
+
* e.g. native elements that can self-close, e.g. `<img>`, `<br>`, `<hr>`
|
|
692
|
+
*/
|
|
693
|
+
isVoidTag?: (tag: string) => boolean;
|
|
694
|
+
/**
|
|
695
|
+
* e.g. elements that should preserve whitespace inside, e.g. `<pre>`
|
|
696
|
+
*/
|
|
697
|
+
isPreTag?: (tag: string) => boolean;
|
|
698
|
+
/**
|
|
699
|
+
* Elements that should ignore the first newline token per parinsg spec
|
|
700
|
+
* e.g. `<textarea>` and `<pre>`
|
|
701
|
+
*/
|
|
702
|
+
isIgnoreNewlineTag?: (tag: string) => boolean;
|
|
703
|
+
/**
|
|
704
|
+
* Platform-specific built-in components e.g. `<Transition>`
|
|
705
|
+
*/
|
|
706
|
+
isBuiltInComponent?: (tag: string) => symbol | void;
|
|
707
|
+
/**
|
|
708
|
+
* Separate option for end users to extend the native elements list
|
|
709
|
+
*/
|
|
710
|
+
isCustomElement?: (tag: string) => boolean | void;
|
|
711
|
+
/**
|
|
712
|
+
* Get tag namespace
|
|
713
|
+
*/
|
|
714
|
+
getNamespace?: (tag: string, parent: ElementNode | undefined, rootNamespace: Namespace) => Namespace;
|
|
715
|
+
/**
|
|
716
|
+
* @default ['{{', '}}']
|
|
717
|
+
*/
|
|
718
|
+
delimiters?: [string, string];
|
|
719
|
+
/**
|
|
720
|
+
* Whitespace handling strategy
|
|
721
|
+
* @default 'condense'
|
|
722
|
+
*/
|
|
723
|
+
whitespace?: "preserve" | "condense";
|
|
724
|
+
/**
|
|
725
|
+
* Only used for DOM compilers that runs in the browser.
|
|
726
|
+
* In non-browser builds, this option is ignored.
|
|
727
|
+
*/
|
|
728
|
+
decodeEntities?: (rawText: string, asAttr: boolean) => string;
|
|
729
|
+
/**
|
|
730
|
+
* Whether to keep comments in the templates AST.
|
|
731
|
+
* This defaults to `true` in development and `false` in production builds.
|
|
732
|
+
*/
|
|
733
|
+
comments?: boolean;
|
|
734
|
+
/**
|
|
735
|
+
* Parse JavaScript expressions with Babel.
|
|
736
|
+
* @default false
|
|
737
|
+
*/
|
|
738
|
+
prefixIdentifiers?: boolean;
|
|
739
|
+
/**
|
|
740
|
+
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
741
|
+
* parse expressions in bindings and interpolations.
|
|
742
|
+
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
743
|
+
*/
|
|
744
|
+
expressionPlugins?: ParserPlugin[];
|
|
711
745
|
}
|
|
712
746
|
export type HoistTransform = (children: TemplateChildNode[], context: TransformContext, parent: ParentNode) => void;
|
|
713
747
|
export declare enum BindingTypes {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
748
|
+
/**
|
|
749
|
+
* returned from data()
|
|
750
|
+
*/
|
|
751
|
+
DATA = "data",
|
|
752
|
+
/**
|
|
753
|
+
* declared as a prop
|
|
754
|
+
*/
|
|
755
|
+
PROPS = "props",
|
|
756
|
+
/**
|
|
757
|
+
* a local alias of a `<script setup>` destructured prop.
|
|
758
|
+
* the original is stored in __propsAliases of the bindingMetadata object.
|
|
759
|
+
*/
|
|
760
|
+
PROPS_ALIASED = "props-aliased",
|
|
761
|
+
/**
|
|
762
|
+
* a let binding (may or may not be a ref)
|
|
763
|
+
*/
|
|
764
|
+
SETUP_LET = "setup-let",
|
|
765
|
+
/**
|
|
766
|
+
* a const binding that can never be a ref.
|
|
767
|
+
* these bindings don't need `unref()` calls when processed in inlined
|
|
768
|
+
* template expressions.
|
|
769
|
+
*/
|
|
770
|
+
SETUP_CONST = "setup-const",
|
|
771
|
+
/**
|
|
772
|
+
* a const binding that does not need `unref()`, but may be mutated.
|
|
773
|
+
*/
|
|
774
|
+
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
|
775
|
+
/**
|
|
776
|
+
* a const binding that may be a ref.
|
|
777
|
+
*/
|
|
778
|
+
SETUP_MAYBE_REF = "setup-maybe-ref",
|
|
779
|
+
/**
|
|
780
|
+
* bindings that are guaranteed to be refs
|
|
781
|
+
*/
|
|
782
|
+
SETUP_REF = "setup-ref",
|
|
783
|
+
/**
|
|
784
|
+
* declared by other options, e.g. computed, inject
|
|
785
|
+
*/
|
|
786
|
+
OPTIONS = "options",
|
|
787
|
+
/**
|
|
788
|
+
* a literal constant, e.g. 'foo', 1, true
|
|
789
|
+
*/
|
|
790
|
+
LITERAL_CONST = "literal-const"
|
|
757
791
|
}
|
|
758
792
|
export type BindingMetadata = {
|
|
759
|
-
|
|
793
|
+
[key: string]: BindingTypes | undefined;
|
|
760
794
|
} & {
|
|
761
|
-
|
|
762
|
-
|
|
795
|
+
__isScriptSetup?: boolean;
|
|
796
|
+
__propsAliases?: Record<string, string>;
|
|
763
797
|
};
|
|
764
798
|
interface SharedTransformCodegenOptions {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
799
|
+
/**
|
|
800
|
+
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
|
801
|
+
* If this option is false, the generated code will be wrapped in a
|
|
802
|
+
* `with (this) { ... }` block.
|
|
803
|
+
* - This is force-enabled in module mode, since modules are by default strict
|
|
804
|
+
* and cannot use `with`
|
|
805
|
+
* @default mode === 'module'
|
|
806
|
+
*/
|
|
807
|
+
prefixIdentifiers?: boolean;
|
|
808
|
+
/**
|
|
809
|
+
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
810
|
+
* parse expressions in bindings and interpolations.
|
|
811
|
+
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
812
|
+
*/
|
|
813
|
+
expressionPlugins?: ParserPlugin[];
|
|
814
|
+
/**
|
|
815
|
+
* Control whether generate SSR-optimized render functions instead.
|
|
816
|
+
* The resulting function must be attached to the component via the
|
|
817
|
+
* `ssrRender` option instead of `render`.
|
|
818
|
+
*
|
|
819
|
+
* When compiler generates code for SSR's fallback branch, we need to set it to false:
|
|
820
|
+
* - context.ssr = false
|
|
821
|
+
*
|
|
822
|
+
* see `subTransform` in `ssrTransformComponent.ts`
|
|
823
|
+
*/
|
|
824
|
+
ssr?: boolean;
|
|
825
|
+
/**
|
|
826
|
+
* Indicates whether the compiler generates code for SSR,
|
|
827
|
+
* it is always true when generating code for SSR,
|
|
828
|
+
* regardless of whether we are generating code for SSR's fallback branch,
|
|
829
|
+
* this means that when the compiler generates code for SSR's fallback branch:
|
|
830
|
+
* - context.ssr = false
|
|
831
|
+
* - context.inSSR = true
|
|
832
|
+
*/
|
|
833
|
+
inSSR?: boolean;
|
|
834
|
+
/**
|
|
835
|
+
* Optional binding metadata analyzed from script - used to optimize
|
|
836
|
+
* binding access when `prefixIdentifiers` is enabled.
|
|
837
|
+
*/
|
|
838
|
+
bindingMetadata?: BindingMetadata;
|
|
839
|
+
/**
|
|
840
|
+
* Compile the function for inlining inside setup().
|
|
841
|
+
* This allows the function to directly access setup() local bindings.
|
|
842
|
+
*/
|
|
843
|
+
inline?: boolean;
|
|
844
|
+
/**
|
|
845
|
+
* Indicates that transforms and codegen should try to output valid TS code
|
|
846
|
+
*/
|
|
847
|
+
isTS?: boolean;
|
|
848
|
+
/**
|
|
849
|
+
* Filename for source map generation.
|
|
850
|
+
* Also used for self-recursive reference in templates
|
|
851
|
+
* @default 'template.vue.html'
|
|
852
|
+
*/
|
|
853
|
+
filename?: string;
|
|
820
854
|
}
|
|
821
855
|
export interface TransformOptions extends SharedTransformCodegenOptions, ErrorHandlingOptions, CompilerCompatOptions {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
856
|
+
/**
|
|
857
|
+
* An array of node transforms to be applied to every AST node.
|
|
858
|
+
*/
|
|
859
|
+
nodeTransforms?: NodeTransform[];
|
|
860
|
+
/**
|
|
861
|
+
* An object of { name: transform } to be applied to every directive attribute
|
|
862
|
+
* node found on element nodes.
|
|
863
|
+
*/
|
|
864
|
+
directiveTransforms?: Record<string, DirectiveTransform | undefined>;
|
|
865
|
+
/**
|
|
866
|
+
* An optional hook to transform a node being hoisted.
|
|
867
|
+
* used by compiler-dom to turn hoisted nodes into stringified HTML vnodes.
|
|
868
|
+
* @default null
|
|
869
|
+
*/
|
|
870
|
+
transformHoist?: HoistTransform | null;
|
|
871
|
+
/**
|
|
872
|
+
* If the pairing runtime provides additional built-in elements, use this to
|
|
873
|
+
* mark them as built-in so the compiler will generate component vnodes
|
|
874
|
+
* for them.
|
|
875
|
+
*/
|
|
876
|
+
isBuiltInComponent?: (tag: string) => symbol | void;
|
|
877
|
+
/**
|
|
878
|
+
* Used by some transforms that expects only native elements
|
|
879
|
+
*/
|
|
880
|
+
isCustomElement?: (tag: string) => boolean | void;
|
|
881
|
+
/**
|
|
882
|
+
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
|
883
|
+
* If this option is false, the generated code will be wrapped in a
|
|
884
|
+
* `with (this) { ... }` block.
|
|
885
|
+
* - This is force-enabled in module mode, since modules are by default strict
|
|
886
|
+
* and cannot use `with`
|
|
887
|
+
* @default mode === 'module'
|
|
888
|
+
*/
|
|
889
|
+
prefixIdentifiers?: boolean;
|
|
890
|
+
/**
|
|
891
|
+
* Cache static VNodes and props objects to `_hoisted_x` constants
|
|
892
|
+
* @default false
|
|
893
|
+
*/
|
|
894
|
+
hoistStatic?: boolean;
|
|
895
|
+
/**
|
|
896
|
+
* Cache v-on handlers to avoid creating new inline functions on each render,
|
|
897
|
+
* also avoids the need for dynamically patching the handlers by wrapping it.
|
|
898
|
+
* e.g `@click="foo"` by default is compiled to `{ onClick: foo }`. With this
|
|
899
|
+
* option it's compiled to:
|
|
900
|
+
* ```js
|
|
901
|
+
* { onClick: _cache[0] || (_cache[0] = e => _ctx.foo(e)) }
|
|
902
|
+
* ```
|
|
903
|
+
* - Requires "prefixIdentifiers" to be enabled because it relies on scope
|
|
904
|
+
* analysis to determine if a handler is safe to cache.
|
|
905
|
+
* @default false
|
|
906
|
+
*/
|
|
907
|
+
cacheHandlers?: boolean;
|
|
908
|
+
/**
|
|
909
|
+
* SFC scoped styles ID
|
|
910
|
+
*/
|
|
911
|
+
scopeId?: string | null;
|
|
912
|
+
/**
|
|
913
|
+
* Indicates this SFC template has used :slotted in its styles
|
|
914
|
+
* Defaults to `true` for backwards compatibility - SFC tooling should set it
|
|
915
|
+
* to `false` if no `:slotted` usage is detected in `<style>`
|
|
916
|
+
*/
|
|
917
|
+
slotted?: boolean;
|
|
918
|
+
/**
|
|
919
|
+
* SFC `<style vars>` injection string
|
|
920
|
+
* Should already be an object expression, e.g. `{ 'xxxx-color': color }`
|
|
921
|
+
* needed to render inline CSS variables on component root
|
|
922
|
+
*/
|
|
923
|
+
ssrCssVars?: string;
|
|
924
|
+
/**
|
|
925
|
+
* Whether to compile the template assuming it needs to handle HMR.
|
|
926
|
+
* Some edge cases may need to generate different code for HMR to work
|
|
927
|
+
* correctly, e.g. #6938, #7138
|
|
928
|
+
*/
|
|
929
|
+
hmr?: boolean;
|
|
896
930
|
}
|
|
897
931
|
export interface CodegenOptions extends SharedTransformCodegenOptions {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
932
|
+
/**
|
|
933
|
+
* - `module` mode will generate ES module import statements for helpers
|
|
934
|
+
* and export the render function as the default export.
|
|
935
|
+
* - `function` mode will generate a single `const { helpers... } = Vue`
|
|
936
|
+
* statement and return the render function. It expects `Vue` to be globally
|
|
937
|
+
* available (or passed by wrapping the code with an IIFE). It is meant to be
|
|
938
|
+
* used with `new Function(code)()` to generate a render function at runtime.
|
|
939
|
+
* @default 'function'
|
|
940
|
+
*/
|
|
941
|
+
mode?: "module" | "function";
|
|
942
|
+
/**
|
|
943
|
+
* Generate source map?
|
|
944
|
+
* @default false
|
|
945
|
+
*/
|
|
946
|
+
sourceMap?: boolean;
|
|
947
|
+
/**
|
|
948
|
+
* SFC scoped styles ID
|
|
949
|
+
*/
|
|
950
|
+
scopeId?: string | null;
|
|
951
|
+
/**
|
|
952
|
+
* Option to optimize helper import bindings via variable assignment
|
|
953
|
+
* (only used for webpack code-split)
|
|
954
|
+
* @default false
|
|
955
|
+
*/
|
|
956
|
+
optimizeImports?: boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Customize where to import runtime helpers from.
|
|
959
|
+
* @default 'vue'
|
|
960
|
+
*/
|
|
961
|
+
runtimeModuleName?: string;
|
|
962
|
+
/**
|
|
963
|
+
* Customize where to import ssr runtime helpers from/**
|
|
964
|
+
* @default 'vue/server-renderer'
|
|
965
|
+
*/
|
|
966
|
+
ssrRuntimeModuleName?: string;
|
|
967
|
+
/**
|
|
968
|
+
* Customize the global variable name of `Vue` to get helpers from
|
|
969
|
+
* in function mode
|
|
970
|
+
* @default 'Vue'
|
|
971
|
+
*/
|
|
972
|
+
runtimeGlobalName?: string;
|
|
939
973
|
}
|
|
940
974
|
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
|
|
941
|
-
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region temp/packages/compiler-core/src/codegen.d.ts
|
|
942
977
|
/**
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
978
|
+
* The `SourceMapGenerator` type from `source-map-js` is a bit incomplete as it
|
|
979
|
+
* misses `toJSON()`. We also need to add types for internal properties which we
|
|
980
|
+
* need to access for better performance.
|
|
981
|
+
*
|
|
982
|
+
* Since TS 5.3, dts generation starts to strangely include broken triple slash
|
|
983
|
+
* references for source-map-js, so we are inlining all source map related types
|
|
984
|
+
* here to to workaround that.
|
|
985
|
+
*/
|
|
951
986
|
export interface CodegenSourceMapGenerator {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
987
|
+
setSourceContent(sourceFile: string, sourceContent: string): void;
|
|
988
|
+
toJSON(): RawSourceMap;
|
|
989
|
+
_sources: Set<string>;
|
|
990
|
+
_names: Set<string>;
|
|
991
|
+
_mappings: {
|
|
992
|
+
add(mapping: MappingItem): void;
|
|
993
|
+
};
|
|
959
994
|
}
|
|
960
995
|
export interface RawSourceMap {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
996
|
+
file?: string;
|
|
997
|
+
sourceRoot?: string;
|
|
998
|
+
version: string;
|
|
999
|
+
sources: string[];
|
|
1000
|
+
names: string[];
|
|
1001
|
+
sourcesContent?: string[];
|
|
1002
|
+
mappings: string;
|
|
968
1003
|
}
|
|
969
1004
|
interface MappingItem {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1005
|
+
source: string;
|
|
1006
|
+
generatedLine: number;
|
|
1007
|
+
generatedColumn: number;
|
|
1008
|
+
originalLine: number;
|
|
1009
|
+
originalColumn: number;
|
|
1010
|
+
name: string | null;
|
|
976
1011
|
}
|
|
977
1012
|
type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
|
|
978
1013
|
export interface BaseCodegenResult {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1014
|
+
code: string;
|
|
1015
|
+
preamble: string;
|
|
1016
|
+
ast: unknown;
|
|
1017
|
+
map?: RawSourceMap;
|
|
1018
|
+
helpers?: Set<string> | Set<symbol>;
|
|
984
1019
|
}
|
|
985
1020
|
export interface CodegenResult extends BaseCodegenResult {
|
|
986
|
-
|
|
1021
|
+
ast: RootNode;
|
|
987
1022
|
}
|
|
988
1023
|
export declare enum NewlineType {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
export interface CodegenContext extends Omit<Required<CodegenOptions>,
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1024
|
+
/** Start with `\n` */
|
|
1025
|
+
Start = 0,
|
|
1026
|
+
/** Ends with `\n` */
|
|
1027
|
+
End = -1,
|
|
1028
|
+
/** No `\n` included */
|
|
1029
|
+
None = -2,
|
|
1030
|
+
/** Don't know, calc it */
|
|
1031
|
+
Unknown = -3
|
|
1032
|
+
}
|
|
1033
|
+
export interface CodegenContext extends Omit<Required<CodegenOptions>, "bindingMetadata" | "inline" | "vaporRuntimeModuleName" | "expressionPlugins"> {
|
|
1034
|
+
source: string;
|
|
1035
|
+
code: string;
|
|
1036
|
+
line: number;
|
|
1037
|
+
column: number;
|
|
1038
|
+
offset: number;
|
|
1039
|
+
indentLevel: number;
|
|
1040
|
+
pure: boolean;
|
|
1041
|
+
map?: CodegenSourceMapGenerator;
|
|
1042
|
+
helper(key: symbol): string;
|
|
1043
|
+
push(code: string, newlineIndex?: number, node?: CodegenNode): void;
|
|
1044
|
+
indent(): void;
|
|
1045
|
+
deindent(withoutNewLine?: boolean): void;
|
|
1046
|
+
newline(): void;
|
|
1012
1047
|
}
|
|
1013
1048
|
export declare function generate(ast: RootNode, options?: CodegenOptions & {
|
|
1014
|
-
|
|
1049
|
+
onContextCreated?: (context: CodegenContext) => void;
|
|
1015
1050
|
}): CodegenResult;
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
Record<string, DirectiveTransform>
|
|
1020
|
-
];
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region temp/packages/compiler-core/src/compile.d.ts
|
|
1053
|
+
export type TransformPreset = [NodeTransform[], Record<string, DirectiveTransform>];
|
|
1021
1054
|
export declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
|
|
1022
1055
|
export declare function baseCompile(source: string | RootNode, options?: CompilerOptions): CodegenResult;
|
|
1023
|
-
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region temp/packages/compiler-core/src/utils.d.ts
|
|
1024
1058
|
export declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
|
|
1025
1059
|
export declare function isCoreComponent(tag: string): symbol | void;
|
|
1026
1060
|
export declare const isSimpleIdentifier: (name: string) => boolean;
|
|
1027
1061
|
export declare const validFirstIdentCharRE: RegExp;
|
|
1028
1062
|
/**
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1063
|
+
* Simple lexer to check if an expression is a member expression. This is
|
|
1064
|
+
* lax and only checks validity at the root level (i.e. does not validate exps
|
|
1065
|
+
* inside square brackets), but it's ok since these are only used on template
|
|
1066
|
+
* expressions and false positives are invalid expressions in the first place.
|
|
1067
|
+
*/
|
|
1034
1068
|
export declare const isMemberExpressionBrowser: (exp: ExpressionNode) => boolean;
|
|
1035
|
-
export declare const isMemberExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext,
|
|
1036
|
-
export declare const isMemberExpression: (exp: ExpressionNode, context: Pick<TransformContext,
|
|
1069
|
+
export declare const isMemberExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
1070
|
+
export declare const isMemberExpression: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
1037
1071
|
export declare const isFnExpressionBrowser: (exp: ExpressionNode) => boolean;
|
|
1038
|
-
export declare const isFnExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext,
|
|
1039
|
-
export declare const isFnExpression: (exp: ExpressionNode, context: Pick<TransformContext,
|
|
1072
|
+
export declare const isFnExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
1073
|
+
export declare const isFnExpression: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
1040
1074
|
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
1041
1075
|
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
1042
1076
|
export declare function assert(condition: boolean, msg?: string): void;
|
|
1043
1077
|
/** find directive */
|
|
1044
1078
|
export declare function findDir(node: ElementNode, name: string | RegExp, allowEmpty?: boolean): DirectiveNode | undefined;
|
|
1045
|
-
export declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode[
|
|
1046
|
-
export declare function isStaticArgOf(arg: DirectiveNode[
|
|
1079
|
+
export declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode["props"][0] | undefined;
|
|
1080
|
+
export declare function isStaticArgOf(arg: DirectiveNode["arg"], name: string): boolean;
|
|
1047
1081
|
export declare function hasDynamicKeyVBind(node: ElementNode): boolean;
|
|
1048
1082
|
export declare function isText(node: TemplateChildNode): node is TextNode | InterpolationNode;
|
|
1049
|
-
export declare function isVPre(p: ElementNode[
|
|
1050
|
-
export declare function isVSlot(p: ElementNode[
|
|
1083
|
+
export declare function isVPre(p: ElementNode["props"][0]): p is DirectiveNode;
|
|
1084
|
+
export declare function isVSlot(p: ElementNode["props"][0]): p is DirectiveNode;
|
|
1051
1085
|
export declare function isTemplateNode(node: RootNode | TemplateChildNode): node is TemplateNode;
|
|
1052
1086
|
export declare function isSlotOutlet(node: RootNode | TemplateChildNode): node is SlotOutletNode;
|
|
1053
1087
|
export declare function injectProp(node: VNodeCall | RenderSlotCall, prop: Property, context: TransformContext): void;
|
|
1054
|
-
export declare function toValidAssetId(name: string, type:
|
|
1055
|
-
export declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | CacheExpression | undefined, ids: TransformContext[
|
|
1088
|
+
export declare function toValidAssetId(name: string, type: "component" | "directive" | "filter"): string;
|
|
1089
|
+
export declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | CacheExpression | undefined, ids: TransformContext["identifiers"]): boolean;
|
|
1056
1090
|
export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
|
|
1057
1091
|
export declare function filterNonCommentChildren(node: ParentNode): TemplateChildNode[];
|
|
1058
1092
|
export declare function hasSingleChild(node: ParentNode): boolean;
|
|
@@ -1061,10 +1095,11 @@ export declare const forAliasRE: RegExp;
|
|
|
1061
1095
|
export declare function isAllWhitespace(str: string): boolean;
|
|
1062
1096
|
export declare function isWhitespaceText(node: TemplateChildNode): boolean;
|
|
1063
1097
|
export declare function isCommentOrWhitespace(node: TemplateChildNode): boolean;
|
|
1064
|
-
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region temp/packages/compiler-core/src/babelUtils.d.ts
|
|
1065
1100
|
/**
|
|
1066
|
-
|
|
1067
|
-
|
|
1101
|
+
* Return value indicates whether the AST walked can be a constant
|
|
1102
|
+
*/
|
|
1068
1103
|
export declare function walkIdentifiers(root: Node$1, onIdentifier: (node: Identifier, parent: Node$1 | null, parentStack: Node$1[], isReference: boolean, isLocal: boolean) => void, includeAll?: boolean, parentStack?: Node$1[], knownIds?: Record<string, number>): void;
|
|
1069
1104
|
export declare function isReferencedIdentifier(id: Identifier, parent: Node$1 | null, parentStack: Node$1[]): boolean;
|
|
1070
1105
|
export declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
|
|
@@ -1079,41 +1114,56 @@ export declare const TS_NODE_TYPES: string[];
|
|
|
1079
1114
|
export declare function unwrapTSNode(node: Node$1): Node$1;
|
|
1080
1115
|
export declare function isStaticNode(node: Node$1): boolean;
|
|
1081
1116
|
export declare function isConstantNode(node: Node$1, bindings: BindingMetadata): boolean;
|
|
1082
|
-
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region temp/packages/compiler-core/src/transforms/vModel.d.ts
|
|
1083
1119
|
export declare const transformModel: DirectiveTransform;
|
|
1084
|
-
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region temp/packages/compiler-core/src/transforms/vOn.d.ts
|
|
1085
1122
|
export declare const transformOn: DirectiveTransform;
|
|
1086
|
-
|
|
1123
|
+
//#endregion
|
|
1124
|
+
//#region temp/packages/compiler-core/src/transforms/vBind.d.ts
|
|
1087
1125
|
export declare const transformBind: DirectiveTransform;
|
|
1088
|
-
|
|
1126
|
+
//#endregion
|
|
1127
|
+
//#region temp/packages/compiler-core/src/transforms/noopDirectiveTransform.d.ts
|
|
1089
1128
|
export declare const noopDirectiveTransform: DirectiveTransform;
|
|
1090
|
-
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region temp/packages/compiler-core/src/transforms/vIf.d.ts
|
|
1091
1131
|
export declare function processIf(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (node: IfNode, branch: IfBranchNode, isRoot: boolean) => (() => void) | undefined): (() => void) | undefined;
|
|
1092
|
-
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region temp/packages/compiler-core/src/transforms/vFor.d.ts
|
|
1093
1134
|
export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
|
|
1094
|
-
export declare function createForLoopParams({
|
|
1095
|
-
|
|
1135
|
+
export declare function createForLoopParams({
|
|
1136
|
+
value,
|
|
1137
|
+
key,
|
|
1138
|
+
index
|
|
1139
|
+
}: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region temp/packages/compiler-core/src/transforms/transformExpression.d.ts
|
|
1096
1142
|
export declare const isLiteralWhitelisted: (key: string) => boolean;
|
|
1097
1143
|
export declare const transformExpression: NodeTransform;
|
|
1098
1144
|
export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean, localVars?: Record<string, number>): ExpressionNode;
|
|
1099
1145
|
export declare function stringifyExpression(exp: ExpressionNode | string): string;
|
|
1100
|
-
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region temp/packages/compiler-core/src/transforms/vSlot.d.ts
|
|
1101
1148
|
export declare const trackSlotScopes: NodeTransform;
|
|
1102
1149
|
export declare const trackVForSlotScopes: NodeTransform;
|
|
1103
1150
|
export type SlotFnBuilder = (slotProps: ExpressionNode | undefined, vFor: DirectiveNode | undefined, slotChildren: TemplateChildNode[], loc: SourceLocation) => FunctionExpression;
|
|
1104
1151
|
export declare function buildSlots(node: ElementNode, context: TransformContext, buildSlotFn?: SlotFnBuilder): {
|
|
1105
|
-
|
|
1106
|
-
|
|
1152
|
+
slots: SlotsExpression;
|
|
1153
|
+
hasDynamicSlots: boolean;
|
|
1107
1154
|
};
|
|
1108
|
-
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region temp/packages/compiler-core/src/transforms/transformVBindShorthand.d.ts
|
|
1109
1157
|
export declare const transformVBindShorthand: NodeTransform;
|
|
1110
|
-
|
|
1158
|
+
//#endregion
|
|
1159
|
+
//#region temp/packages/compiler-core/src/transforms/transformSlotOutlet.d.ts
|
|
1111
1160
|
interface SlotOutletProcessResult {
|
|
1112
|
-
|
|
1113
|
-
|
|
1161
|
+
slotName: string | ExpressionNode;
|
|
1162
|
+
slotProps: PropsExpression | undefined;
|
|
1114
1163
|
}
|
|
1115
1164
|
export declare function processSlotOutlet(node: SlotOutletNode, context: TransformContext): SlotOutletProcessResult;
|
|
1116
|
-
|
|
1165
|
+
//#endregion
|
|
1166
|
+
//#region temp/packages/compiler-core/src/transforms/cacheStatic.d.ts
|
|
1117
1167
|
export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode | CacheExpression, context: TransformContext): ConstantTypes;
|
|
1118
|
-
|
|
1119
|
-
|
|
1168
|
+
//#endregion
|
|
1169
|
+
export { generateCodeFrame, };
|