vue 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 v3.5.0-alpha.1
2
+ * vue v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.0-alpha.1
2
+ * vue v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.0-alpha.1
2
+ * vue 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
  };
@@ -2082,7 +2083,9 @@ const ErrorCodes = {
2082
2083
  "ASYNC_COMPONENT_LOADER": 13,
2083
2084
  "13": "ASYNC_COMPONENT_LOADER",
2084
2085
  "SCHEDULER": 14,
2085
- "14": "SCHEDULER"
2086
+ "14": "SCHEDULER",
2087
+ "APP_UNMOUNT_CLEANUP": 15,
2088
+ "15": "APP_UNMOUNT_CLEANUP"
2086
2089
  };
2087
2090
  const ErrorTypeStrings$1 = {
2088
2091
  ["sp"]: "serverPrefetch hook",
@@ -2113,7 +2116,8 @@ const ErrorTypeStrings$1 = {
2113
2116
  [11]: "app warnHandler",
2114
2117
  [12]: "ref function",
2115
2118
  [13]: "async component loader",
2116
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2119
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2120
+ [15]: "app unmount cleanup function"
2117
2121
  };
2118
2122
  function callWithErrorHandling(fn, instance, type, args) {
2119
2123
  try {
@@ -2838,7 +2842,7 @@ function renderComponentRoot(instance) {
2838
2842
  true ? {
2839
2843
  get attrs() {
2840
2844
  markAttrsAccessed();
2841
- return attrs;
2845
+ return shallowReadonly(attrs);
2842
2846
  },
2843
2847
  slots,
2844
2848
  emit
@@ -2871,7 +2875,7 @@ function renderComponentRoot(instance) {
2871
2875
  propsOptions
2872
2876
  );
2873
2877
  }
2874
- root = cloneVNode(root, fallthroughAttrs);
2878
+ root = cloneVNode(root, fallthroughAttrs, false, true);
2875
2879
  } else if (!accessedAttrs && root.type !== Comment) {
2876
2880
  const allAttrs = Object.keys(attrs);
2877
2881
  const eventAttrs = [];
@@ -2905,7 +2909,7 @@ function renderComponentRoot(instance) {
2905
2909
  `Runtime directive used on component with non-element root node. The directives will not function as intended.`
2906
2910
  );
2907
2911
  }
2908
- root = cloneVNode(root);
2912
+ root = cloneVNode(root, null, false, true);
2909
2913
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2910
2914
  }
2911
2915
  if (vnode.transition) {
@@ -3396,7 +3400,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3396
3400
  let parentSuspenseId;
3397
3401
  const isSuspensible = isVNodeSuspensible(vnode);
3398
3402
  if (isSuspensible) {
3399
- if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
3403
+ if (parentSuspense && parentSuspense.pendingBranch) {
3400
3404
  parentSuspenseId = parentSuspense.pendingId;
3401
3405
  parentSuspense.deps++;
3402
3406
  }
@@ -3708,8 +3712,8 @@ function setActiveBranch(suspense, branch) {
3708
3712
  }
3709
3713
  }
3710
3714
  function isVNodeSuspensible(vnode) {
3711
- var _a;
3712
- return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
3715
+ const suspensible = vnode.props && vnode.props.suspensible;
3716
+ return suspensible != null && suspensible !== false;
3713
3717
  }
3714
3718
 
3715
3719
  const ssrContextKey = Symbol.for("v-scx");
@@ -3945,34 +3949,29 @@ function createPathGetter(ctx, path) {
3945
3949
  return cur;
3946
3950
  };
3947
3951
  }
3948
- function traverse(value, depth, currentDepth = 0, seen) {
3949
- if (!isObject(value) || value["__v_skip"]) {
3952
+ function traverse(value, depth = Infinity, seen) {
3953
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
3950
3954
  return value;
3951
3955
  }
3952
- if (depth && depth > 0) {
3953
- if (currentDepth >= depth) {
3954
- return value;
3955
- }
3956
- currentDepth++;
3957
- }
3958
3956
  seen = seen || /* @__PURE__ */ new Set();
3959
3957
  if (seen.has(value)) {
3960
3958
  return value;
3961
3959
  }
3962
3960
  seen.add(value);
3961
+ depth--;
3963
3962
  if (isRef(value)) {
3964
- traverse(value.value, depth, currentDepth, seen);
3963
+ traverse(value.value, depth, seen);
3965
3964
  } else if (isArray(value)) {
3966
3965
  for (let i = 0; i < value.length; i++) {
3967
- traverse(value[i], depth, currentDepth, seen);
3966
+ traverse(value[i], depth, seen);
3968
3967
  }
3969
3968
  } else if (isSet(value) || isMap(value)) {
3970
3969
  value.forEach((v) => {
3971
- traverse(v, depth, currentDepth, seen);
3970
+ traverse(v, depth, seen);
3972
3971
  });
3973
3972
  } else if (isPlainObject(value)) {
3974
3973
  for (const key in value) {
3975
- traverse(value[key], depth, currentDepth, seen);
3974
+ traverse(value[key], depth, seen);
3976
3975
  }
3977
3976
  }
3978
3977
  return value;
@@ -4115,7 +4114,7 @@ const BaseTransitionImpl = {
4115
4114
  instance
4116
4115
  );
4117
4116
  setTransitionHooks(oldInnerChild, leavingHooks);
4118
- if (mode === "out-in") {
4117
+ if (mode === "out-in" && innerChild.type !== Comment) {
4119
4118
  state.isLeaving = true;
4120
4119
  leavingHooks.afterLeave = () => {
4121
4120
  state.isLeaving = false;
@@ -4650,7 +4649,7 @@ const KeepAliveImpl = {
4650
4649
  return () => {
4651
4650
  pendingCacheKey = null;
4652
4651
  if (!slots.default) {
4653
- return current = null;
4652
+ return null;
4654
4653
  }
4655
4654
  const children = slots.default();
4656
4655
  const rawVNode = children[0];
@@ -5756,6 +5755,7 @@ function createAppAPI(render, hydrate) {
5756
5755
  }
5757
5756
  const context = createAppContext();
5758
5757
  const installedPlugins = /* @__PURE__ */ new WeakSet();
5758
+ const pluginCleanupFns = [];
5759
5759
  let isMounted = false;
5760
5760
  const app = context.app = {
5761
5761
  _uid: uid$1++,
@@ -5873,8 +5873,21 @@ If you want to remount the same app, move your app creation logic into a factory
5873
5873
  );
5874
5874
  }
5875
5875
  },
5876
+ onUnmount(cleanupFn) {
5877
+ if (typeof cleanupFn !== "function") {
5878
+ warn$1(
5879
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
5880
+ );
5881
+ }
5882
+ pluginCleanupFns.push(cleanupFn);
5883
+ },
5876
5884
  unmount() {
5877
5885
  if (isMounted) {
5886
+ callWithAsyncErrorHandling(
5887
+ pluginCleanupFns,
5888
+ app._instance,
5889
+ 15
5890
+ );
5878
5891
  render(null, app._container);
5879
5892
  {
5880
5893
  app._instance = null;
@@ -6400,7 +6413,7 @@ const initSlots = (instance, children) => {
6400
6413
  const type = children._;
6401
6414
  if (type) {
6402
6415
  extend(slots, children);
6403
- def(slots, "_", type);
6416
+ def(slots, "_", type, true);
6404
6417
  } else {
6405
6418
  normalizeObjectSlots(children, slots);
6406
6419
  }
@@ -9146,8 +9159,8 @@ function guardReactiveProps(props) {
9146
9159
  return null;
9147
9160
  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
9148
9161
  }
9149
- function cloneVNode(vnode, extraProps, mergeRef = false) {
9150
- const { props, ref, patchFlag, children } = vnode;
9162
+ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
9163
+ const { props, ref, patchFlag, children, transition } = vnode;
9151
9164
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
9152
9165
  const cloned = {
9153
9166
  __v_isVNode: true,
@@ -9177,7 +9190,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
9177
9190
  dynamicChildren: vnode.dynamicChildren,
9178
9191
  appContext: vnode.appContext,
9179
9192
  dirs: vnode.dirs,
9180
- transition: vnode.transition,
9193
+ transition,
9181
9194
  // These should technically only be non-null on mounted VNodes. However,
9182
9195
  // they *should* be copied for kept-alive vnodes. So we just always copy
9183
9196
  // them since them being non-null during a mount doesn't affect the logic as
@@ -9191,6 +9204,9 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
9191
9204
  ctx: vnode.ctx,
9192
9205
  ce: vnode.ce
9193
9206
  };
9207
+ if (transition && cloneTransition) {
9208
+ cloned.transition = transition.clone(cloned);
9209
+ }
9194
9210
  return cloned;
9195
9211
  }
9196
9212
  function deepCloneVNode(vnode) {
@@ -10000,7 +10016,7 @@ function isMemoSame(cached, memo) {
10000
10016
  return true;
10001
10017
  }
10002
10018
 
10003
- const version = "3.5.0-alpha.1";
10019
+ const version = "3.5.0-alpha.2";
10004
10020
  const warn = warn$1 ;
10005
10021
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10006
10022
  const devtools = devtools$1 ;
@@ -13196,11 +13212,10 @@ const tokenizer = new Tokenizer(stack, {
13196
13212
  }
13197
13213
  },
13198
13214
  onselfclosingtag(end) {
13199
- var _a;
13200
13215
  const name = currentOpenTag.tag;
13201
13216
  currentOpenTag.isSelfClosing = true;
13202
13217
  endOpenTag(end);
13203
- if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
13218
+ if (stack[0] && stack[0].tag === name) {
13204
13219
  onCloseTag(stack.shift(), end);
13205
13220
  }
13206
13221
  },
@@ -13501,16 +13516,15 @@ function endOpenTag(end) {
13501
13516
  currentOpenTag = null;
13502
13517
  }
13503
13518
  function onText(content, start, end) {
13504
- var _a;
13505
13519
  {
13506
- const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
13520
+ const tag = stack[0] && stack[0].tag;
13507
13521
  if (tag !== "script" && tag !== "style" && content.includes("&")) {
13508
13522
  content = currentOptions.decodeEntities(content, false);
13509
13523
  }
13510
13524
  }
13511
13525
  const parent = stack[0] || currentRoot;
13512
13526
  const lastNode = parent.children[parent.children.length - 1];
13513
- if ((lastNode == null ? void 0 : lastNode.type) === 2) {
13527
+ if (lastNode && lastNode.type === 2) {
13514
13528
  lastNode.content += content;
13515
13529
  setLocEnd(lastNode.loc, end);
13516
13530
  } else {
@@ -13586,11 +13600,10 @@ function isFragmentTemplate({ tag, props }) {
13586
13600
  return false;
13587
13601
  }
13588
13602
  function isComponent({ tag, props }) {
13589
- var _a;
13590
13603
  if (currentOptions.isCustomElement(tag)) {
13591
13604
  return false;
13592
13605
  }
13593
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
13606
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
13594
13607
  return true;
13595
13608
  }
13596
13609
  for (let i = 0; i < props.length; i++) {
@@ -13610,7 +13623,6 @@ function isUpperCase(c) {
13610
13623
  }
13611
13624
  const windowsNewlineRE = /\r\n/g;
13612
13625
  function condenseWhitespace(nodes, tag) {
13613
- var _a, _b;
13614
13626
  const shouldCondense = currentOptions.whitespace !== "preserve";
13615
13627
  let removedWhitespace = false;
13616
13628
  for (let i = 0; i < nodes.length; i++) {
@@ -13618,8 +13630,8 @@ function condenseWhitespace(nodes, tag) {
13618
13630
  if (node.type === 2) {
13619
13631
  if (!inPre) {
13620
13632
  if (isAllWhitespace(node.content)) {
13621
- const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
13622
- const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
13633
+ const prev = nodes[i - 1] && nodes[i - 1].type;
13634
+ const next = nodes[i + 1] && nodes[i + 1].type;
13623
13635
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
13624
13636
  removedWhitespace = true;
13625
13637
  nodes[i] = null;
@@ -13757,7 +13769,7 @@ function baseParse(input, options) {
13757
13769
  }
13758
13770
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
13759
13771
  tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
13760
- const delimiters = options == null ? void 0 : options.delimiters;
13772
+ const delimiters = options && options.delimiters;
13761
13773
  if (delimiters) {
13762
13774
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
13763
13775
  tokenizer.delimiterClose = toCharCodes(delimiters[1]);