@vue-mini/core 1.3.0-alpha.1 → 1.3.0-beta.1

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