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