@vueuse/shared 8.9.4 → 9.0.0-beta.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.cjs +71 -45
- package/index.d.ts +60 -55
- package/index.iife.js +72 -63
- package/index.iife.min.js +1 -1
- package/index.mjs +66 -41
- package/package.json +1 -13
package/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var vueDemi = require('vue-demi');
|
|
6
|
+
var shared = require('@vueuse/shared');
|
|
6
7
|
|
|
7
8
|
var __defProp$9 = Object.defineProperty;
|
|
8
9
|
var __defProps$6 = Object.defineProperties;
|
|
@@ -60,6 +61,10 @@ const rand = (min, max) => {
|
|
|
60
61
|
};
|
|
61
62
|
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
62
63
|
|
|
64
|
+
function resolveUnref(r) {
|
|
65
|
+
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
function createFilterWrapper(filter, fn) {
|
|
64
69
|
function wrapper(...args) {
|
|
65
70
|
filter(() => fn.apply(this, args), { fn, thisArg: this, args });
|
|
@@ -73,8 +78,8 @@ function debounceFilter(ms, options = {}) {
|
|
|
73
78
|
let timer;
|
|
74
79
|
let maxTimer;
|
|
75
80
|
const filter = (invoke) => {
|
|
76
|
-
const duration =
|
|
77
|
-
const maxDuration =
|
|
81
|
+
const duration = resolveUnref(ms);
|
|
82
|
+
const maxDuration = resolveUnref(options.maxWait);
|
|
78
83
|
if (timer)
|
|
79
84
|
clearTimeout(timer);
|
|
80
85
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
@@ -112,7 +117,7 @@ function throttleFilter(ms, trailing = true, leading = true) {
|
|
|
112
117
|
}
|
|
113
118
|
};
|
|
114
119
|
const filter = (invoke) => {
|
|
115
|
-
const duration =
|
|
120
|
+
const duration = resolveUnref(ms);
|
|
116
121
|
const elapsed = Date.now() - lastExec;
|
|
117
122
|
clear();
|
|
118
123
|
if (duration <= 0) {
|
|
@@ -357,18 +362,6 @@ function isDefined(v) {
|
|
|
357
362
|
return vueDemi.unref(v) != null;
|
|
358
363
|
}
|
|
359
364
|
|
|
360
|
-
function logicAnd(...args) {
|
|
361
|
-
return vueDemi.computed(() => args.every((i) => vueDemi.unref(i)));
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function logicNot(v) {
|
|
365
|
-
return vueDemi.computed(() => !vueDemi.unref(v));
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function logicOr(...args) {
|
|
369
|
-
return vueDemi.computed(() => args.some((i) => vueDemi.unref(i)));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
365
|
var __defProp$8 = Object.defineProperty;
|
|
373
366
|
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
374
367
|
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
@@ -406,17 +399,20 @@ function makeDestructurable(obj, arr) {
|
|
|
406
399
|
}
|
|
407
400
|
}
|
|
408
401
|
|
|
409
|
-
function reactify(fn) {
|
|
402
|
+
function reactify(fn, options) {
|
|
403
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
|
|
410
404
|
return function(...args) {
|
|
411
|
-
return vueDemi.computed(() => fn.apply(this, args.map((i) =>
|
|
405
|
+
return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
412
406
|
};
|
|
413
407
|
}
|
|
414
408
|
|
|
415
409
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
416
410
|
let keys = [];
|
|
411
|
+
let options;
|
|
417
412
|
if (Array.isArray(optionsOrKeys)) {
|
|
418
413
|
keys = optionsOrKeys;
|
|
419
414
|
} else {
|
|
415
|
+
options = optionsOrKeys;
|
|
420
416
|
const { includeOwnProperties = true } = optionsOrKeys;
|
|
421
417
|
keys.push(...Object.keys(obj));
|
|
422
418
|
if (includeOwnProperties)
|
|
@@ -426,7 +422,7 @@ function reactifyObject(obj, optionsOrKeys = {}) {
|
|
|
426
422
|
const value = obj[key];
|
|
427
423
|
return [
|
|
428
424
|
key,
|
|
429
|
-
typeof value === "function" ? reactify(value.bind(obj)) : value
|
|
425
|
+
typeof value === "function" ? reactify(value.bind(obj), options) : value
|
|
430
426
|
];
|
|
431
427
|
}));
|
|
432
428
|
}
|
|
@@ -485,7 +481,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
|
485
481
|
const resetAfter = () => setTimeout(() => {
|
|
486
482
|
value = defaultValue;
|
|
487
483
|
trigger();
|
|
488
|
-
},
|
|
484
|
+
}, shared.resolveUnref(afterMs));
|
|
489
485
|
tryOnScopeDispose(() => {
|
|
490
486
|
clearTimeout(timer);
|
|
491
487
|
});
|
|
@@ -531,7 +527,7 @@ function refDefault(source, defaultValue) {
|
|
|
531
527
|
});
|
|
532
528
|
}
|
|
533
529
|
|
|
534
|
-
function useThrottleFn(fn, ms = 200, trailing =
|
|
530
|
+
function useThrottleFn(fn, ms = 200, trailing = false, leading = true) {
|
|
535
531
|
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
536
532
|
}
|
|
537
533
|
|
|
@@ -598,10 +594,6 @@ function resolveRef(r) {
|
|
|
598
594
|
return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
|
|
599
595
|
}
|
|
600
596
|
|
|
601
|
-
function resolveUnref(r) {
|
|
602
|
-
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
597
|
function set(...args) {
|
|
606
598
|
if (args.length === 2) {
|
|
607
599
|
const [ref, value] = args;
|
|
@@ -738,7 +730,7 @@ function until(r) {
|
|
|
738
730
|
});
|
|
739
731
|
const promises = [watcher];
|
|
740
732
|
if (timeout != null) {
|
|
741
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
733
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
|
|
742
734
|
}
|
|
743
735
|
return Promise.race(promises);
|
|
744
736
|
}
|
|
@@ -761,9 +753,9 @@ function until(r) {
|
|
|
761
753
|
});
|
|
762
754
|
const promises = [watcher];
|
|
763
755
|
if (timeout != null) {
|
|
764
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
756
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
|
|
765
757
|
stop == null ? void 0 : stop();
|
|
766
|
-
return
|
|
758
|
+
return resolveUnref(r);
|
|
767
759
|
}));
|
|
768
760
|
}
|
|
769
761
|
return Promise.race(promises);
|
|
@@ -783,7 +775,7 @@ function until(r) {
|
|
|
783
775
|
function toContains(value, options) {
|
|
784
776
|
return toMatch((v) => {
|
|
785
777
|
const array = Array.from(v);
|
|
786
|
-
return array.includes(value) || array.includes(
|
|
778
|
+
return array.includes(value) || array.includes(resolveUnref(value));
|
|
787
779
|
}, options);
|
|
788
780
|
}
|
|
789
781
|
function changed(options) {
|
|
@@ -796,7 +788,7 @@ function until(r) {
|
|
|
796
788
|
return count >= n;
|
|
797
789
|
}, options);
|
|
798
790
|
}
|
|
799
|
-
if (Array.isArray(
|
|
791
|
+
if (Array.isArray(resolveUnref(r))) {
|
|
800
792
|
const instance = {
|
|
801
793
|
toMatch,
|
|
802
794
|
toContains,
|
|
@@ -827,6 +819,38 @@ function until(r) {
|
|
|
827
819
|
}
|
|
828
820
|
}
|
|
829
821
|
|
|
822
|
+
function useArrayEvery(list, fn) {
|
|
823
|
+
return vueDemi.computed(() => shared.resolveUnref(list).every((element, index, array) => fn(shared.resolveUnref(element), index, array)));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function useArrayFilter(list, fn) {
|
|
827
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).filter(fn));
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function useArrayFind(list, fn) {
|
|
831
|
+
return vueDemi.computed(() => shared.resolveUnref(shared.resolveUnref(list).find((element, index, array) => fn(shared.resolveUnref(element), index, array))));
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function useArrayJoin(list, separator) {
|
|
835
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).join(shared.resolveUnref(separator)));
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function useArrayMap(list, fn) {
|
|
839
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).map(fn));
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function useArrayReduce(list, reducer, ...args) {
|
|
843
|
+
const reduceCallback = (sum, value, index) => reducer(shared.resolveUnref(sum), shared.resolveUnref(value), index);
|
|
844
|
+
return vueDemi.computed(() => {
|
|
845
|
+
const resolved = shared.resolveUnref(list);
|
|
846
|
+
return args.length ? resolved.reduce(reduceCallback, shared.resolveUnref(args[0])) : resolved.reduce(reduceCallback);
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function useArraySome(list, fn) {
|
|
851
|
+
return vueDemi.computed(() => shared.resolveUnref(list).some((element, index, array) => fn(shared.resolveUnref(element), index, array)));
|
|
852
|
+
}
|
|
853
|
+
|
|
830
854
|
function useCounter(initialValue = 0, options = {}) {
|
|
831
855
|
const count = vueDemi.ref(initialValue);
|
|
832
856
|
const {
|
|
@@ -893,7 +917,7 @@ const normalizeDate = (date) => {
|
|
|
893
917
|
return new Date(date);
|
|
894
918
|
};
|
|
895
919
|
function useDateFormat(date, formatStr = "HH:mm:ss") {
|
|
896
|
-
return vueDemi.computed(() => formatDate(normalizeDate(
|
|
920
|
+
return vueDemi.computed(() => formatDate(normalizeDate(shared.resolveUnref(date)), shared.resolveUnref(formatStr)));
|
|
897
921
|
}
|
|
898
922
|
|
|
899
923
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -920,7 +944,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
920
944
|
if (immediateCallback)
|
|
921
945
|
cb();
|
|
922
946
|
clean();
|
|
923
|
-
timer = setInterval(cb,
|
|
947
|
+
timer = setInterval(cb, resolveUnref(interval));
|
|
924
948
|
}
|
|
925
949
|
if (immediate && isClient)
|
|
926
950
|
resume();
|
|
@@ -1001,7 +1025,7 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1001
1025
|
isPending.value = false;
|
|
1002
1026
|
timer = null;
|
|
1003
1027
|
cb(...args);
|
|
1004
|
-
},
|
|
1028
|
+
}, shared.resolveUnref(interval));
|
|
1005
1029
|
}
|
|
1006
1030
|
if (immediate) {
|
|
1007
1031
|
isPending.value = true;
|
|
@@ -1053,20 +1077,21 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1053
1077
|
falsyValue = false
|
|
1054
1078
|
} = options;
|
|
1055
1079
|
const valueIsRef = vueDemi.isRef(initialValue);
|
|
1056
|
-
const
|
|
1080
|
+
const _value = vueDemi.ref(initialValue);
|
|
1057
1081
|
function toggle(value) {
|
|
1058
1082
|
if (arguments.length) {
|
|
1059
|
-
|
|
1060
|
-
return
|
|
1083
|
+
_value.value = value;
|
|
1084
|
+
return _value.value;
|
|
1061
1085
|
} else {
|
|
1062
|
-
|
|
1063
|
-
|
|
1086
|
+
const truthy = resolveUnref(truthyValue);
|
|
1087
|
+
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
|
|
1088
|
+
return _value.value;
|
|
1064
1089
|
}
|
|
1065
1090
|
}
|
|
1066
1091
|
if (valueIsRef)
|
|
1067
1092
|
return toggle;
|
|
1068
1093
|
else
|
|
1069
|
-
return [
|
|
1094
|
+
return [_value, toggle];
|
|
1070
1095
|
}
|
|
1071
1096
|
|
|
1072
1097
|
function watchArray(source, cb, options) {
|
|
@@ -1142,7 +1167,7 @@ function watchAtMost(source, cb, options) {
|
|
|
1142
1167
|
const current = vueDemi.ref(0);
|
|
1143
1168
|
const stop = watchWithFilter(source, (...args) => {
|
|
1144
1169
|
current.value += 1;
|
|
1145
|
-
if (current.value >=
|
|
1170
|
+
if (current.value >= resolveUnref(count))
|
|
1146
1171
|
vueDemi.nextTick(() => stop());
|
|
1147
1172
|
cb(...args);
|
|
1148
1173
|
}, watchOptions);
|
|
@@ -1444,7 +1469,6 @@ function whenever(source, cb, options) {
|
|
|
1444
1469
|
}
|
|
1445
1470
|
|
|
1446
1471
|
exports.__onlyVue3 = __onlyVue3;
|
|
1447
|
-
exports.and = logicAnd;
|
|
1448
1472
|
exports.assert = assert;
|
|
1449
1473
|
exports.autoResetRef = refAutoReset;
|
|
1450
1474
|
exports.bypassFilter = bypassFilter;
|
|
@@ -1483,16 +1507,11 @@ exports.isNumber = isNumber;
|
|
|
1483
1507
|
exports.isObject = isObject;
|
|
1484
1508
|
exports.isString = isString;
|
|
1485
1509
|
exports.isWindow = isWindow;
|
|
1486
|
-
exports.logicAnd = logicAnd;
|
|
1487
|
-
exports.logicNot = logicNot;
|
|
1488
|
-
exports.logicOr = logicOr;
|
|
1489
1510
|
exports.makeDestructurable = makeDestructurable;
|
|
1490
1511
|
exports.noop = noop;
|
|
1491
1512
|
exports.normalizeDate = normalizeDate;
|
|
1492
|
-
exports.not = logicNot;
|
|
1493
1513
|
exports.now = now;
|
|
1494
1514
|
exports.objectPick = objectPick;
|
|
1495
|
-
exports.or = logicOr;
|
|
1496
1515
|
exports.pausableFilter = pausableFilter;
|
|
1497
1516
|
exports.pausableWatch = watchPausable;
|
|
1498
1517
|
exports.promiseTimeout = promiseTimeout;
|
|
@@ -1524,6 +1543,13 @@ exports.tryOnMounted = tryOnMounted;
|
|
|
1524
1543
|
exports.tryOnScopeDispose = tryOnScopeDispose;
|
|
1525
1544
|
exports.tryOnUnmounted = tryOnUnmounted;
|
|
1526
1545
|
exports.until = until;
|
|
1546
|
+
exports.useArrayEvery = useArrayEvery;
|
|
1547
|
+
exports.useArrayFilter = useArrayFilter;
|
|
1548
|
+
exports.useArrayFind = useArrayFind;
|
|
1549
|
+
exports.useArrayJoin = useArrayJoin;
|
|
1550
|
+
exports.useArrayMap = useArrayMap;
|
|
1551
|
+
exports.useArrayReduce = useArrayReduce;
|
|
1552
|
+
exports.useArraySome = useArraySome;
|
|
1527
1553
|
exports.useCounter = useCounter;
|
|
1528
1554
|
exports.useDateFormat = useDateFormat;
|
|
1529
1555
|
exports.useDebounce = refDebounced;
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, ShallowUnwrapRef as ShallowUnwrapRef$1, WatchOptions, UnwrapRef, ToRefs, WatchCallback, WatchStopHandle } from 'vue-demi';
|
|
3
|
-
import {
|
|
3
|
+
import { MaybeComputedRef as MaybeComputedRef$1 } from '@vueuse/shared';
|
|
4
4
|
|
|
5
5
|
declare function computedEager<T>(fn: () => T, options?: WatchOptionsBase): Readonly<Ref<T>>;
|
|
6
6
|
|
|
@@ -125,13 +125,13 @@ declare type RemoveableRef<T> = RemovableRef<T>;
|
|
|
125
125
|
*/
|
|
126
126
|
declare type MaybeRef<T> = T | Ref<T>;
|
|
127
127
|
/**
|
|
128
|
-
* Maybe it's a ref, or a getter function
|
|
128
|
+
* Maybe it's a ref, or a plain value, or a getter function
|
|
129
129
|
*
|
|
130
130
|
* ```ts
|
|
131
|
-
* type
|
|
131
|
+
* type MaybeComputedRef<T> = T | Ref<T> | (() => T)
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
|
-
declare type MaybeComputedRef<T> = T extends
|
|
134
|
+
declare type MaybeComputedRef<T> = T extends () => void ? never : (() => T) | MaybeRef<T>;
|
|
135
135
|
/**
|
|
136
136
|
* Make all the nested attributes of an object or array to MaybeRef<T>
|
|
137
137
|
*
|
|
@@ -150,6 +150,7 @@ declare type DeepMaybeRef<T> = T extends Ref<infer V> ? MaybeRef<V> : T extends
|
|
|
150
150
|
declare type ElementOf<T> = T extends (infer E)[] ? E : never;
|
|
151
151
|
declare type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T;
|
|
152
152
|
declare type Awaitable<T> = Promise<T> | T;
|
|
153
|
+
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
153
154
|
interface Pausable {
|
|
154
155
|
/**
|
|
155
156
|
* A ref indicate whether a pusable instance is active
|
|
@@ -226,7 +227,7 @@ interface DebounceFilterOptions {
|
|
|
226
227
|
* The maximum time allowed to be delayed before it's invoked.
|
|
227
228
|
* In milliseconds.
|
|
228
229
|
*/
|
|
229
|
-
maxWait?: number
|
|
230
|
+
maxWait?: MaybeComputedRef<number>;
|
|
230
231
|
}
|
|
231
232
|
/**
|
|
232
233
|
* @internal
|
|
@@ -239,7 +240,7 @@ declare const bypassFilter: EventFilter;
|
|
|
239
240
|
* @param ms
|
|
240
241
|
* @param [maxWait=null]
|
|
241
242
|
*/
|
|
242
|
-
declare function debounceFilter(ms:
|
|
243
|
+
declare function debounceFilter(ms: MaybeComputedRef<number>, options?: DebounceFilterOptions): EventFilter<any[], any>;
|
|
243
244
|
/**
|
|
244
245
|
* Create an EventFilter that throttle the events
|
|
245
246
|
*
|
|
@@ -247,7 +248,7 @@ declare function debounceFilter(ms: MaybeRef<number>, options?: DebounceFilterOp
|
|
|
247
248
|
* @param [trailing=true]
|
|
248
249
|
* @param [leading=true]
|
|
249
250
|
*/
|
|
250
|
-
declare function throttleFilter(ms:
|
|
251
|
+
declare function throttleFilter(ms: MaybeComputedRef<number>, trailing?: boolean, leading?: boolean): EventFilter<any[], any>;
|
|
251
252
|
/**
|
|
252
253
|
* EventFilter that gives extra controls to pause and resume the filter
|
|
253
254
|
*
|
|
@@ -316,32 +317,19 @@ declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>
|
|
|
316
317
|
declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>;
|
|
317
318
|
declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>;
|
|
318
319
|
|
|
319
|
-
/**
|
|
320
|
-
* `AND` conditions for refs.
|
|
321
|
-
*
|
|
322
|
-
* @see https://vueuse.org/logicAnd
|
|
323
|
-
*/
|
|
324
|
-
declare function logicAnd(...args: MaybeRef<any>[]): ComputedRef<boolean>;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* `NOT` conditions for refs.
|
|
328
|
-
*
|
|
329
|
-
* @see https://vueuse.org/logicNot
|
|
330
|
-
*/
|
|
331
|
-
declare function logicNot(v: MaybeRef<any>): ComputedRef<boolean>;
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* `OR` conditions for refs.
|
|
335
|
-
*
|
|
336
|
-
* @see https://vueuse.org/logicOr
|
|
337
|
-
*/
|
|
338
|
-
declare function logicOr(...args: MaybeRef<any>[]): ComputedRef<boolean>;
|
|
339
|
-
|
|
340
320
|
declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
|
|
341
321
|
|
|
342
|
-
declare type
|
|
343
|
-
[K in keyof A]: MaybeRef<A[K]>;
|
|
322
|
+
declare type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: {
|
|
323
|
+
[K in keyof A]: Computed extends true ? MaybeComputedRef<A[K]> : MaybeRef<A[K]>;
|
|
344
324
|
}) => ComputedRef<R> : never;
|
|
325
|
+
interface ReactifyOptions<T extends boolean> {
|
|
326
|
+
/**
|
|
327
|
+
* Accept passing a function as a reactive getter
|
|
328
|
+
*
|
|
329
|
+
* @default true
|
|
330
|
+
*/
|
|
331
|
+
computedGetter?: T;
|
|
332
|
+
}
|
|
345
333
|
/**
|
|
346
334
|
* Converts plain function into a reactive function.
|
|
347
335
|
* The converted function accepts refs as it's arguments
|
|
@@ -349,12 +337,12 @@ declare type Reactify<T> = T extends (...args: infer A) => infer R ? (...args: {
|
|
|
349
337
|
*
|
|
350
338
|
* @param fn - Source function
|
|
351
339
|
*/
|
|
352
|
-
declare function reactify<T extends Function>(fn: T):
|
|
340
|
+
declare function reactify<T extends Function, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): Reactified<T, K>;
|
|
353
341
|
|
|
354
|
-
declare type ReactifyNested<T, Keys extends keyof T = keyof T> = {
|
|
355
|
-
[K in Keys]: T[K] extends (...args: any[]) => any ?
|
|
342
|
+
declare type ReactifyNested<T, Keys extends keyof T = keyof T, S extends boolean = true> = {
|
|
343
|
+
[K in Keys]: T[K] extends (...args: any[]) => any ? Reactified<T[K], S> : T[K];
|
|
356
344
|
};
|
|
357
|
-
interface ReactifyObjectOptions {
|
|
345
|
+
interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> {
|
|
358
346
|
/**
|
|
359
347
|
* Includes names from Object.getOwnPropertyNames
|
|
360
348
|
*
|
|
@@ -365,8 +353,8 @@ interface ReactifyObjectOptions {
|
|
|
365
353
|
/**
|
|
366
354
|
* Apply `reactify` to an object
|
|
367
355
|
*/
|
|
368
|
-
declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyNested<T, Keys>;
|
|
369
|
-
declare function reactifyObject<T extends object>(obj: T, options?: ReactifyObjectOptions): ReactifyNested<T>;
|
|
356
|
+
declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyNested<T, Keys, true>;
|
|
357
|
+
declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyNested<T, keyof T, S>;
|
|
370
358
|
|
|
371
359
|
/**
|
|
372
360
|
* Computed reactive object.
|
|
@@ -396,7 +384,7 @@ declare function reactivePick<T extends object, K extends keyof T>(obj: T, ...ke
|
|
|
396
384
|
* @param defaultValue The value which will be set.
|
|
397
385
|
* @param afterMs A zero-or-greater delay in milliseconds.
|
|
398
386
|
*/
|
|
399
|
-
declare function refAutoReset<T>(defaultValue: T, afterMs?:
|
|
387
|
+
declare function refAutoReset<T>(defaultValue: T, afterMs?: MaybeComputedRef$1<number>): Ref<T>;
|
|
400
388
|
|
|
401
389
|
/**
|
|
402
390
|
* Debounce updates of a ref.
|
|
@@ -462,6 +450,7 @@ declare const controlledRef: typeof refWithControl;
|
|
|
462
450
|
*/
|
|
463
451
|
declare function resolveRef<T>(r: MaybeComputedRef<T>): ComputedRef<T>;
|
|
464
452
|
declare function resolveRef<T>(r: MaybeRef<T>): Ref<T>;
|
|
453
|
+
declare function resolveRef<T>(r: T): Ref<T>;
|
|
465
454
|
|
|
466
455
|
/**
|
|
467
456
|
* Normalize value/ref/getter to `ref` or `computed`.
|
|
@@ -610,7 +599,7 @@ interface UntilBaseInstance<T, Not extends boolean = false> {
|
|
|
610
599
|
declare type Falsy = false | void | null | undefined | 0 | 0n | '';
|
|
611
600
|
interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
|
|
612
601
|
readonly not: UntilValueInstance<T, Not extends true ? false : true>;
|
|
613
|
-
toBe<P = T>(value:
|
|
602
|
+
toBe<P = T>(value: MaybeComputedRef<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
|
|
614
603
|
toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
|
|
615
604
|
toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
|
|
616
605
|
toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
|
|
@@ -618,7 +607,7 @@ interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseIn
|
|
|
618
607
|
}
|
|
619
608
|
interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
|
|
620
609
|
readonly not: UntilArrayInstance<T>;
|
|
621
|
-
toContains(value:
|
|
610
|
+
toContains(value: MaybeComputedRef<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
|
|
622
611
|
}
|
|
623
612
|
/**
|
|
624
613
|
* Promised one-time watch for changes
|
|
@@ -633,8 +622,24 @@ interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
|
|
|
633
622
|
* alert('Counter is now larger than 7!')
|
|
634
623
|
* ```
|
|
635
624
|
*/
|
|
636
|
-
declare function until<T extends unknown[]>(r: WatchSource<T> |
|
|
637
|
-
declare function until<T>(r: WatchSource<T> |
|
|
625
|
+
declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeComputedRef<T>): UntilArrayInstance<T>;
|
|
626
|
+
declare function until<T>(r: WatchSource<T> | MaybeComputedRef<T>): UntilValueInstance<T>;
|
|
627
|
+
|
|
628
|
+
declare function useArrayEvery<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef$1<T>[]) => unknown): ComputedRef<boolean>;
|
|
629
|
+
|
|
630
|
+
declare function useArrayFilter<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, fn: (element: T, index: number, array: T[]) => boolean): ComputedRef<T[]>;
|
|
631
|
+
|
|
632
|
+
declare function useArrayFind<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef$1<T>[]) => boolean): ComputedRef<T | undefined>;
|
|
633
|
+
|
|
634
|
+
declare function useArrayJoin(list: MaybeComputedRef$1<MaybeComputedRef$1<any>[]>, separator?: MaybeComputedRef$1<string>): ComputedRef<string>;
|
|
635
|
+
|
|
636
|
+
declare function useArrayMap<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, fn: (element: T, index: number, array: T[]) => T): ComputedRef<T[]>;
|
|
637
|
+
|
|
638
|
+
declare type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R;
|
|
639
|
+
declare function useArrayReduce<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>;
|
|
640
|
+
declare function useArrayReduce<T, U>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeComputedRef$1<U>): ComputedRef<U>;
|
|
641
|
+
|
|
642
|
+
declare function useArraySome<T>(list: MaybeComputedRef$1<MaybeComputedRef$1<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef$1<T>[]) => unknown): ComputedRef<boolean>;
|
|
638
643
|
|
|
639
644
|
interface UseCounterOptions {
|
|
640
645
|
min?: number;
|
|
@@ -666,7 +671,7 @@ declare const normalizeDate: (date: DateLike) => Date;
|
|
|
666
671
|
* @param date
|
|
667
672
|
* @param formatStr
|
|
668
673
|
*/
|
|
669
|
-
declare function useDateFormat(date:
|
|
674
|
+
declare function useDateFormat(date: MaybeComputedRef$1<DateLike>, formatStr?: MaybeComputedRef$1<string>): vue_demi.ComputedRef<string>;
|
|
670
675
|
declare type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
|
|
671
676
|
|
|
672
677
|
/**
|
|
@@ -678,7 +683,7 @@ declare type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
|
|
|
678
683
|
*
|
|
679
684
|
* @return A new, debounce, function.
|
|
680
685
|
*/
|
|
681
|
-
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?:
|
|
686
|
+
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeComputedRef$1<number>, options?: DebounceFilterOptions): T;
|
|
682
687
|
|
|
683
688
|
interface IntervalOptions<Controls extends boolean> {
|
|
684
689
|
/**
|
|
@@ -694,8 +699,8 @@ interface IntervalOptions<Controls extends boolean> {
|
|
|
694
699
|
*/
|
|
695
700
|
immediate?: boolean;
|
|
696
701
|
}
|
|
697
|
-
declare function useInterval(interval?:
|
|
698
|
-
declare function useInterval(interval:
|
|
702
|
+
declare function useInterval(interval?: MaybeComputedRef<number>, options?: IntervalOptions<false>): Ref<number>;
|
|
703
|
+
declare function useInterval(interval: MaybeComputedRef<number>, options: IntervalOptions<true>): {
|
|
699
704
|
counter: Ref<number>;
|
|
700
705
|
} & Pausable;
|
|
701
706
|
|
|
@@ -720,7 +725,7 @@ interface IntervalFnOptions {
|
|
|
720
725
|
* @param interval
|
|
721
726
|
* @param options
|
|
722
727
|
*/
|
|
723
|
-
declare function useIntervalFn(cb: Fn, interval?:
|
|
728
|
+
declare function useIntervalFn(cb: Fn, interval?: MaybeComputedRef<number>, options?: IntervalFnOptions): Pausable;
|
|
724
729
|
|
|
725
730
|
interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends number | null | undefined = undefined> extends WatchOptions<Immediate> {
|
|
726
731
|
initialValue?: InitialValue;
|
|
@@ -742,13 +747,13 @@ declare function useLastChanged(source: WatchSource, options: UseLastChangedOpti
|
|
|
742
747
|
* to `callback` when the throttled-function is executed.
|
|
743
748
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
744
749
|
*
|
|
745
|
-
* @param [trailing=
|
|
750
|
+
* @param [trailing=false] if true, call fn again after the time is up
|
|
746
751
|
*
|
|
747
752
|
* @param [leading=true] if true, call fn on the leading edge of the ms timeout
|
|
748
753
|
*
|
|
749
754
|
* @return A new, throttled, function.
|
|
750
755
|
*/
|
|
751
|
-
declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?:
|
|
756
|
+
declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeComputedRef<number>, trailing?: boolean, leading?: boolean): T;
|
|
752
757
|
|
|
753
758
|
interface TimeoutFnOptions {
|
|
754
759
|
/**
|
|
@@ -765,7 +770,7 @@ interface TimeoutFnOptions {
|
|
|
765
770
|
* @param interval
|
|
766
771
|
* @param immediate
|
|
767
772
|
*/
|
|
768
|
-
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval:
|
|
773
|
+
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval: MaybeComputedRef$1<number>, options?: TimeoutFnOptions): Stoppable;
|
|
769
774
|
|
|
770
775
|
interface TimeoutOptions<Controls extends boolean> extends TimeoutFnOptions {
|
|
771
776
|
/**
|
|
@@ -788,8 +793,8 @@ declare function useTimeout(interval: number, options: TimeoutOptions<true>): {
|
|
|
788
793
|
} & Stoppable;
|
|
789
794
|
|
|
790
795
|
interface UseToggleOptions<Truthy, Falsy> {
|
|
791
|
-
truthyValue?:
|
|
792
|
-
falsyValue?:
|
|
796
|
+
truthyValue?: MaybeComputedRef<Truthy>;
|
|
797
|
+
falsyValue?: MaybeComputedRef<Falsy>;
|
|
793
798
|
}
|
|
794
799
|
declare function useToggle<Truthy, Falsy, T = Truthy | Falsy>(initialValue: Ref<T>, options?: UseToggleOptions<Truthy, Falsy>): (value?: T) => T;
|
|
795
800
|
declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(initialValue?: T, options?: UseToggleOptions<Truthy, Falsy>): [Ref<T>, (value?: T) => T];
|
|
@@ -809,7 +814,7 @@ declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>
|
|
|
809
814
|
declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
|
|
810
815
|
|
|
811
816
|
interface WatchAtMostOptions<Immediate> extends WatchWithFilterOptions<Immediate> {
|
|
812
|
-
count:
|
|
817
|
+
count: MaybeComputedRef<number>;
|
|
813
818
|
}
|
|
814
819
|
interface WatchAtMostReturn {
|
|
815
820
|
stop: WatchStopHandle;
|
|
@@ -819,7 +824,7 @@ declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immedia
|
|
|
819
824
|
declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
|
|
820
825
|
|
|
821
826
|
interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions {
|
|
822
|
-
debounce?:
|
|
827
|
+
debounce?: MaybeComputedRef<number>;
|
|
823
828
|
}
|
|
824
829
|
declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
|
|
825
830
|
declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
|
|
@@ -846,7 +851,7 @@ declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(s
|
|
|
846
851
|
declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
|
|
847
852
|
|
|
848
853
|
interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> {
|
|
849
|
-
throttle?:
|
|
854
|
+
throttle?: MaybeComputedRef<number>;
|
|
850
855
|
trailing?: boolean;
|
|
851
856
|
leading?: boolean;
|
|
852
857
|
}
|
|
@@ -871,4 +876,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
|
|
|
871
876
|
*/
|
|
872
877
|
declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
873
878
|
|
|
874
|
-
export { Awaitable, ComputedRefWithControl, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeComputedRef, MaybeRef, Pausable,
|
|
879
|
+
export { ArgumentsType, Awaitable, ComputedRefWithControl, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeComputedRef, MaybeRef, Pausable, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyOptions, RemovableRef, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, Stoppable, SyncRefOptions, SyncRefsOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayReducer, UseCounterOptions, UseDateFormatReturn, UseLastChangedOptions, UseToggleOptions, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WritableComputedRefWithControl, __onlyVue3, 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, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, makeDestructurable, noop, normalizeDate, now, 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, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayEvery, useArrayFilter, useArrayFind, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchArray, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|
package/index.iife.js
CHANGED
|
@@ -13,22 +13,6 @@
|
|
|
13
13
|
VueDemi.Vue = Vue
|
|
14
14
|
VueDemi.Vue2 = Vue
|
|
15
15
|
VueDemi.version = Vue.version
|
|
16
|
-
VueDemi.set = function(target, key, val) {
|
|
17
|
-
if (Array.isArray(target)) {
|
|
18
|
-
target.length = Math.max(target.length, key)
|
|
19
|
-
target.splice(key, 1, val)
|
|
20
|
-
return val
|
|
21
|
-
}
|
|
22
|
-
Vue.set(target, key, val)
|
|
23
|
-
return val
|
|
24
|
-
}
|
|
25
|
-
VueDemi.del = function(target, key) {
|
|
26
|
-
if (Array.isArray(target)) {
|
|
27
|
-
target.splice(key, 1)
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
Vue.delete(target, key)
|
|
31
|
-
}
|
|
32
16
|
}
|
|
33
17
|
else if (Vue.version.slice(0, 2) === '2.') {
|
|
34
18
|
if (VueCompositionAPI) {
|
|
@@ -87,7 +71,7 @@
|
|
|
87
71
|
this.VueCompositionAPI || (typeof VueCompositionAPI !== "undefined" ? VueCompositionAPI : undefined)
|
|
88
72
|
);
|
|
89
73
|
;
|
|
90
|
-
;(function (exports, vueDemi) {
|
|
74
|
+
;(function (exports, vueDemi, shared) {
|
|
91
75
|
'use strict';
|
|
92
76
|
|
|
93
77
|
var __defProp$9 = Object.defineProperty;
|
|
@@ -146,6 +130,10 @@
|
|
|
146
130
|
};
|
|
147
131
|
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
148
132
|
|
|
133
|
+
function resolveUnref(r) {
|
|
134
|
+
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
135
|
+
}
|
|
136
|
+
|
|
149
137
|
function createFilterWrapper(filter, fn) {
|
|
150
138
|
function wrapper(...args) {
|
|
151
139
|
filter(() => fn.apply(this, args), { fn, thisArg: this, args });
|
|
@@ -159,8 +147,8 @@
|
|
|
159
147
|
let timer;
|
|
160
148
|
let maxTimer;
|
|
161
149
|
const filter = (invoke) => {
|
|
162
|
-
const duration =
|
|
163
|
-
const maxDuration =
|
|
150
|
+
const duration = resolveUnref(ms);
|
|
151
|
+
const maxDuration = resolveUnref(options.maxWait);
|
|
164
152
|
if (timer)
|
|
165
153
|
clearTimeout(timer);
|
|
166
154
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
@@ -198,7 +186,7 @@
|
|
|
198
186
|
}
|
|
199
187
|
};
|
|
200
188
|
const filter = (invoke) => {
|
|
201
|
-
const duration =
|
|
189
|
+
const duration = resolveUnref(ms);
|
|
202
190
|
const elapsed = Date.now() - lastExec;
|
|
203
191
|
clear();
|
|
204
192
|
if (duration <= 0) {
|
|
@@ -443,18 +431,6 @@
|
|
|
443
431
|
return vueDemi.unref(v) != null;
|
|
444
432
|
}
|
|
445
433
|
|
|
446
|
-
function logicAnd(...args) {
|
|
447
|
-
return vueDemi.computed(() => args.every((i) => vueDemi.unref(i)));
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function logicNot(v) {
|
|
451
|
-
return vueDemi.computed(() => !vueDemi.unref(v));
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function logicOr(...args) {
|
|
455
|
-
return vueDemi.computed(() => args.some((i) => vueDemi.unref(i)));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
434
|
var __defProp$8 = Object.defineProperty;
|
|
459
435
|
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
460
436
|
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
@@ -492,17 +468,20 @@
|
|
|
492
468
|
}
|
|
493
469
|
}
|
|
494
470
|
|
|
495
|
-
function reactify(fn) {
|
|
471
|
+
function reactify(fn, options) {
|
|
472
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
|
|
496
473
|
return function(...args) {
|
|
497
|
-
return vueDemi.computed(() => fn.apply(this, args.map((i) =>
|
|
474
|
+
return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
498
475
|
};
|
|
499
476
|
}
|
|
500
477
|
|
|
501
478
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
502
479
|
let keys = [];
|
|
480
|
+
let options;
|
|
503
481
|
if (Array.isArray(optionsOrKeys)) {
|
|
504
482
|
keys = optionsOrKeys;
|
|
505
483
|
} else {
|
|
484
|
+
options = optionsOrKeys;
|
|
506
485
|
const { includeOwnProperties = true } = optionsOrKeys;
|
|
507
486
|
keys.push(...Object.keys(obj));
|
|
508
487
|
if (includeOwnProperties)
|
|
@@ -512,7 +491,7 @@
|
|
|
512
491
|
const value = obj[key];
|
|
513
492
|
return [
|
|
514
493
|
key,
|
|
515
|
-
typeof value === "function" ? reactify(value.bind(obj)) : value
|
|
494
|
+
typeof value === "function" ? reactify(value.bind(obj), options) : value
|
|
516
495
|
];
|
|
517
496
|
}));
|
|
518
497
|
}
|
|
@@ -571,7 +550,7 @@
|
|
|
571
550
|
const resetAfter = () => setTimeout(() => {
|
|
572
551
|
value = defaultValue;
|
|
573
552
|
trigger();
|
|
574
|
-
},
|
|
553
|
+
}, shared.resolveUnref(afterMs));
|
|
575
554
|
tryOnScopeDispose(() => {
|
|
576
555
|
clearTimeout(timer);
|
|
577
556
|
});
|
|
@@ -617,7 +596,7 @@
|
|
|
617
596
|
});
|
|
618
597
|
}
|
|
619
598
|
|
|
620
|
-
function useThrottleFn(fn, ms = 200, trailing =
|
|
599
|
+
function useThrottleFn(fn, ms = 200, trailing = false, leading = true) {
|
|
621
600
|
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
622
601
|
}
|
|
623
602
|
|
|
@@ -684,10 +663,6 @@
|
|
|
684
663
|
return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
|
|
685
664
|
}
|
|
686
665
|
|
|
687
|
-
function resolveUnref(r) {
|
|
688
|
-
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
666
|
function set(...args) {
|
|
692
667
|
if (args.length === 2) {
|
|
693
668
|
const [ref, value] = args;
|
|
@@ -824,7 +799,7 @@
|
|
|
824
799
|
});
|
|
825
800
|
const promises = [watcher];
|
|
826
801
|
if (timeout != null) {
|
|
827
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
802
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
|
|
828
803
|
}
|
|
829
804
|
return Promise.race(promises);
|
|
830
805
|
}
|
|
@@ -847,9 +822,9 @@
|
|
|
847
822
|
});
|
|
848
823
|
const promises = [watcher];
|
|
849
824
|
if (timeout != null) {
|
|
850
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
825
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
|
|
851
826
|
stop == null ? void 0 : stop();
|
|
852
|
-
return
|
|
827
|
+
return resolveUnref(r);
|
|
853
828
|
}));
|
|
854
829
|
}
|
|
855
830
|
return Promise.race(promises);
|
|
@@ -869,7 +844,7 @@
|
|
|
869
844
|
function toContains(value, options) {
|
|
870
845
|
return toMatch((v) => {
|
|
871
846
|
const array = Array.from(v);
|
|
872
|
-
return array.includes(value) || array.includes(
|
|
847
|
+
return array.includes(value) || array.includes(resolveUnref(value));
|
|
873
848
|
}, options);
|
|
874
849
|
}
|
|
875
850
|
function changed(options) {
|
|
@@ -882,7 +857,7 @@
|
|
|
882
857
|
return count >= n;
|
|
883
858
|
}, options);
|
|
884
859
|
}
|
|
885
|
-
if (Array.isArray(
|
|
860
|
+
if (Array.isArray(resolveUnref(r))) {
|
|
886
861
|
const instance = {
|
|
887
862
|
toMatch,
|
|
888
863
|
toContains,
|
|
@@ -913,6 +888,38 @@
|
|
|
913
888
|
}
|
|
914
889
|
}
|
|
915
890
|
|
|
891
|
+
function useArrayEvery(list, fn) {
|
|
892
|
+
return vueDemi.computed(() => shared.resolveUnref(list).every((element, index, array) => fn(shared.resolveUnref(element), index, array)));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function useArrayFilter(list, fn) {
|
|
896
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).filter(fn));
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function useArrayFind(list, fn) {
|
|
900
|
+
return vueDemi.computed(() => shared.resolveUnref(shared.resolveUnref(list).find((element, index, array) => fn(shared.resolveUnref(element), index, array))));
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function useArrayJoin(list, separator) {
|
|
904
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).join(shared.resolveUnref(separator)));
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function useArrayMap(list, fn) {
|
|
908
|
+
return vueDemi.computed(() => shared.resolveUnref(list).map((i) => shared.resolveUnref(i)).map(fn));
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function useArrayReduce(list, reducer, ...args) {
|
|
912
|
+
const reduceCallback = (sum, value, index) => reducer(shared.resolveUnref(sum), shared.resolveUnref(value), index);
|
|
913
|
+
return vueDemi.computed(() => {
|
|
914
|
+
const resolved = shared.resolveUnref(list);
|
|
915
|
+
return args.length ? resolved.reduce(reduceCallback, shared.resolveUnref(args[0])) : resolved.reduce(reduceCallback);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function useArraySome(list, fn) {
|
|
920
|
+
return vueDemi.computed(() => shared.resolveUnref(list).some((element, index, array) => fn(shared.resolveUnref(element), index, array)));
|
|
921
|
+
}
|
|
922
|
+
|
|
916
923
|
function useCounter(initialValue = 0, options = {}) {
|
|
917
924
|
const count = vueDemi.ref(initialValue);
|
|
918
925
|
const {
|
|
@@ -979,7 +986,7 @@
|
|
|
979
986
|
return new Date(date);
|
|
980
987
|
};
|
|
981
988
|
function useDateFormat(date, formatStr = "HH:mm:ss") {
|
|
982
|
-
return vueDemi.computed(() => formatDate(normalizeDate(
|
|
989
|
+
return vueDemi.computed(() => formatDate(normalizeDate(shared.resolveUnref(date)), shared.resolveUnref(formatStr)));
|
|
983
990
|
}
|
|
984
991
|
|
|
985
992
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -1006,7 +1013,7 @@
|
|
|
1006
1013
|
if (immediateCallback)
|
|
1007
1014
|
cb();
|
|
1008
1015
|
clean();
|
|
1009
|
-
timer = setInterval(cb,
|
|
1016
|
+
timer = setInterval(cb, resolveUnref(interval));
|
|
1010
1017
|
}
|
|
1011
1018
|
if (immediate && isClient)
|
|
1012
1019
|
resume();
|
|
@@ -1087,7 +1094,7 @@
|
|
|
1087
1094
|
isPending.value = false;
|
|
1088
1095
|
timer = null;
|
|
1089
1096
|
cb(...args);
|
|
1090
|
-
},
|
|
1097
|
+
}, shared.resolveUnref(interval));
|
|
1091
1098
|
}
|
|
1092
1099
|
if (immediate) {
|
|
1093
1100
|
isPending.value = true;
|
|
@@ -1139,20 +1146,21 @@
|
|
|
1139
1146
|
falsyValue = false
|
|
1140
1147
|
} = options;
|
|
1141
1148
|
const valueIsRef = vueDemi.isRef(initialValue);
|
|
1142
|
-
const
|
|
1149
|
+
const _value = vueDemi.ref(initialValue);
|
|
1143
1150
|
function toggle(value) {
|
|
1144
1151
|
if (arguments.length) {
|
|
1145
|
-
|
|
1146
|
-
return
|
|
1152
|
+
_value.value = value;
|
|
1153
|
+
return _value.value;
|
|
1147
1154
|
} else {
|
|
1148
|
-
|
|
1149
|
-
|
|
1155
|
+
const truthy = resolveUnref(truthyValue);
|
|
1156
|
+
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
|
|
1157
|
+
return _value.value;
|
|
1150
1158
|
}
|
|
1151
1159
|
}
|
|
1152
1160
|
if (valueIsRef)
|
|
1153
1161
|
return toggle;
|
|
1154
1162
|
else
|
|
1155
|
-
return [
|
|
1163
|
+
return [_value, toggle];
|
|
1156
1164
|
}
|
|
1157
1165
|
|
|
1158
1166
|
function watchArray(source, cb, options) {
|
|
@@ -1228,7 +1236,7 @@
|
|
|
1228
1236
|
const current = vueDemi.ref(0);
|
|
1229
1237
|
const stop = watchWithFilter(source, (...args) => {
|
|
1230
1238
|
current.value += 1;
|
|
1231
|
-
if (current.value >=
|
|
1239
|
+
if (current.value >= resolveUnref(count))
|
|
1232
1240
|
vueDemi.nextTick(() => stop());
|
|
1233
1241
|
cb(...args);
|
|
1234
1242
|
}, watchOptions);
|
|
@@ -1530,7 +1538,6 @@
|
|
|
1530
1538
|
}
|
|
1531
1539
|
|
|
1532
1540
|
exports.__onlyVue3 = __onlyVue3;
|
|
1533
|
-
exports.and = logicAnd;
|
|
1534
1541
|
exports.assert = assert;
|
|
1535
1542
|
exports.autoResetRef = refAutoReset;
|
|
1536
1543
|
exports.bypassFilter = bypassFilter;
|
|
@@ -1569,16 +1576,11 @@
|
|
|
1569
1576
|
exports.isObject = isObject;
|
|
1570
1577
|
exports.isString = isString;
|
|
1571
1578
|
exports.isWindow = isWindow;
|
|
1572
|
-
exports.logicAnd = logicAnd;
|
|
1573
|
-
exports.logicNot = logicNot;
|
|
1574
|
-
exports.logicOr = logicOr;
|
|
1575
1579
|
exports.makeDestructurable = makeDestructurable;
|
|
1576
1580
|
exports.noop = noop;
|
|
1577
1581
|
exports.normalizeDate = normalizeDate;
|
|
1578
|
-
exports.not = logicNot;
|
|
1579
1582
|
exports.now = now;
|
|
1580
1583
|
exports.objectPick = objectPick;
|
|
1581
|
-
exports.or = logicOr;
|
|
1582
1584
|
exports.pausableFilter = pausableFilter;
|
|
1583
1585
|
exports.pausableWatch = watchPausable;
|
|
1584
1586
|
exports.promiseTimeout = promiseTimeout;
|
|
@@ -1610,6 +1612,13 @@
|
|
|
1610
1612
|
exports.tryOnScopeDispose = tryOnScopeDispose;
|
|
1611
1613
|
exports.tryOnUnmounted = tryOnUnmounted;
|
|
1612
1614
|
exports.until = until;
|
|
1615
|
+
exports.useArrayEvery = useArrayEvery;
|
|
1616
|
+
exports.useArrayFilter = useArrayFilter;
|
|
1617
|
+
exports.useArrayFind = useArrayFind;
|
|
1618
|
+
exports.useArrayJoin = useArrayJoin;
|
|
1619
|
+
exports.useArrayMap = useArrayMap;
|
|
1620
|
+
exports.useArrayReduce = useArrayReduce;
|
|
1621
|
+
exports.useArraySome = useArraySome;
|
|
1613
1622
|
exports.useCounter = useCounter;
|
|
1614
1623
|
exports.useDateFormat = useDateFormat;
|
|
1615
1624
|
exports.useDebounce = refDebounced;
|
|
@@ -1635,4 +1644,4 @@
|
|
|
1635
1644
|
|
|
1636
1645
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1637
1646
|
|
|
1638
|
-
})(this.VueUse = this.VueUse || {}, VueDemi);
|
|
1647
|
+
})(this.VueUse = this.VueUse || {}, VueDemi, VueUse);
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(a,o,j){if(a.install)return a;if(o)if(o.version.slice(0,4)==="2.7."){for(var g in o)a[g]=o[g];a.isVue2=!0,a.isVue3=!1,a.install=function(){},a.Vue=o,a.Vue2=o,a.version=o.version,a.set=function(y,h,w){return Array.isArray(y)?(y.length=Math.max(y.length,h),y.splice(h,1,w),w):(o.set(y,h,w),w)},a.del=function(y,h){if(Array.isArray(y)){y.splice(h,1);return}o.delete(y,h)}}else if(o.version.slice(0,2)==="2.")if(j){for(var g in j)a[g]=j[g];a.isVue2=!0,a.isVue3=!1,a.install=function(){},a.Vue=o,a.Vue2=o,a.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var g in o)a[g]=o[g];a.isVue2=!1,a.isVue3=!0,a.install=function(){},a.Vue=o,a.Vue2=void 0,a.version=o.version,a.set=function(y,h,w){return Array.isArray(y)?(y.length=Math.max(y.length,h),y.splice(h,1,w),w):(y[h]=w,w)},a.del=function(y,h){if(Array.isArray(y)){y.splice(h,1);return}delete y[h]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return a}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(a,o){"use strict";var j=Object.defineProperty,g=Object.defineProperties,y=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Z=(t,e,r)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xt=(t,e)=>{for(var r in e||(e={}))w.call(e,r)&&Z(t,r,e[r]);if(h)for(var r of h(e))Lt.call(e,r)&&Z(t,r,e[r]);return t},Zt=(t,e)=>g(t,y(e));function K(t,e){var r;const n=o.shallowRef();return o.watchEffect(()=>{n.value=t()},Zt(Xt({},e),{flush:(r=e==null?void 0:e.flush)!=null?r:"sync"})),o.readonly(n)}var q;const A=typeof window!="undefined",Kt=t=>typeof t!="undefined",qt=(t,...e)=>{t||console.warn(...e)},J=Object.prototype.toString,Jt=t=>typeof t=="boolean",W=t=>typeof t=="function",Qt=t=>typeof t=="number",Vt=t=>typeof t=="string",kt=t=>J.call(t)==="[object Object]",xt=t=>typeof window!="undefined"&&J.call(t)==="[object Window]",Dt=()=>Date.now(),Q=()=>+Date.now(),te=(t,e,r)=>Math.min(r,Math.max(e,t)),V=()=>{},ee=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),re=A&&((q=window==null?void 0:window.navigator)==null?void 0:q.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function I(t,e){function r(...n){t(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})}return r}const T=t=>t();function U(t,e={}){let r,n;return l=>{const c=o.unref(t),u=o.unref(e.maxWait);if(r&&clearTimeout(r),c<=0||u!==void 0&&u<=0)return n&&(clearTimeout(n),n=null),l();u&&!n&&(n=setTimeout(()=>{r&&clearTimeout(r),n=null,l()},u)),r=setTimeout(()=>{n&&clearTimeout(n),n=null,l()},c)}}function B(t,e=!0,r=!0){let n=0,i,l=!0;const c=()=>{i&&(clearTimeout(i),i=void 0)};return p=>{const _=o.unref(t),s=Date.now()-n;if(c(),_<=0)return n=Date.now(),p();s>_&&(r||!l)?(n=Date.now(),p()):e&&(i=setTimeout(()=>{n=Date.now(),l=!0,c(),p()},_)),!r&&!i&&(i=setTimeout(()=>l=!0,_)),l=!1}}function k(t=T){const e=o.ref(!0);function r(){e.value=!1}function n(){e.value=!0}return{isActive:e,pause:r,resume:n,eventFilter:(...l)=>{e.value&&t(...l)}}}function x(t="this function"){if(!o.isVue3)throw new Error(`[VueUse] ${t} is only works on Vue 3.`)}const ne={mounted:o.isVue3?"mounted":"inserted",updated:o.isVue3?"updated":"componentUpdated",unmounted:o.isVue3?"unmounted":"unbind"};function H(t,e=!1,r="Timeout"){return new Promise((n,i)=>{setTimeout(e?()=>i(r):n,t)})}function oe(t){return t}function ae(t){let e;function r(){return e||(e=t()),e}return r.reset=async()=>{const n=e;e=void 0,n&&await n},r}function ie(t){return t()}function le(t,...e){return e.some(r=>r in t)}function ce(t,e){var r;if(typeof t=="number")return t+e;const n=((r=t.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:r[0])||"",i=t.slice(n.length),l=parseFloat(n)+e;return Number.isNaN(l)?t:l+i}function ue(t,e,r=!1){return e.reduce((n,i)=>(i in t&&(!r||t[i]!==void 0)&&(n[i]=t[i]),n),{})}function D(t,e){let r,n,i;const l=o.ref(!0),c=()=>{l.value=!0,i()};o.watch(t,c,{flush:"sync"});const u=W(e)?e:e.get,p=W(e)?void 0:e.set,_=o.customRef((s,f)=>(n=s,i=f,{get(){return l.value&&(r=u(),l.value=!1),n(),r},set(d){p==null||p(d)}}));return Object.isExtensible(_)&&(_.trigger=c),_}function fe(){const t=[],e=i=>{const l=t.indexOf(i);l!==-1&&t.splice(l,1)};return{on:i=>(t.push(i),{off:()=>e(i)}),off:e,trigger:i=>{t.forEach(l=>l(i))}}}function se(t){let e=!1,r;const n=o.effectScope(!0);return()=>(e||(r=n.run(t),e=!0),r)}function de(t){const e=Symbol("InjectionState");return[(...i)=>{o.provide(e,t(...i))},()=>o.inject(e)]}function m(t){return o.getCurrentScope()?(o.onScopeDispose(t),!0):!1}function pe(t){let e=0,r,n;const i=()=>{e-=1,n&&e<=0&&(n.stop(),r=void 0,n=void 0)};return(...l)=>(e+=1,r||(n=o.effectScope(!0),r=n.run(()=>t(...l))),m(i),r)}function tt(t,e,{enumerable:r=!1,unwrap:n=!0}={}){x();for(const[i,l]of Object.entries(e))i!=="value"&&(o.isRef(l)&&n?Object.defineProperty(t,i,{get(){return l.value},set(c){l.value=c},enumerable:r}):Object.defineProperty(t,i,{value:l,enumerable:r}));return t}function _e(t,e){return e==null?o.unref(t):o.unref(t)[e]}function ye(t){return o.unref(t)!=null}function et(...t){return o.computed(()=>t.every(e=>o.unref(e)))}function rt(t){return o.computed(()=>!o.unref(t))}function nt(...t){return o.computed(()=>t.some(e=>o.unref(e)))}var Oe=Object.defineProperty,ot=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,at=(t,e,r)=>e in t?Oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,we=(t,e)=>{for(var r in e||(e={}))he.call(e,r)&&at(t,r,e[r]);if(ot)for(var r of ot(e))ve.call(e,r)&&at(t,r,e[r]);return t};function ge(t,e){if(typeof Symbol!="undefined"){const r=we({},t);return Object.defineProperty(r,Symbol.iterator,{enumerable:!1,value(){let n=0;return{next:()=>({value:e[n++],done:n>e.length})}}}),r}else return Object.assign([...e],t)}function Y(t){return function(...e){return o.computed(()=>t.apply(this,e.map(r=>o.unref(r))))}}function Pe(t,e={}){let r=[];if(Array.isArray(e))r=e;else{const{includeOwnProperties:n=!0}=e;r.push(...Object.keys(t)),n&&r.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(r.map(n=>{const i=t[n];return[n,typeof i=="function"?Y(i.bind(t)):i]}))}function it(t){if(!o.isRef(t))return o.reactive(t);const e=new Proxy({},{get(r,n,i){return o.unref(Reflect.get(t.value,n,i))},set(r,n,i){return o.isRef(t.value[n])&&!o.isRef(i)?t.value[n].value=i:t.value[n]=i,!0},deleteProperty(r,n){return Reflect.deleteProperty(t.value,n)},has(r,n){return Reflect.has(t.value,n)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return o.reactive(e)}function lt(t){return it(o.computed(t))}function be(t,...e){const r=e.flat();return lt(()=>Object.fromEntries(Object.entries(o.toRefs(t)).filter(n=>!r.includes(n[0]))))}function me(t,...e){const r=e.flat();return o.reactive(Object.fromEntries(r.map(n=>[n,o.toRef(t,n)])))}function ct(t,e=1e4){return o.customRef((r,n)=>{let i=t,l;const c=()=>setTimeout(()=>{i=t,n()},o.unref(e));return m(()=>{clearTimeout(l)}),{get(){return r(),i},set(u){i=u,n(),clearTimeout(l),l=c()}}})}function ut(t,e=200,r={}){return I(U(e,r),t)}function G(t,e=200,r={}){if(e<=0)return t;const n=o.ref(t.value),i=ut(()=>{n.value=t.value},e,r);return o.watch(t,()=>i()),n}function $e(t,e){return o.computed({get(){var r;return(r=t.value)!=null?r:e},set(r){t.value=r}})}function ft(t,e=200,r=!0,n=!0){return I(B(e,r,n),t)}function z(t,e=200,r=!0,n=!0){if(e<=0)return t;const i=o.ref(t.value),l=ft(()=>{i.value=t.value},e,r,n);return o.watch(t,()=>l()),i}function st(t,e={}){let r=t,n,i;const l=o.customRef((d,O)=>(n=d,i=O,{get(){return c()},set(v){u(v)}}));function c(d=!0){return d&&n(),r}function u(d,O=!0){var v,b;if(d===r)return;const P=r;((v=e.onBeforeChange)==null?void 0:v.call(e,d,P))!==!1&&(r=d,(b=e.onChanged)==null||b.call(e,d,P),O&&i())}return tt(l,{get:c,set:u,untrackedGet:()=>c(!1),silentSet:d=>u(d,!1),peek:()=>c(!1),lay:d=>u(d,!1)},{enumerable:!0})}const Se=st;function je(t){return typeof t=="function"?o.computed(t):o.ref(t)}function Ae(t){return typeof t=="function"?t():o.unref(t)}function Ie(...t){if(t.length===2){const[e,r]=t;e.value=r}if(t.length===3)if(o.isVue2)o.set(...t);else{const[e,r,n]=t;e[r]=n}}function Ee(t,e,r={}){const{flush:n="sync",deep:i=!1,immediate:l=!0,direction:c="both"}=r;let u,p;return(c==="both"||c==="ltr")&&(u=o.watch(t,_=>e.value=_,{flush:n,deep:i,immediate:l})),(c==="both"||c==="rtl")&&(p=o.watch(e,_=>t.value=_,{flush:n,deep:i,immediate:l})),()=>{u==null||u(),p==null||p()}}function Te(t,e,r={}){const{flush:n="sync",deep:i=!1,immediate:l=!0}=r;return Array.isArray(e)||(e=[e]),o.watch(t,c=>e.forEach(u=>u.value=c),{flush:n,deep:i,immediate:l})}var Fe=Object.defineProperty,Ce=Object.defineProperties,Re=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,pt=(t,e,r)=>e in t?Fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,We=(t,e)=>{for(var r in e||(e={}))Me.call(e,r)&&pt(t,r,e[r]);if(dt)for(var r of dt(e))Ne.call(e,r)&&pt(t,r,e[r]);return t},Ue=(t,e)=>Ce(t,Re(e));function Be(t){if(!o.isRef(t))return o.toRefs(t);const e=Array.isArray(t.value)?new Array(t.value.length):{};for(const r in t.value)e[r]=o.customRef(()=>({get(){return t.value[r]},set(n){if(Array.isArray(t.value)){const i=[...t.value];i[r]=n,t.value=i}else{const i=Ue(We({},t.value),{[r]:n});Object.setPrototypeOf(i,t.value),t.value=i}}}));return e}function He(t,e=!0){o.getCurrentInstance()?o.onBeforeMount(t):e?t():o.nextTick(t)}function Ye(t){o.getCurrentInstance()&&o.onBeforeUnmount(t)}function Ge(t,e=!0){o.getCurrentInstance()?o.onMounted(t):e?t():o.nextTick(t)}function ze(t){o.getCurrentInstance()&&o.onUnmounted(t)}function Le(t){let e=!1;function r(f,{flush:d="sync",deep:O=!1,timeout:v,throwOnTimeout:b}={}){let P=null;const X=[new Promise(N=>{P=o.watch(t,S=>{f(S)!==e&&(P==null||P(),N(S))},{flush:d,deep:O,immediate:!0})})];return v!=null&&X.push(H(v,b).then(()=>o.unref(t)).finally(()=>P==null?void 0:P())),Promise.race(X)}function n(f,d){if(!o.isRef(f))return r(S=>S===f,d);const{flush:O="sync",deep:v=!1,timeout:b,throwOnTimeout:P}=d??{};let $=null;const N=[new Promise(S=>{$=o.watch([t,f],([zt,Vr])=>{e!==(zt===Vr)&&($==null||$(),S(zt))},{flush:O,deep:v,immediate:!0})})];return b!=null&&N.push(H(b,P).then(()=>o.unref(t)).finally(()=>($==null||$(),o.unref(t)))),Promise.race(N)}function i(f){return r(d=>Boolean(d),f)}function l(f){return n(null,f)}function c(f){return n(void 0,f)}function u(f){return r(Number.isNaN,f)}function p(f,d){return r(O=>{const v=Array.from(O);return v.includes(f)||v.includes(o.unref(f))},d)}function _(f){return s(1,f)}function s(f=1,d){let O=-1;return r(()=>(O+=1,O>=f),d)}return Array.isArray(o.unref(t))?{toMatch:r,toContains:p,changed:_,changedTimes:s,get not(){return e=!e,this}}:{toMatch:r,toBe:n,toBeTruthy:i,toBeNull:l,toBeNaN:u,toBeUndefined:c,changed:_,changedTimes:s,get not(){return e=!e,this}}}function Xe(t=0,e={}){const r=o.ref(t),{max:n=1/0,min:i=-1/0}=e,l=(s=1)=>r.value=Math.min(n,r.value+s),c=(s=1)=>r.value=Math.max(i,r.value-s),u=()=>r.value,p=s=>r.value=s;return{count:r,inc:l,dec:c,get:u,set:p,reset:(s=t)=>(t=s,p(s))}}const Ze=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Ke=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,_t=(t,e)=>{const r=t.getFullYear(),n=t.getMonth(),i=t.getDate(),l=t.getHours(),c=t.getMinutes(),u=t.getSeconds(),p=t.getMilliseconds(),_=t.getDay(),s={YY:String(r).slice(-2),YYYY:r,M:n+1,MM:`${n+1}`.padStart(2,"0"),D:String(i),DD:`${i}`.padStart(2,"0"),H:String(l),HH:`${l}`.padStart(2,"0"),h:`${l%12||12}`.padStart(1,"0"),hh:`${l%12||12}`.padStart(2,"0"),m:String(c),mm:`${c}`.padStart(2,"0"),s:String(u),ss:`${u}`.padStart(2,"0"),SSS:`${p}`.padStart(3,"0"),d:_};return e.replace(Ke,(f,d)=>d||s[f])},yt=t=>{if(t===null)return new Date(NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Ze);if(e){const r=e[2]-1||0,n=(e[7]||"0").substring(0,3);return new Date(e[1],r,e[3]||1,e[4]||0,e[5]||0,e[6]||0,n)}}return new Date(t)};function qe(t,e="HH:mm:ss"){return o.computed(()=>_t(yt(o.unref(t)),o.unref(e)))}function Ot(t,e=1e3,r={}){const{immediate:n=!0,immediateCallback:i=!1}=r;let l=null;const c=o.ref(!1);function u(){l&&(clearInterval(l),l=null)}function p(){c.value=!1,u()}function _(){o.unref(e)<=0||(c.value=!0,i&&t(),u(),l=setInterval(t,o.unref(e)))}if(n&&A&&_(),o.isRef(e)){const s=o.watch(e,()=>{c.value&&A&&_()});m(s)}return m(p),{isActive:c,pause:p,resume:_}}var Je=Object.defineProperty,ht=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,vt=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ke=(t,e)=>{for(var r in e||(e={}))Qe.call(e,r)&&vt(t,r,e[r]);if(ht)for(var r of ht(e))Ve.call(e,r)&&vt(t,r,e[r]);return t};function xe(t=1e3,e={}){const{controls:r=!1,immediate:n=!0}=e,i=o.ref(0),l=Ot(()=>i.value+=1,t,{immediate:n});return r?ke({counter:i},l):i}function De(t,e={}){var r;const n=o.ref((r=e.initialValue)!=null?r:null);return o.watch(t,()=>n.value=Q(),e),n}function wt(t,e,r={}){const{immediate:n=!0}=r,i=o.ref(!1);let l=null;function c(){l&&(clearTimeout(l),l=null)}function u(){i.value=!1,c()}function p(..._){c(),i.value=!0,l=setTimeout(()=>{i.value=!1,l=null,t(..._)},o.unref(e))}return n&&(i.value=!0,A&&p()),m(u),{isPending:i,start:p,stop:u}}var tr=Object.defineProperty,gt=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Pt=(t,e,r)=>e in t?tr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nr=(t,e)=>{for(var r in e||(e={}))er.call(e,r)&&Pt(t,r,e[r]);if(gt)for(var r of gt(e))rr.call(e,r)&&Pt(t,r,e[r]);return t};function or(t=1e3,e={}){const{controls:r=!1}=e,n=wt(V,t,e),i=o.computed(()=>!n.isPending.value);return r?nr({ready:i},n):i}function ar(t=!1,e={}){const{truthyValue:r=!0,falsyValue:n=!1}=e,i=o.isRef(t),l=o.ref(t);function c(u){return arguments.length?(l.value=u,l.value):(l.value=l.value===o.unref(r)?o.unref(n):o.unref(r),l.value)}return i?c:[l,c]}function ir(t,e,r){let n=(r==null?void 0:r.immediate)?[]:[...t instanceof Function?t():Array.isArray(t)?t:o.unref(t)];return o.watch(t,(i,l,c)=>{const u=new Array(n.length),p=[];for(const s of i){let f=!1;for(let d=0;d<n.length;d++)if(!u[d]&&s===n[d]){u[d]=!0,f=!0;break}f||p.push(s)}const _=n.filter((s,f)=>!u[f]);e(i,n,p,_,c),n=[...i]},r)}var bt=Object.getOwnPropertySymbols,lr=Object.prototype.hasOwnProperty,cr=Object.prototype.propertyIsEnumerable,ur=(t,e)=>{var r={};for(var n in t)lr.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&bt)for(var n of bt(t))e.indexOf(n)<0&&cr.call(t,n)&&(r[n]=t[n]);return r};function E(t,e,r={}){const n=r,{eventFilter:i=T}=n,l=ur(n,["eventFilter"]);return o.watch(t,I(i,e),l)}var mt=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,dr=(t,e)=>{var r={};for(var n in t)fr.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&mt)for(var n of mt(t))e.indexOf(n)<0&&sr.call(t,n)&&(r[n]=t[n]);return r};function pr(t,e,r){const n=r,{count:i}=n,l=dr(n,["count"]),c=o.ref(0),u=E(t,(...p)=>{c.value+=1,c.value>=o.unref(i)&&o.nextTick(()=>u()),e(...p)},l);return{count:c,stop:u}}var _r=Object.defineProperty,yr=Object.defineProperties,Or=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,jt=(t,e,r)=>e in t?_r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hr=(t,e)=>{for(var r in e||(e={}))$t.call(e,r)&&jt(t,r,e[r]);if(F)for(var r of F(e))St.call(e,r)&&jt(t,r,e[r]);return t},vr=(t,e)=>yr(t,Or(e)),wr=(t,e)=>{var r={};for(var n in t)$t.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&F)for(var n of F(t))e.indexOf(n)<0&&St.call(t,n)&&(r[n]=t[n]);return r};function At(t,e,r={}){const n=r,{debounce:i=0,maxWait:l=void 0}=n,c=wr(n,["debounce","maxWait"]);return E(t,e,vr(hr({},c),{eventFilter:U(i,{maxWait:l})}))}var gr=Object.defineProperty,Pr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Tt=(t,e,r)=>e in t?gr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mr=(t,e)=>{for(var r in e||(e={}))It.call(e,r)&&Tt(t,r,e[r]);if(C)for(var r of C(e))Et.call(e,r)&&Tt(t,r,e[r]);return t},$r=(t,e)=>Pr(t,br(e)),Sr=(t,e)=>{var r={};for(var n in t)It.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&C)for(var n of C(t))e.indexOf(n)<0&&Et.call(t,n)&&(r[n]=t[n]);return r};function L(t,e,r={}){const n=r,{eventFilter:i=T}=n,l=Sr(n,["eventFilter"]),c=I(i,e);let u,p,_;if(l.flush==="sync"){const s=o.ref(!1);p=()=>{},u=f=>{s.value=!0,f(),s.value=!1},_=o.watch(t,(...f)=>{s.value||c(...f)},l)}else{const s=[],f=o.ref(0),d=o.ref(0);p=()=>{f.value=d.value},s.push(o.watch(t,()=>{d.value++},$r(mr({},l),{flush:"sync"}))),u=O=>{const v=d.value;O(),f.value+=d.value-v},s.push(o.watch(t,(...O)=>{const v=f.value>0&&f.value===d.value;f.value=0,d.value=0,!v&&c(...O)},l)),_=()=>{s.forEach(O=>O())}}return{stop:_,ignoreUpdates:u,ignorePrevAsyncUpdates:p}}function jr(t,e,r){const n=o.watch(t,(...i)=>(o.nextTick(()=>n()),e(...i)),r)}var Ar=Object.defineProperty,Ir=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,Ft=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,Rt=(t,e,r)=>e in t?Ar(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tr=(t,e)=>{for(var r in e||(e={}))Ft.call(e,r)&&Rt(t,r,e[r]);if(R)for(var r of R(e))Ct.call(e,r)&&Rt(t,r,e[r]);return t},Fr=(t,e)=>Ir(t,Er(e)),Cr=(t,e)=>{var r={};for(var n in t)Ft.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&R)for(var n of R(t))e.indexOf(n)<0&&Ct.call(t,n)&&(r[n]=t[n]);return r};function Mt(t,e,r={}){const n=r,{eventFilter:i}=n,l=Cr(n,["eventFilter"]),{eventFilter:c,pause:u,resume:p,isActive:_}=k(i);return{stop:E(t,e,Fr(Tr({},l),{eventFilter:c})),pause:u,resume:p,isActive:_}}var Rr=Object.defineProperty,Mr=Object.defineProperties,Nr=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Nt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable,Ut=(t,e,r)=>e in t?Rr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wr=(t,e)=>{for(var r in e||(e={}))Nt.call(e,r)&&Ut(t,r,e[r]);if(M)for(var r of M(e))Wt.call(e,r)&&Ut(t,r,e[r]);return t},Ur=(t,e)=>Mr(t,Nr(e)),Br=(t,e)=>{var r={};for(var n in t)Nt.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&M)for(var n of M(t))e.indexOf(n)<0&&Wt.call(t,n)&&(r[n]=t[n]);return r};function Bt(t,e,r={}){const n=r,{throttle:i=0,trailing:l=!0,leading:c=!0}=n,u=Br(n,["throttle","trailing","leading"]);return E(t,e,Ur(Wr({},u),{eventFilter:B(i,l,c)}))}var Hr=Object.defineProperty,Yr=Object.defineProperties,Gr=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,zr=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Yt=(t,e,r)=>e in t?Hr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xr=(t,e)=>{for(var r in e||(e={}))zr.call(e,r)&&Yt(t,r,e[r]);if(Ht)for(var r of Ht(e))Lr.call(e,r)&&Yt(t,r,e[r]);return t},Zr=(t,e)=>Yr(t,Gr(e));function Kr(t,e,r={}){let n;function i(){if(!n)return;const s=n;n=void 0,s()}function l(s){n=s}const c=(s,f)=>(i(),e(s,f,l)),u=L(t,c,r),{ignoreUpdates:p}=u,_=()=>{let s;return p(()=>{s=c(qr(t),Jr(t))}),s};return Zr(Xr({},u),{trigger:_})}function qr(t){return o.isReactive(t)?t:Array.isArray(t)?t.map(e=>Gt(e)):Gt(t)}function Gt(t){return typeof t=="function"?t():o.unref(t)}function Jr(t){return Array.isArray(t)?t.map(()=>{}):void 0}function Qr(t,e,r){return o.watch(t,(n,i,l)=>{n&&e(n,i,l)},r)}a.__onlyVue3=x,a.and=et,a.assert=qt,a.autoResetRef=ct,a.bypassFilter=T,a.clamp=te,a.computedEager=K,a.computedWithControl=D,a.containsProp=le,a.controlledComputed=D,a.controlledRef=Se,a.createEventHook=fe,a.createFilterWrapper=I,a.createGlobalState=se,a.createInjectionState=de,a.createReactiveFn=Y,a.createSharedComposable=pe,a.createSingletonPromise=ae,a.debounceFilter=U,a.debouncedRef=G,a.debouncedWatch=At,a.directiveHooks=ne,a.eagerComputed=K,a.extendRef=tt,a.formatDate=_t,a.get=_e,a.identity=oe,a.ignorableWatch=L,a.increaseWithUnit=ce,a.invoke=ie,a.isBoolean=Jt,a.isClient=A,a.isDef=Kt,a.isDefined=ye,a.isFunction=W,a.isIOS=re,a.isNumber=Qt,a.isObject=kt,a.isString=Vt,a.isWindow=xt,a.logicAnd=et,a.logicNot=rt,a.logicOr=nt,a.makeDestructurable=ge,a.noop=V,a.normalizeDate=yt,a.not=rt,a.now=Dt,a.objectPick=ue,a.or=nt,a.pausableFilter=k,a.pausableWatch=Mt,a.promiseTimeout=H,a.rand=ee,a.reactify=Y,a.reactifyObject=Pe,a.reactiveComputed=lt,a.reactiveOmit=be,a.reactivePick=me,a.refAutoReset=ct,a.refDebounced=G,a.refDefault=$e,a.refThrottled=z,a.refWithControl=st,a.resolveRef=je,a.resolveUnref=Ae,a.set=Ie,a.syncRef=Ee,a.syncRefs=Te,a.throttleFilter=B,a.throttledRef=z,a.throttledWatch=Bt,a.timestamp=Q,a.toReactive=it,a.toRefs=Be,a.tryOnBeforeMount=He,a.tryOnBeforeUnmount=Ye,a.tryOnMounted=Ge,a.tryOnScopeDispose=m,a.tryOnUnmounted=ze,a.until=Le,a.useCounter=Xe,a.useDateFormat=qe,a.useDebounce=G,a.useDebounceFn=ut,a.useInterval=xe,a.useIntervalFn=Ot,a.useLastChanged=De,a.useThrottle=z,a.useThrottleFn=ft,a.useTimeout=or,a.useTimeoutFn=wt,a.useToggle=ar,a.watchArray=ir,a.watchAtMost=pr,a.watchDebounced=At,a.watchIgnorable=L,a.watchOnce=jr,a.watchPausable=Mt,a.watchThrottled=Bt,a.watchTriggerable=Kr,a.watchWithFilter=E,a.whenever=Qr,Object.defineProperty(a,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi);
|
|
1
|
+
var VueDemi=function(o,i,_){if(o.install)return o;if(i)if(i.version.slice(0,4)==="2.7."){for(var g in i)o[g]=i[g];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=i,o.Vue2=i,o.version=i.version}else if(i.version.slice(0,2)==="2.")if(_){for(var g in _)o[g]=_[g];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=i,o.Vue2=i,o.version=i.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(i.version.slice(0,2)==="3."){for(var g in i)o[g]=i[g];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=i,o.Vue2=void 0,o.version=i.version,o.set=function(w,m,b){return Array.isArray(w)?(w.length=Math.max(w.length,m),w.splice(m,1,b),b):(w[m]=b,b)},o.del=function(w,m){if(Array.isArray(w)){w.splice(m,1);return}delete w[m]}}else console.error("[vue-demi] Vue version "+i.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");return o}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(o,i,_){"use strict";var g=Object.defineProperty,w=Object.defineProperties,m=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,X=(e,t,r)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Le=(e,t)=>{for(var r in t||(t={}))Ge.call(t,r)&&X(e,r,t[r]);if(b)for(var r of b(t))ze.call(t,r)&&X(e,r,t[r]);return e},Ve=(e,t)=>w(e,m(t));function Z(e,t){var r;const n=i.shallowRef();return i.watchEffect(()=>{n.value=e()},Ve(Le({},t),{flush:(r=t==null?void 0:t.flush)!=null?r:"sync"})),i.readonly(n)}var k;const I=typeof window!="undefined",Je=e=>typeof e!="undefined",Xe=(e,...t)=>{e||console.warn(...t)},q=Object.prototype.toString,Ze=e=>typeof e=="boolean",W=e=>typeof e=="function",ke=e=>typeof e=="number",qe=e=>typeof e=="string",Ke=e=>q.call(e)==="[object Object]",Qe=e=>typeof window!="undefined"&&q.call(e)==="[object Window]",De=()=>Date.now(),K=()=>+Date.now(),xe=(e,t,r)=>Math.min(r,Math.max(t,e)),Q=()=>{},et=(e,t)=>(e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e),tt=I&&((k=window==null?void 0:window.navigator)==null?void 0:k.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function h(e){return typeof e=="function"?e():i.unref(e)}function E(e,t){function r(...n){e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})}return r}const T=e=>e();function B(e,t={}){let r,n;return l=>{const u=h(e),c=h(t.maxWait);if(r&&clearTimeout(r),u<=0||c!==void 0&&c<=0)return n&&(clearTimeout(n),n=null),l();c&&!n&&(n=setTimeout(()=>{r&&clearTimeout(r),n=null,l()},c)),r=setTimeout(()=>{n&&clearTimeout(n),n=null,l()},u)}}function H(e,t=!0,r=!0){let n=0,a,l=!0;const u=()=>{a&&(clearTimeout(a),a=void 0)};return p=>{const v=h(e),f=Date.now()-n;if(u(),v<=0)return n=Date.now(),p();f>v&&(r||!l)?(n=Date.now(),p()):t&&(a=setTimeout(()=>{n=Date.now(),l=!0,u(),p()},v)),!r&&!a&&(a=setTimeout(()=>l=!0,v)),l=!1}}function D(e=T){const t=i.ref(!0);function r(){t.value=!1}function n(){t.value=!0}return{isActive:t,pause:r,resume:n,eventFilter:(...l)=>{t.value&&e(...l)}}}function x(e="this function"){if(!i.isVue3)throw new Error(`[VueUse] ${e} is only works on Vue 3.`)}const rt={mounted:i.isVue3?"mounted":"inserted",updated:i.isVue3?"updated":"componentUpdated",unmounted:i.isVue3?"unmounted":"unbind"};function Y(e,t=!1,r="Timeout"){return new Promise((n,a)=>{setTimeout(t?()=>a(r):n,e)})}function nt(e){return e}function ot(e){let t;function r(){return t||(t=e()),t}return r.reset=async()=>{const n=t;t=void 0,n&&await n},r}function at(e){return e()}function it(e,...t){return t.some(r=>r in e)}function lt(e,t){var r;if(typeof e=="number")return e+t;const n=((r=e.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:r[0])||"",a=e.slice(n.length),l=parseFloat(n)+t;return Number.isNaN(l)?e:l+a}function ut(e,t,r=!1){return t.reduce((n,a)=>(a in e&&(!r||e[a]!==void 0)&&(n[a]=e[a]),n),{})}function ee(e,t){let r,n,a;const l=i.ref(!0),u=()=>{l.value=!0,a()};i.watch(e,u,{flush:"sync"});const c=W(t)?t:t.get,p=W(t)?void 0:t.set,v=i.customRef((f,s)=>(n=f,a=s,{get(){return l.value&&(r=c(),l.value=!1),n(),r},set(d){p==null||p(d)}}));return Object.isExtensible(v)&&(v.trigger=u),v}function ct(){const e=[],t=a=>{const l=e.indexOf(a);l!==-1&&e.splice(l,1)};return{on:a=>(e.push(a),{off:()=>t(a)}),off:t,trigger:a=>{e.forEach(l=>l(a))}}}function st(e){let t=!1,r;const n=i.effectScope(!0);return()=>(t||(r=n.run(e),t=!0),r)}function ft(e){const t=Symbol("InjectionState");return[(...a)=>{i.provide(t,e(...a))},()=>i.inject(t)]}function S(e){return i.getCurrentScope()?(i.onScopeDispose(e),!0):!1}function dt(e){let t=0,r,n;const a=()=>{t-=1,n&&t<=0&&(n.stop(),r=void 0,n=void 0)};return(...l)=>(t+=1,r||(n=i.effectScope(!0),r=n.run(()=>e(...l))),S(a),r)}function te(e,t,{enumerable:r=!1,unwrap:n=!0}={}){x();for(const[a,l]of Object.entries(t))a!=="value"&&(i.isRef(l)&&n?Object.defineProperty(e,a,{get(){return l.value},set(u){l.value=u},enumerable:r}):Object.defineProperty(e,a,{value:l,enumerable:r}));return e}function pt(e,t){return t==null?i.unref(e):i.unref(e)[t]}function vt(e){return i.unref(e)!=null}var _t=Object.defineProperty,re=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,ne=(e,t,r)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ht=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&ne(e,r,t[r]);if(re)for(var r of re(t))Ot.call(t,r)&&ne(e,r,t[r]);return e};function wt(e,t){if(typeof Symbol!="undefined"){const r=ht({},e);return Object.defineProperty(r,Symbol.iterator,{enumerable:!1,value(){let n=0;return{next:()=>({value:t[n++],done:n>t.length})}}}),r}else return Object.assign([...t],e)}function G(e,t){const r=(t==null?void 0:t.computedGetter)===!1?i.unref:h;return function(...n){return i.computed(()=>e.apply(this,n.map(a=>r(a))))}}function gt(e,t={}){let r=[],n;if(Array.isArray(t))r=t;else{n=t;const{includeOwnProperties:a=!0}=t;r.push(...Object.keys(e)),a&&r.push(...Object.getOwnPropertyNames(e))}return Object.fromEntries(r.map(a=>{const l=e[a];return[a,typeof l=="function"?G(l.bind(e),n):l]}))}function oe(e){if(!i.isRef(e))return i.reactive(e);const t=new Proxy({},{get(r,n,a){return i.unref(Reflect.get(e.value,n,a))},set(r,n,a){return i.isRef(e.value[n])&&!i.isRef(a)?e.value[n].value=a:e.value[n]=a,!0},deleteProperty(r,n){return Reflect.deleteProperty(e.value,n)},has(r,n){return Reflect.has(e.value,n)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return i.reactive(t)}function ae(e){return oe(i.computed(e))}function Pt(e,...t){const r=t.flat();return ae(()=>Object.fromEntries(Object.entries(i.toRefs(e)).filter(n=>!r.includes(n[0]))))}function mt(e,...t){const r=t.flat();return i.reactive(Object.fromEntries(r.map(n=>[n,i.toRef(e,n)])))}function ie(e,t=1e4){return i.customRef((r,n)=>{let a=e,l;const u=()=>setTimeout(()=>{a=e,n()},_.resolveUnref(t));return S(()=>{clearTimeout(l)}),{get(){return r(),a},set(c){a=c,n(),clearTimeout(l),l=u()}}})}function le(e,t=200,r={}){return E(B(t,r),e)}function z(e,t=200,r={}){if(t<=0)return e;const n=i.ref(e.value),a=le(()=>{n.value=e.value},t,r);return i.watch(e,()=>a()),n}function bt(e,t){return i.computed({get(){var r;return(r=e.value)!=null?r:t},set(r){e.value=r}})}function ue(e,t=200,r=!1,n=!0){return E(H(t,r,n),e)}function L(e,t=200,r=!0,n=!0){if(t<=0)return e;const a=i.ref(e.value),l=ue(()=>{a.value=e.value},t,r,n);return i.watch(e,()=>l()),a}function ce(e,t={}){let r=e,n,a;const l=i.customRef((d,y)=>(n=d,a=y,{get(){return u()},set(O){c(O)}}));function u(d=!0){return d&&n(),r}function c(d,y=!0){var O,$;if(d===r)return;const P=r;((O=t.onBeforeChange)==null?void 0:O.call(t,d,P))!==!1&&(r=d,($=t.onChanged)==null||$.call(t,d,P),y&&a())}return te(l,{get:u,set:c,untrackedGet:()=>u(!1),silentSet:d=>c(d,!1),peek:()=>u(!1),lay:d=>c(d,!1)},{enumerable:!0})}const $t=ce;function St(e){return typeof e=="function"?i.computed(e):i.ref(e)}function At(...e){if(e.length===2){const[t,r]=e;t.value=r}if(e.length===3)if(i.isVue2)i.set(...e);else{const[t,r,n]=e;t[r]=n}}function jt(e,t,r={}){const{flush:n="sync",deep:a=!1,immediate:l=!0,direction:u="both"}=r;let c,p;return(u==="both"||u==="ltr")&&(c=i.watch(e,v=>t.value=v,{flush:n,deep:a,immediate:l})),(u==="both"||u==="rtl")&&(p=i.watch(t,v=>e.value=v,{flush:n,deep:a,immediate:l})),()=>{c==null||c(),p==null||p()}}function It(e,t,r={}){const{flush:n="sync",deep:a=!1,immediate:l=!0}=r;return Array.isArray(t)||(t=[t]),i.watch(e,u=>t.forEach(c=>c.value=u),{flush:n,deep:a,immediate:l})}var Et=Object.defineProperty,Ft=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ct=(e,t)=>{for(var r in t||(t={}))Ut.call(t,r)&&fe(e,r,t[r]);if(se)for(var r of se(t))Rt.call(t,r)&&fe(e,r,t[r]);return e},Mt=(e,t)=>Ft(e,Tt(t));function Nt(e){if(!i.isRef(e))return i.toRefs(e);const t=Array.isArray(e.value)?new Array(e.value.length):{};for(const r in e.value)t[r]=i.customRef(()=>({get(){return e.value[r]},set(n){if(Array.isArray(e.value)){const a=[...e.value];a[r]=n,e.value=a}else{const a=Mt(Ct({},e.value),{[r]:n});Object.setPrototypeOf(a,e.value),e.value=a}}}));return t}function Wt(e,t=!0){i.getCurrentInstance()?i.onBeforeMount(e):t?e():i.nextTick(e)}function Bt(e){i.getCurrentInstance()&&i.onBeforeUnmount(e)}function Ht(e,t=!0){i.getCurrentInstance()?i.onMounted(e):t?e():i.nextTick(e)}function Yt(e){i.getCurrentInstance()&&i.onUnmounted(e)}function Gt(e){let t=!1;function r(s,{flush:d="sync",deep:y=!1,timeout:O,throwOnTimeout:$}={}){let P=null;const J=[new Promise(N=>{P=i.watch(e,j=>{s(j)!==t&&(P==null||P(),N(j))},{flush:d,deep:y,immediate:!0})})];return O!=null&&J.push(Y(O,$).then(()=>h(e)).finally(()=>P==null?void 0:P())),Promise.race(J)}function n(s,d){if(!i.isRef(s))return r(j=>j===s,d);const{flush:y="sync",deep:O=!1,timeout:$,throwOnTimeout:P}=d??{};let A=null;const N=[new Promise(j=>{A=i.watch([e,s],([Ye,tn])=>{t!==(Ye===tn)&&(A==null||A(),j(Ye))},{flush:y,deep:O,immediate:!0})})];return $!=null&&N.push(Y($,P).then(()=>h(e)).finally(()=>(A==null||A(),h(e)))),Promise.race(N)}function a(s){return r(d=>Boolean(d),s)}function l(s){return n(null,s)}function u(s){return n(void 0,s)}function c(s){return r(Number.isNaN,s)}function p(s,d){return r(y=>{const O=Array.from(y);return O.includes(s)||O.includes(h(s))},d)}function v(s){return f(1,s)}function f(s=1,d){let y=-1;return r(()=>(y+=1,y>=s),d)}return Array.isArray(h(e))?{toMatch:r,toContains:p,changed:v,changedTimes:f,get not(){return t=!t,this}}:{toMatch:r,toBe:n,toBeTruthy:a,toBeNull:l,toBeNaN:c,toBeUndefined:u,changed:v,changedTimes:f,get not(){return t=!t,this}}}function zt(e,t){return i.computed(()=>_.resolveUnref(e).every((r,n,a)=>t(_.resolveUnref(r),n,a)))}function Lt(e,t){return i.computed(()=>_.resolveUnref(e).map(r=>_.resolveUnref(r)).filter(t))}function Vt(e,t){return i.computed(()=>_.resolveUnref(_.resolveUnref(e).find((r,n,a)=>t(_.resolveUnref(r),n,a))))}function Jt(e,t){return i.computed(()=>_.resolveUnref(e).map(r=>_.resolveUnref(r)).join(_.resolveUnref(t)))}function Xt(e,t){return i.computed(()=>_.resolveUnref(e).map(r=>_.resolveUnref(r)).map(t))}function Zt(e,t,...r){const n=(a,l,u)=>t(_.resolveUnref(a),_.resolveUnref(l),u);return i.computed(()=>{const a=_.resolveUnref(e);return r.length?a.reduce(n,_.resolveUnref(r[0])):a.reduce(n)})}function kt(e,t){return i.computed(()=>_.resolveUnref(e).some((r,n,a)=>t(_.resolveUnref(r),n,a)))}function qt(e=0,t={}){const r=i.ref(e),{max:n=1/0,min:a=-1/0}=t,l=(f=1)=>r.value=Math.min(n,r.value+f),u=(f=1)=>r.value=Math.max(a,r.value-f),c=()=>r.value,p=f=>r.value=f;return{count:r,inc:l,dec:u,get:c,set:p,reset:(f=e)=>(e=f,p(f))}}const Kt=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Qt=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,de=(e,t)=>{const r=e.getFullYear(),n=e.getMonth(),a=e.getDate(),l=e.getHours(),u=e.getMinutes(),c=e.getSeconds(),p=e.getMilliseconds(),v=e.getDay(),f={YY:String(r).slice(-2),YYYY:r,M:n+1,MM:`${n+1}`.padStart(2,"0"),D:String(a),DD:`${a}`.padStart(2,"0"),H:String(l),HH:`${l}`.padStart(2,"0"),h:`${l%12||12}`.padStart(1,"0"),hh:`${l%12||12}`.padStart(2,"0"),m:String(u),mm:`${u}`.padStart(2,"0"),s:String(c),ss:`${c}`.padStart(2,"0"),SSS:`${p}`.padStart(3,"0"),d:v};return t.replace(Qt,(s,d)=>d||f[s])},pe=e=>{if(e===null)return new Date(NaN);if(e===void 0)return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){const t=e.match(Kt);if(t){const r=t[2]-1||0,n=(t[7]||"0").substring(0,3);return new Date(t[1],r,t[3]||1,t[4]||0,t[5]||0,t[6]||0,n)}}return new Date(e)};function Dt(e,t="HH:mm:ss"){return i.computed(()=>de(pe(_.resolveUnref(e)),_.resolveUnref(t)))}function ve(e,t=1e3,r={}){const{immediate:n=!0,immediateCallback:a=!1}=r;let l=null;const u=i.ref(!1);function c(){l&&(clearInterval(l),l=null)}function p(){u.value=!1,c()}function v(){i.unref(t)<=0||(u.value=!0,a&&e(),c(),l=setInterval(e,h(t)))}if(n&&I&&v(),i.isRef(t)){const f=i.watch(t,()=>{u.value&&I&&v()});S(f)}return S(p),{isActive:u,pause:p,resume:v}}var xt=Object.defineProperty,_e=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t)=>{for(var r in t||(t={}))er.call(t,r)&&ye(e,r,t[r]);if(_e)for(var r of _e(t))tr.call(t,r)&&ye(e,r,t[r]);return e};function nr(e=1e3,t={}){const{controls:r=!1,immediate:n=!0}=t,a=i.ref(0),l=ve(()=>a.value+=1,e,{immediate:n});return r?rr({counter:a},l):a}function or(e,t={}){var r;const n=i.ref((r=t.initialValue)!=null?r:null);return i.watch(e,()=>n.value=K(),t),n}function Oe(e,t,r={}){const{immediate:n=!0}=r,a=i.ref(!1);let l=null;function u(){l&&(clearTimeout(l),l=null)}function c(){a.value=!1,u()}function p(...v){u(),a.value=!0,l=setTimeout(()=>{a.value=!1,l=null,e(...v)},_.resolveUnref(t))}return n&&(a.value=!0,I&&p()),S(c),{isPending:a,start:p,stop:c}}var ar=Object.defineProperty,he=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable,we=(e,t,r)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ur=(e,t)=>{for(var r in t||(t={}))ir.call(t,r)&&we(e,r,t[r]);if(he)for(var r of he(t))lr.call(t,r)&&we(e,r,t[r]);return e};function cr(e=1e3,t={}){const{controls:r=!1}=t,n=Oe(Q,e,t),a=i.computed(()=>!n.isPending.value);return r?ur({ready:a},n):a}function sr(e=!1,t={}){const{truthyValue:r=!0,falsyValue:n=!1}=t,a=i.isRef(e),l=i.ref(e);function u(c){if(arguments.length)return l.value=c,l.value;{const p=h(r);return l.value=l.value===p?h(n):p,l.value}}return a?u:[l,u]}function fr(e,t,r){let n=(r==null?void 0:r.immediate)?[]:[...e instanceof Function?e():Array.isArray(e)?e:i.unref(e)];return i.watch(e,(a,l,u)=>{const c=new Array(n.length),p=[];for(const f of a){let s=!1;for(let d=0;d<n.length;d++)if(!c[d]&&f===n[d]){c[d]=!0,s=!0;break}s||p.push(f)}const v=n.filter((f,s)=>!c[s]);t(a,n,p,v,u),n=[...a]},r)}var ge=Object.getOwnPropertySymbols,dr=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable,vr=(e,t)=>{var r={};for(var n in e)dr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&ge)for(var n of ge(e))t.indexOf(n)<0&&pr.call(e,n)&&(r[n]=e[n]);return r};function F(e,t,r={}){const n=r,{eventFilter:a=T}=n,l=vr(n,["eventFilter"]);return i.watch(e,E(a,t),l)}var Pe=Object.getOwnPropertySymbols,_r=Object.prototype.hasOwnProperty,yr=Object.prototype.propertyIsEnumerable,Or=(e,t)=>{var r={};for(var n in e)_r.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Pe)for(var n of Pe(e))t.indexOf(n)<0&&yr.call(e,n)&&(r[n]=e[n]);return r};function hr(e,t,r){const n=r,{count:a}=n,l=Or(n,["count"]),u=i.ref(0),c=F(e,(...p)=>{u.value+=1,u.value>=h(a)&&i.nextTick(()=>c()),t(...p)},l);return{count:u,stop:c}}var wr=Object.defineProperty,gr=Object.defineProperties,Pr=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,$e=(e,t,r)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mr=(e,t)=>{for(var r in t||(t={}))me.call(t,r)&&$e(e,r,t[r]);if(U)for(var r of U(t))be.call(t,r)&&$e(e,r,t[r]);return e},br=(e,t)=>gr(e,Pr(t)),$r=(e,t)=>{var r={};for(var n in e)me.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&U)for(var n of U(e))t.indexOf(n)<0&&be.call(e,n)&&(r[n]=e[n]);return r};function Se(e,t,r={}){const n=r,{debounce:a=0,maxWait:l=void 0}=n,u=$r(n,["debounce","maxWait"]);return F(e,t,br(mr({},u),{eventFilter:B(a,{maxWait:l})}))}var Sr=Object.defineProperty,Ar=Object.defineProperties,jr=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?Sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ir=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&Ie(e,r,t[r]);if(R)for(var r of R(t))je.call(t,r)&&Ie(e,r,t[r]);return e},Er=(e,t)=>Ar(e,jr(t)),Fr=(e,t)=>{var r={};for(var n in e)Ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&je.call(e,n)&&(r[n]=e[n]);return r};function V(e,t,r={}){const n=r,{eventFilter:a=T}=n,l=Fr(n,["eventFilter"]),u=E(a,t);let c,p,v;if(l.flush==="sync"){const f=i.ref(!1);p=()=>{},c=s=>{f.value=!0,s(),f.value=!1},v=i.watch(e,(...s)=>{f.value||u(...s)},l)}else{const f=[],s=i.ref(0),d=i.ref(0);p=()=>{s.value=d.value},f.push(i.watch(e,()=>{d.value++},Er(Ir({},l),{flush:"sync"}))),c=y=>{const O=d.value;y(),s.value+=d.value-O},f.push(i.watch(e,(...y)=>{const O=s.value>0&&s.value===d.value;s.value=0,d.value=0,!O&&u(...y)},l)),v=()=>{f.forEach(y=>y())}}return{stop:v,ignoreUpdates:c,ignorePrevAsyncUpdates:p}}function Tr(e,t,r){const n=i.watch(e,(...a)=>(i.nextTick(()=>n()),t(...a)),r)}var Ur=Object.defineProperty,Rr=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,Te=(e,t,r)=>t in e?Ur(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Mr=(e,t)=>{for(var r in t||(t={}))Ee.call(t,r)&&Te(e,r,t[r]);if(C)for(var r of C(t))Fe.call(t,r)&&Te(e,r,t[r]);return e},Nr=(e,t)=>Rr(e,Cr(t)),Wr=(e,t)=>{var r={};for(var n in e)Ee.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&C)for(var n of C(e))t.indexOf(n)<0&&Fe.call(e,n)&&(r[n]=e[n]);return r};function Ue(e,t,r={}){const n=r,{eventFilter:a}=n,l=Wr(n,["eventFilter"]),{eventFilter:u,pause:c,resume:p,isActive:v}=D(a);return{stop:F(e,t,Nr(Mr({},l),{eventFilter:u})),pause:c,resume:p,isActive:v}}var Br=Object.defineProperty,Hr=Object.defineProperties,Yr=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,Me=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gr=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&Me(e,r,t[r]);if(M)for(var r of M(t))Ce.call(t,r)&&Me(e,r,t[r]);return e},zr=(e,t)=>Hr(e,Yr(t)),Lr=(e,t)=>{var r={};for(var n in e)Re.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&M)for(var n of M(e))t.indexOf(n)<0&&Ce.call(e,n)&&(r[n]=e[n]);return r};function Ne(e,t,r={}){const n=r,{throttle:a=0,trailing:l=!0,leading:u=!0}=n,c=Lr(n,["throttle","trailing","leading"]);return F(e,t,zr(Gr({},c),{eventFilter:H(a,l,u)}))}var Vr=Object.defineProperty,Jr=Object.defineProperties,Xr=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Zr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Be=(e,t,r)=>t in e?Vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qr=(e,t)=>{for(var r in t||(t={}))Zr.call(t,r)&&Be(e,r,t[r]);if(We)for(var r of We(t))kr.call(t,r)&&Be(e,r,t[r]);return e},Kr=(e,t)=>Jr(e,Xr(t));function Qr(e,t,r={}){let n;function a(){if(!n)return;const f=n;n=void 0,f()}function l(f){n=f}const u=(f,s)=>(a(),t(f,s,l)),c=V(e,u,r),{ignoreUpdates:p}=c,v=()=>{let f;return p(()=>{f=u(Dr(e),xr(e))}),f};return Kr(qr({},c),{trigger:v})}function Dr(e){return i.isReactive(e)?e:Array.isArray(e)?e.map(t=>He(t)):He(e)}function He(e){return typeof e=="function"?e():i.unref(e)}function xr(e){return Array.isArray(e)?e.map(()=>{}):void 0}function en(e,t,r){return i.watch(e,(n,a,l)=>{n&&t(n,a,l)},r)}o.__onlyVue3=x,o.assert=Xe,o.autoResetRef=ie,o.bypassFilter=T,o.clamp=xe,o.computedEager=Z,o.computedWithControl=ee,o.containsProp=it,o.controlledComputed=ee,o.controlledRef=$t,o.createEventHook=ct,o.createFilterWrapper=E,o.createGlobalState=st,o.createInjectionState=ft,o.createReactiveFn=G,o.createSharedComposable=dt,o.createSingletonPromise=ot,o.debounceFilter=B,o.debouncedRef=z,o.debouncedWatch=Se,o.directiveHooks=rt,o.eagerComputed=Z,o.extendRef=te,o.formatDate=de,o.get=pt,o.identity=nt,o.ignorableWatch=V,o.increaseWithUnit=lt,o.invoke=at,o.isBoolean=Ze,o.isClient=I,o.isDef=Je,o.isDefined=vt,o.isFunction=W,o.isIOS=tt,o.isNumber=ke,o.isObject=Ke,o.isString=qe,o.isWindow=Qe,o.makeDestructurable=wt,o.noop=Q,o.normalizeDate=pe,o.now=De,o.objectPick=ut,o.pausableFilter=D,o.pausableWatch=Ue,o.promiseTimeout=Y,o.rand=et,o.reactify=G,o.reactifyObject=gt,o.reactiveComputed=ae,o.reactiveOmit=Pt,o.reactivePick=mt,o.refAutoReset=ie,o.refDebounced=z,o.refDefault=bt,o.refThrottled=L,o.refWithControl=ce,o.resolveRef=St,o.resolveUnref=h,o.set=At,o.syncRef=jt,o.syncRefs=It,o.throttleFilter=H,o.throttledRef=L,o.throttledWatch=Ne,o.timestamp=K,o.toReactive=oe,o.toRefs=Nt,o.tryOnBeforeMount=Wt,o.tryOnBeforeUnmount=Bt,o.tryOnMounted=Ht,o.tryOnScopeDispose=S,o.tryOnUnmounted=Yt,o.until=Gt,o.useArrayEvery=zt,o.useArrayFilter=Lt,o.useArrayFind=Vt,o.useArrayJoin=Jt,o.useArrayMap=Xt,o.useArrayReduce=Zt,o.useArraySome=kt,o.useCounter=qt,o.useDateFormat=Dt,o.useDebounce=z,o.useDebounceFn=le,o.useInterval=nr,o.useIntervalFn=ve,o.useLastChanged=or,o.useThrottle=L,o.useThrottleFn=ue,o.useTimeout=cr,o.useTimeoutFn=Oe,o.useToggle=sr,o.watchArray=fr,o.watchAtMost=hr,o.watchDebounced=Se,o.watchIgnorable=V,o.watchOnce=Tr,o.watchPausable=Ue,o.watchThrottled=Ne,o.watchTriggerable=Qr,o.watchWithFilter=F,o.whenever=en,Object.defineProperty(o,"__esModule",{value:!0})})(this.VueUse=this.VueUse||{},VueDemi,VueUse);
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { shallowRef, watchEffect, readonly,
|
|
1
|
+
import { shallowRef, watchEffect, readonly, unref, ref, isVue3, watch, customRef, effectScope, provide, inject, getCurrentScope, onScopeDispose, isRef, computed, reactive, toRefs as toRefs$1, toRef, isVue2, set as set$1, getCurrentInstance, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue-demi';
|
|
2
|
+
import { resolveUnref as resolveUnref$1 } from '@vueuse/shared';
|
|
2
3
|
|
|
3
4
|
var __defProp$9 = Object.defineProperty;
|
|
4
5
|
var __defProps$6 = Object.defineProperties;
|
|
@@ -56,6 +57,10 @@ const rand = (min, max) => {
|
|
|
56
57
|
};
|
|
57
58
|
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
58
59
|
|
|
60
|
+
function resolveUnref(r) {
|
|
61
|
+
return typeof r === "function" ? r() : unref(r);
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
function createFilterWrapper(filter, fn) {
|
|
60
65
|
function wrapper(...args) {
|
|
61
66
|
filter(() => fn.apply(this, args), { fn, thisArg: this, args });
|
|
@@ -69,8 +74,8 @@ function debounceFilter(ms, options = {}) {
|
|
|
69
74
|
let timer;
|
|
70
75
|
let maxTimer;
|
|
71
76
|
const filter = (invoke) => {
|
|
72
|
-
const duration =
|
|
73
|
-
const maxDuration =
|
|
77
|
+
const duration = resolveUnref(ms);
|
|
78
|
+
const maxDuration = resolveUnref(options.maxWait);
|
|
74
79
|
if (timer)
|
|
75
80
|
clearTimeout(timer);
|
|
76
81
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
@@ -108,7 +113,7 @@ function throttleFilter(ms, trailing = true, leading = true) {
|
|
|
108
113
|
}
|
|
109
114
|
};
|
|
110
115
|
const filter = (invoke) => {
|
|
111
|
-
const duration =
|
|
116
|
+
const duration = resolveUnref(ms);
|
|
112
117
|
const elapsed = Date.now() - lastExec;
|
|
113
118
|
clear();
|
|
114
119
|
if (duration <= 0) {
|
|
@@ -353,18 +358,6 @@ function isDefined(v) {
|
|
|
353
358
|
return unref(v) != null;
|
|
354
359
|
}
|
|
355
360
|
|
|
356
|
-
function logicAnd(...args) {
|
|
357
|
-
return computed(() => args.every((i) => unref(i)));
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function logicNot(v) {
|
|
361
|
-
return computed(() => !unref(v));
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function logicOr(...args) {
|
|
365
|
-
return computed(() => args.some((i) => unref(i)));
|
|
366
|
-
}
|
|
367
|
-
|
|
368
361
|
var __defProp$8 = Object.defineProperty;
|
|
369
362
|
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
370
363
|
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
@@ -402,17 +395,20 @@ function makeDestructurable(obj, arr) {
|
|
|
402
395
|
}
|
|
403
396
|
}
|
|
404
397
|
|
|
405
|
-
function reactify(fn) {
|
|
398
|
+
function reactify(fn, options) {
|
|
399
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : resolveUnref;
|
|
406
400
|
return function(...args) {
|
|
407
|
-
return computed(() => fn.apply(this, args.map((i) =>
|
|
401
|
+
return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
408
402
|
};
|
|
409
403
|
}
|
|
410
404
|
|
|
411
405
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
412
406
|
let keys = [];
|
|
407
|
+
let options;
|
|
413
408
|
if (Array.isArray(optionsOrKeys)) {
|
|
414
409
|
keys = optionsOrKeys;
|
|
415
410
|
} else {
|
|
411
|
+
options = optionsOrKeys;
|
|
416
412
|
const { includeOwnProperties = true } = optionsOrKeys;
|
|
417
413
|
keys.push(...Object.keys(obj));
|
|
418
414
|
if (includeOwnProperties)
|
|
@@ -422,7 +418,7 @@ function reactifyObject(obj, optionsOrKeys = {}) {
|
|
|
422
418
|
const value = obj[key];
|
|
423
419
|
return [
|
|
424
420
|
key,
|
|
425
|
-
typeof value === "function" ? reactify(value.bind(obj)) : value
|
|
421
|
+
typeof value === "function" ? reactify(value.bind(obj), options) : value
|
|
426
422
|
];
|
|
427
423
|
}));
|
|
428
424
|
}
|
|
@@ -481,7 +477,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
|
481
477
|
const resetAfter = () => setTimeout(() => {
|
|
482
478
|
value = defaultValue;
|
|
483
479
|
trigger();
|
|
484
|
-
},
|
|
480
|
+
}, resolveUnref$1(afterMs));
|
|
485
481
|
tryOnScopeDispose(() => {
|
|
486
482
|
clearTimeout(timer);
|
|
487
483
|
});
|
|
@@ -527,7 +523,7 @@ function refDefault(source, defaultValue) {
|
|
|
527
523
|
});
|
|
528
524
|
}
|
|
529
525
|
|
|
530
|
-
function useThrottleFn(fn, ms = 200, trailing =
|
|
526
|
+
function useThrottleFn(fn, ms = 200, trailing = false, leading = true) {
|
|
531
527
|
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
532
528
|
}
|
|
533
529
|
|
|
@@ -594,10 +590,6 @@ function resolveRef(r) {
|
|
|
594
590
|
return typeof r === "function" ? computed(r) : ref(r);
|
|
595
591
|
}
|
|
596
592
|
|
|
597
|
-
function resolveUnref(r) {
|
|
598
|
-
return typeof r === "function" ? r() : unref(r);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
593
|
function set(...args) {
|
|
602
594
|
if (args.length === 2) {
|
|
603
595
|
const [ref, value] = args;
|
|
@@ -734,7 +726,7 @@ function until(r) {
|
|
|
734
726
|
});
|
|
735
727
|
const promises = [watcher];
|
|
736
728
|
if (timeout != null) {
|
|
737
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
729
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
|
|
738
730
|
}
|
|
739
731
|
return Promise.race(promises);
|
|
740
732
|
}
|
|
@@ -757,9 +749,9 @@ function until(r) {
|
|
|
757
749
|
});
|
|
758
750
|
const promises = [watcher];
|
|
759
751
|
if (timeout != null) {
|
|
760
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
752
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
|
|
761
753
|
stop == null ? void 0 : stop();
|
|
762
|
-
return
|
|
754
|
+
return resolveUnref(r);
|
|
763
755
|
}));
|
|
764
756
|
}
|
|
765
757
|
return Promise.race(promises);
|
|
@@ -779,7 +771,7 @@ function until(r) {
|
|
|
779
771
|
function toContains(value, options) {
|
|
780
772
|
return toMatch((v) => {
|
|
781
773
|
const array = Array.from(v);
|
|
782
|
-
return array.includes(value) || array.includes(
|
|
774
|
+
return array.includes(value) || array.includes(resolveUnref(value));
|
|
783
775
|
}, options);
|
|
784
776
|
}
|
|
785
777
|
function changed(options) {
|
|
@@ -792,7 +784,7 @@ function until(r) {
|
|
|
792
784
|
return count >= n;
|
|
793
785
|
}, options);
|
|
794
786
|
}
|
|
795
|
-
if (Array.isArray(
|
|
787
|
+
if (Array.isArray(resolveUnref(r))) {
|
|
796
788
|
const instance = {
|
|
797
789
|
toMatch,
|
|
798
790
|
toContains,
|
|
@@ -823,6 +815,38 @@ function until(r) {
|
|
|
823
815
|
}
|
|
824
816
|
}
|
|
825
817
|
|
|
818
|
+
function useArrayEvery(list, fn) {
|
|
819
|
+
return computed(() => resolveUnref$1(list).every((element, index, array) => fn(resolveUnref$1(element), index, array)));
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function useArrayFilter(list, fn) {
|
|
823
|
+
return computed(() => resolveUnref$1(list).map((i) => resolveUnref$1(i)).filter(fn));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function useArrayFind(list, fn) {
|
|
827
|
+
return computed(() => resolveUnref$1(resolveUnref$1(list).find((element, index, array) => fn(resolveUnref$1(element), index, array))));
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function useArrayJoin(list, separator) {
|
|
831
|
+
return computed(() => resolveUnref$1(list).map((i) => resolveUnref$1(i)).join(resolveUnref$1(separator)));
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function useArrayMap(list, fn) {
|
|
835
|
+
return computed(() => resolveUnref$1(list).map((i) => resolveUnref$1(i)).map(fn));
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function useArrayReduce(list, reducer, ...args) {
|
|
839
|
+
const reduceCallback = (sum, value, index) => reducer(resolveUnref$1(sum), resolveUnref$1(value), index);
|
|
840
|
+
return computed(() => {
|
|
841
|
+
const resolved = resolveUnref$1(list);
|
|
842
|
+
return args.length ? resolved.reduce(reduceCallback, resolveUnref$1(args[0])) : resolved.reduce(reduceCallback);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
function useArraySome(list, fn) {
|
|
847
|
+
return computed(() => resolveUnref$1(list).some((element, index, array) => fn(resolveUnref$1(element), index, array)));
|
|
848
|
+
}
|
|
849
|
+
|
|
826
850
|
function useCounter(initialValue = 0, options = {}) {
|
|
827
851
|
const count = ref(initialValue);
|
|
828
852
|
const {
|
|
@@ -889,7 +913,7 @@ const normalizeDate = (date) => {
|
|
|
889
913
|
return new Date(date);
|
|
890
914
|
};
|
|
891
915
|
function useDateFormat(date, formatStr = "HH:mm:ss") {
|
|
892
|
-
return computed(() => formatDate(normalizeDate(
|
|
916
|
+
return computed(() => formatDate(normalizeDate(resolveUnref$1(date)), resolveUnref$1(formatStr)));
|
|
893
917
|
}
|
|
894
918
|
|
|
895
919
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -916,7 +940,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
916
940
|
if (immediateCallback)
|
|
917
941
|
cb();
|
|
918
942
|
clean();
|
|
919
|
-
timer = setInterval(cb,
|
|
943
|
+
timer = setInterval(cb, resolveUnref(interval));
|
|
920
944
|
}
|
|
921
945
|
if (immediate && isClient)
|
|
922
946
|
resume();
|
|
@@ -997,7 +1021,7 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
997
1021
|
isPending.value = false;
|
|
998
1022
|
timer = null;
|
|
999
1023
|
cb(...args);
|
|
1000
|
-
},
|
|
1024
|
+
}, resolveUnref$1(interval));
|
|
1001
1025
|
}
|
|
1002
1026
|
if (immediate) {
|
|
1003
1027
|
isPending.value = true;
|
|
@@ -1049,20 +1073,21 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1049
1073
|
falsyValue = false
|
|
1050
1074
|
} = options;
|
|
1051
1075
|
const valueIsRef = isRef(initialValue);
|
|
1052
|
-
const
|
|
1076
|
+
const _value = ref(initialValue);
|
|
1053
1077
|
function toggle(value) {
|
|
1054
1078
|
if (arguments.length) {
|
|
1055
|
-
|
|
1056
|
-
return
|
|
1079
|
+
_value.value = value;
|
|
1080
|
+
return _value.value;
|
|
1057
1081
|
} else {
|
|
1058
|
-
|
|
1059
|
-
|
|
1082
|
+
const truthy = resolveUnref(truthyValue);
|
|
1083
|
+
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
|
|
1084
|
+
return _value.value;
|
|
1060
1085
|
}
|
|
1061
1086
|
}
|
|
1062
1087
|
if (valueIsRef)
|
|
1063
1088
|
return toggle;
|
|
1064
1089
|
else
|
|
1065
|
-
return [
|
|
1090
|
+
return [_value, toggle];
|
|
1066
1091
|
}
|
|
1067
1092
|
|
|
1068
1093
|
function watchArray(source, cb, options) {
|
|
@@ -1138,7 +1163,7 @@ function watchAtMost(source, cb, options) {
|
|
|
1138
1163
|
const current = ref(0);
|
|
1139
1164
|
const stop = watchWithFilter(source, (...args) => {
|
|
1140
1165
|
current.value += 1;
|
|
1141
|
-
if (current.value >=
|
|
1166
|
+
if (current.value >= resolveUnref(count))
|
|
1142
1167
|
nextTick(() => stop());
|
|
1143
1168
|
cb(...args);
|
|
1144
1169
|
}, watchOptions);
|
|
@@ -1439,4 +1464,4 @@ function whenever(source, cb, options) {
|
|
|
1439
1464
|
}, options);
|
|
1440
1465
|
}
|
|
1441
1466
|
|
|
1442
|
-
export { __onlyVue3,
|
|
1467
|
+
export { __onlyVue3, 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, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, makeDestructurable, noop, normalizeDate, now, 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, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayEvery, useArrayFilter, useArrayFind, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchArray, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-beta.0",
|
|
4
4
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"funding": "https://github.com/sponsors/antfu",
|
|
@@ -32,18 +32,6 @@
|
|
|
32
32
|
"unpkg": "./index.iife.min.js",
|
|
33
33
|
"jsdelivr": "./index.iife.min.js",
|
|
34
34
|
"types": "./index.d.ts",
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"@vue/composition-api": "^1.1.0",
|
|
37
|
-
"vue": "^2.6.0 || ^3.2.0"
|
|
38
|
-
},
|
|
39
|
-
"peerDependenciesMeta": {
|
|
40
|
-
"vue": {
|
|
41
|
-
"optional": true
|
|
42
|
-
},
|
|
43
|
-
"@vue/composition-api": {
|
|
44
|
-
"optional": true
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
35
|
"dependencies": {
|
|
48
36
|
"vue-demi": "*"
|
|
49
37
|
}
|