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