@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.
@@ -22,65 +22,65 @@ function createCompilerError(code, loc, messages, additionalMessage) {
22
22
  }
23
23
  const errorMessages = {
24
24
  // parse errors
25
- [0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
26
- [1 /* CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
27
- [2 /* DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
28
- [3 /* END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
29
- [4 /* END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
30
- [5 /* EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
31
- [6 /* EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
32
- [7 /* EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
33
- [8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
34
- [9 /* EOF_IN_TAG */]: 'Unexpected EOF in tag.',
35
- [10 /* INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
36
- [11 /* INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
37
- [12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
38
- [13 /* MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
39
- [14 /* MISSING_END_TAG_NAME */]: 'End tag name was expected.',
40
- [15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
41
- [16 /* NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
42
- [17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
43
- [18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
44
- [19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
45
- [21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
46
- [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
47
- [22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
25
+ [0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
26
+ [1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
27
+ [2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
28
+ [3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
29
+ [4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
30
+ [5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
31
+ [6 /* ErrorCodes.EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
32
+ [7 /* ErrorCodes.EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
33
+ [8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
34
+ [9 /* ErrorCodes.EOF_IN_TAG */]: 'Unexpected EOF in tag.',
35
+ [10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
36
+ [11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
37
+ [12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
38
+ [13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
39
+ [14 /* ErrorCodes.MISSING_END_TAG_NAME */]: 'End tag name was expected.',
40
+ [15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
41
+ [16 /* ErrorCodes.NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
42
+ [17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
43
+ [18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
44
+ [19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
45
+ [21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
46
+ [20 /* ErrorCodes.UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
47
+ [22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
48
48
  // Vue-specific parse errors
49
- [23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
50
- [24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
51
- [25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
52
- [27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
49
+ [23 /* ErrorCodes.X_INVALID_END_TAG */]: 'Invalid end tag.',
50
+ [24 /* ErrorCodes.X_MISSING_END_TAG */]: 'Element is missing end tag.',
51
+ [25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
52
+ [27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
53
53
  'Note that dynamic directive argument cannot contain spaces.',
54
- [26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
54
+ [26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
55
55
  // transform errors
56
- [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
57
- [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
58
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
59
- [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
60
- [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
61
- [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
62
- [34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
63
- [35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
64
- [36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
65
- [37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
56
+ [28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
57
+ [29 /* ErrorCodes.X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
58
+ [30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
59
+ [31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
60
+ [32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
61
+ [33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
62
+ [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
63
+ [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
64
+ [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
65
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
66
66
  `When there are multiple named slots, all slots should use <template> ` +
67
67
  `syntax to avoid scope ambiguity.`,
68
- [38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
69
- [39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
68
+ [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
69
+ [39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
70
70
  `default slot. These children will be ignored.`,
71
- [40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
72
- [41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
73
- [42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
74
- [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.`,
75
- [44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
76
- [45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
71
+ [40 /* ErrorCodes.X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
72
+ [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
73
+ [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
74
+ [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.`,
75
+ [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
76
+ [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
77
77
  // generic errors
78
- [46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
79
- [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
80
- [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
81
- [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
78
+ [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
79
+ [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
80
+ [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
81
+ [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
82
82
  // just to fulfill types
83
- [50 /* __EXTEND_POINT__ */]: ``
83
+ [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
84
84
  };
85
85
 
86
86
  const FRAGMENT = Symbol(``);
@@ -183,7 +183,7 @@ const locStub = {
183
183
  };
184
184
  function createRoot(children, loc = locStub) {
185
185
  return {
186
- type: 0 /* ROOT */,
186
+ type: 0 /* NodeTypes.ROOT */,
187
187
  children,
188
188
  helpers: [],
189
189
  components: [],
@@ -210,7 +210,7 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
210
210
  }
211
211
  }
212
212
  return {
213
- type: 13 /* VNODE_CALL */,
213
+ type: 13 /* NodeTypes.VNODE_CALL */,
214
214
  tag,
215
215
  props,
216
216
  children,
@@ -225,38 +225,38 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
225
225
  }
226
226
  function createArrayExpression(elements, loc = locStub) {
227
227
  return {
228
- type: 17 /* JS_ARRAY_EXPRESSION */,
228
+ type: 17 /* NodeTypes.JS_ARRAY_EXPRESSION */,
229
229
  loc,
230
230
  elements
231
231
  };
232
232
  }
233
233
  function createObjectExpression(properties, loc = locStub) {
234
234
  return {
235
- type: 15 /* JS_OBJECT_EXPRESSION */,
235
+ type: 15 /* NodeTypes.JS_OBJECT_EXPRESSION */,
236
236
  loc,
237
237
  properties
238
238
  };
239
239
  }
240
240
  function createObjectProperty(key, value) {
241
241
  return {
242
- type: 16 /* JS_PROPERTY */,
242
+ type: 16 /* NodeTypes.JS_PROPERTY */,
243
243
  loc: locStub,
244
244
  key: shared.isString(key) ? createSimpleExpression(key, true) : key,
245
245
  value
246
246
  };
247
247
  }
248
- function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
248
+ function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* ConstantTypes.NOT_CONSTANT */) {
249
249
  return {
250
- type: 4 /* SIMPLE_EXPRESSION */,
250
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
251
251
  loc,
252
252
  content,
253
253
  isStatic,
254
- constType: isStatic ? 3 /* CAN_STRINGIFY */ : constType
254
+ constType: isStatic ? 3 /* ConstantTypes.CAN_STRINGIFY */ : constType
255
255
  };
256
256
  }
257
257
  function createInterpolation(content, loc) {
258
258
  return {
259
- type: 5 /* INTERPOLATION */,
259
+ type: 5 /* NodeTypes.INTERPOLATION */,
260
260
  loc,
261
261
  content: shared.isString(content)
262
262
  ? createSimpleExpression(content, false, loc)
@@ -265,14 +265,14 @@ function createInterpolation(content, loc) {
265
265
  }
266
266
  function createCompoundExpression(children, loc = locStub) {
267
267
  return {
268
- type: 8 /* COMPOUND_EXPRESSION */,
268
+ type: 8 /* NodeTypes.COMPOUND_EXPRESSION */,
269
269
  loc,
270
270
  children
271
271
  };
272
272
  }
273
273
  function createCallExpression(callee, args = [], loc = locStub) {
274
274
  return {
275
- type: 14 /* JS_CALL_EXPRESSION */,
275
+ type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
276
276
  loc,
277
277
  callee,
278
278
  arguments: args
@@ -280,7 +280,7 @@ function createCallExpression(callee, args = [], loc = locStub) {
280
280
  }
281
281
  function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
282
282
  return {
283
- type: 18 /* JS_FUNCTION_EXPRESSION */,
283
+ type: 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */,
284
284
  params,
285
285
  returns,
286
286
  newline,
@@ -290,7 +290,7 @@ function createFunctionExpression(params, returns = undefined, newline = false,
290
290
  }
291
291
  function createConditionalExpression(test, consequent, alternate, newline = true) {
292
292
  return {
293
- type: 19 /* JS_CONDITIONAL_EXPRESSION */,
293
+ type: 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */,
294
294
  test,
295
295
  consequent,
296
296
  alternate,
@@ -300,7 +300,7 @@ function createConditionalExpression(test, consequent, alternate, newline = true
300
300
  }
301
301
  function createCacheExpression(index, value, isVNode = false) {
302
302
  return {
303
- type: 20 /* JS_CACHE_EXPRESSION */,
303
+ type: 20 /* NodeTypes.JS_CACHE_EXPRESSION */,
304
304
  index,
305
305
  value,
306
306
  isVNode,
@@ -309,21 +309,21 @@ function createCacheExpression(index, value, isVNode = false) {
309
309
  }
310
310
  function createBlockStatement(body) {
311
311
  return {
312
- type: 21 /* JS_BLOCK_STATEMENT */,
312
+ type: 21 /* NodeTypes.JS_BLOCK_STATEMENT */,
313
313
  body,
314
314
  loc: locStub
315
315
  };
316
316
  }
317
317
  function createTemplateLiteral(elements) {
318
318
  return {
319
- type: 22 /* JS_TEMPLATE_LITERAL */,
319
+ type: 22 /* NodeTypes.JS_TEMPLATE_LITERAL */,
320
320
  elements,
321
321
  loc: locStub
322
322
  };
323
323
  }
324
324
  function createIfStatement(test, consequent, alternate) {
325
325
  return {
326
- type: 23 /* JS_IF_STATEMENT */,
326
+ type: 23 /* NodeTypes.JS_IF_STATEMENT */,
327
327
  test,
328
328
  consequent,
329
329
  alternate,
@@ -332,7 +332,7 @@ function createIfStatement(test, consequent, alternate) {
332
332
  }
333
333
  function createAssignmentExpression(left, right) {
334
334
  return {
335
- type: 24 /* JS_ASSIGNMENT_EXPRESSION */,
335
+ type: 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */,
336
336
  left,
337
337
  right,
338
338
  loc: locStub
@@ -340,20 +340,20 @@ function createAssignmentExpression(left, right) {
340
340
  }
341
341
  function createSequenceExpression(expressions) {
342
342
  return {
343
- type: 25 /* JS_SEQUENCE_EXPRESSION */,
343
+ type: 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */,
344
344
  expressions,
345
345
  loc: locStub
346
346
  };
347
347
  }
348
348
  function createReturnStatement(returns) {
349
349
  return {
350
- type: 26 /* JS_RETURN_STATEMENT */,
350
+ type: 26 /* NodeTypes.JS_RETURN_STATEMENT */,
351
351
  returns,
352
352
  loc: locStub
353
353
  };
354
354
  }
355
355
 
356
- const isStaticExp = (p) => p.type === 4 /* SIMPLE_EXPRESSION */ && p.isStatic;
356
+ const isStaticExp = (p) => p.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && p.isStatic;
357
357
  const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
358
358
  function isCoreComponent(tag) {
359
359
  if (isBuiltInType(tag, 'Teleport')) {
@@ -383,7 +383,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
383
383
  const isMemberExpressionBrowser = (path) => {
384
384
  // remove whitespaces around . or [ first
385
385
  path = path.trim().replace(whitespaceRE, s => s.trim());
386
- let state = 0 /* inMemberExp */;
386
+ let state = 0 /* MemberExpLexState.inMemberExp */;
387
387
  let stateStack = [];
388
388
  let currentOpenBracketCount = 0;
389
389
  let currentOpenParensCount = 0;
@@ -391,25 +391,25 @@ const isMemberExpressionBrowser = (path) => {
391
391
  for (let i = 0; i < path.length; i++) {
392
392
  const char = path.charAt(i);
393
393
  switch (state) {
394
- case 0 /* inMemberExp */:
394
+ case 0 /* MemberExpLexState.inMemberExp */:
395
395
  if (char === '[') {
396
396
  stateStack.push(state);
397
- state = 1 /* inBrackets */;
397
+ state = 1 /* MemberExpLexState.inBrackets */;
398
398
  currentOpenBracketCount++;
399
399
  }
400
400
  else if (char === '(') {
401
401
  stateStack.push(state);
402
- state = 2 /* inParens */;
402
+ state = 2 /* MemberExpLexState.inParens */;
403
403
  currentOpenParensCount++;
404
404
  }
405
405
  else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
406
406
  return false;
407
407
  }
408
408
  break;
409
- case 1 /* inBrackets */:
409
+ case 1 /* MemberExpLexState.inBrackets */:
410
410
  if (char === `'` || char === `"` || char === '`') {
411
411
  stateStack.push(state);
412
- state = 3 /* inString */;
412
+ state = 3 /* MemberExpLexState.inString */;
413
413
  currentStringType = char;
414
414
  }
415
415
  else if (char === `[`) {
@@ -421,10 +421,10 @@ const isMemberExpressionBrowser = (path) => {
421
421
  }
422
422
  }
423
423
  break;
424
- case 2 /* inParens */:
424
+ case 2 /* MemberExpLexState.inParens */:
425
425
  if (char === `'` || char === `"` || char === '`') {
426
426
  stateStack.push(state);
427
- state = 3 /* inString */;
427
+ state = 3 /* MemberExpLexState.inString */;
428
428
  currentStringType = char;
429
429
  }
430
430
  else if (char === `(`) {
@@ -440,7 +440,7 @@ const isMemberExpressionBrowser = (path) => {
440
440
  }
441
441
  }
442
442
  break;
443
- case 3 /* inString */:
443
+ case 3 /* MemberExpLexState.inString */:
444
444
  if (char === currentStringType) {
445
445
  state = stateStack.pop();
446
446
  currentStringType = null;
@@ -510,7 +510,7 @@ function assert(condition, msg) {
510
510
  function findDir(node, name, allowEmpty = false) {
511
511
  for (let i = 0; i < node.props.length; i++) {
512
512
  const p = node.props[i];
513
- if (p.type === 7 /* DIRECTIVE */ &&
513
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
514
514
  (allowEmpty || p.exp) &&
515
515
  (shared.isString(name) ? p.name === name : name.test(p.name))) {
516
516
  return p;
@@ -520,7 +520,7 @@ function findDir(node, name, allowEmpty = false) {
520
520
  function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
521
521
  for (let i = 0; i < node.props.length; i++) {
522
522
  const p = node.props[i];
523
- if (p.type === 6 /* ATTRIBUTE */) {
523
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
524
524
  if (dynamicOnly)
525
525
  continue;
526
526
  if (p.name === name && (p.value || allowEmpty)) {
@@ -538,24 +538,24 @@ function isStaticArgOf(arg, name) {
538
538
  return !!(arg && isStaticExp(arg) && arg.content === name);
539
539
  }
540
540
  function hasDynamicKeyVBind(node) {
541
- return node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
541
+ return node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
542
542
  p.name === 'bind' &&
543
543
  (!p.arg || // v-bind="obj"
544
- p.arg.type !== 4 /* SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
544
+ p.arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
545
545
  !p.arg.isStatic) // v-bind:[foo]
546
546
  );
547
547
  }
548
548
  function isText(node) {
549
- return node.type === 5 /* INTERPOLATION */ || node.type === 2 /* TEXT */;
549
+ return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
550
550
  }
551
551
  function isVSlot(p) {
552
- return p.type === 7 /* DIRECTIVE */ && p.name === 'slot';
552
+ return p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'slot';
553
553
  }
554
554
  function isTemplateNode(node) {
555
- return (node.type === 1 /* ELEMENT */ && node.tagType === 3 /* TEMPLATE */);
555
+ return (node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 3 /* ElementTypes.TEMPLATE */);
556
556
  }
557
557
  function isSlotOutlet(node) {
558
- return node.type === 1 /* ELEMENT */ && node.tagType === 2 /* SLOT */;
558
+ return node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 2 /* ElementTypes.SLOT */;
559
559
  }
560
560
  function getVNodeHelper(ssr, isComponent) {
561
561
  return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
@@ -567,7 +567,7 @@ const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
567
567
  function getUnnormalizedProps(props, callPath = []) {
568
568
  if (props &&
569
569
  !shared.isString(props) &&
570
- props.type === 14 /* JS_CALL_EXPRESSION */) {
570
+ props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
571
571
  const callee = props.callee;
572
572
  if (!shared.isString(callee) && propsHelperSet.has(callee)) {
573
573
  return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
@@ -585,12 +585,12 @@ function injectProp(node, prop, context) {
585
585
  *
586
586
  * we need to get the real props before normalization
587
587
  */
588
- let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
588
+ let props = node.type === 13 /* NodeTypes.VNODE_CALL */ ? node.props : node.arguments[2];
589
589
  let callPath = [];
590
590
  let parentCall;
591
591
  if (props &&
592
592
  !shared.isString(props) &&
593
- props.type === 14 /* JS_CALL_EXPRESSION */) {
593
+ props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
594
594
  const ret = getUnnormalizedProps(props);
595
595
  props = ret[0];
596
596
  callPath = ret[1];
@@ -599,12 +599,12 @@ function injectProp(node, prop, context) {
599
599
  if (props == null || shared.isString(props)) {
600
600
  propsWithInjection = createObjectExpression([prop]);
601
601
  }
602
- else if (props.type === 14 /* JS_CALL_EXPRESSION */) {
602
+ else if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
603
603
  // merged props... add ours
604
604
  // only inject key to object literal if it's the first argument so that
605
605
  // if doesn't override user provided keys
606
606
  const first = props.arguments[0];
607
- if (!shared.isString(first) && first.type === 15 /* JS_OBJECT_EXPRESSION */) {
607
+ if (!shared.isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
608
608
  first.properties.unshift(prop);
609
609
  }
610
610
  else {
@@ -621,12 +621,12 @@ function injectProp(node, prop, context) {
621
621
  }
622
622
  !propsWithInjection && (propsWithInjection = props);
623
623
  }
624
- else if (props.type === 15 /* JS_OBJECT_EXPRESSION */) {
624
+ else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
625
625
  let alreadyExists = false;
626
626
  // check existing key to avoid overriding user provided keys
627
- if (prop.key.type === 4 /* SIMPLE_EXPRESSION */) {
627
+ if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
628
628
  const propKeyName = prop.key.content;
629
- alreadyExists = props.properties.some(p => p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
629
+ alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
630
630
  p.key.content === propKeyName);
631
631
  }
632
632
  if (!alreadyExists) {
@@ -647,7 +647,7 @@ function injectProp(node, prop, context) {
647
647
  parentCall = callPath[callPath.length - 2];
648
648
  }
649
649
  }
650
- if (node.type === 13 /* VNODE_CALL */) {
650
+ if (node.type === 13 /* NodeTypes.VNODE_CALL */) {
651
651
  if (parentCall) {
652
652
  parentCall.arguments[0] = propsWithInjection;
653
653
  }
@@ -676,45 +676,45 @@ function hasScopeRef(node, ids) {
676
676
  return false;
677
677
  }
678
678
  switch (node.type) {
679
- case 1 /* ELEMENT */:
679
+ case 1 /* NodeTypes.ELEMENT */:
680
680
  for (let i = 0; i < node.props.length; i++) {
681
681
  const p = node.props[i];
682
- if (p.type === 7 /* DIRECTIVE */ &&
682
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
683
683
  (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
684
684
  return true;
685
685
  }
686
686
  }
687
687
  return node.children.some(c => hasScopeRef(c, ids));
688
- case 11 /* FOR */:
688
+ case 11 /* NodeTypes.FOR */:
689
689
  if (hasScopeRef(node.source, ids)) {
690
690
  return true;
691
691
  }
692
692
  return node.children.some(c => hasScopeRef(c, ids));
693
- case 9 /* IF */:
693
+ case 9 /* NodeTypes.IF */:
694
694
  return node.branches.some(b => hasScopeRef(b, ids));
695
- case 10 /* IF_BRANCH */:
695
+ case 10 /* NodeTypes.IF_BRANCH */:
696
696
  if (hasScopeRef(node.condition, ids)) {
697
697
  return true;
698
698
  }
699
699
  return node.children.some(c => hasScopeRef(c, ids));
700
- case 4 /* SIMPLE_EXPRESSION */:
700
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
701
701
  return (!node.isStatic &&
702
702
  isSimpleIdentifier(node.content) &&
703
703
  !!ids[node.content]);
704
- case 8 /* COMPOUND_EXPRESSION */:
704
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
705
705
  return node.children.some(c => shared.isObject(c) && hasScopeRef(c, ids));
706
- case 5 /* INTERPOLATION */:
707
- case 12 /* TEXT_CALL */:
706
+ case 5 /* NodeTypes.INTERPOLATION */:
707
+ case 12 /* NodeTypes.TEXT_CALL */:
708
708
  return hasScopeRef(node.content, ids);
709
- case 2 /* TEXT */:
710
- case 3 /* COMMENT */:
709
+ case 2 /* NodeTypes.TEXT */:
710
+ case 3 /* NodeTypes.COMMENT */:
711
711
  return false;
712
712
  default:
713
713
  return false;
714
714
  }
715
715
  }
716
716
  function getMemoedVNodeCall(node) {
717
- if (node.type === 14 /* JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
717
+ if (node.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
718
718
  return node.arguments[1].returns;
719
719
  }
720
720
  else {
@@ -731,23 +731,23 @@ function makeBlock(node, { helper, removeHelper, inSSR }) {
731
731
  }
732
732
 
733
733
  const deprecationData = {
734
- ["COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */]: {
734
+ ["COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */]: {
735
735
  message: `Platform-native elements with "is" prop will no longer be ` +
736
736
  `treated as components in Vue 3 unless the "is" value is explicitly ` +
737
737
  `prefixed with "vue:".`,
738
738
  link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
739
739
  },
740
- ["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
740
+ ["COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */]: {
741
741
  message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
742
742
  `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
743
743
  `\`v-model:${key}\`.`,
744
744
  link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
745
745
  },
746
- ["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
746
+ ["COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */]: {
747
747
  message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
748
748
  `Vue 3 will automatically set a binding as DOM property when appropriate.`
749
749
  },
750
- ["COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */]: {
750
+ ["COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */]: {
751
751
  message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
752
752
  `object spread: it will now overwrite an existing non-mergeable attribute ` +
753
753
  `that appears before v-bind in the case of conflict. ` +
@@ -755,11 +755,11 @@ const deprecationData = {
755
755
  `You can also suppress this warning if the usage is intended.`,
756
756
  link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
757
757
  },
758
- ["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
758
+ ["COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */]: {
759
759
  message: `.native modifier for v-on has been removed as is no longer necessary.`,
760
760
  link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
761
761
  },
762
- ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
762
+ ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
763
763
  message: `v-if / v-for precedence when used on the same element has changed ` +
764
764
  `in Vue 3: v-if now takes higher precedence and will no longer have ` +
765
765
  `access to v-for scope variables. It is best to avoid the ambiguity ` +
@@ -767,15 +767,15 @@ const deprecationData = {
767
767
  `data source.`,
768
768
  link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
769
769
  },
770
- ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
770
+ ["COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */]: {
771
771
  message: `<template> with no special directives will render as a native template ` +
772
772
  `element instead of its inner content in Vue 3.`
773
773
  },
774
- ["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
774
+ ["COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */]: {
775
775
  message: `"inline-template" has been removed in Vue 3.`,
776
776
  link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
777
777
  },
778
- ["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
778
+ ["COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */]: {
779
779
  message: `filters have been removed in Vue 3. ` +
780
780
  `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
781
781
  `Use method calls or computed properties instead.`,
@@ -832,8 +832,8 @@ const decodeMap = {
832
832
  };
833
833
  const defaultParserOptions = {
834
834
  delimiters: [`{{`, `}}`],
835
- getNamespace: () => 0 /* HTML */,
836
- getTextMode: () => 0 /* DATA */,
835
+ getNamespace: () => 0 /* Namespaces.HTML */,
836
+ getTextMode: () => 0 /* TextModes.DATA */,
837
837
  isVoidTag: shared.NO,
838
838
  isPreTag: shared.NO,
839
839
  isCustomElement: shared.NO,
@@ -845,7 +845,7 @@ const defaultParserOptions = {
845
845
  function baseParse(content, options = {}) {
846
846
  const context = createParserContext(content, options);
847
847
  const start = getCursor(context);
848
- return createRoot(parseChildren(context, 0 /* DATA */, []), getSelection(context, start));
848
+ return createRoot(parseChildren(context, 0 /* TextModes.DATA */, []), getSelection(context, start));
849
849
  }
850
850
  function createParserContext(content, rawOptions) {
851
851
  const options = shared.extend({}, defaultParserOptions);
@@ -871,20 +871,20 @@ function createParserContext(content, rawOptions) {
871
871
  }
872
872
  function parseChildren(context, mode, ancestors) {
873
873
  const parent = last(ancestors);
874
- const ns = parent ? parent.ns : 0 /* HTML */;
874
+ const ns = parent ? parent.ns : 0 /* Namespaces.HTML */;
875
875
  const nodes = [];
876
876
  while (!isEnd(context, mode, ancestors)) {
877
877
  const s = context.source;
878
878
  let node = undefined;
879
- if (mode === 0 /* DATA */ || mode === 1 /* RCDATA */) {
879
+ if (mode === 0 /* TextModes.DATA */ || mode === 1 /* TextModes.RCDATA */) {
880
880
  if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
881
881
  // '{{'
882
882
  node = parseInterpolation(context, mode);
883
883
  }
884
- else if (mode === 0 /* DATA */ && s[0] === '<') {
884
+ else if (mode === 0 /* TextModes.DATA */ && s[0] === '<') {
885
885
  // https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
886
886
  if (s.length === 1) {
887
- emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 1);
887
+ emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 1);
888
888
  }
889
889
  else if (s[1] === '!') {
890
890
  // https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
@@ -896,56 +896,56 @@ function parseChildren(context, mode, ancestors) {
896
896
  node = parseBogusComment(context);
897
897
  }
898
898
  else if (startsWith(s, '<![CDATA[')) {
899
- if (ns !== 0 /* HTML */) {
899
+ if (ns !== 0 /* Namespaces.HTML */) {
900
900
  node = parseCDATA(context, ancestors);
901
901
  }
902
902
  else {
903
- emitError(context, 1 /* CDATA_IN_HTML_CONTENT */);
903
+ emitError(context, 1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */);
904
904
  node = parseBogusComment(context);
905
905
  }
906
906
  }
907
907
  else {
908
- emitError(context, 11 /* INCORRECTLY_OPENED_COMMENT */);
908
+ emitError(context, 11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */);
909
909
  node = parseBogusComment(context);
910
910
  }
911
911
  }
912
912
  else if (s[1] === '/') {
913
913
  // https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
914
914
  if (s.length === 2) {
915
- emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 2);
915
+ emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 2);
916
916
  }
917
917
  else if (s[2] === '>') {
918
- emitError(context, 14 /* MISSING_END_TAG_NAME */, 2);
918
+ emitError(context, 14 /* ErrorCodes.MISSING_END_TAG_NAME */, 2);
919
919
  advanceBy(context, 3);
920
920
  continue;
921
921
  }
922
922
  else if (/[a-z]/i.test(s[2])) {
923
- emitError(context, 23 /* X_INVALID_END_TAG */);
924
- parseTag(context, 1 /* End */, parent);
923
+ emitError(context, 23 /* ErrorCodes.X_INVALID_END_TAG */);
924
+ parseTag(context, 1 /* TagType.End */, parent);
925
925
  continue;
926
926
  }
927
927
  else {
928
- emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
928
+ emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
929
929
  node = parseBogusComment(context);
930
930
  }
931
931
  }
932
932
  else if (/[a-z]/i.test(s[1])) {
933
933
  node = parseElement(context, ancestors);
934
934
  // 2.x <template> with no directive compat
935
- if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context) &&
935
+ if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context) &&
936
936
  node &&
937
937
  node.tag === 'template' &&
938
- !node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
938
+ !node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
939
939
  isSpecialTemplateDirective(p.name))) {
940
940
  node = node.children;
941
941
  }
942
942
  }
943
943
  else if (s[1] === '?') {
944
- emitError(context, 21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
944
+ emitError(context, 21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
945
945
  node = parseBogusComment(context);
946
946
  }
947
947
  else {
948
- emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
948
+ emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
949
949
  }
950
950
  }
951
951
  }
@@ -963,11 +963,11 @@ function parseChildren(context, mode, ancestors) {
963
963
  }
964
964
  // Whitespace handling strategy like v2
965
965
  let removedWhitespace = false;
966
- if (mode !== 2 /* RAWTEXT */ && mode !== 1 /* RCDATA */) {
966
+ if (mode !== 2 /* TextModes.RAWTEXT */ && mode !== 1 /* TextModes.RCDATA */) {
967
967
  const shouldCondense = context.options.whitespace !== 'preserve';
968
968
  for (let i = 0; i < nodes.length; i++) {
969
969
  const node = nodes[i];
970
- if (!context.inPre && node.type === 2 /* TEXT */) {
970
+ if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
971
971
  if (!/[^\t\r\n\f ]/.test(node.content)) {
972
972
  const prev = nodes[i - 1];
973
973
  const next = nodes[i + 1];
@@ -978,10 +978,10 @@ function parseChildren(context, mode, ancestors) {
978
978
  if (!prev ||
979
979
  !next ||
980
980
  (shouldCondense &&
981
- (prev.type === 3 /* COMMENT */ ||
982
- next.type === 3 /* COMMENT */ ||
983
- (prev.type === 1 /* ELEMENT */ &&
984
- next.type === 1 /* ELEMENT */ &&
981
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
982
+ next.type === 3 /* NodeTypes.COMMENT */ ||
983
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
984
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
985
985
  /[\r\n]/.test(node.content))))) {
986
986
  removedWhitespace = true;
987
987
  nodes[i] = null;
@@ -998,7 +998,7 @@ function parseChildren(context, mode, ancestors) {
998
998
  }
999
999
  }
1000
1000
  // Remove comment nodes if desired by configuration.
1001
- else if (node.type === 3 /* COMMENT */ && !context.options.comments) {
1001
+ else if (node.type === 3 /* NodeTypes.COMMENT */ && !context.options.comments) {
1002
1002
  removedWhitespace = true;
1003
1003
  nodes[i] = null;
1004
1004
  }
@@ -1007,7 +1007,7 @@ function parseChildren(context, mode, ancestors) {
1007
1007
  // remove leading newline per html spec
1008
1008
  // https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
1009
1009
  const first = nodes[0];
1010
- if (first && first.type === 2 /* TEXT */) {
1010
+ if (first && first.type === 2 /* NodeTypes.TEXT */) {
1011
1011
  first.content = first.content.replace(/^\r?\n/, '');
1012
1012
  }
1013
1013
  }
@@ -1015,12 +1015,12 @@ function parseChildren(context, mode, ancestors) {
1015
1015
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
1016
1016
  }
1017
1017
  function pushNode(nodes, node) {
1018
- if (node.type === 2 /* TEXT */) {
1018
+ if (node.type === 2 /* NodeTypes.TEXT */) {
1019
1019
  const prev = last(nodes);
1020
1020
  // Merge if both this and the previous node are text and those are
1021
1021
  // consecutive. This happens for cases like "a < b".
1022
1022
  if (prev &&
1023
- prev.type === 2 /* TEXT */ &&
1023
+ prev.type === 2 /* NodeTypes.TEXT */ &&
1024
1024
  prev.loc.end.offset === node.loc.start.offset) {
1025
1025
  prev.content += node.content;
1026
1026
  prev.loc.end = node.loc.end;
@@ -1032,9 +1032,9 @@ function pushNode(nodes, node) {
1032
1032
  }
1033
1033
  function parseCDATA(context, ancestors) {
1034
1034
  advanceBy(context, 9);
1035
- const nodes = parseChildren(context, 3 /* CDATA */, ancestors);
1035
+ const nodes = parseChildren(context, 3 /* TextModes.CDATA */, ancestors);
1036
1036
  if (context.source.length === 0) {
1037
- emitError(context, 6 /* EOF_IN_CDATA */);
1037
+ emitError(context, 6 /* ErrorCodes.EOF_IN_CDATA */);
1038
1038
  }
1039
1039
  else {
1040
1040
  advanceBy(context, 3);
@@ -1049,14 +1049,14 @@ function parseComment(context) {
1049
1049
  if (!match) {
1050
1050
  content = context.source.slice(4);
1051
1051
  advanceBy(context, context.source.length);
1052
- emitError(context, 7 /* EOF_IN_COMMENT */);
1052
+ emitError(context, 7 /* ErrorCodes.EOF_IN_COMMENT */);
1053
1053
  }
1054
1054
  else {
1055
1055
  if (match.index <= 3) {
1056
- emitError(context, 0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
1056
+ emitError(context, 0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
1057
1057
  }
1058
1058
  if (match[1]) {
1059
- emitError(context, 10 /* INCORRECTLY_CLOSED_COMMENT */);
1059
+ emitError(context, 10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */);
1060
1060
  }
1061
1061
  content = context.source.slice(4, match.index);
1062
1062
  // Advancing with reporting nested comments.
@@ -1065,14 +1065,14 @@ function parseComment(context) {
1065
1065
  while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
1066
1066
  advanceBy(context, nestedIndex - prevIndex + 1);
1067
1067
  if (nestedIndex + 4 < s.length) {
1068
- emitError(context, 16 /* NESTED_COMMENT */);
1068
+ emitError(context, 16 /* ErrorCodes.NESTED_COMMENT */);
1069
1069
  }
1070
1070
  prevIndex = nestedIndex + 1;
1071
1071
  }
1072
1072
  advanceBy(context, match.index + match[0].length - prevIndex + 1);
1073
1073
  }
1074
1074
  return {
1075
- type: 3 /* COMMENT */,
1075
+ type: 3 /* NodeTypes.COMMENT */,
1076
1076
  content,
1077
1077
  loc: getSelection(context, start)
1078
1078
  };
@@ -1091,7 +1091,7 @@ function parseBogusComment(context) {
1091
1091
  advanceBy(context, closeIndex + 1);
1092
1092
  }
1093
1093
  return {
1094
- type: 3 /* COMMENT */,
1094
+ type: 3 /* NodeTypes.COMMENT */,
1095
1095
  content,
1096
1096
  loc: getSelection(context, start)
1097
1097
  };
@@ -1101,7 +1101,7 @@ function parseElement(context, ancestors) {
1101
1101
  const wasInPre = context.inPre;
1102
1102
  const wasInVPre = context.inVPre;
1103
1103
  const parent = last(ancestors);
1104
- const element = parseTag(context, 0 /* Start */, parent);
1104
+ const element = parseTag(context, 0 /* TagType.Start */, parent);
1105
1105
  const isPreBoundary = context.inPre && !wasInPre;
1106
1106
  const isVPreBoundary = context.inVPre && !wasInVPre;
1107
1107
  if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
@@ -1121,12 +1121,12 @@ function parseElement(context, ancestors) {
1121
1121
  ancestors.pop();
1122
1122
  // 2.x inline-template compat
1123
1123
  {
1124
- const inlineTemplateProp = element.props.find(p => p.type === 6 /* ATTRIBUTE */ && p.name === 'inline-template');
1124
+ const inlineTemplateProp = element.props.find(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'inline-template');
1125
1125
  if (inlineTemplateProp &&
1126
- checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
1126
+ checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
1127
1127
  const loc = getSelection(context, element.loc.end);
1128
1128
  inlineTemplateProp.value = {
1129
- type: 2 /* TEXT */,
1129
+ type: 2 /* NodeTypes.TEXT */,
1130
1130
  content: loc.source,
1131
1131
  loc
1132
1132
  };
@@ -1135,14 +1135,14 @@ function parseElement(context, ancestors) {
1135
1135
  element.children = children;
1136
1136
  // End tag.
1137
1137
  if (startsWithEndTagOpen(context.source, element.tag)) {
1138
- parseTag(context, 1 /* End */, parent);
1138
+ parseTag(context, 1 /* TagType.End */, parent);
1139
1139
  }
1140
1140
  else {
1141
- emitError(context, 24 /* X_MISSING_END_TAG */, 0, element.loc.start);
1141
+ emitError(context, 24 /* ErrorCodes.X_MISSING_END_TAG */, 0, element.loc.start);
1142
1142
  if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
1143
1143
  const first = children[0];
1144
1144
  if (first && startsWith(first.loc.source, '<!--')) {
1145
- emitError(context, 8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
1145
+ emitError(context, 8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
1146
1146
  }
1147
1147
  }
1148
1148
  }
@@ -1174,9 +1174,9 @@ function parseTag(context, type, parent) {
1174
1174
  // Attributes.
1175
1175
  let props = parseAttributes(context, type);
1176
1176
  // check v-pre
1177
- if (type === 0 /* Start */ &&
1177
+ if (type === 0 /* TagType.Start */ &&
1178
1178
  !context.inVPre &&
1179
- props.some(p => p.type === 7 /* DIRECTIVE */ && p.name === 'pre')) {
1179
+ props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'pre')) {
1180
1180
  context.inVPre = true;
1181
1181
  // reset context
1182
1182
  shared.extend(context, cursor);
@@ -1187,34 +1187,34 @@ function parseTag(context, type, parent) {
1187
1187
  // Tag close.
1188
1188
  let isSelfClosing = false;
1189
1189
  if (context.source.length === 0) {
1190
- emitError(context, 9 /* EOF_IN_TAG */);
1190
+ emitError(context, 9 /* ErrorCodes.EOF_IN_TAG */);
1191
1191
  }
1192
1192
  else {
1193
1193
  isSelfClosing = startsWith(context.source, '/>');
1194
- if (type === 1 /* End */ && isSelfClosing) {
1195
- emitError(context, 4 /* END_TAG_WITH_TRAILING_SOLIDUS */);
1194
+ if (type === 1 /* TagType.End */ && isSelfClosing) {
1195
+ emitError(context, 4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */);
1196
1196
  }
1197
1197
  advanceBy(context, isSelfClosing ? 2 : 1);
1198
1198
  }
1199
- if (type === 1 /* End */) {
1199
+ if (type === 1 /* TagType.End */) {
1200
1200
  return;
1201
1201
  }
1202
- let tagType = 0 /* ELEMENT */;
1202
+ let tagType = 0 /* ElementTypes.ELEMENT */;
1203
1203
  if (!context.inVPre) {
1204
1204
  if (tag === 'slot') {
1205
- tagType = 2 /* SLOT */;
1205
+ tagType = 2 /* ElementTypes.SLOT */;
1206
1206
  }
1207
1207
  else if (tag === 'template') {
1208
- if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
1209
- tagType = 3 /* TEMPLATE */;
1208
+ if (props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
1209
+ tagType = 3 /* ElementTypes.TEMPLATE */;
1210
1210
  }
1211
1211
  }
1212
1212
  else if (isComponent(tag, props, context)) {
1213
- tagType = 1 /* COMPONENT */;
1213
+ tagType = 1 /* ElementTypes.COMPONENT */;
1214
1214
  }
1215
1215
  }
1216
1216
  return {
1217
- type: 1 /* ELEMENT */,
1217
+ type: 1 /* NodeTypes.ELEMENT */,
1218
1218
  ns,
1219
1219
  tag,
1220
1220
  tagType,
@@ -1241,12 +1241,12 @@ function isComponent(tag, props, context) {
1241
1241
  // casting
1242
1242
  for (let i = 0; i < props.length; i++) {
1243
1243
  const p = props[i];
1244
- if (p.type === 6 /* ATTRIBUTE */) {
1244
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
1245
1245
  if (p.name === 'is' && p.value) {
1246
1246
  if (p.value.content.startsWith('vue:')) {
1247
1247
  return true;
1248
1248
  }
1249
- else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1249
+ else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1250
1250
  return true;
1251
1251
  }
1252
1252
  }
@@ -1262,7 +1262,7 @@ function isComponent(tag, props, context) {
1262
1262
  p.name === 'bind' &&
1263
1263
  isStaticArgOf(p.arg, 'is') &&
1264
1264
  true &&
1265
- checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1265
+ checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
1266
1266
  return true;
1267
1267
  }
1268
1268
  }
@@ -1275,27 +1275,27 @@ function parseAttributes(context, type) {
1275
1275
  !startsWith(context.source, '>') &&
1276
1276
  !startsWith(context.source, '/>')) {
1277
1277
  if (startsWith(context.source, '/')) {
1278
- emitError(context, 22 /* UNEXPECTED_SOLIDUS_IN_TAG */);
1278
+ emitError(context, 22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */);
1279
1279
  advanceBy(context, 1);
1280
1280
  advanceSpaces(context);
1281
1281
  continue;
1282
1282
  }
1283
- if (type === 1 /* End */) {
1284
- emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
1283
+ if (type === 1 /* TagType.End */) {
1284
+ emitError(context, 3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */);
1285
1285
  }
1286
1286
  const attr = parseAttribute(context, attributeNames);
1287
1287
  // Trim whitespace between class
1288
1288
  // https://github.com/vuejs/core/issues/4251
1289
- if (attr.type === 6 /* ATTRIBUTE */ &&
1289
+ if (attr.type === 6 /* NodeTypes.ATTRIBUTE */ &&
1290
1290
  attr.value &&
1291
1291
  attr.name === 'class') {
1292
1292
  attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
1293
1293
  }
1294
- if (type === 0 /* Start */) {
1294
+ if (type === 0 /* TagType.Start */) {
1295
1295
  props.push(attr);
1296
1296
  }
1297
1297
  if (/^[^\t\r\n\f />]/.test(context.source)) {
1298
- emitError(context, 15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
1298
+ emitError(context, 15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
1299
1299
  }
1300
1300
  advanceSpaces(context);
1301
1301
  }
@@ -1307,17 +1307,17 @@ function parseAttribute(context, nameSet) {
1307
1307
  const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
1308
1308
  const name = match[0];
1309
1309
  if (nameSet.has(name)) {
1310
- emitError(context, 2 /* DUPLICATE_ATTRIBUTE */);
1310
+ emitError(context, 2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */);
1311
1311
  }
1312
1312
  nameSet.add(name);
1313
1313
  if (name[0] === '=') {
1314
- emitError(context, 19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
1314
+ emitError(context, 19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
1315
1315
  }
1316
1316
  {
1317
1317
  const pattern = /["'<]/g;
1318
1318
  let m;
1319
1319
  while ((m = pattern.exec(name))) {
1320
- emitError(context, 17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
1320
+ emitError(context, 17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
1321
1321
  }
1322
1322
  }
1323
1323
  advanceBy(context, name.length);
@@ -1329,7 +1329,7 @@ function parseAttribute(context, nameSet) {
1329
1329
  advanceSpaces(context);
1330
1330
  value = parseAttributeValue(context);
1331
1331
  if (!value) {
1332
- emitError(context, 13 /* MISSING_ATTRIBUTE_VALUE */);
1332
+ emitError(context, 13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */);
1333
1333
  }
1334
1334
  }
1335
1335
  const loc = getSelection(context, start);
@@ -1352,7 +1352,7 @@ function parseAttribute(context, nameSet) {
1352
1352
  if (content.startsWith('[')) {
1353
1353
  isStatic = false;
1354
1354
  if (!content.endsWith(']')) {
1355
- emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1355
+ emitError(context, 27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1356
1356
  content = content.slice(1);
1357
1357
  }
1358
1358
  else {
@@ -1366,12 +1366,12 @@ function parseAttribute(context, nameSet) {
1366
1366
  content += match[3] || '';
1367
1367
  }
1368
1368
  arg = {
1369
- type: 4 /* SIMPLE_EXPRESSION */,
1369
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1370
1370
  content,
1371
1371
  isStatic,
1372
1372
  constType: isStatic
1373
- ? 3 /* CAN_STRINGIFY */
1374
- : 0 /* NOT_CONSTANT */,
1373
+ ? 3 /* ConstantTypes.CAN_STRINGIFY */
1374
+ : 0 /* ConstantTypes.NOT_CONSTANT */,
1375
1375
  loc
1376
1376
  };
1377
1377
  }
@@ -1388,21 +1388,21 @@ function parseAttribute(context, nameSet) {
1388
1388
  // 2.x compat v-bind:foo.sync -> v-model:foo
1389
1389
  if (dirName === 'bind' && arg) {
1390
1390
  if (modifiers.includes('sync') &&
1391
- checkCompatEnabled("COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
1391
+ checkCompatEnabled("COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
1392
1392
  dirName = 'model';
1393
1393
  modifiers.splice(modifiers.indexOf('sync'), 1);
1394
1394
  }
1395
1395
  }
1396
1396
  return {
1397
- type: 7 /* DIRECTIVE */,
1397
+ type: 7 /* NodeTypes.DIRECTIVE */,
1398
1398
  name: dirName,
1399
1399
  exp: value && {
1400
- type: 4 /* SIMPLE_EXPRESSION */,
1400
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1401
1401
  content: value.content,
1402
1402
  isStatic: false,
1403
1403
  // Treat as non-constant by default. This can be potentially set to
1404
1404
  // other values by `transformExpression` to make it eligible for hoisting.
1405
- constType: 0 /* NOT_CONSTANT */,
1405
+ constType: 0 /* ConstantTypes.NOT_CONSTANT */,
1406
1406
  loc: value.loc
1407
1407
  },
1408
1408
  arg,
@@ -1412,13 +1412,13 @@ function parseAttribute(context, nameSet) {
1412
1412
  }
1413
1413
  // missing directive name or illegal directive name
1414
1414
  if (!context.inVPre && startsWith(name, 'v-')) {
1415
- emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
1415
+ emitError(context, 26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */);
1416
1416
  }
1417
1417
  return {
1418
- type: 6 /* ATTRIBUTE */,
1418
+ type: 6 /* NodeTypes.ATTRIBUTE */,
1419
1419
  name,
1420
1420
  value: value && {
1421
- type: 2 /* TEXT */,
1421
+ type: 2 /* NodeTypes.TEXT */,
1422
1422
  content: value.content,
1423
1423
  loc: value.loc
1424
1424
  },
@@ -1435,10 +1435,10 @@ function parseAttributeValue(context) {
1435
1435
  advanceBy(context, 1);
1436
1436
  const endIndex = context.source.indexOf(quote);
1437
1437
  if (endIndex === -1) {
1438
- content = parseTextData(context, context.source.length, 4 /* ATTRIBUTE_VALUE */);
1438
+ content = parseTextData(context, context.source.length, 4 /* TextModes.ATTRIBUTE_VALUE */);
1439
1439
  }
1440
1440
  else {
1441
- content = parseTextData(context, endIndex, 4 /* ATTRIBUTE_VALUE */);
1441
+ content = parseTextData(context, endIndex, 4 /* TextModes.ATTRIBUTE_VALUE */);
1442
1442
  advanceBy(context, 1);
1443
1443
  }
1444
1444
  }
@@ -1451,9 +1451,9 @@ function parseAttributeValue(context) {
1451
1451
  const unexpectedChars = /["'<=`]/g;
1452
1452
  let m;
1453
1453
  while ((m = unexpectedChars.exec(match[0]))) {
1454
- emitError(context, 18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
1454
+ emitError(context, 18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
1455
1455
  }
1456
- content = parseTextData(context, match[0].length, 4 /* ATTRIBUTE_VALUE */);
1456
+ content = parseTextData(context, match[0].length, 4 /* TextModes.ATTRIBUTE_VALUE */);
1457
1457
  }
1458
1458
  return { content, isQuoted, loc: getSelection(context, start) };
1459
1459
  }
@@ -1461,7 +1461,7 @@ function parseInterpolation(context, mode) {
1461
1461
  const [open, close] = context.options.delimiters;
1462
1462
  const closeIndex = context.source.indexOf(close, open.length);
1463
1463
  if (closeIndex === -1) {
1464
- emitError(context, 25 /* X_MISSING_INTERPOLATION_END */);
1464
+ emitError(context, 25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */);
1465
1465
  return undefined;
1466
1466
  }
1467
1467
  const start = getCursor(context);
@@ -1480,12 +1480,12 @@ function parseInterpolation(context, mode) {
1480
1480
  advancePositionWithMutation(innerEnd, rawContent, endOffset);
1481
1481
  advanceBy(context, close.length);
1482
1482
  return {
1483
- type: 5 /* INTERPOLATION */,
1483
+ type: 5 /* NodeTypes.INTERPOLATION */,
1484
1484
  content: {
1485
- type: 4 /* SIMPLE_EXPRESSION */,
1485
+ type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
1486
1486
  isStatic: false,
1487
1487
  // Set `isConstant` to false by default and will decide in transformExpression
1488
- constType: 0 /* NOT_CONSTANT */,
1488
+ constType: 0 /* ConstantTypes.NOT_CONSTANT */,
1489
1489
  content,
1490
1490
  loc: getSelection(context, innerStart, innerEnd)
1491
1491
  },
@@ -1493,7 +1493,7 @@ function parseInterpolation(context, mode) {
1493
1493
  };
1494
1494
  }
1495
1495
  function parseText(context, mode) {
1496
- const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1496
+ const endTokens = mode === 3 /* TextModes.CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1497
1497
  let endIndex = context.source.length;
1498
1498
  for (let i = 0; i < endTokens.length; i++) {
1499
1499
  const index = context.source.indexOf(endTokens[i], 1);
@@ -1504,7 +1504,7 @@ function parseText(context, mode) {
1504
1504
  const start = getCursor(context);
1505
1505
  const content = parseTextData(context, endIndex, mode);
1506
1506
  return {
1507
- type: 2 /* TEXT */,
1507
+ type: 2 /* NodeTypes.TEXT */,
1508
1508
  content,
1509
1509
  loc: getSelection(context, start)
1510
1510
  };
@@ -1516,14 +1516,14 @@ function parseText(context, mode) {
1516
1516
  function parseTextData(context, length, mode) {
1517
1517
  const rawText = context.source.slice(0, length);
1518
1518
  advanceBy(context, length);
1519
- if (mode === 2 /* RAWTEXT */ ||
1520
- mode === 3 /* CDATA */ ||
1519
+ if (mode === 2 /* TextModes.RAWTEXT */ ||
1520
+ mode === 3 /* TextModes.CDATA */ ||
1521
1521
  !rawText.includes('&')) {
1522
1522
  return rawText;
1523
1523
  }
1524
1524
  else {
1525
1525
  // DATA or RCDATA containing "&"". Entity decoding required.
1526
- return context.options.decodeEntities(rawText, mode === 4 /* ATTRIBUTE_VALUE */);
1526
+ return context.options.decodeEntities(rawText, mode === 4 /* TextModes.ATTRIBUTE_VALUE */);
1527
1527
  }
1528
1528
  }
1529
1529
  function getCursor(context) {
@@ -1572,7 +1572,7 @@ function emitError(context, code, offset, loc = getCursor(context)) {
1572
1572
  function isEnd(context, mode, ancestors) {
1573
1573
  const s = context.source;
1574
1574
  switch (mode) {
1575
- case 0 /* DATA */:
1575
+ case 0 /* TextModes.DATA */:
1576
1576
  if (startsWith(s, '</')) {
1577
1577
  // TODO: probably bad performance
1578
1578
  for (let i = ancestors.length - 1; i >= 0; --i) {
@@ -1582,15 +1582,15 @@ function isEnd(context, mode, ancestors) {
1582
1582
  }
1583
1583
  }
1584
1584
  break;
1585
- case 1 /* RCDATA */:
1586
- case 2 /* RAWTEXT */: {
1585
+ case 1 /* TextModes.RCDATA */:
1586
+ case 2 /* TextModes.RAWTEXT */: {
1587
1587
  const parent = last(ancestors);
1588
1588
  if (parent && startsWithEndTagOpen(s, parent.tag)) {
1589
1589
  return true;
1590
1590
  }
1591
1591
  break;
1592
1592
  }
1593
- case 3 /* CDATA */:
1593
+ case 3 /* TextModes.CDATA */:
1594
1594
  if (startsWith(s, ']]>')) {
1595
1595
  return true;
1596
1596
  }
@@ -1613,7 +1613,7 @@ function hoistStatic(root, context) {
1613
1613
  function isSingleElementRoot(root, child) {
1614
1614
  const { children } = root;
1615
1615
  return (children.length === 1 &&
1616
- child.type === 1 /* ELEMENT */ &&
1616
+ child.type === 1 /* NodeTypes.ELEMENT */ &&
1617
1617
  !isSlotOutlet(child));
1618
1618
  }
1619
1619
  function walk(node, context, doNotHoistNode = false) {
@@ -1623,15 +1623,15 @@ function walk(node, context, doNotHoistNode = false) {
1623
1623
  for (let i = 0; i < children.length; i++) {
1624
1624
  const child = children[i];
1625
1625
  // only plain elements & text calls are eligible for hoisting.
1626
- if (child.type === 1 /* ELEMENT */ &&
1627
- child.tagType === 0 /* ELEMENT */) {
1626
+ if (child.type === 1 /* NodeTypes.ELEMENT */ &&
1627
+ child.tagType === 0 /* ElementTypes.ELEMENT */) {
1628
1628
  const constantType = doNotHoistNode
1629
- ? 0 /* NOT_CONSTANT */
1629
+ ? 0 /* ConstantTypes.NOT_CONSTANT */
1630
1630
  : getConstantType(child, context);
1631
- if (constantType > 0 /* NOT_CONSTANT */) {
1632
- if (constantType >= 2 /* CAN_HOIST */) {
1631
+ if (constantType > 0 /* ConstantTypes.NOT_CONSTANT */) {
1632
+ if (constantType >= 2 /* ConstantTypes.CAN_HOIST */) {
1633
1633
  child.codegenNode.patchFlag =
1634
- -1 /* HOISTED */ + (``);
1634
+ -1 /* PatchFlags.HOISTED */ + (``);
1635
1635
  child.codegenNode = context.hoist(child.codegenNode);
1636
1636
  hoistedCount++;
1637
1637
  continue;
@@ -1641,13 +1641,13 @@ function walk(node, context, doNotHoistNode = false) {
1641
1641
  // node may contain dynamic children, but its props may be eligible for
1642
1642
  // hoisting.
1643
1643
  const codegenNode = child.codegenNode;
1644
- if (codegenNode.type === 13 /* VNODE_CALL */) {
1644
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
1645
1645
  const flag = getPatchFlag(codegenNode);
1646
1646
  if ((!flag ||
1647
- flag === 512 /* NEED_PATCH */ ||
1648
- flag === 1 /* TEXT */) &&
1647
+ flag === 512 /* PatchFlags.NEED_PATCH */ ||
1648
+ flag === 1 /* PatchFlags.TEXT */) &&
1649
1649
  getGeneratedPropsConstantType(child, context) >=
1650
- 2 /* CAN_HOIST */) {
1650
+ 2 /* ConstantTypes.CAN_HOIST */) {
1651
1651
  const props = getNodeProps(child);
1652
1652
  if (props) {
1653
1653
  codegenNode.props = context.hoist(props);
@@ -1659,14 +1659,14 @@ function walk(node, context, doNotHoistNode = false) {
1659
1659
  }
1660
1660
  }
1661
1661
  }
1662
- else if (child.type === 12 /* TEXT_CALL */ &&
1663
- getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
1662
+ else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
1663
+ getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
1664
1664
  child.codegenNode = context.hoist(child.codegenNode);
1665
1665
  hoistedCount++;
1666
1666
  }
1667
1667
  // walk further
1668
- if (child.type === 1 /* ELEMENT */) {
1669
- const isComponent = child.tagType === 1 /* COMPONENT */;
1668
+ if (child.type === 1 /* NodeTypes.ELEMENT */) {
1669
+ const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
1670
1670
  if (isComponent) {
1671
1671
  context.scopes.vSlot++;
1672
1672
  }
@@ -1675,11 +1675,11 @@ function walk(node, context, doNotHoistNode = false) {
1675
1675
  context.scopes.vSlot--;
1676
1676
  }
1677
1677
  }
1678
- else if (child.type === 11 /* FOR */) {
1678
+ else if (child.type === 11 /* NodeTypes.FOR */) {
1679
1679
  // Do not hoist v-for single child because it has to be a block
1680
1680
  walk(child, context, child.children.length === 1);
1681
1681
  }
1682
- else if (child.type === 9 /* IF */) {
1682
+ else if (child.type === 9 /* NodeTypes.IF */) {
1683
1683
  for (let i = 0; i < child.branches.length; i++) {
1684
1684
  // Do not hoist v-if single child because it has to be a block
1685
1685
  walk(child.branches[i], context, child.branches[i].children.length === 1);
@@ -1692,10 +1692,10 @@ function walk(node, context, doNotHoistNode = false) {
1692
1692
  // all children were hoisted - the entire children array is hoistable.
1693
1693
  if (hoistedCount &&
1694
1694
  hoistedCount === originalCount &&
1695
- node.type === 1 /* ELEMENT */ &&
1696
- node.tagType === 0 /* ELEMENT */ &&
1695
+ node.type === 1 /* NodeTypes.ELEMENT */ &&
1696
+ node.tagType === 0 /* ElementTypes.ELEMENT */ &&
1697
1697
  node.codegenNode &&
1698
- node.codegenNode.type === 13 /* VNODE_CALL */ &&
1698
+ node.codegenNode.type === 13 /* NodeTypes.VNODE_CALL */ &&
1699
1699
  shared.isArray(node.codegenNode.children)) {
1700
1700
  node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
1701
1701
  }
@@ -1703,35 +1703,35 @@ function walk(node, context, doNotHoistNode = false) {
1703
1703
  function getConstantType(node, context) {
1704
1704
  const { constantCache } = context;
1705
1705
  switch (node.type) {
1706
- case 1 /* ELEMENT */:
1707
- if (node.tagType !== 0 /* ELEMENT */) {
1708
- return 0 /* NOT_CONSTANT */;
1706
+ case 1 /* NodeTypes.ELEMENT */:
1707
+ if (node.tagType !== 0 /* ElementTypes.ELEMENT */) {
1708
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1709
1709
  }
1710
1710
  const cached = constantCache.get(node);
1711
1711
  if (cached !== undefined) {
1712
1712
  return cached;
1713
1713
  }
1714
1714
  const codegenNode = node.codegenNode;
1715
- if (codegenNode.type !== 13 /* VNODE_CALL */) {
1716
- return 0 /* NOT_CONSTANT */;
1715
+ if (codegenNode.type !== 13 /* NodeTypes.VNODE_CALL */) {
1716
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1717
1717
  }
1718
1718
  if (codegenNode.isBlock &&
1719
1719
  node.tag !== 'svg' &&
1720
1720
  node.tag !== 'foreignObject') {
1721
- return 0 /* NOT_CONSTANT */;
1721
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1722
1722
  }
1723
1723
  const flag = getPatchFlag(codegenNode);
1724
1724
  if (!flag) {
1725
- let returnType = 3 /* CAN_STRINGIFY */;
1725
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1726
1726
  // Element itself has no patch flag. However we still need to check:
1727
1727
  // 1. Even for a node with no patch flag, it is possible for it to contain
1728
1728
  // non-hoistable expressions that refers to scope variables, e.g. compiler
1729
1729
  // injected keys or cached event handlers. Therefore we need to always
1730
1730
  // check the codegenNode's props to be sure.
1731
1731
  const generatedPropsType = getGeneratedPropsConstantType(node, context);
1732
- if (generatedPropsType === 0 /* NOT_CONSTANT */) {
1733
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1734
- return 0 /* NOT_CONSTANT */;
1732
+ if (generatedPropsType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1733
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1734
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1735
1735
  }
1736
1736
  if (generatedPropsType < returnType) {
1737
1737
  returnType = generatedPropsType;
@@ -1739,9 +1739,9 @@ function getConstantType(node, context) {
1739
1739
  // 2. its children.
1740
1740
  for (let i = 0; i < node.children.length; i++) {
1741
1741
  const childType = getConstantType(node.children[i], context);
1742
- if (childType === 0 /* NOT_CONSTANT */) {
1743
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1744
- return 0 /* NOT_CONSTANT */;
1742
+ if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1743
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1744
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1745
1745
  }
1746
1746
  if (childType < returnType) {
1747
1747
  returnType = childType;
@@ -1751,14 +1751,14 @@ function getConstantType(node, context) {
1751
1751
  // type, check if any of the props can cause the type to be lowered
1752
1752
  // we can skip can_patch because it's guaranteed by the absence of a
1753
1753
  // patchFlag.
1754
- if (returnType > 1 /* CAN_SKIP_PATCH */) {
1754
+ if (returnType > 1 /* ConstantTypes.CAN_SKIP_PATCH */) {
1755
1755
  for (let i = 0; i < node.props.length; i++) {
1756
1756
  const p = node.props[i];
1757
- if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind' && p.exp) {
1757
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind' && p.exp) {
1758
1758
  const expType = getConstantType(p.exp, context);
1759
- if (expType === 0 /* NOT_CONSTANT */) {
1760
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1761
- return 0 /* NOT_CONSTANT */;
1759
+ if (expType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1760
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1761
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1762
1762
  }
1763
1763
  if (expType < returnType) {
1764
1764
  returnType = expType;
@@ -1770,6 +1770,14 @@ function getConstantType(node, context) {
1770
1770
  // static then they don't need to be blocks since there will be no
1771
1771
  // nested updates.
1772
1772
  if (codegenNode.isBlock) {
1773
+ // except set custom directives.
1774
+ for (let i = 0; i < node.props.length; i++) {
1775
+ const p = node.props[i];
1776
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
1777
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1778
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1779
+ }
1780
+ }
1773
1781
  context.removeHelper(OPEN_BLOCK);
1774
1782
  context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
1775
1783
  codegenNode.isBlock = false;
@@ -1779,31 +1787,31 @@ function getConstantType(node, context) {
1779
1787
  return returnType;
1780
1788
  }
1781
1789
  else {
1782
- constantCache.set(node, 0 /* NOT_CONSTANT */);
1783
- return 0 /* NOT_CONSTANT */;
1784
- }
1785
- case 2 /* TEXT */:
1786
- case 3 /* COMMENT */:
1787
- return 3 /* CAN_STRINGIFY */;
1788
- case 9 /* IF */:
1789
- case 11 /* FOR */:
1790
- case 10 /* IF_BRANCH */:
1791
- return 0 /* NOT_CONSTANT */;
1792
- case 5 /* INTERPOLATION */:
1793
- case 12 /* TEXT_CALL */:
1790
+ constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
1791
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1792
+ }
1793
+ case 2 /* NodeTypes.TEXT */:
1794
+ case 3 /* NodeTypes.COMMENT */:
1795
+ return 3 /* ConstantTypes.CAN_STRINGIFY */;
1796
+ case 9 /* NodeTypes.IF */:
1797
+ case 11 /* NodeTypes.FOR */:
1798
+ case 10 /* NodeTypes.IF_BRANCH */:
1799
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1800
+ case 5 /* NodeTypes.INTERPOLATION */:
1801
+ case 12 /* NodeTypes.TEXT_CALL */:
1794
1802
  return getConstantType(node.content, context);
1795
- case 4 /* SIMPLE_EXPRESSION */:
1803
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
1796
1804
  return node.constType;
1797
- case 8 /* COMPOUND_EXPRESSION */:
1798
- let returnType = 3 /* CAN_STRINGIFY */;
1805
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
1806
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1799
1807
  for (let i = 0; i < node.children.length; i++) {
1800
1808
  const child = node.children[i];
1801
1809
  if (shared.isString(child) || shared.isSymbol(child)) {
1802
1810
  continue;
1803
1811
  }
1804
1812
  const childType = getConstantType(child, context);
1805
- if (childType === 0 /* NOT_CONSTANT */) {
1806
- return 0 /* NOT_CONSTANT */;
1813
+ if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1814
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1807
1815
  }
1808
1816
  else if (childType < returnType) {
1809
1817
  returnType = childType;
@@ -1811,7 +1819,7 @@ function getConstantType(node, context) {
1811
1819
  }
1812
1820
  return returnType;
1813
1821
  default:
1814
- return 0 /* NOT_CONSTANT */;
1822
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1815
1823
  }
1816
1824
  }
1817
1825
  const allowHoistedHelperSet = new Set([
@@ -1821,48 +1829,48 @@ const allowHoistedHelperSet = new Set([
1821
1829
  GUARD_REACTIVE_PROPS
1822
1830
  ]);
1823
1831
  function getConstantTypeOfHelperCall(value, context) {
1824
- if (value.type === 14 /* JS_CALL_EXPRESSION */ &&
1832
+ if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ &&
1825
1833
  !shared.isString(value.callee) &&
1826
1834
  allowHoistedHelperSet.has(value.callee)) {
1827
1835
  const arg = value.arguments[0];
1828
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
1836
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
1829
1837
  return getConstantType(arg, context);
1830
1838
  }
1831
- else if (arg.type === 14 /* JS_CALL_EXPRESSION */) {
1839
+ else if (arg.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
1832
1840
  // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
1833
1841
  return getConstantTypeOfHelperCall(arg, context);
1834
1842
  }
1835
1843
  }
1836
- return 0 /* NOT_CONSTANT */;
1844
+ return 0 /* ConstantTypes.NOT_CONSTANT */;
1837
1845
  }
1838
1846
  function getGeneratedPropsConstantType(node, context) {
1839
- let returnType = 3 /* CAN_STRINGIFY */;
1847
+ let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1840
1848
  const props = getNodeProps(node);
1841
- if (props && props.type === 15 /* JS_OBJECT_EXPRESSION */) {
1849
+ if (props && props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
1842
1850
  const { properties } = props;
1843
1851
  for (let i = 0; i < properties.length; i++) {
1844
1852
  const { key, value } = properties[i];
1845
1853
  const keyType = getConstantType(key, context);
1846
- if (keyType === 0 /* NOT_CONSTANT */) {
1854
+ if (keyType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1847
1855
  return keyType;
1848
1856
  }
1849
1857
  if (keyType < returnType) {
1850
1858
  returnType = keyType;
1851
1859
  }
1852
1860
  let valueType;
1853
- if (value.type === 4 /* SIMPLE_EXPRESSION */) {
1861
+ if (value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
1854
1862
  valueType = getConstantType(value, context);
1855
1863
  }
1856
- else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
1864
+ else if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
1857
1865
  // some helper calls can be hoisted,
1858
1866
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
1859
1867
  // in this case we need to respect the ConstantType of the helper's arguments
1860
1868
  valueType = getConstantTypeOfHelperCall(value, context);
1861
1869
  }
1862
1870
  else {
1863
- valueType = 0 /* NOT_CONSTANT */;
1871
+ valueType = 0 /* ConstantTypes.NOT_CONSTANT */;
1864
1872
  }
1865
- if (valueType === 0 /* NOT_CONSTANT */) {
1873
+ if (valueType === 0 /* ConstantTypes.NOT_CONSTANT */) {
1866
1874
  return valueType;
1867
1875
  }
1868
1876
  if (valueType < returnType) {
@@ -1874,7 +1882,7 @@ function getGeneratedPropsConstantType(node, context) {
1874
1882
  }
1875
1883
  function getNodeProps(node) {
1876
1884
  const codegenNode = node.codegenNode;
1877
- if (codegenNode.type === 13 /* VNODE_CALL */) {
1885
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
1878
1886
  return codegenNode.props;
1879
1887
  }
1880
1888
  }
@@ -1984,7 +1992,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
1984
1992
  else if (exp.identifiers) {
1985
1993
  exp.identifiers.forEach(addId);
1986
1994
  }
1987
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
1995
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
1988
1996
  addId(exp.content);
1989
1997
  }
1990
1998
  }
@@ -1997,7 +2005,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
1997
2005
  else if (exp.identifiers) {
1998
2006
  exp.identifiers.forEach(removeId);
1999
2007
  }
2000
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
2008
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2001
2009
  removeId(exp.content);
2002
2010
  }
2003
2011
  }
@@ -2006,7 +2014,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
2006
2014
  if (shared.isString(exp))
2007
2015
  exp = createSimpleExpression(exp);
2008
2016
  context.hoists.push(exp);
2009
- const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* CAN_HOIST */);
2017
+ const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* ConstantTypes.CAN_HOIST */);
2010
2018
  identifier.hoisted = exp;
2011
2019
  return identifier;
2012
2020
  },
@@ -2060,7 +2068,7 @@ function createRootCodegen(root, context) {
2060
2068
  // single element root is never hoisted so codegenNode will never be
2061
2069
  // SimpleExpressionNode
2062
2070
  const codegenNode = child.codegenNode;
2063
- if (codegenNode.type === 13 /* VNODE_CALL */) {
2071
+ if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
2064
2072
  makeBlock(codegenNode, context);
2065
2073
  }
2066
2074
  root.codegenNode = codegenNode;
@@ -2074,8 +2082,8 @@ function createRootCodegen(root, context) {
2074
2082
  }
2075
2083
  else if (children.length > 1) {
2076
2084
  // root has multiple nodes - return a fragment block.
2077
- let patchFlag = 64 /* STABLE_FRAGMENT */;
2078
- shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
2085
+ let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
2086
+ shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
2079
2087
  root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (``), undefined, undefined, true, undefined, false /* isComponent */);
2080
2088
  }
2081
2089
  else ;
@@ -2120,29 +2128,29 @@ function traverseNode(node, context) {
2120
2128
  }
2121
2129
  }
2122
2130
  switch (node.type) {
2123
- case 3 /* COMMENT */:
2131
+ case 3 /* NodeTypes.COMMENT */:
2124
2132
  if (!context.ssr) {
2125
2133
  // inject import for the Comment symbol, which is needed for creating
2126
2134
  // comment nodes with `createVNode`
2127
2135
  context.helper(CREATE_COMMENT);
2128
2136
  }
2129
2137
  break;
2130
- case 5 /* INTERPOLATION */:
2138
+ case 5 /* NodeTypes.INTERPOLATION */:
2131
2139
  // no need to traverse, but we need to inject toString helper
2132
2140
  if (!context.ssr) {
2133
2141
  context.helper(TO_DISPLAY_STRING);
2134
2142
  }
2135
2143
  break;
2136
2144
  // for container types, further traverse downwards
2137
- case 9 /* IF */:
2145
+ case 9 /* NodeTypes.IF */:
2138
2146
  for (let i = 0; i < node.branches.length; i++) {
2139
2147
  traverseNode(node.branches[i], context);
2140
2148
  }
2141
2149
  break;
2142
- case 10 /* IF_BRANCH */:
2143
- case 11 /* FOR */:
2144
- case 1 /* ELEMENT */:
2145
- case 0 /* ROOT */:
2150
+ case 10 /* NodeTypes.IF_BRANCH */:
2151
+ case 11 /* NodeTypes.FOR */:
2152
+ case 1 /* NodeTypes.ELEMENT */:
2153
+ case 0 /* NodeTypes.ROOT */:
2146
2154
  traverseChildren(node, context);
2147
2155
  break;
2148
2156
  }
@@ -2158,17 +2166,17 @@ function createStructuralDirectiveTransform(name, fn) {
2158
2166
  ? (n) => n === name
2159
2167
  : (n) => name.test(n);
2160
2168
  return (node, context) => {
2161
- if (node.type === 1 /* ELEMENT */) {
2169
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
2162
2170
  const { props } = node;
2163
2171
  // structural directive transforms are not concerned with slots
2164
2172
  // as they are handled separately in vSlot.ts
2165
- if (node.tagType === 3 /* TEMPLATE */ && props.some(isVSlot)) {
2173
+ if (node.tagType === 3 /* ElementTypes.TEMPLATE */ && props.some(isVSlot)) {
2166
2174
  return;
2167
2175
  }
2168
2176
  const exitFns = [];
2169
2177
  for (let i = 0; i < props.length; i++) {
2170
2178
  const prop = props[i];
2171
- if (prop.type === 7 /* DIRECTIVE */ && matches(prop.name)) {
2179
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */ && matches(prop.name)) {
2172
2180
  // structural directives are removed to avoid infinite recursion
2173
2181
  // also we remove them *before* applying so that it can further
2174
2182
  // traverse itself in case it moves the node around
@@ -2216,7 +2224,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
2216
2224
  if (context.map) {
2217
2225
  if (node) {
2218
2226
  let name;
2219
- if (node.type === 4 /* SIMPLE_EXPRESSION */ && !node.isStatic) {
2227
+ if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !node.isStatic) {
2220
2228
  const content = node.content.replace(/^_ctx\./, '');
2221
2229
  if (content !== node.content && isSimpleIdentifier(content)) {
2222
2230
  name = content;
@@ -2492,7 +2500,7 @@ function genHoists(hoists, context) {
2492
2500
  for (let i = 0; i < hoists.length; i++) {
2493
2501
  const exp = hoists[i];
2494
2502
  if (exp) {
2495
- const needScopeIdWrapper = genScopeId && exp.type === 13 /* VNODE_CALL */;
2503
+ const needScopeIdWrapper = genScopeId && exp.type === 13 /* NodeTypes.VNODE_CALL */;
2496
2504
  push(`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`);
2497
2505
  genNode(exp, context);
2498
2506
  if (needScopeIdWrapper) {
@@ -2516,10 +2524,10 @@ function genImports(importsOptions, context) {
2516
2524
  }
2517
2525
  function isText$1(n) {
2518
2526
  return (shared.isString(n) ||
2519
- n.type === 4 /* SIMPLE_EXPRESSION */ ||
2520
- n.type === 2 /* TEXT */ ||
2521
- n.type === 5 /* INTERPOLATION */ ||
2522
- n.type === 8 /* COMPOUND_EXPRESSION */);
2527
+ n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2528
+ n.type === 2 /* NodeTypes.TEXT */ ||
2529
+ n.type === 5 /* NodeTypes.INTERPOLATION */ ||
2530
+ n.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */);
2523
2531
  }
2524
2532
  function genNodeListAsArray(nodes, context) {
2525
2533
  const multilines = nodes.length > 3 ||
@@ -2564,67 +2572,67 @@ function genNode(node, context) {
2564
2572
  return;
2565
2573
  }
2566
2574
  switch (node.type) {
2567
- case 1 /* ELEMENT */:
2568
- case 9 /* IF */:
2569
- case 11 /* FOR */:
2575
+ case 1 /* NodeTypes.ELEMENT */:
2576
+ case 9 /* NodeTypes.IF */:
2577
+ case 11 /* NodeTypes.FOR */:
2570
2578
  genNode(node.codegenNode, context);
2571
2579
  break;
2572
- case 2 /* TEXT */:
2580
+ case 2 /* NodeTypes.TEXT */:
2573
2581
  genText(node, context);
2574
2582
  break;
2575
- case 4 /* SIMPLE_EXPRESSION */:
2583
+ case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
2576
2584
  genExpression(node, context);
2577
2585
  break;
2578
- case 5 /* INTERPOLATION */:
2586
+ case 5 /* NodeTypes.INTERPOLATION */:
2579
2587
  genInterpolation(node, context);
2580
2588
  break;
2581
- case 12 /* TEXT_CALL */:
2589
+ case 12 /* NodeTypes.TEXT_CALL */:
2582
2590
  genNode(node.codegenNode, context);
2583
2591
  break;
2584
- case 8 /* COMPOUND_EXPRESSION */:
2592
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
2585
2593
  genCompoundExpression(node, context);
2586
2594
  break;
2587
- case 3 /* COMMENT */:
2595
+ case 3 /* NodeTypes.COMMENT */:
2588
2596
  genComment(node, context);
2589
2597
  break;
2590
- case 13 /* VNODE_CALL */:
2598
+ case 13 /* NodeTypes.VNODE_CALL */:
2591
2599
  genVNodeCall(node, context);
2592
2600
  break;
2593
- case 14 /* JS_CALL_EXPRESSION */:
2601
+ case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
2594
2602
  genCallExpression(node, context);
2595
2603
  break;
2596
- case 15 /* JS_OBJECT_EXPRESSION */:
2604
+ case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
2597
2605
  genObjectExpression(node, context);
2598
2606
  break;
2599
- case 17 /* JS_ARRAY_EXPRESSION */:
2607
+ case 17 /* NodeTypes.JS_ARRAY_EXPRESSION */:
2600
2608
  genArrayExpression(node, context);
2601
2609
  break;
2602
- case 18 /* JS_FUNCTION_EXPRESSION */:
2610
+ case 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */:
2603
2611
  genFunctionExpression(node, context);
2604
2612
  break;
2605
- case 19 /* JS_CONDITIONAL_EXPRESSION */:
2613
+ case 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */:
2606
2614
  genConditionalExpression(node, context);
2607
2615
  break;
2608
- case 20 /* JS_CACHE_EXPRESSION */:
2616
+ case 20 /* NodeTypes.JS_CACHE_EXPRESSION */:
2609
2617
  genCacheExpression(node, context);
2610
2618
  break;
2611
- case 21 /* JS_BLOCK_STATEMENT */:
2619
+ case 21 /* NodeTypes.JS_BLOCK_STATEMENT */:
2612
2620
  genNodeList(node.body, context, true, false);
2613
2621
  break;
2614
2622
  // SSR only types
2615
- case 22 /* JS_TEMPLATE_LITERAL */:
2623
+ case 22 /* NodeTypes.JS_TEMPLATE_LITERAL */:
2616
2624
  genTemplateLiteral(node, context);
2617
2625
  break;
2618
- case 23 /* JS_IF_STATEMENT */:
2626
+ case 23 /* NodeTypes.JS_IF_STATEMENT */:
2619
2627
  genIfStatement(node, context);
2620
2628
  break;
2621
- case 24 /* JS_ASSIGNMENT_EXPRESSION */:
2629
+ case 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */:
2622
2630
  genAssignmentExpression(node, context);
2623
2631
  break;
2624
- case 25 /* JS_SEQUENCE_EXPRESSION */:
2632
+ case 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */:
2625
2633
  genSequenceExpression(node, context);
2626
2634
  break;
2627
- case 26 /* JS_RETURN_STATEMENT */:
2635
+ case 26 /* NodeTypes.JS_RETURN_STATEMENT */:
2628
2636
  genReturnStatement(node, context);
2629
2637
  break;
2630
2638
  }
@@ -2657,7 +2665,7 @@ function genCompoundExpression(node, context) {
2657
2665
  }
2658
2666
  function genExpressionAsPropertyKey(node, context) {
2659
2667
  const { push } = context;
2660
- if (node.type === 8 /* COMPOUND_EXPRESSION */) {
2668
+ if (node.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
2661
2669
  push(`[`);
2662
2670
  genCompoundExpression(node, context);
2663
2671
  push(`]`);
@@ -2734,7 +2742,7 @@ function genObjectExpression(node, context) {
2734
2742
  return;
2735
2743
  }
2736
2744
  const multilines = properties.length > 1 ||
2737
- (properties.some(p => p.value.type !== 4 /* SIMPLE_EXPRESSION */));
2745
+ (properties.some(p => p.value.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */));
2738
2746
  push(multilines ? `{` : `{ `);
2739
2747
  multilines && indent();
2740
2748
  for (let i = 0; i < properties.length; i++) {
@@ -2803,7 +2811,7 @@ function genFunctionExpression(node, context) {
2803
2811
  function genConditionalExpression(node, context) {
2804
2812
  const { test, consequent, alternate, newline: needNewline } = node;
2805
2813
  const { push, indent, deindent, newline } = context;
2806
- if (test.type === 4 /* SIMPLE_EXPRESSION */) {
2814
+ if (test.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2807
2815
  const needsParens = !isSimpleIdentifier(test.content);
2808
2816
  needsParens && push(`(`);
2809
2817
  genExpression(test, context);
@@ -2823,7 +2831,7 @@ function genConditionalExpression(node, context) {
2823
2831
  needNewline && newline();
2824
2832
  needNewline || push(` `);
2825
2833
  push(`: `);
2826
- const isNested = alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */;
2834
+ const isNested = alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */;
2827
2835
  if (!isNested) {
2828
2836
  context.indentLevel++;
2829
2837
  }
@@ -2887,7 +2895,7 @@ function genIfStatement(node, context) {
2887
2895
  push(`}`);
2888
2896
  if (alternate) {
2889
2897
  push(` else `);
2890
- if (alternate.type === 23 /* JS_IF_STATEMENT */) {
2898
+ if (alternate.type === 23 /* NodeTypes.JS_IF_STATEMENT */) {
2891
2899
  genIfStatement(alternate, context);
2892
2900
  }
2893
2901
  else {
@@ -3244,27 +3252,27 @@ function isReferenced(node, parent, grandparent) {
3244
3252
 
3245
3253
  const isLiteralWhitelisted = /*#__PURE__*/ shared.makeMap('true,false,null,this');
3246
3254
  const transformExpression = (node, context) => {
3247
- if (node.type === 5 /* INTERPOLATION */) {
3255
+ if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
3248
3256
  node.content = processExpression(node.content, context);
3249
3257
  }
3250
- else if (node.type === 1 /* ELEMENT */) {
3258
+ else if (node.type === 1 /* NodeTypes.ELEMENT */) {
3251
3259
  // handle directives on element
3252
3260
  for (let i = 0; i < node.props.length; i++) {
3253
3261
  const dir = node.props[i];
3254
3262
  // do not process for v-on & v-for since they are special handled
3255
- if (dir.type === 7 /* DIRECTIVE */ && dir.name !== 'for') {
3263
+ if (dir.type === 7 /* NodeTypes.DIRECTIVE */ && dir.name !== 'for') {
3256
3264
  const exp = dir.exp;
3257
3265
  const arg = dir.arg;
3258
3266
  // do not process exp if this is v-on:arg - we need special handling
3259
3267
  // for wrapping inline statements.
3260
3268
  if (exp &&
3261
- exp.type === 4 /* SIMPLE_EXPRESSION */ &&
3269
+ exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
3262
3270
  !(dir.name === 'on' && arg)) {
3263
3271
  dir.exp = processExpression(exp, context,
3264
3272
  // slot args must be processed as function params
3265
3273
  dir.name === 'slot');
3266
3274
  }
3267
- if (arg && arg.type === 4 /* SIMPLE_EXPRESSION */ && !arg.isStatic) {
3275
+ if (arg && arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !arg.isStatic) {
3268
3276
  dir.arg = processExpression(arg, context);
3269
3277
  }
3270
3278
  }
@@ -3293,15 +3301,15 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3293
3301
  const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
3294
3302
  // ({ x } = y)
3295
3303
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
3296
- if (type === "setup-const" /* SETUP_CONST */ ||
3297
- type === "setup-reactive-const" /* SETUP_REACTIVE_CONST */ ||
3304
+ if (type === "setup-const" /* BindingTypes.SETUP_CONST */ ||
3305
+ type === "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */ ||
3298
3306
  localVars[raw]) {
3299
3307
  return raw;
3300
3308
  }
3301
- else if (type === "setup-ref" /* SETUP_REF */) {
3309
+ else if (type === "setup-ref" /* BindingTypes.SETUP_REF */) {
3302
3310
  return `${raw}.value`;
3303
3311
  }
3304
- else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
3312
+ else if (type === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */) {
3305
3313
  // const binding that may or may not be ref
3306
3314
  // if it's not a ref, then assignments don't make sense -
3307
3315
  // so we ignore the non-ref assignment case and generate code
@@ -3310,7 +3318,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3310
3318
  ? `${raw}.value`
3311
3319
  : `${context.helperString(UNREF)}(${raw})`;
3312
3320
  }
3313
- else if (type === "setup-let" /* SETUP_LET */) {
3321
+ else if (type === "setup-let" /* BindingTypes.SETUP_LET */) {
3314
3322
  if (isAssignmentLVal) {
3315
3323
  // let binding.
3316
3324
  // this is a bit more tricky as we need to cover the case where
@@ -3346,12 +3354,12 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3346
3354
  return `${context.helperString(UNREF)}(${raw})`;
3347
3355
  }
3348
3356
  }
3349
- else if (type === "props" /* PROPS */) {
3357
+ else if (type === "props" /* BindingTypes.PROPS */) {
3350
3358
  // use __props which is generated by compileScript so in ts mode
3351
3359
  // it gets correct type
3352
3360
  return shared.genPropsAccessExp(raw);
3353
3361
  }
3354
- else if (type === "props-aliased" /* PROPS_ALIASED */) {
3362
+ else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
3355
3363
  // prop with a different local alias (from defineProps() destructure)
3356
3364
  return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
3357
3365
  }
@@ -3361,7 +3369,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3361
3369
  // setup bindings in non-inline mode
3362
3370
  return `$setup.${raw}`;
3363
3371
  }
3364
- else if (type === "props-aliased" /* PROPS_ALIASED */) {
3372
+ else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
3365
3373
  return `$props['${bindingMetadata.__propsAliases[raw]}']`;
3366
3374
  }
3367
3375
  else if (type) {
@@ -3382,17 +3390,17 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3382
3390
  if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
3383
3391
  // const bindings exposed from setup can be skipped for patching but
3384
3392
  // cannot be hoisted to module scope
3385
- if (bindingMetadata[node.content] === "setup-const" /* SETUP_CONST */) {
3386
- node.constType = 1 /* CAN_SKIP_PATCH */;
3393
+ if (bindingMetadata[node.content] === "setup-const" /* BindingTypes.SETUP_CONST */) {
3394
+ node.constType = 1 /* ConstantTypes.CAN_SKIP_PATCH */;
3387
3395
  }
3388
3396
  node.content = rewriteIdentifier(rawExp);
3389
3397
  }
3390
3398
  else if (!isScopeVarReference) {
3391
3399
  if (isLiteral) {
3392
- node.constType = 3 /* CAN_STRINGIFY */;
3400
+ node.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
3393
3401
  }
3394
3402
  else {
3395
- node.constType = 2 /* CAN_HOIST */;
3403
+ node.constType = 2 /* ConstantTypes.CAN_HOIST */;
3396
3404
  }
3397
3405
  }
3398
3406
  return node;
@@ -3412,7 +3420,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3412
3420
  }).program;
3413
3421
  }
3414
3422
  catch (e) {
3415
- context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3423
+ context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3416
3424
  return node;
3417
3425
  }
3418
3426
  const ids = [];
@@ -3466,7 +3474,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3466
3474
  source,
3467
3475
  start: advancePositionWithClone(node.loc.start, source, start),
3468
3476
  end: advancePositionWithClone(node.loc.start, source, end)
3469
- }, id.isConstant ? 3 /* CAN_STRINGIFY */ : 0 /* NOT_CONSTANT */));
3477
+ }, id.isConstant ? 3 /* ConstantTypes.CAN_STRINGIFY */ : 0 /* ConstantTypes.NOT_CONSTANT */));
3470
3478
  if (i === ids.length - 1 && end < rawExp.length) {
3471
3479
  children.push(rawExp.slice(end));
3472
3480
  }
@@ -3478,8 +3486,8 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3478
3486
  else {
3479
3487
  ret = node;
3480
3488
  ret.constType = bailConstant
3481
- ? 0 /* NOT_CONSTANT */
3482
- : 3 /* CAN_STRINGIFY */;
3489
+ ? 0 /* ConstantTypes.NOT_CONSTANT */
3490
+ : 3 /* ConstantTypes.CAN_STRINGIFY */;
3483
3491
  }
3484
3492
  ret.identifiers = Object.keys(knownIds);
3485
3493
  return ret;
@@ -3499,7 +3507,7 @@ function stringifyExpression(exp) {
3499
3507
  if (shared.isString(exp)) {
3500
3508
  return exp;
3501
3509
  }
3502
- else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
3510
+ else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
3503
3511
  return exp.content;
3504
3512
  }
3505
3513
  else {
@@ -3519,7 +3527,7 @@ const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (n
3519
3527
  let key = 0;
3520
3528
  while (i-- >= 0) {
3521
3529
  const sibling = siblings[i];
3522
- if (sibling && sibling.type === 9 /* IF */) {
3530
+ if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
3523
3531
  key += sibling.branches.length;
3524
3532
  }
3525
3533
  }
@@ -3542,7 +3550,7 @@ function processIf(node, dir, context, processCodegen) {
3542
3550
  if (dir.name !== 'else' &&
3543
3551
  (!dir.exp || !dir.exp.content.trim())) {
3544
3552
  const loc = dir.exp ? dir.exp.loc : node.loc;
3545
- context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
3553
+ context.onError(createCompilerError(28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */, dir.loc));
3546
3554
  dir.exp = createSimpleExpression(`true`, false, loc);
3547
3555
  }
3548
3556
  if (context.prefixIdentifiers && dir.exp) {
@@ -3553,7 +3561,7 @@ function processIf(node, dir, context, processCodegen) {
3553
3561
  if (dir.name === 'if') {
3554
3562
  const branch = createIfBranch(node, dir);
3555
3563
  const ifNode = {
3556
- type: 9 /* IF */,
3564
+ type: 9 /* NodeTypes.IF */,
3557
3565
  loc: node.loc,
3558
3566
  branches: [branch]
3559
3567
  };
@@ -3569,16 +3577,16 @@ function processIf(node, dir, context, processCodegen) {
3569
3577
  while (i-- >= -1) {
3570
3578
  const sibling = siblings[i];
3571
3579
  if (sibling &&
3572
- sibling.type === 2 /* TEXT */ &&
3580
+ sibling.type === 2 /* NodeTypes.TEXT */ &&
3573
3581
  !sibling.content.trim().length) {
3574
3582
  context.removeNode(sibling);
3575
3583
  continue;
3576
3584
  }
3577
- if (sibling && sibling.type === 9 /* IF */) {
3585
+ if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
3578
3586
  // Check if v-else was followed by v-else-if
3579
3587
  if (dir.name === 'else-if' &&
3580
3588
  sibling.branches[sibling.branches.length - 1].condition === undefined) {
3581
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3589
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3582
3590
  }
3583
3591
  // move the node to the if node's branches
3584
3592
  context.removeNode();
@@ -3589,7 +3597,7 @@ function processIf(node, dir, context, processCodegen) {
3589
3597
  if (key) {
3590
3598
  sibling.branches.forEach(({ userKey }) => {
3591
3599
  if (isSameKey(userKey, key)) {
3592
- context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
3600
+ context.onError(createCompilerError(29 /* ErrorCodes.X_V_IF_SAME_KEY */, branch.userKey.loc));
3593
3601
  }
3594
3602
  });
3595
3603
  }
@@ -3607,16 +3615,16 @@ function processIf(node, dir, context, processCodegen) {
3607
3615
  context.currentNode = null;
3608
3616
  }
3609
3617
  else {
3610
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3618
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3611
3619
  }
3612
3620
  break;
3613
3621
  }
3614
3622
  }
3615
3623
  }
3616
3624
  function createIfBranch(node, dir) {
3617
- const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
3625
+ const isTemplateIf = node.tagType === 3 /* ElementTypes.TEMPLATE */;
3618
3626
  return {
3619
- type: 10 /* IF_BRANCH */,
3627
+ type: 10 /* NodeTypes.IF_BRANCH */,
3620
3628
  loc: node.loc,
3621
3629
  condition: dir.name === 'else' ? undefined : dir.exp,
3622
3630
  children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
@@ -3640,20 +3648,20 @@ function createCodegenNodeForBranch(branch, keyIndex, context) {
3640
3648
  }
3641
3649
  function createChildrenCodegenNode(branch, keyIndex, context) {
3642
3650
  const { helper } = context;
3643
- const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* CAN_HOIST */));
3651
+ const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* ConstantTypes.CAN_HOIST */));
3644
3652
  const { children } = branch;
3645
3653
  const firstChild = children[0];
3646
- const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* ELEMENT */;
3654
+ const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* NodeTypes.ELEMENT */;
3647
3655
  if (needFragmentWrapper) {
3648
- if (children.length === 1 && firstChild.type === 11 /* FOR */) {
3656
+ if (children.length === 1 && firstChild.type === 11 /* NodeTypes.FOR */) {
3649
3657
  // optimize away nested fragments when child is a ForNode
3650
3658
  const vnodeCall = firstChild.codegenNode;
3651
3659
  injectProp(vnodeCall, keyProperty, context);
3652
3660
  return vnodeCall;
3653
3661
  }
3654
3662
  else {
3655
- let patchFlag = 64 /* STABLE_FRAGMENT */;
3656
- shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
3663
+ let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
3664
+ shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
3657
3665
  return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (``), undefined, undefined, true, false, false /* isComponent */, branch.loc);
3658
3666
  }
3659
3667
  }
@@ -3661,7 +3669,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
3661
3669
  const ret = firstChild.codegenNode;
3662
3670
  const vnodeCall = getMemoedVNodeCall(ret);
3663
3671
  // Change createVNode to createBlock.
3664
- if (vnodeCall.type === 13 /* VNODE_CALL */) {
3672
+ if (vnodeCall.type === 13 /* NodeTypes.VNODE_CALL */) {
3665
3673
  makeBlock(vnodeCall, context);
3666
3674
  }
3667
3675
  // inject branch key
@@ -3673,7 +3681,7 @@ function isSameKey(a, b) {
3673
3681
  if (!a || a.type !== b.type) {
3674
3682
  return false;
3675
3683
  }
3676
- if (a.type === 6 /* ATTRIBUTE */) {
3684
+ if (a.type === 6 /* NodeTypes.ATTRIBUTE */) {
3677
3685
  if (a.value.content !== b.value.content) {
3678
3686
  return false;
3679
3687
  }
@@ -3685,7 +3693,7 @@ function isSameKey(a, b) {
3685
3693
  if (exp.type !== branchExp.type) {
3686
3694
  return false;
3687
3695
  }
3688
- if (exp.type !== 4 /* SIMPLE_EXPRESSION */ ||
3696
+ if (exp.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
3689
3697
  exp.isStatic !== branchExp.isStatic ||
3690
3698
  exp.content !== branchExp.content) {
3691
3699
  return false;
@@ -3695,15 +3703,15 @@ function isSameKey(a, b) {
3695
3703
  }
3696
3704
  function getParentCondition(node) {
3697
3705
  while (true) {
3698
- if (node.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
3699
- if (node.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
3706
+ if (node.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
3707
+ if (node.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
3700
3708
  node = node.alternate;
3701
3709
  }
3702
3710
  else {
3703
3711
  return node;
3704
3712
  }
3705
3713
  }
3706
- else if (node.type === 20 /* JS_CACHE_EXPRESSION */) {
3714
+ else if (node.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */) {
3707
3715
  node = node.value;
3708
3716
  }
3709
3717
  }
@@ -3721,7 +3729,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3721
3729
  const memo = findDir(node, 'memo');
3722
3730
  const keyProp = findProp(node, `key`);
3723
3731
  const keyExp = keyProp &&
3724
- (keyProp.type === 6 /* ATTRIBUTE */
3732
+ (keyProp.type === 6 /* NodeTypes.ATTRIBUTE */
3725
3733
  ? createSimpleExpression(keyProp.value.content, true)
3726
3734
  : keyProp.exp);
3727
3735
  const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
@@ -3733,17 +3741,17 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3733
3741
  if (memo) {
3734
3742
  memo.exp = processExpression(memo.exp, context);
3735
3743
  }
3736
- if (keyProperty && keyProp.type !== 6 /* ATTRIBUTE */) {
3744
+ if (keyProperty && keyProp.type !== 6 /* NodeTypes.ATTRIBUTE */) {
3737
3745
  keyProperty.value = processExpression(keyProperty.value, context);
3738
3746
  }
3739
3747
  }
3740
- const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
3741
- forNode.source.constType > 0 /* NOT_CONSTANT */;
3748
+ const isStableFragment = forNode.source.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
3749
+ forNode.source.constType > 0 /* ConstantTypes.NOT_CONSTANT */;
3742
3750
  const fragmentFlag = isStableFragment
3743
- ? 64 /* STABLE_FRAGMENT */
3751
+ ? 64 /* PatchFlags.STABLE_FRAGMENT */
3744
3752
  : keyProp
3745
- ? 128 /* KEYED_FRAGMENT */
3746
- : 256 /* UNKEYED_FRAGMENT */;
3753
+ ? 128 /* PatchFlags.KEYED_FRAGMENT */
3754
+ : 256 /* PatchFlags.UNKEYED_FRAGMENT */;
3747
3755
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
3748
3756
  (``), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
3749
3757
  return () => {
@@ -3753,16 +3761,16 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3753
3761
  // check <template v-for> key placement
3754
3762
  if (isTemplate) {
3755
3763
  node.children.some(c => {
3756
- if (c.type === 1 /* ELEMENT */) {
3764
+ if (c.type === 1 /* NodeTypes.ELEMENT */) {
3757
3765
  const key = findProp(c, 'key');
3758
3766
  if (key) {
3759
- context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3767
+ context.onError(createCompilerError(33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3760
3768
  return true;
3761
3769
  }
3762
3770
  }
3763
3771
  });
3764
3772
  }
3765
- const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* ELEMENT */;
3773
+ const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */;
3766
3774
  const slotOutlet = isSlotOutlet(node)
3767
3775
  ? node
3768
3776
  : isTemplate &&
@@ -3783,7 +3791,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3783
3791
  else if (needFragmentWrapper) {
3784
3792
  // <template v-for="..."> with text or multi-elements
3785
3793
  // should generate a fragment block for each loop
3786
- childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* STABLE_FRAGMENT */ +
3794
+ childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* PatchFlags.STABLE_FRAGMENT */ +
3787
3795
  (``), undefined, undefined, true, undefined, false /* isComponent */);
3788
3796
  }
3789
3797
  else {
@@ -3840,7 +3848,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3840
3848
  // target-agnostic transform used for both Client and SSR
3841
3849
  function processFor(node, dir, context, processCodegen) {
3842
3850
  if (!dir.exp) {
3843
- context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
3851
+ context.onError(createCompilerError(31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */, dir.loc));
3844
3852
  return;
3845
3853
  }
3846
3854
  const parseResult = parseForExpression(
@@ -3848,13 +3856,13 @@ function processFor(node, dir, context, processCodegen) {
3848
3856
  // before expression transform.
3849
3857
  dir.exp, context);
3850
3858
  if (!parseResult) {
3851
- context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3859
+ context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3852
3860
  return;
3853
3861
  }
3854
3862
  const { addIdentifiers, removeIdentifiers, scopes } = context;
3855
3863
  const { source, value, key, index } = parseResult;
3856
3864
  const forNode = {
3857
- type: 11 /* FOR */,
3865
+ type: 11 /* NodeTypes.FOR */,
3858
3866
  loc: dir.loc,
3859
3867
  source,
3860
3868
  valueAlias: value,
@@ -3966,9 +3974,9 @@ const defaultFallback = createSimpleExpression(`undefined`, false);
3966
3974
  // Note the exit callback is executed before buildSlots() on the same node,
3967
3975
  // so only nested slots see positive numbers.
3968
3976
  const trackSlotScopes = (node, context) => {
3969
- if (node.type === 1 /* ELEMENT */ &&
3970
- (node.tagType === 1 /* COMPONENT */ ||
3971
- node.tagType === 3 /* TEMPLATE */)) {
3977
+ if (node.type === 1 /* NodeTypes.ELEMENT */ &&
3978
+ (node.tagType === 1 /* ElementTypes.COMPONENT */ ||
3979
+ node.tagType === 3 /* ElementTypes.TEMPLATE */)) {
3972
3980
  // We are only checking non-empty v-slot here
3973
3981
  // since we only care about slots that introduce scope variables.
3974
3982
  const vSlot = findDir(node, 'slot');
@@ -4041,20 +4049,21 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4041
4049
  let hasNamedDefaultSlot = false;
4042
4050
  const implicitDefaultChildren = [];
4043
4051
  const seenSlotNames = new Set();
4052
+ let conditionalBranchIndex = 0;
4044
4053
  for (let i = 0; i < children.length; i++) {
4045
4054
  const slotElement = children[i];
4046
4055
  let slotDir;
4047
4056
  if (!isTemplateNode(slotElement) ||
4048
4057
  !(slotDir = findDir(slotElement, 'slot', true))) {
4049
4058
  // not a <template v-slot>, skip.
4050
- if (slotElement.type !== 3 /* COMMENT */) {
4059
+ if (slotElement.type !== 3 /* NodeTypes.COMMENT */) {
4051
4060
  implicitDefaultChildren.push(slotElement);
4052
4061
  }
4053
4062
  continue;
4054
4063
  }
4055
4064
  if (onComponentSlot) {
4056
4065
  // already has on-component slot - this is incorrect usage.
4057
- context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
4066
+ context.onError(createCompilerError(37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
4058
4067
  break;
4059
4068
  }
4060
4069
  hasTemplateSlots = true;
@@ -4075,7 +4084,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4075
4084
  let vFor;
4076
4085
  if ((vIf = findDir(slotElement, 'if'))) {
4077
4086
  hasDynamicSlots = true;
4078
- dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
4087
+ dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
4079
4088
  }
4080
4089
  else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
4081
4090
  // find adjacent v-if
@@ -4083,7 +4092,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4083
4092
  let prev;
4084
4093
  while (j--) {
4085
4094
  prev = children[j];
4086
- if (prev.type !== 3 /* COMMENT */) {
4095
+ if (prev.type !== 3 /* NodeTypes.COMMENT */) {
4087
4096
  break;
4088
4097
  }
4089
4098
  }
@@ -4093,15 +4102,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4093
4102
  i--;
4094
4103
  // attach this slot to previous conditional
4095
4104
  let conditional = dynamicSlots[dynamicSlots.length - 1];
4096
- while (conditional.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
4105
+ while (conditional.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
4097
4106
  conditional = conditional.alternate;
4098
4107
  }
4099
4108
  conditional.alternate = vElse.exp
4100
- ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
4101
- : buildDynamicSlot(slotName, slotFunction);
4109
+ ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback)
4110
+ : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
4102
4111
  }
4103
4112
  else {
4104
- context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
4113
+ context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
4105
4114
  }
4106
4115
  }
4107
4116
  else if ((vFor = findDir(slotElement, 'for'))) {
@@ -4117,14 +4126,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4117
4126
  ]));
4118
4127
  }
4119
4128
  else {
4120
- context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
4129
+ context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
4121
4130
  }
4122
4131
  }
4123
4132
  else {
4124
4133
  // check duplicate static names
4125
4134
  if (staticSlotName) {
4126
4135
  if (seenSlotNames.has(staticSlotName)) {
4127
- context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
4136
+ context.onError(createCompilerError(38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
4128
4137
  continue;
4129
4138
  }
4130
4139
  seenSlotNames.add(staticSlotName);
@@ -4154,7 +4163,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4154
4163
  implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
4155
4164
  // implicit default slot (mixed with named slots)
4156
4165
  if (hasNamedDefaultSlot) {
4157
- context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
4166
+ context.onError(createCompilerError(39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
4158
4167
  }
4159
4168
  else {
4160
4169
  slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
@@ -4162,10 +4171,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4162
4171
  }
4163
4172
  }
4164
4173
  const slotFlag = hasDynamicSlots
4165
- ? 2 /* DYNAMIC */
4174
+ ? 2 /* SlotFlags.DYNAMIC */
4166
4175
  : hasForwardedSlots(node.children)
4167
- ? 3 /* FORWARDED */
4168
- : 1 /* STABLE */;
4176
+ ? 3 /* SlotFlags.FORWARDED */
4177
+ : 1 /* SlotFlags.STABLE */;
4169
4178
  let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
4170
4179
  // 2 = compiled but dynamic = can skip normalization, but must run diff
4171
4180
  // 1 = compiled and static = can skip normalization AND diff as optimized
@@ -4181,28 +4190,32 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4181
4190
  hasDynamicSlots
4182
4191
  };
4183
4192
  }
4184
- function buildDynamicSlot(name, fn) {
4185
- return createObjectExpression([
4193
+ function buildDynamicSlot(name, fn, index) {
4194
+ const props = [
4186
4195
  createObjectProperty(`name`, name),
4187
4196
  createObjectProperty(`fn`, fn)
4188
- ]);
4197
+ ];
4198
+ if (index != null) {
4199
+ props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
4200
+ }
4201
+ return createObjectExpression(props);
4189
4202
  }
4190
4203
  function hasForwardedSlots(children) {
4191
4204
  for (let i = 0; i < children.length; i++) {
4192
4205
  const child = children[i];
4193
4206
  switch (child.type) {
4194
- case 1 /* ELEMENT */:
4195
- if (child.tagType === 2 /* SLOT */ ||
4207
+ case 1 /* NodeTypes.ELEMENT */:
4208
+ if (child.tagType === 2 /* ElementTypes.SLOT */ ||
4196
4209
  hasForwardedSlots(child.children)) {
4197
4210
  return true;
4198
4211
  }
4199
4212
  break;
4200
- case 9 /* IF */:
4213
+ case 9 /* NodeTypes.IF */:
4201
4214
  if (hasForwardedSlots(child.branches))
4202
4215
  return true;
4203
4216
  break;
4204
- case 10 /* IF_BRANCH */:
4205
- case 11 /* FOR */:
4217
+ case 10 /* NodeTypes.IF_BRANCH */:
4218
+ case 11 /* NodeTypes.FOR */:
4206
4219
  if (hasForwardedSlots(child.children))
4207
4220
  return true;
4208
4221
  break;
@@ -4211,9 +4224,9 @@ function hasForwardedSlots(children) {
4211
4224
  return false;
4212
4225
  }
4213
4226
  function isNonWhitespaceContent(node) {
4214
- if (node.type !== 2 /* TEXT */ && node.type !== 12 /* TEXT_CALL */)
4227
+ if (node.type !== 2 /* NodeTypes.TEXT */ && node.type !== 12 /* NodeTypes.TEXT_CALL */)
4215
4228
  return true;
4216
- return node.type === 2 /* TEXT */
4229
+ return node.type === 2 /* NodeTypes.TEXT */
4217
4230
  ? !!node.content.trim()
4218
4231
  : isNonWhitespaceContent(node.content);
4219
4232
  }
@@ -4227,13 +4240,13 @@ const transformElement = (node, context) => {
4227
4240
  // processed and merged.
4228
4241
  return function postTransformElement() {
4229
4242
  node = context.currentNode;
4230
- if (!(node.type === 1 /* ELEMENT */ &&
4231
- (node.tagType === 0 /* ELEMENT */ ||
4232
- node.tagType === 1 /* COMPONENT */))) {
4243
+ if (!(node.type === 1 /* NodeTypes.ELEMENT */ &&
4244
+ (node.tagType === 0 /* ElementTypes.ELEMENT */ ||
4245
+ node.tagType === 1 /* ElementTypes.COMPONENT */))) {
4233
4246
  return;
4234
4247
  }
4235
4248
  const { tag, props } = node;
4236
- const isComponent = node.tagType === 1 /* COMPONENT */;
4249
+ const isComponent = node.tagType === 1 /* ElementTypes.COMPONENT */;
4237
4250
  // The goal of the transform is to create a codegenNode implementing the
4238
4251
  // VNodeCall interface.
4239
4252
  let vnodeTag = isComponent
@@ -4284,7 +4297,7 @@ const transformElement = (node, context) => {
4284
4297
  // collected by a parent block.
4285
4298
  shouldUseBlock = true;
4286
4299
  // 2. Force keep-alive to always be updated, since it uses raw children.
4287
- patchFlag |= 1024 /* DYNAMIC_SLOTS */;
4300
+ patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
4288
4301
  }
4289
4302
  const shouldBuildAsSlots = isComponent &&
4290
4303
  // Teleport is not a real component and has dedicated runtime handling
@@ -4295,22 +4308,22 @@ const transformElement = (node, context) => {
4295
4308
  const { slots, hasDynamicSlots } = buildSlots(node, context);
4296
4309
  vnodeChildren = slots;
4297
4310
  if (hasDynamicSlots) {
4298
- patchFlag |= 1024 /* DYNAMIC_SLOTS */;
4311
+ patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
4299
4312
  }
4300
4313
  }
4301
4314
  else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
4302
4315
  const child = node.children[0];
4303
4316
  const type = child.type;
4304
4317
  // check for dynamic text children
4305
- const hasDynamicTextChild = type === 5 /* INTERPOLATION */ ||
4306
- type === 8 /* COMPOUND_EXPRESSION */;
4318
+ const hasDynamicTextChild = type === 5 /* NodeTypes.INTERPOLATION */ ||
4319
+ type === 8 /* NodeTypes.COMPOUND_EXPRESSION */;
4307
4320
  if (hasDynamicTextChild &&
4308
- getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
4309
- patchFlag |= 1 /* TEXT */;
4321
+ getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
4322
+ patchFlag |= 1 /* PatchFlags.TEXT */;
4310
4323
  }
4311
4324
  // pass directly if the only child is a text node
4312
4325
  // (plain / interpolation / expression)
4313
- if (hasDynamicTextChild || type === 2 /* TEXT */) {
4326
+ if (hasDynamicTextChild || type === 2 /* NodeTypes.TEXT */) {
4314
4327
  vnodeChildren = child;
4315
4328
  }
4316
4329
  else {
@@ -4340,8 +4353,8 @@ function resolveComponentType(node, context, ssr = false) {
4340
4353
  const isProp = findProp(node, 'is');
4341
4354
  if (isProp) {
4342
4355
  if (isExplicitDynamic ||
4343
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))) {
4344
- const exp = isProp.type === 6 /* ATTRIBUTE */
4356
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))) {
4357
+ const exp = isProp.type === 6 /* NodeTypes.ATTRIBUTE */
4345
4358
  ? isProp.value && createSimpleExpression(isProp.value.content, true)
4346
4359
  : isProp.exp;
4347
4360
  if (exp) {
@@ -4350,7 +4363,7 @@ function resolveComponentType(node, context, ssr = false) {
4350
4363
  ]);
4351
4364
  }
4352
4365
  }
4353
- else if (isProp.type === 6 /* ATTRIBUTE */ &&
4366
+ else if (isProp.type === 6 /* NodeTypes.ATTRIBUTE */ &&
4354
4367
  isProp.value.content.startsWith('vue:')) {
4355
4368
  // <button is="vue:xxx">
4356
4369
  // if not <component>, only is value that starts with "vue:" will be
@@ -4424,17 +4437,17 @@ function resolveSetupReference(name, context) {
4424
4437
  return PascalName;
4425
4438
  }
4426
4439
  };
4427
- const fromConst = checkType("setup-const" /* SETUP_CONST */) ||
4428
- checkType("setup-reactive-const" /* SETUP_REACTIVE_CONST */);
4440
+ const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
4441
+ checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
4429
4442
  if (fromConst) {
4430
4443
  return context.inline
4431
4444
  ? // in inline mode, const setup bindings (e.g. imports) can be used as-is
4432
4445
  fromConst
4433
4446
  : `$setup[${JSON.stringify(fromConst)}]`;
4434
4447
  }
4435
- const fromMaybeRef = checkType("setup-let" /* SETUP_LET */) ||
4436
- checkType("setup-ref" /* SETUP_REF */) ||
4437
- checkType("setup-maybe-ref" /* SETUP_MAYBE_REF */);
4448
+ const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
4449
+ checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
4450
+ checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
4438
4451
  if (fromMaybeRef) {
4439
4452
  return context.inline
4440
4453
  ? // setup scope bindings that may be refs need to be unrefed
@@ -4476,9 +4489,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4476
4489
  if (isEventHandler && shared.isReservedProp(name)) {
4477
4490
  hasVnodeHook = true;
4478
4491
  }
4479
- if (value.type === 20 /* JS_CACHE_EXPRESSION */ ||
4480
- ((value.type === 4 /* SIMPLE_EXPRESSION */ ||
4481
- value.type === 8 /* COMPOUND_EXPRESSION */) &&
4492
+ if (value.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */ ||
4493
+ ((value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
4494
+ value.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) &&
4482
4495
  getConstantType(value, context) > 0)) {
4483
4496
  // skip if the prop is a cached handler or has constant value
4484
4497
  return;
@@ -4509,7 +4522,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4509
4522
  for (let i = 0; i < props.length; i++) {
4510
4523
  // static attribute
4511
4524
  const prop = props[i];
4512
- if (prop.type === 6 /* ATTRIBUTE */) {
4525
+ if (prop.type === 6 /* NodeTypes.ATTRIBUTE */) {
4513
4526
  const { loc, name, value } = prop;
4514
4527
  let isStatic = true;
4515
4528
  if (name === 'ref') {
@@ -4531,7 +4544,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4531
4544
  if (name === 'is' &&
4532
4545
  (isComponentTag(tag) ||
4533
4546
  (value && value.content.startsWith('vue:')) ||
4534
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
4547
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context)))) {
4535
4548
  continue;
4536
4549
  }
4537
4550
  properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
@@ -4544,7 +4557,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4544
4557
  // skip v-slot - it is handled by its dedicated transform.
4545
4558
  if (name === 'slot') {
4546
4559
  if (!isComponent) {
4547
- context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
4560
+ context.onError(createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, loc));
4548
4561
  }
4549
4562
  continue;
4550
4563
  }
@@ -4557,7 +4570,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4557
4570
  (isVBind &&
4558
4571
  isStaticArgOf(arg, 'is') &&
4559
4572
  (isComponentTag(tag) ||
4560
- (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
4573
+ (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))))) {
4561
4574
  continue;
4562
4575
  }
4563
4576
  // skip v-on in SSR compilation
@@ -4585,7 +4598,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4585
4598
  }
4586
4599
  if (isVBind) {
4587
4600
  {
4588
- if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context)) {
4601
+ if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
4589
4602
  mergeArgs.unshift(exp);
4590
4603
  continue;
4591
4604
  }
@@ -4595,17 +4608,17 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4595
4608
  else {
4596
4609
  // v-on="obj" -> toHandlers(obj)
4597
4610
  mergeArgs.push({
4598
- type: 14 /* JS_CALL_EXPRESSION */,
4611
+ type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
4599
4612
  loc,
4600
4613
  callee: context.helper(TO_HANDLERS),
4601
- arguments: [exp]
4614
+ arguments: isComponent ? [exp] : [exp, `true`]
4602
4615
  });
4603
4616
  }
4604
4617
  }
4605
4618
  else {
4606
4619
  context.onError(createCompilerError(isVBind
4607
- ? 34 /* X_V_BIND_NO_EXPRESSION */
4608
- : 35 /* X_V_ON_NO_EXPRESSION */, loc));
4620
+ ? 34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */
4621
+ : 35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
4609
4622
  }
4610
4623
  continue;
4611
4624
  }
@@ -4652,31 +4665,31 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4652
4665
  }
4653
4666
  // patchFlag analysis
4654
4667
  if (hasDynamicKeys) {
4655
- patchFlag |= 16 /* FULL_PROPS */;
4668
+ patchFlag |= 16 /* PatchFlags.FULL_PROPS */;
4656
4669
  }
4657
4670
  else {
4658
4671
  if (hasClassBinding && !isComponent) {
4659
- patchFlag |= 2 /* CLASS */;
4672
+ patchFlag |= 2 /* PatchFlags.CLASS */;
4660
4673
  }
4661
4674
  if (hasStyleBinding && !isComponent) {
4662
- patchFlag |= 4 /* STYLE */;
4675
+ patchFlag |= 4 /* PatchFlags.STYLE */;
4663
4676
  }
4664
4677
  if (dynamicPropNames.length) {
4665
- patchFlag |= 8 /* PROPS */;
4678
+ patchFlag |= 8 /* PatchFlags.PROPS */;
4666
4679
  }
4667
4680
  if (hasHydrationEventBinding) {
4668
- patchFlag |= 32 /* HYDRATE_EVENTS */;
4681
+ patchFlag |= 32 /* PatchFlags.HYDRATE_EVENTS */;
4669
4682
  }
4670
4683
  }
4671
4684
  if (!shouldUseBlock &&
4672
- (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
4685
+ (patchFlag === 0 || patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) &&
4673
4686
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
4674
- patchFlag |= 512 /* NEED_PATCH */;
4687
+ patchFlag |= 512 /* PatchFlags.NEED_PATCH */;
4675
4688
  }
4676
4689
  // pre-normalize props, SSR is skipped for now
4677
4690
  if (!context.inSSR && propsExpression) {
4678
4691
  switch (propsExpression.type) {
4679
- case 15 /* JS_OBJECT_EXPRESSION */:
4692
+ case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
4680
4693
  // means that there is no v-bind,
4681
4694
  // but still need to deal with dynamic key binding
4682
4695
  let classKeyIndex = -1;
@@ -4707,11 +4720,11 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4707
4720
  // the static style is compiled into an object,
4708
4721
  // so use `hasStyleBinding` to ensure that it is a dynamic style binding
4709
4722
  (hasStyleBinding ||
4710
- (styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
4723
+ (styleProp.value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
4711
4724
  styleProp.value.content.trim()[0] === `[`) ||
4712
4725
  // v-bind:style and style both exist,
4713
4726
  // v-bind:style with static literal object
4714
- styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
4727
+ styleProp.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */)) {
4715
4728
  styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
4716
4729
  }
4717
4730
  }
@@ -4720,7 +4733,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4720
4733
  propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
4721
4734
  }
4722
4735
  break;
4723
- case 14 /* JS_CALL_EXPRESSION */:
4736
+ case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
4724
4737
  // mergeProps call, do nothing
4725
4738
  break;
4726
4739
  default:
@@ -4753,7 +4766,7 @@ function dedupeProperties(properties) {
4753
4766
  for (let i = 0; i < properties.length; i++) {
4754
4767
  const prop = properties[i];
4755
4768
  // dynamic keys are always allowed
4756
- if (prop.key.type === 8 /* COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
4769
+ if (prop.key.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
4757
4770
  deduped.push(prop);
4758
4771
  continue;
4759
4772
  }
@@ -4773,7 +4786,7 @@ function dedupeProperties(properties) {
4773
4786
  return deduped;
4774
4787
  }
4775
4788
  function mergeAsArray(existing, incoming) {
4776
- if (existing.value.type === 17 /* JS_ARRAY_EXPRESSION */) {
4789
+ if (existing.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
4777
4790
  existing.value.elements.push(incoming.value);
4778
4791
  }
4779
4792
  else {
@@ -4883,7 +4896,7 @@ function processSlotOutlet(node, context) {
4883
4896
  const nonNameProps = [];
4884
4897
  for (let i = 0; i < node.props.length; i++) {
4885
4898
  const p = node.props[i];
4886
- if (p.type === 6 /* ATTRIBUTE */) {
4899
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
4887
4900
  if (p.value) {
4888
4901
  if (p.name === 'name') {
4889
4902
  slotName = JSON.stringify(p.value.content);
@@ -4911,7 +4924,7 @@ function processSlotOutlet(node, context) {
4911
4924
  const { props, directives } = buildProps(node, context, nonNameProps, false, false);
4912
4925
  slotProps = props;
4913
4926
  if (directives.length) {
4914
- context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
4927
+ context.onError(createCompilerError(36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
4915
4928
  }
4916
4929
  }
4917
4930
  return {
@@ -4924,18 +4937,26 @@ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?functio
4924
4937
  const transformOn = (dir, node, context, augmentor) => {
4925
4938
  const { loc, modifiers, arg } = dir;
4926
4939
  if (!dir.exp && !modifiers.length) {
4927
- context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
4940
+ context.onError(createCompilerError(35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
4928
4941
  }
4929
4942
  let eventName;
4930
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
4943
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
4931
4944
  if (arg.isStatic) {
4932
4945
  let rawName = arg.content;
4933
4946
  // TODO deprecate @vnodeXXX usage
4934
4947
  if (rawName.startsWith('vue:')) {
4935
4948
  rawName = `vnode-${rawName.slice(4)}`;
4936
4949
  }
4937
- // for all event listeners, auto convert it to camelCase. See issue #2249
4938
- eventName = createSimpleExpression(shared.toHandlerKey(shared.camelize(rawName)), true, arg.loc);
4950
+ const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
4951
+ rawName.startsWith('vnode') ||
4952
+ !/[A-Z]/.test(rawName)
4953
+ ? // for component and vnode lifecycle event listeners, auto convert
4954
+ // it to camelCase. See issue #2249
4955
+ shared.toHandlerKey(shared.camelize(rawName))
4956
+ // preserve case for plain element listeners that have uppercase
4957
+ // letters, as these may be custom elements' custom events
4958
+ : `on:${rawName}`;
4959
+ eventName = createSimpleExpression(eventString, true, arg.loc);
4939
4960
  }
4940
4961
  else {
4941
4962
  // #2388
@@ -4975,13 +4996,13 @@ const transformOn = (dir, node, context, augmentor) => {
4975
4996
  !context.inVOnce &&
4976
4997
  // runtime constants don't need to be cached
4977
4998
  // (this is analyzed by compileScript in SFC <script setup>)
4978
- !(exp.type === 4 /* SIMPLE_EXPRESSION */ && exp.constType > 0) &&
4999
+ !(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && exp.constType > 0) &&
4979
5000
  // #1541 bail if this is a member exp handler passed to a component -
4980
5001
  // we need to use the original function to preserve arity,
4981
5002
  // e.g. <transition> relies on checking cb.length to determine
4982
5003
  // transition end handling. Inline function is ok since its arity
4983
5004
  // is preserved even when cached.
4984
- !(isMemberExp && node.tagType === 1 /* COMPONENT */) &&
5005
+ !(isMemberExp && node.tagType === 1 /* ElementTypes.COMPONENT */) &&
4985
5006
  // bail if the function references closure variables (v-for, v-slot)
4986
5007
  // it must be passed fresh to avoid stale values.
4987
5008
  !hasScopeRef(exp, context.identifiers);
@@ -4990,7 +5011,7 @@ const transformOn = (dir, node, context, augmentor) => {
4990
5011
  // below) so that it always accesses the latest value when called - thus
4991
5012
  // avoiding the need to be patched.
4992
5013
  if (shouldCache && isMemberExp) {
4993
- if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
5014
+ if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
4994
5015
  exp.content = `${exp.content} && ${exp.content}(...args)`;
4995
5016
  }
4996
5017
  else {
@@ -5037,7 +5058,7 @@ const transformOn = (dir, node, context, augmentor) => {
5037
5058
  const transformBind = (dir, _node, context) => {
5038
5059
  const { exp, modifiers, loc } = dir;
5039
5060
  const arg = dir.arg;
5040
- if (arg.type !== 4 /* SIMPLE_EXPRESSION */) {
5061
+ if (arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5041
5062
  arg.children.unshift(`(`);
5042
5063
  arg.children.push(`) || ""`);
5043
5064
  }
@@ -5046,7 +5067,7 @@ const transformBind = (dir, _node, context) => {
5046
5067
  }
5047
5068
  // .sync is replaced by v-model:arg
5048
5069
  if (modifiers.includes('camel')) {
5049
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
5070
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5050
5071
  if (arg.isStatic) {
5051
5072
  arg.content = shared.camelize(arg.content);
5052
5073
  }
@@ -5068,8 +5089,8 @@ const transformBind = (dir, _node, context) => {
5068
5089
  }
5069
5090
  }
5070
5091
  if (!exp ||
5071
- (exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
5072
- context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
5092
+ (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !exp.content.trim())) {
5093
+ context.onError(createCompilerError(34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */, loc));
5073
5094
  return {
5074
5095
  props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
5075
5096
  };
@@ -5079,7 +5100,7 @@ const transformBind = (dir, _node, context) => {
5079
5100
  };
5080
5101
  };
5081
5102
  const injectPrefix = (arg, prefix) => {
5082
- if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
5103
+ if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5083
5104
  if (arg.isStatic) {
5084
5105
  arg.content = prefix + arg.content;
5085
5106
  }
@@ -5096,10 +5117,10 @@ const injectPrefix = (arg, prefix) => {
5096
5117
  // Merge adjacent text nodes and expressions into a single expression
5097
5118
  // e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
5098
5119
  const transformText = (node, context) => {
5099
- if (node.type === 0 /* ROOT */ ||
5100
- node.type === 1 /* ELEMENT */ ||
5101
- node.type === 11 /* FOR */ ||
5102
- node.type === 10 /* IF_BRANCH */) {
5120
+ if (node.type === 0 /* NodeTypes.ROOT */ ||
5121
+ node.type === 1 /* NodeTypes.ELEMENT */ ||
5122
+ node.type === 11 /* NodeTypes.FOR */ ||
5123
+ node.type === 10 /* NodeTypes.IF_BRANCH */) {
5103
5124
  // perform the transform on node exit so that all expressions have already
5104
5125
  // been processed.
5105
5126
  return () => {
@@ -5134,15 +5155,15 @@ const transformText = (node, context) => {
5134
5155
  // setting textContent of the element.
5135
5156
  // for component root it's always normalized anyway.
5136
5157
  (children.length === 1 &&
5137
- (node.type === 0 /* ROOT */ ||
5138
- (node.type === 1 /* ELEMENT */ &&
5139
- node.tagType === 0 /* ELEMENT */ &&
5158
+ (node.type === 0 /* NodeTypes.ROOT */ ||
5159
+ (node.type === 1 /* NodeTypes.ELEMENT */ &&
5160
+ node.tagType === 0 /* ElementTypes.ELEMENT */ &&
5140
5161
  // #3756
5141
5162
  // custom directives can potentially add DOM elements arbitrarily,
5142
5163
  // we need to avoid setting textContent of the element at runtime
5143
5164
  // to avoid accidentally overwriting the DOM elements added
5144
5165
  // by the user through custom directives.
5145
- !node.props.find(p => p.type === 7 /* DIRECTIVE */ &&
5166
+ !node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
5146
5167
  !context.directiveTransforms[p.name]) &&
5147
5168
  // in compat mode, <template> tags with no special directives
5148
5169
  // will be rendered as a fragment so its children must be
@@ -5154,21 +5175,21 @@ const transformText = (node, context) => {
5154
5175
  // runtime normalization.
5155
5176
  for (let i = 0; i < children.length; i++) {
5156
5177
  const child = children[i];
5157
- if (isText(child) || child.type === 8 /* COMPOUND_EXPRESSION */) {
5178
+ if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5158
5179
  const callArgs = [];
5159
5180
  // createTextVNode defaults to single whitespace, so if it is a
5160
5181
  // single space the code could be an empty call to save bytes.
5161
- if (child.type !== 2 /* TEXT */ || child.content !== ' ') {
5182
+ if (child.type !== 2 /* NodeTypes.TEXT */ || child.content !== ' ') {
5162
5183
  callArgs.push(child);
5163
5184
  }
5164
5185
  // mark dynamic text with flag so it gets patched inside a block
5165
5186
  if (!context.ssr &&
5166
- getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
5167
- callArgs.push(1 /* TEXT */ +
5187
+ getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
5188
+ callArgs.push(1 /* PatchFlags.TEXT */ +
5168
5189
  (``));
5169
5190
  }
5170
5191
  children[i] = {
5171
- type: 12 /* TEXT_CALL */,
5192
+ type: 12 /* NodeTypes.TEXT_CALL */,
5172
5193
  content: child,
5173
5194
  loc: child.loc,
5174
5195
  codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
@@ -5181,7 +5202,7 @@ const transformText = (node, context) => {
5181
5202
 
5182
5203
  const seen = new WeakSet();
5183
5204
  const transformOnce = (node, context) => {
5184
- if (node.type === 1 /* ELEMENT */ && findDir(node, 'once', true)) {
5205
+ if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5185
5206
  if (seen.has(node) || context.inVOnce) {
5186
5207
  return;
5187
5208
  }
@@ -5201,26 +5222,26 @@ const transformOnce = (node, context) => {
5201
5222
  const transformModel = (dir, node, context) => {
5202
5223
  const { exp, arg } = dir;
5203
5224
  if (!exp) {
5204
- context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
5225
+ context.onError(createCompilerError(41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */, dir.loc));
5205
5226
  return createTransformProps();
5206
5227
  }
5207
5228
  const rawExp = exp.loc.source;
5208
- const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
5229
+ const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
5209
5230
  // im SFC <script setup> inline mode, the exp may have been transformed into
5210
5231
  // _unref(exp)
5211
5232
  const bindingType = context.bindingMetadata[rawExp];
5212
5233
  const maybeRef = context.inline &&
5213
5234
  bindingType &&
5214
- bindingType !== "setup-const" /* SETUP_CONST */;
5235
+ bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
5215
5236
  if (!expString.trim() ||
5216
5237
  (!isMemberExpression(expString, context) && !maybeRef)) {
5217
- context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5238
+ context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5218
5239
  return createTransformProps();
5219
5240
  }
5220
5241
  if (context.prefixIdentifiers &&
5221
5242
  isSimpleIdentifier(expString) &&
5222
5243
  context.identifiers[expString]) {
5223
- context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5244
+ context.onError(createCompilerError(43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5224
5245
  return createTransformProps();
5225
5246
  }
5226
5247
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
@@ -5232,7 +5253,7 @@ const transformModel = (dir, node, context) => {
5232
5253
  let assignmentExp;
5233
5254
  const eventArg = context.isTS ? `($event: any)` : `$event`;
5234
5255
  if (maybeRef) {
5235
- if (bindingType === "setup-ref" /* SETUP_REF */) {
5256
+ if (bindingType === "setup-ref" /* BindingTypes.SETUP_REF */) {
5236
5257
  // v-model used on known ref.
5237
5258
  assignmentExp = createCompoundExpression([
5238
5259
  `${eventArg} => ((`,
@@ -5243,7 +5264,7 @@ const transformModel = (dir, node, context) => {
5243
5264
  else {
5244
5265
  // v-model used on a potentially ref binding in <script setup> inline mode.
5245
5266
  // the assignment needs to check whether the binding is actually a ref.
5246
- const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
5267
+ const altAssignment = bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ? `${rawExp} = $event` : `null`;
5247
5268
  assignmentExp = createCompoundExpression([
5248
5269
  `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
5249
5270
  createSimpleExpression(rawExp, false, exp.loc),
@@ -5272,7 +5293,7 @@ const transformModel = (dir, node, context) => {
5272
5293
  props[1].value = context.cache(props[1].value);
5273
5294
  }
5274
5295
  // modelModifiers: { foo: true, "bar-baz": true }
5275
- if (dir.modifiers.length && node.tagType === 1 /* COMPONENT */) {
5296
+ if (dir.modifiers.length && node.tagType === 1 /* ElementTypes.COMPONENT */) {
5276
5297
  const modifiers = dir.modifiers
5277
5298
  .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
5278
5299
  .join(`, `);
@@ -5281,7 +5302,7 @@ const transformModel = (dir, node, context) => {
5281
5302
  ? `${arg.content}Modifiers`
5282
5303
  : createCompoundExpression([arg, ' + "Modifiers"'])
5283
5304
  : `modelModifiers`;
5284
- props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* CAN_HOIST */)));
5305
+ props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* ConstantTypes.CAN_HOIST */)));
5285
5306
  }
5286
5307
  return createTransformProps(props);
5287
5308
  };
@@ -5291,17 +5312,17 @@ function createTransformProps(props = []) {
5291
5312
 
5292
5313
  const validDivisionCharRE = /[\w).+\-_$\]]/;
5293
5314
  const transformFilter = (node, context) => {
5294
- if (!isCompatEnabled("COMPILER_FILTER" /* COMPILER_FILTERS */, context)) {
5315
+ if (!isCompatEnabled("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context)) {
5295
5316
  return;
5296
5317
  }
5297
- if (node.type === 5 /* INTERPOLATION */) {
5318
+ if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
5298
5319
  // filter rewrite is applied before expression transform so only
5299
5320
  // simple expressions are possible at this stage
5300
5321
  rewriteFilter(node.content, context);
5301
5322
  }
5302
- if (node.type === 1 /* ELEMENT */) {
5323
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
5303
5324
  node.props.forEach((prop) => {
5304
- if (prop.type === 7 /* DIRECTIVE */ &&
5325
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */ &&
5305
5326
  prop.name !== 'for' &&
5306
5327
  prop.exp) {
5307
5328
  rewriteFilter(prop.exp, context);
@@ -5310,7 +5331,7 @@ const transformFilter = (node, context) => {
5310
5331
  }
5311
5332
  };
5312
5333
  function rewriteFilter(node, context) {
5313
- if (node.type === 4 /* SIMPLE_EXPRESSION */) {
5334
+ if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5314
5335
  parseFilter(node, context);
5315
5336
  }
5316
5337
  else {
@@ -5318,13 +5339,13 @@ function rewriteFilter(node, context) {
5318
5339
  const child = node.children[i];
5319
5340
  if (typeof child !== 'object')
5320
5341
  continue;
5321
- if (child.type === 4 /* SIMPLE_EXPRESSION */) {
5342
+ if (child.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
5322
5343
  parseFilter(child, context);
5323
5344
  }
5324
- else if (child.type === 8 /* COMPOUND_EXPRESSION */) {
5345
+ else if (child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5325
5346
  rewriteFilter(node, context);
5326
5347
  }
5327
- else if (child.type === 5 /* INTERPOLATION */) {
5348
+ else if (child.type === 5 /* NodeTypes.INTERPOLATION */) {
5328
5349
  rewriteFilter(child.content, context);
5329
5350
  }
5330
5351
  }
@@ -5455,7 +5476,7 @@ function wrapFilter(exp, filter, context) {
5455
5476
 
5456
5477
  const seen$1 = new WeakSet();
5457
5478
  const transformMemo = (node, context) => {
5458
- if (node.type === 1 /* ELEMENT */) {
5479
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
5459
5480
  const dir = findDir(node, 'memo');
5460
5481
  if (!dir || seen$1.has(node)) {
5461
5482
  return;
@@ -5464,9 +5485,9 @@ const transformMemo = (node, context) => {
5464
5485
  return () => {
5465
5486
  const codegenNode = node.codegenNode ||
5466
5487
  context.currentNode.codegenNode;
5467
- if (codegenNode && codegenNode.type === 13 /* VNODE_CALL */) {
5488
+ if (codegenNode && codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
5468
5489
  // non-component sub tree should be turned into a block
5469
- if (node.tagType !== 1 /* COMPONENT */) {
5490
+ if (node.tagType !== 1 /* ElementTypes.COMPONENT */) {
5470
5491
  makeBlock(codegenNode, context);
5471
5492
  }
5472
5493
  node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
@@ -5514,10 +5535,10 @@ function baseCompile(template, options = {}) {
5514
5535
  const isModuleMode = options.mode === 'module';
5515
5536
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
5516
5537
  if (!prefixIdentifiers && options.cacheHandlers) {
5517
- onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
5538
+ onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5518
5539
  }
5519
5540
  if (options.scopeId && !isModuleMode) {
5520
- onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
5541
+ onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5521
5542
  }
5522
5543
  const ast = shared.isString(template) ? baseParse(template, options) : template;
5523
5544
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);