@vue/compiler-sfc 3.5.18 → 3.5.20

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.18
2
+ * @vue/compiler-sfc v3.5.20
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -23006,7 +23006,7 @@ function recordImport(node, imports) {
23006
23006
  };
23007
23007
  }
23008
23008
  }
23009
- function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
23009
+ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
23010
23010
  try {
23011
23011
  switch (node.type) {
23012
23012
  case "TSStringKeyword":
@@ -23079,12 +23079,38 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
23079
23079
  case "TSTypeReference": {
23080
23080
  const resolved = resolveTypeReference(ctx, node, scope);
23081
23081
  if (resolved) {
23082
- if (resolved.type === "TSTypeAliasDeclaration" && resolved.typeAnnotation.type === "TSFunctionType") {
23083
- return ["Function"];
23082
+ if (resolved.type === "TSTypeAliasDeclaration") {
23083
+ if (resolved.typeAnnotation.type === "TSFunctionType") {
23084
+ return ["Function"];
23085
+ }
23086
+ if (node.typeParameters) {
23087
+ const typeParams = /* @__PURE__ */ Object.create(null);
23088
+ if (resolved.typeParameters) {
23089
+ resolved.typeParameters.params.forEach((p, i) => {
23090
+ typeParams[p.name] = node.typeParameters.params[i];
23091
+ });
23092
+ }
23093
+ return inferRuntimeType(
23094
+ ctx,
23095
+ resolved.typeAnnotation,
23096
+ resolved._ownerScope,
23097
+ isKeyOf,
23098
+ typeParams
23099
+ );
23100
+ }
23084
23101
  }
23085
23102
  return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
23086
23103
  }
23087
23104
  if (node.typeName.type === "Identifier") {
23105
+ if (typeParameters && typeParameters[node.typeName.name]) {
23106
+ return inferRuntimeType(
23107
+ ctx,
23108
+ typeParameters[node.typeName.name],
23109
+ scope,
23110
+ isKeyOf,
23111
+ typeParameters
23112
+ );
23113
+ }
23088
23114
  if (isKeyOf) {
23089
23115
  switch (node.typeName.name) {
23090
23116
  case "String":
@@ -23207,11 +23233,15 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
23207
23233
  case "TSParenthesizedType":
23208
23234
  return inferRuntimeType(ctx, node.typeAnnotation, scope);
23209
23235
  case "TSUnionType":
23210
- return flattenTypes(ctx, node.types, scope, isKeyOf);
23236
+ return flattenTypes(ctx, node.types, scope, isKeyOf, typeParameters);
23211
23237
  case "TSIntersectionType": {
23212
- return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
23213
- (t) => t !== UNKNOWN_TYPE
23214
- );
23238
+ return flattenTypes(
23239
+ ctx,
23240
+ node.types,
23241
+ scope,
23242
+ isKeyOf,
23243
+ typeParameters
23244
+ ).filter((t) => t !== UNKNOWN_TYPE);
23215
23245
  }
23216
23246
  case "TSEnumDeclaration":
23217
23247
  return inferEnumType(node);
@@ -23266,14 +23296,16 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
23266
23296
  }
23267
23297
  return [UNKNOWN_TYPE];
23268
23298
  }
23269
- function flattenTypes(ctx, types, scope, isKeyOf = false) {
23299
+ function flattenTypes(ctx, types, scope, isKeyOf = false, typeParameters = void 0) {
23270
23300
  if (types.length === 1) {
23271
- return inferRuntimeType(ctx, types[0], scope, isKeyOf);
23301
+ return inferRuntimeType(ctx, types[0], scope, isKeyOf, typeParameters);
23272
23302
  }
23273
23303
  return [
23274
23304
  ...new Set(
23275
23305
  [].concat(
23276
- ...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
23306
+ ...types.map(
23307
+ (t) => inferRuntimeType(ctx, t, scope, isKeyOf, typeParameters)
23308
+ )
23277
23309
  )
23278
23310
  )
23279
23311
  ];
@@ -24158,23 +24190,23 @@ function compileScript(sfc, options) {
24158
24190
  Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
24159
24191
  );
24160
24192
  }
24161
- const ctx = new ScriptCompileContext(sfc, options);
24162
24193
  const { script, scriptSetup, source, filename } = sfc;
24163
24194
  const hoistStatic = options.hoistStatic !== false && !script;
24164
24195
  const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
24165
24196
  const scriptLang = script && script.lang;
24166
24197
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
24198
+ if (script && scriptSetup && scriptLang !== scriptSetupLang) {
24199
+ throw new Error(
24200
+ `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
24201
+ );
24202
+ }
24203
+ const ctx = new ScriptCompileContext(sfc, options);
24167
24204
  if (!scriptSetup) {
24168
24205
  if (!script) {
24169
24206
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
24170
24207
  }
24171
24208
  return processNormalScript(ctx, scopeId);
24172
24209
  }
24173
- if (script && scriptLang !== scriptSetupLang) {
24174
- throw new Error(
24175
- `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
24176
- );
24177
- }
24178
24210
  if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
24179
24211
  return scriptSetup;
24180
24212
  }
@@ -24982,7 +25014,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
24982
25014
  return generator.toJSON();
24983
25015
  }
24984
25016
 
24985
- const version = "3.5.18";
25017
+ const version = "3.5.20";
24986
25018
  const parseCache = parseCache$1;
24987
25019
  const errorMessages = {
24988
25020
  ...CompilerDOM.errorMessages,
@@ -464,7 +464,7 @@ export declare function registerTS(_loadTS: () => typeof TS): void;
464
464
  * @private
465
465
  */
466
466
  export declare function invalidateTypeCache(filename: string): void;
467
- export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean): string[];
467
+ export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean, typeParameters?: Record<string, Node>): string[];
468
468
 
469
469
  export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
470
470
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.18
2
+ * @vue/compiler-sfc v3.5.20
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -39,10 +39,10 @@ const isBuiltInDirective = /* @__PURE__ */ makeMap(
39
39
  );
40
40
  const cacheStringFunction = (fn) => {
41
41
  const cache = /* @__PURE__ */ Object.create(null);
42
- return (str) => {
42
+ return ((str) => {
43
43
  const hit = cache[str];
44
44
  return hit || (cache[str] = fn(str));
45
- };
45
+ });
46
46
  };
47
47
  const camelizeRE = /-(\w)/g;
48
48
  const camelize = cacheStringFunction(
@@ -3219,11 +3219,14 @@ function requireLib () {
3219
3219
  finishCallExpression(unfinished, optional) {
3220
3220
  const node = super.finishCallExpression(unfinished, optional);
3221
3221
  if (node.callee.type === "Import") {
3222
- var _ref, _ref2;
3222
+ var _ref;
3223
3223
  this.castNodeTo(node, "ImportExpression");
3224
3224
  node.source = node.arguments[0];
3225
3225
  node.options = (_ref = node.arguments[1]) != null ? _ref : null;
3226
- node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
3226
+ {
3227
+ var _ref2;
3228
+ node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
3229
+ }
3227
3230
  delete node.arguments;
3228
3231
  delete node.callee;
3229
3232
  } else if (node.type === "OptionalCallExpression") {
@@ -10434,6 +10437,7 @@ function requireLib () {
10434
10437
  this.expect(14);
10435
10438
  withProperty.value = this.tsParseImportTypeWithPropertyValue();
10436
10439
  node.properties = [this.finishObjectProperty(withProperty)];
10440
+ this.eat(12);
10437
10441
  this.expect(8);
10438
10442
  return this.finishNode(node, "ObjectExpression");
10439
10443
  }
@@ -11733,6 +11737,7 @@ function requireLib () {
11733
11737
  if (!noCalls && this.atPossibleAsyncArrow(base)) {
11734
11738
  const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
11735
11739
  if (asyncArrowFn) {
11740
+ state.stop = true;
11736
11741
  return asyncArrowFn;
11737
11742
  }
11738
11743
  }
@@ -18682,7 +18687,6 @@ function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
18682
18687
  }
18683
18688
  }
18684
18689
  let cachedAsArray = false;
18685
- const slotCacheKeys = [];
18686
18690
  if (toCache.length === children.length && node.type === 1) {
18687
18691
  if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
18688
18692
  node.codegenNode.children = getCacheExpression(
@@ -18692,7 +18696,6 @@ function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
18692
18696
  } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray$3(node.codegenNode.children) && node.codegenNode.children.type === 15) {
18693
18697
  const slot = getSlotNode(node.codegenNode, "default");
18694
18698
  if (slot) {
18695
- slotCacheKeys.push(context.cached.length);
18696
18699
  slot.returns = getCacheExpression(
18697
18700
  createArrayExpression(slot.returns)
18698
18701
  );
@@ -18702,7 +18705,6 @@ function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
18702
18705
  const slotName = findDir(node, "slot", true);
18703
18706
  const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
18704
18707
  if (slot) {
18705
- slotCacheKeys.push(context.cached.length);
18706
18708
  slot.returns = getCacheExpression(
18707
18709
  createArrayExpression(slot.returns)
18708
18710
  );
@@ -18712,23 +18714,12 @@ function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
18712
18714
  }
18713
18715
  if (!cachedAsArray) {
18714
18716
  for (const child of toCache) {
18715
- slotCacheKeys.push(context.cached.length);
18716
18717
  child.codegenNode = context.cache(child.codegenNode);
18717
18718
  }
18718
18719
  }
18719
- if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray$3(node.codegenNode.children) && node.codegenNode.children.type === 15) {
18720
- node.codegenNode.children.properties.push(
18721
- createObjectProperty(
18722
- `__`,
18723
- createSimpleExpression(JSON.stringify(slotCacheKeys), false)
18724
- )
18725
- );
18726
- }
18727
18720
  function getCacheExpression(value) {
18728
18721
  const exp = context.cache(value);
18729
- if (inFor && context.hmr) {
18730
- exp.needArraySpread = true;
18731
- }
18722
+ exp.needArraySpread = true;
18732
18723
  return exp;
18733
18724
  }
18734
18725
  function getSlotNode(node2, name) {
@@ -23714,7 +23705,7 @@ function processIf(node, dir, context, processCodegen) {
23714
23705
  continue;
23715
23706
  }
23716
23707
  if (sibling && sibling.type === 9) {
23717
- if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
23708
+ if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
23718
23709
  context.onError(
23719
23710
  createCompilerError(30, node.loc)
23720
23711
  );
@@ -25416,7 +25407,7 @@ const seen = /* @__PURE__ */ new WeakSet();
25416
25407
  const transformMemo = (node, context) => {
25417
25408
  if (node.type === 1) {
25418
25409
  const dir = findDir(node, "memo");
25419
- if (!dir || seen.has(node)) {
25410
+ if (!dir || seen.has(node) || context.inSSR) {
25420
25411
  return;
25421
25412
  }
25422
25413
  seen.add(node);
@@ -48441,7 +48432,7 @@ function recordImport(node, imports) {
48441
48432
  };
48442
48433
  }
48443
48434
  }
48444
- function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
48435
+ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
48445
48436
  try {
48446
48437
  switch (node.type) {
48447
48438
  case "TSStringKeyword":
@@ -48514,12 +48505,38 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48514
48505
  case "TSTypeReference": {
48515
48506
  const resolved = resolveTypeReference(ctx, node, scope);
48516
48507
  if (resolved) {
48517
- if (resolved.type === "TSTypeAliasDeclaration" && resolved.typeAnnotation.type === "TSFunctionType") {
48518
- return ["Function"];
48508
+ if (resolved.type === "TSTypeAliasDeclaration") {
48509
+ if (resolved.typeAnnotation.type === "TSFunctionType") {
48510
+ return ["Function"];
48511
+ }
48512
+ if (node.typeParameters) {
48513
+ const typeParams = /* @__PURE__ */ Object.create(null);
48514
+ if (resolved.typeParameters) {
48515
+ resolved.typeParameters.params.forEach((p, i) => {
48516
+ typeParams[p.name] = node.typeParameters.params[i];
48517
+ });
48518
+ }
48519
+ return inferRuntimeType(
48520
+ ctx,
48521
+ resolved.typeAnnotation,
48522
+ resolved._ownerScope,
48523
+ isKeyOf,
48524
+ typeParams
48525
+ );
48526
+ }
48519
48527
  }
48520
48528
  return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
48521
48529
  }
48522
48530
  if (node.typeName.type === "Identifier") {
48531
+ if (typeParameters && typeParameters[node.typeName.name]) {
48532
+ return inferRuntimeType(
48533
+ ctx,
48534
+ typeParameters[node.typeName.name],
48535
+ scope,
48536
+ isKeyOf,
48537
+ typeParameters
48538
+ );
48539
+ }
48523
48540
  if (isKeyOf) {
48524
48541
  switch (node.typeName.name) {
48525
48542
  case "String":
@@ -48642,11 +48659,15 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48642
48659
  case "TSParenthesizedType":
48643
48660
  return inferRuntimeType(ctx, node.typeAnnotation, scope);
48644
48661
  case "TSUnionType":
48645
- return flattenTypes(ctx, node.types, scope, isKeyOf);
48662
+ return flattenTypes(ctx, node.types, scope, isKeyOf, typeParameters);
48646
48663
  case "TSIntersectionType": {
48647
- return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
48648
- (t) => t !== UNKNOWN_TYPE
48649
- );
48664
+ return flattenTypes(
48665
+ ctx,
48666
+ node.types,
48667
+ scope,
48668
+ isKeyOf,
48669
+ typeParameters
48670
+ ).filter((t) => t !== UNKNOWN_TYPE);
48650
48671
  }
48651
48672
  case "TSEnumDeclaration":
48652
48673
  return inferEnumType(node);
@@ -48701,14 +48722,16 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48701
48722
  }
48702
48723
  return [UNKNOWN_TYPE];
48703
48724
  }
48704
- function flattenTypes(ctx, types, scope, isKeyOf = false) {
48725
+ function flattenTypes(ctx, types, scope, isKeyOf = false, typeParameters = void 0) {
48705
48726
  if (types.length === 1) {
48706
- return inferRuntimeType(ctx, types[0], scope, isKeyOf);
48727
+ return inferRuntimeType(ctx, types[0], scope, isKeyOf, typeParameters);
48707
48728
  }
48708
48729
  return [
48709
48730
  ...new Set(
48710
48731
  [].concat(
48711
- ...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
48732
+ ...types.map(
48733
+ (t) => inferRuntimeType(ctx, t, scope, isKeyOf, typeParameters)
48734
+ )
48712
48735
  )
48713
48736
  )
48714
48737
  ];
@@ -49612,23 +49635,23 @@ function compileScript(sfc, options) {
49612
49635
  Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
49613
49636
  );
49614
49637
  }
49615
- const ctx = new ScriptCompileContext(sfc, options);
49616
49638
  const { script, scriptSetup, source, filename } = sfc;
49617
49639
  const hoistStatic = options.hoistStatic !== false && !script;
49618
49640
  const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
49619
49641
  const scriptLang = script && script.lang;
49620
49642
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
49643
+ if (script && scriptSetup && scriptLang !== scriptSetupLang) {
49644
+ throw new Error(
49645
+ `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
49646
+ );
49647
+ }
49648
+ const ctx = new ScriptCompileContext(sfc, options);
49621
49649
  if (!scriptSetup) {
49622
49650
  if (!script) {
49623
49651
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
49624
49652
  }
49625
49653
  return processNormalScript(ctx, scopeId);
49626
49654
  }
49627
- if (script && scriptLang !== scriptSetupLang) {
49628
- throw new Error(
49629
- `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
49630
- );
49631
- }
49632
49655
  if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
49633
49656
  return scriptSetup;
49634
49657
  }
@@ -50447,7 +50470,7 @@ var __spreadValues = (a, b) => {
50447
50470
  }
50448
50471
  return a;
50449
50472
  };
50450
- const version = "3.5.18";
50473
+ const version = "3.5.20";
50451
50474
  const parseCache = parseCache$1;
50452
50475
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
50453
50476
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.5.18",
3
+ "version": "3.5.20",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -42,18 +42,18 @@
42
42
  },
43
43
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
44
44
  "dependencies": {
45
- "@babel/parser": "^7.28.0",
45
+ "@babel/parser": "^7.28.3",
46
46
  "estree-walker": "^2.0.2",
47
47
  "magic-string": "^0.30.17",
48
48
  "postcss": "^8.5.6",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-dom": "3.5.18",
51
- "@vue/compiler-ssr": "3.5.18",
52
- "@vue/shared": "3.5.18",
53
- "@vue/compiler-core": "3.5.18"
50
+ "@vue/compiler-core": "3.5.20",
51
+ "@vue/compiler-dom": "3.5.20",
52
+ "@vue/compiler-ssr": "3.5.20",
53
+ "@vue/shared": "3.5.20"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/types": "^7.28.1",
56
+ "@babel/types": "^7.28.2",
57
57
  "@vue/consolidate": "^1.0.0",
58
58
  "hash-sum": "^2.0.0",
59
59
  "lru-cache": "10.1.0",
@@ -62,6 +62,6 @@
62
62
  "postcss-modules": "^6.0.1",
63
63
  "postcss-selector-parser": "^7.1.0",
64
64
  "pug": "^3.0.3",
65
- "sass": "^1.89.2"
65
+ "sass": "^1.90.0"
66
66
  }
67
67
  }