@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.
@@ -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
  **/
@@ -81,10 +81,11 @@ const invokeArrayFns = (fns, arg) => {
81
81
  fns[i](arg);
82
82
  }
83
83
  };
84
- const def = (obj, key, value) => {
84
+ const def = (obj, key, value, writable = false) => {
85
85
  Object.defineProperty(obj, key, {
86
86
  configurable: true,
87
87
  enumerable: false,
88
+ writable,
88
89
  value
89
90
  });
90
91
  };
@@ -2017,7 +2018,9 @@ const ErrorCodes = {
2017
2018
  "ASYNC_COMPONENT_LOADER": 13,
2018
2019
  "13": "ASYNC_COMPONENT_LOADER",
2019
2020
  "SCHEDULER": 14,
2020
- "14": "SCHEDULER"
2021
+ "14": "SCHEDULER",
2022
+ "APP_UNMOUNT_CLEANUP": 15,
2023
+ "15": "APP_UNMOUNT_CLEANUP"
2021
2024
  };
2022
2025
  const ErrorTypeStrings$1 = {
2023
2026
  ["sp"]: "serverPrefetch hook",
@@ -2048,7 +2051,8 @@ const ErrorTypeStrings$1 = {
2048
2051
  [11]: "app warnHandler",
2049
2052
  [12]: "ref function",
2050
2053
  [13]: "async component loader",
2051
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2054
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2055
+ [15]: "app unmount cleanup function"
2052
2056
  };
2053
2057
  function callWithErrorHandling(fn, instance, type, args) {
2054
2058
  try {
@@ -3269,7 +3273,7 @@ function renderComponentRoot(instance) {
3269
3273
  true ? {
3270
3274
  get attrs() {
3271
3275
  markAttrsAccessed();
3272
- return attrs;
3276
+ return shallowReadonly(attrs);
3273
3277
  },
3274
3278
  slots,
3275
3279
  emit
@@ -3302,7 +3306,7 @@ function renderComponentRoot(instance) {
3302
3306
  propsOptions
3303
3307
  );
3304
3308
  }
3305
- root = cloneVNode(root, fallthroughAttrs);
3309
+ root = cloneVNode(root, fallthroughAttrs, false, true);
3306
3310
  } else if (!accessedAttrs && root.type !== Comment) {
3307
3311
  const allAttrs = Object.keys(attrs);
3308
3312
  const eventAttrs = [];
@@ -3340,10 +3344,15 @@ function renderComponentRoot(instance) {
3340
3344
  getComponentName(instance.type)
3341
3345
  );
3342
3346
  }
3343
- root = cloneVNode(root, {
3344
- class: cls,
3345
- style
3346
- });
3347
+ root = cloneVNode(
3348
+ root,
3349
+ {
3350
+ class: cls,
3351
+ style
3352
+ },
3353
+ false,
3354
+ true
3355
+ );
3347
3356
  }
3348
3357
  }
3349
3358
  if (vnode.dirs) {
@@ -3352,7 +3361,7 @@ function renderComponentRoot(instance) {
3352
3361
  `Runtime directive used on component with non-element root node. The directives will not function as intended.`
3353
3362
  );
3354
3363
  }
3355
- root = cloneVNode(root);
3364
+ root = cloneVNode(root, null, false, true);
3356
3365
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3357
3366
  }
3358
3367
  if (vnode.transition) {
@@ -3847,7 +3856,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3847
3856
  let parentSuspenseId;
3848
3857
  const isSuspensible = isVNodeSuspensible(vnode);
3849
3858
  if (isSuspensible) {
3850
- if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
3859
+ if (parentSuspense && parentSuspense.pendingBranch) {
3851
3860
  parentSuspenseId = parentSuspense.pendingId;
3852
3861
  parentSuspense.deps++;
3853
3862
  }
@@ -4159,8 +4168,8 @@ function setActiveBranch(suspense, branch) {
4159
4168
  }
4160
4169
  }
4161
4170
  function isVNodeSuspensible(vnode) {
4162
- var _a;
4163
- return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
4171
+ const suspensible = vnode.props && vnode.props.suspensible;
4172
+ return suspensible != null && suspensible !== false;
4164
4173
  }
4165
4174
 
4166
4175
  const legacyDirectiveHookMap = {
@@ -4444,34 +4453,29 @@ function createPathGetter(ctx, path) {
4444
4453
  return cur;
4445
4454
  };
4446
4455
  }
4447
- function traverse(value, depth, currentDepth = 0, seen) {
4448
- if (!isObject(value) || value["__v_skip"]) {
4456
+ function traverse(value, depth = Infinity, seen) {
4457
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
4449
4458
  return value;
4450
4459
  }
4451
- if (depth && depth > 0) {
4452
- if (currentDepth >= depth) {
4453
- return value;
4454
- }
4455
- currentDepth++;
4456
- }
4457
4460
  seen = seen || /* @__PURE__ */ new Set();
4458
4461
  if (seen.has(value)) {
4459
4462
  return value;
4460
4463
  }
4461
4464
  seen.add(value);
4465
+ depth--;
4462
4466
  if (isRef(value)) {
4463
- traverse(value.value, depth, currentDepth, seen);
4467
+ traverse(value.value, depth, seen);
4464
4468
  } else if (isArray(value)) {
4465
4469
  for (let i = 0; i < value.length; i++) {
4466
- traverse(value[i], depth, currentDepth, seen);
4470
+ traverse(value[i], depth, seen);
4467
4471
  }
4468
4472
  } else if (isSet(value) || isMap(value)) {
4469
4473
  value.forEach((v) => {
4470
- traverse(v, depth, currentDepth, seen);
4474
+ traverse(v, depth, seen);
4471
4475
  });
4472
4476
  } else if (isPlainObject(value)) {
4473
4477
  for (const key in value) {
4474
- traverse(value[key], depth, currentDepth, seen);
4478
+ traverse(value[key], depth, seen);
4475
4479
  }
4476
4480
  }
4477
4481
  return value;
@@ -4617,7 +4621,7 @@ const BaseTransitionImpl = {
4617
4621
  instance
4618
4622
  );
4619
4623
  setTransitionHooks(oldInnerChild, leavingHooks);
4620
- if (mode === "out-in") {
4624
+ if (mode === "out-in" && innerChild.type !== Comment) {
4621
4625
  state.isLeaving = true;
4622
4626
  leavingHooks.afterLeave = () => {
4623
4627
  state.isLeaving = false;
@@ -5155,7 +5159,7 @@ const KeepAliveImpl = {
5155
5159
  return () => {
5156
5160
  pendingCacheKey = null;
5157
5161
  if (!slots.default) {
5158
- return current = null;
5162
+ return null;
5159
5163
  }
5160
5164
  const children = slots.default();
5161
5165
  const rawVNode = children[0];
@@ -6860,13 +6864,13 @@ function createCompatVue$1(createApp, createSingletonApp) {
6860
6864
  return vm;
6861
6865
  }
6862
6866
  }
6863
- Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6867
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.2"}`;
6864
6868
  Vue.config = singletonApp.config;
6865
- Vue.use = (p, ...options) => {
6866
- if (p && isFunction(p.install)) {
6867
- p.install(Vue, ...options);
6868
- } else if (isFunction(p)) {
6869
- p(Vue, ...options);
6869
+ Vue.use = (plugin, ...options) => {
6870
+ if (plugin && isFunction(plugin.install)) {
6871
+ plugin.install(Vue, ...options);
6872
+ } else if (isFunction(plugin)) {
6873
+ plugin(Vue, ...options);
6870
6874
  }
6871
6875
  return Vue;
6872
6876
  };
@@ -7265,6 +7269,7 @@ function createAppAPI(render, hydrate) {
7265
7269
  }
7266
7270
  const context = createAppContext();
7267
7271
  const installedPlugins = /* @__PURE__ */ new WeakSet();
7272
+ const pluginCleanupFns = [];
7268
7273
  let isMounted = false;
7269
7274
  const app = context.app = {
7270
7275
  _uid: uid$1++,
@@ -7382,8 +7387,21 @@ If you want to remount the same app, move your app creation logic into a factory
7382
7387
  );
7383
7388
  }
7384
7389
  },
7390
+ onUnmount(cleanupFn) {
7391
+ if (typeof cleanupFn !== "function") {
7392
+ warn$1(
7393
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
7394
+ );
7395
+ }
7396
+ pluginCleanupFns.push(cleanupFn);
7397
+ },
7385
7398
  unmount() {
7386
7399
  if (isMounted) {
7400
+ callWithAsyncErrorHandling(
7401
+ pluginCleanupFns,
7402
+ app._instance,
7403
+ 15
7404
+ );
7387
7405
  render(null, app._container);
7388
7406
  {
7389
7407
  app._instance = null;
@@ -7984,7 +8002,7 @@ const initSlots = (instance, children) => {
7984
8002
  const type = children._;
7985
8003
  if (type) {
7986
8004
  extend(slots, children);
7987
- def(slots, "_", type);
8005
+ def(slots, "_", type, true);
7988
8006
  } else {
7989
8007
  normalizeObjectSlots(children, slots, instance);
7990
8008
  }
@@ -10822,8 +10840,8 @@ function guardReactiveProps(props) {
10822
10840
  return null;
10823
10841
  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
10824
10842
  }
10825
- function cloneVNode(vnode, extraProps, mergeRef = false) {
10826
- const { props, ref, patchFlag, children } = vnode;
10843
+ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
10844
+ const { props, ref, patchFlag, children, transition } = vnode;
10827
10845
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
10828
10846
  const cloned = {
10829
10847
  __v_isVNode: true,
@@ -10853,7 +10871,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10853
10871
  dynamicChildren: vnode.dynamicChildren,
10854
10872
  appContext: vnode.appContext,
10855
10873
  dirs: vnode.dirs,
10856
- transition: vnode.transition,
10874
+ transition,
10857
10875
  // These should technically only be non-null on mounted VNodes. However,
10858
10876
  // they *should* be copied for kept-alive vnodes. So we just always copy
10859
10877
  // them since them being non-null during a mount doesn't affect the logic as
@@ -10867,6 +10885,9 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10867
10885
  ctx: vnode.ctx,
10868
10886
  ce: vnode.ce
10869
10887
  };
10888
+ if (transition && cloneTransition) {
10889
+ cloned.transition = transition.clone(cloned);
10890
+ }
10870
10891
  {
10871
10892
  defineLegacyVNodeProperties(cloned);
10872
10893
  }
@@ -11691,7 +11712,7 @@ function isMemoSame(cached, memo) {
11691
11712
  return true;
11692
11713
  }
11693
11714
 
11694
- const version = "3.5.0-alpha.1";
11715
+ const version = "3.5.0-alpha.2";
11695
11716
  const warn = warn$1 ;
11696
11717
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11697
11718
  const devtools = devtools$1 ;