@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.iife.js CHANGED
@@ -117,33 +117,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
117
117
  ;(function (exports, vueDemi) {
118
118
  'use strict';
119
119
 
120
- var __defProp$b = Object.defineProperty;
121
- var __defProps$8 = Object.defineProperties;
122
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
123
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
124
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
125
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
126
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
127
- var __spreadValues$b = (a, b) => {
128
- for (var prop in b || (b = {}))
129
- if (__hasOwnProp$d.call(b, prop))
130
- __defNormalProp$b(a, prop, b[prop]);
131
- if (__getOwnPropSymbols$d)
132
- for (var prop of __getOwnPropSymbols$d(b)) {
133
- if (__propIsEnum$d.call(b, prop))
134
- __defNormalProp$b(a, prop, b[prop]);
135
- }
136
- return a;
137
- };
138
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
139
120
  function computedEager(fn, options) {
140
- var _a;
141
121
  const result = vueDemi.shallowRef();
142
122
  vueDemi.watchEffect(() => {
143
123
  result.value = fn();
144
- }, __spreadProps$8(__spreadValues$b({}, options), {
145
- flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
146
- }));
124
+ }, {
125
+ ...options,
126
+ flush: options?.flush ?? "sync"
127
+ });
147
128
  return vueDemi.readonly(result);
148
129
  }
149
130
 
@@ -172,7 +153,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
172
153
  return v;
173
154
  },
174
155
  set(v2) {
175
- set == null ? void 0 : set(v2);
156
+ set?.(v2);
176
157
  }
177
158
  };
178
159
  });
@@ -295,25 +276,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
295
276
  return vueDemi.unref(v) != null;
296
277
  }
297
278
 
298
- var __defProp$a = Object.defineProperty;
299
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
300
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
301
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
302
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
303
- var __spreadValues$a = (a, b) => {
304
- for (var prop in b || (b = {}))
305
- if (__hasOwnProp$c.call(b, prop))
306
- __defNormalProp$a(a, prop, b[prop]);
307
- if (__getOwnPropSymbols$c)
308
- for (var prop of __getOwnPropSymbols$c(b)) {
309
- if (__propIsEnum$c.call(b, prop))
310
- __defNormalProp$a(a, prop, b[prop]);
311
- }
312
- return a;
313
- };
314
279
  function makeDestructurable(obj, arr) {
315
280
  if (typeof Symbol !== "undefined") {
316
- const clone = __spreadValues$a({}, obj);
281
+ const clone = { ...obj };
317
282
  Object.defineProperty(clone, Symbol.iterator, {
318
283
  enumerable: false,
319
284
  value() {
@@ -338,7 +303,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
338
303
  const resolveUnref = toValue;
339
304
 
340
305
  function reactify(fn, options) {
341
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
306
+ const unrefFn = options?.computedGetter === false ? vueDemi.unref : toValue;
342
307
  return function(...args) {
343
308
  return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
344
309
  };
@@ -412,7 +377,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
412
377
  );
413
378
  }
414
379
 
415
- const isClient = typeof window !== "undefined";
380
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
416
381
  const isDef = (val) => typeof val !== "undefined";
417
382
  const notNullish = (val) => val != null;
418
383
  const assert = (condition, ...infos) => {
@@ -434,8 +399,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
434
399
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
435
400
  const isIOS = /* @__PURE__ */ getIsIOS();
436
401
  function getIsIOS() {
437
- var _a;
438
- return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
402
+ return isClient && window?.navigator?.userAgent && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
439
403
  }
440
404
 
441
405
  function createFilterWrapper(filter, fn) {
@@ -557,6 +521,22 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
557
521
  unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
558
522
  };
559
523
 
524
+ function cacheStringFunction(fn) {
525
+ const cache = /* @__PURE__ */ Object.create(null);
526
+ return (str) => {
527
+ const hit = cache[str];
528
+ return hit || (cache[str] = fn(str));
529
+ };
530
+ }
531
+ const hyphenateRE = /\B([A-Z])/g;
532
+ const hyphenate = cacheStringFunction(
533
+ (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
534
+ );
535
+ const camelizeRE = /-(\w)/g;
536
+ const camelize = cacheStringFunction((str) => {
537
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
538
+ });
539
+
560
540
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
561
541
  return new Promise((resolve, reject) => {
562
542
  if (throwOnTimeout)
@@ -590,10 +570,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
590
570
  return props.some((k) => k in obj);
591
571
  }
592
572
  function increaseWithUnit(target, delta) {
593
- var _a;
594
573
  if (typeof target === "number")
595
574
  return target + delta;
596
- const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
575
+ const value = target.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
597
576
  const unit = target.slice(value.length);
598
577
  const result = Number.parseFloat(value) + delta;
599
578
  if (Number.isNaN(result))
@@ -634,10 +613,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
634
613
 
635
614
  function refAutoReset(defaultValue, afterMs = 1e4) {
636
615
  return vueDemi.customRef((track, trigger) => {
637
- let value = defaultValue;
616
+ let value = toValue(defaultValue);
638
617
  let timer;
639
618
  const resetAfter = () => setTimeout(() => {
640
- value = defaultValue;
619
+ value = toValue(defaultValue);
641
620
  trigger();
642
621
  }, toValue(afterMs));
643
622
  tryOnScopeDispose(() => {
@@ -677,8 +656,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
677
656
  function refDefault(source, defaultValue) {
678
657
  return vueDemi.computed({
679
658
  get() {
680
- var _a;
681
- return (_a = source.value) != null ? _a : defaultValue;
659
+ return source.value ?? defaultValue;
682
660
  },
683
661
  set(value) {
684
662
  source.value = value;
@@ -726,14 +704,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
726
704
  return source;
727
705
  }
728
706
  function set(value, triggering = true) {
729
- var _a, _b;
730
707
  if (value === source)
731
708
  return;
732
709
  const old = source;
733
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
710
+ if (options.onBeforeChange?.(value, old) === false)
734
711
  return;
735
712
  source = value;
736
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
713
+ options.onChanged?.(value, old);
737
714
  if (triggering)
738
715
  trigger();
739
716
  }
@@ -771,8 +748,39 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
771
748
  }
772
749
  }
773
750
 
751
+ function watchWithFilter(source, cb, options = {}) {
752
+ const {
753
+ eventFilter = bypassFilter,
754
+ ...watchOptions
755
+ } = options;
756
+ return vueDemi.watch(
757
+ source,
758
+ createFilterWrapper(
759
+ eventFilter,
760
+ cb
761
+ ),
762
+ watchOptions
763
+ );
764
+ }
765
+
766
+ function watchPausable(source, cb, options = {}) {
767
+ const {
768
+ eventFilter: filter,
769
+ ...watchOptions
770
+ } = options;
771
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
772
+ const stop = watchWithFilter(
773
+ source,
774
+ cb,
775
+ {
776
+ ...watchOptions,
777
+ eventFilter
778
+ }
779
+ );
780
+ return { stop, pause, resume, isActive };
781
+ }
782
+
774
783
  function syncRef(left, right, options = {}) {
775
- var _a, _b;
776
784
  const {
777
785
  flush = "sync",
778
786
  deep = false,
@@ -780,28 +788,35 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
780
788
  direction = "both",
781
789
  transform = {}
782
790
  } = options;
783
- let watchLeft;
784
- let watchRight;
785
- const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
786
- const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
791
+ const watchers = [];
792
+ const transformLTR = transform.ltr ?? ((v) => v);
793
+ const transformRTL = transform.rtl ?? ((v) => v);
787
794
  if (direction === "both" || direction === "ltr") {
788
- watchLeft = vueDemi.watch(
795
+ watchers.push(watchPausable(
789
796
  left,
790
- (newValue) => right.value = transformLTR(newValue),
797
+ (newValue) => {
798
+ watchers.forEach((w) => w.pause());
799
+ right.value = transformLTR(newValue);
800
+ watchers.forEach((w) => w.resume());
801
+ },
791
802
  { flush, deep, immediate }
792
- );
803
+ ));
793
804
  }
794
805
  if (direction === "both" || direction === "rtl") {
795
- watchRight = vueDemi.watch(
806
+ watchers.push(watchPausable(
796
807
  right,
797
- (newValue) => left.value = transformRTL(newValue),
808
+ (newValue) => {
809
+ watchers.forEach((w) => w.pause());
810
+ left.value = transformRTL(newValue);
811
+ watchers.forEach((w) => w.resume());
812
+ },
798
813
  { flush, deep, immediate }
799
- );
814
+ ));
800
815
  }
801
- return () => {
802
- watchLeft == null ? void 0 : watchLeft();
803
- watchRight == null ? void 0 : watchRight();
816
+ const stop = () => {
817
+ watchers.forEach((w) => w.stop());
804
818
  };
819
+ return stop;
805
820
  }
806
821
 
807
822
  function syncRefs(source, targets, options = {}) {
@@ -819,43 +834,29 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
819
834
  );
820
835
  }
821
836
 
822
- var __defProp$9 = Object.defineProperty;
823
- var __defProps$7 = Object.defineProperties;
824
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
825
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
826
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
827
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
828
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
829
- var __spreadValues$9 = (a, b) => {
830
- for (var prop in b || (b = {}))
831
- if (__hasOwnProp$b.call(b, prop))
832
- __defNormalProp$9(a, prop, b[prop]);
833
- if (__getOwnPropSymbols$b)
834
- for (var prop of __getOwnPropSymbols$b(b)) {
835
- if (__propIsEnum$b.call(b, prop))
836
- __defNormalProp$9(a, prop, b[prop]);
837
- }
838
- return a;
839
- };
840
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
841
- function toRefs(objectRef) {
837
+ function toRefs(objectRef, options = {}) {
842
838
  if (!vueDemi.isRef(objectRef))
843
839
  return vueDemi.toRefs(objectRef);
844
- const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
840
+ const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
845
841
  for (const key in objectRef.value) {
846
842
  result[key] = vueDemi.customRef(() => ({
847
843
  get() {
848
844
  return objectRef.value[key];
849
845
  },
850
846
  set(v) {
851
- if (Array.isArray(objectRef.value)) {
852
- const copy = [...objectRef.value];
853
- copy[key] = v;
854
- objectRef.value = copy;
847
+ const replaceRef = toValue(options.replaceRef) ?? true;
848
+ if (replaceRef) {
849
+ if (Array.isArray(objectRef.value)) {
850
+ const copy = [...objectRef.value];
851
+ copy[key] = v;
852
+ objectRef.value = copy;
853
+ } else {
854
+ const newObject = { ...objectRef.value, [key]: v };
855
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
856
+ objectRef.value = newObject;
857
+ }
855
858
  } else {
856
- const newObject = __spreadProps$7(__spreadValues$9({}, objectRef.value), { [key]: v });
857
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
858
- objectRef.value = newObject;
859
+ objectRef.value[key] = v;
859
860
  }
860
861
  }
861
862
  }));
@@ -899,7 +900,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
899
900
  r,
900
901
  (v) => {
901
902
  if (condition(v) !== isNot) {
902
- stop == null ? void 0 : stop();
903
+ stop?.();
903
904
  resolve(v);
904
905
  }
905
906
  },
@@ -913,7 +914,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
913
914
  const promises = [watcher];
914
915
  if (timeout != null) {
915
916
  promises.push(
916
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
917
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop?.())
917
918
  );
918
919
  }
919
920
  return Promise.race(promises);
@@ -921,14 +922,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
921
922
  function toBe(value, options) {
922
923
  if (!vueDemi.isRef(value))
923
924
  return toMatch((v) => v === value, options);
924
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
925
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options ?? {};
925
926
  let stop = null;
926
927
  const watcher = new Promise((resolve) => {
927
928
  stop = vueDemi.watch(
928
929
  [r, value],
929
930
  ([v1, v2]) => {
930
931
  if (isNot !== (v1 === v2)) {
931
- stop == null ? void 0 : stop();
932
+ stop?.();
932
933
  resolve(v1);
933
934
  }
934
935
  },
@@ -943,7 +944,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
943
944
  if (timeout != null) {
944
945
  promises.push(
945
946
  promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
946
- stop == null ? void 0 : stop();
947
+ stop?.();
947
948
  return toValue(r);
948
949
  })
949
950
  );
@@ -1014,10 +1015,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1014
1015
  return value === othVal;
1015
1016
  }
1016
1017
  function useArrayDifference(...args) {
1017
- var _a;
1018
1018
  const list = args[0];
1019
1019
  const values = args[1];
1020
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
1020
+ let compareFn = args[2] ?? defaultComparator;
1021
1021
  if (typeof compareFn === "string") {
1022
1022
  const key = compareFn;
1023
1023
  compareFn = (value, othVal) => value[key] === othVal[key];
@@ -1065,20 +1065,19 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1065
1065
  return isObject(obj) && containsProp(obj, "formIndex", "comparator");
1066
1066
  }
1067
1067
  function useArrayIncludes(...args) {
1068
- var _a;
1069
1068
  const list = args[0];
1070
1069
  const value = args[1];
1071
1070
  let comparator = args[2];
1072
1071
  let formIndex = 0;
1073
1072
  if (isArrayIncludesOptions(comparator)) {
1074
- formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
1073
+ formIndex = comparator.fromIndex ?? 0;
1075
1074
  comparator = comparator.comparator;
1076
1075
  }
1077
1076
  if (typeof comparator === "string") {
1078
1077
  const key = comparator;
1079
1078
  comparator = (element, value2) => element[key] === toValue(value2);
1080
1079
  }
1081
- comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
1080
+ comparator = comparator ?? ((element, value2) => element === toValue(value2));
1082
1081
  return vueDemi.computed(
1083
1082
  () => toValue(list).slice(formIndex).some(
1084
1083
  (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
@@ -1124,17 +1123,18 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1124
1123
  }
1125
1124
 
1126
1125
  function useCounter(initialValue = 0, options = {}) {
1126
+ let _initialValue = vueDemi.unref(initialValue);
1127
1127
  const count = vueDemi.ref(initialValue);
1128
1128
  const {
1129
- max = Infinity,
1130
- min = -Infinity
1129
+ max = Number.POSITIVE_INFINITY,
1130
+ min = Number.NEGATIVE_INFINITY
1131
1131
  } = options;
1132
1132
  const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1133
1133
  const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1134
1134
  const get = () => count.value;
1135
1135
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1136
- const reset = (val = initialValue) => {
1137
- initialValue = val;
1136
+ const reset = (val = _initialValue) => {
1137
+ _initialValue = val;
1138
1138
  return set(val);
1139
1139
  };
1140
1140
  return { count, inc, dec, get, set, reset };
@@ -1149,7 +1149,6 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1149
1149
  return isLowercase ? m.toLowerCase() : m;
1150
1150
  }
1151
1151
  function formatDate(date, formatStr, options = {}) {
1152
- var _a;
1153
1152
  const years = date.getFullYear();
1154
1153
  const month = date.getMonth();
1155
1154
  const days = date.getDate();
@@ -1158,7 +1157,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1158
1157
  const seconds = date.getSeconds();
1159
1158
  const milliseconds = date.getMilliseconds();
1160
1159
  const day = date.getDay();
1161
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
1160
+ const meridiem = options.customMeridiem ?? defaultMeridiem;
1162
1161
  const matches = {
1163
1162
  YY: () => String(years).slice(-2),
1164
1163
  YYYY: () => years,
@@ -1186,14 +1185,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1186
1185
  a: () => meridiem(hours, minutes, true),
1187
1186
  aa: () => meridiem(hours, minutes, true, true)
1188
1187
  };
1189
- return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1190
- var _a2;
1191
- return $1 || ((_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) || match;
1192
- });
1188
+ return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 ?? matches[match]?.() ?? match);
1193
1189
  }
1194
1190
  function normalizeDate(date) {
1195
1191
  if (date === null)
1196
- return /* @__PURE__ */ new Date(NaN);
1192
+ return new Date(Number.NaN);
1197
1193
  if (date === void 0)
1198
1194
  return /* @__PURE__ */ new Date();
1199
1195
  if (date instanceof Date)
@@ -1256,22 +1252,6 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1256
1252
  };
1257
1253
  }
1258
1254
 
1259
- var __defProp$8 = Object.defineProperty;
1260
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1261
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1262
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1263
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1264
- var __spreadValues$8 = (a, b) => {
1265
- for (var prop in b || (b = {}))
1266
- if (__hasOwnProp$a.call(b, prop))
1267
- __defNormalProp$8(a, prop, b[prop]);
1268
- if (__getOwnPropSymbols$a)
1269
- for (var prop of __getOwnPropSymbols$a(b)) {
1270
- if (__propIsEnum$a.call(b, prop))
1271
- __defNormalProp$8(a, prop, b[prop]);
1272
- }
1273
- return a;
1274
- };
1275
1255
  function useInterval(interval = 1e3, options = {}) {
1276
1256
  const {
1277
1257
  controls: exposeControls = false,
@@ -1292,18 +1272,18 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1292
1272
  { immediate }
1293
1273
  );
1294
1274
  if (exposeControls) {
1295
- return __spreadValues$8({
1275
+ return {
1296
1276
  counter,
1297
- reset
1298
- }, controls);
1277
+ reset,
1278
+ ...controls
1279
+ };
1299
1280
  } else {
1300
1281
  return counter;
1301
1282
  }
1302
1283
  }
1303
1284
 
1304
1285
  function useLastChanged(source, options = {}) {
1305
- var _a;
1306
- const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
1286
+ const ms = vueDemi.ref(options.initialValue ?? null);
1307
1287
  vueDemi.watch(
1308
1288
  source,
1309
1289
  () => ms.value = timestamp(),
@@ -1350,37 +1330,22 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1350
1330
  };
1351
1331
  }
1352
1332
 
1353
- var __defProp$7 = Object.defineProperty;
1354
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1355
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1356
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1357
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1358
- var __spreadValues$7 = (a, b) => {
1359
- for (var prop in b || (b = {}))
1360
- if (__hasOwnProp$9.call(b, prop))
1361
- __defNormalProp$7(a, prop, b[prop]);
1362
- if (__getOwnPropSymbols$9)
1363
- for (var prop of __getOwnPropSymbols$9(b)) {
1364
- if (__propIsEnum$9.call(b, prop))
1365
- __defNormalProp$7(a, prop, b[prop]);
1366
- }
1367
- return a;
1368
- };
1369
1333
  function useTimeout(interval = 1e3, options = {}) {
1370
1334
  const {
1371
1335
  controls: exposeControls = false,
1372
1336
  callback
1373
1337
  } = options;
1374
1338
  const controls = useTimeoutFn(
1375
- callback != null ? callback : noop,
1339
+ callback ?? noop,
1376
1340
  interval,
1377
1341
  options
1378
1342
  );
1379
1343
  const ready = vueDemi.computed(() => !controls.isPending.value);
1380
1344
  if (exposeControls) {
1381
- return __spreadValues$7({
1382
- ready
1383
- }, controls);
1345
+ return {
1346
+ ready,
1347
+ ...controls
1348
+ };
1384
1349
  } else {
1385
1350
  return ready;
1386
1351
  }
@@ -1430,11 +1395,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1430
1395
  }
1431
1396
 
1432
1397
  function watchArray(source, cb, options) {
1433
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1398
+ let oldList = options?.immediate ? [] : [
1434
1399
  ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1435
1400
  ];
1436
1401
  return vueDemi.watch(source, (newList, _, onCleanup) => {
1437
- const oldListRemains = new Array(oldList.length);
1402
+ const oldListRemains = Array.from({ length: oldList.length });
1438
1403
  const added = [];
1439
1404
  for (const obj of newList) {
1440
1405
  let found = false;
@@ -1454,58 +1419,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1454
1419
  }, options);
1455
1420
  }
1456
1421
 
1457
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1458
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1459
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1460
- var __objRest$5 = (source, exclude) => {
1461
- var target = {};
1462
- for (var prop in source)
1463
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
1464
- target[prop] = source[prop];
1465
- if (source != null && __getOwnPropSymbols$8)
1466
- for (var prop of __getOwnPropSymbols$8(source)) {
1467
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
1468
- target[prop] = source[prop];
1469
- }
1470
- return target;
1471
- };
1472
- function watchWithFilter(source, cb, options = {}) {
1473
- const _a = options, {
1474
- eventFilter = bypassFilter
1475
- } = _a, watchOptions = __objRest$5(_a, [
1476
- "eventFilter"
1477
- ]);
1478
- return vueDemi.watch(
1479
- source,
1480
- createFilterWrapper(
1481
- eventFilter,
1482
- cb
1483
- ),
1484
- watchOptions
1485
- );
1486
- }
1487
-
1488
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1489
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1490
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1491
- var __objRest$4 = (source, exclude) => {
1492
- var target = {};
1493
- for (var prop in source)
1494
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1495
- target[prop] = source[prop];
1496
- if (source != null && __getOwnPropSymbols$7)
1497
- for (var prop of __getOwnPropSymbols$7(source)) {
1498
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
1499
- target[prop] = source[prop];
1500
- }
1501
- return target;
1502
- };
1503
1422
  function watchAtMost(source, cb, options) {
1504
- const _a = options, {
1505
- count
1506
- } = _a, watchOptions = __objRest$4(_a, [
1507
- "count"
1508
- ]);
1423
+ const {
1424
+ count,
1425
+ ...watchOptions
1426
+ } = options;
1509
1427
  const current = vueDemi.ref(0);
1510
1428
  const stop = watchWithFilter(
1511
1429
  source,
@@ -1520,120 +1438,38 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1520
1438
  return { count: current, stop };
1521
1439
  }
1522
1440
 
1523
- var __defProp$6 = Object.defineProperty;
1524
- var __defProps$6 = Object.defineProperties;
1525
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1526
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1527
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1528
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1529
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1530
- var __spreadValues$6 = (a, b) => {
1531
- for (var prop in b || (b = {}))
1532
- if (__hasOwnProp$6.call(b, prop))
1533
- __defNormalProp$6(a, prop, b[prop]);
1534
- if (__getOwnPropSymbols$6)
1535
- for (var prop of __getOwnPropSymbols$6(b)) {
1536
- if (__propIsEnum$6.call(b, prop))
1537
- __defNormalProp$6(a, prop, b[prop]);
1538
- }
1539
- return a;
1540
- };
1541
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1542
- var __objRest$3 = (source, exclude) => {
1543
- var target = {};
1544
- for (var prop in source)
1545
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1546
- target[prop] = source[prop];
1547
- if (source != null && __getOwnPropSymbols$6)
1548
- for (var prop of __getOwnPropSymbols$6(source)) {
1549
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1550
- target[prop] = source[prop];
1551
- }
1552
- return target;
1553
- };
1554
1441
  function watchDebounced(source, cb, options = {}) {
1555
- const _a = options, {
1442
+ const {
1556
1443
  debounce = 0,
1557
- maxWait = void 0
1558
- } = _a, watchOptions = __objRest$3(_a, [
1559
- "debounce",
1560
- "maxWait"
1561
- ]);
1444
+ maxWait = void 0,
1445
+ ...watchOptions
1446
+ } = options;
1562
1447
  return watchWithFilter(
1563
1448
  source,
1564
1449
  cb,
1565
- __spreadProps$6(__spreadValues$6({}, watchOptions), {
1450
+ {
1451
+ ...watchOptions,
1566
1452
  eventFilter: debounceFilter(debounce, { maxWait })
1567
- })
1453
+ }
1568
1454
  );
1569
1455
  }
1570
1456
 
1571
- var __defProp$5 = Object.defineProperty;
1572
- var __defProps$5 = Object.defineProperties;
1573
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1574
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1575
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1576
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1577
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1578
- var __spreadValues$5 = (a, b) => {
1579
- for (var prop in b || (b = {}))
1580
- if (__hasOwnProp$5.call(b, prop))
1581
- __defNormalProp$5(a, prop, b[prop]);
1582
- if (__getOwnPropSymbols$5)
1583
- for (var prop of __getOwnPropSymbols$5(b)) {
1584
- if (__propIsEnum$5.call(b, prop))
1585
- __defNormalProp$5(a, prop, b[prop]);
1586
- }
1587
- return a;
1588
- };
1589
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1590
1457
  function watchDeep(source, cb, options) {
1591
1458
  return vueDemi.watch(
1592
1459
  source,
1593
1460
  cb,
1594
- __spreadProps$5(__spreadValues$5({}, options), {
1461
+ {
1462
+ ...options,
1595
1463
  deep: true
1596
- })
1464
+ }
1597
1465
  );
1598
1466
  }
1599
1467
 
1600
- var __defProp$4 = Object.defineProperty;
1601
- var __defProps$4 = Object.defineProperties;
1602
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1603
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1604
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1605
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1606
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1607
- var __spreadValues$4 = (a, b) => {
1608
- for (var prop in b || (b = {}))
1609
- if (__hasOwnProp$4.call(b, prop))
1610
- __defNormalProp$4(a, prop, b[prop]);
1611
- if (__getOwnPropSymbols$4)
1612
- for (var prop of __getOwnPropSymbols$4(b)) {
1613
- if (__propIsEnum$4.call(b, prop))
1614
- __defNormalProp$4(a, prop, b[prop]);
1615
- }
1616
- return a;
1617
- };
1618
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1619
- var __objRest$2 = (source, exclude) => {
1620
- var target = {};
1621
- for (var prop in source)
1622
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1623
- target[prop] = source[prop];
1624
- if (source != null && __getOwnPropSymbols$4)
1625
- for (var prop of __getOwnPropSymbols$4(source)) {
1626
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1627
- target[prop] = source[prop];
1628
- }
1629
- return target;
1630
- };
1631
1468
  function watchIgnorable(source, cb, options = {}) {
1632
- const _a = options, {
1633
- eventFilter = bypassFilter
1634
- } = _a, watchOptions = __objRest$2(_a, [
1635
- "eventFilter"
1636
- ]);
1469
+ const {
1470
+ eventFilter = bypassFilter,
1471
+ ...watchOptions
1472
+ } = options;
1637
1473
  const filteredCb = createFilterWrapper(
1638
1474
  eventFilter,
1639
1475
  cb
@@ -1671,7 +1507,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1671
1507
  () => {
1672
1508
  syncCounter.value++;
1673
1509
  },
1674
- __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })
1510
+ { ...watchOptions, flush: "sync" }
1675
1511
  )
1676
1512
  );
1677
1513
  ignoreUpdates = (updater) => {
@@ -1700,32 +1536,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1700
1536
  return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1701
1537
  }
1702
1538
 
1703
- var __defProp$3 = Object.defineProperty;
1704
- var __defProps$3 = Object.defineProperties;
1705
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1706
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1707
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1708
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1709
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1710
- var __spreadValues$3 = (a, b) => {
1711
- for (var prop in b || (b = {}))
1712
- if (__hasOwnProp$3.call(b, prop))
1713
- __defNormalProp$3(a, prop, b[prop]);
1714
- if (__getOwnPropSymbols$3)
1715
- for (var prop of __getOwnPropSymbols$3(b)) {
1716
- if (__propIsEnum$3.call(b, prop))
1717
- __defNormalProp$3(a, prop, b[prop]);
1718
- }
1719
- return a;
1720
- };
1721
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1722
1539
  function watchImmediate(source, cb, options) {
1723
1540
  return vueDemi.watch(
1724
1541
  source,
1725
1542
  cb,
1726
- __spreadProps$3(__spreadValues$3({}, options), {
1543
+ {
1544
+ ...options,
1727
1545
  immediate: true
1728
- })
1546
+ }
1729
1547
  );
1730
1548
  }
1731
1549
 
@@ -1736,123 +1554,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1736
1554
  }, options);
1737
1555
  }
1738
1556
 
1739
- var __defProp$2 = Object.defineProperty;
1740
- var __defProps$2 = Object.defineProperties;
1741
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1742
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1743
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1744
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1745
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1746
- var __spreadValues$2 = (a, b) => {
1747
- for (var prop in b || (b = {}))
1748
- if (__hasOwnProp$2.call(b, prop))
1749
- __defNormalProp$2(a, prop, b[prop]);
1750
- if (__getOwnPropSymbols$2)
1751
- for (var prop of __getOwnPropSymbols$2(b)) {
1752
- if (__propIsEnum$2.call(b, prop))
1753
- __defNormalProp$2(a, prop, b[prop]);
1754
- }
1755
- return a;
1756
- };
1757
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1758
- var __objRest$1 = (source, exclude) => {
1759
- var target = {};
1760
- for (var prop in source)
1761
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1762
- target[prop] = source[prop];
1763
- if (source != null && __getOwnPropSymbols$2)
1764
- for (var prop of __getOwnPropSymbols$2(source)) {
1765
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1766
- target[prop] = source[prop];
1767
- }
1768
- return target;
1769
- };
1770
- function watchPausable(source, cb, options = {}) {
1771
- const _a = options, {
1772
- eventFilter: filter
1773
- } = _a, watchOptions = __objRest$1(_a, [
1774
- "eventFilter"
1775
- ]);
1776
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1777
- const stop = watchWithFilter(
1778
- source,
1779
- cb,
1780
- __spreadProps$2(__spreadValues$2({}, watchOptions), {
1781
- eventFilter
1782
- })
1783
- );
1784
- return { stop, pause, resume, isActive };
1785
- }
1786
-
1787
- var __defProp$1 = Object.defineProperty;
1788
- var __defProps$1 = Object.defineProperties;
1789
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1790
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1791
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1792
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1793
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1794
- var __spreadValues$1 = (a, b) => {
1795
- for (var prop in b || (b = {}))
1796
- if (__hasOwnProp$1.call(b, prop))
1797
- __defNormalProp$1(a, prop, b[prop]);
1798
- if (__getOwnPropSymbols$1)
1799
- for (var prop of __getOwnPropSymbols$1(b)) {
1800
- if (__propIsEnum$1.call(b, prop))
1801
- __defNormalProp$1(a, prop, b[prop]);
1802
- }
1803
- return a;
1804
- };
1805
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1806
- var __objRest = (source, exclude) => {
1807
- var target = {};
1808
- for (var prop in source)
1809
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1810
- target[prop] = source[prop];
1811
- if (source != null && __getOwnPropSymbols$1)
1812
- for (var prop of __getOwnPropSymbols$1(source)) {
1813
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1814
- target[prop] = source[prop];
1815
- }
1816
- return target;
1817
- };
1818
1557
  function watchThrottled(source, cb, options = {}) {
1819
- const _a = options, {
1558
+ const {
1820
1559
  throttle = 0,
1821
1560
  trailing = true,
1822
- leading = true
1823
- } = _a, watchOptions = __objRest(_a, [
1824
- "throttle",
1825
- "trailing",
1826
- "leading"
1827
- ]);
1561
+ leading = true,
1562
+ ...watchOptions
1563
+ } = options;
1828
1564
  return watchWithFilter(
1829
1565
  source,
1830
1566
  cb,
1831
- __spreadProps$1(__spreadValues$1({}, watchOptions), {
1567
+ {
1568
+ ...watchOptions,
1832
1569
  eventFilter: throttleFilter(throttle, trailing, leading)
1833
- })
1570
+ }
1834
1571
  );
1835
1572
  }
1836
1573
 
1837
- var __defProp = Object.defineProperty;
1838
- var __defProps = Object.defineProperties;
1839
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1840
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1841
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1842
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1843
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1844
- var __spreadValues = (a, b) => {
1845
- for (var prop in b || (b = {}))
1846
- if (__hasOwnProp.call(b, prop))
1847
- __defNormalProp(a, prop, b[prop]);
1848
- if (__getOwnPropSymbols)
1849
- for (var prop of __getOwnPropSymbols(b)) {
1850
- if (__propIsEnum.call(b, prop))
1851
- __defNormalProp(a, prop, b[prop]);
1852
- }
1853
- return a;
1854
- };
1855
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1856
1574
  function watchTriggerable(source, cb, options = {}) {
1857
1575
  let cleanupFn;
1858
1576
  function onEffect() {
@@ -1878,9 +1596,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1878
1596
  });
1879
1597
  return res2;
1880
1598
  };
1881
- return __spreadProps(__spreadValues({}, res), {
1599
+ return {
1600
+ ...res,
1882
1601
  trigger
1883
- });
1602
+ };
1884
1603
  }
1885
1604
  function getWatchSources(sources) {
1886
1605
  if (vueDemi.isReactive(sources))
@@ -1907,6 +1626,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1907
1626
  exports.assert = assert;
1908
1627
  exports.autoResetRef = refAutoReset;
1909
1628
  exports.bypassFilter = bypassFilter;
1629
+ exports.camelize = camelize;
1910
1630
  exports.clamp = clamp;
1911
1631
  exports.computedEager = computedEager;
1912
1632
  exports.computedWithControl = computedWithControl;
@@ -1929,6 +1649,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1929
1649
  exports.formatDate = formatDate;
1930
1650
  exports.get = get;
1931
1651
  exports.hasOwn = hasOwn;
1652
+ exports.hyphenate = hyphenate;
1932
1653
  exports.identity = identity;
1933
1654
  exports.ignorableWatch = watchIgnorable;
1934
1655
  exports.increaseWithUnit = increaseWithUnit;