@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.
@@ -375,11 +375,11 @@ type PropConstructor<T = any> = {
375
375
  } | {
376
376
  (): T;
377
377
  } | PropMethod<T>;
378
- type PropMethod<T, TConstructor = any> = [T] extends [((...args: any) => any) | undefined] ? {
378
+ type PropMethod<T, TConstructor = any> = {
379
379
  new (): TConstructor;
380
380
  (): T;
381
381
  readonly prototype: TConstructor;
382
- } : never;
382
+ };
383
383
  type RequiredKeys<T> = { [K in keyof T]: T[K] extends {
384
384
  required: true;
385
385
  } | {
@@ -408,7 +408,7 @@ type InferPropType<T, NullAsAny = true> = [T] extends [null] ? NullAsAny extends
408
408
  type: DateConstructor;
409
409
  }] ? Date : [T] extends [(infer U)[] | {
410
410
  type: (infer U)[];
411
- }] ? U extends DateConstructor ? Date | InferPropType<U, false> : InferPropType<U, false> : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? IfAny<V, V, D> : V : V : T;
411
+ }] ? U extends DateConstructor ? Date | InferPropType<U, false> : InferPropType<U, false> : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? IfAny<V, V, unknown extends D ? V : D> : V : V : T;
412
412
  /**
413
413
  * Extract prop types from a runtime props options object.
414
414
  * The extracted types are **internal** - i.e. the resolved props received by
@@ -1048,6 +1048,7 @@ interface VaporInVdomInterface {
1048
1048
  activate(vnode: VNode, container: RendererElement, anchor: RendererNode | null, parentComponent: ComponentInternalInstance, parentSuspense: SuspenseBoundary | null): void;
1049
1049
  deactivate(vnode: VNode, container: RendererElement, parentSuspense: SuspenseBoundary | null): void;
1050
1050
  setTransitionHooks(component: ComponentInternalInstance, transition: TransitionHooks): void;
1051
+ applyCssVars(vnode: VNode, vars: Record<string, string>): void;
1051
1052
  }
1052
1053
  /**
1053
1054
  * Options for rendering a VDOM slot inside vapor. `flags` carries the
@@ -1065,7 +1066,7 @@ interface VdomSlotOptions {
1065
1066
  interface VdomInVaporInterface {
1066
1067
  mount: (component: ConcreteComponent, parentComponent: any, props?: any, slots?: any, once?: boolean) => any;
1067
1068
  slot: (slots: any, name: string | (() => string), props: Record<string, any>, parentComponent: any, options?: VdomSlotOptions) => any;
1068
- mountVNode: (vnode: VNode, parentComponent: any, getFallthroughAttrs?: () => Record<string, any>) => any;
1069
+ mountVNode: (vnode: VNode, parentComponent: any, isSingleRoot?: boolean) => any;
1069
1070
  }
1070
1071
  /**
1071
1072
  * Minimal app context shared between vdom and vapor
@@ -1595,11 +1596,6 @@ interface GenericComponentInstance {
1595
1596
  * @internal
1596
1597
  */
1597
1598
  asyncResolved: boolean;
1598
- /**
1599
- * restore renderer-specific async context after `withAsyncContext()`
1600
- * @internal
1601
- */
1602
- restoreAsyncContext?: () => void | (() => void);
1603
1599
  /**
1604
1600
  * `updateTeleportCssVars`
1605
1601
  * For updating css vars on contained teleports
package/dist/vue.cjs.js CHANGED
@@ -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
  **/
@@ -238,10 +238,10 @@ function normalizeStyle(value) {
238
238
  }
239
239
  const listDelimiterRE = /;(?![^(]*\))/g;
240
240
  const propertyDelimiterRE = /:([^]+)/;
241
- const styleCommentRE = /\/\*[^]*?\*\//g;
241
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
242
242
  function parseStringStyle(cssText) {
243
243
  const ret = {};
244
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
244
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
245
245
  if (item) {
246
246
  const tmp = item.split(propertyDelimiterRE);
247
247
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -407,19 +407,19 @@ function getEscapedCssVarName(key, doubleEscape) {
407
407
  }
408
408
  //#endregion
409
409
  //#region packages/shared/src/looseEqual.ts
410
- function looseCompareArrays(a, b) {
410
+ function looseCompareArrays(a, b, seen) {
411
411
  if (a.length !== b.length) return false;
412
412
  let equal = true;
413
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
413
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
414
414
  return equal;
415
415
  }
416
- function looseCompareCollections(a, b) {
416
+ function looseCompareCollections(a, b, seen) {
417
417
  if (a.size !== b.size) return false;
418
418
  const candidates = Array.from(b);
419
419
  const matched = new Uint8Array(candidates.length);
420
420
  for (const item of a) {
421
421
  let index = -1;
422
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
422
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
423
423
  index = i;
424
424
  break;
425
425
  }
@@ -428,7 +428,33 @@ function looseCompareCollections(a, b) {
428
428
  }
429
429
  return true;
430
430
  }
431
- function looseEqual(a, b) {
431
+ function looseCompareObjects(a, b, seen) {
432
+ let aValidType = isMap(a);
433
+ let bValidType = isMap(b);
434
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
435
+ aValidType = isSet(a);
436
+ bValidType = isSet(b);
437
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
438
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
439
+ for (const key in a) {
440
+ const aHasKey = a.hasOwnProperty(key);
441
+ const bHasKey = b.hasOwnProperty(key);
442
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
443
+ }
444
+ return String(a) === String(b);
445
+ }
446
+ function looseCompareNested(a, b, seen, compare) {
447
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
448
+ const [seenA, seenB] = seen;
449
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
450
+ seenA.set(a, b);
451
+ seenB.set(b, a);
452
+ const equal = compare(a, b, seen);
453
+ seenA.delete(a);
454
+ seenB.delete(b);
455
+ return equal;
456
+ }
457
+ function looseEqual(a, b, seen) {
432
458
  if (a === b) return true;
433
459
  let aValidType = isDate(a);
434
460
  let bValidType = isDate(b);
@@ -438,23 +464,12 @@ function looseEqual(a, b) {
438
464
  if (aValidType || bValidType) return a === b;
439
465
  aValidType = isArray(a);
440
466
  bValidType = isArray(b);
441
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
467
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
442
468
  aValidType = isObject(a);
443
469
  bValidType = isObject(b);
444
470
  if (aValidType || bValidType) {
445
471
  if (!aValidType || !bValidType) return false;
446
- aValidType = isMap(a);
447
- bValidType = isMap(b);
448
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
449
- aValidType = isSet(a);
450
- bValidType = isSet(b);
451
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
452
- if (Object.keys(a).length !== Object.keys(b).length) return false;
453
- for (const key in a) {
454
- const aHasKey = a.hasOwnProperty(key);
455
- const bHasKey = b.hasOwnProperty(key);
456
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
457
- }
472
+ return looseCompareNested(a, b, seen, looseCompareObjects);
458
473
  }
459
474
  return String(a) === String(b);
460
475
  }
@@ -584,6 +599,8 @@ function setupFlagsHandler(target) {
584
599
  function warn$2(msg, ...args) {
585
600
  console.warn(`[Vue warn] ${msg}`, ...args);
586
601
  }
602
+ //#endregion
603
+ //#region packages/reactivity/src/system.ts
587
604
  const notifyBuffer = [];
588
605
  let batchDepth = 0;
589
606
  let activeSub = void 0;
@@ -910,13 +927,17 @@ function getDepFromReactive(object, key) {
910
927
  /**
911
928
  * Track array iteration and return:
912
929
  * - if input is reactive: a cloned raw array with reactive values
913
- * - if input is non-reactive or shallowReactive: the original raw array
930
+ * - if input is readonly: a cloned raw array with readonly values, preserving
931
+ * reactivity
932
+ * - if input is raw or shallow: the original raw array
914
933
  */
915
934
  function reactiveReadArray(array) {
916
935
  const raw = /* @__PURE__ */ toRaw(array);
917
936
  if (raw === array) return raw;
918
937
  track(raw, "iterate", ARRAY_ITERATE_KEY);
919
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
938
+ if (/* @__PURE__ */ isShallow(array)) return raw;
939
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
940
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
920
941
  }
921
942
  /**
922
943
  * Track array iteration and return raw array
@@ -4448,12 +4469,12 @@ function createHydrationFunctions(rendererInternals) {
4448
4469
  } else {
4449
4470
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
4450
4471
  const component = vnode.component;
4451
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
4472
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
4452
4473
  let subTree;
4453
4474
  if (isFragmentStart) {
4454
4475
  subTree = createVNode(Static);
4455
4476
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
4456
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
4477
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
4457
4478
  subTree.el = node;
4458
4479
  component.subTree = subTree;
4459
4480
  }
@@ -6251,37 +6272,32 @@ function createPropsRestProxy(props, excludedKeys) {
6251
6272
  function withAsyncContext(getAwaitable) {
6252
6273
  const ctx = getCurrentGenericInstance();
6253
6274
  const inSSRSetup = isInSSRComponentSetup;
6254
- const restoreAsyncContext = ctx && ctx.restoreAsyncContext ? ctx.restoreAsyncContext.bind(ctx) : void 0;
6255
6275
  if (!ctx) warn$1("withAsyncContext called without active current instance. This is likely a bug.");
6256
6276
  let awaitable = getAwaitable();
6257
6277
  setCurrentInstance(null, void 0);
6258
6278
  if (inSSRSetup) setInSSRSetupState(false);
6259
6279
  const restore = () => {
6260
- const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
6280
+ const stoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
6261
6281
  setCurrentInstance(ctx);
6262
6282
  if (inSSRSetup) setInSSRSetupState(true);
6263
- const reset = restoreAsyncContext && restoreAsyncContext();
6264
- return () => {
6265
- if (reset) reset();
6266
- if (resetStoppedScope) resetStoppedScope.reset();
6267
- };
6283
+ return stoppedScope;
6268
6284
  };
6269
6285
  const cleanup = () => {
6270
6286
  setCurrentInstance(null, void 0);
6271
6287
  if (inSSRSetup) setInSSRSetupState(false);
6272
6288
  };
6273
6289
  if (isPromise(awaitable)) awaitable = awaitable.catch((e) => {
6274
- const reset = restore();
6290
+ const stoppedScope = restore();
6275
6291
  Promise.resolve().then(() => Promise.resolve().then(() => {
6276
- if (reset) reset();
6292
+ if (stoppedScope) stoppedScope.reset();
6277
6293
  cleanup();
6278
6294
  }));
6279
6295
  throw e;
6280
6296
  });
6281
6297
  return [awaitable, () => {
6282
- const reset = restore();
6298
+ const stoppedScope = restore();
6283
6299
  Promise.resolve().then(() => {
6284
- if (reset) reset();
6300
+ if (stoppedScope) stoppedScope.reset();
6285
6301
  cleanup();
6286
6302
  });
6287
6303
  }];
@@ -6607,7 +6623,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6607
6623
  if (options.el) return vm.$mount(options.el);
6608
6624
  else return vm;
6609
6625
  }
6610
- Vue.version = `2.6.14-compat:3.6.0-rc.7`;
6626
+ Vue.version = `2.6.14-compat:3.6.0-rc.9`;
6611
6627
  Vue.config = singletonApp.config;
6612
6628
  Vue.use = (plugin, ...options) => {
6613
6629
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -7947,6 +7963,10 @@ function baseCreateRenderer(options, createHydrationFns) {
7947
7963
  optimized = false;
7948
7964
  n2.dynamicChildren = null;
7949
7965
  }
7966
+ if (n2.dynamicChildren && n1 && n1.dynamicChildren && n1.dynamicChildren.hasOnce) {
7967
+ if (n2.dynamicChildren === EMPTY_ARR) n2.dynamicChildren = [];
7968
+ n2.dynamicChildren.hasOnce = true;
7969
+ }
7950
7970
  const { type, ref, shapeFlag } = n2;
7951
7971
  switch (type) {
7952
7972
  case Text:
@@ -8266,6 +8286,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8266
8286
  if (shouldUpdateComponent(n1, n2, optimized)) {
8267
8287
  if (instance.asyncDep && !instance.asyncResolved) {
8268
8288
  pushWarningContext(n2);
8289
+ n2.el = n1.el;
8269
8290
  updateComponentPreRender(instance, n2, optimized);
8270
8291
  popWarningContext();
8271
8292
  return;
@@ -8581,13 +8602,13 @@ function baseCreateRenderer(options, createHydrationFns) {
8581
8602
  };
8582
8603
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
8583
8604
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
8584
- if (patchFlag === -2) optimized = false;
8605
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
8585
8606
  if (ref != null) {
8586
8607
  const prevSub = setActiveSub();
8587
8608
  setRef(ref, null, parentSuspense, vnode, true);
8588
8609
  setActiveSub(prevSub);
8589
8610
  }
8590
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
8611
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
8591
8612
  if (shapeFlag & 256) {
8592
8613
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
8593
8614
  else parentComponent.ctx.deactivate(vnode);
@@ -8641,6 +8662,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8641
8662
  }
8642
8663
  if (type === Static) {
8643
8664
  removeStaticNode(vnode);
8665
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
8644
8666
  return;
8645
8667
  }
8646
8668
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -8666,7 +8688,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8666
8688
  if (effect) {
8667
8689
  effect.stop();
8668
8690
  unmount(subTree, instance, parentSuspense, doRemove);
8669
- } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
8691
+ } else if (instance.vnode.el && subTree) {
8692
+ subTree.transition = instance.vnode.transition;
8693
+ unmount(subTree, instance, parentSuspense, doRemove);
8694
+ }
8670
8695
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
8671
8696
  if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) queuePostRenderEffect(() => instance.emit("hook:destroyed"), void 0, parentSuspense);
8672
8697
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
@@ -8873,7 +8898,7 @@ const Suspense = {
8873
8898
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
8874
8899
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
8875
8900
  else {
8876
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
8901
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
8877
8902
  n2.suspense = n1.suspense;
8878
8903
  n2.suspense.vnode = n2;
8879
8904
  n2.el = n1.el;
@@ -8911,7 +8936,9 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
8911
8936
  if (pendingBranch) {
8912
8937
  suspense.pendingBranch = newBranch;
8913
8938
  if (isSameVNodeType(pendingBranch, newBranch)) {
8914
- patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
8939
+ suspense.deps++;
8940
+ patch(pendingBranch, newBranch, isHydrating ? container : suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
8941
+ suspense.deps--;
8915
8942
  if (suspense.deps <= 0) suspense.resolve();
8916
8943
  else if (isInFallback) {
8917
8944
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -9047,6 +9074,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9047
9074
  suspense.effects = [];
9048
9075
  if (isSuspensible) {
9049
9076
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
9077
+ parentSuspenseId = void 0;
9050
9078
  parentSuspense.deps--;
9051
9079
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
9052
9080
  }
@@ -9084,11 +9112,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9084
9112
  registerDep(instance, onResolve) {
9085
9113
  const isInPendingSuspense = !!suspense.pendingBranch;
9086
9114
  if (isInPendingSuspense) suspense.deps++;
9115
+ const hydratedEl = instance.vnode && instance.vnode.el;
9087
9116
  instance.asyncDep.catch((err) => {
9088
9117
  handleError(err, instance, 0);
9089
9118
  }).then((asyncSetupResult) => {
9090
9119
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
9091
9120
  setCurrentInstance(null, void 0);
9121
+ if (hydratedEl && !instance.scope.active) {
9122
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
9123
+ return;
9124
+ }
9092
9125
  instance.asyncResolved = true;
9093
9126
  onResolve(asyncSetupResult);
9094
9127
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -9444,7 +9477,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
9444
9477
  vs: cloneVaporSlotMeta(vnode),
9445
9478
  vb: vnode.vb,
9446
9479
  ibu: vnode.ibu,
9447
- iu: vnode.iu
9480
+ iu: vnode.iu,
9481
+ cacheIndex: vnode.cacheIndex
9448
9482
  };
9449
9483
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
9450
9484
  defineLegacyVNodeProperties(cloned);
@@ -10160,7 +10194,7 @@ function isMemoSame(cached, memo) {
10160
10194
  }
10161
10195
  //#endregion
10162
10196
  //#region packages/runtime-core/src/index.ts
10163
- const version = "3.6.0-rc.7";
10197
+ const version = "3.6.0-rc.9";
10164
10198
  const warn = warn$1;
10165
10199
  /**
10166
10200
  * Runtime error messages. Only exposed in dev or esm builds.