@vue/compiler-sfc 3.6.0-rc.7 → 3.6.0-rc.8

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.6.0-rc.7
2
+ * @vue/compiler-sfc v3.6.0-rc.8
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -15943,7 +15943,7 @@ function compileScript(sfc, options) {
15943
15943
  }
15944
15944
  if (preamble) ctx.s.prepend(preamble);
15945
15945
  if (helpers && (helpers.has(_vue_compiler_dom.UNREF) || helpers.has("unref"))) ctx.helperImports.delete("unref");
15946
- returned = code;
15946
+ returned = vapor && !ssr && hasAwait ? `return () => {${code}}` : code;
15947
15947
  } else returned = `() => {}`;
15948
15948
  if (!inlineMode && true) ctx.s.appendRight(endOffset, `\nconst __returned__ = ${returned}\nObject.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\nreturn __returned__\n}\n\n`);
15949
15949
  else ctx.s.appendRight(endOffset, `\n${vapor && !ssr ? `` : `return `}${returned}\n}\n\n`);
@@ -16121,7 +16121,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
16121
16121
  }
16122
16122
  //#endregion
16123
16123
  //#region packages/compiler-sfc/src/index.ts
16124
- const version = "3.6.0-rc.7";
16124
+ const version = "3.6.0-rc.8";
16125
16125
  const parseCache = parseCache$1;
16126
16126
  const errorMessages = {
16127
16127
  ..._vue_compiler_dom.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.6.0-rc.7
2
+ * @vue/compiler-sfc v3.6.0-rc.8
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -25070,6 +25070,9 @@ function isTeleportTag(tag) {
25070
25070
  tag = tag.toLowerCase();
25071
25071
  return tag === "teleport" || tag === "vaporteleport";
25072
25072
  }
25073
+ function isComponentTag(tag) {
25074
+ return tag === "component" || tag === "Component";
25075
+ }
25073
25076
  function isBuiltInComponent(tag) {
25074
25077
  if (isTeleportTag(tag)) return "VaporTeleport";
25075
25078
  else if (tag === "Suspense" || tag === "suspense") return "Suspense";
@@ -25244,6 +25247,7 @@ var TransformContext = class TransformContext {
25244
25247
  node,
25245
25248
  parent: this,
25246
25249
  index,
25250
+ inVOnce: this.inVOnce && !isComponentNode(this.node),
25247
25251
  template: "",
25248
25252
  templateRoot: false,
25249
25253
  childrenTemplate: [],
@@ -25418,8 +25422,18 @@ function getNextId(map, n) {
25418
25422
  if (map && map.has(n)) return map.get(n);
25419
25423
  return n;
25420
25424
  }
25425
+ function isComponentNode(node) {
25426
+ return node.type === 1 && node.tagType === 1;
25427
+ }
25421
25428
  //#endregion
25422
25429
  //#region packages/compiler-vapor/src/generators/utils.ts
25430
+ /**
25431
+ * Run a helper call inside the once ambient: a helper that creates its own
25432
+ * effects at a v-once site has them run once like compiled ones do.
25433
+ */
25434
+ function genOnce(call, context) {
25435
+ return genCall(context.helper("withOnce"), ["() => ", ...call]);
25436
+ }
25423
25437
  const IMPORT_EXP_START = "__IMPORT_EXP_START__";
25424
25438
  const IMPORT_EXP_END = "__IMPORT_EXP_END__";
25425
25439
  const IMPORT_EXPR_RE = new RegExp(`${IMPORT_EXP_START}(.*?)${IMPORT_EXP_END}`, "g");
@@ -26835,11 +26849,11 @@ function genGetTextChild(oper, context) {
26835
26849
  //#region packages/compiler-vapor/src/generators/vShow.ts
26836
26850
  function genVShow(oper, context) {
26837
26851
  const { element } = oper;
26838
- return [NEWLINE, ...genCall(context.helper("applyVShow"), `n${element}`, [
26852
+ return genCall(context.helper("applyVShow"), `n${element}`, [
26839
26853
  `() => (`,
26840
26854
  ...genExpression(oper.dir.exp, context),
26841
26855
  `)`
26842
- ])];
26856
+ ]);
26843
26857
  }
26844
26858
  //#endregion
26845
26859
  //#region packages/compiler-vapor/src/generators/modifier.ts
@@ -26857,11 +26871,11 @@ const helperMap = {
26857
26871
  };
26858
26872
  function genVModel(oper, context) {
26859
26873
  const { modelType, element, dir: { exp, modifiers } } = oper;
26860
- return [NEWLINE, ...genCall(context.helper(helperMap[modelType]), `n${element}`, [
26874
+ return genCall(context.helper(helperMap[modelType]), `n${element}`, [
26861
26875
  `() => (`,
26862
26876
  ...genExpression(exp, context),
26863
26877
  `)`
26864
- ], genModelHandler(exp, context), modifiers.length ? `{ ${genDirectiveModifiers(modifiers.map((e) => e.content))} }` : void 0)];
26878
+ ], genModelHandler(exp, context), modifiers.length ? `{ ${genDirectiveModifiers(modifiers.map((e) => e.content))} }` : void 0);
26865
26879
  }
26866
26880
  function genModelHandler(exp, context) {
26867
26881
  return [
@@ -26873,11 +26887,17 @@ function genModelHandler(exp, context) {
26873
26887
  //#endregion
26874
26888
  //#region packages/compiler-vapor/src/generators/directive.ts
26875
26889
  function genBuiltinDirective(oper, context) {
26890
+ let call;
26876
26891
  switch (oper.name) {
26877
- case "show": return genVShow(oper, context);
26878
- case "model": return genVModel(oper, context);
26892
+ case "show":
26893
+ call = genVShow(oper, context);
26894
+ break;
26895
+ case "model":
26896
+ call = genVModel(oper, context);
26897
+ break;
26879
26898
  default: return [];
26880
26899
  }
26900
+ return [NEWLINE, ...oper.once ? genOnce(call, context) : call];
26881
26901
  }
26882
26902
  /**
26883
26903
  * user directives via `withVaporDirectives`
@@ -26891,7 +26911,8 @@ function genCustomDirectives(opers, context) {
26891
26911
  const element = `n${opers[0].element}`;
26892
26912
  const directiveItems = opers.map(genDirectiveItem);
26893
26913
  const directives = genMulti(DELIMITERS_ARRAY, ...directiveItems);
26894
- return [NEWLINE, ...genCall(helper("withVaporDirectives"), element, directives)];
26914
+ const call = genCall(helper("withVaporDirectives"), element, directives);
26915
+ return [NEWLINE, ...opers[0].once ? genOnce(call, context) : call];
26895
26916
  function genDirectiveItem({ dir, name, asset }) {
26896
26917
  const directiveVar = asset ? toValidAssetId(name, "directive") : genExpression(extend(createSimpleExpression(name, false), { ast: null }), context);
26897
26918
  const value = dir.exp && [
@@ -26925,7 +26946,8 @@ function genCreateComponent(operation, context) {
26925
26946
  const tag = genTag();
26926
26947
  const { root, props, slots, once, slotRoot } = operation;
26927
26948
  const isRuntimeDynamicComponent = !!(operation.dynamic && !operation.dynamic.isStatic);
26928
- const dynamicComponentFlags = isRuntimeDynamicComponent ? genDynamicComponentFlags(root, once, slotRoot) : false;
26949
+ const dynamicComponentFlags = isRuntimeDynamicComponent ? genDynamicComponentFlags(root, once, slotRoot, operation.ns) : false;
26950
+ const nsArg = !isRuntimeDynamicComponent && (operation.useCreateElement || operation.asset || !!operation.dynamic) && operation.ns ? String(operation.ns) : false;
26929
26951
  const rawSlots = genRawSlots(slots, context);
26930
26952
  const [ids, handlers] = processInlineHandlers(props, context);
26931
26953
  const rawProps = context.withId(() => genRawProps(props, context, true), ids);
@@ -26942,7 +26964,11 @@ function genCreateComponent(operation, context) {
26942
26964
  NEWLINE,
26943
26965
  ...inlineHandlers,
26944
26966
  `const n${operation.id} = `,
26945
- ...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root ? "true" : false, isRuntimeDynamicComponent ? false : once && "true", isRuntimeDynamicComponent ? false : maybeSelfReference && "true"),
26967
+ ...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root ? "true" : false, isRuntimeDynamicComponent ? operation.key && [
26968
+ "() => (",
26969
+ ...genExpression(operation.key, context),
26970
+ ")"
26971
+ ] : once && "true", useAssetComponentHelper ? maybeSelfReference && "true" : nsArg, useAssetComponentHelper && nsArg),
26946
26972
  ...genDirectivesForElement(operation.id, context)
26947
26973
  ];
26948
26974
  function genTag() {
@@ -26969,7 +26995,7 @@ function genCreateComponent(operation, context) {
26969
26995
  }
26970
26996
  }
26971
26997
  }
26972
- function genDynamicComponentFlags(root, once, slotRoot) {
26998
+ function genDynamicComponentFlags(root, once, slotRoot, ns) {
26973
26999
  let flags = 0;
26974
27000
  const names = [];
26975
27001
  if (root) {
@@ -26984,6 +27010,13 @@ function genDynamicComponentFlags(root, once, slotRoot) {
26984
27010
  flags |= 4;
26985
27011
  names.push("SLOT_ROOT");
26986
27012
  }
27013
+ if (ns === 1) {
27014
+ flags |= 8;
27015
+ names.push("NS_SVG");
27016
+ } else if (ns === 2) {
27017
+ flags |= 16;
27018
+ names.push("NS_MATHML");
27019
+ }
26987
27020
  if (!flags) return false;
26988
27021
  return genFlags(flags, names);
26989
27022
  }
@@ -27524,7 +27557,8 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
27524
27557
  continue;
27525
27558
  }
27526
27559
  const id = child.flags & 1 ? child.flags & 4 ? child.anchor : child.id : void 0;
27527
- if (id === void 0 && !child.hasDynamicChild) {
27560
+ const ownsSubtree = child.operation !== void 0;
27561
+ if (id === void 0 && (!child.hasDynamicChild || ownsSubtree)) {
27528
27562
  flushBeforeDynamic && flushBeforeDynamic(child, push);
27529
27563
  push(...genSelf(child, context, flushBeforeDynamic));
27530
27564
  continue;
@@ -27561,7 +27595,7 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
27561
27595
  variable = id === void 0 ? context.pName(context.block.tempId++) : `n${id}`;
27562
27596
  pushBlock(NEWLINE, id === void 0 ? `let ${variable} = ` : `const ${variable} = `, ...accessPath);
27563
27597
  }
27564
- if (id === child.anchor && !child.hasDynamicChild) {
27598
+ if (id === child.anchor && (!child.hasDynamicChild || ownsSubtree)) {
27565
27599
  flushBeforeDynamic && flushBeforeDynamic(child, push);
27566
27600
  push(...genSelf(child, context, flushBeforeDynamic));
27567
27601
  }
@@ -27571,7 +27605,7 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
27571
27605
  elementIndex,
27572
27606
  id === void 0
27573
27607
  ];
27574
- push(...genChildren(child, context, pushBlock, variable, flushBeforeDynamic));
27608
+ if (!ownsSubtree) push(...genChildren(child, context, pushBlock, variable, flushBeforeDynamic));
27575
27609
  }
27576
27610
  return frag;
27577
27611
  }
@@ -28100,6 +28134,37 @@ const transformVBind = (dir, node, context) => {
28100
28134
  };
28101
28135
  };
28102
28136
  //#endregion
28137
+ //#region packages/compiler-vapor/src/transforms/transformKey.ts
28138
+ init_objectSpread2();
28139
+ const dynamicComponentKeys = /* @__PURE__ */ new WeakMap();
28140
+ const transformKey = (node, context) => {
28141
+ if (node.type !== 1 || context.inVOnce || findDir(node, "for")) return;
28142
+ const dir = findProp(node, "key", true, true);
28143
+ if (!dir || dir.type === 6) return;
28144
+ let value;
28145
+ value = dir.exp || normalizeBindShorthand(dir.arg, context);
28146
+ if (isStaticExpression(value, context.options.bindingMetadata)) return;
28147
+ if (isComponentTag(node.tag) && findProp(node, "is", true, true)) {
28148
+ dynamicComponentKeys.set(node, value);
28149
+ return;
28150
+ }
28151
+ let id = context.reference();
28152
+ context.dynamic.flags |= 6;
28153
+ context.node = node = wrapTemplate(node, ["key"]);
28154
+ const block = newBlock(node);
28155
+ const exitBlock = context.enterBlock(block);
28156
+ return () => {
28157
+ exitBlock();
28158
+ context.dynamic.operation = _objectSpread2(_objectSpread2({
28159
+ type: 16,
28160
+ id
28161
+ }, context.effectBoundary()), {}, {
28162
+ value,
28163
+ block
28164
+ });
28165
+ };
28166
+ };
28167
+ //#endregion
28103
28168
  //#region packages/compiler-vapor/src/transforms/vHtml.ts
28104
28169
  function ignoreVHtmlChildren(node, context, clear) {
28105
28170
  if (!node.children.length) return;
@@ -28191,6 +28256,8 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28191
28256
  let { tag } = node;
28192
28257
  let asset = true;
28193
28258
  if (!dynamicComponent && !useCreateElement) {
28259
+ const isProp = findProp(node, "is");
28260
+ if (isProp && isProp.type === 6 && isVueIsValue(isProp)) tag = isProp.value.content.slice(4);
28194
28261
  const fromSetup = resolveSetupReference(tag, context);
28195
28262
  if (fromSetup) {
28196
28263
  tag = fromSetup;
@@ -28227,11 +28294,16 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28227
28294
  slots: [...context.slots],
28228
28295
  once: context.inVOnce,
28229
28296
  dynamic: dynamicComponent,
28230
- useCreateElement
28297
+ useCreateElement,
28298
+ ns: node.ns || void 0,
28299
+ key: dynamicComponentKeys.get(node)
28231
28300
  });
28232
28301
  if (staticKey) context.registerOperation(createSetBlockKey(id, staticKey));
28233
28302
  context.slots = [];
28234
28303
  }
28304
+ function isVueIsValue(prop) {
28305
+ return !!prop.value && prop.value.content.startsWith("vue:");
28306
+ }
28235
28307
  function resolveDynamicComponent(node) {
28236
28308
  const isProp = findProp(node, "is", false, true);
28237
28309
  if (!isProp) return;
@@ -28491,7 +28563,7 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
28491
28563
  continue;
28492
28564
  }
28493
28565
  }
28494
- if (isDynamicComponent && (prop.type === 6 && prop.name === "is" || prop.type === 7 && prop.name === "bind" && isStaticArgOf(prop.arg, "is"))) continue;
28566
+ if (prop.type === 6 ? prop.name === "is" && (isDynamicComponent || isVueIsValue(prop)) : isDynamicComponent && prop.name === "bind" && isStaticArgOf(prop.arg, "is")) continue;
28495
28567
  const result = transformProp(prop, node, context);
28496
28568
  if (result) {
28497
28569
  dynamicExpr.push(result.key, result.value);
@@ -28676,7 +28748,8 @@ function transformProp(prop, node, context) {
28676
28748
  element: context.reference(),
28677
28749
  dir: prop,
28678
28750
  name,
28679
- asset: !fromSetup
28751
+ asset: !fromSetup,
28752
+ once: context.inVOnce
28680
28753
  });
28681
28754
  }
28682
28755
  }
@@ -28717,9 +28790,6 @@ function mergePropValues(existing, incoming) {
28717
28790
  const newValues = incoming.values;
28718
28791
  existing.values.push(...newValues);
28719
28792
  }
28720
- function isComponentTag(tag) {
28721
- return tag === "component" || tag === "Component";
28722
- }
28723
28793
  function shouldUseCreateElement(node, context) {
28724
28794
  return context.options.isCustomElement(node.tag) || node.tagType === 0 && node.tag === "template";
28725
28795
  }
@@ -29100,7 +29170,8 @@ const transformVShow = (dir, node, context) => {
29100
29170
  element: context.reference(),
29101
29171
  dir,
29102
29172
  name: "show",
29103
- builtin: true
29173
+ builtin: true,
29174
+ once: context.inVOnce
29104
29175
  });
29105
29176
  };
29106
29177
  //#endregion
@@ -29184,7 +29255,8 @@ const transformVModel = (dir, node, context) => {
29184
29255
  dir,
29185
29256
  name: "model",
29186
29257
  modelType,
29187
- builtin: true
29258
+ builtin: true,
29259
+ once: context.inVOnce
29188
29260
  });
29189
29261
  function checkDuplicatedValue() {
29190
29262
  const value = findDir$1(node, "bind");
@@ -29627,32 +29699,6 @@ function hasMultipleChildren(node) {
29627
29699
  return children.length !== 1;
29628
29700
  }
29629
29701
  //#endregion
29630
- //#region packages/compiler-vapor/src/transforms/transformKey.ts
29631
- init_objectSpread2();
29632
- const transformKey = (node, context) => {
29633
- if (node.type !== 1 || context.inVOnce || findDir(node, "for")) return;
29634
- const dir = findProp(node, "key", true, true);
29635
- if (!dir || dir.type === 6) return;
29636
- let value;
29637
- value = dir.exp || normalizeBindShorthand(dir.arg, context);
29638
- if (isStaticExpression(value, context.options.bindingMetadata)) return;
29639
- let id = context.reference();
29640
- context.dynamic.flags |= 6;
29641
- context.node = node = wrapTemplate(node, ["key"]);
29642
- const block = newBlock(node);
29643
- const exitBlock = context.enterBlock(block);
29644
- return () => {
29645
- exitBlock();
29646
- context.dynamic.operation = _objectSpread2(_objectSpread2({
29647
- type: 16,
29648
- id
29649
- }, context.effectBoundary()), {}, {
29650
- value,
29651
- block
29652
- });
29653
- };
29654
- };
29655
- //#endregion
29656
29702
  //#region packages/compiler-vapor/src/compile.ts
29657
29703
  function compile$1(source, options = {}) {
29658
29704
  const resolvedOptions = extend({}, options);
@@ -43247,7 +43293,7 @@ function compileScript(sfc, options) {
43247
43293
  }
43248
43294
  if (preamble) ctx.s.prepend(preamble);
43249
43295
  if (helpers && (helpers.has(UNREF) || helpers.has("unref"))) ctx.helperImports.delete("unref");
43250
- returned = code;
43296
+ returned = vapor && !ssr && hasAwait ? `return () => {${code}}` : code;
43251
43297
  } else returned = `() => {}`;
43252
43298
  if (!inlineMode && true) ctx.s.appendRight(endOffset, `\nconst __returned__ = ${returned}\nObject.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\nreturn __returned__\n}\n\n`);
43253
43299
  else ctx.s.appendRight(endOffset, `\n${vapor && !ssr ? `` : `return `}${returned}\n}\n\n`);
@@ -43425,7 +43471,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
43425
43471
  //#endregion
43426
43472
  //#region packages/compiler-sfc/src/index.ts
43427
43473
  init_objectSpread2();
43428
- const version = "3.6.0-rc.7";
43474
+ const version = "3.6.0-rc.8";
43429
43475
  const parseCache = parseCache$1;
43430
43476
  const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
43431
43477
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.6.0-rc.7",
3
+ "version": "3.6.0-rc.8",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -47,11 +47,11 @@
47
47
  "magic-string": "^0.30.21",
48
48
  "postcss": "^8.5.19",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-dom": "3.6.0-rc.7",
51
- "@vue/compiler-core": "3.6.0-rc.7",
52
- "@vue/compiler-vapor": "3.6.0-rc.7",
53
- "@vue/shared": "3.6.0-rc.7",
54
- "@vue/compiler-ssr": "3.6.0-rc.7"
50
+ "@vue/compiler-core": "3.6.0-rc.8",
51
+ "@vue/compiler-dom": "3.6.0-rc.8",
52
+ "@vue/compiler-vapor": "3.6.0-rc.8",
53
+ "@vue/shared": "3.6.0-rc.8",
54
+ "@vue/compiler-ssr": "3.6.0-rc.8"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@babel/types": "^7.29.8",