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