@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.
@@ -1,790 +1,790 @@
1
- import { IfAny } from '@vue/shared';
1
+ import { IfAny } from "@vue/shared";
2
2
 
3
+ //#region temp/packages/reactivity/src/constants.d.ts
3
4
  export declare enum TrackOpTypes {
4
- GET = "get",
5
- HAS = "has",
6
- ITERATE = "iterate"
5
+ GET = "get",
6
+ HAS = "has",
7
+ ITERATE = "iterate"
7
8
  }
8
9
  export declare enum TriggerOpTypes {
9
- SET = "set",
10
- ADD = "add",
11
- DELETE = "delete",
12
- CLEAR = "clear"
10
+ SET = "set",
11
+ ADD = "add",
12
+ DELETE = "delete",
13
+ CLEAR = "clear"
13
14
  }
14
- export declare enum ReactiveFlags$1 {
15
- SKIP = "__v_skip",
16
- IS_REACTIVE = "__v_isReactive",
17
- IS_READONLY = "__v_isReadonly",
18
- IS_SHALLOW = "__v_isShallow",
19
- RAW = "__v_raw",
20
- IS_REF = "__v_isRef"
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
- deps: Link | undefined;
25
- depsTail: Link | undefined;
26
- subs: Link | undefined;
27
- subsTail: Link | undefined;
28
- flags: number;
29
- constructor(detached?: boolean);
30
- get active(): boolean;
31
- pause(): void;
32
- /**
33
- * Resumes the effect scope, including all child scopes and effects.
34
- */
35
- resume(): void;
36
- run<T>(fn: () => T): T | undefined;
37
- stop(): void;
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
- * Creates an effect scope object which can capture the reactive effects (i.e.
41
- * computed and watchers) created within it so that these effects can be
42
- * disposed together. For detailed use cases of this API, please consult its
43
- * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
44
- *
45
- * @param detached - Can be used to create a "detached" effect scope.
46
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
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
- * Returns the current active effect scope if there is one.
51
- *
52
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
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
- * Registers a dispose callback on the current active effect scope. The
58
- * callback will be invoked when the associated effect scope is stopped.
59
- *
60
- * @param fn - The callback function to attach to the scope's cleanup.
61
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
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
- deps?: Link;
67
- depsTail?: Link;
68
- subs?: Link;
69
- subsTail?: Link;
70
- flags: ReactiveFlags;
69
+ deps?: Link;
70
+ depsTail?: Link;
71
+ subs?: Link;
72
+ subsTail?: Link;
73
+ flags: ReactiveFlags$1;
71
74
  }
72
75
  interface Link {
73
- version: number;
74
- dep: ReactiveNode | ComputedRefImpl | ReactiveEffect | EffectScope;
75
- sub: ReactiveNode | ComputedRefImpl | ReactiveEffect | EffectScope;
76
- prevSub: Link | undefined;
77
- nextSub: Link | undefined;
78
- prevDep: Link | undefined;
79
- nextDep: Link | undefined;
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
- None = 0,
83
- Mutable = 1,
84
- Watching = 2,
85
- RecursedCheck = 4,
86
- Recursed = 8,
87
- Dirty = 16,
88
- Pending = 32
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
- effect: ReactiveNode;
97
+ effect: ReactiveNode;
94
98
  } & DebuggerEventExtraInfo;
95
99
  export type DebuggerEventExtraInfo = {
96
- target: object;
97
- type: TrackOpTypes | TriggerOpTypes;
98
- key: any;
99
- newValue?: any;
100
- oldValue?: any;
101
- oldTarget?: Map<any, any> | Set<any>;
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
- onTrack?: (event: DebuggerEvent) => void;
105
- onTrigger?: (event: DebuggerEvent) => void;
108
+ onTrack?: (event: DebuggerEvent) => void;
109
+ onTrigger?: (event: DebuggerEvent) => void;
106
110
  }
107
111
  export interface ReactiveEffectOptions extends DebuggerOptions {
108
- scheduler?: EffectScheduler;
109
- onStop?: () => void;
112
+ scheduler?: EffectScheduler;
113
+ onStop?: () => void;
110
114
  }
111
115
  export interface ReactiveEffectRunner<T = any> {
112
- (): T;
113
- effect: ReactiveEffect;
116
+ (): T;
117
+ effect: ReactiveEffect;
114
118
  }
115
119
  export declare enum EffectFlags {
116
- /**
117
- * ReactiveEffect only
118
- */
119
- ALLOW_RECURSE = 128,
120
- PAUSED = 256,
121
- STOP = 1024
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
- deps: Link | undefined;
125
- depsTail: Link | undefined;
126
- subs: Link | undefined;
127
- subsTail: Link | undefined;
128
- flags: number;
129
- onTrack?: (event: DebuggerEvent) => void;
130
- onTrigger?: (event: DebuggerEvent) => void;
131
- fn(): T;
132
- constructor(fn?: () => T);
133
- get active(): boolean;
134
- pause(): void;
135
- resume(): void;
136
- notify(): void;
137
- run(): T;
138
- stop(): void;
139
- get dirty(): boolean;
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
- * Stops the effect associated with the given runner.
144
- *
145
- * @param runner - Association with the effect to stop tracking.
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
- * Temporarily pauses tracking.
150
- */
153
+ * Temporarily pauses tracking.
154
+ */
151
155
  export declare function pauseTracking(): void;
152
156
  /**
153
- * Re-enables effect tracking (if it was paused).
154
- */
157
+ * Re-enables effect tracking (if it was paused).
158
+ */
155
159
  export declare function enableTracking(): void;
156
160
  /**
157
- * Resets the previous global effect tracking state.
158
- */
161
+ * Resets the previous global effect tracking state.
162
+ */
159
163
  export declare function resetTracking(): void;
160
164
  /**
161
- * Registers a cleanup function for the current active effect.
162
- * The cleanup function is called right before the next effect run, or when the
163
- * effect is stopped.
164
- *
165
- * Throws a warning if there is no current active effect. The warning can be
166
- * suppressed by passing `true` to the second argument.
167
- *
168
- * @param fn - the cleanup function to be registered
169
- * @param failSilently - if `true`, will not throw warning when called without
170
- * an active effect.
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
- [ComputedRefSymbol]: true;
178
- /**
179
- * @deprecated computed no longer uses effect
180
- */
181
- effect: ComputedRefImpl;
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
- readonly value: T;
189
+ readonly value: T;
185
190
  }
186
191
  export interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
187
- [WritableComputedRefSymbol]: true;
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
- get: ComputedGetter<T>;
193
- set: ComputedSetter<S>;
197
+ get: ComputedGetter<T>;
198
+ set: ComputedSetter<S>;
194
199
  }
195
200
  /**
196
- * @private exported by @vue/reactivity for Vue core use, but not exported from
197
- * the main vue package
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
- fn: ComputedGetter<T>;
201
- private readonly setter;
202
- subs: Link | undefined;
203
- subsTail: Link | undefined;
204
- deps: Link | undefined;
205
- depsTail: Link | undefined;
206
- flags: ReactiveFlags;
207
- get effect(): this;
208
- get dep(): ReactiveNode;
209
- onTrack?: (event: DebuggerEvent) => void;
210
- onTrigger?: (event: DebuggerEvent) => void;
211
- constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined);
212
- get value(): T;
213
- set value(newValue: T);
214
- update(): boolean;
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
- * Takes a getter function and returns a readonly reactive ref object for the
218
- * returned value from the getter. It can also take an object with get and set
219
- * functions to create a writable ref object.
220
- *
221
- * @example
222
- * ```js
223
- * // Creating a readonly computed ref:
224
- * const count = ref(1)
225
- * const plusOne = computed(() => count.value + 1)
226
- *
227
- * console.log(plusOne.value) // 2
228
- * plusOne.value++ // error
229
- * ```
230
- *
231
- * ```js
232
- * // Creating a writable computed ref:
233
- * const count = ref(1)
234
- * const plusOne = computed({
235
- * get: () => count.value + 1,
236
- * set: (val) => {
237
- * count.value = val - 1
238
- * }
239
- * })
240
- *
241
- * plusOne.value = 1
242
- * console.log(count.value) // 0
243
- * ```
244
- *
245
- * @param getter - Function that produces the next value.
246
- * @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
247
- * @see {@link https://vuejs.org/api/reactivity-core.html#computed}
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
- [ReactiveMarkerSymbol]?: void;
261
+ [ReactiveMarkerSymbol]?: void;
256
262
  }
257
263
  export type Reactive<T> = UnwrapNestedRefs<T> & (T extends readonly any[] ? ReactiveMarker : {});
258
264
  /**
259
- * Returns a reactive proxy of the object.
260
- *
261
- * The reactive conversion is "deep": it affects all nested properties. A
262
- * reactive object also deeply unwraps any properties that are refs while
263
- * maintaining reactivity.
264
- *
265
- * @example
266
- * ```js
267
- * const obj = reactive({ count: 0 })
268
- * ```
269
- *
270
- * @param target - The source object.
271
- * @see {@link https://vuejs.org/api/reactivity-core.html#reactive}
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 const ShallowReactiveMarker: unique symbol;
275
- export type ShallowReactive<T> = T & {
276
- [ShallowReactiveMarker]?: true;
277
- };
278
- /**
279
- * Shallow version of {@link reactive}.
280
- *
281
- * Unlike {@link reactive}, there is no deep conversion: only root-level
282
- * properties are reactive for a shallow reactive object. Property values are
283
- * stored and exposed as-is - this also means properties with ref values will
284
- * not be automatically unwrapped.
285
- *
286
- * @example
287
- * ```js
288
- * const state = shallowReactive({
289
- * foo: 1,
290
- * nested: {
291
- * bar: 2
292
- * }
293
- * })
294
- *
295
- * // mutating state's own properties is reactive
296
- * state.foo++
297
- *
298
- * // ...but does not convert nested objects
299
- * isReactive(state.nested) // false
300
- *
301
- * // NOT reactive
302
- * state.nested.bar++
303
- * ```
304
- *
305
- * @param target - The source object.
306
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
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
- readonly [K in keyof T]: DeepReadonly<T[K]>;
313
- } : Readonly<T>;
314
- /**
315
- * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
316
- * the original.
317
- *
318
- * A readonly proxy is deep: any nested property accessed will be readonly as
319
- * well. It also has the same ref-unwrapping behavior as {@link reactive},
320
- * except the unwrapped values will also be made readonly.
321
- *
322
- * @example
323
- * ```js
324
- * const original = reactive({ count: 0 })
325
- *
326
- * const copy = readonly(original)
327
- *
328
- * watchEffect(() => {
329
- * // works for reactivity tracking
330
- * console.log(copy.count)
331
- * })
332
- *
333
- * // mutating original will trigger watchers relying on the copy
334
- * original.count++
335
- *
336
- * // mutating the copy will fail and result in a warning
337
- * copy.count++ // warning!
338
- * ```
339
- *
340
- * @param target - The source object.
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
- * Shallow version of {@link readonly}.
346
- *
347
- * Unlike {@link readonly}, there is no deep conversion: only root-level
348
- * properties are made readonly. Property values are stored and exposed as-is -
349
- * this also means properties with ref values will not be automatically
350
- * unwrapped.
351
- *
352
- * @example
353
- * ```js
354
- * const state = shallowReadonly({
355
- * foo: 1,
356
- * nested: {
357
- * bar: 2
358
- * }
359
- * })
360
- *
361
- * // mutating state's own properties will fail
362
- * state.foo++
363
- *
364
- * // ...but works on nested objects
365
- * isReadonly(state.nested) // false
366
- *
367
- * // works
368
- * state.nested.bar++
369
- * ```
370
- *
371
- * @param target - The source object.
372
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
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
- * Checks if an object is a proxy created by {@link reactive} or
377
- * {@link shallowReactive} (or {@link ref} in some cases).
378
- *
379
- * @example
380
- * ```js
381
- * isReactive(reactive({})) // => true
382
- * isReactive(readonly(reactive({}))) // => true
383
- * isReactive(ref({}).value) // => true
384
- * isReactive(readonly(ref({})).value) // => true
385
- * isReactive(ref(true)) // => false
386
- * isReactive(shallowRef({}).value) // => false
387
- * isReactive(shallowReactive({})) // => true
388
- * ```
389
- *
390
- * @param value - The value to check.
391
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
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
- * Checks whether the passed value is a readonly object. The properties of a
396
- * readonly object can change, but they can't be assigned directly via the
397
- * passed object.
398
- *
399
- * The proxies created by {@link readonly} and {@link shallowReadonly} are
400
- * both considered readonly, as is a computed ref without a set function.
401
- *
402
- * @param value - The value to check.
403
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
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
- * Checks if an object is a proxy created by {@link reactive},
409
- * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
410
- *
411
- * @param value - The value to check.
412
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
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
- * Returns the raw, original object of a Vue-created proxy.
417
- *
418
- * `toRaw()` can return the original object from proxies created by
419
- * {@link reactive}, {@link readonly}, {@link shallowReactive} or
420
- * {@link shallowReadonly}.
421
- *
422
- * This is an escape hatch that can be used to temporarily read without
423
- * incurring proxy access / tracking overhead or write without triggering
424
- * changes. It is **not** recommended to hold a persistent reference to the
425
- * original object. Use with caution.
426
- *
427
- * @example
428
- * ```js
429
- * const foo = {}
430
- * const reactiveFoo = reactive(foo)
431
- *
432
- * console.log(toRaw(reactiveFoo) === foo) // true
433
- * ```
434
- *
435
- * @param observed - The object for which the "raw" value is requested.
436
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
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
- [RawSymbol]?: true;
445
+ [RawSymbol]?: true;
441
446
  };
442
447
  /**
443
- * Marks an object so that it will never be converted to a proxy. Returns the
444
- * object itself.
445
- *
446
- * @example
447
- * ```js
448
- * const foo = markRaw({})
449
- * console.log(isReactive(reactive(foo))) // false
450
- *
451
- * // also works when nested inside other reactive objects
452
- * const bar = reactive({ foo })
453
- * console.log(isReactive(bar.foo)) // false
454
- * ```
455
- *
456
- * **Warning:** `markRaw()` together with the shallow APIs such as
457
- * {@link shallowReactive} allow you to selectively opt-out of the default
458
- * deep reactive/readonly conversion and embed raw, non-proxied objects in your
459
- * state graph.
460
- *
461
- * @param value - The object to be marked as "raw".
462
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
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
- * Returns a reactive proxy of the given value (if possible).
467
- *
468
- * If the given value is not an object, the original value itself is returned.
469
- *
470
- * @param value - The value for which a reactive proxy shall be created.
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
- * Returns a readonly proxy of the given value (if possible).
475
- *
476
- * If the given value is not an object, the original value itself is returned.
477
- *
478
- * @param value - The value for which a readonly proxy shall be created.
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
- get value(): T;
486
- set value(_: S);
487
- /**
488
- * Type differentiator only.
489
- * We need this to be in public d.ts but don't want it to show up in IDE
490
- * autocomplete, so we use a private Symbol instead.
491
- */
492
- [RefSymbol]: true;
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
- * Checks if a value is a ref object.
496
- *
497
- * @param r - The value to inspect.
498
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isref}
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
- * Takes an inner value and returns a reactive and mutable ref object, which
503
- * has a single property `.value` that points to the inner value.
504
- *
505
- * @param value - The object to wrap in the ref.
506
- * @see {@link https://vuejs.org/api/reactivity-core.html#ref}
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
- [ShallowRefMarker]?: true;
518
+ [ShallowRefMarker]?: true;
513
519
  };
514
520
  /**
515
- * Shallow version of {@link ref}.
516
- *
517
- * @example
518
- * ```js
519
- * const state = shallowRef({ count: 1 })
520
- *
521
- * // does NOT trigger change
522
- * state.value.count = 2
523
- *
524
- * // does trigger change
525
- * state.value = { count: 2 }
526
- * ```
527
- *
528
- * @param value - The "inner value" for the shallow ref.
529
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
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
- * Force trigger effects that depends on a shallow ref. This is typically used
535
- * after making deep mutations to the inner value of a shallow ref.
536
- *
537
- * @example
538
- * ```js
539
- * const shallow = shallowRef({
540
- * greet: 'Hello, world'
541
- * })
542
- *
543
- * // Logs "Hello, world" once for the first run-through
544
- * watchEffect(() => {
545
- * console.log(shallow.value.greet)
546
- * })
547
- *
548
- * // This won't trigger the effect because the ref is shallow
549
- * shallow.value.greet = 'Hello, universe'
550
- *
551
- * // Logs "Hello, universe"
552
- * triggerRef(shallow)
553
- * ```
554
- *
555
- * @param ref - The ref whose tied effects shall be executed.
556
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
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
- * Returns the inner value if the argument is a ref, otherwise return the
563
- * argument itself. This is a sugar function for
564
- * `val = isRef(val) ? val.value : val`.
565
- *
566
- * @example
567
- * ```js
568
- * function useFoo(x: number | Ref<number>) {
569
- * const unwrapped = unref(x)
570
- * // unwrapped is guaranteed to be number now
571
- * }
572
- * ```
573
- *
574
- * @param ref - Ref or plain value to be converted into the plain value.
575
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
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
- * Normalizes values / refs / getters to values.
580
- * This is similar to {@link unref}, except that it also normalizes getters.
581
- * If the argument is a getter, it will be invoked and its return value will
582
- * be returned.
583
- *
584
- * @example
585
- * ```js
586
- * toValue(1) // 1
587
- * toValue(ref(1)) // 1
588
- * toValue(() => 1) // 1
589
- * ```
590
- *
591
- * @param source - A getter, an existing ref, or a non-function value.
592
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
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
- * Returns a proxy for the given object that shallowly unwraps properties that
597
- * are refs. If the object already is reactive, it's returned as-is. If not, a
598
- * new reactive proxy is created.
599
- *
600
- * @param objectWithRefs - Either an already-reactive object or a simple object
601
- * that contains refs.
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
- get: () => T;
606
- set: (value: T) => void;
610
+ export type CustomRefFactory<T, S = T> = (track: () => void, trigger: () => void) => {
611
+ get: () => T;
612
+ set: (value: S) => void;
607
613
  };
608
614
  /**
609
- * Creates a customized ref with explicit control over its dependency tracking
610
- * and updates triggering.
611
- *
612
- * @param factory - The function that receives the `track` and `trigger` callbacks.
613
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
614
- */
615
- export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
616
- export type ToRefs<T = any> = {
617
- [K in keyof T]: ToRef<T[K]>;
618
- };
619
- /**
620
- * Converts a reactive object to a plain object where each property of the
621
- * resulting object is a ref pointing to the corresponding property of the
622
- * original object. Each individual ref is created using {@link toRef}.
623
- *
624
- * @param object - Reactive object to be made into an object of linked refs.
625
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
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
- * Used to normalize values / refs / getters into refs.
631
- *
632
- * @example
633
- * ```js
634
- * // returns existing refs as-is
635
- * toRef(existingRef)
636
- *
637
- * // creates a ref that calls the getter on .value access
638
- * toRef(() => props.foo)
639
- *
640
- * // creates normal refs from non-function values
641
- * // equivalent to ref(1)
642
- * toRef(1)
643
- * ```
644
- *
645
- * Can also be used to create a ref for a property on a source reactive object.
646
- * The created ref is synced with its source property: mutating the source
647
- * property will update the ref, and vice-versa.
648
- *
649
- * @example
650
- * ```js
651
- * const state = reactive({
652
- * foo: 1,
653
- * bar: 2
654
- * })
655
- *
656
- * const fooRef = toRef(state, 'foo')
657
- *
658
- * // mutating the ref updates the original
659
- * fooRef.value++
660
- * console.log(state.foo) // 2
661
- *
662
- * // mutating the original also updates the ref
663
- * state.foo++
664
- * console.log(fooRef.value) // 3
665
- * ```
666
- *
667
- * @param source - A getter, an existing ref, a non-function value, or a
668
- * reactive object to create a property ref from.
669
- * @param [key] - (optional) Name of the property in the reactive object.
670
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
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 keyof T>(object: T, key: K): ToRef<T[K]>;
674
- export declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
675
- /**
676
- * This is a special exported interface for other packages to declare
677
- * additional types that should bail out for ref unwrapping. For example
678
- * \@vue/runtime-dom can declare it like so in its d.ts:
679
- *
680
- * ``` ts
681
- * declare module '@vue/reactivity' {
682
- * export interface RefUnwrapBailTypes {
683
- * runtimeDOMBailTypes: Node | Window
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
- [RawSymbol]?: true;
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
- [K in keyof T]: UnwrapRefSimple<T[K]>;
699
- } : T extends object & {
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
- * Tracks access to a reactive property.
710
- *
711
- * This will check which effect is running at the moment and record it as dep
712
- * which records all effects that depend on the reactive property.
713
- *
714
- * @param target - Object holding the reactive property.
715
- * @param type - Defines the type of access to the reactive property.
716
- * @param key - Identifier of the reactive property to track.
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
- * Finds all deps associated with the target (or a specific property) and
721
- * triggers the effects stored within.
722
- *
723
- * @param target - The reactive object.
724
- * @param type - Defines the type of the operation that needs to trigger effects.
725
- * @param key - Can be used to target a specific reactive property in the target object.
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
- * 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
- */
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
- * Track array iteration and return raw array
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
- WATCH_GETTER = 2,
742
- WATCH_CALLBACK = 3,
743
- WATCH_CLEANUP = 4
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
- immediate?: Immediate;
751
- deep?: boolean | number;
752
- once?: boolean;
753
- onWarn?: (msg: string, ...args: any[]) => void;
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
- pause: () => void;
758
- resume: () => void;
759
- stop: () => void;
758
+ pause: () => void;
759
+ resume: () => void;
760
+ stop: () => void;
760
761
  }
761
762
  /**
762
- * Returns the current active effect if there is one.
763
- */
763
+ * Returns the current active effect if there is one.
764
+ */
764
765
  export declare function getCurrentWatcher(): ReactiveEffect<any> | undefined;
765
766
  /**
766
- * Registers a cleanup callback on the current active effect. This
767
- * registered cleanup callback will be invoked right before the
768
- * associated effect re-runs.
769
- *
770
- * @param cleanupFn - The callback function to attach to the effect's cleanup.
771
- * @param failSilently - if `true`, will not throw warning when called without
772
- * an active effect.
773
- * @param owner - The effect that this cleanup function should be attached to.
774
- * By default, the current active effect.
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
- cb?: WatchCallback<any, any> | null | undefined;
779
- options: WatchOptions;
780
- forceTrigger: boolean;
781
- isMultiSource: boolean;
782
- oldValue: any;
783
- boundCleanup: typeof onWatcherCleanup;
784
- constructor(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback<any, any> | null | undefined, options?: WatchOptions);
785
- run(initialRun?: boolean): void;
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