@vue/reactivity 3.6.0-beta.4 → 3.6.0-beta.6
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 +1761 -1878
- package/dist/reactivity.cjs.prod.js +1652 -1687
- package/dist/reactivity.d.ts +622 -624
- package/dist/reactivity.esm-browser.js +1805 -1889
- package/dist/reactivity.esm-browser.prod.js +5 -4
- package/dist/reactivity.esm-bundler.js +1761 -1885
- package/dist/reactivity.global.js +2048 -2133
- package/dist/reactivity.global.prod.js +5 -4
- package/package.json +2 -2
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.6.0-beta.
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
|
|
2
|
+
* @vue/reactivity v3.6.0-beta.6
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
//#region packages/shared/src/makeMap.ts
|
|
7
|
+
/**
|
|
8
|
+
* Make a map and return a function for checking if a key
|
|
9
|
+
* is in that map.
|
|
10
|
+
* IMPORTANT: all calls of this function must be prefixed with
|
|
11
|
+
* \/\*#\_\_PURE\_\_\*\/
|
|
12
|
+
* So that they can be tree-shaken if necessary.
|
|
13
|
+
*/
|
|
14
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
7
15
|
function makeMap(str) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
const map = Object.create(null);
|
|
17
|
+
for (const key of str.split(",")) map[key] = 1;
|
|
18
|
+
return (val) => val in map;
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region packages/shared/src/general.ts
|
|
23
|
+
const EMPTY_OBJ = Object.freeze({});
|
|
24
|
+
const EMPTY_ARR = Object.freeze([]);
|
|
25
|
+
const NOOP = () => {};
|
|
16
26
|
const extend = Object.assign;
|
|
17
27
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
18
28
|
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
@@ -26,44 +36,109 @@ const isObject = (val) => val !== null && typeof val === "object";
|
|
|
26
36
|
const objectToString = Object.prototype.toString;
|
|
27
37
|
const toTypeString = (value) => objectToString.call(value);
|
|
28
38
|
const toRawType = (value) => {
|
|
29
|
-
|
|
39
|
+
return toTypeString(value).slice(8, -1);
|
|
30
40
|
};
|
|
31
41
|
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
32
42
|
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
33
43
|
const cacheStringFunction = (fn) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
44
|
+
const cache = Object.create(null);
|
|
45
|
+
return ((str) => {
|
|
46
|
+
return cache[str] || (cache[str] = fn(str));
|
|
47
|
+
});
|
|
39
48
|
};
|
|
49
|
+
const camelizeRE = /-(\w)/g;
|
|
50
|
+
const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
|
|
51
|
+
/**
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
const camelize = cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
|
|
55
|
+
const hyphenateRE = /\B([A-Z])/g;
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
60
|
+
/**
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
40
63
|
const capitalize = cacheStringFunction((str) => {
|
|
41
|
-
|
|
64
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
const toHandlerKey = cacheStringFunction((str) => {
|
|
70
|
+
return str ? `on${capitalize(str)}` : ``;
|
|
42
71
|
});
|
|
43
72
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
44
73
|
const def = (obj, key, value, writable = false) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
74
|
+
Object.defineProperty(obj, key, {
|
|
75
|
+
configurable: true,
|
|
76
|
+
enumerable: false,
|
|
77
|
+
writable,
|
|
78
|
+
value
|
|
79
|
+
});
|
|
51
80
|
};
|
|
52
81
|
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region packages/reactivity/src/debug.ts
|
|
84
|
+
const triggerEventInfos = [];
|
|
85
|
+
function onTrack(sub, debugInfo) {
|
|
86
|
+
if (sub.onTrack) sub.onTrack(extend({ effect: sub }, debugInfo));
|
|
87
|
+
}
|
|
88
|
+
function onTrigger(sub) {
|
|
89
|
+
if (sub.onTrigger) {
|
|
90
|
+
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
91
|
+
sub.onTrigger(extend({ effect: sub }, debugInfo));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function setupOnTrigger(target) {
|
|
95
|
+
Object.defineProperty(target.prototype, "onTrigger", {
|
|
96
|
+
get() {
|
|
97
|
+
return this._onTrigger;
|
|
98
|
+
},
|
|
99
|
+
set(val) {
|
|
100
|
+
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
101
|
+
this._onTrigger = val;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function setupFlagsHandler(target) {
|
|
106
|
+
target._flags = target.flags;
|
|
107
|
+
Object.defineProperty(target, "flags", {
|
|
108
|
+
get() {
|
|
109
|
+
return target._flags;
|
|
110
|
+
},
|
|
111
|
+
set(value) {
|
|
112
|
+
if (!(target._flags & 48) && !!(value & 48)) onTrigger(this);
|
|
113
|
+
target._flags = value;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region packages/reactivity/src/warning.ts
|
|
53
120
|
function warn(msg, ...args) {
|
|
54
|
-
|
|
121
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
55
122
|
}
|
|
56
123
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region packages/reactivity/src/system.ts
|
|
126
|
+
const ReactiveFlags$1 = {
|
|
127
|
+
"None": 0,
|
|
128
|
+
"0": "None",
|
|
129
|
+
"Mutable": 1,
|
|
130
|
+
"1": "Mutable",
|
|
131
|
+
"Watching": 2,
|
|
132
|
+
"2": "Watching",
|
|
133
|
+
"RecursedCheck": 4,
|
|
134
|
+
"4": "RecursedCheck",
|
|
135
|
+
"Recursed": 8,
|
|
136
|
+
"8": "Recursed",
|
|
137
|
+
"Dirty": 16,
|
|
138
|
+
"16": "Dirty",
|
|
139
|
+
"Pending": 32,
|
|
140
|
+
"32": "Pending"
|
|
141
|
+
};
|
|
67
142
|
const notifyBuffer = [];
|
|
68
143
|
let batchDepth = 0;
|
|
69
144
|
let activeSub = void 0;
|
|
@@ -71,2023 +146,1864 @@ let globalVersion = 0;
|
|
|
71
146
|
let notifyIndex = 0;
|
|
72
147
|
let notifyBufferLength = 0;
|
|
73
148
|
function setActiveSub(sub) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
149
|
+
try {
|
|
150
|
+
return activeSub;
|
|
151
|
+
} finally {
|
|
152
|
+
activeSub = sub;
|
|
153
|
+
}
|
|
79
154
|
}
|
|
80
155
|
function startBatch() {
|
|
81
|
-
|
|
156
|
+
++batchDepth;
|
|
82
157
|
}
|
|
83
158
|
function endBatch() {
|
|
84
|
-
|
|
85
|
-
flush();
|
|
86
|
-
}
|
|
159
|
+
if (!--batchDepth && notifyBufferLength) flush();
|
|
87
160
|
}
|
|
88
161
|
function link(dep, sub) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
if (flags & 1 /* Mutable */) {
|
|
183
|
-
const subSubs = sub.subs;
|
|
184
|
-
if (subSubs !== void 0) {
|
|
185
|
-
link2 = subSubs;
|
|
186
|
-
if (subSubs.nextSub !== void 0) {
|
|
187
|
-
stack = { value: next, prev: stack };
|
|
188
|
-
next = link2.nextSub;
|
|
189
|
-
}
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if ((link2 = next) !== void 0) {
|
|
195
|
-
next = link2.nextSub;
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
while (stack !== void 0) {
|
|
199
|
-
link2 = stack.value;
|
|
200
|
-
stack = stack.prev;
|
|
201
|
-
if (link2 !== void 0) {
|
|
202
|
-
next = link2.nextSub;
|
|
203
|
-
continue top;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
break;
|
|
207
|
-
} while (true);
|
|
162
|
+
const prevDep = sub.depsTail;
|
|
163
|
+
if (prevDep !== void 0 && prevDep.dep === dep) return;
|
|
164
|
+
const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
165
|
+
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
166
|
+
nextDep.version = globalVersion;
|
|
167
|
+
sub.depsTail = nextDep;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const prevSub = dep.subsTail;
|
|
171
|
+
if (prevSub !== void 0 && prevSub.version === globalVersion && prevSub.sub === sub) return;
|
|
172
|
+
const newLink = sub.depsTail = dep.subsTail = {
|
|
173
|
+
version: globalVersion,
|
|
174
|
+
dep,
|
|
175
|
+
sub,
|
|
176
|
+
prevDep,
|
|
177
|
+
nextDep,
|
|
178
|
+
prevSub,
|
|
179
|
+
nextSub: void 0
|
|
180
|
+
};
|
|
181
|
+
if (nextDep !== void 0) nextDep.prevDep = newLink;
|
|
182
|
+
if (prevDep !== void 0) prevDep.nextDep = newLink;
|
|
183
|
+
else sub.deps = newLink;
|
|
184
|
+
if (prevSub !== void 0) prevSub.nextSub = newLink;
|
|
185
|
+
else dep.subs = newLink;
|
|
186
|
+
}
|
|
187
|
+
function unlink(link, sub = link.sub) {
|
|
188
|
+
const dep = link.dep;
|
|
189
|
+
const prevDep = link.prevDep;
|
|
190
|
+
const nextDep = link.nextDep;
|
|
191
|
+
const nextSub = link.nextSub;
|
|
192
|
+
const prevSub = link.prevSub;
|
|
193
|
+
if (nextDep !== void 0) nextDep.prevDep = prevDep;
|
|
194
|
+
else sub.depsTail = prevDep;
|
|
195
|
+
if (prevDep !== void 0) prevDep.nextDep = nextDep;
|
|
196
|
+
else sub.deps = nextDep;
|
|
197
|
+
if (nextSub !== void 0) nextSub.prevSub = prevSub;
|
|
198
|
+
else dep.subsTail = prevSub;
|
|
199
|
+
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
200
|
+
else if ((dep.subs = nextSub) === void 0) {
|
|
201
|
+
let toRemove = dep.deps;
|
|
202
|
+
if (toRemove !== void 0) {
|
|
203
|
+
do
|
|
204
|
+
toRemove = unlink(toRemove, dep);
|
|
205
|
+
while (toRemove !== void 0);
|
|
206
|
+
dep.flags |= 16;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return nextDep;
|
|
210
|
+
}
|
|
211
|
+
function propagate(link) {
|
|
212
|
+
let next = link.nextSub;
|
|
213
|
+
let stack;
|
|
214
|
+
top: do {
|
|
215
|
+
const sub = link.sub;
|
|
216
|
+
let flags = sub.flags;
|
|
217
|
+
if (flags & 3) {
|
|
218
|
+
if (!(flags & 60)) sub.flags = flags | 32;
|
|
219
|
+
else if (!(flags & 12)) flags = 0;
|
|
220
|
+
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
221
|
+
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
222
|
+
sub.flags = flags | 40;
|
|
223
|
+
flags &= 1;
|
|
224
|
+
} else flags = 0;
|
|
225
|
+
if (flags & 2) notifyBuffer[notifyBufferLength++] = sub;
|
|
226
|
+
if (flags & 1) {
|
|
227
|
+
const subSubs = sub.subs;
|
|
228
|
+
if (subSubs !== void 0) {
|
|
229
|
+
link = subSubs;
|
|
230
|
+
if (subSubs.nextSub !== void 0) {
|
|
231
|
+
stack = {
|
|
232
|
+
value: next,
|
|
233
|
+
prev: stack
|
|
234
|
+
};
|
|
235
|
+
next = link.nextSub;
|
|
236
|
+
}
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if ((link = next) !== void 0) {
|
|
242
|
+
next = link.nextSub;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
while (stack !== void 0) {
|
|
246
|
+
link = stack.value;
|
|
247
|
+
stack = stack.prev;
|
|
248
|
+
if (link !== void 0) {
|
|
249
|
+
next = link.nextSub;
|
|
250
|
+
continue top;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
} while (true);
|
|
208
255
|
}
|
|
209
256
|
function startTracking(sub) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
257
|
+
++globalVersion;
|
|
258
|
+
sub.depsTail = void 0;
|
|
259
|
+
sub.flags = sub.flags & -57 | 4;
|
|
260
|
+
return setActiveSub(sub);
|
|
214
261
|
}
|
|
215
262
|
function endTracking(sub, prevSub) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const depsTail = sub.depsTail;
|
|
223
|
-
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
224
|
-
while (toRemove !== void 0) {
|
|
225
|
-
toRemove = unlink(toRemove, sub);
|
|
226
|
-
}
|
|
227
|
-
sub.flags &= -5 /* RecursedCheck */;
|
|
263
|
+
if (activeSub !== sub) warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
|
|
264
|
+
activeSub = prevSub;
|
|
265
|
+
const depsTail = sub.depsTail;
|
|
266
|
+
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
267
|
+
while (toRemove !== void 0) toRemove = unlink(toRemove, sub);
|
|
268
|
+
sub.flags &= -5;
|
|
228
269
|
}
|
|
229
270
|
function flush() {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
function checkDirty(
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
function shallowPropagate(link2) {
|
|
300
|
-
do {
|
|
301
|
-
const sub = link2.sub;
|
|
302
|
-
const nextSub = link2.nextSub;
|
|
303
|
-
const subFlags = sub.flags;
|
|
304
|
-
if ((subFlags & (32 /* Pending */ | 16 /* Dirty */)) === 32 /* Pending */) {
|
|
305
|
-
sub.flags = subFlags | 16 /* Dirty */;
|
|
306
|
-
}
|
|
307
|
-
link2 = nextSub;
|
|
308
|
-
} while (link2 !== void 0);
|
|
271
|
+
while (notifyIndex < notifyBufferLength) {
|
|
272
|
+
const effect = notifyBuffer[notifyIndex];
|
|
273
|
+
notifyBuffer[notifyIndex++] = void 0;
|
|
274
|
+
effect.notify();
|
|
275
|
+
}
|
|
276
|
+
notifyIndex = 0;
|
|
277
|
+
notifyBufferLength = 0;
|
|
278
|
+
}
|
|
279
|
+
function checkDirty(link, sub) {
|
|
280
|
+
let stack;
|
|
281
|
+
let checkDepth = 0;
|
|
282
|
+
top: do {
|
|
283
|
+
const dep = link.dep;
|
|
284
|
+
const depFlags = dep.flags;
|
|
285
|
+
let dirty = false;
|
|
286
|
+
if (sub.flags & 16) dirty = true;
|
|
287
|
+
else if ((depFlags & 17) === 17) {
|
|
288
|
+
if (dep.update()) {
|
|
289
|
+
const subs = dep.subs;
|
|
290
|
+
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
291
|
+
dirty = true;
|
|
292
|
+
}
|
|
293
|
+
} else if ((depFlags & 33) === 33) {
|
|
294
|
+
if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
|
|
295
|
+
value: link,
|
|
296
|
+
prev: stack
|
|
297
|
+
};
|
|
298
|
+
link = dep.deps;
|
|
299
|
+
sub = dep;
|
|
300
|
+
++checkDepth;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (!dirty && link.nextDep !== void 0) {
|
|
304
|
+
link = link.nextDep;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
while (checkDepth) {
|
|
308
|
+
--checkDepth;
|
|
309
|
+
const firstSub = sub.subs;
|
|
310
|
+
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
311
|
+
if (hasMultipleSubs) {
|
|
312
|
+
link = stack.value;
|
|
313
|
+
stack = stack.prev;
|
|
314
|
+
} else link = firstSub;
|
|
315
|
+
if (dirty) {
|
|
316
|
+
if (sub.update()) {
|
|
317
|
+
if (hasMultipleSubs) shallowPropagate(firstSub);
|
|
318
|
+
sub = link.sub;
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
} else sub.flags &= -33;
|
|
322
|
+
sub = link.sub;
|
|
323
|
+
if (link.nextDep !== void 0) {
|
|
324
|
+
link = link.nextDep;
|
|
325
|
+
continue top;
|
|
326
|
+
}
|
|
327
|
+
dirty = false;
|
|
328
|
+
}
|
|
329
|
+
return dirty;
|
|
330
|
+
} while (true);
|
|
331
|
+
}
|
|
332
|
+
function shallowPropagate(link) {
|
|
333
|
+
do {
|
|
334
|
+
const sub = link.sub;
|
|
335
|
+
const nextSub = link.nextSub;
|
|
336
|
+
const subFlags = sub.flags;
|
|
337
|
+
if ((subFlags & 48) === 32) sub.flags = subFlags | 16;
|
|
338
|
+
link = nextSub;
|
|
339
|
+
} while (link !== void 0);
|
|
309
340
|
}
|
|
310
341
|
function isValidLink(checkLink, sub) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const triggerEventInfos = [];
|
|
322
|
-
function onTrack(sub, debugInfo) {
|
|
323
|
-
if (sub.onTrack) {
|
|
324
|
-
sub.onTrack(
|
|
325
|
-
extend(
|
|
326
|
-
{
|
|
327
|
-
effect: sub
|
|
328
|
-
},
|
|
329
|
-
debugInfo
|
|
330
|
-
)
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
function onTrigger(sub) {
|
|
335
|
-
if (sub.onTrigger) {
|
|
336
|
-
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
337
|
-
sub.onTrigger(
|
|
338
|
-
extend(
|
|
339
|
-
{
|
|
340
|
-
effect: sub
|
|
341
|
-
},
|
|
342
|
-
debugInfo
|
|
343
|
-
)
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
function setupOnTrigger(target) {
|
|
348
|
-
Object.defineProperty(target.prototype, "onTrigger", {
|
|
349
|
-
get() {
|
|
350
|
-
return this._onTrigger;
|
|
351
|
-
},
|
|
352
|
-
set(val) {
|
|
353
|
-
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
354
|
-
this._onTrigger = val;
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
function setupFlagsHandler(target) {
|
|
359
|
-
target._flags = target.flags;
|
|
360
|
-
Object.defineProperty(target, "flags", {
|
|
361
|
-
get() {
|
|
362
|
-
return target._flags;
|
|
363
|
-
},
|
|
364
|
-
set(value) {
|
|
365
|
-
if (!(target._flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) && !!(value & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending))) {
|
|
366
|
-
onTrigger(this);
|
|
367
|
-
}
|
|
368
|
-
target._flags = value;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
342
|
+
let link = sub.depsTail;
|
|
343
|
+
while (link !== void 0) {
|
|
344
|
+
if (link === checkLink) return true;
|
|
345
|
+
link = link.prevDep;
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
371
348
|
}
|
|
372
349
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region packages/reactivity/src/dep.ts
|
|
352
|
+
var Dep = class {
|
|
353
|
+
constructor(map, key) {
|
|
354
|
+
this.map = map;
|
|
355
|
+
this.key = key;
|
|
356
|
+
this._subs = void 0;
|
|
357
|
+
this.subsTail = void 0;
|
|
358
|
+
this.flags = 0;
|
|
359
|
+
}
|
|
360
|
+
get subs() {
|
|
361
|
+
return this._subs;
|
|
362
|
+
}
|
|
363
|
+
set subs(value) {
|
|
364
|
+
this._subs = value;
|
|
365
|
+
if (value === void 0) this.map.delete(this.key);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
391
368
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
392
|
-
const ITERATE_KEY =
|
|
393
|
-
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
369
|
+
const ITERATE_KEY = Symbol("Object iterate");
|
|
370
|
+
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
|
|
371
|
+
const ARRAY_ITERATE_KEY = Symbol("Array iterate");
|
|
372
|
+
/**
|
|
373
|
+
* Tracks access to a reactive property.
|
|
374
|
+
*
|
|
375
|
+
* This will check which effect is running at the moment and record it as dep
|
|
376
|
+
* which records all effects that depend on the reactive property.
|
|
377
|
+
*
|
|
378
|
+
* @param target - Object holding the reactive property.
|
|
379
|
+
* @param type - Defines the type of access to the reactive property.
|
|
380
|
+
* @param key - Identifier of the reactive property to track.
|
|
381
|
+
*/
|
|
401
382
|
function track(target, type, key) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
type,
|
|
415
|
-
key
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
link(dep, activeSub);
|
|
419
|
-
}
|
|
383
|
+
if (activeSub !== void 0) {
|
|
384
|
+
let depsMap = targetMap.get(target);
|
|
385
|
+
if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
386
|
+
let dep = depsMap.get(key);
|
|
387
|
+
if (!dep) depsMap.set(key, dep = new Dep(depsMap, key));
|
|
388
|
+
onTrack(activeSub, {
|
|
389
|
+
target,
|
|
390
|
+
type,
|
|
391
|
+
key
|
|
392
|
+
});
|
|
393
|
+
link(dep, activeSub);
|
|
394
|
+
}
|
|
420
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Finds all deps associated with the target (or a specific property) and
|
|
398
|
+
* triggers the effects stored within.
|
|
399
|
+
*
|
|
400
|
+
* @param target - The reactive object.
|
|
401
|
+
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
402
|
+
* @param key - Can be used to target a specific reactive property in the target object.
|
|
403
|
+
*/
|
|
421
404
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
} else if (isArrayIndex) {
|
|
473
|
-
run(depsMap.get("length"));
|
|
474
|
-
}
|
|
475
|
-
break;
|
|
476
|
-
case "delete":
|
|
477
|
-
if (!targetIsArray) {
|
|
478
|
-
run(depsMap.get(ITERATE_KEY));
|
|
479
|
-
if (isMap(target)) {
|
|
480
|
-
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
break;
|
|
484
|
-
case "set":
|
|
485
|
-
if (isMap(target)) {
|
|
486
|
-
run(depsMap.get(ITERATE_KEY));
|
|
487
|
-
}
|
|
488
|
-
break;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
endBatch();
|
|
405
|
+
const depsMap = targetMap.get(target);
|
|
406
|
+
if (!depsMap) return;
|
|
407
|
+
const run = (dep) => {
|
|
408
|
+
if (dep !== void 0 && dep.subs !== void 0) {
|
|
409
|
+
triggerEventInfos.push({
|
|
410
|
+
target,
|
|
411
|
+
type,
|
|
412
|
+
key,
|
|
413
|
+
newValue,
|
|
414
|
+
oldValue,
|
|
415
|
+
oldTarget
|
|
416
|
+
});
|
|
417
|
+
propagate(dep.subs);
|
|
418
|
+
shallowPropagate(dep.subs);
|
|
419
|
+
triggerEventInfos.pop();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
startBatch();
|
|
423
|
+
if (type === "clear") depsMap.forEach(run);
|
|
424
|
+
else {
|
|
425
|
+
const targetIsArray = isArray(target);
|
|
426
|
+
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
427
|
+
if (targetIsArray && key === "length") {
|
|
428
|
+
const newLength = Number(newValue);
|
|
429
|
+
depsMap.forEach((dep, key) => {
|
|
430
|
+
if (key === "length" || key === ARRAY_ITERATE_KEY || !isSymbol(key) && key >= newLength) run(dep);
|
|
431
|
+
});
|
|
432
|
+
} else {
|
|
433
|
+
if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
|
|
434
|
+
if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
435
|
+
switch (type) {
|
|
436
|
+
case "add":
|
|
437
|
+
if (!targetIsArray) {
|
|
438
|
+
run(depsMap.get(ITERATE_KEY));
|
|
439
|
+
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
440
|
+
} else if (isArrayIndex) run(depsMap.get("length"));
|
|
441
|
+
break;
|
|
442
|
+
case "delete":
|
|
443
|
+
if (!targetIsArray) {
|
|
444
|
+
run(depsMap.get(ITERATE_KEY));
|
|
445
|
+
if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
446
|
+
}
|
|
447
|
+
break;
|
|
448
|
+
case "set":
|
|
449
|
+
if (isMap(target)) run(depsMap.get(ITERATE_KEY));
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
endBatch();
|
|
493
455
|
}
|
|
494
456
|
function getDepFromReactive(object, key) {
|
|
495
|
-
|
|
496
|
-
|
|
457
|
+
const depMap = targetMap.get(object);
|
|
458
|
+
return depMap && depMap.get(key);
|
|
497
459
|
}
|
|
498
460
|
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region packages/reactivity/src/arrayInstrumentations.ts
|
|
463
|
+
/**
|
|
464
|
+
* Track array iteration and return:
|
|
465
|
+
* - if input is reactive: a cloned raw array with reactive values
|
|
466
|
+
* - if input is non-reactive or shallowReactive: the original raw array
|
|
467
|
+
*/
|
|
499
468
|
function reactiveReadArray(array) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
469
|
+
const raw = /* @__PURE__ */ toRaw(array);
|
|
470
|
+
if (raw === array) return raw;
|
|
471
|
+
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
472
|
+
return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
|
|
504
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Track array iteration and return raw array
|
|
476
|
+
*/
|
|
505
477
|
function shallowReadArray(arr) {
|
|
506
|
-
|
|
507
|
-
|
|
478
|
+
track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
479
|
+
return arr;
|
|
508
480
|
}
|
|
509
481
|
function toWrapped(target, item) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
return toReactive(item);
|
|
482
|
+
if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
|
|
483
|
+
return toReactive(item);
|
|
514
484
|
}
|
|
515
485
|
const arrayInstrumentations = {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
},
|
|
602
|
-
shift() {
|
|
603
|
-
return noTracking(this, "shift");
|
|
604
|
-
},
|
|
605
|
-
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
|
606
|
-
some(fn, thisArg) {
|
|
607
|
-
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
608
|
-
},
|
|
609
|
-
splice(...args) {
|
|
610
|
-
return noTracking(this, "splice", args);
|
|
611
|
-
},
|
|
612
|
-
toReversed() {
|
|
613
|
-
return reactiveReadArray(this).toReversed();
|
|
614
|
-
},
|
|
615
|
-
toSorted(comparer) {
|
|
616
|
-
return reactiveReadArray(this).toSorted(comparer);
|
|
617
|
-
},
|
|
618
|
-
toSpliced(...args) {
|
|
619
|
-
return reactiveReadArray(this).toSpliced(...args);
|
|
620
|
-
},
|
|
621
|
-
unshift(...args) {
|
|
622
|
-
return noTracking(this, "unshift", args);
|
|
623
|
-
},
|
|
624
|
-
values() {
|
|
625
|
-
return iterator(this, "values", (item) => toWrapped(this, item));
|
|
626
|
-
}
|
|
486
|
+
__proto__: null,
|
|
487
|
+
[Symbol.iterator]() {
|
|
488
|
+
return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
|
|
489
|
+
},
|
|
490
|
+
concat(...args) {
|
|
491
|
+
return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
|
|
492
|
+
},
|
|
493
|
+
entries() {
|
|
494
|
+
return iterator(this, "entries", (value) => {
|
|
495
|
+
value[1] = toWrapped(this, value[1]);
|
|
496
|
+
return value;
|
|
497
|
+
});
|
|
498
|
+
},
|
|
499
|
+
every(fn, thisArg) {
|
|
500
|
+
return apply(this, "every", fn, thisArg, void 0, arguments);
|
|
501
|
+
},
|
|
502
|
+
filter(fn, thisArg) {
|
|
503
|
+
return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
|
|
504
|
+
},
|
|
505
|
+
find(fn, thisArg) {
|
|
506
|
+
return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
507
|
+
},
|
|
508
|
+
findIndex(fn, thisArg) {
|
|
509
|
+
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
510
|
+
},
|
|
511
|
+
findLast(fn, thisArg) {
|
|
512
|
+
return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
513
|
+
},
|
|
514
|
+
findLastIndex(fn, thisArg) {
|
|
515
|
+
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
516
|
+
},
|
|
517
|
+
forEach(fn, thisArg) {
|
|
518
|
+
return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
|
519
|
+
},
|
|
520
|
+
includes(...args) {
|
|
521
|
+
return searchProxy(this, "includes", args);
|
|
522
|
+
},
|
|
523
|
+
indexOf(...args) {
|
|
524
|
+
return searchProxy(this, "indexOf", args);
|
|
525
|
+
},
|
|
526
|
+
join(separator) {
|
|
527
|
+
return reactiveReadArray(this).join(separator);
|
|
528
|
+
},
|
|
529
|
+
lastIndexOf(...args) {
|
|
530
|
+
return searchProxy(this, "lastIndexOf", args);
|
|
531
|
+
},
|
|
532
|
+
map(fn, thisArg) {
|
|
533
|
+
return apply(this, "map", fn, thisArg, void 0, arguments);
|
|
534
|
+
},
|
|
535
|
+
pop() {
|
|
536
|
+
return noTracking(this, "pop");
|
|
537
|
+
},
|
|
538
|
+
push(...args) {
|
|
539
|
+
return noTracking(this, "push", args);
|
|
540
|
+
},
|
|
541
|
+
reduce(fn, ...args) {
|
|
542
|
+
return reduce(this, "reduce", fn, args);
|
|
543
|
+
},
|
|
544
|
+
reduceRight(fn, ...args) {
|
|
545
|
+
return reduce(this, "reduceRight", fn, args);
|
|
546
|
+
},
|
|
547
|
+
shift() {
|
|
548
|
+
return noTracking(this, "shift");
|
|
549
|
+
},
|
|
550
|
+
some(fn, thisArg) {
|
|
551
|
+
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
552
|
+
},
|
|
553
|
+
splice(...args) {
|
|
554
|
+
return noTracking(this, "splice", args);
|
|
555
|
+
},
|
|
556
|
+
toReversed() {
|
|
557
|
+
return reactiveReadArray(this).toReversed();
|
|
558
|
+
},
|
|
559
|
+
toSorted(comparer) {
|
|
560
|
+
return reactiveReadArray(this).toSorted(comparer);
|
|
561
|
+
},
|
|
562
|
+
toSpliced(...args) {
|
|
563
|
+
return reactiveReadArray(this).toSpliced(...args);
|
|
564
|
+
},
|
|
565
|
+
unshift(...args) {
|
|
566
|
+
return noTracking(this, "unshift", args);
|
|
567
|
+
},
|
|
568
|
+
values() {
|
|
569
|
+
return iterator(this, "values", (item) => toWrapped(this, item));
|
|
570
|
+
}
|
|
627
571
|
};
|
|
628
572
|
function iterator(self, method, wrapValue) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
return iter;
|
|
573
|
+
const arr = shallowReadArray(self);
|
|
574
|
+
const iter = arr[method]();
|
|
575
|
+
if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
|
|
576
|
+
iter._next = iter.next;
|
|
577
|
+
iter.next = () => {
|
|
578
|
+
const result = iter._next();
|
|
579
|
+
if (!result.done) result.value = wrapValue(result.value);
|
|
580
|
+
return result;
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
return iter;
|
|
642
584
|
}
|
|
643
585
|
const arrayProto = Array.prototype;
|
|
644
586
|
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
}
|
|
664
|
-
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
665
|
-
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
587
|
+
const arr = shallowReadArray(self);
|
|
588
|
+
const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
|
|
589
|
+
const methodFn = arr[method];
|
|
590
|
+
if (methodFn !== arrayProto[method]) {
|
|
591
|
+
const result = methodFn.apply(self, args);
|
|
592
|
+
return needsWrap ? toReactive(result) : result;
|
|
593
|
+
}
|
|
594
|
+
let wrappedFn = fn;
|
|
595
|
+
if (arr !== self) {
|
|
596
|
+
if (needsWrap) wrappedFn = function(item, index) {
|
|
597
|
+
return fn.call(this, toWrapped(self, item), index, self);
|
|
598
|
+
};
|
|
599
|
+
else if (fn.length > 2) wrappedFn = function(item, index) {
|
|
600
|
+
return fn.call(this, item, index, self);
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
604
|
+
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
666
605
|
}
|
|
667
606
|
function reduce(self, method, fn, args) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return arr[method](wrappedFn, ...args);
|
|
607
|
+
const arr = shallowReadArray(self);
|
|
608
|
+
let wrappedFn = fn;
|
|
609
|
+
if (arr !== self) {
|
|
610
|
+
if (!/* @__PURE__ */ isShallow(self)) wrappedFn = function(acc, item, index) {
|
|
611
|
+
return fn.call(this, acc, toWrapped(self, item), index, self);
|
|
612
|
+
};
|
|
613
|
+
else if (fn.length > 3) wrappedFn = function(acc, item, index) {
|
|
614
|
+
return fn.call(this, acc, item, index, self);
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
return arr[method](wrappedFn, ...args);
|
|
682
618
|
}
|
|
683
619
|
function searchProxy(self, method, args) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
620
|
+
const arr = /* @__PURE__ */ toRaw(self);
|
|
621
|
+
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
622
|
+
const res = arr[method](...args);
|
|
623
|
+
if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
|
|
624
|
+
args[0] = /* @__PURE__ */ toRaw(args[0]);
|
|
625
|
+
return arr[method](...args);
|
|
626
|
+
}
|
|
627
|
+
return res;
|
|
692
628
|
}
|
|
693
629
|
function noTracking(self, method, args = []) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
630
|
+
startBatch();
|
|
631
|
+
const prevSub = setActiveSub();
|
|
632
|
+
const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
|
|
633
|
+
setActiveSub(prevSub);
|
|
634
|
+
endBatch();
|
|
635
|
+
return res;
|
|
700
636
|
}
|
|
701
637
|
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region packages/reactivity/src/baseHandlers.ts
|
|
702
640
|
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
703
|
-
const builtInSymbols = new Set(
|
|
704
|
-
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
705
|
-
);
|
|
641
|
+
const builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
706
642
|
function hasOwnProperty(key) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
key,
|
|
807
|
-
value,
|
|
808
|
-
isRef(target) ? target : receiver
|
|
809
|
-
);
|
|
810
|
-
if (target === toRaw(receiver)) {
|
|
811
|
-
if (!hadKey) {
|
|
812
|
-
trigger(target, "add", key, value);
|
|
813
|
-
} else if (hasChanged(value, oldValue)) {
|
|
814
|
-
trigger(target, "set", key, value, oldValue);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
return result;
|
|
818
|
-
}
|
|
819
|
-
deleteProperty(target, key) {
|
|
820
|
-
const hadKey = hasOwn(target, key);
|
|
821
|
-
const oldValue = target[key];
|
|
822
|
-
const result = Reflect.deleteProperty(target, key);
|
|
823
|
-
if (result && hadKey) {
|
|
824
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
825
|
-
}
|
|
826
|
-
return result;
|
|
827
|
-
}
|
|
828
|
-
has(target, key) {
|
|
829
|
-
const result = Reflect.has(target, key);
|
|
830
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
831
|
-
track(target, "has", key);
|
|
832
|
-
}
|
|
833
|
-
return result;
|
|
834
|
-
}
|
|
835
|
-
ownKeys(target) {
|
|
836
|
-
track(
|
|
837
|
-
target,
|
|
838
|
-
"iterate",
|
|
839
|
-
isArray(target) ? "length" : ITERATE_KEY
|
|
840
|
-
);
|
|
841
|
-
return Reflect.ownKeys(target);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
845
|
-
constructor(isShallow2 = false) {
|
|
846
|
-
super(true, isShallow2);
|
|
847
|
-
}
|
|
848
|
-
set(target, key) {
|
|
849
|
-
{
|
|
850
|
-
warn(
|
|
851
|
-
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
852
|
-
target
|
|
853
|
-
);
|
|
854
|
-
}
|
|
855
|
-
return true;
|
|
856
|
-
}
|
|
857
|
-
deleteProperty(target, key) {
|
|
858
|
-
{
|
|
859
|
-
warn(
|
|
860
|
-
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
861
|
-
target
|
|
862
|
-
);
|
|
863
|
-
}
|
|
864
|
-
return true;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
643
|
+
if (!isSymbol(key)) key = String(key);
|
|
644
|
+
const obj = /* @__PURE__ */ toRaw(this);
|
|
645
|
+
track(obj, "has", key);
|
|
646
|
+
return obj.hasOwnProperty(key);
|
|
647
|
+
}
|
|
648
|
+
var BaseReactiveHandler = class {
|
|
649
|
+
constructor(_isReadonly = false, _isShallow = false) {
|
|
650
|
+
this._isReadonly = _isReadonly;
|
|
651
|
+
this._isShallow = _isShallow;
|
|
652
|
+
}
|
|
653
|
+
get(target, key, receiver) {
|
|
654
|
+
if (key === "__v_skip") return target["__v_skip"];
|
|
655
|
+
const isReadonly = this._isReadonly, isShallow = this._isShallow;
|
|
656
|
+
if (key === "__v_isReactive") return !isReadonly;
|
|
657
|
+
else if (key === "__v_isReadonly") return isReadonly;
|
|
658
|
+
else if (key === "__v_isShallow") return isShallow;
|
|
659
|
+
else if (key === "__v_raw") {
|
|
660
|
+
if (receiver === (isReadonly ? isShallow ? shallowReadonlyMap : readonlyMap : isShallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const targetIsArray = isArray(target);
|
|
664
|
+
if (!isReadonly) {
|
|
665
|
+
let fn;
|
|
666
|
+
if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
|
|
667
|
+
if (key === "hasOwnProperty") return hasOwnProperty;
|
|
668
|
+
}
|
|
669
|
+
const wasRef = /* @__PURE__ */ isRef(target);
|
|
670
|
+
const res = Reflect.get(target, key, wasRef ? target : receiver);
|
|
671
|
+
if (wasRef && key !== "value") return res;
|
|
672
|
+
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
|
|
673
|
+
if (!isReadonly) track(target, "get", key);
|
|
674
|
+
if (isShallow) return res;
|
|
675
|
+
if (/* @__PURE__ */ isRef(res)) {
|
|
676
|
+
const value = targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
677
|
+
return isReadonly && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
678
|
+
}
|
|
679
|
+
if (isObject(res)) return isReadonly ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
|
|
680
|
+
return res;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
684
|
+
constructor(isShallow = false) {
|
|
685
|
+
super(false, isShallow);
|
|
686
|
+
}
|
|
687
|
+
set(target, key, value, receiver) {
|
|
688
|
+
let oldValue = target[key];
|
|
689
|
+
const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
|
|
690
|
+
if (!this._isShallow) {
|
|
691
|
+
const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
|
|
692
|
+
if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
|
|
693
|
+
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
694
|
+
value = /* @__PURE__ */ toRaw(value);
|
|
695
|
+
}
|
|
696
|
+
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
|
|
697
|
+
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
|
|
698
|
+
return true;
|
|
699
|
+
} else {
|
|
700
|
+
oldValue.value = value;
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
|
|
705
|
+
const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
706
|
+
if (target === /* @__PURE__ */ toRaw(receiver)) {
|
|
707
|
+
if (!hadKey) trigger(target, "add", key, value);
|
|
708
|
+
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
709
|
+
}
|
|
710
|
+
return result;
|
|
711
|
+
}
|
|
712
|
+
deleteProperty(target, key) {
|
|
713
|
+
const hadKey = hasOwn(target, key);
|
|
714
|
+
const oldValue = target[key];
|
|
715
|
+
const result = Reflect.deleteProperty(target, key);
|
|
716
|
+
if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
has(target, key) {
|
|
720
|
+
const result = Reflect.has(target, key);
|
|
721
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
|
|
722
|
+
return result;
|
|
723
|
+
}
|
|
724
|
+
ownKeys(target) {
|
|
725
|
+
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
726
|
+
return Reflect.ownKeys(target);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
730
|
+
constructor(isShallow = false) {
|
|
731
|
+
super(true, isShallow);
|
|
732
|
+
}
|
|
733
|
+
set(target, key) {
|
|
734
|
+
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
deleteProperty(target, key) {
|
|
738
|
+
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
867
742
|
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
868
743
|
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
869
744
|
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
|
870
745
|
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
871
746
|
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region packages/reactivity/src/collectionHandlers.ts
|
|
872
749
|
const toShallow = (value) => value;
|
|
873
750
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
874
|
-
function createIterableMethod(method,
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
return done ? { value, done } : {
|
|
896
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
897
|
-
done
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
);
|
|
902
|
-
};
|
|
751
|
+
function createIterableMethod(method, isReadonly, isShallow) {
|
|
752
|
+
return function(...args) {
|
|
753
|
+
const target = this["__v_raw"];
|
|
754
|
+
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
755
|
+
const targetIsMap = isMap(rawTarget);
|
|
756
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
757
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
758
|
+
const innerIterator = target[method](...args);
|
|
759
|
+
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
|
760
|
+
!isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
761
|
+
return extend(Object.create(innerIterator), { next() {
|
|
762
|
+
const { value, done } = innerIterator.next();
|
|
763
|
+
return done ? {
|
|
764
|
+
value,
|
|
765
|
+
done
|
|
766
|
+
} : {
|
|
767
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
768
|
+
done
|
|
769
|
+
};
|
|
770
|
+
} });
|
|
771
|
+
};
|
|
903
772
|
}
|
|
904
773
|
function createReadonlyMethod(type) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
914
|
-
};
|
|
774
|
+
return function(...args) {
|
|
775
|
+
{
|
|
776
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
777
|
+
warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
|
|
778
|
+
}
|
|
779
|
+
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
780
|
+
};
|
|
915
781
|
}
|
|
916
782
|
function createInstrumentations(readonly, shallow) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
target,
|
|
1034
|
-
"clear",
|
|
1035
|
-
void 0,
|
|
1036
|
-
void 0,
|
|
1037
|
-
oldTarget
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
return result;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
);
|
|
1044
|
-
const iteratorMethods = [
|
|
1045
|
-
"keys",
|
|
1046
|
-
"values",
|
|
1047
|
-
"entries",
|
|
1048
|
-
Symbol.iterator
|
|
1049
|
-
];
|
|
1050
|
-
iteratorMethods.forEach((method) => {
|
|
1051
|
-
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1052
|
-
});
|
|
1053
|
-
return instrumentations;
|
|
1054
|
-
}
|
|
1055
|
-
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1056
|
-
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1057
|
-
return (target, key, receiver) => {
|
|
1058
|
-
if (key === "__v_isReactive") {
|
|
1059
|
-
return !isReadonly2;
|
|
1060
|
-
} else if (key === "__v_isReadonly") {
|
|
1061
|
-
return isReadonly2;
|
|
1062
|
-
} else if (key === "__v_raw") {
|
|
1063
|
-
return target;
|
|
1064
|
-
}
|
|
1065
|
-
return Reflect.get(
|
|
1066
|
-
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
1067
|
-
key,
|
|
1068
|
-
receiver
|
|
1069
|
-
);
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
const mutableCollectionHandlers = {
|
|
1073
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
1074
|
-
};
|
|
1075
|
-
const shallowCollectionHandlers = {
|
|
1076
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
1077
|
-
};
|
|
1078
|
-
const readonlyCollectionHandlers = {
|
|
1079
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
1080
|
-
};
|
|
1081
|
-
const shallowReadonlyCollectionHandlers = {
|
|
1082
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
1083
|
-
};
|
|
783
|
+
const instrumentations = {
|
|
784
|
+
get(key) {
|
|
785
|
+
const target = this["__v_raw"];
|
|
786
|
+
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
787
|
+
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
788
|
+
if (!readonly) {
|
|
789
|
+
if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
|
|
790
|
+
track(rawTarget, "get", rawKey);
|
|
791
|
+
}
|
|
792
|
+
const { has } = getProto(rawTarget);
|
|
793
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
794
|
+
if (has.call(rawTarget, key)) return wrap(target.get(key));
|
|
795
|
+
else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
|
|
796
|
+
else if (target !== rawTarget) target.get(key);
|
|
797
|
+
},
|
|
798
|
+
get size() {
|
|
799
|
+
const target = this["__v_raw"];
|
|
800
|
+
!readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
|
|
801
|
+
return target.size;
|
|
802
|
+
},
|
|
803
|
+
has(key) {
|
|
804
|
+
const target = this["__v_raw"];
|
|
805
|
+
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
806
|
+
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
807
|
+
if (!readonly) {
|
|
808
|
+
if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
|
|
809
|
+
track(rawTarget, "has", rawKey);
|
|
810
|
+
}
|
|
811
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
812
|
+
},
|
|
813
|
+
forEach(callback, thisArg) {
|
|
814
|
+
const observed = this;
|
|
815
|
+
const target = observed["__v_raw"];
|
|
816
|
+
const rawTarget = /* @__PURE__ */ toRaw(target);
|
|
817
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
818
|
+
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
819
|
+
return target.forEach((value, key) => {
|
|
820
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
extend(instrumentations, readonly ? {
|
|
825
|
+
add: createReadonlyMethod("add"),
|
|
826
|
+
set: createReadonlyMethod("set"),
|
|
827
|
+
delete: createReadonlyMethod("delete"),
|
|
828
|
+
clear: createReadonlyMethod("clear")
|
|
829
|
+
} : {
|
|
830
|
+
add(value) {
|
|
831
|
+
if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
|
|
832
|
+
const target = /* @__PURE__ */ toRaw(this);
|
|
833
|
+
if (!getProto(target).has.call(target, value)) {
|
|
834
|
+
target.add(value);
|
|
835
|
+
trigger(target, "add", value, value);
|
|
836
|
+
}
|
|
837
|
+
return this;
|
|
838
|
+
},
|
|
839
|
+
set(key, value) {
|
|
840
|
+
if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
|
|
841
|
+
const target = /* @__PURE__ */ toRaw(this);
|
|
842
|
+
const { has, get } = getProto(target);
|
|
843
|
+
let hadKey = has.call(target, key);
|
|
844
|
+
if (!hadKey) {
|
|
845
|
+
key = /* @__PURE__ */ toRaw(key);
|
|
846
|
+
hadKey = has.call(target, key);
|
|
847
|
+
} else checkIdentityKeys(target, has, key);
|
|
848
|
+
const oldValue = get.call(target, key);
|
|
849
|
+
target.set(key, value);
|
|
850
|
+
if (!hadKey) trigger(target, "add", key, value);
|
|
851
|
+
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
852
|
+
return this;
|
|
853
|
+
},
|
|
854
|
+
delete(key) {
|
|
855
|
+
const target = /* @__PURE__ */ toRaw(this);
|
|
856
|
+
const { has, get } = getProto(target);
|
|
857
|
+
let hadKey = has.call(target, key);
|
|
858
|
+
if (!hadKey) {
|
|
859
|
+
key = /* @__PURE__ */ toRaw(key);
|
|
860
|
+
hadKey = has.call(target, key);
|
|
861
|
+
} else checkIdentityKeys(target, has, key);
|
|
862
|
+
const oldValue = get ? get.call(target, key) : void 0;
|
|
863
|
+
const result = target.delete(key);
|
|
864
|
+
if (hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
865
|
+
return result;
|
|
866
|
+
},
|
|
867
|
+
clear() {
|
|
868
|
+
const target = /* @__PURE__ */ toRaw(this);
|
|
869
|
+
const hadItems = target.size !== 0;
|
|
870
|
+
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
|
|
871
|
+
const result = target.clear();
|
|
872
|
+
if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
|
|
873
|
+
return result;
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
[
|
|
877
|
+
"keys",
|
|
878
|
+
"values",
|
|
879
|
+
"entries",
|
|
880
|
+
Symbol.iterator
|
|
881
|
+
].forEach((method) => {
|
|
882
|
+
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
883
|
+
});
|
|
884
|
+
return instrumentations;
|
|
885
|
+
}
|
|
886
|
+
function createInstrumentationGetter(isReadonly, shallow) {
|
|
887
|
+
const instrumentations = createInstrumentations(isReadonly, shallow);
|
|
888
|
+
return (target, key, receiver) => {
|
|
889
|
+
if (key === "__v_isReactive") return !isReadonly;
|
|
890
|
+
else if (key === "__v_isReadonly") return isReadonly;
|
|
891
|
+
else if (key === "__v_raw") return target;
|
|
892
|
+
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
const mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
|
|
896
|
+
const shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
|
|
897
|
+
const readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
|
|
898
|
+
const shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
|
|
1084
899
|
function checkIdentityKeys(target, has, key) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
);
|
|
1091
|
-
}
|
|
900
|
+
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
901
|
+
if (rawKey !== key && has.call(target, rawKey)) {
|
|
902
|
+
const type = toRawType(target);
|
|
903
|
+
warn(`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.`);
|
|
904
|
+
}
|
|
1092
905
|
}
|
|
1093
906
|
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region packages/reactivity/src/reactive.ts
|
|
1094
909
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1095
910
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1096
911
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1097
912
|
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1098
913
|
function targetTypeMap(rawType) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
default:
|
|
1109
|
-
return 0 /* INVALID */;
|
|
1110
|
-
}
|
|
914
|
+
switch (rawType) {
|
|
915
|
+
case "Object":
|
|
916
|
+
case "Array": return 1;
|
|
917
|
+
case "Map":
|
|
918
|
+
case "Set":
|
|
919
|
+
case "WeakMap":
|
|
920
|
+
case "WeakSet": return 2;
|
|
921
|
+
default: return 0;
|
|
922
|
+
}
|
|
1111
923
|
}
|
|
1112
924
|
function getTargetType(value) {
|
|
1113
|
-
|
|
925
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
1114
926
|
}
|
|
1115
|
-
|
|
927
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1116
928
|
function reactive(target) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
929
|
+
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
930
|
+
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Shallow version of {@link reactive}.
|
|
934
|
+
*
|
|
935
|
+
* Unlike {@link reactive}, there is no deep conversion: only root-level
|
|
936
|
+
* properties are reactive for a shallow reactive object. Property values are
|
|
937
|
+
* stored and exposed as-is - this also means properties with ref values will
|
|
938
|
+
* not be automatically unwrapped.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```js
|
|
942
|
+
* const state = shallowReactive({
|
|
943
|
+
* foo: 1,
|
|
944
|
+
* nested: {
|
|
945
|
+
* bar: 2
|
|
946
|
+
* }
|
|
947
|
+
* })
|
|
948
|
+
*
|
|
949
|
+
* // mutating state's own properties is reactive
|
|
950
|
+
* state.foo++
|
|
951
|
+
*
|
|
952
|
+
* // ...but does not convert nested objects
|
|
953
|
+
* isReactive(state.nested) // false
|
|
954
|
+
*
|
|
955
|
+
* // NOT reactive
|
|
956
|
+
* state.nested.bar++
|
|
957
|
+
* ```
|
|
958
|
+
*
|
|
959
|
+
* @param target - The source object.
|
|
960
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
961
|
+
*/
|
|
962
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1129
963
|
function shallowReactive(target) {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
|
|
964
|
+
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
968
|
+
* the original.
|
|
969
|
+
*
|
|
970
|
+
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
971
|
+
* well. It also has the same ref-unwrapping behavior as {@link reactive},
|
|
972
|
+
* except the unwrapped values will also be made readonly.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```js
|
|
976
|
+
* const original = reactive({ count: 0 })
|
|
977
|
+
*
|
|
978
|
+
* const copy = readonly(original)
|
|
979
|
+
*
|
|
980
|
+
* watchEffect(() => {
|
|
981
|
+
* // works for reactivity tracking
|
|
982
|
+
* console.log(copy.count)
|
|
983
|
+
* })
|
|
984
|
+
*
|
|
985
|
+
* // mutating original will trigger watchers relying on the copy
|
|
986
|
+
* original.count++
|
|
987
|
+
*
|
|
988
|
+
* // mutating the copy will fail and result in a warning
|
|
989
|
+
* copy.count++ // warning!
|
|
990
|
+
* ```
|
|
991
|
+
*
|
|
992
|
+
* @param target - The source object.
|
|
993
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
994
|
+
*/
|
|
995
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1139
996
|
function readonly(target) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
997
|
+
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Shallow version of {@link readonly}.
|
|
1001
|
+
*
|
|
1002
|
+
* Unlike {@link readonly}, there is no deep conversion: only root-level
|
|
1003
|
+
* properties are made readonly. Property values are stored and exposed as-is -
|
|
1004
|
+
* this also means properties with ref values will not be automatically
|
|
1005
|
+
* unwrapped.
|
|
1006
|
+
*
|
|
1007
|
+
* @example
|
|
1008
|
+
* ```js
|
|
1009
|
+
* const state = shallowReadonly({
|
|
1010
|
+
* foo: 1,
|
|
1011
|
+
* nested: {
|
|
1012
|
+
* bar: 2
|
|
1013
|
+
* }
|
|
1014
|
+
* })
|
|
1015
|
+
*
|
|
1016
|
+
* // mutating state's own properties will fail
|
|
1017
|
+
* state.foo++
|
|
1018
|
+
*
|
|
1019
|
+
* // ...but works on nested objects
|
|
1020
|
+
* isReadonly(state.nested) // false
|
|
1021
|
+
*
|
|
1022
|
+
* // works
|
|
1023
|
+
* state.nested.bar++
|
|
1024
|
+
* ```
|
|
1025
|
+
*
|
|
1026
|
+
* @param target - The source object.
|
|
1027
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
1028
|
+
*/
|
|
1029
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1149
1030
|
function shallowReadonly(target) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
return proxy;
|
|
1186
|
-
}
|
|
1187
|
-
// @__NO_SIDE_EFFECTS__
|
|
1031
|
+
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
1032
|
+
}
|
|
1033
|
+
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
|
1034
|
+
if (!isObject(target)) {
|
|
1035
|
+
warn(`value cannot be made ${isReadonly ? "readonly" : "reactive"}: ${String(target)}`);
|
|
1036
|
+
return target;
|
|
1037
|
+
}
|
|
1038
|
+
if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
|
|
1039
|
+
const targetType = getTargetType(target);
|
|
1040
|
+
if (targetType === 0) return target;
|
|
1041
|
+
const existingProxy = proxyMap.get(target);
|
|
1042
|
+
if (existingProxy) return existingProxy;
|
|
1043
|
+
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1044
|
+
proxyMap.set(target, proxy);
|
|
1045
|
+
return proxy;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Checks if an object is a proxy created by {@link reactive} or
|
|
1049
|
+
* {@link shallowReactive} (or {@link ref} in some cases).
|
|
1050
|
+
*
|
|
1051
|
+
* @example
|
|
1052
|
+
* ```js
|
|
1053
|
+
* isReactive(reactive({})) // => true
|
|
1054
|
+
* isReactive(readonly(reactive({}))) // => true
|
|
1055
|
+
* isReactive(ref({}).value) // => true
|
|
1056
|
+
* isReactive(readonly(ref({})).value) // => true
|
|
1057
|
+
* isReactive(ref(true)) // => false
|
|
1058
|
+
* isReactive(shallowRef({}).value) // => false
|
|
1059
|
+
* isReactive(shallowReactive({})) // => true
|
|
1060
|
+
* ```
|
|
1061
|
+
*
|
|
1062
|
+
* @param value - The value to check.
|
|
1063
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
1064
|
+
*/
|
|
1065
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1188
1066
|
function isReactive(value) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
}
|
|
1192
|
-
return !!(value && value["__v_isReactive"]);
|
|
1067
|
+
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1068
|
+
return !!(value && value["__v_isReactive"]);
|
|
1193
1069
|
}
|
|
1194
|
-
|
|
1070
|
+
/**
|
|
1071
|
+
* Checks whether the passed value is a readonly object. The properties of a
|
|
1072
|
+
* readonly object can change, but they can't be assigned directly via the
|
|
1073
|
+
* passed object.
|
|
1074
|
+
*
|
|
1075
|
+
* The proxies created by {@link readonly} and {@link shallowReadonly} are
|
|
1076
|
+
* both considered readonly, as is a computed ref without a set function.
|
|
1077
|
+
*
|
|
1078
|
+
* @param value - The value to check.
|
|
1079
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
1080
|
+
*/
|
|
1081
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1195
1082
|
function isReadonly(value) {
|
|
1196
|
-
|
|
1083
|
+
return !!(value && value["__v_isReadonly"]);
|
|
1197
1084
|
}
|
|
1198
|
-
|
|
1085
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1199
1086
|
function isShallow(value) {
|
|
1200
|
-
|
|
1087
|
+
return !!(value && value["__v_isShallow"]);
|
|
1201
1088
|
}
|
|
1202
|
-
|
|
1089
|
+
/**
|
|
1090
|
+
* Checks if an object is a proxy created by {@link reactive},
|
|
1091
|
+
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
1092
|
+
*
|
|
1093
|
+
* @param value - The value to check.
|
|
1094
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
1095
|
+
*/
|
|
1096
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1203
1097
|
function isProxy(value) {
|
|
1204
|
-
|
|
1098
|
+
return value ? !!value["__v_raw"] : false;
|
|
1205
1099
|
}
|
|
1206
|
-
|
|
1100
|
+
/**
|
|
1101
|
+
* Returns the raw, original object of a Vue-created proxy.
|
|
1102
|
+
*
|
|
1103
|
+
* `toRaw()` can return the original object from proxies created by
|
|
1104
|
+
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
1105
|
+
* {@link shallowReadonly}.
|
|
1106
|
+
*
|
|
1107
|
+
* This is an escape hatch that can be used to temporarily read without
|
|
1108
|
+
* incurring proxy access / tracking overhead or write without triggering
|
|
1109
|
+
* changes. It is **not** recommended to hold a persistent reference to the
|
|
1110
|
+
* original object. Use with caution.
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* ```js
|
|
1114
|
+
* const foo = {}
|
|
1115
|
+
* const reactiveFoo = reactive(foo)
|
|
1116
|
+
*
|
|
1117
|
+
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
1118
|
+
* ```
|
|
1119
|
+
*
|
|
1120
|
+
* @param observed - The object for which the "raw" value is requested.
|
|
1121
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
1122
|
+
*/
|
|
1123
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1207
1124
|
function toRaw(observed) {
|
|
1208
|
-
|
|
1209
|
-
|
|
1125
|
+
const raw = observed && observed["__v_raw"];
|
|
1126
|
+
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
1210
1127
|
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Marks an object so that it will never be converted to a proxy. Returns the
|
|
1130
|
+
* object itself.
|
|
1131
|
+
*
|
|
1132
|
+
* @example
|
|
1133
|
+
* ```js
|
|
1134
|
+
* const foo = markRaw({})
|
|
1135
|
+
* console.log(isReactive(reactive(foo))) // false
|
|
1136
|
+
*
|
|
1137
|
+
* // also works when nested inside other reactive objects
|
|
1138
|
+
* const bar = reactive({ foo })
|
|
1139
|
+
* console.log(isReactive(bar.foo)) // false
|
|
1140
|
+
* ```
|
|
1141
|
+
*
|
|
1142
|
+
* **Warning:** `markRaw()` together with the shallow APIs such as
|
|
1143
|
+
* {@link shallowReactive} allow you to selectively opt-out of the default
|
|
1144
|
+
* deep reactive/readonly conversion and embed raw, non-proxied objects in your
|
|
1145
|
+
* state graph.
|
|
1146
|
+
*
|
|
1147
|
+
* @param value - The object to be marked as "raw".
|
|
1148
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
|
|
1149
|
+
*/
|
|
1211
1150
|
function markRaw(value) {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1215
|
-
return value;
|
|
1151
|
+
if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) def(value, "__v_skip", true);
|
|
1152
|
+
return value;
|
|
1216
1153
|
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Returns a reactive proxy of the given value (if possible).
|
|
1156
|
+
*
|
|
1157
|
+
* If the given value is not an object, the original value itself is returned.
|
|
1158
|
+
*
|
|
1159
|
+
* @param value - The value for which a reactive proxy shall be created.
|
|
1160
|
+
*/
|
|
1217
1161
|
const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
|
|
1162
|
+
/**
|
|
1163
|
+
* Returns a readonly proxy of the given value (if possible).
|
|
1164
|
+
*
|
|
1165
|
+
* If the given value is not an object, the original value itself is returned.
|
|
1166
|
+
*
|
|
1167
|
+
* @param value - The value for which a readonly proxy shall be created.
|
|
1168
|
+
*/
|
|
1218
1169
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1219
1170
|
|
|
1220
|
-
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region packages/reactivity/src/ref.ts
|
|
1173
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1221
1174
|
function isRef(r) {
|
|
1222
|
-
|
|
1175
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1223
1176
|
}
|
|
1224
|
-
|
|
1177
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1225
1178
|
function ref(value) {
|
|
1226
|
-
|
|
1179
|
+
return createRef(value, toReactive);
|
|
1227
1180
|
}
|
|
1228
|
-
|
|
1181
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1229
1182
|
function shallowRef(value) {
|
|
1230
|
-
|
|
1183
|
+
return createRef(value);
|
|
1231
1184
|
}
|
|
1232
1185
|
function createRef(rawValue, wrap) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1186
|
+
if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
|
|
1187
|
+
return new RefImpl(rawValue, wrap);
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* @internal
|
|
1191
|
+
*/
|
|
1192
|
+
var RefImpl = class {
|
|
1193
|
+
constructor(value, wrap) {
|
|
1194
|
+
this.subs = void 0;
|
|
1195
|
+
this.subsTail = void 0;
|
|
1196
|
+
this.flags = ReactiveFlags$1.Mutable;
|
|
1197
|
+
this.__v_isRef = true;
|
|
1198
|
+
this.__v_isShallow = false;
|
|
1199
|
+
this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
|
|
1200
|
+
this._value = wrap ? wrap(value) : value;
|
|
1201
|
+
this._wrap = wrap;
|
|
1202
|
+
this["__v_isShallow"] = !wrap;
|
|
1203
|
+
}
|
|
1204
|
+
get dep() {
|
|
1205
|
+
return this;
|
|
1206
|
+
}
|
|
1207
|
+
get value() {
|
|
1208
|
+
trackRef(this);
|
|
1209
|
+
if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
|
|
1210
|
+
const subs = this.subs;
|
|
1211
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1212
|
+
}
|
|
1213
|
+
return this._value;
|
|
1214
|
+
}
|
|
1215
|
+
set value(newValue) {
|
|
1216
|
+
const oldValue = this._rawValue;
|
|
1217
|
+
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
1218
|
+
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
1219
|
+
if (hasChanged(newValue, oldValue)) {
|
|
1220
|
+
this.flags |= ReactiveFlags$1.Dirty;
|
|
1221
|
+
this._rawValue = newValue;
|
|
1222
|
+
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1223
|
+
const subs = this.subs;
|
|
1224
|
+
if (subs !== void 0) {
|
|
1225
|
+
triggerEventInfos.push({
|
|
1226
|
+
target: this,
|
|
1227
|
+
type: "set",
|
|
1228
|
+
key: "value",
|
|
1229
|
+
newValue,
|
|
1230
|
+
oldValue
|
|
1231
|
+
});
|
|
1232
|
+
propagate(subs);
|
|
1233
|
+
if (!batchDepth) flush();
|
|
1234
|
+
triggerEventInfos.pop();
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
update() {
|
|
1239
|
+
this.flags &= ~ReactiveFlags$1.Dirty;
|
|
1240
|
+
return hasChanged(this._oldValue, this._oldValue = this._rawValue);
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
/**
|
|
1244
|
+
* Force trigger effects that depends on a shallow ref. This is typically used
|
|
1245
|
+
* after making deep mutations to the inner value of a shallow ref.
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* ```js
|
|
1249
|
+
* const shallow = shallowRef({
|
|
1250
|
+
* greet: 'Hello, world'
|
|
1251
|
+
* })
|
|
1252
|
+
*
|
|
1253
|
+
* // Logs "Hello, world" once for the first run-through
|
|
1254
|
+
* watchEffect(() => {
|
|
1255
|
+
* console.log(shallow.value.greet)
|
|
1256
|
+
* })
|
|
1257
|
+
*
|
|
1258
|
+
* // This won't trigger the effect because the ref is shallow
|
|
1259
|
+
* shallow.value.greet = 'Hello, universe'
|
|
1260
|
+
*
|
|
1261
|
+
* // Logs "Hello, universe"
|
|
1262
|
+
* triggerRef(shallow)
|
|
1263
|
+
* ```
|
|
1264
|
+
*
|
|
1265
|
+
* @param ref - The ref whose tied effects shall be executed.
|
|
1266
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
|
|
1267
|
+
*/
|
|
1268
|
+
function triggerRef(ref) {
|
|
1269
|
+
const dep = ref.dep;
|
|
1270
|
+
if (dep !== void 0 && dep.subs !== void 0) {
|
|
1271
|
+
propagate(dep.subs);
|
|
1272
|
+
shallowPropagate(dep.subs);
|
|
1273
|
+
if (!batchDepth) flush();
|
|
1274
|
+
}
|
|
1314
1275
|
}
|
|
1315
1276
|
function trackRef(dep) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
link(dep, activeSub);
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
function unref(ref2) {
|
|
1328
|
-
return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
|
|
1277
|
+
if (activeSub !== void 0) {
|
|
1278
|
+
onTrack(activeSub, {
|
|
1279
|
+
target: dep,
|
|
1280
|
+
type: "get",
|
|
1281
|
+
key: "value"
|
|
1282
|
+
});
|
|
1283
|
+
link(dep, activeSub);
|
|
1284
|
+
}
|
|
1329
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Returns the inner value if the argument is a ref, otherwise return the
|
|
1288
|
+
* argument itself. This is a sugar function for
|
|
1289
|
+
* `val = isRef(val) ? val.value : val`.
|
|
1290
|
+
*
|
|
1291
|
+
* @example
|
|
1292
|
+
* ```js
|
|
1293
|
+
* function useFoo(x: number | Ref<number>) {
|
|
1294
|
+
* const unwrapped = unref(x)
|
|
1295
|
+
* // unwrapped is guaranteed to be number now
|
|
1296
|
+
* }
|
|
1297
|
+
* ```
|
|
1298
|
+
*
|
|
1299
|
+
* @param ref - Ref or plain value to be converted into the plain value.
|
|
1300
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
1301
|
+
*/
|
|
1302
|
+
function unref(ref) {
|
|
1303
|
+
return /* @__PURE__ */ isRef(ref) ? ref.value : ref;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Normalizes values / refs / getters to values.
|
|
1307
|
+
* This is similar to {@link unref}, except that it also normalizes getters.
|
|
1308
|
+
* If the argument is a getter, it will be invoked and its return value will
|
|
1309
|
+
* be returned.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```js
|
|
1313
|
+
* toValue(1) // 1
|
|
1314
|
+
* toValue(ref(1)) // 1
|
|
1315
|
+
* toValue(() => 1) // 1
|
|
1316
|
+
* ```
|
|
1317
|
+
*
|
|
1318
|
+
* @param source - A getter, an existing ref, or a non-function value.
|
|
1319
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
1320
|
+
*/
|
|
1330
1321
|
function toValue(source) {
|
|
1331
|
-
|
|
1322
|
+
return isFunction(source) ? source() : unref(source);
|
|
1332
1323
|
}
|
|
1333
1324
|
const shallowUnwrapHandlers = {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1325
|
+
get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
|
|
1326
|
+
set: (target, key, value, receiver) => {
|
|
1327
|
+
const oldValue = target[key];
|
|
1328
|
+
if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
|
|
1329
|
+
oldValue.value = value;
|
|
1330
|
+
return true;
|
|
1331
|
+
} else return Reflect.set(target, key, value, receiver);
|
|
1332
|
+
}
|
|
1344
1333
|
};
|
|
1334
|
+
/**
|
|
1335
|
+
* Returns a proxy for the given object that shallowly unwraps properties that
|
|
1336
|
+
* are refs. If the object already is reactive, it's returned as-is. If not, a
|
|
1337
|
+
* new reactive proxy is created.
|
|
1338
|
+
*
|
|
1339
|
+
* @param objectWithRefs - Either an already-reactive object or a simple object
|
|
1340
|
+
* that contains refs.
|
|
1341
|
+
*/
|
|
1345
1342
|
function proxyRefs(objectWithRefs) {
|
|
1346
|
-
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1343
|
+
return /* @__PURE__ */ isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1344
|
+
}
|
|
1345
|
+
var CustomRefImpl = class {
|
|
1346
|
+
constructor(factory) {
|
|
1347
|
+
this.subs = void 0;
|
|
1348
|
+
this.subsTail = void 0;
|
|
1349
|
+
this.flags = ReactiveFlags$1.None;
|
|
1350
|
+
this["__v_isRef"] = true;
|
|
1351
|
+
this._value = void 0;
|
|
1352
|
+
const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
|
|
1353
|
+
this._get = get;
|
|
1354
|
+
this._set = set;
|
|
1355
|
+
}
|
|
1356
|
+
get dep() {
|
|
1357
|
+
return this;
|
|
1358
|
+
}
|
|
1359
|
+
get value() {
|
|
1360
|
+
return this._value = this._get();
|
|
1361
|
+
}
|
|
1362
|
+
set value(newVal) {
|
|
1363
|
+
this._set(newVal);
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
/**
|
|
1367
|
+
* Creates a customized ref with explicit control over its dependency tracking
|
|
1368
|
+
* and updates triggering.
|
|
1369
|
+
*
|
|
1370
|
+
* @param factory - The function that receives the `track` and `trigger` callbacks.
|
|
1371
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
|
|
1372
|
+
*/
|
|
1372
1373
|
function customRef(factory) {
|
|
1373
|
-
|
|
1374
|
+
return new CustomRefImpl(factory);
|
|
1374
1375
|
}
|
|
1375
|
-
|
|
1376
|
+
/**
|
|
1377
|
+
* Converts a reactive object to a plain object where each property of the
|
|
1378
|
+
* resulting object is a ref pointing to the corresponding property of the
|
|
1379
|
+
* original object. Each individual ref is created using {@link toRef}.
|
|
1380
|
+
*
|
|
1381
|
+
* @param object - Reactive object to be made into an object of linked refs.
|
|
1382
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
1383
|
+
*/
|
|
1384
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1376
1385
|
function toRefs(object) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
get value() {
|
|
1429
|
-
return this._value = this._getter();
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
// @__NO_SIDE_EFFECTS__
|
|
1386
|
+
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1387
|
+
for (const key in object) ret[key] = propertyToRef(object, key);
|
|
1388
|
+
return ret;
|
|
1389
|
+
}
|
|
1390
|
+
var ObjectRefImpl = class {
|
|
1391
|
+
constructor(_object, _key, _defaultValue) {
|
|
1392
|
+
this._object = _object;
|
|
1393
|
+
this._key = _key;
|
|
1394
|
+
this._defaultValue = _defaultValue;
|
|
1395
|
+
this["__v_isRef"] = true;
|
|
1396
|
+
this._value = void 0;
|
|
1397
|
+
this._raw = /* @__PURE__ */ toRaw(_object);
|
|
1398
|
+
let shallow = true;
|
|
1399
|
+
let obj = _object;
|
|
1400
|
+
if (!isArray(_object) || !isIntegerKey(String(_key))) do
|
|
1401
|
+
shallow = !/* @__PURE__ */ isProxy(obj) || /* @__PURE__ */ isShallow(obj);
|
|
1402
|
+
while (shallow && (obj = obj["__v_raw"]));
|
|
1403
|
+
this._shallow = shallow;
|
|
1404
|
+
}
|
|
1405
|
+
get value() {
|
|
1406
|
+
let val = this._object[this._key];
|
|
1407
|
+
if (this._shallow) val = unref(val);
|
|
1408
|
+
return this._value = val === void 0 ? this._defaultValue : val;
|
|
1409
|
+
}
|
|
1410
|
+
set value(newVal) {
|
|
1411
|
+
if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
|
|
1412
|
+
const nestedRef = this._object[this._key];
|
|
1413
|
+
if (/* @__PURE__ */ isRef(nestedRef)) {
|
|
1414
|
+
nestedRef.value = newVal;
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
this._object[this._key] = newVal;
|
|
1419
|
+
}
|
|
1420
|
+
get dep() {
|
|
1421
|
+
return getDepFromReactive(this._raw, this._key);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
var GetterRefImpl = class {
|
|
1425
|
+
constructor(_getter) {
|
|
1426
|
+
this._getter = _getter;
|
|
1427
|
+
this["__v_isRef"] = true;
|
|
1428
|
+
this["__v_isReadonly"] = true;
|
|
1429
|
+
this._value = void 0;
|
|
1430
|
+
}
|
|
1431
|
+
get value() {
|
|
1432
|
+
return this._value = this._getter();
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1433
1436
|
function toRef(source, key, defaultValue) {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
} else if (isObject(source) && arguments.length > 1) {
|
|
1439
|
-
return propertyToRef(source, key, defaultValue);
|
|
1440
|
-
} else {
|
|
1441
|
-
return /* @__PURE__ */ ref(source);
|
|
1442
|
-
}
|
|
1437
|
+
if (/* @__PURE__ */ isRef(source)) return source;
|
|
1438
|
+
else if (isFunction(source)) return new GetterRefImpl(source);
|
|
1439
|
+
else if (isObject(source) && arguments.length > 1) return propertyToRef(source, key, defaultValue);
|
|
1440
|
+
else return /* @__PURE__ */ ref(source);
|
|
1443
1441
|
}
|
|
1444
1442
|
function propertyToRef(source, key, defaultValue) {
|
|
1445
|
-
|
|
1443
|
+
return new ObjectRefImpl(source, key, defaultValue);
|
|
1446
1444
|
}
|
|
1447
1445
|
|
|
1446
|
+
//#endregion
|
|
1447
|
+
//#region packages/reactivity/src/effect.ts
|
|
1448
1448
|
const EffectFlags = {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1449
|
+
"ALLOW_RECURSE": 128,
|
|
1450
|
+
"128": "ALLOW_RECURSE",
|
|
1451
|
+
"PAUSED": 256,
|
|
1452
|
+
"256": "PAUSED",
|
|
1453
|
+
"STOP": 1024,
|
|
1454
|
+
"1024": "STOP"
|
|
1455
1455
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
if (!this.active) {
|
|
1517
|
-
return;
|
|
1518
|
-
}
|
|
1519
|
-
this.flags = 1024;
|
|
1520
|
-
let dep = this.deps;
|
|
1521
|
-
while (dep !== void 0) {
|
|
1522
|
-
dep = unlink(dep, this);
|
|
1523
|
-
}
|
|
1524
|
-
const sub = this.subs;
|
|
1525
|
-
if (sub !== void 0) {
|
|
1526
|
-
unlink(sub);
|
|
1527
|
-
}
|
|
1528
|
-
cleanup(this);
|
|
1529
|
-
}
|
|
1530
|
-
get dirty() {
|
|
1531
|
-
const flags = this.flags;
|
|
1532
|
-
if (flags & ReactiveFlags$1.Dirty) {
|
|
1533
|
-
return true;
|
|
1534
|
-
}
|
|
1535
|
-
if (flags & ReactiveFlags$1.Pending) {
|
|
1536
|
-
if (checkDirty(this.deps, this)) {
|
|
1537
|
-
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1538
|
-
return true;
|
|
1539
|
-
} else {
|
|
1540
|
-
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
return false;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
{
|
|
1547
|
-
setupOnTrigger(ReactiveEffect);
|
|
1548
|
-
}
|
|
1456
|
+
var ReactiveEffect = class {
|
|
1457
|
+
fn() {}
|
|
1458
|
+
constructor(fn) {
|
|
1459
|
+
this.deps = void 0;
|
|
1460
|
+
this.depsTail = void 0;
|
|
1461
|
+
this.subs = void 0;
|
|
1462
|
+
this.subsTail = void 0;
|
|
1463
|
+
this.flags = 18;
|
|
1464
|
+
this.cleanups = [];
|
|
1465
|
+
this.cleanupsLength = 0;
|
|
1466
|
+
if (fn !== void 0) this.fn = fn;
|
|
1467
|
+
if (activeEffectScope) link(this, activeEffectScope);
|
|
1468
|
+
}
|
|
1469
|
+
get active() {
|
|
1470
|
+
return !(this.flags & 1024);
|
|
1471
|
+
}
|
|
1472
|
+
pause() {
|
|
1473
|
+
this.flags |= 256;
|
|
1474
|
+
}
|
|
1475
|
+
resume() {
|
|
1476
|
+
if ((this.flags &= -257) & 48) this.notify();
|
|
1477
|
+
}
|
|
1478
|
+
notify() {
|
|
1479
|
+
if (!(this.flags & 256) && this.dirty) this.run();
|
|
1480
|
+
}
|
|
1481
|
+
run() {
|
|
1482
|
+
if (!this.active) return this.fn();
|
|
1483
|
+
cleanup(this);
|
|
1484
|
+
const prevSub = startTracking(this);
|
|
1485
|
+
try {
|
|
1486
|
+
return this.fn();
|
|
1487
|
+
} finally {
|
|
1488
|
+
endTracking(this, prevSub);
|
|
1489
|
+
const flags = this.flags;
|
|
1490
|
+
if ((flags & 136) === 136) {
|
|
1491
|
+
this.flags = flags & -9;
|
|
1492
|
+
this.notify();
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
stop() {
|
|
1497
|
+
if (!this.active) return;
|
|
1498
|
+
this.flags = 1024;
|
|
1499
|
+
let dep = this.deps;
|
|
1500
|
+
while (dep !== void 0) dep = unlink(dep, this);
|
|
1501
|
+
const sub = this.subs;
|
|
1502
|
+
if (sub !== void 0) unlink(sub);
|
|
1503
|
+
cleanup(this);
|
|
1504
|
+
}
|
|
1505
|
+
get dirty() {
|
|
1506
|
+
const flags = this.flags;
|
|
1507
|
+
if (flags & 16) return true;
|
|
1508
|
+
if (flags & 32) if (checkDirty(this.deps, this)) {
|
|
1509
|
+
this.flags = flags | 16;
|
|
1510
|
+
return true;
|
|
1511
|
+
} else this.flags = flags & -33;
|
|
1512
|
+
return false;
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
setupOnTrigger(ReactiveEffect);
|
|
1549
1516
|
function effect(fn, options) {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1580
|
-
const runner = e.run.bind(e);
|
|
1581
|
-
runner.effect = e;
|
|
1582
|
-
return runner;
|
|
1517
|
+
if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
|
|
1518
|
+
const e = new ReactiveEffect(fn);
|
|
1519
|
+
if (options) {
|
|
1520
|
+
const { onStop, scheduler } = options;
|
|
1521
|
+
if (onStop) {
|
|
1522
|
+
options.onStop = void 0;
|
|
1523
|
+
const stop = e.stop.bind(e);
|
|
1524
|
+
e.stop = () => {
|
|
1525
|
+
stop();
|
|
1526
|
+
onStop();
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
if (scheduler) {
|
|
1530
|
+
options.scheduler = void 0;
|
|
1531
|
+
e.notify = () => {
|
|
1532
|
+
if (!(e.flags & 256)) scheduler();
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
extend(e, options);
|
|
1536
|
+
}
|
|
1537
|
+
try {
|
|
1538
|
+
e.run();
|
|
1539
|
+
} catch (err) {
|
|
1540
|
+
e.stop();
|
|
1541
|
+
throw err;
|
|
1542
|
+
}
|
|
1543
|
+
const runner = e.run.bind(e);
|
|
1544
|
+
runner.effect = e;
|
|
1545
|
+
return runner;
|
|
1583
1546
|
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Stops the effect associated with the given runner.
|
|
1549
|
+
*
|
|
1550
|
+
* @param runner - Association with the effect to stop tracking.
|
|
1551
|
+
*/
|
|
1584
1552
|
function stop(runner) {
|
|
1585
|
-
|
|
1553
|
+
runner.effect.stop();
|
|
1586
1554
|
}
|
|
1587
1555
|
const resetTrackingStack = [];
|
|
1556
|
+
/**
|
|
1557
|
+
* Temporarily pauses tracking.
|
|
1558
|
+
*/
|
|
1588
1559
|
function pauseTracking() {
|
|
1589
|
-
|
|
1590
|
-
|
|
1560
|
+
resetTrackingStack.push(activeSub);
|
|
1561
|
+
setActiveSub();
|
|
1591
1562
|
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Re-enables effect tracking (if it was paused).
|
|
1565
|
+
*/
|
|
1592
1566
|
function enableTracking() {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
break;
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1567
|
+
if (!(activeSub === void 0)) resetTrackingStack.push(activeSub);
|
|
1568
|
+
else {
|
|
1569
|
+
resetTrackingStack.push(void 0);
|
|
1570
|
+
for (let i = resetTrackingStack.length - 1; i >= 0; i--) if (resetTrackingStack[i] !== void 0) {
|
|
1571
|
+
setActiveSub(resetTrackingStack[i]);
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1605
1575
|
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Resets the previous global effect tracking state.
|
|
1578
|
+
*/
|
|
1606
1579
|
function resetTracking() {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
);
|
|
1611
|
-
}
|
|
1612
|
-
if (resetTrackingStack.length) {
|
|
1613
|
-
setActiveSub(resetTrackingStack.pop());
|
|
1614
|
-
} else {
|
|
1615
|
-
setActiveSub();
|
|
1616
|
-
}
|
|
1580
|
+
if (resetTrackingStack.length === 0) warn("resetTracking() was called when there was no active tracking to reset.");
|
|
1581
|
+
if (resetTrackingStack.length) setActiveSub(resetTrackingStack.pop());
|
|
1582
|
+
else setActiveSub();
|
|
1617
1583
|
}
|
|
1618
1584
|
function cleanup(sub) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
sub.cleanupsLength = 0;
|
|
1625
|
-
}
|
|
1585
|
+
const l = sub.cleanupsLength;
|
|
1586
|
+
if (l) {
|
|
1587
|
+
for (let i = 0; i < l; i++) sub.cleanups[i]();
|
|
1588
|
+
sub.cleanupsLength = 0;
|
|
1589
|
+
}
|
|
1626
1590
|
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Registers a cleanup function for the current active effect.
|
|
1593
|
+
* The cleanup function is called right before the next effect run, or when the
|
|
1594
|
+
* effect is stopped.
|
|
1595
|
+
*
|
|
1596
|
+
* Throws a warning if there is no current active effect. The warning can be
|
|
1597
|
+
* suppressed by passing `true` to the second argument.
|
|
1598
|
+
*
|
|
1599
|
+
* @param fn - the cleanup function to be registered
|
|
1600
|
+
* @param failSilently - if `true`, will not throw warning when called without
|
|
1601
|
+
* an active effect.
|
|
1602
|
+
*/
|
|
1627
1603
|
function onEffectCleanup(fn, failSilently = false) {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
} else if (!failSilently) {
|
|
1631
|
-
warn(
|
|
1632
|
-
`onEffectCleanup() was called when there was no active effect to associate with.`
|
|
1633
|
-
);
|
|
1634
|
-
}
|
|
1604
|
+
if (activeSub instanceof ReactiveEffect) activeSub.cleanups[activeSub.cleanupsLength++] = () => cleanupEffect(fn);
|
|
1605
|
+
else if (!failSilently) warn("onEffectCleanup() was called when there was no active effect to associate with.");
|
|
1635
1606
|
}
|
|
1636
1607
|
function cleanupEffect(fn) {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1608
|
+
const prevSub = setActiveSub();
|
|
1609
|
+
try {
|
|
1610
|
+
fn();
|
|
1611
|
+
} finally {
|
|
1612
|
+
setActiveSub(prevSub);
|
|
1613
|
+
}
|
|
1643
1614
|
}
|
|
1644
1615
|
|
|
1616
|
+
//#endregion
|
|
1617
|
+
//#region packages/reactivity/src/effectScope.ts
|
|
1645
1618
|
let activeEffectScope;
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
dep = dep.nextDep;
|
|
1723
|
-
node.stop();
|
|
1724
|
-
} else {
|
|
1725
|
-
dep = unlink(dep, this);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
cleanup(this);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1619
|
+
var EffectScope = class {
|
|
1620
|
+
constructor(detached = false) {
|
|
1621
|
+
this.deps = void 0;
|
|
1622
|
+
this.depsTail = void 0;
|
|
1623
|
+
this.subs = void 0;
|
|
1624
|
+
this.subsTail = void 0;
|
|
1625
|
+
this.flags = 0;
|
|
1626
|
+
this.cleanups = [];
|
|
1627
|
+
this.cleanupsLength = 0;
|
|
1628
|
+
if (!detached && activeEffectScope) link(this, activeEffectScope);
|
|
1629
|
+
}
|
|
1630
|
+
get active() {
|
|
1631
|
+
return !(this.flags & 1024);
|
|
1632
|
+
}
|
|
1633
|
+
pause() {
|
|
1634
|
+
if (!(this.flags & 256)) {
|
|
1635
|
+
this.flags |= 256;
|
|
1636
|
+
for (let link = this.deps; link !== void 0; link = link.nextDep) {
|
|
1637
|
+
const dep = link.dep;
|
|
1638
|
+
if ("pause" in dep) dep.pause();
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Resumes the effect scope, including all child scopes and effects.
|
|
1644
|
+
*/
|
|
1645
|
+
resume() {
|
|
1646
|
+
const flags = this.flags;
|
|
1647
|
+
if (flags & 256) {
|
|
1648
|
+
this.flags = flags & -257;
|
|
1649
|
+
for (let link = this.deps; link !== void 0; link = link.nextDep) {
|
|
1650
|
+
const dep = link.dep;
|
|
1651
|
+
if ("resume" in dep) dep.resume();
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
run(fn) {
|
|
1656
|
+
const prevScope = activeEffectScope;
|
|
1657
|
+
try {
|
|
1658
|
+
activeEffectScope = this;
|
|
1659
|
+
return fn();
|
|
1660
|
+
} finally {
|
|
1661
|
+
activeEffectScope = prevScope;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
stop() {
|
|
1665
|
+
if (!this.active) return;
|
|
1666
|
+
this.flags = 1024;
|
|
1667
|
+
this.reset();
|
|
1668
|
+
const sub = this.subs;
|
|
1669
|
+
if (sub !== void 0) unlink(sub);
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* @internal
|
|
1673
|
+
*/
|
|
1674
|
+
reset() {
|
|
1675
|
+
let dep = this.deps;
|
|
1676
|
+
while (dep !== void 0) {
|
|
1677
|
+
const node = dep.dep;
|
|
1678
|
+
if ("stop" in node) {
|
|
1679
|
+
dep = dep.nextDep;
|
|
1680
|
+
node.stop();
|
|
1681
|
+
} else dep = unlink(dep, this);
|
|
1682
|
+
}
|
|
1683
|
+
cleanup(this);
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
/**
|
|
1687
|
+
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
1688
|
+
* computed and watchers) created within it so that these effects can be
|
|
1689
|
+
* disposed together. For detailed use cases of this API, please consult its
|
|
1690
|
+
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
1691
|
+
*
|
|
1692
|
+
* @param detached - Can be used to create a "detached" effect scope.
|
|
1693
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
1694
|
+
*/
|
|
1731
1695
|
function effectScope(detached) {
|
|
1732
|
-
|
|
1696
|
+
return new EffectScope(detached);
|
|
1733
1697
|
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Returns the current active effect scope if there is one.
|
|
1700
|
+
*
|
|
1701
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
1702
|
+
*/
|
|
1734
1703
|
function getCurrentScope() {
|
|
1735
|
-
|
|
1704
|
+
return activeEffectScope;
|
|
1736
1705
|
}
|
|
1737
1706
|
function setCurrentScope(scope) {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1707
|
+
try {
|
|
1708
|
+
return activeEffectScope;
|
|
1709
|
+
} finally {
|
|
1710
|
+
activeEffectScope = scope;
|
|
1711
|
+
}
|
|
1743
1712
|
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Registers a dispose callback on the current active effect scope. The
|
|
1715
|
+
* callback will be invoked when the associated effect scope is stopped.
|
|
1716
|
+
*
|
|
1717
|
+
* @param fn - The callback function to attach to the scope's cleanup.
|
|
1718
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
1719
|
+
*/
|
|
1744
1720
|
function onScopeDispose(fn, failSilently = false) {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
} else if (!failSilently) {
|
|
1748
|
-
warn(
|
|
1749
|
-
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
1750
|
-
);
|
|
1751
|
-
}
|
|
1721
|
+
if (activeEffectScope !== void 0) activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
|
|
1722
|
+
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
1752
1723
|
}
|
|
1753
1724
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
if (this.setter) {
|
|
1840
|
-
this.setter(newValue);
|
|
1841
|
-
} else {
|
|
1842
|
-
warn("Write operation failed: computed value is readonly");
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
update() {
|
|
1846
|
-
const prevSub = startTracking(this);
|
|
1847
|
-
try {
|
|
1848
|
-
const oldValue = this._value;
|
|
1849
|
-
const newValue = this.fn(oldValue);
|
|
1850
|
-
if (hasChanged(oldValue, newValue)) {
|
|
1851
|
-
this._value = newValue;
|
|
1852
|
-
return true;
|
|
1853
|
-
}
|
|
1854
|
-
return false;
|
|
1855
|
-
} finally {
|
|
1856
|
-
endTracking(this, prevSub);
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
{
|
|
1861
|
-
setupOnTrigger(ComputedRefImpl);
|
|
1862
|
-
}
|
|
1863
|
-
// @__NO_SIDE_EFFECTS__
|
|
1725
|
+
//#endregion
|
|
1726
|
+
//#region packages/reactivity/src/computed.ts
|
|
1727
|
+
/**
|
|
1728
|
+
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1729
|
+
* the main vue package
|
|
1730
|
+
*/
|
|
1731
|
+
var ComputedRefImpl = class {
|
|
1732
|
+
get effect() {
|
|
1733
|
+
return this;
|
|
1734
|
+
}
|
|
1735
|
+
get dep() {
|
|
1736
|
+
return this;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* @internal
|
|
1740
|
+
* for backwards compat
|
|
1741
|
+
*/
|
|
1742
|
+
get _dirty() {
|
|
1743
|
+
const flags = this.flags;
|
|
1744
|
+
if (flags & ReactiveFlags$1.Dirty) return true;
|
|
1745
|
+
if (flags & ReactiveFlags$1.Pending) if (checkDirty(this.deps, this)) {
|
|
1746
|
+
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1747
|
+
return true;
|
|
1748
|
+
} else this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* @internal
|
|
1753
|
+
* for backwards compat
|
|
1754
|
+
*/
|
|
1755
|
+
set _dirty(v) {
|
|
1756
|
+
if (v) this.flags |= ReactiveFlags$1.Dirty;
|
|
1757
|
+
else this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
|
|
1758
|
+
}
|
|
1759
|
+
constructor(fn, setter) {
|
|
1760
|
+
this.fn = fn;
|
|
1761
|
+
this.setter = setter;
|
|
1762
|
+
this._value = void 0;
|
|
1763
|
+
this.subs = void 0;
|
|
1764
|
+
this.subsTail = void 0;
|
|
1765
|
+
this.deps = void 0;
|
|
1766
|
+
this.depsTail = void 0;
|
|
1767
|
+
this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
|
|
1768
|
+
this.__v_isRef = true;
|
|
1769
|
+
this["__v_isReadonly"] = !setter;
|
|
1770
|
+
}
|
|
1771
|
+
get value() {
|
|
1772
|
+
const flags = this.flags;
|
|
1773
|
+
if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
|
|
1774
|
+
if (this.update()) {
|
|
1775
|
+
const subs = this.subs;
|
|
1776
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1777
|
+
}
|
|
1778
|
+
} else if (flags & ReactiveFlags$1.Pending) this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1779
|
+
if (activeSub !== void 0) {
|
|
1780
|
+
onTrack(activeSub, {
|
|
1781
|
+
target: this,
|
|
1782
|
+
type: "get",
|
|
1783
|
+
key: "value"
|
|
1784
|
+
});
|
|
1785
|
+
link(this, activeSub);
|
|
1786
|
+
} else if (activeEffectScope !== void 0) link(this, activeEffectScope);
|
|
1787
|
+
return this._value;
|
|
1788
|
+
}
|
|
1789
|
+
set value(newValue) {
|
|
1790
|
+
if (this.setter) this.setter(newValue);
|
|
1791
|
+
else warn("Write operation failed: computed value is readonly");
|
|
1792
|
+
}
|
|
1793
|
+
update() {
|
|
1794
|
+
const prevSub = startTracking(this);
|
|
1795
|
+
try {
|
|
1796
|
+
const oldValue = this._value;
|
|
1797
|
+
const newValue = this.fn(oldValue);
|
|
1798
|
+
if (hasChanged(oldValue, newValue)) {
|
|
1799
|
+
this._value = newValue;
|
|
1800
|
+
return true;
|
|
1801
|
+
}
|
|
1802
|
+
return false;
|
|
1803
|
+
} finally {
|
|
1804
|
+
endTracking(this, prevSub);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
setupOnTrigger(ComputedRefImpl);
|
|
1809
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1864
1810
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
return cRef;
|
|
1811
|
+
let getter;
|
|
1812
|
+
let setter;
|
|
1813
|
+
if (isFunction(getterOrOptions)) getter = getterOrOptions;
|
|
1814
|
+
else {
|
|
1815
|
+
getter = getterOrOptions.get;
|
|
1816
|
+
setter = getterOrOptions.set;
|
|
1817
|
+
}
|
|
1818
|
+
const cRef = new ComputedRefImpl(getter, setter);
|
|
1819
|
+
if (debugOptions && !isSSR) {
|
|
1820
|
+
cRef.onTrack = debugOptions.onTrack;
|
|
1821
|
+
cRef.onTrigger = debugOptions.onTrigger;
|
|
1822
|
+
}
|
|
1823
|
+
return cRef;
|
|
1879
1824
|
}
|
|
1880
1825
|
|
|
1826
|
+
//#endregion
|
|
1827
|
+
//#region packages/reactivity/src/constants.ts
|
|
1881
1828
|
const TrackOpTypes = {
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1829
|
+
"GET": "get",
|
|
1830
|
+
"HAS": "has",
|
|
1831
|
+
"ITERATE": "iterate"
|
|
1885
1832
|
};
|
|
1886
1833
|
const TriggerOpTypes = {
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1834
|
+
"SET": "set",
|
|
1835
|
+
"ADD": "add",
|
|
1836
|
+
"DELETE": "delete",
|
|
1837
|
+
"CLEAR": "clear"
|
|
1891
1838
|
};
|
|
1892
1839
|
const ReactiveFlags = {
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1840
|
+
"SKIP": "__v_skip",
|
|
1841
|
+
"IS_REACTIVE": "__v_isReactive",
|
|
1842
|
+
"IS_READONLY": "__v_isReadonly",
|
|
1843
|
+
"IS_SHALLOW": "__v_isShallow",
|
|
1844
|
+
"RAW": "__v_raw",
|
|
1845
|
+
"IS_REF": "__v_isRef"
|
|
1899
1846
|
};
|
|
1900
1847
|
|
|
1848
|
+
//#endregion
|
|
1849
|
+
//#region packages/reactivity/src/watch.ts
|
|
1901
1850
|
const WatchErrorCodes = {
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1851
|
+
"WATCH_GETTER": 2,
|
|
1852
|
+
"2": "WATCH_GETTER",
|
|
1853
|
+
"WATCH_CALLBACK": 3,
|
|
1854
|
+
"3": "WATCH_CALLBACK",
|
|
1855
|
+
"WATCH_CLEANUP": 4,
|
|
1856
|
+
"4": "WATCH_CLEANUP"
|
|
1908
1857
|
};
|
|
1909
1858
|
const INITIAL_WATCHER_VALUE = {};
|
|
1910
1859
|
let activeWatcher = void 0;
|
|
1860
|
+
/**
|
|
1861
|
+
* Returns the current active effect if there is one.
|
|
1862
|
+
*/
|
|
1911
1863
|
function getCurrentWatcher() {
|
|
1912
|
-
|
|
1864
|
+
return activeWatcher;
|
|
1913
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Registers a cleanup callback on the current active effect. This
|
|
1868
|
+
* registered cleanup callback will be invoked right before the
|
|
1869
|
+
* associated effect re-runs.
|
|
1870
|
+
*
|
|
1871
|
+
* @param cleanupFn - The callback function to attach to the effect's cleanup.
|
|
1872
|
+
* @param failSilently - if `true`, will not throw warning when called without
|
|
1873
|
+
* an active effect.
|
|
1874
|
+
* @param owner - The effect that this cleanup function should be attached to.
|
|
1875
|
+
* By default, the current active effect.
|
|
1876
|
+
*/
|
|
1914
1877
|
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
if (!this.cb) {
|
|
2011
|
-
return;
|
|
2012
|
-
}
|
|
2013
|
-
const { immediate, deep, call } = this.options;
|
|
2014
|
-
if (initialRun && !immediate) {
|
|
2015
|
-
return;
|
|
2016
|
-
}
|
|
2017
|
-
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
2018
|
-
cleanup(this);
|
|
2019
|
-
const currentWatcher = activeWatcher;
|
|
2020
|
-
activeWatcher = this;
|
|
2021
|
-
try {
|
|
2022
|
-
const args = [
|
|
2023
|
-
newValue,
|
|
2024
|
-
// pass undefined as the old value when it's changed for the first time
|
|
2025
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
2026
|
-
this.boundCleanup
|
|
2027
|
-
];
|
|
2028
|
-
call ? call(this.cb, 3, args) : (
|
|
2029
|
-
// @ts-expect-error
|
|
2030
|
-
this.cb(...args)
|
|
2031
|
-
);
|
|
2032
|
-
} finally {
|
|
2033
|
-
activeWatcher = currentWatcher;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
1878
|
+
if (owner) {
|
|
1879
|
+
const { call } = owner.options;
|
|
1880
|
+
if (call) owner.cleanups[owner.cleanupsLength++] = () => call(cleanupFn, 4);
|
|
1881
|
+
else owner.cleanups[owner.cleanupsLength++] = cleanupFn;
|
|
1882
|
+
} else if (!failSilently) warn("onWatcherCleanup() was called when there was no active watcher to associate with.");
|
|
1883
|
+
}
|
|
1884
|
+
var WatcherEffect = class extends ReactiveEffect {
|
|
1885
|
+
constructor(source, cb, options = EMPTY_OBJ) {
|
|
1886
|
+
const { deep, once, call, onWarn } = options;
|
|
1887
|
+
let getter;
|
|
1888
|
+
let forceTrigger = false;
|
|
1889
|
+
let isMultiSource = false;
|
|
1890
|
+
if (/* @__PURE__ */ isRef(source)) {
|
|
1891
|
+
getter = () => source.value;
|
|
1892
|
+
forceTrigger = /* @__PURE__ */ isShallow(source);
|
|
1893
|
+
} else if (/* @__PURE__ */ isReactive(source)) {
|
|
1894
|
+
getter = () => reactiveGetter(source, deep);
|
|
1895
|
+
forceTrigger = true;
|
|
1896
|
+
} else if (isArray(source)) {
|
|
1897
|
+
isMultiSource = true;
|
|
1898
|
+
forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
|
|
1899
|
+
getter = () => source.map((s) => {
|
|
1900
|
+
if (/* @__PURE__ */ isRef(s)) return s.value;
|
|
1901
|
+
else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s, deep);
|
|
1902
|
+
else if (isFunction(s)) return call ? call(s, 2) : s();
|
|
1903
|
+
else warnInvalidSource(s, onWarn);
|
|
1904
|
+
});
|
|
1905
|
+
} else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
|
|
1906
|
+
else getter = () => {
|
|
1907
|
+
if (this.cleanupsLength) {
|
|
1908
|
+
const prevSub = setActiveSub();
|
|
1909
|
+
try {
|
|
1910
|
+
cleanup(this);
|
|
1911
|
+
} finally {
|
|
1912
|
+
setActiveSub(prevSub);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
const currentEffect = activeWatcher;
|
|
1916
|
+
activeWatcher = this;
|
|
1917
|
+
try {
|
|
1918
|
+
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1919
|
+
} finally {
|
|
1920
|
+
activeWatcher = currentEffect;
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
else {
|
|
1924
|
+
getter = NOOP;
|
|
1925
|
+
warnInvalidSource(source, onWarn);
|
|
1926
|
+
}
|
|
1927
|
+
if (cb && deep) {
|
|
1928
|
+
const baseGetter = getter;
|
|
1929
|
+
const depth = deep === true ? Infinity : deep;
|
|
1930
|
+
getter = () => traverse(baseGetter(), depth);
|
|
1931
|
+
}
|
|
1932
|
+
super(getter);
|
|
1933
|
+
this.cb = cb;
|
|
1934
|
+
this.options = options;
|
|
1935
|
+
this.boundCleanup = (fn) => onWatcherCleanup(fn, false, this);
|
|
1936
|
+
this.forceTrigger = forceTrigger;
|
|
1937
|
+
this.isMultiSource = isMultiSource;
|
|
1938
|
+
if (once && cb) {
|
|
1939
|
+
const _cb = cb;
|
|
1940
|
+
cb = (...args) => {
|
|
1941
|
+
_cb(...args);
|
|
1942
|
+
this.stop();
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
this.cb = cb;
|
|
1946
|
+
this.oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1947
|
+
this.onTrack = options.onTrack;
|
|
1948
|
+
this.onTrigger = options.onTrigger;
|
|
1949
|
+
}
|
|
1950
|
+
run(initialRun = false) {
|
|
1951
|
+
const oldValue = this.oldValue;
|
|
1952
|
+
const newValue = this.oldValue = super.run();
|
|
1953
|
+
if (!this.cb) return;
|
|
1954
|
+
const { immediate, deep, call } = this.options;
|
|
1955
|
+
if (initialRun && !immediate) return;
|
|
1956
|
+
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1957
|
+
cleanup(this);
|
|
1958
|
+
const currentWatcher = activeWatcher;
|
|
1959
|
+
activeWatcher = this;
|
|
1960
|
+
try {
|
|
1961
|
+
const args = [
|
|
1962
|
+
newValue,
|
|
1963
|
+
oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1964
|
+
this.boundCleanup
|
|
1965
|
+
];
|
|
1966
|
+
call ? call(this.cb, 3, args) : this.cb(...args);
|
|
1967
|
+
} finally {
|
|
1968
|
+
activeWatcher = currentWatcher;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
2038
1973
|
function reactiveGetter(source, deep) {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
return traverse(source);
|
|
1974
|
+
if (deep) return source;
|
|
1975
|
+
if (/* @__PURE__ */ isShallow(source) || deep === false || deep === 0) return traverse(source, 1);
|
|
1976
|
+
return traverse(source);
|
|
2043
1977
|
}
|
|
2044
1978
|
function warnInvalidSource(s, onWarn) {
|
|
2045
|
-
|
|
2046
|
-
`Invalid watch source: `,
|
|
2047
|
-
s,
|
|
2048
|
-
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
2049
|
-
);
|
|
1979
|
+
(onWarn || warn)(`Invalid watch source: `, s, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
|
|
2050
1980
|
}
|
|
2051
1981
|
function watch(source, cb, options = EMPTY_OBJ) {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
1982
|
+
const effect = new WatcherEffect(source, cb, options);
|
|
1983
|
+
effect.run(true);
|
|
1984
|
+
const stop = effect.stop.bind(effect);
|
|
1985
|
+
stop.pause = effect.pause.bind(effect);
|
|
1986
|
+
stop.resume = effect.resume.bind(effect);
|
|
1987
|
+
stop.stop = stop;
|
|
1988
|
+
return stop;
|
|
2059
1989
|
}
|
|
2060
1990
|
function traverse(value, depth = Infinity, seen) {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
} else if (isSet(value) || isMap(value)) {
|
|
2077
|
-
value.forEach((v) => {
|
|
2078
|
-
traverse(v, depth, seen);
|
|
2079
|
-
});
|
|
2080
|
-
} else if (isPlainObject(value)) {
|
|
2081
|
-
for (const key in value) {
|
|
2082
|
-
traverse(value[key], depth, seen);
|
|
2083
|
-
}
|
|
2084
|
-
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
2085
|
-
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
2086
|
-
traverse(value[key], depth, seen);
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
return value;
|
|
1991
|
+
if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
|
|
1992
|
+
seen = seen || /* @__PURE__ */ new Map();
|
|
1993
|
+
if ((seen.get(value) || 0) >= depth) return value;
|
|
1994
|
+
seen.set(value, depth);
|
|
1995
|
+
depth--;
|
|
1996
|
+
if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
|
|
1997
|
+
else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
|
|
1998
|
+
else if (isSet(value) || isMap(value)) value.forEach((v) => {
|
|
1999
|
+
traverse(v, depth, seen);
|
|
2000
|
+
});
|
|
2001
|
+
else if (isPlainObject(value)) {
|
|
2002
|
+
for (const key in value) traverse(value[key], depth, seen);
|
|
2003
|
+
for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
|
|
2004
|
+
}
|
|
2005
|
+
return value;
|
|
2091
2006
|
}
|
|
2092
2007
|
|
|
2093
|
-
|
|
2008
|
+
//#endregion
|
|
2009
|
+
export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, WatcherEffect, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, setActiveSub, setCurrentScope, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };
|