@vue/compiler-core 3.4.0-alpha.2 → 3.4.0-alpha.4

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.
@@ -96,6 +96,90 @@ function registerRuntimeHelpers(helpers) {
96
96
  });
97
97
  }
98
98
 
99
+ const Namespaces = {
100
+ "HTML": 0,
101
+ "0": "HTML",
102
+ "SVG": 1,
103
+ "1": "SVG",
104
+ "MATH_ML": 2,
105
+ "2": "MATH_ML"
106
+ };
107
+ const NodeTypes = {
108
+ "ROOT": 0,
109
+ "0": "ROOT",
110
+ "ELEMENT": 1,
111
+ "1": "ELEMENT",
112
+ "TEXT": 2,
113
+ "2": "TEXT",
114
+ "COMMENT": 3,
115
+ "3": "COMMENT",
116
+ "SIMPLE_EXPRESSION": 4,
117
+ "4": "SIMPLE_EXPRESSION",
118
+ "INTERPOLATION": 5,
119
+ "5": "INTERPOLATION",
120
+ "ATTRIBUTE": 6,
121
+ "6": "ATTRIBUTE",
122
+ "DIRECTIVE": 7,
123
+ "7": "DIRECTIVE",
124
+ "COMPOUND_EXPRESSION": 8,
125
+ "8": "COMPOUND_EXPRESSION",
126
+ "IF": 9,
127
+ "9": "IF",
128
+ "IF_BRANCH": 10,
129
+ "10": "IF_BRANCH",
130
+ "FOR": 11,
131
+ "11": "FOR",
132
+ "TEXT_CALL": 12,
133
+ "12": "TEXT_CALL",
134
+ "VNODE_CALL": 13,
135
+ "13": "VNODE_CALL",
136
+ "JS_CALL_EXPRESSION": 14,
137
+ "14": "JS_CALL_EXPRESSION",
138
+ "JS_OBJECT_EXPRESSION": 15,
139
+ "15": "JS_OBJECT_EXPRESSION",
140
+ "JS_PROPERTY": 16,
141
+ "16": "JS_PROPERTY",
142
+ "JS_ARRAY_EXPRESSION": 17,
143
+ "17": "JS_ARRAY_EXPRESSION",
144
+ "JS_FUNCTION_EXPRESSION": 18,
145
+ "18": "JS_FUNCTION_EXPRESSION",
146
+ "JS_CONDITIONAL_EXPRESSION": 19,
147
+ "19": "JS_CONDITIONAL_EXPRESSION",
148
+ "JS_CACHE_EXPRESSION": 20,
149
+ "20": "JS_CACHE_EXPRESSION",
150
+ "JS_BLOCK_STATEMENT": 21,
151
+ "21": "JS_BLOCK_STATEMENT",
152
+ "JS_TEMPLATE_LITERAL": 22,
153
+ "22": "JS_TEMPLATE_LITERAL",
154
+ "JS_IF_STATEMENT": 23,
155
+ "23": "JS_IF_STATEMENT",
156
+ "JS_ASSIGNMENT_EXPRESSION": 24,
157
+ "24": "JS_ASSIGNMENT_EXPRESSION",
158
+ "JS_SEQUENCE_EXPRESSION": 25,
159
+ "25": "JS_SEQUENCE_EXPRESSION",
160
+ "JS_RETURN_STATEMENT": 26,
161
+ "26": "JS_RETURN_STATEMENT"
162
+ };
163
+ const ElementTypes = {
164
+ "ELEMENT": 0,
165
+ "0": "ELEMENT",
166
+ "COMPONENT": 1,
167
+ "1": "COMPONENT",
168
+ "SLOT": 2,
169
+ "2": "SLOT",
170
+ "TEMPLATE": 3,
171
+ "3": "TEMPLATE"
172
+ };
173
+ const ConstantTypes = {
174
+ "NOT_CONSTANT": 0,
175
+ "0": "NOT_CONSTANT",
176
+ "CAN_SKIP_PATCH": 1,
177
+ "1": "CAN_SKIP_PATCH",
178
+ "CAN_HOIST": 2,
179
+ "2": "CAN_HOIST",
180
+ "CAN_STRINGIFY": 3,
181
+ "3": "CAN_STRINGIFY"
182
+ };
99
183
  const locStub = {
100
184
  start: { line: 1, column: 1, offset: 0 },
101
185
  end: { line: 1, column: 1, offset: 0 },
@@ -350,7 +434,9 @@ class Tokenizer {
350
434
  this.inRCDATA = false;
351
435
  /** For disabling RCDATA tags handling */
352
436
  this.inXML = false;
353
- /** Reocrd newline positions for fast line / column calculation */
437
+ /** For disabling interpolation parsing in v-pre */
438
+ this.inVPre = false;
439
+ /** Record newline positions for fast line / column calculation */
354
440
  this.newlines = [];
355
441
  this.mode = 0;
356
442
  this.delimiterOpen = defaultDelimitersOpen;
@@ -375,6 +461,7 @@ class Tokenizer {
375
461
  this.sectionStart = 0;
376
462
  this.index = 0;
377
463
  this.baseState = 1;
464
+ this.inRCDATA = false;
378
465
  this.currentSequence = void 0;
379
466
  this.newlines.length = 0;
380
467
  this.delimiterOpen = defaultDelimitersOpen;
@@ -415,7 +502,7 @@ class Tokenizer {
415
502
  this.sectionStart = this.index;
416
503
  } else if (c === 38) {
417
504
  this.startEntity();
418
- } else if (c === this.delimiterOpen[0]) {
505
+ } else if (!this.inVPre && c === this.delimiterOpen[0]) {
419
506
  this.state = 2;
420
507
  this.delimiterIndex = 0;
421
508
  this.stateInterpolationOpen(c);
@@ -1151,6 +1238,16 @@ class Tokenizer {
1151
1238
  }
1152
1239
  }
1153
1240
 
1241
+ const CompilerDeprecationTypes = {
1242
+ "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
1243
+ "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
1244
+ "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
1245
+ "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
1246
+ "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
1247
+ "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
1248
+ "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
1249
+ "COMPILER_FILTERS": "COMPILER_FILTER"
1250
+ };
1154
1251
  const deprecationData = {
1155
1252
  ["COMPILER_IS_ON_ELEMENT"]: {
1156
1253
  message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
@@ -1232,6 +1329,114 @@ function createCompilerError(code, loc, messages, additionalMessage) {
1232
1329
  error.loc = loc;
1233
1330
  return error;
1234
1331
  }
1332
+ const ErrorCodes = {
1333
+ "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
1334
+ "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
1335
+ "CDATA_IN_HTML_CONTENT": 1,
1336
+ "1": "CDATA_IN_HTML_CONTENT",
1337
+ "DUPLICATE_ATTRIBUTE": 2,
1338
+ "2": "DUPLICATE_ATTRIBUTE",
1339
+ "END_TAG_WITH_ATTRIBUTES": 3,
1340
+ "3": "END_TAG_WITH_ATTRIBUTES",
1341
+ "END_TAG_WITH_TRAILING_SOLIDUS": 4,
1342
+ "4": "END_TAG_WITH_TRAILING_SOLIDUS",
1343
+ "EOF_BEFORE_TAG_NAME": 5,
1344
+ "5": "EOF_BEFORE_TAG_NAME",
1345
+ "EOF_IN_CDATA": 6,
1346
+ "6": "EOF_IN_CDATA",
1347
+ "EOF_IN_COMMENT": 7,
1348
+ "7": "EOF_IN_COMMENT",
1349
+ "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
1350
+ "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
1351
+ "EOF_IN_TAG": 9,
1352
+ "9": "EOF_IN_TAG",
1353
+ "INCORRECTLY_CLOSED_COMMENT": 10,
1354
+ "10": "INCORRECTLY_CLOSED_COMMENT",
1355
+ "INCORRECTLY_OPENED_COMMENT": 11,
1356
+ "11": "INCORRECTLY_OPENED_COMMENT",
1357
+ "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
1358
+ "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
1359
+ "MISSING_ATTRIBUTE_VALUE": 13,
1360
+ "13": "MISSING_ATTRIBUTE_VALUE",
1361
+ "MISSING_END_TAG_NAME": 14,
1362
+ "14": "MISSING_END_TAG_NAME",
1363
+ "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
1364
+ "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
1365
+ "NESTED_COMMENT": 16,
1366
+ "16": "NESTED_COMMENT",
1367
+ "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
1368
+ "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
1369
+ "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
1370
+ "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
1371
+ "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
1372
+ "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
1373
+ "UNEXPECTED_NULL_CHARACTER": 20,
1374
+ "20": "UNEXPECTED_NULL_CHARACTER",
1375
+ "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
1376
+ "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
1377
+ "UNEXPECTED_SOLIDUS_IN_TAG": 22,
1378
+ "22": "UNEXPECTED_SOLIDUS_IN_TAG",
1379
+ "X_INVALID_END_TAG": 23,
1380
+ "23": "X_INVALID_END_TAG",
1381
+ "X_MISSING_END_TAG": 24,
1382
+ "24": "X_MISSING_END_TAG",
1383
+ "X_MISSING_INTERPOLATION_END": 25,
1384
+ "25": "X_MISSING_INTERPOLATION_END",
1385
+ "X_MISSING_DIRECTIVE_NAME": 26,
1386
+ "26": "X_MISSING_DIRECTIVE_NAME",
1387
+ "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
1388
+ "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
1389
+ "X_V_IF_NO_EXPRESSION": 28,
1390
+ "28": "X_V_IF_NO_EXPRESSION",
1391
+ "X_V_IF_SAME_KEY": 29,
1392
+ "29": "X_V_IF_SAME_KEY",
1393
+ "X_V_ELSE_NO_ADJACENT_IF": 30,
1394
+ "30": "X_V_ELSE_NO_ADJACENT_IF",
1395
+ "X_V_FOR_NO_EXPRESSION": 31,
1396
+ "31": "X_V_FOR_NO_EXPRESSION",
1397
+ "X_V_FOR_MALFORMED_EXPRESSION": 32,
1398
+ "32": "X_V_FOR_MALFORMED_EXPRESSION",
1399
+ "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
1400
+ "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
1401
+ "X_V_BIND_NO_EXPRESSION": 34,
1402
+ "34": "X_V_BIND_NO_EXPRESSION",
1403
+ "X_V_ON_NO_EXPRESSION": 35,
1404
+ "35": "X_V_ON_NO_EXPRESSION",
1405
+ "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
1406
+ "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
1407
+ "X_V_SLOT_MIXED_SLOT_USAGE": 37,
1408
+ "37": "X_V_SLOT_MIXED_SLOT_USAGE",
1409
+ "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
1410
+ "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
1411
+ "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
1412
+ "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
1413
+ "X_V_SLOT_MISPLACED": 40,
1414
+ "40": "X_V_SLOT_MISPLACED",
1415
+ "X_V_MODEL_NO_EXPRESSION": 41,
1416
+ "41": "X_V_MODEL_NO_EXPRESSION",
1417
+ "X_V_MODEL_MALFORMED_EXPRESSION": 42,
1418
+ "42": "X_V_MODEL_MALFORMED_EXPRESSION",
1419
+ "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
1420
+ "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
1421
+ "X_V_MODEL_ON_PROPS": 44,
1422
+ "44": "X_V_MODEL_ON_PROPS",
1423
+ "X_INVALID_EXPRESSION": 45,
1424
+ "45": "X_INVALID_EXPRESSION",
1425
+ "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
1426
+ "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
1427
+ "X_VNODE_HOOKS": 47,
1428
+ "47": "X_VNODE_HOOKS",
1429
+ "X_PREFIX_ID_NOT_SUPPORTED": 48,
1430
+ "48": "X_PREFIX_ID_NOT_SUPPORTED",
1431
+ "X_MODULE_MODE_NOT_SUPPORTED": 49,
1432
+ "49": "X_MODULE_MODE_NOT_SUPPORTED",
1433
+ "X_CACHE_HANDLER_NOT_SUPPORTED": 50,
1434
+ "50": "X_CACHE_HANDLER_NOT_SUPPORTED",
1435
+ "X_SCOPE_ID_NOT_SUPPORTED": 51,
1436
+ "51": "X_SCOPE_ID_NOT_SUPPORTED",
1437
+ "__EXTEND_POINT__": 52,
1438
+ "52": "__EXTEND_POINT__"
1439
+ };
1235
1440
  const errorMessages = {
1236
1441
  // parse errors
1237
1442
  [0]: "Illegal comment.",
@@ -1284,16 +1489,14 @@ const errorMessages = {
1284
1489
  Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
1285
1490
  [45]: `Error parsing JavaScript expression: `,
1286
1491
  [46]: `<KeepAlive> expects exactly one child component.`,
1492
+ [47]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
1287
1493
  // generic errors
1288
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1289
- [48]: `ES module mode is not supported in this build of compiler.`,
1290
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1291
- [50]: `"scopeId" option is only supported in module mode.`,
1292
- // deprecations
1293
- [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
1294
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
1494
+ [48]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1495
+ [49]: `ES module mode is not supported in this build of compiler.`,
1496
+ [50]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1497
+ [51]: `"scopeId" option is only supported in module mode.`,
1295
1498
  // just to fulfill types
1296
- [53]: ``
1499
+ [52]: ``
1297
1500
  };
1298
1501
 
1299
1502
  const isStaticExp = (p) => p.type === 4 && p.isStatic;
@@ -1613,7 +1816,8 @@ const defaultParserOptions = {
1613
1816
  isCustomElement: shared.NO,
1614
1817
  onError: defaultOnError,
1615
1818
  onWarn: defaultOnWarn,
1616
- comments: true
1819
+ comments: true,
1820
+ prefixIdentifiers: false
1617
1821
  };
1618
1822
  let currentOptions = defaultParserOptions;
1619
1823
  let currentRoot = null;
@@ -1655,7 +1859,7 @@ const tokenizer = new Tokenizer(stack, {
1655
1859
  }
1656
1860
  addNode({
1657
1861
  type: 5,
1658
- content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
1862
+ content: createExp(exp, false, getLoc(innerStart, innerEnd)),
1659
1863
  loc: getLoc(start, end)
1660
1864
  });
1661
1865
  },
@@ -1748,7 +1952,7 @@ const tokenizer = new Tokenizer(stack, {
1748
1952
  loc: getLoc(start)
1749
1953
  };
1750
1954
  if (name === "pre") {
1751
- inVPre = true;
1955
+ inVPre = tokenizer.inVPre = true;
1752
1956
  currentVPreBoundary = currentOpenTag;
1753
1957
  const props = currentOpenTag.props;
1754
1958
  for (let i = 0; i < props.length; i++) {
@@ -1760,13 +1964,15 @@ const tokenizer = new Tokenizer(stack, {
1760
1964
  }
1761
1965
  },
1762
1966
  ondirarg(start, end) {
1967
+ if (start === end)
1968
+ return;
1763
1969
  const arg = getSlice(start, end);
1764
1970
  if (inVPre) {
1765
1971
  currentProp.name += arg;
1766
1972
  setLocEnd(currentProp.nameLoc, end);
1767
1973
  } else {
1768
1974
  const isStatic = arg[0] !== `[`;
1769
- currentProp.arg = createSimpleExpression(
1975
+ currentProp.arg = createExp(
1770
1976
  isStatic ? arg : arg.slice(1, -1),
1771
1977
  isStatic,
1772
1978
  getLoc(start, end),
@@ -1833,10 +2039,22 @@ const tokenizer = new Tokenizer(stack, {
1833
2039
  tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
1834
2040
  }
1835
2041
  } else {
1836
- currentProp.exp = createSimpleExpression(
2042
+ let expParseMode = 0 /* Normal */;
2043
+ {
2044
+ if (currentProp.name === "for") {
2045
+ expParseMode = 3 /* Skip */;
2046
+ } else if (currentProp.name === "slot") {
2047
+ expParseMode = 1 /* Params */;
2048
+ } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
2049
+ expParseMode = 2 /* Statements */;
2050
+ }
2051
+ }
2052
+ currentProp.exp = createExp(
1837
2053
  currentAttrValue,
1838
2054
  false,
1839
- getLoc(currentAttrStartIndex, currentAttrEndIndex)
2055
+ getLoc(currentAttrStartIndex, currentAttrEndIndex),
2056
+ 0,
2057
+ expParseMode
1840
2058
  );
1841
2059
  if (currentProp.name === "for") {
1842
2060
  currentProp.forParseResult = parseForExpression(currentProp.exp);
@@ -1939,10 +2157,16 @@ function parseForExpression(input) {
1939
2157
  if (!inMatch)
1940
2158
  return;
1941
2159
  const [, LHS, RHS] = inMatch;
1942
- const createAliasExpression = (content, offset) => {
2160
+ const createAliasExpression = (content, offset, asParam = false) => {
1943
2161
  const start = loc.start.offset + offset;
1944
2162
  const end = start + content.length;
1945
- return createSimpleExpression(content, false, getLoc(start, end));
2163
+ return createExp(
2164
+ content,
2165
+ false,
2166
+ getLoc(start, end),
2167
+ 0,
2168
+ asParam ? 1 /* Params */ : 0 /* Normal */
2169
+ );
1946
2170
  };
1947
2171
  const result = {
1948
2172
  source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
@@ -1960,7 +2184,7 @@ function parseForExpression(input) {
1960
2184
  let keyOffset;
1961
2185
  if (keyContent) {
1962
2186
  keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
1963
- result.key = createAliasExpression(keyContent, keyOffset);
2187
+ result.key = createAliasExpression(keyContent, keyOffset, true);
1964
2188
  }
1965
2189
  if (iteratorMatch[2]) {
1966
2190
  const indexContent = iteratorMatch[2].trim();
@@ -1970,13 +2194,14 @@ function parseForExpression(input) {
1970
2194
  exp.indexOf(
1971
2195
  indexContent,
1972
2196
  result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
1973
- )
2197
+ ),
2198
+ true
1974
2199
  );
1975
2200
  }
1976
2201
  }
1977
2202
  }
1978
2203
  if (valueContent) {
1979
- result.value = createAliasExpression(valueContent, trimmedOffset);
2204
+ result.value = createAliasExpression(valueContent, trimmedOffset, true);
1980
2205
  }
1981
2206
  return result;
1982
2207
  }
@@ -2047,7 +2272,7 @@ function onCloseTag(el, end, isImplied = false) {
2047
2272
  inPre--;
2048
2273
  }
2049
2274
  if (currentVPreBoundary === el) {
2050
- inVPre = false;
2275
+ inVPre = tokenizer.inVPre = false;
2051
2276
  currentVPreBoundary = null;
2052
2277
  }
2053
2278
  if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
@@ -2282,8 +2507,36 @@ function dirToAttr(dir) {
2282
2507
  }
2283
2508
  return attr;
2284
2509
  }
2285
- function emitError(code, index) {
2286
- currentOptions.onError(createCompilerError(code, getLoc(index, index)));
2510
+ function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
2511
+ const exp = createSimpleExpression(content, isStatic, loc, constType);
2512
+ if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
2513
+ if (isSimpleIdentifier(content)) {
2514
+ exp.ast = null;
2515
+ return exp;
2516
+ }
2517
+ try {
2518
+ const plugins = currentOptions.expressionPlugins;
2519
+ const options = {
2520
+ plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
2521
+ };
2522
+ if (parseMode === 2 /* Statements */) {
2523
+ exp.ast = parser.parse(` ${content} `, options).program;
2524
+ } else if (parseMode === 1 /* Params */) {
2525
+ exp.ast = parser.parseExpression(`(${content})=>{}`, options);
2526
+ } else {
2527
+ exp.ast = parser.parseExpression(`(${content})`, options);
2528
+ }
2529
+ } catch (e) {
2530
+ exp.ast = false;
2531
+ emitError(45, loc.start.offset, e.message);
2532
+ }
2533
+ }
2534
+ return exp;
2535
+ }
2536
+ function emitError(code, index, message) {
2537
+ currentOptions.onError(
2538
+ createCompilerError(code, getLoc(index, index), void 0, message)
2539
+ );
2287
2540
  }
2288
2541
  function reset() {
2289
2542
  tokenizer.reset();
@@ -2314,6 +2567,7 @@ function baseParse(input, options) {
2314
2567
  }
2315
2568
  }
2316
2569
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2570
+ tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
2317
2571
  const delimiters = options == null ? void 0 : options.delimiters;
2318
2572
  if (delimiters) {
2319
2573
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
@@ -3672,7 +3926,7 @@ function genReturnStatement({ returns }, context) {
3672
3926
  }
3673
3927
 
3674
3928
  function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
3675
- const rootExp = root.type === "Program" && root.body[0].type === "ExpressionStatement" && root.body[0].expression;
3929
+ const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
3676
3930
  estreeWalker.walk(root, {
3677
3931
  enter(node, parent) {
3678
3932
  parent && parentStack.push(parent);
@@ -4021,7 +4275,11 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4021
4275
  };
4022
4276
  const rawExp = node.content;
4023
4277
  const bailConstant = constantBailRE.test(rawExp);
4024
- if (isSimpleIdentifier(rawExp)) {
4278
+ let ast = node.ast;
4279
+ if (ast === false) {
4280
+ return node;
4281
+ }
4282
+ if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
4025
4283
  const isScopeVarReference = context.identifiers[rawExp];
4026
4284
  const isAllowedGlobal = shared.isGloballyAllowed(rawExp);
4027
4285
  const isLiteral = isLiteralWhitelisted(rawExp);
@@ -4039,22 +4297,23 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4039
4297
  }
4040
4298
  return node;
4041
4299
  }
4042
- let ast;
4043
- const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
4044
- try {
4045
- ast = parser.parse(source, {
4046
- plugins: context.expressionPlugins
4047
- }).program;
4048
- } catch (e) {
4049
- context.onError(
4050
- createCompilerError(
4051
- 45,
4052
- node.loc,
4053
- void 0,
4054
- e.message
4055
- )
4056
- );
4057
- return node;
4300
+ if (!ast) {
4301
+ const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
4302
+ try {
4303
+ ast = parser.parse(source, {
4304
+ plugins: context.expressionPlugins
4305
+ }).program;
4306
+ } catch (e) {
4307
+ context.onError(
4308
+ createCompilerError(
4309
+ 45,
4310
+ node.loc,
4311
+ void 0,
4312
+ e.message
4313
+ )
4314
+ );
4315
+ return node;
4316
+ }
4058
4317
  }
4059
4318
  const ids = [];
4060
4319
  const parentStack = [];
@@ -4097,15 +4356,15 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4097
4356
  if (leadingText.length || id.prefix) {
4098
4357
  children.push(leadingText + (id.prefix || ``));
4099
4358
  }
4100
- const source2 = rawExp.slice(start, end);
4359
+ const source = rawExp.slice(start, end);
4101
4360
  children.push(
4102
4361
  createSimpleExpression(
4103
4362
  id.name,
4104
4363
  false,
4105
4364
  {
4106
- start: advancePositionWithClone(node.loc.start, source2, start),
4107
- end: advancePositionWithClone(node.loc.start, source2, end),
4108
- source: source2
4365
+ start: advancePositionWithClone(node.loc.start, source, start),
4366
+ end: advancePositionWithClone(node.loc.start, source, end),
4367
+ source
4109
4368
  },
4110
4369
  id.isConstant ? 3 : 0
4111
4370
  )
@@ -4117,6 +4376,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4117
4376
  let ret;
4118
4377
  if (children.length) {
4119
4378
  ret = createCompoundExpression(children, node.loc);
4379
+ ret.ast = ast;
4120
4380
  } else {
4121
4381
  ret = node;
4122
4382
  ret.constType = bailConstant ? 0 : 3;
@@ -5076,6 +5336,10 @@ function resolveSetupReference(name, context) {
5076
5336
  `${context.helperString(UNREF)}(${fromMaybeRef})`
5077
5337
  ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
5078
5338
  }
5339
+ const fromProps = checkType("props");
5340
+ if (fromProps) {
5341
+ return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
5342
+ }
5079
5343
  }
5080
5344
  function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
5081
5345
  const { tag, loc: elementLoc, children } = node;
@@ -5116,6 +5380,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5116
5380
  if (isEventHandler && shared.isReservedProp(name)) {
5117
5381
  hasVnodeHook = true;
5118
5382
  }
5383
+ if (isEventHandler && value.type === 14) {
5384
+ value = value.arguments[0];
5385
+ }
5119
5386
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
5120
5387
  return;
5121
5388
  }
@@ -5583,9 +5850,7 @@ const transformOn = (dir, node, context, augmentor) => {
5583
5850
  if (arg.isStatic) {
5584
5851
  let rawName = arg.content;
5585
5852
  if (rawName.startsWith("vnode")) {
5586
- context.onWarn(
5587
- createCompilerError(51, arg.loc)
5588
- );
5853
+ context.onError(createCompilerError(47, arg.loc));
5589
5854
  }
5590
5855
  if (rawName.startsWith("vue:")) {
5591
5856
  rawName = `vnode-${rawName.slice(4)}`;
@@ -6119,10 +6384,10 @@ function baseCompile(source, options = {}) {
6119
6384
  const isModuleMode = options.mode === "module";
6120
6385
  const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
6121
6386
  if (!prefixIdentifiers && options.cacheHandlers) {
6122
- onError(createCompilerError(49));
6387
+ onError(createCompilerError(50));
6123
6388
  }
6124
6389
  if (options.scopeId && !isModuleMode) {
6125
- onError(createCompilerError(50));
6390
+ onError(createCompilerError(51));
6126
6391
  }
6127
6392
  const ast = shared.isString(source) ? baseParse(source, options) : source;
6128
6393
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -6157,10 +6422,24 @@ function baseCompile(source, options = {}) {
6157
6422
  );
6158
6423
  }
6159
6424
 
6425
+ const BindingTypes = {
6426
+ "DATA": "data",
6427
+ "PROPS": "props",
6428
+ "PROPS_ALIASED": "props-aliased",
6429
+ "SETUP_LET": "setup-let",
6430
+ "SETUP_CONST": "setup-const",
6431
+ "SETUP_REACTIVE_CONST": "setup-reactive-const",
6432
+ "SETUP_MAYBE_REF": "setup-maybe-ref",
6433
+ "SETUP_REF": "setup-ref",
6434
+ "OPTIONS": "options",
6435
+ "LITERAL_CONST": "literal-const"
6436
+ };
6437
+
6160
6438
  const noopDirectiveTransform = () => ({ props: [] });
6161
6439
 
6162
6440
  exports.generateCodeFrame = shared.generateCodeFrame;
6163
6441
  exports.BASE_TRANSITION = BASE_TRANSITION;
6442
+ exports.BindingTypes = BindingTypes;
6164
6443
  exports.CAMELIZE = CAMELIZE;
6165
6444
  exports.CAPITALIZE = CAPITALIZE;
6166
6445
  exports.CREATE_BLOCK = CREATE_BLOCK;
@@ -6171,6 +6450,10 @@ exports.CREATE_SLOTS = CREATE_SLOTS;
6171
6450
  exports.CREATE_STATIC = CREATE_STATIC;
6172
6451
  exports.CREATE_TEXT = CREATE_TEXT;
6173
6452
  exports.CREATE_VNODE = CREATE_VNODE;
6453
+ exports.CompilerDeprecationTypes = CompilerDeprecationTypes;
6454
+ exports.ConstantTypes = ConstantTypes;
6455
+ exports.ElementTypes = ElementTypes;
6456
+ exports.ErrorCodes = ErrorCodes;
6174
6457
  exports.FRAGMENT = FRAGMENT;
6175
6458
  exports.GUARD_REACTIVE_PROPS = GUARD_REACTIVE_PROPS;
6176
6459
  exports.IS_MEMO_SAME = IS_MEMO_SAME;
@@ -6180,6 +6463,8 @@ exports.MERGE_PROPS = MERGE_PROPS;
6180
6463
  exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
6181
6464
  exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
6182
6465
  exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
6466
+ exports.Namespaces = Namespaces;
6467
+ exports.NodeTypes = NodeTypes;
6183
6468
  exports.OPEN_BLOCK = OPEN_BLOCK;
6184
6469
  exports.POP_SCOPE_ID = POP_SCOPE_ID;
6185
6470
  exports.PUSH_SCOPE_ID = PUSH_SCOPE_ID;