@reactive-vscode/reactivity 0.2.6-beta.1 → 0.2.7-beta.1
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/dist/index.cjs +2224 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +158 -218
- package/package.json +9 -8
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
/**
|
|
4
|
+
* @vue/shared v3.5.12
|
|
5
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
6
|
+
* @license MIT
|
|
7
|
+
**/
|
|
8
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
9
|
+
// @__NO_SIDE_EFFECTS__
|
|
10
|
+
function makeMap(str) {
|
|
11
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
12
|
+
for (const key of str.split(",")) map[key] = 1;
|
|
13
|
+
return (val) => val in map;
|
|
14
|
+
}
|
|
15
|
+
const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
16
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
17
|
+
const NOOP = () => {
|
|
18
|
+
};
|
|
19
|
+
const extend = Object.assign;
|
|
20
|
+
const remove = (arr, el) => {
|
|
21
|
+
const i = arr.indexOf(el);
|
|
22
|
+
if (i > -1) {
|
|
23
|
+
arr.splice(i, 1);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
27
|
+
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
28
|
+
const isArray = Array.isArray;
|
|
29
|
+
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
30
|
+
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
31
|
+
const isFunction = (val) => typeof val === "function";
|
|
32
|
+
const isString = (val) => typeof val === "string";
|
|
33
|
+
const isSymbol = (val) => typeof val === "symbol";
|
|
34
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
35
|
+
const isPromise = (val) => {
|
|
36
|
+
return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
37
|
+
};
|
|
38
|
+
const objectToString = Object.prototype.toString;
|
|
39
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
40
|
+
const toRawType = (value) => {
|
|
41
|
+
return toTypeString(value).slice(8, -1);
|
|
42
|
+
};
|
|
43
|
+
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
44
|
+
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
45
|
+
const cacheStringFunction = (fn) => {
|
|
46
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
47
|
+
return (str) => {
|
|
48
|
+
const hit = cache[str];
|
|
49
|
+
return hit || (cache[str] = fn(str));
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const capitalize = cacheStringFunction((str) => {
|
|
53
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
54
|
+
});
|
|
55
|
+
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
56
|
+
const def = (obj, key, value, writable = false) => {
|
|
57
|
+
Object.defineProperty(obj, key, {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: false,
|
|
60
|
+
writable,
|
|
61
|
+
value
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* @vue/reactivity v3.5.12
|
|
66
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
67
|
+
* @license MIT
|
|
68
|
+
**/
|
|
69
|
+
function warn$1(msg, ...args) {
|
|
70
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
71
|
+
}
|
|
72
|
+
let activeEffectScope;
|
|
73
|
+
class EffectScope {
|
|
74
|
+
constructor(detached = false) {
|
|
75
|
+
this.detached = detached;
|
|
76
|
+
this._active = true;
|
|
77
|
+
this.effects = [];
|
|
78
|
+
this.cleanups = [];
|
|
79
|
+
this._isPaused = false;
|
|
80
|
+
this.parent = activeEffectScope;
|
|
81
|
+
if (!detached && activeEffectScope) {
|
|
82
|
+
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
83
|
+
this
|
|
84
|
+
) - 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
get active() {
|
|
88
|
+
return this._active;
|
|
89
|
+
}
|
|
90
|
+
pause() {
|
|
91
|
+
if (this._active) {
|
|
92
|
+
this._isPaused = true;
|
|
93
|
+
let i, l;
|
|
94
|
+
if (this.scopes) {
|
|
95
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
96
|
+
this.scopes[i].pause();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
100
|
+
this.effects[i].pause();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resumes the effect scope, including all child scopes and effects.
|
|
106
|
+
*/
|
|
107
|
+
resume() {
|
|
108
|
+
if (this._active) {
|
|
109
|
+
if (this._isPaused) {
|
|
110
|
+
this._isPaused = false;
|
|
111
|
+
let i, l;
|
|
112
|
+
if (this.scopes) {
|
|
113
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
114
|
+
this.scopes[i].resume();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
118
|
+
this.effects[i].resume();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
run(fn) {
|
|
124
|
+
if (this._active) {
|
|
125
|
+
const currentEffectScope = activeEffectScope;
|
|
126
|
+
try {
|
|
127
|
+
activeEffectScope = this;
|
|
128
|
+
return fn();
|
|
129
|
+
} finally {
|
|
130
|
+
activeEffectScope = currentEffectScope;
|
|
131
|
+
}
|
|
132
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
133
|
+
warn$1(`cannot run an inactive effect scope.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* This should only be called on non-detached scopes
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
on() {
|
|
141
|
+
activeEffectScope = this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* This should only be called on non-detached scopes
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
off() {
|
|
148
|
+
activeEffectScope = this.parent;
|
|
149
|
+
}
|
|
150
|
+
stop(fromParent) {
|
|
151
|
+
if (this._active) {
|
|
152
|
+
let i, l;
|
|
153
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
154
|
+
this.effects[i].stop();
|
|
155
|
+
}
|
|
156
|
+
for (i = 0, l = this.cleanups.length; i < l; i++) {
|
|
157
|
+
this.cleanups[i]();
|
|
158
|
+
}
|
|
159
|
+
if (this.scopes) {
|
|
160
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
161
|
+
this.scopes[i].stop(true);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (!this.detached && this.parent && !fromParent) {
|
|
165
|
+
const last = this.parent.scopes.pop();
|
|
166
|
+
if (last && last !== this) {
|
|
167
|
+
this.parent.scopes[this.index] = last;
|
|
168
|
+
last.index = this.index;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
this.parent = void 0;
|
|
172
|
+
this._active = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function effectScope(detached) {
|
|
177
|
+
return new EffectScope(detached);
|
|
178
|
+
}
|
|
179
|
+
function getCurrentScope() {
|
|
180
|
+
return activeEffectScope;
|
|
181
|
+
}
|
|
182
|
+
function onScopeDispose(fn, failSilently = false) {
|
|
183
|
+
if (activeEffectScope) {
|
|
184
|
+
activeEffectScope.cleanups.push(fn);
|
|
185
|
+
} else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
|
|
186
|
+
warn$1(
|
|
187
|
+
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
let activeSub;
|
|
192
|
+
const EffectFlags = {
|
|
193
|
+
"ACTIVE": 1,
|
|
194
|
+
"1": "ACTIVE",
|
|
195
|
+
"RUNNING": 2,
|
|
196
|
+
"2": "RUNNING",
|
|
197
|
+
"TRACKING": 4,
|
|
198
|
+
"4": "TRACKING",
|
|
199
|
+
"NOTIFIED": 8,
|
|
200
|
+
"8": "NOTIFIED",
|
|
201
|
+
"DIRTY": 16,
|
|
202
|
+
"16": "DIRTY",
|
|
203
|
+
"ALLOW_RECURSE": 32,
|
|
204
|
+
"32": "ALLOW_RECURSE",
|
|
205
|
+
"PAUSED": 64,
|
|
206
|
+
"64": "PAUSED"
|
|
207
|
+
};
|
|
208
|
+
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
209
|
+
class ReactiveEffect {
|
|
210
|
+
constructor(fn) {
|
|
211
|
+
this.fn = fn;
|
|
212
|
+
this.deps = void 0;
|
|
213
|
+
this.depsTail = void 0;
|
|
214
|
+
this.flags = 1 | 4;
|
|
215
|
+
this.next = void 0;
|
|
216
|
+
this.cleanup = void 0;
|
|
217
|
+
this.scheduler = void 0;
|
|
218
|
+
if (activeEffectScope && activeEffectScope.active) {
|
|
219
|
+
activeEffectScope.effects.push(this);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
pause() {
|
|
223
|
+
this.flags |= 64;
|
|
224
|
+
}
|
|
225
|
+
resume() {
|
|
226
|
+
if (this.flags & 64) {
|
|
227
|
+
this.flags &= ~64;
|
|
228
|
+
if (pausedQueueEffects.has(this)) {
|
|
229
|
+
pausedQueueEffects.delete(this);
|
|
230
|
+
this.trigger();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
notify() {
|
|
238
|
+
if (this.flags & 2 && !(this.flags & 32)) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!(this.flags & 8)) {
|
|
242
|
+
batch(this);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
run() {
|
|
246
|
+
if (!(this.flags & 1)) {
|
|
247
|
+
return this.fn();
|
|
248
|
+
}
|
|
249
|
+
this.flags |= 2;
|
|
250
|
+
cleanupEffect(this);
|
|
251
|
+
prepareDeps(this);
|
|
252
|
+
const prevEffect = activeSub;
|
|
253
|
+
const prevShouldTrack = shouldTrack;
|
|
254
|
+
activeSub = this;
|
|
255
|
+
shouldTrack = true;
|
|
256
|
+
try {
|
|
257
|
+
return this.fn();
|
|
258
|
+
} finally {
|
|
259
|
+
if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) {
|
|
260
|
+
warn$1(
|
|
261
|
+
"Active effect was not restored correctly - this is likely a Vue internal bug."
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
cleanupDeps(this);
|
|
265
|
+
activeSub = prevEffect;
|
|
266
|
+
shouldTrack = prevShouldTrack;
|
|
267
|
+
this.flags &= ~2;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
stop() {
|
|
271
|
+
if (this.flags & 1) {
|
|
272
|
+
for (let link = this.deps; link; link = link.nextDep) {
|
|
273
|
+
removeSub(link);
|
|
274
|
+
}
|
|
275
|
+
this.deps = this.depsTail = void 0;
|
|
276
|
+
cleanupEffect(this);
|
|
277
|
+
this.onStop && this.onStop();
|
|
278
|
+
this.flags &= ~1;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
trigger() {
|
|
282
|
+
if (this.flags & 64) {
|
|
283
|
+
pausedQueueEffects.add(this);
|
|
284
|
+
} else if (this.scheduler) {
|
|
285
|
+
this.scheduler();
|
|
286
|
+
} else {
|
|
287
|
+
this.runIfDirty();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
runIfDirty() {
|
|
294
|
+
if (isDirty(this)) {
|
|
295
|
+
this.run();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
get dirty() {
|
|
299
|
+
return isDirty(this);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
let batchDepth = 0;
|
|
303
|
+
let batchedSub;
|
|
304
|
+
let batchedComputed;
|
|
305
|
+
function batch(sub, isComputed = false) {
|
|
306
|
+
sub.flags |= 8;
|
|
307
|
+
if (isComputed) {
|
|
308
|
+
sub.next = batchedComputed;
|
|
309
|
+
batchedComputed = sub;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
sub.next = batchedSub;
|
|
313
|
+
batchedSub = sub;
|
|
314
|
+
}
|
|
315
|
+
function startBatch() {
|
|
316
|
+
batchDepth++;
|
|
317
|
+
}
|
|
318
|
+
function endBatch() {
|
|
319
|
+
if (--batchDepth > 0) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (batchedComputed) {
|
|
323
|
+
let e = batchedComputed;
|
|
324
|
+
batchedComputed = void 0;
|
|
325
|
+
while (e) {
|
|
326
|
+
const next = e.next;
|
|
327
|
+
e.next = void 0;
|
|
328
|
+
e.flags &= ~8;
|
|
329
|
+
e = next;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
let error;
|
|
333
|
+
while (batchedSub) {
|
|
334
|
+
let e = batchedSub;
|
|
335
|
+
batchedSub = void 0;
|
|
336
|
+
while (e) {
|
|
337
|
+
const next = e.next;
|
|
338
|
+
e.next = void 0;
|
|
339
|
+
e.flags &= ~8;
|
|
340
|
+
if (e.flags & 1) {
|
|
341
|
+
try {
|
|
342
|
+
;
|
|
343
|
+
e.trigger();
|
|
344
|
+
} catch (err) {
|
|
345
|
+
if (!error) error = err;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
e = next;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (error) throw error;
|
|
352
|
+
}
|
|
353
|
+
function prepareDeps(sub) {
|
|
354
|
+
for (let link = sub.deps; link; link = link.nextDep) {
|
|
355
|
+
link.version = -1;
|
|
356
|
+
link.prevActiveLink = link.dep.activeLink;
|
|
357
|
+
link.dep.activeLink = link;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function cleanupDeps(sub) {
|
|
361
|
+
let head;
|
|
362
|
+
let tail = sub.depsTail;
|
|
363
|
+
let link = tail;
|
|
364
|
+
while (link) {
|
|
365
|
+
const prev = link.prevDep;
|
|
366
|
+
if (link.version === -1) {
|
|
367
|
+
if (link === tail) tail = prev;
|
|
368
|
+
removeSub(link);
|
|
369
|
+
removeDep(link);
|
|
370
|
+
} else {
|
|
371
|
+
head = link;
|
|
372
|
+
}
|
|
373
|
+
link.dep.activeLink = link.prevActiveLink;
|
|
374
|
+
link.prevActiveLink = void 0;
|
|
375
|
+
link = prev;
|
|
376
|
+
}
|
|
377
|
+
sub.deps = head;
|
|
378
|
+
sub.depsTail = tail;
|
|
379
|
+
}
|
|
380
|
+
function isDirty(sub) {
|
|
381
|
+
for (let link = sub.deps; link; link = link.nextDep) {
|
|
382
|
+
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (sub._dirty) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
function refreshComputed(computed2) {
|
|
392
|
+
if (computed2.flags & 4 && !(computed2.flags & 16)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
computed2.flags &= ~16;
|
|
396
|
+
if (computed2.globalVersion === globalVersion) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
computed2.globalVersion = globalVersion;
|
|
400
|
+
const dep = computed2.dep;
|
|
401
|
+
computed2.flags |= 2;
|
|
402
|
+
if (dep.version > 0 && !computed2.isSSR && computed2.deps && !isDirty(computed2)) {
|
|
403
|
+
computed2.flags &= ~2;
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const prevSub = activeSub;
|
|
407
|
+
const prevShouldTrack = shouldTrack;
|
|
408
|
+
activeSub = computed2;
|
|
409
|
+
shouldTrack = true;
|
|
410
|
+
try {
|
|
411
|
+
prepareDeps(computed2);
|
|
412
|
+
const value = computed2.fn(computed2._value);
|
|
413
|
+
if (dep.version === 0 || hasChanged(value, computed2._value)) {
|
|
414
|
+
computed2._value = value;
|
|
415
|
+
dep.version++;
|
|
416
|
+
}
|
|
417
|
+
} catch (err) {
|
|
418
|
+
dep.version++;
|
|
419
|
+
throw err;
|
|
420
|
+
} finally {
|
|
421
|
+
activeSub = prevSub;
|
|
422
|
+
shouldTrack = prevShouldTrack;
|
|
423
|
+
cleanupDeps(computed2);
|
|
424
|
+
computed2.flags &= ~2;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function removeSub(link, soft = false) {
|
|
428
|
+
const { dep, prevSub, nextSub } = link;
|
|
429
|
+
if (prevSub) {
|
|
430
|
+
prevSub.nextSub = nextSub;
|
|
431
|
+
link.prevSub = void 0;
|
|
432
|
+
}
|
|
433
|
+
if (nextSub) {
|
|
434
|
+
nextSub.prevSub = prevSub;
|
|
435
|
+
link.nextSub = void 0;
|
|
436
|
+
}
|
|
437
|
+
if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) {
|
|
438
|
+
dep.subsHead = nextSub;
|
|
439
|
+
}
|
|
440
|
+
if (dep.subs === link) {
|
|
441
|
+
dep.subs = prevSub;
|
|
442
|
+
if (!prevSub && dep.computed) {
|
|
443
|
+
dep.computed.flags &= ~4;
|
|
444
|
+
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
445
|
+
removeSub(l, true);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (!soft && !--dep.sc && dep.map) {
|
|
450
|
+
dep.map.delete(dep.key);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function removeDep(link) {
|
|
454
|
+
const { prevDep, nextDep } = link;
|
|
455
|
+
if (prevDep) {
|
|
456
|
+
prevDep.nextDep = nextDep;
|
|
457
|
+
link.prevDep = void 0;
|
|
458
|
+
}
|
|
459
|
+
if (nextDep) {
|
|
460
|
+
nextDep.prevDep = prevDep;
|
|
461
|
+
link.nextDep = void 0;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function effect(fn, options) {
|
|
465
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
466
|
+
fn = fn.effect.fn;
|
|
467
|
+
}
|
|
468
|
+
const e = new ReactiveEffect(fn);
|
|
469
|
+
if (options) {
|
|
470
|
+
extend(e, options);
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
e.run();
|
|
474
|
+
} catch (err) {
|
|
475
|
+
e.stop();
|
|
476
|
+
throw err;
|
|
477
|
+
}
|
|
478
|
+
const runner = e.run.bind(e);
|
|
479
|
+
runner.effect = e;
|
|
480
|
+
return runner;
|
|
481
|
+
}
|
|
482
|
+
function stop(runner) {
|
|
483
|
+
runner.effect.stop();
|
|
484
|
+
}
|
|
485
|
+
let shouldTrack = true;
|
|
486
|
+
const trackStack = [];
|
|
487
|
+
function pauseTracking() {
|
|
488
|
+
trackStack.push(shouldTrack);
|
|
489
|
+
shouldTrack = false;
|
|
490
|
+
}
|
|
491
|
+
function enableTracking() {
|
|
492
|
+
trackStack.push(shouldTrack);
|
|
493
|
+
shouldTrack = true;
|
|
494
|
+
}
|
|
495
|
+
function resetTracking() {
|
|
496
|
+
const last = trackStack.pop();
|
|
497
|
+
shouldTrack = last === void 0 ? true : last;
|
|
498
|
+
}
|
|
499
|
+
function onEffectCleanup(fn, failSilently = false) {
|
|
500
|
+
if (activeSub instanceof ReactiveEffect) {
|
|
501
|
+
activeSub.cleanup = fn;
|
|
502
|
+
} else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
|
|
503
|
+
warn$1(
|
|
504
|
+
`onEffectCleanup() was called when there was no active effect to associate with.`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function cleanupEffect(e) {
|
|
509
|
+
const { cleanup } = e;
|
|
510
|
+
e.cleanup = void 0;
|
|
511
|
+
if (cleanup) {
|
|
512
|
+
const prevSub = activeSub;
|
|
513
|
+
activeSub = void 0;
|
|
514
|
+
try {
|
|
515
|
+
cleanup();
|
|
516
|
+
} finally {
|
|
517
|
+
activeSub = prevSub;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
let globalVersion = 0;
|
|
522
|
+
class Link {
|
|
523
|
+
constructor(sub, dep) {
|
|
524
|
+
this.sub = sub;
|
|
525
|
+
this.dep = dep;
|
|
526
|
+
this.version = dep.version;
|
|
527
|
+
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
class Dep {
|
|
531
|
+
constructor(computed2) {
|
|
532
|
+
this.computed = computed2;
|
|
533
|
+
this.version = 0;
|
|
534
|
+
this.activeLink = void 0;
|
|
535
|
+
this.subs = void 0;
|
|
536
|
+
this.map = void 0;
|
|
537
|
+
this.key = void 0;
|
|
538
|
+
this.sc = 0;
|
|
539
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
540
|
+
this.subsHead = void 0;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
track(debugInfo) {
|
|
544
|
+
if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
let link = this.activeLink;
|
|
548
|
+
if (link === void 0 || link.sub !== activeSub) {
|
|
549
|
+
link = this.activeLink = new Link(activeSub, this);
|
|
550
|
+
if (!activeSub.deps) {
|
|
551
|
+
activeSub.deps = activeSub.depsTail = link;
|
|
552
|
+
} else {
|
|
553
|
+
link.prevDep = activeSub.depsTail;
|
|
554
|
+
activeSub.depsTail.nextDep = link;
|
|
555
|
+
activeSub.depsTail = link;
|
|
556
|
+
}
|
|
557
|
+
addSub(link);
|
|
558
|
+
} else if (link.version === -1) {
|
|
559
|
+
link.version = this.version;
|
|
560
|
+
if (link.nextDep) {
|
|
561
|
+
const next = link.nextDep;
|
|
562
|
+
next.prevDep = link.prevDep;
|
|
563
|
+
if (link.prevDep) {
|
|
564
|
+
link.prevDep.nextDep = next;
|
|
565
|
+
}
|
|
566
|
+
link.prevDep = activeSub.depsTail;
|
|
567
|
+
link.nextDep = void 0;
|
|
568
|
+
activeSub.depsTail.nextDep = link;
|
|
569
|
+
activeSub.depsTail = link;
|
|
570
|
+
if (activeSub.deps === link) {
|
|
571
|
+
activeSub.deps = next;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) {
|
|
576
|
+
activeSub.onTrack(
|
|
577
|
+
extend(
|
|
578
|
+
{
|
|
579
|
+
effect: activeSub
|
|
580
|
+
},
|
|
581
|
+
debugInfo
|
|
582
|
+
)
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
return link;
|
|
586
|
+
}
|
|
587
|
+
trigger(debugInfo) {
|
|
588
|
+
this.version++;
|
|
589
|
+
globalVersion++;
|
|
590
|
+
this.notify(debugInfo);
|
|
591
|
+
}
|
|
592
|
+
notify(debugInfo) {
|
|
593
|
+
startBatch();
|
|
594
|
+
try {
|
|
595
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
596
|
+
for (let head = this.subsHead; head; head = head.nextSub) {
|
|
597
|
+
if (head.sub.onTrigger && !(head.sub.flags & 8)) {
|
|
598
|
+
head.sub.onTrigger(
|
|
599
|
+
extend(
|
|
600
|
+
{
|
|
601
|
+
effect: head.sub
|
|
602
|
+
},
|
|
603
|
+
debugInfo
|
|
604
|
+
)
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
for (let link = this.subs; link; link = link.prevSub) {
|
|
610
|
+
if (link.sub.notify()) {
|
|
611
|
+
;
|
|
612
|
+
link.sub.dep.notify();
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
} finally {
|
|
616
|
+
endBatch();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function addSub(link) {
|
|
621
|
+
link.dep.sc++;
|
|
622
|
+
if (link.sub.flags & 4) {
|
|
623
|
+
const computed2 = link.dep.computed;
|
|
624
|
+
if (computed2 && !link.dep.subs) {
|
|
625
|
+
computed2.flags |= 4 | 16;
|
|
626
|
+
for (let l = computed2.deps; l; l = l.nextDep) {
|
|
627
|
+
addSub(l);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
const currentTail = link.dep.subs;
|
|
631
|
+
if (currentTail !== link) {
|
|
632
|
+
link.prevSub = currentTail;
|
|
633
|
+
if (currentTail) currentTail.nextSub = link;
|
|
634
|
+
}
|
|
635
|
+
if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
|
|
636
|
+
link.dep.subsHead = link;
|
|
637
|
+
}
|
|
638
|
+
link.dep.subs = link;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
642
|
+
const ITERATE_KEY = Symbol(
|
|
643
|
+
!!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""
|
|
644
|
+
);
|
|
645
|
+
const MAP_KEY_ITERATE_KEY = Symbol(
|
|
646
|
+
!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""
|
|
647
|
+
);
|
|
648
|
+
const ARRAY_ITERATE_KEY = Symbol(
|
|
649
|
+
!!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""
|
|
650
|
+
);
|
|
651
|
+
function track(target, type, key) {
|
|
652
|
+
if (shouldTrack && activeSub) {
|
|
653
|
+
let depsMap = targetMap.get(target);
|
|
654
|
+
if (!depsMap) {
|
|
655
|
+
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
656
|
+
}
|
|
657
|
+
let dep = depsMap.get(key);
|
|
658
|
+
if (!dep) {
|
|
659
|
+
depsMap.set(key, dep = new Dep());
|
|
660
|
+
dep.map = depsMap;
|
|
661
|
+
dep.key = key;
|
|
662
|
+
}
|
|
663
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
664
|
+
dep.track({
|
|
665
|
+
target,
|
|
666
|
+
type,
|
|
667
|
+
key
|
|
668
|
+
});
|
|
669
|
+
} else {
|
|
670
|
+
dep.track();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
675
|
+
const depsMap = targetMap.get(target);
|
|
676
|
+
if (!depsMap) {
|
|
677
|
+
globalVersion++;
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const run = (dep) => {
|
|
681
|
+
if (dep) {
|
|
682
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
683
|
+
dep.trigger({
|
|
684
|
+
target,
|
|
685
|
+
type,
|
|
686
|
+
key,
|
|
687
|
+
newValue,
|
|
688
|
+
oldValue,
|
|
689
|
+
oldTarget
|
|
690
|
+
});
|
|
691
|
+
} else {
|
|
692
|
+
dep.trigger();
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
startBatch();
|
|
697
|
+
if (type === "clear") {
|
|
698
|
+
depsMap.forEach(run);
|
|
699
|
+
} else {
|
|
700
|
+
const targetIsArray = isArray(target);
|
|
701
|
+
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
702
|
+
if (targetIsArray && key === "length") {
|
|
703
|
+
const newLength = Number(newValue);
|
|
704
|
+
depsMap.forEach((dep, key2) => {
|
|
705
|
+
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
|
|
706
|
+
run(dep);
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
} else {
|
|
710
|
+
if (key !== void 0 || depsMap.has(void 0)) {
|
|
711
|
+
run(depsMap.get(key));
|
|
712
|
+
}
|
|
713
|
+
if (isArrayIndex) {
|
|
714
|
+
run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
715
|
+
}
|
|
716
|
+
switch (type) {
|
|
717
|
+
case "add":
|
|
718
|
+
if (!targetIsArray) {
|
|
719
|
+
run(depsMap.get(ITERATE_KEY));
|
|
720
|
+
if (isMap(target)) {
|
|
721
|
+
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
722
|
+
}
|
|
723
|
+
} else if (isArrayIndex) {
|
|
724
|
+
run(depsMap.get("length"));
|
|
725
|
+
}
|
|
726
|
+
break;
|
|
727
|
+
case "delete":
|
|
728
|
+
if (!targetIsArray) {
|
|
729
|
+
run(depsMap.get(ITERATE_KEY));
|
|
730
|
+
if (isMap(target)) {
|
|
731
|
+
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
break;
|
|
735
|
+
case "set":
|
|
736
|
+
if (isMap(target)) {
|
|
737
|
+
run(depsMap.get(ITERATE_KEY));
|
|
738
|
+
}
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
endBatch();
|
|
744
|
+
}
|
|
745
|
+
function getDepFromReactive(object, key) {
|
|
746
|
+
const depMap = targetMap.get(object);
|
|
747
|
+
return depMap && depMap.get(key);
|
|
748
|
+
}
|
|
749
|
+
function reactiveReadArray(array) {
|
|
750
|
+
const raw = toRaw(array);
|
|
751
|
+
if (raw === array) return raw;
|
|
752
|
+
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
753
|
+
return isShallow(array) ? raw : raw.map(toReactive);
|
|
754
|
+
}
|
|
755
|
+
function shallowReadArray(arr) {
|
|
756
|
+
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
757
|
+
return arr;
|
|
758
|
+
}
|
|
759
|
+
const arrayInstrumentations = {
|
|
760
|
+
__proto__: null,
|
|
761
|
+
[Symbol.iterator]() {
|
|
762
|
+
return iterator(this, Symbol.iterator, toReactive);
|
|
763
|
+
},
|
|
764
|
+
concat(...args) {
|
|
765
|
+
return reactiveReadArray(this).concat(
|
|
766
|
+
...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
|
|
767
|
+
);
|
|
768
|
+
},
|
|
769
|
+
entries() {
|
|
770
|
+
return iterator(this, "entries", (value) => {
|
|
771
|
+
value[1] = toReactive(value[1]);
|
|
772
|
+
return value;
|
|
773
|
+
});
|
|
774
|
+
},
|
|
775
|
+
every(fn, thisArg) {
|
|
776
|
+
return apply(this, "every", fn, thisArg, void 0, arguments);
|
|
777
|
+
},
|
|
778
|
+
filter(fn, thisArg) {
|
|
779
|
+
return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
|
|
780
|
+
},
|
|
781
|
+
find(fn, thisArg) {
|
|
782
|
+
return apply(this, "find", fn, thisArg, toReactive, arguments);
|
|
783
|
+
},
|
|
784
|
+
findIndex(fn, thisArg) {
|
|
785
|
+
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
786
|
+
},
|
|
787
|
+
findLast(fn, thisArg) {
|
|
788
|
+
return apply(this, "findLast", fn, thisArg, toReactive, arguments);
|
|
789
|
+
},
|
|
790
|
+
findLastIndex(fn, thisArg) {
|
|
791
|
+
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
792
|
+
},
|
|
793
|
+
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
|
|
794
|
+
forEach(fn, thisArg) {
|
|
795
|
+
return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
|
796
|
+
},
|
|
797
|
+
includes(...args) {
|
|
798
|
+
return searchProxy(this, "includes", args);
|
|
799
|
+
},
|
|
800
|
+
indexOf(...args) {
|
|
801
|
+
return searchProxy(this, "indexOf", args);
|
|
802
|
+
},
|
|
803
|
+
join(separator) {
|
|
804
|
+
return reactiveReadArray(this).join(separator);
|
|
805
|
+
},
|
|
806
|
+
// keys() iterator only reads `length`, no optimisation required
|
|
807
|
+
lastIndexOf(...args) {
|
|
808
|
+
return searchProxy(this, "lastIndexOf", args);
|
|
809
|
+
},
|
|
810
|
+
map(fn, thisArg) {
|
|
811
|
+
return apply(this, "map", fn, thisArg, void 0, arguments);
|
|
812
|
+
},
|
|
813
|
+
pop() {
|
|
814
|
+
return noTracking(this, "pop");
|
|
815
|
+
},
|
|
816
|
+
push(...args) {
|
|
817
|
+
return noTracking(this, "push", args);
|
|
818
|
+
},
|
|
819
|
+
reduce(fn, ...args) {
|
|
820
|
+
return reduce(this, "reduce", fn, args);
|
|
821
|
+
},
|
|
822
|
+
reduceRight(fn, ...args) {
|
|
823
|
+
return reduce(this, "reduceRight", fn, args);
|
|
824
|
+
},
|
|
825
|
+
shift() {
|
|
826
|
+
return noTracking(this, "shift");
|
|
827
|
+
},
|
|
828
|
+
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
|
829
|
+
some(fn, thisArg) {
|
|
830
|
+
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
831
|
+
},
|
|
832
|
+
splice(...args) {
|
|
833
|
+
return noTracking(this, "splice", args);
|
|
834
|
+
},
|
|
835
|
+
toReversed() {
|
|
836
|
+
return reactiveReadArray(this).toReversed();
|
|
837
|
+
},
|
|
838
|
+
toSorted(comparer) {
|
|
839
|
+
return reactiveReadArray(this).toSorted(comparer);
|
|
840
|
+
},
|
|
841
|
+
toSpliced(...args) {
|
|
842
|
+
return reactiveReadArray(this).toSpliced(...args);
|
|
843
|
+
},
|
|
844
|
+
unshift(...args) {
|
|
845
|
+
return noTracking(this, "unshift", args);
|
|
846
|
+
},
|
|
847
|
+
values() {
|
|
848
|
+
return iterator(this, "values", toReactive);
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
function iterator(self, method, wrapValue) {
|
|
852
|
+
const arr = shallowReadArray(self);
|
|
853
|
+
const iter = arr[method]();
|
|
854
|
+
if (arr !== self && !isShallow(self)) {
|
|
855
|
+
iter._next = iter.next;
|
|
856
|
+
iter.next = () => {
|
|
857
|
+
const result = iter._next();
|
|
858
|
+
if (result.value) {
|
|
859
|
+
result.value = wrapValue(result.value);
|
|
860
|
+
}
|
|
861
|
+
return result;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
return iter;
|
|
865
|
+
}
|
|
866
|
+
const arrayProto = Array.prototype;
|
|
867
|
+
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
868
|
+
const arr = shallowReadArray(self);
|
|
869
|
+
const needsWrap = arr !== self && !isShallow(self);
|
|
870
|
+
const methodFn = arr[method];
|
|
871
|
+
if (methodFn !== arrayProto[method]) {
|
|
872
|
+
const result2 = methodFn.apply(self, args);
|
|
873
|
+
return needsWrap ? toReactive(result2) : result2;
|
|
874
|
+
}
|
|
875
|
+
let wrappedFn = fn;
|
|
876
|
+
if (arr !== self) {
|
|
877
|
+
if (needsWrap) {
|
|
878
|
+
wrappedFn = function(item, index) {
|
|
879
|
+
return fn.call(this, toReactive(item), index, self);
|
|
880
|
+
};
|
|
881
|
+
} else if (fn.length > 2) {
|
|
882
|
+
wrappedFn = function(item, index) {
|
|
883
|
+
return fn.call(this, item, index, self);
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
888
|
+
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
889
|
+
}
|
|
890
|
+
function reduce(self, method, fn, args) {
|
|
891
|
+
const arr = shallowReadArray(self);
|
|
892
|
+
let wrappedFn = fn;
|
|
893
|
+
if (arr !== self) {
|
|
894
|
+
if (!isShallow(self)) {
|
|
895
|
+
wrappedFn = function(acc, item, index) {
|
|
896
|
+
return fn.call(this, acc, toReactive(item), index, self);
|
|
897
|
+
};
|
|
898
|
+
} else if (fn.length > 3) {
|
|
899
|
+
wrappedFn = function(acc, item, index) {
|
|
900
|
+
return fn.call(this, acc, item, index, self);
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return arr[method](wrappedFn, ...args);
|
|
905
|
+
}
|
|
906
|
+
function searchProxy(self, method, args) {
|
|
907
|
+
const arr = toRaw(self);
|
|
908
|
+
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
909
|
+
const res = arr[method](...args);
|
|
910
|
+
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
911
|
+
args[0] = toRaw(args[0]);
|
|
912
|
+
return arr[method](...args);
|
|
913
|
+
}
|
|
914
|
+
return res;
|
|
915
|
+
}
|
|
916
|
+
function noTracking(self, method, args = []) {
|
|
917
|
+
pauseTracking();
|
|
918
|
+
startBatch();
|
|
919
|
+
const res = toRaw(self)[method].apply(self, args);
|
|
920
|
+
endBatch();
|
|
921
|
+
resetTracking();
|
|
922
|
+
return res;
|
|
923
|
+
}
|
|
924
|
+
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
925
|
+
const builtInSymbols = new Set(
|
|
926
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
927
|
+
);
|
|
928
|
+
function hasOwnProperty(key) {
|
|
929
|
+
if (!isSymbol(key)) key = String(key);
|
|
930
|
+
const obj = toRaw(this);
|
|
931
|
+
track(obj, "has", key);
|
|
932
|
+
return obj.hasOwnProperty(key);
|
|
933
|
+
}
|
|
934
|
+
class BaseReactiveHandler {
|
|
935
|
+
constructor(_isReadonly = false, _isShallow = false) {
|
|
936
|
+
this._isReadonly = _isReadonly;
|
|
937
|
+
this._isShallow = _isShallow;
|
|
938
|
+
}
|
|
939
|
+
get(target, key, receiver) {
|
|
940
|
+
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
941
|
+
if (key === "__v_isReactive") {
|
|
942
|
+
return !isReadonly2;
|
|
943
|
+
} else if (key === "__v_isReadonly") {
|
|
944
|
+
return isReadonly2;
|
|
945
|
+
} else if (key === "__v_isShallow") {
|
|
946
|
+
return isShallow2;
|
|
947
|
+
} else if (key === "__v_raw") {
|
|
948
|
+
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
949
|
+
// this means the receiver is a user proxy of the reactive proxy
|
|
950
|
+
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
951
|
+
return target;
|
|
952
|
+
}
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
const targetIsArray = isArray(target);
|
|
956
|
+
if (!isReadonly2) {
|
|
957
|
+
let fn;
|
|
958
|
+
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
959
|
+
return fn;
|
|
960
|
+
}
|
|
961
|
+
if (key === "hasOwnProperty") {
|
|
962
|
+
return hasOwnProperty;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const res = Reflect.get(
|
|
966
|
+
target,
|
|
967
|
+
key,
|
|
968
|
+
// if this is a proxy wrapping a ref, return methods using the raw ref
|
|
969
|
+
// as receiver so that we don't have to call `toRaw` on the ref in all
|
|
970
|
+
// its class methods
|
|
971
|
+
isRef(target) ? target : receiver
|
|
972
|
+
);
|
|
973
|
+
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
974
|
+
return res;
|
|
975
|
+
}
|
|
976
|
+
if (!isReadonly2) {
|
|
977
|
+
track(target, "get", key);
|
|
978
|
+
}
|
|
979
|
+
if (isShallow2) {
|
|
980
|
+
return res;
|
|
981
|
+
}
|
|
982
|
+
if (isRef(res)) {
|
|
983
|
+
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
984
|
+
}
|
|
985
|
+
if (isObject(res)) {
|
|
986
|
+
return isReadonly2 ? readonly(res) : reactive(res);
|
|
987
|
+
}
|
|
988
|
+
return res;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
992
|
+
constructor(isShallow2 = false) {
|
|
993
|
+
super(false, isShallow2);
|
|
994
|
+
}
|
|
995
|
+
set(target, key, value, receiver) {
|
|
996
|
+
let oldValue = target[key];
|
|
997
|
+
if (!this._isShallow) {
|
|
998
|
+
const isOldValueReadonly = isReadonly(oldValue);
|
|
999
|
+
if (!isShallow(value) && !isReadonly(value)) {
|
|
1000
|
+
oldValue = toRaw(oldValue);
|
|
1001
|
+
value = toRaw(value);
|
|
1002
|
+
}
|
|
1003
|
+
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
1004
|
+
if (isOldValueReadonly) {
|
|
1005
|
+
return false;
|
|
1006
|
+
} else {
|
|
1007
|
+
oldValue.value = value;
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
1013
|
+
const result = Reflect.set(
|
|
1014
|
+
target,
|
|
1015
|
+
key,
|
|
1016
|
+
value,
|
|
1017
|
+
isRef(target) ? target : receiver
|
|
1018
|
+
);
|
|
1019
|
+
if (target === toRaw(receiver)) {
|
|
1020
|
+
if (!hadKey) {
|
|
1021
|
+
trigger(target, "add", key, value);
|
|
1022
|
+
} else if (hasChanged(value, oldValue)) {
|
|
1023
|
+
trigger(target, "set", key, value, oldValue);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return result;
|
|
1027
|
+
}
|
|
1028
|
+
deleteProperty(target, key) {
|
|
1029
|
+
const hadKey = hasOwn(target, key);
|
|
1030
|
+
const oldValue = target[key];
|
|
1031
|
+
const result = Reflect.deleteProperty(target, key);
|
|
1032
|
+
if (result && hadKey) {
|
|
1033
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
1034
|
+
}
|
|
1035
|
+
return result;
|
|
1036
|
+
}
|
|
1037
|
+
has(target, key) {
|
|
1038
|
+
const result = Reflect.has(target, key);
|
|
1039
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
1040
|
+
track(target, "has", key);
|
|
1041
|
+
}
|
|
1042
|
+
return result;
|
|
1043
|
+
}
|
|
1044
|
+
ownKeys(target) {
|
|
1045
|
+
track(
|
|
1046
|
+
target,
|
|
1047
|
+
"iterate",
|
|
1048
|
+
isArray(target) ? "length" : ITERATE_KEY
|
|
1049
|
+
);
|
|
1050
|
+
return Reflect.ownKeys(target);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
1054
|
+
constructor(isShallow2 = false) {
|
|
1055
|
+
super(true, isShallow2);
|
|
1056
|
+
}
|
|
1057
|
+
set(target, key) {
|
|
1058
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1059
|
+
warn$1(
|
|
1060
|
+
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
1061
|
+
target
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
deleteProperty(target, key) {
|
|
1067
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1068
|
+
warn$1(
|
|
1069
|
+
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
1070
|
+
target
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return true;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
1077
|
+
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
1078
|
+
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
|
1079
|
+
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
1080
|
+
const toShallow = (value) => value;
|
|
1081
|
+
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1082
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1083
|
+
return function(...args) {
|
|
1084
|
+
const target = this["__v_raw"];
|
|
1085
|
+
const rawTarget = toRaw(target);
|
|
1086
|
+
const targetIsMap = isMap(rawTarget);
|
|
1087
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1088
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1089
|
+
const innerIterator = target[method](...args);
|
|
1090
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1091
|
+
!isReadonly2 && track(
|
|
1092
|
+
rawTarget,
|
|
1093
|
+
"iterate",
|
|
1094
|
+
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
1095
|
+
);
|
|
1096
|
+
return {
|
|
1097
|
+
// iterator protocol
|
|
1098
|
+
next() {
|
|
1099
|
+
const { value, done } = innerIterator.next();
|
|
1100
|
+
return done ? { value, done } : {
|
|
1101
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
1102
|
+
done
|
|
1103
|
+
};
|
|
1104
|
+
},
|
|
1105
|
+
// iterable protocol
|
|
1106
|
+
[Symbol.iterator]() {
|
|
1107
|
+
return this;
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
function createReadonlyMethod(type) {
|
|
1113
|
+
return function(...args) {
|
|
1114
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1115
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
1116
|
+
warn$1(
|
|
1117
|
+
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
1118
|
+
toRaw(this)
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
function createInstrumentations(readonly2, shallow) {
|
|
1125
|
+
const instrumentations = {
|
|
1126
|
+
get(key) {
|
|
1127
|
+
const target = this["__v_raw"];
|
|
1128
|
+
const rawTarget = toRaw(target);
|
|
1129
|
+
const rawKey = toRaw(key);
|
|
1130
|
+
if (!readonly2) {
|
|
1131
|
+
if (hasChanged(key, rawKey)) {
|
|
1132
|
+
track(rawTarget, "get", key);
|
|
1133
|
+
}
|
|
1134
|
+
track(rawTarget, "get", rawKey);
|
|
1135
|
+
}
|
|
1136
|
+
const { has } = getProto(rawTarget);
|
|
1137
|
+
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
1138
|
+
if (has.call(rawTarget, key)) {
|
|
1139
|
+
return wrap(target.get(key));
|
|
1140
|
+
} else if (has.call(rawTarget, rawKey)) {
|
|
1141
|
+
return wrap(target.get(rawKey));
|
|
1142
|
+
} else if (target !== rawTarget) {
|
|
1143
|
+
target.get(key);
|
|
1144
|
+
}
|
|
1145
|
+
},
|
|
1146
|
+
get size() {
|
|
1147
|
+
const target = this["__v_raw"];
|
|
1148
|
+
!readonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1149
|
+
return Reflect.get(target, "size", target);
|
|
1150
|
+
},
|
|
1151
|
+
has(key) {
|
|
1152
|
+
const target = this["__v_raw"];
|
|
1153
|
+
const rawTarget = toRaw(target);
|
|
1154
|
+
const rawKey = toRaw(key);
|
|
1155
|
+
if (!readonly2) {
|
|
1156
|
+
if (hasChanged(key, rawKey)) {
|
|
1157
|
+
track(rawTarget, "has", key);
|
|
1158
|
+
}
|
|
1159
|
+
track(rawTarget, "has", rawKey);
|
|
1160
|
+
}
|
|
1161
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1162
|
+
},
|
|
1163
|
+
forEach(callback, thisArg) {
|
|
1164
|
+
const observed = this;
|
|
1165
|
+
const target = observed["__v_raw"];
|
|
1166
|
+
const rawTarget = toRaw(target);
|
|
1167
|
+
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
1168
|
+
!readonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1169
|
+
return target.forEach((value, key) => {
|
|
1170
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
extend(
|
|
1175
|
+
instrumentations,
|
|
1176
|
+
readonly2 ? {
|
|
1177
|
+
add: createReadonlyMethod("add"),
|
|
1178
|
+
set: createReadonlyMethod("set"),
|
|
1179
|
+
delete: createReadonlyMethod("delete"),
|
|
1180
|
+
clear: createReadonlyMethod("clear")
|
|
1181
|
+
} : {
|
|
1182
|
+
add(value) {
|
|
1183
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1184
|
+
value = toRaw(value);
|
|
1185
|
+
}
|
|
1186
|
+
const target = toRaw(this);
|
|
1187
|
+
const proto = getProto(target);
|
|
1188
|
+
const hadKey = proto.has.call(target, value);
|
|
1189
|
+
if (!hadKey) {
|
|
1190
|
+
target.add(value);
|
|
1191
|
+
trigger(target, "add", value, value);
|
|
1192
|
+
}
|
|
1193
|
+
return this;
|
|
1194
|
+
},
|
|
1195
|
+
set(key, value) {
|
|
1196
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1197
|
+
value = toRaw(value);
|
|
1198
|
+
}
|
|
1199
|
+
const target = toRaw(this);
|
|
1200
|
+
const { has, get } = getProto(target);
|
|
1201
|
+
let hadKey = has.call(target, key);
|
|
1202
|
+
if (!hadKey) {
|
|
1203
|
+
key = toRaw(key);
|
|
1204
|
+
hadKey = has.call(target, key);
|
|
1205
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1206
|
+
checkIdentityKeys(target, has, key);
|
|
1207
|
+
}
|
|
1208
|
+
const oldValue = get.call(target, key);
|
|
1209
|
+
target.set(key, value);
|
|
1210
|
+
if (!hadKey) {
|
|
1211
|
+
trigger(target, "add", key, value);
|
|
1212
|
+
} else if (hasChanged(value, oldValue)) {
|
|
1213
|
+
trigger(target, "set", key, value, oldValue);
|
|
1214
|
+
}
|
|
1215
|
+
return this;
|
|
1216
|
+
},
|
|
1217
|
+
delete(key) {
|
|
1218
|
+
const target = toRaw(this);
|
|
1219
|
+
const { has, get } = getProto(target);
|
|
1220
|
+
let hadKey = has.call(target, key);
|
|
1221
|
+
if (!hadKey) {
|
|
1222
|
+
key = toRaw(key);
|
|
1223
|
+
hadKey = has.call(target, key);
|
|
1224
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1225
|
+
checkIdentityKeys(target, has, key);
|
|
1226
|
+
}
|
|
1227
|
+
const oldValue = get ? get.call(target, key) : void 0;
|
|
1228
|
+
const result = target.delete(key);
|
|
1229
|
+
if (hadKey) {
|
|
1230
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
1231
|
+
}
|
|
1232
|
+
return result;
|
|
1233
|
+
},
|
|
1234
|
+
clear() {
|
|
1235
|
+
const target = toRaw(this);
|
|
1236
|
+
const hadItems = target.size !== 0;
|
|
1237
|
+
const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
1238
|
+
const result = target.clear();
|
|
1239
|
+
if (hadItems) {
|
|
1240
|
+
trigger(
|
|
1241
|
+
target,
|
|
1242
|
+
"clear",
|
|
1243
|
+
void 0,
|
|
1244
|
+
void 0,
|
|
1245
|
+
oldTarget
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
return result;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
1252
|
+
const iteratorMethods = [
|
|
1253
|
+
"keys",
|
|
1254
|
+
"values",
|
|
1255
|
+
"entries",
|
|
1256
|
+
Symbol.iterator
|
|
1257
|
+
];
|
|
1258
|
+
iteratorMethods.forEach((method) => {
|
|
1259
|
+
instrumentations[method] = createIterableMethod(method, readonly2, shallow);
|
|
1260
|
+
});
|
|
1261
|
+
return instrumentations;
|
|
1262
|
+
}
|
|
1263
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1264
|
+
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1265
|
+
return (target, key, receiver) => {
|
|
1266
|
+
if (key === "__v_isReactive") {
|
|
1267
|
+
return !isReadonly2;
|
|
1268
|
+
} else if (key === "__v_isReadonly") {
|
|
1269
|
+
return isReadonly2;
|
|
1270
|
+
} else if (key === "__v_raw") {
|
|
1271
|
+
return target;
|
|
1272
|
+
}
|
|
1273
|
+
return Reflect.get(
|
|
1274
|
+
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
1275
|
+
key,
|
|
1276
|
+
receiver
|
|
1277
|
+
);
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
const mutableCollectionHandlers = {
|
|
1281
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
1282
|
+
};
|
|
1283
|
+
const shallowCollectionHandlers = {
|
|
1284
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
1285
|
+
};
|
|
1286
|
+
const readonlyCollectionHandlers = {
|
|
1287
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
1288
|
+
};
|
|
1289
|
+
const shallowReadonlyCollectionHandlers = {
|
|
1290
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
1291
|
+
};
|
|
1292
|
+
function checkIdentityKeys(target, has, key) {
|
|
1293
|
+
const rawKey = toRaw(key);
|
|
1294
|
+
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1295
|
+
const type = toRawType(target);
|
|
1296
|
+
warn$1(
|
|
1297
|
+
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1302
|
+
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1303
|
+
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1304
|
+
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1305
|
+
function targetTypeMap(rawType) {
|
|
1306
|
+
switch (rawType) {
|
|
1307
|
+
case "Object":
|
|
1308
|
+
case "Array":
|
|
1309
|
+
return 1;
|
|
1310
|
+
case "Map":
|
|
1311
|
+
case "Set":
|
|
1312
|
+
case "WeakMap":
|
|
1313
|
+
case "WeakSet":
|
|
1314
|
+
return 2;
|
|
1315
|
+
default:
|
|
1316
|
+
return 0;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
function getTargetType(value) {
|
|
1320
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
1321
|
+
}
|
|
1322
|
+
function reactive(target) {
|
|
1323
|
+
if (isReadonly(target)) {
|
|
1324
|
+
return target;
|
|
1325
|
+
}
|
|
1326
|
+
return createReactiveObject(
|
|
1327
|
+
target,
|
|
1328
|
+
false,
|
|
1329
|
+
mutableHandlers,
|
|
1330
|
+
mutableCollectionHandlers,
|
|
1331
|
+
reactiveMap
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
function shallowReactive(target) {
|
|
1335
|
+
return createReactiveObject(
|
|
1336
|
+
target,
|
|
1337
|
+
false,
|
|
1338
|
+
shallowReactiveHandlers,
|
|
1339
|
+
shallowCollectionHandlers,
|
|
1340
|
+
shallowReactiveMap
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
function readonly(target) {
|
|
1344
|
+
return createReactiveObject(
|
|
1345
|
+
target,
|
|
1346
|
+
true,
|
|
1347
|
+
readonlyHandlers,
|
|
1348
|
+
readonlyCollectionHandlers,
|
|
1349
|
+
readonlyMap
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1352
|
+
function shallowReadonly(target) {
|
|
1353
|
+
return createReactiveObject(
|
|
1354
|
+
target,
|
|
1355
|
+
true,
|
|
1356
|
+
shallowReadonlyHandlers,
|
|
1357
|
+
shallowReadonlyCollectionHandlers,
|
|
1358
|
+
shallowReadonlyMap
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1362
|
+
if (!isObject(target)) {
|
|
1363
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1364
|
+
warn$1(
|
|
1365
|
+
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
1366
|
+
target
|
|
1367
|
+
)}`
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
return target;
|
|
1371
|
+
}
|
|
1372
|
+
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
1373
|
+
return target;
|
|
1374
|
+
}
|
|
1375
|
+
const existingProxy = proxyMap.get(target);
|
|
1376
|
+
if (existingProxy) {
|
|
1377
|
+
return existingProxy;
|
|
1378
|
+
}
|
|
1379
|
+
const targetType = getTargetType(target);
|
|
1380
|
+
if (targetType === 0) {
|
|
1381
|
+
return target;
|
|
1382
|
+
}
|
|
1383
|
+
const proxy = new Proxy(
|
|
1384
|
+
target,
|
|
1385
|
+
targetType === 2 ? collectionHandlers : baseHandlers
|
|
1386
|
+
);
|
|
1387
|
+
proxyMap.set(target, proxy);
|
|
1388
|
+
return proxy;
|
|
1389
|
+
}
|
|
1390
|
+
function isReactive(value) {
|
|
1391
|
+
if (isReadonly(value)) {
|
|
1392
|
+
return isReactive(value["__v_raw"]);
|
|
1393
|
+
}
|
|
1394
|
+
return !!(value && value["__v_isReactive"]);
|
|
1395
|
+
}
|
|
1396
|
+
function isReadonly(value) {
|
|
1397
|
+
return !!(value && value["__v_isReadonly"]);
|
|
1398
|
+
}
|
|
1399
|
+
function isShallow(value) {
|
|
1400
|
+
return !!(value && value["__v_isShallow"]);
|
|
1401
|
+
}
|
|
1402
|
+
function isProxy(value) {
|
|
1403
|
+
return value ? !!value["__v_raw"] : false;
|
|
1404
|
+
}
|
|
1405
|
+
function toRaw(observed) {
|
|
1406
|
+
const raw = observed && observed["__v_raw"];
|
|
1407
|
+
return raw ? toRaw(raw) : observed;
|
|
1408
|
+
}
|
|
1409
|
+
function markRaw(value) {
|
|
1410
|
+
if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
|
|
1411
|
+
def(value, "__v_skip", true);
|
|
1412
|
+
}
|
|
1413
|
+
return value;
|
|
1414
|
+
}
|
|
1415
|
+
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
1416
|
+
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1417
|
+
function isRef(r) {
|
|
1418
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1419
|
+
}
|
|
1420
|
+
function ref(value) {
|
|
1421
|
+
return createRef(value, false);
|
|
1422
|
+
}
|
|
1423
|
+
function shallowRef(value) {
|
|
1424
|
+
return createRef(value, true);
|
|
1425
|
+
}
|
|
1426
|
+
function createRef(rawValue, shallow) {
|
|
1427
|
+
if (isRef(rawValue)) {
|
|
1428
|
+
return rawValue;
|
|
1429
|
+
}
|
|
1430
|
+
return new RefImpl(rawValue, shallow);
|
|
1431
|
+
}
|
|
1432
|
+
class RefImpl {
|
|
1433
|
+
constructor(value, isShallow2) {
|
|
1434
|
+
this.dep = new Dep();
|
|
1435
|
+
this["__v_isRef"] = true;
|
|
1436
|
+
this["__v_isShallow"] = false;
|
|
1437
|
+
this._rawValue = isShallow2 ? value : toRaw(value);
|
|
1438
|
+
this._value = isShallow2 ? value : toReactive(value);
|
|
1439
|
+
this["__v_isShallow"] = isShallow2;
|
|
1440
|
+
}
|
|
1441
|
+
get value() {
|
|
1442
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1443
|
+
this.dep.track({
|
|
1444
|
+
target: this,
|
|
1445
|
+
type: "get",
|
|
1446
|
+
key: "value"
|
|
1447
|
+
});
|
|
1448
|
+
} else {
|
|
1449
|
+
this.dep.track();
|
|
1450
|
+
}
|
|
1451
|
+
return this._value;
|
|
1452
|
+
}
|
|
1453
|
+
set value(newValue) {
|
|
1454
|
+
const oldValue = this._rawValue;
|
|
1455
|
+
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1456
|
+
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1457
|
+
if (hasChanged(newValue, oldValue)) {
|
|
1458
|
+
this._rawValue = newValue;
|
|
1459
|
+
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
1460
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1461
|
+
this.dep.trigger({
|
|
1462
|
+
target: this,
|
|
1463
|
+
type: "set",
|
|
1464
|
+
key: "value",
|
|
1465
|
+
newValue,
|
|
1466
|
+
oldValue
|
|
1467
|
+
});
|
|
1468
|
+
} else {
|
|
1469
|
+
this.dep.trigger();
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
function triggerRef(ref2) {
|
|
1475
|
+
if (ref2.dep) {
|
|
1476
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1477
|
+
ref2.dep.trigger({
|
|
1478
|
+
target: ref2,
|
|
1479
|
+
type: "set",
|
|
1480
|
+
key: "value",
|
|
1481
|
+
newValue: ref2._value
|
|
1482
|
+
});
|
|
1483
|
+
} else {
|
|
1484
|
+
ref2.dep.trigger();
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
function unref(ref2) {
|
|
1489
|
+
return isRef(ref2) ? ref2.value : ref2;
|
|
1490
|
+
}
|
|
1491
|
+
function toValue(source) {
|
|
1492
|
+
return isFunction(source) ? source() : unref(source);
|
|
1493
|
+
}
|
|
1494
|
+
const shallowUnwrapHandlers = {
|
|
1495
|
+
get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
|
|
1496
|
+
set: (target, key, value, receiver) => {
|
|
1497
|
+
const oldValue = target[key];
|
|
1498
|
+
if (isRef(oldValue) && !isRef(value)) {
|
|
1499
|
+
oldValue.value = value;
|
|
1500
|
+
return true;
|
|
1501
|
+
} else {
|
|
1502
|
+
return Reflect.set(target, key, value, receiver);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
function proxyRefs(objectWithRefs) {
|
|
1507
|
+
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1508
|
+
}
|
|
1509
|
+
class CustomRefImpl {
|
|
1510
|
+
constructor(factory) {
|
|
1511
|
+
this["__v_isRef"] = true;
|
|
1512
|
+
this._value = void 0;
|
|
1513
|
+
const dep = this.dep = new Dep();
|
|
1514
|
+
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
1515
|
+
this._get = get;
|
|
1516
|
+
this._set = set;
|
|
1517
|
+
}
|
|
1518
|
+
get value() {
|
|
1519
|
+
return this._value = this._get();
|
|
1520
|
+
}
|
|
1521
|
+
set value(newVal) {
|
|
1522
|
+
this._set(newVal);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
function customRef(factory) {
|
|
1526
|
+
return new CustomRefImpl(factory);
|
|
1527
|
+
}
|
|
1528
|
+
function toRefs(object) {
|
|
1529
|
+
if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
|
|
1530
|
+
warn$1(`toRefs() expects a reactive object but received a plain one.`);
|
|
1531
|
+
}
|
|
1532
|
+
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1533
|
+
for (const key in object) {
|
|
1534
|
+
ret[key] = propertyToRef(object, key);
|
|
1535
|
+
}
|
|
1536
|
+
return ret;
|
|
1537
|
+
}
|
|
1538
|
+
class ObjectRefImpl {
|
|
1539
|
+
constructor(_object, _key, _defaultValue) {
|
|
1540
|
+
this._object = _object;
|
|
1541
|
+
this._key = _key;
|
|
1542
|
+
this._defaultValue = _defaultValue;
|
|
1543
|
+
this["__v_isRef"] = true;
|
|
1544
|
+
this._value = void 0;
|
|
1545
|
+
}
|
|
1546
|
+
get value() {
|
|
1547
|
+
const val = this._object[this._key];
|
|
1548
|
+
return this._value = val === void 0 ? this._defaultValue : val;
|
|
1549
|
+
}
|
|
1550
|
+
set value(newVal) {
|
|
1551
|
+
this._object[this._key] = newVal;
|
|
1552
|
+
}
|
|
1553
|
+
get dep() {
|
|
1554
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
class GetterRefImpl {
|
|
1558
|
+
constructor(_getter) {
|
|
1559
|
+
this._getter = _getter;
|
|
1560
|
+
this["__v_isRef"] = true;
|
|
1561
|
+
this["__v_isReadonly"] = true;
|
|
1562
|
+
this._value = void 0;
|
|
1563
|
+
}
|
|
1564
|
+
get value() {
|
|
1565
|
+
return this._value = this._getter();
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
function toRef(source, key, defaultValue) {
|
|
1569
|
+
if (isRef(source)) {
|
|
1570
|
+
return source;
|
|
1571
|
+
} else if (isFunction(source)) {
|
|
1572
|
+
return new GetterRefImpl(source);
|
|
1573
|
+
} else if (isObject(source) && arguments.length > 1) {
|
|
1574
|
+
return propertyToRef(source, key, defaultValue);
|
|
1575
|
+
} else {
|
|
1576
|
+
return ref(source);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1580
|
+
const val = source[key];
|
|
1581
|
+
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1582
|
+
}
|
|
1583
|
+
class ComputedRefImpl {
|
|
1584
|
+
constructor(fn, setter, isSSR) {
|
|
1585
|
+
this.fn = fn;
|
|
1586
|
+
this.setter = setter;
|
|
1587
|
+
this._value = void 0;
|
|
1588
|
+
this.dep = new Dep(this);
|
|
1589
|
+
this.__v_isRef = true;
|
|
1590
|
+
this.deps = void 0;
|
|
1591
|
+
this.depsTail = void 0;
|
|
1592
|
+
this.flags = 16;
|
|
1593
|
+
this.globalVersion = globalVersion - 1;
|
|
1594
|
+
this.next = void 0;
|
|
1595
|
+
this.effect = this;
|
|
1596
|
+
this["__v_isReadonly"] = !setter;
|
|
1597
|
+
this.isSSR = isSSR;
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* @internal
|
|
1601
|
+
*/
|
|
1602
|
+
notify() {
|
|
1603
|
+
this.flags |= 16;
|
|
1604
|
+
if (!(this.flags & 8) && // avoid infinite self recursion
|
|
1605
|
+
activeSub !== this) {
|
|
1606
|
+
batch(this, true);
|
|
1607
|
+
return true;
|
|
1608
|
+
} else if (!!(process.env.NODE_ENV !== "production")) ;
|
|
1609
|
+
}
|
|
1610
|
+
get value() {
|
|
1611
|
+
const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
|
|
1612
|
+
target: this,
|
|
1613
|
+
type: "get",
|
|
1614
|
+
key: "value"
|
|
1615
|
+
}) : this.dep.track();
|
|
1616
|
+
refreshComputed(this);
|
|
1617
|
+
if (link) {
|
|
1618
|
+
link.version = this.dep.version;
|
|
1619
|
+
}
|
|
1620
|
+
return this._value;
|
|
1621
|
+
}
|
|
1622
|
+
set value(newValue) {
|
|
1623
|
+
if (this.setter) {
|
|
1624
|
+
this.setter(newValue);
|
|
1625
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1626
|
+
warn$1("Write operation failed: computed value is readonly");
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1631
|
+
let getter;
|
|
1632
|
+
let setter;
|
|
1633
|
+
if (isFunction(getterOrOptions)) {
|
|
1634
|
+
getter = getterOrOptions;
|
|
1635
|
+
} else {
|
|
1636
|
+
getter = getterOrOptions.get;
|
|
1637
|
+
setter = getterOrOptions.set;
|
|
1638
|
+
}
|
|
1639
|
+
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
1640
|
+
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
|
|
1641
|
+
cRef.onTrack = debugOptions.onTrack;
|
|
1642
|
+
cRef.onTrigger = debugOptions.onTrigger;
|
|
1643
|
+
}
|
|
1644
|
+
return cRef;
|
|
1645
|
+
}
|
|
1646
|
+
const TrackOpTypes = {
|
|
1647
|
+
"GET": "get",
|
|
1648
|
+
"HAS": "has",
|
|
1649
|
+
"ITERATE": "iterate"
|
|
1650
|
+
};
|
|
1651
|
+
const TriggerOpTypes = {
|
|
1652
|
+
"SET": "set",
|
|
1653
|
+
"ADD": "add",
|
|
1654
|
+
"DELETE": "delete",
|
|
1655
|
+
"CLEAR": "clear"
|
|
1656
|
+
};
|
|
1657
|
+
const ReactiveFlags = {
|
|
1658
|
+
"SKIP": "__v_skip",
|
|
1659
|
+
"IS_REACTIVE": "__v_isReactive",
|
|
1660
|
+
"IS_READONLY": "__v_isReadonly",
|
|
1661
|
+
"IS_SHALLOW": "__v_isShallow",
|
|
1662
|
+
"RAW": "__v_raw",
|
|
1663
|
+
"IS_REF": "__v_isRef"
|
|
1664
|
+
};
|
|
1665
|
+
const WatchErrorCodes = {
|
|
1666
|
+
"WATCH_GETTER": 2,
|
|
1667
|
+
"2": "WATCH_GETTER",
|
|
1668
|
+
"WATCH_CALLBACK": 3,
|
|
1669
|
+
"3": "WATCH_CALLBACK",
|
|
1670
|
+
"WATCH_CLEANUP": 4,
|
|
1671
|
+
"4": "WATCH_CLEANUP"
|
|
1672
|
+
};
|
|
1673
|
+
const INITIAL_WATCHER_VALUE = {};
|
|
1674
|
+
const cleanupMap = /* @__PURE__ */ new WeakMap();
|
|
1675
|
+
let activeWatcher = void 0;
|
|
1676
|
+
function getCurrentWatcher() {
|
|
1677
|
+
return activeWatcher;
|
|
1678
|
+
}
|
|
1679
|
+
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1680
|
+
if (owner) {
|
|
1681
|
+
let cleanups = cleanupMap.get(owner);
|
|
1682
|
+
if (!cleanups) cleanupMap.set(owner, cleanups = []);
|
|
1683
|
+
cleanups.push(cleanupFn);
|
|
1684
|
+
} else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
|
|
1685
|
+
warn$1(
|
|
1686
|
+
`onWatcherCleanup() was called when there was no active watcher to associate with.`
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
function watch$1(source, cb, options = EMPTY_OBJ) {
|
|
1691
|
+
const { immediate, deep, once, scheduler, augmentJob, call } = options;
|
|
1692
|
+
const warnInvalidSource = (s) => {
|
|
1693
|
+
(options.onWarn || warn$1)(
|
|
1694
|
+
`Invalid watch source: `,
|
|
1695
|
+
s,
|
|
1696
|
+
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
1697
|
+
);
|
|
1698
|
+
};
|
|
1699
|
+
const reactiveGetter = (source2) => {
|
|
1700
|
+
if (deep) return source2;
|
|
1701
|
+
if (isShallow(source2) || deep === false || deep === 0)
|
|
1702
|
+
return traverse(source2, 1);
|
|
1703
|
+
return traverse(source2);
|
|
1704
|
+
};
|
|
1705
|
+
let effect2;
|
|
1706
|
+
let getter;
|
|
1707
|
+
let cleanup;
|
|
1708
|
+
let boundCleanup;
|
|
1709
|
+
let forceTrigger = false;
|
|
1710
|
+
let isMultiSource = false;
|
|
1711
|
+
if (isRef(source)) {
|
|
1712
|
+
getter = () => source.value;
|
|
1713
|
+
forceTrigger = isShallow(source);
|
|
1714
|
+
} else if (isReactive(source)) {
|
|
1715
|
+
getter = () => reactiveGetter(source);
|
|
1716
|
+
forceTrigger = true;
|
|
1717
|
+
} else if (isArray(source)) {
|
|
1718
|
+
isMultiSource = true;
|
|
1719
|
+
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1720
|
+
getter = () => source.map((s) => {
|
|
1721
|
+
if (isRef(s)) {
|
|
1722
|
+
return s.value;
|
|
1723
|
+
} else if (isReactive(s)) {
|
|
1724
|
+
return reactiveGetter(s);
|
|
1725
|
+
} else if (isFunction(s)) {
|
|
1726
|
+
return call ? call(s, 2) : s();
|
|
1727
|
+
} else {
|
|
1728
|
+
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
} else if (isFunction(source)) {
|
|
1732
|
+
if (cb) {
|
|
1733
|
+
getter = call ? () => call(source, 2) : source;
|
|
1734
|
+
} else {
|
|
1735
|
+
getter = () => {
|
|
1736
|
+
if (cleanup) {
|
|
1737
|
+
pauseTracking();
|
|
1738
|
+
try {
|
|
1739
|
+
cleanup();
|
|
1740
|
+
} finally {
|
|
1741
|
+
resetTracking();
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
const currentEffect = activeWatcher;
|
|
1745
|
+
activeWatcher = effect2;
|
|
1746
|
+
try {
|
|
1747
|
+
return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
|
|
1748
|
+
} finally {
|
|
1749
|
+
activeWatcher = currentEffect;
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
} else {
|
|
1754
|
+
getter = NOOP;
|
|
1755
|
+
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
|
|
1756
|
+
}
|
|
1757
|
+
if (cb && deep) {
|
|
1758
|
+
const baseGetter = getter;
|
|
1759
|
+
const depth = deep === true ? Infinity : deep;
|
|
1760
|
+
getter = () => traverse(baseGetter(), depth);
|
|
1761
|
+
}
|
|
1762
|
+
const scope = getCurrentScope();
|
|
1763
|
+
const watchHandle = () => {
|
|
1764
|
+
effect2.stop();
|
|
1765
|
+
if (scope) {
|
|
1766
|
+
remove(scope.effects, effect2);
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
if (once && cb) {
|
|
1770
|
+
const _cb = cb;
|
|
1771
|
+
cb = (...args) => {
|
|
1772
|
+
_cb(...args);
|
|
1773
|
+
watchHandle();
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1777
|
+
const job = (immediateFirstRun) => {
|
|
1778
|
+
if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
if (cb) {
|
|
1782
|
+
const newValue = effect2.run();
|
|
1783
|
+
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1784
|
+
if (cleanup) {
|
|
1785
|
+
cleanup();
|
|
1786
|
+
}
|
|
1787
|
+
const currentWatcher = activeWatcher;
|
|
1788
|
+
activeWatcher = effect2;
|
|
1789
|
+
try {
|
|
1790
|
+
const args = [
|
|
1791
|
+
newValue,
|
|
1792
|
+
// pass undefined as the old value when it's changed for the first time
|
|
1793
|
+
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1794
|
+
boundCleanup
|
|
1795
|
+
];
|
|
1796
|
+
call ? call(cb, 3, args) : (
|
|
1797
|
+
// @ts-expect-error
|
|
1798
|
+
cb(...args)
|
|
1799
|
+
);
|
|
1800
|
+
oldValue = newValue;
|
|
1801
|
+
} finally {
|
|
1802
|
+
activeWatcher = currentWatcher;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
} else {
|
|
1806
|
+
effect2.run();
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
if (augmentJob) {
|
|
1810
|
+
augmentJob(job);
|
|
1811
|
+
}
|
|
1812
|
+
effect2 = new ReactiveEffect(getter);
|
|
1813
|
+
effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
|
|
1814
|
+
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
|
|
1815
|
+
cleanup = effect2.onStop = () => {
|
|
1816
|
+
const cleanups = cleanupMap.get(effect2);
|
|
1817
|
+
if (cleanups) {
|
|
1818
|
+
if (call) {
|
|
1819
|
+
call(cleanups, 4);
|
|
1820
|
+
} else {
|
|
1821
|
+
for (const cleanup2 of cleanups) cleanup2();
|
|
1822
|
+
}
|
|
1823
|
+
cleanupMap.delete(effect2);
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1827
|
+
effect2.onTrack = options.onTrack;
|
|
1828
|
+
effect2.onTrigger = options.onTrigger;
|
|
1829
|
+
}
|
|
1830
|
+
if (cb) {
|
|
1831
|
+
if (immediate) {
|
|
1832
|
+
job(true);
|
|
1833
|
+
} else {
|
|
1834
|
+
oldValue = effect2.run();
|
|
1835
|
+
}
|
|
1836
|
+
} else if (scheduler) {
|
|
1837
|
+
scheduler(job.bind(null, true), true);
|
|
1838
|
+
} else {
|
|
1839
|
+
effect2.run();
|
|
1840
|
+
}
|
|
1841
|
+
watchHandle.pause = effect2.pause.bind(effect2);
|
|
1842
|
+
watchHandle.resume = effect2.resume.bind(effect2);
|
|
1843
|
+
watchHandle.stop = watchHandle;
|
|
1844
|
+
return watchHandle;
|
|
1845
|
+
}
|
|
1846
|
+
function traverse(value, depth = Infinity, seen) {
|
|
1847
|
+
if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
|
|
1848
|
+
return value;
|
|
1849
|
+
}
|
|
1850
|
+
seen = seen || /* @__PURE__ */ new Set();
|
|
1851
|
+
if (seen.has(value)) {
|
|
1852
|
+
return value;
|
|
1853
|
+
}
|
|
1854
|
+
seen.add(value);
|
|
1855
|
+
depth--;
|
|
1856
|
+
if (isRef(value)) {
|
|
1857
|
+
traverse(value.value, depth, seen);
|
|
1858
|
+
} else if (isArray(value)) {
|
|
1859
|
+
for (let i = 0; i < value.length; i++) {
|
|
1860
|
+
traverse(value[i], depth, seen);
|
|
1861
|
+
}
|
|
1862
|
+
} else if (isSet(value) || isMap(value)) {
|
|
1863
|
+
value.forEach((v) => {
|
|
1864
|
+
traverse(v, depth, seen);
|
|
1865
|
+
});
|
|
1866
|
+
} else if (isPlainObject(value)) {
|
|
1867
|
+
for (const key in value) {
|
|
1868
|
+
traverse(value[key], depth, seen);
|
|
1869
|
+
}
|
|
1870
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
1871
|
+
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
1872
|
+
traverse(value[key], depth, seen);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
return value;
|
|
1877
|
+
}
|
|
1878
|
+
function warn(msg, ...args) {
|
|
1879
|
+
pauseTracking();
|
|
1880
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
1881
|
+
console.warn(...warnArgs);
|
|
1882
|
+
resetTracking();
|
|
1883
|
+
}
|
|
1884
|
+
var LifecycleHooks = /* @__PURE__ */ ((LifecycleHooks2) => {
|
|
1885
|
+
LifecycleHooks2["ACTIVATED"] = "a";
|
|
1886
|
+
LifecycleHooks2["DEACTIVATED"] = "da";
|
|
1887
|
+
return LifecycleHooks2;
|
|
1888
|
+
})(LifecycleHooks || {});
|
|
1889
|
+
var ErrorCodes = /* @__PURE__ */ ((ErrorCodes2) => {
|
|
1890
|
+
ErrorCodes2[ErrorCodes2["WATCH_GETTER"] = 0] = "WATCH_GETTER";
|
|
1891
|
+
ErrorCodes2[ErrorCodes2["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
|
|
1892
|
+
ErrorCodes2[ErrorCodes2["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
|
|
1893
|
+
ErrorCodes2[ErrorCodes2["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
|
|
1894
|
+
ErrorCodes2[ErrorCodes2["SCHEDULER"] = 4] = "SCHEDULER";
|
|
1895
|
+
return ErrorCodes2;
|
|
1896
|
+
})(ErrorCodes || {});
|
|
1897
|
+
const ErrorTypeStrings = {
|
|
1898
|
+
[LifecycleHooks.ACTIVATED]: "activated hook",
|
|
1899
|
+
[LifecycleHooks.DEACTIVATED]: "deactivated hook",
|
|
1900
|
+
[
|
|
1901
|
+
0
|
|
1902
|
+
/* WATCH_GETTER */
|
|
1903
|
+
]: "watcher getter",
|
|
1904
|
+
[
|
|
1905
|
+
1
|
|
1906
|
+
/* WATCH_CALLBACK */
|
|
1907
|
+
]: "watcher callback",
|
|
1908
|
+
[
|
|
1909
|
+
2
|
|
1910
|
+
/* WATCH_CLEANUP */
|
|
1911
|
+
]: "watcher cleanup function",
|
|
1912
|
+
[
|
|
1913
|
+
3
|
|
1914
|
+
/* APP_ERROR_HANDLER */
|
|
1915
|
+
]: "app errorHandler",
|
|
1916
|
+
[
|
|
1917
|
+
4
|
|
1918
|
+
/* SCHEDULER */
|
|
1919
|
+
]: "scheduler flush"
|
|
1920
|
+
};
|
|
1921
|
+
function callWithErrorHandling(fn, instance, type, args) {
|
|
1922
|
+
try {
|
|
1923
|
+
return args ? fn(...args) : fn();
|
|
1924
|
+
} catch (err) {
|
|
1925
|
+
handleError(err, instance, type);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
1929
|
+
if (isFunction(fn)) {
|
|
1930
|
+
const res = callWithErrorHandling(fn, instance, type, args);
|
|
1931
|
+
if (res && isPromise(res)) {
|
|
1932
|
+
res.catch((err) => {
|
|
1933
|
+
handleError(err, instance, type);
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
return res;
|
|
1937
|
+
}
|
|
1938
|
+
if (isArray(fn)) {
|
|
1939
|
+
const values = [];
|
|
1940
|
+
for (let i = 0; i < fn.length; i++) {
|
|
1941
|
+
values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
|
1942
|
+
}
|
|
1943
|
+
return values;
|
|
1944
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1945
|
+
warn(
|
|
1946
|
+
`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
function handleError(err, instance, type, throwInDev = true) {
|
|
1951
|
+
const contextVNode = null;
|
|
1952
|
+
logError(err, type, contextVNode, throwInDev);
|
|
1953
|
+
}
|
|
1954
|
+
function logError(err, type, contextVNode, throwInDev = true) {
|
|
1955
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1956
|
+
const info = ErrorTypeStrings[type];
|
|
1957
|
+
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
1958
|
+
if (throwInDev) {
|
|
1959
|
+
throw err;
|
|
1960
|
+
} else {
|
|
1961
|
+
console.error(err);
|
|
1962
|
+
}
|
|
1963
|
+
} else {
|
|
1964
|
+
console.error(err);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
var SchedulerJobFlags = /* @__PURE__ */ ((SchedulerJobFlags2) => {
|
|
1968
|
+
SchedulerJobFlags2[SchedulerJobFlags2["QUEUED"] = 1] = "QUEUED";
|
|
1969
|
+
SchedulerJobFlags2[SchedulerJobFlags2["PRE"] = 2] = "PRE";
|
|
1970
|
+
SchedulerJobFlags2[SchedulerJobFlags2["ALLOW_RECURSE"] = 4] = "ALLOW_RECURSE";
|
|
1971
|
+
SchedulerJobFlags2[SchedulerJobFlags2["DISPOSED"] = 8] = "DISPOSED";
|
|
1972
|
+
return SchedulerJobFlags2;
|
|
1973
|
+
})(SchedulerJobFlags || {});
|
|
1974
|
+
let isFlushing = false;
|
|
1975
|
+
let isFlushPending = false;
|
|
1976
|
+
const queue = [];
|
|
1977
|
+
let flushIndex = 0;
|
|
1978
|
+
const pendingPostFlushCbs = [];
|
|
1979
|
+
let activePostFlushCbs = null;
|
|
1980
|
+
let postFlushIndex = 0;
|
|
1981
|
+
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
1982
|
+
let currentFlushPromise = null;
|
|
1983
|
+
const RECURSION_LIMIT = 100;
|
|
1984
|
+
function nextTick(fn) {
|
|
1985
|
+
const p = currentFlushPromise || resolvedPromise;
|
|
1986
|
+
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
1987
|
+
}
|
|
1988
|
+
function findInsertionIndex(id) {
|
|
1989
|
+
let start = isFlushing ? flushIndex + 1 : 0;
|
|
1990
|
+
let end = queue.length;
|
|
1991
|
+
while (start < end) {
|
|
1992
|
+
const middle = start + end >>> 1;
|
|
1993
|
+
const middleJob = queue[middle];
|
|
1994
|
+
const middleJobId = getId(middleJob);
|
|
1995
|
+
if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
|
|
1996
|
+
start = middle + 1;
|
|
1997
|
+
} else {
|
|
1998
|
+
end = middle;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
return start;
|
|
2002
|
+
}
|
|
2003
|
+
function queueJob(job) {
|
|
2004
|
+
if (!(job.flags & 1)) {
|
|
2005
|
+
const jobId = getId(job);
|
|
2006
|
+
const lastJob = queue[queue.length - 1];
|
|
2007
|
+
if (!lastJob || // fast path when the job id is larger than the tail
|
|
2008
|
+
!(job.flags & 2) && jobId >= getId(lastJob)) {
|
|
2009
|
+
queue.push(job);
|
|
2010
|
+
} else {
|
|
2011
|
+
queue.splice(findInsertionIndex(jobId), 0, job);
|
|
2012
|
+
}
|
|
2013
|
+
job.flags |= 1;
|
|
2014
|
+
queueFlush();
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
function queueFlush() {
|
|
2018
|
+
if (!isFlushing && !isFlushPending) {
|
|
2019
|
+
isFlushPending = true;
|
|
2020
|
+
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
function flushPostFlushCbs(seen) {
|
|
2024
|
+
if (pendingPostFlushCbs.length) {
|
|
2025
|
+
const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
|
2026
|
+
(a, b) => getId(a) - getId(b)
|
|
2027
|
+
);
|
|
2028
|
+
pendingPostFlushCbs.length = 0;
|
|
2029
|
+
if (activePostFlushCbs) {
|
|
2030
|
+
activePostFlushCbs.push(...deduped);
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
activePostFlushCbs = deduped;
|
|
2034
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
2035
|
+
seen = seen || /* @__PURE__ */ new Map();
|
|
2036
|
+
}
|
|
2037
|
+
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
|
2038
|
+
const cb = activePostFlushCbs[postFlushIndex];
|
|
2039
|
+
if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) {
|
|
2040
|
+
continue;
|
|
2041
|
+
}
|
|
2042
|
+
if (cb.flags & 4) {
|
|
2043
|
+
cb.flags &= ~1;
|
|
2044
|
+
}
|
|
2045
|
+
if (!(cb.flags & 8)) cb();
|
|
2046
|
+
cb.flags &= ~1;
|
|
2047
|
+
}
|
|
2048
|
+
activePostFlushCbs = null;
|
|
2049
|
+
postFlushIndex = 0;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
|
|
2053
|
+
function flushJobs(seen) {
|
|
2054
|
+
isFlushPending = false;
|
|
2055
|
+
isFlushing = true;
|
|
2056
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
2057
|
+
seen = seen || /* @__PURE__ */ new Map();
|
|
2058
|
+
}
|
|
2059
|
+
const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
|
|
2060
|
+
try {
|
|
2061
|
+
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
2062
|
+
const job = queue[flushIndex];
|
|
2063
|
+
if (job && !(job.flags & 8)) {
|
|
2064
|
+
if (!!(process.env.NODE_ENV !== "production") && check(job)) {
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
if (job.flags & 4) {
|
|
2068
|
+
job.flags &= ~1;
|
|
2069
|
+
}
|
|
2070
|
+
callWithErrorHandling(
|
|
2071
|
+
job,
|
|
2072
|
+
null,
|
|
2073
|
+
ErrorCodes.SCHEDULER
|
|
2074
|
+
);
|
|
2075
|
+
if (!(job.flags & 4)) {
|
|
2076
|
+
job.flags &= ~1;
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
} finally {
|
|
2081
|
+
for (; flushIndex < queue.length; flushIndex++) {
|
|
2082
|
+
const job = queue[flushIndex];
|
|
2083
|
+
if (job) {
|
|
2084
|
+
job.flags &= ~1;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
flushIndex = 0;
|
|
2088
|
+
queue.length = 0;
|
|
2089
|
+
flushPostFlushCbs(seen);
|
|
2090
|
+
isFlushing = false;
|
|
2091
|
+
currentFlushPromise = null;
|
|
2092
|
+
if (queue.length || pendingPostFlushCbs.length) {
|
|
2093
|
+
flushJobs(seen);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
function checkRecursiveUpdates(seen, fn) {
|
|
2098
|
+
const count = seen.get(fn) || 0;
|
|
2099
|
+
if (count > RECURSION_LIMIT) {
|
|
2100
|
+
handleError(
|
|
2101
|
+
`Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
|
2102
|
+
null,
|
|
2103
|
+
ErrorCodes.APP_ERROR_HANDLER
|
|
2104
|
+
);
|
|
2105
|
+
return true;
|
|
2106
|
+
}
|
|
2107
|
+
seen.set(fn, count + 1);
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2110
|
+
function watchEffect(effect2, options) {
|
|
2111
|
+
return doWatch(effect2, null, options);
|
|
2112
|
+
}
|
|
2113
|
+
function watchSyncEffect(effect2, options) {
|
|
2114
|
+
return doWatch(
|
|
2115
|
+
effect2,
|
|
2116
|
+
null,
|
|
2117
|
+
!!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
|
|
2118
|
+
);
|
|
2119
|
+
}
|
|
2120
|
+
function watch(source, cb, options) {
|
|
2121
|
+
if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
|
|
2122
|
+
warn(
|
|
2123
|
+
`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
return doWatch(source, cb, options);
|
|
2127
|
+
}
|
|
2128
|
+
function doWatch(source, cb, options = EMPTY_OBJ) {
|
|
2129
|
+
const { immediate, deep, flush, once } = options;
|
|
2130
|
+
if (!!(process.env.NODE_ENV !== "production") && !cb) {
|
|
2131
|
+
if (immediate !== void 0) {
|
|
2132
|
+
warn(
|
|
2133
|
+
`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
|
2134
|
+
);
|
|
2135
|
+
}
|
|
2136
|
+
if (deep !== void 0) {
|
|
2137
|
+
warn(
|
|
2138
|
+
`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
if (once !== void 0) {
|
|
2142
|
+
warn(
|
|
2143
|
+
`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
const baseWatchOptions = extend({}, options);
|
|
2148
|
+
if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn;
|
|
2149
|
+
baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, type, args);
|
|
2150
|
+
let isPre = false;
|
|
2151
|
+
if (flush !== "sync") {
|
|
2152
|
+
isPre = true;
|
|
2153
|
+
baseWatchOptions.scheduler = (job, isFirstRun) => {
|
|
2154
|
+
if (isFirstRun) {
|
|
2155
|
+
job();
|
|
2156
|
+
} else {
|
|
2157
|
+
queueJob(job);
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
baseWatchOptions.augmentJob = (job) => {
|
|
2162
|
+
if (cb) {
|
|
2163
|
+
job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
|
|
2164
|
+
}
|
|
2165
|
+
if (isPre) {
|
|
2166
|
+
job.flags |= SchedulerJobFlags.PRE;
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
const watchHandle = watch$1(source, cb, baseWatchOptions);
|
|
2170
|
+
return watchHandle;
|
|
2171
|
+
}
|
|
2172
|
+
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
2173
|
+
exports.EffectFlags = EffectFlags;
|
|
2174
|
+
exports.EffectScope = EffectScope;
|
|
2175
|
+
exports.ITERATE_KEY = ITERATE_KEY;
|
|
2176
|
+
exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY;
|
|
2177
|
+
exports.ReactiveEffect = ReactiveEffect;
|
|
2178
|
+
exports.ReactiveFlags = ReactiveFlags;
|
|
2179
|
+
exports.TrackOpTypes = TrackOpTypes;
|
|
2180
|
+
exports.TriggerOpTypes = TriggerOpTypes;
|
|
2181
|
+
exports.WatchErrorCodes = WatchErrorCodes;
|
|
2182
|
+
exports.computed = computed;
|
|
2183
|
+
exports.customRef = customRef;
|
|
2184
|
+
exports.effect = effect;
|
|
2185
|
+
exports.effectScope = effectScope;
|
|
2186
|
+
exports.enableTracking = enableTracking;
|
|
2187
|
+
exports.getCurrentScope = getCurrentScope;
|
|
2188
|
+
exports.getCurrentWatcher = getCurrentWatcher;
|
|
2189
|
+
exports.isProxy = isProxy;
|
|
2190
|
+
exports.isReactive = isReactive;
|
|
2191
|
+
exports.isReadonly = isReadonly;
|
|
2192
|
+
exports.isRef = isRef;
|
|
2193
|
+
exports.isShallow = isShallow;
|
|
2194
|
+
exports.markRaw = markRaw;
|
|
2195
|
+
exports.nextTick = nextTick;
|
|
2196
|
+
exports.onEffectCleanup = onEffectCleanup;
|
|
2197
|
+
exports.onScopeDispose = onScopeDispose;
|
|
2198
|
+
exports.onWatcherCleanup = onWatcherCleanup;
|
|
2199
|
+
exports.pauseTracking = pauseTracking;
|
|
2200
|
+
exports.proxyRefs = proxyRefs;
|
|
2201
|
+
exports.reactive = reactive;
|
|
2202
|
+
exports.reactiveReadArray = reactiveReadArray;
|
|
2203
|
+
exports.readonly = readonly;
|
|
2204
|
+
exports.ref = ref;
|
|
2205
|
+
exports.resetTracking = resetTracking;
|
|
2206
|
+
exports.shallowReactive = shallowReactive;
|
|
2207
|
+
exports.shallowReadArray = shallowReadArray;
|
|
2208
|
+
exports.shallowReadonly = shallowReadonly;
|
|
2209
|
+
exports.shallowRef = shallowRef;
|
|
2210
|
+
exports.stop = stop;
|
|
2211
|
+
exports.toRaw = toRaw;
|
|
2212
|
+
exports.toReactive = toReactive;
|
|
2213
|
+
exports.toReadonly = toReadonly;
|
|
2214
|
+
exports.toRef = toRef;
|
|
2215
|
+
exports.toRefs = toRefs;
|
|
2216
|
+
exports.toValue = toValue;
|
|
2217
|
+
exports.track = track;
|
|
2218
|
+
exports.traverse = traverse;
|
|
2219
|
+
exports.trigger = trigger;
|
|
2220
|
+
exports.triggerRef = triggerRef;
|
|
2221
|
+
exports.unref = unref;
|
|
2222
|
+
exports.watch = watch;
|
|
2223
|
+
exports.watchEffect = watchEffect;
|
|
2224
|
+
exports.watchSyncEffect = watchSyncEffect;
|