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