@vueuse/shared 10.0.0-beta.3 → 10.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -32,222 +32,6 @@ function computedEager(fn, options) {
32
32
  return vueDemi.readonly(result);
33
33
  }
34
34
 
35
- var _a;
36
- const isClient = typeof window !== "undefined";
37
- const isDef = (val) => typeof val !== "undefined";
38
- const assert = (condition, ...infos) => {
39
- if (!condition)
40
- console.warn(...infos);
41
- };
42
- const toString = Object.prototype.toString;
43
- const isBoolean = (val) => typeof val === "boolean";
44
- const isFunction = (val) => typeof val === "function";
45
- const isNumber = (val) => typeof val === "number";
46
- const isString = (val) => typeof val === "string";
47
- const isObject = (val) => toString.call(val) === "[object Object]";
48
- const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
49
- const now = () => Date.now();
50
- const timestamp = () => +Date.now();
51
- const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
52
- const noop = () => {
53
- };
54
- const rand = (min, max) => {
55
- min = Math.ceil(min);
56
- max = Math.floor(max);
57
- return Math.floor(Math.random() * (max - min + 1)) + min;
58
- };
59
- const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
60
- const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
61
-
62
- function resolveUnref(r) {
63
- return typeof r === "function" ? r() : vueDemi.unref(r);
64
- }
65
-
66
- function createFilterWrapper(filter, fn) {
67
- function wrapper(...args) {
68
- return new Promise((resolve, reject) => {
69
- Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
70
- });
71
- }
72
- return wrapper;
73
- }
74
- const bypassFilter = (invoke) => {
75
- return invoke();
76
- };
77
- function debounceFilter(ms, options = {}) {
78
- let timer;
79
- let maxTimer;
80
- let lastRejector = noop;
81
- const _clearTimeout = (timer2) => {
82
- clearTimeout(timer2);
83
- lastRejector();
84
- lastRejector = noop;
85
- };
86
- const filter = (invoke) => {
87
- const duration = resolveUnref(ms);
88
- const maxDuration = resolveUnref(options.maxWait);
89
- if (timer)
90
- _clearTimeout(timer);
91
- if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
92
- if (maxTimer) {
93
- _clearTimeout(maxTimer);
94
- maxTimer = null;
95
- }
96
- return Promise.resolve(invoke());
97
- }
98
- return new Promise((resolve, reject) => {
99
- lastRejector = options.rejectOnCancel ? reject : resolve;
100
- if (maxDuration && !maxTimer) {
101
- maxTimer = setTimeout(() => {
102
- if (timer)
103
- _clearTimeout(timer);
104
- maxTimer = null;
105
- resolve(invoke());
106
- }, maxDuration);
107
- }
108
- timer = setTimeout(() => {
109
- if (maxTimer)
110
- _clearTimeout(maxTimer);
111
- maxTimer = null;
112
- resolve(invoke());
113
- }, duration);
114
- });
115
- };
116
- return filter;
117
- }
118
- function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
119
- let lastExec = 0;
120
- let timer;
121
- let isLeading = true;
122
- let lastRejector = noop;
123
- let lastValue;
124
- const clear = () => {
125
- if (timer) {
126
- clearTimeout(timer);
127
- timer = void 0;
128
- lastRejector();
129
- lastRejector = noop;
130
- }
131
- };
132
- const filter = (_invoke) => {
133
- const duration = resolveUnref(ms);
134
- const elapsed = Date.now() - lastExec;
135
- const invoke = () => {
136
- return lastValue = _invoke();
137
- };
138
- clear();
139
- if (duration <= 0) {
140
- lastExec = Date.now();
141
- return invoke();
142
- }
143
- if (elapsed > duration && (leading || !isLeading)) {
144
- lastExec = Date.now();
145
- invoke();
146
- } else if (trailing) {
147
- lastValue = new Promise((resolve, reject) => {
148
- lastRejector = rejectOnCancel ? reject : resolve;
149
- timer = setTimeout(() => {
150
- lastExec = Date.now();
151
- isLeading = true;
152
- resolve(invoke());
153
- clear();
154
- }, Math.max(0, duration - elapsed));
155
- });
156
- }
157
- if (!leading && !timer)
158
- timer = setTimeout(() => isLeading = true, duration);
159
- isLeading = false;
160
- return lastValue;
161
- };
162
- return filter;
163
- }
164
- function pausableFilter(extendFilter = bypassFilter) {
165
- const isActive = vueDemi.ref(true);
166
- function pause() {
167
- isActive.value = false;
168
- }
169
- function resume() {
170
- isActive.value = true;
171
- }
172
- const eventFilter = (...args) => {
173
- if (isActive.value)
174
- extendFilter(...args);
175
- };
176
- return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
177
- }
178
-
179
- function __onlyVue3(name = "this function") {
180
- if (vueDemi.isVue3)
181
- return;
182
- throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
183
- }
184
- function __onlyVue27Plus(name = "this function") {
185
- if (vueDemi.isVue3 || vueDemi.version.startsWith("2.7."))
186
- return;
187
- throw new Error(`[VueUse] ${name} is only works on Vue 2.7 or above.`);
188
- }
189
- const directiveHooks = {
190
- mounted: vueDemi.isVue3 ? "mounted" : "inserted",
191
- updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
192
- unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
193
- };
194
-
195
- function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
196
- return new Promise((resolve, reject) => {
197
- if (throwOnTimeout)
198
- setTimeout(() => reject(reason), ms);
199
- else
200
- setTimeout(resolve, ms);
201
- });
202
- }
203
- function identity(arg) {
204
- return arg;
205
- }
206
- function createSingletonPromise(fn) {
207
- let _promise;
208
- function wrapper() {
209
- if (!_promise)
210
- _promise = fn();
211
- return _promise;
212
- }
213
- wrapper.reset = async () => {
214
- const _prev = _promise;
215
- _promise = void 0;
216
- if (_prev)
217
- await _prev;
218
- };
219
- return wrapper;
220
- }
221
- function invoke(fn) {
222
- return fn();
223
- }
224
- function containsProp(obj, ...props) {
225
- return props.some((k) => k in obj);
226
- }
227
- function increaseWithUnit(target, delta) {
228
- var _a;
229
- if (typeof target === "number")
230
- return target + delta;
231
- const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
232
- const unit = target.slice(value.length);
233
- const result = parseFloat(value) + delta;
234
- if (Number.isNaN(result))
235
- return target;
236
- return result + unit;
237
- }
238
- function objectPick(obj, keys, omitUndefined = false) {
239
- return keys.reduce((n, k) => {
240
- if (k in obj) {
241
- if (!omitUndefined || obj[k] !== void 0)
242
- n[k] = obj[k];
243
- }
244
- return n;
245
- }, {});
246
- }
247
- function objectEntries(obj) {
248
- return Object.entries(obj);
249
- }
250
-
251
35
  function computedWithControl(source, fn) {
252
36
  let v = void 0;
253
37
  let track;
@@ -258,8 +42,8 @@ function computedWithControl(source, fn) {
258
42
  trigger();
259
43
  };
260
44
  vueDemi.watch(source, update, { flush: "sync" });
261
- const get = isFunction(fn) ? fn : fn.get;
262
- const set = isFunction(fn) ? void 0 : fn.set;
45
+ const get = typeof fn === "function" ? fn : fn.get;
46
+ const set = typeof fn === "function" ? void 0 : fn.set;
263
47
  const result = vueDemi.customRef((_track, _trigger) => {
264
48
  track = _track;
265
49
  trigger = _trigger;
@@ -361,7 +145,11 @@ function createSharedComposable(composable) {
361
145
  }
362
146
 
363
147
  function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
364
- __onlyVue27Plus();
148
+ if (!vueDemi.isVue3 && !vueDemi.version.startsWith("2.7.")) {
149
+ if (process.env.NODE_ENV !== "production")
150
+ throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");
151
+ return;
152
+ }
365
153
  for (const [key, value] of Object.entries(extend)) {
366
154
  if (key === "value")
367
155
  continue;
@@ -429,8 +217,13 @@ function makeDestructurable(obj, arr) {
429
217
  }
430
218
  }
431
219
 
220
+ function toValue(r) {
221
+ return typeof r === "function" ? r() : vueDemi.unref(r);
222
+ }
223
+ const resolveUnref = toValue;
224
+
432
225
  function reactify(fn, options) {
433
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
226
+ const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
434
227
  return function(...args) {
435
228
  return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
436
229
  };
@@ -500,14 +293,227 @@ function reactiveOmit(obj, ...keys) {
500
293
  const flatKeys = keys.flat();
501
294
  const predicate = flatKeys[0];
502
295
  return reactiveComputed(
503
- () => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(resolveUnref(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))
296
+ () => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))
504
297
  );
505
298
  }
506
299
 
300
+ const isClient = typeof window !== "undefined";
301
+ const isDef = (val) => typeof val !== "undefined";
302
+ const assert = (condition, ...infos) => {
303
+ if (!condition)
304
+ console.warn(...infos);
305
+ };
306
+ const toString = Object.prototype.toString;
307
+ const isObject = (val) => toString.call(val) === "[object Object]";
308
+ const now = () => Date.now();
309
+ const timestamp = () => +Date.now();
310
+ const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
311
+ const noop = () => {
312
+ };
313
+ const rand = (min, max) => {
314
+ min = Math.ceil(min);
315
+ max = Math.floor(max);
316
+ return Math.floor(Math.random() * (max - min + 1)) + min;
317
+ };
318
+ const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
319
+ const isIOS = /* @__PURE__ */ getIsIOS();
320
+ function getIsIOS() {
321
+ var _a;
322
+ return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
323
+ }
324
+
325
+ function createFilterWrapper(filter, fn) {
326
+ function wrapper(...args) {
327
+ return new Promise((resolve, reject) => {
328
+ Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
329
+ });
330
+ }
331
+ return wrapper;
332
+ }
333
+ const bypassFilter = (invoke) => {
334
+ return invoke();
335
+ };
336
+ function debounceFilter(ms, options = {}) {
337
+ let timer;
338
+ let maxTimer;
339
+ let lastRejector = noop;
340
+ const _clearTimeout = (timer2) => {
341
+ clearTimeout(timer2);
342
+ lastRejector();
343
+ lastRejector = noop;
344
+ };
345
+ const filter = (invoke) => {
346
+ const duration = toValue(ms);
347
+ const maxDuration = toValue(options.maxWait);
348
+ if (timer)
349
+ _clearTimeout(timer);
350
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
351
+ if (maxTimer) {
352
+ _clearTimeout(maxTimer);
353
+ maxTimer = null;
354
+ }
355
+ return Promise.resolve(invoke());
356
+ }
357
+ return new Promise((resolve, reject) => {
358
+ lastRejector = options.rejectOnCancel ? reject : resolve;
359
+ if (maxDuration && !maxTimer) {
360
+ maxTimer = setTimeout(() => {
361
+ if (timer)
362
+ _clearTimeout(timer);
363
+ maxTimer = null;
364
+ resolve(invoke());
365
+ }, maxDuration);
366
+ }
367
+ timer = setTimeout(() => {
368
+ if (maxTimer)
369
+ _clearTimeout(maxTimer);
370
+ maxTimer = null;
371
+ resolve(invoke());
372
+ }, duration);
373
+ });
374
+ };
375
+ return filter;
376
+ }
377
+ function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
378
+ let lastExec = 0;
379
+ let timer;
380
+ let isLeading = true;
381
+ let lastRejector = noop;
382
+ let lastValue;
383
+ const clear = () => {
384
+ if (timer) {
385
+ clearTimeout(timer);
386
+ timer = void 0;
387
+ lastRejector();
388
+ lastRejector = noop;
389
+ }
390
+ };
391
+ const filter = (_invoke) => {
392
+ const duration = toValue(ms);
393
+ const elapsed = Date.now() - lastExec;
394
+ const invoke = () => {
395
+ return lastValue = _invoke();
396
+ };
397
+ clear();
398
+ if (duration <= 0) {
399
+ lastExec = Date.now();
400
+ return invoke();
401
+ }
402
+ if (elapsed > duration && (leading || !isLeading)) {
403
+ lastExec = Date.now();
404
+ invoke();
405
+ } else if (trailing) {
406
+ lastValue = new Promise((resolve, reject) => {
407
+ lastRejector = rejectOnCancel ? reject : resolve;
408
+ timer = setTimeout(() => {
409
+ lastExec = Date.now();
410
+ isLeading = true;
411
+ resolve(invoke());
412
+ clear();
413
+ }, Math.max(0, duration - elapsed));
414
+ });
415
+ }
416
+ if (!leading && !timer)
417
+ timer = setTimeout(() => isLeading = true, duration);
418
+ isLeading = false;
419
+ return lastValue;
420
+ };
421
+ return filter;
422
+ }
423
+ function pausableFilter(extendFilter = bypassFilter) {
424
+ const isActive = vueDemi.ref(true);
425
+ function pause() {
426
+ isActive.value = false;
427
+ }
428
+ function resume() {
429
+ isActive.value = true;
430
+ }
431
+ const eventFilter = (...args) => {
432
+ if (isActive.value)
433
+ extendFilter(...args);
434
+ };
435
+ return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
436
+ }
437
+
438
+ const directiveHooks = {
439
+ mounted: vueDemi.isVue3 ? "mounted" : "inserted",
440
+ updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
441
+ unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
442
+ };
443
+
444
+ function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
445
+ return new Promise((resolve, reject) => {
446
+ if (throwOnTimeout)
447
+ setTimeout(() => reject(reason), ms);
448
+ else
449
+ setTimeout(resolve, ms);
450
+ });
451
+ }
452
+ function identity(arg) {
453
+ return arg;
454
+ }
455
+ function createSingletonPromise(fn) {
456
+ let _promise;
457
+ function wrapper() {
458
+ if (!_promise)
459
+ _promise = fn();
460
+ return _promise;
461
+ }
462
+ wrapper.reset = async () => {
463
+ const _prev = _promise;
464
+ _promise = void 0;
465
+ if (_prev)
466
+ await _prev;
467
+ };
468
+ return wrapper;
469
+ }
470
+ function invoke(fn) {
471
+ return fn();
472
+ }
473
+ function containsProp(obj, ...props) {
474
+ return props.some((k) => k in obj);
475
+ }
476
+ function increaseWithUnit(target, delta) {
477
+ var _a;
478
+ if (typeof target === "number")
479
+ return target + delta;
480
+ const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
481
+ const unit = target.slice(value.length);
482
+ const result = parseFloat(value) + delta;
483
+ if (Number.isNaN(result))
484
+ return target;
485
+ return result + unit;
486
+ }
487
+ function objectPick(obj, keys, omitUndefined = false) {
488
+ return keys.reduce((n, k) => {
489
+ if (k in obj) {
490
+ if (!omitUndefined || obj[k] !== void 0)
491
+ n[k] = obj[k];
492
+ }
493
+ return n;
494
+ }, {});
495
+ }
496
+ function objectOmit(obj, keys, omitUndefined = false) {
497
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
498
+ return (!omitUndefined || value !== void 0) && !keys.includes(key);
499
+ }));
500
+ }
501
+ function objectEntries(obj) {
502
+ return Object.entries(obj);
503
+ }
504
+
505
+ function toRef(...args) {
506
+ if (args.length !== 1)
507
+ return vueDemi.toRef(...args);
508
+ const r = args[0];
509
+ return typeof r === "function" ? vueDemi.readonly(vueDemi.customRef(() => ({ get: r, set: noop }))) : vueDemi.ref(r);
510
+ }
511
+ const resolveRef = toRef;
512
+
507
513
  function reactivePick(obj, ...keys) {
508
514
  const flatKeys = keys.flat();
509
515
  const predicate = flatKeys[0];
510
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => predicate(resolveUnref(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, vueDemi.toRef(obj, k)])));
516
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
511
517
  }
512
518
 
513
519
  function refAutoReset(defaultValue, afterMs = 1e4) {
@@ -517,7 +523,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
517
523
  const resetAfter = () => setTimeout(() => {
518
524
  value = defaultValue;
519
525
  trigger();
520
- }, resolveUnref(afterMs));
526
+ }, toValue(afterMs));
521
527
  tryOnScopeDispose(() => {
522
528
  clearTimeout(timer);
523
529
  });
@@ -634,10 +640,6 @@ function refWithControl(initial, options = {}) {
634
640
  }
635
641
  const controlledRef = refWithControl;
636
642
 
637
- function resolveRef(r) {
638
- return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
639
- }
640
-
641
643
  function set(...args) {
642
644
  if (args.length === 2) {
643
645
  const [ref, value] = args;
@@ -795,7 +797,7 @@ function createUntil(r, isNot = false) {
795
797
  const promises = [watcher];
796
798
  if (timeout != null) {
797
799
  promises.push(
798
- promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop())
800
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
799
801
  );
800
802
  }
801
803
  return Promise.race(promises);
@@ -824,9 +826,9 @@ function createUntil(r, isNot = false) {
824
826
  const promises = [watcher];
825
827
  if (timeout != null) {
826
828
  promises.push(
827
- promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
829
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
828
830
  stop == null ? void 0 : stop();
829
- return resolveUnref(r);
831
+ return toValue(r);
830
832
  })
831
833
  );
832
834
  }
@@ -847,7 +849,7 @@ function createUntil(r, isNot = false) {
847
849
  function toContains(value, options) {
848
850
  return toMatch((v) => {
849
851
  const array = Array.from(v);
850
- return array.includes(value) || array.includes(resolveUnref(value));
852
+ return array.includes(value) || array.includes(toValue(value));
851
853
  }, options);
852
854
  }
853
855
  function changed(options) {
@@ -860,7 +862,7 @@ function createUntil(r, isNot = false) {
860
862
  return count >= n;
861
863
  }, options);
862
864
  }
863
- if (Array.isArray(resolveUnref(r))) {
865
+ if (Array.isArray(toValue(r))) {
864
866
  const instance = {
865
867
  toMatch,
866
868
  toContains,
@@ -900,31 +902,31 @@ function useArrayDifference(...args) {
900
902
  const list = args[0];
901
903
  const values = args[1];
902
904
  let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
903
- if (isString(compareFn)) {
905
+ if (typeof compareFn === "string") {
904
906
  const key = compareFn;
905
907
  compareFn = (value, othVal) => value[key] === othVal[key];
906
908
  }
907
- return vueDemi.computed(() => resolveUnref(list).filter((x) => resolveUnref(values).findIndex((y) => compareFn(x, y)) === -1));
909
+ return vueDemi.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
908
910
  }
909
911
 
910
912
  function useArrayEvery(list, fn) {
911
- return vueDemi.computed(() => resolveUnref(list).every((element, index, array) => fn(resolveUnref(element), index, array)));
913
+ return vueDemi.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
912
914
  }
913
915
 
914
916
  function useArrayFilter(list, fn) {
915
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).filter(fn));
917
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
916
918
  }
917
919
 
918
920
  function useArrayFind(list, fn) {
919
921
  return vueDemi.computed(
920
- () => resolveUnref(
921
- resolveUnref(list).find((element, index, array) => fn(resolveUnref(element), index, array))
922
+ () => toValue(
923
+ toValue(list).find((element, index, array) => fn(toValue(element), index, array))
922
924
  )
923
925
  );
924
926
  }
925
927
 
926
928
  function useArrayFindIndex(list, fn) {
927
- return vueDemi.computed(() => resolveUnref(list).findIndex((element, index, array) => fn(resolveUnref(element), index, array)));
929
+ return vueDemi.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
928
930
  }
929
931
 
930
932
  function findLast(arr, cb) {
@@ -937,8 +939,8 @@ function findLast(arr, cb) {
937
939
  }
938
940
  function useArrayFindLast(list, fn) {
939
941
  return vueDemi.computed(
940
- () => resolveUnref(
941
- !Array.prototype.findLast ? findLast(resolveUnref(list), (element, index, array) => fn(resolveUnref(element), index, array)) : resolveUnref(list).findLast((element, index, array) => fn(resolveUnref(element), index, array))
942
+ () => toValue(
943
+ !Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
942
944
  )
943
945
  );
944
946
  }
@@ -958,34 +960,34 @@ function useArrayIncludes(...args) {
958
960
  }
959
961
  if (typeof comparator === "string") {
960
962
  const key = comparator;
961
- comparator = (element, value2) => element[key] === resolveUnref(value2);
963
+ comparator = (element, value2) => element[key] === toValue(value2);
962
964
  }
963
- comparator = comparator != null ? comparator : (element, value2) => element === resolveUnref(value2);
965
+ comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
964
966
  return vueDemi.computed(
965
- () => resolveUnref(list).slice(formIndex).some(
966
- (element, index, array) => comparator(resolveUnref(element), resolveUnref(value), index, resolveUnref(array))
967
+ () => toValue(list).slice(formIndex).some(
968
+ (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
967
969
  )
968
970
  );
969
971
  }
970
972
 
971
973
  function useArrayJoin(list, separator) {
972
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).join(resolveUnref(separator)));
974
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
973
975
  }
974
976
 
975
977
  function useArrayMap(list, fn) {
976
- return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).map(fn));
978
+ return vueDemi.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
977
979
  }
978
980
 
979
981
  function useArrayReduce(list, reducer, ...args) {
980
- const reduceCallback = (sum, value, index) => reducer(resolveUnref(sum), resolveUnref(value), index);
982
+ const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
981
983
  return vueDemi.computed(() => {
982
- const resolved = resolveUnref(list);
983
- return args.length ? resolved.reduce(reduceCallback, resolveUnref(args[0])) : resolved.reduce(reduceCallback);
984
+ const resolved = toValue(list);
985
+ return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
984
986
  });
985
987
  }
986
988
 
987
989
  function useArraySome(list, fn) {
988
- return vueDemi.computed(() => resolveUnref(list).some((element, index, array) => fn(resolveUnref(element), index, array)));
990
+ return vueDemi.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
989
991
  }
990
992
 
991
993
  function uniq(array) {
@@ -1000,7 +1002,7 @@ function uniqueElementsBy(array, fn) {
1000
1002
  }
1001
1003
  function useArrayUnique(list, compareFn) {
1002
1004
  return vueDemi.computed(() => {
1003
- const resolvedList = resolveUnref(list).map((element) => resolveUnref(element));
1005
+ const resolvedList = toValue(list).map((element) => toValue(element));
1004
1006
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1005
1007
  });
1006
1008
  }
@@ -1088,7 +1090,7 @@ function normalizeDate(date) {
1088
1090
  return new Date(date);
1089
1091
  }
1090
1092
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1091
- return vueDemi.computed(() => formatDate(normalizeDate(resolveUnref(date)), resolveUnref(formatStr), options));
1093
+ return vueDemi.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1092
1094
  }
1093
1095
 
1094
1096
  function useIntervalFn(cb, interval = 1e3, options = {}) {
@@ -1109,7 +1111,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1109
1111
  clean();
1110
1112
  }
1111
1113
  function resume() {
1112
- const intervalValue = resolveUnref(interval);
1114
+ const intervalValue = toValue(interval);
1113
1115
  if (intervalValue <= 0)
1114
1116
  return;
1115
1117
  isActive.value = true;
@@ -1120,7 +1122,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1120
1122
  }
1121
1123
  if (immediate && isClient)
1122
1124
  resume();
1123
- if (vueDemi.isRef(interval) || isFunction(interval)) {
1125
+ if (vueDemi.isRef(interval) || typeof interval === "function") {
1124
1126
  const stopWatch = vueDemi.watch(interval, () => {
1125
1127
  if (isActive.value && isClient)
1126
1128
  resume();
@@ -1214,7 +1216,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1214
1216
  isPending.value = false;
1215
1217
  timer = null;
1216
1218
  cb(...args);
1217
- }, resolveUnref(interval));
1219
+ }, toValue(interval));
1218
1220
  }
1219
1221
  if (immediate) {
1220
1222
  isPending.value = true;
@@ -1272,7 +1274,7 @@ function useToNumber(value, options = {}) {
1272
1274
  nanToZero
1273
1275
  } = options;
1274
1276
  return vueDemi.computed(() => {
1275
- let resolved = resolveUnref(value);
1277
+ let resolved = toValue(value);
1276
1278
  if (typeof resolved === "string")
1277
1279
  resolved = Number[method](resolved, radix);
1278
1280
  if (nanToZero && isNaN(resolved))
@@ -1282,7 +1284,7 @@ function useToNumber(value, options = {}) {
1282
1284
  }
1283
1285
 
1284
1286
  function useToString(value) {
1285
- return vueDemi.computed(() => `${resolveUnref(value)}`);
1287
+ return vueDemi.computed(() => `${toValue(value)}`);
1286
1288
  }
1287
1289
 
1288
1290
  function useToggle(initialValue = false, options = {}) {
@@ -1297,8 +1299,8 @@ function useToggle(initialValue = false, options = {}) {
1297
1299
  _value.value = value;
1298
1300
  return _value.value;
1299
1301
  } else {
1300
- const truthy = resolveUnref(truthyValue);
1301
- _value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
1302
+ const truthy = toValue(truthyValue);
1303
+ _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
1302
1304
  return _value.value;
1303
1305
  }
1304
1306
  }
@@ -1310,7 +1312,7 @@ function useToggle(initialValue = false, options = {}) {
1310
1312
 
1311
1313
  function watchArray(source, cb, options) {
1312
1314
  let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1313
- ...source instanceof Function ? source() : Array.isArray(source) ? source : vueDemi.unref(source)
1315
+ ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1314
1316
  ];
1315
1317
  return vueDemi.watch(source, (newList, _, onCleanup) => {
1316
1318
  const oldListRemains = new Array(oldList.length);
@@ -1390,7 +1392,7 @@ function watchAtMost(source, cb, options) {
1390
1392
  source,
1391
1393
  (...args) => {
1392
1394
  current.value += 1;
1393
- if (current.value >= resolveUnref(count))
1395
+ if (current.value >= toValue(count))
1394
1396
  vueDemi.nextTick(() => stop());
1395
1397
  cb(...args);
1396
1398
  },
@@ -1765,11 +1767,8 @@ function getWatchSources(sources) {
1765
1767
  if (vueDemi.isReactive(sources))
1766
1768
  return sources;
1767
1769
  if (Array.isArray(sources))
1768
- return sources.map((item) => getOneWatchSource(item));
1769
- return getOneWatchSource(sources);
1770
- }
1771
- function getOneWatchSource(source) {
1772
- return typeof source === "function" ? source() : vueDemi.unref(source);
1770
+ return sources.map((item) => toValue(item));
1771
+ return toValue(sources);
1773
1772
  }
1774
1773
  function getOldValue(source) {
1775
1774
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
@@ -1786,8 +1785,6 @@ function whenever(source, cb, options) {
1786
1785
  );
1787
1786
  }
1788
1787
 
1789
- exports.__onlyVue27Plus = __onlyVue27Plus;
1790
- exports.__onlyVue3 = __onlyVue3;
1791
1788
  exports.assert = assert;
1792
1789
  exports.autoResetRef = refAutoReset;
1793
1790
  exports.bypassFilter = bypassFilter;
@@ -1817,21 +1814,17 @@ exports.identity = identity;
1817
1814
  exports.ignorableWatch = watchIgnorable;
1818
1815
  exports.increaseWithUnit = increaseWithUnit;
1819
1816
  exports.invoke = invoke;
1820
- exports.isBoolean = isBoolean;
1821
1817
  exports.isClient = isClient;
1822
1818
  exports.isDef = isDef;
1823
1819
  exports.isDefined = isDefined;
1824
- exports.isFunction = isFunction;
1825
1820
  exports.isIOS = isIOS;
1826
- exports.isNumber = isNumber;
1827
1821
  exports.isObject = isObject;
1828
- exports.isString = isString;
1829
- exports.isWindow = isWindow;
1830
1822
  exports.makeDestructurable = makeDestructurable;
1831
1823
  exports.noop = noop;
1832
1824
  exports.normalizeDate = normalizeDate;
1833
1825
  exports.now = now;
1834
1826
  exports.objectEntries = objectEntries;
1827
+ exports.objectOmit = objectOmit;
1835
1828
  exports.objectPick = objectPick;
1836
1829
  exports.pausableFilter = pausableFilter;
1837
1830
  exports.pausableWatch = watchPausable;
@@ -1857,7 +1850,9 @@ exports.throttledRef = refThrottled;
1857
1850
  exports.throttledWatch = watchThrottled;
1858
1851
  exports.timestamp = timestamp;
1859
1852
  exports.toReactive = toReactive;
1853
+ exports.toRef = toRef;
1860
1854
  exports.toRefs = toRefs;
1855
+ exports.toValue = toValue;
1861
1856
  exports.tryOnBeforeMount = tryOnBeforeMount;
1862
1857
  exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
1863
1858
  exports.tryOnMounted = tryOnMounted;