@vueuse/shared 6.3.2 → 6.5.3

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
@@ -4,1102 +4,1103 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vueDemi = require('vue-demi');
6
6
 
7
- /**
8
- * `AND` conditions for refs.
9
- *
10
- * @see https://vueuse.org/and
11
- */
12
- function and(...args) {
13
- return vueDemi.computed(() => args.every(i => vueDemi.unref(i)));
7
+ function and(...args) {
8
+ return vueDemi.computed(() => args.every((i) => vueDemi.unref(i)));
14
9
  }
15
10
 
16
- /**
17
- * Two-way refs synchronization.
18
- *
19
- * @param a
20
- * @param b
21
- */
22
- function biSyncRef(a, b) {
23
- const flush = 'sync';
24
- const stop1 = vueDemi.watch(a, (newValue) => {
25
- b.value = newValue;
26
- }, {
27
- flush,
28
- immediate: true,
29
- });
30
- const stop2 = vueDemi.watch(b, (newValue) => {
31
- a.value = newValue;
32
- }, {
33
- flush,
34
- immediate: true,
35
- });
36
- return () => {
37
- stop1();
38
- stop2();
39
- };
11
+ function biSyncRef(a, b) {
12
+ const flush = "sync";
13
+ const stop1 = vueDemi.watch(a, (newValue) => {
14
+ b.value = newValue;
15
+ }, {
16
+ flush,
17
+ immediate: true
18
+ });
19
+ const stop2 = vueDemi.watch(b, (newValue) => {
20
+ a.value = newValue;
21
+ }, {
22
+ flush,
23
+ immediate: true
24
+ });
25
+ return () => {
26
+ stop1();
27
+ stop2();
28
+ };
40
29
  }
41
30
 
42
- /**
43
- * Explicitly define the deps of computed.
44
- *
45
- * @param source
46
- * @param fn
47
- */
48
- function controlledComputed(source, fn) {
49
- let v = undefined;
50
- let track;
51
- let trigger;
52
- const dirty = vueDemi.ref(true);
53
- vueDemi.watch(source, () => {
54
- dirty.value = true;
55
- trigger();
56
- }, { flush: 'sync' });
57
- return vueDemi.customRef((_track, _trigger) => {
58
- track = _track;
59
- trigger = _trigger;
60
- return {
61
- get() {
62
- if (dirty.value) {
63
- v = fn();
64
- dirty.value = false;
65
- }
66
- track();
67
- return v;
68
- },
69
- set() { },
70
- };
71
- });
31
+ function controlledComputed(source, fn) {
32
+ let v = void 0;
33
+ let track;
34
+ let trigger;
35
+ const dirty = vueDemi.ref(true);
36
+ vueDemi.watch(source, () => {
37
+ dirty.value = true;
38
+ trigger();
39
+ }, { flush: "sync" });
40
+ return vueDemi.customRef((_track, _trigger) => {
41
+ track = _track;
42
+ trigger = _trigger;
43
+ return {
44
+ get() {
45
+ if (dirty.value) {
46
+ v = fn();
47
+ dirty.value = false;
48
+ }
49
+ track();
50
+ return v;
51
+ },
52
+ set() {
53
+ }
54
+ };
55
+ });
72
56
  }
73
57
 
74
- function __onlyVue3(name = 'this function') {
75
- if (vueDemi.isVue3)
76
- return;
77
- throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
58
+ function __onlyVue3(name = "this function") {
59
+ if (vueDemi.isVue3)
60
+ return;
61
+ throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
78
62
  }
79
63
 
80
- // implementation
81
- function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
82
- __onlyVue3();
83
- for (const [key, value] of Object.entries(extend)) {
84
- if (key === 'value')
85
- continue;
86
- if (vueDemi.isRef(value) && unwrap) {
87
- Object.defineProperty(ref, key, {
88
- get() {
89
- return value.value;
90
- },
91
- set(v) {
92
- value.value = v;
93
- },
94
- enumerable,
95
- });
96
- }
97
- else {
98
- Object.defineProperty(ref, key, { value, enumerable });
99
- }
100
- }
101
- return ref;
64
+ function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
65
+ __onlyVue3();
66
+ for (const [key, value] of Object.entries(extend)) {
67
+ if (key === "value")
68
+ continue;
69
+ if (vueDemi.isRef(value) && unwrap) {
70
+ Object.defineProperty(ref, key, {
71
+ get() {
72
+ return value.value;
73
+ },
74
+ set(v) {
75
+ value.value = v;
76
+ },
77
+ enumerable
78
+ });
79
+ } else {
80
+ Object.defineProperty(ref, key, { value, enumerable });
81
+ }
82
+ }
83
+ return ref;
102
84
  }
103
85
 
104
- /**
105
- * Explicitly define the deps of computed.
106
- *
107
- * @param source
108
- * @param fn
109
- */
110
- function controlledRef(initial, options = {}) {
111
- let source = initial;
112
- let track;
113
- let trigger;
114
- const ref = vueDemi.customRef((_track, _trigger) => {
115
- track = _track;
116
- trigger = _trigger;
117
- return {
118
- get() {
119
- return get();
120
- },
121
- set(v) {
122
- set(v);
123
- },
124
- };
125
- });
126
- function get(tracking = true) {
127
- if (tracking)
128
- track();
129
- return source;
130
- }
131
- function set(value, triggering = true) {
132
- var _a, _b;
133
- if (value === source)
134
- return;
135
- const old = source;
136
- if (((_a = options.onBeforeChange) === null || _a === void 0 ? void 0 : _a.call(options, value, old)) === false)
137
- return; // dismissed
138
- source = value;
139
- (_b = options.onChanged) === null || _b === void 0 ? void 0 : _b.call(options, value, old);
140
- if (triggering)
141
- trigger();
142
- }
143
- /**
144
- * Get the value without tracked in the reactivity system
145
- */
146
- const untrackedGet = () => get(false);
147
- /**
148
- * Set the value without triggering the reactivity system
149
- */
150
- const silentSet = (v) => set(v, false);
151
- /**
152
- * Get the value without tracked in the reactivity system.
153
- *
154
- * Alias for `untrackedGet()`
155
- */
156
- const peek = () => get(false);
157
- /**
158
- * Set the value without triggering the reactivity system
159
- *
160
- * Alias for `silentSet(v)`
161
- */
162
- const lay = (v) => set(v, false);
163
- return extendRef(ref, {
164
- get,
165
- set,
166
- untrackedGet,
167
- silentSet,
168
- peek,
169
- lay,
170
- }, { enumerable: true });
86
+ function controlledRef(initial, options = {}) {
87
+ let source = initial;
88
+ let track;
89
+ let trigger;
90
+ const ref = vueDemi.customRef((_track, _trigger) => {
91
+ track = _track;
92
+ trigger = _trigger;
93
+ return {
94
+ get() {
95
+ return get();
96
+ },
97
+ set(v) {
98
+ set(v);
99
+ }
100
+ };
101
+ });
102
+ function get(tracking = true) {
103
+ if (tracking)
104
+ track();
105
+ return source;
106
+ }
107
+ function set(value, triggering = true) {
108
+ var _a, _b;
109
+ if (value === source)
110
+ return;
111
+ const old = source;
112
+ if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
113
+ return;
114
+ source = value;
115
+ (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
116
+ if (triggering)
117
+ trigger();
118
+ }
119
+ const untrackedGet = () => get(false);
120
+ const silentSet = (v) => set(v, false);
121
+ const peek = () => get(false);
122
+ const lay = (v) => set(v, false);
123
+ return extendRef(ref, {
124
+ get,
125
+ set,
126
+ untrackedGet,
127
+ silentSet,
128
+ peek,
129
+ lay
130
+ }, { enumerable: true });
171
131
  }
172
132
 
173
- /**
174
- * The source code for this function was inspired by vue-apollo's `useEventHook` util
175
- * https://github.com/vuejs/vue-apollo/blob/v4/packages/vue-apollo-composable/src/util/useEventHook.ts
176
- */
177
- /**
178
- * Utility for creating event hooks
179
- *
180
- * @see https://vueuse.org/createEventHook
181
- */
182
- function createEventHook() {
183
- const fns = [];
184
- const off = (fn) => {
185
- const index = fns.indexOf(fn);
186
- if (index !== -1)
187
- fns.splice(index, 1);
188
- };
189
- const on = (fn) => {
190
- fns.push(fn);
191
- return {
192
- off: () => off(fn),
193
- };
194
- };
195
- const trigger = (param) => {
196
- fns.forEach(fn => fn(param));
197
- };
198
- return {
199
- on,
200
- off,
201
- trigger,
202
- };
133
+ function createEventHook() {
134
+ const fns = [];
135
+ const off = (fn) => {
136
+ const index = fns.indexOf(fn);
137
+ if (index !== -1)
138
+ fns.splice(index, 1);
139
+ };
140
+ const on = (fn) => {
141
+ fns.push(fn);
142
+ return {
143
+ off: () => off(fn)
144
+ };
145
+ };
146
+ const trigger = (param) => {
147
+ fns.forEach((fn) => fn(param));
148
+ };
149
+ return {
150
+ on,
151
+ off,
152
+ trigger
153
+ };
203
154
  }
204
155
 
205
- /**
206
- * Keep states in the global scope to be reusable across Vue instances.
207
- *
208
- * @see https://vueuse.org/createGlobalState
209
- * @param stateFactory A factory function to create the state
210
- */
211
- function createGlobalState(stateFactory) {
212
- let initialized = false;
213
- let state;
214
- const scope = vueDemi.effectScope(true);
215
- return () => {
216
- if (!initialized) {
217
- state = scope.run(stateFactory);
218
- initialized = true;
219
- }
220
- return state;
221
- };
156
+ function createGlobalState(stateFactory) {
157
+ let initialized = false;
158
+ let state;
159
+ const scope = vueDemi.effectScope(true);
160
+ return () => {
161
+ if (!initialized) {
162
+ state = scope.run(stateFactory);
163
+ initialized = true;
164
+ }
165
+ return state;
166
+ };
222
167
  }
223
168
 
224
- /**
225
- * Call onScopeDispose() if it's inside a effect scope lifecycle, if not, do nothing
226
- *
227
- * @param fn
228
- */
229
- function tryOnScopeDispose(fn) {
230
- if (vueDemi.getCurrentScope()) {
231
- vueDemi.onScopeDispose(fn);
232
- return true;
233
- }
234
- return false;
169
+ function tryOnScopeDispose(fn) {
170
+ if (vueDemi.getCurrentScope()) {
171
+ vueDemi.onScopeDispose(fn);
172
+ return true;
173
+ }
174
+ return false;
235
175
  }
236
176
 
237
- /**
238
- * Make a composable function usable with multiple Vue instances.
239
- *
240
- * @see https://vueuse.org/createSharedComposable
241
- */
242
- function createSharedComposable(composable) {
243
- let subscribers = 0;
244
- let state;
245
- let scope;
246
- const dispose = () => {
247
- subscribers -= 1;
248
- if (scope && subscribers <= 0) {
249
- scope.stop();
250
- state = undefined;
251
- scope = undefined;
252
- }
253
- };
254
- return ((...args) => {
255
- subscribers += 1;
256
- if (!state) {
257
- scope = vueDemi.effectScope(true);
258
- state = scope.run(() => composable(...args));
259
- }
260
- tryOnScopeDispose(dispose);
261
- return state;
262
- });
177
+ function createSharedComposable(composable) {
178
+ let subscribers = 0;
179
+ let state;
180
+ let scope;
181
+ const dispose = () => {
182
+ subscribers -= 1;
183
+ if (scope && subscribers <= 0) {
184
+ scope.stop();
185
+ state = void 0;
186
+ scope = void 0;
187
+ }
188
+ };
189
+ return (...args) => {
190
+ subscribers += 1;
191
+ if (!state) {
192
+ scope = vueDemi.effectScope(true);
193
+ state = scope.run(() => composable(...args));
194
+ }
195
+ tryOnScopeDispose(dispose);
196
+ return state;
197
+ };
263
198
  }
264
199
 
265
- /*! *****************************************************************************
266
- Copyright (c) Microsoft Corporation.
267
-
268
- Permission to use, copy, modify, and/or distribute this software for any
269
- purpose with or without fee is hereby granted.
270
-
271
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
272
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
273
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
274
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
275
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
276
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
277
- PERFORMANCE OF THIS SOFTWARE.
278
- ***************************************************************************** */
279
-
280
- function __rest(s, e) {
281
- var t = {};
282
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
283
- t[p] = s[p];
284
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
285
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
286
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
287
- t[p[i]] = s[p[i]];
288
- }
289
- return t;
290
- }
200
+ const isClient = typeof window !== "undefined";
201
+ const isDef = (val) => typeof val !== "undefined";
202
+ const assert = (condition, ...infos) => {
203
+ if (!condition)
204
+ console.warn(...infos);
205
+ };
206
+ const toString = Object.prototype.toString;
207
+ const isBoolean = (val) => typeof val === "boolean";
208
+ const isFunction = (val) => typeof val === "function";
209
+ const isNumber = (val) => typeof val === "number";
210
+ const isString = (val) => typeof val === "string";
211
+ const isObject = (val) => toString.call(val) === "[object Object]";
212
+ const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
213
+ const now = () => Date.now();
214
+ const timestamp = () => +Date.now();
215
+ const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
216
+ const noop = () => {
217
+ };
218
+ const rand = (min, max) => {
219
+ min = Math.ceil(min);
220
+ max = Math.floor(max);
221
+ return Math.floor(Math.random() * (max - min + 1)) + min;
222
+ };
291
223
 
292
- const isClient = typeof window !== 'undefined';
293
- const isDef = (val) => typeof val !== 'undefined';
294
- const assert = (condition, ...infos) => {
295
- // eslint-disable-next-line no-console
296
- if (!condition)
297
- console.warn(...infos);
298
- };
299
- const toString = Object.prototype.toString;
300
- const isBoolean = (val) => typeof val === 'boolean';
301
- const isFunction = (val) => typeof val === 'function';
302
- const isNumber = (val) => typeof val === 'number';
303
- const isString = (val) => typeof val === 'string';
304
- const isObject = (val) => toString.call(val) === '[object Object]';
305
- const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
306
- const now = () => Date.now();
307
- const timestamp = () => +Date.now();
308
- const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
309
- const noop = () => { };
310
- const rand = (min, max) => {
311
- min = Math.ceil(min);
312
- max = Math.floor(max);
313
- return Math.floor(Math.random() * (max - min + 1)) + min;
224
+ function createFilterWrapper(filter, fn) {
225
+ function wrapper(...args) {
226
+ filter(() => fn.apply(this, args), { fn, thisArg: this, args });
227
+ }
228
+ return wrapper;
229
+ }
230
+ const bypassFilter = (invoke) => {
231
+ return invoke();
314
232
  };
233
+ function debounceFilter(ms) {
234
+ let timer;
235
+ const filter = (invoke) => {
236
+ const duration = vueDemi.unref(ms);
237
+ if (timer)
238
+ clearTimeout(timer);
239
+ if (duration <= 0)
240
+ return invoke();
241
+ timer = setTimeout(invoke, duration);
242
+ };
243
+ return filter;
244
+ }
245
+ function throttleFilter(ms, trailing = true, leading = true) {
246
+ let lastExec = 0;
247
+ let timer;
248
+ let preventLeading = !leading;
249
+ const clear = () => {
250
+ if (timer) {
251
+ clearTimeout(timer);
252
+ timer = void 0;
253
+ }
254
+ };
255
+ const filter = (invoke) => {
256
+ const duration = vueDemi.unref(ms);
257
+ const elapsed = Date.now() - lastExec;
258
+ clear();
259
+ if (duration <= 0) {
260
+ lastExec = Date.now();
261
+ return invoke();
262
+ }
263
+ if (elapsed > duration) {
264
+ lastExec = Date.now();
265
+ if (preventLeading)
266
+ preventLeading = false;
267
+ else
268
+ invoke();
269
+ } else if (trailing) {
270
+ timer = setTimeout(() => {
271
+ lastExec = Date.now();
272
+ if (!leading)
273
+ preventLeading = true;
274
+ clear();
275
+ invoke();
276
+ }, duration);
277
+ }
278
+ if (!leading && !timer)
279
+ timer = setTimeout(() => preventLeading = true, duration);
280
+ };
281
+ return filter;
282
+ }
283
+ function pausableFilter(extendFilter = bypassFilter) {
284
+ const isActive = vueDemi.ref(true);
285
+ function pause() {
286
+ isActive.value = false;
287
+ }
288
+ function resume() {
289
+ isActive.value = true;
290
+ }
291
+ const eventFilter = (...args) => {
292
+ if (isActive.value)
293
+ extendFilter(...args);
294
+ };
295
+ return { isActive, pause, resume, eventFilter };
296
+ }
315
297
 
316
- /**
317
- * @internal
318
- */
319
- function createFilterWrapper(filter, fn) {
320
- function wrapper(...args) {
321
- filter(() => fn.apply(this, args), { fn, thisArg: this, args });
322
- }
323
- return wrapper;
324
- }
325
- const bypassFilter = (invoke) => {
326
- return invoke();
327
- };
328
- /**
329
- * Create an EventFilter that debounce the events
330
- *
331
- * @param ms
332
- */
333
- function debounceFilter(ms) {
334
- let timer;
335
- const filter = (invoke) => {
336
- const duration = vueDemi.unref(ms);
337
- if (timer)
338
- clearTimeout(timer);
339
- if (duration <= 0)
340
- return invoke();
341
- timer = setTimeout(invoke, duration);
342
- };
343
- return filter;
344
- }
345
- /**
346
- * Create an EventFilter that throttle the events
347
- *
348
- * @param ms
349
- * @param [trailing=true]
350
- */
351
- function throttleFilter(ms, trailing = true) {
352
- let lastExec = 0;
353
- let timer;
354
- const clear = () => {
355
- if (timer) {
356
- clearTimeout(timer);
357
- timer = undefined;
358
- }
359
- };
360
- const filter = (invoke) => {
361
- const duration = vueDemi.unref(ms);
362
- const elapsed = Date.now() - lastExec;
363
- clear();
364
- if (duration <= 0) {
365
- lastExec = Date.now();
366
- return invoke();
367
- }
368
- if (elapsed > duration) {
369
- lastExec = Date.now();
370
- invoke();
371
- }
372
- else if (trailing) {
373
- timer = setTimeout(() => {
374
- lastExec = Date.now();
375
- clear();
376
- invoke();
377
- }, duration);
378
- }
379
- };
380
- return filter;
381
- }
382
- /**
383
- * EventFilter that gives extra controls to pause and resume the filter
384
- *
385
- * @param extendFilter Extra filter to apply when the PauseableFilter is active, default to none
386
- *
387
- */
388
- function pausableFilter(extendFilter = bypassFilter) {
389
- const isActive = vueDemi.ref(true);
390
- function pause() {
391
- isActive.value = false;
392
- }
393
- function resume() {
394
- isActive.value = true;
395
- }
396
- const eventFilter = (...args) => {
397
- if (isActive.value)
398
- extendFilter(...args);
399
- };
400
- return { isActive, pause, resume, eventFilter };
298
+ function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
299
+ return new Promise((resolve, reject) => {
300
+ if (throwOnTimeout)
301
+ setTimeout(() => reject(reason), ms);
302
+ else
303
+ setTimeout(resolve, ms);
304
+ });
305
+ }
306
+ function identity(arg) {
307
+ return arg;
308
+ }
309
+ function createSingletonPromise(fn) {
310
+ let _promise;
311
+ function wrapper() {
312
+ if (!_promise)
313
+ _promise = fn();
314
+ return _promise;
315
+ }
316
+ wrapper.reset = async () => {
317
+ const _prev = _promise;
318
+ _promise = void 0;
319
+ if (_prev)
320
+ await _prev;
321
+ };
322
+ return wrapper;
323
+ }
324
+ function invoke(fn) {
325
+ return fn();
326
+ }
327
+ function containsProp(obj, ...props) {
328
+ return props.some((k) => k in obj);
329
+ }
330
+ function increaseWithUnit(target, delta) {
331
+ var _a;
332
+ if (typeof target === "number")
333
+ return target + delta;
334
+ const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
335
+ const unit = target.slice(value.length);
336
+ const result = parseFloat(value) + delta;
337
+ if (Number.isNaN(result))
338
+ return target;
339
+ return result + unit;
340
+ }
341
+ function objectPick(obj, keys, omitUndefined = false) {
342
+ return keys.reduce((n, k) => {
343
+ if (k in obj) {
344
+ if (!omitUndefined || !obj[k] === void 0)
345
+ n[k] = obj[k];
346
+ }
347
+ return n;
348
+ }, {});
401
349
  }
402
350
 
403
- function promiseTimeout(ms, throwOnTimeout = false, reason = 'Timeout') {
404
- return new Promise((resolve, reject) => {
405
- if (throwOnTimeout)
406
- setTimeout(() => reject(reason), ms);
407
- else
408
- setTimeout(resolve, ms);
409
- });
410
- }
411
- function identity(arg) {
412
- return arg;
413
- }
414
- /**
415
- * Create singleton promise function
416
- *
417
- * @example
418
- * ```
419
- * const promise = createSingletonPromise(async () => { ... })
420
- *
421
- * await promise()
422
- * await promise() // all of them will be bind to a single promise instance
423
- * await promise() // and be resolved together
424
- * ```
425
- */
426
- function createSingletonPromise(fn) {
427
- let _promise;
428
- function wrapper() {
429
- if (!_promise)
430
- _promise = fn();
431
- return _promise;
432
- }
433
- wrapper.reset = async () => {
434
- const _prev = _promise;
435
- _promise = undefined;
436
- if (_prev)
437
- await _prev;
438
- };
439
- return wrapper;
440
- }
441
- function invoke(fn) {
442
- return fn();
443
- }
444
- function containsProp(obj, ...props) {
445
- return props.some(k => k in obj);
446
- }
447
- function increaseWithUnit(target, delta) {
448
- var _a;
449
- if (typeof target === 'number')
450
- return target + delta;
451
- const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) === null || _a === void 0 ? void 0 : _a[0]) || '';
452
- const unit = target.slice(value.length);
453
- const result = (parseFloat(value) + delta);
454
- if (Number.isNaN(result))
455
- return target;
456
- return result + unit;
457
- }
458
- /**
459
- * Create a new subset object by giving keys
460
- *
461
- * @category Object
462
- */
463
- function objectPick(obj, keys, omitUndefined = false) {
464
- return keys.reduce((n, k) => {
465
- if (k in obj)
466
- if (!omitUndefined || !obj[k] === undefined)
467
- n[k] = obj[k];
468
- return n;
469
- }, {});
351
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
352
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
353
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
354
+ var __objRest$5 = (source, exclude) => {
355
+ var target = {};
356
+ for (var prop in source)
357
+ if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
358
+ target[prop] = source[prop];
359
+ if (source != null && __getOwnPropSymbols$8)
360
+ for (var prop of __getOwnPropSymbols$8(source)) {
361
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
362
+ target[prop] = source[prop];
363
+ }
364
+ return target;
365
+ };
366
+ function watchWithFilter(source, cb, options = {}) {
367
+ const _a = options, {
368
+ eventFilter = bypassFilter
369
+ } = _a, watchOptions = __objRest$5(_a, [
370
+ "eventFilter"
371
+ ]);
372
+ return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
470
373
  }
471
374
 
472
- // implementation
473
- function watchWithFilter(source, cb, options = {}) {
474
- const { eventFilter = bypassFilter } = options, watchOptions = __rest(options, ["eventFilter"]);
475
- return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
375
+ var __defProp$6 = Object.defineProperty;
376
+ var __defProps$3 = Object.defineProperties;
377
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
378
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
379
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
380
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
381
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
382
+ var __spreadValues$6 = (a, b) => {
383
+ for (var prop in b || (b = {}))
384
+ if (__hasOwnProp$7.call(b, prop))
385
+ __defNormalProp$6(a, prop, b[prop]);
386
+ if (__getOwnPropSymbols$7)
387
+ for (var prop of __getOwnPropSymbols$7(b)) {
388
+ if (__propIsEnum$7.call(b, prop))
389
+ __defNormalProp$6(a, prop, b[prop]);
390
+ }
391
+ return a;
392
+ };
393
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
394
+ var __objRest$4 = (source, exclude) => {
395
+ var target = {};
396
+ for (var prop in source)
397
+ if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
398
+ target[prop] = source[prop];
399
+ if (source != null && __getOwnPropSymbols$7)
400
+ for (var prop of __getOwnPropSymbols$7(source)) {
401
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
402
+ target[prop] = source[prop];
403
+ }
404
+ return target;
405
+ };
406
+ function debouncedWatch(source, cb, options = {}) {
407
+ const _a = options, {
408
+ debounce = 0
409
+ } = _a, watchOptions = __objRest$4(_a, [
410
+ "debounce"
411
+ ]);
412
+ return watchWithFilter(source, cb, __spreadProps$3(__spreadValues$6({}, watchOptions), {
413
+ eventFilter: debounceFilter(debounce)
414
+ }));
476
415
  }
477
416
 
478
- // implementation
479
- function debouncedWatch(source, cb, options = {}) {
480
- const { debounce = 0 } = options, watchOptions = __rest(options, ["debounce"]);
481
- return watchWithFilter(source, cb, Object.assign(Object.assign({}, watchOptions), { eventFilter: debounceFilter(debounce) }));
417
+ function eagerComputed(fn) {
418
+ const result = vueDemi.shallowRef();
419
+ vueDemi.watchSyncEffect(() => {
420
+ result.value = fn();
421
+ });
422
+ return vueDemi.readonly(result);
482
423
  }
483
424
 
484
- // ported from https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j
485
- function eagerComputed(fn) {
486
- const result = vueDemi.shallowRef();
487
- vueDemi.watchSyncEffect(() => {
488
- result.value = fn();
489
- });
490
- return vueDemi.readonly(result);
425
+ function get(obj, key) {
426
+ if (key == null)
427
+ return vueDemi.unref(obj);
428
+ return vueDemi.unref(obj)[key];
491
429
  }
492
430
 
493
- function get(obj, key) {
494
- if (key == null)
495
- return vueDemi.unref(obj);
496
- return vueDemi.unref(obj)[key];
431
+ var __defProp$5 = Object.defineProperty;
432
+ var __defProps$2 = Object.defineProperties;
433
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
434
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
435
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
436
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
437
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
438
+ var __spreadValues$5 = (a, b) => {
439
+ for (var prop in b || (b = {}))
440
+ if (__hasOwnProp$6.call(b, prop))
441
+ __defNormalProp$5(a, prop, b[prop]);
442
+ if (__getOwnPropSymbols$6)
443
+ for (var prop of __getOwnPropSymbols$6(b)) {
444
+ if (__propIsEnum$6.call(b, prop))
445
+ __defNormalProp$5(a, prop, b[prop]);
446
+ }
447
+ return a;
448
+ };
449
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
450
+ var __objRest$3 = (source, exclude) => {
451
+ var target = {};
452
+ for (var prop in source)
453
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
454
+ target[prop] = source[prop];
455
+ if (source != null && __getOwnPropSymbols$6)
456
+ for (var prop of __getOwnPropSymbols$6(source)) {
457
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
458
+ target[prop] = source[prop];
459
+ }
460
+ return target;
461
+ };
462
+ function ignorableWatch(source, cb, options = {}) {
463
+ const _a = options, {
464
+ eventFilter = bypassFilter
465
+ } = _a, watchOptions = __objRest$3(_a, [
466
+ "eventFilter"
467
+ ]);
468
+ const filteredCb = createFilterWrapper(eventFilter, cb);
469
+ let ignoreUpdates;
470
+ let ignorePrevAsyncUpdates;
471
+ let stop;
472
+ if (watchOptions.flush === "sync") {
473
+ const ignore = vueDemi.ref(false);
474
+ ignorePrevAsyncUpdates = () => {
475
+ };
476
+ ignoreUpdates = (updater) => {
477
+ ignore.value = true;
478
+ updater();
479
+ ignore.value = false;
480
+ };
481
+ stop = vueDemi.watch(source, (...args) => {
482
+ if (!ignore.value)
483
+ filteredCb(...args);
484
+ }, watchOptions);
485
+ } else {
486
+ const disposables = [];
487
+ const ignoreCounter = vueDemi.ref(0);
488
+ const syncCounter = vueDemi.ref(0);
489
+ ignorePrevAsyncUpdates = () => {
490
+ ignoreCounter.value = syncCounter.value;
491
+ };
492
+ disposables.push(vueDemi.watch(source, () => {
493
+ syncCounter.value++;
494
+ }, __spreadProps$2(__spreadValues$5({}, watchOptions), { flush: "sync" })));
495
+ ignoreUpdates = (updater) => {
496
+ const syncCounterPrev = syncCounter.value;
497
+ updater();
498
+ ignoreCounter.value += syncCounter.value - syncCounterPrev;
499
+ };
500
+ disposables.push(vueDemi.watch(source, (...args) => {
501
+ const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
502
+ ignoreCounter.value = 0;
503
+ syncCounter.value = 0;
504
+ if (ignore)
505
+ return;
506
+ filteredCb(...args);
507
+ }, watchOptions));
508
+ stop = () => {
509
+ disposables.forEach((fn) => fn());
510
+ };
511
+ }
512
+ return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
513
+ }
514
+
515
+ var __defProp$4 = Object.defineProperty;
516
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
517
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
518
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
519
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
520
+ var __spreadValues$4 = (a, b) => {
521
+ for (var prop in b || (b = {}))
522
+ if (__hasOwnProp$5.call(b, prop))
523
+ __defNormalProp$4(a, prop, b[prop]);
524
+ if (__getOwnPropSymbols$5)
525
+ for (var prop of __getOwnPropSymbols$5(b)) {
526
+ if (__propIsEnum$5.call(b, prop))
527
+ __defNormalProp$4(a, prop, b[prop]);
528
+ }
529
+ return a;
530
+ };
531
+ function makeDestructurable(obj, arr) {
532
+ if (typeof Symbol !== "undefined") {
533
+ const clone = __spreadValues$4({}, obj);
534
+ Object.defineProperty(clone, Symbol.iterator, {
535
+ enumerable: false,
536
+ value() {
537
+ let index = 0;
538
+ return {
539
+ next: () => ({
540
+ value: arr[index++],
541
+ done: index > arr.length
542
+ })
543
+ };
544
+ }
545
+ });
546
+ return clone;
547
+ } else {
548
+ return Object.assign([...arr], obj);
549
+ }
497
550
  }
498
551
 
499
- function ignorableWatch(source, cb, options = {}) {
500
- const { eventFilter = bypassFilter } = options, watchOptions = __rest(options, ["eventFilter"]);
501
- const filteredCb = createFilterWrapper(eventFilter, cb);
502
- let ignoreUpdates;
503
- let ignorePrevAsyncUpdates;
504
- let stop;
505
- if (watchOptions.flush === 'sync') {
506
- const ignore = vueDemi.ref(false);
507
- // no op for flush: sync
508
- ignorePrevAsyncUpdates = () => { };
509
- ignoreUpdates = (updater) => {
510
- // Call the updater function and count how many sync updates are performed,
511
- // then add them to the ignore count
512
- ignore.value = true;
513
- updater();
514
- ignore.value = false;
515
- };
516
- stop = vueDemi.watch(source, (...args) => {
517
- if (!ignore.value)
518
- filteredCb(...args);
519
- }, watchOptions);
520
- }
521
- else {
522
- // flush 'pre' and 'post'
523
- const disposables = [];
524
- // counters for how many following changes to be ignored
525
- // ignoreCounter is incremented before there is a history operation
526
- // affecting the source ref value (undo, redo, revert).
527
- // syncCounter is incremented in sync with every change to the
528
- // source ref value. This let us know how many times the ref
529
- // was modified and support chained sync operations. If there
530
- // are more sync triggers than the ignore count, the we now
531
- // there are modifications in the source ref value that we
532
- // need to commit
533
- const ignoreCounter = vueDemi.ref(0);
534
- const syncCounter = vueDemi.ref(0);
535
- ignorePrevAsyncUpdates = () => {
536
- ignoreCounter.value = syncCounter.value;
537
- };
538
- // Sync watch to count modifications to the source
539
- disposables.push(vueDemi.watch(source, () => {
540
- syncCounter.value++;
541
- }, Object.assign(Object.assign({}, watchOptions), { flush: 'sync' })));
542
- ignoreUpdates = (updater) => {
543
- // Call the updater function and count how many sync updates are performed,
544
- // then add them to the ignore count
545
- const syncCounterPrev = syncCounter.value;
546
- updater();
547
- ignoreCounter.value += syncCounter.value - syncCounterPrev;
548
- };
549
- disposables.push(vueDemi.watch(source, (...args) => {
550
- // If a history operation was performed (ignoreCounter > 0) and there are
551
- // no other changes to the source ref value afterwards, then ignore this commit
552
- const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
553
- ignoreCounter.value = 0;
554
- syncCounter.value = 0;
555
- if (ignore)
556
- return;
557
- filteredCb(...args);
558
- }, watchOptions));
559
- stop = () => {
560
- disposables.forEach(fn => fn());
561
- };
562
- }
563
- return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
552
+ function not(v) {
553
+ return vueDemi.computed(() => !vueDemi.unref(v));
564
554
  }
565
555
 
566
- function makeDestructurable(obj, arr) {
567
- if (typeof Symbol !== 'undefined') {
568
- const clone = Object.assign({}, obj);
569
- Object.defineProperty(clone, Symbol.iterator, {
570
- enumerable: false,
571
- value() {
572
- let index = 0;
573
- return {
574
- next: () => ({
575
- value: arr[index++],
576
- done: index > arr.length,
577
- }),
578
- };
579
- },
580
- });
581
- return clone;
582
- }
583
- else {
584
- return Object.assign([...arr], obj);
585
- }
556
+ function or(...args) {
557
+ return vueDemi.computed(() => args.some((i) => vueDemi.unref(i)));
586
558
  }
587
559
 
588
- /**
589
- * `NOT` conditions for refs.
590
- *
591
- * @see https://vueuse.org/not
592
- */
593
- function not(v) {
594
- return vueDemi.computed(() => !vueDemi.unref(v));
560
+ var __defProp$3 = Object.defineProperty;
561
+ var __defProps$1 = Object.defineProperties;
562
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
563
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
564
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
565
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
566
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
567
+ var __spreadValues$3 = (a, b) => {
568
+ for (var prop in b || (b = {}))
569
+ if (__hasOwnProp$4.call(b, prop))
570
+ __defNormalProp$3(a, prop, b[prop]);
571
+ if (__getOwnPropSymbols$4)
572
+ for (var prop of __getOwnPropSymbols$4(b)) {
573
+ if (__propIsEnum$4.call(b, prop))
574
+ __defNormalProp$3(a, prop, b[prop]);
575
+ }
576
+ return a;
577
+ };
578
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
579
+ var __objRest$2 = (source, exclude) => {
580
+ var target = {};
581
+ for (var prop in source)
582
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
583
+ target[prop] = source[prop];
584
+ if (source != null && __getOwnPropSymbols$4)
585
+ for (var prop of __getOwnPropSymbols$4(source)) {
586
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
587
+ target[prop] = source[prop];
588
+ }
589
+ return target;
590
+ };
591
+ function pausableWatch(source, cb, options = {}) {
592
+ const _a = options, {
593
+ eventFilter: filter
594
+ } = _a, watchOptions = __objRest$2(_a, [
595
+ "eventFilter"
596
+ ]);
597
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
598
+ const stop = watchWithFilter(source, cb, __spreadProps$1(__spreadValues$3({}, watchOptions), {
599
+ eventFilter
600
+ }));
601
+ return { stop, pause, resume, isActive };
595
602
  }
596
603
 
597
- /**
598
- * `OR` conditions for refs.
599
- *
600
- * @see https://vueuse.org/or
601
- */
602
- function or(...args) {
603
- return vueDemi.computed(() => args.some(i => vueDemi.unref(i)));
604
+ function reactify(fn) {
605
+ return function(...args) {
606
+ return vueDemi.computed(() => fn.apply(this, args.map((i) => vueDemi.unref(i))));
607
+ };
604
608
  }
605
609
 
606
- // implementation
607
- function pausableWatch(source, cb, options = {}) {
608
- const { eventFilter: filter } = options, watchOptions = __rest(options, ["eventFilter"]);
609
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
610
- const stop = watchWithFilter(source, cb, Object.assign(Object.assign({}, watchOptions), { eventFilter }));
611
- return { stop, pause, resume, isActive };
610
+ function reactifyObject(obj, optionsOrKeys = {}) {
611
+ let keys = [];
612
+ if (Array.isArray(optionsOrKeys)) {
613
+ keys = optionsOrKeys;
614
+ } else {
615
+ const { includeOwnProperties = true } = optionsOrKeys;
616
+ keys.push(...Object.keys(obj));
617
+ if (includeOwnProperties)
618
+ keys.push(...Object.getOwnPropertyNames(obj));
619
+ }
620
+ return Object.fromEntries(keys.map((key) => {
621
+ const value = obj[key];
622
+ return [
623
+ key,
624
+ typeof value === "function" ? reactify(value.bind(obj)) : value
625
+ ];
626
+ }));
612
627
  }
613
628
 
614
- /**
615
- * Converts plain function into a reactive function.
616
- * The converted function accepts refs as it's arguments
617
- * and returns a ComputedRef, with proper typing.
618
- *
619
- * @param fn - Source function
620
- */
621
- function reactify(fn) {
622
- return function (...args) {
623
- return vueDemi.computed(() => fn.apply(this, args.map(i => vueDemi.unref(i))));
624
- };
629
+ function reactivePick(obj, ...keys) {
630
+ return vueDemi.reactive(Object.fromEntries(keys.map((k) => [k, vueDemi.toRef(obj, k)])));
625
631
  }
626
632
 
627
- function reactifyObject(obj, optionsOrKeys = {}) {
628
- let keys = [];
629
- if (Array.isArray(optionsOrKeys)) {
630
- keys = optionsOrKeys;
631
- }
632
- else {
633
- const { includeOwnProperties = true } = optionsOrKeys;
634
- keys.push(...Object.keys(obj));
635
- if (includeOwnProperties)
636
- keys.push(...Object.getOwnPropertyNames(obj));
637
- }
638
- return Object.fromEntries(keys
639
- .map((key) => {
640
- const value = obj[key];
641
- return [
642
- key,
643
- typeof value === 'function'
644
- ? reactify(value.bind(obj))
645
- : value,
646
- ];
647
- }));
633
+ function set(...args) {
634
+ if (args.length === 2) {
635
+ const [ref, value] = args;
636
+ ref.value = value;
637
+ }
638
+ if (args.length === 3) {
639
+ if (vueDemi.isVue2) {
640
+ require("vue-demi").set(...args);
641
+ } else {
642
+ const [target, key, value] = args;
643
+ target[key] = value;
644
+ }
645
+ }
648
646
  }
649
647
 
650
- /**
651
- * Reactively pick fields from a reactive object
652
- *
653
- * @see https://vueuse.js.org/reactivePick
654
- */
655
- function reactivePick(obj, ...keys) {
656
- return vueDemi.reactive(Object.fromEntries(keys.map(k => [k, vueDemi.toRef(obj, k)])));
648
+ function syncRef(source, targets, {
649
+ flush = "sync",
650
+ deep = false,
651
+ immediate = true
652
+ } = {}) {
653
+ if (!Array.isArray(targets))
654
+ targets = [targets];
655
+ return vueDemi.watch(source, (newValue) => {
656
+ targets.forEach((target) => target.value = newValue);
657
+ }, {
658
+ flush,
659
+ deep,
660
+ immediate
661
+ });
657
662
  }
658
663
 
659
- /**
660
- * Shorthand for `ref.value = x`
661
- */
662
- function set(...args) {
663
- if (args.length === 2) {
664
- const [ref, value] = args;
665
- ref.value = value;
666
- }
667
- if (args.length === 3) {
668
- if (vueDemi.isVue2) {
669
- // use @vue/composition-api's set API
670
- // eslint-disable-next-line @typescript-eslint/no-var-requires
671
- require('vue-demi').set(...args);
672
- }
673
- else {
674
- const [target, key, value] = args;
675
- target[key] = value;
676
- }
677
- }
664
+ var __defProp$2 = Object.defineProperty;
665
+ var __defProps = Object.defineProperties;
666
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
667
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
668
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
669
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
670
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
671
+ var __spreadValues$2 = (a, b) => {
672
+ for (var prop in b || (b = {}))
673
+ if (__hasOwnProp$3.call(b, prop))
674
+ __defNormalProp$2(a, prop, b[prop]);
675
+ if (__getOwnPropSymbols$3)
676
+ for (var prop of __getOwnPropSymbols$3(b)) {
677
+ if (__propIsEnum$3.call(b, prop))
678
+ __defNormalProp$2(a, prop, b[prop]);
679
+ }
680
+ return a;
681
+ };
682
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
683
+ var __objRest$1 = (source, exclude) => {
684
+ var target = {};
685
+ for (var prop in source)
686
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
687
+ target[prop] = source[prop];
688
+ if (source != null && __getOwnPropSymbols$3)
689
+ for (var prop of __getOwnPropSymbols$3(source)) {
690
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
691
+ target[prop] = source[prop];
692
+ }
693
+ return target;
694
+ };
695
+ function throttledWatch(source, cb, options = {}) {
696
+ const _a = options, {
697
+ throttle = 0,
698
+ trailing = true
699
+ } = _a, watchOptions = __objRest$1(_a, [
700
+ "throttle",
701
+ "trailing"
702
+ ]);
703
+ return watchWithFilter(source, cb, __spreadProps(__spreadValues$2({}, watchOptions), {
704
+ eventFilter: throttleFilter(throttle, trailing)
705
+ }));
678
706
  }
679
707
 
680
- /**
681
- * Keep target ref(s) in sync with the source ref
682
- *
683
- * @param source source ref
684
- * @param targets
685
- */
686
- function syncRef(source, targets, { flush = 'sync', deep = false, immediate = true, } = {}) {
687
- if (!Array.isArray(targets))
688
- targets = [targets];
689
- return vueDemi.watch(source, (newValue) => {
690
- targets.forEach(target => target.value = newValue);
691
- }, {
692
- flush,
693
- deep,
694
- immediate,
695
- });
708
+ function toReactive(objectRef) {
709
+ if (!vueDemi.isRef(objectRef))
710
+ return vueDemi.reactive(objectRef);
711
+ const proxy = new Proxy({}, {
712
+ get(_, p, receiver) {
713
+ return Reflect.get(objectRef.value, p, receiver);
714
+ },
715
+ set(_, p, value) {
716
+ objectRef.value[p] = value;
717
+ return true;
718
+ },
719
+ deleteProperty(_, p) {
720
+ return Reflect.deleteProperty(objectRef.value, p);
721
+ },
722
+ has(_, p) {
723
+ return Reflect.has(objectRef.value, p);
724
+ },
725
+ ownKeys() {
726
+ return Object.keys(objectRef.value);
727
+ },
728
+ getOwnPropertyDescriptor() {
729
+ return {
730
+ enumerable: true,
731
+ configurable: true
732
+ };
733
+ }
734
+ });
735
+ return vueDemi.reactive(proxy);
696
736
  }
697
737
 
698
- // implementation
699
- function throttledWatch(source, cb, options = {}) {
700
- const { throttle = 0 } = options, watchOptions = __rest(options, ["throttle"]);
701
- return watchWithFilter(source, cb, Object.assign(Object.assign({}, watchOptions), { eventFilter: throttleFilter(throttle) }));
738
+ function toRefs(objectRef) {
739
+ if (!vueDemi.isRef(objectRef))
740
+ return vueDemi.toRefs(objectRef);
741
+ const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
742
+ for (const key in objectRef.value) {
743
+ result[key] = vueDemi.customRef(() => ({
744
+ get() {
745
+ return objectRef.value[key];
746
+ },
747
+ set(v) {
748
+ objectRef.value[key] = v;
749
+ }
750
+ }));
751
+ }
752
+ return result;
702
753
  }
703
754
 
704
- /**
705
- * Converts ref to reactive.
706
- *
707
- * @see https://vueuse.org/toReactive
708
- * @param objectRef A ref of object
709
- */
710
- function toReactive(objectRef) {
711
- if (!vueDemi.isRef(objectRef))
712
- return vueDemi.reactive(objectRef);
713
- const proxy = new Proxy({}, {
714
- get(_, p, receiver) {
715
- return Reflect.get(objectRef.value, p, receiver);
716
- },
717
- set(_, p, value) {
718
- objectRef.value[p] = value;
719
- return true;
720
- },
721
- deleteProperty(_, p) {
722
- return Reflect.deleteProperty(objectRef.value, p);
723
- },
724
- has(_, p) {
725
- return Reflect.has(objectRef.value, p);
726
- },
727
- ownKeys() {
728
- return Object.keys(objectRef.value);
729
- },
730
- getOwnPropertyDescriptor() {
731
- return {
732
- enumerable: true,
733
- configurable: true,
734
- };
735
- },
736
- });
737
- return vueDemi.reactive(proxy);
755
+ function tryOnBeforeUnmount(fn) {
756
+ if (vueDemi.getCurrentInstance())
757
+ vueDemi.onBeforeUnmount(fn);
738
758
  }
739
759
 
740
- /**
741
- * Extended `toRefs` that also accepts refs of an object.
742
- *
743
- * @see https://vueuse.org/toRefs
744
- * @param objectRef A ref or normal object or array.
745
- */
746
- function toRefs(objectRef) {
747
- if (!vueDemi.isRef(objectRef))
748
- return vueDemi.toRefs(objectRef);
749
- const result = Array.isArray(objectRef.value)
750
- ? new Array(objectRef.value.length)
751
- : {};
752
- // eslint-disable-next-line no-restricted-syntax
753
- for (const key in objectRef.value) {
754
- result[key] = vueDemi.customRef(() => ({
755
- get() {
756
- return objectRef.value[key];
757
- },
758
- set(v) {
759
- objectRef.value[key] = v;
760
- },
761
- }));
762
- }
763
- return result;
760
+ function tryOnMounted(fn, sync = true) {
761
+ if (vueDemi.getCurrentInstance())
762
+ vueDemi.onMounted(fn);
763
+ else if (sync)
764
+ fn();
765
+ else
766
+ vueDemi.nextTick(fn);
764
767
  }
765
768
 
766
- /**
767
- * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
768
- *
769
- * @param fn
770
- */
771
- function tryOnBeforeUnmount(fn) {
772
- if (vueDemi.getCurrentInstance())
773
- vueDemi.onBeforeUnmount(fn);
769
+ function tryOnUnmounted(fn) {
770
+ if (vueDemi.getCurrentInstance())
771
+ vueDemi.onUnmounted(fn);
774
772
  }
775
773
 
776
- /**
777
- * Call onMounted() if it's inside a component lifecycle, if not, run just call the function
778
- *
779
- * @param fn
780
- * @param sync if set to false, it will run in the nextTick() of Vue
781
- */
782
- function tryOnMounted(fn, sync = true) {
783
- if (vueDemi.getCurrentInstance())
784
- vueDemi.onMounted(fn);
785
- else if (sync)
786
- fn();
787
- else
788
- vueDemi.nextTick(fn);
774
+ function until(r) {
775
+ let isNot = false;
776
+ function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
777
+ let stop = null;
778
+ const watcher = new Promise((resolve) => {
779
+ stop = vueDemi.watch(r, (v) => {
780
+ if (condition(v) === !isNot) {
781
+ stop == null ? void 0 : stop();
782
+ resolve();
783
+ }
784
+ }, {
785
+ flush,
786
+ deep,
787
+ immediate: true
788
+ });
789
+ });
790
+ const promises = [watcher];
791
+ if (timeout) {
792
+ promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
793
+ stop == null ? void 0 : stop();
794
+ }));
795
+ }
796
+ return Promise.race(promises);
797
+ }
798
+ function toBe(value, options) {
799
+ return toMatch((v) => v === vueDemi.unref(value), options);
800
+ }
801
+ function toBeTruthy(options) {
802
+ return toMatch((v) => Boolean(v), options);
803
+ }
804
+ function toBeNull(options) {
805
+ return toBe(null, options);
806
+ }
807
+ function toBeUndefined(options) {
808
+ return toBe(void 0, options);
809
+ }
810
+ function toBeNaN(options) {
811
+ return toMatch(Number.isNaN, options);
812
+ }
813
+ function toContains(value, options) {
814
+ return toMatch((v) => {
815
+ const array = Array.from(v);
816
+ return array.includes(value) || array.includes(vueDemi.unref(value));
817
+ }, options);
818
+ }
819
+ function changed(options) {
820
+ return changedTimes(1, options);
821
+ }
822
+ function changedTimes(n = 1, options) {
823
+ let count = -1;
824
+ return toMatch(() => {
825
+ count += 1;
826
+ return count >= n;
827
+ }, options);
828
+ }
829
+ if (Array.isArray(vueDemi.unref(r))) {
830
+ const instance = {
831
+ toMatch,
832
+ toContains,
833
+ changed,
834
+ changedTimes,
835
+ get not() {
836
+ isNot = !isNot;
837
+ return this;
838
+ }
839
+ };
840
+ return instance;
841
+ } else {
842
+ const instance = {
843
+ toMatch,
844
+ toBe,
845
+ toBeTruthy,
846
+ toBeNull,
847
+ toBeNaN,
848
+ toBeUndefined,
849
+ changed,
850
+ changedTimes,
851
+ get not() {
852
+ isNot = !isNot;
853
+ return this;
854
+ }
855
+ };
856
+ return instance;
857
+ }
789
858
  }
790
859
 
791
- /**
792
- * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing
793
- *
794
- * @param fn
795
- */
796
- function tryOnUnmounted(fn) {
797
- if (vueDemi.getCurrentInstance())
798
- vueDemi.onUnmounted(fn);
860
+ function useCounter(initialValue = 0) {
861
+ const count = vueDemi.ref(initialValue);
862
+ const inc = (delta = 1) => count.value += delta;
863
+ const dec = (delta = 1) => count.value -= delta;
864
+ const get = () => count.value;
865
+ const set = (val) => count.value = val;
866
+ const reset = (val = initialValue) => {
867
+ initialValue = val;
868
+ return set(val);
869
+ };
870
+ return { count, inc, dec, get, set, reset };
799
871
  }
800
872
 
801
- function until(r) {
802
- let isNot = false;
803
- function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
804
- let stop = null;
805
- const watcher = new Promise((resolve) => {
806
- stop = vueDemi.watch(r, (v) => {
807
- if (condition(v) === !isNot) {
808
- stop === null || stop === void 0 ? void 0 : stop();
809
- resolve();
810
- }
811
- }, {
812
- flush,
813
- deep,
814
- immediate: true,
815
- });
816
- });
817
- const promises = [watcher];
818
- if (timeout) {
819
- promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
820
- stop === null || stop === void 0 ? void 0 : stop();
821
- }));
822
- }
823
- return Promise.race(promises);
824
- }
825
- function toBe(value, options) {
826
- return toMatch(v => v === vueDemi.unref(value), options);
827
- }
828
- function toBeTruthy(options) {
829
- return toMatch(v => Boolean(v), options);
830
- }
831
- function toBeNull(options) {
832
- return toBe(null, options);
833
- }
834
- function toBeUndefined(options) {
835
- return toBe(undefined, options);
836
- }
837
- function toBeNaN(options) {
838
- return toMatch(Number.isNaN, options);
839
- }
840
- function toContains(value, options) {
841
- return toMatch((v) => {
842
- const array = Array.from(v);
843
- return array.includes(value) || array.includes(vueDemi.unref(value));
844
- }, options);
845
- }
846
- function changed(options) {
847
- return changedTimes(1, options);
848
- }
849
- function changedTimes(n = 1, options) {
850
- let count = -1; // skip the immediate check
851
- return toMatch(() => {
852
- count += 1;
853
- return count >= n;
854
- }, options);
855
- }
856
- if (Array.isArray(vueDemi.unref(r))) {
857
- const instance = {
858
- toMatch,
859
- toContains,
860
- changed,
861
- changedTimes,
862
- get not() {
863
- isNot = !isNot;
864
- return this;
865
- },
866
- };
867
- return instance;
868
- }
869
- else {
870
- const instance = {
871
- toMatch,
872
- toBe,
873
- toBeTruthy,
874
- toBeNull,
875
- toBeNaN,
876
- toBeUndefined,
877
- changed,
878
- changedTimes,
879
- get not() {
880
- isNot = !isNot;
881
- return this;
882
- },
883
- };
884
- return instance;
885
- }
873
+ function useDebounceFn(fn, ms = 200) {
874
+ return createFilterWrapper(debounceFilter(ms), fn);
886
875
  }
887
876
 
888
- /**
889
- * Basic counter with utility functions.
890
- *
891
- * @see https://vueuse.org/useCounter
892
- * @param [initialValue=0]
893
- */
894
- function useCounter(initialValue = 0) {
895
- const count = vueDemi.ref(initialValue);
896
- const inc = (delta = 1) => (count.value += delta);
897
- const dec = (delta = 1) => (count.value -= delta);
898
- const get = () => count.value;
899
- const set = (val) => (count.value = val);
900
- const reset = (val = initialValue) => {
901
- initialValue = val;
902
- return set(val);
903
- };
904
- return { count, inc, dec, get, set, reset };
877
+ function useDebounce(value, ms = 200) {
878
+ if (ms <= 0)
879
+ return value;
880
+ const debounced = vueDemi.ref(value.value);
881
+ const updater = useDebounceFn(() => {
882
+ debounced.value = value.value;
883
+ }, ms);
884
+ vueDemi.watch(value, () => updater());
885
+ return debounced;
905
886
  }
906
887
 
907
- /**
908
- * Debounce execution of a function.
909
- *
910
- * @param fn A function to be executed after delay milliseconds debounced.
911
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
912
- *
913
- * @return A new, debounce, function.
914
- */
915
- function useDebounceFn(fn, ms = 200) {
916
- return createFilterWrapper(debounceFilter(ms), fn);
888
+ function useIntervalFn(cb, interval = 1e3, options = {}) {
889
+ const {
890
+ immediate = true,
891
+ immediateCallback = false
892
+ } = options;
893
+ let timer = null;
894
+ const isActive = vueDemi.ref(false);
895
+ function clean() {
896
+ if (timer) {
897
+ clearInterval(timer);
898
+ timer = null;
899
+ }
900
+ }
901
+ function pause() {
902
+ isActive.value = false;
903
+ clean();
904
+ }
905
+ function resume() {
906
+ if (interval <= 0)
907
+ return;
908
+ isActive.value = true;
909
+ if (immediateCallback)
910
+ cb();
911
+ clean();
912
+ timer = setInterval(cb, interval);
913
+ }
914
+ if (immediate && isClient)
915
+ resume();
916
+ tryOnScopeDispose(pause);
917
+ return {
918
+ isActive,
919
+ pause,
920
+ resume
921
+ };
917
922
  }
918
923
 
919
- function useDebounce(value, ms = 200) {
920
- if (ms <= 0)
921
- return value;
922
- const debounced = vueDemi.ref(value.value);
923
- const updater = useDebounceFn(() => {
924
- debounced.value = value.value;
925
- }, ms);
926
- vueDemi.watch(value, () => updater());
927
- return debounced;
924
+ var __defProp$1 = Object.defineProperty;
925
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
926
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
927
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
928
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
929
+ var __spreadValues$1 = (a, b) => {
930
+ for (var prop in b || (b = {}))
931
+ if (__hasOwnProp$2.call(b, prop))
932
+ __defNormalProp$1(a, prop, b[prop]);
933
+ if (__getOwnPropSymbols$2)
934
+ for (var prop of __getOwnPropSymbols$2(b)) {
935
+ if (__propIsEnum$2.call(b, prop))
936
+ __defNormalProp$1(a, prop, b[prop]);
937
+ }
938
+ return a;
939
+ };
940
+ function useInterval(interval = 1e3, options = {}) {
941
+ const {
942
+ controls: exposeControls = false,
943
+ immediate = true
944
+ } = options;
945
+ const counter = vueDemi.ref(0);
946
+ const controls = useIntervalFn(() => counter.value += 1, interval, { immediate });
947
+ if (exposeControls) {
948
+ return __spreadValues$1({
949
+ counter
950
+ }, controls);
951
+ } else {
952
+ return counter;
953
+ }
928
954
  }
929
955
 
930
- /**
931
- * Wrapper for `setInterval` with controls
932
- *
933
- * @param cb
934
- * @param interval
935
- * @param options
936
- */
937
- function useIntervalFn(cb, interval = 1000, options = {}) {
938
- const { immediate = true, immediateCallback = false, } = options;
939
- let timer = null;
940
- const isActive = vueDemi.ref(false);
941
- function clean() {
942
- if (timer) {
943
- clearInterval(timer);
944
- timer = null;
945
- }
946
- }
947
- function pause() {
948
- isActive.value = false;
949
- clean();
950
- }
951
- function resume() {
952
- if (interval <= 0)
953
- return;
954
- isActive.value = true;
955
- if (immediateCallback)
956
- cb();
957
- clean();
958
- timer = setInterval(cb, interval);
959
- }
960
- if (immediate && isClient)
961
- resume();
962
- tryOnScopeDispose(pause);
963
- return {
964
- isActive,
965
- pause,
966
- resume,
967
- };
956
+ function useLastChanged(source, options = {}) {
957
+ var _a;
958
+ const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
959
+ vueDemi.watch(source, () => ms.value = timestamp(), options);
960
+ return ms;
968
961
  }
969
962
 
970
- function useInterval(interval = 1000, options = {}) {
971
- const { controls: exposeControls = false, immediate = true, } = options;
972
- const counter = vueDemi.ref(0);
973
- const controls = useIntervalFn(() => counter.value += 1, interval, { immediate });
974
- if (exposeControls) {
975
- return Object.assign({ counter }, controls);
976
- }
977
- else {
978
- return counter;
979
- }
963
+ function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
964
+ return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
980
965
  }
981
966
 
982
- function useLastChanged(source, options = {}) {
983
- var _a;
984
- const ms = vueDemi.ref((_a = options.initialValue) !== null && _a !== void 0 ? _a : null);
985
- vueDemi.watch(source, () => ms.value = timestamp(), options);
986
- return ms;
967
+ function useThrottle(value, delay = 200, trailing = true, leading = true) {
968
+ if (delay <= 0)
969
+ return value;
970
+ const throttled = vueDemi.ref(value.value);
971
+ const updater = useThrottleFn(() => {
972
+ throttled.value = value.value;
973
+ }, delay, trailing, leading);
974
+ vueDemi.watch(value, () => updater());
975
+ return throttled;
987
976
  }
988
977
 
989
- /**
990
- * Throttle execution of a function. Especially useful for rate limiting
991
- * execution of handlers on events like resize and scroll.
992
- *
993
- * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
994
- * to `callback` when the throttled-function is executed.
995
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
996
- *
997
- * @return A new, throttled, function.
998
- */
999
- function useThrottleFn(fn, ms = 200, trailing = true) {
1000
- return createFilterWrapper(throttleFilter(ms, trailing), fn);
978
+ function useTimeoutFn(cb, interval, options = {}) {
979
+ const {
980
+ immediate = true
981
+ } = options;
982
+ const isPending = vueDemi.ref(false);
983
+ let timer = null;
984
+ function clear() {
985
+ if (timer) {
986
+ clearTimeout(timer);
987
+ timer = null;
988
+ }
989
+ }
990
+ function stop() {
991
+ isPending.value = false;
992
+ clear();
993
+ }
994
+ function start(...args) {
995
+ clear();
996
+ isPending.value = true;
997
+ timer = setTimeout(() => {
998
+ isPending.value = false;
999
+ timer = null;
1000
+ cb(...args);
1001
+ }, vueDemi.unref(interval));
1002
+ }
1003
+ if (immediate) {
1004
+ isPending.value = true;
1005
+ if (isClient)
1006
+ start();
1007
+ }
1008
+ tryOnScopeDispose(stop);
1009
+ return {
1010
+ isPending,
1011
+ start,
1012
+ stop
1013
+ };
1001
1014
  }
1002
1015
 
1003
- /**
1004
- * Throttle execution of a function. Especially useful for rate limiting
1005
- * execution of handlers on events like resize and scroll.
1006
- *
1007
- * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
1008
- */
1009
- function useThrottle(value, delay = 200) {
1010
- if (delay <= 0)
1011
- return value;
1012
- const throttled = vueDemi.ref(value.value);
1013
- const updater = useThrottleFn(() => {
1014
- throttled.value = value.value;
1015
- }, delay);
1016
- vueDemi.watch(value, () => updater());
1017
- return throttled;
1016
+ var __defProp = Object.defineProperty;
1017
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1018
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1019
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1020
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1021
+ var __spreadValues = (a, b) => {
1022
+ for (var prop in b || (b = {}))
1023
+ if (__hasOwnProp$1.call(b, prop))
1024
+ __defNormalProp(a, prop, b[prop]);
1025
+ if (__getOwnPropSymbols$1)
1026
+ for (var prop of __getOwnPropSymbols$1(b)) {
1027
+ if (__propIsEnum$1.call(b, prop))
1028
+ __defNormalProp(a, prop, b[prop]);
1029
+ }
1030
+ return a;
1031
+ };
1032
+ function useTimeout(interval = 1e3, options = {}) {
1033
+ const {
1034
+ controls: exposeControls = false
1035
+ } = options;
1036
+ const controls = useTimeoutFn(noop, interval, options);
1037
+ const ready = vueDemi.computed(() => !controls.isPending.value);
1038
+ if (exposeControls) {
1039
+ return __spreadValues({
1040
+ ready
1041
+ }, controls);
1042
+ } else {
1043
+ return ready;
1044
+ }
1018
1045
  }
1019
1046
 
1020
- /**
1021
- * Wrapper for `setTimeout` with controls.
1022
- *
1023
- * @param cb
1024
- * @param interval
1025
- * @param immediate
1026
- */
1027
- function useTimeoutFn(cb, interval, options = {}) {
1028
- const { immediate = true, } = options;
1029
- const isPending = vueDemi.ref(false);
1030
- let timer = null;
1031
- function clear() {
1032
- if (timer) {
1033
- clearTimeout(timer);
1034
- timer = null;
1035
- }
1036
- }
1037
- function stop() {
1038
- isPending.value = false;
1039
- clear();
1040
- }
1041
- function start(...args) {
1042
- clear();
1043
- isPending.value = true;
1044
- timer = setTimeout(() => {
1045
- isPending.value = false;
1046
- timer = null;
1047
- // eslint-disable-next-line node/no-callback-literal
1048
- cb(...args);
1049
- }, vueDemi.unref(interval));
1050
- }
1051
- if (immediate) {
1052
- isPending.value = true;
1053
- if (isClient)
1054
- start();
1055
- }
1056
- tryOnScopeDispose(stop);
1057
- return {
1058
- isPending,
1059
- start,
1060
- stop,
1061
- };
1047
+ function useToggle(initialValue = false) {
1048
+ if (vueDemi.isRef(initialValue)) {
1049
+ return (value) => {
1050
+ initialValue.value = typeof value === "boolean" ? value : !initialValue.value;
1051
+ };
1052
+ } else {
1053
+ const boolean = vueDemi.ref(initialValue);
1054
+ const toggle = (value) => {
1055
+ boolean.value = typeof value === "boolean" ? value : !boolean.value;
1056
+ };
1057
+ return [boolean, toggle];
1058
+ }
1062
1059
  }
1063
1060
 
1064
- function useTimeout(interval = 1000, options = {}) {
1065
- const { controls: exposeControls = false, } = options;
1066
- const controls = useTimeoutFn(noop, interval, options);
1067
- const ready = vueDemi.computed(() => !controls.isPending.value);
1068
- if (exposeControls) {
1069
- return Object.assign({ ready }, controls);
1070
- }
1071
- else {
1072
- return ready;
1073
- }
1061
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1062
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1063
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1064
+ var __objRest = (source, exclude) => {
1065
+ var target = {};
1066
+ for (var prop in source)
1067
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1068
+ target[prop] = source[prop];
1069
+ if (source != null && __getOwnPropSymbols)
1070
+ for (var prop of __getOwnPropSymbols(source)) {
1071
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1072
+ target[prop] = source[prop];
1073
+ }
1074
+ return target;
1075
+ };
1076
+ function watchAtMost(source, cb, options) {
1077
+ const _a = options, {
1078
+ count
1079
+ } = _a, watchOptions = __objRest(_a, [
1080
+ "count"
1081
+ ]);
1082
+ const current = vueDemi.ref(0);
1083
+ const stop = watchWithFilter(source, (...args) => {
1084
+ current.value += 1;
1085
+ if (current.value >= vueDemi.unref(count))
1086
+ stop();
1087
+ cb(...args);
1088
+ }, watchOptions);
1089
+ return { count: current, stop };
1074
1090
  }
1075
1091
 
1076
- function useToggle(initialValue = false) {
1077
- if (vueDemi.isRef(initialValue)) {
1078
- return (value) => {
1079
- initialValue.value = typeof value === 'boolean'
1080
- ? value
1081
- : !initialValue.value;
1082
- };
1083
- }
1084
- else {
1085
- const boolean = vueDemi.ref(initialValue);
1086
- const toggle = (value) => {
1087
- boolean.value = typeof value === 'boolean'
1088
- ? value
1089
- : !boolean.value;
1090
- };
1091
- return [boolean, toggle];
1092
- }
1092
+ function watchOnce(source, cb, options) {
1093
+ const stop = vueDemi.watch(source, (...args) => {
1094
+ stop();
1095
+ return cb(...args);
1096
+ }, options);
1093
1097
  }
1094
1098
 
1095
- /**
1096
- * Shorthand for watching value to be truthy
1097
- *
1098
- * @see https://vueuse.js.org/whenever
1099
- */
1100
- function whenever(source, cb, options) {
1101
- return vueDemi.watch(source, (v, ov, onInvalidate) => { if (v)
1102
- cb(v, ov, onInvalidate); }, options);
1099
+ function whenever(source, cb, options) {
1100
+ return vueDemi.watch(source, (v, ov, onInvalidate) => {
1101
+ if (v)
1102
+ cb(v, ov, onInvalidate);
1103
+ }, options);
1103
1104
  }
1104
1105
 
1105
1106
  exports.and = and;
@@ -1168,5 +1169,7 @@ exports.useThrottleFn = useThrottleFn;
1168
1169
  exports.useTimeout = useTimeout;
1169
1170
  exports.useTimeoutFn = useTimeoutFn;
1170
1171
  exports.useToggle = useToggle;
1172
+ exports.watchAtMost = watchAtMost;
1173
+ exports.watchOnce = watchOnce;
1171
1174
  exports.watchWithFilter = watchWithFilter;
1172
1175
  exports.whenever = whenever;