@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
  **/
@@ -1141,14 +1141,14 @@ function iterator(self, method, wrapValue) {
1141
1141
  const arrayProto = Array.prototype;
1142
1142
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1143
1143
  const arr = shallowReadArray(self);
1144
- let methodFn;
1145
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1146
- return methodFn.apply(arr, args);
1144
+ const needsWrap = arr !== self && !isShallow(self);
1145
+ const methodFn = arr[method];
1146
+ if (methodFn !== arrayProto[method]) {
1147
+ const result2 = methodFn.apply(arr, args);
1148
+ return needsWrap ? toReactive(result2) : result2;
1147
1149
  }
1148
- let needsWrap = false;
1149
1150
  let wrappedFn = fn;
1150
1151
  if (arr !== self) {
1151
- needsWrap = !isShallow(self);
1152
1152
  if (needsWrap) {
1153
1153
  wrappedFn = function(item, index) {
1154
1154
  return fn.call(this, toReactive(item), index, self);
@@ -2016,6 +2016,220 @@ const TriggerOpTypes = {
2016
2016
  "CLEAR": "clear"
2017
2017
  };
2018
2018
 
2019
+ const INITIAL_WATCHER_VALUE = {};
2020
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2021
+ let activeWatcher = void 0;
2022
+ function getCurrentWatcher() {
2023
+ return activeWatcher;
2024
+ }
2025
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2026
+ if (owner) {
2027
+ let cleanups = cleanupMap.get(owner);
2028
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2029
+ cleanups.push(cleanupFn);
2030
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
2031
+ warn$2(
2032
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2033
+ );
2034
+ }
2035
+ }
2036
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2037
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2038
+ const warnInvalidSource = (s) => {
2039
+ (options.onWarn || warn$2)(
2040
+ `Invalid watch source: `,
2041
+ s,
2042
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2043
+ );
2044
+ };
2045
+ const reactiveGetter = (source2) => {
2046
+ if (deep) return source2;
2047
+ if (isShallow(source2) || deep === false || deep === 0)
2048
+ return traverse(source2, 1);
2049
+ return traverse(source2);
2050
+ };
2051
+ let effect;
2052
+ let getter;
2053
+ let cleanup;
2054
+ let boundCleanup;
2055
+ let forceTrigger = false;
2056
+ let isMultiSource = false;
2057
+ if (isRef(source)) {
2058
+ getter = () => source.value;
2059
+ forceTrigger = isShallow(source);
2060
+ } else if (isReactive(source)) {
2061
+ getter = () => reactiveGetter(source);
2062
+ forceTrigger = true;
2063
+ } else if (isArray(source)) {
2064
+ isMultiSource = true;
2065
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2066
+ getter = () => source.map((s) => {
2067
+ if (isRef(s)) {
2068
+ return s.value;
2069
+ } else if (isReactive(s)) {
2070
+ return reactiveGetter(s);
2071
+ } else if (isFunction(s)) {
2072
+ return call ? call(s, 2) : s();
2073
+ } else {
2074
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
2075
+ }
2076
+ });
2077
+ } else if (isFunction(source)) {
2078
+ if (cb) {
2079
+ getter = call ? () => call(source, 2) : source;
2080
+ } else {
2081
+ getter = () => {
2082
+ if (cleanup) {
2083
+ pauseTracking();
2084
+ try {
2085
+ cleanup();
2086
+ } finally {
2087
+ resetTracking();
2088
+ }
2089
+ }
2090
+ const currentEffect = activeWatcher;
2091
+ activeWatcher = effect;
2092
+ try {
2093
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2094
+ } finally {
2095
+ activeWatcher = currentEffect;
2096
+ }
2097
+ };
2098
+ }
2099
+ } else {
2100
+ getter = NOOP;
2101
+ !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
2102
+ }
2103
+ if (cb && deep) {
2104
+ const baseGetter = getter;
2105
+ const depth = deep === true ? Infinity : deep;
2106
+ getter = () => traverse(baseGetter(), depth);
2107
+ }
2108
+ if (once) {
2109
+ if (cb) {
2110
+ const _cb = cb;
2111
+ cb = (...args) => {
2112
+ _cb(...args);
2113
+ effect.stop();
2114
+ };
2115
+ } else {
2116
+ const _getter = getter;
2117
+ getter = () => {
2118
+ _getter();
2119
+ effect.stop();
2120
+ };
2121
+ }
2122
+ }
2123
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2124
+ const job = (immediateFirstRun) => {
2125
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2126
+ return;
2127
+ }
2128
+ if (cb) {
2129
+ const newValue = effect.run();
2130
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2131
+ if (cleanup) {
2132
+ cleanup();
2133
+ }
2134
+ const currentWatcher = activeWatcher;
2135
+ activeWatcher = effect;
2136
+ try {
2137
+ const args = [
2138
+ newValue,
2139
+ // pass undefined as the old value when it's changed for the first time
2140
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2141
+ boundCleanup
2142
+ ];
2143
+ call ? call(cb, 3, args) : (
2144
+ // @ts-expect-error
2145
+ cb(...args)
2146
+ );
2147
+ oldValue = newValue;
2148
+ } finally {
2149
+ activeWatcher = currentWatcher;
2150
+ }
2151
+ }
2152
+ } else {
2153
+ effect.run();
2154
+ }
2155
+ };
2156
+ if (augmentJob) {
2157
+ augmentJob(job);
2158
+ }
2159
+ effect = new ReactiveEffect(getter);
2160
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2161
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2162
+ cleanup = effect.onStop = () => {
2163
+ const cleanups = cleanupMap.get(effect);
2164
+ if (cleanups) {
2165
+ if (call) {
2166
+ call(cleanups, 4);
2167
+ } else {
2168
+ for (const cleanup2 of cleanups) cleanup2();
2169
+ }
2170
+ cleanupMap.delete(effect);
2171
+ }
2172
+ };
2173
+ if (!!(process.env.NODE_ENV !== "production")) {
2174
+ effect.onTrack = options.onTrack;
2175
+ effect.onTrigger = options.onTrigger;
2176
+ }
2177
+ if (cb) {
2178
+ if (immediate) {
2179
+ job(true);
2180
+ } else {
2181
+ oldValue = effect.run();
2182
+ }
2183
+ } else if (scheduler) {
2184
+ scheduler(job.bind(null, true), true);
2185
+ } else {
2186
+ effect.run();
2187
+ }
2188
+ const scope = getCurrentScope();
2189
+ const watchHandle = () => {
2190
+ effect.stop();
2191
+ if (scope) {
2192
+ remove(scope.effects, effect);
2193
+ }
2194
+ };
2195
+ watchHandle.pause = effect.pause.bind(effect);
2196
+ watchHandle.resume = effect.resume.bind(effect);
2197
+ watchHandle.stop = watchHandle;
2198
+ return watchHandle;
2199
+ }
2200
+ function traverse(value, depth = Infinity, seen) {
2201
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2202
+ return value;
2203
+ }
2204
+ seen = seen || /* @__PURE__ */ new Set();
2205
+ if (seen.has(value)) {
2206
+ return value;
2207
+ }
2208
+ seen.add(value);
2209
+ depth--;
2210
+ if (isRef(value)) {
2211
+ traverse(value.value, depth, seen);
2212
+ } else if (isArray(value)) {
2213
+ for (let i = 0; i < value.length; i++) {
2214
+ traverse(value[i], depth, seen);
2215
+ }
2216
+ } else if (isSet(value) || isMap(value)) {
2217
+ value.forEach((v) => {
2218
+ traverse(v, depth, seen);
2219
+ });
2220
+ } else if (isPlainObject(value)) {
2221
+ for (const key in value) {
2222
+ traverse(value[key], depth, seen);
2223
+ }
2224
+ for (const key of Object.getOwnPropertySymbols(value)) {
2225
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2226
+ traverse(value[key], depth, seen);
2227
+ }
2228
+ }
2229
+ }
2230
+ return value;
2231
+ }
2232
+
2019
2233
  const stack$1 = [];
2020
2234
  function pushWarningContext(vnode) {
2021
2235
  stack$1.push(vnode);
@@ -2144,12 +2358,6 @@ const ErrorCodes = {
2144
2358
  "0": "SETUP_FUNCTION",
2145
2359
  "RENDER_FUNCTION": 1,
2146
2360
  "1": "RENDER_FUNCTION",
2147
- "WATCH_GETTER": 2,
2148
- "2": "WATCH_GETTER",
2149
- "WATCH_CALLBACK": 3,
2150
- "3": "WATCH_CALLBACK",
2151
- "WATCH_CLEANUP": 4,
2152
- "4": "WATCH_CLEANUP",
2153
2361
  "NATIVE_EVENT_HANDLER": 5,
2154
2362
  "5": "NATIVE_EVENT_HANDLER",
2155
2363
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2305,7 +2513,7 @@ function nextTick(fn) {
2305
2513
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2306
2514
  }
2307
2515
  function findInsertionIndex(id) {
2308
- let start = flushIndex + 1;
2516
+ let start = isFlushing ? flushIndex + 1 : 0;
2309
2517
  let end = queue.length;
2310
2518
  while (start < end) {
2311
2519
  const middle = start + end >>> 1;
@@ -2321,15 +2529,13 @@ function findInsertionIndex(id) {
2321
2529
  }
2322
2530
  function queueJob(job) {
2323
2531
  if (!(job.flags & 1)) {
2324
- if (job.id == null) {
2325
- queue.push(job);
2326
- } else if (
2327
- // fast path when the job id is larger than the tail
2328
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2329
- ) {
2532
+ const jobId = getId(job);
2533
+ const lastJob = queue[queue.length - 1];
2534
+ if (!lastJob || // fast path when the job id is larger than the tail
2535
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2330
2536
  queue.push(job);
2331
2537
  } else {
2332
- queue.splice(findInsertionIndex(job.id), 0, job);
2538
+ queue.splice(findInsertionIndex(jobId), 0, job);
2333
2539
  }
2334
2540
  if (!(job.flags & 4)) {
2335
2541
  job.flags |= 1;
@@ -2343,12 +2549,6 @@ function queueFlush() {
2343
2549
  currentFlushPromise = resolvedPromise.then(flushJobs);
2344
2550
  }
2345
2551
  }
2346
- function invalidateJob(job) {
2347
- const i = queue.indexOf(job);
2348
- if (i > flushIndex) {
2349
- queue.splice(i, 1);
2350
- }
2351
- }
2352
2552
  function queuePostFlushCb(cb) {
2353
2553
  if (!isArray(cb)) {
2354
2554
  if (activePostFlushCbs && cb.id === -1) {
@@ -2410,24 +2610,13 @@ function flushPostFlushCbs(seen) {
2410
2610
  postFlushIndex = 0;
2411
2611
  }
2412
2612
  }
2413
- const getId = (job) => job.id == null ? Infinity : job.id;
2414
- const comparator = (a, b) => {
2415
- const diff = getId(a) - getId(b);
2416
- if (diff === 0) {
2417
- const isAPre = a.flags & 2;
2418
- const isBPre = b.flags & 2;
2419
- if (isAPre && !isBPre) return -1;
2420
- if (isBPre && !isAPre) return 1;
2421
- }
2422
- return diff;
2423
- };
2613
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2424
2614
  function flushJobs(seen) {
2425
2615
  isFlushPending = false;
2426
2616
  isFlushing = true;
2427
2617
  if (!!(process.env.NODE_ENV !== "production")) {
2428
2618
  seen = seen || /* @__PURE__ */ new Map();
2429
2619
  }
2430
- queue.sort(comparator);
2431
2620
  const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2432
2621
  try {
2433
2622
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3071,7 +3260,7 @@ function on(instance, event, fn) {
3071
3260
  function once(instance, event, fn) {
3072
3261
  const wrapped = (...args) => {
3073
3262
  off(instance, event, wrapped);
3074
- fn.call(instance.proxy, ...args);
3263
+ fn.apply(instance.proxy, args);
3075
3264
  };
3076
3265
  wrapped.fn = fn;
3077
3266
  on(instance, event, wrapped);
@@ -6619,23 +6808,43 @@ function callHook$1(hook, instance, type) {
6619
6808
  );
6620
6809
  }
6621
6810
  function createWatcher(raw, ctx, publicThis, key) {
6622
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6811
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6812
+ const options = {};
6813
+ {
6814
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6815
+ const newValue = getter();
6816
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
6817
+ options.deep = true;
6818
+ }
6819
+ const baseGetter = getter;
6820
+ getter = () => {
6821
+ const val = baseGetter();
6822
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
6823
+ traverse(val);
6824
+ }
6825
+ return val;
6826
+ };
6827
+ }
6623
6828
  if (isString(raw)) {
6624
6829
  const handler = ctx[raw];
6625
6830
  if (isFunction(handler)) {
6626
- watch(getter, handler);
6831
+ {
6832
+ watch(getter, handler, options);
6833
+ }
6627
6834
  } else if (!!(process.env.NODE_ENV !== "production")) {
6628
6835
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6629
6836
  }
6630
6837
  } else if (isFunction(raw)) {
6631
- watch(getter, raw.bind(publicThis));
6838
+ {
6839
+ watch(getter, raw.bind(publicThis), options);
6840
+ }
6632
6841
  } else if (isObject(raw)) {
6633
6842
  if (isArray(raw)) {
6634
6843
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6635
6844
  } else {
6636
6845
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6637
6846
  if (isFunction(handler)) {
6638
- watch(getter, handler, raw);
6847
+ watch(getter, handler, extend(raw, options) );
6639
6848
  } else if (!!(process.env.NODE_ENV !== "production")) {
6640
6849
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6641
6850
  }
@@ -6859,7 +7068,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6859
7068
  return vm;
6860
7069
  }
6861
7070
  }
6862
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7071
+ Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
6863
7072
  Vue.config = singletonApp.config;
6864
7073
  Vue.use = (plugin, ...options) => {
6865
7074
  if (plugin && isFunction(plugin.install)) {
@@ -7191,7 +7400,7 @@ function defineReactive(obj, key, val) {
7191
7400
  if (isArray(val)) {
7192
7401
  methodsToPatch.forEach((m) => {
7193
7402
  val[m] = (...args) => {
7194
- Array.prototype[m].call(reactiveVal, ...args);
7403
+ Array.prototype[m].apply(reactiveVal, args);
7195
7404
  };
7196
7405
  });
7197
7406
  } else {
@@ -8415,7 +8624,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8415
8624
  if (!!(process.env.NODE_ENV !== "production") && subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8416
8625
  subTree = filterSingleRoot(subTree.children) || subTree;
8417
8626
  }
8418
- if (vnode === subTree) {
8627
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8419
8628
  const parentVNode = parentComponent.vnode;
8420
8629
  setScopeId(
8421
8630
  el,
@@ -8756,7 +8965,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8756
8965
  return;
8757
8966
  } else {
8758
8967
  instance.next = n2;
8759
- invalidateJob(instance.update);
8760
8968
  instance.update();
8761
8969
  }
8762
8970
  } else {
@@ -9680,7 +9888,6 @@ function watchSyncEffect(effect, options) {
9680
9888
  !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
9681
9889
  );
9682
9890
  }
9683
- const INITIAL_WATCHER_VALUE = {};
9684
9891
  function watch(source, cb, options) {
9685
9892
  if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
9686
9893
  warn$1(
@@ -9689,21 +9896,8 @@ function watch(source, cb, options) {
9689
9896
  }
9690
9897
  return doWatch(source, cb, options);
9691
9898
  }
9692
- function doWatch(source, cb, {
9693
- immediate,
9694
- deep,
9695
- flush,
9696
- once,
9697
- onTrack,
9698
- onTrigger
9699
- } = EMPTY_OBJ) {
9700
- if (cb && once) {
9701
- const _cb = cb;
9702
- cb = (...args) => {
9703
- _cb(...args);
9704
- watchHandle();
9705
- };
9706
- }
9899
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9900
+ const { immediate, deep, flush, once } = options;
9707
9901
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
9708
9902
  if (immediate !== void 0) {
9709
9903
  warn$1(
@@ -9721,173 +9915,53 @@ function doWatch(source, cb, {
9721
9915
  );
9722
9916
  }
9723
9917
  }
9724
- const warnInvalidSource = (s) => {
9725
- warn$1(
9726
- `Invalid watch source: `,
9727
- s,
9728
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9729
- );
9730
- };
9731
- const instance = currentInstance;
9732
- const reactiveGetter = (source2) => {
9733
- if (deep) return source2;
9734
- if (isShallow(source2) || deep === false || deep === 0)
9735
- return traverse(source2, 1);
9736
- return traverse(source2);
9737
- };
9738
- let getter;
9739
- let forceTrigger = false;
9740
- let isMultiSource = false;
9741
- if (isRef(source)) {
9742
- getter = () => source.value;
9743
- forceTrigger = isShallow(source);
9744
- } else if (isReactive(source)) {
9745
- getter = () => reactiveGetter(source);
9746
- forceTrigger = true;
9747
- } else if (isArray(source)) {
9748
- isMultiSource = true;
9749
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9750
- getter = () => source.map((s) => {
9751
- if (isRef(s)) {
9752
- return s.value;
9753
- } else if (isReactive(s)) {
9754
- return reactiveGetter(s);
9755
- } else if (isFunction(s)) {
9756
- return callWithErrorHandling(s, instance, 2);
9757
- } else {
9758
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
9759
- }
9760
- });
9761
- } else if (isFunction(source)) {
9762
- if (cb) {
9763
- getter = () => callWithErrorHandling(source, instance, 2);
9764
- } else {
9765
- getter = () => {
9766
- if (cleanup) {
9767
- cleanup();
9768
- }
9769
- return callWithAsyncErrorHandling(
9770
- source,
9771
- instance,
9772
- 3,
9773
- [onCleanup]
9774
- );
9775
- };
9776
- }
9777
- } else {
9778
- getter = NOOP;
9779
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
9780
- }
9781
- if (cb && !deep) {
9782
- const baseGetter = getter;
9783
- getter = () => {
9784
- const val = baseGetter();
9785
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
9786
- traverse(val);
9787
- }
9788
- return val;
9789
- };
9790
- }
9791
- if (cb && deep) {
9792
- const baseGetter = getter;
9793
- const depth = deep === true ? Infinity : deep;
9794
- getter = () => traverse(baseGetter(), depth);
9795
- }
9796
- let cleanup;
9797
- let onCleanup = (fn) => {
9798
- cleanup = effect.onStop = () => {
9799
- callWithErrorHandling(fn, instance, 4);
9800
- cleanup = effect.onStop = void 0;
9801
- };
9802
- };
9918
+ const baseWatchOptions = extend({}, options);
9919
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn$1;
9803
9920
  let ssrCleanup;
9804
9921
  if (isInSSRComponentSetup) {
9805
- onCleanup = NOOP;
9806
- if (!cb) {
9807
- getter();
9808
- } else if (immediate) {
9809
- callWithAsyncErrorHandling(cb, instance, 3, [
9810
- getter(),
9811
- isMultiSource ? [] : void 0,
9812
- onCleanup
9813
- ]);
9814
- }
9815
9922
  if (flush === "sync") {
9816
9923
  const ctx = useSSRContext();
9817
9924
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9925
+ } else if (!cb || immediate) {
9926
+ baseWatchOptions.once = true;
9818
9927
  } else {
9819
- const watchHandle2 = () => {
9928
+ return {
9929
+ stop: NOOP,
9930
+ resume: NOOP,
9931
+ pause: NOOP
9820
9932
  };
9821
- watchHandle2.stop = NOOP;
9822
- watchHandle2.resume = NOOP;
9823
- watchHandle2.pause = NOOP;
9824
- return watchHandle2;
9825
9933
  }
9826
9934
  }
9827
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9828
- const job = (immediateFirstRun) => {
9829
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9830
- return;
9831
- }
9832
- if (cb) {
9833
- const newValue = effect.run();
9834
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
9835
- if (cleanup) {
9836
- cleanup();
9837
- }
9838
- callWithAsyncErrorHandling(cb, instance, 3, [
9839
- newValue,
9840
- // pass undefined as the old value when it's changed for the first time
9841
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9842
- onCleanup
9843
- ]);
9844
- oldValue = newValue;
9935
+ const instance = currentInstance;
9936
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9937
+ let isPre = false;
9938
+ if (flush === "post") {
9939
+ baseWatchOptions.scheduler = (job) => {
9940
+ queuePostRenderEffect(job, instance && instance.suspense);
9941
+ };
9942
+ } else if (flush !== "sync") {
9943
+ isPre = true;
9944
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9945
+ if (isFirstRun) {
9946
+ job();
9947
+ } else {
9948
+ queueJob(job);
9845
9949
  }
9846
- } else {
9847
- effect.run();
9848
- }
9849
- };
9850
- if (cb) job.flags |= 4;
9851
- const effect = new ReactiveEffect(getter);
9852
- let scheduler;
9853
- if (flush === "sync") {
9854
- scheduler = job;
9855
- } else if (flush === "post") {
9856
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9857
- } else {
9858
- job.flags |= 2;
9859
- if (instance) job.id = instance.uid;
9860
- scheduler = () => queueJob(job);
9950
+ };
9861
9951
  }
9862
- effect.scheduler = scheduler;
9863
- const scope = getCurrentScope();
9864
- const watchHandle = () => {
9865
- effect.stop();
9866
- if (scope) {
9867
- remove(scope.effects, effect);
9952
+ baseWatchOptions.augmentJob = (job) => {
9953
+ if (cb) {
9954
+ job.flags |= 4;
9868
9955
  }
9869
- };
9870
- watchHandle.pause = effect.pause.bind(effect);
9871
- watchHandle.resume = effect.resume.bind(effect);
9872
- watchHandle.stop = watchHandle;
9873
- if (!!(process.env.NODE_ENV !== "production")) {
9874
- effect.onTrack = onTrack;
9875
- effect.onTrigger = onTrigger;
9876
- }
9877
- if (cb) {
9878
- if (immediate) {
9879
- job(true);
9880
- } else {
9881
- oldValue = effect.run();
9956
+ if (isPre) {
9957
+ job.flags |= 2;
9958
+ if (instance) {
9959
+ job.id = instance.uid;
9960
+ job.i = instance;
9961
+ }
9882
9962
  }
9883
- } else if (flush === "post") {
9884
- queuePostRenderEffect(
9885
- effect.run.bind(effect),
9886
- instance && instance.suspense
9887
- );
9888
- } else {
9889
- effect.run();
9890
- }
9963
+ };
9964
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9891
9965
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9892
9966
  return watchHandle;
9893
9967
  }
@@ -9916,38 +9990,6 @@ function createPathGetter(ctx, path) {
9916
9990
  return cur;
9917
9991
  };
9918
9992
  }
9919
- function traverse(value, depth = Infinity, seen) {
9920
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9921
- return value;
9922
- }
9923
- seen = seen || /* @__PURE__ */ new Set();
9924
- if (seen.has(value)) {
9925
- return value;
9926
- }
9927
- seen.add(value);
9928
- depth--;
9929
- if (isRef(value)) {
9930
- traverse(value.value, depth, seen);
9931
- } else if (isArray(value)) {
9932
- for (let i = 0; i < value.length; i++) {
9933
- traverse(value[i], depth, seen);
9934
- }
9935
- } else if (isSet(value) || isMap(value)) {
9936
- value.forEach((v) => {
9937
- traverse(v, depth, seen);
9938
- });
9939
- } else if (isPlainObject(value)) {
9940
- for (const key in value) {
9941
- traverse(value[key], depth, seen);
9942
- }
9943
- for (const key of Object.getOwnPropertySymbols(value)) {
9944
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9945
- traverse(value[key], depth, seen);
9946
- }
9947
- }
9948
- }
9949
- return value;
9950
- }
9951
9993
 
9952
9994
  function useModel(props, name, options = EMPTY_OBJ) {
9953
9995
  const i = getCurrentInstance();
@@ -12216,7 +12258,7 @@ function isMemoSame(cached, memo) {
12216
12258
  return true;
12217
12259
  }
12218
12260
 
12219
- const version = "3.5.0-beta.2";
12261
+ const version = "3.5.0-beta.3";
12220
12262
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12221
12263
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12222
12264
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -14258,6 +14300,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14258
14300
  effectScope: effectScope,
14259
14301
  getCurrentInstance: getCurrentInstance,
14260
14302
  getCurrentScope: getCurrentScope,
14303
+ getCurrentWatcher: getCurrentWatcher,
14261
14304
  getTransitionRawChildren: getTransitionRawChildren,
14262
14305
  guardReactiveProps: guardReactiveProps,
14263
14306
  h: h,
@@ -14300,6 +14343,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14300
14343
  onServerPrefetch: onServerPrefetch,
14301
14344
  onUnmounted: onUnmounted,
14302
14345
  onUpdated: onUpdated,
14346
+ onWatcherCleanup: onWatcherCleanup,
14303
14347
  openBlock: openBlock,
14304
14348
  popScopeId: popScopeId,
14305
14349
  provide: provide,
@@ -16145,7 +16189,9 @@ const tokenizer = new Tokenizer(stack, {
16145
16189
  case 17:
16146
16190
  case 18:
16147
16191
  case 19:
16192
+ // "
16148
16193
  case 20:
16194
+ // '
16149
16195
  case 21:
16150
16196
  emitError(9, end);
16151
16197
  break;
@@ -17128,6 +17174,7 @@ function traverseNode(node, context) {
17128
17174
  context.helper(TO_DISPLAY_STRING);
17129
17175
  }
17130
17176
  break;
17177
+ // for container types, further traverse downwards
17131
17178
  case 9:
17132
17179
  for (let i2 = 0; i2 < node.branches.length; i2++) {
17133
17180
  traverseNode(node.branches[i2], context);
@@ -17480,6 +17527,7 @@ function genNode(node, context) {
17480
17527
  case 21:
17481
17528
  genNodeList(node.body, context, true, false);
17482
17529
  break;
17530
+ // SSR only types
17483
17531
  case 22:
17484
17532
  break;
17485
17533
  case 23:
@@ -17490,6 +17538,7 @@ function genNode(node, context) {
17490
17538
  break;
17491
17539
  case 26:
17492
17540
  break;
17541
+ /* istanbul ignore next */
17493
17542
  case 10:
17494
17543
  break;
17495
17544
  default:
@@ -19499,27 +19548,35 @@ function parseFilter(node, context) {
19499
19548
  case 34:
19500
19549
  inDouble = true;
19501
19550
  break;
19551
+ // "
19502
19552
  case 39:
19503
19553
  inSingle = true;
19504
19554
  break;
19555
+ // '
19505
19556
  case 96:
19506
19557
  inTemplateString = true;
19507
19558
  break;
19559
+ // `
19508
19560
  case 40:
19509
19561
  paren++;
19510
19562
  break;
19563
+ // (
19511
19564
  case 41:
19512
19565
  paren--;
19513
19566
  break;
19567
+ // )
19514
19568
  case 91:
19515
19569
  square++;
19516
19570
  break;
19571
+ // [
19517
19572
  case 93:
19518
19573
  square--;
19519
19574
  break;
19575
+ // ]
19520
19576
  case 123:
19521
19577
  curly++;
19522
19578
  break;
19579
+ // {
19523
19580
  case 125:
19524
19581
  curly--;
19525
19582
  break;
@@ -20370,4 +20427,4 @@ Vue.compile = compileToFunction;
20370
20427
 
20371
20428
  const configureCompat = Vue.configureCompat;
20372
20429
 
20373
- 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 };
20430
+ 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 };