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