@vue/reactivity 3.3.8 → 3.3.9
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/reactivity.cjs.js +1 -1
- package/dist/reactivity.cjs.prod.js +1 -1
- package/dist/reactivity.d.ts +198 -197
- package/dist/reactivity.esm-browser.js +1 -1
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +1 -1
- package/dist/reactivity.global.js +1 -1
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
package/dist/reactivity.cjs.js
CHANGED
|
@@ -645,7 +645,7 @@ function createIterableMethod(method, isReadonly, isShallow) {
|
|
|
645
645
|
}
|
|
646
646
|
function createReadonlyMethod(type) {
|
|
647
647
|
return function(...args) {
|
|
648
|
-
return type === "delete" ? false : this;
|
|
648
|
+
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
649
649
|
};
|
|
650
650
|
}
|
|
651
651
|
function createInstrumentations() {
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -1,5 +1,157 @@
|
|
|
1
1
|
import { IfAny } from '@vue/shared';
|
|
2
2
|
|
|
3
|
+
export declare const enum TrackOpTypes {
|
|
4
|
+
GET = "get",
|
|
5
|
+
HAS = "has",
|
|
6
|
+
ITERATE = "iterate"
|
|
7
|
+
}
|
|
8
|
+
export declare const enum TriggerOpTypes {
|
|
9
|
+
SET = "set",
|
|
10
|
+
ADD = "add",
|
|
11
|
+
DELETE = "delete",
|
|
12
|
+
CLEAR = "clear"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class EffectScope {
|
|
16
|
+
detached: boolean;
|
|
17
|
+
constructor(detached?: boolean);
|
|
18
|
+
get active(): boolean;
|
|
19
|
+
run<T>(fn: () => T): T | undefined;
|
|
20
|
+
stop(fromParent?: boolean): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
24
|
+
* computed and watchers) created within it so that these effects can be
|
|
25
|
+
* disposed together. For detailed use cases of this API, please consult its
|
|
26
|
+
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
27
|
+
*
|
|
28
|
+
* @param detached - Can be used to create a "detached" effect scope.
|
|
29
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
30
|
+
*/
|
|
31
|
+
export declare function effectScope(detached?: boolean): EffectScope;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the current active effect scope if there is one.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCurrentScope(): EffectScope | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Registers a dispose callback on the current active effect scope. The
|
|
40
|
+
* callback will be invoked when the associated effect scope is stopped.
|
|
41
|
+
*
|
|
42
|
+
* @param fn - The callback function to attach to the scope's cleanup.
|
|
43
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
44
|
+
*/
|
|
45
|
+
export declare function onScopeDispose(fn: () => void): void;
|
|
46
|
+
|
|
47
|
+
type Dep = Set<ReactiveEffect> & TrackedMarkers;
|
|
48
|
+
/**
|
|
49
|
+
* wasTracked and newTracked maintain the status for several levels of effect
|
|
50
|
+
* tracking recursion. One bit per level is used to define whether the dependency
|
|
51
|
+
* was/is tracked.
|
|
52
|
+
*/
|
|
53
|
+
type TrackedMarkers = {
|
|
54
|
+
/**
|
|
55
|
+
* wasTracked
|
|
56
|
+
*/
|
|
57
|
+
w: number;
|
|
58
|
+
/**
|
|
59
|
+
* newTracked
|
|
60
|
+
*/
|
|
61
|
+
n: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type EffectScheduler = (...args: any[]) => any;
|
|
65
|
+
export type DebuggerEvent = {
|
|
66
|
+
effect: ReactiveEffect;
|
|
67
|
+
} & DebuggerEventExtraInfo;
|
|
68
|
+
export type DebuggerEventExtraInfo = {
|
|
69
|
+
target: object;
|
|
70
|
+
type: TrackOpTypes | TriggerOpTypes;
|
|
71
|
+
key: any;
|
|
72
|
+
newValue?: any;
|
|
73
|
+
oldValue?: any;
|
|
74
|
+
oldTarget?: Map<any, any> | Set<any>;
|
|
75
|
+
};
|
|
76
|
+
export declare const ITERATE_KEY: unique symbol;
|
|
77
|
+
export declare class ReactiveEffect<T = any> {
|
|
78
|
+
fn: () => T;
|
|
79
|
+
scheduler: EffectScheduler | null;
|
|
80
|
+
active: boolean;
|
|
81
|
+
deps: Dep[];
|
|
82
|
+
parent: ReactiveEffect | undefined;
|
|
83
|
+
onStop?: () => void;
|
|
84
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
85
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
86
|
+
constructor(fn: () => T, scheduler?: EffectScheduler | null, scope?: EffectScope);
|
|
87
|
+
run(): T | undefined;
|
|
88
|
+
stop(): void;
|
|
89
|
+
}
|
|
90
|
+
export interface DebuggerOptions {
|
|
91
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
92
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
93
|
+
}
|
|
94
|
+
export interface ReactiveEffectOptions extends DebuggerOptions {
|
|
95
|
+
lazy?: boolean;
|
|
96
|
+
scheduler?: EffectScheduler;
|
|
97
|
+
scope?: EffectScope;
|
|
98
|
+
allowRecurse?: boolean;
|
|
99
|
+
onStop?: () => void;
|
|
100
|
+
}
|
|
101
|
+
export interface ReactiveEffectRunner<T = any> {
|
|
102
|
+
(): T;
|
|
103
|
+
effect: ReactiveEffect;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Registers the given function to track reactive updates.
|
|
107
|
+
*
|
|
108
|
+
* The given function will be run once immediately. Every time any reactive
|
|
109
|
+
* property that's accessed within it gets updated, the function will run again.
|
|
110
|
+
*
|
|
111
|
+
* @param fn - The function that will track reactive updates.
|
|
112
|
+
* @param options - Allows to control the effect's behaviour.
|
|
113
|
+
* @returns A runner that can be used to control the effect after creation.
|
|
114
|
+
*/
|
|
115
|
+
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
|
|
116
|
+
/**
|
|
117
|
+
* Stops the effect associated with the given runner.
|
|
118
|
+
*
|
|
119
|
+
* @param runner - Association with the effect to stop tracking.
|
|
120
|
+
*/
|
|
121
|
+
export declare function stop(runner: ReactiveEffectRunner): void;
|
|
122
|
+
/**
|
|
123
|
+
* Temporarily pauses tracking.
|
|
124
|
+
*/
|
|
125
|
+
export declare function pauseTracking(): void;
|
|
126
|
+
/**
|
|
127
|
+
* Re-enables effect tracking (if it was paused).
|
|
128
|
+
*/
|
|
129
|
+
export declare function enableTracking(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Resets the previous global effect tracking state.
|
|
132
|
+
*/
|
|
133
|
+
export declare function resetTracking(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Tracks access to a reactive property.
|
|
136
|
+
*
|
|
137
|
+
* This will check which effect is running at the moment and record it as dep
|
|
138
|
+
* which records all effects that depend on the reactive property.
|
|
139
|
+
*
|
|
140
|
+
* @param target - Object holding the reactive property.
|
|
141
|
+
* @param type - Defines the type of access to the reactive property.
|
|
142
|
+
* @param key - Identifier of the reactive property to track.
|
|
143
|
+
*/
|
|
144
|
+
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
145
|
+
/**
|
|
146
|
+
* Finds all deps associated with the target (or a specific property) and
|
|
147
|
+
* triggers the effects stored within.
|
|
148
|
+
*
|
|
149
|
+
* @param target - The reactive object.
|
|
150
|
+
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
151
|
+
* @param key - Can be used to target a specific reactive property in the target object.
|
|
152
|
+
*/
|
|
153
|
+
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
154
|
+
|
|
3
155
|
export declare const enum ReactiveFlags {
|
|
4
156
|
SKIP = "__v_skip",
|
|
5
157
|
IS_REACTIVE = "__v_isReactive",
|
|
@@ -216,161 +368,59 @@ export type Raw<T> = T & {
|
|
|
216
368
|
*/
|
|
217
369
|
export declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
218
370
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
export declare const enum TrackOpTypes {
|
|
224
|
-
GET = "get",
|
|
225
|
-
HAS = "has",
|
|
226
|
-
ITERATE = "iterate"
|
|
227
|
-
}
|
|
228
|
-
export declare const enum TriggerOpTypes {
|
|
229
|
-
SET = "set",
|
|
230
|
-
ADD = "add",
|
|
231
|
-
DELETE = "delete",
|
|
232
|
-
CLEAR = "clear"
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export declare class EffectScope {
|
|
236
|
-
detached: boolean;
|
|
237
|
-
constructor(detached?: boolean);
|
|
238
|
-
get active(): boolean;
|
|
239
|
-
run<T>(fn: () => T): T | undefined;
|
|
240
|
-
stop(fromParent?: boolean): void;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
244
|
-
* computed and watchers) created within it so that these effects can be
|
|
245
|
-
* disposed together. For detailed use cases of this API, please consult its
|
|
246
|
-
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
247
|
-
*
|
|
248
|
-
* @param detached - Can be used to create a "detached" effect scope.
|
|
249
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
250
|
-
*/
|
|
251
|
-
export declare function effectScope(detached?: boolean): EffectScope;
|
|
252
|
-
/**
|
|
253
|
-
* Returns the current active effect scope if there is one.
|
|
254
|
-
*
|
|
255
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
256
|
-
*/
|
|
257
|
-
export declare function getCurrentScope(): EffectScope | undefined;
|
|
258
|
-
/**
|
|
259
|
-
* Registers a dispose callback on the current active effect scope. The
|
|
260
|
-
* callback will be invoked when the associated effect scope is stopped.
|
|
261
|
-
*
|
|
262
|
-
* @param fn - The callback function to attach to the scope's cleanup.
|
|
263
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
264
|
-
*/
|
|
265
|
-
export declare function onScopeDispose(fn: () => void): void;
|
|
266
|
-
|
|
267
|
-
export type EffectScheduler = (...args: any[]) => any;
|
|
268
|
-
export type DebuggerEvent = {
|
|
269
|
-
effect: ReactiveEffect;
|
|
270
|
-
} & DebuggerEventExtraInfo;
|
|
271
|
-
export type DebuggerEventExtraInfo = {
|
|
272
|
-
target: object;
|
|
273
|
-
type: TrackOpTypes | TriggerOpTypes;
|
|
274
|
-
key: any;
|
|
275
|
-
newValue?: any;
|
|
276
|
-
oldValue?: any;
|
|
277
|
-
oldTarget?: Map<any, any> | Set<any>;
|
|
278
|
-
};
|
|
279
|
-
export declare const ITERATE_KEY: unique symbol;
|
|
280
|
-
export declare class ReactiveEffect<T = any> {
|
|
281
|
-
fn: () => T;
|
|
282
|
-
scheduler: EffectScheduler | null;
|
|
283
|
-
active: boolean;
|
|
284
|
-
deps: Dep[];
|
|
285
|
-
parent: ReactiveEffect | undefined;
|
|
286
|
-
onStop?: () => void;
|
|
287
|
-
onTrack?: (event: DebuggerEvent) => void;
|
|
288
|
-
onTrigger?: (event: DebuggerEvent) => void;
|
|
289
|
-
constructor(fn: () => T, scheduler?: EffectScheduler | null, scope?: EffectScope);
|
|
290
|
-
run(): T | undefined;
|
|
291
|
-
stop(): void;
|
|
292
|
-
}
|
|
293
|
-
export interface DebuggerOptions {
|
|
294
|
-
onTrack?: (event: DebuggerEvent) => void;
|
|
295
|
-
onTrigger?: (event: DebuggerEvent) => void;
|
|
371
|
+
declare const ComputedRefSymbol: unique symbol;
|
|
372
|
+
export interface ComputedRef<T = any> extends WritableComputedRef<T> {
|
|
373
|
+
readonly value: T;
|
|
374
|
+
[ComputedRefSymbol]: true;
|
|
296
375
|
}
|
|
297
|
-
export interface
|
|
298
|
-
|
|
299
|
-
scheduler?: EffectScheduler;
|
|
300
|
-
scope?: EffectScope;
|
|
301
|
-
allowRecurse?: boolean;
|
|
302
|
-
onStop?: () => void;
|
|
376
|
+
export interface WritableComputedRef<T> extends Ref<T> {
|
|
377
|
+
readonly effect: ReactiveEffect<T>;
|
|
303
378
|
}
|
|
304
|
-
export
|
|
305
|
-
|
|
306
|
-
|
|
379
|
+
export type ComputedGetter<T> = (...args: any[]) => T;
|
|
380
|
+
export type ComputedSetter<T> = (v: T) => void;
|
|
381
|
+
export interface WritableComputedOptions<T> {
|
|
382
|
+
get: ComputedGetter<T>;
|
|
383
|
+
set: ComputedSetter<T>;
|
|
307
384
|
}
|
|
308
385
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* property that's accessed within it gets updated, the function will run again.
|
|
386
|
+
* Takes a getter function and returns a readonly reactive ref object for the
|
|
387
|
+
* returned value from the getter. It can also take an object with get and set
|
|
388
|
+
* functions to create a writable ref object.
|
|
313
389
|
*
|
|
314
|
-
* @
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Stops the effect associated with the given runner.
|
|
390
|
+
* @example
|
|
391
|
+
* ```js
|
|
392
|
+
* // Creating a readonly computed ref:
|
|
393
|
+
* const count = ref(1)
|
|
394
|
+
* const plusOne = computed(() => count.value + 1)
|
|
321
395
|
*
|
|
322
|
-
*
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Temporarily pauses tracking.
|
|
327
|
-
*/
|
|
328
|
-
export declare function pauseTracking(): void;
|
|
329
|
-
/**
|
|
330
|
-
* Re-enables effect tracking (if it was paused).
|
|
331
|
-
*/
|
|
332
|
-
export declare function enableTracking(): void;
|
|
333
|
-
/**
|
|
334
|
-
* Resets the previous global effect tracking state.
|
|
335
|
-
*/
|
|
336
|
-
export declare function resetTracking(): void;
|
|
337
|
-
/**
|
|
338
|
-
* Tracks access to a reactive property.
|
|
396
|
+
* console.log(plusOne.value) // 2
|
|
397
|
+
* plusOne.value++ // error
|
|
398
|
+
* ```
|
|
339
399
|
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
400
|
+
* ```js
|
|
401
|
+
* // Creating a writable computed ref:
|
|
402
|
+
* const count = ref(1)
|
|
403
|
+
* const plusOne = computed({
|
|
404
|
+
* get: () => count.value + 1,
|
|
405
|
+
* set: (val) => {
|
|
406
|
+
* count.value = val - 1
|
|
407
|
+
* }
|
|
408
|
+
* })
|
|
342
409
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*/
|
|
347
|
-
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
348
|
-
/**
|
|
349
|
-
* Finds all deps associated with the target (or a specific property) and
|
|
350
|
-
* triggers the effects stored within.
|
|
410
|
+
* plusOne.value = 1
|
|
411
|
+
* console.log(count.value) // 0
|
|
412
|
+
* ```
|
|
351
413
|
*
|
|
352
|
-
* @param
|
|
353
|
-
* @param
|
|
354
|
-
* @
|
|
414
|
+
* @param getter - Function that produces the next value.
|
|
415
|
+
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
|
|
416
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#computed}
|
|
355
417
|
*/
|
|
356
|
-
export declare function
|
|
418
|
+
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
419
|
+
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
|
|
357
420
|
|
|
358
|
-
type
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
* tracking recursion. One bit per level is used to define whether the dependency
|
|
362
|
-
* was/is tracked.
|
|
363
|
-
*/
|
|
364
|
-
type TrackedMarkers = {
|
|
365
|
-
/**
|
|
366
|
-
* wasTracked
|
|
367
|
-
*/
|
|
368
|
-
w: number;
|
|
369
|
-
/**
|
|
370
|
-
* newTracked
|
|
371
|
-
*/
|
|
372
|
-
n: number;
|
|
373
|
-
};
|
|
421
|
+
type CollectionTypes = IterableCollections | WeakCollections;
|
|
422
|
+
type IterableCollections = Map<any, any> | Set<any>;
|
|
423
|
+
type WeakCollections = WeakMap<any, any> | WeakSet<any>;
|
|
374
424
|
|
|
375
425
|
declare const RefSymbol: unique symbol;
|
|
376
426
|
declare const RawSymbol: unique symbol;
|
|
@@ -421,7 +471,8 @@ export type ShallowRef<T = any> = Ref<T> & {
|
|
|
421
471
|
* @param value - The "inner value" for the shallow ref.
|
|
422
472
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
|
|
423
473
|
*/
|
|
424
|
-
export declare function shallowRef<T
|
|
474
|
+
export declare function shallowRef<T>(value: MaybeRef<T>): Ref<T> | ShallowRef<T>;
|
|
475
|
+
export declare function shallowRef<T extends Ref>(value: T): T;
|
|
425
476
|
export declare function shallowRef<T>(value: T): ShallowRef<T>;
|
|
426
477
|
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
427
478
|
/**
|
|
@@ -468,7 +519,7 @@ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
|
|
|
468
519
|
* @param ref - Ref or plain value to be converted into the plain value.
|
|
469
520
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
470
521
|
*/
|
|
471
|
-
export declare function unref<T>(ref: MaybeRef<T>): T;
|
|
522
|
+
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
|
|
472
523
|
/**
|
|
473
524
|
* Normalizes values / refs / getters to values.
|
|
474
525
|
* This is similar to {@link unref()}, except that it also normalizes getters.
|
|
@@ -485,7 +536,7 @@ export declare function unref<T>(ref: MaybeRef<T>): T;
|
|
|
485
536
|
* @param source - A getter, an existing ref, or a non-function value.
|
|
486
537
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
487
538
|
*/
|
|
488
|
-
export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
|
|
539
|
+
export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T>): T;
|
|
489
540
|
/**
|
|
490
541
|
* Returns a reactive proxy for the given object.
|
|
491
542
|
*
|
|
@@ -598,55 +649,5 @@ type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseTypes | Ref
|
|
|
598
649
|
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
|
|
599
650
|
} : T;
|
|
600
651
|
|
|
601
|
-
declare const ComputedRefSymbol: unique symbol;
|
|
602
|
-
export interface ComputedRef<T = any> extends WritableComputedRef<T> {
|
|
603
|
-
readonly value: T;
|
|
604
|
-
[ComputedRefSymbol]: true;
|
|
605
|
-
}
|
|
606
|
-
export interface WritableComputedRef<T> extends Ref<T> {
|
|
607
|
-
readonly effect: ReactiveEffect<T>;
|
|
608
|
-
}
|
|
609
|
-
export type ComputedGetter<T> = (...args: any[]) => T;
|
|
610
|
-
export type ComputedSetter<T> = (v: T) => void;
|
|
611
|
-
export interface WritableComputedOptions<T> {
|
|
612
|
-
get: ComputedGetter<T>;
|
|
613
|
-
set: ComputedSetter<T>;
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Takes a getter function and returns a readonly reactive ref object for the
|
|
617
|
-
* returned value from the getter. It can also take an object with get and set
|
|
618
|
-
* functions to create a writable ref object.
|
|
619
|
-
*
|
|
620
|
-
* @example
|
|
621
|
-
* ```js
|
|
622
|
-
* // Creating a readonly computed ref:
|
|
623
|
-
* const count = ref(1)
|
|
624
|
-
* const plusOne = computed(() => count.value + 1)
|
|
625
|
-
*
|
|
626
|
-
* console.log(plusOne.value) // 2
|
|
627
|
-
* plusOne.value++ // error
|
|
628
|
-
* ```
|
|
629
|
-
*
|
|
630
|
-
* ```js
|
|
631
|
-
* // Creating a writable computed ref:
|
|
632
|
-
* const count = ref(1)
|
|
633
|
-
* const plusOne = computed({
|
|
634
|
-
* get: () => count.value + 1,
|
|
635
|
-
* set: (val) => {
|
|
636
|
-
* count.value = val - 1
|
|
637
|
-
* }
|
|
638
|
-
* })
|
|
639
|
-
*
|
|
640
|
-
* plusOne.value = 1
|
|
641
|
-
* console.log(count.value) // 0
|
|
642
|
-
* ```
|
|
643
|
-
*
|
|
644
|
-
* @param getter - Function that produces the next value.
|
|
645
|
-
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
|
|
646
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#computed}
|
|
647
|
-
*/
|
|
648
|
-
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
649
|
-
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
|
|
650
|
-
|
|
651
652
|
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;
|
|
652
653
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>l(t).slice(8,-1),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t){return new v(t)}function y(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function b(t){p&&p.cleanups.push(t)}const R=t=>{const e=new Set(t);return e.w=0,e.n=0,e},m=t=>(t.w&j)>0,S=t=>(t.n&j)>0,k=new WeakMap;let O=0,j=1;const x=30;let P;const E=Symbol(""),M=Symbol("");class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=P,e=A;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=P,P=this,A=!0,j=1<<++O,O<=x?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=j})(this):W(this),this.fn()}finally{O<=x&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];m(i)&&!S(i)?i.delete(t):e[s++]=i,i.w&=~j,i.n&=~j}e.length=s}})(this),j=1<<--O,P=this.parent,A=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){P===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}function V(t,e){t.effect instanceof z&&(t=t.effect.fn);const n=new z(t);e&&(s(n,e),e.scope&&y(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}function N(t){t.effect.stop()}let A=!0;const I=[];function K(){I.push(A),A=!1}function C(){I.push(A),A=!0}function L(){const t=I.pop();A=void 0===t||t}function q(t,e,s){if(A&&P){let e=k.get(t);e||k.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=R()),B(n)}}function B(t,e){let s=!1;O<=x?S(t)||(t.n|=j,s=!m(t)):s=!t.has(P),s&&(t.add(P),P.deps.push(t))}function D(t,e,s,n,i,o){const h=k.get(t);if(!h)return;let a=[];if("clear"===e)a=[...h.values()];else if("length"===s&&r(t)){const t=Number(n);h.forEach(((e,s)=>{("length"===s||!u(s)&&s>=t)&&a.push(e)}))}else switch(void 0!==s&&a.push(h.get(s)),e){case"add":r(t)?_(s)&&a.push(h.get("length")):(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"delete":r(t)||(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"set":c(t)&&a.push(h.get(E))}if(1===a.length)a[0]&&F(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);F(R(t))}}function F(t,e){const s=r(t)?t:[...t];for(const n of s)n.computed&&G(n);for(const n of s)n.computed||G(n)}function G(t,e){(t!==P||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const H=t("__proto__,__v_isRef,__isVue"),J=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),Q=T();function T(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Ct(this);for(let e=0,i=this.length;e<i;e++)q(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Ct)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){K();const s=Ct(this)[e].apply(this,t);return L(),s}})),t}function U(t){const e=Ct(this);return q(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,c=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return c;if("__v_raw"===e&&s===(n?c?Pt:xt:c?jt:Ot).get(t))return t;const o=r(t);if(!n){if(o&&i(Q,e))return Reflect.get(Q,e,s);if("hasOwnProperty"===e)return U}const a=Reflect.get(t,e,s);return(u(e)?J.has(e):H(e))?a:(n||q(t,0,e),c?a:Gt(a)?o&&_(e)?a:a.value:h(a)?n?zt(a):Et(a):a)}}class Y extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(At(c)&&Gt(c)&&!Gt(s))return!1;if(!this._shallow&&(It(s)||At(s)||(c=Ct(c),s=Ct(s)),!r(t)&&Gt(c)&&!Gt(s)))return c.value=s,!0;const o=r(t)&&_(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Ct(n)&&(o?d(s,c)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&D(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&J.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,r(t)?"length":E),Reflect.ownKeys(t)}}class Z extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const $=new Y,tt=new Z,et=new Y(!0),st=new Z(!0),nt=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,s=!1,n=!1){const i=Ct(t=t.__v_raw),r=Ct(e);s||(d(e,r)&&q(i,0,e),q(i,0,r));const{has:c}=it(i),o=n?nt:s?Bt:qt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const s=this.__v_raw,n=Ct(s),i=Ct(t);return e||(d(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ot(t,e=!1){return t=t.__v_raw,!e&&q(Ct(t),0,E),Reflect.get(t,"size",t)}function ut(t){t=Ct(t);const e=Ct(this);return it(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function ht(t,e){e=Ct(e);const s=Ct(this),{has:n,get:i}=it(s);let r=n.call(s,t);r||(t=Ct(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function at(t){const e=Ct(this),{has:s,get:n}=it(e);let i=s.call(e,t);i||(t=Ct(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function lt(){const t=Ct(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Ct(r),o=e?nt:t?Bt:qt;return!t&&q(c,0,E),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function _t(t,e,s){return function(...n){const i=this.__v_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...n),l=s?nt:e?Bt:qt;return!e&&q(r,0,h?M:E),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&this}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},s={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},n={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),s[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),n[i]=_t(i,!0,!0)})),[t,s,e,n]}const[vt,gt,yt,wt]=pt();function bt(t,e){const s=e?t?wt:yt:t?gt:vt;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const Rt={get:bt(!1,!1)},mt={get:bt(!1,!0)},St={get:bt(!0,!1)},kt={get:bt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return At(t)?t:Vt(t,!1,$,Rt,Ot)}function Mt(t){return Vt(t,!1,et,mt,jt)}function zt(t){return Vt(t,!0,tt,St,xt)}function Wt(t){return Vt(t,!0,st,kt,Pt)}function Vt(t,e,s,n,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function Nt(t){return At(t)?Nt(t.__v_raw):!(!t||!t.__v_isReactive)}function At(t){return!(!t||!t.__v_isReadonly)}function It(t){return!(!t||!t.__v_isShallow)}function Kt(t){return Nt(t)||At(t)}function Ct(t){const e=t&&t.__v_raw;return e?Ct(e):t}function Lt(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t}const qt=t=>h(t)?Et(t):t,Bt=t=>h(t)?zt(t):t;function Dt(t){A&&P&&B((t=Ct(t)).dep||(t.dep=R()))}function Ft(t,e){const s=(t=Ct(t)).dep;s&&F(s)}function Gt(t){return!(!t||!0!==t.__v_isRef)}function Ht(t){return Qt(t,!1)}function Jt(t){return Qt(t,!0)}function Qt(t,e){return Gt(t)?t:new Tt(t,e)}class Tt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Dt(this),this._value}set value(t){const e=this.__v_isShallow||It(t)||At(t);t=e?t:Ct(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:qt(t),Ft(this))}}function Ut(t){Ft(t)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return o(t)?t():Xt(t)}const Zt={get:(t,e,s)=>Xt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function $t(t){return Nt(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Dt(this)),(()=>Ft(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function se(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=ce(t,s);return e}class ne{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Ct(this._object),e=this._key,null==(s=k.get(t))?void 0:s.get(e);var t,e,s}}class ie{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function re(t,e,s){return Gt(t)?t:o(t)?new ie(t):h(t)&&arguments.length>1?ce(t,e,s):Ht(t)}function ce(t,e,s){const n=t[e];return Gt(n)?n:new ne(t,e,s)}class oe{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Ct(this);return Dt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,n)}const he=Promise.resolve(),ae=[];let le=!1;const fe=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,le=!1};class _e{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let s=!1,n=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ft(this),n=!1})),le||(le=!0,he.then(fe))}for(const t of this.dep)t.computed instanceof _e&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Dt(this),Ct(this)._get()}}function de(t){return new _e(t)}export{v as EffectScope,E as ITERATE_KEY,z as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,V as effect,g as effectScope,C as enableTracking,w as getCurrentScope,Kt as isProxy,Nt as isReactive,At as isReadonly,Gt as isRef,It as isShallow,Lt as markRaw,b as onScopeDispose,K as pauseTracking,$t as proxyRefs,Et as reactive,zt as readonly,Ht as ref,L as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,N as stop,Ct as toRaw,re as toRef,se as toRefs,Yt as toValue,q as track,D as trigger,Ut as triggerRef,Xt as unref};
|
|
1
|
+
function t(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>l(t).slice(8,-1),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t){return new v(t)}function y(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function b(t){p&&p.cleanups.push(t)}const R=t=>{const e=new Set(t);return e.w=0,e.n=0,e},m=t=>(t.w&j)>0,S=t=>(t.n&j)>0,k=new WeakMap;let O=0,j=1;const x=30;let P;const E=Symbol(""),M=Symbol("");class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=P,e=A;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=P,P=this,A=!0,j=1<<++O,O<=x?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=j})(this):W(this),this.fn()}finally{O<=x&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];m(i)&&!S(i)?i.delete(t):e[s++]=i,i.w&=~j,i.n&=~j}e.length=s}})(this),j=1<<--O,P=this.parent,A=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){P===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}function V(t,e){t.effect instanceof z&&(t=t.effect.fn);const n=new z(t);e&&(s(n,e),e.scope&&y(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}function N(t){t.effect.stop()}let A=!0;const I=[];function K(){I.push(A),A=!1}function C(){I.push(A),A=!0}function L(){const t=I.pop();A=void 0===t||t}function q(t,e,s){if(A&&P){let e=k.get(t);e||k.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=R()),B(n)}}function B(t,e){let s=!1;O<=x?S(t)||(t.n|=j,s=!m(t)):s=!t.has(P),s&&(t.add(P),P.deps.push(t))}function D(t,e,s,n,i,o){const h=k.get(t);if(!h)return;let a=[];if("clear"===e)a=[...h.values()];else if("length"===s&&r(t)){const t=Number(n);h.forEach(((e,s)=>{("length"===s||!u(s)&&s>=t)&&a.push(e)}))}else switch(void 0!==s&&a.push(h.get(s)),e){case"add":r(t)?_(s)&&a.push(h.get("length")):(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"delete":r(t)||(a.push(h.get(E)),c(t)&&a.push(h.get(M)));break;case"set":c(t)&&a.push(h.get(E))}if(1===a.length)a[0]&&F(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);F(R(t))}}function F(t,e){const s=r(t)?t:[...t];for(const n of s)n.computed&&G(n);for(const n of s)n.computed||G(n)}function G(t,e){(t!==P||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const H=t("__proto__,__v_isRef,__isVue"),J=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),Q=T();function T(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Ct(this);for(let e=0,i=this.length;e<i;e++)q(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Ct)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){K();const s=Ct(this)[e].apply(this,t);return L(),s}})),t}function U(t){const e=Ct(this);return q(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,c=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return c;if("__v_raw"===e&&s===(n?c?Pt:xt:c?jt:Ot).get(t))return t;const o=r(t);if(!n){if(o&&i(Q,e))return Reflect.get(Q,e,s);if("hasOwnProperty"===e)return U}const a=Reflect.get(t,e,s);return(u(e)?J.has(e):H(e))?a:(n||q(t,0,e),c?a:Gt(a)?o&&_(e)?a:a.value:h(a)?n?zt(a):Et(a):a)}}class Y extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(At(c)&&Gt(c)&&!Gt(s))return!1;if(!this._shallow&&(It(s)||At(s)||(c=Ct(c),s=Ct(s)),!r(t)&&Gt(c)&&!Gt(s)))return c.value=s,!0;const o=r(t)&&_(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Ct(n)&&(o?d(s,c)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&D(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&J.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,r(t)?"length":E),Reflect.ownKeys(t)}}class Z extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const $=new Y,tt=new Z,et=new Y(!0),st=new Z(!0),nt=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,s=!1,n=!1){const i=Ct(t=t.__v_raw),r=Ct(e);s||(d(e,r)&&q(i,0,e),q(i,0,r));const{has:c}=it(i),o=n?nt:s?Bt:qt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const s=this.__v_raw,n=Ct(s),i=Ct(t);return e||(d(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ot(t,e=!1){return t=t.__v_raw,!e&&q(Ct(t),0,E),Reflect.get(t,"size",t)}function ut(t){t=Ct(t);const e=Ct(this);return it(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function ht(t,e){e=Ct(e);const s=Ct(this),{has:n,get:i}=it(s);let r=n.call(s,t);r||(t=Ct(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function at(t){const e=Ct(this),{has:s,get:n}=it(e);let i=s.call(e,t);i||(t=Ct(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function lt(){const t=Ct(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Ct(r),o=e?nt:t?Bt:qt;return!t&&q(c,0,E),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function _t(t,e,s){return function(...n){const i=this.__v_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...n),l=s?nt:e?Bt:qt;return!e&&q(r,0,h?M:E),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},s={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},n={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),s[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),n[i]=_t(i,!0,!0)})),[t,s,e,n]}const[vt,gt,yt,wt]=pt();function bt(t,e){const s=e?t?wt:yt:t?gt:vt;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const Rt={get:bt(!1,!1)},mt={get:bt(!1,!0)},St={get:bt(!0,!1)},kt={get:bt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return At(t)?t:Vt(t,!1,$,Rt,Ot)}function Mt(t){return Vt(t,!1,et,mt,jt)}function zt(t){return Vt(t,!0,tt,St,xt)}function Wt(t){return Vt(t,!0,st,kt,Pt)}function Vt(t,e,s,n,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function Nt(t){return At(t)?Nt(t.__v_raw):!(!t||!t.__v_isReactive)}function At(t){return!(!t||!t.__v_isReadonly)}function It(t){return!(!t||!t.__v_isShallow)}function Kt(t){return Nt(t)||At(t)}function Ct(t){const e=t&&t.__v_raw;return e?Ct(e):t}function Lt(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t}const qt=t=>h(t)?Et(t):t,Bt=t=>h(t)?zt(t):t;function Dt(t){A&&P&&B((t=Ct(t)).dep||(t.dep=R()))}function Ft(t,e){const s=(t=Ct(t)).dep;s&&F(s)}function Gt(t){return!(!t||!0!==t.__v_isRef)}function Ht(t){return Qt(t,!1)}function Jt(t){return Qt(t,!0)}function Qt(t,e){return Gt(t)?t:new Tt(t,e)}class Tt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Dt(this),this._value}set value(t){const e=this.__v_isShallow||It(t)||At(t);t=e?t:Ct(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:qt(t),Ft(this))}}function Ut(t){Ft(t)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return o(t)?t():Xt(t)}const Zt={get:(t,e,s)=>Xt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function $t(t){return Nt(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Dt(this)),(()=>Ft(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function se(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=ce(t,s);return e}class ne{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Ct(this._object),e=this._key,null==(s=k.get(t))?void 0:s.get(e);var t,e,s}}class ie{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function re(t,e,s){return Gt(t)?t:o(t)?new ie(t):h(t)&&arguments.length>1?ce(t,e,s):Ht(t)}function ce(t,e,s){const n=t[e];return Gt(n)?n:new ne(t,e,s)}class oe{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Ct(this);return Dt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,n)}const he=Promise.resolve(),ae=[];let le=!1;const fe=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,le=!1};class _e{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let s=!1,n=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ft(this),n=!1})),le||(le=!0,he.then(fe))}for(const t of this.dep)t.computed instanceof _e&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Dt(this),Ct(this)._get()}}function de(t){return new _e(t)}export{v as EffectScope,E as ITERATE_KEY,z as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,V as effect,g as effectScope,C as enableTracking,w as getCurrentScope,Kt as isProxy,Nt as isReactive,At as isReadonly,Gt as isRef,It as isShallow,Lt as markRaw,b as onScopeDispose,K as pauseTracking,$t as proxyRefs,Et as reactive,zt as readonly,Ht as ref,L as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,N as stop,Ct as toRaw,re as toRef,se as toRefs,Yt as toValue,q as track,D as trigger,Ut as triggerRef,Xt as unref};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueReactivity=function(t){"use strict";function e(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const s=()=>{},n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>f(t).slice(8,-1),d=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let v;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=v,!t&&v&&(this.index=(v.scopes||(v.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=v;try{return v=this,t()}finally{v=e}}}on(){v=this}off(){v=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t,e=v){e&&e.active&&e.effects.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&k)>0,b=t=>(t.n&k)>0,m=new WeakMap;let S=0,k=1;const O=30;let j;const x=Symbol(""),E=Symbol("");class P{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=j,e=V;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,V=!0,k=1<<++S,S<=O?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=k})(this):M(this),this.fn()}finally{S<=O&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];R(i)&&!b(i)?i.delete(t):e[s++]=i,i.w&=~k,i.n&=~k}e.length=s}})(this),k=1<<--S,j=this.parent,V=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let V=!0;const z=[];function W(){z.push(V),V=!1}function A(){const t=z.pop();V=void 0===t||t}function N(t,e,s){if(V&&j){let e=m.get(t);e||m.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=w()),T(n)}}function T(t,e){let s=!1;S<=O?b(t)||(t.n|=k,s=!R(t)):s=!t.has(j),s&&(t.add(j),j.deps.push(t))}function C(t,e,s,n,i,r){const u=m.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||!a(s)&&s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(u.get(s)),e){case"add":c(t)?d(s)&&h.push(u.get("length")):(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"delete":c(t)||(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"set":o(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&I(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);I(w(t))}}function I(t,e){const s=c(t)?t:[...t];for(const n of s)n.computed&&K(n);for(const n of s)n.computed||K(n)}function K(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=e("__proto__,__v_isRef,__isVue"),L=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=q();function q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Mt(this);for(let e=0,i=this.length;e<i;e++)N(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Mt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){W();const s=Mt(this)[e].apply(this,t);return A(),s}})),t}function B(t){const e=Mt(this);return N(e,0,t),e.hasOwnProperty(t)}class F{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,i=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return i;if("__v_raw"===e&&s===(n?i?St:mt:i?bt:Rt).get(t))return t;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return B}const u=Reflect.get(t,e,s);return(a(e)?L.has(e):D(e))?u:(n||N(t,0,e),i?u:Nt(u)?o&&d(e)?u:u.value:h(u)?n?Ot(u):kt(u):u)}}class G extends F{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(Et(i)&&Nt(i)&&!Nt(s))return!1;if(!this._shallow&&(Pt(s)||Et(s)||(i=Mt(i),s=Mt(s)),!c(t)&&Nt(i)&&!Nt(s)))return i.value=s,!0;const o=c(t)&&d(e)?Number(e)<t.length:r(t,e),u=Reflect.set(t,e,s,n);return t===Mt(n)&&(o?p(s,i)&&C(t,"set",e,s):C(t,"add",e,s)),u}deleteProperty(t,e){const s=r(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&C(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return a(e)&&L.has(e)||N(t,0,e),s}ownKeys(t){return N(t,0,c(t)?"length":x),Reflect.ownKeys(t)}}class H extends F{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const J=new G,Q=new H,U=new G(!0),X=new H(!0),Z=t=>t,$=t=>Reflect.getPrototypeOf(t);function tt(t,e,s=!1,n=!1){const i=Mt(t=t.__v_raw),r=Mt(e);s||(p(e,r)&&N(i,0,e),N(i,0,r));const{has:c}=$(i),o=n?Z:s?zt:Vt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function et(t,e=!1){const s=this.__v_raw,n=Mt(s),i=Mt(t);return e||(p(t,i)&&N(n,0,t),N(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function st(t,e=!1){return t=t.__v_raw,!e&&N(Mt(t),0,x),Reflect.get(t,"size",t)}function nt(t){t=Mt(t);const e=Mt(this);return $(e).has.call(e,t)||(e.add(t),C(e,"add",t,t)),this}function it(t,e){e=Mt(e);const s=Mt(this),{has:n,get:i}=$(s);let r=n.call(s,t);r||(t=Mt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&C(s,"set",t,e):C(s,"add",t,e),this}function rt(t){const e=Mt(this),{has:s,get:n}=$(e);let i=s.call(e,t);i||(t=Mt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&C(e,"delete",t,void 0),r}function ct(){const t=Mt(this),e=0!==t.size,s=t.clear();return e&&C(t,"clear",void 0,void 0),s}function ot(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Mt(r),o=e?Z:t?zt:Vt;return!t&&N(c,0,x),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function ut(t,e,s){return function(...n){const i=this.__v_raw,r=Mt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...n),l=s?Z:e?zt:Vt;return!e&&N(r,0,a?E:x),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function at(t){return function(...e){return"delete"!==t&&this}}function ht(){const t={get(t){return tt(this,t)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!1)},e={get(t){return tt(this,t,!1,!0)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!0)},s={get(t){return tt(this,t,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!1)},n={get(t){return tt(this,t,!0,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ut(i,!1,!1),s[i]=ut(i,!0,!1),e[i]=ut(i,!1,!0),n[i]=ut(i,!0,!0)})),[t,s,e,n]}const[lt,ft,_t,dt]=ht();function pt(t,e){const s=e?t?dt:_t:t?ft:lt;return(e,n,i)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(r(s,n)&&n in e?s:e,n,i)}const vt={get:pt(!1,!1)},gt={get:pt(!1,!0)},yt={get:pt(!0,!1)},wt={get:pt(!0,!0)},Rt=new WeakMap,bt=new WeakMap,mt=new WeakMap,St=new WeakMap;function kt(t){return Et(t)?t:jt(t,!1,J,vt,Rt)}function Ot(t){return jt(t,!0,Q,yt,mt)}function jt(t,e,s,n,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function xt(t){return Et(t)?xt(t.__v_raw):!(!t||!t.__v_isReactive)}function Et(t){return!(!t||!t.__v_isReadonly)}function Pt(t){return!(!t||!t.__v_isShallow)}function Mt(t){const e=t&&t.__v_raw;return e?Mt(e):t}const Vt=t=>h(t)?kt(t):t,zt=t=>h(t)?Ot(t):t;function Wt(t){V&&j&&T((t=Mt(t)).dep||(t.dep=w()))}function At(t,e){const s=(t=Mt(t)).dep;s&&I(s)}function Nt(t){return!(!t||!0!==t.__v_isRef)}function Tt(t){return Ct(t,!1)}function Ct(t,e){return Nt(t)?t:new It(t,e)}class It{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Mt(t),this._value=e?t:Vt(t)}get value(){return Wt(this),this._value}set value(t){const e=this.__v_isShallow||Pt(t)||Et(t);t=e?t:Mt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Vt(t),At(this))}}function Kt(t){return Nt(t)?t.value:t}const Dt={get:(t,e,s)=>Kt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Nt(i)&&!Nt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Lt{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Wt(this)),(()=>At(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Mt(this._object),e=this._key,null==(s=m.get(t))?void 0:s.get(e);var t,e,s}}class qt{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function Bt(t,e,s){const n=t[e];return Nt(n)?n:new Yt(t,e,s)}class Ft{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,At(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Mt(this);return Wt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Gt=Promise.resolve(),Ht=[];let Jt=!1;const Qt=()=>{for(let t=0;t<Ht.length;t++)Ht[t]();Ht.length=0,Jt=!1};class Ut{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let s=!1,n=!1;this.effect=new P(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,Ht.push((()=>{this.effect.active&&this._get()!==t&&At(this),n=!1})),Jt||(Jt=!0,Gt.then(Qt))}for(const t of this.dep)t.computed instanceof Ut&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Wt(this),Mt(this)._get()}}return t.EffectScope=g,t.ITERATE_KEY=x,t.ReactiveEffect=P,t.computed=function(t,e,n=!1){let i,r;const c=u(t);return c?(i=t,r=s):(i=t.get,r=t.set),new Ft(i,r,c||!r,n)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Ut(t)},t.effect=function(t,e){t.effect instanceof P&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&y(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i},t.effectScope=function(t){return new g(t)},t.enableTracking=function(){z.push(V),V=!0},t.getCurrentScope=function(){return v},t.isProxy=function(t){return xt(t)||Et(t)},t.isReactive=xt,t.isReadonly=Et,t.isRef=Nt,t.isShallow=Pt,t.markRaw=function(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){v&&v.cleanups.push(t)},t.pauseTracking=W,t.proxyRefs=function(t){return xt(t)?t:new Proxy(t,Dt)},t.reactive=kt,t.readonly=Ot,t.ref=Tt,t.resetTracking=A,t.shallowReactive=function(t){return jt(t,!1,U,gt,bt)},t.shallowReadonly=function(t){return jt(t,!0,X,wt,St)},t.shallowRef=function(t){return Ct(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Mt,t.toRef=function(t,e,s){return Nt(t)?t:u(t)?new qt(t):h(t)&&arguments.length>1?Bt(t,e,s):Tt(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const s in t)e[s]=Bt(t,s);return e},t.toValue=function(t){return u(t)?t():Kt(t)},t.track=N,t.trigger=C,t.triggerRef=function(t){At(t)},t.unref=Kt,t}({});
|
|
1
|
+
var VueReactivity=function(t){"use strict";function e(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const s=()=>{},n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>f(t).slice(8,-1),d=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let v;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=v,!t&&v&&(this.index=(v.scopes||(v.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=v;try{return v=this,t()}finally{v=e}}}on(){v=this}off(){v=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t,e=v){e&&e.active&&e.effects.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&k)>0,b=t=>(t.n&k)>0,m=new WeakMap;let S=0,k=1;const O=30;let j;const x=Symbol(""),E=Symbol("");class P{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=j,e=V;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,V=!0,k=1<<++S,S<=O?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=k})(this):M(this),this.fn()}finally{S<=O&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];R(i)&&!b(i)?i.delete(t):e[s++]=i,i.w&=~k,i.n&=~k}e.length=s}})(this),k=1<<--S,j=this.parent,V=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let V=!0;const z=[];function W(){z.push(V),V=!1}function A(){const t=z.pop();V=void 0===t||t}function N(t,e,s){if(V&&j){let e=m.get(t);e||m.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=w()),T(n)}}function T(t,e){let s=!1;S<=O?b(t)||(t.n|=k,s=!R(t)):s=!t.has(j),s&&(t.add(j),j.deps.push(t))}function C(t,e,s,n,i,r){const u=m.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||!a(s)&&s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(u.get(s)),e){case"add":c(t)?d(s)&&h.push(u.get("length")):(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"delete":c(t)||(h.push(u.get(x)),o(t)&&h.push(u.get(E)));break;case"set":o(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&I(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);I(w(t))}}function I(t,e){const s=c(t)?t:[...t];for(const n of s)n.computed&&K(n);for(const n of s)n.computed||K(n)}function K(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=e("__proto__,__v_isRef,__isVue"),L=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=q();function q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Mt(this);for(let e=0,i=this.length;e<i;e++)N(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Mt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){W();const s=Mt(this)[e].apply(this,t);return A(),s}})),t}function B(t){const e=Mt(this);return N(e,0,t),e.hasOwnProperty(t)}class F{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,i=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return i;if("__v_raw"===e&&s===(n?i?St:mt:i?bt:Rt).get(t))return t;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return B}const u=Reflect.get(t,e,s);return(a(e)?L.has(e):D(e))?u:(n||N(t,0,e),i?u:Nt(u)?o&&d(e)?u:u.value:h(u)?n?Ot(u):kt(u):u)}}class G extends F{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(Et(i)&&Nt(i)&&!Nt(s))return!1;if(!this._shallow&&(Pt(s)||Et(s)||(i=Mt(i),s=Mt(s)),!c(t)&&Nt(i)&&!Nt(s)))return i.value=s,!0;const o=c(t)&&d(e)?Number(e)<t.length:r(t,e),u=Reflect.set(t,e,s,n);return t===Mt(n)&&(o?p(s,i)&&C(t,"set",e,s):C(t,"add",e,s)),u}deleteProperty(t,e){const s=r(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&C(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return a(e)&&L.has(e)||N(t,0,e),s}ownKeys(t){return N(t,0,c(t)?"length":x),Reflect.ownKeys(t)}}class H extends F{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const J=new G,Q=new H,U=new G(!0),X=new H(!0),Z=t=>t,$=t=>Reflect.getPrototypeOf(t);function tt(t,e,s=!1,n=!1){const i=Mt(t=t.__v_raw),r=Mt(e);s||(p(e,r)&&N(i,0,e),N(i,0,r));const{has:c}=$(i),o=n?Z:s?zt:Vt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function et(t,e=!1){const s=this.__v_raw,n=Mt(s),i=Mt(t);return e||(p(t,i)&&N(n,0,t),N(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function st(t,e=!1){return t=t.__v_raw,!e&&N(Mt(t),0,x),Reflect.get(t,"size",t)}function nt(t){t=Mt(t);const e=Mt(this);return $(e).has.call(e,t)||(e.add(t),C(e,"add",t,t)),this}function it(t,e){e=Mt(e);const s=Mt(this),{has:n,get:i}=$(s);let r=n.call(s,t);r||(t=Mt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&C(s,"set",t,e):C(s,"add",t,e),this}function rt(t){const e=Mt(this),{has:s,get:n}=$(e);let i=s.call(e,t);i||(t=Mt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&C(e,"delete",t,void 0),r}function ct(){const t=Mt(this),e=0!==t.size,s=t.clear();return e&&C(t,"clear",void 0,void 0),s}function ot(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Mt(r),o=e?Z:t?zt:Vt;return!t&&N(c,0,x),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function ut(t,e,s){return function(...n){const i=this.__v_raw,r=Mt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...n),l=s?Z:e?zt:Vt;return!e&&N(r,0,a?E:x),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function at(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function ht(){const t={get(t){return tt(this,t)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!1)},e={get(t){return tt(this,t,!1,!0)},get size(){return st(this)},has:et,add:nt,set:it,delete:rt,clear:ct,forEach:ot(!1,!0)},s={get(t){return tt(this,t,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!1)},n={get(t){return tt(this,t,!0,!0)},get size(){return st(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ut(i,!1,!1),s[i]=ut(i,!0,!1),e[i]=ut(i,!1,!0),n[i]=ut(i,!0,!0)})),[t,s,e,n]}const[lt,ft,_t,dt]=ht();function pt(t,e){const s=e?t?dt:_t:t?ft:lt;return(e,n,i)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(r(s,n)&&n in e?s:e,n,i)}const vt={get:pt(!1,!1)},gt={get:pt(!1,!0)},yt={get:pt(!0,!1)},wt={get:pt(!0,!0)},Rt=new WeakMap,bt=new WeakMap,mt=new WeakMap,St=new WeakMap;function kt(t){return Et(t)?t:jt(t,!1,J,vt,Rt)}function Ot(t){return jt(t,!0,Q,yt,mt)}function jt(t,e,s,n,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function xt(t){return Et(t)?xt(t.__v_raw):!(!t||!t.__v_isReactive)}function Et(t){return!(!t||!t.__v_isReadonly)}function Pt(t){return!(!t||!t.__v_isShallow)}function Mt(t){const e=t&&t.__v_raw;return e?Mt(e):t}const Vt=t=>h(t)?kt(t):t,zt=t=>h(t)?Ot(t):t;function Wt(t){V&&j&&T((t=Mt(t)).dep||(t.dep=w()))}function At(t,e){const s=(t=Mt(t)).dep;s&&I(s)}function Nt(t){return!(!t||!0!==t.__v_isRef)}function Tt(t){return Ct(t,!1)}function Ct(t,e){return Nt(t)?t:new It(t,e)}class It{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Mt(t),this._value=e?t:Vt(t)}get value(){return Wt(this),this._value}set value(t){const e=this.__v_isShallow||Pt(t)||Et(t);t=e?t:Mt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Vt(t),At(this))}}function Kt(t){return Nt(t)?t.value:t}const Dt={get:(t,e,s)=>Kt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Nt(i)&&!Nt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Lt{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Wt(this)),(()=>At(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Mt(this._object),e=this._key,null==(s=m.get(t))?void 0:s.get(e);var t,e,s}}class qt{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function Bt(t,e,s){const n=t[e];return Nt(n)?n:new Yt(t,e,s)}class Ft{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,At(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Mt(this);return Wt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Gt=Promise.resolve(),Ht=[];let Jt=!1;const Qt=()=>{for(let t=0;t<Ht.length;t++)Ht[t]();Ht.length=0,Jt=!1};class Ut{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let s=!1,n=!1;this.effect=new P(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,Ht.push((()=>{this.effect.active&&this._get()!==t&&At(this),n=!1})),Jt||(Jt=!0,Gt.then(Qt))}for(const t of this.dep)t.computed instanceof Ut&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Wt(this),Mt(this)._get()}}return t.EffectScope=g,t.ITERATE_KEY=x,t.ReactiveEffect=P,t.computed=function(t,e,n=!1){let i,r;const c=u(t);return c?(i=t,r=s):(i=t.get,r=t.set),new Ft(i,r,c||!r,n)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Ut(t)},t.effect=function(t,e){t.effect instanceof P&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&y(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i},t.effectScope=function(t){return new g(t)},t.enableTracking=function(){z.push(V),V=!0},t.getCurrentScope=function(){return v},t.isProxy=function(t){return xt(t)||Et(t)},t.isReactive=xt,t.isReadonly=Et,t.isRef=Nt,t.isShallow=Pt,t.markRaw=function(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){v&&v.cleanups.push(t)},t.pauseTracking=W,t.proxyRefs=function(t){return xt(t)?t:new Proxy(t,Dt)},t.reactive=kt,t.readonly=Ot,t.ref=Tt,t.resetTracking=A,t.shallowReactive=function(t){return jt(t,!1,U,gt,bt)},t.shallowReadonly=function(t){return jt(t,!0,X,wt,St)},t.shallowRef=function(t){return Ct(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Mt,t.toRef=function(t,e,s){return Nt(t)?t:u(t)?new qt(t):h(t)&&arguments.length>1?Bt(t,e,s):Tt(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const s in t)e[s]=Bt(t,s);return e},t.toValue=function(t){return u(t)?t():Kt(t)},t.track=N,t.trigger=C,t.triggerRef=function(t){At(t)},t.unref=Kt,t}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/reactivity",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.9",
|
|
4
4
|
"description": "@vue/reactivity",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/reactivity.esm-bundler.js",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/reactivity#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@vue/shared": "3.3.
|
|
39
|
+
"@vue/shared": "3.3.9"
|
|
40
40
|
}
|
|
41
41
|
}
|