vue-micro-router 1.0.25 → 1.0.26
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 +143 -132
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ const Ee = Symbol("micro-router");
|
|
|
4
4
|
function ct() {
|
|
5
5
|
return Symbol("micro-router-nested");
|
|
6
6
|
}
|
|
7
|
-
const ce = Symbol("micro-router-root"), Se = Symbol("micro-route-path"),
|
|
7
|
+
const ce = Symbol("micro-router-root"), Se = Symbol("micro-route-path"), Le = Symbol("micro-dialog-path"), Me = Symbol("micro-control-name"), te = Symbol("micro-attrs-read"), ne = Symbol("micro-attrs-write"), Ke = 550;
|
|
8
8
|
function K(e) {
|
|
9
9
|
return e.startsWith("/") ? e : `/${e}`;
|
|
10
10
|
}
|
|
@@ -43,24 +43,24 @@ function $e(e, n) {
|
|
|
43
43
|
for (const f of r.values())
|
|
44
44
|
f.activated && s.push(f);
|
|
45
45
|
return s;
|
|
46
|
-
}), d = a,
|
|
46
|
+
}), d = a, D = R(
|
|
47
47
|
() => a.value.some((s) => s.name !== o)
|
|
48
|
-
),
|
|
48
|
+
), M = R(() => {
|
|
49
49
|
const s = a.value.find((f) => f.name !== o);
|
|
50
50
|
return (s == null ? void 0 : s.name) ?? o;
|
|
51
51
|
});
|
|
52
52
|
function T(s, f, y) {
|
|
53
|
-
var
|
|
53
|
+
var C, _, p;
|
|
54
54
|
if (!(f && l)) {
|
|
55
55
|
f && (l = !0);
|
|
56
56
|
try {
|
|
57
57
|
const h = r.get(s);
|
|
58
58
|
if (!h) return;
|
|
59
|
-
const v = r.get(o),
|
|
59
|
+
const v = r.get(o), A = s === o || s === i;
|
|
60
60
|
if (f)
|
|
61
|
-
(
|
|
62
|
-
var
|
|
63
|
-
P.name !== o && P.activated && ((
|
|
61
|
+
(C = n == null ? void 0 : n.trackGuiEnter) == null || C.call(n, s), A ? r.forEach((P) => {
|
|
62
|
+
var L;
|
|
63
|
+
P.name !== o && P.activated && ((L = n == null ? void 0 : n.trackGuiLeave) == null || L.call(n, P.name), r.set(P.name, {
|
|
64
64
|
...P,
|
|
65
65
|
activated: !1,
|
|
66
66
|
attrs: void 0
|
|
@@ -74,7 +74,7 @@ function $e(e, n) {
|
|
|
74
74
|
else {
|
|
75
75
|
(p = n == null ? void 0 : n.trackGuiLeave) == null || p.call(n, s), u.delete(s), r.set(s, { ...h, activated: !1, attrs: void 0 });
|
|
76
76
|
const P = r.get(o);
|
|
77
|
-
if (!
|
|
77
|
+
if (!A && P && !P.activated) {
|
|
78
78
|
if (P.name === i) return;
|
|
79
79
|
r.set(o, { ...P, activated: !0 });
|
|
80
80
|
}
|
|
@@ -94,7 +94,7 @@ function $e(e, n) {
|
|
|
94
94
|
component: ye(f)
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function b(s) {
|
|
98
98
|
s.forEach(w);
|
|
99
99
|
}
|
|
100
100
|
function g(s) {
|
|
@@ -106,11 +106,11 @@ function $e(e, n) {
|
|
|
106
106
|
}
|
|
107
107
|
return {
|
|
108
108
|
resolveControls: d,
|
|
109
|
-
activeControl:
|
|
110
|
-
currentControl:
|
|
109
|
+
activeControl: D,
|
|
110
|
+
currentControl: M,
|
|
111
111
|
toggleControl: T,
|
|
112
112
|
registerControl: w,
|
|
113
|
-
registerControls:
|
|
113
|
+
registerControls: b,
|
|
114
114
|
getControlAttrs: g,
|
|
115
115
|
updateControlAttrs: m,
|
|
116
116
|
cleanup: c.cleanup
|
|
@@ -298,7 +298,7 @@ function Ve(e) {
|
|
|
298
298
|
t.fromDialog = t.activeDialog;
|
|
299
299
|
const y = t.dialogStack.indexOf(g);
|
|
300
300
|
y > -1 && t.dialogStack.splice(y, 1), t.activeDialog = t.dialogStack.at(-1) ?? "", t.toDialog = t.activeDialog;
|
|
301
|
-
const
|
|
301
|
+
const C = f.transitionDuration ?? (f.transition === "slide" ? 500 : 300);
|
|
302
302
|
t.dialogs.set(g, {
|
|
303
303
|
...f,
|
|
304
304
|
activated: !1,
|
|
@@ -307,7 +307,7 @@ function Ve(e) {
|
|
|
307
307
|
}), l(() => {
|
|
308
308
|
const _ = t.dialogs.get(g);
|
|
309
309
|
_ && !_.activated && t.dialogs.set(g, { ..._, closing: !1 });
|
|
310
|
-
},
|
|
310
|
+
}, C + 200);
|
|
311
311
|
}
|
|
312
312
|
}), r(g, s);
|
|
313
313
|
}
|
|
@@ -330,13 +330,13 @@ function Ve(e) {
|
|
|
330
330
|
var m;
|
|
331
331
|
(m = e == null ? void 0 : e.trackDialogLeave) == null || m.call(e, g, g, ""), t.dialogAttrs.delete(g), u({ path: g, open: !1 });
|
|
332
332
|
}
|
|
333
|
-
function
|
|
333
|
+
function D() {
|
|
334
334
|
const g = [], m = [];
|
|
335
335
|
t.dialogs.forEach((s, f) => {
|
|
336
|
-
var y,
|
|
336
|
+
var y, C;
|
|
337
337
|
if (s.activated) {
|
|
338
338
|
(y = e == null ? void 0 : e.trackDialogLeave) == null || y.call(e, f, f, "");
|
|
339
|
-
const _ = (
|
|
339
|
+
const _ = (C = s.attrs) == null ? void 0 : C.onClose;
|
|
340
340
|
typeof _ == "function" && m.push(_), t.dialogs.set(f, {
|
|
341
341
|
...s,
|
|
342
342
|
activated: !1,
|
|
@@ -351,7 +351,7 @@ function Ve(e) {
|
|
|
351
351
|
});
|
|
352
352
|
}, 500);
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function M(g) {
|
|
355
355
|
t.dialogs.has(g.path) && console.warn(`[vue-micro-router] Dialog "${g.path}" already registered. Overwriting.`);
|
|
356
356
|
let { component: m } = g;
|
|
357
357
|
Pe(m) && (m = ge(m)), t.dialogs.set(g.path, {
|
|
@@ -361,12 +361,12 @@ function Ve(e) {
|
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
function T(g) {
|
|
364
|
-
g.forEach(
|
|
364
|
+
g.forEach(M);
|
|
365
365
|
}
|
|
366
366
|
function w(g) {
|
|
367
367
|
return t.dialogAttrs.get(g);
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function b(g, m) {
|
|
370
370
|
const s = t.dialogAttrs.get(g);
|
|
371
371
|
t.dialogAttrs.set(g, { ...s, ...m });
|
|
372
372
|
}
|
|
@@ -377,15 +377,15 @@ function Ve(e) {
|
|
|
377
377
|
resolveDialogs: c,
|
|
378
378
|
openDialog: a,
|
|
379
379
|
closeDialog: d,
|
|
380
|
-
closeAllDialogs:
|
|
381
|
-
registerDialog:
|
|
380
|
+
closeAllDialogs: D,
|
|
381
|
+
registerDialog: M,
|
|
382
382
|
registerDialogs: T,
|
|
383
383
|
getDialogAttrs: w,
|
|
384
|
-
updateDialogAttrs:
|
|
384
|
+
updateDialogAttrs: b,
|
|
385
385
|
cleanup: o.cleanup
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const be = 5e3;
|
|
389
389
|
async function ue(e, n, o, i) {
|
|
390
390
|
let t;
|
|
391
391
|
try {
|
|
@@ -400,14 +400,14 @@ async function ue(e, n, o, i) {
|
|
|
400
400
|
return clearTimeout(t), !1;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
async function Fe(e, n, o, i =
|
|
403
|
+
async function Fe(e, n, o, i = be) {
|
|
404
404
|
for (const t of e)
|
|
405
405
|
if (!await ue(t, n, o, i)) return !1;
|
|
406
406
|
return !0;
|
|
407
407
|
}
|
|
408
408
|
async function Ce(e, n, o, i) {
|
|
409
409
|
var r;
|
|
410
|
-
const t = o.guardTimeout ??
|
|
410
|
+
const t = o.guardTimeout ?? be;
|
|
411
411
|
if ((r = o.beforeEach) != null && r.length && !await Fe(o.beforeEach, e, n, t))
|
|
412
412
|
return !1;
|
|
413
413
|
const c = x(e);
|
|
@@ -440,7 +440,7 @@ function je(e, n) {
|
|
|
440
440
|
!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 > o && (i.shift(), t--), l.value++);
|
|
441
441
|
}
|
|
442
442
|
const u = R(() => (l.value, [...i])), a = R(() => (l.value, t > 0)), d = R(() => (l.value, t < i.length - 1));
|
|
443
|
-
async function
|
|
443
|
+
async function D(g) {
|
|
444
444
|
if (g < 0 || g >= i.length) return;
|
|
445
445
|
const m = i[g];
|
|
446
446
|
if (m) {
|
|
@@ -452,20 +452,20 @@ function je(e, n) {
|
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
async function
|
|
456
|
-
a.value && await
|
|
455
|
+
async function M() {
|
|
456
|
+
a.value && await D(t - 1);
|
|
457
457
|
}
|
|
458
458
|
async function T() {
|
|
459
|
-
d.value && await
|
|
459
|
+
d.value && await D(t + 1);
|
|
460
460
|
}
|
|
461
461
|
async function w(g) {
|
|
462
462
|
const m = t + g;
|
|
463
|
-
await
|
|
463
|
+
await D(m);
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function b() {
|
|
466
466
|
i.length = 0, t = -1, l.value++;
|
|
467
467
|
}
|
|
468
|
-
return { entries: u, canGoBack: a, canGoForward: d, back:
|
|
468
|
+
return { entries: u, canGoBack: a, canGoForward: d, back: M, forward: T, go: w, clear: b, record: r };
|
|
469
469
|
}
|
|
470
470
|
function He() {
|
|
471
471
|
const e = $(/* @__PURE__ */ new Map()), n = /* @__PURE__ */ new Map();
|
|
@@ -515,8 +515,8 @@ function qe(e) {
|
|
|
515
515
|
u.slice(0, a + 1)
|
|
516
516
|
);
|
|
517
517
|
if (e.getActivePath() === d) continue;
|
|
518
|
-
const
|
|
519
|
-
await e.pushCore(d,
|
|
518
|
+
const D = a === u.length - 1;
|
|
519
|
+
await e.pushCore(d, D ? c : void 0), D || await se(n);
|
|
520
520
|
}
|
|
521
521
|
else {
|
|
522
522
|
const a = u.filter(
|
|
@@ -527,8 +527,8 @@ function qe(e) {
|
|
|
527
527
|
return;
|
|
528
528
|
}
|
|
529
529
|
for (let d = 0; d < a.length; d++) {
|
|
530
|
-
const
|
|
531
|
-
await e.pushCore(a[d],
|
|
530
|
+
const D = d === a.length - 1;
|
|
531
|
+
await e.pushCore(a[d], D ? c : void 0), D || await se(n);
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
e.scheduleUnlock();
|
|
@@ -573,16 +573,16 @@ function Je(e, n) {
|
|
|
573
573
|
routeKeys: $(/* @__PURE__ */ new Map()),
|
|
574
574
|
/** Component key per segment — incremented to force Vue full remount (resets local state) */
|
|
575
575
|
componentKeys: $(/* @__PURE__ */ new Map())
|
|
576
|
-
}), d = /* @__PURE__ */ new Map(),
|
|
576
|
+
}), d = /* @__PURE__ */ new Map(), D = R(() => {
|
|
577
577
|
const p = G(a.activePath), h = [];
|
|
578
578
|
for (const v of p) {
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
581
|
-
const P = a.routeKeys.get(v) || 0,
|
|
582
|
-
if (E && E.key === S && E.componentKey ===
|
|
579
|
+
const A = r.routes.get(v);
|
|
580
|
+
if (!A) continue;
|
|
581
|
+
const P = a.routeKeys.get(v) || 0, L = a.componentKeys.get(v) || 0, S = `${A.path}-${P}`, E = d.get(v);
|
|
582
|
+
if (E && E.key === S && E.componentKey === L)
|
|
583
583
|
h.push(E);
|
|
584
584
|
else {
|
|
585
|
-
const N = { ...
|
|
585
|
+
const N = { ...A, key: S, componentKey: L };
|
|
586
586
|
d.set(v, N), h.push(N);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
@@ -590,12 +590,12 @@ function Je(e, n) {
|
|
|
590
590
|
p.includes(v) || d.delete(v);
|
|
591
591
|
return h;
|
|
592
592
|
});
|
|
593
|
-
function
|
|
593
|
+
function M(p, h) {
|
|
594
594
|
var N, O;
|
|
595
|
-
const v = G(a.activePath),
|
|
596
|
-
if (
|
|
597
|
-
const P = v.slice(0, -
|
|
598
|
-
v.slice(-
|
|
595
|
+
const v = G(a.activePath), A = Math.min(p, v.length - 1);
|
|
596
|
+
if (A <= 0) return;
|
|
597
|
+
const P = v.slice(0, -A), L = W(P);
|
|
598
|
+
v.slice(-A).forEach((F) => {
|
|
599
599
|
a.routeAttrs.delete(F);
|
|
600
600
|
});
|
|
601
601
|
const S = P.at(-1);
|
|
@@ -607,24 +607,24 @@ function Je(e, n) {
|
|
|
607
607
|
);
|
|
608
608
|
}
|
|
609
609
|
const E = a.activePath;
|
|
610
|
-
(N = n == null ? void 0 : n.trackPageLeave) == null || N.call(n, E, E,
|
|
610
|
+
(N = n == null ? void 0 : n.trackPageLeave) == null || N.call(n, E, E, L), a.fromPath = E, a.toPath = L, a.activePath = L, (O = n == null ? void 0 : n.trackPageEnter) == null || O.call(n, L, E, L);
|
|
611
611
|
}
|
|
612
612
|
async function T(p, h) {
|
|
613
|
-
var
|
|
614
|
-
const v = K(p),
|
|
613
|
+
var L, S;
|
|
614
|
+
const v = K(p), A = G(v);
|
|
615
615
|
await Promise.all(
|
|
616
|
-
|
|
616
|
+
A.map((E) => r.asyncLoaders.get(E)).filter((E) => !!E).map((E) => k(E))
|
|
617
617
|
);
|
|
618
618
|
const P = a.activePath;
|
|
619
|
-
P !== v && ((
|
|
619
|
+
P !== v && ((L = n == null ? void 0 : n.trackPageLeave) == null || L.call(n, P, P, v)), a.fromPath = P, a.toPath = v, a.activePath = v, h && w(v, h), (S = n == null ? void 0 : n.trackPageEnter) == null || S.call(n, v, P, v);
|
|
620
620
|
}
|
|
621
621
|
function w(p, h) {
|
|
622
622
|
const v = G(p).at(-1);
|
|
623
623
|
if (!v) return;
|
|
624
|
-
const
|
|
625
|
-
a.routeAttrs.set(v, { ...
|
|
624
|
+
const A = a.routeAttrs.get(v);
|
|
625
|
+
a.routeAttrs.set(v, { ...A, ...h });
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function b(p, h) {
|
|
628
628
|
const v = a.routeAttrs.get(p);
|
|
629
629
|
a.routeAttrs.set(p, { ...v, ...h });
|
|
630
630
|
}
|
|
@@ -634,7 +634,7 @@ function Je(e, n) {
|
|
|
634
634
|
async function m(p, h) {
|
|
635
635
|
if (!p && p !== 0) return;
|
|
636
636
|
if (typeof p == "number" && p < 0) {
|
|
637
|
-
|
|
637
|
+
M(Math.abs(p), h);
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
640
640
|
const v = p.toString();
|
|
@@ -642,12 +642,12 @@ function Je(e, n) {
|
|
|
642
642
|
const S = G(v), E = G(a.activePath);
|
|
643
643
|
if (S.length < E.length && S.every((F, oe) => E[oe] === F)) {
|
|
644
644
|
if (E.length - S.length === 1)
|
|
645
|
-
|
|
645
|
+
M(1, h);
|
|
646
646
|
else {
|
|
647
647
|
const oe = E.slice(0, S.length + 1), _e = W(oe);
|
|
648
648
|
E.slice(S.length + 1).forEach((Te) => {
|
|
649
649
|
a.routeAttrs.delete(Te);
|
|
650
|
-
}), a.activePath = _e, await J(),
|
|
650
|
+
}), a.activePath = _e, await J(), M(1, h);
|
|
651
651
|
}
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
@@ -658,35 +658,35 @@ function Je(e, n) {
|
|
|
658
658
|
), await T(v, h);
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
661
|
-
const
|
|
661
|
+
const A = G(a.activePath), P = A.indexOf(v);
|
|
662
662
|
if (P !== -1) {
|
|
663
|
-
const S =
|
|
663
|
+
const S = A.length - (P + 1);
|
|
664
664
|
if (S === 1)
|
|
665
|
-
|
|
665
|
+
M(1, h);
|
|
666
666
|
else if (S > 1) {
|
|
667
|
-
const E =
|
|
668
|
-
|
|
667
|
+
const E = A.slice(0, P + 2), N = W(E);
|
|
668
|
+
A.slice(P + 2).forEach((O) => {
|
|
669
669
|
a.routeAttrs.delete(O);
|
|
670
|
-
}), a.activePath = N, await J(),
|
|
670
|
+
}), a.activePath = N, await J(), M(1, h);
|
|
671
671
|
} else
|
|
672
672
|
a.routeKeys.set(v, (a.routeKeys.get(v) || 0) + 1), await T(
|
|
673
|
-
W(
|
|
673
|
+
W(A.slice(0, P + 1)),
|
|
674
674
|
h
|
|
675
675
|
);
|
|
676
676
|
return;
|
|
677
677
|
}
|
|
678
|
-
const
|
|
679
|
-
await T(
|
|
678
|
+
const L = W([...A, v]);
|
|
679
|
+
await T(L, h);
|
|
680
680
|
}
|
|
681
681
|
function s(p) {
|
|
682
682
|
if (typeof p == "number" && p < 0) {
|
|
683
|
-
const P = G(a.activePath),
|
|
684
|
-
return
|
|
683
|
+
const P = G(a.activePath), L = Math.min(Math.abs(p), P.length - 1);
|
|
684
|
+
return L <= 0 ? a.activePath : W(P.slice(0, -L));
|
|
685
685
|
}
|
|
686
686
|
const h = p.toString();
|
|
687
687
|
if (h.startsWith("/")) return K(h);
|
|
688
|
-
const v = G(a.activePath),
|
|
689
|
-
return W(
|
|
688
|
+
const v = G(a.activePath), A = v.indexOf(h);
|
|
689
|
+
return W(A !== -1 ? v.slice(0, A + 1) : [...v, h]);
|
|
690
690
|
}
|
|
691
691
|
const f = { getRoute: (p) => r.routes.get(p) };
|
|
692
692
|
async function y(p, h) {
|
|
@@ -694,34 +694,34 @@ function Je(e, n) {
|
|
|
694
694
|
if (!u) {
|
|
695
695
|
u = !0;
|
|
696
696
|
try {
|
|
697
|
-
const
|
|
698
|
-
if ((
|
|
697
|
+
const A = (((v = t.beforeEach) == null ? void 0 : v.length) ?? 0) > 0, P = r.routes.size > 0;
|
|
698
|
+
if ((A || P) && p) {
|
|
699
699
|
const E = s(p), N = K(a.activePath);
|
|
700
700
|
if (!await Ce(E, N, t, f)) {
|
|
701
701
|
u = !1;
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
const
|
|
705
|
+
const L = K(a.activePath);
|
|
706
706
|
await m(p, h);
|
|
707
707
|
const S = K(a.activePath);
|
|
708
|
-
|
|
708
|
+
C == null || C.record(S, h), xe(S, L, t.afterEach), r.preloadAdjacent(G(a.activePath)), l.schedule(() => {
|
|
709
709
|
u = !1;
|
|
710
710
|
}, i);
|
|
711
|
-
} catch (
|
|
712
|
-
throw u = !1,
|
|
711
|
+
} catch (A) {
|
|
712
|
+
throw u = !1, A;
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
const
|
|
716
|
+
const C = c.enabled ? je(c, async (p) => {
|
|
717
717
|
const h = G(a.activePath), v = G(p);
|
|
718
|
-
if (v.length < h.length && v.every((P,
|
|
718
|
+
if (v.length < h.length && v.every((P, L) => h[L] === P)) {
|
|
719
719
|
const P = h.length - v.length;
|
|
720
720
|
await y(-P);
|
|
721
721
|
} else
|
|
722
722
|
await y(p);
|
|
723
723
|
}) : void 0;
|
|
724
|
-
|
|
724
|
+
C && C.record(K(o));
|
|
725
725
|
const _ = qe({
|
|
726
726
|
getActivePath: () => a.activePath,
|
|
727
727
|
pushCore: m,
|
|
@@ -745,17 +745,17 @@ function Je(e, n) {
|
|
|
745
745
|
activePage: R(() => x(a.activePath)),
|
|
746
746
|
fromPage: R(() => x(a.fromPath)),
|
|
747
747
|
toPage: R(() => x(a.toPath)),
|
|
748
|
-
resolveRoutes:
|
|
748
|
+
resolveRoutes: D,
|
|
749
749
|
push: y,
|
|
750
750
|
stepWisePush: _.stepWisePush,
|
|
751
751
|
stepWiseBack: _.stepWiseBack,
|
|
752
752
|
registerRoute: r.registerRoute,
|
|
753
753
|
registerRoutes: r.registerRoutes,
|
|
754
|
-
updateRouteAttrs:
|
|
754
|
+
updateRouteAttrs: b,
|
|
755
755
|
getRouteAttrs: g,
|
|
756
756
|
preloadRoute: r.preloadRoute,
|
|
757
757
|
routes: r.routes,
|
|
758
|
-
history:
|
|
758
|
+
history: C,
|
|
759
759
|
cleanup: l.cleanup
|
|
760
760
|
};
|
|
761
761
|
}
|
|
@@ -847,13 +847,24 @@ function Ze(e) {
|
|
|
847
847
|
updateBackgroundMusic: c.updateBackgroundMusic
|
|
848
848
|
} : {}
|
|
849
849
|
}, r = x(e.defaultPath);
|
|
850
|
-
|
|
850
|
+
if (Y(o.activePage, (a, d) => {
|
|
851
851
|
if (!d) return;
|
|
852
|
-
const
|
|
853
|
-
d === r && a !== r && n.trackGuiLeave(
|
|
854
|
-
}), c
|
|
855
|
-
|
|
856
|
-
|
|
852
|
+
const D = t.currentControl.value;
|
|
853
|
+
d === r && a !== r && n.trackGuiLeave(D), a === r && d !== r && n.trackGuiEnter(D);
|
|
854
|
+
}), c) {
|
|
855
|
+
let a = !1;
|
|
856
|
+
Y(o.activePath, (D) => {
|
|
857
|
+
c.updateBackgroundMusic(D, o.routes);
|
|
858
|
+
});
|
|
859
|
+
const d = () => {
|
|
860
|
+
a || (a = !0, c.updateBackgroundMusic(
|
|
861
|
+
o.activePath.value,
|
|
862
|
+
o.routes
|
|
863
|
+
), document.removeEventListener("click", d), document.removeEventListener("touchstart", d));
|
|
864
|
+
};
|
|
865
|
+
document.addEventListener("click", d, { once: !0 }), document.addEventListener("touchstart", d, { once: !0 });
|
|
866
|
+
}
|
|
867
|
+
return j(async () => {
|
|
857
868
|
await J(), t.toggleControl(e.defaultControlName, !0), n.trackPageEnter(
|
|
858
869
|
o.activePath.value,
|
|
859
870
|
void 0,
|
|
@@ -912,7 +923,7 @@ function gt(e) {
|
|
|
912
923
|
});
|
|
913
924
|
}
|
|
914
925
|
function ft(e) {
|
|
915
|
-
const n = V(
|
|
926
|
+
const n = V(Le);
|
|
916
927
|
if (!n) {
|
|
917
928
|
console.warn(
|
|
918
929
|
"[vue-micro-router] useDialogLifecycle() must be called inside a dialog component rendered by <MicroDialog>."
|
|
@@ -931,7 +942,7 @@ function ft(e) {
|
|
|
931
942
|
});
|
|
932
943
|
}
|
|
933
944
|
function dt(e) {
|
|
934
|
-
const n = V(
|
|
945
|
+
const n = V(Me);
|
|
935
946
|
if (!n) {
|
|
936
947
|
console.warn(
|
|
937
948
|
"[vue-micro-router] useControlLifecycle() must be called inside a control component rendered by <MicroControlWrapper>."
|
|
@@ -953,12 +964,12 @@ function ke(e, n) {
|
|
|
953
964
|
if (!e.enabled) return;
|
|
954
965
|
const o = e.edgeWidth ?? 20, i = e.threshold ?? 0.3, t = e.velocityThreshold ?? 0.5;
|
|
955
966
|
let c = 0, l = 0, r = 0, u = !1, a = null, d = null;
|
|
956
|
-
function
|
|
967
|
+
function D() {
|
|
957
968
|
const s = n.containerRef.value;
|
|
958
969
|
return s ? "$el" in s ? s.$el : s : null;
|
|
959
970
|
}
|
|
960
|
-
function
|
|
961
|
-
const s =
|
|
971
|
+
function M() {
|
|
972
|
+
const s = D();
|
|
962
973
|
if (!s) return { current: null, previous: null };
|
|
963
974
|
const f = s.querySelectorAll(".route-page");
|
|
964
975
|
return f.length < 2 ? { current: f[f.length - 1] ?? null, previous: null } : {
|
|
@@ -969,11 +980,11 @@ function ke(e, n) {
|
|
|
969
980
|
function T(s) {
|
|
970
981
|
var _;
|
|
971
982
|
if (!n.canGoBack() || s.clientX > o) return;
|
|
972
|
-
const { current: f, previous: y } =
|
|
983
|
+
const { current: f, previous: y } = M();
|
|
973
984
|
if (!f) return;
|
|
974
985
|
u = !0, c = s.clientX, l = s.clientY, r = Date.now(), a = f, d = y;
|
|
975
|
-
const
|
|
976
|
-
(_ =
|
|
986
|
+
const C = D();
|
|
987
|
+
(_ = C == null ? void 0 : C.setPointerCapture) == null || _.call(C, s.pointerId), a.style.willChange = "transform", d && (d.style.willChange = "transform", d.style.transition = "none"), a.style.transition = "none";
|
|
977
988
|
}
|
|
978
989
|
function w(s) {
|
|
979
990
|
if (!u || !a) return;
|
|
@@ -982,20 +993,20 @@ function ke(e, n) {
|
|
|
982
993
|
g();
|
|
983
994
|
return;
|
|
984
995
|
}
|
|
985
|
-
const
|
|
996
|
+
const C = f / window.innerWidth;
|
|
986
997
|
if (a.style.transform = `translateX(${f}px)`, d) {
|
|
987
|
-
const _ = -20 + 20 *
|
|
998
|
+
const _ = -20 + 20 * C;
|
|
988
999
|
d.style.transform = `translateX(${_}%)`;
|
|
989
1000
|
}
|
|
990
1001
|
}
|
|
991
|
-
function
|
|
1002
|
+
function b(s) {
|
|
992
1003
|
if (!u || !a) return;
|
|
993
1004
|
if (!a.isConnected) {
|
|
994
1005
|
m(), u = !1;
|
|
995
1006
|
return;
|
|
996
1007
|
}
|
|
997
|
-
const f = s.clientX - c, y = Date.now() - r,
|
|
998
|
-
f / window.innerWidth > i ||
|
|
1008
|
+
const f = s.clientX - c, y = Date.now() - r, C = f / y;
|
|
1009
|
+
f / window.innerWidth > i || C > 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(() => {
|
|
999
1010
|
m(), n.goBack();
|
|
1000
1011
|
}, 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)), u = !1;
|
|
1001
1012
|
}
|
|
@@ -1006,11 +1017,11 @@ function ke(e, n) {
|
|
|
1006
1017
|
a && (a.style.willChange = "", a.style.transition = "", a.style.transform = ""), d && (d.style.willChange = "", d.style.transition = "", d.style.transform = ""), a = null, d = null;
|
|
1007
1018
|
}
|
|
1008
1019
|
j(() => {
|
|
1009
|
-
const s =
|
|
1010
|
-
s != null && s.addEventListener && (s.addEventListener("pointerdown", T, { passive: !0 }), s.addEventListener("pointermove", w, { passive: !0 }), s.addEventListener("pointerup",
|
|
1020
|
+
const s = D();
|
|
1021
|
+
s != null && s.addEventListener && (s.addEventListener("pointerdown", T, { passive: !0 }), s.addEventListener("pointermove", w, { passive: !0 }), s.addEventListener("pointerup", b, { passive: !0 }), s.addEventListener("pointercancel", g, { passive: !0 }));
|
|
1011
1022
|
}), Ae(() => {
|
|
1012
|
-
const s =
|
|
1013
|
-
s != null && s.removeEventListener && (s.removeEventListener("pointerdown", T), s.removeEventListener("pointermove", w), s.removeEventListener("pointerup",
|
|
1023
|
+
const s = D();
|
|
1024
|
+
s != null && s.removeEventListener && (s.removeEventListener("pointerdown", T), s.removeEventListener("pointermove", w), s.removeEventListener("pointerup", b), s.removeEventListener("pointercancel", g));
|
|
1014
1025
|
});
|
|
1015
1026
|
}
|
|
1016
1027
|
function vt(e) {
|
|
@@ -1028,7 +1039,7 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1028
1039
|
},
|
|
1029
1040
|
setup(e) {
|
|
1030
1041
|
const n = e, { getControlAttrs: o, updateControlAttrs: i } = H();
|
|
1031
|
-
return B(
|
|
1042
|
+
return B(Me, n.control.name), B(te, () => o(n.control.name)), B(ne, (t) => {
|
|
1032
1043
|
i(n.control.name, t);
|
|
1033
1044
|
}), (t, c) => (I(), z(ve(e.control.component), me({
|
|
1034
1045
|
key: e.control.componentKey || 0
|
|
@@ -1043,18 +1054,18 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1043
1054
|
emits: ["close"],
|
|
1044
1055
|
setup(e, { emit: n }) {
|
|
1045
1056
|
const o = e, i = n, { getDialogAttrs: t, updateDialogAttrs: c } = H(), l = de(null);
|
|
1046
|
-
B(
|
|
1057
|
+
B(Le, o.dialog.path), B(te, () => t(o.dialog.path)), B(ne, (w) => {
|
|
1047
1058
|
c(o.dialog.path, w);
|
|
1048
1059
|
});
|
|
1049
1060
|
const r = R(() => o.dialog.transition ?? "scale"), u = R(() => o.dialog.transitionDuration != null ? o.dialog.transitionDuration : r.value === "slide" ? 500 : 300), a = R(() => o.dialog.position ?? "standard"), d = R(() => o.dialog.seamless ?? !0);
|
|
1050
|
-
function
|
|
1061
|
+
function D(w) {
|
|
1051
1062
|
if (o.dialog.persistent) {
|
|
1052
1063
|
w.preventDefault();
|
|
1053
1064
|
return;
|
|
1054
1065
|
}
|
|
1055
1066
|
w.preventDefault(), i("close", o.dialog.path);
|
|
1056
1067
|
}
|
|
1057
|
-
function
|
|
1068
|
+
function M(w) {
|
|
1058
1069
|
o.dialog.persistent || w.target === l.value && i("close", o.dialog.path);
|
|
1059
1070
|
}
|
|
1060
1071
|
function T() {
|
|
@@ -1073,12 +1084,12 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1073
1084
|
), Y(
|
|
1074
1085
|
() => o.dialog.closing,
|
|
1075
1086
|
(w) => {
|
|
1076
|
-
var
|
|
1077
|
-
!w && !o.dialog.activated && ((
|
|
1087
|
+
var b;
|
|
1088
|
+
!w && !o.dialog.activated && ((b = l.value) != null && b.open) && l.value.close();
|
|
1078
1089
|
}
|
|
1079
1090
|
), j(() => {
|
|
1080
1091
|
o.dialog.activated && l.value && !l.value.open && (l.value.showModal(), T());
|
|
1081
|
-
}), (w,
|
|
1092
|
+
}), (w, b) => (I(), z(Ne, { to: "body" }, [
|
|
1082
1093
|
Q("dialog", {
|
|
1083
1094
|
ref_key: "dialogRef",
|
|
1084
1095
|
ref: l,
|
|
@@ -1101,12 +1112,12 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1101
1112
|
padding: "0",
|
|
1102
1113
|
inset: "0"
|
|
1103
1114
|
}),
|
|
1104
|
-
onCancel:
|
|
1105
|
-
onClick:
|
|
1115
|
+
onCancel: D,
|
|
1116
|
+
onClick: M
|
|
1106
1117
|
}, [
|
|
1107
1118
|
Q("div", {
|
|
1108
1119
|
class: "micro-dialog__content",
|
|
1109
|
-
onClick:
|
|
1120
|
+
onClick: b[0] || (b[0] = Oe(() => {
|
|
1110
1121
|
}, ["stop"]))
|
|
1111
1122
|
}, [
|
|
1112
1123
|
he(w.$slots, "default"),
|
|
@@ -1159,13 +1170,13 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1159
1170
|
} = o, a = de(null), d = R(() => {
|
|
1160
1171
|
const s = l.value.split("/").filter(Boolean), f = r.value.split("/").filter(Boolean);
|
|
1161
1172
|
return s.some((y) => f.includes(y));
|
|
1162
|
-
}),
|
|
1173
|
+
}), D = R(() => c.value.length > 0), M = R(() => {
|
|
1163
1174
|
const s = i.value.at(-1);
|
|
1164
1175
|
return (s == null ? void 0 : s.transition) ?? "slide";
|
|
1165
|
-
}), T = R(() =>
|
|
1176
|
+
}), T = R(() => M.value === "none" ? "" : M.value === "fade" ? "page-fade" : "page-slide"), w = R(() => {
|
|
1166
1177
|
const s = i.value.at(-1);
|
|
1167
|
-
return s != null && s.transitionDuration ? s.transitionDuration :
|
|
1168
|
-
}),
|
|
1178
|
+
return s != null && s.transitionDuration ? s.transitionDuration : M.value === "fade" ? 300 : 500;
|
|
1179
|
+
}), b = R(() => d.value && M.value !== "none");
|
|
1169
1180
|
return (m = n.config.gesture) != null && m.enabled && ke(n.config.gesture, {
|
|
1170
1181
|
containerRef: a,
|
|
1171
1182
|
goBack: () => o.push(-1),
|
|
@@ -1175,18 +1186,18 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1175
1186
|
ref_key: "pageContainerRef",
|
|
1176
1187
|
ref: a,
|
|
1177
1188
|
name: T.value,
|
|
1178
|
-
css:
|
|
1189
|
+
css: b.value
|
|
1179
1190
|
}, {
|
|
1180
1191
|
default: ae(() => [
|
|
1181
|
-
(I(!0), q(Z, null, ie(U(i), (y,
|
|
1192
|
+
(I(!0), q(Z, null, ie(U(i), (y, C) => (I(), z(it, {
|
|
1182
1193
|
key: y.key || y.path,
|
|
1183
1194
|
"route-path": y.path,
|
|
1184
1195
|
class: le({
|
|
1185
|
-
deactive: U(i).length > 1 &&
|
|
1196
|
+
deactive: U(i).length > 1 && C !== U(i).length - 1
|
|
1186
1197
|
}),
|
|
1187
1198
|
style: Re({
|
|
1188
|
-
transition:
|
|
1189
|
-
zIndex:
|
|
1199
|
+
transition: b.value ? `transform ${w.value}ms cubic-bezier(0.65, 0, 0.35, 1), opacity ${w.value}ms ease` : "none",
|
|
1200
|
+
zIndex: C,
|
|
1190
1201
|
"--mr-page-height": e.nested ? "100%" : "100dvh"
|
|
1191
1202
|
})
|
|
1192
1203
|
}, {
|
|
@@ -1204,7 +1215,7 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1204
1215
|
he(s.$slots, "default")
|
|
1205
1216
|
]),
|
|
1206
1217
|
Q("div", {
|
|
1207
|
-
class: le(["micro-router-gui-layer", { "gui-visible":
|
|
1218
|
+
class: le(["micro-router-gui-layer", { "gui-visible": D.value }])
|
|
1208
1219
|
}, [
|
|
1209
1220
|
we(De, { name: "control-fade" }, {
|
|
1210
1221
|
default: ae(() => [
|
|
@@ -1216,10 +1227,10 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1216
1227
|
_: 1
|
|
1217
1228
|
})
|
|
1218
1229
|
], 2),
|
|
1219
|
-
(I(!0), q(Z, null, ie(U(t), (y,
|
|
1230
|
+
(I(!0), q(Z, null, ie(U(t), (y, C) => (I(), z(nt, {
|
|
1220
1231
|
key: "dialog-" + y.path,
|
|
1221
1232
|
dialog: y,
|
|
1222
|
-
"stack-index":
|
|
1233
|
+
"stack-index": C,
|
|
1223
1234
|
onClose: U(u)
|
|
1224
1235
|
}, null, 8, ["dialog", "stack-index", "onClose"]))), 128))
|
|
1225
1236
|
], 64));
|
|
@@ -1228,8 +1239,8 @@ const tt = /* @__PURE__ */ ee({
|
|
|
1228
1239
|
export {
|
|
1229
1240
|
te as MICRO_ATTRS_READ_KEY,
|
|
1230
1241
|
ne as MICRO_ATTRS_WRITE_KEY,
|
|
1231
|
-
|
|
1232
|
-
|
|
1242
|
+
Me as MICRO_CONTROL_NAME_KEY,
|
|
1243
|
+
Le as MICRO_DIALOG_PATH_KEY,
|
|
1233
1244
|
Ee as MICRO_ROUTER_KEY,
|
|
1234
1245
|
ce as MICRO_ROUTER_ROOT_KEY,
|
|
1235
1246
|
Se as MICRO_ROUTE_PATH_KEY,
|