@vue/compat 3.6.0-rc.8 → 3.6.0-rc.9

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.6.0-rc.8
2
+ * @vue/compat v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -232,10 +232,10 @@ var Vue = (function() {
232
232
  }
233
233
  const listDelimiterRE = /;(?![^(]*\))/g;
234
234
  const propertyDelimiterRE = /:([^]+)/;
235
- const styleCommentRE = /\/\*[^]*?\*\//g;
235
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
236
236
  function parseStringStyle(cssText) {
237
237
  const ret = {};
238
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
238
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
239
239
  if (item) {
240
240
  const tmp = item.split(propertyDelimiterRE);
241
241
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -363,19 +363,19 @@ var Vue = (function() {
363
363
  }
364
364
  //#endregion
365
365
  //#region packages/shared/src/looseEqual.ts
366
- function looseCompareArrays(a, b) {
366
+ function looseCompareArrays(a, b, seen) {
367
367
  if (a.length !== b.length) return false;
368
368
  let equal = true;
369
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
369
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
370
370
  return equal;
371
371
  }
372
- function looseCompareCollections(a, b) {
372
+ function looseCompareCollections(a, b, seen) {
373
373
  if (a.size !== b.size) return false;
374
374
  const candidates = Array.from(b);
375
375
  const matched = new Uint8Array(candidates.length);
376
376
  for (const item of a) {
377
377
  let index = -1;
378
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
378
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
379
379
  index = i;
380
380
  break;
381
381
  }
@@ -384,7 +384,33 @@ var Vue = (function() {
384
384
  }
385
385
  return true;
386
386
  }
387
- function looseEqual(a, b) {
387
+ function looseCompareObjects(a, b, seen) {
388
+ let aValidType = isMap(a);
389
+ let bValidType = isMap(b);
390
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
391
+ aValidType = isSet(a);
392
+ bValidType = isSet(b);
393
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
394
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
395
+ for (const key in a) {
396
+ const aHasKey = a.hasOwnProperty(key);
397
+ const bHasKey = b.hasOwnProperty(key);
398
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
399
+ }
400
+ return String(a) === String(b);
401
+ }
402
+ function looseCompareNested(a, b, seen, compare) {
403
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
404
+ const [seenA, seenB] = seen;
405
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
406
+ seenA.set(a, b);
407
+ seenB.set(b, a);
408
+ const equal = compare(a, b, seen);
409
+ seenA.delete(a);
410
+ seenB.delete(b);
411
+ return equal;
412
+ }
413
+ function looseEqual(a, b, seen) {
388
414
  if (a === b) return true;
389
415
  let aValidType = isDate(a);
390
416
  let bValidType = isDate(b);
@@ -394,23 +420,12 @@ var Vue = (function() {
394
420
  if (aValidType || bValidType) return a === b;
395
421
  aValidType = isArray(a);
396
422
  bValidType = isArray(b);
397
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
423
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
398
424
  aValidType = isObject(a);
399
425
  bValidType = isObject(b);
400
426
  if (aValidType || bValidType) {
401
427
  if (!aValidType || !bValidType) return false;
402
- aValidType = isMap(a);
403
- bValidType = isMap(b);
404
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
405
- aValidType = isSet(a);
406
- bValidType = isSet(b);
407
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
408
- if (Object.keys(a).length !== Object.keys(b).length) return false;
409
- for (const key in a) {
410
- const aHasKey = a.hasOwnProperty(key);
411
- const bHasKey = b.hasOwnProperty(key);
412
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
413
- }
428
+ return looseCompareNested(a, b, seen, looseCompareObjects);
414
429
  }
415
430
  return String(a) === String(b);
416
431
  }
@@ -868,13 +883,17 @@ var Vue = (function() {
868
883
  /**
869
884
  * Track array iteration and return:
870
885
  * - if input is reactive: a cloned raw array with reactive values
871
- * - if input is non-reactive or shallowReactive: the original raw array
886
+ * - if input is readonly: a cloned raw array with readonly values, preserving
887
+ * reactivity
888
+ * - if input is raw or shallow: the original raw array
872
889
  */
873
890
  function reactiveReadArray(array) {
874
891
  const raw = /* @__PURE__ */ toRaw(array);
875
892
  if (raw === array) return raw;
876
893
  track(raw, "iterate", ARRAY_ITERATE_KEY);
877
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
894
+ if (/* @__PURE__ */ isShallow(array)) return raw;
895
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
896
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
878
897
  }
879
898
  /**
880
899
  * Track array iteration and return raw array
@@ -4384,12 +4403,12 @@ var Vue = (function() {
4384
4403
  } else {
4385
4404
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
4386
4405
  const component = vnode.component;
4387
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
4406
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
4388
4407
  let subTree;
4389
4408
  if (isFragmentStart) {
4390
4409
  subTree = createVNode(Static);
4391
4410
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
4392
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
4411
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
4393
4412
  subTree.el = node;
4394
4413
  component.subTree = subTree;
4395
4414
  }
@@ -6533,7 +6552,7 @@ var Vue = (function() {
6533
6552
  if (options.el) return vm.$mount(options.el);
6534
6553
  else return vm;
6535
6554
  }
6536
- Vue.version = `2.6.14-compat:3.6.0-rc.8`;
6555
+ Vue.version = `2.6.14-compat:3.6.0-rc.9`;
6537
6556
  Vue.config = singletonApp.config;
6538
6557
  Vue.use = (plugin, ...options) => {
6539
6558
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -7873,6 +7892,10 @@ var Vue = (function() {
7873
7892
  optimized = false;
7874
7893
  n2.dynamicChildren = null;
7875
7894
  }
7895
+ if (n2.dynamicChildren && n1 && n1.dynamicChildren && n1.dynamicChildren.hasOnce) {
7896
+ if (n2.dynamicChildren === EMPTY_ARR) n2.dynamicChildren = [];
7897
+ n2.dynamicChildren.hasOnce = true;
7898
+ }
7876
7899
  const { type, ref, shapeFlag } = n2;
7877
7900
  switch (type) {
7878
7901
  case Text:
@@ -8192,6 +8215,7 @@ var Vue = (function() {
8192
8215
  if (shouldUpdateComponent(n1, n2, optimized)) {
8193
8216
  if (instance.asyncDep && !instance.asyncResolved) {
8194
8217
  pushWarningContext(n2);
8218
+ n2.el = n1.el;
8195
8219
  updateComponentPreRender(instance, n2, optimized);
8196
8220
  popWarningContext();
8197
8221
  return;
@@ -8507,13 +8531,13 @@ var Vue = (function() {
8507
8531
  };
8508
8532
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
8509
8533
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
8510
- if (patchFlag === -2) optimized = false;
8534
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
8511
8535
  if (ref != null) {
8512
8536
  const prevSub = setActiveSub();
8513
8537
  setRef(ref, null, parentSuspense, vnode, true);
8514
8538
  setActiveSub(prevSub);
8515
8539
  }
8516
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
8540
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
8517
8541
  if (shapeFlag & 256) {
8518
8542
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
8519
8543
  else parentComponent.ctx.deactivate(vnode);
@@ -8567,6 +8591,7 @@ var Vue = (function() {
8567
8591
  }
8568
8592
  if (type === Static) {
8569
8593
  removeStaticNode(vnode);
8594
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
8570
8595
  return;
8571
8596
  }
8572
8597
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -8592,7 +8617,10 @@ var Vue = (function() {
8592
8617
  if (effect) {
8593
8618
  effect.stop();
8594
8619
  unmount(subTree, instance, parentSuspense, doRemove);
8595
- } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
8620
+ } else if (instance.vnode.el && subTree) {
8621
+ subTree.transition = instance.vnode.transition;
8622
+ unmount(subTree, instance, parentSuspense, doRemove);
8623
+ }
8596
8624
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
8597
8625
  if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) queuePostRenderEffect(() => instance.emit("hook:destroyed"), void 0, parentSuspense);
8598
8626
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
@@ -8799,7 +8827,7 @@ var Vue = (function() {
8799
8827
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
8800
8828
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
8801
8829
  else {
8802
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
8830
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
8803
8831
  n2.suspense = n1.suspense;
8804
8832
  n2.suspense.vnode = n2;
8805
8833
  n2.el = n1.el;
@@ -8837,7 +8865,9 @@ var Vue = (function() {
8837
8865
  if (pendingBranch) {
8838
8866
  suspense.pendingBranch = newBranch;
8839
8867
  if (isSameVNodeType(pendingBranch, newBranch)) {
8840
- patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
8868
+ suspense.deps++;
8869
+ patch(pendingBranch, newBranch, isHydrating ? container : suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
8870
+ suspense.deps--;
8841
8871
  if (suspense.deps <= 0) suspense.resolve();
8842
8872
  else if (isInFallback) {
8843
8873
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -8973,6 +9003,7 @@ var Vue = (function() {
8973
9003
  suspense.effects = [];
8974
9004
  if (isSuspensible) {
8975
9005
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
9006
+ parentSuspenseId = void 0;
8976
9007
  parentSuspense.deps--;
8977
9008
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
8978
9009
  }
@@ -9010,11 +9041,16 @@ var Vue = (function() {
9010
9041
  registerDep(instance, onResolve) {
9011
9042
  const isInPendingSuspense = !!suspense.pendingBranch;
9012
9043
  if (isInPendingSuspense) suspense.deps++;
9044
+ const hydratedEl = instance.vnode && instance.vnode.el;
9013
9045
  instance.asyncDep.catch((err) => {
9014
9046
  handleError(err, instance, 0);
9015
9047
  }).then((asyncSetupResult) => {
9016
9048
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
9017
9049
  setCurrentInstance(null, void 0);
9050
+ if (hydratedEl && !instance.scope.active) {
9051
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
9052
+ return;
9053
+ }
9018
9054
  instance.asyncResolved = true;
9019
9055
  onResolve(asyncSetupResult);
9020
9056
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -9370,7 +9406,8 @@ var Vue = (function() {
9370
9406
  vs: cloneVaporSlotMeta(vnode),
9371
9407
  vb: vnode.vb,
9372
9408
  ibu: vnode.ibu,
9373
- iu: vnode.iu
9409
+ iu: vnode.iu,
9410
+ cacheIndex: vnode.cacheIndex
9374
9411
  };
9375
9412
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
9376
9413
  defineLegacyVNodeProperties(cloned);
@@ -10075,7 +10112,7 @@ var Vue = (function() {
10075
10112
  }
10076
10113
  //#endregion
10077
10114
  //#region packages/runtime-core/src/index.ts
10078
- const version = "3.6.0-rc.8";
10115
+ const version = "3.6.0-rc.9";
10079
10116
  const warn = warn$1;
10080
10117
  /**
10081
10118
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -10468,49 +10505,20 @@ var Vue = (function() {
10468
10505
  */
10469
10506
  function useCssVars(getter) {
10470
10507
  const instance = getCurrentInstance();
10471
- const getVars = () => getter(instance.proxy);
10472
- const setVars = (vars) => {
10473
- if (instance.ce) setVarsOnNode(instance.ce, vars);
10474
- else setVarsOnVNode(instance.subTree, vars);
10475
- };
10476
- baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
10477
- }
10478
- function setVarsOnVNode(vnode, vars) {
10479
- if (vnode.shapeFlag & 128) {
10480
- const suspense = vnode.suspense;
10481
- vnode = suspense.activeBranch;
10482
- if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
10483
- setVarsOnVNode(suspense.activeBranch, vars);
10484
- });
10485
- }
10486
- while (vnode.component) vnode = vnode.component.subTree;
10487
- if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
10488
- else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
10489
- else if (vnode.type === Static) {
10490
- let { el, anchor } = vnode;
10491
- while (el) {
10492
- setVarsOnNode(el, vars);
10493
- if (el === anchor) break;
10494
- el = el.nextSibling;
10495
- }
10496
- }
10497
- }
10498
- /**
10499
- * @internal
10500
- * shared between vdom and vapor
10501
- */
10502
- function baseUseCssVars(instance, getParentNode, getVars, setVars) {
10503
10508
  /* v8 ignore start */
10504
10509
  if (!instance) {
10505
10510
  warn(`useCssVars is called without current active component instance.`);
10506
10511
  return;
10507
10512
  }
10513
+ /* v8 ignore stop */
10514
+ const getVars = () => getter(instance.proxy);
10508
10515
  instance.getCssVars = getVars;
10509
10516
  const updateTeleports = instance.ut = (vars = getVars()) => {
10510
10517
  Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
10511
10518
  };
10512
10519
  const applyCssVars = (vars = getVars()) => {
10513
- setVars(vars);
10520
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
10521
+ else setVarsOnVNode(instance.subTree, vars);
10514
10522
  updateTeleports(vars);
10515
10523
  };
10516
10524
  onBeforeUpdate(() => {
@@ -10523,10 +10531,37 @@ var Vue = (function() {
10523
10531
  applyCssVars(vars);
10524
10532
  }, NOOP, { flush: "post" });
10525
10533
  const ob = new MutationObserver(() => applyCssVars());
10526
- ob.observe(getParentNode(), { childList: true });
10534
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
10527
10535
  onUnmounted(() => ob.disconnect());
10528
10536
  });
10529
10537
  }
10538
+ function setVarsOnVNode(vnode, vars) {
10539
+ if (vnode.shapeFlag & 128) {
10540
+ const suspense = vnode.suspense;
10541
+ vnode = suspense.activeBranch;
10542
+ if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
10543
+ setVarsOnVNode(suspense.activeBranch, vars);
10544
+ });
10545
+ }
10546
+ while (vnode.component) {
10547
+ const component = vnode.component;
10548
+ if (component.vapor) {
10549
+ component.appContext.vapor.applyCssVars(vnode, vars);
10550
+ return;
10551
+ }
10552
+ vnode = vnode.component.subTree;
10553
+ }
10554
+ if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
10555
+ else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
10556
+ else if (vnode.type === Static) {
10557
+ let { el, anchor } = vnode;
10558
+ while (el) {
10559
+ setVarsOnNode(el, vars);
10560
+ if (el === anchor) break;
10561
+ el = el.nextSibling;
10562
+ }
10563
+ }
10564
+ }
10530
10565
  /**
10531
10566
  * @internal
10532
10567
  * shared between vdom and vapor