@vue/compat 3.6.0-beta.13 → 3.6.0-beta.15

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-beta.13
2
+ * @vue/compat v3.6.0-beta.15
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2246,8 +2246,9 @@ var WatcherEffect = class extends ReactiveEffect {
2246
2246
  if (once && cb) {
2247
2247
  const _cb = cb;
2248
2248
  cb = (...args) => {
2249
- _cb(...args);
2249
+ const res = _cb(...args);
2250
2250
  this.stop();
2251
+ return res;
2251
2252
  };
2252
2253
  }
2253
2254
  this.cb = cb;
@@ -2261,7 +2262,7 @@ var WatcherEffect = class extends ReactiveEffect {
2261
2262
  if (!this.cb) return;
2262
2263
  const { immediate, deep, call } = this.options;
2263
2264
  if (initialRun && !immediate) return;
2264
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2265
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2265
2266
  cleanup(this);
2266
2267
  const currentWatcher = activeWatcher;
2267
2268
  activeWatcher = this;
@@ -2678,6 +2679,7 @@ function flushJobs(seen) {
2678
2679
  }
2679
2680
  flushIndex = 0;
2680
2681
  jobsLength = 0;
2682
+ jobs.length = 0;
2681
2683
  flushPostFlushCbs(seen);
2682
2684
  currentFlushPromise = null;
2683
2685
  if (jobsLength || postJobs.length) flushJobs(seen);
@@ -2735,6 +2737,14 @@ function createRecord(id, initialDef) {
2735
2737
  function normalizeClassComponent(component) {
2736
2738
  return isClassComponent(component) ? component.__vccOpts : component;
2737
2739
  }
2740
+ function hasDirtyAncestor(instance, dirtyInstances) {
2741
+ let parent = instance.parent;
2742
+ while (parent) {
2743
+ if (dirtyInstances.has(parent)) return true;
2744
+ parent = parent.parent;
2745
+ }
2746
+ return false;
2747
+ }
2738
2748
  function rerender(id, newRender) {
2739
2749
  const record = map.get(id);
2740
2750
  if (!record) return;
@@ -2766,42 +2776,69 @@ function reload(id, newComp) {
2766
2776
  const isVapor = record.initialDef.__vapor;
2767
2777
  updateComponentDef(record.initialDef, newComp);
2768
2778
  const instances = [...record.instances];
2769
- if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
2779
+ if (isVapor && newComp.__vapor && !instances.some((instance) => instance.parent && !instance.parent.vapor) && !instances.some((i) => i.ceReload)) {
2770
2780
  for (const instance of instances) if (instance.root && instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(instance.type);
2771
- for (const instance of instances) instance.hmrReload(newComp);
2772
- } else for (const instance of instances) {
2773
- const oldComp = normalizeClassComponent(instance.type);
2774
- let dirtyInstances = hmrDirtyComponents.get(oldComp);
2775
- if (!dirtyInstances) {
2776
- if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
2777
- hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
2778
- }
2779
- dirtyInstances.add(instance);
2780
- hmrDirtyComponentsMode.set(oldComp, !!isVapor);
2781
- instance.appContext.propsCache.delete(instance.type);
2782
- instance.appContext.emitsCache.delete(instance.type);
2783
- instance.appContext.optionsCache.delete(instance.type);
2784
- if (instance.ceReload) {
2785
- dirtyInstances.add(instance);
2786
- instance.ceReload(newComp.styles);
2787
- dirtyInstances.delete(instance);
2788
- } else if (instance.parent) queueJob(() => {
2789
- isHmrUpdating = true;
2781
+ const dirtyInstances = new Set(instances);
2782
+ const rerenderedParents = /* @__PURE__ */ new Set();
2783
+ for (const instance of instances) {
2790
2784
  const parent = instance.parent;
2791
- if (parent.vapor) parent.hmrRerender();
2792
- else if (!(parent.effect.flags & 1024)) {
2793
- parent.renderCache = [];
2794
- parent.effect.run();
2785
+ if (parent) {
2786
+ if (!hasDirtyAncestor(instance, dirtyInstances) && !rerenderedParents.has(parent)) {
2787
+ rerenderedParents.add(parent);
2788
+ parent.hmrRerender();
2789
+ }
2790
+ } else instance.hmrReload(newComp);
2791
+ }
2792
+ } else {
2793
+ const parentUpdates = /* @__PURE__ */ new Map();
2794
+ const dirtyInstanceSet = new Set(instances);
2795
+ for (const instance of instances) {
2796
+ const oldComp = normalizeClassComponent(instance.type);
2797
+ let dirtyInstances = hmrDirtyComponents.get(oldComp);
2798
+ if (!dirtyInstances) {
2799
+ if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
2800
+ hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
2795
2801
  }
2796
- nextTick(() => {
2797
- isHmrUpdating = false;
2802
+ dirtyInstances.add(instance);
2803
+ hmrDirtyComponentsMode.set(oldComp, !!isVapor);
2804
+ instance.appContext.propsCache.delete(instance.type);
2805
+ instance.appContext.emitsCache.delete(instance.type);
2806
+ instance.appContext.optionsCache.delete(instance.type);
2807
+ if (instance.ceReload) {
2808
+ dirtyInstances.add(instance);
2809
+ instance.ceReload(newComp.styles);
2810
+ dirtyInstances.delete(instance);
2811
+ } else if (instance.parent) {
2812
+ const parent = instance.parent;
2813
+ if (!hasDirtyAncestor(instance, dirtyInstanceSet)) {
2814
+ let updates = parentUpdates.get(parent);
2815
+ if (!updates) parentUpdates.set(parent, updates = []);
2816
+ updates.push([instance, dirtyInstances]);
2817
+ }
2818
+ } else if (instance.appContext.reload) instance.appContext.reload();
2819
+ else if (typeof window !== "undefined") window.location.reload();
2820
+ else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
2821
+ if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
2822
+ }
2823
+ parentUpdates.forEach((updates, parent) => {
2824
+ queueJob(() => {
2825
+ isHmrUpdating = true;
2826
+ if (parent.vapor) parent.hmrRerender();
2827
+ else {
2828
+ const i = parent;
2829
+ if (!(i.effect.flags & 1024)) {
2830
+ i.renderCache = [];
2831
+ i.effect.run();
2832
+ }
2833
+ }
2834
+ nextTick(() => {
2835
+ isHmrUpdating = false;
2836
+ });
2837
+ updates.forEach(([instance, dirtyInstances]) => {
2838
+ dirtyInstances.delete(instance);
2839
+ });
2798
2840
  });
2799
- dirtyInstances.delete(instance);
2800
2841
  });
2801
- else if (instance.appContext.reload) instance.appContext.reload();
2802
- else if (typeof window !== "undefined") window.location.reload();
2803
- else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
2804
- if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
2805
2842
  }
2806
2843
  queuePostFlushCb(() => {
2807
2844
  hmrDirtyComponents.clear();
@@ -4633,11 +4670,16 @@ function defineAsyncComponent(source) {
4633
4670
  onError(err);
4634
4671
  return () => errorComponent ? createVNode(errorComponent, { error: err }) : null;
4635
4672
  });
4636
- const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError);
4673
+ const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError, instance);
4637
4674
  load().then(() => {
4675
+ if (instance.isUnmounted) return;
4638
4676
  loaded.value = true;
4639
4677
  if (instance.parent && instance.parent.vnode && isKeepAlive(instance.parent.vnode)) instance.parent.update();
4640
4678
  }).catch((err) => {
4679
+ if (instance.isUnmounted) {
4680
+ setPendingRequest(null);
4681
+ return;
4682
+ }
4641
4683
  onError(err);
4642
4684
  error.value = err;
4643
4685
  });
@@ -4695,14 +4737,22 @@ function createAsyncComponentContext(source) {
4695
4737
  setPendingRequest: (request) => pendingRequest = request
4696
4738
  };
4697
4739
  }
4698
- const useAsyncComponentState = (delay, timeout, onError) => {
4740
+ const useAsyncComponentState = (delay, timeout, onError, instance = currentInstance) => {
4699
4741
  const loaded = /* @__PURE__ */ ref(false);
4700
4742
  const error = /* @__PURE__ */ ref();
4701
4743
  const delayed = /* @__PURE__ */ ref(!!delay);
4702
- if (delay) setTimeout(() => {
4744
+ let timeoutTimer;
4745
+ let delayTimer;
4746
+ if (instance) onUnmounted(() => {
4747
+ if (timeoutTimer != null) clearTimeout(timeoutTimer);
4748
+ if (delayTimer != null) clearTimeout(delayTimer);
4749
+ }, instance);
4750
+ if (delay) delayTimer = setTimeout(() => {
4751
+ if (instance && instance.isUnmounted) return;
4703
4752
  delayed.value = false;
4704
4753
  }, delay);
4705
- if (timeout != null) setTimeout(() => {
4754
+ if (timeout != null) timeoutTimer = setTimeout(() => {
4755
+ if (instance && instance.isUnmounted) return;
4706
4756
  if (!loaded.value && !error.value) {
4707
4757
  const err = /* @__PURE__ */ new Error(`Async component timed out after ${timeout}ms.`);
4708
4758
  onError(err);
@@ -5320,6 +5370,7 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5320
5370
  slot: vaporSlot,
5321
5371
  fallback
5322
5372
  };
5373
+ if (!noSlotted && ret.scopeId) ret.slotScopeIds = [ret.scopeId + "-s"];
5323
5374
  return ret;
5324
5375
  }
5325
5376
  if (currentRenderingInstance && (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce)) {
@@ -6256,7 +6307,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6256
6307
  if (options.el) return vm.$mount(options.el);
6257
6308
  else return vm;
6258
6309
  }
6259
- Vue.version = `2.6.14-compat:3.6.0-beta.13`;
6310
+ Vue.version = `2.6.14-compat:3.6.0-beta.15`;
6260
6311
  Vue.config = singletonApp.config;
6261
6312
  Vue.use = (plugin, ...options) => {
6262
6313
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -6511,7 +6562,9 @@ function defineReactive(obj, key, val) {
6511
6562
  else Object.keys(val).forEach((key) => {
6512
6563
  try {
6513
6564
  defineReactiveSimple(val, key, val[key]);
6514
- } catch (e) {}
6565
+ } catch (e) {
6566
+ warn$1(`Failed making property "${key}" reactive:`, e);
6567
+ }
6515
6568
  });
6516
6569
  }
6517
6570
  const i = obj.$;
@@ -6756,12 +6809,13 @@ function useModel(props, name, options = EMPTY_OBJ) {
6756
6809
  for (const key of rawPropKeys) if (key === name || key === camelizedName || key === hyphenatedName) parentPassedModelValue = true;
6757
6810
  else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) parentPassedModelUpdater = true;
6758
6811
  }
6759
- if (!parentPassedModelValue || !parentPassedModelUpdater) {
6812
+ const hasVModel = parentPassedModelValue && parentPassedModelUpdater;
6813
+ if (!hasVModel) {
6760
6814
  localValue = value;
6761
6815
  trigger();
6762
6816
  }
6763
6817
  i.emit(`update:${name}`, emittedValue);
6764
- if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) trigger();
6818
+ if (hasChanged(value, prevSetValue) && (hasChanged(value, emittedValue) && !hasChanged(emittedValue, prevEmittedValue) || hasVModel && prevSetValue !== EMPTY_OBJ && !hasChanged(emittedValue, localValue))) trigger();
6765
6819
  prevSetValue = value;
6766
6820
  prevEmittedValue = emittedValue;
6767
6821
  }
@@ -9716,7 +9770,7 @@ function isMemoSame(cached, memo) {
9716
9770
  }
9717
9771
  //#endregion
9718
9772
  //#region packages/runtime-core/src/index.ts
9719
- const version = "3.6.0-beta.13";
9773
+ const version = "3.6.0-beta.15";
9720
9774
  const warn = warn$1;
9721
9775
  /**
9722
9776
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -10919,7 +10973,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
10919
10973
  prevChildren = [];
10920
10974
  if (children) for (let i = 0; i < children.length; i++) {
10921
10975
  const child = children[i];
10922
- if (child.el && child.el instanceof Element) {
10976
+ if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
10923
10977
  prevChildren.push(child);
10924
10978
  setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10925
10979
  positionMap.set(child, getPosition(child.el));
@@ -13140,7 +13194,7 @@ const tokenizer = new Tokenizer(stack, {
13140
13194
  }
13141
13195
  },
13142
13196
  oncdata(start, end) {
13143
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
13197
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
13144
13198
  else emitError(1, start - 9);
13145
13199
  },
13146
13200
  onprocessinginstruction(start) {
@@ -13632,7 +13686,7 @@ function getSelfName(filename) {
13632
13686
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
13633
13687
  return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
13634
13688
  }
13635
- function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
13689
+ function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, eventDelegation = true, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
13636
13690
  const context = {
13637
13691
  filename,
13638
13692
  selfName: getSelfName(filename),
@@ -13654,6 +13708,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
13654
13708
  bindingMetadata,
13655
13709
  inline,
13656
13710
  isTS,
13711
+ eventDelegation,
13657
13712
  onError,
13658
13713
  onWarn,
13659
13714
  compatConfig,
@@ -13665,6 +13720,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
13665
13720
  imports: [],
13666
13721
  cached: [],
13667
13722
  constantCache: /* @__PURE__ */ new WeakMap(),
13723
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
13668
13724
  temps: 0,
13669
13725
  identifiers: Object.create(null),
13670
13726
  identifierScopes: Object.create(null),
@@ -14295,7 +14351,7 @@ const transformExpression = (node, context) => {
14295
14351
  if (dir.type === 7 && dir.name !== "for") {
14296
14352
  const exp = dir.exp;
14297
14353
  const arg = dir.arg;
14298
- if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
14354
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && context.vForMemoKeyedNodes.has(node) && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
14299
14355
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
14300
14356
  }
14301
14357
  }