@reactive-vscode/reactivity 1.0.0-beta.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2225 +1,1814 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- // @__NO_SIDE_EFFECTS__
2
+ //#region ../../node_modules/.pnpm/@vue+shared@3.5.32/node_modules/@vue/shared/dist/shared.esm-bundler.js
3
+ /**
4
+ * @vue/shared v3.5.32
5
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
6
+ * @license MIT
7
+ **/
8
+ /* @__NO_SIDE_EFFECTS__ */
4
9
  function makeMap(str) {
5
- const map = /* @__PURE__ */ Object.create(null);
6
- for (const key of str.split(",")) map[key] = 1;
7
- return (val) => val in map;
8
- }
9
- const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
10
- !!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
11
- const NOOP = () => {
12
- };
13
- const extend = Object.assign;
14
- const remove = (arr, el) => {
15
- const i = arr.indexOf(el);
16
- if (i > -1) {
17
- arr.splice(i, 1);
18
- }
10
+ const map = /* @__PURE__ */ Object.create(null);
11
+ for (const key of str.split(",")) map[key] = 1;
12
+ return (val) => val in map;
13
+ }
14
+ var EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
15
+ process.env.NODE_ENV !== "production" && Object.freeze([]);
16
+ var NOOP = () => {};
17
+ var extend = Object.assign;
18
+ var remove = (arr, el) => {
19
+ const i = arr.indexOf(el);
20
+ if (i > -1) arr.splice(i, 1);
19
21
  };
20
- const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
21
- const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
22
- const isArray = Array.isArray;
23
- const isMap = (val) => toTypeString(val) === "[object Map]";
24
- const isSet = (val) => toTypeString(val) === "[object Set]";
25
- const isFunction = (val) => typeof val === "function";
26
- const isString = (val) => typeof val === "string";
27
- const isSymbol = (val) => typeof val === "symbol";
28
- const isObject = (val) => val !== null && typeof val === "object";
29
- const isPromise = (val) => {
30
- return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
22
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
23
+ var hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
24
+ var isArray = Array.isArray;
25
+ var isMap = (val) => toTypeString(val) === "[object Map]";
26
+ var isSet = (val) => toTypeString(val) === "[object Set]";
27
+ var isFunction = (val) => typeof val === "function";
28
+ var isString = (val) => typeof val === "string";
29
+ var isSymbol = (val) => typeof val === "symbol";
30
+ var isObject = (val) => val !== null && typeof val === "object";
31
+ var isPromise = (val) => {
32
+ return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
31
33
  };
32
- const objectToString = Object.prototype.toString;
33
- const toTypeString = (value) => objectToString.call(value);
34
- const toRawType = (value) => {
35
- return toTypeString(value).slice(8, -1);
34
+ var objectToString = Object.prototype.toString;
35
+ var toTypeString = (value) => objectToString.call(value);
36
+ var toRawType = (value) => {
37
+ return toTypeString(value).slice(8, -1);
36
38
  };
37
- const isPlainObject = (val) => toTypeString(val) === "[object Object]";
38
- const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
39
- const cacheStringFunction = (fn) => {
40
- const cache = /* @__PURE__ */ Object.create(null);
41
- return ((str) => {
42
- const hit = cache[str];
43
- return hit || (cache[str] = fn(str));
44
- });
39
+ var isPlainObject = (val) => toTypeString(val) === "[object Object]";
40
+ var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
41
+ var cacheStringFunction = (fn) => {
42
+ const cache = /* @__PURE__ */ Object.create(null);
43
+ return ((str) => {
44
+ return cache[str] || (cache[str] = fn(str));
45
+ });
45
46
  };
46
- const capitalize = cacheStringFunction((str) => {
47
- return str.charAt(0).toUpperCase() + str.slice(1);
47
+ var camelizeRE = /-\w/g;
48
+ cacheStringFunction((str) => {
49
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
50
+ });
51
+ var hyphenateRE = /\B([A-Z])/g;
52
+ cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
53
+ var capitalize = cacheStringFunction((str) => {
54
+ return str.charAt(0).toUpperCase() + str.slice(1);
55
+ });
56
+ cacheStringFunction((str) => {
57
+ return str ? `on${capitalize(str)}` : ``;
48
58
  });
49
- const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
50
- const def = (obj, key, value, writable = false) => {
51
- Object.defineProperty(obj, key, {
52
- configurable: true,
53
- enumerable: false,
54
- writable,
55
- value
56
- });
59
+ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
60
+ var def = (obj, key, value, writable = false) => {
61
+ Object.defineProperty(obj, key, {
62
+ configurable: true,
63
+ enumerable: false,
64
+ writable,
65
+ value
66
+ });
57
67
  };
68
+ //#endregion
69
+ //#region ../../node_modules/.pnpm/@vue+reactivity@3.5.32/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
70
+ /**
71
+ * @vue/reactivity v3.5.32
72
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
73
+ * @license MIT
74
+ **/
58
75
  function warn$1(msg, ...args) {
59
- console.warn(`[Vue warn] ${msg}`, ...args);
60
- }
61
- let activeEffectScope;
62
- class EffectScope {
63
- constructor(detached = false) {
64
- this.detached = detached;
65
- this._active = true;
66
- this._on = 0;
67
- this.effects = [];
68
- this.cleanups = [];
69
- this._isPaused = false;
70
- this.parent = activeEffectScope;
71
- if (!detached && activeEffectScope) {
72
- this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
73
- this
74
- ) - 1;
75
- }
76
- }
77
- get active() {
78
- return this._active;
79
- }
80
- pause() {
81
- if (this._active) {
82
- this._isPaused = true;
83
- let i, l;
84
- if (this.scopes) {
85
- for (i = 0, l = this.scopes.length; i < l; i++) {
86
- this.scopes[i].pause();
87
- }
88
- }
89
- for (i = 0, l = this.effects.length; i < l; i++) {
90
- this.effects[i].pause();
91
- }
92
- }
93
- }
94
- /**
95
- * Resumes the effect scope, including all child scopes and effects.
96
- */
97
- resume() {
98
- if (this._active) {
99
- if (this._isPaused) {
100
- this._isPaused = false;
101
- let i, l;
102
- if (this.scopes) {
103
- for (i = 0, l = this.scopes.length; i < l; i++) {
104
- this.scopes[i].resume();
105
- }
106
- }
107
- for (i = 0, l = this.effects.length; i < l; i++) {
108
- this.effects[i].resume();
109
- }
110
- }
111
- }
112
- }
113
- run(fn) {
114
- if (this._active) {
115
- const currentEffectScope = activeEffectScope;
116
- try {
117
- activeEffectScope = this;
118
- return fn();
119
- } finally {
120
- activeEffectScope = currentEffectScope;
121
- }
122
- } else if (!!(process.env.NODE_ENV !== "production")) {
123
- warn$1(`cannot run an inactive effect scope.`);
124
- }
125
- }
126
- /**
127
- * This should only be called on non-detached scopes
128
- * @internal
129
- */
130
- on() {
131
- if (++this._on === 1) {
132
- this.prevScope = activeEffectScope;
133
- activeEffectScope = this;
134
- }
135
- }
136
- /**
137
- * This should only be called on non-detached scopes
138
- * @internal
139
- */
140
- off() {
141
- if (this._on > 0 && --this._on === 0) {
142
- activeEffectScope = this.prevScope;
143
- this.prevScope = void 0;
144
- }
145
- }
146
- stop(fromParent) {
147
- if (this._active) {
148
- this._active = false;
149
- let i, l;
150
- for (i = 0, l = this.effects.length; i < l; i++) {
151
- this.effects[i].stop();
152
- }
153
- this.effects.length = 0;
154
- for (i = 0, l = this.cleanups.length; i < l; i++) {
155
- this.cleanups[i]();
156
- }
157
- this.cleanups.length = 0;
158
- if (this.scopes) {
159
- for (i = 0, l = this.scopes.length; i < l; i++) {
160
- this.scopes[i].stop(true);
161
- }
162
- this.scopes.length = 0;
163
- }
164
- if (!this.detached && this.parent && !fromParent) {
165
- const last = this.parent.scopes.pop();
166
- if (last && last !== this) {
167
- this.parent.scopes[this.index] = last;
168
- last.index = this.index;
169
- }
170
- }
171
- this.parent = void 0;
172
- }
173
- }
174
- }
76
+ console.warn(`[Vue warn] ${msg}`, ...args);
77
+ }
78
+ var activeEffectScope;
79
+ var EffectScope = class {
80
+ constructor(detached = false) {
81
+ this.detached = detached;
82
+ /**
83
+ * @internal
84
+ */
85
+ this._active = true;
86
+ /**
87
+ * @internal track `on` calls, allow `on` call multiple times
88
+ */
89
+ this._on = 0;
90
+ /**
91
+ * @internal
92
+ */
93
+ this.effects = [];
94
+ /**
95
+ * @internal
96
+ */
97
+ this.cleanups = [];
98
+ this._isPaused = false;
99
+ this.__v_skip = true;
100
+ this.parent = activeEffectScope;
101
+ if (!detached && activeEffectScope) this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
102
+ }
103
+ get active() {
104
+ return this._active;
105
+ }
106
+ pause() {
107
+ if (this._active) {
108
+ this._isPaused = true;
109
+ let i, l;
110
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause();
111
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause();
112
+ }
113
+ }
114
+ /**
115
+ * Resumes the effect scope, including all child scopes and effects.
116
+ */
117
+ resume() {
118
+ if (this._active) {
119
+ if (this._isPaused) {
120
+ this._isPaused = false;
121
+ let i, l;
122
+ if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume();
123
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume();
124
+ }
125
+ }
126
+ }
127
+ run(fn) {
128
+ if (this._active) {
129
+ const currentEffectScope = activeEffectScope;
130
+ try {
131
+ activeEffectScope = this;
132
+ return fn();
133
+ } finally {
134
+ activeEffectScope = currentEffectScope;
135
+ }
136
+ } else if (!!(process.env.NODE_ENV !== "production")) warn$1(`cannot run an inactive effect scope.`);
137
+ }
138
+ /**
139
+ * This should only be called on non-detached scopes
140
+ * @internal
141
+ */
142
+ on() {
143
+ if (++this._on === 1) {
144
+ this.prevScope = activeEffectScope;
145
+ activeEffectScope = this;
146
+ }
147
+ }
148
+ /**
149
+ * This should only be called on non-detached scopes
150
+ * @internal
151
+ */
152
+ off() {
153
+ if (this._on > 0 && --this._on === 0) {
154
+ activeEffectScope = this.prevScope;
155
+ this.prevScope = void 0;
156
+ }
157
+ }
158
+ stop(fromParent) {
159
+ if (this._active) {
160
+ this._active = false;
161
+ let i, l;
162
+ for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
163
+ this.effects.length = 0;
164
+ for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
165
+ this.cleanups.length = 0;
166
+ if (this.scopes) {
167
+ for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
168
+ this.scopes.length = 0;
169
+ }
170
+ if (!this.detached && this.parent && !fromParent) {
171
+ const last = this.parent.scopes.pop();
172
+ if (last && last !== this) {
173
+ this.parent.scopes[this.index] = last;
174
+ last.index = this.index;
175
+ }
176
+ }
177
+ this.parent = void 0;
178
+ }
179
+ }
180
+ };
175
181
  function effectScope(detached) {
176
- return new EffectScope(detached);
182
+ return new EffectScope(detached);
177
183
  }
178
184
  function getCurrentScope() {
179
- return activeEffectScope;
185
+ return activeEffectScope;
180
186
  }
181
187
  function onScopeDispose(fn, failSilently = false) {
182
- if (activeEffectScope) {
183
- activeEffectScope.cleanups.push(fn);
184
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
185
- warn$1(
186
- `onScopeDispose() is called when there is no active effect scope to be associated with.`
187
- );
188
- }
189
- }
190
- let activeSub;
191
- const EffectFlags = {
192
- "ACTIVE": 1,
193
- "1": "ACTIVE",
194
- "RUNNING": 2,
195
- "2": "RUNNING",
196
- "TRACKING": 4,
197
- "4": "TRACKING",
198
- "NOTIFIED": 8,
199
- "8": "NOTIFIED",
200
- "DIRTY": 16,
201
- "16": "DIRTY",
202
- "ALLOW_RECURSE": 32,
203
- "32": "ALLOW_RECURSE",
204
- "PAUSED": 64,
205
- "64": "PAUSED",
206
- "EVALUATED": 128,
207
- "128": "EVALUATED"
188
+ if (activeEffectScope) activeEffectScope.cleanups.push(fn);
189
+ else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
190
+ }
191
+ var activeSub;
192
+ var EffectFlags = {
193
+ "ACTIVE": 1,
194
+ "1": "ACTIVE",
195
+ "RUNNING": 2,
196
+ "2": "RUNNING",
197
+ "TRACKING": 4,
198
+ "4": "TRACKING",
199
+ "NOTIFIED": 8,
200
+ "8": "NOTIFIED",
201
+ "DIRTY": 16,
202
+ "16": "DIRTY",
203
+ "ALLOW_RECURSE": 32,
204
+ "32": "ALLOW_RECURSE",
205
+ "PAUSED": 64,
206
+ "64": "PAUSED",
207
+ "EVALUATED": 128,
208
+ "128": "EVALUATED"
208
209
  };
209
- const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
210
- class ReactiveEffect {
211
- constructor(fn) {
212
- this.fn = fn;
213
- this.deps = void 0;
214
- this.depsTail = void 0;
215
- this.flags = 1 | 4;
216
- this.next = void 0;
217
- this.cleanup = void 0;
218
- this.scheduler = void 0;
219
- if (activeEffectScope && activeEffectScope.active) {
220
- activeEffectScope.effects.push(this);
221
- }
222
- }
223
- pause() {
224
- this.flags |= 64;
225
- }
226
- resume() {
227
- if (this.flags & 64) {
228
- this.flags &= -65;
229
- if (pausedQueueEffects.has(this)) {
230
- pausedQueueEffects.delete(this);
231
- this.trigger();
232
- }
233
- }
234
- }
235
- /**
236
- * @internal
237
- */
238
- notify() {
239
- if (this.flags & 2 && !(this.flags & 32)) {
240
- return;
241
- }
242
- if (!(this.flags & 8)) {
243
- batch(this);
244
- }
245
- }
246
- run() {
247
- if (!(this.flags & 1)) {
248
- return this.fn();
249
- }
250
- this.flags |= 2;
251
- cleanupEffect(this);
252
- prepareDeps(this);
253
- const prevEffect = activeSub;
254
- const prevShouldTrack = shouldTrack;
255
- activeSub = this;
256
- shouldTrack = true;
257
- try {
258
- return this.fn();
259
- } finally {
260
- if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) {
261
- warn$1(
262
- "Active effect was not restored correctly - this is likely a Vue internal bug."
263
- );
264
- }
265
- cleanupDeps(this);
266
- activeSub = prevEffect;
267
- shouldTrack = prevShouldTrack;
268
- this.flags &= -3;
269
- }
270
- }
271
- stop() {
272
- if (this.flags & 1) {
273
- for (let link = this.deps; link; link = link.nextDep) {
274
- removeSub(link);
275
- }
276
- this.deps = this.depsTail = void 0;
277
- cleanupEffect(this);
278
- this.onStop && this.onStop();
279
- this.flags &= -2;
280
- }
281
- }
282
- trigger() {
283
- if (this.flags & 64) {
284
- pausedQueueEffects.add(this);
285
- } else if (this.scheduler) {
286
- this.scheduler();
287
- } else {
288
- this.runIfDirty();
289
- }
290
- }
291
- /**
292
- * @internal
293
- */
294
- runIfDirty() {
295
- if (isDirty(this)) {
296
- this.run();
297
- }
298
- }
299
- get dirty() {
300
- return isDirty(this);
301
- }
302
- }
303
- let batchDepth = 0;
304
- let batchedSub;
305
- let batchedComputed;
210
+ var pausedQueueEffects = /* @__PURE__ */ new WeakSet();
211
+ var ReactiveEffect = class {
212
+ constructor(fn) {
213
+ this.fn = fn;
214
+ /**
215
+ * @internal
216
+ */
217
+ this.deps = void 0;
218
+ /**
219
+ * @internal
220
+ */
221
+ this.depsTail = void 0;
222
+ /**
223
+ * @internal
224
+ */
225
+ this.flags = 5;
226
+ /**
227
+ * @internal
228
+ */
229
+ this.next = void 0;
230
+ /**
231
+ * @internal
232
+ */
233
+ this.cleanup = void 0;
234
+ this.scheduler = void 0;
235
+ if (activeEffectScope && activeEffectScope.active) activeEffectScope.effects.push(this);
236
+ }
237
+ pause() {
238
+ this.flags |= 64;
239
+ }
240
+ resume() {
241
+ if (this.flags & 64) {
242
+ this.flags &= -65;
243
+ if (pausedQueueEffects.has(this)) {
244
+ pausedQueueEffects.delete(this);
245
+ this.trigger();
246
+ }
247
+ }
248
+ }
249
+ /**
250
+ * @internal
251
+ */
252
+ notify() {
253
+ if (this.flags & 2 && !(this.flags & 32)) return;
254
+ if (!(this.flags & 8)) batch(this);
255
+ }
256
+ run() {
257
+ if (!(this.flags & 1)) return this.fn();
258
+ this.flags |= 2;
259
+ cleanupEffect(this);
260
+ prepareDeps(this);
261
+ const prevEffect = activeSub;
262
+ const prevShouldTrack = shouldTrack;
263
+ activeSub = this;
264
+ shouldTrack = true;
265
+ try {
266
+ return this.fn();
267
+ } finally {
268
+ if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) warn$1("Active effect was not restored correctly - this is likely a Vue internal bug.");
269
+ cleanupDeps(this);
270
+ activeSub = prevEffect;
271
+ shouldTrack = prevShouldTrack;
272
+ this.flags &= -3;
273
+ }
274
+ }
275
+ stop() {
276
+ if (this.flags & 1) {
277
+ for (let link = this.deps; link; link = link.nextDep) removeSub(link);
278
+ this.deps = this.depsTail = void 0;
279
+ cleanupEffect(this);
280
+ this.onStop && this.onStop();
281
+ this.flags &= -2;
282
+ }
283
+ }
284
+ trigger() {
285
+ if (this.flags & 64) pausedQueueEffects.add(this);
286
+ else if (this.scheduler) this.scheduler();
287
+ else this.runIfDirty();
288
+ }
289
+ /**
290
+ * @internal
291
+ */
292
+ runIfDirty() {
293
+ if (isDirty(this)) this.run();
294
+ }
295
+ get dirty() {
296
+ return isDirty(this);
297
+ }
298
+ };
299
+ var batchDepth = 0;
300
+ var batchedSub;
301
+ var batchedComputed;
306
302
  function batch(sub, isComputed = false) {
307
- sub.flags |= 8;
308
- if (isComputed) {
309
- sub.next = batchedComputed;
310
- batchedComputed = sub;
311
- return;
312
- }
313
- sub.next = batchedSub;
314
- batchedSub = sub;
303
+ sub.flags |= 8;
304
+ if (isComputed) {
305
+ sub.next = batchedComputed;
306
+ batchedComputed = sub;
307
+ return;
308
+ }
309
+ sub.next = batchedSub;
310
+ batchedSub = sub;
315
311
  }
316
312
  function startBatch() {
317
- batchDepth++;
313
+ batchDepth++;
318
314
  }
319
315
  function endBatch() {
320
- if (--batchDepth > 0) {
321
- return;
322
- }
323
- if (batchedComputed) {
324
- let e = batchedComputed;
325
- batchedComputed = void 0;
326
- while (e) {
327
- const next = e.next;
328
- e.next = void 0;
329
- e.flags &= -9;
330
- e = next;
331
- }
332
- }
333
- let error;
334
- while (batchedSub) {
335
- let e = batchedSub;
336
- batchedSub = void 0;
337
- while (e) {
338
- const next = e.next;
339
- e.next = void 0;
340
- e.flags &= -9;
341
- if (e.flags & 1) {
342
- try {
343
- ;
344
- e.trigger();
345
- } catch (err) {
346
- if (!error) error = err;
347
- }
348
- }
349
- e = next;
350
- }
351
- }
352
- if (error) throw error;
316
+ if (--batchDepth > 0) return;
317
+ if (batchedComputed) {
318
+ let e = batchedComputed;
319
+ batchedComputed = void 0;
320
+ while (e) {
321
+ const next = e.next;
322
+ e.next = void 0;
323
+ e.flags &= -9;
324
+ e = next;
325
+ }
326
+ }
327
+ let error;
328
+ while (batchedSub) {
329
+ let e = batchedSub;
330
+ batchedSub = void 0;
331
+ while (e) {
332
+ const next = e.next;
333
+ e.next = void 0;
334
+ e.flags &= -9;
335
+ if (e.flags & 1) try {
336
+ e.trigger();
337
+ } catch (err) {
338
+ if (!error) error = err;
339
+ }
340
+ e = next;
341
+ }
342
+ }
343
+ if (error) throw error;
353
344
  }
354
345
  function prepareDeps(sub) {
355
- for (let link = sub.deps; link; link = link.nextDep) {
356
- link.version = -1;
357
- link.prevActiveLink = link.dep.activeLink;
358
- link.dep.activeLink = link;
359
- }
346
+ for (let link = sub.deps; link; link = link.nextDep) {
347
+ link.version = -1;
348
+ link.prevActiveLink = link.dep.activeLink;
349
+ link.dep.activeLink = link;
350
+ }
360
351
  }
361
352
  function cleanupDeps(sub) {
362
- let head;
363
- let tail = sub.depsTail;
364
- let link = tail;
365
- while (link) {
366
- const prev = link.prevDep;
367
- if (link.version === -1) {
368
- if (link === tail) tail = prev;
369
- removeSub(link);
370
- removeDep(link);
371
- } else {
372
- head = link;
373
- }
374
- link.dep.activeLink = link.prevActiveLink;
375
- link.prevActiveLink = void 0;
376
- link = prev;
377
- }
378
- sub.deps = head;
379
- sub.depsTail = tail;
353
+ let head;
354
+ let tail = sub.depsTail;
355
+ let link = tail;
356
+ while (link) {
357
+ const prev = link.prevDep;
358
+ if (link.version === -1) {
359
+ if (link === tail) tail = prev;
360
+ removeSub(link);
361
+ removeDep(link);
362
+ } else head = link;
363
+ link.dep.activeLink = link.prevActiveLink;
364
+ link.prevActiveLink = void 0;
365
+ link = prev;
366
+ }
367
+ sub.deps = head;
368
+ sub.depsTail = tail;
380
369
  }
381
370
  function isDirty(sub) {
382
- for (let link = sub.deps; link; link = link.nextDep) {
383
- if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
384
- return true;
385
- }
386
- }
387
- if (sub._dirty) {
388
- return true;
389
- }
390
- return false;
391
- }
392
- function refreshComputed(computed2) {
393
- if (computed2.flags & 4 && !(computed2.flags & 16)) {
394
- return;
395
- }
396
- computed2.flags &= -17;
397
- if (computed2.globalVersion === globalVersion) {
398
- return;
399
- }
400
- computed2.globalVersion = globalVersion;
401
- if (!computed2.isSSR && computed2.flags & 128 && (!computed2.deps && !computed2._dirty || !isDirty(computed2))) {
402
- return;
403
- }
404
- computed2.flags |= 2;
405
- const dep = computed2.dep;
406
- const prevSub = activeSub;
407
- const prevShouldTrack = shouldTrack;
408
- activeSub = computed2;
409
- shouldTrack = true;
410
- try {
411
- prepareDeps(computed2);
412
- const value = computed2.fn(computed2._value);
413
- if (dep.version === 0 || hasChanged(value, computed2._value)) {
414
- computed2.flags |= 128;
415
- computed2._value = value;
416
- dep.version++;
417
- }
418
- } catch (err) {
419
- dep.version++;
420
- throw err;
421
- } finally {
422
- activeSub = prevSub;
423
- shouldTrack = prevShouldTrack;
424
- cleanupDeps(computed2);
425
- computed2.flags &= -3;
426
- }
371
+ for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
372
+ if (sub._dirty) return true;
373
+ return false;
374
+ }
375
+ function refreshComputed(computed) {
376
+ if (computed.flags & 4 && !(computed.flags & 16)) return;
377
+ computed.flags &= -17;
378
+ if (computed.globalVersion === globalVersion) return;
379
+ computed.globalVersion = globalVersion;
380
+ if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return;
381
+ computed.flags |= 2;
382
+ const dep = computed.dep;
383
+ const prevSub = activeSub;
384
+ const prevShouldTrack = shouldTrack;
385
+ activeSub = computed;
386
+ shouldTrack = true;
387
+ try {
388
+ prepareDeps(computed);
389
+ const value = computed.fn(computed._value);
390
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
391
+ computed.flags |= 128;
392
+ computed._value = value;
393
+ dep.version++;
394
+ }
395
+ } catch (err) {
396
+ dep.version++;
397
+ throw err;
398
+ } finally {
399
+ activeSub = prevSub;
400
+ shouldTrack = prevShouldTrack;
401
+ cleanupDeps(computed);
402
+ computed.flags &= -3;
403
+ }
427
404
  }
428
405
  function removeSub(link, soft = false) {
429
- const { dep, prevSub, nextSub } = link;
430
- if (prevSub) {
431
- prevSub.nextSub = nextSub;
432
- link.prevSub = void 0;
433
- }
434
- if (nextSub) {
435
- nextSub.prevSub = prevSub;
436
- link.nextSub = void 0;
437
- }
438
- if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) {
439
- dep.subsHead = nextSub;
440
- }
441
- if (dep.subs === link) {
442
- dep.subs = prevSub;
443
- if (!prevSub && dep.computed) {
444
- dep.computed.flags &= -5;
445
- for (let l = dep.computed.deps; l; l = l.nextDep) {
446
- removeSub(l, true);
447
- }
448
- }
449
- }
450
- if (!soft && !--dep.sc && dep.map) {
451
- dep.map.delete(dep.key);
452
- }
406
+ const { dep, prevSub, nextSub } = link;
407
+ if (prevSub) {
408
+ prevSub.nextSub = nextSub;
409
+ link.prevSub = void 0;
410
+ }
411
+ if (nextSub) {
412
+ nextSub.prevSub = prevSub;
413
+ link.nextSub = void 0;
414
+ }
415
+ if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) dep.subsHead = nextSub;
416
+ if (dep.subs === link) {
417
+ dep.subs = prevSub;
418
+ if (!prevSub && dep.computed) {
419
+ dep.computed.flags &= -5;
420
+ for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true);
421
+ }
422
+ }
423
+ if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key);
453
424
  }
454
425
  function removeDep(link) {
455
- const { prevDep, nextDep } = link;
456
- if (prevDep) {
457
- prevDep.nextDep = nextDep;
458
- link.prevDep = void 0;
459
- }
460
- if (nextDep) {
461
- nextDep.prevDep = prevDep;
462
- link.nextDep = void 0;
463
- }
426
+ const { prevDep, nextDep } = link;
427
+ if (prevDep) {
428
+ prevDep.nextDep = nextDep;
429
+ link.prevDep = void 0;
430
+ }
431
+ if (nextDep) {
432
+ nextDep.prevDep = prevDep;
433
+ link.nextDep = void 0;
434
+ }
464
435
  }
465
436
  function effect(fn, options) {
466
- if (fn.effect instanceof ReactiveEffect) {
467
- fn = fn.effect.fn;
468
- }
469
- const e = new ReactiveEffect(fn);
470
- if (options) {
471
- extend(e, options);
472
- }
473
- try {
474
- e.run();
475
- } catch (err) {
476
- e.stop();
477
- throw err;
478
- }
479
- const runner = e.run.bind(e);
480
- runner.effect = e;
481
- return runner;
437
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
438
+ const e = new ReactiveEffect(fn);
439
+ if (options) extend(e, options);
440
+ try {
441
+ e.run();
442
+ } catch (err) {
443
+ e.stop();
444
+ throw err;
445
+ }
446
+ const runner = e.run.bind(e);
447
+ runner.effect = e;
448
+ return runner;
482
449
  }
483
450
  function stop(runner) {
484
- runner.effect.stop();
451
+ runner.effect.stop();
485
452
  }
486
- let shouldTrack = true;
487
- const trackStack = [];
453
+ var shouldTrack = true;
454
+ var trackStack = [];
488
455
  function pauseTracking() {
489
- trackStack.push(shouldTrack);
490
- shouldTrack = false;
456
+ trackStack.push(shouldTrack);
457
+ shouldTrack = false;
491
458
  }
492
459
  function enableTracking() {
493
- trackStack.push(shouldTrack);
494
- shouldTrack = true;
460
+ trackStack.push(shouldTrack);
461
+ shouldTrack = true;
495
462
  }
496
463
  function resetTracking() {
497
- const last = trackStack.pop();
498
- shouldTrack = last === void 0 ? true : last;
464
+ const last = trackStack.pop();
465
+ shouldTrack = last === void 0 ? true : last;
499
466
  }
500
467
  function onEffectCleanup(fn, failSilently = false) {
501
- if (activeSub instanceof ReactiveEffect) {
502
- activeSub.cleanup = fn;
503
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
504
- warn$1(
505
- `onEffectCleanup() was called when there was no active effect to associate with.`
506
- );
507
- }
468
+ if (activeSub instanceof ReactiveEffect) activeSub.cleanup = fn;
469
+ else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onEffectCleanup() was called when there was no active effect to associate with.`);
508
470
  }
509
471
  function cleanupEffect(e) {
510
- const { cleanup } = e;
511
- e.cleanup = void 0;
512
- if (cleanup) {
513
- const prevSub = activeSub;
514
- activeSub = void 0;
515
- try {
516
- cleanup();
517
- } finally {
518
- activeSub = prevSub;
519
- }
520
- }
521
- }
522
- let globalVersion = 0;
523
- class Link {
524
- constructor(sub, dep) {
525
- this.sub = sub;
526
- this.dep = dep;
527
- this.version = dep.version;
528
- this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
529
- }
530
- }
531
- class Dep {
532
- // TODO isolatedDeclarations "__v_skip"
533
- constructor(computed2) {
534
- this.computed = computed2;
535
- this.version = 0;
536
- this.activeLink = void 0;
537
- this.subs = void 0;
538
- this.map = void 0;
539
- this.key = void 0;
540
- this.sc = 0;
541
- this.__v_skip = true;
542
- if (!!(process.env.NODE_ENV !== "production")) {
543
- this.subsHead = void 0;
544
- }
545
- }
546
- track(debugInfo) {
547
- if (!activeSub || !shouldTrack || activeSub === this.computed) {
548
- return;
549
- }
550
- let link = this.activeLink;
551
- if (link === void 0 || link.sub !== activeSub) {
552
- link = this.activeLink = new Link(activeSub, this);
553
- if (!activeSub.deps) {
554
- activeSub.deps = activeSub.depsTail = link;
555
- } else {
556
- link.prevDep = activeSub.depsTail;
557
- activeSub.depsTail.nextDep = link;
558
- activeSub.depsTail = link;
559
- }
560
- addSub(link);
561
- } else if (link.version === -1) {
562
- link.version = this.version;
563
- if (link.nextDep) {
564
- const next = link.nextDep;
565
- next.prevDep = link.prevDep;
566
- if (link.prevDep) {
567
- link.prevDep.nextDep = next;
568
- }
569
- link.prevDep = activeSub.depsTail;
570
- link.nextDep = void 0;
571
- activeSub.depsTail.nextDep = link;
572
- activeSub.depsTail = link;
573
- if (activeSub.deps === link) {
574
- activeSub.deps = next;
575
- }
576
- }
577
- }
578
- if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) {
579
- activeSub.onTrack(
580
- extend(
581
- {
582
- effect: activeSub
583
- },
584
- debugInfo
585
- )
586
- );
587
- }
588
- return link;
589
- }
590
- trigger(debugInfo) {
591
- this.version++;
592
- globalVersion++;
593
- this.notify(debugInfo);
594
- }
595
- notify(debugInfo) {
596
- startBatch();
597
- try {
598
- if (!!(process.env.NODE_ENV !== "production")) {
599
- for (let head = this.subsHead; head; head = head.nextSub) {
600
- if (head.sub.onTrigger && !(head.sub.flags & 8)) {
601
- head.sub.onTrigger(
602
- extend(
603
- {
604
- effect: head.sub
605
- },
606
- debugInfo
607
- )
608
- );
609
- }
610
- }
611
- }
612
- for (let link = this.subs; link; link = link.prevSub) {
613
- if (link.sub.notify()) {
614
- ;
615
- link.sub.dep.notify();
616
- }
617
- }
618
- } finally {
619
- endBatch();
620
- }
621
- }
622
- }
472
+ const { cleanup } = e;
473
+ e.cleanup = void 0;
474
+ if (cleanup) {
475
+ const prevSub = activeSub;
476
+ activeSub = void 0;
477
+ try {
478
+ cleanup();
479
+ } finally {
480
+ activeSub = prevSub;
481
+ }
482
+ }
483
+ }
484
+ var globalVersion = 0;
485
+ var Link = class {
486
+ constructor(sub, dep) {
487
+ this.sub = sub;
488
+ this.dep = dep;
489
+ this.version = dep.version;
490
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
491
+ }
492
+ };
493
+ var Dep = class {
494
+ constructor(computed) {
495
+ this.computed = computed;
496
+ this.version = 0;
497
+ /**
498
+ * Link between this dep and the current active effect
499
+ */
500
+ this.activeLink = void 0;
501
+ /**
502
+ * Doubly linked list representing the subscribing effects (tail)
503
+ */
504
+ this.subs = void 0;
505
+ /**
506
+ * For object property deps cleanup
507
+ */
508
+ this.map = void 0;
509
+ this.key = void 0;
510
+ /**
511
+ * Subscriber counter
512
+ */
513
+ this.sc = 0;
514
+ /**
515
+ * @internal
516
+ */
517
+ this.__v_skip = true;
518
+ if (!!(process.env.NODE_ENV !== "production")) this.subsHead = void 0;
519
+ }
520
+ track(debugInfo) {
521
+ if (!activeSub || !shouldTrack || activeSub === this.computed) return;
522
+ let link = this.activeLink;
523
+ if (link === void 0 || link.sub !== activeSub) {
524
+ link = this.activeLink = new Link(activeSub, this);
525
+ if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link;
526
+ else {
527
+ link.prevDep = activeSub.depsTail;
528
+ activeSub.depsTail.nextDep = link;
529
+ activeSub.depsTail = link;
530
+ }
531
+ addSub(link);
532
+ } else if (link.version === -1) {
533
+ link.version = this.version;
534
+ if (link.nextDep) {
535
+ const next = link.nextDep;
536
+ next.prevDep = link.prevDep;
537
+ if (link.prevDep) link.prevDep.nextDep = next;
538
+ link.prevDep = activeSub.depsTail;
539
+ link.nextDep = void 0;
540
+ activeSub.depsTail.nextDep = link;
541
+ activeSub.depsTail = link;
542
+ if (activeSub.deps === link) activeSub.deps = next;
543
+ }
544
+ }
545
+ if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) activeSub.onTrack(extend({ effect: activeSub }, debugInfo));
546
+ return link;
547
+ }
548
+ trigger(debugInfo) {
549
+ this.version++;
550
+ globalVersion++;
551
+ this.notify(debugInfo);
552
+ }
553
+ notify(debugInfo) {
554
+ startBatch();
555
+ try {
556
+ if (!!(process.env.NODE_ENV !== "production")) {
557
+ for (let head = this.subsHead; head; head = head.nextSub) if (head.sub.onTrigger && !(head.sub.flags & 8)) head.sub.onTrigger(extend({ effect: head.sub }, debugInfo));
558
+ }
559
+ for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify();
560
+ } finally {
561
+ endBatch();
562
+ }
563
+ }
564
+ };
623
565
  function addSub(link) {
624
- link.dep.sc++;
625
- if (link.sub.flags & 4) {
626
- const computed2 = link.dep.computed;
627
- if (computed2 && !link.dep.subs) {
628
- computed2.flags |= 4 | 16;
629
- for (let l = computed2.deps; l; l = l.nextDep) {
630
- addSub(l);
631
- }
632
- }
633
- const currentTail = link.dep.subs;
634
- if (currentTail !== link) {
635
- link.prevSub = currentTail;
636
- if (currentTail) currentTail.nextSub = link;
637
- }
638
- if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
639
- link.dep.subsHead = link;
640
- }
641
- link.dep.subs = link;
642
- }
643
- }
644
- const targetMap = /* @__PURE__ */ new WeakMap();
645
- const ITERATE_KEY = /* @__PURE__ */ Symbol(
646
- !!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""
647
- );
648
- const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
649
- !!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""
650
- );
651
- const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
652
- !!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""
653
- );
566
+ link.dep.sc++;
567
+ if (link.sub.flags & 4) {
568
+ const computed = link.dep.computed;
569
+ if (computed && !link.dep.subs) {
570
+ computed.flags |= 20;
571
+ for (let l = computed.deps; l; l = l.nextDep) addSub(l);
572
+ }
573
+ const currentTail = link.dep.subs;
574
+ if (currentTail !== link) {
575
+ link.prevSub = currentTail;
576
+ if (currentTail) currentTail.nextSub = link;
577
+ }
578
+ if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) link.dep.subsHead = link;
579
+ link.dep.subs = link;
580
+ }
581
+ }
582
+ var targetMap = /* @__PURE__ */ new WeakMap();
583
+ var ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
584
+ var MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
585
+ var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "Array iterate" : "");
654
586
  function track(target, type, key) {
655
- if (shouldTrack && activeSub) {
656
- let depsMap = targetMap.get(target);
657
- if (!depsMap) {
658
- targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
659
- }
660
- let dep = depsMap.get(key);
661
- if (!dep) {
662
- depsMap.set(key, dep = new Dep());
663
- dep.map = depsMap;
664
- dep.key = key;
665
- }
666
- if (!!(process.env.NODE_ENV !== "production")) {
667
- dep.track({
668
- target,
669
- type,
670
- key
671
- });
672
- } else {
673
- dep.track();
674
- }
675
- }
587
+ if (shouldTrack && activeSub) {
588
+ let depsMap = targetMap.get(target);
589
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
590
+ let dep = depsMap.get(key);
591
+ if (!dep) {
592
+ depsMap.set(key, dep = new Dep());
593
+ dep.map = depsMap;
594
+ dep.key = key;
595
+ }
596
+ if (!!(process.env.NODE_ENV !== "production")) dep.track({
597
+ target,
598
+ type,
599
+ key
600
+ });
601
+ else dep.track();
602
+ }
676
603
  }
677
604
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
678
- const depsMap = targetMap.get(target);
679
- if (!depsMap) {
680
- globalVersion++;
681
- return;
682
- }
683
- const run = (dep) => {
684
- if (dep) {
685
- if (!!(process.env.NODE_ENV !== "production")) {
686
- dep.trigger({
687
- target,
688
- type,
689
- key,
690
- newValue,
691
- oldValue,
692
- oldTarget
693
- });
694
- } else {
695
- dep.trigger();
696
- }
697
- }
698
- };
699
- startBatch();
700
- if (type === "clear") {
701
- depsMap.forEach(run);
702
- } else {
703
- const targetIsArray = isArray(target);
704
- const isArrayIndex = targetIsArray && isIntegerKey(key);
705
- if (targetIsArray && key === "length") {
706
- const newLength = Number(newValue);
707
- depsMap.forEach((dep, key2) => {
708
- if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
709
- run(dep);
710
- }
711
- });
712
- } else {
713
- if (key !== void 0 || depsMap.has(void 0)) {
714
- run(depsMap.get(key));
715
- }
716
- if (isArrayIndex) {
717
- run(depsMap.get(ARRAY_ITERATE_KEY));
718
- }
719
- switch (type) {
720
- case "add":
721
- if (!targetIsArray) {
722
- run(depsMap.get(ITERATE_KEY));
723
- if (isMap(target)) {
724
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
725
- }
726
- } else if (isArrayIndex) {
727
- run(depsMap.get("length"));
728
- }
729
- break;
730
- case "delete":
731
- if (!targetIsArray) {
732
- run(depsMap.get(ITERATE_KEY));
733
- if (isMap(target)) {
734
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
735
- }
736
- }
737
- break;
738
- case "set":
739
- if (isMap(target)) {
740
- run(depsMap.get(ITERATE_KEY));
741
- }
742
- break;
743
- }
744
- }
745
- }
746
- endBatch();
605
+ const depsMap = targetMap.get(target);
606
+ if (!depsMap) {
607
+ globalVersion++;
608
+ return;
609
+ }
610
+ const run = (dep) => {
611
+ if (dep) if (!!(process.env.NODE_ENV !== "production")) dep.trigger({
612
+ target,
613
+ type,
614
+ key,
615
+ newValue,
616
+ oldValue,
617
+ oldTarget
618
+ });
619
+ else dep.trigger();
620
+ };
621
+ startBatch();
622
+ if (type === "clear") depsMap.forEach(run);
623
+ else {
624
+ const targetIsArray = isArray(target);
625
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
626
+ if (targetIsArray && key === "length") {
627
+ const newLength = Number(newValue);
628
+ depsMap.forEach((dep, key2) => {
629
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) run(dep);
630
+ });
631
+ } else {
632
+ if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key));
633
+ if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY));
634
+ switch (type) {
635
+ case "add":
636
+ if (!targetIsArray) {
637
+ run(depsMap.get(ITERATE_KEY));
638
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
639
+ } else if (isArrayIndex) run(depsMap.get("length"));
640
+ break;
641
+ case "delete":
642
+ if (!targetIsArray) {
643
+ run(depsMap.get(ITERATE_KEY));
644
+ if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
645
+ }
646
+ break;
647
+ case "set":
648
+ if (isMap(target)) run(depsMap.get(ITERATE_KEY));
649
+ break;
650
+ }
651
+ }
652
+ }
653
+ endBatch();
747
654
  }
748
655
  function getDepFromReactive(object, key) {
749
- const depMap = targetMap.get(object);
750
- return depMap && depMap.get(key);
656
+ const depMap = targetMap.get(object);
657
+ return depMap && depMap.get(key);
751
658
  }
752
659
  function reactiveReadArray(array) {
753
- const raw = toRaw(array);
754
- if (raw === array) return raw;
755
- track(raw, "iterate", ARRAY_ITERATE_KEY);
756
- return isShallow(array) ? raw : raw.map(toReactive);
660
+ const raw = /* @__PURE__ */ toRaw(array);
661
+ if (raw === array) return raw;
662
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
663
+ return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
757
664
  }
758
665
  function shallowReadArray(arr) {
759
- track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
760
- return arr;
666
+ track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
667
+ return arr;
761
668
  }
762
669
  function toWrapped(target, item) {
763
- if (isReadonly(target)) {
764
- return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
765
- }
766
- return toReactive(item);
767
- }
768
- const arrayInstrumentations = {
769
- __proto__: null,
770
- [Symbol.iterator]() {
771
- return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
772
- },
773
- concat(...args) {
774
- return reactiveReadArray(this).concat(
775
- ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
776
- );
777
- },
778
- entries() {
779
- return iterator(this, "entries", (value) => {
780
- value[1] = toWrapped(this, value[1]);
781
- return value;
782
- });
783
- },
784
- every(fn, thisArg) {
785
- return apply(this, "every", fn, thisArg, void 0, arguments);
786
- },
787
- filter(fn, thisArg) {
788
- return apply(
789
- this,
790
- "filter",
791
- fn,
792
- thisArg,
793
- (v) => v.map((item) => toWrapped(this, item)),
794
- arguments
795
- );
796
- },
797
- find(fn, thisArg) {
798
- return apply(
799
- this,
800
- "find",
801
- fn,
802
- thisArg,
803
- (item) => toWrapped(this, item),
804
- arguments
805
- );
806
- },
807
- findIndex(fn, thisArg) {
808
- return apply(this, "findIndex", fn, thisArg, void 0, arguments);
809
- },
810
- findLast(fn, thisArg) {
811
- return apply(
812
- this,
813
- "findLast",
814
- fn,
815
- thisArg,
816
- (item) => toWrapped(this, item),
817
- arguments
818
- );
819
- },
820
- findLastIndex(fn, thisArg) {
821
- return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
822
- },
823
- // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
824
- forEach(fn, thisArg) {
825
- return apply(this, "forEach", fn, thisArg, void 0, arguments);
826
- },
827
- includes(...args) {
828
- return searchProxy(this, "includes", args);
829
- },
830
- indexOf(...args) {
831
- return searchProxy(this, "indexOf", args);
832
- },
833
- join(separator) {
834
- return reactiveReadArray(this).join(separator);
835
- },
836
- // keys() iterator only reads `length`, no optimization required
837
- lastIndexOf(...args) {
838
- return searchProxy(this, "lastIndexOf", args);
839
- },
840
- map(fn, thisArg) {
841
- return apply(this, "map", fn, thisArg, void 0, arguments);
842
- },
843
- pop() {
844
- return noTracking(this, "pop");
845
- },
846
- push(...args) {
847
- return noTracking(this, "push", args);
848
- },
849
- reduce(fn, ...args) {
850
- return reduce(this, "reduce", fn, args);
851
- },
852
- reduceRight(fn, ...args) {
853
- return reduce(this, "reduceRight", fn, args);
854
- },
855
- shift() {
856
- return noTracking(this, "shift");
857
- },
858
- // slice could use ARRAY_ITERATE but also seems to beg for range tracking
859
- some(fn, thisArg) {
860
- return apply(this, "some", fn, thisArg, void 0, arguments);
861
- },
862
- splice(...args) {
863
- return noTracking(this, "splice", args);
864
- },
865
- toReversed() {
866
- return reactiveReadArray(this).toReversed();
867
- },
868
- toSorted(comparer) {
869
- return reactiveReadArray(this).toSorted(comparer);
870
- },
871
- toSpliced(...args) {
872
- return reactiveReadArray(this).toSpliced(...args);
873
- },
874
- unshift(...args) {
875
- return noTracking(this, "unshift", args);
876
- },
877
- values() {
878
- return iterator(this, "values", (item) => toWrapped(this, item));
879
- }
670
+ if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
671
+ return toReactive(item);
672
+ }
673
+ var arrayInstrumentations = {
674
+ __proto__: null,
675
+ [Symbol.iterator]() {
676
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
677
+ },
678
+ concat(...args) {
679
+ return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
680
+ },
681
+ entries() {
682
+ return iterator(this, "entries", (value) => {
683
+ value[1] = toWrapped(this, value[1]);
684
+ return value;
685
+ });
686
+ },
687
+ every(fn, thisArg) {
688
+ return apply(this, "every", fn, thisArg, void 0, arguments);
689
+ },
690
+ filter(fn, thisArg) {
691
+ return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
692
+ },
693
+ find(fn, thisArg) {
694
+ return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
695
+ },
696
+ findIndex(fn, thisArg) {
697
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
698
+ },
699
+ findLast(fn, thisArg) {
700
+ return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
701
+ },
702
+ findLastIndex(fn, thisArg) {
703
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
704
+ },
705
+ forEach(fn, thisArg) {
706
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
707
+ },
708
+ includes(...args) {
709
+ return searchProxy(this, "includes", args);
710
+ },
711
+ indexOf(...args) {
712
+ return searchProxy(this, "indexOf", args);
713
+ },
714
+ join(separator) {
715
+ return reactiveReadArray(this).join(separator);
716
+ },
717
+ lastIndexOf(...args) {
718
+ return searchProxy(this, "lastIndexOf", args);
719
+ },
720
+ map(fn, thisArg) {
721
+ return apply(this, "map", fn, thisArg, void 0, arguments);
722
+ },
723
+ pop() {
724
+ return noTracking(this, "pop");
725
+ },
726
+ push(...args) {
727
+ return noTracking(this, "push", args);
728
+ },
729
+ reduce(fn, ...args) {
730
+ return reduce(this, "reduce", fn, args);
731
+ },
732
+ reduceRight(fn, ...args) {
733
+ return reduce(this, "reduceRight", fn, args);
734
+ },
735
+ shift() {
736
+ return noTracking(this, "shift");
737
+ },
738
+ some(fn, thisArg) {
739
+ return apply(this, "some", fn, thisArg, void 0, arguments);
740
+ },
741
+ splice(...args) {
742
+ return noTracking(this, "splice", args);
743
+ },
744
+ toReversed() {
745
+ return reactiveReadArray(this).toReversed();
746
+ },
747
+ toSorted(comparer) {
748
+ return reactiveReadArray(this).toSorted(comparer);
749
+ },
750
+ toSpliced(...args) {
751
+ return reactiveReadArray(this).toSpliced(...args);
752
+ },
753
+ unshift(...args) {
754
+ return noTracking(this, "unshift", args);
755
+ },
756
+ values() {
757
+ return iterator(this, "values", (item) => toWrapped(this, item));
758
+ }
880
759
  };
881
760
  function iterator(self, method, wrapValue) {
882
- const arr = shallowReadArray(self);
883
- const iter = arr[method]();
884
- if (arr !== self && !isShallow(self)) {
885
- iter._next = iter.next;
886
- iter.next = () => {
887
- const result = iter._next();
888
- if (!result.done) {
889
- result.value = wrapValue(result.value);
890
- }
891
- return result;
892
- };
893
- }
894
- return iter;
895
- }
896
- const arrayProto = Array.prototype;
761
+ const arr = shallowReadArray(self);
762
+ const iter = arr[method]();
763
+ if (arr !== self && !/* @__PURE__ */ isShallow(self)) {
764
+ iter._next = iter.next;
765
+ iter.next = () => {
766
+ const result = iter._next();
767
+ if (!result.done) result.value = wrapValue(result.value);
768
+ return result;
769
+ };
770
+ }
771
+ return iter;
772
+ }
773
+ var arrayProto = Array.prototype;
897
774
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
898
- const arr = shallowReadArray(self);
899
- const needsWrap = arr !== self && !isShallow(self);
900
- const methodFn = arr[method];
901
- if (methodFn !== arrayProto[method]) {
902
- const result2 = methodFn.apply(self, args);
903
- return needsWrap ? toReactive(result2) : result2;
904
- }
905
- let wrappedFn = fn;
906
- if (arr !== self) {
907
- if (needsWrap) {
908
- wrappedFn = function(item, index) {
909
- return fn.call(this, toWrapped(self, item), index, self);
910
- };
911
- } else if (fn.length > 2) {
912
- wrappedFn = function(item, index) {
913
- return fn.call(this, item, index, self);
914
- };
915
- }
916
- }
917
- const result = methodFn.call(arr, wrappedFn, thisArg);
918
- return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
775
+ const arr = shallowReadArray(self);
776
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
777
+ const methodFn = arr[method];
778
+ if (methodFn !== arrayProto[method]) {
779
+ const result2 = methodFn.apply(self, args);
780
+ return needsWrap ? toReactive(result2) : result2;
781
+ }
782
+ let wrappedFn = fn;
783
+ if (arr !== self) {
784
+ if (needsWrap) wrappedFn = function(item, index) {
785
+ return fn.call(this, toWrapped(self, item), index, self);
786
+ };
787
+ else if (fn.length > 2) wrappedFn = function(item, index) {
788
+ return fn.call(this, item, index, self);
789
+ };
790
+ }
791
+ const result = methodFn.call(arr, wrappedFn, thisArg);
792
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
919
793
  }
920
794
  function reduce(self, method, fn, args) {
921
- const arr = shallowReadArray(self);
922
- let wrappedFn = fn;
923
- if (arr !== self) {
924
- if (!isShallow(self)) {
925
- wrappedFn = function(acc, item, index) {
926
- return fn.call(this, acc, toWrapped(self, item), index, self);
927
- };
928
- } else if (fn.length > 3) {
929
- wrappedFn = function(acc, item, index) {
930
- return fn.call(this, acc, item, index, self);
931
- };
932
- }
933
- }
934
- return arr[method](wrappedFn, ...args);
795
+ const arr = shallowReadArray(self);
796
+ const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self);
797
+ let wrappedFn = fn;
798
+ let wrapInitialAccumulator = false;
799
+ if (arr !== self) {
800
+ if (needsWrap) {
801
+ wrapInitialAccumulator = args.length === 0;
802
+ wrappedFn = function(acc, item, index) {
803
+ if (wrapInitialAccumulator) {
804
+ wrapInitialAccumulator = false;
805
+ acc = toWrapped(self, acc);
806
+ }
807
+ return fn.call(this, acc, toWrapped(self, item), index, self);
808
+ };
809
+ } else if (fn.length > 3) wrappedFn = function(acc, item, index) {
810
+ return fn.call(this, acc, item, index, self);
811
+ };
812
+ }
813
+ const result = arr[method](wrappedFn, ...args);
814
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
935
815
  }
936
816
  function searchProxy(self, method, args) {
937
- const arr = toRaw(self);
938
- track(arr, "iterate", ARRAY_ITERATE_KEY);
939
- const res = arr[method](...args);
940
- if ((res === -1 || res === false) && isProxy(args[0])) {
941
- args[0] = toRaw(args[0]);
942
- return arr[method](...args);
943
- }
944
- return res;
817
+ const arr = /* @__PURE__ */ toRaw(self);
818
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
819
+ const res = arr[method](...args);
820
+ if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) {
821
+ args[0] = /* @__PURE__ */ toRaw(args[0]);
822
+ return arr[method](...args);
823
+ }
824
+ return res;
945
825
  }
946
826
  function noTracking(self, method, args = []) {
947
- pauseTracking();
948
- startBatch();
949
- const res = toRaw(self)[method].apply(self, args);
950
- endBatch();
951
- resetTracking();
952
- return res;
953
- }
954
- const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
955
- const builtInSymbols = new Set(
956
- /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
957
- );
827
+ pauseTracking();
828
+ startBatch();
829
+ const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args);
830
+ endBatch();
831
+ resetTracking();
832
+ return res;
833
+ }
834
+ var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
835
+ var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
958
836
  function hasOwnProperty(key) {
959
- if (!isSymbol(key)) key = String(key);
960
- const obj = toRaw(this);
961
- track(obj, "has", key);
962
- return obj.hasOwnProperty(key);
963
- }
964
- class BaseReactiveHandler {
965
- constructor(_isReadonly = false, _isShallow = false) {
966
- this._isReadonly = _isReadonly;
967
- this._isShallow = _isShallow;
968
- }
969
- get(target, key, receiver) {
970
- if (key === "__v_skip") return target["__v_skip"];
971
- const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
972
- if (key === "__v_isReactive") {
973
- return !isReadonly2;
974
- } else if (key === "__v_isReadonly") {
975
- return isReadonly2;
976
- } else if (key === "__v_isShallow") {
977
- return isShallow2;
978
- } else if (key === "__v_raw") {
979
- if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
980
- // this means the receiver is a user proxy of the reactive proxy
981
- Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
982
- return target;
983
- }
984
- return;
985
- }
986
- const targetIsArray = isArray(target);
987
- if (!isReadonly2) {
988
- let fn;
989
- if (targetIsArray && (fn = arrayInstrumentations[key])) {
990
- return fn;
991
- }
992
- if (key === "hasOwnProperty") {
993
- return hasOwnProperty;
994
- }
995
- }
996
- const res = Reflect.get(
997
- target,
998
- key,
999
- // if this is a proxy wrapping a ref, return methods using the raw ref
1000
- // as receiver so that we don't have to call `toRaw` on the ref in all
1001
- // its class methods
1002
- isRef(target) ? target : receiver
1003
- );
1004
- if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1005
- return res;
1006
- }
1007
- if (!isReadonly2) {
1008
- track(target, "get", key);
1009
- }
1010
- if (isShallow2) {
1011
- return res;
1012
- }
1013
- if (isRef(res)) {
1014
- const value = targetIsArray && isIntegerKey(key) ? res : res.value;
1015
- return isReadonly2 && isObject(value) ? readonly(value) : value;
1016
- }
1017
- if (isObject(res)) {
1018
- return isReadonly2 ? readonly(res) : reactive(res);
1019
- }
1020
- return res;
1021
- }
1022
- }
1023
- class MutableReactiveHandler extends BaseReactiveHandler {
1024
- constructor(isShallow2 = false) {
1025
- super(false, isShallow2);
1026
- }
1027
- set(target, key, value, receiver) {
1028
- let oldValue = target[key];
1029
- const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
1030
- if (!this._isShallow) {
1031
- const isOldValueReadonly = isReadonly(oldValue);
1032
- if (!isShallow(value) && !isReadonly(value)) {
1033
- oldValue = toRaw(oldValue);
1034
- value = toRaw(value);
1035
- }
1036
- if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
1037
- if (isOldValueReadonly) {
1038
- if (!!(process.env.NODE_ENV !== "production")) {
1039
- warn$1(
1040
- `Set operation on key "${String(key)}" failed: target is readonly.`,
1041
- target[key]
1042
- );
1043
- }
1044
- return true;
1045
- } else {
1046
- oldValue.value = value;
1047
- return true;
1048
- }
1049
- }
1050
- }
1051
- const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1052
- const result = Reflect.set(
1053
- target,
1054
- key,
1055
- value,
1056
- isRef(target) ? target : receiver
1057
- );
1058
- if (target === toRaw(receiver)) {
1059
- if (!hadKey) {
1060
- trigger(target, "add", key, value);
1061
- } else if (hasChanged(value, oldValue)) {
1062
- trigger(target, "set", key, value, oldValue);
1063
- }
1064
- }
1065
- return result;
1066
- }
1067
- deleteProperty(target, key) {
1068
- const hadKey = hasOwn(target, key);
1069
- const oldValue = target[key];
1070
- const result = Reflect.deleteProperty(target, key);
1071
- if (result && hadKey) {
1072
- trigger(target, "delete", key, void 0, oldValue);
1073
- }
1074
- return result;
1075
- }
1076
- has(target, key) {
1077
- const result = Reflect.has(target, key);
1078
- if (!isSymbol(key) || !builtInSymbols.has(key)) {
1079
- track(target, "has", key);
1080
- }
1081
- return result;
1082
- }
1083
- ownKeys(target) {
1084
- track(
1085
- target,
1086
- "iterate",
1087
- isArray(target) ? "length" : ITERATE_KEY
1088
- );
1089
- return Reflect.ownKeys(target);
1090
- }
1091
- }
1092
- class ReadonlyReactiveHandler extends BaseReactiveHandler {
1093
- constructor(isShallow2 = false) {
1094
- super(true, isShallow2);
1095
- }
1096
- set(target, key) {
1097
- if (!!(process.env.NODE_ENV !== "production")) {
1098
- warn$1(
1099
- `Set operation on key "${String(key)}" failed: target is readonly.`,
1100
- target
1101
- );
1102
- }
1103
- return true;
1104
- }
1105
- deleteProperty(target, key) {
1106
- if (!!(process.env.NODE_ENV !== "production")) {
1107
- warn$1(
1108
- `Delete operation on key "${String(key)}" failed: target is readonly.`,
1109
- target
1110
- );
1111
- }
1112
- return true;
1113
- }
1114
- }
1115
- const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
1116
- const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
1117
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
1118
- const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
1119
- const toShallow = (value) => value;
1120
- const getProto = (v) => Reflect.getPrototypeOf(v);
837
+ if (!isSymbol(key)) key = String(key);
838
+ const obj = /* @__PURE__ */ toRaw(this);
839
+ track(obj, "has", key);
840
+ return obj.hasOwnProperty(key);
841
+ }
842
+ var BaseReactiveHandler = class {
843
+ constructor(_isReadonly = false, _isShallow = false) {
844
+ this._isReadonly = _isReadonly;
845
+ this._isShallow = _isShallow;
846
+ }
847
+ get(target, key, receiver) {
848
+ if (key === "__v_skip") return target["__v_skip"];
849
+ const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
850
+ if (key === "__v_isReactive") return !isReadonly2;
851
+ else if (key === "__v_isReadonly") return isReadonly2;
852
+ else if (key === "__v_isShallow") return isShallow2;
853
+ else if (key === "__v_raw") {
854
+ if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
855
+ return;
856
+ }
857
+ const targetIsArray = isArray(target);
858
+ if (!isReadonly2) {
859
+ let fn;
860
+ if (targetIsArray && (fn = arrayInstrumentations[key])) return fn;
861
+ if (key === "hasOwnProperty") return hasOwnProperty;
862
+ }
863
+ const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver);
864
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
865
+ if (!isReadonly2) track(target, "get", key);
866
+ if (isShallow2) return res;
867
+ if (/* @__PURE__ */ isRef(res)) {
868
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
869
+ return isReadonly2 && isObject(value) ? /* @__PURE__ */ readonly(value) : value;
870
+ }
871
+ if (isObject(res)) return isReadonly2 ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res);
872
+ return res;
873
+ }
874
+ };
875
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
876
+ constructor(isShallow2 = false) {
877
+ super(false, isShallow2);
878
+ }
879
+ set(target, key, value, receiver) {
880
+ let oldValue = target[key];
881
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
882
+ if (!this._isShallow) {
883
+ const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue);
884
+ if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) {
885
+ oldValue = /* @__PURE__ */ toRaw(oldValue);
886
+ value = /* @__PURE__ */ toRaw(value);
887
+ }
888
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
889
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
890
+ return true;
891
+ } else {
892
+ oldValue.value = value;
893
+ return true;
894
+ }
895
+ }
896
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
897
+ const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
898
+ if (target === /* @__PURE__ */ toRaw(receiver)) {
899
+ if (!hadKey) trigger(target, "add", key, value);
900
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
901
+ }
902
+ return result;
903
+ }
904
+ deleteProperty(target, key) {
905
+ const hadKey = hasOwn(target, key);
906
+ const oldValue = target[key];
907
+ const result = Reflect.deleteProperty(target, key);
908
+ if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
909
+ return result;
910
+ }
911
+ has(target, key) {
912
+ const result = Reflect.has(target, key);
913
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
914
+ return result;
915
+ }
916
+ ownKeys(target) {
917
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
918
+ return Reflect.ownKeys(target);
919
+ }
920
+ };
921
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
922
+ constructor(isShallow2 = false) {
923
+ super(true, isShallow2);
924
+ }
925
+ set(target, key) {
926
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
927
+ return true;
928
+ }
929
+ deleteProperty(target, key) {
930
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
931
+ return true;
932
+ }
933
+ };
934
+ var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
935
+ var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
936
+ var shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
937
+ var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
938
+ var toShallow = (value) => value;
939
+ var getProto = (v) => Reflect.getPrototypeOf(v);
1121
940
  function createIterableMethod(method, isReadonly2, isShallow2) {
1122
- return function(...args) {
1123
- const target = this["__v_raw"];
1124
- const rawTarget = toRaw(target);
1125
- const targetIsMap = isMap(rawTarget);
1126
- const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1127
- const isKeyOnly = method === "keys" && targetIsMap;
1128
- const innerIterator = target[method](...args);
1129
- const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
1130
- !isReadonly2 && track(
1131
- rawTarget,
1132
- "iterate",
1133
- isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
1134
- );
1135
- return {
1136
- // iterator protocol
1137
- next() {
1138
- const { value, done } = innerIterator.next();
1139
- return done ? { value, done } : {
1140
- value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1141
- done
1142
- };
1143
- },
1144
- // iterable protocol
1145
- [Symbol.iterator]() {
1146
- return this;
1147
- }
1148
- };
1149
- };
941
+ return function(...args) {
942
+ const target = this["__v_raw"];
943
+ const rawTarget = /* @__PURE__ */ toRaw(target);
944
+ const targetIsMap = isMap(rawTarget);
945
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
946
+ const isKeyOnly = method === "keys" && targetIsMap;
947
+ const innerIterator = target[method](...args);
948
+ const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
949
+ !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
950
+ return extend(Object.create(innerIterator), { next() {
951
+ const { value, done } = innerIterator.next();
952
+ return done ? {
953
+ value,
954
+ done
955
+ } : {
956
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
957
+ done
958
+ };
959
+ } });
960
+ };
1150
961
  }
1151
962
  function createReadonlyMethod(type) {
1152
- return function(...args) {
1153
- if (!!(process.env.NODE_ENV !== "production")) {
1154
- const key = args[0] ? `on key "${args[0]}" ` : ``;
1155
- warn$1(
1156
- `${capitalize(type)} operation ${key}failed: target is readonly.`,
1157
- toRaw(this)
1158
- );
1159
- }
1160
- return type === "delete" ? false : type === "clear" ? void 0 : this;
1161
- };
1162
- }
1163
- function createInstrumentations(readonly2, shallow) {
1164
- const instrumentations = {
1165
- get(key) {
1166
- const target = this["__v_raw"];
1167
- const rawTarget = toRaw(target);
1168
- const rawKey = toRaw(key);
1169
- if (!readonly2) {
1170
- if (hasChanged(key, rawKey)) {
1171
- track(rawTarget, "get", key);
1172
- }
1173
- track(rawTarget, "get", rawKey);
1174
- }
1175
- const { has } = getProto(rawTarget);
1176
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1177
- if (has.call(rawTarget, key)) {
1178
- return wrap(target.get(key));
1179
- } else if (has.call(rawTarget, rawKey)) {
1180
- return wrap(target.get(rawKey));
1181
- } else if (target !== rawTarget) {
1182
- target.get(key);
1183
- }
1184
- },
1185
- get size() {
1186
- const target = this["__v_raw"];
1187
- !readonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
1188
- return target.size;
1189
- },
1190
- has(key) {
1191
- const target = this["__v_raw"];
1192
- const rawTarget = toRaw(target);
1193
- const rawKey = toRaw(key);
1194
- if (!readonly2) {
1195
- if (hasChanged(key, rawKey)) {
1196
- track(rawTarget, "has", key);
1197
- }
1198
- track(rawTarget, "has", rawKey);
1199
- }
1200
- return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1201
- },
1202
- forEach(callback, thisArg) {
1203
- const observed = this;
1204
- const target = observed["__v_raw"];
1205
- const rawTarget = toRaw(target);
1206
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1207
- !readonly2 && track(rawTarget, "iterate", ITERATE_KEY);
1208
- return target.forEach((value, key) => {
1209
- return callback.call(thisArg, wrap(value), wrap(key), observed);
1210
- });
1211
- }
1212
- };
1213
- extend(
1214
- instrumentations,
1215
- readonly2 ? {
1216
- add: createReadonlyMethod("add"),
1217
- set: createReadonlyMethod("set"),
1218
- delete: createReadonlyMethod("delete"),
1219
- clear: createReadonlyMethod("clear")
1220
- } : {
1221
- add(value) {
1222
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1223
- value = toRaw(value);
1224
- }
1225
- const target = toRaw(this);
1226
- const proto = getProto(target);
1227
- const hadKey = proto.has.call(target, value);
1228
- if (!hadKey) {
1229
- target.add(value);
1230
- trigger(target, "add", value, value);
1231
- }
1232
- return this;
1233
- },
1234
- set(key, value) {
1235
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1236
- value = toRaw(value);
1237
- }
1238
- const target = toRaw(this);
1239
- const { has, get } = getProto(target);
1240
- let hadKey = has.call(target, key);
1241
- if (!hadKey) {
1242
- key = toRaw(key);
1243
- hadKey = has.call(target, key);
1244
- } else if (!!(process.env.NODE_ENV !== "production")) {
1245
- checkIdentityKeys(target, has, key);
1246
- }
1247
- const oldValue = get.call(target, key);
1248
- target.set(key, value);
1249
- if (!hadKey) {
1250
- trigger(target, "add", key, value);
1251
- } else if (hasChanged(value, oldValue)) {
1252
- trigger(target, "set", key, value, oldValue);
1253
- }
1254
- return this;
1255
- },
1256
- delete(key) {
1257
- const target = toRaw(this);
1258
- const { has, get } = getProto(target);
1259
- let hadKey = has.call(target, key);
1260
- if (!hadKey) {
1261
- key = toRaw(key);
1262
- hadKey = has.call(target, key);
1263
- } else if (!!(process.env.NODE_ENV !== "production")) {
1264
- checkIdentityKeys(target, has, key);
1265
- }
1266
- const oldValue = get ? get.call(target, key) : void 0;
1267
- const result = target.delete(key);
1268
- if (hadKey) {
1269
- trigger(target, "delete", key, void 0, oldValue);
1270
- }
1271
- return result;
1272
- },
1273
- clear() {
1274
- const target = toRaw(this);
1275
- const hadItems = target.size !== 0;
1276
- const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
1277
- const result = target.clear();
1278
- if (hadItems) {
1279
- trigger(
1280
- target,
1281
- "clear",
1282
- void 0,
1283
- void 0,
1284
- oldTarget
1285
- );
1286
- }
1287
- return result;
1288
- }
1289
- }
1290
- );
1291
- const iteratorMethods = [
1292
- "keys",
1293
- "values",
1294
- "entries",
1295
- Symbol.iterator
1296
- ];
1297
- iteratorMethods.forEach((method) => {
1298
- instrumentations[method] = createIterableMethod(method, readonly2, shallow);
1299
- });
1300
- return instrumentations;
963
+ return function(...args) {
964
+ if (!!(process.env.NODE_ENV !== "production")) {
965
+ const key = args[0] ? `on key "${args[0]}" ` : ``;
966
+ warn$1(`${capitalize(type)} operation ${key}failed: target is readonly.`, /* @__PURE__ */ toRaw(this));
967
+ }
968
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
969
+ };
970
+ }
971
+ function createInstrumentations(readonly, shallow) {
972
+ const instrumentations = {
973
+ get(key) {
974
+ const target = this["__v_raw"];
975
+ const rawTarget = /* @__PURE__ */ toRaw(target);
976
+ const rawKey = /* @__PURE__ */ toRaw(key);
977
+ if (!readonly) {
978
+ if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
979
+ track(rawTarget, "get", rawKey);
980
+ }
981
+ const { has } = getProto(rawTarget);
982
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
983
+ if (has.call(rawTarget, key)) return wrap(target.get(key));
984
+ else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
985
+ else if (target !== rawTarget) target.get(key);
986
+ },
987
+ get size() {
988
+ const target = this["__v_raw"];
989
+ !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY);
990
+ return target.size;
991
+ },
992
+ has(key) {
993
+ const target = this["__v_raw"];
994
+ const rawTarget = /* @__PURE__ */ toRaw(target);
995
+ const rawKey = /* @__PURE__ */ toRaw(key);
996
+ if (!readonly) {
997
+ if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
998
+ track(rawTarget, "has", rawKey);
999
+ }
1000
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1001
+ },
1002
+ forEach(callback, thisArg) {
1003
+ const observed = this;
1004
+ const target = observed["__v_raw"];
1005
+ const rawTarget = /* @__PURE__ */ toRaw(target);
1006
+ const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
1007
+ !readonly && track(rawTarget, "iterate", ITERATE_KEY);
1008
+ return target.forEach((value, key) => {
1009
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
1010
+ });
1011
+ }
1012
+ };
1013
+ extend(instrumentations, readonly ? {
1014
+ add: createReadonlyMethod("add"),
1015
+ set: createReadonlyMethod("set"),
1016
+ delete: createReadonlyMethod("delete"),
1017
+ clear: createReadonlyMethod("clear")
1018
+ } : {
1019
+ add(value) {
1020
+ const target = /* @__PURE__ */ toRaw(this);
1021
+ const proto = getProto(target);
1022
+ const rawValue = /* @__PURE__ */ toRaw(value);
1023
+ const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value;
1024
+ if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) {
1025
+ target.add(valueToAdd);
1026
+ trigger(target, "add", valueToAdd, valueToAdd);
1027
+ }
1028
+ return this;
1029
+ },
1030
+ set(key, value) {
1031
+ if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value);
1032
+ const target = /* @__PURE__ */ toRaw(this);
1033
+ const { has, get } = getProto(target);
1034
+ let hadKey = has.call(target, key);
1035
+ if (!hadKey) {
1036
+ key = /* @__PURE__ */ toRaw(key);
1037
+ hadKey = has.call(target, key);
1038
+ } else if (!!(process.env.NODE_ENV !== "production")) checkIdentityKeys(target, has, key);
1039
+ const oldValue = get.call(target, key);
1040
+ target.set(key, value);
1041
+ if (!hadKey) trigger(target, "add", key, value);
1042
+ else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1043
+ return this;
1044
+ },
1045
+ delete(key) {
1046
+ const target = /* @__PURE__ */ toRaw(this);
1047
+ const { has, get } = getProto(target);
1048
+ let hadKey = has.call(target, key);
1049
+ if (!hadKey) {
1050
+ key = /* @__PURE__ */ toRaw(key);
1051
+ hadKey = has.call(target, key);
1052
+ } else if (!!(process.env.NODE_ENV !== "production")) checkIdentityKeys(target, has, key);
1053
+ const oldValue = get ? get.call(target, key) : void 0;
1054
+ const result = target.delete(key);
1055
+ if (hadKey) trigger(target, "delete", key, void 0, oldValue);
1056
+ return result;
1057
+ },
1058
+ clear() {
1059
+ const target = /* @__PURE__ */ toRaw(this);
1060
+ const hadItems = target.size !== 0;
1061
+ const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
1062
+ const result = target.clear();
1063
+ if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
1064
+ return result;
1065
+ }
1066
+ });
1067
+ [
1068
+ "keys",
1069
+ "values",
1070
+ "entries",
1071
+ Symbol.iterator
1072
+ ].forEach((method) => {
1073
+ instrumentations[method] = createIterableMethod(method, readonly, shallow);
1074
+ });
1075
+ return instrumentations;
1301
1076
  }
1302
1077
  function createInstrumentationGetter(isReadonly2, shallow) {
1303
- const instrumentations = createInstrumentations(isReadonly2, shallow);
1304
- return (target, key, receiver) => {
1305
- if (key === "__v_isReactive") {
1306
- return !isReadonly2;
1307
- } else if (key === "__v_isReadonly") {
1308
- return isReadonly2;
1309
- } else if (key === "__v_raw") {
1310
- return target;
1311
- }
1312
- return Reflect.get(
1313
- hasOwn(instrumentations, key) && key in target ? instrumentations : target,
1314
- key,
1315
- receiver
1316
- );
1317
- };
1318
- }
1319
- const mutableCollectionHandlers = {
1320
- get: /* @__PURE__ */ createInstrumentationGetter(false, false)
1321
- };
1322
- const shallowCollectionHandlers = {
1323
- get: /* @__PURE__ */ createInstrumentationGetter(false, true)
1324
- };
1325
- const readonlyCollectionHandlers = {
1326
- get: /* @__PURE__ */ createInstrumentationGetter(true, false)
1327
- };
1328
- const shallowReadonlyCollectionHandlers = {
1329
- get: /* @__PURE__ */ createInstrumentationGetter(true, true)
1330
- };
1078
+ const instrumentations = createInstrumentations(isReadonly2, shallow);
1079
+ return (target, key, receiver) => {
1080
+ if (key === "__v_isReactive") return !isReadonly2;
1081
+ else if (key === "__v_isReadonly") return isReadonly2;
1082
+ else if (key === "__v_raw") return target;
1083
+ return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1084
+ };
1085
+ }
1086
+ var mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
1087
+ var shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
1088
+ var readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
1089
+ var shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
1331
1090
  function checkIdentityKeys(target, has, key) {
1332
- const rawKey = toRaw(key);
1333
- if (rawKey !== key && has.call(target, rawKey)) {
1334
- const type = toRawType(target);
1335
- warn$1(
1336
- `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.`
1337
- );
1338
- }
1339
- }
1340
- const reactiveMap = /* @__PURE__ */ new WeakMap();
1341
- const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1342
- const readonlyMap = /* @__PURE__ */ new WeakMap();
1343
- const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1091
+ const rawKey = /* @__PURE__ */ toRaw(key);
1092
+ if (rawKey !== key && has.call(target, rawKey)) {
1093
+ const type = toRawType(target);
1094
+ warn$1(`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.`);
1095
+ }
1096
+ }
1097
+ var reactiveMap = /* @__PURE__ */ new WeakMap();
1098
+ var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
1099
+ var readonlyMap = /* @__PURE__ */ new WeakMap();
1100
+ var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
1344
1101
  function targetTypeMap(rawType) {
1345
- switch (rawType) {
1346
- case "Object":
1347
- case "Array":
1348
- return 1;
1349
- case "Map":
1350
- case "Set":
1351
- case "WeakMap":
1352
- case "WeakSet":
1353
- return 2;
1354
- default:
1355
- return 0;
1356
- }
1102
+ switch (rawType) {
1103
+ case "Object":
1104
+ case "Array": return 1;
1105
+ case "Map":
1106
+ case "Set":
1107
+ case "WeakMap":
1108
+ case "WeakSet": return 2;
1109
+ default: return 0;
1110
+ }
1357
1111
  }
1358
1112
  function getTargetType(value) {
1359
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1113
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1360
1114
  }
1115
+ /* @__NO_SIDE_EFFECTS__ */
1361
1116
  function reactive(target) {
1362
- if (isReadonly(target)) {
1363
- return target;
1364
- }
1365
- return createReactiveObject(
1366
- target,
1367
- false,
1368
- mutableHandlers,
1369
- mutableCollectionHandlers,
1370
- reactiveMap
1371
- );
1117
+ if (/* @__PURE__ */ isReadonly(target)) return target;
1118
+ return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1372
1119
  }
1120
+ /* @__NO_SIDE_EFFECTS__ */
1373
1121
  function shallowReactive(target) {
1374
- return createReactiveObject(
1375
- target,
1376
- false,
1377
- shallowReactiveHandlers,
1378
- shallowCollectionHandlers,
1379
- shallowReactiveMap
1380
- );
1122
+ return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1381
1123
  }
1124
+ /* @__NO_SIDE_EFFECTS__ */
1382
1125
  function readonly(target) {
1383
- return createReactiveObject(
1384
- target,
1385
- true,
1386
- readonlyHandlers,
1387
- readonlyCollectionHandlers,
1388
- readonlyMap
1389
- );
1126
+ return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1390
1127
  }
1128
+ /* @__NO_SIDE_EFFECTS__ */
1391
1129
  function shallowReadonly(target) {
1392
- return createReactiveObject(
1393
- target,
1394
- true,
1395
- shallowReadonlyHandlers,
1396
- shallowReadonlyCollectionHandlers,
1397
- shallowReadonlyMap
1398
- );
1130
+ return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1399
1131
  }
1400
1132
  function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
1401
- if (!isObject(target)) {
1402
- if (!!(process.env.NODE_ENV !== "production")) {
1403
- warn$1(
1404
- `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
1405
- target
1406
- )}`
1407
- );
1408
- }
1409
- return target;
1410
- }
1411
- if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1412
- return target;
1413
- }
1414
- const targetType = getTargetType(target);
1415
- if (targetType === 0) {
1416
- return target;
1417
- }
1418
- const existingProxy = proxyMap.get(target);
1419
- if (existingProxy) {
1420
- return existingProxy;
1421
- }
1422
- const proxy = new Proxy(
1423
- target,
1424
- targetType === 2 ? collectionHandlers : baseHandlers
1425
- );
1426
- proxyMap.set(target, proxy);
1427
- return proxy;
1428
- }
1133
+ if (!isObject(target)) {
1134
+ if (!!(process.env.NODE_ENV !== "production")) warn$1(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
1135
+ return target;
1136
+ }
1137
+ if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) return target;
1138
+ const targetType = getTargetType(target);
1139
+ if (targetType === 0) return target;
1140
+ const existingProxy = proxyMap.get(target);
1141
+ if (existingProxy) return existingProxy;
1142
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1143
+ proxyMap.set(target, proxy);
1144
+ return proxy;
1145
+ }
1146
+ /* @__NO_SIDE_EFFECTS__ */
1429
1147
  function isReactive(value) {
1430
- if (isReadonly(value)) {
1431
- return isReactive(value["__v_raw"]);
1432
- }
1433
- return !!(value && value["__v_isReactive"]);
1148
+ if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1149
+ return !!(value && value["__v_isReactive"]);
1434
1150
  }
1151
+ /* @__NO_SIDE_EFFECTS__ */
1435
1152
  function isReadonly(value) {
1436
- return !!(value && value["__v_isReadonly"]);
1153
+ return !!(value && value["__v_isReadonly"]);
1437
1154
  }
1155
+ /* @__NO_SIDE_EFFECTS__ */
1438
1156
  function isShallow(value) {
1439
- return !!(value && value["__v_isShallow"]);
1157
+ return !!(value && value["__v_isShallow"]);
1440
1158
  }
1159
+ /* @__NO_SIDE_EFFECTS__ */
1441
1160
  function isProxy(value) {
1442
- return value ? !!value["__v_raw"] : false;
1161
+ return value ? !!value["__v_raw"] : false;
1443
1162
  }
1163
+ /* @__NO_SIDE_EFFECTS__ */
1444
1164
  function toRaw(observed) {
1445
- const raw = observed && observed["__v_raw"];
1446
- return raw ? toRaw(raw) : observed;
1165
+ const raw = observed && observed["__v_raw"];
1166
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
1447
1167
  }
1448
1168
  function markRaw(value) {
1449
- if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
1450
- def(value, "__v_skip", true);
1451
- }
1452
- return value;
1169
+ if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) def(value, "__v_skip", true);
1170
+ return value;
1453
1171
  }
1454
- const toReactive = (value) => isObject(value) ? reactive(value) : value;
1455
- const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1172
+ var toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
1173
+ var toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1174
+ /* @__NO_SIDE_EFFECTS__ */
1456
1175
  function isRef(r) {
1457
- return r ? r["__v_isRef"] === true : false;
1176
+ return r ? r["__v_isRef"] === true : false;
1458
1177
  }
1178
+ /* @__NO_SIDE_EFFECTS__ */
1459
1179
  function ref(value) {
1460
- return createRef(value, false);
1180
+ return createRef(value, false);
1461
1181
  }
1182
+ /* @__NO_SIDE_EFFECTS__ */
1462
1183
  function shallowRef(value) {
1463
- return createRef(value, true);
1184
+ return createRef(value, true);
1464
1185
  }
1465
1186
  function createRef(rawValue, shallow) {
1466
- if (isRef(rawValue)) {
1467
- return rawValue;
1468
- }
1469
- return new RefImpl(rawValue, shallow);
1470
- }
1471
- class RefImpl {
1472
- constructor(value, isShallow2) {
1473
- this.dep = new Dep();
1474
- this["__v_isRef"] = true;
1475
- this["__v_isShallow"] = false;
1476
- this._rawValue = isShallow2 ? value : toRaw(value);
1477
- this._value = isShallow2 ? value : toReactive(value);
1478
- this["__v_isShallow"] = isShallow2;
1479
- }
1480
- get value() {
1481
- if (!!(process.env.NODE_ENV !== "production")) {
1482
- this.dep.track({
1483
- target: this,
1484
- type: "get",
1485
- key: "value"
1486
- });
1487
- } else {
1488
- this.dep.track();
1489
- }
1490
- return this._value;
1491
- }
1492
- set value(newValue) {
1493
- const oldValue = this._rawValue;
1494
- const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1495
- newValue = useDirectValue ? newValue : toRaw(newValue);
1496
- if (hasChanged(newValue, oldValue)) {
1497
- this._rawValue = newValue;
1498
- this._value = useDirectValue ? newValue : toReactive(newValue);
1499
- if (!!(process.env.NODE_ENV !== "production")) {
1500
- this.dep.trigger({
1501
- target: this,
1502
- type: "set",
1503
- key: "value",
1504
- newValue,
1505
- oldValue
1506
- });
1507
- } else {
1508
- this.dep.trigger();
1509
- }
1510
- }
1511
- }
1512
- }
1187
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
1188
+ return new RefImpl(rawValue, shallow);
1189
+ }
1190
+ var RefImpl = class {
1191
+ constructor(value, isShallow2) {
1192
+ this.dep = new Dep();
1193
+ this["__v_isRef"] = true;
1194
+ this["__v_isShallow"] = false;
1195
+ this._rawValue = isShallow2 ? value : /* @__PURE__ */ toRaw(value);
1196
+ this._value = isShallow2 ? value : toReactive(value);
1197
+ this["__v_isShallow"] = isShallow2;
1198
+ }
1199
+ get value() {
1200
+ if (!!(process.env.NODE_ENV !== "production")) this.dep.track({
1201
+ target: this,
1202
+ type: "get",
1203
+ key: "value"
1204
+ });
1205
+ else this.dep.track();
1206
+ return this._value;
1207
+ }
1208
+ set value(newValue) {
1209
+ const oldValue = this._rawValue;
1210
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1211
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1212
+ if (hasChanged(newValue, oldValue)) {
1213
+ this._rawValue = newValue;
1214
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1215
+ if (!!(process.env.NODE_ENV !== "production")) this.dep.trigger({
1216
+ target: this,
1217
+ type: "set",
1218
+ key: "value",
1219
+ newValue,
1220
+ oldValue
1221
+ });
1222
+ else this.dep.trigger();
1223
+ }
1224
+ }
1225
+ };
1513
1226
  function triggerRef(ref2) {
1514
- if (ref2.dep) {
1515
- if (!!(process.env.NODE_ENV !== "production")) {
1516
- ref2.dep.trigger({
1517
- target: ref2,
1518
- type: "set",
1519
- key: "value",
1520
- newValue: ref2._value
1521
- });
1522
- } else {
1523
- ref2.dep.trigger();
1524
- }
1525
- }
1227
+ if (ref2.dep) if (!!(process.env.NODE_ENV !== "production")) ref2.dep.trigger({
1228
+ target: ref2,
1229
+ type: "set",
1230
+ key: "value",
1231
+ newValue: ref2._value
1232
+ });
1233
+ else ref2.dep.trigger();
1526
1234
  }
1527
1235
  function unref(ref2) {
1528
- return isRef(ref2) ? ref2.value : ref2;
1236
+ return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
1529
1237
  }
1530
1238
  function toValue(source) {
1531
- return isFunction(source) ? source() : unref(source);
1532
- }
1533
- const shallowUnwrapHandlers = {
1534
- get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1535
- set: (target, key, value, receiver) => {
1536
- const oldValue = target[key];
1537
- if (isRef(oldValue) && !isRef(value)) {
1538
- oldValue.value = value;
1539
- return true;
1540
- } else {
1541
- return Reflect.set(target, key, value, receiver);
1542
- }
1543
- }
1239
+ return isFunction(source) ? source() : unref(source);
1240
+ }
1241
+ var shallowUnwrapHandlers = {
1242
+ get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1243
+ set: (target, key, value, receiver) => {
1244
+ const oldValue = target[key];
1245
+ if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
1246
+ oldValue.value = value;
1247
+ return true;
1248
+ } else return Reflect.set(target, key, value, receiver);
1249
+ }
1544
1250
  };
1545
1251
  function proxyRefs(objectWithRefs) {
1546
- return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1547
- }
1548
- class CustomRefImpl {
1549
- constructor(factory) {
1550
- this["__v_isRef"] = true;
1551
- this._value = void 0;
1552
- const dep = this.dep = new Dep();
1553
- const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1554
- this._get = get;
1555
- this._set = set;
1556
- }
1557
- get value() {
1558
- return this._value = this._get();
1559
- }
1560
- set value(newVal) {
1561
- this._set(newVal);
1562
- }
1563
- }
1252
+ return /* @__PURE__ */ isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1253
+ }
1254
+ var CustomRefImpl = class {
1255
+ constructor(factory) {
1256
+ this["__v_isRef"] = true;
1257
+ this._value = void 0;
1258
+ const dep = this.dep = new Dep();
1259
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1260
+ this._get = get;
1261
+ this._set = set;
1262
+ }
1263
+ get value() {
1264
+ return this._value = this._get();
1265
+ }
1266
+ set value(newVal) {
1267
+ this._set(newVal);
1268
+ }
1269
+ };
1564
1270
  function customRef(factory) {
1565
- return new CustomRefImpl(factory);
1271
+ return new CustomRefImpl(factory);
1566
1272
  }
1273
+ /* @__NO_SIDE_EFFECTS__ */
1567
1274
  function toRefs(object) {
1568
- if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
1569
- warn$1(`toRefs() expects a reactive object but received a plain one.`);
1570
- }
1571
- const ret = isArray(object) ? new Array(object.length) : {};
1572
- for (const key in object) {
1573
- ret[key] = propertyToRef(object, key);
1574
- }
1575
- return ret;
1576
- }
1577
- class ObjectRefImpl {
1578
- constructor(_object, _key, _defaultValue) {
1579
- this._object = _object;
1580
- this._key = _key;
1581
- this._defaultValue = _defaultValue;
1582
- this["__v_isRef"] = true;
1583
- this._value = void 0;
1584
- this._raw = toRaw(_object);
1585
- let shallow = true;
1586
- let obj = _object;
1587
- if (!isArray(_object) || !isIntegerKey(String(_key))) {
1588
- do {
1589
- shallow = !isProxy(obj) || isShallow(obj);
1590
- } while (shallow && (obj = obj["__v_raw"]));
1591
- }
1592
- this._shallow = shallow;
1593
- }
1594
- get value() {
1595
- let val = this._object[this._key];
1596
- if (this._shallow) {
1597
- val = unref(val);
1598
- }
1599
- return this._value = val === void 0 ? this._defaultValue : val;
1600
- }
1601
- set value(newVal) {
1602
- if (this._shallow && isRef(this._raw[this._key])) {
1603
- const nestedRef = this._object[this._key];
1604
- if (isRef(nestedRef)) {
1605
- nestedRef.value = newVal;
1606
- return;
1607
- }
1608
- }
1609
- this._object[this._key] = newVal;
1610
- }
1611
- get dep() {
1612
- return getDepFromReactive(this._raw, this._key);
1613
- }
1614
- }
1615
- class GetterRefImpl {
1616
- constructor(_getter) {
1617
- this._getter = _getter;
1618
- this["__v_isRef"] = true;
1619
- this["__v_isReadonly"] = true;
1620
- this._value = void 0;
1621
- }
1622
- get value() {
1623
- return this._value = this._getter();
1624
- }
1625
- }
1275
+ if (!!(process.env.NODE_ENV !== "production") && !/* @__PURE__ */ isProxy(object)) warn$1(`toRefs() expects a reactive object but received a plain one.`);
1276
+ const ret = isArray(object) ? new Array(object.length) : {};
1277
+ for (const key in object) ret[key] = propertyToRef(object, key);
1278
+ return ret;
1279
+ }
1280
+ var ObjectRefImpl = class {
1281
+ constructor(_object, key, _defaultValue) {
1282
+ this._object = _object;
1283
+ this._defaultValue = _defaultValue;
1284
+ this["__v_isRef"] = true;
1285
+ this._value = void 0;
1286
+ this._key = isSymbol(key) ? key : String(key);
1287
+ this._raw = /* @__PURE__ */ toRaw(_object);
1288
+ let shallow = true;
1289
+ let obj = _object;
1290
+ if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) do
1291
+ shallow = !/* @__PURE__ */ isProxy(obj) || /* @__PURE__ */ isShallow(obj);
1292
+ while (shallow && (obj = obj["__v_raw"]));
1293
+ this._shallow = shallow;
1294
+ }
1295
+ get value() {
1296
+ let val = this._object[this._key];
1297
+ if (this._shallow) val = unref(val);
1298
+ return this._value = val === void 0 ? this._defaultValue : val;
1299
+ }
1300
+ set value(newVal) {
1301
+ if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
1302
+ const nestedRef = this._object[this._key];
1303
+ if (/* @__PURE__ */ isRef(nestedRef)) {
1304
+ nestedRef.value = newVal;
1305
+ return;
1306
+ }
1307
+ }
1308
+ this._object[this._key] = newVal;
1309
+ }
1310
+ get dep() {
1311
+ return getDepFromReactive(this._raw, this._key);
1312
+ }
1313
+ };
1314
+ var GetterRefImpl = class {
1315
+ constructor(_getter) {
1316
+ this._getter = _getter;
1317
+ this["__v_isRef"] = true;
1318
+ this["__v_isReadonly"] = true;
1319
+ this._value = void 0;
1320
+ }
1321
+ get value() {
1322
+ return this._value = this._getter();
1323
+ }
1324
+ };
1325
+ /* @__NO_SIDE_EFFECTS__ */
1626
1326
  function toRef(source, key, defaultValue) {
1627
- if (isRef(source)) {
1628
- return source;
1629
- } else if (isFunction(source)) {
1630
- return new GetterRefImpl(source);
1631
- } else if (isObject(source) && arguments.length > 1) {
1632
- return propertyToRef(source, key, defaultValue);
1633
- } else {
1634
- return ref(source);
1635
- }
1327
+ if (/* @__PURE__ */ isRef(source)) return source;
1328
+ else if (isFunction(source)) return new GetterRefImpl(source);
1329
+ else if (isObject(source) && arguments.length > 1) return propertyToRef(source, key, defaultValue);
1330
+ else return /* @__PURE__ */ ref(source);
1636
1331
  }
1637
1332
  function propertyToRef(source, key, defaultValue) {
1638
- return new ObjectRefImpl(source, key, defaultValue);
1639
- }
1640
- class ComputedRefImpl {
1641
- constructor(fn, setter, isSSR) {
1642
- this.fn = fn;
1643
- this.setter = setter;
1644
- this._value = void 0;
1645
- this.dep = new Dep(this);
1646
- this.__v_isRef = true;
1647
- this.deps = void 0;
1648
- this.depsTail = void 0;
1649
- this.flags = 16;
1650
- this.globalVersion = globalVersion - 1;
1651
- this.next = void 0;
1652
- this.effect = this;
1653
- this["__v_isReadonly"] = !setter;
1654
- this.isSSR = isSSR;
1655
- }
1656
- /**
1657
- * @internal
1658
- */
1659
- notify() {
1660
- this.flags |= 16;
1661
- if (!(this.flags & 8) && // avoid infinite self recursion
1662
- activeSub !== this) {
1663
- batch(this, true);
1664
- return true;
1665
- } else if (!!(process.env.NODE_ENV !== "production")) ;
1666
- }
1667
- get value() {
1668
- const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1669
- target: this,
1670
- type: "get",
1671
- key: "value"
1672
- }) : this.dep.track();
1673
- refreshComputed(this);
1674
- if (link) {
1675
- link.version = this.dep.version;
1676
- }
1677
- return this._value;
1678
- }
1679
- set value(newValue) {
1680
- if (this.setter) {
1681
- this.setter(newValue);
1682
- } else if (!!(process.env.NODE_ENV !== "production")) {
1683
- warn$1("Write operation failed: computed value is readonly");
1684
- }
1685
- }
1686
- }
1333
+ return new ObjectRefImpl(source, key, defaultValue);
1334
+ }
1335
+ var ComputedRefImpl = class {
1336
+ constructor(fn, setter, isSSR) {
1337
+ this.fn = fn;
1338
+ this.setter = setter;
1339
+ /**
1340
+ * @internal
1341
+ */
1342
+ this._value = void 0;
1343
+ /**
1344
+ * @internal
1345
+ */
1346
+ this.dep = new Dep(this);
1347
+ /**
1348
+ * @internal
1349
+ */
1350
+ this.__v_isRef = true;
1351
+ /**
1352
+ * @internal
1353
+ */
1354
+ this.deps = void 0;
1355
+ /**
1356
+ * @internal
1357
+ */
1358
+ this.depsTail = void 0;
1359
+ /**
1360
+ * @internal
1361
+ */
1362
+ this.flags = 16;
1363
+ /**
1364
+ * @internal
1365
+ */
1366
+ this.globalVersion = globalVersion - 1;
1367
+ /**
1368
+ * @internal
1369
+ */
1370
+ this.next = void 0;
1371
+ this.effect = this;
1372
+ this["__v_isReadonly"] = !setter;
1373
+ this.isSSR = isSSR;
1374
+ }
1375
+ /**
1376
+ * @internal
1377
+ */
1378
+ notify() {
1379
+ this.flags |= 16;
1380
+ if (!(this.flags & 8) && activeSub !== this) {
1381
+ batch(this, true);
1382
+ return true;
1383
+ } else if (!!(process.env.NODE_ENV !== "production"));
1384
+ }
1385
+ get value() {
1386
+ const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1387
+ target: this,
1388
+ type: "get",
1389
+ key: "value"
1390
+ }) : this.dep.track();
1391
+ refreshComputed(this);
1392
+ if (link) link.version = this.dep.version;
1393
+ return this._value;
1394
+ }
1395
+ set value(newValue) {
1396
+ if (this.setter) this.setter(newValue);
1397
+ else if (!!(process.env.NODE_ENV !== "production")) warn$1("Write operation failed: computed value is readonly");
1398
+ }
1399
+ };
1400
+ /* @__NO_SIDE_EFFECTS__ */
1687
1401
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1688
- let getter;
1689
- let setter;
1690
- if (isFunction(getterOrOptions)) {
1691
- getter = getterOrOptions;
1692
- } else {
1693
- getter = getterOrOptions.get;
1694
- setter = getterOrOptions.set;
1695
- }
1696
- const cRef = new ComputedRefImpl(getter, setter, isSSR);
1697
- if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1698
- cRef.onTrack = debugOptions.onTrack;
1699
- cRef.onTrigger = debugOptions.onTrigger;
1700
- }
1701
- return cRef;
1702
- }
1703
- const TrackOpTypes = {
1704
- "GET": "get",
1705
- "HAS": "has",
1706
- "ITERATE": "iterate"
1402
+ let getter;
1403
+ let setter;
1404
+ if (isFunction(getterOrOptions)) getter = getterOrOptions;
1405
+ else {
1406
+ getter = getterOrOptions.get;
1407
+ setter = getterOrOptions.set;
1408
+ }
1409
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1410
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1411
+ cRef.onTrack = debugOptions.onTrack;
1412
+ cRef.onTrigger = debugOptions.onTrigger;
1413
+ }
1414
+ return cRef;
1415
+ }
1416
+ var TrackOpTypes = {
1417
+ "GET": "get",
1418
+ "HAS": "has",
1419
+ "ITERATE": "iterate"
1707
1420
  };
1708
- const TriggerOpTypes = {
1709
- "SET": "set",
1710
- "ADD": "add",
1711
- "DELETE": "delete",
1712
- "CLEAR": "clear"
1421
+ var TriggerOpTypes = {
1422
+ "SET": "set",
1423
+ "ADD": "add",
1424
+ "DELETE": "delete",
1425
+ "CLEAR": "clear"
1713
1426
  };
1714
- const ReactiveFlags = {
1715
- "SKIP": "__v_skip",
1716
- "IS_REACTIVE": "__v_isReactive",
1717
- "IS_READONLY": "__v_isReadonly",
1718
- "IS_SHALLOW": "__v_isShallow",
1719
- "RAW": "__v_raw",
1720
- "IS_REF": "__v_isRef"
1427
+ var ReactiveFlags = {
1428
+ "SKIP": "__v_skip",
1429
+ "IS_REACTIVE": "__v_isReactive",
1430
+ "IS_READONLY": "__v_isReadonly",
1431
+ "IS_SHALLOW": "__v_isShallow",
1432
+ "RAW": "__v_raw",
1433
+ "IS_REF": "__v_isRef"
1721
1434
  };
1722
- const WatchErrorCodes = {
1723
- "WATCH_GETTER": 2,
1724
- "2": "WATCH_GETTER",
1725
- "WATCH_CALLBACK": 3,
1726
- "3": "WATCH_CALLBACK",
1727
- "WATCH_CLEANUP": 4,
1728
- "4": "WATCH_CLEANUP"
1435
+ var WatchErrorCodes = {
1436
+ "WATCH_GETTER": 2,
1437
+ "2": "WATCH_GETTER",
1438
+ "WATCH_CALLBACK": 3,
1439
+ "3": "WATCH_CALLBACK",
1440
+ "WATCH_CLEANUP": 4,
1441
+ "4": "WATCH_CLEANUP"
1729
1442
  };
1730
- const INITIAL_WATCHER_VALUE = {};
1731
- const cleanupMap = /* @__PURE__ */ new WeakMap();
1732
- let activeWatcher = void 0;
1443
+ var INITIAL_WATCHER_VALUE = {};
1444
+ var cleanupMap = /* @__PURE__ */ new WeakMap();
1445
+ var activeWatcher = void 0;
1733
1446
  function getCurrentWatcher() {
1734
- return activeWatcher;
1447
+ return activeWatcher;
1735
1448
  }
1736
1449
  function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1737
- if (owner) {
1738
- let cleanups = cleanupMap.get(owner);
1739
- if (!cleanups) cleanupMap.set(owner, cleanups = []);
1740
- cleanups.push(cleanupFn);
1741
- } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
1742
- warn$1(
1743
- `onWatcherCleanup() was called when there was no active watcher to associate with.`
1744
- );
1745
- }
1450
+ if (owner) {
1451
+ let cleanups = cleanupMap.get(owner);
1452
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1453
+ cleanups.push(cleanupFn);
1454
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) warn$1(`onWatcherCleanup() was called when there was no active watcher to associate with.`);
1746
1455
  }
1747
1456
  function watch$1(source, cb, options = EMPTY_OBJ) {
1748
- const { immediate, deep, once, scheduler, augmentJob, call } = options;
1749
- const warnInvalidSource = (s) => {
1750
- (options.onWarn || warn$1)(
1751
- `Invalid watch source: `,
1752
- s,
1753
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1754
- );
1755
- };
1756
- const reactiveGetter = (source2) => {
1757
- if (deep) return source2;
1758
- if (isShallow(source2) || deep === false || deep === 0)
1759
- return traverse(source2, 1);
1760
- return traverse(source2);
1761
- };
1762
- let effect2;
1763
- let getter;
1764
- let cleanup;
1765
- let boundCleanup;
1766
- let forceTrigger = false;
1767
- let isMultiSource = false;
1768
- if (isRef(source)) {
1769
- getter = () => source.value;
1770
- forceTrigger = isShallow(source);
1771
- } else if (isReactive(source)) {
1772
- getter = () => reactiveGetter(source);
1773
- forceTrigger = true;
1774
- } else if (isArray(source)) {
1775
- isMultiSource = true;
1776
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1777
- getter = () => source.map((s) => {
1778
- if (isRef(s)) {
1779
- return s.value;
1780
- } else if (isReactive(s)) {
1781
- return reactiveGetter(s);
1782
- } else if (isFunction(s)) {
1783
- return call ? call(s, 2) : s();
1784
- } else {
1785
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
1786
- }
1787
- });
1788
- } else if (isFunction(source)) {
1789
- if (cb) {
1790
- getter = call ? () => call(source, 2) : source;
1791
- } else {
1792
- getter = () => {
1793
- if (cleanup) {
1794
- pauseTracking();
1795
- try {
1796
- cleanup();
1797
- } finally {
1798
- resetTracking();
1799
- }
1800
- }
1801
- const currentEffect = activeWatcher;
1802
- activeWatcher = effect2;
1803
- try {
1804
- return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1805
- } finally {
1806
- activeWatcher = currentEffect;
1807
- }
1808
- };
1809
- }
1810
- } else {
1811
- getter = NOOP;
1812
- !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
1813
- }
1814
- if (cb && deep) {
1815
- const baseGetter = getter;
1816
- const depth = deep === true ? Infinity : deep;
1817
- getter = () => traverse(baseGetter(), depth);
1818
- }
1819
- const scope = getCurrentScope();
1820
- const watchHandle = () => {
1821
- effect2.stop();
1822
- if (scope && scope.active) {
1823
- remove(scope.effects, effect2);
1824
- }
1825
- };
1826
- if (once && cb) {
1827
- const _cb = cb;
1828
- cb = (...args) => {
1829
- _cb(...args);
1830
- watchHandle();
1831
- };
1832
- }
1833
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1834
- const job = (immediateFirstRun) => {
1835
- if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
1836
- return;
1837
- }
1838
- if (cb) {
1839
- const newValue = effect2.run();
1840
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1841
- if (cleanup) {
1842
- cleanup();
1843
- }
1844
- const currentWatcher = activeWatcher;
1845
- activeWatcher = effect2;
1846
- try {
1847
- const args = [
1848
- newValue,
1849
- // pass undefined as the old value when it's changed for the first time
1850
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1851
- boundCleanup
1852
- ];
1853
- oldValue = newValue;
1854
- call ? call(cb, 3, args) : (
1855
- // @ts-expect-error
1856
- cb(...args)
1857
- );
1858
- } finally {
1859
- activeWatcher = currentWatcher;
1860
- }
1861
- }
1862
- } else {
1863
- effect2.run();
1864
- }
1865
- };
1866
- if (augmentJob) {
1867
- augmentJob(job);
1868
- }
1869
- effect2 = new ReactiveEffect(getter);
1870
- effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
1871
- boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
1872
- cleanup = effect2.onStop = () => {
1873
- const cleanups = cleanupMap.get(effect2);
1874
- if (cleanups) {
1875
- if (call) {
1876
- call(cleanups, 4);
1877
- } else {
1878
- for (const cleanup2 of cleanups) cleanup2();
1879
- }
1880
- cleanupMap.delete(effect2);
1881
- }
1882
- };
1883
- if (!!(process.env.NODE_ENV !== "production")) {
1884
- effect2.onTrack = options.onTrack;
1885
- effect2.onTrigger = options.onTrigger;
1886
- }
1887
- if (cb) {
1888
- if (immediate) {
1889
- job(true);
1890
- } else {
1891
- oldValue = effect2.run();
1892
- }
1893
- } else if (scheduler) {
1894
- scheduler(job.bind(null, true), true);
1895
- } else {
1896
- effect2.run();
1897
- }
1898
- watchHandle.pause = effect2.pause.bind(effect2);
1899
- watchHandle.resume = effect2.resume.bind(effect2);
1900
- watchHandle.stop = watchHandle;
1901
- return watchHandle;
1457
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1458
+ const warnInvalidSource = (s) => {
1459
+ (options.onWarn || warn$1)(`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.`);
1460
+ };
1461
+ const reactiveGetter = (source2) => {
1462
+ if (deep) return source2;
1463
+ if (/* @__PURE__ */ isShallow(source2) || deep === false || deep === 0) return traverse(source2, 1);
1464
+ return traverse(source2);
1465
+ };
1466
+ let effect;
1467
+ let getter;
1468
+ let cleanup;
1469
+ let boundCleanup;
1470
+ let forceTrigger = false;
1471
+ let isMultiSource = false;
1472
+ if (/* @__PURE__ */ isRef(source)) {
1473
+ getter = () => source.value;
1474
+ forceTrigger = /* @__PURE__ */ isShallow(source);
1475
+ } else if (/* @__PURE__ */ isReactive(source)) {
1476
+ getter = () => reactiveGetter(source);
1477
+ forceTrigger = true;
1478
+ } else if (isArray(source)) {
1479
+ isMultiSource = true;
1480
+ forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s));
1481
+ getter = () => source.map((s) => {
1482
+ if (/* @__PURE__ */ isRef(s)) return s.value;
1483
+ else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s);
1484
+ else if (isFunction(s)) return call ? call(s, 2) : s();
1485
+ else process.env.NODE_ENV !== "production" && warnInvalidSource(s);
1486
+ });
1487
+ } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1488
+ else getter = () => {
1489
+ if (cleanup) {
1490
+ pauseTracking();
1491
+ try {
1492
+ cleanup();
1493
+ } finally {
1494
+ resetTracking();
1495
+ }
1496
+ }
1497
+ const currentEffect = activeWatcher;
1498
+ activeWatcher = effect;
1499
+ try {
1500
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1501
+ } finally {
1502
+ activeWatcher = currentEffect;
1503
+ }
1504
+ };
1505
+ else {
1506
+ getter = NOOP;
1507
+ process.env.NODE_ENV !== "production" && warnInvalidSource(source);
1508
+ }
1509
+ if (cb && deep) {
1510
+ const baseGetter = getter;
1511
+ const depth = deep === true ? Infinity : deep;
1512
+ getter = () => traverse(baseGetter(), depth);
1513
+ }
1514
+ const scope = getCurrentScope();
1515
+ const watchHandle = () => {
1516
+ effect.stop();
1517
+ if (scope && scope.active) remove(scope.effects, effect);
1518
+ };
1519
+ if (once && cb) {
1520
+ const _cb = cb;
1521
+ cb = (...args) => {
1522
+ _cb(...args);
1523
+ watchHandle();
1524
+ };
1525
+ }
1526
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1527
+ const job = (immediateFirstRun) => {
1528
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return;
1529
+ if (cb) {
1530
+ const newValue = effect.run();
1531
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1532
+ if (cleanup) cleanup();
1533
+ const currentWatcher = activeWatcher;
1534
+ activeWatcher = effect;
1535
+ try {
1536
+ const args = [
1537
+ newValue,
1538
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1539
+ boundCleanup
1540
+ ];
1541
+ oldValue = newValue;
1542
+ call ? call(cb, 3, args) : cb(...args);
1543
+ } finally {
1544
+ activeWatcher = currentWatcher;
1545
+ }
1546
+ }
1547
+ } else effect.run();
1548
+ };
1549
+ if (augmentJob) augmentJob(job);
1550
+ effect = new ReactiveEffect(getter);
1551
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1552
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1553
+ cleanup = effect.onStop = () => {
1554
+ const cleanups = cleanupMap.get(effect);
1555
+ if (cleanups) {
1556
+ if (call) call(cleanups, 4);
1557
+ else for (const cleanup2 of cleanups) cleanup2();
1558
+ cleanupMap.delete(effect);
1559
+ }
1560
+ };
1561
+ if (!!(process.env.NODE_ENV !== "production")) {
1562
+ effect.onTrack = options.onTrack;
1563
+ effect.onTrigger = options.onTrigger;
1564
+ }
1565
+ if (cb) if (immediate) job(true);
1566
+ else oldValue = effect.run();
1567
+ else if (scheduler) scheduler(job.bind(null, true), true);
1568
+ else effect.run();
1569
+ watchHandle.pause = effect.pause.bind(effect);
1570
+ watchHandle.resume = effect.resume.bind(effect);
1571
+ watchHandle.stop = watchHandle;
1572
+ return watchHandle;
1902
1573
  }
1903
1574
  function traverse(value, depth = Infinity, seen) {
1904
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
1905
- return value;
1906
- }
1907
- seen = seen || /* @__PURE__ */ new Map();
1908
- if ((seen.get(value) || 0) >= depth) {
1909
- return value;
1910
- }
1911
- seen.set(value, depth);
1912
- depth--;
1913
- if (isRef(value)) {
1914
- traverse(value.value, depth, seen);
1915
- } else if (isArray(value)) {
1916
- for (let i = 0; i < value.length; i++) {
1917
- traverse(value[i], depth, seen);
1918
- }
1919
- } else if (isSet(value) || isMap(value)) {
1920
- value.forEach((v) => {
1921
- traverse(v, depth, seen);
1922
- });
1923
- } else if (isPlainObject(value)) {
1924
- for (const key in value) {
1925
- traverse(value[key], depth, seen);
1926
- }
1927
- for (const key of Object.getOwnPropertySymbols(value)) {
1928
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
1929
- traverse(value[key], depth, seen);
1930
- }
1931
- }
1932
- }
1933
- return value;
1934
- }
1575
+ if (depth <= 0 || !isObject(value) || value["__v_skip"]) return value;
1576
+ seen = seen || /* @__PURE__ */ new Map();
1577
+ if ((seen.get(value) || 0) >= depth) return value;
1578
+ seen.set(value, depth);
1579
+ depth--;
1580
+ if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen);
1581
+ else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen);
1582
+ else if (isSet(value) || isMap(value)) value.forEach((v) => {
1583
+ traverse(v, depth, seen);
1584
+ });
1585
+ else if (isPlainObject(value)) {
1586
+ for (const key in value) traverse(value[key], depth, seen);
1587
+ for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen);
1588
+ }
1589
+ return value;
1590
+ }
1591
+ //#endregion
1592
+ //#region src/warning.ts
1935
1593
  function warn(msg, ...args) {
1936
- pauseTracking();
1937
- const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1938
- console.warn(...warnArgs);
1939
- resetTracking();
1940
- }
1941
- var LifecycleHooks = /* @__PURE__ */ ((LifecycleHooks2) => {
1942
- LifecycleHooks2["ACTIVATED"] = "a";
1943
- LifecycleHooks2["DEACTIVATED"] = "da";
1944
- return LifecycleHooks2;
1945
- })(LifecycleHooks || {});
1946
- var ErrorCodes = /* @__PURE__ */ ((ErrorCodes2) => {
1947
- ErrorCodes2[ErrorCodes2["WATCH_GETTER"] = 0] = "WATCH_GETTER";
1948
- ErrorCodes2[ErrorCodes2["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
1949
- ErrorCodes2[ErrorCodes2["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
1950
- ErrorCodes2[ErrorCodes2["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
1951
- ErrorCodes2[ErrorCodes2["SCHEDULER"] = 4] = "SCHEDULER";
1952
- return ErrorCodes2;
1953
- })(ErrorCodes || {});
1954
- const ErrorTypeStrings = {
1955
- [LifecycleHooks.ACTIVATED]: "activated hook",
1956
- [LifecycleHooks.DEACTIVATED]: "deactivated hook",
1957
- [
1958
- 0
1959
- /* WATCH_GETTER */
1960
- ]: "watcher getter",
1961
- [
1962
- 1
1963
- /* WATCH_CALLBACK */
1964
- ]: "watcher callback",
1965
- [
1966
- 2
1967
- /* WATCH_CLEANUP */
1968
- ]: "watcher cleanup function",
1969
- [
1970
- 3
1971
- /* APP_ERROR_HANDLER */
1972
- ]: "app errorHandler",
1973
- [
1974
- 4
1975
- /* SCHEDULER */
1976
- ]: "scheduler flush"
1594
+ pauseTracking();
1595
+ const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1596
+ /* istanbul ignore if */
1597
+ console.warn(...warnArgs);
1598
+ resetTracking();
1599
+ }
1600
+ //#endregion
1601
+ //#region src/enums.ts
1602
+ var LifecycleHooks = /* @__PURE__ */ function(LifecycleHooks) {
1603
+ LifecycleHooks["ACTIVATED"] = "a";
1604
+ LifecycleHooks["DEACTIVATED"] = "da";
1605
+ return LifecycleHooks;
1606
+ }({});
1607
+ //#endregion
1608
+ //#region src/errorHandling.ts
1609
+ var ErrorCodes = /* @__PURE__ */ function(ErrorCodes) {
1610
+ ErrorCodes[ErrorCodes["WATCH_GETTER"] = 0] = "WATCH_GETTER";
1611
+ ErrorCodes[ErrorCodes["WATCH_CALLBACK"] = 1] = "WATCH_CALLBACK";
1612
+ ErrorCodes[ErrorCodes["WATCH_CLEANUP"] = 2] = "WATCH_CLEANUP";
1613
+ ErrorCodes[ErrorCodes["APP_ERROR_HANDLER"] = 3] = "APP_ERROR_HANDLER";
1614
+ ErrorCodes[ErrorCodes["SCHEDULER"] = 4] = "SCHEDULER";
1615
+ return ErrorCodes;
1616
+ }({});
1617
+ var ErrorTypeStrings = {
1618
+ [LifecycleHooks.ACTIVATED]: "activated hook",
1619
+ [LifecycleHooks.DEACTIVATED]: "deactivated hook",
1620
+ [ErrorCodes.WATCH_GETTER]: "watcher getter",
1621
+ [ErrorCodes.WATCH_CALLBACK]: "watcher callback",
1622
+ [ErrorCodes.WATCH_CLEANUP]: "watcher cleanup function",
1623
+ [ErrorCodes.APP_ERROR_HANDLER]: "app errorHandler",
1624
+ [ErrorCodes.SCHEDULER]: "scheduler flush"
1977
1625
  };
1978
1626
  function callWithErrorHandling(fn, instance, type, args) {
1979
- try {
1980
- return args ? fn(...args) : fn();
1981
- } catch (err) {
1982
- handleError(err, instance, type);
1983
- }
1627
+ try {
1628
+ return args ? fn(...args) : fn();
1629
+ } catch (err) {
1630
+ handleError(err, instance, type);
1631
+ }
1984
1632
  }
1985
1633
  function callWithAsyncErrorHandling(fn, instance, type, args) {
1986
- if (isFunction(fn)) {
1987
- const res = callWithErrorHandling(fn, instance, type, args);
1988
- if (res && isPromise(res)) {
1989
- res.catch((err) => {
1990
- handleError(err, instance, type);
1991
- });
1992
- }
1993
- return res;
1994
- }
1995
- if (isArray(fn)) {
1996
- const values = [];
1997
- for (let i = 0; i < fn.length; i++) {
1998
- values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1999
- }
2000
- return values;
2001
- } else if (!!(process.env.NODE_ENV !== "production")) {
2002
- warn(
2003
- `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
2004
- );
2005
- }
1634
+ if (isFunction(fn)) {
1635
+ const res = callWithErrorHandling(fn, instance, type, args);
1636
+ if (res && isPromise(res)) res.catch((err) => {
1637
+ handleError(err, instance, type);
1638
+ });
1639
+ return res;
1640
+ }
1641
+ if (isArray(fn)) {
1642
+ const values = [];
1643
+ for (let i = 0; i < fn.length; i++) values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1644
+ return values;
1645
+ } else if (!!(process.env.NODE_ENV !== "production")) warn(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`);
2006
1646
  }
2007
1647
  function handleError(err, instance, type, throwInDev = true) {
2008
- const contextVNode = null;
2009
- logError(err, type, contextVNode, throwInDev);
1648
+ logError(err, type, null, throwInDev);
2010
1649
  }
2011
1650
  function logError(err, type, contextVNode, throwInDev = true) {
2012
- if (!!(process.env.NODE_ENV !== "production")) {
2013
- const info = ErrorTypeStrings[type];
2014
- warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
2015
- if (throwInDev) {
2016
- throw err;
2017
- } else {
2018
- console.error(err);
2019
- }
2020
- } else {
2021
- console.error(err);
2022
- }
2023
- }
2024
- var SchedulerJobFlags = /* @__PURE__ */ ((SchedulerJobFlags2) => {
2025
- SchedulerJobFlags2[SchedulerJobFlags2["QUEUED"] = 1] = "QUEUED";
2026
- SchedulerJobFlags2[SchedulerJobFlags2["PRE"] = 2] = "PRE";
2027
- SchedulerJobFlags2[SchedulerJobFlags2["ALLOW_RECURSE"] = 4] = "ALLOW_RECURSE";
2028
- SchedulerJobFlags2[SchedulerJobFlags2["DISPOSED"] = 8] = "DISPOSED";
2029
- return SchedulerJobFlags2;
2030
- })(SchedulerJobFlags || {});
2031
- const queue = [];
2032
- let flushIndex = -1;
2033
- const pendingPostFlushCbs = [];
2034
- let activePostFlushCbs = null;
2035
- let postFlushIndex = 0;
2036
- const resolvedPromise = /* @__PURE__ */ Promise.resolve();
2037
- let currentFlushPromise = null;
2038
- const RECURSION_LIMIT = 100;
1651
+ if (!!(process.env.NODE_ENV !== "production")) {
1652
+ const info = ErrorTypeStrings[type];
1653
+ warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
1654
+ if (throwInDev) throw err;
1655
+ else console.error(err);
1656
+ } else console.error(err);
1657
+ }
1658
+ //#endregion
1659
+ //#region src/scheduler.ts
1660
+ var SchedulerJobFlags = /* @__PURE__ */ function(SchedulerJobFlags) {
1661
+ SchedulerJobFlags[SchedulerJobFlags["QUEUED"] = 1] = "QUEUED";
1662
+ SchedulerJobFlags[SchedulerJobFlags["PRE"] = 2] = "PRE";
1663
+ /**
1664
+ * Indicates whether the effect is allowed to recursively trigger itself
1665
+ * when managed by the scheduler.
1666
+ *
1667
+ * By default, a job cannot trigger itself because some built-in method calls,
1668
+ * e.g. Array.prototype.push actually performs reads as well (#1740) which
1669
+ * can lead to confusing infinite loops.
1670
+ * The allowed cases are component update functions and watch callbacks.
1671
+ * Component update functions may update child component props, which in turn
1672
+ * trigger flush: "pre" watch callbacks that mutates state that the parent
1673
+ * relies on (#1801). Watch callbacks doesn't track its dependencies so if it
1674
+ * triggers itself again, it's likely intentional and it is the user's
1675
+ * responsibility to perform recursive state mutation that eventually
1676
+ * stabilizes (#1727).
1677
+ */
1678
+ SchedulerJobFlags[SchedulerJobFlags["ALLOW_RECURSE"] = 4] = "ALLOW_RECURSE";
1679
+ SchedulerJobFlags[SchedulerJobFlags["DISPOSED"] = 8] = "DISPOSED";
1680
+ return SchedulerJobFlags;
1681
+ }({});
1682
+ var queue = [];
1683
+ var flushIndex = -1;
1684
+ var pendingPostFlushCbs = [];
1685
+ var activePostFlushCbs = null;
1686
+ var postFlushIndex = 0;
1687
+ var resolvedPromise = /* @__PURE__ */ Promise.resolve();
1688
+ var currentFlushPromise = null;
1689
+ var RECURSION_LIMIT = 100;
2039
1690
  function nextTick(fn) {
2040
- const p = currentFlushPromise || resolvedPromise;
2041
- return fn ? p.then(this ? fn.bind(this) : fn) : p;
1691
+ const p = currentFlushPromise || resolvedPromise;
1692
+ return fn ? p.then(this ? fn.bind(this) : fn) : p;
2042
1693
  }
2043
1694
  function findInsertionIndex(id) {
2044
- let start = flushIndex + 1;
2045
- let end = queue.length;
2046
- while (start < end) {
2047
- const middle = start + end >>> 1;
2048
- const middleJob = queue[middle];
2049
- const middleJobId = getId(middleJob);
2050
- if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
2051
- start = middle + 1;
2052
- } else {
2053
- end = middle;
2054
- }
2055
- }
2056
- return start;
1695
+ let start = flushIndex + 1;
1696
+ let end = queue.length;
1697
+ while (start < end) {
1698
+ const middle = start + end >>> 1;
1699
+ const middleJob = queue[middle];
1700
+ const middleJobId = getId(middleJob);
1701
+ if (middleJobId < id || middleJobId === id && middleJob.flags & SchedulerJobFlags.PRE) start = middle + 1;
1702
+ else end = middle;
1703
+ }
1704
+ return start;
2057
1705
  }
2058
1706
  function queueJob(job) {
2059
- if (!(job.flags & 1)) {
2060
- const jobId = getId(job);
2061
- const lastJob = queue[queue.length - 1];
2062
- if (!lastJob || // fast path when the job id is larger than the tail
2063
- !(job.flags & 2) && jobId >= getId(lastJob)) {
2064
- queue.push(job);
2065
- } else {
2066
- queue.splice(findInsertionIndex(jobId), 0, job);
2067
- }
2068
- job.flags |= 1;
2069
- queueFlush();
2070
- }
1707
+ if (!(job.flags & SchedulerJobFlags.QUEUED)) {
1708
+ const jobId = getId(job);
1709
+ const lastJob = queue[queue.length - 1];
1710
+ if (!lastJob || !(job.flags & SchedulerJobFlags.PRE) && jobId >= getId(lastJob)) queue.push(job);
1711
+ else queue.splice(findInsertionIndex(jobId), 0, job);
1712
+ job.flags |= SchedulerJobFlags.QUEUED;
1713
+ queueFlush();
1714
+ }
2071
1715
  }
2072
1716
  function queueFlush() {
2073
- if (!currentFlushPromise) {
2074
- currentFlushPromise = resolvedPromise.then(flushJobs);
2075
- }
1717
+ if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(flushJobs);
2076
1718
  }
2077
1719
  function flushPostFlushCbs(seen) {
2078
- if (pendingPostFlushCbs.length) {
2079
- const deduped = [...new Set(pendingPostFlushCbs)].sort(
2080
- (a, b) => getId(a) - getId(b)
2081
- );
2082
- pendingPostFlushCbs.length = 0;
2083
- if (activePostFlushCbs) {
2084
- activePostFlushCbs.push(...deduped);
2085
- return;
2086
- }
2087
- activePostFlushCbs = deduped;
2088
- if (!!(process.env.NODE_ENV !== "production")) {
2089
- seen = seen || /* @__PURE__ */ new Map();
2090
- }
2091
- for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
2092
- const cb = activePostFlushCbs[postFlushIndex];
2093
- if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) {
2094
- continue;
2095
- }
2096
- if (cb.flags & 4) {
2097
- cb.flags &= -2;
2098
- }
2099
- if (!(cb.flags & 8)) cb();
2100
- cb.flags &= -2;
2101
- }
2102
- activePostFlushCbs = null;
2103
- postFlushIndex = 0;
2104
- }
2105
- }
2106
- const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
1720
+ if (pendingPostFlushCbs.length) {
1721
+ const deduped = [...new Set(pendingPostFlushCbs)].sort((a, b) => getId(a) - getId(b));
1722
+ pendingPostFlushCbs.length = 0;
1723
+ if (activePostFlushCbs) {
1724
+ activePostFlushCbs.push(...deduped);
1725
+ return;
1726
+ }
1727
+ activePostFlushCbs = deduped;
1728
+ if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
1729
+ for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1730
+ const cb = activePostFlushCbs[postFlushIndex];
1731
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) continue;
1732
+ if (cb.flags & SchedulerJobFlags.ALLOW_RECURSE) cb.flags &= ~SchedulerJobFlags.QUEUED;
1733
+ if (!(cb.flags & SchedulerJobFlags.DISPOSED)) cb();
1734
+ cb.flags &= ~SchedulerJobFlags.QUEUED;
1735
+ }
1736
+ activePostFlushCbs = null;
1737
+ postFlushIndex = 0;
1738
+ }
1739
+ }
1740
+ var getId = (job) => job.id == null ? job.flags & SchedulerJobFlags.PRE ? -1 : Infinity : job.id;
2107
1741
  function flushJobs(seen) {
2108
- if (!!(process.env.NODE_ENV !== "production")) {
2109
- seen = seen || /* @__PURE__ */ new Map();
2110
- }
2111
- const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
2112
- try {
2113
- for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
2114
- const job = queue[flushIndex];
2115
- if (job && !(job.flags & 8)) {
2116
- if (!!(process.env.NODE_ENV !== "production") && check(job)) {
2117
- continue;
2118
- }
2119
- if (job.flags & 4) {
2120
- job.flags &= ~1;
2121
- }
2122
- callWithErrorHandling(
2123
- job,
2124
- null,
2125
- ErrorCodes.SCHEDULER
2126
- );
2127
- if (!(job.flags & 4)) {
2128
- job.flags &= ~1;
2129
- }
2130
- }
2131
- }
2132
- } finally {
2133
- for (; flushIndex < queue.length; flushIndex++) {
2134
- const job = queue[flushIndex];
2135
- if (job) {
2136
- job.flags &= -2;
2137
- }
2138
- }
2139
- flushIndex = -1;
2140
- queue.length = 0;
2141
- flushPostFlushCbs(seen);
2142
- currentFlushPromise = null;
2143
- if (queue.length || pendingPostFlushCbs.length) {
2144
- flushJobs(seen);
2145
- }
2146
- }
1742
+ if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
1743
+ const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
1744
+ try {
1745
+ for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1746
+ const job = queue[flushIndex];
1747
+ if (job && !(job.flags & SchedulerJobFlags.DISPOSED)) {
1748
+ if (!!(process.env.NODE_ENV !== "production") && check(job)) continue;
1749
+ if (job.flags & SchedulerJobFlags.ALLOW_RECURSE) job.flags &= ~SchedulerJobFlags.QUEUED;
1750
+ callWithErrorHandling(job, null, ErrorCodes.SCHEDULER);
1751
+ if (!(job.flags & SchedulerJobFlags.ALLOW_RECURSE)) job.flags &= ~SchedulerJobFlags.QUEUED;
1752
+ }
1753
+ }
1754
+ } finally {
1755
+ for (; flushIndex < queue.length; flushIndex++) {
1756
+ const job = queue[flushIndex];
1757
+ if (job) job.flags &= ~SchedulerJobFlags.QUEUED;
1758
+ }
1759
+ flushIndex = -1;
1760
+ queue.length = 0;
1761
+ flushPostFlushCbs(seen);
1762
+ currentFlushPromise = null;
1763
+ if (queue.length || pendingPostFlushCbs.length) flushJobs(seen);
1764
+ }
2147
1765
  }
2148
1766
  function checkRecursiveUpdates(seen, fn) {
2149
- const count = seen.get(fn) || 0;
2150
- if (count > RECURSION_LIMIT) {
2151
- handleError(
2152
- `Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
2153
- null,
2154
- ErrorCodes.APP_ERROR_HANDLER
2155
- );
2156
- return true;
2157
- }
2158
- seen.set(fn, count + 1);
2159
- return false;
2160
- }
2161
- function watchEffect(effect2, options) {
2162
- return doWatch(effect2, null, options);
2163
- }
2164
- function watchSyncEffect(effect2, options) {
2165
- return doWatch(
2166
- effect2,
2167
- null,
2168
- !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" }
2169
- );
1767
+ const count = seen.get(fn) || 0;
1768
+ if (count > RECURSION_LIMIT) {
1769
+ handleError("Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.", null, ErrorCodes.APP_ERROR_HANDLER);
1770
+ return true;
1771
+ }
1772
+ seen.set(fn, count + 1);
1773
+ return false;
1774
+ }
1775
+ //#endregion
1776
+ //#region src/apiWatch.ts
1777
+ function watchEffect(effect, options) {
1778
+ return doWatch(effect, null, options);
1779
+ }
1780
+ function watchSyncEffect(effect, options) {
1781
+ return doWatch(effect, null, !!(process.env.NODE_ENV !== "production") ? extend({}, options, { flush: "sync" }) : { flush: "sync" });
2170
1782
  }
2171
1783
  function watch(source, cb, options) {
2172
- if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
2173
- warn(
2174
- `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
2175
- );
2176
- }
2177
- return doWatch(source, cb, options);
1784
+ if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) warn("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature.");
1785
+ return doWatch(source, cb, options);
2178
1786
  }
2179
1787
  function doWatch(source, cb, options = EMPTY_OBJ) {
2180
- const { immediate, deep, flush, once } = options;
2181
- if (!!(process.env.NODE_ENV !== "production") && !cb) {
2182
- if (immediate !== void 0) {
2183
- warn(
2184
- `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
2185
- );
2186
- }
2187
- if (deep !== void 0) {
2188
- warn(
2189
- `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
2190
- );
2191
- }
2192
- if (once !== void 0) {
2193
- warn(
2194
- `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
2195
- );
2196
- }
2197
- }
2198
- const baseWatchOptions = extend({}, options);
2199
- if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn;
2200
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, null, type, args);
2201
- let isPre = false;
2202
- if (flush !== "sync") {
2203
- isPre = true;
2204
- baseWatchOptions.scheduler = (job, isFirstRun) => {
2205
- if (isFirstRun) {
2206
- job();
2207
- } else {
2208
- queueJob(job);
2209
- }
2210
- };
2211
- }
2212
- baseWatchOptions.augmentJob = (job) => {
2213
- if (cb) {
2214
- job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
2215
- }
2216
- if (isPre) {
2217
- job.flags |= SchedulerJobFlags.PRE;
2218
- }
2219
- };
2220
- const watchHandle = watch$1(source, cb, baseWatchOptions);
2221
- return watchHandle;
2222
- }
1788
+ const { immediate, deep, flush, once } = options;
1789
+ if (!!(process.env.NODE_ENV !== "production") && !cb) {
1790
+ if (immediate !== void 0) warn("watch() \"immediate\" option is only respected when using the watch(source, callback, options?) signature.");
1791
+ if (deep !== void 0) warn("watch() \"deep\" option is only respected when using the watch(source, callback, options?) signature.");
1792
+ if (once !== void 0) warn("watch() \"once\" option is only respected when using the watch(source, callback, options?) signature.");
1793
+ }
1794
+ const baseWatchOptions = extend({}, options);
1795
+ if (!!(process.env.NODE_ENV !== "production")) baseWatchOptions.onWarn = warn;
1796
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, null, type, args);
1797
+ let isPre = false;
1798
+ if (flush !== "sync") {
1799
+ isPre = true;
1800
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
1801
+ if (isFirstRun) job();
1802
+ else queueJob(job);
1803
+ };
1804
+ }
1805
+ baseWatchOptions.augmentJob = (job) => {
1806
+ if (cb) job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
1807
+ if (isPre) job.flags |= SchedulerJobFlags.PRE;
1808
+ };
1809
+ return watch$1(source, cb, baseWatchOptions);
1810
+ }
1811
+ //#endregion
2223
1812
  exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
2224
1813
  exports.EffectFlags = EffectFlags;
2225
1814
  exports.EffectScope = EffectScope;
@@ -2273,4 +1862,5 @@ exports.unref = unref;
2273
1862
  exports.watch = watch;
2274
1863
  exports.watchEffect = watchEffect;
2275
1864
  exports.watchSyncEffect = watchSyncEffect;
2276
- //# sourceMappingURL=index.cjs.map
1865
+
1866
+ //# sourceMappingURL=index.cjs.map