@vue/compiler-sfc 3.4.26 → 3.5.0-alpha.2

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.26
2
+ * @vue/compiler-sfc v3.5.0-alpha.2
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
  /**
@@ -19593,13 +19597,11 @@ function inferValueType(node) {
19593
19597
  }
19594
19598
 
19595
19599
  function processPropsDestructure(ctx, declId) {
19596
- if (!ctx.options.propsDestructure) {
19600
+ if (ctx.options.propsDestructure === "error") {
19601
+ ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
19602
+ } else if (ctx.options.propsDestructure === false) {
19597
19603
  return;
19598
19604
  }
19599
- warnOnce(
19600
- `This project is using reactive props destructure, which is an experimental feature. It may receive breaking changes or be removed in the future, so use at your own risk.
19601
- To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
19602
- );
19603
19605
  ctx.propsDestructureDecl = declId;
19604
19606
  const registerBinding = (key, local, defaultValue) => {
19605
19607
  ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
@@ -19641,7 +19643,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
19641
19643
  }
19642
19644
  }
19643
19645
  function transformDestructuredProps(ctx, vueImportAliases) {
19644
- if (!ctx.options.propsDestructure) {
19646
+ if (ctx.options.propsDestructure === false) {
19645
19647
  return;
19646
19648
  }
19647
19649
  const rootScope = {};
@@ -20763,7 +20765,7 @@ function isStaticNode(node) {
20763
20765
  return false;
20764
20766
  }
20765
20767
 
20766
- const version = "3.4.26";
20768
+ const version = "3.5.0-alpha.2";
20767
20769
  const parseCache = parseCache$1;
20768
20770
  const errorMessages = {
20769
20771
  ...CompilerDOM.errorMessages,
@@ -117,10 +117,11 @@ export interface SFCScriptCompileOptions {
117
117
  */
118
118
  hoistStatic?: boolean;
119
119
  /**
120
- * (**Experimental**) Enable reactive destructure for `defineProps`
121
- * @default false
120
+ * Set to `false` to disable reactive destructure for `defineProps` (pre-3.5
121
+ * behavior), or set to `'error'` to throw hard error on props destructures.
122
+ * @default true
122
123
  */
123
- propsDestructure?: boolean;
124
+ propsDestructure?: boolean | 'error';
124
125
  /**
125
126
  * File system access methods to be used when resolving types
126
127
  * imported in SFC macros. Defaults to ts.sys in Node.js, can be overwritten
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.4.26
2
+ * @vue/compiler-sfc v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -25259,9 +25259,183 @@ const ignoreSideEffectTags = (node, context) => {
25259
25259
  }
25260
25260
  };
25261
25261
 
25262
+ function isValidHTMLNesting(parent, child) {
25263
+ if (parent in onlyValidChildren) {
25264
+ return onlyValidChildren[parent].has(child);
25265
+ }
25266
+ if (child in onlyValidParents) {
25267
+ return onlyValidParents[child].has(parent);
25268
+ }
25269
+ if (parent in knownInvalidChildren) {
25270
+ if (knownInvalidChildren[parent].has(child))
25271
+ return false;
25272
+ }
25273
+ if (child in knownInvalidParents) {
25274
+ if (knownInvalidParents[child].has(parent))
25275
+ return false;
25276
+ }
25277
+ return true;
25278
+ }
25279
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
25280
+ const emptySet = /* @__PURE__ */ new Set([]);
25281
+ const onlyValidChildren = {
25282
+ head: /* @__PURE__ */ new Set([
25283
+ "base",
25284
+ "basefront",
25285
+ "bgsound",
25286
+ "link",
25287
+ "meta",
25288
+ "title",
25289
+ "noscript",
25290
+ "noframes",
25291
+ "style",
25292
+ "script",
25293
+ "template"
25294
+ ]),
25295
+ optgroup: /* @__PURE__ */ new Set(["option"]),
25296
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
25297
+ // table
25298
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
25299
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
25300
+ colgroup: /* @__PURE__ */ new Set(["col"]),
25301
+ tbody: /* @__PURE__ */ new Set(["tr"]),
25302
+ thead: /* @__PURE__ */ new Set(["tr"]),
25303
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
25304
+ // these elements can not have any children elements
25305
+ script: emptySet,
25306
+ iframe: emptySet,
25307
+ option: emptySet,
25308
+ textarea: emptySet,
25309
+ style: emptySet,
25310
+ title: emptySet
25311
+ };
25312
+ const onlyValidParents = {
25313
+ // sections
25314
+ html: emptySet,
25315
+ body: /* @__PURE__ */ new Set(["html"]),
25316
+ head: /* @__PURE__ */ new Set(["html"]),
25317
+ // table
25318
+ td: /* @__PURE__ */ new Set(["tr"]),
25319
+ colgroup: /* @__PURE__ */ new Set(["table"]),
25320
+ caption: /* @__PURE__ */ new Set(["table"]),
25321
+ tbody: /* @__PURE__ */ new Set(["table"]),
25322
+ tfoot: /* @__PURE__ */ new Set(["table"]),
25323
+ col: /* @__PURE__ */ new Set(["colgroup"]),
25324
+ th: /* @__PURE__ */ new Set(["tr"]),
25325
+ thead: /* @__PURE__ */ new Set(["table"]),
25326
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
25327
+ // data list
25328
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
25329
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
25330
+ // other
25331
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
25332
+ // li: new Set(["ul", "ol"]),
25333
+ summary: /* @__PURE__ */ new Set(["details"]),
25334
+ area: /* @__PURE__ */ new Set(["map"])
25335
+ };
25336
+ const knownInvalidChildren = {
25337
+ p: /* @__PURE__ */ new Set([
25338
+ "address",
25339
+ "article",
25340
+ "aside",
25341
+ "blockquote",
25342
+ "center",
25343
+ "details",
25344
+ "dialog",
25345
+ "dir",
25346
+ "div",
25347
+ "dl",
25348
+ "fieldset",
25349
+ "figure",
25350
+ "footer",
25351
+ "form",
25352
+ "h1",
25353
+ "h2",
25354
+ "h3",
25355
+ "h4",
25356
+ "h5",
25357
+ "h6",
25358
+ "header",
25359
+ "hgroup",
25360
+ "hr",
25361
+ "li",
25362
+ "main",
25363
+ "nav",
25364
+ "menu",
25365
+ "ol",
25366
+ "p",
25367
+ "pre",
25368
+ "section",
25369
+ "table",
25370
+ "ul"
25371
+ ]),
25372
+ svg: /* @__PURE__ */ new Set([
25373
+ "b",
25374
+ "blockquote",
25375
+ "br",
25376
+ "code",
25377
+ "dd",
25378
+ "div",
25379
+ "dl",
25380
+ "dt",
25381
+ "em",
25382
+ "embed",
25383
+ "h1",
25384
+ "h2",
25385
+ "h3",
25386
+ "h4",
25387
+ "h5",
25388
+ "h6",
25389
+ "hr",
25390
+ "i",
25391
+ "img",
25392
+ "li",
25393
+ "menu",
25394
+ "meta",
25395
+ "ol",
25396
+ "p",
25397
+ "pre",
25398
+ "ruby",
25399
+ "s",
25400
+ "small",
25401
+ "span",
25402
+ "strong",
25403
+ "sub",
25404
+ "sup",
25405
+ "table",
25406
+ "u",
25407
+ "ul",
25408
+ "var"
25409
+ ])
25410
+ };
25411
+ const knownInvalidParents = {
25412
+ a: /* @__PURE__ */ new Set(["a"]),
25413
+ button: /* @__PURE__ */ new Set(["button"]),
25414
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
25415
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
25416
+ form: /* @__PURE__ */ new Set(["form"]),
25417
+ li: /* @__PURE__ */ new Set(["li"]),
25418
+ h1: headings,
25419
+ h2: headings,
25420
+ h3: headings,
25421
+ h4: headings,
25422
+ h5: headings,
25423
+ h6: headings
25424
+ };
25425
+
25426
+ const validateHtmlNesting = (node, context) => {
25427
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
25428
+ const error = new SyntaxError(
25429
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
25430
+ );
25431
+ error.loc = node.loc;
25432
+ context.onWarn(error);
25433
+ }
25434
+ };
25435
+
25262
25436
  const DOMNodeTransforms = [
25263
25437
  transformStyle,
25264
- ...[transformTransition]
25438
+ ...[transformTransition, validateHtmlNesting]
25265
25439
  ];
25266
25440
  const DOMDirectiveTransforms = {
25267
25441
  cloak: noopDirectiveTransform,
@@ -37220,7 +37394,7 @@ types.UNIVERSAL = UNIVERSAL;
37220
37394
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37221
37395
  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."); }
37222
37396
  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); }
37223
- function _arrayLikeToArray(arr, len) { len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37397
+ 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; }
37224
37398
  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); } }
37225
37399
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37226
37400
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
@@ -47164,13 +47338,11 @@ function inferValueType(node) {
47164
47338
  }
47165
47339
 
47166
47340
  function processPropsDestructure(ctx, declId) {
47167
- if (!ctx.options.propsDestructure) {
47341
+ if (ctx.options.propsDestructure === "error") {
47342
+ ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
47343
+ } else if (ctx.options.propsDestructure === false) {
47168
47344
  return;
47169
47345
  }
47170
- warnOnce$3(
47171
- `This project is using reactive props destructure, which is an experimental feature. It may receive breaking changes or be removed in the future, so use at your own risk.
47172
- To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
47173
- );
47174
47346
  ctx.propsDestructureDecl = declId;
47175
47347
  const registerBinding = (key, local, defaultValue) => {
47176
47348
  ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
@@ -47212,7 +47384,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
47212
47384
  }
47213
47385
  }
47214
47386
  function transformDestructuredProps(ctx, vueImportAliases) {
47215
- if (!ctx.options.propsDestructure) {
47387
+ if (ctx.options.propsDestructure === false) {
47216
47388
  return;
47217
47389
  }
47218
47390
  const rootScope = {};
@@ -48364,7 +48536,7 @@ var __spreadValues = (a, b) => {
48364
48536
  }
48365
48537
  return a;
48366
48538
  };
48367
- const version = "3.4.26";
48539
+ const version = "3.5.0-alpha.2";
48368
48540
  const parseCache = parseCache$1;
48369
48541
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48370
48542
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.4.26",
3
+ "version": "3.5.0-alpha.2",
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.26",
51
- "@vue/shared": "3.4.26",
52
- "@vue/compiler-dom": "3.4.26",
53
- "@vue/compiler-ssr": "3.4.26"
50
+ "@vue/compiler-dom": "3.5.0-alpha.2",
51
+ "@vue/shared": "3.5.0-alpha.2",
52
+ "@vue/compiler-core": "3.5.0-alpha.2",
53
+ "@vue/compiler-ssr": "3.5.0-alpha.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.24.0",