@vue/compiler-sfc 3.4.25 → 3.4.27

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.4.25
2
+ * @vue/compiler-sfc v3.4.27
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -4826,7 +4826,7 @@ types$1.UNIVERSAL = UNIVERSAL;
4826
4826
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4827
4827
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4828
4828
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4829
- function _arrayLikeToArray(arr, len) { len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4829
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4830
4830
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4831
4831
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4832
4832
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
@@ -12000,6 +12000,10 @@ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
12000
12000
  function baseSlice(array, start, end) {
12001
12001
  var index = -1,
12002
12002
  length = array.length;
12003
+
12004
+ if (start < 0) {
12005
+ start = -start > length ? 0 : (length + start);
12006
+ }
12003
12007
  end = end > length ? length : end;
12004
12008
  if (end < 0) {
12005
12009
  end += length;
@@ -12046,7 +12050,7 @@ function baseToString(value) {
12046
12050
  function castSlice(array, start, end) {
12047
12051
  var length = array.length;
12048
12052
  end = end === undefined ? length : end;
12049
- return baseSlice(array, start, end);
12053
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
12050
12054
  }
12051
12055
 
12052
12056
  /**
@@ -18934,7 +18938,7 @@ function recordImport(node, imports) {
18934
18938
  };
18935
18939
  }
18936
18940
  }
18937
- function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)) {
18941
+ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
18938
18942
  try {
18939
18943
  switch (node.type) {
18940
18944
  case "TSStringKeyword":
@@ -18952,7 +18956,13 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
18952
18956
  const types = /* @__PURE__ */ new Set();
18953
18957
  const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
18954
18958
  for (const m of members) {
18955
- if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
18959
+ if (isKeyOf) {
18960
+ if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
18961
+ types.add("Number");
18962
+ } else {
18963
+ types.add("String");
18964
+ }
18965
+ } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
18956
18966
  types.add("Function");
18957
18967
  } else {
18958
18968
  types.add("Object");
@@ -18990,9 +19000,20 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
18990
19000
  case "TSTypeReference": {
18991
19001
  const resolved = resolveTypeReference(ctx, node, scope);
18992
19002
  if (resolved) {
18993
- return inferRuntimeType(ctx, resolved, resolved._ownerScope);
19003
+ return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
18994
19004
  }
18995
19005
  if (node.typeName.type === "Identifier") {
19006
+ if (isKeyOf) {
19007
+ switch (node.typeName.name) {
19008
+ case "String":
19009
+ case "Array":
19010
+ case "ArrayLike":
19011
+ case "ReadonlyArray":
19012
+ return ["String", "Number"];
19013
+ default:
19014
+ return ["String"];
19015
+ }
19016
+ }
18996
19017
  switch (node.typeName.name) {
18997
19018
  case "Array":
18998
19019
  case "Function":
@@ -19095,13 +19116,18 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
19095
19116
  if (id.type === "Identifier") {
19096
19117
  const matched = scope.declares[id.name];
19097
19118
  if (matched) {
19098
- return inferRuntimeType(ctx, matched, matched._ownerScope);
19119
+ return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
19099
19120
  }
19100
19121
  }
19101
19122
  break;
19102
19123
  }
19103
19124
  case "TSTypeOperator": {
19104
- return inferRuntimeType(ctx, node.typeAnnotation, scope);
19125
+ return inferRuntimeType(
19126
+ ctx,
19127
+ node.typeAnnotation,
19128
+ scope,
19129
+ node.operator === "keyof"
19130
+ );
19105
19131
  }
19106
19132
  }
19107
19133
  } catch (e) {
@@ -20763,7 +20789,7 @@ function isStaticNode(node) {
20763
20789
  return false;
20764
20790
  }
20765
20791
 
20766
- const version = "3.4.25";
20792
+ const version = "3.4.27";
20767
20793
  const parseCache = parseCache$1;
20768
20794
  const errorMessages = {
20769
20795
  ...CompilerDOM.errorMessages,
@@ -467,7 +467,7 @@ export declare function registerTS(_loadTS: () => typeof TS): void;
467
467
  * @private
468
468
  */
469
469
  export declare function invalidateTypeCache(filename: string): void;
470
- export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope): string[];
470
+ export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean): string[];
471
471
 
472
472
  export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
473
473
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.4.25
2
+ * @vue/compiler-sfc v3.4.27
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -166,8 +166,8 @@ function stringifyStyle(styles) {
166
166
  }
167
167
  for (const key in styles) {
168
168
  const value = styles[key];
169
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
170
169
  if (isString$2(value) || typeof value === "number") {
170
+ const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
171
171
  ret += `${normalizedKey}:${value};`;
172
172
  }
173
173
  }
@@ -17247,11 +17247,10 @@ const tokenizer$2 = new Tokenizer$1(stack, {
17247
17247
  }
17248
17248
  },
17249
17249
  onselfclosingtag(end) {
17250
- var _a;
17251
17250
  const name = currentOpenTag.tag;
17252
17251
  currentOpenTag.isSelfClosing = true;
17253
17252
  endOpenTag(end);
17254
- if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
17253
+ if (stack[0] && stack[0].tag === name) {
17255
17254
  onCloseTag(stack.shift(), end);
17256
17255
  }
17257
17256
  },
@@ -17557,7 +17556,7 @@ function endOpenTag(end) {
17557
17556
  function onText(content, start, end) {
17558
17557
  const parent = stack[0] || currentRoot;
17559
17558
  const lastNode = parent.children[parent.children.length - 1];
17560
- if ((lastNode == null ? void 0 : lastNode.type) === 2) {
17559
+ if (lastNode && lastNode.type === 2) {
17561
17560
  lastNode.content += content;
17562
17561
  setLocEnd(lastNode.loc, end);
17563
17562
  } else {
@@ -17633,11 +17632,10 @@ function isFragmentTemplate({ tag, props }) {
17633
17632
  return false;
17634
17633
  }
17635
17634
  function isComponent({ tag, props }) {
17636
- var _a;
17637
17635
  if (currentOptions.isCustomElement(tag)) {
17638
17636
  return false;
17639
17637
  }
17640
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
17638
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
17641
17639
  return true;
17642
17640
  }
17643
17641
  for (let i = 0; i < props.length; i++) {
@@ -17657,7 +17655,6 @@ function isUpperCase(c) {
17657
17655
  }
17658
17656
  const windowsNewlineRE = /\r\n/g;
17659
17657
  function condenseWhitespace(nodes, tag) {
17660
- var _a, _b;
17661
17658
  const shouldCondense = currentOptions.whitespace !== "preserve";
17662
17659
  let removedWhitespace = false;
17663
17660
  for (let i = 0; i < nodes.length; i++) {
@@ -17665,8 +17662,8 @@ function condenseWhitespace(nodes, tag) {
17665
17662
  if (node.type === 2) {
17666
17663
  if (!inPre) {
17667
17664
  if (isAllWhitespace(node.content)) {
17668
- const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
17669
- const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
17665
+ const prev = nodes[i - 1] && nodes[i - 1].type;
17666
+ const next = nodes[i + 1] && nodes[i + 1].type;
17670
17667
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
17671
17668
  removedWhitespace = true;
17672
17669
  nodes[i] = null;
@@ -17826,7 +17823,7 @@ function baseParse(input, options) {
17826
17823
  }
17827
17824
  tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
17828
17825
  tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
17829
- const delimiters = options == null ? void 0 : options.delimiters;
17826
+ const delimiters = options && options.delimiters;
17830
17827
  if (delimiters) {
17831
17828
  tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
17832
17829
  tokenizer$2.delimiterClose = toCharCodes(delimiters[1]);
@@ -22510,7 +22507,6 @@ function genReturnStatement({ returns }, context) {
22510
22507
  }
22511
22508
 
22512
22509
  const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
22513
- const constantBailRE = /\w\s*\(|\.[^\d]/;
22514
22510
  const transformExpression = (node, context) => {
22515
22511
  if (node.type === 5) {
22516
22512
  node.content = processExpression(
@@ -22605,7 +22601,6 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22605
22601
  return `_ctx.${raw}`;
22606
22602
  };
22607
22603
  const rawExp = node.content;
22608
- const bailConstant = constantBailRE.test(rawExp);
22609
22604
  let ast = node.ast;
22610
22605
  if (ast === false) {
22611
22606
  return node;
@@ -22664,7 +22659,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22664
22659
  node2.name = rewriteIdentifier(node2.name, parent, node2);
22665
22660
  ids.push(node2);
22666
22661
  } else {
22667
- if (!(needPrefix && isLocal) && !bailConstant) {
22662
+ if (!(needPrefix && isLocal) && parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression") {
22668
22663
  node2.isConstant = true;
22669
22664
  }
22670
22665
  ids.push(node2);
@@ -22708,7 +22703,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22708
22703
  ret.ast = ast;
22709
22704
  } else {
22710
22705
  ret = node;
22711
- ret.constType = bailConstant ? 0 : 3;
22706
+ ret.constType = 3;
22712
22707
  }
22713
22708
  ret.identifiers = Object.keys(knownIds);
22714
22709
  return ret;
@@ -24149,7 +24144,7 @@ function processSlotOutlet(node, context) {
24149
24144
  };
24150
24145
  }
24151
24146
 
24152
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
24147
+ const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
24153
24148
  const transformOn$1 = (dir, node, context, augmentor) => {
24154
24149
  const { loc, modifiers, arg } = dir;
24155
24150
  if (!dir.exp && !modifiers.length) {
@@ -25119,6 +25114,7 @@ function analyzeNode(node) {
25119
25114
  return false;
25120
25115
  };
25121
25116
  function walk(node2) {
25117
+ const isOptionTag = node2.tag === "option" && node2.ns === 0;
25122
25118
  for (let i = 0; i < node2.props.length; i++) {
25123
25119
  const p = node2.props[i];
25124
25120
  if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
@@ -25131,6 +25127,9 @@ function analyzeNode(node) {
25131
25127
  if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
25132
25128
  return bail();
25133
25129
  }
25130
+ if (isOptionTag && isStaticArgOf(p.arg, "value") && p.exp && p.exp.ast && p.exp.ast.type !== "StringLiteral") {
25131
+ return bail();
25132
+ }
25134
25133
  }
25135
25134
  }
25136
25135
  for (let i = 0; i < node2.children.length; i++) {
@@ -37225,7 +37224,7 @@ types.UNIVERSAL = UNIVERSAL;
37225
37224
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37226
37225
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
37227
37226
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37228
- function _arrayLikeToArray(arr, len) { len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37227
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37229
37228
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
37230
37229
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37231
37230
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
@@ -46510,7 +46509,7 @@ function recordImport(node, imports) {
46510
46509
  };
46511
46510
  }
46512
46511
  }
46513
- function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)) {
46512
+ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
46514
46513
  try {
46515
46514
  switch (node.type) {
46516
46515
  case "TSStringKeyword":
@@ -46528,7 +46527,13 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
46528
46527
  const types = /* @__PURE__ */ new Set();
46529
46528
  const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
46530
46529
  for (const m of members) {
46531
- if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
46530
+ if (isKeyOf) {
46531
+ if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
46532
+ types.add("Number");
46533
+ } else {
46534
+ types.add("String");
46535
+ }
46536
+ } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
46532
46537
  types.add("Function");
46533
46538
  } else {
46534
46539
  types.add("Object");
@@ -46566,9 +46571,20 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
46566
46571
  case "TSTypeReference": {
46567
46572
  const resolved = resolveTypeReference(ctx, node, scope);
46568
46573
  if (resolved) {
46569
- return inferRuntimeType(ctx, resolved, resolved._ownerScope);
46574
+ return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
46570
46575
  }
46571
46576
  if (node.typeName.type === "Identifier") {
46577
+ if (isKeyOf) {
46578
+ switch (node.typeName.name) {
46579
+ case "String":
46580
+ case "Array":
46581
+ case "ArrayLike":
46582
+ case "ReadonlyArray":
46583
+ return ["String", "Number"];
46584
+ default:
46585
+ return ["String"];
46586
+ }
46587
+ }
46572
46588
  switch (node.typeName.name) {
46573
46589
  case "Array":
46574
46590
  case "Function":
@@ -46671,13 +46687,18 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
46671
46687
  if (id.type === "Identifier") {
46672
46688
  const matched = scope.declares[id.name];
46673
46689
  if (matched) {
46674
- return inferRuntimeType(ctx, matched, matched._ownerScope);
46690
+ return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
46675
46691
  }
46676
46692
  }
46677
46693
  break;
46678
46694
  }
46679
46695
  case "TSTypeOperator": {
46680
- return inferRuntimeType(ctx, node.typeAnnotation, scope);
46696
+ return inferRuntimeType(
46697
+ ctx,
46698
+ node.typeAnnotation,
46699
+ scope,
46700
+ node.operator === "keyof"
46701
+ );
46681
46702
  }
46682
46703
  }
46683
46704
  } catch (e) {
@@ -48369,7 +48390,7 @@ var __spreadValues = (a, b) => {
48369
48390
  }
48370
48391
  return a;
48371
48392
  };
48372
- const version = "3.4.25";
48393
+ const version = "3.4.27";
48373
48394
  const parseCache = parseCache$1;
48374
48395
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48375
48396
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.4.25",
3
+ "version": "3.4.27",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -47,10 +47,10 @@
47
47
  "magic-string": "^0.30.10",
48
48
  "postcss": "^8.4.38",
49
49
  "source-map-js": "^1.2.0",
50
- "@vue/compiler-core": "3.4.25",
51
- "@vue/compiler-ssr": "3.4.25",
52
- "@vue/compiler-dom": "3.4.25",
53
- "@vue/shared": "3.4.25"
50
+ "@vue/shared": "3.4.27",
51
+ "@vue/compiler-core": "3.4.27",
52
+ "@vue/compiler-ssr": "3.4.27",
53
+ "@vue/compiler-dom": "3.4.27"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.24.0",
@@ -62,6 +62,6 @@
62
62
  "postcss-modules": "^6.0.0",
63
63
  "postcss-selector-parser": "^6.0.16",
64
64
  "pug": "^3.0.2",
65
- "sass": "^1.75.0"
65
+ "sass": "^1.76.0"
66
66
  }
67
67
  }