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