@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.iife.js CHANGED
@@ -169,12 +169,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
169
169
  max = Math.floor(max);
170
170
  return Math.floor(Math.random() * (max - min + 1)) + min;
171
171
  };
172
- const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
173
172
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
173
+ const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
174
174
 
175
- function resolveUnref(r) {
175
+ function toValue(r) {
176
176
  return typeof r === "function" ? r() : vueDemi.unref(r);
177
177
  }
178
+ const resolveUnref = toValue;
178
179
 
179
180
  function createFilterWrapper(filter, fn) {
180
181
  function wrapper(...args) {
@@ -197,8 +198,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
197
198
  lastRejector = noop;
198
199
  };
199
200
  const filter = (invoke) => {
200
- const duration = resolveUnref(ms);
201
- const maxDuration = resolveUnref(options.maxWait);
201
+ const duration = toValue(ms);
202
+ const maxDuration = toValue(options.maxWait);
202
203
  if (timer)
203
204
  _clearTimeout(timer);
204
205
  if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
@@ -243,7 +244,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
243
244
  }
244
245
  };
245
246
  const filter = (_invoke) => {
246
- const duration = resolveUnref(ms);
247
+ const duration = toValue(ms);
247
248
  const elapsed = Date.now() - lastExec;
248
249
  const invoke = () => {
249
250
  return lastValue = _invoke();
@@ -357,6 +358,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
357
358
  return n;
358
359
  }, {});
359
360
  }
361
+ function objectOmit(obj, keys, omitUndefined = false) {
362
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
363
+ return (!omitUndefined || value !== void 0) && !keys.includes(key);
364
+ }));
365
+ }
360
366
  function objectEntries(obj) {
361
367
  return Object.entries(obj);
362
368
  }
@@ -404,7 +410,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
404
410
  }
405
411
 
406
412
  function createEventHook() {
407
- const fns = new Set();
413
+ const fns = /* @__PURE__ */ new Set();
408
414
  const off = (fn) => {
409
415
  fns.delete(fn);
410
416
  };
@@ -543,7 +549,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
543
549
  }
544
550
 
545
551
  function reactify(fn, options) {
546
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
552
+ const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
547
553
  return function(...args) {
548
554
  return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
549
555
  };
@@ -561,13 +567,15 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
561
567
  if (includeOwnProperties)
562
568
  keys.push(...Object.getOwnPropertyNames(obj));
563
569
  }
564
- return Object.fromEntries(keys.map((key) => {
565
- const value = obj[key];
566
- return [
567
- key,
568
- typeof value === "function" ? reactify(value.bind(obj), options) : value
569
- ];
570
- }));
570
+ return Object.fromEntries(
571
+ keys.map((key) => {
572
+ const value = obj[key];
573
+ return [
574
+ key,
575
+ typeof value === "function" ? reactify(value.bind(obj), options) : value
576
+ ];
577
+ })
578
+ );
571
579
  }
572
580
 
573
581
  function toReactive(objectRef) {
@@ -610,13 +618,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
610
618
  function reactiveOmit(obj, ...keys) {
611
619
  const flatKeys = keys.flat();
612
620
  const predicate = flatKeys[0];
613
- 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]))));
621
+ return reactiveComputed(
622
+ () => 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])))
623
+ );
614
624
  }
615
625
 
626
+ function toRef(...args) {
627
+ if (args.length !== 1)
628
+ return vueDemi.toRef(...args);
629
+ const r = args[0];
630
+ return typeof r === "function" ? vueDemi.readonly(vueDemi.customRef(() => ({ get: r, set: noop }))) : vueDemi.ref(r);
631
+ }
632
+ const resolveRef = toRef;
633
+
616
634
  function reactivePick(obj, ...keys) {
617
635
  const flatKeys = keys.flat();
618
636
  const predicate = flatKeys[0];
619
- 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)])));
637
+ 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)])));
620
638
  }
621
639
 
622
640
  function refAutoReset(defaultValue, afterMs = 1e4) {
@@ -626,7 +644,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
626
644
  const resetAfter = () => setTimeout(() => {
627
645
  value = defaultValue;
628
646
  trigger();
629
- }, resolveUnref(afterMs));
647
+ }, toValue(afterMs));
630
648
  tryOnScopeDispose(() => {
631
649
  clearTimeout(timer);
632
650
  });
@@ -646,7 +664,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
646
664
  }
647
665
 
648
666
  function useDebounceFn(fn, ms = 200, options = {}) {
649
- return createFilterWrapper(debounceFilter(ms, options), fn);
667
+ return createFilterWrapper(
668
+ debounceFilter(ms, options),
669
+ fn
670
+ );
650
671
  }
651
672
 
652
673
  function refDebounced(value, ms = 200, options = {}) {
@@ -671,7 +692,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
671
692
  }
672
693
 
673
694
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
674
- return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
695
+ return createFilterWrapper(
696
+ throttleFilter(ms, trailing, leading, rejectOnCancel),
697
+ fn
698
+ );
675
699
  }
676
700
 
677
701
  function refThrottled(value, delay = 200, trailing = true, leading = true) {
@@ -722,21 +746,21 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
722
746
  const silentSet = (v) => set(v, false);
723
747
  const peek = () => get(false);
724
748
  const lay = (v) => set(v, false);
725
- return extendRef(ref, {
726
- get,
727
- set,
728
- untrackedGet,
729
- silentSet,
730
- peek,
731
- lay
732
- }, { enumerable: true });
749
+ return extendRef(
750
+ ref,
751
+ {
752
+ get,
753
+ set,
754
+ untrackedGet,
755
+ silentSet,
756
+ peek,
757
+ lay
758
+ },
759
+ { enumerable: true }
760
+ );
733
761
  }
734
762
  const controlledRef = refWithControl;
735
763
 
736
- function resolveRef(r) {
737
- return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
738
- }
739
-
740
764
  function set(...args) {
741
765
  if (args.length === 2) {
742
766
  const [ref, value] = args;
@@ -766,10 +790,18 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
766
790
  const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
767
791
  const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
768
792
  if (direction === "both" || direction === "ltr") {
769
- watchLeft = vueDemi.watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
793
+ watchLeft = vueDemi.watch(
794
+ left,
795
+ (newValue) => right.value = transformLTR(newValue),
796
+ { flush, deep, immediate }
797
+ );
770
798
  }
771
799
  if (direction === "both" || direction === "rtl") {
772
- watchRight = vueDemi.watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
800
+ watchRight = vueDemi.watch(
801
+ right,
802
+ (newValue) => left.value = transformRTL(newValue),
803
+ { flush, deep, immediate }
804
+ );
773
805
  }
774
806
  return () => {
775
807
  watchLeft == null ? void 0 : watchLeft();
@@ -785,7 +817,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
785
817
  } = options;
786
818
  if (!Array.isArray(targets))
787
819
  targets = [targets];
788
- return vueDemi.watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
820
+ return vueDemi.watch(
821
+ source,
822
+ (newValue) => targets.forEach((target) => target.value = newValue),
823
+ { flush, deep, immediate }
824
+ );
789
825
  }
790
826
 
791
827
  var __defProp$9 = Object.defineProperty;
@@ -864,20 +900,26 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
864
900
  function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
865
901
  let stop = null;
866
902
  const watcher = new Promise((resolve) => {
867
- stop = vueDemi.watch(r, (v) => {
868
- if (condition(v) !== isNot) {
869
- stop == null ? void 0 : stop();
870
- resolve(v);
903
+ stop = vueDemi.watch(
904
+ r,
905
+ (v) => {
906
+ if (condition(v) !== isNot) {
907
+ stop == null ? void 0 : stop();
908
+ resolve(v);
909
+ }
910
+ },
911
+ {
912
+ flush,
913
+ deep,
914
+ immediate: true
871
915
  }
872
- }, {
873
- flush,
874
- deep,
875
- immediate: true
876
- });
916
+ );
877
917
  });
878
918
  const promises = [watcher];
879
919
  if (timeout != null) {
880
- promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
920
+ promises.push(
921
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
922
+ );
881
923
  }
882
924
  return Promise.race(promises);
883
925
  }
@@ -887,23 +929,29 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
887
929
  const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
888
930
  let stop = null;
889
931
  const watcher = new Promise((resolve) => {
890
- stop = vueDemi.watch([r, value], ([v1, v2]) => {
891
- if (isNot !== (v1 === v2)) {
892
- stop == null ? void 0 : stop();
893
- resolve(v1);
932
+ stop = vueDemi.watch(
933
+ [r, value],
934
+ ([v1, v2]) => {
935
+ if (isNot !== (v1 === v2)) {
936
+ stop == null ? void 0 : stop();
937
+ resolve(v1);
938
+ }
939
+ },
940
+ {
941
+ flush,
942
+ deep,
943
+ immediate: true
894
944
  }
895
- }, {
896
- flush,
897
- deep,
898
- immediate: true
899
- });
945
+ );
900
946
  });
901
947
  const promises = [watcher];
902
948
  if (timeout != null) {
903
- promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
904
- stop == null ? void 0 : stop();
905
- return resolveUnref(r);
906
- }));
949
+ promises.push(
950
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
951
+ stop == null ? void 0 : stop();
952
+ return toValue(r);
953
+ })
954
+ );
907
955
  }
908
956
  return Promise.race(promises);
909
957
  }
@@ -922,7 +970,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
922
970
  function toContains(value, options) {
923
971
  return toMatch((v) => {
924
972
  const array = Array.from(v);
925
- return array.includes(value) || array.includes(resolveUnref(value));
973
+ return array.includes(value) || array.includes(toValue(value));
926
974
  }, options);
927
975
  }
928
976
  function changed(options) {
@@ -935,7 +983,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
935
983
  return count >= n;
936
984
  }, options);
937
985
  }
938
- if (Array.isArray(resolveUnref(r))) {
986
+ if (Array.isArray(toValue(r))) {
939
987
  const instance = {
940
988
  toMatch,
941
989
  toContains,
@@ -967,7 +1015,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
967
1015
  return createUntil(r);
968
1016
  }
969
1017
 
970
- const defaultComparator = (value, othVal) => value === othVal;
1018
+ function defaultComparator(value, othVal) {
1019
+ return value === othVal;
1020
+ }
971
1021
  function useArrayDifference(...args) {
972
1022
  var _a;
973
1023
  const list = args[0];
@@ -977,23 +1027,27 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
977
1027
  const key = compareFn;
978
1028
  compareFn = (value, othVal) => value[key] === othVal[key];
979
1029
  }
980
- return vueDemi.computed(() => resolveUnref(list).filter((x) => resolveUnref(values).findIndex((y) => compareFn(x, y)) === -1));
1030
+ return vueDemi.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
981
1031
  }
982
1032
 
983
1033
  function useArrayEvery(list, fn) {
984
- return vueDemi.computed(() => resolveUnref(list).every((element, index, array) => fn(resolveUnref(element), index, array)));
1034
+ return vueDemi.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
985
1035
  }
986
1036
 
987
1037
  function useArrayFilter(list, fn) {
988
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).filter(fn));
1038
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
989
1039
  }
990
1040
 
991
1041
  function useArrayFind(list, fn) {
992
- return vueDemi.computed(() => resolveUnref(resolveUnref(list).find((element, index, array) => fn(resolveUnref(element), index, array))));
1042
+ return vueDemi.computed(
1043
+ () => toValue(
1044
+ toValue(list).find((element, index, array) => fn(toValue(element), index, array))
1045
+ )
1046
+ );
993
1047
  }
994
1048
 
995
1049
  function useArrayFindIndex(list, fn) {
996
- return vueDemi.computed(() => resolveUnref(list).findIndex((element, index, array) => fn(resolveUnref(element), index, array)));
1050
+ return vueDemi.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
997
1051
  }
998
1052
 
999
1053
  function findLast(arr, cb) {
@@ -1005,7 +1059,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1005
1059
  return void 0;
1006
1060
  }
1007
1061
  function useArrayFindLast(list, fn) {
1008
- 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))));
1062
+ return vueDemi.computed(
1063
+ () => toValue(
1064
+ !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))
1065
+ )
1066
+ );
1009
1067
  }
1010
1068
 
1011
1069
  function isArrayIncludesOptions(obj) {
@@ -1023,30 +1081,34 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1023
1081
  }
1024
1082
  if (typeof comparator === "string") {
1025
1083
  const key = comparator;
1026
- comparator = (element, value2) => element[key] === resolveUnref(value2);
1084
+ comparator = (element, value2) => element[key] === toValue(value2);
1027
1085
  }
1028
- comparator = comparator != null ? comparator : (element, value2) => element === resolveUnref(value2);
1029
- return vueDemi.computed(() => resolveUnref(list).slice(formIndex).some((element, index, array) => comparator(resolveUnref(element), resolveUnref(value), index, resolveUnref(array))));
1086
+ comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
1087
+ return vueDemi.computed(
1088
+ () => toValue(list).slice(formIndex).some(
1089
+ (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
1090
+ )
1091
+ );
1030
1092
  }
1031
1093
 
1032
1094
  function useArrayJoin(list, separator) {
1033
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).join(resolveUnref(separator)));
1095
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1034
1096
  }
1035
1097
 
1036
1098
  function useArrayMap(list, fn) {
1037
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).map(fn));
1099
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1038
1100
  }
1039
1101
 
1040
1102
  function useArrayReduce(list, reducer, ...args) {
1041
- const reduceCallback = (sum, value, index) => reducer(resolveUnref(sum), resolveUnref(value), index);
1103
+ const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
1042
1104
  return vueDemi.computed(() => {
1043
- const resolved = resolveUnref(list);
1044
- return args.length ? resolved.reduce(reduceCallback, resolveUnref(args[0])) : resolved.reduce(reduceCallback);
1105
+ const resolved = toValue(list);
1106
+ return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
1045
1107
  });
1046
1108
  }
1047
1109
 
1048
1110
  function useArraySome(list, fn) {
1049
- return vueDemi.computed(() => resolveUnref(list).some((element, index, array) => fn(resolveUnref(element), index, array)));
1111
+ return vueDemi.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1050
1112
  }
1051
1113
 
1052
1114
  function uniq(array) {
@@ -1061,7 +1123,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1061
1123
  }
1062
1124
  function useArrayUnique(list, compareFn) {
1063
1125
  return vueDemi.computed(() => {
1064
- const resolvedList = resolveUnref(list).map((element) => resolveUnref(element));
1126
+ const resolvedList = toValue(list).map((element) => toValue(element));
1065
1127
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1066
1128
  });
1067
1129
  }
@@ -1085,13 +1147,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1085
1147
 
1086
1148
  const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
1087
1149
  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;
1088
- const defaultMeridiem = (hours, minutes, isLowercase, hasPeriod) => {
1150
+ function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1089
1151
  let m = hours < 12 ? "AM" : "PM";
1090
1152
  if (hasPeriod)
1091
1153
  m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
1092
1154
  return isLowercase ? m.toLowerCase() : m;
1093
- };
1094
- const formatDate = (date, formatStr, options = {}) => {
1155
+ }
1156
+ function formatDate(date, formatStr, options = {}) {
1095
1157
  var _a;
1096
1158
  const years = date.getFullYear();
1097
1159
  const month = date.getMonth();
@@ -1130,12 +1192,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1130
1192
  aa: () => meridiem(hours, minutes, true, true)
1131
1193
  };
1132
1194
  return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match]());
1133
- };
1134
- const normalizeDate = (date) => {
1195
+ }
1196
+ function normalizeDate(date) {
1135
1197
  if (date === null)
1136
- return new Date(NaN);
1198
+ return /* @__PURE__ */ new Date(NaN);
1137
1199
  if (date === void 0)
1138
- return new Date();
1200
+ return /* @__PURE__ */ new Date();
1139
1201
  if (date instanceof Date)
1140
1202
  return new Date(date);
1141
1203
  if (typeof date === "string" && !/Z$/i.test(date)) {
@@ -1147,9 +1209,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1147
1209
  }
1148
1210
  }
1149
1211
  return new Date(date);
1150
- };
1212
+ }
1151
1213
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1152
- return vueDemi.computed(() => formatDate(normalizeDate(resolveUnref(date)), resolveUnref(formatStr), options));
1214
+ return vueDemi.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1153
1215
  }
1154
1216
 
1155
1217
  function useIntervalFn(cb, interval = 1e3, options = {}) {
@@ -1170,7 +1232,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1170
1232
  clean();
1171
1233
  }
1172
1234
  function resume() {
1173
- const intervalValue = resolveUnref(interval);
1235
+ const intervalValue = toValue(interval);
1174
1236
  if (intervalValue <= 0)
1175
1237
  return;
1176
1238
  isActive.value = true;
@@ -1223,10 +1285,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1223
1285
  const reset = () => {
1224
1286
  counter.value = 0;
1225
1287
  };
1226
- const controls = useIntervalFn(callback ? () => {
1227
- update();
1228
- callback(counter.value);
1229
- } : update, interval, { immediate });
1288
+ const controls = useIntervalFn(
1289
+ callback ? () => {
1290
+ update();
1291
+ callback(counter.value);
1292
+ } : update,
1293
+ interval,
1294
+ { immediate }
1295
+ );
1230
1296
  if (exposeControls) {
1231
1297
  return __spreadValues$8({
1232
1298
  counter,
@@ -1240,7 +1306,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1240
1306
  function useLastChanged(source, options = {}) {
1241
1307
  var _a;
1242
1308
  const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
1243
- vueDemi.watch(source, () => ms.value = timestamp(), options);
1309
+ vueDemi.watch(
1310
+ source,
1311
+ () => ms.value = timestamp(),
1312
+ options
1313
+ );
1244
1314
  return ms;
1245
1315
  }
1246
1316
 
@@ -1267,7 +1337,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1267
1337
  isPending.value = false;
1268
1338
  timer = null;
1269
1339
  cb(...args);
1270
- }, resolveUnref(interval));
1340
+ }, toValue(interval));
1271
1341
  }
1272
1342
  if (immediate) {
1273
1343
  isPending.value = true;
@@ -1303,7 +1373,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1303
1373
  controls: exposeControls = false,
1304
1374
  callback
1305
1375
  } = options;
1306
- const controls = useTimeoutFn(callback != null ? callback : noop, interval, options);
1376
+ const controls = useTimeoutFn(
1377
+ callback != null ? callback : noop,
1378
+ interval,
1379
+ options
1380
+ );
1307
1381
  const ready = vueDemi.computed(() => !controls.isPending.value);
1308
1382
  if (exposeControls) {
1309
1383
  return __spreadValues$7({
@@ -1321,7 +1395,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1321
1395
  nanToZero
1322
1396
  } = options;
1323
1397
  return vueDemi.computed(() => {
1324
- let resolved = resolveUnref(value);
1398
+ let resolved = toValue(value);
1325
1399
  if (typeof resolved === "string")
1326
1400
  resolved = Number[method](resolved, radix);
1327
1401
  if (nanToZero && isNaN(resolved))
@@ -1331,7 +1405,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1331
1405
  }
1332
1406
 
1333
1407
  function useToString(value) {
1334
- return vueDemi.computed(() => `${resolveUnref(value)}`);
1408
+ return vueDemi.computed(() => `${toValue(value)}`);
1335
1409
  }
1336
1410
 
1337
1411
  function useToggle(initialValue = false, options = {}) {
@@ -1346,8 +1420,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1346
1420
  _value.value = value;
1347
1421
  return _value.value;
1348
1422
  } else {
1349
- const truthy = resolveUnref(truthyValue);
1350
- _value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
1423
+ const truthy = toValue(truthyValue);
1424
+ _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
1351
1425
  return _value.value;
1352
1426
  }
1353
1427
  }
@@ -1359,7 +1433,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1359
1433
 
1360
1434
  function watchArray(source, cb, options) {
1361
1435
  let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1362
- ...source instanceof Function ? source() : Array.isArray(source) ? source : vueDemi.unref(source)
1436
+ ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1363
1437
  ];
1364
1438
  return vueDemi.watch(source, (newList, _, onCleanup) => {
1365
1439
  const oldListRemains = new Array(oldList.length);
@@ -1403,7 +1477,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1403
1477
  } = _a, watchOptions = __objRest$5(_a, [
1404
1478
  "eventFilter"
1405
1479
  ]);
1406
- return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
1480
+ return vueDemi.watch(
1481
+ source,
1482
+ createFilterWrapper(
1483
+ eventFilter,
1484
+ cb
1485
+ ),
1486
+ watchOptions
1487
+ );
1407
1488
  }
1408
1489
 
1409
1490
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
@@ -1428,12 +1509,16 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1428
1509
  "count"
1429
1510
  ]);
1430
1511
  const current = vueDemi.ref(0);
1431
- const stop = watchWithFilter(source, (...args) => {
1432
- current.value += 1;
1433
- if (current.value >= resolveUnref(count))
1434
- vueDemi.nextTick(() => stop());
1435
- cb(...args);
1436
- }, watchOptions);
1512
+ const stop = watchWithFilter(
1513
+ source,
1514
+ (...args) => {
1515
+ current.value += 1;
1516
+ if (current.value >= toValue(count))
1517
+ vueDemi.nextTick(() => stop());
1518
+ cb(...args);
1519
+ },
1520
+ watchOptions
1521
+ );
1437
1522
  return { count: current, stop };
1438
1523
  }
1439
1524
 
@@ -1476,9 +1561,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1476
1561
  "debounce",
1477
1562
  "maxWait"
1478
1563
  ]);
1479
- return watchWithFilter(source, cb, __spreadProps$6(__spreadValues$6({}, watchOptions), {
1480
- eventFilter: debounceFilter(debounce, { maxWait })
1481
- }));
1564
+ return watchWithFilter(
1565
+ source,
1566
+ cb,
1567
+ __spreadProps$6(__spreadValues$6({}, watchOptions), {
1568
+ eventFilter: debounceFilter(debounce, { maxWait })
1569
+ })
1570
+ );
1482
1571
  }
1483
1572
 
1484
1573
  var __defProp$5 = Object.defineProperty;
@@ -1501,12 +1590,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1501
1590
  };
1502
1591
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1503
1592
  function watchDeep(source, cb, options) {
1504
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1505
- if (v)
1506
- cb(v, ov, onInvalidate);
1507
- }, __spreadProps$5(__spreadValues$5({}, options), {
1508
- deep: true
1509
- }));
1593
+ return vueDemi.watch(
1594
+ source,
1595
+ cb,
1596
+ __spreadProps$5(__spreadValues$5({}, options), {
1597
+ deep: true
1598
+ })
1599
+ );
1510
1600
  }
1511
1601
 
1512
1602
  var __defProp$4 = Object.defineProperty;
@@ -1546,7 +1636,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1546
1636
  } = _a, watchOptions = __objRest$2(_a, [
1547
1637
  "eventFilter"
1548
1638
  ]);
1549
- const filteredCb = createFilterWrapper(eventFilter, cb);
1639
+ const filteredCb = createFilterWrapper(
1640
+ eventFilter,
1641
+ cb
1642
+ );
1550
1643
  let ignoreUpdates;
1551
1644
  let ignorePrevAsyncUpdates;
1552
1645
  let stop;
@@ -1559,10 +1652,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1559
1652
  updater();
1560
1653
  ignore.value = false;
1561
1654
  };
1562
- stop = vueDemi.watch(source, (...args) => {
1563
- if (!ignore.value)
1564
- filteredCb(...args);
1565
- }, watchOptions);
1655
+ stop = vueDemi.watch(
1656
+ source,
1657
+ (...args) => {
1658
+ if (!ignore.value)
1659
+ filteredCb(...args);
1660
+ },
1661
+ watchOptions
1662
+ );
1566
1663
  } else {
1567
1664
  const disposables = [];
1568
1665
  const ignoreCounter = vueDemi.ref(0);
@@ -1570,22 +1667,34 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1570
1667
  ignorePrevAsyncUpdates = () => {
1571
1668
  ignoreCounter.value = syncCounter.value;
1572
1669
  };
1573
- disposables.push(vueDemi.watch(source, () => {
1574
- syncCounter.value++;
1575
- }, __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })));
1670
+ disposables.push(
1671
+ vueDemi.watch(
1672
+ source,
1673
+ () => {
1674
+ syncCounter.value++;
1675
+ },
1676
+ __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })
1677
+ )
1678
+ );
1576
1679
  ignoreUpdates = (updater) => {
1577
1680
  const syncCounterPrev = syncCounter.value;
1578
1681
  updater();
1579
1682
  ignoreCounter.value += syncCounter.value - syncCounterPrev;
1580
1683
  };
1581
- disposables.push(vueDemi.watch(source, (...args) => {
1582
- const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1583
- ignoreCounter.value = 0;
1584
- syncCounter.value = 0;
1585
- if (ignore)
1586
- return;
1587
- filteredCb(...args);
1588
- }, watchOptions));
1684
+ disposables.push(
1685
+ vueDemi.watch(
1686
+ source,
1687
+ (...args) => {
1688
+ const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1689
+ ignoreCounter.value = 0;
1690
+ syncCounter.value = 0;
1691
+ if (ignore)
1692
+ return;
1693
+ filteredCb(...args);
1694
+ },
1695
+ watchOptions
1696
+ )
1697
+ );
1589
1698
  stop = () => {
1590
1699
  disposables.forEach((fn) => fn());
1591
1700
  };
@@ -1613,12 +1722,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1613
1722
  };
1614
1723
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1615
1724
  function watchImmediate(source, cb, options) {
1616
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1617
- if (v)
1618
- cb(v, ov, onInvalidate);
1619
- }, __spreadProps$3(__spreadValues$3({}, options), {
1620
- immediate: true
1621
- }));
1725
+ return vueDemi.watch(
1726
+ source,
1727
+ cb,
1728
+ __spreadProps$3(__spreadValues$3({}, options), {
1729
+ immediate: true
1730
+ })
1731
+ );
1622
1732
  }
1623
1733
 
1624
1734
  function watchOnce(source, cb, options) {
@@ -1666,9 +1776,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1666
1776
  "eventFilter"
1667
1777
  ]);
1668
1778
  const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1669
- const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$2({}, watchOptions), {
1670
- eventFilter
1671
- }));
1779
+ const stop = watchWithFilter(
1780
+ source,
1781
+ cb,
1782
+ __spreadProps$2(__spreadValues$2({}, watchOptions), {
1783
+ eventFilter
1784
+ })
1785
+ );
1672
1786
  return { stop, pause, resume, isActive };
1673
1787
  }
1674
1788
 
@@ -1713,9 +1827,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1713
1827
  "trailing",
1714
1828
  "leading"
1715
1829
  ]);
1716
- return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
1717
- eventFilter: throttleFilter(throttle, trailing, leading)
1718
- }));
1830
+ return watchWithFilter(
1831
+ source,
1832
+ cb,
1833
+ __spreadProps$1(__spreadValues$1({}, watchOptions), {
1834
+ eventFilter: throttleFilter(throttle, trailing, leading)
1835
+ })
1836
+ );
1719
1837
  }
1720
1838
 
1721
1839
  var __defProp = Object.defineProperty;
@@ -1770,21 +1888,22 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1770
1888
  if (vueDemi.isReactive(sources))
1771
1889
  return sources;
1772
1890
  if (Array.isArray(sources))
1773
- return sources.map((item) => getOneWatchSource(item));
1774
- return getOneWatchSource(sources);
1775
- }
1776
- function getOneWatchSource(source) {
1777
- return typeof source === "function" ? source() : vueDemi.unref(source);
1891
+ return sources.map((item) => toValue(item));
1892
+ return toValue(sources);
1778
1893
  }
1779
1894
  function getOldValue(source) {
1780
1895
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
1781
1896
  }
1782
1897
 
1783
1898
  function whenever(source, cb, options) {
1784
- return vueDemi.watch(source, (v, ov, onInvalidate) => {
1785
- if (v)
1786
- cb(v, ov, onInvalidate);
1787
- }, options);
1899
+ return vueDemi.watch(
1900
+ source,
1901
+ (v, ov, onInvalidate) => {
1902
+ if (v)
1903
+ cb(v, ov, onInvalidate);
1904
+ },
1905
+ options
1906
+ );
1788
1907
  }
1789
1908
 
1790
1909
  exports.__onlyVue27Plus = __onlyVue27Plus;
@@ -1833,6 +1952,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1833
1952
  exports.normalizeDate = normalizeDate;
1834
1953
  exports.now = now;
1835
1954
  exports.objectEntries = objectEntries;
1955
+ exports.objectOmit = objectOmit;
1836
1956
  exports.objectPick = objectPick;
1837
1957
  exports.pausableFilter = pausableFilter;
1838
1958
  exports.pausableWatch = watchPausable;
@@ -1858,7 +1978,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1858
1978
  exports.throttledWatch = watchThrottled;
1859
1979
  exports.timestamp = timestamp;
1860
1980
  exports.toReactive = toReactive;
1981
+ exports.toRef = toRef;
1861
1982
  exports.toRefs = toRefs;
1983
+ exports.toValue = toValue;
1862
1984
  exports.tryOnBeforeMount = tryOnBeforeMount;
1863
1985
  exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
1864
1986
  exports.tryOnMounted = tryOnMounted;