@vue/runtime-core 3.5.0-beta.2 → 3.5.0-rc.1

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-core v3.5.0-beta.2
2
+ * @vue/runtime-core v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -19,12 +19,6 @@ const ErrorCodes = {
19
19
  "0": "SETUP_FUNCTION",
20
20
  "RENDER_FUNCTION": 1,
21
21
  "1": "RENDER_FUNCTION",
22
- "WATCH_GETTER": 2,
23
- "2": "WATCH_GETTER",
24
- "WATCH_CALLBACK": 3,
25
- "3": "WATCH_CALLBACK",
26
- "WATCH_CLEANUP": 4,
27
- "4": "WATCH_CLEANUP",
28
22
  "NATIVE_EVENT_HANDLER": 5,
29
23
  "5": "NATIVE_EVENT_HANDLER",
30
24
  "COMPONENT_EVENT_HANDLER": 6,
@@ -161,7 +155,7 @@ function nextTick(fn) {
161
155
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
162
156
  }
163
157
  function findInsertionIndex(id) {
164
- let start = flushIndex + 1;
158
+ let start = isFlushing ? flushIndex + 1 : 0;
165
159
  let end = queue.length;
166
160
  while (start < end) {
167
161
  const middle = start + end >>> 1;
@@ -177,15 +171,13 @@ function findInsertionIndex(id) {
177
171
  }
178
172
  function queueJob(job) {
179
173
  if (!(job.flags & 1)) {
180
- if (job.id == null) {
181
- queue.push(job);
182
- } else if (
183
- // fast path when the job id is larger than the tail
184
- !(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
185
- ) {
174
+ const jobId = getId(job);
175
+ const lastJob = queue[queue.length - 1];
176
+ if (!lastJob || // fast path when the job id is larger than the tail
177
+ !(job.flags & 2) && jobId >= getId(lastJob)) {
186
178
  queue.push(job);
187
179
  } else {
188
- queue.splice(findInsertionIndex(job.id), 0, job);
180
+ queue.splice(findInsertionIndex(jobId), 0, job);
189
181
  }
190
182
  if (!(job.flags & 4)) {
191
183
  job.flags |= 1;
@@ -199,12 +191,6 @@ function queueFlush() {
199
191
  currentFlushPromise = resolvedPromise.then(flushJobs);
200
192
  }
201
193
  }
202
- function invalidateJob(job) {
203
- const i = queue.indexOf(job);
204
- if (i > flushIndex) {
205
- queue.splice(i, 1);
206
- }
207
- }
208
194
  function queuePostFlushCb(cb) {
209
195
  if (!shared.isArray(cb)) {
210
196
  if (activePostFlushCbs && cb.id === -1) {
@@ -254,21 +240,10 @@ function flushPostFlushCbs(seen) {
254
240
  postFlushIndex = 0;
255
241
  }
256
242
  }
257
- const getId = (job) => job.id == null ? Infinity : job.id;
258
- const comparator = (a, b) => {
259
- const diff = getId(a) - getId(b);
260
- if (diff === 0) {
261
- const isAPre = a.flags & 2;
262
- const isBPre = b.flags & 2;
263
- if (isAPre && !isBPre) return -1;
264
- if (isBPre && !isAPre) return 1;
265
- }
266
- return diff;
267
- };
243
+ const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
268
244
  function flushJobs(seen) {
269
245
  isFlushPending = false;
270
246
  isFlushing = true;
271
- queue.sort(comparator);
272
247
  try {
273
248
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
274
249
  const job = queue[flushIndex];
@@ -352,7 +327,7 @@ function withDirectives(vnode, directives) {
352
327
  };
353
328
  }
354
329
  if (dir.deep) {
355
- traverse(value);
330
+ reactivity.traverse(value);
356
331
  }
357
332
  bindings.push({
358
333
  dir,
@@ -1013,7 +988,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1013
988
  // @__NO_SIDE_EFFECTS__
1014
989
  function defineComponent(options, extraOptions) {
1015
990
  return shared.isFunction(options) ? (
1016
- // #8326: extend call and options.name access are considered side-effects
991
+ // #8236: extend call and options.name access are considered side-effects
1017
992
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1018
993
  /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1019
994
  ) : options;
@@ -1941,6 +1916,7 @@ const KeepAliveImpl = {
1941
1916
  );
1942
1917
  const { include, exclude, max } = props;
1943
1918
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1919
+ vnode.shapeFlag &= ~256;
1944
1920
  current = vnode;
1945
1921
  return rawVNode;
1946
1922
  }
@@ -2642,14 +2618,18 @@ function callHook(hook, instance, type) {
2642
2618
  );
2643
2619
  }
2644
2620
  function createWatcher(raw, ctx, publicThis, key) {
2645
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
2621
+ let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
2646
2622
  if (shared.isString(raw)) {
2647
2623
  const handler = ctx[raw];
2648
2624
  if (shared.isFunction(handler)) {
2649
- watch(getter, handler);
2625
+ {
2626
+ watch(getter, handler);
2627
+ }
2650
2628
  }
2651
2629
  } else if (shared.isFunction(raw)) {
2652
- watch(getter, raw.bind(publicThis));
2630
+ {
2631
+ watch(getter, raw.bind(publicThis));
2632
+ }
2653
2633
  } else if (shared.isObject(raw)) {
2654
2634
  if (shared.isArray(raw)) {
2655
2635
  raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
@@ -3583,7 +3563,7 @@ function baseCreateRenderer(options, createHydrationFns) {
3583
3563
  }
3584
3564
  if (parentComponent) {
3585
3565
  let subTree = parentComponent.subTree;
3586
- if (vnode === subTree) {
3566
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
3587
3567
  const parentVNode = parentComponent.vnode;
3588
3568
  setScopeId(
3589
3569
  el,
@@ -3881,7 +3861,6 @@ function baseCreateRenderer(options, createHydrationFns) {
3881
3861
  return;
3882
3862
  } else {
3883
3863
  instance.next = n2;
3884
- invalidateJob(instance.update);
3885
3864
  instance.update();
3886
3865
  }
3887
3866
  } else {
@@ -4691,168 +4670,57 @@ function watchSyncEffect(effect, options) {
4691
4670
  { flush: "sync" }
4692
4671
  );
4693
4672
  }
4694
- const INITIAL_WATCHER_VALUE = {};
4695
4673
  function watch(source, cb, options) {
4696
4674
  return doWatch(source, cb, options);
4697
4675
  }
4698
- function doWatch(source, cb, {
4699
- immediate,
4700
- deep,
4701
- flush,
4702
- once,
4703
- onTrack,
4704
- onTrigger
4705
- } = shared.EMPTY_OBJ) {
4706
- if (cb && once) {
4707
- const _cb = cb;
4708
- cb = (...args) => {
4709
- _cb(...args);
4710
- watchHandle();
4711
- };
4712
- }
4713
- const instance = currentInstance;
4714
- const reactiveGetter = (source2) => {
4715
- if (deep) return source2;
4716
- if (reactivity.isShallow(source2) || deep === false || deep === 0)
4717
- return traverse(source2, 1);
4718
- return traverse(source2);
4719
- };
4720
- let getter;
4721
- let forceTrigger = false;
4722
- let isMultiSource = false;
4723
- if (reactivity.isRef(source)) {
4724
- getter = () => source.value;
4725
- forceTrigger = reactivity.isShallow(source);
4726
- } else if (reactivity.isReactive(source)) {
4727
- getter = () => reactiveGetter(source);
4728
- forceTrigger = true;
4729
- } else if (shared.isArray(source)) {
4730
- isMultiSource = true;
4731
- forceTrigger = source.some((s) => reactivity.isReactive(s) || reactivity.isShallow(s));
4732
- getter = () => source.map((s) => {
4733
- if (reactivity.isRef(s)) {
4734
- return s.value;
4735
- } else if (reactivity.isReactive(s)) {
4736
- return reactiveGetter(s);
4737
- } else if (shared.isFunction(s)) {
4738
- return callWithErrorHandling(s, instance, 2);
4739
- } else ;
4740
- });
4741
- } else if (shared.isFunction(source)) {
4742
- if (cb) {
4743
- getter = () => callWithErrorHandling(source, instance, 2);
4744
- } else {
4745
- getter = () => {
4746
- if (cleanup) {
4747
- cleanup();
4748
- }
4749
- return callWithAsyncErrorHandling(
4750
- source,
4751
- instance,
4752
- 3,
4753
- [onCleanup]
4754
- );
4755
- };
4756
- }
4757
- } else {
4758
- getter = shared.NOOP;
4759
- }
4760
- if (cb && deep) {
4761
- const baseGetter = getter;
4762
- const depth = deep === true ? Infinity : deep;
4763
- getter = () => traverse(baseGetter(), depth);
4764
- }
4765
- let cleanup;
4766
- let onCleanup = (fn) => {
4767
- cleanup = effect.onStop = () => {
4768
- callWithErrorHandling(fn, instance, 4);
4769
- cleanup = effect.onStop = void 0;
4770
- };
4771
- };
4676
+ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
4677
+ const { immediate, deep, flush, once } = options;
4678
+ const baseWatchOptions = shared.extend({}, options);
4772
4679
  let ssrCleanup;
4773
4680
  if (isInSSRComponentSetup) {
4774
- onCleanup = shared.NOOP;
4775
- if (!cb) {
4776
- getter();
4777
- } else if (immediate) {
4778
- callWithAsyncErrorHandling(cb, instance, 3, [
4779
- getter(),
4780
- isMultiSource ? [] : void 0,
4781
- onCleanup
4782
- ]);
4783
- }
4784
4681
  if (flush === "sync") {
4785
4682
  const ctx = useSSRContext();
4786
4683
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
4684
+ } else if (!cb || immediate) {
4685
+ baseWatchOptions.once = true;
4787
4686
  } else {
4788
- const watchHandle2 = () => {
4687
+ return {
4688
+ stop: shared.NOOP,
4689
+ resume: shared.NOOP,
4690
+ pause: shared.NOOP
4789
4691
  };
4790
- watchHandle2.stop = shared.NOOP;
4791
- watchHandle2.resume = shared.NOOP;
4792
- watchHandle2.pause = shared.NOOP;
4793
- return watchHandle2;
4794
4692
  }
4795
4693
  }
4796
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4797
- const job = (immediateFirstRun) => {
4798
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4799
- return;
4800
- }
4801
- if (cb) {
4802
- const newValue = effect.run();
4803
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue)) || false) {
4804
- if (cleanup) {
4805
- cleanup();
4806
- }
4807
- callWithAsyncErrorHandling(cb, instance, 3, [
4808
- newValue,
4809
- // pass undefined as the old value when it's changed for the first time
4810
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
4811
- onCleanup
4812
- ]);
4813
- oldValue = newValue;
4694
+ const instance = currentInstance;
4695
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
4696
+ let isPre = false;
4697
+ if (flush === "post") {
4698
+ baseWatchOptions.scheduler = (job) => {
4699
+ queuePostRenderEffect(job, instance && instance.suspense);
4700
+ };
4701
+ } else if (flush !== "sync") {
4702
+ isPre = true;
4703
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
4704
+ if (isFirstRun) {
4705
+ job();
4706
+ } else {
4707
+ queueJob(job);
4814
4708
  }
4815
- } else {
4816
- effect.run();
4817
- }
4818
- };
4819
- if (cb) job.flags |= 4;
4820
- const effect = new reactivity.ReactiveEffect(getter);
4821
- let scheduler;
4822
- if (flush === "sync") {
4823
- scheduler = job;
4824
- } else if (flush === "post") {
4825
- scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4826
- } else {
4827
- job.flags |= 2;
4828
- if (instance) job.id = instance.uid;
4829
- scheduler = () => queueJob(job);
4709
+ };
4830
4710
  }
4831
- effect.scheduler = scheduler;
4832
- const scope = reactivity.getCurrentScope();
4833
- const watchHandle = () => {
4834
- effect.stop();
4835
- if (scope) {
4836
- shared.remove(scope.effects, effect);
4711
+ baseWatchOptions.augmentJob = (job) => {
4712
+ if (cb) {
4713
+ job.flags |= 4;
4837
4714
  }
4838
- };
4839
- watchHandle.pause = effect.pause.bind(effect);
4840
- watchHandle.resume = effect.resume.bind(effect);
4841
- watchHandle.stop = watchHandle;
4842
- if (cb) {
4843
- if (immediate) {
4844
- job(true);
4845
- } else {
4846
- oldValue = effect.run();
4715
+ if (isPre) {
4716
+ job.flags |= 2;
4717
+ if (instance) {
4718
+ job.id = instance.uid;
4719
+ job.i = instance;
4720
+ }
4847
4721
  }
4848
- } else if (flush === "post") {
4849
- queuePostRenderEffect(
4850
- effect.run.bind(effect),
4851
- instance && instance.suspense
4852
- );
4853
- } else {
4854
- effect.run();
4855
- }
4722
+ };
4723
+ const watchHandle = reactivity.watch(source, cb, baseWatchOptions);
4856
4724
  if (ssrCleanup) ssrCleanup.push(watchHandle);
4857
4725
  return watchHandle;
4858
4726
  }
@@ -4881,38 +4749,6 @@ function createPathGetter(ctx, path) {
4881
4749
  return cur;
4882
4750
  };
4883
4751
  }
4884
- function traverse(value, depth = Infinity, seen) {
4885
- if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
4886
- return value;
4887
- }
4888
- seen = seen || /* @__PURE__ */ new Set();
4889
- if (seen.has(value)) {
4890
- return value;
4891
- }
4892
- seen.add(value);
4893
- depth--;
4894
- if (reactivity.isRef(value)) {
4895
- traverse(value.value, depth, seen);
4896
- } else if (shared.isArray(value)) {
4897
- for (let i = 0; i < value.length; i++) {
4898
- traverse(value[i], depth, seen);
4899
- }
4900
- } else if (shared.isSet(value) || shared.isMap(value)) {
4901
- value.forEach((v) => {
4902
- traverse(v, depth, seen);
4903
- });
4904
- } else if (shared.isPlainObject(value)) {
4905
- for (const key in value) {
4906
- traverse(value[key], depth, seen);
4907
- }
4908
- for (const key of Object.getOwnPropertySymbols(value)) {
4909
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
4910
- traverse(value[key], depth, seen);
4911
- }
4912
- }
4913
- }
4914
- return value;
4915
- }
4916
4752
 
4917
4753
  function useModel(props, name, options = shared.EMPTY_OBJ) {
4918
4754
  const i = getCurrentInstance();
@@ -6540,7 +6376,7 @@ function isMemoSame(cached, memo) {
6540
6376
  return true;
6541
6377
  }
6542
6378
 
6543
- const version = "3.5.0-beta.2";
6379
+ const version = "3.5.0-rc.1";
6544
6380
  const warn$1 = shared.NOOP;
6545
6381
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6546
6382
  const devtools = void 0;
@@ -6568,6 +6404,7 @@ exports.customRef = reactivity.customRef;
6568
6404
  exports.effect = reactivity.effect;
6569
6405
  exports.effectScope = reactivity.effectScope;
6570
6406
  exports.getCurrentScope = reactivity.getCurrentScope;
6407
+ exports.getCurrentWatcher = reactivity.getCurrentWatcher;
6571
6408
  exports.isProxy = reactivity.isProxy;
6572
6409
  exports.isReactive = reactivity.isReactive;
6573
6410
  exports.isReadonly = reactivity.isReadonly;
@@ -6575,6 +6412,7 @@ exports.isRef = reactivity.isRef;
6575
6412
  exports.isShallow = reactivity.isShallow;
6576
6413
  exports.markRaw = reactivity.markRaw;
6577
6414
  exports.onScopeDispose = reactivity.onScopeDispose;
6415
+ exports.onWatcherCleanup = reactivity.onWatcherCleanup;
6578
6416
  exports.proxyRefs = reactivity.proxyRefs;
6579
6417
  exports.reactive = reactivity.reactive;
6580
6418
  exports.readonly = reactivity.readonly;
@@ -1,5 +1,5 @@
1
- import { computed as computed$1, Ref, ShallowUnwrapRef, UnwrapNestedRefs, DebuggerEvent, ComputedGetter, WritableComputedOptions, ReactiveEffect, ComputedRef, DebuggerOptions, ReactiveMarker, ShallowRef, reactive } from '@vue/reactivity';
2
- export { ComputedGetter, ComputedRef, ComputedSetter, CustomRefFactory, DebuggerEvent, DebuggerEventExtraInfo, DebuggerOptions, DeepReadonly, EffectScheduler, EffectScope, MaybeRef, MaybeRefOrGetter, Raw, Reactive, ReactiveEffect, ReactiveEffectOptions, ReactiveEffectRunner, ReactiveFlags, Ref, ShallowReactive, ShallowRef, ShallowUnwrapRef, ToRef, ToRefs, TrackOpTypes, TriggerOpTypes, UnwrapNestedRefs, UnwrapRef, WritableComputedOptions, WritableComputedRef, customRef, effect, effectScope, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
1
+ import { computed as computed$1, Ref, OnCleanup, WatchStopHandle, ShallowUnwrapRef, UnwrapNestedRefs, DebuggerEvent, ComputedGetter, WritableComputedOptions, WatchCallback, ReactiveEffect, DebuggerOptions, WatchEffect, WatchHandle, WatchSource, ReactiveMarker, ShallowRef, WatchErrorCodes, reactive } from '@vue/reactivity';
2
+ export { ComputedGetter, ComputedRef, ComputedSetter, CustomRefFactory, DebuggerEvent, DebuggerEventExtraInfo, DebuggerOptions, DeepReadonly, EffectScheduler, EffectScope, MaybeRef, MaybeRefOrGetter, Raw, Reactive, ReactiveEffect, ReactiveEffectOptions, ReactiveEffectRunner, ReactiveFlags, Ref, ShallowReactive, ShallowRef, ShallowUnwrapRef, ToRef, ToRefs, TrackOpTypes, TriggerOpTypes, UnwrapNestedRefs, UnwrapRef, WatchCallback, WatchEffect, WatchHandle, WatchSource, WatchStopHandle, WritableComputedOptions, WritableComputedRef, customRef, effect, effectScope, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, onWatcherCleanup, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
3
3
  import { IfAny, Prettify, Awaited, LooseRequired, UnionToIntersection, OverloadParameters } from '@vue/shared';
4
4
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
5
5
 
@@ -334,7 +334,7 @@ type InferDefaults<T> = {
334
334
  type NativeType = null | number | string | boolean | symbol | Function;
335
335
  type InferDefault<P, T> = ((props: P) => T & {}) | (T extends NativeType ? T : never);
336
336
  type PropsWithDefaults<T, Defaults extends InferDefaults<T>, BKeys extends keyof T> = Readonly<MappedOmit<T, keyof Defaults>> & {
337
- readonly [K in keyof Defaults]-?: K extends keyof T ? Defaults[K] extends undefined ? IfAny<Defaults[K], NotUndefined<T[K]>, T[K]> : NotUndefined<T[K]> : never;
337
+ readonly [K in keyof Defaults as K extends keyof T ? K : never]-?: K extends keyof T ? Defaults[K] extends undefined ? IfAny<Defaults[K], NotUndefined<T[K]>, T[K]> : NotUndefined<T[K]> : never;
338
338
  } & {
339
339
  readonly [K in BKeys]-?: K extends keyof Defaults ? Defaults[K] extends undefined ? boolean | undefined : boolean : boolean;
340
340
  };
@@ -367,7 +367,7 @@ export type EmitsOptions = ObjectEmitsOptions | string[];
367
367
  export type EmitsToProps<T extends EmitsOptions | ComponentTypeEmits> = T extends string[] ? {
368
368
  [K in `on${Capitalize<T[number]>}`]?: (...args: any[]) => any;
369
369
  } : T extends ObjectEmitsOptions ? {
370
- [K in `on${Capitalize<string & keyof T>}`]?: K extends `on${infer C}` ? (...args: T[Uncapitalize<C>] extends (...args: infer P) => any ? P : T[Uncapitalize<C>] extends null ? any[] : never) => any : never;
370
+ [K in string & keyof T as `on${Capitalize<K>}`]?: (...args: T[K] extends (...args: infer P) => any ? P : T[K] extends null ? any[] : never) => any;
371
371
  } : {};
372
372
  type TypeEmitsToOptions<T extends ComponentTypeEmits> = T extends Record<string, any[]> ? {
373
373
  [K in keyof T]: T[K] extends [...args: infer Args] ? (...args: Args) => any : () => any;
@@ -1334,7 +1334,7 @@ export interface ComponentCustomProps {
1334
1334
  * }
1335
1335
  * ```
1336
1336
  */
1337
- export interface GlobalDirectives extends Record<string, Directive> {
1337
+ export interface GlobalDirectives {
1338
1338
  }
1339
1339
  /**
1340
1340
  * For globally defined Components
@@ -1351,7 +1351,7 @@ export interface GlobalDirectives extends Record<string, Directive> {
1351
1351
  * }
1352
1352
  * ```
1353
1353
  */
1354
- export interface GlobalComponents extends Record<string, Component> {
1354
+ export interface GlobalComponents {
1355
1355
  Teleport: DefineComponent<TeleportProps>;
1356
1356
  Suspense: DefineComponent<SuspenseProps>;
1357
1357
  KeepAlive: DefineComponent<KeepAliveProps>;
@@ -1463,31 +1463,21 @@ export declare const isRuntimeOnly: () => boolean;
1463
1463
  export interface ComponentCustomElementInterface {
1464
1464
  }
1465
1465
 
1466
- export type WatchEffect = (onCleanup: OnCleanup) => void;
1467
- export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T);
1468
- export type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onCleanup: OnCleanup) => any;
1469
1466
  type MaybeUndefined<T, I> = I extends true ? T | undefined : T;
1470
1467
  type MapSources<T, Immediate> = {
1471
1468
  [K in keyof T]: T[K] extends WatchSource<infer V> ? MaybeUndefined<V, Immediate> : T[K] extends object ? MaybeUndefined<T[K], Immediate> : never;
1472
1469
  };
1473
- type OnCleanup = (cleanupFn: () => void) => void;
1474
- export interface WatchOptionsBase extends DebuggerOptions {
1470
+ export interface WatchEffectOptions extends DebuggerOptions {
1475
1471
  flush?: 'pre' | 'post' | 'sync';
1476
1472
  }
1477
- export interface WatchOptions<Immediate = boolean> extends WatchOptionsBase {
1473
+ export interface WatchOptions<Immediate = boolean> extends WatchEffectOptions {
1478
1474
  immediate?: Immediate;
1479
1475
  deep?: boolean | number;
1480
1476
  once?: boolean;
1481
1477
  }
1482
- export type WatchStopHandle = () => void;
1483
- export interface WatchHandle extends WatchStopHandle {
1484
- pause: () => void;
1485
- resume: () => void;
1486
- stop: () => void;
1487
- }
1488
- export declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchHandle;
1489
- export declare function watchPostEffect(effect: WatchEffect, options?: DebuggerOptions): WatchStopHandle;
1490
- export declare function watchSyncEffect(effect: WatchEffect, options?: DebuggerOptions): WatchStopHandle;
1478
+ export declare function watchEffect(effect: WatchEffect, options?: WatchEffectOptions): WatchHandle;
1479
+ export declare function watchPostEffect(effect: WatchEffect, options?: DebuggerOptions): WatchHandle;
1480
+ export declare function watchSyncEffect(effect: WatchEffect, options?: DebuggerOptions): WatchHandle;
1491
1481
  export type MultiWatchSources = (WatchSource<unknown> | object)[];
1492
1482
  export declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, MaybeUndefined<T, Immediate>>, options?: WatchOptions<Immediate>): WatchHandle;
1493
1483
  export declare function watch<T extends Readonly<MultiWatchSources>, Immediate extends Readonly<boolean> = false>(sources: readonly [...T] | T, cb: [T] extends [ReactiveMarker] ? WatchCallback<T, MaybeUndefined<T, Immediate>> : WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchHandle;
@@ -1583,9 +1573,6 @@ declare function warn$1(msg: string, ...args: any[]): void;
1583
1573
  export declare enum ErrorCodes {
1584
1574
  SETUP_FUNCTION = 0,
1585
1575
  RENDER_FUNCTION = 1,
1586
- WATCH_GETTER = 2,
1587
- WATCH_CALLBACK = 3,
1588
- WATCH_CLEANUP = 4,
1589
1576
  NATIVE_EVENT_HANDLER = 5,
1590
1577
  COMPONENT_EVENT_HANDLER = 6,
1591
1578
  VNODE_HOOK = 7,
@@ -1599,7 +1586,7 @@ export declare enum ErrorCodes {
1599
1586
  COMPONENT_UPDATE = 15,
1600
1587
  APP_UNMOUNT_CLEANUP = 16
1601
1588
  }
1602
- type ErrorTypes = LifecycleHooks | ErrorCodes;
1589
+ type ErrorTypes = LifecycleHooks | ErrorCodes | WatchErrorCodes;
1603
1590
  export declare function callWithErrorHandling(fn: Function, instance: ComponentInternalInstance | null | undefined, type: ErrorTypes, args?: unknown[]): any;
1604
1591
  export declare function callWithAsyncErrorHandling(fn: Function | Function[], instance: ComponentInternalInstance | null, type: ErrorTypes, args?: unknown[]): any;
1605
1592
  export declare function handleError(err: unknown, instance: ComponentInternalInstance | null | undefined, type: ErrorTypes, throwInDev?: boolean): void;
@@ -1807,7 +1794,7 @@ declare module '@vue/reactivity' {
1807
1794
 
1808
1795
  export declare const DeprecationTypes: typeof DeprecationTypes$1;
1809
1796
 
1810
- export { createBaseVNode as createElementVNode, };
1797
+ export { type WatchEffectOptions as WatchOptionsBase, createBaseVNode as createElementVNode, };
1811
1798
  // Note: this file is auto concatenated to the end of the bundled d.ts during
1812
1799
  // build.
1813
1800