@vue/compiler-core 3.2.47 → 3.3.0-alpha.1

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