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