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