pinia-react 1.5.0 → 1.5.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 +3 -164
- package/dist/index.d.ts +368 -356
- package/dist/index.js +367 -2232
- package/dist/index.js.map +1 -0
- package/package.json +11 -4
package/dist/index.js
CHANGED
|
@@ -1,2253 +1,388 @@
|
|
|
1
|
-
|
|
1
|
+
// src/createPinia.ts
|
|
2
|
+
import { effectScope, markRaw, ref } from "@maoism/runtime-core";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return expectsLowerCase ? (val) => set2.has(val.toLowerCase()) : (val) => set2.has(val);
|
|
7
|
-
}
|
|
8
|
-
var EMPTY_OBJ = Object.freeze({});
|
|
9
|
-
var EMPTY_ARR = Object.freeze([]);
|
|
10
|
-
var NOOP = () => {};
|
|
11
|
-
var NO = () => false;
|
|
12
|
-
var extend = Object.assign;
|
|
13
|
-
var remove = (arr, el) => {
|
|
14
|
-
const i = arr.indexOf(el);
|
|
15
|
-
if (i > -1) arr.splice(i, 1);
|
|
16
|
-
};
|
|
17
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
18
|
-
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
19
|
-
var isArray = Array.isArray;
|
|
20
|
-
var isMap = (val) => toTypeString(val) === "[object Map]";
|
|
21
|
-
var isSet = (val) => toTypeString(val) === "[object Set]";
|
|
22
|
-
var isFunction = (val) => typeof val === "function";
|
|
23
|
-
var isString = (val) => typeof val === "string";
|
|
24
|
-
var isSymbol = (val) => typeof val === "symbol";
|
|
25
|
-
var isObject = (val) => val !== null && typeof val === "object";
|
|
26
|
-
var isPromise = (val) => {
|
|
27
|
-
return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
28
|
-
};
|
|
29
|
-
var objectToString = Object.prototype.toString;
|
|
30
|
-
var toTypeString = (value) => objectToString.call(value);
|
|
31
|
-
var toRawType = (value) => {
|
|
32
|
-
return toTypeString(value).slice(8, -1);
|
|
33
|
-
};
|
|
34
|
-
var isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
|
|
35
|
-
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
36
|
-
var cacheStringFunction = (fn) => {
|
|
37
|
-
const cache = /* @__PURE__ */ Object.create(null);
|
|
38
|
-
return (str) => {
|
|
39
|
-
const hit = cache[str];
|
|
40
|
-
return hit || (cache[str] = fn(str));
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
var camelizeRE = /-(\w)/g;
|
|
44
|
-
var camelize = cacheStringFunction((str) => {
|
|
45
|
-
return str.replace(camelizeRE, (_$1, c) => c ? c.toUpperCase() : "");
|
|
46
|
-
});
|
|
47
|
-
var hyphenateRE = /\B([A-Z])/g;
|
|
48
|
-
var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
49
|
-
var capitalize = cacheStringFunction((str) => {
|
|
50
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
51
|
-
});
|
|
52
|
-
var toHandlerKey = cacheStringFunction((str) => {
|
|
53
|
-
const s = str ? `on${capitalize(str)}` : ``;
|
|
54
|
-
return s;
|
|
55
|
-
});
|
|
56
|
-
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
57
|
-
var def = (obj, key, value) => {
|
|
58
|
-
Object.defineProperty(obj, key, {
|
|
59
|
-
configurable: true,
|
|
60
|
-
enumerable: false,
|
|
61
|
-
value
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
var _globalThis;
|
|
65
|
-
var getGlobalThis = () => {
|
|
66
|
-
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
67
|
-
};
|
|
68
|
-
var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
69
|
-
var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
|
|
70
|
-
function warn(msg, ...args) {
|
|
71
|
-
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
72
|
-
}
|
|
73
|
-
var activeEffectScope;
|
|
74
|
-
var EffectScope = class {
|
|
75
|
-
constructor(detached = false) {
|
|
76
|
-
this.detached = detached;
|
|
77
|
-
/**
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
this._active = true;
|
|
81
|
-
/**
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
this.effects = [];
|
|
85
|
-
/**
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
this.cleanups = [];
|
|
89
|
-
this.parent = activeEffectScope;
|
|
90
|
-
if (!detached && activeEffectScope) this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
91
|
-
}
|
|
92
|
-
get active() {
|
|
93
|
-
return this._active;
|
|
94
|
-
}
|
|
95
|
-
run(fn) {
|
|
96
|
-
if (this._active) {
|
|
97
|
-
const currentEffectScope = activeEffectScope;
|
|
98
|
-
try {
|
|
99
|
-
activeEffectScope = this;
|
|
100
|
-
return fn();
|
|
101
|
-
} finally {
|
|
102
|
-
activeEffectScope = currentEffectScope;
|
|
103
|
-
}
|
|
104
|
-
} else warn(`cannot run an inactive effect scope.`);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* This should only be called on non-detached scopes
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
on() {
|
|
111
|
-
activeEffectScope = this;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* This should only be called on non-detached scopes
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
off() {
|
|
118
|
-
activeEffectScope = this.parent;
|
|
119
|
-
}
|
|
120
|
-
stop(fromParent) {
|
|
121
|
-
if (this._active) {
|
|
122
|
-
let i, l;
|
|
123
|
-
for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop();
|
|
124
|
-
for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i]();
|
|
125
|
-
if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true);
|
|
126
|
-
if (!this.detached && this.parent && !fromParent) {
|
|
127
|
-
const last = this.parent.scopes.pop();
|
|
128
|
-
if (last && last !== this) {
|
|
129
|
-
this.parent.scopes[this.index] = last;
|
|
130
|
-
last.index = this.index;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
this.parent = void 0;
|
|
134
|
-
this._active = false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
function effectScope(detached) {
|
|
139
|
-
return new EffectScope(detached);
|
|
140
|
-
}
|
|
141
|
-
function recordEffectScope(effect2, scope = activeEffectScope) {
|
|
142
|
-
if (scope && scope.active) scope.effects.push(effect2);
|
|
143
|
-
}
|
|
144
|
-
function getCurrentScope() {
|
|
145
|
-
return activeEffectScope;
|
|
146
|
-
}
|
|
147
|
-
var activeEffect = { value: void 0 };
|
|
148
|
-
var ReactiveEffect = class {
|
|
149
|
-
constructor(fn, trigger2, scheduler, scope) {
|
|
150
|
-
this.fn = fn;
|
|
151
|
-
this.trigger = trigger2;
|
|
152
|
-
this.scheduler = scheduler;
|
|
153
|
-
this.active = true;
|
|
154
|
-
this.deps = [];
|
|
155
|
-
/**
|
|
156
|
-
* @internal
|
|
157
|
-
*/
|
|
158
|
-
this._dirtyLevel = 2;
|
|
159
|
-
/**
|
|
160
|
-
* @internal
|
|
161
|
-
*/
|
|
162
|
-
this._trackId = 0;
|
|
163
|
-
/**
|
|
164
|
-
* @internal
|
|
165
|
-
*/
|
|
166
|
-
this._runnings = 0;
|
|
167
|
-
/**
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
170
|
-
this._shouldSchedule = false;
|
|
171
|
-
/**
|
|
172
|
-
* @internal
|
|
173
|
-
*/
|
|
174
|
-
this._depsLength = 0;
|
|
175
|
-
recordEffectScope(this, scope);
|
|
176
|
-
}
|
|
177
|
-
get dirty() {
|
|
178
|
-
if (this._dirtyLevel === 1) {
|
|
179
|
-
pauseTracking();
|
|
180
|
-
for (let i = 0; i < this._depsLength; i++) {
|
|
181
|
-
const dep = this.deps[i];
|
|
182
|
-
if (dep.computed) {
|
|
183
|
-
triggerComputed(dep.computed);
|
|
184
|
-
if (this._dirtyLevel >= 2) break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (this._dirtyLevel < 2) this._dirtyLevel = 0;
|
|
188
|
-
resetTracking();
|
|
189
|
-
}
|
|
190
|
-
return this._dirtyLevel >= 2;
|
|
191
|
-
}
|
|
192
|
-
set dirty(v) {
|
|
193
|
-
this._dirtyLevel = v ? 2 : 0;
|
|
194
|
-
}
|
|
195
|
-
run() {
|
|
196
|
-
this._dirtyLevel = 0;
|
|
197
|
-
if (!this.active) return this.fn();
|
|
198
|
-
let lastShouldTrack = shouldTrack;
|
|
199
|
-
let lastEffect = activeEffect.value;
|
|
200
|
-
try {
|
|
201
|
-
shouldTrack = true;
|
|
202
|
-
activeEffect.value = this;
|
|
203
|
-
this._runnings++;
|
|
204
|
-
preCleanupEffect(this);
|
|
205
|
-
return this.fn();
|
|
206
|
-
} finally {
|
|
207
|
-
postCleanupEffect(this);
|
|
208
|
-
this._runnings--;
|
|
209
|
-
activeEffect.value = lastEffect;
|
|
210
|
-
shouldTrack = lastShouldTrack;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
stop() {
|
|
214
|
-
if (this.active) {
|
|
215
|
-
preCleanupEffect(this);
|
|
216
|
-
postCleanupEffect(this);
|
|
217
|
-
this.onStop?.();
|
|
218
|
-
this.active = false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
function triggerComputed(computed3) {
|
|
223
|
-
return computed3.value;
|
|
224
|
-
}
|
|
225
|
-
function preCleanupEffect(effect2) {
|
|
226
|
-
effect2._trackId++;
|
|
227
|
-
effect2._depsLength = 0;
|
|
228
|
-
}
|
|
229
|
-
function postCleanupEffect(effect2) {
|
|
230
|
-
if (effect2.deps && effect2.deps.length > effect2._depsLength) {
|
|
231
|
-
for (let i = effect2._depsLength; i < effect2.deps.length; i++) cleanupDepEffect(effect2.deps[i], effect2);
|
|
232
|
-
effect2.deps.length = effect2._depsLength;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function cleanupDepEffect(dep, effect2) {
|
|
236
|
-
const trackId = dep.get(effect2);
|
|
237
|
-
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
238
|
-
dep.delete(effect2);
|
|
239
|
-
if (dep.size === 0) dep.cleanup();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
var shouldTrack = true;
|
|
243
|
-
var pauseScheduleStack = 0;
|
|
244
|
-
var trackStack = [];
|
|
245
|
-
function pauseTracking() {
|
|
246
|
-
trackStack.push(shouldTrack);
|
|
247
|
-
shouldTrack = false;
|
|
248
|
-
}
|
|
249
|
-
function resetTracking() {
|
|
250
|
-
const last = trackStack.pop();
|
|
251
|
-
shouldTrack = last === void 0 ? true : last;
|
|
252
|
-
}
|
|
253
|
-
function pauseScheduling() {
|
|
254
|
-
pauseScheduleStack++;
|
|
255
|
-
}
|
|
256
|
-
function resetScheduling() {
|
|
257
|
-
pauseScheduleStack--;
|
|
258
|
-
while (!pauseScheduleStack && queueEffectSchedulers.length) queueEffectSchedulers.shift()();
|
|
259
|
-
}
|
|
260
|
-
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
261
|
-
if (dep.get(effect2) !== effect2._trackId) {
|
|
262
|
-
dep.set(effect2, effect2._trackId);
|
|
263
|
-
const oldDep = effect2.deps[effect2._depsLength];
|
|
264
|
-
if (oldDep !== dep) {
|
|
265
|
-
if (oldDep) cleanupDepEffect(oldDep, effect2);
|
|
266
|
-
effect2.deps[effect2._depsLength++] = dep;
|
|
267
|
-
} else effect2._depsLength++;
|
|
268
|
-
effect2.onTrack?.(extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
var queueEffectSchedulers = [];
|
|
272
|
-
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
273
|
-
pauseScheduling();
|
|
274
|
-
for (const effect2 of dep.keys()) {
|
|
275
|
-
if (dep.get(effect2) !== effect2._trackId) continue;
|
|
276
|
-
if (effect2._dirtyLevel < dirtyLevel) {
|
|
277
|
-
const lastDirtyLevel = effect2._dirtyLevel;
|
|
278
|
-
effect2._dirtyLevel = dirtyLevel;
|
|
279
|
-
if (lastDirtyLevel === 0) {
|
|
280
|
-
effect2._shouldSchedule = true;
|
|
281
|
-
effect2.onTrigger?.(extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
282
|
-
effect2.trigger();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (effect2.scheduler && effect2._shouldSchedule && (!effect2._runnings || effect2.allowRecurse)) {
|
|
286
|
-
effect2._shouldSchedule = false;
|
|
287
|
-
queueEffectSchedulers.push(effect2.scheduler);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
resetScheduling();
|
|
291
|
-
}
|
|
292
|
-
var createDep = (cleanup, computed3) => {
|
|
293
|
-
const dep = /* @__PURE__ */ new Map();
|
|
294
|
-
dep.cleanup = cleanup;
|
|
295
|
-
dep.computed = computed3;
|
|
296
|
-
return dep;
|
|
297
|
-
};
|
|
298
|
-
var targetMap = /* @__PURE__ */ new WeakMap();
|
|
299
|
-
var ITERATE_KEY = Symbol("iterate");
|
|
300
|
-
var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
|
|
301
|
-
function track(target, type, key) {
|
|
302
|
-
if (shouldTrack && activeEffect.value) {
|
|
303
|
-
let depsMap = targetMap.get(target);
|
|
304
|
-
if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
305
|
-
let dep = depsMap.get(key);
|
|
306
|
-
if (!dep) depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
307
|
-
trackEffect(activeEffect.value, dep, {
|
|
308
|
-
target,
|
|
309
|
-
type,
|
|
310
|
-
key
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
315
|
-
const depsMap = targetMap.get(target);
|
|
316
|
-
if (!depsMap) return;
|
|
317
|
-
let deps = [];
|
|
318
|
-
if (type === "clear") deps = [...depsMap.values()];
|
|
319
|
-
else if (key === "length" && isArray(target)) {
|
|
320
|
-
const newLength = Number(newValue);
|
|
321
|
-
depsMap.forEach((dep, key2) => {
|
|
322
|
-
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) deps.push(dep);
|
|
323
|
-
});
|
|
324
|
-
} else {
|
|
325
|
-
if (key !== void 0) deps.push(depsMap.get(key));
|
|
326
|
-
switch (type) {
|
|
327
|
-
case "add":
|
|
328
|
-
if (!isArray(target)) {
|
|
329
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
330
|
-
if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
331
|
-
} else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
|
|
332
|
-
break;
|
|
333
|
-
case "delete":
|
|
334
|
-
if (!isArray(target)) {
|
|
335
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
336
|
-
if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
337
|
-
}
|
|
338
|
-
break;
|
|
339
|
-
case "set":
|
|
340
|
-
if (isMap(target)) deps.push(depsMap.get(ITERATE_KEY));
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
pauseScheduling();
|
|
345
|
-
for (const dep of deps) if (dep) triggerEffects(dep, 2, {
|
|
346
|
-
target,
|
|
347
|
-
type,
|
|
348
|
-
key,
|
|
349
|
-
newValue,
|
|
350
|
-
oldValue,
|
|
351
|
-
oldTarget
|
|
352
|
-
});
|
|
353
|
-
resetScheduling();
|
|
354
|
-
}
|
|
355
|
-
function getDepFromReactive(object, key) {
|
|
356
|
-
return targetMap.get(object)?.get(key);
|
|
357
|
-
}
|
|
358
|
-
var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
359
|
-
var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
360
|
-
var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
361
|
-
function createArrayInstrumentations() {
|
|
362
|
-
const instrumentations = {};
|
|
363
|
-
[
|
|
364
|
-
"includes",
|
|
365
|
-
"indexOf",
|
|
366
|
-
"lastIndexOf"
|
|
367
|
-
].forEach((key) => {
|
|
368
|
-
instrumentations[key] = function(...args) {
|
|
369
|
-
const arr = toRaw(this);
|
|
370
|
-
for (let i = 0, l = this.length; i < l; i++) track(arr, "get", i + "");
|
|
371
|
-
const res = arr[key](...args);
|
|
372
|
-
if (res === -1 || res === false) return arr[key](...args.map(toRaw));
|
|
373
|
-
else return res;
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
[
|
|
377
|
-
"push",
|
|
378
|
-
"pop",
|
|
379
|
-
"shift",
|
|
380
|
-
"unshift",
|
|
381
|
-
"splice"
|
|
382
|
-
].forEach((key) => {
|
|
383
|
-
instrumentations[key] = function(...args) {
|
|
384
|
-
pauseTracking();
|
|
385
|
-
pauseScheduling();
|
|
386
|
-
const res = toRaw(this)[key].apply(this, args);
|
|
387
|
-
resetScheduling();
|
|
388
|
-
resetTracking();
|
|
389
|
-
return res;
|
|
390
|
-
};
|
|
391
|
-
});
|
|
392
|
-
return instrumentations;
|
|
393
|
-
}
|
|
394
|
-
function hasOwnProperty2(key) {
|
|
395
|
-
const obj = toRaw(this);
|
|
396
|
-
track(obj, "has", key);
|
|
397
|
-
return obj.hasOwnProperty(key);
|
|
398
|
-
}
|
|
399
|
-
var BaseReactiveHandler = class {
|
|
400
|
-
constructor(_isReadonly = false, _shallow = false) {
|
|
401
|
-
this._isReadonly = _isReadonly;
|
|
402
|
-
this._shallow = _shallow;
|
|
403
|
-
}
|
|
404
|
-
get(target, key, receiver) {
|
|
405
|
-
const isReadonly2 = this._isReadonly, shallow = this._shallow;
|
|
406
|
-
if (key === "__v_isReactive") return !isReadonly2;
|
|
407
|
-
else if (key === "__v_isReadonly") return isReadonly2;
|
|
408
|
-
else if (key === "__v_isShallow") return shallow;
|
|
409
|
-
else if (key === "__v_raw") {
|
|
410
|
-
if (receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
const targetIsArray = isArray(target);
|
|
414
|
-
if (!isReadonly2) {
|
|
415
|
-
if (targetIsArray && hasOwn(arrayInstrumentations, key)) return Reflect.get(arrayInstrumentations, key, receiver);
|
|
416
|
-
if (key === "hasOwnProperty") return hasOwnProperty2;
|
|
417
|
-
}
|
|
418
|
-
const res = Reflect.get(target, key, receiver);
|
|
419
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
|
|
420
|
-
if (!isReadonly2) track(target, "get", key);
|
|
421
|
-
if (shallow) return res;
|
|
422
|
-
if (isRef(res)) return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
423
|
-
if (isObject(res)) return isReadonly2 ? readonly(res) : reactive(res);
|
|
424
|
-
return res;
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
428
|
-
constructor(shallow = false) {
|
|
429
|
-
super(false, shallow);
|
|
430
|
-
}
|
|
431
|
-
set(target, key, value, receiver) {
|
|
432
|
-
let oldValue = target[key];
|
|
433
|
-
if (!this._shallow) {
|
|
434
|
-
const isOldValueReadonly = isReadonly(oldValue);
|
|
435
|
-
if (!isShallow(value) && !isReadonly(value)) {
|
|
436
|
-
oldValue = toRaw(oldValue);
|
|
437
|
-
value = toRaw(value);
|
|
438
|
-
}
|
|
439
|
-
if (!isArray(target) && isRef(oldValue) && !isRef(value)) if (isOldValueReadonly) return false;
|
|
440
|
-
else {
|
|
441
|
-
oldValue.value = value;
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
446
|
-
const result = Reflect.set(target, key, value, receiver);
|
|
447
|
-
if (target === toRaw(receiver)) {
|
|
448
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
449
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
450
|
-
}
|
|
451
|
-
return result;
|
|
452
|
-
}
|
|
453
|
-
deleteProperty(target, key) {
|
|
454
|
-
const hadKey = hasOwn(target, key);
|
|
455
|
-
const oldValue = target[key];
|
|
456
|
-
const result = Reflect.deleteProperty(target, key);
|
|
457
|
-
if (result && hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
458
|
-
return result;
|
|
459
|
-
}
|
|
460
|
-
has(target, key) {
|
|
461
|
-
const result = Reflect.has(target, key);
|
|
462
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
|
|
463
|
-
return result;
|
|
464
|
-
}
|
|
465
|
-
ownKeys(target) {
|
|
466
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
467
|
-
return Reflect.ownKeys(target);
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
471
|
-
constructor(shallow = false) {
|
|
472
|
-
super(true, shallow);
|
|
473
|
-
}
|
|
474
|
-
set(target, key) {
|
|
475
|
-
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
deleteProperty(target, key) {
|
|
479
|
-
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
480
|
-
return true;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
484
|
-
var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
485
|
-
var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
486
|
-
var toShallow = (value) => value;
|
|
487
|
-
var getProto = (v) => Reflect.getPrototypeOf(v);
|
|
488
|
-
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
489
|
-
target = target["__v_raw"];
|
|
490
|
-
const rawTarget = toRaw(target);
|
|
491
|
-
const rawKey = toRaw(key);
|
|
492
|
-
if (!isReadonly2) {
|
|
493
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "get", key);
|
|
494
|
-
track(rawTarget, "get", rawKey);
|
|
495
|
-
}
|
|
496
|
-
const { has: has2 } = getProto(rawTarget);
|
|
497
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
498
|
-
if (has2.call(rawTarget, key)) return wrap(target.get(key));
|
|
499
|
-
else if (has2.call(rawTarget, rawKey)) return wrap(target.get(rawKey));
|
|
500
|
-
else if (target !== rawTarget) target.get(key);
|
|
501
|
-
}
|
|
502
|
-
function has(key, isReadonly2 = false) {
|
|
503
|
-
const target = this["__v_raw"];
|
|
504
|
-
const rawTarget = toRaw(target);
|
|
505
|
-
const rawKey = toRaw(key);
|
|
506
|
-
if (!isReadonly2) {
|
|
507
|
-
if (hasChanged(key, rawKey)) track(rawTarget, "has", key);
|
|
508
|
-
track(rawTarget, "has", rawKey);
|
|
509
|
-
}
|
|
510
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
511
|
-
}
|
|
512
|
-
function size(target, isReadonly2 = false) {
|
|
513
|
-
target = target["__v_raw"];
|
|
514
|
-
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
515
|
-
return Reflect.get(target, "size", target);
|
|
516
|
-
}
|
|
517
|
-
function add(value) {
|
|
518
|
-
value = toRaw(value);
|
|
519
|
-
const target = toRaw(this);
|
|
520
|
-
const proto = getProto(target);
|
|
521
|
-
const hadKey = proto.has.call(target, value);
|
|
522
|
-
if (!hadKey) {
|
|
523
|
-
target.add(value);
|
|
524
|
-
trigger(target, "add", value, value);
|
|
525
|
-
}
|
|
526
|
-
return this;
|
|
527
|
-
}
|
|
528
|
-
function set(key, value) {
|
|
529
|
-
value = toRaw(value);
|
|
530
|
-
const target = toRaw(this);
|
|
531
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
532
|
-
let hadKey = has2.call(target, key);
|
|
533
|
-
if (!hadKey) {
|
|
534
|
-
key = toRaw(key);
|
|
535
|
-
hadKey = has2.call(target, key);
|
|
536
|
-
} else checkIdentityKeys(target, has2, key);
|
|
537
|
-
const oldValue = get2.call(target, key);
|
|
538
|
-
target.set(key, value);
|
|
539
|
-
if (!hadKey) trigger(target, "add", key, value);
|
|
540
|
-
else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
541
|
-
return this;
|
|
542
|
-
}
|
|
543
|
-
function deleteEntry(key) {
|
|
544
|
-
const target = toRaw(this);
|
|
545
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
546
|
-
let hadKey = has2.call(target, key);
|
|
547
|
-
if (!hadKey) {
|
|
548
|
-
key = toRaw(key);
|
|
549
|
-
hadKey = has2.call(target, key);
|
|
550
|
-
} else checkIdentityKeys(target, has2, key);
|
|
551
|
-
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
552
|
-
const result = target.delete(key);
|
|
553
|
-
if (hadKey) trigger(target, "delete", key, void 0, oldValue);
|
|
554
|
-
return result;
|
|
555
|
-
}
|
|
556
|
-
function clear() {
|
|
557
|
-
const target = toRaw(this);
|
|
558
|
-
const hadItems = target.size !== 0;
|
|
559
|
-
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
|
|
560
|
-
const result = target.clear();
|
|
561
|
-
if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget);
|
|
562
|
-
return result;
|
|
563
|
-
}
|
|
564
|
-
function createForEach(isReadonly2, isShallow2) {
|
|
565
|
-
return function forEach(callback, thisArg) {
|
|
566
|
-
const observed = this;
|
|
567
|
-
const target = observed["__v_raw"];
|
|
568
|
-
const rawTarget = toRaw(target);
|
|
569
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
570
|
-
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
571
|
-
return target.forEach((value, key) => {
|
|
572
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
573
|
-
});
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
577
|
-
return function(...args) {
|
|
578
|
-
const target = this["__v_raw"];
|
|
579
|
-
const rawTarget = toRaw(target);
|
|
580
|
-
const targetIsMap = isMap(rawTarget);
|
|
581
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
582
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
583
|
-
const innerIterator = target[method](...args);
|
|
584
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
585
|
-
!isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
586
|
-
return {
|
|
587
|
-
next() {
|
|
588
|
-
const { value, done } = innerIterator.next();
|
|
589
|
-
return done ? {
|
|
590
|
-
value,
|
|
591
|
-
done
|
|
592
|
-
} : {
|
|
593
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
594
|
-
done
|
|
595
|
-
};
|
|
596
|
-
},
|
|
597
|
-
[Symbol.iterator]() {
|
|
598
|
-
return this;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
function createReadonlyMethod(type) {
|
|
604
|
-
return function(...args) {
|
|
605
|
-
{
|
|
606
|
-
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
607
|
-
console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
|
608
|
-
}
|
|
609
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
function createInstrumentations() {
|
|
613
|
-
const mutableInstrumentations2 = {
|
|
614
|
-
get(key) {
|
|
615
|
-
return get(this, key);
|
|
616
|
-
},
|
|
617
|
-
get size() {
|
|
618
|
-
return size(this);
|
|
619
|
-
},
|
|
620
|
-
has,
|
|
621
|
-
add,
|
|
622
|
-
set,
|
|
623
|
-
delete: deleteEntry,
|
|
624
|
-
clear,
|
|
625
|
-
forEach: createForEach(false, false)
|
|
626
|
-
};
|
|
627
|
-
const shallowInstrumentations2 = {
|
|
628
|
-
get(key) {
|
|
629
|
-
return get(this, key, false, true);
|
|
630
|
-
},
|
|
631
|
-
get size() {
|
|
632
|
-
return size(this);
|
|
633
|
-
},
|
|
634
|
-
has,
|
|
635
|
-
add,
|
|
636
|
-
set,
|
|
637
|
-
delete: deleteEntry,
|
|
638
|
-
clear,
|
|
639
|
-
forEach: createForEach(false, true)
|
|
640
|
-
};
|
|
641
|
-
const readonlyInstrumentations2 = {
|
|
642
|
-
get(key) {
|
|
643
|
-
return get(this, key, true);
|
|
644
|
-
},
|
|
645
|
-
get size() {
|
|
646
|
-
return size(this, true);
|
|
647
|
-
},
|
|
648
|
-
has(key) {
|
|
649
|
-
return has.call(this, key, true);
|
|
650
|
-
},
|
|
651
|
-
add: createReadonlyMethod("add"),
|
|
652
|
-
set: createReadonlyMethod("set"),
|
|
653
|
-
delete: createReadonlyMethod("delete"),
|
|
654
|
-
clear: createReadonlyMethod("clear"),
|
|
655
|
-
forEach: createForEach(true, false)
|
|
656
|
-
};
|
|
657
|
-
const shallowReadonlyInstrumentations2 = {
|
|
658
|
-
get(key) {
|
|
659
|
-
return get(this, key, true, true);
|
|
660
|
-
},
|
|
661
|
-
get size() {
|
|
662
|
-
return size(this, true);
|
|
663
|
-
},
|
|
664
|
-
has(key) {
|
|
665
|
-
return has.call(this, key, true);
|
|
666
|
-
},
|
|
667
|
-
add: createReadonlyMethod("add"),
|
|
668
|
-
set: createReadonlyMethod("set"),
|
|
669
|
-
delete: createReadonlyMethod("delete"),
|
|
670
|
-
clear: createReadonlyMethod("clear"),
|
|
671
|
-
forEach: createForEach(true, true)
|
|
672
|
-
};
|
|
673
|
-
const iteratorMethods = [
|
|
674
|
-
"keys",
|
|
675
|
-
"values",
|
|
676
|
-
"entries",
|
|
677
|
-
Symbol.iterator
|
|
678
|
-
];
|
|
679
|
-
iteratorMethods.forEach((method) => {
|
|
680
|
-
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
|
681
|
-
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
682
|
-
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
683
|
-
shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true);
|
|
684
|
-
});
|
|
685
|
-
return [
|
|
686
|
-
mutableInstrumentations2,
|
|
687
|
-
readonlyInstrumentations2,
|
|
688
|
-
shallowInstrumentations2,
|
|
689
|
-
shallowReadonlyInstrumentations2
|
|
690
|
-
];
|
|
691
|
-
}
|
|
692
|
-
var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations();
|
|
693
|
-
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
694
|
-
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
695
|
-
return (target, key, receiver) => {
|
|
696
|
-
if (key === "__v_isReactive") return !isReadonly2;
|
|
697
|
-
else if (key === "__v_isReadonly") return isReadonly2;
|
|
698
|
-
else if (key === "__v_raw") return target;
|
|
699
|
-
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
var mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
|
|
703
|
-
var readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
|
|
704
|
-
var shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
|
|
705
|
-
function checkIdentityKeys(target, has2, key) {
|
|
706
|
-
const rawKey = toRaw(key);
|
|
707
|
-
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
708
|
-
const type = toRawType(target);
|
|
709
|
-
console.warn(`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.`);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
var reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
713
|
-
var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
714
|
-
var readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
715
|
-
var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
716
|
-
function targetTypeMap(rawType) {
|
|
717
|
-
switch (rawType) {
|
|
718
|
-
case "Object":
|
|
719
|
-
case "Array": return 1;
|
|
720
|
-
case "Map":
|
|
721
|
-
case "Set":
|
|
722
|
-
case "WeakMap":
|
|
723
|
-
case "WeakSet": return 2;
|
|
724
|
-
default: return 0;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
function getTargetType(value) {
|
|
728
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
729
|
-
}
|
|
730
|
-
function reactive(target) {
|
|
731
|
-
if (isReadonly(target)) return target;
|
|
732
|
-
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
733
|
-
}
|
|
734
|
-
function readonly(target) {
|
|
735
|
-
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
736
|
-
}
|
|
737
|
-
function shallowReadonly(target) {
|
|
738
|
-
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
739
|
-
}
|
|
740
|
-
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
741
|
-
if (!isObject(target)) {
|
|
742
|
-
console.warn(`value cannot be made reactive: ${String(target)}`);
|
|
743
|
-
return target;
|
|
744
|
-
}
|
|
745
|
-
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) return target;
|
|
746
|
-
const existingProxy = proxyMap.get(target);
|
|
747
|
-
if (existingProxy) return existingProxy;
|
|
748
|
-
const targetType = getTargetType(target);
|
|
749
|
-
if (targetType === 0) return target;
|
|
750
|
-
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
751
|
-
proxyMap.set(target, proxy);
|
|
752
|
-
return proxy;
|
|
753
|
-
}
|
|
754
|
-
function isReactive(value) {
|
|
755
|
-
if (isReadonly(value)) return isReactive(value["__v_raw"]);
|
|
756
|
-
return !!(value && value["__v_isReactive"]);
|
|
757
|
-
}
|
|
758
|
-
function isReadonly(value) {
|
|
759
|
-
return !!(value && value["__v_isReadonly"]);
|
|
760
|
-
}
|
|
761
|
-
function isShallow(value) {
|
|
762
|
-
return !!(value && value["__v_isShallow"]);
|
|
763
|
-
}
|
|
764
|
-
function isProxy(value) {
|
|
765
|
-
return isReactive(value) || isReadonly(value);
|
|
766
|
-
}
|
|
767
|
-
function toRaw(observed) {
|
|
768
|
-
const raw = observed && observed["__v_raw"];
|
|
769
|
-
return raw ? toRaw(raw) : observed;
|
|
770
|
-
}
|
|
771
|
-
function markRaw(value) {
|
|
772
|
-
def(value, "__v_skip", true);
|
|
773
|
-
return value;
|
|
774
|
-
}
|
|
775
|
-
var toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
776
|
-
var toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
777
|
-
var _a;
|
|
778
|
-
var ComputedRefImpl = class {
|
|
779
|
-
constructor(getter, _setter, isReadonly2, isSSR) {
|
|
780
|
-
this._setter = _setter;
|
|
781
|
-
this.dep = void 0;
|
|
782
|
-
this.__v_isRef = true;
|
|
783
|
-
this[_a] = false;
|
|
784
|
-
this.effect = new ReactiveEffect(() => getter(this._value), () => triggerRefValue(this, 1));
|
|
785
|
-
this.effect.computed = this;
|
|
786
|
-
this.effect.active = this._cacheable = !isSSR;
|
|
787
|
-
this["__v_isReadonly"] = isReadonly2;
|
|
788
|
-
}
|
|
789
|
-
static {
|
|
790
|
-
_a = "__v_isReadonly";
|
|
791
|
-
}
|
|
792
|
-
get value() {
|
|
793
|
-
const self2 = toRaw(this);
|
|
794
|
-
if (!self2._cacheable || self2.effect.dirty) {
|
|
795
|
-
if (hasChanged(self2._value, self2._value = self2.effect.run())) triggerRefValue(self2, 2);
|
|
796
|
-
}
|
|
797
|
-
trackRefValue(self2);
|
|
798
|
-
return self2._value;
|
|
799
|
-
}
|
|
800
|
-
set value(newValue) {
|
|
801
|
-
this._setter(newValue);
|
|
802
|
-
}
|
|
803
|
-
get _dirty() {
|
|
804
|
-
return this.effect.dirty;
|
|
805
|
-
}
|
|
806
|
-
set _dirty(v) {
|
|
807
|
-
this.effect.dirty = v;
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
811
|
-
let getter;
|
|
812
|
-
let setter;
|
|
813
|
-
const onlyGetter = isFunction(getterOrOptions);
|
|
814
|
-
if (onlyGetter) {
|
|
815
|
-
getter = getterOrOptions;
|
|
816
|
-
setter = () => {
|
|
817
|
-
console.warn("Write operation failed: computed value is readonly");
|
|
818
|
-
};
|
|
819
|
-
} else {
|
|
820
|
-
getter = getterOrOptions.get;
|
|
821
|
-
setter = getterOrOptions.set;
|
|
822
|
-
}
|
|
823
|
-
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
824
|
-
if (debugOptions && !isSSR) {
|
|
825
|
-
cRef.effect.onTrack = debugOptions.onTrack;
|
|
826
|
-
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
827
|
-
}
|
|
828
|
-
return cRef;
|
|
829
|
-
}
|
|
830
|
-
function trackRefValue(ref2) {
|
|
831
|
-
if (shouldTrack && activeEffect.value) {
|
|
832
|
-
ref2 = toRaw(ref2);
|
|
833
|
-
trackEffect(activeEffect.value, ref2.dep || (ref2.dep = createDep(() => ref2.dep = void 0, ref2 instanceof ComputedRefImpl ? ref2 : void 0)), {
|
|
834
|
-
target: ref2,
|
|
835
|
-
type: "get",
|
|
836
|
-
key: "value"
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
function triggerRefValue(ref2, dirtyLevel = 2, newVal) {
|
|
841
|
-
ref2 = toRaw(ref2);
|
|
842
|
-
const dep = ref2.dep;
|
|
843
|
-
if (dep) triggerEffects(dep, dirtyLevel, {
|
|
844
|
-
target: ref2,
|
|
845
|
-
type: "set",
|
|
846
|
-
key: "value",
|
|
847
|
-
newValue: newVal
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
function isRef(r) {
|
|
851
|
-
return !!(r && r.__v_isRef === true);
|
|
852
|
-
}
|
|
853
|
-
function ref(value) {
|
|
854
|
-
return createRef(value, false);
|
|
855
|
-
}
|
|
856
|
-
function createRef(rawValue, shallow) {
|
|
857
|
-
if (isRef(rawValue)) return rawValue;
|
|
858
|
-
return new RefImpl(rawValue, shallow);
|
|
859
|
-
}
|
|
860
|
-
var RefImpl = class {
|
|
861
|
-
constructor(value, __v_isShallow) {
|
|
862
|
-
this.__v_isShallow = __v_isShallow;
|
|
863
|
-
this.dep = void 0;
|
|
864
|
-
this.__v_isRef = true;
|
|
865
|
-
this._rawValue = __v_isShallow ? value : toRaw(value);
|
|
866
|
-
this._value = __v_isShallow ? value : toReactive(value);
|
|
867
|
-
}
|
|
868
|
-
get value() {
|
|
869
|
-
trackRefValue(this);
|
|
870
|
-
return this._value;
|
|
871
|
-
}
|
|
872
|
-
set value(newVal) {
|
|
873
|
-
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
|
874
|
-
newVal = useDirectValue ? newVal : toRaw(newVal);
|
|
875
|
-
if (hasChanged(newVal, this._rawValue)) {
|
|
876
|
-
this._rawValue = newVal;
|
|
877
|
-
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
878
|
-
triggerRefValue(this, 2, newVal);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
};
|
|
882
|
-
function unref(ref2) {
|
|
883
|
-
return isRef(ref2) ? ref2.value : ref2;
|
|
884
|
-
}
|
|
885
|
-
var shallowUnwrapHandlers = {
|
|
886
|
-
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
887
|
-
set: (target, key, value, receiver) => {
|
|
888
|
-
const oldValue = target[key];
|
|
889
|
-
if (isRef(oldValue) && !isRef(value)) {
|
|
890
|
-
oldValue.value = value;
|
|
891
|
-
return true;
|
|
892
|
-
} else return Reflect.set(target, key, value, receiver);
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
function proxyRefs(objectWithRefs) {
|
|
896
|
-
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
897
|
-
}
|
|
898
|
-
function toRefs(object) {
|
|
899
|
-
if (!isProxy(object)) console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
900
|
-
const ret = isArray(object) ? new Array(object.length) : {};
|
|
901
|
-
for (const key in object) ret[key] = propertyToRef(object, key);
|
|
902
|
-
return ret;
|
|
903
|
-
}
|
|
904
|
-
var ObjectRefImpl = class {
|
|
905
|
-
constructor(_object, _key, _defaultValue) {
|
|
906
|
-
this._object = _object;
|
|
907
|
-
this._key = _key;
|
|
908
|
-
this._defaultValue = _defaultValue;
|
|
909
|
-
this.__v_isRef = true;
|
|
910
|
-
}
|
|
911
|
-
get value() {
|
|
912
|
-
const val = this._object[this._key];
|
|
913
|
-
return val === void 0 ? this._defaultValue : val;
|
|
914
|
-
}
|
|
915
|
-
set value(newVal) {
|
|
916
|
-
this._object[this._key] = newVal;
|
|
917
|
-
}
|
|
918
|
-
get dep() {
|
|
919
|
-
return getDepFromReactive(toRaw(this._object), this._key);
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
function propertyToRef(source, key, defaultValue) {
|
|
923
|
-
const val = source[key];
|
|
924
|
-
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
925
|
-
}
|
|
926
|
-
var stack = [];
|
|
927
|
-
function pushWarningContext(vnode) {
|
|
928
|
-
stack.push(vnode);
|
|
929
|
-
}
|
|
930
|
-
function popWarningContext() {
|
|
931
|
-
stack.pop();
|
|
932
|
-
}
|
|
933
|
-
function warn2(msg, ...args) {
|
|
934
|
-
pauseTracking();
|
|
935
|
-
const instance = stack.length ? stack[stack.length - 1].component : null;
|
|
936
|
-
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
937
|
-
const trace = getComponentTrace();
|
|
938
|
-
if (appWarnHandler) callWithErrorHandling(appWarnHandler, instance, 11, [
|
|
939
|
-
msg + args.join(""),
|
|
940
|
-
instance && instance.proxy,
|
|
941
|
-
trace.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`).join("\n"),
|
|
942
|
-
trace
|
|
943
|
-
]);
|
|
944
|
-
else {
|
|
945
|
-
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
946
|
-
if (trace.length && true) warnArgs.push(`
|
|
947
|
-
`, ...formatTrace(trace));
|
|
948
|
-
console.warn(...warnArgs);
|
|
949
|
-
}
|
|
950
|
-
resetTracking();
|
|
951
|
-
}
|
|
952
|
-
function getComponentTrace() {
|
|
953
|
-
let currentVNode = stack[stack.length - 1];
|
|
954
|
-
if (!currentVNode) return [];
|
|
955
|
-
const normalizedStack = [];
|
|
956
|
-
while (currentVNode) {
|
|
957
|
-
const last = normalizedStack[0];
|
|
958
|
-
if (last && last.vnode === currentVNode) last.recurseCount++;
|
|
959
|
-
else normalizedStack.push({
|
|
960
|
-
vnode: currentVNode,
|
|
961
|
-
recurseCount: 0
|
|
962
|
-
});
|
|
963
|
-
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
964
|
-
currentVNode = parentInstance && parentInstance.vnode;
|
|
965
|
-
}
|
|
966
|
-
return normalizedStack;
|
|
967
|
-
}
|
|
968
|
-
function formatTrace(trace) {
|
|
969
|
-
const logs = [];
|
|
970
|
-
trace.forEach((entry, i) => {
|
|
971
|
-
logs.push(...i === 0 ? [] : [`
|
|
972
|
-
`], ...formatTraceEntry(entry));
|
|
973
|
-
});
|
|
974
|
-
return logs;
|
|
975
|
-
}
|
|
976
|
-
function formatTraceEntry({ vnode, recurseCount }) {
|
|
977
|
-
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
978
|
-
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
979
|
-
const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
|
|
980
|
-
const close = `>` + postfix;
|
|
981
|
-
return vnode.props ? [
|
|
982
|
-
open,
|
|
983
|
-
...formatProps(vnode.props),
|
|
984
|
-
close
|
|
985
|
-
] : [open + close];
|
|
986
|
-
}
|
|
987
|
-
function formatProps(props) {
|
|
988
|
-
const res = [];
|
|
989
|
-
const keys = Object.keys(props);
|
|
990
|
-
keys.slice(0, 3).forEach((key) => {
|
|
991
|
-
res.push(...formatProp(key, props[key]));
|
|
992
|
-
});
|
|
993
|
-
if (keys.length > 3) res.push(` ...`);
|
|
994
|
-
return res;
|
|
995
|
-
}
|
|
996
|
-
function formatProp(key, value, raw) {
|
|
997
|
-
if (isString(value)) {
|
|
998
|
-
value = JSON.stringify(value);
|
|
999
|
-
return raw ? value : [`${key}=${value}`];
|
|
1000
|
-
} else if (typeof value === "number" || typeof value === "boolean" || value == null) return raw ? value : [`${key}=${value}`];
|
|
1001
|
-
else if (isRef(value)) {
|
|
1002
|
-
value = formatProp(key, toRaw(value.value), true);
|
|
1003
|
-
return raw ? value : [
|
|
1004
|
-
`${key}=Ref<`,
|
|
1005
|
-
value,
|
|
1006
|
-
`>`
|
|
1007
|
-
];
|
|
1008
|
-
} else if (isFunction(value)) return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
1009
|
-
else {
|
|
1010
|
-
value = toRaw(value);
|
|
1011
|
-
return raw ? value : [`${key}=`, value];
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
var ErrorTypeStrings = {
|
|
1015
|
-
["sp"]: "serverPrefetch hook",
|
|
1016
|
-
["bc"]: "beforeCreate hook",
|
|
1017
|
-
["c"]: "created hook",
|
|
1018
|
-
["bm"]: "beforeMount hook",
|
|
1019
|
-
["m"]: "mounted hook",
|
|
1020
|
-
["bu"]: "beforeUpdate hook",
|
|
1021
|
-
["u"]: "updated",
|
|
1022
|
-
["bum"]: "beforeUnmount hook",
|
|
1023
|
-
["um"]: "unmounted hook",
|
|
1024
|
-
["a"]: "activated hook",
|
|
1025
|
-
["da"]: "deactivated hook",
|
|
1026
|
-
["ec"]: "errorCaptured hook",
|
|
1027
|
-
["rtc"]: "renderTracked hook",
|
|
1028
|
-
["rtg"]: "renderTriggered hook",
|
|
1029
|
-
[0]: "setup function",
|
|
1030
|
-
[1]: "render function",
|
|
1031
|
-
[2]: "watcher getter",
|
|
1032
|
-
[3]: "watcher callback",
|
|
1033
|
-
[4]: "watcher cleanup function",
|
|
1034
|
-
[5]: "native event handler",
|
|
1035
|
-
[6]: "component event handler",
|
|
1036
|
-
[7]: "vnode hook",
|
|
1037
|
-
[8]: "directive hook",
|
|
1038
|
-
[9]: "transition hook",
|
|
1039
|
-
[10]: "app errorHandler",
|
|
1040
|
-
[11]: "app warnHandler",
|
|
1041
|
-
[12]: "ref function",
|
|
1042
|
-
[13]: "async component loader",
|
|
1043
|
-
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
|
1044
|
-
};
|
|
1045
|
-
function callWithErrorHandling(fn, instance, type, args) {
|
|
1046
|
-
let res;
|
|
1047
|
-
try {
|
|
1048
|
-
res = args ? fn(...args) : fn();
|
|
1049
|
-
} catch (err) {
|
|
1050
|
-
handleError(err, instance, type);
|
|
1051
|
-
}
|
|
1052
|
-
return res;
|
|
1053
|
-
}
|
|
1054
|
-
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
1055
|
-
if (isFunction(fn)) {
|
|
1056
|
-
const res = callWithErrorHandling(fn, instance, type, args);
|
|
1057
|
-
if (res && isPromise(res)) res.catch((err) => {
|
|
1058
|
-
handleError(err, instance, type);
|
|
1059
|
-
});
|
|
1060
|
-
return res;
|
|
1061
|
-
}
|
|
1062
|
-
const values = [];
|
|
1063
|
-
for (let i = 0; i < fn.length; i++) values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
|
1064
|
-
return values;
|
|
1065
|
-
}
|
|
1066
|
-
function handleError(err, instance, type, throwInDev = true) {
|
|
1067
|
-
const contextVNode = instance ? instance.vnode : null;
|
|
1068
|
-
if (instance) {
|
|
1069
|
-
let cur = instance.parent;
|
|
1070
|
-
const exposedInstance = instance.proxy;
|
|
1071
|
-
const errorInfo = ErrorTypeStrings[type];
|
|
1072
|
-
while (cur) {
|
|
1073
|
-
const errorCapturedHooks = cur.ec;
|
|
1074
|
-
if (errorCapturedHooks) {
|
|
1075
|
-
for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return;
|
|
1076
|
-
}
|
|
1077
|
-
cur = cur.parent;
|
|
1078
|
-
}
|
|
1079
|
-
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
1080
|
-
if (appErrorHandler) {
|
|
1081
|
-
callWithErrorHandling(appErrorHandler, null, 10, [
|
|
1082
|
-
err,
|
|
1083
|
-
exposedInstance,
|
|
1084
|
-
errorInfo
|
|
1085
|
-
]);
|
|
1086
|
-
return;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
logError(err, type, contextVNode, throwInDev);
|
|
1090
|
-
}
|
|
1091
|
-
function logError(err, type, contextVNode, throwInDev = true) {
|
|
1092
|
-
{
|
|
1093
|
-
const info = ErrorTypeStrings[type];
|
|
1094
|
-
if (contextVNode) pushWarningContext(contextVNode);
|
|
1095
|
-
warn2(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
1096
|
-
if (contextVNode) popWarningContext();
|
|
1097
|
-
if (throwInDev) throw err;
|
|
1098
|
-
else console.error(err);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
var isFlushing = false;
|
|
1102
|
-
var isFlushPending = false;
|
|
1103
|
-
var queue = [];
|
|
1104
|
-
var flushIndex = 0;
|
|
1105
|
-
var pendingPostFlushCbs = [];
|
|
1106
|
-
var activePostFlushCbs = null;
|
|
1107
|
-
var postFlushIndex = 0;
|
|
1108
|
-
var resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
1109
|
-
var currentFlushPromise = null;
|
|
1110
|
-
var RECURSION_LIMIT = 100;
|
|
1111
|
-
function nextTick(fn) {
|
|
1112
|
-
const p = currentFlushPromise || resolvedPromise;
|
|
1113
|
-
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
1114
|
-
}
|
|
1115
|
-
function findInsertionIndex(id) {
|
|
1116
|
-
let start = flushIndex + 1;
|
|
1117
|
-
let end = queue.length;
|
|
1118
|
-
while (start < end) {
|
|
1119
|
-
const middle = start + end >>> 1;
|
|
1120
|
-
const middleJob = queue[middle];
|
|
1121
|
-
const middleJobId = getId(middleJob);
|
|
1122
|
-
if (middleJobId < id || middleJobId === id && middleJob.pre) start = middle + 1;
|
|
1123
|
-
else end = middle;
|
|
1124
|
-
}
|
|
1125
|
-
return start;
|
|
1126
|
-
}
|
|
1127
|
-
function queueJob(job) {
|
|
1128
|
-
if (!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
|
|
1129
|
-
if (job.id == null) queue.push(job);
|
|
1130
|
-
else queue.splice(findInsertionIndex(job.id), 0, job);
|
|
1131
|
-
queueFlush();
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
function queueFlush() {
|
|
1135
|
-
if (!isFlushing && !isFlushPending) {
|
|
1136
|
-
isFlushPending = true;
|
|
1137
|
-
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
function queuePostFlushCb(cb) {
|
|
1141
|
-
if (!isArray(cb)) {
|
|
1142
|
-
if (!activePostFlushCbs || !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) pendingPostFlushCbs.push(cb);
|
|
1143
|
-
} else pendingPostFlushCbs.push(...cb);
|
|
1144
|
-
queueFlush();
|
|
1145
|
-
}
|
|
1146
|
-
function flushPostFlushCbs(seen) {
|
|
1147
|
-
if (pendingPostFlushCbs.length) {
|
|
1148
|
-
const deduped = [...new Set(pendingPostFlushCbs)].sort((a$1, b$1) => getId(a$1) - getId(b$1));
|
|
1149
|
-
pendingPostFlushCbs.length = 0;
|
|
1150
|
-
if (activePostFlushCbs) {
|
|
1151
|
-
activePostFlushCbs.push(...deduped);
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1154
|
-
activePostFlushCbs = deduped;
|
|
1155
|
-
seen = seen || /* @__PURE__ */ new Map();
|
|
1156
|
-
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
|
1157
|
-
if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) continue;
|
|
1158
|
-
activePostFlushCbs[postFlushIndex]();
|
|
1159
|
-
}
|
|
1160
|
-
activePostFlushCbs = null;
|
|
1161
|
-
postFlushIndex = 0;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
var getId = (job) => job.id == null ? Infinity : job.id;
|
|
1165
|
-
var comparator = (a$1, b$1) => {
|
|
1166
|
-
const diff = getId(a$1) - getId(b$1);
|
|
1167
|
-
if (diff === 0) {
|
|
1168
|
-
if (a$1.pre && !b$1.pre) return -1;
|
|
1169
|
-
if (b$1.pre && !a$1.pre) return 1;
|
|
1170
|
-
}
|
|
1171
|
-
return diff;
|
|
1172
|
-
};
|
|
1173
|
-
function flushJobs(seen) {
|
|
1174
|
-
isFlushPending = false;
|
|
1175
|
-
isFlushing = true;
|
|
1176
|
-
seen = seen || /* @__PURE__ */ new Map();
|
|
1177
|
-
queue.sort(comparator);
|
|
1178
|
-
const check = (job) => checkRecursiveUpdates(seen, job);
|
|
1179
|
-
try {
|
|
1180
|
-
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
1181
|
-
const job = queue[flushIndex];
|
|
1182
|
-
if (job && job.active !== false) {
|
|
1183
|
-
if (check(job)) continue;
|
|
1184
|
-
callWithErrorHandling(job, null, 14);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
} finally {
|
|
1188
|
-
flushIndex = 0;
|
|
1189
|
-
queue.length = 0;
|
|
1190
|
-
flushPostFlushCbs(seen);
|
|
1191
|
-
isFlushing = false;
|
|
1192
|
-
currentFlushPromise = null;
|
|
1193
|
-
if (queue.length || pendingPostFlushCbs.length) flushJobs(seen);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
function checkRecursiveUpdates(seen, fn) {
|
|
1197
|
-
if (!seen.has(fn)) seen.set(fn, 1);
|
|
1198
|
-
else {
|
|
1199
|
-
const count = seen.get(fn);
|
|
1200
|
-
if (count > RECURSION_LIMIT) {
|
|
1201
|
-
const instance = fn.ownerInstance;
|
|
1202
|
-
const componentName = instance && getComponentName(instance.type);
|
|
1203
|
-
handleError(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`, null, 10);
|
|
1204
|
-
return true;
|
|
1205
|
-
} else seen.set(fn, count + 1);
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
var isHmrUpdating = false;
|
|
1209
|
-
var hmrDirtyComponents = /* @__PURE__ */ new Set();
|
|
1210
|
-
getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
|
1211
|
-
createRecord: tryWrap(createRecord),
|
|
1212
|
-
rerender: tryWrap(rerender),
|
|
1213
|
-
reload: tryWrap(reload)
|
|
1214
|
-
};
|
|
1215
|
-
var map = /* @__PURE__ */ new Map();
|
|
1216
|
-
function createRecord(id, initialDef) {
|
|
1217
|
-
if (map.has(id)) return false;
|
|
1218
|
-
map.set(id, {
|
|
1219
|
-
initialDef: normalizeClassComponent(initialDef),
|
|
1220
|
-
instances: /* @__PURE__ */ new Set()
|
|
1221
|
-
});
|
|
1222
|
-
return true;
|
|
1223
|
-
}
|
|
1224
|
-
function normalizeClassComponent(component) {
|
|
1225
|
-
return isClassComponent(component) ? component.__vccOpts : component;
|
|
1226
|
-
}
|
|
1227
|
-
function rerender(id, newRender) {
|
|
1228
|
-
const record = map.get(id);
|
|
1229
|
-
if (!record) return;
|
|
1230
|
-
record.initialDef.render = newRender;
|
|
1231
|
-
[...record.instances].forEach((instance) => {
|
|
1232
|
-
if (newRender) {
|
|
1233
|
-
instance.render = newRender;
|
|
1234
|
-
normalizeClassComponent(instance.type).render = newRender;
|
|
1235
|
-
}
|
|
1236
|
-
instance.renderCache = [];
|
|
1237
|
-
isHmrUpdating = true;
|
|
1238
|
-
instance.effect.dirty = true;
|
|
1239
|
-
instance.update();
|
|
1240
|
-
isHmrUpdating = false;
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
function reload(id, newComp) {
|
|
1244
|
-
const record = map.get(id);
|
|
1245
|
-
if (!record) return;
|
|
1246
|
-
newComp = normalizeClassComponent(newComp);
|
|
1247
|
-
updateComponentDef(record.initialDef, newComp);
|
|
1248
|
-
const instances = [...record.instances];
|
|
1249
|
-
for (const instance of instances) {
|
|
1250
|
-
const oldComp = normalizeClassComponent(instance.type);
|
|
1251
|
-
if (!hmrDirtyComponents.has(oldComp)) {
|
|
1252
|
-
if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
|
|
1253
|
-
hmrDirtyComponents.add(oldComp);
|
|
1254
|
-
}
|
|
1255
|
-
instance.appContext.propsCache.delete(instance.type);
|
|
1256
|
-
instance.appContext.emitsCache.delete(instance.type);
|
|
1257
|
-
instance.appContext.optionsCache.delete(instance.type);
|
|
1258
|
-
if (instance.ceReload) {
|
|
1259
|
-
hmrDirtyComponents.add(oldComp);
|
|
1260
|
-
instance.ceReload(newComp.styles);
|
|
1261
|
-
hmrDirtyComponents.delete(oldComp);
|
|
1262
|
-
} else if (instance.parent) {
|
|
1263
|
-
instance.parent.effect.dirty = true;
|
|
1264
|
-
queueJob(instance.parent.update);
|
|
1265
|
-
} else if (instance.appContext.reload) instance.appContext.reload();
|
|
1266
|
-
else if (typeof window !== "undefined") window.location.reload();
|
|
1267
|
-
else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
|
|
1268
|
-
}
|
|
1269
|
-
queuePostFlushCb(() => {
|
|
1270
|
-
for (const instance of instances) hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
function updateComponentDef(oldComp, newComp) {
|
|
1274
|
-
extend(oldComp, newComp);
|
|
1275
|
-
for (const key in oldComp) if (key !== "__file" && !(key in newComp)) delete oldComp[key];
|
|
1276
|
-
}
|
|
1277
|
-
function tryWrap(fn) {
|
|
1278
|
-
return (id, arg) => {
|
|
1279
|
-
try {
|
|
1280
|
-
return fn(id, arg);
|
|
1281
|
-
} catch (e) {
|
|
1282
|
-
console.error(e);
|
|
1283
|
-
console.warn(`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`);
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
}
|
|
1287
|
-
var currentRenderingInstance = null;
|
|
1288
|
-
var accessedAttrs = false;
|
|
1289
|
-
function markAttrsAccessed() {
|
|
1290
|
-
accessedAttrs = true;
|
|
1291
|
-
}
|
|
1292
|
-
var ssrContextKey = Symbol.for("v-scx");
|
|
1293
|
-
var useSSRContext = () => {
|
|
1294
|
-
{
|
|
1295
|
-
const ctx = inject(ssrContextKey);
|
|
1296
|
-
if (!ctx) warn2(`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`);
|
|
1297
|
-
return ctx;
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
1300
|
-
var INITIAL_WATCHER_VALUE = {};
|
|
1301
|
-
function watch(source, cb, options) {
|
|
1302
|
-
if (!isFunction(cb)) warn2(`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`);
|
|
1303
|
-
return doWatch(source, cb, options);
|
|
1304
|
-
}
|
|
1305
|
-
function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
|
|
1306
|
-
if (cb && once) {
|
|
1307
|
-
const _cb = cb;
|
|
1308
|
-
cb = (...args) => {
|
|
1309
|
-
_cb(...args);
|
|
1310
|
-
unwatch();
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
if (deep !== void 0 && typeof deep === "number") warn2(`watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`);
|
|
1314
|
-
if (!cb) {
|
|
1315
|
-
if (immediate !== void 0) warn2(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`);
|
|
1316
|
-
if (deep !== void 0) warn2(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`);
|
|
1317
|
-
if (once !== void 0) warn2(`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`);
|
|
1318
|
-
}
|
|
1319
|
-
const warnInvalidSource = (s) => {
|
|
1320
|
-
warn2(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
|
|
1321
|
-
};
|
|
1322
|
-
const instance = currentInstance;
|
|
1323
|
-
const reactiveGetter = (source2) => deep === true ? source2 : traverse(source2, deep === false ? 1 : void 0);
|
|
1324
|
-
let getter;
|
|
1325
|
-
let forceTrigger = false;
|
|
1326
|
-
let isMultiSource = false;
|
|
1327
|
-
if (isRef(source)) {
|
|
1328
|
-
getter = () => source.value;
|
|
1329
|
-
forceTrigger = isShallow(source);
|
|
1330
|
-
} else if (isReactive(source)) {
|
|
1331
|
-
getter = () => reactiveGetter(source);
|
|
1332
|
-
forceTrigger = true;
|
|
1333
|
-
} else if (isArray(source)) {
|
|
1334
|
-
isMultiSource = true;
|
|
1335
|
-
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1336
|
-
getter = () => source.map((s) => {
|
|
1337
|
-
if (isRef(s)) return s.value;
|
|
1338
|
-
else if (isReactive(s)) return reactiveGetter(s);
|
|
1339
|
-
else if (isFunction(s)) return callWithErrorHandling(s, instance, 2);
|
|
1340
|
-
else warnInvalidSource(s);
|
|
1341
|
-
});
|
|
1342
|
-
} else if (isFunction(source)) if (cb) getter = () => callWithErrorHandling(source, instance, 2);
|
|
1343
|
-
else getter = () => {
|
|
1344
|
-
if (cleanup) cleanup();
|
|
1345
|
-
return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]);
|
|
1346
|
-
};
|
|
1347
|
-
else {
|
|
1348
|
-
getter = NOOP;
|
|
1349
|
-
warnInvalidSource(source);
|
|
1350
|
-
}
|
|
1351
|
-
if (cb && deep) {
|
|
1352
|
-
const baseGetter = getter;
|
|
1353
|
-
getter = () => traverse(baseGetter());
|
|
1354
|
-
}
|
|
1355
|
-
let cleanup;
|
|
1356
|
-
let onCleanup = (fn) => {
|
|
1357
|
-
cleanup = effect2.onStop = () => {
|
|
1358
|
-
callWithErrorHandling(fn, instance, 4);
|
|
1359
|
-
cleanup = effect2.onStop = void 0;
|
|
1360
|
-
};
|
|
1361
|
-
};
|
|
1362
|
-
let ssrCleanup;
|
|
1363
|
-
if (isInSSRComponentSetup) {
|
|
1364
|
-
onCleanup = NOOP;
|
|
1365
|
-
if (!cb) getter();
|
|
1366
|
-
else if (immediate) callWithAsyncErrorHandling(cb, instance, 3, [
|
|
1367
|
-
getter(),
|
|
1368
|
-
isMultiSource ? [] : void 0,
|
|
1369
|
-
onCleanup
|
|
1370
|
-
]);
|
|
1371
|
-
if (flush === "sync") {
|
|
1372
|
-
const ctx = useSSRContext();
|
|
1373
|
-
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
|
|
1374
|
-
} else return NOOP;
|
|
1375
|
-
}
|
|
1376
|
-
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1377
|
-
const job = () => {
|
|
1378
|
-
if (!effect2.active || !effect2.dirty) return;
|
|
1379
|
-
if (cb) {
|
|
1380
|
-
const newValue = effect2.run();
|
|
1381
|
-
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
|
|
1382
|
-
if (cleanup) cleanup();
|
|
1383
|
-
callWithAsyncErrorHandling(cb, instance, 3, [
|
|
1384
|
-
newValue,
|
|
1385
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1386
|
-
onCleanup
|
|
1387
|
-
]);
|
|
1388
|
-
oldValue = newValue;
|
|
1389
|
-
}
|
|
1390
|
-
} else effect2.run();
|
|
1391
|
-
};
|
|
1392
|
-
job.allowRecurse = !!cb;
|
|
1393
|
-
let scheduler;
|
|
1394
|
-
if (flush === "sync") scheduler = job;
|
|
1395
|
-
else if (flush === "post") scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
|
1396
|
-
else {
|
|
1397
|
-
job.pre = true;
|
|
1398
|
-
if (instance) job.id = instance.uid;
|
|
1399
|
-
scheduler = () => queueJob(job);
|
|
1400
|
-
}
|
|
1401
|
-
const effect2 = new ReactiveEffect(getter, NOOP, scheduler);
|
|
1402
|
-
const scope = getCurrentScope();
|
|
1403
|
-
const unwatch = () => {
|
|
1404
|
-
effect2.stop();
|
|
1405
|
-
if (scope) remove(scope.effects, effect2);
|
|
1406
|
-
};
|
|
1407
|
-
effect2.onTrack = onTrack;
|
|
1408
|
-
effect2.onTrigger = onTrigger;
|
|
1409
|
-
if (cb) if (immediate) job();
|
|
1410
|
-
else oldValue = effect2.run();
|
|
1411
|
-
else if (flush === "post") queuePostRenderEffect(effect2.run.bind(effect2), instance && instance.suspense);
|
|
1412
|
-
else effect2.run();
|
|
1413
|
-
if (ssrCleanup) ssrCleanup.push(unwatch);
|
|
1414
|
-
return unwatch;
|
|
1415
|
-
}
|
|
1416
|
-
function instanceWatch(source, value, options) {
|
|
1417
|
-
const publicThis = this.proxy;
|
|
1418
|
-
const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
|
1419
|
-
let cb;
|
|
1420
|
-
if (isFunction(value)) cb = value;
|
|
1421
|
-
else {
|
|
1422
|
-
cb = value.handler;
|
|
1423
|
-
options = value;
|
|
1424
|
-
}
|
|
1425
|
-
const reset = setCurrentInstance(this);
|
|
1426
|
-
const res = doWatch(getter, cb.bind(publicThis), options);
|
|
1427
|
-
reset();
|
|
1428
|
-
return res;
|
|
1429
|
-
}
|
|
1430
|
-
function createPathGetter(ctx, path) {
|
|
1431
|
-
const segments = path.split(".");
|
|
1432
|
-
return () => {
|
|
1433
|
-
let cur = ctx;
|
|
1434
|
-
for (let i = 0; i < segments.length && cur; i++) cur = cur[segments[i]];
|
|
1435
|
-
return cur;
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
function traverse(value, depth, currentDepth = 0, seen) {
|
|
1439
|
-
if (!isObject(value) || value["__v_skip"]) return value;
|
|
1440
|
-
if (depth && depth > 0) {
|
|
1441
|
-
if (currentDepth >= depth) return value;
|
|
1442
|
-
currentDepth++;
|
|
1443
|
-
}
|
|
1444
|
-
seen = seen || /* @__PURE__ */ new Set();
|
|
1445
|
-
if (seen.has(value)) return value;
|
|
1446
|
-
seen.add(value);
|
|
1447
|
-
if (isRef(value)) traverse(value.value, depth, currentDepth, seen);
|
|
1448
|
-
else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, currentDepth, seen);
|
|
1449
|
-
else if (isSet(value) || isMap(value)) value.forEach((v) => {
|
|
1450
|
-
traverse(v, depth, currentDepth, seen);
|
|
1451
|
-
});
|
|
1452
|
-
else if (isPlainObject$1(value)) for (const key in value) traverse(value[key], depth, currentDepth, seen);
|
|
1453
|
-
return value;
|
|
1454
|
-
}
|
|
1455
|
-
var leaveCbKey = Symbol("_leaveCb");
|
|
1456
|
-
var enterCbKey = Symbol("_enterCb");
|
|
1457
|
-
function injectHook(type, hook, target = currentInstance, prepend = false) {
|
|
1458
|
-
if (target) {
|
|
1459
|
-
const hooks = target[type] || (target[type] = []);
|
|
1460
|
-
const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
|
1461
|
-
if (target.isUnmounted) return;
|
|
1462
|
-
pauseTracking();
|
|
1463
|
-
const reset = setCurrentInstance(target);
|
|
1464
|
-
const res = callWithAsyncErrorHandling(hook, target, type, args);
|
|
1465
|
-
reset();
|
|
1466
|
-
resetTracking();
|
|
1467
|
-
return res;
|
|
1468
|
-
});
|
|
1469
|
-
if (prepend) hooks.unshift(wrappedHook);
|
|
1470
|
-
else hooks.push(wrappedHook);
|
|
1471
|
-
return wrappedHook;
|
|
1472
|
-
} else {
|
|
1473
|
-
const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
|
|
1474
|
-
warn2(`${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
var createHook = (lifecycle) => (hook, target = currentInstance) => (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target);
|
|
1478
|
-
var onBeforeMount = createHook("bm");
|
|
1479
|
-
var onMounted = createHook("m");
|
|
1480
|
-
var onBeforeUpdate = createHook("bu");
|
|
1481
|
-
var onUpdated = createHook("u");
|
|
1482
|
-
var onBeforeUnmount = createHook("bum");
|
|
1483
|
-
var onUnmounted = createHook("um");
|
|
1484
|
-
var onServerPrefetch = createHook("sp");
|
|
1485
|
-
var onRenderTriggered = createHook("rtg");
|
|
1486
|
-
var onRenderTracked = createHook("rtc");
|
|
1487
|
-
var NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
|
1488
|
-
var getPublicInstance = (i) => {
|
|
1489
|
-
if (!i) return null;
|
|
1490
|
-
if (isStatefulComponent(i)) return getExposeProxy(i) || i.proxy;
|
|
1491
|
-
return getPublicInstance(i.parent);
|
|
1492
|
-
};
|
|
1493
|
-
var publicPropertiesMap = /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
|
|
1494
|
-
$: (i) => i,
|
|
1495
|
-
$el: (i) => i.vnode.el,
|
|
1496
|
-
$data: (i) => i.data,
|
|
1497
|
-
$props: (i) => shallowReadonly(i.props),
|
|
1498
|
-
$attrs: (i) => shallowReadonly(i.attrs),
|
|
1499
|
-
$slots: (i) => shallowReadonly(i.slots),
|
|
1500
|
-
$refs: (i) => shallowReadonly(i.refs),
|
|
1501
|
-
$parent: (i) => getPublicInstance(i.parent),
|
|
1502
|
-
$root: (i) => getPublicInstance(i.root),
|
|
1503
|
-
$emit: (i) => i.emit,
|
|
1504
|
-
$options: (i) => resolveMergedOptions(i),
|
|
1505
|
-
$forceUpdate: (i) => i.f || (i.f = () => {
|
|
1506
|
-
i.effect.dirty = true;
|
|
1507
|
-
queueJob(i.update);
|
|
1508
|
-
}),
|
|
1509
|
-
$nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
|
1510
|
-
$watch: (i) => instanceWatch.bind(i)
|
|
1511
|
-
});
|
|
1512
|
-
var isReservedPrefix = (key) => key === "_" || key === "$";
|
|
1513
|
-
var hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
|
1514
|
-
var PublicInstanceProxyHandlers = {
|
|
1515
|
-
get({ _: instance }, key) {
|
|
1516
|
-
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
|
1517
|
-
if (key === "__isVue") return true;
|
|
1518
|
-
let normalizedProps;
|
|
1519
|
-
if (key[0] !== "$") {
|
|
1520
|
-
const n = accessCache[key];
|
|
1521
|
-
if (n !== void 0) switch (n) {
|
|
1522
|
-
case 1: return setupState[key];
|
|
1523
|
-
case 2: return data[key];
|
|
1524
|
-
case 4: return ctx[key];
|
|
1525
|
-
case 3: return props[key];
|
|
1526
|
-
}
|
|
1527
|
-
else if (hasSetupBinding(setupState, key)) {
|
|
1528
|
-
accessCache[key] = 1;
|
|
1529
|
-
return setupState[key];
|
|
1530
|
-
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
1531
|
-
accessCache[key] = 2;
|
|
1532
|
-
return data[key];
|
|
1533
|
-
} else if ((normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) {
|
|
1534
|
-
accessCache[key] = 3;
|
|
1535
|
-
return props[key];
|
|
1536
|
-
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
1537
|
-
accessCache[key] = 4;
|
|
1538
|
-
return ctx[key];
|
|
1539
|
-
} else if (shouldCacheAccess) accessCache[key] = 0;
|
|
1540
|
-
}
|
|
1541
|
-
const publicGetter = publicPropertiesMap[key];
|
|
1542
|
-
let cssModule, globalProperties;
|
|
1543
|
-
if (publicGetter) {
|
|
1544
|
-
if (key === "$attrs") {
|
|
1545
|
-
track(instance, "get", key);
|
|
1546
|
-
markAttrsAccessed();
|
|
1547
|
-
} else if (key === "$slots") track(instance, "get", key);
|
|
1548
|
-
return publicGetter(instance);
|
|
1549
|
-
} else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) return cssModule;
|
|
1550
|
-
else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
1551
|
-
accessCache[key] = 4;
|
|
1552
|
-
return ctx[key];
|
|
1553
|
-
} else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) return globalProperties[key];
|
|
1554
|
-
else if (currentRenderingInstance && (!isString(key) || key.indexOf("__v") !== 0)) {
|
|
1555
|
-
if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) warn2(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`);
|
|
1556
|
-
else if (instance === currentRenderingInstance) warn2(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`);
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
set({ _: instance }, key, value) {
|
|
1560
|
-
const { data, setupState, ctx } = instance;
|
|
1561
|
-
if (hasSetupBinding(setupState, key)) {
|
|
1562
|
-
setupState[key] = value;
|
|
1563
|
-
return true;
|
|
1564
|
-
} else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
|
1565
|
-
warn2(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
|
1566
|
-
return false;
|
|
1567
|
-
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
1568
|
-
data[key] = value;
|
|
1569
|
-
return true;
|
|
1570
|
-
} else if (hasOwn(instance.props, key)) {
|
|
1571
|
-
warn2(`Attempting to mutate prop "${key}". Props are readonly.`);
|
|
1572
|
-
return false;
|
|
1573
|
-
}
|
|
1574
|
-
if (key[0] === "$" && key.slice(1) in instance) {
|
|
1575
|
-
warn2(`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`);
|
|
1576
|
-
return false;
|
|
1577
|
-
} else if (key in instance.appContext.config.globalProperties) Object.defineProperty(ctx, key, {
|
|
1578
|
-
enumerable: true,
|
|
1579
|
-
configurable: true,
|
|
1580
|
-
value
|
|
1581
|
-
});
|
|
1582
|
-
else ctx[key] = value;
|
|
1583
|
-
return true;
|
|
1584
|
-
},
|
|
1585
|
-
has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
|
|
1586
|
-
let normalizedProps;
|
|
1587
|
-
return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
|
|
1588
|
-
},
|
|
1589
|
-
defineProperty(target, key, descriptor) {
|
|
1590
|
-
if (descriptor.get != null) target._.accessCache[key] = 0;
|
|
1591
|
-
else if (hasOwn(descriptor, "value")) this.set(target, key, descriptor.value, null);
|
|
1592
|
-
return Reflect.defineProperty(target, key, descriptor);
|
|
1593
|
-
}
|
|
1594
|
-
};
|
|
1595
|
-
PublicInstanceProxyHandlers.ownKeys = (target) => {
|
|
1596
|
-
warn2(`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`);
|
|
1597
|
-
return Reflect.ownKeys(target);
|
|
1598
|
-
};
|
|
1599
|
-
function normalizePropsOrEmits(props) {
|
|
1600
|
-
return isArray(props) ? props.reduce((normalized, p) => (normalized[p] = null, normalized), {}) : props;
|
|
1601
|
-
}
|
|
1602
|
-
var shouldCacheAccess = true;
|
|
1603
|
-
function resolveMergedOptions(instance) {
|
|
1604
|
-
const base = instance.type;
|
|
1605
|
-
const { mixins, extends: extendsOptions } = base;
|
|
1606
|
-
const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
|
|
1607
|
-
const cached = cache.get(base);
|
|
1608
|
-
let resolved;
|
|
1609
|
-
if (cached) resolved = cached;
|
|
1610
|
-
else if (!globalMixins.length && !mixins && !extendsOptions) resolved = base;
|
|
1611
|
-
else {
|
|
1612
|
-
resolved = {};
|
|
1613
|
-
if (globalMixins.length) globalMixins.forEach((m$1) => mergeOptions(resolved, m$1, optionMergeStrategies, true));
|
|
1614
|
-
mergeOptions(resolved, base, optionMergeStrategies);
|
|
1615
|
-
}
|
|
1616
|
-
if (isObject(base)) cache.set(base, resolved);
|
|
1617
|
-
return resolved;
|
|
1618
|
-
}
|
|
1619
|
-
function mergeOptions(to, from, strats, asMixin = false) {
|
|
1620
|
-
const { mixins, extends: extendsOptions } = from;
|
|
1621
|
-
if (extendsOptions) mergeOptions(to, extendsOptions, strats, true);
|
|
1622
|
-
if (mixins) mixins.forEach((m$1) => mergeOptions(to, m$1, strats, true));
|
|
1623
|
-
for (const key in from) if (asMixin && key === "expose") warn2(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);
|
|
1624
|
-
else {
|
|
1625
|
-
const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
|
1626
|
-
to[key] = strat ? strat(to[key], from[key]) : from[key];
|
|
1627
|
-
}
|
|
1628
|
-
return to;
|
|
1629
|
-
}
|
|
1630
|
-
var internalOptionMergeStrats = {
|
|
1631
|
-
data: mergeDataFn,
|
|
1632
|
-
props: mergeEmitsOrPropsOptions,
|
|
1633
|
-
emits: mergeEmitsOrPropsOptions,
|
|
1634
|
-
methods: mergeObjectOptions,
|
|
1635
|
-
computed: mergeObjectOptions,
|
|
1636
|
-
beforeCreate: mergeAsArray,
|
|
1637
|
-
created: mergeAsArray,
|
|
1638
|
-
beforeMount: mergeAsArray,
|
|
1639
|
-
mounted: mergeAsArray,
|
|
1640
|
-
beforeUpdate: mergeAsArray,
|
|
1641
|
-
updated: mergeAsArray,
|
|
1642
|
-
beforeDestroy: mergeAsArray,
|
|
1643
|
-
beforeUnmount: mergeAsArray,
|
|
1644
|
-
destroyed: mergeAsArray,
|
|
1645
|
-
unmounted: mergeAsArray,
|
|
1646
|
-
activated: mergeAsArray,
|
|
1647
|
-
deactivated: mergeAsArray,
|
|
1648
|
-
errorCaptured: mergeAsArray,
|
|
1649
|
-
serverPrefetch: mergeAsArray,
|
|
1650
|
-
components: mergeObjectOptions,
|
|
1651
|
-
directives: mergeObjectOptions,
|
|
1652
|
-
watch: mergeWatchOptions,
|
|
1653
|
-
provide: mergeDataFn,
|
|
1654
|
-
inject: mergeInject
|
|
1655
|
-
};
|
|
1656
|
-
function mergeDataFn(to, from) {
|
|
1657
|
-
if (!from) return to;
|
|
1658
|
-
if (!to) return from;
|
|
1659
|
-
return function mergedDataFn() {
|
|
1660
|
-
return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
function mergeInject(to, from) {
|
|
1664
|
-
return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
|
1665
|
-
}
|
|
1666
|
-
function normalizeInject(raw) {
|
|
1667
|
-
if (isArray(raw)) {
|
|
1668
|
-
const res = {};
|
|
1669
|
-
for (let i = 0; i < raw.length; i++) res[raw[i]] = raw[i];
|
|
1670
|
-
return res;
|
|
1671
|
-
}
|
|
1672
|
-
return raw;
|
|
1673
|
-
}
|
|
1674
|
-
function mergeAsArray(to, from) {
|
|
1675
|
-
return to ? [...new Set([].concat(to, from))] : from;
|
|
1676
|
-
}
|
|
1677
|
-
function mergeObjectOptions(to, from) {
|
|
1678
|
-
return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
|
|
1679
|
-
}
|
|
1680
|
-
function mergeEmitsOrPropsOptions(to, from) {
|
|
1681
|
-
if (to) {
|
|
1682
|
-
if (isArray(to) && isArray(from)) return [.../* @__PURE__ */ new Set([...to, ...from])];
|
|
1683
|
-
return extend(/* @__PURE__ */ Object.create(null), normalizePropsOrEmits(to), normalizePropsOrEmits(from ?? {}));
|
|
1684
|
-
} else return from;
|
|
1685
|
-
}
|
|
1686
|
-
function mergeWatchOptions(to, from) {
|
|
1687
|
-
if (!to) return from;
|
|
1688
|
-
if (!from) return to;
|
|
1689
|
-
const merged = extend(/* @__PURE__ */ Object.create(null), to);
|
|
1690
|
-
for (const key in from) merged[key] = mergeAsArray(to[key], from[key]);
|
|
1691
|
-
return merged;
|
|
1692
|
-
}
|
|
1693
|
-
function createAppContext() {
|
|
1694
|
-
return {
|
|
1695
|
-
app: null,
|
|
1696
|
-
config: {
|
|
1697
|
-
isNativeTag: NO,
|
|
1698
|
-
performance: false,
|
|
1699
|
-
globalProperties: {},
|
|
1700
|
-
optionMergeStrategies: {},
|
|
1701
|
-
errorHandler: void 0,
|
|
1702
|
-
warnHandler: void 0,
|
|
1703
|
-
compilerOptions: {}
|
|
1704
|
-
},
|
|
1705
|
-
mixins: [],
|
|
1706
|
-
components: {},
|
|
1707
|
-
directives: {},
|
|
1708
|
-
provides: /* @__PURE__ */ Object.create(null),
|
|
1709
|
-
optionsCache: /* @__PURE__ */ new WeakMap(),
|
|
1710
|
-
propsCache: /* @__PURE__ */ new WeakMap(),
|
|
1711
|
-
emitsCache: /* @__PURE__ */ new WeakMap()
|
|
1712
|
-
};
|
|
1713
|
-
}
|
|
1714
|
-
var currentApp = null;
|
|
1715
|
-
function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
1716
|
-
const instance = currentInstance || currentRenderingInstance;
|
|
1717
|
-
if (instance || currentApp) {
|
|
1718
|
-
const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
|
|
1719
|
-
if (provides && key in provides) return provides[key];
|
|
1720
|
-
else if (arguments.length > 1) return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
|
1721
|
-
else warn2(`injection "${String(key)}" not found.`);
|
|
1722
|
-
} else warn2(`inject() can only be used inside setup() or functional components.`);
|
|
1723
|
-
}
|
|
1724
|
-
var queuePostRenderEffect = queueEffectWithSuspense;
|
|
1725
|
-
function queueEffectWithSuspense(fn, suspense) {
|
|
1726
|
-
if (suspense && suspense.pendingBranch) if (isArray(fn)) suspense.effects.push(...fn);
|
|
1727
|
-
else suspense.effects.push(fn);
|
|
1728
|
-
else queuePostFlushCb(fn);
|
|
1729
|
-
}
|
|
1730
|
-
var Fragment = Symbol.for("v-fgt");
|
|
1731
|
-
var Text = Symbol.for("v-txt");
|
|
1732
|
-
var Comment = Symbol.for("v-cmt");
|
|
1733
|
-
var Static = Symbol.for("v-stc");
|
|
1734
|
-
var emptyAppContext = createAppContext();
|
|
1735
|
-
var currentInstance = null;
|
|
1736
|
-
var internalSetCurrentInstance;
|
|
1737
|
-
var setInSSRSetupState;
|
|
1738
|
-
{
|
|
1739
|
-
const g$1 = getGlobalThis();
|
|
1740
|
-
const registerGlobalSetter = (key, setter) => {
|
|
1741
|
-
let setters;
|
|
1742
|
-
if (!(setters = g$1[key])) setters = g$1[key] = [];
|
|
1743
|
-
setters.push(setter);
|
|
1744
|
-
return (v) => {
|
|
1745
|
-
if (setters.length > 1) setters.forEach((set2) => set2(v));
|
|
1746
|
-
else setters[0](v);
|
|
1747
|
-
};
|
|
1748
|
-
};
|
|
1749
|
-
internalSetCurrentInstance = registerGlobalSetter(`__VUE_INSTANCE_SETTERS__`, (v) => currentInstance = v);
|
|
1750
|
-
setInSSRSetupState = registerGlobalSetter(`__VUE_SSR_SETTERS__`, (v) => isInSSRComponentSetup = v);
|
|
1751
|
-
}
|
|
1752
|
-
var setCurrentInstance = (instance) => {
|
|
1753
|
-
const prev = currentInstance;
|
|
1754
|
-
internalSetCurrentInstance(instance);
|
|
1755
|
-
instance.scope.on();
|
|
1756
|
-
return () => {
|
|
1757
|
-
instance.scope.off();
|
|
1758
|
-
internalSetCurrentInstance(prev);
|
|
1759
|
-
};
|
|
1760
|
-
};
|
|
1761
|
-
function isStatefulComponent(instance) {
|
|
1762
|
-
return instance.vnode.shapeFlag & 4;
|
|
1763
|
-
}
|
|
1764
|
-
var isInSSRComponentSetup = false;
|
|
1765
|
-
function getExposeProxy(instance) {
|
|
1766
|
-
if (instance.exposed) return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
|
1767
|
-
get(target, key) {
|
|
1768
|
-
if (key in target) return target[key];
|
|
1769
|
-
else if (key in publicPropertiesMap) return publicPropertiesMap[key](instance);
|
|
1770
|
-
},
|
|
1771
|
-
has(target, key) {
|
|
1772
|
-
return key in target || key in publicPropertiesMap;
|
|
1773
|
-
}
|
|
1774
|
-
}));
|
|
1775
|
-
}
|
|
1776
|
-
var classifyRE = /(?:^|[-_])(\w)/g;
|
|
1777
|
-
var classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
1778
|
-
function getComponentName(Component, includeInferred = true) {
|
|
1779
|
-
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
1780
|
-
}
|
|
1781
|
-
function formatComponentName(instance, Component, isRoot = false) {
|
|
1782
|
-
let name = getComponentName(Component);
|
|
1783
|
-
if (!name && Component.__file) {
|
|
1784
|
-
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
1785
|
-
if (match) name = match[1];
|
|
1786
|
-
}
|
|
1787
|
-
if (!name && instance && instance.parent) {
|
|
1788
|
-
const inferFromRegistry = (registry) => {
|
|
1789
|
-
for (const key in registry) if (registry[key] === Component) return key;
|
|
1790
|
-
};
|
|
1791
|
-
name = inferFromRegistry(instance.components || instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
1792
|
-
}
|
|
1793
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
1794
|
-
}
|
|
1795
|
-
function isClassComponent(value) {
|
|
1796
|
-
return isFunction(value) && "__vccOpts" in value;
|
|
1797
|
-
}
|
|
1798
|
-
var computed2 = (getterOrOptions, debugOptions) => {
|
|
1799
|
-
return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
|
1800
|
-
};
|
|
1801
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
1802
|
-
|
|
1803
|
-
//#endregion
|
|
1804
|
-
//#region src/rootStore.ts
|
|
1805
|
-
/**
|
|
1806
|
-
* Get the currently active pinia if there is any.
|
|
1807
|
-
*/
|
|
1808
|
-
const getActivePinia = () => activePinia;
|
|
1809
|
-
let activePinia;
|
|
4
|
+
// src/rootStore.ts
|
|
5
|
+
var getActivePinia = () => activePinia;
|
|
6
|
+
var activePinia;
|
|
1810
7
|
function setActivePinia(_pinia) {
|
|
1811
|
-
|
|
8
|
+
activePinia = _pinia;
|
|
1812
9
|
}
|
|
1813
10
|
|
|
1814
|
-
|
|
1815
|
-
//#region src/createPinia.ts
|
|
1816
|
-
/**
|
|
1817
|
-
* Creates a Pinia instance to be used by the application
|
|
1818
|
-
*/
|
|
11
|
+
// src/createPinia.ts
|
|
1819
12
|
function createPinia() {
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
//#endregion
|
|
1838
|
-
//#region src/subscription.ts
|
|
1839
|
-
const noop$1 = () => {};
|
|
1840
|
-
function addSubscription(activeComponentCleanUp$1, subscriptions, callback, detached, onCleanup = noop$1) {
|
|
1841
|
-
subscriptions.add(callback);
|
|
1842
|
-
const removeSubscription = () => {
|
|
1843
|
-
subscriptions.delete(callback);
|
|
1844
|
-
onCleanup();
|
|
1845
|
-
};
|
|
1846
|
-
if (!detached) activeComponentCleanUp$1[0].push(removeSubscription);
|
|
1847
|
-
return removeSubscription;
|
|
1848
|
-
}
|
|
1849
|
-
function triggerSubscriptions(subscriptions, ...args) {
|
|
1850
|
-
subscriptions.forEach((callback) => {
|
|
1851
|
-
callback(...args);
|
|
1852
|
-
});
|
|
13
|
+
const scope = effectScope(true);
|
|
14
|
+
const state = scope.run(() => ref({}));
|
|
15
|
+
const _p = [];
|
|
16
|
+
const pinia = markRaw({
|
|
17
|
+
use(plugin) {
|
|
18
|
+
_p.push(plugin);
|
|
19
|
+
return this;
|
|
20
|
+
},
|
|
21
|
+
_p,
|
|
22
|
+
_e: scope,
|
|
23
|
+
_s: /* @__PURE__ */ new Map(),
|
|
24
|
+
state
|
|
25
|
+
});
|
|
26
|
+
setActivePinia(pinia);
|
|
27
|
+
return pinia;
|
|
1853
28
|
}
|
|
1854
29
|
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
/**
|
|
1870
|
-
* Mutated the state with `$patch` and an object
|
|
1871
|
-
*
|
|
1872
|
-
* - `store.$patch({ name: 'newName' })`
|
|
1873
|
-
*/
|
|
1874
|
-
MutationType$1["patchObject"] = "patch object";
|
|
1875
|
-
/**
|
|
1876
|
-
* Mutated the state with `$patch` and a function
|
|
1877
|
-
*
|
|
1878
|
-
* - `store.$patch(state => state.name = 'newName')`
|
|
1879
|
-
*/
|
|
1880
|
-
MutationType$1["patchFunction"] = "patch function";
|
|
1881
|
-
return MutationType$1;
|
|
1882
|
-
}({});
|
|
30
|
+
// src/store.ts
|
|
31
|
+
import {
|
|
32
|
+
activeEffect,
|
|
33
|
+
computed,
|
|
34
|
+
effectScope as effectScope2,
|
|
35
|
+
markRaw as markRaw2,
|
|
36
|
+
nextTick,
|
|
37
|
+
ReactiveEffect,
|
|
38
|
+
reactive,
|
|
39
|
+
toRaw,
|
|
40
|
+
toRefs,
|
|
41
|
+
watch
|
|
42
|
+
} from "@maoism/runtime-core";
|
|
43
|
+
import { useCallback, useEffect, useId, useRef, useSyncExternalStore } from "react";
|
|
1883
44
|
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
45
|
+
// src/subscription.ts
|
|
46
|
+
var noop = () => {
|
|
47
|
+
};
|
|
48
|
+
function addSubscription(activeComponentCleanUp2, subscriptions, callback, detached, onCleanup = noop) {
|
|
49
|
+
subscriptions.add(callback);
|
|
50
|
+
const removeSubscription = () => {
|
|
51
|
+
subscriptions.delete(callback);
|
|
52
|
+
onCleanup();
|
|
53
|
+
};
|
|
54
|
+
if (!detached) {
|
|
55
|
+
activeComponentCleanUp2[0].push(removeSubscription);
|
|
56
|
+
}
|
|
57
|
+
return removeSubscription;
|
|
1891
58
|
}
|
|
1892
|
-
function
|
|
1893
|
-
|
|
59
|
+
function triggerSubscriptions(subscriptions, ...args) {
|
|
60
|
+
subscriptions.forEach((callback) => {
|
|
61
|
+
callback(...args);
|
|
62
|
+
});
|
|
1894
63
|
}
|
|
1895
64
|
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
subscribe(e, t) {
|
|
1905
|
-
var s;
|
|
1906
|
-
this.pubAndNoSub[e] && (t(this.pubAndNoSub[e]), Reflect.deleteProperty(this.pubAndNoSub, e)), (s = this.subscribeList[e]) != null && s.push(t) || (this.subscribeList[e] = [t]);
|
|
1907
|
-
}
|
|
1908
|
-
publish(e, t) {
|
|
1909
|
-
let s = this.subscribeList[e];
|
|
1910
|
-
!s || s.length === 0 ? this.pubAndNoSub[e] = t : s.forEach((r) => r(t));
|
|
1911
|
-
}
|
|
1912
|
-
remove(e, t) {
|
|
1913
|
-
let s = this.subscribeList[e];
|
|
1914
|
-
!s || s.length === 0 || (t ? s.forEach((r, o$1) => {
|
|
1915
|
-
r === t && this.subscribeList[e].splice(o$1, 1);
|
|
1916
|
-
}) : this.subscribeList[e] = []);
|
|
1917
|
-
}
|
|
1918
|
-
}, D = new a();
|
|
1919
|
-
var b = class {
|
|
1920
|
-
constructor() {
|
|
1921
|
-
this.copyShallow = (e) => this.copy(e, "shallow");
|
|
1922
|
-
this.copyDeep = (e) => this.copy(e, "deep");
|
|
1923
|
-
}
|
|
1924
|
-
copy(e, t) {
|
|
1925
|
-
if (typeof e == "object" && e !== null) {
|
|
1926
|
-
let s = Reflect.construct(e.constructor, []);
|
|
1927
|
-
return Object.keys(e).forEach((r) => {
|
|
1928
|
-
s[r] = t === "shallow" ? e[r] : this.copy(e[r], "deep");
|
|
1929
|
-
}), s;
|
|
1930
|
-
}
|
|
1931
|
-
return e;
|
|
1932
|
-
}
|
|
1933
|
-
}, { copyShallow: Q, copyDeep: g } = new b();
|
|
1934
|
-
var T = class {
|
|
1935
|
-
constructor() {
|
|
1936
|
-
this.compareShallow = (e, t) => this.compare(e, t, "shallow");
|
|
1937
|
-
this.compareDeep = (e, t) => this.compare(e, t, "deep");
|
|
1938
|
-
}
|
|
1939
|
-
compare(e, t, s) {
|
|
1940
|
-
if (e === t) return !0;
|
|
1941
|
-
if (!G(e) || _(e) || !G(t) || _(t)) return !1;
|
|
1942
|
-
let r = Object.keys(e).length, o$1 = Object.keys(t).length;
|
|
1943
|
-
if (r !== o$1) return !1;
|
|
1944
|
-
for (let l of Object.keys(e)) {
|
|
1945
|
-
let c = l;
|
|
1946
|
-
if (s === "shallow" && e[c] !== t[c]) return !1;
|
|
1947
|
-
if (s === "deep") {
|
|
1948
|
-
let i = this.compare(e[c], t[c], "deep");
|
|
1949
|
-
if (!i) return i;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
return !0;
|
|
1953
|
-
}
|
|
1954
|
-
}, { compareShallow: X, compareDeep: Y } = new T();
|
|
1955
|
-
var m = class {
|
|
1956
|
-
constructor() {
|
|
1957
|
-
this.mergeShallow = (e, ...t) => this.merge(e, "shallow", ...t);
|
|
1958
|
-
this.mergeDeep = (e, ...t) => this.merge(e, "deep", ...t);
|
|
1959
|
-
}
|
|
1960
|
-
merge(e, t, ...s) {
|
|
1961
|
-
if (o(s)) {
|
|
1962
|
-
for (; s.length > 0;) {
|
|
1963
|
-
let r = s.pop();
|
|
1964
|
-
if (!G(r)) return e;
|
|
1965
|
-
Reflect.ownKeys(r).forEach((o$1) => {
|
|
1966
|
-
if (t === "shallow") e[o$1] = r[o$1];
|
|
1967
|
-
else {
|
|
1968
|
-
if (!Reflect.has(e, o$1) || !G(r[o$1])) return e[o$1] = g(r[o$1]);
|
|
1969
|
-
this.merge(e[o$1], "deep", r[o$1]);
|
|
1970
|
-
}
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
return e;
|
|
1974
|
-
}
|
|
1975
|
-
return e;
|
|
1976
|
-
}
|
|
1977
|
-
}, { mergeShallow: oe, mergeDeep: ie } = new m();
|
|
65
|
+
// src/types.ts
|
|
66
|
+
var MutationType = /* @__PURE__ */ ((MutationType2) => {
|
|
67
|
+
MutationType2["direct"] = "direct";
|
|
68
|
+
MutationType2["patchObject"] = "patch object";
|
|
69
|
+
MutationType2["patchFunction"] = "patch function";
|
|
70
|
+
return MutationType2;
|
|
71
|
+
})(MutationType || {});
|
|
1978
72
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
function
|
|
1982
|
-
|
|
73
|
+
// src/utils.ts
|
|
74
|
+
import { isReactive, isRef } from "@maoism/runtime-core";
|
|
75
|
+
function noop2() {
|
|
76
|
+
return {};
|
|
1983
77
|
}
|
|
1984
|
-
function isPlainObject(o
|
|
1985
|
-
|
|
78
|
+
function isPlainObject(o) {
|
|
79
|
+
return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
|
|
1986
80
|
}
|
|
1987
81
|
function mergeReactiveObjects(target, patchToApply) {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
82
|
+
if (target instanceof Map && patchToApply instanceof Map) {
|
|
83
|
+
patchToApply.forEach((value, key) => target.set(key, value));
|
|
84
|
+
}
|
|
85
|
+
if (target instanceof Set && patchToApply instanceof Set) {
|
|
86
|
+
patchToApply.forEach(target.add, target);
|
|
87
|
+
}
|
|
88
|
+
for (const key in patchToApply) {
|
|
89
|
+
if (!Object.hasOwn(patchToApply, key)) continue;
|
|
90
|
+
const subPatch = patchToApply[key];
|
|
91
|
+
const targetValue = target[key];
|
|
92
|
+
if (isPlainObject(targetValue) && isPlainObject(subPatch) && // biome-ignore lint/suspicious/noPrototypeBuiltins: <>
|
|
93
|
+
target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
94
|
+
target[key] = mergeReactiveObjects(targetValue, subPatch);
|
|
95
|
+
} else {
|
|
96
|
+
target[key] = subPatch;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return target;
|
|
1998
100
|
}
|
|
1999
101
|
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
* @internal
|
|
2005
|
-
*/
|
|
2006
|
-
const ACTION_MARKER = Symbol();
|
|
2007
|
-
/**
|
|
2008
|
-
* Action name symbol. Allows to add a name to an action after defining it
|
|
2009
|
-
* @internal
|
|
2010
|
-
*/
|
|
2011
|
-
const ACTION_NAME = Symbol();
|
|
2012
|
-
const { assign } = Object;
|
|
102
|
+
// src/store.ts
|
|
103
|
+
var ACTION_MARKER = Symbol();
|
|
104
|
+
var ACTION_NAME = Symbol();
|
|
105
|
+
var { assign } = Object;
|
|
2013
106
|
function createOptionsStore(id, options, pinia) {
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
107
|
+
const { state, actions, getters } = options;
|
|
108
|
+
const initialState = pinia.state.value[id];
|
|
109
|
+
let store;
|
|
110
|
+
function setup() {
|
|
111
|
+
if (!initialState) {
|
|
112
|
+
pinia.state.value[id] = state ? state() : {};
|
|
113
|
+
}
|
|
114
|
+
const localState = toRefs(pinia.state.value[id]);
|
|
115
|
+
return assign(
|
|
116
|
+
localState,
|
|
117
|
+
actions,
|
|
118
|
+
Object.keys(getters || {}).reduce(
|
|
119
|
+
(computedGetters, name) => {
|
|
120
|
+
if (name in localState) {
|
|
121
|
+
console.warn(
|
|
122
|
+
`[\u{1F34D}]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
computedGetters[name] = markRaw2(
|
|
126
|
+
computed(() => {
|
|
127
|
+
setActivePinia(pinia);
|
|
128
|
+
const store2 = pinia._s.get(id);
|
|
129
|
+
return getters[name].call(store2, store2);
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
return computedGetters;
|
|
133
|
+
},
|
|
134
|
+
{}
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
store = createSetupStore(id, setup, options, pinia);
|
|
139
|
+
return store;
|
|
2032
140
|
}
|
|
2033
141
|
function createSetupStore($id, setup, options = {}, pinia) {
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
142
|
+
let scope;
|
|
143
|
+
const optionsForPlugin = assign({ actions: {} }, options);
|
|
144
|
+
const $subscribeOptions = { deep: true };
|
|
145
|
+
let isListening;
|
|
146
|
+
let isSyncListening;
|
|
147
|
+
const subscriptions = /* @__PURE__ */ new Set();
|
|
148
|
+
const actionSubscriptions = /* @__PURE__ */ new Set();
|
|
149
|
+
const debuggerEvents = [];
|
|
150
|
+
let activeListener;
|
|
151
|
+
function $patch(partialStateOrMutator) {
|
|
152
|
+
let subscriptionMutation;
|
|
153
|
+
isListening = isSyncListening = false;
|
|
154
|
+
if (typeof partialStateOrMutator === "function") {
|
|
155
|
+
partialStateOrMutator(pinia.state.value[$id]);
|
|
156
|
+
subscriptionMutation = {
|
|
157
|
+
type: "patch function" /* patchFunction */,
|
|
158
|
+
storeId: $id,
|
|
159
|
+
events: debuggerEvents
|
|
160
|
+
};
|
|
161
|
+
} else {
|
|
162
|
+
mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
|
|
163
|
+
subscriptionMutation = {
|
|
164
|
+
type: "patch object" /* patchObject */,
|
|
165
|
+
payload: partialStateOrMutator,
|
|
166
|
+
storeId: $id,
|
|
167
|
+
events: debuggerEvents
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
activeListener = Symbol();
|
|
171
|
+
const myListenerId = activeListener;
|
|
172
|
+
nextTick().then(() => {
|
|
173
|
+
if (activeListener === myListenerId) {
|
|
174
|
+
isListening = true;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
isSyncListening = true;
|
|
178
|
+
triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
|
|
179
|
+
}
|
|
180
|
+
const $reset = function $reset2() {
|
|
181
|
+
const { state } = options;
|
|
182
|
+
const newState = state ? state() : {};
|
|
183
|
+
this.$patch(($state) => {
|
|
184
|
+
assign($state, newState);
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
const action = (fn, name = "") => {
|
|
188
|
+
if (ACTION_MARKER in fn) {
|
|
189
|
+
;
|
|
190
|
+
fn[ACTION_NAME] = name;
|
|
191
|
+
return fn;
|
|
192
|
+
}
|
|
193
|
+
const wrappedAction = function() {
|
|
194
|
+
setActivePinia(pinia);
|
|
195
|
+
const args = Array.from(arguments);
|
|
196
|
+
const afterCallbackSet = /* @__PURE__ */ new Set();
|
|
197
|
+
const onErrorCallbackSet = /* @__PURE__ */ new Set();
|
|
198
|
+
function after(callback) {
|
|
199
|
+
afterCallbackSet.add(callback);
|
|
200
|
+
}
|
|
201
|
+
function onError(callback) {
|
|
202
|
+
onErrorCallbackSet.add(callback);
|
|
203
|
+
}
|
|
204
|
+
triggerSubscriptions(actionSubscriptions, {
|
|
205
|
+
args,
|
|
206
|
+
name: wrappedAction[ACTION_NAME],
|
|
207
|
+
store,
|
|
208
|
+
after,
|
|
209
|
+
onError
|
|
210
|
+
});
|
|
211
|
+
let ret;
|
|
212
|
+
try {
|
|
213
|
+
ret = fn.apply(this && this.$id === $id ? this : store, args);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
triggerSubscriptions(onErrorCallbackSet, error);
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
if (ret instanceof Promise) {
|
|
219
|
+
return ret.then((value) => {
|
|
220
|
+
triggerSubscriptions(afterCallbackSet, value);
|
|
221
|
+
return value;
|
|
222
|
+
}).catch((error) => {
|
|
223
|
+
triggerSubscriptions(onErrorCallbackSet, error);
|
|
224
|
+
return Promise.reject(error);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
triggerSubscriptions(afterCallbackSet, ret);
|
|
228
|
+
return ret;
|
|
229
|
+
};
|
|
230
|
+
wrappedAction[ACTION_MARKER] = true;
|
|
231
|
+
wrappedAction[ACTION_NAME] = name;
|
|
232
|
+
return wrappedAction;
|
|
233
|
+
};
|
|
234
|
+
const partialStore = {
|
|
235
|
+
_p: pinia,
|
|
236
|
+
// _s: scope,
|
|
237
|
+
$id,
|
|
238
|
+
$onAction: addSubscription.bind(null, activeComponentCleanUp, actionSubscriptions),
|
|
239
|
+
$patch,
|
|
240
|
+
$reset,
|
|
241
|
+
$subscribe(callback, options2 = {}) {
|
|
242
|
+
const removeSubscription = addSubscription([[]], subscriptions, callback, options2.detached, () => stopWatcher());
|
|
243
|
+
const stopWatcher = scope.run(
|
|
244
|
+
() => watch(
|
|
245
|
+
() => pinia.state.value[$id],
|
|
246
|
+
(state) => {
|
|
247
|
+
if (options2.flush === "sync" ? isSyncListening : isListening) {
|
|
248
|
+
callback(
|
|
249
|
+
{
|
|
250
|
+
storeId: $id,
|
|
251
|
+
type: "direct" /* direct */,
|
|
252
|
+
events: debuggerEvents
|
|
253
|
+
},
|
|
254
|
+
state
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
assign({}, $subscribeOptions, options2)
|
|
259
|
+
)
|
|
260
|
+
);
|
|
261
|
+
return removeSubscription;
|
|
262
|
+
}
|
|
263
|
+
// $dispose
|
|
264
|
+
};
|
|
265
|
+
const store = reactive(partialStore);
|
|
266
|
+
pinia._s.set($id, store);
|
|
267
|
+
scope = effectScope2();
|
|
268
|
+
const setupStore = scope.run(() => setup({ action }));
|
|
269
|
+
for (const key in setupStore) {
|
|
270
|
+
const prop = setupStore[key];
|
|
271
|
+
if (typeof prop === "function") {
|
|
272
|
+
const actionValue = action(prop, key);
|
|
273
|
+
setupStore[key] = actionValue;
|
|
274
|
+
optionsForPlugin.actions[key] = prop;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
assign(store, setupStore);
|
|
278
|
+
assign(toRaw(store), setupStore);
|
|
279
|
+
Object.defineProperty(store, "$state", {
|
|
280
|
+
get: () => pinia.state.value[$id],
|
|
281
|
+
set: (state) => {
|
|
282
|
+
$patch(($state) => {
|
|
283
|
+
assign($state, state);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
pinia._p.forEach((extender) => {
|
|
288
|
+
assign(
|
|
289
|
+
store,
|
|
290
|
+
scope.run(
|
|
291
|
+
() => extender({
|
|
292
|
+
store,
|
|
293
|
+
pinia,
|
|
294
|
+
options: optionsForPlugin
|
|
295
|
+
})
|
|
296
|
+
)
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
isListening = true;
|
|
300
|
+
isSyncListening = true;
|
|
301
|
+
return store;
|
|
302
|
+
}
|
|
303
|
+
var activeComponentCleanUp = [[]];
|
|
2185
304
|
function defineStore(id, options) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
305
|
+
const effectMap = /* @__PURE__ */ new WeakMap();
|
|
306
|
+
const subscribeMap = /* @__PURE__ */ new WeakMap();
|
|
307
|
+
const cleanUpMap = /* @__PURE__ */ new WeakMap();
|
|
308
|
+
function useStore(pinia) {
|
|
309
|
+
if (pinia) setActivePinia(pinia);
|
|
310
|
+
if (!activePinia) {
|
|
311
|
+
throw new Error(
|
|
312
|
+
`[\u{1F34D}]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "createPinia()"?
|
|
313
|
+
`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
pinia = activePinia;
|
|
317
|
+
const lastEffect = activeEffect.value;
|
|
318
|
+
activeEffect.value = void 0;
|
|
319
|
+
if (!pinia._s.has(id)) createOptionsStore(id, options, pinia);
|
|
320
|
+
activeEffect.value = lastEffect;
|
|
321
|
+
const store = pinia._s.get(id);
|
|
322
|
+
const _id = useRef([useId()]);
|
|
323
|
+
const storeSnapshotRef = useRef({ ...store });
|
|
324
|
+
const isCollectDep = useRef(false);
|
|
325
|
+
if (!cleanUpMap.get(_id.current)) {
|
|
326
|
+
cleanUpMap.set(_id.current, []);
|
|
327
|
+
}
|
|
328
|
+
activeComponentCleanUp[0] = cleanUpMap.get(_id.current);
|
|
329
|
+
useEffect(() => {
|
|
330
|
+
activeComponentCleanUp[0] = cleanUpMap.get(_id.current);
|
|
331
|
+
return () => {
|
|
332
|
+
cleanUpMap.get(_id.current).forEach((fn) => {
|
|
333
|
+
fn();
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
}, []);
|
|
337
|
+
const subscribe = useCallback((onStoreChange) => {
|
|
338
|
+
subscribeMap.set(_id.current, onStoreChange);
|
|
339
|
+
return () => {
|
|
340
|
+
const effect2 = effectMap.get(_id.current);
|
|
341
|
+
if (effect2) effect2.stop();
|
|
342
|
+
subscribeMap.delete(_id.current);
|
|
343
|
+
effectMap.delete(_id.current);
|
|
344
|
+
};
|
|
345
|
+
}, []);
|
|
346
|
+
useSyncExternalStore(
|
|
347
|
+
subscribe,
|
|
348
|
+
() => storeSnapshotRef.current,
|
|
349
|
+
() => storeSnapshotRef.current
|
|
350
|
+
);
|
|
351
|
+
let effect = effectMap.get(_id.current);
|
|
352
|
+
if (!effect) {
|
|
353
|
+
const fn = () => {
|
|
354
|
+
const onStoreChange = subscribeMap.get(_id.current);
|
|
355
|
+
if (!isCollectDep.current) {
|
|
356
|
+
storeSnapshotRef.current = { ...store };
|
|
357
|
+
onStoreChange?.();
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
effect = new ReactiveEffect(fn, noop2, () => {
|
|
361
|
+
if (effect?.dirty) effect.run();
|
|
362
|
+
});
|
|
363
|
+
activeEffect.value = effect;
|
|
364
|
+
isCollectDep.current = true;
|
|
365
|
+
effect.run();
|
|
366
|
+
effectMap.set(_id.current, effect);
|
|
367
|
+
isCollectDep.current = false;
|
|
368
|
+
}
|
|
369
|
+
return store;
|
|
370
|
+
}
|
|
371
|
+
useStore.$id = id;
|
|
372
|
+
useStore.$getStore = (pinia) => {
|
|
373
|
+
if (pinia) setActivePinia(pinia);
|
|
374
|
+
pinia = activePinia;
|
|
375
|
+
if (!pinia._s.has(id)) createOptionsStore(id, options, pinia);
|
|
376
|
+
const store = pinia._s.get(id);
|
|
377
|
+
return store;
|
|
378
|
+
};
|
|
379
|
+
return useStore;
|
|
380
|
+
}
|
|
381
|
+
export {
|
|
382
|
+
MutationType,
|
|
383
|
+
createPinia,
|
|
384
|
+
defineStore,
|
|
385
|
+
getActivePinia,
|
|
386
|
+
setActivePinia
|
|
387
|
+
};
|
|
388
|
+
//# sourceMappingURL=index.js.map
|