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