@vue/reactivity 3.2.47 → 3.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactivity.cjs.js +1005 -1060
- package/dist/reactivity.cjs.prod.js +928 -985
- package/dist/reactivity.d.ts +314 -351
- package/dist/reactivity.esm-browser.js +1031 -1096
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +1015 -1075
- package/dist/reactivity.global.js +1031 -1098
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -1,1279 +1,1219 @@
|
|
|
1
1
|
import { extend, isArray, isMap, isIntegerKey, hasOwn, isSymbol, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
|
|
2
2
|
|
|
3
3
|
function warn(msg, ...args) {
|
|
4
|
-
|
|
4
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
let activeEffectScope;
|
|
8
8
|
class EffectScope {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
this._active = true;
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
this.effects = [];
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
this.cleanups = [];
|
|
23
|
-
this.parent = activeEffectScope;
|
|
24
|
-
if (!detached && activeEffectScope) {
|
|
25
|
-
this.index =
|
|
26
|
-
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
get active() {
|
|
30
|
-
return this._active;
|
|
31
|
-
}
|
|
32
|
-
run(fn) {
|
|
33
|
-
if (this._active) {
|
|
34
|
-
const currentEffectScope = activeEffectScope;
|
|
35
|
-
try {
|
|
36
|
-
activeEffectScope = this;
|
|
37
|
-
return fn();
|
|
38
|
-
}
|
|
39
|
-
finally {
|
|
40
|
-
activeEffectScope = currentEffectScope;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if ((process.env.NODE_ENV !== 'production')) {
|
|
44
|
-
warn(`cannot run an inactive effect scope.`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
9
|
+
constructor(detached = false) {
|
|
10
|
+
this.detached = detached;
|
|
47
11
|
/**
|
|
48
|
-
* This should only be called on non-detached scopes
|
|
49
12
|
* @internal
|
|
50
13
|
*/
|
|
51
|
-
|
|
52
|
-
activeEffectScope = this;
|
|
53
|
-
}
|
|
14
|
+
this._active = true;
|
|
54
15
|
/**
|
|
55
|
-
* This should only be called on non-detached scopes
|
|
56
16
|
* @internal
|
|
57
17
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
18
|
+
this.effects = [];
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
this.cleanups = [];
|
|
23
|
+
this.parent = activeEffectScope;
|
|
24
|
+
if (!detached && activeEffectScope) {
|
|
25
|
+
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
26
|
+
this
|
|
27
|
+
) - 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
get active() {
|
|
31
|
+
return this._active;
|
|
32
|
+
}
|
|
33
|
+
run(fn) {
|
|
34
|
+
if (this._active) {
|
|
35
|
+
const currentEffectScope = activeEffectScope;
|
|
36
|
+
try {
|
|
37
|
+
activeEffectScope = this;
|
|
38
|
+
return fn();
|
|
39
|
+
} finally {
|
|
40
|
+
activeEffectScope = currentEffectScope;
|
|
41
|
+
}
|
|
42
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
43
|
+
warn(`cannot run an inactive effect scope.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* This should only be called on non-detached scopes
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
on() {
|
|
51
|
+
activeEffectScope = this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* This should only be called on non-detached scopes
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
off() {
|
|
58
|
+
activeEffectScope = this.parent;
|
|
59
|
+
}
|
|
60
|
+
stop(fromParent) {
|
|
61
|
+
if (this._active) {
|
|
62
|
+
let i, l;
|
|
63
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
64
|
+
this.effects[i].stop();
|
|
65
|
+
}
|
|
66
|
+
for (i = 0, l = this.cleanups.length; i < l; i++) {
|
|
67
|
+
this.cleanups[i]();
|
|
68
|
+
}
|
|
69
|
+
if (this.scopes) {
|
|
70
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
71
|
+
this.scopes[i].stop(true);
|
|
86
72
|
}
|
|
73
|
+
}
|
|
74
|
+
if (!this.detached && this.parent && !fromParent) {
|
|
75
|
+
const last = this.parent.scopes.pop();
|
|
76
|
+
if (last && last !== this) {
|
|
77
|
+
this.parent.scopes[this.index] = last;
|
|
78
|
+
last.index = this.index;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.parent = void 0;
|
|
82
|
+
this._active = false;
|
|
87
83
|
}
|
|
84
|
+
}
|
|
88
85
|
}
|
|
89
86
|
function effectScope(detached) {
|
|
90
|
-
|
|
87
|
+
return new EffectScope(detached);
|
|
91
88
|
}
|
|
92
89
|
function recordEffectScope(effect, scope = activeEffectScope) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
if (scope && scope.active) {
|
|
91
|
+
scope.effects.push(effect);
|
|
92
|
+
}
|
|
96
93
|
}
|
|
97
94
|
function getCurrentScope() {
|
|
98
|
-
|
|
95
|
+
return activeEffectScope;
|
|
99
96
|
}
|
|
100
97
|
function onScopeDispose(fn) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
if (activeEffectScope) {
|
|
99
|
+
activeEffectScope.cleanups.push(fn);
|
|
100
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
101
|
+
warn(
|
|
102
|
+
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
const createDep = (effects) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
const dep = new Set(effects);
|
|
109
|
+
dep.w = 0;
|
|
110
|
+
dep.n = 0;
|
|
111
|
+
return dep;
|
|
115
112
|
};
|
|
116
113
|
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
|
117
114
|
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
|
118
115
|
const initDepMarkers = ({ deps }) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
116
|
+
if (deps.length) {
|
|
117
|
+
for (let i = 0; i < deps.length; i++) {
|
|
118
|
+
deps[i].w |= trackOpBit;
|
|
123
119
|
}
|
|
120
|
+
}
|
|
124
121
|
};
|
|
125
122
|
const finalizeDepMarkers = (effect) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
deps.length = ptr;
|
|
142
|
-
}
|
|
123
|
+
const { deps } = effect;
|
|
124
|
+
if (deps.length) {
|
|
125
|
+
let ptr = 0;
|
|
126
|
+
for (let i = 0; i < deps.length; i++) {
|
|
127
|
+
const dep = deps[i];
|
|
128
|
+
if (wasTracked(dep) && !newTracked(dep)) {
|
|
129
|
+
dep.delete(effect);
|
|
130
|
+
} else {
|
|
131
|
+
deps[ptr++] = dep;
|
|
132
|
+
}
|
|
133
|
+
dep.w &= ~trackOpBit;
|
|
134
|
+
dep.n &= ~trackOpBit;
|
|
135
|
+
}
|
|
136
|
+
deps.length = ptr;
|
|
137
|
+
}
|
|
143
138
|
};
|
|
144
139
|
|
|
145
|
-
const targetMap = new WeakMap();
|
|
146
|
-
// The number of effects currently being tracked recursively.
|
|
140
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
147
141
|
let effectTrackDepth = 0;
|
|
148
142
|
let trackOpBit = 1;
|
|
149
|
-
/**
|
|
150
|
-
* The bitwise track markers support at most 30 levels of recursion.
|
|
151
|
-
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
|
|
152
|
-
* When recursion depth is greater, fall back to using a full cleanup.
|
|
153
|
-
*/
|
|
154
143
|
const maxMarkerBits = 30;
|
|
155
144
|
let activeEffect;
|
|
156
|
-
const ITERATE_KEY = Symbol(
|
|
157
|
-
const MAP_KEY_ITERATE_KEY = Symbol(
|
|
145
|
+
const ITERATE_KEY = Symbol(process.env.NODE_ENV !== "production" ? "iterate" : "");
|
|
146
|
+
const MAP_KEY_ITERATE_KEY = Symbol(process.env.NODE_ENV !== "production" ? "Map key iterate" : "");
|
|
158
147
|
class ReactiveEffect {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
deps[i].delete(effect);
|
|
224
|
-
}
|
|
225
|
-
deps.length = 0;
|
|
226
|
-
}
|
|
148
|
+
constructor(fn, scheduler = null, scope) {
|
|
149
|
+
this.fn = fn;
|
|
150
|
+
this.scheduler = scheduler;
|
|
151
|
+
this.active = true;
|
|
152
|
+
this.deps = [];
|
|
153
|
+
this.parent = void 0;
|
|
154
|
+
recordEffectScope(this, scope);
|
|
155
|
+
}
|
|
156
|
+
run() {
|
|
157
|
+
if (!this.active) {
|
|
158
|
+
return this.fn();
|
|
159
|
+
}
|
|
160
|
+
let parent = activeEffect;
|
|
161
|
+
let lastShouldTrack = shouldTrack;
|
|
162
|
+
while (parent) {
|
|
163
|
+
if (parent === this) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
parent = parent.parent;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
this.parent = activeEffect;
|
|
170
|
+
activeEffect = this;
|
|
171
|
+
shouldTrack = true;
|
|
172
|
+
trackOpBit = 1 << ++effectTrackDepth;
|
|
173
|
+
if (effectTrackDepth <= maxMarkerBits) {
|
|
174
|
+
initDepMarkers(this);
|
|
175
|
+
} else {
|
|
176
|
+
cleanupEffect(this);
|
|
177
|
+
}
|
|
178
|
+
return this.fn();
|
|
179
|
+
} finally {
|
|
180
|
+
if (effectTrackDepth <= maxMarkerBits) {
|
|
181
|
+
finalizeDepMarkers(this);
|
|
182
|
+
}
|
|
183
|
+
trackOpBit = 1 << --effectTrackDepth;
|
|
184
|
+
activeEffect = this.parent;
|
|
185
|
+
shouldTrack = lastShouldTrack;
|
|
186
|
+
this.parent = void 0;
|
|
187
|
+
if (this.deferStop) {
|
|
188
|
+
this.stop();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
stop() {
|
|
193
|
+
if (activeEffect === this) {
|
|
194
|
+
this.deferStop = true;
|
|
195
|
+
} else if (this.active) {
|
|
196
|
+
cleanupEffect(this);
|
|
197
|
+
if (this.onStop) {
|
|
198
|
+
this.onStop();
|
|
199
|
+
}
|
|
200
|
+
this.active = false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function cleanupEffect(effect2) {
|
|
205
|
+
const { deps } = effect2;
|
|
206
|
+
if (deps.length) {
|
|
207
|
+
for (let i = 0; i < deps.length; i++) {
|
|
208
|
+
deps[i].delete(effect2);
|
|
209
|
+
}
|
|
210
|
+
deps.length = 0;
|
|
211
|
+
}
|
|
227
212
|
}
|
|
228
213
|
function effect(fn, options) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
214
|
+
if (fn.effect) {
|
|
215
|
+
fn = fn.effect.fn;
|
|
216
|
+
}
|
|
217
|
+
const _effect = new ReactiveEffect(fn);
|
|
218
|
+
if (options) {
|
|
219
|
+
extend(_effect, options);
|
|
220
|
+
if (options.scope)
|
|
221
|
+
recordEffectScope(_effect, options.scope);
|
|
222
|
+
}
|
|
223
|
+
if (!options || !options.lazy) {
|
|
224
|
+
_effect.run();
|
|
225
|
+
}
|
|
226
|
+
const runner = _effect.run.bind(_effect);
|
|
227
|
+
runner.effect = _effect;
|
|
228
|
+
return runner;
|
|
244
229
|
}
|
|
245
230
|
function stop(runner) {
|
|
246
|
-
|
|
231
|
+
runner.effect.stop();
|
|
247
232
|
}
|
|
248
233
|
let shouldTrack = true;
|
|
249
234
|
const trackStack = [];
|
|
250
235
|
function pauseTracking() {
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
trackStack.push(shouldTrack);
|
|
237
|
+
shouldTrack = false;
|
|
253
238
|
}
|
|
254
239
|
function enableTracking() {
|
|
255
|
-
|
|
256
|
-
|
|
240
|
+
trackStack.push(shouldTrack);
|
|
241
|
+
shouldTrack = true;
|
|
257
242
|
}
|
|
258
243
|
function resetTracking() {
|
|
259
|
-
|
|
260
|
-
|
|
244
|
+
const last = trackStack.pop();
|
|
245
|
+
shouldTrack = last === void 0 ? true : last;
|
|
261
246
|
}
|
|
262
247
|
function track(target, type, key) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
let dep = depsMap.get(key);
|
|
269
|
-
if (!dep) {
|
|
270
|
-
depsMap.set(key, (dep = createDep()));
|
|
271
|
-
}
|
|
272
|
-
const eventInfo = (process.env.NODE_ENV !== 'production')
|
|
273
|
-
? { effect: activeEffect, target, type, key }
|
|
274
|
-
: undefined;
|
|
275
|
-
trackEffects(dep, eventInfo);
|
|
248
|
+
if (shouldTrack && activeEffect) {
|
|
249
|
+
let depsMap = targetMap.get(target);
|
|
250
|
+
if (!depsMap) {
|
|
251
|
+
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
276
252
|
}
|
|
253
|
+
let dep = depsMap.get(key);
|
|
254
|
+
if (!dep) {
|
|
255
|
+
depsMap.set(key, dep = createDep());
|
|
256
|
+
}
|
|
257
|
+
const eventInfo = process.env.NODE_ENV !== "production" ? { effect: activeEffect, target, type, key } : void 0;
|
|
258
|
+
trackEffects(dep, eventInfo);
|
|
259
|
+
}
|
|
277
260
|
}
|
|
278
261
|
function trackEffects(dep, debuggerEventExtraInfo) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
262
|
+
let shouldTrack2 = false;
|
|
263
|
+
if (effectTrackDepth <= maxMarkerBits) {
|
|
264
|
+
if (!newTracked(dep)) {
|
|
265
|
+
dep.n |= trackOpBit;
|
|
266
|
+
shouldTrack2 = !wasTracked(dep);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
shouldTrack2 = !dep.has(activeEffect);
|
|
270
|
+
}
|
|
271
|
+
if (shouldTrack2) {
|
|
272
|
+
dep.add(activeEffect);
|
|
273
|
+
activeEffect.deps.push(dep);
|
|
274
|
+
if (process.env.NODE_ENV !== "production" && activeEffect.onTrack) {
|
|
275
|
+
activeEffect.onTrack(
|
|
276
|
+
extend(
|
|
277
|
+
{
|
|
278
|
+
effect: activeEffect
|
|
279
|
+
},
|
|
280
|
+
debuggerEventExtraInfo
|
|
281
|
+
)
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
297
285
|
}
|
|
298
286
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (!isArray(target)) {
|
|
327
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
328
|
-
if (isMap(target)) {
|
|
329
|
-
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
else if (isIntegerKey(key)) {
|
|
333
|
-
// new index added to array -> length changes
|
|
334
|
-
deps.push(depsMap.get('length'));
|
|
335
|
-
}
|
|
336
|
-
break;
|
|
337
|
-
case "delete" /* TriggerOpTypes.DELETE */:
|
|
338
|
-
if (!isArray(target)) {
|
|
339
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
340
|
-
if (isMap(target)) {
|
|
341
|
-
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
break;
|
|
345
|
-
case "set" /* TriggerOpTypes.SET */:
|
|
346
|
-
if (isMap(target)) {
|
|
347
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
348
|
-
}
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
const eventInfo = (process.env.NODE_ENV !== 'production')
|
|
353
|
-
? { target, type, key, newValue, oldValue, oldTarget }
|
|
354
|
-
: undefined;
|
|
355
|
-
if (deps.length === 1) {
|
|
356
|
-
if (deps[0]) {
|
|
357
|
-
if ((process.env.NODE_ENV !== 'production')) {
|
|
358
|
-
triggerEffects(deps[0], eventInfo);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
triggerEffects(deps[0]);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
const effects = [];
|
|
367
|
-
for (const dep of deps) {
|
|
368
|
-
if (dep) {
|
|
369
|
-
effects.push(...dep);
|
|
370
|
-
}
|
|
287
|
+
const depsMap = targetMap.get(target);
|
|
288
|
+
if (!depsMap) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
let deps = [];
|
|
292
|
+
if (type === "clear") {
|
|
293
|
+
deps = [...depsMap.values()];
|
|
294
|
+
} else if (key === "length" && isArray(target)) {
|
|
295
|
+
const newLength = Number(newValue);
|
|
296
|
+
depsMap.forEach((dep, key2) => {
|
|
297
|
+
if (key2 === "length" || key2 >= newLength) {
|
|
298
|
+
deps.push(dep);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
} else {
|
|
302
|
+
if (key !== void 0) {
|
|
303
|
+
deps.push(depsMap.get(key));
|
|
304
|
+
}
|
|
305
|
+
switch (type) {
|
|
306
|
+
case "add":
|
|
307
|
+
if (!isArray(target)) {
|
|
308
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
309
|
+
if (isMap(target)) {
|
|
310
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
311
|
+
}
|
|
312
|
+
} else if (isIntegerKey(key)) {
|
|
313
|
+
deps.push(depsMap.get("length"));
|
|
371
314
|
}
|
|
372
|
-
|
|
373
|
-
|
|
315
|
+
break;
|
|
316
|
+
case "delete":
|
|
317
|
+
if (!isArray(target)) {
|
|
318
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
319
|
+
if (isMap(target)) {
|
|
320
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
321
|
+
}
|
|
374
322
|
}
|
|
375
|
-
|
|
376
|
-
|
|
323
|
+
break;
|
|
324
|
+
case "set":
|
|
325
|
+
if (isMap(target)) {
|
|
326
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
377
327
|
}
|
|
378
|
-
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const eventInfo = process.env.NODE_ENV !== "production" ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
|
|
332
|
+
if (deps.length === 1) {
|
|
333
|
+
if (deps[0]) {
|
|
334
|
+
if (process.env.NODE_ENV !== "production") {
|
|
335
|
+
triggerEffects(deps[0], eventInfo);
|
|
336
|
+
} else {
|
|
337
|
+
triggerEffects(deps[0]);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
const effects = [];
|
|
342
|
+
for (const dep of deps) {
|
|
343
|
+
if (dep) {
|
|
344
|
+
effects.push(...dep);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (process.env.NODE_ENV !== "production") {
|
|
348
|
+
triggerEffects(createDep(effects), eventInfo);
|
|
349
|
+
} else {
|
|
350
|
+
triggerEffects(createDep(effects));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
379
353
|
}
|
|
380
354
|
function triggerEffects(dep, debuggerEventExtraInfo) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
triggerEffect(effect, debuggerEventExtraInfo);
|
|
386
|
-
}
|
|
355
|
+
const effects = isArray(dep) ? dep : [...dep];
|
|
356
|
+
for (const effect2 of effects) {
|
|
357
|
+
if (effect2.computed) {
|
|
358
|
+
triggerEffect(effect2, debuggerEventExtraInfo);
|
|
387
359
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
360
|
+
}
|
|
361
|
+
for (const effect2 of effects) {
|
|
362
|
+
if (!effect2.computed) {
|
|
363
|
+
triggerEffect(effect2, debuggerEventExtraInfo);
|
|
392
364
|
}
|
|
365
|
+
}
|
|
393
366
|
}
|
|
394
|
-
function triggerEffect(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
if (effect.scheduler) {
|
|
400
|
-
effect.scheduler();
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
effect.run();
|
|
404
|
-
}
|
|
367
|
+
function triggerEffect(effect2, debuggerEventExtraInfo) {
|
|
368
|
+
if (effect2 !== activeEffect || effect2.allowRecurse) {
|
|
369
|
+
if (process.env.NODE_ENV !== "production" && effect2.onTrigger) {
|
|
370
|
+
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
405
371
|
}
|
|
372
|
+
if (effect2.scheduler) {
|
|
373
|
+
effect2.scheduler();
|
|
374
|
+
} else {
|
|
375
|
+
effect2.run();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
406
378
|
}
|
|
407
379
|
function getDepFromReactive(object, key) {
|
|
408
|
-
|
|
409
|
-
|
|
380
|
+
var _a;
|
|
381
|
+
return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
|
|
410
382
|
}
|
|
411
383
|
|
|
412
|
-
const isNonTrackableKeys =
|
|
384
|
+
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
413
385
|
const builtInSymbols = new Set(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
.filter(isSymbol));
|
|
422
|
-
const get$1 = /*#__PURE__*/ createGetter();
|
|
423
|
-
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
424
|
-
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
425
|
-
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
426
|
-
const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
|
386
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
387
|
+
);
|
|
388
|
+
const get$1 = /* @__PURE__ */ createGetter();
|
|
389
|
+
const shallowGet = /* @__PURE__ */ createGetter(false, true);
|
|
390
|
+
const readonlyGet = /* @__PURE__ */ createGetter(true);
|
|
391
|
+
const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
|
|
392
|
+
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
427
393
|
function createArrayInstrumentations() {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return arr[key](...args.map(toRaw));
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
return res;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
});
|
|
446
|
-
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
|
447
|
-
instrumentations[key] = function (...args) {
|
|
448
|
-
pauseTracking();
|
|
449
|
-
const res = toRaw(this)[key].apply(this, args);
|
|
450
|
-
resetTracking();
|
|
451
|
-
return res;
|
|
452
|
-
};
|
|
453
|
-
});
|
|
454
|
-
return instrumentations;
|
|
455
|
-
}
|
|
456
|
-
function hasOwnProperty(key) {
|
|
457
|
-
const obj = toRaw(this);
|
|
458
|
-
track(obj, "has" /* TrackOpTypes.HAS */, key);
|
|
459
|
-
return obj.hasOwnProperty(key);
|
|
460
|
-
}
|
|
461
|
-
function createGetter(isReadonly = false, shallow = false) {
|
|
462
|
-
return function get(target, key, receiver) {
|
|
463
|
-
if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
|
|
464
|
-
return !isReadonly;
|
|
465
|
-
}
|
|
466
|
-
else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
|
|
467
|
-
return isReadonly;
|
|
468
|
-
}
|
|
469
|
-
else if (key === "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */) {
|
|
470
|
-
return shallow;
|
|
471
|
-
}
|
|
472
|
-
else if (key === "__v_raw" /* ReactiveFlags.RAW */ &&
|
|
473
|
-
receiver ===
|
|
474
|
-
(isReadonly
|
|
475
|
-
? shallow
|
|
476
|
-
? shallowReadonlyMap
|
|
477
|
-
: readonlyMap
|
|
478
|
-
: shallow
|
|
479
|
-
? shallowReactiveMap
|
|
480
|
-
: reactiveMap).get(target)) {
|
|
481
|
-
return target;
|
|
482
|
-
}
|
|
483
|
-
const targetIsArray = isArray(target);
|
|
484
|
-
if (!isReadonly) {
|
|
485
|
-
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
486
|
-
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
487
|
-
}
|
|
488
|
-
if (key === 'hasOwnProperty') {
|
|
489
|
-
return hasOwnProperty;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
const res = Reflect.get(target, key, receiver);
|
|
493
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
494
|
-
return res;
|
|
495
|
-
}
|
|
496
|
-
if (!isReadonly) {
|
|
497
|
-
track(target, "get" /* TrackOpTypes.GET */, key);
|
|
498
|
-
}
|
|
499
|
-
if (shallow) {
|
|
500
|
-
return res;
|
|
501
|
-
}
|
|
502
|
-
if (isRef(res)) {
|
|
503
|
-
// ref unwrapping - skip unwrap for Array + integer key.
|
|
504
|
-
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
505
|
-
}
|
|
506
|
-
if (isObject(res)) {
|
|
507
|
-
// Convert returned value into a proxy as well. we do the isObject check
|
|
508
|
-
// here to avoid invalid value warning. Also need to lazy access readonly
|
|
509
|
-
// and reactive here to avoid circular dependency.
|
|
510
|
-
return isReadonly ? readonly(res) : reactive(res);
|
|
511
|
-
}
|
|
394
|
+
const instrumentations = {};
|
|
395
|
+
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
396
|
+
instrumentations[key] = function(...args) {
|
|
397
|
+
const arr = toRaw(this);
|
|
398
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
399
|
+
track(arr, "get", i + "");
|
|
400
|
+
}
|
|
401
|
+
const res = arr[key](...args);
|
|
402
|
+
if (res === -1 || res === false) {
|
|
403
|
+
return arr[key](...args.map(toRaw));
|
|
404
|
+
} else {
|
|
512
405
|
return res;
|
|
406
|
+
}
|
|
513
407
|
};
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
if (!shallow) {
|
|
524
|
-
if (!isShallow(value) && !isReadonly(value)) {
|
|
525
|
-
oldValue = toRaw(oldValue);
|
|
526
|
-
value = toRaw(value);
|
|
527
|
-
}
|
|
528
|
-
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
529
|
-
oldValue.value = value;
|
|
530
|
-
return true;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
const hadKey = isArray(target) && isIntegerKey(key)
|
|
534
|
-
? Number(key) < target.length
|
|
535
|
-
: hasOwn(target, key);
|
|
536
|
-
const result = Reflect.set(target, key, value, receiver);
|
|
537
|
-
// don't trigger if target is something up in the prototype chain of original
|
|
538
|
-
if (target === toRaw(receiver)) {
|
|
539
|
-
if (!hadKey) {
|
|
540
|
-
trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
|
|
541
|
-
}
|
|
542
|
-
else if (hasChanged(value, oldValue)) {
|
|
543
|
-
trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return result;
|
|
408
|
+
});
|
|
409
|
+
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
410
|
+
instrumentations[key] = function(...args) {
|
|
411
|
+
pauseTracking();
|
|
412
|
+
const res = toRaw(this)[key].apply(this, args);
|
|
413
|
+
resetTracking();
|
|
414
|
+
return res;
|
|
547
415
|
};
|
|
416
|
+
});
|
|
417
|
+
return instrumentations;
|
|
548
418
|
}
|
|
549
|
-
function
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
419
|
+
function hasOwnProperty(key) {
|
|
420
|
+
const obj = toRaw(this);
|
|
421
|
+
track(obj, "has", key);
|
|
422
|
+
return obj.hasOwnProperty(key);
|
|
423
|
+
}
|
|
424
|
+
function createGetter(isReadonly2 = false, shallow = false) {
|
|
425
|
+
return function get2(target, key, receiver) {
|
|
426
|
+
if (key === "__v_isReactive") {
|
|
427
|
+
return !isReadonly2;
|
|
428
|
+
} else if (key === "__v_isReadonly") {
|
|
429
|
+
return isReadonly2;
|
|
430
|
+
} else if (key === "__v_isShallow") {
|
|
431
|
+
return shallow;
|
|
432
|
+
} else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
|
|
433
|
+
return target;
|
|
434
|
+
}
|
|
435
|
+
const targetIsArray = isArray(target);
|
|
436
|
+
if (!isReadonly2) {
|
|
437
|
+
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
438
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
439
|
+
}
|
|
440
|
+
if (key === "hasOwnProperty") {
|
|
441
|
+
return hasOwnProperty;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const res = Reflect.get(target, key, receiver);
|
|
445
|
+
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
446
|
+
return res;
|
|
447
|
+
}
|
|
448
|
+
if (!isReadonly2) {
|
|
449
|
+
track(target, "get", key);
|
|
450
|
+
}
|
|
451
|
+
if (shallow) {
|
|
452
|
+
return res;
|
|
453
|
+
}
|
|
454
|
+
if (isRef(res)) {
|
|
455
|
+
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
456
|
+
}
|
|
457
|
+
if (isObject(res)) {
|
|
458
|
+
return isReadonly2 ? readonly(res) : reactive(res);
|
|
459
|
+
}
|
|
460
|
+
return res;
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
const set$1 = /* @__PURE__ */ createSetter();
|
|
464
|
+
const shallowSet = /* @__PURE__ */ createSetter(true);
|
|
465
|
+
function createSetter(shallow = false) {
|
|
466
|
+
return function set2(target, key, value, receiver) {
|
|
467
|
+
let oldValue = target[key];
|
|
468
|
+
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
if (!shallow) {
|
|
472
|
+
if (!isShallow(value) && !isReadonly(value)) {
|
|
473
|
+
oldValue = toRaw(oldValue);
|
|
474
|
+
value = toRaw(value);
|
|
475
|
+
}
|
|
476
|
+
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
477
|
+
oldValue.value = value;
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
482
|
+
const result = Reflect.set(target, key, value, receiver);
|
|
483
|
+
if (target === toRaw(receiver)) {
|
|
484
|
+
if (!hadKey) {
|
|
485
|
+
trigger(target, "add", key, value);
|
|
486
|
+
} else if (hasChanged(value, oldValue)) {
|
|
487
|
+
trigger(target, "set", key, value, oldValue);
|
|
488
|
+
}
|
|
555
489
|
}
|
|
556
490
|
return result;
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function deleteProperty(target, key) {
|
|
494
|
+
const hadKey = hasOwn(target, key);
|
|
495
|
+
const oldValue = target[key];
|
|
496
|
+
const result = Reflect.deleteProperty(target, key);
|
|
497
|
+
if (result && hadKey) {
|
|
498
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
499
|
+
}
|
|
500
|
+
return result;
|
|
557
501
|
}
|
|
558
502
|
function has$1(target, key) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
503
|
+
const result = Reflect.has(target, key);
|
|
504
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
505
|
+
track(target, "has", key);
|
|
506
|
+
}
|
|
507
|
+
return result;
|
|
564
508
|
}
|
|
565
509
|
function ownKeys(target) {
|
|
566
|
-
|
|
567
|
-
|
|
510
|
+
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
511
|
+
return Reflect.ownKeys(target);
|
|
568
512
|
}
|
|
569
513
|
const mutableHandlers = {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
514
|
+
get: get$1,
|
|
515
|
+
set: set$1,
|
|
516
|
+
deleteProperty,
|
|
517
|
+
has: has$1,
|
|
518
|
+
ownKeys
|
|
575
519
|
};
|
|
576
520
|
const readonlyHandlers = {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
521
|
+
get: readonlyGet,
|
|
522
|
+
set(target, key) {
|
|
523
|
+
if (process.env.NODE_ENV !== "production") {
|
|
524
|
+
warn(
|
|
525
|
+
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
526
|
+
target
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return true;
|
|
530
|
+
},
|
|
531
|
+
deleteProperty(target, key) {
|
|
532
|
+
if (process.env.NODE_ENV !== "production") {
|
|
533
|
+
warn(
|
|
534
|
+
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
535
|
+
target
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
590
540
|
};
|
|
591
|
-
const shallowReactiveHandlers =
|
|
541
|
+
const shallowReactiveHandlers = /* @__PURE__ */ extend(
|
|
542
|
+
{},
|
|
543
|
+
mutableHandlers,
|
|
544
|
+
{
|
|
592
545
|
get: shallowGet,
|
|
593
546
|
set: shallowSet
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
547
|
+
}
|
|
548
|
+
);
|
|
549
|
+
const shallowReadonlyHandlers = /* @__PURE__ */ extend(
|
|
550
|
+
{},
|
|
551
|
+
readonlyHandlers,
|
|
552
|
+
{
|
|
599
553
|
get: shallowReadonlyGet
|
|
600
|
-
}
|
|
554
|
+
}
|
|
555
|
+
);
|
|
601
556
|
|
|
602
557
|
const toShallow = (value) => value;
|
|
603
558
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
604
559
|
function get(target, key, isReadonly = false, isShallow = false) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
else if (target !== rawTarget) {
|
|
625
|
-
// #3602 readonly(reactive(Map))
|
|
626
|
-
// ensure that the nested reactive `Map` can do tracking for itself
|
|
627
|
-
target.get(key);
|
|
628
|
-
}
|
|
560
|
+
target = target["__v_raw"];
|
|
561
|
+
const rawTarget = toRaw(target);
|
|
562
|
+
const rawKey = toRaw(key);
|
|
563
|
+
if (!isReadonly) {
|
|
564
|
+
if (key !== rawKey) {
|
|
565
|
+
track(rawTarget, "get", key);
|
|
566
|
+
}
|
|
567
|
+
track(rawTarget, "get", rawKey);
|
|
568
|
+
}
|
|
569
|
+
const { has: has2 } = getProto(rawTarget);
|
|
570
|
+
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
571
|
+
if (has2.call(rawTarget, key)) {
|
|
572
|
+
return wrap(target.get(key));
|
|
573
|
+
} else if (has2.call(rawTarget, rawKey)) {
|
|
574
|
+
return wrap(target.get(rawKey));
|
|
575
|
+
} else if (target !== rawTarget) {
|
|
576
|
+
target.get(key);
|
|
577
|
+
}
|
|
629
578
|
}
|
|
630
579
|
function has(key, isReadonly = false) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
track(rawTarget, "has" /* TrackOpTypes.HAS */, rawKey);
|
|
580
|
+
const target = this["__v_raw"];
|
|
581
|
+
const rawTarget = toRaw(target);
|
|
582
|
+
const rawKey = toRaw(key);
|
|
583
|
+
if (!isReadonly) {
|
|
584
|
+
if (key !== rawKey) {
|
|
585
|
+
track(rawTarget, "has", key);
|
|
639
586
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
587
|
+
track(rawTarget, "has", rawKey);
|
|
588
|
+
}
|
|
589
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
643
590
|
}
|
|
644
591
|
function size(target, isReadonly = false) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
592
|
+
target = target["__v_raw"];
|
|
593
|
+
!isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
594
|
+
return Reflect.get(target, "size", target);
|
|
648
595
|
}
|
|
649
596
|
function add(value) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
597
|
+
value = toRaw(value);
|
|
598
|
+
const target = toRaw(this);
|
|
599
|
+
const proto = getProto(target);
|
|
600
|
+
const hadKey = proto.has.call(target, value);
|
|
601
|
+
if (!hadKey) {
|
|
602
|
+
target.add(value);
|
|
603
|
+
trigger(target, "add", value, value);
|
|
604
|
+
}
|
|
605
|
+
return this;
|
|
659
606
|
}
|
|
660
607
|
function set(key, value) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
return this;
|
|
608
|
+
value = toRaw(value);
|
|
609
|
+
const target = toRaw(this);
|
|
610
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
611
|
+
let hadKey = has2.call(target, key);
|
|
612
|
+
if (!hadKey) {
|
|
613
|
+
key = toRaw(key);
|
|
614
|
+
hadKey = has2.call(target, key);
|
|
615
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
616
|
+
checkIdentityKeys(target, has2, key);
|
|
617
|
+
}
|
|
618
|
+
const oldValue = get2.call(target, key);
|
|
619
|
+
target.set(key, value);
|
|
620
|
+
if (!hadKey) {
|
|
621
|
+
trigger(target, "add", key, value);
|
|
622
|
+
} else if (hasChanged(value, oldValue)) {
|
|
623
|
+
trigger(target, "set", key, value, oldValue);
|
|
624
|
+
}
|
|
625
|
+
return this;
|
|
681
626
|
}
|
|
682
627
|
function deleteEntry(key) {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
return result;
|
|
628
|
+
const target = toRaw(this);
|
|
629
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
630
|
+
let hadKey = has2.call(target, key);
|
|
631
|
+
if (!hadKey) {
|
|
632
|
+
key = toRaw(key);
|
|
633
|
+
hadKey = has2.call(target, key);
|
|
634
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
635
|
+
checkIdentityKeys(target, has2, key);
|
|
636
|
+
}
|
|
637
|
+
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
638
|
+
const result = target.delete(key);
|
|
639
|
+
if (hadKey) {
|
|
640
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
641
|
+
}
|
|
642
|
+
return result;
|
|
700
643
|
}
|
|
701
644
|
function clear() {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
const result = target.clear();
|
|
711
|
-
if (hadItems) {
|
|
712
|
-
trigger(target, "clear" /* TriggerOpTypes.CLEAR */, undefined, undefined, oldTarget);
|
|
713
|
-
}
|
|
714
|
-
return result;
|
|
645
|
+
const target = toRaw(this);
|
|
646
|
+
const hadItems = target.size !== 0;
|
|
647
|
+
const oldTarget = process.env.NODE_ENV !== "production" ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
648
|
+
const result = target.clear();
|
|
649
|
+
if (hadItems) {
|
|
650
|
+
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
651
|
+
}
|
|
652
|
+
return result;
|
|
715
653
|
}
|
|
716
654
|
function createForEach(isReadonly, isShallow) {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
728
|
-
});
|
|
729
|
-
};
|
|
655
|
+
return function forEach(callback, thisArg) {
|
|
656
|
+
const observed = this;
|
|
657
|
+
const target = observed["__v_raw"];
|
|
658
|
+
const rawTarget = toRaw(target);
|
|
659
|
+
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
660
|
+
!isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
661
|
+
return target.forEach((value, key) => {
|
|
662
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
663
|
+
});
|
|
664
|
+
};
|
|
730
665
|
}
|
|
731
666
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
done
|
|
753
|
-
};
|
|
754
|
-
},
|
|
755
|
-
// iterable protocol
|
|
756
|
-
[Symbol.iterator]() {
|
|
757
|
-
return this;
|
|
758
|
-
}
|
|
667
|
+
return function(...args) {
|
|
668
|
+
const target = this["__v_raw"];
|
|
669
|
+
const rawTarget = toRaw(target);
|
|
670
|
+
const targetIsMap = isMap(rawTarget);
|
|
671
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
672
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
673
|
+
const innerIterator = target[method](...args);
|
|
674
|
+
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
675
|
+
!isReadonly && track(
|
|
676
|
+
rawTarget,
|
|
677
|
+
"iterate",
|
|
678
|
+
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
679
|
+
);
|
|
680
|
+
return {
|
|
681
|
+
// iterator protocol
|
|
682
|
+
next() {
|
|
683
|
+
const { value, done } = innerIterator.next();
|
|
684
|
+
return done ? { value, done } : {
|
|
685
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
686
|
+
done
|
|
759
687
|
};
|
|
688
|
+
},
|
|
689
|
+
// iterable protocol
|
|
690
|
+
[Symbol.iterator]() {
|
|
691
|
+
return this;
|
|
692
|
+
}
|
|
760
693
|
};
|
|
694
|
+
};
|
|
761
695
|
}
|
|
762
696
|
function createReadonlyMethod(type) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
697
|
+
return function(...args) {
|
|
698
|
+
if (process.env.NODE_ENV !== "production") {
|
|
699
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
700
|
+
console.warn(
|
|
701
|
+
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
702
|
+
toRaw(this)
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
return type === "delete" ? false : this;
|
|
706
|
+
};
|
|
770
707
|
}
|
|
771
708
|
function createInstrumentations() {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
]
|
|
845
|
-
|
|
846
|
-
|
|
709
|
+
const mutableInstrumentations2 = {
|
|
710
|
+
get(key) {
|
|
711
|
+
return get(this, key);
|
|
712
|
+
},
|
|
713
|
+
get size() {
|
|
714
|
+
return size(this);
|
|
715
|
+
},
|
|
716
|
+
has,
|
|
717
|
+
add,
|
|
718
|
+
set,
|
|
719
|
+
delete: deleteEntry,
|
|
720
|
+
clear,
|
|
721
|
+
forEach: createForEach(false, false)
|
|
722
|
+
};
|
|
723
|
+
const shallowInstrumentations2 = {
|
|
724
|
+
get(key) {
|
|
725
|
+
return get(this, key, false, true);
|
|
726
|
+
},
|
|
727
|
+
get size() {
|
|
728
|
+
return size(this);
|
|
729
|
+
},
|
|
730
|
+
has,
|
|
731
|
+
add,
|
|
732
|
+
set,
|
|
733
|
+
delete: deleteEntry,
|
|
734
|
+
clear,
|
|
735
|
+
forEach: createForEach(false, true)
|
|
736
|
+
};
|
|
737
|
+
const readonlyInstrumentations2 = {
|
|
738
|
+
get(key) {
|
|
739
|
+
return get(this, key, true);
|
|
740
|
+
},
|
|
741
|
+
get size() {
|
|
742
|
+
return size(this, true);
|
|
743
|
+
},
|
|
744
|
+
has(key) {
|
|
745
|
+
return has.call(this, key, true);
|
|
746
|
+
},
|
|
747
|
+
add: createReadonlyMethod("add"),
|
|
748
|
+
set: createReadonlyMethod("set"),
|
|
749
|
+
delete: createReadonlyMethod("delete"),
|
|
750
|
+
clear: createReadonlyMethod("clear"),
|
|
751
|
+
forEach: createForEach(true, false)
|
|
752
|
+
};
|
|
753
|
+
const shallowReadonlyInstrumentations2 = {
|
|
754
|
+
get(key) {
|
|
755
|
+
return get(this, key, true, true);
|
|
756
|
+
},
|
|
757
|
+
get size() {
|
|
758
|
+
return size(this, true);
|
|
759
|
+
},
|
|
760
|
+
has(key) {
|
|
761
|
+
return has.call(this, key, true);
|
|
762
|
+
},
|
|
763
|
+
add: createReadonlyMethod("add"),
|
|
764
|
+
set: createReadonlyMethod("set"),
|
|
765
|
+
delete: createReadonlyMethod("delete"),
|
|
766
|
+
clear: createReadonlyMethod("clear"),
|
|
767
|
+
forEach: createForEach(true, true)
|
|
768
|
+
};
|
|
769
|
+
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
|
|
770
|
+
iteratorMethods.forEach((method) => {
|
|
771
|
+
mutableInstrumentations2[method] = createIterableMethod(
|
|
772
|
+
method,
|
|
773
|
+
false,
|
|
774
|
+
false
|
|
775
|
+
);
|
|
776
|
+
readonlyInstrumentations2[method] = createIterableMethod(
|
|
777
|
+
method,
|
|
778
|
+
true,
|
|
779
|
+
false
|
|
780
|
+
);
|
|
781
|
+
shallowInstrumentations2[method] = createIterableMethod(
|
|
782
|
+
method,
|
|
783
|
+
false,
|
|
784
|
+
true
|
|
785
|
+
);
|
|
786
|
+
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
787
|
+
method,
|
|
788
|
+
true,
|
|
789
|
+
true
|
|
790
|
+
);
|
|
791
|
+
});
|
|
792
|
+
return [
|
|
793
|
+
mutableInstrumentations2,
|
|
794
|
+
readonlyInstrumentations2,
|
|
795
|
+
shallowInstrumentations2,
|
|
796
|
+
shallowReadonlyInstrumentations2
|
|
797
|
+
];
|
|
798
|
+
}
|
|
799
|
+
const [
|
|
800
|
+
mutableInstrumentations,
|
|
801
|
+
readonlyInstrumentations,
|
|
802
|
+
shallowInstrumentations,
|
|
803
|
+
shallowReadonlyInstrumentations
|
|
804
|
+
] = /* @__PURE__ */ createInstrumentations();
|
|
847
805
|
function createInstrumentationGetter(isReadonly, shallow) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
return target;
|
|
864
|
-
}
|
|
865
|
-
return Reflect.get(hasOwn(instrumentations, key) && key in target
|
|
866
|
-
? instrumentations
|
|
867
|
-
: target, key, receiver);
|
|
868
|
-
};
|
|
806
|
+
const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
|
|
807
|
+
return (target, key, receiver) => {
|
|
808
|
+
if (key === "__v_isReactive") {
|
|
809
|
+
return !isReadonly;
|
|
810
|
+
} else if (key === "__v_isReadonly") {
|
|
811
|
+
return isReadonly;
|
|
812
|
+
} else if (key === "__v_raw") {
|
|
813
|
+
return target;
|
|
814
|
+
}
|
|
815
|
+
return Reflect.get(
|
|
816
|
+
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
817
|
+
key,
|
|
818
|
+
receiver
|
|
819
|
+
);
|
|
820
|
+
};
|
|
869
821
|
}
|
|
870
822
|
const mutableCollectionHandlers = {
|
|
871
|
-
|
|
823
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
872
824
|
};
|
|
873
825
|
const shallowCollectionHandlers = {
|
|
874
|
-
|
|
826
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
875
827
|
};
|
|
876
828
|
const readonlyCollectionHandlers = {
|
|
877
|
-
|
|
829
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
878
830
|
};
|
|
879
831
|
const shallowReadonlyCollectionHandlers = {
|
|
880
|
-
|
|
832
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
881
833
|
};
|
|
882
|
-
function checkIdentityKeys(target,
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
`of an object and only use the reactive version if possible.`);
|
|
891
|
-
}
|
|
834
|
+
function checkIdentityKeys(target, has2, key) {
|
|
835
|
+
const rawKey = toRaw(key);
|
|
836
|
+
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
837
|
+
const type = toRawType(target);
|
|
838
|
+
console.warn(
|
|
839
|
+
`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.`
|
|
840
|
+
);
|
|
841
|
+
}
|
|
892
842
|
}
|
|
893
843
|
|
|
894
|
-
const reactiveMap = new WeakMap();
|
|
895
|
-
const shallowReactiveMap = new WeakMap();
|
|
896
|
-
const readonlyMap = new WeakMap();
|
|
897
|
-
const shallowReadonlyMap = new WeakMap();
|
|
844
|
+
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
845
|
+
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
846
|
+
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
847
|
+
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
898
848
|
function targetTypeMap(rawType) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
849
|
+
switch (rawType) {
|
|
850
|
+
case "Object":
|
|
851
|
+
case "Array":
|
|
852
|
+
return 1 /* COMMON */;
|
|
853
|
+
case "Map":
|
|
854
|
+
case "Set":
|
|
855
|
+
case "WeakMap":
|
|
856
|
+
case "WeakSet":
|
|
857
|
+
return 2 /* COLLECTION */;
|
|
858
|
+
default:
|
|
859
|
+
return 0 /* INVALID */;
|
|
860
|
+
}
|
|
911
861
|
}
|
|
912
862
|
function getTargetType(value) {
|
|
913
|
-
|
|
914
|
-
? 0 /* TargetType.INVALID */
|
|
915
|
-
: targetTypeMap(toRawType(value));
|
|
863
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
|
|
916
864
|
}
|
|
917
865
|
function reactive(target) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
866
|
+
if (isReadonly(target)) {
|
|
867
|
+
return target;
|
|
868
|
+
}
|
|
869
|
+
return createReactiveObject(
|
|
870
|
+
target,
|
|
871
|
+
false,
|
|
872
|
+
mutableHandlers,
|
|
873
|
+
mutableCollectionHandlers,
|
|
874
|
+
reactiveMap
|
|
875
|
+
);
|
|
923
876
|
}
|
|
924
|
-
/**
|
|
925
|
-
* Return a shallowly-reactive copy of the original object, where only the root
|
|
926
|
-
* level properties are reactive. It also does not auto-unwrap refs (even at the
|
|
927
|
-
* root level).
|
|
928
|
-
*/
|
|
929
877
|
function shallowReactive(target) {
|
|
930
|
-
|
|
878
|
+
return createReactiveObject(
|
|
879
|
+
target,
|
|
880
|
+
false,
|
|
881
|
+
shallowReactiveHandlers,
|
|
882
|
+
shallowCollectionHandlers,
|
|
883
|
+
shallowReactiveMap
|
|
884
|
+
);
|
|
931
885
|
}
|
|
932
|
-
/**
|
|
933
|
-
* Creates a readonly copy of the original object. Note the returned copy is not
|
|
934
|
-
* made reactive, but `readonly` can be called on an already reactive object.
|
|
935
|
-
*/
|
|
936
886
|
function readonly(target) {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
*/
|
|
945
|
-
function shallowReadonly(target) {
|
|
946
|
-
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
887
|
+
return createReactiveObject(
|
|
888
|
+
target,
|
|
889
|
+
true,
|
|
890
|
+
readonlyHandlers,
|
|
891
|
+
readonlyCollectionHandlers,
|
|
892
|
+
readonlyMap
|
|
893
|
+
);
|
|
947
894
|
}
|
|
948
|
-
function
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
return
|
|
895
|
+
function shallowReadonly(target) {
|
|
896
|
+
return createReactiveObject(
|
|
897
|
+
target,
|
|
898
|
+
true,
|
|
899
|
+
shallowReadonlyHandlers,
|
|
900
|
+
shallowReadonlyCollectionHandlers,
|
|
901
|
+
shallowReadonlyMap
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
905
|
+
if (!isObject(target)) {
|
|
906
|
+
if (process.env.NODE_ENV !== "production") {
|
|
907
|
+
console.warn(`value cannot be made reactive: ${String(target)}`);
|
|
908
|
+
}
|
|
909
|
+
return target;
|
|
910
|
+
}
|
|
911
|
+
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
912
|
+
return target;
|
|
913
|
+
}
|
|
914
|
+
const existingProxy = proxyMap.get(target);
|
|
915
|
+
if (existingProxy) {
|
|
916
|
+
return existingProxy;
|
|
917
|
+
}
|
|
918
|
+
const targetType = getTargetType(target);
|
|
919
|
+
if (targetType === 0 /* INVALID */) {
|
|
920
|
+
return target;
|
|
921
|
+
}
|
|
922
|
+
const proxy = new Proxy(
|
|
923
|
+
target,
|
|
924
|
+
targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
|
|
925
|
+
);
|
|
926
|
+
proxyMap.set(target, proxy);
|
|
927
|
+
return proxy;
|
|
974
928
|
}
|
|
975
929
|
function isReactive(value) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
930
|
+
if (isReadonly(value)) {
|
|
931
|
+
return isReactive(value["__v_raw"]);
|
|
932
|
+
}
|
|
933
|
+
return !!(value && value["__v_isReactive"]);
|
|
980
934
|
}
|
|
981
935
|
function isReadonly(value) {
|
|
982
|
-
|
|
936
|
+
return !!(value && value["__v_isReadonly"]);
|
|
983
937
|
}
|
|
984
938
|
function isShallow(value) {
|
|
985
|
-
|
|
939
|
+
return !!(value && value["__v_isShallow"]);
|
|
986
940
|
}
|
|
987
941
|
function isProxy(value) {
|
|
988
|
-
|
|
942
|
+
return isReactive(value) || isReadonly(value);
|
|
989
943
|
}
|
|
990
944
|
function toRaw(observed) {
|
|
991
|
-
|
|
992
|
-
|
|
945
|
+
const raw = observed && observed["__v_raw"];
|
|
946
|
+
return raw ? toRaw(raw) : observed;
|
|
993
947
|
}
|
|
994
948
|
function markRaw(value) {
|
|
995
|
-
|
|
996
|
-
|
|
949
|
+
def(value, "__v_skip", true);
|
|
950
|
+
return value;
|
|
997
951
|
}
|
|
998
952
|
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
999
953
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1000
954
|
|
|
1001
|
-
function trackRefValue(
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
if (
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
955
|
+
function trackRefValue(ref2) {
|
|
956
|
+
if (shouldTrack && activeEffect) {
|
|
957
|
+
ref2 = toRaw(ref2);
|
|
958
|
+
if (process.env.NODE_ENV !== "production") {
|
|
959
|
+
trackEffects(ref2.dep || (ref2.dep = createDep()), {
|
|
960
|
+
target: ref2,
|
|
961
|
+
type: "get",
|
|
962
|
+
key: "value"
|
|
963
|
+
});
|
|
964
|
+
} else {
|
|
965
|
+
trackEffects(ref2.dep || (ref2.dep = createDep()));
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function triggerRefValue(ref2, newVal) {
|
|
970
|
+
ref2 = toRaw(ref2);
|
|
971
|
+
const dep = ref2.dep;
|
|
972
|
+
if (dep) {
|
|
973
|
+
if (process.env.NODE_ENV !== "production") {
|
|
974
|
+
triggerEffects(dep, {
|
|
975
|
+
target: ref2,
|
|
976
|
+
type: "set",
|
|
977
|
+
key: "value",
|
|
978
|
+
newValue: newVal
|
|
979
|
+
});
|
|
980
|
+
} else {
|
|
981
|
+
triggerEffects(dep);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
1032
984
|
}
|
|
1033
985
|
function isRef(r) {
|
|
1034
|
-
|
|
986
|
+
return !!(r && r.__v_isRef === true);
|
|
1035
987
|
}
|
|
1036
988
|
function ref(value) {
|
|
1037
|
-
|
|
989
|
+
return createRef(value, false);
|
|
1038
990
|
}
|
|
1039
991
|
function shallowRef(value) {
|
|
1040
|
-
|
|
992
|
+
return createRef(value, true);
|
|
1041
993
|
}
|
|
1042
994
|
function createRef(rawValue, shallow) {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
995
|
+
if (isRef(rawValue)) {
|
|
996
|
+
return rawValue;
|
|
997
|
+
}
|
|
998
|
+
return new RefImpl(rawValue, shallow);
|
|
1047
999
|
}
|
|
1048
1000
|
class RefImpl {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
}
|
|
1070
|
-
function triggerRef(
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
function unref(
|
|
1074
|
-
|
|
1001
|
+
constructor(value, __v_isShallow) {
|
|
1002
|
+
this.__v_isShallow = __v_isShallow;
|
|
1003
|
+
this.dep = void 0;
|
|
1004
|
+
this.__v_isRef = true;
|
|
1005
|
+
this._rawValue = __v_isShallow ? value : toRaw(value);
|
|
1006
|
+
this._value = __v_isShallow ? value : toReactive(value);
|
|
1007
|
+
}
|
|
1008
|
+
get value() {
|
|
1009
|
+
trackRefValue(this);
|
|
1010
|
+
return this._value;
|
|
1011
|
+
}
|
|
1012
|
+
set value(newVal) {
|
|
1013
|
+
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
|
1014
|
+
newVal = useDirectValue ? newVal : toRaw(newVal);
|
|
1015
|
+
if (hasChanged(newVal, this._rawValue)) {
|
|
1016
|
+
this._rawValue = newVal;
|
|
1017
|
+
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1018
|
+
triggerRefValue(this, newVal);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function triggerRef(ref2) {
|
|
1023
|
+
triggerRefValue(ref2, process.env.NODE_ENV !== "production" ? ref2.value : void 0);
|
|
1024
|
+
}
|
|
1025
|
+
function unref(ref2) {
|
|
1026
|
+
return isRef(ref2) ? ref2.value : ref2;
|
|
1075
1027
|
}
|
|
1076
1028
|
const shallowUnwrapHandlers = {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
return Reflect.set(target, key, value, receiver);
|
|
1086
|
-
}
|
|
1029
|
+
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1030
|
+
set: (target, key, value, receiver) => {
|
|
1031
|
+
const oldValue = target[key];
|
|
1032
|
+
if (isRef(oldValue) && !isRef(value)) {
|
|
1033
|
+
oldValue.value = value;
|
|
1034
|
+
return true;
|
|
1035
|
+
} else {
|
|
1036
|
+
return Reflect.set(target, key, value, receiver);
|
|
1087
1037
|
}
|
|
1038
|
+
}
|
|
1088
1039
|
};
|
|
1089
1040
|
function proxyRefs(objectWithRefs) {
|
|
1090
|
-
|
|
1091
|
-
? objectWithRefs
|
|
1092
|
-
: new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1041
|
+
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1093
1042
|
}
|
|
1094
1043
|
class CustomRefImpl {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1044
|
+
constructor(factory) {
|
|
1045
|
+
this.dep = void 0;
|
|
1046
|
+
this.__v_isRef = true;
|
|
1047
|
+
const { get, set } = factory(
|
|
1048
|
+
() => trackRefValue(this),
|
|
1049
|
+
() => triggerRefValue(this)
|
|
1050
|
+
);
|
|
1051
|
+
this._get = get;
|
|
1052
|
+
this._set = set;
|
|
1053
|
+
}
|
|
1054
|
+
get value() {
|
|
1055
|
+
return this._get();
|
|
1056
|
+
}
|
|
1057
|
+
set value(newVal) {
|
|
1058
|
+
this._set(newVal);
|
|
1059
|
+
}
|
|
1108
1060
|
}
|
|
1109
1061
|
function customRef(factory) {
|
|
1110
|
-
|
|
1062
|
+
return new CustomRefImpl(factory);
|
|
1111
1063
|
}
|
|
1112
1064
|
function toRefs(object) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1065
|
+
if (process.env.NODE_ENV !== "production" && !isProxy(object)) {
|
|
1066
|
+
console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
1067
|
+
}
|
|
1068
|
+
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1069
|
+
for (const key in object) {
|
|
1070
|
+
ret[key] = toRef(object, key);
|
|
1071
|
+
}
|
|
1072
|
+
return ret;
|
|
1121
1073
|
}
|
|
1122
1074
|
class ObjectRefImpl {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1075
|
+
constructor(_object, _key, _defaultValue) {
|
|
1076
|
+
this._object = _object;
|
|
1077
|
+
this._key = _key;
|
|
1078
|
+
this._defaultValue = _defaultValue;
|
|
1079
|
+
this.__v_isRef = true;
|
|
1080
|
+
}
|
|
1081
|
+
get value() {
|
|
1082
|
+
const val = this._object[this._key];
|
|
1083
|
+
return val === void 0 ? this._defaultValue : val;
|
|
1084
|
+
}
|
|
1085
|
+
set value(newVal) {
|
|
1086
|
+
this._object[this._key] = newVal;
|
|
1087
|
+
}
|
|
1088
|
+
get dep() {
|
|
1089
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1090
|
+
}
|
|
1139
1091
|
}
|
|
1140
1092
|
function toRef(object, key, defaultValue) {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
? val
|
|
1144
|
-
: new ObjectRefImpl(object, key, defaultValue);
|
|
1093
|
+
const val = object[key];
|
|
1094
|
+
return isRef(val) ? val : new ObjectRefImpl(object, key, defaultValue);
|
|
1145
1095
|
}
|
|
1146
1096
|
|
|
1147
|
-
var _a$1;
|
|
1148
1097
|
class ComputedRefImpl {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1098
|
+
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1099
|
+
this._setter = _setter;
|
|
1100
|
+
this.dep = void 0;
|
|
1101
|
+
this.__v_isRef = true;
|
|
1102
|
+
this["__v_isReadonly"] = false;
|
|
1103
|
+
this._dirty = true;
|
|
1104
|
+
this.effect = new ReactiveEffect(getter, () => {
|
|
1105
|
+
if (!this._dirty) {
|
|
1154
1106
|
this._dirty = true;
|
|
1155
|
-
this
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
}
|
|
1175
|
-
set value(newValue) {
|
|
1176
|
-
this._setter(newValue);
|
|
1177
|
-
}
|
|
1107
|
+
triggerRefValue(this);
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
this.effect.computed = this;
|
|
1111
|
+
this.effect.active = this._cacheable = !isSSR;
|
|
1112
|
+
this["__v_isReadonly"] = isReadonly;
|
|
1113
|
+
}
|
|
1114
|
+
get value() {
|
|
1115
|
+
const self = toRaw(this);
|
|
1116
|
+
trackRefValue(self);
|
|
1117
|
+
if (self._dirty || !self._cacheable) {
|
|
1118
|
+
self._dirty = false;
|
|
1119
|
+
self._value = self.effect.run();
|
|
1120
|
+
}
|
|
1121
|
+
return self._value;
|
|
1122
|
+
}
|
|
1123
|
+
set value(newValue) {
|
|
1124
|
+
this._setter(newValue);
|
|
1125
|
+
}
|
|
1178
1126
|
}
|
|
1179
|
-
_a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1180
1127
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1200
|
-
}
|
|
1201
|
-
return cRef;
|
|
1128
|
+
let getter;
|
|
1129
|
+
let setter;
|
|
1130
|
+
const onlyGetter = isFunction(getterOrOptions);
|
|
1131
|
+
if (onlyGetter) {
|
|
1132
|
+
getter = getterOrOptions;
|
|
1133
|
+
setter = process.env.NODE_ENV !== "production" ? () => {
|
|
1134
|
+
console.warn("Write operation failed: computed value is readonly");
|
|
1135
|
+
} : NOOP;
|
|
1136
|
+
} else {
|
|
1137
|
+
getter = getterOrOptions.get;
|
|
1138
|
+
setter = getterOrOptions.set;
|
|
1139
|
+
}
|
|
1140
|
+
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1141
|
+
if (process.env.NODE_ENV !== "production" && debugOptions && !isSSR) {
|
|
1142
|
+
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1143
|
+
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1144
|
+
}
|
|
1145
|
+
return cRef;
|
|
1202
1146
|
}
|
|
1203
1147
|
|
|
1204
|
-
|
|
1205
|
-
const tick = /*#__PURE__*/ Promise.resolve();
|
|
1148
|
+
const tick = /* @__PURE__ */ Promise.resolve();
|
|
1206
1149
|
const queue = [];
|
|
1207
1150
|
let queued = false;
|
|
1208
1151
|
const scheduler = (fn) => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1152
|
+
queue.push(fn);
|
|
1153
|
+
if (!queued) {
|
|
1154
|
+
queued = true;
|
|
1155
|
+
tick.then(flush);
|
|
1156
|
+
}
|
|
1214
1157
|
};
|
|
1215
1158
|
const flush = () => {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1159
|
+
for (let i = 0; i < queue.length; i++) {
|
|
1160
|
+
queue[i]();
|
|
1161
|
+
}
|
|
1162
|
+
queue.length = 0;
|
|
1163
|
+
queued = false;
|
|
1221
1164
|
};
|
|
1222
1165
|
class DeferredComputedRefImpl {
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
triggerRefValue(this);
|
|
1244
|
-
}
|
|
1245
|
-
scheduled = false;
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
// chained upstream computeds are notified synchronously to ensure
|
|
1249
|
-
// value invalidation in case of sync access; normal effects are
|
|
1250
|
-
// deferred to be triggered in scheduler.
|
|
1251
|
-
for (const e of this.dep) {
|
|
1252
|
-
if (e.computed instanceof DeferredComputedRefImpl) {
|
|
1253
|
-
e.scheduler(true /* computedTrigger */);
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1166
|
+
constructor(getter) {
|
|
1167
|
+
this.dep = void 0;
|
|
1168
|
+
this._dirty = true;
|
|
1169
|
+
this.__v_isRef = true;
|
|
1170
|
+
this["__v_isReadonly"] = true;
|
|
1171
|
+
let compareTarget;
|
|
1172
|
+
let hasCompareTarget = false;
|
|
1173
|
+
let scheduled = false;
|
|
1174
|
+
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
|
|
1175
|
+
if (this.dep) {
|
|
1176
|
+
if (computedTrigger) {
|
|
1177
|
+
compareTarget = this._value;
|
|
1178
|
+
hasCompareTarget = true;
|
|
1179
|
+
} else if (!scheduled) {
|
|
1180
|
+
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
|
|
1181
|
+
scheduled = true;
|
|
1182
|
+
hasCompareTarget = false;
|
|
1183
|
+
scheduler(() => {
|
|
1184
|
+
if (this.effect.active && this._get() !== valueToCompare) {
|
|
1185
|
+
triggerRefValue(this);
|
|
1256
1186
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
this.effect.computed = this;
|
|
1260
|
-
}
|
|
1261
|
-
_get() {
|
|
1262
|
-
if (this._dirty) {
|
|
1263
|
-
this._dirty = false;
|
|
1264
|
-
return (this._value = this.effect.run());
|
|
1187
|
+
scheduled = false;
|
|
1188
|
+
});
|
|
1265
1189
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1190
|
+
for (const e of this.dep) {
|
|
1191
|
+
if (e.computed instanceof DeferredComputedRefImpl) {
|
|
1192
|
+
e.scheduler(
|
|
1193
|
+
true
|
|
1194
|
+
/* computedTrigger */
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
this._dirty = true;
|
|
1200
|
+
});
|
|
1201
|
+
this.effect.computed = this;
|
|
1202
|
+
}
|
|
1203
|
+
_get() {
|
|
1204
|
+
if (this._dirty) {
|
|
1205
|
+
this._dirty = false;
|
|
1206
|
+
return this._value = this.effect.run();
|
|
1207
|
+
}
|
|
1208
|
+
return this._value;
|
|
1209
|
+
}
|
|
1210
|
+
get value() {
|
|
1211
|
+
trackRefValue(this);
|
|
1212
|
+
return toRaw(this)._get();
|
|
1213
|
+
}
|
|
1273
1214
|
}
|
|
1274
|
-
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1275
1215
|
function deferredComputed(getter) {
|
|
1276
|
-
|
|
1216
|
+
return new DeferredComputedRefImpl(getter);
|
|
1277
1217
|
}
|
|
1278
1218
|
|
|
1279
1219
|
export { EffectScope, ITERATE_KEY, ReactiveEffect, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
|