@vue/compiler-sfc 3.4.4 → 3.4.5

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.
@@ -19098,7 +19098,8 @@ function processDefineModel(ctx, node, declId) {
19098
19098
  let modelName;
19099
19099
  let options;
19100
19100
  const arg0 = node.arguments[0] && CompilerDOM.unwrapTSNode(node.arguments[0]);
19101
- if (arg0 && arg0.type === "StringLiteral") {
19101
+ const hasName = arg0 && arg0.type === "StringLiteral";
19102
+ if (hasName) {
19102
19103
  modelName = arg0.value;
19103
19104
  options = node.arguments[1];
19104
19105
  } else {
@@ -19109,29 +19110,27 @@ function processDefineModel(ctx, node, declId) {
19109
19110
  ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
19110
19111
  }
19111
19112
  let optionsString = options && ctx.getString(options);
19112
- let runtimeOptions = "";
19113
- let transformOptions = "";
19114
- if (options) {
19115
- if (options.type === "ObjectExpression") {
19116
- for (let i = options.properties.length - 1; i >= 0; i--) {
19117
- const p = options.properties[i];
19118
- if (p.type === "SpreadElement" || p.computed) {
19119
- runtimeOptions = optionsString;
19120
- break;
19121
- }
19122
- if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
19123
- transformOptions = ctx.getString(p) + ", " + transformOptions;
19124
- const offset = p.start - options.start;
19125
- const next = options.properties[i + 1];
19126
- const end = (next ? next.start : options.end - 1) - options.start;
19127
- optionsString = optionsString.slice(0, offset) + optionsString.slice(end);
19128
- }
19129
- }
19130
- if (!runtimeOptions && transformOptions) {
19131
- runtimeOptions = `{ ${transformOptions} }`;
19113
+ let optionsRemoved = !options;
19114
+ if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
19115
+ let removed = 0;
19116
+ for (let i = options.properties.length - 1; i >= 0; i--) {
19117
+ const p = options.properties[i];
19118
+ const next = options.properties[i + 1];
19119
+ const start = p.start;
19120
+ const end = next ? next.start : options.end - 1;
19121
+ if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
19122
+ optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
19123
+ } else {
19124
+ removed++;
19125
+ ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
19132
19126
  }
19133
- } else {
19134
- runtimeOptions = optionsString;
19127
+ }
19128
+ if (removed === options.properties.length) {
19129
+ optionsRemoved = true;
19130
+ ctx.s.remove(
19131
+ ctx.startOffset + (hasName ? arg0.end : options.start),
19132
+ ctx.startOffset + options.end
19133
+ );
19135
19134
  }
19136
19135
  }
19137
19136
  ctx.modelDecls[modelName] = {
@@ -19141,9 +19140,13 @@ function processDefineModel(ctx, node, declId) {
19141
19140
  };
19142
19141
  ctx.bindingMetadata[modelName] = "props";
19143
19142
  ctx.s.overwrite(
19144
- ctx.startOffset + node.start,
19145
- ctx.startOffset + node.end,
19146
- `${ctx.helper("useModel")}(__props, ${JSON.stringify(modelName)}${runtimeOptions ? `, ${runtimeOptions}` : ``})`
19143
+ ctx.startOffset + node.callee.start,
19144
+ ctx.startOffset + node.callee.end,
19145
+ ctx.helper("useModel")
19146
+ );
19147
+ ctx.s.appendLeft(
19148
+ ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
19149
+ `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
19147
19150
  );
19148
19151
  return true;
19149
19152
  }
@@ -20591,7 +20594,7 @@ function isStaticNode(node) {
20591
20594
  return false;
20592
20595
  }
20593
20596
 
20594
- const version = "3.4.4";
20597
+ const version = "3.4.5";
20595
20598
  const parseCache = parseCache$1;
20596
20599
  const errorMessages = {
20597
20600
  ...CompilerDOM.errorMessages,
@@ -17098,6 +17098,18 @@ function isInDestructureAssignment(parent, parentStack) {
17098
17098
  }
17099
17099
  return false;
17100
17100
  }
17101
+ function isInNewExpression(parentStack) {
17102
+ let i = parentStack.length;
17103
+ while (i--) {
17104
+ const p = parentStack[i];
17105
+ if (p.type === "NewExpression") {
17106
+ return true;
17107
+ } else if (p.type !== "MemberExpression") {
17108
+ break;
17109
+ }
17110
+ }
17111
+ return false;
17112
+ }
17101
17113
  function walkFunctionParams(node, onIdent) {
17102
17114
  for (const p of node.params) {
17103
17115
  for (const id of extractIdentifiers$1(p)) {
@@ -22974,12 +22986,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
22974
22986
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
22975
22987
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
22976
22988
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
22989
+ const isNewExpression = parent && isInNewExpression(parentStack);
22990
+ const wrapWithUnref = (raw2) => {
22991
+ const wrapped = `${context.helperString(UNREF)}(${raw2})`;
22992
+ return isNewExpression ? `(${wrapped})` : wrapped;
22993
+ };
22977
22994
  if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
22978
22995
  return raw;
22979
22996
  } else if (type === "setup-ref") {
22980
22997
  return `${raw}.value`;
22981
22998
  } else if (type === "setup-maybe-ref") {
22982
- return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : `${context.helperString(UNREF)}(${raw})`;
22999
+ return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
22983
23000
  } else if (type === "setup-let") {
22984
23001
  if (isAssignmentLVal) {
22985
23002
  const { right: rVal, operator } = parent;
@@ -23006,7 +23023,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
23006
23023
  } else if (isDestructureAssignment) {
23007
23024
  return raw;
23008
23025
  } else {
23009
- return `${context.helperString(UNREF)}(${raw})`;
23026
+ return wrapWithUnref(raw);
23010
23027
  }
23011
23028
  } else if (type === "props") {
23012
23029
  return genPropsAccessExp(raw);
@@ -25796,6 +25813,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
25796
25813
  isCoreComponent: isCoreComponent,
25797
25814
  isFunctionType: isFunctionType,
25798
25815
  isInDestructureAssignment: isInDestructureAssignment,
25816
+ isInNewExpression: isInNewExpression,
25799
25817
  isMemberExpression: isMemberExpression,
25800
25818
  isMemberExpressionBrowser: isMemberExpressionBrowser,
25801
25819
  isMemberExpressionNode: isMemberExpressionNode,
@@ -31986,7 +32004,7 @@ function subTransform(node, options, parentContext) {
31986
32004
  function clone(v) {
31987
32005
  if (isArray$3(v)) {
31988
32006
  return v.map(clone);
31989
- } else if (isObject$2(v)) {
32007
+ } else if (isPlainObject(v)) {
31990
32008
  const res = {};
31991
32009
  for (const key in v) {
31992
32010
  res[key] = clone(v[key]);
@@ -47086,7 +47104,8 @@ function processDefineModel(ctx, node, declId) {
47086
47104
  let modelName;
47087
47105
  let options;
47088
47106
  const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
47089
- if (arg0 && arg0.type === "StringLiteral") {
47107
+ const hasName = arg0 && arg0.type === "StringLiteral";
47108
+ if (hasName) {
47090
47109
  modelName = arg0.value;
47091
47110
  options = node.arguments[1];
47092
47111
  } else {
@@ -47097,29 +47116,27 @@ function processDefineModel(ctx, node, declId) {
47097
47116
  ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
47098
47117
  }
47099
47118
  let optionsString = options && ctx.getString(options);
47100
- let runtimeOptions = "";
47101
- let transformOptions = "";
47102
- if (options) {
47103
- if (options.type === "ObjectExpression") {
47104
- for (let i = options.properties.length - 1; i >= 0; i--) {
47105
- const p = options.properties[i];
47106
- if (p.type === "SpreadElement" || p.computed) {
47107
- runtimeOptions = optionsString;
47108
- break;
47109
- }
47110
- if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
47111
- transformOptions = ctx.getString(p) + ", " + transformOptions;
47112
- const offset = p.start - options.start;
47113
- const next = options.properties[i + 1];
47114
- const end = (next ? next.start : options.end - 1) - options.start;
47115
- optionsString = optionsString.slice(0, offset) + optionsString.slice(end);
47116
- }
47117
- }
47118
- if (!runtimeOptions && transformOptions) {
47119
- runtimeOptions = `{ ${transformOptions} }`;
47119
+ let optionsRemoved = !options;
47120
+ if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
47121
+ let removed = 0;
47122
+ for (let i = options.properties.length - 1; i >= 0; i--) {
47123
+ const p = options.properties[i];
47124
+ const next = options.properties[i + 1];
47125
+ const start = p.start;
47126
+ const end = next ? next.start : options.end - 1;
47127
+ if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
47128
+ optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
47129
+ } else {
47130
+ removed++;
47131
+ ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
47120
47132
  }
47121
- } else {
47122
- runtimeOptions = optionsString;
47133
+ }
47134
+ if (removed === options.properties.length) {
47135
+ optionsRemoved = true;
47136
+ ctx.s.remove(
47137
+ ctx.startOffset + (hasName ? arg0.end : options.start),
47138
+ ctx.startOffset + options.end
47139
+ );
47123
47140
  }
47124
47141
  }
47125
47142
  ctx.modelDecls[modelName] = {
@@ -47129,9 +47146,13 @@ function processDefineModel(ctx, node, declId) {
47129
47146
  };
47130
47147
  ctx.bindingMetadata[modelName] = "props";
47131
47148
  ctx.s.overwrite(
47132
- ctx.startOffset + node.start,
47133
- ctx.startOffset + node.end,
47134
- `${ctx.helper("useModel")}(__props, ${JSON.stringify(modelName)}${runtimeOptions ? `, ${runtimeOptions}` : ``})`
47149
+ ctx.startOffset + node.callee.start,
47150
+ ctx.startOffset + node.callee.end,
47151
+ ctx.helper("useModel")
47152
+ );
47153
+ ctx.s.appendLeft(
47154
+ ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
47155
+ `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
47135
47156
  );
47136
47157
  return true;
47137
47158
  }
@@ -48609,7 +48630,7 @@ var __spreadValues = (a, b) => {
48609
48630
  }
48610
48631
  return a;
48611
48632
  };
48612
- const version = "3.4.4";
48633
+ const version = "3.4.5";
48613
48634
  const parseCache = parseCache$1;
48614
48635
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48615
48636
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -8,6 +8,15 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/compiler-sfc.d.ts",
14
+ "node": "./dist/compiler-sfc.cjs.js",
15
+ "import": "./dist/compiler-sfc.esm-browser.js",
16
+ "require": "./dist/compiler-sfc.cjs.js"
17
+ },
18
+ "./*": "./*"
19
+ },
11
20
  "buildOptions": {
12
21
  "name": "VueCompilerSFC",
13
22
  "formats": [
@@ -37,10 +46,10 @@
37
46
  "magic-string": "^0.30.5",
38
47
  "postcss": "^8.4.32",
39
48
  "source-map-js": "^1.0.2",
40
- "@vue/compiler-core": "3.4.4",
41
- "@vue/shared": "3.4.4",
42
- "@vue/compiler-dom": "3.4.4",
43
- "@vue/compiler-ssr": "3.4.4"
49
+ "@vue/compiler-core": "3.4.5",
50
+ "@vue/compiler-ssr": "3.4.5",
51
+ "@vue/compiler-dom": "3.4.5",
52
+ "@vue/shared": "3.4.5"
44
53
  },
45
54
  "devDependencies": {
46
55
  "@babel/types": "^7.23.6",