@vue/compiler-core 3.3.0-alpha.5 → 3.3.0-alpha.7

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.
@@ -2827,7 +2827,7 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
2827
2827
  estreeWalker.walk(root, {
2828
2828
  enter(node, parent) {
2829
2829
  parent && parentStack.push(parent);
2830
- if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
2830
+ if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
2831
2831
  return this.skip();
2832
2832
  }
2833
2833
  if (node.type === "Identifier") {
@@ -2971,6 +2971,13 @@ const isFunctionType = (node) => {
2971
2971
  };
2972
2972
  const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
2973
2973
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
2974
+ function getImportedName(specifier) {
2975
+ if (specifier.type === "ImportSpecifier")
2976
+ return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
2977
+ else if (specifier.type === "ImportNamespaceSpecifier")
2978
+ return "*";
2979
+ return "default";
2980
+ }
2974
2981
  function isReferenced(node, parent, grandparent) {
2975
2982
  switch (parent.type) {
2976
2983
  case "MemberExpression":
@@ -3058,6 +3065,28 @@ function isReferenced(node, parent, grandparent) {
3058
3065
  }
3059
3066
  return true;
3060
3067
  }
3068
+ const TS_NODE_TYPES = [
3069
+ "TSAsExpression",
3070
+ // foo as number
3071
+ "TSTypeAssertion",
3072
+ // (<number>foo)
3073
+ "TSNonNullExpression",
3074
+ // foo!
3075
+ "TSInstantiationExpression",
3076
+ // foo<string>
3077
+ "TSSatisfiesExpression"
3078
+ // foo satisfies T
3079
+ ];
3080
+ function unwrapTSNode(node) {
3081
+ if (TS_NODE_TYPES.includes(node.type)) {
3082
+ return unwrapTSNode(node.expression);
3083
+ } else {
3084
+ return node;
3085
+ }
3086
+ }
3087
+ function isCallOf(node, test) {
3088
+ return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
3089
+ }
3061
3090
 
3062
3091
  const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
3063
3092
  const transformExpression = (node, context) => {
@@ -3098,7 +3127,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3098
3127
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
3099
3128
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
3100
3129
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
3101
- if (type === "setup-const" || type === "setup-reactive-const" || localVars[raw]) {
3130
+ if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
3102
3131
  return raw;
3103
3132
  } else if (type === "setup-ref") {
3104
3133
  return `${raw}.value`;
@@ -3142,6 +3171,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3142
3171
  return `$setup.${raw}`;
3143
3172
  } else if (type === "props-aliased") {
3144
3173
  return `$props['${bindingMetadata.__propsAliases[raw]}']`;
3174
+ } else if (type === "literal-const") {
3175
+ return raw;
3145
3176
  } else if (type) {
3146
3177
  return `$${type}.${raw}`;
3147
3178
  }
@@ -3155,7 +3186,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3155
3186
  const isAllowedGlobal = shared.isGloballyWhitelisted(rawExp);
3156
3187
  const isLiteral = isLiteralWhitelisted(rawExp);
3157
3188
  if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
3158
- if (bindingMetadata[node.content] === "setup-const") {
3189
+ if (isConst(bindingMetadata[node.content])) {
3159
3190
  node.constType = 1;
3160
3191
  }
3161
3192
  node.content = rewriteIdentifier(rawExp);
@@ -3271,6 +3302,9 @@ function stringifyExpression(exp) {
3271
3302
  return exp.children.map(stringifyExpression).join("");
3272
3303
  }
3273
3304
  }
3305
+ function isConst(type) {
3306
+ return type === "setup-const" || type === "literal-const";
3307
+ }
3274
3308
 
3275
3309
  const transformIf = createStructuralDirectiveTransform(
3276
3310
  /^(if|else|else-if)$/,
@@ -4239,7 +4273,7 @@ function resolveSetupReference(name, context) {
4239
4273
  return PascalName;
4240
4274
  }
4241
4275
  };
4242
- const fromConst = checkType("setup-const") || checkType("setup-reactive-const");
4276
+ const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
4243
4277
  if (fromConst) {
4244
4278
  return context.inline ? (
4245
4279
  // in inline mode, const setup bindings (e.g. imports) can be used as-is
@@ -5360,6 +5394,7 @@ exports.TELEPORT = TELEPORT;
5360
5394
  exports.TO_DISPLAY_STRING = TO_DISPLAY_STRING;
5361
5395
  exports.TO_HANDLERS = TO_HANDLERS;
5362
5396
  exports.TO_HANDLER_KEY = TO_HANDLER_KEY;
5397
+ exports.TS_NODE_TYPES = TS_NODE_TYPES;
5363
5398
  exports.UNREF = UNREF;
5364
5399
  exports.WITH_CTX = WITH_CTX;
5365
5400
  exports.WITH_DIRECTIVES = WITH_DIRECTIVES;
@@ -5402,6 +5437,7 @@ exports.findProp = findProp;
5402
5437
  exports.generate = generate;
5403
5438
  exports.getBaseTransformPreset = getBaseTransformPreset;
5404
5439
  exports.getConstantType = getConstantType;
5440
+ exports.getImportedName = getImportedName;
5405
5441
  exports.getInnerRange = getInnerRange;
5406
5442
  exports.getMemoedVNodeCall = getMemoedVNodeCall;
5407
5443
  exports.getVNodeBlockHelper = getVNodeBlockHelper;
@@ -5411,6 +5447,7 @@ exports.hasScopeRef = hasScopeRef;
5411
5447
  exports.helperNameMap = helperNameMap;
5412
5448
  exports.injectProp = injectProp;
5413
5449
  exports.isBuiltInType = isBuiltInType;
5450
+ exports.isCallOf = isCallOf;
5414
5451
  exports.isCoreComponent = isCoreComponent;
5415
5452
  exports.isFunctionType = isFunctionType;
5416
5453
  exports.isInDestructureAssignment = isInDestructureAssignment;
@@ -5446,6 +5483,7 @@ exports.transformExpression = transformExpression;
5446
5483
  exports.transformModel = transformModel;
5447
5484
  exports.transformOn = transformOn;
5448
5485
  exports.traverseNode = traverseNode;
5486
+ exports.unwrapTSNode = unwrapTSNode;
5449
5487
  exports.walkBlockDeclarations = walkBlockDeclarations;
5450
5488
  exports.walkFunctionParams = walkFunctionParams;
5451
5489
  exports.walkIdentifiers = walkIdentifiers;
@@ -2756,7 +2756,7 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
2756
2756
  estreeWalker.walk(root, {
2757
2757
  enter(node, parent) {
2758
2758
  parent && parentStack.push(parent);
2759
- if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
2759
+ if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
2760
2760
  return this.skip();
2761
2761
  }
2762
2762
  if (node.type === "Identifier") {
@@ -2900,6 +2900,13 @@ const isFunctionType = (node) => {
2900
2900
  };
2901
2901
  const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
2902
2902
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
2903
+ function getImportedName(specifier) {
2904
+ if (specifier.type === "ImportSpecifier")
2905
+ return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
2906
+ else if (specifier.type === "ImportNamespaceSpecifier")
2907
+ return "*";
2908
+ return "default";
2909
+ }
2903
2910
  function isReferenced(node, parent, grandparent) {
2904
2911
  switch (parent.type) {
2905
2912
  case "MemberExpression":
@@ -2987,6 +2994,28 @@ function isReferenced(node, parent, grandparent) {
2987
2994
  }
2988
2995
  return true;
2989
2996
  }
2997
+ const TS_NODE_TYPES = [
2998
+ "TSAsExpression",
2999
+ // foo as number
3000
+ "TSTypeAssertion",
3001
+ // (<number>foo)
3002
+ "TSNonNullExpression",
3003
+ // foo!
3004
+ "TSInstantiationExpression",
3005
+ // foo<string>
3006
+ "TSSatisfiesExpression"
3007
+ // foo satisfies T
3008
+ ];
3009
+ function unwrapTSNode(node) {
3010
+ if (TS_NODE_TYPES.includes(node.type)) {
3011
+ return unwrapTSNode(node.expression);
3012
+ } else {
3013
+ return node;
3014
+ }
3015
+ }
3016
+ function isCallOf(node, test) {
3017
+ return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
3018
+ }
2990
3019
 
2991
3020
  const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
2992
3021
  const transformExpression = (node, context) => {
@@ -3027,7 +3056,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3027
3056
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
3028
3057
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
3029
3058
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
3030
- if (type === "setup-const" || type === "setup-reactive-const" || localVars[raw]) {
3059
+ if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
3031
3060
  return raw;
3032
3061
  } else if (type === "setup-ref") {
3033
3062
  return `${raw}.value`;
@@ -3071,6 +3100,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3071
3100
  return `$setup.${raw}`;
3072
3101
  } else if (type === "props-aliased") {
3073
3102
  return `$props['${bindingMetadata.__propsAliases[raw]}']`;
3103
+ } else if (type === "literal-const") {
3104
+ return raw;
3074
3105
  } else if (type) {
3075
3106
  return `$${type}.${raw}`;
3076
3107
  }
@@ -3084,7 +3115,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
3084
3115
  const isAllowedGlobal = shared.isGloballyWhitelisted(rawExp);
3085
3116
  const isLiteral = isLiteralWhitelisted(rawExp);
3086
3117
  if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
3087
- if (bindingMetadata[node.content] === "setup-const") {
3118
+ if (isConst(bindingMetadata[node.content])) {
3088
3119
  node.constType = 1;
3089
3120
  }
3090
3121
  node.content = rewriteIdentifier(rawExp);
@@ -3200,6 +3231,9 @@ function stringifyExpression(exp) {
3200
3231
  return exp.children.map(stringifyExpression).join("");
3201
3232
  }
3202
3233
  }
3234
+ function isConst(type) {
3235
+ return type === "setup-const" || type === "literal-const";
3236
+ }
3203
3237
 
3204
3238
  const transformIf = createStructuralDirectiveTransform(
3205
3239
  /^(if|else|else-if)$/,
@@ -4144,7 +4178,7 @@ function resolveSetupReference(name, context) {
4144
4178
  return PascalName;
4145
4179
  }
4146
4180
  };
4147
- const fromConst = checkType("setup-const") || checkType("setup-reactive-const");
4181
+ const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
4148
4182
  if (fromConst) {
4149
4183
  return context.inline ? (
4150
4184
  // in inline mode, const setup bindings (e.g. imports) can be used as-is
@@ -5239,6 +5273,7 @@ exports.TELEPORT = TELEPORT;
5239
5273
  exports.TO_DISPLAY_STRING = TO_DISPLAY_STRING;
5240
5274
  exports.TO_HANDLERS = TO_HANDLERS;
5241
5275
  exports.TO_HANDLER_KEY = TO_HANDLER_KEY;
5276
+ exports.TS_NODE_TYPES = TS_NODE_TYPES;
5242
5277
  exports.UNREF = UNREF;
5243
5278
  exports.WITH_CTX = WITH_CTX;
5244
5279
  exports.WITH_DIRECTIVES = WITH_DIRECTIVES;
@@ -5281,6 +5316,7 @@ exports.findProp = findProp;
5281
5316
  exports.generate = generate;
5282
5317
  exports.getBaseTransformPreset = getBaseTransformPreset;
5283
5318
  exports.getConstantType = getConstantType;
5319
+ exports.getImportedName = getImportedName;
5284
5320
  exports.getInnerRange = getInnerRange;
5285
5321
  exports.getMemoedVNodeCall = getMemoedVNodeCall;
5286
5322
  exports.getVNodeBlockHelper = getVNodeBlockHelper;
@@ -5290,6 +5326,7 @@ exports.hasScopeRef = hasScopeRef;
5290
5326
  exports.helperNameMap = helperNameMap;
5291
5327
  exports.injectProp = injectProp;
5292
5328
  exports.isBuiltInType = isBuiltInType;
5329
+ exports.isCallOf = isCallOf;
5293
5330
  exports.isCoreComponent = isCoreComponent;
5294
5331
  exports.isFunctionType = isFunctionType;
5295
5332
  exports.isInDestructureAssignment = isInDestructureAssignment;
@@ -5325,6 +5362,7 @@ exports.transformExpression = transformExpression;
5325
5362
  exports.transformModel = transformModel;
5326
5363
  exports.transformOn = transformOn;
5327
5364
  exports.traverseNode = traverseNode;
5365
+ exports.unwrapTSNode = unwrapTSNode;
5328
5366
  exports.walkBlockDeclarations = walkBlockDeclarations;
5329
5367
  exports.walkFunctionParams = walkFunctionParams;
5330
5368
  exports.walkIdentifiers = walkIdentifiers;
@@ -1,18 +1,18 @@
1
1
  import { ParserPlugin } from '@babel/parser';
2
2
  import { RawSourceMap, SourceMapGenerator } from 'source-map';
3
- import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty } from '@babel/types';
3
+ import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, CallExpression as CallExpression$1 } from '@babel/types';
4
4
  export { generateCodeFrame } from '@vue/shared';
5
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 {
6
+ type OptionalOptions = 'whitespace' | 'isNativeTag' | 'isBuiltInComponent' | keyof CompilerCompatOptions;
7
+ type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> & Pick<ParserOptions, OptionalOptions>;
8
+ export declare const enum TextModes {
9
9
  DATA = 0,
10
10
  RCDATA = 1,
11
11
  RAWTEXT = 2,
12
12
  CDATA = 3,
13
13
  ATTRIBUTE_VALUE = 4
14
14
  }
15
- export interface ParserContext {
15
+ interface ParserContext {
16
16
  options: MergedParserOptions;
17
17
  readonly originalSource: string;
18
18
  source: string;
@@ -23,15 +23,15 @@ export interface ParserContext {
23
23
  inVPre: boolean;
24
24
  onWarn: NonNullable<ErrorHandlingOptions['onWarn']>;
25
25
  }
26
- declare function baseParse(content: string, options?: ParserOptions): RootNode;
26
+ export declare function baseParse(content: string, options?: ParserOptions): RootNode;
27
27
 
28
- export type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>> & {
28
+ type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>> & {
29
29
  MODE?: 2 | 3;
30
30
  };
31
- export interface CompilerCompatOptions {
31
+ interface CompilerCompatOptions {
32
32
  compatConfig?: CompilerCompatConfig;
33
33
  }
34
- declare const enum CompilerDeprecationTypes {
34
+ export declare const enum CompilerDeprecationTypes {
35
35
  COMPILER_IS_ON_ELEMENT = "COMPILER_IS_ON_ELEMENT",
36
36
  COMPILER_V_BIND_SYNC = "COMPILER_V_BIND_SYNC",
37
37
  COMPILER_V_BIND_PROP = "COMPILER_V_BIND_PROP",
@@ -42,18 +42,18 @@ declare const enum CompilerDeprecationTypes {
42
42
  COMPILER_INLINE_TEMPLATE = "COMPILER_INLINE_TEMPLATE",
43
43
  COMPILER_FILTERS = "COMPILER_FILTER"
44
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;
45
+ export declare function checkCompatEnabled(key: CompilerDeprecationTypes, context: ParserContext | TransformContext, loc: SourceLocation | null, ...args: any[]): boolean;
46
+ export declare function warnDeprecation(key: CompilerDeprecationTypes, context: ParserContext | TransformContext, loc: SourceLocation | null, ...args: any[]): void;
47
47
 
48
48
  export type NodeTransform = (node: RootNode | TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[];
49
49
  export type DirectiveTransform = (dir: DirectiveNode, node: ElementNode, context: TransformContext, augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult) => DirectiveTransformResult;
50
- export interface DirectiveTransformResult {
50
+ interface DirectiveTransformResult {
51
51
  props: Property[];
52
52
  needRuntime?: boolean | symbol;
53
53
  ssrTagParts?: TemplateLiteral['elements'];
54
54
  }
55
55
  export type StructuralDirectiveTransform = (node: ElementNode, dir: DirectiveNode, context: TransformContext) => void | (() => void);
56
- export interface ImportItem {
56
+ interface ImportItem {
57
57
  exp: string | ExpressionNode;
58
58
  path: string;
59
59
  }
@@ -93,79 +93,79 @@ export interface TransformContext extends Required<Omit<TransformOptions, 'filen
93
93
  constantCache: Map<TemplateChildNode, ConstantTypes>;
94
94
  filters?: Set<string>;
95
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;
96
+ 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;
97
+ export declare function transform(root: RootNode, options: TransformOptions): void;
98
+ export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
99
+ export declare function createStructuralDirectiveTransform(name: string | RegExp, fn: StructuralDirectiveTransform): NodeTransform;
100
100
 
101
- declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
102
- export interface ForParseResult {
101
+ export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
102
+ interface ForParseResult {
103
103
  source: ExpressionNode;
104
104
  value: ExpressionNode | undefined;
105
105
  key: ExpressionNode | undefined;
106
106
  index: ExpressionNode | undefined;
107
107
  }
108
- declare function createForLoopParams({ value, key, index }: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
108
+ export declare function createForLoopParams({ value, key, index }: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
109
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;
110
+ export declare const FRAGMENT: unique symbol;
111
+ export declare const TELEPORT: unique symbol;
112
+ export declare const SUSPENSE: unique symbol;
113
+ export declare const KEEP_ALIVE: unique symbol;
114
+ export declare const BASE_TRANSITION: unique symbol;
115
+ export declare const OPEN_BLOCK: unique symbol;
116
+ export declare const CREATE_BLOCK: unique symbol;
117
+ export declare const CREATE_ELEMENT_BLOCK: unique symbol;
118
+ export declare const CREATE_VNODE: unique symbol;
119
+ export declare const CREATE_ELEMENT_VNODE: unique symbol;
120
+ export declare const CREATE_COMMENT: unique symbol;
121
+ export declare const CREATE_TEXT: unique symbol;
122
+ export declare const CREATE_STATIC: unique symbol;
123
+ export declare const RESOLVE_COMPONENT: unique symbol;
124
+ export declare const RESOLVE_DYNAMIC_COMPONENT: unique symbol;
125
+ export declare const RESOLVE_DIRECTIVE: unique symbol;
126
+ export declare const RESOLVE_FILTER: unique symbol;
127
+ export declare const WITH_DIRECTIVES: unique symbol;
128
+ export declare const RENDER_LIST: unique symbol;
129
+ export declare const RENDER_SLOT: unique symbol;
130
+ export declare const CREATE_SLOTS: unique symbol;
131
+ export declare const TO_DISPLAY_STRING: unique symbol;
132
+ export declare const MERGE_PROPS: unique symbol;
133
+ export declare const NORMALIZE_CLASS: unique symbol;
134
+ export declare const NORMALIZE_STYLE: unique symbol;
135
+ export declare const NORMALIZE_PROPS: unique symbol;
136
+ export declare const GUARD_REACTIVE_PROPS: unique symbol;
137
+ export declare const TO_HANDLERS: unique symbol;
138
+ export declare const CAMELIZE: unique symbol;
139
+ export declare const CAPITALIZE: unique symbol;
140
+ export declare const TO_HANDLER_KEY: unique symbol;
141
+ export declare const SET_BLOCK_TRACKING: unique symbol;
142
+ export declare const PUSH_SCOPE_ID: unique symbol;
143
+ export declare const POP_SCOPE_ID: unique symbol;
144
+ export declare const WITH_CTX: unique symbol;
145
+ export declare const UNREF: unique symbol;
146
+ export declare const IS_REF: unique symbol;
147
+ export declare const WITH_MEMO: unique symbol;
148
+ export declare const IS_MEMO_SAME: unique symbol;
149
+ export declare const helperNameMap: Record<symbol, string>;
150
+ export declare function registerRuntimeHelpers(helpers: Record<symbol, string>): void;
151
151
 
152
- declare const transformElement: NodeTransform;
153
- declare function resolveComponentType(node: ComponentNode, context: TransformContext, ssr?: boolean): string | symbol | CallExpression;
152
+ export declare const transformElement: NodeTransform;
153
+ export declare function resolveComponentType(node: ComponentNode, context: TransformContext, ssr?: boolean): string | symbol | CallExpression;
154
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): {
155
+ export declare function buildProps(node: ElementNode, context: TransformContext, props: (DirectiveNode | AttributeNode)[] | undefined, isComponent: boolean, isDynamicComponent: boolean, ssr?: boolean): {
156
156
  props: PropsExpression | undefined;
157
157
  directives: DirectiveNode[];
158
158
  patchFlag: number;
159
159
  dynamicPropNames: string[];
160
160
  shouldUseBlock: boolean;
161
161
  };
162
- declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
162
+ export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
163
163
 
164
164
  export type Namespace = number;
165
- declare const enum Namespaces {
165
+ export declare const enum Namespaces {
166
166
  HTML = 0
167
167
  }
168
- declare const enum NodeTypes {
168
+ export declare const enum NodeTypes {
169
169
  ROOT = 0,
170
170
  ELEMENT = 1,
171
171
  TEXT = 2,
@@ -194,7 +194,7 @@ declare const enum NodeTypes {
194
194
  JS_SEQUENCE_EXPRESSION = 25,
195
195
  JS_RETURN_STATEMENT = 26
196
196
  }
197
- declare const enum ElementTypes {
197
+ export declare const enum ElementTypes {
198
198
  ELEMENT = 0,
199
199
  COMPONENT = 1,
200
200
  SLOT = 2,
@@ -289,7 +289,7 @@ export interface DirectiveNode extends Node {
289
289
  * Higher levels implies lower levels. e.g. a node that can be stringified
290
290
  * can always be hoisted and skipped for patch.
291
291
  */
292
- declare const enum ConstantTypes {
292
+ export declare const enum ConstantTypes {
293
293
  NOT_CONSTANT = 0,
294
294
  CAN_SKIP_PATCH = 1,
295
295
  CAN_HOIST = 2,
@@ -419,7 +419,7 @@ export interface MemoExpression extends CallExpression {
419
419
  callee: typeof WITH_MEMO;
420
420
  arguments: [ExpressionNode, MemoFactory, string, string];
421
421
  }
422
- export interface MemoFactory extends FunctionExpression {
422
+ interface MemoFactory extends FunctionExpression {
423
423
  returns: BlockCodegenNode;
424
424
  }
425
425
  export type SSRCodegenNode = BlockStatement | TemplateLiteral | IfStatement | AssignmentExpression | ReturnStatement | SequenceExpression;
@@ -519,29 +519,29 @@ export interface ForRenderListExpression extends CallExpression {
519
519
  export interface ForIteratorExpression extends FunctionExpression {
520
520
  returns: BlockCodegenNode;
521
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
- declare function getVNodeHelper(ssr: boolean, isComponent: boolean): typeof CREATE_VNODE | typeof CREATE_ELEMENT_VNODE;
543
- declare function getVNodeBlockHelper(ssr: boolean, isComponent: boolean): typeof CREATE_BLOCK | typeof CREATE_ELEMENT_BLOCK;
544
- declare function convertToBlock(node: VNodeCall, { helper, removeHelper, inSSR }: TransformContext): void;
522
+ export declare const locStub: SourceLocation;
523
+ export declare function createRoot(children: TemplateChildNode[], loc?: SourceLocation): RootNode;
524
+ 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;
525
+ export declare function createArrayExpression(elements: ArrayExpression['elements'], loc?: SourceLocation): ArrayExpression;
526
+ export declare function createObjectExpression(properties: ObjectExpression['properties'], loc?: SourceLocation): ObjectExpression;
527
+ export declare function createObjectProperty(key: Property['key'] | string, value: Property['value']): Property;
528
+ export declare function createSimpleExpression(content: SimpleExpressionNode['content'], isStatic?: SimpleExpressionNode['isStatic'], loc?: SourceLocation, constType?: ConstantTypes): SimpleExpressionNode;
529
+ export declare function createInterpolation(content: InterpolationNode['content'] | string, loc: SourceLocation): InterpolationNode;
530
+ export declare function createCompoundExpression(children: CompoundExpressionNode['children'], loc?: SourceLocation): CompoundExpressionNode;
531
+ type InferCodegenNodeType<T> = T extends typeof RENDER_SLOT ? RenderSlotCall : CallExpression;
532
+ export declare function createCallExpression<T extends CallExpression['callee']>(callee: T, args?: CallExpression['arguments'], loc?: SourceLocation): InferCodegenNodeType<T>;
533
+ export declare function createFunctionExpression(params: FunctionExpression['params'], returns?: FunctionExpression['returns'], newline?: boolean, isSlot?: boolean, loc?: SourceLocation): FunctionExpression;
534
+ export declare function createConditionalExpression(test: ConditionalExpression['test'], consequent: ConditionalExpression['consequent'], alternate: ConditionalExpression['alternate'], newline?: boolean): ConditionalExpression;
535
+ export declare function createCacheExpression(index: number, value: JSChildNode, isVNode?: boolean): CacheExpression;
536
+ export declare function createBlockStatement(body: BlockStatement['body']): BlockStatement;
537
+ export declare function createTemplateLiteral(elements: TemplateLiteral['elements']): TemplateLiteral;
538
+ export declare function createIfStatement(test: IfStatement['test'], consequent: IfStatement['consequent'], alternate?: IfStatement['alternate']): IfStatement;
539
+ export declare function createAssignmentExpression(left: AssignmentExpression['left'], right: AssignmentExpression['right']): AssignmentExpression;
540
+ export declare function createSequenceExpression(expressions: SequenceExpression['expressions']): SequenceExpression;
541
+ export declare function createReturnStatement(returns: ReturnStatement['returns']): ReturnStatement;
542
+ export declare function getVNodeHelper(ssr: boolean, isComponent: boolean): typeof CREATE_VNODE | typeof CREATE_ELEMENT_VNODE;
543
+ export declare function getVNodeBlockHelper(ssr: boolean, isComponent: boolean): typeof CREATE_BLOCK | typeof CREATE_ELEMENT_BLOCK;
544
+ export declare function convertToBlock(node: VNodeCall, { helper, removeHelper, inSSR }: TransformContext): void;
545
545
 
546
546
  export interface CompilerError extends SyntaxError {
547
547
  code: number | string;
@@ -550,11 +550,11 @@ export interface CompilerError extends SyntaxError {
550
550
  export interface CoreCompilerError extends CompilerError {
551
551
  code: ErrorCodes;
552
552
  }
553
- export type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : CompilerError;
554
- declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
553
+ type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : CompilerError;
554
+ export declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
555
555
  [code: number]: string;
556
556
  }, additionalMessage?: string): InferCompilerError<T>;
557
- declare const enum ErrorCodes {
557
+ export declare const enum ErrorCodes {
558
558
  ABRUPT_CLOSING_OF_EMPTY_COMMENT = 0,
559
559
  CDATA_IN_HTML_CONTENT = 1,
560
560
  DUPLICATE_ATTRIBUTE = 2,
@@ -609,7 +609,7 @@ declare const enum ErrorCodes {
609
609
  __EXTEND_POINT__ = 51
610
610
  }
611
611
 
612
- export interface ErrorHandlingOptions {
612
+ interface ErrorHandlingOptions {
613
613
  onWarn?: (warning: CompilerError) => void;
614
614
  onError?: (error: CompilerError) => void;
615
615
  }
@@ -661,7 +661,7 @@ export interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptio
661
661
  comments?: boolean;
662
662
  }
663
663
  export type HoistTransform = (children: TemplateChildNode[], context: TransformContext, parent: ParentNode) => void;
664
- declare const enum BindingTypes {
664
+ export declare const enum BindingTypes {
665
665
  /**
666
666
  * returned from data()
667
667
  */
@@ -700,7 +700,11 @@ declare const enum BindingTypes {
700
700
  /**
701
701
  * declared by other options, e.g. computed, inject
702
702
  */
703
- OPTIONS = "options"
703
+ OPTIONS = "options",
704
+ /**
705
+ * a literal constant, e.g. 'foo', 1, true
706
+ */
707
+ LITERAL_CONST = "literal-const"
704
708
  }
705
709
  export type BindingMetadata = {
706
710
  [key: string]: BindingTypes | undefined;
@@ -708,7 +712,7 @@ export type BindingMetadata = {
708
712
  __isScriptSetup?: boolean;
709
713
  __propsAliases?: Record<string, string>;
710
714
  };
711
- export interface SharedTransformCodegenOptions {
715
+ interface SharedTransformCodegenOptions {
712
716
  /**
713
717
  * Transform expressions like {{ foo }} to `_ctx.foo`.
714
718
  * If this option is false, the generated code will be wrapped in a
@@ -880,7 +884,7 @@ export interface CodegenOptions extends SharedTransformCodegenOptions {
880
884
  }
881
885
  export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
882
886
 
883
- export type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
887
+ type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
884
888
  export interface CodegenResult {
885
889
  code: string;
886
890
  preamble: string;
@@ -902,7 +906,7 @@ export interface CodegenContext extends Omit<Required<CodegenOptions>, 'bindingM
902
906
  deindent(withoutNewLine?: boolean): void;
903
907
  newline(): void;
904
908
  }
905
- declare function generate(ast: RootNode, options?: CodegenOptions & {
909
+ export declare function generate(ast: RootNode, options?: CodegenOptions & {
906
910
  onContextCreated?: (context: CodegenContext) => void;
907
911
  }): CodegenResult;
908
912
 
@@ -910,77 +914,80 @@ export type TransformPreset = [
910
914
  NodeTransform[],
911
915
  Record<string, DirectiveTransform>
912
916
  ];
913
- declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
914
- declare function baseCompile(template: string | RootNode, options?: CompilerOptions): CodegenResult;
917
+ export declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
918
+ export declare function baseCompile(template: string | RootNode, options?: CompilerOptions): CodegenResult;
915
919
 
916
- declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
917
- declare const isBuiltInType: (tag: string, expected: string) => boolean;
918
- declare function isCoreComponent(tag: string): symbol | void;
919
- declare const isSimpleIdentifier: (name: string) => boolean;
920
+ export declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
921
+ export declare const isBuiltInType: (tag: string, expected: string) => boolean;
922
+ export declare function isCoreComponent(tag: string): symbol | void;
923
+ export declare const isSimpleIdentifier: (name: string) => boolean;
920
924
  /**
921
925
  * Simple lexer to check if an expression is a member expression. This is
922
926
  * lax and only checks validity at the root level (i.e. does not validate exps
923
927
  * inside square brackets), but it's ok since these are only used on template
924
928
  * expressions and false positives are invalid expressions in the first place.
925
929
  */
926
- declare const isMemberExpressionBrowser: (path: string) => boolean;
927
- declare const isMemberExpressionNode: (path: string, context: TransformContext) => boolean;
928
- declare const isMemberExpression: (path: string, context: TransformContext) => boolean;
929
- declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
930
- declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
931
- declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
932
- declare function assert(condition: boolean, msg?: string): void;
933
- declare function findDir(node: ElementNode, name: string | RegExp, allowEmpty?: boolean): DirectiveNode | undefined;
934
- declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode['props'][0] | undefined;
935
- declare function isStaticArgOf(arg: DirectiveNode['arg'], name: string): boolean;
936
- declare function hasDynamicKeyVBind(node: ElementNode): boolean;
937
- declare function isText(node: TemplateChildNode): node is TextNode | InterpolationNode;
938
- declare function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode;
939
- declare function isTemplateNode(node: RootNode | TemplateChildNode): node is TemplateNode;
940
- declare function isSlotOutlet(node: RootNode | TemplateChildNode): node is SlotOutletNode;
941
- declare function injectProp(node: VNodeCall | RenderSlotCall, prop: Property, context: TransformContext): void;
942
- declare function toValidAssetId(name: string, type: 'component' | 'directive' | 'filter'): string;
943
- declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined, ids: TransformContext['identifiers']): boolean;
944
- declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
930
+ export declare const isMemberExpressionBrowser: (path: string) => boolean;
931
+ export declare const isMemberExpressionNode: (path: string, context: TransformContext) => boolean;
932
+ export declare const isMemberExpression: (path: string, context: TransformContext) => boolean;
933
+ export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
934
+ export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
935
+ export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
936
+ export declare function assert(condition: boolean, msg?: string): void;
937
+ export declare function findDir(node: ElementNode, name: string | RegExp, allowEmpty?: boolean): DirectiveNode | undefined;
938
+ export declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode['props'][0] | undefined;
939
+ export declare function isStaticArgOf(arg: DirectiveNode['arg'], name: string): boolean;
940
+ export declare function hasDynamicKeyVBind(node: ElementNode): boolean;
941
+ export declare function isText(node: TemplateChildNode): node is TextNode | InterpolationNode;
942
+ export declare function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode;
943
+ export declare function isTemplateNode(node: RootNode | TemplateChildNode): node is TemplateNode;
944
+ export declare function isSlotOutlet(node: RootNode | TemplateChildNode): node is SlotOutletNode;
945
+ export declare function injectProp(node: VNodeCall | RenderSlotCall, prop: Property, context: TransformContext): void;
946
+ export declare function toValidAssetId(name: string, type: 'component' | 'directive' | 'filter'): string;
947
+ export declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined, ids: TransformContext['identifiers']): boolean;
948
+ export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
945
949
 
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;
950
+ export 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;
951
+ export declare function isReferencedIdentifier(id: Identifier, parent: Node$1 | null, parentStack: Node$1[]): boolean;
952
+ export declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
953
+ export declare function walkFunctionParams(node: Function, onIdent: (id: Identifier) => void): void;
954
+ export declare function walkBlockDeclarations(block: BlockStatement$1 | Program, onIdent: (node: Identifier) => void): void;
955
+ export declare function extractIdentifiers(param: Node$1, nodes?: Identifier[]): Identifier[];
956
+ export declare const isFunctionType: (node: Node$1) => node is Function;
957
+ export declare const isStaticProperty: (node: Node$1) => node is ObjectProperty;
958
+ export declare const isStaticPropertyKey: (node: Node$1, parent: Node$1) => boolean;
959
+ export declare function getImportedName(specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier): string;
960
+ export declare const TS_NODE_TYPES: string[];
961
+ export declare function unwrapTSNode(node: Node$1): Node$1;
962
+ export declare function isCallOf(node: Node$1 | null | undefined, test: string | ((id: string) => boolean) | null | undefined): node is CallExpression$1;
955
963
 
956
- declare const transformModel: DirectiveTransform;
964
+ export declare const transformModel: DirectiveTransform;
957
965
 
958
- declare const transformOn: DirectiveTransform;
966
+ export declare const transformOn: DirectiveTransform;
959
967
 
960
- declare const transformBind: DirectiveTransform;
968
+ export declare const transformBind: DirectiveTransform;
961
969
 
962
- declare const noopDirectiveTransform: DirectiveTransform;
970
+ export declare const noopDirectiveTransform: DirectiveTransform;
963
971
 
964
- declare function processIf(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (node: IfNode, branch: IfBranchNode, isRoot: boolean) => (() => void) | undefined): (() => void) | undefined;
972
+ export declare function processIf(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (node: IfNode, branch: IfBranchNode, isRoot: boolean) => (() => void) | undefined): (() => void) | undefined;
965
973
 
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;
974
+ export declare const transformExpression: NodeTransform;
975
+ export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean, localVars?: Record<string, number>): ExpressionNode;
976
+ export declare function stringifyExpression(exp: ExpressionNode | string): string;
969
977
 
970
- declare const trackSlotScopes: NodeTransform;
971
- declare const trackVForSlotScopes: NodeTransform;
978
+ export declare const trackSlotScopes: NodeTransform;
979
+ export declare const trackVForSlotScopes: NodeTransform;
972
980
  export type SlotFnBuilder = (slotProps: ExpressionNode | undefined, slotChildren: TemplateChildNode[], loc: SourceLocation) => FunctionExpression;
973
- declare function buildSlots(node: ElementNode, context: TransformContext, buildSlotFn?: SlotFnBuilder): {
981
+ export declare function buildSlots(node: ElementNode, context: TransformContext, buildSlotFn?: SlotFnBuilder): {
974
982
  slots: SlotsExpression;
975
983
  hasDynamicSlots: boolean;
976
984
  };
977
985
 
978
- export interface SlotOutletProcessResult {
986
+ interface SlotOutletProcessResult {
979
987
  slotName: string | ExpressionNode;
980
988
  slotProps: PropsExpression | undefined;
981
989
  }
982
- declare function processSlotOutlet(node: SlotOutletNode, context: TransformContext): SlotOutletProcessResult;
990
+ export declare function processSlotOutlet(node: SlotOutletNode, context: TransformContext): SlotOutletProcessResult;
983
991
 
984
- declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode, context: TransformContext): ConstantTypes;
992
+ export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode, context: TransformContext): ConstantTypes;
985
993
 
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, convertToBlock, 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, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
@@ -2676,6 +2676,35 @@ const isFunctionType = (node) => {
2676
2676
  };
2677
2677
  const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
2678
2678
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
2679
+ function getImportedName(specifier) {
2680
+ if (specifier.type === "ImportSpecifier")
2681
+ return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
2682
+ else if (specifier.type === "ImportNamespaceSpecifier")
2683
+ return "*";
2684
+ return "default";
2685
+ }
2686
+ const TS_NODE_TYPES = [
2687
+ "TSAsExpression",
2688
+ // foo as number
2689
+ "TSTypeAssertion",
2690
+ // (<number>foo)
2691
+ "TSNonNullExpression",
2692
+ // foo!
2693
+ "TSInstantiationExpression",
2694
+ // foo<string>
2695
+ "TSSatisfiesExpression"
2696
+ // foo satisfies T
2697
+ ];
2698
+ function unwrapTSNode(node) {
2699
+ if (TS_NODE_TYPES.includes(node.type)) {
2700
+ return unwrapTSNode(node.expression);
2701
+ } else {
2702
+ return node;
2703
+ }
2704
+ }
2705
+ function isCallOf(node, test) {
2706
+ return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
2707
+ }
2679
2708
 
2680
2709
  const prohibitedKeywordRE = new RegExp(
2681
2710
  "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
@@ -4667,4 +4696,4 @@ function baseCompile(template, options = {}) {
4667
4696
 
4668
4697
  const noopDirectiveTransform = () => ({ props: [] });
4669
4698
 
4670
- export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, 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, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, 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$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
4699
+ export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, 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, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, 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, getImportedName, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCallOf, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.3.0-alpha.5",
3
+ "version": "3.3.0-alpha.7",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -32,12 +32,12 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.3.0-alpha.5",
36
- "@babel/parser": "^7.20.15",
35
+ "@babel/parser": "^7.21.3",
36
+ "@vue/shared": "3.3.0-alpha.7",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/types": "^7.16.0"
41
+ "@babel/types": "^7.21.3"
42
42
  }
43
43
  }