@vue/compiler-sfc 3.3.8 → 3.3.10

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.
@@ -11,8 +11,8 @@ const EMPTY_OBJ = Object.freeze({}) ;
11
11
  const NOOP = () => {
12
12
  };
13
13
  const NO = () => false;
14
- const onRE = /^on[^a-z]/;
15
- const isOn = (key) => onRE.test(key);
14
+ const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
15
+ (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
16
16
  const extend = Object.assign;
17
17
  const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
18
18
  const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
@@ -66,7 +66,7 @@ const PatchFlagNames = {
66
66
  [4]: `STYLE`,
67
67
  [8]: `PROPS`,
68
68
  [16]: `FULL_PROPS`,
69
- [32]: `HYDRATE_EVENTS`,
69
+ [32]: `NEED_HYDRATION`,
70
70
  [64]: `STABLE_FRAGMENT`,
71
71
  [128]: `KEYED_FRAGMENT`,
72
72
  [256]: `UNKEYED_FRAGMENT`,
@@ -4162,11 +4162,6 @@ function newAsyncArrowScope() {
4162
4162
  function newExpressionScope() {
4163
4163
  return new ExpressionScope();
4164
4164
  }
4165
- const PARAM = 0b0000,
4166
- PARAM_YIELD = 0b0001,
4167
- PARAM_AWAIT = 0b0010,
4168
- PARAM_RETURN = 0b0100,
4169
- PARAM_IN = 0b1000;
4170
4165
  class ProductionParameterHandler {
4171
4166
  constructor() {
4172
4167
  this.stacks = [];
@@ -4181,20 +4176,20 @@ class ProductionParameterHandler {
4181
4176
  return this.stacks[this.stacks.length - 1];
4182
4177
  }
4183
4178
  get hasAwait() {
4184
- return (this.currentFlags() & PARAM_AWAIT) > 0;
4179
+ return (this.currentFlags() & 2) > 0;
4185
4180
  }
4186
4181
  get hasYield() {
4187
- return (this.currentFlags() & PARAM_YIELD) > 0;
4182
+ return (this.currentFlags() & 1) > 0;
4188
4183
  }
4189
4184
  get hasReturn() {
4190
- return (this.currentFlags() & PARAM_RETURN) > 0;
4185
+ return (this.currentFlags() & 4) > 0;
4191
4186
  }
4192
4187
  get hasIn() {
4193
- return (this.currentFlags() & PARAM_IN) > 0;
4188
+ return (this.currentFlags() & 8) > 0;
4194
4189
  }
4195
4190
  }
4196
4191
  function functionFlags(isAsync, isGenerator) {
4197
- return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
4192
+ return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
4198
4193
  }
4199
4194
  class UtilParser extends Tokenizer {
4200
4195
  addExtra(node, key, value, enumerable = true) {
@@ -4391,9 +4386,9 @@ class UtilParser extends Tokenizer {
4391
4386
  };
4392
4387
  }
4393
4388
  enterInitialScopes() {
4394
- let paramFlags = PARAM;
4389
+ let paramFlags = 0;
4395
4390
  if (this.inModule) {
4396
- paramFlags |= PARAM_AWAIT;
4391
+ paramFlags |= 2;
4397
4392
  }
4398
4393
  this.scope.enter(1);
4399
4394
  this.prodParam.enter(paramFlags);
@@ -9436,7 +9431,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9436
9431
  node.body = inner;
9437
9432
  } else {
9438
9433
  this.scope.enter(256);
9439
- this.prodParam.enter(PARAM);
9434
+ this.prodParam.enter(0);
9440
9435
  node.body = this.tsParseModuleBlock();
9441
9436
  this.prodParam.exit();
9442
9437
  this.scope.exit();
@@ -9454,7 +9449,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9454
9449
  }
9455
9450
  if (this.match(5)) {
9456
9451
  this.scope.enter(256);
9457
- this.prodParam.enter(PARAM);
9452
+ this.prodParam.enter(0);
9458
9453
  node.body = this.tsParseModuleBlock();
9459
9454
  this.prodParam.exit();
9460
9455
  this.scope.exit();
@@ -9581,7 +9576,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9581
9576
  case "global":
9582
9577
  if (this.match(5)) {
9583
9578
  this.scope.enter(256);
9584
- this.prodParam.enter(PARAM);
9579
+ this.prodParam.enter(0);
9585
9580
  const mod = node;
9586
9581
  mod.global = true;
9587
9582
  mod.id = expr;
@@ -12012,7 +12007,7 @@ class ExpressionParser extends LValParser {
12012
12007
  const oldLabels = this.state.labels;
12013
12008
  this.state.labels = [];
12014
12009
  if (isAsync) {
12015
- this.prodParam.enter(PARAM_AWAIT);
12010
+ this.prodParam.enter(2);
12016
12011
  node.body = this.parseBlock();
12017
12012
  this.prodParam.exit();
12018
12013
  } else {
@@ -12576,7 +12571,7 @@ class ExpressionParser extends LValParser {
12576
12571
  this.scope.enter(2 | 4);
12577
12572
  let flags = functionFlags(isAsync, false);
12578
12573
  if (!this.match(5) && this.prodParam.hasIn) {
12579
- flags |= PARAM_IN;
12574
+ flags |= 8;
12580
12575
  }
12581
12576
  this.prodParam.enter(flags);
12582
12577
  this.initFunction(node, isAsync);
@@ -12610,7 +12605,7 @@ class ExpressionParser extends LValParser {
12610
12605
  const oldStrict = this.state.strict;
12611
12606
  const oldLabels = this.state.labels;
12612
12607
  this.state.labels = [];
12613
- this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN);
12608
+ this.prodParam.enter(this.prodParam.currentFlags() | 4);
12614
12609
  node.body = this.parseBlock(true, false, hasStrictModeDirective => {
12615
12610
  const nonSimple = !this.isSimpleParamList(node.params);
12616
12611
  if (hasStrictModeDirective && nonSimple) {
@@ -12951,9 +12946,9 @@ class ExpressionParser extends LValParser {
12951
12946
  }
12952
12947
  allowInAnd(callback) {
12953
12948
  const flags = this.prodParam.currentFlags();
12954
- const prodParamToSet = PARAM_IN & ~flags;
12949
+ const prodParamToSet = 8 & ~flags;
12955
12950
  if (prodParamToSet) {
12956
- this.prodParam.enter(flags | PARAM_IN);
12951
+ this.prodParam.enter(flags | 8);
12957
12952
  try {
12958
12953
  return callback();
12959
12954
  } finally {
@@ -12964,9 +12959,9 @@ class ExpressionParser extends LValParser {
12964
12959
  }
12965
12960
  disallowInAnd(callback) {
12966
12961
  const flags = this.prodParam.currentFlags();
12967
- const prodParamToClear = PARAM_IN & flags;
12962
+ const prodParamToClear = 8 & flags;
12968
12963
  if (prodParamToClear) {
12969
- this.prodParam.enter(flags & ~PARAM_IN);
12964
+ this.prodParam.enter(flags & ~8);
12970
12965
  try {
12971
12966
  return callback();
12972
12967
  } finally {
@@ -13881,7 +13876,7 @@ class StatementParser extends ExpressionParser {
13881
13876
  }
13882
13877
  body.push(stmt);
13883
13878
  }
13884
- afterBlockParse == null ? void 0 : afterBlockParse.call(this, hasStrictModeDirective);
13879
+ afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
13885
13880
  if (!oldStrict) {
13886
13881
  this.setStrict(false);
13887
13882
  }
@@ -14257,7 +14252,7 @@ class StatementParser extends ExpressionParser {
14257
14252
  this.scope.enter(64 | 128 | 16);
14258
14253
  const oldLabels = this.state.labels;
14259
14254
  this.state.labels = [];
14260
- this.prodParam.enter(PARAM);
14255
+ this.prodParam.enter(0);
14261
14256
  const body = member.body = [];
14262
14257
  this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
14263
14258
  this.prodParam.exit();
@@ -14329,7 +14324,7 @@ class StatementParser extends ExpressionParser {
14329
14324
  parseInitializer(node) {
14330
14325
  this.scope.enter(64 | 16);
14331
14326
  this.expressionScope.enter(newExpressionScope());
14332
- this.prodParam.enter(PARAM);
14327
+ this.prodParam.enter(0);
14333
14328
  node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
14334
14329
  this.expressionScope.exit();
14335
14330
  this.prodParam.exit();
@@ -15450,6 +15445,7 @@ function getMemoedVNodeCall(node) {
15450
15445
  return node;
15451
15446
  }
15452
15447
  }
15448
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
15453
15449
 
15454
15450
  const deprecationData = {
15455
15451
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -21124,6 +21120,15 @@ function walkBlockDeclarations(block, onIdent) {
21124
21120
  if (stmt.declare || !stmt.id)
21125
21121
  continue;
21126
21122
  onIdent(stmt.id);
21123
+ } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
21124
+ const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
21125
+ if (variable && variable.type === "VariableDeclaration") {
21126
+ for (const decl of variable.declarations) {
21127
+ for (const id of extractIdentifiers(decl.id)) {
21128
+ onIdent(id);
21129
+ }
21130
+ }
21131
+ }
21127
21132
  }
21128
21133
  }
21129
21134
  }
@@ -21911,13 +21916,12 @@ function processFor(node, dir, context, processCodegen) {
21911
21916
  onExit();
21912
21917
  };
21913
21918
  }
21914
- const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
21915
21919
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
21916
21920
  const stripParensRE = /^\(|\)$/g;
21917
21921
  function parseForExpression(input, context) {
21918
21922
  const loc = input.loc;
21919
21923
  const exp = input.content;
21920
- const inMatch = exp.match(forAliasRE$1);
21924
+ const inMatch = exp.match(forAliasRE);
21921
21925
  if (!inMatch)
21922
21926
  return;
21923
21927
  const [, LHS, RHS] = inMatch;
@@ -22479,6 +22483,10 @@ function resolveSetupReference(name, context) {
22479
22483
  `${context.helperString(UNREF)}(${fromMaybeRef})`
22480
22484
  ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
22481
22485
  }
22486
+ const fromProps = checkType("props");
22487
+ if (fromProps) {
22488
+ return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
22489
+ }
22482
22490
  }
22483
22491
  function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
22484
22492
  const { tag, loc: elementLoc, children } = node;
@@ -22519,6 +22527,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
22519
22527
  if (isEventHandler && isReservedProp(name)) {
22520
22528
  hasVnodeHook = true;
22521
22529
  }
22530
+ if (isEventHandler && value.type === 14) {
22531
+ value = value.arguments[0];
22532
+ }
22522
22533
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
22523
22534
  return;
22524
22535
  }
@@ -22584,7 +22595,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
22584
22595
  )
22585
22596
  );
22586
22597
  } else {
22587
- const { name, arg, exp, loc } = prop;
22598
+ const { name, arg, exp, loc, modifiers } = prop;
22588
22599
  const isVBind = name === "bind";
22589
22600
  const isVOn = name === "on";
22590
22601
  if (name === "slot") {
@@ -22644,6 +22655,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
22644
22655
  }
22645
22656
  continue;
22646
22657
  }
22658
+ if (isVBind && modifiers.includes("prop")) {
22659
+ patchFlag |= 32;
22660
+ }
22647
22661
  const directiveTransform = context.directiveTransforms[name];
22648
22662
  if (directiveTransform) {
22649
22663
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -25906,8 +25920,8 @@ const transformModel = (dir, node, context) => {
25906
25920
  );
25907
25921
  }
25908
25922
  function checkDuplicatedValue() {
25909
- const value = findProp(node, "value");
25910
- if (value) {
25923
+ const value = findDir(node, "bind");
25924
+ if (value && isStaticArgOf(value.arg, "value")) {
25911
25925
  context.onError(
25912
25926
  createDOMCompilerError(
25913
25927
  60,
@@ -26477,6 +26491,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
26477
26491
  extractIdentifiers: extractIdentifiers,
26478
26492
  findDir: findDir,
26479
26493
  findProp: findProp,
26494
+ forAliasRE: forAliasRE,
26480
26495
  generate: generate,
26481
26496
  generateCodeFrame: generateCodeFrame,
26482
26497
  getBaseTransformPreset: getBaseTransformPreset,
@@ -26829,9 +26844,16 @@ function normalizePath(p) {
26829
26844
  return normalize(p.replace(windowsSlashRE, "/"));
26830
26845
  }
26831
26846
  const joinPaths = (path.posix || path).join;
26832
- const escapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
26833
- function getEscapedKey(key) {
26834
- return escapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
26847
+ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
26848
+ function getEscapedPropName(key) {
26849
+ return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
26850
+ }
26851
+ const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
26852
+ function getEscapedCssVarName(key, doubleEscape) {
26853
+ return key.replace(
26854
+ cssVarNameEscapeSymbolsRE,
26855
+ (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
26856
+ );
26835
26857
  }
26836
26858
 
26837
26859
  function pad$1 (hash, len) {
@@ -26908,15 +26930,15 @@ const CSS_VARS_HELPER = `useCssVars`;
26908
26930
  function genCssVarsFromList(vars, id, isProd, isSSR = false) {
26909
26931
  return `{
26910
26932
  ${vars.map(
26911
- (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
26933
+ (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
26912
26934
  ).join(",\n ")}
26913
26935
  }`;
26914
26936
  }
26915
- function genVarName(id, raw, isProd) {
26937
+ function genVarName(id, raw, isProd, isSSR = false) {
26916
26938
  if (isProd) {
26917
26939
  return hash(id + raw);
26918
26940
  } else {
26919
- return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`;
26941
+ return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
26920
26942
  }
26921
26943
  }
26922
26944
  function normalizeExpression(exp) {
@@ -27326,7 +27348,6 @@ function resolveTemplateUsageCheckString(sfc) {
27326
27348
  templateUsageCheckCache.set(content, code);
27327
27349
  return code;
27328
27350
  }
27329
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
27330
27351
  function processExp(exp, dir) {
27331
27352
  if (/ as\s+\w|<.*>|:/.test(exp)) {
27332
27353
  if (dir === "slot") {
@@ -27505,22 +27526,29 @@ function parse$7(source, {
27505
27526
  descriptor.script = null;
27506
27527
  }
27507
27528
  }
27529
+ let templateColumnOffset = 0;
27530
+ if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
27531
+ [descriptor.template.content, templateColumnOffset] = dedent(
27532
+ descriptor.template.content
27533
+ );
27534
+ }
27508
27535
  if (sourceMap) {
27509
- const genMap = (block) => {
27536
+ const genMap = (block, columnOffset = 0) => {
27510
27537
  if (block && !block.src) {
27511
27538
  block.map = generateSourceMap(
27512
27539
  filename,
27513
27540
  source,
27514
27541
  block.content,
27515
27542
  sourceRoot,
27516
- !pad || block.type === "template" ? block.loc.start.line - 1 : 0
27543
+ !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
27544
+ columnOffset
27517
27545
  );
27518
27546
  }
27519
27547
  };
27520
- genMap(descriptor.template);
27548
+ genMap(descriptor.template, templateColumnOffset);
27521
27549
  genMap(descriptor.script);
27522
- descriptor.styles.forEach(genMap);
27523
- descriptor.customBlocks.forEach(genMap);
27550
+ descriptor.styles.forEach((s) => genMap(s));
27551
+ descriptor.customBlocks.forEach((s) => genMap(s));
27524
27552
  }
27525
27553
  descriptor.cssVars = parseCssVars(descriptor);
27526
27554
  const slottedRE = /(?:::v-|:)slotted\(/;
@@ -27598,7 +27626,7 @@ function createBlock(node, source, pad) {
27598
27626
  const splitRE = /\r?\n/g;
27599
27627
  const emptyRE = /^(?:\/\/)?\s*$/;
27600
27628
  const replaceRE = /./g;
27601
- function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
27629
+ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
27602
27630
  const map = new SourceMapGenerator$6({
27603
27631
  file: filename.replace(/\\/g, "/"),
27604
27632
  sourceRoot: sourceRoot.replace(/\\/g, "/")
@@ -27614,7 +27642,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
27614
27642
  source: filename,
27615
27643
  original: {
27616
27644
  line: originalLine,
27617
- column: i
27645
+ column: i + columnOffset
27618
27646
  },
27619
27647
  generated: {
27620
27648
  line: generatedLine,
@@ -27665,6 +27693,26 @@ function hmrShouldReload(prevImports, next) {
27665
27693
  }
27666
27694
  return false;
27667
27695
  }
27696
+ function dedent(s) {
27697
+ const lines = s.split("\n");
27698
+ const minIndent = lines.reduce(function(minIndent2, line) {
27699
+ var _a, _b;
27700
+ if (line.trim() === "") {
27701
+ return minIndent2;
27702
+ }
27703
+ const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
27704
+ return Math.min(indent, minIndent2);
27705
+ }, Infinity);
27706
+ if (minIndent === 0) {
27707
+ return [s, minIndent];
27708
+ }
27709
+ return [
27710
+ lines.map(function(line) {
27711
+ return line.slice(minIndent);
27712
+ }).join("\n"),
27713
+ minIndent
27714
+ ];
27715
+ }
27668
27716
 
27669
27717
  /*! https://mths.be/punycode v1.4.1 by @mathias */
27670
27718
 
@@ -33189,7 +33237,7 @@ function compile(template, options = {}) {
33189
33237
  // reusing core v-bind
33190
33238
  bind: transformBind,
33191
33239
  on: transformOn$1,
33192
- // model and show has dedicated SSR handling
33240
+ // model and show have dedicated SSR handling
33193
33241
  model: ssrTransformModel,
33194
33242
  show: ssrTransformShow,
33195
33243
  // the following are ignored during SSR
@@ -37591,7 +37639,7 @@ let Root$2 = root$2;
37591
37639
 
37592
37640
  let Processor$1 = class Processor {
37593
37641
  constructor(plugins = []) {
37594
- this.version = '8.4.31';
37642
+ this.version = '8.4.32';
37595
37643
  this.plugins = this.normalize(plugins);
37596
37644
  }
37597
37645
 
@@ -41383,10 +41431,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
41383
41431
  return false;
41384
41432
  }
41385
41433
  }
41386
- if (n.type !== "pseudo" && n.type !== "combinator") {
41434
+ if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
41387
41435
  node = n;
41388
41436
  }
41389
41437
  });
41438
+ if (node) {
41439
+ const { type, value } = node;
41440
+ if (type === "pseudo" && (value === ":is" || value === ":where")) {
41441
+ node.nodes.forEach(
41442
+ (value2) => rewriteSelector(id, value2, selectorRoot, slotted)
41443
+ );
41444
+ shouldInject = false;
41445
+ }
41446
+ }
41390
41447
  if (node) {
41391
41448
  node.spaces.after = "";
41392
41449
  } else {
@@ -47073,7 +47130,7 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
47073
47130
  }
47074
47131
  if (lang === "ts" || lang === "tsx") {
47075
47132
  plugins.push(["typescript", { dts }]);
47076
- if (!plugins.includes("decorators")) {
47133
+ if (!userPlugins || !userPlugins.includes("decorators")) {
47077
47134
  plugins.push("decorators-legacy");
47078
47135
  }
47079
47136
  }
@@ -47115,33 +47172,39 @@ class TypeScope {
47115
47172
  this.exportedDeclares = /* @__PURE__ */ Object.create(null);
47116
47173
  }
47117
47174
  }
47118
- function resolveTypeElements(ctx, node, scope) {
47175
+ function resolveTypeElements(ctx, node, scope, typeParameters) {
47119
47176
  if (node._resolvedElements) {
47120
47177
  return node._resolvedElements;
47121
47178
  }
47122
47179
  return node._resolvedElements = innerResolveTypeElements(
47123
47180
  ctx,
47124
47181
  node,
47125
- node._ownerScope || scope || ctxToScope(ctx)
47182
+ node._ownerScope || scope || ctxToScope(ctx),
47183
+ typeParameters
47126
47184
  );
47127
47185
  }
47128
- function innerResolveTypeElements(ctx, node, scope) {
47186
+ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
47129
47187
  var _a, _b;
47130
47188
  switch (node.type) {
47131
47189
  case "TSTypeLiteral":
47132
- return typeElementsToMap(ctx, node.members, scope);
47190
+ return typeElementsToMap(ctx, node.members, scope, typeParameters);
47133
47191
  case "TSInterfaceDeclaration":
47134
- return resolveInterfaceMembers(ctx, node, scope);
47192
+ return resolveInterfaceMembers(ctx, node, scope, typeParameters);
47135
47193
  case "TSTypeAliasDeclaration":
47136
47194
  case "TSParenthesizedType":
47137
- return resolveTypeElements(ctx, node.typeAnnotation, scope);
47195
+ return resolveTypeElements(
47196
+ ctx,
47197
+ node.typeAnnotation,
47198
+ scope,
47199
+ typeParameters
47200
+ );
47138
47201
  case "TSFunctionType": {
47139
47202
  return { props: {}, calls: [node] };
47140
47203
  }
47141
47204
  case "TSUnionType":
47142
47205
  case "TSIntersectionType":
47143
47206
  return mergeElements(
47144
- node.types.map((t) => resolveTypeElements(ctx, t, scope)),
47207
+ node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
47145
47208
  node.type
47146
47209
  );
47147
47210
  case "TSMappedType":
@@ -47158,20 +47221,53 @@ function innerResolveTypeElements(ctx, node, scope) {
47158
47221
  const typeName = getReferenceName(node);
47159
47222
  if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
47160
47223
  return resolveExtractPropTypes(
47161
- resolveTypeElements(ctx, node.typeParameters.params[0], scope),
47224
+ resolveTypeElements(
47225
+ ctx,
47226
+ node.typeParameters.params[0],
47227
+ scope,
47228
+ typeParameters
47229
+ ),
47162
47230
  scope
47163
47231
  );
47164
47232
  }
47165
47233
  const resolved = resolveTypeReference(ctx, node, scope);
47166
47234
  if (resolved) {
47167
- return resolveTypeElements(ctx, resolved, resolved._ownerScope);
47235
+ const typeParams = /* @__PURE__ */ Object.create(null);
47236
+ if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
47237
+ resolved.typeParameters.params.forEach((p, i) => {
47238
+ let param = typeParameters && typeParameters[p.name];
47239
+ if (!param)
47240
+ param = node.typeParameters.params[i];
47241
+ typeParams[p.name] = param;
47242
+ });
47243
+ }
47244
+ return resolveTypeElements(
47245
+ ctx,
47246
+ resolved,
47247
+ resolved._ownerScope,
47248
+ typeParams
47249
+ );
47168
47250
  } else {
47169
47251
  if (typeof typeName === "string") {
47252
+ if (typeParameters && typeParameters[typeName]) {
47253
+ return resolveTypeElements(
47254
+ ctx,
47255
+ typeParameters[typeName],
47256
+ scope,
47257
+ typeParameters
47258
+ );
47259
+ }
47170
47260
  if (
47171
47261
  // @ts-ignore
47172
47262
  SupportedBuiltinsSet.has(typeName)
47173
47263
  ) {
47174
- return resolveBuiltin(ctx, node, typeName, scope);
47264
+ return resolveBuiltin(
47265
+ ctx,
47266
+ node,
47267
+ typeName,
47268
+ scope,
47269
+ typeParameters
47270
+ );
47175
47271
  } else if (typeName === "ReturnType" && node.typeParameters) {
47176
47272
  const ret = resolveReturnType(
47177
47273
  ctx,
@@ -47220,10 +47316,14 @@ function innerResolveTypeElements(ctx, node, scope) {
47220
47316
  }
47221
47317
  return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
47222
47318
  }
47223
- function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
47319
+ function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
47224
47320
  const res = { props: {} };
47225
47321
  for (const e of elements) {
47226
47322
  if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
47323
+ if (typeParameters) {
47324
+ scope = createChildScope(scope);
47325
+ Object.assign(scope.types, typeParameters);
47326
+ }
47227
47327
  e._ownerScope = scope;
47228
47328
  const name = getId(e.key);
47229
47329
  if (name && !e.computed) {
@@ -47286,20 +47386,29 @@ function createProperty(key, typeAnnotation, scope, optional) {
47286
47386
  _ownerScope: scope
47287
47387
  };
47288
47388
  }
47289
- function resolveInterfaceMembers(ctx, node, scope) {
47290
- const base = typeElementsToMap(ctx, node.body.body, node._ownerScope);
47389
+ function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
47390
+ const base = typeElementsToMap(
47391
+ ctx,
47392
+ node.body.body,
47393
+ node._ownerScope,
47394
+ typeParameters
47395
+ );
47291
47396
  if (node.extends) {
47292
47397
  for (const ext of node.extends) {
47293
47398
  if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
47294
47399
  continue;
47295
47400
  }
47296
47401
  try {
47297
- const { props } = resolveTypeElements(ctx, ext, scope);
47402
+ const { props, calls } = resolveTypeElements(ctx, ext, scope);
47298
47403
  for (const key in props) {
47299
47404
  if (!hasOwn(base.props, key)) {
47300
47405
  base.props[key] = props[key];
47301
47406
  }
47302
47407
  }
47408
+ if (calls) {
47409
+ ;
47410
+ (base.calls || (base.calls = [])).push(...calls);
47411
+ }
47303
47412
  } catch (e) {
47304
47413
  ctx.error(
47305
47414
  `Failed to resolve extends base type.
@@ -47457,8 +47566,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
47457
47566
  "Pick",
47458
47567
  "Omit"
47459
47568
  ]);
47460
- function resolveBuiltin(ctx, node, name, scope) {
47461
- const t = resolveTypeElements(ctx, node.typeParameters.params[0], scope);
47569
+ function resolveBuiltin(ctx, node, name, scope, typeParameters) {
47570
+ const t = resolveTypeElements(
47571
+ ctx,
47572
+ node.typeParameters.params[0],
47573
+ scope,
47574
+ typeParameters
47575
+ );
47462
47576
  switch (name) {
47463
47577
  case "Partial": {
47464
47578
  const res2 = { props: {}, calls: t.calls };
@@ -47586,7 +47700,21 @@ function resolveGlobalScope(ctx) {
47586
47700
  let ts;
47587
47701
  let loadTS;
47588
47702
  function registerTS(_loadTS) {
47589
- loadTS = _loadTS;
47703
+ loadTS = () => {
47704
+ try {
47705
+ return _loadTS();
47706
+ } catch (err) {
47707
+ if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
47708
+ throw new Error(
47709
+ 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
47710
+ );
47711
+ } else {
47712
+ throw new Error(
47713
+ "Failed to load TypeScript for resolving imported types."
47714
+ );
47715
+ }
47716
+ }
47717
+ };
47590
47718
  }
47591
47719
  function resolveFS(ctx) {
47592
47720
  if (ctx.fs) {
@@ -47620,7 +47748,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
47620
47748
  return resolveTypeReference(ctx, node, sourceScope, imported, true);
47621
47749
  }
47622
47750
  function importSourceToScope(ctx, node, scope, source) {
47623
- const fs = resolveFS(ctx);
47751
+ let fs;
47752
+ try {
47753
+ fs = resolveFS(ctx);
47754
+ } catch (err) {
47755
+ return ctx.error(err.message, node, scope);
47756
+ }
47624
47757
  if (!fs) {
47625
47758
  return ctx.error(
47626
47759
  `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
@@ -47630,7 +47763,11 @@ function importSourceToScope(ctx, node, scope, source) {
47630
47763
  }
47631
47764
  let resolved = scope.resolvedImportSources[source];
47632
47765
  if (!resolved) {
47633
- if (source.startsWith(".")) {
47766
+ if (source.startsWith("..")) {
47767
+ const osSpecificJoinFn = joinPaths;
47768
+ const filename = osSpecificJoinFn(dirname$2(scope.filename), source);
47769
+ resolved = resolveExt(filename, fs);
47770
+ } else if (source.startsWith(".")) {
47634
47771
  const filename = joinPaths(dirname$2(scope.filename), source);
47635
47772
  resolved = resolveExt(filename, fs);
47636
47773
  } else {
@@ -47741,14 +47878,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
47741
47878
  if (node._resolvedChildScope) {
47742
47879
  return node._resolvedChildScope;
47743
47880
  }
47744
- const scope = new TypeScope(
47745
- parentScope.filename,
47746
- parentScope.source,
47747
- parentScope.offset,
47748
- Object.create(parentScope.imports),
47749
- Object.create(parentScope.types),
47750
- Object.create(parentScope.declares)
47751
- );
47881
+ const scope = createChildScope(parentScope);
47752
47882
  if (node.body.type === "TSModuleDeclaration") {
47753
47883
  const decl = node.body;
47754
47884
  decl._ownerScope = scope;
@@ -47759,6 +47889,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
47759
47889
  }
47760
47890
  return node._resolvedChildScope = scope;
47761
47891
  }
47892
+ function createChildScope(parentScope) {
47893
+ return new TypeScope(
47894
+ parentScope.filename,
47895
+ parentScope.source,
47896
+ parentScope.offset,
47897
+ Object.create(parentScope.imports),
47898
+ Object.create(parentScope.types),
47899
+ Object.create(parentScope.declares)
47900
+ );
47901
+ }
47762
47902
  const importExportRE = /^Import|^Export/;
47763
47903
  function recordTypes(ctx, body, scope, asGlobal = false) {
47764
47904
  const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
@@ -47880,7 +48020,7 @@ function recordType(node, types, declares, overwriteId) {
47880
48020
  types[overwriteId || getId(node.id)] = node;
47881
48021
  break;
47882
48022
  case "TSTypeAliasDeclaration":
47883
- types[node.id.name] = node.typeAnnotation;
48023
+ types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
47884
48024
  break;
47885
48025
  case "TSDeclareFunction":
47886
48026
  if (node.id)
@@ -48413,14 +48553,14 @@ function genRuntimeProps(ctx) {
48413
48553
  const defaults = [];
48414
48554
  for (const key in ctx.propsDestructuredBindings) {
48415
48555
  const d = genDestructuredDefaultValue(ctx, key);
48416
- const finalKey = getEscapedKey(key);
48556
+ const finalKey = getEscapedPropName(key);
48417
48557
  if (d)
48418
48558
  defaults.push(
48419
48559
  `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
48420
48560
  );
48421
48561
  }
48422
48562
  if (defaults.length) {
48423
- propsDecls = `${ctx.helper(
48563
+ propsDecls = `/*#__PURE__*/${ctx.helper(
48424
48564
  `mergeDefaults`
48425
48565
  )}(${propsDecls}, {
48426
48566
  ${defaults.join(",\n ")}
@@ -48432,7 +48572,9 @@ function genRuntimeProps(ctx) {
48432
48572
  }
48433
48573
  const modelsDecls = genModelProps(ctx);
48434
48574
  if (propsDecls && modelsDecls) {
48435
- return `${ctx.helper("mergeModels")}(${propsDecls}, ${modelsDecls})`;
48575
+ return `/*#__PURE__*/${ctx.helper(
48576
+ "mergeModels"
48577
+ )}(${propsDecls}, ${modelsDecls})`;
48436
48578
  } else {
48437
48579
  return modelsDecls || propsDecls;
48438
48580
  }
@@ -48454,9 +48596,9 @@ function genRuntimePropsFromTypes(ctx) {
48454
48596
  ${propStrings.join(",\n ")}
48455
48597
  }`;
48456
48598
  if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
48457
- propsDecls = `${ctx.helper("mergeDefaults")}(${propsDecls}, ${ctx.getString(
48458
- ctx.propsRuntimeDefaults
48459
- )})`;
48599
+ propsDecls = `/*#__PURE__*/${ctx.helper(
48600
+ "mergeDefaults"
48601
+ )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
48460
48602
  }
48461
48603
  return propsDecls;
48462
48604
  }
@@ -48505,7 +48647,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
48505
48647
  }
48506
48648
  }
48507
48649
  }
48508
- const finalKey = getEscapedKey(key);
48650
+ const finalKey = getEscapedPropName(key);
48509
48651
  if (!ctx.options.isProd) {
48510
48652
  return `${finalKey}: { ${concatStrings([
48511
48653
  `type: ${toRuntimeTypeString(type)}`,
@@ -48793,7 +48935,9 @@ function genRuntimeEmits(ctx) {
48793
48935
  }
48794
48936
  if (ctx.hasDefineModelCall) {
48795
48937
  let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
48796
- emitsDecl = emitsDecl ? `${ctx.helper("mergeModels")}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
48938
+ emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
48939
+ "mergeModels"
48940
+ )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
48797
48941
  }
48798
48942
  return emitsDecl;
48799
48943
  }
@@ -49777,7 +49921,7 @@ function isStaticNode(node) {
49777
49921
  return false;
49778
49922
  }
49779
49923
 
49780
- const version = "3.3.8";
49924
+ const version = "3.3.10";
49781
49925
  const parseCache = parseCache$1;
49782
49926
  const walk = walk$1;
49783
49927