@vueuse/shared 10.0.0-beta.2 → 10.0.0-beta.4

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
@@ -56,12 +56,13 @@ const rand = (min, max) => {
56
56
  max = Math.floor(max);
57
57
  return Math.floor(Math.random() * (max - min + 1)) + min;
58
58
  };
59
- const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
60
59
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
60
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
61
61
 
62
- function resolveUnref(r) {
62
+ function toValue(r) {
63
63
  return typeof r === "function" ? r() : vueDemi.unref(r);
64
64
  }
65
+ const resolveUnref = toValue;
65
66
 
66
67
  function createFilterWrapper(filter, fn) {
67
68
  function wrapper(...args) {
@@ -84,8 +85,8 @@ function debounceFilter(ms, options = {}) {
84
85
  lastRejector = noop;
85
86
  };
86
87
  const filter = (invoke) => {
87
- const duration = resolveUnref(ms);
88
- const maxDuration = resolveUnref(options.maxWait);
88
+ const duration = toValue(ms);
89
+ const maxDuration = toValue(options.maxWait);
89
90
  if (timer)
90
91
  _clearTimeout(timer);
91
92
  if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
@@ -130,7 +131,7 @@ function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = fa
130
131
  }
131
132
  };
132
133
  const filter = (_invoke) => {
133
- const duration = resolveUnref(ms);
134
+ const duration = toValue(ms);
134
135
  const elapsed = Date.now() - lastExec;
135
136
  const invoke = () => {
136
137
  return lastValue = _invoke();
@@ -244,6 +245,11 @@ function objectPick(obj, keys, omitUndefined = false) {
244
245
  return n;
245
246
  }, {});
246
247
  }
248
+ function objectOmit(obj, keys, omitUndefined = false) {
249
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
250
+ return (!omitUndefined || value !== void 0) && !keys.includes(key);
251
+ }));
252
+ }
247
253
  function objectEntries(obj) {
248
254
  return Object.entries(obj);
249
255
  }
@@ -291,7 +297,7 @@ function tryOnScopeDispose(fn) {
291
297
  }
292
298
 
293
299
  function createEventHook() {
294
- const fns = new Set();
300
+ const fns = /* @__PURE__ */ new Set();
295
301
  const off = (fn) => {
296
302
  fns.delete(fn);
297
303
  };
@@ -430,7 +436,7 @@ function makeDestructurable(obj, arr) {
430
436
  }
431
437
 
432
438
  function reactify(fn, options) {
433
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
439
+ const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
434
440
  return function(...args) {
435
441
  return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
436
442
  };
@@ -448,13 +454,15 @@ function reactifyObject(obj, optionsOrKeys = {}) {
448
454
  if (includeOwnProperties)
449
455
  keys.push(...Object.getOwnPropertyNames(obj));
450
456
  }
451
- return Object.fromEntries(keys.map((key) => {
452
- const value = obj[key];
453
- return [
454
- key,
455
- typeof value === "function" ? reactify(value.bind(obj), options) : value
456
- ];
457
- }));
457
+ return Object.fromEntries(
458
+ keys.map((key) => {
459
+ const value = obj[key];
460
+ return [
461
+ key,
462
+ typeof value === "function" ? reactify(value.bind(obj), options) : value
463
+ ];
464
+ })
465
+ );
458
466
  }
459
467
 
460
468
  function toReactive(objectRef) {
@@ -497,13 +505,23 @@ function reactiveComputed(fn) {
497
505
  function reactiveOmit(obj, ...keys) {
498
506
  const flatKeys = keys.flat();
499
507
  const predicate = flatKeys[0];
500
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(resolveUnref(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
508
+ return reactiveComputed(
509
+ () => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))
510
+ );
501
511
  }
502
512
 
513
+ function toRef(...args) {
514
+ if (args.length !== 1)
515
+ return vueDemi.toRef(...args);
516
+ const r = args[0];
517
+ return typeof r === "function" ? vueDemi.readonly(vueDemi.customRef(() => ({ get: r, set: noop }))) : vueDemi.ref(r);
518
+ }
519
+ const resolveRef = toRef;
520
+
503
521
  function reactivePick(obj, ...keys) {
504
522
  const flatKeys = keys.flat();
505
523
  const predicate = flatKeys[0];
506
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => predicate(resolveUnref(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, vueDemi.toRef(obj, k)])));
524
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
507
525
  }
508
526
 
509
527
  function refAutoReset(defaultValue, afterMs = 1e4) {
@@ -513,7 +531,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
513
531
  const resetAfter = () => setTimeout(() => {
514
532
  value = defaultValue;
515
533
  trigger();
516
- }, resolveUnref(afterMs));
534
+ }, toValue(afterMs));
517
535
  tryOnScopeDispose(() => {
518
536
  clearTimeout(timer);
519
537
  });
@@ -533,7 +551,10 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
533
551
  }
534
552
 
535
553
  function useDebounceFn(fn, ms = 200, options = {}) {
536
- return createFilterWrapper(debounceFilter(ms, options), fn);
554
+ return createFilterWrapper(
555
+ debounceFilter(ms, options),
556
+ fn
557
+ );
537
558
  }
538
559
 
539
560
  function refDebounced(value, ms = 200, options = {}) {
@@ -558,7 +579,10 @@ function refDefault(source, defaultValue) {
558
579
  }
559
580
 
560
581
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
561
- return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
582
+ return createFilterWrapper(
583
+ throttleFilter(ms, trailing, leading, rejectOnCancel),
584
+ fn
585
+ );
562
586
  }
563
587
 
564
588
  function refThrottled(value, delay = 200, trailing = true, leading = true) {
@@ -609,21 +633,21 @@ function refWithControl(initial, options = {}) {
609
633
  const silentSet = (v) => set(v, false);
610
634
  const peek = () => get(false);
611
635
  const lay = (v) => set(v, false);
612
- return extendRef(ref, {
613
- get,
614
- set,
615
- untrackedGet,
616
- silentSet,
617
- peek,
618
- lay
619
- }, { enumerable: true });
636
+ return extendRef(
637
+ ref,
638
+ {
639
+ get,
640
+ set,
641
+ untrackedGet,
642
+ silentSet,
643
+ peek,
644
+ lay
645
+ },
646
+ { enumerable: true }
647
+ );
620
648
  }
621
649
  const controlledRef = refWithControl;
622
650
 
623
- function resolveRef(r) {
624
- return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
625
- }
626
-
627
651
  function set(...args) {
628
652
  if (args.length === 2) {
629
653
  const [ref, value] = args;
@@ -653,10 +677,18 @@ function syncRef(left, right, options = {}) {
653
677
  const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
654
678
  const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
655
679
  if (direction === "both" || direction === "ltr") {
656
- watchLeft = vueDemi.watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
680
+ watchLeft = vueDemi.watch(
681
+ left,
682
+ (newValue) => right.value = transformLTR(newValue),
683
+ { flush, deep, immediate }
684
+ );
657
685
  }
658
686
  if (direction === "both" || direction === "rtl") {
659
- watchRight = vueDemi.watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
687
+ watchRight = vueDemi.watch(
688
+ right,
689
+ (newValue) => left.value = transformRTL(newValue),
690
+ { flush, deep, immediate }
691
+ );
660
692
  }
661
693
  return () => {
662
694
  watchLeft == null ? void 0 : watchLeft();
@@ -672,7 +704,11 @@ function syncRefs(source, targets, options = {}) {
672
704
  } = options;
673
705
  if (!Array.isArray(targets))
674
706
  targets = [targets];
675
- return vueDemi.watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
707
+ return vueDemi.watch(
708
+ source,
709
+ (newValue) => targets.forEach((target) => target.value = newValue),
710
+ { flush, deep, immediate }
711
+ );
676
712
  }
677
713
 
678
714
  var __defProp$9 = Object.defineProperty;
@@ -751,20 +787,26 @@ function createUntil(r, isNot = false) {
751
787
  function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
752
788
  let stop = null;
753
789
  const watcher = new Promise((resolve) => {
754
- stop = vueDemi.watch(r, (v) => {
755
- if (condition(v) !== isNot) {
756
- stop == null ? void 0 : stop();
757
- resolve(v);
790
+ stop = vueDemi.watch(
791
+ r,
792
+ (v) => {
793
+ if (condition(v) !== isNot) {
794
+ stop == null ? void 0 : stop();
795
+ resolve(v);
796
+ }
797
+ },
798
+ {
799
+ flush,
800
+ deep,
801
+ immediate: true
758
802
  }
759
- }, {
760
- flush,
761
- deep,
762
- immediate: true
763
- });
803
+ );
764
804
  });
765
805
  const promises = [watcher];
766
806
  if (timeout != null) {
767
- promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
807
+ promises.push(
808
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
809
+ );
768
810
  }
769
811
  return Promise.race(promises);
770
812
  }
@@ -774,23 +816,29 @@ function createUntil(r, isNot = false) {
774
816
  const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
775
817
  let stop = null;
776
818
  const watcher = new Promise((resolve) => {
777
- stop = vueDemi.watch([r, value], ([v1, v2]) => {
778
- if (isNot !== (v1 === v2)) {
779
- stop == null ? void 0 : stop();
780
- resolve(v1);
819
+ stop = vueDemi.watch(
820
+ [r, value],
821
+ ([v1, v2]) => {
822
+ if (isNot !== (v1 === v2)) {
823
+ stop == null ? void 0 : stop();
824
+ resolve(v1);
825
+ }
826
+ },
827
+ {
828
+ flush,
829
+ deep,
830
+ immediate: true
781
831
  }
782
- }, {
783
- flush,
784
- deep,
785
- immediate: true
786
- });
832
+ );
787
833
  });
788
834
  const promises = [watcher];
789
835
  if (timeout != null) {
790
- promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
791
- stop == null ? void 0 : stop();
792
- return resolveUnref(r);
793
- }));
836
+ promises.push(
837
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
838
+ stop == null ? void 0 : stop();
839
+ return toValue(r);
840
+ })
841
+ );
794
842
  }
795
843
  return Promise.race(promises);
796
844
  }
@@ -809,7 +857,7 @@ function createUntil(r, isNot = false) {
809
857
  function toContains(value, options) {
810
858
  return toMatch((v) => {
811
859
  const array = Array.from(v);
812
- return array.includes(value) || array.includes(resolveUnref(value));
860
+ return array.includes(value) || array.includes(toValue(value));
813
861
  }, options);
814
862
  }
815
863
  function changed(options) {
@@ -822,7 +870,7 @@ function createUntil(r, isNot = false) {
822
870
  return count >= n;
823
871
  }, options);
824
872
  }
825
- if (Array.isArray(resolveUnref(r))) {
873
+ if (Array.isArray(toValue(r))) {
826
874
  const instance = {
827
875
  toMatch,
828
876
  toContains,
@@ -854,7 +902,9 @@ function until(r) {
854
902
  return createUntil(r);
855
903
  }
856
904
 
857
- const defaultComparator = (value, othVal) => value === othVal;
905
+ function defaultComparator(value, othVal) {
906
+ return value === othVal;
907
+ }
858
908
  function useArrayDifference(...args) {
859
909
  var _a;
860
910
  const list = args[0];
@@ -864,23 +914,27 @@ function useArrayDifference(...args) {
864
914
  const key = compareFn;
865
915
  compareFn = (value, othVal) => value[key] === othVal[key];
866
916
  }
867
- return vueDemi.computed(() => resolveUnref(list).filter((x) => resolveUnref(values).findIndex((y) => compareFn(x, y)) === -1));
917
+ return vueDemi.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
868
918
  }
869
919
 
870
920
  function useArrayEvery(list, fn) {
871
- return vueDemi.computed(() => resolveUnref(list).every((element, index, array) => fn(resolveUnref(element), index, array)));
921
+ return vueDemi.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
872
922
  }
873
923
 
874
924
  function useArrayFilter(list, fn) {
875
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).filter(fn));
925
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
876
926
  }
877
927
 
878
928
  function useArrayFind(list, fn) {
879
- return vueDemi.computed(() => resolveUnref(resolveUnref(list).find((element, index, array) => fn(resolveUnref(element), index, array))));
929
+ return vueDemi.computed(
930
+ () => toValue(
931
+ toValue(list).find((element, index, array) => fn(toValue(element), index, array))
932
+ )
933
+ );
880
934
  }
881
935
 
882
936
  function useArrayFindIndex(list, fn) {
883
- return vueDemi.computed(() => resolveUnref(list).findIndex((element, index, array) => fn(resolveUnref(element), index, array)));
937
+ return vueDemi.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
884
938
  }
885
939
 
886
940
  function findLast(arr, cb) {
@@ -892,7 +946,11 @@ function findLast(arr, cb) {
892
946
  return void 0;
893
947
  }
894
948
  function useArrayFindLast(list, fn) {
895
- return vueDemi.computed(() => resolveUnref(!Array.prototype.findLast ? findLast(resolveUnref(list), (element, index, array) => fn(resolveUnref(element), index, array)) : resolveUnref(list).findLast((element, index, array) => fn(resolveUnref(element), index, array))));
949
+ return vueDemi.computed(
950
+ () => toValue(
951
+ !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))
952
+ )
953
+ );
896
954
  }
897
955
 
898
956
  function isArrayIncludesOptions(obj) {
@@ -910,30 +968,34 @@ function useArrayIncludes(...args) {
910
968
  }
911
969
  if (typeof comparator === "string") {
912
970
  const key = comparator;
913
- comparator = (element, value2) => element[key] === resolveUnref(value2);
971
+ comparator = (element, value2) => element[key] === toValue(value2);
914
972
  }
915
- comparator = comparator != null ? comparator : (element, value2) => element === resolveUnref(value2);
916
- return vueDemi.computed(() => resolveUnref(list).slice(formIndex).some((element, index, array) => comparator(resolveUnref(element), resolveUnref(value), index, resolveUnref(array))));
973
+ comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
974
+ return vueDemi.computed(
975
+ () => toValue(list).slice(formIndex).some(
976
+ (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
977
+ )
978
+ );
917
979
  }
918
980
 
919
981
  function useArrayJoin(list, separator) {
920
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).join(resolveUnref(separator)));
982
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
921
983
  }
922
984
 
923
985
  function useArrayMap(list, fn) {
924
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).map(fn));
986
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
925
987
  }
926
988
 
927
989
  function useArrayReduce(list, reducer, ...args) {
928
- const reduceCallback = (sum, value, index) => reducer(resolveUnref(sum), resolveUnref(value), index);
990
+ const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
929
991
  return vueDemi.computed(() => {
930
- const resolved = resolveUnref(list);
931
- return args.length ? resolved.reduce(reduceCallback, resolveUnref(args[0])) : resolved.reduce(reduceCallback);
992
+ const resolved = toValue(list);
993
+ return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
932
994
  });
933
995
  }
934
996
 
935
997
  function useArraySome(list, fn) {
936
- return vueDemi.computed(() => resolveUnref(list).some((element, index, array) => fn(resolveUnref(element), index, array)));
998
+ return vueDemi.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
937
999
  }
938
1000
 
939
1001
  function uniq(array) {
@@ -948,7 +1010,7 @@ function uniqueElementsBy(array, fn) {
948
1010
  }
949
1011
  function useArrayUnique(list, compareFn) {
950
1012
  return vueDemi.computed(() => {
951
- const resolvedList = resolveUnref(list).map((element) => resolveUnref(element));
1013
+ const resolvedList = toValue(list).map((element) => toValue(element));
952
1014
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
953
1015
  });
954
1016
  }
@@ -972,13 +1034,13 @@ function useCounter(initialValue = 0, options = {}) {
972
1034
 
973
1035
  const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
974
1036
  const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
975
- const defaultMeridiem = (hours, minutes, isLowercase, hasPeriod) => {
1037
+ function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
976
1038
  let m = hours < 12 ? "AM" : "PM";
977
1039
  if (hasPeriod)
978
1040
  m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
979
1041
  return isLowercase ? m.toLowerCase() : m;
980
- };
981
- const formatDate = (date, formatStr, options = {}) => {
1042
+ }
1043
+ function formatDate(date, formatStr, options = {}) {
982
1044
  var _a;
983
1045
  const years = date.getFullYear();
984
1046
  const month = date.getMonth();
@@ -1017,12 +1079,12 @@ const formatDate = (date, formatStr, options = {}) => {
1017
1079
  aa: () => meridiem(hours, minutes, true, true)
1018
1080
  };
1019
1081
  return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match]());
1020
- };
1021
- const normalizeDate = (date) => {
1082
+ }
1083
+ function normalizeDate(date) {
1022
1084
  if (date === null)
1023
- return new Date(NaN);
1085
+ return /* @__PURE__ */ new Date(NaN);
1024
1086
  if (date === void 0)
1025
- return new Date();
1087
+ return /* @__PURE__ */ new Date();
1026
1088
  if (date instanceof Date)
1027
1089
  return new Date(date);
1028
1090
  if (typeof date === "string" && !/Z$/i.test(date)) {
@@ -1034,9 +1096,9 @@ const normalizeDate = (date) => {
1034
1096
  }
1035
1097
  }
1036
1098
  return new Date(date);
1037
- };
1099
+ }
1038
1100
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1039
- return vueDemi.computed(() => formatDate(normalizeDate(resolveUnref(date)), resolveUnref(formatStr), options));
1101
+ return vueDemi.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1040
1102
  }
1041
1103
 
1042
1104
  function useIntervalFn(cb, interval = 1e3, options = {}) {
@@ -1057,7 +1119,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1057
1119
  clean();
1058
1120
  }
1059
1121
  function resume() {
1060
- const intervalValue = resolveUnref(interval);
1122
+ const intervalValue = toValue(interval);
1061
1123
  if (intervalValue <= 0)
1062
1124
  return;
1063
1125
  isActive.value = true;
@@ -1110,10 +1172,14 @@ function useInterval(interval = 1e3, options = {}) {
1110
1172
  const reset = () => {
1111
1173
  counter.value = 0;
1112
1174
  };
1113
- const controls = useIntervalFn(callback ? () => {
1114
- update();
1115
- callback(counter.value);
1116
- } : update, interval, { immediate });
1175
+ const controls = useIntervalFn(
1176
+ callback ? () => {
1177
+ update();
1178
+ callback(counter.value);
1179
+ } : update,
1180
+ interval,
1181
+ { immediate }
1182
+ );
1117
1183
  if (exposeControls) {
1118
1184
  return __spreadValues$8({
1119
1185
  counter,
@@ -1127,7 +1193,11 @@ function useInterval(interval = 1e3, options = {}) {
1127
1193
  function useLastChanged(source, options = {}) {
1128
1194
  var _a;
1129
1195
  const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
1130
- vueDemi.watch(source, () => ms.value = timestamp(), options);
1196
+ vueDemi.watch(
1197
+ source,
1198
+ () => ms.value = timestamp(),
1199
+ options
1200
+ );
1131
1201
  return ms;
1132
1202
  }
1133
1203
 
@@ -1154,7 +1224,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1154
1224
  isPending.value = false;
1155
1225
  timer = null;
1156
1226
  cb(...args);
1157
- }, resolveUnref(interval));
1227
+ }, toValue(interval));
1158
1228
  }
1159
1229
  if (immediate) {
1160
1230
  isPending.value = true;
@@ -1190,7 +1260,11 @@ function useTimeout(interval = 1e3, options = {}) {
1190
1260
  controls: exposeControls = false,
1191
1261
  callback
1192
1262
  } = options;
1193
- const controls = useTimeoutFn(callback != null ? callback : noop, interval, options);
1263
+ const controls = useTimeoutFn(
1264
+ callback != null ? callback : noop,
1265
+ interval,
1266
+ options
1267
+ );
1194
1268
  const ready = vueDemi.computed(() => !controls.isPending.value);
1195
1269
  if (exposeControls) {
1196
1270
  return __spreadValues$7({
@@ -1208,7 +1282,7 @@ function useToNumber(value, options = {}) {
1208
1282
  nanToZero
1209
1283
  } = options;
1210
1284
  return vueDemi.computed(() => {
1211
- let resolved = resolveUnref(value);
1285
+ let resolved = toValue(value);
1212
1286
  if (typeof resolved === "string")
1213
1287
  resolved = Number[method](resolved, radix);
1214
1288
  if (nanToZero && isNaN(resolved))
@@ -1218,7 +1292,7 @@ function useToNumber(value, options = {}) {
1218
1292
  }
1219
1293
 
1220
1294
  function useToString(value) {
1221
- return vueDemi.computed(() => `${resolveUnref(value)}`);
1295
+ return vueDemi.computed(() => `${toValue(value)}`);
1222
1296
  }
1223
1297
 
1224
1298
  function useToggle(initialValue = false, options = {}) {
@@ -1233,8 +1307,8 @@ function useToggle(initialValue = false, options = {}) {
1233
1307
  _value.value = value;
1234
1308
  return _value.value;
1235
1309
  } else {
1236
- const truthy = resolveUnref(truthyValue);
1237
- _value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
1310
+ const truthy = toValue(truthyValue);
1311
+ _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
1238
1312
  return _value.value;
1239
1313
  }
1240
1314
  }
@@ -1246,7 +1320,7 @@ function useToggle(initialValue = false, options = {}) {
1246
1320
 
1247
1321
  function watchArray(source, cb, options) {
1248
1322
  let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1249
- ...source instanceof Function ? source() : Array.isArray(source) ? source : vueDemi.unref(source)
1323
+ ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1250
1324
  ];
1251
1325
  return vueDemi.watch(source, (newList, _, onCleanup) => {
1252
1326
  const oldListRemains = new Array(oldList.length);
@@ -1290,7 +1364,14 @@ function watchWithFilter(source, cb, options = {}) {
1290
1364
  } = _a, watchOptions = __objRest$5(_a, [
1291
1365
  "eventFilter"
1292
1366
  ]);
1293
- return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
1367
+ return vueDemi.watch(
1368
+ source,
1369
+ createFilterWrapper(
1370
+ eventFilter,
1371
+ cb
1372
+ ),
1373
+ watchOptions
1374
+ );
1294
1375
  }
1295
1376
 
1296
1377
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
@@ -1315,12 +1396,16 @@ function watchAtMost(source, cb, options) {
1315
1396
  "count"
1316
1397
  ]);
1317
1398
  const current = vueDemi.ref(0);
1318
- const stop = watchWithFilter(source, (...args) => {
1319
- current.value += 1;
1320
- if (current.value >= resolveUnref(count))
1321
- vueDemi.nextTick(() => stop());
1322
- cb(...args);
1323
- }, watchOptions);
1399
+ const stop = watchWithFilter(
1400
+ source,
1401
+ (...args) => {
1402
+ current.value += 1;
1403
+ if (current.value >= toValue(count))
1404
+ vueDemi.nextTick(() => stop());
1405
+ cb(...args);
1406
+ },
1407
+ watchOptions
1408
+ );
1324
1409
  return { count: current, stop };
1325
1410
  }
1326
1411
 
@@ -1363,9 +1448,13 @@ function watchDebounced(source, cb, options = {}) {
1363
1448
  "debounce",
1364
1449
  "maxWait"
1365
1450
  ]);
1366
- return watchWithFilter(source, cb, __spreadProps$6(__spreadValues$6({}, watchOptions), {
1367
- eventFilter: debounceFilter(debounce, { maxWait })
1368
- }));
1451
+ return watchWithFilter(
1452
+ source,
1453
+ cb,
1454
+ __spreadProps$6(__spreadValues$6({}, watchOptions), {
1455
+ eventFilter: debounceFilter(debounce, { maxWait })
1456
+ })
1457
+ );
1369
1458
  }
1370
1459
 
1371
1460
  var __defProp$5 = Object.defineProperty;
@@ -1388,12 +1477,13 @@ var __spreadValues$5 = (a, b) => {
1388
1477
  };
1389
1478
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1390
1479
  function watchDeep(source, cb, options) {
1391
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1392
- if (v)
1393
- cb(v, ov, onInvalidate);
1394
- }, __spreadProps$5(__spreadValues$5({}, options), {
1395
- deep: true
1396
- }));
1480
+ return vueDemi.watch(
1481
+ source,
1482
+ cb,
1483
+ __spreadProps$5(__spreadValues$5({}, options), {
1484
+ deep: true
1485
+ })
1486
+ );
1397
1487
  }
1398
1488
 
1399
1489
  var __defProp$4 = Object.defineProperty;
@@ -1433,7 +1523,10 @@ function watchIgnorable(source, cb, options = {}) {
1433
1523
  } = _a, watchOptions = __objRest$2(_a, [
1434
1524
  "eventFilter"
1435
1525
  ]);
1436
- const filteredCb = createFilterWrapper(eventFilter, cb);
1526
+ const filteredCb = createFilterWrapper(
1527
+ eventFilter,
1528
+ cb
1529
+ );
1437
1530
  let ignoreUpdates;
1438
1531
  let ignorePrevAsyncUpdates;
1439
1532
  let stop;
@@ -1446,10 +1539,14 @@ function watchIgnorable(source, cb, options = {}) {
1446
1539
  updater();
1447
1540
  ignore.value = false;
1448
1541
  };
1449
- stop = vueDemi.watch(source, (...args) => {
1450
- if (!ignore.value)
1451
- filteredCb(...args);
1452
- }, watchOptions);
1542
+ stop = vueDemi.watch(
1543
+ source,
1544
+ (...args) => {
1545
+ if (!ignore.value)
1546
+ filteredCb(...args);
1547
+ },
1548
+ watchOptions
1549
+ );
1453
1550
  } else {
1454
1551
  const disposables = [];
1455
1552
  const ignoreCounter = vueDemi.ref(0);
@@ -1457,22 +1554,34 @@ function watchIgnorable(source, cb, options = {}) {
1457
1554
  ignorePrevAsyncUpdates = () => {
1458
1555
  ignoreCounter.value = syncCounter.value;
1459
1556
  };
1460
- disposables.push(vueDemi.watch(source, () => {
1461
- syncCounter.value++;
1462
- }, __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })));
1557
+ disposables.push(
1558
+ vueDemi.watch(
1559
+ source,
1560
+ () => {
1561
+ syncCounter.value++;
1562
+ },
1563
+ __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })
1564
+ )
1565
+ );
1463
1566
  ignoreUpdates = (updater) => {
1464
1567
  const syncCounterPrev = syncCounter.value;
1465
1568
  updater();
1466
1569
  ignoreCounter.value += syncCounter.value - syncCounterPrev;
1467
1570
  };
1468
- disposables.push(vueDemi.watch(source, (...args) => {
1469
- const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1470
- ignoreCounter.value = 0;
1471
- syncCounter.value = 0;
1472
- if (ignore)
1473
- return;
1474
- filteredCb(...args);
1475
- }, watchOptions));
1571
+ disposables.push(
1572
+ vueDemi.watch(
1573
+ source,
1574
+ (...args) => {
1575
+ const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1576
+ ignoreCounter.value = 0;
1577
+ syncCounter.value = 0;
1578
+ if (ignore)
1579
+ return;
1580
+ filteredCb(...args);
1581
+ },
1582
+ watchOptions
1583
+ )
1584
+ );
1476
1585
  stop = () => {
1477
1586
  disposables.forEach((fn) => fn());
1478
1587
  };
@@ -1500,12 +1609,13 @@ var __spreadValues$3 = (a, b) => {
1500
1609
  };
1501
1610
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1502
1611
  function watchImmediate(source, cb, options) {
1503
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1504
- if (v)
1505
- cb(v, ov, onInvalidate);
1506
- }, __spreadProps$3(__spreadValues$3({}, options), {
1507
- immediate: true
1508
- }));
1612
+ return vueDemi.watch(
1613
+ source,
1614
+ cb,
1615
+ __spreadProps$3(__spreadValues$3({}, options), {
1616
+ immediate: true
1617
+ })
1618
+ );
1509
1619
  }
1510
1620
 
1511
1621
  function watchOnce(source, cb, options) {
@@ -1553,9 +1663,13 @@ function watchPausable(source, cb, options = {}) {
1553
1663
  "eventFilter"
1554
1664
  ]);
1555
1665
  const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1556
- const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$2({}, watchOptions), {
1557
- eventFilter
1558
- }));
1666
+ const stop = watchWithFilter(
1667
+ source,
1668
+ cb,
1669
+ __spreadProps$2(__spreadValues$2({}, watchOptions), {
1670
+ eventFilter
1671
+ })
1672
+ );
1559
1673
  return { stop, pause, resume, isActive };
1560
1674
  }
1561
1675
 
@@ -1600,9 +1714,13 @@ function watchThrottled(source, cb, options = {}) {
1600
1714
  "trailing",
1601
1715
  "leading"
1602
1716
  ]);
1603
- return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
1604
- eventFilter: throttleFilter(throttle, trailing, leading)
1605
- }));
1717
+ return watchWithFilter(
1718
+ source,
1719
+ cb,
1720
+ __spreadProps$1(__spreadValues$1({}, watchOptions), {
1721
+ eventFilter: throttleFilter(throttle, trailing, leading)
1722
+ })
1723
+ );
1606
1724
  }
1607
1725
 
1608
1726
  var __defProp = Object.defineProperty;
@@ -1657,21 +1775,22 @@ function getWatchSources(sources) {
1657
1775
  if (vueDemi.isReactive(sources))
1658
1776
  return sources;
1659
1777
  if (Array.isArray(sources))
1660
- return sources.map((item) => getOneWatchSource(item));
1661
- return getOneWatchSource(sources);
1662
- }
1663
- function getOneWatchSource(source) {
1664
- return typeof source === "function" ? source() : vueDemi.unref(source);
1778
+ return sources.map((item) => toValue(item));
1779
+ return toValue(sources);
1665
1780
  }
1666
1781
  function getOldValue(source) {
1667
1782
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
1668
1783
  }
1669
1784
 
1670
1785
  function whenever(source, cb, options) {
1671
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1672
- if (v)
1673
- cb(v, ov, onInvalidate);
1674
- }, options);
1786
+ return vueDemi.watch(
1787
+ source,
1788
+ (v, ov, onInvalidate) => {
1789
+ if (v)
1790
+ cb(v, ov, onInvalidate);
1791
+ },
1792
+ options
1793
+ );
1675
1794
  }
1676
1795
 
1677
1796
  exports.__onlyVue27Plus = __onlyVue27Plus;
@@ -1720,6 +1839,7 @@ exports.noop = noop;
1720
1839
  exports.normalizeDate = normalizeDate;
1721
1840
  exports.now = now;
1722
1841
  exports.objectEntries = objectEntries;
1842
+ exports.objectOmit = objectOmit;
1723
1843
  exports.objectPick = objectPick;
1724
1844
  exports.pausableFilter = pausableFilter;
1725
1845
  exports.pausableWatch = watchPausable;
@@ -1745,7 +1865,9 @@ exports.throttledRef = refThrottled;
1745
1865
  exports.throttledWatch = watchThrottled;
1746
1866
  exports.timestamp = timestamp;
1747
1867
  exports.toReactive = toReactive;
1868
+ exports.toRef = toRef;
1748
1869
  exports.toRefs = toRefs;
1870
+ exports.toValue = toValue;
1749
1871
  exports.tryOnBeforeMount = tryOnBeforeMount;
1750
1872
  exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
1751
1873
  exports.tryOnMounted = tryOnMounted;