@vue/reactivity 3.6.0-alpha.7 → 3.6.0-beta.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.
- package/dist/reactivity.cjs.js +1778 -1881
- package/dist/reactivity.cjs.prod.js +1667 -1686
- package/dist/reactivity.d.ts +633 -633
- package/dist/reactivity.esm-browser.js +1812 -1895
- package/dist/reactivity.esm-browser.prod.js +5 -4
- package/dist/reactivity.esm-bundler.js +1776 -1889
- package/dist/reactivity.global.js +2049 -2135
- package/dist/reactivity.global.prod.js +5 -4
- package/package.json +2 -2
package/dist/reactivity.d.ts
CHANGED
|
@@ -1,790 +1,790 @@
|
|
|
1
|
-
import { IfAny } from
|
|
1
|
+
import { IfAny } from "@vue/shared";
|
|
2
2
|
|
|
3
|
+
//#region temp/packages/reactivity/src/constants.d.ts
|
|
3
4
|
export declare enum TrackOpTypes {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
GET = "get",
|
|
6
|
+
HAS = "has",
|
|
7
|
+
ITERATE = "iterate"
|
|
7
8
|
}
|
|
8
9
|
export declare enum TriggerOpTypes {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
SET = "set",
|
|
11
|
+
ADD = "add",
|
|
12
|
+
DELETE = "delete",
|
|
13
|
+
CLEAR = "clear"
|
|
13
14
|
}
|
|
14
|
-
export declare enum ReactiveFlags
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export declare enum ReactiveFlags {
|
|
16
|
+
SKIP = "__v_skip",
|
|
17
|
+
IS_REACTIVE = "__v_isReactive",
|
|
18
|
+
IS_READONLY = "__v_isReadonly",
|
|
19
|
+
IS_SHALLOW = "__v_isShallow",
|
|
20
|
+
RAW = "__v_raw",
|
|
21
|
+
IS_REF = "__v_isRef"
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region temp/packages/reactivity/src/effectScope.d.ts
|
|
23
25
|
export declare class EffectScope implements ReactiveNode {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
deps: Link | undefined;
|
|
27
|
+
depsTail: Link | undefined;
|
|
28
|
+
subs: Link | undefined;
|
|
29
|
+
subsTail: Link | undefined;
|
|
30
|
+
flags: number;
|
|
31
|
+
constructor(detached?: boolean);
|
|
32
|
+
get active(): boolean;
|
|
33
|
+
pause(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Resumes the effect scope, including all child scopes and effects.
|
|
36
|
+
*/
|
|
37
|
+
resume(): void;
|
|
38
|
+
run<T>(fn: () => T): T | undefined;
|
|
39
|
+
stop(): void;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
43
|
+
* computed and watchers) created within it so that these effects can be
|
|
44
|
+
* disposed together. For detailed use cases of this API, please consult its
|
|
45
|
+
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
46
|
+
*
|
|
47
|
+
* @param detached - Can be used to create a "detached" effect scope.
|
|
48
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
49
|
+
*/
|
|
48
50
|
export declare function effectScope(detached?: boolean): EffectScope;
|
|
49
51
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
* Returns the current active effect scope if there is one.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
55
|
+
*/
|
|
54
56
|
export declare function getCurrentScope(): EffectScope | undefined;
|
|
55
57
|
export declare function setCurrentScope(scope?: EffectScope): EffectScope | undefined;
|
|
56
58
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
* Registers a dispose callback on the current active effect scope. The
|
|
60
|
+
* callback will be invoked when the associated effect scope is stopped.
|
|
61
|
+
*
|
|
62
|
+
* @param fn - The callback function to attach to the scope's cleanup.
|
|
63
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
64
|
+
*/
|
|
63
65
|
export declare function onScopeDispose(fn: () => void, failSilently?: boolean): void;
|
|
64
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region temp/packages/reactivity/src/system.d.ts
|
|
65
68
|
interface ReactiveNode {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
deps?: Link;
|
|
70
|
+
depsTail?: Link;
|
|
71
|
+
subs?: Link;
|
|
72
|
+
subsTail?: Link;
|
|
73
|
+
flags: ReactiveFlags$1;
|
|
71
74
|
}
|
|
72
75
|
interface Link {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
version: number;
|
|
77
|
+
dep: ReactiveNode | ComputedRefImpl | ReactiveEffect | EffectScope;
|
|
78
|
+
sub: ReactiveNode | ComputedRefImpl | ReactiveEffect | EffectScope;
|
|
79
|
+
prevSub: Link | undefined;
|
|
80
|
+
nextSub: Link | undefined;
|
|
81
|
+
prevDep: Link | undefined;
|
|
82
|
+
nextDep: Link | undefined;
|
|
80
83
|
}
|
|
81
|
-
declare const enum ReactiveFlags {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
declare const enum ReactiveFlags$1 {
|
|
85
|
+
None = 0,
|
|
86
|
+
Mutable = 1,
|
|
87
|
+
Watching = 2,
|
|
88
|
+
RecursedCheck = 4,
|
|
89
|
+
Recursed = 8,
|
|
90
|
+
Dirty = 16,
|
|
91
|
+
Pending = 32
|
|
89
92
|
}
|
|
90
|
-
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region temp/packages/reactivity/src/effect.d.ts
|
|
91
95
|
export type EffectScheduler = (...args: any[]) => any;
|
|
92
96
|
export type DebuggerEvent = {
|
|
93
|
-
|
|
97
|
+
effect: ReactiveNode;
|
|
94
98
|
} & DebuggerEventExtraInfo;
|
|
95
99
|
export type DebuggerEventExtraInfo = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
target: object;
|
|
101
|
+
type: TrackOpTypes | TriggerOpTypes;
|
|
102
|
+
key: any;
|
|
103
|
+
newValue?: any;
|
|
104
|
+
oldValue?: any;
|
|
105
|
+
oldTarget?: Map<any, any> | Set<any>;
|
|
102
106
|
};
|
|
103
107
|
export interface DebuggerOptions {
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
109
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
106
110
|
}
|
|
107
111
|
export interface ReactiveEffectOptions extends DebuggerOptions {
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
scheduler?: EffectScheduler;
|
|
113
|
+
onStop?: () => void;
|
|
110
114
|
}
|
|
111
115
|
export interface ReactiveEffectRunner<T = any> {
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
(): T;
|
|
117
|
+
effect: ReactiveEffect;
|
|
114
118
|
}
|
|
115
119
|
export declare enum EffectFlags {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
/**
|
|
121
|
+
* ReactiveEffect only
|
|
122
|
+
*/
|
|
123
|
+
ALLOW_RECURSE = 128,
|
|
124
|
+
PAUSED = 256,
|
|
125
|
+
STOP = 1024
|
|
122
126
|
}
|
|
123
127
|
export declare class ReactiveEffect<T = any> implements ReactiveEffectOptions, ReactiveNode {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
deps: Link | undefined;
|
|
129
|
+
depsTail: Link | undefined;
|
|
130
|
+
subs: Link | undefined;
|
|
131
|
+
subsTail: Link | undefined;
|
|
132
|
+
flags: number;
|
|
133
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
134
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
135
|
+
fn(): T;
|
|
136
|
+
constructor(fn?: () => T);
|
|
137
|
+
get active(): boolean;
|
|
138
|
+
pause(): void;
|
|
139
|
+
resume(): void;
|
|
140
|
+
notify(): void;
|
|
141
|
+
run(): T;
|
|
142
|
+
stop(): void;
|
|
143
|
+
get dirty(): boolean;
|
|
140
144
|
}
|
|
141
145
|
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner<T>;
|
|
142
146
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
* Stops the effect associated with the given runner.
|
|
148
|
+
*
|
|
149
|
+
* @param runner - Association with the effect to stop tracking.
|
|
150
|
+
*/
|
|
147
151
|
export declare function stop(runner: ReactiveEffectRunner): void;
|
|
148
152
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
* Temporarily pauses tracking.
|
|
154
|
+
*/
|
|
151
155
|
export declare function pauseTracking(): void;
|
|
152
156
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
* Re-enables effect tracking (if it was paused).
|
|
158
|
+
*/
|
|
155
159
|
export declare function enableTracking(): void;
|
|
156
160
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
* Resets the previous global effect tracking state.
|
|
162
|
+
*/
|
|
159
163
|
export declare function resetTracking(): void;
|
|
160
164
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
* Registers a cleanup function for the current active effect.
|
|
166
|
+
* The cleanup function is called right before the next effect run, or when the
|
|
167
|
+
* effect is stopped.
|
|
168
|
+
*
|
|
169
|
+
* Throws a warning if there is no current active effect. The warning can be
|
|
170
|
+
* suppressed by passing `true` to the second argument.
|
|
171
|
+
*
|
|
172
|
+
* @param fn - the cleanup function to be registered
|
|
173
|
+
* @param failSilently - if `true`, will not throw warning when called without
|
|
174
|
+
* an active effect.
|
|
175
|
+
*/
|
|
172
176
|
export declare function onEffectCleanup(fn: () => void, failSilently?: boolean): void;
|
|
173
|
-
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region temp/packages/reactivity/src/computed.d.ts
|
|
174
179
|
declare const ComputedRefSymbol: unique symbol;
|
|
175
180
|
declare const WritableComputedRefSymbol: unique symbol;
|
|
176
181
|
interface BaseComputedRef<T, S = T> extends Ref<T, S> {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
[ComputedRefSymbol]: true;
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated computed no longer uses effect
|
|
185
|
+
*/
|
|
186
|
+
effect: ComputedRefImpl;
|
|
182
187
|
}
|
|
183
188
|
export interface ComputedRef<T = any> extends BaseComputedRef<T> {
|
|
184
|
-
|
|
189
|
+
readonly value: T;
|
|
185
190
|
}
|
|
186
191
|
export interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
|
|
187
|
-
|
|
192
|
+
[WritableComputedRefSymbol]: true;
|
|
188
193
|
}
|
|
189
194
|
export type ComputedGetter<T> = (oldValue?: T) => T;
|
|
190
195
|
export type ComputedSetter<T> = (newValue: T) => void;
|
|
191
196
|
export interface WritableComputedOptions<T, S = T> {
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
get: ComputedGetter<T>;
|
|
198
|
+
set: ComputedSetter<S>;
|
|
194
199
|
}
|
|
195
200
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
202
|
+
* the main vue package
|
|
203
|
+
*/
|
|
199
204
|
export declare class ComputedRefImpl<T = any> implements ReactiveNode {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
fn: ComputedGetter<T>;
|
|
206
|
+
private readonly setter;
|
|
207
|
+
subs: Link | undefined;
|
|
208
|
+
subsTail: Link | undefined;
|
|
209
|
+
deps: Link | undefined;
|
|
210
|
+
depsTail: Link | undefined;
|
|
211
|
+
flags: ReactiveFlags$1;
|
|
212
|
+
get effect(): this;
|
|
213
|
+
get dep(): ReactiveNode;
|
|
214
|
+
onTrack?: (event: DebuggerEvent) => void;
|
|
215
|
+
onTrigger?: (event: DebuggerEvent) => void;
|
|
216
|
+
constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined);
|
|
217
|
+
get value(): T;
|
|
218
|
+
set value(newValue: T);
|
|
219
|
+
update(): boolean;
|
|
215
220
|
}
|
|
216
221
|
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
222
|
+
* Takes a getter function and returns a readonly reactive ref object for the
|
|
223
|
+
* returned value from the getter. It can also take an object with get and set
|
|
224
|
+
* functions to create a writable ref object.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```js
|
|
228
|
+
* // Creating a readonly computed ref:
|
|
229
|
+
* const count = ref(1)
|
|
230
|
+
* const plusOne = computed(() => count.value + 1)
|
|
231
|
+
*
|
|
232
|
+
* console.log(plusOne.value) // 2
|
|
233
|
+
* plusOne.value++ // error
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* ```js
|
|
237
|
+
* // Creating a writable computed ref:
|
|
238
|
+
* const count = ref(1)
|
|
239
|
+
* const plusOne = computed({
|
|
240
|
+
* get: () => count.value + 1,
|
|
241
|
+
* set: (val) => {
|
|
242
|
+
* count.value = val - 1
|
|
243
|
+
* }
|
|
244
|
+
* })
|
|
245
|
+
*
|
|
246
|
+
* plusOne.value = 1
|
|
247
|
+
* console.log(count.value) // 0
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @param getter - Function that produces the next value.
|
|
251
|
+
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
|
|
252
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#computed}
|
|
253
|
+
*/
|
|
249
254
|
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
250
255
|
export declare function computed<T, S = T>(options: WritableComputedOptions<T, S>, debugOptions?: DebuggerOptions): WritableComputedRef<T, S>;
|
|
251
|
-
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region temp/packages/reactivity/src/reactive.d.ts
|
|
252
258
|
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
|
|
253
259
|
declare const ReactiveMarkerSymbol: unique symbol;
|
|
254
260
|
export interface ReactiveMarker {
|
|
255
|
-
|
|
261
|
+
[ReactiveMarkerSymbol]?: void;
|
|
256
262
|
}
|
|
257
263
|
export type Reactive<T> = UnwrapNestedRefs<T> & (T extends readonly any[] ? ReactiveMarker : {});
|
|
258
264
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
265
|
+
* Returns a reactive proxy of the object.
|
|
266
|
+
*
|
|
267
|
+
* The reactive conversion is "deep": it affects all nested properties. A
|
|
268
|
+
* reactive object also deeply unwraps any properties that are refs while
|
|
269
|
+
* maintaining reactivity.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```js
|
|
273
|
+
* const obj = reactive({ count: 0 })
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @param target - The source object.
|
|
277
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#reactive}
|
|
278
|
+
*/
|
|
273
279
|
export declare function reactive<T extends object>(target: T): Reactive<T>;
|
|
274
|
-
declare
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
280
|
+
declare class ShallowReactiveBrandClass {
|
|
281
|
+
private __shallowReactiveBrand?;
|
|
282
|
+
}
|
|
283
|
+
type ShallowReactiveBrand = ShallowReactiveBrandClass;
|
|
284
|
+
export type ShallowReactive<T> = T & ShallowReactiveBrand;
|
|
285
|
+
/**
|
|
286
|
+
* Shallow version of {@link reactive}.
|
|
287
|
+
*
|
|
288
|
+
* Unlike {@link reactive}, there is no deep conversion: only root-level
|
|
289
|
+
* properties are reactive for a shallow reactive object. Property values are
|
|
290
|
+
* stored and exposed as-is - this also means properties with ref values will
|
|
291
|
+
* not be automatically unwrapped.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```js
|
|
295
|
+
* const state = shallowReactive({
|
|
296
|
+
* foo: 1,
|
|
297
|
+
* nested: {
|
|
298
|
+
* bar: 2
|
|
299
|
+
* }
|
|
300
|
+
* })
|
|
301
|
+
*
|
|
302
|
+
* // mutating state's own properties is reactive
|
|
303
|
+
* state.foo++
|
|
304
|
+
*
|
|
305
|
+
* // ...but does not convert nested objects
|
|
306
|
+
* isReactive(state.nested) // false
|
|
307
|
+
*
|
|
308
|
+
* // NOT reactive
|
|
309
|
+
* state.nested.bar++
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @param target - The source object.
|
|
313
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
314
|
+
*/
|
|
308
315
|
export declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
|
|
309
316
|
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
310
317
|
type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
311
|
-
export type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends WeakSet<infer U> ? WeakSet<DeepReadonly<U>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends Ref<infer U, unknown> ? Readonly<Ref<DeepReadonly<U>>> : T extends {} ? {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
342
|
-
*/
|
|
318
|
+
export type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends WeakSet<infer U> ? WeakSet<DeepReadonly<U>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends Ref<infer U, unknown> ? Readonly<Ref<DeepReadonly<U>>> : T extends {} ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : Readonly<T>;
|
|
319
|
+
/**
|
|
320
|
+
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
321
|
+
* the original.
|
|
322
|
+
*
|
|
323
|
+
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
324
|
+
* well. It also has the same ref-unwrapping behavior as {@link reactive},
|
|
325
|
+
* except the unwrapped values will also be made readonly.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```js
|
|
329
|
+
* const original = reactive({ count: 0 })
|
|
330
|
+
*
|
|
331
|
+
* const copy = readonly(original)
|
|
332
|
+
*
|
|
333
|
+
* watchEffect(() => {
|
|
334
|
+
* // works for reactivity tracking
|
|
335
|
+
* console.log(copy.count)
|
|
336
|
+
* })
|
|
337
|
+
*
|
|
338
|
+
* // mutating original will trigger watchers relying on the copy
|
|
339
|
+
* original.count++
|
|
340
|
+
*
|
|
341
|
+
* // mutating the copy will fail and result in a warning
|
|
342
|
+
* copy.count++ // warning!
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @param target - The source object.
|
|
346
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
347
|
+
*/
|
|
343
348
|
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
|
|
344
349
|
/**
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
350
|
+
* Shallow version of {@link readonly}.
|
|
351
|
+
*
|
|
352
|
+
* Unlike {@link readonly}, there is no deep conversion: only root-level
|
|
353
|
+
* properties are made readonly. Property values are stored and exposed as-is -
|
|
354
|
+
* this also means properties with ref values will not be automatically
|
|
355
|
+
* unwrapped.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```js
|
|
359
|
+
* const state = shallowReadonly({
|
|
360
|
+
* foo: 1,
|
|
361
|
+
* nested: {
|
|
362
|
+
* bar: 2
|
|
363
|
+
* }
|
|
364
|
+
* })
|
|
365
|
+
*
|
|
366
|
+
* // mutating state's own properties will fail
|
|
367
|
+
* state.foo++
|
|
368
|
+
*
|
|
369
|
+
* // ...but works on nested objects
|
|
370
|
+
* isReadonly(state.nested) // false
|
|
371
|
+
*
|
|
372
|
+
* // works
|
|
373
|
+
* state.nested.bar++
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @param target - The source object.
|
|
377
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
378
|
+
*/
|
|
374
379
|
export declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
|
|
375
380
|
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
381
|
+
* Checks if an object is a proxy created by {@link reactive} or
|
|
382
|
+
* {@link shallowReactive} (or {@link ref} in some cases).
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```js
|
|
386
|
+
* isReactive(reactive({})) // => true
|
|
387
|
+
* isReactive(readonly(reactive({}))) // => true
|
|
388
|
+
* isReactive(ref({}).value) // => true
|
|
389
|
+
* isReactive(readonly(ref({})).value) // => true
|
|
390
|
+
* isReactive(ref(true)) // => false
|
|
391
|
+
* isReactive(shallowRef({}).value) // => false
|
|
392
|
+
* isReactive(shallowReactive({})) // => true
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @param value - The value to check.
|
|
396
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
397
|
+
*/
|
|
393
398
|
export declare function isReactive(value: unknown): boolean;
|
|
394
399
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
* Checks whether the passed value is a readonly object. The properties of a
|
|
401
|
+
* readonly object can change, but they can't be assigned directly via the
|
|
402
|
+
* passed object.
|
|
403
|
+
*
|
|
404
|
+
* The proxies created by {@link readonly} and {@link shallowReadonly} are
|
|
405
|
+
* both considered readonly, as is a computed ref without a set function.
|
|
406
|
+
*
|
|
407
|
+
* @param value - The value to check.
|
|
408
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
409
|
+
*/
|
|
405
410
|
export declare function isReadonly(value: unknown): boolean;
|
|
406
411
|
export declare function isShallow(value: unknown): boolean;
|
|
407
412
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
413
|
+
* Checks if an object is a proxy created by {@link reactive},
|
|
414
|
+
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
415
|
+
*
|
|
416
|
+
* @param value - The value to check.
|
|
417
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
418
|
+
*/
|
|
414
419
|
export declare function isProxy(value: any): boolean;
|
|
415
420
|
/**
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
421
|
+
* Returns the raw, original object of a Vue-created proxy.
|
|
422
|
+
*
|
|
423
|
+
* `toRaw()` can return the original object from proxies created by
|
|
424
|
+
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
425
|
+
* {@link shallowReadonly}.
|
|
426
|
+
*
|
|
427
|
+
* This is an escape hatch that can be used to temporarily read without
|
|
428
|
+
* incurring proxy access / tracking overhead or write without triggering
|
|
429
|
+
* changes. It is **not** recommended to hold a persistent reference to the
|
|
430
|
+
* original object. Use with caution.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```js
|
|
434
|
+
* const foo = {}
|
|
435
|
+
* const reactiveFoo = reactive(foo)
|
|
436
|
+
*
|
|
437
|
+
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @param observed - The object for which the "raw" value is requested.
|
|
441
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
442
|
+
*/
|
|
438
443
|
export declare function toRaw<T>(observed: T): T;
|
|
439
444
|
export type Raw<T> = T & {
|
|
440
|
-
|
|
445
|
+
[RawSymbol]?: true;
|
|
441
446
|
};
|
|
442
447
|
/**
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
448
|
+
* Marks an object so that it will never be converted to a proxy. Returns the
|
|
449
|
+
* object itself.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```js
|
|
453
|
+
* const foo = markRaw({})
|
|
454
|
+
* console.log(isReactive(reactive(foo))) // false
|
|
455
|
+
*
|
|
456
|
+
* // also works when nested inside other reactive objects
|
|
457
|
+
* const bar = reactive({ foo })
|
|
458
|
+
* console.log(isReactive(bar.foo)) // false
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* **Warning:** `markRaw()` together with the shallow APIs such as
|
|
462
|
+
* {@link shallowReactive} allow you to selectively opt-out of the default
|
|
463
|
+
* deep reactive/readonly conversion and embed raw, non-proxied objects in your
|
|
464
|
+
* state graph.
|
|
465
|
+
*
|
|
466
|
+
* @param value - The object to be marked as "raw".
|
|
467
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
|
|
468
|
+
*/
|
|
464
469
|
export declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
465
470
|
/**
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
471
|
+
* Returns a reactive proxy of the given value (if possible).
|
|
472
|
+
*
|
|
473
|
+
* If the given value is not an object, the original value itself is returned.
|
|
474
|
+
*
|
|
475
|
+
* @param value - The value for which a reactive proxy shall be created.
|
|
476
|
+
*/
|
|
472
477
|
export declare const toReactive: <T extends unknown>(value: T) => T;
|
|
473
478
|
/**
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
479
|
+
* Returns a readonly proxy of the given value (if possible).
|
|
480
|
+
*
|
|
481
|
+
* If the given value is not an object, the original value itself is returned.
|
|
482
|
+
*
|
|
483
|
+
* @param value - The value for which a readonly proxy shall be created.
|
|
484
|
+
*/
|
|
480
485
|
export declare const toReadonly: <T extends unknown>(value: T) => DeepReadonly<T>;
|
|
481
|
-
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region temp/packages/reactivity/src/ref.d.ts
|
|
482
488
|
declare const RefSymbol: unique symbol;
|
|
483
489
|
declare const RawSymbol: unique symbol;
|
|
484
490
|
export interface Ref<T = any, S = T> {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
491
|
+
get value(): T;
|
|
492
|
+
set value(_: S);
|
|
493
|
+
/**
|
|
494
|
+
* Type differentiator only.
|
|
495
|
+
* We need this to be in public d.ts but don't want it to show up in IDE
|
|
496
|
+
* autocomplete, so we use a private Symbol instead.
|
|
497
|
+
*/
|
|
498
|
+
[RefSymbol]: true;
|
|
493
499
|
}
|
|
494
500
|
/**
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
501
|
+
* Checks if a value is a ref object.
|
|
502
|
+
*
|
|
503
|
+
* @param r - The value to inspect.
|
|
504
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isref}
|
|
505
|
+
*/
|
|
500
506
|
export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
|
|
501
507
|
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
+
* Takes an inner value and returns a reactive and mutable ref object, which
|
|
509
|
+
* has a single property `.value` that points to the inner value.
|
|
510
|
+
*
|
|
511
|
+
* @param value - The object to wrap in the ref.
|
|
512
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
|
|
513
|
+
*/
|
|
508
514
|
export declare function ref<T>(value: T): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
|
|
509
515
|
export declare function ref<T = any>(): Ref<T | undefined>;
|
|
510
516
|
declare const ShallowRefMarker: unique symbol;
|
|
511
517
|
export type ShallowRef<T = any, S = T> = Ref<T, S> & {
|
|
512
|
-
|
|
518
|
+
[ShallowRefMarker]?: true;
|
|
513
519
|
};
|
|
514
520
|
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
521
|
+
* Shallow version of {@link ref}.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```js
|
|
525
|
+
* const state = shallowRef({ count: 1 })
|
|
526
|
+
*
|
|
527
|
+
* // does NOT trigger change
|
|
528
|
+
* state.value.count = 2
|
|
529
|
+
*
|
|
530
|
+
* // does trigger change
|
|
531
|
+
* state.value = { count: 2 }
|
|
532
|
+
* ```
|
|
533
|
+
*
|
|
534
|
+
* @param value - The "inner value" for the shallow ref.
|
|
535
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
|
|
536
|
+
*/
|
|
531
537
|
export declare function shallowRef<T>(value: T): Ref extends T ? T extends Ref ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>;
|
|
532
538
|
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
533
539
|
/**
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
540
|
+
* Force trigger effects that depends on a shallow ref. This is typically used
|
|
541
|
+
* after making deep mutations to the inner value of a shallow ref.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```js
|
|
545
|
+
* const shallow = shallowRef({
|
|
546
|
+
* greet: 'Hello, world'
|
|
547
|
+
* })
|
|
548
|
+
*
|
|
549
|
+
* // Logs "Hello, world" once for the first run-through
|
|
550
|
+
* watchEffect(() => {
|
|
551
|
+
* console.log(shallow.value.greet)
|
|
552
|
+
* })
|
|
553
|
+
*
|
|
554
|
+
* // This won't trigger the effect because the ref is shallow
|
|
555
|
+
* shallow.value.greet = 'Hello, universe'
|
|
556
|
+
*
|
|
557
|
+
* // Logs "Hello, universe"
|
|
558
|
+
* triggerRef(shallow)
|
|
559
|
+
* ```
|
|
560
|
+
*
|
|
561
|
+
* @param ref - The ref whose tied effects shall be executed.
|
|
562
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
|
|
563
|
+
*/
|
|
558
564
|
export declare function triggerRef(ref: Ref): void;
|
|
559
565
|
export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
|
|
560
566
|
export type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
|
|
561
567
|
/**
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
568
|
+
* Returns the inner value if the argument is a ref, otherwise return the
|
|
569
|
+
* argument itself. This is a sugar function for
|
|
570
|
+
* `val = isRef(val) ? val.value : val`.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```js
|
|
574
|
+
* function useFoo(x: number | Ref<number>) {
|
|
575
|
+
* const unwrapped = unref(x)
|
|
576
|
+
* // unwrapped is guaranteed to be number now
|
|
577
|
+
* }
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* @param ref - Ref or plain value to be converted into the plain value.
|
|
581
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
582
|
+
*/
|
|
577
583
|
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
|
|
578
584
|
/**
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
585
|
+
* Normalizes values / refs / getters to values.
|
|
586
|
+
* This is similar to {@link unref}, except that it also normalizes getters.
|
|
587
|
+
* If the argument is a getter, it will be invoked and its return value will
|
|
588
|
+
* be returned.
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* ```js
|
|
592
|
+
* toValue(1) // 1
|
|
593
|
+
* toValue(ref(1)) // 1
|
|
594
|
+
* toValue(() => 1) // 1
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* @param source - A getter, an existing ref, or a non-function value.
|
|
598
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
599
|
+
*/
|
|
594
600
|
export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
|
|
595
601
|
/**
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
602
|
+
* Returns a proxy for the given object that shallowly unwraps properties that
|
|
603
|
+
* are refs. If the object already is reactive, it's returned as-is. If not, a
|
|
604
|
+
* new reactive proxy is created.
|
|
605
|
+
*
|
|
606
|
+
* @param objectWithRefs - Either an already-reactive object or a simple object
|
|
607
|
+
* that contains refs.
|
|
608
|
+
*/
|
|
603
609
|
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
604
|
-
export type CustomRefFactory<T> = (track: () => void, trigger: () => void) => {
|
|
605
|
-
|
|
606
|
-
|
|
610
|
+
export type CustomRefFactory<T, S = T> = (track: () => void, trigger: () => void) => {
|
|
611
|
+
get: () => T;
|
|
612
|
+
set: (value: S) => void;
|
|
607
613
|
};
|
|
608
614
|
/**
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
|
|
616
|
-
export type ToRefs<T = any> = {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
615
|
+
* Creates a customized ref with explicit control over its dependency tracking
|
|
616
|
+
* and updates triggering.
|
|
617
|
+
*
|
|
618
|
+
* @param factory - The function that receives the `track` and `trigger` callbacks.
|
|
619
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
|
|
620
|
+
*/
|
|
621
|
+
export declare function customRef<T, S = T>(factory: CustomRefFactory<T, S>): Ref<T, S>;
|
|
622
|
+
export type ToRefs<T = any> = { [K in keyof T]: ToRef<T[K]> };
|
|
623
|
+
type ArrayStringKey<T> = T extends readonly any[] ? number extends T["length"] ? `${number}` : never : never;
|
|
624
|
+
type ToRefKey<T> = keyof T | ArrayStringKey<T>;
|
|
625
|
+
type ToRefValue<T extends object, K extends ToRefKey<T>> = K extends keyof T ? T[K] : T extends readonly (infer V)[] ? K extends ArrayStringKey<T> ? V : never : never;
|
|
626
|
+
/**
|
|
627
|
+
* Converts a reactive object to a plain object where each property of the
|
|
628
|
+
* resulting object is a ref pointing to the corresponding property of the
|
|
629
|
+
* original object. Each individual ref is created using {@link toRef}.
|
|
630
|
+
*
|
|
631
|
+
* @param object - Reactive object to be made into an object of linked refs.
|
|
632
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
633
|
+
*/
|
|
627
634
|
export declare function toRefs<T extends object>(object: T): ToRefs<T>;
|
|
628
635
|
export type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>;
|
|
629
636
|
/**
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
export declare function toRef<T>(value: T): T extends () => infer R ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>;
|
|
673
|
-
export declare function toRef<T extends object, K extends
|
|
674
|
-
export declare function toRef<T extends object, K extends
|
|
675
|
-
/**
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
export interface RefUnwrapBailTypes {
|
|
689
|
-
}
|
|
690
|
-
export type ShallowUnwrapRef<T> = {
|
|
691
|
-
[K in keyof T]: DistributeRef<T[K]>;
|
|
692
|
-
};
|
|
637
|
+
* Used to normalize values / refs / getters into refs.
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* ```js
|
|
641
|
+
* // returns existing refs as-is
|
|
642
|
+
* toRef(existingRef)
|
|
643
|
+
*
|
|
644
|
+
* // creates a ref that calls the getter on .value access
|
|
645
|
+
* toRef(() => props.foo)
|
|
646
|
+
*
|
|
647
|
+
* // creates normal refs from non-function values
|
|
648
|
+
* // equivalent to ref(1)
|
|
649
|
+
* toRef(1)
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* Can also be used to create a ref for a property on a source reactive object.
|
|
653
|
+
* The created ref is synced with its source property: mutating the source
|
|
654
|
+
* property will update the ref, and vice-versa.
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```js
|
|
658
|
+
* const state = reactive({
|
|
659
|
+
* foo: 1,
|
|
660
|
+
* bar: 2
|
|
661
|
+
* })
|
|
662
|
+
*
|
|
663
|
+
* const fooRef = toRef(state, 'foo')
|
|
664
|
+
*
|
|
665
|
+
* // mutating the ref updates the original
|
|
666
|
+
* fooRef.value++
|
|
667
|
+
* console.log(state.foo) // 2
|
|
668
|
+
*
|
|
669
|
+
* // mutating the original also updates the ref
|
|
670
|
+
* state.foo++
|
|
671
|
+
* console.log(fooRef.value) // 3
|
|
672
|
+
* ```
|
|
673
|
+
*
|
|
674
|
+
* @param source - A getter, an existing ref, a non-function value, or a
|
|
675
|
+
* reactive object to create a property ref from.
|
|
676
|
+
* @param [key] - (optional) Name of the property in the reactive object.
|
|
677
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
|
|
678
|
+
*/
|
|
679
|
+
export declare function toRef<T>(value: T): T extends (() => infer R) ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>;
|
|
680
|
+
export declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K): ToRef<ToRefValue<T, K>>;
|
|
681
|
+
export declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K, defaultValue: ToRefValue<T, K>): ToRef<Exclude<ToRefValue<T, K>, undefined>>;
|
|
682
|
+
/**
|
|
683
|
+
* This is a special exported interface for other packages to declare
|
|
684
|
+
* additional types that should bail out for ref unwrapping. For example
|
|
685
|
+
* \@vue/runtime-dom can declare it like so in its d.ts:
|
|
686
|
+
*
|
|
687
|
+
* ``` ts
|
|
688
|
+
* declare module '@vue/reactivity' {
|
|
689
|
+
* export interface RefUnwrapBailTypes {
|
|
690
|
+
* runtimeDOMBailTypes: Node | Window
|
|
691
|
+
* }
|
|
692
|
+
* }
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
export interface RefUnwrapBailTypes {}
|
|
696
|
+
export type ShallowUnwrapRef<T> = T extends ShallowReactiveBrand ? T : { [K in keyof T]: DistributeRef<T[K]> };
|
|
693
697
|
type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T;
|
|
694
698
|
export type UnwrapRef<T> = T extends ShallowRef<infer V, unknown> ? V : T extends Ref<infer V, unknown> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;
|
|
695
699
|
type UnwrapRefSimple<T> = T extends Builtin | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
|
|
696
|
-
|
|
697
|
-
} ? T : T extends Map<infer K, infer V> ? Map<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Map<any, any>>> : T extends WeakMap<infer K, infer V> ? WeakMap<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakMap<any, any>>> : T extends Set<infer V> ? Set<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Set<any>>> : T extends WeakSet<infer V> ? WeakSet<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakSet<any>>> : T extends ReadonlyArray<any> ? {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
[ShallowReactiveMarker]?: never;
|
|
701
|
-
} ? {
|
|
702
|
-
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
|
|
703
|
-
} : T;
|
|
704
|
-
|
|
700
|
+
[RawSymbol]?: true;
|
|
701
|
+
} ? T : T extends ShallowReactiveBrand ? T : T extends Map<infer K, infer V> ? Map<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Map<any, any>>> : T extends WeakMap<infer K, infer V> ? WeakMap<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakMap<any, any>>> : T extends Set<infer V> ? Set<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Set<any>>> : T extends WeakSet<infer V> ? WeakSet<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakSet<any>>> : T extends ReadonlyArray<any> ? { [K in keyof T]: UnwrapRefSimple<T[K]> } : T extends object ? { [P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]> } : T;
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region temp/packages/reactivity/src/dep.d.ts
|
|
705
704
|
export declare const ITERATE_KEY: unique symbol;
|
|
706
705
|
export declare const MAP_KEY_ITERATE_KEY: unique symbol;
|
|
707
706
|
export declare const ARRAY_ITERATE_KEY: unique symbol;
|
|
708
707
|
/**
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
708
|
+
* Tracks access to a reactive property.
|
|
709
|
+
*
|
|
710
|
+
* This will check which effect is running at the moment and record it as dep
|
|
711
|
+
* which records all effects that depend on the reactive property.
|
|
712
|
+
*
|
|
713
|
+
* @param target - Object holding the reactive property.
|
|
714
|
+
* @param type - Defines the type of access to the reactive property.
|
|
715
|
+
* @param key - Identifier of the reactive property to track.
|
|
716
|
+
*/
|
|
718
717
|
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
719
718
|
/**
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
719
|
+
* Finds all deps associated with the target (or a specific property) and
|
|
720
|
+
* triggers the effects stored within.
|
|
721
|
+
*
|
|
722
|
+
* @param target - The reactive object.
|
|
723
|
+
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
724
|
+
* @param key - Can be used to target a specific reactive property in the target object.
|
|
725
|
+
*/
|
|
727
726
|
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
728
|
-
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region temp/packages/reactivity/src/arrayInstrumentations.d.ts
|
|
729
729
|
/**
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
730
|
+
* Track array iteration and return:
|
|
731
|
+
* - if input is reactive: a cloned raw array with reactive values
|
|
732
|
+
* - if input is non-reactive or shallowReactive: the original raw array
|
|
733
|
+
*/
|
|
734
734
|
export declare function reactiveReadArray<T>(array: T[]): T[];
|
|
735
735
|
/**
|
|
736
|
-
|
|
737
|
-
|
|
736
|
+
* Track array iteration and return raw array
|
|
737
|
+
*/
|
|
738
738
|
export declare function shallowReadArray<T>(arr: T[]): T[];
|
|
739
|
-
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region temp/packages/reactivity/src/watch.d.ts
|
|
740
741
|
export declare enum WatchErrorCodes {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
742
|
+
WATCH_GETTER = 2,
|
|
743
|
+
WATCH_CALLBACK = 3,
|
|
744
|
+
WATCH_CLEANUP = 4
|
|
744
745
|
}
|
|
745
746
|
export type WatchEffect = (onCleanup: OnCleanup) => void;
|
|
746
747
|
export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T);
|
|
747
748
|
export type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onCleanup: OnCleanup) => any;
|
|
748
749
|
export type OnCleanup = (cleanupFn: () => void) => void;
|
|
749
750
|
export interface WatchOptions<Immediate = boolean> extends DebuggerOptions {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
751
|
+
immediate?: Immediate;
|
|
752
|
+
deep?: boolean | number;
|
|
753
|
+
once?: boolean;
|
|
754
|
+
onWarn?: (msg: string, ...args: any[]) => void;
|
|
754
755
|
}
|
|
755
756
|
export type WatchStopHandle = () => void;
|
|
756
757
|
export interface WatchHandle extends WatchStopHandle {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
pause: () => void;
|
|
759
|
+
resume: () => void;
|
|
760
|
+
stop: () => void;
|
|
760
761
|
}
|
|
761
762
|
/**
|
|
762
|
-
|
|
763
|
-
|
|
763
|
+
* Returns the current active effect if there is one.
|
|
764
|
+
*/
|
|
764
765
|
export declare function getCurrentWatcher(): ReactiveEffect<any> | undefined;
|
|
765
766
|
/**
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
767
|
+
* Registers a cleanup callback on the current active effect. This
|
|
768
|
+
* registered cleanup callback will be invoked right before the
|
|
769
|
+
* associated effect re-runs.
|
|
770
|
+
*
|
|
771
|
+
* @param cleanupFn - The callback function to attach to the effect's cleanup.
|
|
772
|
+
* @param failSilently - if `true`, will not throw warning when called without
|
|
773
|
+
* an active effect.
|
|
774
|
+
* @param owner - The effect that this cleanup function should be attached to.
|
|
775
|
+
* By default, the current active effect.
|
|
776
|
+
*/
|
|
776
777
|
export declare function onWatcherCleanup(cleanupFn: () => void, failSilently?: boolean, owner?: WatcherEffect | undefined): void;
|
|
777
778
|
export declare class WatcherEffect extends ReactiveEffect {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
779
|
+
cb?: WatchCallback<any, any> | null | undefined;
|
|
780
|
+
options: WatchOptions;
|
|
781
|
+
forceTrigger: boolean;
|
|
782
|
+
isMultiSource: boolean;
|
|
783
|
+
oldValue: any;
|
|
784
|
+
boundCleanup: typeof onWatcherCleanup;
|
|
785
|
+
constructor(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback<any, any> | null | undefined, options?: WatchOptions);
|
|
786
|
+
run(initialRun?: boolean): void;
|
|
786
787
|
}
|
|
787
788
|
export declare function watch(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback | null, options?: WatchOptions): WatchHandle;
|
|
788
789
|
export declare function traverse(value: unknown, depth?: number, seen?: Map<unknown, number>): unknown;
|
|
789
|
-
|
|
790
|
-
export { ReactiveFlags$1 as ReactiveFlags, };
|
|
790
|
+
//#endregion
|