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