@vue/runtime-dom 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/runtime-dom v3.5.0-beta.2
2
+ * @vue/runtime-dom v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.0-beta.2
2
+ * @vue/runtime-dom v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,4 +1,4 @@
1
- import { BaseTransitionProps, FunctionalComponent, ObjectDirective, Directive, App, SetupContext, RenderFunction, ComponentOptions, ComponentObjectPropsOptions, EmitsOptions, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentInjectOptions, SlotsType, Component, ComponentProvideOptions, ExtractPropTypes, EmitsToProps, ComponentOptionsBase, CreateComponentPublicInstanceWithMixins, DefineComponent, ComponentCustomElementInterface, CreateAppFunction, ConcreteComponent, VNodeRef, RootRenderFunction, RootHydrateFunction } from '@vue/runtime-core';
1
+ import { BaseTransitionProps, FunctionalComponent, ObjectDirective, Directive, App, SetupContext, RenderFunction, ComponentOptions, ComponentObjectPropsOptions, EmitsOptions, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentInjectOptions, SlotsType, Component, ComponentProvideOptions, ExtractPropTypes, EmitsToProps, ComponentOptionsBase, CreateComponentPublicInstanceWithMixins, ComponentPublicInstance, DefineComponent, ComponentCustomElementInterface, CreateAppFunction, ConcreteComponent, VNodeRef, RootRenderFunction, RootHydrateFunction } from '@vue/runtime-core';
2
2
  export * from '@vue/runtime-core';
3
3
  import * as CSS from 'csstype';
4
4
 
@@ -103,7 +103,9 @@ export declare function defineCustomElement<RuntimePropsOptions extends Componen
103
103
  props?: (RuntimePropsOptions & ThisType<void>) | PropsKeys[];
104
104
  } & ComponentOptionsBase<ResolvedProps, SetupBindings, Data, Computed, Methods, Mixin, Extends, RuntimeEmitsOptions, EmitsKeys, {}, // Defaults
105
105
  InjectOptions, InjectKeys, Slots, LocalComponents, Directives, Exposed, Provide> & ThisType<CreateComponentPublicInstanceWithMixins<Readonly<ResolvedProps>, SetupBindings, Data, Computed, Methods, Mixin, Extends, RuntimeEmitsOptions, EmitsKeys, {}, false, InjectOptions, Slots, LocalComponents, Directives, Exposed>>, extraOptions?: CustomElementOptions): VueElementConstructor<ResolvedProps>;
106
- export declare function defineCustomElement<T extends DefineComponent<any, any, any, any>>(options: T, extraOptions?: CustomElementOptions): VueElementConstructor<T extends DefineComponent<infer P, any, any, any> ? ExtractPropTypes<P> : unknown>;
106
+ export declare function defineCustomElement<T extends {
107
+ new (...args: any[]): ComponentPublicInstance<any>;
108
+ }>(options: T, extraOptions?: CustomElementOptions): VueElementConstructor<T extends DefineComponent<infer P, any, any, any> ? P : unknown>;
107
109
  /*! #__NO_SIDE_EFFECTS__ */
108
110
  export declare const defineSSRCustomElement: typeof defineCustomElement;
109
111
  declare const BaseClass: typeof HTMLElement;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.0-beta.2
2
+ * @vue/runtime-dom v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1070,14 +1070,14 @@ function iterator(self, method, wrapValue) {
1070
1070
  const arrayProto = Array.prototype;
1071
1071
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1072
1072
  const arr = shallowReadArray(self);
1073
- let methodFn;
1074
- if ((methodFn = arr[method]) !== arrayProto[method]) {
1075
- return methodFn.apply(arr, args);
1073
+ const needsWrap = arr !== self && !isShallow(self);
1074
+ const methodFn = arr[method];
1075
+ if (methodFn !== arrayProto[method]) {
1076
+ const result2 = methodFn.apply(arr, args);
1077
+ return needsWrap ? toReactive(result2) : result2;
1076
1078
  }
1077
- let needsWrap = false;
1078
1079
  let wrappedFn = fn;
1079
1080
  if (arr !== self) {
1080
- needsWrap = !isShallow(self);
1081
1081
  if (needsWrap) {
1082
1082
  wrappedFn = function(item, index) {
1083
1083
  return fn.call(this, toReactive(item), index, self);
@@ -1939,6 +1939,220 @@ const TriggerOpTypes = {
1939
1939
  "CLEAR": "clear"
1940
1940
  };
1941
1941
 
1942
+ const INITIAL_WATCHER_VALUE = {};
1943
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1944
+ let activeWatcher = void 0;
1945
+ function getCurrentWatcher() {
1946
+ return activeWatcher;
1947
+ }
1948
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1949
+ if (owner) {
1950
+ let cleanups = cleanupMap.get(owner);
1951
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1952
+ cleanups.push(cleanupFn);
1953
+ } else if (!failSilently) {
1954
+ warn$2(
1955
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1956
+ );
1957
+ }
1958
+ }
1959
+ function watch$1(source, cb, options = EMPTY_OBJ) {
1960
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1961
+ const warnInvalidSource = (s) => {
1962
+ (options.onWarn || warn$2)(
1963
+ `Invalid watch source: `,
1964
+ s,
1965
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1966
+ );
1967
+ };
1968
+ const reactiveGetter = (source2) => {
1969
+ if (deep) return source2;
1970
+ if (isShallow(source2) || deep === false || deep === 0)
1971
+ return traverse(source2, 1);
1972
+ return traverse(source2);
1973
+ };
1974
+ let effect;
1975
+ let getter;
1976
+ let cleanup;
1977
+ let boundCleanup;
1978
+ let forceTrigger = false;
1979
+ let isMultiSource = false;
1980
+ if (isRef(source)) {
1981
+ getter = () => source.value;
1982
+ forceTrigger = isShallow(source);
1983
+ } else if (isReactive(source)) {
1984
+ getter = () => reactiveGetter(source);
1985
+ forceTrigger = true;
1986
+ } else if (isArray(source)) {
1987
+ isMultiSource = true;
1988
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1989
+ getter = () => source.map((s) => {
1990
+ if (isRef(s)) {
1991
+ return s.value;
1992
+ } else if (isReactive(s)) {
1993
+ return reactiveGetter(s);
1994
+ } else if (isFunction(s)) {
1995
+ return call ? call(s, 2) : s();
1996
+ } else {
1997
+ warnInvalidSource(s);
1998
+ }
1999
+ });
2000
+ } else if (isFunction(source)) {
2001
+ if (cb) {
2002
+ getter = call ? () => call(source, 2) : source;
2003
+ } else {
2004
+ getter = () => {
2005
+ if (cleanup) {
2006
+ pauseTracking();
2007
+ try {
2008
+ cleanup();
2009
+ } finally {
2010
+ resetTracking();
2011
+ }
2012
+ }
2013
+ const currentEffect = activeWatcher;
2014
+ activeWatcher = effect;
2015
+ try {
2016
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2017
+ } finally {
2018
+ activeWatcher = currentEffect;
2019
+ }
2020
+ };
2021
+ }
2022
+ } else {
2023
+ getter = NOOP;
2024
+ warnInvalidSource(source);
2025
+ }
2026
+ if (cb && deep) {
2027
+ const baseGetter = getter;
2028
+ const depth = deep === true ? Infinity : deep;
2029
+ getter = () => traverse(baseGetter(), depth);
2030
+ }
2031
+ if (once) {
2032
+ if (cb) {
2033
+ const _cb = cb;
2034
+ cb = (...args) => {
2035
+ _cb(...args);
2036
+ effect.stop();
2037
+ };
2038
+ } else {
2039
+ const _getter = getter;
2040
+ getter = () => {
2041
+ _getter();
2042
+ effect.stop();
2043
+ };
2044
+ }
2045
+ }
2046
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2047
+ const job = (immediateFirstRun) => {
2048
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
2049
+ return;
2050
+ }
2051
+ if (cb) {
2052
+ const newValue = effect.run();
2053
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2054
+ if (cleanup) {
2055
+ cleanup();
2056
+ }
2057
+ const currentWatcher = activeWatcher;
2058
+ activeWatcher = effect;
2059
+ try {
2060
+ const args = [
2061
+ newValue,
2062
+ // pass undefined as the old value when it's changed for the first time
2063
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2064
+ boundCleanup
2065
+ ];
2066
+ call ? call(cb, 3, args) : (
2067
+ // @ts-expect-error
2068
+ cb(...args)
2069
+ );
2070
+ oldValue = newValue;
2071
+ } finally {
2072
+ activeWatcher = currentWatcher;
2073
+ }
2074
+ }
2075
+ } else {
2076
+ effect.run();
2077
+ }
2078
+ };
2079
+ if (augmentJob) {
2080
+ augmentJob(job);
2081
+ }
2082
+ effect = new ReactiveEffect(getter);
2083
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
2084
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
2085
+ cleanup = effect.onStop = () => {
2086
+ const cleanups = cleanupMap.get(effect);
2087
+ if (cleanups) {
2088
+ if (call) {
2089
+ call(cleanups, 4);
2090
+ } else {
2091
+ for (const cleanup2 of cleanups) cleanup2();
2092
+ }
2093
+ cleanupMap.delete(effect);
2094
+ }
2095
+ };
2096
+ {
2097
+ effect.onTrack = options.onTrack;
2098
+ effect.onTrigger = options.onTrigger;
2099
+ }
2100
+ if (cb) {
2101
+ if (immediate) {
2102
+ job(true);
2103
+ } else {
2104
+ oldValue = effect.run();
2105
+ }
2106
+ } else if (scheduler) {
2107
+ scheduler(job.bind(null, true), true);
2108
+ } else {
2109
+ effect.run();
2110
+ }
2111
+ const scope = getCurrentScope();
2112
+ const watchHandle = () => {
2113
+ effect.stop();
2114
+ if (scope) {
2115
+ remove(scope.effects, effect);
2116
+ }
2117
+ };
2118
+ watchHandle.pause = effect.pause.bind(effect);
2119
+ watchHandle.resume = effect.resume.bind(effect);
2120
+ watchHandle.stop = watchHandle;
2121
+ return watchHandle;
2122
+ }
2123
+ function traverse(value, depth = Infinity, seen) {
2124
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2125
+ return value;
2126
+ }
2127
+ seen = seen || /* @__PURE__ */ new Set();
2128
+ if (seen.has(value)) {
2129
+ return value;
2130
+ }
2131
+ seen.add(value);
2132
+ depth--;
2133
+ if (isRef(value)) {
2134
+ traverse(value.value, depth, seen);
2135
+ } else if (isArray(value)) {
2136
+ for (let i = 0; i < value.length; i++) {
2137
+ traverse(value[i], depth, seen);
2138
+ }
2139
+ } else if (isSet(value) || isMap(value)) {
2140
+ value.forEach((v) => {
2141
+ traverse(v, depth, seen);
2142
+ });
2143
+ } else if (isPlainObject(value)) {
2144
+ for (const key in value) {
2145
+ traverse(value[key], depth, seen);
2146
+ }
2147
+ for (const key of Object.getOwnPropertySymbols(value)) {
2148
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2149
+ traverse(value[key], depth, seen);
2150
+ }
2151
+ }
2152
+ }
2153
+ return value;
2154
+ }
2155
+
1942
2156
  const stack = [];
1943
2157
  function pushWarningContext(vnode) {
1944
2158
  stack.push(vnode);
@@ -2066,12 +2280,6 @@ const ErrorCodes = {
2066
2280
  "0": "SETUP_FUNCTION",
2067
2281
  "RENDER_FUNCTION": 1,
2068
2282
  "1": "RENDER_FUNCTION",
2069
- "WATCH_GETTER": 2,
2070
- "2": "WATCH_GETTER",
2071
- "WATCH_CALLBACK": 3,
2072
- "3": "WATCH_CALLBACK",
2073
- "WATCH_CLEANUP": 4,
2074
- "4": "WATCH_CLEANUP",
2075
2283
  "NATIVE_EVENT_HANDLER": 5,
2076
2284
  "5": "NATIVE_EVENT_HANDLER",
2077
2285
  "COMPONENT_EVENT_HANDLER": 6,
@@ -2223,7 +2431,7 @@ function nextTick(fn) {
2223
2431
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
2224
2432
  }
2225
2433
  function findInsertionIndex(id) {
2226
- let start = flushIndex + 1;
2434
+ let start = isFlushing ? flushIndex + 1 : 0;
2227
2435
  let end = queue.length;
2228
2436
  while (start < end) {
2229
2437
  const middle = start + end >>> 1;
@@ -2239,15 +2447,13 @@ function findInsertionIndex(id) {
2239
2447
  }
2240
2448
  function queueJob(job) {
2241
2449
  if (!(job.flags & 1)) {
2242
- if (job.id == null) {
2243
- queue.push(job);
2244
- } else if (
2245
- // fast path when the job id is larger than the tail
2246
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
2247
- ) {
2450
+ const jobId = getId(job);
2451
+ const lastJob = queue[queue.length - 1];
2452
+ if (!lastJob || // fast path when the job id is larger than the tail
2453
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
2248
2454
  queue.push(job);
2249
2455
  } else {
2250
- queue.splice(findInsertionIndex(job.id), 0, job);
2456
+ queue.splice(findInsertionIndex(jobId), 0, job);
2251
2457
  }
2252
2458
  if (!(job.flags & 4)) {
2253
2459
  job.flags |= 1;
@@ -2261,12 +2467,6 @@ function queueFlush() {
2261
2467
  currentFlushPromise = resolvedPromise.then(flushJobs);
2262
2468
  }
2263
2469
  }
2264
- function invalidateJob(job) {
2265
- const i = queue.indexOf(job);
2266
- if (i > flushIndex) {
2267
- queue.splice(i, 1);
2268
- }
2269
- }
2270
2470
  function queuePostFlushCb(cb) {
2271
2471
  if (!isArray(cb)) {
2272
2472
  if (activePostFlushCbs && cb.id === -1) {
@@ -2328,24 +2528,13 @@ function flushPostFlushCbs(seen) {
2328
2528
  postFlushIndex = 0;
2329
2529
  }
2330
2530
  }
2331
- const getId = (job) => job.id == null ? Infinity : job.id;
2332
- const comparator = (a, b) => {
2333
- const diff = getId(a) - getId(b);
2334
- if (diff === 0) {
2335
- const isAPre = a.flags & 2;
2336
- const isBPre = b.flags & 2;
2337
- if (isAPre && !isBPre) return -1;
2338
- if (isBPre && !isAPre) return 1;
2339
- }
2340
- return diff;
2341
- };
2531
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
2342
2532
  function flushJobs(seen) {
2343
2533
  isFlushPending = false;
2344
2534
  isFlushing = true;
2345
2535
  {
2346
2536
  seen = seen || /* @__PURE__ */ new Map();
2347
2537
  }
2348
- queue.sort(comparator);
2349
2538
  const check = (job) => checkRecursiveUpdates(seen, job) ;
2350
2539
  try {
2351
2540
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
@@ -5436,16 +5625,20 @@ function callHook$1(hook, instance, type) {
5436
5625
  );
5437
5626
  }
5438
5627
  function createWatcher(raw, ctx, publicThis, key) {
5439
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5628
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
5440
5629
  if (isString(raw)) {
5441
5630
  const handler = ctx[raw];
5442
5631
  if (isFunction(handler)) {
5443
- watch(getter, handler);
5632
+ {
5633
+ watch(getter, handler);
5634
+ }
5444
5635
  } else {
5445
5636
  warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5446
5637
  }
5447
5638
  } else if (isFunction(raw)) {
5448
- watch(getter, raw.bind(publicThis));
5639
+ {
5640
+ watch(getter, raw.bind(publicThis));
5641
+ }
5449
5642
  } else if (isObject(raw)) {
5450
5643
  if (isArray(raw)) {
5451
5644
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -6683,7 +6876,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6683
6876
  if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
6684
6877
  subTree = filterSingleRoot(subTree.children) || subTree;
6685
6878
  }
6686
- if (vnode === subTree) {
6879
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
6687
6880
  const parentVNode = parentComponent.vnode;
6688
6881
  setScopeId(
6689
6882
  el,
@@ -7012,7 +7205,6 @@ function baseCreateRenderer(options, createHydrationFns) {
7012
7205
  return;
7013
7206
  } else {
7014
7207
  instance.next = n2;
7015
- invalidateJob(instance.update);
7016
7208
  instance.update();
7017
7209
  }
7018
7210
  } else {
@@ -7903,7 +8095,6 @@ function watchSyncEffect(effect, options) {
7903
8095
  extend({}, options, { flush: "sync" })
7904
8096
  );
7905
8097
  }
7906
- const INITIAL_WATCHER_VALUE = {};
7907
8098
  function watch(source, cb, options) {
7908
8099
  if (!isFunction(cb)) {
7909
8100
  warn$1(
@@ -7912,21 +8103,8 @@ function watch(source, cb, options) {
7912
8103
  }
7913
8104
  return doWatch(source, cb, options);
7914
8105
  }
7915
- function doWatch(source, cb, {
7916
- immediate,
7917
- deep,
7918
- flush,
7919
- once,
7920
- onTrack,
7921
- onTrigger
7922
- } = EMPTY_OBJ) {
7923
- if (cb && once) {
7924
- const _cb = cb;
7925
- cb = (...args) => {
7926
- _cb(...args);
7927
- watchHandle();
7928
- };
7929
- }
8106
+ function doWatch(source, cb, options = EMPTY_OBJ) {
8107
+ const { immediate, deep, flush, once } = options;
7930
8108
  if (!cb) {
7931
8109
  if (immediate !== void 0) {
7932
8110
  warn$1(
@@ -7944,163 +8122,53 @@ function doWatch(source, cb, {
7944
8122
  );
7945
8123
  }
7946
8124
  }
7947
- const warnInvalidSource = (s) => {
7948
- warn$1(
7949
- `Invalid watch source: `,
7950
- s,
7951
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
7952
- );
7953
- };
7954
- const instance = currentInstance;
7955
- const reactiveGetter = (source2) => {
7956
- if (deep) return source2;
7957
- if (isShallow(source2) || deep === false || deep === 0)
7958
- return traverse(source2, 1);
7959
- return traverse(source2);
7960
- };
7961
- let getter;
7962
- let forceTrigger = false;
7963
- let isMultiSource = false;
7964
- if (isRef(source)) {
7965
- getter = () => source.value;
7966
- forceTrigger = isShallow(source);
7967
- } else if (isReactive(source)) {
7968
- getter = () => reactiveGetter(source);
7969
- forceTrigger = true;
7970
- } else if (isArray(source)) {
7971
- isMultiSource = true;
7972
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
7973
- getter = () => source.map((s) => {
7974
- if (isRef(s)) {
7975
- return s.value;
7976
- } else if (isReactive(s)) {
7977
- return reactiveGetter(s);
7978
- } else if (isFunction(s)) {
7979
- return callWithErrorHandling(s, instance, 2);
7980
- } else {
7981
- warnInvalidSource(s);
7982
- }
7983
- });
7984
- } else if (isFunction(source)) {
7985
- if (cb) {
7986
- getter = () => callWithErrorHandling(source, instance, 2);
7987
- } else {
7988
- getter = () => {
7989
- if (cleanup) {
7990
- cleanup();
7991
- }
7992
- return callWithAsyncErrorHandling(
7993
- source,
7994
- instance,
7995
- 3,
7996
- [onCleanup]
7997
- );
7998
- };
7999
- }
8000
- } else {
8001
- getter = NOOP;
8002
- warnInvalidSource(source);
8003
- }
8004
- if (cb && deep) {
8005
- const baseGetter = getter;
8006
- const depth = deep === true ? Infinity : deep;
8007
- getter = () => traverse(baseGetter(), depth);
8008
- }
8009
- let cleanup;
8010
- let onCleanup = (fn) => {
8011
- cleanup = effect.onStop = () => {
8012
- callWithErrorHandling(fn, instance, 4);
8013
- cleanup = effect.onStop = void 0;
8014
- };
8015
- };
8125
+ const baseWatchOptions = extend({}, options);
8126
+ baseWatchOptions.onWarn = warn$1;
8016
8127
  let ssrCleanup;
8017
8128
  if (isInSSRComponentSetup) {
8018
- onCleanup = NOOP;
8019
- if (!cb) {
8020
- getter();
8021
- } else if (immediate) {
8022
- callWithAsyncErrorHandling(cb, instance, 3, [
8023
- getter(),
8024
- isMultiSource ? [] : void 0,
8025
- onCleanup
8026
- ]);
8027
- }
8028
8129
  if (flush === "sync") {
8029
8130
  const ctx = useSSRContext();
8030
8131
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
8132
+ } else if (!cb || immediate) {
8133
+ baseWatchOptions.once = true;
8031
8134
  } else {
8032
- const watchHandle2 = () => {
8135
+ return {
8136
+ stop: NOOP,
8137
+ resume: NOOP,
8138
+ pause: NOOP
8033
8139
  };
8034
- watchHandle2.stop = NOOP;
8035
- watchHandle2.resume = NOOP;
8036
- watchHandle2.pause = NOOP;
8037
- return watchHandle2;
8038
8140
  }
8039
8141
  }
8040
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
8041
- const job = (immediateFirstRun) => {
8042
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
8043
- return;
8044
- }
8045
- if (cb) {
8046
- const newValue = effect.run();
8047
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
8048
- if (cleanup) {
8049
- cleanup();
8050
- }
8051
- callWithAsyncErrorHandling(cb, instance, 3, [
8052
- newValue,
8053
- // pass undefined as the old value when it's changed for the first time
8054
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
8055
- onCleanup
8056
- ]);
8057
- oldValue = newValue;
8142
+ const instance = currentInstance;
8143
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8144
+ let isPre = false;
8145
+ if (flush === "post") {
8146
+ baseWatchOptions.scheduler = (job) => {
8147
+ queuePostRenderEffect(job, instance && instance.suspense);
8148
+ };
8149
+ } else if (flush !== "sync") {
8150
+ isPre = true;
8151
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
8152
+ if (isFirstRun) {
8153
+ job();
8154
+ } else {
8155
+ queueJob(job);
8058
8156
  }
8059
- } else {
8060
- effect.run();
8061
- }
8062
- };
8063
- if (cb) job.flags |= 4;
8064
- const effect = new ReactiveEffect(getter);
8065
- let scheduler;
8066
- if (flush === "sync") {
8067
- scheduler = job;
8068
- } else if (flush === "post") {
8069
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
8070
- } else {
8071
- job.flags |= 2;
8072
- if (instance) job.id = instance.uid;
8073
- scheduler = () => queueJob(job);
8157
+ };
8074
8158
  }
8075
- effect.scheduler = scheduler;
8076
- const scope = getCurrentScope();
8077
- const watchHandle = () => {
8078
- effect.stop();
8079
- if (scope) {
8080
- remove(scope.effects, effect);
8159
+ baseWatchOptions.augmentJob = (job) => {
8160
+ if (cb) {
8161
+ job.flags |= 4;
8081
8162
  }
8082
- };
8083
- watchHandle.pause = effect.pause.bind(effect);
8084
- watchHandle.resume = effect.resume.bind(effect);
8085
- watchHandle.stop = watchHandle;
8086
- {
8087
- effect.onTrack = onTrack;
8088
- effect.onTrigger = onTrigger;
8089
- }
8090
- if (cb) {
8091
- if (immediate) {
8092
- job(true);
8093
- } else {
8094
- oldValue = effect.run();
8163
+ if (isPre) {
8164
+ job.flags |= 2;
8165
+ if (instance) {
8166
+ job.id = instance.uid;
8167
+ job.i = instance;
8168
+ }
8095
8169
  }
8096
- } else if (flush === "post") {
8097
- queuePostRenderEffect(
8098
- effect.run.bind(effect),
8099
- instance && instance.suspense
8100
- );
8101
- } else {
8102
- effect.run();
8103
- }
8170
+ };
8171
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
8104
8172
  if (ssrCleanup) ssrCleanup.push(watchHandle);
8105
8173
  return watchHandle;
8106
8174
  }
@@ -8129,38 +8197,6 @@ function createPathGetter(ctx, path) {
8129
8197
  return cur;
8130
8198
  };
8131
8199
  }
8132
- function traverse(value, depth = Infinity, seen) {
8133
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
8134
- return value;
8135
- }
8136
- seen = seen || /* @__PURE__ */ new Set();
8137
- if (seen.has(value)) {
8138
- return value;
8139
- }
8140
- seen.add(value);
8141
- depth--;
8142
- if (isRef(value)) {
8143
- traverse(value.value, depth, seen);
8144
- } else if (isArray(value)) {
8145
- for (let i = 0; i < value.length; i++) {
8146
- traverse(value[i], depth, seen);
8147
- }
8148
- } else if (isSet(value) || isMap(value)) {
8149
- value.forEach((v) => {
8150
- traverse(v, depth, seen);
8151
- });
8152
- } else if (isPlainObject(value)) {
8153
- for (const key in value) {
8154
- traverse(value[key], depth, seen);
8155
- }
8156
- for (const key of Object.getOwnPropertySymbols(value)) {
8157
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
8158
- traverse(value[key], depth, seen);
8159
- }
8160
- }
8161
- }
8162
- return value;
8163
- }
8164
8200
 
8165
8201
  function useModel(props, name, options = EMPTY_OBJ) {
8166
8202
  const i = getCurrentInstance();
@@ -10308,7 +10344,7 @@ function isMemoSame(cached, memo) {
10308
10344
  return true;
10309
10345
  }
10310
10346
 
10311
- const version = "3.5.0-beta.2";
10347
+ const version = "3.5.0-beta.3";
10312
10348
  const warn = warn$1 ;
10313
10349
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10314
10350
  const devtools = devtools$1 ;
@@ -12147,4 +12183,4 @@ const initDirectivesForSSR = () => {
12147
12183
  }
12148
12184
  } ;
12149
12185
 
12150
- 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, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, 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 };
12186
+ 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, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, 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 };