@vue/compiler-sfc 3.4.24 → 3.4.26

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.24
2
+ * @vue/compiler-sfc v3.4.26
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -19306,29 +19306,39 @@ function genModelProps(ctx) {
19306
19306
  return;
19307
19307
  const isProd = !!ctx.options.isProd;
19308
19308
  let modelPropsDecl = "";
19309
- for (const [name, { type, options }] of Object.entries(ctx.modelDecls)) {
19309
+ for (const [name, { type, options: runtimeOptions }] of Object.entries(
19310
+ ctx.modelDecls
19311
+ )) {
19310
19312
  let skipCheck = false;
19313
+ let codegenOptions = ``;
19311
19314
  let runtimeTypes = type && inferRuntimeType(ctx, type);
19312
19315
  if (runtimeTypes) {
19313
19316
  const hasBoolean = runtimeTypes.includes("Boolean");
19317
+ const hasFunction = runtimeTypes.includes("Function");
19314
19318
  const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
19315
- if (isProd || hasUnknownType) {
19316
- runtimeTypes = runtimeTypes.filter(
19317
- (t) => t === "Boolean" || hasBoolean && t === "String" || t === "Function" && options
19318
- );
19319
- skipCheck = !isProd && hasUnknownType && runtimeTypes.length > 0;
19319
+ if (hasUnknownType) {
19320
+ if (hasBoolean || hasFunction) {
19321
+ runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
19322
+ skipCheck = true;
19323
+ } else {
19324
+ runtimeTypes = ["null"];
19325
+ }
19320
19326
  }
19327
+ if (!isProd) {
19328
+ codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
19329
+ } else if (hasBoolean || runtimeOptions && hasFunction) {
19330
+ codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
19331
+ } else ;
19321
19332
  }
19322
- let runtimeType = runtimeTypes && runtimeTypes.length > 0 && toRuntimeTypeString(runtimeTypes) || void 0;
19323
- const codegenOptions = concatStrings([
19324
- runtimeType && `type: ${runtimeType}`,
19325
- skipCheck && "skipCheck: true"
19326
- ]);
19327
19333
  let decl;
19328
- if (runtimeType && options) {
19329
- decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
19334
+ if (codegenOptions && runtimeOptions) {
19335
+ decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
19336
+ } else if (codegenOptions) {
19337
+ decl = `{ ${codegenOptions} }`;
19338
+ } else if (runtimeOptions) {
19339
+ decl = runtimeOptions;
19330
19340
  } else {
19331
- decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
19341
+ decl = `{}`;
19332
19342
  }
19333
19343
  modelPropsDecl += `
19334
19344
  ${JSON.stringify(name)}: ${decl},`;
@@ -20753,7 +20763,7 @@ function isStaticNode(node) {
20753
20763
  return false;
20754
20764
  }
20755
20765
 
20756
- const version = "3.4.24";
20766
+ const version = "3.4.26";
20757
20767
  const parseCache = parseCache$1;
20758
20768
  const errorMessages = {
20759
20769
  ...CompilerDOM.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.4.24
2
+ * @vue/compiler-sfc v3.4.26
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -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;
@@ -46882,29 +46877,39 @@ function genModelProps(ctx) {
46882
46877
  return;
46883
46878
  const isProd = !!ctx.options.isProd;
46884
46879
  let modelPropsDecl = "";
46885
- for (const [name, { type, options }] of Object.entries(ctx.modelDecls)) {
46880
+ for (const [name, { type, options: runtimeOptions }] of Object.entries(
46881
+ ctx.modelDecls
46882
+ )) {
46886
46883
  let skipCheck = false;
46884
+ let codegenOptions = ``;
46887
46885
  let runtimeTypes = type && inferRuntimeType(ctx, type);
46888
46886
  if (runtimeTypes) {
46889
46887
  const hasBoolean = runtimeTypes.includes("Boolean");
46888
+ const hasFunction = runtimeTypes.includes("Function");
46890
46889
  const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
46891
- if (isProd || hasUnknownType) {
46892
- runtimeTypes = runtimeTypes.filter(
46893
- (t) => t === "Boolean" || hasBoolean && t === "String" || t === "Function" && options
46894
- );
46895
- skipCheck = !isProd && hasUnknownType && runtimeTypes.length > 0;
46890
+ if (hasUnknownType) {
46891
+ if (hasBoolean || hasFunction) {
46892
+ runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
46893
+ skipCheck = true;
46894
+ } else {
46895
+ runtimeTypes = ["null"];
46896
+ }
46896
46897
  }
46898
+ if (!isProd) {
46899
+ codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
46900
+ } else if (hasBoolean || runtimeOptions && hasFunction) {
46901
+ codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
46902
+ } else ;
46897
46903
  }
46898
- let runtimeType = runtimeTypes && runtimeTypes.length > 0 && toRuntimeTypeString(runtimeTypes) || void 0;
46899
- const codegenOptions = concatStrings([
46900
- runtimeType && `type: ${runtimeType}`,
46901
- skipCheck && "skipCheck: true"
46902
- ]);
46903
46904
  let decl;
46904
- if (runtimeType && options) {
46905
- decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
46905
+ if (codegenOptions && runtimeOptions) {
46906
+ decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
46907
+ } else if (codegenOptions) {
46908
+ decl = `{ ${codegenOptions} }`;
46909
+ } else if (runtimeOptions) {
46910
+ decl = runtimeOptions;
46906
46911
  } else {
46907
- decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
46912
+ decl = `{}`;
46908
46913
  }
46909
46914
  modelPropsDecl += `
46910
46915
  ${JSON.stringify(name)}: ${decl},`;
@@ -48359,7 +48364,7 @@ var __spreadValues = (a, b) => {
48359
48364
  }
48360
48365
  return a;
48361
48366
  };
48362
- const version = "3.4.24";
48367
+ const version = "3.4.26";
48363
48368
  const parseCache = parseCache$1;
48364
48369
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48365
48370
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.4.24",
3
+ "version": "3.4.26",
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.24",
51
- "@vue/compiler-dom": "3.4.24",
52
- "@vue/compiler-ssr": "3.4.24",
53
- "@vue/shared": "3.4.24"
50
+ "@vue/compiler-core": "3.4.26",
51
+ "@vue/shared": "3.4.26",
52
+ "@vue/compiler-dom": "3.4.26",
53
+ "@vue/compiler-ssr": "3.4.26"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.24.0",