@vueuse/shared 10.2.1 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -1,32 +1,13 @@
1
1
  import { shallowRef, watchEffect, readonly, ref, watch, customRef, getCurrentScope, onScopeDispose, effectScope, provide, inject, isVue3, version, isRef, unref, computed, reactive, toRefs as toRefs$1, toRef as toRef$1, isVue2, set as set$1, getCurrentInstance, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue-demi';
2
2
 
3
- var __defProp$b = Object.defineProperty;
4
- var __defProps$8 = Object.defineProperties;
5
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
7
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
8
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues$b = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp$d.call(b, prop))
13
- __defNormalProp$b(a, prop, b[prop]);
14
- if (__getOwnPropSymbols$d)
15
- for (var prop of __getOwnPropSymbols$d(b)) {
16
- if (__propIsEnum$d.call(b, prop))
17
- __defNormalProp$b(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
22
3
  function computedEager(fn, options) {
23
- var _a;
24
4
  const result = shallowRef();
25
5
  watchEffect(() => {
26
6
  result.value = fn();
27
- }, __spreadProps$8(__spreadValues$b({}, options), {
28
- flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
29
- }));
7
+ }, {
8
+ ...options,
9
+ flush: options?.flush ?? "sync"
10
+ });
30
11
  return readonly(result);
31
12
  }
32
13
 
@@ -55,7 +36,7 @@ function computedWithControl(source, fn) {
55
36
  return v;
56
37
  },
57
38
  set(v2) {
58
- set == null ? void 0 : set(v2);
39
+ set?.(v2);
59
40
  }
60
41
  };
61
42
  });
@@ -178,25 +159,9 @@ function isDefined(v) {
178
159
  return unref(v) != null;
179
160
  }
180
161
 
181
- var __defProp$a = Object.defineProperty;
182
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
183
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
184
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
185
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
186
- var __spreadValues$a = (a, b) => {
187
- for (var prop in b || (b = {}))
188
- if (__hasOwnProp$c.call(b, prop))
189
- __defNormalProp$a(a, prop, b[prop]);
190
- if (__getOwnPropSymbols$c)
191
- for (var prop of __getOwnPropSymbols$c(b)) {
192
- if (__propIsEnum$c.call(b, prop))
193
- __defNormalProp$a(a, prop, b[prop]);
194
- }
195
- return a;
196
- };
197
162
  function makeDestructurable(obj, arr) {
198
163
  if (typeof Symbol !== "undefined") {
199
- const clone = __spreadValues$a({}, obj);
164
+ const clone = { ...obj };
200
165
  Object.defineProperty(clone, Symbol.iterator, {
201
166
  enumerable: false,
202
167
  value() {
@@ -221,7 +186,7 @@ function toValue(r) {
221
186
  const resolveUnref = toValue;
222
187
 
223
188
  function reactify(fn, options) {
224
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue;
189
+ const unrefFn = options?.computedGetter === false ? unref : toValue;
225
190
  return function(...args) {
226
191
  return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
227
192
  };
@@ -295,7 +260,7 @@ function reactiveOmit(obj, ...keys) {
295
260
  );
296
261
  }
297
262
 
298
- const isClient = typeof window !== "undefined";
263
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
299
264
  const isDef = (val) => typeof val !== "undefined";
300
265
  const notNullish = (val) => val != null;
301
266
  const assert = (condition, ...infos) => {
@@ -317,8 +282,7 @@ const rand = (min, max) => {
317
282
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
318
283
  const isIOS = /* @__PURE__ */ getIsIOS();
319
284
  function getIsIOS() {
320
- var _a;
321
- return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
285
+ return isClient && window?.navigator?.userAgent && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
322
286
  }
323
287
 
324
288
  function createFilterWrapper(filter, fn) {
@@ -440,6 +404,22 @@ const directiveHooks = {
440
404
  unmounted: isVue3 ? "unmounted" : "unbind"
441
405
  };
442
406
 
407
+ function cacheStringFunction(fn) {
408
+ const cache = /* @__PURE__ */ Object.create(null);
409
+ return (str) => {
410
+ const hit = cache[str];
411
+ return hit || (cache[str] = fn(str));
412
+ };
413
+ }
414
+ const hyphenateRE = /\B([A-Z])/g;
415
+ const hyphenate = cacheStringFunction(
416
+ (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
417
+ );
418
+ const camelizeRE = /-(\w)/g;
419
+ const camelize = cacheStringFunction((str) => {
420
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
421
+ });
422
+
443
423
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
444
424
  return new Promise((resolve, reject) => {
445
425
  if (throwOnTimeout)
@@ -473,10 +453,9 @@ function containsProp(obj, ...props) {
473
453
  return props.some((k) => k in obj);
474
454
  }
475
455
  function increaseWithUnit(target, delta) {
476
- var _a;
477
456
  if (typeof target === "number")
478
457
  return target + delta;
479
- const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
458
+ const value = target.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
480
459
  const unit = target.slice(value.length);
481
460
  const result = Number.parseFloat(value) + delta;
482
461
  if (Number.isNaN(result))
@@ -517,10 +496,10 @@ function reactivePick(obj, ...keys) {
517
496
 
518
497
  function refAutoReset(defaultValue, afterMs = 1e4) {
519
498
  return customRef((track, trigger) => {
520
- let value = defaultValue;
499
+ let value = toValue(defaultValue);
521
500
  let timer;
522
501
  const resetAfter = () => setTimeout(() => {
523
- value = defaultValue;
502
+ value = toValue(defaultValue);
524
503
  trigger();
525
504
  }, toValue(afterMs));
526
505
  tryOnScopeDispose(() => {
@@ -560,8 +539,7 @@ function refDebounced(value, ms = 200, options = {}) {
560
539
  function refDefault(source, defaultValue) {
561
540
  return computed({
562
541
  get() {
563
- var _a;
564
- return (_a = source.value) != null ? _a : defaultValue;
542
+ return source.value ?? defaultValue;
565
543
  },
566
544
  set(value) {
567
545
  source.value = value;
@@ -609,14 +587,13 @@ function refWithControl(initial, options = {}) {
609
587
  return source;
610
588
  }
611
589
  function set(value, triggering = true) {
612
- var _a, _b;
613
590
  if (value === source)
614
591
  return;
615
592
  const old = source;
616
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
593
+ if (options.onBeforeChange?.(value, old) === false)
617
594
  return;
618
595
  source = value;
619
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
596
+ options.onChanged?.(value, old);
620
597
  if (triggering)
621
598
  trigger();
622
599
  }
@@ -654,8 +631,39 @@ function set(...args) {
654
631
  }
655
632
  }
656
633
 
634
+ function watchWithFilter(source, cb, options = {}) {
635
+ const {
636
+ eventFilter = bypassFilter,
637
+ ...watchOptions
638
+ } = options;
639
+ return watch(
640
+ source,
641
+ createFilterWrapper(
642
+ eventFilter,
643
+ cb
644
+ ),
645
+ watchOptions
646
+ );
647
+ }
648
+
649
+ function watchPausable(source, cb, options = {}) {
650
+ const {
651
+ eventFilter: filter,
652
+ ...watchOptions
653
+ } = options;
654
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
655
+ const stop = watchWithFilter(
656
+ source,
657
+ cb,
658
+ {
659
+ ...watchOptions,
660
+ eventFilter
661
+ }
662
+ );
663
+ return { stop, pause, resume, isActive };
664
+ }
665
+
657
666
  function syncRef(left, right, options = {}) {
658
- var _a, _b;
659
667
  const {
660
668
  flush = "sync",
661
669
  deep = false,
@@ -663,28 +671,35 @@ function syncRef(left, right, options = {}) {
663
671
  direction = "both",
664
672
  transform = {}
665
673
  } = options;
666
- let watchLeft;
667
- let watchRight;
668
- const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
669
- const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
674
+ const watchers = [];
675
+ const transformLTR = transform.ltr ?? ((v) => v);
676
+ const transformRTL = transform.rtl ?? ((v) => v);
670
677
  if (direction === "both" || direction === "ltr") {
671
- watchLeft = watch(
678
+ watchers.push(watchPausable(
672
679
  left,
673
- (newValue) => right.value = transformLTR(newValue),
680
+ (newValue) => {
681
+ watchers.forEach((w) => w.pause());
682
+ right.value = transformLTR(newValue);
683
+ watchers.forEach((w) => w.resume());
684
+ },
674
685
  { flush, deep, immediate }
675
- );
686
+ ));
676
687
  }
677
688
  if (direction === "both" || direction === "rtl") {
678
- watchRight = watch(
689
+ watchers.push(watchPausable(
679
690
  right,
680
- (newValue) => left.value = transformRTL(newValue),
691
+ (newValue) => {
692
+ watchers.forEach((w) => w.pause());
693
+ left.value = transformRTL(newValue);
694
+ watchers.forEach((w) => w.resume());
695
+ },
681
696
  { flush, deep, immediate }
682
- );
697
+ ));
683
698
  }
684
- return () => {
685
- watchLeft == null ? void 0 : watchLeft();
686
- watchRight == null ? void 0 : watchRight();
699
+ const stop = () => {
700
+ watchers.forEach((w) => w.stop());
687
701
  };
702
+ return stop;
688
703
  }
689
704
 
690
705
  function syncRefs(source, targets, options = {}) {
@@ -702,43 +717,29 @@ function syncRefs(source, targets, options = {}) {
702
717
  );
703
718
  }
704
719
 
705
- var __defProp$9 = Object.defineProperty;
706
- var __defProps$7 = Object.defineProperties;
707
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
708
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
709
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
710
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
711
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
712
- var __spreadValues$9 = (a, b) => {
713
- for (var prop in b || (b = {}))
714
- if (__hasOwnProp$b.call(b, prop))
715
- __defNormalProp$9(a, prop, b[prop]);
716
- if (__getOwnPropSymbols$b)
717
- for (var prop of __getOwnPropSymbols$b(b)) {
718
- if (__propIsEnum$b.call(b, prop))
719
- __defNormalProp$9(a, prop, b[prop]);
720
- }
721
- return a;
722
- };
723
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
724
- function toRefs(objectRef) {
720
+ function toRefs(objectRef, options = {}) {
725
721
  if (!isRef(objectRef))
726
722
  return toRefs$1(objectRef);
727
- const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
723
+ const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
728
724
  for (const key in objectRef.value) {
729
725
  result[key] = customRef(() => ({
730
726
  get() {
731
727
  return objectRef.value[key];
732
728
  },
733
729
  set(v) {
734
- if (Array.isArray(objectRef.value)) {
735
- const copy = [...objectRef.value];
736
- copy[key] = v;
737
- objectRef.value = copy;
730
+ const replaceRef = toValue(options.replaceRef) ?? true;
731
+ if (replaceRef) {
732
+ if (Array.isArray(objectRef.value)) {
733
+ const copy = [...objectRef.value];
734
+ copy[key] = v;
735
+ objectRef.value = copy;
736
+ } else {
737
+ const newObject = { ...objectRef.value, [key]: v };
738
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
739
+ objectRef.value = newObject;
740
+ }
738
741
  } else {
739
- const newObject = __spreadProps$7(__spreadValues$9({}, objectRef.value), { [key]: v });
740
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
741
- objectRef.value = newObject;
742
+ objectRef.value[key] = v;
742
743
  }
743
744
  }
744
745
  }));
@@ -782,7 +783,7 @@ function createUntil(r, isNot = false) {
782
783
  r,
783
784
  (v) => {
784
785
  if (condition(v) !== isNot) {
785
- stop == null ? void 0 : stop();
786
+ stop?.();
786
787
  resolve(v);
787
788
  }
788
789
  },
@@ -796,7 +797,7 @@ function createUntil(r, isNot = false) {
796
797
  const promises = [watcher];
797
798
  if (timeout != null) {
798
799
  promises.push(
799
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
800
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop?.())
800
801
  );
801
802
  }
802
803
  return Promise.race(promises);
@@ -804,14 +805,14 @@ function createUntil(r, isNot = false) {
804
805
  function toBe(value, options) {
805
806
  if (!isRef(value))
806
807
  return toMatch((v) => v === value, options);
807
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
808
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options ?? {};
808
809
  let stop = null;
809
810
  const watcher = new Promise((resolve) => {
810
811
  stop = watch(
811
812
  [r, value],
812
813
  ([v1, v2]) => {
813
814
  if (isNot !== (v1 === v2)) {
814
- stop == null ? void 0 : stop();
815
+ stop?.();
815
816
  resolve(v1);
816
817
  }
817
818
  },
@@ -826,7 +827,7 @@ function createUntil(r, isNot = false) {
826
827
  if (timeout != null) {
827
828
  promises.push(
828
829
  promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
829
- stop == null ? void 0 : stop();
830
+ stop?.();
830
831
  return toValue(r);
831
832
  })
832
833
  );
@@ -897,10 +898,9 @@ function defaultComparator(value, othVal) {
897
898
  return value === othVal;
898
899
  }
899
900
  function useArrayDifference(...args) {
900
- var _a;
901
901
  const list = args[0];
902
902
  const values = args[1];
903
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
903
+ let compareFn = args[2] ?? defaultComparator;
904
904
  if (typeof compareFn === "string") {
905
905
  const key = compareFn;
906
906
  compareFn = (value, othVal) => value[key] === othVal[key];
@@ -948,20 +948,19 @@ function isArrayIncludesOptions(obj) {
948
948
  return isObject(obj) && containsProp(obj, "formIndex", "comparator");
949
949
  }
950
950
  function useArrayIncludes(...args) {
951
- var _a;
952
951
  const list = args[0];
953
952
  const value = args[1];
954
953
  let comparator = args[2];
955
954
  let formIndex = 0;
956
955
  if (isArrayIncludesOptions(comparator)) {
957
- formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
956
+ formIndex = comparator.fromIndex ?? 0;
958
957
  comparator = comparator.comparator;
959
958
  }
960
959
  if (typeof comparator === "string") {
961
960
  const key = comparator;
962
961
  comparator = (element, value2) => element[key] === toValue(value2);
963
962
  }
964
- comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
963
+ comparator = comparator ?? ((element, value2) => element === toValue(value2));
965
964
  return computed(
966
965
  () => toValue(list).slice(formIndex).some(
967
966
  (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
@@ -1007,17 +1006,18 @@ function useArrayUnique(list, compareFn) {
1007
1006
  }
1008
1007
 
1009
1008
  function useCounter(initialValue = 0, options = {}) {
1009
+ let _initialValue = unref(initialValue);
1010
1010
  const count = ref(initialValue);
1011
1011
  const {
1012
- max = Infinity,
1013
- min = -Infinity
1012
+ max = Number.POSITIVE_INFINITY,
1013
+ min = Number.NEGATIVE_INFINITY
1014
1014
  } = options;
1015
1015
  const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1016
1016
  const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1017
1017
  const get = () => count.value;
1018
1018
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1019
- const reset = (val = initialValue) => {
1020
- initialValue = val;
1019
+ const reset = (val = _initialValue) => {
1020
+ _initialValue = val;
1021
1021
  return set(val);
1022
1022
  };
1023
1023
  return { count, inc, dec, get, set, reset };
@@ -1032,7 +1032,6 @@ function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1032
1032
  return isLowercase ? m.toLowerCase() : m;
1033
1033
  }
1034
1034
  function formatDate(date, formatStr, options = {}) {
1035
- var _a;
1036
1035
  const years = date.getFullYear();
1037
1036
  const month = date.getMonth();
1038
1037
  const days = date.getDate();
@@ -1041,7 +1040,7 @@ function formatDate(date, formatStr, options = {}) {
1041
1040
  const seconds = date.getSeconds();
1042
1041
  const milliseconds = date.getMilliseconds();
1043
1042
  const day = date.getDay();
1044
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
1043
+ const meridiem = options.customMeridiem ?? defaultMeridiem;
1045
1044
  const matches = {
1046
1045
  YY: () => String(years).slice(-2),
1047
1046
  YYYY: () => years,
@@ -1069,14 +1068,11 @@ function formatDate(date, formatStr, options = {}) {
1069
1068
  a: () => meridiem(hours, minutes, true),
1070
1069
  aa: () => meridiem(hours, minutes, true, true)
1071
1070
  };
1072
- return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1073
- var _a2;
1074
- return $1 || ((_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) || match;
1075
- });
1071
+ return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 ?? matches[match]?.() ?? match);
1076
1072
  }
1077
1073
  function normalizeDate(date) {
1078
1074
  if (date === null)
1079
- return /* @__PURE__ */ new Date(NaN);
1075
+ return new Date(Number.NaN);
1080
1076
  if (date === void 0)
1081
1077
  return /* @__PURE__ */ new Date();
1082
1078
  if (date instanceof Date)
@@ -1139,22 +1135,6 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1139
1135
  };
1140
1136
  }
1141
1137
 
1142
- var __defProp$8 = Object.defineProperty;
1143
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1144
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1145
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1146
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1147
- var __spreadValues$8 = (a, b) => {
1148
- for (var prop in b || (b = {}))
1149
- if (__hasOwnProp$a.call(b, prop))
1150
- __defNormalProp$8(a, prop, b[prop]);
1151
- if (__getOwnPropSymbols$a)
1152
- for (var prop of __getOwnPropSymbols$a(b)) {
1153
- if (__propIsEnum$a.call(b, prop))
1154
- __defNormalProp$8(a, prop, b[prop]);
1155
- }
1156
- return a;
1157
- };
1158
1138
  function useInterval(interval = 1e3, options = {}) {
1159
1139
  const {
1160
1140
  controls: exposeControls = false,
@@ -1175,18 +1155,18 @@ function useInterval(interval = 1e3, options = {}) {
1175
1155
  { immediate }
1176
1156
  );
1177
1157
  if (exposeControls) {
1178
- return __spreadValues$8({
1158
+ return {
1179
1159
  counter,
1180
- reset
1181
- }, controls);
1160
+ reset,
1161
+ ...controls
1162
+ };
1182
1163
  } else {
1183
1164
  return counter;
1184
1165
  }
1185
1166
  }
1186
1167
 
1187
1168
  function useLastChanged(source, options = {}) {
1188
- var _a;
1189
- const ms = ref((_a = options.initialValue) != null ? _a : null);
1169
+ const ms = ref(options.initialValue ?? null);
1190
1170
  watch(
1191
1171
  source,
1192
1172
  () => ms.value = timestamp(),
@@ -1233,37 +1213,22 @@ function useTimeoutFn(cb, interval, options = {}) {
1233
1213
  };
1234
1214
  }
1235
1215
 
1236
- var __defProp$7 = Object.defineProperty;
1237
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1238
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1239
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1240
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1241
- var __spreadValues$7 = (a, b) => {
1242
- for (var prop in b || (b = {}))
1243
- if (__hasOwnProp$9.call(b, prop))
1244
- __defNormalProp$7(a, prop, b[prop]);
1245
- if (__getOwnPropSymbols$9)
1246
- for (var prop of __getOwnPropSymbols$9(b)) {
1247
- if (__propIsEnum$9.call(b, prop))
1248
- __defNormalProp$7(a, prop, b[prop]);
1249
- }
1250
- return a;
1251
- };
1252
1216
  function useTimeout(interval = 1e3, options = {}) {
1253
1217
  const {
1254
1218
  controls: exposeControls = false,
1255
1219
  callback
1256
1220
  } = options;
1257
1221
  const controls = useTimeoutFn(
1258
- callback != null ? callback : noop,
1222
+ callback ?? noop,
1259
1223
  interval,
1260
1224
  options
1261
1225
  );
1262
1226
  const ready = computed(() => !controls.isPending.value);
1263
1227
  if (exposeControls) {
1264
- return __spreadValues$7({
1265
- ready
1266
- }, controls);
1228
+ return {
1229
+ ready,
1230
+ ...controls
1231
+ };
1267
1232
  } else {
1268
1233
  return ready;
1269
1234
  }
@@ -1313,11 +1278,11 @@ function useToggle(initialValue = false, options = {}) {
1313
1278
  }
1314
1279
 
1315
1280
  function watchArray(source, cb, options) {
1316
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1281
+ let oldList = options?.immediate ? [] : [
1317
1282
  ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1318
1283
  ];
1319
1284
  return watch(source, (newList, _, onCleanup) => {
1320
- const oldListRemains = new Array(oldList.length);
1285
+ const oldListRemains = Array.from({ length: oldList.length });
1321
1286
  const added = [];
1322
1287
  for (const obj of newList) {
1323
1288
  let found = false;
@@ -1337,58 +1302,11 @@ function watchArray(source, cb, options) {
1337
1302
  }, options);
1338
1303
  }
1339
1304
 
1340
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1341
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1342
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1343
- var __objRest$5 = (source, exclude) => {
1344
- var target = {};
1345
- for (var prop in source)
1346
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
1347
- target[prop] = source[prop];
1348
- if (source != null && __getOwnPropSymbols$8)
1349
- for (var prop of __getOwnPropSymbols$8(source)) {
1350
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
1351
- target[prop] = source[prop];
1352
- }
1353
- return target;
1354
- };
1355
- function watchWithFilter(source, cb, options = {}) {
1356
- const _a = options, {
1357
- eventFilter = bypassFilter
1358
- } = _a, watchOptions = __objRest$5(_a, [
1359
- "eventFilter"
1360
- ]);
1361
- return watch(
1362
- source,
1363
- createFilterWrapper(
1364
- eventFilter,
1365
- cb
1366
- ),
1367
- watchOptions
1368
- );
1369
- }
1370
-
1371
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1372
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1373
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1374
- var __objRest$4 = (source, exclude) => {
1375
- var target = {};
1376
- for (var prop in source)
1377
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1378
- target[prop] = source[prop];
1379
- if (source != null && __getOwnPropSymbols$7)
1380
- for (var prop of __getOwnPropSymbols$7(source)) {
1381
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
1382
- target[prop] = source[prop];
1383
- }
1384
- return target;
1385
- };
1386
1305
  function watchAtMost(source, cb, options) {
1387
- const _a = options, {
1388
- count
1389
- } = _a, watchOptions = __objRest$4(_a, [
1390
- "count"
1391
- ]);
1306
+ const {
1307
+ count,
1308
+ ...watchOptions
1309
+ } = options;
1392
1310
  const current = ref(0);
1393
1311
  const stop = watchWithFilter(
1394
1312
  source,
@@ -1403,120 +1321,38 @@ function watchAtMost(source, cb, options) {
1403
1321
  return { count: current, stop };
1404
1322
  }
1405
1323
 
1406
- var __defProp$6 = Object.defineProperty;
1407
- var __defProps$6 = Object.defineProperties;
1408
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1409
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1410
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1411
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1412
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1413
- var __spreadValues$6 = (a, b) => {
1414
- for (var prop in b || (b = {}))
1415
- if (__hasOwnProp$6.call(b, prop))
1416
- __defNormalProp$6(a, prop, b[prop]);
1417
- if (__getOwnPropSymbols$6)
1418
- for (var prop of __getOwnPropSymbols$6(b)) {
1419
- if (__propIsEnum$6.call(b, prop))
1420
- __defNormalProp$6(a, prop, b[prop]);
1421
- }
1422
- return a;
1423
- };
1424
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1425
- var __objRest$3 = (source, exclude) => {
1426
- var target = {};
1427
- for (var prop in source)
1428
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1429
- target[prop] = source[prop];
1430
- if (source != null && __getOwnPropSymbols$6)
1431
- for (var prop of __getOwnPropSymbols$6(source)) {
1432
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1433
- target[prop] = source[prop];
1434
- }
1435
- return target;
1436
- };
1437
1324
  function watchDebounced(source, cb, options = {}) {
1438
- const _a = options, {
1325
+ const {
1439
1326
  debounce = 0,
1440
- maxWait = void 0
1441
- } = _a, watchOptions = __objRest$3(_a, [
1442
- "debounce",
1443
- "maxWait"
1444
- ]);
1327
+ maxWait = void 0,
1328
+ ...watchOptions
1329
+ } = options;
1445
1330
  return watchWithFilter(
1446
1331
  source,
1447
1332
  cb,
1448
- __spreadProps$6(__spreadValues$6({}, watchOptions), {
1333
+ {
1334
+ ...watchOptions,
1449
1335
  eventFilter: debounceFilter(debounce, { maxWait })
1450
- })
1336
+ }
1451
1337
  );
1452
1338
  }
1453
1339
 
1454
- var __defProp$5 = Object.defineProperty;
1455
- var __defProps$5 = Object.defineProperties;
1456
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1457
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1458
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1459
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1460
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1461
- var __spreadValues$5 = (a, b) => {
1462
- for (var prop in b || (b = {}))
1463
- if (__hasOwnProp$5.call(b, prop))
1464
- __defNormalProp$5(a, prop, b[prop]);
1465
- if (__getOwnPropSymbols$5)
1466
- for (var prop of __getOwnPropSymbols$5(b)) {
1467
- if (__propIsEnum$5.call(b, prop))
1468
- __defNormalProp$5(a, prop, b[prop]);
1469
- }
1470
- return a;
1471
- };
1472
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1473
1340
  function watchDeep(source, cb, options) {
1474
1341
  return watch(
1475
1342
  source,
1476
1343
  cb,
1477
- __spreadProps$5(__spreadValues$5({}, options), {
1344
+ {
1345
+ ...options,
1478
1346
  deep: true
1479
- })
1347
+ }
1480
1348
  );
1481
1349
  }
1482
1350
 
1483
- var __defProp$4 = Object.defineProperty;
1484
- var __defProps$4 = Object.defineProperties;
1485
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1486
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1487
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1488
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1489
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1490
- var __spreadValues$4 = (a, b) => {
1491
- for (var prop in b || (b = {}))
1492
- if (__hasOwnProp$4.call(b, prop))
1493
- __defNormalProp$4(a, prop, b[prop]);
1494
- if (__getOwnPropSymbols$4)
1495
- for (var prop of __getOwnPropSymbols$4(b)) {
1496
- if (__propIsEnum$4.call(b, prop))
1497
- __defNormalProp$4(a, prop, b[prop]);
1498
- }
1499
- return a;
1500
- };
1501
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1502
- var __objRest$2 = (source, exclude) => {
1503
- var target = {};
1504
- for (var prop in source)
1505
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1506
- target[prop] = source[prop];
1507
- if (source != null && __getOwnPropSymbols$4)
1508
- for (var prop of __getOwnPropSymbols$4(source)) {
1509
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1510
- target[prop] = source[prop];
1511
- }
1512
- return target;
1513
- };
1514
1351
  function watchIgnorable(source, cb, options = {}) {
1515
- const _a = options, {
1516
- eventFilter = bypassFilter
1517
- } = _a, watchOptions = __objRest$2(_a, [
1518
- "eventFilter"
1519
- ]);
1352
+ const {
1353
+ eventFilter = bypassFilter,
1354
+ ...watchOptions
1355
+ } = options;
1520
1356
  const filteredCb = createFilterWrapper(
1521
1357
  eventFilter,
1522
1358
  cb
@@ -1554,7 +1390,7 @@ function watchIgnorable(source, cb, options = {}) {
1554
1390
  () => {
1555
1391
  syncCounter.value++;
1556
1392
  },
1557
- __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })
1393
+ { ...watchOptions, flush: "sync" }
1558
1394
  )
1559
1395
  );
1560
1396
  ignoreUpdates = (updater) => {
@@ -1583,32 +1419,14 @@ function watchIgnorable(source, cb, options = {}) {
1583
1419
  return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1584
1420
  }
1585
1421
 
1586
- var __defProp$3 = Object.defineProperty;
1587
- var __defProps$3 = Object.defineProperties;
1588
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1589
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1590
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1591
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1592
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1593
- var __spreadValues$3 = (a, b) => {
1594
- for (var prop in b || (b = {}))
1595
- if (__hasOwnProp$3.call(b, prop))
1596
- __defNormalProp$3(a, prop, b[prop]);
1597
- if (__getOwnPropSymbols$3)
1598
- for (var prop of __getOwnPropSymbols$3(b)) {
1599
- if (__propIsEnum$3.call(b, prop))
1600
- __defNormalProp$3(a, prop, b[prop]);
1601
- }
1602
- return a;
1603
- };
1604
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1605
1422
  function watchImmediate(source, cb, options) {
1606
1423
  return watch(
1607
1424
  source,
1608
1425
  cb,
1609
- __spreadProps$3(__spreadValues$3({}, options), {
1426
+ {
1427
+ ...options,
1610
1428
  immediate: true
1611
- })
1429
+ }
1612
1430
  );
1613
1431
  }
1614
1432
 
@@ -1619,123 +1437,23 @@ function watchOnce(source, cb, options) {
1619
1437
  }, options);
1620
1438
  }
1621
1439
 
1622
- var __defProp$2 = Object.defineProperty;
1623
- var __defProps$2 = Object.defineProperties;
1624
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1625
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1626
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1627
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1628
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1629
- var __spreadValues$2 = (a, b) => {
1630
- for (var prop in b || (b = {}))
1631
- if (__hasOwnProp$2.call(b, prop))
1632
- __defNormalProp$2(a, prop, b[prop]);
1633
- if (__getOwnPropSymbols$2)
1634
- for (var prop of __getOwnPropSymbols$2(b)) {
1635
- if (__propIsEnum$2.call(b, prop))
1636
- __defNormalProp$2(a, prop, b[prop]);
1637
- }
1638
- return a;
1639
- };
1640
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1641
- var __objRest$1 = (source, exclude) => {
1642
- var target = {};
1643
- for (var prop in source)
1644
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1645
- target[prop] = source[prop];
1646
- if (source != null && __getOwnPropSymbols$2)
1647
- for (var prop of __getOwnPropSymbols$2(source)) {
1648
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1649
- target[prop] = source[prop];
1650
- }
1651
- return target;
1652
- };
1653
- function watchPausable(source, cb, options = {}) {
1654
- const _a = options, {
1655
- eventFilter: filter
1656
- } = _a, watchOptions = __objRest$1(_a, [
1657
- "eventFilter"
1658
- ]);
1659
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1660
- const stop = watchWithFilter(
1661
- source,
1662
- cb,
1663
- __spreadProps$2(__spreadValues$2({}, watchOptions), {
1664
- eventFilter
1665
- })
1666
- );
1667
- return { stop, pause, resume, isActive };
1668
- }
1669
-
1670
- var __defProp$1 = Object.defineProperty;
1671
- var __defProps$1 = Object.defineProperties;
1672
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1673
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1674
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1675
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1676
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1677
- var __spreadValues$1 = (a, b) => {
1678
- for (var prop in b || (b = {}))
1679
- if (__hasOwnProp$1.call(b, prop))
1680
- __defNormalProp$1(a, prop, b[prop]);
1681
- if (__getOwnPropSymbols$1)
1682
- for (var prop of __getOwnPropSymbols$1(b)) {
1683
- if (__propIsEnum$1.call(b, prop))
1684
- __defNormalProp$1(a, prop, b[prop]);
1685
- }
1686
- return a;
1687
- };
1688
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1689
- var __objRest = (source, exclude) => {
1690
- var target = {};
1691
- for (var prop in source)
1692
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1693
- target[prop] = source[prop];
1694
- if (source != null && __getOwnPropSymbols$1)
1695
- for (var prop of __getOwnPropSymbols$1(source)) {
1696
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1697
- target[prop] = source[prop];
1698
- }
1699
- return target;
1700
- };
1701
1440
  function watchThrottled(source, cb, options = {}) {
1702
- const _a = options, {
1441
+ const {
1703
1442
  throttle = 0,
1704
1443
  trailing = true,
1705
- leading = true
1706
- } = _a, watchOptions = __objRest(_a, [
1707
- "throttle",
1708
- "trailing",
1709
- "leading"
1710
- ]);
1444
+ leading = true,
1445
+ ...watchOptions
1446
+ } = options;
1711
1447
  return watchWithFilter(
1712
1448
  source,
1713
1449
  cb,
1714
- __spreadProps$1(__spreadValues$1({}, watchOptions), {
1450
+ {
1451
+ ...watchOptions,
1715
1452
  eventFilter: throttleFilter(throttle, trailing, leading)
1716
- })
1453
+ }
1717
1454
  );
1718
1455
  }
1719
1456
 
1720
- var __defProp = Object.defineProperty;
1721
- var __defProps = Object.defineProperties;
1722
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1723
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1724
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1725
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1726
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1727
- var __spreadValues = (a, b) => {
1728
- for (var prop in b || (b = {}))
1729
- if (__hasOwnProp.call(b, prop))
1730
- __defNormalProp(a, prop, b[prop]);
1731
- if (__getOwnPropSymbols)
1732
- for (var prop of __getOwnPropSymbols(b)) {
1733
- if (__propIsEnum.call(b, prop))
1734
- __defNormalProp(a, prop, b[prop]);
1735
- }
1736
- return a;
1737
- };
1738
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1739
1457
  function watchTriggerable(source, cb, options = {}) {
1740
1458
  let cleanupFn;
1741
1459
  function onEffect() {
@@ -1761,9 +1479,10 @@ function watchTriggerable(source, cb, options = {}) {
1761
1479
  });
1762
1480
  return res2;
1763
1481
  };
1764
- return __spreadProps(__spreadValues({}, res), {
1482
+ return {
1483
+ ...res,
1765
1484
  trigger
1766
- });
1485
+ };
1767
1486
  }
1768
1487
  function getWatchSources(sources) {
1769
1488
  if (isReactive(sources))
@@ -1787,4 +1506,4 @@ function whenever(source, cb, options) {
1787
1506
  );
1788
1507
  }
1789
1508
 
1790
- export { assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
1509
+ export { assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };