@vue/compiler-core 3.2.35 → 3.2.38

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.
@@ -23,65 +23,65 @@ function createCompilerError(code, loc, messages, additionalMessage) {
23
23
  }
24
24
  const errorMessages = {
25
25
  // parse errors
26
- [0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
27
- [1 /* CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
28
- [2 /* DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
29
- [3 /* END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
30
- [4 /* END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
31
- [5 /* EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
32
- [6 /* EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
33
- [7 /* EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
34
- [8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
35
- [9 /* EOF_IN_TAG */]: 'Unexpected EOF in tag.',
36
- [10 /* INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
37
- [11 /* INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
38
- [12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
39
- [13 /* MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
40
- [14 /* MISSING_END_TAG_NAME */]: 'End tag name was expected.',
41
- [15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
42
- [16 /* NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
43
- [17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
44
- [18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
45
- [19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
46
- [21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
47
- [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
48
- [22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
26
+ [0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
27
+ [1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
28
+ [2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
29
+ [3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
30
+ [4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
31
+ [5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
32
+ [6 /* ErrorCodes.EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
33
+ [7 /* ErrorCodes.EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
34
+ [8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
35
+ [9 /* ErrorCodes.EOF_IN_TAG */]: 'Unexpected EOF in tag.',
36
+ [10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
37
+ [11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
38
+ [12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
39
+ [13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
40
+ [14 /* ErrorCodes.MISSING_END_TAG_NAME */]: 'End tag name was expected.',
41
+ [15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
42
+ [16 /* ErrorCodes.NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
43
+ [17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
44
+ [18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
45
+ [19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
46
+ [21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
47
+ [20 /* ErrorCodes.UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
48
+ [22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
49
49
  // Vue-specific parse errors
50
- [23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
51
- [24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
52
- [25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
53
- [27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
50
+ [23 /* ErrorCodes.X_INVALID_END_TAG */]: 'Invalid end tag.',
51
+ [24 /* ErrorCodes.X_MISSING_END_TAG */]: 'Element is missing end tag.',
52
+ [25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
53
+ [27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
54
54
  'Note that dynamic directive argument cannot contain spaces.',
55
- [26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
55
+ [26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
56
56
  // transform errors
57
- [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
58
- [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
59
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
60
- [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
61
- [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
62
- [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
63
- [34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
64
- [35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
65
- [36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
66
- [37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
57
+ [28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
58
+ [29 /* ErrorCodes.X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
59
+ [30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
60
+ [31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
61
+ [32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
62
+ [33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
63
+ [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
64
+ [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
65
+ [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
66
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
67
67
  `When there are multiple named slots, all slots should use <template> ` +
68
68
  `syntax to avoid scope ambiguity.`,
69
- [38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
70
- [39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
69
+ [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
70
+ [39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
71
71
  `default slot. These children will be ignored.`,
72
- [40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
73
- [41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
74
- [42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
75
- [43 /* X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
76
- [44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
77
- [45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
72
+ [40 /* ErrorCodes.X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
73
+ [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
74
+ [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
75
+ [43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
76
+ [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
77
+ [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
78
78
  // generic errors
79
- [46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
80
- [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
81
- [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
82
- [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
79
+ [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
80
+ [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
81
+ [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
82
+ [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
83
83
  // just to fulfill types
84
- [50 /* __EXTEND_POINT__ */]: ``
84
+ [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
85
85
  };
86
86
 
87
87
  const FRAGMENT = Symbol(`Fragment` );
@@ -184,7 +184,7 @@ const locStub = {
184
184
  };
185
185
  function createRoot(children, loc = locStub) {
186
186
  return {
187
- type: 0 /* ROOT */,
187
+ type: 0 /* NodeTypes.ROOT */,
188
188
  children,
189
189
  helpers: [],
190
190
  components: [],
@@ -211,7 +211,7 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
211
211
  }
212
212
  }
213
213
  return {
214
- type: 13 /* VNODE_CALL */,
214
+ type: 13 /* NodeTypes.VNODE_CALL */,
215
215
  tag,
216
216
  props,
217
217
  children,
@@ -226,38 +226,38 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
226
226
  }
227
227
  function createArrayExpression(elements, loc = locStub) {
228
228
  return {
229
- type: 17 /* JS_ARRAY_EXPRESSION */,
229
+ type: 17 /* NodeTypes.JS_ARRAY_EXPRESSION */,
230
230
  loc,
231
231
  elements
232
232
  };
233
233
  }
234
234
  function createObjectExpression(properties, loc = locStub) {
235
235
  return {
236
- type: 15 /* JS_OBJECT_EXPRESSION */,
236
+ type: 15 /* NodeTypes.JS_OBJECT_EXPRESSION */,
237
237
  loc,
238
238
  properties
239
239
  };
240
240
  }
241
241
  function createObjectProperty(key, value) {
242
242
  return {
243
- type: 16 /* JS_PROPERTY */,
243
+ type: 16 /* NodeTypes.JS_PROPERTY */,
244
244
  loc: locStub,
245
245
  key: shared.isString(key) ? createSimpleExpression(key, true) : key,
246
246
  value
247
247
  };
248
248
  }
249
- function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
249
+ function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* ConstantTypes.NOT_CONSTANT */) {
250
250
  return {
251
- type: 4 /* SIMPLE_EXPRESSION */,
251
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
252
252
  loc,
253
253
  content,
254
254
  isStatic,
255
- constType: isStatic ? 3 /* CAN_STRINGIFY */ : constType
255
+ constType: isStatic ? 3 /* ConstantTypes.CAN_STRINGIFY */ : constType
256
256
  };
257
257
  }
258
258
  function createInterpolation(content, loc) {
259
259
  return {
260
- type: 5 /* INTERPOLATION */,
260
+ type: 5 /* NodeTypes.INTERPOLATION */,
261
261
  loc,
262
262
  content: shared.isString(content)
263
263
  ? createSimpleExpression(content, false, loc)
@@ -266,14 +266,14 @@ function createInterpolation(content, loc) {
266
266
  }
267
267
  function createCompoundExpression(children, loc = locStub) {
268
268
  return {
269
- type: 8 /* COMPOUND_EXPRESSION */,
269
+ type: 8 /* NodeTypes.COMPOUND_EXPRESSION */,
270
270
  loc,
271
271
  children
272
272
  };
273
273
  }
274
274
  function createCallExpression(callee, args = [], loc = locStub) {
275
275
  return {
276
- type: 14 /* JS_CALL_EXPRESSION */,
276
+ type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
277
277
  loc,
278
278
  callee,
279
279
  arguments: args
@@ -281,7 +281,7 @@ function createCallExpression(callee, args = [], loc = locStub) {
281
281
  }
282
282
  function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
283
283
  return {
284
- type: 18 /* JS_FUNCTION_EXPRESSION */,
284
+ type: 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */,
285
285
  params,
286
286
  returns,
287
287
  newline,
@@ -291,7 +291,7 @@ function createFunctionExpression(params, returns = undefined, newline = false,
291
291
  }
292
292
  function createConditionalExpression(test, consequent, alternate, newline = true) {
293
293
  return {
294
- type: 19 /* JS_CONDITIONAL_EXPRESSION */,
294
+ type: 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */,
295
295
  test,
296
296
  consequent,
297
297
  alternate,
@@ -301,7 +301,7 @@ function createConditionalExpression(test, consequent, alternate, newline = true
301
301
  }
302
302
  function createCacheExpression(index, value, isVNode = false) {
303
303
  return {
304
- type: 20 /* JS_CACHE_EXPRESSION */,
304
+ type: 20 /* NodeTypes.JS_CACHE_EXPRESSION */,
305
305
  index,
306
306
  value,
307
307
  isVNode,
@@ -310,21 +310,21 @@ function createCacheExpression(index, value, isVNode = false) {
310
310
  }
311
311
  function createBlockStatement(body) {
312
312
  return {
313
- type: 21 /* JS_BLOCK_STATEMENT */,
313
+ type: 21 /* NodeTypes.JS_BLOCK_STATEMENT */,
314
314
  body,
315
315
  loc: locStub
316
316
  };
317
317
  }
318
318
  function createTemplateLiteral(elements) {
319
319
  return {
320
- type: 22 /* JS_TEMPLATE_LITERAL */,
320
+ type: 22 /* NodeTypes.JS_TEMPLATE_LITERAL */,
321
321
  elements,
322
322
  loc: locStub
323
323
  };
324
324
  }
325
325
  function createIfStatement(test, consequent, alternate) {
326
326
  return {
327
- type: 23 /* JS_IF_STATEMENT */,
327
+ type: 23 /* NodeTypes.JS_IF_STATEMENT */,
328
328
  test,
329
329
  consequent,
330
330
  alternate,
@@ -333,7 +333,7 @@ function createIfStatement(test, consequent, alternate) {
333
333
  }
334
334
  function createAssignmentExpression(left, right) {
335
335
  return {
336
- type: 24 /* JS_ASSIGNMENT_EXPRESSION */,
336
+ type: 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */,
337
337
  left,
338
338
  right,
339
339
  loc: locStub
@@ -341,20 +341,20 @@ function createAssignmentExpression(left, right) {
341
341
  }
342
342
  function createSequenceExpression(expressions) {
343
343
  return {
344
- type: 25 /* JS_SEQUENCE_EXPRESSION */,
344
+ type: 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */,
345
345
  expressions,
346
346
  loc: locStub
347
347
  };
348
348
  }
349
349
  function createReturnStatement(returns) {
350
350
  return {
351
- type: 26 /* JS_RETURN_STATEMENT */,
351
+ type: 26 /* NodeTypes.JS_RETURN_STATEMENT */,
352
352
  returns,
353
353
  loc: locStub
354
354
  };
355
355
  }
356
356
 
357
- const isStaticExp = (p) => p.type === 4 /* SIMPLE_EXPRESSION */ && p.isStatic;
357
+ const isStaticExp = (p) => p.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && p.isStatic;
358
358
  const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
359
359
  function isCoreComponent(tag) {
360
360
  if (isBuiltInType(tag, 'Teleport')) {
@@ -384,7 +384,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
384
384
  const isMemberExpressionBrowser = (path) => {
385
385
  // remove whitespaces around . or [ first
386
386
  path = path.trim().replace(whitespaceRE, s => s.trim());
387
- let state = 0 /* inMemberExp */;
387
+ let state = 0 /* MemberExpLexState.inMemberExp */;
388
388
  let stateStack = [];
389
389
  let currentOpenBracketCount = 0;
390
390
  let currentOpenParensCount = 0;
@@ -392,25 +392,25 @@ const isMemberExpressionBrowser = (path) => {
392
392
  for (let i = 0; i < path.length; i++) {
393
393
  const char = path.charAt(i);
394
394
  switch (state) {
395
- case 0 /* inMemberExp */:
395
+ case 0 /* MemberExpLexState.inMemberExp */:
396
396
  if (char === '[') {
397
397
  stateStack.push(state);
398
- state = 1 /* inBrackets */;
398
+ state = 1 /* MemberExpLexState.inBrackets */;
399
399
  currentOpenBracketCount++;
400
400
  }
401
401
  else if (char === '(') {
402
402
  stateStack.push(state);
403
- state = 2 /* inParens */;
403
+ state = 2 /* MemberExpLexState.inParens */;
404
404
  currentOpenParensCount++;
405
405
  }
406
406
  else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
407
407
  return false;
408
408
  }
409
409
  break;
410
- case 1 /* inBrackets */:
410
+ case 1 /* MemberExpLexState.inBrackets */:
411
411
  if (char === `'` || char === `"` || char === '`') {
412
412
  stateStack.push(state);
413
- state = 3 /* inString */;
413
+ state = 3 /* MemberExpLexState.inString */;
414
414
  currentStringType = char;
415
415
  }
416
416
  else if (char === `[`) {
@@ -422,10 +422,10 @@ const isMemberExpressionBrowser = (path) => {
422
422
  }
423
423
  }
424
424
  break;
425
- case 2 /* inParens */:
425
+ case 2 /* MemberExpLexState.inParens */:
426
426
  if (char === `'` || char === `"` || char === '`') {
427
427
  stateStack.push(state);
428
- state = 3 /* inString */;
428
+ state = 3 /* MemberExpLexState.inString */;
429
429
  currentStringType = char;
430
430
  }
431
431
  else if (char === `(`) {
@@ -441,7 +441,7 @@ const isMemberExpressionBrowser = (path) => {
441
441
  }
442
442
  }
443
443
  break;
444
- case 3 /* inString */:
444
+ case 3 /* MemberExpLexState.inString */:
445
445
  if (char === currentStringType) {
446
446
  state = stateStack.pop();
447
447
  currentStringType = null;
@@ -511,7 +511,7 @@ function assert(condition, msg) {
511
511
  function findDir(node, name, allowEmpty = false) {
512
512
  for (let i = 0; i < node.props.length; i++) {
513
513
  const p = node.props[i];
514
- if (p.type === 7 /* DIRECTIVE */ &&
514
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
515
515
  (allowEmpty || p.exp) &&
516
516
  (shared.isString(name) ? p.name === name : name.test(p.name))) {
517
517
  return p;
@@ -521,7 +521,7 @@ function findDir(node, name, allowEmpty = false) {
521
521
  function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
522
522
  for (let i = 0; i < node.props.length; i++) {
523
523
  const p = node.props[i];
524
- if (p.type === 6 /* ATTRIBUTE */) {
524
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
525
525
  if (dynamicOnly)
526
526
  continue;
527
527
  if (p.name === name && (p.value || allowEmpty)) {
@@ -539,24 +539,24 @@ function isStaticArgOf(arg, name) {
539
539
  return !!(arg && isStaticExp(arg) && arg.content === name);
540
540
  }
541
541
  function hasDynamicKeyVBind(node) {
542
- return node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
542
+ return node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
543
543
  p.name === 'bind' &&
544
544
  (!p.arg || // v-bind="obj"
545
- p.arg.type !== 4 /* SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
545
+ p.arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
546
546
  !p.arg.isStatic) // v-bind:[foo]
547
547
  );
548
548
  }
549
549
  function isText(node) {
550
- return node.type === 5 /* INTERPOLATION */ || node.type === 2 /* TEXT */;
550
+ return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
551
551
  }
552
552
  function isVSlot(p) {
553
- return p.type === 7 /* DIRECTIVE */ && p.name === 'slot';
553
+ return p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'slot';
554
554
  }
555
555
  function isTemplateNode(node) {
556
- return (node.type === 1 /* ELEMENT */ && node.tagType === 3 /* TEMPLATE */);
556
+ return (node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 3 /* ElementTypes.TEMPLATE */);
557
557
  }
558
558
  function isSlotOutlet(node) {
559
- return node.type === 1 /* ELEMENT */ && node.tagType === 2 /* SLOT */;
559
+ return node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 2 /* ElementTypes.SLOT */;
560
560
  }
561
561
  function getVNodeHelper(ssr, isComponent) {
562
562
  return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
@@ -568,7 +568,7 @@ const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
568
568
  function getUnnormalizedProps(props, callPath = []) {
569
569
  if (props &&
570
570
  !shared.isString(props) &&
571
- props.type === 14 /* JS_CALL_EXPRESSION */) {
571
+ props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
572
572
  const callee = props.callee;
573
573
  if (!shared.isString(callee) && propsHelperSet.has(callee)) {
574
574
  return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
@@ -586,12 +586,12 @@ function injectProp(node, prop, context) {
586
586
  *
587
587
  * we need to get the real props before normalization
588
588
  */
589
- let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
589
+ let props = node.type === 13 /* NodeTypes.VNODE_CALL */ ? node.props : node.arguments[2];
590
590
  let callPath = [];
591
591
  let parentCall;
592
592
  if (props &&
593
593
  !shared.isString(props) &&
594
- props.type === 14 /* JS_CALL_EXPRESSION */) {
594
+ props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
595
595
  const ret = getUnnormalizedProps(props);
596
596
  props = ret[0];
597
597
  callPath = ret[1];
@@ -600,12 +600,12 @@ function injectProp(node, prop, context) {
600
600
  if (props == null || shared.isString(props)) {
601
601
  propsWithInjection = createObjectExpression([prop]);
602
602
  }
603
- else if (props.type === 14 /* JS_CALL_EXPRESSION */) {
603
+ else if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
604
604
  // merged props... add ours
605
605
  // only inject key to object literal if it's the first argument so that
606
606
  // if doesn't override user provided keys
607
607
  const first = props.arguments[0];
608
- if (!shared.isString(first) && first.type === 15 /* JS_OBJECT_EXPRESSION */) {
608
+ if (!shared.isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
609
609
  first.properties.unshift(prop);
610
610
  }
611
611
  else {
@@ -622,12 +622,12 @@ function injectProp(node, prop, context) {
622
622
  }
623
623
  !propsWithInjection && (propsWithInjection = props);
624
624
  }
625
- else if (props.type === 15 /* JS_OBJECT_EXPRESSION */) {
625
+ else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
626
626
  let alreadyExists = false;
627
627
  // check existing key to avoid overriding user provided keys
628
- if (prop.key.type === 4 /* SIMPLE_EXPRESSION */) {
628
+ if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
629
629
  const propKeyName = prop.key.content;
630
- alreadyExists = props.properties.some(p => p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
630
+ alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
631
631
  p.key.content === propKeyName);
632
632
  }
633
633
  if (!alreadyExists) {
@@ -648,7 +648,7 @@ function injectProp(node, prop, context) {
648
648
  parentCall = callPath[callPath.length - 2];
649
649
  }
650
650
  }
651
- if (node.type === 13 /* VNODE_CALL */) {
651
+ if (node.type === 13 /* NodeTypes.VNODE_CALL */) {
652
652
  if (parentCall) {
653
653
  parentCall.arguments[0] = propsWithInjection;
654
654
  }
@@ -677,45 +677,45 @@ function hasScopeRef(node, ids) {
677
677
  return false;
678
678
  }
679
679
  switch (node.type) {
680
- case 1 /* ELEMENT */:
680
+ case 1 /* NodeTypes.ELEMENT */:
681
681
  for (let i = 0; i < node.props.length; i++) {
682
682
  const p = node.props[i];
683
- if (p.type === 7 /* DIRECTIVE */ &&
683
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
684
684
  (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
685
685
  return true;
686
686
  }
687
687
  }
688
688
  return node.children.some(c => hasScopeRef(c, ids));
689
- case 11 /* FOR */:
689
+ case 11 /* NodeTypes.FOR */:
690
690
  if (hasScopeRef(node.source, ids)) {
691
691
  return true;
692
692
  }
693
693
  return node.children.some(c => hasScopeRef(c, ids));
694
- case 9 /* IF */:
694
+ case 9 /* NodeTypes.IF */:
695
695
  return node.branches.some(b => hasScopeRef(b, ids));
696
- case 10 /* IF_BRANCH */:
696
+ case 10 /* NodeTypes.IF_BRANCH */:
697
697
  if (hasScopeRef(node.condition, ids)) {
698
698
  return true;
699
699
  }
700
700
  return node.children.some(c => hasScopeRef(c, ids));
701
- case 4 /* SIMPLE_EXPRESSION */:
701
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
702
702
  return (!node.isStatic &&
703
703
  isSimpleIdentifier(node.content) &&
704
704
  !!ids[node.content]);
705
- case 8 /* COMPOUND_EXPRESSION */:
705
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
706
706
  return node.children.some(c => shared.isObject(c) && hasScopeRef(c, ids));
707
- case 5 /* INTERPOLATION */:
708
- case 12 /* TEXT_CALL */:
707
+ case 5 /* NodeTypes.INTERPOLATION */:
708
+ case 12 /* NodeTypes.TEXT_CALL */:
709
709
  return hasScopeRef(node.content, ids);
710
- case 2 /* TEXT */:
711
- case 3 /* COMMENT */:
710
+ case 2 /* NodeTypes.TEXT */:
711
+ case 3 /* NodeTypes.COMMENT */:
712
712
  return false;
713
713
  default:
714
714
  return false;
715
715
  }
716
716
  }
717
717
  function getMemoedVNodeCall(node) {
718
- if (node.type === 14 /* JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
718
+ if (node.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
719
719
  return node.arguments[1].returns;
720
720
  }
721
721
  else {
@@ -732,23 +732,23 @@ function makeBlock(node, { helper, removeHelper, inSSR }) {
732
732
  }
733
733
 
734
734
  const deprecationData = {
735
- ["COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */]: {
735
+ ["COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */]: {
736
736
  message: `Platform-native elements with "is" prop will no longer be ` +
737
737
  `treated as components in Vue 3 unless the "is" value is explicitly ` +
738
738
  `prefixed with "vue:".`,
739
739
  link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
740
740
  },
741
- ["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
741
+ ["COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */]: {
742
742
  message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
743
743
  `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
744
744
  `\`v-model:${key}\`.`,
745
745
  link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
746
746
  },
747
- ["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
747
+ ["COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */]: {
748
748
  message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
749
749
  `Vue 3 will automatically set a binding as DOM property when appropriate.`
750
750
  },
751
- ["COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */]: {
751
+ ["COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */]: {
752
752
  message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
753
753
  `object spread: it will now overwrite an existing non-mergeable attribute ` +
754
754
  `that appears before v-bind in the case of conflict. ` +
@@ -756,11 +756,11 @@ const deprecationData = {
756
756
  `You can also suppress this warning if the usage is intended.`,
757
757
  link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
758
758
  },
759
- ["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
759
+ ["COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */]: {
760
760
  message: `.native modifier for v-on has been removed as is no longer necessary.`,
761
761
  link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
762
762
  },
763
- ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
763
+ ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
764
764
  message: `v-if / v-for precedence when used on the same element has changed ` +
765
765
  `in Vue 3: v-if now takes higher precedence and will no longer have ` +
766
766
  `access to v-for scope variables. It is best to avoid the ambiguity ` +
@@ -768,15 +768,15 @@ const deprecationData = {
768
768
  `data source.`,
769
769
  link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
770
770
  },
771
- ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
771
+ ["COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */]: {
772
772
  message: `<template> with no special directives will render as a native template ` +
773
773
  `element instead of its inner content in Vue 3.`
774
774
  },
775
- ["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
775
+ ["COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */]: {
776
776
  message: `"inline-template" has been removed in Vue 3.`,
777
777
  link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
778
778
  },
779
- ["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
779
+ ["COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */]: {
780
780
  message: `filters have been removed in Vue 3. ` +
781
781
  `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
782
782
  `Use method calls or computed properties instead.`,
@@ -836,8 +836,8 @@ const decodeMap = {
836
836
  };
837
837
  const defaultParserOptions = {
838
838
  delimiters: [`{{`, `}}`],
839
- getNamespace: () => 0 /* HTML */,
840
- getTextMode: () => 0 /* DATA */,
839
+ getNamespace: () => 0 /* Namespaces.HTML */,
840
+ getTextMode: () => 0 /* TextModes.DATA */,
841
841
  isVoidTag: shared.NO,
842
842
  isPreTag: shared.NO,
843
843
  isCustomElement: shared.NO,
@@ -849,7 +849,7 @@ const defaultParserOptions = {
849
849
  function baseParse(content, options = {}) {
850
850
  const context = createParserContext(content, options);
851
851
  const start = getCursor(context);
852
- return createRoot(parseChildren(context, 0 /* DATA */, []), getSelection(context, start));
852
+ return createRoot(parseChildren(context, 0 /* TextModes.DATA */, []), getSelection(context, start));
853
853
  }
854
854
  function createParserContext(content, rawOptions) {
855
855
  const options = shared.extend({}, defaultParserOptions);
@@ -875,20 +875,20 @@ function createParserContext(content, rawOptions) {
875
875
  }
876
876
  function parseChildren(context, mode, ancestors) {
877
877
  const parent = last(ancestors);
878
- const ns = parent ? parent.ns : 0 /* HTML */;
878
+ const ns = parent ? parent.ns : 0 /* Namespaces.HTML */;
879
879
  const nodes = [];
880
880
  while (!isEnd(context, mode, ancestors)) {
881
881
  const s = context.source;
882
882
  let node = undefined;
883
- if (mode === 0 /* DATA */ || mode === 1 /* RCDATA */) {
883
+ if (mode === 0 /* TextModes.DATA */ || mode === 1 /* TextModes.RCDATA */) {
884
884
  if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
885
885
  // '{{'
886
886
  node = parseInterpolation(context, mode);
887
887
  }
888
- else if (mode === 0 /* DATA */ && s[0] === '<') {
888
+ else if (mode === 0 /* TextModes.DATA */ && s[0] === '<') {
889
889
  // https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
890
890
  if (s.length === 1) {
891
- emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 1);
891
+ emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 1);
892
892
  }
893
893
  else if (s[1] === '!') {
894
894
  // https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
@@ -900,57 +900,57 @@ function parseChildren(context, mode, ancestors) {
900
900
  node = parseBogusComment(context);
901
901
  }
902
902
  else if (startsWith(s, '<![CDATA[')) {
903
- if (ns !== 0 /* HTML */) {
903
+ if (ns !== 0 /* Namespaces.HTML */) {
904
904
  node = parseCDATA(context, ancestors);
905
905
  }
906
906
  else {
907
- emitError(context, 1 /* CDATA_IN_HTML_CONTENT */);
907
+ emitError(context, 1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */);
908
908
  node = parseBogusComment(context);
909
909
  }
910
910
  }
911
911
  else {
912
- emitError(context, 11 /* INCORRECTLY_OPENED_COMMENT */);
912
+ emitError(context, 11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */);
913
913
  node = parseBogusComment(context);
914
914
  }
915
915
  }
916
916
  else if (s[1] === '/') {
917
917
  // https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
918
918
  if (s.length === 2) {
919
- emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 2);
919
+ emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 2);
920
920
  }
921
921
  else if (s[2] === '>') {
922
- emitError(context, 14 /* MISSING_END_TAG_NAME */, 2);
922
+ emitError(context, 14 /* ErrorCodes.MISSING_END_TAG_NAME */, 2);
923
923
  advanceBy(context, 3);
924
924
  continue;
925
925
  }
926
926
  else if (/[a-z]/i.test(s[2])) {
927
- emitError(context, 23 /* X_INVALID_END_TAG */);
928
- parseTag(context, 1 /* End */, parent);
927
+ emitError(context, 23 /* ErrorCodes.X_INVALID_END_TAG */);
928
+ parseTag(context, 1 /* TagType.End */, parent);
929
929
  continue;
930
930
  }
931
931
  else {
932
- emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
932
+ emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
933
933
  node = parseBogusComment(context);
934
934
  }
935
935
  }
936
936
  else if (/[a-z]/i.test(s[1])) {
937
937
  node = parseElement(context, ancestors);
938
938
  // 2.x <template> with no directive compat
939
- if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context) &&
939
+ if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context) &&
940
940
  node &&
941
941
  node.tag === 'template' &&
942
- !node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
942
+ !node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
943
943
  isSpecialTemplateDirective(p.name))) {
944
- warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context, node.loc);
944
+ warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context, node.loc);
945
945
  node = node.children;
946
946
  }
947
947
  }
948
948
  else if (s[1] === '?') {
949
- emitError(context, 21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
949
+ emitError(context, 21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
950
950
  node = parseBogusComment(context);
951
951
  }
952
952
  else {
953
- emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
953
+ emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
954
954
  }
955
955
  }
956
956
  }
@@ -968,11 +968,11 @@ function parseChildren(context, mode, ancestors) {
968
968
  }
969
969
  // Whitespace handling strategy like v2
970
970
  let removedWhitespace = false;
971
- if (mode !== 2 /* RAWTEXT */ && mode !== 1 /* RCDATA */) {
971
+ if (mode !== 2 /* TextModes.RAWTEXT */ && mode !== 1 /* TextModes.RCDATA */) {
972
972
  const shouldCondense = context.options.whitespace !== 'preserve';
973
973
  for (let i = 0; i < nodes.length; i++) {
974
974
  const node = nodes[i];
975
- if (!context.inPre && node.type === 2 /* TEXT */) {
975
+ if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
976
976
  if (!/[^\t\r\n\f ]/.test(node.content)) {
977
977
  const prev = nodes[i - 1];
978
978
  const next = nodes[i + 1];
@@ -983,10 +983,10 @@ function parseChildren(context, mode, ancestors) {
983
983
  if (!prev ||
984
984
  !next ||
985
985
  (shouldCondense &&
986
- (prev.type === 3 /* COMMENT */ ||
987
- next.type === 3 /* COMMENT */ ||
988
- (prev.type === 1 /* ELEMENT */ &&
989
- next.type === 1 /* ELEMENT */ &&
986
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
987
+ next.type === 3 /* NodeTypes.COMMENT */ ||
988
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
989
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
990
990
  /[\r\n]/.test(node.content))))) {
991
991
  removedWhitespace = true;
992
992
  nodes[i] = null;
@@ -1003,7 +1003,7 @@ function parseChildren(context, mode, ancestors) {
1003
1003
  }
1004
1004
  }
1005
1005
  // Remove comment nodes if desired by configuration.
1006
- else if (node.type === 3 /* COMMENT */ && !context.options.comments) {
1006
+ else if (node.type === 3 /* NodeTypes.COMMENT */ && !context.options.comments) {
1007
1007
  removedWhitespace = true;
1008
1008
  nodes[i] = null;
1009
1009
  }
@@ -1012,7 +1012,7 @@ function parseChildren(context, mode, ancestors) {
1012
1012
  // remove leading newline per html spec
1013
1013
  // https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
1014
1014
  const first = nodes[0];
1015
- if (first && first.type === 2 /* TEXT */) {
1015
+ if (first && first.type === 2 /* NodeTypes.TEXT */) {
1016
1016
  first.content = first.content.replace(/^\r?\n/, '');
1017
1017
  }
1018
1018
  }
@@ -1020,12 +1020,12 @@ function parseChildren(context, mode, ancestors) {
1020
1020
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
1021
1021
  }
1022
1022
  function pushNode(nodes, node) {
1023
- if (node.type === 2 /* TEXT */) {
1023
+ if (node.type === 2 /* NodeTypes.TEXT */) {
1024
1024
  const prev = last(nodes);
1025
1025
  // Merge if both this and the previous node are text and those are
1026
1026
  // consecutive. This happens for cases like "a < b".
1027
1027
  if (prev &&
1028
- prev.type === 2 /* TEXT */ &&
1028
+ prev.type === 2 /* NodeTypes.TEXT */ &&
1029
1029
  prev.loc.end.offset === node.loc.start.offset) {
1030
1030
  prev.content += node.content;
1031
1031
  prev.loc.end = node.loc.end;
@@ -1037,9 +1037,9 @@ function pushNode(nodes, node) {
1037
1037
  }
1038
1038
  function parseCDATA(context, ancestors) {
1039
1039
  advanceBy(context, 9);
1040
- const nodes = parseChildren(context, 3 /* CDATA */, ancestors);
1040
+ const nodes = parseChildren(context, 3 /* TextModes.CDATA */, ancestors);
1041
1041
  if (context.source.length === 0) {
1042
- emitError(context, 6 /* EOF_IN_CDATA */);
1042
+ emitError(context, 6 /* ErrorCodes.EOF_IN_CDATA */);
1043
1043
  }
1044
1044
  else {
1045
1045
  advanceBy(context, 3);
@@ -1054,14 +1054,14 @@ function parseComment(context) {
1054
1054
  if (!match) {
1055
1055
  content = context.source.slice(4);
1056
1056
  advanceBy(context, context.source.length);
1057
- emitError(context, 7 /* EOF_IN_COMMENT */);
1057
+ emitError(context, 7 /* ErrorCodes.EOF_IN_COMMENT */);
1058
1058
  }
1059
1059
  else {
1060
1060
  if (match.index <= 3) {
1061
- emitError(context, 0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
1061
+ emitError(context, 0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
1062
1062
  }
1063
1063
  if (match[1]) {
1064
- emitError(context, 10 /* INCORRECTLY_CLOSED_COMMENT */);
1064
+ emitError(context, 10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */);
1065
1065
  }
1066
1066
  content = context.source.slice(4, match.index);
1067
1067
  // Advancing with reporting nested comments.
@@ -1070,14 +1070,14 @@ function parseComment(context) {
1070
1070
  while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
1071
1071
  advanceBy(context, nestedIndex - prevIndex + 1);
1072
1072
  if (nestedIndex + 4 < s.length) {
1073
- emitError(context, 16 /* NESTED_COMMENT */);
1073
+ emitError(context, 16 /* ErrorCodes.NESTED_COMMENT */);
1074
1074
  }
1075
1075
  prevIndex = nestedIndex + 1;
1076
1076
  }
1077
1077
  advanceBy(context, match.index + match[0].length - prevIndex + 1);
1078
1078
  }
1079
1079
  return {
1080
- type: 3 /* COMMENT */,
1080
+ type: 3 /* NodeTypes.COMMENT */,
1081
1081
  content,
1082
1082
  loc: getSelection(context, start)
1083
1083
  };
@@ -1096,7 +1096,7 @@ function parseBogusComment(context) {
1096
1096
  advanceBy(context, closeIndex + 1);
1097
1097
  }
1098
1098
  return {
1099
- type: 3 /* COMMENT */,
1099
+ type: 3 /* NodeTypes.COMMENT */,
1100
1100
  content,
1101
1101
  loc: getSelection(context, start)
1102
1102
  };
@@ -1106,7 +1106,7 @@ function parseElement(context, ancestors) {
1106
1106
  const wasInPre = context.inPre;
1107
1107
  const wasInVPre = context.inVPre;
1108
1108
  const parent = last(ancestors);
1109
- const element = parseTag(context, 0 /* Start */, parent);
1109
+ const element = parseTag(context, 0 /* TagType.Start */, parent);
1110
1110
  const isPreBoundary = context.inPre && !wasInPre;
1111
1111
  const isVPreBoundary = context.inVPre && !wasInVPre;
1112
1112
  if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
@@ -1126,12 +1126,12 @@ function parseElement(context, ancestors) {
1126
1126
  ancestors.pop();
1127
1127
  // 2.x inline-template compat
1128
1128
  {
1129
- const inlineTemplateProp = element.props.find(p => p.type === 6 /* ATTRIBUTE */ && p.name === 'inline-template');
1129
+ const inlineTemplateProp = element.props.find(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'inline-template');
1130
1130
  if (inlineTemplateProp &&
1131
- checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
1131
+ checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
1132
1132
  const loc = getSelection(context, element.loc.end);
1133
1133
  inlineTemplateProp.value = {
1134
- type: 2 /* TEXT */,
1134
+ type: 2 /* NodeTypes.TEXT */,
1135
1135
  content: loc.source,
1136
1136
  loc
1137
1137
  };
@@ -1140,14 +1140,14 @@ function parseElement(context, ancestors) {
1140
1140
  element.children = children;
1141
1141
  // End tag.
1142
1142
  if (startsWithEndTagOpen(context.source, element.tag)) {
1143
- parseTag(context, 1 /* End */, parent);
1143
+ parseTag(context, 1 /* TagType.End */, parent);
1144
1144
  }
1145
1145
  else {
1146
- emitError(context, 24 /* X_MISSING_END_TAG */, 0, element.loc.start);
1146
+ emitError(context, 24 /* ErrorCodes.X_MISSING_END_TAG */, 0, element.loc.start);
1147
1147
  if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
1148
1148
  const first = children[0];
1149
1149
  if (first && startsWith(first.loc.source, '<!--')) {
1150
- emitError(context, 8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
1150
+ emitError(context, 8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
1151
1151
  }
1152
1152
  }
1153
1153
  }
@@ -1179,9 +1179,9 @@ function parseTag(context, type, parent) {
1179
1179
  // Attributes.
1180
1180
  let props = parseAttributes(context, type);
1181
1181
  // check v-pre
1182
- if (type === 0 /* Start */ &&
1182
+ if (type === 0 /* TagType.Start */ &&
1183
1183
  !context.inVPre &&
1184
- props.some(p => p.type === 7 /* DIRECTIVE */ && p.name === 'pre')) {
1184
+ props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'pre')) {
1185
1185
  context.inVPre = true;
1186
1186
  // reset context
1187
1187
  shared.extend(context, cursor);
@@ -1192,25 +1192,25 @@ function parseTag(context, type, parent) {
1192
1192
  // Tag close.
1193
1193
  let isSelfClosing = false;
1194
1194
  if (context.source.length === 0) {
1195
- emitError(context, 9 /* EOF_IN_TAG */);
1195
+ emitError(context, 9 /* ErrorCodes.EOF_IN_TAG */);
1196
1196
  }
1197
1197
  else {
1198
1198
  isSelfClosing = startsWith(context.source, '/>');
1199
- if (type === 1 /* End */ && isSelfClosing) {
1200
- emitError(context, 4 /* END_TAG_WITH_TRAILING_SOLIDUS */);
1199
+ if (type === 1 /* TagType.End */ && isSelfClosing) {
1200
+ emitError(context, 4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */);
1201
1201
  }
1202
1202
  advanceBy(context, isSelfClosing ? 2 : 1);
1203
1203
  }
1204
- if (type === 1 /* End */) {
1204
+ if (type === 1 /* TagType.End */) {
1205
1205
  return;
1206
1206
  }
1207
1207
  // 2.x deprecation checks
1208
- if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
1208
+ if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
1209
1209
  let hasIf = false;
1210
1210
  let hasFor = false;
1211
1211
  for (let i = 0; i < props.length; i++) {
1212
1212
  const p = props[i];
1213
- if (p.type === 7 /* DIRECTIVE */) {
1213
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
1214
1214
  if (p.name === 'if') {
1215
1215
  hasIf = true;
1216
1216
  }
@@ -1219,27 +1219,27 @@ function parseTag(context, type, parent) {
1219
1219
  }
1220
1220
  }
1221
1221
  if (hasIf && hasFor) {
1222
- warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
1222
+ warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
1223
1223
  break;
1224
1224
  }
1225
1225
  }
1226
1226
  }
1227
- let tagType = 0 /* ELEMENT */;
1227
+ let tagType = 0 /* ElementTypes.ELEMENT */;
1228
1228
  if (!context.inVPre) {
1229
1229
  if (tag === 'slot') {
1230
- tagType = 2 /* SLOT */;
1230
+ tagType = 2 /* ElementTypes.SLOT */;
1231
1231
  }
1232
1232
  else if (tag === 'template') {
1233
- if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
1234
- tagType = 3 /* TEMPLATE */;
1233
+ if (props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
1234
+ tagType = 3 /* ElementTypes.TEMPLATE */;
1235
1235
  }
1236
1236
  }
1237
1237
  else if (isComponent(tag, props, context)) {
1238
- tagType = 1 /* COMPONENT */;
1238
+ tagType = 1 /* ElementTypes.COMPONENT */;
1239
1239
  }
1240
1240
  }
1241
1241
  return {
1242
- type: 1 /* ELEMENT */,
1242
+ type: 1 /* NodeTypes.ELEMENT */,
1243
1243
  ns,
1244
1244
  tag,
1245
1245
  tagType,
@@ -1266,12 +1266,12 @@ function isComponent(tag, props, context) {
1266
1266
  // casting
1267
1267
  for (let i = 0; i < props.length; i++) {
1268
1268
  const p = props[i];
1269
- if (p.type === 6 /* ATTRIBUTE */) {
1269
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
1270
1270
  if (p.name === 'is' && p.value) {
1271
1271
  if (p.value.content.startsWith('vue:')) {
1272
1272
  return true;
1273
1273
  }
1274
- else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1274
+ else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1275
1275
  return true;
1276
1276
  }
1277
1277
  }
@@ -1287,7 +1287,7 @@ function isComponent(tag, props, context) {
1287
1287
  p.name === 'bind' &&
1288
1288
  isStaticArgOf(p.arg, 'is') &&
1289
1289
  true &&
1290
- checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1290
+ checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1291
1291
  return true;
1292
1292
  }
1293
1293
  }
@@ -1300,27 +1300,27 @@ function parseAttributes(context, type) {
1300
1300
  !startsWith(context.source, '>') &&
1301
1301
  !startsWith(context.source, '/>')) {
1302
1302
  if (startsWith(context.source, '/')) {
1303
- emitError(context, 22 /* UNEXPECTED_SOLIDUS_IN_TAG */);
1303
+ emitError(context, 22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */);
1304
1304
  advanceBy(context, 1);
1305
1305
  advanceSpaces(context);
1306
1306
  continue;
1307
1307
  }
1308
- if (type === 1 /* End */) {
1309
- emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
1308
+ if (type === 1 /* TagType.End */) {
1309
+ emitError(context, 3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */);
1310
1310
  }
1311
1311
  const attr = parseAttribute(context, attributeNames);
1312
1312
  // Trim whitespace between class
1313
1313
  // https://github.com/vuejs/core/issues/4251
1314
- if (attr.type === 6 /* ATTRIBUTE */ &&
1314
+ if (attr.type === 6 /* NodeTypes.ATTRIBUTE */ &&
1315
1315
  attr.value &&
1316
1316
  attr.name === 'class') {
1317
1317
  attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
1318
1318
  }
1319
- if (type === 0 /* Start */) {
1319
+ if (type === 0 /* TagType.Start */) {
1320
1320
  props.push(attr);
1321
1321
  }
1322
1322
  if (/^[^\t\r\n\f />]/.test(context.source)) {
1323
- emitError(context, 15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
1323
+ emitError(context, 15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
1324
1324
  }
1325
1325
  advanceSpaces(context);
1326
1326
  }
@@ -1332,17 +1332,17 @@ function parseAttribute(context, nameSet) {
1332
1332
  const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
1333
1333
  const name = match[0];
1334
1334
  if (nameSet.has(name)) {
1335
- emitError(context, 2 /* DUPLICATE_ATTRIBUTE */);
1335
+ emitError(context, 2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */);
1336
1336
  }
1337
1337
  nameSet.add(name);
1338
1338
  if (name[0] === '=') {
1339
- emitError(context, 19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
1339
+ emitError(context, 19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
1340
1340
  }
1341
1341
  {
1342
1342
  const pattern = /["'<]/g;
1343
1343
  let m;
1344
1344
  while ((m = pattern.exec(name))) {
1345
- emitError(context, 17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
1345
+ emitError(context, 17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
1346
1346
  }
1347
1347
  }
1348
1348
  advanceBy(context, name.length);
@@ -1354,7 +1354,7 @@ function parseAttribute(context, nameSet) {
1354
1354
  advanceSpaces(context);
1355
1355
  value = parseAttributeValue(context);
1356
1356
  if (!value) {
1357
- emitError(context, 13 /* MISSING_ATTRIBUTE_VALUE */);
1357
+ emitError(context, 13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */);
1358
1358
  }
1359
1359
  }
1360
1360
  const loc = getSelection(context, start);
@@ -1377,7 +1377,7 @@ function parseAttribute(context, nameSet) {
1377
1377
  if (content.startsWith('[')) {
1378
1378
  isStatic = false;
1379
1379
  if (!content.endsWith(']')) {
1380
- emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1380
+ emitError(context, 27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1381
1381
  content = content.slice(1);
1382
1382
  }
1383
1383
  else {
@@ -1391,12 +1391,12 @@ function parseAttribute(context, nameSet) {
1391
1391
  content += match[3] || '';
1392
1392
  }
1393
1393
  arg = {
1394
- type: 4 /* SIMPLE_EXPRESSION */,
1394
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1395
1395
  content,
1396
1396
  isStatic,
1397
1397
  constType: isStatic
1398
- ? 3 /* CAN_STRINGIFY */
1399
- : 0 /* NOT_CONSTANT */,
1398
+ ? 3 /* ConstantTypes.CAN_STRINGIFY */
1399
+ : 0 /* ConstantTypes.NOT_CONSTANT */,
1400
1400
  loc
1401
1401
  };
1402
1402
  }
@@ -1413,24 +1413,24 @@ function parseAttribute(context, nameSet) {
1413
1413
  // 2.x compat v-bind:foo.sync -> v-model:foo
1414
1414
  if (dirName === 'bind' && arg) {
1415
1415
  if (modifiers.includes('sync') &&
1416
- checkCompatEnabled("COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
1416
+ checkCompatEnabled("COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
1417
1417
  dirName = 'model';
1418
1418
  modifiers.splice(modifiers.indexOf('sync'), 1);
1419
1419
  }
1420
1420
  if (modifiers.includes('prop')) {
1421
- checkCompatEnabled("COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */, context, loc);
1421
+ checkCompatEnabled("COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */, context, loc);
1422
1422
  }
1423
1423
  }
1424
1424
  return {
1425
- type: 7 /* DIRECTIVE */,
1425
+ type: 7 /* NodeTypes.DIRECTIVE */,
1426
1426
  name: dirName,
1427
1427
  exp: value && {
1428
- type: 4 /* SIMPLE_EXPRESSION */,
1428
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1429
1429
  content: value.content,
1430
1430
  isStatic: false,
1431
1431
  // Treat as non-constant by default. This can be potentially set to
1432
1432
  // other values by `transformExpression` to make it eligible for hoisting.
1433
- constType: 0 /* NOT_CONSTANT */,
1433
+ constType: 0 /* ConstantTypes.NOT_CONSTANT */,
1434
1434
  loc: value.loc
1435
1435
  },
1436
1436
  arg,
@@ -1440,13 +1440,13 @@ function parseAttribute(context, nameSet) {
1440
1440
  }
1441
1441
  // missing directive name or illegal directive name
1442
1442
  if (!context.inVPre && startsWith(name, 'v-')) {
1443
- emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
1443
+ emitError(context, 26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */);
1444
1444
  }
1445
1445
  return {
1446
- type: 6 /* ATTRIBUTE */,
1446
+ type: 6 /* NodeTypes.ATTRIBUTE */,
1447
1447
  name,
1448
1448
  value: value && {
1449
- type: 2 /* TEXT */,
1449
+ type: 2 /* NodeTypes.TEXT */,
1450
1450
  content: value.content,
1451
1451
  loc: value.loc
1452
1452
  },
@@ -1463,10 +1463,10 @@ function parseAttributeValue(context) {
1463
1463
  advanceBy(context, 1);
1464
1464
  const endIndex = context.source.indexOf(quote);
1465
1465
  if (endIndex === -1) {
1466
- content = parseTextData(context, context.source.length, 4 /* ATTRIBUTE_VALUE */);
1466
+ content = parseTextData(context, context.source.length, 4 /* TextModes.ATTRIBUTE_VALUE */);
1467
1467
  }
1468
1468
  else {
1469
- content = parseTextData(context, endIndex, 4 /* ATTRIBUTE_VALUE */);
1469
+ content = parseTextData(context, endIndex, 4 /* TextModes.ATTRIBUTE_VALUE */);
1470
1470
  advanceBy(context, 1);
1471
1471
  }
1472
1472
  }
@@ -1479,9 +1479,9 @@ function parseAttributeValue(context) {
1479
1479
  const unexpectedChars = /["'<=`]/g;
1480
1480
  let m;
1481
1481
  while ((m = unexpectedChars.exec(match[0]))) {
1482
- emitError(context, 18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
1482
+ emitError(context, 18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
1483
1483
  }
1484
- content = parseTextData(context, match[0].length, 4 /* ATTRIBUTE_VALUE */);
1484
+ content = parseTextData(context, match[0].length, 4 /* TextModes.ATTRIBUTE_VALUE */);
1485
1485
  }
1486
1486
  return { content, isQuoted, loc: getSelection(context, start) };
1487
1487
  }
@@ -1489,7 +1489,7 @@ function parseInterpolation(context, mode) {
1489
1489
  const [open, close] = context.options.delimiters;
1490
1490
  const closeIndex = context.source.indexOf(close, open.length);
1491
1491
  if (closeIndex === -1) {
1492
- emitError(context, 25 /* X_MISSING_INTERPOLATION_END */);
1492
+ emitError(context, 25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */);
1493
1493
  return undefined;
1494
1494
  }
1495
1495
  const start = getCursor(context);
@@ -1508,12 +1508,12 @@ function parseInterpolation(context, mode) {
1508
1508
  advancePositionWithMutation(innerEnd, rawContent, endOffset);
1509
1509
  advanceBy(context, close.length);
1510
1510
  return {
1511
- type: 5 /* INTERPOLATION */,
1511
+ type: 5 /* NodeTypes.INTERPOLATION */,
1512
1512
  content: {
1513
- type: 4 /* SIMPLE_EXPRESSION */,
1513
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1514
1514
  isStatic: false,
1515
1515
  // Set `isConstant` to false by default and will decide in transformExpression
1516
- constType: 0 /* NOT_CONSTANT */,
1516
+ constType: 0 /* ConstantTypes.NOT_CONSTANT */,
1517
1517
  content,
1518
1518
  loc: getSelection(context, innerStart, innerEnd)
1519
1519
  },
@@ -1521,7 +1521,7 @@ function parseInterpolation(context, mode) {
1521
1521
  };
1522
1522
  }
1523
1523
  function parseText(context, mode) {
1524
- const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1524
+ const endTokens = mode === 3 /* TextModes.CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1525
1525
  let endIndex = context.source.length;
1526
1526
  for (let i = 0; i < endTokens.length; i++) {
1527
1527
  const index = context.source.indexOf(endTokens[i], 1);
@@ -1532,7 +1532,7 @@ function parseText(context, mode) {
1532
1532
  const start = getCursor(context);
1533
1533
  const content = parseTextData(context, endIndex, mode);
1534
1534
  return {
1535
- type: 2 /* TEXT */,
1535
+ type: 2 /* NodeTypes.TEXT */,
1536
1536
  content,
1537
1537
  loc: getSelection(context, start)
1538
1538
  };
@@ -1544,14 +1544,14 @@ function parseText(context, mode) {
1544
1544
  function parseTextData(context, length, mode) {
1545
1545
  const rawText = context.source.slice(0, length);
1546
1546
  advanceBy(context, length);
1547
- if (mode === 2 /* RAWTEXT */ ||
1548
- mode === 3 /* CDATA */ ||
1547
+ if (mode === 2 /* TextModes.RAWTEXT */ ||
1548
+ mode === 3 /* TextModes.CDATA */ ||
1549
1549
  !rawText.includes('&')) {
1550
1550
  return rawText;
1551
1551
  }
1552
1552
  else {
1553
1553
  // DATA or RCDATA containing "&"". Entity decoding required.
1554
- return context.options.decodeEntities(rawText, mode === 4 /* ATTRIBUTE_VALUE */);
1554
+ return context.options.decodeEntities(rawText, mode === 4 /* TextModes.ATTRIBUTE_VALUE */);
1555
1555
  }
1556
1556
  }
1557
1557
  function getCursor(context) {
@@ -1600,7 +1600,7 @@ function emitError(context, code, offset, loc = getCursor(context)) {
1600
1600
  function isEnd(context, mode, ancestors) {
1601
1601
  const s = context.source;
1602
1602
  switch (mode) {
1603
- case 0 /* DATA */:
1603
+ case 0 /* TextModes.DATA */:
1604
1604
  if (startsWith(s, '</')) {
1605
1605
  // TODO: probably bad performance
1606
1606
  for (let i = ancestors.length - 1; i >= 0; --i) {
@@ -1610,15 +1610,15 @@ function isEnd(context, mode, ancestors) {
1610
1610
  }
1611
1611
  }
1612
1612
  break;
1613
- case 1 /* RCDATA */:
1614
- case 2 /* RAWTEXT */: {
1613
+ case 1 /* TextModes.RCDATA */:
1614
+ case 2 /* TextModes.RAWTEXT */: {
1615
1615
  const parent = last(ancestors);
1616
1616
  if (parent && startsWithEndTagOpen(s, parent.tag)) {
1617
1617
  return true;
1618
1618
  }
1619
1619
  break;
1620
1620
  }
1621
- case 3 /* CDATA */:
1621
+ case 3 /* TextModes.CDATA */:
1622
1622
  if (startsWith(s, ']]>')) {
1623
1623
  return true;
1624
1624
  }
@@ -1641,7 +1641,7 @@ function hoistStatic(root, context) {
1641
1641
  function isSingleElementRoot(root, child) {
1642
1642
  const { children } = root;
1643
1643
  return (children.length === 1 &&
1644
- child.type === 1 /* ELEMENT */ &&
1644
+ child.type === 1 /* NodeTypes.ELEMENT */ &&
1645
1645
  !isSlotOutlet(child));
1646
1646
  }
1647
1647
  function walk(node, context, doNotHoistNode = false) {
@@ -1651,15 +1651,15 @@ function walk(node, context, doNotHoistNode = false) {
1651
1651
  for (let i = 0; i < children.length; i++) {
1652
1652
  const child = children[i];
1653
1653
  // only plain elements & text calls are eligible for hoisting.
1654
- if (child.type === 1 /* ELEMENT */ &&
1655
- child.tagType === 0 /* ELEMENT */) {
1654
+ if (child.type === 1 /* NodeTypes.ELEMENT */ &&
1655
+ child.tagType === 0 /* ElementTypes.ELEMENT */) {
1656
1656
  const constantType = doNotHoistNode
1657
- ? 0 /* NOT_CONSTANT */
1657
+ ? 0 /* ConstantTypes.NOT_CONSTANT */
1658
1658
  : getConstantType(child, context);
1659
- if (constantType > 0 /* NOT_CONSTANT */) {
1660
- if (constantType >= 2 /* CAN_HOIST */) {
1659
+ if (constantType > 0 /* ConstantTypes.NOT_CONSTANT */) {
1660
+ if (constantType >= 2 /* ConstantTypes.CAN_HOIST */) {
1661
1661
  child.codegenNode.patchFlag =
1662
- -1 /* HOISTED */ + (` /* HOISTED */` );
1662
+ -1 /* PatchFlags.HOISTED */ + (` /* HOISTED */` );
1663
1663
  child.codegenNode = context.hoist(child.codegenNode);
1664
1664
  hoistedCount++;
1665
1665
  continue;
@@ -1669,13 +1669,13 @@ function walk(node, context, doNotHoistNode = false) {
1669
1669
  // node may contain dynamic children, but its props may be eligible for
1670
1670
  // hoisting.
1671
1671
  const codegenNode = child.codegenNode;
1672
- if (codegenNode.type === 13 /* VNODE_CALL */) {
1672
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
1673
1673
  const flag = getPatchFlag(codegenNode);
1674
1674
  if ((!flag ||
1675
- flag === 512 /* NEED_PATCH */ ||
1676
- flag === 1 /* TEXT */) &&
1675
+ flag === 512 /* PatchFlags.NEED_PATCH */ ||
1676
+ flag === 1 /* PatchFlags.TEXT */) &&
1677
1677
  getGeneratedPropsConstantType(child, context) >=
1678
- 2 /* CAN_HOIST */) {
1678
+ 2 /* ConstantTypes.CAN_HOIST */) {
1679
1679
  const props = getNodeProps(child);
1680
1680
  if (props) {
1681
1681
  codegenNode.props = context.hoist(props);
@@ -1687,14 +1687,14 @@ function walk(node, context, doNotHoistNode = false) {
1687
1687
  }
1688
1688
  }
1689
1689
  }
1690
- else if (child.type === 12 /* TEXT_CALL */ &&
1691
- getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
1690
+ else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
1691
+ getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
1692
1692
  child.codegenNode = context.hoist(child.codegenNode);
1693
1693
  hoistedCount++;
1694
1694
  }
1695
1695
  // walk further
1696
- if (child.type === 1 /* ELEMENT */) {
1697
- const isComponent = child.tagType === 1 /* COMPONENT */;
1696
+ if (child.type === 1 /* NodeTypes.ELEMENT */) {
1697
+ const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
1698
1698
  if (isComponent) {
1699
1699
  context.scopes.vSlot++;
1700
1700
  }
@@ -1703,11 +1703,11 @@ function walk(node, context, doNotHoistNode = false) {
1703
1703
  context.scopes.vSlot--;
1704
1704
  }
1705
1705
  }
1706
- else if (child.type === 11 /* FOR */) {
1706
+ else if (child.type === 11 /* NodeTypes.FOR */) {
1707
1707
  // Do not hoist v-for single child because it has to be a block
1708
1708
  walk(child, context, child.children.length === 1);
1709
1709
  }
1710
- else if (child.type === 9 /* IF */) {
1710
+ else if (child.type === 9 /* NodeTypes.IF */) {
1711
1711
  for (let i = 0; i < child.branches.length; i++) {
1712
1712
  // Do not hoist v-if single child because it has to be a block
1713
1713
  walk(child.branches[i], context, child.branches[i].children.length === 1);
@@ -1720,10 +1720,10 @@ function walk(node, context, doNotHoistNode = false) {
1720
1720
  // all children were hoisted - the entire children array is hoistable.
1721
1721
  if (hoistedCount &&
1722
1722
  hoistedCount === originalCount &&
1723
- node.type === 1 /* ELEMENT */ &&
1724
- node.tagType === 0 /* ELEMENT */ &&
1723
+ node.type === 1 /* NodeTypes.ELEMENT */ &&
1724
+ node.tagType === 0 /* ElementTypes.ELEMENT */ &&
1725
1725
  node.codegenNode &&
1726
- node.codegenNode.type === 13 /* VNODE_CALL */ &&
1726
+ node.codegenNode.type === 13 /* NodeTypes.VNODE_CALL */ &&
1727
1727
  shared.isArray(node.codegenNode.children)) {
1728
1728
  node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
1729
1729
  }
@@ -1731,35 +1731,35 @@ function walk(node, context, doNotHoistNode = false) {
1731
1731
  function getConstantType(node, context) {
1732
1732
  const { constantCache } = context;
1733
1733
  switch (node.type) {
1734
- case 1 /* ELEMENT */:
1735
- if (node.tagType !== 0 /* ELEMENT */) {
1736
- return 0 /* NOT_CONSTANT */;
1734
+ case 1 /* NodeTypes.ELEMENT */:
1735
+ if (node.tagType !== 0 /* ElementTypes.ELEMENT */) {
1736
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1737
1737
  }
1738
1738
  const cached = constantCache.get(node);
1739
1739
  if (cached !== undefined) {
1740
1740
  return cached;
1741
1741
  }
1742
1742
  const codegenNode = node.codegenNode;
1743
- if (codegenNode.type !== 13 /* VNODE_CALL */) {
1744
- return 0 /* NOT_CONSTANT */;
1743
+ if (codegenNode.type !== 13 /* NodeTypes.VNODE_CALL */) {
1744
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1745
1745
  }
1746
1746
  if (codegenNode.isBlock &&
1747
1747
  node.tag !== 'svg' &&
1748
1748
  node.tag !== 'foreignObject') {
1749
- return 0 /* NOT_CONSTANT */;
1749
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1750
1750
  }
1751
1751
  const flag = getPatchFlag(codegenNode);
1752
1752
  if (!flag) {
1753
- let returnType = 3 /* CAN_STRINGIFY */;
1753
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1754
1754
  // Element itself has no patch flag. However we still need to check:
1755
1755
  // 1. Even for a node with no patch flag, it is possible for it to contain
1756
1756
  // non-hoistable expressions that refers to scope variables, e.g. compiler
1757
1757
  // injected keys or cached event handlers. Therefore we need to always
1758
1758
  // check the codegenNode's props to be sure.
1759
1759
  const generatedPropsType = getGeneratedPropsConstantType(node, context);
1760
- if (generatedPropsType === 0 /* NOT_CONSTANT */) {
1761
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1762
- return 0 /* NOT_CONSTANT */;
1760
+ if (generatedPropsType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1761
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1762
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1763
1763
  }
1764
1764
  if (generatedPropsType < returnType) {
1765
1765
  returnType = generatedPropsType;
@@ -1767,9 +1767,9 @@ function getConstantType(node, context) {
1767
1767
  // 2. its children.
1768
1768
  for (let i = 0; i < node.children.length; i++) {
1769
1769
  const childType = getConstantType(node.children[i], context);
1770
- if (childType === 0 /* NOT_CONSTANT */) {
1771
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1772
- return 0 /* NOT_CONSTANT */;
1770
+ if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1771
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1772
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1773
1773
  }
1774
1774
  if (childType < returnType) {
1775
1775
  returnType = childType;
@@ -1779,14 +1779,14 @@ function getConstantType(node, context) {
1779
1779
  // type, check if any of the props can cause the type to be lowered
1780
1780
  // we can skip can_patch because it's guaranteed by the absence of a
1781
1781
  // patchFlag.
1782
- if (returnType > 1 /* CAN_SKIP_PATCH */) {
1782
+ if (returnType > 1 /* ConstantTypes.CAN_SKIP_PATCH */) {
1783
1783
  for (let i = 0; i < node.props.length; i++) {
1784
1784
  const p = node.props[i];
1785
- if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind' && p.exp) {
1785
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind' && p.exp) {
1786
1786
  const expType = getConstantType(p.exp, context);
1787
- if (expType === 0 /* NOT_CONSTANT */) {
1788
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1789
- return 0 /* NOT_CONSTANT */;
1787
+ if (expType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1788
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1789
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1790
1790
  }
1791
1791
  if (expType < returnType) {
1792
1792
  returnType = expType;
@@ -1798,6 +1798,14 @@ function getConstantType(node, context) {
1798
1798
  // static then they don't need to be blocks since there will be no
1799
1799
  // nested updates.
1800
1800
  if (codegenNode.isBlock) {
1801
+ // except set custom directives.
1802
+ for (let i = 0; i < node.props.length; i++) {
1803
+ const p = node.props[i];
1804
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
1805
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1806
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1807
+ }
1808
+ }
1801
1809
  context.removeHelper(OPEN_BLOCK);
1802
1810
  context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
1803
1811
  codegenNode.isBlock = false;
@@ -1807,31 +1815,31 @@ function getConstantType(node, context) {
1807
1815
  return returnType;
1808
1816
  }
1809
1817
  else {
1810
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1811
- return 0 /* NOT_CONSTANT */;
1812
- }
1813
- case 2 /* TEXT */:
1814
- case 3 /* COMMENT */:
1815
- return 3 /* CAN_STRINGIFY */;
1816
- case 9 /* IF */:
1817
- case 11 /* FOR */:
1818
- case 10 /* IF_BRANCH */:
1819
- return 0 /* NOT_CONSTANT */;
1820
- case 5 /* INTERPOLATION */:
1821
- case 12 /* TEXT_CALL */:
1818
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1819
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1820
+ }
1821
+ case 2 /* NodeTypes.TEXT */:
1822
+ case 3 /* NodeTypes.COMMENT */:
1823
+ return 3 /* ConstantTypes.CAN_STRINGIFY */;
1824
+ case 9 /* NodeTypes.IF */:
1825
+ case 11 /* NodeTypes.FOR */:
1826
+ case 10 /* NodeTypes.IF_BRANCH */:
1827
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1828
+ case 5 /* NodeTypes.INTERPOLATION */:
1829
+ case 12 /* NodeTypes.TEXT_CALL */:
1822
1830
  return getConstantType(node.content, context);
1823
- case 4 /* SIMPLE_EXPRESSION */:
1831
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
1824
1832
  return node.constType;
1825
- case 8 /* COMPOUND_EXPRESSION */:
1826
- let returnType = 3 /* CAN_STRINGIFY */;
1833
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
1834
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1827
1835
  for (let i = 0; i < node.children.length; i++) {
1828
1836
  const child = node.children[i];
1829
1837
  if (shared.isString(child) || shared.isSymbol(child)) {
1830
1838
  continue;
1831
1839
  }
1832
1840
  const childType = getConstantType(child, context);
1833
- if (childType === 0 /* NOT_CONSTANT */) {
1834
- return 0 /* NOT_CONSTANT */;
1841
+ if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1842
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1835
1843
  }
1836
1844
  else if (childType < returnType) {
1837
1845
  returnType = childType;
@@ -1839,7 +1847,7 @@ function getConstantType(node, context) {
1839
1847
  }
1840
1848
  return returnType;
1841
1849
  default:
1842
- return 0 /* NOT_CONSTANT */;
1850
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1843
1851
  }
1844
1852
  }
1845
1853
  const allowHoistedHelperSet = new Set([
@@ -1849,48 +1857,48 @@ const allowHoistedHelperSet = new Set([
1849
1857
  GUARD_REACTIVE_PROPS
1850
1858
  ]);
1851
1859
  function getConstantTypeOfHelperCall(value, context) {
1852
- if (value.type === 14 /* JS_CALL_EXPRESSION */ &&
1860
+ if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ &&
1853
1861
  !shared.isString(value.callee) &&
1854
1862
  allowHoistedHelperSet.has(value.callee)) {
1855
1863
  const arg = value.arguments[0];
1856
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
1864
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
1857
1865
  return getConstantType(arg, context);
1858
1866
  }
1859
- else if (arg.type === 14 /* JS_CALL_EXPRESSION */) {
1867
+ else if (arg.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
1860
1868
  // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
1861
1869
  return getConstantTypeOfHelperCall(arg, context);
1862
1870
  }
1863
1871
  }
1864
- return 0 /* NOT_CONSTANT */;
1872
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1865
1873
  }
1866
1874
  function getGeneratedPropsConstantType(node, context) {
1867
- let returnType = 3 /* CAN_STRINGIFY */;
1875
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1868
1876
  const props = getNodeProps(node);
1869
- if (props && props.type === 15 /* JS_OBJECT_EXPRESSION */) {
1877
+ if (props && props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
1870
1878
  const { properties } = props;
1871
1879
  for (let i = 0; i < properties.length; i++) {
1872
1880
  const { key, value } = properties[i];
1873
1881
  const keyType = getConstantType(key, context);
1874
- if (keyType === 0 /* NOT_CONSTANT */) {
1882
+ if (keyType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1875
1883
  return keyType;
1876
1884
  }
1877
1885
  if (keyType < returnType) {
1878
1886
  returnType = keyType;
1879
1887
  }
1880
1888
  let valueType;
1881
- if (value.type === 4 /* SIMPLE_EXPRESSION */) {
1889
+ if (value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
1882
1890
  valueType = getConstantType(value, context);
1883
1891
  }
1884
- else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
1892
+ else if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
1885
1893
  // some helper calls can be hoisted,
1886
1894
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
1887
1895
  // in this case we need to respect the ConstantType of the helper's arguments
1888
1896
  valueType = getConstantTypeOfHelperCall(value, context);
1889
1897
  }
1890
1898
  else {
1891
- valueType = 0 /* NOT_CONSTANT */;
1899
+ valueType = 0 /* ConstantTypes.NOT_CONSTANT */;
1892
1900
  }
1893
- if (valueType === 0 /* NOT_CONSTANT */) {
1901
+ if (valueType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1894
1902
  return valueType;
1895
1903
  }
1896
1904
  if (valueType < returnType) {
@@ -1902,7 +1910,7 @@ function getGeneratedPropsConstantType(node, context) {
1902
1910
  }
1903
1911
  function getNodeProps(node) {
1904
1912
  const codegenNode = node.codegenNode;
1905
- if (codegenNode.type === 13 /* VNODE_CALL */) {
1913
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
1906
1914
  return codegenNode.props;
1907
1915
  }
1908
1916
  }
@@ -2028,7 +2036,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
2028
2036
  else if (exp.identifiers) {
2029
2037
  exp.identifiers.forEach(addId);
2030
2038
  }
2031
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
2039
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2032
2040
  addId(exp.content);
2033
2041
  }
2034
2042
  }
@@ -2041,7 +2049,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
2041
2049
  else if (exp.identifiers) {
2042
2050
  exp.identifiers.forEach(removeId);
2043
2051
  }
2044
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
2052
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2045
2053
  removeId(exp.content);
2046
2054
  }
2047
2055
  }
@@ -2050,7 +2058,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
2050
2058
  if (shared.isString(exp))
2051
2059
  exp = createSimpleExpression(exp);
2052
2060
  context.hoists.push(exp);
2053
- const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* CAN_HOIST */);
2061
+ const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* ConstantTypes.CAN_HOIST */);
2054
2062
  identifier.hoisted = exp;
2055
2063
  return identifier;
2056
2064
  },
@@ -2104,7 +2112,7 @@ function createRootCodegen(root, context) {
2104
2112
  // single element root is never hoisted so codegenNode will never be
2105
2113
  // SimpleExpressionNode
2106
2114
  const codegenNode = child.codegenNode;
2107
- if (codegenNode.type === 13 /* VNODE_CALL */) {
2115
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
2108
2116
  makeBlock(codegenNode, context);
2109
2117
  }
2110
2118
  root.codegenNode = codegenNode;
@@ -2118,13 +2126,13 @@ function createRootCodegen(root, context) {
2118
2126
  }
2119
2127
  else if (children.length > 1) {
2120
2128
  // root has multiple nodes - return a fragment block.
2121
- let patchFlag = 64 /* STABLE_FRAGMENT */;
2122
- let patchFlagText = shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
2129
+ let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
2130
+ let patchFlagText = shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
2123
2131
  // check if the fragment actually contains a single valid child with
2124
2132
  // the rest being comments
2125
- if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
2126
- patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
2127
- patchFlagText += `, ${shared.PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
2133
+ if (children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
2134
+ patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
2135
+ patchFlagText += `, ${shared.PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
2128
2136
  }
2129
2137
  root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false /* isComponent */);
2130
2138
  }
@@ -2170,29 +2178,29 @@ function traverseNode(node, context) {
2170
2178
  }
2171
2179
  }
2172
2180
  switch (node.type) {
2173
- case 3 /* COMMENT */:
2181
+ case 3 /* NodeTypes.COMMENT */:
2174
2182
  if (!context.ssr) {
2175
2183
  // inject import for the Comment symbol, which is needed for creating
2176
2184
  // comment nodes with `createVNode`
2177
2185
  context.helper(CREATE_COMMENT);
2178
2186
  }
2179
2187
  break;
2180
- case 5 /* INTERPOLATION */:
2188
+ case 5 /* NodeTypes.INTERPOLATION */:
2181
2189
  // no need to traverse, but we need to inject toString helper
2182
2190
  if (!context.ssr) {
2183
2191
  context.helper(TO_DISPLAY_STRING);
2184
2192
  }
2185
2193
  break;
2186
2194
  // for container types, further traverse downwards
2187
- case 9 /* IF */:
2195
+ case 9 /* NodeTypes.IF */:
2188
2196
  for (let i = 0; i < node.branches.length; i++) {
2189
2197
  traverseNode(node.branches[i], context);
2190
2198
  }
2191
2199
  break;
2192
- case 10 /* IF_BRANCH */:
2193
- case 11 /* FOR */:
2194
- case 1 /* ELEMENT */:
2195
- case 0 /* ROOT */:
2200
+ case 10 /* NodeTypes.IF_BRANCH */:
2201
+ case 11 /* NodeTypes.FOR */:
2202
+ case 1 /* NodeTypes.ELEMENT */:
2203
+ case 0 /* NodeTypes.ROOT */:
2196
2204
  traverseChildren(node, context);
2197
2205
  break;
2198
2206
  }
@@ -2208,17 +2216,17 @@ function createStructuralDirectiveTransform(name, fn) {
2208
2216
  ? (n) => n === name
2209
2217
  : (n) => name.test(n);
2210
2218
  return (node, context) => {
2211
- if (node.type === 1 /* ELEMENT */) {
2219
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
2212
2220
  const { props } = node;
2213
2221
  // structural directive transforms are not concerned with slots
2214
2222
  // as they are handled separately in vSlot.ts
2215
- if (node.tagType === 3 /* TEMPLATE */ && props.some(isVSlot)) {
2223
+ if (node.tagType === 3 /* ElementTypes.TEMPLATE */ && props.some(isVSlot)) {
2216
2224
  return;
2217
2225
  }
2218
2226
  const exitFns = [];
2219
2227
  for (let i = 0; i < props.length; i++) {
2220
2228
  const prop = props[i];
2221
- if (prop.type === 7 /* DIRECTIVE */ && matches(prop.name)) {
2229
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */ && matches(prop.name)) {
2222
2230
  // structural directives are removed to avoid infinite recursion
2223
2231
  // also we remove them *before* applying so that it can further
2224
2232
  // traverse itself in case it moves the node around
@@ -2266,7 +2274,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
2266
2274
  if (context.map) {
2267
2275
  if (node) {
2268
2276
  let name;
2269
- if (node.type === 4 /* SIMPLE_EXPRESSION */ && !node.isStatic) {
2277
+ if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !node.isStatic) {
2270
2278
  const content = node.content.replace(/^_ctx\./, '');
2271
2279
  if (content !== node.content && isSimpleIdentifier(content)) {
2272
2280
  name = content;
@@ -2542,7 +2550,7 @@ function genHoists(hoists, context) {
2542
2550
  for (let i = 0; i < hoists.length; i++) {
2543
2551
  const exp = hoists[i];
2544
2552
  if (exp) {
2545
- const needScopeIdWrapper = genScopeId && exp.type === 13 /* VNODE_CALL */;
2553
+ const needScopeIdWrapper = genScopeId && exp.type === 13 /* NodeTypes.VNODE_CALL */;
2546
2554
  push(`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`);
2547
2555
  genNode(exp, context);
2548
2556
  if (needScopeIdWrapper) {
@@ -2566,10 +2574,10 @@ function genImports(importsOptions, context) {
2566
2574
  }
2567
2575
  function isText$1(n) {
2568
2576
  return (shared.isString(n) ||
2569
- n.type === 4 /* SIMPLE_EXPRESSION */ ||
2570
- n.type === 2 /* TEXT */ ||
2571
- n.type === 5 /* INTERPOLATION */ ||
2572
- n.type === 8 /* COMPOUND_EXPRESSION */);
2577
+ n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2578
+ n.type === 2 /* NodeTypes.TEXT */ ||
2579
+ n.type === 5 /* NodeTypes.INTERPOLATION */ ||
2580
+ n.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */);
2573
2581
  }
2574
2582
  function genNodeListAsArray(nodes, context) {
2575
2583
  const multilines = nodes.length > 3 ||
@@ -2614,73 +2622,73 @@ function genNode(node, context) {
2614
2622
  return;
2615
2623
  }
2616
2624
  switch (node.type) {
2617
- case 1 /* ELEMENT */:
2618
- case 9 /* IF */:
2619
- case 11 /* FOR */:
2625
+ case 1 /* NodeTypes.ELEMENT */:
2626
+ case 9 /* NodeTypes.IF */:
2627
+ case 11 /* NodeTypes.FOR */:
2620
2628
  assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
2621
2629
  `Apply appropriate transforms first.`);
2622
2630
  genNode(node.codegenNode, context);
2623
2631
  break;
2624
- case 2 /* TEXT */:
2632
+ case 2 /* NodeTypes.TEXT */:
2625
2633
  genText(node, context);
2626
2634
  break;
2627
- case 4 /* SIMPLE_EXPRESSION */:
2635
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
2628
2636
  genExpression(node, context);
2629
2637
  break;
2630
- case 5 /* INTERPOLATION */:
2638
+ case 5 /* NodeTypes.INTERPOLATION */:
2631
2639
  genInterpolation(node, context);
2632
2640
  break;
2633
- case 12 /* TEXT_CALL */:
2641
+ case 12 /* NodeTypes.TEXT_CALL */:
2634
2642
  genNode(node.codegenNode, context);
2635
2643
  break;
2636
- case 8 /* COMPOUND_EXPRESSION */:
2644
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
2637
2645
  genCompoundExpression(node, context);
2638
2646
  break;
2639
- case 3 /* COMMENT */:
2647
+ case 3 /* NodeTypes.COMMENT */:
2640
2648
  genComment(node, context);
2641
2649
  break;
2642
- case 13 /* VNODE_CALL */:
2650
+ case 13 /* NodeTypes.VNODE_CALL */:
2643
2651
  genVNodeCall(node, context);
2644
2652
  break;
2645
- case 14 /* JS_CALL_EXPRESSION */:
2653
+ case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
2646
2654
  genCallExpression(node, context);
2647
2655
  break;
2648
- case 15 /* JS_OBJECT_EXPRESSION */:
2656
+ case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
2649
2657
  genObjectExpression(node, context);
2650
2658
  break;
2651
- case 17 /* JS_ARRAY_EXPRESSION */:
2659
+ case 17 /* NodeTypes.JS_ARRAY_EXPRESSION */:
2652
2660
  genArrayExpression(node, context);
2653
2661
  break;
2654
- case 18 /* JS_FUNCTION_EXPRESSION */:
2662
+ case 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */:
2655
2663
  genFunctionExpression(node, context);
2656
2664
  break;
2657
- case 19 /* JS_CONDITIONAL_EXPRESSION */:
2665
+ case 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */:
2658
2666
  genConditionalExpression(node, context);
2659
2667
  break;
2660
- case 20 /* JS_CACHE_EXPRESSION */:
2668
+ case 20 /* NodeTypes.JS_CACHE_EXPRESSION */:
2661
2669
  genCacheExpression(node, context);
2662
2670
  break;
2663
- case 21 /* JS_BLOCK_STATEMENT */:
2671
+ case 21 /* NodeTypes.JS_BLOCK_STATEMENT */:
2664
2672
  genNodeList(node.body, context, true, false);
2665
2673
  break;
2666
2674
  // SSR only types
2667
- case 22 /* JS_TEMPLATE_LITERAL */:
2675
+ case 22 /* NodeTypes.JS_TEMPLATE_LITERAL */:
2668
2676
  genTemplateLiteral(node, context);
2669
2677
  break;
2670
- case 23 /* JS_IF_STATEMENT */:
2678
+ case 23 /* NodeTypes.JS_IF_STATEMENT */:
2671
2679
  genIfStatement(node, context);
2672
2680
  break;
2673
- case 24 /* JS_ASSIGNMENT_EXPRESSION */:
2681
+ case 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */:
2674
2682
  genAssignmentExpression(node, context);
2675
2683
  break;
2676
- case 25 /* JS_SEQUENCE_EXPRESSION */:
2684
+ case 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */:
2677
2685
  genSequenceExpression(node, context);
2678
2686
  break;
2679
- case 26 /* JS_RETURN_STATEMENT */:
2687
+ case 26 /* NodeTypes.JS_RETURN_STATEMENT */:
2680
2688
  genReturnStatement(node, context);
2681
2689
  break;
2682
2690
  /* istanbul ignore next */
2683
- case 10 /* IF_BRANCH */:
2691
+ case 10 /* NodeTypes.IF_BRANCH */:
2684
2692
  // noop
2685
2693
  break;
2686
2694
  default:
@@ -2720,7 +2728,7 @@ function genCompoundExpression(node, context) {
2720
2728
  }
2721
2729
  function genExpressionAsPropertyKey(node, context) {
2722
2730
  const { push } = context;
2723
- if (node.type === 8 /* COMPOUND_EXPRESSION */) {
2731
+ if (node.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
2724
2732
  push(`[`);
2725
2733
  genCompoundExpression(node, context);
2726
2734
  push(`]`);
@@ -2797,7 +2805,7 @@ function genObjectExpression(node, context) {
2797
2805
  return;
2798
2806
  }
2799
2807
  const multilines = properties.length > 1 ||
2800
- (properties.some(p => p.value.type !== 4 /* SIMPLE_EXPRESSION */));
2808
+ (properties.some(p => p.value.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */));
2801
2809
  push(multilines ? `{` : `{ `);
2802
2810
  multilines && indent();
2803
2811
  for (let i = 0; i < properties.length; i++) {
@@ -2866,7 +2874,7 @@ function genFunctionExpression(node, context) {
2866
2874
  function genConditionalExpression(node, context) {
2867
2875
  const { test, consequent, alternate, newline: needNewline } = node;
2868
2876
  const { push, indent, deindent, newline } = context;
2869
- if (test.type === 4 /* SIMPLE_EXPRESSION */) {
2877
+ if (test.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2870
2878
  const needsParens = !isSimpleIdentifier(test.content);
2871
2879
  needsParens && push(`(`);
2872
2880
  genExpression(test, context);
@@ -2886,7 +2894,7 @@ function genConditionalExpression(node, context) {
2886
2894
  needNewline && newline();
2887
2895
  needNewline || push(` `);
2888
2896
  push(`: `);
2889
- const isNested = alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */;
2897
+ const isNested = alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */;
2890
2898
  if (!isNested) {
2891
2899
  context.indentLevel++;
2892
2900
  }
@@ -2950,7 +2958,7 @@ function genIfStatement(node, context) {
2950
2958
  push(`}`);
2951
2959
  if (alternate) {
2952
2960
  push(` else `);
2953
- if (alternate.type === 23 /* JS_IF_STATEMENT */) {
2961
+ if (alternate.type === 23 /* NodeTypes.JS_IF_STATEMENT */) {
2954
2962
  genIfStatement(alternate, context);
2955
2963
  }
2956
2964
  else {
@@ -3307,27 +3315,27 @@ function isReferenced(node, parent, grandparent) {
3307
3315
 
3308
3316
  const isLiteralWhitelisted = /*#__PURE__*/ shared.makeMap('true,false,null,this');
3309
3317
  const transformExpression = (node, context) => {
3310
- if (node.type === 5 /* INTERPOLATION */) {
3318
+ if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
3311
3319
  node.content = processExpression(node.content, context);
3312
3320
  }
3313
- else if (node.type === 1 /* ELEMENT */) {
3321
+ else if (node.type === 1 /* NodeTypes.ELEMENT */) {
3314
3322
  // handle directives on element
3315
3323
  for (let i = 0; i < node.props.length; i++) {
3316
3324
  const dir = node.props[i];
3317
3325
  // do not process for v-on & v-for since they are special handled
3318
- if (dir.type === 7 /* DIRECTIVE */ && dir.name !== 'for') {
3326
+ if (dir.type === 7 /* NodeTypes.DIRECTIVE */ && dir.name !== 'for') {
3319
3327
  const exp = dir.exp;
3320
3328
  const arg = dir.arg;
3321
3329
  // do not process exp if this is v-on:arg - we need special handling
3322
3330
  // for wrapping inline statements.
3323
3331
  if (exp &&
3324
- exp.type === 4 /* SIMPLE_EXPRESSION */ &&
3332
+ exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
3325
3333
  !(dir.name === 'on' && arg)) {
3326
3334
  dir.exp = processExpression(exp, context,
3327
3335
  // slot args must be processed as function params
3328
3336
  dir.name === 'slot');
3329
3337
  }
3330
- if (arg && arg.type === 4 /* SIMPLE_EXPRESSION */ && !arg.isStatic) {
3338
+ if (arg && arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !arg.isStatic) {
3331
3339
  dir.arg = processExpression(arg, context);
3332
3340
  }
3333
3341
  }
@@ -3356,15 +3364,15 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3356
3364
  const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
3357
3365
  // ({ x } = y)
3358
3366
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
3359
- if (type === "setup-const" /* SETUP_CONST */ ||
3360
- type === "setup-reactive-const" /* SETUP_REACTIVE_CONST */ ||
3367
+ if (type === "setup-const" /* BindingTypes.SETUP_CONST */ ||
3368
+ type === "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */ ||
3361
3369
  localVars[raw]) {
3362
3370
  return raw;
3363
3371
  }
3364
- else if (type === "setup-ref" /* SETUP_REF */) {
3372
+ else if (type === "setup-ref" /* BindingTypes.SETUP_REF */) {
3365
3373
  return `${raw}.value`;
3366
3374
  }
3367
- else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
3375
+ else if (type === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */) {
3368
3376
  // const binding that may or may not be ref
3369
3377
  // if it's not a ref, then assignments don't make sense -
3370
3378
  // so we ignore the non-ref assignment case and generate code
@@ -3373,7 +3381,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3373
3381
  ? `${raw}.value`
3374
3382
  : `${context.helperString(UNREF)}(${raw})`;
3375
3383
  }
3376
- else if (type === "setup-let" /* SETUP_LET */) {
3384
+ else if (type === "setup-let" /* BindingTypes.SETUP_LET */) {
3377
3385
  if (isAssignmentLVal) {
3378
3386
  // let binding.
3379
3387
  // this is a bit more tricky as we need to cover the case where
@@ -3409,12 +3417,12 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3409
3417
  return `${context.helperString(UNREF)}(${raw})`;
3410
3418
  }
3411
3419
  }
3412
- else if (type === "props" /* PROPS */) {
3420
+ else if (type === "props" /* BindingTypes.PROPS */) {
3413
3421
  // use __props which is generated by compileScript so in ts mode
3414
3422
  // it gets correct type
3415
3423
  return shared.genPropsAccessExp(raw);
3416
3424
  }
3417
- else if (type === "props-aliased" /* PROPS_ALIASED */) {
3425
+ else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
3418
3426
  // prop with a different local alias (from defineProps() destructure)
3419
3427
  return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
3420
3428
  }
@@ -3424,7 +3432,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3424
3432
  // setup bindings in non-inline mode
3425
3433
  return `$setup.${raw}`;
3426
3434
  }
3427
- else if (type === "props-aliased" /* PROPS_ALIASED */) {
3435
+ else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
3428
3436
  return `$props['${bindingMetadata.__propsAliases[raw]}']`;
3429
3437
  }
3430
3438
  else if (type) {
@@ -3445,17 +3453,17 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3445
3453
  if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
3446
3454
  // const bindings exposed from setup can be skipped for patching but
3447
3455
  // cannot be hoisted to module scope
3448
- if (bindingMetadata[node.content] === "setup-const" /* SETUP_CONST */) {
3449
- node.constType = 1 /* CAN_SKIP_PATCH */;
3456
+ if (bindingMetadata[node.content] === "setup-const" /* BindingTypes.SETUP_CONST */) {
3457
+ node.constType = 1 /* ConstantTypes.CAN_SKIP_PATCH */;
3450
3458
  }
3451
3459
  node.content = rewriteIdentifier(rawExp);
3452
3460
  }
3453
3461
  else if (!isScopeVarReference) {
3454
3462
  if (isLiteral) {
3455
- node.constType = 3 /* CAN_STRINGIFY */;
3463
+ node.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
3456
3464
  }
3457
3465
  else {
3458
- node.constType = 2 /* CAN_HOIST */;
3466
+ node.constType = 2 /* ConstantTypes.CAN_HOIST */;
3459
3467
  }
3460
3468
  }
3461
3469
  return node;
@@ -3475,7 +3483,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3475
3483
  }).program;
3476
3484
  }
3477
3485
  catch (e) {
3478
- context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3486
+ context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3479
3487
  return node;
3480
3488
  }
3481
3489
  const ids = [];
@@ -3529,7 +3537,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3529
3537
  source,
3530
3538
  start: advancePositionWithClone(node.loc.start, source, start),
3531
3539
  end: advancePositionWithClone(node.loc.start, source, end)
3532
- }, id.isConstant ? 3 /* CAN_STRINGIFY */ : 0 /* NOT_CONSTANT */));
3540
+ }, id.isConstant ? 3 /* ConstantTypes.CAN_STRINGIFY */ : 0 /* ConstantTypes.NOT_CONSTANT */));
3533
3541
  if (i === ids.length - 1 && end < rawExp.length) {
3534
3542
  children.push(rawExp.slice(end));
3535
3543
  }
@@ -3541,8 +3549,8 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3541
3549
  else {
3542
3550
  ret = node;
3543
3551
  ret.constType = bailConstant
3544
- ? 0 /* NOT_CONSTANT */
3545
- : 3 /* CAN_STRINGIFY */;
3552
+ ? 0 /* ConstantTypes.NOT_CONSTANT */
3553
+ : 3 /* ConstantTypes.CAN_STRINGIFY */;
3546
3554
  }
3547
3555
  ret.identifiers = Object.keys(knownIds);
3548
3556
  return ret;
@@ -3562,7 +3570,7 @@ function stringifyExpression(exp) {
3562
3570
  if (shared.isString(exp)) {
3563
3571
  return exp;
3564
3572
  }
3565
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
3573
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
3566
3574
  return exp.content;
3567
3575
  }
3568
3576
  else {
@@ -3582,7 +3590,7 @@ const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (n
3582
3590
  let key = 0;
3583
3591
  while (i-- >= 0) {
3584
3592
  const sibling = siblings[i];
3585
- if (sibling && sibling.type === 9 /* IF */) {
3593
+ if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
3586
3594
  key += sibling.branches.length;
3587
3595
  }
3588
3596
  }
@@ -3605,7 +3613,7 @@ function processIf(node, dir, context, processCodegen) {
3605
3613
  if (dir.name !== 'else' &&
3606
3614
  (!dir.exp || !dir.exp.content.trim())) {
3607
3615
  const loc = dir.exp ? dir.exp.loc : node.loc;
3608
- context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
3616
+ context.onError(createCompilerError(28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */, dir.loc));
3609
3617
  dir.exp = createSimpleExpression(`true`, false, loc);
3610
3618
  }
3611
3619
  if (context.prefixIdentifiers && dir.exp) {
@@ -3616,7 +3624,7 @@ function processIf(node, dir, context, processCodegen) {
3616
3624
  if (dir.name === 'if') {
3617
3625
  const branch = createIfBranch(node, dir);
3618
3626
  const ifNode = {
3619
- type: 9 /* IF */,
3627
+ type: 9 /* NodeTypes.IF */,
3620
3628
  loc: node.loc,
3621
3629
  branches: [branch]
3622
3630
  };
@@ -3632,22 +3640,22 @@ function processIf(node, dir, context, processCodegen) {
3632
3640
  let i = siblings.indexOf(node);
3633
3641
  while (i-- >= -1) {
3634
3642
  const sibling = siblings[i];
3635
- if (sibling && sibling.type === 3 /* COMMENT */) {
3643
+ if (sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
3636
3644
  context.removeNode(sibling);
3637
3645
  comments.unshift(sibling);
3638
3646
  continue;
3639
3647
  }
3640
3648
  if (sibling &&
3641
- sibling.type === 2 /* TEXT */ &&
3649
+ sibling.type === 2 /* NodeTypes.TEXT */ &&
3642
3650
  !sibling.content.trim().length) {
3643
3651
  context.removeNode(sibling);
3644
3652
  continue;
3645
3653
  }
3646
- if (sibling && sibling.type === 9 /* IF */) {
3654
+ if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
3647
3655
  // Check if v-else was followed by v-else-if
3648
3656
  if (dir.name === 'else-if' &&
3649
3657
  sibling.branches[sibling.branches.length - 1].condition === undefined) {
3650
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3658
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3651
3659
  }
3652
3660
  // move the node to the if node's branches
3653
3661
  context.removeNode();
@@ -3655,7 +3663,7 @@ function processIf(node, dir, context, processCodegen) {
3655
3663
  if (comments.length &&
3656
3664
  // #3619 ignore comments if the v-if is direct child of <transition>
3657
3665
  !(context.parent &&
3658
- context.parent.type === 1 /* ELEMENT */ &&
3666
+ context.parent.type === 1 /* NodeTypes.ELEMENT */ &&
3659
3667
  isBuiltInType(context.parent.tag, 'transition'))) {
3660
3668
  branch.children = [...comments, ...branch.children];
3661
3669
  }
@@ -3665,7 +3673,7 @@ function processIf(node, dir, context, processCodegen) {
3665
3673
  if (key) {
3666
3674
  sibling.branches.forEach(({ userKey }) => {
3667
3675
  if (isSameKey(userKey, key)) {
3668
- context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
3676
+ context.onError(createCompilerError(29 /* ErrorCodes.X_V_IF_SAME_KEY */, branch.userKey.loc));
3669
3677
  }
3670
3678
  });
3671
3679
  }
@@ -3683,16 +3691,16 @@ function processIf(node, dir, context, processCodegen) {
3683
3691
  context.currentNode = null;
3684
3692
  }
3685
3693
  else {
3686
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3694
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3687
3695
  }
3688
3696
  break;
3689
3697
  }
3690
3698
  }
3691
3699
  }
3692
3700
  function createIfBranch(node, dir) {
3693
- const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
3701
+ const isTemplateIf = node.tagType === 3 /* ElementTypes.TEMPLATE */;
3694
3702
  return {
3695
- type: 10 /* IF_BRANCH */,
3703
+ type: 10 /* NodeTypes.IF_BRANCH */,
3696
3704
  loc: node.loc,
3697
3705
  condition: dir.name === 'else' ? undefined : dir.exp,
3698
3706
  children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
@@ -3716,26 +3724,26 @@ function createCodegenNodeForBranch(branch, keyIndex, context) {
3716
3724
  }
3717
3725
  function createChildrenCodegenNode(branch, keyIndex, context) {
3718
3726
  const { helper } = context;
3719
- const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* CAN_HOIST */));
3727
+ const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* ConstantTypes.CAN_HOIST */));
3720
3728
  const { children } = branch;
3721
3729
  const firstChild = children[0];
3722
- const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* ELEMENT */;
3730
+ const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* NodeTypes.ELEMENT */;
3723
3731
  if (needFragmentWrapper) {
3724
- if (children.length === 1 && firstChild.type === 11 /* FOR */) {
3732
+ if (children.length === 1 && firstChild.type === 11 /* NodeTypes.FOR */) {
3725
3733
  // optimize away nested fragments when child is a ForNode
3726
3734
  const vnodeCall = firstChild.codegenNode;
3727
3735
  injectProp(vnodeCall, keyProperty, context);
3728
3736
  return vnodeCall;
3729
3737
  }
3730
3738
  else {
3731
- let patchFlag = 64 /* STABLE_FRAGMENT */;
3732
- let patchFlagText = shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
3739
+ let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
3740
+ let patchFlagText = shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
3733
3741
  // check if the fragment actually contains a single valid child with
3734
3742
  // the rest being comments
3735
3743
  if (!branch.isTemplateIf &&
3736
- children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
3737
- patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
3738
- patchFlagText += `, ${shared.PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
3744
+ children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
3745
+ patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
3746
+ patchFlagText += `, ${shared.PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
3739
3747
  }
3740
3748
  return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false /* isComponent */, branch.loc);
3741
3749
  }
@@ -3744,7 +3752,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
3744
3752
  const ret = firstChild.codegenNode;
3745
3753
  const vnodeCall = getMemoedVNodeCall(ret);
3746
3754
  // Change createVNode to createBlock.
3747
- if (vnodeCall.type === 13 /* VNODE_CALL */) {
3755
+ if (vnodeCall.type === 13 /* NodeTypes.VNODE_CALL */) {
3748
3756
  makeBlock(vnodeCall, context);
3749
3757
  }
3750
3758
  // inject branch key
@@ -3756,7 +3764,7 @@ function isSameKey(a, b) {
3756
3764
  if (!a || a.type !== b.type) {
3757
3765
  return false;
3758
3766
  }
3759
- if (a.type === 6 /* ATTRIBUTE */) {
3767
+ if (a.type === 6 /* NodeTypes.ATTRIBUTE */) {
3760
3768
  if (a.value.content !== b.value.content) {
3761
3769
  return false;
3762
3770
  }
@@ -3768,7 +3776,7 @@ function isSameKey(a, b) {
3768
3776
  if (exp.type !== branchExp.type) {
3769
3777
  return false;
3770
3778
  }
3771
- if (exp.type !== 4 /* SIMPLE_EXPRESSION */ ||
3779
+ if (exp.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
3772
3780
  exp.isStatic !== branchExp.isStatic ||
3773
3781
  exp.content !== branchExp.content) {
3774
3782
  return false;
@@ -3778,15 +3786,15 @@ function isSameKey(a, b) {
3778
3786
  }
3779
3787
  function getParentCondition(node) {
3780
3788
  while (true) {
3781
- if (node.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
3782
- if (node.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
3789
+ if (node.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
3790
+ if (node.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
3783
3791
  node = node.alternate;
3784
3792
  }
3785
3793
  else {
3786
3794
  return node;
3787
3795
  }
3788
3796
  }
3789
- else if (node.type === 20 /* JS_CACHE_EXPRESSION */) {
3797
+ else if (node.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */) {
3790
3798
  node = node.value;
3791
3799
  }
3792
3800
  }
@@ -3804,7 +3812,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3804
3812
  const memo = findDir(node, 'memo');
3805
3813
  const keyProp = findProp(node, `key`);
3806
3814
  const keyExp = keyProp &&
3807
- (keyProp.type === 6 /* ATTRIBUTE */
3815
+ (keyProp.type === 6 /* NodeTypes.ATTRIBUTE */
3808
3816
  ? createSimpleExpression(keyProp.value.content, true)
3809
3817
  : keyProp.exp);
3810
3818
  const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
@@ -3816,17 +3824,17 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3816
3824
  if (memo) {
3817
3825
  memo.exp = processExpression(memo.exp, context);
3818
3826
  }
3819
- if (keyProperty && keyProp.type !== 6 /* ATTRIBUTE */) {
3827
+ if (keyProperty && keyProp.type !== 6 /* NodeTypes.ATTRIBUTE */) {
3820
3828
  keyProperty.value = processExpression(keyProperty.value, context);
3821
3829
  }
3822
3830
  }
3823
- const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
3824
- forNode.source.constType > 0 /* NOT_CONSTANT */;
3831
+ const isStableFragment = forNode.source.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
3832
+ forNode.source.constType > 0 /* ConstantTypes.NOT_CONSTANT */;
3825
3833
  const fragmentFlag = isStableFragment
3826
- ? 64 /* STABLE_FRAGMENT */
3834
+ ? 64 /* PatchFlags.STABLE_FRAGMENT */
3827
3835
  : keyProp
3828
- ? 128 /* KEYED_FRAGMENT */
3829
- : 256 /* UNKEYED_FRAGMENT */;
3836
+ ? 128 /* PatchFlags.KEYED_FRAGMENT */
3837
+ : 256 /* PatchFlags.UNKEYED_FRAGMENT */;
3830
3838
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
3831
3839
  (` /* ${shared.PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
3832
3840
  return () => {
@@ -3836,16 +3844,16 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3836
3844
  // check <template v-for> key placement
3837
3845
  if (isTemplate) {
3838
3846
  node.children.some(c => {
3839
- if (c.type === 1 /* ELEMENT */) {
3847
+ if (c.type === 1 /* NodeTypes.ELEMENT */) {
3840
3848
  const key = findProp(c, 'key');
3841
3849
  if (key) {
3842
- context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3850
+ context.onError(createCompilerError(33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3843
3851
  return true;
3844
3852
  }
3845
3853
  }
3846
3854
  });
3847
3855
  }
3848
- const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* ELEMENT */;
3856
+ const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */;
3849
3857
  const slotOutlet = isSlotOutlet(node)
3850
3858
  ? node
3851
3859
  : isTemplate &&
@@ -3866,8 +3874,8 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3866
3874
  else if (needFragmentWrapper) {
3867
3875
  // <template v-for="..."> with text or multi-elements
3868
3876
  // should generate a fragment block for each loop
3869
- childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* STABLE_FRAGMENT */ +
3870
- (` /* ${shared.PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
3877
+ childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* PatchFlags.STABLE_FRAGMENT */ +
3878
+ (` /* ${shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */]} */`
3871
3879
  ), undefined, undefined, true, undefined, false /* isComponent */);
3872
3880
  }
3873
3881
  else {
@@ -3924,7 +3932,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3924
3932
  // target-agnostic transform used for both Client and SSR
3925
3933
  function processFor(node, dir, context, processCodegen) {
3926
3934
  if (!dir.exp) {
3927
- context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
3935
+ context.onError(createCompilerError(31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */, dir.loc));
3928
3936
  return;
3929
3937
  }
3930
3938
  const parseResult = parseForExpression(
@@ -3932,13 +3940,13 @@ function processFor(node, dir, context, processCodegen) {
3932
3940
  // before expression transform.
3933
3941
  dir.exp, context);
3934
3942
  if (!parseResult) {
3935
- context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3943
+ context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3936
3944
  return;
3937
3945
  }
3938
3946
  const { addIdentifiers, removeIdentifiers, scopes } = context;
3939
3947
  const { source, value, key, index } = parseResult;
3940
3948
  const forNode = {
3941
- type: 11 /* FOR */,
3949
+ type: 11 /* NodeTypes.FOR */,
3942
3950
  loc: dir.loc,
3943
3951
  source,
3944
3952
  valueAlias: value,
@@ -4050,9 +4058,9 @@ const defaultFallback = createSimpleExpression(`undefined`, false);
4050
4058
  // Note the exit callback is executed before buildSlots() on the same node,
4051
4059
  // so only nested slots see positive numbers.
4052
4060
  const trackSlotScopes = (node, context) => {
4053
- if (node.type === 1 /* ELEMENT */ &&
4054
- (node.tagType === 1 /* COMPONENT */ ||
4055
- node.tagType === 3 /* TEMPLATE */)) {
4061
+ if (node.type === 1 /* NodeTypes.ELEMENT */ &&
4062
+ (node.tagType === 1 /* ElementTypes.COMPONENT */ ||
4063
+ node.tagType === 3 /* ElementTypes.TEMPLATE */)) {
4056
4064
  // We are only checking non-empty v-slot here
4057
4065
  // since we only care about slots that introduce scope variables.
4058
4066
  const vSlot = findDir(node, 'slot');
@@ -4125,20 +4133,21 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4125
4133
  let hasNamedDefaultSlot = false;
4126
4134
  const implicitDefaultChildren = [];
4127
4135
  const seenSlotNames = new Set();
4136
+ let conditionalBranchIndex = 0;
4128
4137
  for (let i = 0; i < children.length; i++) {
4129
4138
  const slotElement = children[i];
4130
4139
  let slotDir;
4131
4140
  if (!isTemplateNode(slotElement) ||
4132
4141
  !(slotDir = findDir(slotElement, 'slot', true))) {
4133
4142
  // not a <template v-slot>, skip.
4134
- if (slotElement.type !== 3 /* COMMENT */) {
4143
+ if (slotElement.type !== 3 /* NodeTypes.COMMENT */) {
4135
4144
  implicitDefaultChildren.push(slotElement);
4136
4145
  }
4137
4146
  continue;
4138
4147
  }
4139
4148
  if (onComponentSlot) {
4140
4149
  // already has on-component slot - this is incorrect usage.
4141
- context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
4150
+ context.onError(createCompilerError(37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
4142
4151
  break;
4143
4152
  }
4144
4153
  hasTemplateSlots = true;
@@ -4159,7 +4168,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4159
4168
  let vFor;
4160
4169
  if ((vIf = findDir(slotElement, 'if'))) {
4161
4170
  hasDynamicSlots = true;
4162
- dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
4171
+ dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
4163
4172
  }
4164
4173
  else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
4165
4174
  // find adjacent v-if
@@ -4167,7 +4176,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4167
4176
  let prev;
4168
4177
  while (j--) {
4169
4178
  prev = children[j];
4170
- if (prev.type !== 3 /* COMMENT */) {
4179
+ if (prev.type !== 3 /* NodeTypes.COMMENT */) {
4171
4180
  break;
4172
4181
  }
4173
4182
  }
@@ -4177,15 +4186,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4177
4186
  i--;
4178
4187
  // attach this slot to previous conditional
4179
4188
  let conditional = dynamicSlots[dynamicSlots.length - 1];
4180
- while (conditional.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
4189
+ while (conditional.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
4181
4190
  conditional = conditional.alternate;
4182
4191
  }
4183
4192
  conditional.alternate = vElse.exp
4184
- ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
4185
- : buildDynamicSlot(slotName, slotFunction);
4193
+ ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback)
4194
+ : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
4186
4195
  }
4187
4196
  else {
4188
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
4197
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
4189
4198
  }
4190
4199
  }
4191
4200
  else if ((vFor = findDir(slotElement, 'for'))) {
@@ -4201,14 +4210,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4201
4210
  ]));
4202
4211
  }
4203
4212
  else {
4204
- context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
4213
+ context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
4205
4214
  }
4206
4215
  }
4207
4216
  else {
4208
4217
  // check duplicate static names
4209
4218
  if (staticSlotName) {
4210
4219
  if (seenSlotNames.has(staticSlotName)) {
4211
- context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
4220
+ context.onError(createCompilerError(38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
4212
4221
  continue;
4213
4222
  }
4214
4223
  seenSlotNames.add(staticSlotName);
@@ -4238,7 +4247,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4238
4247
  implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
4239
4248
  // implicit default slot (mixed with named slots)
4240
4249
  if (hasNamedDefaultSlot) {
4241
- context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
4250
+ context.onError(createCompilerError(39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
4242
4251
  }
4243
4252
  else {
4244
4253
  slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
@@ -4246,10 +4255,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4246
4255
  }
4247
4256
  }
4248
4257
  const slotFlag = hasDynamicSlots
4249
- ? 2 /* DYNAMIC */
4258
+ ? 2 /* SlotFlags.DYNAMIC */
4250
4259
  : hasForwardedSlots(node.children)
4251
- ? 3 /* FORWARDED */
4252
- : 1 /* STABLE */;
4260
+ ? 3 /* SlotFlags.FORWARDED */
4261
+ : 1 /* SlotFlags.STABLE */;
4253
4262
  let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
4254
4263
  // 2 = compiled but dynamic = can skip normalization, but must run diff
4255
4264
  // 1 = compiled and static = can skip normalization AND diff as optimized
@@ -4265,28 +4274,32 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4265
4274
  hasDynamicSlots
4266
4275
  };
4267
4276
  }
4268
- function buildDynamicSlot(name, fn) {
4269
- return createObjectExpression([
4277
+ function buildDynamicSlot(name, fn, index) {
4278
+ const props = [
4270
4279
  createObjectProperty(`name`, name),
4271
4280
  createObjectProperty(`fn`, fn)
4272
- ]);
4281
+ ];
4282
+ if (index != null) {
4283
+ props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
4284
+ }
4285
+ return createObjectExpression(props);
4273
4286
  }
4274
4287
  function hasForwardedSlots(children) {
4275
4288
  for (let i = 0; i < children.length; i++) {
4276
4289
  const child = children[i];
4277
4290
  switch (child.type) {
4278
- case 1 /* ELEMENT */:
4279
- if (child.tagType === 2 /* SLOT */ ||
4291
+ case 1 /* NodeTypes.ELEMENT */:
4292
+ if (child.tagType === 2 /* ElementTypes.SLOT */ ||
4280
4293
  hasForwardedSlots(child.children)) {
4281
4294
  return true;
4282
4295
  }
4283
4296
  break;
4284
- case 9 /* IF */:
4297
+ case 9 /* NodeTypes.IF */:
4285
4298
  if (hasForwardedSlots(child.branches))
4286
4299
  return true;
4287
4300
  break;
4288
- case 10 /* IF_BRANCH */:
4289
- case 11 /* FOR */:
4301
+ case 10 /* NodeTypes.IF_BRANCH */:
4302
+ case 11 /* NodeTypes.FOR */:
4290
4303
  if (hasForwardedSlots(child.children))
4291
4304
  return true;
4292
4305
  break;
@@ -4295,9 +4308,9 @@ function hasForwardedSlots(children) {
4295
4308
  return false;
4296
4309
  }
4297
4310
  function isNonWhitespaceContent(node) {
4298
- if (node.type !== 2 /* TEXT */ && node.type !== 12 /* TEXT_CALL */)
4311
+ if (node.type !== 2 /* NodeTypes.TEXT */ && node.type !== 12 /* NodeTypes.TEXT_CALL */)
4299
4312
  return true;
4300
- return node.type === 2 /* TEXT */
4313
+ return node.type === 2 /* NodeTypes.TEXT */
4301
4314
  ? !!node.content.trim()
4302
4315
  : isNonWhitespaceContent(node.content);
4303
4316
  }
@@ -4311,13 +4324,13 @@ const transformElement = (node, context) => {
4311
4324
  // processed and merged.
4312
4325
  return function postTransformElement() {
4313
4326
  node = context.currentNode;
4314
- if (!(node.type === 1 /* ELEMENT */ &&
4315
- (node.tagType === 0 /* ELEMENT */ ||
4316
- node.tagType === 1 /* COMPONENT */))) {
4327
+ if (!(node.type === 1 /* NodeTypes.ELEMENT */ &&
4328
+ (node.tagType === 0 /* ElementTypes.ELEMENT */ ||
4329
+ node.tagType === 1 /* ElementTypes.COMPONENT */))) {
4317
4330
  return;
4318
4331
  }
4319
4332
  const { tag, props } = node;
4320
- const isComponent = node.tagType === 1 /* COMPONENT */;
4333
+ const isComponent = node.tagType === 1 /* ElementTypes.COMPONENT */;
4321
4334
  // The goal of the transform is to create a codegenNode implementing the
4322
4335
  // VNodeCall interface.
4323
4336
  let vnodeTag = isComponent
@@ -4368,9 +4381,9 @@ const transformElement = (node, context) => {
4368
4381
  // collected by a parent block.
4369
4382
  shouldUseBlock = true;
4370
4383
  // 2. Force keep-alive to always be updated, since it uses raw children.
4371
- patchFlag |= 1024 /* DYNAMIC_SLOTS */;
4384
+ patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
4372
4385
  if (node.children.length > 1) {
4373
- context.onError(createCompilerError(45 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
4386
+ context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
4374
4387
  start: node.children[0].loc.start,
4375
4388
  end: node.children[node.children.length - 1].loc.end,
4376
4389
  source: ''
@@ -4386,22 +4399,22 @@ const transformElement = (node, context) => {
4386
4399
  const { slots, hasDynamicSlots } = buildSlots(node, context);
4387
4400
  vnodeChildren = slots;
4388
4401
  if (hasDynamicSlots) {
4389
- patchFlag |= 1024 /* DYNAMIC_SLOTS */;
4402
+ patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
4390
4403
  }
4391
4404
  }
4392
4405
  else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
4393
4406
  const child = node.children[0];
4394
4407
  const type = child.type;
4395
4408
  // check for dynamic text children
4396
- const hasDynamicTextChild = type === 5 /* INTERPOLATION */ ||
4397
- type === 8 /* COMPOUND_EXPRESSION */;
4409
+ const hasDynamicTextChild = type === 5 /* NodeTypes.INTERPOLATION */ ||
4410
+ type === 8 /* NodeTypes.COMPOUND_EXPRESSION */;
4398
4411
  if (hasDynamicTextChild &&
4399
- getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
4400
- patchFlag |= 1 /* TEXT */;
4412
+ getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
4413
+ patchFlag |= 1 /* PatchFlags.TEXT */;
4401
4414
  }
4402
4415
  // pass directly if the only child is a text node
4403
4416
  // (plain / interpolation / expression)
4404
- if (hasDynamicTextChild || type === 2 /* TEXT */) {
4417
+ if (hasDynamicTextChild || type === 2 /* NodeTypes.TEXT */) {
4405
4418
  vnodeChildren = child;
4406
4419
  }
4407
4420
  else {
@@ -4443,8 +4456,8 @@ function resolveComponentType(node, context, ssr = false) {
4443
4456
  const isProp = findProp(node, 'is');
4444
4457
  if (isProp) {
4445
4458
  if (isExplicitDynamic ||
4446
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))) {
4447
- const exp = isProp.type === 6 /* ATTRIBUTE */
4459
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))) {
4460
+ const exp = isProp.type === 6 /* NodeTypes.ATTRIBUTE */
4448
4461
  ? isProp.value && createSimpleExpression(isProp.value.content, true)
4449
4462
  : isProp.exp;
4450
4463
  if (exp) {
@@ -4453,7 +4466,7 @@ function resolveComponentType(node, context, ssr = false) {
4453
4466
  ]);
4454
4467
  }
4455
4468
  }
4456
- else if (isProp.type === 6 /* ATTRIBUTE */ &&
4469
+ else if (isProp.type === 6 /* NodeTypes.ATTRIBUTE */ &&
4457
4470
  isProp.value.content.startsWith('vue:')) {
4458
4471
  // <button is="vue:xxx">
4459
4472
  // if not <component>, only is value that starts with "vue:" will be
@@ -4527,17 +4540,17 @@ function resolveSetupReference(name, context) {
4527
4540
  return PascalName;
4528
4541
  }
4529
4542
  };
4530
- const fromConst = checkType("setup-const" /* SETUP_CONST */) ||
4531
- checkType("setup-reactive-const" /* SETUP_REACTIVE_CONST */);
4543
+ const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
4544
+ checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
4532
4545
  if (fromConst) {
4533
4546
  return context.inline
4534
4547
  ? // in inline mode, const setup bindings (e.g. imports) can be used as-is
4535
4548
  fromConst
4536
4549
  : `$setup[${JSON.stringify(fromConst)}]`;
4537
4550
  }
4538
- const fromMaybeRef = checkType("setup-let" /* SETUP_LET */) ||
4539
- checkType("setup-ref" /* SETUP_REF */) ||
4540
- checkType("setup-maybe-ref" /* SETUP_MAYBE_REF */);
4551
+ const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
4552
+ checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
4553
+ checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
4541
4554
  if (fromMaybeRef) {
4542
4555
  return context.inline
4543
4556
  ? // setup scope bindings that may be refs need to be unrefed
@@ -4579,9 +4592,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4579
4592
  if (isEventHandler && shared.isReservedProp(name)) {
4580
4593
  hasVnodeHook = true;
4581
4594
  }
4582
- if (value.type === 20 /* JS_CACHE_EXPRESSION */ ||
4583
- ((value.type === 4 /* SIMPLE_EXPRESSION */ ||
4584
- value.type === 8 /* COMPOUND_EXPRESSION */) &&
4595
+ if (value.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */ ||
4596
+ ((value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
4597
+ value.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) &&
4585
4598
  getConstantType(value, context) > 0)) {
4586
4599
  // skip if the prop is a cached handler or has constant value
4587
4600
  return;
@@ -4612,7 +4625,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4612
4625
  for (let i = 0; i < props.length; i++) {
4613
4626
  // static attribute
4614
4627
  const prop = props[i];
4615
- if (prop.type === 6 /* ATTRIBUTE */) {
4628
+ if (prop.type === 6 /* NodeTypes.ATTRIBUTE */) {
4616
4629
  const { loc, name, value } = prop;
4617
4630
  let isStatic = true;
4618
4631
  if (name === 'ref') {
@@ -4634,7 +4647,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4634
4647
  if (name === 'is' &&
4635
4648
  (isComponentTag(tag) ||
4636
4649
  (value && value.content.startsWith('vue:')) ||
4637
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
4650
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context)))) {
4638
4651
  continue;
4639
4652
  }
4640
4653
  properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
@@ -4647,7 +4660,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4647
4660
  // skip v-slot - it is handled by its dedicated transform.
4648
4661
  if (name === 'slot') {
4649
4662
  if (!isComponent) {
4650
- context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
4663
+ context.onError(createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, loc));
4651
4664
  }
4652
4665
  continue;
4653
4666
  }
@@ -4660,7 +4673,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4660
4673
  (isVBind &&
4661
4674
  isStaticArgOf(arg, 'is') &&
4662
4675
  (isComponentTag(tag) ||
4663
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
4676
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))))) {
4664
4677
  continue;
4665
4678
  }
4666
4679
  // skip v-on in SSR compilation
@@ -4691,9 +4704,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4691
4704
  // 2.x v-bind object order compat
4692
4705
  {
4693
4706
  const hasOverridableKeys = mergeArgs.some(arg => {
4694
- if (arg.type === 15 /* JS_OBJECT_EXPRESSION */) {
4707
+ if (arg.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
4695
4708
  return arg.properties.some(({ key }) => {
4696
- if (key.type !== 4 /* SIMPLE_EXPRESSION */ ||
4709
+ if (key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
4697
4710
  !key.isStatic) {
4698
4711
  return true;
4699
4712
  }
@@ -4708,10 +4721,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4708
4721
  }
4709
4722
  });
4710
4723
  if (hasOverridableKeys) {
4711
- checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
4724
+ checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
4712
4725
  }
4713
4726
  }
4714
- if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context)) {
4727
+ if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
4715
4728
  mergeArgs.unshift(exp);
4716
4729
  continue;
4717
4730
  }
@@ -4721,17 +4734,17 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4721
4734
  else {
4722
4735
  // v-on="obj" -> toHandlers(obj)
4723
4736
  mergeArgs.push({
4724
- type: 14 /* JS_CALL_EXPRESSION */,
4737
+ type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
4725
4738
  loc,
4726
4739
  callee: context.helper(TO_HANDLERS),
4727
- arguments: [exp]
4740
+ arguments: isComponent ? [exp] : [exp, `true`]
4728
4741
  });
4729
4742
  }
4730
4743
  }
4731
4744
  else {
4732
4745
  context.onError(createCompilerError(isVBind
4733
- ? 34 /* X_V_BIND_NO_EXPRESSION */
4734
- : 35 /* X_V_ON_NO_EXPRESSION */, loc));
4746
+ ? 34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */
4747
+ : 35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
4735
4748
  }
4736
4749
  continue;
4737
4750
  }
@@ -4778,31 +4791,31 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4778
4791
  }
4779
4792
  // patchFlag analysis
4780
4793
  if (hasDynamicKeys) {
4781
- patchFlag |= 16 /* FULL_PROPS */;
4794
+ patchFlag |= 16 /* PatchFlags.FULL_PROPS */;
4782
4795
  }
4783
4796
  else {
4784
4797
  if (hasClassBinding && !isComponent) {
4785
- patchFlag |= 2 /* CLASS */;
4798
+ patchFlag |= 2 /* PatchFlags.CLASS */;
4786
4799
  }
4787
4800
  if (hasStyleBinding && !isComponent) {
4788
- patchFlag |= 4 /* STYLE */;
4801
+ patchFlag |= 4 /* PatchFlags.STYLE */;
4789
4802
  }
4790
4803
  if (dynamicPropNames.length) {
4791
- patchFlag |= 8 /* PROPS */;
4804
+ patchFlag |= 8 /* PatchFlags.PROPS */;
4792
4805
  }
4793
4806
  if (hasHydrationEventBinding) {
4794
- patchFlag |= 32 /* HYDRATE_EVENTS */;
4807
+ patchFlag |= 32 /* PatchFlags.HYDRATE_EVENTS */;
4795
4808
  }
4796
4809
  }
4797
4810
  if (!shouldUseBlock &&
4798
- (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
4811
+ (patchFlag === 0 || patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) &&
4799
4812
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
4800
- patchFlag |= 512 /* NEED_PATCH */;
4813
+ patchFlag |= 512 /* PatchFlags.NEED_PATCH */;
4801
4814
  }
4802
4815
  // pre-normalize props, SSR is skipped for now
4803
4816
  if (!context.inSSR && propsExpression) {
4804
4817
  switch (propsExpression.type) {
4805
- case 15 /* JS_OBJECT_EXPRESSION */:
4818
+ case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
4806
4819
  // means that there is no v-bind,
4807
4820
  // but still need to deal with dynamic key binding
4808
4821
  let classKeyIndex = -1;
@@ -4833,11 +4846,11 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4833
4846
  // the static style is compiled into an object,
4834
4847
  // so use `hasStyleBinding` to ensure that it is a dynamic style binding
4835
4848
  (hasStyleBinding ||
4836
- (styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
4849
+ (styleProp.value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
4837
4850
  styleProp.value.content.trim()[0] === `[`) ||
4838
4851
  // v-bind:style and style both exist,
4839
4852
  // v-bind:style with static literal object
4840
- styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
4853
+ styleProp.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */)) {
4841
4854
  styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
4842
4855
  }
4843
4856
  }
@@ -4846,7 +4859,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4846
4859
  propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
4847
4860
  }
4848
4861
  break;
4849
- case 14 /* JS_CALL_EXPRESSION */:
4862
+ case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
4850
4863
  // mergeProps call, do nothing
4851
4864
  break;
4852
4865
  default:
@@ -4879,7 +4892,7 @@ function dedupeProperties(properties) {
4879
4892
  for (let i = 0; i < properties.length; i++) {
4880
4893
  const prop = properties[i];
4881
4894
  // dynamic keys are always allowed
4882
- if (prop.key.type === 8 /* COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
4895
+ if (prop.key.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
4883
4896
  deduped.push(prop);
4884
4897
  continue;
4885
4898
  }
@@ -4899,7 +4912,7 @@ function dedupeProperties(properties) {
4899
4912
  return deduped;
4900
4913
  }
4901
4914
  function mergeAsArray(existing, incoming) {
4902
- if (existing.value.type === 17 /* JS_ARRAY_EXPRESSION */) {
4915
+ if (existing.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
4903
4916
  existing.value.elements.push(incoming.value);
4904
4917
  }
4905
4918
  else {
@@ -5012,7 +5025,7 @@ function processSlotOutlet(node, context) {
5012
5025
  const nonNameProps = [];
5013
5026
  for (let i = 0; i < node.props.length; i++) {
5014
5027
  const p = node.props[i];
5015
- if (p.type === 6 /* ATTRIBUTE */) {
5028
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
5016
5029
  if (p.value) {
5017
5030
  if (p.name === 'name') {
5018
5031
  slotName = JSON.stringify(p.value.content);
@@ -5040,7 +5053,7 @@ function processSlotOutlet(node, context) {
5040
5053
  const { props, directives } = buildProps(node, context, nonNameProps, false, false);
5041
5054
  slotProps = props;
5042
5055
  if (directives.length) {
5043
- context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
5056
+ context.onError(createCompilerError(36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
5044
5057
  }
5045
5058
  }
5046
5059
  return {
@@ -5053,18 +5066,26 @@ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?functio
5053
5066
  const transformOn = (dir, node, context, augmentor) => {
5054
5067
  const { loc, modifiers, arg } = dir;
5055
5068
  if (!dir.exp && !modifiers.length) {
5056
- context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
5069
+ context.onError(createCompilerError(35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
5057
5070
  }
5058
5071
  let eventName;
5059
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
5072
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5060
5073
  if (arg.isStatic) {
5061
5074
  let rawName = arg.content;
5062
5075
  // TODO deprecate @vnodeXXX usage
5063
5076
  if (rawName.startsWith('vue:')) {
5064
5077
  rawName = `vnode-${rawName.slice(4)}`;
5065
5078
  }
5066
- // for all event listeners, auto convert it to camelCase. See issue #2249
5067
- eventName = createSimpleExpression(shared.toHandlerKey(shared.camelize(rawName)), true, arg.loc);
5079
+ const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
5080
+ rawName.startsWith('vnode') ||
5081
+ !/[A-Z]/.test(rawName)
5082
+ ? // for component and vnode lifecycle event listeners, auto convert
5083
+ // it to camelCase. See issue #2249
5084
+ shared.toHandlerKey(shared.camelize(rawName))
5085
+ // preserve case for plain element listeners that have uppercase
5086
+ // letters, as these may be custom elements' custom events
5087
+ : `on:${rawName}`;
5088
+ eventName = createSimpleExpression(eventString, true, arg.loc);
5068
5089
  }
5069
5090
  else {
5070
5091
  // #2388
@@ -5104,13 +5125,13 @@ const transformOn = (dir, node, context, augmentor) => {
5104
5125
  !context.inVOnce &&
5105
5126
  // runtime constants don't need to be cached
5106
5127
  // (this is analyzed by compileScript in SFC <script setup>)
5107
- !(exp.type === 4 /* SIMPLE_EXPRESSION */ && exp.constType > 0) &&
5128
+ !(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && exp.constType > 0) &&
5108
5129
  // #1541 bail if this is a member exp handler passed to a component -
5109
5130
  // we need to use the original function to preserve arity,
5110
5131
  // e.g. <transition> relies on checking cb.length to determine
5111
5132
  // transition end handling. Inline function is ok since its arity
5112
5133
  // is preserved even when cached.
5113
- !(isMemberExp && node.tagType === 1 /* COMPONENT */) &&
5134
+ !(isMemberExp && node.tagType === 1 /* ElementTypes.COMPONENT */) &&
5114
5135
  // bail if the function references closure variables (v-for, v-slot)
5115
5136
  // it must be passed fresh to avoid stale values.
5116
5137
  !hasScopeRef(exp, context.identifiers);
@@ -5119,7 +5140,7 @@ const transformOn = (dir, node, context, augmentor) => {
5119
5140
  // below) so that it always accesses the latest value when called - thus
5120
5141
  // avoiding the need to be patched.
5121
5142
  if (shouldCache && isMemberExp) {
5122
- if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
5143
+ if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5123
5144
  exp.content = `${exp.content} && ${exp.content}(...args)`;
5124
5145
  }
5125
5146
  else {
@@ -5166,7 +5187,7 @@ const transformOn = (dir, node, context, augmentor) => {
5166
5187
  const transformBind = (dir, _node, context) => {
5167
5188
  const { exp, modifiers, loc } = dir;
5168
5189
  const arg = dir.arg;
5169
- if (arg.type !== 4 /* SIMPLE_EXPRESSION */) {
5190
+ if (arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5170
5191
  arg.children.unshift(`(`);
5171
5192
  arg.children.push(`) || ""`);
5172
5193
  }
@@ -5175,7 +5196,7 @@ const transformBind = (dir, _node, context) => {
5175
5196
  }
5176
5197
  // .sync is replaced by v-model:arg
5177
5198
  if (modifiers.includes('camel')) {
5178
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
5199
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5179
5200
  if (arg.isStatic) {
5180
5201
  arg.content = shared.camelize(arg.content);
5181
5202
  }
@@ -5197,8 +5218,8 @@ const transformBind = (dir, _node, context) => {
5197
5218
  }
5198
5219
  }
5199
5220
  if (!exp ||
5200
- (exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
5201
- context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
5221
+ (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !exp.content.trim())) {
5222
+ context.onError(createCompilerError(34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */, loc));
5202
5223
  return {
5203
5224
  props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
5204
5225
  };
@@ -5208,7 +5229,7 @@ const transformBind = (dir, _node, context) => {
5208
5229
  };
5209
5230
  };
5210
5231
  const injectPrefix = (arg, prefix) => {
5211
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
5232
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5212
5233
  if (arg.isStatic) {
5213
5234
  arg.content = prefix + arg.content;
5214
5235
  }
@@ -5225,10 +5246,10 @@ const injectPrefix = (arg, prefix) => {
5225
5246
  // Merge adjacent text nodes and expressions into a single expression
5226
5247
  // e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
5227
5248
  const transformText = (node, context) => {
5228
- if (node.type === 0 /* ROOT */ ||
5229
- node.type === 1 /* ELEMENT */ ||
5230
- node.type === 11 /* FOR */ ||
5231
- node.type === 10 /* IF_BRANCH */) {
5249
+ if (node.type === 0 /* NodeTypes.ROOT */ ||
5250
+ node.type === 1 /* NodeTypes.ELEMENT */ ||
5251
+ node.type === 11 /* NodeTypes.FOR */ ||
5252
+ node.type === 10 /* NodeTypes.IF_BRANCH */) {
5232
5253
  // perform the transform on node exit so that all expressions have already
5233
5254
  // been processed.
5234
5255
  return () => {
@@ -5263,15 +5284,15 @@ const transformText = (node, context) => {
5263
5284
  // setting textContent of the element.
5264
5285
  // for component root it's always normalized anyway.
5265
5286
  (children.length === 1 &&
5266
- (node.type === 0 /* ROOT */ ||
5267
- (node.type === 1 /* ELEMENT */ &&
5268
- node.tagType === 0 /* ELEMENT */ &&
5287
+ (node.type === 0 /* NodeTypes.ROOT */ ||
5288
+ (node.type === 1 /* NodeTypes.ELEMENT */ &&
5289
+ node.tagType === 0 /* ElementTypes.ELEMENT */ &&
5269
5290
  // #3756
5270
5291
  // custom directives can potentially add DOM elements arbitrarily,
5271
5292
  // we need to avoid setting textContent of the element at runtime
5272
5293
  // to avoid accidentally overwriting the DOM elements added
5273
5294
  // by the user through custom directives.
5274
- !node.props.find(p => p.type === 7 /* DIRECTIVE */ &&
5295
+ !node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
5275
5296
  !context.directiveTransforms[p.name]) &&
5276
5297
  // in compat mode, <template> tags with no special directives
5277
5298
  // will be rendered as a fragment so its children must be
@@ -5283,21 +5304,21 @@ const transformText = (node, context) => {
5283
5304
  // runtime normalization.
5284
5305
  for (let i = 0; i < children.length; i++) {
5285
5306
  const child = children[i];
5286
- if (isText(child) || child.type === 8 /* COMPOUND_EXPRESSION */) {
5307
+ if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5287
5308
  const callArgs = [];
5288
5309
  // createTextVNode defaults to single whitespace, so if it is a
5289
5310
  // single space the code could be an empty call to save bytes.
5290
- if (child.type !== 2 /* TEXT */ || child.content !== ' ') {
5311
+ if (child.type !== 2 /* NodeTypes.TEXT */ || child.content !== ' ') {
5291
5312
  callArgs.push(child);
5292
5313
  }
5293
5314
  // mark dynamic text with flag so it gets patched inside a block
5294
5315
  if (!context.ssr &&
5295
- getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
5296
- callArgs.push(1 /* TEXT */ +
5297
- (` /* ${shared.PatchFlagNames[1 /* TEXT */]} */` ));
5316
+ getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
5317
+ callArgs.push(1 /* PatchFlags.TEXT */ +
5318
+ (` /* ${shared.PatchFlagNames[1 /* PatchFlags.TEXT */]} */` ));
5298
5319
  }
5299
5320
  children[i] = {
5300
- type: 12 /* TEXT_CALL */,
5321
+ type: 12 /* NodeTypes.TEXT_CALL */,
5301
5322
  content: child,
5302
5323
  loc: child.loc,
5303
5324
  codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
@@ -5310,7 +5331,7 @@ const transformText = (node, context) => {
5310
5331
 
5311
5332
  const seen = new WeakSet();
5312
5333
  const transformOnce = (node, context) => {
5313
- if (node.type === 1 /* ELEMENT */ && findDir(node, 'once', true)) {
5334
+ if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5314
5335
  if (seen.has(node) || context.inVOnce) {
5315
5336
  return;
5316
5337
  }
@@ -5330,26 +5351,26 @@ const transformOnce = (node, context) => {
5330
5351
  const transformModel = (dir, node, context) => {
5331
5352
  const { exp, arg } = dir;
5332
5353
  if (!exp) {
5333
- context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
5354
+ context.onError(createCompilerError(41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */, dir.loc));
5334
5355
  return createTransformProps();
5335
5356
  }
5336
5357
  const rawExp = exp.loc.source;
5337
- const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
5358
+ const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
5338
5359
  // im SFC <script setup> inline mode, the exp may have been transformed into
5339
5360
  // _unref(exp)
5340
5361
  const bindingType = context.bindingMetadata[rawExp];
5341
5362
  const maybeRef = context.inline &&
5342
5363
  bindingType &&
5343
- bindingType !== "setup-const" /* SETUP_CONST */;
5364
+ bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
5344
5365
  if (!expString.trim() ||
5345
5366
  (!isMemberExpression(expString, context) && !maybeRef)) {
5346
- context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5367
+ context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5347
5368
  return createTransformProps();
5348
5369
  }
5349
5370
  if (context.prefixIdentifiers &&
5350
5371
  isSimpleIdentifier(expString) &&
5351
5372
  context.identifiers[expString]) {
5352
- context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5373
+ context.onError(createCompilerError(43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5353
5374
  return createTransformProps();
5354
5375
  }
5355
5376
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
@@ -5361,7 +5382,7 @@ const transformModel = (dir, node, context) => {
5361
5382
  let assignmentExp;
5362
5383
  const eventArg = context.isTS ? `($event: any)` : `$event`;
5363
5384
  if (maybeRef) {
5364
- if (bindingType === "setup-ref" /* SETUP_REF */) {
5385
+ if (bindingType === "setup-ref" /* BindingTypes.SETUP_REF */) {
5365
5386
  // v-model used on known ref.
5366
5387
  assignmentExp = createCompoundExpression([
5367
5388
  `${eventArg} => ((`,
@@ -5372,7 +5393,7 @@ const transformModel = (dir, node, context) => {
5372
5393
  else {
5373
5394
  // v-model used on a potentially ref binding in <script setup> inline mode.
5374
5395
  // the assignment needs to check whether the binding is actually a ref.
5375
- const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
5396
+ const altAssignment = bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ? `${rawExp} = $event` : `null`;
5376
5397
  assignmentExp = createCompoundExpression([
5377
5398
  `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
5378
5399
  createSimpleExpression(rawExp, false, exp.loc),
@@ -5401,7 +5422,7 @@ const transformModel = (dir, node, context) => {
5401
5422
  props[1].value = context.cache(props[1].value);
5402
5423
  }
5403
5424
  // modelModifiers: { foo: true, "bar-baz": true }
5404
- if (dir.modifiers.length && node.tagType === 1 /* COMPONENT */) {
5425
+ if (dir.modifiers.length && node.tagType === 1 /* ElementTypes.COMPONENT */) {
5405
5426
  const modifiers = dir.modifiers
5406
5427
  .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
5407
5428
  .join(`, `);
@@ -5410,7 +5431,7 @@ const transformModel = (dir, node, context) => {
5410
5431
  ? `${arg.content}Modifiers`
5411
5432
  : createCompoundExpression([arg, ' + "Modifiers"'])
5412
5433
  : `modelModifiers`;
5413
- props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* CAN_HOIST */)));
5434
+ props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* ConstantTypes.CAN_HOIST */)));
5414
5435
  }
5415
5436
  return createTransformProps(props);
5416
5437
  };
@@ -5420,17 +5441,17 @@ function createTransformProps(props = []) {
5420
5441
 
5421
5442
  const validDivisionCharRE = /[\w).+\-_$\]]/;
5422
5443
  const transformFilter = (node, context) => {
5423
- if (!isCompatEnabled("COMPILER_FILTER" /* COMPILER_FILTERS */, context)) {
5444
+ if (!isCompatEnabled("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context)) {
5424
5445
  return;
5425
5446
  }
5426
- if (node.type === 5 /* INTERPOLATION */) {
5447
+ if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
5427
5448
  // filter rewrite is applied before expression transform so only
5428
5449
  // simple expressions are possible at this stage
5429
5450
  rewriteFilter(node.content, context);
5430
5451
  }
5431
- if (node.type === 1 /* ELEMENT */) {
5452
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
5432
5453
  node.props.forEach((prop) => {
5433
- if (prop.type === 7 /* DIRECTIVE */ &&
5454
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */ &&
5434
5455
  prop.name !== 'for' &&
5435
5456
  prop.exp) {
5436
5457
  rewriteFilter(prop.exp, context);
@@ -5439,7 +5460,7 @@ const transformFilter = (node, context) => {
5439
5460
  }
5440
5461
  };
5441
5462
  function rewriteFilter(node, context) {
5442
- if (node.type === 4 /* SIMPLE_EXPRESSION */) {
5463
+ if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5443
5464
  parseFilter(node, context);
5444
5465
  }
5445
5466
  else {
@@ -5447,13 +5468,13 @@ function rewriteFilter(node, context) {
5447
5468
  const child = node.children[i];
5448
5469
  if (typeof child !== 'object')
5449
5470
  continue;
5450
- if (child.type === 4 /* SIMPLE_EXPRESSION */) {
5471
+ if (child.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5451
5472
  parseFilter(child, context);
5452
5473
  }
5453
- else if (child.type === 8 /* COMPOUND_EXPRESSION */) {
5474
+ else if (child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5454
5475
  rewriteFilter(node, context);
5455
5476
  }
5456
- else if (child.type === 5 /* INTERPOLATION */) {
5477
+ else if (child.type === 5 /* NodeTypes.INTERPOLATION */) {
5457
5478
  rewriteFilter(child.content, context);
5458
5479
  }
5459
5480
  }
@@ -5561,7 +5582,7 @@ function parseFilter(node, context) {
5561
5582
  lastFilterIndex = i + 1;
5562
5583
  }
5563
5584
  if (filters.length) {
5564
- warnDeprecation("COMPILER_FILTER" /* COMPILER_FILTERS */, context, node.loc);
5585
+ warnDeprecation("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context, node.loc);
5565
5586
  for (i = 0; i < filters.length; i++) {
5566
5587
  expression = wrapFilter(expression, filters[i], context);
5567
5588
  }
@@ -5585,7 +5606,7 @@ function wrapFilter(exp, filter, context) {
5585
5606
 
5586
5607
  const seen$1 = new WeakSet();
5587
5608
  const transformMemo = (node, context) => {
5588
- if (node.type === 1 /* ELEMENT */) {
5609
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
5589
5610
  const dir = findDir(node, 'memo');
5590
5611
  if (!dir || seen$1.has(node)) {
5591
5612
  return;
@@ -5594,9 +5615,9 @@ const transformMemo = (node, context) => {
5594
5615
  return () => {
5595
5616
  const codegenNode = node.codegenNode ||
5596
5617
  context.currentNode.codegenNode;
5597
- if (codegenNode && codegenNode.type === 13 /* VNODE_CALL */) {
5618
+ if (codegenNode && codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
5598
5619
  // non-component sub tree should be turned into a block
5599
- if (node.tagType !== 1 /* COMPONENT */) {
5620
+ if (node.tagType !== 1 /* ElementTypes.COMPONENT */) {
5600
5621
  makeBlock(codegenNode, context);
5601
5622
  }
5602
5623
  node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
@@ -5644,10 +5665,10 @@ function baseCompile(template, options = {}) {
5644
5665
  const isModuleMode = options.mode === 'module';
5645
5666
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
5646
5667
  if (!prefixIdentifiers && options.cacheHandlers) {
5647
- onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
5668
+ onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5648
5669
  }
5649
5670
  if (options.scopeId && !isModuleMode) {
5650
- onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
5671
+ onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5651
5672
  }
5652
5673
  const ast = shared.isString(template) ? baseParse(template, options) : template;
5653
5674
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);