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