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