@vue/compat 3.5.0-alpha.1 → 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-alpha.1
2
+ * @vue/compat v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -88,10 +88,11 @@ const invokeArrayFns = (fns, arg) => {
88
88
  fns[i](arg);
89
89
  }
90
90
  };
91
- const def = (obj, key, value) => {
91
+ const def = (obj, key, value, writable = false) => {
92
92
  Object.defineProperty(obj, key, {
93
93
  configurable: true,
94
94
  enumerable: false,
95
+ writable,
95
96
  value
96
97
  });
97
98
  };
@@ -2133,7 +2134,9 @@ const ErrorCodes = {
2133
2134
  "ASYNC_COMPONENT_LOADER": 13,
2134
2135
  "13": "ASYNC_COMPONENT_LOADER",
2135
2136
  "SCHEDULER": 14,
2136
- "14": "SCHEDULER"
2137
+ "14": "SCHEDULER",
2138
+ "APP_UNMOUNT_CLEANUP": 15,
2139
+ "15": "APP_UNMOUNT_CLEANUP"
2137
2140
  };
2138
2141
  const ErrorTypeStrings$1 = {
2139
2142
  ["sp"]: "serverPrefetch hook",
@@ -2164,7 +2167,8 @@ const ErrorTypeStrings$1 = {
2164
2167
  [11]: "app warnHandler",
2165
2168
  [12]: "ref function",
2166
2169
  [13]: "async component loader",
2167
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2170
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2171
+ [15]: "app unmount cleanup function"
2168
2172
  };
2169
2173
  function callWithErrorHandling(fn, instance, type, args) {
2170
2174
  try {
@@ -3385,7 +3389,7 @@ function renderComponentRoot(instance) {
3385
3389
  true ? {
3386
3390
  get attrs() {
3387
3391
  markAttrsAccessed();
3388
- return attrs;
3392
+ return shallowReadonly(attrs);
3389
3393
  },
3390
3394
  slots,
3391
3395
  emit
@@ -3418,7 +3422,7 @@ function renderComponentRoot(instance) {
3418
3422
  propsOptions
3419
3423
  );
3420
3424
  }
3421
- root = cloneVNode(root, fallthroughAttrs);
3425
+ root = cloneVNode(root, fallthroughAttrs, false, true);
3422
3426
  } else if (!accessedAttrs && root.type !== Comment) {
3423
3427
  const allAttrs = Object.keys(attrs);
3424
3428
  const eventAttrs = [];
@@ -3456,10 +3460,15 @@ function renderComponentRoot(instance) {
3456
3460
  getComponentName(instance.type)
3457
3461
  );
3458
3462
  }
3459
- root = cloneVNode(root, {
3460
- class: cls,
3461
- style
3462
- });
3463
+ root = cloneVNode(
3464
+ root,
3465
+ {
3466
+ class: cls,
3467
+ style
3468
+ },
3469
+ false,
3470
+ true
3471
+ );
3463
3472
  }
3464
3473
  }
3465
3474
  if (vnode.dirs) {
@@ -3468,7 +3477,7 @@ function renderComponentRoot(instance) {
3468
3477
  `Runtime directive used on component with non-element root node. The directives will not function as intended.`
3469
3478
  );
3470
3479
  }
3471
- root = cloneVNode(root);
3480
+ root = cloneVNode(root, null, false, true);
3472
3481
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3473
3482
  }
3474
3483
  if (vnode.transition) {
@@ -3963,7 +3972,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3963
3972
  let parentSuspenseId;
3964
3973
  const isSuspensible = isVNodeSuspensible(vnode);
3965
3974
  if (isSuspensible) {
3966
- if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
3975
+ if (parentSuspense && parentSuspense.pendingBranch) {
3967
3976
  parentSuspenseId = parentSuspense.pendingId;
3968
3977
  parentSuspense.deps++;
3969
3978
  }
@@ -4275,8 +4284,8 @@ function setActiveBranch(suspense, branch) {
4275
4284
  }
4276
4285
  }
4277
4286
  function isVNodeSuspensible(vnode) {
4278
- var _a;
4279
- return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
4287
+ const suspensible = vnode.props && vnode.props.suspensible;
4288
+ return suspensible != null && suspensible !== false;
4280
4289
  }
4281
4290
 
4282
4291
  const legacyDirectiveHookMap = {
@@ -4581,34 +4590,29 @@ function createPathGetter(ctx, path) {
4581
4590
  return cur;
4582
4591
  };
4583
4592
  }
4584
- function traverse(value, depth, currentDepth = 0, seen) {
4585
- if (!isObject(value) || value["__v_skip"]) {
4593
+ function traverse(value, depth = Infinity, seen) {
4594
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
4586
4595
  return value;
4587
4596
  }
4588
- if (depth && depth > 0) {
4589
- if (currentDepth >= depth) {
4590
- return value;
4591
- }
4592
- currentDepth++;
4593
- }
4594
4597
  seen = seen || /* @__PURE__ */ new Set();
4595
4598
  if (seen.has(value)) {
4596
4599
  return value;
4597
4600
  }
4598
4601
  seen.add(value);
4602
+ depth--;
4599
4603
  if (isRef(value)) {
4600
- traverse(value.value, depth, currentDepth, seen);
4604
+ traverse(value.value, depth, seen);
4601
4605
  } else if (isArray(value)) {
4602
4606
  for (let i = 0; i < value.length; i++) {
4603
- traverse(value[i], depth, currentDepth, seen);
4607
+ traverse(value[i], depth, seen);
4604
4608
  }
4605
4609
  } else if (isSet(value) || isMap(value)) {
4606
4610
  value.forEach((v) => {
4607
- traverse(v, depth, currentDepth, seen);
4611
+ traverse(v, depth, seen);
4608
4612
  });
4609
4613
  } else if (isPlainObject(value)) {
4610
4614
  for (const key in value) {
4611
- traverse(value[key], depth, currentDepth, seen);
4615
+ traverse(value[key], depth, seen);
4612
4616
  }
4613
4617
  }
4614
4618
  return value;
@@ -4754,7 +4758,7 @@ const BaseTransitionImpl = {
4754
4758
  instance
4755
4759
  );
4756
4760
  setTransitionHooks(oldInnerChild, leavingHooks);
4757
- if (mode === "out-in") {
4761
+ if (mode === "out-in" && innerChild.type !== Comment) {
4758
4762
  state.isLeaving = true;
4759
4763
  leavingHooks.afterLeave = () => {
4760
4764
  state.isLeaving = false;
@@ -5298,7 +5302,7 @@ const KeepAliveImpl = {
5298
5302
  return () => {
5299
5303
  pendingCacheKey = null;
5300
5304
  if (!slots.default) {
5301
- return current = null;
5305
+ return null;
5302
5306
  }
5303
5307
  const children = slots.default();
5304
5308
  const rawVNode = children[0];
@@ -7003,13 +7007,13 @@ function createCompatVue$1(createApp, createSingletonApp) {
7003
7007
  return vm;
7004
7008
  }
7005
7009
  }
7006
- Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
7010
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.2"}`;
7007
7011
  Vue.config = singletonApp.config;
7008
- Vue.use = (p, ...options) => {
7009
- if (p && isFunction(p.install)) {
7010
- p.install(Vue, ...options);
7011
- } else if (isFunction(p)) {
7012
- p(Vue, ...options);
7012
+ Vue.use = (plugin, ...options) => {
7013
+ if (plugin && isFunction(plugin.install)) {
7014
+ plugin.install(Vue, ...options);
7015
+ } else if (isFunction(plugin)) {
7016
+ plugin(Vue, ...options);
7013
7017
  }
7014
7018
  return Vue;
7015
7019
  };
@@ -7408,6 +7412,7 @@ function createAppAPI(render, hydrate) {
7408
7412
  }
7409
7413
  const context = createAppContext();
7410
7414
  const installedPlugins = /* @__PURE__ */ new WeakSet();
7415
+ const pluginCleanupFns = [];
7411
7416
  let isMounted = false;
7412
7417
  const app = context.app = {
7413
7418
  _uid: uid$1++,
@@ -7525,8 +7530,21 @@ If you want to remount the same app, move your app creation logic into a factory
7525
7530
  );
7526
7531
  }
7527
7532
  },
7533
+ onUnmount(cleanupFn) {
7534
+ if (typeof cleanupFn !== "function") {
7535
+ warn$1(
7536
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
7537
+ );
7538
+ }
7539
+ pluginCleanupFns.push(cleanupFn);
7540
+ },
7528
7541
  unmount() {
7529
7542
  if (isMounted) {
7543
+ callWithAsyncErrorHandling(
7544
+ pluginCleanupFns,
7545
+ app._instance,
7546
+ 15
7547
+ );
7530
7548
  render(null, app._container);
7531
7549
  {
7532
7550
  app._instance = null;
@@ -8127,7 +8145,7 @@ const initSlots = (instance, children) => {
8127
8145
  const type = children._;
8128
8146
  if (type) {
8129
8147
  extend(slots, children);
8130
- def(slots, "_", type);
8148
+ def(slots, "_", type, true);
8131
8149
  } else {
8132
8150
  normalizeObjectSlots(children, slots, instance);
8133
8151
  }
@@ -10965,8 +10983,8 @@ function guardReactiveProps(props) {
10965
10983
  return null;
10966
10984
  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
10967
10985
  }
10968
- function cloneVNode(vnode, extraProps, mergeRef = false) {
10969
- const { props, ref, patchFlag, children } = vnode;
10986
+ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
10987
+ const { props, ref, patchFlag, children, transition } = vnode;
10970
10988
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
10971
10989
  const cloned = {
10972
10990
  __v_isVNode: true,
@@ -10996,7 +11014,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10996
11014
  dynamicChildren: vnode.dynamicChildren,
10997
11015
  appContext: vnode.appContext,
10998
11016
  dirs: vnode.dirs,
10999
- transition: vnode.transition,
11017
+ transition,
11000
11018
  // These should technically only be non-null on mounted VNodes. However,
11001
11019
  // they *should* be copied for kept-alive vnodes. So we just always copy
11002
11020
  // them since them being non-null during a mount doesn't affect the logic as
@@ -11010,6 +11028,9 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
11010
11028
  ctx: vnode.ctx,
11011
11029
  ce: vnode.ce
11012
11030
  };
11031
+ if (transition && cloneTransition) {
11032
+ cloned.transition = transition.clone(cloned);
11033
+ }
11013
11034
  {
11014
11035
  defineLegacyVNodeProperties(cloned);
11015
11036
  }
@@ -11851,7 +11872,7 @@ function isMemoSame(cached, memo) {
11851
11872
  return true;
11852
11873
  }
11853
11874
 
11854
- const version = "3.5.0-alpha.1";
11875
+ const version = "3.5.0-alpha.2";
11855
11876
  const warn = warn$1 ;
11856
11877
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11857
11878
  const devtools = devtools$1 ;
@@ -15619,11 +15640,10 @@ const tokenizer = new Tokenizer(stack, {
15619
15640
  }
15620
15641
  },
15621
15642
  onselfclosingtag(end) {
15622
- var _a;
15623
15643
  const name = currentOpenTag.tag;
15624
15644
  currentOpenTag.isSelfClosing = true;
15625
15645
  endOpenTag(end);
15626
- if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
15646
+ if (stack[0] && stack[0].tag === name) {
15627
15647
  onCloseTag(stack.shift(), end);
15628
15648
  }
15629
15649
  },
@@ -15939,7 +15959,7 @@ function endOpenTag(end) {
15939
15959
  function onText(content, start, end) {
15940
15960
  const parent = stack[0] || currentRoot;
15941
15961
  const lastNode = parent.children[parent.children.length - 1];
15942
- if ((lastNode == null ? void 0 : lastNode.type) === 2) {
15962
+ if (lastNode && lastNode.type === 2) {
15943
15963
  lastNode.content += content;
15944
15964
  setLocEnd(lastNode.loc, end);
15945
15965
  } else {
@@ -16073,11 +16093,10 @@ function isFragmentTemplate({ tag, props }) {
16073
16093
  return false;
16074
16094
  }
16075
16095
  function isComponent({ tag, props }) {
16076
- var _a;
16077
16096
  if (currentOptions.isCustomElement(tag)) {
16078
16097
  return false;
16079
16098
  }
16080
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
16099
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
16081
16100
  return true;
16082
16101
  }
16083
16102
  for (let i = 0; i < props.length; i++) {
@@ -16110,7 +16129,6 @@ function isUpperCase(c) {
16110
16129
  }
16111
16130
  const windowsNewlineRE = /\r\n/g;
16112
16131
  function condenseWhitespace(nodes, tag) {
16113
- var _a, _b;
16114
16132
  const shouldCondense = currentOptions.whitespace !== "preserve";
16115
16133
  let removedWhitespace = false;
16116
16134
  for (let i = 0; i < nodes.length; i++) {
@@ -16118,8 +16136,8 @@ function condenseWhitespace(nodes, tag) {
16118
16136
  if (node.type === 2) {
16119
16137
  if (!inPre) {
16120
16138
  if (isAllWhitespace(node.content)) {
16121
- const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
16122
- const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
16139
+ const prev = nodes[i - 1] && nodes[i - 1].type;
16140
+ const next = nodes[i + 1] && nodes[i + 1].type;
16123
16141
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
16124
16142
  removedWhitespace = true;
16125
16143
  nodes[i] = null;
@@ -16279,7 +16297,7 @@ function baseParse(input, options) {
16279
16297
  }
16280
16298
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
16281
16299
  tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
16282
- const delimiters = options == null ? void 0 : options.delimiters;
16300
+ const delimiters = options && options.delimiters;
16283
16301
  if (delimiters) {
16284
16302
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
16285
16303
  tokenizer.delimiterClose = toCharCodes(delimiters[1]);
@@ -17637,7 +17655,6 @@ function genReturnStatement({ returns }, context) {
17637
17655
  }
17638
17656
 
17639
17657
  const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
17640
- const constantBailRE = /\w\s*\(|\.[^\d]/;
17641
17658
  const transformExpression = (node, context) => {
17642
17659
  if (node.type === 5) {
17643
17660
  node.content = processExpression(
@@ -17732,7 +17749,6 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17732
17749
  return `_ctx.${raw}`;
17733
17750
  };
17734
17751
  const rawExp = node.content;
17735
- const bailConstant = constantBailRE.test(rawExp);
17736
17752
  let ast = node.ast;
17737
17753
  if (ast === false) {
17738
17754
  return node;
@@ -17794,7 +17810,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17794
17810
  node2.name = rewriteIdentifier(node2.name, parent, node2);
17795
17811
  ids.push(node2);
17796
17812
  } else {
17797
- if (!(needPrefix && isLocal) && !bailConstant) {
17813
+ if (!(needPrefix && isLocal) && parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression") {
17798
17814
  node2.isConstant = true;
17799
17815
  }
17800
17816
  ids.push(node2);
@@ -17838,7 +17854,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17838
17854
  ret.ast = ast;
17839
17855
  } else {
17840
17856
  ret = node;
17841
- ret.constType = bailConstant ? 0 : 3;
17857
+ ret.constType = 3;
17842
17858
  }
17843
17859
  ret.identifiers = Object.keys(knownIds);
17844
17860
  return ret;