@vueuse/shared 7.6.2 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +790 -685
- package/index.d.ts +241 -182
- package/index.iife.js +790 -685
- package/index.iife.min.js +1 -1
- package/index.mjs +759 -673
- package/package.json +1 -1
package/index.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,319 +495,80 @@ function useDebounce(value, ms = 200, options = {}) {
|
|
|
390
495
|
return debounced;
|
|
391
496
|
}
|
|
392
497
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
var
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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];
|
|
498
|
+
function refDefault(source, defaultValue) {
|
|
499
|
+
return vueDemi.computed({
|
|
500
|
+
get() {
|
|
501
|
+
var _a;
|
|
502
|
+
return (_a = source.value) != null ? _a : defaultValue;
|
|
503
|
+
},
|
|
504
|
+
set(value) {
|
|
505
|
+
source.value = value;
|
|
405
506
|
}
|
|
406
|
-
|
|
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];
|
|
507
|
+
});
|
|
493
508
|
}
|
|
494
509
|
|
|
495
|
-
|
|
496
|
-
|
|
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 };
|
|
510
|
+
function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
|
|
511
|
+
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
577
512
|
}
|
|
578
513
|
|
|
579
|
-
function
|
|
580
|
-
|
|
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;
|
|
581
523
|
}
|
|
582
524
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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
|
-
};
|
|
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);
|
|
612
538
|
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
539
|
+
};
|
|
540
|
+
});
|
|
541
|
+
function get(tracking = true) {
|
|
542
|
+
if (tracking)
|
|
543
|
+
track();
|
|
544
|
+
return source;
|
|
617
545
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
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));
|
|
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();
|
|
681
557
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function refDefault(source, defaultValue) {
|
|
696
|
-
return vueDemi.computed({
|
|
697
|
-
get() {
|
|
698
|
-
var _a;
|
|
699
|
-
return (_a = source.value) != null ? _a : defaultValue;
|
|
700
|
-
},
|
|
701
|
-
set(value) {
|
|
702
|
-
source.value = value;
|
|
703
|
-
}
|
|
704
|
-
});
|
|
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 });
|
|
705
570
|
}
|
|
571
|
+
const controlledRef = refWithControl;
|
|
706
572
|
|
|
707
573
|
function set(...args) {
|
|
708
574
|
if (args.length === 2) {
|
|
@@ -719,126 +585,56 @@ function set(...args) {
|
|
|
719
585
|
}
|
|
720
586
|
}
|
|
721
587
|
|
|
722
|
-
function syncRef(
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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;
|
|
727
614
|
if (!Array.isArray(targets))
|
|
728
615
|
targets = [targets];
|
|
729
616
|
return vueDemi.watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
|
|
730
617
|
}
|
|
731
618
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const updater = useThrottleFn(() => {
|
|
741
|
-
throttled.value = value.value;
|
|
742
|
-
}, delay, trailing, leading);
|
|
743
|
-
vueDemi.watch(value, () => updater());
|
|
744
|
-
return throttled;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
var __defProp$3 = Object.defineProperty;
|
|
748
|
-
var __defProps$1 = Object.defineProperties;
|
|
749
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
750
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
751
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
752
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
753
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
754
|
-
var __spreadValues$3 = (a, b) => {
|
|
755
|
-
for (var prop in b || (b = {}))
|
|
756
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
757
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
758
|
-
if (__getOwnPropSymbols$4)
|
|
759
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
760
|
-
if (__propIsEnum$4.call(b, prop))
|
|
761
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
762
|
-
}
|
|
763
|
-
return a;
|
|
764
|
-
};
|
|
765
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
766
|
-
var __objRest$1 = (source, exclude) => {
|
|
767
|
-
var target = {};
|
|
768
|
-
for (var prop in source)
|
|
769
|
-
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
770
|
-
target[prop] = source[prop];
|
|
771
|
-
if (source != null && __getOwnPropSymbols$4)
|
|
772
|
-
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
773
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
774
|
-
target[prop] = source[prop];
|
|
775
|
-
}
|
|
776
|
-
return target;
|
|
777
|
-
};
|
|
778
|
-
function throttledWatch(source, cb, options = {}) {
|
|
779
|
-
const _a = options, {
|
|
780
|
-
throttle = 0,
|
|
781
|
-
trailing = true,
|
|
782
|
-
leading = true
|
|
783
|
-
} = _a, watchOptions = __objRest$1(_a, [
|
|
784
|
-
"throttle",
|
|
785
|
-
"trailing",
|
|
786
|
-
"leading"
|
|
787
|
-
]);
|
|
788
|
-
return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$3({}, watchOptions), {
|
|
789
|
-
eventFilter: throttleFilter(throttle, trailing, leading)
|
|
790
|
-
}));
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
function toReactive(objectRef) {
|
|
794
|
-
if (!vueDemi.isRef(objectRef))
|
|
795
|
-
return vueDemi.reactive(objectRef);
|
|
796
|
-
const proxy = new Proxy({}, {
|
|
797
|
-
get(_, p, receiver) {
|
|
798
|
-
return Reflect.get(objectRef.value, p, receiver);
|
|
799
|
-
},
|
|
800
|
-
set(_, p, value) {
|
|
801
|
-
objectRef.value[p] = value;
|
|
802
|
-
return true;
|
|
803
|
-
},
|
|
804
|
-
deleteProperty(_, p) {
|
|
805
|
-
return Reflect.deleteProperty(objectRef.value, p);
|
|
806
|
-
},
|
|
807
|
-
has(_, p) {
|
|
808
|
-
return Reflect.has(objectRef.value, p);
|
|
809
|
-
},
|
|
810
|
-
ownKeys() {
|
|
811
|
-
return Object.keys(objectRef.value);
|
|
812
|
-
},
|
|
813
|
-
getOwnPropertyDescriptor() {
|
|
814
|
-
return {
|
|
815
|
-
enumerable: true,
|
|
816
|
-
configurable: true
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
return vueDemi.reactive(proxy);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
var __defProp$2 = Object.defineProperty;
|
|
824
|
-
var __defProps = Object.defineProperties;
|
|
825
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
826
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
827
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
828
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
829
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
830
|
-
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) => {
|
|
831
627
|
for (var prop in b || (b = {}))
|
|
832
|
-
if (__hasOwnProp$
|
|
833
|
-
__defNormalProp$
|
|
834
|
-
if (__getOwnPropSymbols$
|
|
835
|
-
for (var prop of __getOwnPropSymbols$
|
|
836
|
-
if (__propIsEnum$
|
|
837
|
-
__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]);
|
|
838
634
|
}
|
|
839
635
|
return a;
|
|
840
636
|
};
|
|
841
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
637
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
842
638
|
function toRefs(objectRef) {
|
|
843
639
|
if (!vueDemi.isRef(objectRef))
|
|
844
640
|
return vueDemi.toRefs(objectRef);
|
|
@@ -854,7 +650,7 @@ function toRefs(objectRef) {
|
|
|
854
650
|
copy[key] = v;
|
|
855
651
|
objectRef.value = copy;
|
|
856
652
|
} else {
|
|
857
|
-
objectRef.value = __spreadProps(__spreadValues$
|
|
653
|
+
objectRef.value = __spreadProps$4(__spreadValues$6({}, objectRef.value), { [key]: v });
|
|
858
654
|
}
|
|
859
655
|
}
|
|
860
656
|
}));
|
|
@@ -984,6 +780,56 @@ function useCounter(initialValue = 0, options = {}) {
|
|
|
984
780
|
return { count, inc, dec, get, set, reset };
|
|
985
781
|
}
|
|
986
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
|
+
|
|
987
833
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
988
834
|
const {
|
|
989
835
|
immediate = true,
|
|
@@ -1027,19 +873,19 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1027
873
|
};
|
|
1028
874
|
}
|
|
1029
875
|
|
|
1030
|
-
var __defProp$
|
|
1031
|
-
var __getOwnPropSymbols$
|
|
1032
|
-
var __hasOwnProp$
|
|
1033
|
-
var __propIsEnum$
|
|
1034
|
-
var __defNormalProp$
|
|
1035
|
-
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) => {
|
|
1036
882
|
for (var prop in b || (b = {}))
|
|
1037
|
-
if (__hasOwnProp$
|
|
1038
|
-
__defNormalProp$
|
|
1039
|
-
if (__getOwnPropSymbols$
|
|
1040
|
-
for (var prop of __getOwnPropSymbols$
|
|
1041
|
-
if (__propIsEnum$
|
|
1042
|
-
__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]);
|
|
1043
889
|
}
|
|
1044
890
|
return a;
|
|
1045
891
|
};
|
|
@@ -1051,7 +897,7 @@ function useInterval(interval = 1e3, options = {}) {
|
|
|
1051
897
|
const counter = vueDemi.ref(0);
|
|
1052
898
|
const controls = useIntervalFn(() => counter.value += 1, interval, { immediate });
|
|
1053
899
|
if (exposeControls) {
|
|
1054
|
-
return __spreadValues$
|
|
900
|
+
return __spreadValues$5({
|
|
1055
901
|
counter
|
|
1056
902
|
}, controls);
|
|
1057
903
|
} else {
|
|
@@ -1100,23 +946,23 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1100
946
|
return {
|
|
1101
947
|
isPending,
|
|
1102
948
|
start,
|
|
1103
|
-
stop
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
var __defProp = Object.defineProperty;
|
|
1108
|
-
var __getOwnPropSymbols$
|
|
1109
|
-
var __hasOwnProp$
|
|
1110
|
-
var __propIsEnum$
|
|
1111
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1112
|
-
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) => {
|
|
1113
959
|
for (var prop in b || (b = {}))
|
|
1114
|
-
if (__hasOwnProp$
|
|
1115
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1116
|
-
if (__getOwnPropSymbols$
|
|
1117
|
-
for (var prop of __getOwnPropSymbols$
|
|
1118
|
-
if (__propIsEnum$
|
|
1119
|
-
__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]);
|
|
1120
966
|
}
|
|
1121
967
|
return a;
|
|
1122
968
|
};
|
|
@@ -1127,7 +973,7 @@ function useTimeout(interval = 1e3, options = {}) {
|
|
|
1127
973
|
const controls = useTimeoutFn(noop, interval, options);
|
|
1128
974
|
const ready = vueDemi.computed(() => !controls.isPending.value);
|
|
1129
975
|
if (exposeControls) {
|
|
1130
|
-
return __spreadValues({
|
|
976
|
+
return __spreadValues$4({
|
|
1131
977
|
ready
|
|
1132
978
|
}, controls);
|
|
1133
979
|
} else {
|
|
@@ -1151,17 +997,41 @@ function useToggle(initialValue = false) {
|
|
|
1151
997
|
}
|
|
1152
998
|
}
|
|
1153
999
|
|
|
1154
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1155
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1156
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1157
|
-
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) => {
|
|
1158
1004
|
var target = {};
|
|
1159
1005
|
for (var prop in source)
|
|
1160
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1006
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1161
1007
|
target[prop] = source[prop];
|
|
1162
|
-
if (source != null && __getOwnPropSymbols)
|
|
1163
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
1164
|
-
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))
|
|
1165
1035
|
target[prop] = source[prop];
|
|
1166
1036
|
}
|
|
1167
1037
|
return target;
|
|
@@ -1169,7 +1039,7 @@ var __objRest = (source, exclude) => {
|
|
|
1169
1039
|
function watchAtMost(source, cb, options) {
|
|
1170
1040
|
const _a = options, {
|
|
1171
1041
|
count
|
|
1172
|
-
} = _a, watchOptions = __objRest(_a, [
|
|
1042
|
+
} = _a, watchOptions = __objRest$4(_a, [
|
|
1173
1043
|
"count"
|
|
1174
1044
|
]);
|
|
1175
1045
|
const current = vueDemi.ref(0);
|
|
@@ -1182,6 +1052,132 @@ function watchAtMost(source, cb, options) {
|
|
|
1182
1052
|
return { count: current, stop };
|
|
1183
1053
|
}
|
|
1184
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
|
+
|
|
1185
1181
|
function watchOnce(source, cb, options) {
|
|
1186
1182
|
const stop = vueDemi.watch(source, (...args) => {
|
|
1187
1183
|
vueDemi.nextTick(() => stop());
|
|
@@ -1189,6 +1185,96 @@ function watchOnce(source, cb, options) {
|
|
|
1189
1185
|
}, options);
|
|
1190
1186
|
}
|
|
1191
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
|
+
|
|
1192
1278
|
function whenever(source, cb, options) {
|
|
1193
1279
|
return vueDemi.watch(source, (v, ov, onInvalidate) => {
|
|
1194
1280
|
if (v)
|
|
@@ -1196,13 +1282,15 @@ function whenever(source, cb, options) {
|
|
|
1196
1282
|
}, options);
|
|
1197
1283
|
}
|
|
1198
1284
|
|
|
1199
|
-
exports.and =
|
|
1285
|
+
exports.and = logicAnd;
|
|
1200
1286
|
exports.assert = assert;
|
|
1201
|
-
exports.
|
|
1287
|
+
exports.autoResetRef = refAutoReset;
|
|
1202
1288
|
exports.bypassFilter = bypassFilter;
|
|
1203
1289
|
exports.clamp = clamp;
|
|
1290
|
+
exports.computedEager = computedEager;
|
|
1291
|
+
exports.computedWithControl = computedWithControl;
|
|
1204
1292
|
exports.containsProp = containsProp;
|
|
1205
|
-
exports.controlledComputed =
|
|
1293
|
+
exports.controlledComputed = computedWithControl;
|
|
1206
1294
|
exports.controlledRef = controlledRef;
|
|
1207
1295
|
exports.createEventHook = createEventHook;
|
|
1208
1296
|
exports.createFilterWrapper = createFilterWrapper;
|
|
@@ -1211,13 +1299,14 @@ exports.createReactiveFn = reactify;
|
|
|
1211
1299
|
exports.createSharedComposable = createSharedComposable;
|
|
1212
1300
|
exports.createSingletonPromise = createSingletonPromise;
|
|
1213
1301
|
exports.debounceFilter = debounceFilter;
|
|
1214
|
-
exports.debouncedRef =
|
|
1215
|
-
exports.debouncedWatch =
|
|
1216
|
-
exports.eagerComputed =
|
|
1302
|
+
exports.debouncedRef = refDebounced;
|
|
1303
|
+
exports.debouncedWatch = watchDebounced;
|
|
1304
|
+
exports.eagerComputed = computedEager;
|
|
1217
1305
|
exports.extendRef = extendRef;
|
|
1306
|
+
exports.formatDate = formatDate;
|
|
1218
1307
|
exports.get = get;
|
|
1219
1308
|
exports.identity = identity;
|
|
1220
|
-
exports.ignorableWatch =
|
|
1309
|
+
exports.ignorableWatch = watchIgnorable;
|
|
1221
1310
|
exports.increaseWithUnit = increaseWithUnit;
|
|
1222
1311
|
exports.invoke = invoke;
|
|
1223
1312
|
exports.isBoolean = isBoolean;
|
|
@@ -1229,25 +1318,36 @@ exports.isNumber = isNumber;
|
|
|
1229
1318
|
exports.isObject = isObject;
|
|
1230
1319
|
exports.isString = isString;
|
|
1231
1320
|
exports.isWindow = isWindow;
|
|
1321
|
+
exports.logicAnd = logicAnd;
|
|
1322
|
+
exports.logicNot = logicNot;
|
|
1323
|
+
exports.logicOr = logicOr;
|
|
1232
1324
|
exports.makeDestructurable = makeDestructurable;
|
|
1233
1325
|
exports.noop = noop;
|
|
1234
|
-
exports.
|
|
1326
|
+
exports.normalizeDate = normalizeDate;
|
|
1327
|
+
exports.not = logicNot;
|
|
1235
1328
|
exports.now = now;
|
|
1236
1329
|
exports.objectPick = objectPick;
|
|
1237
|
-
exports.or =
|
|
1330
|
+
exports.or = logicOr;
|
|
1238
1331
|
exports.pausableFilter = pausableFilter;
|
|
1239
|
-
exports.pausableWatch =
|
|
1332
|
+
exports.pausableWatch = watchPausable;
|
|
1240
1333
|
exports.promiseTimeout = promiseTimeout;
|
|
1241
1334
|
exports.rand = rand;
|
|
1242
1335
|
exports.reactify = reactify;
|
|
1243
1336
|
exports.reactifyObject = reactifyObject;
|
|
1337
|
+
exports.reactiveComputed = reactiveComputed;
|
|
1338
|
+
exports.reactiveOmit = reactiveOmit;
|
|
1244
1339
|
exports.reactivePick = reactivePick;
|
|
1340
|
+
exports.refAutoReset = refAutoReset;
|
|
1341
|
+
exports.refDebounced = refDebounced;
|
|
1245
1342
|
exports.refDefault = refDefault;
|
|
1343
|
+
exports.refThrottled = refThrottled;
|
|
1344
|
+
exports.refWithControl = refWithControl;
|
|
1246
1345
|
exports.set = set;
|
|
1247
1346
|
exports.syncRef = syncRef;
|
|
1347
|
+
exports.syncRefs = syncRefs;
|
|
1248
1348
|
exports.throttleFilter = throttleFilter;
|
|
1249
|
-
exports.throttledRef =
|
|
1250
|
-
exports.throttledWatch =
|
|
1349
|
+
exports.throttledRef = refThrottled;
|
|
1350
|
+
exports.throttledWatch = watchThrottled;
|
|
1251
1351
|
exports.timestamp = timestamp;
|
|
1252
1352
|
exports.toReactive = toReactive;
|
|
1253
1353
|
exports.toRefs = toRefs;
|
|
@@ -1257,17 +1357,22 @@ exports.tryOnScopeDispose = tryOnScopeDispose;
|
|
|
1257
1357
|
exports.tryOnUnmounted = tryOnUnmounted;
|
|
1258
1358
|
exports.until = until;
|
|
1259
1359
|
exports.useCounter = useCounter;
|
|
1260
|
-
exports.
|
|
1360
|
+
exports.useDateFormat = useDateFormat;
|
|
1361
|
+
exports.useDebounce = refDebounced;
|
|
1261
1362
|
exports.useDebounceFn = useDebounceFn;
|
|
1262
1363
|
exports.useInterval = useInterval;
|
|
1263
1364
|
exports.useIntervalFn = useIntervalFn;
|
|
1264
1365
|
exports.useLastChanged = useLastChanged;
|
|
1265
|
-
exports.useThrottle =
|
|
1366
|
+
exports.useThrottle = refThrottled;
|
|
1266
1367
|
exports.useThrottleFn = useThrottleFn;
|
|
1267
1368
|
exports.useTimeout = useTimeout;
|
|
1268
1369
|
exports.useTimeoutFn = useTimeoutFn;
|
|
1269
1370
|
exports.useToggle = useToggle;
|
|
1270
1371
|
exports.watchAtMost = watchAtMost;
|
|
1372
|
+
exports.watchDebounced = watchDebounced;
|
|
1373
|
+
exports.watchIgnorable = watchIgnorable;
|
|
1271
1374
|
exports.watchOnce = watchOnce;
|
|
1375
|
+
exports.watchPausable = watchPausable;
|
|
1376
|
+
exports.watchThrottled = watchThrottled;
|
|
1272
1377
|
exports.watchWithFilter = watchWithFilter;
|
|
1273
1378
|
exports.whenever = whenever;
|