@vue/compat 3.5.0-beta.2 → 3.5.0-beta.3

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.5.0-beta.2
2
+ * @vue/compat v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1074,14 +1074,14 @@ function iterator(self, method, wrapValue) {
1074
1074
  const arrayProto = Array.prototype;
1075
1075
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1076
1076
  const arr = shallowReadArray(self);
1077
- let methodFn;
1078
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1079
- return methodFn.apply(arr, args);
1077
+ const needsWrap = arr !== self && !isShallow(self);
1078
+ const methodFn = arr[method];
1079
+ if (methodFn !== arrayProto[method]) {
1080
+ const result2 = methodFn.apply(arr, args);
1081
+ return needsWrap ? toReactive(result2) : result2;
1080
1082
  }
1081
- let needsWrap = false;
1082
1083
  let wrappedFn = fn;
1083
1084
  if (arr !== self) {
1084
- needsWrap = !isShallow(self);
1085
1085
  if (needsWrap) {
1086
1086
  wrappedFn = function(item, index) {
1087
1087
  return fn.call(this, toReactive(item), index, self);
@@ -1949,6 +1949,220 @@ const TriggerOpTypes = {
1949
1949
  "CLEAR": "clear"
1950
1950
  };
1951
1951
 
1952
+ const INITIAL_WATCHER_VALUE = {};
1953
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1954
+ let activeWatcher = void 0;
1955
+ function getCurrentWatcher() {
1956
+ return activeWatcher;
1957
+ }
1958
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1959
+ if (owner) {
1960
+ let cleanups = cleanupMap.get(owner);
1961
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1962
+ cleanups.push(cleanupFn);
1963
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
1964
+ warn$2(
1965
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1966
+ );
1967
+ }
1968
+ }
1969
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1970
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1971
+ const warnInvalidSource = (s) => {
1972
+ (options.onWarn || warn$2)(
1973
+ `Invalid watch source: `,
1974
+ s,
1975
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1976
+ );
1977
+ };
1978
+ const reactiveGetter = (source2) => {
1979
+ if (deep) return source2;
1980
+ if (isShallow(source2) || deep === false || deep === 0)
1981
+ return traverse(source2, 1);
1982
+ return traverse(source2);
1983
+ };
1984
+ let effect;
1985
+ let getter;
1986
+ let cleanup;
1987
+ let boundCleanup;
1988
+ let forceTrigger = false;
1989
+ let isMultiSource = false;
1990
+ if (isRef(source)) {
1991
+ getter = () => source.value;
1992
+ forceTrigger = isShallow(source);
1993
+ } else if (isReactive(source)) {
1994
+ getter = () => reactiveGetter(source);
1995
+ forceTrigger = true;
1996
+ } else if (isArray(source)) {
1997
+ isMultiSource = true;
1998
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1999
+ getter = () => source.map((s) => {
2000
+ if (isRef(s)) {
2001
+ return s.value;
2002
+ } else if (isReactive(s)) {
2003
+ return reactiveGetter(s);
2004
+ } else if (isFunction(s)) {
2005
+ return call ? call(s, 2) : s();
2006
+ } else {
2007
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
2008
+ }
2009
+ });
2010
+ } else if (isFunction(source)) {
2011
+ if (cb) {
2012
+ getter = call ? () => call(source, 2) : source;
2013
+ } else {
2014
+ getter = () => {
2015
+ if (cleanup) {
2016
+ pauseTracking();
2017
+ try {
2018
+ cleanup();
2019
+ } finally {
2020
+ resetTracking();
2021
+ }
2022
+ }
2023
+ const currentEffect = activeWatcher;
2024
+ activeWatcher = effect;
2025
+ try {
2026
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2027
+ } finally {
2028
+ activeWatcher = currentEffect;
2029
+ }
2030
+ };
2031
+ }
2032
+ } else {
2033
+ getter = NOOP;
2034
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
2035
+ }
2036
+ if (cb && deep) {
2037
+ const baseGetter = getter;
2038
+ const depth = deep === true ? Infinity : deep;
2039
+ getter = () => traverse(baseGetter(), depth);
2040
+ }
2041
+ if (once) {
2042
+ if (cb) {
2043
+ const _cb = cb;
2044
+ cb = (...args) => {
2045
+ _cb(...args);
2046
+ effect.stop();
2047
+ };
2048
+ } else {
2049
+ const _getter = getter;
2050
+ getter = () => {
2051
+ _getter();
2052
+ effect.stop();
2053
+ };
2054
+ }
2055
+ }
2056
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2057
+ const job = (immediateFirstRun) => {
2058
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2059
+ return;
2060
+ }
2061
+ if (cb) {
2062
+ const newValue = effect.run();
2063
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2064
+ if (cleanup) {
2065
+ cleanup();
2066
+ }
2067
+ const currentWatcher = activeWatcher;
2068
+ activeWatcher = effect;
2069
+ try {
2070
+ const args = [
2071
+ newValue,
2072
+ // pass undefined as the old value when it's changed for the first time
2073
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2074
+ boundCleanup
2075
+ ];
2076
+ call ? call(cb, 3, args) : (
2077
+ // @ts-expect-error
2078
+ cb(...args)
2079
+ );
2080
+ oldValue = newValue;
2081
+ } finally {
2082
+ activeWatcher = currentWatcher;
2083
+ }
2084
+ }
2085
+ } else {
2086
+ effect.run();
2087
+ }
2088
+ };
2089
+ if (augmentJob) {
2090
+ augmentJob(job);
2091
+ }
2092
+ effect = new ReactiveEffect(getter);
2093
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2094
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2095
+ cleanup = effect.onStop = () => {
2096
+ const cleanups = cleanupMap.get(effect);
2097
+ if (cleanups) {
2098
+ if (call) {
2099
+ call(cleanups, 4);
2100
+ } else {
2101
+ for (const cleanup2 of cleanups) cleanup2();
2102
+ }
2103
+ cleanupMap.delete(effect);
2104
+ }
2105
+ };
2106
+ if (!!(process.env.NODE_ENV !== "production")) {
2107
+ effect.onTrack = options.onTrack;
2108
+ effect.onTrigger = options.onTrigger;
2109
+ }
2110
+ if (cb) {
2111
+ if (immediate) {
2112
+ job(true);
2113
+ } else {
2114
+ oldValue = effect.run();
2115
+ }
2116
+ } else if (scheduler) {
2117
+ scheduler(job.bind(null, true), true);
2118
+ } else {
2119
+ effect.run();
2120
+ }
2121
+ const scope = getCurrentScope();
2122
+ const watchHandle = () => {
2123
+ effect.stop();
2124
+ if (scope) {
2125
+ remove(scope.effects, effect);
2126
+ }
2127
+ };
2128
+ watchHandle.pause = effect.pause.bind(effect);
2129
+ watchHandle.resume = effect.resume.bind(effect);
2130
+ watchHandle.stop = watchHandle;
2131
+ return watchHandle;
2132
+ }
2133
+ function traverse(value, depth = Infinity, seen) {
2134
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2135
+ return value;
2136
+ }
2137
+ seen = seen || /* @__PURE__ */ new Set();
2138
+ if (seen.has(value)) {
2139
+ return value;
2140
+ }
2141
+ seen.add(value);
2142
+ depth--;
2143
+ if (isRef(value)) {
2144
+ traverse(value.value, depth, seen);
2145
+ } else if (isArray(value)) {
2146
+ for (let i = 0; i < value.length; i++) {
2147
+ traverse(value[i], depth, seen);
2148
+ }
2149
+ } else if (isSet(value) || isMap(value)) {
2150
+ value.forEach((v) => {
2151
+ traverse(v, depth, seen);
2152
+ });
2153
+ } else if (isPlainObject(value)) {
2154
+ for (const key in value) {
2155
+ traverse(value[key], depth, seen);
2156
+ }
2157
+ for (const key of Object.getOwnPropertySymbols(value)) {
2158
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2159
+ traverse(value[key], depth, seen);
2160
+ }
2161
+ }
2162
+ }
2163
+ return value;
2164
+ }
2165
+
1952
2166
  const stack = [];
1953
2167
  function pushWarningContext(vnode) {
1954
2168
  stack.push(vnode);
@@ -2077,12 +2291,6 @@ const ErrorCodes = {
2077
2291
  "0": "SETUP_FUNCTION",
2078
2292
  "RENDER_FUNCTION": 1,
2079
2293
  "1": "RENDER_FUNCTION",
2080
- "WATCH_GETTER": 2,
2081
- "2": "WATCH_GETTER",
2082
- "WATCH_CALLBACK": 3,
2083
- "3": "WATCH_CALLBACK",
2084
- "WATCH_CLEANUP": 4,
2085
- "4": "WATCH_CLEANUP",
2086
2294
  "NATIVE_EVENT_HANDLER": 5,
2087
2295
  "5": "NATIVE_EVENT_HANDLER",
2088
2296
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2238,7 +2446,7 @@ function nextTick(fn) {
2238
2446
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2239
2447
  }
2240
2448
  function findInsertionIndex(id) {
2241
- let start = flushIndex + 1;
2449
+ let start = isFlushing ? flushIndex + 1 : 0;
2242
2450
  let end = queue.length;
2243
2451
  while (start < end) {
2244
2452
  const middle = start + end >>> 1;
@@ -2254,15 +2462,13 @@ function findInsertionIndex(id) {
2254
2462
  }
2255
2463
  function queueJob(job) {
2256
2464
  if (!(job.flags & 1)) {
2257
- if (job.id == null) {
2258
- queue.push(job);
2259
- } else if (
2260
- // fast path when the job id is larger than the tail
2261
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2262
- ) {
2465
+ const jobId = getId(job);
2466
+ const lastJob = queue[queue.length - 1];
2467
+ if (!lastJob || // fast path when the job id is larger than the tail
2468
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2263
2469
  queue.push(job);
2264
2470
  } else {
2265
- queue.splice(findInsertionIndex(job.id), 0, job);
2471
+ queue.splice(findInsertionIndex(jobId), 0, job);
2266
2472
  }
2267
2473
  if (!(job.flags & 4)) {
2268
2474
  job.flags |= 1;
@@ -2276,12 +2482,6 @@ function queueFlush() {
2276
2482
  currentFlushPromise = resolvedPromise.then(flushJobs);
2277
2483
  }
2278
2484
  }
2279
- function invalidateJob(job) {
2280
- const i = queue.indexOf(job);
2281
- if (i > flushIndex) {
2282
- queue.splice(i, 1);
2283
- }
2284
- }
2285
2485
  function queuePostFlushCb(cb) {
2286
2486
  if (!isArray(cb)) {
2287
2487
  if (activePostFlushCbs && cb.id === -1) {
@@ -2343,24 +2543,13 @@ function flushPostFlushCbs(seen) {
2343
2543
  postFlushIndex = 0;
2344
2544
  }
2345
2545
  }
2346
- const getId = (job) => job.id == null ? Infinity : job.id;
2347
- const comparator = (a, b) => {
2348
- const diff = getId(a) - getId(b);
2349
- if (diff === 0) {
2350
- const isAPre = a.flags & 2;
2351
- const isBPre = b.flags & 2;
2352
- if (isAPre && !isBPre) return -1;
2353
- if (isBPre && !isAPre) return 1;
2354
- }
2355
- return diff;
2356
- };
2546
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2357
2547
  function flushJobs(seen) {
2358
2548
  isFlushPending = false;
2359
2549
  isFlushing = true;
2360
2550
  if (!!(process.env.NODE_ENV !== "production")) {
2361
2551
  seen = seen || /* @__PURE__ */ new Map();
2362
2552
  }
2363
- queue.sort(comparator);
2364
2553
  const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2365
2554
  try {
2366
2555
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3004,7 +3193,7 @@ function on(instance, event, fn) {
3004
3193
  function once(instance, event, fn) {
3005
3194
  const wrapped = (...args) => {
3006
3195
  off(instance, event, wrapped);
3007
- fn.call(instance.proxy, ...args);
3196
+ fn.apply(instance.proxy, args);
3008
3197
  };
3009
3198
  wrapped.fn = fn;
3010
3199
  on(instance, event, wrapped);
@@ -6552,23 +6741,43 @@ function callHook$1(hook, instance, type) {
6552
6741
  );
6553
6742
  }
6554
6743
  function createWatcher(raw, ctx, publicThis, key) {
6555
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6744
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6745
+ const options = {};
6746
+ {
6747
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6748
+ const newValue = getter();
6749
+ if (isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
6750
+ options.deep = true;
6751
+ }
6752
+ const baseGetter = getter;
6753
+ getter = () => {
6754
+ const val = baseGetter();
6755
+ if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
6756
+ traverse(val);
6757
+ }
6758
+ return val;
6759
+ };
6760
+ }
6556
6761
  if (isString(raw)) {
6557
6762
  const handler = ctx[raw];
6558
6763
  if (isFunction(handler)) {
6559
- watch(getter, handler);
6764
+ {
6765
+ watch(getter, handler, options);
6766
+ }
6560
6767
  } else if (!!(process.env.NODE_ENV !== "production")) {
6561
6768
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6562
6769
  }
6563
6770
  } else if (isFunction(raw)) {
6564
- watch(getter, raw.bind(publicThis));
6771
+ {
6772
+ watch(getter, raw.bind(publicThis), options);
6773
+ }
6565
6774
  } else if (isObject(raw)) {
6566
6775
  if (isArray(raw)) {
6567
6776
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6568
6777
  } else {
6569
6778
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6570
6779
  if (isFunction(handler)) {
6571
- watch(getter, handler, raw);
6780
+ watch(getter, handler, extend(raw, options) );
6572
6781
  } else if (!!(process.env.NODE_ENV !== "production")) {
6573
6782
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6574
6783
  }
@@ -6792,7 +7001,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6792
7001
  return vm;
6793
7002
  }
6794
7003
  }
6795
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7004
+ Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
6796
7005
  Vue.config = singletonApp.config;
6797
7006
  Vue.use = (plugin, ...options) => {
6798
7007
  if (plugin && isFunction(plugin.install)) {
@@ -7124,7 +7333,7 @@ function defineReactive(obj, key, val) {
7124
7333
  if (isArray(val)) {
7125
7334
  methodsToPatch.forEach((m) => {
7126
7335
  val[m] = (...args) => {
7127
- Array.prototype[m].call(reactiveVal, ...args);
7336
+ Array.prototype[m].apply(reactiveVal, args);
7128
7337
  };
7129
7338
  });
7130
7339
  } else {
@@ -8348,7 +8557,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8348
8557
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8349
8558
  subTree = filterSingleRoot(subTree.children) || subTree;
8350
8559
  }
8351
- if (vnode === subTree) {
8560
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8352
8561
  const parentVNode = parentComponent.vnode;
8353
8562
  setScopeId(
8354
8563
  el,
@@ -8689,7 +8898,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8689
8898
  return;
8690
8899
  } else {
8691
8900
  instance.next = n2;
8692
- invalidateJob(instance.update);
8693
8901
  instance.update();
8694
8902
  }
8695
8903
  } else {
@@ -9613,7 +9821,6 @@ function watchSyncEffect(effect, options) {
9613
9821
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
9614
9822
  );
9615
9823
  }
9616
- const INITIAL_WATCHER_VALUE = {};
9617
9824
  function watch(source, cb, options) {
9618
9825
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
9619
9826
  warn$1(
@@ -9622,21 +9829,8 @@ function watch(source, cb, options) {
9622
9829
  }
9623
9830
  return doWatch(source, cb, options);
9624
9831
  }
9625
- function doWatch(source, cb, {
9626
- immediate,
9627
- deep,
9628
- flush,
9629
- once,
9630
- onTrack,
9631
- onTrigger
9632
- } = EMPTY_OBJ) {
9633
- if (cb && once) {
9634
- const _cb = cb;
9635
- cb = (...args) => {
9636
- _cb(...args);
9637
- watchHandle();
9638
- };
9639
- }
9832
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9833
+ const { immediate, deep, flush, once } = options;
9640
9834
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
9641
9835
  if (immediate !== void 0) {
9642
9836
  warn$1(
@@ -9654,173 +9848,53 @@ function doWatch(source, cb, {
9654
9848
  );
9655
9849
  }
9656
9850
  }
9657
- const warnInvalidSource = (s) => {
9658
- warn$1(
9659
- `Invalid watch source: `,
9660
- s,
9661
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9662
- );
9663
- };
9664
- const instance = currentInstance;
9665
- const reactiveGetter = (source2) => {
9666
- if (deep) return source2;
9667
- if (isShallow(source2) || deep === false || deep === 0)
9668
- return traverse(source2, 1);
9669
- return traverse(source2);
9670
- };
9671
- let getter;
9672
- let forceTrigger = false;
9673
- let isMultiSource = false;
9674
- if (isRef(source)) {
9675
- getter = () => source.value;
9676
- forceTrigger = isShallow(source);
9677
- } else if (isReactive(source)) {
9678
- getter = () => reactiveGetter(source);
9679
- forceTrigger = true;
9680
- } else if (isArray(source)) {
9681
- isMultiSource = true;
9682
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9683
- getter = () => source.map((s) => {
9684
- if (isRef(s)) {
9685
- return s.value;
9686
- } else if (isReactive(s)) {
9687
- return reactiveGetter(s);
9688
- } else if (isFunction(s)) {
9689
- return callWithErrorHandling(s, instance, 2);
9690
- } else {
9691
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
9692
- }
9693
- });
9694
- } else if (isFunction(source)) {
9695
- if (cb) {
9696
- getter = () => callWithErrorHandling(source, instance, 2);
9697
- } else {
9698
- getter = () => {
9699
- if (cleanup) {
9700
- cleanup();
9701
- }
9702
- return callWithAsyncErrorHandling(
9703
- source,
9704
- instance,
9705
- 3,
9706
- [onCleanup]
9707
- );
9708
- };
9709
- }
9710
- } else {
9711
- getter = NOOP;
9712
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
9713
- }
9714
- if (cb && !deep) {
9715
- const baseGetter = getter;
9716
- getter = () => {
9717
- const val = baseGetter();
9718
- if (isArray(val) && checkCompatEnabled("WATCH_ARRAY", instance)) {
9719
- traverse(val);
9720
- }
9721
- return val;
9722
- };
9723
- }
9724
- if (cb && deep) {
9725
- const baseGetter = getter;
9726
- const depth = deep === true ? Infinity : deep;
9727
- getter = () => traverse(baseGetter(), depth);
9728
- }
9729
- let cleanup;
9730
- let onCleanup = (fn) => {
9731
- cleanup = effect.onStop = () => {
9732
- callWithErrorHandling(fn, instance, 4);
9733
- cleanup = effect.onStop = void 0;
9734
- };
9735
- };
9851
+ const baseWatchOptions = extend({}, options);
9852
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
9736
9853
  let ssrCleanup;
9737
9854
  if (isInSSRComponentSetup) {
9738
- onCleanup = NOOP;
9739
- if (!cb) {
9740
- getter();
9741
- } else if (immediate) {
9742
- callWithAsyncErrorHandling(cb, instance, 3, [
9743
- getter(),
9744
- isMultiSource ? [] : void 0,
9745
- onCleanup
9746
- ]);
9747
- }
9748
9855
  if (flush === "sync") {
9749
9856
  const ctx = useSSRContext();
9750
9857
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9858
+ } else if (!cb || immediate) {
9859
+ baseWatchOptions.once = true;
9751
9860
  } else {
9752
- const watchHandle2 = () => {
9861
+ return {
9862
+ stop: NOOP,
9863
+ resume: NOOP,
9864
+ pause: NOOP
9753
9865
  };
9754
- watchHandle2.stop = NOOP;
9755
- watchHandle2.resume = NOOP;
9756
- watchHandle2.pause = NOOP;
9757
- return watchHandle2;
9758
9866
  }
9759
9867
  }
9760
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9761
- const job = (immediateFirstRun) => {
9762
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9763
- return;
9764
- }
9765
- if (cb) {
9766
- const newValue = effect.run();
9767
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled("WATCH_ARRAY", instance)) {
9768
- if (cleanup) {
9769
- cleanup();
9770
- }
9771
- callWithAsyncErrorHandling(cb, instance, 3, [
9772
- newValue,
9773
- // pass undefined as the old value when it's changed for the first time
9774
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9775
- onCleanup
9776
- ]);
9777
- oldValue = newValue;
9868
+ const instance = currentInstance;
9869
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9870
+ let isPre = false;
9871
+ if (flush === "post") {
9872
+ baseWatchOptions.scheduler = (job) => {
9873
+ queuePostRenderEffect(job, instance && instance.suspense);
9874
+ };
9875
+ } else if (flush !== "sync") {
9876
+ isPre = true;
9877
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9878
+ if (isFirstRun) {
9879
+ job();
9880
+ } else {
9881
+ queueJob(job);
9778
9882
  }
9779
- } else {
9780
- effect.run();
9781
- }
9782
- };
9783
- if (cb) job.flags |= 4;
9784
- const effect = new ReactiveEffect(getter);
9785
- let scheduler;
9786
- if (flush === "sync") {
9787
- scheduler = job;
9788
- } else if (flush === "post") {
9789
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9790
- } else {
9791
- job.flags |= 2;
9792
- if (instance) job.id = instance.uid;
9793
- scheduler = () => queueJob(job);
9883
+ };
9794
9884
  }
9795
- effect.scheduler = scheduler;
9796
- const scope = getCurrentScope();
9797
- const watchHandle = () => {
9798
- effect.stop();
9799
- if (scope) {
9800
- remove(scope.effects, effect);
9885
+ baseWatchOptions.augmentJob = (job) => {
9886
+ if (cb) {
9887
+ job.flags |= 4;
9801
9888
  }
9802
- };
9803
- watchHandle.pause = effect.pause.bind(effect);
9804
- watchHandle.resume = effect.resume.bind(effect);
9805
- watchHandle.stop = watchHandle;
9806
- if (!!(process.env.NODE_ENV !== "production")) {
9807
- effect.onTrack = onTrack;
9808
- effect.onTrigger = onTrigger;
9809
- }
9810
- if (cb) {
9811
- if (immediate) {
9812
- job(true);
9813
- } else {
9814
- oldValue = effect.run();
9889
+ if (isPre) {
9890
+ job.flags |= 2;
9891
+ if (instance) {
9892
+ job.id = instance.uid;
9893
+ job.i = instance;
9894
+ }
9815
9895
  }
9816
- } else if (flush === "post") {
9817
- queuePostRenderEffect(
9818
- effect.run.bind(effect),
9819
- instance && instance.suspense
9820
- );
9821
- } else {
9822
- effect.run();
9823
- }
9896
+ };
9897
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9824
9898
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9825
9899
  return watchHandle;
9826
9900
  }
@@ -9849,38 +9923,6 @@ function createPathGetter(ctx, path) {
9849
9923
  return cur;
9850
9924
  };
9851
9925
  }
9852
- function traverse(value, depth = Infinity, seen) {
9853
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9854
- return value;
9855
- }
9856
- seen = seen || /* @__PURE__ */ new Set();
9857
- if (seen.has(value)) {
9858
- return value;
9859
- }
9860
- seen.add(value);
9861
- depth--;
9862
- if (isRef(value)) {
9863
- traverse(value.value, depth, seen);
9864
- } else if (isArray(value)) {
9865
- for (let i = 0; i < value.length; i++) {
9866
- traverse(value[i], depth, seen);
9867
- }
9868
- } else if (isSet(value) || isMap(value)) {
9869
- value.forEach((v) => {
9870
- traverse(v, depth, seen);
9871
- });
9872
- } else if (isPlainObject(value)) {
9873
- for (const key in value) {
9874
- traverse(value[key], depth, seen);
9875
- }
9876
- for (const key of Object.getOwnPropertySymbols(value)) {
9877
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9878
- traverse(value[key], depth, seen);
9879
- }
9880
- }
9881
- }
9882
- return value;
9883
- }
9884
9926
 
9885
9927
  function useModel(props, name, options = EMPTY_OBJ) {
9886
9928
  const i = getCurrentInstance();
@@ -12149,7 +12191,7 @@ function isMemoSame(cached, memo) {
12149
12191
  return true;
12150
12192
  }
12151
12193
 
12152
- const version = "3.5.0-beta.2";
12194
+ const version = "3.5.0-beta.3";
12153
12195
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12154
12196
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12155
12197
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -14191,6 +14233,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14191
14233
  effectScope: effectScope,
14192
14234
  getCurrentInstance: getCurrentInstance,
14193
14235
  getCurrentScope: getCurrentScope,
14236
+ getCurrentWatcher: getCurrentWatcher,
14194
14237
  getTransitionRawChildren: getTransitionRawChildren,
14195
14238
  guardReactiveProps: guardReactiveProps,
14196
14239
  h: h,
@@ -14233,6 +14276,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14233
14276
  onServerPrefetch: onServerPrefetch,
14234
14277
  onUnmounted: onUnmounted,
14235
14278
  onUpdated: onUpdated,
14279
+ onWatcherCleanup: onWatcherCleanup,
14236
14280
  openBlock: openBlock,
14237
14281
  popScopeId: popScopeId,
14238
14282
  provide: provide,
@@ -14340,4 +14384,4 @@ Vue.compile = () => {
14340
14384
 
14341
14385
  const configureCompat = Vue.configureCompat;
14342
14386
 
14343
- export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, hydrateOnIdle, hydrateOnInteraction, hydrateOnMediaQuery, hydrateOnVisible, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useHost, useId, useModel, useSSRContext, useShadowRoot, useSlots, useTemplateRef, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
14387
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getCurrentWatcher, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, hydrateOnIdle, hydrateOnInteraction, hydrateOnMediaQuery, hydrateOnVisible, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, onWatcherCleanup, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useHost, useId, useModel, useSSRContext, useShadowRoot, useSlots, useTemplateRef, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };