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