@vue/compat 3.6.0-rc.7 → 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.7
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
  }
@@ -540,6 +555,8 @@ var Vue = (function() {
540
555
  function warn$2(msg, ...args) {
541
556
  console.warn(`[Vue warn] ${msg}`, ...args);
542
557
  }
558
+ //#endregion
559
+ //#region packages/reactivity/src/system.ts
543
560
  const notifyBuffer = [];
544
561
  let batchDepth = 0;
545
562
  let activeSub = void 0;
@@ -866,13 +883,17 @@ var Vue = (function() {
866
883
  /**
867
884
  * Track array iteration and return:
868
885
  * - if input is reactive: a cloned raw array with reactive values
869
- * - 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
870
889
  */
871
890
  function reactiveReadArray(array) {
872
891
  const raw = /* @__PURE__ */ toRaw(array);
873
892
  if (raw === array) return raw;
874
893
  track(raw, "iterate", ARRAY_ITERATE_KEY);
875
- 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);
876
897
  }
877
898
  /**
878
899
  * Track array iteration and return raw array
@@ -4382,12 +4403,12 @@ var Vue = (function() {
4382
4403
  } else {
4383
4404
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
4384
4405
  const component = vnode.component;
4385
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
4406
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
4386
4407
  let subTree;
4387
4408
  if (isFragmentStart) {
4388
4409
  subTree = createVNode(Static);
4389
4410
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
4390
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
4411
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
4391
4412
  subTree.el = node;
4392
4413
  component.subTree = subTree;
4393
4414
  }
@@ -6181,37 +6202,32 @@ var Vue = (function() {
6181
6202
  function withAsyncContext(getAwaitable) {
6182
6203
  const ctx = getCurrentGenericInstance();
6183
6204
  const inSSRSetup = isInSSRComponentSetup;
6184
- const restoreAsyncContext = ctx && ctx.restoreAsyncContext ? ctx.restoreAsyncContext.bind(ctx) : void 0;
6185
6205
  if (!ctx) warn$1("withAsyncContext called without active current instance. This is likely a bug.");
6186
6206
  let awaitable = getAwaitable();
6187
6207
  setCurrentInstance(null, void 0);
6188
6208
  if (inSSRSetup) setInSSRSetupState(false);
6189
6209
  const restore = () => {
6190
- const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
6210
+ const stoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
6191
6211
  setCurrentInstance(ctx);
6192
6212
  if (inSSRSetup) setInSSRSetupState(true);
6193
- const reset = restoreAsyncContext && restoreAsyncContext();
6194
- return () => {
6195
- if (reset) reset();
6196
- if (resetStoppedScope) resetStoppedScope.reset();
6197
- };
6213
+ return stoppedScope;
6198
6214
  };
6199
6215
  const cleanup = () => {
6200
6216
  setCurrentInstance(null, void 0);
6201
6217
  if (inSSRSetup) setInSSRSetupState(false);
6202
6218
  };
6203
6219
  if (isPromise(awaitable)) awaitable = awaitable.catch((e) => {
6204
- const reset = restore();
6220
+ const stoppedScope = restore();
6205
6221
  Promise.resolve().then(() => Promise.resolve().then(() => {
6206
- if (reset) reset();
6222
+ if (stoppedScope) stoppedScope.reset();
6207
6223
  cleanup();
6208
6224
  }));
6209
6225
  throw e;
6210
6226
  });
6211
6227
  return [awaitable, () => {
6212
- const reset = restore();
6228
+ const stoppedScope = restore();
6213
6229
  Promise.resolve().then(() => {
6214
- if (reset) reset();
6230
+ if (stoppedScope) stoppedScope.reset();
6215
6231
  cleanup();
6216
6232
  });
6217
6233
  }];
@@ -6536,7 +6552,7 @@ var Vue = (function() {
6536
6552
  if (options.el) return vm.$mount(options.el);
6537
6553
  else return vm;
6538
6554
  }
6539
- Vue.version = `2.6.14-compat:3.6.0-rc.7`;
6555
+ Vue.version = `2.6.14-compat:3.6.0-rc.9`;
6540
6556
  Vue.config = singletonApp.config;
6541
6557
  Vue.use = (plugin, ...options) => {
6542
6558
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -7876,6 +7892,10 @@ var Vue = (function() {
7876
7892
  optimized = false;
7877
7893
  n2.dynamicChildren = null;
7878
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
+ }
7879
7899
  const { type, ref, shapeFlag } = n2;
7880
7900
  switch (type) {
7881
7901
  case Text:
@@ -8195,6 +8215,7 @@ var Vue = (function() {
8195
8215
  if (shouldUpdateComponent(n1, n2, optimized)) {
8196
8216
  if (instance.asyncDep && !instance.asyncResolved) {
8197
8217
  pushWarningContext(n2);
8218
+ n2.el = n1.el;
8198
8219
  updateComponentPreRender(instance, n2, optimized);
8199
8220
  popWarningContext();
8200
8221
  return;
@@ -8510,13 +8531,13 @@ var Vue = (function() {
8510
8531
  };
8511
8532
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
8512
8533
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
8513
- if (patchFlag === -2) optimized = false;
8534
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
8514
8535
  if (ref != null) {
8515
8536
  const prevSub = setActiveSub();
8516
8537
  setRef(ref, null, parentSuspense, vnode, true);
8517
8538
  setActiveSub(prevSub);
8518
8539
  }
8519
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
8540
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
8520
8541
  if (shapeFlag & 256) {
8521
8542
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
8522
8543
  else parentComponent.ctx.deactivate(vnode);
@@ -8570,6 +8591,7 @@ var Vue = (function() {
8570
8591
  }
8571
8592
  if (type === Static) {
8572
8593
  removeStaticNode(vnode);
8594
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
8573
8595
  return;
8574
8596
  }
8575
8597
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -8595,7 +8617,10 @@ var Vue = (function() {
8595
8617
  if (effect) {
8596
8618
  effect.stop();
8597
8619
  unmount(subTree, instance, parentSuspense, doRemove);
8598
- } 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
+ }
8599
8624
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
8600
8625
  if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) queuePostRenderEffect(() => instance.emit("hook:destroyed"), void 0, parentSuspense);
8601
8626
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
@@ -8802,7 +8827,7 @@ var Vue = (function() {
8802
8827
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
8803
8828
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
8804
8829
  else {
8805
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
8830
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
8806
8831
  n2.suspense = n1.suspense;
8807
8832
  n2.suspense.vnode = n2;
8808
8833
  n2.el = n1.el;
@@ -8840,7 +8865,9 @@ var Vue = (function() {
8840
8865
  if (pendingBranch) {
8841
8866
  suspense.pendingBranch = newBranch;
8842
8867
  if (isSameVNodeType(pendingBranch, newBranch)) {
8843
- 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--;
8844
8871
  if (suspense.deps <= 0) suspense.resolve();
8845
8872
  else if (isInFallback) {
8846
8873
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -8976,6 +9003,7 @@ var Vue = (function() {
8976
9003
  suspense.effects = [];
8977
9004
  if (isSuspensible) {
8978
9005
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
9006
+ parentSuspenseId = void 0;
8979
9007
  parentSuspense.deps--;
8980
9008
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
8981
9009
  }
@@ -9013,11 +9041,16 @@ var Vue = (function() {
9013
9041
  registerDep(instance, onResolve) {
9014
9042
  const isInPendingSuspense = !!suspense.pendingBranch;
9015
9043
  if (isInPendingSuspense) suspense.deps++;
9044
+ const hydratedEl = instance.vnode && instance.vnode.el;
9016
9045
  instance.asyncDep.catch((err) => {
9017
9046
  handleError(err, instance, 0);
9018
9047
  }).then((asyncSetupResult) => {
9019
9048
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
9020
9049
  setCurrentInstance(null, void 0);
9050
+ if (hydratedEl && !instance.scope.active) {
9051
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
9052
+ return;
9053
+ }
9021
9054
  instance.asyncResolved = true;
9022
9055
  onResolve(asyncSetupResult);
9023
9056
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -9373,7 +9406,8 @@ var Vue = (function() {
9373
9406
  vs: cloneVaporSlotMeta(vnode),
9374
9407
  vb: vnode.vb,
9375
9408
  ibu: vnode.ibu,
9376
- iu: vnode.iu
9409
+ iu: vnode.iu,
9410
+ cacheIndex: vnode.cacheIndex
9377
9411
  };
9378
9412
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
9379
9413
  defineLegacyVNodeProperties(cloned);
@@ -10078,7 +10112,7 @@ var Vue = (function() {
10078
10112
  }
10079
10113
  //#endregion
10080
10114
  //#region packages/runtime-core/src/index.ts
10081
- const version = "3.6.0-rc.7";
10115
+ const version = "3.6.0-rc.9";
10082
10116
  const warn = warn$1;
10083
10117
  /**
10084
10118
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -10471,49 +10505,20 @@ var Vue = (function() {
10471
10505
  */
10472
10506
  function useCssVars(getter) {
10473
10507
  const instance = getCurrentInstance();
10474
- const getVars = () => getter(instance.proxy);
10475
- const setVars = (vars) => {
10476
- if (instance.ce) setVarsOnNode(instance.ce, vars);
10477
- else setVarsOnVNode(instance.subTree, vars);
10478
- };
10479
- baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
10480
- }
10481
- function setVarsOnVNode(vnode, vars) {
10482
- if (vnode.shapeFlag & 128) {
10483
- const suspense = vnode.suspense;
10484
- vnode = suspense.activeBranch;
10485
- if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
10486
- setVarsOnVNode(suspense.activeBranch, vars);
10487
- });
10488
- }
10489
- while (vnode.component) vnode = vnode.component.subTree;
10490
- if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
10491
- else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
10492
- else if (vnode.type === Static) {
10493
- let { el, anchor } = vnode;
10494
- while (el) {
10495
- setVarsOnNode(el, vars);
10496
- if (el === anchor) break;
10497
- el = el.nextSibling;
10498
- }
10499
- }
10500
- }
10501
- /**
10502
- * @internal
10503
- * shared between vdom and vapor
10504
- */
10505
- function baseUseCssVars(instance, getParentNode, getVars, setVars) {
10506
10508
  /* v8 ignore start */
10507
10509
  if (!instance) {
10508
10510
  warn(`useCssVars is called without current active component instance.`);
10509
10511
  return;
10510
10512
  }
10513
+ /* v8 ignore stop */
10514
+ const getVars = () => getter(instance.proxy);
10511
10515
  instance.getCssVars = getVars;
10512
10516
  const updateTeleports = instance.ut = (vars = getVars()) => {
10513
10517
  Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
10514
10518
  };
10515
10519
  const applyCssVars = (vars = getVars()) => {
10516
- setVars(vars);
10520
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
10521
+ else setVarsOnVNode(instance.subTree, vars);
10517
10522
  updateTeleports(vars);
10518
10523
  };
10519
10524
  onBeforeUpdate(() => {
@@ -10526,10 +10531,37 @@ var Vue = (function() {
10526
10531
  applyCssVars(vars);
10527
10532
  }, NOOP, { flush: "post" });
10528
10533
  const ob = new MutationObserver(() => applyCssVars());
10529
- ob.observe(getParentNode(), { childList: true });
10534
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
10530
10535
  onUnmounted(() => ob.disconnect());
10531
10536
  });
10532
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
+ }
10533
10565
  /**
10534
10566
  * @internal
10535
10567
  * shared between vdom and vapor