@reactive-vscode/reactivity 0.2.0-beta.1 → 0.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +780 -0
- package/dist/index.js +1703 -0
- package/package.json +11 -11
- package/shim.d.ts +0 -4
- package/src/apiWatch.ts +0 -415
- package/src/enums.ts +0 -4
- package/src/errorHandling.ts +0 -120
- package/src/index.ts +0 -5
- package/src/scheduler.ts +0 -211
- package/src/warning.ts +0 -13
- package/tsconfig.json +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1703 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vue/shared v3.4.27
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
7
|
+
// @__NO_SIDE_EFFECTS__
|
|
8
|
+
function makeMap(str, expectsLowerCase) {
|
|
9
|
+
const set2 = new Set(str.split(","));
|
|
10
|
+
return (val) => set2.has(val);
|
|
11
|
+
}
|
|
12
|
+
const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
13
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
14
|
+
const NOOP = () => {
|
|
15
|
+
};
|
|
16
|
+
const extend = Object.assign;
|
|
17
|
+
const remove = (arr, el) => {
|
|
18
|
+
const i = arr.indexOf(el);
|
|
19
|
+
if (i > -1) {
|
|
20
|
+
arr.splice(i, 1);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
24
|
+
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
25
|
+
const isArray = Array.isArray;
|
|
26
|
+
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
27
|
+
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
28
|
+
const isFunction = (val) => typeof val === "function";
|
|
29
|
+
const isString = (val) => typeof val === "string";
|
|
30
|
+
const isSymbol = (val) => typeof val === "symbol";
|
|
31
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
32
|
+
const isPromise = (val) => {
|
|
33
|
+
return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
34
|
+
};
|
|
35
|
+
const objectToString = Object.prototype.toString;
|
|
36
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
37
|
+
const toRawType = (value) => {
|
|
38
|
+
return toTypeString(value).slice(8, -1);
|
|
39
|
+
};
|
|
40
|
+
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
41
|
+
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
42
|
+
const cacheStringFunction = (fn) => {
|
|
43
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
44
|
+
return (str) => {
|
|
45
|
+
const hit = cache[str];
|
|
46
|
+
return hit || (cache[str] = fn(str));
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const capitalize = cacheStringFunction((str) => {
|
|
50
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
51
|
+
});
|
|
52
|
+
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
53
|
+
const def = (obj, key, value, writable = false) => {
|
|
54
|
+
Object.defineProperty(obj, key, {
|
|
55
|
+
configurable: true,
|
|
56
|
+
enumerable: false,
|
|
57
|
+
writable,
|
|
58
|
+
value
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* @vue/reactivity v3.4.27
|
|
63
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
64
|
+
* @license MIT
|
|
65
|
+
**/
|
|
66
|
+
function warn$1(msg, ...args) {
|
|
67
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
68
|
+
}
|
|
69
|
+
let activeEffectScope;
|
|
70
|
+
class EffectScope {
|
|
71
|
+
constructor(detached = false) {
|
|
72
|
+
this.detached = detached;
|
|
73
|
+
this._active = true;
|
|
74
|
+
this.effects = [];
|
|
75
|
+
this.cleanups = [];
|
|
76
|
+
this.parent = activeEffectScope;
|
|
77
|
+
if (!detached && activeEffectScope) {
|
|
78
|
+
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
79
|
+
this
|
|
80
|
+
) - 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
get active() {
|
|
84
|
+
return this._active;
|
|
85
|
+
}
|
|
86
|
+
run(fn) {
|
|
87
|
+
if (this._active) {
|
|
88
|
+
const currentEffectScope = activeEffectScope;
|
|
89
|
+
try {
|
|
90
|
+
activeEffectScope = this;
|
|
91
|
+
return fn();
|
|
92
|
+
} finally {
|
|
93
|
+
activeEffectScope = currentEffectScope;
|
|
94
|
+
}
|
|
95
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
96
|
+
warn$1(`cannot run an inactive effect scope.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* This should only be called on non-detached scopes
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
on() {
|
|
104
|
+
activeEffectScope = this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* This should only be called on non-detached scopes
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
off() {
|
|
111
|
+
activeEffectScope = this.parent;
|
|
112
|
+
}
|
|
113
|
+
stop(fromParent) {
|
|
114
|
+
if (this._active) {
|
|
115
|
+
let i, l;
|
|
116
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
117
|
+
this.effects[i].stop();
|
|
118
|
+
}
|
|
119
|
+
for (i = 0, l = this.cleanups.length; i < l; i++) {
|
|
120
|
+
this.cleanups[i]();
|
|
121
|
+
}
|
|
122
|
+
if (this.scopes) {
|
|
123
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
124
|
+
this.scopes[i].stop(true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!this.detached && this.parent && !fromParent) {
|
|
128
|
+
const last = this.parent.scopes.pop();
|
|
129
|
+
if (last && last !== this) {
|
|
130
|
+
this.parent.scopes[this.index] = last;
|
|
131
|
+
last.index = this.index;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
this.parent = void 0;
|
|
135
|
+
this._active = false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function effectScope(detached) {
|
|
140
|
+
return new EffectScope(detached);
|
|
141
|
+
}
|
|
142
|
+
function recordEffectScope(effect2, scope = activeEffectScope) {
|
|
143
|
+
if (scope && scope.active) {
|
|
144
|
+
scope.effects.push(effect2);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function getCurrentScope() {
|
|
148
|
+
return activeEffectScope;
|
|
149
|
+
}
|
|
150
|
+
function onScopeDispose(fn) {
|
|
151
|
+
if (activeEffectScope) {
|
|
152
|
+
activeEffectScope.cleanups.push(fn);
|
|
153
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
154
|
+
warn$1(
|
|
155
|
+
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
let activeEffect;
|
|
160
|
+
class ReactiveEffect {
|
|
161
|
+
constructor(fn, trigger2, scheduler, scope) {
|
|
162
|
+
this.fn = fn;
|
|
163
|
+
this.trigger = trigger2;
|
|
164
|
+
this.scheduler = scheduler;
|
|
165
|
+
this.active = true;
|
|
166
|
+
this.deps = [];
|
|
167
|
+
this._dirtyLevel = 4;
|
|
168
|
+
this._trackId = 0;
|
|
169
|
+
this._runnings = 0;
|
|
170
|
+
this._shouldSchedule = false;
|
|
171
|
+
this._depsLength = 0;
|
|
172
|
+
recordEffectScope(this, scope);
|
|
173
|
+
}
|
|
174
|
+
get dirty() {
|
|
175
|
+
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
176
|
+
this._dirtyLevel = 1;
|
|
177
|
+
pauseTracking();
|
|
178
|
+
for (let i = 0; i < this._depsLength; i++) {
|
|
179
|
+
const dep = this.deps[i];
|
|
180
|
+
if (dep.computed) {
|
|
181
|
+
triggerComputed(dep.computed);
|
|
182
|
+
if (this._dirtyLevel >= 4) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (this._dirtyLevel === 1) {
|
|
188
|
+
this._dirtyLevel = 0;
|
|
189
|
+
}
|
|
190
|
+
resetTracking();
|
|
191
|
+
}
|
|
192
|
+
return this._dirtyLevel >= 4;
|
|
193
|
+
}
|
|
194
|
+
set dirty(v) {
|
|
195
|
+
this._dirtyLevel = v ? 4 : 0;
|
|
196
|
+
}
|
|
197
|
+
run() {
|
|
198
|
+
this._dirtyLevel = 0;
|
|
199
|
+
if (!this.active) {
|
|
200
|
+
return this.fn();
|
|
201
|
+
}
|
|
202
|
+
let lastShouldTrack = shouldTrack;
|
|
203
|
+
let lastEffect = activeEffect;
|
|
204
|
+
try {
|
|
205
|
+
shouldTrack = true;
|
|
206
|
+
activeEffect = this;
|
|
207
|
+
this._runnings++;
|
|
208
|
+
preCleanupEffect(this);
|
|
209
|
+
return this.fn();
|
|
210
|
+
} finally {
|
|
211
|
+
postCleanupEffect(this);
|
|
212
|
+
this._runnings--;
|
|
213
|
+
activeEffect = lastEffect;
|
|
214
|
+
shouldTrack = lastShouldTrack;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
stop() {
|
|
218
|
+
if (this.active) {
|
|
219
|
+
preCleanupEffect(this);
|
|
220
|
+
postCleanupEffect(this);
|
|
221
|
+
this.onStop && this.onStop();
|
|
222
|
+
this.active = false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function triggerComputed(computed2) {
|
|
227
|
+
return computed2.value;
|
|
228
|
+
}
|
|
229
|
+
function preCleanupEffect(effect2) {
|
|
230
|
+
effect2._trackId++;
|
|
231
|
+
effect2._depsLength = 0;
|
|
232
|
+
}
|
|
233
|
+
function postCleanupEffect(effect2) {
|
|
234
|
+
if (effect2.deps.length > effect2._depsLength) {
|
|
235
|
+
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
|
236
|
+
cleanupDepEffect(effect2.deps[i], effect2);
|
|
237
|
+
}
|
|
238
|
+
effect2.deps.length = effect2._depsLength;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function cleanupDepEffect(dep, effect2) {
|
|
242
|
+
const trackId = dep.get(effect2);
|
|
243
|
+
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
244
|
+
dep.delete(effect2);
|
|
245
|
+
if (dep.size === 0) {
|
|
246
|
+
dep.cleanup();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function effect(fn, options) {
|
|
251
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
252
|
+
fn = fn.effect.fn;
|
|
253
|
+
}
|
|
254
|
+
const _effect = new ReactiveEffect(fn, NOOP, () => {
|
|
255
|
+
if (_effect.dirty) {
|
|
256
|
+
_effect.run();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
if (options) {
|
|
260
|
+
extend(_effect, options);
|
|
261
|
+
if (options.scope)
|
|
262
|
+
recordEffectScope(_effect, options.scope);
|
|
263
|
+
}
|
|
264
|
+
if (!options || !options.lazy) {
|
|
265
|
+
_effect.run();
|
|
266
|
+
}
|
|
267
|
+
const runner = _effect.run.bind(_effect);
|
|
268
|
+
runner.effect = _effect;
|
|
269
|
+
return runner;
|
|
270
|
+
}
|
|
271
|
+
function stop(runner) {
|
|
272
|
+
runner.effect.stop();
|
|
273
|
+
}
|
|
274
|
+
let shouldTrack = true;
|
|
275
|
+
let pauseScheduleStack = 0;
|
|
276
|
+
const trackStack = [];
|
|
277
|
+
function pauseTracking() {
|
|
278
|
+
trackStack.push(shouldTrack);
|
|
279
|
+
shouldTrack = false;
|
|
280
|
+
}
|
|
281
|
+
function enableTracking() {
|
|
282
|
+
trackStack.push(shouldTrack);
|
|
283
|
+
shouldTrack = true;
|
|
284
|
+
}
|
|
285
|
+
function resetTracking() {
|
|
286
|
+
const last = trackStack.pop();
|
|
287
|
+
shouldTrack = last === void 0 ? true : last;
|
|
288
|
+
}
|
|
289
|
+
function pauseScheduling() {
|
|
290
|
+
pauseScheduleStack++;
|
|
291
|
+
}
|
|
292
|
+
function resetScheduling() {
|
|
293
|
+
pauseScheduleStack--;
|
|
294
|
+
while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
|
295
|
+
queueEffectSchedulers.shift()();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
299
|
+
var _a;
|
|
300
|
+
if (dep.get(effect2) !== effect2._trackId) {
|
|
301
|
+
dep.set(effect2, effect2._trackId);
|
|
302
|
+
const oldDep = effect2.deps[effect2._depsLength];
|
|
303
|
+
if (oldDep !== dep) {
|
|
304
|
+
if (oldDep) {
|
|
305
|
+
cleanupDepEffect(oldDep, effect2);
|
|
306
|
+
}
|
|
307
|
+
effect2.deps[effect2._depsLength++] = dep;
|
|
308
|
+
} else {
|
|
309
|
+
effect2._depsLength++;
|
|
310
|
+
}
|
|
311
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
312
|
+
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const queueEffectSchedulers = [];
|
|
317
|
+
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
318
|
+
var _a;
|
|
319
|
+
pauseScheduling();
|
|
320
|
+
for (const effect2 of dep.keys()) {
|
|
321
|
+
let tracking;
|
|
322
|
+
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
323
|
+
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
|
324
|
+
effect2._dirtyLevel = dirtyLevel;
|
|
325
|
+
}
|
|
326
|
+
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
327
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
328
|
+
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
329
|
+
}
|
|
330
|
+
effect2.trigger();
|
|
331
|
+
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
|
332
|
+
effect2._shouldSchedule = false;
|
|
333
|
+
if (effect2.scheduler) {
|
|
334
|
+
queueEffectSchedulers.push(effect2.scheduler);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
resetScheduling();
|
|
340
|
+
}
|
|
341
|
+
const createDep = (cleanup, computed2) => {
|
|
342
|
+
const dep = /* @__PURE__ */ new Map();
|
|
343
|
+
dep.cleanup = cleanup;
|
|
344
|
+
dep.computed = computed2;
|
|
345
|
+
return dep;
|
|
346
|
+
};
|
|
347
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
348
|
+
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
|
|
349
|
+
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
|
|
350
|
+
function track(target, type, key) {
|
|
351
|
+
if (shouldTrack && activeEffect) {
|
|
352
|
+
let depsMap = targetMap.get(target);
|
|
353
|
+
if (!depsMap) {
|
|
354
|
+
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
355
|
+
}
|
|
356
|
+
let dep = depsMap.get(key);
|
|
357
|
+
if (!dep) {
|
|
358
|
+
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
359
|
+
}
|
|
360
|
+
trackEffect(
|
|
361
|
+
activeEffect,
|
|
362
|
+
dep,
|
|
363
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
364
|
+
target,
|
|
365
|
+
type,
|
|
366
|
+
key
|
|
367
|
+
} : void 0
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
372
|
+
const depsMap = targetMap.get(target);
|
|
373
|
+
if (!depsMap) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
let deps = [];
|
|
377
|
+
if (type === "clear") {
|
|
378
|
+
deps = [...depsMap.values()];
|
|
379
|
+
} else if (key === "length" && isArray(target)) {
|
|
380
|
+
const newLength = Number(newValue);
|
|
381
|
+
depsMap.forEach((dep, key2) => {
|
|
382
|
+
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
|
383
|
+
deps.push(dep);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
} else {
|
|
387
|
+
if (key !== void 0) {
|
|
388
|
+
deps.push(depsMap.get(key));
|
|
389
|
+
}
|
|
390
|
+
switch (type) {
|
|
391
|
+
case "add":
|
|
392
|
+
if (!isArray(target)) {
|
|
393
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
394
|
+
if (isMap(target)) {
|
|
395
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
396
|
+
}
|
|
397
|
+
} else if (isIntegerKey(key)) {
|
|
398
|
+
deps.push(depsMap.get("length"));
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
case "delete":
|
|
402
|
+
if (!isArray(target)) {
|
|
403
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
404
|
+
if (isMap(target)) {
|
|
405
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
case "set":
|
|
410
|
+
if (isMap(target)) {
|
|
411
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
pauseScheduling();
|
|
417
|
+
for (const dep of deps) {
|
|
418
|
+
if (dep) {
|
|
419
|
+
triggerEffects(
|
|
420
|
+
dep,
|
|
421
|
+
4,
|
|
422
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
423
|
+
target,
|
|
424
|
+
type,
|
|
425
|
+
key,
|
|
426
|
+
newValue,
|
|
427
|
+
oldValue,
|
|
428
|
+
oldTarget
|
|
429
|
+
} : void 0
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
resetScheduling();
|
|
434
|
+
}
|
|
435
|
+
function getDepFromReactive(object, key) {
|
|
436
|
+
const depsMap = targetMap.get(object);
|
|
437
|
+
return depsMap && depsMap.get(key);
|
|
438
|
+
}
|
|
439
|
+
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
440
|
+
const builtInSymbols = new Set(
|
|
441
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
442
|
+
);
|
|
443
|
+
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
444
|
+
function createArrayInstrumentations() {
|
|
445
|
+
const instrumentations = {};
|
|
446
|
+
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
447
|
+
instrumentations[key] = function(...args) {
|
|
448
|
+
const arr = toRaw(this);
|
|
449
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
450
|
+
track(arr, "get", i + "");
|
|
451
|
+
}
|
|
452
|
+
const res = arr[key](...args);
|
|
453
|
+
if (res === -1 || res === false) {
|
|
454
|
+
return arr[key](...args.map(toRaw));
|
|
455
|
+
} else {
|
|
456
|
+
return res;
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
});
|
|
460
|
+
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
461
|
+
instrumentations[key] = function(...args) {
|
|
462
|
+
pauseTracking();
|
|
463
|
+
pauseScheduling();
|
|
464
|
+
const res = toRaw(this)[key].apply(this, args);
|
|
465
|
+
resetScheduling();
|
|
466
|
+
resetTracking();
|
|
467
|
+
return res;
|
|
468
|
+
};
|
|
469
|
+
});
|
|
470
|
+
return instrumentations;
|
|
471
|
+
}
|
|
472
|
+
function hasOwnProperty(key) {
|
|
473
|
+
if (!isSymbol(key))
|
|
474
|
+
key = String(key);
|
|
475
|
+
const obj = toRaw(this);
|
|
476
|
+
track(obj, "has", key);
|
|
477
|
+
return obj.hasOwnProperty(key);
|
|
478
|
+
}
|
|
479
|
+
class BaseReactiveHandler {
|
|
480
|
+
constructor(_isReadonly = false, _isShallow = false) {
|
|
481
|
+
this._isReadonly = _isReadonly;
|
|
482
|
+
this._isShallow = _isShallow;
|
|
483
|
+
}
|
|
484
|
+
get(target, key, receiver) {
|
|
485
|
+
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
486
|
+
if (key === "__v_isReactive") {
|
|
487
|
+
return !isReadonly2;
|
|
488
|
+
} else if (key === "__v_isReadonly") {
|
|
489
|
+
return isReadonly2;
|
|
490
|
+
} else if (key === "__v_isShallow") {
|
|
491
|
+
return isShallow2;
|
|
492
|
+
} else if (key === "__v_raw") {
|
|
493
|
+
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
494
|
+
// this means the reciever is a user proxy of the reactive proxy
|
|
495
|
+
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
496
|
+
return target;
|
|
497
|
+
}
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const targetIsArray = isArray(target);
|
|
501
|
+
if (!isReadonly2) {
|
|
502
|
+
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
503
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
504
|
+
}
|
|
505
|
+
if (key === "hasOwnProperty") {
|
|
506
|
+
return hasOwnProperty;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const res = Reflect.get(target, key, receiver);
|
|
510
|
+
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
511
|
+
return res;
|
|
512
|
+
}
|
|
513
|
+
if (!isReadonly2) {
|
|
514
|
+
track(target, "get", key);
|
|
515
|
+
}
|
|
516
|
+
if (isShallow2) {
|
|
517
|
+
return res;
|
|
518
|
+
}
|
|
519
|
+
if (isRef(res)) {
|
|
520
|
+
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
521
|
+
}
|
|
522
|
+
if (isObject(res)) {
|
|
523
|
+
return isReadonly2 ? readonly(res) : reactive(res);
|
|
524
|
+
}
|
|
525
|
+
return res;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
529
|
+
constructor(isShallow2 = false) {
|
|
530
|
+
super(false, isShallow2);
|
|
531
|
+
}
|
|
532
|
+
set(target, key, value, receiver) {
|
|
533
|
+
let oldValue = target[key];
|
|
534
|
+
if (!this._isShallow) {
|
|
535
|
+
const isOldValueReadonly = isReadonly(oldValue);
|
|
536
|
+
if (!isShallow(value) && !isReadonly(value)) {
|
|
537
|
+
oldValue = toRaw(oldValue);
|
|
538
|
+
value = toRaw(value);
|
|
539
|
+
}
|
|
540
|
+
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
541
|
+
if (isOldValueReadonly) {
|
|
542
|
+
return false;
|
|
543
|
+
} else {
|
|
544
|
+
oldValue.value = value;
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
550
|
+
const result = Reflect.set(target, key, value, receiver);
|
|
551
|
+
if (target === toRaw(receiver)) {
|
|
552
|
+
if (!hadKey) {
|
|
553
|
+
trigger(target, "add", key, value);
|
|
554
|
+
} else if (hasChanged(value, oldValue)) {
|
|
555
|
+
trigger(target, "set", key, value, oldValue);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return result;
|
|
559
|
+
}
|
|
560
|
+
deleteProperty(target, key) {
|
|
561
|
+
const hadKey = hasOwn(target, key);
|
|
562
|
+
const oldValue = target[key];
|
|
563
|
+
const result = Reflect.deleteProperty(target, key);
|
|
564
|
+
if (result && hadKey) {
|
|
565
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
has(target, key) {
|
|
570
|
+
const result = Reflect.has(target, key);
|
|
571
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
572
|
+
track(target, "has", key);
|
|
573
|
+
}
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
576
|
+
ownKeys(target) {
|
|
577
|
+
track(
|
|
578
|
+
target,
|
|
579
|
+
"iterate",
|
|
580
|
+
isArray(target) ? "length" : ITERATE_KEY
|
|
581
|
+
);
|
|
582
|
+
return Reflect.ownKeys(target);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
586
|
+
constructor(isShallow2 = false) {
|
|
587
|
+
super(true, isShallow2);
|
|
588
|
+
}
|
|
589
|
+
set(target, key) {
|
|
590
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
591
|
+
warn$1(
|
|
592
|
+
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
593
|
+
target
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
deleteProperty(target, key) {
|
|
599
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
600
|
+
warn$1(
|
|
601
|
+
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
602
|
+
target
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
return true;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
609
|
+
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
610
|
+
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
|
|
611
|
+
true
|
|
612
|
+
);
|
|
613
|
+
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
614
|
+
const toShallow = (value) => value;
|
|
615
|
+
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
616
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
617
|
+
target = target["__v_raw"];
|
|
618
|
+
const rawTarget = toRaw(target);
|
|
619
|
+
const rawKey = toRaw(key);
|
|
620
|
+
if (!isReadonly2) {
|
|
621
|
+
if (hasChanged(key, rawKey)) {
|
|
622
|
+
track(rawTarget, "get", key);
|
|
623
|
+
}
|
|
624
|
+
track(rawTarget, "get", rawKey);
|
|
625
|
+
}
|
|
626
|
+
const { has: has2 } = getProto(rawTarget);
|
|
627
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
628
|
+
if (has2.call(rawTarget, key)) {
|
|
629
|
+
return wrap(target.get(key));
|
|
630
|
+
} else if (has2.call(rawTarget, rawKey)) {
|
|
631
|
+
return wrap(target.get(rawKey));
|
|
632
|
+
} else if (target !== rawTarget) {
|
|
633
|
+
target.get(key);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function has(key, isReadonly2 = false) {
|
|
637
|
+
const target = this["__v_raw"];
|
|
638
|
+
const rawTarget = toRaw(target);
|
|
639
|
+
const rawKey = toRaw(key);
|
|
640
|
+
if (!isReadonly2) {
|
|
641
|
+
if (hasChanged(key, rawKey)) {
|
|
642
|
+
track(rawTarget, "has", key);
|
|
643
|
+
}
|
|
644
|
+
track(rawTarget, "has", rawKey);
|
|
645
|
+
}
|
|
646
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
647
|
+
}
|
|
648
|
+
function size(target, isReadonly2 = false) {
|
|
649
|
+
target = target["__v_raw"];
|
|
650
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
651
|
+
return Reflect.get(target, "size", target);
|
|
652
|
+
}
|
|
653
|
+
function add(value) {
|
|
654
|
+
value = toRaw(value);
|
|
655
|
+
const target = toRaw(this);
|
|
656
|
+
const proto = getProto(target);
|
|
657
|
+
const hadKey = proto.has.call(target, value);
|
|
658
|
+
if (!hadKey) {
|
|
659
|
+
target.add(value);
|
|
660
|
+
trigger(target, "add", value, value);
|
|
661
|
+
}
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
function set(key, value) {
|
|
665
|
+
value = toRaw(value);
|
|
666
|
+
const target = toRaw(this);
|
|
667
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
668
|
+
let hadKey = has2.call(target, key);
|
|
669
|
+
if (!hadKey) {
|
|
670
|
+
key = toRaw(key);
|
|
671
|
+
hadKey = has2.call(target, key);
|
|
672
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
673
|
+
checkIdentityKeys(target, has2, key);
|
|
674
|
+
}
|
|
675
|
+
const oldValue = get2.call(target, key);
|
|
676
|
+
target.set(key, value);
|
|
677
|
+
if (!hadKey) {
|
|
678
|
+
trigger(target, "add", key, value);
|
|
679
|
+
} else if (hasChanged(value, oldValue)) {
|
|
680
|
+
trigger(target, "set", key, value, oldValue);
|
|
681
|
+
}
|
|
682
|
+
return this;
|
|
683
|
+
}
|
|
684
|
+
function deleteEntry(key) {
|
|
685
|
+
const target = toRaw(this);
|
|
686
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
687
|
+
let hadKey = has2.call(target, key);
|
|
688
|
+
if (!hadKey) {
|
|
689
|
+
key = toRaw(key);
|
|
690
|
+
hadKey = has2.call(target, key);
|
|
691
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
692
|
+
checkIdentityKeys(target, has2, key);
|
|
693
|
+
}
|
|
694
|
+
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
695
|
+
const result = target.delete(key);
|
|
696
|
+
if (hadKey) {
|
|
697
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
698
|
+
}
|
|
699
|
+
return result;
|
|
700
|
+
}
|
|
701
|
+
function clear() {
|
|
702
|
+
const target = toRaw(this);
|
|
703
|
+
const hadItems = target.size !== 0;
|
|
704
|
+
const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
705
|
+
const result = target.clear();
|
|
706
|
+
if (hadItems) {
|
|
707
|
+
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
708
|
+
}
|
|
709
|
+
return result;
|
|
710
|
+
}
|
|
711
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
712
|
+
return function forEach(callback, thisArg) {
|
|
713
|
+
const observed = this;
|
|
714
|
+
const target = observed["__v_raw"];
|
|
715
|
+
const rawTarget = toRaw(target);
|
|
716
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
717
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
718
|
+
return target.forEach((value, key) => {
|
|
719
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
724
|
+
return function(...args) {
|
|
725
|
+
const target = this["__v_raw"];
|
|
726
|
+
const rawTarget = toRaw(target);
|
|
727
|
+
const targetIsMap = isMap(rawTarget);
|
|
728
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
729
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
730
|
+
const innerIterator = target[method](...args);
|
|
731
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
732
|
+
!isReadonly2 && track(
|
|
733
|
+
rawTarget,
|
|
734
|
+
"iterate",
|
|
735
|
+
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
736
|
+
);
|
|
737
|
+
return {
|
|
738
|
+
// iterator protocol
|
|
739
|
+
next() {
|
|
740
|
+
const { value, done } = innerIterator.next();
|
|
741
|
+
return done ? { value, done } : {
|
|
742
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
743
|
+
done
|
|
744
|
+
};
|
|
745
|
+
},
|
|
746
|
+
// iterable protocol
|
|
747
|
+
[Symbol.iterator]() {
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function createReadonlyMethod(type) {
|
|
754
|
+
return function(...args) {
|
|
755
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
756
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
757
|
+
warn$1(
|
|
758
|
+
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
759
|
+
toRaw(this)
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function createInstrumentations() {
|
|
766
|
+
const mutableInstrumentations2 = {
|
|
767
|
+
get(key) {
|
|
768
|
+
return get(this, key);
|
|
769
|
+
},
|
|
770
|
+
get size() {
|
|
771
|
+
return size(this);
|
|
772
|
+
},
|
|
773
|
+
has,
|
|
774
|
+
add,
|
|
775
|
+
set,
|
|
776
|
+
delete: deleteEntry,
|
|
777
|
+
clear,
|
|
778
|
+
forEach: createForEach(false, false)
|
|
779
|
+
};
|
|
780
|
+
const shallowInstrumentations2 = {
|
|
781
|
+
get(key) {
|
|
782
|
+
return get(this, key, false, true);
|
|
783
|
+
},
|
|
784
|
+
get size() {
|
|
785
|
+
return size(this);
|
|
786
|
+
},
|
|
787
|
+
has,
|
|
788
|
+
add,
|
|
789
|
+
set,
|
|
790
|
+
delete: deleteEntry,
|
|
791
|
+
clear,
|
|
792
|
+
forEach: createForEach(false, true)
|
|
793
|
+
};
|
|
794
|
+
const readonlyInstrumentations2 = {
|
|
795
|
+
get(key) {
|
|
796
|
+
return get(this, key, true);
|
|
797
|
+
},
|
|
798
|
+
get size() {
|
|
799
|
+
return size(this, true);
|
|
800
|
+
},
|
|
801
|
+
has(key) {
|
|
802
|
+
return has.call(this, key, true);
|
|
803
|
+
},
|
|
804
|
+
add: createReadonlyMethod("add"),
|
|
805
|
+
set: createReadonlyMethod("set"),
|
|
806
|
+
delete: createReadonlyMethod("delete"),
|
|
807
|
+
clear: createReadonlyMethod("clear"),
|
|
808
|
+
forEach: createForEach(true, false)
|
|
809
|
+
};
|
|
810
|
+
const shallowReadonlyInstrumentations2 = {
|
|
811
|
+
get(key) {
|
|
812
|
+
return get(this, key, true, true);
|
|
813
|
+
},
|
|
814
|
+
get size() {
|
|
815
|
+
return size(this, true);
|
|
816
|
+
},
|
|
817
|
+
has(key) {
|
|
818
|
+
return has.call(this, key, true);
|
|
819
|
+
},
|
|
820
|
+
add: createReadonlyMethod("add"),
|
|
821
|
+
set: createReadonlyMethod("set"),
|
|
822
|
+
delete: createReadonlyMethod("delete"),
|
|
823
|
+
clear: createReadonlyMethod("clear"),
|
|
824
|
+
forEach: createForEach(true, true)
|
|
825
|
+
};
|
|
826
|
+
const iteratorMethods = [
|
|
827
|
+
"keys",
|
|
828
|
+
"values",
|
|
829
|
+
"entries",
|
|
830
|
+
Symbol.iterator
|
|
831
|
+
];
|
|
832
|
+
iteratorMethods.forEach((method) => {
|
|
833
|
+
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
|
834
|
+
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
835
|
+
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
836
|
+
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
837
|
+
method,
|
|
838
|
+
true,
|
|
839
|
+
true
|
|
840
|
+
);
|
|
841
|
+
});
|
|
842
|
+
return [
|
|
843
|
+
mutableInstrumentations2,
|
|
844
|
+
readonlyInstrumentations2,
|
|
845
|
+
shallowInstrumentations2,
|
|
846
|
+
shallowReadonlyInstrumentations2
|
|
847
|
+
];
|
|
848
|
+
}
|
|
849
|
+
const [
|
|
850
|
+
mutableInstrumentations,
|
|
851
|
+
readonlyInstrumentations,
|
|
852
|
+
shallowInstrumentations,
|
|
853
|
+
shallowReadonlyInstrumentations
|
|
854
|
+
] = /* @__PURE__ */ createInstrumentations();
|
|
855
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
856
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
857
|
+
return (target, key, receiver) => {
|
|
858
|
+
if (key === "__v_isReactive") {
|
|
859
|
+
return !isReadonly2;
|
|
860
|
+
} else if (key === "__v_isReadonly") {
|
|
861
|
+
return isReadonly2;
|
|
862
|
+
} else if (key === "__v_raw") {
|
|
863
|
+
return target;
|
|
864
|
+
}
|
|
865
|
+
return Reflect.get(
|
|
866
|
+
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
867
|
+
key,
|
|
868
|
+
receiver
|
|
869
|
+
);
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
const mutableCollectionHandlers = {
|
|
873
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
874
|
+
};
|
|
875
|
+
const shallowCollectionHandlers = {
|
|
876
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
877
|
+
};
|
|
878
|
+
const readonlyCollectionHandlers = {
|
|
879
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
880
|
+
};
|
|
881
|
+
const shallowReadonlyCollectionHandlers = {
|
|
882
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
883
|
+
};
|
|
884
|
+
function checkIdentityKeys(target, has2, key) {
|
|
885
|
+
const rawKey = toRaw(key);
|
|
886
|
+
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
887
|
+
const type = toRawType(target);
|
|
888
|
+
warn$1(
|
|
889
|
+
`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.`
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
894
|
+
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
895
|
+
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
896
|
+
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
897
|
+
function targetTypeMap(rawType) {
|
|
898
|
+
switch (rawType) {
|
|
899
|
+
case "Object":
|
|
900
|
+
case "Array":
|
|
901
|
+
return 1;
|
|
902
|
+
case "Map":
|
|
903
|
+
case "Set":
|
|
904
|
+
case "WeakMap":
|
|
905
|
+
case "WeakSet":
|
|
906
|
+
return 2;
|
|
907
|
+
default:
|
|
908
|
+
return 0;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
function getTargetType(value) {
|
|
912
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
913
|
+
}
|
|
914
|
+
function reactive(target) {
|
|
915
|
+
if (isReadonly(target)) {
|
|
916
|
+
return target;
|
|
917
|
+
}
|
|
918
|
+
return createReactiveObject(
|
|
919
|
+
target,
|
|
920
|
+
false,
|
|
921
|
+
mutableHandlers,
|
|
922
|
+
mutableCollectionHandlers,
|
|
923
|
+
reactiveMap
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
function shallowReactive(target) {
|
|
927
|
+
return createReactiveObject(
|
|
928
|
+
target,
|
|
929
|
+
false,
|
|
930
|
+
shallowReactiveHandlers,
|
|
931
|
+
shallowCollectionHandlers,
|
|
932
|
+
shallowReactiveMap
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function readonly(target) {
|
|
936
|
+
return createReactiveObject(
|
|
937
|
+
target,
|
|
938
|
+
true,
|
|
939
|
+
readonlyHandlers,
|
|
940
|
+
readonlyCollectionHandlers,
|
|
941
|
+
readonlyMap
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
function shallowReadonly(target) {
|
|
945
|
+
return createReactiveObject(
|
|
946
|
+
target,
|
|
947
|
+
true,
|
|
948
|
+
shallowReadonlyHandlers,
|
|
949
|
+
shallowReadonlyCollectionHandlers,
|
|
950
|
+
shallowReadonlyMap
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
954
|
+
if (!isObject(target)) {
|
|
955
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
956
|
+
warn$1(`value cannot be made reactive: ${String(target)}`);
|
|
957
|
+
}
|
|
958
|
+
return target;
|
|
959
|
+
}
|
|
960
|
+
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
961
|
+
return target;
|
|
962
|
+
}
|
|
963
|
+
const existingProxy = proxyMap.get(target);
|
|
964
|
+
if (existingProxy) {
|
|
965
|
+
return existingProxy;
|
|
966
|
+
}
|
|
967
|
+
const targetType = getTargetType(target);
|
|
968
|
+
if (targetType === 0) {
|
|
969
|
+
return target;
|
|
970
|
+
}
|
|
971
|
+
const proxy = new Proxy(
|
|
972
|
+
target,
|
|
973
|
+
targetType === 2 ? collectionHandlers : baseHandlers
|
|
974
|
+
);
|
|
975
|
+
proxyMap.set(target, proxy);
|
|
976
|
+
return proxy;
|
|
977
|
+
}
|
|
978
|
+
function isReactive(value) {
|
|
979
|
+
if (isReadonly(value)) {
|
|
980
|
+
return isReactive(value["__v_raw"]);
|
|
981
|
+
}
|
|
982
|
+
return !!(value && value["__v_isReactive"]);
|
|
983
|
+
}
|
|
984
|
+
function isReadonly(value) {
|
|
985
|
+
return !!(value && value["__v_isReadonly"]);
|
|
986
|
+
}
|
|
987
|
+
function isShallow(value) {
|
|
988
|
+
return !!(value && value["__v_isShallow"]);
|
|
989
|
+
}
|
|
990
|
+
function isProxy(value) {
|
|
991
|
+
return value ? !!value["__v_raw"] : false;
|
|
992
|
+
}
|
|
993
|
+
function toRaw(observed) {
|
|
994
|
+
const raw = observed && observed["__v_raw"];
|
|
995
|
+
return raw ? toRaw(raw) : observed;
|
|
996
|
+
}
|
|
997
|
+
function markRaw(value) {
|
|
998
|
+
if (Object.isExtensible(value)) {
|
|
999
|
+
def(value, "__v_skip", true);
|
|
1000
|
+
}
|
|
1001
|
+
return value;
|
|
1002
|
+
}
|
|
1003
|
+
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
1004
|
+
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1005
|
+
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
|
1006
|
+
class ComputedRefImpl {
|
|
1007
|
+
constructor(getter, _setter, isReadonly2, isSSR) {
|
|
1008
|
+
this.getter = getter;
|
|
1009
|
+
this._setter = _setter;
|
|
1010
|
+
this.dep = void 0;
|
|
1011
|
+
this.__v_isRef = true;
|
|
1012
|
+
this["__v_isReadonly"] = false;
|
|
1013
|
+
this.effect = new ReactiveEffect(
|
|
1014
|
+
() => getter(this._value),
|
|
1015
|
+
() => triggerRefValue(
|
|
1016
|
+
this,
|
|
1017
|
+
this.effect._dirtyLevel === 2 ? 2 : 3
|
|
1018
|
+
)
|
|
1019
|
+
);
|
|
1020
|
+
this.effect.computed = this;
|
|
1021
|
+
this.effect.active = this._cacheable = !isSSR;
|
|
1022
|
+
this["__v_isReadonly"] = isReadonly2;
|
|
1023
|
+
}
|
|
1024
|
+
get value() {
|
|
1025
|
+
const self = toRaw(this);
|
|
1026
|
+
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
|
|
1027
|
+
triggerRefValue(self, 4);
|
|
1028
|
+
}
|
|
1029
|
+
trackRefValue(self);
|
|
1030
|
+
if (self.effect._dirtyLevel >= 2) {
|
|
1031
|
+
if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) {
|
|
1032
|
+
warn$1(COMPUTED_SIDE_EFFECT_WARN, `
|
|
1033
|
+
|
|
1034
|
+
getter: `, this.getter);
|
|
1035
|
+
}
|
|
1036
|
+
triggerRefValue(self, 2);
|
|
1037
|
+
}
|
|
1038
|
+
return self._value;
|
|
1039
|
+
}
|
|
1040
|
+
set value(newValue) {
|
|
1041
|
+
this._setter(newValue);
|
|
1042
|
+
}
|
|
1043
|
+
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
|
|
1044
|
+
get _dirty() {
|
|
1045
|
+
return this.effect.dirty;
|
|
1046
|
+
}
|
|
1047
|
+
set _dirty(v) {
|
|
1048
|
+
this.effect.dirty = v;
|
|
1049
|
+
}
|
|
1050
|
+
// #endregion
|
|
1051
|
+
}
|
|
1052
|
+
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1053
|
+
let getter;
|
|
1054
|
+
let setter;
|
|
1055
|
+
const onlyGetter = isFunction(getterOrOptions);
|
|
1056
|
+
if (onlyGetter) {
|
|
1057
|
+
getter = getterOrOptions;
|
|
1058
|
+
setter = !!(process.env.NODE_ENV !== "production") ? () => {
|
|
1059
|
+
warn$1("Write operation failed: computed value is readonly");
|
|
1060
|
+
} : NOOP;
|
|
1061
|
+
} else {
|
|
1062
|
+
getter = getterOrOptions.get;
|
|
1063
|
+
setter = getterOrOptions.set;
|
|
1064
|
+
}
|
|
1065
|
+
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1066
|
+
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
|
|
1067
|
+
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1068
|
+
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1069
|
+
}
|
|
1070
|
+
return cRef;
|
|
1071
|
+
}
|
|
1072
|
+
function trackRefValue(ref2) {
|
|
1073
|
+
var _a;
|
|
1074
|
+
if (shouldTrack && activeEffect) {
|
|
1075
|
+
ref2 = toRaw(ref2);
|
|
1076
|
+
trackEffect(
|
|
1077
|
+
activeEffect,
|
|
1078
|
+
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
|
1079
|
+
() => ref2.dep = void 0,
|
|
1080
|
+
ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
|
1081
|
+
),
|
|
1082
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
1083
|
+
target: ref2,
|
|
1084
|
+
type: "get",
|
|
1085
|
+
key: "value"
|
|
1086
|
+
} : void 0
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
|
1091
|
+
ref2 = toRaw(ref2);
|
|
1092
|
+
const dep = ref2.dep;
|
|
1093
|
+
if (dep) {
|
|
1094
|
+
triggerEffects(
|
|
1095
|
+
dep,
|
|
1096
|
+
dirtyLevel,
|
|
1097
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
1098
|
+
target: ref2,
|
|
1099
|
+
type: "set",
|
|
1100
|
+
key: "value",
|
|
1101
|
+
newValue: newVal
|
|
1102
|
+
} : void 0
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function isRef(r) {
|
|
1107
|
+
return !!(r && r.__v_isRef === true);
|
|
1108
|
+
}
|
|
1109
|
+
function ref(value) {
|
|
1110
|
+
return createRef(value, false);
|
|
1111
|
+
}
|
|
1112
|
+
function shallowRef(value) {
|
|
1113
|
+
return createRef(value, true);
|
|
1114
|
+
}
|
|
1115
|
+
function createRef(rawValue, shallow) {
|
|
1116
|
+
if (isRef(rawValue)) {
|
|
1117
|
+
return rawValue;
|
|
1118
|
+
}
|
|
1119
|
+
return new RefImpl(rawValue, shallow);
|
|
1120
|
+
}
|
|
1121
|
+
class RefImpl {
|
|
1122
|
+
constructor(value, __v_isShallow) {
|
|
1123
|
+
this.__v_isShallow = __v_isShallow;
|
|
1124
|
+
this.dep = void 0;
|
|
1125
|
+
this.__v_isRef = true;
|
|
1126
|
+
this._rawValue = __v_isShallow ? value : toRaw(value);
|
|
1127
|
+
this._value = __v_isShallow ? value : toReactive(value);
|
|
1128
|
+
}
|
|
1129
|
+
get value() {
|
|
1130
|
+
trackRefValue(this);
|
|
1131
|
+
return this._value;
|
|
1132
|
+
}
|
|
1133
|
+
set value(newVal) {
|
|
1134
|
+
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
|
1135
|
+
newVal = useDirectValue ? newVal : toRaw(newVal);
|
|
1136
|
+
if (hasChanged(newVal, this._rawValue)) {
|
|
1137
|
+
this._rawValue = newVal;
|
|
1138
|
+
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1139
|
+
triggerRefValue(this, 4, newVal);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
function triggerRef(ref2) {
|
|
1144
|
+
triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
|
|
1145
|
+
}
|
|
1146
|
+
function unref(ref2) {
|
|
1147
|
+
return isRef(ref2) ? ref2.value : ref2;
|
|
1148
|
+
}
|
|
1149
|
+
function toValue(source) {
|
|
1150
|
+
return isFunction(source) ? source() : unref(source);
|
|
1151
|
+
}
|
|
1152
|
+
const shallowUnwrapHandlers = {
|
|
1153
|
+
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1154
|
+
set: (target, key, value, receiver) => {
|
|
1155
|
+
const oldValue = target[key];
|
|
1156
|
+
if (isRef(oldValue) && !isRef(value)) {
|
|
1157
|
+
oldValue.value = value;
|
|
1158
|
+
return true;
|
|
1159
|
+
} else {
|
|
1160
|
+
return Reflect.set(target, key, value, receiver);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
function proxyRefs(objectWithRefs) {
|
|
1165
|
+
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1166
|
+
}
|
|
1167
|
+
class CustomRefImpl {
|
|
1168
|
+
constructor(factory) {
|
|
1169
|
+
this.dep = void 0;
|
|
1170
|
+
this.__v_isRef = true;
|
|
1171
|
+
const { get: get2, set: set2 } = factory(
|
|
1172
|
+
() => trackRefValue(this),
|
|
1173
|
+
() => triggerRefValue(this)
|
|
1174
|
+
);
|
|
1175
|
+
this._get = get2;
|
|
1176
|
+
this._set = set2;
|
|
1177
|
+
}
|
|
1178
|
+
get value() {
|
|
1179
|
+
return this._get();
|
|
1180
|
+
}
|
|
1181
|
+
set value(newVal) {
|
|
1182
|
+
this._set(newVal);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
function customRef(factory) {
|
|
1186
|
+
return new CustomRefImpl(factory);
|
|
1187
|
+
}
|
|
1188
|
+
function toRefs(object) {
|
|
1189
|
+
if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
|
|
1190
|
+
warn$1(`toRefs() expects a reactive object but received a plain one.`);
|
|
1191
|
+
}
|
|
1192
|
+
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1193
|
+
for (const key in object) {
|
|
1194
|
+
ret[key] = propertyToRef(object, key);
|
|
1195
|
+
}
|
|
1196
|
+
return ret;
|
|
1197
|
+
}
|
|
1198
|
+
class ObjectRefImpl {
|
|
1199
|
+
constructor(_object, _key, _defaultValue) {
|
|
1200
|
+
this._object = _object;
|
|
1201
|
+
this._key = _key;
|
|
1202
|
+
this._defaultValue = _defaultValue;
|
|
1203
|
+
this.__v_isRef = true;
|
|
1204
|
+
}
|
|
1205
|
+
get value() {
|
|
1206
|
+
const val = this._object[this._key];
|
|
1207
|
+
return val === void 0 ? this._defaultValue : val;
|
|
1208
|
+
}
|
|
1209
|
+
set value(newVal) {
|
|
1210
|
+
this._object[this._key] = newVal;
|
|
1211
|
+
}
|
|
1212
|
+
get dep() {
|
|
1213
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
class GetterRefImpl {
|
|
1217
|
+
constructor(_getter) {
|
|
1218
|
+
this._getter = _getter;
|
|
1219
|
+
this.__v_isRef = true;
|
|
1220
|
+
this.__v_isReadonly = true;
|
|
1221
|
+
}
|
|
1222
|
+
get value() {
|
|
1223
|
+
return this._getter();
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
function toRef(source, key, defaultValue) {
|
|
1227
|
+
if (isRef(source)) {
|
|
1228
|
+
return source;
|
|
1229
|
+
} else if (isFunction(source)) {
|
|
1230
|
+
return new GetterRefImpl(source);
|
|
1231
|
+
} else if (isObject(source) && arguments.length > 1) {
|
|
1232
|
+
return propertyToRef(source, key, defaultValue);
|
|
1233
|
+
} else {
|
|
1234
|
+
return ref(source);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1238
|
+
const val = source[key];
|
|
1239
|
+
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1240
|
+
}
|
|
1241
|
+
const deferredComputed = computed;
|
|
1242
|
+
const TrackOpTypes = {
|
|
1243
|
+
"GET": "get",
|
|
1244
|
+
"HAS": "has",
|
|
1245
|
+
"ITERATE": "iterate"
|
|
1246
|
+
};
|
|
1247
|
+
const TriggerOpTypes = {
|
|
1248
|
+
"SET": "set",
|
|
1249
|
+
"ADD": "add",
|
|
1250
|
+
"DELETE": "delete",
|
|
1251
|
+
"CLEAR": "clear"
|
|
1252
|
+
};
|
|
1253
|
+
const ReactiveFlags = {
|
|
1254
|
+
"SKIP": "__v_skip",
|
|
1255
|
+
"IS_REACTIVE": "__v_isReactive",
|
|
1256
|
+
"IS_READONLY": "__v_isReadonly",
|
|
1257
|
+
"IS_SHALLOW": "__v_isShallow",
|
|
1258
|
+
"RAW": "__v_raw"
|
|
1259
|
+
};
|
|
1260
|
+
function warn(msg, ...args) {
|
|
1261
|
+
pauseTracking();
|
|
1262
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
1263
|
+
console.warn(...warnArgs);
|
|
1264
|
+
resetTracking();
|
|
1265
|
+
}
|
|
1266
|
+
var LifecycleHooks = /* @__PURE__ */ ((LifecycleHooks2) => {
|
|
1267
|
+
LifecycleHooks2["ACTIVATED"] = "a";
|
|
1268
|
+
LifecycleHooks2["DEACTIVATED"] = "da";
|
|
1269
|
+
return LifecycleHooks2;
|
|
1270
|
+
})(LifecycleHooks || {});
|
|
1271
|
+
var ErrorCodes = /* @__PURE__ */ ((ErrorCodes2) => {
|
|
1272
|
+
ErrorCodes2[ErrorCodes2["WATCH_GETTER"] = 0] = "WATCH_GETTER";
|
|
1273
|
+
ErrorCodes2[ErrorCodes2["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
|
|
1274
|
+
ErrorCodes2[ErrorCodes2["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
|
|
1275
|
+
ErrorCodes2[ErrorCodes2["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
|
|
1276
|
+
ErrorCodes2[ErrorCodes2["SCHEDULER"] = 4] = "SCHEDULER";
|
|
1277
|
+
return ErrorCodes2;
|
|
1278
|
+
})(ErrorCodes || {});
|
|
1279
|
+
const ErrorTypeStrings = {
|
|
1280
|
+
[LifecycleHooks.ACTIVATED]: "activated hook",
|
|
1281
|
+
[LifecycleHooks.DEACTIVATED]: "deactivated hook",
|
|
1282
|
+
[
|
|
1283
|
+
0
|
|
1284
|
+
/* WATCH_GETTER */
|
|
1285
|
+
]: "watcher getter",
|
|
1286
|
+
[
|
|
1287
|
+
1
|
|
1288
|
+
/* WATCH_CALLBACK */
|
|
1289
|
+
]: "watcher callback",
|
|
1290
|
+
[
|
|
1291
|
+
2
|
|
1292
|
+
/* WATCH_CLEANUP */
|
|
1293
|
+
]: "watcher cleanup function",
|
|
1294
|
+
[
|
|
1295
|
+
3
|
|
1296
|
+
/* APP_ERROR_HANDLER */
|
|
1297
|
+
]: "app errorHandler",
|
|
1298
|
+
[
|
|
1299
|
+
4
|
|
1300
|
+
/* SCHEDULER */
|
|
1301
|
+
]: "scheduler flush"
|
|
1302
|
+
};
|
|
1303
|
+
function callWithErrorHandling(fn, instance, type, args) {
|
|
1304
|
+
try {
|
|
1305
|
+
return args ? fn(...args) : fn();
|
|
1306
|
+
} catch (err) {
|
|
1307
|
+
handleError(err, instance, type);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
1311
|
+
if (isFunction(fn)) {
|
|
1312
|
+
const res = callWithErrorHandling(fn, instance, type, args);
|
|
1313
|
+
if (res && isPromise(res)) {
|
|
1314
|
+
res.catch((err) => {
|
|
1315
|
+
handleError(err, instance, type);
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
return res;
|
|
1319
|
+
}
|
|
1320
|
+
if (isArray(fn)) {
|
|
1321
|
+
const values = [];
|
|
1322
|
+
for (let i = 0; i < fn.length; i++) {
|
|
1323
|
+
values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
|
1324
|
+
}
|
|
1325
|
+
return values;
|
|
1326
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1327
|
+
warn(
|
|
1328
|
+
`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function handleError(err, instance, type, throwInDev = true) {
|
|
1333
|
+
const contextVNode = null;
|
|
1334
|
+
logError(err, type, contextVNode, throwInDev);
|
|
1335
|
+
}
|
|
1336
|
+
function logError(err, type, contextVNode, throwInDev = true) {
|
|
1337
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1338
|
+
const info = ErrorTypeStrings[type];
|
|
1339
|
+
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
1340
|
+
if (throwInDev) {
|
|
1341
|
+
throw err;
|
|
1342
|
+
} else {
|
|
1343
|
+
console.error(err);
|
|
1344
|
+
}
|
|
1345
|
+
} else {
|
|
1346
|
+
console.error(err);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
let isFlushing = false;
|
|
1350
|
+
let isFlushPending = false;
|
|
1351
|
+
const queue = [];
|
|
1352
|
+
let flushIndex = 0;
|
|
1353
|
+
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
1354
|
+
let currentFlushPromise = null;
|
|
1355
|
+
const RECURSION_LIMIT = 100;
|
|
1356
|
+
function nextTick(fn) {
|
|
1357
|
+
const p = currentFlushPromise || resolvedPromise;
|
|
1358
|
+
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
1359
|
+
}
|
|
1360
|
+
function findInsertionIndex(id) {
|
|
1361
|
+
let start = flushIndex + 1;
|
|
1362
|
+
let end = queue.length;
|
|
1363
|
+
while (start < end) {
|
|
1364
|
+
const middle = start + end >>> 1;
|
|
1365
|
+
const middleJob = queue[middle];
|
|
1366
|
+
const middleJobId = getId(middleJob);
|
|
1367
|
+
if (middleJobId < id || middleJobId === id && middleJob.pre) {
|
|
1368
|
+
start = middle + 1;
|
|
1369
|
+
} else {
|
|
1370
|
+
end = middle;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return start;
|
|
1374
|
+
}
|
|
1375
|
+
function queueJob(job) {
|
|
1376
|
+
if (!queue.length || !queue.includes(
|
|
1377
|
+
job,
|
|
1378
|
+
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
|
1379
|
+
)) {
|
|
1380
|
+
if (job.id == null) {
|
|
1381
|
+
queue.push(job);
|
|
1382
|
+
} else {
|
|
1383
|
+
queue.splice(findInsertionIndex(job.id), 0, job);
|
|
1384
|
+
}
|
|
1385
|
+
queueFlush();
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function queueFlush() {
|
|
1389
|
+
if (!isFlushing && !isFlushPending) {
|
|
1390
|
+
isFlushPending = true;
|
|
1391
|
+
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
const getId = (job) => job.id == null ? Infinity : job.id;
|
|
1395
|
+
const comparator = (a, b) => {
|
|
1396
|
+
const diff = getId(a) - getId(b);
|
|
1397
|
+
if (diff === 0) {
|
|
1398
|
+
if (a.pre && !b.pre)
|
|
1399
|
+
return -1;
|
|
1400
|
+
if (b.pre && !a.pre)
|
|
1401
|
+
return 1;
|
|
1402
|
+
}
|
|
1403
|
+
return diff;
|
|
1404
|
+
};
|
|
1405
|
+
function flushJobs(seen) {
|
|
1406
|
+
isFlushPending = false;
|
|
1407
|
+
isFlushing = true;
|
|
1408
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1409
|
+
seen = seen || /* @__PURE__ */ new Map();
|
|
1410
|
+
}
|
|
1411
|
+
queue.sort(comparator);
|
|
1412
|
+
const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
|
|
1413
|
+
try {
|
|
1414
|
+
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
1415
|
+
const job = queue[flushIndex];
|
|
1416
|
+
if (job && job.active !== false) {
|
|
1417
|
+
if (!!(process.env.NODE_ENV !== "production") && check(job)) {
|
|
1418
|
+
continue;
|
|
1419
|
+
}
|
|
1420
|
+
callWithErrorHandling(job, null, ErrorCodes.SCHEDULER);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
} finally {
|
|
1424
|
+
flushIndex = 0;
|
|
1425
|
+
queue.length = 0;
|
|
1426
|
+
isFlushing = false;
|
|
1427
|
+
currentFlushPromise = null;
|
|
1428
|
+
if (queue.length) {
|
|
1429
|
+
flushJobs(seen);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
function checkRecursiveUpdates(seen, fn) {
|
|
1434
|
+
if (!seen.has(fn)) {
|
|
1435
|
+
seen.set(fn, 1);
|
|
1436
|
+
} else {
|
|
1437
|
+
const count = seen.get(fn);
|
|
1438
|
+
if (count > RECURSION_LIMIT) {
|
|
1439
|
+
handleError(
|
|
1440
|
+
`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.`,
|
|
1441
|
+
null,
|
|
1442
|
+
ErrorCodes.APP_ERROR_HANDLER
|
|
1443
|
+
);
|
|
1444
|
+
return true;
|
|
1445
|
+
} else {
|
|
1446
|
+
seen.set(fn, count + 1);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function watchEffect(effect2, options) {
|
|
1451
|
+
return doWatch(effect2, null, options);
|
|
1452
|
+
}
|
|
1453
|
+
function watchSyncEffect(effect2, options) {
|
|
1454
|
+
return doWatch(
|
|
1455
|
+
effect2,
|
|
1456
|
+
null,
|
|
1457
|
+
!!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
const INITIAL_WATCHER_VALUE = {};
|
|
1461
|
+
function watch(source, cb, options) {
|
|
1462
|
+
if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
|
|
1463
|
+
warn(
|
|
1464
|
+
`\`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.`
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
return doWatch(source, cb, options);
|
|
1468
|
+
}
|
|
1469
|
+
function doWatch(source, cb, {
|
|
1470
|
+
immediate,
|
|
1471
|
+
deep,
|
|
1472
|
+
flush,
|
|
1473
|
+
once,
|
|
1474
|
+
onTrack,
|
|
1475
|
+
onTrigger
|
|
1476
|
+
} = EMPTY_OBJ) {
|
|
1477
|
+
if (cb && once) {
|
|
1478
|
+
const _cb = cb;
|
|
1479
|
+
cb = (...args) => {
|
|
1480
|
+
_cb(...args);
|
|
1481
|
+
unwatch();
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
if (!!(process.env.NODE_ENV !== "production") && deep !== void 0 && typeof deep === "number") {
|
|
1485
|
+
warn(
|
|
1486
|
+
`watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
if (!!(process.env.NODE_ENV !== "production") && !cb) {
|
|
1490
|
+
if (immediate !== void 0) {
|
|
1491
|
+
warn(
|
|
1492
|
+
`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
if (deep !== void 0) {
|
|
1496
|
+
warn(
|
|
1497
|
+
`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1498
|
+
);
|
|
1499
|
+
}
|
|
1500
|
+
if (once !== void 0) {
|
|
1501
|
+
warn(
|
|
1502
|
+
`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
const warnInvalidSource = (s) => {
|
|
1507
|
+
warn(
|
|
1508
|
+
`Invalid watch source: `,
|
|
1509
|
+
s,
|
|
1510
|
+
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
1511
|
+
);
|
|
1512
|
+
};
|
|
1513
|
+
const instance = null;
|
|
1514
|
+
const reactiveGetter = (source2) => deep === true ? source2 : (
|
|
1515
|
+
// for deep: false, only traverse root-level properties
|
|
1516
|
+
traverse(source2, deep === false ? 1 : void 0)
|
|
1517
|
+
);
|
|
1518
|
+
let getter;
|
|
1519
|
+
let forceTrigger = false;
|
|
1520
|
+
let isMultiSource = false;
|
|
1521
|
+
if (isRef(source)) {
|
|
1522
|
+
getter = () => source.value;
|
|
1523
|
+
forceTrigger = isShallow(source);
|
|
1524
|
+
} else if (isReactive(source)) {
|
|
1525
|
+
getter = () => reactiveGetter(source);
|
|
1526
|
+
forceTrigger = true;
|
|
1527
|
+
} else if (isArray(source)) {
|
|
1528
|
+
isMultiSource = true;
|
|
1529
|
+
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1530
|
+
getter = () => source.map((s) => {
|
|
1531
|
+
if (isRef(s)) {
|
|
1532
|
+
return s.value;
|
|
1533
|
+
} else if (isReactive(s)) {
|
|
1534
|
+
return reactiveGetter(s);
|
|
1535
|
+
} else if (isFunction(s)) {
|
|
1536
|
+
return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER);
|
|
1537
|
+
} else {
|
|
1538
|
+
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
} else if (isFunction(source)) {
|
|
1542
|
+
if (cb) {
|
|
1543
|
+
getter = () => callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER);
|
|
1544
|
+
} else {
|
|
1545
|
+
getter = () => {
|
|
1546
|
+
if (cleanup) {
|
|
1547
|
+
cleanup();
|
|
1548
|
+
}
|
|
1549
|
+
return callWithAsyncErrorHandling(
|
|
1550
|
+
source,
|
|
1551
|
+
instance,
|
|
1552
|
+
ErrorCodes.WATCH_CALLBACK,
|
|
1553
|
+
[onCleanup]
|
|
1554
|
+
);
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
} else {
|
|
1558
|
+
getter = NOOP;
|
|
1559
|
+
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
|
|
1560
|
+
}
|
|
1561
|
+
if (cb && deep) {
|
|
1562
|
+
const baseGetter = getter;
|
|
1563
|
+
getter = () => traverse(baseGetter());
|
|
1564
|
+
}
|
|
1565
|
+
let cleanup;
|
|
1566
|
+
let onCleanup = (fn) => {
|
|
1567
|
+
cleanup = effect2.onStop = () => {
|
|
1568
|
+
callWithErrorHandling(fn, instance, ErrorCodes.WATCH_CLEANUP);
|
|
1569
|
+
cleanup = effect2.onStop = void 0;
|
|
1570
|
+
};
|
|
1571
|
+
};
|
|
1572
|
+
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1573
|
+
const job = () => {
|
|
1574
|
+
if (!effect2.active || !effect2.dirty) {
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
if (cb) {
|
|
1578
|
+
const newValue = effect2.run();
|
|
1579
|
+
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1580
|
+
if (cleanup) {
|
|
1581
|
+
cleanup();
|
|
1582
|
+
}
|
|
1583
|
+
callWithAsyncErrorHandling(cb, instance, ErrorCodes.WATCH_CALLBACK, [
|
|
1584
|
+
newValue,
|
|
1585
|
+
// pass undefined as the old value when it's changed for the first time
|
|
1586
|
+
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1587
|
+
onCleanup
|
|
1588
|
+
]);
|
|
1589
|
+
oldValue = newValue;
|
|
1590
|
+
}
|
|
1591
|
+
} else {
|
|
1592
|
+
effect2.run();
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
job.allowRecurse = !!cb;
|
|
1596
|
+
let scheduler;
|
|
1597
|
+
if (flush === "sync") {
|
|
1598
|
+
scheduler = job;
|
|
1599
|
+
} else {
|
|
1600
|
+
job.pre = true;
|
|
1601
|
+
scheduler = () => queueJob(job);
|
|
1602
|
+
}
|
|
1603
|
+
const effect2 = new ReactiveEffect(getter, NOOP, scheduler);
|
|
1604
|
+
const scope = getCurrentScope();
|
|
1605
|
+
const unwatch = () => {
|
|
1606
|
+
effect2.stop();
|
|
1607
|
+
if (scope) {
|
|
1608
|
+
remove(scope.effects, effect2);
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1612
|
+
effect2.onTrack = onTrack;
|
|
1613
|
+
effect2.onTrigger = onTrigger;
|
|
1614
|
+
}
|
|
1615
|
+
if (cb) {
|
|
1616
|
+
if (immediate) {
|
|
1617
|
+
job();
|
|
1618
|
+
} else {
|
|
1619
|
+
oldValue = effect2.run();
|
|
1620
|
+
}
|
|
1621
|
+
} else {
|
|
1622
|
+
effect2.run();
|
|
1623
|
+
}
|
|
1624
|
+
return unwatch;
|
|
1625
|
+
}
|
|
1626
|
+
function traverse(value, depth = Infinity, seen) {
|
|
1627
|
+
if (depth <= 0 || !isObject(value) || value[ReactiveFlags.SKIP]) {
|
|
1628
|
+
return value;
|
|
1629
|
+
}
|
|
1630
|
+
seen = seen || /* @__PURE__ */ new Set();
|
|
1631
|
+
if (seen.has(value)) {
|
|
1632
|
+
return value;
|
|
1633
|
+
}
|
|
1634
|
+
seen.add(value);
|
|
1635
|
+
depth--;
|
|
1636
|
+
if (isRef(value)) {
|
|
1637
|
+
traverse(value.value, depth, seen);
|
|
1638
|
+
} else if (isArray(value)) {
|
|
1639
|
+
for (let i = 0; i < value.length; i++) {
|
|
1640
|
+
traverse(value[i], depth, seen);
|
|
1641
|
+
}
|
|
1642
|
+
} else if (isSet(value) || isMap(value)) {
|
|
1643
|
+
value.forEach((v) => {
|
|
1644
|
+
traverse(v, depth, seen);
|
|
1645
|
+
});
|
|
1646
|
+
} else if (isPlainObject(value)) {
|
|
1647
|
+
for (const key in value) {
|
|
1648
|
+
traverse(value[key], depth, seen);
|
|
1649
|
+
}
|
|
1650
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
1651
|
+
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
1652
|
+
traverse(value[key], depth, seen);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
return value;
|
|
1657
|
+
}
|
|
1658
|
+
export {
|
|
1659
|
+
EffectScope,
|
|
1660
|
+
ITERATE_KEY,
|
|
1661
|
+
ReactiveEffect,
|
|
1662
|
+
ReactiveFlags,
|
|
1663
|
+
TrackOpTypes,
|
|
1664
|
+
TriggerOpTypes,
|
|
1665
|
+
computed,
|
|
1666
|
+
customRef,
|
|
1667
|
+
deferredComputed,
|
|
1668
|
+
effect,
|
|
1669
|
+
effectScope,
|
|
1670
|
+
enableTracking,
|
|
1671
|
+
getCurrentScope,
|
|
1672
|
+
isProxy,
|
|
1673
|
+
isReactive,
|
|
1674
|
+
isReadonly,
|
|
1675
|
+
isRef,
|
|
1676
|
+
isShallow,
|
|
1677
|
+
markRaw,
|
|
1678
|
+
nextTick,
|
|
1679
|
+
onScopeDispose,
|
|
1680
|
+
pauseScheduling,
|
|
1681
|
+
pauseTracking,
|
|
1682
|
+
proxyRefs,
|
|
1683
|
+
reactive,
|
|
1684
|
+
readonly,
|
|
1685
|
+
ref,
|
|
1686
|
+
resetScheduling,
|
|
1687
|
+
resetTracking,
|
|
1688
|
+
shallowReactive,
|
|
1689
|
+
shallowReadonly,
|
|
1690
|
+
shallowRef,
|
|
1691
|
+
stop,
|
|
1692
|
+
toRaw,
|
|
1693
|
+
toRef,
|
|
1694
|
+
toRefs,
|
|
1695
|
+
toValue,
|
|
1696
|
+
track,
|
|
1697
|
+
trigger,
|
|
1698
|
+
triggerRef,
|
|
1699
|
+
unref,
|
|
1700
|
+
watch,
|
|
1701
|
+
watchEffect,
|
|
1702
|
+
watchSyncEffect
|
|
1703
|
+
};
|