@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.cjs +1005 -1020
- package/index.d.ts +13 -6
- package/index.iife.js +1006 -1021
- package/index.iife.min.js +1 -1
- package/index.mjs +1005 -1021
- package/package.json +2 -2
package/index.iife.js
CHANGED
|
@@ -62,1119 +62,1103 @@
|
|
|
62
62
|
;(function (exports, vueDemi) {
|
|
63
63
|
'use strict';
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
|
625
|
-
|
|
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
|
-
|
|
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
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
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
|
|
686
|
-
|
|
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
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
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
|
-
|
|
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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
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
|
-
|
|
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
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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
|
-
|
|
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
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
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
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
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
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
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
|
|
1041
|
-
|
|
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
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
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
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
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
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
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
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
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
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
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
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
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
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
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);
|