@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.
package/dist/vue.cjs.js CHANGED
@@ -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
  **/
@@ -1188,14 +1188,14 @@ function iterator(self, method, wrapValue) {
1188
1188
  const arrayProto = Array.prototype;
1189
1189
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1190
1190
  const arr = shallowReadArray(self);
1191
- let methodFn;
1192
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1193
- return methodFn.apply(arr, args);
1191
+ const needsWrap = arr !== self && !isShallow(self);
1192
+ const methodFn = arr[method];
1193
+ if (methodFn !== arrayProto[method]) {
1194
+ const result2 = methodFn.apply(arr, args);
1195
+ return needsWrap ? toReactive(result2) : result2;
1194
1196
  }
1195
- let needsWrap = false;
1196
1197
  let wrappedFn = fn;
1197
1198
  if (arr !== self) {
1198
- needsWrap = !isShallow(self);
1199
1199
  if (needsWrap) {
1200
1200
  wrappedFn = function(item, index) {
1201
1201
  return fn.call(this, toReactive(item), index, self);
@@ -2057,6 +2057,220 @@ const TriggerOpTypes = {
2057
2057
  "CLEAR": "clear"
2058
2058
  };
2059
2059
 
2060
+ const INITIAL_WATCHER_VALUE = {};
2061
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
2062
+ let activeWatcher = void 0;
2063
+ function getCurrentWatcher() {
2064
+ return activeWatcher;
2065
+ }
2066
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2067
+ if (owner) {
2068
+ let cleanups = cleanupMap.get(owner);
2069
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
2070
+ cleanups.push(cleanupFn);
2071
+ } else if (!failSilently) {
2072
+ warn$2(
2073
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
2074
+ );
2075
+ }
2076
+ }
2077
+ function watch$1(source, cb, options = EMPTY_OBJ) {
2078
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
2079
+ const warnInvalidSource = (s) => {
2080
+ (options.onWarn || warn$2)(
2081
+ `Invalid watch source: `,
2082
+ s,
2083
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
2084
+ );
2085
+ };
2086
+ const reactiveGetter = (source2) => {
2087
+ if (deep) return source2;
2088
+ if (isShallow(source2) || deep === false || deep === 0)
2089
+ return traverse(source2, 1);
2090
+ return traverse(source2);
2091
+ };
2092
+ let effect;
2093
+ let getter;
2094
+ let cleanup;
2095
+ let boundCleanup;
2096
+ let forceTrigger = false;
2097
+ let isMultiSource = false;
2098
+ if (isRef(source)) {
2099
+ getter = () => source.value;
2100
+ forceTrigger = isShallow(source);
2101
+ } else if (isReactive(source)) {
2102
+ getter = () => reactiveGetter(source);
2103
+ forceTrigger = true;
2104
+ } else if (isArray(source)) {
2105
+ isMultiSource = true;
2106
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
2107
+ getter = () => source.map((s) => {
2108
+ if (isRef(s)) {
2109
+ return s.value;
2110
+ } else if (isReactive(s)) {
2111
+ return reactiveGetter(s);
2112
+ } else if (isFunction(s)) {
2113
+ return call ? call(s, 2) : s();
2114
+ } else {
2115
+ warnInvalidSource(s);
2116
+ }
2117
+ });
2118
+ } else if (isFunction(source)) {
2119
+ if (cb) {
2120
+ getter = call ? () => call(source, 2) : source;
2121
+ } else {
2122
+ getter = () => {
2123
+ if (cleanup) {
2124
+ pauseTracking();
2125
+ try {
2126
+ cleanup();
2127
+ } finally {
2128
+ resetTracking();
2129
+ }
2130
+ }
2131
+ const currentEffect = activeWatcher;
2132
+ activeWatcher = effect;
2133
+ try {
2134
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2135
+ } finally {
2136
+ activeWatcher = currentEffect;
2137
+ }
2138
+ };
2139
+ }
2140
+ } else {
2141
+ getter = NOOP;
2142
+ warnInvalidSource(source);
2143
+ }
2144
+ if (cb && deep) {
2145
+ const baseGetter = getter;
2146
+ const depth = deep === true ? Infinity : deep;
2147
+ getter = () => traverse(baseGetter(), depth);
2148
+ }
2149
+ if (once) {
2150
+ if (cb) {
2151
+ const _cb = cb;
2152
+ cb = (...args) => {
2153
+ _cb(...args);
2154
+ effect.stop();
2155
+ };
2156
+ } else {
2157
+ const _getter = getter;
2158
+ getter = () => {
2159
+ _getter();
2160
+ effect.stop();
2161
+ };
2162
+ }
2163
+ }
2164
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2165
+ const job = (immediateFirstRun) => {
2166
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2167
+ return;
2168
+ }
2169
+ if (cb) {
2170
+ const newValue = effect.run();
2171
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2172
+ if (cleanup) {
2173
+ cleanup();
2174
+ }
2175
+ const currentWatcher = activeWatcher;
2176
+ activeWatcher = effect;
2177
+ try {
2178
+ const args = [
2179
+ newValue,
2180
+ // pass undefined as the old value when it's changed for the first time
2181
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2182
+ boundCleanup
2183
+ ];
2184
+ call ? call(cb, 3, args) : (
2185
+ // @ts-expect-error
2186
+ cb(...args)
2187
+ );
2188
+ oldValue = newValue;
2189
+ } finally {
2190
+ activeWatcher = currentWatcher;
2191
+ }
2192
+ }
2193
+ } else {
2194
+ effect.run();
2195
+ }
2196
+ };
2197
+ if (augmentJob) {
2198
+ augmentJob(job);
2199
+ }
2200
+ effect = new ReactiveEffect(getter);
2201
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2202
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2203
+ cleanup = effect.onStop = () => {
2204
+ const cleanups = cleanupMap.get(effect);
2205
+ if (cleanups) {
2206
+ if (call) {
2207
+ call(cleanups, 4);
2208
+ } else {
2209
+ for (const cleanup2 of cleanups) cleanup2();
2210
+ }
2211
+ cleanupMap.delete(effect);
2212
+ }
2213
+ };
2214
+ {
2215
+ effect.onTrack = options.onTrack;
2216
+ effect.onTrigger = options.onTrigger;
2217
+ }
2218
+ if (cb) {
2219
+ if (immediate) {
2220
+ job(true);
2221
+ } else {
2222
+ oldValue = effect.run();
2223
+ }
2224
+ } else if (scheduler) {
2225
+ scheduler(job.bind(null, true), true);
2226
+ } else {
2227
+ effect.run();
2228
+ }
2229
+ const scope = getCurrentScope();
2230
+ const watchHandle = () => {
2231
+ effect.stop();
2232
+ if (scope) {
2233
+ remove(scope.effects, effect);
2234
+ }
2235
+ };
2236
+ watchHandle.pause = effect.pause.bind(effect);
2237
+ watchHandle.resume = effect.resume.bind(effect);
2238
+ watchHandle.stop = watchHandle;
2239
+ return watchHandle;
2240
+ }
2241
+ function traverse(value, depth = Infinity, seen) {
2242
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2243
+ return value;
2244
+ }
2245
+ seen = seen || /* @__PURE__ */ new Set();
2246
+ if (seen.has(value)) {
2247
+ return value;
2248
+ }
2249
+ seen.add(value);
2250
+ depth--;
2251
+ if (isRef(value)) {
2252
+ traverse(value.value, depth, seen);
2253
+ } else if (isArray(value)) {
2254
+ for (let i = 0; i < value.length; i++) {
2255
+ traverse(value[i], depth, seen);
2256
+ }
2257
+ } else if (isSet(value) || isMap(value)) {
2258
+ value.forEach((v) => {
2259
+ traverse(v, depth, seen);
2260
+ });
2261
+ } else if (isPlainObject(value)) {
2262
+ for (const key in value) {
2263
+ traverse(value[key], depth, seen);
2264
+ }
2265
+ for (const key of Object.getOwnPropertySymbols(value)) {
2266
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2267
+ traverse(value[key], depth, seen);
2268
+ }
2269
+ }
2270
+ }
2271
+ return value;
2272
+ }
2273
+
2060
2274
  const stack$1 = [];
2061
2275
  function pushWarningContext(vnode) {
2062
2276
  stack$1.push(vnode);
@@ -2184,12 +2398,6 @@ const ErrorCodes = {
2184
2398
  "0": "SETUP_FUNCTION",
2185
2399
  "RENDER_FUNCTION": 1,
2186
2400
  "1": "RENDER_FUNCTION",
2187
- "WATCH_GETTER": 2,
2188
- "2": "WATCH_GETTER",
2189
- "WATCH_CALLBACK": 3,
2190
- "3": "WATCH_CALLBACK",
2191
- "WATCH_CLEANUP": 4,
2192
- "4": "WATCH_CLEANUP",
2193
2401
  "NATIVE_EVENT_HANDLER": 5,
2194
2402
  "5": "NATIVE_EVENT_HANDLER",
2195
2403
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2341,7 +2549,7 @@ function nextTick(fn) {
2341
2549
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2342
2550
  }
2343
2551
  function findInsertionIndex(id) {
2344
- let start = flushIndex + 1;
2552
+ let start = isFlushing ? flushIndex + 1 : 0;
2345
2553
  let end = queue.length;
2346
2554
  while (start < end) {
2347
2555
  const middle = start + end >>> 1;
@@ -2357,15 +2565,13 @@ function findInsertionIndex(id) {
2357
2565
  }
2358
2566
  function queueJob(job) {
2359
2567
  if (!(job.flags & 1)) {
2360
- if (job.id == null) {
2361
- queue.push(job);
2362
- } else if (
2363
- // fast path when the job id is larger than the tail
2364
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2365
- ) {
2568
+ const jobId = getId(job);
2569
+ const lastJob = queue[queue.length - 1];
2570
+ if (!lastJob || // fast path when the job id is larger than the tail
2571
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2366
2572
  queue.push(job);
2367
2573
  } else {
2368
- queue.splice(findInsertionIndex(job.id), 0, job);
2574
+ queue.splice(findInsertionIndex(jobId), 0, job);
2369
2575
  }
2370
2576
  if (!(job.flags & 4)) {
2371
2577
  job.flags |= 1;
@@ -2379,12 +2585,6 @@ function queueFlush() {
2379
2585
  currentFlushPromise = resolvedPromise.then(flushJobs);
2380
2586
  }
2381
2587
  }
2382
- function invalidateJob(job) {
2383
- const i = queue.indexOf(job);
2384
- if (i > flushIndex) {
2385
- queue.splice(i, 1);
2386
- }
2387
- }
2388
2588
  function queuePostFlushCb(cb) {
2389
2589
  if (!isArray(cb)) {
2390
2590
  if (activePostFlushCbs && cb.id === -1) {
@@ -2446,24 +2646,13 @@ function flushPostFlushCbs(seen) {
2446
2646
  postFlushIndex = 0;
2447
2647
  }
2448
2648
  }
2449
- const getId = (job) => job.id == null ? Infinity : job.id;
2450
- const comparator = (a, b) => {
2451
- const diff = getId(a) - getId(b);
2452
- if (diff === 0) {
2453
- const isAPre = a.flags & 2;
2454
- const isBPre = b.flags & 2;
2455
- if (isAPre && !isBPre) return -1;
2456
- if (isBPre && !isAPre) return 1;
2457
- }
2458
- return diff;
2459
- };
2649
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2460
2650
  function flushJobs(seen) {
2461
2651
  isFlushPending = false;
2462
2652
  isFlushing = true;
2463
2653
  {
2464
2654
  seen = seen || /* @__PURE__ */ new Map();
2465
2655
  }
2466
- queue.sort(comparator);
2467
2656
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2468
2657
  try {
2469
2658
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -3104,7 +3293,7 @@ function on(instance, event, fn) {
3104
3293
  function once(instance, event, fn) {
3105
3294
  const wrapped = (...args) => {
3106
3295
  off(instance, event, wrapped);
3107
- fn.call(instance.proxy, ...args);
3296
+ fn.apply(instance.proxy, args);
3108
3297
  };
3109
3298
  wrapped.fn = fn;
3110
3299
  on(instance, event, wrapped);
@@ -6638,23 +6827,43 @@ function callHook$1(hook, instance, type) {
6638
6827
  );
6639
6828
  }
6640
6829
  function createWatcher(raw, ctx, publicThis, key) {
6641
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6830
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
6831
+ const options = {};
6832
+ {
6833
+ const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
6834
+ const newValue = getter();
6835
+ if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
6836
+ options.deep = true;
6837
+ }
6838
+ const baseGetter = getter;
6839
+ getter = () => {
6840
+ const val = baseGetter();
6841
+ if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
6842
+ traverse(val);
6843
+ }
6844
+ return val;
6845
+ };
6846
+ }
6642
6847
  if (isString(raw)) {
6643
6848
  const handler = ctx[raw];
6644
6849
  if (isFunction(handler)) {
6645
- watch(getter, handler);
6850
+ {
6851
+ watch(getter, handler, options);
6852
+ }
6646
6853
  } else {
6647
6854
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
6648
6855
  }
6649
6856
  } else if (isFunction(raw)) {
6650
- watch(getter, raw.bind(publicThis));
6857
+ {
6858
+ watch(getter, raw.bind(publicThis), options);
6859
+ }
6651
6860
  } else if (isObject(raw)) {
6652
6861
  if (isArray(raw)) {
6653
6862
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
6654
6863
  } else {
6655
6864
  const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
6656
6865
  if (isFunction(handler)) {
6657
- watch(getter, handler, raw);
6866
+ watch(getter, handler, extend(raw, options) );
6658
6867
  } else {
6659
6868
  warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
6660
6869
  }
@@ -6878,7 +7087,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6878
7087
  return vm;
6879
7088
  }
6880
7089
  }
6881
- Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
7090
+ Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
6882
7091
  Vue.config = singletonApp.config;
6883
7092
  Vue.use = (plugin, ...options) => {
6884
7093
  if (plugin && isFunction(plugin.install)) {
@@ -7210,7 +7419,7 @@ function defineReactive(obj, key, val) {
7210
7419
  if (isArray(val)) {
7211
7420
  methodsToPatch.forEach((m) => {
7212
7421
  val[m] = (...args) => {
7213
- Array.prototype[m].call(reactiveVal, ...args);
7422
+ Array.prototype[m].apply(reactiveVal, args);
7214
7423
  };
7215
7424
  });
7216
7425
  } else {
@@ -8405,7 +8614,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8405
8614
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
8406
8615
  subTree = filterSingleRoot(subTree.children) || subTree;
8407
8616
  }
8408
- if (vnode === subTree) {
8617
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
8409
8618
  const parentVNode = parentComponent.vnode;
8410
8619
  setScopeId(
8411
8620
  el,
@@ -8735,7 +8944,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8735
8944
  return;
8736
8945
  } else {
8737
8946
  instance.next = n2;
8738
- invalidateJob(instance.update);
8739
8947
  instance.update();
8740
8948
  }
8741
8949
  } else {
@@ -9659,7 +9867,6 @@ function watchSyncEffect(effect, options) {
9659
9867
  extend({}, options, { flush: "sync" })
9660
9868
  );
9661
9869
  }
9662
- const INITIAL_WATCHER_VALUE = {};
9663
9870
  function watch(source, cb, options) {
9664
9871
  if (!isFunction(cb)) {
9665
9872
  warn$1(
@@ -9668,21 +9875,8 @@ function watch(source, cb, options) {
9668
9875
  }
9669
9876
  return doWatch(source, cb, options);
9670
9877
  }
9671
- function doWatch(source, cb, {
9672
- immediate,
9673
- deep,
9674
- flush,
9675
- once,
9676
- onTrack,
9677
- onTrigger
9678
- } = EMPTY_OBJ) {
9679
- if (cb && once) {
9680
- const _cb = cb;
9681
- cb = (...args) => {
9682
- _cb(...args);
9683
- watchHandle();
9684
- };
9685
- }
9878
+ function doWatch(source, cb, options = EMPTY_OBJ) {
9879
+ const { immediate, deep, flush, once } = options;
9686
9880
  if (!cb) {
9687
9881
  if (immediate !== void 0) {
9688
9882
  warn$1(
@@ -9700,173 +9894,53 @@ function doWatch(source, cb, {
9700
9894
  );
9701
9895
  }
9702
9896
  }
9703
- const warnInvalidSource = (s) => {
9704
- warn$1(
9705
- `Invalid watch source: `,
9706
- s,
9707
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
9708
- );
9709
- };
9710
- const instance = currentInstance;
9711
- const reactiveGetter = (source2) => {
9712
- if (deep) return source2;
9713
- if (isShallow(source2) || deep === false || deep === 0)
9714
- return traverse(source2, 1);
9715
- return traverse(source2);
9716
- };
9717
- let getter;
9718
- let forceTrigger = false;
9719
- let isMultiSource = false;
9720
- if (isRef(source)) {
9721
- getter = () => source.value;
9722
- forceTrigger = isShallow(source);
9723
- } else if (isReactive(source)) {
9724
- getter = () => reactiveGetter(source);
9725
- forceTrigger = true;
9726
- } else if (isArray(source)) {
9727
- isMultiSource = true;
9728
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
9729
- getter = () => source.map((s) => {
9730
- if (isRef(s)) {
9731
- return s.value;
9732
- } else if (isReactive(s)) {
9733
- return reactiveGetter(s);
9734
- } else if (isFunction(s)) {
9735
- return callWithErrorHandling(s, instance, 2);
9736
- } else {
9737
- warnInvalidSource(s);
9738
- }
9739
- });
9740
- } else if (isFunction(source)) {
9741
- if (cb) {
9742
- getter = () => callWithErrorHandling(source, instance, 2);
9743
- } else {
9744
- getter = () => {
9745
- if (cleanup) {
9746
- cleanup();
9747
- }
9748
- return callWithAsyncErrorHandling(
9749
- source,
9750
- instance,
9751
- 3,
9752
- [onCleanup]
9753
- );
9754
- };
9755
- }
9756
- } else {
9757
- getter = NOOP;
9758
- warnInvalidSource(source);
9759
- }
9760
- if (cb && !deep) {
9761
- const baseGetter = getter;
9762
- getter = () => {
9763
- const val = baseGetter();
9764
- if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
9765
- traverse(val);
9766
- }
9767
- return val;
9768
- };
9769
- }
9770
- if (cb && deep) {
9771
- const baseGetter = getter;
9772
- const depth = deep === true ? Infinity : deep;
9773
- getter = () => traverse(baseGetter(), depth);
9774
- }
9775
- let cleanup;
9776
- let onCleanup = (fn) => {
9777
- cleanup = effect.onStop = () => {
9778
- callWithErrorHandling(fn, instance, 4);
9779
- cleanup = effect.onStop = void 0;
9780
- };
9781
- };
9897
+ const baseWatchOptions = extend({}, options);
9898
+ baseWatchOptions.onWarn = warn$1;
9782
9899
  let ssrCleanup;
9783
9900
  if (isInSSRComponentSetup) {
9784
- onCleanup = NOOP;
9785
- if (!cb) {
9786
- getter();
9787
- } else if (immediate) {
9788
- callWithAsyncErrorHandling(cb, instance, 3, [
9789
- getter(),
9790
- isMultiSource ? [] : void 0,
9791
- onCleanup
9792
- ]);
9793
- }
9794
9901
  if (flush === "sync") {
9795
9902
  const ctx = useSSRContext();
9796
9903
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9904
+ } else if (!cb || immediate) {
9905
+ baseWatchOptions.once = true;
9797
9906
  } else {
9798
- const watchHandle2 = () => {
9907
+ return {
9908
+ stop: NOOP,
9909
+ resume: NOOP,
9910
+ pause: NOOP
9799
9911
  };
9800
- watchHandle2.stop = NOOP;
9801
- watchHandle2.resume = NOOP;
9802
- watchHandle2.pause = NOOP;
9803
- return watchHandle2;
9804
9912
  }
9805
9913
  }
9806
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
9807
- const job = (immediateFirstRun) => {
9808
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
9809
- return;
9810
- }
9811
- if (cb) {
9812
- const newValue = effect.run();
9813
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
9814
- if (cleanup) {
9815
- cleanup();
9816
- }
9817
- callWithAsyncErrorHandling(cb, instance, 3, [
9818
- newValue,
9819
- // pass undefined as the old value when it's changed for the first time
9820
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
9821
- onCleanup
9822
- ]);
9823
- oldValue = newValue;
9914
+ const instance = currentInstance;
9915
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
9916
+ let isPre = false;
9917
+ if (flush === "post") {
9918
+ baseWatchOptions.scheduler = (job) => {
9919
+ queuePostRenderEffect(job, instance && instance.suspense);
9920
+ };
9921
+ } else if (flush !== "sync") {
9922
+ isPre = true;
9923
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
9924
+ if (isFirstRun) {
9925
+ job();
9926
+ } else {
9927
+ queueJob(job);
9824
9928
  }
9825
- } else {
9826
- effect.run();
9827
- }
9828
- };
9829
- if (cb) job.flags |= 4;
9830
- const effect = new ReactiveEffect(getter);
9831
- let scheduler;
9832
- if (flush === "sync") {
9833
- scheduler = job;
9834
- } else if (flush === "post") {
9835
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
9836
- } else {
9837
- job.flags |= 2;
9838
- if (instance) job.id = instance.uid;
9839
- scheduler = () => queueJob(job);
9929
+ };
9840
9930
  }
9841
- effect.scheduler = scheduler;
9842
- const scope = getCurrentScope();
9843
- const watchHandle = () => {
9844
- effect.stop();
9845
- if (scope) {
9846
- remove(scope.effects, effect);
9931
+ baseWatchOptions.augmentJob = (job) => {
9932
+ if (cb) {
9933
+ job.flags |= 4;
9847
9934
  }
9848
- };
9849
- watchHandle.pause = effect.pause.bind(effect);
9850
- watchHandle.resume = effect.resume.bind(effect);
9851
- watchHandle.stop = watchHandle;
9852
- {
9853
- effect.onTrack = onTrack;
9854
- effect.onTrigger = onTrigger;
9855
- }
9856
- if (cb) {
9857
- if (immediate) {
9858
- job(true);
9859
- } else {
9860
- oldValue = effect.run();
9935
+ if (isPre) {
9936
+ job.flags |= 2;
9937
+ if (instance) {
9938
+ job.id = instance.uid;
9939
+ job.i = instance;
9940
+ }
9861
9941
  }
9862
- } else if (flush === "post") {
9863
- queuePostRenderEffect(
9864
- effect.run.bind(effect),
9865
- instance && instance.suspense
9866
- );
9867
- } else {
9868
- effect.run();
9869
- }
9942
+ };
9943
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
9870
9944
  if (ssrCleanup) ssrCleanup.push(watchHandle);
9871
9945
  return watchHandle;
9872
9946
  }
@@ -9895,38 +9969,6 @@ function createPathGetter(ctx, path) {
9895
9969
  return cur;
9896
9970
  };
9897
9971
  }
9898
- function traverse(value, depth = Infinity, seen) {
9899
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
9900
- return value;
9901
- }
9902
- seen = seen || /* @__PURE__ */ new Set();
9903
- if (seen.has(value)) {
9904
- return value;
9905
- }
9906
- seen.add(value);
9907
- depth--;
9908
- if (isRef(value)) {
9909
- traverse(value.value, depth, seen);
9910
- } else if (isArray(value)) {
9911
- for (let i = 0; i < value.length; i++) {
9912
- traverse(value[i], depth, seen);
9913
- }
9914
- } else if (isSet(value) || isMap(value)) {
9915
- value.forEach((v) => {
9916
- traverse(v, depth, seen);
9917
- });
9918
- } else if (isPlainObject(value)) {
9919
- for (const key in value) {
9920
- traverse(value[key], depth, seen);
9921
- }
9922
- for (const key of Object.getOwnPropertySymbols(value)) {
9923
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
9924
- traverse(value[key], depth, seen);
9925
- }
9926
- }
9927
- }
9928
- return value;
9929
- }
9930
9972
 
9931
9973
  function useModel(props, name, options = EMPTY_OBJ) {
9932
9974
  const i = getCurrentInstance();
@@ -12181,7 +12223,7 @@ function isMemoSame(cached, memo) {
12181
12223
  return true;
12182
12224
  }
12183
12225
 
12184
- const version = "3.5.0-beta.2";
12226
+ const version = "3.5.0-beta.3";
12185
12227
  const warn = warn$1 ;
12186
12228
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12187
12229
  const devtools = devtools$1 ;
@@ -14157,6 +14199,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14157
14199
  effectScope: effectScope,
14158
14200
  getCurrentInstance: getCurrentInstance,
14159
14201
  getCurrentScope: getCurrentScope,
14202
+ getCurrentWatcher: getCurrentWatcher,
14160
14203
  getTransitionRawChildren: getTransitionRawChildren,
14161
14204
  guardReactiveProps: guardReactiveProps,
14162
14205
  h: h,
@@ -14199,6 +14242,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
14199
14242
  onServerPrefetch: onServerPrefetch,
14200
14243
  onUnmounted: onUnmounted,
14201
14244
  onUpdated: onUpdated,
14245
+ onWatcherCleanup: onWatcherCleanup,
14202
14246
  openBlock: openBlock,
14203
14247
  popScopeId: popScopeId,
14204
14248
  provide: provide,
@@ -15762,6 +15806,9 @@ const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || no
15762
15806
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
15763
15807
  function isReferenced(node, parent, grandparent) {
15764
15808
  switch (parent.type) {
15809
+ // yes: PARENT[NODE]
15810
+ // yes: NODE.child
15811
+ // no: parent.NODE
15765
15812
  case "MemberExpression":
15766
15813
  case "OptionalMemberExpression":
15767
15814
  if (parent.property === node) {
@@ -15770,12 +15817,23 @@ function isReferenced(node, parent, grandparent) {
15770
15817
  return parent.object === node;
15771
15818
  case "JSXMemberExpression":
15772
15819
  return parent.object === node;
15820
+ // no: let NODE = init;
15821
+ // yes: let id = NODE;
15773
15822
  case "VariableDeclarator":
15774
15823
  return parent.init === node;
15824
+ // yes: () => NODE
15825
+ // no: (NODE) => {}
15775
15826
  case "ArrowFunctionExpression":
15776
15827
  return parent.body === node;
15828
+ // no: class { #NODE; }
15829
+ // no: class { get #NODE() {} }
15830
+ // no: class { #NODE() {} }
15831
+ // no: class { fn() { return this.#NODE; } }
15777
15832
  case "PrivateName":
15778
15833
  return false;
15834
+ // no: class { NODE() {} }
15835
+ // yes: class { [NODE]() {} }
15836
+ // no: class { foo(NODE) {} }
15779
15837
  case "ClassMethod":
15780
15838
  case "ClassPrivateMethod":
15781
15839
  case "ObjectMethod":
@@ -15783,11 +15841,18 @@ function isReferenced(node, parent, grandparent) {
15783
15841
  return !!parent.computed;
15784
15842
  }
15785
15843
  return false;
15844
+ // yes: { [NODE]: "" }
15845
+ // no: { NODE: "" }
15846
+ // depends: { NODE }
15847
+ // depends: { key: NODE }
15786
15848
  case "ObjectProperty":
15787
15849
  if (parent.key === node) {
15788
15850
  return !!parent.computed;
15789
15851
  }
15790
15852
  return !grandparent;
15853
+ // no: class { NODE = value; }
15854
+ // yes: class { [NODE] = value; }
15855
+ // yes: class { key = NODE; }
15791
15856
  case "ClassProperty":
15792
15857
  if (parent.key === node) {
15793
15858
  return !!parent.computed;
@@ -15795,47 +15860,80 @@ function isReferenced(node, parent, grandparent) {
15795
15860
  return true;
15796
15861
  case "ClassPrivateProperty":
15797
15862
  return parent.key !== node;
15863
+ // no: class NODE {}
15864
+ // yes: class Foo extends NODE {}
15798
15865
  case "ClassDeclaration":
15799
15866
  case "ClassExpression":
15800
15867
  return parent.superClass === node;
15868
+ // yes: left = NODE;
15869
+ // no: NODE = right;
15801
15870
  case "AssignmentExpression":
15802
15871
  return parent.right === node;
15872
+ // no: [NODE = foo] = [];
15873
+ // yes: [foo = NODE] = [];
15803
15874
  case "AssignmentPattern":
15804
15875
  return parent.right === node;
15876
+ // no: NODE: for (;;) {}
15805
15877
  case "LabeledStatement":
15806
15878
  return false;
15879
+ // no: try {} catch (NODE) {}
15807
15880
  case "CatchClause":
15808
15881
  return false;
15882
+ // no: function foo(...NODE) {}
15809
15883
  case "RestElement":
15810
15884
  return false;
15811
15885
  case "BreakStatement":
15812
15886
  case "ContinueStatement":
15813
15887
  return false;
15888
+ // no: function NODE() {}
15889
+ // no: function foo(NODE) {}
15814
15890
  case "FunctionDeclaration":
15815
15891
  case "FunctionExpression":
15816
15892
  return false;
15893
+ // no: export NODE from "foo";
15894
+ // no: export * as NODE from "foo";
15817
15895
  case "ExportNamespaceSpecifier":
15818
15896
  case "ExportDefaultSpecifier":
15819
15897
  return false;
15898
+ // no: export { foo as NODE };
15899
+ // yes: export { NODE as foo };
15900
+ // no: export { NODE as foo } from "foo";
15820
15901
  case "ExportSpecifier":
15821
15902
  return parent.local === node;
15903
+ // no: import NODE from "foo";
15904
+ // no: import * as NODE from "foo";
15905
+ // no: import { NODE as foo } from "foo";
15906
+ // no: import { foo as NODE } from "foo";
15907
+ // no: import NODE from "bar";
15822
15908
  case "ImportDefaultSpecifier":
15823
15909
  case "ImportNamespaceSpecifier":
15824
15910
  case "ImportSpecifier":
15825
15911
  return false;
15912
+ // no: import "foo" assert { NODE: "json" }
15826
15913
  case "ImportAttribute":
15827
15914
  return false;
15915
+ // no: <div NODE="foo" />
15828
15916
  case "JSXAttribute":
15829
15917
  return false;
15918
+ // no: [NODE] = [];
15919
+ // no: ({ NODE }) = [];
15830
15920
  case "ObjectPattern":
15831
15921
  case "ArrayPattern":
15832
15922
  return false;
15923
+ // no: new.NODE
15924
+ // no: NODE.target
15833
15925
  case "MetaProperty":
15834
15926
  return false;
15927
+ // yes: type X = { someProperty: NODE }
15928
+ // no: type X = { NODE: OtherType }
15835
15929
  case "ObjectTypeProperty":
15836
15930
  return parent.key !== node;
15931
+ // yes: enum X { Foo = NODE }
15932
+ // no: enum X { NODE }
15837
15933
  case "TSEnumMember":
15838
15934
  return parent.id !== node;
15935
+ // yes: { [NODE]: value }
15936
+ // no: { NODE: value }
15839
15937
  case "TSPropertySignature":
15840
15938
  if (parent.key === node) {
15841
15939
  return !!parent.computed;
@@ -16428,7 +16526,9 @@ const tokenizer = new Tokenizer(stack, {
16428
16526
  case 17:
16429
16527
  case 18:
16430
16528
  case 19:
16529
+ // "
16431
16530
  case 20:
16531
+ // '
16432
16532
  case 21:
16433
16533
  emitError(9, end);
16434
16534
  break;
@@ -17454,6 +17554,7 @@ function traverseNode(node, context) {
17454
17554
  context.helper(TO_DISPLAY_STRING);
17455
17555
  }
17456
17556
  break;
17557
+ // for container types, further traverse downwards
17457
17558
  case 9:
17458
17559
  for (let i2 = 0; i2 < node.branches.length; i2++) {
17459
17560
  traverseNode(node.branches[i2], context);
@@ -17934,6 +18035,7 @@ function genNode(node, context) {
17934
18035
  case 21:
17935
18036
  genNodeList(node.body, context, true, false);
17936
18037
  break;
18038
+ // SSR only types
17937
18039
  case 22:
17938
18040
  genTemplateLiteral(node, context);
17939
18041
  break;
@@ -17949,6 +18051,7 @@ function genNode(node, context) {
17949
18051
  case 26:
17950
18052
  genReturnStatement(node, context);
17951
18053
  break;
18054
+ /* istanbul ignore next */
17952
18055
  case 10:
17953
18056
  break;
17954
18057
  default:
@@ -20364,27 +20467,35 @@ function parseFilter(node, context) {
20364
20467
  case 34:
20365
20468
  inDouble = true;
20366
20469
  break;
20470
+ // "
20367
20471
  case 39:
20368
20472
  inSingle = true;
20369
20473
  break;
20474
+ // '
20370
20475
  case 96:
20371
20476
  inTemplateString = true;
20372
20477
  break;
20478
+ // `
20373
20479
  case 40:
20374
20480
  paren++;
20375
20481
  break;
20482
+ // (
20376
20483
  case 41:
20377
20484
  paren--;
20378
20485
  break;
20486
+ // )
20379
20487
  case 91:
20380
20488
  square++;
20381
20489
  break;
20490
+ // [
20382
20491
  case 93:
20383
20492
  square--;
20384
20493
  break;
20494
+ // ]
20385
20495
  case 123:
20386
20496
  curly++;
20387
20497
  break;
20498
+ // {
20388
20499
  case 125:
20389
20500
  curly--;
20390
20501
  break;