@vue/compiler-sfc 3.4.25 → 3.5.0-alpha.1

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.5.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -19593,13 +19593,11 @@ function inferValueType(node) {
19593
19593
  }
19594
19594
 
19595
19595
  function processPropsDestructure(ctx, declId) {
19596
- if (!ctx.options.propsDestructure) {
19596
+ if (ctx.options.propsDestructure === "error") {
19597
+ ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
19598
+ } else if (ctx.options.propsDestructure === false) {
19597
19599
  return;
19598
19600
  }
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
19601
  ctx.propsDestructureDecl = declId;
19604
19602
  const registerBinding = (key, local, defaultValue) => {
19605
19603
  ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
@@ -19641,7 +19639,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
19641
19639
  }
19642
19640
  }
19643
19641
  function transformDestructuredProps(ctx, vueImportAliases) {
19644
- if (!ctx.options.propsDestructure) {
19642
+ if (ctx.options.propsDestructure === false) {
19645
19643
  return;
19646
19644
  }
19647
19645
  const rootScope = {};
@@ -20763,7 +20761,7 @@ function isStaticNode(node) {
20763
20761
  return false;
20764
20762
  }
20765
20763
 
20766
- const version = "3.4.25";
20764
+ const version = "3.5.0-alpha.1";
20767
20765
  const parseCache = parseCache$1;
20768
20766
  const errorMessages = {
20769
20767
  ...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.25
2
+ * @vue/compiler-sfc v3.5.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -25264,9 +25264,183 @@ const ignoreSideEffectTags = (node, context) => {
25264
25264
  }
25265
25265
  };
25266
25266
 
25267
+ function isValidHTMLNesting(parent, child) {
25268
+ if (parent in onlyValidChildren) {
25269
+ return onlyValidChildren[parent].has(child);
25270
+ }
25271
+ if (child in onlyValidParents) {
25272
+ return onlyValidParents[child].has(parent);
25273
+ }
25274
+ if (parent in knownInvalidChildren) {
25275
+ if (knownInvalidChildren[parent].has(child))
25276
+ return false;
25277
+ }
25278
+ if (child in knownInvalidParents) {
25279
+ if (knownInvalidParents[child].has(parent))
25280
+ return false;
25281
+ }
25282
+ return true;
25283
+ }
25284
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
25285
+ const emptySet = /* @__PURE__ */ new Set([]);
25286
+ const onlyValidChildren = {
25287
+ head: /* @__PURE__ */ new Set([
25288
+ "base",
25289
+ "basefront",
25290
+ "bgsound",
25291
+ "link",
25292
+ "meta",
25293
+ "title",
25294
+ "noscript",
25295
+ "noframes",
25296
+ "style",
25297
+ "script",
25298
+ "template"
25299
+ ]),
25300
+ optgroup: /* @__PURE__ */ new Set(["option"]),
25301
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
25302
+ // table
25303
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
25304
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
25305
+ colgroup: /* @__PURE__ */ new Set(["col"]),
25306
+ tbody: /* @__PURE__ */ new Set(["tr"]),
25307
+ thead: /* @__PURE__ */ new Set(["tr"]),
25308
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
25309
+ // these elements can not have any children elements
25310
+ script: emptySet,
25311
+ iframe: emptySet,
25312
+ option: emptySet,
25313
+ textarea: emptySet,
25314
+ style: emptySet,
25315
+ title: emptySet
25316
+ };
25317
+ const onlyValidParents = {
25318
+ // sections
25319
+ html: emptySet,
25320
+ body: /* @__PURE__ */ new Set(["html"]),
25321
+ head: /* @__PURE__ */ new Set(["html"]),
25322
+ // table
25323
+ td: /* @__PURE__ */ new Set(["tr"]),
25324
+ colgroup: /* @__PURE__ */ new Set(["table"]),
25325
+ caption: /* @__PURE__ */ new Set(["table"]),
25326
+ tbody: /* @__PURE__ */ new Set(["table"]),
25327
+ tfoot: /* @__PURE__ */ new Set(["table"]),
25328
+ col: /* @__PURE__ */ new Set(["colgroup"]),
25329
+ th: /* @__PURE__ */ new Set(["tr"]),
25330
+ thead: /* @__PURE__ */ new Set(["table"]),
25331
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
25332
+ // data list
25333
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
25334
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
25335
+ // other
25336
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
25337
+ // li: new Set(["ul", "ol"]),
25338
+ summary: /* @__PURE__ */ new Set(["details"]),
25339
+ area: /* @__PURE__ */ new Set(["map"])
25340
+ };
25341
+ const knownInvalidChildren = {
25342
+ p: /* @__PURE__ */ new Set([
25343
+ "address",
25344
+ "article",
25345
+ "aside",
25346
+ "blockquote",
25347
+ "center",
25348
+ "details",
25349
+ "dialog",
25350
+ "dir",
25351
+ "div",
25352
+ "dl",
25353
+ "fieldset",
25354
+ "figure",
25355
+ "footer",
25356
+ "form",
25357
+ "h1",
25358
+ "h2",
25359
+ "h3",
25360
+ "h4",
25361
+ "h5",
25362
+ "h6",
25363
+ "header",
25364
+ "hgroup",
25365
+ "hr",
25366
+ "li",
25367
+ "main",
25368
+ "nav",
25369
+ "menu",
25370
+ "ol",
25371
+ "p",
25372
+ "pre",
25373
+ "section",
25374
+ "table",
25375
+ "ul"
25376
+ ]),
25377
+ svg: /* @__PURE__ */ new Set([
25378
+ "b",
25379
+ "blockquote",
25380
+ "br",
25381
+ "code",
25382
+ "dd",
25383
+ "div",
25384
+ "dl",
25385
+ "dt",
25386
+ "em",
25387
+ "embed",
25388
+ "h1",
25389
+ "h2",
25390
+ "h3",
25391
+ "h4",
25392
+ "h5",
25393
+ "h6",
25394
+ "hr",
25395
+ "i",
25396
+ "img",
25397
+ "li",
25398
+ "menu",
25399
+ "meta",
25400
+ "ol",
25401
+ "p",
25402
+ "pre",
25403
+ "ruby",
25404
+ "s",
25405
+ "small",
25406
+ "span",
25407
+ "strong",
25408
+ "sub",
25409
+ "sup",
25410
+ "table",
25411
+ "u",
25412
+ "ul",
25413
+ "var"
25414
+ ])
25415
+ };
25416
+ const knownInvalidParents = {
25417
+ a: /* @__PURE__ */ new Set(["a"]),
25418
+ button: /* @__PURE__ */ new Set(["button"]),
25419
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
25420
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
25421
+ form: /* @__PURE__ */ new Set(["form"]),
25422
+ li: /* @__PURE__ */ new Set(["li"]),
25423
+ h1: headings,
25424
+ h2: headings,
25425
+ h3: headings,
25426
+ h4: headings,
25427
+ h5: headings,
25428
+ h6: headings
25429
+ };
25430
+
25431
+ const validateHtmlNesting = (node, context) => {
25432
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
25433
+ const error = new SyntaxError(
25434
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
25435
+ );
25436
+ error.loc = node.loc;
25437
+ context.onWarn(error);
25438
+ }
25439
+ };
25440
+
25267
25441
  const DOMNodeTransforms = [
25268
25442
  transformStyle,
25269
- ...[transformTransition]
25443
+ ...[transformTransition, validateHtmlNesting]
25270
25444
  ];
25271
25445
  const DOMDirectiveTransforms = {
25272
25446
  cloak: noopDirectiveTransform,
@@ -47169,13 +47343,11 @@ function inferValueType(node) {
47169
47343
  }
47170
47344
 
47171
47345
  function processPropsDestructure(ctx, declId) {
47172
- if (!ctx.options.propsDestructure) {
47346
+ if (ctx.options.propsDestructure === "error") {
47347
+ ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
47348
+ } else if (ctx.options.propsDestructure === false) {
47173
47349
  return;
47174
47350
  }
47175
- warnOnce$3(
47176
- `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.
47177
- To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
47178
- );
47179
47351
  ctx.propsDestructureDecl = declId;
47180
47352
  const registerBinding = (key, local, defaultValue) => {
47181
47353
  ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
@@ -47217,7 +47389,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
47217
47389
  }
47218
47390
  }
47219
47391
  function transformDestructuredProps(ctx, vueImportAliases) {
47220
- if (!ctx.options.propsDestructure) {
47392
+ if (ctx.options.propsDestructure === false) {
47221
47393
  return;
47222
47394
  }
47223
47395
  const rootScope = {};
@@ -48369,7 +48541,7 @@ var __spreadValues = (a, b) => {
48369
48541
  }
48370
48542
  return a;
48371
48543
  };
48372
- const version = "3.4.25";
48544
+ const version = "3.5.0-alpha.1";
48373
48545
  const parseCache = parseCache$1;
48374
48546
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48375
48547
  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.5.0-alpha.1",
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/compiler-dom": "3.5.0-alpha.1",
51
+ "@vue/compiler-core": "3.5.0-alpha.1",
52
+ "@vue/shared": "3.5.0-alpha.1",
53
+ "@vue/compiler-ssr": "3.5.0-alpha.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.24.0",