@vue/reactivity 3.3.0-alpha.6 → 3.3.0-alpha.8
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 +33 -4
- package/dist/reactivity.cjs.prod.js +33 -4
- package/dist/reactivity.d.ts +430 -27
- package/dist/reactivity.esm-browser.js +33 -5
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +33 -5
- package/dist/reactivity.global.js +33 -4
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
package/dist/reactivity.cjs.js
CHANGED
|
@@ -1021,6 +1021,9 @@ function triggerRef(ref2) {
|
|
|
1021
1021
|
function unref(ref2) {
|
|
1022
1022
|
return isRef(ref2) ? ref2.value : ref2;
|
|
1023
1023
|
}
|
|
1024
|
+
function toValue(source) {
|
|
1025
|
+
return shared.isFunction(source) ? source() : unref(source);
|
|
1026
|
+
}
|
|
1024
1027
|
const shallowUnwrapHandlers = {
|
|
1025
1028
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1026
1029
|
set: (target, key, value, receiver) => {
|
|
@@ -1063,7 +1066,7 @@ function toRefs(object) {
|
|
|
1063
1066
|
}
|
|
1064
1067
|
const ret = shared.isArray(object) ? new Array(object.length) : {};
|
|
1065
1068
|
for (const key in object) {
|
|
1066
|
-
ret[key] =
|
|
1069
|
+
ret[key] = propertyToRef(object, key);
|
|
1067
1070
|
}
|
|
1068
1071
|
return ret;
|
|
1069
1072
|
}
|
|
@@ -1085,9 +1088,34 @@ class ObjectRefImpl {
|
|
|
1085
1088
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1086
1089
|
}
|
|
1087
1090
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
+
class GetterRefImpl {
|
|
1092
|
+
constructor(_getter) {
|
|
1093
|
+
this._getter = _getter;
|
|
1094
|
+
this.__v_isRef = true;
|
|
1095
|
+
this.__v_isReadonly = true;
|
|
1096
|
+
}
|
|
1097
|
+
get value() {
|
|
1098
|
+
return this._getter();
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function toRef(source, key, defaultValue) {
|
|
1102
|
+
if (isRef(source)) {
|
|
1103
|
+
return source;
|
|
1104
|
+
} else if (shared.isFunction(source)) {
|
|
1105
|
+
return new GetterRefImpl(source);
|
|
1106
|
+
} else if (shared.isObject(source) && arguments.length > 1) {
|
|
1107
|
+
return propertyToRef(source, key, defaultValue);
|
|
1108
|
+
} else {
|
|
1109
|
+
return ref(source);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1113
|
+
const val = source[key];
|
|
1114
|
+
return isRef(val) ? val : new ObjectRefImpl(
|
|
1115
|
+
source,
|
|
1116
|
+
key,
|
|
1117
|
+
defaultValue
|
|
1118
|
+
);
|
|
1091
1119
|
}
|
|
1092
1120
|
|
|
1093
1121
|
class ComputedRefImpl {
|
|
@@ -1242,6 +1270,7 @@ exports.stop = stop;
|
|
|
1242
1270
|
exports.toRaw = toRaw;
|
|
1243
1271
|
exports.toRef = toRef;
|
|
1244
1272
|
exports.toRefs = toRefs;
|
|
1273
|
+
exports.toValue = toValue;
|
|
1245
1274
|
exports.track = track;
|
|
1246
1275
|
exports.trigger = trigger;
|
|
1247
1276
|
exports.triggerRef = triggerRef;
|
|
@@ -951,6 +951,9 @@ function triggerRef(ref2) {
|
|
|
951
951
|
function unref(ref2) {
|
|
952
952
|
return isRef(ref2) ? ref2.value : ref2;
|
|
953
953
|
}
|
|
954
|
+
function toValue(source) {
|
|
955
|
+
return shared.isFunction(source) ? source() : unref(source);
|
|
956
|
+
}
|
|
954
957
|
const shallowUnwrapHandlers = {
|
|
955
958
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
956
959
|
set: (target, key, value, receiver) => {
|
|
@@ -990,7 +993,7 @@ function customRef(factory) {
|
|
|
990
993
|
function toRefs(object) {
|
|
991
994
|
const ret = shared.isArray(object) ? new Array(object.length) : {};
|
|
992
995
|
for (const key in object) {
|
|
993
|
-
ret[key] =
|
|
996
|
+
ret[key] = propertyToRef(object, key);
|
|
994
997
|
}
|
|
995
998
|
return ret;
|
|
996
999
|
}
|
|
@@ -1012,9 +1015,34 @@ class ObjectRefImpl {
|
|
|
1012
1015
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1013
1016
|
}
|
|
1014
1017
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
+
class GetterRefImpl {
|
|
1019
|
+
constructor(_getter) {
|
|
1020
|
+
this._getter = _getter;
|
|
1021
|
+
this.__v_isRef = true;
|
|
1022
|
+
this.__v_isReadonly = true;
|
|
1023
|
+
}
|
|
1024
|
+
get value() {
|
|
1025
|
+
return this._getter();
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
function toRef(source, key, defaultValue) {
|
|
1029
|
+
if (isRef(source)) {
|
|
1030
|
+
return source;
|
|
1031
|
+
} else if (shared.isFunction(source)) {
|
|
1032
|
+
return new GetterRefImpl(source);
|
|
1033
|
+
} else if (shared.isObject(source) && arguments.length > 1) {
|
|
1034
|
+
return propertyToRef(source, key, defaultValue);
|
|
1035
|
+
} else {
|
|
1036
|
+
return ref(source);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1040
|
+
const val = source[key];
|
|
1041
|
+
return isRef(val) ? val : new ObjectRefImpl(
|
|
1042
|
+
source,
|
|
1043
|
+
key,
|
|
1044
|
+
defaultValue
|
|
1045
|
+
);
|
|
1018
1046
|
}
|
|
1019
1047
|
|
|
1020
1048
|
class ComputedRefImpl {
|
|
@@ -1163,6 +1191,7 @@ exports.stop = stop;
|
|
|
1163
1191
|
exports.toRaw = toRaw;
|
|
1164
1192
|
exports.toRef = toRef;
|
|
1165
1193
|
exports.toRefs = toRefs;
|
|
1194
|
+
exports.toValue = toValue;
|
|
1166
1195
|
exports.track = track;
|
|
1167
1196
|
exports.trigger = trigger;
|
|
1168
1197
|
exports.triggerRef = triggerRef;
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -9,26 +9,19 @@ export declare const enum ReactiveFlags {
|
|
|
9
9
|
}
|
|
10
10
|
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Returns a reactive proxy of the object.
|
|
13
13
|
*
|
|
14
|
-
* The reactive conversion is "deep"
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* proxy and avoid relying on the original object.
|
|
18
|
-
*
|
|
19
|
-
* A reactive object also automatically unwraps refs contained in it, so you
|
|
20
|
-
* don't need to use `.value` when accessing and mutating their value:
|
|
14
|
+
* The reactive conversion is "deep": it affects all nested properties. A
|
|
15
|
+
* reactive object also deeply unwraps any properties that are refs while
|
|
16
|
+
* maintaining reactivity.
|
|
21
17
|
*
|
|
18
|
+
* @example
|
|
22
19
|
* ```js
|
|
23
|
-
* const
|
|
24
|
-
* const obj = reactive({
|
|
25
|
-
* count
|
|
26
|
-
* })
|
|
27
|
-
*
|
|
28
|
-
* obj.count++
|
|
29
|
-
* obj.count // -> 1
|
|
30
|
-
* count.value // -> 1
|
|
20
|
+
* const obj = reactive({ count: 0 })
|
|
31
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param target - The source object.
|
|
24
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#reactive}
|
|
32
25
|
*/
|
|
33
26
|
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
|
|
34
27
|
declare const ShallowReactiveMarker: unique symbol;
|
|
@@ -36,9 +29,34 @@ export type ShallowReactive<T> = T & {
|
|
|
36
29
|
[ShallowReactiveMarker]?: true;
|
|
37
30
|
};
|
|
38
31
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* root
|
|
32
|
+
* Shallow version of {@link reactive()}.
|
|
33
|
+
*
|
|
34
|
+
* Unlike {@link reactive()}, there is no deep conversion: only root-level
|
|
35
|
+
* properties are reactive for a shallow reactive object. Property values are
|
|
36
|
+
* stored and exposed as-is - this also means properties with ref values will
|
|
37
|
+
* not be automatically unwrapped.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```js
|
|
41
|
+
* const state = shallowReactive({
|
|
42
|
+
* foo: 1,
|
|
43
|
+
* nested: {
|
|
44
|
+
* bar: 2
|
|
45
|
+
* }
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* // mutating state's own properties is reactive
|
|
49
|
+
* state.foo++
|
|
50
|
+
*
|
|
51
|
+
* // ...but does not convert nested objects
|
|
52
|
+
* isReactive(state.nested) // false
|
|
53
|
+
*
|
|
54
|
+
* // NOT reactive
|
|
55
|
+
* state.nested.bar++
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param target - The source object.
|
|
59
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
42
60
|
*/
|
|
43
61
|
export declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
|
|
44
62
|
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
@@ -47,25 +65,155 @@ export type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infer K, inf
|
|
|
47
65
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
48
66
|
} : Readonly<T>;
|
|
49
67
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
68
|
+
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
69
|
+
* the original.
|
|
70
|
+
*
|
|
71
|
+
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
72
|
+
* well. It also has the same ref-unwrapping behavior as {@link reactive()},
|
|
73
|
+
* except the unwrapped values will also be made readonly.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```js
|
|
77
|
+
* const original = reactive({ count: 0 })
|
|
78
|
+
*
|
|
79
|
+
* const copy = readonly(original)
|
|
80
|
+
*
|
|
81
|
+
* watchEffect(() => {
|
|
82
|
+
* // works for reactivity tracking
|
|
83
|
+
* console.log(copy.count)
|
|
84
|
+
* })
|
|
85
|
+
*
|
|
86
|
+
* // mutating original will trigger watchers relying on the copy
|
|
87
|
+
* original.count++
|
|
88
|
+
*
|
|
89
|
+
* // mutating the copy will fail and result in a warning
|
|
90
|
+
* copy.count++ // warning!
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param target - The source object.
|
|
94
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
52
95
|
*/
|
|
53
96
|
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
|
|
54
97
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
98
|
+
* Shallow version of {@link readonly()}.
|
|
99
|
+
*
|
|
100
|
+
* Unlike {@link readonly()}, there is no deep conversion: only root-level
|
|
101
|
+
* properties are made readonly. Property values are stored and exposed as-is -
|
|
102
|
+
* this also means properties with ref values will not be automatically
|
|
103
|
+
* unwrapped.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```js
|
|
107
|
+
* const state = shallowReadonly({
|
|
108
|
+
* foo: 1,
|
|
109
|
+
* nested: {
|
|
110
|
+
* bar: 2
|
|
111
|
+
* }
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* // mutating state's own properties will fail
|
|
115
|
+
* state.foo++
|
|
116
|
+
*
|
|
117
|
+
* // ...but works on nested objects
|
|
118
|
+
* isReadonly(state.nested) // false
|
|
119
|
+
*
|
|
120
|
+
* // works
|
|
121
|
+
* state.nested.bar++
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @param target - The source object.
|
|
125
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
59
126
|
*/
|
|
60
127
|
export declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
|
|
128
|
+
/**
|
|
129
|
+
* Checks if an object is a proxy created by {@link reactive()} or
|
|
130
|
+
* {@link shallowReactive()} (or {@link ref()} in some cases).
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```js
|
|
134
|
+
* isReactive(reactive({})) // => true
|
|
135
|
+
* isReactive(readonly(reactive({}))) // => true
|
|
136
|
+
* isReactive(ref({}).value) // => true
|
|
137
|
+
* isReactive(readonly(ref({})).value) // => true
|
|
138
|
+
* isReactive(ref(true)) // => false
|
|
139
|
+
* isReactive(shallowRef({}).value) // => false
|
|
140
|
+
* isReactive(shallowReactive({})) // => true
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param value - The value to check.
|
|
144
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
145
|
+
*/
|
|
61
146
|
export declare function isReactive(value: unknown): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Checks whether the passed value is a readonly object. The properties of a
|
|
149
|
+
* readonly object can change, but they can't be assigned directly via the
|
|
150
|
+
* passed object.
|
|
151
|
+
*
|
|
152
|
+
* The proxies created by {@link readonly()} and {@link shallowReadonly()} are
|
|
153
|
+
* both considered readonly, as is a computed ref without a set function.
|
|
154
|
+
*
|
|
155
|
+
* @param value - The value to check.
|
|
156
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
157
|
+
*/
|
|
62
158
|
export declare function isReadonly(value: unknown): boolean;
|
|
63
159
|
export declare function isShallow(value: unknown): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Checks if an object is a proxy created by {@link reactive},
|
|
162
|
+
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly()}.
|
|
163
|
+
*
|
|
164
|
+
* @param value - The value to check.
|
|
165
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
166
|
+
*/
|
|
64
167
|
export declare function isProxy(value: unknown): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Returns the raw, original object of a Vue-created proxy.
|
|
170
|
+
*
|
|
171
|
+
* `toRaw()` can return the original object from proxies created by
|
|
172
|
+
* {@link reactive()}, {@link readonly()}, {@link shallowReactive()} or
|
|
173
|
+
* {@link shallowReadonly()}.
|
|
174
|
+
*
|
|
175
|
+
* This is an escape hatch that can be used to temporarily read without
|
|
176
|
+
* incurring proxy access / tracking overhead or write without triggering
|
|
177
|
+
* changes. It is **not** recommended to hold a persistent reference to the
|
|
178
|
+
* original object. Use with caution.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```js
|
|
182
|
+
* const foo = {}
|
|
183
|
+
* const reactiveFoo = reactive(foo)
|
|
184
|
+
*
|
|
185
|
+
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @param observed - The object for which the "raw" value is requested.
|
|
189
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
190
|
+
*/
|
|
65
191
|
export declare function toRaw<T>(observed: T): T;
|
|
66
192
|
export type Raw<T> = T & {
|
|
67
193
|
[RawSymbol]?: true;
|
|
68
194
|
};
|
|
195
|
+
/**
|
|
196
|
+
* Marks an object so that it will never be converted to a proxy. Returns the
|
|
197
|
+
* object itself.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```js
|
|
201
|
+
* const foo = markRaw({})
|
|
202
|
+
* console.log(isReactive(reactive(foo))) // false
|
|
203
|
+
*
|
|
204
|
+
* // also works when nested inside other reactive objects
|
|
205
|
+
* const bar = reactive({ foo })
|
|
206
|
+
* console.log(isReactive(bar.foo)) // false
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* **Warning:** `markRaw()` together with the shallow APIs such as
|
|
210
|
+
* {@link shallowReactive()} allow you to selectively opt-out of the default
|
|
211
|
+
* deep reactive/readonly conversion and embed raw, non-proxied objects in your
|
|
212
|
+
* state graph.
|
|
213
|
+
*
|
|
214
|
+
* @param value - The object to be marked as "raw".
|
|
215
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
|
|
216
|
+
*/
|
|
69
217
|
export declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
70
218
|
|
|
71
219
|
type CollectionTypes = IterableCollections | WeakCollections;
|
|
@@ -99,8 +247,29 @@ export declare class EffectScope {
|
|
|
99
247
|
/* removed internal: off */
|
|
100
248
|
stop(fromParent?: boolean): void;
|
|
101
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Creates an effect scope object which can capture the reactive effects (i.e.
|
|
252
|
+
* computed and watchers) created within it so that these effects can be
|
|
253
|
+
* disposed together. For detailed use cases of this API, please consult its
|
|
254
|
+
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
|
|
255
|
+
*
|
|
256
|
+
* @param detached - Can be used to create a "detached" effect scope.
|
|
257
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
|
|
258
|
+
*/
|
|
102
259
|
export declare function effectScope(detached?: boolean): EffectScope;
|
|
260
|
+
/**
|
|
261
|
+
* Returns the current active effect scope if there is one.
|
|
262
|
+
*
|
|
263
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
|
|
264
|
+
*/
|
|
103
265
|
export declare function getCurrentScope(): EffectScope | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* Registers a dispose callback on the current active effect scope. The
|
|
268
|
+
* callback will be invoked when the associated effect scope is stopped.
|
|
269
|
+
*
|
|
270
|
+
* @param fn - The callback function to attach to the scope's cleanup.
|
|
271
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
272
|
+
*/
|
|
104
273
|
export declare function onScopeDispose(fn: () => void): void;
|
|
105
274
|
|
|
106
275
|
declare const ComputedRefSymbol: unique symbol;
|
|
@@ -130,6 +299,39 @@ declare class ComputedRefImpl<T> {
|
|
|
130
299
|
get value(): T;
|
|
131
300
|
set value(newValue: T);
|
|
132
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Takes a getter function and returns a readonly reactive ref object for the
|
|
304
|
+
* returned value from the getter. It can also take an object with get and set
|
|
305
|
+
* functions to create a writable ref object.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```js
|
|
309
|
+
* // Creating a readonly computed ref:
|
|
310
|
+
* const count = ref(1)
|
|
311
|
+
* const plusOne = computed(() => count.value + 1)
|
|
312
|
+
*
|
|
313
|
+
* console.log(plusOne.value) // 2
|
|
314
|
+
* plusOne.value++ // error
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* ```js
|
|
318
|
+
* // Creating a writable computed ref:
|
|
319
|
+
* const count = ref(1)
|
|
320
|
+
* const plusOne = computed({
|
|
321
|
+
* get: () => count.value + 1,
|
|
322
|
+
* set: (val) => {
|
|
323
|
+
* count.value = val - 1
|
|
324
|
+
* }
|
|
325
|
+
* })
|
|
326
|
+
*
|
|
327
|
+
* plusOne.value = 1
|
|
328
|
+
* console.log(count.value) // 0
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @param getter - Function that produces the next value.
|
|
332
|
+
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
|
|
333
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#computed}
|
|
334
|
+
*/
|
|
133
335
|
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
|
|
134
336
|
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
|
|
135
337
|
|
|
@@ -177,12 +379,54 @@ export interface ReactiveEffectRunner<T = any> {
|
|
|
177
379
|
(): T;
|
|
178
380
|
effect: ReactiveEffect;
|
|
179
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Registers the given function to track reactive updates.
|
|
384
|
+
*
|
|
385
|
+
* The given function will be run once immediately. Every time any reactive
|
|
386
|
+
* property that's accessed within it gets updated, the function will run again.
|
|
387
|
+
*
|
|
388
|
+
* @param fn - The function that will track reactive updates.
|
|
389
|
+
* @param options - Allows to control the effect's behaviour.
|
|
390
|
+
* @returns A runner that can be used to control the effect after creation.
|
|
391
|
+
*/
|
|
180
392
|
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
|
|
393
|
+
/**
|
|
394
|
+
* Stops the effect associated with the given runner.
|
|
395
|
+
*
|
|
396
|
+
* @param runner - Association with the effect to stop tracking.
|
|
397
|
+
*/
|
|
181
398
|
export declare function stop(runner: ReactiveEffectRunner): void;
|
|
399
|
+
/**
|
|
400
|
+
* Temporarily pauses tracking.
|
|
401
|
+
*/
|
|
182
402
|
export declare function pauseTracking(): void;
|
|
403
|
+
/**
|
|
404
|
+
* Re-enables effect tracking (if it was paused).
|
|
405
|
+
*/
|
|
183
406
|
export declare function enableTracking(): void;
|
|
407
|
+
/**
|
|
408
|
+
* Resets the previous global effect tracking state.
|
|
409
|
+
*/
|
|
184
410
|
export declare function resetTracking(): void;
|
|
411
|
+
/**
|
|
412
|
+
* Tracks access to a reactive property.
|
|
413
|
+
*
|
|
414
|
+
* This will check which effect is running at the moment and record it as dep
|
|
415
|
+
* which records all effects that depend on the reactive property.
|
|
416
|
+
*
|
|
417
|
+
* @param target - Object holding the reactive property.
|
|
418
|
+
* @param type - Defines the type of access to the reactive property.
|
|
419
|
+
* @param key - Identifier of the reactive property to track.
|
|
420
|
+
*/
|
|
185
421
|
export declare function track(target: object, type: TrackOpTypes, key: unknown): void;
|
|
422
|
+
/**
|
|
423
|
+
* Finds all deps associated with the target (or a specific property) and
|
|
424
|
+
* triggers the effects stored within.
|
|
425
|
+
*
|
|
426
|
+
* @param target - The reactive object.
|
|
427
|
+
* @param type - Defines the type of the operation that needs to trigger effects.
|
|
428
|
+
* @param key - Can be used to target a specific reactive property in the target object.
|
|
429
|
+
*/
|
|
186
430
|
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
187
431
|
|
|
188
432
|
type Dep = Set<ReactiveEffect> & TrackedMarkers;
|
|
@@ -213,30 +457,189 @@ export interface Ref<T = any> {
|
|
|
213
457
|
*/
|
|
214
458
|
[RefSymbol]: true;
|
|
215
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Checks if a value is a ref object.
|
|
462
|
+
*
|
|
463
|
+
* @param r - The value to inspect.
|
|
464
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isref}
|
|
465
|
+
*/
|
|
216
466
|
export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
|
|
217
|
-
|
|
467
|
+
/**
|
|
468
|
+
* Takes an inner value and returns a reactive and mutable ref object, which
|
|
469
|
+
* has a single property `.value` that points to the inner value.
|
|
470
|
+
*
|
|
471
|
+
* @param value - The object to wrap in the ref.
|
|
472
|
+
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
|
|
473
|
+
*/
|
|
474
|
+
export declare function ref<T extends Ref>(value: T): T;
|
|
218
475
|
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
|
|
219
476
|
export declare function ref<T = any>(): Ref<T | undefined>;
|
|
220
477
|
declare const ShallowRefMarker: unique symbol;
|
|
221
478
|
export type ShallowRef<T = any> = Ref<T> & {
|
|
222
479
|
[ShallowRefMarker]?: true;
|
|
223
480
|
};
|
|
481
|
+
/**
|
|
482
|
+
* Shallow version of {@link ref()}.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```js
|
|
486
|
+
* const state = shallowRef({ count: 1 })
|
|
487
|
+
*
|
|
488
|
+
* // does NOT trigger change
|
|
489
|
+
* state.value.count = 2
|
|
490
|
+
*
|
|
491
|
+
* // does trigger change
|
|
492
|
+
* state.value = { count: 2 }
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* @param value - The "inner value" for the shallow ref.
|
|
496
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
|
|
497
|
+
*/
|
|
224
498
|
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
|
|
225
499
|
export declare function shallowRef<T>(value: T): ShallowRef<T>;
|
|
226
500
|
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
501
|
+
/**
|
|
502
|
+
* Force trigger effects that depends on a shallow ref. This is typically used
|
|
503
|
+
* after making deep mutations to the inner value of a shallow ref.
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```js
|
|
507
|
+
* const shallow = shallowRef({
|
|
508
|
+
* greet: 'Hello, world'
|
|
509
|
+
* })
|
|
510
|
+
*
|
|
511
|
+
* // Logs "Hello, world" once for the first run-through
|
|
512
|
+
* watchEffect(() => {
|
|
513
|
+
* console.log(shallow.value.greet)
|
|
514
|
+
* })
|
|
515
|
+
*
|
|
516
|
+
* // This won't trigger the effect because the ref is shallow
|
|
517
|
+
* shallow.value.greet = 'Hello, universe'
|
|
518
|
+
*
|
|
519
|
+
* // Logs "Hello, universe"
|
|
520
|
+
* triggerRef(shallow)
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* @param ref - The ref whose tied effects shall be executed.
|
|
524
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
|
|
525
|
+
*/
|
|
227
526
|
export declare function triggerRef(ref: Ref): void;
|
|
228
|
-
export
|
|
527
|
+
export type MaybeRef<T = any> = T | Ref<T>;
|
|
528
|
+
export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
|
|
529
|
+
/**
|
|
530
|
+
* Returns the inner value if the argument is a ref, otherwise return the
|
|
531
|
+
* argument itself. This is a sugar function for
|
|
532
|
+
* `val = isRef(val) ? val.value : val`.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```js
|
|
536
|
+
* function useFoo(x: number | Ref<number>) {
|
|
537
|
+
* const unwrapped = unref(x)
|
|
538
|
+
* // unwrapped is guaranteed to be number now
|
|
539
|
+
* }
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @param ref - Ref or plain value to be converted into the plain value.
|
|
543
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
544
|
+
*/
|
|
545
|
+
export declare function unref<T>(ref: MaybeRef<T>): T;
|
|
546
|
+
/**
|
|
547
|
+
* Normalizes values / refs / getters to values.
|
|
548
|
+
* This is similar to {@link unref()}, except that it also normalizes getters.
|
|
549
|
+
* If the argument is a getter, it will be invoked and its return value will
|
|
550
|
+
* be returned.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```js
|
|
554
|
+
* toValue(1) // 1
|
|
555
|
+
* toValue(ref(1)) // 1
|
|
556
|
+
* toValue(() => 1) // 1
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @param source - A getter, an existing ref, or a non-function value.
|
|
560
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
561
|
+
*/
|
|
562
|
+
export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
|
|
563
|
+
/**
|
|
564
|
+
* Returns a reactive proxy for the given object.
|
|
565
|
+
*
|
|
566
|
+
* If the object already is reactive, it's returned as-is. If not, a new
|
|
567
|
+
* reactive proxy is created. Direct child properties that are refs are properly
|
|
568
|
+
* handled, as well.
|
|
569
|
+
*
|
|
570
|
+
* @param objectWithRefs - Either an already-reactive object or a simple object
|
|
571
|
+
* that contains refs.
|
|
572
|
+
*/
|
|
229
573
|
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
230
574
|
export type CustomRefFactory<T> = (track: () => void, trigger: () => void) => {
|
|
231
575
|
get: () => T;
|
|
232
576
|
set: (value: T) => void;
|
|
233
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* Creates a customized ref with explicit control over its dependency tracking
|
|
580
|
+
* and updates triggering.
|
|
581
|
+
*
|
|
582
|
+
* @param factory - The function that receives the `track` and `trigger` callbacks.
|
|
583
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
|
|
584
|
+
*/
|
|
234
585
|
export declare function customRef<T>(factory: CustomRefFactory<T>): Ref<T>;
|
|
235
586
|
export type ToRefs<T = any> = {
|
|
236
587
|
[K in keyof T]: ToRef<T[K]>;
|
|
237
588
|
};
|
|
589
|
+
/**
|
|
590
|
+
* Converts a reactive object to a plain object where each property of the
|
|
591
|
+
* resulting object is a ref pointing to the corresponding property of the
|
|
592
|
+
* original object. Each individual ref is created using {@link toRef()}.
|
|
593
|
+
*
|
|
594
|
+
* @param object - Reactive object to be made into an object of linked refs.
|
|
595
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
596
|
+
*/
|
|
238
597
|
export declare function toRefs<T extends object>(object: T): ToRefs<T>;
|
|
239
598
|
export type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>;
|
|
599
|
+
/**
|
|
600
|
+
* Used to normalize values / refs / getters into refs.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```js
|
|
604
|
+
* // returns existing refs as-is
|
|
605
|
+
* toRef(existingRef)
|
|
606
|
+
*
|
|
607
|
+
* // creates a ref that calls the getter on .value access
|
|
608
|
+
* toRef(() => props.foo)
|
|
609
|
+
*
|
|
610
|
+
* // creates normal refs from non-function values
|
|
611
|
+
* // equivalent to ref(1)
|
|
612
|
+
* toRef(1)
|
|
613
|
+
* ```
|
|
614
|
+
*
|
|
615
|
+
* Can also be used to create a ref for a property on a source reactive object.
|
|
616
|
+
* The created ref is synced with its source property: mutating the source
|
|
617
|
+
* property will update the ref, and vice-versa.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```js
|
|
621
|
+
* const state = reactive({
|
|
622
|
+
* foo: 1,
|
|
623
|
+
* bar: 2
|
|
624
|
+
* })
|
|
625
|
+
*
|
|
626
|
+
* const fooRef = toRef(state, 'foo')
|
|
627
|
+
*
|
|
628
|
+
* // mutating the ref updates the original
|
|
629
|
+
* fooRef.value++
|
|
630
|
+
* console.log(state.foo) // 2
|
|
631
|
+
*
|
|
632
|
+
* // mutating the original also updates the ref
|
|
633
|
+
* state.foo++
|
|
634
|
+
* console.log(fooRef.value) // 3
|
|
635
|
+
* ```
|
|
636
|
+
*
|
|
637
|
+
* @param source - A getter, an existing ref, a non-function value, or a
|
|
638
|
+
* reactive object to create a property ref from.
|
|
639
|
+
* @param [key] - (optional) Name of the property in the reactive object.
|
|
640
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
|
|
641
|
+
*/
|
|
642
|
+
export declare function toRef<T>(value: T): T extends () => infer R ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>;
|
|
240
643
|
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
|
|
241
644
|
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
|
|
242
645
|
type BaseTypes = string | number | boolean;
|
|
@@ -1058,6 +1058,9 @@ function triggerRef(ref2) {
|
|
|
1058
1058
|
function unref(ref2) {
|
|
1059
1059
|
return isRef(ref2) ? ref2.value : ref2;
|
|
1060
1060
|
}
|
|
1061
|
+
function toValue(source) {
|
|
1062
|
+
return isFunction(source) ? source() : unref(source);
|
|
1063
|
+
}
|
|
1061
1064
|
const shallowUnwrapHandlers = {
|
|
1062
1065
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1063
1066
|
set: (target, key, value, receiver) => {
|
|
@@ -1100,7 +1103,7 @@ function toRefs(object) {
|
|
|
1100
1103
|
}
|
|
1101
1104
|
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1102
1105
|
for (const key in object) {
|
|
1103
|
-
ret[key] =
|
|
1106
|
+
ret[key] = propertyToRef(object, key);
|
|
1104
1107
|
}
|
|
1105
1108
|
return ret;
|
|
1106
1109
|
}
|
|
@@ -1122,9 +1125,34 @@ class ObjectRefImpl {
|
|
|
1122
1125
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1123
1126
|
}
|
|
1124
1127
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
+
class GetterRefImpl {
|
|
1129
|
+
constructor(_getter) {
|
|
1130
|
+
this._getter = _getter;
|
|
1131
|
+
this.__v_isRef = true;
|
|
1132
|
+
this.__v_isReadonly = true;
|
|
1133
|
+
}
|
|
1134
|
+
get value() {
|
|
1135
|
+
return this._getter();
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
function toRef(source, key, defaultValue) {
|
|
1139
|
+
if (isRef(source)) {
|
|
1140
|
+
return source;
|
|
1141
|
+
} else if (isFunction(source)) {
|
|
1142
|
+
return new GetterRefImpl(source);
|
|
1143
|
+
} else if (isObject(source) && arguments.length > 1) {
|
|
1144
|
+
return propertyToRef(source, key, defaultValue);
|
|
1145
|
+
} else {
|
|
1146
|
+
return ref(source);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1150
|
+
const val = source[key];
|
|
1151
|
+
return isRef(val) ? val : new ObjectRefImpl(
|
|
1152
|
+
source,
|
|
1153
|
+
key,
|
|
1154
|
+
defaultValue
|
|
1155
|
+
);
|
|
1128
1156
|
}
|
|
1129
1157
|
|
|
1130
1158
|
class ComputedRefImpl {
|
|
@@ -1249,4 +1277,4 @@ function deferredComputed(getter) {
|
|
|
1249
1277
|
return new DeferredComputedRefImpl(getter);
|
|
1250
1278
|
}
|
|
1251
1279
|
|
|
1252
|
-
export { EffectScope, ITERATE_KEY, ReactiveEffect, 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 };
|
|
1280
|
+
export { EffectScope, ITERATE_KEY, ReactiveEffect, 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, toValue, track, trigger, triggerRef, unref };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=()=>{},n=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),r=Array.isArray,c=t=>"[object Map]"===a(t),o=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,a=t=>h.call(t),l=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,f=(t,e)=>!Object.is(t,e);let _;class d{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=_,!t&&_&&(this.index=(_.scopes||(_.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=_;try{return _=this,t()}finally{_=e}}}on(){_=this}off(){_=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function p(t){return new d(t)}function v(t,e=_){e&&e.active&&e.effects.push(t)}function g(){return _}function y(t){_&&_.cleanups.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},b=t=>(t.w&k)>0,R=t=>(t.n&k)>0,m=new WeakMap;let S=0,k=1;let O;const j=Symbol(""),x=Symbol("");class P{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,v(this,n)}run(){if(!this.active)return this.fn();let t=O,e=W;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=O,O=this,W=!0,k=1<<++S,S<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=k})(this):E(this),this.fn()}finally{S<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];b(i)&&!R(i)?i.delete(t):e[n++]=i,i.w&=~k,i.n&=~k}e.length=n}})(this),k=1<<--S,O=this.parent,W=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){O===this?this.deferStop=!0:this.active&&(E(this),this.onStop&&this.onStop(),this.active=!1)}}function E(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function M(t,e){t.effect&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&v(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function z(t){t.effect.stop()}let W=!0;const V=[];function N(){V.push(W),W=!1}function A(){V.push(W),W=!0}function I(){const t=V.pop();W=void 0===t||t}function K(t,e,n){if(W&&O){let e=m.get(t);e||m.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=w()),C(s)}}function C(t,e){let n=!1;S<=30?R(t)||(t.n|=k,n=!b(t)):n=!t.has(O),n&&(t.add(O),O.deps.push(t))}function L(t,e,n,s,i,o){const u=m.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&h.push(e)}))}else switch(void 0!==n&&h.push(u.get(n)),e){case"add":r(t)?l(n)&&h.push(u.get("length")):(h.push(u.get(j)),c(t)&&h.push(u.get(x)));break;case"delete":r(t)||(h.push(u.get(j)),c(t)&&h.push(u.get(x)));break;case"set":c(t)&&h.push(u.get(j))}if(1===h.length)h[0]&&q(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);q(w(t))}}function q(t,e){const n=r(t)?t:[...t];for(const s of n)s.computed&&B(s);for(const s of n)s.computed||B(s)}function B(t,e){(t!==O||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=t("__proto__,__v_isRef,__isVue"),F=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(o)),G=Y(),H=Y(!1,!0),J=Y(!0),Q=Y(!0,!0),T=U();function U(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=Lt(this);for(let e=0,i=this.length;e<i;e++)K(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Lt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){N();const n=Lt(this)[e].apply(this,t);return I(),n}})),t}function X(t){const e=Lt(this);return K(e,0,t),e.hasOwnProperty(t)}function Y(t=!1,e=!1){return function(n,s,c){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&c===(t?e?Pt:xt:e?jt:Ot).get(n))return n;const h=r(n);if(!t){if(h&&i(T,s))return Reflect.get(T,s,c);if("hasOwnProperty"===s)return X}const a=Reflect.get(n,s,c);return(o(s)?F.has(s):D(s))?a:(t||K(n,0,s),e?a:Ht(a)?h&&l(s)?a:a.value:u(a)?t?Wt(a):Mt(a):a)}}function Z(t=!1){return function(e,n,s,c){let o=e[n];if(It(o)&&Ht(o)&&!Ht(s))return!1;if(!t&&(Kt(s)||It(s)||(o=Lt(o),s=Lt(s)),!r(e)&&Ht(o)&&!Ht(s)))return o.value=s,!0;const u=r(e)&&l(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===Lt(c)&&(u?f(s,o)&&L(e,"set",n,s):L(e,"add",n,s)),h}}const $={get:G,set:Z(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&L(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return o(e)&&F.has(e)||K(t,0,e),n},ownKeys:function(t){return K(t,0,r(t)?"length":j),Reflect.ownKeys(t)}},tt={get:J,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},et=n({},$,{get:H,set:Z(!0)}),nt=n({},tt,{get:Q}),st=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,n=!1,s=!1){const i=Lt(t=t.__v_raw),r=Lt(e);n||(e!==r&&K(i,0,e),K(i,0,r));const{has:c}=it(i),o=s?st:n?Dt:Bt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const n=this.__v_raw,s=Lt(n),i=Lt(t);return e||(t!==i&&K(s,0,t),K(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function ot(t,e=!1){return t=t.__v_raw,!e&&K(Lt(t),0,j),Reflect.get(t,"size",t)}function ut(t){t=Lt(t);const e=Lt(this);return it(e).has.call(e,t)||(e.add(t),L(e,"add",t,t)),this}function ht(t,e){e=Lt(e);const n=Lt(this),{has:s,get:i}=it(n);let r=s.call(n,t);r||(t=Lt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?f(e,c)&&L(n,"set",t,e):L(n,"add",t,e),this}function at(t){const e=Lt(this),{has:n,get:s}=it(e);let i=n.call(e,t);i||(t=Lt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&L(e,"delete",t,void 0),r}function lt(){const t=Lt(this),e=0!==t.size,n=t.clear();return e&&L(t,"clear",void 0,void 0),n}function ft(t,e){return function(n,s){const i=this,r=i.__v_raw,c=Lt(r),o=e?st:t?Dt:Bt;return!t&&K(c,0,j),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function _t(t,e,n){return function(...s){const i=this.__v_raw,r=Lt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...s),l=n?st:e?Dt:Bt;return!e&&K(r,0,h?x:j),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&this}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},n={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},s={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),n[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),s[i]=_t(i,!0,!0)})),[t,n,e,s]}const[vt,gt,yt,wt]=pt();function bt(t,e){const n=e?t?wt:yt:t?gt:vt;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const Rt={get:bt(!1,!1)},mt={get:bt(!1,!0)},St={get:bt(!0,!1)},kt={get:bt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>a(t).slice(8,-1))(t))}function Mt(t){return It(t)?t:Nt(t,!1,$,Rt,Ot)}function zt(t){return Nt(t,!1,et,mt,jt)}function Wt(t){return Nt(t,!0,tt,St,xt)}function Vt(t){return Nt(t,!0,nt,kt,Pt)}function Nt(t,e,n,s,i){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Et(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function At(t){return It(t)?At(t.__v_raw):!(!t||!t.__v_isReactive)}function It(t){return!(!t||!t.__v_isReadonly)}function Kt(t){return!(!t||!t.__v_isShallow)}function Ct(t){return At(t)||It(t)}function Lt(t){const e=t&&t.__v_raw;return e?Lt(e):t}function qt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Bt=t=>u(t)?Mt(t):t,Dt=t=>u(t)?Wt(t):t;function Ft(t){W&&O&&C((t=Lt(t)).dep||(t.dep=w()))}function Gt(t,e){const n=(t=Lt(t)).dep;n&&q(n)}function Ht(t){return!(!t||!0!==t.__v_isRef)}function Jt(t){return Tt(t,!1)}function Qt(t){return Tt(t,!0)}function Tt(t,e){return Ht(t)?t:new Ut(t,e)}class Ut{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Lt(t),this._value=e?t:Bt(t)}get value(){return Ft(this),this._value}set value(t){const e=this.__v_isShallow||Kt(t)||It(t);t=e?t:Lt(t),f(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Bt(t),Gt(this))}}function Xt(t){Gt(t)}function Yt(t){return Ht(t)?t.value:t}const Zt={get:(t,e,n)=>Yt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Ht(i)&&!Ht(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function $t(t){return At(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Ft(this)),(()=>Gt(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function ne(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ie(t,n);return e}class se{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Lt(this._object),e=this._key,null==(n=m.get(t))?void 0:n.get(e);var t,e,n}}function ie(t,e,n){const s=t[e];return Ht(s)?s:new se(t,e,n)}class re{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,Gt(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=Lt(this);return Ft(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ce(t,n,s=!1){let i,r;const c="function"==typeof t;c?(i=t,r=e):(i=t.get,r=t.set);return new re(i,r,c||!r,s)}const oe=Promise.resolve(),ue=[];let he=!1;const ae=()=>{for(let t=0;t<ue.length;t++)ue[t]();ue.length=0,he=!1};class le{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new P(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,ue.push((()=>{this.effect.active&&this._get()!==t&&Gt(this),s=!1})),he||(he=!0,oe.then(ae))}for(const t of this.dep)t.computed instanceof le&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Ft(this),Lt(this)._get()}}function fe(t){return new le(t)}export{d as EffectScope,j as ITERATE_KEY,P as ReactiveEffect,ce as computed,ee as customRef,fe as deferredComputed,M as effect,p as effectScope,A as enableTracking,g as getCurrentScope,Ct as isProxy,At as isReactive,It as isReadonly,Ht as isRef,Kt as isShallow,qt as markRaw,y as onScopeDispose,N as pauseTracking,$t as proxyRefs,Mt as reactive,Wt as readonly,Jt as ref,I as resetTracking,zt as shallowReactive,Vt as shallowReadonly,Qt as shallowRef,z as stop,Lt as toRaw,ie as toRef,ne as toRefs,K as track,L as trigger,Xt as triggerRef,Yt as unref};
|
|
1
|
+
function t(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=()=>{},n=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>!Object.is(t,e);let d;class p{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=d,!t&&d&&(this.index=(d.scopes||(d.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=d;try{return d=this,t()}finally{d=e}}}on(){d=this}off(){d=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function v(t){return new p(t)}function g(t,e=d){e&&e.active&&e.effects.push(t)}function y(){return d}function w(t){d&&d.cleanups.push(t)}const b=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&O)>0,m=t=>(t.n&O)>0,S=new WeakMap;let k=0,O=1;let j;const x=Symbol(""),P=Symbol("");class E{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,g(this,n)}run(){if(!this.active)return this.fn();let t=j,e=V;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,V=!0,O=1<<++k,k<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=O})(this):M(this),this.fn()}finally{k<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];R(i)&&!m(i)?i.delete(t):e[n++]=i,i.w&=~O,i.n&=~O}e.length=n}})(this),O=1<<--k,j=this.parent,V=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function z(t,e){t.effect&&(t=t.effect.fn);const s=new E(t);e&&(n(s,e),e.scope&&g(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function W(t){t.effect.stop()}let V=!0;const N=[];function A(){N.push(V),V=!1}function I(){N.push(V),V=!0}function K(){const t=N.pop();V=void 0===t||t}function C(t,e,n){if(V&&j){let e=S.get(t);e||S.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=b()),L(s)}}function L(t,e){let n=!1;k<=30?m(t)||(t.n|=O,n=!R(t)):n=!t.has(j),n&&(t.add(j),j.deps.push(t))}function q(t,e,n,s,i,o){const u=S.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&h.push(e)}))}else switch(void 0!==n&&h.push(u.get(n)),e){case"add":r(t)?f(n)&&h.push(u.get("length")):(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"delete":r(t)||(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"set":c(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&B(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);B(b(t))}}function B(t,e){const n=r(t)?t:[...t];for(const s of n)s.computed&&D(s);for(const s of n)s.computed||D(s)}function D(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const F=t("__proto__,__v_isRef,__isVue"),G=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),H=Z(),J=Z(!1,!0),Q=Z(!0),T=Z(!0,!0),U=X();function X(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=qt(this);for(let e=0,i=this.length;e<i;e++)C(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(qt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){A();const n=qt(this)[e].apply(this,t);return K(),n}})),t}function Y(t){const e=qt(this);return C(e,0,t),e.hasOwnProperty(t)}function Z(t=!1,e=!1){return function(n,s,c){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&c===(t?e?Et:Pt:e?xt:jt).get(n))return n;const o=r(n);if(!t){if(o&&i(U,s))return Reflect.get(U,s,c);if("hasOwnProperty"===s)return Y}const a=Reflect.get(n,s,c);return(u(s)?G.has(s):F(s))?a:(t||C(n,0,s),e?a:Jt(a)?o&&f(s)?a:a.value:h(a)?t?Vt(a):zt(a):a)}}function $(t=!1){return function(e,n,s,c){let o=e[n];if(Kt(o)&&Jt(o)&&!Jt(s))return!1;if(!t&&(Ct(s)||Kt(s)||(o=qt(o),s=qt(s)),!r(e)&&Jt(o)&&!Jt(s)))return o.value=s,!0;const u=r(e)&&f(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===qt(c)&&(u?_(s,o)&&q(e,"set",n,s):q(e,"add",n,s)),h}}const tt={get:H,set:$(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&q(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&G.has(e)||C(t,0,e),n},ownKeys:function(t){return C(t,0,r(t)?"length":x),Reflect.ownKeys(t)}},et={get:Q,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},nt=n({},tt,{get:J,set:$(!0)}),st=n({},et,{get:T}),it=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ct(t,e,n=!1,s=!1){const i=qt(t=t.__v_raw),r=qt(e);n||(e!==r&&C(i,0,e),C(i,0,r));const{has:c}=rt(i),o=s?it:n?Ft:Dt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ot(t,e=!1){const n=this.__v_raw,s=qt(n),i=qt(t);return e||(t!==i&&C(s,0,t),C(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function ut(t,e=!1){return t=t.__v_raw,!e&&C(qt(t),0,x),Reflect.get(t,"size",t)}function ht(t){t=qt(t);const e=qt(this);return rt(e).has.call(e,t)||(e.add(t),q(e,"add",t,t)),this}function at(t,e){e=qt(e);const n=qt(this),{has:s,get:i}=rt(n);let r=s.call(n,t);r||(t=qt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?_(e,c)&&q(n,"set",t,e):q(n,"add",t,e),this}function lt(t){const e=qt(this),{has:n,get:s}=rt(e);let i=n.call(e,t);i||(t=qt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&q(e,"delete",t,void 0),r}function ft(){const t=qt(this),e=0!==t.size,n=t.clear();return e&&q(t,"clear",void 0,void 0),n}function _t(t,e){return function(n,s){const i=this,r=i.__v_raw,c=qt(r),o=e?it:t?Ft:Dt;return!t&&C(c,0,x),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function dt(t,e,n){return function(...s){const i=this.__v_raw,r=qt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...s),l=n?it:e?Ft:Dt;return!e&&C(r,0,h?P:x),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function pt(t){return function(...e){return"delete"!==t&&this}}function vt(){const t={get(t){return ct(this,t)},get size(){return ut(this)},has:ot,add:ht,set:at,delete:lt,clear:ft,forEach:_t(!1,!1)},e={get(t){return ct(this,t,!1,!0)},get size(){return ut(this)},has:ot,add:ht,set:at,delete:lt,clear:ft,forEach:_t(!1,!0)},n={get(t){return ct(this,t,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!1)},s={get(t){return ct(this,t,!0,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=dt(i,!1,!1),n[i]=dt(i,!0,!1),e[i]=dt(i,!1,!0),s[i]=dt(i,!0,!0)})),[t,n,e,s]}const[gt,yt,wt,bt]=vt();function Rt(t,e){const n=e?t?bt:wt:t?yt:gt;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const mt={get:Rt(!1,!1)},St={get:Rt(!1,!0)},kt={get:Rt(!0,!1)},Ot={get:Rt(!0,!0)},jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap,Et=new WeakMap;function Mt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>l(t).slice(8,-1))(t))}function zt(t){return Kt(t)?t:At(t,!1,tt,mt,jt)}function Wt(t){return At(t,!1,nt,St,xt)}function Vt(t){return At(t,!0,et,kt,Pt)}function Nt(t){return At(t,!0,st,Ot,Et)}function At(t,e,n,s,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Mt(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function It(t){return Kt(t)?It(t.__v_raw):!(!t||!t.__v_isReactive)}function Kt(t){return!(!t||!t.__v_isReadonly)}function Ct(t){return!(!t||!t.__v_isShallow)}function Lt(t){return It(t)||Kt(t)}function qt(t){const e=t&&t.__v_raw;return e?qt(e):t}function Bt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Dt=t=>h(t)?zt(t):t,Ft=t=>h(t)?Vt(t):t;function Gt(t){V&&j&&L((t=qt(t)).dep||(t.dep=b()))}function Ht(t,e){const n=(t=qt(t)).dep;n&&B(n)}function Jt(t){return!(!t||!0!==t.__v_isRef)}function Qt(t){return Ut(t,!1)}function Tt(t){return Ut(t,!0)}function Ut(t,e){return Jt(t)?t:new Xt(t,e)}class Xt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:qt(t),this._value=e?t:Dt(t)}get value(){return Gt(this),this._value}set value(t){const e=this.__v_isShallow||Ct(t)||Kt(t);t=e?t:qt(t),_(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Dt(t),Ht(this))}}function Yt(t){Ht(t)}function Zt(t){return Jt(t)?t.value:t}function $t(t){return o(t)?t():Zt(t)}const te={get:(t,e,n)=>Zt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Jt(i)&&!Jt(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function ee(t){return It(t)?t:new Proxy(t,te)}class ne{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Gt(this)),(()=>Ht(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function se(t){return new ne(t)}function ie(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ue(t,n);return e}class re{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=qt(this._object),e=this._key,null==(n=S.get(t))?void 0:n.get(e);var t,e,n}}class ce{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function oe(t,e,n){return Jt(t)?t:o(t)?new ce(t):h(t)&&arguments.length>1?ue(t,e,n):Qt(t)}function ue(t,e,n){const s=t[e];return Jt(s)?s:new re(t,e,n)}class he{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new E(t,(()=>{this._dirty||(this._dirty=!0,Ht(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=qt(this);return Gt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ae(t,n,s=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new he(i,r,c||!r,s)}const le=Promise.resolve(),fe=[];let _e=!1;const de=()=>{for(let t=0;t<fe.length;t++)fe[t]();fe.length=0,_e=!1};class pe{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new E(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,fe.push((()=>{this.effect.active&&this._get()!==t&&Ht(this),s=!1})),_e||(_e=!0,le.then(de))}for(const t of this.dep)t.computed instanceof pe&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Gt(this),qt(this)._get()}}function ve(t){return new pe(t)}export{p as EffectScope,x as ITERATE_KEY,E as ReactiveEffect,ae as computed,se as customRef,ve as deferredComputed,z as effect,v as effectScope,I as enableTracking,y as getCurrentScope,Lt as isProxy,It as isReactive,Kt as isReadonly,Jt as isRef,Ct as isShallow,Bt as markRaw,w as onScopeDispose,A as pauseTracking,ee as proxyRefs,zt as reactive,Vt as readonly,Qt as ref,K as resetTracking,Wt as shallowReactive,Nt as shallowReadonly,Tt as shallowRef,W as stop,qt as toRaw,oe as toRef,ie as toRefs,$t as toValue,C as track,q as trigger,Yt as triggerRef,Zt as unref};
|
|
@@ -1025,6 +1025,9 @@ function triggerRef(ref2) {
|
|
|
1025
1025
|
function unref(ref2) {
|
|
1026
1026
|
return isRef(ref2) ? ref2.value : ref2;
|
|
1027
1027
|
}
|
|
1028
|
+
function toValue(source) {
|
|
1029
|
+
return isFunction(source) ? source() : unref(source);
|
|
1030
|
+
}
|
|
1028
1031
|
const shallowUnwrapHandlers = {
|
|
1029
1032
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1030
1033
|
set: (target, key, value, receiver) => {
|
|
@@ -1067,7 +1070,7 @@ function toRefs(object) {
|
|
|
1067
1070
|
}
|
|
1068
1071
|
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1069
1072
|
for (const key in object) {
|
|
1070
|
-
ret[key] =
|
|
1073
|
+
ret[key] = propertyToRef(object, key);
|
|
1071
1074
|
}
|
|
1072
1075
|
return ret;
|
|
1073
1076
|
}
|
|
@@ -1089,9 +1092,34 @@ class ObjectRefImpl {
|
|
|
1089
1092
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1090
1093
|
}
|
|
1091
1094
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
+
class GetterRefImpl {
|
|
1096
|
+
constructor(_getter) {
|
|
1097
|
+
this._getter = _getter;
|
|
1098
|
+
this.__v_isRef = true;
|
|
1099
|
+
this.__v_isReadonly = true;
|
|
1100
|
+
}
|
|
1101
|
+
get value() {
|
|
1102
|
+
return this._getter();
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
function toRef(source, key, defaultValue) {
|
|
1106
|
+
if (isRef(source)) {
|
|
1107
|
+
return source;
|
|
1108
|
+
} else if (isFunction(source)) {
|
|
1109
|
+
return new GetterRefImpl(source);
|
|
1110
|
+
} else if (isObject(source) && arguments.length > 1) {
|
|
1111
|
+
return propertyToRef(source, key, defaultValue);
|
|
1112
|
+
} else {
|
|
1113
|
+
return ref(source);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1117
|
+
const val = source[key];
|
|
1118
|
+
return isRef(val) ? val : new ObjectRefImpl(
|
|
1119
|
+
source,
|
|
1120
|
+
key,
|
|
1121
|
+
defaultValue
|
|
1122
|
+
);
|
|
1095
1123
|
}
|
|
1096
1124
|
|
|
1097
1125
|
class ComputedRefImpl {
|
|
@@ -1216,4 +1244,4 @@ function deferredComputed(getter) {
|
|
|
1216
1244
|
return new DeferredComputedRefImpl(getter);
|
|
1217
1245
|
}
|
|
1218
1246
|
|
|
1219
|
-
export { EffectScope, ITERATE_KEY, ReactiveEffect, 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 };
|
|
1247
|
+
export { EffectScope, ITERATE_KEY, ReactiveEffect, 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, toValue, track, trigger, triggerRef, unref };
|
|
@@ -1061,6 +1061,9 @@ var VueReactivity = (function (exports) {
|
|
|
1061
1061
|
function unref(ref2) {
|
|
1062
1062
|
return isRef(ref2) ? ref2.value : ref2;
|
|
1063
1063
|
}
|
|
1064
|
+
function toValue(source) {
|
|
1065
|
+
return isFunction(source) ? source() : unref(source);
|
|
1066
|
+
}
|
|
1064
1067
|
const shallowUnwrapHandlers = {
|
|
1065
1068
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1066
1069
|
set: (target, key, value, receiver) => {
|
|
@@ -1103,7 +1106,7 @@ var VueReactivity = (function (exports) {
|
|
|
1103
1106
|
}
|
|
1104
1107
|
const ret = isArray(object) ? new Array(object.length) : {};
|
|
1105
1108
|
for (const key in object) {
|
|
1106
|
-
ret[key] =
|
|
1109
|
+
ret[key] = propertyToRef(object, key);
|
|
1107
1110
|
}
|
|
1108
1111
|
return ret;
|
|
1109
1112
|
}
|
|
@@ -1125,9 +1128,34 @@ var VueReactivity = (function (exports) {
|
|
|
1125
1128
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1126
1129
|
}
|
|
1127
1130
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
+
class GetterRefImpl {
|
|
1132
|
+
constructor(_getter) {
|
|
1133
|
+
this._getter = _getter;
|
|
1134
|
+
this.__v_isRef = true;
|
|
1135
|
+
this.__v_isReadonly = true;
|
|
1136
|
+
}
|
|
1137
|
+
get value() {
|
|
1138
|
+
return this._getter();
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function toRef(source, key, defaultValue) {
|
|
1142
|
+
if (isRef(source)) {
|
|
1143
|
+
return source;
|
|
1144
|
+
} else if (isFunction(source)) {
|
|
1145
|
+
return new GetterRefImpl(source);
|
|
1146
|
+
} else if (isObject(source) && arguments.length > 1) {
|
|
1147
|
+
return propertyToRef(source, key, defaultValue);
|
|
1148
|
+
} else {
|
|
1149
|
+
return ref(source);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1153
|
+
const val = source[key];
|
|
1154
|
+
return isRef(val) ? val : new ObjectRefImpl(
|
|
1155
|
+
source,
|
|
1156
|
+
key,
|
|
1157
|
+
defaultValue
|
|
1158
|
+
);
|
|
1131
1159
|
}
|
|
1132
1160
|
|
|
1133
1161
|
class ComputedRefImpl {
|
|
@@ -1282,6 +1310,7 @@ var VueReactivity = (function (exports) {
|
|
|
1282
1310
|
exports.toRaw = toRaw;
|
|
1283
1311
|
exports.toRef = toRef;
|
|
1284
1312
|
exports.toRefs = toRefs;
|
|
1313
|
+
exports.toValue = toValue;
|
|
1285
1314
|
exports.track = track;
|
|
1286
1315
|
exports.trigger = trigger;
|
|
1287
1316
|
exports.triggerRef = triggerRef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueReactivity=function(t){"use strict";function e(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const n=()=>{},s=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===l(t),u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,l=t=>h.call(t),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>!Object.is(t,e);let d;class p{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=d,!t&&d&&(this.index=(d.scopes||(d.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=d;try{return d=this,t()}finally{d=e}}}on(){d=this}off(){d=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function v(t,e=d){e&&e.active&&e.effects.push(t)}const g=t=>{const e=new Set(t);return e.w=0,e.n=0,e},y=t=>(t.w&m)>0,w=t=>(t.n&m)>0,R=new WeakMap;let b=0,m=1;let S;const k=Symbol(""),O=Symbol("");class j{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,v(this,n)}run(){if(!this.active)return this.fn();let t=S,e=x;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=S,S=this,x=!0,m=1<<++b,b<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=m})(this):E(this),this.fn()}finally{b<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];y(i)&&!w(i)?i.delete(t):e[n++]=i,i.w&=~m,i.n&=~m}e.length=n}})(this),m=1<<--b,S=this.parent,x=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){S===this?this.deferStop=!0:this.active&&(E(this),this.onStop&&this.onStop(),this.active=!1)}}function E(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let x=!0;const P=[];function M(){P.push(x),x=!1}function z(){const t=P.pop();x=void 0===t||t}function V(t,e,n){if(x&&S){let e=R.get(t);e||R.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=g()),W(s)}}function W(t,e){let n=!1;b<=30?w(t)||(t.n|=m,n=!y(t)):n=!t.has(S),n&&(t.add(S),S.deps.push(t))}function A(t,e,n,s,i,r){const u=R.get(t);if(!u)return;let a=[];if("clear"===e)a=[...u.values()];else if("length"===n&&c(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&a.push(e)}))}else switch(void 0!==n&&a.push(u.get(n)),e){case"add":c(t)?f(n)&&a.push(u.get("length")):(a.push(u.get(k)),o(t)&&a.push(u.get(O)));break;case"delete":c(t)||(a.push(u.get(k)),o(t)&&a.push(u.get(O)));break;case"set":o(t)&&a.push(u.get(k))}if(1===a.length)a[0]&&N(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);N(g(t))}}function N(t,e){const n=c(t)?t:[...t];for(const s of n)s.computed&&T(s);for(const s of n)s.computed||T(s)}function T(t,e){(t!==S||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const C=e("__proto__,__v_isRef,__isVue"),I=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),K=G(),D=G(!1,!0),L=G(!0),Y=G(!0,!0),q=B();function B(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=zt(this);for(let e=0,i=this.length;e<i;e++)V(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(zt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){M();const n=zt(this)[e].apply(this,t);return z(),n}})),t}function F(t){const e=zt(this);return V(e,0,t),e.hasOwnProperty(t)}function G(t=!1,e=!1){return function(n,s,i){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&i===(t?e?St:mt:e?bt:Rt).get(n))return n;const o=c(n);if(!t){if(o&&r(q,s))return Reflect.get(q,s,i);if("hasOwnProperty"===s)return F}const h=Reflect.get(n,s,i);return(u(s)?I.has(s):C(s))?h:(t||V(n,0,s),e?h:Tt(h)?o&&f(s)?h:h.value:a(h)?t?jt(h):Ot(h):h)}}function H(t=!1){return function(e,n,s,i){let o=e[n];if(Pt(o)&&Tt(o)&&!Tt(s))return!1;if(!t&&(Mt(s)||Pt(s)||(o=zt(o),s=zt(s)),!c(e)&&Tt(o)&&!Tt(s)))return o.value=s,!0;const u=c(e)&&f(n)?Number(n)<e.length:r(e,n),a=Reflect.set(e,n,s,i);return e===zt(i)&&(u?_(s,o)&&A(e,"set",n,s):A(e,"add",n,s)),a}}const J={get:K,set:H(),deleteProperty:function(t,e){const n=r(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&A(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&I.has(e)||V(t,0,e),n},ownKeys:function(t){return V(t,0,c(t)?"length":k),Reflect.ownKeys(t)}},Q={get:L,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},U=s({},J,{get:D,set:H(!0)}),X=s({},Q,{get:Y}),Z=t=>t,$=t=>Reflect.getPrototypeOf(t);function tt(t,e,n=!1,s=!1){const i=zt(t=t.__v_raw),r=zt(e);n||(e!==r&&V(i,0,e),V(i,0,r));const{has:c}=$(i),o=s?Z:n?Wt:Vt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function et(t,e=!1){const n=this.__v_raw,s=zt(n),i=zt(t);return e||(t!==i&&V(s,0,t),V(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function nt(t,e=!1){return t=t.__v_raw,!e&&V(zt(t),0,k),Reflect.get(t,"size",t)}function st(t){t=zt(t);const e=zt(this);return $(e).has.call(e,t)||(e.add(t),A(e,"add",t,t)),this}function it(t,e){e=zt(e);const n=zt(this),{has:s,get:i}=$(n);let r=s.call(n,t);r||(t=zt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?_(e,c)&&A(n,"set",t,e):A(n,"add",t,e),this}function rt(t){const e=zt(this),{has:n,get:s}=$(e);let i=n.call(e,t);i||(t=zt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&A(e,"delete",t,void 0),r}function ct(){const t=zt(this),e=0!==t.size,n=t.clear();return e&&A(t,"clear",void 0,void 0),n}function ot(t,e){return function(n,s){const i=this,r=i.__v_raw,c=zt(r),o=e?Z:t?Wt:Vt;return!t&&V(c,0,k),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function ut(t,e,n){return function(...s){const i=this.__v_raw,r=zt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...s),l=n?Z:e?Wt:Vt;return!e&&V(r,0,a?O:k),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function at(t){return function(...e){return"delete"!==t&&this}}function ht(){const t={get(t){return tt(this,t)},get size(){return nt(this)},has:et,add:st,set:it,delete:rt,clear:ct,forEach:ot(!1,!1)},e={get(t){return tt(this,t,!1,!0)},get size(){return nt(this)},has:et,add:st,set:it,delete:rt,clear:ct,forEach:ot(!1,!0)},n={get(t){return tt(this,t,!0)},get size(){return nt(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!1)},s={get(t){return tt(this,t,!0,!0)},get size(){return nt(this,!0)},has(t){return et.call(this,t,!0)},add:at("add"),set:at("set"),delete:at("delete"),clear:at("clear"),forEach:ot(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ut(i,!1,!1),n[i]=ut(i,!0,!1),e[i]=ut(i,!1,!0),s[i]=ut(i,!0,!0)})),[t,n,e,s]}const[lt,ft,_t,dt]=ht();function pt(t,e){const n=e?t?dt:_t:t?ft:lt;return(e,s,i)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(r(n,s)&&s in e?n:e,s,i)}const vt={get:pt(!1,!1)},gt={get:pt(!1,!0)},yt={get:pt(!0,!1)},wt={get:pt(!0,!0)},Rt=new WeakMap,bt=new WeakMap,mt=new WeakMap,St=new WeakMap;function kt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>l(t).slice(8,-1))(t))}function Ot(t){return Pt(t)?t:Et(t,!1,J,vt,Rt)}function jt(t){return Et(t,!0,Q,yt,mt)}function Et(t,e,n,s,i){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=kt(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function xt(t){return Pt(t)?xt(t.__v_raw):!(!t||!t.__v_isReactive)}function Pt(t){return!(!t||!t.__v_isReadonly)}function Mt(t){return!(!t||!t.__v_isShallow)}function zt(t){const e=t&&t.__v_raw;return e?zt(e):t}const Vt=t=>a(t)?Ot(t):t,Wt=t=>a(t)?jt(t):t;function At(t){x&&S&&W((t=zt(t)).dep||(t.dep=g()))}function Nt(t,e){const n=(t=zt(t)).dep;n&&N(n)}function Tt(t){return!(!t||!0!==t.__v_isRef)}function Ct(t,e){return Tt(t)?t:new It(t,e)}class It{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:zt(t),this._value=e?t:Vt(t)}get value(){return At(this),this._value}set value(t){const e=this.__v_isShallow||Mt(t)||Pt(t);t=e?t:zt(t),_(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Vt(t),Nt(this))}}function Kt(t){return Tt(t)?t.value:t}const Dt={get:(t,e,n)=>Kt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Tt(i)&&!Tt(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};class Lt{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>At(this)),(()=>Nt(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=zt(this._object),e=this._key,null==(n=R.get(t))?void 0:n.get(e);var t,e,n}}function qt(t,e,n){const s=t[e];return Tt(s)?s:new Yt(t,e,n)}class Bt{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new j(t,(()=>{this._dirty||(this._dirty=!0,Nt(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=zt(this);return At(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Ft=Promise.resolve(),Gt=[];let Ht=!1;const Jt=()=>{for(let t=0;t<Gt.length;t++)Gt[t]();Gt.length=0,Ht=!1};class Qt{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new j(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,Gt.push((()=>{this.effect.active&&this._get()!==t&&Nt(this),s=!1})),Ht||(Ht=!0,Ft.then(Jt))}for(const t of this.dep)t.computed instanceof Qt&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return At(this),zt(this)._get()}}return t.EffectScope=p,t.ITERATE_KEY=k,t.ReactiveEffect=j,t.computed=function(t,e,s=!1){let i,r;const c="function"==typeof t;return c?(i=t,r=n):(i=t.get,r=t.set),new Bt(i,r,c||!r,s)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Qt(t)},t.effect=function(t,e){t.effect&&(t=t.effect.fn);const n=new j(t);e&&(s(n,e),e.scope&&v(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i},t.effectScope=function(t){return new p(t)},t.enableTracking=function(){P.push(x),x=!0},t.getCurrentScope=function(){return d},t.isProxy=function(t){return xt(t)||Pt(t)},t.isReactive=xt,t.isReadonly=Pt,t.isRef=Tt,t.isShallow=Mt,t.markRaw=function(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){d&&d.cleanups.push(t)},t.pauseTracking=M,t.proxyRefs=function(t){return xt(t)?t:new Proxy(t,Dt)},t.reactive=Ot,t.readonly=jt,t.ref=function(t){return Ct(t,!1)},t.resetTracking=z,t.shallowReactive=function(t){return Et(t,!1,U,gt,bt)},t.shallowReadonly=function(t){return Et(t,!0,X,wt,St)},t.shallowRef=function(t){return Ct(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=zt,t.toRef=qt,t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const n in t)e[n]=qt(t,n);return e},t.track=V,t.trigger=A,t.triggerRef=function(t){Nt(t)},t.unref=Kt,t}({});
|
|
1
|
+
var VueReactivity=function(t){"use strict";function e(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const n=()=>{},s=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t,e=p){e&&e.active&&e.effects.push(t)}const y=t=>{const e=new Set(t);return e.w=0,e.n=0,e},w=t=>(t.w&S)>0,R=t=>(t.n&S)>0,b=new WeakMap;let m=0,S=1;let k;const O=Symbol(""),j=Symbol("");class E{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,g(this,n)}run(){if(!this.active)return this.fn();let t=k,e=P;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=k,k=this,P=!0,S=1<<++m,m<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=S})(this):x(this),this.fn()}finally{m<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];w(i)&&!R(i)?i.delete(t):e[n++]=i,i.w&=~S,i.n&=~S}e.length=n}})(this),S=1<<--m,k=this.parent,P=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){k===this?this.deferStop=!0:this.active&&(x(this),this.onStop&&this.onStop(),this.active=!1)}}function x(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let P=!0;const M=[];function V(){M.push(P),P=!1}function z(){const t=M.pop();P=void 0===t||t}function W(t,e,n){if(P&&k){let e=b.get(t);e||b.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=y()),A(s)}}function A(t,e){let n=!1;m<=30?R(t)||(t.n|=S,n=!w(t)):n=!t.has(k),n&&(t.add(k),k.deps.push(t))}function N(t,e,n,s,i,r){const u=b.get(t);if(!u)return;let a=[];if("clear"===e)a=[...u.values()];else if("length"===n&&c(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&a.push(e)}))}else switch(void 0!==n&&a.push(u.get(n)),e){case"add":c(t)?_(n)&&a.push(u.get("length")):(a.push(u.get(O)),o(t)&&a.push(u.get(j)));break;case"delete":c(t)||(a.push(u.get(O)),o(t)&&a.push(u.get(j)));break;case"set":o(t)&&a.push(u.get(O))}if(1===a.length)a[0]&&T(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);T(y(t))}}function T(t,e){const n=c(t)?t:[...t];for(const s of n)s.computed&&C(s);for(const s of n)s.computed||C(s)}function C(t,e){(t!==k||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const I=e("__proto__,__v_isRef,__isVue"),K=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),D=H(),L=H(!1,!0),Y=H(!0),q=H(!0,!0),B=F();function F(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=zt(this);for(let e=0,i=this.length;e<i;e++)W(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(zt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){V();const n=zt(this)[e].apply(this,t);return z(),n}})),t}function G(t){const e=zt(this);return W(e,0,t),e.hasOwnProperty(t)}function H(t=!1,e=!1){return function(n,s,i){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&i===(t?e?kt:St:e?mt:bt).get(n))return n;const o=c(n);if(!t){if(o&&r(B,s))return Reflect.get(B,s,i);if("hasOwnProperty"===s)return G}const u=Reflect.get(n,s,i);return(a(s)?K.has(s):I(s))?u:(t||W(n,0,s),e?u:Ct(u)?o&&_(s)?u:u.value:h(u)?t?Et(u):jt(u):u)}}function J(t=!1){return function(e,n,s,i){let o=e[n];if(Mt(o)&&Ct(o)&&!Ct(s))return!1;if(!t&&(Vt(s)||Mt(s)||(o=zt(o),s=zt(s)),!c(e)&&Ct(o)&&!Ct(s)))return o.value=s,!0;const u=c(e)&&_(n)?Number(n)<e.length:r(e,n),a=Reflect.set(e,n,s,i);return e===zt(i)&&(u?d(s,o)&&N(e,"set",n,s):N(e,"add",n,s)),a}}const Q={get:D,set:J(),deleteProperty:function(t,e){const n=r(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&N(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return a(e)&&K.has(e)||W(t,0,e),n},ownKeys:function(t){return W(t,0,c(t)?"length":O),Reflect.ownKeys(t)}},U={get:Y,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},X=s({},Q,{get:L,set:J(!0)}),Z=s({},U,{get:q}),$=t=>t,tt=t=>Reflect.getPrototypeOf(t);function et(t,e,n=!1,s=!1){const i=zt(t=t.__v_raw),r=zt(e);n||(e!==r&&W(i,0,e),W(i,0,r));const{has:c}=tt(i),o=s?$:n?At:Wt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function nt(t,e=!1){const n=this.__v_raw,s=zt(n),i=zt(t);return e||(t!==i&&W(s,0,t),W(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function st(t,e=!1){return t=t.__v_raw,!e&&W(zt(t),0,O),Reflect.get(t,"size",t)}function it(t){t=zt(t);const e=zt(this);return tt(e).has.call(e,t)||(e.add(t),N(e,"add",t,t)),this}function rt(t,e){e=zt(e);const n=zt(this),{has:s,get:i}=tt(n);let r=s.call(n,t);r||(t=zt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?d(e,c)&&N(n,"set",t,e):N(n,"add",t,e),this}function ct(t){const e=zt(this),{has:n,get:s}=tt(e);let i=n.call(e,t);i||(t=zt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&N(e,"delete",t,void 0),r}function ot(){const t=zt(this),e=0!==t.size,n=t.clear();return e&&N(t,"clear",void 0,void 0),n}function ut(t,e){return function(n,s){const i=this,r=i.__v_raw,c=zt(r),o=e?$:t?At:Wt;return!t&&W(c,0,O),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function at(t,e,n){return function(...s){const i=this.__v_raw,r=zt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,h=i[t](...s),l=n?$:e?At:Wt;return!e&&W(r,0,a?j:O),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function ht(t){return function(...e){return"delete"!==t&&this}}function lt(){const t={get(t){return et(this,t)},get size(){return st(this)},has:nt,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!1)},e={get(t){return et(this,t,!1,!0)},get size(){return st(this)},has:nt,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!0)},n={get(t){return et(this,t,!0)},get size(){return st(this,!0)},has(t){return nt.call(this,t,!0)},add:ht("add"),set:ht("set"),delete:ht("delete"),clear:ht("clear"),forEach:ut(!0,!1)},s={get(t){return et(this,t,!0,!0)},get size(){return st(this,!0)},has(t){return nt.call(this,t,!0)},add:ht("add"),set:ht("set"),delete:ht("delete"),clear:ht("clear"),forEach:ut(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=at(i,!1,!1),n[i]=at(i,!0,!1),e[i]=at(i,!1,!0),s[i]=at(i,!0,!0)})),[t,n,e,s]}const[ft,_t,dt,pt]=lt();function vt(t,e){const n=e?t?pt:dt:t?_t:ft;return(e,s,i)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(r(n,s)&&s in e?n:e,s,i)}const gt={get:vt(!1,!1)},yt={get:vt(!1,!0)},wt={get:vt(!0,!1)},Rt={get:vt(!0,!0)},bt=new WeakMap,mt=new WeakMap,St=new WeakMap,kt=new WeakMap;function Ot(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>f(t).slice(8,-1))(t))}function jt(t){return Mt(t)?t:xt(t,!1,Q,gt,bt)}function Et(t){return xt(t,!0,U,wt,St)}function xt(t,e,n,s,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Ot(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function Pt(t){return Mt(t)?Pt(t.__v_raw):!(!t||!t.__v_isReactive)}function Mt(t){return!(!t||!t.__v_isReadonly)}function Vt(t){return!(!t||!t.__v_isShallow)}function zt(t){const e=t&&t.__v_raw;return e?zt(e):t}const Wt=t=>h(t)?jt(t):t,At=t=>h(t)?Et(t):t;function Nt(t){P&&k&&A((t=zt(t)).dep||(t.dep=y()))}function Tt(t,e){const n=(t=zt(t)).dep;n&&T(n)}function Ct(t){return!(!t||!0!==t.__v_isRef)}function It(t){return Kt(t,!1)}function Kt(t,e){return Ct(t)?t:new Dt(t,e)}class Dt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:zt(t),this._value=e?t:Wt(t)}get value(){return Nt(this),this._value}set value(t){const e=this.__v_isShallow||Vt(t)||Mt(t);t=e?t:zt(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Wt(t),Tt(this))}}function Lt(t){return Ct(t)?t.value:t}const Yt={get:(t,e,n)=>Lt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Ct(i)&&!Ct(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};class qt{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Nt(this)),(()=>Tt(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Bt{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=zt(this._object),e=this._key,null==(n=b.get(t))?void 0:n.get(e);var t,e,n}}class Ft{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function Gt(t,e,n){const s=t[e];return Ct(s)?s:new Bt(t,e,n)}class Ht{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new E(t,(()=>{this._dirty||(this._dirty=!0,Tt(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=zt(this);return Nt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const Jt=Promise.resolve(),Qt=[];let Ut=!1;const Xt=()=>{for(let t=0;t<Qt.length;t++)Qt[t]();Qt.length=0,Ut=!1};class Zt{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new E(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,Qt.push((()=>{this.effect.active&&this._get()!==t&&Tt(this),s=!1})),Ut||(Ut=!0,Jt.then(Xt))}for(const t of this.dep)t.computed instanceof Zt&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Nt(this),zt(this)._get()}}return t.EffectScope=v,t.ITERATE_KEY=O,t.ReactiveEffect=E,t.computed=function(t,e,s=!1){let i,r;const c=u(t);return c?(i=t,r=n):(i=t.get,r=t.set),new Ht(i,r,c||!r,s)},t.customRef=function(t){return new qt(t)},t.deferredComputed=function(t){return new Zt(t)},t.effect=function(t,e){t.effect&&(t=t.effect.fn);const n=new E(t);e&&(s(n,e),e.scope&&g(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i},t.effectScope=function(t){return new v(t)},t.enableTracking=function(){M.push(P),P=!0},t.getCurrentScope=function(){return p},t.isProxy=function(t){return Pt(t)||Mt(t)},t.isReactive=Pt,t.isReadonly=Mt,t.isRef=Ct,t.isShallow=Vt,t.markRaw=function(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){p&&p.cleanups.push(t)},t.pauseTracking=V,t.proxyRefs=function(t){return Pt(t)?t:new Proxy(t,Yt)},t.reactive=jt,t.readonly=Et,t.ref=It,t.resetTracking=z,t.shallowReactive=function(t){return xt(t,!1,X,yt,mt)},t.shallowReadonly=function(t){return xt(t,!0,Z,Rt,kt)},t.shallowRef=function(t){return Kt(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=zt,t.toRef=function(t,e,n){return Ct(t)?t:u(t)?new Ft(t):h(t)&&arguments.length>1?Gt(t,e,n):It(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const n in t)e[n]=Gt(t,n);return e},t.toValue=function(t){return u(t)?t():Lt(t)},t.track=W,t.trigger=N,t.triggerRef=function(t){Tt(t)},t.unref=Lt,t}({});
|
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.8",
|
|
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.8"
|
|
40
40
|
}
|
|
41
41
|
}
|