@vue/compiler-sfc 3.4.0-alpha.3 → 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.
@@ -7,8 +7,8 @@ const EMPTY_OBJ = Object.freeze({}) ;
7
7
  const NOOP = () => {
8
8
  };
9
9
  const NO = () => false;
10
- const onRE = /^on[^a-z]/;
11
- const isOn = (key) => onRE.test(key);
10
+ const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
11
+ (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
12
12
  const extend = Object.assign;
13
13
  const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
14
14
  const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
@@ -79,7 +79,7 @@ const slotFlagsText = {
79
79
  [3]: "FORWARDED"
80
80
  };
81
81
 
82
- const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
82
+ const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
83
83
  const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
84
84
 
85
85
  const range = 2;
@@ -374,6 +374,90 @@ function registerRuntimeHelpers(helpers) {
374
374
  });
375
375
  }
376
376
 
377
+ const Namespaces = {
378
+ "HTML": 0,
379
+ "0": "HTML",
380
+ "SVG": 1,
381
+ "1": "SVG",
382
+ "MATH_ML": 2,
383
+ "2": "MATH_ML"
384
+ };
385
+ const NodeTypes = {
386
+ "ROOT": 0,
387
+ "0": "ROOT",
388
+ "ELEMENT": 1,
389
+ "1": "ELEMENT",
390
+ "TEXT": 2,
391
+ "2": "TEXT",
392
+ "COMMENT": 3,
393
+ "3": "COMMENT",
394
+ "SIMPLE_EXPRESSION": 4,
395
+ "4": "SIMPLE_EXPRESSION",
396
+ "INTERPOLATION": 5,
397
+ "5": "INTERPOLATION",
398
+ "ATTRIBUTE": 6,
399
+ "6": "ATTRIBUTE",
400
+ "DIRECTIVE": 7,
401
+ "7": "DIRECTIVE",
402
+ "COMPOUND_EXPRESSION": 8,
403
+ "8": "COMPOUND_EXPRESSION",
404
+ "IF": 9,
405
+ "9": "IF",
406
+ "IF_BRANCH": 10,
407
+ "10": "IF_BRANCH",
408
+ "FOR": 11,
409
+ "11": "FOR",
410
+ "TEXT_CALL": 12,
411
+ "12": "TEXT_CALL",
412
+ "VNODE_CALL": 13,
413
+ "13": "VNODE_CALL",
414
+ "JS_CALL_EXPRESSION": 14,
415
+ "14": "JS_CALL_EXPRESSION",
416
+ "JS_OBJECT_EXPRESSION": 15,
417
+ "15": "JS_OBJECT_EXPRESSION",
418
+ "JS_PROPERTY": 16,
419
+ "16": "JS_PROPERTY",
420
+ "JS_ARRAY_EXPRESSION": 17,
421
+ "17": "JS_ARRAY_EXPRESSION",
422
+ "JS_FUNCTION_EXPRESSION": 18,
423
+ "18": "JS_FUNCTION_EXPRESSION",
424
+ "JS_CONDITIONAL_EXPRESSION": 19,
425
+ "19": "JS_CONDITIONAL_EXPRESSION",
426
+ "JS_CACHE_EXPRESSION": 20,
427
+ "20": "JS_CACHE_EXPRESSION",
428
+ "JS_BLOCK_STATEMENT": 21,
429
+ "21": "JS_BLOCK_STATEMENT",
430
+ "JS_TEMPLATE_LITERAL": 22,
431
+ "22": "JS_TEMPLATE_LITERAL",
432
+ "JS_IF_STATEMENT": 23,
433
+ "23": "JS_IF_STATEMENT",
434
+ "JS_ASSIGNMENT_EXPRESSION": 24,
435
+ "24": "JS_ASSIGNMENT_EXPRESSION",
436
+ "JS_SEQUENCE_EXPRESSION": 25,
437
+ "25": "JS_SEQUENCE_EXPRESSION",
438
+ "JS_RETURN_STATEMENT": 26,
439
+ "26": "JS_RETURN_STATEMENT"
440
+ };
441
+ const ElementTypes = {
442
+ "ELEMENT": 0,
443
+ "0": "ELEMENT",
444
+ "COMPONENT": 1,
445
+ "1": "COMPONENT",
446
+ "SLOT": 2,
447
+ "2": "SLOT",
448
+ "TEMPLATE": 3,
449
+ "3": "TEMPLATE"
450
+ };
451
+ const ConstantTypes = {
452
+ "NOT_CONSTANT": 0,
453
+ "0": "NOT_CONSTANT",
454
+ "CAN_SKIP_PATCH": 1,
455
+ "1": "CAN_SKIP_PATCH",
456
+ "CAN_HOIST": 2,
457
+ "2": "CAN_HOIST",
458
+ "CAN_STRINGIFY": 3,
459
+ "3": "CAN_STRINGIFY"
460
+ };
377
461
  const locStub = {
378
462
  start: { line: 1, column: 1, offset: 0 },
379
463
  end: { line: 1, column: 1, offset: 0 },
@@ -1166,7 +1250,9 @@ let Tokenizer$1 = class Tokenizer {
1166
1250
  this.inRCDATA = false;
1167
1251
  /** For disabling RCDATA tags handling */
1168
1252
  this.inXML = false;
1169
- /** Reocrd newline positions for fast line / column calculation */
1253
+ /** For disabling interpolation parsing in v-pre */
1254
+ this.inVPre = false;
1255
+ /** Record newline positions for fast line / column calculation */
1170
1256
  this.newlines = [];
1171
1257
  this.mode = 0;
1172
1258
  this.delimiterOpen = defaultDelimitersOpen;
@@ -1191,6 +1277,7 @@ let Tokenizer$1 = class Tokenizer {
1191
1277
  this.sectionStart = 0;
1192
1278
  this.index = 0;
1193
1279
  this.baseState = 1;
1280
+ this.inRCDATA = false;
1194
1281
  this.currentSequence = void 0;
1195
1282
  this.newlines.length = 0;
1196
1283
  this.delimiterOpen = defaultDelimitersOpen;
@@ -1231,7 +1318,7 @@ let Tokenizer$1 = class Tokenizer {
1231
1318
  this.sectionStart = this.index;
1232
1319
  } else if (c === 38) {
1233
1320
  this.startEntity();
1234
- } else if (c === this.delimiterOpen[0]) {
1321
+ } else if (!this.inVPre && c === this.delimiterOpen[0]) {
1235
1322
  this.state = 2;
1236
1323
  this.delimiterIndex = 0;
1237
1324
  this.stateInterpolationOpen(c);
@@ -1967,6 +2054,16 @@ let Tokenizer$1 = class Tokenizer {
1967
2054
  }
1968
2055
  };
1969
2056
 
2057
+ const CompilerDeprecationTypes = {
2058
+ "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
2059
+ "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
2060
+ "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
2061
+ "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
2062
+ "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
2063
+ "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
2064
+ "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
2065
+ "COMPILER_FILTERS": "COMPILER_FILTER"
2066
+ };
1970
2067
  const deprecationData = {
1971
2068
  ["COMPILER_IS_ON_ELEMENT"]: {
1972
2069
  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:".`,
@@ -2048,6 +2145,114 @@ function createCompilerError(code, loc, messages, additionalMessage) {
2048
2145
  error.loc = loc;
2049
2146
  return error;
2050
2147
  }
2148
+ const ErrorCodes = {
2149
+ "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
2150
+ "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
2151
+ "CDATA_IN_HTML_CONTENT": 1,
2152
+ "1": "CDATA_IN_HTML_CONTENT",
2153
+ "DUPLICATE_ATTRIBUTE": 2,
2154
+ "2": "DUPLICATE_ATTRIBUTE",
2155
+ "END_TAG_WITH_ATTRIBUTES": 3,
2156
+ "3": "END_TAG_WITH_ATTRIBUTES",
2157
+ "END_TAG_WITH_TRAILING_SOLIDUS": 4,
2158
+ "4": "END_TAG_WITH_TRAILING_SOLIDUS",
2159
+ "EOF_BEFORE_TAG_NAME": 5,
2160
+ "5": "EOF_BEFORE_TAG_NAME",
2161
+ "EOF_IN_CDATA": 6,
2162
+ "6": "EOF_IN_CDATA",
2163
+ "EOF_IN_COMMENT": 7,
2164
+ "7": "EOF_IN_COMMENT",
2165
+ "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
2166
+ "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
2167
+ "EOF_IN_TAG": 9,
2168
+ "9": "EOF_IN_TAG",
2169
+ "INCORRECTLY_CLOSED_COMMENT": 10,
2170
+ "10": "INCORRECTLY_CLOSED_COMMENT",
2171
+ "INCORRECTLY_OPENED_COMMENT": 11,
2172
+ "11": "INCORRECTLY_OPENED_COMMENT",
2173
+ "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
2174
+ "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
2175
+ "MISSING_ATTRIBUTE_VALUE": 13,
2176
+ "13": "MISSING_ATTRIBUTE_VALUE",
2177
+ "MISSING_END_TAG_NAME": 14,
2178
+ "14": "MISSING_END_TAG_NAME",
2179
+ "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
2180
+ "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
2181
+ "NESTED_COMMENT": 16,
2182
+ "16": "NESTED_COMMENT",
2183
+ "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
2184
+ "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
2185
+ "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
2186
+ "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
2187
+ "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
2188
+ "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
2189
+ "UNEXPECTED_NULL_CHARACTER": 20,
2190
+ "20": "UNEXPECTED_NULL_CHARACTER",
2191
+ "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
2192
+ "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
2193
+ "UNEXPECTED_SOLIDUS_IN_TAG": 22,
2194
+ "22": "UNEXPECTED_SOLIDUS_IN_TAG",
2195
+ "X_INVALID_END_TAG": 23,
2196
+ "23": "X_INVALID_END_TAG",
2197
+ "X_MISSING_END_TAG": 24,
2198
+ "24": "X_MISSING_END_TAG",
2199
+ "X_MISSING_INTERPOLATION_END": 25,
2200
+ "25": "X_MISSING_INTERPOLATION_END",
2201
+ "X_MISSING_DIRECTIVE_NAME": 26,
2202
+ "26": "X_MISSING_DIRECTIVE_NAME",
2203
+ "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
2204
+ "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
2205
+ "X_V_IF_NO_EXPRESSION": 28,
2206
+ "28": "X_V_IF_NO_EXPRESSION",
2207
+ "X_V_IF_SAME_KEY": 29,
2208
+ "29": "X_V_IF_SAME_KEY",
2209
+ "X_V_ELSE_NO_ADJACENT_IF": 30,
2210
+ "30": "X_V_ELSE_NO_ADJACENT_IF",
2211
+ "X_V_FOR_NO_EXPRESSION": 31,
2212
+ "31": "X_V_FOR_NO_EXPRESSION",
2213
+ "X_V_FOR_MALFORMED_EXPRESSION": 32,
2214
+ "32": "X_V_FOR_MALFORMED_EXPRESSION",
2215
+ "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
2216
+ "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
2217
+ "X_V_BIND_NO_EXPRESSION": 34,
2218
+ "34": "X_V_BIND_NO_EXPRESSION",
2219
+ "X_V_ON_NO_EXPRESSION": 35,
2220
+ "35": "X_V_ON_NO_EXPRESSION",
2221
+ "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
2222
+ "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
2223
+ "X_V_SLOT_MIXED_SLOT_USAGE": 37,
2224
+ "37": "X_V_SLOT_MIXED_SLOT_USAGE",
2225
+ "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
2226
+ "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
2227
+ "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
2228
+ "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
2229
+ "X_V_SLOT_MISPLACED": 40,
2230
+ "40": "X_V_SLOT_MISPLACED",
2231
+ "X_V_MODEL_NO_EXPRESSION": 41,
2232
+ "41": "X_V_MODEL_NO_EXPRESSION",
2233
+ "X_V_MODEL_MALFORMED_EXPRESSION": 42,
2234
+ "42": "X_V_MODEL_MALFORMED_EXPRESSION",
2235
+ "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
2236
+ "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
2237
+ "X_V_MODEL_ON_PROPS": 44,
2238
+ "44": "X_V_MODEL_ON_PROPS",
2239
+ "X_INVALID_EXPRESSION": 45,
2240
+ "45": "X_INVALID_EXPRESSION",
2241
+ "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
2242
+ "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
2243
+ "X_VNODE_HOOKS": 47,
2244
+ "47": "X_VNODE_HOOKS",
2245
+ "X_PREFIX_ID_NOT_SUPPORTED": 48,
2246
+ "48": "X_PREFIX_ID_NOT_SUPPORTED",
2247
+ "X_MODULE_MODE_NOT_SUPPORTED": 49,
2248
+ "49": "X_MODULE_MODE_NOT_SUPPORTED",
2249
+ "X_CACHE_HANDLER_NOT_SUPPORTED": 50,
2250
+ "50": "X_CACHE_HANDLER_NOT_SUPPORTED",
2251
+ "X_SCOPE_ID_NOT_SUPPORTED": 51,
2252
+ "51": "X_SCOPE_ID_NOT_SUPPORTED",
2253
+ "__EXTEND_POINT__": 52,
2254
+ "52": "__EXTEND_POINT__"
2255
+ };
2051
2256
  const errorMessages = {
2052
2257
  // parse errors
2053
2258
  [0]: "Illegal comment.",
@@ -2100,16 +2305,14 @@ const errorMessages = {
2100
2305
  Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
2101
2306
  [45]: `Error parsing JavaScript expression: `,
2102
2307
  [46]: `<KeepAlive> expects exactly one child component.`,
2308
+ [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.`,
2103
2309
  // generic errors
2104
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
2105
- [48]: `ES module mode is not supported in this build of compiler.`,
2106
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
2107
- [50]: `"scopeId" option is only supported in module mode.`,
2108
- // deprecations
2109
- [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.`,
2110
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
2310
+ [48]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
2311
+ [49]: `ES module mode is not supported in this build of compiler.`,
2312
+ [50]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
2313
+ [51]: `"scopeId" option is only supported in module mode.`,
2111
2314
  // just to fulfill types
2112
- [53]: ``
2315
+ [52]: ``
2113
2316
  };
2114
2317
 
2115
2318
  function getDefaultExportFromCjs (x) {
@@ -16918,7 +17121,8 @@ const defaultParserOptions = {
16918
17121
  isCustomElement: NO,
16919
17122
  onError: defaultOnError,
16920
17123
  onWarn: defaultOnWarn,
16921
- comments: true
17124
+ comments: true,
17125
+ prefixIdentifiers: false
16922
17126
  };
16923
17127
  let currentOptions = defaultParserOptions;
16924
17128
  let currentRoot = null;
@@ -16960,7 +17164,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
16960
17164
  }
16961
17165
  addNode({
16962
17166
  type: 5,
16963
- content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
17167
+ content: createExp(exp, false, getLoc(innerStart, innerEnd)),
16964
17168
  loc: getLoc(start, end)
16965
17169
  });
16966
17170
  },
@@ -17053,7 +17257,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
17053
17257
  loc: getLoc(start)
17054
17258
  };
17055
17259
  if (name === "pre") {
17056
- inVPre = true;
17260
+ inVPre = tokenizer$2.inVPre = true;
17057
17261
  currentVPreBoundary = currentOpenTag;
17058
17262
  const props = currentOpenTag.props;
17059
17263
  for (let i = 0; i < props.length; i++) {
@@ -17073,7 +17277,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
17073
17277
  setLocEnd(currentProp.nameLoc, end);
17074
17278
  } else {
17075
17279
  const isStatic = arg[0] !== `[`;
17076
- currentProp.arg = createSimpleExpression(
17280
+ currentProp.arg = createExp(
17077
17281
  isStatic ? arg : arg.slice(1, -1),
17078
17282
  isStatic,
17079
17283
  getLoc(start, end),
@@ -17140,10 +17344,22 @@ const tokenizer$2 = new Tokenizer$1(stack, {
17140
17344
  tokenizer$2.enterRCDATA(toCharCodes(`</template`), 0);
17141
17345
  }
17142
17346
  } else {
17143
- currentProp.exp = createSimpleExpression(
17347
+ let expParseMode = 0 /* Normal */;
17348
+ {
17349
+ if (currentProp.name === "for") {
17350
+ expParseMode = 3 /* Skip */;
17351
+ } else if (currentProp.name === "slot") {
17352
+ expParseMode = 1 /* Params */;
17353
+ } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
17354
+ expParseMode = 2 /* Statements */;
17355
+ }
17356
+ }
17357
+ currentProp.exp = createExp(
17144
17358
  currentAttrValue,
17145
17359
  false,
17146
- getLoc(currentAttrStartIndex, currentAttrEndIndex)
17360
+ getLoc(currentAttrStartIndex, currentAttrEndIndex),
17361
+ 0,
17362
+ expParseMode
17147
17363
  );
17148
17364
  if (currentProp.name === "for") {
17149
17365
  currentProp.forParseResult = parseForExpression(currentProp.exp);
@@ -17236,10 +17452,16 @@ function parseForExpression(input) {
17236
17452
  if (!inMatch)
17237
17453
  return;
17238
17454
  const [, LHS, RHS] = inMatch;
17239
- const createAliasExpression = (content, offset) => {
17455
+ const createAliasExpression = (content, offset, asParam = false) => {
17240
17456
  const start = loc.start.offset + offset;
17241
17457
  const end = start + content.length;
17242
- return createSimpleExpression(content, false, getLoc(start, end));
17458
+ return createExp(
17459
+ content,
17460
+ false,
17461
+ getLoc(start, end),
17462
+ 0,
17463
+ asParam ? 1 /* Params */ : 0 /* Normal */
17464
+ );
17243
17465
  };
17244
17466
  const result = {
17245
17467
  source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
@@ -17257,7 +17479,7 @@ function parseForExpression(input) {
17257
17479
  let keyOffset;
17258
17480
  if (keyContent) {
17259
17481
  keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
17260
- result.key = createAliasExpression(keyContent, keyOffset);
17482
+ result.key = createAliasExpression(keyContent, keyOffset, true);
17261
17483
  }
17262
17484
  if (iteratorMatch[2]) {
17263
17485
  const indexContent = iteratorMatch[2].trim();
@@ -17267,13 +17489,14 @@ function parseForExpression(input) {
17267
17489
  exp.indexOf(
17268
17490
  indexContent,
17269
17491
  result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
17270
- )
17492
+ ),
17493
+ true
17271
17494
  );
17272
17495
  }
17273
17496
  }
17274
17497
  }
17275
17498
  if (valueContent) {
17276
- result.value = createAliasExpression(valueContent, trimmedOffset);
17499
+ result.value = createAliasExpression(valueContent, trimmedOffset, true);
17277
17500
  }
17278
17501
  return result;
17279
17502
  }
@@ -17344,7 +17567,7 @@ function onCloseTag(el, end, isImplied = false) {
17344
17567
  inPre--;
17345
17568
  }
17346
17569
  if (currentVPreBoundary === el) {
17347
- inVPre = false;
17570
+ inVPre = tokenizer$2.inVPre = false;
17348
17571
  currentVPreBoundary = null;
17349
17572
  }
17350
17573
  if (tokenizer$2.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
@@ -17508,8 +17731,36 @@ function dirToAttr(dir) {
17508
17731
  }
17509
17732
  return attr;
17510
17733
  }
17511
- function emitError(code, index) {
17512
- currentOptions.onError(createCompilerError(code, getLoc(index, index)));
17734
+ function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
17735
+ const exp = createSimpleExpression(content, isStatic, loc, constType);
17736
+ if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
17737
+ if (isSimpleIdentifier(content)) {
17738
+ exp.ast = null;
17739
+ return exp;
17740
+ }
17741
+ try {
17742
+ const plugins = currentOptions.expressionPlugins;
17743
+ const options = {
17744
+ plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
17745
+ };
17746
+ if (parseMode === 2 /* Statements */) {
17747
+ exp.ast = parse_1$1(` ${content} `, options).program;
17748
+ } else if (parseMode === 1 /* Params */) {
17749
+ exp.ast = parseExpression_1(`(${content})=>{}`, options);
17750
+ } else {
17751
+ exp.ast = parseExpression_1(`(${content})`, options);
17752
+ }
17753
+ } catch (e) {
17754
+ exp.ast = false;
17755
+ emitError(45, loc.start.offset, e.message);
17756
+ }
17757
+ }
17758
+ return exp;
17759
+ }
17760
+ function emitError(code, index, message) {
17761
+ currentOptions.onError(
17762
+ createCompilerError(code, getLoc(index, index), void 0, message)
17763
+ );
17513
17764
  }
17514
17765
  function reset() {
17515
17766
  tokenizer$2.reset();
@@ -17540,6 +17791,7 @@ function baseParse(input, options) {
17540
17791
  }
17541
17792
  }
17542
17793
  tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
17794
+ tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
17543
17795
  const delimiters = options == null ? void 0 : options.delimiters;
17544
17796
  if (delimiters) {
17545
17797
  tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
@@ -22405,7 +22657,7 @@ function walk$1(ast, { enter, leave }) {
22405
22657
  }
22406
22658
 
22407
22659
  function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
22408
- const rootExp = root.type === "Program" && root.body[0].type === "ExpressionStatement" && root.body[0].expression;
22660
+ const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
22409
22661
  walk$1(root, {
22410
22662
  enter(node, parent) {
22411
22663
  parent && parentStack.push(parent);
@@ -22478,7 +22730,7 @@ function isInDestructureAssignment(parent, parentStack) {
22478
22730
  }
22479
22731
  function walkFunctionParams(node, onIdent) {
22480
22732
  for (const p of node.params) {
22481
- for (const id of extractIdentifiers(p)) {
22733
+ for (const id of extractIdentifiers$1(p)) {
22482
22734
  onIdent(id);
22483
22735
  }
22484
22736
  }
@@ -22489,7 +22741,7 @@ function walkBlockDeclarations(block, onIdent) {
22489
22741
  if (stmt.declare)
22490
22742
  continue;
22491
22743
  for (const decl of stmt.declarations) {
22492
- for (const id of extractIdentifiers(decl.id)) {
22744
+ for (const id of extractIdentifiers$1(decl.id)) {
22493
22745
  onIdent(id);
22494
22746
  }
22495
22747
  }
@@ -22501,7 +22753,7 @@ function walkBlockDeclarations(block, onIdent) {
22501
22753
  const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
22502
22754
  if (variable && variable.type === "VariableDeclaration") {
22503
22755
  for (const decl of variable.declarations) {
22504
- for (const id of extractIdentifiers(decl.id)) {
22756
+ for (const id of extractIdentifiers$1(decl.id)) {
22505
22757
  onIdent(id);
22506
22758
  }
22507
22759
  }
@@ -22509,7 +22761,7 @@ function walkBlockDeclarations(block, onIdent) {
22509
22761
  }
22510
22762
  }
22511
22763
  }
22512
- function extractIdentifiers(param, nodes = []) {
22764
+ function extractIdentifiers$1(param, nodes = []) {
22513
22765
  switch (param.type) {
22514
22766
  case "Identifier":
22515
22767
  nodes.push(param);
@@ -22524,23 +22776,23 @@ function extractIdentifiers(param, nodes = []) {
22524
22776
  case "ObjectPattern":
22525
22777
  for (const prop of param.properties) {
22526
22778
  if (prop.type === "RestElement") {
22527
- extractIdentifiers(prop.argument, nodes);
22779
+ extractIdentifiers$1(prop.argument, nodes);
22528
22780
  } else {
22529
- extractIdentifiers(prop.value, nodes);
22781
+ extractIdentifiers$1(prop.value, nodes);
22530
22782
  }
22531
22783
  }
22532
22784
  break;
22533
22785
  case "ArrayPattern":
22534
22786
  param.elements.forEach((element) => {
22535
22787
  if (element)
22536
- extractIdentifiers(element, nodes);
22788
+ extractIdentifiers$1(element, nodes);
22537
22789
  });
22538
22790
  break;
22539
22791
  case "RestElement":
22540
- extractIdentifiers(param.argument, nodes);
22792
+ extractIdentifiers$1(param.argument, nodes);
22541
22793
  break;
22542
22794
  case "AssignmentPattern":
22543
- extractIdentifiers(param.left, nodes);
22795
+ extractIdentifiers$1(param.left, nodes);
22544
22796
  break;
22545
22797
  }
22546
22798
  return nodes;
@@ -22754,7 +23006,11 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22754
23006
  };
22755
23007
  const rawExp = node.content;
22756
23008
  const bailConstant = constantBailRE.test(rawExp);
22757
- if (isSimpleIdentifier(rawExp)) {
23009
+ let ast = node.ast;
23010
+ if (ast === false) {
23011
+ return node;
23012
+ }
23013
+ if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
22758
23014
  const isScopeVarReference = context.identifiers[rawExp];
22759
23015
  const isAllowedGlobal = isGloballyAllowed(rawExp);
22760
23016
  const isLiteral = isLiteralWhitelisted(rawExp);
@@ -22772,22 +23028,23 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22772
23028
  }
22773
23029
  return node;
22774
23030
  }
22775
- let ast;
22776
- const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
22777
- try {
22778
- ast = parse_1$1(source, {
22779
- plugins: context.expressionPlugins
22780
- }).program;
22781
- } catch (e) {
22782
- context.onError(
22783
- createCompilerError(
22784
- 45,
22785
- node.loc,
22786
- void 0,
22787
- e.message
22788
- )
22789
- );
22790
- return node;
23031
+ if (!ast) {
23032
+ const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
23033
+ try {
23034
+ ast = parse_1$1(source, {
23035
+ plugins: context.expressionPlugins
23036
+ }).program;
23037
+ } catch (e) {
23038
+ context.onError(
23039
+ createCompilerError(
23040
+ 45,
23041
+ node.loc,
23042
+ void 0,
23043
+ e.message
23044
+ )
23045
+ );
23046
+ return node;
23047
+ }
22791
23048
  }
22792
23049
  const ids = [];
22793
23050
  const parentStack = [];
@@ -22827,15 +23084,15 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22827
23084
  if (leadingText.length || id.prefix) {
22828
23085
  children.push(leadingText + (id.prefix || ``));
22829
23086
  }
22830
- const source2 = rawExp.slice(start, end);
23087
+ const source = rawExp.slice(start, end);
22831
23088
  children.push(
22832
23089
  createSimpleExpression(
22833
23090
  id.name,
22834
23091
  false,
22835
23092
  {
22836
- start: advancePositionWithClone(node.loc.start, source2, start),
22837
- end: advancePositionWithClone(node.loc.start, source2, end),
22838
- source: source2
23093
+ start: advancePositionWithClone(node.loc.start, source, start),
23094
+ end: advancePositionWithClone(node.loc.start, source, end),
23095
+ source
22839
23096
  },
22840
23097
  id.isConstant ? 3 : 0
22841
23098
  )
@@ -22847,6 +23104,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22847
23104
  let ret;
22848
23105
  if (children.length) {
22849
23106
  ret = createCompoundExpression(children, node.loc);
23107
+ ret.ast = ast;
22850
23108
  } else {
22851
23109
  ret = node;
22852
23110
  ret.constType = bailConstant ? 0 : 3;
@@ -23800,6 +24058,10 @@ function resolveSetupReference(name, context) {
23800
24058
  `${context.helperString(UNREF)}(${fromMaybeRef})`
23801
24059
  ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
23802
24060
  }
24061
+ const fromProps = checkType("props");
24062
+ if (fromProps) {
24063
+ return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
24064
+ }
23803
24065
  }
23804
24066
  function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
23805
24067
  const { tag, loc: elementLoc, children } = node;
@@ -23840,6 +24102,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
23840
24102
  if (isEventHandler && isReservedProp(name)) {
23841
24103
  hasVnodeHook = true;
23842
24104
  }
24105
+ if (isEventHandler && value.type === 14) {
24106
+ value = value.arguments[0];
24107
+ }
23843
24108
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
23844
24109
  return;
23845
24110
  }
@@ -24271,9 +24536,7 @@ const transformOn$1 = (dir, node, context, augmentor) => {
24271
24536
  if (arg.isStatic) {
24272
24537
  let rawName = arg.content;
24273
24538
  if (rawName.startsWith("vnode")) {
24274
- context.onWarn(
24275
- createCompilerError(51, arg.loc)
24276
- );
24539
+ context.onError(createCompilerError(47, arg.loc));
24277
24540
  }
24278
24541
  if (rawName.startsWith("vue:")) {
24279
24542
  rawName = `vnode-${rawName.slice(4)}`;
@@ -24660,10 +24923,10 @@ function baseCompile(source, options = {}) {
24660
24923
  const isModuleMode = options.mode === "module";
24661
24924
  const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
24662
24925
  if (!prefixIdentifiers && options.cacheHandlers) {
24663
- onError(createCompilerError(49));
24926
+ onError(createCompilerError(50));
24664
24927
  }
24665
24928
  if (options.scopeId && !isModuleMode) {
24666
- onError(createCompilerError(50));
24929
+ onError(createCompilerError(51));
24667
24930
  }
24668
24931
  const ast = isString$2(source) ? baseParse(source, options) : source;
24669
24932
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -24698,6 +24961,19 @@ function baseCompile(source, options = {}) {
24698
24961
  );
24699
24962
  }
24700
24963
 
24964
+ const BindingTypes = {
24965
+ "DATA": "data",
24966
+ "PROPS": "props",
24967
+ "PROPS_ALIASED": "props-aliased",
24968
+ "SETUP_LET": "setup-let",
24969
+ "SETUP_CONST": "setup-const",
24970
+ "SETUP_REACTIVE_CONST": "setup-reactive-const",
24971
+ "SETUP_MAYBE_REF": "setup-maybe-ref",
24972
+ "SETUP_REF": "setup-ref",
24973
+ "OPTIONS": "options",
24974
+ "LITERAL_CONST": "literal-const"
24975
+ };
24976
+
24701
24977
  const noopDirectiveTransform = () => ({ props: [] });
24702
24978
 
24703
24979
  const V_MODEL_RADIO = Symbol(`vModelRadio` );
@@ -24802,6 +25078,32 @@ function createDOMCompilerError(code, loc) {
24802
25078
  DOMErrorMessages
24803
25079
  );
24804
25080
  }
25081
+ const DOMErrorCodes = {
25082
+ "X_V_HTML_NO_EXPRESSION": 53,
25083
+ "53": "X_V_HTML_NO_EXPRESSION",
25084
+ "X_V_HTML_WITH_CHILDREN": 54,
25085
+ "54": "X_V_HTML_WITH_CHILDREN",
25086
+ "X_V_TEXT_NO_EXPRESSION": 55,
25087
+ "55": "X_V_TEXT_NO_EXPRESSION",
25088
+ "X_V_TEXT_WITH_CHILDREN": 56,
25089
+ "56": "X_V_TEXT_WITH_CHILDREN",
25090
+ "X_V_MODEL_ON_INVALID_ELEMENT": 57,
25091
+ "57": "X_V_MODEL_ON_INVALID_ELEMENT",
25092
+ "X_V_MODEL_ARG_ON_ELEMENT": 58,
25093
+ "58": "X_V_MODEL_ARG_ON_ELEMENT",
25094
+ "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
25095
+ "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
25096
+ "X_V_MODEL_UNNECESSARY_VALUE": 60,
25097
+ "60": "X_V_MODEL_UNNECESSARY_VALUE",
25098
+ "X_V_SHOW_NO_EXPRESSION": 61,
25099
+ "61": "X_V_SHOW_NO_EXPRESSION",
25100
+ "X_TRANSITION_INVALID_CHILDREN": 62,
25101
+ "62": "X_TRANSITION_INVALID_CHILDREN",
25102
+ "X_IGNORED_SIDE_EFFECT_TAG": 63,
25103
+ "63": "X_IGNORED_SIDE_EFFECT_TAG",
25104
+ "__EXTEND_POINT__": 64,
25105
+ "64": "__EXTEND_POINT__"
25106
+ };
24805
25107
  const DOMErrorMessages = {
24806
25108
  [53]: `v-html is missing expression.`,
24807
25109
  [54]: `v-html will override element children.`,
@@ -25364,6 +25666,7 @@ function parse$8(template, options = {}) {
25364
25666
  var CompilerDOM = /*#__PURE__*/Object.freeze({
25365
25667
  __proto__: null,
25366
25668
  BASE_TRANSITION: BASE_TRANSITION,
25669
+ BindingTypes: BindingTypes,
25367
25670
  CAMELIZE: CAMELIZE,
25368
25671
  CAPITALIZE: CAPITALIZE,
25369
25672
  CREATE_BLOCK: CREATE_BLOCK,
@@ -25374,9 +25677,14 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
25374
25677
  CREATE_STATIC: CREATE_STATIC,
25375
25678
  CREATE_TEXT: CREATE_TEXT,
25376
25679
  CREATE_VNODE: CREATE_VNODE,
25680
+ CompilerDeprecationTypes: CompilerDeprecationTypes,
25681
+ ConstantTypes: ConstantTypes,
25377
25682
  DOMDirectiveTransforms: DOMDirectiveTransforms,
25683
+ DOMErrorCodes: DOMErrorCodes,
25378
25684
  DOMErrorMessages: DOMErrorMessages,
25379
25685
  DOMNodeTransforms: DOMNodeTransforms,
25686
+ ElementTypes: ElementTypes,
25687
+ ErrorCodes: ErrorCodes,
25380
25688
  FRAGMENT: FRAGMENT,
25381
25689
  GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
25382
25690
  IS_MEMO_SAME: IS_MEMO_SAME,
@@ -25386,6 +25694,8 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
25386
25694
  NORMALIZE_CLASS: NORMALIZE_CLASS,
25387
25695
  NORMALIZE_PROPS: NORMALIZE_PROPS,
25388
25696
  NORMALIZE_STYLE: NORMALIZE_STYLE,
25697
+ Namespaces: Namespaces,
25698
+ NodeTypes: NodeTypes,
25389
25699
  OPEN_BLOCK: OPEN_BLOCK,
25390
25700
  POP_SCOPE_ID: POP_SCOPE_ID,
25391
25701
  PUSH_SCOPE_ID: PUSH_SCOPE_ID,
@@ -25451,7 +25761,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
25451
25761
  createTransformContext: createTransformContext,
25452
25762
  createVNodeCall: createVNodeCall,
25453
25763
  errorMessages: errorMessages,
25454
- extractIdentifiers: extractIdentifiers,
25764
+ extractIdentifiers: extractIdentifiers$1,
25455
25765
  findDir: findDir,
25456
25766
  findProp: findProp,
25457
25767
  forAliasRE: forAliasRE,
@@ -25810,8 +26120,11 @@ function getEscapedPropName(key) {
25810
26120
  return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
25811
26121
  }
25812
26122
  const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
25813
- function getEscapedCssVarName(key) {
25814
- return key.replace(cssVarNameEscapeSymbolsRE, (s) => `\\${s}`);
26123
+ function getEscapedCssVarName(key, doubleEscape) {
26124
+ return key.replace(
26125
+ cssVarNameEscapeSymbolsRE,
26126
+ (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
26127
+ );
25815
26128
  }
25816
26129
 
25817
26130
  function pad$1 (hash, len) {
@@ -25888,15 +26201,15 @@ const CSS_VARS_HELPER = `useCssVars`;
25888
26201
  function genCssVarsFromList(vars, id, isProd, isSSR = false) {
25889
26202
  return `{
25890
26203
  ${vars.map(
25891
- (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
26204
+ (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
25892
26205
  ).join(",\n ")}
25893
26206
  }`;
25894
26207
  }
25895
- function genVarName(id, raw, isProd) {
26208
+ function genVarName(id, raw, isProd, isSSR = false) {
25896
26209
  if (isProd) {
25897
26210
  return hash(id + raw);
25898
26211
  } else {
25899
- return `${id}-${getEscapedCssVarName(raw)}`;
26212
+ return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
25900
26213
  }
25901
26214
  }
25902
26215
  function normalizeExpression(exp) {
@@ -26250,11 +26563,7 @@ function createCache(max = 500) {
26250
26563
  }
26251
26564
 
26252
26565
  function isImportUsed(local, sfc) {
26253
- return new RegExp(
26254
- // #4274 escape $ since it's a special char in regex
26255
- // (and is the only regex special char that is valid in identifiers)
26256
- `[^\\w$_]${local.replace(/\$/g, "\\$")}[^\\w$_]`
26257
- ).test(resolveTemplateUsageCheckString(sfc));
26566
+ return resolveTemplateUsageCheckString(sfc).has(local);
26258
26567
  }
26259
26568
  const templateUsageCheckCache = createCache();
26260
26569
  function resolveTemplateUsageCheckString(sfc) {
@@ -26263,80 +26572,51 @@ function resolveTemplateUsageCheckString(sfc) {
26263
26572
  if (cached) {
26264
26573
  return cached;
26265
26574
  }
26266
- let code = "";
26575
+ const ids = /* @__PURE__ */ new Set();
26267
26576
  ast.children.forEach(walk);
26268
26577
  function walk(node) {
26269
26578
  var _a;
26270
26579
  switch (node.type) {
26271
26580
  case 1:
26272
26581
  if (!parserOptions.isNativeTag(node.tag) && !parserOptions.isBuiltInComponent(node.tag)) {
26273
- code += `,${camelize(node.tag)},${capitalize$1(camelize(node.tag))}`;
26582
+ ids.add(camelize(node.tag));
26583
+ ids.add(capitalize$1(camelize(node.tag)));
26274
26584
  }
26275
26585
  for (let i = 0; i < node.props.length; i++) {
26276
26586
  const prop = node.props[i];
26277
26587
  if (prop.type === 7) {
26278
26588
  if (!isBuiltInDirective(prop.name)) {
26279
- code += `,v${capitalize$1(camelize(prop.name))}`;
26589
+ ids.add(`v${capitalize$1(camelize(prop.name))}`);
26280
26590
  }
26281
26591
  if (prop.arg && !prop.arg.isStatic) {
26282
- code += `,${stripStrings(
26283
- prop.arg.content
26284
- )}`;
26592
+ extractIdentifiers(ids, prop.arg);
26285
26593
  }
26286
- if (prop.exp) {
26287
- code += `,${processExp(
26288
- prop.exp.content,
26289
- prop.name
26290
- )}`;
26594
+ if (prop.name === "for") {
26595
+ extractIdentifiers(ids, prop.forParseResult.source);
26596
+ } else if (prop.exp) {
26597
+ extractIdentifiers(ids, prop.exp);
26291
26598
  }
26292
26599
  }
26293
26600
  if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
26294
- code += `,${prop.value.content}`;
26601
+ ids.add(prop.value.content);
26295
26602
  }
26296
26603
  }
26297
26604
  node.children.forEach(walk);
26298
26605
  break;
26299
26606
  case 5:
26300
- code += `,${processExp(node.content.content)}`;
26607
+ extractIdentifiers(ids, node.content);
26301
26608
  break;
26302
26609
  }
26303
26610
  }
26304
- code += ";";
26305
- templateUsageCheckCache.set(content, code);
26306
- return code;
26611
+ templateUsageCheckCache.set(content, ids);
26612
+ return ids;
26307
26613
  }
26308
- function processExp(exp, dir) {
26309
- if (/ as\s+\w|<.*>|:/.test(exp)) {
26310
- if (dir === "slot") {
26311
- exp = `(${exp})=>{}`;
26312
- } else if (dir === "on") {
26313
- exp = `()=>{return ${exp}}`;
26314
- } else if (dir === "for") {
26315
- const inMatch = exp.match(forAliasRE);
26316
- if (inMatch) {
26317
- let [, LHS, RHS] = inMatch;
26318
- LHS = LHS.trim().replace(/^\(|\)$/g, "");
26319
- return processExp(`(${LHS})=>{}`) + processExp(RHS);
26320
- }
26321
- }
26322
- let ret = "";
26323
- const ast = parseExpression_1(exp, { plugins: ["typescript"] });
26324
- walkIdentifiers(ast, (node) => {
26325
- ret += `,` + node.name;
26326
- });
26327
- return ret;
26614
+ function extractIdentifiers(ids, node) {
26615
+ if (node.ast) {
26616
+ walkIdentifiers(node.ast, (n) => ids.add(n.name));
26617
+ } else if (node.ast === null) {
26618
+ ids.add(node.content);
26328
26619
  }
26329
- return stripStrings(exp);
26330
- }
26331
- function stripStrings(exp) {
26332
- return exp.replace(/'[^']*'|"[^"]*"/g, "").replace(/`[^`]+`/g, stripTemplateString);
26333
- }
26334
- function stripTemplateString(str) {
26335
- const interpMatch = str.match(/\${[^}]+}/g);
26336
- if (interpMatch) {
26337
- return interpMatch.map((m) => m.slice(2, -1)).join(",");
26338
- }
26339
- return "";
26340
26620
  }
26341
26621
 
26342
26622
  const DEFAULT_FILENAME = "anonymous.vue";
@@ -26347,7 +26627,8 @@ function parse$7(source, {
26347
26627
  sourceRoot = "",
26348
26628
  pad = false,
26349
26629
  ignoreEmpty = true,
26350
- compiler = CompilerDOM
26630
+ compiler = CompilerDOM,
26631
+ parseExpressions = true
26351
26632
  } = {}) {
26352
26633
  const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
26353
26634
  const cache = parseCache$1.get(sourceKey);
@@ -26369,6 +26650,7 @@ function parse$7(source, {
26369
26650
  const errors = [];
26370
26651
  const ast = compiler.parse(source, {
26371
26652
  parseMode: "sfc",
26653
+ prefixIdentifiers: parseExpressions,
26372
26654
  onError: (e) => {
26373
26655
  errors.push(e);
26374
26656
  }
@@ -26458,22 +26740,29 @@ function parse$7(source, {
26458
26740
  descriptor.script = null;
26459
26741
  }
26460
26742
  }
26743
+ let templateColumnOffset = 0;
26744
+ if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
26745
+ [descriptor.template.content, templateColumnOffset] = dedent(
26746
+ descriptor.template.content
26747
+ );
26748
+ }
26461
26749
  if (sourceMap) {
26462
- const genMap = (block) => {
26750
+ const genMap = (block, columnOffset = 0) => {
26463
26751
  if (block && !block.src) {
26464
26752
  block.map = generateSourceMap(
26465
26753
  filename,
26466
26754
  source,
26467
26755
  block.content,
26468
26756
  sourceRoot,
26469
- !pad || block.type === "template" ? block.loc.start.line - 1 : 0
26757
+ !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
26758
+ columnOffset
26470
26759
  );
26471
26760
  }
26472
26761
  };
26473
- genMap(descriptor.template);
26762
+ genMap(descriptor.template, templateColumnOffset);
26474
26763
  genMap(descriptor.script);
26475
- descriptor.styles.forEach(genMap);
26476
- descriptor.customBlocks.forEach(genMap);
26764
+ descriptor.styles.forEach((s) => genMap(s));
26765
+ descriptor.customBlocks.forEach((s) => genMap(s));
26477
26766
  }
26478
26767
  descriptor.cssVars = parseCssVars(descriptor);
26479
26768
  const slottedRE = /(?:::v-|:)slotted\(/;
@@ -26531,7 +26820,7 @@ function createBlock(node, source, pad) {
26531
26820
  const splitRE = /\r?\n/g;
26532
26821
  const emptyRE = /^(?:\/\/)?\s*$/;
26533
26822
  const replaceRE = /./g;
26534
- function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
26823
+ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
26535
26824
  const map = new SourceMapGenerator$6({
26536
26825
  file: filename.replace(/\\/g, "/"),
26537
26826
  sourceRoot: sourceRoot.replace(/\\/g, "/")
@@ -26546,7 +26835,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
26546
26835
  if (!/\s/.test(line[i])) {
26547
26836
  map._mappings.add({
26548
26837
  originalLine,
26549
- originalColumn: i,
26838
+ originalColumn: i + columnOffset,
26550
26839
  generatedLine,
26551
26840
  generatedColumn: i,
26552
26841
  source: filename,
@@ -26597,6 +26886,26 @@ function hmrShouldReload(prevImports, next) {
26597
26886
  }
26598
26887
  return false;
26599
26888
  }
26889
+ function dedent(s) {
26890
+ const lines = s.split("\n");
26891
+ const minIndent = lines.reduce(function(minIndent2, line) {
26892
+ var _a, _b;
26893
+ if (line.trim() === "") {
26894
+ return minIndent2;
26895
+ }
26896
+ const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
26897
+ return Math.min(indent, minIndent2);
26898
+ }, Infinity);
26899
+ if (minIndent === 0) {
26900
+ return [s, minIndent];
26901
+ }
26902
+ return [
26903
+ lines.map(function(line) {
26904
+ return line.slice(minIndent);
26905
+ }).join("\n"),
26906
+ minIndent
26907
+ ];
26908
+ }
26600
26909
 
26601
26910
  /*! https://mths.be/punycode v1.4.1 by @mathias */
26602
26911
 
@@ -32144,7 +32453,7 @@ var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
32144
32453
 
32145
32454
  var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
32146
32455
 
32147
- var require$$2$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
32456
+ var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
32148
32457
 
32149
32458
  var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
32150
32459
 
@@ -33714,7 +34023,7 @@ var nonSecure = { nanoid: nanoid$1, customAlphabet };
33714
34023
 
33715
34024
  let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
33716
34025
  let { existsSync, readFileSync } = require$$0$2;
33717
- let { dirname: dirname$1, join } = require$$2$1;
34026
+ let { dirname: dirname$1, join } = require$$1;
33718
34027
 
33719
34028
  function fromBase64(str) {
33720
34029
  if (Buffer$1) {
@@ -33855,7 +34164,7 @@ PreviousMap$2.default = PreviousMap$2;
33855
34164
 
33856
34165
  let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
33857
34166
  let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
33858
- let { isAbsolute, resolve: resolve$1 } = require$$2$1;
34167
+ let { isAbsolute, resolve: resolve$1 } = require$$1;
33859
34168
  let { nanoid } = nonSecure;
33860
34169
 
33861
34170
  let terminalHighlight = terminalHighlight_1;
@@ -34101,7 +34410,7 @@ if (terminalHighlight && terminalHighlight.registerInput) {
34101
34410
  }
34102
34411
 
34103
34412
  let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
34104
- let { dirname, relative, resolve, sep } = require$$2$1;
34413
+ let { dirname, relative, resolve, sep } = require$$1;
34105
34414
  let { pathToFileURL } = require$$2;
34106
34415
 
34107
34416
  let Input$3 = input;
@@ -36536,7 +36845,7 @@ let Root$2 = root$2;
36536
36845
 
36537
36846
  let Processor$1 = class Processor {
36538
36847
  constructor(plugins = []) {
36539
- this.version = '8.4.31';
36848
+ this.version = '8.4.32';
36540
36849
  this.plugins = this.normalize(plugins);
36541
36850
  }
36542
36851
 
@@ -40328,14 +40637,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
40328
40637
  return false;
40329
40638
  }
40330
40639
  }
40331
- if (n.type !== "pseudo" && n.type !== "combinator") {
40640
+ if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
40332
40641
  node = n;
40333
40642
  }
40334
- if (n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
40335
- rewriteSelector(id, n.nodes[0], selectorRoot, slotted);
40643
+ });
40644
+ if (node) {
40645
+ const { type, value } = node;
40646
+ if (type === "pseudo" && (value === ":is" || value === ":where")) {
40647
+ node.nodes.forEach(
40648
+ (value2) => rewriteSelector(id, value2, selectorRoot, slotted)
40649
+ );
40336
40650
  shouldInject = false;
40337
40651
  }
40338
- });
40652
+ }
40339
40653
  if (node) {
40340
40654
  node.spaces.after = "";
40341
40655
  } else {
@@ -45495,33 +45809,39 @@ class TypeScope {
45495
45809
  this.exportedDeclares = /* @__PURE__ */ Object.create(null);
45496
45810
  }
45497
45811
  }
45498
- function resolveTypeElements(ctx, node, scope) {
45812
+ function resolveTypeElements(ctx, node, scope, typeParameters) {
45499
45813
  if (node._resolvedElements) {
45500
45814
  return node._resolvedElements;
45501
45815
  }
45502
45816
  return node._resolvedElements = innerResolveTypeElements(
45503
45817
  ctx,
45504
45818
  node,
45505
- node._ownerScope || scope || ctxToScope(ctx)
45819
+ node._ownerScope || scope || ctxToScope(ctx),
45820
+ typeParameters
45506
45821
  );
45507
45822
  }
45508
- function innerResolveTypeElements(ctx, node, scope) {
45823
+ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
45509
45824
  var _a, _b;
45510
45825
  switch (node.type) {
45511
45826
  case "TSTypeLiteral":
45512
- return typeElementsToMap(ctx, node.members, scope);
45827
+ return typeElementsToMap(ctx, node.members, scope, typeParameters);
45513
45828
  case "TSInterfaceDeclaration":
45514
- return resolveInterfaceMembers(ctx, node, scope);
45829
+ return resolveInterfaceMembers(ctx, node, scope, typeParameters);
45515
45830
  case "TSTypeAliasDeclaration":
45516
45831
  case "TSParenthesizedType":
45517
- return resolveTypeElements(ctx, node.typeAnnotation, scope);
45832
+ return resolveTypeElements(
45833
+ ctx,
45834
+ node.typeAnnotation,
45835
+ scope,
45836
+ typeParameters
45837
+ );
45518
45838
  case "TSFunctionType": {
45519
45839
  return { props: {}, calls: [node] };
45520
45840
  }
45521
45841
  case "TSUnionType":
45522
45842
  case "TSIntersectionType":
45523
45843
  return mergeElements(
45524
- node.types.map((t) => resolveTypeElements(ctx, t, scope)),
45844
+ node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
45525
45845
  node.type
45526
45846
  );
45527
45847
  case "TSMappedType":
@@ -45538,20 +45858,53 @@ function innerResolveTypeElements(ctx, node, scope) {
45538
45858
  const typeName = getReferenceName(node);
45539
45859
  if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
45540
45860
  return resolveExtractPropTypes(
45541
- resolveTypeElements(ctx, node.typeParameters.params[0], scope),
45861
+ resolveTypeElements(
45862
+ ctx,
45863
+ node.typeParameters.params[0],
45864
+ scope,
45865
+ typeParameters
45866
+ ),
45542
45867
  scope
45543
45868
  );
45544
45869
  }
45545
45870
  const resolved = resolveTypeReference(ctx, node, scope);
45546
45871
  if (resolved) {
45547
- return resolveTypeElements(ctx, resolved, resolved._ownerScope);
45872
+ const typeParams = /* @__PURE__ */ Object.create(null);
45873
+ if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
45874
+ resolved.typeParameters.params.forEach((p, i) => {
45875
+ let param = typeParameters && typeParameters[p.name];
45876
+ if (!param)
45877
+ param = node.typeParameters.params[i];
45878
+ typeParams[p.name] = param;
45879
+ });
45880
+ }
45881
+ return resolveTypeElements(
45882
+ ctx,
45883
+ resolved,
45884
+ resolved._ownerScope,
45885
+ typeParams
45886
+ );
45548
45887
  } else {
45549
45888
  if (typeof typeName === "string") {
45889
+ if (typeParameters && typeParameters[typeName]) {
45890
+ return resolveTypeElements(
45891
+ ctx,
45892
+ typeParameters[typeName],
45893
+ scope,
45894
+ typeParameters
45895
+ );
45896
+ }
45550
45897
  if (
45551
45898
  // @ts-ignore
45552
45899
  SupportedBuiltinsSet.has(typeName)
45553
45900
  ) {
45554
- return resolveBuiltin(ctx, node, typeName, scope);
45901
+ return resolveBuiltin(
45902
+ ctx,
45903
+ node,
45904
+ typeName,
45905
+ scope,
45906
+ typeParameters
45907
+ );
45555
45908
  } else if (typeName === "ReturnType" && node.typeParameters) {
45556
45909
  const ret = resolveReturnType(
45557
45910
  ctx,
@@ -45600,10 +45953,14 @@ function innerResolveTypeElements(ctx, node, scope) {
45600
45953
  }
45601
45954
  return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
45602
45955
  }
45603
- function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
45956
+ function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
45604
45957
  const res = { props: {} };
45605
45958
  for (const e of elements) {
45606
45959
  if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
45960
+ if (typeParameters) {
45961
+ scope = createChildScope(scope);
45962
+ Object.assign(scope.types, typeParameters);
45963
+ }
45607
45964
  e._ownerScope = scope;
45608
45965
  const name = getId(e.key);
45609
45966
  if (name && !e.computed) {
@@ -45666,8 +46023,13 @@ function createProperty(key, typeAnnotation, scope, optional) {
45666
46023
  _ownerScope: scope
45667
46024
  };
45668
46025
  }
45669
- function resolveInterfaceMembers(ctx, node, scope) {
45670
- const base = typeElementsToMap(ctx, node.body.body, node._ownerScope);
46026
+ function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
46027
+ const base = typeElementsToMap(
46028
+ ctx,
46029
+ node.body.body,
46030
+ node._ownerScope,
46031
+ typeParameters
46032
+ );
45671
46033
  if (node.extends) {
45672
46034
  for (const ext of node.extends) {
45673
46035
  if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
@@ -45841,8 +46203,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
45841
46203
  "Pick",
45842
46204
  "Omit"
45843
46205
  ]);
45844
- function resolveBuiltin(ctx, node, name, scope) {
45845
- const t = resolveTypeElements(ctx, node.typeParameters.params[0], scope);
46206
+ function resolveBuiltin(ctx, node, name, scope, typeParameters) {
46207
+ const t = resolveTypeElements(
46208
+ ctx,
46209
+ node.typeParameters.params[0],
46210
+ scope,
46211
+ typeParameters
46212
+ );
45846
46213
  switch (name) {
45847
46214
  case "Partial": {
45848
46215
  const res2 = { props: {}, calls: t.calls };
@@ -45970,7 +46337,21 @@ function resolveGlobalScope(ctx) {
45970
46337
  let ts;
45971
46338
  let loadTS;
45972
46339
  function registerTS(_loadTS) {
45973
- loadTS = _loadTS;
46340
+ loadTS = () => {
46341
+ try {
46342
+ return _loadTS();
46343
+ } catch (err) {
46344
+ if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
46345
+ throw new Error(
46346
+ 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
46347
+ );
46348
+ } else {
46349
+ throw new Error(
46350
+ "Failed to load TypeScript for resolving imported types."
46351
+ );
46352
+ }
46353
+ }
46354
+ };
45974
46355
  }
45975
46356
  function resolveFS(ctx) {
45976
46357
  if (ctx.fs) {
@@ -46004,7 +46385,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
46004
46385
  return resolveTypeReference(ctx, node, sourceScope, imported, true);
46005
46386
  }
46006
46387
  function importSourceToScope(ctx, node, scope, source) {
46007
- const fs = resolveFS(ctx);
46388
+ let fs;
46389
+ try {
46390
+ fs = resolveFS(ctx);
46391
+ } catch (err) {
46392
+ return ctx.error(err.message, node, scope);
46393
+ }
46008
46394
  if (!fs) {
46009
46395
  return ctx.error(
46010
46396
  `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
@@ -46129,14 +46515,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
46129
46515
  if (node._resolvedChildScope) {
46130
46516
  return node._resolvedChildScope;
46131
46517
  }
46132
- const scope = new TypeScope(
46133
- parentScope.filename,
46134
- parentScope.source,
46135
- parentScope.offset,
46136
- Object.create(parentScope.imports),
46137
- Object.create(parentScope.types),
46138
- Object.create(parentScope.declares)
46139
- );
46518
+ const scope = createChildScope(parentScope);
46140
46519
  if (node.body.type === "TSModuleDeclaration") {
46141
46520
  const decl = node.body;
46142
46521
  decl._ownerScope = scope;
@@ -46147,6 +46526,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
46147
46526
  }
46148
46527
  return node._resolvedChildScope = scope;
46149
46528
  }
46529
+ function createChildScope(parentScope) {
46530
+ return new TypeScope(
46531
+ parentScope.filename,
46532
+ parentScope.source,
46533
+ parentScope.offset,
46534
+ Object.create(parentScope.imports),
46535
+ Object.create(parentScope.types),
46536
+ Object.create(parentScope.declares)
46537
+ );
46538
+ }
46150
46539
  const importExportRE = /^Import|^Export/;
46151
46540
  function recordTypes(ctx, body, scope, asGlobal = false) {
46152
46541
  const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
@@ -46268,7 +46657,7 @@ function recordType(node, types, declares, overwriteId) {
46268
46657
  types[overwriteId || getId(node.id)] = node;
46269
46658
  break;
46270
46659
  case "TSTypeAliasDeclaration":
46271
- types[node.id.name] = node.typeAnnotation;
46660
+ types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
46272
46661
  break;
46273
46662
  case "TSDeclareFunction":
46274
46663
  if (node.id)
@@ -46808,7 +47197,7 @@ function genRuntimeProps(ctx) {
46808
47197
  );
46809
47198
  }
46810
47199
  if (defaults.length) {
46811
- propsDecls = `${ctx.helper(
47200
+ propsDecls = `/*#__PURE__*/${ctx.helper(
46812
47201
  `mergeDefaults`
46813
47202
  )}(${propsDecls}, {
46814
47203
  ${defaults.join(",\n ")}
@@ -46820,7 +47209,9 @@ function genRuntimeProps(ctx) {
46820
47209
  }
46821
47210
  const modelsDecls = genModelProps(ctx);
46822
47211
  if (propsDecls && modelsDecls) {
46823
- return `${ctx.helper("mergeModels")}(${propsDecls}, ${modelsDecls})`;
47212
+ return `/*#__PURE__*/${ctx.helper(
47213
+ "mergeModels"
47214
+ )}(${propsDecls}, ${modelsDecls})`;
46824
47215
  } else {
46825
47216
  return modelsDecls || propsDecls;
46826
47217
  }
@@ -46842,9 +47233,9 @@ function extractRuntimeProps(ctx) {
46842
47233
  ${propStrings.join(",\n ")}
46843
47234
  }`;
46844
47235
  if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
46845
- propsDecls = `${ctx.helper("mergeDefaults")}(${propsDecls}, ${ctx.getString(
46846
- ctx.propsRuntimeDefaults
46847
- )})`;
47236
+ propsDecls = `/*#__PURE__*/${ctx.helper(
47237
+ "mergeDefaults"
47238
+ )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
46848
47239
  }
46849
47240
  return propsDecls;
46850
47241
  }
@@ -47062,7 +47453,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
47062
47453
  }
47063
47454
  for (const decl of stmt.declarations) {
47064
47455
  const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
47065
- for (const id of extractIdentifiers(decl.id)) {
47456
+ for (const id of extractIdentifiers$1(decl.id)) {
47066
47457
  if (isDefineProps) {
47067
47458
  excludedIds.add(id);
47068
47459
  } else {
@@ -47181,7 +47572,9 @@ function genRuntimeEmits(ctx) {
47181
47572
  }
47182
47573
  if (ctx.hasDefineModelCall) {
47183
47574
  let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
47184
- emitsDecl = emitsDecl ? `${ctx.helper("mergeModels")}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
47575
+ emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
47576
+ "mergeModels"
47577
+ )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
47185
47578
  }
47186
47579
  return emitsDecl;
47187
47580
  }
@@ -48133,9 +48526,9 @@ function isStaticNode(node) {
48133
48526
  return false;
48134
48527
  }
48135
48528
 
48136
- const version = "3.4.0-alpha.3";
48529
+ const version = "3.4.0-alpha.4";
48137
48530
  const parseCache = parseCache$1;
48138
48531
  const walk = walk$1;
48139
48532
  const shouldTransformRef = () => false;
48140
48533
 
48141
- export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };
48534
+ export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };