@vue/compiler-core 3.6.0-rc.1 → 3.6.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-core.cjs.js +285 -235
- package/dist/compiler-core.cjs.prod.js +271 -228
- package/dist/compiler-core.d.ts +253 -284
- package/dist/compiler-core.esm-bundler.js +195 -160
- package/package.json +5 -5
package/dist/compiler-core.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Namespace, Namespaces, PatchFlags, generateCodeFrame } from "@vue/shared";
|
|
2
2
|
import { BlockStatement as BlockStatement$1, Function, Identifier, Node as Node$1, ObjectProperty, Program, SwitchCase } from "@babel/types";
|
|
3
3
|
import { ParserPlugin } from "@babel/parser";
|
|
4
|
-
|
|
5
4
|
//#region temp/packages/compiler-core/src/runtimeHelpers.d.ts
|
|
6
5
|
export declare const FRAGMENT: unique symbol;
|
|
7
6
|
export declare const TELEPORT: unique symbol;
|
|
@@ -36,13 +35,13 @@ export declare const CAPITALIZE: unique symbol;
|
|
|
36
35
|
export declare const TO_HANDLER_KEY: unique symbol;
|
|
37
36
|
export declare const SET_BLOCK_TRACKING: unique symbol;
|
|
38
37
|
/**
|
|
39
|
-
* @deprecated no longer needed in 3.5+ because we no longer hoist element nodes
|
|
40
|
-
* but kept for backwards compat
|
|
41
|
-
*/
|
|
38
|
+
* @deprecated no longer needed in 3.5+ because we no longer hoist element nodes
|
|
39
|
+
* but kept for backwards compat
|
|
40
|
+
*/
|
|
42
41
|
export declare const PUSH_SCOPE_ID: unique symbol;
|
|
43
42
|
/**
|
|
44
|
-
* @deprecated kept for backwards compat
|
|
45
|
-
*/
|
|
43
|
+
* @deprecated kept for backwards compat
|
|
44
|
+
*/
|
|
46
45
|
export declare const POP_SCOPE_ID: unique symbol;
|
|
47
46
|
export declare const WITH_CTX: unique symbol;
|
|
48
47
|
export declare const UNREF: unique symbol;
|
|
@@ -134,31 +133,7 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
|
|
|
134
133
|
filters?: Set<string>;
|
|
135
134
|
}
|
|
136
135
|
export declare function getSelfName(filename: string): string | null;
|
|
137
|
-
export declare function createTransformContext(root: RootNode, {
|
|
138
|
-
filename,
|
|
139
|
-
prefixIdentifiers,
|
|
140
|
-
hoistStatic,
|
|
141
|
-
hmr,
|
|
142
|
-
cacheHandlers,
|
|
143
|
-
nodeTransforms,
|
|
144
|
-
directiveTransforms,
|
|
145
|
-
transformHoist,
|
|
146
|
-
isBuiltInComponent,
|
|
147
|
-
isCustomElement,
|
|
148
|
-
expressionPlugins,
|
|
149
|
-
scopeId,
|
|
150
|
-
slotted,
|
|
151
|
-
ssr,
|
|
152
|
-
inSSR,
|
|
153
|
-
ssrCssVars,
|
|
154
|
-
bindingMetadata,
|
|
155
|
-
inline,
|
|
156
|
-
isTS,
|
|
157
|
-
eventDelegation,
|
|
158
|
-
onError,
|
|
159
|
-
onWarn,
|
|
160
|
-
compatConfig
|
|
161
|
-
}: TransformOptions): TransformContext;
|
|
136
|
+
export declare function createTransformContext(root: RootNode, { filename, prefixIdentifiers, hoistStatic, hmr, cacheHandlers, nodeTransforms, directiveTransforms, transformHoist, isBuiltInComponent, isCustomElement, expressionPlugins, scopeId, slotted, ssr, inSSR, ssrCssVars, bindingMetadata, inline, isTS, onError, onWarn, compatConfig }: TransformOptions): TransformContext;
|
|
162
137
|
export declare function transform(root: RootNode, options: TransformOptions): void;
|
|
163
138
|
export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
|
|
164
139
|
export declare function createStructuralDirectiveTransform(name: string | RegExp, fn: StructuralDirectiveTransform): NodeTransform;
|
|
@@ -173,6 +148,8 @@ export declare function buildProps(node: ElementNode, context: TransformContext,
|
|
|
173
148
|
patchFlag: number;
|
|
174
149
|
dynamicPropNames: string[];
|
|
175
150
|
shouldUseBlock: boolean;
|
|
151
|
+
needsPatch: boolean;
|
|
152
|
+
isBlockRequired: boolean;
|
|
176
153
|
};
|
|
177
154
|
export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
|
|
178
155
|
//#endregion
|
|
@@ -293,27 +270,27 @@ export interface AttributeNode extends Node {
|
|
|
293
270
|
export interface DirectiveNode extends Node {
|
|
294
271
|
type: NodeTypes.DIRECTIVE;
|
|
295
272
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
273
|
+
* the normalized name without prefix or shorthands, e.g. "bind", "on"
|
|
274
|
+
*/
|
|
298
275
|
name: string;
|
|
299
276
|
/**
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
277
|
+
* the raw attribute name, preserving shorthand, and including arg & modifiers
|
|
278
|
+
* this is only used during parse.
|
|
279
|
+
*/
|
|
303
280
|
rawName?: string;
|
|
304
281
|
exp: ExpressionNode | undefined;
|
|
305
282
|
arg: ExpressionNode | undefined;
|
|
306
283
|
modifiers: SimpleExpressionNode[];
|
|
307
284
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
285
|
+
* optional property to cache the expression parse result for v-for
|
|
286
|
+
*/
|
|
310
287
|
forParseResult?: ForParseResult;
|
|
311
288
|
}
|
|
312
289
|
/**
|
|
313
|
-
* Static types have several levels.
|
|
314
|
-
* Higher levels implies lower levels. e.g. a node that can be stringified
|
|
315
|
-
* can always be hoisted and skipped for patch.
|
|
316
|
-
*/
|
|
290
|
+
* Static types have several levels.
|
|
291
|
+
* Higher levels implies lower levels. e.g. a node that can be stringified
|
|
292
|
+
* can always be hoisted and skipped for patch.
|
|
293
|
+
*/
|
|
317
294
|
export declare enum ConstantTypes {
|
|
318
295
|
NOT_CONSTANT = 0,
|
|
319
296
|
CAN_SKIP_PATCH = 1,
|
|
@@ -326,20 +303,20 @@ export interface SimpleExpressionNode extends Node {
|
|
|
326
303
|
isStatic: boolean;
|
|
327
304
|
constType: ConstantTypes;
|
|
328
305
|
/**
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
306
|
+
* - `null` means the expression is a simple identifier that doesn't need
|
|
307
|
+
* parsing
|
|
308
|
+
* - `false` means there was a parsing error
|
|
309
|
+
*/
|
|
333
310
|
ast?: Node$1 | null | false;
|
|
334
311
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
312
|
+
* Indicates this is an identifier for a hoist vnode call and points to the
|
|
313
|
+
* hoisted node.
|
|
314
|
+
*/
|
|
338
315
|
hoisted?: JSChildNode;
|
|
339
316
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
317
|
+
* an expression parsed as the params of a function will track
|
|
318
|
+
* the identifiers declared inside the function body.
|
|
319
|
+
*/
|
|
343
320
|
identifiers?: string[];
|
|
344
321
|
isHandlerKey?: boolean;
|
|
345
322
|
}
|
|
@@ -350,16 +327,16 @@ export interface InterpolationNode extends Node {
|
|
|
350
327
|
export interface CompoundExpressionNode extends Node {
|
|
351
328
|
type: NodeTypes.COMPOUND_EXPRESSION;
|
|
352
329
|
/**
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
330
|
+
* - `null` means the expression is a simple identifier that doesn't need
|
|
331
|
+
* parsing
|
|
332
|
+
* - `false` means there was a parsing error
|
|
333
|
+
*/
|
|
357
334
|
ast?: Node$1 | null | false;
|
|
358
335
|
children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string | symbol)[];
|
|
359
336
|
/**
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
337
|
+
* an expression parsed as the params of a function will track
|
|
338
|
+
* the identifiers declared inside the function body.
|
|
339
|
+
*/
|
|
363
340
|
identifiers?: string[];
|
|
364
341
|
isHandlerKey?: boolean;
|
|
365
342
|
}
|
|
@@ -406,6 +383,10 @@ export interface VNodeCall extends Node {
|
|
|
406
383
|
patchFlag: PatchFlags | undefined;
|
|
407
384
|
dynamicProps: string | SimpleExpressionNode | undefined;
|
|
408
385
|
directives: DirectiveArguments | undefined;
|
|
386
|
+
/** Whether this vnode must be patched if a later transform makes it non-block. */
|
|
387
|
+
needsPatch?: boolean;
|
|
388
|
+
/** Whether a later transform must preserve this vnode as a block. */
|
|
389
|
+
isBlockRequired?: boolean;
|
|
409
390
|
isBlock: boolean;
|
|
410
391
|
disableTracking: boolean;
|
|
411
392
|
isComponent: boolean;
|
|
@@ -436,14 +417,14 @@ export interface FunctionExpression extends Node {
|
|
|
436
417
|
body?: BlockStatement | IfStatement;
|
|
437
418
|
newline: boolean;
|
|
438
419
|
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
420
|
+
* This flag is for codegen to determine whether it needs to generate the
|
|
421
|
+
* withScopeId() wrapper
|
|
422
|
+
*/
|
|
442
423
|
isSlot: boolean;
|
|
443
424
|
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
425
|
+
* __COMPAT__ only, indicates a slot function that should be excluded from
|
|
426
|
+
* the legacy $scopedSlots instance property.
|
|
427
|
+
*/
|
|
447
428
|
isNonScopedSlot?: boolean;
|
|
448
429
|
}
|
|
449
430
|
export interface ConditionalExpression extends Node {
|
|
@@ -582,11 +563,7 @@ export declare function createSequenceExpression(expressions: SequenceExpression
|
|
|
582
563
|
export declare function createReturnStatement(returns: ReturnStatement["returns"]): ReturnStatement;
|
|
583
564
|
export declare function getVNodeHelper(ssr: boolean, isComponent: boolean): typeof CREATE_VNODE | typeof CREATE_ELEMENT_VNODE;
|
|
584
565
|
export declare function getVNodeBlockHelper(ssr: boolean, isComponent: boolean): typeof CREATE_BLOCK | typeof CREATE_ELEMENT_BLOCK;
|
|
585
|
-
export declare function convertToBlock(node: VNodeCall, {
|
|
586
|
-
helper,
|
|
587
|
-
removeHelper,
|
|
588
|
-
inSSR
|
|
589
|
-
}: TransformContext): void;
|
|
566
|
+
export declare function convertToBlock(node: VNodeCall, { helper, removeHelper, inSSR }: TransformContext): void;
|
|
590
567
|
//#endregion
|
|
591
568
|
//#region temp/packages/compiler-core/src/errors.d.ts
|
|
592
569
|
export interface CompilerError extends SyntaxError {
|
|
@@ -668,127 +645,127 @@ interface ErrorHandlingOptions {
|
|
|
668
645
|
}
|
|
669
646
|
export interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptions {
|
|
670
647
|
/**
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
648
|
+
* Base mode is platform agnostic and only parses HTML-like template syntax,
|
|
649
|
+
* treating all tags the same way. Specific tag parsing behavior can be
|
|
650
|
+
* configured by higher-level compilers.
|
|
651
|
+
*
|
|
652
|
+
* HTML mode adds additional logic for handling special parsing behavior in
|
|
653
|
+
* `<script>`, `<style>`,`<title>` and `<textarea>`.
|
|
654
|
+
* The logic is handled inside compiler-core for efficiency.
|
|
655
|
+
*
|
|
656
|
+
* SFC mode treats content of all root-level tags except `<template>` as plain
|
|
657
|
+
* text.
|
|
658
|
+
*/
|
|
682
659
|
parseMode?: "base" | "html" | "sfc";
|
|
683
660
|
/**
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
661
|
+
* Specify the root namespace to use when parsing a template.
|
|
662
|
+
* Defaults to `Namespaces.HTML` (0).
|
|
663
|
+
*/
|
|
687
664
|
ns?: Namespaces;
|
|
688
665
|
/**
|
|
689
|
-
|
|
690
|
-
|
|
666
|
+
* e.g. platform native elements, e.g. `<div>` for browsers
|
|
667
|
+
*/
|
|
691
668
|
isNativeTag?: (tag: string) => boolean;
|
|
692
669
|
/**
|
|
693
|
-
|
|
694
|
-
|
|
670
|
+
* e.g. native elements that can self-close, e.g. `<img>`, `<br>`, `<hr>`
|
|
671
|
+
*/
|
|
695
672
|
isVoidTag?: (tag: string) => boolean;
|
|
696
673
|
/**
|
|
697
|
-
|
|
698
|
-
|
|
674
|
+
* e.g. elements that should preserve whitespace inside, e.g. `<pre>`
|
|
675
|
+
*/
|
|
699
676
|
isPreTag?: (tag: string) => boolean;
|
|
700
677
|
/**
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
678
|
+
* Elements that should ignore the first newline token per parinsg spec
|
|
679
|
+
* e.g. `<textarea>` and `<pre>`
|
|
680
|
+
*/
|
|
704
681
|
isIgnoreNewlineTag?: (tag: string) => boolean;
|
|
705
682
|
/**
|
|
706
|
-
|
|
707
|
-
|
|
683
|
+
* Platform-specific built-in components e.g. `<Transition>`
|
|
684
|
+
*/
|
|
708
685
|
isBuiltInComponent?: (tag: string) => symbol | void;
|
|
709
686
|
/**
|
|
710
|
-
|
|
711
|
-
|
|
687
|
+
* Separate option for end users to extend the native elements list
|
|
688
|
+
*/
|
|
712
689
|
isCustomElement?: (tag: string) => boolean | void;
|
|
713
690
|
/**
|
|
714
|
-
|
|
715
|
-
|
|
691
|
+
* Get tag namespace
|
|
692
|
+
*/
|
|
716
693
|
getNamespace?: (tag: string, parent: ElementNode | undefined, rootNamespace: Namespace) => Namespace;
|
|
717
694
|
/**
|
|
718
|
-
|
|
719
|
-
|
|
695
|
+
* @default ['{{', '}}']
|
|
696
|
+
*/
|
|
720
697
|
delimiters?: [string, string];
|
|
721
698
|
/**
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
699
|
+
* Whitespace handling strategy
|
|
700
|
+
* @default 'condense'
|
|
701
|
+
*/
|
|
725
702
|
whitespace?: "preserve" | "condense";
|
|
726
703
|
/**
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
704
|
+
* Only used for DOM compilers that runs in the browser.
|
|
705
|
+
* In non-browser builds, this option is ignored.
|
|
706
|
+
*/
|
|
730
707
|
decodeEntities?: (rawText: string, asAttr: boolean) => string;
|
|
731
708
|
/**
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
709
|
+
* Whether to keep comments in the templates AST.
|
|
710
|
+
* This defaults to `true` in development and `false` in production builds.
|
|
711
|
+
*/
|
|
735
712
|
comments?: boolean;
|
|
736
713
|
/**
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
714
|
+
* Parse JavaScript expressions with Babel.
|
|
715
|
+
* @default false
|
|
716
|
+
*/
|
|
740
717
|
prefixIdentifiers?: boolean;
|
|
741
718
|
/**
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
719
|
+
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
720
|
+
* parse expressions in bindings and interpolations.
|
|
721
|
+
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
722
|
+
*/
|
|
746
723
|
expressionPlugins?: ParserPlugin[];
|
|
747
724
|
}
|
|
748
725
|
export type HoistTransform = (children: TemplateChildNode[], context: TransformContext, parent: ParentNode) => void;
|
|
749
726
|
export declare enum BindingTypes {
|
|
750
727
|
/**
|
|
751
|
-
|
|
752
|
-
|
|
728
|
+
* returned from data()
|
|
729
|
+
*/
|
|
753
730
|
DATA = "data",
|
|
754
731
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
732
|
+
* declared as a prop
|
|
733
|
+
*/
|
|
757
734
|
PROPS = "props",
|
|
758
735
|
/**
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
736
|
+
* a local alias of a `<script setup>` destructured prop.
|
|
737
|
+
* the original is stored in __propsAliases of the bindingMetadata object.
|
|
738
|
+
*/
|
|
762
739
|
PROPS_ALIASED = "props-aliased",
|
|
763
740
|
/**
|
|
764
|
-
|
|
765
|
-
|
|
741
|
+
* a let binding (may or may not be a ref)
|
|
742
|
+
*/
|
|
766
743
|
SETUP_LET = "setup-let",
|
|
767
744
|
/**
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
745
|
+
* a const binding that can never be a ref.
|
|
746
|
+
* these bindings don't need `unref()` calls when processed in inlined
|
|
747
|
+
* template expressions.
|
|
748
|
+
*/
|
|
772
749
|
SETUP_CONST = "setup-const",
|
|
773
750
|
/**
|
|
774
|
-
|
|
775
|
-
|
|
751
|
+
* a const binding that does not need `unref()`, but may be mutated.
|
|
752
|
+
*/
|
|
776
753
|
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
|
777
754
|
/**
|
|
778
|
-
|
|
779
|
-
|
|
755
|
+
* a const binding that may be a ref.
|
|
756
|
+
*/
|
|
780
757
|
SETUP_MAYBE_REF = "setup-maybe-ref",
|
|
781
758
|
/**
|
|
782
|
-
|
|
783
|
-
|
|
759
|
+
* bindings that are guaranteed to be refs
|
|
760
|
+
*/
|
|
784
761
|
SETUP_REF = "setup-ref",
|
|
785
762
|
/**
|
|
786
|
-
|
|
787
|
-
|
|
763
|
+
* declared by other options, e.g. computed, inject
|
|
764
|
+
*/
|
|
788
765
|
OPTIONS = "options",
|
|
789
766
|
/**
|
|
790
|
-
|
|
791
|
-
|
|
767
|
+
* a literal constant, e.g. 'foo', 1, true
|
|
768
|
+
*/
|
|
792
769
|
LITERAL_CONST = "literal-const"
|
|
793
770
|
}
|
|
794
771
|
export type BindingMetadata = {
|
|
@@ -799,198 +776,194 @@ export type BindingMetadata = {
|
|
|
799
776
|
};
|
|
800
777
|
interface SharedTransformCodegenOptions {
|
|
801
778
|
/**
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
779
|
+
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
|
780
|
+
* If this option is false, the generated code will be wrapped in a
|
|
781
|
+
* `with (this) { ... }` block.
|
|
782
|
+
* - This is force-enabled in module mode, since modules are by default strict
|
|
783
|
+
* and cannot use `with`
|
|
784
|
+
* @default mode === 'module'
|
|
785
|
+
*/
|
|
809
786
|
prefixIdentifiers?: boolean;
|
|
810
787
|
/**
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
788
|
+
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
789
|
+
* parse expressions in bindings and interpolations.
|
|
790
|
+
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
791
|
+
*/
|
|
815
792
|
expressionPlugins?: ParserPlugin[];
|
|
816
793
|
/**
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
794
|
+
* Control whether generate SSR-optimized render functions instead.
|
|
795
|
+
* The resulting function must be attached to the component via the
|
|
796
|
+
* `ssrRender` option instead of `render`.
|
|
797
|
+
*
|
|
798
|
+
* When compiler generates code for SSR's fallback branch, we need to set it to false:
|
|
799
|
+
* - context.ssr = false
|
|
800
|
+
*
|
|
801
|
+
* see `subTransform` in `ssrTransformComponent.ts`
|
|
802
|
+
*/
|
|
826
803
|
ssr?: boolean;
|
|
827
804
|
/**
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
805
|
+
* Indicates whether the compiler generates code for SSR,
|
|
806
|
+
* it is always true when generating code for SSR,
|
|
807
|
+
* regardless of whether we are generating code for SSR's fallback branch,
|
|
808
|
+
* this means that when the compiler generates code for SSR's fallback branch:
|
|
809
|
+
* - context.ssr = false
|
|
810
|
+
* - context.inSSR = true
|
|
811
|
+
*/
|
|
835
812
|
inSSR?: boolean;
|
|
836
813
|
/**
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
814
|
+
* Optional binding metadata analyzed from script - used to optimize
|
|
815
|
+
* binding access when `prefixIdentifiers` is enabled.
|
|
816
|
+
*/
|
|
840
817
|
bindingMetadata?: BindingMetadata;
|
|
841
818
|
/**
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
819
|
+
* Compile the function for inlining inside setup().
|
|
820
|
+
* This allows the function to directly access setup() local bindings.
|
|
821
|
+
*/
|
|
845
822
|
inline?: boolean;
|
|
846
823
|
/**
|
|
847
|
-
|
|
848
|
-
|
|
824
|
+
* Indicates that transforms and codegen should try to output valid TS code
|
|
825
|
+
*/
|
|
849
826
|
isTS?: boolean;
|
|
850
827
|
/**
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
828
|
+
* Filename for source map generation.
|
|
829
|
+
* Also used for self-recursive reference in templates
|
|
830
|
+
* @default 'template.vue.html'
|
|
831
|
+
*/
|
|
855
832
|
filename?: string;
|
|
856
833
|
}
|
|
857
834
|
export interface TransformOptions extends SharedTransformCodegenOptions, ErrorHandlingOptions, CompilerCompatOptions {
|
|
858
835
|
/**
|
|
859
|
-
|
|
860
|
-
|
|
836
|
+
* An array of node transforms to be applied to every AST node.
|
|
837
|
+
*/
|
|
861
838
|
nodeTransforms?: NodeTransform[];
|
|
862
839
|
/**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
840
|
+
* An object of { name: transform } to be applied to every directive attribute
|
|
841
|
+
* node found on element nodes.
|
|
842
|
+
*/
|
|
866
843
|
directiveTransforms?: Record<string, DirectiveTransform | undefined>;
|
|
867
844
|
/**
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
845
|
+
* An optional hook to transform a node being hoisted.
|
|
846
|
+
* used by compiler-dom to turn hoisted nodes into stringified HTML vnodes.
|
|
847
|
+
* @default null
|
|
848
|
+
*/
|
|
872
849
|
transformHoist?: HoistTransform | null;
|
|
873
850
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
851
|
+
* If the pairing runtime provides additional built-in elements, use this to
|
|
852
|
+
* mark them as built-in so the compiler will generate component vnodes
|
|
853
|
+
* for them.
|
|
854
|
+
*/
|
|
878
855
|
isBuiltInComponent?: (tag: string) => symbol | void;
|
|
879
856
|
/**
|
|
880
|
-
|
|
881
|
-
|
|
857
|
+
* Used by some transforms that expects only native elements
|
|
858
|
+
*/
|
|
882
859
|
isCustomElement?: (tag: string) => boolean | void;
|
|
883
860
|
/**
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
861
|
+
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
|
862
|
+
* If this option is false, the generated code will be wrapped in a
|
|
863
|
+
* `with (this) { ... }` block.
|
|
864
|
+
* - This is force-enabled in module mode, since modules are by default strict
|
|
865
|
+
* and cannot use `with`
|
|
866
|
+
* @default mode === 'module'
|
|
867
|
+
*/
|
|
891
868
|
prefixIdentifiers?: boolean;
|
|
892
869
|
/**
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
870
|
+
* Cache static VNodes and props objects to `_hoisted_x` constants
|
|
871
|
+
* @default false
|
|
872
|
+
*/
|
|
896
873
|
hoistStatic?: boolean;
|
|
897
874
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
875
|
+
* Cache v-on handlers to avoid creating new inline functions on each render,
|
|
876
|
+
* also avoids the need for dynamically patching the handlers by wrapping it.
|
|
877
|
+
* e.g `@click="foo"` by default is compiled to `{ onClick: foo }`. With this
|
|
878
|
+
* option it's compiled to:
|
|
879
|
+
* ```js
|
|
880
|
+
* { onClick: _cache[0] || (_cache[0] = e => _ctx.foo(e)) }
|
|
881
|
+
* ```
|
|
882
|
+
* - Requires "prefixIdentifiers" to be enabled because it relies on scope
|
|
883
|
+
* analysis to determine if a handler is safe to cache.
|
|
884
|
+
* @default false
|
|
885
|
+
*/
|
|
909
886
|
cacheHandlers?: boolean;
|
|
910
887
|
/**
|
|
911
|
-
|
|
912
|
-
|
|
888
|
+
* SFC scoped styles ID
|
|
889
|
+
*/
|
|
913
890
|
scopeId?: string | null;
|
|
914
891
|
/**
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
892
|
+
* Indicates this SFC template has used :slotted in its styles
|
|
893
|
+
* Defaults to `true` for backwards compatibility - SFC tooling should set it
|
|
894
|
+
* to `false` if no `:slotted` usage is detected in `<style>`
|
|
895
|
+
*/
|
|
919
896
|
slotted?: boolean;
|
|
920
897
|
/**
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
898
|
+
* SFC `<style vars>` injection string
|
|
899
|
+
* Should already be an object expression, e.g. `{ 'xxxx-color': color }`
|
|
900
|
+
* needed to render inline CSS variables on component root
|
|
901
|
+
*/
|
|
925
902
|
ssrCssVars?: string;
|
|
926
903
|
/**
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
904
|
+
* Whether to compile the template assuming it needs to handle HMR.
|
|
905
|
+
* Some edge cases may need to generate different code for HMR to work
|
|
906
|
+
* correctly, e.g. #6938, #7138
|
|
907
|
+
*/
|
|
931
908
|
hmr?: boolean;
|
|
932
|
-
/**
|
|
933
|
-
* Vapor only: control whether eligible static DOM events are compiled to
|
|
934
|
-
* document-level delegated events.
|
|
935
|
-
* @default true
|
|
936
|
-
*/
|
|
937
|
-
eventDelegation?: boolean;
|
|
938
909
|
}
|
|
939
910
|
export interface CodegenOptions extends SharedTransformCodegenOptions {
|
|
940
911
|
/**
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
912
|
+
* - `module` mode will generate ES module import statements for helpers
|
|
913
|
+
* and export the render function as the default export.
|
|
914
|
+
* - `function` mode will generate a single `const { helpers... } = Vue`
|
|
915
|
+
* statement and return the render function. It expects `Vue` to be globally
|
|
916
|
+
* available (or passed by wrapping the code with an IIFE). It is meant to be
|
|
917
|
+
* used with `new Function(code)()` to generate a render function at runtime.
|
|
918
|
+
* @default 'function'
|
|
919
|
+
*/
|
|
949
920
|
mode?: "module" | "function";
|
|
950
921
|
/**
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
922
|
+
* Generate source map?
|
|
923
|
+
* @default false
|
|
924
|
+
*/
|
|
954
925
|
sourceMap?: boolean;
|
|
955
926
|
/**
|
|
956
|
-
|
|
957
|
-
|
|
927
|
+
* SFC scoped styles ID
|
|
928
|
+
*/
|
|
958
929
|
scopeId?: string | null;
|
|
959
930
|
/**
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
931
|
+
* Option to optimize helper import bindings via variable assignment
|
|
932
|
+
* (only used for webpack code-split)
|
|
933
|
+
* @default false
|
|
934
|
+
*/
|
|
964
935
|
optimizeImports?: boolean;
|
|
965
936
|
/**
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
937
|
+
* Customize where to import runtime helpers from.
|
|
938
|
+
* @default 'vue'
|
|
939
|
+
*/
|
|
969
940
|
runtimeModuleName?: string;
|
|
970
941
|
/**
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
942
|
+
* Customize where to import ssr runtime helpers from/**
|
|
943
|
+
* @default 'vue/server-renderer'
|
|
944
|
+
*/
|
|
974
945
|
ssrRuntimeModuleName?: string;
|
|
975
946
|
/**
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
947
|
+
* Customize the global variable name of `Vue` to get helpers from
|
|
948
|
+
* in function mode
|
|
949
|
+
* @default 'Vue'
|
|
950
|
+
*/
|
|
980
951
|
runtimeGlobalName?: string;
|
|
981
952
|
}
|
|
982
|
-
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions
|
|
953
|
+
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions & {
|
|
954
|
+
vapor?: boolean;
|
|
955
|
+
};
|
|
983
956
|
//#endregion
|
|
984
957
|
//#region temp/packages/compiler-core/src/codegen.d.ts
|
|
985
958
|
/**
|
|
986
|
-
* The `SourceMapGenerator` type from `source-map-js` is a bit incomplete as it
|
|
987
|
-
* misses `toJSON()`. We also need to add types for internal properties which we
|
|
988
|
-
* need to access for better performance.
|
|
989
|
-
*
|
|
990
|
-
* Since TS 5.3, dts generation starts to strangely include broken triple slash
|
|
991
|
-
* references for source-map-js, so we are inlining all source map related types
|
|
992
|
-
* here to workaround that.
|
|
993
|
-
*/
|
|
959
|
+
* The `SourceMapGenerator` type from `source-map-js` is a bit incomplete as it
|
|
960
|
+
* misses `toJSON()`. We also need to add types for internal properties which we
|
|
961
|
+
* need to access for better performance.
|
|
962
|
+
*
|
|
963
|
+
* Since TS 5.3, dts generation starts to strangely include broken triple slash
|
|
964
|
+
* references for source-map-js, so we are inlining all source map related types
|
|
965
|
+
* here to workaround that.
|
|
966
|
+
*/
|
|
994
967
|
export interface CodegenSourceMapGenerator {
|
|
995
968
|
setSourceContent(sourceFile: string, sourceContent: string): void;
|
|
996
969
|
toJSON(): RawSourceMap;
|
|
@@ -1068,11 +1041,11 @@ export declare function isCoreComponent(tag: string): symbol | void;
|
|
|
1068
1041
|
export declare const isSimpleIdentifier: (name: string) => boolean;
|
|
1069
1042
|
export declare const validFirstIdentCharRE: RegExp;
|
|
1070
1043
|
/**
|
|
1071
|
-
* Simple lexer to check if an expression is a member expression. This is
|
|
1072
|
-
* lax and only checks validity at the root level (i.e. does not validate exps
|
|
1073
|
-
* inside square brackets), but it's ok since these are only used on template
|
|
1074
|
-
* expressions and false positives are invalid expressions in the first place.
|
|
1075
|
-
*/
|
|
1044
|
+
* Simple lexer to check if an expression is a member expression. This is
|
|
1045
|
+
* lax and only checks validity at the root level (i.e. does not validate exps
|
|
1046
|
+
* inside square brackets), but it's ok since these are only used on template
|
|
1047
|
+
* expressions and false positives are invalid expressions in the first place.
|
|
1048
|
+
*/
|
|
1076
1049
|
export declare const isMemberExpressionBrowser: (exp: ExpressionNode) => boolean;
|
|
1077
1050
|
export declare const isMemberExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
1078
1051
|
export declare const isMemberExpression: (exp: ExpressionNode, context: Pick<TransformContext, "expressionPlugins">) => boolean;
|
|
@@ -1106,8 +1079,8 @@ export declare function isCommentOrWhitespace(node: TemplateChildNode): boolean;
|
|
|
1106
1079
|
//#endregion
|
|
1107
1080
|
//#region temp/packages/compiler-core/src/babelUtils.d.ts
|
|
1108
1081
|
/**
|
|
1109
|
-
* Return value indicates whether the AST walked can be a constant
|
|
1110
|
-
*/
|
|
1082
|
+
* Return value indicates whether the AST walked can be a constant
|
|
1083
|
+
*/
|
|
1111
1084
|
export declare function walkIdentifiers(root: Node$1, onIdentifier: (node: Identifier, parent: Node$1 | null, parentStack: Node$1[], isReference: boolean, isLocal: boolean) => void, includeAll?: boolean, parentStack?: Node$1[], knownIds?: Record<string, number>): void;
|
|
1112
1085
|
export declare function isReferencedIdentifier(id: Identifier, parent: Node$1 | null, parentStack: Node$1[]): boolean;
|
|
1113
1086
|
export declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
|
|
@@ -1140,11 +1113,7 @@ export declare function processIf(node: ElementNode, dir: DirectiveNode, context
|
|
|
1140
1113
|
//#endregion
|
|
1141
1114
|
//#region temp/packages/compiler-core/src/transforms/vFor.d.ts
|
|
1142
1115
|
export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
|
|
1143
|
-
export declare function createForLoopParams({
|
|
1144
|
-
value,
|
|
1145
|
-
key,
|
|
1146
|
-
index
|
|
1147
|
-
}: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
|
|
1116
|
+
export declare function createForLoopParams({ value, key, index }: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
|
|
1148
1117
|
//#endregion
|
|
1149
1118
|
//#region temp/packages/compiler-core/src/transforms/transformExpression.d.ts
|
|
1150
1119
|
export declare const isLiteralWhitelisted: (key: string) => boolean;
|
|
@@ -1174,4 +1143,4 @@ export declare function processSlotOutlet(node: SlotOutletNode, context: Transfo
|
|
|
1174
1143
|
//#region temp/packages/compiler-core/src/transforms/cacheStatic.d.ts
|
|
1175
1144
|
export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode | CacheExpression, context: TransformContext): ConstantTypes;
|
|
1176
1145
|
//#endregion
|
|
1177
|
-
export { generateCodeFrame
|
|
1146
|
+
export { generateCodeFrame };
|