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