@vue/reactivity 3.3.0-alpha.4 → 3.3.0-alpha.6
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.d.ts +63 -104
- package/package.json +2 -2
package/dist/reactivity.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IfAny } from '@vue/shared';
|
|
2
2
|
|
|
3
|
-
declare const enum ReactiveFlags {
|
|
3
|
+
export declare const enum ReactiveFlags {
|
|
4
4
|
SKIP = "__v_skip",
|
|
5
5
|
IS_REACTIVE = "__v_isReactive",
|
|
6
6
|
IS_READONLY = "__v_isReadonly",
|
|
@@ -30,7 +30,7 @@ export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
|
|
|
30
30
|
* count.value // -> 1
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
|
|
33
|
+
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
|
|
34
34
|
declare const ShallowReactiveMarker: unique symbol;
|
|
35
35
|
export type ShallowReactive<T> = T & {
|
|
36
36
|
[ShallowReactiveMarker]?: true;
|
|
@@ -40,9 +40,9 @@ export type ShallowReactive<T> = T & {
|
|
|
40
40
|
* level properties are reactive. It also does not auto-unwrap refs (even at the
|
|
41
41
|
* root level).
|
|
42
42
|
*/
|
|
43
|
-
declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
export declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
|
|
44
|
+
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
45
|
+
type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
46
46
|
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> ? Readonly<Ref<DeepReadonly<U>>> : T extends {} ? {
|
|
47
47
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
48
48
|
} : Readonly<T>;
|
|
@@ -50,88 +50,58 @@ export type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infer K, inf
|
|
|
50
50
|
* Creates a readonly copy of the original object. Note the returned copy is not
|
|
51
51
|
* made reactive, but `readonly` can be called on an already reactive object.
|
|
52
52
|
*/
|
|
53
|
-
declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
|
|
53
|
+
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
|
|
54
54
|
/**
|
|
55
55
|
* Returns a reactive-copy of the original object, where only the root level
|
|
56
56
|
* properties are readonly, and does NOT unwrap refs nor recursively convert
|
|
57
57
|
* returned properties.
|
|
58
58
|
* This is used for creating the props proxy object for stateful components.
|
|
59
59
|
*/
|
|
60
|
-
declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
|
|
61
|
-
declare function isReactive(value: unknown): boolean;
|
|
62
|
-
declare function isReadonly(value: unknown): boolean;
|
|
63
|
-
declare function isShallow(value: unknown): boolean;
|
|
64
|
-
declare function isProxy(value: unknown): boolean;
|
|
65
|
-
declare function toRaw<T>(observed: T): T;
|
|
60
|
+
export declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
|
|
61
|
+
export declare function isReactive(value: unknown): boolean;
|
|
62
|
+
export declare function isReadonly(value: unknown): boolean;
|
|
63
|
+
export declare function isShallow(value: unknown): boolean;
|
|
64
|
+
export declare function isProxy(value: unknown): boolean;
|
|
65
|
+
export declare function toRaw<T>(observed: T): T;
|
|
66
66
|
export type Raw<T> = T & {
|
|
67
67
|
[RawSymbol]?: true;
|
|
68
68
|
};
|
|
69
|
-
declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
69
|
+
export declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
type CollectionTypes = IterableCollections | WeakCollections;
|
|
72
|
+
type IterableCollections = Map<any, any> | Set<any>;
|
|
73
|
+
type WeakCollections = WeakMap<any, any> | WeakSet<any>;
|
|
74
74
|
|
|
75
|
-
declare const enum TrackOpTypes {
|
|
75
|
+
export declare const enum TrackOpTypes {
|
|
76
76
|
GET = "get",
|
|
77
77
|
HAS = "has",
|
|
78
78
|
ITERATE = "iterate"
|
|
79
79
|
}
|
|
80
|
-
declare const enum TriggerOpTypes {
|
|
80
|
+
export declare const enum TriggerOpTypes {
|
|
81
81
|
SET = "set",
|
|
82
82
|
ADD = "add",
|
|
83
83
|
DELETE = "delete",
|
|
84
84
|
CLEAR = "clear"
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
declare class EffectScope {
|
|
87
|
+
export declare class EffectScope {
|
|
88
88
|
detached: boolean;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*/
|
|
96
|
-
effects: ReactiveEffect[];
|
|
97
|
-
/**
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
cleanups: (() => void)[];
|
|
101
|
-
/**
|
|
102
|
-
* only assigned by undetached scope
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
parent: EffectScope | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* record undetached scopes
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
scopes: EffectScope[] | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* track a child scope's index in its parent's scopes array for optimized
|
|
113
|
-
* removal
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
116
|
-
private index;
|
|
89
|
+
/* removed internal: _active */
|
|
90
|
+
/* removed internal: effects */
|
|
91
|
+
/* removed internal: cleanups */
|
|
92
|
+
/* removed internal: parent */
|
|
93
|
+
/* removed internal: scopes */
|
|
94
|
+
/* removed internal: index */
|
|
117
95
|
constructor(detached?: boolean);
|
|
118
96
|
get active(): boolean;
|
|
119
97
|
run<T>(fn: () => T): T | undefined;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @internal
|
|
123
|
-
*/
|
|
124
|
-
on(): void;
|
|
125
|
-
/**
|
|
126
|
-
* This should only be called on non-detached scopes
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
off(): void;
|
|
98
|
+
/* removed internal: on */
|
|
99
|
+
/* removed internal: off */
|
|
130
100
|
stop(fromParent?: boolean): void;
|
|
131
101
|
}
|
|
132
|
-
declare function effectScope(detached?: boolean): EffectScope;
|
|
133
|
-
declare function getCurrentScope(): EffectScope | undefined;
|
|
134
|
-
declare function onScopeDispose(fn: () => void): void;
|
|
102
|
+
export declare function effectScope(detached?: boolean): EffectScope;
|
|
103
|
+
export declare function getCurrentScope(): EffectScope | undefined;
|
|
104
|
+
export declare function onScopeDispose(fn: () => void): void;
|
|
135
105
|
|
|
136
106
|
declare const ComputedRefSymbol: unique symbol;
|
|
137
107
|
export interface ComputedRef<T = any> extends WritableComputedRef<T> {
|
|
@@ -160,8 +130,8 @@ declare class ComputedRefImpl<T> {
|
|
|
160
130
|
get value(): T;
|
|
161
131
|
set value(newValue: T);
|
|
162
132
|
}
|
|
163
|
-
declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
164
|
-
declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
|
|
133
|
+
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
134
|
+
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
|
|
165
135
|
|
|
166
136
|
export type EffectScheduler = (...args: any[]) => any;
|
|
167
137
|
export type DebuggerEvent = {
|
|
@@ -175,26 +145,16 @@ export type DebuggerEventExtraInfo = {
|
|
|
175
145
|
oldValue?: any;
|
|
176
146
|
oldTarget?: Map<any, any> | Set<any>;
|
|
177
147
|
};
|
|
178
|
-
declare const ITERATE_KEY: unique symbol;
|
|
179
|
-
declare class ReactiveEffect<T = any> {
|
|
148
|
+
export declare const ITERATE_KEY: unique symbol;
|
|
149
|
+
export declare class ReactiveEffect<T = any> {
|
|
180
150
|
fn: () => T;
|
|
181
151
|
scheduler: EffectScheduler | null;
|
|
182
152
|
active: boolean;
|
|
183
153
|
deps: Dep[];
|
|
184
154
|
parent: ReactiveEffect | undefined;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*/
|
|
189
|
-
computed?: ComputedRefImpl<T>;
|
|
190
|
-
/**
|
|
191
|
-
* @internal
|
|
192
|
-
*/
|
|
193
|
-
allowRecurse?: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* @internal
|
|
196
|
-
*/
|
|
197
|
-
private deferStop?;
|
|
155
|
+
/* removed internal: computed */
|
|
156
|
+
/* removed internal: allowRecurse */
|
|
157
|
+
/* removed internal: deferStop */
|
|
198
158
|
onStop?: () => void;
|
|
199
159
|
onTrack?: (event: DebuggerEvent) => void;
|
|
200
160
|
onTrigger?: (event: DebuggerEvent) => void;
|
|
@@ -217,21 +177,21 @@ export interface ReactiveEffectRunner<T = any> {
|
|
|
217
177
|
(): T;
|
|
218
178
|
effect: ReactiveEffect;
|
|
219
179
|
}
|
|
220
|
-
declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
|
|
221
|
-
declare function stop(runner: ReactiveEffectRunner): void;
|
|
222
|
-
declare function pauseTracking(): void;
|
|
223
|
-
declare function enableTracking(): void;
|
|
224
|
-
declare function resetTracking(): void;
|
|
225
|
-
declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
226
|
-
declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
180
|
+
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
|
|
181
|
+
export declare function stop(runner: ReactiveEffectRunner): void;
|
|
182
|
+
export declare function pauseTracking(): void;
|
|
183
|
+
export declare function enableTracking(): void;
|
|
184
|
+
export declare function resetTracking(): void;
|
|
185
|
+
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
186
|
+
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
227
187
|
|
|
228
|
-
|
|
188
|
+
type Dep = Set<ReactiveEffect> & TrackedMarkers;
|
|
229
189
|
/**
|
|
230
190
|
* wasTracked and newTracked maintain the status for several levels of effect
|
|
231
191
|
* tracking recursion. One bit per level is used to define whether the dependency
|
|
232
192
|
* was/is tracked.
|
|
233
193
|
*/
|
|
234
|
-
|
|
194
|
+
type TrackedMarkers = {
|
|
235
195
|
/**
|
|
236
196
|
* wasTracked
|
|
237
197
|
*/
|
|
@@ -253,33 +213,33 @@ export interface Ref<T = any> {
|
|
|
253
213
|
*/
|
|
254
214
|
[RefSymbol]: true;
|
|
255
215
|
}
|
|
256
|
-
declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
|
|
257
|
-
declare function ref<T extends object>(value: T): [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
|
|
258
|
-
declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
|
|
259
|
-
declare function ref<T = any>(): Ref<T | undefined>;
|
|
216
|
+
export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
|
|
217
|
+
export declare function ref<T extends object>(value: T): [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
|
|
218
|
+
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
|
|
219
|
+
export declare function ref<T = any>(): Ref<T | undefined>;
|
|
260
220
|
declare const ShallowRefMarker: unique symbol;
|
|
261
221
|
export type ShallowRef<T = any> = Ref<T> & {
|
|
262
222
|
[ShallowRefMarker]?: true;
|
|
263
223
|
};
|
|
264
|
-
declare function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
|
|
265
|
-
declare function shallowRef<T>(value: T): ShallowRef<T>;
|
|
266
|
-
declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
267
|
-
declare function triggerRef(ref: Ref): void;
|
|
268
|
-
declare function unref<T>(ref: T | Ref<T>): T;
|
|
269
|
-
declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
224
|
+
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
|
|
225
|
+
export declare function shallowRef<T>(value: T): ShallowRef<T>;
|
|
226
|
+
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
227
|
+
export declare function triggerRef(ref: Ref): void;
|
|
228
|
+
export declare function unref<T>(ref: T | Ref<T>): T;
|
|
229
|
+
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
270
230
|
export type CustomRefFactory<T> = (track: () => void, trigger: () => void) => {
|
|
271
231
|
get: () => T;
|
|
272
232
|
set: (value: T) => void;
|
|
273
233
|
};
|
|
274
|
-
declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
|
|
234
|
+
export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
|
|
275
235
|
export type ToRefs<T = any> = {
|
|
276
236
|
[K in keyof T]: ToRef<T[K]>;
|
|
277
237
|
};
|
|
278
|
-
declare function toRefs<T extends object>(object: T): ToRefs<T>;
|
|
238
|
+
export declare function toRefs<T extends object>(object: T): ToRefs<T>;
|
|
279
239
|
export type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>;
|
|
280
|
-
declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
|
|
281
|
-
declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
|
|
282
|
-
|
|
240
|
+
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
|
|
241
|
+
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
|
|
242
|
+
type BaseTypes = string | number | boolean;
|
|
283
243
|
/**
|
|
284
244
|
* This is a special exported interface for other packages to declare
|
|
285
245
|
* additional types that should bail out for ref unwrapping. For example
|
|
@@ -299,7 +259,7 @@ export type ShallowUnwrapRef<T> = {
|
|
|
299
259
|
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K] extends Ref<infer V> | undefined ? unknown extends V ? undefined : V | undefined : T[K];
|
|
300
260
|
};
|
|
301
261
|
export type UnwrapRef<T> = T extends ShallowRef<infer V> ? V : T extends Ref<infer V> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;
|
|
302
|
-
|
|
262
|
+
type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseTypes | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
|
|
303
263
|
[RawSymbol]?: true;
|
|
304
264
|
} ? T : T extends ReadonlyArray<any> ? {
|
|
305
265
|
[K in keyof T]: UnwrapRefSimple<T[K]>;
|
|
@@ -309,6 +269,5 @@ export type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseType
|
|
|
309
269
|
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
|
|
310
270
|
} : T;
|
|
311
271
|
|
|
312
|
-
declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;
|
|
272
|
+
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;
|
|
313
273
|
|
|
314
|
-
export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/reactivity",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.6",
|
|
4
4
|
"description": "@vue/reactivity",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/reactivity.esm-bundler.js",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/reactivity#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@vue/shared": "3.3.0-alpha.
|
|
39
|
+
"@vue/shared": "3.3.0-alpha.6"
|
|
40
40
|
}
|
|
41
41
|
}
|