@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4070620250731002
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/easycom.d.ts +0 -1
- package/dist/easycom.js +13 -17
- package/dist/hbx/alias.js +10 -43
- package/dist/hbx/index.js +0 -10
- package/dist/hbx/log.js +1 -23
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +1 -2
- package/dist/json/manifest.d.ts +0 -1
- package/dist/json/manifest.js +1 -11
- package/dist/json/mp/jsonFile.js +2 -4
- package/dist/json/mp/pages.js +0 -1
- package/dist/json/mp/types.d.ts +1 -4
- package/dist/json/uni-x/manifest.d.ts +0 -1
- package/dist/json/uni-x/manifest.js +1 -5
- package/dist/messages/zh_CN.js +0 -1
- package/dist/uni_modules.cloud.d.ts +4 -10
- package/dist/uni_modules.cloud.js +19 -58
- package/dist/uni_modules.d.ts +0 -2
- package/dist/uni_modules.js +2 -81
- package/dist/uts.js +0 -16
- package/dist/vite/autoImport.js +0 -2
- package/dist/vite/cloud.js +5 -51
- package/dist/vite/plugins/index.d.ts +0 -1
- package/dist/vite/plugins/index.js +1 -3
- package/dist/vite/plugins/inject.js +1 -3
- package/dist/vite/plugins/uts/uni_modules.d.ts +0 -1
- package/dist/vite/plugins/uts/uni_modules.js +14 -63
- package/dist/vite/plugins/uts/uvue.js +3 -17
- package/dist/vite/plugins/vitejs/plugins/css.js +5 -40
- package/dist/vue/transforms/transformUTSComponent.js +3 -8
- package/package.json +38 -38
- package/dist/vite/plugins/stats.d.ts +0 -2
- package/dist/vite/plugins/stats.js +0 -42
- package/dist/workers.d.ts +0 -14
- package/dist/workers.js +0 -187
- package/lib/vapor/@vitejs/plugin-vue/LICENSE +0 -21
- package/lib/vapor/@vitejs/plugin-vue/README.md +0 -278
- package/lib/vapor/@vitejs/plugin-vue/dist/index.cjs +0 -3105
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.cts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.mts +0 -111
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.ts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.mjs +0 -3090
- package/lib/vapor/@vitejs/plugin-vue/package.json +0 -50
- package/lib/vapor/@vue/compiler-core/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-core/README.md +0 -1
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6902
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6779
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5870
- package/lib/vapor/@vue/compiler-core/index.js +0 -7
- package/lib/vapor/@vue/compiler-core/package.json +0 -58
- package/lib/vapor/@vue/compiler-dom/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-dom/README.md +0 -1
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -936
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -856
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6682
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -693
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6855
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/index.js +0 -7
- package/lib/vapor/@vue/compiler-dom/package.json +0 -57
- package/lib/vapor/@vue/compiler-sfc/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-sfc/README.md +0 -80
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -21682
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -66272
- package/lib/vapor/@vue/compiler-sfc/package.json +0 -68
- package/lib/vapor/@vue/compiler-ssr/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-ssr/README.md +0 -1
- package/lib/vapor/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1402
- package/lib/vapor/@vue/compiler-ssr/package.json +0 -34
- package/lib/vapor/@vue/compiler-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-vapor/README.md +0 -1
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +0 -4540
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +0 -37020
- package/lib/vapor/@vue/compiler-vapor/package.json +0 -49
- package/lib/vapor/@vue/reactivity/LICENSE +0 -21
- package/lib/vapor/@vue/reactivity/README.md +0 -19
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.js +0 -2033
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1841
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.js +0 -2023
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1992
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.js +0 -2082
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/index.js +0 -7
- package/lib/vapor/@vue/reactivity/package.json +0 -55
- package/lib/vapor/@vue/runtime-core/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-core/README.md +0 -28
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8972
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -7088
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8913
- package/lib/vapor/@vue/runtime-core/index.js +0 -7
- package/lib/vapor/@vue/runtime-core/package.json +0 -54
- package/lib/vapor/@vue/runtime-dom/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-dom/README.md +0 -13
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1797
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1646
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12929
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1838
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +0 -13086
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/index.js +0 -7
- package/lib/vapor/@vue/runtime-dom/package.json +0 -60
- package/lib/vapor/@vue/runtime-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-vapor/README.md +0 -8
- package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +0 -3242
- package/lib/vapor/@vue/runtime-vapor/package.json +0 -47
- package/lib/vapor/@vue/server-renderer/LICENSE +0 -21
- package/lib/vapor/@vue/server-renderer/README.md +0 -178
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1144
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -871
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8756
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1366
- package/lib/vapor/@vue/server-renderer/index.js +0 -7
- package/lib/vapor/@vue/server-renderer/package.json +0 -55
- package/lib/vapor/@vue/shared/LICENSE +0 -21
- package/lib/vapor/@vue/shared/README.md +0 -3
- package/lib/vapor/@vue/shared/dist/shared.cjs.js +0 -698
- package/lib/vapor/@vue/shared/dist/shared.cjs.prod.js +0 -690
- package/lib/vapor/@vue/shared/dist/shared.esm-bundler.js +0 -616
- package/lib/vapor/@vue/shared/index.js +0 -7
- package/lib/vapor/@vue/shared/package.json +0 -47
- package/lib/vapor/@vue/vue/LICENSE +0 -21
- package/lib/vapor/@vue/vue/README.md +0 -62
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.js +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.mjs +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.js +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/index.mjs +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/package.json +0 -4
- package/lib/vapor/@vue/vue/compiler-sfc/register-ts.js +0 -3
- package/lib/vapor/@vue/vue/dist/vue.cjs.js +0 -80
- package/lib/vapor/@vue/vue/dist/vue.cjs.prod.js +0 -66
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +0 -18840
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.esm-bundler.js +0 -72
- package/lib/vapor/@vue/vue/dist/vue.global.js +0 -18820
- package/lib/vapor/@vue/vue/dist/vue.global.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +0 -15648
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +0 -9
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +0 -12953
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-bundler.js +0 -29
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +0 -13111
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +0 -6
- package/lib/vapor/@vue/vue/index.js +0 -7
- package/lib/vapor/@vue/vue/index.mjs +0 -1
- package/lib/vapor/@vue/vue/jsx-runtime/index.d.ts +0 -25
- package/lib/vapor/@vue/vue/jsx-runtime/index.js +0 -15
- package/lib/vapor/@vue/vue/jsx-runtime/index.mjs +0 -12
- package/lib/vapor/@vue/vue/jsx-runtime/package.json +0 -5
- package/lib/vapor/@vue/vue/jsx.d.ts +0 -22
- package/lib/vapor/@vue/vue/package.json +0 -114
- package/lib/vapor/@vue/vue/server-renderer/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.js +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.mjs +0 -1
- package/lib/vapor/@vue/vue/server-renderer/package.json +0 -4
|
@@ -1,2033 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vue/reactivity v3.6.0-alpha.2
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
-
|
|
10
|
-
var shared = require('@vue/shared');
|
|
11
|
-
|
|
12
|
-
function warn(msg, ...args) {
|
|
13
|
-
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var ReactiveFlags$1 = /* @__PURE__ */ ((ReactiveFlags2) => {
|
|
17
|
-
ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
|
|
18
|
-
ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
|
|
19
|
-
ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
|
|
20
|
-
ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
|
|
21
|
-
ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
|
|
22
|
-
ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
|
|
23
|
-
ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
|
|
24
|
-
return ReactiveFlags2;
|
|
25
|
-
})(ReactiveFlags$1 || {});
|
|
26
|
-
const notifyBuffer = [];
|
|
27
|
-
let batchDepth = 0;
|
|
28
|
-
let activeSub = void 0;
|
|
29
|
-
let notifyIndex = 0;
|
|
30
|
-
let notifyBufferLength = 0;
|
|
31
|
-
function setActiveSub(sub) {
|
|
32
|
-
try {
|
|
33
|
-
return activeSub;
|
|
34
|
-
} finally {
|
|
35
|
-
activeSub = sub;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function startBatch() {
|
|
39
|
-
++batchDepth;
|
|
40
|
-
}
|
|
41
|
-
function endBatch() {
|
|
42
|
-
if (!--batchDepth && notifyBufferLength) {
|
|
43
|
-
flush();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function link(dep, sub) {
|
|
47
|
-
const prevDep = sub.depsTail;
|
|
48
|
-
if (prevDep !== void 0 && prevDep.dep === dep) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
let nextDep = void 0;
|
|
52
|
-
const recursedCheck = sub.flags & 4 /* RecursedCheck */;
|
|
53
|
-
if (recursedCheck) {
|
|
54
|
-
nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
55
|
-
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
56
|
-
sub.depsTail = nextDep;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const prevSub = dep.subsTail;
|
|
61
|
-
const newLink = sub.depsTail = dep.subsTail = {
|
|
62
|
-
dep,
|
|
63
|
-
sub,
|
|
64
|
-
prevDep,
|
|
65
|
-
nextDep,
|
|
66
|
-
prevSub,
|
|
67
|
-
nextSub: void 0
|
|
68
|
-
};
|
|
69
|
-
if (nextDep !== void 0) {
|
|
70
|
-
nextDep.prevDep = newLink;
|
|
71
|
-
}
|
|
72
|
-
if (prevDep !== void 0) {
|
|
73
|
-
prevDep.nextDep = newLink;
|
|
74
|
-
} else {
|
|
75
|
-
sub.deps = newLink;
|
|
76
|
-
}
|
|
77
|
-
if (prevSub !== void 0) {
|
|
78
|
-
prevSub.nextSub = newLink;
|
|
79
|
-
} else {
|
|
80
|
-
dep.subs = newLink;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function unlink(link2, sub = link2.sub) {
|
|
84
|
-
const dep = link2.dep;
|
|
85
|
-
const prevDep = link2.prevDep;
|
|
86
|
-
const nextDep = link2.nextDep;
|
|
87
|
-
const nextSub = link2.nextSub;
|
|
88
|
-
const prevSub = link2.prevSub;
|
|
89
|
-
if (nextDep !== void 0) {
|
|
90
|
-
nextDep.prevDep = prevDep;
|
|
91
|
-
} else {
|
|
92
|
-
sub.depsTail = prevDep;
|
|
93
|
-
}
|
|
94
|
-
if (prevDep !== void 0) {
|
|
95
|
-
prevDep.nextDep = nextDep;
|
|
96
|
-
} else {
|
|
97
|
-
sub.deps = nextDep;
|
|
98
|
-
}
|
|
99
|
-
if (nextSub !== void 0) {
|
|
100
|
-
nextSub.prevSub = prevSub;
|
|
101
|
-
} else {
|
|
102
|
-
dep.subsTail = prevSub;
|
|
103
|
-
}
|
|
104
|
-
if (prevSub !== void 0) {
|
|
105
|
-
prevSub.nextSub = nextSub;
|
|
106
|
-
} else if ((dep.subs = nextSub) === void 0) {
|
|
107
|
-
let toRemove = dep.deps;
|
|
108
|
-
if (toRemove !== void 0) {
|
|
109
|
-
do {
|
|
110
|
-
toRemove = unlink(toRemove, dep);
|
|
111
|
-
} while (toRemove !== void 0);
|
|
112
|
-
dep.flags |= 16 /* Dirty */;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return nextDep;
|
|
116
|
-
}
|
|
117
|
-
function propagate(link2) {
|
|
118
|
-
let next = link2.nextSub;
|
|
119
|
-
let stack;
|
|
120
|
-
top: do {
|
|
121
|
-
const sub = link2.sub;
|
|
122
|
-
let flags = sub.flags;
|
|
123
|
-
if (flags & (1 /* Mutable */ | 2 /* Watching */)) {
|
|
124
|
-
if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */ | 16 /* Dirty */ | 32 /* Pending */))) {
|
|
125
|
-
sub.flags = flags | 32 /* Pending */;
|
|
126
|
-
} else if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */))) {
|
|
127
|
-
flags = 0 /* None */;
|
|
128
|
-
} else if (!(flags & 4 /* RecursedCheck */)) {
|
|
129
|
-
sub.flags = flags & -9 /* Recursed */ | 32 /* Pending */;
|
|
130
|
-
} else if (!(flags & (16 /* Dirty */ | 32 /* Pending */)) && isValidLink(link2, sub)) {
|
|
131
|
-
sub.flags = flags | 8 /* Recursed */ | 32 /* Pending */;
|
|
132
|
-
flags &= 1 /* Mutable */;
|
|
133
|
-
} else {
|
|
134
|
-
flags = 0 /* None */;
|
|
135
|
-
}
|
|
136
|
-
if (flags & 2 /* Watching */) {
|
|
137
|
-
notifyBuffer[notifyBufferLength++] = sub;
|
|
138
|
-
}
|
|
139
|
-
if (flags & 1 /* Mutable */) {
|
|
140
|
-
const subSubs = sub.subs;
|
|
141
|
-
if (subSubs !== void 0) {
|
|
142
|
-
link2 = subSubs;
|
|
143
|
-
if (subSubs.nextSub !== void 0) {
|
|
144
|
-
stack = { value: next, prev: stack };
|
|
145
|
-
next = link2.nextSub;
|
|
146
|
-
}
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if ((link2 = next) !== void 0) {
|
|
152
|
-
next = link2.nextSub;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
while (stack !== void 0) {
|
|
156
|
-
link2 = stack.value;
|
|
157
|
-
stack = stack.prev;
|
|
158
|
-
if (link2 !== void 0) {
|
|
159
|
-
next = link2.nextSub;
|
|
160
|
-
continue top;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
} while (true);
|
|
165
|
-
}
|
|
166
|
-
function startTracking(sub) {
|
|
167
|
-
sub.depsTail = void 0;
|
|
168
|
-
sub.flags = sub.flags & -57 | 4 /* RecursedCheck */;
|
|
169
|
-
return setActiveSub(sub);
|
|
170
|
-
}
|
|
171
|
-
function endTracking(sub, prevSub) {
|
|
172
|
-
if (activeSub !== sub) {
|
|
173
|
-
warn(
|
|
174
|
-
"Active effect was not restored correctly - this is likely a Vue internal bug."
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
activeSub = prevSub;
|
|
178
|
-
const depsTail = sub.depsTail;
|
|
179
|
-
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
180
|
-
while (toRemove !== void 0) {
|
|
181
|
-
toRemove = unlink(toRemove, sub);
|
|
182
|
-
}
|
|
183
|
-
sub.flags &= -5 /* RecursedCheck */;
|
|
184
|
-
}
|
|
185
|
-
function flush() {
|
|
186
|
-
while (notifyIndex < notifyBufferLength) {
|
|
187
|
-
const effect = notifyBuffer[notifyIndex];
|
|
188
|
-
notifyBuffer[notifyIndex++] = void 0;
|
|
189
|
-
effect.notify();
|
|
190
|
-
}
|
|
191
|
-
notifyIndex = 0;
|
|
192
|
-
notifyBufferLength = 0;
|
|
193
|
-
}
|
|
194
|
-
function checkDirty(link2, sub) {
|
|
195
|
-
let stack;
|
|
196
|
-
let checkDepth = 0;
|
|
197
|
-
top: do {
|
|
198
|
-
const dep = link2.dep;
|
|
199
|
-
const depFlags = dep.flags;
|
|
200
|
-
let dirty = false;
|
|
201
|
-
if (sub.flags & 16 /* Dirty */) {
|
|
202
|
-
dirty = true;
|
|
203
|
-
} else if ((depFlags & (1 /* Mutable */ | 16 /* Dirty */)) === (1 /* Mutable */ | 16 /* Dirty */)) {
|
|
204
|
-
if (dep.update()) {
|
|
205
|
-
const subs = dep.subs;
|
|
206
|
-
if (subs.nextSub !== void 0) {
|
|
207
|
-
shallowPropagate(subs);
|
|
208
|
-
}
|
|
209
|
-
dirty = true;
|
|
210
|
-
}
|
|
211
|
-
} else if ((depFlags & (1 /* Mutable */ | 32 /* Pending */)) === (1 /* Mutable */ | 32 /* Pending */)) {
|
|
212
|
-
if (link2.nextSub !== void 0 || link2.prevSub !== void 0) {
|
|
213
|
-
stack = { value: link2, prev: stack };
|
|
214
|
-
}
|
|
215
|
-
link2 = dep.deps;
|
|
216
|
-
sub = dep;
|
|
217
|
-
++checkDepth;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (!dirty && link2.nextDep !== void 0) {
|
|
221
|
-
link2 = link2.nextDep;
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
while (checkDepth) {
|
|
225
|
-
--checkDepth;
|
|
226
|
-
const firstSub = sub.subs;
|
|
227
|
-
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
228
|
-
if (hasMultipleSubs) {
|
|
229
|
-
link2 = stack.value;
|
|
230
|
-
stack = stack.prev;
|
|
231
|
-
} else {
|
|
232
|
-
link2 = firstSub;
|
|
233
|
-
}
|
|
234
|
-
if (dirty) {
|
|
235
|
-
if (sub.update()) {
|
|
236
|
-
if (hasMultipleSubs) {
|
|
237
|
-
shallowPropagate(firstSub);
|
|
238
|
-
}
|
|
239
|
-
sub = link2.sub;
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
sub.flags &= -33 /* Pending */;
|
|
244
|
-
}
|
|
245
|
-
sub = link2.sub;
|
|
246
|
-
if (link2.nextDep !== void 0) {
|
|
247
|
-
link2 = link2.nextDep;
|
|
248
|
-
continue top;
|
|
249
|
-
}
|
|
250
|
-
dirty = false;
|
|
251
|
-
}
|
|
252
|
-
return dirty;
|
|
253
|
-
} while (true);
|
|
254
|
-
}
|
|
255
|
-
function shallowPropagate(link2) {
|
|
256
|
-
do {
|
|
257
|
-
const sub = link2.sub;
|
|
258
|
-
const nextSub = link2.nextSub;
|
|
259
|
-
const subFlags = sub.flags;
|
|
260
|
-
if ((subFlags & (32 /* Pending */ | 16 /* Dirty */)) === 32 /* Pending */) {
|
|
261
|
-
sub.flags = subFlags | 16 /* Dirty */;
|
|
262
|
-
}
|
|
263
|
-
link2 = nextSub;
|
|
264
|
-
} while (link2 !== void 0);
|
|
265
|
-
}
|
|
266
|
-
function isValidLink(checkLink, sub) {
|
|
267
|
-
const depsTail = sub.depsTail;
|
|
268
|
-
if (depsTail !== void 0) {
|
|
269
|
-
let link2 = sub.deps;
|
|
270
|
-
do {
|
|
271
|
-
if (link2 === checkLink) {
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
if (link2 === depsTail) {
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
link2 = link2.nextDep;
|
|
278
|
-
} while (link2 !== void 0);
|
|
279
|
-
}
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const triggerEventInfos = [];
|
|
284
|
-
function onTrack(sub, debugInfo) {
|
|
285
|
-
if (sub.onTrack) {
|
|
286
|
-
sub.onTrack(
|
|
287
|
-
shared.extend(
|
|
288
|
-
{
|
|
289
|
-
effect: sub
|
|
290
|
-
},
|
|
291
|
-
debugInfo
|
|
292
|
-
)
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
function onTrigger(sub) {
|
|
297
|
-
if (sub.onTrigger) {
|
|
298
|
-
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
299
|
-
sub.onTrigger(
|
|
300
|
-
shared.extend(
|
|
301
|
-
{
|
|
302
|
-
effect: sub
|
|
303
|
-
},
|
|
304
|
-
debugInfo
|
|
305
|
-
)
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
function setupOnTrigger(target) {
|
|
310
|
-
Object.defineProperty(target.prototype, "onTrigger", {
|
|
311
|
-
get() {
|
|
312
|
-
return this._onTrigger;
|
|
313
|
-
},
|
|
314
|
-
set(val) {
|
|
315
|
-
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
316
|
-
this._onTrigger = val;
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
function setupFlagsHandler(target) {
|
|
321
|
-
target._flags = target.flags;
|
|
322
|
-
Object.defineProperty(target, "flags", {
|
|
323
|
-
get() {
|
|
324
|
-
return target._flags;
|
|
325
|
-
},
|
|
326
|
-
set(value) {
|
|
327
|
-
if (!(target._flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) && !!(value & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending))) {
|
|
328
|
-
onTrigger(this);
|
|
329
|
-
}
|
|
330
|
-
target._flags = value;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
class Dep {
|
|
336
|
-
constructor(map, key) {
|
|
337
|
-
this.map = map;
|
|
338
|
-
this.key = key;
|
|
339
|
-
this._subs = void 0;
|
|
340
|
-
this.subsTail = void 0;
|
|
341
|
-
this.flags = ReactiveFlags$1.None;
|
|
342
|
-
}
|
|
343
|
-
get subs() {
|
|
344
|
-
return this._subs;
|
|
345
|
-
}
|
|
346
|
-
set subs(value) {
|
|
347
|
-
this._subs = value;
|
|
348
|
-
if (value === void 0) {
|
|
349
|
-
this.map.delete(this.key);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
354
|
-
const ITERATE_KEY = Symbol(
|
|
355
|
-
"Object iterate"
|
|
356
|
-
);
|
|
357
|
-
const MAP_KEY_ITERATE_KEY = Symbol(
|
|
358
|
-
"Map keys iterate"
|
|
359
|
-
);
|
|
360
|
-
const ARRAY_ITERATE_KEY = Symbol(
|
|
361
|
-
"Array iterate"
|
|
362
|
-
);
|
|
363
|
-
function track(target, type, key) {
|
|
364
|
-
if (activeSub !== void 0) {
|
|
365
|
-
let depsMap = targetMap.get(target);
|
|
366
|
-
if (!depsMap) {
|
|
367
|
-
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
368
|
-
}
|
|
369
|
-
let dep = depsMap.get(key);
|
|
370
|
-
if (!dep) {
|
|
371
|
-
depsMap.set(key, dep = new Dep(depsMap, key));
|
|
372
|
-
}
|
|
373
|
-
{
|
|
374
|
-
onTrack(activeSub, {
|
|
375
|
-
target,
|
|
376
|
-
type,
|
|
377
|
-
key
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
link(dep, activeSub);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
384
|
-
const depsMap = targetMap.get(target);
|
|
385
|
-
if (!depsMap) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const run = (dep) => {
|
|
389
|
-
if (dep !== void 0 && dep.subs !== void 0) {
|
|
390
|
-
{
|
|
391
|
-
triggerEventInfos.push({
|
|
392
|
-
target,
|
|
393
|
-
type,
|
|
394
|
-
key,
|
|
395
|
-
newValue,
|
|
396
|
-
oldValue,
|
|
397
|
-
oldTarget
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
propagate(dep.subs);
|
|
401
|
-
shallowPropagate(dep.subs);
|
|
402
|
-
{
|
|
403
|
-
triggerEventInfos.pop();
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
startBatch();
|
|
408
|
-
if (type === "clear") {
|
|
409
|
-
depsMap.forEach(run);
|
|
410
|
-
} else {
|
|
411
|
-
const targetIsArray = shared.isArray(target);
|
|
412
|
-
const isArrayIndex = targetIsArray && shared.isIntegerKey(key);
|
|
413
|
-
if (targetIsArray && key === "length") {
|
|
414
|
-
const newLength = Number(newValue);
|
|
415
|
-
depsMap.forEach((dep, key2) => {
|
|
416
|
-
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !shared.isSymbol(key2) && key2 >= newLength) {
|
|
417
|
-
run(dep);
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
} else {
|
|
421
|
-
if (key !== void 0 || depsMap.has(void 0)) {
|
|
422
|
-
run(depsMap.get(key));
|
|
423
|
-
}
|
|
424
|
-
if (isArrayIndex) {
|
|
425
|
-
run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
426
|
-
}
|
|
427
|
-
switch (type) {
|
|
428
|
-
case "add":
|
|
429
|
-
if (!targetIsArray) {
|
|
430
|
-
run(depsMap.get(ITERATE_KEY));
|
|
431
|
-
if (shared.isMap(target)) {
|
|
432
|
-
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
433
|
-
}
|
|
434
|
-
} else if (isArrayIndex) {
|
|
435
|
-
run(depsMap.get("length"));
|
|
436
|
-
}
|
|
437
|
-
break;
|
|
438
|
-
case "delete":
|
|
439
|
-
if (!targetIsArray) {
|
|
440
|
-
run(depsMap.get(ITERATE_KEY));
|
|
441
|
-
if (shared.isMap(target)) {
|
|
442
|
-
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
break;
|
|
446
|
-
case "set":
|
|
447
|
-
if (shared.isMap(target)) {
|
|
448
|
-
run(depsMap.get(ITERATE_KEY));
|
|
449
|
-
}
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
endBatch();
|
|
455
|
-
}
|
|
456
|
-
function getDepFromReactive(object, key) {
|
|
457
|
-
const depMap = targetMap.get(object);
|
|
458
|
-
return depMap && depMap.get(key);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function reactiveReadArray(array) {
|
|
462
|
-
const raw = toRaw(array);
|
|
463
|
-
if (raw === array) return raw;
|
|
464
|
-
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
465
|
-
return isShallow(array) ? raw : raw.map(toReactive);
|
|
466
|
-
}
|
|
467
|
-
function shallowReadArray(arr) {
|
|
468
|
-
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
469
|
-
return arr;
|
|
470
|
-
}
|
|
471
|
-
const arrayInstrumentations = {
|
|
472
|
-
__proto__: null,
|
|
473
|
-
[Symbol.iterator]() {
|
|
474
|
-
return iterator(this, Symbol.iterator, toReactive);
|
|
475
|
-
},
|
|
476
|
-
concat(...args) {
|
|
477
|
-
return reactiveReadArray(this).concat(
|
|
478
|
-
...args.map((x) => shared.isArray(x) ? reactiveReadArray(x) : x)
|
|
479
|
-
);
|
|
480
|
-
},
|
|
481
|
-
entries() {
|
|
482
|
-
return iterator(this, "entries", (value) => {
|
|
483
|
-
value[1] = toReactive(value[1]);
|
|
484
|
-
return value;
|
|
485
|
-
});
|
|
486
|
-
},
|
|
487
|
-
every(fn, thisArg) {
|
|
488
|
-
return apply(this, "every", fn, thisArg, void 0, arguments);
|
|
489
|
-
},
|
|
490
|
-
filter(fn, thisArg) {
|
|
491
|
-
return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
|
|
492
|
-
},
|
|
493
|
-
find(fn, thisArg) {
|
|
494
|
-
return apply(this, "find", fn, thisArg, toReactive, arguments);
|
|
495
|
-
},
|
|
496
|
-
findIndex(fn, thisArg) {
|
|
497
|
-
return apply(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
498
|
-
},
|
|
499
|
-
findLast(fn, thisArg) {
|
|
500
|
-
return apply(this, "findLast", fn, thisArg, toReactive, arguments);
|
|
501
|
-
},
|
|
502
|
-
findLastIndex(fn, thisArg) {
|
|
503
|
-
return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
504
|
-
},
|
|
505
|
-
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
|
|
506
|
-
forEach(fn, thisArg) {
|
|
507
|
-
return apply(this, "forEach", fn, thisArg, void 0, arguments);
|
|
508
|
-
},
|
|
509
|
-
includes(...args) {
|
|
510
|
-
return searchProxy(this, "includes", args);
|
|
511
|
-
},
|
|
512
|
-
indexOf(...args) {
|
|
513
|
-
return searchProxy(this, "indexOf", args);
|
|
514
|
-
},
|
|
515
|
-
join(separator) {
|
|
516
|
-
return reactiveReadArray(this).join(separator);
|
|
517
|
-
},
|
|
518
|
-
// keys() iterator only reads `length`, no optimisation required
|
|
519
|
-
lastIndexOf(...args) {
|
|
520
|
-
return searchProxy(this, "lastIndexOf", args);
|
|
521
|
-
},
|
|
522
|
-
map(fn, thisArg) {
|
|
523
|
-
return apply(this, "map", fn, thisArg, void 0, arguments);
|
|
524
|
-
},
|
|
525
|
-
pop() {
|
|
526
|
-
return noTracking(this, "pop");
|
|
527
|
-
},
|
|
528
|
-
push(...args) {
|
|
529
|
-
return noTracking(this, "push", args);
|
|
530
|
-
},
|
|
531
|
-
reduce(fn, ...args) {
|
|
532
|
-
return reduce(this, "reduce", fn, args);
|
|
533
|
-
},
|
|
534
|
-
reduceRight(fn, ...args) {
|
|
535
|
-
return reduce(this, "reduceRight", fn, args);
|
|
536
|
-
},
|
|
537
|
-
shift() {
|
|
538
|
-
return noTracking(this, "shift");
|
|
539
|
-
},
|
|
540
|
-
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
|
541
|
-
some(fn, thisArg) {
|
|
542
|
-
return apply(this, "some", fn, thisArg, void 0, arguments);
|
|
543
|
-
},
|
|
544
|
-
splice(...args) {
|
|
545
|
-
return noTracking(this, "splice", args);
|
|
546
|
-
},
|
|
547
|
-
toReversed() {
|
|
548
|
-
return reactiveReadArray(this).toReversed();
|
|
549
|
-
},
|
|
550
|
-
toSorted(comparer) {
|
|
551
|
-
return reactiveReadArray(this).toSorted(comparer);
|
|
552
|
-
},
|
|
553
|
-
toSpliced(...args) {
|
|
554
|
-
return reactiveReadArray(this).toSpliced(...args);
|
|
555
|
-
},
|
|
556
|
-
unshift(...args) {
|
|
557
|
-
return noTracking(this, "unshift", args);
|
|
558
|
-
},
|
|
559
|
-
values() {
|
|
560
|
-
return iterator(this, "values", toReactive);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
function iterator(self, method, wrapValue) {
|
|
564
|
-
const arr = shallowReadArray(self);
|
|
565
|
-
const iter = arr[method]();
|
|
566
|
-
if (arr !== self && !isShallow(self)) {
|
|
567
|
-
iter._next = iter.next;
|
|
568
|
-
iter.next = () => {
|
|
569
|
-
const result = iter._next();
|
|
570
|
-
if (result.value) {
|
|
571
|
-
result.value = wrapValue(result.value);
|
|
572
|
-
}
|
|
573
|
-
return result;
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
return iter;
|
|
577
|
-
}
|
|
578
|
-
const arrayProto = Array.prototype;
|
|
579
|
-
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
580
|
-
const arr = shallowReadArray(self);
|
|
581
|
-
const needsWrap = arr !== self && !isShallow(self);
|
|
582
|
-
const methodFn = arr[method];
|
|
583
|
-
if (methodFn !== arrayProto[method]) {
|
|
584
|
-
const result2 = methodFn.apply(self, args);
|
|
585
|
-
return needsWrap ? toReactive(result2) : result2;
|
|
586
|
-
}
|
|
587
|
-
let wrappedFn = fn;
|
|
588
|
-
if (arr !== self) {
|
|
589
|
-
if (needsWrap) {
|
|
590
|
-
wrappedFn = function(item, index) {
|
|
591
|
-
return fn.call(this, toReactive(item), index, self);
|
|
592
|
-
};
|
|
593
|
-
} else if (fn.length > 2) {
|
|
594
|
-
wrappedFn = function(item, index) {
|
|
595
|
-
return fn.call(this, item, index, self);
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
600
|
-
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
601
|
-
}
|
|
602
|
-
function reduce(self, method, fn, args) {
|
|
603
|
-
const arr = shallowReadArray(self);
|
|
604
|
-
let wrappedFn = fn;
|
|
605
|
-
if (arr !== self) {
|
|
606
|
-
if (!isShallow(self)) {
|
|
607
|
-
wrappedFn = function(acc, item, index) {
|
|
608
|
-
return fn.call(this, acc, toReactive(item), index, self);
|
|
609
|
-
};
|
|
610
|
-
} else if (fn.length > 3) {
|
|
611
|
-
wrappedFn = function(acc, item, index) {
|
|
612
|
-
return fn.call(this, acc, item, index, self);
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return arr[method](wrappedFn, ...args);
|
|
617
|
-
}
|
|
618
|
-
function searchProxy(self, method, args) {
|
|
619
|
-
const arr = toRaw(self);
|
|
620
|
-
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
621
|
-
const res = arr[method](...args);
|
|
622
|
-
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
623
|
-
args[0] = toRaw(args[0]);
|
|
624
|
-
return arr[method](...args);
|
|
625
|
-
}
|
|
626
|
-
return res;
|
|
627
|
-
}
|
|
628
|
-
function noTracking(self, method, args = []) {
|
|
629
|
-
startBatch();
|
|
630
|
-
const prevSub = setActiveSub();
|
|
631
|
-
const res = toRaw(self)[method].apply(self, args);
|
|
632
|
-
setActiveSub(prevSub);
|
|
633
|
-
endBatch();
|
|
634
|
-
return res;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
const isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`);
|
|
638
|
-
const builtInSymbols = new Set(
|
|
639
|
-
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared.isSymbol)
|
|
640
|
-
);
|
|
641
|
-
function hasOwnProperty(key) {
|
|
642
|
-
if (!shared.isSymbol(key)) key = String(key);
|
|
643
|
-
const obj = toRaw(this);
|
|
644
|
-
track(obj, "has", key);
|
|
645
|
-
return obj.hasOwnProperty(key);
|
|
646
|
-
}
|
|
647
|
-
class BaseReactiveHandler {
|
|
648
|
-
constructor(_isReadonly = false, _isShallow = false) {
|
|
649
|
-
this._isReadonly = _isReadonly;
|
|
650
|
-
this._isShallow = _isShallow;
|
|
651
|
-
}
|
|
652
|
-
get(target, key, receiver) {
|
|
653
|
-
if (key === "__v_skip") return target["__v_skip"];
|
|
654
|
-
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
655
|
-
if (key === "__v_isReactive") {
|
|
656
|
-
return !isReadonly2;
|
|
657
|
-
} else if (key === "__v_isReadonly") {
|
|
658
|
-
return isReadonly2;
|
|
659
|
-
} else if (key === "__v_isShallow") {
|
|
660
|
-
return isShallow2;
|
|
661
|
-
} else if (key === "__v_raw") {
|
|
662
|
-
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
663
|
-
// this means the receiver is a user proxy of the reactive proxy
|
|
664
|
-
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
665
|
-
return target;
|
|
666
|
-
}
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
const targetIsArray = shared.isArray(target);
|
|
670
|
-
if (!isReadonly2) {
|
|
671
|
-
let fn;
|
|
672
|
-
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
673
|
-
return fn;
|
|
674
|
-
}
|
|
675
|
-
if (key === "hasOwnProperty") {
|
|
676
|
-
return hasOwnProperty;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
const wasRef = isRef(target);
|
|
680
|
-
const res = Reflect.get(
|
|
681
|
-
target,
|
|
682
|
-
key,
|
|
683
|
-
// if this is a proxy wrapping a ref, return methods using the raw ref
|
|
684
|
-
// as receiver so that we don't have to call `toRaw` on the ref in all
|
|
685
|
-
// its class methods
|
|
686
|
-
wasRef ? target : receiver
|
|
687
|
-
);
|
|
688
|
-
if (wasRef && key !== "value") {
|
|
689
|
-
return res;
|
|
690
|
-
}
|
|
691
|
-
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
692
|
-
return res;
|
|
693
|
-
}
|
|
694
|
-
if (!isReadonly2) {
|
|
695
|
-
track(target, "get", key);
|
|
696
|
-
}
|
|
697
|
-
if (isShallow2) {
|
|
698
|
-
return res;
|
|
699
|
-
}
|
|
700
|
-
if (isRef(res)) {
|
|
701
|
-
return targetIsArray && shared.isIntegerKey(key) ? res : res.value;
|
|
702
|
-
}
|
|
703
|
-
if (shared.isObject(res)) {
|
|
704
|
-
return isReadonly2 ? readonly(res) : reactive(res);
|
|
705
|
-
}
|
|
706
|
-
return res;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
710
|
-
constructor(isShallow2 = false) {
|
|
711
|
-
super(false, isShallow2);
|
|
712
|
-
}
|
|
713
|
-
set(target, key, value, receiver) {
|
|
714
|
-
let oldValue = target[key];
|
|
715
|
-
if (!this._isShallow) {
|
|
716
|
-
const isOldValueReadonly = isReadonly(oldValue);
|
|
717
|
-
if (!isShallow(value) && !isReadonly(value)) {
|
|
718
|
-
oldValue = toRaw(oldValue);
|
|
719
|
-
value = toRaw(value);
|
|
720
|
-
}
|
|
721
|
-
if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
722
|
-
if (isOldValueReadonly) {
|
|
723
|
-
return false;
|
|
724
|
-
} else {
|
|
725
|
-
oldValue.value = value;
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
const hadKey = shared.isArray(target) && shared.isIntegerKey(key) ? Number(key) < target.length : shared.hasOwn(target, key);
|
|
731
|
-
const result = Reflect.set(
|
|
732
|
-
target,
|
|
733
|
-
key,
|
|
734
|
-
value,
|
|
735
|
-
isRef(target) ? target : receiver
|
|
736
|
-
);
|
|
737
|
-
if (target === toRaw(receiver)) {
|
|
738
|
-
if (!hadKey) {
|
|
739
|
-
trigger(target, "add", key, value);
|
|
740
|
-
} else if (shared.hasChanged(value, oldValue)) {
|
|
741
|
-
trigger(target, "set", key, value, oldValue);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return result;
|
|
745
|
-
}
|
|
746
|
-
deleteProperty(target, key) {
|
|
747
|
-
const hadKey = shared.hasOwn(target, key);
|
|
748
|
-
const oldValue = target[key];
|
|
749
|
-
const result = Reflect.deleteProperty(target, key);
|
|
750
|
-
if (result && hadKey) {
|
|
751
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
752
|
-
}
|
|
753
|
-
return result;
|
|
754
|
-
}
|
|
755
|
-
has(target, key) {
|
|
756
|
-
const result = Reflect.has(target, key);
|
|
757
|
-
if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
|
|
758
|
-
track(target, "has", key);
|
|
759
|
-
}
|
|
760
|
-
return result;
|
|
761
|
-
}
|
|
762
|
-
ownKeys(target) {
|
|
763
|
-
track(
|
|
764
|
-
target,
|
|
765
|
-
"iterate",
|
|
766
|
-
shared.isArray(target) ? "length" : ITERATE_KEY
|
|
767
|
-
);
|
|
768
|
-
return Reflect.ownKeys(target);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
772
|
-
constructor(isShallow2 = false) {
|
|
773
|
-
super(true, isShallow2);
|
|
774
|
-
}
|
|
775
|
-
set(target, key) {
|
|
776
|
-
{
|
|
777
|
-
warn(
|
|
778
|
-
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
779
|
-
target
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
return true;
|
|
783
|
-
}
|
|
784
|
-
deleteProperty(target, key) {
|
|
785
|
-
{
|
|
786
|
-
warn(
|
|
787
|
-
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
788
|
-
target
|
|
789
|
-
);
|
|
790
|
-
}
|
|
791
|
-
return true;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
795
|
-
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
796
|
-
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
|
797
|
-
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
798
|
-
|
|
799
|
-
const toShallow = (value) => value;
|
|
800
|
-
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
801
|
-
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
802
|
-
return function(...args) {
|
|
803
|
-
const target = this["__v_raw"];
|
|
804
|
-
const rawTarget = toRaw(target);
|
|
805
|
-
const targetIsMap = shared.isMap(rawTarget);
|
|
806
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
807
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
808
|
-
const innerIterator = target[method](...args);
|
|
809
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
810
|
-
!isReadonly2 && track(
|
|
811
|
-
rawTarget,
|
|
812
|
-
"iterate",
|
|
813
|
-
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
814
|
-
);
|
|
815
|
-
return {
|
|
816
|
-
// iterator protocol
|
|
817
|
-
next() {
|
|
818
|
-
const { value, done } = innerIterator.next();
|
|
819
|
-
return done ? { value, done } : {
|
|
820
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
821
|
-
done
|
|
822
|
-
};
|
|
823
|
-
},
|
|
824
|
-
// iterable protocol
|
|
825
|
-
[Symbol.iterator]() {
|
|
826
|
-
return this;
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
|
-
function createReadonlyMethod(type) {
|
|
832
|
-
return function(...args) {
|
|
833
|
-
{
|
|
834
|
-
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
835
|
-
warn(
|
|
836
|
-
`${shared.capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
837
|
-
toRaw(this)
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
function createInstrumentations(readonly, shallow) {
|
|
844
|
-
const instrumentations = {
|
|
845
|
-
get(key) {
|
|
846
|
-
const target = this["__v_raw"];
|
|
847
|
-
const rawTarget = toRaw(target);
|
|
848
|
-
const rawKey = toRaw(key);
|
|
849
|
-
if (!readonly) {
|
|
850
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
851
|
-
track(rawTarget, "get", key);
|
|
852
|
-
}
|
|
853
|
-
track(rawTarget, "get", rawKey);
|
|
854
|
-
}
|
|
855
|
-
const { has } = getProto(rawTarget);
|
|
856
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
857
|
-
if (has.call(rawTarget, key)) {
|
|
858
|
-
return wrap(target.get(key));
|
|
859
|
-
} else if (has.call(rawTarget, rawKey)) {
|
|
860
|
-
return wrap(target.get(rawKey));
|
|
861
|
-
} else if (target !== rawTarget) {
|
|
862
|
-
target.get(key);
|
|
863
|
-
}
|
|
864
|
-
},
|
|
865
|
-
get size() {
|
|
866
|
-
const target = this["__v_raw"];
|
|
867
|
-
!readonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
868
|
-
return Reflect.get(target, "size", target);
|
|
869
|
-
},
|
|
870
|
-
has(key) {
|
|
871
|
-
const target = this["__v_raw"];
|
|
872
|
-
const rawTarget = toRaw(target);
|
|
873
|
-
const rawKey = toRaw(key);
|
|
874
|
-
if (!readonly) {
|
|
875
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
876
|
-
track(rawTarget, "has", key);
|
|
877
|
-
}
|
|
878
|
-
track(rawTarget, "has", rawKey);
|
|
879
|
-
}
|
|
880
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
881
|
-
},
|
|
882
|
-
forEach(callback, thisArg) {
|
|
883
|
-
const observed = this;
|
|
884
|
-
const target = observed["__v_raw"];
|
|
885
|
-
const rawTarget = toRaw(target);
|
|
886
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
887
|
-
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
888
|
-
return target.forEach((value, key) => {
|
|
889
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
};
|
|
893
|
-
shared.extend(
|
|
894
|
-
instrumentations,
|
|
895
|
-
readonly ? {
|
|
896
|
-
add: createReadonlyMethod("add"),
|
|
897
|
-
set: createReadonlyMethod("set"),
|
|
898
|
-
delete: createReadonlyMethod("delete"),
|
|
899
|
-
clear: createReadonlyMethod("clear")
|
|
900
|
-
} : {
|
|
901
|
-
add(value) {
|
|
902
|
-
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
903
|
-
value = toRaw(value);
|
|
904
|
-
}
|
|
905
|
-
const target = toRaw(this);
|
|
906
|
-
const proto = getProto(target);
|
|
907
|
-
const hadKey = proto.has.call(target, value);
|
|
908
|
-
if (!hadKey) {
|
|
909
|
-
target.add(value);
|
|
910
|
-
trigger(target, "add", value, value);
|
|
911
|
-
}
|
|
912
|
-
return this;
|
|
913
|
-
},
|
|
914
|
-
set(key, value) {
|
|
915
|
-
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
916
|
-
value = toRaw(value);
|
|
917
|
-
}
|
|
918
|
-
const target = toRaw(this);
|
|
919
|
-
const { has, get } = getProto(target);
|
|
920
|
-
let hadKey = has.call(target, key);
|
|
921
|
-
if (!hadKey) {
|
|
922
|
-
key = toRaw(key);
|
|
923
|
-
hadKey = has.call(target, key);
|
|
924
|
-
} else {
|
|
925
|
-
checkIdentityKeys(target, has, key);
|
|
926
|
-
}
|
|
927
|
-
const oldValue = get.call(target, key);
|
|
928
|
-
target.set(key, value);
|
|
929
|
-
if (!hadKey) {
|
|
930
|
-
trigger(target, "add", key, value);
|
|
931
|
-
} else if (shared.hasChanged(value, oldValue)) {
|
|
932
|
-
trigger(target, "set", key, value, oldValue);
|
|
933
|
-
}
|
|
934
|
-
return this;
|
|
935
|
-
},
|
|
936
|
-
delete(key) {
|
|
937
|
-
const target = toRaw(this);
|
|
938
|
-
const { has, get } = getProto(target);
|
|
939
|
-
let hadKey = has.call(target, key);
|
|
940
|
-
if (!hadKey) {
|
|
941
|
-
key = toRaw(key);
|
|
942
|
-
hadKey = has.call(target, key);
|
|
943
|
-
} else {
|
|
944
|
-
checkIdentityKeys(target, has, key);
|
|
945
|
-
}
|
|
946
|
-
const oldValue = get ? get.call(target, key) : void 0;
|
|
947
|
-
const result = target.delete(key);
|
|
948
|
-
if (hadKey) {
|
|
949
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
950
|
-
}
|
|
951
|
-
return result;
|
|
952
|
-
},
|
|
953
|
-
clear() {
|
|
954
|
-
const target = toRaw(this);
|
|
955
|
-
const hadItems = target.size !== 0;
|
|
956
|
-
const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target) ;
|
|
957
|
-
const result = target.clear();
|
|
958
|
-
if (hadItems) {
|
|
959
|
-
trigger(
|
|
960
|
-
target,
|
|
961
|
-
"clear",
|
|
962
|
-
void 0,
|
|
963
|
-
void 0,
|
|
964
|
-
oldTarget
|
|
965
|
-
);
|
|
966
|
-
}
|
|
967
|
-
return result;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
);
|
|
971
|
-
const iteratorMethods = [
|
|
972
|
-
"keys",
|
|
973
|
-
"values",
|
|
974
|
-
"entries",
|
|
975
|
-
Symbol.iterator
|
|
976
|
-
];
|
|
977
|
-
iteratorMethods.forEach((method) => {
|
|
978
|
-
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
979
|
-
});
|
|
980
|
-
return instrumentations;
|
|
981
|
-
}
|
|
982
|
-
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
983
|
-
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
984
|
-
return (target, key, receiver) => {
|
|
985
|
-
if (key === "__v_isReactive") {
|
|
986
|
-
return !isReadonly2;
|
|
987
|
-
} else if (key === "__v_isReadonly") {
|
|
988
|
-
return isReadonly2;
|
|
989
|
-
} else if (key === "__v_raw") {
|
|
990
|
-
return target;
|
|
991
|
-
}
|
|
992
|
-
return Reflect.get(
|
|
993
|
-
shared.hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
994
|
-
key,
|
|
995
|
-
receiver
|
|
996
|
-
);
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
const mutableCollectionHandlers = {
|
|
1000
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
1001
|
-
};
|
|
1002
|
-
const shallowCollectionHandlers = {
|
|
1003
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
1004
|
-
};
|
|
1005
|
-
const readonlyCollectionHandlers = {
|
|
1006
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
1007
|
-
};
|
|
1008
|
-
const shallowReadonlyCollectionHandlers = {
|
|
1009
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
1010
|
-
};
|
|
1011
|
-
function checkIdentityKeys(target, has, key) {
|
|
1012
|
-
const rawKey = toRaw(key);
|
|
1013
|
-
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1014
|
-
const type = shared.toRawType(target);
|
|
1015
|
-
warn(
|
|
1016
|
-
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1022
|
-
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1023
|
-
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1024
|
-
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
1025
|
-
function targetTypeMap(rawType) {
|
|
1026
|
-
switch (rawType) {
|
|
1027
|
-
case "Object":
|
|
1028
|
-
case "Array":
|
|
1029
|
-
return 1 /* COMMON */;
|
|
1030
|
-
case "Map":
|
|
1031
|
-
case "Set":
|
|
1032
|
-
case "WeakMap":
|
|
1033
|
-
case "WeakSet":
|
|
1034
|
-
return 2 /* COLLECTION */;
|
|
1035
|
-
default:
|
|
1036
|
-
return 0 /* INVALID */;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
function getTargetType(value) {
|
|
1040
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(shared.toRawType(value));
|
|
1041
|
-
}
|
|
1042
|
-
function reactive(target) {
|
|
1043
|
-
if (isReadonly(target)) {
|
|
1044
|
-
return target;
|
|
1045
|
-
}
|
|
1046
|
-
return createReactiveObject(
|
|
1047
|
-
target,
|
|
1048
|
-
false,
|
|
1049
|
-
mutableHandlers,
|
|
1050
|
-
mutableCollectionHandlers,
|
|
1051
|
-
reactiveMap
|
|
1052
|
-
);
|
|
1053
|
-
}
|
|
1054
|
-
function shallowReactive(target) {
|
|
1055
|
-
return createReactiveObject(
|
|
1056
|
-
target,
|
|
1057
|
-
false,
|
|
1058
|
-
shallowReactiveHandlers,
|
|
1059
|
-
shallowCollectionHandlers,
|
|
1060
|
-
shallowReactiveMap
|
|
1061
|
-
);
|
|
1062
|
-
}
|
|
1063
|
-
function readonly(target) {
|
|
1064
|
-
return createReactiveObject(
|
|
1065
|
-
target,
|
|
1066
|
-
true,
|
|
1067
|
-
readonlyHandlers,
|
|
1068
|
-
readonlyCollectionHandlers,
|
|
1069
|
-
readonlyMap
|
|
1070
|
-
);
|
|
1071
|
-
}
|
|
1072
|
-
function shallowReadonly(target) {
|
|
1073
|
-
return createReactiveObject(
|
|
1074
|
-
target,
|
|
1075
|
-
true,
|
|
1076
|
-
shallowReadonlyHandlers,
|
|
1077
|
-
shallowReadonlyCollectionHandlers,
|
|
1078
|
-
shallowReadonlyMap
|
|
1079
|
-
);
|
|
1080
|
-
}
|
|
1081
|
-
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1082
|
-
if (!shared.isObject(target)) {
|
|
1083
|
-
{
|
|
1084
|
-
warn(
|
|
1085
|
-
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
1086
|
-
target
|
|
1087
|
-
)}`
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1090
|
-
return target;
|
|
1091
|
-
}
|
|
1092
|
-
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
1093
|
-
return target;
|
|
1094
|
-
}
|
|
1095
|
-
const targetType = getTargetType(target);
|
|
1096
|
-
if (targetType === 0 /* INVALID */) {
|
|
1097
|
-
return target;
|
|
1098
|
-
}
|
|
1099
|
-
const existingProxy = proxyMap.get(target);
|
|
1100
|
-
if (existingProxy) {
|
|
1101
|
-
return existingProxy;
|
|
1102
|
-
}
|
|
1103
|
-
const proxy = new Proxy(
|
|
1104
|
-
target,
|
|
1105
|
-
targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
|
|
1106
|
-
);
|
|
1107
|
-
proxyMap.set(target, proxy);
|
|
1108
|
-
return proxy;
|
|
1109
|
-
}
|
|
1110
|
-
function isReactive(value) {
|
|
1111
|
-
if (isReadonly(value)) {
|
|
1112
|
-
return isReactive(value["__v_raw"]);
|
|
1113
|
-
}
|
|
1114
|
-
return !!(value && value["__v_isReactive"]);
|
|
1115
|
-
}
|
|
1116
|
-
function isReadonly(value) {
|
|
1117
|
-
return !!(value && value["__v_isReadonly"]);
|
|
1118
|
-
}
|
|
1119
|
-
function isShallow(value) {
|
|
1120
|
-
return !!(value && value["__v_isShallow"]);
|
|
1121
|
-
}
|
|
1122
|
-
function isProxy(value) {
|
|
1123
|
-
return value ? !!value["__v_raw"] : false;
|
|
1124
|
-
}
|
|
1125
|
-
function toRaw(observed) {
|
|
1126
|
-
const raw = observed && observed["__v_raw"];
|
|
1127
|
-
return raw ? toRaw(raw) : observed;
|
|
1128
|
-
}
|
|
1129
|
-
function markRaw(value) {
|
|
1130
|
-
if (!shared.hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
|
|
1131
|
-
shared.def(value, "__v_skip", true);
|
|
1132
|
-
}
|
|
1133
|
-
return value;
|
|
1134
|
-
}
|
|
1135
|
-
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
|
|
1136
|
-
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
|
|
1137
|
-
|
|
1138
|
-
function isRef(r) {
|
|
1139
|
-
return r ? r["__v_isRef"] === true : false;
|
|
1140
|
-
}
|
|
1141
|
-
function ref(value) {
|
|
1142
|
-
return createRef(value, toReactive);
|
|
1143
|
-
}
|
|
1144
|
-
function shallowRef(value) {
|
|
1145
|
-
return createRef(value);
|
|
1146
|
-
}
|
|
1147
|
-
function createRef(rawValue, wrap) {
|
|
1148
|
-
if (isRef(rawValue)) {
|
|
1149
|
-
return rawValue;
|
|
1150
|
-
}
|
|
1151
|
-
return new RefImpl(rawValue, wrap);
|
|
1152
|
-
}
|
|
1153
|
-
class RefImpl {
|
|
1154
|
-
// TODO isolatedDeclarations "__v_isShallow"
|
|
1155
|
-
constructor(value, wrap) {
|
|
1156
|
-
this.subs = void 0;
|
|
1157
|
-
this.subsTail = void 0;
|
|
1158
|
-
this.flags = ReactiveFlags$1.Mutable;
|
|
1159
|
-
/**
|
|
1160
|
-
* @internal
|
|
1161
|
-
*/
|
|
1162
|
-
this.__v_isRef = true;
|
|
1163
|
-
// TODO isolatedDeclarations "__v_isRef"
|
|
1164
|
-
/**
|
|
1165
|
-
* @internal
|
|
1166
|
-
*/
|
|
1167
|
-
this.__v_isShallow = false;
|
|
1168
|
-
this._oldValue = this._rawValue = wrap ? toRaw(value) : value;
|
|
1169
|
-
this._value = wrap ? wrap(value) : value;
|
|
1170
|
-
this._wrap = wrap;
|
|
1171
|
-
this["__v_isShallow"] = !wrap;
|
|
1172
|
-
}
|
|
1173
|
-
get dep() {
|
|
1174
|
-
return this;
|
|
1175
|
-
}
|
|
1176
|
-
get value() {
|
|
1177
|
-
trackRef(this);
|
|
1178
|
-
if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
|
|
1179
|
-
const subs = this.subs;
|
|
1180
|
-
if (subs !== void 0) {
|
|
1181
|
-
shallowPropagate(subs);
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
return this._value;
|
|
1185
|
-
}
|
|
1186
|
-
set value(newValue) {
|
|
1187
|
-
const oldValue = this._rawValue;
|
|
1188
|
-
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1189
|
-
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1190
|
-
if (shared.hasChanged(newValue, oldValue)) {
|
|
1191
|
-
this.flags |= ReactiveFlags$1.Dirty;
|
|
1192
|
-
this._rawValue = newValue;
|
|
1193
|
-
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1194
|
-
const subs = this.subs;
|
|
1195
|
-
if (subs !== void 0) {
|
|
1196
|
-
{
|
|
1197
|
-
triggerEventInfos.push({
|
|
1198
|
-
target: this,
|
|
1199
|
-
type: "set",
|
|
1200
|
-
key: "value",
|
|
1201
|
-
newValue,
|
|
1202
|
-
oldValue
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
propagate(subs);
|
|
1206
|
-
if (!batchDepth) {
|
|
1207
|
-
flush();
|
|
1208
|
-
}
|
|
1209
|
-
{
|
|
1210
|
-
triggerEventInfos.pop();
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
update() {
|
|
1216
|
-
this.flags &= ~ReactiveFlags$1.Dirty;
|
|
1217
|
-
return shared.hasChanged(this._oldValue, this._oldValue = this._rawValue);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
function triggerRef(ref2) {
|
|
1221
|
-
const dep = ref2.dep;
|
|
1222
|
-
if (dep !== void 0 && dep.subs !== void 0) {
|
|
1223
|
-
propagate(dep.subs);
|
|
1224
|
-
shallowPropagate(dep.subs);
|
|
1225
|
-
if (!batchDepth) {
|
|
1226
|
-
flush();
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
function trackRef(dep) {
|
|
1231
|
-
if (activeSub !== void 0) {
|
|
1232
|
-
{
|
|
1233
|
-
onTrack(activeSub, {
|
|
1234
|
-
target: dep,
|
|
1235
|
-
type: "get",
|
|
1236
|
-
key: "value"
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
link(dep, activeSub);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
function unref(ref2) {
|
|
1243
|
-
return isRef(ref2) ? ref2.value : ref2;
|
|
1244
|
-
}
|
|
1245
|
-
function toValue(source) {
|
|
1246
|
-
return shared.isFunction(source) ? source() : unref(source);
|
|
1247
|
-
}
|
|
1248
|
-
const shallowUnwrapHandlers = {
|
|
1249
|
-
get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
|
|
1250
|
-
set: (target, key, value, receiver) => {
|
|
1251
|
-
const oldValue = target[key];
|
|
1252
|
-
if (isRef(oldValue) && !isRef(value)) {
|
|
1253
|
-
oldValue.value = value;
|
|
1254
|
-
return true;
|
|
1255
|
-
} else {
|
|
1256
|
-
return Reflect.set(target, key, value, receiver);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
function proxyRefs(objectWithRefs) {
|
|
1261
|
-
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1262
|
-
}
|
|
1263
|
-
class CustomRefImpl {
|
|
1264
|
-
constructor(factory) {
|
|
1265
|
-
this.subs = void 0;
|
|
1266
|
-
this.subsTail = void 0;
|
|
1267
|
-
this.flags = ReactiveFlags$1.None;
|
|
1268
|
-
this["__v_isRef"] = true;
|
|
1269
|
-
this._value = void 0;
|
|
1270
|
-
const { get, set } = factory(
|
|
1271
|
-
() => trackRef(this),
|
|
1272
|
-
() => triggerRef(this)
|
|
1273
|
-
);
|
|
1274
|
-
this._get = get;
|
|
1275
|
-
this._set = set;
|
|
1276
|
-
}
|
|
1277
|
-
get dep() {
|
|
1278
|
-
return this;
|
|
1279
|
-
}
|
|
1280
|
-
get value() {
|
|
1281
|
-
return this._value = this._get();
|
|
1282
|
-
}
|
|
1283
|
-
set value(newVal) {
|
|
1284
|
-
this._set(newVal);
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
function customRef(factory) {
|
|
1288
|
-
return new CustomRefImpl(factory);
|
|
1289
|
-
}
|
|
1290
|
-
function toRefs(object) {
|
|
1291
|
-
const ret = shared.isArray(object) ? new Array(object.length) : {};
|
|
1292
|
-
for (const key in object) {
|
|
1293
|
-
ret[key] = propertyToRef(object, key);
|
|
1294
|
-
}
|
|
1295
|
-
return ret;
|
|
1296
|
-
}
|
|
1297
|
-
class ObjectRefImpl {
|
|
1298
|
-
constructor(_object, _key, _defaultValue) {
|
|
1299
|
-
this._object = _object;
|
|
1300
|
-
this._key = _key;
|
|
1301
|
-
this._defaultValue = _defaultValue;
|
|
1302
|
-
this["__v_isRef"] = true;
|
|
1303
|
-
this._value = void 0;
|
|
1304
|
-
}
|
|
1305
|
-
get value() {
|
|
1306
|
-
const val = this._object[this._key];
|
|
1307
|
-
return this._value = val === void 0 ? this._defaultValue : val;
|
|
1308
|
-
}
|
|
1309
|
-
set value(newVal) {
|
|
1310
|
-
this._object[this._key] = newVal;
|
|
1311
|
-
}
|
|
1312
|
-
get dep() {
|
|
1313
|
-
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
class GetterRefImpl {
|
|
1317
|
-
constructor(_getter) {
|
|
1318
|
-
this._getter = _getter;
|
|
1319
|
-
this["__v_isRef"] = true;
|
|
1320
|
-
this["__v_isReadonly"] = true;
|
|
1321
|
-
this._value = void 0;
|
|
1322
|
-
}
|
|
1323
|
-
get value() {
|
|
1324
|
-
return this._value = this._getter();
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
function toRef(source, key, defaultValue) {
|
|
1328
|
-
if (isRef(source)) {
|
|
1329
|
-
return source;
|
|
1330
|
-
} else if (shared.isFunction(source)) {
|
|
1331
|
-
return new GetterRefImpl(source);
|
|
1332
|
-
} else if (shared.isObject(source) && arguments.length > 1) {
|
|
1333
|
-
return propertyToRef(source, key, defaultValue);
|
|
1334
|
-
} else {
|
|
1335
|
-
return ref(source);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
function propertyToRef(source, key, defaultValue) {
|
|
1339
|
-
const val = source[key];
|
|
1340
|
-
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
const EffectFlags = {
|
|
1344
|
-
"ALLOW_RECURSE": 128,
|
|
1345
|
-
"128": "ALLOW_RECURSE",
|
|
1346
|
-
"PAUSED": 256,
|
|
1347
|
-
"256": "PAUSED",
|
|
1348
|
-
"STOP": 1024,
|
|
1349
|
-
"1024": "STOP"
|
|
1350
|
-
};
|
|
1351
|
-
class ReactiveEffect {
|
|
1352
|
-
constructor(fn) {
|
|
1353
|
-
this.deps = void 0;
|
|
1354
|
-
this.depsTail = void 0;
|
|
1355
|
-
this.subs = void 0;
|
|
1356
|
-
this.subsTail = void 0;
|
|
1357
|
-
this.flags = ReactiveFlags$1.Watching | ReactiveFlags$1.Dirty;
|
|
1358
|
-
/**
|
|
1359
|
-
* @internal
|
|
1360
|
-
*/
|
|
1361
|
-
this.cleanups = [];
|
|
1362
|
-
/**
|
|
1363
|
-
* @internal
|
|
1364
|
-
*/
|
|
1365
|
-
this.cleanupsLength = 0;
|
|
1366
|
-
if (fn !== void 0) {
|
|
1367
|
-
this.fn = fn;
|
|
1368
|
-
}
|
|
1369
|
-
if (activeEffectScope) {
|
|
1370
|
-
link(this, activeEffectScope);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
// @ts-expect-error
|
|
1374
|
-
fn() {
|
|
1375
|
-
}
|
|
1376
|
-
get active() {
|
|
1377
|
-
return !(this.flags & 1024);
|
|
1378
|
-
}
|
|
1379
|
-
pause() {
|
|
1380
|
-
this.flags |= 256;
|
|
1381
|
-
}
|
|
1382
|
-
resume() {
|
|
1383
|
-
const flags = this.flags &= -257;
|
|
1384
|
-
if (flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) {
|
|
1385
|
-
this.notify();
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
notify() {
|
|
1389
|
-
if (!(this.flags & 256) && this.dirty) {
|
|
1390
|
-
this.run();
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
run() {
|
|
1394
|
-
if (!this.active) {
|
|
1395
|
-
return this.fn();
|
|
1396
|
-
}
|
|
1397
|
-
cleanup(this);
|
|
1398
|
-
const prevSub = startTracking(this);
|
|
1399
|
-
try {
|
|
1400
|
-
return this.fn();
|
|
1401
|
-
} finally {
|
|
1402
|
-
endTracking(this, prevSub);
|
|
1403
|
-
const flags = this.flags;
|
|
1404
|
-
if ((flags & (ReactiveFlags$1.Recursed | 128)) === (ReactiveFlags$1.Recursed | 128)) {
|
|
1405
|
-
this.flags = flags & ~ReactiveFlags$1.Recursed;
|
|
1406
|
-
this.notify();
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
stop() {
|
|
1411
|
-
if (!this.active) {
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
this.flags = 1024;
|
|
1415
|
-
let dep = this.deps;
|
|
1416
|
-
while (dep !== void 0) {
|
|
1417
|
-
dep = unlink(dep, this);
|
|
1418
|
-
}
|
|
1419
|
-
const sub = this.subs;
|
|
1420
|
-
if (sub !== void 0) {
|
|
1421
|
-
unlink(sub);
|
|
1422
|
-
}
|
|
1423
|
-
cleanup(this);
|
|
1424
|
-
}
|
|
1425
|
-
get dirty() {
|
|
1426
|
-
const flags = this.flags;
|
|
1427
|
-
if (flags & ReactiveFlags$1.Dirty) {
|
|
1428
|
-
return true;
|
|
1429
|
-
}
|
|
1430
|
-
if (flags & ReactiveFlags$1.Pending) {
|
|
1431
|
-
if (checkDirty(this.deps, this)) {
|
|
1432
|
-
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1433
|
-
return true;
|
|
1434
|
-
} else {
|
|
1435
|
-
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
return false;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
{
|
|
1442
|
-
setupOnTrigger(ReactiveEffect);
|
|
1443
|
-
}
|
|
1444
|
-
function effect(fn, options) {
|
|
1445
|
-
if (fn.effect instanceof ReactiveEffect) {
|
|
1446
|
-
fn = fn.effect.fn;
|
|
1447
|
-
}
|
|
1448
|
-
const e = new ReactiveEffect(fn);
|
|
1449
|
-
if (options) {
|
|
1450
|
-
const { onStop, scheduler } = options;
|
|
1451
|
-
if (onStop) {
|
|
1452
|
-
options.onStop = void 0;
|
|
1453
|
-
const stop2 = e.stop.bind(e);
|
|
1454
|
-
e.stop = () => {
|
|
1455
|
-
stop2();
|
|
1456
|
-
onStop();
|
|
1457
|
-
};
|
|
1458
|
-
}
|
|
1459
|
-
if (scheduler) {
|
|
1460
|
-
options.scheduler = void 0;
|
|
1461
|
-
e.notify = () => {
|
|
1462
|
-
if (!(e.flags & 256)) {
|
|
1463
|
-
scheduler();
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
}
|
|
1467
|
-
shared.extend(e, options);
|
|
1468
|
-
}
|
|
1469
|
-
try {
|
|
1470
|
-
e.run();
|
|
1471
|
-
} catch (err) {
|
|
1472
|
-
e.stop();
|
|
1473
|
-
throw err;
|
|
1474
|
-
}
|
|
1475
|
-
const runner = e.run.bind(e);
|
|
1476
|
-
runner.effect = e;
|
|
1477
|
-
return runner;
|
|
1478
|
-
}
|
|
1479
|
-
function stop(runner) {
|
|
1480
|
-
runner.effect.stop();
|
|
1481
|
-
}
|
|
1482
|
-
const resetTrackingStack = [];
|
|
1483
|
-
function pauseTracking() {
|
|
1484
|
-
resetTrackingStack.push(activeSub);
|
|
1485
|
-
setActiveSub();
|
|
1486
|
-
}
|
|
1487
|
-
function enableTracking() {
|
|
1488
|
-
const isPaused = activeSub === void 0;
|
|
1489
|
-
if (!isPaused) {
|
|
1490
|
-
resetTrackingStack.push(activeSub);
|
|
1491
|
-
} else {
|
|
1492
|
-
resetTrackingStack.push(void 0);
|
|
1493
|
-
for (let i = resetTrackingStack.length - 1; i >= 0; i--) {
|
|
1494
|
-
if (resetTrackingStack[i] !== void 0) {
|
|
1495
|
-
setActiveSub(resetTrackingStack[i]);
|
|
1496
|
-
break;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
function resetTracking() {
|
|
1502
|
-
if (resetTrackingStack.length === 0) {
|
|
1503
|
-
warn(
|
|
1504
|
-
`resetTracking() was called when there was no active tracking to reset.`
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1507
|
-
if (resetTrackingStack.length) {
|
|
1508
|
-
setActiveSub(resetTrackingStack.pop());
|
|
1509
|
-
} else {
|
|
1510
|
-
setActiveSub();
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
function cleanup(sub) {
|
|
1514
|
-
const l = sub.cleanupsLength;
|
|
1515
|
-
if (l) {
|
|
1516
|
-
for (let i = 0; i < l; i++) {
|
|
1517
|
-
sub.cleanups[i]();
|
|
1518
|
-
}
|
|
1519
|
-
sub.cleanupsLength = 0;
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
function onEffectCleanup(fn, failSilently = false) {
|
|
1523
|
-
if (activeSub instanceof ReactiveEffect) {
|
|
1524
|
-
activeSub.cleanups[activeSub.cleanupsLength++] = () => cleanupEffect(fn);
|
|
1525
|
-
} else if (!failSilently) {
|
|
1526
|
-
warn(
|
|
1527
|
-
`onEffectCleanup() was called when there was no active effect to associate with.`
|
|
1528
|
-
);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
function cleanupEffect(fn) {
|
|
1532
|
-
const prevSub = setActiveSub();
|
|
1533
|
-
try {
|
|
1534
|
-
fn();
|
|
1535
|
-
} finally {
|
|
1536
|
-
setActiveSub(prevSub);
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
let activeEffectScope;
|
|
1541
|
-
class EffectScope {
|
|
1542
|
-
constructor(detached = false) {
|
|
1543
|
-
this.deps = void 0;
|
|
1544
|
-
this.depsTail = void 0;
|
|
1545
|
-
this.subs = void 0;
|
|
1546
|
-
this.subsTail = void 0;
|
|
1547
|
-
this.flags = 0;
|
|
1548
|
-
/**
|
|
1549
|
-
* @internal
|
|
1550
|
-
*/
|
|
1551
|
-
this.cleanups = [];
|
|
1552
|
-
/**
|
|
1553
|
-
* @internal
|
|
1554
|
-
*/
|
|
1555
|
-
this.cleanupsLength = 0;
|
|
1556
|
-
if (!detached && activeEffectScope) {
|
|
1557
|
-
link(this, activeEffectScope);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
get active() {
|
|
1561
|
-
return !(this.flags & 1024);
|
|
1562
|
-
}
|
|
1563
|
-
pause() {
|
|
1564
|
-
if (!(this.flags & 256)) {
|
|
1565
|
-
this.flags |= 256;
|
|
1566
|
-
for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
|
|
1567
|
-
const dep = link2.dep;
|
|
1568
|
-
if ("pause" in dep) {
|
|
1569
|
-
dep.pause();
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Resumes the effect scope, including all child scopes and effects.
|
|
1576
|
-
*/
|
|
1577
|
-
resume() {
|
|
1578
|
-
const flags = this.flags;
|
|
1579
|
-
if (flags & 256) {
|
|
1580
|
-
this.flags = flags & -257;
|
|
1581
|
-
for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
|
|
1582
|
-
const dep = link2.dep;
|
|
1583
|
-
if ("resume" in dep) {
|
|
1584
|
-
dep.resume();
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
run(fn) {
|
|
1590
|
-
const prevScope = activeEffectScope;
|
|
1591
|
-
try {
|
|
1592
|
-
activeEffectScope = this;
|
|
1593
|
-
return fn();
|
|
1594
|
-
} finally {
|
|
1595
|
-
activeEffectScope = prevScope;
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
stop() {
|
|
1599
|
-
if (!this.active) {
|
|
1600
|
-
return;
|
|
1601
|
-
}
|
|
1602
|
-
this.flags = 1024;
|
|
1603
|
-
let dep = this.deps;
|
|
1604
|
-
while (dep !== void 0) {
|
|
1605
|
-
const node = dep.dep;
|
|
1606
|
-
if ("stop" in node) {
|
|
1607
|
-
dep = dep.nextDep;
|
|
1608
|
-
node.stop();
|
|
1609
|
-
} else {
|
|
1610
|
-
dep = unlink(dep, this);
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
const sub = this.subs;
|
|
1614
|
-
if (sub !== void 0) {
|
|
1615
|
-
unlink(sub);
|
|
1616
|
-
}
|
|
1617
|
-
cleanup(this);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
function effectScope(detached) {
|
|
1621
|
-
return new EffectScope(detached);
|
|
1622
|
-
}
|
|
1623
|
-
function getCurrentScope() {
|
|
1624
|
-
return activeEffectScope;
|
|
1625
|
-
}
|
|
1626
|
-
function setCurrentScope(scope) {
|
|
1627
|
-
try {
|
|
1628
|
-
return activeEffectScope;
|
|
1629
|
-
} finally {
|
|
1630
|
-
activeEffectScope = scope;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
function onScopeDispose(fn, failSilently = false) {
|
|
1634
|
-
if (activeEffectScope !== void 0) {
|
|
1635
|
-
activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
|
|
1636
|
-
} else if (!failSilently) {
|
|
1637
|
-
warn(
|
|
1638
|
-
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
1639
|
-
);
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
class ComputedRefImpl {
|
|
1644
|
-
constructor(fn, setter) {
|
|
1645
|
-
this.fn = fn;
|
|
1646
|
-
this.setter = setter;
|
|
1647
|
-
/**
|
|
1648
|
-
* @internal
|
|
1649
|
-
*/
|
|
1650
|
-
this._value = void 0;
|
|
1651
|
-
this.subs = void 0;
|
|
1652
|
-
this.subsTail = void 0;
|
|
1653
|
-
this.deps = void 0;
|
|
1654
|
-
this.depsTail = void 0;
|
|
1655
|
-
this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
|
|
1656
|
-
/**
|
|
1657
|
-
* @internal
|
|
1658
|
-
*/
|
|
1659
|
-
this.__v_isRef = true;
|
|
1660
|
-
this["__v_isReadonly"] = !setter;
|
|
1661
|
-
}
|
|
1662
|
-
// TODO isolatedDeclarations "__v_isReadonly"
|
|
1663
|
-
// for backwards compat
|
|
1664
|
-
get effect() {
|
|
1665
|
-
return this;
|
|
1666
|
-
}
|
|
1667
|
-
// for backwards compat
|
|
1668
|
-
get dep() {
|
|
1669
|
-
return this;
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* @internal
|
|
1673
|
-
* for backwards compat
|
|
1674
|
-
*/
|
|
1675
|
-
get _dirty() {
|
|
1676
|
-
const flags = this.flags;
|
|
1677
|
-
if (flags & ReactiveFlags$1.Dirty) {
|
|
1678
|
-
return true;
|
|
1679
|
-
}
|
|
1680
|
-
if (flags & ReactiveFlags$1.Pending) {
|
|
1681
|
-
if (checkDirty(this.deps, this)) {
|
|
1682
|
-
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1683
|
-
return true;
|
|
1684
|
-
} else {
|
|
1685
|
-
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
return false;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* @internal
|
|
1692
|
-
* for backwards compat
|
|
1693
|
-
*/
|
|
1694
|
-
set _dirty(v) {
|
|
1695
|
-
if (v) {
|
|
1696
|
-
this.flags |= ReactiveFlags$1.Dirty;
|
|
1697
|
-
} else {
|
|
1698
|
-
this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
get value() {
|
|
1702
|
-
const flags = this.flags;
|
|
1703
|
-
if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
|
|
1704
|
-
if (this.update()) {
|
|
1705
|
-
const subs = this.subs;
|
|
1706
|
-
if (subs !== void 0) {
|
|
1707
|
-
shallowPropagate(subs);
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
} else if (flags & ReactiveFlags$1.Pending) {
|
|
1711
|
-
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1712
|
-
}
|
|
1713
|
-
if (activeSub !== void 0) {
|
|
1714
|
-
{
|
|
1715
|
-
onTrack(activeSub, {
|
|
1716
|
-
target: this,
|
|
1717
|
-
type: "get",
|
|
1718
|
-
key: "value"
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
link(this, activeSub);
|
|
1722
|
-
} else if (activeEffectScope !== void 0) {
|
|
1723
|
-
link(this, activeEffectScope);
|
|
1724
|
-
}
|
|
1725
|
-
return this._value;
|
|
1726
|
-
}
|
|
1727
|
-
set value(newValue) {
|
|
1728
|
-
if (this.setter) {
|
|
1729
|
-
this.setter(newValue);
|
|
1730
|
-
} else {
|
|
1731
|
-
warn("Write operation failed: computed value is readonly");
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
update() {
|
|
1735
|
-
const prevSub = startTracking(this);
|
|
1736
|
-
try {
|
|
1737
|
-
const oldValue = this._value;
|
|
1738
|
-
const newValue = this.fn(oldValue);
|
|
1739
|
-
if (shared.hasChanged(oldValue, newValue)) {
|
|
1740
|
-
this._value = newValue;
|
|
1741
|
-
return true;
|
|
1742
|
-
}
|
|
1743
|
-
return false;
|
|
1744
|
-
} finally {
|
|
1745
|
-
endTracking(this, prevSub);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
{
|
|
1750
|
-
setupOnTrigger(ComputedRefImpl);
|
|
1751
|
-
}
|
|
1752
|
-
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1753
|
-
let getter;
|
|
1754
|
-
let setter;
|
|
1755
|
-
if (shared.isFunction(getterOrOptions)) {
|
|
1756
|
-
getter = getterOrOptions;
|
|
1757
|
-
} else {
|
|
1758
|
-
getter = getterOrOptions.get;
|
|
1759
|
-
setter = getterOrOptions.set;
|
|
1760
|
-
}
|
|
1761
|
-
const cRef = new ComputedRefImpl(getter, setter);
|
|
1762
|
-
if (debugOptions && !isSSR) {
|
|
1763
|
-
cRef.onTrack = debugOptions.onTrack;
|
|
1764
|
-
cRef.onTrigger = debugOptions.onTrigger;
|
|
1765
|
-
}
|
|
1766
|
-
return cRef;
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
const TrackOpTypes = {
|
|
1770
|
-
"GET": "get",
|
|
1771
|
-
"HAS": "has",
|
|
1772
|
-
"ITERATE": "iterate"
|
|
1773
|
-
};
|
|
1774
|
-
const TriggerOpTypes = {
|
|
1775
|
-
"SET": "set",
|
|
1776
|
-
"ADD": "add",
|
|
1777
|
-
"DELETE": "delete",
|
|
1778
|
-
"CLEAR": "clear"
|
|
1779
|
-
};
|
|
1780
|
-
const ReactiveFlags = {
|
|
1781
|
-
"SKIP": "__v_skip",
|
|
1782
|
-
"IS_REACTIVE": "__v_isReactive",
|
|
1783
|
-
"IS_READONLY": "__v_isReadonly",
|
|
1784
|
-
"IS_SHALLOW": "__v_isShallow",
|
|
1785
|
-
"RAW": "__v_raw",
|
|
1786
|
-
"IS_REF": "__v_isRef"
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
const WatchErrorCodes = {
|
|
1790
|
-
"WATCH_GETTER": 2,
|
|
1791
|
-
"2": "WATCH_GETTER",
|
|
1792
|
-
"WATCH_CALLBACK": 3,
|
|
1793
|
-
"3": "WATCH_CALLBACK",
|
|
1794
|
-
"WATCH_CLEANUP": 4,
|
|
1795
|
-
"4": "WATCH_CLEANUP"
|
|
1796
|
-
};
|
|
1797
|
-
const INITIAL_WATCHER_VALUE = {};
|
|
1798
|
-
let activeWatcher = void 0;
|
|
1799
|
-
function getCurrentWatcher() {
|
|
1800
|
-
return activeWatcher;
|
|
1801
|
-
}
|
|
1802
|
-
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1803
|
-
if (owner) {
|
|
1804
|
-
const { call } = owner.options;
|
|
1805
|
-
if (call) {
|
|
1806
|
-
owner.cleanups[owner.cleanupsLength++] = () => call(cleanupFn, 4);
|
|
1807
|
-
} else {
|
|
1808
|
-
owner.cleanups[owner.cleanupsLength++] = cleanupFn;
|
|
1809
|
-
}
|
|
1810
|
-
} else if (!failSilently) {
|
|
1811
|
-
warn(
|
|
1812
|
-
`onWatcherCleanup() was called when there was no active watcher to associate with.`
|
|
1813
|
-
);
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
class WatcherEffect extends ReactiveEffect {
|
|
1817
|
-
constructor(source, cb, options = shared.EMPTY_OBJ) {
|
|
1818
|
-
const { deep, once, call, onWarn } = options;
|
|
1819
|
-
let getter;
|
|
1820
|
-
let forceTrigger = false;
|
|
1821
|
-
let isMultiSource = false;
|
|
1822
|
-
if (isRef(source)) {
|
|
1823
|
-
getter = () => source.value;
|
|
1824
|
-
forceTrigger = isShallow(source);
|
|
1825
|
-
} else if (isReactive(source)) {
|
|
1826
|
-
getter = () => reactiveGetter(source, deep);
|
|
1827
|
-
forceTrigger = true;
|
|
1828
|
-
} else if (shared.isArray(source)) {
|
|
1829
|
-
isMultiSource = true;
|
|
1830
|
-
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1831
|
-
getter = () => source.map((s) => {
|
|
1832
|
-
if (isRef(s)) {
|
|
1833
|
-
return s.value;
|
|
1834
|
-
} else if (isReactive(s)) {
|
|
1835
|
-
return reactiveGetter(s, deep);
|
|
1836
|
-
} else if (shared.isFunction(s)) {
|
|
1837
|
-
return call ? call(s, 2) : s();
|
|
1838
|
-
} else {
|
|
1839
|
-
warnInvalidSource(s, onWarn);
|
|
1840
|
-
}
|
|
1841
|
-
});
|
|
1842
|
-
} else if (shared.isFunction(source)) {
|
|
1843
|
-
if (cb) {
|
|
1844
|
-
getter = call ? () => call(source, 2) : source;
|
|
1845
|
-
} else {
|
|
1846
|
-
getter = () => {
|
|
1847
|
-
if (this.cleanupsLength) {
|
|
1848
|
-
const prevSub = setActiveSub();
|
|
1849
|
-
try {
|
|
1850
|
-
cleanup(this);
|
|
1851
|
-
} finally {
|
|
1852
|
-
setActiveSub(prevSub);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
const currentEffect = activeWatcher;
|
|
1856
|
-
activeWatcher = this;
|
|
1857
|
-
try {
|
|
1858
|
-
return call ? call(source, 3, [
|
|
1859
|
-
this.boundCleanup
|
|
1860
|
-
]) : source(this.boundCleanup);
|
|
1861
|
-
} finally {
|
|
1862
|
-
activeWatcher = currentEffect;
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
} else {
|
|
1867
|
-
getter = shared.NOOP;
|
|
1868
|
-
warnInvalidSource(source, onWarn);
|
|
1869
|
-
}
|
|
1870
|
-
if (cb && deep) {
|
|
1871
|
-
const baseGetter = getter;
|
|
1872
|
-
const depth = deep === true ? Infinity : deep;
|
|
1873
|
-
getter = () => traverse(baseGetter(), depth);
|
|
1874
|
-
}
|
|
1875
|
-
super(getter);
|
|
1876
|
-
this.cb = cb;
|
|
1877
|
-
this.options = options;
|
|
1878
|
-
this.boundCleanup = (fn) => onWatcherCleanup(fn, false, this);
|
|
1879
|
-
this.forceTrigger = forceTrigger;
|
|
1880
|
-
this.isMultiSource = isMultiSource;
|
|
1881
|
-
if (once && cb) {
|
|
1882
|
-
const _cb = cb;
|
|
1883
|
-
cb = (...args) => {
|
|
1884
|
-
_cb(...args);
|
|
1885
|
-
this.stop();
|
|
1886
|
-
};
|
|
1887
|
-
}
|
|
1888
|
-
this.cb = cb;
|
|
1889
|
-
this.oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1890
|
-
{
|
|
1891
|
-
this.onTrack = options.onTrack;
|
|
1892
|
-
this.onTrigger = options.onTrigger;
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
run(initialRun = false) {
|
|
1896
|
-
const oldValue = this.oldValue;
|
|
1897
|
-
const newValue = this.oldValue = super.run();
|
|
1898
|
-
if (!this.cb) {
|
|
1899
|
-
return;
|
|
1900
|
-
}
|
|
1901
|
-
const { immediate, deep, call } = this.options;
|
|
1902
|
-
if (initialRun && !immediate) {
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
|
|
1906
|
-
cleanup(this);
|
|
1907
|
-
const currentWatcher = activeWatcher;
|
|
1908
|
-
activeWatcher = this;
|
|
1909
|
-
try {
|
|
1910
|
-
const args = [
|
|
1911
|
-
newValue,
|
|
1912
|
-
// pass undefined as the old value when it's changed for the first time
|
|
1913
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1914
|
-
this.boundCleanup
|
|
1915
|
-
];
|
|
1916
|
-
call ? call(this.cb, 3, args) : (
|
|
1917
|
-
// @ts-expect-error
|
|
1918
|
-
this.cb(...args)
|
|
1919
|
-
);
|
|
1920
|
-
} finally {
|
|
1921
|
-
activeWatcher = currentWatcher;
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
function reactiveGetter(source, deep) {
|
|
1927
|
-
if (deep) return source;
|
|
1928
|
-
if (isShallow(source) || deep === false || deep === 0)
|
|
1929
|
-
return traverse(source, 1);
|
|
1930
|
-
return traverse(source);
|
|
1931
|
-
}
|
|
1932
|
-
function warnInvalidSource(s, onWarn) {
|
|
1933
|
-
(onWarn || warn)(
|
|
1934
|
-
`Invalid watch source: `,
|
|
1935
|
-
s,
|
|
1936
|
-
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
1937
|
-
);
|
|
1938
|
-
}
|
|
1939
|
-
function watch(source, cb, options = shared.EMPTY_OBJ) {
|
|
1940
|
-
const effect = new WatcherEffect(source, cb, options);
|
|
1941
|
-
effect.run(true);
|
|
1942
|
-
const stop = effect.stop.bind(effect);
|
|
1943
|
-
stop.pause = effect.pause.bind(effect);
|
|
1944
|
-
stop.resume = effect.resume.bind(effect);
|
|
1945
|
-
stop.stop = stop;
|
|
1946
|
-
return stop;
|
|
1947
|
-
}
|
|
1948
|
-
function traverse(value, depth = Infinity, seen) {
|
|
1949
|
-
if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
|
|
1950
|
-
return value;
|
|
1951
|
-
}
|
|
1952
|
-
seen = seen || /* @__PURE__ */ new Set();
|
|
1953
|
-
if (seen.has(value)) {
|
|
1954
|
-
return value;
|
|
1955
|
-
}
|
|
1956
|
-
seen.add(value);
|
|
1957
|
-
depth--;
|
|
1958
|
-
if (isRef(value)) {
|
|
1959
|
-
traverse(value.value, depth, seen);
|
|
1960
|
-
} else if (shared.isArray(value)) {
|
|
1961
|
-
for (let i = 0; i < value.length; i++) {
|
|
1962
|
-
traverse(value[i], depth, seen);
|
|
1963
|
-
}
|
|
1964
|
-
} else if (shared.isSet(value) || shared.isMap(value)) {
|
|
1965
|
-
value.forEach((v) => {
|
|
1966
|
-
traverse(v, depth, seen);
|
|
1967
|
-
});
|
|
1968
|
-
} else if (shared.isPlainObject(value)) {
|
|
1969
|
-
for (const key in value) {
|
|
1970
|
-
traverse(value[key], depth, seen);
|
|
1971
|
-
}
|
|
1972
|
-
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
1973
|
-
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
1974
|
-
traverse(value[key], depth, seen);
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
return value;
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
1982
|
-
exports.EffectFlags = EffectFlags;
|
|
1983
|
-
exports.EffectScope = EffectScope;
|
|
1984
|
-
exports.ITERATE_KEY = ITERATE_KEY;
|
|
1985
|
-
exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY;
|
|
1986
|
-
exports.ReactiveEffect = ReactiveEffect;
|
|
1987
|
-
exports.ReactiveFlags = ReactiveFlags;
|
|
1988
|
-
exports.TrackOpTypes = TrackOpTypes;
|
|
1989
|
-
exports.TriggerOpTypes = TriggerOpTypes;
|
|
1990
|
-
exports.WatchErrorCodes = WatchErrorCodes;
|
|
1991
|
-
exports.WatcherEffect = WatcherEffect;
|
|
1992
|
-
exports.computed = computed;
|
|
1993
|
-
exports.customRef = customRef;
|
|
1994
|
-
exports.effect = effect;
|
|
1995
|
-
exports.effectScope = effectScope;
|
|
1996
|
-
exports.enableTracking = enableTracking;
|
|
1997
|
-
exports.getCurrentScope = getCurrentScope;
|
|
1998
|
-
exports.getCurrentWatcher = getCurrentWatcher;
|
|
1999
|
-
exports.isProxy = isProxy;
|
|
2000
|
-
exports.isReactive = isReactive;
|
|
2001
|
-
exports.isReadonly = isReadonly;
|
|
2002
|
-
exports.isRef = isRef;
|
|
2003
|
-
exports.isShallow = isShallow;
|
|
2004
|
-
exports.markRaw = markRaw;
|
|
2005
|
-
exports.onEffectCleanup = onEffectCleanup;
|
|
2006
|
-
exports.onScopeDispose = onScopeDispose;
|
|
2007
|
-
exports.onWatcherCleanup = onWatcherCleanup;
|
|
2008
|
-
exports.pauseTracking = pauseTracking;
|
|
2009
|
-
exports.proxyRefs = proxyRefs;
|
|
2010
|
-
exports.reactive = reactive;
|
|
2011
|
-
exports.reactiveReadArray = reactiveReadArray;
|
|
2012
|
-
exports.readonly = readonly;
|
|
2013
|
-
exports.ref = ref;
|
|
2014
|
-
exports.resetTracking = resetTracking;
|
|
2015
|
-
exports.setActiveSub = setActiveSub;
|
|
2016
|
-
exports.setCurrentScope = setCurrentScope;
|
|
2017
|
-
exports.shallowReactive = shallowReactive;
|
|
2018
|
-
exports.shallowReadArray = shallowReadArray;
|
|
2019
|
-
exports.shallowReadonly = shallowReadonly;
|
|
2020
|
-
exports.shallowRef = shallowRef;
|
|
2021
|
-
exports.stop = stop;
|
|
2022
|
-
exports.toRaw = toRaw;
|
|
2023
|
-
exports.toReactive = toReactive;
|
|
2024
|
-
exports.toReadonly = toReadonly;
|
|
2025
|
-
exports.toRef = toRef;
|
|
2026
|
-
exports.toRefs = toRefs;
|
|
2027
|
-
exports.toValue = toValue;
|
|
2028
|
-
exports.track = track;
|
|
2029
|
-
exports.traverse = traverse;
|
|
2030
|
-
exports.trigger = trigger;
|
|
2031
|
-
exports.triggerRef = triggerRef;
|
|
2032
|
-
exports.unref = unref;
|
|
2033
|
-
exports.watch = watch;
|