@vueuse/shared 14.2.0 → 14.3.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/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { computed, customRef, effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isReactive, isRef, nextTick, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, provide, reactive, readonly, ref, shallowReadonly, shallowRef, toRef as toRef$1, toRefs as toRefs$1, toValue, unref, watch, watchEffect } from "vue";
2
-
3
2
  //#region computedEager/index.ts
4
3
  /**
5
4
  *
@@ -27,7 +26,6 @@ function computedEager(fn, options) {
27
26
  }
28
27
  /** @deprecated use `computedEager` instead */
29
28
  const eagerComputed = computedEager;
30
-
31
29
  //#endregion
32
30
  //#region computedWithControl/index.ts
33
31
  /**
@@ -49,22 +47,22 @@ function computedWithControl(source, fn, options = {}) {
49
47
  flush: "sync",
50
48
  ...options
51
49
  });
52
- const get$1 = typeof fn === "function" ? fn : fn.get;
53
- const set$1 = typeof fn === "function" ? void 0 : fn.set;
50
+ const get = typeof fn === "function" ? fn : fn.get;
51
+ const set = typeof fn === "function" ? void 0 : fn.set;
54
52
  const result = customRef((_track, _trigger) => {
55
53
  track = _track;
56
54
  trigger = _trigger;
57
55
  return {
58
56
  get() {
59
57
  if (dirty) {
60
- v = get$1(v);
58
+ v = get(v);
61
59
  dirty = false;
62
60
  }
63
61
  track();
64
62
  return v;
65
63
  },
66
- set(v$1) {
67
- set$1 === null || set$1 === void 0 || set$1(v$1);
64
+ set(v) {
65
+ set === null || set === void 0 || set(v);
68
66
  }
69
67
  };
70
68
  });
@@ -73,7 +71,44 @@ function computedWithControl(source, fn, options = {}) {
73
71
  }
74
72
  /** @deprecated use `computedWithControl` instead */
75
73
  const controlledComputed = computedWithControl;
76
-
74
+ //#endregion
75
+ //#region createDisposableDirective/index.ts
76
+ /**
77
+ * Utility for authoring disposable directives. Reactive effects created within `mounted` directive hook will be tracked and automatically disposed when directive is unmounted.
78
+ *
79
+ * @see https://vueuse.org/createDisposableDirective
80
+ *
81
+ * @__NO_SIDE_EFFECTS__
82
+ */
83
+ function createDisposableDirective(origin = {}) {
84
+ function isFunc(fn) {
85
+ return typeof fn === "function";
86
+ }
87
+ const normalisedOrigin = isFunc(origin) ? {
88
+ mounted: origin,
89
+ updated: origin
90
+ } : origin;
91
+ const { mounted, unmounted } = normalisedOrigin;
92
+ if (!isFunc(mounted)) return origin;
93
+ const scopeWeakMap = /* @__PURE__ */ new WeakMap();
94
+ return {
95
+ ...normalisedOrigin,
96
+ mounted(el, binding, vNode, prevNode) {
97
+ var _scopeWeakMap$get;
98
+ const scope = (_scopeWeakMap$get = scopeWeakMap.get(el)) !== null && _scopeWeakMap$get !== void 0 ? _scopeWeakMap$get : effectScope();
99
+ scopeWeakMap.set(el, scope);
100
+ scope.run(() => {
101
+ mounted === null || mounted === void 0 || mounted(el, binding, vNode, prevNode);
102
+ });
103
+ },
104
+ unmounted(el, binding, vNode, prevNode) {
105
+ var _scopeWeakMap$get2;
106
+ (_scopeWeakMap$get2 = scopeWeakMap.get(el)) === null || _scopeWeakMap$get2 === void 0 || _scopeWeakMap$get2.stop();
107
+ scopeWeakMap.delete(el);
108
+ if (isFunc(unmounted)) unmounted(el, binding, vNode, prevNode);
109
+ }
110
+ };
111
+ }
77
112
  //#endregion
78
113
  //#region tryOnScopeDispose/index.ts
79
114
  /**
@@ -88,7 +123,6 @@ function tryOnScopeDispose(fn, failSilently) {
88
123
  }
89
124
  return false;
90
125
  }
91
-
92
126
  //#endregion
93
127
  //#region createEventHook/index.ts
94
128
  /**
@@ -122,7 +156,6 @@ function createEventHook() {
122
156
  clear
123
157
  };
124
158
  }
125
-
126
159
  //#endregion
127
160
  //#region createGlobalState/index.ts
128
161
  /**
@@ -145,11 +178,9 @@ function createGlobalState(stateFactory) {
145
178
  return state;
146
179
  });
147
180
  }
148
-
149
181
  //#endregion
150
182
  //#region provideLocal/map.ts
151
183
  const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
152
-
153
184
  //#endregion
154
185
  //#region injectLocal/index.ts
155
186
  /**
@@ -172,7 +203,6 @@ const injectLocal = (...args) => {
172
203
  if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key];
173
204
  return inject(...args);
174
205
  };
175
-
176
206
  //#endregion
177
207
  //#region provideLocal/index.ts
178
208
  /**
@@ -194,16 +224,8 @@ function provideLocal(key, value) {
194
224
  localProvidedState[key] = value;
195
225
  return provide(key, value);
196
226
  }
197
-
198
227
  //#endregion
199
228
  //#region createInjectionState/index.ts
200
- /**
201
- * Create global state that can be injected into components.
202
- *
203
- * @see https://vueuse.org/createInjectionState
204
- *
205
- * @__NO_SIDE_EFFECTS__
206
- */
207
229
  function createInjectionState(composable, options) {
208
230
  const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
209
231
  const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue;
@@ -215,7 +237,6 @@ function createInjectionState(composable, options) {
215
237
  const useInjectedState = () => injectLocal(key, defaultValue);
216
238
  return [useProvidingState, useInjectedState];
217
239
  }
218
-
219
240
  //#endregion
220
241
  //#region createRef/index.ts
221
242
  /**
@@ -237,7 +258,6 @@ function createRef(value, deep) {
237
258
  if (deep === true) return ref(value);
238
259
  else return shallowRef(value);
239
260
  }
240
-
241
261
  //#endregion
242
262
  //#region utils/is.ts
243
263
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
@@ -258,13 +278,12 @@ const rand = (min, max) => {
258
278
  max = Math.floor(max);
259
279
  return Math.floor(Math.random() * (max - min + 1)) + min;
260
280
  };
261
- const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
281
+ const hasOwn = (val, key) => Object.hasOwn(val, key);
262
282
  const isIOS = /* @__PURE__ */ getIsIOS();
263
283
  function getIsIOS() {
264
284
  var _window, _window2, _window3;
265
285
  return isClient && !!((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
266
286
  }
267
-
268
287
  //#endregion
269
288
  //#region toRef/index.ts
270
289
  function toRef(...args) {
@@ -275,7 +294,6 @@ function toRef(...args) {
275
294
  set: noop
276
295
  }))) : ref(r);
277
296
  }
278
-
279
297
  //#endregion
280
298
  //#region utils/filters.ts
281
299
  /**
@@ -293,8 +311,8 @@ function createFilterWrapper(filter, fn) {
293
311
  }
294
312
  return wrapper;
295
313
  }
296
- const bypassFilter = (invoke$1) => {
297
- return invoke$1();
314
+ const bypassFilter = (invoke) => {
315
+ return invoke();
298
316
  };
299
317
  /**
300
318
  * Create an EventFilter that debounce the events
@@ -303,13 +321,13 @@ function debounceFilter(ms, options = {}) {
303
321
  let timer;
304
322
  let maxTimer;
305
323
  let lastRejector = noop;
306
- const _clearTimeout = (timer$1) => {
307
- clearTimeout(timer$1);
324
+ const _clearTimeout = (timer) => {
325
+ clearTimeout(timer);
308
326
  lastRejector();
309
327
  lastRejector = noop;
310
328
  };
311
329
  let lastInvoker;
312
- const filter = (invoke$1) => {
330
+ const filter = (invoke) => {
313
331
  const duration = toValue(ms);
314
332
  const maxDuration = toValue(options.maxWait);
315
333
  if (timer) _clearTimeout(timer);
@@ -318,11 +336,11 @@ function debounceFilter(ms, options = {}) {
318
336
  _clearTimeout(maxTimer);
319
337
  maxTimer = void 0;
320
338
  }
321
- return Promise.resolve(invoke$1());
339
+ return Promise.resolve(invoke());
322
340
  }
323
341
  return new Promise((resolve, reject) => {
324
342
  lastRejector = options.rejectOnCancel ? reject : resolve;
325
- lastInvoker = invoke$1;
343
+ lastInvoker = invoke;
326
344
  if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
327
345
  if (timer) _clearTimeout(timer);
328
346
  maxTimer = void 0;
@@ -331,7 +349,7 @@ function debounceFilter(ms, options = {}) {
331
349
  timer = setTimeout(() => {
332
350
  if (maxTimer) _clearTimeout(maxTimer);
333
351
  maxTimer = void 0;
334
- resolve(invoke$1());
352
+ resolve(invoke());
335
353
  }, duration);
336
354
  });
337
355
  };
@@ -360,23 +378,23 @@ function throttleFilter(...args) {
360
378
  const filter = (_invoke) => {
361
379
  const duration = toValue(ms);
362
380
  const elapsed = Date.now() - lastExec;
363
- const invoke$1 = () => {
381
+ const invoke = () => {
364
382
  return lastValue = _invoke();
365
383
  };
366
384
  clear();
367
385
  if (duration <= 0) {
368
386
  lastExec = Date.now();
369
- return invoke$1();
387
+ return invoke();
370
388
  }
371
389
  if (elapsed > duration) {
372
390
  lastExec = Date.now();
373
- if (leading || !isLeading) invoke$1();
391
+ if (leading || !isLeading) invoke();
374
392
  } else if (trailing) lastValue = new Promise((resolve, reject) => {
375
393
  lastRejector = rejectOnCancel ? reject : resolve;
376
394
  timer = setTimeout(() => {
377
395
  lastExec = Date.now();
378
396
  isLeading = true;
379
- resolve(invoke$1());
397
+ resolve(invoke());
380
398
  clear();
381
399
  }, Math.max(0, duration - elapsed));
382
400
  });
@@ -405,18 +423,17 @@ function pausableFilter(extendFilter = bypassFilter, options = {}) {
405
423
  if (isActive.value) extendFilter(...args);
406
424
  };
407
425
  return {
408
- isActive: readonly(isActive),
426
+ isActive: shallowReadonly(isActive),
409
427
  pause,
410
428
  resume,
411
429
  eventFilter
412
430
  };
413
431
  }
414
-
415
432
  //#endregion
416
433
  //#region utils/general.ts
417
434
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
418
435
  return new Promise((resolve, reject) => {
419
- if (throwOnTimeout) setTimeout(() => reject(reason), ms);
436
+ if (throwOnTimeout) setTimeout(reject, ms, reason);
420
437
  else setTimeout(resolve, ms);
421
438
  });
422
439
  }
@@ -494,7 +511,6 @@ function objectEntries(obj) {
494
511
  function toArray(value) {
495
512
  return Array.isArray(value) ? value : [value];
496
513
  }
497
-
498
514
  //#endregion
499
515
  //#region utils/port.ts
500
516
  function cacheStringFunction(fn) {
@@ -509,13 +525,11 @@ const camelizeRE = /-(\w)/g;
509
525
  const camelize = cacheStringFunction((str) => {
510
526
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
511
527
  });
512
-
513
528
  //#endregion
514
529
  //#region utils/vue.ts
515
530
  function getLifeCycleTarget(target) {
516
531
  return target || getCurrentInstance();
517
532
  }
518
-
519
533
  //#endregion
520
534
  //#region createSharedComposable/index.ts
521
535
  /**
@@ -548,13 +562,12 @@ function createSharedComposable(composable) {
548
562
  return state;
549
563
  });
550
564
  }
551
-
552
565
  //#endregion
553
566
  //#region extendRef/index.ts
554
- function extendRef(ref$1, extend, { enumerable = false, unwrap = true } = {}) {
567
+ function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
555
568
  for (const [key, value] of Object.entries(extend)) {
556
569
  if (key === "value") continue;
557
- if (isRef(value) && unwrap) Object.defineProperty(ref$1, key, {
570
+ if (isRef(value) && unwrap) Object.defineProperty(ref, key, {
558
571
  get() {
559
572
  return value.value;
560
573
  },
@@ -563,27 +576,24 @@ function extendRef(ref$1, extend, { enumerable = false, unwrap = true } = {}) {
563
576
  },
564
577
  enumerable
565
578
  });
566
- else Object.defineProperty(ref$1, key, {
579
+ else Object.defineProperty(ref, key, {
567
580
  value,
568
581
  enumerable
569
582
  });
570
583
  }
571
- return ref$1;
584
+ return ref;
572
585
  }
573
-
574
586
  //#endregion
575
587
  //#region get/index.ts
576
588
  function get(obj, key) {
577
589
  if (key == null) return unref(obj);
578
590
  return unref(obj)[key];
579
591
  }
580
-
581
592
  //#endregion
582
593
  //#region isDefined/index.ts
583
594
  function isDefined(v) {
584
595
  return unref(v) != null;
585
596
  }
586
-
587
597
  //#endregion
588
598
  //#region makeDestructurable/index.ts
589
599
  /* @__NO_SIDE_EFFECTS__ */
@@ -603,7 +613,6 @@ function makeDestructurable(obj, arr) {
603
613
  return clone;
604
614
  } else return Object.assign([...arr], obj);
605
615
  }
606
-
607
616
  //#endregion
608
617
  //#region reactify/index.ts
609
618
  /**
@@ -624,7 +633,6 @@ function reactify(fn, options) {
624
633
  }
625
634
  /** @deprecated use `reactify` instead */
626
635
  const createReactiveFn = reactify;
627
-
628
636
  //#endregion
629
637
  //#region reactifyObject/index.ts
630
638
  /**
@@ -647,7 +655,6 @@ function reactifyObject(obj, optionsOrKeys = {}) {
647
655
  return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value];
648
656
  }));
649
657
  }
650
-
651
658
  //#endregion
652
659
  //#region toReactive/index.ts
653
660
  /**
@@ -684,7 +691,6 @@ function toReactive(objectRef) {
684
691
  }
685
692
  }));
686
693
  }
687
-
688
694
  //#endregion
689
695
  //#region reactiveComputed/index.ts
690
696
  /**
@@ -693,7 +699,6 @@ function toReactive(objectRef) {
693
699
  function reactiveComputed(fn) {
694
700
  return toReactive(computed(fn));
695
701
  }
696
-
697
702
  //#endregion
698
703
  //#region reactiveOmit/index.ts
699
704
  /**
@@ -706,7 +711,6 @@ function reactiveOmit(obj, ...keys) {
706
711
  const predicate = flatKeys[0];
707
712
  return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
708
713
  }
709
-
710
714
  //#endregion
711
715
  //#region reactivePick/index.ts
712
716
  /**
@@ -719,7 +723,6 @@ function reactivePick(obj, ...keys) {
719
723
  const predicate = flatKeys[0];
720
724
  return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
721
725
  }
722
-
723
726
  //#endregion
724
727
  //#region refAutoReset/index.ts
725
728
  /**
@@ -756,7 +759,6 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
756
759
  }
757
760
  /** @deprecated use `refAutoReset` instead */
758
761
  const autoResetRef = refAutoReset;
759
-
760
762
  //#endregion
761
763
  //#region useDebounceFn/index.ts
762
764
  /**
@@ -774,7 +776,6 @@ const autoResetRef = refAutoReset;
774
776
  function useDebounceFn(fn, ms = 200, options = {}) {
775
777
  return createFilterWrapper(debounceFilter(ms, options), fn);
776
778
  }
777
-
778
779
  //#endregion
779
780
  //#region refDebounced/index.ts
780
781
  /**
@@ -794,7 +795,6 @@ function refDebounced(value, ms = 200, options = {}) {
794
795
  const debouncedRef = refDebounced;
795
796
  /** @deprecated use `refDebounced` instead */
796
797
  const useDebounce = refDebounced;
797
-
798
798
  //#endregion
799
799
  //#region refDefault/index.ts
800
800
  /**
@@ -813,7 +813,6 @@ function refDefault(source, defaultValue) {
813
813
  }
814
814
  });
815
815
  }
816
-
817
816
  //#endregion
818
817
  //#region refManualReset/index.ts
819
818
  /**
@@ -845,7 +844,6 @@ function refManualReset(defaultValue) {
845
844
  refValue.reset = reset;
846
845
  return refValue;
847
846
  }
848
-
849
847
  //#endregion
850
848
  //#region useThrottleFn/index.ts
851
849
  /**
@@ -870,7 +868,6 @@ function refManualReset(defaultValue) {
870
868
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
871
869
  return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
872
870
  }
873
-
874
871
  //#endregion
875
872
  //#region refThrottled/index.ts
876
873
  /**
@@ -895,7 +892,6 @@ function refThrottled(value, delay = 200, trailing = true, leading = true) {
895
892
  const throttledRef = refThrottled;
896
893
  /** @deprecated use `refThrottled` instead */
897
894
  const useThrottle = refThrottled;
898
-
899
895
  //#endregion
900
896
  //#region refWithControl/index.ts
901
897
  /**
@@ -907,23 +903,23 @@ function refWithControl(initial, options = {}) {
907
903
  let source = initial;
908
904
  let track;
909
905
  let trigger;
910
- const ref$1 = customRef((_track, _trigger) => {
906
+ const ref = customRef((_track, _trigger) => {
911
907
  track = _track;
912
908
  trigger = _trigger;
913
909
  return {
914
910
  get() {
915
- return get$1();
911
+ return get();
916
912
  },
917
913
  set(v) {
918
- set$1(v);
914
+ set(v);
919
915
  }
920
916
  };
921
917
  });
922
- function get$1(tracking = true) {
918
+ function get(tracking = true) {
923
919
  if (tracking) track();
924
920
  return source;
925
921
  }
926
- function set$1(value, triggering = true) {
922
+ function set(value, triggering = true) {
927
923
  var _options$onBeforeChan, _options$onChanged;
928
924
  if (value === source) return;
929
925
  const old = source;
@@ -935,26 +931,26 @@ function refWithControl(initial, options = {}) {
935
931
  /**
936
932
  * Get the value without tracked in the reactivity system
937
933
  */
938
- const untrackedGet = () => get$1(false);
934
+ const untrackedGet = () => get(false);
939
935
  /**
940
936
  * Set the value without triggering the reactivity system
941
937
  */
942
- const silentSet = (v) => set$1(v, false);
938
+ const silentSet = (v) => set(v, false);
943
939
  /**
944
940
  * Get the value without tracked in the reactivity system.
945
941
  *
946
942
  * Alias for `untrackedGet()`
947
943
  */
948
- const peek = () => get$1(false);
944
+ const peek = () => get(false);
949
945
  /**
950
946
  * Set the value without triggering the reactivity system
951
947
  *
952
948
  * Alias for `silentSet(v)`
953
949
  */
954
- const lay = (v) => set$1(v, false);
955
- return extendRef(ref$1, {
956
- get: get$1,
957
- set: set$1,
950
+ const lay = (v) => set(v, false);
951
+ return extendRef(ref, {
952
+ get,
953
+ set,
958
954
  untrackedGet,
959
955
  silentSet,
960
956
  peek,
@@ -963,7 +959,6 @@ function refWithControl(initial, options = {}) {
963
959
  }
964
960
  /** @deprecated use `refWithControl` instead */
965
961
  const controlledRef = refWithControl;
966
-
967
962
  //#endregion
968
963
  //#region set/index.ts
969
964
  /**
@@ -971,27 +966,25 @@ const controlledRef = refWithControl;
971
966
  */
972
967
  function set(...args) {
973
968
  if (args.length === 2) {
974
- const [ref$1, value] = args;
975
- ref$1.value = value;
969
+ const [ref, value] = args;
970
+ ref.value = value;
976
971
  }
977
972
  if (args.length === 3) {
978
973
  const [target, key, value] = args;
979
974
  target[key] = value;
980
975
  }
981
976
  }
982
-
983
977
  //#endregion
984
978
  //#region watchWithFilter/index.ts
985
979
  function watchWithFilter(source, cb, options = {}) {
986
- const { eventFilter = bypassFilter,...watchOptions } = options;
980
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
987
981
  return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
988
982
  }
989
-
990
983
  //#endregion
991
984
  //#region watchPausable/index.ts
992
985
  /** @deprecated Use Vue's built-in `watch` instead. This function will be removed in future version. */
993
986
  function watchPausable(source, cb, options = {}) {
994
- const { eventFilter: filter, initialState = "active",...watchOptions } = options;
987
+ const { eventFilter: filter, initialState = "active", ...watchOptions } = options;
995
988
  const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
996
989
  return {
997
990
  stop: watchWithFilter(source, cb, {
@@ -1005,7 +998,6 @@ function watchPausable(source, cb, options = {}) {
1005
998
  }
1006
999
  /** @deprecated Use Vue's built-in `watch` instead. This function will be removed in future version. */
1007
1000
  const pausableWatch = watchPausable;
1008
-
1009
1001
  //#endregion
1010
1002
  //#region syncRef/index.ts
1011
1003
  /**
@@ -1045,7 +1037,6 @@ function syncRef(left, right, ...[options]) {
1045
1037
  };
1046
1038
  return stop;
1047
1039
  }
1048
-
1049
1040
  //#endregion
1050
1041
  //#region syncRefs/index.ts
1051
1042
  /**
@@ -1063,7 +1054,6 @@ function syncRefs(source, targets, options = {}) {
1063
1054
  immediate
1064
1055
  });
1065
1056
  }
1066
-
1067
1057
  //#endregion
1068
1058
  //#region toRefs/index.ts
1069
1059
  /**
@@ -1099,7 +1089,6 @@ function toRefs(objectRef, options = {}) {
1099
1089
  }));
1100
1090
  return result;
1101
1091
  }
1102
-
1103
1092
  //#endregion
1104
1093
  //#region tryOnBeforeMount/index.ts
1105
1094
  /**
@@ -1114,7 +1103,6 @@ function tryOnBeforeMount(fn, sync = true, target) {
1114
1103
  else if (sync) fn();
1115
1104
  else nextTick(fn);
1116
1105
  }
1117
-
1118
1106
  //#endregion
1119
1107
  //#region tryOnBeforeUnmount/index.ts
1120
1108
  /**
@@ -1126,7 +1114,6 @@ function tryOnBeforeMount(fn, sync = true, target) {
1126
1114
  function tryOnBeforeUnmount(fn, target) {
1127
1115
  if (getLifeCycleTarget(target)) onBeforeUnmount(fn, target);
1128
1116
  }
1129
-
1130
1117
  //#endregion
1131
1118
  //#region tryOnMounted/index.ts
1132
1119
  /**
@@ -1141,7 +1128,6 @@ function tryOnMounted(fn, sync = true, target) {
1141
1128
  else if (sync) fn();
1142
1129
  else nextTick(fn);
1143
1130
  }
1144
-
1145
1131
  //#endregion
1146
1132
  //#region tryOnUnmounted/index.ts
1147
1133
  /**
@@ -1153,7 +1139,6 @@ function tryOnMounted(fn, sync = true, target) {
1153
1139
  function tryOnUnmounted(fn, target) {
1154
1140
  if (getLifeCycleTarget(target)) onUnmounted(fn, target);
1155
1141
  }
1156
-
1157
1142
  //#endregion
1158
1143
  //#region until/index.ts
1159
1144
  function createUntil(r, isNot = false) {
@@ -1252,7 +1237,6 @@ function createUntil(r, isNot = false) {
1252
1237
  function until(r) {
1253
1238
  return createUntil(r);
1254
1239
  }
1255
-
1256
1240
  //#endregion
1257
1241
  //#region useArrayDifference/index.ts
1258
1242
  function defaultComparator(value, othVal) {
@@ -1282,7 +1266,6 @@ function useArrayDifference(...args) {
1282
1266
  return computed(() => symmetric ? [...toValue(diff1), ...toValue(diff2)] : toValue(diff1));
1283
1267
  } else return diff1;
1284
1268
  }
1285
-
1286
1269
  //#endregion
1287
1270
  //#region useArrayEvery/index.ts
1288
1271
  /**
@@ -1299,7 +1282,6 @@ function useArrayDifference(...args) {
1299
1282
  function useArrayEvery(list, fn) {
1300
1283
  return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
1301
1284
  }
1302
-
1303
1285
  //#endregion
1304
1286
  //#region useArrayFilter/index.ts
1305
1287
  /**
@@ -1316,7 +1298,6 @@ function useArrayEvery(list, fn) {
1316
1298
  function useArrayFilter(list, fn) {
1317
1299
  return computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
1318
1300
  }
1319
-
1320
1301
  //#endregion
1321
1302
  //#region useArrayFind/index.ts
1322
1303
  /**
@@ -1333,7 +1314,6 @@ function useArrayFilter(list, fn) {
1333
1314
  function useArrayFind(list, fn) {
1334
1315
  return computed(() => toValue(toValue(list).find((element, index, array) => fn(toValue(element), index, array))));
1335
1316
  }
1336
-
1337
1317
  //#endregion
1338
1318
  //#region useArrayFindIndex/index.ts
1339
1319
  /**
@@ -1350,7 +1330,6 @@ function useArrayFind(list, fn) {
1350
1330
  function useArrayFindIndex(list, fn) {
1351
1331
  return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
1352
1332
  }
1353
-
1354
1333
  //#endregion
1355
1334
  //#region useArrayFindLast/index.ts
1356
1335
  function findLast(arr, cb) {
@@ -1371,7 +1350,6 @@ function findLast(arr, cb) {
1371
1350
  function useArrayFindLast(list, fn) {
1372
1351
  return computed(() => toValue(!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))));
1373
1352
  }
1374
-
1375
1353
  //#endregion
1376
1354
  //#region useArrayIncludes/index.ts
1377
1355
  function isArrayIncludesOptions(obj) {
@@ -1399,12 +1377,11 @@ function useArrayIncludes(...args) {
1399
1377
  }
1400
1378
  if (typeof comparator === "string") {
1401
1379
  const key = comparator;
1402
- comparator = (element, value$1) => element[key] === toValue(value$1);
1380
+ comparator = (element, value) => element[key] === toValue(value);
1403
1381
  }
1404
- comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === toValue(value$1));
1382
+ comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value) => element === toValue(value));
1405
1383
  return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))));
1406
1384
  }
1407
-
1408
1385
  //#endregion
1409
1386
  //#region useArrayJoin/index.ts
1410
1387
  /**
@@ -1421,7 +1398,6 @@ function useArrayIncludes(...args) {
1421
1398
  function useArrayJoin(list, separator) {
1422
1399
  return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1423
1400
  }
1424
-
1425
1401
  //#endregion
1426
1402
  //#region useArrayMap/index.ts
1427
1403
  /**
@@ -1438,7 +1414,6 @@ function useArrayJoin(list, separator) {
1438
1414
  function useArrayMap(list, fn) {
1439
1415
  return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1440
1416
  }
1441
-
1442
1417
  //#endregion
1443
1418
  //#region useArrayReduce/index.ts
1444
1419
  /**
@@ -1460,7 +1435,6 @@ function useArrayReduce(list, reducer, ...args) {
1460
1435
  return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
1461
1436
  });
1462
1437
  }
1463
-
1464
1438
  //#endregion
1465
1439
  //#region useArraySome/index.ts
1466
1440
  /**
@@ -1477,7 +1451,6 @@ function useArrayReduce(list, reducer, ...args) {
1477
1451
  function useArraySome(list, fn) {
1478
1452
  return computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1479
1453
  }
1480
-
1481
1454
  //#endregion
1482
1455
  //#region useArrayUnique/index.ts
1483
1456
  function uniq(array) {
@@ -1504,7 +1477,6 @@ function useArrayUnique(list, compareFn) {
1504
1477
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1505
1478
  });
1506
1479
  }
1507
-
1508
1480
  //#endregion
1509
1481
  //#region useCounter/index.ts
1510
1482
  /**
@@ -1520,22 +1492,21 @@ function useCounter(initialValue = 0, options = {}) {
1520
1492
  const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options;
1521
1493
  const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1522
1494
  const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1523
- const get$1 = () => count.value;
1524
- const set$1 = (val) => count.value = Math.max(min, Math.min(max, val));
1495
+ const get = () => count.value;
1496
+ const set = (val) => count.value = Math.max(min, Math.min(max, val));
1525
1497
  const reset = (val = _initialValue) => {
1526
1498
  _initialValue = val;
1527
- return set$1(val);
1499
+ return set(val);
1528
1500
  };
1529
1501
  return {
1530
1502
  count: shallowReadonly(count),
1531
1503
  inc,
1532
1504
  dec,
1533
- get: get$1,
1534
- set: set$1,
1505
+ get,
1506
+ set,
1535
1507
  reset
1536
1508
  };
1537
1509
  }
1538
-
1539
1510
  //#endregion
1540
1511
  //#region useDateFormat/index.ts
1541
1512
  const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
@@ -1640,7 +1611,6 @@ function normalizeDate(date) {
1640
1611
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1641
1612
  return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1642
1613
  }
1643
-
1644
1614
  //#endregion
1645
1615
  //#region useIntervalFn/index.ts
1646
1616
  /**
@@ -1684,7 +1654,6 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1684
1654
  resume
1685
1655
  };
1686
1656
  }
1687
-
1688
1657
  //#endregion
1689
1658
  //#region useInterval/index.ts
1690
1659
  function useInterval(interval = 1e3, options = {}) {
@@ -1705,7 +1674,6 @@ function useInterval(interval = 1e3, options = {}) {
1705
1674
  };
1706
1675
  else return shallowReadonly(counter);
1707
1676
  }
1708
-
1709
1677
  //#endregion
1710
1678
  //#region useLastChanged/index.ts
1711
1679
  function useLastChanged(source, options = {}) {
@@ -1714,7 +1682,6 @@ function useLastChanged(source, options = {}) {
1714
1682
  watch(source, () => ms.value = timestamp(), options);
1715
1683
  return shallowReadonly(ms);
1716
1684
  }
1717
-
1718
1685
  //#endregion
1719
1686
  //#region useTimeoutFn/index.ts
1720
1687
  /**
@@ -1759,7 +1726,6 @@ function useTimeoutFn(cb, interval, options = {}) {
1759
1726
  stop
1760
1727
  };
1761
1728
  }
1762
-
1763
1729
  //#endregion
1764
1730
  //#region useTimeout/index.ts
1765
1731
  function useTimeout(interval = 1e3, options = {}) {
@@ -1772,7 +1738,6 @@ function useTimeout(interval = 1e3, options = {}) {
1772
1738
  };
1773
1739
  else return ready;
1774
1740
  }
1775
-
1776
1741
  //#endregion
1777
1742
  //#region useToNumber/index.ts
1778
1743
  /**
@@ -1790,7 +1755,6 @@ function useToNumber(value, options = {}) {
1790
1755
  return resolved;
1791
1756
  });
1792
1757
  }
1793
-
1794
1758
  //#endregion
1795
1759
  //#region useToString/index.ts
1796
1760
  /**
@@ -1803,7 +1767,6 @@ function useToNumber(value, options = {}) {
1803
1767
  function useToString(value) {
1804
1768
  return computed(() => `${toValue(value)}`);
1805
1769
  }
1806
-
1807
1770
  //#endregion
1808
1771
  //#region useToggle/index.ts
1809
1772
  /**
@@ -1832,7 +1795,6 @@ function useToggle(initialValue = false, options = {}) {
1832
1795
  if (valueIsRef) return toggle;
1833
1796
  else return [_value, toggle];
1834
1797
  }
1835
-
1836
1798
  //#endregion
1837
1799
  //#region watchArray/index.ts
1838
1800
  /**
@@ -1854,16 +1816,15 @@ function watchArray(source, cb, options) {
1854
1816
  }
1855
1817
  if (!found) added.push(obj);
1856
1818
  }
1857
- const removed = oldList.filter((_$1, i) => !oldListRemains[i]);
1819
+ const removed = oldList.filter((_, i) => !oldListRemains[i]);
1858
1820
  cb(newList, oldList, added, removed, onCleanup);
1859
1821
  oldList = [...newList];
1860
1822
  }, options);
1861
1823
  }
1862
-
1863
1824
  //#endregion
1864
1825
  //#region watchAtMost/index.ts
1865
1826
  function watchAtMost(source, cb, options) {
1866
- const { count,...watchOptions } = options;
1827
+ const { count, ...watchOptions } = options;
1867
1828
  const current = shallowRef(0);
1868
1829
  const { stop, resume, pause } = watchWithFilter(source, (...args) => {
1869
1830
  current.value += 1;
@@ -1877,11 +1838,10 @@ function watchAtMost(source, cb, options) {
1877
1838
  pause
1878
1839
  };
1879
1840
  }
1880
-
1881
1841
  //#endregion
1882
1842
  //#region watchDebounced/index.ts
1883
1843
  function watchDebounced(source, cb, options = {}) {
1884
- const { debounce = 0, maxWait = void 0,...watchOptions } = options;
1844
+ const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
1885
1845
  return watchWithFilter(source, cb, {
1886
1846
  ...watchOptions,
1887
1847
  eventFilter: debounceFilter(debounce, { maxWait })
@@ -1889,7 +1849,6 @@ function watchDebounced(source, cb, options = {}) {
1889
1849
  }
1890
1850
  /** @deprecated use `watchDebounced` instead */
1891
1851
  const debouncedWatch = watchDebounced;
1892
-
1893
1852
  //#endregion
1894
1853
  //#region watchDeep/index.ts
1895
1854
  /**
@@ -1903,11 +1862,10 @@ function watchDeep(source, cb, options) {
1903
1862
  deep: true
1904
1863
  });
1905
1864
  }
1906
-
1907
1865
  //#endregion
1908
1866
  //#region watchIgnorable/index.ts
1909
1867
  function watchIgnorable(source, cb, options = {}) {
1910
- const { eventFilter = bypassFilter,...watchOptions } = options;
1868
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
1911
1869
  const filteredCb = createFilterWrapper(eventFilter, cb);
1912
1870
  let ignoreUpdates;
1913
1871
  let ignorePrevAsyncUpdates;
@@ -1960,7 +1918,6 @@ function watchIgnorable(source, cb, options = {}) {
1960
1918
  }
1961
1919
  /** @deprecated use `watchIgnorable` instead */
1962
1920
  const ignorableWatch = watchIgnorable;
1963
-
1964
1921
  //#endregion
1965
1922
  //#region watchImmediate/index.ts
1966
1923
  /**
@@ -1974,7 +1931,6 @@ function watchImmediate(source, cb, options) {
1974
1931
  immediate: true
1975
1932
  });
1976
1933
  }
1977
-
1978
1934
  //#endregion
1979
1935
  //#region watchOnce/index.ts
1980
1936
  /**
@@ -1988,11 +1944,10 @@ function watchOnce(source, cb, options) {
1988
1944
  once: true
1989
1945
  });
1990
1946
  }
1991
-
1992
1947
  //#endregion
1993
1948
  //#region watchThrottled/index.ts
1994
1949
  function watchThrottled(source, cb, options = {}) {
1995
- const { throttle = 0, trailing = true, leading = true,...watchOptions } = options;
1950
+ const { throttle = 0, trailing = true, leading = true, ...watchOptions } = options;
1996
1951
  return watchWithFilter(source, cb, {
1997
1952
  ...watchOptions,
1998
1953
  eventFilter: throttleFilter(throttle, trailing, leading)
@@ -2000,7 +1955,6 @@ function watchThrottled(source, cb, options = {}) {
2000
1955
  }
2001
1956
  /** @deprecated use `watchThrottled` instead */
2002
1957
  const throttledWatch = watchThrottled;
2003
-
2004
1958
  //#endregion
2005
1959
  //#region watchTriggerable/index.ts
2006
1960
  function watchTriggerable(source, cb, options = {}) {
@@ -2022,11 +1976,11 @@ function watchTriggerable(source, cb, options = {}) {
2022
1976
  const res = watchIgnorable(source, _cb, options);
2023
1977
  const { ignoreUpdates } = res;
2024
1978
  const trigger = () => {
2025
- let res$1;
1979
+ let res;
2026
1980
  ignoreUpdates(() => {
2027
- res$1 = _cb(getWatchSources(source), getOldValue(source));
1981
+ res = _cb(getWatchSources(source), getOldValue(source));
2028
1982
  });
2029
- return res$1;
1983
+ return res;
2030
1984
  };
2031
1985
  return {
2032
1986
  ...res,
@@ -2041,14 +1995,8 @@ function getWatchSources(sources) {
2041
1995
  function getOldValue(source) {
2042
1996
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
2043
1997
  }
2044
-
2045
1998
  //#endregion
2046
1999
  //#region whenever/index.ts
2047
- /**
2048
- * Shorthand for watching value to be truthy
2049
- *
2050
- * @see https://vueuse.org/whenever
2051
- */
2052
2000
  function whenever(source, cb, options) {
2053
2001
  const stop = watch(source, (v, ov, onInvalidate) => {
2054
2002
  if (v) {
@@ -2061,6 +2009,5 @@ function whenever(source, cb, options) {
2061
2009
  });
2062
2010
  return stop;
2063
2011
  }
2064
-
2065
2012
  //#endregion
2066
- export { assert, autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, debouncedRef, debouncedWatch, eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refManualReset, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, throttledRef, throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
2013
+ export { assert, autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, controlledComputed, controlledRef, createDisposableDirective, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, debouncedRef, debouncedWatch, eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refManualReset, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, throttledRef, throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };