@vueuse/shared 7.7.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -1,30 +1,36 @@
1
- import { computed, unref, watch, ref, customRef, isVue3, isRef, effectScope, getCurrentScope, onScopeDispose, shallowRef, watchEffect, readonly, reactive, toRefs as toRefs$1, toRef, isVue2, set as set$1, getCurrentInstance, onBeforeUnmount, onMounted, nextTick, onUnmounted } from 'vue-demi';
1
+ import { shallowRef, watchEffect, readonly, ref, watch, customRef, effectScope, getCurrentScope, onScopeDispose, isVue3, isRef, unref, computed, reactive, toRefs as toRefs$1, toRef, isVue2, set as set$1, getCurrentInstance, onBeforeUnmount, onMounted, nextTick, onUnmounted } from 'vue-demi';
2
2
 
3
- function and(...args) {
4
- return computed(() => args.every((i) => unref(i)));
5
- }
6
-
7
- function biSyncRef(a, b) {
8
- const flush = "sync";
9
- const stop1 = watch(a, (newValue) => {
10
- b.value = newValue;
11
- }, {
12
- flush,
13
- immediate: true
14
- });
15
- const stop2 = watch(b, (newValue) => {
16
- a.value = newValue;
17
- }, {
18
- flush,
19
- immediate: true
20
- });
21
- return () => {
22
- stop1();
23
- stop2();
24
- };
3
+ var __defProp$8 = Object.defineProperty;
4
+ var __defProps$5 = Object.defineProperties;
5
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues$8 = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp$a.call(b, prop))
13
+ __defNormalProp$8(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols$a)
15
+ for (var prop of __getOwnPropSymbols$a(b)) {
16
+ if (__propIsEnum$a.call(b, prop))
17
+ __defNormalProp$8(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
22
+ function computedEager(fn, options) {
23
+ var _a;
24
+ const result = shallowRef();
25
+ watchEffect(() => {
26
+ result.value = fn();
27
+ }, __spreadProps$5(__spreadValues$8({}, options), {
28
+ flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
29
+ }));
30
+ return readonly(result);
25
31
  }
26
32
 
27
- function controlledComputed(source, fn) {
33
+ function computedWithControl(source, fn) {
28
34
  let v = void 0;
29
35
  let track;
30
36
  let trigger;
@@ -51,81 +57,6 @@ function controlledComputed(source, fn) {
51
57
  });
52
58
  }
53
59
 
54
- function __onlyVue3(name = "this function") {
55
- if (isVue3)
56
- return;
57
- throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
58
- }
59
-
60
- function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
61
- __onlyVue3();
62
- for (const [key, value] of Object.entries(extend)) {
63
- if (key === "value")
64
- continue;
65
- if (isRef(value) && unwrap) {
66
- Object.defineProperty(ref, key, {
67
- get() {
68
- return value.value;
69
- },
70
- set(v) {
71
- value.value = v;
72
- },
73
- enumerable
74
- });
75
- } else {
76
- Object.defineProperty(ref, key, { value, enumerable });
77
- }
78
- }
79
- return ref;
80
- }
81
-
82
- function controlledRef(initial, options = {}) {
83
- let source = initial;
84
- let track;
85
- let trigger;
86
- const ref = customRef((_track, _trigger) => {
87
- track = _track;
88
- trigger = _trigger;
89
- return {
90
- get() {
91
- return get();
92
- },
93
- set(v) {
94
- set(v);
95
- }
96
- };
97
- });
98
- function get(tracking = true) {
99
- if (tracking)
100
- track();
101
- return source;
102
- }
103
- function set(value, triggering = true) {
104
- var _a, _b;
105
- if (value === source)
106
- return;
107
- const old = source;
108
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
109
- return;
110
- source = value;
111
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
112
- if (triggering)
113
- trigger();
114
- }
115
- const untrackedGet = () => get(false);
116
- const silentSet = (v) => set(v, false);
117
- const peek = () => get(false);
118
- const lay = (v) => set(v, false);
119
- return extendRef(ref, {
120
- get,
121
- set,
122
- untrackedGet,
123
- silentSet,
124
- peek,
125
- lay
126
- }, { enumerable: true });
127
- }
128
-
129
60
  function createEventHook() {
130
61
  const fns = [];
131
62
  const off = (fn) => {
@@ -162,12 +93,6 @@ function createGlobalState(stateFactory) {
162
93
  };
163
94
  }
164
95
 
165
- function reactify(fn) {
166
- return function(...args) {
167
- return computed(() => fn.apply(this, args.map((i) => unref(i))));
168
- };
169
- }
170
-
171
96
  function tryOnScopeDispose(fn) {
172
97
  if (getCurrentScope()) {
173
98
  onScopeDispose(fn);
@@ -199,126 +124,306 @@ function createSharedComposable(composable) {
199
124
  };
200
125
  }
201
126
 
202
- const isClient = typeof window !== "undefined";
203
- const isDef = (val) => typeof val !== "undefined";
204
- const assert = (condition, ...infos) => {
205
- if (!condition)
206
- console.warn(...infos);
207
- };
208
- const toString = Object.prototype.toString;
209
- const isBoolean = (val) => typeof val === "boolean";
210
- const isFunction = (val) => typeof val === "function";
211
- const isNumber = (val) => typeof val === "number";
212
- const isString = (val) => typeof val === "string";
213
- const isObject = (val) => toString.call(val) === "[object Object]";
214
- const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
215
- const now = () => Date.now();
216
- const timestamp = () => +Date.now();
217
- const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
218
- const noop = () => {
219
- };
220
- const rand = (min, max) => {
221
- min = Math.ceil(min);
222
- max = Math.floor(max);
223
- return Math.floor(Math.random() * (max - min + 1)) + min;
224
- };
127
+ function __onlyVue3(name = "this function") {
128
+ if (isVue3)
129
+ return;
130
+ throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
131
+ }
225
132
 
226
- function createFilterWrapper(filter, fn) {
227
- function wrapper(...args) {
228
- filter(() => fn.apply(this, args), { fn, thisArg: this, args });
133
+ function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
134
+ __onlyVue3();
135
+ for (const [key, value] of Object.entries(extend)) {
136
+ if (key === "value")
137
+ continue;
138
+ if (isRef(value) && unwrap) {
139
+ Object.defineProperty(ref, key, {
140
+ get() {
141
+ return value.value;
142
+ },
143
+ set(v) {
144
+ value.value = v;
145
+ },
146
+ enumerable
147
+ });
148
+ } else {
149
+ Object.defineProperty(ref, key, { value, enumerable });
150
+ }
229
151
  }
230
- return wrapper;
152
+ return ref;
231
153
  }
232
- const bypassFilter = (invoke) => {
233
- return invoke();
234
- };
235
- function debounceFilter(ms, options = {}) {
236
- let timer;
237
- let maxTimer;
238
- const filter = (invoke) => {
239
- const duration = unref(ms);
240
- const maxDuration = unref(options.maxWait);
241
- if (timer)
242
- clearTimeout(timer);
243
- if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
244
- if (maxTimer) {
245
- clearTimeout(maxTimer);
246
- maxTimer = null;
247
- }
248
- return invoke();
249
- }
250
- if (maxDuration && !maxTimer) {
251
- maxTimer = setTimeout(() => {
252
- if (timer)
253
- clearTimeout(timer);
254
- maxTimer = null;
255
- invoke();
256
- }, maxDuration);
257
- }
258
- timer = setTimeout(() => {
259
- if (maxTimer)
260
- clearTimeout(maxTimer);
261
- maxTimer = null;
262
- invoke();
263
- }, duration);
264
- };
265
- return filter;
154
+
155
+ function get(obj, key) {
156
+ if (key == null)
157
+ return unref(obj);
158
+ return unref(obj)[key];
266
159
  }
267
- function throttleFilter(ms, trailing = true, leading = true) {
268
- let lastExec = 0;
269
- let timer;
270
- let preventLeading = !leading;
271
- const clear = () => {
272
- if (timer) {
273
- clearTimeout(timer);
274
- timer = void 0;
275
- }
276
- };
277
- const filter = (invoke) => {
278
- const duration = unref(ms);
279
- const elapsed = Date.now() - lastExec;
280
- clear();
281
- if (duration <= 0) {
282
- lastExec = Date.now();
283
- return invoke();
284
- }
285
- if (elapsed > duration) {
286
- lastExec = Date.now();
287
- if (preventLeading)
288
- preventLeading = false;
289
- else
290
- invoke();
291
- }
292
- if (trailing) {
293
- timer = setTimeout(() => {
294
- lastExec = Date.now();
295
- if (!leading)
296
- preventLeading = true;
297
- clear();
298
- invoke();
299
- }, duration);
300
- }
301
- if (!leading && !timer)
302
- timer = setTimeout(() => preventLeading = true, duration);
303
- };
304
- return filter;
160
+
161
+ function isDefined(v) {
162
+ return unref(v) != null;
305
163
  }
306
- function pausableFilter(extendFilter = bypassFilter) {
307
- const isActive = ref(true);
308
- function pause() {
309
- isActive.value = false;
310
- }
311
- function resume() {
312
- isActive.value = true;
313
- }
314
- const eventFilter = (...args) => {
315
- if (isActive.value)
316
- extendFilter(...args);
317
- };
318
- return { isActive, pause, resume, eventFilter };
164
+
165
+ function logicAnd(...args) {
166
+ return computed(() => args.every((i) => unref(i)));
319
167
  }
320
168
 
321
- function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
169
+ function logicNot(v) {
170
+ return computed(() => !unref(v));
171
+ }
172
+
173
+ function logicOr(...args) {
174
+ return computed(() => args.some((i) => unref(i)));
175
+ }
176
+
177
+ var __defProp$7 = Object.defineProperty;
178
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
179
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
180
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
181
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
182
+ var __spreadValues$7 = (a, b) => {
183
+ for (var prop in b || (b = {}))
184
+ if (__hasOwnProp$9.call(b, prop))
185
+ __defNormalProp$7(a, prop, b[prop]);
186
+ if (__getOwnPropSymbols$9)
187
+ for (var prop of __getOwnPropSymbols$9(b)) {
188
+ if (__propIsEnum$9.call(b, prop))
189
+ __defNormalProp$7(a, prop, b[prop]);
190
+ }
191
+ return a;
192
+ };
193
+ function makeDestructurable(obj, arr) {
194
+ if (typeof Symbol !== "undefined") {
195
+ const clone = __spreadValues$7({}, obj);
196
+ Object.defineProperty(clone, Symbol.iterator, {
197
+ enumerable: false,
198
+ value() {
199
+ let index = 0;
200
+ return {
201
+ next: () => ({
202
+ value: arr[index++],
203
+ done: index > arr.length
204
+ })
205
+ };
206
+ }
207
+ });
208
+ return clone;
209
+ } else {
210
+ return Object.assign([...arr], obj);
211
+ }
212
+ }
213
+
214
+ function reactify(fn) {
215
+ return function(...args) {
216
+ return computed(() => fn.apply(this, args.map((i) => unref(i))));
217
+ };
218
+ }
219
+
220
+ function reactifyObject(obj, optionsOrKeys = {}) {
221
+ let keys = [];
222
+ if (Array.isArray(optionsOrKeys)) {
223
+ keys = optionsOrKeys;
224
+ } else {
225
+ const { includeOwnProperties = true } = optionsOrKeys;
226
+ keys.push(...Object.keys(obj));
227
+ if (includeOwnProperties)
228
+ keys.push(...Object.getOwnPropertyNames(obj));
229
+ }
230
+ return Object.fromEntries(keys.map((key) => {
231
+ const value = obj[key];
232
+ return [
233
+ key,
234
+ typeof value === "function" ? reactify(value.bind(obj)) : value
235
+ ];
236
+ }));
237
+ }
238
+
239
+ function toReactive(objectRef) {
240
+ if (!isRef(objectRef))
241
+ return reactive(objectRef);
242
+ const proxy = new Proxy({}, {
243
+ get(_, p, receiver) {
244
+ return unref(Reflect.get(objectRef.value, p, receiver));
245
+ },
246
+ set(_, p, value) {
247
+ if (isRef(objectRef.value[p]) && !isRef(value))
248
+ objectRef.value[p].value = value;
249
+ else
250
+ objectRef.value[p] = value;
251
+ return true;
252
+ },
253
+ deleteProperty(_, p) {
254
+ return Reflect.deleteProperty(objectRef.value, p);
255
+ },
256
+ has(_, p) {
257
+ return Reflect.has(objectRef.value, p);
258
+ },
259
+ ownKeys() {
260
+ return Object.keys(objectRef.value);
261
+ },
262
+ getOwnPropertyDescriptor() {
263
+ return {
264
+ enumerable: true,
265
+ configurable: true
266
+ };
267
+ }
268
+ });
269
+ return reactive(proxy);
270
+ }
271
+
272
+ function reactiveComputed(fn) {
273
+ return toReactive(computed(fn));
274
+ }
275
+
276
+ function reactiveOmit(obj, ...keys) {
277
+ return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !keys.includes(e[0]))));
278
+ }
279
+
280
+ function reactivePick(obj, ...keys) {
281
+ return reactive(Object.fromEntries(keys.map((k) => [k, toRef(obj, k)])));
282
+ }
283
+
284
+ function refAutoReset(defaultValue, afterMs = 1e4) {
285
+ return customRef((track, trigger) => {
286
+ let value = defaultValue;
287
+ let timer;
288
+ const resetAfter = () => setTimeout(() => {
289
+ value = defaultValue;
290
+ trigger();
291
+ }, unref(afterMs));
292
+ return {
293
+ get() {
294
+ track();
295
+ return value;
296
+ },
297
+ set(newValue) {
298
+ value = newValue;
299
+ trigger();
300
+ clearTimeout(timer);
301
+ timer = resetAfter();
302
+ }
303
+ };
304
+ });
305
+ }
306
+
307
+ const isClient = typeof window !== "undefined";
308
+ const isDef = (val) => typeof val !== "undefined";
309
+ const assert = (condition, ...infos) => {
310
+ if (!condition)
311
+ console.warn(...infos);
312
+ };
313
+ const toString = Object.prototype.toString;
314
+ const isBoolean = (val) => typeof val === "boolean";
315
+ const isFunction = (val) => typeof val === "function";
316
+ const isNumber = (val) => typeof val === "number";
317
+ const isString = (val) => typeof val === "string";
318
+ const isObject = (val) => toString.call(val) === "[object Object]";
319
+ const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
320
+ const now = () => Date.now();
321
+ const timestamp = () => +Date.now();
322
+ const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
323
+ const noop = () => {
324
+ };
325
+ const rand = (min, max) => {
326
+ min = Math.ceil(min);
327
+ max = Math.floor(max);
328
+ return Math.floor(Math.random() * (max - min + 1)) + min;
329
+ };
330
+
331
+ function createFilterWrapper(filter, fn) {
332
+ function wrapper(...args) {
333
+ filter(() => fn.apply(this, args), { fn, thisArg: this, args });
334
+ }
335
+ return wrapper;
336
+ }
337
+ const bypassFilter = (invoke) => {
338
+ return invoke();
339
+ };
340
+ function debounceFilter(ms, options = {}) {
341
+ let timer;
342
+ let maxTimer;
343
+ const filter = (invoke) => {
344
+ const duration = unref(ms);
345
+ const maxDuration = unref(options.maxWait);
346
+ if (timer)
347
+ clearTimeout(timer);
348
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
349
+ if (maxTimer) {
350
+ clearTimeout(maxTimer);
351
+ maxTimer = null;
352
+ }
353
+ return invoke();
354
+ }
355
+ if (maxDuration && !maxTimer) {
356
+ maxTimer = setTimeout(() => {
357
+ if (timer)
358
+ clearTimeout(timer);
359
+ maxTimer = null;
360
+ invoke();
361
+ }, maxDuration);
362
+ }
363
+ timer = setTimeout(() => {
364
+ if (maxTimer)
365
+ clearTimeout(maxTimer);
366
+ maxTimer = null;
367
+ invoke();
368
+ }, duration);
369
+ };
370
+ return filter;
371
+ }
372
+ function throttleFilter(ms, trailing = true, leading = true) {
373
+ let lastExec = 0;
374
+ let timer;
375
+ let preventLeading = !leading;
376
+ const clear = () => {
377
+ if (timer) {
378
+ clearTimeout(timer);
379
+ timer = void 0;
380
+ }
381
+ };
382
+ const filter = (invoke) => {
383
+ const duration = unref(ms);
384
+ const elapsed = Date.now() - lastExec;
385
+ clear();
386
+ if (duration <= 0) {
387
+ lastExec = Date.now();
388
+ return invoke();
389
+ }
390
+ if (elapsed > duration) {
391
+ lastExec = Date.now();
392
+ if (preventLeading)
393
+ preventLeading = false;
394
+ else
395
+ invoke();
396
+ }
397
+ if (trailing) {
398
+ timer = setTimeout(() => {
399
+ lastExec = Date.now();
400
+ if (!leading)
401
+ preventLeading = true;
402
+ clear();
403
+ invoke();
404
+ }, duration);
405
+ }
406
+ if (!leading && !timer)
407
+ timer = setTimeout(() => preventLeading = true, duration);
408
+ };
409
+ return filter;
410
+ }
411
+ function pausableFilter(extendFilter = bypassFilter) {
412
+ const isActive = ref(true);
413
+ function pause() {
414
+ isActive.value = false;
415
+ }
416
+ function resume() {
417
+ isActive.value = true;
418
+ }
419
+ const eventFilter = (...args) => {
420
+ if (isActive.value)
421
+ extendFilter(...args);
422
+ };
423
+ return { isActive, pause, resume, eventFilter };
424
+ }
425
+
426
+ function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
322
427
  return new Promise((resolve, reject) => {
323
428
  if (throwOnTimeout)
324
429
  setTimeout(() => reject(reason), ms);
@@ -375,7 +480,7 @@ function useDebounceFn(fn, ms = 200, options = {}) {
375
480
  return createFilterWrapper(debounceFilter(ms, options), fn);
376
481
  }
377
482
 
378
- function useDebounce(value, ms = 200, options = {}) {
483
+ function refDebounced(value, ms = 200, options = {}) {
379
484
  if (ms <= 0)
380
485
  return value;
381
486
  const debounced = ref(value.value);
@@ -386,349 +491,6 @@ function useDebounce(value, ms = 200, options = {}) {
386
491
  return debounced;
387
492
  }
388
493
 
389
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
390
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
391
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
392
- var __objRest$5 = (source, exclude) => {
393
- var target = {};
394
- for (var prop in source)
395
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
396
- target[prop] = source[prop];
397
- if (source != null && __getOwnPropSymbols$a)
398
- for (var prop of __getOwnPropSymbols$a(source)) {
399
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
400
- target[prop] = source[prop];
401
- }
402
- return target;
403
- };
404
- function watchWithFilter(source, cb, options = {}) {
405
- const _a = options, {
406
- eventFilter = bypassFilter
407
- } = _a, watchOptions = __objRest$5(_a, [
408
- "eventFilter"
409
- ]);
410
- return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
411
- }
412
-
413
- var __defProp$8 = Object.defineProperty;
414
- var __defProps$5 = Object.defineProperties;
415
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
416
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
417
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
418
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
419
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
420
- var __spreadValues$8 = (a, b) => {
421
- for (var prop in b || (b = {}))
422
- if (__hasOwnProp$9.call(b, prop))
423
- __defNormalProp$8(a, prop, b[prop]);
424
- if (__getOwnPropSymbols$9)
425
- for (var prop of __getOwnPropSymbols$9(b)) {
426
- if (__propIsEnum$9.call(b, prop))
427
- __defNormalProp$8(a, prop, b[prop]);
428
- }
429
- return a;
430
- };
431
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
432
- var __objRest$4 = (source, exclude) => {
433
- var target = {};
434
- for (var prop in source)
435
- if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
436
- target[prop] = source[prop];
437
- if (source != null && __getOwnPropSymbols$9)
438
- for (var prop of __getOwnPropSymbols$9(source)) {
439
- if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
440
- target[prop] = source[prop];
441
- }
442
- return target;
443
- };
444
- function debouncedWatch(source, cb, options = {}) {
445
- const _a = options, {
446
- debounce = 0
447
- } = _a, watchOptions = __objRest$4(_a, [
448
- "debounce"
449
- ]);
450
- return watchWithFilter(source, cb, __spreadProps$5(__spreadValues$8({}, watchOptions), {
451
- eventFilter: debounceFilter(debounce)
452
- }));
453
- }
454
-
455
- var __defProp$7 = Object.defineProperty;
456
- var __defProps$4 = Object.defineProperties;
457
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
458
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
459
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
460
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
461
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
462
- var __spreadValues$7 = (a, b) => {
463
- for (var prop in b || (b = {}))
464
- if (__hasOwnProp$8.call(b, prop))
465
- __defNormalProp$7(a, prop, b[prop]);
466
- if (__getOwnPropSymbols$8)
467
- for (var prop of __getOwnPropSymbols$8(b)) {
468
- if (__propIsEnum$8.call(b, prop))
469
- __defNormalProp$7(a, prop, b[prop]);
470
- }
471
- return a;
472
- };
473
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
474
- function eagerComputed(fn, options) {
475
- var _a;
476
- const result = shallowRef();
477
- watchEffect(() => {
478
- result.value = fn();
479
- }, __spreadProps$4(__spreadValues$7({}, options), {
480
- flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
481
- }));
482
- return readonly(result);
483
- }
484
-
485
- function get(obj, key) {
486
- if (key == null)
487
- return unref(obj);
488
- return unref(obj)[key];
489
- }
490
-
491
- var __defProp$6 = Object.defineProperty;
492
- var __defProps$3 = Object.defineProperties;
493
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
494
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
495
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
496
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
497
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
498
- var __spreadValues$6 = (a, b) => {
499
- for (var prop in b || (b = {}))
500
- if (__hasOwnProp$7.call(b, prop))
501
- __defNormalProp$6(a, prop, b[prop]);
502
- if (__getOwnPropSymbols$7)
503
- for (var prop of __getOwnPropSymbols$7(b)) {
504
- if (__propIsEnum$7.call(b, prop))
505
- __defNormalProp$6(a, prop, b[prop]);
506
- }
507
- return a;
508
- };
509
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
510
- var __objRest$3 = (source, exclude) => {
511
- var target = {};
512
- for (var prop in source)
513
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
514
- target[prop] = source[prop];
515
- if (source != null && __getOwnPropSymbols$7)
516
- for (var prop of __getOwnPropSymbols$7(source)) {
517
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
518
- target[prop] = source[prop];
519
- }
520
- return target;
521
- };
522
- function ignorableWatch(source, cb, options = {}) {
523
- const _a = options, {
524
- eventFilter = bypassFilter
525
- } = _a, watchOptions = __objRest$3(_a, [
526
- "eventFilter"
527
- ]);
528
- const filteredCb = createFilterWrapper(eventFilter, cb);
529
- let ignoreUpdates;
530
- let ignorePrevAsyncUpdates;
531
- let stop;
532
- if (watchOptions.flush === "sync") {
533
- const ignore = ref(false);
534
- ignorePrevAsyncUpdates = () => {
535
- };
536
- ignoreUpdates = (updater) => {
537
- ignore.value = true;
538
- updater();
539
- ignore.value = false;
540
- };
541
- stop = watch(source, (...args) => {
542
- if (!ignore.value)
543
- filteredCb(...args);
544
- }, watchOptions);
545
- } else {
546
- const disposables = [];
547
- const ignoreCounter = ref(0);
548
- const syncCounter = ref(0);
549
- ignorePrevAsyncUpdates = () => {
550
- ignoreCounter.value = syncCounter.value;
551
- };
552
- disposables.push(watch(source, () => {
553
- syncCounter.value++;
554
- }, __spreadProps$3(__spreadValues$6({}, watchOptions), { flush: "sync" })));
555
- ignoreUpdates = (updater) => {
556
- const syncCounterPrev = syncCounter.value;
557
- updater();
558
- ignoreCounter.value += syncCounter.value - syncCounterPrev;
559
- };
560
- disposables.push(watch(source, (...args) => {
561
- const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
562
- ignoreCounter.value = 0;
563
- syncCounter.value = 0;
564
- if (ignore)
565
- return;
566
- filteredCb(...args);
567
- }, watchOptions));
568
- stop = () => {
569
- disposables.forEach((fn) => fn());
570
- };
571
- }
572
- return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
573
- }
574
-
575
- function isDefined(v) {
576
- return unref(v) != null;
577
- }
578
-
579
- var __defProp$5 = Object.defineProperty;
580
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
581
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
582
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
583
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
584
- var __spreadValues$5 = (a, b) => {
585
- for (var prop in b || (b = {}))
586
- if (__hasOwnProp$6.call(b, prop))
587
- __defNormalProp$5(a, prop, b[prop]);
588
- if (__getOwnPropSymbols$6)
589
- for (var prop of __getOwnPropSymbols$6(b)) {
590
- if (__propIsEnum$6.call(b, prop))
591
- __defNormalProp$5(a, prop, b[prop]);
592
- }
593
- return a;
594
- };
595
- function makeDestructurable(obj, arr) {
596
- if (typeof Symbol !== "undefined") {
597
- const clone = __spreadValues$5({}, obj);
598
- Object.defineProperty(clone, Symbol.iterator, {
599
- enumerable: false,
600
- value() {
601
- let index = 0;
602
- return {
603
- next: () => ({
604
- value: arr[index++],
605
- done: index > arr.length
606
- })
607
- };
608
- }
609
- });
610
- return clone;
611
- } else {
612
- return Object.assign([...arr], obj);
613
- }
614
- }
615
-
616
- function not(v) {
617
- return computed(() => !unref(v));
618
- }
619
-
620
- function or(...args) {
621
- return computed(() => args.some((i) => unref(i)));
622
- }
623
-
624
- var __defProp$4 = Object.defineProperty;
625
- var __defProps$2 = Object.defineProperties;
626
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
627
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
628
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
629
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
630
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
631
- var __spreadValues$4 = (a, b) => {
632
- for (var prop in b || (b = {}))
633
- if (__hasOwnProp$5.call(b, prop))
634
- __defNormalProp$4(a, prop, b[prop]);
635
- if (__getOwnPropSymbols$5)
636
- for (var prop of __getOwnPropSymbols$5(b)) {
637
- if (__propIsEnum$5.call(b, prop))
638
- __defNormalProp$4(a, prop, b[prop]);
639
- }
640
- return a;
641
- };
642
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
643
- var __objRest$2 = (source, exclude) => {
644
- var target = {};
645
- for (var prop in source)
646
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
647
- target[prop] = source[prop];
648
- if (source != null && __getOwnPropSymbols$5)
649
- for (var prop of __getOwnPropSymbols$5(source)) {
650
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
651
- target[prop] = source[prop];
652
- }
653
- return target;
654
- };
655
- function pausableWatch(source, cb, options = {}) {
656
- const _a = options, {
657
- eventFilter: filter
658
- } = _a, watchOptions = __objRest$2(_a, [
659
- "eventFilter"
660
- ]);
661
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
662
- const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$4({}, watchOptions), {
663
- eventFilter
664
- }));
665
- return { stop, pause, resume, isActive };
666
- }
667
-
668
- function reactifyObject(obj, optionsOrKeys = {}) {
669
- let keys = [];
670
- if (Array.isArray(optionsOrKeys)) {
671
- keys = optionsOrKeys;
672
- } else {
673
- const { includeOwnProperties = true } = optionsOrKeys;
674
- keys.push(...Object.keys(obj));
675
- if (includeOwnProperties)
676
- keys.push(...Object.getOwnPropertyNames(obj));
677
- }
678
- return Object.fromEntries(keys.map((key) => {
679
- const value = obj[key];
680
- return [
681
- key,
682
- typeof value === "function" ? reactify(value.bind(obj)) : value
683
- ];
684
- }));
685
- }
686
-
687
- function toReactive(objectRef) {
688
- if (!isRef(objectRef))
689
- return reactive(objectRef);
690
- const proxy = new Proxy({}, {
691
- get(_, p, receiver) {
692
- return unref(Reflect.get(objectRef.value, p, receiver));
693
- },
694
- set(_, p, value) {
695
- if (isRef(objectRef.value[p]) && !isRef(value))
696
- objectRef.value[p].value = value;
697
- else
698
- objectRef.value[p] = value;
699
- return true;
700
- },
701
- deleteProperty(_, p) {
702
- return Reflect.deleteProperty(objectRef.value, p);
703
- },
704
- has(_, p) {
705
- return Reflect.has(objectRef.value, p);
706
- },
707
- ownKeys() {
708
- return Object.keys(objectRef.value);
709
- },
710
- getOwnPropertyDescriptor() {
711
- return {
712
- enumerable: true,
713
- configurable: true
714
- };
715
- }
716
- });
717
- return reactive(proxy);
718
- }
719
-
720
- function reactiveComputed(fn) {
721
- return toReactive(computed(fn));
722
- }
723
-
724
- function reactiveOmit(obj, ...keys) {
725
- return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !keys.includes(e[0]))));
726
- }
727
-
728
- function reactivePick(obj, ...keys) {
729
- return reactive(Object.fromEntries(keys.map((k) => [k, toRef(obj, k)])));
730
- }
731
-
732
494
  function refDefault(source, defaultValue) {
733
495
  return computed({
734
496
  get() {
@@ -741,6 +503,69 @@ function refDefault(source, defaultValue) {
741
503
  });
742
504
  }
743
505
 
506
+ function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
507
+ return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
508
+ }
509
+
510
+ function refThrottled(value, delay = 200, trailing = true, leading = true) {
511
+ if (delay <= 0)
512
+ return value;
513
+ const throttled = ref(value.value);
514
+ const updater = useThrottleFn(() => {
515
+ throttled.value = value.value;
516
+ }, delay, trailing, leading);
517
+ watch(value, () => updater());
518
+ return throttled;
519
+ }
520
+
521
+ function refWithControl(initial, options = {}) {
522
+ let source = initial;
523
+ let track;
524
+ let trigger;
525
+ const ref = customRef((_track, _trigger) => {
526
+ track = _track;
527
+ trigger = _trigger;
528
+ return {
529
+ get() {
530
+ return get();
531
+ },
532
+ set(v) {
533
+ set(v);
534
+ }
535
+ };
536
+ });
537
+ function get(tracking = true) {
538
+ if (tracking)
539
+ track();
540
+ return source;
541
+ }
542
+ function set(value, triggering = true) {
543
+ var _a, _b;
544
+ if (value === source)
545
+ return;
546
+ const old = source;
547
+ if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
548
+ return;
549
+ source = value;
550
+ (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
551
+ if (triggering)
552
+ trigger();
553
+ }
554
+ const untrackedGet = () => get(false);
555
+ const silentSet = (v) => set(v, false);
556
+ const peek = () => get(false);
557
+ const lay = (v) => set(v, false);
558
+ return extendRef(ref, {
559
+ get,
560
+ set,
561
+ untrackedGet,
562
+ silentSet,
563
+ peek,
564
+ lay
565
+ }, { enumerable: true });
566
+ }
567
+ const controlledRef = refWithControl;
568
+
744
569
  function set(...args) {
745
570
  if (args.length === 2) {
746
571
  const [ref, value] = args;
@@ -756,96 +581,56 @@ function set(...args) {
756
581
  }
757
582
  }
758
583
 
759
- function syncRef(source, targets, {
760
- flush = "sync",
761
- deep = false,
762
- immediate = true
763
- } = {}) {
584
+ function syncRef(left, right, options = {}) {
585
+ const {
586
+ flush = "sync",
587
+ deep = false,
588
+ immediate = true,
589
+ direction = "both"
590
+ } = options;
591
+ let stop1, stop2;
592
+ if (direction === "both" || direction === "ltr") {
593
+ stop1 = watch(left, (newValue) => right.value = newValue, { flush, deep, immediate });
594
+ }
595
+ if (direction === "both" || direction === "rtl") {
596
+ stop2 = watch(right, (newValue) => left.value = newValue, { flush, deep, immediate });
597
+ }
598
+ return () => {
599
+ stop1 == null ? void 0 : stop1();
600
+ stop2 == null ? void 0 : stop2();
601
+ };
602
+ }
603
+
604
+ function syncRefs(source, targets, options = {}) {
605
+ const {
606
+ flush = "sync",
607
+ deep = false,
608
+ immediate = true
609
+ } = options;
764
610
  if (!Array.isArray(targets))
765
611
  targets = [targets];
766
612
  return watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
767
613
  }
768
614
 
769
- function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
770
- return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
771
- }
772
-
773
- function useThrottle(value, delay = 200, trailing = true, leading = true) {
774
- if (delay <= 0)
775
- return value;
776
- const throttled = ref(value.value);
777
- const updater = useThrottleFn(() => {
778
- throttled.value = value.value;
779
- }, delay, trailing, leading);
780
- watch(value, () => updater());
781
- return throttled;
782
- }
783
-
784
- var __defProp$3 = Object.defineProperty;
785
- var __defProps$1 = Object.defineProperties;
786
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
787
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
788
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
789
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
790
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
791
- var __spreadValues$3 = (a, b) => {
792
- for (var prop in b || (b = {}))
793
- if (__hasOwnProp$4.call(b, prop))
794
- __defNormalProp$3(a, prop, b[prop]);
795
- if (__getOwnPropSymbols$4)
796
- for (var prop of __getOwnPropSymbols$4(b)) {
797
- if (__propIsEnum$4.call(b, prop))
798
- __defNormalProp$3(a, prop, b[prop]);
799
- }
800
- return a;
801
- };
802
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
803
- var __objRest$1 = (source, exclude) => {
804
- var target = {};
805
- for (var prop in source)
806
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
807
- target[prop] = source[prop];
808
- if (source != null && __getOwnPropSymbols$4)
809
- for (var prop of __getOwnPropSymbols$4(source)) {
810
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
811
- target[prop] = source[prop];
812
- }
813
- return target;
814
- };
815
- function throttledWatch(source, cb, options = {}) {
816
- const _a = options, {
817
- throttle = 0,
818
- trailing = true,
819
- leading = true
820
- } = _a, watchOptions = __objRest$1(_a, [
821
- "throttle",
822
- "trailing",
823
- "leading"
824
- ]);
825
- return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$3({}, watchOptions), {
826
- eventFilter: throttleFilter(throttle, trailing, leading)
827
- }));
828
- }
829
-
830
- var __defProp$2 = Object.defineProperty;
831
- var __defProps = Object.defineProperties;
832
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
833
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
834
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
835
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
836
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
837
- var __spreadValues$2 = (a, b) => {
615
+ var __defProp$6 = Object.defineProperty;
616
+ var __defProps$4 = Object.defineProperties;
617
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
618
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
619
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
620
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
621
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
622
+ var __spreadValues$6 = (a, b) => {
838
623
  for (var prop in b || (b = {}))
839
- if (__hasOwnProp$3.call(b, prop))
840
- __defNormalProp$2(a, prop, b[prop]);
841
- if (__getOwnPropSymbols$3)
842
- for (var prop of __getOwnPropSymbols$3(b)) {
843
- if (__propIsEnum$3.call(b, prop))
844
- __defNormalProp$2(a, prop, b[prop]);
624
+ if (__hasOwnProp$8.call(b, prop))
625
+ __defNormalProp$6(a, prop, b[prop]);
626
+ if (__getOwnPropSymbols$8)
627
+ for (var prop of __getOwnPropSymbols$8(b)) {
628
+ if (__propIsEnum$8.call(b, prop))
629
+ __defNormalProp$6(a, prop, b[prop]);
845
630
  }
846
631
  return a;
847
632
  };
848
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
633
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
849
634
  function toRefs(objectRef) {
850
635
  if (!isRef(objectRef))
851
636
  return toRefs$1(objectRef);
@@ -861,7 +646,7 @@ function toRefs(objectRef) {
861
646
  copy[key] = v;
862
647
  objectRef.value = copy;
863
648
  } else {
864
- objectRef.value = __spreadProps(__spreadValues$2({}, objectRef.value), { [key]: v });
649
+ objectRef.value = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
865
650
  }
866
651
  }
867
652
  }));
@@ -991,6 +776,56 @@ function useCounter(initialValue = 0, options = {}) {
991
776
  return { count, inc, dec, get, set, reset };
992
777
  }
993
778
 
779
+ const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
780
+ const REGEX_FORMAT = /\[([^\]]+)]|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;
781
+ const formatDate = (date, formatStr) => {
782
+ const years = date.getFullYear();
783
+ const month = date.getMonth();
784
+ const days = date.getDate();
785
+ const hours = date.getHours();
786
+ const minutes = date.getMinutes();
787
+ const seconds = date.getSeconds();
788
+ const milliseconds = date.getMilliseconds();
789
+ const matches = {
790
+ YY: String(years).slice(-2),
791
+ YYYY: years,
792
+ M: month + 1,
793
+ MM: `${month + 1}`.padStart(2, "0"),
794
+ D: String(days),
795
+ DD: `${days}`.padStart(2, "0"),
796
+ H: String(hours),
797
+ HH: `${hours}`.padStart(2, "0"),
798
+ h: `${hours % 12 || 12}`.padStart(1, "0"),
799
+ hh: `${hours % 12 || 12}`.padStart(2, "0"),
800
+ m: String(minutes),
801
+ mm: `${minutes}`.padStart(2, "0"),
802
+ s: String(seconds),
803
+ ss: `${seconds}`.padStart(2, "0"),
804
+ SSS: `${milliseconds}`.padStart(3, "0")
805
+ };
806
+ return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match]);
807
+ };
808
+ const normalizeDate = (date) => {
809
+ if (date === null)
810
+ return new Date(NaN);
811
+ if (date === void 0)
812
+ return new Date();
813
+ if (date instanceof Date)
814
+ return new Date(date);
815
+ if (typeof date === "string" && !/Z$/i.test(date)) {
816
+ const d = date.match(REGEX_PARSE);
817
+ if (d) {
818
+ const m = d[2] - 1 || 0;
819
+ const ms = (d[7] || "0").substring(0, 3);
820
+ return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
821
+ }
822
+ }
823
+ return new Date(date);
824
+ };
825
+ function useDateFormat(date, formatStr = "HH:mm:ss") {
826
+ return computed(() => formatDate(normalizeDate(unref(date)), unref(formatStr)));
827
+ }
828
+
994
829
  function useIntervalFn(cb, interval = 1e3, options = {}) {
995
830
  const {
996
831
  immediate = true,
@@ -1034,19 +869,19 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1034
869
  };
1035
870
  }
1036
871
 
1037
- var __defProp$1 = Object.defineProperty;
1038
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1039
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1040
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1041
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1042
- var __spreadValues$1 = (a, b) => {
872
+ var __defProp$5 = Object.defineProperty;
873
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
874
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
875
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
876
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
877
+ var __spreadValues$5 = (a, b) => {
1043
878
  for (var prop in b || (b = {}))
1044
- if (__hasOwnProp$2.call(b, prop))
1045
- __defNormalProp$1(a, prop, b[prop]);
1046
- if (__getOwnPropSymbols$2)
1047
- for (var prop of __getOwnPropSymbols$2(b)) {
1048
- if (__propIsEnum$2.call(b, prop))
1049
- __defNormalProp$1(a, prop, b[prop]);
879
+ if (__hasOwnProp$7.call(b, prop))
880
+ __defNormalProp$5(a, prop, b[prop]);
881
+ if (__getOwnPropSymbols$7)
882
+ for (var prop of __getOwnPropSymbols$7(b)) {
883
+ if (__propIsEnum$7.call(b, prop))
884
+ __defNormalProp$5(a, prop, b[prop]);
1050
885
  }
1051
886
  return a;
1052
887
  };
@@ -1058,7 +893,7 @@ function useInterval(interval = 1e3, options = {}) {
1058
893
  const counter = ref(0);
1059
894
  const controls = useIntervalFn(() => counter.value += 1, interval, { immediate });
1060
895
  if (exposeControls) {
1061
- return __spreadValues$1({
896
+ return __spreadValues$5({
1062
897
  counter
1063
898
  }, controls);
1064
899
  } else {
@@ -1107,23 +942,23 @@ function useTimeoutFn(cb, interval, options = {}) {
1107
942
  return {
1108
943
  isPending,
1109
944
  start,
1110
- stop
1111
- };
1112
- }
1113
-
1114
- var __defProp = Object.defineProperty;
1115
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1116
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1117
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1118
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1119
- var __spreadValues = (a, b) => {
945
+ stop
946
+ };
947
+ }
948
+
949
+ var __defProp$4 = Object.defineProperty;
950
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
951
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
952
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
953
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
954
+ var __spreadValues$4 = (a, b) => {
1120
955
  for (var prop in b || (b = {}))
1121
- if (__hasOwnProp$1.call(b, prop))
1122
- __defNormalProp(a, prop, b[prop]);
1123
- if (__getOwnPropSymbols$1)
1124
- for (var prop of __getOwnPropSymbols$1(b)) {
1125
- if (__propIsEnum$1.call(b, prop))
1126
- __defNormalProp(a, prop, b[prop]);
956
+ if (__hasOwnProp$6.call(b, prop))
957
+ __defNormalProp$4(a, prop, b[prop]);
958
+ if (__getOwnPropSymbols$6)
959
+ for (var prop of __getOwnPropSymbols$6(b)) {
960
+ if (__propIsEnum$6.call(b, prop))
961
+ __defNormalProp$4(a, prop, b[prop]);
1127
962
  }
1128
963
  return a;
1129
964
  };
@@ -1134,7 +969,7 @@ function useTimeout(interval = 1e3, options = {}) {
1134
969
  const controls = useTimeoutFn(noop, interval, options);
1135
970
  const ready = computed(() => !controls.isPending.value);
1136
971
  if (exposeControls) {
1137
- return __spreadValues({
972
+ return __spreadValues$4({
1138
973
  ready
1139
974
  }, controls);
1140
975
  } else {
@@ -1158,17 +993,41 @@ function useToggle(initialValue = false) {
1158
993
  }
1159
994
  }
1160
995
 
1161
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1162
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1163
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1164
- var __objRest = (source, exclude) => {
996
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
997
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
998
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
999
+ var __objRest$5 = (source, exclude) => {
1165
1000
  var target = {};
1166
1001
  for (var prop in source)
1167
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1002
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1168
1003
  target[prop] = source[prop];
1169
- if (source != null && __getOwnPropSymbols)
1170
- for (var prop of __getOwnPropSymbols(source)) {
1171
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1004
+ if (source != null && __getOwnPropSymbols$5)
1005
+ for (var prop of __getOwnPropSymbols$5(source)) {
1006
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1007
+ target[prop] = source[prop];
1008
+ }
1009
+ return target;
1010
+ };
1011
+ function watchWithFilter(source, cb, options = {}) {
1012
+ const _a = options, {
1013
+ eventFilter = bypassFilter
1014
+ } = _a, watchOptions = __objRest$5(_a, [
1015
+ "eventFilter"
1016
+ ]);
1017
+ return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
1018
+ }
1019
+
1020
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1021
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1022
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1023
+ var __objRest$4 = (source, exclude) => {
1024
+ var target = {};
1025
+ for (var prop in source)
1026
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1027
+ target[prop] = source[prop];
1028
+ if (source != null && __getOwnPropSymbols$4)
1029
+ for (var prop of __getOwnPropSymbols$4(source)) {
1030
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1172
1031
  target[prop] = source[prop];
1173
1032
  }
1174
1033
  return target;
@@ -1176,7 +1035,7 @@ var __objRest = (source, exclude) => {
1176
1035
  function watchAtMost(source, cb, options) {
1177
1036
  const _a = options, {
1178
1037
  count
1179
- } = _a, watchOptions = __objRest(_a, [
1038
+ } = _a, watchOptions = __objRest$4(_a, [
1180
1039
  "count"
1181
1040
  ]);
1182
1041
  const current = ref(0);
@@ -1189,6 +1048,132 @@ function watchAtMost(source, cb, options) {
1189
1048
  return { count: current, stop };
1190
1049
  }
1191
1050
 
1051
+ var __defProp$3 = Object.defineProperty;
1052
+ var __defProps$3 = Object.defineProperties;
1053
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1054
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1055
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1056
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1057
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1058
+ var __spreadValues$3 = (a, b) => {
1059
+ for (var prop in b || (b = {}))
1060
+ if (__hasOwnProp$3.call(b, prop))
1061
+ __defNormalProp$3(a, prop, b[prop]);
1062
+ if (__getOwnPropSymbols$3)
1063
+ for (var prop of __getOwnPropSymbols$3(b)) {
1064
+ if (__propIsEnum$3.call(b, prop))
1065
+ __defNormalProp$3(a, prop, b[prop]);
1066
+ }
1067
+ return a;
1068
+ };
1069
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1070
+ var __objRest$3 = (source, exclude) => {
1071
+ var target = {};
1072
+ for (var prop in source)
1073
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1074
+ target[prop] = source[prop];
1075
+ if (source != null && __getOwnPropSymbols$3)
1076
+ for (var prop of __getOwnPropSymbols$3(source)) {
1077
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1078
+ target[prop] = source[prop];
1079
+ }
1080
+ return target;
1081
+ };
1082
+ function watchDebounced(source, cb, options = {}) {
1083
+ const _a = options, {
1084
+ debounce = 0
1085
+ } = _a, watchOptions = __objRest$3(_a, [
1086
+ "debounce"
1087
+ ]);
1088
+ return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$3({}, watchOptions), {
1089
+ eventFilter: debounceFilter(debounce)
1090
+ }));
1091
+ }
1092
+
1093
+ var __defProp$2 = Object.defineProperty;
1094
+ var __defProps$2 = Object.defineProperties;
1095
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1096
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1097
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1098
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1099
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1100
+ var __spreadValues$2 = (a, b) => {
1101
+ for (var prop in b || (b = {}))
1102
+ if (__hasOwnProp$2.call(b, prop))
1103
+ __defNormalProp$2(a, prop, b[prop]);
1104
+ if (__getOwnPropSymbols$2)
1105
+ for (var prop of __getOwnPropSymbols$2(b)) {
1106
+ if (__propIsEnum$2.call(b, prop))
1107
+ __defNormalProp$2(a, prop, b[prop]);
1108
+ }
1109
+ return a;
1110
+ };
1111
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1112
+ var __objRest$2 = (source, exclude) => {
1113
+ var target = {};
1114
+ for (var prop in source)
1115
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1116
+ target[prop] = source[prop];
1117
+ if (source != null && __getOwnPropSymbols$2)
1118
+ for (var prop of __getOwnPropSymbols$2(source)) {
1119
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1120
+ target[prop] = source[prop];
1121
+ }
1122
+ return target;
1123
+ };
1124
+ function watchIgnorable(source, cb, options = {}) {
1125
+ const _a = options, {
1126
+ eventFilter = bypassFilter
1127
+ } = _a, watchOptions = __objRest$2(_a, [
1128
+ "eventFilter"
1129
+ ]);
1130
+ const filteredCb = createFilterWrapper(eventFilter, cb);
1131
+ let ignoreUpdates;
1132
+ let ignorePrevAsyncUpdates;
1133
+ let stop;
1134
+ if (watchOptions.flush === "sync") {
1135
+ const ignore = ref(false);
1136
+ ignorePrevAsyncUpdates = () => {
1137
+ };
1138
+ ignoreUpdates = (updater) => {
1139
+ ignore.value = true;
1140
+ updater();
1141
+ ignore.value = false;
1142
+ };
1143
+ stop = watch(source, (...args) => {
1144
+ if (!ignore.value)
1145
+ filteredCb(...args);
1146
+ }, watchOptions);
1147
+ } else {
1148
+ const disposables = [];
1149
+ const ignoreCounter = ref(0);
1150
+ const syncCounter = ref(0);
1151
+ ignorePrevAsyncUpdates = () => {
1152
+ ignoreCounter.value = syncCounter.value;
1153
+ };
1154
+ disposables.push(watch(source, () => {
1155
+ syncCounter.value++;
1156
+ }, __spreadProps$2(__spreadValues$2({}, watchOptions), { flush: "sync" })));
1157
+ ignoreUpdates = (updater) => {
1158
+ const syncCounterPrev = syncCounter.value;
1159
+ updater();
1160
+ ignoreCounter.value += syncCounter.value - syncCounterPrev;
1161
+ };
1162
+ disposables.push(watch(source, (...args) => {
1163
+ const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
1164
+ ignoreCounter.value = 0;
1165
+ syncCounter.value = 0;
1166
+ if (ignore)
1167
+ return;
1168
+ filteredCb(...args);
1169
+ }, watchOptions));
1170
+ stop = () => {
1171
+ disposables.forEach((fn) => fn());
1172
+ };
1173
+ }
1174
+ return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1175
+ }
1176
+
1192
1177
  function watchOnce(source, cb, options) {
1193
1178
  const stop = watch(source, (...args) => {
1194
1179
  nextTick(() => stop());
@@ -1196,6 +1181,96 @@ function watchOnce(source, cb, options) {
1196
1181
  }, options);
1197
1182
  }
1198
1183
 
1184
+ var __defProp$1 = Object.defineProperty;
1185
+ var __defProps$1 = Object.defineProperties;
1186
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1187
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1188
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1189
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1190
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1191
+ var __spreadValues$1 = (a, b) => {
1192
+ for (var prop in b || (b = {}))
1193
+ if (__hasOwnProp$1.call(b, prop))
1194
+ __defNormalProp$1(a, prop, b[prop]);
1195
+ if (__getOwnPropSymbols$1)
1196
+ for (var prop of __getOwnPropSymbols$1(b)) {
1197
+ if (__propIsEnum$1.call(b, prop))
1198
+ __defNormalProp$1(a, prop, b[prop]);
1199
+ }
1200
+ return a;
1201
+ };
1202
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1203
+ var __objRest$1 = (source, exclude) => {
1204
+ var target = {};
1205
+ for (var prop in source)
1206
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1207
+ target[prop] = source[prop];
1208
+ if (source != null && __getOwnPropSymbols$1)
1209
+ for (var prop of __getOwnPropSymbols$1(source)) {
1210
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1211
+ target[prop] = source[prop];
1212
+ }
1213
+ return target;
1214
+ };
1215
+ function watchPausable(source, cb, options = {}) {
1216
+ const _a = options, {
1217
+ eventFilter: filter
1218
+ } = _a, watchOptions = __objRest$1(_a, [
1219
+ "eventFilter"
1220
+ ]);
1221
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1222
+ const stop = watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
1223
+ eventFilter
1224
+ }));
1225
+ return { stop, pause, resume, isActive };
1226
+ }
1227
+
1228
+ var __defProp = Object.defineProperty;
1229
+ var __defProps = Object.defineProperties;
1230
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1231
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1232
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1233
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1234
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1235
+ var __spreadValues = (a, b) => {
1236
+ for (var prop in b || (b = {}))
1237
+ if (__hasOwnProp.call(b, prop))
1238
+ __defNormalProp(a, prop, b[prop]);
1239
+ if (__getOwnPropSymbols)
1240
+ for (var prop of __getOwnPropSymbols(b)) {
1241
+ if (__propIsEnum.call(b, prop))
1242
+ __defNormalProp(a, prop, b[prop]);
1243
+ }
1244
+ return a;
1245
+ };
1246
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1247
+ var __objRest = (source, exclude) => {
1248
+ var target = {};
1249
+ for (var prop in source)
1250
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1251
+ target[prop] = source[prop];
1252
+ if (source != null && __getOwnPropSymbols)
1253
+ for (var prop of __getOwnPropSymbols(source)) {
1254
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1255
+ target[prop] = source[prop];
1256
+ }
1257
+ return target;
1258
+ };
1259
+ function watchThrottled(source, cb, options = {}) {
1260
+ const _a = options, {
1261
+ throttle = 0,
1262
+ trailing = true,
1263
+ leading = true
1264
+ } = _a, watchOptions = __objRest(_a, [
1265
+ "throttle",
1266
+ "trailing",
1267
+ "leading"
1268
+ ]);
1269
+ return watchWithFilter(source, cb, __spreadProps(__spreadValues({}, watchOptions), {
1270
+ eventFilter: throttleFilter(throttle, trailing, leading)
1271
+ }));
1272
+ }
1273
+
1199
1274
  function whenever(source, cb, options) {
1200
1275
  return watch(source, (v, ov, onInvalidate) => {
1201
1276
  if (v)
@@ -1203,4 +1278,4 @@ function whenever(source, cb, options) {
1203
1278
  }, options);
1204
1279
  }
1205
1280
 
1206
- export { and, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, useDebounce as debouncedRef, debouncedWatch, eagerComputed, extendRef, get, identity, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, not, now, objectPick, or, pausableFilter, pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refDefault, set, syncRef, throttleFilter, useThrottle as throttledRef, throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchOnce, watchWithFilter, whenever };
1281
+ export { logicAnd as and, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, logicAnd, logicNot, logicOr, makeDestructurable, noop, normalizeDate, logicNot as not, now, objectPick, logicOr as or, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchWithFilter, whenever };