vue-micro-router 1.0.53 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +197 -190
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -24,62 +24,62 @@ function fe(e) {
|
|
|
24
24
|
function Ue(e, o) {
|
|
25
25
|
const n = e.defaultControlName, i = e.onboardingControlName, t = 300, c = Ae();
|
|
26
26
|
let u = !1;
|
|
27
|
-
const
|
|
27
|
+
const s = U(/* @__PURE__ */ new Map()), f = U(
|
|
28
28
|
/* @__PURE__ */ new Map()
|
|
29
29
|
), a = C(() => {
|
|
30
30
|
const l = [];
|
|
31
|
-
for (const
|
|
32
|
-
|
|
31
|
+
for (const r of s.values())
|
|
32
|
+
r.activated && l.push(r);
|
|
33
33
|
return l;
|
|
34
34
|
}), d = a, A = C(
|
|
35
35
|
() => a.value.some((l) => l.name !== n)
|
|
36
36
|
), L = C(() => {
|
|
37
|
-
const l = a.value.find((
|
|
37
|
+
const l = a.value.find((r) => r.name !== n);
|
|
38
38
|
return (l == null ? void 0 : l.name) ?? n;
|
|
39
39
|
});
|
|
40
|
-
function M(l,
|
|
40
|
+
function M(l, r, P) {
|
|
41
41
|
var y, S, p;
|
|
42
|
-
if (!(
|
|
43
|
-
|
|
42
|
+
if (!(r && u)) {
|
|
43
|
+
r && (u = !0);
|
|
44
44
|
try {
|
|
45
|
-
const h =
|
|
45
|
+
const h = s.get(l);
|
|
46
46
|
if (!h) return;
|
|
47
|
-
const v =
|
|
48
|
-
if (
|
|
49
|
-
(y = o == null ? void 0 : o.trackGuiEnter) == null || y.call(o, l), D ?
|
|
47
|
+
const v = s.get(n), D = l === n || l === i;
|
|
48
|
+
if (r)
|
|
49
|
+
(y = o == null ? void 0 : o.trackGuiEnter) == null || y.call(o, l), D ? s.forEach((w) => {
|
|
50
50
|
var b;
|
|
51
|
-
|
|
52
|
-
...
|
|
51
|
+
w.name !== n && w.activated && ((b = o == null ? void 0 : o.trackGuiLeave) == null || b.call(o, w.name), s.set(w.name, {
|
|
52
|
+
...w,
|
|
53
53
|
activated: !1,
|
|
54
54
|
attrs: void 0
|
|
55
55
|
}));
|
|
56
|
-
}) : v != null && v.activated && ((S = o == null ? void 0 : o.trackGuiLeave) == null || S.call(o, n),
|
|
56
|
+
}) : v != null && v.activated && ((S = o == null ? void 0 : o.trackGuiLeave) == null || S.call(o, n), s.set(n, { ...v, activated: !1 })), P && f.set(l, { ...P }), s.set(l, {
|
|
57
57
|
...h,
|
|
58
58
|
activated: !0,
|
|
59
59
|
componentKey: (h.componentKey || 0) + 1,
|
|
60
|
-
attrs:
|
|
60
|
+
attrs: P ? { ...P } : void 0
|
|
61
61
|
});
|
|
62
62
|
else {
|
|
63
|
-
(p = o == null ? void 0 : o.trackGuiLeave) == null || p.call(o, l), f.delete(l),
|
|
64
|
-
const
|
|
65
|
-
if (!D &&
|
|
66
|
-
if (
|
|
67
|
-
|
|
63
|
+
(p = o == null ? void 0 : o.trackGuiLeave) == null || p.call(o, l), f.delete(l), s.set(l, { ...h, activated: !1, attrs: void 0 });
|
|
64
|
+
const w = s.get(n);
|
|
65
|
+
if (!D && w && !w.activated) {
|
|
66
|
+
if (w.name === i) return;
|
|
67
|
+
s.set(n, { ...w, activated: !0 });
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
} finally {
|
|
71
|
-
|
|
71
|
+
r && c.schedule(() => {
|
|
72
72
|
u = !1;
|
|
73
73
|
}, t);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
function _(l) {
|
|
78
|
-
|
|
79
|
-
let { component:
|
|
80
|
-
De(
|
|
78
|
+
s.has(l.name) && console.warn(`[vue-micro-router] Control "${l.name}" already registered. Overwriting.`);
|
|
79
|
+
let { component: r } = l;
|
|
80
|
+
De(r) && (r = me(r)), s.set(l.name, {
|
|
81
81
|
...l,
|
|
82
|
-
component: Ce(
|
|
82
|
+
component: Ce(r)
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
function T(l) {
|
|
@@ -88,9 +88,9 @@ function Ue(e, o) {
|
|
|
88
88
|
function g(l) {
|
|
89
89
|
return f.get(l);
|
|
90
90
|
}
|
|
91
|
-
function m(l,
|
|
92
|
-
const
|
|
93
|
-
f.set(l, { ...
|
|
91
|
+
function m(l, r) {
|
|
92
|
+
const P = f.get(l);
|
|
93
|
+
f.set(l, { ...P, ...r });
|
|
94
94
|
}
|
|
95
95
|
return {
|
|
96
96
|
resolveControls: d,
|
|
@@ -202,22 +202,22 @@ async function ze(e) {
|
|
|
202
202
|
}
|
|
203
203
|
function Fe(e) {
|
|
204
204
|
const o = e.activePath.value.split("/").filter(Boolean), n = {};
|
|
205
|
-
for (const
|
|
206
|
-
const f = e.getRouteAttrs(
|
|
207
|
-
f && (n[
|
|
205
|
+
for (const s of o) {
|
|
206
|
+
const f = e.getRouteAttrs(s);
|
|
207
|
+
f && (n[s] = { ...f });
|
|
208
208
|
}
|
|
209
209
|
const i = [], t = {};
|
|
210
|
-
for (const
|
|
211
|
-
if (
|
|
212
|
-
i.push(
|
|
213
|
-
const f = e.getDialogAttrs(
|
|
214
|
-
f && (t[
|
|
210
|
+
for (const s of e.resolveDialogs.value) {
|
|
211
|
+
if (s.closing) continue;
|
|
212
|
+
i.push(s.path);
|
|
213
|
+
const f = e.getDialogAttrs(s.path);
|
|
214
|
+
f && (t[s.path] = { ...f });
|
|
215
215
|
}
|
|
216
216
|
const c = [], u = {};
|
|
217
|
-
for (const
|
|
218
|
-
c.push(
|
|
219
|
-
const f = e.getControlAttrs(
|
|
220
|
-
f && (u[
|
|
217
|
+
for (const s of e.resolveControls.value) {
|
|
218
|
+
c.push(s.name);
|
|
219
|
+
const f = e.getControlAttrs(s.name);
|
|
220
|
+
f && (u[s.name] = { ...f });
|
|
221
221
|
}
|
|
222
222
|
return {
|
|
223
223
|
version: 1,
|
|
@@ -260,25 +260,25 @@ function Ve(e) {
|
|
|
260
260
|
}), c = C(() => {
|
|
261
261
|
const g = [], m = /* @__PURE__ */ new Set();
|
|
262
262
|
for (const l of t.dialogStack) {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const r = t.dialogs.get(l);
|
|
264
|
+
r && (r.activated || r.closing) && (g.push(r), m.add(l));
|
|
265
265
|
}
|
|
266
266
|
for (const l of t.dialogs.values())
|
|
267
267
|
l.closing && !m.has(l.path) && g.push(l);
|
|
268
268
|
return g;
|
|
269
269
|
}), u = n.schedule;
|
|
270
|
-
function
|
|
270
|
+
function s(g, m) {
|
|
271
271
|
return { path: g, attrs: m };
|
|
272
272
|
}
|
|
273
273
|
function f({ path: g, open: m, attrs: l }) {
|
|
274
|
-
const
|
|
275
|
-
return
|
|
274
|
+
const r = t.dialogs.get(g);
|
|
275
|
+
return r && k(() => {
|
|
276
276
|
if (m)
|
|
277
277
|
t.fromDialog = t.activeDialog, t.toDialog = g, t.dialogStack.includes(g) || t.dialogStack.push(g), t.activeDialog = g, l && t.dialogAttrs.set(g, { ...l }), t.dialogs.set(g, {
|
|
278
|
-
...
|
|
278
|
+
...r,
|
|
279
279
|
activated: !0,
|
|
280
280
|
closing: !1,
|
|
281
|
-
componentKey: (
|
|
281
|
+
componentKey: (r.componentKey || 0) + 1,
|
|
282
282
|
attrs: {
|
|
283
283
|
path: g,
|
|
284
284
|
...l,
|
|
@@ -289,11 +289,11 @@ function Ve(e) {
|
|
|
289
289
|
});
|
|
290
290
|
else {
|
|
291
291
|
t.fromDialog = t.activeDialog;
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const y =
|
|
292
|
+
const P = t.dialogStack.indexOf(g);
|
|
293
|
+
P > -1 && t.dialogStack.splice(P, 1), t.activeDialog = t.dialogStack.at(-1) ?? "", t.toDialog = t.activeDialog;
|
|
294
|
+
const y = r.transitionDuration ?? (r.transition === "slide" ? 500 : 300);
|
|
295
295
|
t.dialogs.set(g, {
|
|
296
|
-
...
|
|
296
|
+
...r,
|
|
297
297
|
activated: !1,
|
|
298
298
|
closing: !0,
|
|
299
299
|
attrs: void 0
|
|
@@ -302,21 +302,21 @@ function Ve(e) {
|
|
|
302
302
|
S && !S.activated && t.dialogs.set(g, { ...S, closing: !1 });
|
|
303
303
|
}, y + 200);
|
|
304
304
|
}
|
|
305
|
-
}),
|
|
305
|
+
}), s(g, l);
|
|
306
306
|
}
|
|
307
307
|
function a(g, m) {
|
|
308
308
|
var l;
|
|
309
|
-
if (i) return
|
|
309
|
+
if (i) return s(g, m);
|
|
310
310
|
i = !0;
|
|
311
311
|
try {
|
|
312
|
-
const
|
|
313
|
-
(l = e == null ? void 0 : e.trackDialogEnter) == null || l.call(e, g,
|
|
314
|
-
const
|
|
312
|
+
const r = t.activeDialog || "";
|
|
313
|
+
(l = e == null ? void 0 : e.trackDialogEnter) == null || l.call(e, g, r, g);
|
|
314
|
+
const P = f({ path: g, open: !0, attrs: m });
|
|
315
315
|
return u(() => {
|
|
316
316
|
i = !1;
|
|
317
|
-
}, 300),
|
|
318
|
-
} catch (
|
|
319
|
-
throw i = !1,
|
|
317
|
+
}, 300), P;
|
|
318
|
+
} catch (r) {
|
|
319
|
+
throw i = !1, r;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
function d(g) {
|
|
@@ -325,22 +325,22 @@ function Ve(e) {
|
|
|
325
325
|
}
|
|
326
326
|
function A() {
|
|
327
327
|
const g = [], m = [];
|
|
328
|
-
t.dialogs.forEach((l,
|
|
329
|
-
var
|
|
328
|
+
t.dialogs.forEach((l, r) => {
|
|
329
|
+
var P, y;
|
|
330
330
|
if (l.activated) {
|
|
331
|
-
(
|
|
331
|
+
(P = e == null ? void 0 : e.trackDialogLeave) == null || P.call(e, r, r, "");
|
|
332
332
|
const S = (y = l.attrs) == null ? void 0 : y.onClose;
|
|
333
|
-
typeof S == "function" && m.push(S), t.dialogs.set(
|
|
333
|
+
typeof S == "function" && m.push(S), t.dialogs.set(r, {
|
|
334
334
|
...l,
|
|
335
335
|
activated: !1,
|
|
336
336
|
closing: !0,
|
|
337
337
|
attrs: void 0
|
|
338
|
-
}), g.push(
|
|
338
|
+
}), g.push(r);
|
|
339
339
|
}
|
|
340
340
|
}), m.forEach((l) => l()), t.dialogAttrs.clear(), t.fromDialog = t.activeDialog, t.toDialog = "", t.activeDialog = "", t.dialogStack = [], u(() => {
|
|
341
341
|
g.forEach((l) => {
|
|
342
|
-
const
|
|
343
|
-
|
|
342
|
+
const r = t.dialogs.get(l);
|
|
343
|
+
r && !r.activated && t.dialogs.set(l, { ...r, closing: !1 });
|
|
344
344
|
});
|
|
345
345
|
}, 500);
|
|
346
346
|
}
|
|
@@ -384,8 +384,8 @@ async function ve(e, o, n, i) {
|
|
|
384
384
|
try {
|
|
385
385
|
const c = await Promise.race([
|
|
386
386
|
Promise.resolve(e(o, n)),
|
|
387
|
-
new Promise((u,
|
|
388
|
-
t = setTimeout(() =>
|
|
387
|
+
new Promise((u, s) => {
|
|
388
|
+
t = setTimeout(() => s(new Error("Navigation guard timed out")), i);
|
|
389
389
|
})
|
|
390
390
|
]);
|
|
391
391
|
return clearTimeout(t), c !== !1;
|
|
@@ -399,9 +399,9 @@ async function je(e, o, n, i = Be) {
|
|
|
399
399
|
return !0;
|
|
400
400
|
}
|
|
401
401
|
async function Ee(e, o, n, i) {
|
|
402
|
-
var
|
|
402
|
+
var s;
|
|
403
403
|
const t = n.guardTimeout ?? Be;
|
|
404
|
-
if ((
|
|
404
|
+
if ((s = n.beforeEach) != null && s.length && !await je(n.beforeEach, e, o, t))
|
|
405
405
|
return !1;
|
|
406
406
|
const c = H(e);
|
|
407
407
|
if (c) {
|
|
@@ -429,7 +429,7 @@ function qe(e, o) {
|
|
|
429
429
|
const n = e.maxEntries ?? 50, i = [];
|
|
430
430
|
let t = -1, c = !1;
|
|
431
431
|
const u = ee(0);
|
|
432
|
-
function
|
|
432
|
+
function s(g, m) {
|
|
433
433
|
!e.enabled || c || (t < i.length - 1 && i.splice(t + 1), i.push({ path: g, timestamp: Date.now(), props: m ? { ...m } : void 0 }), t = i.length - 1, i.length > n && (i.shift(), t--), u.value++);
|
|
434
434
|
}
|
|
435
435
|
const f = C(() => (u.value, [...i])), a = C(() => (u.value, t > 0)), d = C(() => (u.value, t < i.length - 1));
|
|
@@ -458,29 +458,29 @@ function qe(e, o) {
|
|
|
458
458
|
function T() {
|
|
459
459
|
i.length = 0, t = -1, u.value++;
|
|
460
460
|
}
|
|
461
|
-
return { entries: f, canGoBack: a, canGoForward: d, back: L, forward: M, go: _, clear: T, record:
|
|
461
|
+
return { entries: f, canGoBack: a, canGoForward: d, back: L, forward: M, go: _, clear: T, record: s };
|
|
462
462
|
}
|
|
463
463
|
function Je() {
|
|
464
464
|
const e = U(/* @__PURE__ */ new Map()), o = /* @__PURE__ */ new Map();
|
|
465
465
|
function n(u) {
|
|
466
466
|
e.has(u.path) && console.warn(`[vue-micro-router] Route "${u.path}" already registered. Overwriting.`);
|
|
467
|
-
let { component:
|
|
468
|
-
De(
|
|
467
|
+
let { component: s } = u;
|
|
468
|
+
De(s) && (o.set(u.path, s), s = me(s)), e.set(u.path, {
|
|
469
469
|
...u,
|
|
470
|
-
component: Ce(
|
|
470
|
+
component: Ce(s)
|
|
471
471
|
}), u.preload === "eager" && o.has(u.path) && ne(o.get(u.path));
|
|
472
472
|
}
|
|
473
473
|
function i(u) {
|
|
474
474
|
u.forEach(n);
|
|
475
475
|
}
|
|
476
476
|
async function t(u) {
|
|
477
|
-
const
|
|
478
|
-
|
|
477
|
+
const s = o.get(u);
|
|
478
|
+
s && await ne(s);
|
|
479
479
|
}
|
|
480
480
|
function c(u) {
|
|
481
|
-
for (const [
|
|
482
|
-
if (f.preload === "adjacent" && !u.includes(
|
|
483
|
-
const a = o.get(
|
|
481
|
+
for (const [s, f] of e.entries())
|
|
482
|
+
if (f.preload === "adjacent" && !u.includes(s)) {
|
|
483
|
+
const a = o.get(s);
|
|
484
484
|
a && ne(a);
|
|
485
485
|
}
|
|
486
486
|
}
|
|
@@ -501,7 +501,7 @@ function Qe(e) {
|
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const s = B(e.getActivePath()), f = B(u);
|
|
505
505
|
if (t.startsWith("/"))
|
|
506
506
|
for (let a = 0; a < f.length; a++) {
|
|
507
507
|
const d = K(
|
|
@@ -513,7 +513,7 @@ function Qe(e) {
|
|
|
513
513
|
}
|
|
514
514
|
else {
|
|
515
515
|
const a = f.filter(
|
|
516
|
-
(d) => !
|
|
516
|
+
(d) => !s.includes(d)
|
|
517
517
|
);
|
|
518
518
|
if (a.length === 0) {
|
|
519
519
|
await e.pushCore(t, c), e.scheduleUnlock();
|
|
@@ -525,8 +525,8 @@ function Qe(e) {
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
e.scheduleUnlock();
|
|
528
|
-
} catch (
|
|
529
|
-
throw e.unlock(),
|
|
528
|
+
} catch (s) {
|
|
529
|
+
throw e.unlock(), s;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
}
|
|
@@ -537,24 +537,24 @@ function Qe(e) {
|
|
|
537
537
|
e.lock();
|
|
538
538
|
try {
|
|
539
539
|
if (e.runGuards) {
|
|
540
|
-
const
|
|
540
|
+
const s = c.slice(0, c.length - u), f = K(s), a = W(e.getActivePath());
|
|
541
541
|
if (!await e.runGuards(f, a)) {
|
|
542
542
|
e.unlock();
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
for (let
|
|
547
|
-
await e.pushCore(-1),
|
|
546
|
+
for (let s = 0; s < u; s++)
|
|
547
|
+
await e.pushCore(-1), s < u - 1 && await fe(o);
|
|
548
548
|
e.scheduleUnlock();
|
|
549
|
-
} catch (
|
|
550
|
-
throw e.unlock(),
|
|
549
|
+
} catch (s) {
|
|
550
|
+
throw e.unlock(), s;
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
554
|
return { stepWisePush: n, stepWiseBack: i };
|
|
555
555
|
}
|
|
556
556
|
function Ze(e, o) {
|
|
557
|
-
const n = e.defaultPath, i = e.stepDelay ?? Ye, t = e.guards ?? {}, c = e.history ?? {}, u = Ae(),
|
|
557
|
+
const n = e.defaultPath, i = e.stepDelay ?? Ye, t = e.guards ?? {}, c = e.history ?? {}, u = Ae(), s = Je(), f = ee(!1), a = pe({
|
|
558
558
|
activePath: n,
|
|
559
559
|
fromPath: n,
|
|
560
560
|
toPath: n,
|
|
@@ -567,9 +567,9 @@ function Ze(e, o) {
|
|
|
567
567
|
}), d = /* @__PURE__ */ new Map(), A = C(() => {
|
|
568
568
|
const p = B(a.activePath), h = [];
|
|
569
569
|
for (const v of p) {
|
|
570
|
-
const D =
|
|
570
|
+
const D = s.routes.get(v);
|
|
571
571
|
if (!D) continue;
|
|
572
|
-
const
|
|
572
|
+
const w = a.routeKeys.get(v) || 0, b = a.componentKeys.get(v) || 0, E = `${D.path}-${w}`, R = d.get(v);
|
|
573
573
|
if (R && R.key === E && R.componentKey === b)
|
|
574
574
|
h.push(R);
|
|
575
575
|
else {
|
|
@@ -585,10 +585,10 @@ function Ze(e, o) {
|
|
|
585
585
|
var O, I;
|
|
586
586
|
const v = B(a.activePath), D = Math.min(p, v.length - 1);
|
|
587
587
|
if (D <= 0) return;
|
|
588
|
-
const
|
|
588
|
+
const w = v.slice(0, -D), b = K(w);
|
|
589
589
|
for (let $ = v.length - D; $ < v.length; $++)
|
|
590
590
|
a.routeAttrs.delete(v[$]);
|
|
591
|
-
const E =
|
|
591
|
+
const E = w.at(-1);
|
|
592
592
|
if (E && h) {
|
|
593
593
|
const $ = a.routeAttrs.get(E);
|
|
594
594
|
a.routeAttrs.set(E, { ...$, ...h }), a.componentKeys.set(
|
|
@@ -603,10 +603,10 @@ function Ze(e, o) {
|
|
|
603
603
|
var b, E;
|
|
604
604
|
const v = W(p), D = B(v);
|
|
605
605
|
await Promise.all(
|
|
606
|
-
D.map((R) =>
|
|
606
|
+
D.map((R) => s.asyncLoaders.get(R)).filter((R) => !!R).map((R) => ne(R))
|
|
607
607
|
);
|
|
608
|
-
const
|
|
609
|
-
|
|
608
|
+
const w = a.activePath;
|
|
609
|
+
w !== v && ((b = o == null ? void 0 : o.trackPageLeave) == null || b.call(o, w, w, v)), a.fromPath = w, a.toPath = v, a.activePath = v, h && _(v, h), (E = o == null ? void 0 : o.trackPageEnter) == null || E.call(o, v, w, v);
|
|
610
610
|
}
|
|
611
611
|
function _(p, h) {
|
|
612
612
|
const v = B(p).at(-1);
|
|
@@ -648,19 +648,19 @@ function Ze(e, o) {
|
|
|
648
648
|
), await M(v, h);
|
|
649
649
|
return;
|
|
650
650
|
}
|
|
651
|
-
const D = B(a.activePath),
|
|
652
|
-
if (
|
|
653
|
-
const E = D.length - (
|
|
651
|
+
const D = B(a.activePath), w = D.indexOf(v);
|
|
652
|
+
if (w !== -1) {
|
|
653
|
+
const E = D.length - (w + 1);
|
|
654
654
|
if (E === 1)
|
|
655
655
|
L(1, h);
|
|
656
656
|
else if (E > 1) {
|
|
657
|
-
const R = D.slice(0,
|
|
658
|
-
for (let I =
|
|
657
|
+
const R = D.slice(0, w + 2), O = K(R);
|
|
658
|
+
for (let I = w + 2; I < D.length; I++)
|
|
659
659
|
a.routeAttrs.delete(D[I]);
|
|
660
660
|
a.activePath = O, await k(), L(1, h);
|
|
661
661
|
} else
|
|
662
662
|
a.routeKeys.set(v, (a.routeKeys.get(v) || 0) + 1), await M(
|
|
663
|
-
K(D.slice(0,
|
|
663
|
+
K(D.slice(0, w + 1)),
|
|
664
664
|
h
|
|
665
665
|
);
|
|
666
666
|
return;
|
|
@@ -670,24 +670,24 @@ function Ze(e, o) {
|
|
|
670
670
|
}
|
|
671
671
|
function l(p) {
|
|
672
672
|
if (typeof p == "number" && p < 0) {
|
|
673
|
-
const
|
|
674
|
-
return b <= 0 ? a.activePath : K(
|
|
673
|
+
const w = B(a.activePath), b = Math.min(Math.abs(p), w.length - 1);
|
|
674
|
+
return b <= 0 ? a.activePath : K(w.slice(0, -b));
|
|
675
675
|
}
|
|
676
676
|
const h = p.toString();
|
|
677
677
|
if (h.startsWith("/")) return W(h);
|
|
678
678
|
const v = B(a.activePath), D = v.indexOf(h);
|
|
679
679
|
return D !== -1 ? K(v.slice(0, D + 1)) : K([...v, h]);
|
|
680
680
|
}
|
|
681
|
-
const
|
|
682
|
-
async function
|
|
681
|
+
const r = { getRoute: (p) => s.routes.get(p) };
|
|
682
|
+
async function P(p, h) {
|
|
683
683
|
var v;
|
|
684
684
|
if (!f.value) {
|
|
685
685
|
f.value = !0;
|
|
686
686
|
try {
|
|
687
|
-
const D = (((v = t.beforeEach) == null ? void 0 : v.length) ?? 0) > 0,
|
|
688
|
-
if ((D ||
|
|
687
|
+
const D = (((v = t.beforeEach) == null ? void 0 : v.length) ?? 0) > 0, w = s.routes.size > 0;
|
|
688
|
+
if ((D || w) && p) {
|
|
689
689
|
const R = l(p), O = W(a.activePath);
|
|
690
|
-
if (!await Ee(R, O, t,
|
|
690
|
+
if (!await Ee(R, O, t, r)) {
|
|
691
691
|
f.value = !1;
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
@@ -695,7 +695,7 @@ function Ze(e, o) {
|
|
|
695
695
|
const b = W(a.activePath);
|
|
696
696
|
await m(p, h);
|
|
697
697
|
const E = W(a.activePath);
|
|
698
|
-
y == null || y.record(E, h), He(E, b, t.afterEach),
|
|
698
|
+
y == null || y.record(E, h), He(E, b, t.afterEach), s.preloadAdjacent(B(a.activePath)), u.schedule(() => {
|
|
699
699
|
f.value = !1;
|
|
700
700
|
}, i);
|
|
701
701
|
} catch (D) {
|
|
@@ -705,17 +705,17 @@ function Ze(e, o) {
|
|
|
705
705
|
}
|
|
706
706
|
const y = c.enabled ? qe(c, async (p) => {
|
|
707
707
|
const h = B(a.activePath), v = B(p);
|
|
708
|
-
if (v.length < h.length && v.every((
|
|
709
|
-
const
|
|
710
|
-
await
|
|
708
|
+
if (v.length < h.length && v.every((w, b) => h[b] === w)) {
|
|
709
|
+
const w = h.length - v.length;
|
|
710
|
+
await P(-w);
|
|
711
711
|
} else
|
|
712
|
-
await
|
|
712
|
+
await P(p);
|
|
713
713
|
}) : void 0;
|
|
714
714
|
y && y.record(W(n));
|
|
715
715
|
const S = Qe({
|
|
716
716
|
getActivePath: () => a.activePath,
|
|
717
717
|
pushCore: m,
|
|
718
|
-
runGuards: (p, h) => Ee(p, h, t,
|
|
718
|
+
runGuards: (p, h) => Ee(p, h, t, r),
|
|
719
719
|
scheduleUnlock: () => u.schedule(() => {
|
|
720
720
|
f.value = !1;
|
|
721
721
|
}, i),
|
|
@@ -737,15 +737,15 @@ function Ze(e, o) {
|
|
|
737
737
|
toPage: C(() => H(a.toPath)),
|
|
738
738
|
isNavigating: C(() => f.value),
|
|
739
739
|
resolveRoutes: A,
|
|
740
|
-
push:
|
|
740
|
+
push: P,
|
|
741
741
|
stepWisePush: S.stepWisePush,
|
|
742
742
|
stepWiseBack: S.stepWiseBack,
|
|
743
|
-
registerRoute:
|
|
744
|
-
registerRoutes:
|
|
743
|
+
registerRoute: s.registerRoute,
|
|
744
|
+
registerRoutes: s.registerRoutes,
|
|
745
745
|
updateRouteAttrs: T,
|
|
746
746
|
getRouteAttrs: g,
|
|
747
|
-
preloadRoute:
|
|
748
|
-
routes:
|
|
747
|
+
preloadRoute: s.preloadRoute,
|
|
748
|
+
routes: s.routes,
|
|
749
749
|
history: y,
|
|
750
750
|
cleanup: u.cleanup
|
|
751
751
|
};
|
|
@@ -845,11 +845,11 @@ function et(e) {
|
|
|
845
845
|
resumeSound: c.resumeSound,
|
|
846
846
|
updateBackgroundMusic: c.updateBackgroundMusic
|
|
847
847
|
} : {}
|
|
848
|
-
},
|
|
848
|
+
}, s = H(e.defaultPath);
|
|
849
849
|
return X(n.activePage, (a, d) => {
|
|
850
850
|
if (!d) return;
|
|
851
851
|
const A = t.currentControl.value;
|
|
852
|
-
d ===
|
|
852
|
+
d === s && a !== s && o.trackGuiLeave(A), a === s && d !== s && o.trackGuiEnter(A);
|
|
853
853
|
}), c && e.defaultBgm && e.bgmStartRef && X(e.bgmStartRef, (a) => {
|
|
854
854
|
a && !c.isStarted() && c.playSoundSync(e.defaultBgm, !0);
|
|
855
855
|
}, { flush: "sync" }), q(async () => {
|
|
@@ -876,18 +876,18 @@ function mt(e) {
|
|
|
876
876
|
"[vue-micro-router] useMicroState() called without provider and no defaults. Ensure component is inside <RoutePage>, <MicroDialog>, or <MicroControlWrapper>."
|
|
877
877
|
);
|
|
878
878
|
const i = (o == null ? void 0 : o()) ?? {}, t = e ? { ...e } : {};
|
|
879
|
-
for (const
|
|
880
|
-
t[
|
|
879
|
+
for (const s of Object.keys(i))
|
|
880
|
+
t[s] = i[s];
|
|
881
881
|
const c = pe(t);
|
|
882
882
|
n && X(
|
|
883
883
|
c,
|
|
884
|
-
(
|
|
884
|
+
(s) => n({ ...s }),
|
|
885
885
|
{ deep: !0, flush: "post" }
|
|
886
886
|
);
|
|
887
887
|
const u = Ne(c);
|
|
888
888
|
return new Proxy(u, {
|
|
889
|
-
get(
|
|
890
|
-
return typeof f == "string" && !(f in
|
|
889
|
+
get(s, f, a) {
|
|
890
|
+
return typeof f == "string" && !(f in s) && (s[f] = Oe(c, f)), Reflect.get(s, f, a);
|
|
891
891
|
}
|
|
892
892
|
});
|
|
893
893
|
}
|
|
@@ -905,9 +905,9 @@ function pt(e) {
|
|
|
905
905
|
var t;
|
|
906
906
|
return (t = e.onRouteEnter) == null ? void 0 : t.call(e);
|
|
907
907
|
}), X(n, (t) => {
|
|
908
|
-
var u,
|
|
908
|
+
var u, s;
|
|
909
909
|
const c = t === o;
|
|
910
|
-
c && !i ? (u = e.onRouteEnter) == null || u.call(e) : !c && i && ((
|
|
910
|
+
c && !i ? (u = e.onRouteEnter) == null || u.call(e) : !c && i && ((s = e.onRouteLeave) == null || s.call(e)), i = c;
|
|
911
911
|
});
|
|
912
912
|
}
|
|
913
913
|
function ht(e) {
|
|
@@ -924,9 +924,9 @@ function ht(e) {
|
|
|
924
924
|
var t;
|
|
925
925
|
return (t = e.onDialogEnter) == null ? void 0 : t.call(e);
|
|
926
926
|
}), X(n, (t) => {
|
|
927
|
-
var u,
|
|
927
|
+
var u, s;
|
|
928
928
|
const c = t === o;
|
|
929
|
-
c && !i ? (u = e.onDialogEnter) == null || u.call(e) : !c && i && ((
|
|
929
|
+
c && !i ? (u = e.onDialogEnter) == null || u.call(e) : !c && i && ((s = e.onDialogLeave) == null || s.call(e)), i = c;
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
932
|
function yt(e) {
|
|
@@ -943,15 +943,15 @@ function yt(e) {
|
|
|
943
943
|
var t;
|
|
944
944
|
return (t = e.onControlEnter) == null ? void 0 : t.call(e);
|
|
945
945
|
}), X(n, (t) => {
|
|
946
|
-
var u,
|
|
946
|
+
var u, s;
|
|
947
947
|
const c = t === o;
|
|
948
|
-
c && !i ? (u = e.onControlEnter) == null || u.call(e) : !c && i && ((
|
|
948
|
+
c && !i ? (u = e.onControlEnter) == null || u.call(e) : !c && i && ((s = e.onControlLeave) == null || s.call(e)), i = c;
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
951
|
function tt(e, o) {
|
|
952
952
|
if (!e.enabled) return;
|
|
953
953
|
const n = e.edgeWidth ?? 20, i = e.threshold ?? 0.3, t = e.velocityThreshold ?? 0.5;
|
|
954
|
-
let c = 0, u = 0,
|
|
954
|
+
let c = 0, u = 0, s = 0, f = !1, a = null, d = null;
|
|
955
955
|
function A() {
|
|
956
956
|
const l = o.containerRef.value;
|
|
957
957
|
return l ? "$el" in l ? l.$el : l : null;
|
|
@@ -959,30 +959,30 @@ function tt(e, o) {
|
|
|
959
959
|
function L() {
|
|
960
960
|
const l = A();
|
|
961
961
|
if (!l) return { current: null, previous: null };
|
|
962
|
-
const
|
|
963
|
-
return
|
|
964
|
-
current:
|
|
965
|
-
previous:
|
|
962
|
+
const r = l.querySelectorAll(".route-page");
|
|
963
|
+
return r.length < 2 ? { current: r[r.length - 1] ?? null, previous: null } : {
|
|
964
|
+
current: r[r.length - 1],
|
|
965
|
+
previous: r[r.length - 2]
|
|
966
966
|
};
|
|
967
967
|
}
|
|
968
968
|
function M(l) {
|
|
969
969
|
var S;
|
|
970
970
|
if (!o.canGoBack() || l.clientX > n) return;
|
|
971
|
-
const { current:
|
|
972
|
-
if (!
|
|
973
|
-
f = !0, c = l.clientX, u = l.clientY,
|
|
971
|
+
const { current: r, previous: P } = L();
|
|
972
|
+
if (!r) return;
|
|
973
|
+
f = !0, c = l.clientX, u = l.clientY, s = Date.now(), a = r, d = P;
|
|
974
974
|
const y = A();
|
|
975
975
|
(S = y == null ? void 0 : y.setPointerCapture) == null || S.call(y, l.pointerId), a.style.willChange = "transform", d && (d.style.willChange = "transform", d.style.transition = "none"), a.style.transition = "none";
|
|
976
976
|
}
|
|
977
977
|
function _(l) {
|
|
978
978
|
if (!f || !a) return;
|
|
979
|
-
const
|
|
980
|
-
if (Math.abs(l.clientY - u) >
|
|
979
|
+
const r = Math.max(0, l.clientX - c);
|
|
980
|
+
if (Math.abs(l.clientY - u) > r * 1.5) {
|
|
981
981
|
g();
|
|
982
982
|
return;
|
|
983
983
|
}
|
|
984
|
-
const y =
|
|
985
|
-
if (a.style.transform = `translateX(${
|
|
984
|
+
const y = r / window.innerWidth;
|
|
985
|
+
if (a.style.transform = `translateX(${r}px)`, d) {
|
|
986
986
|
const S = -20 + 20 * y;
|
|
987
987
|
d.style.transform = `translateX(${S}%)`;
|
|
988
988
|
}
|
|
@@ -993,8 +993,8 @@ function tt(e, o) {
|
|
|
993
993
|
m(), f = !1;
|
|
994
994
|
return;
|
|
995
995
|
}
|
|
996
|
-
const
|
|
997
|
-
|
|
996
|
+
const r = l.clientX - c, P = Date.now() - s, y = r / P;
|
|
997
|
+
r / window.innerWidth > i || y > t ? (a.style.transition = "transform 0.2s ease-out", a.style.transform = "translateX(100%)", d && (d.style.transition = "transform 0.2s ease-out", d.style.transform = "translateX(0)"), setTimeout(() => {
|
|
998
998
|
m(), o.goBack();
|
|
999
999
|
}, 200)) : (a.style.transition = "transform 0.2s ease-out", a.style.transform = "translateX(0)", d && (d.style.transition = "transform 0.2s ease-out", d.style.transform = "translateX(-20%)"), setTimeout(m, 200)), f = !1;
|
|
1000
1000
|
}
|
|
@@ -1051,65 +1051,72 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1051
1051
|
setup(e, { emit: o }) {
|
|
1052
1052
|
const n = e, i = o, { getDialogAttrs: t, updateDialogAttrs: c } = J();
|
|
1053
1053
|
let u = !1;
|
|
1054
|
-
const
|
|
1054
|
+
const s = ee(null), f = ee(null), a = C(() => n.dialog.transition ?? "scale"), d = C(() => n.dialog.transitionDuration != null ? n.dialog.transitionDuration : a.value === "slide" ? 500 : 300), A = C(() => n.dialog.position ?? "standard"), L = C(() => n.dialog.seamless ?? !1);
|
|
1055
1055
|
function M() {
|
|
1056
|
-
return
|
|
1057
|
-
|
|
1058
|
-
).filter((
|
|
1056
|
+
return s.value ? Array.from(
|
|
1057
|
+
s.value.querySelectorAll(st)
|
|
1058
|
+
).filter((r) => r.offsetParent !== null) : [];
|
|
1059
1059
|
}
|
|
1060
|
-
function _(
|
|
1060
|
+
function _(r) {
|
|
1061
1061
|
var v, D;
|
|
1062
|
-
if (
|
|
1062
|
+
if (r.key === "Escape") {
|
|
1063
1063
|
if (n.dialog.persistent) return;
|
|
1064
|
-
|
|
1064
|
+
r.preventDefault(), r.stopPropagation(), i("close", n.dialog.path);
|
|
1065
1065
|
return;
|
|
1066
1066
|
}
|
|
1067
|
-
if (
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1070
|
-
|
|
1067
|
+
if (r.key !== "Tab") return;
|
|
1068
|
+
const P = M();
|
|
1069
|
+
if (P.length === 0) {
|
|
1070
|
+
r.preventDefault(), (v = s.value) == null || v.focus();
|
|
1071
1071
|
return;
|
|
1072
1072
|
}
|
|
1073
|
-
const y =
|
|
1074
|
-
|
|
1073
|
+
const y = P[0], S = P[P.length - 1], p = document.activeElement, h = !!((D = s.value) != null && D.contains(p));
|
|
1074
|
+
r.shiftKey ? (!h || p === y) && (r.preventDefault(), S.focus()) : (!h || p === S) && (r.preventDefault(), y.focus());
|
|
1075
1075
|
}
|
|
1076
|
-
function T(
|
|
1077
|
-
n.dialog.persistent ||
|
|
1076
|
+
function T(r) {
|
|
1077
|
+
n.dialog.persistent || r.target === r.currentTarget && i("close", n.dialog.path);
|
|
1078
1078
|
}
|
|
1079
|
-
function g() {
|
|
1080
|
-
if (!n.dialog.focusInput || !
|
|
1081
|
-
|
|
1082
|
-
|
|
1079
|
+
function g(r) {
|
|
1080
|
+
if (!n.dialog.focusInput || !s.value) {
|
|
1081
|
+
r();
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
const P = document.createElement("input");
|
|
1085
|
+
P.style.cssText = "position:fixed;opacity:0;height:0;width:0;top:-100px;", s.value.appendChild(P), P.focus(), setTimeout(() => {
|
|
1086
|
+
P.remove(), r();
|
|
1087
|
+
}, 50);
|
|
1083
1088
|
}
|
|
1084
1089
|
function m() {
|
|
1085
1090
|
u || (u = !0, f.value = document.activeElement, at(), k(() => {
|
|
1086
|
-
|
|
1087
|
-
|
|
1091
|
+
s.value && g(() => {
|
|
1092
|
+
if (!s.value) return;
|
|
1093
|
+
(M()[0] ?? s.value).focus();
|
|
1094
|
+
});
|
|
1088
1095
|
}));
|
|
1089
1096
|
}
|
|
1090
1097
|
function l() {
|
|
1091
1098
|
if (!u) return;
|
|
1092
1099
|
u = !1, it();
|
|
1093
|
-
const
|
|
1094
|
-
f.value = null,
|
|
1100
|
+
const r = f.value;
|
|
1101
|
+
f.value = null, r && typeof r.focus == "function" && document.contains(r) && r.focus();
|
|
1095
1102
|
}
|
|
1096
|
-
return N(Te, n.dialog.path), N(ae, () => t(n.dialog.path)), N(ie, (
|
|
1097
|
-
c(n.dialog.path,
|
|
1103
|
+
return N(Te, n.dialog.path), N(ae, () => t(n.dialog.path)), N(ie, (r) => {
|
|
1104
|
+
c(n.dialog.path, r);
|
|
1098
1105
|
}), X(
|
|
1099
1106
|
() => n.dialog.activated,
|
|
1100
|
-
(
|
|
1101
|
-
|
|
1107
|
+
(r) => {
|
|
1108
|
+
r && m();
|
|
1102
1109
|
}
|
|
1103
1110
|
), X(
|
|
1104
1111
|
() => n.dialog.closing,
|
|
1105
|
-
(
|
|
1106
|
-
!
|
|
1112
|
+
(r) => {
|
|
1113
|
+
!r && !n.dialog.activated && u && l();
|
|
1107
1114
|
}
|
|
1108
1115
|
), q(() => {
|
|
1109
1116
|
n.dialog.activated && m();
|
|
1110
1117
|
}), he(() => {
|
|
1111
1118
|
u && l();
|
|
1112
|
-
}), (
|
|
1119
|
+
}), (r, P) => (G(), F(Ke, { to: "body" }, [
|
|
1113
1120
|
j("div", {
|
|
1114
1121
|
class: Q(["micro-dialog-portal", [
|
|
1115
1122
|
`micro-dialog--${A.value}`,
|
|
@@ -1128,7 +1135,7 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1128
1135
|
}, null, 2)),
|
|
1129
1136
|
j("div", {
|
|
1130
1137
|
ref_key: "wrapperRef",
|
|
1131
|
-
ref:
|
|
1138
|
+
ref: s,
|
|
1132
1139
|
role: "dialog",
|
|
1133
1140
|
"aria-modal": "true",
|
|
1134
1141
|
tabindex: "-1",
|
|
@@ -1141,10 +1148,10 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1141
1148
|
}, [
|
|
1142
1149
|
j("div", {
|
|
1143
1150
|
class: "micro-dialog__content",
|
|
1144
|
-
onClick:
|
|
1151
|
+
onClick: P[0] || (P[0] = le(() => {
|
|
1145
1152
|
}, ["stop"]))
|
|
1146
1153
|
}, [
|
|
1147
|
-
we(
|
|
1154
|
+
we(r.$slots, "default"),
|
|
1148
1155
|
(G(), F(ye(e.dialog.component), Pe({
|
|
1149
1156
|
key: e.dialog.componentKey
|
|
1150
1157
|
}, e.dialog.attrs), null, 16))
|
|
@@ -1190,18 +1197,18 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1190
1197
|
resolveDialogs: t,
|
|
1191
1198
|
resolveControls: c,
|
|
1192
1199
|
fromPath: u,
|
|
1193
|
-
toPath:
|
|
1200
|
+
toPath: s,
|
|
1194
1201
|
isNavigating: f,
|
|
1195
1202
|
closeDialog: a
|
|
1196
1203
|
} = n, d = ee(null), A = C(() => {
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
1204
|
+
const r = u.value.split("/").filter(Boolean), P = new Set(s.value.split("/").filter(Boolean));
|
|
1205
|
+
return r.some((y) => P.has(y));
|
|
1199
1206
|
}), L = C(() => c.value.length > 0), M = C(() => {
|
|
1200
|
-
const
|
|
1201
|
-
return (
|
|
1207
|
+
const r = i.value.at(-1);
|
|
1208
|
+
return (r == null ? void 0 : r.transition) ?? "slide";
|
|
1202
1209
|
}), _ = C(() => M.value === "none" ? "" : M.value === "fade" ? "page-fade" : "page-slide"), T = C(() => {
|
|
1203
|
-
const
|
|
1204
|
-
return
|
|
1210
|
+
const r = i.value.at(-1);
|
|
1211
|
+
return r != null && r.transitionDuration ? r.transitionDuration : M.value === "fade" ? 300 : 500;
|
|
1205
1212
|
}), g = C(
|
|
1206
1213
|
() => A.value && M.value !== "none"
|
|
1207
1214
|
);
|
|
@@ -1209,7 +1216,7 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1209
1216
|
containerRef: d,
|
|
1210
1217
|
goBack: () => n.push(-1),
|
|
1211
1218
|
canGoBack: () => i.value.length > 1
|
|
1212
|
-
}), (
|
|
1219
|
+
}), (r, P) => (G(), V(te, null, [
|
|
1213
1220
|
Re(Se, {
|
|
1214
1221
|
ref_key: "pageContainerRef",
|
|
1215
1222
|
ref: d,
|
|
@@ -1241,7 +1248,7 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
|
|
|
1241
1248
|
_: 1
|
|
1242
1249
|
}, 8, ["name", "css"]),
|
|
1243
1250
|
j("div", ft, [
|
|
1244
|
-
we(
|
|
1251
|
+
we(r.$slots, "default")
|
|
1245
1252
|
]),
|
|
1246
1253
|
j("div", {
|
|
1247
1254
|
class: Q(["micro-router-gui-layer", { "gui-visible": L.value }])
|