@kitbag/router 0.0.1 → 0.0.2
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 +17 -0
- package/dist/kitbag-router.d.ts +547 -3699
- package/dist/kitbag-router.js +1188 -4725
- package/dist/kitbag-router.umd.cjs +1 -4951
- package/package.json +1 -1
|
@@ -1,4951 +1 @@
|
|
|
1
|
-
(function(global2, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@kitbag/router"] = {}));
|
|
3
|
-
})(this, function(exports2) {
|
|
4
|
-
"use strict";var __defProp = Object.defineProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => {
|
|
7
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
function useParam(_param, _defaultValue) {
|
|
12
|
-
throw "not implemented";
|
|
13
|
-
}
|
|
14
|
-
function useParamRaw(_param, _defaultValue) {
|
|
15
|
-
throw "not implemented";
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @vue/shared v3.4.23
|
|
19
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
20
|
-
* @license MIT
|
|
21
|
-
**/
|
|
22
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
23
|
-
// @__NO_SIDE_EFFECTS__
|
|
24
|
-
function makeMap(str, expectsLowerCase) {
|
|
25
|
-
const set2 = new Set(str.split(","));
|
|
26
|
-
return expectsLowerCase ? (val) => set2.has(val.toLowerCase()) : (val) => set2.has(val);
|
|
27
|
-
}
|
|
28
|
-
const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
29
|
-
const EMPTY_ARR = !!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
30
|
-
const NOOP = () => {
|
|
31
|
-
};
|
|
32
|
-
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
|
|
33
|
-
(key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
34
|
-
const extend = Object.assign;
|
|
35
|
-
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
36
|
-
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
37
|
-
const isArray = Array.isArray;
|
|
38
|
-
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
39
|
-
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
40
|
-
const isFunction = (val) => typeof val === "function";
|
|
41
|
-
const isString = (val) => typeof val === "string";
|
|
42
|
-
const isSymbol = (val) => typeof val === "symbol";
|
|
43
|
-
const isObject = (val) => val !== null && typeof val === "object";
|
|
44
|
-
const isPromise = (val) => {
|
|
45
|
-
return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
46
|
-
};
|
|
47
|
-
const objectToString = Object.prototype.toString;
|
|
48
|
-
const toTypeString = (value) => objectToString.call(value);
|
|
49
|
-
const toRawType = (value) => {
|
|
50
|
-
return toTypeString(value).slice(8, -1);
|
|
51
|
-
};
|
|
52
|
-
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
53
|
-
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
54
|
-
const cacheStringFunction = (fn) => {
|
|
55
|
-
const cache = /* @__PURE__ */ Object.create(null);
|
|
56
|
-
return (str) => {
|
|
57
|
-
const hit = cache[str];
|
|
58
|
-
return hit || (cache[str] = fn(str));
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
const camelizeRE = /-(\w)/g;
|
|
62
|
-
const camelize = cacheStringFunction((str) => {
|
|
63
|
-
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
64
|
-
});
|
|
65
|
-
const capitalize = cacheStringFunction((str) => {
|
|
66
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
67
|
-
});
|
|
68
|
-
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
69
|
-
const def = (obj, key, value) => {
|
|
70
|
-
Object.defineProperty(obj, key, {
|
|
71
|
-
configurable: true,
|
|
72
|
-
enumerable: false,
|
|
73
|
-
value
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
let _globalThis;
|
|
77
|
-
const getGlobalThis = () => {
|
|
78
|
-
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
79
|
-
};
|
|
80
|
-
function normalizeStyle(value) {
|
|
81
|
-
if (isArray(value)) {
|
|
82
|
-
const res = {};
|
|
83
|
-
for (let i = 0; i < value.length; i++) {
|
|
84
|
-
const item = value[i];
|
|
85
|
-
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
86
|
-
if (normalized) {
|
|
87
|
-
for (const key in normalized) {
|
|
88
|
-
res[key] = normalized[key];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return res;
|
|
93
|
-
} else if (isString(value) || isObject(value)) {
|
|
94
|
-
return value;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
98
|
-
const propertyDelimiterRE = /:([^]+)/;
|
|
99
|
-
const styleCommentRE = /\/\*[^]*?\*\//g;
|
|
100
|
-
function parseStringStyle(cssText) {
|
|
101
|
-
const ret = {};
|
|
102
|
-
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
103
|
-
if (item) {
|
|
104
|
-
const tmp = item.split(propertyDelimiterRE);
|
|
105
|
-
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return ret;
|
|
109
|
-
}
|
|
110
|
-
function normalizeClass(value) {
|
|
111
|
-
let res = "";
|
|
112
|
-
if (isString(value)) {
|
|
113
|
-
res = value;
|
|
114
|
-
} else if (isArray(value)) {
|
|
115
|
-
for (let i = 0; i < value.length; i++) {
|
|
116
|
-
const normalized = normalizeClass(value[i]);
|
|
117
|
-
if (normalized) {
|
|
118
|
-
res += normalized + " ";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} else if (isObject(value)) {
|
|
122
|
-
for (const name in value) {
|
|
123
|
-
if (value[name]) {
|
|
124
|
-
res += name + " ";
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return res.trim();
|
|
129
|
-
}
|
|
130
|
-
function normalizeProps(props) {
|
|
131
|
-
if (!props)
|
|
132
|
-
return null;
|
|
133
|
-
let { class: klass, style } = props;
|
|
134
|
-
if (klass && !isString(klass)) {
|
|
135
|
-
props.class = normalizeClass(klass);
|
|
136
|
-
}
|
|
137
|
-
if (style) {
|
|
138
|
-
props.style = normalizeStyle(style);
|
|
139
|
-
}
|
|
140
|
-
return props;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* @vue/reactivity v3.4.23
|
|
144
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
145
|
-
* @license MIT
|
|
146
|
-
**/
|
|
147
|
-
function warn(msg, ...args) {
|
|
148
|
-
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
149
|
-
}
|
|
150
|
-
let activeEffectScope;
|
|
151
|
-
function recordEffectScope(effect, scope = activeEffectScope) {
|
|
152
|
-
if (scope && scope.active) {
|
|
153
|
-
scope.effects.push(effect);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
let activeEffect;
|
|
157
|
-
class ReactiveEffect {
|
|
158
|
-
constructor(fn, trigger2, scheduler, scope) {
|
|
159
|
-
this.fn = fn;
|
|
160
|
-
this.trigger = trigger2;
|
|
161
|
-
this.scheduler = scheduler;
|
|
162
|
-
this.active = true;
|
|
163
|
-
this.deps = [];
|
|
164
|
-
this._dirtyLevel = 4;
|
|
165
|
-
this._trackId = 0;
|
|
166
|
-
this._runnings = 0;
|
|
167
|
-
this._shouldSchedule = false;
|
|
168
|
-
this._depsLength = 0;
|
|
169
|
-
recordEffectScope(this, scope);
|
|
170
|
-
}
|
|
171
|
-
get dirty() {
|
|
172
|
-
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
173
|
-
this._dirtyLevel = 1;
|
|
174
|
-
pauseTracking();
|
|
175
|
-
for (let i = 0; i < this._depsLength; i++) {
|
|
176
|
-
const dep = this.deps[i];
|
|
177
|
-
if (dep.computed) {
|
|
178
|
-
triggerComputed(dep.computed);
|
|
179
|
-
if (this._dirtyLevel >= 4) {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (this._dirtyLevel === 1) {
|
|
185
|
-
this._dirtyLevel = 0;
|
|
186
|
-
}
|
|
187
|
-
resetTracking();
|
|
188
|
-
}
|
|
189
|
-
return this._dirtyLevel >= 4;
|
|
190
|
-
}
|
|
191
|
-
set dirty(v) {
|
|
192
|
-
this._dirtyLevel = v ? 4 : 0;
|
|
193
|
-
}
|
|
194
|
-
run() {
|
|
195
|
-
this._dirtyLevel = 0;
|
|
196
|
-
if (!this.active) {
|
|
197
|
-
return this.fn();
|
|
198
|
-
}
|
|
199
|
-
let lastShouldTrack = shouldTrack;
|
|
200
|
-
let lastEffect = activeEffect;
|
|
201
|
-
try {
|
|
202
|
-
shouldTrack = true;
|
|
203
|
-
activeEffect = this;
|
|
204
|
-
this._runnings++;
|
|
205
|
-
preCleanupEffect(this);
|
|
206
|
-
return this.fn();
|
|
207
|
-
} finally {
|
|
208
|
-
postCleanupEffect(this);
|
|
209
|
-
this._runnings--;
|
|
210
|
-
activeEffect = lastEffect;
|
|
211
|
-
shouldTrack = lastShouldTrack;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
stop() {
|
|
215
|
-
var _a;
|
|
216
|
-
if (this.active) {
|
|
217
|
-
preCleanupEffect(this);
|
|
218
|
-
postCleanupEffect(this);
|
|
219
|
-
(_a = this.onStop) == null ? void 0 : _a.call(this);
|
|
220
|
-
this.active = false;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function triggerComputed(computed2) {
|
|
225
|
-
return computed2.value;
|
|
226
|
-
}
|
|
227
|
-
function preCleanupEffect(effect2) {
|
|
228
|
-
effect2._trackId++;
|
|
229
|
-
effect2._depsLength = 0;
|
|
230
|
-
}
|
|
231
|
-
function postCleanupEffect(effect2) {
|
|
232
|
-
if (effect2.deps.length > effect2._depsLength) {
|
|
233
|
-
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
|
234
|
-
cleanupDepEffect(effect2.deps[i], effect2);
|
|
235
|
-
}
|
|
236
|
-
effect2.deps.length = effect2._depsLength;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function cleanupDepEffect(dep, effect2) {
|
|
240
|
-
const trackId = dep.get(effect2);
|
|
241
|
-
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
242
|
-
dep.delete(effect2);
|
|
243
|
-
if (dep.size === 0) {
|
|
244
|
-
dep.cleanup();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
let shouldTrack = true;
|
|
249
|
-
let pauseScheduleStack = 0;
|
|
250
|
-
const trackStack = [];
|
|
251
|
-
function pauseTracking() {
|
|
252
|
-
trackStack.push(shouldTrack);
|
|
253
|
-
shouldTrack = false;
|
|
254
|
-
}
|
|
255
|
-
function resetTracking() {
|
|
256
|
-
const last = trackStack.pop();
|
|
257
|
-
shouldTrack = last === void 0 ? true : last;
|
|
258
|
-
}
|
|
259
|
-
function pauseScheduling() {
|
|
260
|
-
pauseScheduleStack++;
|
|
261
|
-
}
|
|
262
|
-
function resetScheduling() {
|
|
263
|
-
pauseScheduleStack--;
|
|
264
|
-
while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
|
265
|
-
queueEffectSchedulers.shift()();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
269
|
-
var _a;
|
|
270
|
-
if (dep.get(effect2) !== effect2._trackId) {
|
|
271
|
-
dep.set(effect2, effect2._trackId);
|
|
272
|
-
const oldDep = effect2.deps[effect2._depsLength];
|
|
273
|
-
if (oldDep !== dep) {
|
|
274
|
-
if (oldDep) {
|
|
275
|
-
cleanupDepEffect(oldDep, effect2);
|
|
276
|
-
}
|
|
277
|
-
effect2.deps[effect2._depsLength++] = dep;
|
|
278
|
-
} else {
|
|
279
|
-
effect2._depsLength++;
|
|
280
|
-
}
|
|
281
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
282
|
-
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const queueEffectSchedulers = [];
|
|
287
|
-
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
288
|
-
var _a;
|
|
289
|
-
pauseScheduling();
|
|
290
|
-
for (const effect2 of dep.keys()) {
|
|
291
|
-
let tracking;
|
|
292
|
-
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
293
|
-
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
|
294
|
-
effect2._dirtyLevel = dirtyLevel;
|
|
295
|
-
}
|
|
296
|
-
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
297
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
298
|
-
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
299
|
-
}
|
|
300
|
-
effect2.trigger();
|
|
301
|
-
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
|
302
|
-
effect2._shouldSchedule = false;
|
|
303
|
-
if (effect2.scheduler) {
|
|
304
|
-
queueEffectSchedulers.push(effect2.scheduler);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
resetScheduling();
|
|
310
|
-
}
|
|
311
|
-
const createDep = (cleanup, computed2) => {
|
|
312
|
-
const dep = /* @__PURE__ */ new Map();
|
|
313
|
-
dep.cleanup = cleanup;
|
|
314
|
-
dep.computed = computed2;
|
|
315
|
-
return dep;
|
|
316
|
-
};
|
|
317
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
318
|
-
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
|
|
319
|
-
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
|
|
320
|
-
function track(target, type, key) {
|
|
321
|
-
if (shouldTrack && activeEffect) {
|
|
322
|
-
let depsMap = targetMap.get(target);
|
|
323
|
-
if (!depsMap) {
|
|
324
|
-
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
325
|
-
}
|
|
326
|
-
let dep = depsMap.get(key);
|
|
327
|
-
if (!dep) {
|
|
328
|
-
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
329
|
-
}
|
|
330
|
-
trackEffect(
|
|
331
|
-
activeEffect,
|
|
332
|
-
dep,
|
|
333
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
334
|
-
target,
|
|
335
|
-
type,
|
|
336
|
-
key
|
|
337
|
-
} : void 0
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
342
|
-
const depsMap = targetMap.get(target);
|
|
343
|
-
if (!depsMap) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
let deps = [];
|
|
347
|
-
if (type === "clear") {
|
|
348
|
-
deps = [...depsMap.values()];
|
|
349
|
-
} else if (key === "length" && isArray(target)) {
|
|
350
|
-
const newLength = Number(newValue);
|
|
351
|
-
depsMap.forEach((dep, key2) => {
|
|
352
|
-
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
|
353
|
-
deps.push(dep);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
} else {
|
|
357
|
-
if (key !== void 0) {
|
|
358
|
-
deps.push(depsMap.get(key));
|
|
359
|
-
}
|
|
360
|
-
switch (type) {
|
|
361
|
-
case "add":
|
|
362
|
-
if (!isArray(target)) {
|
|
363
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
364
|
-
if (isMap(target)) {
|
|
365
|
-
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
366
|
-
}
|
|
367
|
-
} else if (isIntegerKey(key)) {
|
|
368
|
-
deps.push(depsMap.get("length"));
|
|
369
|
-
}
|
|
370
|
-
break;
|
|
371
|
-
case "delete":
|
|
372
|
-
if (!isArray(target)) {
|
|
373
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
374
|
-
if (isMap(target)) {
|
|
375
|
-
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
break;
|
|
379
|
-
case "set":
|
|
380
|
-
if (isMap(target)) {
|
|
381
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
382
|
-
}
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
pauseScheduling();
|
|
387
|
-
for (const dep of deps) {
|
|
388
|
-
if (dep) {
|
|
389
|
-
triggerEffects(
|
|
390
|
-
dep,
|
|
391
|
-
4,
|
|
392
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
393
|
-
target,
|
|
394
|
-
type,
|
|
395
|
-
key,
|
|
396
|
-
newValue,
|
|
397
|
-
oldValue,
|
|
398
|
-
oldTarget
|
|
399
|
-
} : void 0
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
resetScheduling();
|
|
404
|
-
}
|
|
405
|
-
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
406
|
-
const builtInSymbols = new Set(
|
|
407
|
-
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
408
|
-
);
|
|
409
|
-
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
410
|
-
function createArrayInstrumentations() {
|
|
411
|
-
const instrumentations = {};
|
|
412
|
-
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
413
|
-
instrumentations[key] = function(...args) {
|
|
414
|
-
const arr = toRaw(this);
|
|
415
|
-
for (let i = 0, l = this.length; i < l; i++) {
|
|
416
|
-
track(arr, "get", i + "");
|
|
417
|
-
}
|
|
418
|
-
const res = arr[key](...args);
|
|
419
|
-
if (res === -1 || res === false) {
|
|
420
|
-
return arr[key](...args.map(toRaw));
|
|
421
|
-
} else {
|
|
422
|
-
return res;
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
});
|
|
426
|
-
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
427
|
-
instrumentations[key] = function(...args) {
|
|
428
|
-
pauseTracking();
|
|
429
|
-
pauseScheduling();
|
|
430
|
-
const res = toRaw(this)[key].apply(this, args);
|
|
431
|
-
resetScheduling();
|
|
432
|
-
resetTracking();
|
|
433
|
-
return res;
|
|
434
|
-
};
|
|
435
|
-
});
|
|
436
|
-
return instrumentations;
|
|
437
|
-
}
|
|
438
|
-
function hasOwnProperty(key) {
|
|
439
|
-
if (!isSymbol(key))
|
|
440
|
-
key = String(key);
|
|
441
|
-
const obj = toRaw(this);
|
|
442
|
-
track(obj, "has", key);
|
|
443
|
-
return obj.hasOwnProperty(key);
|
|
444
|
-
}
|
|
445
|
-
class BaseReactiveHandler {
|
|
446
|
-
constructor(_isReadonly = false, _isShallow = false) {
|
|
447
|
-
this._isReadonly = _isReadonly;
|
|
448
|
-
this._isShallow = _isShallow;
|
|
449
|
-
}
|
|
450
|
-
get(target, key, receiver) {
|
|
451
|
-
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
452
|
-
if (key === "__v_isReactive") {
|
|
453
|
-
return !isReadonly2;
|
|
454
|
-
} else if (key === "__v_isReadonly") {
|
|
455
|
-
return isReadonly2;
|
|
456
|
-
} else if (key === "__v_isShallow") {
|
|
457
|
-
return isShallow2;
|
|
458
|
-
} else if (key === "__v_raw") {
|
|
459
|
-
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
460
|
-
// this means the reciever is a user proxy of the reactive proxy
|
|
461
|
-
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
462
|
-
return target;
|
|
463
|
-
}
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
const targetIsArray = isArray(target);
|
|
467
|
-
if (!isReadonly2) {
|
|
468
|
-
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
469
|
-
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
470
|
-
}
|
|
471
|
-
if (key === "hasOwnProperty") {
|
|
472
|
-
return hasOwnProperty;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
const res = Reflect.get(target, key, receiver);
|
|
476
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
477
|
-
return res;
|
|
478
|
-
}
|
|
479
|
-
if (!isReadonly2) {
|
|
480
|
-
track(target, "get", key);
|
|
481
|
-
}
|
|
482
|
-
if (isShallow2) {
|
|
483
|
-
return res;
|
|
484
|
-
}
|
|
485
|
-
if (isRef(res)) {
|
|
486
|
-
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
487
|
-
}
|
|
488
|
-
if (isObject(res)) {
|
|
489
|
-
return isReadonly2 ? readonly(res) : reactive(res);
|
|
490
|
-
}
|
|
491
|
-
return res;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
495
|
-
constructor(isShallow2 = false) {
|
|
496
|
-
super(false, isShallow2);
|
|
497
|
-
}
|
|
498
|
-
set(target, key, value, receiver) {
|
|
499
|
-
let oldValue = target[key];
|
|
500
|
-
if (!this._isShallow) {
|
|
501
|
-
const isOldValueReadonly = isReadonly(oldValue);
|
|
502
|
-
if (!isShallow(value) && !isReadonly(value)) {
|
|
503
|
-
oldValue = toRaw(oldValue);
|
|
504
|
-
value = toRaw(value);
|
|
505
|
-
}
|
|
506
|
-
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
507
|
-
if (isOldValueReadonly) {
|
|
508
|
-
return false;
|
|
509
|
-
} else {
|
|
510
|
-
oldValue.value = value;
|
|
511
|
-
return true;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
516
|
-
const result = Reflect.set(target, key, value, receiver);
|
|
517
|
-
if (target === toRaw(receiver)) {
|
|
518
|
-
if (!hadKey) {
|
|
519
|
-
trigger(target, "add", key, value);
|
|
520
|
-
} else if (hasChanged(value, oldValue)) {
|
|
521
|
-
trigger(target, "set", key, value, oldValue);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return result;
|
|
525
|
-
}
|
|
526
|
-
deleteProperty(target, key) {
|
|
527
|
-
const hadKey = hasOwn(target, key);
|
|
528
|
-
const oldValue = target[key];
|
|
529
|
-
const result = Reflect.deleteProperty(target, key);
|
|
530
|
-
if (result && hadKey) {
|
|
531
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
532
|
-
}
|
|
533
|
-
return result;
|
|
534
|
-
}
|
|
535
|
-
has(target, key) {
|
|
536
|
-
const result = Reflect.has(target, key);
|
|
537
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
538
|
-
track(target, "has", key);
|
|
539
|
-
}
|
|
540
|
-
return result;
|
|
541
|
-
}
|
|
542
|
-
ownKeys(target) {
|
|
543
|
-
track(
|
|
544
|
-
target,
|
|
545
|
-
"iterate",
|
|
546
|
-
isArray(target) ? "length" : ITERATE_KEY
|
|
547
|
-
);
|
|
548
|
-
return Reflect.ownKeys(target);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
552
|
-
constructor(isShallow2 = false) {
|
|
553
|
-
super(true, isShallow2);
|
|
554
|
-
}
|
|
555
|
-
set(target, key) {
|
|
556
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
557
|
-
warn(
|
|
558
|
-
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
559
|
-
target
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
deleteProperty(target, key) {
|
|
565
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
566
|
-
warn(
|
|
567
|
-
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
568
|
-
target
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
return true;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
575
|
-
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
576
|
-
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
577
|
-
const toShallow = (value) => value;
|
|
578
|
-
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
579
|
-
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
580
|
-
target = target["__v_raw"];
|
|
581
|
-
const rawTarget = toRaw(target);
|
|
582
|
-
const rawKey = toRaw(key);
|
|
583
|
-
if (!isReadonly2) {
|
|
584
|
-
if (hasChanged(key, rawKey)) {
|
|
585
|
-
track(rawTarget, "get", key);
|
|
586
|
-
}
|
|
587
|
-
track(rawTarget, "get", rawKey);
|
|
588
|
-
}
|
|
589
|
-
const { has: has2 } = getProto(rawTarget);
|
|
590
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
591
|
-
if (has2.call(rawTarget, key)) {
|
|
592
|
-
return wrap(target.get(key));
|
|
593
|
-
} else if (has2.call(rawTarget, rawKey)) {
|
|
594
|
-
return wrap(target.get(rawKey));
|
|
595
|
-
} else if (target !== rawTarget) {
|
|
596
|
-
target.get(key);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
function has(key, isReadonly2 = false) {
|
|
600
|
-
const target = this["__v_raw"];
|
|
601
|
-
const rawTarget = toRaw(target);
|
|
602
|
-
const rawKey = toRaw(key);
|
|
603
|
-
if (!isReadonly2) {
|
|
604
|
-
if (hasChanged(key, rawKey)) {
|
|
605
|
-
track(rawTarget, "has", key);
|
|
606
|
-
}
|
|
607
|
-
track(rawTarget, "has", rawKey);
|
|
608
|
-
}
|
|
609
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
610
|
-
}
|
|
611
|
-
function size(target, isReadonly2 = false) {
|
|
612
|
-
target = target["__v_raw"];
|
|
613
|
-
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
614
|
-
return Reflect.get(target, "size", target);
|
|
615
|
-
}
|
|
616
|
-
function add(value) {
|
|
617
|
-
value = toRaw(value);
|
|
618
|
-
const target = toRaw(this);
|
|
619
|
-
const proto = getProto(target);
|
|
620
|
-
const hadKey = proto.has.call(target, value);
|
|
621
|
-
if (!hadKey) {
|
|
622
|
-
target.add(value);
|
|
623
|
-
trigger(target, "add", value, value);
|
|
624
|
-
}
|
|
625
|
-
return this;
|
|
626
|
-
}
|
|
627
|
-
function set(key, value) {
|
|
628
|
-
value = toRaw(value);
|
|
629
|
-
const target = toRaw(this);
|
|
630
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
631
|
-
let hadKey = has2.call(target, key);
|
|
632
|
-
if (!hadKey) {
|
|
633
|
-
key = toRaw(key);
|
|
634
|
-
hadKey = has2.call(target, key);
|
|
635
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
636
|
-
checkIdentityKeys(target, has2, key);
|
|
637
|
-
}
|
|
638
|
-
const oldValue = get2.call(target, key);
|
|
639
|
-
target.set(key, value);
|
|
640
|
-
if (!hadKey) {
|
|
641
|
-
trigger(target, "add", key, value);
|
|
642
|
-
} else if (hasChanged(value, oldValue)) {
|
|
643
|
-
trigger(target, "set", key, value, oldValue);
|
|
644
|
-
}
|
|
645
|
-
return this;
|
|
646
|
-
}
|
|
647
|
-
function deleteEntry(key) {
|
|
648
|
-
const target = toRaw(this);
|
|
649
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
650
|
-
let hadKey = has2.call(target, key);
|
|
651
|
-
if (!hadKey) {
|
|
652
|
-
key = toRaw(key);
|
|
653
|
-
hadKey = has2.call(target, key);
|
|
654
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
655
|
-
checkIdentityKeys(target, has2, key);
|
|
656
|
-
}
|
|
657
|
-
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
658
|
-
const result = target.delete(key);
|
|
659
|
-
if (hadKey) {
|
|
660
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
661
|
-
}
|
|
662
|
-
return result;
|
|
663
|
-
}
|
|
664
|
-
function clear() {
|
|
665
|
-
const target = toRaw(this);
|
|
666
|
-
const hadItems = target.size !== 0;
|
|
667
|
-
const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
668
|
-
const result = target.clear();
|
|
669
|
-
if (hadItems) {
|
|
670
|
-
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
671
|
-
}
|
|
672
|
-
return result;
|
|
673
|
-
}
|
|
674
|
-
function createForEach(isReadonly2, isShallow2) {
|
|
675
|
-
return function forEach(callback, thisArg) {
|
|
676
|
-
const observed = this;
|
|
677
|
-
const target = observed["__v_raw"];
|
|
678
|
-
const rawTarget = toRaw(target);
|
|
679
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
680
|
-
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
681
|
-
return target.forEach((value, key) => {
|
|
682
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
683
|
-
});
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
687
|
-
return function(...args) {
|
|
688
|
-
const target = this["__v_raw"];
|
|
689
|
-
const rawTarget = toRaw(target);
|
|
690
|
-
const targetIsMap = isMap(rawTarget);
|
|
691
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
692
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
693
|
-
const innerIterator = target[method](...args);
|
|
694
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
695
|
-
!isReadonly2 && track(
|
|
696
|
-
rawTarget,
|
|
697
|
-
"iterate",
|
|
698
|
-
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
699
|
-
);
|
|
700
|
-
return {
|
|
701
|
-
// iterator protocol
|
|
702
|
-
next() {
|
|
703
|
-
const { value, done } = innerIterator.next();
|
|
704
|
-
return done ? { value, done } : {
|
|
705
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
706
|
-
done
|
|
707
|
-
};
|
|
708
|
-
},
|
|
709
|
-
// iterable protocol
|
|
710
|
-
[Symbol.iterator]() {
|
|
711
|
-
return this;
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
function createReadonlyMethod(type) {
|
|
717
|
-
return function(...args) {
|
|
718
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
719
|
-
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
720
|
-
warn(
|
|
721
|
-
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
722
|
-
toRaw(this)
|
|
723
|
-
);
|
|
724
|
-
}
|
|
725
|
-
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
function createInstrumentations() {
|
|
729
|
-
const mutableInstrumentations2 = {
|
|
730
|
-
get(key) {
|
|
731
|
-
return get(this, key);
|
|
732
|
-
},
|
|
733
|
-
get size() {
|
|
734
|
-
return size(this);
|
|
735
|
-
},
|
|
736
|
-
has,
|
|
737
|
-
add,
|
|
738
|
-
set,
|
|
739
|
-
delete: deleteEntry,
|
|
740
|
-
clear,
|
|
741
|
-
forEach: createForEach(false, false)
|
|
742
|
-
};
|
|
743
|
-
const shallowInstrumentations2 = {
|
|
744
|
-
get(key) {
|
|
745
|
-
return get(this, key, false, true);
|
|
746
|
-
},
|
|
747
|
-
get size() {
|
|
748
|
-
return size(this);
|
|
749
|
-
},
|
|
750
|
-
has,
|
|
751
|
-
add,
|
|
752
|
-
set,
|
|
753
|
-
delete: deleteEntry,
|
|
754
|
-
clear,
|
|
755
|
-
forEach: createForEach(false, true)
|
|
756
|
-
};
|
|
757
|
-
const readonlyInstrumentations2 = {
|
|
758
|
-
get(key) {
|
|
759
|
-
return get(this, key, true);
|
|
760
|
-
},
|
|
761
|
-
get size() {
|
|
762
|
-
return size(this, true);
|
|
763
|
-
},
|
|
764
|
-
has(key) {
|
|
765
|
-
return has.call(this, key, true);
|
|
766
|
-
},
|
|
767
|
-
add: createReadonlyMethod("add"),
|
|
768
|
-
set: createReadonlyMethod("set"),
|
|
769
|
-
delete: createReadonlyMethod("delete"),
|
|
770
|
-
clear: createReadonlyMethod("clear"),
|
|
771
|
-
forEach: createForEach(true, false)
|
|
772
|
-
};
|
|
773
|
-
const shallowReadonlyInstrumentations2 = {
|
|
774
|
-
get(key) {
|
|
775
|
-
return get(this, key, true, true);
|
|
776
|
-
},
|
|
777
|
-
get size() {
|
|
778
|
-
return size(this, true);
|
|
779
|
-
},
|
|
780
|
-
has(key) {
|
|
781
|
-
return has.call(this, key, true);
|
|
782
|
-
},
|
|
783
|
-
add: createReadonlyMethod("add"),
|
|
784
|
-
set: createReadonlyMethod("set"),
|
|
785
|
-
delete: createReadonlyMethod("delete"),
|
|
786
|
-
clear: createReadonlyMethod("clear"),
|
|
787
|
-
forEach: createForEach(true, true)
|
|
788
|
-
};
|
|
789
|
-
const iteratorMethods = [
|
|
790
|
-
"keys",
|
|
791
|
-
"values",
|
|
792
|
-
"entries",
|
|
793
|
-
Symbol.iterator
|
|
794
|
-
];
|
|
795
|
-
iteratorMethods.forEach((method) => {
|
|
796
|
-
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
|
797
|
-
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
798
|
-
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
799
|
-
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
800
|
-
method,
|
|
801
|
-
true,
|
|
802
|
-
true
|
|
803
|
-
);
|
|
804
|
-
});
|
|
805
|
-
return [
|
|
806
|
-
mutableInstrumentations2,
|
|
807
|
-
readonlyInstrumentations2,
|
|
808
|
-
shallowInstrumentations2,
|
|
809
|
-
shallowReadonlyInstrumentations2
|
|
810
|
-
];
|
|
811
|
-
}
|
|
812
|
-
const [
|
|
813
|
-
mutableInstrumentations,
|
|
814
|
-
readonlyInstrumentations,
|
|
815
|
-
shallowInstrumentations,
|
|
816
|
-
shallowReadonlyInstrumentations
|
|
817
|
-
] = /* @__PURE__ */ createInstrumentations();
|
|
818
|
-
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
819
|
-
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
820
|
-
return (target, key, receiver) => {
|
|
821
|
-
if (key === "__v_isReactive") {
|
|
822
|
-
return !isReadonly2;
|
|
823
|
-
} else if (key === "__v_isReadonly") {
|
|
824
|
-
return isReadonly2;
|
|
825
|
-
} else if (key === "__v_raw") {
|
|
826
|
-
return target;
|
|
827
|
-
}
|
|
828
|
-
return Reflect.get(
|
|
829
|
-
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
830
|
-
key,
|
|
831
|
-
receiver
|
|
832
|
-
);
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
const mutableCollectionHandlers = {
|
|
836
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
837
|
-
};
|
|
838
|
-
const readonlyCollectionHandlers = {
|
|
839
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
840
|
-
};
|
|
841
|
-
const shallowReadonlyCollectionHandlers = {
|
|
842
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
843
|
-
};
|
|
844
|
-
function checkIdentityKeys(target, has2, key) {
|
|
845
|
-
const rawKey = toRaw(key);
|
|
846
|
-
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
847
|
-
const type = toRawType(target);
|
|
848
|
-
warn(
|
|
849
|
-
`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.`
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
854
|
-
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
855
|
-
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
856
|
-
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
857
|
-
function targetTypeMap(rawType) {
|
|
858
|
-
switch (rawType) {
|
|
859
|
-
case "Object":
|
|
860
|
-
case "Array":
|
|
861
|
-
return 1;
|
|
862
|
-
case "Map":
|
|
863
|
-
case "Set":
|
|
864
|
-
case "WeakMap":
|
|
865
|
-
case "WeakSet":
|
|
866
|
-
return 2;
|
|
867
|
-
default:
|
|
868
|
-
return 0;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
function getTargetType(value) {
|
|
872
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
873
|
-
}
|
|
874
|
-
function reactive(target) {
|
|
875
|
-
if (isReadonly(target)) {
|
|
876
|
-
return target;
|
|
877
|
-
}
|
|
878
|
-
return createReactiveObject(
|
|
879
|
-
target,
|
|
880
|
-
false,
|
|
881
|
-
mutableHandlers,
|
|
882
|
-
mutableCollectionHandlers,
|
|
883
|
-
reactiveMap
|
|
884
|
-
);
|
|
885
|
-
}
|
|
886
|
-
function readonly(target) {
|
|
887
|
-
return createReactiveObject(
|
|
888
|
-
target,
|
|
889
|
-
true,
|
|
890
|
-
readonlyHandlers,
|
|
891
|
-
readonlyCollectionHandlers,
|
|
892
|
-
readonlyMap
|
|
893
|
-
);
|
|
894
|
-
}
|
|
895
|
-
function shallowReadonly(target) {
|
|
896
|
-
return createReactiveObject(
|
|
897
|
-
target,
|
|
898
|
-
true,
|
|
899
|
-
shallowReadonlyHandlers,
|
|
900
|
-
shallowReadonlyCollectionHandlers,
|
|
901
|
-
shallowReadonlyMap
|
|
902
|
-
);
|
|
903
|
-
}
|
|
904
|
-
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
905
|
-
if (!isObject(target)) {
|
|
906
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
907
|
-
warn(`value cannot be made reactive: ${String(target)}`);
|
|
908
|
-
}
|
|
909
|
-
return target;
|
|
910
|
-
}
|
|
911
|
-
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
912
|
-
return target;
|
|
913
|
-
}
|
|
914
|
-
const existingProxy = proxyMap.get(target);
|
|
915
|
-
if (existingProxy) {
|
|
916
|
-
return existingProxy;
|
|
917
|
-
}
|
|
918
|
-
const targetType = getTargetType(target);
|
|
919
|
-
if (targetType === 0) {
|
|
920
|
-
return target;
|
|
921
|
-
}
|
|
922
|
-
const proxy = new Proxy(
|
|
923
|
-
target,
|
|
924
|
-
targetType === 2 ? collectionHandlers : baseHandlers
|
|
925
|
-
);
|
|
926
|
-
proxyMap.set(target, proxy);
|
|
927
|
-
return proxy;
|
|
928
|
-
}
|
|
929
|
-
function isReactive(value) {
|
|
930
|
-
if (isReadonly(value)) {
|
|
931
|
-
return isReactive(value["__v_raw"]);
|
|
932
|
-
}
|
|
933
|
-
return !!(value && value["__v_isReactive"]);
|
|
934
|
-
}
|
|
935
|
-
function isReadonly(value) {
|
|
936
|
-
return !!(value && value["__v_isReadonly"]);
|
|
937
|
-
}
|
|
938
|
-
function isShallow(value) {
|
|
939
|
-
return !!(value && value["__v_isShallow"]);
|
|
940
|
-
}
|
|
941
|
-
function isProxy(value) {
|
|
942
|
-
return value ? !!value["__v_raw"] : false;
|
|
943
|
-
}
|
|
944
|
-
function toRaw(observed) {
|
|
945
|
-
const raw = observed && observed["__v_raw"];
|
|
946
|
-
return raw ? toRaw(raw) : observed;
|
|
947
|
-
}
|
|
948
|
-
function markRaw(value) {
|
|
949
|
-
if (Object.isExtensible(value)) {
|
|
950
|
-
def(value, "__v_skip", true);
|
|
951
|
-
}
|
|
952
|
-
return value;
|
|
953
|
-
}
|
|
954
|
-
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
955
|
-
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
956
|
-
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
|
957
|
-
class ComputedRefImpl {
|
|
958
|
-
constructor(getter, _setter, isReadonly2, isSSR) {
|
|
959
|
-
this.getter = getter;
|
|
960
|
-
this._setter = _setter;
|
|
961
|
-
this.dep = void 0;
|
|
962
|
-
this.__v_isRef = true;
|
|
963
|
-
this["__v_isReadonly"] = false;
|
|
964
|
-
this.effect = new ReactiveEffect(
|
|
965
|
-
() => getter(this._value),
|
|
966
|
-
() => triggerRefValue(
|
|
967
|
-
this,
|
|
968
|
-
this.effect._dirtyLevel === 2 ? 2 : 3
|
|
969
|
-
)
|
|
970
|
-
);
|
|
971
|
-
this.effect.computed = this;
|
|
972
|
-
this.effect.active = this._cacheable = !isSSR;
|
|
973
|
-
this["__v_isReadonly"] = isReadonly2;
|
|
974
|
-
}
|
|
975
|
-
get value() {
|
|
976
|
-
const self2 = toRaw(this);
|
|
977
|
-
if ((!self2._cacheable || self2.effect.dirty) && hasChanged(self2._value, self2._value = self2.effect.run())) {
|
|
978
|
-
triggerRefValue(self2, 4);
|
|
979
|
-
}
|
|
980
|
-
trackRefValue(self2);
|
|
981
|
-
if (self2.effect._dirtyLevel >= 2) {
|
|
982
|
-
if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) {
|
|
983
|
-
warn(COMPUTED_SIDE_EFFECT_WARN, `
|
|
984
|
-
|
|
985
|
-
getter: `, this.getter);
|
|
986
|
-
}
|
|
987
|
-
triggerRefValue(self2, 2);
|
|
988
|
-
}
|
|
989
|
-
return self2._value;
|
|
990
|
-
}
|
|
991
|
-
set value(newValue) {
|
|
992
|
-
this._setter(newValue);
|
|
993
|
-
}
|
|
994
|
-
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
|
|
995
|
-
get _dirty() {
|
|
996
|
-
return this.effect.dirty;
|
|
997
|
-
}
|
|
998
|
-
set _dirty(v) {
|
|
999
|
-
this.effect.dirty = v;
|
|
1000
|
-
}
|
|
1001
|
-
// #endregion
|
|
1002
|
-
}
|
|
1003
|
-
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
|
1004
|
-
let getter;
|
|
1005
|
-
let setter;
|
|
1006
|
-
const onlyGetter = isFunction(getterOrOptions);
|
|
1007
|
-
if (onlyGetter) {
|
|
1008
|
-
getter = getterOrOptions;
|
|
1009
|
-
setter = !!(process.env.NODE_ENV !== "production") ? () => {
|
|
1010
|
-
warn("Write operation failed: computed value is readonly");
|
|
1011
|
-
} : NOOP;
|
|
1012
|
-
} else {
|
|
1013
|
-
getter = getterOrOptions.get;
|
|
1014
|
-
setter = getterOrOptions.set;
|
|
1015
|
-
}
|
|
1016
|
-
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1017
|
-
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
|
|
1018
|
-
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1019
|
-
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1020
|
-
}
|
|
1021
|
-
return cRef;
|
|
1022
|
-
}
|
|
1023
|
-
function trackRefValue(ref2) {
|
|
1024
|
-
var _a;
|
|
1025
|
-
if (shouldTrack && activeEffect) {
|
|
1026
|
-
ref2 = toRaw(ref2);
|
|
1027
|
-
trackEffect(
|
|
1028
|
-
activeEffect,
|
|
1029
|
-
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
|
1030
|
-
() => ref2.dep = void 0,
|
|
1031
|
-
ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
|
1032
|
-
),
|
|
1033
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
1034
|
-
target: ref2,
|
|
1035
|
-
type: "get",
|
|
1036
|
-
key: "value"
|
|
1037
|
-
} : void 0
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
|
1042
|
-
ref2 = toRaw(ref2);
|
|
1043
|
-
const dep = ref2.dep;
|
|
1044
|
-
if (dep) {
|
|
1045
|
-
triggerEffects(
|
|
1046
|
-
dep,
|
|
1047
|
-
dirtyLevel,
|
|
1048
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
1049
|
-
target: ref2,
|
|
1050
|
-
type: "set",
|
|
1051
|
-
key: "value",
|
|
1052
|
-
newValue: newVal
|
|
1053
|
-
} : void 0
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
function isRef(r) {
|
|
1058
|
-
return !!(r && r.__v_isRef === true);
|
|
1059
|
-
}
|
|
1060
|
-
function ref(value) {
|
|
1061
|
-
return createRef(value, false);
|
|
1062
|
-
}
|
|
1063
|
-
function createRef(rawValue, shallow) {
|
|
1064
|
-
if (isRef(rawValue)) {
|
|
1065
|
-
return rawValue;
|
|
1066
|
-
}
|
|
1067
|
-
return new RefImpl(rawValue, shallow);
|
|
1068
|
-
}
|
|
1069
|
-
class RefImpl {
|
|
1070
|
-
constructor(value, __v_isShallow) {
|
|
1071
|
-
this.__v_isShallow = __v_isShallow;
|
|
1072
|
-
this.dep = void 0;
|
|
1073
|
-
this.__v_isRef = true;
|
|
1074
|
-
this._rawValue = __v_isShallow ? value : toRaw(value);
|
|
1075
|
-
this._value = __v_isShallow ? value : toReactive(value);
|
|
1076
|
-
}
|
|
1077
|
-
get value() {
|
|
1078
|
-
trackRefValue(this);
|
|
1079
|
-
return this._value;
|
|
1080
|
-
}
|
|
1081
|
-
set value(newVal) {
|
|
1082
|
-
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
|
|
1083
|
-
newVal = useDirectValue ? newVal : toRaw(newVal);
|
|
1084
|
-
if (hasChanged(newVal, this._rawValue)) {
|
|
1085
|
-
this._rawValue = newVal;
|
|
1086
|
-
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1087
|
-
triggerRefValue(this, 4, newVal);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
function unref(ref2) {
|
|
1092
|
-
return isRef(ref2) ? ref2.value : ref2;
|
|
1093
|
-
}
|
|
1094
|
-
const shallowUnwrapHandlers = {
|
|
1095
|
-
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
1096
|
-
set: (target, key, value, receiver) => {
|
|
1097
|
-
const oldValue = target[key];
|
|
1098
|
-
if (isRef(oldValue) && !isRef(value)) {
|
|
1099
|
-
oldValue.value = value;
|
|
1100
|
-
return true;
|
|
1101
|
-
} else {
|
|
1102
|
-
return Reflect.set(target, key, value, receiver);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
function proxyRefs(objectWithRefs) {
|
|
1107
|
-
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* @vue/runtime-core v3.4.23
|
|
1111
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
1112
|
-
* @license MIT
|
|
1113
|
-
**/
|
|
1114
|
-
const stack = [];
|
|
1115
|
-
function pushWarningContext(vnode) {
|
|
1116
|
-
stack.push(vnode);
|
|
1117
|
-
}
|
|
1118
|
-
function popWarningContext() {
|
|
1119
|
-
stack.pop();
|
|
1120
|
-
}
|
|
1121
|
-
function warn$1(msg, ...args) {
|
|
1122
|
-
pauseTracking();
|
|
1123
|
-
const instance = stack.length ? stack[stack.length - 1].component : null;
|
|
1124
|
-
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
1125
|
-
const trace = getComponentTrace();
|
|
1126
|
-
if (appWarnHandler) {
|
|
1127
|
-
callWithErrorHandling(
|
|
1128
|
-
appWarnHandler,
|
|
1129
|
-
instance,
|
|
1130
|
-
11,
|
|
1131
|
-
[
|
|
1132
|
-
msg + args.map((a) => {
|
|
1133
|
-
var _a, _b;
|
|
1134
|
-
return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
|
|
1135
|
-
}).join(""),
|
|
1136
|
-
instance && instance.proxy,
|
|
1137
|
-
trace.map(
|
|
1138
|
-
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
|
1139
|
-
).join("\n"),
|
|
1140
|
-
trace
|
|
1141
|
-
]
|
|
1142
|
-
);
|
|
1143
|
-
} else {
|
|
1144
|
-
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
1145
|
-
if (trace.length && // avoid spamming console during tests
|
|
1146
|
-
true) {
|
|
1147
|
-
warnArgs.push(`
|
|
1148
|
-
`, ...formatTrace(trace));
|
|
1149
|
-
}
|
|
1150
|
-
console.warn(...warnArgs);
|
|
1151
|
-
}
|
|
1152
|
-
resetTracking();
|
|
1153
|
-
}
|
|
1154
|
-
function getComponentTrace() {
|
|
1155
|
-
let currentVNode = stack[stack.length - 1];
|
|
1156
|
-
if (!currentVNode) {
|
|
1157
|
-
return [];
|
|
1158
|
-
}
|
|
1159
|
-
const normalizedStack = [];
|
|
1160
|
-
while (currentVNode) {
|
|
1161
|
-
const last = normalizedStack[0];
|
|
1162
|
-
if (last && last.vnode === currentVNode) {
|
|
1163
|
-
last.recurseCount++;
|
|
1164
|
-
} else {
|
|
1165
|
-
normalizedStack.push({
|
|
1166
|
-
vnode: currentVNode,
|
|
1167
|
-
recurseCount: 0
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
1171
|
-
currentVNode = parentInstance && parentInstance.vnode;
|
|
1172
|
-
}
|
|
1173
|
-
return normalizedStack;
|
|
1174
|
-
}
|
|
1175
|
-
function formatTrace(trace) {
|
|
1176
|
-
const logs = [];
|
|
1177
|
-
trace.forEach((entry, i) => {
|
|
1178
|
-
logs.push(...i === 0 ? [] : [`
|
|
1179
|
-
`], ...formatTraceEntry(entry));
|
|
1180
|
-
});
|
|
1181
|
-
return logs;
|
|
1182
|
-
}
|
|
1183
|
-
function formatTraceEntry({ vnode, recurseCount }) {
|
|
1184
|
-
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
1185
|
-
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
1186
|
-
const open = ` at <${formatComponentName(
|
|
1187
|
-
vnode.component,
|
|
1188
|
-
vnode.type,
|
|
1189
|
-
isRoot
|
|
1190
|
-
)}`;
|
|
1191
|
-
const close = `>` + postfix;
|
|
1192
|
-
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
|
1193
|
-
}
|
|
1194
|
-
function formatProps(props) {
|
|
1195
|
-
const res = [];
|
|
1196
|
-
const keys = Object.keys(props);
|
|
1197
|
-
keys.slice(0, 3).forEach((key) => {
|
|
1198
|
-
res.push(...formatProp(key, props[key]));
|
|
1199
|
-
});
|
|
1200
|
-
if (keys.length > 3) {
|
|
1201
|
-
res.push(` ...`);
|
|
1202
|
-
}
|
|
1203
|
-
return res;
|
|
1204
|
-
}
|
|
1205
|
-
function formatProp(key, value, raw) {
|
|
1206
|
-
if (isString(value)) {
|
|
1207
|
-
value = JSON.stringify(value);
|
|
1208
|
-
return raw ? value : [`${key}=${value}`];
|
|
1209
|
-
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
1210
|
-
return raw ? value : [`${key}=${value}`];
|
|
1211
|
-
} else if (isRef(value)) {
|
|
1212
|
-
value = formatProp(key, toRaw(value.value), true);
|
|
1213
|
-
return raw ? value : [`${key}=Ref<`, value, `>`];
|
|
1214
|
-
} else if (isFunction(value)) {
|
|
1215
|
-
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
1216
|
-
} else {
|
|
1217
|
-
value = toRaw(value);
|
|
1218
|
-
return raw ? value : [`${key}=`, value];
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
const ErrorTypeStrings$1 = {
|
|
1222
|
-
["sp"]: "serverPrefetch hook",
|
|
1223
|
-
["bc"]: "beforeCreate hook",
|
|
1224
|
-
["c"]: "created hook",
|
|
1225
|
-
["bm"]: "beforeMount hook",
|
|
1226
|
-
["m"]: "mounted hook",
|
|
1227
|
-
["bu"]: "beforeUpdate hook",
|
|
1228
|
-
["u"]: "updated",
|
|
1229
|
-
["bum"]: "beforeUnmount hook",
|
|
1230
|
-
["um"]: "unmounted hook",
|
|
1231
|
-
["a"]: "activated hook",
|
|
1232
|
-
["da"]: "deactivated hook",
|
|
1233
|
-
["ec"]: "errorCaptured hook",
|
|
1234
|
-
["rtc"]: "renderTracked hook",
|
|
1235
|
-
["rtg"]: "renderTriggered hook",
|
|
1236
|
-
[0]: "setup function",
|
|
1237
|
-
[1]: "render function",
|
|
1238
|
-
[2]: "watcher getter",
|
|
1239
|
-
[3]: "watcher callback",
|
|
1240
|
-
[4]: "watcher cleanup function",
|
|
1241
|
-
[5]: "native event handler",
|
|
1242
|
-
[6]: "component event handler",
|
|
1243
|
-
[7]: "vnode hook",
|
|
1244
|
-
[8]: "directive hook",
|
|
1245
|
-
[9]: "transition hook",
|
|
1246
|
-
[10]: "app errorHandler",
|
|
1247
|
-
[11]: "app warnHandler",
|
|
1248
|
-
[12]: "ref function",
|
|
1249
|
-
[13]: "async component loader",
|
|
1250
|
-
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
|
1251
|
-
};
|
|
1252
|
-
function callWithErrorHandling(fn, instance, type, args) {
|
|
1253
|
-
try {
|
|
1254
|
-
return args ? fn(...args) : fn();
|
|
1255
|
-
} catch (err) {
|
|
1256
|
-
handleError(err, instance, type);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
1260
|
-
if (isFunction(fn)) {
|
|
1261
|
-
const res = callWithErrorHandling(fn, instance, type, args);
|
|
1262
|
-
if (res && isPromise(res)) {
|
|
1263
|
-
res.catch((err) => {
|
|
1264
|
-
handleError(err, instance, type);
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
return res;
|
|
1268
|
-
}
|
|
1269
|
-
if (isArray(fn)) {
|
|
1270
|
-
const values = [];
|
|
1271
|
-
for (let i = 0; i < fn.length; i++) {
|
|
1272
|
-
values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
|
1273
|
-
}
|
|
1274
|
-
return values;
|
|
1275
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1276
|
-
warn$1(
|
|
1277
|
-
`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
|
1278
|
-
);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
function handleError(err, instance, type, throwInDev = true) {
|
|
1282
|
-
const contextVNode = instance ? instance.vnode : null;
|
|
1283
|
-
if (instance) {
|
|
1284
|
-
let cur = instance.parent;
|
|
1285
|
-
const exposedInstance = instance.proxy;
|
|
1286
|
-
const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : `https://vuejs.org/error-reference/#runtime-${type}`;
|
|
1287
|
-
while (cur) {
|
|
1288
|
-
const errorCapturedHooks = cur.ec;
|
|
1289
|
-
if (errorCapturedHooks) {
|
|
1290
|
-
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
1291
|
-
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
1292
|
-
return;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
cur = cur.parent;
|
|
1297
|
-
}
|
|
1298
|
-
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
1299
|
-
if (appErrorHandler) {
|
|
1300
|
-
pauseTracking();
|
|
1301
|
-
callWithErrorHandling(
|
|
1302
|
-
appErrorHandler,
|
|
1303
|
-
null,
|
|
1304
|
-
10,
|
|
1305
|
-
[err, exposedInstance, errorInfo]
|
|
1306
|
-
);
|
|
1307
|
-
resetTracking();
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
logError(err, type, contextVNode, throwInDev);
|
|
1312
|
-
}
|
|
1313
|
-
function logError(err, type, contextVNode, throwInDev = true) {
|
|
1314
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1315
|
-
const info = ErrorTypeStrings$1[type];
|
|
1316
|
-
if (contextVNode) {
|
|
1317
|
-
pushWarningContext(contextVNode);
|
|
1318
|
-
}
|
|
1319
|
-
warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
1320
|
-
if (contextVNode) {
|
|
1321
|
-
popWarningContext();
|
|
1322
|
-
}
|
|
1323
|
-
if (throwInDev) {
|
|
1324
|
-
throw err;
|
|
1325
|
-
} else {
|
|
1326
|
-
console.error(err);
|
|
1327
|
-
}
|
|
1328
|
-
} else {
|
|
1329
|
-
console.error(err);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
let isFlushing = false;
|
|
1333
|
-
let isFlushPending = false;
|
|
1334
|
-
const queue = [];
|
|
1335
|
-
let flushIndex = 0;
|
|
1336
|
-
const pendingPostFlushCbs = [];
|
|
1337
|
-
let activePostFlushCbs = null;
|
|
1338
|
-
let postFlushIndex = 0;
|
|
1339
|
-
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
1340
|
-
let currentFlushPromise = null;
|
|
1341
|
-
const RECURSION_LIMIT = 100;
|
|
1342
|
-
function nextTick(fn) {
|
|
1343
|
-
const p = currentFlushPromise || resolvedPromise;
|
|
1344
|
-
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
1345
|
-
}
|
|
1346
|
-
function findInsertionIndex(id) {
|
|
1347
|
-
let start = flushIndex + 1;
|
|
1348
|
-
let end = queue.length;
|
|
1349
|
-
while (start < end) {
|
|
1350
|
-
const middle = start + end >>> 1;
|
|
1351
|
-
const middleJob = queue[middle];
|
|
1352
|
-
const middleJobId = getId(middleJob);
|
|
1353
|
-
if (middleJobId < id || middleJobId === id && middleJob.pre) {
|
|
1354
|
-
start = middle + 1;
|
|
1355
|
-
} else {
|
|
1356
|
-
end = middle;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
return start;
|
|
1360
|
-
}
|
|
1361
|
-
function queueJob(job) {
|
|
1362
|
-
if (!queue.length || !queue.includes(
|
|
1363
|
-
job,
|
|
1364
|
-
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
|
1365
|
-
)) {
|
|
1366
|
-
if (job.id == null) {
|
|
1367
|
-
queue.push(job);
|
|
1368
|
-
} else {
|
|
1369
|
-
queue.splice(findInsertionIndex(job.id), 0, job);
|
|
1370
|
-
}
|
|
1371
|
-
queueFlush();
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
function queueFlush() {
|
|
1375
|
-
if (!isFlushing && !isFlushPending) {
|
|
1376
|
-
isFlushPending = true;
|
|
1377
|
-
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
function queuePostFlushCb(cb) {
|
|
1381
|
-
if (!isArray(cb)) {
|
|
1382
|
-
if (!activePostFlushCbs || !activePostFlushCbs.includes(
|
|
1383
|
-
cb,
|
|
1384
|
-
cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
|
|
1385
|
-
)) {
|
|
1386
|
-
pendingPostFlushCbs.push(cb);
|
|
1387
|
-
}
|
|
1388
|
-
} else {
|
|
1389
|
-
pendingPostFlushCbs.push(...cb);
|
|
1390
|
-
}
|
|
1391
|
-
queueFlush();
|
|
1392
|
-
}
|
|
1393
|
-
function flushPostFlushCbs(seen) {
|
|
1394
|
-
if (pendingPostFlushCbs.length) {
|
|
1395
|
-
const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
|
1396
|
-
(a, b) => getId(a) - getId(b)
|
|
1397
|
-
);
|
|
1398
|
-
pendingPostFlushCbs.length = 0;
|
|
1399
|
-
if (activePostFlushCbs) {
|
|
1400
|
-
activePostFlushCbs.push(...deduped);
|
|
1401
|
-
return;
|
|
1402
|
-
}
|
|
1403
|
-
activePostFlushCbs = deduped;
|
|
1404
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1405
|
-
seen = seen || /* @__PURE__ */ new Map();
|
|
1406
|
-
}
|
|
1407
|
-
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
|
1408
|
-
if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
|
1409
|
-
continue;
|
|
1410
|
-
}
|
|
1411
|
-
activePostFlushCbs[postFlushIndex]();
|
|
1412
|
-
}
|
|
1413
|
-
activePostFlushCbs = null;
|
|
1414
|
-
postFlushIndex = 0;
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
const getId = (job) => job.id == null ? Infinity : job.id;
|
|
1418
|
-
const comparator = (a, b) => {
|
|
1419
|
-
const diff = getId(a) - getId(b);
|
|
1420
|
-
if (diff === 0) {
|
|
1421
|
-
if (a.pre && !b.pre)
|
|
1422
|
-
return -1;
|
|
1423
|
-
if (b.pre && !a.pre)
|
|
1424
|
-
return 1;
|
|
1425
|
-
}
|
|
1426
|
-
return diff;
|
|
1427
|
-
};
|
|
1428
|
-
function flushJobs(seen) {
|
|
1429
|
-
isFlushPending = false;
|
|
1430
|
-
isFlushing = true;
|
|
1431
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1432
|
-
seen = seen || /* @__PURE__ */ new Map();
|
|
1433
|
-
}
|
|
1434
|
-
queue.sort(comparator);
|
|
1435
|
-
const check = !!(process.env.NODE_ENV !== "production") ? (job) => checkRecursiveUpdates(seen, job) : NOOP;
|
|
1436
|
-
try {
|
|
1437
|
-
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
1438
|
-
const job = queue[flushIndex];
|
|
1439
|
-
if (job && job.active !== false) {
|
|
1440
|
-
if (!!(process.env.NODE_ENV !== "production") && check(job)) {
|
|
1441
|
-
continue;
|
|
1442
|
-
}
|
|
1443
|
-
callWithErrorHandling(job, null, 14);
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
} finally {
|
|
1447
|
-
flushIndex = 0;
|
|
1448
|
-
queue.length = 0;
|
|
1449
|
-
flushPostFlushCbs(seen);
|
|
1450
|
-
isFlushing = false;
|
|
1451
|
-
currentFlushPromise = null;
|
|
1452
|
-
if (queue.length || pendingPostFlushCbs.length) {
|
|
1453
|
-
flushJobs(seen);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
function checkRecursiveUpdates(seen, fn) {
|
|
1458
|
-
if (!seen.has(fn)) {
|
|
1459
|
-
seen.set(fn, 1);
|
|
1460
|
-
} else {
|
|
1461
|
-
const count = seen.get(fn);
|
|
1462
|
-
if (count > RECURSION_LIMIT) {
|
|
1463
|
-
const instance = fn.ownerInstance;
|
|
1464
|
-
const componentName = instance && getComponentName(instance.type);
|
|
1465
|
-
handleError(
|
|
1466
|
-
`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.`,
|
|
1467
|
-
null,
|
|
1468
|
-
10
|
|
1469
|
-
);
|
|
1470
|
-
return true;
|
|
1471
|
-
} else {
|
|
1472
|
-
seen.set(fn, count + 1);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
const hmrDirtyComponents = /* @__PURE__ */ new Set();
|
|
1477
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1478
|
-
getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
|
1479
|
-
createRecord: tryWrap(createRecord),
|
|
1480
|
-
rerender: tryWrap(rerender),
|
|
1481
|
-
reload: tryWrap(reload)
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
|
-
const map = /* @__PURE__ */ new Map();
|
|
1485
|
-
function createRecord(id, initialDef) {
|
|
1486
|
-
if (map.has(id)) {
|
|
1487
|
-
return false;
|
|
1488
|
-
}
|
|
1489
|
-
map.set(id, {
|
|
1490
|
-
initialDef: normalizeClassComponent(initialDef),
|
|
1491
|
-
instances: /* @__PURE__ */ new Set()
|
|
1492
|
-
});
|
|
1493
|
-
return true;
|
|
1494
|
-
}
|
|
1495
|
-
function normalizeClassComponent(component2) {
|
|
1496
|
-
return isClassComponent(component2) ? component2.__vccOpts : component2;
|
|
1497
|
-
}
|
|
1498
|
-
function rerender(id, newRender) {
|
|
1499
|
-
const record = map.get(id);
|
|
1500
|
-
if (!record) {
|
|
1501
|
-
return;
|
|
1502
|
-
}
|
|
1503
|
-
record.initialDef.render = newRender;
|
|
1504
|
-
[...record.instances].forEach((instance) => {
|
|
1505
|
-
if (newRender) {
|
|
1506
|
-
instance.render = newRender;
|
|
1507
|
-
normalizeClassComponent(instance.type).render = newRender;
|
|
1508
|
-
}
|
|
1509
|
-
instance.renderCache = [];
|
|
1510
|
-
instance.effect.dirty = true;
|
|
1511
|
-
instance.update();
|
|
1512
|
-
});
|
|
1513
|
-
}
|
|
1514
|
-
function reload(id, newComp) {
|
|
1515
|
-
const record = map.get(id);
|
|
1516
|
-
if (!record)
|
|
1517
|
-
return;
|
|
1518
|
-
newComp = normalizeClassComponent(newComp);
|
|
1519
|
-
updateComponentDef(record.initialDef, newComp);
|
|
1520
|
-
const instances = [...record.instances];
|
|
1521
|
-
for (const instance of instances) {
|
|
1522
|
-
const oldComp = normalizeClassComponent(instance.type);
|
|
1523
|
-
if (!hmrDirtyComponents.has(oldComp)) {
|
|
1524
|
-
if (oldComp !== record.initialDef) {
|
|
1525
|
-
updateComponentDef(oldComp, newComp);
|
|
1526
|
-
}
|
|
1527
|
-
hmrDirtyComponents.add(oldComp);
|
|
1528
|
-
}
|
|
1529
|
-
instance.appContext.propsCache.delete(instance.type);
|
|
1530
|
-
instance.appContext.emitsCache.delete(instance.type);
|
|
1531
|
-
instance.appContext.optionsCache.delete(instance.type);
|
|
1532
|
-
if (instance.ceReload) {
|
|
1533
|
-
hmrDirtyComponents.add(oldComp);
|
|
1534
|
-
instance.ceReload(newComp.styles);
|
|
1535
|
-
hmrDirtyComponents.delete(oldComp);
|
|
1536
|
-
} else if (instance.parent) {
|
|
1537
|
-
instance.parent.effect.dirty = true;
|
|
1538
|
-
queueJob(instance.parent.update);
|
|
1539
|
-
} else if (instance.appContext.reload) {
|
|
1540
|
-
instance.appContext.reload();
|
|
1541
|
-
} else if (typeof window !== "undefined") {
|
|
1542
|
-
window.location.reload();
|
|
1543
|
-
} else {
|
|
1544
|
-
console.warn(
|
|
1545
|
-
"[HMR] Root or manually mounted instance modified. Full reload required."
|
|
1546
|
-
);
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
queuePostFlushCb(() => {
|
|
1550
|
-
for (const instance of instances) {
|
|
1551
|
-
hmrDirtyComponents.delete(
|
|
1552
|
-
normalizeClassComponent(instance.type)
|
|
1553
|
-
);
|
|
1554
|
-
}
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
function updateComponentDef(oldComp, newComp) {
|
|
1558
|
-
extend(oldComp, newComp);
|
|
1559
|
-
for (const key in oldComp) {
|
|
1560
|
-
if (key !== "__file" && !(key in newComp)) {
|
|
1561
|
-
delete oldComp[key];
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
function tryWrap(fn) {
|
|
1566
|
-
return (id, arg) => {
|
|
1567
|
-
try {
|
|
1568
|
-
return fn(id, arg);
|
|
1569
|
-
} catch (e) {
|
|
1570
|
-
console.error(e);
|
|
1571
|
-
console.warn(
|
|
1572
|
-
`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
|
1573
|
-
);
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
}
|
|
1577
|
-
let devtools$1;
|
|
1578
|
-
let buffer = [];
|
|
1579
|
-
function setDevtoolsHook$1(hook, target) {
|
|
1580
|
-
var _a, _b;
|
|
1581
|
-
devtools$1 = hook;
|
|
1582
|
-
if (devtools$1) {
|
|
1583
|
-
devtools$1.enabled = true;
|
|
1584
|
-
buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
|
1585
|
-
buffer = [];
|
|
1586
|
-
} else if (
|
|
1587
|
-
// handle late devtools injection - only do this if we are in an actual
|
|
1588
|
-
// browser environment to avoid the timer handle stalling test runner exit
|
|
1589
|
-
// (#4815)
|
|
1590
|
-
typeof window !== "undefined" && // some envs mock window but not fully
|
|
1591
|
-
window.HTMLElement && // also exclude jsdom
|
|
1592
|
-
!((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
|
1593
|
-
) {
|
|
1594
|
-
const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
|
1595
|
-
replay.push((newHook) => {
|
|
1596
|
-
setDevtoolsHook$1(newHook, target);
|
|
1597
|
-
});
|
|
1598
|
-
setTimeout(() => {
|
|
1599
|
-
if (!devtools$1) {
|
|
1600
|
-
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
|
1601
|
-
buffer = [];
|
|
1602
|
-
}
|
|
1603
|
-
}, 3e3);
|
|
1604
|
-
} else {
|
|
1605
|
-
buffer = [];
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
let currentRenderingInstance = null;
|
|
1609
|
-
let currentScopeId = null;
|
|
1610
|
-
function markAttrsAccessed() {
|
|
1611
|
-
}
|
|
1612
|
-
const COMPONENTS = "components";
|
|
1613
|
-
function resolveComponent(name, maybeSelfReference) {
|
|
1614
|
-
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
|
1615
|
-
}
|
|
1616
|
-
const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
|
1617
|
-
function resolveDynamicComponent(component2) {
|
|
1618
|
-
if (isString(component2)) {
|
|
1619
|
-
return resolveAsset(COMPONENTS, component2, false) || component2;
|
|
1620
|
-
} else {
|
|
1621
|
-
return component2 || NULL_DYNAMIC_COMPONENT;
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
|
1625
|
-
const instance = currentInstance;
|
|
1626
|
-
if (instance) {
|
|
1627
|
-
const Component = instance.type;
|
|
1628
|
-
if (type === COMPONENTS) {
|
|
1629
|
-
const selfName = getComponentName(
|
|
1630
|
-
Component,
|
|
1631
|
-
false
|
|
1632
|
-
);
|
|
1633
|
-
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
|
1634
|
-
return Component;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
const res = (
|
|
1638
|
-
// local registration
|
|
1639
|
-
// check instance[type] first which is resolved for options API
|
|
1640
|
-
resolve(instance[type] || Component[type], name) || // global registration
|
|
1641
|
-
resolve(instance.appContext[type], name)
|
|
1642
|
-
);
|
|
1643
|
-
if (!res && maybeSelfReference) {
|
|
1644
|
-
return Component;
|
|
1645
|
-
}
|
|
1646
|
-
if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
|
|
1647
|
-
const extra = type === COMPONENTS ? `
|
|
1648
|
-
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
|
1649
|
-
warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
|
1650
|
-
}
|
|
1651
|
-
return res;
|
|
1652
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1653
|
-
warn$1(
|
|
1654
|
-
`resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
|
1655
|
-
);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
function resolve(registry, name) {
|
|
1659
|
-
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
|
1660
|
-
}
|
|
1661
|
-
const isSuspense = (type) => type.__isSuspense;
|
|
1662
|
-
function queueEffectWithSuspense(fn, suspense) {
|
|
1663
|
-
if (suspense && suspense.pendingBranch) {
|
|
1664
|
-
if (isArray(fn)) {
|
|
1665
|
-
suspense.effects.push(...fn);
|
|
1666
|
-
} else {
|
|
1667
|
-
suspense.effects.push(fn);
|
|
1668
|
-
}
|
|
1669
|
-
} else {
|
|
1670
|
-
queuePostFlushCb(fn);
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
const ssrContextKey = Symbol.for("v-scx");
|
|
1674
|
-
const useSSRContext = () => {
|
|
1675
|
-
{
|
|
1676
|
-
const ctx = inject(ssrContextKey);
|
|
1677
|
-
if (!ctx) {
|
|
1678
|
-
!!(process.env.NODE_ENV !== "production") && warn$1(
|
|
1679
|
-
`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
|
|
1680
|
-
);
|
|
1681
|
-
}
|
|
1682
|
-
return ctx;
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
const INITIAL_WATCHER_VALUE = {};
|
|
1686
|
-
function watch(source, cb, options) {
|
|
1687
|
-
if (!!(process.env.NODE_ENV !== "production") && !isFunction(cb)) {
|
|
1688
|
-
warn$1(
|
|
1689
|
-
`\`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.`
|
|
1690
|
-
);
|
|
1691
|
-
}
|
|
1692
|
-
return doWatch(source, cb, options);
|
|
1693
|
-
}
|
|
1694
|
-
function doWatch(source, cb, {
|
|
1695
|
-
immediate,
|
|
1696
|
-
deep,
|
|
1697
|
-
flush,
|
|
1698
|
-
once,
|
|
1699
|
-
onTrack,
|
|
1700
|
-
onTrigger
|
|
1701
|
-
} = EMPTY_OBJ) {
|
|
1702
|
-
if (cb && once) {
|
|
1703
|
-
const _cb = cb;
|
|
1704
|
-
cb = (...args) => {
|
|
1705
|
-
_cb(...args);
|
|
1706
|
-
unwatch();
|
|
1707
|
-
};
|
|
1708
|
-
}
|
|
1709
|
-
if (!!(process.env.NODE_ENV !== "production") && deep !== void 0 && typeof deep === "number") {
|
|
1710
|
-
warn$1(
|
|
1711
|
-
`watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
|
|
1712
|
-
);
|
|
1713
|
-
}
|
|
1714
|
-
if (!!(process.env.NODE_ENV !== "production") && !cb) {
|
|
1715
|
-
if (immediate !== void 0) {
|
|
1716
|
-
warn$1(
|
|
1717
|
-
`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1718
|
-
);
|
|
1719
|
-
}
|
|
1720
|
-
if (deep !== void 0) {
|
|
1721
|
-
warn$1(
|
|
1722
|
-
`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1723
|
-
);
|
|
1724
|
-
}
|
|
1725
|
-
if (once !== void 0) {
|
|
1726
|
-
warn$1(
|
|
1727
|
-
`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
|
1728
|
-
);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
const warnInvalidSource = (s) => {
|
|
1732
|
-
warn$1(
|
|
1733
|
-
`Invalid watch source: `,
|
|
1734
|
-
s,
|
|
1735
|
-
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
1736
|
-
);
|
|
1737
|
-
};
|
|
1738
|
-
const instance = currentInstance;
|
|
1739
|
-
const reactiveGetter = (source2) => deep === true ? source2 : (
|
|
1740
|
-
// for deep: false, only traverse root-level properties
|
|
1741
|
-
traverse(source2, deep === false ? 1 : void 0)
|
|
1742
|
-
);
|
|
1743
|
-
let getter;
|
|
1744
|
-
let forceTrigger = false;
|
|
1745
|
-
let isMultiSource = false;
|
|
1746
|
-
if (isRef(source)) {
|
|
1747
|
-
getter = () => source.value;
|
|
1748
|
-
forceTrigger = isShallow(source);
|
|
1749
|
-
} else if (isReactive(source)) {
|
|
1750
|
-
getter = () => reactiveGetter(source);
|
|
1751
|
-
forceTrigger = true;
|
|
1752
|
-
} else if (isArray(source)) {
|
|
1753
|
-
isMultiSource = true;
|
|
1754
|
-
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1755
|
-
getter = () => source.map((s) => {
|
|
1756
|
-
if (isRef(s)) {
|
|
1757
|
-
return s.value;
|
|
1758
|
-
} else if (isReactive(s)) {
|
|
1759
|
-
return reactiveGetter(s);
|
|
1760
|
-
} else if (isFunction(s)) {
|
|
1761
|
-
return callWithErrorHandling(s, instance, 2);
|
|
1762
|
-
} else {
|
|
1763
|
-
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
|
|
1764
|
-
}
|
|
1765
|
-
});
|
|
1766
|
-
} else if (isFunction(source)) {
|
|
1767
|
-
if (cb) {
|
|
1768
|
-
getter = () => callWithErrorHandling(source, instance, 2);
|
|
1769
|
-
} else {
|
|
1770
|
-
getter = () => {
|
|
1771
|
-
if (cleanup) {
|
|
1772
|
-
cleanup();
|
|
1773
|
-
}
|
|
1774
|
-
return callWithAsyncErrorHandling(
|
|
1775
|
-
source,
|
|
1776
|
-
instance,
|
|
1777
|
-
3,
|
|
1778
|
-
[onCleanup]
|
|
1779
|
-
);
|
|
1780
|
-
};
|
|
1781
|
-
}
|
|
1782
|
-
} else {
|
|
1783
|
-
getter = NOOP;
|
|
1784
|
-
!!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
|
|
1785
|
-
}
|
|
1786
|
-
if (cb && deep) {
|
|
1787
|
-
const baseGetter = getter;
|
|
1788
|
-
getter = () => traverse(baseGetter());
|
|
1789
|
-
}
|
|
1790
|
-
let cleanup;
|
|
1791
|
-
let onCleanup = (fn) => {
|
|
1792
|
-
cleanup = effect2.onStop = () => {
|
|
1793
|
-
callWithErrorHandling(fn, instance, 4);
|
|
1794
|
-
cleanup = effect2.onStop = void 0;
|
|
1795
|
-
};
|
|
1796
|
-
};
|
|
1797
|
-
let ssrCleanup;
|
|
1798
|
-
if (isInSSRComponentSetup) {
|
|
1799
|
-
onCleanup = NOOP;
|
|
1800
|
-
if (!cb) {
|
|
1801
|
-
getter();
|
|
1802
|
-
} else if (immediate) {
|
|
1803
|
-
callWithAsyncErrorHandling(cb, instance, 3, [
|
|
1804
|
-
getter(),
|
|
1805
|
-
isMultiSource ? [] : void 0,
|
|
1806
|
-
onCleanup
|
|
1807
|
-
]);
|
|
1808
|
-
}
|
|
1809
|
-
if (flush === "sync") {
|
|
1810
|
-
const ctx = useSSRContext();
|
|
1811
|
-
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
|
|
1812
|
-
} else {
|
|
1813
|
-
return NOOP;
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1817
|
-
const job = () => {
|
|
1818
|
-
if (!effect2.active || !effect2.dirty) {
|
|
1819
|
-
return;
|
|
1820
|
-
}
|
|
1821
|
-
if (cb) {
|
|
1822
|
-
const newValue = effect2.run();
|
|
1823
|
-
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
|
|
1824
|
-
if (cleanup) {
|
|
1825
|
-
cleanup();
|
|
1826
|
-
}
|
|
1827
|
-
callWithAsyncErrorHandling(cb, instance, 3, [
|
|
1828
|
-
newValue,
|
|
1829
|
-
// pass undefined as the old value when it's changed for the first time
|
|
1830
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1831
|
-
onCleanup
|
|
1832
|
-
]);
|
|
1833
|
-
oldValue = newValue;
|
|
1834
|
-
}
|
|
1835
|
-
} else {
|
|
1836
|
-
effect2.run();
|
|
1837
|
-
}
|
|
1838
|
-
};
|
|
1839
|
-
job.allowRecurse = !!cb;
|
|
1840
|
-
let scheduler;
|
|
1841
|
-
if (flush === "sync") {
|
|
1842
|
-
scheduler = job;
|
|
1843
|
-
} else if (flush === "post") {
|
|
1844
|
-
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
|
1845
|
-
} else {
|
|
1846
|
-
job.pre = true;
|
|
1847
|
-
if (instance)
|
|
1848
|
-
job.id = instance.uid;
|
|
1849
|
-
scheduler = () => queueJob(job);
|
|
1850
|
-
}
|
|
1851
|
-
const effect2 = new ReactiveEffect(getter, NOOP, scheduler);
|
|
1852
|
-
const unwatch = () => {
|
|
1853
|
-
effect2.stop();
|
|
1854
|
-
};
|
|
1855
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1856
|
-
effect2.onTrack = onTrack;
|
|
1857
|
-
effect2.onTrigger = onTrigger;
|
|
1858
|
-
}
|
|
1859
|
-
if (cb) {
|
|
1860
|
-
if (immediate) {
|
|
1861
|
-
job();
|
|
1862
|
-
} else {
|
|
1863
|
-
oldValue = effect2.run();
|
|
1864
|
-
}
|
|
1865
|
-
} else if (flush === "post") {
|
|
1866
|
-
queuePostRenderEffect(
|
|
1867
|
-
effect2.run.bind(effect2),
|
|
1868
|
-
instance && instance.suspense
|
|
1869
|
-
);
|
|
1870
|
-
} else {
|
|
1871
|
-
effect2.run();
|
|
1872
|
-
}
|
|
1873
|
-
if (ssrCleanup)
|
|
1874
|
-
ssrCleanup.push(unwatch);
|
|
1875
|
-
return unwatch;
|
|
1876
|
-
}
|
|
1877
|
-
function instanceWatch(source, value, options) {
|
|
1878
|
-
const publicThis = this.proxy;
|
|
1879
|
-
const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
|
1880
|
-
let cb;
|
|
1881
|
-
if (isFunction(value)) {
|
|
1882
|
-
cb = value;
|
|
1883
|
-
} else {
|
|
1884
|
-
cb = value.handler;
|
|
1885
|
-
options = value;
|
|
1886
|
-
}
|
|
1887
|
-
const reset = setCurrentInstance(this);
|
|
1888
|
-
const res = doWatch(getter, cb.bind(publicThis), options);
|
|
1889
|
-
reset();
|
|
1890
|
-
return res;
|
|
1891
|
-
}
|
|
1892
|
-
function createPathGetter(ctx, path2) {
|
|
1893
|
-
const segments = path2.split(".");
|
|
1894
|
-
return () => {
|
|
1895
|
-
let cur = ctx;
|
|
1896
|
-
for (let i = 0; i < segments.length && cur; i++) {
|
|
1897
|
-
cur = cur[segments[i]];
|
|
1898
|
-
}
|
|
1899
|
-
return cur;
|
|
1900
|
-
};
|
|
1901
|
-
}
|
|
1902
|
-
function traverse(value, depth, currentDepth = 0, seen) {
|
|
1903
|
-
if (!isObject(value) || value["__v_skip"]) {
|
|
1904
|
-
return value;
|
|
1905
|
-
}
|
|
1906
|
-
if (depth && depth > 0) {
|
|
1907
|
-
if (currentDepth >= depth) {
|
|
1908
|
-
return value;
|
|
1909
|
-
}
|
|
1910
|
-
currentDepth++;
|
|
1911
|
-
}
|
|
1912
|
-
seen = seen || /* @__PURE__ */ new Set();
|
|
1913
|
-
if (seen.has(value)) {
|
|
1914
|
-
return value;
|
|
1915
|
-
}
|
|
1916
|
-
seen.add(value);
|
|
1917
|
-
if (isRef(value)) {
|
|
1918
|
-
traverse(value.value, depth, currentDepth, seen);
|
|
1919
|
-
} else if (isArray(value)) {
|
|
1920
|
-
for (let i = 0; i < value.length; i++) {
|
|
1921
|
-
traverse(value[i], depth, currentDepth, seen);
|
|
1922
|
-
}
|
|
1923
|
-
} else if (isSet(value) || isMap(value)) {
|
|
1924
|
-
value.forEach((v) => {
|
|
1925
|
-
traverse(v, depth, currentDepth, seen);
|
|
1926
|
-
});
|
|
1927
|
-
} else if (isPlainObject(value)) {
|
|
1928
|
-
for (const key in value) {
|
|
1929
|
-
traverse(value[key], depth, currentDepth, seen);
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
return value;
|
|
1933
|
-
}
|
|
1934
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
1935
|
-
// @__NO_SIDE_EFFECTS__
|
|
1936
|
-
function defineComponent(options, extraOptions) {
|
|
1937
|
-
return isFunction(options) ? (
|
|
1938
|
-
// #8326: extend call and options.name access are considered side-effects
|
|
1939
|
-
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
|
1940
|
-
/* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
|
|
1941
|
-
) : options;
|
|
1942
|
-
}
|
|
1943
|
-
const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
|
1944
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
1945
|
-
// @__NO_SIDE_EFFECTS__
|
|
1946
|
-
function defineAsyncComponent(source) {
|
|
1947
|
-
if (isFunction(source)) {
|
|
1948
|
-
source = { loader: source };
|
|
1949
|
-
}
|
|
1950
|
-
const {
|
|
1951
|
-
loader,
|
|
1952
|
-
loadingComponent,
|
|
1953
|
-
errorComponent,
|
|
1954
|
-
delay = 200,
|
|
1955
|
-
timeout,
|
|
1956
|
-
// undefined = never times out
|
|
1957
|
-
suspensible = true,
|
|
1958
|
-
onError: userOnError
|
|
1959
|
-
} = source;
|
|
1960
|
-
let pendingRequest = null;
|
|
1961
|
-
let resolvedComp;
|
|
1962
|
-
let retries = 0;
|
|
1963
|
-
const retry = () => {
|
|
1964
|
-
retries++;
|
|
1965
|
-
pendingRequest = null;
|
|
1966
|
-
return load();
|
|
1967
|
-
};
|
|
1968
|
-
const load = () => {
|
|
1969
|
-
let thisRequest;
|
|
1970
|
-
return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
|
1971
|
-
err = err instanceof Error ? err : new Error(String(err));
|
|
1972
|
-
if (userOnError) {
|
|
1973
|
-
return new Promise((resolve2, reject) => {
|
|
1974
|
-
const userRetry = () => resolve2(retry());
|
|
1975
|
-
const userFail = () => reject(err);
|
|
1976
|
-
userOnError(err, userRetry, userFail, retries + 1);
|
|
1977
|
-
});
|
|
1978
|
-
} else {
|
|
1979
|
-
throw err;
|
|
1980
|
-
}
|
|
1981
|
-
}).then((comp) => {
|
|
1982
|
-
if (thisRequest !== pendingRequest && pendingRequest) {
|
|
1983
|
-
return pendingRequest;
|
|
1984
|
-
}
|
|
1985
|
-
if (!!(process.env.NODE_ENV !== "production") && !comp) {
|
|
1986
|
-
warn$1(
|
|
1987
|
-
`Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
|
|
1988
|
-
);
|
|
1989
|
-
}
|
|
1990
|
-
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
|
1991
|
-
comp = comp.default;
|
|
1992
|
-
}
|
|
1993
|
-
if (!!(process.env.NODE_ENV !== "production") && comp && !isObject(comp) && !isFunction(comp)) {
|
|
1994
|
-
throw new Error(`Invalid async component load result: ${comp}`);
|
|
1995
|
-
}
|
|
1996
|
-
resolvedComp = comp;
|
|
1997
|
-
return comp;
|
|
1998
|
-
}));
|
|
1999
|
-
};
|
|
2000
|
-
return /* @__PURE__ */ defineComponent({
|
|
2001
|
-
name: "AsyncComponentWrapper",
|
|
2002
|
-
__asyncLoader: load,
|
|
2003
|
-
get __asyncResolved() {
|
|
2004
|
-
return resolvedComp;
|
|
2005
|
-
},
|
|
2006
|
-
setup() {
|
|
2007
|
-
const instance = currentInstance;
|
|
2008
|
-
if (resolvedComp) {
|
|
2009
|
-
return () => createInnerComp(resolvedComp, instance);
|
|
2010
|
-
}
|
|
2011
|
-
const onError = (err) => {
|
|
2012
|
-
pendingRequest = null;
|
|
2013
|
-
handleError(
|
|
2014
|
-
err,
|
|
2015
|
-
instance,
|
|
2016
|
-
13,
|
|
2017
|
-
!errorComponent
|
|
2018
|
-
);
|
|
2019
|
-
};
|
|
2020
|
-
if (suspensible && instance.suspense || isInSSRComponentSetup) {
|
|
2021
|
-
return load().then((comp) => {
|
|
2022
|
-
return () => createInnerComp(comp, instance);
|
|
2023
|
-
}).catch((err) => {
|
|
2024
|
-
onError(err);
|
|
2025
|
-
return () => errorComponent ? createVNode(errorComponent, {
|
|
2026
|
-
error: err
|
|
2027
|
-
}) : null;
|
|
2028
|
-
});
|
|
2029
|
-
}
|
|
2030
|
-
const loaded = ref(false);
|
|
2031
|
-
const error = ref();
|
|
2032
|
-
const delayed = ref(!!delay);
|
|
2033
|
-
if (delay) {
|
|
2034
|
-
setTimeout(() => {
|
|
2035
|
-
delayed.value = false;
|
|
2036
|
-
}, delay);
|
|
2037
|
-
}
|
|
2038
|
-
if (timeout != null) {
|
|
2039
|
-
setTimeout(() => {
|
|
2040
|
-
if (!loaded.value && !error.value) {
|
|
2041
|
-
const err = new Error(
|
|
2042
|
-
`Async component timed out after ${timeout}ms.`
|
|
2043
|
-
);
|
|
2044
|
-
onError(err);
|
|
2045
|
-
error.value = err;
|
|
2046
|
-
}
|
|
2047
|
-
}, timeout);
|
|
2048
|
-
}
|
|
2049
|
-
load().then(() => {
|
|
2050
|
-
loaded.value = true;
|
|
2051
|
-
if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
|
2052
|
-
instance.parent.effect.dirty = true;
|
|
2053
|
-
queueJob(instance.parent.update);
|
|
2054
|
-
}
|
|
2055
|
-
}).catch((err) => {
|
|
2056
|
-
onError(err);
|
|
2057
|
-
error.value = err;
|
|
2058
|
-
});
|
|
2059
|
-
return () => {
|
|
2060
|
-
if (loaded.value && resolvedComp) {
|
|
2061
|
-
return createInnerComp(resolvedComp, instance);
|
|
2062
|
-
} else if (error.value && errorComponent) {
|
|
2063
|
-
return createVNode(errorComponent, {
|
|
2064
|
-
error: error.value
|
|
2065
|
-
});
|
|
2066
|
-
} else if (loadingComponent && !delayed.value) {
|
|
2067
|
-
return createVNode(loadingComponent);
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
|
-
}
|
|
2073
|
-
function createInnerComp(comp, parent) {
|
|
2074
|
-
const { ref: ref22, props, children, ce } = parent.vnode;
|
|
2075
|
-
const vnode = createVNode(comp, props, children);
|
|
2076
|
-
vnode.ref = ref22;
|
|
2077
|
-
vnode.ce = ce;
|
|
2078
|
-
delete parent.vnode.ce;
|
|
2079
|
-
return vnode;
|
|
2080
|
-
}
|
|
2081
|
-
const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
|
2082
|
-
function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
|
2083
|
-
if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
|
|
2084
|
-
if (name !== "default")
|
|
2085
|
-
props.name = name;
|
|
2086
|
-
return createVNode("slot", props, fallback && fallback());
|
|
2087
|
-
}
|
|
2088
|
-
let slot = slots[name];
|
|
2089
|
-
if (!!(process.env.NODE_ENV !== "production") && slot && slot.length > 1) {
|
|
2090
|
-
warn$1(
|
|
2091
|
-
`SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
|
|
2092
|
-
);
|
|
2093
|
-
slot = () => [];
|
|
2094
|
-
}
|
|
2095
|
-
if (slot && slot._c) {
|
|
2096
|
-
slot._d = false;
|
|
2097
|
-
}
|
|
2098
|
-
openBlock();
|
|
2099
|
-
const validSlotContent = slot && ensureValidVNode(slot(props));
|
|
2100
|
-
const rendered = createBlock(
|
|
2101
|
-
Fragment,
|
|
2102
|
-
{
|
|
2103
|
-
key: props.key || // slot content array of a dynamic conditional slot may have a branch
|
|
2104
|
-
// key attached in the `createSlots` helper, respect that
|
|
2105
|
-
validSlotContent && validSlotContent.key || `_${name}`
|
|
2106
|
-
},
|
|
2107
|
-
validSlotContent || (fallback ? fallback() : []),
|
|
2108
|
-
validSlotContent && slots._ === 1 ? 64 : -2
|
|
2109
|
-
);
|
|
2110
|
-
if (!noSlotted && rendered.scopeId) {
|
|
2111
|
-
rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
|
2112
|
-
}
|
|
2113
|
-
if (slot && slot._c) {
|
|
2114
|
-
slot._d = true;
|
|
2115
|
-
}
|
|
2116
|
-
return rendered;
|
|
2117
|
-
}
|
|
2118
|
-
function ensureValidVNode(vnodes) {
|
|
2119
|
-
return vnodes.some((child) => {
|
|
2120
|
-
if (!isVNode(child))
|
|
2121
|
-
return true;
|
|
2122
|
-
if (child.type === Comment)
|
|
2123
|
-
return false;
|
|
2124
|
-
if (child.type === Fragment && !ensureValidVNode(child.children))
|
|
2125
|
-
return false;
|
|
2126
|
-
return true;
|
|
2127
|
-
}) ? vnodes : null;
|
|
2128
|
-
}
|
|
2129
|
-
const getPublicInstance = (i) => {
|
|
2130
|
-
if (!i)
|
|
2131
|
-
return null;
|
|
2132
|
-
if (isStatefulComponent(i))
|
|
2133
|
-
return getExposeProxy(i) || i.proxy;
|
|
2134
|
-
return getPublicInstance(i.parent);
|
|
2135
|
-
};
|
|
2136
|
-
const publicPropertiesMap = (
|
|
2137
|
-
// Move PURE marker to new line to workaround compiler discarding it
|
|
2138
|
-
// due to type annotation
|
|
2139
|
-
/* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
|
|
2140
|
-
$: (i) => i,
|
|
2141
|
-
$el: (i) => i.vnode.el,
|
|
2142
|
-
$data: (i) => i.data,
|
|
2143
|
-
$props: (i) => !!(process.env.NODE_ENV !== "production") ? shallowReadonly(i.props) : i.props,
|
|
2144
|
-
$attrs: (i) => !!(process.env.NODE_ENV !== "production") ? shallowReadonly(i.attrs) : i.attrs,
|
|
2145
|
-
$slots: (i) => !!(process.env.NODE_ENV !== "production") ? shallowReadonly(i.slots) : i.slots,
|
|
2146
|
-
$refs: (i) => !!(process.env.NODE_ENV !== "production") ? shallowReadonly(i.refs) : i.refs,
|
|
2147
|
-
$parent: (i) => getPublicInstance(i.parent),
|
|
2148
|
-
$root: (i) => getPublicInstance(i.root),
|
|
2149
|
-
$emit: (i) => i.emit,
|
|
2150
|
-
$options: (i) => resolveMergedOptions(i),
|
|
2151
|
-
$forceUpdate: (i) => i.f || (i.f = () => {
|
|
2152
|
-
i.effect.dirty = true;
|
|
2153
|
-
queueJob(i.update);
|
|
2154
|
-
}),
|
|
2155
|
-
$nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
|
2156
|
-
$watch: (i) => instanceWatch.bind(i)
|
|
2157
|
-
})
|
|
2158
|
-
);
|
|
2159
|
-
const isReservedPrefix = (key) => key === "_" || key === "$";
|
|
2160
|
-
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
|
2161
|
-
const PublicInstanceProxyHandlers = {
|
|
2162
|
-
get({ _: instance }, key) {
|
|
2163
|
-
if (key === "__v_skip") {
|
|
2164
|
-
return true;
|
|
2165
|
-
}
|
|
2166
|
-
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
|
2167
|
-
if (!!(process.env.NODE_ENV !== "production") && key === "__isVue") {
|
|
2168
|
-
return true;
|
|
2169
|
-
}
|
|
2170
|
-
let normalizedProps;
|
|
2171
|
-
if (key[0] !== "$") {
|
|
2172
|
-
const n = accessCache[key];
|
|
2173
|
-
if (n !== void 0) {
|
|
2174
|
-
switch (n) {
|
|
2175
|
-
case 1:
|
|
2176
|
-
return setupState[key];
|
|
2177
|
-
case 2:
|
|
2178
|
-
return data[key];
|
|
2179
|
-
case 4:
|
|
2180
|
-
return ctx[key];
|
|
2181
|
-
case 3:
|
|
2182
|
-
return props[key];
|
|
2183
|
-
}
|
|
2184
|
-
} else if (hasSetupBinding(setupState, key)) {
|
|
2185
|
-
accessCache[key] = 1;
|
|
2186
|
-
return setupState[key];
|
|
2187
|
-
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
2188
|
-
accessCache[key] = 2;
|
|
2189
|
-
return data[key];
|
|
2190
|
-
} else if (
|
|
2191
|
-
// only cache other properties when instance has declared (thus stable)
|
|
2192
|
-
// props
|
|
2193
|
-
(normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
|
2194
|
-
) {
|
|
2195
|
-
accessCache[key] = 3;
|
|
2196
|
-
return props[key];
|
|
2197
|
-
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
2198
|
-
accessCache[key] = 4;
|
|
2199
|
-
return ctx[key];
|
|
2200
|
-
} else {
|
|
2201
|
-
accessCache[key] = 0;
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
const publicGetter = publicPropertiesMap[key];
|
|
2205
|
-
let cssModule, globalProperties;
|
|
2206
|
-
if (publicGetter) {
|
|
2207
|
-
if (key === "$attrs") {
|
|
2208
|
-
track(instance.attrs, "get", "");
|
|
2209
|
-
!!(process.env.NODE_ENV !== "production") && markAttrsAccessed();
|
|
2210
|
-
} else if (!!(process.env.NODE_ENV !== "production") && key === "$slots") {
|
|
2211
|
-
track(instance, "get", key);
|
|
2212
|
-
}
|
|
2213
|
-
return publicGetter(instance);
|
|
2214
|
-
} else if (
|
|
2215
|
-
// css module (injected by vue-loader)
|
|
2216
|
-
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
|
2217
|
-
) {
|
|
2218
|
-
return cssModule;
|
|
2219
|
-
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
2220
|
-
accessCache[key] = 4;
|
|
2221
|
-
return ctx[key];
|
|
2222
|
-
} else if (
|
|
2223
|
-
// global properties
|
|
2224
|
-
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
|
2225
|
-
) {
|
|
2226
|
-
{
|
|
2227
|
-
return globalProperties[key];
|
|
2228
|
-
}
|
|
2229
|
-
} else if (!!(process.env.NODE_ENV !== "production") && currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
|
|
2230
|
-
// to infinite warning loop
|
|
2231
|
-
key.indexOf("__v") !== 0)) {
|
|
2232
|
-
if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
|
2233
|
-
warn$1(
|
|
2234
|
-
`Property ${JSON.stringify(
|
|
2235
|
-
key
|
|
2236
|
-
)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
|
2237
|
-
);
|
|
2238
|
-
} else if (instance === currentRenderingInstance) {
|
|
2239
|
-
warn$1(
|
|
2240
|
-
`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
|
2241
|
-
);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
},
|
|
2245
|
-
set({ _: instance }, key, value) {
|
|
2246
|
-
const { data, setupState, ctx } = instance;
|
|
2247
|
-
if (hasSetupBinding(setupState, key)) {
|
|
2248
|
-
setupState[key] = value;
|
|
2249
|
-
return true;
|
|
2250
|
-
} else if (!!(process.env.NODE_ENV !== "production") && setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
|
2251
|
-
warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
|
2252
|
-
return false;
|
|
2253
|
-
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
2254
|
-
data[key] = value;
|
|
2255
|
-
return true;
|
|
2256
|
-
} else if (hasOwn(instance.props, key)) {
|
|
2257
|
-
!!(process.env.NODE_ENV !== "production") && warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
|
2258
|
-
return false;
|
|
2259
|
-
}
|
|
2260
|
-
if (key[0] === "$" && key.slice(1) in instance) {
|
|
2261
|
-
!!(process.env.NODE_ENV !== "production") && warn$1(
|
|
2262
|
-
`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
|
2263
|
-
);
|
|
2264
|
-
return false;
|
|
2265
|
-
} else {
|
|
2266
|
-
if (!!(process.env.NODE_ENV !== "production") && key in instance.appContext.config.globalProperties) {
|
|
2267
|
-
Object.defineProperty(ctx, key, {
|
|
2268
|
-
enumerable: true,
|
|
2269
|
-
configurable: true,
|
|
2270
|
-
value
|
|
2271
|
-
});
|
|
2272
|
-
} else {
|
|
2273
|
-
ctx[key] = value;
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
return true;
|
|
2277
|
-
},
|
|
2278
|
-
has({
|
|
2279
|
-
_: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
|
2280
|
-
}, key) {
|
|
2281
|
-
let normalizedProps;
|
|
2282
|
-
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);
|
|
2283
|
-
},
|
|
2284
|
-
defineProperty(target, key, descriptor) {
|
|
2285
|
-
if (descriptor.get != null) {
|
|
2286
|
-
target._.accessCache[key] = 0;
|
|
2287
|
-
} else if (hasOwn(descriptor, "value")) {
|
|
2288
|
-
this.set(target, key, descriptor.value, null);
|
|
2289
|
-
}
|
|
2290
|
-
return Reflect.defineProperty(target, key, descriptor);
|
|
2291
|
-
}
|
|
2292
|
-
};
|
|
2293
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
2294
|
-
PublicInstanceProxyHandlers.ownKeys = (target) => {
|
|
2295
|
-
warn$1(
|
|
2296
|
-
`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
|
2297
|
-
);
|
|
2298
|
-
return Reflect.ownKeys(target);
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
function normalizePropsOrEmits(props) {
|
|
2302
|
-
return isArray(props) ? props.reduce(
|
|
2303
|
-
(normalized, p) => (normalized[p] = null, normalized),
|
|
2304
|
-
{}
|
|
2305
|
-
) : props;
|
|
2306
|
-
}
|
|
2307
|
-
function resolveMergedOptions(instance) {
|
|
2308
|
-
const base = instance.type;
|
|
2309
|
-
const { mixins, extends: extendsOptions } = base;
|
|
2310
|
-
const {
|
|
2311
|
-
mixins: globalMixins,
|
|
2312
|
-
optionsCache: cache,
|
|
2313
|
-
config: { optionMergeStrategies }
|
|
2314
|
-
} = instance.appContext;
|
|
2315
|
-
const cached = cache.get(base);
|
|
2316
|
-
let resolved;
|
|
2317
|
-
if (cached) {
|
|
2318
|
-
resolved = cached;
|
|
2319
|
-
} else if (!globalMixins.length && !mixins && !extendsOptions) {
|
|
2320
|
-
{
|
|
2321
|
-
resolved = base;
|
|
2322
|
-
}
|
|
2323
|
-
} else {
|
|
2324
|
-
resolved = {};
|
|
2325
|
-
if (globalMixins.length) {
|
|
2326
|
-
globalMixins.forEach(
|
|
2327
|
-
(m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
|
2328
|
-
);
|
|
2329
|
-
}
|
|
2330
|
-
mergeOptions(resolved, base, optionMergeStrategies);
|
|
2331
|
-
}
|
|
2332
|
-
if (isObject(base)) {
|
|
2333
|
-
cache.set(base, resolved);
|
|
2334
|
-
}
|
|
2335
|
-
return resolved;
|
|
2336
|
-
}
|
|
2337
|
-
function mergeOptions(to, from, strats, asMixin = false) {
|
|
2338
|
-
const { mixins, extends: extendsOptions } = from;
|
|
2339
|
-
if (extendsOptions) {
|
|
2340
|
-
mergeOptions(to, extendsOptions, strats, true);
|
|
2341
|
-
}
|
|
2342
|
-
if (mixins) {
|
|
2343
|
-
mixins.forEach(
|
|
2344
|
-
(m) => mergeOptions(to, m, strats, true)
|
|
2345
|
-
);
|
|
2346
|
-
}
|
|
2347
|
-
for (const key in from) {
|
|
2348
|
-
if (asMixin && key === "expose") {
|
|
2349
|
-
!!(process.env.NODE_ENV !== "production") && warn$1(
|
|
2350
|
-
`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
|
2351
|
-
);
|
|
2352
|
-
} else {
|
|
2353
|
-
const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
|
2354
|
-
to[key] = strat ? strat(to[key], from[key]) : from[key];
|
|
2355
|
-
}
|
|
2356
|
-
}
|
|
2357
|
-
return to;
|
|
2358
|
-
}
|
|
2359
|
-
const internalOptionMergeStrats = {
|
|
2360
|
-
data: mergeDataFn,
|
|
2361
|
-
props: mergeEmitsOrPropsOptions,
|
|
2362
|
-
emits: mergeEmitsOrPropsOptions,
|
|
2363
|
-
// objects
|
|
2364
|
-
methods: mergeObjectOptions,
|
|
2365
|
-
computed: mergeObjectOptions,
|
|
2366
|
-
// lifecycle
|
|
2367
|
-
beforeCreate: mergeAsArray,
|
|
2368
|
-
created: mergeAsArray,
|
|
2369
|
-
beforeMount: mergeAsArray,
|
|
2370
|
-
mounted: mergeAsArray,
|
|
2371
|
-
beforeUpdate: mergeAsArray,
|
|
2372
|
-
updated: mergeAsArray,
|
|
2373
|
-
beforeDestroy: mergeAsArray,
|
|
2374
|
-
beforeUnmount: mergeAsArray,
|
|
2375
|
-
destroyed: mergeAsArray,
|
|
2376
|
-
unmounted: mergeAsArray,
|
|
2377
|
-
activated: mergeAsArray,
|
|
2378
|
-
deactivated: mergeAsArray,
|
|
2379
|
-
errorCaptured: mergeAsArray,
|
|
2380
|
-
serverPrefetch: mergeAsArray,
|
|
2381
|
-
// assets
|
|
2382
|
-
components: mergeObjectOptions,
|
|
2383
|
-
directives: mergeObjectOptions,
|
|
2384
|
-
// watch
|
|
2385
|
-
watch: mergeWatchOptions,
|
|
2386
|
-
// provide / inject
|
|
2387
|
-
provide: mergeDataFn,
|
|
2388
|
-
inject: mergeInject
|
|
2389
|
-
};
|
|
2390
|
-
function mergeDataFn(to, from) {
|
|
2391
|
-
if (!from) {
|
|
2392
|
-
return to;
|
|
2393
|
-
}
|
|
2394
|
-
if (!to) {
|
|
2395
|
-
return from;
|
|
2396
|
-
}
|
|
2397
|
-
return function mergedDataFn() {
|
|
2398
|
-
return extend(
|
|
2399
|
-
isFunction(to) ? to.call(this, this) : to,
|
|
2400
|
-
isFunction(from) ? from.call(this, this) : from
|
|
2401
|
-
);
|
|
2402
|
-
};
|
|
2403
|
-
}
|
|
2404
|
-
function mergeInject(to, from) {
|
|
2405
|
-
return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
|
2406
|
-
}
|
|
2407
|
-
function normalizeInject(raw) {
|
|
2408
|
-
if (isArray(raw)) {
|
|
2409
|
-
const res = {};
|
|
2410
|
-
for (let i = 0; i < raw.length; i++) {
|
|
2411
|
-
res[raw[i]] = raw[i];
|
|
2412
|
-
}
|
|
2413
|
-
return res;
|
|
2414
|
-
}
|
|
2415
|
-
return raw;
|
|
2416
|
-
}
|
|
2417
|
-
function mergeAsArray(to, from) {
|
|
2418
|
-
return to ? [...new Set([].concat(to, from))] : from;
|
|
2419
|
-
}
|
|
2420
|
-
function mergeObjectOptions(to, from) {
|
|
2421
|
-
return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
|
|
2422
|
-
}
|
|
2423
|
-
function mergeEmitsOrPropsOptions(to, from) {
|
|
2424
|
-
if (to) {
|
|
2425
|
-
if (isArray(to) && isArray(from)) {
|
|
2426
|
-
return [.../* @__PURE__ */ new Set([...to, ...from])];
|
|
2427
|
-
}
|
|
2428
|
-
return extend(
|
|
2429
|
-
/* @__PURE__ */ Object.create(null),
|
|
2430
|
-
normalizePropsOrEmits(to),
|
|
2431
|
-
normalizePropsOrEmits(from != null ? from : {})
|
|
2432
|
-
);
|
|
2433
|
-
} else {
|
|
2434
|
-
return from;
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
function mergeWatchOptions(to, from) {
|
|
2438
|
-
if (!to)
|
|
2439
|
-
return from;
|
|
2440
|
-
if (!from)
|
|
2441
|
-
return to;
|
|
2442
|
-
const merged = extend(/* @__PURE__ */ Object.create(null), to);
|
|
2443
|
-
for (const key in from) {
|
|
2444
|
-
merged[key] = mergeAsArray(to[key], from[key]);
|
|
2445
|
-
}
|
|
2446
|
-
return merged;
|
|
2447
|
-
}
|
|
2448
|
-
let currentApp = null;
|
|
2449
|
-
function provide(key, value) {
|
|
2450
|
-
if (!currentInstance) {
|
|
2451
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
2452
|
-
warn$1(`provide() can only be used inside setup().`);
|
|
2453
|
-
}
|
|
2454
|
-
} else {
|
|
2455
|
-
let provides = currentInstance.provides;
|
|
2456
|
-
const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
|
2457
|
-
if (parentProvides === provides) {
|
|
2458
|
-
provides = currentInstance.provides = Object.create(parentProvides);
|
|
2459
|
-
}
|
|
2460
|
-
provides[key] = value;
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
2464
|
-
const instance = currentInstance || currentRenderingInstance;
|
|
2465
|
-
if (instance || currentApp) {
|
|
2466
|
-
const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
|
|
2467
|
-
if (provides && key in provides) {
|
|
2468
|
-
return provides[key];
|
|
2469
|
-
} else if (arguments.length > 1) {
|
|
2470
|
-
return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
|
2471
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
2472
|
-
warn$1(`injection "${String(key)}" not found.`);
|
|
2473
|
-
}
|
|
2474
|
-
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
2475
|
-
warn$1(`inject() can only be used inside setup() or functional components.`);
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
const internalObjectProto = /* @__PURE__ */ Object.create(null);
|
|
2479
|
-
const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
|
2480
|
-
const queuePostRenderEffect = queueEffectWithSuspense;
|
|
2481
|
-
const isTeleport = (type) => type.__isTeleport;
|
|
2482
|
-
const Fragment = Symbol.for("v-fgt");
|
|
2483
|
-
const Text = Symbol.for("v-txt");
|
|
2484
|
-
const Comment = Symbol.for("v-cmt");
|
|
2485
|
-
const blockStack = [];
|
|
2486
|
-
let currentBlock = null;
|
|
2487
|
-
function openBlock(disableTracking = false) {
|
|
2488
|
-
blockStack.push(currentBlock = disableTracking ? null : []);
|
|
2489
|
-
}
|
|
2490
|
-
function closeBlock() {
|
|
2491
|
-
blockStack.pop();
|
|
2492
|
-
currentBlock = blockStack[blockStack.length - 1] || null;
|
|
2493
|
-
}
|
|
2494
|
-
function setupBlock(vnode) {
|
|
2495
|
-
vnode.dynamicChildren = currentBlock || EMPTY_ARR;
|
|
2496
|
-
closeBlock();
|
|
2497
|
-
if (currentBlock) {
|
|
2498
|
-
currentBlock.push(vnode);
|
|
2499
|
-
}
|
|
2500
|
-
return vnode;
|
|
2501
|
-
}
|
|
2502
|
-
function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
|
2503
|
-
return setupBlock(
|
|
2504
|
-
createBaseVNode(
|
|
2505
|
-
type,
|
|
2506
|
-
props,
|
|
2507
|
-
children,
|
|
2508
|
-
patchFlag,
|
|
2509
|
-
dynamicProps,
|
|
2510
|
-
shapeFlag,
|
|
2511
|
-
true
|
|
2512
|
-
)
|
|
2513
|
-
);
|
|
2514
|
-
}
|
|
2515
|
-
function createBlock(type, props, children, patchFlag, dynamicProps) {
|
|
2516
|
-
return setupBlock(
|
|
2517
|
-
createVNode(
|
|
2518
|
-
type,
|
|
2519
|
-
props,
|
|
2520
|
-
children,
|
|
2521
|
-
patchFlag,
|
|
2522
|
-
dynamicProps,
|
|
2523
|
-
true
|
|
2524
|
-
)
|
|
2525
|
-
);
|
|
2526
|
-
}
|
|
2527
|
-
function isVNode(value) {
|
|
2528
|
-
return value ? value.__v_isVNode === true : false;
|
|
2529
|
-
}
|
|
2530
|
-
const createVNodeWithArgsTransform = (...args) => {
|
|
2531
|
-
return _createVNode(
|
|
2532
|
-
...args
|
|
2533
|
-
);
|
|
2534
|
-
};
|
|
2535
|
-
const normalizeKey = ({ key }) => key != null ? key : null;
|
|
2536
|
-
const normalizeRef = ({
|
|
2537
|
-
ref: ref3,
|
|
2538
|
-
ref_key,
|
|
2539
|
-
ref_for
|
|
2540
|
-
}) => {
|
|
2541
|
-
if (typeof ref3 === "number") {
|
|
2542
|
-
ref3 = "" + ref3;
|
|
2543
|
-
}
|
|
2544
|
-
return ref3 != null ? isString(ref3) || isRef(ref3) || isFunction(ref3) ? { i: currentRenderingInstance, r: ref3, k: ref_key, f: !!ref_for } : ref3 : null;
|
|
2545
|
-
};
|
|
2546
|
-
function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
|
2547
|
-
const vnode = {
|
|
2548
|
-
__v_isVNode: true,
|
|
2549
|
-
__v_skip: true,
|
|
2550
|
-
type,
|
|
2551
|
-
props,
|
|
2552
|
-
key: props && normalizeKey(props),
|
|
2553
|
-
ref: props && normalizeRef(props),
|
|
2554
|
-
scopeId: currentScopeId,
|
|
2555
|
-
slotScopeIds: null,
|
|
2556
|
-
children,
|
|
2557
|
-
component: null,
|
|
2558
|
-
suspense: null,
|
|
2559
|
-
ssContent: null,
|
|
2560
|
-
ssFallback: null,
|
|
2561
|
-
dirs: null,
|
|
2562
|
-
transition: null,
|
|
2563
|
-
el: null,
|
|
2564
|
-
anchor: null,
|
|
2565
|
-
target: null,
|
|
2566
|
-
targetAnchor: null,
|
|
2567
|
-
staticCount: 0,
|
|
2568
|
-
shapeFlag,
|
|
2569
|
-
patchFlag,
|
|
2570
|
-
dynamicProps,
|
|
2571
|
-
dynamicChildren: null,
|
|
2572
|
-
appContext: null,
|
|
2573
|
-
ctx: currentRenderingInstance
|
|
2574
|
-
};
|
|
2575
|
-
if (needFullChildrenNormalization) {
|
|
2576
|
-
normalizeChildren(vnode, children);
|
|
2577
|
-
if (shapeFlag & 128) {
|
|
2578
|
-
type.normalize(vnode);
|
|
2579
|
-
}
|
|
2580
|
-
} else if (children) {
|
|
2581
|
-
vnode.shapeFlag |= isString(children) ? 8 : 16;
|
|
2582
|
-
}
|
|
2583
|
-
if (!!(process.env.NODE_ENV !== "production") && vnode.key !== vnode.key) {
|
|
2584
|
-
warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
|
2585
|
-
}
|
|
2586
|
-
if (
|
|
2587
|
-
// avoid a block node from tracking itself
|
|
2588
|
-
!isBlockNode && // has current parent block
|
|
2589
|
-
currentBlock && // presence of a patch flag indicates this node needs patching on updates.
|
|
2590
|
-
// component nodes also should always be patched, because even if the
|
|
2591
|
-
// component doesn't need to update, it needs to persist the instance on to
|
|
2592
|
-
// the next vnode so that it can be properly unmounted later.
|
|
2593
|
-
(vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
|
2594
|
-
// vnode should not be considered dynamic due to handler caching.
|
|
2595
|
-
vnode.patchFlag !== 32
|
|
2596
|
-
) {
|
|
2597
|
-
currentBlock.push(vnode);
|
|
2598
|
-
}
|
|
2599
|
-
return vnode;
|
|
2600
|
-
}
|
|
2601
|
-
const createVNode = !!(process.env.NODE_ENV !== "production") ? createVNodeWithArgsTransform : _createVNode;
|
|
2602
|
-
function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
|
2603
|
-
if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
|
2604
|
-
if (!!(process.env.NODE_ENV !== "production") && !type) {
|
|
2605
|
-
warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
|
2606
|
-
}
|
|
2607
|
-
type = Comment;
|
|
2608
|
-
}
|
|
2609
|
-
if (isVNode(type)) {
|
|
2610
|
-
const cloned = cloneVNode(
|
|
2611
|
-
type,
|
|
2612
|
-
props,
|
|
2613
|
-
true
|
|
2614
|
-
/* mergeRef: true */
|
|
2615
|
-
);
|
|
2616
|
-
if (children) {
|
|
2617
|
-
normalizeChildren(cloned, children);
|
|
2618
|
-
}
|
|
2619
|
-
if (!isBlockNode && currentBlock) {
|
|
2620
|
-
if (cloned.shapeFlag & 6) {
|
|
2621
|
-
currentBlock[currentBlock.indexOf(type)] = cloned;
|
|
2622
|
-
} else {
|
|
2623
|
-
currentBlock.push(cloned);
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
cloned.patchFlag |= -2;
|
|
2627
|
-
return cloned;
|
|
2628
|
-
}
|
|
2629
|
-
if (isClassComponent(type)) {
|
|
2630
|
-
type = type.__vccOpts;
|
|
2631
|
-
}
|
|
2632
|
-
if (props) {
|
|
2633
|
-
props = guardReactiveProps(props);
|
|
2634
|
-
let { class: klass, style } = props;
|
|
2635
|
-
if (klass && !isString(klass)) {
|
|
2636
|
-
props.class = normalizeClass(klass);
|
|
2637
|
-
}
|
|
2638
|
-
if (isObject(style)) {
|
|
2639
|
-
if (isProxy(style) && !isArray(style)) {
|
|
2640
|
-
style = extend({}, style);
|
|
2641
|
-
}
|
|
2642
|
-
props.style = normalizeStyle(style);
|
|
2643
|
-
}
|
|
2644
|
-
}
|
|
2645
|
-
const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
|
2646
|
-
if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && isProxy(type)) {
|
|
2647
|
-
type = toRaw(type);
|
|
2648
|
-
warn$1(
|
|
2649
|
-
`Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
|
|
2650
|
-
`
|
|
2651
|
-
Component that was made reactive: `,
|
|
2652
|
-
type
|
|
2653
|
-
);
|
|
2654
|
-
}
|
|
2655
|
-
return createBaseVNode(
|
|
2656
|
-
type,
|
|
2657
|
-
props,
|
|
2658
|
-
children,
|
|
2659
|
-
patchFlag,
|
|
2660
|
-
dynamicProps,
|
|
2661
|
-
shapeFlag,
|
|
2662
|
-
isBlockNode,
|
|
2663
|
-
true
|
|
2664
|
-
);
|
|
2665
|
-
}
|
|
2666
|
-
function guardReactiveProps(props) {
|
|
2667
|
-
if (!props)
|
|
2668
|
-
return null;
|
|
2669
|
-
return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
|
|
2670
|
-
}
|
|
2671
|
-
function cloneVNode(vnode, extraProps, mergeRef = false) {
|
|
2672
|
-
const { props, ref: ref3, patchFlag, children } = vnode;
|
|
2673
|
-
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
|
2674
|
-
const cloned = {
|
|
2675
|
-
__v_isVNode: true,
|
|
2676
|
-
__v_skip: true,
|
|
2677
|
-
type: vnode.type,
|
|
2678
|
-
props: mergedProps,
|
|
2679
|
-
key: mergedProps && normalizeKey(mergedProps),
|
|
2680
|
-
ref: extraProps && extraProps.ref ? (
|
|
2681
|
-
// #2078 in the case of <component :is="vnode" ref="extra"/>
|
|
2682
|
-
// if the vnode itself already has a ref, cloneVNode will need to merge
|
|
2683
|
-
// the refs so the single vnode can be set on multiple refs
|
|
2684
|
-
mergeRef && ref3 ? isArray(ref3) ? ref3.concat(normalizeRef(extraProps)) : [ref3, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
|
2685
|
-
) : ref3,
|
|
2686
|
-
scopeId: vnode.scopeId,
|
|
2687
|
-
slotScopeIds: vnode.slotScopeIds,
|
|
2688
|
-
children: !!(process.env.NODE_ENV !== "production") && patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
|
2689
|
-
target: vnode.target,
|
|
2690
|
-
targetAnchor: vnode.targetAnchor,
|
|
2691
|
-
staticCount: vnode.staticCount,
|
|
2692
|
-
shapeFlag: vnode.shapeFlag,
|
|
2693
|
-
// if the vnode is cloned with extra props, we can no longer assume its
|
|
2694
|
-
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
|
2695
|
-
// note: preserve flag for fragments since they use the flag for children
|
|
2696
|
-
// fast paths only.
|
|
2697
|
-
patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
|
2698
|
-
dynamicProps: vnode.dynamicProps,
|
|
2699
|
-
dynamicChildren: vnode.dynamicChildren,
|
|
2700
|
-
appContext: vnode.appContext,
|
|
2701
|
-
dirs: vnode.dirs,
|
|
2702
|
-
transition: vnode.transition,
|
|
2703
|
-
// These should technically only be non-null on mounted VNodes. However,
|
|
2704
|
-
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
2705
|
-
// them since them being non-null during a mount doesn't affect the logic as
|
|
2706
|
-
// they will simply be overwritten.
|
|
2707
|
-
component: vnode.component,
|
|
2708
|
-
suspense: vnode.suspense,
|
|
2709
|
-
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
|
2710
|
-
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
|
2711
|
-
el: vnode.el,
|
|
2712
|
-
anchor: vnode.anchor,
|
|
2713
|
-
ctx: vnode.ctx,
|
|
2714
|
-
ce: vnode.ce
|
|
2715
|
-
};
|
|
2716
|
-
return cloned;
|
|
2717
|
-
}
|
|
2718
|
-
function deepCloneVNode(vnode) {
|
|
2719
|
-
const cloned = cloneVNode(vnode);
|
|
2720
|
-
if (isArray(vnode.children)) {
|
|
2721
|
-
cloned.children = vnode.children.map(deepCloneVNode);
|
|
2722
|
-
}
|
|
2723
|
-
return cloned;
|
|
2724
|
-
}
|
|
2725
|
-
function createTextVNode(text = " ", flag = 0) {
|
|
2726
|
-
return createVNode(Text, null, text, flag);
|
|
2727
|
-
}
|
|
2728
|
-
function normalizeChildren(vnode, children) {
|
|
2729
|
-
let type = 0;
|
|
2730
|
-
const { shapeFlag } = vnode;
|
|
2731
|
-
if (children == null) {
|
|
2732
|
-
children = null;
|
|
2733
|
-
} else if (isArray(children)) {
|
|
2734
|
-
type = 16;
|
|
2735
|
-
} else if (typeof children === "object") {
|
|
2736
|
-
if (shapeFlag & (1 | 64)) {
|
|
2737
|
-
const slot = children.default;
|
|
2738
|
-
if (slot) {
|
|
2739
|
-
slot._c && (slot._d = false);
|
|
2740
|
-
normalizeChildren(vnode, slot());
|
|
2741
|
-
slot._c && (slot._d = true);
|
|
2742
|
-
}
|
|
2743
|
-
return;
|
|
2744
|
-
} else {
|
|
2745
|
-
type = 32;
|
|
2746
|
-
const slotFlag = children._;
|
|
2747
|
-
if (!slotFlag && !isInternalObject(children)) {
|
|
2748
|
-
children._ctx = currentRenderingInstance;
|
|
2749
|
-
} else if (slotFlag === 3 && currentRenderingInstance) {
|
|
2750
|
-
if (currentRenderingInstance.slots._ === 1) {
|
|
2751
|
-
children._ = 1;
|
|
2752
|
-
} else {
|
|
2753
|
-
children._ = 2;
|
|
2754
|
-
vnode.patchFlag |= 1024;
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
} else if (isFunction(children)) {
|
|
2759
|
-
children = { default: children, _ctx: currentRenderingInstance };
|
|
2760
|
-
type = 32;
|
|
2761
|
-
} else {
|
|
2762
|
-
children = String(children);
|
|
2763
|
-
if (shapeFlag & 64) {
|
|
2764
|
-
type = 16;
|
|
2765
|
-
children = [createTextVNode(children)];
|
|
2766
|
-
} else {
|
|
2767
|
-
type = 8;
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
vnode.children = children;
|
|
2771
|
-
vnode.shapeFlag |= type;
|
|
2772
|
-
}
|
|
2773
|
-
function mergeProps(...args) {
|
|
2774
|
-
const ret = {};
|
|
2775
|
-
for (let i = 0; i < args.length; i++) {
|
|
2776
|
-
const toMerge = args[i];
|
|
2777
|
-
for (const key in toMerge) {
|
|
2778
|
-
if (key === "class") {
|
|
2779
|
-
if (ret.class !== toMerge.class) {
|
|
2780
|
-
ret.class = normalizeClass([ret.class, toMerge.class]);
|
|
2781
|
-
}
|
|
2782
|
-
} else if (key === "style") {
|
|
2783
|
-
ret.style = normalizeStyle([ret.style, toMerge.style]);
|
|
2784
|
-
} else if (isOn(key)) {
|
|
2785
|
-
const existing = ret[key];
|
|
2786
|
-
const incoming = toMerge[key];
|
|
2787
|
-
if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
|
2788
|
-
ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
|
2789
|
-
}
|
|
2790
|
-
} else if (key !== "") {
|
|
2791
|
-
ret[key] = toMerge[key];
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
return ret;
|
|
2796
|
-
}
|
|
2797
|
-
let currentInstance = null;
|
|
2798
|
-
const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
|
2799
|
-
let internalSetCurrentInstance;
|
|
2800
|
-
{
|
|
2801
|
-
const g = getGlobalThis();
|
|
2802
|
-
const registerGlobalSetter = (key, setter) => {
|
|
2803
|
-
let setters;
|
|
2804
|
-
if (!(setters = g[key]))
|
|
2805
|
-
setters = g[key] = [];
|
|
2806
|
-
setters.push(setter);
|
|
2807
|
-
return (v) => {
|
|
2808
|
-
if (setters.length > 1)
|
|
2809
|
-
setters.forEach((set2) => set2(v));
|
|
2810
|
-
else
|
|
2811
|
-
setters[0](v);
|
|
2812
|
-
};
|
|
2813
|
-
};
|
|
2814
|
-
internalSetCurrentInstance = registerGlobalSetter(
|
|
2815
|
-
`__VUE_INSTANCE_SETTERS__`,
|
|
2816
|
-
(v) => currentInstance = v
|
|
2817
|
-
);
|
|
2818
|
-
registerGlobalSetter(
|
|
2819
|
-
`__VUE_SSR_SETTERS__`,
|
|
2820
|
-
(v) => isInSSRComponentSetup = v
|
|
2821
|
-
);
|
|
2822
|
-
}
|
|
2823
|
-
const setCurrentInstance = (instance) => {
|
|
2824
|
-
const prev = currentInstance;
|
|
2825
|
-
internalSetCurrentInstance(instance);
|
|
2826
|
-
instance.scope.on();
|
|
2827
|
-
return () => {
|
|
2828
|
-
instance.scope.off();
|
|
2829
|
-
internalSetCurrentInstance(prev);
|
|
2830
|
-
};
|
|
2831
|
-
};
|
|
2832
|
-
function isStatefulComponent(instance) {
|
|
2833
|
-
return instance.vnode.shapeFlag & 4;
|
|
2834
|
-
}
|
|
2835
|
-
let isInSSRComponentSetup = false;
|
|
2836
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
2837
|
-
get(target, key) {
|
|
2838
|
-
track(target, "get", "");
|
|
2839
|
-
return target[key];
|
|
2840
|
-
},
|
|
2841
|
-
set() {
|
|
2842
|
-
warn$1(`setupContext.attrs is readonly.`);
|
|
2843
|
-
return false;
|
|
2844
|
-
},
|
|
2845
|
-
deleteProperty() {
|
|
2846
|
-
warn$1(`setupContext.attrs is readonly.`);
|
|
2847
|
-
return false;
|
|
2848
|
-
}
|
|
2849
|
-
} : {
|
|
2850
|
-
get(target, key) {
|
|
2851
|
-
track(target, "get", "");
|
|
2852
|
-
return target[key];
|
|
2853
|
-
}
|
|
2854
|
-
};
|
|
2855
|
-
function getExposeProxy(instance) {
|
|
2856
|
-
if (instance.exposed) {
|
|
2857
|
-
return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
|
2858
|
-
get(target, key) {
|
|
2859
|
-
if (key in target) {
|
|
2860
|
-
return target[key];
|
|
2861
|
-
} else if (key in publicPropertiesMap) {
|
|
2862
|
-
return publicPropertiesMap[key](instance);
|
|
2863
|
-
}
|
|
2864
|
-
},
|
|
2865
|
-
has(target, key) {
|
|
2866
|
-
return key in target || key in publicPropertiesMap;
|
|
2867
|
-
}
|
|
2868
|
-
}));
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
const classifyRE = /(?:^|[-_])(\w)/g;
|
|
2872
|
-
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
2873
|
-
function getComponentName(Component, includeInferred = true) {
|
|
2874
|
-
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
2875
|
-
}
|
|
2876
|
-
function formatComponentName(instance, Component, isRoot = false) {
|
|
2877
|
-
let name = getComponentName(Component);
|
|
2878
|
-
if (!name && Component.__file) {
|
|
2879
|
-
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
2880
|
-
if (match) {
|
|
2881
|
-
name = match[1];
|
|
2882
|
-
}
|
|
2883
|
-
}
|
|
2884
|
-
if (!name && instance && instance.parent) {
|
|
2885
|
-
const inferFromRegistry = (registry) => {
|
|
2886
|
-
for (const key in registry) {
|
|
2887
|
-
if (registry[key] === Component) {
|
|
2888
|
-
return key;
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
};
|
|
2892
|
-
name = inferFromRegistry(
|
|
2893
|
-
instance.components || instance.parent.type.components
|
|
2894
|
-
) || inferFromRegistry(instance.appContext.components);
|
|
2895
|
-
}
|
|
2896
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
2897
|
-
}
|
|
2898
|
-
function isClassComponent(value) {
|
|
2899
|
-
return isFunction(value) && "__vccOpts" in value;
|
|
2900
|
-
}
|
|
2901
|
-
const computed = (getterOrOptions, debugOptions) => {
|
|
2902
|
-
const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
|
2903
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
2904
|
-
const i = getCurrentInstance();
|
|
2905
|
-
if (i && i.appContext.config.warnRecursiveComputed) {
|
|
2906
|
-
c._warnRecursive = true;
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
return c;
|
|
2910
|
-
};
|
|
2911
|
-
function h(type, propsOrChildren, children) {
|
|
2912
|
-
const l = arguments.length;
|
|
2913
|
-
if (l === 2) {
|
|
2914
|
-
if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
|
2915
|
-
if (isVNode(propsOrChildren)) {
|
|
2916
|
-
return createVNode(type, null, [propsOrChildren]);
|
|
2917
|
-
}
|
|
2918
|
-
return createVNode(type, propsOrChildren);
|
|
2919
|
-
} else {
|
|
2920
|
-
return createVNode(type, null, propsOrChildren);
|
|
2921
|
-
}
|
|
2922
|
-
} else {
|
|
2923
|
-
if (l > 3) {
|
|
2924
|
-
children = Array.prototype.slice.call(arguments, 2);
|
|
2925
|
-
} else if (l === 3 && isVNode(children)) {
|
|
2926
|
-
children = [children];
|
|
2927
|
-
}
|
|
2928
|
-
return createVNode(type, propsOrChildren, children);
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
function initCustomFormatter() {
|
|
2932
|
-
if (!!!(process.env.NODE_ENV !== "production") || typeof window === "undefined") {
|
|
2933
|
-
return;
|
|
2934
|
-
}
|
|
2935
|
-
const vueStyle = { style: "color:#3ba776" };
|
|
2936
|
-
const numberStyle = { style: "color:#1677ff" };
|
|
2937
|
-
const stringStyle = { style: "color:#f5222d" };
|
|
2938
|
-
const keywordStyle = { style: "color:#eb2f96" };
|
|
2939
|
-
const formatter = {
|
|
2940
|
-
header(obj) {
|
|
2941
|
-
if (!isObject(obj)) {
|
|
2942
|
-
return null;
|
|
2943
|
-
}
|
|
2944
|
-
if (obj.__isVue) {
|
|
2945
|
-
return ["div", vueStyle, `VueInstance`];
|
|
2946
|
-
} else if (isRef(obj)) {
|
|
2947
|
-
return [
|
|
2948
|
-
"div",
|
|
2949
|
-
{},
|
|
2950
|
-
["span", vueStyle, genRefFlag(obj)],
|
|
2951
|
-
"<",
|
|
2952
|
-
formatValue(obj.value),
|
|
2953
|
-
`>`
|
|
2954
|
-
];
|
|
2955
|
-
} else if (isReactive(obj)) {
|
|
2956
|
-
return [
|
|
2957
|
-
"div",
|
|
2958
|
-
{},
|
|
2959
|
-
["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
|
|
2960
|
-
"<",
|
|
2961
|
-
formatValue(obj),
|
|
2962
|
-
`>${isReadonly(obj) ? ` (readonly)` : ``}`
|
|
2963
|
-
];
|
|
2964
|
-
} else if (isReadonly(obj)) {
|
|
2965
|
-
return [
|
|
2966
|
-
"div",
|
|
2967
|
-
{},
|
|
2968
|
-
["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
|
|
2969
|
-
"<",
|
|
2970
|
-
formatValue(obj),
|
|
2971
|
-
">"
|
|
2972
|
-
];
|
|
2973
|
-
}
|
|
2974
|
-
return null;
|
|
2975
|
-
},
|
|
2976
|
-
hasBody(obj) {
|
|
2977
|
-
return obj && obj.__isVue;
|
|
2978
|
-
},
|
|
2979
|
-
body(obj) {
|
|
2980
|
-
if (obj && obj.__isVue) {
|
|
2981
|
-
return [
|
|
2982
|
-
"div",
|
|
2983
|
-
{},
|
|
2984
|
-
...formatInstance(obj.$)
|
|
2985
|
-
];
|
|
2986
|
-
}
|
|
2987
|
-
}
|
|
2988
|
-
};
|
|
2989
|
-
function formatInstance(instance) {
|
|
2990
|
-
const blocks = [];
|
|
2991
|
-
if (instance.type.props && instance.props) {
|
|
2992
|
-
blocks.push(createInstanceBlock("props", toRaw(instance.props)));
|
|
2993
|
-
}
|
|
2994
|
-
if (instance.setupState !== EMPTY_OBJ) {
|
|
2995
|
-
blocks.push(createInstanceBlock("setup", instance.setupState));
|
|
2996
|
-
}
|
|
2997
|
-
if (instance.data !== EMPTY_OBJ) {
|
|
2998
|
-
blocks.push(createInstanceBlock("data", toRaw(instance.data)));
|
|
2999
|
-
}
|
|
3000
|
-
const computed2 = extractKeys(instance, "computed");
|
|
3001
|
-
if (computed2) {
|
|
3002
|
-
blocks.push(createInstanceBlock("computed", computed2));
|
|
3003
|
-
}
|
|
3004
|
-
const injected = extractKeys(instance, "inject");
|
|
3005
|
-
if (injected) {
|
|
3006
|
-
blocks.push(createInstanceBlock("injected", injected));
|
|
3007
|
-
}
|
|
3008
|
-
blocks.push([
|
|
3009
|
-
"div",
|
|
3010
|
-
{},
|
|
3011
|
-
[
|
|
3012
|
-
"span",
|
|
3013
|
-
{
|
|
3014
|
-
style: keywordStyle.style + ";opacity:0.66"
|
|
3015
|
-
},
|
|
3016
|
-
"$ (internal): "
|
|
3017
|
-
],
|
|
3018
|
-
["object", { object: instance }]
|
|
3019
|
-
]);
|
|
3020
|
-
return blocks;
|
|
3021
|
-
}
|
|
3022
|
-
function createInstanceBlock(type, target) {
|
|
3023
|
-
target = extend({}, target);
|
|
3024
|
-
if (!Object.keys(target).length) {
|
|
3025
|
-
return ["span", {}];
|
|
3026
|
-
}
|
|
3027
|
-
return [
|
|
3028
|
-
"div",
|
|
3029
|
-
{ style: "line-height:1.25em;margin-bottom:0.6em" },
|
|
3030
|
-
[
|
|
3031
|
-
"div",
|
|
3032
|
-
{
|
|
3033
|
-
style: "color:#476582"
|
|
3034
|
-
},
|
|
3035
|
-
type
|
|
3036
|
-
],
|
|
3037
|
-
[
|
|
3038
|
-
"div",
|
|
3039
|
-
{
|
|
3040
|
-
style: "padding-left:1.25em"
|
|
3041
|
-
},
|
|
3042
|
-
...Object.keys(target).map((key) => {
|
|
3043
|
-
return [
|
|
3044
|
-
"div",
|
|
3045
|
-
{},
|
|
3046
|
-
["span", keywordStyle, key + ": "],
|
|
3047
|
-
formatValue(target[key], false)
|
|
3048
|
-
];
|
|
3049
|
-
})
|
|
3050
|
-
]
|
|
3051
|
-
];
|
|
3052
|
-
}
|
|
3053
|
-
function formatValue(v, asRaw = true) {
|
|
3054
|
-
if (typeof v === "number") {
|
|
3055
|
-
return ["span", numberStyle, v];
|
|
3056
|
-
} else if (typeof v === "string") {
|
|
3057
|
-
return ["span", stringStyle, JSON.stringify(v)];
|
|
3058
|
-
} else if (typeof v === "boolean") {
|
|
3059
|
-
return ["span", keywordStyle, v];
|
|
3060
|
-
} else if (isObject(v)) {
|
|
3061
|
-
return ["object", { object: asRaw ? toRaw(v) : v }];
|
|
3062
|
-
} else {
|
|
3063
|
-
return ["span", stringStyle, String(v)];
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
function extractKeys(instance, type) {
|
|
3067
|
-
const Comp = instance.type;
|
|
3068
|
-
if (isFunction(Comp)) {
|
|
3069
|
-
return;
|
|
3070
|
-
}
|
|
3071
|
-
const extracted = {};
|
|
3072
|
-
for (const key in instance.ctx) {
|
|
3073
|
-
if (isKeyOfType(Comp, key, type)) {
|
|
3074
|
-
extracted[key] = instance.ctx[key];
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
return extracted;
|
|
3078
|
-
}
|
|
3079
|
-
function isKeyOfType(Comp, key, type) {
|
|
3080
|
-
const opts = Comp[type];
|
|
3081
|
-
if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
|
|
3082
|
-
return true;
|
|
3083
|
-
}
|
|
3084
|
-
if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
|
3085
|
-
return true;
|
|
3086
|
-
}
|
|
3087
|
-
if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
|
|
3088
|
-
return true;
|
|
3089
|
-
}
|
|
3090
|
-
}
|
|
3091
|
-
function genRefFlag(v) {
|
|
3092
|
-
if (isShallow(v)) {
|
|
3093
|
-
return `ShallowRef`;
|
|
3094
|
-
}
|
|
3095
|
-
if (v.effect) {
|
|
3096
|
-
return `ComputedRef`;
|
|
3097
|
-
}
|
|
3098
|
-
return `Ref`;
|
|
3099
|
-
}
|
|
3100
|
-
if (window.devtoolsFormatters) {
|
|
3101
|
-
window.devtoolsFormatters.push(formatter);
|
|
3102
|
-
} else {
|
|
3103
|
-
window.devtoolsFormatters = [formatter];
|
|
3104
|
-
}
|
|
3105
|
-
}
|
|
3106
|
-
!!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
|
|
3107
|
-
!!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
|
|
3108
|
-
!!(process.env.NODE_ENV !== "production") || true ? setDevtoolsHook$1 : NOOP;
|
|
3109
|
-
/**
|
|
3110
|
-
* vue v3.4.23
|
|
3111
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
3112
|
-
* @license MIT
|
|
3113
|
-
**/
|
|
3114
|
-
function initDev() {
|
|
3115
|
-
{
|
|
3116
|
-
initCustomFormatter();
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3119
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
3120
|
-
initDev();
|
|
3121
|
-
}
|
|
3122
|
-
const routerRejectionKey = Symbol();
|
|
3123
|
-
function useRejection() {
|
|
3124
|
-
const rejection = inject(routerRejectionKey);
|
|
3125
|
-
if (!rejection) {
|
|
3126
|
-
throw new Error("Router is not installed");
|
|
3127
|
-
}
|
|
3128
|
-
return rejection;
|
|
3129
|
-
}
|
|
3130
|
-
class DuplicateParamsError extends Error {
|
|
3131
|
-
constructor(paramName) {
|
|
3132
|
-
super(`Invalid Param "${paramName}": Router does not support multiple params by the same name. All param names must be unique.`);
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
class NavigationAbortError extends Error {
|
|
3136
|
-
}
|
|
3137
|
-
class RouterNotInstalledError extends Error {
|
|
3138
|
-
constructor() {
|
|
3139
|
-
super("Router not installed");
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
class RouterPushError extends Error {
|
|
3143
|
-
constructor(to) {
|
|
3144
|
-
super();
|
|
3145
|
-
__publicField(this, "to");
|
|
3146
|
-
this.to = to;
|
|
3147
|
-
}
|
|
3148
|
-
}
|
|
3149
|
-
class RouterRejectionError extends Error {
|
|
3150
|
-
constructor(type) {
|
|
3151
|
-
super();
|
|
3152
|
-
__publicField(this, "type");
|
|
3153
|
-
this.type = type;
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
class UseRouteInvalidError extends Error {
|
|
3157
|
-
constructor(routeName, actualRouteName) {
|
|
3158
|
-
super(`useRoute called with incorrect route. Given ${routeName}, expected ${actualRouteName}`);
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
const routerInjectionKey = Symbol();
|
|
3162
|
-
function useRouter() {
|
|
3163
|
-
const router = inject(routerInjectionKey);
|
|
3164
|
-
if (!router) {
|
|
3165
|
-
throw new RouterNotInstalledError();
|
|
3166
|
-
}
|
|
3167
|
-
console.log([router]);
|
|
3168
|
-
return router;
|
|
3169
|
-
}
|
|
3170
|
-
function combineName(parentName, childName) {
|
|
3171
|
-
return [parentName, childName].filter((value) => !!value).join(".");
|
|
3172
|
-
}
|
|
3173
|
-
function useRoute(routeKey) {
|
|
3174
|
-
const router = useRouter();
|
|
3175
|
-
function checkRouteKeyIsValid() {
|
|
3176
|
-
if (!routeKey) {
|
|
3177
|
-
return;
|
|
3178
|
-
}
|
|
3179
|
-
const actualRouteKeys = router.route.matches.map((route) => route.name);
|
|
3180
|
-
const actualRouteKey = getRouteKey(actualRouteKeys);
|
|
3181
|
-
const routeKeyIsValid = actualRouteKey.includes(routeKey);
|
|
3182
|
-
if (!routeKeyIsValid) {
|
|
3183
|
-
throw new UseRouteInvalidError(routeKey, router.route.key);
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
watch(router.route, checkRouteKeyIsValid, { immediate: true, deep: true });
|
|
3187
|
-
return router.route;
|
|
3188
|
-
}
|
|
3189
|
-
function getRouteKey(names) {
|
|
3190
|
-
return names.reduce((ancestorNames, name) => {
|
|
3191
|
-
const previous = ancestorNames.pop();
|
|
3192
|
-
const next = name ? [combineName(previous, name)] : [];
|
|
3193
|
-
if (!previous) {
|
|
3194
|
-
return next;
|
|
3195
|
-
}
|
|
3196
|
-
return [
|
|
3197
|
-
...ancestorNames,
|
|
3198
|
-
previous,
|
|
3199
|
-
...next
|
|
3200
|
-
];
|
|
3201
|
-
}, []);
|
|
3202
|
-
}
|
|
3203
|
-
function useRouteParam(_route, _param, _defaultValue) {
|
|
3204
|
-
throw "not implemented";
|
|
3205
|
-
}
|
|
3206
|
-
function useRouteParamRaw(_route, _param, _defaultValue) {
|
|
3207
|
-
throw "not implemented";
|
|
3208
|
-
}
|
|
3209
|
-
const notFoundText = "Not Found";
|
|
3210
|
-
const NotFound = /* @__PURE__ */ defineComponent(() => {
|
|
3211
|
-
return () => h("h1", notFoundText);
|
|
3212
|
-
}, {
|
|
3213
|
-
name: "NotFound",
|
|
3214
|
-
props: []
|
|
3215
|
-
});
|
|
3216
|
-
const depthInjectionKey = Symbol();
|
|
3217
|
-
class InvalidRouteParamValueError extends Error {
|
|
3218
|
-
}
|
|
3219
|
-
function isNotConstructor(value) {
|
|
3220
|
-
return value !== String && value !== Boolean && value !== Number;
|
|
3221
|
-
}
|
|
3222
|
-
function isParamGetter(value) {
|
|
3223
|
-
return typeof value === "function" && isNotConstructor(value);
|
|
3224
|
-
}
|
|
3225
|
-
function isParamGetSet(value) {
|
|
3226
|
-
return typeof value === "object" && "get" in value && typeof value.get === "function" && "set" in value && typeof value.set === "function";
|
|
3227
|
-
}
|
|
3228
|
-
function isParentRoute(value) {
|
|
3229
|
-
return "children" in value;
|
|
3230
|
-
}
|
|
3231
|
-
function isUrl(value) {
|
|
3232
|
-
if (typeof value !== "string") {
|
|
3233
|
-
return false;
|
|
3234
|
-
}
|
|
3235
|
-
const regexPattern = /^(https?:\/\/|\/).*/g;
|
|
3236
|
-
return regexPattern.test(value);
|
|
3237
|
-
}
|
|
3238
|
-
const _hoisted_1$1 = ["href"];
|
|
3239
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3240
|
-
__name: "routerLink",
|
|
3241
|
-
props: {
|
|
3242
|
-
to: { type: [String, Function] },
|
|
3243
|
-
query: {},
|
|
3244
|
-
replace: { type: Boolean }
|
|
3245
|
-
},
|
|
3246
|
-
setup(__props) {
|
|
3247
|
-
const props = __props;
|
|
3248
|
-
const router = useRouter();
|
|
3249
|
-
const resolved = computed(() => {
|
|
3250
|
-
return isUrl(props.to) ? props.to : props.to(router.resolve);
|
|
3251
|
-
});
|
|
3252
|
-
const options = computed(() => {
|
|
3253
|
-
const { to, ...options2 } = props;
|
|
3254
|
-
return options2;
|
|
3255
|
-
});
|
|
3256
|
-
const route = computed(() => {
|
|
3257
|
-
var _a;
|
|
3258
|
-
return (_a = router.find(resolved.value, options.value)) == null ? void 0 : _a.matched;
|
|
3259
|
-
});
|
|
3260
|
-
const match = computed(() => !!route.value && router.route.matches.includes(readonly(route.value)));
|
|
3261
|
-
const exactMatch = computed(() => !!route.value && router.route.matched === route.value);
|
|
3262
|
-
const classes = computed(() => ({
|
|
3263
|
-
"router-link--match": match.value,
|
|
3264
|
-
"router-link--exact-match": exactMatch.value
|
|
3265
|
-
}));
|
|
3266
|
-
const isExternal = computed(() => {
|
|
3267
|
-
const { host } = new URL(resolved.value, window.location.origin);
|
|
3268
|
-
return host !== window.location.host;
|
|
3269
|
-
});
|
|
3270
|
-
function onClick(event) {
|
|
3271
|
-
event.preventDefault();
|
|
3272
|
-
router.push(resolved.value, options.value);
|
|
3273
|
-
}
|
|
3274
|
-
return (_ctx, _cache) => {
|
|
3275
|
-
return openBlock(), createElementBlock("a", {
|
|
3276
|
-
href: resolved.value,
|
|
3277
|
-
class: normalizeClass(classes.value),
|
|
3278
|
-
onClick
|
|
3279
|
-
}, [
|
|
3280
|
-
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ resolved: resolved.value, match: match.value, exactMatch: exactMatch.value, isExternal: isExternal.value })))
|
|
3281
|
-
], 10, _hoisted_1$1);
|
|
3282
|
-
};
|
|
3283
|
-
}
|
|
3284
|
-
});
|
|
3285
|
-
function useRouterDepth() {
|
|
3286
|
-
return inject(depthInjectionKey, 0);
|
|
3287
|
-
}
|
|
3288
|
-
const _hoisted_1 = { class: "router-view" };
|
|
3289
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3290
|
-
__name: "routerView",
|
|
3291
|
-
setup(__props) {
|
|
3292
|
-
const router = useRouter();
|
|
3293
|
-
const rejection = useRejection();
|
|
3294
|
-
const depth = useRouterDepth();
|
|
3295
|
-
const routerView = resolveComponent("RouterView", true);
|
|
3296
|
-
provide(depthInjectionKey, depth + 1);
|
|
3297
|
-
watch(router.route, (value) => console.log("router.route changed", value), { immediate: true });
|
|
3298
|
-
const component2 = computed(() => {
|
|
3299
|
-
console.log("triggered computed", JSON.stringify(router.route));
|
|
3300
|
-
const routeComponent = router.route.matches[depth].component;
|
|
3301
|
-
console.log(routeComponent);
|
|
3302
|
-
if (routeComponent) {
|
|
3303
|
-
if (typeof routeComponent === "function") {
|
|
3304
|
-
return /* @__PURE__ */ defineAsyncComponent(routeComponent);
|
|
3305
|
-
}
|
|
3306
|
-
return routeComponent;
|
|
3307
|
-
}
|
|
3308
|
-
return routerView;
|
|
3309
|
-
});
|
|
3310
|
-
return (_ctx, _cache) => {
|
|
3311
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
3312
|
-
unref(rejection) ? (openBlock(), createBlock(resolveDynamicComponent(unref(rejection).component), { key: 0 })) : (openBlock(), createBlock(resolveDynamicComponent(component2.value), { key: 1 }))
|
|
3313
|
-
]);
|
|
3314
|
-
};
|
|
3315
|
-
}
|
|
3316
|
-
});
|
|
3317
|
-
function asArray(value) {
|
|
3318
|
-
return Array.isArray(value) ? value : [value];
|
|
3319
|
-
}
|
|
3320
|
-
function createCurrentRoute(fallbackRoute) {
|
|
3321
|
-
const route = reactive(fallbackRoute);
|
|
3322
|
-
const updateRoute = (newRoute) => {
|
|
3323
|
-
route.matched = newRoute.matched;
|
|
3324
|
-
route.matches = newRoute.matches;
|
|
3325
|
-
route.key = newRoute.key;
|
|
3326
|
-
route.query = newRoute.query;
|
|
3327
|
-
route.params = newRoute.params;
|
|
3328
|
-
};
|
|
3329
|
-
return {
|
|
3330
|
-
route,
|
|
3331
|
-
updateRoute
|
|
3332
|
-
};
|
|
3333
|
-
}
|
|
3334
|
-
function createMaybeRelativeUrl(value) {
|
|
3335
|
-
const isRelative = !value.startsWith("http");
|
|
3336
|
-
return isRelative ? createRelativeUrl(value) : createAbsoluteUrl(value);
|
|
3337
|
-
}
|
|
3338
|
-
function createAbsoluteUrl(value) {
|
|
3339
|
-
const { protocol, host, pathname, search, searchParams, hash } = new URL(value, value);
|
|
3340
|
-
return {
|
|
3341
|
-
protocol,
|
|
3342
|
-
host,
|
|
3343
|
-
pathname,
|
|
3344
|
-
search,
|
|
3345
|
-
searchParams,
|
|
3346
|
-
hash
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
function createRelativeUrl(value) {
|
|
3350
|
-
const { pathname, search, searchParams, hash } = new URL(value, "https://localhost");
|
|
3351
|
-
return {
|
|
3352
|
-
pathname,
|
|
3353
|
-
search,
|
|
3354
|
-
searchParams,
|
|
3355
|
-
hash
|
|
3356
|
-
};
|
|
3357
|
-
}
|
|
3358
|
-
function createResolvedRouteQuery(query2) {
|
|
3359
|
-
const params = new URLSearchParams(query2);
|
|
3360
|
-
return {
|
|
3361
|
-
get: (key) => params.get(key),
|
|
3362
|
-
getAll: (key) => params.getAll(key)
|
|
3363
|
-
};
|
|
3364
|
-
}
|
|
3365
|
-
function stringHasValue(value) {
|
|
3366
|
-
return typeof value === "string" && value.length > 0;
|
|
3367
|
-
}
|
|
3368
|
-
function getParam(params, param) {
|
|
3369
|
-
return params[param] ?? String;
|
|
3370
|
-
}
|
|
3371
|
-
const optionalKey = Symbol();
|
|
3372
|
-
function isOptionalParam(param) {
|
|
3373
|
-
return optionalKey in param;
|
|
3374
|
-
}
|
|
3375
|
-
function optional(param) {
|
|
3376
|
-
return {
|
|
3377
|
-
[optionalKey]: true,
|
|
3378
|
-
get: (value) => {
|
|
3379
|
-
if (!stringHasValue(value)) {
|
|
3380
|
-
return void 0;
|
|
3381
|
-
}
|
|
3382
|
-
return getParamValue(value, param);
|
|
3383
|
-
},
|
|
3384
|
-
set: (value) => {
|
|
3385
|
-
if (!stringHasValue(value)) {
|
|
3386
|
-
return "";
|
|
3387
|
-
}
|
|
3388
|
-
return setParamValue(value, param);
|
|
3389
|
-
}
|
|
3390
|
-
};
|
|
3391
|
-
}
|
|
3392
|
-
const extras = {
|
|
3393
|
-
invalid: (message) => {
|
|
3394
|
-
throw new InvalidRouteParamValueError(message);
|
|
3395
|
-
}
|
|
3396
|
-
};
|
|
3397
|
-
const stringParam = {
|
|
3398
|
-
get: (value) => {
|
|
3399
|
-
return value;
|
|
3400
|
-
},
|
|
3401
|
-
set: (value, { invalid }) => {
|
|
3402
|
-
if (typeof value !== "string") {
|
|
3403
|
-
throw invalid();
|
|
3404
|
-
}
|
|
3405
|
-
return value;
|
|
3406
|
-
}
|
|
3407
|
-
};
|
|
3408
|
-
const booleanParam = {
|
|
3409
|
-
get: (value, { invalid }) => {
|
|
3410
|
-
if (value === "true") {
|
|
3411
|
-
return true;
|
|
3412
|
-
}
|
|
3413
|
-
if (value === "false") {
|
|
3414
|
-
return false;
|
|
3415
|
-
}
|
|
3416
|
-
throw invalid();
|
|
3417
|
-
},
|
|
3418
|
-
set: (value, { invalid }) => {
|
|
3419
|
-
if (typeof value !== "boolean") {
|
|
3420
|
-
throw invalid();
|
|
3421
|
-
}
|
|
3422
|
-
return value.toString();
|
|
3423
|
-
}
|
|
3424
|
-
};
|
|
3425
|
-
const numberParam = {
|
|
3426
|
-
get: (value, { invalid }) => {
|
|
3427
|
-
const number = Number(value);
|
|
3428
|
-
if (isNaN(number)) {
|
|
3429
|
-
throw invalid();
|
|
3430
|
-
}
|
|
3431
|
-
return number;
|
|
3432
|
-
},
|
|
3433
|
-
set: (value, { invalid }) => {
|
|
3434
|
-
if (typeof value !== "number") {
|
|
3435
|
-
throw invalid();
|
|
3436
|
-
}
|
|
3437
|
-
return value.toString();
|
|
3438
|
-
}
|
|
3439
|
-
};
|
|
3440
|
-
function getParamValue(value, param) {
|
|
3441
|
-
if (value === void 0) {
|
|
3442
|
-
if (isOptionalParam(param)) {
|
|
3443
|
-
return param.get(value, extras);
|
|
3444
|
-
}
|
|
3445
|
-
throw new InvalidRouteParamValueError();
|
|
3446
|
-
}
|
|
3447
|
-
if (param === String) {
|
|
3448
|
-
return stringParam.get(value, extras);
|
|
3449
|
-
}
|
|
3450
|
-
if (param === Boolean) {
|
|
3451
|
-
return booleanParam.get(value, extras);
|
|
3452
|
-
}
|
|
3453
|
-
if (param === Number) {
|
|
3454
|
-
return numberParam.get(value, extras);
|
|
3455
|
-
}
|
|
3456
|
-
if (isParamGetter(param)) {
|
|
3457
|
-
return param(value, extras);
|
|
3458
|
-
}
|
|
3459
|
-
if (isParamGetSet(param)) {
|
|
3460
|
-
return param.get(value, extras);
|
|
3461
|
-
}
|
|
3462
|
-
if (param instanceof RegExp) {
|
|
3463
|
-
if (param.test(value)) {
|
|
3464
|
-
return value;
|
|
3465
|
-
}
|
|
3466
|
-
throw new InvalidRouteParamValueError();
|
|
3467
|
-
}
|
|
3468
|
-
return value;
|
|
3469
|
-
}
|
|
3470
|
-
function setParamValue(value, param) {
|
|
3471
|
-
if (param === Boolean) {
|
|
3472
|
-
return booleanParam.set(value, extras);
|
|
3473
|
-
}
|
|
3474
|
-
if (param === Number) {
|
|
3475
|
-
return numberParam.set(value, extras);
|
|
3476
|
-
}
|
|
3477
|
-
if (isParamGetSet(param)) {
|
|
3478
|
-
return param.set(value, extras);
|
|
3479
|
-
}
|
|
3480
|
-
try {
|
|
3481
|
-
return value.toString();
|
|
3482
|
-
} catch (error) {
|
|
3483
|
-
throw new InvalidRouteParamValueError();
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
function generateRoutePathRegexPattern(route) {
|
|
3487
|
-
const routeRegex = replaceParamSyntaxWithCatchAlls(route.path.toString());
|
|
3488
|
-
return new RegExp(`^${routeRegex}$`, "i");
|
|
3489
|
-
}
|
|
3490
|
-
function generateRouteQueryRegexPatterns(route) {
|
|
3491
|
-
const queryParams = new URLSearchParams(route.query.toString());
|
|
3492
|
-
return Array.from(queryParams.entries()).map(([key, value]) => new RegExp(`${key}=${replaceParamSyntaxWithCatchAlls(value)}`, "i"));
|
|
3493
|
-
}
|
|
3494
|
-
function replaceParamSyntaxWithCatchAlls(value) {
|
|
3495
|
-
return [
|
|
3496
|
-
replaceOptionalParamSyntaxWithCatchAll,
|
|
3497
|
-
replaceRequiredParamSyntaxWithCatchAll
|
|
3498
|
-
].reduce((pattern, regexBuild) => {
|
|
3499
|
-
return regexBuild(pattern);
|
|
3500
|
-
}, value);
|
|
3501
|
-
}
|
|
3502
|
-
function replaceOptionalParamSyntaxWithCatchAll(value) {
|
|
3503
|
-
const optionalParamRegex = /(:\?[\w]+)(?=\W|$)/g;
|
|
3504
|
-
return value.replace(optionalParamRegex, "[^/]*");
|
|
3505
|
-
}
|
|
3506
|
-
function replaceRequiredParamSyntaxWithCatchAll(value) {
|
|
3507
|
-
const requiredParamRegex = /(:[\w]+)(?=\W|$)/g;
|
|
3508
|
-
return value.replace(requiredParamRegex, "[^/]+");
|
|
3509
|
-
}
|
|
3510
|
-
function getParamValueFromUrl(url, path2, paramName) {
|
|
3511
|
-
const regexPattern = getParamRegexPattern(path2, paramName);
|
|
3512
|
-
const [paramValue] = getCaptureGroups(url, regexPattern);
|
|
3513
|
-
return paramValue;
|
|
3514
|
-
}
|
|
3515
|
-
function setParamValueOnUrl(path2, paramReplace) {
|
|
3516
|
-
if (!paramReplace) {
|
|
3517
|
-
return path2;
|
|
3518
|
-
}
|
|
3519
|
-
const { name, param, value } = paramReplace;
|
|
3520
|
-
const regexPattern = getParamRegexPattern(path2, name);
|
|
3521
|
-
const captureGroups = getCaptureGroups(path2, regexPattern);
|
|
3522
|
-
return captureGroups.reduce((url, captureGroup) => {
|
|
3523
|
-
return url.replace(captureGroup, () => setParamValue(value, param));
|
|
3524
|
-
}, path2);
|
|
3525
|
-
}
|
|
3526
|
-
function getParamRegexPattern(path2, paramName) {
|
|
3527
|
-
const regexPattern = [
|
|
3528
|
-
replaceOptionalParamSyntaxWithCaptureGroup,
|
|
3529
|
-
replaceRequiredParamSyntaxWithCaptureGroup,
|
|
3530
|
-
replaceParamSyntaxWithCatchAlls
|
|
3531
|
-
].reduce((pattern, regexBuild) => {
|
|
3532
|
-
return regexBuild(pattern, paramName);
|
|
3533
|
-
}, path2);
|
|
3534
|
-
return new RegExp(regexPattern, "g");
|
|
3535
|
-
}
|
|
3536
|
-
function replaceOptionalParamSyntaxWithCaptureGroup(path2, paramName) {
|
|
3537
|
-
const optionalParamRegex = new RegExp(`(:\\?${paramName})(?=\\W|$)`, "g");
|
|
3538
|
-
return path2.replace(optionalParamRegex, "([^/]*)");
|
|
3539
|
-
}
|
|
3540
|
-
function replaceRequiredParamSyntaxWithCaptureGroup(path2, paramName) {
|
|
3541
|
-
const requiredParamRegex = new RegExp(`(:${paramName})(?=\\W|$)`, "g");
|
|
3542
|
-
return path2.replace(requiredParamRegex, "([^/]+)");
|
|
3543
|
-
}
|
|
3544
|
-
function getCaptureGroups(value, pattern) {
|
|
3545
|
-
const matches = Array.from(value.matchAll(pattern));
|
|
3546
|
-
return matches.flatMap(([, ...values]) => values.map((value2) => stringHasValue(value2) ? value2 : ""));
|
|
3547
|
-
}
|
|
3548
|
-
function withQuery(url, query2) {
|
|
3549
|
-
if (!query2) {
|
|
3550
|
-
return url;
|
|
3551
|
-
}
|
|
3552
|
-
if (Object.keys(query2).length === 0) {
|
|
3553
|
-
return url;
|
|
3554
|
-
}
|
|
3555
|
-
const queryString = new URLSearchParams(query2).toString();
|
|
3556
|
-
if (url.includes("?")) {
|
|
3557
|
-
return `${url}&${queryString}`;
|
|
3558
|
-
}
|
|
3559
|
-
return `${url}?${queryString}`;
|
|
3560
|
-
}
|
|
3561
|
-
function assembleUrl(route, options = {}) {
|
|
3562
|
-
const { params: paramValues = {}, query: queryValues } = options;
|
|
3563
|
-
const params = Object.entries({ ...route.pathParams, ...route.queryParams });
|
|
3564
|
-
const path2 = route.path.toString();
|
|
3565
|
-
const query2 = route.query.toString();
|
|
3566
|
-
const pathWithQuery = query2.length ? `${path2}?${query2}` : path2;
|
|
3567
|
-
const url = params.reduce((url2, [name, param]) => {
|
|
3568
|
-
return setParamValueOnUrl(url2, { name, param, value: paramValues[name] });
|
|
3569
|
-
}, pathWithQuery);
|
|
3570
|
-
return withQuery(url, queryValues);
|
|
3571
|
-
}
|
|
3572
|
-
function createRouterResolve(routes2) {
|
|
3573
|
-
return (source, paramsOrOptions, maybeOptions) => {
|
|
3574
|
-
if (isUrl(source)) {
|
|
3575
|
-
const options2 = paramsOrOptions ?? {};
|
|
3576
|
-
return withQuery(source, options2.query);
|
|
3577
|
-
}
|
|
3578
|
-
const params = paramsOrOptions ?? {};
|
|
3579
|
-
const options = maybeOptions ?? {};
|
|
3580
|
-
const match = routes2.find((route) => route.key === source);
|
|
3581
|
-
if (!match) {
|
|
3582
|
-
throw `Route not found: "${String(source)}"`;
|
|
3583
|
-
}
|
|
3584
|
-
if (match.matched.disabled) {
|
|
3585
|
-
throw `Route disabled: "${String(source)}"`;
|
|
3586
|
-
}
|
|
3587
|
-
const url = assembleUrl(match, {
|
|
3588
|
-
params,
|
|
3589
|
-
query: options.query
|
|
3590
|
-
});
|
|
3591
|
-
return url;
|
|
3592
|
-
};
|
|
3593
|
-
}
|
|
3594
|
-
const routeParamsAreValid = (route, url) => {
|
|
3595
|
-
try {
|
|
3596
|
-
getRouteParamValues(route, url);
|
|
3597
|
-
} catch {
|
|
3598
|
-
return false;
|
|
3599
|
-
}
|
|
3600
|
-
return true;
|
|
3601
|
-
};
|
|
3602
|
-
const getRouteParamValues = (route, url) => {
|
|
3603
|
-
const { pathname, search } = createMaybeRelativeUrl(url);
|
|
3604
|
-
return {
|
|
3605
|
-
...getRouteParams(route.pathParams, route.path.toString(), pathname),
|
|
3606
|
-
...getRouteParams(route.queryParams, route.query.toString(), search)
|
|
3607
|
-
};
|
|
3608
|
-
};
|
|
3609
|
-
const getRouteParams = (paramDefinitions, paramFormat, valueFromUrl) => {
|
|
3610
|
-
const params = {};
|
|
3611
|
-
for (const [key, param] of Object.entries(paramDefinitions)) {
|
|
3612
|
-
const stringValue = getParamValueFromUrl(valueFromUrl, paramFormat, key);
|
|
3613
|
-
const formattedValues = getParamValue(stringValue, param);
|
|
3614
|
-
params[key] = formattedValues;
|
|
3615
|
-
}
|
|
3616
|
-
return params;
|
|
3617
|
-
};
|
|
3618
|
-
const routePathMatches = (route, url) => {
|
|
3619
|
-
const { pathname } = createMaybeRelativeUrl(url);
|
|
3620
|
-
const pathPattern = generateRoutePathRegexPattern(route);
|
|
3621
|
-
return pathPattern.test(pathname);
|
|
3622
|
-
};
|
|
3623
|
-
const routeQueryMatches = (route, url) => {
|
|
3624
|
-
const { search } = createMaybeRelativeUrl(url);
|
|
3625
|
-
const queryPatterns = generateRouteQueryRegexPatterns(route);
|
|
3626
|
-
return queryPatterns.every((pattern) => pattern.test(search));
|
|
3627
|
-
};
|
|
3628
|
-
function getRouteScoreSortMethod(url) {
|
|
3629
|
-
const { searchParams: actualQuery } = createMaybeRelativeUrl(url);
|
|
3630
|
-
const sortBefore = -1;
|
|
3631
|
-
const sortAfter = 1;
|
|
3632
|
-
return (aRoute, bRoute) => {
|
|
3633
|
-
const aRouteQueryScore = countExpectedQueryKeys(aRoute, actualQuery);
|
|
3634
|
-
const bRouteQueryScore = countExpectedQueryKeys(bRoute, actualQuery);
|
|
3635
|
-
if (aRouteQueryScore > bRouteQueryScore) {
|
|
3636
|
-
return sortBefore;
|
|
3637
|
-
}
|
|
3638
|
-
if (aRouteQueryScore < bRouteQueryScore) {
|
|
3639
|
-
return sortAfter;
|
|
3640
|
-
}
|
|
3641
|
-
if (aRoute.depth > bRoute.depth) {
|
|
3642
|
-
return sortBefore;
|
|
3643
|
-
}
|
|
3644
|
-
if (aRoute.depth < bRoute.depth) {
|
|
3645
|
-
return sortAfter;
|
|
3646
|
-
}
|
|
3647
|
-
return 0;
|
|
3648
|
-
};
|
|
3649
|
-
}
|
|
3650
|
-
function countExpectedQueryKeys(route, actualQuery) {
|
|
3651
|
-
const expectedQuery = new URLSearchParams(route.query.toString());
|
|
3652
|
-
const expectedQueryKeys = Array.from(expectedQuery.keys());
|
|
3653
|
-
const missing = expectedQueryKeys.filter((expected) => !actualQuery.has(expected));
|
|
3654
|
-
return expectedQueryKeys.length - missing.length;
|
|
3655
|
-
}
|
|
3656
|
-
function getResolvedRouteForUrl(routes2, url) {
|
|
3657
|
-
const rules = [isNamedRoute, routePathMatches, routeQueryMatches, routeParamsAreValid];
|
|
3658
|
-
const sortByRouteScore = getRouteScoreSortMethod(url);
|
|
3659
|
-
const matches = routes2.filter((route2) => rules.every((test) => test(route2, url))).sort(sortByRouteScore);
|
|
3660
|
-
if (matches.length === 0) {
|
|
3661
|
-
return void 0;
|
|
3662
|
-
}
|
|
3663
|
-
const [route] = matches;
|
|
3664
|
-
const { search } = createMaybeRelativeUrl(url);
|
|
3665
|
-
const query2 = createResolvedRouteQuery(search);
|
|
3666
|
-
const params = getRouteParamValues(route, url);
|
|
3667
|
-
return {
|
|
3668
|
-
matched: route.matched,
|
|
3669
|
-
matches: route.matches,
|
|
3670
|
-
key: route.key,
|
|
3671
|
-
query: query2,
|
|
3672
|
-
params
|
|
3673
|
-
};
|
|
3674
|
-
}
|
|
3675
|
-
const isNamedRoute = (route) => {
|
|
3676
|
-
return "name" in route.matched && !!route.matched.name;
|
|
3677
|
-
};
|
|
3678
|
-
function createRouterFind(routes2) {
|
|
3679
|
-
return (source, params = {}) => {
|
|
3680
|
-
const resolve2 = createRouterResolve(routes2);
|
|
3681
|
-
const url = resolve2(source, params);
|
|
3682
|
-
return getResolvedRouteForUrl(routes2, url);
|
|
3683
|
-
};
|
|
3684
|
-
}
|
|
3685
|
-
function _extends() {
|
|
3686
|
-
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
3687
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
3688
|
-
var source = arguments[i];
|
|
3689
|
-
for (var key in source) {
|
|
3690
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3691
|
-
target[key] = source[key];
|
|
3692
|
-
}
|
|
3693
|
-
}
|
|
3694
|
-
}
|
|
3695
|
-
return target;
|
|
3696
|
-
};
|
|
3697
|
-
return _extends.apply(this, arguments);
|
|
3698
|
-
}
|
|
3699
|
-
var Action;
|
|
3700
|
-
(function(Action2) {
|
|
3701
|
-
Action2["Pop"] = "POP";
|
|
3702
|
-
Action2["Push"] = "PUSH";
|
|
3703
|
-
Action2["Replace"] = "REPLACE";
|
|
3704
|
-
})(Action || (Action = {}));
|
|
3705
|
-
var readOnly = process.env.NODE_ENV !== "production" ? function(obj) {
|
|
3706
|
-
return Object.freeze(obj);
|
|
3707
|
-
} : function(obj) {
|
|
3708
|
-
return obj;
|
|
3709
|
-
};
|
|
3710
|
-
function warning(cond, message) {
|
|
3711
|
-
if (!cond) {
|
|
3712
|
-
if (typeof console !== "undefined")
|
|
3713
|
-
console.warn(message);
|
|
3714
|
-
try {
|
|
3715
|
-
throw new Error(message);
|
|
3716
|
-
} catch (e) {
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
}
|
|
3720
|
-
var BeforeUnloadEventType = "beforeunload";
|
|
3721
|
-
var HashChangeEventType = "hashchange";
|
|
3722
|
-
var PopStateEventType = "popstate";
|
|
3723
|
-
function createBrowserHistory(options) {
|
|
3724
|
-
if (options === void 0) {
|
|
3725
|
-
options = {};
|
|
3726
|
-
}
|
|
3727
|
-
var _options = options, _options$window = _options.window, window2 = _options$window === void 0 ? document.defaultView : _options$window;
|
|
3728
|
-
var globalHistory = window2.history;
|
|
3729
|
-
function getIndexAndLocation() {
|
|
3730
|
-
var _window$location = window2.location, pathname = _window$location.pathname, search = _window$location.search, hash = _window$location.hash;
|
|
3731
|
-
var state = globalHistory.state || {};
|
|
3732
|
-
return [state.idx, readOnly({
|
|
3733
|
-
pathname,
|
|
3734
|
-
search,
|
|
3735
|
-
hash,
|
|
3736
|
-
state: state.usr || null,
|
|
3737
|
-
key: state.key || "default"
|
|
3738
|
-
})];
|
|
3739
|
-
}
|
|
3740
|
-
var blockedPopTx = null;
|
|
3741
|
-
function handlePop() {
|
|
3742
|
-
if (blockedPopTx) {
|
|
3743
|
-
blockers.call(blockedPopTx);
|
|
3744
|
-
blockedPopTx = null;
|
|
3745
|
-
} else {
|
|
3746
|
-
var nextAction = Action.Pop;
|
|
3747
|
-
var _getIndexAndLocation = getIndexAndLocation(), nextIndex = _getIndexAndLocation[0], nextLocation = _getIndexAndLocation[1];
|
|
3748
|
-
if (blockers.length) {
|
|
3749
|
-
if (nextIndex != null) {
|
|
3750
|
-
var delta = index - nextIndex;
|
|
3751
|
-
if (delta) {
|
|
3752
|
-
blockedPopTx = {
|
|
3753
|
-
action: nextAction,
|
|
3754
|
-
location: nextLocation,
|
|
3755
|
-
retry: function retry() {
|
|
3756
|
-
go(delta * -1);
|
|
3757
|
-
}
|
|
3758
|
-
};
|
|
3759
|
-
go(delta);
|
|
3760
|
-
}
|
|
3761
|
-
} else {
|
|
3762
|
-
process.env.NODE_ENV !== "production" ? warning(
|
|
3763
|
-
false,
|
|
3764
|
-
// TODO: Write up a doc that explains our blocking strategy in
|
|
3765
|
-
// detail and link to it here so people can understand better what
|
|
3766
|
-
// is going on and how to avoid it.
|
|
3767
|
-
"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
|
|
3768
|
-
) : void 0;
|
|
3769
|
-
}
|
|
3770
|
-
} else {
|
|
3771
|
-
applyTx(nextAction);
|
|
3772
|
-
}
|
|
3773
|
-
}
|
|
3774
|
-
}
|
|
3775
|
-
window2.addEventListener(PopStateEventType, handlePop);
|
|
3776
|
-
var action = Action.Pop;
|
|
3777
|
-
var _getIndexAndLocation2 = getIndexAndLocation(), index = _getIndexAndLocation2[0], location = _getIndexAndLocation2[1];
|
|
3778
|
-
var listeners = createEvents();
|
|
3779
|
-
var blockers = createEvents();
|
|
3780
|
-
if (index == null) {
|
|
3781
|
-
index = 0;
|
|
3782
|
-
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
3783
|
-
idx: index
|
|
3784
|
-
}), "");
|
|
3785
|
-
}
|
|
3786
|
-
function createHref(to) {
|
|
3787
|
-
return typeof to === "string" ? to : createPath(to);
|
|
3788
|
-
}
|
|
3789
|
-
function getNextLocation(to, state) {
|
|
3790
|
-
if (state === void 0) {
|
|
3791
|
-
state = null;
|
|
3792
|
-
}
|
|
3793
|
-
return readOnly(_extends({
|
|
3794
|
-
pathname: location.pathname,
|
|
3795
|
-
hash: "",
|
|
3796
|
-
search: ""
|
|
3797
|
-
}, typeof to === "string" ? parsePath(to) : to, {
|
|
3798
|
-
state,
|
|
3799
|
-
key: createKey()
|
|
3800
|
-
}));
|
|
3801
|
-
}
|
|
3802
|
-
function getHistoryStateAndUrl(nextLocation, index2) {
|
|
3803
|
-
return [{
|
|
3804
|
-
usr: nextLocation.state,
|
|
3805
|
-
key: nextLocation.key,
|
|
3806
|
-
idx: index2
|
|
3807
|
-
}, createHref(nextLocation)];
|
|
3808
|
-
}
|
|
3809
|
-
function allowTx(action2, location2, retry) {
|
|
3810
|
-
return !blockers.length || (blockers.call({
|
|
3811
|
-
action: action2,
|
|
3812
|
-
location: location2,
|
|
3813
|
-
retry
|
|
3814
|
-
}), false);
|
|
3815
|
-
}
|
|
3816
|
-
function applyTx(nextAction) {
|
|
3817
|
-
action = nextAction;
|
|
3818
|
-
var _getIndexAndLocation3 = getIndexAndLocation();
|
|
3819
|
-
index = _getIndexAndLocation3[0];
|
|
3820
|
-
location = _getIndexAndLocation3[1];
|
|
3821
|
-
listeners.call({
|
|
3822
|
-
action,
|
|
3823
|
-
location
|
|
3824
|
-
});
|
|
3825
|
-
}
|
|
3826
|
-
function push(to, state) {
|
|
3827
|
-
var nextAction = Action.Push;
|
|
3828
|
-
var nextLocation = getNextLocation(to, state);
|
|
3829
|
-
function retry() {
|
|
3830
|
-
push(to, state);
|
|
3831
|
-
}
|
|
3832
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
3833
|
-
var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1), historyState = _getHistoryStateAndUr[0], url = _getHistoryStateAndUr[1];
|
|
3834
|
-
try {
|
|
3835
|
-
globalHistory.pushState(historyState, "", url);
|
|
3836
|
-
} catch (error) {
|
|
3837
|
-
window2.location.assign(url);
|
|
3838
|
-
}
|
|
3839
|
-
applyTx(nextAction);
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
function replace(to, state) {
|
|
3843
|
-
var nextAction = Action.Replace;
|
|
3844
|
-
var nextLocation = getNextLocation(to, state);
|
|
3845
|
-
function retry() {
|
|
3846
|
-
replace(to, state);
|
|
3847
|
-
}
|
|
3848
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
3849
|
-
var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index), historyState = _getHistoryStateAndUr2[0], url = _getHistoryStateAndUr2[1];
|
|
3850
|
-
globalHistory.replaceState(historyState, "", url);
|
|
3851
|
-
applyTx(nextAction);
|
|
3852
|
-
}
|
|
3853
|
-
}
|
|
3854
|
-
function go(delta) {
|
|
3855
|
-
globalHistory.go(delta);
|
|
3856
|
-
}
|
|
3857
|
-
var history = {
|
|
3858
|
-
get action() {
|
|
3859
|
-
return action;
|
|
3860
|
-
},
|
|
3861
|
-
get location() {
|
|
3862
|
-
return location;
|
|
3863
|
-
},
|
|
3864
|
-
createHref,
|
|
3865
|
-
push,
|
|
3866
|
-
replace,
|
|
3867
|
-
go,
|
|
3868
|
-
back: function back() {
|
|
3869
|
-
go(-1);
|
|
3870
|
-
},
|
|
3871
|
-
forward: function forward() {
|
|
3872
|
-
go(1);
|
|
3873
|
-
},
|
|
3874
|
-
listen: function listen(listener) {
|
|
3875
|
-
return listeners.push(listener);
|
|
3876
|
-
},
|
|
3877
|
-
block: function block(blocker) {
|
|
3878
|
-
var unblock = blockers.push(blocker);
|
|
3879
|
-
if (blockers.length === 1) {
|
|
3880
|
-
window2.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
3881
|
-
}
|
|
3882
|
-
return function() {
|
|
3883
|
-
unblock();
|
|
3884
|
-
if (!blockers.length) {
|
|
3885
|
-
window2.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
3886
|
-
}
|
|
3887
|
-
};
|
|
3888
|
-
}
|
|
3889
|
-
};
|
|
3890
|
-
return history;
|
|
3891
|
-
}
|
|
3892
|
-
function createHashHistory(options) {
|
|
3893
|
-
if (options === void 0) {
|
|
3894
|
-
options = {};
|
|
3895
|
-
}
|
|
3896
|
-
var _options2 = options, _options2$window = _options2.window, window2 = _options2$window === void 0 ? document.defaultView : _options2$window;
|
|
3897
|
-
var globalHistory = window2.history;
|
|
3898
|
-
function getIndexAndLocation() {
|
|
3899
|
-
var _parsePath = parsePath(window2.location.hash.substr(1)), _parsePath$pathname = _parsePath.pathname, pathname = _parsePath$pathname === void 0 ? "/" : _parsePath$pathname, _parsePath$search = _parsePath.search, search = _parsePath$search === void 0 ? "" : _parsePath$search, _parsePath$hash = _parsePath.hash, hash = _parsePath$hash === void 0 ? "" : _parsePath$hash;
|
|
3900
|
-
var state = globalHistory.state || {};
|
|
3901
|
-
return [state.idx, readOnly({
|
|
3902
|
-
pathname,
|
|
3903
|
-
search,
|
|
3904
|
-
hash,
|
|
3905
|
-
state: state.usr || null,
|
|
3906
|
-
key: state.key || "default"
|
|
3907
|
-
})];
|
|
3908
|
-
}
|
|
3909
|
-
var blockedPopTx = null;
|
|
3910
|
-
function handlePop() {
|
|
3911
|
-
if (blockedPopTx) {
|
|
3912
|
-
blockers.call(blockedPopTx);
|
|
3913
|
-
blockedPopTx = null;
|
|
3914
|
-
} else {
|
|
3915
|
-
var nextAction = Action.Pop;
|
|
3916
|
-
var _getIndexAndLocation4 = getIndexAndLocation(), nextIndex = _getIndexAndLocation4[0], nextLocation = _getIndexAndLocation4[1];
|
|
3917
|
-
if (blockers.length) {
|
|
3918
|
-
if (nextIndex != null) {
|
|
3919
|
-
var delta = index - nextIndex;
|
|
3920
|
-
if (delta) {
|
|
3921
|
-
blockedPopTx = {
|
|
3922
|
-
action: nextAction,
|
|
3923
|
-
location: nextLocation,
|
|
3924
|
-
retry: function retry() {
|
|
3925
|
-
go(delta * -1);
|
|
3926
|
-
}
|
|
3927
|
-
};
|
|
3928
|
-
go(delta);
|
|
3929
|
-
}
|
|
3930
|
-
} else {
|
|
3931
|
-
process.env.NODE_ENV !== "production" ? warning(
|
|
3932
|
-
false,
|
|
3933
|
-
// TODO: Write up a doc that explains our blocking strategy in
|
|
3934
|
-
// detail and link to it here so people can understand better
|
|
3935
|
-
// what is going on and how to avoid it.
|
|
3936
|
-
"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
|
|
3937
|
-
) : void 0;
|
|
3938
|
-
}
|
|
3939
|
-
} else {
|
|
3940
|
-
applyTx(nextAction);
|
|
3941
|
-
}
|
|
3942
|
-
}
|
|
3943
|
-
}
|
|
3944
|
-
window2.addEventListener(PopStateEventType, handlePop);
|
|
3945
|
-
window2.addEventListener(HashChangeEventType, function() {
|
|
3946
|
-
var _getIndexAndLocation5 = getIndexAndLocation(), nextLocation = _getIndexAndLocation5[1];
|
|
3947
|
-
if (createPath(nextLocation) !== createPath(location)) {
|
|
3948
|
-
handlePop();
|
|
3949
|
-
}
|
|
3950
|
-
});
|
|
3951
|
-
var action = Action.Pop;
|
|
3952
|
-
var _getIndexAndLocation6 = getIndexAndLocation(), index = _getIndexAndLocation6[0], location = _getIndexAndLocation6[1];
|
|
3953
|
-
var listeners = createEvents();
|
|
3954
|
-
var blockers = createEvents();
|
|
3955
|
-
if (index == null) {
|
|
3956
|
-
index = 0;
|
|
3957
|
-
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
3958
|
-
idx: index
|
|
3959
|
-
}), "");
|
|
3960
|
-
}
|
|
3961
|
-
function getBaseHref() {
|
|
3962
|
-
var base = document.querySelector("base");
|
|
3963
|
-
var href = "";
|
|
3964
|
-
if (base && base.getAttribute("href")) {
|
|
3965
|
-
var url = window2.location.href;
|
|
3966
|
-
var hashIndex = url.indexOf("#");
|
|
3967
|
-
href = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
3968
|
-
}
|
|
3969
|
-
return href;
|
|
3970
|
-
}
|
|
3971
|
-
function createHref(to) {
|
|
3972
|
-
return getBaseHref() + "#" + (typeof to === "string" ? to : createPath(to));
|
|
3973
|
-
}
|
|
3974
|
-
function getNextLocation(to, state) {
|
|
3975
|
-
if (state === void 0) {
|
|
3976
|
-
state = null;
|
|
3977
|
-
}
|
|
3978
|
-
return readOnly(_extends({
|
|
3979
|
-
pathname: location.pathname,
|
|
3980
|
-
hash: "",
|
|
3981
|
-
search: ""
|
|
3982
|
-
}, typeof to === "string" ? parsePath(to) : to, {
|
|
3983
|
-
state,
|
|
3984
|
-
key: createKey()
|
|
3985
|
-
}));
|
|
3986
|
-
}
|
|
3987
|
-
function getHistoryStateAndUrl(nextLocation, index2) {
|
|
3988
|
-
return [{
|
|
3989
|
-
usr: nextLocation.state,
|
|
3990
|
-
key: nextLocation.key,
|
|
3991
|
-
idx: index2
|
|
3992
|
-
}, createHref(nextLocation)];
|
|
3993
|
-
}
|
|
3994
|
-
function allowTx(action2, location2, retry) {
|
|
3995
|
-
return !blockers.length || (blockers.call({
|
|
3996
|
-
action: action2,
|
|
3997
|
-
location: location2,
|
|
3998
|
-
retry
|
|
3999
|
-
}), false);
|
|
4000
|
-
}
|
|
4001
|
-
function applyTx(nextAction) {
|
|
4002
|
-
action = nextAction;
|
|
4003
|
-
var _getIndexAndLocation7 = getIndexAndLocation();
|
|
4004
|
-
index = _getIndexAndLocation7[0];
|
|
4005
|
-
location = _getIndexAndLocation7[1];
|
|
4006
|
-
listeners.call({
|
|
4007
|
-
action,
|
|
4008
|
-
location
|
|
4009
|
-
});
|
|
4010
|
-
}
|
|
4011
|
-
function push(to, state) {
|
|
4012
|
-
var nextAction = Action.Push;
|
|
4013
|
-
var nextLocation = getNextLocation(to, state);
|
|
4014
|
-
function retry() {
|
|
4015
|
-
push(to, state);
|
|
4016
|
-
}
|
|
4017
|
-
process.env.NODE_ENV !== "production" ? warning(nextLocation.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")") : void 0;
|
|
4018
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
4019
|
-
var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1), historyState = _getHistoryStateAndUr3[0], url = _getHistoryStateAndUr3[1];
|
|
4020
|
-
try {
|
|
4021
|
-
globalHistory.pushState(historyState, "", url);
|
|
4022
|
-
} catch (error) {
|
|
4023
|
-
window2.location.assign(url);
|
|
4024
|
-
}
|
|
4025
|
-
applyTx(nextAction);
|
|
4026
|
-
}
|
|
4027
|
-
}
|
|
4028
|
-
function replace(to, state) {
|
|
4029
|
-
var nextAction = Action.Replace;
|
|
4030
|
-
var nextLocation = getNextLocation(to, state);
|
|
4031
|
-
function retry() {
|
|
4032
|
-
replace(to, state);
|
|
4033
|
-
}
|
|
4034
|
-
process.env.NODE_ENV !== "production" ? warning(nextLocation.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(to) + ")") : void 0;
|
|
4035
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
4036
|
-
var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index), historyState = _getHistoryStateAndUr4[0], url = _getHistoryStateAndUr4[1];
|
|
4037
|
-
globalHistory.replaceState(historyState, "", url);
|
|
4038
|
-
applyTx(nextAction);
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
function go(delta) {
|
|
4042
|
-
globalHistory.go(delta);
|
|
4043
|
-
}
|
|
4044
|
-
var history = {
|
|
4045
|
-
get action() {
|
|
4046
|
-
return action;
|
|
4047
|
-
},
|
|
4048
|
-
get location() {
|
|
4049
|
-
return location;
|
|
4050
|
-
},
|
|
4051
|
-
createHref,
|
|
4052
|
-
push,
|
|
4053
|
-
replace,
|
|
4054
|
-
go,
|
|
4055
|
-
back: function back() {
|
|
4056
|
-
go(-1);
|
|
4057
|
-
},
|
|
4058
|
-
forward: function forward() {
|
|
4059
|
-
go(1);
|
|
4060
|
-
},
|
|
4061
|
-
listen: function listen(listener) {
|
|
4062
|
-
return listeners.push(listener);
|
|
4063
|
-
},
|
|
4064
|
-
block: function block(blocker) {
|
|
4065
|
-
var unblock = blockers.push(blocker);
|
|
4066
|
-
if (blockers.length === 1) {
|
|
4067
|
-
window2.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
4068
|
-
}
|
|
4069
|
-
return function() {
|
|
4070
|
-
unblock();
|
|
4071
|
-
if (!blockers.length) {
|
|
4072
|
-
window2.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
4073
|
-
}
|
|
4074
|
-
};
|
|
4075
|
-
}
|
|
4076
|
-
};
|
|
4077
|
-
return history;
|
|
4078
|
-
}
|
|
4079
|
-
function createMemoryHistory(options) {
|
|
4080
|
-
if (options === void 0) {
|
|
4081
|
-
options = {};
|
|
4082
|
-
}
|
|
4083
|
-
var _options3 = options, _options3$initialEntr = _options3.initialEntries, initialEntries = _options3$initialEntr === void 0 ? ["/"] : _options3$initialEntr, initialIndex = _options3.initialIndex;
|
|
4084
|
-
var entries = initialEntries.map(function(entry) {
|
|
4085
|
-
var location2 = readOnly(_extends({
|
|
4086
|
-
pathname: "/",
|
|
4087
|
-
search: "",
|
|
4088
|
-
hash: "",
|
|
4089
|
-
state: null,
|
|
4090
|
-
key: createKey()
|
|
4091
|
-
}, typeof entry === "string" ? parsePath(entry) : entry));
|
|
4092
|
-
process.env.NODE_ENV !== "production" ? warning(location2.pathname.charAt(0) === "/", "Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: " + JSON.stringify(entry) + ")") : void 0;
|
|
4093
|
-
return location2;
|
|
4094
|
-
});
|
|
4095
|
-
var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);
|
|
4096
|
-
var action = Action.Pop;
|
|
4097
|
-
var location = entries[index];
|
|
4098
|
-
var listeners = createEvents();
|
|
4099
|
-
var blockers = createEvents();
|
|
4100
|
-
function createHref(to) {
|
|
4101
|
-
return typeof to === "string" ? to : createPath(to);
|
|
4102
|
-
}
|
|
4103
|
-
function getNextLocation(to, state) {
|
|
4104
|
-
if (state === void 0) {
|
|
4105
|
-
state = null;
|
|
4106
|
-
}
|
|
4107
|
-
return readOnly(_extends({
|
|
4108
|
-
pathname: location.pathname,
|
|
4109
|
-
search: "",
|
|
4110
|
-
hash: ""
|
|
4111
|
-
}, typeof to === "string" ? parsePath(to) : to, {
|
|
4112
|
-
state,
|
|
4113
|
-
key: createKey()
|
|
4114
|
-
}));
|
|
4115
|
-
}
|
|
4116
|
-
function allowTx(action2, location2, retry) {
|
|
4117
|
-
return !blockers.length || (blockers.call({
|
|
4118
|
-
action: action2,
|
|
4119
|
-
location: location2,
|
|
4120
|
-
retry
|
|
4121
|
-
}), false);
|
|
4122
|
-
}
|
|
4123
|
-
function applyTx(nextAction, nextLocation) {
|
|
4124
|
-
action = nextAction;
|
|
4125
|
-
location = nextLocation;
|
|
4126
|
-
listeners.call({
|
|
4127
|
-
action,
|
|
4128
|
-
location
|
|
4129
|
-
});
|
|
4130
|
-
}
|
|
4131
|
-
function push(to, state) {
|
|
4132
|
-
var nextAction = Action.Push;
|
|
4133
|
-
var nextLocation = getNextLocation(to, state);
|
|
4134
|
-
function retry() {
|
|
4135
|
-
push(to, state);
|
|
4136
|
-
}
|
|
4137
|
-
process.env.NODE_ENV !== "production" ? warning(location.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.push(" + JSON.stringify(to) + ")") : void 0;
|
|
4138
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
4139
|
-
index += 1;
|
|
4140
|
-
entries.splice(index, entries.length, nextLocation);
|
|
4141
|
-
applyTx(nextAction, nextLocation);
|
|
4142
|
-
}
|
|
4143
|
-
}
|
|
4144
|
-
function replace(to, state) {
|
|
4145
|
-
var nextAction = Action.Replace;
|
|
4146
|
-
var nextLocation = getNextLocation(to, state);
|
|
4147
|
-
function retry() {
|
|
4148
|
-
replace(to, state);
|
|
4149
|
-
}
|
|
4150
|
-
process.env.NODE_ENV !== "production" ? warning(location.pathname.charAt(0) === "/", "Relative pathnames are not supported in memory history.replace(" + JSON.stringify(to) + ")") : void 0;
|
|
4151
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
4152
|
-
entries[index] = nextLocation;
|
|
4153
|
-
applyTx(nextAction, nextLocation);
|
|
4154
|
-
}
|
|
4155
|
-
}
|
|
4156
|
-
function go(delta) {
|
|
4157
|
-
var nextIndex = clamp(index + delta, 0, entries.length - 1);
|
|
4158
|
-
var nextAction = Action.Pop;
|
|
4159
|
-
var nextLocation = entries[nextIndex];
|
|
4160
|
-
function retry() {
|
|
4161
|
-
go(delta);
|
|
4162
|
-
}
|
|
4163
|
-
if (allowTx(nextAction, nextLocation, retry)) {
|
|
4164
|
-
index = nextIndex;
|
|
4165
|
-
applyTx(nextAction, nextLocation);
|
|
4166
|
-
}
|
|
4167
|
-
}
|
|
4168
|
-
var history = {
|
|
4169
|
-
get index() {
|
|
4170
|
-
return index;
|
|
4171
|
-
},
|
|
4172
|
-
get action() {
|
|
4173
|
-
return action;
|
|
4174
|
-
},
|
|
4175
|
-
get location() {
|
|
4176
|
-
return location;
|
|
4177
|
-
},
|
|
4178
|
-
createHref,
|
|
4179
|
-
push,
|
|
4180
|
-
replace,
|
|
4181
|
-
go,
|
|
4182
|
-
back: function back() {
|
|
4183
|
-
go(-1);
|
|
4184
|
-
},
|
|
4185
|
-
forward: function forward() {
|
|
4186
|
-
go(1);
|
|
4187
|
-
},
|
|
4188
|
-
listen: function listen(listener) {
|
|
4189
|
-
return listeners.push(listener);
|
|
4190
|
-
},
|
|
4191
|
-
block: function block(blocker) {
|
|
4192
|
-
return blockers.push(blocker);
|
|
4193
|
-
}
|
|
4194
|
-
};
|
|
4195
|
-
return history;
|
|
4196
|
-
}
|
|
4197
|
-
function clamp(n, lowerBound, upperBound) {
|
|
4198
|
-
return Math.min(Math.max(n, lowerBound), upperBound);
|
|
4199
|
-
}
|
|
4200
|
-
function promptBeforeUnload(event) {
|
|
4201
|
-
event.preventDefault();
|
|
4202
|
-
event.returnValue = "";
|
|
4203
|
-
}
|
|
4204
|
-
function createEvents() {
|
|
4205
|
-
var handlers = [];
|
|
4206
|
-
return {
|
|
4207
|
-
get length() {
|
|
4208
|
-
return handlers.length;
|
|
4209
|
-
},
|
|
4210
|
-
push: function push(fn) {
|
|
4211
|
-
handlers.push(fn);
|
|
4212
|
-
return function() {
|
|
4213
|
-
handlers = handlers.filter(function(handler) {
|
|
4214
|
-
return handler !== fn;
|
|
4215
|
-
});
|
|
4216
|
-
};
|
|
4217
|
-
},
|
|
4218
|
-
call: function call(arg) {
|
|
4219
|
-
handlers.forEach(function(fn) {
|
|
4220
|
-
return fn && fn(arg);
|
|
4221
|
-
});
|
|
4222
|
-
}
|
|
4223
|
-
};
|
|
4224
|
-
}
|
|
4225
|
-
function createKey() {
|
|
4226
|
-
return Math.random().toString(36).substr(2, 8);
|
|
4227
|
-
}
|
|
4228
|
-
function createPath(_ref) {
|
|
4229
|
-
var _ref$pathname = _ref.pathname, pathname = _ref$pathname === void 0 ? "/" : _ref$pathname, _ref$search = _ref.search, search = _ref$search === void 0 ? "" : _ref$search, _ref$hash = _ref.hash, hash = _ref$hash === void 0 ? "" : _ref$hash;
|
|
4230
|
-
if (search && search !== "?")
|
|
4231
|
-
pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
4232
|
-
if (hash && hash !== "#")
|
|
4233
|
-
pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
4234
|
-
return pathname;
|
|
4235
|
-
}
|
|
4236
|
-
function parsePath(path2) {
|
|
4237
|
-
var parsedPath = {};
|
|
4238
|
-
if (path2) {
|
|
4239
|
-
var hashIndex = path2.indexOf("#");
|
|
4240
|
-
if (hashIndex >= 0) {
|
|
4241
|
-
parsedPath.hash = path2.substr(hashIndex);
|
|
4242
|
-
path2 = path2.substr(0, hashIndex);
|
|
4243
|
-
}
|
|
4244
|
-
var searchIndex = path2.indexOf("?");
|
|
4245
|
-
if (searchIndex >= 0) {
|
|
4246
|
-
parsedPath.search = path2.substr(searchIndex);
|
|
4247
|
-
path2 = path2.substr(0, searchIndex);
|
|
4248
|
-
}
|
|
4249
|
-
if (path2) {
|
|
4250
|
-
parsedPath.pathname = path2;
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
return parsedPath;
|
|
4254
|
-
}
|
|
4255
|
-
function isBrowser() {
|
|
4256
|
-
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4257
|
-
}
|
|
4258
|
-
function createRouterHistory({ mode } = {}) {
|
|
4259
|
-
const history = createHistory(mode);
|
|
4260
|
-
const update = (url, options) => {
|
|
4261
|
-
if (options == null ? void 0 : options.replace) {
|
|
4262
|
-
return history.replace(url);
|
|
4263
|
-
}
|
|
4264
|
-
history.push(url);
|
|
4265
|
-
};
|
|
4266
|
-
const refresh = () => {
|
|
4267
|
-
const url = createPath(history.location);
|
|
4268
|
-
return history.replace(url);
|
|
4269
|
-
};
|
|
4270
|
-
return {
|
|
4271
|
-
forward: history.forward,
|
|
4272
|
-
back: history.back,
|
|
4273
|
-
go: history.go,
|
|
4274
|
-
update,
|
|
4275
|
-
refresh
|
|
4276
|
-
};
|
|
4277
|
-
}
|
|
4278
|
-
function createHistory(mode = "auto") {
|
|
4279
|
-
switch (mode) {
|
|
4280
|
-
case "auto":
|
|
4281
|
-
return isBrowser() ? createBrowserHistory() : createMemoryHistory();
|
|
4282
|
-
case "browser":
|
|
4283
|
-
return createBrowserHistory();
|
|
4284
|
-
case "memory":
|
|
4285
|
-
return createMemoryHistory();
|
|
4286
|
-
case "hash":
|
|
4287
|
-
return createHashHistory();
|
|
4288
|
-
default:
|
|
4289
|
-
const exhaustive = mode;
|
|
4290
|
-
throw new Error(`createHistory missing case for mode: ${exhaustive}`);
|
|
4291
|
-
}
|
|
4292
|
-
}
|
|
4293
|
-
class RouteHooks {
|
|
4294
|
-
constructor() {
|
|
4295
|
-
__publicField(this, "onBeforeRouteEnter", /* @__PURE__ */ new Set());
|
|
4296
|
-
__publicField(this, "onBeforeRouteUpdate", /* @__PURE__ */ new Set());
|
|
4297
|
-
__publicField(this, "onBeforeRouteLeave", /* @__PURE__ */ new Set());
|
|
4298
|
-
__publicField(this, "onAfterRouteEnter", /* @__PURE__ */ new Set());
|
|
4299
|
-
__publicField(this, "onAfterRouteUpdate", /* @__PURE__ */ new Set());
|
|
4300
|
-
__publicField(this, "onAfterRouteLeave", /* @__PURE__ */ new Set());
|
|
4301
|
-
}
|
|
4302
|
-
}
|
|
4303
|
-
function getBeforeRouteHooksFromRoutes(to, from) {
|
|
4304
|
-
const hooks = new RouteHooks();
|
|
4305
|
-
to.matches.forEach((route, depth) => {
|
|
4306
|
-
if (route.onBeforeRouteEnter && isRouteEnter(to, from, depth)) {
|
|
4307
|
-
asArray(route.onBeforeRouteEnter).forEach((hook) => hooks.onBeforeRouteEnter.add(hook));
|
|
4308
|
-
}
|
|
4309
|
-
if (route.onBeforeRouteUpdate && isRouteUpdate(to, from, depth)) {
|
|
4310
|
-
asArray(route.onBeforeRouteUpdate).forEach((hook) => hooks.onBeforeRouteUpdate.add(hook));
|
|
4311
|
-
}
|
|
4312
|
-
});
|
|
4313
|
-
from.matches.forEach((route, depth) => {
|
|
4314
|
-
if (route.onBeforeRouteLeave && isRouteLeave(to, from, depth)) {
|
|
4315
|
-
asArray(route.onBeforeRouteLeave).forEach((hook) => hooks.onBeforeRouteLeave.add(hook));
|
|
4316
|
-
}
|
|
4317
|
-
});
|
|
4318
|
-
return hooks;
|
|
4319
|
-
}
|
|
4320
|
-
function getAfterRouteHooksFromRoutes(to, from) {
|
|
4321
|
-
const hooks = new RouteHooks();
|
|
4322
|
-
to.matches.forEach((route, depth) => {
|
|
4323
|
-
if (route.onAfterRouteEnter && isRouteEnter(to, from, depth)) {
|
|
4324
|
-
asArray(route.onAfterRouteEnter).forEach((hook) => hooks.onAfterRouteEnter.add(hook));
|
|
4325
|
-
}
|
|
4326
|
-
if (route.onAfterRouteUpdate && isRouteUpdate(to, from, depth)) {
|
|
4327
|
-
asArray(route.onAfterRouteUpdate).forEach((hook) => hooks.onAfterRouteUpdate.add(hook));
|
|
4328
|
-
}
|
|
4329
|
-
});
|
|
4330
|
-
from.matches.forEach((route, depth) => {
|
|
4331
|
-
if (route.onAfterRouteLeave && isRouteLeave(to, from, depth)) {
|
|
4332
|
-
asArray(route.onAfterRouteLeave).forEach((hook) => hooks.onAfterRouteLeave.add(hook));
|
|
4333
|
-
}
|
|
4334
|
-
});
|
|
4335
|
-
return hooks;
|
|
4336
|
-
}
|
|
4337
|
-
function createRouteHookRunners() {
|
|
4338
|
-
const reject = (type) => {
|
|
4339
|
-
throw new RouterRejectionError(type);
|
|
4340
|
-
};
|
|
4341
|
-
const push = (...parameters) => {
|
|
4342
|
-
throw new RouterPushError(parameters);
|
|
4343
|
-
};
|
|
4344
|
-
const replace = (source, paramsOrOptions, maybeOptions) => {
|
|
4345
|
-
if (isUrl(source)) {
|
|
4346
|
-
const options2 = paramsOrOptions ?? {};
|
|
4347
|
-
throw new RouterPushError([source, { ...options2, replace: true }]);
|
|
4348
|
-
}
|
|
4349
|
-
const params = paramsOrOptions;
|
|
4350
|
-
const options = maybeOptions ?? {};
|
|
4351
|
-
throw new RouterPushError([source, params, { ...options, replace: true }]);
|
|
4352
|
-
};
|
|
4353
|
-
const abort = () => {
|
|
4354
|
-
throw new NavigationAbortError();
|
|
4355
|
-
};
|
|
4356
|
-
async function runBeforeRouteHooks({ to, from, hooks }) {
|
|
4357
|
-
const { global: global2, component: component2 } = hooks;
|
|
4358
|
-
const route = getBeforeRouteHooksFromRoutes(to, from);
|
|
4359
|
-
const allHooks = [
|
|
4360
|
-
...global2.onBeforeRouteEnter,
|
|
4361
|
-
...route.onBeforeRouteEnter,
|
|
4362
|
-
...global2.onBeforeRouteUpdate,
|
|
4363
|
-
...route.onBeforeRouteUpdate,
|
|
4364
|
-
...component2.onBeforeRouteUpdate,
|
|
4365
|
-
...global2.onBeforeRouteLeave,
|
|
4366
|
-
...route.onBeforeRouteLeave,
|
|
4367
|
-
...component2.onBeforeRouteLeave
|
|
4368
|
-
];
|
|
4369
|
-
try {
|
|
4370
|
-
const results = allHooks.map((callback) => callback(to, {
|
|
4371
|
-
from,
|
|
4372
|
-
reject,
|
|
4373
|
-
push,
|
|
4374
|
-
replace,
|
|
4375
|
-
abort
|
|
4376
|
-
}));
|
|
4377
|
-
await Promise.all(results);
|
|
4378
|
-
} catch (error) {
|
|
4379
|
-
if (error instanceof RouterPushError) {
|
|
4380
|
-
return {
|
|
4381
|
-
status: "PUSH",
|
|
4382
|
-
to: error.to
|
|
4383
|
-
};
|
|
4384
|
-
}
|
|
4385
|
-
if (error instanceof RouterRejectionError) {
|
|
4386
|
-
return {
|
|
4387
|
-
status: "REJECT",
|
|
4388
|
-
type: error.type
|
|
4389
|
-
};
|
|
4390
|
-
}
|
|
4391
|
-
if (error instanceof NavigationAbortError) {
|
|
4392
|
-
return {
|
|
4393
|
-
status: "ABORT"
|
|
4394
|
-
};
|
|
4395
|
-
}
|
|
4396
|
-
throw error;
|
|
4397
|
-
}
|
|
4398
|
-
return {
|
|
4399
|
-
status: "SUCCESS"
|
|
4400
|
-
};
|
|
4401
|
-
}
|
|
4402
|
-
async function runAfterRouteHooks({ to, from, hooks }) {
|
|
4403
|
-
const { global: global2, component: component2 } = hooks;
|
|
4404
|
-
const route = getAfterRouteHooksFromRoutes(to, from);
|
|
4405
|
-
const allHooks = [
|
|
4406
|
-
...component2.onAfterRouteLeave,
|
|
4407
|
-
...route.onAfterRouteLeave,
|
|
4408
|
-
...global2.onAfterRouteLeave,
|
|
4409
|
-
...component2.onAfterRouteUpdate,
|
|
4410
|
-
...route.onAfterRouteUpdate,
|
|
4411
|
-
...global2.onAfterRouteUpdate,
|
|
4412
|
-
...component2.onAfterRouteEnter,
|
|
4413
|
-
...route.onAfterRouteEnter,
|
|
4414
|
-
...global2.onAfterRouteEnter
|
|
4415
|
-
];
|
|
4416
|
-
try {
|
|
4417
|
-
const results = allHooks.map((callback) => callback(to, {
|
|
4418
|
-
from,
|
|
4419
|
-
reject,
|
|
4420
|
-
push,
|
|
4421
|
-
replace
|
|
4422
|
-
}));
|
|
4423
|
-
await Promise.all(results);
|
|
4424
|
-
} catch (error) {
|
|
4425
|
-
if (error instanceof RouterPushError) {
|
|
4426
|
-
return {
|
|
4427
|
-
status: "PUSH",
|
|
4428
|
-
to: error.to
|
|
4429
|
-
};
|
|
4430
|
-
}
|
|
4431
|
-
if (error instanceof RouterRejectionError) {
|
|
4432
|
-
return {
|
|
4433
|
-
status: "REJECT",
|
|
4434
|
-
type: error.type
|
|
4435
|
-
};
|
|
4436
|
-
}
|
|
4437
|
-
throw error;
|
|
4438
|
-
}
|
|
4439
|
-
return {
|
|
4440
|
-
status: "SUCCESS"
|
|
4441
|
-
};
|
|
4442
|
-
}
|
|
4443
|
-
return {
|
|
4444
|
-
runBeforeRouteHooks,
|
|
4445
|
-
runAfterRouteHooks
|
|
4446
|
-
};
|
|
4447
|
-
}
|
|
4448
|
-
const isRouteEnter = (to, from, depth) => {
|
|
4449
|
-
const toMatches = to.matches;
|
|
4450
|
-
const fromMatches = (from == null ? void 0 : from.matches) ?? [];
|
|
4451
|
-
return toMatches.length < depth || toMatches[depth] !== fromMatches[depth];
|
|
4452
|
-
};
|
|
4453
|
-
const isRouteLeave = (to, from, depth) => {
|
|
4454
|
-
const toMatches = to.matches;
|
|
4455
|
-
const fromMatches = (from == null ? void 0 : from.matches) ?? [];
|
|
4456
|
-
return toMatches.length < depth || toMatches[depth] !== fromMatches[depth];
|
|
4457
|
-
};
|
|
4458
|
-
const isRouteUpdate = (to, from, depth) => {
|
|
4459
|
-
return to.matches[depth] === (from == null ? void 0 : from.matches[depth]);
|
|
4460
|
-
};
|
|
4461
|
-
function getRouteHookCondition(lifecycle) {
|
|
4462
|
-
switch (lifecycle) {
|
|
4463
|
-
case "onBeforeRouteEnter":
|
|
4464
|
-
case "onAfterRouteEnter":
|
|
4465
|
-
return isRouteEnter;
|
|
4466
|
-
case "onBeforeRouteUpdate":
|
|
4467
|
-
case "onAfterRouteUpdate":
|
|
4468
|
-
return isRouteUpdate;
|
|
4469
|
-
case "onBeforeRouteLeave":
|
|
4470
|
-
case "onAfterRouteLeave":
|
|
4471
|
-
return isRouteLeave;
|
|
4472
|
-
default:
|
|
4473
|
-
throw new Error(`No route hook condition for lifecycle: ${lifecycle}`);
|
|
4474
|
-
}
|
|
4475
|
-
}
|
|
4476
|
-
class RouteHookStore {
|
|
4477
|
-
constructor() {
|
|
4478
|
-
__publicField(this, "global", new RouteHooks());
|
|
4479
|
-
__publicField(this, "component", new RouteHooks());
|
|
4480
|
-
}
|
|
4481
|
-
addBeforeRouteHook({ lifecycle, timing, depth, hook }) {
|
|
4482
|
-
const condition = getRouteHookCondition(lifecycle);
|
|
4483
|
-
const store = this[timing][lifecycle];
|
|
4484
|
-
const wrapped = (to, context) => {
|
|
4485
|
-
if (!condition(to, context.from, depth)) {
|
|
4486
|
-
return;
|
|
4487
|
-
}
|
|
4488
|
-
return hook(to, context);
|
|
4489
|
-
};
|
|
4490
|
-
store.add(wrapped);
|
|
4491
|
-
return () => store.delete(wrapped);
|
|
4492
|
-
}
|
|
4493
|
-
addAfterRouteHook({ lifecycle, timing, depth, hook }) {
|
|
4494
|
-
const condition = getRouteHookCondition(lifecycle);
|
|
4495
|
-
const store = this[timing][lifecycle];
|
|
4496
|
-
const wrapped = (to, context) => {
|
|
4497
|
-
if (!condition(to, context.from, depth)) {
|
|
4498
|
-
return;
|
|
4499
|
-
}
|
|
4500
|
-
return hook(to, context);
|
|
4501
|
-
};
|
|
4502
|
-
store.add(wrapped);
|
|
4503
|
-
return () => store.delete(wrapped);
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
|
-
const routeHookStoreKey = Symbol();
|
|
4507
|
-
function createRouterHooks() {
|
|
4508
|
-
const hooks = new RouteHookStore();
|
|
4509
|
-
const onBeforeRouteEnter = (hook) => {
|
|
4510
|
-
return hooks.addBeforeRouteHook({ lifecycle: "onBeforeRouteEnter", hook, timing: "global", depth: 0 });
|
|
4511
|
-
};
|
|
4512
|
-
const onBeforeRouteUpdate = (hook) => {
|
|
4513
|
-
return hooks.addBeforeRouteHook({ lifecycle: "onBeforeRouteUpdate", hook, timing: "global", depth: 0 });
|
|
4514
|
-
};
|
|
4515
|
-
const onBeforeRouteLeave = (hook) => {
|
|
4516
|
-
return hooks.addBeforeRouteHook({ lifecycle: "onBeforeRouteLeave", hook, timing: "global", depth: 0 });
|
|
4517
|
-
};
|
|
4518
|
-
const onAfterRouteEnter = (hook) => {
|
|
4519
|
-
return hooks.addAfterRouteHook({ lifecycle: "onAfterRouteEnter", hook, timing: "global", depth: 0 });
|
|
4520
|
-
};
|
|
4521
|
-
const onAfterRouteUpdate = (hook) => {
|
|
4522
|
-
return hooks.addAfterRouteHook({ lifecycle: "onAfterRouteUpdate", hook, timing: "global", depth: 0 });
|
|
4523
|
-
};
|
|
4524
|
-
const onAfterRouteLeave = (hook) => {
|
|
4525
|
-
return hooks.addAfterRouteHook({ lifecycle: "onAfterRouteLeave", hook, timing: "global", depth: 0 });
|
|
4526
|
-
};
|
|
4527
|
-
return {
|
|
4528
|
-
onBeforeRouteEnter,
|
|
4529
|
-
onBeforeRouteUpdate,
|
|
4530
|
-
onBeforeRouteLeave,
|
|
4531
|
-
onAfterRouteEnter,
|
|
4532
|
-
onAfterRouteUpdate,
|
|
4533
|
-
onAfterRouteLeave,
|
|
4534
|
-
hooks
|
|
4535
|
-
};
|
|
4536
|
-
}
|
|
4537
|
-
const builtInRejections = ["NotFound"];
|
|
4538
|
-
const builtInRejectionComponents = {
|
|
4539
|
-
NotFound
|
|
4540
|
-
};
|
|
4541
|
-
const isRejectionRouteSymbol = Symbol();
|
|
4542
|
-
function createRouterReject({
|
|
4543
|
-
rejections: customRejectionComponents
|
|
4544
|
-
}) {
|
|
4545
|
-
const getRejectionComponent = (type) => {
|
|
4546
|
-
const components = {
|
|
4547
|
-
...builtInRejectionComponents,
|
|
4548
|
-
...customRejectionComponents
|
|
4549
|
-
};
|
|
4550
|
-
return markRaw(components[type]);
|
|
4551
|
-
};
|
|
4552
|
-
const getRejectionRoute = (type) => {
|
|
4553
|
-
const component2 = markRaw(getRejectionComponent(type));
|
|
4554
|
-
const route = {
|
|
4555
|
-
name: type,
|
|
4556
|
-
path: "",
|
|
4557
|
-
component: component2
|
|
4558
|
-
};
|
|
4559
|
-
const resolved = {
|
|
4560
|
-
matched: route,
|
|
4561
|
-
matches: [route],
|
|
4562
|
-
key: type,
|
|
4563
|
-
query: createResolvedRouteQuery(""),
|
|
4564
|
-
params: {},
|
|
4565
|
-
[isRejectionRouteSymbol]: true
|
|
4566
|
-
};
|
|
4567
|
-
return resolved;
|
|
4568
|
-
};
|
|
4569
|
-
const isRejectionRoute = (route) => {
|
|
4570
|
-
return route[isRejectionRouteSymbol] === true;
|
|
4571
|
-
};
|
|
4572
|
-
const setRejection = (type) => {
|
|
4573
|
-
if (!type) {
|
|
4574
|
-
rejection.value = null;
|
|
4575
|
-
return;
|
|
4576
|
-
}
|
|
4577
|
-
const component2 = getRejectionComponent(type);
|
|
4578
|
-
rejection.value = { type, component: component2 };
|
|
4579
|
-
};
|
|
4580
|
-
const rejection = ref(null);
|
|
4581
|
-
return {
|
|
4582
|
-
setRejection,
|
|
4583
|
-
rejection,
|
|
4584
|
-
getRejectionRoute,
|
|
4585
|
-
isRejectionRoute
|
|
4586
|
-
};
|
|
4587
|
-
}
|
|
4588
|
-
function getInitialUrl(initialUrl) {
|
|
4589
|
-
if (initialUrl) {
|
|
4590
|
-
return initialUrl;
|
|
4591
|
-
}
|
|
4592
|
-
if (isBrowser()) {
|
|
4593
|
-
return window.location.toString();
|
|
4594
|
-
}
|
|
4595
|
-
throw new Error("initialUrl must be set if window.location is unavailable");
|
|
4596
|
-
}
|
|
4597
|
-
function createRouter(routes2, options = {}) {
|
|
4598
|
-
const resolve2 = createRouterResolve(routes2);
|
|
4599
|
-
const history = createRouterHistory({ mode: options.historyMode });
|
|
4600
|
-
const { runBeforeRouteHooks, runAfterRouteHooks } = createRouteHookRunners();
|
|
4601
|
-
const {
|
|
4602
|
-
hooks,
|
|
4603
|
-
onBeforeRouteEnter,
|
|
4604
|
-
onAfterRouteUpdate,
|
|
4605
|
-
onBeforeRouteLeave,
|
|
4606
|
-
onAfterRouteEnter,
|
|
4607
|
-
onBeforeRouteUpdate,
|
|
4608
|
-
onAfterRouteLeave
|
|
4609
|
-
} = createRouterHooks();
|
|
4610
|
-
async function update(url, { replace: replace2 } = {}) {
|
|
4611
|
-
const to = getResolvedRouteForUrl(routes2, url) ?? getRejectionRoute("NotFound");
|
|
4612
|
-
const from = route;
|
|
4613
|
-
const beforeResponse = await runBeforeRouteHooks({ to, from, hooks });
|
|
4614
|
-
const setHistory = () => history.update(url, { replace: replace2 });
|
|
4615
|
-
const setRoute = () => updateRoute(to);
|
|
4616
|
-
switch (beforeResponse.status) {
|
|
4617
|
-
case "ABORT":
|
|
4618
|
-
return;
|
|
4619
|
-
case "PUSH":
|
|
4620
|
-
setHistory();
|
|
4621
|
-
push(...beforeResponse.to);
|
|
4622
|
-
return;
|
|
4623
|
-
case "REJECT":
|
|
4624
|
-
setHistory();
|
|
4625
|
-
setRoute();
|
|
4626
|
-
setRejection(beforeResponse.type);
|
|
4627
|
-
break;
|
|
4628
|
-
case "SUCCESS":
|
|
4629
|
-
setHistory();
|
|
4630
|
-
setRoute();
|
|
4631
|
-
setRejection(null);
|
|
4632
|
-
break;
|
|
4633
|
-
default:
|
|
4634
|
-
throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(beforeResponse)}`);
|
|
4635
|
-
}
|
|
4636
|
-
const afterResponse = await runAfterRouteHooks({ to, from, hooks });
|
|
4637
|
-
switch (afterResponse.status) {
|
|
4638
|
-
case "PUSH":
|
|
4639
|
-
push(...afterResponse.to);
|
|
4640
|
-
break;
|
|
4641
|
-
case "REJECT":
|
|
4642
|
-
setRejection(afterResponse.type);
|
|
4643
|
-
break;
|
|
4644
|
-
case "SUCCESS":
|
|
4645
|
-
break;
|
|
4646
|
-
default:
|
|
4647
|
-
const exhaustive = afterResponse;
|
|
4648
|
-
throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(exhaustive)}`);
|
|
4649
|
-
}
|
|
4650
|
-
}
|
|
4651
|
-
const push = (source, paramsOrOptions, maybeOptions) => {
|
|
4652
|
-
if (isUrl(source)) {
|
|
4653
|
-
const options3 = { ...paramsOrOptions };
|
|
4654
|
-
const url2 = resolve2(source, options3);
|
|
4655
|
-
return update(url2, { replace: options3.replace });
|
|
4656
|
-
}
|
|
4657
|
-
const options2 = { ...maybeOptions };
|
|
4658
|
-
const params = paramsOrOptions ?? {};
|
|
4659
|
-
const url = resolve2(source, params, options2);
|
|
4660
|
-
return update(url, { replace: options2.replace });
|
|
4661
|
-
};
|
|
4662
|
-
const replace = (source, paramsOrOptions, maybeOptions) => {
|
|
4663
|
-
if (isUrl(source)) {
|
|
4664
|
-
const options3 = { ...paramsOrOptions, replace: true };
|
|
4665
|
-
return push(source, options3);
|
|
4666
|
-
}
|
|
4667
|
-
const params = paramsOrOptions ?? {};
|
|
4668
|
-
const options2 = { ...maybeOptions, replace: true };
|
|
4669
|
-
return push(source, params, options2);
|
|
4670
|
-
};
|
|
4671
|
-
const reject = (type) => {
|
|
4672
|
-
return setRejection(type);
|
|
4673
|
-
};
|
|
4674
|
-
const find = createRouterFind(routes2);
|
|
4675
|
-
const { setRejection, rejection, getRejectionRoute } = createRouterReject(options);
|
|
4676
|
-
const notFoundRoute = getRejectionRoute("NotFound");
|
|
4677
|
-
const { route, updateRoute } = createCurrentRoute(notFoundRoute);
|
|
4678
|
-
const initialUrl = getInitialUrl(options.initialUrl);
|
|
4679
|
-
const initialized = update(initialUrl, { replace: true });
|
|
4680
|
-
function install(app) {
|
|
4681
|
-
app.component("RouterView", _sfc_main);
|
|
4682
|
-
app.component("RouterLink", _sfc_main$1);
|
|
4683
|
-
app.provide(routerInjectionKey, router);
|
|
4684
|
-
app.provide(routerRejectionKey, rejection);
|
|
4685
|
-
app.provide(routeHookStoreKey, hooks);
|
|
4686
|
-
}
|
|
4687
|
-
const router = {
|
|
4688
|
-
route: readonly(route),
|
|
4689
|
-
resolve: resolve2,
|
|
4690
|
-
push,
|
|
4691
|
-
replace,
|
|
4692
|
-
reject,
|
|
4693
|
-
find,
|
|
4694
|
-
refresh: history.refresh,
|
|
4695
|
-
forward: history.forward,
|
|
4696
|
-
back: history.back,
|
|
4697
|
-
go: history.go,
|
|
4698
|
-
install,
|
|
4699
|
-
initialized,
|
|
4700
|
-
onBeforeRouteEnter,
|
|
4701
|
-
onAfterRouteUpdate,
|
|
4702
|
-
onBeforeRouteLeave,
|
|
4703
|
-
onAfterRouteEnter,
|
|
4704
|
-
onBeforeRouteUpdate,
|
|
4705
|
-
onAfterRouteLeave
|
|
4706
|
-
};
|
|
4707
|
-
return router;
|
|
4708
|
-
}
|
|
4709
|
-
function checkDuplicateKeys(aParams, bParams) {
|
|
4710
|
-
const aParamKeys = Object.keys(aParams);
|
|
4711
|
-
const bParamKeys = Object.keys(bParams);
|
|
4712
|
-
const duplicateKey = aParamKeys.find((key) => bParamKeys.includes(key));
|
|
4713
|
-
if (duplicateKey) {
|
|
4714
|
-
return {
|
|
4715
|
-
key: duplicateKey,
|
|
4716
|
-
hasDuplicates: true
|
|
4717
|
-
};
|
|
4718
|
-
}
|
|
4719
|
-
return {
|
|
4720
|
-
key: void 0,
|
|
4721
|
-
hasDuplicates: false
|
|
4722
|
-
};
|
|
4723
|
-
}
|
|
4724
|
-
function getParamsForString(string, params) {
|
|
4725
|
-
const paramPattern = /:\??([\w]+)(?=\W|$)/g;
|
|
4726
|
-
const matches = Array.from(string.matchAll(paramPattern));
|
|
4727
|
-
return matches.reduce((value, [match, paramName]) => {
|
|
4728
|
-
const isOptional = match.startsWith(":?");
|
|
4729
|
-
const param = getParam(params, paramName);
|
|
4730
|
-
if (paramName in value) {
|
|
4731
|
-
throw new DuplicateParamsError(paramName);
|
|
4732
|
-
}
|
|
4733
|
-
value[paramName] = isOptional ? optional(param) : param;
|
|
4734
|
-
return value;
|
|
4735
|
-
}, {});
|
|
4736
|
-
}
|
|
4737
|
-
function isRecord(value) {
|
|
4738
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4739
|
-
}
|
|
4740
|
-
function hasProperty(value, key, type) {
|
|
4741
|
-
const propertyExists = isRecord(value) && key in value;
|
|
4742
|
-
if (!propertyExists) {
|
|
4743
|
-
return false;
|
|
4744
|
-
}
|
|
4745
|
-
if (type) {
|
|
4746
|
-
return typeof value[key] === typeof type();
|
|
4747
|
-
}
|
|
4748
|
-
return true;
|
|
4749
|
-
}
|
|
4750
|
-
function path(path2, params) {
|
|
4751
|
-
return {
|
|
4752
|
-
path: path2,
|
|
4753
|
-
params: getParamsForString(path2, params),
|
|
4754
|
-
toString: () => path2
|
|
4755
|
-
};
|
|
4756
|
-
}
|
|
4757
|
-
function isPath(value) {
|
|
4758
|
-
return isRecord(value) && typeof value.path === "string";
|
|
4759
|
-
}
|
|
4760
|
-
function toPath(value) {
|
|
4761
|
-
if (isPath(value)) {
|
|
4762
|
-
return value;
|
|
4763
|
-
}
|
|
4764
|
-
return path(value, {});
|
|
4765
|
-
}
|
|
4766
|
-
function combinePath(parentPath, childPath) {
|
|
4767
|
-
const { hasDuplicates, key } = checkDuplicateKeys(parentPath.params, childPath.params);
|
|
4768
|
-
if (hasDuplicates) {
|
|
4769
|
-
throw new DuplicateParamsError(key);
|
|
4770
|
-
}
|
|
4771
|
-
return path(`${parentPath.path}${childPath.path}`, { ...parentPath.params, ...childPath.params });
|
|
4772
|
-
}
|
|
4773
|
-
function query(query2, params) {
|
|
4774
|
-
return {
|
|
4775
|
-
query: query2,
|
|
4776
|
-
params: getParamsForString(query2, params),
|
|
4777
|
-
toString: () => query2
|
|
4778
|
-
};
|
|
4779
|
-
}
|
|
4780
|
-
function isQuery(value) {
|
|
4781
|
-
return isRecord(value) && typeof value.query === "string";
|
|
4782
|
-
}
|
|
4783
|
-
function toQuery(value) {
|
|
4784
|
-
if (value === void 0) {
|
|
4785
|
-
return query("", {});
|
|
4786
|
-
}
|
|
4787
|
-
if (isQuery(value)) {
|
|
4788
|
-
return value;
|
|
4789
|
-
}
|
|
4790
|
-
return query(value, {});
|
|
4791
|
-
}
|
|
4792
|
-
function combineQuery(parentQuery, childQuery) {
|
|
4793
|
-
const { hasDuplicates, key } = checkDuplicateKeys(parentQuery.params, childQuery.params);
|
|
4794
|
-
if (hasDuplicates) {
|
|
4795
|
-
throw new DuplicateParamsError(key);
|
|
4796
|
-
}
|
|
4797
|
-
return query(`${parentQuery.query}${childQuery.query}`, { ...parentQuery.params, ...childQuery.params });
|
|
4798
|
-
}
|
|
4799
|
-
function markRouteRaw(route) {
|
|
4800
|
-
return { ...route, component: route.component ? markRaw(route.component) : route.component };
|
|
4801
|
-
}
|
|
4802
|
-
function createRoutes(routesProps) {
|
|
4803
|
-
const routes2 = routesProps.reduce((routes22, routeProps) => {
|
|
4804
|
-
const route = createRoute(routeProps);
|
|
4805
|
-
if (isParentRoute(routeProps) && routeProps.children) {
|
|
4806
|
-
routes22.push(...routeProps.children.map((childRoute) => ({
|
|
4807
|
-
...childRoute,
|
|
4808
|
-
key: combineName(route.key, childRoute.key),
|
|
4809
|
-
path: combinePath(route.path, childRoute.path),
|
|
4810
|
-
query: combineQuery(route.query, childRoute.query),
|
|
4811
|
-
matches: [...childRoute.matches, route.matched],
|
|
4812
|
-
depth: childRoute.depth + 1
|
|
4813
|
-
})));
|
|
4814
|
-
}
|
|
4815
|
-
routes22.push(route);
|
|
4816
|
-
return routes22;
|
|
4817
|
-
}, []);
|
|
4818
|
-
routes2.forEach(({ path: path2, query: query2 }) => {
|
|
4819
|
-
const { hasDuplicates, key } = checkDuplicateKeys(path2.params, query2.params);
|
|
4820
|
-
if (hasDuplicates) {
|
|
4821
|
-
throw new DuplicateParamsError(key);
|
|
4822
|
-
}
|
|
4823
|
-
});
|
|
4824
|
-
return routes2;
|
|
4825
|
-
}
|
|
4826
|
-
function createRoute(route) {
|
|
4827
|
-
const path2 = toPath(route.path);
|
|
4828
|
-
const query2 = toQuery(route.query);
|
|
4829
|
-
const rawRoute = markRouteRaw(route);
|
|
4830
|
-
return {
|
|
4831
|
-
matched: rawRoute,
|
|
4832
|
-
matches: [rawRoute],
|
|
4833
|
-
key: route.name,
|
|
4834
|
-
path: path2,
|
|
4835
|
-
query: query2,
|
|
4836
|
-
pathParams: path2.params,
|
|
4837
|
-
queryParams: query2.params,
|
|
4838
|
-
depth: 1,
|
|
4839
|
-
disabled: route.disabled ?? false
|
|
4840
|
-
};
|
|
4841
|
-
}
|
|
4842
|
-
const random = {
|
|
4843
|
-
number(options = {}) {
|
|
4844
|
-
const { min, max } = { min: 0, max: 1, ...options };
|
|
4845
|
-
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
4846
|
-
return randomNumber;
|
|
4847
|
-
}
|
|
4848
|
-
};
|
|
4849
|
-
const component = { template: "<div>This is component</div>" };
|
|
4850
|
-
const routes = createRoutes([
|
|
4851
|
-
{
|
|
4852
|
-
name: "parentA",
|
|
4853
|
-
path: "/:paramA",
|
|
4854
|
-
children: createRoutes([
|
|
4855
|
-
{
|
|
4856
|
-
name: "childA",
|
|
4857
|
-
path: "/:?paramB",
|
|
4858
|
-
children: createRoutes([
|
|
4859
|
-
{
|
|
4860
|
-
name: "grandChildA",
|
|
4861
|
-
path: "/:paramC",
|
|
4862
|
-
component
|
|
4863
|
-
}
|
|
4864
|
-
])
|
|
4865
|
-
},
|
|
4866
|
-
{
|
|
4867
|
-
name: "childB",
|
|
4868
|
-
path: "/:paramD",
|
|
4869
|
-
component
|
|
4870
|
-
}
|
|
4871
|
-
])
|
|
4872
|
-
},
|
|
4873
|
-
{
|
|
4874
|
-
name: "parentB",
|
|
4875
|
-
path: "/parentB",
|
|
4876
|
-
component
|
|
4877
|
-
}
|
|
4878
|
-
]);
|
|
4879
|
-
exports2.InvalidRouteParamValueError = InvalidRouteParamValueError;
|
|
4880
|
-
exports2.NotFound = NotFound;
|
|
4881
|
-
exports2.RouterLink = _sfc_main$1;
|
|
4882
|
-
exports2.RouterView = _sfc_main;
|
|
4883
|
-
exports2.asArray = asArray;
|
|
4884
|
-
exports2.assembleUrl = assembleUrl;
|
|
4885
|
-
exports2.builtInRejectionComponents = builtInRejectionComponents;
|
|
4886
|
-
exports2.builtInRejections = builtInRejections;
|
|
4887
|
-
exports2.component = component;
|
|
4888
|
-
exports2.countExpectedQueryKeys = countExpectedQueryKeys;
|
|
4889
|
-
exports2.createCurrentRoute = createCurrentRoute;
|
|
4890
|
-
exports2.createMaybeRelativeUrl = createMaybeRelativeUrl;
|
|
4891
|
-
exports2.createResolvedRouteQuery = createResolvedRouteQuery;
|
|
4892
|
-
exports2.createRouteHookRunners = createRouteHookRunners;
|
|
4893
|
-
exports2.createRouter = createRouter;
|
|
4894
|
-
exports2.createRouterFind = createRouterFind;
|
|
4895
|
-
exports2.createRouterHistory = createRouterHistory;
|
|
4896
|
-
exports2.createRouterHooks = createRouterHooks;
|
|
4897
|
-
exports2.createRouterReject = createRouterReject;
|
|
4898
|
-
exports2.createRouterResolve = createRouterResolve;
|
|
4899
|
-
exports2.createRoutes = createRoutes;
|
|
4900
|
-
exports2.depthInjectionKey = depthInjectionKey;
|
|
4901
|
-
exports2.generateRoutePathRegexPattern = generateRoutePathRegexPattern;
|
|
4902
|
-
exports2.generateRouteQueryRegexPatterns = generateRouteQueryRegexPatterns;
|
|
4903
|
-
exports2.getAfterRouteHooksFromRoutes = getAfterRouteHooksFromRoutes;
|
|
4904
|
-
exports2.getBeforeRouteHooksFromRoutes = getBeforeRouteHooksFromRoutes;
|
|
4905
|
-
exports2.getInitialUrl = getInitialUrl;
|
|
4906
|
-
exports2.getParam = getParam;
|
|
4907
|
-
exports2.getParamValue = getParamValue;
|
|
4908
|
-
exports2.getParamValueFromUrl = getParamValueFromUrl;
|
|
4909
|
-
exports2.getParamsForString = getParamsForString;
|
|
4910
|
-
exports2.getResolvedRouteForUrl = getResolvedRouteForUrl;
|
|
4911
|
-
exports2.getRouteHookCondition = getRouteHookCondition;
|
|
4912
|
-
exports2.getRouteParamValues = getRouteParamValues;
|
|
4913
|
-
exports2.getRouteScoreSortMethod = getRouteScoreSortMethod;
|
|
4914
|
-
exports2.hasProperty = hasProperty;
|
|
4915
|
-
exports2.isBrowser = isBrowser;
|
|
4916
|
-
exports2.isParamGetSet = isParamGetSet;
|
|
4917
|
-
exports2.isParamGetter = isParamGetter;
|
|
4918
|
-
exports2.isParentRoute = isParentRoute;
|
|
4919
|
-
exports2.isRecord = isRecord;
|
|
4920
|
-
exports2.isRouteEnter = isRouteEnter;
|
|
4921
|
-
exports2.isRouteLeave = isRouteLeave;
|
|
4922
|
-
exports2.isRouteUpdate = isRouteUpdate;
|
|
4923
|
-
exports2.isUrl = isUrl;
|
|
4924
|
-
exports2.markRouteRaw = markRouteRaw;
|
|
4925
|
-
exports2.optional = optional;
|
|
4926
|
-
exports2.path = path;
|
|
4927
|
-
exports2.query = query;
|
|
4928
|
-
exports2.random = random;
|
|
4929
|
-
exports2.replaceParamSyntaxWithCatchAlls = replaceParamSyntaxWithCatchAlls;
|
|
4930
|
-
exports2.routeHookStoreKey = routeHookStoreKey;
|
|
4931
|
-
exports2.routeParamsAreValid = routeParamsAreValid;
|
|
4932
|
-
exports2.routePathMatches = routePathMatches;
|
|
4933
|
-
exports2.routeQueryMatches = routeQueryMatches;
|
|
4934
|
-
exports2.routerInjectionKey = routerInjectionKey;
|
|
4935
|
-
exports2.routerRejectionKey = routerRejectionKey;
|
|
4936
|
-
exports2.routes = routes;
|
|
4937
|
-
exports2.setParamValue = setParamValue;
|
|
4938
|
-
exports2.setParamValueOnUrl = setParamValueOnUrl;
|
|
4939
|
-
exports2.stringHasValue = stringHasValue;
|
|
4940
|
-
exports2.toPath = toPath;
|
|
4941
|
-
exports2.toQuery = toQuery;
|
|
4942
|
-
exports2.useParam = useParam;
|
|
4943
|
-
exports2.useParamRaw = useParamRaw;
|
|
4944
|
-
exports2.useRejection = useRejection;
|
|
4945
|
-
exports2.useRoute = useRoute;
|
|
4946
|
-
exports2.useRouteParam = useRouteParam;
|
|
4947
|
-
exports2.useRouteParamRaw = useRouteParamRaw;
|
|
4948
|
-
exports2.useRouter = useRouter;
|
|
4949
|
-
exports2.withQuery = withQuery;
|
|
4950
|
-
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
4951
|
-
});
|
|
1
|
+
(function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w["@kitbag/router"]={},w.Vue))})(this,function(w,u){"use strict";var cn=Object.defineProperty;var sn=(w,u,$)=>u in w?cn(w,u,{enumerable:!0,configurable:!0,writable:!0,value:$}):w[u]=$;var q=(w,u,$)=>(sn(w,typeof u!="symbol"?u+"":u,$),$);class $ extends Error{constructor(t){super(`Invalid Param "${t}": Router does not support multiple params by the same name. All param names must be unique.`)}}class Y extends Error{constructor(){super("Router not installed")}}class ve extends Error{constructor(t,n){super(`useRoute called with incorrect route. Given ${t}, expected ${n}`)}}const ce=Symbol();function Ee(){const e=u.inject(ce);if(!e)throw new Y;return e}const se=Symbol();function X(){const e=u.inject(se);if(!e)throw new Y;return e}function be(e,t){return[e,t].filter(n=>!!n).join(".")}function ot(e){const t=X();function n(){if(!e)return;const r=t.route.matches.map(c=>c.name);if(!at(r).includes(e))throw new ve(e,t.route.key)}return u.watch(t.route,n,{immediate:!0,deep:!0}),t.route}function at(e){return e.reduce((t,n)=>{const r=t.pop(),o=n?[be(r,n)]:[];return r?[...t,r,...o]:o},[])}const ke=Symbol();function ie(){return u.inject(ke,0)}class Z{constructor(){q(this,"onBeforeRouteEnter",new Set);q(this,"onBeforeRouteUpdate",new Set);q(this,"onBeforeRouteLeave",new Set);q(this,"onAfterRouteEnter",new Set);q(this,"onAfterRouteUpdate",new Set);q(this,"onAfterRouteLeave",new Set)}}class Pe extends Error{}class J extends Error{constructor(n){super("Error occurred during a router push operation.");q(this,"to");this.to=n}}class ue extends Error{constructor(n){super(`Routing action rejected: ${n}`);q(this,"type");this.type=n}}function I(e){return Array.isArray(e)?e:[e]}function ct(e,t){const n=new Z;return e.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&fe(e,t,o)&&I(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&he(e,t,o)&&I(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&le(e,t,o)&&I(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function st(e,t){const n=new Z;return e.matches.forEach((r,o)=>{r.onAfterRouteEnter&&fe(e,t,o)&&I(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&he(e,t,o)&&I(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onAfterRouteLeave&&le(e,t,o)&&I(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function G(e){return typeof e!="string"?!1:/^(https?:\/\/|\/).*/g.test(e)}function it(){const e=c=>{throw new ue(c)},t=(...c)=>{throw new J(c)},n=(c,i,f)=>{if(G(c)){const g=i??{};throw new J([c,{...g,replace:!0}])}const m=i,y=f??{};throw new J([c,m,{...y,replace:!0}])},r=()=>{throw new Pe};async function o({to:c,from:i,hooks:f}){const{global:m,component:y}=f,g=ct(c,i),L=[...m.onBeforeRouteEnter,...g.onBeforeRouteEnter,...m.onBeforeRouteUpdate,...g.onBeforeRouteUpdate,...y.onBeforeRouteUpdate,...m.onBeforeRouteLeave,...g.onBeforeRouteLeave,...y.onBeforeRouteLeave];try{const p=L.map(A=>A(c,{from:i,reject:e,push:t,replace:n,abort:r}));await Promise.all(p)}catch(p){if(p instanceof J)return{status:"PUSH",to:p.to};if(p instanceof ue)return{status:"REJECT",type:p.type};if(p instanceof Pe)return{status:"ABORT"};throw p}return{status:"SUCCESS"}}async function a({to:c,from:i,hooks:f}){const{global:m,component:y}=f,g=st(c,i),L=[...y.onAfterRouteLeave,...g.onAfterRouteLeave,...m.onAfterRouteLeave,...y.onAfterRouteUpdate,...g.onAfterRouteUpdate,...m.onAfterRouteUpdate,...y.onAfterRouteEnter,...g.onAfterRouteEnter,...m.onAfterRouteEnter];try{const p=L.map(A=>A(c,{from:i,reject:e,push:t,replace:n}));await Promise.all(p)}catch(p){if(p instanceof J)return{status:"PUSH",to:p.to};if(p instanceof ue)return{status:"REJECT",type:p.type};throw p}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const fe=(e,t,n)=>{const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n]!==o[n]},le=(e,t,n)=>{const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n]!==o[n]},he=(e,t,n)=>e.matches[n]===(t==null?void 0:t.matches[n]);function Se(e){switch(e){case"onBeforeRouteEnter":case"onAfterRouteEnter":return fe;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return he;case"onBeforeRouteLeave":case"onAfterRouteLeave":return le;default:throw new Error(`Switch is not exhaustive for lifecycle: ${e}`)}}class ut{constructor(){q(this,"global",new Z);q(this,"component",new Z)}addBeforeRouteHook({lifecycle:t,timing:n,depth:r,hook:o}){const a=Se(t),c=this[n][t],i=(f,m)=>{if(a(f,m.from,r))return o(f,m)};return c.add(i),()=>c.delete(i)}addAfterRouteHook({lifecycle:t,timing:n,depth:r,hook:o}){const a=Se(t),c=this[n][t],i=(f,m)=>{if(a(f,m.from,r))return o(f,m)};return c.add(i),()=>c.delete(i)}}const Ae=Symbol();function ft(){const e=new ut;return{onBeforeRouteEnter:i=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:i,timing:"global",depth:0}),onBeforeRouteUpdate:i=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:i,timing:"global",depth:0}),onBeforeRouteLeave:i=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:i,timing:"global",depth:0}),onAfterRouteEnter:i=>e.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:i,timing:"global",depth:0}),onAfterRouteUpdate:i=>e.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:i,timing:"global",depth:0}),onAfterRouteLeave:i=>e.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:i,timing:"global",depth:0}),hooks:e}}function xe(){const e=u.inject(Ae);if(!e)throw new Y;return e}function Be(e){return t=>{const n=ie(),o=xe().addBeforeRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return u.onUnmounted(o),o}}function pe(e){return t=>{const n=ie(),o=xe().addAfterRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return u.onUnmounted(o),o}}const lt=Be("onBeforeRouteUpdate"),ht=Be("onBeforeRouteLeave"),pt=pe("onAfterRouteEnter"),dt=pe("onAfterRouteUpdate"),mt=pe("onAfterRouteLeave"),yt=["href"],Le=u.defineComponent({__name:"routerLink",props:{to:{type:[String,Function]},query:{},replace:{type:Boolean}},setup(e){const t=e,n=X(),r=u.computed(()=>G(t.to)?t.to:t.to(n.resolve)),o=u.computed(()=>{const{to:g,...L}=t;return L}),a=u.computed(()=>{var g;return(g=n.find(r.value,o.value))==null?void 0:g.matched}),c=u.computed(()=>!!a.value&&n.route.matches.includes(u.readonly(a.value))),i=u.computed(()=>!!a.value&&n.route.matched===a.value),f=u.computed(()=>({"router-link--match":c.value,"router-link--exact-match":i.value})),m=u.computed(()=>{const{host:g}=new URL(r.value,window.location.origin);return g!==window.location.host});function y(g){g.preventDefault(),n.push(r.value,o.value)}return(g,L)=>(u.openBlock(),u.createElementBlock("a",{href:r.value,class:u.normalizeClass(f.value),onClick:y},[u.renderSlot(g.$slots,"default",u.normalizeProps(u.guardReactiveProps({resolved:r.value,match:c.value,exactMatch:i.value,isExternal:m.value})))],10,yt))}}),de=u.defineComponent({__name:"routerView",setup(e){const t=X(),n=Ee(),r=ie();u.provide(ke,r+1);const o=u.computed(()=>{var c;const a=(c=t.route.matches[r])==null?void 0:c.component;return a?typeof a=="function"?u.defineAsyncComponent(a):a:null});return(a,c)=>u.unref(n)?(u.openBlock(),u.createBlock(u.resolveDynamicComponent(u.unref(n).component),{key:0})):u.renderSlot(a.$slots,"default",{key:1,route:u.unref(t).route,component:o.value},()=>[(u.openBlock(),u.createBlock(u.resolveDynamicComponent(o.value)))])}});function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)}var U;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(U||(U={}));var W=process.env.NODE_ENV!=="production"?function(e){return Object.freeze(e)}:function(e){return e};function D(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}var ee="beforeunload",Rt="hashchange",Ue="popstate";function He(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var h=r.location,s=h.pathname,l=h.search,E=h.hash,b=o.state||{};return[b.idx,W({pathname:s,search:l,hash:E,state:b.usr||null,key:b.key||"default"})]}var c=null;function i(){if(c)p.call(c),c=null;else{var h=U.Pop,s=a(),l=s[0],E=s[1];if(p.length)if(l!=null){var b=y-l;b&&(c={action:h,location:E,retry:function(){k(b*-1)}},k(b))}else process.env.NODE_ENV!=="production"&&D(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else H(h)}}r.addEventListener(Ue,i);var f=U.Pop,m=a(),y=m[0],g=m[1],L=F(),p=F();y==null&&(y=0,o.replaceState(V({},o.state,{idx:y}),""));function A(h){return typeof h=="string"?h:M(h)}function C(h,s){return s===void 0&&(s=null),W(V({pathname:g.pathname,hash:"",search:""},typeof h=="string"?Q(h):h,{state:s,key:ne()}))}function N(h,s){return[{usr:h.state,key:h.key,idx:s},A(h)]}function j(h,s,l){return!p.length||(p.call({action:h,location:s,retry:l}),!1)}function H(h){f=h;var s=a();y=s[0],g=s[1],L.call({action:f,location:g})}function d(h,s){var l=U.Push,E=C(h,s);function b(){d(h,s)}if(j(l,E,b)){var x=N(E,y+1),R=x[0],S=x[1];try{o.pushState(R,"",S)}catch{r.location.assign(S)}H(l)}}function v(h,s){var l=U.Replace,E=C(h,s);function b(){v(h,s)}if(j(l,E,b)){var x=N(E,y),R=x[0],S=x[1];o.replaceState(R,"",S),H(l)}}function k(h){o.go(h)}var P={get action(){return f},get location(){return g},createHref:A,push:d,replace:v,go:k,back:function(){k(-1)},forward:function(){k(1)},listen:function(s){return L.push(s)},block:function(s){var l=p.push(s);return p.length===1&&r.addEventListener(ee,te),function(){l(),p.length||r.removeEventListener(ee,te)}}};return P}function gt(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var s=Q(r.location.hash.substr(1)),l=s.pathname,E=l===void 0?"/":l,b=s.search,x=b===void 0?"":b,R=s.hash,S=R===void 0?"":R,B=o.state||{};return[B.idx,W({pathname:E,search:x,hash:S,state:B.usr||null,key:B.key||"default"})]}var c=null;function i(){if(c)p.call(c),c=null;else{var s=U.Pop,l=a(),E=l[0],b=l[1];if(p.length)if(E!=null){var x=y-E;x&&(c={action:s,location:b,retry:function(){P(x*-1)}},P(x))}else process.env.NODE_ENV!=="production"&&D(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else d(s)}}r.addEventListener(Ue,i),r.addEventListener(Rt,function(){var s=a(),l=s[1];M(l)!==M(g)&&i()});var f=U.Pop,m=a(),y=m[0],g=m[1],L=F(),p=F();y==null&&(y=0,o.replaceState(V({},o.state,{idx:y}),""));function A(){var s=document.querySelector("base"),l="";if(s&&s.getAttribute("href")){var E=r.location.href,b=E.indexOf("#");l=b===-1?E:E.slice(0,b)}return l}function C(s){return A()+"#"+(typeof s=="string"?s:M(s))}function N(s,l){return l===void 0&&(l=null),W(V({pathname:g.pathname,hash:"",search:""},typeof s=="string"?Q(s):s,{state:l,key:ne()}))}function j(s,l){return[{usr:s.state,key:s.key,idx:l},C(s)]}function H(s,l,E){return!p.length||(p.call({action:s,location:l,retry:E}),!1)}function d(s){f=s;var l=a();y=l[0],g=l[1],L.call({action:f,location:g})}function v(s,l){var E=U.Push,b=N(s,l);function x(){v(s,l)}if(process.env.NODE_ENV!=="production"&&D(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(s)+")"),H(E,b,x)){var R=j(b,y+1),S=R[0],B=R[1];try{o.pushState(S,"",B)}catch{r.location.assign(B)}d(E)}}function k(s,l){var E=U.Replace,b=N(s,l);function x(){k(s,l)}if(process.env.NODE_ENV!=="production"&&D(b.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(s)+")"),H(E,b,x)){var R=j(b,y),S=R[0],B=R[1];o.replaceState(S,"",B),d(E)}}function P(s){o.go(s)}var h={get action(){return f},get location(){return g},createHref:C,push:v,replace:k,go:P,back:function(){P(-1)},forward:function(){P(1)},listen:function(l){return L.push(l)},block:function(l){var E=p.push(l);return p.length===1&&r.addEventListener(ee,te),function(){E(),p.length||r.removeEventListener(ee,te)}}};return h}function je(e){e===void 0&&(e={});var t=e,n=t.initialEntries,r=n===void 0?["/"]:n,o=t.initialIndex,a=r.map(function(d){var v=W(V({pathname:"/",search:"",hash:"",state:null,key:ne()},typeof d=="string"?Q(d):d));return process.env.NODE_ENV!=="production"&&D(v.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(d)+")"),v}),c=$e(o??a.length-1,0,a.length-1),i=U.Pop,f=a[c],m=F(),y=F();function g(d){return typeof d=="string"?d:M(d)}function L(d,v){return v===void 0&&(v=null),W(V({pathname:f.pathname,search:"",hash:""},typeof d=="string"?Q(d):d,{state:v,key:ne()}))}function p(d,v,k){return!y.length||(y.call({action:d,location:v,retry:k}),!1)}function A(d,v){i=d,f=v,m.call({action:i,location:f})}function C(d,v){var k=U.Push,P=L(d,v);function h(){C(d,v)}process.env.NODE_ENV!=="production"&&D(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(d)+")"),p(k,P,h)&&(c+=1,a.splice(c,a.length,P),A(k,P))}function N(d,v){var k=U.Replace,P=L(d,v);function h(){N(d,v)}process.env.NODE_ENV!=="production"&&D(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(d)+")"),p(k,P,h)&&(a[c]=P,A(k,P))}function j(d){var v=$e(c+d,0,a.length-1),k=U.Pop,P=a[v];function h(){j(d)}p(k,P,h)&&(c=v,A(k,P))}var H={get index(){return c},get action(){return i},get location(){return f},createHref:g,push:C,replace:N,go:j,back:function(){j(-1)},forward:function(){j(1)},listen:function(v){return m.push(v)},block:function(v){return y.push(v)}};return H}function $e(e,t,n){return Math.min(Math.max(e,t),n)}function te(e){e.preventDefault(),e.returnValue=""}function F(){var e=[];return{get length(){return e.length},push:function(n){return e.push(n),function(){e=e.filter(function(r){return r!==n})}},call:function(n){e.forEach(function(r){return r&&r(n)})}}}function ne(){return Math.random().toString(36).substr(2,8)}function M(e){var t=e.pathname,n=t===void 0?"/":t,r=e.search,o=r===void 0?"":r,a=e.hash,c=a===void 0?"":a;return o&&o!=="?"&&(n+=o.charAt(0)==="?"?o:"?"+o),c&&c!=="#"&&(n+=c.charAt(0)==="#"?c:"#"+c),n}function Q(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function wt(e,t){function n(r,o,a){if(typeof r=="object"){const i={...e.params,...r};return t(e.key,i,o)}const c={...e.params,[r]:o};return t(e.key,c,a)}return new Proxy(e,{get:(r,o,a)=>o==="update"?n:o==="params"?new Proxy(e.params,{set(c,i,f){return n(i,f),!0}}):Reflect.get(r,o,a)})}function vt(e,t){const n=u.reactive({...e}),r=c=>{Object.assign(n,{...c})},o=u.readonly(n),a=wt(o,t);return{currentRoute:o,routerRoute:a,updateRoute:r}}class re extends Error{}function Et(e){return e!==String&&e!==Boolean&&e!==Number}function qe(e){return typeof e=="function"&&Et(e)}function me(e){return typeof e=="object"&&"get"in e&&typeof e.get=="function"&&"set"in e&&typeof e.set=="function"}function ye(e){return typeof e=="string"&&e.length>0}function bt(e,t){return e[t]??String}const Ce=Symbol();function Ne(e){return Ce in e}function kt(e){return{[Ce]:!0,get:t=>{if(ye(t))return Oe(t,e)},set:t=>ye(t)?Te(t,e):""}}const _={invalid:e=>{throw new re(e)}},Pt={get:e=>e,set:(e,{invalid:t})=>{if(typeof e!="string")throw t();return e}},_e={get:(e,{invalid:t})=>{if(e==="true")return!0;if(e==="false")return!1;throw t()},set:(e,{invalid:t})=>{if(typeof e!="boolean")throw t();return e.toString()}},Ve={get:(e,{invalid:t})=>{const n=Number(e);if(isNaN(n))throw t();return n},set:(e,{invalid:t})=>{if(typeof e!="number")throw t();return e.toString()}};function Oe(e,t){if(e===void 0){if(Ne(t))return t.get(e,_);throw new re}if(t===String)return Pt.get(e,_);if(t===Boolean)return _e.get(e,_);if(t===Number)return Ve.get(e,_);if(qe(t))return t(e,_);if(me(t))return t.get(e,_);if(t instanceof RegExp){if(t.test(e))return e;throw new re}return e}function Te(e,t){if(t===Boolean)return _e.set(e,_);if(t===Number)return Ve.set(e,_);if(me(t))return t.set(e,_);try{return e.toString()}catch{throw new re}}function St(e){const t=Re(e.path.toString());return new RegExp(`^${t}$`,"i")}function At(e){const t=new URLSearchParams(e.query.toString());return Array.from(t.entries()).filter(([,n])=>!Lt(n)).map(([n,r])=>new RegExp(`${n}=${Re(r)}(&|$)`,"i"))}function Re(e){return[Bt,Ut].reduce((t,n)=>n(t),e)}const De=/(:\?[\w]+)(?=\W|$)/g,xt=/(:[\w]+)(?=\W|$)/g;function Bt(e){return e.replace(De,"[^\\/]*")}function Lt(e){return De.test(e)}function Ut(e){return e.replace(xt,"[^\\/]+")}function Me(e,t,n){const r=Ke(t.toString(),n),[o]=Ie(e,r);return o}function Ht(e,t){if(!t)return e;const{name:n,param:r,value:o}=t,a=Ke(e,n);return Ie(e,a).reduce((i,f)=>i.replace(f,()=>Te(o,r)),e)}function Ke(e,t){const n=[jt,$t,Re].reduce((r,o)=>o(r,t),e);return new RegExp(n,"g")}function jt(e,t){const n=new RegExp(`(:\\?${t})(?=\\W|$)`,"g");return e.replace(n,"([^\\/]*)")}function $t(e,t){const n=new RegExp(`(:${t})(?=\\W|$)`,"g");return e.replace(n,"([^\\/]+)")}function Ie(e,t){return Array.from(e.matchAll(t)).flatMap(([,...r])=>r.map(o=>ye(o)?o:""))}function We(e,...t){return t.reduce((n,r)=>{if(!r)return n;const o=new URLSearchParams(r).toString();return Object.keys(o).length===0?n:n.includes("?")?`${n}&${o}`:`${n}?${o}`},e)}function qt(e,t={}){const{params:n={},query:r}=t,o=Object.entries({...e.pathParams,...e.queryParams}),a=e.path.toString(),c=e.query.toString(),i=Fe(a,o,n),f=Fe(c,o,n);return We(i,f,r)}function Fe(e,t,n){return e.length?t.reduce((r,[o,a])=>Ht(r,{name:o,param:a,value:n[o]}),e):e}function Je(e){return(t,n,r)=>{if(G(t))return We(t,(n??{}).query);const o=n??{},a=r??{},c=e.find(f=>f.key===t);if(!c)throw`Route not found: "${String(t)}"`;if(c.matched.disabled)throw`Route disabled: "${String(t)}"`;return qt(c,{params:o,query:a.query})}}function z(e){return!e.startsWith("http")?Nt(e):Ct(e)}function Ct(e){const{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:c}=new URL(e,e);return{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:c}}function Nt(e){const{pathname:t,search:n,searchParams:r,hash:o}=new URL(e,"https://localhost");return{pathname:t,search:n,searchParams:r,hash:o}}function Ge(e){const t=new URLSearchParams(e);return{get:n=>t.get(n),getAll:n=>t.getAll(n)}}const _t=(e,t)=>{try{Qe(e,t)}catch{return!1}return!0},Qe=(e,t)=>{const{pathname:n,search:r}=z(t);return{...ze(e.pathParams,e.path.toString(),n),...ze(e.queryParams,e.query.toString(),r)}},ze=(e,t,n)=>{const r={},o=decodeURIComponent(n);for(const[a,c]of Object.entries(e)){const i=Me(o,t,a),f=Oe(i,c);r[a]=f}return r},Vt=(e,t)=>{const{pathname:n}=z(t);return St(e).test(n)},Ot=(e,t)=>{const{search:n}=z(t);return At(e).every(o=>o.test(n))};function Tt(e){const{searchParams:t,pathname:n}=z(e),r=-1,o=1;return(a,c)=>{const i=Xe(a,t),f=Ye(a,n),m=Xe(c,t),y=Ye(c,n);return i+f>m+y?r:i+f<m+y?o:a.depth>c.depth?r:a.depth<c.depth?o:0}}function Ye(e,t){const n=Object.entries(e.pathParams).filter(([,o])=>Ne(o)).map(([o])=>o),r=n.filter(o=>Me(t,e.path.toString(),o)===void 0);return n.length-r.length}function Xe(e,t){const n=new URLSearchParams(e.query.toString()),r=Array.from(n.keys()),o=r.filter(a=>!t.has(a));return r.length-o.length}function Ze(e,t){const n=[Dt,Vt,Ot,_t],r=Tt(t),o=e.filter(m=>n.every(y=>y(m,t))).sort(r);if(o.length===0)return;const[a]=o,{search:c}=z(t),i=Ge(c),f=Qe(a,t);return u.readonly({matched:a.matched,matches:a.matches,key:a.key,query:i,params:f})}const Dt=e=>"name"in e.matched&&!!e.matched.name;function Mt(e){return(t,n={})=>{const o=Je(e)(t,n);return Ze(e,o)}}function et(){return typeof window<"u"&&typeof window.document<"u"}function Kt({mode:e,listener:t}){const n=It(e),r=(f,m)=>{if(m!=null&&m.replace)return n.replace(f);n.push(f)},o=()=>{const f=M(n.location);return n.replace(f)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(t)},stopListening:()=>{a==null||a()}}}function It(e="auto"){switch(e){case"auto":return et()?He():je();case"browser":return He();case"memory":return je();case"hash":return gt();default:const t=e;throw new Error(`Switch is not exhaustive for mode: ${t}`)}}function Wt(e){return u.defineComponent(()=>()=>u.h("h1",e),{name:e,props:[]})}const tt=Symbol();function Ft({rejections:e}){const t=c=>{const i={...e};return u.markRaw(i[c]??Wt(c))},n=c=>{const i=u.markRaw(t(c)),f={name:c,path:"",component:i,meta:{}};return u.readonly({matched:f,matches:[f],key:c,query:Ge(""),params:{},[tt]:!0})},r=c=>c[tt]===!0,o=c=>{if(!c){a.value=null;return}const i=t(c);a.value={type:c,component:i}},a=u.ref(null);return{setRejection:o,rejection:a,getRejectionRoute:n,isRejectionRoute:r}}class Jt extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Gt(e){if(e)return e;if(et())return window.location.toString();throw new Jt}function Qt(e,t={}){const n=Je(e),r=Kt({mode:t.historyMode,listener:()=>{const R=M(location);p(R)}}),{runBeforeRouteHooks:o,runAfterRouteHooks:a}=it(),{hooks:c,onBeforeRouteEnter:i,onAfterRouteUpdate:f,onBeforeRouteLeave:m,onAfterRouteEnter:y,onBeforeRouteUpdate:g,onAfterRouteLeave:L}=ft();async function p(R,{replace:S}={}){r.stopListening();const B=Ze(e,R)??v("NotFound"),O={...P},K=await o({to:B,from:O,hooks:c});switch(K.status){case"ABORT":return;case"PUSH":r.update(R,{replace:S}),await A(...K.to);return;case"REJECT":r.update(R,{replace:S}),H(K.type),s(B);break;case"SUCCESS":r.update(R,{replace:S}),H(null),s(B);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(K)}`)}const T=await a({to:B,from:O,hooks:c});switch(T.status){case"PUSH":await A(...T.to);break;case"REJECT":H(T.type);break;case"SUCCESS":break;default:const ae=T;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(ae)}`)}r.startListening()}const A=(R,S,B)=>{if(G(R)){const ae={...S},an=n(R,ae);return p(an,{replace:ae.replace})}const O={...B},T=n(R,S??{},O);return p(T,{replace:O.replace})},C=(R,S,B)=>{if(G(R)){const T={...S,replace:!0};return A(R,T)}const O=S??{},K={...B,replace:!0};return A(R,O,K)},N=R=>H(R),j=Mt(e),{setRejection:H,rejection:d,getRejectionRoute:v}=Ft(t),k=v("NotFound"),{currentRoute:P,routerRoute:h,updateRoute:s}=vt(k,A);r.startListening();const l=Gt(t.initialUrl),E=p(l,{replace:!0});function b(R){R.component("RouterView",de),R.component("RouterLink",Le),R.provide(se,x),R.provide(ce,d),R.provide(Ae,c)}const x={route:h,resolve:n,push:A,replace:C,reject:N,find:j,refresh:r.refresh,forward:r.forward,back:r.back,go:r.go,install:b,initialized:E,onBeforeRouteEnter:i,onAfterRouteUpdate:f,onBeforeRouteLeave:m,onAfterRouteEnter:y,onBeforeRouteUpdate:g,onAfterRouteLeave:L};return x}function nt(e,t){const n=/:\??([\w]+)(?=\W|$)/g;return Array.from(e.matchAll(n)).reduce((o,[a,c])=>{const i=a.startsWith(":?"),f=bt(t,c);if(c in o)throw new $(c);return o[c]=i?kt(f):f,o},{})}function ge(e,t){return{path:e,params:nt(e,t),toString:()=>e}}function we(e,t){const n=Object.keys(e),r=Object.keys(t),o=n.find(a=>r.includes(a));return o?{key:o,hasDuplicates:!0}:{key:void 0,hasDuplicates:!1}}function zt(e,t){const{hasDuplicates:n,key:r}=we(e.params,t.params);if(n)throw new $(r);return ge(`${e.path}${t.path}`,{...e.params,...t.params})}function oe(e,t){return{query:e,params:nt(e,t),toString:()=>e}}function Yt(e,t){const{hasDuplicates:n,key:r}=we(e.params,t.params);if(n)throw new $(r);return oe(`${e.query}${t.query}`,{...e.params,...t.params})}function rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xt(e){return rt(e)&&typeof e.path=="string"}function Zt(e){return Xt(e)?e:ge(e,{})}function en(e){return rt(e)&&typeof e.query=="string"}function tn(e){return e===void 0?oe("",{}):en(e)?e:oe(e,{})}function nn(e){return"children"in e}function rn(e){const t=e.reduce((n,r)=>{const o=on({...r,component:r.component??de});return nn(r)&&n.push(...r.children.map(a=>({...a,key:be(o.key,a.key),path:zt(o.path,a.path),query:Yt(o.query,a.query),matches:[o.matched,...a.matches],depth:a.depth+1}))),n.push(o),n},[]);return t.forEach(({path:n,query:r})=>{const{hasDuplicates:o,key:a}=we(n.params,r.params);if(o)throw new $(a)}),t}function on(e){const t=Zt(e.path),n=tn(e.query),r=u.markRaw({meta:{},...e});return{matched:r,matches:[r],key:e.name,path:t,query:n,pathParams:t.params,queryParams:n.params,depth:1,disabled:e.disabled??!1}}w.DuplicateParamsError=$,w.RouterLink=Le,w.RouterNotInstalledError=Y,w.RouterView=de,w.UseRouteInvalidError=ve,w.createRouter=Qt,w.createRoutes=rn,w.isParamGetSet=me,w.isParamGetter=qe,w.onAfterRouteEnter=pt,w.onAfterRouteLeave=dt,w.onAfterRouteUpdate=mt,w.onBeforeRouteLeave=lt,w.onBeforeRouteUpdate=ht,w.path=ge,w.query=oe,w.routerInjectionKey=se,w.routerRejectionKey=ce,w.useRejection=Ee,w.useRoute=ot,w.useRouter=X,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|