@vue/reactivity 3.6.0-beta.4 → 3.6.0-beta.6

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