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