@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
  **/
@@ -168,10 +168,10 @@ function normalizeStyle(value) {
168
168
  }
169
169
  const listDelimiterRE = /;(?![^(]*\))/g;
170
170
  const propertyDelimiterRE = /:([^]+)/;
171
- const styleCommentRE = /\/\*[^]*?\*\//g;
171
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
172
172
  function parseStringStyle(cssText) {
173
173
  const ret = {};
174
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
174
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
175
175
  if (item) {
176
176
  const tmp = item.split(propertyDelimiterRE);
177
177
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -325,19 +325,19 @@ function escapeHtml(string) {
325
325
  }
326
326
  //#endregion
327
327
  //#region packages/shared/src/looseEqual.ts
328
- function looseCompareArrays(a, b) {
328
+ function looseCompareArrays(a, b, seen) {
329
329
  if (a.length !== b.length) return false;
330
330
  let equal = true;
331
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
331
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
332
332
  return equal;
333
333
  }
334
- function looseCompareCollections(a, b) {
334
+ function looseCompareCollections(a, b, seen) {
335
335
  if (a.size !== b.size) return false;
336
336
  const candidates = Array.from(b);
337
337
  const matched = new Uint8Array(candidates.length);
338
338
  for (const item of a) {
339
339
  let index = -1;
340
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
340
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
341
341
  index = i;
342
342
  break;
343
343
  }
@@ -346,7 +346,33 @@ function looseCompareCollections(a, b) {
346
346
  }
347
347
  return true;
348
348
  }
349
- function looseEqual(a, b) {
349
+ function looseCompareObjects(a, b, seen) {
350
+ let aValidType = isMap(a);
351
+ let bValidType = isMap(b);
352
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
353
+ aValidType = isSet(a);
354
+ bValidType = isSet(b);
355
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
356
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
357
+ for (const key in a) {
358
+ const aHasKey = a.hasOwnProperty(key);
359
+ const bHasKey = b.hasOwnProperty(key);
360
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
361
+ }
362
+ return String(a) === String(b);
363
+ }
364
+ function looseCompareNested(a, b, seen, compare) {
365
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
366
+ const [seenA, seenB] = seen;
367
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
368
+ seenA.set(a, b);
369
+ seenB.set(b, a);
370
+ const equal = compare(a, b, seen);
371
+ seenA.delete(a);
372
+ seenB.delete(b);
373
+ return equal;
374
+ }
375
+ function looseEqual(a, b, seen) {
350
376
  if (a === b) return true;
351
377
  let aValidType = isDate(a);
352
378
  let bValidType = isDate(b);
@@ -356,23 +382,12 @@ function looseEqual(a, b) {
356
382
  if (aValidType || bValidType) return a === b;
357
383
  aValidType = isArray(a);
358
384
  bValidType = isArray(b);
359
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
385
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
360
386
  aValidType = isObject(a);
361
387
  bValidType = isObject(b);
362
388
  if (aValidType || bValidType) {
363
389
  if (!aValidType || !bValidType) return false;
364
- aValidType = isMap(a);
365
- bValidType = isMap(b);
366
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
367
- aValidType = isSet(a);
368
- bValidType = isSet(b);
369
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
370
- if (Object.keys(a).length !== Object.keys(b).length) return false;
371
- for (const key in a) {
372
- const aHasKey = a.hasOwnProperty(key);
373
- const bHasKey = b.hasOwnProperty(key);
374
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
375
- }
390
+ return looseCompareNested(a, b, seen, looseCompareObjects);
376
391
  }
377
392
  return String(a) === String(b);
378
393
  }
@@ -450,6 +465,8 @@ function getSequence(arr) {
450
465
  }
451
466
  return result;
452
467
  }
468
+ //#endregion
469
+ //#region packages/reactivity/src/system.ts
453
470
  const notifyBuffer = [];
454
471
  let batchDepth = 0;
455
472
  let activeSub = void 0;
@@ -761,13 +778,17 @@ function getDepFromReactive(object, key) {
761
778
  /**
762
779
  * Track array iteration and return:
763
780
  * - if input is reactive: a cloned raw array with reactive values
764
- * - if input is non-reactive or shallowReactive: the original raw array
781
+ * - if input is readonly: a cloned raw array with readonly values, preserving
782
+ * reactivity
783
+ * - if input is raw or shallow: the original raw array
765
784
  */
766
785
  function reactiveReadArray(array) {
767
786
  const raw = /* @__PURE__ */ toRaw(array);
768
787
  if (raw === array) return raw;
769
788
  track(raw, "iterate", ARRAY_ITERATE_KEY);
770
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
789
+ if (/* @__PURE__ */ isShallow(array)) return raw;
790
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
791
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
771
792
  }
772
793
  /**
773
794
  * Track array iteration and return raw array
@@ -3633,12 +3654,12 @@ function createHydrationFunctions(rendererInternals) {
3633
3654
  } else {
3634
3655
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
3635
3656
  const component = vnode.component;
3636
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
3657
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
3637
3658
  let subTree;
3638
3659
  if (isFragmentStart) {
3639
3660
  subTree = createVNode(Static);
3640
3661
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
3641
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
3662
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
3642
3663
  subTree.el = node;
3643
3664
  component.subTree = subTree;
3644
3665
  }
@@ -5169,36 +5190,31 @@ function createPropsRestProxy(props, excludedKeys) {
5169
5190
  function withAsyncContext(getAwaitable) {
5170
5191
  const ctx = getCurrentGenericInstance();
5171
5192
  const inSSRSetup = isInSSRComponentSetup;
5172
- const restoreAsyncContext = ctx && ctx.restoreAsyncContext ? ctx.restoreAsyncContext.bind(ctx) : void 0;
5173
5193
  let awaitable = getAwaitable();
5174
5194
  setCurrentInstance(null, void 0);
5175
5195
  if (inSSRSetup) setInSSRSetupState(false);
5176
5196
  const restore = () => {
5177
- const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
5197
+ const stoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
5178
5198
  setCurrentInstance(ctx);
5179
5199
  if (inSSRSetup) setInSSRSetupState(true);
5180
- const reset = restoreAsyncContext && restoreAsyncContext();
5181
- return () => {
5182
- if (reset) reset();
5183
- if (resetStoppedScope) resetStoppedScope.reset();
5184
- };
5200
+ return stoppedScope;
5185
5201
  };
5186
5202
  const cleanup = () => {
5187
5203
  setCurrentInstance(null, void 0);
5188
5204
  if (inSSRSetup) setInSSRSetupState(false);
5189
5205
  };
5190
5206
  if (isPromise(awaitable)) awaitable = awaitable.catch((e) => {
5191
- const reset = restore();
5207
+ const stoppedScope = restore();
5192
5208
  Promise.resolve().then(() => Promise.resolve().then(() => {
5193
- if (reset) reset();
5209
+ if (stoppedScope) stoppedScope.reset();
5194
5210
  cleanup();
5195
5211
  }));
5196
5212
  throw e;
5197
5213
  });
5198
5214
  return [awaitable, () => {
5199
- const reset = restore();
5215
+ const stoppedScope = restore();
5200
5216
  Promise.resolve().then(() => {
5201
- if (reset) reset();
5217
+ if (stoppedScope) stoppedScope.reset();
5202
5218
  cleanup();
5203
5219
  });
5204
5220
  }];
@@ -5458,7 +5474,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5458
5474
  if (options.el) return vm.$mount(options.el);
5459
5475
  else return vm;
5460
5476
  }
5461
- Vue.version = `2.6.14-compat:3.6.0-rc.7`;
5477
+ Vue.version = `2.6.14-compat:3.6.0-rc.9`;
5462
5478
  Vue.config = singletonApp.config;
5463
5479
  Vue.use = (plugin, ...options) => {
5464
5480
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -6471,6 +6487,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6471
6487
  optimized = false;
6472
6488
  n2.dynamicChildren = null;
6473
6489
  }
6490
+ if (n2.dynamicChildren && n1 && n1.dynamicChildren && n1.dynamicChildren.hasOnce) {
6491
+ if (n2.dynamicChildren === EMPTY_ARR) n2.dynamicChildren = [];
6492
+ n2.dynamicChildren.hasOnce = true;
6493
+ }
6474
6494
  const { type, ref, shapeFlag } = n2;
6475
6495
  switch (type) {
6476
6496
  case Text:
@@ -6745,6 +6765,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6745
6765
  const instance = n2.component = n1.component;
6746
6766
  if (shouldUpdateComponent(n1, n2, optimized)) {
6747
6767
  if (instance.asyncDep && !instance.asyncResolved) {
6768
+ n2.el = n1.el;
6748
6769
  updateComponentPreRender(instance, n2, optimized);
6749
6770
  return;
6750
6771
  } else {
@@ -7038,13 +7059,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7038
7059
  };
7039
7060
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
7040
7061
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
7041
- if (patchFlag === -2) optimized = false;
7062
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
7042
7063
  if (ref != null) {
7043
7064
  const prevSub = setActiveSub();
7044
7065
  setRef(ref, null, parentSuspense, vnode, true);
7045
7066
  setActiveSub(prevSub);
7046
7067
  }
7047
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
7068
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
7048
7069
  if (shapeFlag & 256) {
7049
7070
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
7050
7071
  else parentComponent.ctx.deactivate(vnode);
@@ -7094,6 +7115,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7094
7115
  }
7095
7116
  if (type === Static) {
7096
7117
  removeStaticNode(vnode);
7118
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
7097
7119
  return;
7098
7120
  }
7099
7121
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -7118,7 +7140,10 @@ function baseCreateRenderer(options, createHydrationFns) {
7118
7140
  if (effect) {
7119
7141
  effect.stop();
7120
7142
  unmount(subTree, instance, parentSuspense, doRemove);
7121
- } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
7143
+ } else if (instance.vnode.el && subTree) {
7144
+ subTree.transition = instance.vnode.transition;
7145
+ unmount(subTree, instance, parentSuspense, doRemove);
7146
+ }
7122
7147
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
7123
7148
  if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) queuePostRenderEffect(() => instance.emit("hook:destroyed"), void 0, parentSuspense);
7124
7149
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
@@ -7314,7 +7339,7 @@ const Suspense = {
7314
7339
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
7315
7340
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
7316
7341
  else {
7317
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
7342
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
7318
7343
  n2.suspense = n1.suspense;
7319
7344
  n2.suspense.vnode = n2;
7320
7345
  n2.el = n1.el;
@@ -7352,7 +7377,9 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
7352
7377
  if (pendingBranch) {
7353
7378
  suspense.pendingBranch = newBranch;
7354
7379
  if (isSameVNodeType(pendingBranch, newBranch)) {
7355
- patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7380
+ suspense.deps++;
7381
+ patch(pendingBranch, newBranch, isHydrating ? container : suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7382
+ suspense.deps--;
7356
7383
  if (suspense.deps <= 0) suspense.resolve();
7357
7384
  else if (isInFallback) {
7358
7385
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -7479,6 +7506,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7479
7506
  suspense.effects = [];
7480
7507
  if (isSuspensible) {
7481
7508
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
7509
+ parentSuspenseId = void 0;
7482
7510
  parentSuspense.deps--;
7483
7511
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
7484
7512
  }
@@ -7516,11 +7544,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7516
7544
  registerDep(instance, onResolve) {
7517
7545
  const isInPendingSuspense = !!suspense.pendingBranch;
7518
7546
  if (isInPendingSuspense) suspense.deps++;
7547
+ const hydratedEl = instance.vnode && instance.vnode.el;
7519
7548
  instance.asyncDep.catch((err) => {
7520
7549
  handleError(err, instance, 0);
7521
7550
  }).then((asyncSetupResult) => {
7522
7551
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
7523
7552
  setCurrentInstance(null, void 0);
7553
+ if (hydratedEl && !instance.scope.active) {
7554
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
7555
+ return;
7556
+ }
7524
7557
  instance.asyncResolved = true;
7525
7558
  onResolve(asyncSetupResult);
7526
7559
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -7835,7 +7868,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
7835
7868
  vs: cloneVaporSlotMeta(vnode),
7836
7869
  vb: vnode.vb,
7837
7870
  ibu: vnode.ibu,
7838
- iu: vnode.iu
7871
+ iu: vnode.iu,
7872
+ cacheIndex: vnode.cacheIndex
7839
7873
  };
7840
7874
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
7841
7875
  defineLegacyVNodeProperties(cloned);
@@ -8286,7 +8320,7 @@ function isMemoSame(cached, memo) {
8286
8320
  }
8287
8321
  //#endregion
8288
8322
  //#region packages/runtime-core/src/index.ts
8289
- const version = "3.6.0-rc.7";
8323
+ const version = "3.6.0-rc.9";
8290
8324
  const warn = NOOP;
8291
8325
  /**
8292
8326
  * Runtime error messages. Only exposed in dev or esm builds.