@vue/reactivity 3.2.47 → 3.3.0-alpha.10

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.
@@ -6,1188 +6,1159 @@ var shared = require('@vue/shared');
6
6
 
7
7
  let activeEffectScope;
8
8
  class EffectScope {
9
- constructor(detached = false) {
10
- this.detached = detached;
11
- /**
12
- * @internal
13
- */
14
- this._active = true;
15
- /**
16
- * @internal
17
- */
18
- this.effects = [];
19
- /**
20
- * @internal
21
- */
22
- this.cleanups = [];
23
- this.parent = activeEffectScope;
24
- if (!detached && activeEffectScope) {
25
- this.index =
26
- (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
27
- }
28
- }
29
- get active() {
30
- return this._active;
31
- }
32
- run(fn) {
33
- if (this._active) {
34
- const currentEffectScope = activeEffectScope;
35
- try {
36
- activeEffectScope = this;
37
- return fn();
38
- }
39
- finally {
40
- activeEffectScope = currentEffectScope;
41
- }
42
- }
43
- }
9
+ constructor(detached = false) {
10
+ this.detached = detached;
44
11
  /**
45
- * This should only be called on non-detached scopes
46
12
  * @internal
47
13
  */
48
- on() {
49
- activeEffectScope = this;
50
- }
14
+ this._active = true;
51
15
  /**
52
- * This should only be called on non-detached scopes
53
16
  * @internal
54
17
  */
55
- off() {
56
- activeEffectScope = this.parent;
57
- }
58
- stop(fromParent) {
59
- if (this._active) {
60
- let i, l;
61
- for (i = 0, l = this.effects.length; i < l; i++) {
62
- this.effects[i].stop();
63
- }
64
- for (i = 0, l = this.cleanups.length; i < l; i++) {
65
- this.cleanups[i]();
66
- }
67
- if (this.scopes) {
68
- for (i = 0, l = this.scopes.length; i < l; i++) {
69
- this.scopes[i].stop(true);
70
- }
71
- }
72
- // nested scope, dereference from parent to avoid memory leaks
73
- if (!this.detached && this.parent && !fromParent) {
74
- // optimized O(1) removal
75
- const last = this.parent.scopes.pop();
76
- if (last && last !== this) {
77
- this.parent.scopes[this.index] = last;
78
- last.index = this.index;
79
- }
80
- }
81
- this.parent = undefined;
82
- this._active = false;
18
+ this.effects = [];
19
+ /**
20
+ * @internal
21
+ */
22
+ this.cleanups = [];
23
+ this.parent = activeEffectScope;
24
+ if (!detached && activeEffectScope) {
25
+ this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
26
+ this
27
+ ) - 1;
28
+ }
29
+ }
30
+ get active() {
31
+ return this._active;
32
+ }
33
+ run(fn) {
34
+ if (this._active) {
35
+ const currentEffectScope = activeEffectScope;
36
+ try {
37
+ activeEffectScope = this;
38
+ return fn();
39
+ } finally {
40
+ activeEffectScope = currentEffectScope;
41
+ }
42
+ }
43
+ }
44
+ /**
45
+ * This should only be called on non-detached scopes
46
+ * @internal
47
+ */
48
+ on() {
49
+ activeEffectScope = this;
50
+ }
51
+ /**
52
+ * This should only be called on non-detached scopes
53
+ * @internal
54
+ */
55
+ off() {
56
+ activeEffectScope = this.parent;
57
+ }
58
+ stop(fromParent) {
59
+ if (this._active) {
60
+ let i, l;
61
+ for (i = 0, l = this.effects.length; i < l; i++) {
62
+ this.effects[i].stop();
63
+ }
64
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
65
+ this.cleanups[i]();
66
+ }
67
+ if (this.scopes) {
68
+ for (i = 0, l = this.scopes.length; i < l; i++) {
69
+ this.scopes[i].stop(true);
70
+ }
71
+ }
72
+ if (!this.detached && this.parent && !fromParent) {
73
+ const last = this.parent.scopes.pop();
74
+ if (last && last !== this) {
75
+ this.parent.scopes[this.index] = last;
76
+ last.index = this.index;
83
77
  }
78
+ }
79
+ this.parent = void 0;
80
+ this._active = false;
84
81
  }
82
+ }
85
83
  }
86
84
  function effectScope(detached) {
87
- return new EffectScope(detached);
85
+ return new EffectScope(detached);
88
86
  }
89
87
  function recordEffectScope(effect, scope = activeEffectScope) {
90
- if (scope && scope.active) {
91
- scope.effects.push(effect);
92
- }
88
+ if (scope && scope.active) {
89
+ scope.effects.push(effect);
90
+ }
93
91
  }
94
92
  function getCurrentScope() {
95
- return activeEffectScope;
93
+ return activeEffectScope;
96
94
  }
97
95
  function onScopeDispose(fn) {
98
- if (activeEffectScope) {
99
- activeEffectScope.cleanups.push(fn);
100
- }
96
+ if (activeEffectScope) {
97
+ activeEffectScope.cleanups.push(fn);
98
+ }
101
99
  }
102
100
 
103
101
  const createDep = (effects) => {
104
- const dep = new Set(effects);
105
- dep.w = 0;
106
- dep.n = 0;
107
- return dep;
102
+ const dep = new Set(effects);
103
+ dep.w = 0;
104
+ dep.n = 0;
105
+ return dep;
108
106
  };
109
107
  const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
110
108
  const newTracked = (dep) => (dep.n & trackOpBit) > 0;
111
109
  const initDepMarkers = ({ deps }) => {
112
- if (deps.length) {
113
- for (let i = 0; i < deps.length; i++) {
114
- deps[i].w |= trackOpBit; // set was tracked
115
- }
110
+ if (deps.length) {
111
+ for (let i = 0; i < deps.length; i++) {
112
+ deps[i].w |= trackOpBit;
116
113
  }
114
+ }
117
115
  };
118
116
  const finalizeDepMarkers = (effect) => {
119
- const { deps } = effect;
120
- if (deps.length) {
121
- let ptr = 0;
122
- for (let i = 0; i < deps.length; i++) {
123
- const dep = deps[i];
124
- if (wasTracked(dep) && !newTracked(dep)) {
125
- dep.delete(effect);
126
- }
127
- else {
128
- deps[ptr++] = dep;
129
- }
130
- // clear bits
131
- dep.w &= ~trackOpBit;
132
- dep.n &= ~trackOpBit;
133
- }
134
- deps.length = ptr;
135
- }
117
+ const { deps } = effect;
118
+ if (deps.length) {
119
+ let ptr = 0;
120
+ for (let i = 0; i < deps.length; i++) {
121
+ const dep = deps[i];
122
+ if (wasTracked(dep) && !newTracked(dep)) {
123
+ dep.delete(effect);
124
+ } else {
125
+ deps[ptr++] = dep;
126
+ }
127
+ dep.w &= ~trackOpBit;
128
+ dep.n &= ~trackOpBit;
129
+ }
130
+ deps.length = ptr;
131
+ }
136
132
  };
137
133
 
138
- const targetMap = new WeakMap();
139
- // The number of effects currently being tracked recursively.
134
+ const targetMap = /* @__PURE__ */ new WeakMap();
140
135
  let effectTrackDepth = 0;
141
136
  let trackOpBit = 1;
142
- /**
143
- * The bitwise track markers support at most 30 levels of recursion.
144
- * This value is chosen to enable modern JS engines to use a SMI on all platforms.
145
- * When recursion depth is greater, fall back to using a full cleanup.
146
- */
147
137
  const maxMarkerBits = 30;
148
138
  let activeEffect;
149
- const ITERATE_KEY = Symbol('');
150
- const MAP_KEY_ITERATE_KEY = Symbol('');
139
+ const ITERATE_KEY = Symbol("");
140
+ const MAP_KEY_ITERATE_KEY = Symbol("");
151
141
  class ReactiveEffect {
152
- constructor(fn, scheduler = null, scope) {
153
- this.fn = fn;
154
- this.scheduler = scheduler;
155
- this.active = true;
156
- this.deps = [];
157
- this.parent = undefined;
158
- recordEffectScope(this, scope);
159
- }
160
- run() {
161
- if (!this.active) {
162
- return this.fn();
163
- }
164
- let parent = activeEffect;
165
- let lastShouldTrack = shouldTrack;
166
- while (parent) {
167
- if (parent === this) {
168
- return;
169
- }
170
- parent = parent.parent;
171
- }
172
- try {
173
- this.parent = activeEffect;
174
- activeEffect = this;
175
- shouldTrack = true;
176
- trackOpBit = 1 << ++effectTrackDepth;
177
- if (effectTrackDepth <= maxMarkerBits) {
178
- initDepMarkers(this);
179
- }
180
- else {
181
- cleanupEffect(this);
182
- }
183
- return this.fn();
184
- }
185
- finally {
186
- if (effectTrackDepth <= maxMarkerBits) {
187
- finalizeDepMarkers(this);
188
- }
189
- trackOpBit = 1 << --effectTrackDepth;
190
- activeEffect = this.parent;
191
- shouldTrack = lastShouldTrack;
192
- this.parent = undefined;
193
- if (this.deferStop) {
194
- this.stop();
195
- }
196
- }
197
- }
198
- stop() {
199
- // stopped while running itself - defer the cleanup
200
- if (activeEffect === this) {
201
- this.deferStop = true;
202
- }
203
- else if (this.active) {
204
- cleanupEffect(this);
205
- if (this.onStop) {
206
- this.onStop();
207
- }
208
- this.active = false;
209
- }
210
- }
211
- }
212
- function cleanupEffect(effect) {
213
- const { deps } = effect;
214
- if (deps.length) {
215
- for (let i = 0; i < deps.length; i++) {
216
- deps[i].delete(effect);
217
- }
218
- deps.length = 0;
219
- }
142
+ constructor(fn, scheduler = null, scope) {
143
+ this.fn = fn;
144
+ this.scheduler = scheduler;
145
+ this.active = true;
146
+ this.deps = [];
147
+ this.parent = void 0;
148
+ recordEffectScope(this, scope);
149
+ }
150
+ run() {
151
+ if (!this.active) {
152
+ return this.fn();
153
+ }
154
+ let parent = activeEffect;
155
+ let lastShouldTrack = shouldTrack;
156
+ while (parent) {
157
+ if (parent === this) {
158
+ return;
159
+ }
160
+ parent = parent.parent;
161
+ }
162
+ try {
163
+ this.parent = activeEffect;
164
+ activeEffect = this;
165
+ shouldTrack = true;
166
+ trackOpBit = 1 << ++effectTrackDepth;
167
+ if (effectTrackDepth <= maxMarkerBits) {
168
+ initDepMarkers(this);
169
+ } else {
170
+ cleanupEffect(this);
171
+ }
172
+ return this.fn();
173
+ } finally {
174
+ if (effectTrackDepth <= maxMarkerBits) {
175
+ finalizeDepMarkers(this);
176
+ }
177
+ trackOpBit = 1 << --effectTrackDepth;
178
+ activeEffect = this.parent;
179
+ shouldTrack = lastShouldTrack;
180
+ this.parent = void 0;
181
+ if (this.deferStop) {
182
+ this.stop();
183
+ }
184
+ }
185
+ }
186
+ stop() {
187
+ if (activeEffect === this) {
188
+ this.deferStop = true;
189
+ } else if (this.active) {
190
+ cleanupEffect(this);
191
+ if (this.onStop) {
192
+ this.onStop();
193
+ }
194
+ this.active = false;
195
+ }
196
+ }
197
+ }
198
+ function cleanupEffect(effect2) {
199
+ const { deps } = effect2;
200
+ if (deps.length) {
201
+ for (let i = 0; i < deps.length; i++) {
202
+ deps[i].delete(effect2);
203
+ }
204
+ deps.length = 0;
205
+ }
220
206
  }
221
207
  function effect(fn, options) {
222
- if (fn.effect) {
223
- fn = fn.effect.fn;
224
- }
225
- const _effect = new ReactiveEffect(fn);
226
- if (options) {
227
- shared.extend(_effect, options);
228
- if (options.scope)
229
- recordEffectScope(_effect, options.scope);
230
- }
231
- if (!options || !options.lazy) {
232
- _effect.run();
233
- }
234
- const runner = _effect.run.bind(_effect);
235
- runner.effect = _effect;
236
- return runner;
208
+ if (fn.effect) {
209
+ fn = fn.effect.fn;
210
+ }
211
+ const _effect = new ReactiveEffect(fn);
212
+ if (options) {
213
+ shared.extend(_effect, options);
214
+ if (options.scope)
215
+ recordEffectScope(_effect, options.scope);
216
+ }
217
+ if (!options || !options.lazy) {
218
+ _effect.run();
219
+ }
220
+ const runner = _effect.run.bind(_effect);
221
+ runner.effect = _effect;
222
+ return runner;
237
223
  }
238
224
  function stop(runner) {
239
- runner.effect.stop();
225
+ runner.effect.stop();
240
226
  }
241
227
  let shouldTrack = true;
242
228
  const trackStack = [];
243
229
  function pauseTracking() {
244
- trackStack.push(shouldTrack);
245
- shouldTrack = false;
230
+ trackStack.push(shouldTrack);
231
+ shouldTrack = false;
246
232
  }
247
233
  function enableTracking() {
248
- trackStack.push(shouldTrack);
249
- shouldTrack = true;
234
+ trackStack.push(shouldTrack);
235
+ shouldTrack = true;
250
236
  }
251
237
  function resetTracking() {
252
- const last = trackStack.pop();
253
- shouldTrack = last === undefined ? true : last;
238
+ const last = trackStack.pop();
239
+ shouldTrack = last === void 0 ? true : last;
254
240
  }
255
241
  function track(target, type, key) {
256
- if (shouldTrack && activeEffect) {
257
- let depsMap = targetMap.get(target);
258
- if (!depsMap) {
259
- targetMap.set(target, (depsMap = new Map()));
260
- }
261
- let dep = depsMap.get(key);
262
- if (!dep) {
263
- depsMap.set(key, (dep = createDep()));
264
- }
265
- trackEffects(dep);
242
+ if (shouldTrack && activeEffect) {
243
+ let depsMap = targetMap.get(target);
244
+ if (!depsMap) {
245
+ targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
246
+ }
247
+ let dep = depsMap.get(key);
248
+ if (!dep) {
249
+ depsMap.set(key, dep = createDep());
266
250
  }
251
+ trackEffects(dep);
252
+ }
267
253
  }
268
254
  function trackEffects(dep, debuggerEventExtraInfo) {
269
- let shouldTrack = false;
270
- if (effectTrackDepth <= maxMarkerBits) {
271
- if (!newTracked(dep)) {
272
- dep.n |= trackOpBit; // set newly tracked
273
- shouldTrack = !wasTracked(dep);
274
- }
275
- }
276
- else {
277
- // Full cleanup mode.
278
- shouldTrack = !dep.has(activeEffect);
279
- }
280
- if (shouldTrack) {
281
- dep.add(activeEffect);
282
- activeEffect.deps.push(dep);
283
- }
255
+ let shouldTrack2 = false;
256
+ if (effectTrackDepth <= maxMarkerBits) {
257
+ if (!newTracked(dep)) {
258
+ dep.n |= trackOpBit;
259
+ shouldTrack2 = !wasTracked(dep);
260
+ }
261
+ } else {
262
+ shouldTrack2 = !dep.has(activeEffect);
263
+ }
264
+ if (shouldTrack2) {
265
+ dep.add(activeEffect);
266
+ activeEffect.deps.push(dep);
267
+ }
284
268
  }
285
269
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
286
- const depsMap = targetMap.get(target);
287
- if (!depsMap) {
288
- // never been tracked
289
- return;
290
- }
291
- let deps = [];
292
- if (type === "clear" /* TriggerOpTypes.CLEAR */) {
293
- // collection being cleared
294
- // trigger all effects for target
295
- deps = [...depsMap.values()];
296
- }
297
- else if (key === 'length' && shared.isArray(target)) {
298
- const newLength = Number(newValue);
299
- depsMap.forEach((dep, key) => {
300
- if (key === 'length' || key >= newLength) {
301
- deps.push(dep);
302
- }
303
- });
304
- }
305
- else {
306
- // schedule runs for SET | ADD | DELETE
307
- if (key !== void 0) {
308
- deps.push(depsMap.get(key));
270
+ const depsMap = targetMap.get(target);
271
+ if (!depsMap) {
272
+ return;
273
+ }
274
+ let deps = [];
275
+ if (type === "clear") {
276
+ deps = [...depsMap.values()];
277
+ } else if (key === "length" && shared.isArray(target)) {
278
+ const newLength = Number(newValue);
279
+ depsMap.forEach((dep, key2) => {
280
+ if (key2 === "length" || key2 >= newLength) {
281
+ deps.push(dep);
282
+ }
283
+ });
284
+ } else {
285
+ if (key !== void 0) {
286
+ deps.push(depsMap.get(key));
287
+ }
288
+ switch (type) {
289
+ case "add":
290
+ if (!shared.isArray(target)) {
291
+ deps.push(depsMap.get(ITERATE_KEY));
292
+ if (shared.isMap(target)) {
293
+ deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
294
+ }
295
+ } else if (shared.isIntegerKey(key)) {
296
+ deps.push(depsMap.get("length"));
309
297
  }
310
- // also run for iteration key on ADD | DELETE | Map.SET
311
- switch (type) {
312
- case "add" /* TriggerOpTypes.ADD */:
313
- if (!shared.isArray(target)) {
314
- deps.push(depsMap.get(ITERATE_KEY));
315
- if (shared.isMap(target)) {
316
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
317
- }
318
- }
319
- else if (shared.isIntegerKey(key)) {
320
- // new index added to array -> length changes
321
- deps.push(depsMap.get('length'));
322
- }
323
- break;
324
- case "delete" /* TriggerOpTypes.DELETE */:
325
- if (!shared.isArray(target)) {
326
- deps.push(depsMap.get(ITERATE_KEY));
327
- if (shared.isMap(target)) {
328
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
329
- }
330
- }
331
- break;
332
- case "set" /* TriggerOpTypes.SET */:
333
- if (shared.isMap(target)) {
334
- deps.push(depsMap.get(ITERATE_KEY));
335
- }
336
- break;
298
+ break;
299
+ case "delete":
300
+ if (!shared.isArray(target)) {
301
+ deps.push(depsMap.get(ITERATE_KEY));
302
+ if (shared.isMap(target)) {
303
+ deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
304
+ }
337
305
  }
338
- }
339
- if (deps.length === 1) {
340
- if (deps[0]) {
341
- {
342
- triggerEffects(deps[0]);
343
- }
306
+ break;
307
+ case "set":
308
+ if (shared.isMap(target)) {
309
+ deps.push(depsMap.get(ITERATE_KEY));
344
310
  }
311
+ break;
345
312
  }
346
- else {
347
- const effects = [];
348
- for (const dep of deps) {
349
- if (dep) {
350
- effects.push(...dep);
351
- }
352
- }
353
- {
354
- triggerEffects(createDep(effects));
355
- }
313
+ }
314
+ if (deps.length === 1) {
315
+ if (deps[0]) {
316
+ {
317
+ triggerEffects(deps[0]);
318
+ }
319
+ }
320
+ } else {
321
+ const effects = [];
322
+ for (const dep of deps) {
323
+ if (dep) {
324
+ effects.push(...dep);
325
+ }
356
326
  }
327
+ {
328
+ triggerEffects(createDep(effects));
329
+ }
330
+ }
357
331
  }
358
332
  function triggerEffects(dep, debuggerEventExtraInfo) {
359
- // spread into array for stabilization
360
- const effects = shared.isArray(dep) ? dep : [...dep];
361
- for (const effect of effects) {
362
- if (effect.computed) {
363
- triggerEffect(effect);
364
- }
333
+ const effects = shared.isArray(dep) ? dep : [...dep];
334
+ for (const effect2 of effects) {
335
+ if (effect2.computed) {
336
+ triggerEffect(effect2);
365
337
  }
366
- for (const effect of effects) {
367
- if (!effect.computed) {
368
- triggerEffect(effect);
369
- }
338
+ }
339
+ for (const effect2 of effects) {
340
+ if (!effect2.computed) {
341
+ triggerEffect(effect2);
370
342
  }
343
+ }
371
344
  }
372
- function triggerEffect(effect, debuggerEventExtraInfo) {
373
- if (effect !== activeEffect || effect.allowRecurse) {
374
- if (effect.scheduler) {
375
- effect.scheduler();
376
- }
377
- else {
378
- effect.run();
379
- }
345
+ function triggerEffect(effect2, debuggerEventExtraInfo) {
346
+ if (effect2 !== activeEffect || effect2.allowRecurse) {
347
+ if (effect2.scheduler) {
348
+ effect2.scheduler();
349
+ } else {
350
+ effect2.run();
380
351
  }
352
+ }
381
353
  }
382
354
  function getDepFromReactive(object, key) {
383
- var _a;
384
- return (_a = targetMap.get(object)) === null || _a === void 0 ? void 0 : _a.get(key);
355
+ var _a;
356
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
385
357
  }
386
358
 
387
- const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
359
+ const isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`);
388
360
  const builtInSymbols = new Set(
389
- /*#__PURE__*/
390
- Object.getOwnPropertyNames(Symbol)
391
- // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
392
- // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
393
- // function
394
- .filter(key => key !== 'arguments' && key !== 'caller')
395
- .map(key => Symbol[key])
396
- .filter(shared.isSymbol));
397
- const get$1 = /*#__PURE__*/ createGetter();
398
- const shallowGet = /*#__PURE__*/ createGetter(false, true);
399
- const readonlyGet = /*#__PURE__*/ createGetter(true);
400
- const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
401
- const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
361
+ /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared.isSymbol)
362
+ );
363
+ const get$1 = /* @__PURE__ */ createGetter();
364
+ const shallowGet = /* @__PURE__ */ createGetter(false, true);
365
+ const readonlyGet = /* @__PURE__ */ createGetter(true);
366
+ const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
367
+ const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
402
368
  function createArrayInstrumentations() {
403
- const instrumentations = {};
404
- ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
405
- instrumentations[key] = function (...args) {
406
- const arr = toRaw(this);
407
- for (let i = 0, l = this.length; i < l; i++) {
408
- track(arr, "get" /* TrackOpTypes.GET */, i + '');
409
- }
410
- // we run the method using the original args first (which may be reactive)
411
- const res = arr[key](...args);
412
- if (res === -1 || res === false) {
413
- // if that didn't work, run it again using raw values.
414
- return arr[key](...args.map(toRaw));
415
- }
416
- else {
417
- return res;
418
- }
419
- };
420
- });
421
- ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
422
- instrumentations[key] = function (...args) {
423
- pauseTracking();
424
- const res = toRaw(this)[key].apply(this, args);
425
- resetTracking();
426
- return res;
427
- };
428
- });
429
- return instrumentations;
430
- }
431
- function hasOwnProperty(key) {
432
- const obj = toRaw(this);
433
- track(obj, "has" /* TrackOpTypes.HAS */, key);
434
- return obj.hasOwnProperty(key);
435
- }
436
- function createGetter(isReadonly = false, shallow = false) {
437
- return function get(target, key, receiver) {
438
- if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
439
- return !isReadonly;
440
- }
441
- else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
442
- return isReadonly;
443
- }
444
- else if (key === "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */) {
445
- return shallow;
446
- }
447
- else if (key === "__v_raw" /* ReactiveFlags.RAW */ &&
448
- receiver ===
449
- (isReadonly
450
- ? shallow
451
- ? shallowReadonlyMap
452
- : readonlyMap
453
- : shallow
454
- ? shallowReactiveMap
455
- : reactiveMap).get(target)) {
456
- return target;
457
- }
458
- const targetIsArray = shared.isArray(target);
459
- if (!isReadonly) {
460
- if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
461
- return Reflect.get(arrayInstrumentations, key, receiver);
462
- }
463
- if (key === 'hasOwnProperty') {
464
- return hasOwnProperty;
465
- }
466
- }
467
- const res = Reflect.get(target, key, receiver);
468
- if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
469
- return res;
470
- }
471
- if (!isReadonly) {
472
- track(target, "get" /* TrackOpTypes.GET */, key);
473
- }
474
- if (shallow) {
475
- return res;
476
- }
477
- if (isRef(res)) {
478
- // ref unwrapping - skip unwrap for Array + integer key.
479
- return targetIsArray && shared.isIntegerKey(key) ? res : res.value;
480
- }
481
- if (shared.isObject(res)) {
482
- // Convert returned value into a proxy as well. we do the isObject check
483
- // here to avoid invalid value warning. Also need to lazy access readonly
484
- // and reactive here to avoid circular dependency.
485
- return isReadonly ? readonly(res) : reactive(res);
486
- }
369
+ const instrumentations = {};
370
+ ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
371
+ instrumentations[key] = function(...args) {
372
+ const arr = toRaw(this);
373
+ for (let i = 0, l = this.length; i < l; i++) {
374
+ track(arr, "get", i + "");
375
+ }
376
+ const res = arr[key](...args);
377
+ if (res === -1 || res === false) {
378
+ return arr[key](...args.map(toRaw));
379
+ } else {
487
380
  return res;
381
+ }
488
382
  };
489
- }
490
- const set$1 = /*#__PURE__*/ createSetter();
491
- const shallowSet = /*#__PURE__*/ createSetter(true);
492
- function createSetter(shallow = false) {
493
- return function set(target, key, value, receiver) {
494
- let oldValue = target[key];
495
- if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
496
- return false;
497
- }
498
- if (!shallow) {
499
- if (!isShallow(value) && !isReadonly(value)) {
500
- oldValue = toRaw(oldValue);
501
- value = toRaw(value);
502
- }
503
- if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {
504
- oldValue.value = value;
505
- return true;
506
- }
507
- }
508
- const hadKey = shared.isArray(target) && shared.isIntegerKey(key)
509
- ? Number(key) < target.length
510
- : shared.hasOwn(target, key);
511
- const result = Reflect.set(target, key, value, receiver);
512
- // don't trigger if target is something up in the prototype chain of original
513
- if (target === toRaw(receiver)) {
514
- if (!hadKey) {
515
- trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
516
- }
517
- else if (shared.hasChanged(value, oldValue)) {
518
- trigger(target, "set" /* TriggerOpTypes.SET */, key, value);
519
- }
520
- }
521
- return result;
383
+ });
384
+ ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
385
+ instrumentations[key] = function(...args) {
386
+ pauseTracking();
387
+ const res = toRaw(this)[key].apply(this, args);
388
+ resetTracking();
389
+ return res;
522
390
  };
391
+ });
392
+ return instrumentations;
523
393
  }
524
- function deleteProperty(target, key) {
525
- const hadKey = shared.hasOwn(target, key);
526
- target[key];
527
- const result = Reflect.deleteProperty(target, key);
528
- if (result && hadKey) {
529
- trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined);
394
+ function hasOwnProperty(key) {
395
+ const obj = toRaw(this);
396
+ track(obj, "has", key);
397
+ return obj.hasOwnProperty(key);
398
+ }
399
+ function createGetter(isReadonly2 = false, shallow = false) {
400
+ return function get2(target, key, receiver) {
401
+ if (key === "__v_isReactive") {
402
+ return !isReadonly2;
403
+ } else if (key === "__v_isReadonly") {
404
+ return isReadonly2;
405
+ } else if (key === "__v_isShallow") {
406
+ return shallow;
407
+ } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
408
+ return target;
409
+ }
410
+ const targetIsArray = shared.isArray(target);
411
+ if (!isReadonly2) {
412
+ if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
413
+ return Reflect.get(arrayInstrumentations, key, receiver);
414
+ }
415
+ if (key === "hasOwnProperty") {
416
+ return hasOwnProperty;
417
+ }
418
+ }
419
+ const res = Reflect.get(target, key, receiver);
420
+ if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
421
+ return res;
422
+ }
423
+ if (!isReadonly2) {
424
+ track(target, "get", key);
425
+ }
426
+ if (shallow) {
427
+ return res;
428
+ }
429
+ if (isRef(res)) {
430
+ return targetIsArray && shared.isIntegerKey(key) ? res : res.value;
431
+ }
432
+ if (shared.isObject(res)) {
433
+ return isReadonly2 ? readonly(res) : reactive(res);
434
+ }
435
+ return res;
436
+ };
437
+ }
438
+ const set$1 = /* @__PURE__ */ createSetter();
439
+ const shallowSet = /* @__PURE__ */ createSetter(true);
440
+ function createSetter(shallow = false) {
441
+ return function set2(target, key, value, receiver) {
442
+ let oldValue = target[key];
443
+ if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
444
+ return false;
445
+ }
446
+ if (!shallow) {
447
+ if (!isShallow(value) && !isReadonly(value)) {
448
+ oldValue = toRaw(oldValue);
449
+ value = toRaw(value);
450
+ }
451
+ if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {
452
+ oldValue.value = value;
453
+ return true;
454
+ }
455
+ }
456
+ const hadKey = shared.isArray(target) && shared.isIntegerKey(key) ? Number(key) < target.length : shared.hasOwn(target, key);
457
+ const result = Reflect.set(target, key, value, receiver);
458
+ if (target === toRaw(receiver)) {
459
+ if (!hadKey) {
460
+ trigger(target, "add", key, value);
461
+ } else if (shared.hasChanged(value, oldValue)) {
462
+ trigger(target, "set", key, value);
463
+ }
530
464
  }
531
465
  return result;
466
+ };
467
+ }
468
+ function deleteProperty(target, key) {
469
+ const hadKey = shared.hasOwn(target, key);
470
+ target[key];
471
+ const result = Reflect.deleteProperty(target, key);
472
+ if (result && hadKey) {
473
+ trigger(target, "delete", key, void 0);
474
+ }
475
+ return result;
532
476
  }
533
477
  function has$1(target, key) {
534
- const result = Reflect.has(target, key);
535
- if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
536
- track(target, "has" /* TrackOpTypes.HAS */, key);
537
- }
538
- return result;
478
+ const result = Reflect.has(target, key);
479
+ if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
480
+ track(target, "has", key);
481
+ }
482
+ return result;
539
483
  }
540
484
  function ownKeys(target) {
541
- track(target, "iterate" /* TrackOpTypes.ITERATE */, shared.isArray(target) ? 'length' : ITERATE_KEY);
542
- return Reflect.ownKeys(target);
485
+ track(target, "iterate", shared.isArray(target) ? "length" : ITERATE_KEY);
486
+ return Reflect.ownKeys(target);
543
487
  }
544
488
  const mutableHandlers = {
545
- get: get$1,
546
- set: set$1,
547
- deleteProperty,
548
- has: has$1,
549
- ownKeys
489
+ get: get$1,
490
+ set: set$1,
491
+ deleteProperty,
492
+ has: has$1,
493
+ ownKeys
550
494
  };
551
495
  const readonlyHandlers = {
552
- get: readonlyGet,
553
- set(target, key) {
554
- return true;
555
- },
556
- deleteProperty(target, key) {
557
- return true;
558
- }
496
+ get: readonlyGet,
497
+ set(target, key) {
498
+ return true;
499
+ },
500
+ deleteProperty(target, key) {
501
+ return true;
502
+ }
559
503
  };
560
- const shallowReactiveHandlers = /*#__PURE__*/ shared.extend({}, mutableHandlers, {
504
+ const shallowReactiveHandlers = /* @__PURE__ */ shared.extend(
505
+ {},
506
+ mutableHandlers,
507
+ {
561
508
  get: shallowGet,
562
509
  set: shallowSet
563
- });
564
- // Props handlers are special in the sense that it should not unwrap top-level
565
- // refs (in order to allow refs to be explicitly passed down), but should
566
- // retain the reactivity of the normal readonly object.
567
- const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers, {
510
+ }
511
+ );
512
+ const shallowReadonlyHandlers = /* @__PURE__ */ shared.extend(
513
+ {},
514
+ readonlyHandlers,
515
+ {
568
516
  get: shallowReadonlyGet
569
- });
517
+ }
518
+ );
570
519
 
571
520
  const toShallow = (value) => value;
572
521
  const getProto = (v) => Reflect.getPrototypeOf(v);
573
522
  function get(target, key, isReadonly = false, isShallow = false) {
574
- // #1772: readonly(reactive(Map)) should return readonly + reactive version
575
- // of the value
576
- target = target["__v_raw" /* ReactiveFlags.RAW */];
577
- const rawTarget = toRaw(target);
578
- const rawKey = toRaw(key);
579
- if (!isReadonly) {
580
- if (key !== rawKey) {
581
- track(rawTarget, "get" /* TrackOpTypes.GET */, key);
582
- }
583
- track(rawTarget, "get" /* TrackOpTypes.GET */, rawKey);
584
- }
585
- const { has } = getProto(rawTarget);
586
- const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
587
- if (has.call(rawTarget, key)) {
588
- return wrap(target.get(key));
589
- }
590
- else if (has.call(rawTarget, rawKey)) {
591
- return wrap(target.get(rawKey));
592
- }
593
- else if (target !== rawTarget) {
594
- // #3602 readonly(reactive(Map))
595
- // ensure that the nested reactive `Map` can do tracking for itself
596
- target.get(key);
597
- }
523
+ target = target["__v_raw"];
524
+ const rawTarget = toRaw(target);
525
+ const rawKey = toRaw(key);
526
+ if (!isReadonly) {
527
+ if (key !== rawKey) {
528
+ track(rawTarget, "get", key);
529
+ }
530
+ track(rawTarget, "get", rawKey);
531
+ }
532
+ const { has: has2 } = getProto(rawTarget);
533
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
534
+ if (has2.call(rawTarget, key)) {
535
+ return wrap(target.get(key));
536
+ } else if (has2.call(rawTarget, rawKey)) {
537
+ return wrap(target.get(rawKey));
538
+ } else if (target !== rawTarget) {
539
+ target.get(key);
540
+ }
598
541
  }
599
542
  function has(key, isReadonly = false) {
600
- const target = this["__v_raw" /* ReactiveFlags.RAW */];
601
- const rawTarget = toRaw(target);
602
- const rawKey = toRaw(key);
603
- if (!isReadonly) {
604
- if (key !== rawKey) {
605
- track(rawTarget, "has" /* TrackOpTypes.HAS */, key);
606
- }
607
- track(rawTarget, "has" /* TrackOpTypes.HAS */, rawKey);
543
+ const target = this["__v_raw"];
544
+ const rawTarget = toRaw(target);
545
+ const rawKey = toRaw(key);
546
+ if (!isReadonly) {
547
+ if (key !== rawKey) {
548
+ track(rawTarget, "has", key);
608
549
  }
609
- return key === rawKey
610
- ? target.has(key)
611
- : target.has(key) || target.has(rawKey);
550
+ track(rawTarget, "has", rawKey);
551
+ }
552
+ return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
612
553
  }
613
554
  function size(target, isReadonly = false) {
614
- target = target["__v_raw" /* ReactiveFlags.RAW */];
615
- !isReadonly && track(toRaw(target), "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
616
- return Reflect.get(target, 'size', target);
555
+ target = target["__v_raw"];
556
+ !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
557
+ return Reflect.get(target, "size", target);
617
558
  }
618
559
  function add(value) {
619
- value = toRaw(value);
620
- const target = toRaw(this);
621
- const proto = getProto(target);
622
- const hadKey = proto.has.call(target, value);
623
- if (!hadKey) {
624
- target.add(value);
625
- trigger(target, "add" /* TriggerOpTypes.ADD */, value, value);
626
- }
627
- return this;
560
+ value = toRaw(value);
561
+ const target = toRaw(this);
562
+ const proto = getProto(target);
563
+ const hadKey = proto.has.call(target, value);
564
+ if (!hadKey) {
565
+ target.add(value);
566
+ trigger(target, "add", value, value);
567
+ }
568
+ return this;
628
569
  }
629
570
  function set(key, value) {
630
- value = toRaw(value);
631
- const target = toRaw(this);
632
- const { has, get } = getProto(target);
633
- let hadKey = has.call(target, key);
634
- if (!hadKey) {
635
- key = toRaw(key);
636
- hadKey = has.call(target, key);
637
- }
638
- const oldValue = get.call(target, key);
639
- target.set(key, value);
640
- if (!hadKey) {
641
- trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
642
- }
643
- else if (shared.hasChanged(value, oldValue)) {
644
- trigger(target, "set" /* TriggerOpTypes.SET */, key, value);
645
- }
646
- return this;
571
+ value = toRaw(value);
572
+ const target = toRaw(this);
573
+ const { has: has2, get: get2 } = getProto(target);
574
+ let hadKey = has2.call(target, key);
575
+ if (!hadKey) {
576
+ key = toRaw(key);
577
+ hadKey = has2.call(target, key);
578
+ }
579
+ const oldValue = get2.call(target, key);
580
+ target.set(key, value);
581
+ if (!hadKey) {
582
+ trigger(target, "add", key, value);
583
+ } else if (shared.hasChanged(value, oldValue)) {
584
+ trigger(target, "set", key, value);
585
+ }
586
+ return this;
647
587
  }
648
588
  function deleteEntry(key) {
649
- const target = toRaw(this);
650
- const { has, get } = getProto(target);
651
- let hadKey = has.call(target, key);
652
- if (!hadKey) {
653
- key = toRaw(key);
654
- hadKey = has.call(target, key);
655
- }
656
- get ? get.call(target, key) : undefined;
657
- // forward the operation before queueing reactions
658
- const result = target.delete(key);
659
- if (hadKey) {
660
- trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined);
661
- }
662
- return result;
589
+ const target = toRaw(this);
590
+ const { has: has2, get: get2 } = getProto(target);
591
+ let hadKey = has2.call(target, key);
592
+ if (!hadKey) {
593
+ key = toRaw(key);
594
+ hadKey = has2.call(target, key);
595
+ }
596
+ get2 ? get2.call(target, key) : void 0;
597
+ const result = target.delete(key);
598
+ if (hadKey) {
599
+ trigger(target, "delete", key, void 0);
600
+ }
601
+ return result;
663
602
  }
664
603
  function clear() {
665
- const target = toRaw(this);
666
- const hadItems = target.size !== 0;
667
- // forward the operation before queueing reactions
668
- const result = target.clear();
669
- if (hadItems) {
670
- trigger(target, "clear" /* TriggerOpTypes.CLEAR */, undefined, undefined);
671
- }
672
- return result;
604
+ const target = toRaw(this);
605
+ const hadItems = target.size !== 0;
606
+ const result = target.clear();
607
+ if (hadItems) {
608
+ trigger(target, "clear", void 0, void 0);
609
+ }
610
+ return result;
673
611
  }
674
612
  function createForEach(isReadonly, isShallow) {
675
- return function forEach(callback, thisArg) {
676
- const observed = this;
677
- const target = observed["__v_raw" /* ReactiveFlags.RAW */];
678
- const rawTarget = toRaw(target);
679
- const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
680
- !isReadonly && track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
681
- return target.forEach((value, key) => {
682
- // important: make sure the callback is
683
- // 1. invoked with the reactive map as `this` and 3rd arg
684
- // 2. the value received should be a corresponding reactive/readonly.
685
- return callback.call(thisArg, wrap(value), wrap(key), observed);
686
- });
687
- };
613
+ return function forEach(callback, thisArg) {
614
+ const observed = this;
615
+ const target = observed["__v_raw"];
616
+ const rawTarget = toRaw(target);
617
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
618
+ !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
619
+ return target.forEach((value, key) => {
620
+ return callback.call(thisArg, wrap(value), wrap(key), observed);
621
+ });
622
+ };
688
623
  }
689
624
  function createIterableMethod(method, isReadonly, isShallow) {
690
- return function (...args) {
691
- const target = this["__v_raw" /* ReactiveFlags.RAW */];
692
- const rawTarget = toRaw(target);
693
- const targetIsMap = shared.isMap(rawTarget);
694
- const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
695
- const isKeyOnly = method === 'keys' && targetIsMap;
696
- const innerIterator = target[method](...args);
697
- const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
698
- !isReadonly &&
699
- track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
700
- // return a wrapped iterator which returns observed versions of the
701
- // values emitted from the real iterator
702
- return {
703
- // iterator protocol
704
- next() {
705
- const { value, done } = innerIterator.next();
706
- return done
707
- ? { value, done }
708
- : {
709
- value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
710
- done
711
- };
712
- },
713
- // iterable protocol
714
- [Symbol.iterator]() {
715
- return this;
716
- }
625
+ return function(...args) {
626
+ const target = this["__v_raw"];
627
+ const rawTarget = toRaw(target);
628
+ const targetIsMap = shared.isMap(rawTarget);
629
+ const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
630
+ const isKeyOnly = method === "keys" && targetIsMap;
631
+ const innerIterator = target[method](...args);
632
+ const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
633
+ !isReadonly && track(
634
+ rawTarget,
635
+ "iterate",
636
+ isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
637
+ );
638
+ return {
639
+ // iterator protocol
640
+ next() {
641
+ const { value, done } = innerIterator.next();
642
+ return done ? { value, done } : {
643
+ value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
644
+ done
717
645
  };
646
+ },
647
+ // iterable protocol
648
+ [Symbol.iterator]() {
649
+ return this;
650
+ }
718
651
  };
652
+ };
719
653
  }
720
654
  function createReadonlyMethod(type) {
721
- return function (...args) {
722
- return type === "delete" /* TriggerOpTypes.DELETE */ ? false : this;
723
- };
655
+ return function(...args) {
656
+ return type === "delete" ? false : this;
657
+ };
724
658
  }
725
659
  function createInstrumentations() {
726
- const mutableInstrumentations = {
727
- get(key) {
728
- return get(this, key);
729
- },
730
- get size() {
731
- return size(this);
732
- },
733
- has,
734
- add,
735
- set,
736
- delete: deleteEntry,
737
- clear,
738
- forEach: createForEach(false, false)
739
- };
740
- const shallowInstrumentations = {
741
- get(key) {
742
- return get(this, key, false, true);
743
- },
744
- get size() {
745
- return size(this);
746
- },
747
- has,
748
- add,
749
- set,
750
- delete: deleteEntry,
751
- clear,
752
- forEach: createForEach(false, true)
753
- };
754
- const readonlyInstrumentations = {
755
- get(key) {
756
- return get(this, key, true);
757
- },
758
- get size() {
759
- return size(this, true);
760
- },
761
- has(key) {
762
- return has.call(this, key, true);
763
- },
764
- add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
765
- set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
766
- delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
767
- clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
768
- forEach: createForEach(true, false)
769
- };
770
- const shallowReadonlyInstrumentations = {
771
- get(key) {
772
- return get(this, key, true, true);
773
- },
774
- get size() {
775
- return size(this, true);
776
- },
777
- has(key) {
778
- return has.call(this, key, true);
779
- },
780
- add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
781
- set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
782
- delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
783
- clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
784
- forEach: createForEach(true, true)
785
- };
786
- const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
787
- iteratorMethods.forEach(method => {
788
- mutableInstrumentations[method] = createIterableMethod(method, false, false);
789
- readonlyInstrumentations[method] = createIterableMethod(method, true, false);
790
- shallowInstrumentations[method] = createIterableMethod(method, false, true);
791
- shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
792
- });
793
- return [
794
- mutableInstrumentations,
795
- readonlyInstrumentations,
796
- shallowInstrumentations,
797
- shallowReadonlyInstrumentations
798
- ];
799
- }
800
- const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
660
+ const mutableInstrumentations2 = {
661
+ get(key) {
662
+ return get(this, key);
663
+ },
664
+ get size() {
665
+ return size(this);
666
+ },
667
+ has,
668
+ add,
669
+ set,
670
+ delete: deleteEntry,
671
+ clear,
672
+ forEach: createForEach(false, false)
673
+ };
674
+ const shallowInstrumentations2 = {
675
+ get(key) {
676
+ return get(this, key, false, true);
677
+ },
678
+ get size() {
679
+ return size(this);
680
+ },
681
+ has,
682
+ add,
683
+ set,
684
+ delete: deleteEntry,
685
+ clear,
686
+ forEach: createForEach(false, true)
687
+ };
688
+ const readonlyInstrumentations2 = {
689
+ get(key) {
690
+ return get(this, key, true);
691
+ },
692
+ get size() {
693
+ return size(this, true);
694
+ },
695
+ has(key) {
696
+ return has.call(this, key, true);
697
+ },
698
+ add: createReadonlyMethod("add"),
699
+ set: createReadonlyMethod("set"),
700
+ delete: createReadonlyMethod("delete"),
701
+ clear: createReadonlyMethod("clear"),
702
+ forEach: createForEach(true, false)
703
+ };
704
+ const shallowReadonlyInstrumentations2 = {
705
+ get(key) {
706
+ return get(this, key, true, true);
707
+ },
708
+ get size() {
709
+ return size(this, true);
710
+ },
711
+ has(key) {
712
+ return has.call(this, key, true);
713
+ },
714
+ add: createReadonlyMethod("add"),
715
+ set: createReadonlyMethod("set"),
716
+ delete: createReadonlyMethod("delete"),
717
+ clear: createReadonlyMethod("clear"),
718
+ forEach: createForEach(true, true)
719
+ };
720
+ const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
721
+ iteratorMethods.forEach((method) => {
722
+ mutableInstrumentations2[method] = createIterableMethod(
723
+ method,
724
+ false,
725
+ false
726
+ );
727
+ readonlyInstrumentations2[method] = createIterableMethod(
728
+ method,
729
+ true,
730
+ false
731
+ );
732
+ shallowInstrumentations2[method] = createIterableMethod(
733
+ method,
734
+ false,
735
+ true
736
+ );
737
+ shallowReadonlyInstrumentations2[method] = createIterableMethod(
738
+ method,
739
+ true,
740
+ true
741
+ );
742
+ });
743
+ return [
744
+ mutableInstrumentations2,
745
+ readonlyInstrumentations2,
746
+ shallowInstrumentations2,
747
+ shallowReadonlyInstrumentations2
748
+ ];
749
+ }
750
+ const [
751
+ mutableInstrumentations,
752
+ readonlyInstrumentations,
753
+ shallowInstrumentations,
754
+ shallowReadonlyInstrumentations
755
+ ] = /* @__PURE__ */ createInstrumentations();
801
756
  function createInstrumentationGetter(isReadonly, shallow) {
802
- const instrumentations = shallow
803
- ? isReadonly
804
- ? shallowReadonlyInstrumentations
805
- : shallowInstrumentations
806
- : isReadonly
807
- ? readonlyInstrumentations
808
- : mutableInstrumentations;
809
- return (target, key, receiver) => {
810
- if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
811
- return !isReadonly;
812
- }
813
- else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
814
- return isReadonly;
815
- }
816
- else if (key === "__v_raw" /* ReactiveFlags.RAW */) {
817
- return target;
818
- }
819
- return Reflect.get(shared.hasOwn(instrumentations, key) && key in target
820
- ? instrumentations
821
- : target, key, receiver);
822
- };
757
+ const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
758
+ return (target, key, receiver) => {
759
+ if (key === "__v_isReactive") {
760
+ return !isReadonly;
761
+ } else if (key === "__v_isReadonly") {
762
+ return isReadonly;
763
+ } else if (key === "__v_raw") {
764
+ return target;
765
+ }
766
+ return Reflect.get(
767
+ shared.hasOwn(instrumentations, key) && key in target ? instrumentations : target,
768
+ key,
769
+ receiver
770
+ );
771
+ };
823
772
  }
824
773
  const mutableCollectionHandlers = {
825
- get: /*#__PURE__*/ createInstrumentationGetter(false, false)
774
+ get: /* @__PURE__ */ createInstrumentationGetter(false, false)
826
775
  };
827
776
  const shallowCollectionHandlers = {
828
- get: /*#__PURE__*/ createInstrumentationGetter(false, true)
777
+ get: /* @__PURE__ */ createInstrumentationGetter(false, true)
829
778
  };
830
779
  const readonlyCollectionHandlers = {
831
- get: /*#__PURE__*/ createInstrumentationGetter(true, false)
780
+ get: /* @__PURE__ */ createInstrumentationGetter(true, false)
832
781
  };
833
782
  const shallowReadonlyCollectionHandlers = {
834
- get: /*#__PURE__*/ createInstrumentationGetter(true, true)
783
+ get: /* @__PURE__ */ createInstrumentationGetter(true, true)
835
784
  };
836
785
 
837
- const reactiveMap = new WeakMap();
838
- const shallowReactiveMap = new WeakMap();
839
- const readonlyMap = new WeakMap();
840
- const shallowReadonlyMap = new WeakMap();
786
+ const reactiveMap = /* @__PURE__ */ new WeakMap();
787
+ const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
788
+ const readonlyMap = /* @__PURE__ */ new WeakMap();
789
+ const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
841
790
  function targetTypeMap(rawType) {
842
- switch (rawType) {
843
- case 'Object':
844
- case 'Array':
845
- return 1 /* TargetType.COMMON */;
846
- case 'Map':
847
- case 'Set':
848
- case 'WeakMap':
849
- case 'WeakSet':
850
- return 2 /* TargetType.COLLECTION */;
851
- default:
852
- return 0 /* TargetType.INVALID */;
853
- }
791
+ switch (rawType) {
792
+ case "Object":
793
+ case "Array":
794
+ return 1 /* COMMON */;
795
+ case "Map":
796
+ case "Set":
797
+ case "WeakMap":
798
+ case "WeakSet":
799
+ return 2 /* COLLECTION */;
800
+ default:
801
+ return 0 /* INVALID */;
802
+ }
854
803
  }
855
804
  function getTargetType(value) {
856
- return value["__v_skip" /* ReactiveFlags.SKIP */] || !Object.isExtensible(value)
857
- ? 0 /* TargetType.INVALID */
858
- : targetTypeMap(shared.toRawType(value));
805
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(shared.toRawType(value));
859
806
  }
860
807
  function reactive(target) {
861
- // if trying to observe a readonly proxy, return the readonly version.
862
- if (isReadonly(target)) {
863
- return target;
864
- }
865
- return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
808
+ if (isReadonly(target)) {
809
+ return target;
810
+ }
811
+ return createReactiveObject(
812
+ target,
813
+ false,
814
+ mutableHandlers,
815
+ mutableCollectionHandlers,
816
+ reactiveMap
817
+ );
866
818
  }
867
- /**
868
- * Return a shallowly-reactive copy of the original object, where only the root
869
- * level properties are reactive. It also does not auto-unwrap refs (even at the
870
- * root level).
871
- */
872
819
  function shallowReactive(target) {
873
- return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
820
+ return createReactiveObject(
821
+ target,
822
+ false,
823
+ shallowReactiveHandlers,
824
+ shallowCollectionHandlers,
825
+ shallowReactiveMap
826
+ );
874
827
  }
875
- /**
876
- * Creates a readonly copy of the original object. Note the returned copy is not
877
- * made reactive, but `readonly` can be called on an already reactive object.
878
- */
879
828
  function readonly(target) {
880
- return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
881
- }
882
- /**
883
- * Returns a reactive-copy of the original object, where only the root level
884
- * properties are readonly, and does NOT unwrap refs nor recursively convert
885
- * returned properties.
886
- * This is used for creating the props proxy object for stateful components.
887
- */
888
- function shallowReadonly(target) {
889
- return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
829
+ return createReactiveObject(
830
+ target,
831
+ true,
832
+ readonlyHandlers,
833
+ readonlyCollectionHandlers,
834
+ readonlyMap
835
+ );
890
836
  }
891
- function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
892
- if (!shared.isObject(target)) {
893
- return target;
894
- }
895
- // target is already a Proxy, return it.
896
- // exception: calling readonly() on a reactive object
897
- if (target["__v_raw" /* ReactiveFlags.RAW */] &&
898
- !(isReadonly && target["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */])) {
899
- return target;
900
- }
901
- // target already has corresponding Proxy
902
- const existingProxy = proxyMap.get(target);
903
- if (existingProxy) {
904
- return existingProxy;
905
- }
906
- // only specific value types can be observed.
907
- const targetType = getTargetType(target);
908
- if (targetType === 0 /* TargetType.INVALID */) {
909
- return target;
910
- }
911
- const proxy = new Proxy(target, targetType === 2 /* TargetType.COLLECTION */ ? collectionHandlers : baseHandlers);
912
- proxyMap.set(target, proxy);
913
- return proxy;
837
+ function shallowReadonly(target) {
838
+ return createReactiveObject(
839
+ target,
840
+ true,
841
+ shallowReadonlyHandlers,
842
+ shallowReadonlyCollectionHandlers,
843
+ shallowReadonlyMap
844
+ );
845
+ }
846
+ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
847
+ if (!shared.isObject(target)) {
848
+ return target;
849
+ }
850
+ if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
851
+ return target;
852
+ }
853
+ const existingProxy = proxyMap.get(target);
854
+ if (existingProxy) {
855
+ return existingProxy;
856
+ }
857
+ const targetType = getTargetType(target);
858
+ if (targetType === 0 /* INVALID */) {
859
+ return target;
860
+ }
861
+ const proxy = new Proxy(
862
+ target,
863
+ targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
864
+ );
865
+ proxyMap.set(target, proxy);
866
+ return proxy;
914
867
  }
915
868
  function isReactive(value) {
916
- if (isReadonly(value)) {
917
- return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
918
- }
919
- return !!(value && value["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */]);
869
+ if (isReadonly(value)) {
870
+ return isReactive(value["__v_raw"]);
871
+ }
872
+ return !!(value && value["__v_isReactive"]);
920
873
  }
921
874
  function isReadonly(value) {
922
- return !!(value && value["__v_isReadonly" /* ReactiveFlags.IS_READONLY */]);
875
+ return !!(value && value["__v_isReadonly"]);
923
876
  }
924
877
  function isShallow(value) {
925
- return !!(value && value["__v_isShallow" /* ReactiveFlags.IS_SHALLOW */]);
878
+ return !!(value && value["__v_isShallow"]);
926
879
  }
927
880
  function isProxy(value) {
928
- return isReactive(value) || isReadonly(value);
881
+ return isReactive(value) || isReadonly(value);
929
882
  }
930
883
  function toRaw(observed) {
931
- const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
932
- return raw ? toRaw(raw) : observed;
884
+ const raw = observed && observed["__v_raw"];
885
+ return raw ? toRaw(raw) : observed;
933
886
  }
934
887
  function markRaw(value) {
935
- shared.def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
936
- return value;
888
+ shared.def(value, "__v_skip", true);
889
+ return value;
937
890
  }
938
891
  const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
939
892
  const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
940
893
 
941
- function trackRefValue(ref) {
942
- if (shouldTrack && activeEffect) {
943
- ref = toRaw(ref);
944
- {
945
- trackEffects(ref.dep || (ref.dep = createDep()));
946
- }
894
+ function trackRefValue(ref2) {
895
+ if (shouldTrack && activeEffect) {
896
+ ref2 = toRaw(ref2);
897
+ {
898
+ trackEffects(ref2.dep || (ref2.dep = createDep()));
947
899
  }
900
+ }
948
901
  }
949
- function triggerRefValue(ref, newVal) {
950
- ref = toRaw(ref);
951
- const dep = ref.dep;
952
- if (dep) {
953
- {
954
- triggerEffects(dep);
955
- }
902
+ function triggerRefValue(ref2, newVal) {
903
+ ref2 = toRaw(ref2);
904
+ const dep = ref2.dep;
905
+ if (dep) {
906
+ {
907
+ triggerEffects(dep);
956
908
  }
909
+ }
957
910
  }
958
911
  function isRef(r) {
959
- return !!(r && r.__v_isRef === true);
912
+ return !!(r && r.__v_isRef === true);
960
913
  }
961
914
  function ref(value) {
962
- return createRef(value, false);
915
+ return createRef(value, false);
963
916
  }
964
917
  function shallowRef(value) {
965
- return createRef(value, true);
918
+ return createRef(value, true);
966
919
  }
967
920
  function createRef(rawValue, shallow) {
968
- if (isRef(rawValue)) {
969
- return rawValue;
970
- }
971
- return new RefImpl(rawValue, shallow);
921
+ if (isRef(rawValue)) {
922
+ return rawValue;
923
+ }
924
+ return new RefImpl(rawValue, shallow);
972
925
  }
973
926
  class RefImpl {
974
- constructor(value, __v_isShallow) {
975
- this.__v_isShallow = __v_isShallow;
976
- this.dep = undefined;
977
- this.__v_isRef = true;
978
- this._rawValue = __v_isShallow ? value : toRaw(value);
979
- this._value = __v_isShallow ? value : toReactive(value);
980
- }
981
- get value() {
982
- trackRefValue(this);
983
- return this._value;
984
- }
985
- set value(newVal) {
986
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
987
- newVal = useDirectValue ? newVal : toRaw(newVal);
988
- if (shared.hasChanged(newVal, this._rawValue)) {
989
- this._rawValue = newVal;
990
- this._value = useDirectValue ? newVal : toReactive(newVal);
991
- triggerRefValue(this);
992
- }
993
- }
994
- }
995
- function triggerRef(ref) {
996
- triggerRefValue(ref);
997
- }
998
- function unref(ref) {
999
- return isRef(ref) ? ref.value : ref;
927
+ constructor(value, __v_isShallow) {
928
+ this.__v_isShallow = __v_isShallow;
929
+ this.dep = void 0;
930
+ this.__v_isRef = true;
931
+ this._rawValue = __v_isShallow ? value : toRaw(value);
932
+ this._value = __v_isShallow ? value : toReactive(value);
933
+ }
934
+ get value() {
935
+ trackRefValue(this);
936
+ return this._value;
937
+ }
938
+ set value(newVal) {
939
+ const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
940
+ newVal = useDirectValue ? newVal : toRaw(newVal);
941
+ if (shared.hasChanged(newVal, this._rawValue)) {
942
+ this._rawValue = newVal;
943
+ this._value = useDirectValue ? newVal : toReactive(newVal);
944
+ triggerRefValue(this);
945
+ }
946
+ }
947
+ }
948
+ function triggerRef(ref2) {
949
+ triggerRefValue(ref2);
950
+ }
951
+ function unref(ref2) {
952
+ return isRef(ref2) ? ref2.value : ref2;
953
+ }
954
+ function toValue(source) {
955
+ return shared.isFunction(source) ? source() : unref(source);
1000
956
  }
1001
957
  const shallowUnwrapHandlers = {
1002
- get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
1003
- set: (target, key, value, receiver) => {
1004
- const oldValue = target[key];
1005
- if (isRef(oldValue) && !isRef(value)) {
1006
- oldValue.value = value;
1007
- return true;
1008
- }
1009
- else {
1010
- return Reflect.set(target, key, value, receiver);
1011
- }
1012
- }
958
+ get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
959
+ set: (target, key, value, receiver) => {
960
+ const oldValue = target[key];
961
+ if (isRef(oldValue) && !isRef(value)) {
962
+ oldValue.value = value;
963
+ return true;
964
+ } else {
965
+ return Reflect.set(target, key, value, receiver);
966
+ }
967
+ }
1013
968
  };
1014
969
  function proxyRefs(objectWithRefs) {
1015
- return isReactive(objectWithRefs)
1016
- ? objectWithRefs
1017
- : new Proxy(objectWithRefs, shallowUnwrapHandlers);
970
+ return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1018
971
  }
1019
972
  class CustomRefImpl {
1020
- constructor(factory) {
1021
- this.dep = undefined;
1022
- this.__v_isRef = true;
1023
- const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
1024
- this._get = get;
1025
- this._set = set;
1026
- }
1027
- get value() {
1028
- return this._get();
1029
- }
1030
- set value(newVal) {
1031
- this._set(newVal);
1032
- }
973
+ constructor(factory) {
974
+ this.dep = void 0;
975
+ this.__v_isRef = true;
976
+ const { get, set } = factory(
977
+ () => trackRefValue(this),
978
+ () => triggerRefValue(this)
979
+ );
980
+ this._get = get;
981
+ this._set = set;
982
+ }
983
+ get value() {
984
+ return this._get();
985
+ }
986
+ set value(newVal) {
987
+ this._set(newVal);
988
+ }
1033
989
  }
1034
990
  function customRef(factory) {
1035
- return new CustomRefImpl(factory);
991
+ return new CustomRefImpl(factory);
1036
992
  }
1037
993
  function toRefs(object) {
1038
- const ret = shared.isArray(object) ? new Array(object.length) : {};
1039
- for (const key in object) {
1040
- ret[key] = toRef(object, key);
1041
- }
1042
- return ret;
994
+ const ret = shared.isArray(object) ? new Array(object.length) : {};
995
+ for (const key in object) {
996
+ ret[key] = propertyToRef(object, key);
997
+ }
998
+ return ret;
1043
999
  }
1044
1000
  class ObjectRefImpl {
1045
- constructor(_object, _key, _defaultValue) {
1046
- this._object = _object;
1047
- this._key = _key;
1048
- this._defaultValue = _defaultValue;
1049
- this.__v_isRef = true;
1050
- }
1051
- get value() {
1052
- const val = this._object[this._key];
1053
- return val === undefined ? this._defaultValue : val;
1054
- }
1055
- set value(newVal) {
1056
- this._object[this._key] = newVal;
1057
- }
1058
- get dep() {
1059
- return getDepFromReactive(toRaw(this._object), this._key);
1060
- }
1061
- }
1062
- function toRef(object, key, defaultValue) {
1063
- const val = object[key];
1064
- return isRef(val)
1065
- ? val
1066
- : new ObjectRefImpl(object, key, defaultValue);
1001
+ constructor(_object, _key, _defaultValue) {
1002
+ this._object = _object;
1003
+ this._key = _key;
1004
+ this._defaultValue = _defaultValue;
1005
+ this.__v_isRef = true;
1006
+ }
1007
+ get value() {
1008
+ const val = this._object[this._key];
1009
+ return val === void 0 ? this._defaultValue : val;
1010
+ }
1011
+ set value(newVal) {
1012
+ this._object[this._key] = newVal;
1013
+ }
1014
+ get dep() {
1015
+ return getDepFromReactive(toRaw(this._object), this._key);
1016
+ }
1017
+ }
1018
+ class GetterRefImpl {
1019
+ constructor(_getter) {
1020
+ this._getter = _getter;
1021
+ this.__v_isRef = true;
1022
+ this.__v_isReadonly = true;
1023
+ }
1024
+ get value() {
1025
+ return this._getter();
1026
+ }
1027
+ }
1028
+ function toRef(source, key, defaultValue) {
1029
+ if (isRef(source)) {
1030
+ return source;
1031
+ } else if (shared.isFunction(source)) {
1032
+ return new GetterRefImpl(source);
1033
+ } else if (shared.isObject(source) && arguments.length > 1) {
1034
+ return propertyToRef(source, key, defaultValue);
1035
+ } else {
1036
+ return ref(source);
1037
+ }
1038
+ }
1039
+ function propertyToRef(source, key, defaultValue) {
1040
+ const val = source[key];
1041
+ return isRef(val) ? val : new ObjectRefImpl(
1042
+ source,
1043
+ key,
1044
+ defaultValue
1045
+ );
1067
1046
  }
1068
1047
 
1069
- var _a$1;
1070
1048
  class ComputedRefImpl {
1071
- constructor(getter, _setter, isReadonly, isSSR) {
1072
- this._setter = _setter;
1073
- this.dep = undefined;
1074
- this.__v_isRef = true;
1075
- this[_a$1] = false;
1049
+ constructor(getter, _setter, isReadonly, isSSR) {
1050
+ this._setter = _setter;
1051
+ this.dep = void 0;
1052
+ this.__v_isRef = true;
1053
+ this["__v_isReadonly"] = false;
1054
+ this._dirty = true;
1055
+ this.effect = new ReactiveEffect(getter, () => {
1056
+ if (!this._dirty) {
1076
1057
  this._dirty = true;
1077
- this.effect = new ReactiveEffect(getter, () => {
1078
- if (!this._dirty) {
1079
- this._dirty = true;
1080
- triggerRefValue(this);
1081
- }
1082
- });
1083
- this.effect.computed = this;
1084
- this.effect.active = this._cacheable = !isSSR;
1085
- this["__v_isReadonly" /* ReactiveFlags.IS_READONLY */] = isReadonly;
1086
- }
1087
- get value() {
1088
- // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1089
- const self = toRaw(this);
1090
- trackRefValue(self);
1091
- if (self._dirty || !self._cacheable) {
1092
- self._dirty = false;
1093
- self._value = self.effect.run();
1094
- }
1095
- return self._value;
1096
- }
1097
- set value(newValue) {
1098
- this._setter(newValue);
1099
- }
1058
+ triggerRefValue(this);
1059
+ }
1060
+ });
1061
+ this.effect.computed = this;
1062
+ this.effect.active = this._cacheable = !isSSR;
1063
+ this["__v_isReadonly"] = isReadonly;
1064
+ }
1065
+ get value() {
1066
+ const self = toRaw(this);
1067
+ trackRefValue(self);
1068
+ if (self._dirty || !self._cacheable) {
1069
+ self._dirty = false;
1070
+ self._value = self.effect.run();
1071
+ }
1072
+ return self._value;
1073
+ }
1074
+ set value(newValue) {
1075
+ this._setter(newValue);
1076
+ }
1100
1077
  }
1101
- _a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
1102
1078
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1103
- let getter;
1104
- let setter;
1105
- const onlyGetter = shared.isFunction(getterOrOptions);
1106
- if (onlyGetter) {
1107
- getter = getterOrOptions;
1108
- setter = shared.NOOP;
1109
- }
1110
- else {
1111
- getter = getterOrOptions.get;
1112
- setter = getterOrOptions.set;
1113
- }
1114
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1115
- return cRef;
1079
+ let getter;
1080
+ let setter;
1081
+ const onlyGetter = shared.isFunction(getterOrOptions);
1082
+ if (onlyGetter) {
1083
+ getter = getterOrOptions;
1084
+ setter = shared.NOOP;
1085
+ } else {
1086
+ getter = getterOrOptions.get;
1087
+ setter = getterOrOptions.set;
1088
+ }
1089
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1090
+ return cRef;
1116
1091
  }
1117
1092
 
1118
- var _a;
1119
- const tick = /*#__PURE__*/ Promise.resolve();
1093
+ const tick = /* @__PURE__ */ Promise.resolve();
1120
1094
  const queue = [];
1121
1095
  let queued = false;
1122
1096
  const scheduler = (fn) => {
1123
- queue.push(fn);
1124
- if (!queued) {
1125
- queued = true;
1126
- tick.then(flush);
1127
- }
1097
+ queue.push(fn);
1098
+ if (!queued) {
1099
+ queued = true;
1100
+ tick.then(flush);
1101
+ }
1128
1102
  };
1129
1103
  const flush = () => {
1130
- for (let i = 0; i < queue.length; i++) {
1131
- queue[i]();
1132
- }
1133
- queue.length = 0;
1134
- queued = false;
1104
+ for (let i = 0; i < queue.length; i++) {
1105
+ queue[i]();
1106
+ }
1107
+ queue.length = 0;
1108
+ queued = false;
1135
1109
  };
1136
1110
  class DeferredComputedRefImpl {
1137
- constructor(getter) {
1138
- this.dep = undefined;
1139
- this._dirty = true;
1140
- this.__v_isRef = true;
1141
- this[_a] = true;
1142
- let compareTarget;
1143
- let hasCompareTarget = false;
1144
- let scheduled = false;
1145
- this.effect = new ReactiveEffect(getter, (computedTrigger) => {
1146
- if (this.dep) {
1147
- if (computedTrigger) {
1148
- compareTarget = this._value;
1149
- hasCompareTarget = true;
1150
- }
1151
- else if (!scheduled) {
1152
- const valueToCompare = hasCompareTarget ? compareTarget : this._value;
1153
- scheduled = true;
1154
- hasCompareTarget = false;
1155
- scheduler(() => {
1156
- if (this.effect.active && this._get() !== valueToCompare) {
1157
- triggerRefValue(this);
1158
- }
1159
- scheduled = false;
1160
- });
1161
- }
1162
- // chained upstream computeds are notified synchronously to ensure
1163
- // value invalidation in case of sync access; normal effects are
1164
- // deferred to be triggered in scheduler.
1165
- for (const e of this.dep) {
1166
- if (e.computed instanceof DeferredComputedRefImpl) {
1167
- e.scheduler(true /* computedTrigger */);
1168
- }
1169
- }
1111
+ constructor(getter) {
1112
+ this.dep = void 0;
1113
+ this._dirty = true;
1114
+ this.__v_isRef = true;
1115
+ this["__v_isReadonly"] = true;
1116
+ let compareTarget;
1117
+ let hasCompareTarget = false;
1118
+ let scheduled = false;
1119
+ this.effect = new ReactiveEffect(getter, (computedTrigger) => {
1120
+ if (this.dep) {
1121
+ if (computedTrigger) {
1122
+ compareTarget = this._value;
1123
+ hasCompareTarget = true;
1124
+ } else if (!scheduled) {
1125
+ const valueToCompare = hasCompareTarget ? compareTarget : this._value;
1126
+ scheduled = true;
1127
+ hasCompareTarget = false;
1128
+ scheduler(() => {
1129
+ if (this.effect.active && this._get() !== valueToCompare) {
1130
+ triggerRefValue(this);
1170
1131
  }
1171
- this._dirty = true;
1172
- });
1173
- this.effect.computed = this;
1174
- }
1175
- _get() {
1176
- if (this._dirty) {
1177
- this._dirty = false;
1178
- return (this._value = this.effect.run());
1132
+ scheduled = false;
1133
+ });
1179
1134
  }
1180
- return this._value;
1181
- }
1182
- get value() {
1183
- trackRefValue(this);
1184
- // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1185
- return toRaw(this)._get();
1186
- }
1135
+ for (const e of this.dep) {
1136
+ if (e.computed instanceof DeferredComputedRefImpl) {
1137
+ e.scheduler(
1138
+ true
1139
+ /* computedTrigger */
1140
+ );
1141
+ }
1142
+ }
1143
+ }
1144
+ this._dirty = true;
1145
+ });
1146
+ this.effect.computed = this;
1147
+ }
1148
+ _get() {
1149
+ if (this._dirty) {
1150
+ this._dirty = false;
1151
+ return this._value = this.effect.run();
1152
+ }
1153
+ return this._value;
1154
+ }
1155
+ get value() {
1156
+ trackRefValue(this);
1157
+ return toRaw(this)._get();
1158
+ }
1187
1159
  }
1188
- _a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
1189
1160
  function deferredComputed(getter) {
1190
- return new DeferredComputedRefImpl(getter);
1161
+ return new DeferredComputedRefImpl(getter);
1191
1162
  }
1192
1163
 
1193
1164
  exports.EffectScope = EffectScope;
@@ -1220,6 +1191,7 @@ exports.stop = stop;
1220
1191
  exports.toRaw = toRaw;
1221
1192
  exports.toRef = toRef;
1222
1193
  exports.toRefs = toRefs;
1194
+ exports.toValue = toValue;
1223
1195
  exports.track = track;
1224
1196
  exports.trigger = trigger;
1225
1197
  exports.triggerRef = triggerRef;