@reactive-vscode/vueuse 0.2.6-beta.1 → 0.2.7-beta.1
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/dist/index.cjs +3365 -0
- package/package.json +9 -8
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactivity = require("@reactive-vscode/reactivity");
|
|
4
|
+
function computedWithControl(source, fn) {
|
|
5
|
+
let v = void 0;
|
|
6
|
+
let track;
|
|
7
|
+
let trigger;
|
|
8
|
+
const dirty = reactivity.ref(true);
|
|
9
|
+
const update = () => {
|
|
10
|
+
dirty.value = true;
|
|
11
|
+
trigger();
|
|
12
|
+
};
|
|
13
|
+
reactivity.watch(source, update, { flush: "sync" });
|
|
14
|
+
const get2 = typeof fn === "function" ? fn : fn.get;
|
|
15
|
+
const set2 = typeof fn === "function" ? void 0 : fn.set;
|
|
16
|
+
const result = reactivity.customRef((_track, _trigger) => {
|
|
17
|
+
track = _track;
|
|
18
|
+
trigger = _trigger;
|
|
19
|
+
return {
|
|
20
|
+
get() {
|
|
21
|
+
if (dirty.value) {
|
|
22
|
+
v = get2(v);
|
|
23
|
+
dirty.value = false;
|
|
24
|
+
}
|
|
25
|
+
track();
|
|
26
|
+
return v;
|
|
27
|
+
},
|
|
28
|
+
set(v2) {
|
|
29
|
+
set2 == null ? void 0 : set2(v2);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
if (Object.isExtensible(result))
|
|
34
|
+
result.trigger = update;
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function tryOnScopeDispose(fn) {
|
|
38
|
+
if (reactivity.getCurrentScope()) {
|
|
39
|
+
reactivity.onScopeDispose(fn);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function createEventHook() {
|
|
45
|
+
const fns = /* @__PURE__ */ new Set();
|
|
46
|
+
const off = (fn) => {
|
|
47
|
+
fns.delete(fn);
|
|
48
|
+
};
|
|
49
|
+
const on = (fn) => {
|
|
50
|
+
fns.add(fn);
|
|
51
|
+
const offFn = () => off(fn);
|
|
52
|
+
tryOnScopeDispose(offFn);
|
|
53
|
+
return {
|
|
54
|
+
off: offFn
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const trigger = (...args) => {
|
|
58
|
+
return Promise.all(Array.from(fns).map((fn) => fn(...args)));
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
on,
|
|
62
|
+
off,
|
|
63
|
+
trigger
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function createGlobalState(stateFactory) {
|
|
67
|
+
let initialized = false;
|
|
68
|
+
let state;
|
|
69
|
+
const scope = reactivity.effectScope(true);
|
|
70
|
+
return (...args) => {
|
|
71
|
+
if (!initialized) {
|
|
72
|
+
state = scope.run(() => stateFactory(...args));
|
|
73
|
+
initialized = true;
|
|
74
|
+
}
|
|
75
|
+
return state;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createSharedComposable(composable) {
|
|
79
|
+
let subscribers = 0;
|
|
80
|
+
let state;
|
|
81
|
+
let scope;
|
|
82
|
+
const dispose = () => {
|
|
83
|
+
subscribers -= 1;
|
|
84
|
+
if (scope && subscribers <= 0) {
|
|
85
|
+
scope.stop();
|
|
86
|
+
state = void 0;
|
|
87
|
+
scope = void 0;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return (...args) => {
|
|
91
|
+
subscribers += 1;
|
|
92
|
+
if (!scope) {
|
|
93
|
+
scope = reactivity.effectScope(true);
|
|
94
|
+
state = scope.run(() => composable(...args));
|
|
95
|
+
}
|
|
96
|
+
tryOnScopeDispose(dispose);
|
|
97
|
+
return state;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
|
|
101
|
+
for (const [key, value] of Object.entries(extend)) {
|
|
102
|
+
if (key === "value")
|
|
103
|
+
continue;
|
|
104
|
+
if (reactivity.isRef(value) && unwrap) {
|
|
105
|
+
Object.defineProperty(ref, key, {
|
|
106
|
+
get() {
|
|
107
|
+
return value.value;
|
|
108
|
+
},
|
|
109
|
+
set(v) {
|
|
110
|
+
value.value = v;
|
|
111
|
+
},
|
|
112
|
+
enumerable
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
Object.defineProperty(ref, key, { value, enumerable });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return ref;
|
|
119
|
+
}
|
|
120
|
+
function get(obj, key) {
|
|
121
|
+
if (key == null)
|
|
122
|
+
return reactivity.unref(obj);
|
|
123
|
+
return reactivity.unref(obj)[key];
|
|
124
|
+
}
|
|
125
|
+
function isDefined(v) {
|
|
126
|
+
return reactivity.unref(v) != null;
|
|
127
|
+
}
|
|
128
|
+
function makeDestructurable(obj, arr) {
|
|
129
|
+
if (typeof Symbol !== "undefined") {
|
|
130
|
+
const clone = { ...obj };
|
|
131
|
+
Object.defineProperty(clone, Symbol.iterator, {
|
|
132
|
+
enumerable: false,
|
|
133
|
+
value() {
|
|
134
|
+
let index = 0;
|
|
135
|
+
return {
|
|
136
|
+
next: () => ({
|
|
137
|
+
value: arr[index++],
|
|
138
|
+
done: index > arr.length
|
|
139
|
+
})
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return clone;
|
|
144
|
+
} else {
|
|
145
|
+
return Object.assign([...arr], obj);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function toValue(r) {
|
|
149
|
+
return typeof r === "function" ? r() : reactivity.unref(r);
|
|
150
|
+
}
|
|
151
|
+
const resolveUnref = toValue;
|
|
152
|
+
function reactify(fn, options) {
|
|
153
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? reactivity.unref : toValue;
|
|
154
|
+
return function(...args) {
|
|
155
|
+
return reactivity.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
159
|
+
let keys = [];
|
|
160
|
+
let options;
|
|
161
|
+
if (Array.isArray(optionsOrKeys)) {
|
|
162
|
+
keys = optionsOrKeys;
|
|
163
|
+
} else {
|
|
164
|
+
options = optionsOrKeys;
|
|
165
|
+
const { includeOwnProperties = true } = optionsOrKeys;
|
|
166
|
+
keys.push(...Object.keys(obj));
|
|
167
|
+
if (includeOwnProperties)
|
|
168
|
+
keys.push(...Object.getOwnPropertyNames(obj));
|
|
169
|
+
}
|
|
170
|
+
return Object.fromEntries(
|
|
171
|
+
keys.map((key) => {
|
|
172
|
+
const value = obj[key];
|
|
173
|
+
return [
|
|
174
|
+
key,
|
|
175
|
+
typeof value === "function" ? reactify(value.bind(obj), options) : value
|
|
176
|
+
];
|
|
177
|
+
})
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
function toReactive(objectRef) {
|
|
181
|
+
if (!reactivity.isRef(objectRef))
|
|
182
|
+
return reactivity.reactive(objectRef);
|
|
183
|
+
const proxy = new Proxy({}, {
|
|
184
|
+
get(_, p, receiver) {
|
|
185
|
+
return reactivity.unref(Reflect.get(objectRef.value, p, receiver));
|
|
186
|
+
},
|
|
187
|
+
set(_, p, value) {
|
|
188
|
+
if (reactivity.isRef(objectRef.value[p]) && !reactivity.isRef(value))
|
|
189
|
+
objectRef.value[p].value = value;
|
|
190
|
+
else
|
|
191
|
+
objectRef.value[p] = value;
|
|
192
|
+
return true;
|
|
193
|
+
},
|
|
194
|
+
deleteProperty(_, p) {
|
|
195
|
+
return Reflect.deleteProperty(objectRef.value, p);
|
|
196
|
+
},
|
|
197
|
+
has(_, p) {
|
|
198
|
+
return Reflect.has(objectRef.value, p);
|
|
199
|
+
},
|
|
200
|
+
ownKeys() {
|
|
201
|
+
return Object.keys(objectRef.value);
|
|
202
|
+
},
|
|
203
|
+
getOwnPropertyDescriptor() {
|
|
204
|
+
return {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
configurable: true
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return reactivity.reactive(proxy);
|
|
211
|
+
}
|
|
212
|
+
function reactiveComputed(fn) {
|
|
213
|
+
return toReactive(reactivity.computed(fn));
|
|
214
|
+
}
|
|
215
|
+
function reactiveOmit(obj, ...keys) {
|
|
216
|
+
const flatKeys = keys.flat();
|
|
217
|
+
const predicate = flatKeys[0];
|
|
218
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
219
|
+
}
|
|
220
|
+
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
221
|
+
const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
222
|
+
const isDef = (val) => typeof val !== "undefined";
|
|
223
|
+
const notNullish = (val) => val != null;
|
|
224
|
+
const assert = (condition, ...infos) => {
|
|
225
|
+
if (!condition)
|
|
226
|
+
console.warn(...infos);
|
|
227
|
+
};
|
|
228
|
+
const toString = Object.prototype.toString;
|
|
229
|
+
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
230
|
+
const now = () => Date.now();
|
|
231
|
+
const timestamp = () => +Date.now();
|
|
232
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
233
|
+
const noop = () => {
|
|
234
|
+
};
|
|
235
|
+
const rand = (min, max) => {
|
|
236
|
+
min = Math.ceil(min);
|
|
237
|
+
max = Math.floor(max);
|
|
238
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
239
|
+
};
|
|
240
|
+
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
241
|
+
function createFilterWrapper(filter, fn) {
|
|
242
|
+
function wrapper(...args) {
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
244
|
+
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return wrapper;
|
|
248
|
+
}
|
|
249
|
+
const bypassFilter = (invoke2) => {
|
|
250
|
+
return invoke2();
|
|
251
|
+
};
|
|
252
|
+
function debounceFilter(ms, options = {}) {
|
|
253
|
+
let timer;
|
|
254
|
+
let maxTimer;
|
|
255
|
+
let lastRejector = noop;
|
|
256
|
+
const _clearTimeout = (timer2) => {
|
|
257
|
+
clearTimeout(timer2);
|
|
258
|
+
lastRejector();
|
|
259
|
+
lastRejector = noop;
|
|
260
|
+
};
|
|
261
|
+
const filter = (invoke2) => {
|
|
262
|
+
const duration = toValue(ms);
|
|
263
|
+
const maxDuration = toValue(options.maxWait);
|
|
264
|
+
if (timer)
|
|
265
|
+
_clearTimeout(timer);
|
|
266
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
267
|
+
if (maxTimer) {
|
|
268
|
+
_clearTimeout(maxTimer);
|
|
269
|
+
maxTimer = null;
|
|
270
|
+
}
|
|
271
|
+
return Promise.resolve(invoke2());
|
|
272
|
+
}
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
275
|
+
if (maxDuration && !maxTimer) {
|
|
276
|
+
maxTimer = setTimeout(() => {
|
|
277
|
+
if (timer)
|
|
278
|
+
_clearTimeout(timer);
|
|
279
|
+
maxTimer = null;
|
|
280
|
+
resolve(invoke2());
|
|
281
|
+
}, maxDuration);
|
|
282
|
+
}
|
|
283
|
+
timer = setTimeout(() => {
|
|
284
|
+
if (maxTimer)
|
|
285
|
+
_clearTimeout(maxTimer);
|
|
286
|
+
maxTimer = null;
|
|
287
|
+
resolve(invoke2());
|
|
288
|
+
}, duration);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
return filter;
|
|
292
|
+
}
|
|
293
|
+
function throttleFilter(...args) {
|
|
294
|
+
let lastExec = 0;
|
|
295
|
+
let timer;
|
|
296
|
+
let isLeading = true;
|
|
297
|
+
let lastRejector = noop;
|
|
298
|
+
let lastValue;
|
|
299
|
+
let ms;
|
|
300
|
+
let trailing;
|
|
301
|
+
let leading;
|
|
302
|
+
let rejectOnCancel;
|
|
303
|
+
if (!reactivity.isRef(args[0]) && typeof args[0] === "object")
|
|
304
|
+
({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
|
|
305
|
+
else
|
|
306
|
+
[ms, trailing = true, leading = true, rejectOnCancel = false] = args;
|
|
307
|
+
const clear = () => {
|
|
308
|
+
if (timer) {
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
timer = void 0;
|
|
311
|
+
lastRejector();
|
|
312
|
+
lastRejector = noop;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const filter = (_invoke) => {
|
|
316
|
+
const duration = toValue(ms);
|
|
317
|
+
const elapsed = Date.now() - lastExec;
|
|
318
|
+
const invoke2 = () => {
|
|
319
|
+
return lastValue = _invoke();
|
|
320
|
+
};
|
|
321
|
+
clear();
|
|
322
|
+
if (duration <= 0) {
|
|
323
|
+
lastExec = Date.now();
|
|
324
|
+
return invoke2();
|
|
325
|
+
}
|
|
326
|
+
if (elapsed > duration && (leading || !isLeading)) {
|
|
327
|
+
lastExec = Date.now();
|
|
328
|
+
invoke2();
|
|
329
|
+
} else if (trailing) {
|
|
330
|
+
lastValue = new Promise((resolve, reject) => {
|
|
331
|
+
lastRejector = rejectOnCancel ? reject : resolve;
|
|
332
|
+
timer = setTimeout(() => {
|
|
333
|
+
lastExec = Date.now();
|
|
334
|
+
isLeading = true;
|
|
335
|
+
resolve(invoke2());
|
|
336
|
+
clear();
|
|
337
|
+
}, Math.max(0, duration - elapsed));
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (!leading && !timer)
|
|
341
|
+
timer = setTimeout(() => isLeading = true, duration);
|
|
342
|
+
isLeading = false;
|
|
343
|
+
return lastValue;
|
|
344
|
+
};
|
|
345
|
+
return filter;
|
|
346
|
+
}
|
|
347
|
+
function pausableFilter(extendFilter = bypassFilter) {
|
|
348
|
+
const isActive = reactivity.ref(true);
|
|
349
|
+
function pause() {
|
|
350
|
+
isActive.value = false;
|
|
351
|
+
}
|
|
352
|
+
function resume() {
|
|
353
|
+
isActive.value = true;
|
|
354
|
+
}
|
|
355
|
+
const eventFilter = (...args) => {
|
|
356
|
+
if (isActive.value)
|
|
357
|
+
extendFilter(...args);
|
|
358
|
+
};
|
|
359
|
+
return { isActive: reactivity.readonly(isActive), pause, resume, eventFilter };
|
|
360
|
+
}
|
|
361
|
+
function cacheStringFunction(fn) {
|
|
362
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
363
|
+
return (str) => {
|
|
364
|
+
const hit = cache[str];
|
|
365
|
+
return hit || (cache[str] = fn(str));
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const hyphenateRE = /\B([A-Z])/g;
|
|
369
|
+
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
370
|
+
const camelizeRE = /-(\w)/g;
|
|
371
|
+
const camelize = cacheStringFunction((str) => {
|
|
372
|
+
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
373
|
+
});
|
|
374
|
+
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
375
|
+
return new Promise((resolve, reject) => {
|
|
376
|
+
if (throwOnTimeout)
|
|
377
|
+
setTimeout(() => reject(reason), ms);
|
|
378
|
+
else
|
|
379
|
+
setTimeout(resolve, ms);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function identity(arg) {
|
|
383
|
+
return arg;
|
|
384
|
+
}
|
|
385
|
+
function createSingletonPromise(fn) {
|
|
386
|
+
let _promise;
|
|
387
|
+
function wrapper() {
|
|
388
|
+
if (!_promise)
|
|
389
|
+
_promise = fn();
|
|
390
|
+
return _promise;
|
|
391
|
+
}
|
|
392
|
+
wrapper.reset = async () => {
|
|
393
|
+
const _prev = _promise;
|
|
394
|
+
_promise = void 0;
|
|
395
|
+
if (_prev)
|
|
396
|
+
await _prev;
|
|
397
|
+
};
|
|
398
|
+
return wrapper;
|
|
399
|
+
}
|
|
400
|
+
function invoke(fn) {
|
|
401
|
+
return fn();
|
|
402
|
+
}
|
|
403
|
+
function containsProp(obj, ...props) {
|
|
404
|
+
return props.some((k) => k in obj);
|
|
405
|
+
}
|
|
406
|
+
function increaseWithUnit(target, delta) {
|
|
407
|
+
var _a;
|
|
408
|
+
if (typeof target === "number")
|
|
409
|
+
return target + delta;
|
|
410
|
+
const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
|
|
411
|
+
const unit = target.slice(value.length);
|
|
412
|
+
const result = Number.parseFloat(value) + delta;
|
|
413
|
+
if (Number.isNaN(result))
|
|
414
|
+
return target;
|
|
415
|
+
return result + unit;
|
|
416
|
+
}
|
|
417
|
+
function objectPick(obj, keys, omitUndefined = false) {
|
|
418
|
+
return keys.reduce((n, k) => {
|
|
419
|
+
if (k in obj) {
|
|
420
|
+
if (!omitUndefined || obj[k] !== void 0)
|
|
421
|
+
n[k] = obj[k];
|
|
422
|
+
}
|
|
423
|
+
return n;
|
|
424
|
+
}, {});
|
|
425
|
+
}
|
|
426
|
+
function objectOmit(obj, keys, omitUndefined = false) {
|
|
427
|
+
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
428
|
+
return (!omitUndefined || value !== void 0) && !keys.includes(key);
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
function objectEntries(obj) {
|
|
432
|
+
return Object.entries(obj);
|
|
433
|
+
}
|
|
434
|
+
function getLifeCycleTarget(target) {
|
|
435
|
+
return target || null;
|
|
436
|
+
}
|
|
437
|
+
function toRef(...args) {
|
|
438
|
+
if (args.length !== 1)
|
|
439
|
+
return reactivity.toRef(...args);
|
|
440
|
+
const r = args[0];
|
|
441
|
+
return typeof r === "function" ? reactivity.readonly(reactivity.customRef(() => ({ get: r, set: noop }))) : reactivity.ref(r);
|
|
442
|
+
}
|
|
443
|
+
const resolveRef = toRef;
|
|
444
|
+
function reactivePick(obj, ...keys) {
|
|
445
|
+
const flatKeys = keys.flat();
|
|
446
|
+
const predicate = flatKeys[0];
|
|
447
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
448
|
+
}
|
|
449
|
+
function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
450
|
+
return reactivity.customRef((track, trigger) => {
|
|
451
|
+
let value = toValue(defaultValue);
|
|
452
|
+
let timer;
|
|
453
|
+
const resetAfter = () => setTimeout(() => {
|
|
454
|
+
value = toValue(defaultValue);
|
|
455
|
+
trigger();
|
|
456
|
+
}, toValue(afterMs));
|
|
457
|
+
tryOnScopeDispose(() => {
|
|
458
|
+
clearTimeout(timer);
|
|
459
|
+
});
|
|
460
|
+
return {
|
|
461
|
+
get() {
|
|
462
|
+
track();
|
|
463
|
+
return value;
|
|
464
|
+
},
|
|
465
|
+
set(newValue) {
|
|
466
|
+
value = newValue;
|
|
467
|
+
trigger();
|
|
468
|
+
clearTimeout(timer);
|
|
469
|
+
timer = resetAfter();
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
475
|
+
return createFilterWrapper(
|
|
476
|
+
debounceFilter(ms, options),
|
|
477
|
+
fn
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
function refDebounced(value, ms = 200, options = {}) {
|
|
481
|
+
const debounced = reactivity.ref(value.value);
|
|
482
|
+
const updater = useDebounceFn(() => {
|
|
483
|
+
debounced.value = value.value;
|
|
484
|
+
}, ms, options);
|
|
485
|
+
reactivity.watch(value, () => updater());
|
|
486
|
+
return debounced;
|
|
487
|
+
}
|
|
488
|
+
function refDefault(source, defaultValue) {
|
|
489
|
+
return reactivity.computed({
|
|
490
|
+
get() {
|
|
491
|
+
var _a;
|
|
492
|
+
return (_a = source.value) != null ? _a : defaultValue;
|
|
493
|
+
},
|
|
494
|
+
set(value) {
|
|
495
|
+
source.value = value;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
|
|
500
|
+
return createFilterWrapper(
|
|
501
|
+
throttleFilter(ms, trailing, leading, rejectOnCancel),
|
|
502
|
+
fn
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
function refThrottled(value, delay = 200, trailing = true, leading = true) {
|
|
506
|
+
if (delay <= 0)
|
|
507
|
+
return value;
|
|
508
|
+
const throttled = reactivity.ref(value.value);
|
|
509
|
+
const updater = useThrottleFn(() => {
|
|
510
|
+
throttled.value = value.value;
|
|
511
|
+
}, delay, trailing, leading);
|
|
512
|
+
reactivity.watch(value, () => updater());
|
|
513
|
+
return throttled;
|
|
514
|
+
}
|
|
515
|
+
function refWithControl(initial, options = {}) {
|
|
516
|
+
let source = initial;
|
|
517
|
+
let track;
|
|
518
|
+
let trigger;
|
|
519
|
+
const ref = reactivity.customRef((_track, _trigger) => {
|
|
520
|
+
track = _track;
|
|
521
|
+
trigger = _trigger;
|
|
522
|
+
return {
|
|
523
|
+
get() {
|
|
524
|
+
return get2();
|
|
525
|
+
},
|
|
526
|
+
set(v) {
|
|
527
|
+
set2(v);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
});
|
|
531
|
+
function get2(tracking = true) {
|
|
532
|
+
if (tracking)
|
|
533
|
+
track();
|
|
534
|
+
return source;
|
|
535
|
+
}
|
|
536
|
+
function set2(value, triggering = true) {
|
|
537
|
+
var _a, _b;
|
|
538
|
+
if (value === source)
|
|
539
|
+
return;
|
|
540
|
+
const old = source;
|
|
541
|
+
if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
|
|
542
|
+
return;
|
|
543
|
+
source = value;
|
|
544
|
+
(_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
|
|
545
|
+
if (triggering)
|
|
546
|
+
trigger();
|
|
547
|
+
}
|
|
548
|
+
const untrackedGet = () => get2(false);
|
|
549
|
+
const silentSet = (v) => set2(v, false);
|
|
550
|
+
const peek = () => get2(false);
|
|
551
|
+
const lay = (v) => set2(v, false);
|
|
552
|
+
return extendRef(
|
|
553
|
+
ref,
|
|
554
|
+
{
|
|
555
|
+
get: get2,
|
|
556
|
+
set: set2,
|
|
557
|
+
untrackedGet,
|
|
558
|
+
silentSet,
|
|
559
|
+
peek,
|
|
560
|
+
lay
|
|
561
|
+
},
|
|
562
|
+
{ enumerable: true }
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
const controlledRef = refWithControl;
|
|
566
|
+
function set(...args) {
|
|
567
|
+
if (args.length === 2) {
|
|
568
|
+
const [ref, value] = args;
|
|
569
|
+
ref.value = value;
|
|
570
|
+
}
|
|
571
|
+
if (args.length === 3) {
|
|
572
|
+
{
|
|
573
|
+
const [target, key, value] = args;
|
|
574
|
+
target[key] = value;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function watchWithFilter(source, cb, options = {}) {
|
|
579
|
+
const {
|
|
580
|
+
eventFilter = bypassFilter,
|
|
581
|
+
...watchOptions
|
|
582
|
+
} = options;
|
|
583
|
+
return reactivity.watch(
|
|
584
|
+
source,
|
|
585
|
+
createFilterWrapper(
|
|
586
|
+
eventFilter,
|
|
587
|
+
cb
|
|
588
|
+
),
|
|
589
|
+
watchOptions
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
function watchPausable(source, cb, options = {}) {
|
|
593
|
+
const {
|
|
594
|
+
eventFilter: filter,
|
|
595
|
+
...watchOptions
|
|
596
|
+
} = options;
|
|
597
|
+
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
|
|
598
|
+
const stop = watchWithFilter(
|
|
599
|
+
source,
|
|
600
|
+
cb,
|
|
601
|
+
{
|
|
602
|
+
...watchOptions,
|
|
603
|
+
eventFilter
|
|
604
|
+
}
|
|
605
|
+
);
|
|
606
|
+
return { stop, pause, resume, isActive };
|
|
607
|
+
}
|
|
608
|
+
function syncRef(left, right, ...[options]) {
|
|
609
|
+
const {
|
|
610
|
+
flush = "sync",
|
|
611
|
+
deep = false,
|
|
612
|
+
immediate = true,
|
|
613
|
+
direction = "both",
|
|
614
|
+
transform = {}
|
|
615
|
+
} = options || {};
|
|
616
|
+
const watchers = [];
|
|
617
|
+
const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
|
|
618
|
+
const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
|
|
619
|
+
if (direction === "both" || direction === "ltr") {
|
|
620
|
+
watchers.push(watchPausable(
|
|
621
|
+
left,
|
|
622
|
+
(newValue) => {
|
|
623
|
+
watchers.forEach((w) => w.pause());
|
|
624
|
+
right.value = transformLTR(newValue);
|
|
625
|
+
watchers.forEach((w) => w.resume());
|
|
626
|
+
},
|
|
627
|
+
{ flush, deep, immediate }
|
|
628
|
+
));
|
|
629
|
+
}
|
|
630
|
+
if (direction === "both" || direction === "rtl") {
|
|
631
|
+
watchers.push(watchPausable(
|
|
632
|
+
right,
|
|
633
|
+
(newValue) => {
|
|
634
|
+
watchers.forEach((w) => w.pause());
|
|
635
|
+
left.value = transformRTL(newValue);
|
|
636
|
+
watchers.forEach((w) => w.resume());
|
|
637
|
+
},
|
|
638
|
+
{ flush, deep, immediate }
|
|
639
|
+
));
|
|
640
|
+
}
|
|
641
|
+
const stop = () => {
|
|
642
|
+
watchers.forEach((w) => w.stop());
|
|
643
|
+
};
|
|
644
|
+
return stop;
|
|
645
|
+
}
|
|
646
|
+
function syncRefs(source, targets, options = {}) {
|
|
647
|
+
const {
|
|
648
|
+
flush = "sync",
|
|
649
|
+
deep = false,
|
|
650
|
+
immediate = true
|
|
651
|
+
} = options;
|
|
652
|
+
if (!Array.isArray(targets))
|
|
653
|
+
targets = [targets];
|
|
654
|
+
return reactivity.watch(
|
|
655
|
+
source,
|
|
656
|
+
(newValue) => targets.forEach((target) => target.value = newValue),
|
|
657
|
+
{ flush, deep, immediate }
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
function toRefs(objectRef, options = {}) {
|
|
661
|
+
if (!reactivity.isRef(objectRef))
|
|
662
|
+
return reactivity.toRefs(objectRef);
|
|
663
|
+
const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
|
|
664
|
+
for (const key in objectRef.value) {
|
|
665
|
+
result[key] = reactivity.customRef(() => ({
|
|
666
|
+
get() {
|
|
667
|
+
return objectRef.value[key];
|
|
668
|
+
},
|
|
669
|
+
set(v) {
|
|
670
|
+
var _a;
|
|
671
|
+
const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
|
|
672
|
+
if (replaceRef) {
|
|
673
|
+
if (Array.isArray(objectRef.value)) {
|
|
674
|
+
const copy = [...objectRef.value];
|
|
675
|
+
copy[key] = v;
|
|
676
|
+
objectRef.value = copy;
|
|
677
|
+
} else {
|
|
678
|
+
const newObject = { ...objectRef.value, [key]: v };
|
|
679
|
+
Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
|
|
680
|
+
objectRef.value = newObject;
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
objectRef.value[key] = v;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}));
|
|
687
|
+
}
|
|
688
|
+
return result;
|
|
689
|
+
}
|
|
690
|
+
function tryOnMounted(fn, sync = true, target) {
|
|
691
|
+
if (sync)
|
|
692
|
+
fn();
|
|
693
|
+
else
|
|
694
|
+
reactivity.nextTick(fn);
|
|
695
|
+
}
|
|
696
|
+
function createUntil(r, isNot = false) {
|
|
697
|
+
function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
|
|
698
|
+
let stop = null;
|
|
699
|
+
const watcher = new Promise((resolve) => {
|
|
700
|
+
stop = reactivity.watch(
|
|
701
|
+
r,
|
|
702
|
+
(v) => {
|
|
703
|
+
if (condition(v) !== isNot) {
|
|
704
|
+
if (stop)
|
|
705
|
+
stop();
|
|
706
|
+
else
|
|
707
|
+
reactivity.nextTick(() => stop == null ? void 0 : stop());
|
|
708
|
+
resolve(v);
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
flush,
|
|
713
|
+
deep,
|
|
714
|
+
immediate: true
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
});
|
|
718
|
+
const promises = [watcher];
|
|
719
|
+
if (timeout != null) {
|
|
720
|
+
promises.push(
|
|
721
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
return Promise.race(promises);
|
|
725
|
+
}
|
|
726
|
+
function toBe(value, options) {
|
|
727
|
+
if (!reactivity.isRef(value))
|
|
728
|
+
return toMatch((v) => v === value, options);
|
|
729
|
+
const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
|
|
730
|
+
let stop = null;
|
|
731
|
+
const watcher = new Promise((resolve) => {
|
|
732
|
+
stop = reactivity.watch(
|
|
733
|
+
[r, value],
|
|
734
|
+
([v1, v2]) => {
|
|
735
|
+
if (isNot !== (v1 === v2)) {
|
|
736
|
+
if (stop)
|
|
737
|
+
stop();
|
|
738
|
+
else
|
|
739
|
+
reactivity.nextTick(() => stop == null ? void 0 : stop());
|
|
740
|
+
resolve(v1);
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
flush,
|
|
745
|
+
deep,
|
|
746
|
+
immediate: true
|
|
747
|
+
}
|
|
748
|
+
);
|
|
749
|
+
});
|
|
750
|
+
const promises = [watcher];
|
|
751
|
+
if (timeout != null) {
|
|
752
|
+
promises.push(
|
|
753
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
|
|
754
|
+
stop == null ? void 0 : stop();
|
|
755
|
+
return toValue(r);
|
|
756
|
+
})
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
return Promise.race(promises);
|
|
760
|
+
}
|
|
761
|
+
function toBeTruthy(options) {
|
|
762
|
+
return toMatch((v) => Boolean(v), options);
|
|
763
|
+
}
|
|
764
|
+
function toBeNull(options) {
|
|
765
|
+
return toBe(null, options);
|
|
766
|
+
}
|
|
767
|
+
function toBeUndefined(options) {
|
|
768
|
+
return toBe(void 0, options);
|
|
769
|
+
}
|
|
770
|
+
function toBeNaN(options) {
|
|
771
|
+
return toMatch(Number.isNaN, options);
|
|
772
|
+
}
|
|
773
|
+
function toContains(value, options) {
|
|
774
|
+
return toMatch((v) => {
|
|
775
|
+
const array = Array.from(v);
|
|
776
|
+
return array.includes(value) || array.includes(toValue(value));
|
|
777
|
+
}, options);
|
|
778
|
+
}
|
|
779
|
+
function changed(options) {
|
|
780
|
+
return changedTimes(1, options);
|
|
781
|
+
}
|
|
782
|
+
function changedTimes(n = 1, options) {
|
|
783
|
+
let count = -1;
|
|
784
|
+
return toMatch(() => {
|
|
785
|
+
count += 1;
|
|
786
|
+
return count >= n;
|
|
787
|
+
}, options);
|
|
788
|
+
}
|
|
789
|
+
if (Array.isArray(toValue(r))) {
|
|
790
|
+
const instance = {
|
|
791
|
+
toMatch,
|
|
792
|
+
toContains,
|
|
793
|
+
changed,
|
|
794
|
+
changedTimes,
|
|
795
|
+
get not() {
|
|
796
|
+
return createUntil(r, !isNot);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
return instance;
|
|
800
|
+
} else {
|
|
801
|
+
const instance = {
|
|
802
|
+
toMatch,
|
|
803
|
+
toBe,
|
|
804
|
+
toBeTruthy,
|
|
805
|
+
toBeNull,
|
|
806
|
+
toBeNaN,
|
|
807
|
+
toBeUndefined,
|
|
808
|
+
changed,
|
|
809
|
+
changedTimes,
|
|
810
|
+
get not() {
|
|
811
|
+
return createUntil(r, !isNot);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
return instance;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function until(r) {
|
|
818
|
+
return createUntil(r);
|
|
819
|
+
}
|
|
820
|
+
function defaultComparator(value, othVal) {
|
|
821
|
+
return value === othVal;
|
|
822
|
+
}
|
|
823
|
+
function useArrayDifference(...args) {
|
|
824
|
+
var _a;
|
|
825
|
+
const list = args[0];
|
|
826
|
+
const values = args[1];
|
|
827
|
+
let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
|
|
828
|
+
if (typeof compareFn === "string") {
|
|
829
|
+
const key = compareFn;
|
|
830
|
+
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
831
|
+
}
|
|
832
|
+
return reactivity.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
|
|
833
|
+
}
|
|
834
|
+
function useArrayEvery(list, fn) {
|
|
835
|
+
return reactivity.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
|
|
836
|
+
}
|
|
837
|
+
function useArrayFilter(list, fn) {
|
|
838
|
+
return reactivity.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
|
|
839
|
+
}
|
|
840
|
+
function useArrayFind(list, fn) {
|
|
841
|
+
return reactivity.computed(() => toValue(
|
|
842
|
+
toValue(list).find((element, index, array) => fn(toValue(element), index, array))
|
|
843
|
+
));
|
|
844
|
+
}
|
|
845
|
+
function useArrayFindIndex(list, fn) {
|
|
846
|
+
return reactivity.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
|
|
847
|
+
}
|
|
848
|
+
function findLast(arr, cb) {
|
|
849
|
+
let index = arr.length;
|
|
850
|
+
while (index-- > 0) {
|
|
851
|
+
if (cb(arr[index], index, arr))
|
|
852
|
+
return arr[index];
|
|
853
|
+
}
|
|
854
|
+
return void 0;
|
|
855
|
+
}
|
|
856
|
+
function useArrayFindLast(list, fn) {
|
|
857
|
+
return reactivity.computed(() => toValue(
|
|
858
|
+
!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
|
|
859
|
+
));
|
|
860
|
+
}
|
|
861
|
+
function isArrayIncludesOptions(obj) {
|
|
862
|
+
return isObject(obj) && containsProp(obj, "formIndex", "comparator");
|
|
863
|
+
}
|
|
864
|
+
function useArrayIncludes(...args) {
|
|
865
|
+
var _a;
|
|
866
|
+
const list = args[0];
|
|
867
|
+
const value = args[1];
|
|
868
|
+
let comparator = args[2];
|
|
869
|
+
let formIndex = 0;
|
|
870
|
+
if (isArrayIncludesOptions(comparator)) {
|
|
871
|
+
formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
|
|
872
|
+
comparator = comparator.comparator;
|
|
873
|
+
}
|
|
874
|
+
if (typeof comparator === "string") {
|
|
875
|
+
const key = comparator;
|
|
876
|
+
comparator = (element, value2) => element[key] === toValue(value2);
|
|
877
|
+
}
|
|
878
|
+
comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
|
|
879
|
+
return reactivity.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
880
|
+
toValue(element),
|
|
881
|
+
toValue(value),
|
|
882
|
+
index,
|
|
883
|
+
toValue(array)
|
|
884
|
+
)));
|
|
885
|
+
}
|
|
886
|
+
function useArrayJoin(list, separator) {
|
|
887
|
+
return reactivity.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
|
|
888
|
+
}
|
|
889
|
+
function useArrayMap(list, fn) {
|
|
890
|
+
return reactivity.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
|
|
891
|
+
}
|
|
892
|
+
function useArrayReduce(list, reducer, ...args) {
|
|
893
|
+
const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
|
|
894
|
+
return reactivity.computed(() => {
|
|
895
|
+
const resolved = toValue(list);
|
|
896
|
+
return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
function useArraySome(list, fn) {
|
|
900
|
+
return reactivity.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
|
|
901
|
+
}
|
|
902
|
+
function uniq(array) {
|
|
903
|
+
return Array.from(new Set(array));
|
|
904
|
+
}
|
|
905
|
+
function uniqueElementsBy(array, fn) {
|
|
906
|
+
return array.reduce((acc, v) => {
|
|
907
|
+
if (!acc.some((x) => fn(v, x, array)))
|
|
908
|
+
acc.push(v);
|
|
909
|
+
return acc;
|
|
910
|
+
}, []);
|
|
911
|
+
}
|
|
912
|
+
function useArrayUnique(list, compareFn) {
|
|
913
|
+
return reactivity.computed(() => {
|
|
914
|
+
const resolvedList = toValue(list).map((element) => toValue(element));
|
|
915
|
+
return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
function useCounter(initialValue = 0, options = {}) {
|
|
919
|
+
let _initialValue = reactivity.unref(initialValue);
|
|
920
|
+
const count = reactivity.ref(initialValue);
|
|
921
|
+
const {
|
|
922
|
+
max = Number.POSITIVE_INFINITY,
|
|
923
|
+
min = Number.NEGATIVE_INFINITY
|
|
924
|
+
} = options;
|
|
925
|
+
const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
|
|
926
|
+
const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
|
|
927
|
+
const get2 = () => count.value;
|
|
928
|
+
const set2 = (val) => count.value = Math.max(min, Math.min(max, val));
|
|
929
|
+
const reset = (val = _initialValue) => {
|
|
930
|
+
_initialValue = val;
|
|
931
|
+
return set2(val);
|
|
932
|
+
};
|
|
933
|
+
return { count, inc, dec, get: get2, set: set2, reset };
|
|
934
|
+
}
|
|
935
|
+
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
|
936
|
+
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
937
|
+
function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
|
|
938
|
+
let m = hours < 12 ? "AM" : "PM";
|
|
939
|
+
if (hasPeriod)
|
|
940
|
+
m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
|
|
941
|
+
return isLowercase ? m.toLowerCase() : m;
|
|
942
|
+
}
|
|
943
|
+
function formatOrdinal(num) {
|
|
944
|
+
const suffixes = ["th", "st", "nd", "rd"];
|
|
945
|
+
const v = num % 100;
|
|
946
|
+
return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
|
|
947
|
+
}
|
|
948
|
+
function formatDate(date, formatStr, options = {}) {
|
|
949
|
+
var _a;
|
|
950
|
+
const years = date.getFullYear();
|
|
951
|
+
const month = date.getMonth();
|
|
952
|
+
const days = date.getDate();
|
|
953
|
+
const hours = date.getHours();
|
|
954
|
+
const minutes = date.getMinutes();
|
|
955
|
+
const seconds = date.getSeconds();
|
|
956
|
+
const milliseconds = date.getMilliseconds();
|
|
957
|
+
const day = date.getDay();
|
|
958
|
+
const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
|
|
959
|
+
const matches = {
|
|
960
|
+
Yo: () => formatOrdinal(years),
|
|
961
|
+
YY: () => String(years).slice(-2),
|
|
962
|
+
YYYY: () => years,
|
|
963
|
+
M: () => month + 1,
|
|
964
|
+
Mo: () => formatOrdinal(month + 1),
|
|
965
|
+
MM: () => `${month + 1}`.padStart(2, "0"),
|
|
966
|
+
MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
|
|
967
|
+
MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
|
|
968
|
+
D: () => String(days),
|
|
969
|
+
Do: () => formatOrdinal(days),
|
|
970
|
+
DD: () => `${days}`.padStart(2, "0"),
|
|
971
|
+
H: () => String(hours),
|
|
972
|
+
Ho: () => formatOrdinal(hours),
|
|
973
|
+
HH: () => `${hours}`.padStart(2, "0"),
|
|
974
|
+
h: () => `${hours % 12 || 12}`.padStart(1, "0"),
|
|
975
|
+
ho: () => formatOrdinal(hours % 12 || 12),
|
|
976
|
+
hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
|
|
977
|
+
m: () => String(minutes),
|
|
978
|
+
mo: () => formatOrdinal(minutes),
|
|
979
|
+
mm: () => `${minutes}`.padStart(2, "0"),
|
|
980
|
+
s: () => String(seconds),
|
|
981
|
+
so: () => formatOrdinal(seconds),
|
|
982
|
+
ss: () => `${seconds}`.padStart(2, "0"),
|
|
983
|
+
SSS: () => `${milliseconds}`.padStart(3, "0"),
|
|
984
|
+
d: () => day,
|
|
985
|
+
dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
|
|
986
|
+
ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
|
|
987
|
+
dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
|
|
988
|
+
A: () => meridiem(hours, minutes),
|
|
989
|
+
AA: () => meridiem(hours, minutes, false, true),
|
|
990
|
+
a: () => meridiem(hours, minutes, true),
|
|
991
|
+
aa: () => meridiem(hours, minutes, true, true)
|
|
992
|
+
};
|
|
993
|
+
return formatStr.replace(REGEX_FORMAT, (match, $1) => {
|
|
994
|
+
var _a2, _b;
|
|
995
|
+
return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
function normalizeDate(date) {
|
|
999
|
+
if (date === null)
|
|
1000
|
+
return new Date(Number.NaN);
|
|
1001
|
+
if (date === void 0)
|
|
1002
|
+
return /* @__PURE__ */ new Date();
|
|
1003
|
+
if (date instanceof Date)
|
|
1004
|
+
return new Date(date);
|
|
1005
|
+
if (typeof date === "string" && !/Z$/i.test(date)) {
|
|
1006
|
+
const d = date.match(REGEX_PARSE);
|
|
1007
|
+
if (d) {
|
|
1008
|
+
const m = d[2] - 1 || 0;
|
|
1009
|
+
const ms = (d[7] || "0").substring(0, 3);
|
|
1010
|
+
return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return new Date(date);
|
|
1014
|
+
}
|
|
1015
|
+
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1016
|
+
return reactivity.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
|
|
1017
|
+
}
|
|
1018
|
+
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
1019
|
+
const {
|
|
1020
|
+
immediate = true,
|
|
1021
|
+
immediateCallback = false
|
|
1022
|
+
} = options;
|
|
1023
|
+
let timer = null;
|
|
1024
|
+
const isActive = reactivity.ref(false);
|
|
1025
|
+
function clean() {
|
|
1026
|
+
if (timer) {
|
|
1027
|
+
clearInterval(timer);
|
|
1028
|
+
timer = null;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
function pause() {
|
|
1032
|
+
isActive.value = false;
|
|
1033
|
+
clean();
|
|
1034
|
+
}
|
|
1035
|
+
function resume() {
|
|
1036
|
+
const intervalValue = toValue(interval);
|
|
1037
|
+
if (intervalValue <= 0)
|
|
1038
|
+
return;
|
|
1039
|
+
isActive.value = true;
|
|
1040
|
+
if (immediateCallback)
|
|
1041
|
+
cb();
|
|
1042
|
+
clean();
|
|
1043
|
+
timer = setInterval(cb, intervalValue);
|
|
1044
|
+
}
|
|
1045
|
+
if (immediate && isClient)
|
|
1046
|
+
resume();
|
|
1047
|
+
if (reactivity.isRef(interval) || typeof interval === "function") {
|
|
1048
|
+
const stopWatch = reactivity.watch(interval, () => {
|
|
1049
|
+
if (isActive.value && isClient)
|
|
1050
|
+
resume();
|
|
1051
|
+
});
|
|
1052
|
+
tryOnScopeDispose(stopWatch);
|
|
1053
|
+
}
|
|
1054
|
+
tryOnScopeDispose(pause);
|
|
1055
|
+
return {
|
|
1056
|
+
isActive,
|
|
1057
|
+
pause,
|
|
1058
|
+
resume
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function useInterval(interval = 1e3, options = {}) {
|
|
1062
|
+
const {
|
|
1063
|
+
controls: exposeControls = false,
|
|
1064
|
+
immediate = true,
|
|
1065
|
+
callback
|
|
1066
|
+
} = options;
|
|
1067
|
+
const counter = reactivity.ref(0);
|
|
1068
|
+
const update = () => counter.value += 1;
|
|
1069
|
+
const reset = () => {
|
|
1070
|
+
counter.value = 0;
|
|
1071
|
+
};
|
|
1072
|
+
const controls = useIntervalFn(
|
|
1073
|
+
callback ? () => {
|
|
1074
|
+
update();
|
|
1075
|
+
callback(counter.value);
|
|
1076
|
+
} : update,
|
|
1077
|
+
interval,
|
|
1078
|
+
{ immediate }
|
|
1079
|
+
);
|
|
1080
|
+
if (exposeControls) {
|
|
1081
|
+
return {
|
|
1082
|
+
counter,
|
|
1083
|
+
reset,
|
|
1084
|
+
...controls
|
|
1085
|
+
};
|
|
1086
|
+
} else {
|
|
1087
|
+
return counter;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function useLastChanged(source, options = {}) {
|
|
1091
|
+
var _a;
|
|
1092
|
+
const ms = reactivity.ref((_a = options.initialValue) != null ? _a : null);
|
|
1093
|
+
reactivity.watch(
|
|
1094
|
+
source,
|
|
1095
|
+
() => ms.value = timestamp(),
|
|
1096
|
+
options
|
|
1097
|
+
);
|
|
1098
|
+
return ms;
|
|
1099
|
+
}
|
|
1100
|
+
function useTimeoutFn(cb, interval, options = {}) {
|
|
1101
|
+
const {
|
|
1102
|
+
immediate = true
|
|
1103
|
+
} = options;
|
|
1104
|
+
const isPending = reactivity.ref(false);
|
|
1105
|
+
let timer = null;
|
|
1106
|
+
function clear() {
|
|
1107
|
+
if (timer) {
|
|
1108
|
+
clearTimeout(timer);
|
|
1109
|
+
timer = null;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
function stop() {
|
|
1113
|
+
isPending.value = false;
|
|
1114
|
+
clear();
|
|
1115
|
+
}
|
|
1116
|
+
function start(...args) {
|
|
1117
|
+
clear();
|
|
1118
|
+
isPending.value = true;
|
|
1119
|
+
timer = setTimeout(() => {
|
|
1120
|
+
isPending.value = false;
|
|
1121
|
+
timer = null;
|
|
1122
|
+
cb(...args);
|
|
1123
|
+
}, toValue(interval));
|
|
1124
|
+
}
|
|
1125
|
+
if (immediate) {
|
|
1126
|
+
isPending.value = true;
|
|
1127
|
+
if (isClient)
|
|
1128
|
+
start();
|
|
1129
|
+
}
|
|
1130
|
+
tryOnScopeDispose(stop);
|
|
1131
|
+
return {
|
|
1132
|
+
isPending: reactivity.readonly(isPending),
|
|
1133
|
+
start,
|
|
1134
|
+
stop
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function useTimeout(interval = 1e3, options = {}) {
|
|
1138
|
+
const {
|
|
1139
|
+
controls: exposeControls = false,
|
|
1140
|
+
callback
|
|
1141
|
+
} = options;
|
|
1142
|
+
const controls = useTimeoutFn(
|
|
1143
|
+
callback != null ? callback : noop,
|
|
1144
|
+
interval,
|
|
1145
|
+
options
|
|
1146
|
+
);
|
|
1147
|
+
const ready = reactivity.computed(() => !controls.isPending.value);
|
|
1148
|
+
if (exposeControls) {
|
|
1149
|
+
return {
|
|
1150
|
+
ready,
|
|
1151
|
+
...controls
|
|
1152
|
+
};
|
|
1153
|
+
} else {
|
|
1154
|
+
return ready;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
function useToNumber(value, options = {}) {
|
|
1158
|
+
const {
|
|
1159
|
+
method = "parseFloat",
|
|
1160
|
+
radix,
|
|
1161
|
+
nanToZero
|
|
1162
|
+
} = options;
|
|
1163
|
+
return reactivity.computed(() => {
|
|
1164
|
+
let resolved = toValue(value);
|
|
1165
|
+
if (typeof resolved === "string")
|
|
1166
|
+
resolved = Number[method](resolved, radix);
|
|
1167
|
+
if (nanToZero && Number.isNaN(resolved))
|
|
1168
|
+
resolved = 0;
|
|
1169
|
+
return resolved;
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
function useToString(value) {
|
|
1173
|
+
return reactivity.computed(() => `${toValue(value)}`);
|
|
1174
|
+
}
|
|
1175
|
+
function useToggle(initialValue = false, options = {}) {
|
|
1176
|
+
const {
|
|
1177
|
+
truthyValue = true,
|
|
1178
|
+
falsyValue = false
|
|
1179
|
+
} = options;
|
|
1180
|
+
const valueIsRef = reactivity.isRef(initialValue);
|
|
1181
|
+
const _value = reactivity.ref(initialValue);
|
|
1182
|
+
function toggle(value) {
|
|
1183
|
+
if (arguments.length) {
|
|
1184
|
+
_value.value = value;
|
|
1185
|
+
return _value.value;
|
|
1186
|
+
} else {
|
|
1187
|
+
const truthy = toValue(truthyValue);
|
|
1188
|
+
_value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
|
|
1189
|
+
return _value.value;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (valueIsRef)
|
|
1193
|
+
return toggle;
|
|
1194
|
+
else
|
|
1195
|
+
return [_value, toggle];
|
|
1196
|
+
}
|
|
1197
|
+
function watchArray(source, cb, options) {
|
|
1198
|
+
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
|
|
1199
|
+
return reactivity.watch(source, (newList, _, onCleanup) => {
|
|
1200
|
+
const oldListRemains = Array.from({ length: oldList.length });
|
|
1201
|
+
const added = [];
|
|
1202
|
+
for (const obj of newList) {
|
|
1203
|
+
let found = false;
|
|
1204
|
+
for (let i = 0; i < oldList.length; i++) {
|
|
1205
|
+
if (!oldListRemains[i] && obj === oldList[i]) {
|
|
1206
|
+
oldListRemains[i] = true;
|
|
1207
|
+
found = true;
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
if (!found)
|
|
1212
|
+
added.push(obj);
|
|
1213
|
+
}
|
|
1214
|
+
const removed = oldList.filter((_2, i) => !oldListRemains[i]);
|
|
1215
|
+
cb(newList, oldList, added, removed, onCleanup);
|
|
1216
|
+
oldList = [...newList];
|
|
1217
|
+
}, options);
|
|
1218
|
+
}
|
|
1219
|
+
function watchAtMost(source, cb, options) {
|
|
1220
|
+
const {
|
|
1221
|
+
count,
|
|
1222
|
+
...watchOptions
|
|
1223
|
+
} = options;
|
|
1224
|
+
const current = reactivity.ref(0);
|
|
1225
|
+
const stop = watchWithFilter(
|
|
1226
|
+
source,
|
|
1227
|
+
(...args) => {
|
|
1228
|
+
current.value += 1;
|
|
1229
|
+
if (current.value >= toValue(count))
|
|
1230
|
+
reactivity.nextTick(() => stop());
|
|
1231
|
+
cb(...args);
|
|
1232
|
+
},
|
|
1233
|
+
watchOptions
|
|
1234
|
+
);
|
|
1235
|
+
return { count: current, stop };
|
|
1236
|
+
}
|
|
1237
|
+
function watchDebounced(source, cb, options = {}) {
|
|
1238
|
+
const {
|
|
1239
|
+
debounce = 0,
|
|
1240
|
+
maxWait = void 0,
|
|
1241
|
+
...watchOptions
|
|
1242
|
+
} = options;
|
|
1243
|
+
return watchWithFilter(
|
|
1244
|
+
source,
|
|
1245
|
+
cb,
|
|
1246
|
+
{
|
|
1247
|
+
...watchOptions,
|
|
1248
|
+
eventFilter: debounceFilter(debounce, { maxWait })
|
|
1249
|
+
}
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
function watchDeep(source, cb, options) {
|
|
1253
|
+
return reactivity.watch(
|
|
1254
|
+
source,
|
|
1255
|
+
cb,
|
|
1256
|
+
{
|
|
1257
|
+
...options,
|
|
1258
|
+
deep: true
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
function watchIgnorable(source, cb, options = {}) {
|
|
1263
|
+
const {
|
|
1264
|
+
eventFilter = bypassFilter,
|
|
1265
|
+
...watchOptions
|
|
1266
|
+
} = options;
|
|
1267
|
+
const filteredCb = createFilterWrapper(
|
|
1268
|
+
eventFilter,
|
|
1269
|
+
cb
|
|
1270
|
+
);
|
|
1271
|
+
let ignoreUpdates;
|
|
1272
|
+
let ignorePrevAsyncUpdates;
|
|
1273
|
+
let stop;
|
|
1274
|
+
if (watchOptions.flush === "sync") {
|
|
1275
|
+
const ignore = reactivity.ref(false);
|
|
1276
|
+
ignorePrevAsyncUpdates = () => {
|
|
1277
|
+
};
|
|
1278
|
+
ignoreUpdates = (updater) => {
|
|
1279
|
+
ignore.value = true;
|
|
1280
|
+
updater();
|
|
1281
|
+
ignore.value = false;
|
|
1282
|
+
};
|
|
1283
|
+
stop = reactivity.watch(
|
|
1284
|
+
source,
|
|
1285
|
+
(...args) => {
|
|
1286
|
+
if (!ignore.value)
|
|
1287
|
+
filteredCb(...args);
|
|
1288
|
+
},
|
|
1289
|
+
watchOptions
|
|
1290
|
+
);
|
|
1291
|
+
} else {
|
|
1292
|
+
const disposables = [];
|
|
1293
|
+
const ignoreCounter = reactivity.ref(0);
|
|
1294
|
+
const syncCounter = reactivity.ref(0);
|
|
1295
|
+
ignorePrevAsyncUpdates = () => {
|
|
1296
|
+
ignoreCounter.value = syncCounter.value;
|
|
1297
|
+
};
|
|
1298
|
+
disposables.push(
|
|
1299
|
+
reactivity.watch(
|
|
1300
|
+
source,
|
|
1301
|
+
() => {
|
|
1302
|
+
syncCounter.value++;
|
|
1303
|
+
},
|
|
1304
|
+
{ ...watchOptions, flush: "sync" }
|
|
1305
|
+
)
|
|
1306
|
+
);
|
|
1307
|
+
ignoreUpdates = (updater) => {
|
|
1308
|
+
const syncCounterPrev = syncCounter.value;
|
|
1309
|
+
updater();
|
|
1310
|
+
ignoreCounter.value += syncCounter.value - syncCounterPrev;
|
|
1311
|
+
};
|
|
1312
|
+
disposables.push(
|
|
1313
|
+
reactivity.watch(
|
|
1314
|
+
source,
|
|
1315
|
+
(...args) => {
|
|
1316
|
+
const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
|
|
1317
|
+
ignoreCounter.value = 0;
|
|
1318
|
+
syncCounter.value = 0;
|
|
1319
|
+
if (ignore)
|
|
1320
|
+
return;
|
|
1321
|
+
filteredCb(...args);
|
|
1322
|
+
},
|
|
1323
|
+
watchOptions
|
|
1324
|
+
)
|
|
1325
|
+
);
|
|
1326
|
+
stop = () => {
|
|
1327
|
+
disposables.forEach((fn) => fn());
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
|
|
1331
|
+
}
|
|
1332
|
+
function watchImmediate(source, cb, options) {
|
|
1333
|
+
return reactivity.watch(
|
|
1334
|
+
source,
|
|
1335
|
+
cb,
|
|
1336
|
+
{
|
|
1337
|
+
...options,
|
|
1338
|
+
immediate: true
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
function watchOnce(source, cb, options) {
|
|
1343
|
+
const stop = reactivity.watch(source, (...args) => {
|
|
1344
|
+
reactivity.nextTick(() => stop());
|
|
1345
|
+
return cb(...args);
|
|
1346
|
+
}, options);
|
|
1347
|
+
return stop;
|
|
1348
|
+
}
|
|
1349
|
+
function watchThrottled(source, cb, options = {}) {
|
|
1350
|
+
const {
|
|
1351
|
+
throttle = 0,
|
|
1352
|
+
trailing = true,
|
|
1353
|
+
leading = true,
|
|
1354
|
+
...watchOptions
|
|
1355
|
+
} = options;
|
|
1356
|
+
return watchWithFilter(
|
|
1357
|
+
source,
|
|
1358
|
+
cb,
|
|
1359
|
+
{
|
|
1360
|
+
...watchOptions,
|
|
1361
|
+
eventFilter: throttleFilter(throttle, trailing, leading)
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
function watchTriggerable(source, cb, options = {}) {
|
|
1366
|
+
let cleanupFn;
|
|
1367
|
+
function onEffect() {
|
|
1368
|
+
if (!cleanupFn)
|
|
1369
|
+
return;
|
|
1370
|
+
const fn = cleanupFn;
|
|
1371
|
+
cleanupFn = void 0;
|
|
1372
|
+
fn();
|
|
1373
|
+
}
|
|
1374
|
+
function onCleanup(callback) {
|
|
1375
|
+
cleanupFn = callback;
|
|
1376
|
+
}
|
|
1377
|
+
const _cb = (value, oldValue) => {
|
|
1378
|
+
onEffect();
|
|
1379
|
+
return cb(value, oldValue, onCleanup);
|
|
1380
|
+
};
|
|
1381
|
+
const res = watchIgnorable(source, _cb, options);
|
|
1382
|
+
const { ignoreUpdates } = res;
|
|
1383
|
+
const trigger = () => {
|
|
1384
|
+
let res2;
|
|
1385
|
+
ignoreUpdates(() => {
|
|
1386
|
+
res2 = _cb(getWatchSources(source), getOldValue(source));
|
|
1387
|
+
});
|
|
1388
|
+
return res2;
|
|
1389
|
+
};
|
|
1390
|
+
return {
|
|
1391
|
+
...res,
|
|
1392
|
+
trigger
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
function getWatchSources(sources) {
|
|
1396
|
+
if (reactivity.isReactive(sources))
|
|
1397
|
+
return sources;
|
|
1398
|
+
if (Array.isArray(sources))
|
|
1399
|
+
return sources.map((item) => toValue(item));
|
|
1400
|
+
return toValue(sources);
|
|
1401
|
+
}
|
|
1402
|
+
function getOldValue(source) {
|
|
1403
|
+
return Array.isArray(source) ? source.map(() => void 0) : void 0;
|
|
1404
|
+
}
|
|
1405
|
+
function whenever(source, cb, options) {
|
|
1406
|
+
const stop = reactivity.watch(
|
|
1407
|
+
source,
|
|
1408
|
+
(v, ov, onInvalidate) => {
|
|
1409
|
+
if (v) {
|
|
1410
|
+
if (options == null ? void 0 : options.once)
|
|
1411
|
+
reactivity.nextTick(() => stop());
|
|
1412
|
+
cb(v, ov, onInvalidate);
|
|
1413
|
+
}
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
...options,
|
|
1417
|
+
once: false
|
|
1418
|
+
}
|
|
1419
|
+
);
|
|
1420
|
+
return stop;
|
|
1421
|
+
}
|
|
1422
|
+
function computedAsync(evaluationCallback, initialState, optionsOrRef) {
|
|
1423
|
+
let options;
|
|
1424
|
+
if (reactivity.isRef(optionsOrRef)) {
|
|
1425
|
+
options = {
|
|
1426
|
+
evaluating: optionsOrRef
|
|
1427
|
+
};
|
|
1428
|
+
} else {
|
|
1429
|
+
options = optionsOrRef || {};
|
|
1430
|
+
}
|
|
1431
|
+
const {
|
|
1432
|
+
lazy = false,
|
|
1433
|
+
evaluating = void 0,
|
|
1434
|
+
shallow = true,
|
|
1435
|
+
onError = noop
|
|
1436
|
+
} = options;
|
|
1437
|
+
const started = reactivity.ref(!lazy);
|
|
1438
|
+
const current = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
|
|
1439
|
+
let counter = 0;
|
|
1440
|
+
reactivity.watchEffect(async (onInvalidate) => {
|
|
1441
|
+
if (!started.value)
|
|
1442
|
+
return;
|
|
1443
|
+
counter++;
|
|
1444
|
+
const counterAtBeginning = counter;
|
|
1445
|
+
let hasFinished = false;
|
|
1446
|
+
if (evaluating) {
|
|
1447
|
+
Promise.resolve().then(() => {
|
|
1448
|
+
evaluating.value = true;
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
try {
|
|
1452
|
+
const result = await evaluationCallback((cancelCallback) => {
|
|
1453
|
+
onInvalidate(() => {
|
|
1454
|
+
if (evaluating)
|
|
1455
|
+
evaluating.value = false;
|
|
1456
|
+
if (!hasFinished)
|
|
1457
|
+
cancelCallback();
|
|
1458
|
+
});
|
|
1459
|
+
});
|
|
1460
|
+
if (counterAtBeginning === counter)
|
|
1461
|
+
current.value = result;
|
|
1462
|
+
} catch (e) {
|
|
1463
|
+
onError(e);
|
|
1464
|
+
} finally {
|
|
1465
|
+
if (evaluating && counterAtBeginning === counter)
|
|
1466
|
+
evaluating.value = false;
|
|
1467
|
+
hasFinished = true;
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
if (lazy) {
|
|
1471
|
+
return reactivity.computed(() => {
|
|
1472
|
+
started.value = true;
|
|
1473
|
+
return current.value;
|
|
1474
|
+
});
|
|
1475
|
+
} else {
|
|
1476
|
+
return current;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
function createUnrefFn(fn) {
|
|
1480
|
+
return function(...args) {
|
|
1481
|
+
return fn.apply(this, args.map((i) => toValue(i)));
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
const defaultWindow = isClient ? window : void 0;
|
|
1485
|
+
function unrefElement(elRef) {
|
|
1486
|
+
var _a;
|
|
1487
|
+
const plain = toValue(elRef);
|
|
1488
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
1489
|
+
}
|
|
1490
|
+
function useEventListener(...args) {
|
|
1491
|
+
let target;
|
|
1492
|
+
let events2;
|
|
1493
|
+
let listeners;
|
|
1494
|
+
let options;
|
|
1495
|
+
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
1496
|
+
[events2, listeners, options] = args;
|
|
1497
|
+
target = defaultWindow;
|
|
1498
|
+
} else {
|
|
1499
|
+
[target, events2, listeners, options] = args;
|
|
1500
|
+
}
|
|
1501
|
+
if (!target)
|
|
1502
|
+
return noop;
|
|
1503
|
+
if (!Array.isArray(events2))
|
|
1504
|
+
events2 = [events2];
|
|
1505
|
+
if (!Array.isArray(listeners))
|
|
1506
|
+
listeners = [listeners];
|
|
1507
|
+
const cleanups = [];
|
|
1508
|
+
const cleanup = () => {
|
|
1509
|
+
cleanups.forEach((fn) => fn());
|
|
1510
|
+
cleanups.length = 0;
|
|
1511
|
+
};
|
|
1512
|
+
const register = (el, event, listener, options2) => {
|
|
1513
|
+
el.addEventListener(event, listener, options2);
|
|
1514
|
+
return () => el.removeEventListener(event, listener, options2);
|
|
1515
|
+
};
|
|
1516
|
+
const stopWatch = reactivity.watch(
|
|
1517
|
+
() => [unrefElement(target), toValue(options)],
|
|
1518
|
+
([el, options2]) => {
|
|
1519
|
+
cleanup();
|
|
1520
|
+
if (!el)
|
|
1521
|
+
return;
|
|
1522
|
+
const optionsClone = isObject(options2) ? { ...options2 } : options2;
|
|
1523
|
+
cleanups.push(
|
|
1524
|
+
...events2.flatMap((event) => {
|
|
1525
|
+
return listeners.map((listener) => register(el, event, listener, optionsClone));
|
|
1526
|
+
})
|
|
1527
|
+
);
|
|
1528
|
+
},
|
|
1529
|
+
{ immediate: true, flush: "post" }
|
|
1530
|
+
);
|
|
1531
|
+
const stop = () => {
|
|
1532
|
+
stopWatch();
|
|
1533
|
+
cleanup();
|
|
1534
|
+
};
|
|
1535
|
+
tryOnScopeDispose(stop);
|
|
1536
|
+
return stop;
|
|
1537
|
+
}
|
|
1538
|
+
function useMounted() {
|
|
1539
|
+
const isMounted = reactivity.ref(false);
|
|
1540
|
+
return isMounted;
|
|
1541
|
+
}
|
|
1542
|
+
function useSupported(callback) {
|
|
1543
|
+
const isMounted = useMounted();
|
|
1544
|
+
return reactivity.computed(() => {
|
|
1545
|
+
isMounted.value;
|
|
1546
|
+
return Boolean(callback());
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
function useRafFn(fn, options = {}) {
|
|
1550
|
+
const {
|
|
1551
|
+
immediate = true,
|
|
1552
|
+
fpsLimit = void 0,
|
|
1553
|
+
window: window2 = defaultWindow
|
|
1554
|
+
} = options;
|
|
1555
|
+
const isActive = reactivity.ref(false);
|
|
1556
|
+
const intervalLimit = fpsLimit ? 1e3 / fpsLimit : null;
|
|
1557
|
+
let previousFrameTimestamp = 0;
|
|
1558
|
+
let rafId = null;
|
|
1559
|
+
function loop(timestamp2) {
|
|
1560
|
+
if (!isActive.value || !window2)
|
|
1561
|
+
return;
|
|
1562
|
+
if (!previousFrameTimestamp)
|
|
1563
|
+
previousFrameTimestamp = timestamp2;
|
|
1564
|
+
const delta = timestamp2 - previousFrameTimestamp;
|
|
1565
|
+
if (intervalLimit && delta < intervalLimit) {
|
|
1566
|
+
rafId = window2.requestAnimationFrame(loop);
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
previousFrameTimestamp = timestamp2;
|
|
1570
|
+
fn({ delta, timestamp: timestamp2 });
|
|
1571
|
+
rafId = window2.requestAnimationFrame(loop);
|
|
1572
|
+
}
|
|
1573
|
+
function resume() {
|
|
1574
|
+
if (!isActive.value && window2) {
|
|
1575
|
+
isActive.value = true;
|
|
1576
|
+
previousFrameTimestamp = 0;
|
|
1577
|
+
rafId = window2.requestAnimationFrame(loop);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
function pause() {
|
|
1581
|
+
isActive.value = false;
|
|
1582
|
+
if (rafId != null && window2) {
|
|
1583
|
+
window2.cancelAnimationFrame(rafId);
|
|
1584
|
+
rafId = null;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
if (immediate)
|
|
1588
|
+
resume();
|
|
1589
|
+
tryOnScopeDispose(pause);
|
|
1590
|
+
return {
|
|
1591
|
+
isActive: reactivity.readonly(isActive),
|
|
1592
|
+
pause,
|
|
1593
|
+
resume
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function useAsyncQueue(tasks, options) {
|
|
1597
|
+
const {
|
|
1598
|
+
interrupt = true,
|
|
1599
|
+
onError = noop,
|
|
1600
|
+
onFinished = noop,
|
|
1601
|
+
signal
|
|
1602
|
+
} = options || {};
|
|
1603
|
+
const promiseState = {
|
|
1604
|
+
aborted: "aborted",
|
|
1605
|
+
fulfilled: "fulfilled",
|
|
1606
|
+
pending: "pending",
|
|
1607
|
+
rejected: "rejected"
|
|
1608
|
+
};
|
|
1609
|
+
const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
|
|
1610
|
+
const result = reactivity.reactive(initialResult);
|
|
1611
|
+
const activeIndex = reactivity.ref(-1);
|
|
1612
|
+
if (!tasks || tasks.length === 0) {
|
|
1613
|
+
onFinished();
|
|
1614
|
+
return {
|
|
1615
|
+
activeIndex,
|
|
1616
|
+
result
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
function updateResult(state, res) {
|
|
1620
|
+
activeIndex.value++;
|
|
1621
|
+
result[activeIndex.value].data = res;
|
|
1622
|
+
result[activeIndex.value].state = state;
|
|
1623
|
+
}
|
|
1624
|
+
tasks.reduce((prev, curr) => {
|
|
1625
|
+
return prev.then((prevRes) => {
|
|
1626
|
+
var _a;
|
|
1627
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
1628
|
+
updateResult(promiseState.aborted, new Error("aborted"));
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
if (((_a = result[activeIndex.value]) == null ? void 0 : _a.state) === promiseState.rejected && interrupt) {
|
|
1632
|
+
onFinished();
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
const done = curr(prevRes).then((currentRes) => {
|
|
1636
|
+
updateResult(promiseState.fulfilled, currentRes);
|
|
1637
|
+
if (activeIndex.value === tasks.length - 1)
|
|
1638
|
+
onFinished();
|
|
1639
|
+
return currentRes;
|
|
1640
|
+
});
|
|
1641
|
+
if (!signal)
|
|
1642
|
+
return done;
|
|
1643
|
+
return Promise.race([done, whenAborted(signal)]);
|
|
1644
|
+
}).catch((e) => {
|
|
1645
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
1646
|
+
updateResult(promiseState.aborted, e);
|
|
1647
|
+
return e;
|
|
1648
|
+
}
|
|
1649
|
+
updateResult(promiseState.rejected, e);
|
|
1650
|
+
onError();
|
|
1651
|
+
return e;
|
|
1652
|
+
});
|
|
1653
|
+
}, Promise.resolve());
|
|
1654
|
+
return {
|
|
1655
|
+
activeIndex,
|
|
1656
|
+
result
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
function whenAborted(signal) {
|
|
1660
|
+
return new Promise((resolve, reject) => {
|
|
1661
|
+
const error = new Error("aborted");
|
|
1662
|
+
if (signal.aborted)
|
|
1663
|
+
reject(error);
|
|
1664
|
+
else
|
|
1665
|
+
signal.addEventListener("abort", () => reject(error), { once: true });
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
function useAsyncState(promise, initialState, options) {
|
|
1669
|
+
const {
|
|
1670
|
+
immediate = true,
|
|
1671
|
+
delay = 0,
|
|
1672
|
+
onError = noop,
|
|
1673
|
+
onSuccess = noop,
|
|
1674
|
+
resetOnExecute = true,
|
|
1675
|
+
shallow = true,
|
|
1676
|
+
throwError
|
|
1677
|
+
} = options != null ? options : {};
|
|
1678
|
+
const state = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
|
|
1679
|
+
const isReady = reactivity.ref(false);
|
|
1680
|
+
const isLoading = reactivity.ref(false);
|
|
1681
|
+
const error = reactivity.shallowRef(void 0);
|
|
1682
|
+
async function execute(delay2 = 0, ...args) {
|
|
1683
|
+
if (resetOnExecute)
|
|
1684
|
+
state.value = initialState;
|
|
1685
|
+
error.value = void 0;
|
|
1686
|
+
isReady.value = false;
|
|
1687
|
+
isLoading.value = true;
|
|
1688
|
+
if (delay2 > 0)
|
|
1689
|
+
await promiseTimeout(delay2);
|
|
1690
|
+
const _promise = typeof promise === "function" ? promise(...args) : promise;
|
|
1691
|
+
try {
|
|
1692
|
+
const data = await _promise;
|
|
1693
|
+
state.value = data;
|
|
1694
|
+
isReady.value = true;
|
|
1695
|
+
onSuccess(data);
|
|
1696
|
+
} catch (e) {
|
|
1697
|
+
error.value = e;
|
|
1698
|
+
onError(e);
|
|
1699
|
+
if (throwError)
|
|
1700
|
+
throw e;
|
|
1701
|
+
} finally {
|
|
1702
|
+
isLoading.value = false;
|
|
1703
|
+
}
|
|
1704
|
+
return state.value;
|
|
1705
|
+
}
|
|
1706
|
+
if (immediate)
|
|
1707
|
+
execute(delay);
|
|
1708
|
+
const shell = {
|
|
1709
|
+
state,
|
|
1710
|
+
isReady,
|
|
1711
|
+
isLoading,
|
|
1712
|
+
error,
|
|
1713
|
+
execute
|
|
1714
|
+
};
|
|
1715
|
+
function waitUntilIsLoaded() {
|
|
1716
|
+
return new Promise((resolve, reject) => {
|
|
1717
|
+
until(isLoading).toBe(false).then(() => resolve(shell)).catch(reject);
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
...shell,
|
|
1722
|
+
then(onFulfilled, onRejected) {
|
|
1723
|
+
return waitUntilIsLoaded().then(onFulfilled, onRejected);
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
const defaults = {
|
|
1728
|
+
array: (v) => JSON.stringify(v),
|
|
1729
|
+
object: (v) => JSON.stringify(v),
|
|
1730
|
+
set: (v) => JSON.stringify(Array.from(v)),
|
|
1731
|
+
map: (v) => JSON.stringify(Object.fromEntries(v)),
|
|
1732
|
+
null: () => ""
|
|
1733
|
+
};
|
|
1734
|
+
function getDefaultSerialization(target) {
|
|
1735
|
+
if (!target)
|
|
1736
|
+
return defaults.null;
|
|
1737
|
+
if (target instanceof Map)
|
|
1738
|
+
return defaults.map;
|
|
1739
|
+
else if (target instanceof Set)
|
|
1740
|
+
return defaults.set;
|
|
1741
|
+
else if (Array.isArray(target))
|
|
1742
|
+
return defaults.array;
|
|
1743
|
+
else
|
|
1744
|
+
return defaults.object;
|
|
1745
|
+
}
|
|
1746
|
+
function useBase64(target, options) {
|
|
1747
|
+
const base64 = reactivity.ref("");
|
|
1748
|
+
const promise = reactivity.ref();
|
|
1749
|
+
function execute() {
|
|
1750
|
+
if (!isClient)
|
|
1751
|
+
return;
|
|
1752
|
+
promise.value = new Promise((resolve, reject) => {
|
|
1753
|
+
try {
|
|
1754
|
+
const _target = toValue(target);
|
|
1755
|
+
if (_target == null) {
|
|
1756
|
+
resolve("");
|
|
1757
|
+
} else if (typeof _target === "string") {
|
|
1758
|
+
resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
|
|
1759
|
+
} else if (_target instanceof Blob) {
|
|
1760
|
+
resolve(blobToBase64(_target));
|
|
1761
|
+
} else if (_target instanceof ArrayBuffer) {
|
|
1762
|
+
resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
|
|
1763
|
+
} else if (_target instanceof HTMLCanvasElement) {
|
|
1764
|
+
resolve(_target.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
|
|
1765
|
+
} else if (_target instanceof HTMLImageElement) {
|
|
1766
|
+
const img = _target.cloneNode(false);
|
|
1767
|
+
img.crossOrigin = "Anonymous";
|
|
1768
|
+
imgLoaded(img).then(() => {
|
|
1769
|
+
const canvas = document.createElement("canvas");
|
|
1770
|
+
const ctx = canvas.getContext("2d");
|
|
1771
|
+
canvas.width = img.width;
|
|
1772
|
+
canvas.height = img.height;
|
|
1773
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
1774
|
+
resolve(canvas.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
|
|
1775
|
+
}).catch(reject);
|
|
1776
|
+
} else if (typeof _target === "object") {
|
|
1777
|
+
const _serializeFn = (options == null ? void 0 : options.serializer) || getDefaultSerialization(_target);
|
|
1778
|
+
const serialized = _serializeFn(_target);
|
|
1779
|
+
return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
|
|
1780
|
+
} else {
|
|
1781
|
+
reject(new Error("target is unsupported types"));
|
|
1782
|
+
}
|
|
1783
|
+
} catch (error) {
|
|
1784
|
+
reject(error);
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
promise.value.then((res) => base64.value = res);
|
|
1788
|
+
return promise.value;
|
|
1789
|
+
}
|
|
1790
|
+
if (reactivity.isRef(target) || typeof target === "function")
|
|
1791
|
+
reactivity.watch(target, execute, { immediate: true });
|
|
1792
|
+
else
|
|
1793
|
+
execute();
|
|
1794
|
+
return {
|
|
1795
|
+
base64,
|
|
1796
|
+
promise,
|
|
1797
|
+
execute
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
function imgLoaded(img) {
|
|
1801
|
+
return new Promise((resolve, reject) => {
|
|
1802
|
+
if (!img.complete) {
|
|
1803
|
+
img.onload = () => {
|
|
1804
|
+
resolve();
|
|
1805
|
+
};
|
|
1806
|
+
img.onerror = reject;
|
|
1807
|
+
} else {
|
|
1808
|
+
resolve();
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
function blobToBase64(blob) {
|
|
1813
|
+
return new Promise((resolve, reject) => {
|
|
1814
|
+
const fr = new FileReader();
|
|
1815
|
+
fr.onload = (e) => {
|
|
1816
|
+
resolve(e.target.result);
|
|
1817
|
+
};
|
|
1818
|
+
fr.onerror = reject;
|
|
1819
|
+
fr.readAsDataURL(blob);
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
function useBroadcastChannel(options) {
|
|
1823
|
+
const {
|
|
1824
|
+
name,
|
|
1825
|
+
window: window2 = defaultWindow
|
|
1826
|
+
} = options;
|
|
1827
|
+
const isSupported = useSupported(() => window2 && "BroadcastChannel" in window2);
|
|
1828
|
+
const isClosed = reactivity.ref(false);
|
|
1829
|
+
const channel = reactivity.ref();
|
|
1830
|
+
const data = reactivity.ref();
|
|
1831
|
+
const error = reactivity.shallowRef(null);
|
|
1832
|
+
const post = (data2) => {
|
|
1833
|
+
if (channel.value)
|
|
1834
|
+
channel.value.postMessage(data2);
|
|
1835
|
+
};
|
|
1836
|
+
const close = () => {
|
|
1837
|
+
if (channel.value)
|
|
1838
|
+
channel.value.close();
|
|
1839
|
+
isClosed.value = true;
|
|
1840
|
+
};
|
|
1841
|
+
if (isSupported.value) {
|
|
1842
|
+
tryOnMounted(() => {
|
|
1843
|
+
error.value = null;
|
|
1844
|
+
channel.value = new BroadcastChannel(name);
|
|
1845
|
+
channel.value.addEventListener("message", (e) => {
|
|
1846
|
+
data.value = e.data;
|
|
1847
|
+
}, { passive: true });
|
|
1848
|
+
channel.value.addEventListener("messageerror", (e) => {
|
|
1849
|
+
error.value = e;
|
|
1850
|
+
}, { passive: true });
|
|
1851
|
+
channel.value.addEventListener("close", () => {
|
|
1852
|
+
isClosed.value = true;
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
tryOnScopeDispose(() => {
|
|
1857
|
+
close();
|
|
1858
|
+
});
|
|
1859
|
+
return {
|
|
1860
|
+
isSupported,
|
|
1861
|
+
channel,
|
|
1862
|
+
data,
|
|
1863
|
+
post,
|
|
1864
|
+
close,
|
|
1865
|
+
error,
|
|
1866
|
+
isClosed
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function useCached(refValue, comparator = (a, b) => a === b, watchOptions) {
|
|
1870
|
+
const cachedValue = reactivity.ref(refValue.value);
|
|
1871
|
+
reactivity.watch(() => refValue.value, (value) => {
|
|
1872
|
+
if (!comparator(value, cachedValue.value))
|
|
1873
|
+
cachedValue.value = value;
|
|
1874
|
+
}, watchOptions);
|
|
1875
|
+
return cachedValue;
|
|
1876
|
+
}
|
|
1877
|
+
function cloneFnJSON(source) {
|
|
1878
|
+
return JSON.parse(JSON.stringify(source));
|
|
1879
|
+
}
|
|
1880
|
+
function useCloned(source, options = {}) {
|
|
1881
|
+
const cloned = reactivity.ref({});
|
|
1882
|
+
const {
|
|
1883
|
+
manual,
|
|
1884
|
+
clone = cloneFnJSON,
|
|
1885
|
+
// watch options
|
|
1886
|
+
deep = true,
|
|
1887
|
+
immediate = true
|
|
1888
|
+
} = options;
|
|
1889
|
+
function sync() {
|
|
1890
|
+
cloned.value = clone(toValue(source));
|
|
1891
|
+
}
|
|
1892
|
+
if (!manual && (reactivity.isRef(source) || typeof source === "function")) {
|
|
1893
|
+
reactivity.watch(source, sync, {
|
|
1894
|
+
...options,
|
|
1895
|
+
deep,
|
|
1896
|
+
immediate
|
|
1897
|
+
});
|
|
1898
|
+
} else {
|
|
1899
|
+
sync();
|
|
1900
|
+
}
|
|
1901
|
+
return { cloned, sync };
|
|
1902
|
+
}
|
|
1903
|
+
function useCycleList(list, options) {
|
|
1904
|
+
const state = reactivity.shallowRef(getInitialValue());
|
|
1905
|
+
const listRef = toRef(list);
|
|
1906
|
+
const index = reactivity.computed({
|
|
1907
|
+
get() {
|
|
1908
|
+
var _a;
|
|
1909
|
+
const targetList = listRef.value;
|
|
1910
|
+
let index2 = (options == null ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
|
|
1911
|
+
if (index2 < 0)
|
|
1912
|
+
index2 = (_a = options == null ? void 0 : options.fallbackIndex) != null ? _a : 0;
|
|
1913
|
+
return index2;
|
|
1914
|
+
},
|
|
1915
|
+
set(v) {
|
|
1916
|
+
set2(v);
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
function set2(i) {
|
|
1920
|
+
const targetList = listRef.value;
|
|
1921
|
+
const length = targetList.length;
|
|
1922
|
+
const index2 = (i % length + length) % length;
|
|
1923
|
+
const value = targetList[index2];
|
|
1924
|
+
state.value = value;
|
|
1925
|
+
return value;
|
|
1926
|
+
}
|
|
1927
|
+
function shift(delta = 1) {
|
|
1928
|
+
return set2(index.value + delta);
|
|
1929
|
+
}
|
|
1930
|
+
function next(n = 1) {
|
|
1931
|
+
return shift(n);
|
|
1932
|
+
}
|
|
1933
|
+
function prev(n = 1) {
|
|
1934
|
+
return shift(-n);
|
|
1935
|
+
}
|
|
1936
|
+
function getInitialValue() {
|
|
1937
|
+
var _a, _b;
|
|
1938
|
+
return (_b = toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : toValue(list)[0])) != null ? _b : void 0;
|
|
1939
|
+
}
|
|
1940
|
+
reactivity.watch(listRef, () => set2(index.value));
|
|
1941
|
+
return {
|
|
1942
|
+
state,
|
|
1943
|
+
index,
|
|
1944
|
+
next,
|
|
1945
|
+
prev,
|
|
1946
|
+
go: set2
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
function fnBypass(v) {
|
|
1950
|
+
return v;
|
|
1951
|
+
}
|
|
1952
|
+
function fnSetSource(source, value) {
|
|
1953
|
+
return source.value = value;
|
|
1954
|
+
}
|
|
1955
|
+
function defaultDump(clone) {
|
|
1956
|
+
return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
|
|
1957
|
+
}
|
|
1958
|
+
function defaultParse(clone) {
|
|
1959
|
+
return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
|
|
1960
|
+
}
|
|
1961
|
+
function useManualRefHistory(source, options = {}) {
|
|
1962
|
+
const {
|
|
1963
|
+
clone = false,
|
|
1964
|
+
dump = defaultDump(clone),
|
|
1965
|
+
parse = defaultParse(clone),
|
|
1966
|
+
setSource = fnSetSource
|
|
1967
|
+
} = options;
|
|
1968
|
+
function _createHistoryRecord() {
|
|
1969
|
+
return reactivity.markRaw({
|
|
1970
|
+
snapshot: dump(source.value),
|
|
1971
|
+
timestamp: timestamp()
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
const last = reactivity.ref(_createHistoryRecord());
|
|
1975
|
+
const undoStack = reactivity.ref([]);
|
|
1976
|
+
const redoStack = reactivity.ref([]);
|
|
1977
|
+
const _setSource = (record) => {
|
|
1978
|
+
setSource(source, parse(record.snapshot));
|
|
1979
|
+
last.value = record;
|
|
1980
|
+
};
|
|
1981
|
+
const commit = () => {
|
|
1982
|
+
undoStack.value.unshift(last.value);
|
|
1983
|
+
last.value = _createHistoryRecord();
|
|
1984
|
+
if (options.capacity && undoStack.value.length > options.capacity)
|
|
1985
|
+
undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
|
|
1986
|
+
if (redoStack.value.length)
|
|
1987
|
+
redoStack.value.splice(0, redoStack.value.length);
|
|
1988
|
+
};
|
|
1989
|
+
const clear = () => {
|
|
1990
|
+
undoStack.value.splice(0, undoStack.value.length);
|
|
1991
|
+
redoStack.value.splice(0, redoStack.value.length);
|
|
1992
|
+
};
|
|
1993
|
+
const undo = () => {
|
|
1994
|
+
const state = undoStack.value.shift();
|
|
1995
|
+
if (state) {
|
|
1996
|
+
redoStack.value.unshift(last.value);
|
|
1997
|
+
_setSource(state);
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
const redo = () => {
|
|
2001
|
+
const state = redoStack.value.shift();
|
|
2002
|
+
if (state) {
|
|
2003
|
+
undoStack.value.unshift(last.value);
|
|
2004
|
+
_setSource(state);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
const reset = () => {
|
|
2008
|
+
_setSource(last.value);
|
|
2009
|
+
};
|
|
2010
|
+
const history = reactivity.computed(() => [last.value, ...undoStack.value]);
|
|
2011
|
+
const canUndo = reactivity.computed(() => undoStack.value.length > 0);
|
|
2012
|
+
const canRedo = reactivity.computed(() => redoStack.value.length > 0);
|
|
2013
|
+
return {
|
|
2014
|
+
source,
|
|
2015
|
+
undoStack,
|
|
2016
|
+
redoStack,
|
|
2017
|
+
last,
|
|
2018
|
+
history,
|
|
2019
|
+
canUndo,
|
|
2020
|
+
canRedo,
|
|
2021
|
+
clear,
|
|
2022
|
+
commit,
|
|
2023
|
+
reset,
|
|
2024
|
+
undo,
|
|
2025
|
+
redo
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
function useRefHistory(source, options = {}) {
|
|
2029
|
+
const {
|
|
2030
|
+
deep = false,
|
|
2031
|
+
flush = "pre",
|
|
2032
|
+
eventFilter
|
|
2033
|
+
} = options;
|
|
2034
|
+
const {
|
|
2035
|
+
eventFilter: composedFilter,
|
|
2036
|
+
pause,
|
|
2037
|
+
resume: resumeTracking,
|
|
2038
|
+
isActive: isTracking
|
|
2039
|
+
} = pausableFilter(eventFilter);
|
|
2040
|
+
const {
|
|
2041
|
+
ignoreUpdates,
|
|
2042
|
+
ignorePrevAsyncUpdates,
|
|
2043
|
+
stop
|
|
2044
|
+
} = watchIgnorable(
|
|
2045
|
+
source,
|
|
2046
|
+
commit,
|
|
2047
|
+
{ deep, flush, eventFilter: composedFilter }
|
|
2048
|
+
);
|
|
2049
|
+
function setSource(source2, value) {
|
|
2050
|
+
ignorePrevAsyncUpdates();
|
|
2051
|
+
ignoreUpdates(() => {
|
|
2052
|
+
source2.value = value;
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
const manualHistory = useManualRefHistory(source, { ...options, clone: options.clone || deep, setSource });
|
|
2056
|
+
const { clear, commit: manualCommit } = manualHistory;
|
|
2057
|
+
function commit() {
|
|
2058
|
+
ignorePrevAsyncUpdates();
|
|
2059
|
+
manualCommit();
|
|
2060
|
+
}
|
|
2061
|
+
function resume(commitNow) {
|
|
2062
|
+
resumeTracking();
|
|
2063
|
+
if (commitNow)
|
|
2064
|
+
commit();
|
|
2065
|
+
}
|
|
2066
|
+
function batch(fn) {
|
|
2067
|
+
let canceled = false;
|
|
2068
|
+
const cancel = () => canceled = true;
|
|
2069
|
+
ignoreUpdates(() => {
|
|
2070
|
+
fn(cancel);
|
|
2071
|
+
});
|
|
2072
|
+
if (!canceled)
|
|
2073
|
+
commit();
|
|
2074
|
+
}
|
|
2075
|
+
function dispose() {
|
|
2076
|
+
stop();
|
|
2077
|
+
clear();
|
|
2078
|
+
}
|
|
2079
|
+
return {
|
|
2080
|
+
...manualHistory,
|
|
2081
|
+
isTracking,
|
|
2082
|
+
pause,
|
|
2083
|
+
resume,
|
|
2084
|
+
commit,
|
|
2085
|
+
batch,
|
|
2086
|
+
dispose
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
function useDebouncedRefHistory(source, options = {}) {
|
|
2090
|
+
const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
|
|
2091
|
+
const history = useRefHistory(source, { ...options, eventFilter: filter });
|
|
2092
|
+
return {
|
|
2093
|
+
...history
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
const events = /* @__PURE__ */ new Map();
|
|
2097
|
+
function useEventBus(key) {
|
|
2098
|
+
const scope = reactivity.getCurrentScope();
|
|
2099
|
+
function on(listener) {
|
|
2100
|
+
var _a;
|
|
2101
|
+
const listeners = events.get(key) || /* @__PURE__ */ new Set();
|
|
2102
|
+
listeners.add(listener);
|
|
2103
|
+
events.set(key, listeners);
|
|
2104
|
+
const _off = () => off(listener);
|
|
2105
|
+
(_a = scope == null ? void 0 : scope.cleanups) == null ? void 0 : _a.push(_off);
|
|
2106
|
+
return _off;
|
|
2107
|
+
}
|
|
2108
|
+
function once(listener) {
|
|
2109
|
+
function _listener(...args) {
|
|
2110
|
+
off(_listener);
|
|
2111
|
+
listener(...args);
|
|
2112
|
+
}
|
|
2113
|
+
return on(_listener);
|
|
2114
|
+
}
|
|
2115
|
+
function off(listener) {
|
|
2116
|
+
const listeners = events.get(key);
|
|
2117
|
+
if (!listeners)
|
|
2118
|
+
return;
|
|
2119
|
+
listeners.delete(listener);
|
|
2120
|
+
if (!listeners.size)
|
|
2121
|
+
reset();
|
|
2122
|
+
}
|
|
2123
|
+
function reset() {
|
|
2124
|
+
events.delete(key);
|
|
2125
|
+
}
|
|
2126
|
+
function emit(event, payload) {
|
|
2127
|
+
var _a;
|
|
2128
|
+
(_a = events.get(key)) == null ? void 0 : _a.forEach((v) => v(event, payload));
|
|
2129
|
+
}
|
|
2130
|
+
return { on, once, off, emit, reset };
|
|
2131
|
+
}
|
|
2132
|
+
const payloadMapping = {
|
|
2133
|
+
json: "application/json",
|
|
2134
|
+
text: "text/plain"
|
|
2135
|
+
};
|
|
2136
|
+
function isFetchOptions(obj) {
|
|
2137
|
+
return obj && containsProp(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch", "updateDataOnError");
|
|
2138
|
+
}
|
|
2139
|
+
const reAbsolute = /^(?:[a-z][a-z\d+\-.]*:)?\/\//i;
|
|
2140
|
+
function isAbsoluteURL(url) {
|
|
2141
|
+
return reAbsolute.test(url);
|
|
2142
|
+
}
|
|
2143
|
+
function headersToObject(headers) {
|
|
2144
|
+
if (typeof Headers !== "undefined" && headers instanceof Headers)
|
|
2145
|
+
return Object.fromEntries(headers.entries());
|
|
2146
|
+
return headers;
|
|
2147
|
+
}
|
|
2148
|
+
function combineCallbacks(combination, ...callbacks) {
|
|
2149
|
+
if (combination === "overwrite") {
|
|
2150
|
+
return async (ctx) => {
|
|
2151
|
+
const callback = callbacks[callbacks.length - 1];
|
|
2152
|
+
if (callback)
|
|
2153
|
+
return { ...ctx, ...await callback(ctx) };
|
|
2154
|
+
return ctx;
|
|
2155
|
+
};
|
|
2156
|
+
} else {
|
|
2157
|
+
return async (ctx) => {
|
|
2158
|
+
for (const callback of callbacks) {
|
|
2159
|
+
if (callback)
|
|
2160
|
+
ctx = { ...ctx, ...await callback(ctx) };
|
|
2161
|
+
}
|
|
2162
|
+
return ctx;
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
function createFetch(config = {}) {
|
|
2167
|
+
const _combination = config.combination || "chain";
|
|
2168
|
+
const _options = config.options || {};
|
|
2169
|
+
const _fetchOptions = config.fetchOptions || {};
|
|
2170
|
+
function useFactoryFetch(url, ...args) {
|
|
2171
|
+
const computedUrl = reactivity.computed(() => {
|
|
2172
|
+
const baseUrl = toValue(config.baseUrl);
|
|
2173
|
+
const targetUrl = toValue(url);
|
|
2174
|
+
return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
|
|
2175
|
+
});
|
|
2176
|
+
let options = _options;
|
|
2177
|
+
let fetchOptions = _fetchOptions;
|
|
2178
|
+
if (args.length > 0) {
|
|
2179
|
+
if (isFetchOptions(args[0])) {
|
|
2180
|
+
options = {
|
|
2181
|
+
...options,
|
|
2182
|
+
...args[0],
|
|
2183
|
+
beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
|
|
2184
|
+
afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
|
|
2185
|
+
onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
|
|
2186
|
+
};
|
|
2187
|
+
} else {
|
|
2188
|
+
fetchOptions = {
|
|
2189
|
+
...fetchOptions,
|
|
2190
|
+
...args[0],
|
|
2191
|
+
headers: {
|
|
2192
|
+
...headersToObject(fetchOptions.headers) || {},
|
|
2193
|
+
...headersToObject(args[0].headers) || {}
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
if (args.length > 1 && isFetchOptions(args[1])) {
|
|
2199
|
+
options = {
|
|
2200
|
+
...options,
|
|
2201
|
+
...args[1],
|
|
2202
|
+
beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
|
|
2203
|
+
afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
|
|
2204
|
+
onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
return useFetch(computedUrl, fetchOptions, options);
|
|
2208
|
+
}
|
|
2209
|
+
return useFactoryFetch;
|
|
2210
|
+
}
|
|
2211
|
+
function useFetch(url, ...args) {
|
|
2212
|
+
var _a;
|
|
2213
|
+
const supportsAbort = typeof AbortController === "function";
|
|
2214
|
+
let fetchOptions = {};
|
|
2215
|
+
let options = {
|
|
2216
|
+
immediate: true,
|
|
2217
|
+
refetch: false,
|
|
2218
|
+
timeout: 0,
|
|
2219
|
+
updateDataOnError: false
|
|
2220
|
+
};
|
|
2221
|
+
const config = {
|
|
2222
|
+
method: "GET",
|
|
2223
|
+
type: "text",
|
|
2224
|
+
payload: void 0
|
|
2225
|
+
};
|
|
2226
|
+
if (args.length > 0) {
|
|
2227
|
+
if (isFetchOptions(args[0]))
|
|
2228
|
+
options = { ...options, ...args[0] };
|
|
2229
|
+
else
|
|
2230
|
+
fetchOptions = args[0];
|
|
2231
|
+
}
|
|
2232
|
+
if (args.length > 1) {
|
|
2233
|
+
if (isFetchOptions(args[1]))
|
|
2234
|
+
options = { ...options, ...args[1] };
|
|
2235
|
+
}
|
|
2236
|
+
const {
|
|
2237
|
+
fetch = (_a = defaultWindow) == null ? void 0 : _a.fetch,
|
|
2238
|
+
initialData,
|
|
2239
|
+
timeout
|
|
2240
|
+
} = options;
|
|
2241
|
+
const responseEvent = createEventHook();
|
|
2242
|
+
const errorEvent = createEventHook();
|
|
2243
|
+
const finallyEvent = createEventHook();
|
|
2244
|
+
const isFinished = reactivity.ref(false);
|
|
2245
|
+
const isFetching = reactivity.ref(false);
|
|
2246
|
+
const aborted = reactivity.ref(false);
|
|
2247
|
+
const statusCode = reactivity.ref(null);
|
|
2248
|
+
const response = reactivity.shallowRef(null);
|
|
2249
|
+
const error = reactivity.shallowRef(null);
|
|
2250
|
+
const data = reactivity.shallowRef(initialData || null);
|
|
2251
|
+
const canAbort = reactivity.computed(() => supportsAbort && isFetching.value);
|
|
2252
|
+
let controller;
|
|
2253
|
+
let timer;
|
|
2254
|
+
const abort = () => {
|
|
2255
|
+
if (supportsAbort) {
|
|
2256
|
+
controller == null ? void 0 : controller.abort();
|
|
2257
|
+
controller = new AbortController();
|
|
2258
|
+
controller.signal.onabort = () => aborted.value = true;
|
|
2259
|
+
fetchOptions = {
|
|
2260
|
+
...fetchOptions,
|
|
2261
|
+
signal: controller.signal
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
};
|
|
2265
|
+
const loading = (isLoading) => {
|
|
2266
|
+
isFetching.value = isLoading;
|
|
2267
|
+
isFinished.value = !isLoading;
|
|
2268
|
+
};
|
|
2269
|
+
if (timeout)
|
|
2270
|
+
timer = useTimeoutFn(abort, timeout, { immediate: false });
|
|
2271
|
+
let executeCounter = 0;
|
|
2272
|
+
const execute = async (throwOnFailed = false) => {
|
|
2273
|
+
var _a2, _b;
|
|
2274
|
+
abort();
|
|
2275
|
+
loading(true);
|
|
2276
|
+
error.value = null;
|
|
2277
|
+
statusCode.value = null;
|
|
2278
|
+
aborted.value = false;
|
|
2279
|
+
executeCounter += 1;
|
|
2280
|
+
const currentExecuteCounter = executeCounter;
|
|
2281
|
+
const defaultFetchOptions = {
|
|
2282
|
+
method: config.method,
|
|
2283
|
+
headers: {}
|
|
2284
|
+
};
|
|
2285
|
+
if (config.payload) {
|
|
2286
|
+
const headers = headersToObject(defaultFetchOptions.headers);
|
|
2287
|
+
const payload = toValue(config.payload);
|
|
2288
|
+
if (!config.payloadType && payload && Object.getPrototypeOf(payload) === Object.prototype && !(payload instanceof FormData))
|
|
2289
|
+
config.payloadType = "json";
|
|
2290
|
+
if (config.payloadType)
|
|
2291
|
+
headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
|
|
2292
|
+
defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
|
|
2293
|
+
}
|
|
2294
|
+
let isCanceled = false;
|
|
2295
|
+
const context = {
|
|
2296
|
+
url: toValue(url),
|
|
2297
|
+
options: {
|
|
2298
|
+
...defaultFetchOptions,
|
|
2299
|
+
...fetchOptions
|
|
2300
|
+
},
|
|
2301
|
+
cancel: () => {
|
|
2302
|
+
isCanceled = true;
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
if (options.beforeFetch)
|
|
2306
|
+
Object.assign(context, await options.beforeFetch(context));
|
|
2307
|
+
if (isCanceled || !fetch) {
|
|
2308
|
+
loading(false);
|
|
2309
|
+
return Promise.resolve(null);
|
|
2310
|
+
}
|
|
2311
|
+
let responseData = null;
|
|
2312
|
+
if (timer)
|
|
2313
|
+
timer.start();
|
|
2314
|
+
return fetch(
|
|
2315
|
+
context.url,
|
|
2316
|
+
{
|
|
2317
|
+
...defaultFetchOptions,
|
|
2318
|
+
...context.options,
|
|
2319
|
+
headers: {
|
|
2320
|
+
...headersToObject(defaultFetchOptions.headers),
|
|
2321
|
+
...headersToObject((_b = context.options) == null ? void 0 : _b.headers)
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
).then(async (fetchResponse) => {
|
|
2325
|
+
response.value = fetchResponse;
|
|
2326
|
+
statusCode.value = fetchResponse.status;
|
|
2327
|
+
responseData = await fetchResponse.clone()[config.type]();
|
|
2328
|
+
if (!fetchResponse.ok) {
|
|
2329
|
+
data.value = initialData || null;
|
|
2330
|
+
throw new Error(fetchResponse.statusText);
|
|
2331
|
+
}
|
|
2332
|
+
if (options.afterFetch) {
|
|
2333
|
+
({ data: responseData } = await options.afterFetch({
|
|
2334
|
+
data: responseData,
|
|
2335
|
+
response: fetchResponse
|
|
2336
|
+
}));
|
|
2337
|
+
}
|
|
2338
|
+
data.value = responseData;
|
|
2339
|
+
responseEvent.trigger(fetchResponse);
|
|
2340
|
+
return fetchResponse;
|
|
2341
|
+
}).catch(async (fetchError) => {
|
|
2342
|
+
let errorData = fetchError.message || fetchError.name;
|
|
2343
|
+
if (options.onFetchError) {
|
|
2344
|
+
({ error: errorData, data: responseData } = await options.onFetchError({
|
|
2345
|
+
data: responseData,
|
|
2346
|
+
error: fetchError,
|
|
2347
|
+
response: response.value
|
|
2348
|
+
}));
|
|
2349
|
+
}
|
|
2350
|
+
error.value = errorData;
|
|
2351
|
+
if (options.updateDataOnError)
|
|
2352
|
+
data.value = responseData;
|
|
2353
|
+
errorEvent.trigger(fetchError);
|
|
2354
|
+
if (throwOnFailed)
|
|
2355
|
+
throw fetchError;
|
|
2356
|
+
return null;
|
|
2357
|
+
}).finally(() => {
|
|
2358
|
+
if (currentExecuteCounter === executeCounter)
|
|
2359
|
+
loading(false);
|
|
2360
|
+
if (timer)
|
|
2361
|
+
timer.stop();
|
|
2362
|
+
finallyEvent.trigger(null);
|
|
2363
|
+
});
|
|
2364
|
+
};
|
|
2365
|
+
const refetch = toRef(options.refetch);
|
|
2366
|
+
reactivity.watch(
|
|
2367
|
+
[
|
|
2368
|
+
refetch,
|
|
2369
|
+
toRef(url)
|
|
2370
|
+
],
|
|
2371
|
+
([refetch2]) => refetch2 && execute(),
|
|
2372
|
+
{ deep: true }
|
|
2373
|
+
);
|
|
2374
|
+
const shell = {
|
|
2375
|
+
isFinished: reactivity.readonly(isFinished),
|
|
2376
|
+
isFetching: reactivity.readonly(isFetching),
|
|
2377
|
+
statusCode,
|
|
2378
|
+
response,
|
|
2379
|
+
error,
|
|
2380
|
+
data,
|
|
2381
|
+
canAbort,
|
|
2382
|
+
aborted,
|
|
2383
|
+
abort,
|
|
2384
|
+
execute,
|
|
2385
|
+
onFetchResponse: responseEvent.on,
|
|
2386
|
+
onFetchError: errorEvent.on,
|
|
2387
|
+
onFetchFinally: finallyEvent.on,
|
|
2388
|
+
// method
|
|
2389
|
+
get: setMethod("GET"),
|
|
2390
|
+
put: setMethod("PUT"),
|
|
2391
|
+
post: setMethod("POST"),
|
|
2392
|
+
delete: setMethod("DELETE"),
|
|
2393
|
+
patch: setMethod("PATCH"),
|
|
2394
|
+
head: setMethod("HEAD"),
|
|
2395
|
+
options: setMethod("OPTIONS"),
|
|
2396
|
+
// type
|
|
2397
|
+
json: setType("json"),
|
|
2398
|
+
text: setType("text"),
|
|
2399
|
+
blob: setType("blob"),
|
|
2400
|
+
arrayBuffer: setType("arrayBuffer"),
|
|
2401
|
+
formData: setType("formData")
|
|
2402
|
+
};
|
|
2403
|
+
function setMethod(method) {
|
|
2404
|
+
return (payload, payloadType) => {
|
|
2405
|
+
if (!isFetching.value) {
|
|
2406
|
+
config.method = method;
|
|
2407
|
+
config.payload = payload;
|
|
2408
|
+
config.payloadType = payloadType;
|
|
2409
|
+
if (reactivity.isRef(config.payload)) {
|
|
2410
|
+
reactivity.watch(
|
|
2411
|
+
[
|
|
2412
|
+
refetch,
|
|
2413
|
+
toRef(config.payload)
|
|
2414
|
+
],
|
|
2415
|
+
([refetch2]) => refetch2 && execute(),
|
|
2416
|
+
{ deep: true }
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
2419
|
+
return {
|
|
2420
|
+
...shell,
|
|
2421
|
+
then(onFulfilled, onRejected) {
|
|
2422
|
+
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
return void 0;
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function waitUntilFinished() {
|
|
2430
|
+
return new Promise((resolve, reject) => {
|
|
2431
|
+
until(isFinished).toBe(true).then(() => resolve(shell)).catch((error2) => reject(error2));
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
function setType(type) {
|
|
2435
|
+
return () => {
|
|
2436
|
+
if (!isFetching.value) {
|
|
2437
|
+
config.type = type;
|
|
2438
|
+
return {
|
|
2439
|
+
...shell,
|
|
2440
|
+
then(onFulfilled, onRejected) {
|
|
2441
|
+
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
return void 0;
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
if (options.immediate)
|
|
2449
|
+
Promise.resolve().then(() => execute());
|
|
2450
|
+
return {
|
|
2451
|
+
...shell,
|
|
2452
|
+
then(onFulfilled, onRejected) {
|
|
2453
|
+
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function joinPaths(start, end) {
|
|
2458
|
+
if (!start.endsWith("/") && !end.startsWith("/"))
|
|
2459
|
+
return `${start}/${end}`;
|
|
2460
|
+
return `${start}${end}`;
|
|
2461
|
+
}
|
|
2462
|
+
const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
|
|
2463
|
+
const oneMinute = 6e4;
|
|
2464
|
+
function useIdle(timeout = oneMinute, options = {}) {
|
|
2465
|
+
const {
|
|
2466
|
+
initialState = false,
|
|
2467
|
+
listenForVisibilityChange = true,
|
|
2468
|
+
events: events2 = defaultEvents$1,
|
|
2469
|
+
window: window2 = defaultWindow,
|
|
2470
|
+
eventFilter = throttleFilter(50)
|
|
2471
|
+
} = options;
|
|
2472
|
+
const idle = reactivity.ref(initialState);
|
|
2473
|
+
const lastActive = reactivity.ref(timestamp());
|
|
2474
|
+
let timer;
|
|
2475
|
+
const reset = () => {
|
|
2476
|
+
idle.value = false;
|
|
2477
|
+
clearTimeout(timer);
|
|
2478
|
+
timer = setTimeout(() => idle.value = true, timeout);
|
|
2479
|
+
};
|
|
2480
|
+
const onEvent = createFilterWrapper(
|
|
2481
|
+
eventFilter,
|
|
2482
|
+
() => {
|
|
2483
|
+
lastActive.value = timestamp();
|
|
2484
|
+
reset();
|
|
2485
|
+
}
|
|
2486
|
+
);
|
|
2487
|
+
if (window2) {
|
|
2488
|
+
const document2 = window2.document;
|
|
2489
|
+
for (const event of events2)
|
|
2490
|
+
useEventListener(window2, event, onEvent, { passive: true });
|
|
2491
|
+
if (listenForVisibilityChange) {
|
|
2492
|
+
useEventListener(document2, "visibilitychange", () => {
|
|
2493
|
+
if (!document2.hidden)
|
|
2494
|
+
onEvent();
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
reset();
|
|
2498
|
+
}
|
|
2499
|
+
return {
|
|
2500
|
+
idle,
|
|
2501
|
+
lastActive,
|
|
2502
|
+
reset
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
function useNow(options = {}) {
|
|
2506
|
+
const {
|
|
2507
|
+
controls: exposeControls = false,
|
|
2508
|
+
interval = "requestAnimationFrame"
|
|
2509
|
+
} = options;
|
|
2510
|
+
const now2 = reactivity.ref(/* @__PURE__ */ new Date());
|
|
2511
|
+
const update = () => now2.value = /* @__PURE__ */ new Date();
|
|
2512
|
+
const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
|
|
2513
|
+
if (exposeControls) {
|
|
2514
|
+
return {
|
|
2515
|
+
now: now2,
|
|
2516
|
+
...controls
|
|
2517
|
+
};
|
|
2518
|
+
} else {
|
|
2519
|
+
return now2;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
function useObjectUrl(object) {
|
|
2523
|
+
const url = reactivity.ref();
|
|
2524
|
+
const release = () => {
|
|
2525
|
+
if (url.value)
|
|
2526
|
+
URL.revokeObjectURL(url.value);
|
|
2527
|
+
url.value = void 0;
|
|
2528
|
+
};
|
|
2529
|
+
reactivity.watch(
|
|
2530
|
+
() => toValue(object),
|
|
2531
|
+
(newObject) => {
|
|
2532
|
+
release();
|
|
2533
|
+
if (newObject)
|
|
2534
|
+
url.value = URL.createObjectURL(newObject);
|
|
2535
|
+
},
|
|
2536
|
+
{ immediate: true }
|
|
2537
|
+
);
|
|
2538
|
+
tryOnScopeDispose(release);
|
|
2539
|
+
return reactivity.readonly(url);
|
|
2540
|
+
}
|
|
2541
|
+
function useClamp(value, min, max) {
|
|
2542
|
+
if (typeof value === "function" || reactivity.isReadonly(value))
|
|
2543
|
+
return reactivity.computed(() => clamp(toValue(value), toValue(min), toValue(max)));
|
|
2544
|
+
const _value = reactivity.ref(value);
|
|
2545
|
+
return reactivity.computed({
|
|
2546
|
+
get() {
|
|
2547
|
+
return _value.value = clamp(_value.value, toValue(min), toValue(max));
|
|
2548
|
+
},
|
|
2549
|
+
set(value2) {
|
|
2550
|
+
_value.value = clamp(value2, toValue(min), toValue(max));
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
function useOffsetPagination(options) {
|
|
2555
|
+
const {
|
|
2556
|
+
total = Number.POSITIVE_INFINITY,
|
|
2557
|
+
pageSize = 10,
|
|
2558
|
+
page = 1,
|
|
2559
|
+
onPageChange = noop,
|
|
2560
|
+
onPageSizeChange = noop,
|
|
2561
|
+
onPageCountChange = noop
|
|
2562
|
+
} = options;
|
|
2563
|
+
const currentPageSize = useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
|
|
2564
|
+
const pageCount = reactivity.computed(() => Math.max(
|
|
2565
|
+
1,
|
|
2566
|
+
Math.ceil(toValue(total) / toValue(currentPageSize))
|
|
2567
|
+
));
|
|
2568
|
+
const currentPage = useClamp(page, 1, pageCount);
|
|
2569
|
+
const isFirstPage = reactivity.computed(() => currentPage.value === 1);
|
|
2570
|
+
const isLastPage = reactivity.computed(() => currentPage.value === pageCount.value);
|
|
2571
|
+
if (reactivity.isRef(page)) {
|
|
2572
|
+
syncRef(page, currentPage, {
|
|
2573
|
+
direction: reactivity.isReadonly(page) ? "ltr" : "both"
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
if (reactivity.isRef(pageSize)) {
|
|
2577
|
+
syncRef(pageSize, currentPageSize, {
|
|
2578
|
+
direction: reactivity.isReadonly(pageSize) ? "ltr" : "both"
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
function prev() {
|
|
2582
|
+
currentPage.value--;
|
|
2583
|
+
}
|
|
2584
|
+
function next() {
|
|
2585
|
+
currentPage.value++;
|
|
2586
|
+
}
|
|
2587
|
+
const returnValue = {
|
|
2588
|
+
currentPage,
|
|
2589
|
+
currentPageSize,
|
|
2590
|
+
pageCount,
|
|
2591
|
+
isFirstPage,
|
|
2592
|
+
isLastPage,
|
|
2593
|
+
prev,
|
|
2594
|
+
next
|
|
2595
|
+
};
|
|
2596
|
+
reactivity.watch(currentPage, () => {
|
|
2597
|
+
onPageChange(reactivity.reactive(returnValue));
|
|
2598
|
+
});
|
|
2599
|
+
reactivity.watch(currentPageSize, () => {
|
|
2600
|
+
onPageSizeChange(reactivity.reactive(returnValue));
|
|
2601
|
+
});
|
|
2602
|
+
reactivity.watch(pageCount, () => {
|
|
2603
|
+
onPageCountChange(reactivity.reactive(returnValue));
|
|
2604
|
+
});
|
|
2605
|
+
return returnValue;
|
|
2606
|
+
}
|
|
2607
|
+
function usePrevious(value, initialValue) {
|
|
2608
|
+
const previous = reactivity.shallowRef(initialValue);
|
|
2609
|
+
reactivity.watch(
|
|
2610
|
+
toRef(value),
|
|
2611
|
+
(_, oldValue) => {
|
|
2612
|
+
previous.value = oldValue;
|
|
2613
|
+
},
|
|
2614
|
+
{ flush: "sync" }
|
|
2615
|
+
);
|
|
2616
|
+
return reactivity.readonly(previous);
|
|
2617
|
+
}
|
|
2618
|
+
const defaultSortFn = (source, compareFn) => source.sort(compareFn);
|
|
2619
|
+
const defaultCompare = (a, b) => a - b;
|
|
2620
|
+
function useSorted(...args) {
|
|
2621
|
+
var _a, _b, _c, _d;
|
|
2622
|
+
const [source] = args;
|
|
2623
|
+
let compareFn = defaultCompare;
|
|
2624
|
+
let options = {};
|
|
2625
|
+
if (args.length === 2) {
|
|
2626
|
+
if (typeof args[1] === "object") {
|
|
2627
|
+
options = args[1];
|
|
2628
|
+
compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
|
|
2629
|
+
} else {
|
|
2630
|
+
compareFn = (_b = args[1]) != null ? _b : defaultCompare;
|
|
2631
|
+
}
|
|
2632
|
+
} else if (args.length > 2) {
|
|
2633
|
+
compareFn = (_c = args[1]) != null ? _c : defaultCompare;
|
|
2634
|
+
options = (_d = args[2]) != null ? _d : {};
|
|
2635
|
+
}
|
|
2636
|
+
const {
|
|
2637
|
+
dirty = false,
|
|
2638
|
+
sortFn = defaultSortFn
|
|
2639
|
+
} = options;
|
|
2640
|
+
if (!dirty)
|
|
2641
|
+
return reactivity.computed(() => sortFn([...toValue(source)], compareFn));
|
|
2642
|
+
reactivity.watchEffect(() => {
|
|
2643
|
+
const result = sortFn(toValue(source), compareFn);
|
|
2644
|
+
if (reactivity.isRef(source))
|
|
2645
|
+
source.value = result;
|
|
2646
|
+
else
|
|
2647
|
+
source.splice(0, source.length, ...result);
|
|
2648
|
+
});
|
|
2649
|
+
return source;
|
|
2650
|
+
}
|
|
2651
|
+
function useStepper(steps, initialStep) {
|
|
2652
|
+
const stepsRef = reactivity.ref(steps);
|
|
2653
|
+
const stepNames = reactivity.computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
|
|
2654
|
+
const index = reactivity.ref(stepNames.value.indexOf(initialStep != null ? initialStep : stepNames.value[0]));
|
|
2655
|
+
const current = reactivity.computed(() => at(index.value));
|
|
2656
|
+
const isFirst = reactivity.computed(() => index.value === 0);
|
|
2657
|
+
const isLast = reactivity.computed(() => index.value === stepNames.value.length - 1);
|
|
2658
|
+
const next = reactivity.computed(() => stepNames.value[index.value + 1]);
|
|
2659
|
+
const previous = reactivity.computed(() => stepNames.value[index.value - 1]);
|
|
2660
|
+
function at(index2) {
|
|
2661
|
+
if (Array.isArray(stepsRef.value))
|
|
2662
|
+
return stepsRef.value[index2];
|
|
2663
|
+
return stepsRef.value[stepNames.value[index2]];
|
|
2664
|
+
}
|
|
2665
|
+
function get2(step) {
|
|
2666
|
+
if (!stepNames.value.includes(step))
|
|
2667
|
+
return;
|
|
2668
|
+
return at(stepNames.value.indexOf(step));
|
|
2669
|
+
}
|
|
2670
|
+
function goTo(step) {
|
|
2671
|
+
if (stepNames.value.includes(step))
|
|
2672
|
+
index.value = stepNames.value.indexOf(step);
|
|
2673
|
+
}
|
|
2674
|
+
function goToNext() {
|
|
2675
|
+
if (isLast.value)
|
|
2676
|
+
return;
|
|
2677
|
+
index.value++;
|
|
2678
|
+
}
|
|
2679
|
+
function goToPrevious() {
|
|
2680
|
+
if (isFirst.value)
|
|
2681
|
+
return;
|
|
2682
|
+
index.value--;
|
|
2683
|
+
}
|
|
2684
|
+
function goBackTo(step) {
|
|
2685
|
+
if (isAfter(step))
|
|
2686
|
+
goTo(step);
|
|
2687
|
+
}
|
|
2688
|
+
function isNext(step) {
|
|
2689
|
+
return stepNames.value.indexOf(step) === index.value + 1;
|
|
2690
|
+
}
|
|
2691
|
+
function isPrevious(step) {
|
|
2692
|
+
return stepNames.value.indexOf(step) === index.value - 1;
|
|
2693
|
+
}
|
|
2694
|
+
function isCurrent(step) {
|
|
2695
|
+
return stepNames.value.indexOf(step) === index.value;
|
|
2696
|
+
}
|
|
2697
|
+
function isBefore(step) {
|
|
2698
|
+
return index.value < stepNames.value.indexOf(step);
|
|
2699
|
+
}
|
|
2700
|
+
function isAfter(step) {
|
|
2701
|
+
return index.value > stepNames.value.indexOf(step);
|
|
2702
|
+
}
|
|
2703
|
+
return {
|
|
2704
|
+
steps: stepsRef,
|
|
2705
|
+
stepNames,
|
|
2706
|
+
index,
|
|
2707
|
+
current,
|
|
2708
|
+
next,
|
|
2709
|
+
previous,
|
|
2710
|
+
isFirst,
|
|
2711
|
+
isLast,
|
|
2712
|
+
at,
|
|
2713
|
+
get: get2,
|
|
2714
|
+
goTo,
|
|
2715
|
+
goToNext,
|
|
2716
|
+
goToPrevious,
|
|
2717
|
+
goBackTo,
|
|
2718
|
+
isNext,
|
|
2719
|
+
isPrevious,
|
|
2720
|
+
isCurrent,
|
|
2721
|
+
isBefore,
|
|
2722
|
+
isAfter
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
function useThrottledRefHistory(source, options = {}) {
|
|
2726
|
+
const { throttle = 200, trailing = true } = options;
|
|
2727
|
+
const filter = throttleFilter(throttle, trailing);
|
|
2728
|
+
const history = useRefHistory(source, { ...options, eventFilter: filter });
|
|
2729
|
+
return {
|
|
2730
|
+
...history
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
const DEFAULT_UNITS = [
|
|
2734
|
+
{ max: 6e4, value: 1e3, name: "second" },
|
|
2735
|
+
{ max: 276e4, value: 6e4, name: "minute" },
|
|
2736
|
+
{ max: 72e6, value: 36e5, name: "hour" },
|
|
2737
|
+
{ max: 5184e5, value: 864e5, name: "day" },
|
|
2738
|
+
{ max: 24192e5, value: 6048e5, name: "week" },
|
|
2739
|
+
{ max: 28512e6, value: 2592e6, name: "month" },
|
|
2740
|
+
{ max: Number.POSITIVE_INFINITY, value: 31536e6, name: "year" }
|
|
2741
|
+
];
|
|
2742
|
+
const DEFAULT_MESSAGES = {
|
|
2743
|
+
justNow: "just now",
|
|
2744
|
+
past: (n) => n.match(/\d/) ? `${n} ago` : n,
|
|
2745
|
+
future: (n) => n.match(/\d/) ? `in ${n}` : n,
|
|
2746
|
+
month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`,
|
|
2747
|
+
year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`,
|
|
2748
|
+
day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`,
|
|
2749
|
+
week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
|
|
2750
|
+
hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
|
|
2751
|
+
minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
|
|
2752
|
+
second: (n) => `${n} second${n > 1 ? "s" : ""}`,
|
|
2753
|
+
invalid: ""
|
|
2754
|
+
};
|
|
2755
|
+
function DEFAULT_FORMATTER(date) {
|
|
2756
|
+
return date.toISOString().slice(0, 10);
|
|
2757
|
+
}
|
|
2758
|
+
function useTimeAgo(time, options = {}) {
|
|
2759
|
+
const {
|
|
2760
|
+
controls: exposeControls = false,
|
|
2761
|
+
updateInterval = 3e4
|
|
2762
|
+
} = options;
|
|
2763
|
+
const { now: now2, ...controls } = useNow({ interval: updateInterval, controls: true });
|
|
2764
|
+
const timeAgo = reactivity.computed(() => formatTimeAgo(new Date(toValue(time)), options, toValue(now2)));
|
|
2765
|
+
if (exposeControls) {
|
|
2766
|
+
return {
|
|
2767
|
+
timeAgo,
|
|
2768
|
+
...controls
|
|
2769
|
+
};
|
|
2770
|
+
} else {
|
|
2771
|
+
return timeAgo;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
function formatTimeAgo(from, options = {}, now2 = Date.now()) {
|
|
2775
|
+
var _a;
|
|
2776
|
+
const {
|
|
2777
|
+
max,
|
|
2778
|
+
messages = DEFAULT_MESSAGES,
|
|
2779
|
+
fullDateFormatter = DEFAULT_FORMATTER,
|
|
2780
|
+
units = DEFAULT_UNITS,
|
|
2781
|
+
showSecond = false,
|
|
2782
|
+
rounding = "round"
|
|
2783
|
+
} = options;
|
|
2784
|
+
const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
|
|
2785
|
+
const diff = +now2 - +from;
|
|
2786
|
+
const absDiff = Math.abs(diff);
|
|
2787
|
+
function getValue(diff2, unit) {
|
|
2788
|
+
return roundFn(Math.abs(diff2) / unit.value);
|
|
2789
|
+
}
|
|
2790
|
+
function format(diff2, unit) {
|
|
2791
|
+
const val = getValue(diff2, unit);
|
|
2792
|
+
const past = diff2 > 0;
|
|
2793
|
+
const str = applyFormat(unit.name, val, past);
|
|
2794
|
+
return applyFormat(past ? "past" : "future", str, past);
|
|
2795
|
+
}
|
|
2796
|
+
function applyFormat(name, val, isPast) {
|
|
2797
|
+
const formatter = messages[name];
|
|
2798
|
+
if (typeof formatter === "function")
|
|
2799
|
+
return formatter(val, isPast);
|
|
2800
|
+
return formatter.replace("{0}", val.toString());
|
|
2801
|
+
}
|
|
2802
|
+
if (absDiff < 6e4 && !showSecond)
|
|
2803
|
+
return messages.justNow;
|
|
2804
|
+
if (typeof max === "number" && absDiff > max)
|
|
2805
|
+
return fullDateFormatter(new Date(from));
|
|
2806
|
+
if (typeof max === "string") {
|
|
2807
|
+
const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
|
|
2808
|
+
if (unitMax && absDiff > unitMax)
|
|
2809
|
+
return fullDateFormatter(new Date(from));
|
|
2810
|
+
}
|
|
2811
|
+
for (const [idx, unit] of units.entries()) {
|
|
2812
|
+
const val = getValue(diff, unit);
|
|
2813
|
+
if (val <= 0 && units[idx - 1])
|
|
2814
|
+
return format(diff, units[idx - 1]);
|
|
2815
|
+
if (absDiff < unit.max)
|
|
2816
|
+
return format(diff, unit);
|
|
2817
|
+
}
|
|
2818
|
+
return messages.invalid;
|
|
2819
|
+
}
|
|
2820
|
+
function useTimeoutPoll(fn, interval, timeoutPollOptions) {
|
|
2821
|
+
const { start } = useTimeoutFn(loop, interval, { immediate: false });
|
|
2822
|
+
const isActive = reactivity.ref(false);
|
|
2823
|
+
async function loop() {
|
|
2824
|
+
if (!isActive.value)
|
|
2825
|
+
return;
|
|
2826
|
+
await fn();
|
|
2827
|
+
start();
|
|
2828
|
+
}
|
|
2829
|
+
function resume() {
|
|
2830
|
+
if (!isActive.value) {
|
|
2831
|
+
isActive.value = true;
|
|
2832
|
+
loop();
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
function pause() {
|
|
2836
|
+
isActive.value = false;
|
|
2837
|
+
}
|
|
2838
|
+
if (timeoutPollOptions == null ? void 0 : timeoutPollOptions.immediate)
|
|
2839
|
+
resume();
|
|
2840
|
+
tryOnScopeDispose(pause);
|
|
2841
|
+
return {
|
|
2842
|
+
isActive,
|
|
2843
|
+
pause,
|
|
2844
|
+
resume
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
function useTimestamp(options = {}) {
|
|
2848
|
+
const {
|
|
2849
|
+
controls: exposeControls = false,
|
|
2850
|
+
offset = 0,
|
|
2851
|
+
immediate = true,
|
|
2852
|
+
interval = "requestAnimationFrame",
|
|
2853
|
+
callback
|
|
2854
|
+
} = options;
|
|
2855
|
+
const ts = reactivity.ref(timestamp() + offset);
|
|
2856
|
+
const update = () => ts.value = timestamp() + offset;
|
|
2857
|
+
const cb = callback ? () => {
|
|
2858
|
+
update();
|
|
2859
|
+
callback(ts.value);
|
|
2860
|
+
} : update;
|
|
2861
|
+
const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
|
|
2862
|
+
if (exposeControls) {
|
|
2863
|
+
return {
|
|
2864
|
+
timestamp: ts,
|
|
2865
|
+
...controls
|
|
2866
|
+
};
|
|
2867
|
+
} else {
|
|
2868
|
+
return ts;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
function useUrlSearchParams(mode = "history", options = {}) {
|
|
2872
|
+
const {
|
|
2873
|
+
initialValue = {},
|
|
2874
|
+
removeNullishValues = true,
|
|
2875
|
+
removeFalsyValues = false,
|
|
2876
|
+
write: enableWrite = true,
|
|
2877
|
+
window: window2 = defaultWindow
|
|
2878
|
+
} = options;
|
|
2879
|
+
if (!window2)
|
|
2880
|
+
return reactivity.reactive(initialValue);
|
|
2881
|
+
const state = reactivity.reactive({});
|
|
2882
|
+
function getRawParams() {
|
|
2883
|
+
if (mode === "history") {
|
|
2884
|
+
return window2.location.search || "";
|
|
2885
|
+
} else if (mode === "hash") {
|
|
2886
|
+
const hash = window2.location.hash || "";
|
|
2887
|
+
const index = hash.indexOf("?");
|
|
2888
|
+
return index > 0 ? hash.slice(index) : "";
|
|
2889
|
+
} else {
|
|
2890
|
+
return (window2.location.hash || "").replace(/^#/, "");
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
function constructQuery(params) {
|
|
2894
|
+
const stringified = params.toString();
|
|
2895
|
+
if (mode === "history")
|
|
2896
|
+
return `${stringified ? `?${stringified}` : ""}${window2.location.hash || ""}`;
|
|
2897
|
+
if (mode === "hash-params")
|
|
2898
|
+
return `${window2.location.search || ""}${stringified ? `#${stringified}` : ""}`;
|
|
2899
|
+
const hash = window2.location.hash || "#";
|
|
2900
|
+
const index = hash.indexOf("?");
|
|
2901
|
+
if (index > 0)
|
|
2902
|
+
return `${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
|
|
2903
|
+
return `${hash}${stringified ? `?${stringified}` : ""}`;
|
|
2904
|
+
}
|
|
2905
|
+
function read() {
|
|
2906
|
+
return new URLSearchParams(getRawParams());
|
|
2907
|
+
}
|
|
2908
|
+
function updateState(params) {
|
|
2909
|
+
const unusedKeys = new Set(Object.keys(state));
|
|
2910
|
+
for (const key of params.keys()) {
|
|
2911
|
+
const paramsForKey = params.getAll(key);
|
|
2912
|
+
state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
|
|
2913
|
+
unusedKeys.delete(key);
|
|
2914
|
+
}
|
|
2915
|
+
Array.from(unusedKeys).forEach((key) => delete state[key]);
|
|
2916
|
+
}
|
|
2917
|
+
const { pause, resume } = watchPausable(
|
|
2918
|
+
state,
|
|
2919
|
+
() => {
|
|
2920
|
+
const params = new URLSearchParams("");
|
|
2921
|
+
Object.keys(state).forEach((key) => {
|
|
2922
|
+
const mapEntry = state[key];
|
|
2923
|
+
if (Array.isArray(mapEntry))
|
|
2924
|
+
mapEntry.forEach((value) => params.append(key, value));
|
|
2925
|
+
else if (removeNullishValues && mapEntry == null)
|
|
2926
|
+
params.delete(key);
|
|
2927
|
+
else if (removeFalsyValues && !mapEntry)
|
|
2928
|
+
params.delete(key);
|
|
2929
|
+
else
|
|
2930
|
+
params.set(key, mapEntry);
|
|
2931
|
+
});
|
|
2932
|
+
write(params);
|
|
2933
|
+
},
|
|
2934
|
+
{ deep: true }
|
|
2935
|
+
);
|
|
2936
|
+
function write(params, shouldUpdate) {
|
|
2937
|
+
pause();
|
|
2938
|
+
if (shouldUpdate)
|
|
2939
|
+
updateState(params);
|
|
2940
|
+
window2.history.replaceState(
|
|
2941
|
+
window2.history.state,
|
|
2942
|
+
window2.document.title,
|
|
2943
|
+
window2.location.pathname + constructQuery(params)
|
|
2944
|
+
);
|
|
2945
|
+
resume();
|
|
2946
|
+
}
|
|
2947
|
+
function onChanged() {
|
|
2948
|
+
if (!enableWrite)
|
|
2949
|
+
return;
|
|
2950
|
+
write(read(), true);
|
|
2951
|
+
}
|
|
2952
|
+
useEventListener(window2, "popstate", onChanged, false);
|
|
2953
|
+
if (mode !== "history")
|
|
2954
|
+
useEventListener(window2, "hashchange", onChanged, false);
|
|
2955
|
+
const initial = read();
|
|
2956
|
+
if (initial.keys().next().value)
|
|
2957
|
+
updateState(initial);
|
|
2958
|
+
else
|
|
2959
|
+
Object.assign(state, initialValue);
|
|
2960
|
+
return state;
|
|
2961
|
+
}
|
|
2962
|
+
const DEFAULT_PING_MESSAGE = "ping";
|
|
2963
|
+
function resolveNestedOptions(options) {
|
|
2964
|
+
if (options === true)
|
|
2965
|
+
return {};
|
|
2966
|
+
return options;
|
|
2967
|
+
}
|
|
2968
|
+
function useWebSocket(url, options = {}) {
|
|
2969
|
+
const {
|
|
2970
|
+
onConnected,
|
|
2971
|
+
onDisconnected,
|
|
2972
|
+
onError,
|
|
2973
|
+
onMessage,
|
|
2974
|
+
immediate = true,
|
|
2975
|
+
autoClose = true,
|
|
2976
|
+
protocols = []
|
|
2977
|
+
} = options;
|
|
2978
|
+
const data = reactivity.ref(null);
|
|
2979
|
+
const status = reactivity.ref("CLOSED");
|
|
2980
|
+
const wsRef = reactivity.ref();
|
|
2981
|
+
const urlRef = toRef(url);
|
|
2982
|
+
let heartbeatPause;
|
|
2983
|
+
let heartbeatResume;
|
|
2984
|
+
let explicitlyClosed = false;
|
|
2985
|
+
let retried = 0;
|
|
2986
|
+
let bufferedData = [];
|
|
2987
|
+
let pongTimeoutWait;
|
|
2988
|
+
const _sendBuffer = () => {
|
|
2989
|
+
if (bufferedData.length && wsRef.value && status.value === "OPEN") {
|
|
2990
|
+
for (const buffer of bufferedData)
|
|
2991
|
+
wsRef.value.send(buffer);
|
|
2992
|
+
bufferedData = [];
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
2995
|
+
const resetHeartbeat = () => {
|
|
2996
|
+
clearTimeout(pongTimeoutWait);
|
|
2997
|
+
pongTimeoutWait = void 0;
|
|
2998
|
+
};
|
|
2999
|
+
const close = (code = 1e3, reason) => {
|
|
3000
|
+
if (!isClient || !wsRef.value)
|
|
3001
|
+
return;
|
|
3002
|
+
explicitlyClosed = true;
|
|
3003
|
+
resetHeartbeat();
|
|
3004
|
+
heartbeatPause == null ? void 0 : heartbeatPause();
|
|
3005
|
+
wsRef.value.close(code, reason);
|
|
3006
|
+
wsRef.value = void 0;
|
|
3007
|
+
};
|
|
3008
|
+
const send = (data2, useBuffer = true) => {
|
|
3009
|
+
if (!wsRef.value || status.value !== "OPEN") {
|
|
3010
|
+
if (useBuffer)
|
|
3011
|
+
bufferedData.push(data2);
|
|
3012
|
+
return false;
|
|
3013
|
+
}
|
|
3014
|
+
_sendBuffer();
|
|
3015
|
+
wsRef.value.send(data2);
|
|
3016
|
+
return true;
|
|
3017
|
+
};
|
|
3018
|
+
const _init = () => {
|
|
3019
|
+
if (explicitlyClosed || typeof urlRef.value === "undefined")
|
|
3020
|
+
return;
|
|
3021
|
+
const ws = new WebSocket(urlRef.value, protocols);
|
|
3022
|
+
wsRef.value = ws;
|
|
3023
|
+
status.value = "CONNECTING";
|
|
3024
|
+
ws.onopen = () => {
|
|
3025
|
+
status.value = "OPEN";
|
|
3026
|
+
retried = 0;
|
|
3027
|
+
onConnected == null ? void 0 : onConnected(ws);
|
|
3028
|
+
heartbeatResume == null ? void 0 : heartbeatResume();
|
|
3029
|
+
_sendBuffer();
|
|
3030
|
+
};
|
|
3031
|
+
ws.onclose = (ev) => {
|
|
3032
|
+
status.value = "CLOSED";
|
|
3033
|
+
onDisconnected == null ? void 0 : onDisconnected(ws, ev);
|
|
3034
|
+
if (!explicitlyClosed && options.autoReconnect && ws === wsRef.value) {
|
|
3035
|
+
const {
|
|
3036
|
+
retries = -1,
|
|
3037
|
+
delay = 1e3,
|
|
3038
|
+
onFailed
|
|
3039
|
+
} = resolveNestedOptions(options.autoReconnect);
|
|
3040
|
+
if (typeof retries === "number" && (retries < 0 || retried < retries)) {
|
|
3041
|
+
retried += 1;
|
|
3042
|
+
setTimeout(_init, delay);
|
|
3043
|
+
} else if (typeof retries === "function" && retries()) {
|
|
3044
|
+
setTimeout(_init, delay);
|
|
3045
|
+
} else {
|
|
3046
|
+
onFailed == null ? void 0 : onFailed();
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
ws.onerror = (e) => {
|
|
3051
|
+
onError == null ? void 0 : onError(ws, e);
|
|
3052
|
+
};
|
|
3053
|
+
ws.onmessage = (e) => {
|
|
3054
|
+
if (options.heartbeat) {
|
|
3055
|
+
resetHeartbeat();
|
|
3056
|
+
const {
|
|
3057
|
+
message = DEFAULT_PING_MESSAGE,
|
|
3058
|
+
responseMessage = message
|
|
3059
|
+
} = resolveNestedOptions(options.heartbeat);
|
|
3060
|
+
if (e.data === responseMessage)
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
data.value = e.data;
|
|
3064
|
+
onMessage == null ? void 0 : onMessage(ws, e);
|
|
3065
|
+
};
|
|
3066
|
+
};
|
|
3067
|
+
if (options.heartbeat) {
|
|
3068
|
+
const {
|
|
3069
|
+
message = DEFAULT_PING_MESSAGE,
|
|
3070
|
+
interval = 1e3,
|
|
3071
|
+
pongTimeout = 1e3
|
|
3072
|
+
} = resolveNestedOptions(options.heartbeat);
|
|
3073
|
+
const { pause, resume } = useIntervalFn(
|
|
3074
|
+
() => {
|
|
3075
|
+
send(message, false);
|
|
3076
|
+
if (pongTimeoutWait != null)
|
|
3077
|
+
return;
|
|
3078
|
+
pongTimeoutWait = setTimeout(() => {
|
|
3079
|
+
close();
|
|
3080
|
+
explicitlyClosed = false;
|
|
3081
|
+
}, pongTimeout);
|
|
3082
|
+
},
|
|
3083
|
+
interval,
|
|
3084
|
+
{ immediate: false }
|
|
3085
|
+
);
|
|
3086
|
+
heartbeatPause = pause;
|
|
3087
|
+
heartbeatResume = resume;
|
|
3088
|
+
}
|
|
3089
|
+
if (autoClose) {
|
|
3090
|
+
if (isClient)
|
|
3091
|
+
useEventListener("beforeunload", () => close());
|
|
3092
|
+
tryOnScopeDispose(close);
|
|
3093
|
+
}
|
|
3094
|
+
const open = () => {
|
|
3095
|
+
if (!isClient && !isWorker)
|
|
3096
|
+
return;
|
|
3097
|
+
close();
|
|
3098
|
+
explicitlyClosed = false;
|
|
3099
|
+
retried = 0;
|
|
3100
|
+
_init();
|
|
3101
|
+
};
|
|
3102
|
+
if (immediate)
|
|
3103
|
+
open();
|
|
3104
|
+
reactivity.watch(urlRef, open);
|
|
3105
|
+
return {
|
|
3106
|
+
data,
|
|
3107
|
+
status,
|
|
3108
|
+
close,
|
|
3109
|
+
send,
|
|
3110
|
+
open,
|
|
3111
|
+
ws: wsRef
|
|
3112
|
+
};
|
|
3113
|
+
}
|
|
3114
|
+
function depsParser(deps, localDeps) {
|
|
3115
|
+
if (deps.length === 0 && localDeps.length === 0)
|
|
3116
|
+
return "";
|
|
3117
|
+
const depsString = deps.map((dep) => `'${dep}'`).toString();
|
|
3118
|
+
const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => {
|
|
3119
|
+
const str = fn.toString();
|
|
3120
|
+
if (str.trim().startsWith("function")) {
|
|
3121
|
+
return str;
|
|
3122
|
+
} else {
|
|
3123
|
+
const name = fn.name;
|
|
3124
|
+
return `const ${name} = ${str}`;
|
|
3125
|
+
}
|
|
3126
|
+
}).join(";");
|
|
3127
|
+
const importString = `importScripts(${depsString});`;
|
|
3128
|
+
return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
|
|
3129
|
+
}
|
|
3130
|
+
function jobRunner(userFunc) {
|
|
3131
|
+
return (e) => {
|
|
3132
|
+
const userFuncArgs = e.data[0];
|
|
3133
|
+
return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
|
|
3134
|
+
postMessage(["SUCCESS", result]);
|
|
3135
|
+
}).catch((error) => {
|
|
3136
|
+
postMessage(["ERROR", error]);
|
|
3137
|
+
});
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
function createWorkerBlobUrl(fn, deps, localDeps) {
|
|
3141
|
+
const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
|
|
3142
|
+
const blob = new Blob([blobCode], { type: "text/javascript" });
|
|
3143
|
+
const url = URL.createObjectURL(blob);
|
|
3144
|
+
return url;
|
|
3145
|
+
}
|
|
3146
|
+
function useWebWorkerFn(fn, options = {}) {
|
|
3147
|
+
const {
|
|
3148
|
+
dependencies = [],
|
|
3149
|
+
localDependencies = [],
|
|
3150
|
+
timeout,
|
|
3151
|
+
window: window2 = defaultWindow
|
|
3152
|
+
} = options;
|
|
3153
|
+
const worker = reactivity.ref();
|
|
3154
|
+
const workerStatus = reactivity.ref("PENDING");
|
|
3155
|
+
const promise = reactivity.ref({});
|
|
3156
|
+
const timeoutId = reactivity.ref();
|
|
3157
|
+
const workerTerminate = (status = "PENDING") => {
|
|
3158
|
+
if (worker.value && worker.value._url && window2) {
|
|
3159
|
+
worker.value.terminate();
|
|
3160
|
+
URL.revokeObjectURL(worker.value._url);
|
|
3161
|
+
promise.value = {};
|
|
3162
|
+
worker.value = void 0;
|
|
3163
|
+
window2.clearTimeout(timeoutId.value);
|
|
3164
|
+
workerStatus.value = status;
|
|
3165
|
+
}
|
|
3166
|
+
};
|
|
3167
|
+
workerTerminate();
|
|
3168
|
+
tryOnScopeDispose(workerTerminate);
|
|
3169
|
+
const generateWorker = () => {
|
|
3170
|
+
const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies);
|
|
3171
|
+
const newWorker = new Worker(blobUrl);
|
|
3172
|
+
newWorker._url = blobUrl;
|
|
3173
|
+
newWorker.onmessage = (e) => {
|
|
3174
|
+
const { resolve = () => {
|
|
3175
|
+
}, reject = () => {
|
|
3176
|
+
} } = promise.value;
|
|
3177
|
+
const [status, result] = e.data;
|
|
3178
|
+
switch (status) {
|
|
3179
|
+
case "SUCCESS":
|
|
3180
|
+
resolve(result);
|
|
3181
|
+
workerTerminate(status);
|
|
3182
|
+
break;
|
|
3183
|
+
default:
|
|
3184
|
+
reject(result);
|
|
3185
|
+
workerTerminate("ERROR");
|
|
3186
|
+
break;
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
3189
|
+
newWorker.onerror = (e) => {
|
|
3190
|
+
const { reject = () => {
|
|
3191
|
+
} } = promise.value;
|
|
3192
|
+
e.preventDefault();
|
|
3193
|
+
reject(e);
|
|
3194
|
+
workerTerminate("ERROR");
|
|
3195
|
+
};
|
|
3196
|
+
if (timeout) {
|
|
3197
|
+
timeoutId.value = setTimeout(
|
|
3198
|
+
() => workerTerminate("TIMEOUT_EXPIRED"),
|
|
3199
|
+
timeout
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
return newWorker;
|
|
3203
|
+
};
|
|
3204
|
+
const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
|
|
3205
|
+
var _a;
|
|
3206
|
+
promise.value = {
|
|
3207
|
+
resolve,
|
|
3208
|
+
reject
|
|
3209
|
+
};
|
|
3210
|
+
(_a = worker.value) == null ? void 0 : _a.postMessage([[...fnArgs]]);
|
|
3211
|
+
workerStatus.value = "RUNNING";
|
|
3212
|
+
});
|
|
3213
|
+
const workerFn = (...fnArgs) => {
|
|
3214
|
+
if (workerStatus.value === "RUNNING") {
|
|
3215
|
+
console.error(
|
|
3216
|
+
"[useWebWorkerFn] You can only run one instance of the worker at a time."
|
|
3217
|
+
);
|
|
3218
|
+
return Promise.reject();
|
|
3219
|
+
}
|
|
3220
|
+
worker.value = generateWorker();
|
|
3221
|
+
return callWorker(...fnArgs);
|
|
3222
|
+
};
|
|
3223
|
+
return {
|
|
3224
|
+
workerFn,
|
|
3225
|
+
workerStatus,
|
|
3226
|
+
workerTerminate
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
exports.assert = assert;
|
|
3230
|
+
exports.asyncComputed = computedAsync;
|
|
3231
|
+
exports.autoResetRef = refAutoReset;
|
|
3232
|
+
exports.bypassFilter = bypassFilter;
|
|
3233
|
+
exports.camelize = camelize;
|
|
3234
|
+
exports.clamp = clamp;
|
|
3235
|
+
exports.cloneFnJSON = cloneFnJSON;
|
|
3236
|
+
exports.computedAsync = computedAsync;
|
|
3237
|
+
exports.computedWithControl = computedWithControl;
|
|
3238
|
+
exports.containsProp = containsProp;
|
|
3239
|
+
exports.controlledComputed = computedWithControl;
|
|
3240
|
+
exports.controlledRef = controlledRef;
|
|
3241
|
+
exports.createEventHook = createEventHook;
|
|
3242
|
+
exports.createFetch = createFetch;
|
|
3243
|
+
exports.createFilterWrapper = createFilterWrapper;
|
|
3244
|
+
exports.createGlobalState = createGlobalState;
|
|
3245
|
+
exports.createReactiveFn = reactify;
|
|
3246
|
+
exports.createSharedComposable = createSharedComposable;
|
|
3247
|
+
exports.createSingletonPromise = createSingletonPromise;
|
|
3248
|
+
exports.createUnrefFn = createUnrefFn;
|
|
3249
|
+
exports.debounceFilter = debounceFilter;
|
|
3250
|
+
exports.debouncedRef = refDebounced;
|
|
3251
|
+
exports.debouncedWatch = watchDebounced;
|
|
3252
|
+
exports.extendRef = extendRef;
|
|
3253
|
+
exports.formatDate = formatDate;
|
|
3254
|
+
exports.formatTimeAgo = formatTimeAgo;
|
|
3255
|
+
exports.get = get;
|
|
3256
|
+
exports.getLifeCycleTarget = getLifeCycleTarget;
|
|
3257
|
+
exports.hasOwn = hasOwn;
|
|
3258
|
+
exports.hyphenate = hyphenate;
|
|
3259
|
+
exports.identity = identity;
|
|
3260
|
+
exports.ignorableWatch = watchIgnorable;
|
|
3261
|
+
exports.increaseWithUnit = increaseWithUnit;
|
|
3262
|
+
exports.invoke = invoke;
|
|
3263
|
+
exports.isDef = isDef;
|
|
3264
|
+
exports.isDefined = isDefined;
|
|
3265
|
+
exports.isObject = isObject;
|
|
3266
|
+
exports.makeDestructurable = makeDestructurable;
|
|
3267
|
+
exports.noop = noop;
|
|
3268
|
+
exports.normalizeDate = normalizeDate;
|
|
3269
|
+
exports.notNullish = notNullish;
|
|
3270
|
+
exports.now = now;
|
|
3271
|
+
exports.objectEntries = objectEntries;
|
|
3272
|
+
exports.objectOmit = objectOmit;
|
|
3273
|
+
exports.objectPick = objectPick;
|
|
3274
|
+
exports.pausableFilter = pausableFilter;
|
|
3275
|
+
exports.pausableWatch = watchPausable;
|
|
3276
|
+
exports.promiseTimeout = promiseTimeout;
|
|
3277
|
+
exports.rand = rand;
|
|
3278
|
+
exports.reactify = reactify;
|
|
3279
|
+
exports.reactifyObject = reactifyObject;
|
|
3280
|
+
exports.reactiveComputed = reactiveComputed;
|
|
3281
|
+
exports.reactiveOmit = reactiveOmit;
|
|
3282
|
+
exports.reactivePick = reactivePick;
|
|
3283
|
+
exports.refAutoReset = refAutoReset;
|
|
3284
|
+
exports.refDebounced = refDebounced;
|
|
3285
|
+
exports.refDefault = refDefault;
|
|
3286
|
+
exports.refThrottled = refThrottled;
|
|
3287
|
+
exports.refWithControl = refWithControl;
|
|
3288
|
+
exports.resolveRef = resolveRef;
|
|
3289
|
+
exports.resolveUnref = resolveUnref;
|
|
3290
|
+
exports.set = set;
|
|
3291
|
+
exports.syncRef = syncRef;
|
|
3292
|
+
exports.syncRefs = syncRefs;
|
|
3293
|
+
exports.throttleFilter = throttleFilter;
|
|
3294
|
+
exports.throttledRef = refThrottled;
|
|
3295
|
+
exports.throttledWatch = watchThrottled;
|
|
3296
|
+
exports.toReactive = toReactive;
|
|
3297
|
+
exports.toRef = toRef;
|
|
3298
|
+
exports.toRefs = toRefs;
|
|
3299
|
+
exports.toValue = toValue;
|
|
3300
|
+
exports.tryOnScopeDispose = tryOnScopeDispose;
|
|
3301
|
+
exports.until = until;
|
|
3302
|
+
exports.useArrayDifference = useArrayDifference;
|
|
3303
|
+
exports.useArrayEvery = useArrayEvery;
|
|
3304
|
+
exports.useArrayFilter = useArrayFilter;
|
|
3305
|
+
exports.useArrayFind = useArrayFind;
|
|
3306
|
+
exports.useArrayFindIndex = useArrayFindIndex;
|
|
3307
|
+
exports.useArrayFindLast = useArrayFindLast;
|
|
3308
|
+
exports.useArrayIncludes = useArrayIncludes;
|
|
3309
|
+
exports.useArrayJoin = useArrayJoin;
|
|
3310
|
+
exports.useArrayMap = useArrayMap;
|
|
3311
|
+
exports.useArrayReduce = useArrayReduce;
|
|
3312
|
+
exports.useArraySome = useArraySome;
|
|
3313
|
+
exports.useArrayUnique = useArrayUnique;
|
|
3314
|
+
exports.useAsyncQueue = useAsyncQueue;
|
|
3315
|
+
exports.useAsyncState = useAsyncState;
|
|
3316
|
+
exports.useBase64 = useBase64;
|
|
3317
|
+
exports.useBroadcastChannel = useBroadcastChannel;
|
|
3318
|
+
exports.useCached = useCached;
|
|
3319
|
+
exports.useCloned = useCloned;
|
|
3320
|
+
exports.useCounter = useCounter;
|
|
3321
|
+
exports.useCycleList = useCycleList;
|
|
3322
|
+
exports.useDateFormat = useDateFormat;
|
|
3323
|
+
exports.useDebounce = refDebounced;
|
|
3324
|
+
exports.useDebounceFn = useDebounceFn;
|
|
3325
|
+
exports.useDebouncedRefHistory = useDebouncedRefHistory;
|
|
3326
|
+
exports.useEventBus = useEventBus;
|
|
3327
|
+
exports.useFetch = useFetch;
|
|
3328
|
+
exports.useIdle = useIdle;
|
|
3329
|
+
exports.useInterval = useInterval;
|
|
3330
|
+
exports.useIntervalFn = useIntervalFn;
|
|
3331
|
+
exports.useLastChanged = useLastChanged;
|
|
3332
|
+
exports.useManualRefHistory = useManualRefHistory;
|
|
3333
|
+
exports.useNow = useNow;
|
|
3334
|
+
exports.useObjectUrl = useObjectUrl;
|
|
3335
|
+
exports.useOffsetPagination = useOffsetPagination;
|
|
3336
|
+
exports.usePrevious = usePrevious;
|
|
3337
|
+
exports.useRefHistory = useRefHistory;
|
|
3338
|
+
exports.useSorted = useSorted;
|
|
3339
|
+
exports.useStepper = useStepper;
|
|
3340
|
+
exports.useThrottle = refThrottled;
|
|
3341
|
+
exports.useThrottleFn = useThrottleFn;
|
|
3342
|
+
exports.useThrottledRefHistory = useThrottledRefHistory;
|
|
3343
|
+
exports.useTimeAgo = useTimeAgo;
|
|
3344
|
+
exports.useTimeout = useTimeout;
|
|
3345
|
+
exports.useTimeoutFn = useTimeoutFn;
|
|
3346
|
+
exports.useTimeoutPoll = useTimeoutPoll;
|
|
3347
|
+
exports.useTimestamp = useTimestamp;
|
|
3348
|
+
exports.useToNumber = useToNumber;
|
|
3349
|
+
exports.useToString = useToString;
|
|
3350
|
+
exports.useToggle = useToggle;
|
|
3351
|
+
exports.useUrlSearchParams = useUrlSearchParams;
|
|
3352
|
+
exports.useWebSocket = useWebSocket;
|
|
3353
|
+
exports.useWebWorkerFn = useWebWorkerFn;
|
|
3354
|
+
exports.watchArray = watchArray;
|
|
3355
|
+
exports.watchAtMost = watchAtMost;
|
|
3356
|
+
exports.watchDebounced = watchDebounced;
|
|
3357
|
+
exports.watchDeep = watchDeep;
|
|
3358
|
+
exports.watchIgnorable = watchIgnorable;
|
|
3359
|
+
exports.watchImmediate = watchImmediate;
|
|
3360
|
+
exports.watchOnce = watchOnce;
|
|
3361
|
+
exports.watchPausable = watchPausable;
|
|
3362
|
+
exports.watchThrottled = watchThrottled;
|
|
3363
|
+
exports.watchTriggerable = watchTriggerable;
|
|
3364
|
+
exports.watchWithFilter = watchWithFilter;
|
|
3365
|
+
exports.whenever = whenever;
|