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