@vueuse/shared 8.4.2 → 8.7.0

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/index.cjs CHANGED
@@ -325,6 +325,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
325
325
  });
326
326
  }
327
327
 
328
+ var _a;
328
329
  const isClient = typeof window !== "undefined";
329
330
  const isDef = (val) => typeof val !== "undefined";
330
331
  const assert = (condition, ...infos) => {
@@ -348,6 +349,7 @@ const rand = (min, max) => {
348
349
  max = Math.floor(max);
349
350
  return Math.floor(Math.random() * (max - min + 1)) + min;
350
351
  };
352
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
351
353
 
352
354
  function createFilterWrapper(filter, fn) {
353
355
  function wrapper(...args) {
@@ -393,7 +395,7 @@ function debounceFilter(ms, options = {}) {
393
395
  function throttleFilter(ms, trailing = true, leading = true) {
394
396
  let lastExec = 0;
395
397
  let timer;
396
- let preventLeading = !leading;
398
+ let isLeading = true;
397
399
  const clear = () => {
398
400
  if (timer) {
399
401
  clearTimeout(timer);
@@ -408,24 +410,20 @@ function throttleFilter(ms, trailing = true, leading = true) {
408
410
  lastExec = Date.now();
409
411
  return invoke();
410
412
  }
411
- if (elapsed > duration) {
413
+ if (elapsed > duration && (leading || !isLeading)) {
412
414
  lastExec = Date.now();
413
- if (preventLeading)
414
- preventLeading = false;
415
- else
416
- invoke();
417
- }
418
- if (trailing) {
415
+ invoke();
416
+ } else if (trailing) {
419
417
  timer = setTimeout(() => {
420
418
  lastExec = Date.now();
421
- if (!leading)
422
- preventLeading = true;
419
+ isLeading = true;
423
420
  clear();
424
421
  invoke();
425
422
  }, duration);
426
423
  }
427
424
  if (!leading && !timer)
428
- timer = setTimeout(() => preventLeading = true, duration);
425
+ timer = setTimeout(() => isLeading = true, duration);
426
+ isLeading = false;
429
427
  };
430
428
  return filter;
431
429
  }
@@ -490,7 +488,7 @@ function increaseWithUnit(target, delta) {
490
488
  function objectPick(obj, keys, omitUndefined = false) {
491
489
  return keys.reduce((n, k) => {
492
490
  if (k in obj) {
493
- if (!omitUndefined || !obj[k] === void 0)
491
+ if (!omitUndefined || obj[k] !== void 0)
494
492
  n[k] = obj[k];
495
493
  }
496
494
  return n;
@@ -667,7 +665,9 @@ function toRefs(objectRef) {
667
665
  copy[key] = v;
668
666
  objectRef.value = copy;
669
667
  } else {
670
- objectRef.value = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
668
+ const newObject = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
669
+ Object.setPrototypeOf(newObject, objectRef.value);
670
+ objectRef.value = newObject;
671
671
  }
672
672
  }
673
673
  }));
@@ -709,9 +709,9 @@ function until(r) {
709
709
  let stop = null;
710
710
  const watcher = new Promise((resolve) => {
711
711
  stop = vueDemi.watch(r, (v) => {
712
- if (condition(v) === !isNot) {
712
+ if (condition(v) !== isNot) {
713
713
  stop == null ? void 0 : stop();
714
- resolve();
714
+ resolve(v);
715
715
  }
716
716
  }, {
717
717
  flush,
@@ -720,15 +720,36 @@ function until(r) {
720
720
  });
721
721
  });
722
722
  const promises = [watcher];
723
- if (timeout) {
724
- promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
725
- stop == null ? void 0 : stop();
726
- }));
723
+ if (timeout != null) {
724
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => vueDemi.unref(r)).finally(() => stop == null ? void 0 : stop()));
727
725
  }
728
726
  return Promise.race(promises);
729
727
  }
730
728
  function toBe(value, options) {
731
- return toMatch((v) => v === vueDemi.unref(value), options);
729
+ if (!vueDemi.isRef(value))
730
+ return toMatch((v) => v === value, options);
731
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
732
+ let stop = null;
733
+ const watcher = new Promise((resolve) => {
734
+ stop = vueDemi.watch([r, value], ([v1, v2]) => {
735
+ if (isNot !== (v1 === v2)) {
736
+ stop == null ? void 0 : stop();
737
+ resolve(v1);
738
+ }
739
+ }, {
740
+ flush,
741
+ deep,
742
+ immediate: true
743
+ });
744
+ });
745
+ const promises = [watcher];
746
+ if (timeout != null) {
747
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => vueDemi.unref(r)).finally(() => {
748
+ stop == null ? void 0 : stop();
749
+ return vueDemi.unref(r);
750
+ }));
751
+ }
752
+ return Promise.race(promises);
732
753
  }
733
754
  function toBeTruthy(options) {
734
755
  return toMatch((v) => Boolean(v), options);
@@ -876,7 +897,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
876
897
  clean();
877
898
  }
878
899
  function resume() {
879
- if (interval <= 0)
900
+ if (vueDemi.unref(interval) <= 0)
880
901
  return;
881
902
  isActive.value = true;
882
903
  if (immediateCallback)
@@ -888,7 +909,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
888
909
  resume();
889
910
  if (vueDemi.isRef(interval)) {
890
911
  const stopWatch = vueDemi.watch(interval, () => {
891
- if (immediate && isClient)
912
+ if (isActive.value && isClient)
892
913
  resume();
893
914
  });
894
915
  tryOnScopeDispose(stopWatch);
@@ -1119,12 +1140,14 @@ var __objRest$3 = (source, exclude) => {
1119
1140
  };
1120
1141
  function watchDebounced(source, cb, options = {}) {
1121
1142
  const _a = options, {
1122
- debounce = 0
1143
+ debounce = 0,
1144
+ maxWait = void 0
1123
1145
  } = _a, watchOptions = __objRest$3(_a, [
1124
- "debounce"
1146
+ "debounce",
1147
+ "maxWait"
1125
1148
  ]);
1126
1149
  return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$3({}, watchOptions), {
1127
- eventFilter: debounceFilter(debounce)
1150
+ eventFilter: debounceFilter(debounce, { maxWait })
1128
1151
  }));
1129
1152
  }
1130
1153
 
@@ -1351,6 +1374,7 @@ exports.isClient = isClient;
1351
1374
  exports.isDef = isDef;
1352
1375
  exports.isDefined = isDefined;
1353
1376
  exports.isFunction = isFunction;
1377
+ exports.isIOS = isIOS;
1354
1378
  exports.isNumber = isNumber;
1355
1379
  exports.isObject = isObject;
1356
1380
  exports.isString = isString;
package/index.d.ts CHANGED
@@ -94,6 +94,7 @@ declare const timestamp: () => number;
94
94
  declare const clamp: (n: number, min: number, max: number) => number;
95
95
  declare const noop: () => void;
96
96
  declare const rand: (min: number, max: number) => number;
97
+ declare const isIOS: boolean | "";
97
98
 
98
99
  /**
99
100
  * Any function
@@ -576,22 +577,24 @@ interface UntilToMatchOptions {
576
577
  */
577
578
  deep?: WatchOptions['deep'];
578
579
  }
579
- interface UntilBaseInstance<T> {
580
- toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<void>;
581
- changed(options?: UntilToMatchOptions): Promise<void>;
582
- changedTimes(n?: number, options?: UntilToMatchOptions): Promise<void>;
583
- }
584
- interface UntilValueInstance<T> extends UntilBaseInstance<T> {
585
- readonly not: UntilValueInstance<T>;
586
- toBe<P = T>(value: MaybeRef<T | P>, options?: UntilToMatchOptions): Promise<void>;
587
- toBeTruthy(options?: UntilToMatchOptions): Promise<void>;
588
- toBeNull(options?: UntilToMatchOptions): Promise<void>;
589
- toBeUndefined(options?: UntilToMatchOptions): Promise<void>;
590
- toBeNaN(options?: UntilToMatchOptions): Promise<void>;
580
+ interface UntilBaseInstance<T, Not extends boolean = false> {
581
+ toMatch<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, U>> : Promise<U>;
582
+ toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<T>;
583
+ changed(options?: UntilToMatchOptions): Promise<T>;
584
+ changedTimes(n?: number, options?: UntilToMatchOptions): Promise<T>;
585
+ }
586
+ declare type Falsy = false | void | null | undefined | 0 | 0n | '';
587
+ interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
588
+ readonly not: UntilValueInstance<T, Not extends true ? false : true>;
589
+ toBe<P = T>(value: MaybeRef<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
590
+ toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
591
+ toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
592
+ toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
593
+ toBeNaN(options?: UntilToMatchOptions): Promise<T>;
591
594
  }
592
595
  interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
593
596
  readonly not: UntilArrayInstance<T>;
594
- toContains(value: MaybeRef<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<void>;
597
+ toContains(value: MaybeRef<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
595
598
  }
596
599
  /**
597
600
  * Promised one-time watch for changes
@@ -769,7 +772,7 @@ declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(ini
769
772
 
770
773
  interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {
771
774
  }
772
- declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
775
+ declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
773
776
  declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
774
777
  declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
775
778
 
@@ -780,14 +783,13 @@ interface WatchAtMostReturn {
780
783
  stop: WatchStopHandle;
781
784
  count: Ref<number>;
782
785
  }
783
- declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
784
- declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
786
+ declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
785
787
  declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
786
788
 
787
- interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate> {
789
+ interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions {
788
790
  debounce?: MaybeRef<number>;
789
791
  }
790
- declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
792
+ declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
791
793
  declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
792
794
  declare function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
793
795
 
@@ -797,18 +799,17 @@ interface WatchIgnorableReturn {
797
799
  ignorePrevAsyncUpdates: () => void;
798
800
  stop: WatchStopHandle;
799
801
  }
800
- declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
802
+ declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
801
803
  declare function watchIgnorable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
802
804
  declare function watchIgnorable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
803
805
 
804
- declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): void;
805
- declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): void;
806
+ declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): void;
806
807
  declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): void;
807
808
 
808
809
  interface WatchPausableReturn extends Pausable {
809
810
  stop: WatchStopHandle;
810
811
  }
811
- declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
812
+ declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
812
813
  declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
813
814
  declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
814
815
 
@@ -817,7 +818,7 @@ interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> {
817
818
  trailing?: boolean;
818
819
  leading?: boolean;
819
820
  }
820
- declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
821
+ declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
821
822
  declare function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
822
823
  declare function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
823
824
 
@@ -828,4 +829,4 @@ declare function watchThrottled<T extends object, Immediate extends Readonly<boo
828
829
  */
829
830
  declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
830
831
 
831
- export { Awaitable, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, Reactify, ReactifyNested, ReactifyObjectOptions, RemovableRef, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, Stoppable, SyncRefOptions, SyncRefsOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseCounterOptions, UseDateFormatReturn, UseLastChangedOptions, UseToggleOptions, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchWithFilterOptions, __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };
832
+ export { Awaitable, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, Reactify, ReactifyNested, ReactifyObjectOptions, RemovableRef, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, Stoppable, SyncRefOptions, SyncRefsOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseCounterOptions, UseDateFormatReturn, UseLastChangedOptions, UseToggleOptions, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchWithFilterOptions, __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };
package/index.iife.js CHANGED
@@ -3,7 +3,34 @@
3
3
  return VueDemi
4
4
  }
5
5
  if (Vue) {
6
- if (Vue.version.slice(0, 2) === '2.') {
6
+ if (Vue.version.slice(0, 4) === '2.7.') {
7
+ for (var key in Vue) {
8
+ VueDemi[key] = Vue[key]
9
+ }
10
+ VueDemi.isVue2 = true
11
+ VueDemi.isVue3 = false
12
+ VueDemi.install = function (){}
13
+ VueDemi.Vue = Vue
14
+ VueDemi.Vue2 = Vue
15
+ VueDemi.version = Vue.version
16
+ VueDemi.set = function(target, key, val) {
17
+ if (Array.isArray(target)) {
18
+ target.length = Math.max(target.length, key)
19
+ target.splice(key, 1, val)
20
+ return val
21
+ }
22
+ Vue.set(target, key, val)
23
+ return val
24
+ }
25
+ VueDemi.del = function(target, key) {
26
+ if (Array.isArray(target)) {
27
+ target.splice(key, 1)
28
+ return
29
+ }
30
+ Vue.delete(target, key)
31
+ }
32
+ }
33
+ else if (Vue.version.slice(0, 2) === '2.') {
7
34
  if (VueCompositionAPI) {
8
35
  for (var key in VueCompositionAPI) {
9
36
  VueDemi[key] = VueCompositionAPI[key]
@@ -384,6 +411,7 @@
384
411
  });
385
412
  }
386
413
 
414
+ var _a;
387
415
  const isClient = typeof window !== "undefined";
388
416
  const isDef = (val) => typeof val !== "undefined";
389
417
  const assert = (condition, ...infos) => {
@@ -407,6 +435,7 @@
407
435
  max = Math.floor(max);
408
436
  return Math.floor(Math.random() * (max - min + 1)) + min;
409
437
  };
438
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
410
439
 
411
440
  function createFilterWrapper(filter, fn) {
412
441
  function wrapper(...args) {
@@ -452,7 +481,7 @@
452
481
  function throttleFilter(ms, trailing = true, leading = true) {
453
482
  let lastExec = 0;
454
483
  let timer;
455
- let preventLeading = !leading;
484
+ let isLeading = true;
456
485
  const clear = () => {
457
486
  if (timer) {
458
487
  clearTimeout(timer);
@@ -467,24 +496,20 @@
467
496
  lastExec = Date.now();
468
497
  return invoke();
469
498
  }
470
- if (elapsed > duration) {
499
+ if (elapsed > duration && (leading || !isLeading)) {
471
500
  lastExec = Date.now();
472
- if (preventLeading)
473
- preventLeading = false;
474
- else
475
- invoke();
476
- }
477
- if (trailing) {
501
+ invoke();
502
+ } else if (trailing) {
478
503
  timer = setTimeout(() => {
479
504
  lastExec = Date.now();
480
- if (!leading)
481
- preventLeading = true;
505
+ isLeading = true;
482
506
  clear();
483
507
  invoke();
484
508
  }, duration);
485
509
  }
486
510
  if (!leading && !timer)
487
- timer = setTimeout(() => preventLeading = true, duration);
511
+ timer = setTimeout(() => isLeading = true, duration);
512
+ isLeading = false;
488
513
  };
489
514
  return filter;
490
515
  }
@@ -549,7 +574,7 @@
549
574
  function objectPick(obj, keys, omitUndefined = false) {
550
575
  return keys.reduce((n, k) => {
551
576
  if (k in obj) {
552
- if (!omitUndefined || !obj[k] === void 0)
577
+ if (!omitUndefined || obj[k] !== void 0)
553
578
  n[k] = obj[k];
554
579
  }
555
580
  return n;
@@ -726,7 +751,9 @@
726
751
  copy[key] = v;
727
752
  objectRef.value = copy;
728
753
  } else {
729
- objectRef.value = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
754
+ const newObject = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
755
+ Object.setPrototypeOf(newObject, objectRef.value);
756
+ objectRef.value = newObject;
730
757
  }
731
758
  }
732
759
  }));
@@ -768,9 +795,9 @@
768
795
  let stop = null;
769
796
  const watcher = new Promise((resolve) => {
770
797
  stop = vueDemi.watch(r, (v) => {
771
- if (condition(v) === !isNot) {
798
+ if (condition(v) !== isNot) {
772
799
  stop == null ? void 0 : stop();
773
- resolve();
800
+ resolve(v);
774
801
  }
775
802
  }, {
776
803
  flush,
@@ -779,15 +806,36 @@
779
806
  });
780
807
  });
781
808
  const promises = [watcher];
782
- if (timeout) {
783
- promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
784
- stop == null ? void 0 : stop();
785
- }));
809
+ if (timeout != null) {
810
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => vueDemi.unref(r)).finally(() => stop == null ? void 0 : stop()));
786
811
  }
787
812
  return Promise.race(promises);
788
813
  }
789
814
  function toBe(value, options) {
790
- return toMatch((v) => v === vueDemi.unref(value), options);
815
+ if (!vueDemi.isRef(value))
816
+ return toMatch((v) => v === value, options);
817
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
818
+ let stop = null;
819
+ const watcher = new Promise((resolve) => {
820
+ stop = vueDemi.watch([r, value], ([v1, v2]) => {
821
+ if (isNot !== (v1 === v2)) {
822
+ stop == null ? void 0 : stop();
823
+ resolve(v1);
824
+ }
825
+ }, {
826
+ flush,
827
+ deep,
828
+ immediate: true
829
+ });
830
+ });
831
+ const promises = [watcher];
832
+ if (timeout != null) {
833
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => vueDemi.unref(r)).finally(() => {
834
+ stop == null ? void 0 : stop();
835
+ return vueDemi.unref(r);
836
+ }));
837
+ }
838
+ return Promise.race(promises);
791
839
  }
792
840
  function toBeTruthy(options) {
793
841
  return toMatch((v) => Boolean(v), options);
@@ -935,7 +983,7 @@
935
983
  clean();
936
984
  }
937
985
  function resume() {
938
- if (interval <= 0)
986
+ if (vueDemi.unref(interval) <= 0)
939
987
  return;
940
988
  isActive.value = true;
941
989
  if (immediateCallback)
@@ -947,7 +995,7 @@
947
995
  resume();
948
996
  if (vueDemi.isRef(interval)) {
949
997
  const stopWatch = vueDemi.watch(interval, () => {
950
- if (immediate && isClient)
998
+ if (isActive.value && isClient)
951
999
  resume();
952
1000
  });
953
1001
  tryOnScopeDispose(stopWatch);
@@ -1178,12 +1226,14 @@
1178
1226
  };
1179
1227
  function watchDebounced(source, cb, options = {}) {
1180
1228
  const _a = options, {
1181
- debounce = 0
1229
+ debounce = 0,
1230
+ maxWait = void 0
1182
1231
  } = _a, watchOptions = __objRest$3(_a, [
1183
- "debounce"
1232
+ "debounce",
1233
+ "maxWait"
1184
1234
  ]);
1185
1235
  return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$3({}, watchOptions), {
1186
- eventFilter: debounceFilter(debounce)
1236
+ eventFilter: debounceFilter(debounce, { maxWait })
1187
1237
  }));
1188
1238
  }
1189
1239
 
@@ -1410,6 +1460,7 @@
1410
1460
  exports.isDef = isDef;
1411
1461
  exports.isDefined = isDefined;
1412
1462
  exports.isFunction = isFunction;
1463
+ exports.isIOS = isIOS;
1413
1464
  exports.isNumber = isNumber;
1414
1465
  exports.isObject = isObject;
1415
1466
  exports.isString = isString;
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- var VueDemi=function(o,a,m){if(o.install)return o;if(a)if(a.version.slice(0,2)==="2.")if(m){for(var P in m)o[P]=m[P];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=a,o.Vue2=a,o.version=a.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(a.version.slice(0,2)==="3."){for(var P in a)o[P]=a[P];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=a,o.Vue2=void 0,o.version=a.version,o.set=function(h,v,g){return Array.isArray(h)?(h.length=Math.max(h.length,v),h.splice(v,1,g),g):(h[v]=g,g)},o.del=function(h,v){if(Array.isArray(h)){h.splice(v,1);return}delete h[v]}}else console.error("[vue-demi] Vue version "+a.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return o}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(o,a){"use strict";var m=Object.defineProperty,P=Object.defineProperties,h=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,U=(t,e,r)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nt=(t,e)=>{for(var r in e||(e={}))g.call(e,r)&&U(t,r,e[r]);if(v)for(var r of v(e))Mt.call(e,r)&&U(t,r,e[r]);return t},Wt=(t,e)=>P(t,h(e));function H(t,e){var r;const n=a.shallowRef();return a.watchEffect(()=>{n.value=t()},Wt(Nt({},e),{flush:(r=e==null?void 0:e.flush)!=null?r:"sync"})),a.readonly(n)}function V(t,e){let r,n,i;const u=a.ref(!0);return a.watch(t,()=>{u.value=!0,i()},{flush:"sync"}),a.customRef((l,c)=>(n=l,i=c,{get(){return u.value&&(r=e(),u.value=!1),n(),r},set(){}}))}function Bt(){const t=[],e=i=>{const u=t.indexOf(i);u!==-1&&t.splice(u,1)};return{on:i=>(t.push(i),{off:()=>e(i)}),off:e,trigger:i=>{t.forEach(u=>u(i))}}}function Ut(t){let e=!1,r;const n=a.effectScope(!0);return()=>(e||(r=n.run(t),e=!0),r)}function Ht(t){const e=Symbol("InjectionState");return[(...i)=>{a.provide(e,t(...i))},()=>a.inject(e)]}function b(t){return a.getCurrentScope()?(a.onScopeDispose(t),!0):!1}function Vt(t){let e=0,r,n;const i=()=>{e-=1,n&&e<=0&&(n.stop(),r=void 0,n=void 0)};return(...u)=>(e+=1,r||(n=a.effectScope(!0),r=n.run(()=>t(...u))),b(i),r)}function Y(t="this function"){if(!a.isVue3)throw new Error(`[VueUse] ${t} is only works on Vue 3.`)}const Yt={mounted:a.isVue3?"mounted":"inserted",updated:a.isVue3?"updated":"componentUpdated",unmounted:a.isVue3?"unmounted":"unbind"};function G(t,e,{enumerable:r=!1,unwrap:n=!0}={}){Y();for(const[i,u]of Object.entries(e))i!=="value"&&(a.isRef(u)&&n?Object.defineProperty(t,i,{get(){return u.value},set(l){u.value=l},enumerable:r}):Object.defineProperty(t,i,{value:u,enumerable:r}));return t}function Gt(t,e){return e==null?a.unref(t):a.unref(t)[e]}function zt(t){return a.unref(t)!=null}function z(...t){return a.computed(()=>t.every(e=>a.unref(e)))}function L(t){return a.computed(()=>!a.unref(t))}function X(...t){return a.computed(()=>t.some(e=>a.unref(e)))}var Lt=Object.defineProperty,Z=Object.getOwnPropertySymbols,Xt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable,k=(t,e,r)=>e in t?Lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e)=>{for(var r in e||(e={}))Xt.call(e,r)&&k(t,r,e[r]);if(Z)for(var r of Z(e))Zt.call(e,r)&&k(t,r,e[r]);return t};function qt(t,e){if(typeof Symbol!="undefined"){const r=kt({},t);return Object.defineProperty(r,Symbol.iterator,{enumerable:!1,value(){let n=0;return{next:()=>({value:e[n++],done:n>e.length})}}}),r}else return Object.assign([...e],t)}function R(t){return function(...e){return a.computed(()=>t.apply(this,e.map(r=>a.unref(r))))}}function Jt(t,e={}){let r=[];if(Array.isArray(e))r=e;else{const{includeOwnProperties:n=!0}=e;r.push(...Object.keys(t)),n&&r.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(r.map(n=>{const i=t[n];return[n,typeof i=="function"?R(i.bind(t)):i]}))}function q(t){if(!a.isRef(t))return a.reactive(t);const e=new Proxy({},{get(r,n,i){return a.unref(Reflect.get(t.value,n,i))},set(r,n,i){return a.isRef(t.value[n])&&!a.isRef(i)?t.value[n].value=i:t.value[n]=i,!0},deleteProperty(r,n){return Reflect.deleteProperty(t.value,n)},has(r,n){return Reflect.has(t.value,n)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return a.reactive(e)}function J(t){return q(a.computed(t))}function Qt(t,...e){return J(()=>Object.fromEntries(Object.entries(a.toRefs(t)).filter(r=>!e.includes(r[0]))))}function Kt(t,...e){return a.reactive(Object.fromEntries(e.map(r=>[r,a.toRef(t,r)])))}function Q(t,e=1e4){return a.customRef((r,n)=>{let i=t,u;const l=()=>setTimeout(()=>{i=t,n()},a.unref(e));return b(()=>{clearTimeout(u)}),{get(){return r(),i},set(c){i=c,n(),clearTimeout(u),u=l()}}})}const j=typeof window!="undefined",Dt=t=>typeof t!="undefined",xt=(t,...e)=>{t||console.warn(...e)},K=Object.prototype.toString,te=t=>typeof t=="boolean",ee=t=>typeof t=="function",re=t=>typeof t=="number",ne=t=>typeof t=="string",oe=t=>K.call(t)==="[object Object]",ae=t=>typeof window!="undefined"&&K.call(t)==="[object Window]",ie=()=>Date.now(),D=()=>+Date.now(),ue=(t,e,r)=>Math.min(r,Math.max(e,t)),x=()=>{},le=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t);function $(t,e){function r(...n){t(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})}return r}const I=t=>t();function M(t,e={}){let r,n;return u=>{const l=a.unref(t),c=a.unref(e.maxWait);if(r&&clearTimeout(r),l<=0||c!==void 0&&c<=0)return n&&(clearTimeout(n),n=null),u();c&&!n&&(n=setTimeout(()=>{r&&clearTimeout(r),n=null,u()},c)),r=setTimeout(()=>{n&&clearTimeout(n),n=null,u()},l)}}function N(t,e=!0,r=!0){let n=0,i,u=!r;const l=()=>{i&&(clearTimeout(i),i=void 0)};return d=>{const _=a.unref(t),p=Date.now()-n;if(l(),_<=0)return n=Date.now(),d();p>_&&(n=Date.now(),u?u=!1:d()),e&&(i=setTimeout(()=>{n=Date.now(),r||(u=!0),l(),d()},_)),!r&&!i&&(i=setTimeout(()=>u=!0,_))}}function tt(t=I){const e=a.ref(!0);function r(){e.value=!1}function n(){e.value=!0}return{isActive:e,pause:r,resume:n,eventFilter:(...u)=>{e.value&&t(...u)}}}function et(t,e=!1,r="Timeout"){return new Promise((n,i)=>{setTimeout(e?()=>i(r):n,t)})}function ce(t){return t}function se(t){let e;function r(){return e||(e=t()),e}return r.reset=async()=>{const n=e;e=void 0,n&&await n},r}function fe(t){return t()}function de(t,...e){return e.some(r=>r in t)}function pe(t,e){var r;if(typeof t=="number")return t+e;const n=((r=t.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:r[0])||"",i=t.slice(n.length),u=parseFloat(n)+e;return Number.isNaN(u)?t:u+i}function _e(t,e,r=!1){return e.reduce((n,i)=>(i in t&&(!r||!t[i]===void 0)&&(n[i]=t[i]),n),{})}function rt(t,e=200,r={}){return $(M(e,r),t)}function W(t,e=200,r={}){if(e<=0)return t;const n=a.ref(t.value),i=rt(()=>{n.value=t.value},e,r);return a.watch(t,()=>i()),n}function ye(t,e){return a.computed({get(){var r;return(r=t.value)!=null?r:e},set(r){t.value=r}})}function nt(t,e=200,r=!0,n=!0){return $(N(e,r,n),t)}function B(t,e=200,r=!0,n=!0){if(e<=0)return t;const i=a.ref(t.value),u=nt(()=>{i.value=t.value},e,r,n);return a.watch(t,()=>u()),i}function ot(t,e={}){let r=t,n,i;const u=a.customRef((f,y)=>(n=f,i=y,{get(){return l()},set(O){c(O)}}));function l(f=!0){return f&&n(),r}function c(f,y=!0){var O,C;if(f===r)return;const w=r;((O=e.onBeforeChange)==null?void 0:O.call(e,f,w))!==!1&&(r=f,(C=e.onChanged)==null||C.call(e,f,w),y&&i())}return G(u,{get:l,set:c,untrackedGet:()=>l(!1),silentSet:f=>c(f,!1),peek:()=>l(!1),lay:f=>c(f,!1)},{enumerable:!0})}const Oe=ot;function he(...t){if(t.length===2){const[e,r]=t;e.value=r}if(t.length===3)if(a.isVue2)a.set(...t);else{const[e,r,n]=t;e[r]=n}}function ve(t,e,r={}){const{flush:n="sync",deep:i=!1,immediate:u=!0,direction:l="both"}=r;let c,d;return(l==="both"||l==="ltr")&&(c=a.watch(t,_=>e.value=_,{flush:n,deep:i,immediate:u})),(l==="both"||l==="rtl")&&(d=a.watch(e,_=>t.value=_,{flush:n,deep:i,immediate:u})),()=>{c==null||c(),d==null||d()}}function we(t,e,r={}){const{flush:n="sync",deep:i=!1,immediate:u=!0}=r;return Array.isArray(e)||(e=[e]),a.watch(t,l=>e.forEach(c=>c.value=l),{flush:n,deep:i,immediate:u})}var Pe=Object.defineProperty,ge=Object.defineProperties,be=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,it=(t,e,r)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Se=(t,e)=>{for(var r in e||(e={}))me.call(e,r)&&it(t,r,e[r]);if(at)for(var r of at(e))$e.call(e,r)&&it(t,r,e[r]);return t},je=(t,e)=>ge(t,be(e));function Ie(t){if(!a.isRef(t))return a.toRefs(t);const e=Array.isArray(t.value)?new Array(t.value.length):{};for(const r in t.value)e[r]=a.customRef(()=>({get(){return t.value[r]},set(n){if(Array.isArray(t.value)){const i=[...t.value];i[r]=n,t.value=i}else t.value=je(Se({},t.value),{[r]:n})}}));return e}function Te(t,e=!0){a.getCurrentInstance()?a.onBeforeMount(t):e?t():a.nextTick(t)}function Ee(t){a.getCurrentInstance()&&a.onBeforeUnmount(t)}function Fe(t,e=!0){a.getCurrentInstance()?a.onMounted(t):e?t():a.nextTick(t)}function Ae(t){a.getCurrentInstance()&&a.onUnmounted(t)}function Ce(t){let e=!1;function r(s,{flush:f="sync",deep:y=!1,timeout:O,throwOnTimeout:C}={}){let w=null;const Rt=[new Promise(Tr=>{w=a.watch(t,Er=>{s(Er)===!e&&(w==null||w(),Tr())},{flush:f,deep:y,immediate:!0})})];return O&&Rt.push(et(O,C).finally(()=>{w==null||w()})),Promise.race(Rt)}function n(s,f){return r(y=>y===a.unref(s),f)}function i(s){return r(f=>Boolean(f),s)}function u(s){return n(null,s)}function l(s){return n(void 0,s)}function c(s){return r(Number.isNaN,s)}function d(s,f){return r(y=>{const O=Array.from(y);return O.includes(s)||O.includes(a.unref(s))},f)}function _(s){return p(1,s)}function p(s=1,f){let y=-1;return r(()=>(y+=1,y>=s),f)}return Array.isArray(a.unref(t))?{toMatch:r,toContains:d,changed:_,changedTimes:p,get not(){return e=!e,this}}:{toMatch:r,toBe:n,toBeTruthy:i,toBeNull:u,toBeNaN:c,toBeUndefined:l,changed:_,changedTimes:p,get not(){return e=!e,this}}}function Re(t=0,e={}){const r=a.ref(t),{max:n=1/0,min:i=-1/0}=e,u=(p=1)=>r.value=Math.min(n,r.value+p),l=(p=1)=>r.value=Math.max(i,r.value-p),c=()=>r.value,d=p=>r.value=p;return{count:r,inc:u,dec:l,get:c,set:d,reset:(p=t)=>(t=p,d(p))}}const Me=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Ne=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,ut=(t,e)=>{const r=t.getFullYear(),n=t.getMonth(),i=t.getDate(),u=t.getHours(),l=t.getMinutes(),c=t.getSeconds(),d=t.getMilliseconds(),_=t.getDay(),p={YY:String(r).slice(-2),YYYY:r,M:n+1,MM:`${n+1}`.padStart(2,"0"),D:String(i),DD:`${i}`.padStart(2,"0"),H:String(u),HH:`${u}`.padStart(2,"0"),h:`${u%12||12}`.padStart(1,"0"),hh:`${u%12||12}`.padStart(2,"0"),m:String(l),mm:`${l}`.padStart(2,"0"),s:String(c),ss:`${c}`.padStart(2,"0"),SSS:`${d}`.padStart(3,"0"),d:_};return e.replace(Ne,(s,f)=>f||p[s])},lt=t=>{if(t===null)return new Date(NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Me);if(e){const r=e[2]-1||0,n=(e[7]||"0").substring(0,3);return new Date(e[1],r,e[3]||1,e[4]||0,e[5]||0,e[6]||0,n)}}return new Date(t)};function We(t,e="HH:mm:ss"){return a.computed(()=>ut(lt(a.unref(t)),a.unref(e)))}function ct(t,e=1e3,r={}){const{immediate:n=!0,immediateCallback:i=!1}=r;let u=null;const l=a.ref(!1);function c(){u&&(clearInterval(u),u=null)}function d(){l.value=!1,c()}function _(){e<=0||(l.value=!0,i&&t(),c(),u=setInterval(t,a.unref(e)))}if(n&&j&&_(),a.isRef(e)){const p=a.watch(e,()=>{n&&j&&_()});b(p)}return b(d),{isActive:l,pause:d,resume:_}}var Be=Object.defineProperty,st=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable,ft=(t,e,r)=>e in t?Be(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ve=(t,e)=>{for(var r in e||(e={}))Ue.call(e,r)&&ft(t,r,e[r]);if(st)for(var r of st(e))He.call(e,r)&&ft(t,r,e[r]);return t};function Ye(t=1e3,e={}){const{controls:r=!1,immediate:n=!0}=e,i=a.ref(0),u=ct(()=>i.value+=1,t,{immediate:n});return r?Ve({counter:i},u):i}function Ge(t,e={}){var r;const n=a.ref((r=e.initialValue)!=null?r:null);return a.watch(t,()=>n.value=D(),e),n}function dt(t,e,r={}){const{immediate:n=!0}=r,i=a.ref(!1);let u=null;function l(){u&&(clearTimeout(u),u=null)}function c(){i.value=!1,l()}function d(..._){l(),i.value=!0,u=setTimeout(()=>{i.value=!1,u=null,t(..._)},a.unref(e))}return n&&(i.value=!0,j&&d()),b(c),{isPending:i,start:d,stop:c}}var ze=Object.defineProperty,pt=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,_t=(t,e,r)=>e in t?ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ze=(t,e)=>{for(var r in e||(e={}))Le.call(e,r)&&_t(t,r,e[r]);if(pt)for(var r of pt(e))Xe.call(e,r)&&_t(t,r,e[r]);return t};function ke(t=1e3,e={}){const{controls:r=!1}=e,n=dt(x,t,e),i=a.computed(()=>!n.isPending.value);return r?Ze({ready:i},n):i}function qe(t=!1,e={}){const{truthyValue:r=!0,falsyValue:n=!1}=e,i=a.isRef(t),u=a.ref(t);function l(c){return arguments.length?(u.value=c,u.value):(u.value=u.value===a.unref(r)?a.unref(n):a.unref(r),u.value)}return i?l:[u,l]}var yt=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,Ke=(t,e)=>{var r={};for(var n in t)Je.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&yt)for(var n of yt(t))e.indexOf(n)<0&&Qe.call(t,n)&&(r[n]=t[n]);return r};function S(t,e,r={}){const n=r,{eventFilter:i=I}=n,u=Ke(n,["eventFilter"]);return a.watch(t,$(i,e),u)}var Ot=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,tr=(t,e)=>{var r={};for(var n in t)De.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ot)for(var n of Ot(t))e.indexOf(n)<0&&xe.call(t,n)&&(r[n]=t[n]);return r};function er(t,e,r){const n=r,{count:i}=n,u=tr(n,["count"]),l=a.ref(0),c=S(t,(...d)=>{l.value+=1,l.value>=a.unref(i)&&a.nextTick(()=>c()),e(...d)},u);return{count:l,stop:c}}var rr=Object.defineProperty,nr=Object.defineProperties,or=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable,wt=(t,e,r)=>e in t?rr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ar=(t,e)=>{for(var r in e||(e={}))ht.call(e,r)&&wt(t,r,e[r]);if(T)for(var r of T(e))vt.call(e,r)&&wt(t,r,e[r]);return t},ir=(t,e)=>nr(t,or(e)),ur=(t,e)=>{var r={};for(var n in t)ht.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&T)for(var n of T(t))e.indexOf(n)<0&&vt.call(t,n)&&(r[n]=t[n]);return r};function Pt(t,e,r={}){const n=r,{debounce:i=0}=n,u=ur(n,["debounce"]);return S(t,e,ir(ar({},u),{eventFilter:M(i)}))}var lr=Object.defineProperty,cr=Object.defineProperties,sr=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,mt=(t,e,r)=>e in t?lr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fr=(t,e)=>{for(var r in e||(e={}))gt.call(e,r)&&mt(t,r,e[r]);if(E)for(var r of E(e))bt.call(e,r)&&mt(t,r,e[r]);return t},dr=(t,e)=>cr(t,sr(e)),pr=(t,e)=>{var r={};for(var n in t)gt.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&E)for(var n of E(t))e.indexOf(n)<0&&bt.call(t,n)&&(r[n]=t[n]);return r};function $t(t,e,r={}){const n=r,{eventFilter:i=I}=n,u=pr(n,["eventFilter"]),l=$(i,e);let c,d,_;if(u.flush==="sync"){const p=a.ref(!1);d=()=>{},c=s=>{p.value=!0,s(),p.value=!1},_=a.watch(t,(...s)=>{p.value||l(...s)},u)}else{const p=[],s=a.ref(0),f=a.ref(0);d=()=>{s.value=f.value},p.push(a.watch(t,()=>{f.value++},dr(fr({},u),{flush:"sync"}))),c=y=>{const O=f.value;y(),s.value+=f.value-O},p.push(a.watch(t,(...y)=>{const O=s.value>0&&s.value===f.value;s.value=0,f.value=0,!O&&l(...y)},u)),_=()=>{p.forEach(y=>y())}}return{stop:_,ignoreUpdates:c,ignorePrevAsyncUpdates:d}}function _r(t,e,r){const n=a.watch(t,(...i)=>(a.nextTick(()=>n()),e(...i)),r)}var yr=Object.defineProperty,Or=Object.defineProperties,hr=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vr=(t,e)=>{for(var r in e||(e={}))St.call(e,r)&&It(t,r,e[r]);if(F)for(var r of F(e))jt.call(e,r)&&It(t,r,e[r]);return t},wr=(t,e)=>Or(t,hr(e)),Pr=(t,e)=>{var r={};for(var n in t)St.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&F)for(var n of F(t))e.indexOf(n)<0&&jt.call(t,n)&&(r[n]=t[n]);return r};function Tt(t,e,r={}){const n=r,{eventFilter:i}=n,u=Pr(n,["eventFilter"]),{eventFilter:l,pause:c,resume:d,isActive:_}=tt(i);return{stop:S(t,e,wr(vr({},u),{eventFilter:l})),pause:c,resume:d,isActive:_}}var gr=Object.defineProperty,br=Object.defineProperties,mr=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,At=(t,e,r)=>e in t?gr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$r=(t,e)=>{for(var r in e||(e={}))Et.call(e,r)&&At(t,r,e[r]);if(A)for(var r of A(e))Ft.call(e,r)&&At(t,r,e[r]);return t},Sr=(t,e)=>br(t,mr(e)),jr=(t,e)=>{var r={};for(var n in t)Et.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&A)for(var n of A(t))e.indexOf(n)<0&&Ft.call(t,n)&&(r[n]=t[n]);return r};function Ct(t,e,r={}){const n=r,{throttle:i=0,trailing:u=!0,leading:l=!0}=n,c=jr(n,["throttle","trailing","leading"]);return S(t,e,Sr($r({},c),{eventFilter:N(i,u,l)}))}function Ir(t,e,r){return a.watch(t,(n,i,u)=>{n&&e(n,i,u)},r)}o.__onlyVue3=Y,o.and=z,o.assert=xt,o.autoResetRef=Q,o.bypassFilter=I,o.clamp=ue,o.computedEager=H,o.computedWithControl=V,o.containsProp=de,o.controlledComputed=V,o.controlledRef=Oe,o.createEventHook=Bt,o.createFilterWrapper=$,o.createGlobalState=Ut,o.createInjectionState=Ht,o.createReactiveFn=R,o.createSharedComposable=Vt,o.createSingletonPromise=se,o.debounceFilter=M,o.debouncedRef=W,o.debouncedWatch=Pt,o.directiveHooks=Yt,o.eagerComputed=H,o.extendRef=G,o.formatDate=ut,o.get=Gt,o.identity=ce,o.ignorableWatch=$t,o.increaseWithUnit=pe,o.invoke=fe,o.isBoolean=te,o.isClient=j,o.isDef=Dt,o.isDefined=zt,o.isFunction=ee,o.isNumber=re,o.isObject=oe,o.isString=ne,o.isWindow=ae,o.logicAnd=z,o.logicNot=L,o.logicOr=X,o.makeDestructurable=qt,o.noop=x,o.normalizeDate=lt,o.not=L,o.now=ie,o.objectPick=_e,o.or=X,o.pausableFilter=tt,o.pausableWatch=Tt,o.promiseTimeout=et,o.rand=le,o.reactify=R,o.reactifyObject=Jt,o.reactiveComputed=J,o.reactiveOmit=Qt,o.reactivePick=Kt,o.refAutoReset=Q,o.refDebounced=W,o.refDefault=ye,o.refThrottled=B,o.refWithControl=ot,o.set=he,o.syncRef=ve,o.syncRefs=we,o.throttleFilter=N,o.throttledRef=B,o.throttledWatch=Ct,o.timestamp=D,o.toReactive=q,o.toRefs=Ie,o.tryOnBeforeMount=Te,o.tryOnBeforeUnmount=Ee,o.tryOnMounted=Fe,o.tryOnScopeDispose=b,o.tryOnUnmounted=Ae,o.until=Ce,o.useCounter=Re,o.useDateFormat=We,o.useDebounce=W,o.useDebounceFn=rt,o.useInterval=Ye,o.useIntervalFn=ct,o.useLastChanged=Ge,o.useThrottle=B,o.useThrottleFn=nt,o.useTimeout=ke,o.useTimeoutFn=dt,o.useToggle=qe,o.watchAtMost=er,o.watchDebounced=Pt,o.watchIgnorable=$t,o.watchOnce=_r,o.watchPausable=Tt,o.watchThrottled=Ct,o.watchWithFilter=S,o.whenever=Ir,Object.defineProperty(o,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi);
1
+ var VueDemi=function(o,a,j){if(o.install)return o;if(a)if(a.version.slice(0,4)==="2.7."){for(var P in a)o[P]=a[P];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=a,o.Vue2=a,o.version=a.version,o.set=function(y,O,w){return Array.isArray(y)?(y.length=Math.max(y.length,O),y.splice(O,1,w),w):(a.set(y,O,w),w)},o.del=function(y,O){if(Array.isArray(y)){y.splice(O,1);return}a.delete(y,O)}}else if(a.version.slice(0,2)==="2.")if(j){for(var P in j)o[P]=j[P];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=a,o.Vue2=a,o.version=a.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(a.version.slice(0,2)==="3."){for(var P in a)o[P]=a[P];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=a,o.Vue2=void 0,o.version=a.version,o.set=function(y,O,w){return Array.isArray(y)?(y.length=Math.max(y.length,O),y.splice(O,1,w),w):(y[O]=w,w)},o.del=function(y,O){if(Array.isArray(y)){y.splice(O,1);return}delete y[O]}}else console.error("[vue-demi] Vue version "+a.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return o}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(o,a){"use strict";var j=Object.defineProperty,P=Object.defineProperties,y=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable,L=(t,e,n)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Yt=(t,e)=>{for(var n in e||(e={}))w.call(e,n)&&L(t,n,e[n]);if(O)for(var n of O(e))Ht.call(e,n)&&L(t,n,e[n]);return t},Gt=(t,e)=>P(t,y(e));function X(t,e){var n;const r=a.shallowRef();return a.watchEffect(()=>{r.value=t()},Gt(Yt({},e),{flush:(n=e==null?void 0:e.flush)!=null?n:"sync"})),a.readonly(r)}function Z(t,e){let n,r,i;const l=a.ref(!0);return a.watch(t,()=>{l.value=!0,i()},{flush:"sync"}),a.customRef((c,u)=>(r=c,i=u,{get(){return l.value&&(n=e(),l.value=!1),r(),n},set(){}}))}function zt(){const t=[],e=i=>{const l=t.indexOf(i);l!==-1&&t.splice(l,1)};return{on:i=>(t.push(i),{off:()=>e(i)}),off:e,trigger:i=>{t.forEach(l=>l(i))}}}function Lt(t){let e=!1,n;const r=a.effectScope(!0);return()=>(e||(n=r.run(t),e=!0),n)}function Xt(t){const e=Symbol("InjectionState");return[(...i)=>{a.provide(e,t(...i))},()=>a.inject(e)]}function m(t){return a.getCurrentScope()?(a.onScopeDispose(t),!0):!1}function Zt(t){let e=0,n,r;const i=()=>{e-=1,r&&e<=0&&(r.stop(),n=void 0,r=void 0)};return(...l)=>(e+=1,n||(r=a.effectScope(!0),n=r.run(()=>t(...l))),m(i),n)}function q(t="this function"){if(!a.isVue3)throw new Error(`[VueUse] ${t} is only works on Vue 3.`)}const qt={mounted:a.isVue3?"mounted":"inserted",updated:a.isVue3?"updated":"componentUpdated",unmounted:a.isVue3?"unmounted":"unbind"};function J(t,e,{enumerable:n=!1,unwrap:r=!0}={}){q();for(const[i,l]of Object.entries(e))i!=="value"&&(a.isRef(l)&&r?Object.defineProperty(t,i,{get(){return l.value},set(c){l.value=c},enumerable:n}):Object.defineProperty(t,i,{value:l,enumerable:n}));return t}function Jt(t,e){return e==null?a.unref(t):a.unref(t)[e]}function Qt(t){return a.unref(t)!=null}function Q(...t){return a.computed(()=>t.every(e=>a.unref(e)))}function K(t){return a.computed(()=>!a.unref(t))}function k(...t){return a.computed(()=>t.some(e=>a.unref(e)))}var Kt=Object.defineProperty,V=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable,x=(t,e,n)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xt=(t,e)=>{for(var n in e||(e={}))kt.call(e,n)&&x(t,n,e[n]);if(V)for(var n of V(e))Vt.call(e,n)&&x(t,n,e[n]);return t};function Dt(t,e){if(typeof Symbol!="undefined"){const n=xt({},t);return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let r=0;return{next:()=>({value:e[r++],done:r>e.length})}}}),n}else return Object.assign([...e],t)}function W(t){return function(...e){return a.computed(()=>t.apply(this,e.map(n=>a.unref(n))))}}function te(t,e={}){let n=[];if(Array.isArray(e))n=e;else{const{includeOwnProperties:r=!0}=e;n.push(...Object.keys(t)),r&&n.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(n.map(r=>{const i=t[r];return[r,typeof i=="function"?W(i.bind(t)):i]}))}function D(t){if(!a.isRef(t))return a.reactive(t);const e=new Proxy({},{get(n,r,i){return a.unref(Reflect.get(t.value,r,i))},set(n,r,i){return a.isRef(t.value[r])&&!a.isRef(i)?t.value[r].value=i:t.value[r]=i,!0},deleteProperty(n,r){return Reflect.deleteProperty(t.value,r)},has(n,r){return Reflect.has(t.value,r)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return a.reactive(e)}function tt(t){return D(a.computed(t))}function ee(t,...e){return tt(()=>Object.fromEntries(Object.entries(a.toRefs(t)).filter(n=>!e.includes(n[0]))))}function ne(t,...e){return a.reactive(Object.fromEntries(e.map(n=>[n,a.toRef(t,n)])))}function et(t,e=1e4){return a.customRef((n,r)=>{let i=t,l;const c=()=>setTimeout(()=>{i=t,r()},a.unref(e));return m(()=>{clearTimeout(l)}),{get(){return n(),i},set(u){i=u,r(),clearTimeout(l),l=c()}}})}var nt;const I=typeof window!="undefined",re=t=>typeof t!="undefined",oe=(t,...e)=>{t||console.warn(...e)},rt=Object.prototype.toString,ae=t=>typeof t=="boolean",ie=t=>typeof t=="function",le=t=>typeof t=="number",ce=t=>typeof t=="string",ue=t=>rt.call(t)==="[object Object]",se=t=>typeof window!="undefined"&&rt.call(t)==="[object Window]",fe=()=>Date.now(),ot=()=>+Date.now(),de=(t,e,n)=>Math.min(n,Math.max(e,t)),at=()=>{},pe=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),_e=I&&((nt=window==null?void 0:window.navigator)==null?void 0:nt.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function T(t,e){function n(...r){t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})}return n}const A=t=>t();function B(t,e={}){let n,r;return l=>{const c=a.unref(t),u=a.unref(e.maxWait);if(n&&clearTimeout(n),c<=0||u!==void 0&&u<=0)return r&&(clearTimeout(r),r=null),l();u&&!r&&(r=setTimeout(()=>{n&&clearTimeout(n),r=null,l()},u)),n=setTimeout(()=>{r&&clearTimeout(r),r=null,l()},c)}}function U(t,e=!0,n=!0){let r=0,i,l=!0;const c=()=>{i&&(clearTimeout(i),i=void 0)};return d=>{const _=a.unref(t),p=Date.now()-r;if(c(),_<=0)return r=Date.now(),d();p>_&&(n||!l)?(r=Date.now(),d()):e&&(i=setTimeout(()=>{r=Date.now(),l=!0,c(),d()},_)),!n&&!i&&(i=setTimeout(()=>l=!0,_)),l=!1}}function it(t=A){const e=a.ref(!0);function n(){e.value=!1}function r(){e.value=!0}return{isActive:e,pause:n,resume:r,eventFilter:(...l)=>{e.value&&t(...l)}}}function H(t,e=!1,n="Timeout"){return new Promise((r,i)=>{setTimeout(e?()=>i(n):r,t)})}function ye(t){return t}function he(t){let e;function n(){return e||(e=t()),e}return n.reset=async()=>{const r=e;e=void 0,r&&await r},n}function Oe(t){return t()}function ve(t,...e){return e.some(n=>n in t)}function we(t,e){var n;if(typeof t=="number")return t+e;const r=((n=t.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:n[0])||"",i=t.slice(r.length),l=parseFloat(r)+e;return Number.isNaN(l)?t:l+i}function Pe(t,e,n=!1){return e.reduce((r,i)=>(i in t&&(!n||t[i]!==void 0)&&(r[i]=t[i]),r),{})}function lt(t,e=200,n={}){return T(B(e,n),t)}function Y(t,e=200,n={}){if(e<=0)return t;const r=a.ref(t.value),i=lt(()=>{r.value=t.value},e,n);return a.watch(t,()=>i()),r}function ge(t,e){return a.computed({get(){var n;return(n=t.value)!=null?n:e},set(n){t.value=n}})}function ct(t,e=200,n=!0,r=!0){return T(U(e,n,r),t)}function G(t,e=200,n=!0,r=!0){if(e<=0)return t;const i=a.ref(t.value),l=ct(()=>{i.value=t.value},e,n,r);return a.watch(t,()=>l()),i}function ut(t,e={}){let n=t,r,i;const l=a.customRef((f,h)=>(r=f,i=h,{get(){return c()},set(v){u(v)}}));function c(f=!0){return f&&r(),n}function u(f,h=!0){var v,b;if(f===n)return;const g=n;((v=e.onBeforeChange)==null?void 0:v.call(e,f,g))!==!1&&(n=f,(b=e.onChanged)==null||b.call(e,f,g),h&&i())}return J(l,{get:c,set:u,untrackedGet:()=>c(!1),silentSet:f=>u(f,!1),peek:()=>c(!1),lay:f=>u(f,!1)},{enumerable:!0})}const be=ut;function me(...t){if(t.length===2){const[e,n]=t;e.value=n}if(t.length===3)if(a.isVue2)a.set(...t);else{const[e,n,r]=t;e[n]=r}}function $e(t,e,n={}){const{flush:r="sync",deep:i=!1,immediate:l=!0,direction:c="both"}=n;let u,d;return(c==="both"||c==="ltr")&&(u=a.watch(t,_=>e.value=_,{flush:r,deep:i,immediate:l})),(c==="both"||c==="rtl")&&(d=a.watch(e,_=>t.value=_,{flush:r,deep:i,immediate:l})),()=>{u==null||u(),d==null||d()}}function Se(t,e,n={}){const{flush:r="sync",deep:i=!1,immediate:l=!0}=n;return Array.isArray(e)||(e=[e]),a.watch(t,c=>e.forEach(u=>u.value=c),{flush:r,deep:i,immediate:l})}var je=Object.defineProperty,Ie=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,ft=(t,e,n)=>e in t?je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Fe=(t,e)=>{for(var n in e||(e={}))Ee.call(e,n)&&ft(t,n,e[n]);if(st)for(var n of st(e))Ae.call(e,n)&&ft(t,n,e[n]);return t},Ce=(t,e)=>Ie(t,Te(e));function Re(t){if(!a.isRef(t))return a.toRefs(t);const e=Array.isArray(t.value)?new Array(t.value.length):{};for(const n in t.value)e[n]=a.customRef(()=>({get(){return t.value[n]},set(r){if(Array.isArray(t.value)){const i=[...t.value];i[n]=r,t.value=i}else{const i=Ce(Fe({},t.value),{[n]:r});Object.setPrototypeOf(i,t.value),t.value=i}}}));return e}function Me(t,e=!0){a.getCurrentInstance()?a.onBeforeMount(t):e?t():a.nextTick(t)}function Ne(t){a.getCurrentInstance()&&a.onBeforeUnmount(t)}function We(t,e=!0){a.getCurrentInstance()?a.onMounted(t):e?t():a.nextTick(t)}function Be(t){a.getCurrentInstance()&&a.onUnmounted(t)}function Ue(t){let e=!1;function n(s,{flush:f="sync",deep:h=!1,timeout:v,throwOnTimeout:b}={}){let g=null;const z=[new Promise(N=>{g=a.watch(t,S=>{s(S)!==e&&(g==null||g(),N(S))},{flush:f,deep:h,immediate:!0})})];return v!=null&&z.push(H(v,b).then(()=>a.unref(t)).finally(()=>g==null?void 0:g())),Promise.race(z)}function r(s,f){if(!a.isRef(s))return n(S=>S===s,f);const{flush:h="sync",deep:v=!1,timeout:b,throwOnTimeout:g}=f??{};let $=null;const N=[new Promise(S=>{$=a.watch([t,s],([Ut,Nn])=>{e!==(Ut===Nn)&&($==null||$(),S(Ut))},{flush:h,deep:v,immediate:!0})})];return b!=null&&N.push(H(b,g).then(()=>a.unref(t)).finally(()=>($==null||$(),a.unref(t)))),Promise.race(N)}function i(s){return n(f=>Boolean(f),s)}function l(s){return r(null,s)}function c(s){return r(void 0,s)}function u(s){return n(Number.isNaN,s)}function d(s,f){return n(h=>{const v=Array.from(h);return v.includes(s)||v.includes(a.unref(s))},f)}function _(s){return p(1,s)}function p(s=1,f){let h=-1;return n(()=>(h+=1,h>=s),f)}return Array.isArray(a.unref(t))?{toMatch:n,toContains:d,changed:_,changedTimes:p,get not(){return e=!e,this}}:{toMatch:n,toBe:r,toBeTruthy:i,toBeNull:l,toBeNaN:u,toBeUndefined:c,changed:_,changedTimes:p,get not(){return e=!e,this}}}function He(t=0,e={}){const n=a.ref(t),{max:r=1/0,min:i=-1/0}=e,l=(p=1)=>n.value=Math.min(r,n.value+p),c=(p=1)=>n.value=Math.max(i,n.value-p),u=()=>n.value,d=p=>n.value=p;return{count:n,inc:l,dec:c,get:u,set:d,reset:(p=t)=>(t=p,d(p))}}const Ye=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Ge=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,dt=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),i=t.getDate(),l=t.getHours(),c=t.getMinutes(),u=t.getSeconds(),d=t.getMilliseconds(),_=t.getDay(),p={YY:String(n).slice(-2),YYYY:n,M:r+1,MM:`${r+1}`.padStart(2,"0"),D:String(i),DD:`${i}`.padStart(2,"0"),H:String(l),HH:`${l}`.padStart(2,"0"),h:`${l%12||12}`.padStart(1,"0"),hh:`${l%12||12}`.padStart(2,"0"),m:String(c),mm:`${c}`.padStart(2,"0"),s:String(u),ss:`${u}`.padStart(2,"0"),SSS:`${d}`.padStart(3,"0"),d:_};return e.replace(Ge,(s,f)=>f||p[s])},pt=t=>{if(t===null)return new Date(NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Ye);if(e){const n=e[2]-1||0,r=(e[7]||"0").substring(0,3);return new Date(e[1],n,e[3]||1,e[4]||0,e[5]||0,e[6]||0,r)}}return new Date(t)};function ze(t,e="HH:mm:ss"){return a.computed(()=>dt(pt(a.unref(t)),a.unref(e)))}function _t(t,e=1e3,n={}){const{immediate:r=!0,immediateCallback:i=!1}=n;let l=null;const c=a.ref(!1);function u(){l&&(clearInterval(l),l=null)}function d(){c.value=!1,u()}function _(){a.unref(e)<=0||(c.value=!0,i&&t(),u(),l=setInterval(t,a.unref(e)))}if(r&&I&&_(),a.isRef(e)){const p=a.watch(e,()=>{c.value&&I&&_()});m(p)}return m(d),{isActive:c,pause:d,resume:_}}var Le=Object.defineProperty,yt=Object.getOwnPropertySymbols,Xe=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,ht=(t,e,n)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,qe=(t,e)=>{for(var n in e||(e={}))Xe.call(e,n)&&ht(t,n,e[n]);if(yt)for(var n of yt(e))Ze.call(e,n)&&ht(t,n,e[n]);return t};function Je(t=1e3,e={}){const{controls:n=!1,immediate:r=!0}=e,i=a.ref(0),l=_t(()=>i.value+=1,t,{immediate:r});return n?qe({counter:i},l):i}function Qe(t,e={}){var n;const r=a.ref((n=e.initialValue)!=null?n:null);return a.watch(t,()=>r.value=ot(),e),r}function Ot(t,e,n={}){const{immediate:r=!0}=n,i=a.ref(!1);let l=null;function c(){l&&(clearTimeout(l),l=null)}function u(){i.value=!1,c()}function d(..._){c(),i.value=!0,l=setTimeout(()=>{i.value=!1,l=null,t(..._)},a.unref(e))}return r&&(i.value=!0,I&&d()),m(u),{isPending:i,start:d,stop:u}}var Ke=Object.defineProperty,vt=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,wt=(t,e,n)=>e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xe=(t,e)=>{for(var n in e||(e={}))ke.call(e,n)&&wt(t,n,e[n]);if(vt)for(var n of vt(e))Ve.call(e,n)&&wt(t,n,e[n]);return t};function De(t=1e3,e={}){const{controls:n=!1}=e,r=Ot(at,t,e),i=a.computed(()=>!r.isPending.value);return n?xe({ready:i},r):i}function tn(t=!1,e={}){const{truthyValue:n=!0,falsyValue:r=!1}=e,i=a.isRef(t),l=a.ref(t);function c(u){return arguments.length?(l.value=u,l.value):(l.value=l.value===a.unref(n)?a.unref(r):a.unref(n),l.value)}return i?c:[l,c]}var Pt=Object.getOwnPropertySymbols,en=Object.prototype.hasOwnProperty,nn=Object.prototype.propertyIsEnumerable,rn=(t,e)=>{var n={};for(var r in t)en.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Pt)for(var r of Pt(t))e.indexOf(r)<0&&nn.call(t,r)&&(n[r]=t[r]);return n};function E(t,e,n={}){const r=n,{eventFilter:i=A}=r,l=rn(r,["eventFilter"]);return a.watch(t,T(i,e),l)}var gt=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,ln=(t,e)=>{var n={};for(var r in t)on.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&gt)for(var r of gt(t))e.indexOf(r)<0&&an.call(t,r)&&(n[r]=t[r]);return n};function cn(t,e,n){const r=n,{count:i}=r,l=ln(r,["count"]),c=a.ref(0),u=E(t,(...d)=>{c.value+=1,c.value>=a.unref(i)&&a.nextTick(()=>u()),e(...d)},l);return{count:c,stop:u}}var un=Object.defineProperty,sn=Object.defineProperties,fn=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,$t=(t,e,n)=>e in t?un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,dn=(t,e)=>{for(var n in e||(e={}))bt.call(e,n)&&$t(t,n,e[n]);if(F)for(var n of F(e))mt.call(e,n)&&$t(t,n,e[n]);return t},pn=(t,e)=>sn(t,fn(e)),_n=(t,e)=>{var n={};for(var r in t)bt.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&F)for(var r of F(t))e.indexOf(r)<0&&mt.call(t,r)&&(n[r]=t[r]);return n};function St(t,e,n={}){const r=n,{debounce:i=0,maxWait:l=void 0}=r,c=_n(r,["debounce","maxWait"]);return E(t,e,pn(dn({},c),{eventFilter:B(i,{maxWait:l})}))}var yn=Object.defineProperty,hn=Object.defineProperties,On=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,Tt=(t,e,n)=>e in t?yn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vn=(t,e)=>{for(var n in e||(e={}))jt.call(e,n)&&Tt(t,n,e[n]);if(C)for(var n of C(e))It.call(e,n)&&Tt(t,n,e[n]);return t},wn=(t,e)=>hn(t,On(e)),Pn=(t,e)=>{var n={};for(var r in t)jt.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&C)for(var r of C(t))e.indexOf(r)<0&&It.call(t,r)&&(n[r]=t[r]);return n};function Et(t,e,n={}){const r=n,{eventFilter:i=A}=r,l=Pn(r,["eventFilter"]),c=T(i,e);let u,d,_;if(l.flush==="sync"){const p=a.ref(!1);d=()=>{},u=s=>{p.value=!0,s(),p.value=!1},_=a.watch(t,(...s)=>{p.value||c(...s)},l)}else{const p=[],s=a.ref(0),f=a.ref(0);d=()=>{s.value=f.value},p.push(a.watch(t,()=>{f.value++},wn(vn({},l),{flush:"sync"}))),u=h=>{const v=f.value;h(),s.value+=f.value-v},p.push(a.watch(t,(...h)=>{const v=s.value>0&&s.value===f.value;s.value=0,f.value=0,!v&&c(...h)},l)),_=()=>{p.forEach(h=>h())}}return{stop:_,ignoreUpdates:u,ignorePrevAsyncUpdates:d}}function gn(t,e,n){const r=a.watch(t,(...i)=>(a.nextTick(()=>r()),e(...i)),n)}var bn=Object.defineProperty,mn=Object.defineProperties,$n=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Ct=(t,e,n)=>e in t?bn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Sn=(t,e)=>{for(var n in e||(e={}))At.call(e,n)&&Ct(t,n,e[n]);if(R)for(var n of R(e))Ft.call(e,n)&&Ct(t,n,e[n]);return t},jn=(t,e)=>mn(t,$n(e)),In=(t,e)=>{var n={};for(var r in t)At.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&R)for(var r of R(t))e.indexOf(r)<0&&Ft.call(t,r)&&(n[r]=t[r]);return n};function Rt(t,e,n={}){const r=n,{eventFilter:i}=r,l=In(r,["eventFilter"]),{eventFilter:c,pause:u,resume:d,isActive:_}=it(i);return{stop:E(t,e,jn(Sn({},l),{eventFilter:c})),pause:u,resume:d,isActive:_}}var Tn=Object.defineProperty,En=Object.defineProperties,An=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Wt=(t,e,n)=>e in t?Tn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Fn=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&Wt(t,n,e[n]);if(M)for(var n of M(e))Nt.call(e,n)&&Wt(t,n,e[n]);return t},Cn=(t,e)=>En(t,An(e)),Rn=(t,e)=>{var n={};for(var r in t)Mt.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&M)for(var r of M(t))e.indexOf(r)<0&&Nt.call(t,r)&&(n[r]=t[r]);return n};function Bt(t,e,n={}){const r=n,{throttle:i=0,trailing:l=!0,leading:c=!0}=r,u=Rn(r,["throttle","trailing","leading"]);return E(t,e,Cn(Fn({},u),{eventFilter:U(i,l,c)}))}function Mn(t,e,n){return a.watch(t,(r,i,l)=>{r&&e(r,i,l)},n)}o.__onlyVue3=q,o.and=Q,o.assert=oe,o.autoResetRef=et,o.bypassFilter=A,o.clamp=de,o.computedEager=X,o.computedWithControl=Z,o.containsProp=ve,o.controlledComputed=Z,o.controlledRef=be,o.createEventHook=zt,o.createFilterWrapper=T,o.createGlobalState=Lt,o.createInjectionState=Xt,o.createReactiveFn=W,o.createSharedComposable=Zt,o.createSingletonPromise=he,o.debounceFilter=B,o.debouncedRef=Y,o.debouncedWatch=St,o.directiveHooks=qt,o.eagerComputed=X,o.extendRef=J,o.formatDate=dt,o.get=Jt,o.identity=ye,o.ignorableWatch=Et,o.increaseWithUnit=we,o.invoke=Oe,o.isBoolean=ae,o.isClient=I,o.isDef=re,o.isDefined=Qt,o.isFunction=ie,o.isIOS=_e,o.isNumber=le,o.isObject=ue,o.isString=ce,o.isWindow=se,o.logicAnd=Q,o.logicNot=K,o.logicOr=k,o.makeDestructurable=Dt,o.noop=at,o.normalizeDate=pt,o.not=K,o.now=fe,o.objectPick=Pe,o.or=k,o.pausableFilter=it,o.pausableWatch=Rt,o.promiseTimeout=H,o.rand=pe,o.reactify=W,o.reactifyObject=te,o.reactiveComputed=tt,o.reactiveOmit=ee,o.reactivePick=ne,o.refAutoReset=et,o.refDebounced=Y,o.refDefault=ge,o.refThrottled=G,o.refWithControl=ut,o.set=me,o.syncRef=$e,o.syncRefs=Se,o.throttleFilter=U,o.throttledRef=G,o.throttledWatch=Bt,o.timestamp=ot,o.toReactive=D,o.toRefs=Re,o.tryOnBeforeMount=Me,o.tryOnBeforeUnmount=Ne,o.tryOnMounted=We,o.tryOnScopeDispose=m,o.tryOnUnmounted=Be,o.until=Ue,o.useCounter=He,o.useDateFormat=ze,o.useDebounce=Y,o.useDebounceFn=lt,o.useInterval=Je,o.useIntervalFn=_t,o.useLastChanged=Qe,o.useThrottle=G,o.useThrottleFn=ct,o.useTimeout=De,o.useTimeoutFn=Ot,o.useToggle=tn,o.watchAtMost=cn,o.watchDebounced=St,o.watchIgnorable=Et,o.watchOnce=gn,o.watchPausable=Rt,o.watchThrottled=Bt,o.watchWithFilter=E,o.whenever=Mn,Object.defineProperty(o,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi);
package/index.mjs CHANGED
@@ -321,6 +321,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
321
321
  });
322
322
  }
323
323
 
324
+ var _a;
324
325
  const isClient = typeof window !== "undefined";
325
326
  const isDef = (val) => typeof val !== "undefined";
326
327
  const assert = (condition, ...infos) => {
@@ -344,6 +345,7 @@ const rand = (min, max) => {
344
345
  max = Math.floor(max);
345
346
  return Math.floor(Math.random() * (max - min + 1)) + min;
346
347
  };
348
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
347
349
 
348
350
  function createFilterWrapper(filter, fn) {
349
351
  function wrapper(...args) {
@@ -389,7 +391,7 @@ function debounceFilter(ms, options = {}) {
389
391
  function throttleFilter(ms, trailing = true, leading = true) {
390
392
  let lastExec = 0;
391
393
  let timer;
392
- let preventLeading = !leading;
394
+ let isLeading = true;
393
395
  const clear = () => {
394
396
  if (timer) {
395
397
  clearTimeout(timer);
@@ -404,24 +406,20 @@ function throttleFilter(ms, trailing = true, leading = true) {
404
406
  lastExec = Date.now();
405
407
  return invoke();
406
408
  }
407
- if (elapsed > duration) {
409
+ if (elapsed > duration && (leading || !isLeading)) {
408
410
  lastExec = Date.now();
409
- if (preventLeading)
410
- preventLeading = false;
411
- else
412
- invoke();
413
- }
414
- if (trailing) {
411
+ invoke();
412
+ } else if (trailing) {
415
413
  timer = setTimeout(() => {
416
414
  lastExec = Date.now();
417
- if (!leading)
418
- preventLeading = true;
415
+ isLeading = true;
419
416
  clear();
420
417
  invoke();
421
418
  }, duration);
422
419
  }
423
420
  if (!leading && !timer)
424
- timer = setTimeout(() => preventLeading = true, duration);
421
+ timer = setTimeout(() => isLeading = true, duration);
422
+ isLeading = false;
425
423
  };
426
424
  return filter;
427
425
  }
@@ -486,7 +484,7 @@ function increaseWithUnit(target, delta) {
486
484
  function objectPick(obj, keys, omitUndefined = false) {
487
485
  return keys.reduce((n, k) => {
488
486
  if (k in obj) {
489
- if (!omitUndefined || !obj[k] === void 0)
487
+ if (!omitUndefined || obj[k] !== void 0)
490
488
  n[k] = obj[k];
491
489
  }
492
490
  return n;
@@ -663,7 +661,9 @@ function toRefs(objectRef) {
663
661
  copy[key] = v;
664
662
  objectRef.value = copy;
665
663
  } else {
666
- objectRef.value = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
664
+ const newObject = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
665
+ Object.setPrototypeOf(newObject, objectRef.value);
666
+ objectRef.value = newObject;
667
667
  }
668
668
  }
669
669
  }));
@@ -705,9 +705,9 @@ function until(r) {
705
705
  let stop = null;
706
706
  const watcher = new Promise((resolve) => {
707
707
  stop = watch(r, (v) => {
708
- if (condition(v) === !isNot) {
708
+ if (condition(v) !== isNot) {
709
709
  stop == null ? void 0 : stop();
710
- resolve();
710
+ resolve(v);
711
711
  }
712
712
  }, {
713
713
  flush,
@@ -716,15 +716,36 @@ function until(r) {
716
716
  });
717
717
  });
718
718
  const promises = [watcher];
719
- if (timeout) {
720
- promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
721
- stop == null ? void 0 : stop();
722
- }));
719
+ if (timeout != null) {
720
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => unref(r)).finally(() => stop == null ? void 0 : stop()));
723
721
  }
724
722
  return Promise.race(promises);
725
723
  }
726
724
  function toBe(value, options) {
727
- return toMatch((v) => v === unref(value), options);
725
+ if (!isRef(value))
726
+ return toMatch((v) => v === value, options);
727
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
728
+ let stop = null;
729
+ const watcher = new Promise((resolve) => {
730
+ stop = watch([r, value], ([v1, v2]) => {
731
+ if (isNot !== (v1 === v2)) {
732
+ stop == null ? void 0 : stop();
733
+ resolve(v1);
734
+ }
735
+ }, {
736
+ flush,
737
+ deep,
738
+ immediate: true
739
+ });
740
+ });
741
+ const promises = [watcher];
742
+ if (timeout != null) {
743
+ promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => unref(r)).finally(() => {
744
+ stop == null ? void 0 : stop();
745
+ return unref(r);
746
+ }));
747
+ }
748
+ return Promise.race(promises);
728
749
  }
729
750
  function toBeTruthy(options) {
730
751
  return toMatch((v) => Boolean(v), options);
@@ -872,7 +893,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
872
893
  clean();
873
894
  }
874
895
  function resume() {
875
- if (interval <= 0)
896
+ if (unref(interval) <= 0)
876
897
  return;
877
898
  isActive.value = true;
878
899
  if (immediateCallback)
@@ -884,7 +905,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
884
905
  resume();
885
906
  if (isRef(interval)) {
886
907
  const stopWatch = watch(interval, () => {
887
- if (immediate && isClient)
908
+ if (isActive.value && isClient)
888
909
  resume();
889
910
  });
890
911
  tryOnScopeDispose(stopWatch);
@@ -1115,12 +1136,14 @@ var __objRest$3 = (source, exclude) => {
1115
1136
  };
1116
1137
  function watchDebounced(source, cb, options = {}) {
1117
1138
  const _a = options, {
1118
- debounce = 0
1139
+ debounce = 0,
1140
+ maxWait = void 0
1119
1141
  } = _a, watchOptions = __objRest$3(_a, [
1120
- "debounce"
1142
+ "debounce",
1143
+ "maxWait"
1121
1144
  ]);
1122
1145
  return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$3({}, watchOptions), {
1123
- eventFilter: debounceFilter(debounce)
1146
+ eventFilter: debounceFilter(debounce, { maxWait })
1124
1147
  }));
1125
1148
  }
1126
1149
 
@@ -1312,4 +1335,4 @@ function whenever(source, cb, options) {
1312
1335
  }, options);
1313
1336
  }
1314
1337
 
1315
- export { __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };
1338
+ export { __onlyVue3, logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
2
  "name": "@vueuse/shared",
3
- "version": "8.4.2",
4
- "keywords": [
5
- "vue",
6
- "vue-use",
7
- "utils"
8
- ],
9
- "license": "MIT",
3
+ "version": "8.7.0",
10
4
  "author": "Anthony Fu <https://github.com/antfu>",
5
+ "license": "MIT",
6
+ "funding": "https://github.com/sponsors/antfu",
7
+ "homepage": "https://github.com/vueuse/vueuse/tree/main/packages/shared#readme",
11
8
  "repository": {
12
9
  "type": "git",
13
10
  "url": "git+https://github.com/vueuse/vueuse.git",
14
11
  "directory": "packages/shared"
15
12
  },
16
- "funding": "https://github.com/sponsors/antfu",
17
- "main": "./index.cjs",
18
- "module": "./index.mjs",
19
- "types": "./index.d.ts",
20
- "unpkg": "./index.iife.min.js",
21
- "jsdelivr": "./index.iife.min.js",
13
+ "bugs": {
14
+ "url": "https://github.com/vueuse/vueuse/issues"
15
+ },
16
+ "keywords": [
17
+ "vue",
18
+ "vue-use",
19
+ "utils"
20
+ ],
21
+ "sideEffects": false,
22
22
  "exports": {
23
23
  ".": {
24
- "import": "./index.mjs",
24
+ "types": "./index.d.ts",
25
25
  "require": "./index.cjs",
26
- "types": "./index.d.ts"
26
+ "import": "./index.mjs"
27
27
  },
28
28
  "./*": "./*"
29
29
  },
30
- "sideEffects": false,
31
- "bugs": {
32
- "url": "https://github.com/vueuse/vueuse/issues"
33
- },
34
- "homepage": "https://github.com/vueuse/vueuse/tree/main/packages/shared#readme",
30
+ "main": "./index.cjs",
31
+ "module": "./index.mjs",
32
+ "unpkg": "./index.iife.min.js",
33
+ "jsdelivr": "./index.iife.min.js",
34
+ "types": "./index.d.ts",
35
35
  "peerDependencies": {
36
36
  "@vue/composition-api": "^1.1.0",
37
37
  "vue": "^2.6.0 || ^3.2.0"