vue-micro-router 1.0.55 → 1.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +196 -193
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { shallowReactive as U, computed as C, defineAsyncComponent as me, reactive as pe, nextTick as k, ref as ee, inject as x, watch as X, onMounted as q, onBeforeUnmount as he, provide as N, toRefs as Ne, toRef as Oe, defineComponent as oe, openBlock as G, createBlock as F, resolveDynamicComponent as ye, mergeProps as Pe, Teleport as Ke, createElementVNode as j, withModifiers as le, normalizeStyle as be, normalizeClass as Q, createElementBlock as V, createCommentVNode as We, renderSlot as we, Fragment as te, createVNode as Re, TransitionGroup as Se, withCtx as ce, renderList as ue, unref as Y } from "vue";
1
+ import { shallowReactive as U, computed as A, defineAsyncComponent as me, reactive as pe, nextTick as k, ref as ee, inject as x, watch as X, onMounted as q, onBeforeUnmount as he, provide as N, toRefs as Ne, toRef as Oe, defineComponent as oe, openBlock as G, createBlock as F, resolveDynamicComponent as ye, mergeProps as Pe, Teleport as Ke, createElementVNode as j, withModifiers as le, normalizeStyle as be, normalizeClass as Q, createElementBlock as V, createCommentVNode as We, renderSlot as we, Fragment as te, createVNode as Re, TransitionGroup as Se, withCtx as ce, renderList as ue, unref as Y } from "vue";
2
2
  import { i as De, s as Ce, g as H, w as ne, p as B, b as K, n as W, u as $e } from "./use-audio-manager.mjs";
3
3
  const Me = Symbol("micro-router");
4
4
  function vt() {
@@ -26,41 +26,41 @@ function Ue(e, o) {
26
26
  let u = !1;
27
27
  const s = U(/* @__PURE__ */ new Map()), f = U(
28
28
  /* @__PURE__ */ new Map()
29
- ), a = C(() => {
29
+ ), a = A(() => {
30
30
  const l = [];
31
31
  for (const r of s.values())
32
32
  r.activated && l.push(r);
33
33
  return l;
34
- }), d = a, A = C(
34
+ }), d = a, R = A(
35
35
  () => a.value.some((l) => l.name !== n)
36
- ), L = C(() => {
36
+ ), L = A(() => {
37
37
  const l = a.value.find((r) => r.name !== n);
38
38
  return (l == null ? void 0 : l.name) ?? n;
39
39
  });
40
40
  function M(l, r, P) {
41
- var y, S, p;
41
+ var h, C, m;
42
42
  if (!(r && u)) {
43
43
  r && (u = !0);
44
44
  try {
45
- const h = s.get(l);
46
- if (!h) return;
45
+ const y = s.get(l);
46
+ if (!y) return;
47
47
  const v = s.get(n), D = l === n || l === i;
48
48
  if (r)
49
- (y = o == null ? void 0 : o.trackGuiEnter) == null || y.call(o, l), D ? s.forEach((w) => {
49
+ (h = o == null ? void 0 : o.trackGuiEnter) == null || h.call(o, l), D ? s.forEach((w) => {
50
50
  var b;
51
51
  w.name !== n && w.activated && ((b = o == null ? void 0 : o.trackGuiLeave) == null || b.call(o, w.name), s.set(w.name, {
52
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), s.set(n, { ...v, activated: !1 })), P && f.set(l, { ...P }), s.set(l, {
57
- ...h,
56
+ }) : v != null && v.activated && ((C = o == null ? void 0 : o.trackGuiLeave) == null || C.call(o, n), s.set(n, { ...v, activated: !1 })), P && f.set(l, { ...P }), s.set(l, {
57
+ ...y,
58
58
  activated: !0,
59
- componentKey: (h.componentKey || 0) + 1,
59
+ componentKey: (y.componentKey || 0) + 1,
60
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), s.set(l, { ...h, activated: !1, attrs: void 0 });
63
+ (m = o == null ? void 0 : o.trackGuiLeave) == null || m.call(o, l), f.delete(l), s.set(l, { ...y, activated: !1, attrs: void 0 });
64
64
  const w = s.get(n);
65
65
  if (!D && w && !w.activated) {
66
66
  if (w.name === i) return;
@@ -88,19 +88,19 @@ function Ue(e, o) {
88
88
  function g(l) {
89
89
  return f.get(l);
90
90
  }
91
- function m(l, r) {
91
+ function p(l, r) {
92
92
  const P = f.get(l);
93
93
  f.set(l, { ...P, ...r });
94
94
  }
95
95
  return {
96
96
  resolveControls: d,
97
- activeControl: A,
97
+ activeControl: R,
98
98
  currentControl: L,
99
99
  toggleControl: M,
100
100
  registerControl: _,
101
101
  registerControls: T,
102
102
  getControlAttrs: g,
103
- updateControlAttrs: m,
103
+ updateControlAttrs: p,
104
104
  cleanup: c.cleanup
105
105
  };
106
106
  }
@@ -257,23 +257,23 @@ function Ve(e) {
257
257
  dialogs: U(/* @__PURE__ */ new Map()),
258
258
  /** Attrs stored separately for useMicroState access inside dialog components */
259
259
  dialogAttrs: U(/* @__PURE__ */ new Map())
260
- }), c = C(() => {
261
- const g = [], m = /* @__PURE__ */ new Set();
260
+ }), c = A(() => {
261
+ const g = [], p = /* @__PURE__ */ new Set();
262
262
  for (const l of t.dialogStack) {
263
263
  const r = t.dialogs.get(l);
264
- r && (r.activated || r.closing) && (g.push(r), m.add(l));
264
+ r && (r.activated || r.closing) && (g.push(r), p.add(l));
265
265
  }
266
266
  for (const l of t.dialogs.values())
267
- l.closing && !m.has(l.path) && g.push(l);
267
+ l.closing && !p.has(l.path) && g.push(l);
268
268
  return g;
269
269
  }), u = n.schedule;
270
- function s(g, m) {
271
- return { path: g, attrs: m };
270
+ function s(g, p) {
271
+ return { path: g, attrs: p };
272
272
  }
273
- function f({ path: g, open: m, attrs: l }) {
273
+ function f({ path: g, open: p, attrs: l }) {
274
274
  const r = t.dialogs.get(g);
275
275
  return r && k(() => {
276
- if (m)
276
+ if (p)
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,
@@ -291,27 +291,27 @@ function Ve(e) {
291
291
  t.fromDialog = t.activeDialog;
292
292
  const P = t.dialogStack.indexOf(g);
293
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);
294
+ const h = 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
300
300
  }), u(() => {
301
- const S = t.dialogs.get(g);
302
- S && !S.activated && t.dialogs.set(g, { ...S, closing: !1 });
303
- }, y + 200);
301
+ const C = t.dialogs.get(g);
302
+ C && !C.activated && t.dialogs.set(g, { ...C, closing: !1 });
303
+ }, h + 200);
304
304
  }
305
305
  }), s(g, l);
306
306
  }
307
- function a(g, m) {
307
+ function a(g, p) {
308
308
  var l;
309
- if (i) return s(g, m);
309
+ if (i) return s(g, p);
310
310
  i = !0;
311
311
  try {
312
312
  const r = t.activeDialog || "";
313
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 });
314
+ const P = f({ path: g, open: !0, attrs: p });
315
315
  return u(() => {
316
316
  i = !1;
317
317
  }, 300), P;
@@ -320,24 +320,24 @@ function Ve(e) {
320
320
  }
321
321
  }
322
322
  function d(g) {
323
- var m;
324
- (m = e == null ? void 0 : e.trackDialogLeave) == null || m.call(e, g, g, ""), t.dialogAttrs.delete(g), f({ path: g, open: !1 });
323
+ var p;
324
+ (p = e == null ? void 0 : e.trackDialogLeave) == null || p.call(e, g, g, ""), t.dialogAttrs.delete(g), f({ path: g, open: !1 });
325
325
  }
326
- function A() {
327
- const g = [], m = [];
326
+ function R() {
327
+ const g = [], p = [];
328
328
  t.dialogs.forEach((l, r) => {
329
- var P, y;
329
+ var P, h;
330
330
  if (l.activated) {
331
331
  (P = e == null ? void 0 : e.trackDialogLeave) == null || P.call(e, r, r, "");
332
- const S = (y = l.attrs) == null ? void 0 : y.onClose;
333
- typeof S == "function" && m.push(S), t.dialogs.set(r, {
332
+ const C = (h = l.attrs) == null ? void 0 : h.onClose;
333
+ typeof C == "function" && p.push(C), t.dialogs.set(r, {
334
334
  ...l,
335
335
  activated: !1,
336
336
  closing: !0,
337
337
  attrs: void 0
338
338
  }), g.push(r);
339
339
  }
340
- }), m.forEach((l) => l()), t.dialogAttrs.clear(), t.fromDialog = t.activeDialog, t.toDialog = "", t.activeDialog = "", t.dialogStack = [], u(() => {
340
+ }), p.forEach((l) => l()), t.dialogAttrs.clear(), t.fromDialog = t.activeDialog, t.toDialog = "", t.activeDialog = "", t.dialogStack = [], u(() => {
341
341
  g.forEach((l) => {
342
342
  const r = t.dialogs.get(l);
343
343
  r && !r.activated && t.dialogs.set(l, { ...r, closing: !1 });
@@ -346,11 +346,11 @@ function Ve(e) {
346
346
  }
347
347
  function L(g) {
348
348
  t.dialogs.has(g.path) && console.warn(`[vue-micro-router] Dialog "${g.path}" already registered. Overwriting.`);
349
- let { component: m } = g;
350
- De(m) && (m = me(m)), t.dialogs.set(g.path, {
349
+ let { component: p } = g;
350
+ De(p) && (p = me(p)), t.dialogs.set(g.path, {
351
351
  persistent: !0,
352
352
  ...g,
353
- component: Ce(m)
353
+ component: Ce(p)
354
354
  });
355
355
  }
356
356
  function M(g) {
@@ -359,18 +359,18 @@ function Ve(e) {
359
359
  function _(g) {
360
360
  return t.dialogAttrs.get(g);
361
361
  }
362
- function T(g, m) {
362
+ function T(g, p) {
363
363
  const l = t.dialogAttrs.get(g);
364
- t.dialogAttrs.set(g, { ...l, ...m });
364
+ t.dialogAttrs.set(g, { ...l, ...p });
365
365
  }
366
366
  return {
367
- activeDialog: C(() => t.activeDialog),
368
- fromDialog: C(() => t.fromDialog),
369
- toDialog: C(() => t.toDialog),
367
+ activeDialog: A(() => t.activeDialog),
368
+ fromDialog: A(() => t.fromDialog),
369
+ toDialog: A(() => t.toDialog),
370
370
  resolveDialogs: c,
371
371
  openDialog: a,
372
372
  closeDialog: d,
373
- closeAllDialogs: A,
373
+ closeAllDialogs: R,
374
374
  registerDialog: L,
375
375
  registerDialogs: M,
376
376
  getDialogAttrs: _,
@@ -429,31 +429,31 @@ 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 s(g, m) {
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++);
432
+ function s(g, p) {
433
+ !e.enabled || c || (t < i.length - 1 && i.splice(t + 1), i.push({ path: g, timestamp: Date.now(), props: p ? { ...p } : void 0 }), t = i.length - 1, i.length > n && (i.shift(), t--), u.value++);
434
434
  }
435
- const f = C(() => (u.value, [...i])), a = C(() => (u.value, t > 0)), d = C(() => (u.value, t < i.length - 1));
436
- async function A(g) {
435
+ const f = A(() => (u.value, [...i])), a = A(() => (u.value, t > 0)), d = A(() => (u.value, t < i.length - 1));
436
+ async function R(g) {
437
437
  if (g < 0 || g >= i.length) return;
438
- const m = i[g];
439
- if (m) {
438
+ const p = i[g];
439
+ if (p) {
440
440
  t = g, c = !0, u.value++;
441
441
  try {
442
- await o(m.path);
442
+ await o(p.path);
443
443
  } finally {
444
444
  c = !1;
445
445
  }
446
446
  }
447
447
  }
448
448
  async function L() {
449
- a.value && await A(t - 1);
449
+ a.value && await R(t - 1);
450
450
  }
451
451
  async function M() {
452
- d.value && await A(t + 1);
452
+ d.value && await R(t + 1);
453
453
  }
454
454
  async function _(g) {
455
- const m = t + g;
456
- await A(m);
455
+ const p = t + g;
456
+ await R(p);
457
457
  }
458
458
  function T() {
459
459
  i.length = 0, t = -1, u.value++;
@@ -508,8 +508,8 @@ function Qe(e) {
508
508
  f.slice(0, a + 1)
509
509
  );
510
510
  if (e.getActivePath() === d) continue;
511
- const A = a === f.length - 1;
512
- await e.pushCore(d, A ? c : void 0), A || await fe(o);
511
+ const R = a === f.length - 1;
512
+ await e.pushCore(d, R ? c : void 0), R || await fe(o);
513
513
  }
514
514
  else {
515
515
  const a = f.filter(
@@ -520,8 +520,8 @@ function Qe(e) {
520
520
  return;
521
521
  }
522
522
  for (let d = 0; d < a.length; d++) {
523
- const A = d === a.length - 1;
524
- await e.pushCore(a[d], A ? c : void 0), A || await fe(o);
523
+ const R = d === a.length - 1;
524
+ await e.pushCore(a[d], R ? c : void 0), R || await fe(o);
525
525
  }
526
526
  }
527
527
  e.scheduleUnlock();
@@ -564,138 +564,138 @@ function Ze(e, o) {
564
564
  routeKeys: U(/* @__PURE__ */ new Map()),
565
565
  /** Component key per segment — incremented to force Vue full remount (resets local state) */
566
566
  componentKeys: U(/* @__PURE__ */ new Map())
567
- }), d = /* @__PURE__ */ new Map(), A = C(() => {
568
- const p = B(a.activePath), h = [];
569
- for (const v of p) {
567
+ }), d = /* @__PURE__ */ new Map(), R = A(() => {
568
+ const m = B(a.activePath), y = [];
569
+ for (const v of m) {
570
570
  const D = s.routes.get(v);
571
571
  if (!D) continue;
572
- const w = a.routeKeys.get(v) || 0, b = a.componentKeys.get(v) || 0, E = `${D.path}-${w}`, R = d.get(v);
573
- if (R && R.key === E && R.componentKey === b)
574
- h.push(R);
572
+ const w = a.routeKeys.get(v) || 0, b = a.componentKeys.get(v) || 0, E = `${D.path}-${w}`, S = d.get(v);
573
+ if (S && S.key === E && S.componentKey === b)
574
+ y.push(S);
575
575
  else {
576
576
  const O = { ...D, key: E, componentKey: b };
577
- d.set(v, O), h.push(O);
577
+ d.set(v, O), y.push(O);
578
578
  }
579
579
  }
580
580
  for (const v of d.keys())
581
- p.includes(v) || d.delete(v);
582
- return h;
581
+ m.includes(v) || d.delete(v);
582
+ return y;
583
583
  });
584
- function L(p, h) {
584
+ function L(m, y) {
585
585
  var O, I;
586
- const v = B(a.activePath), D = Math.min(p, v.length - 1);
586
+ const v = B(a.activePath), D = Math.min(m, v.length - 1);
587
587
  if (D <= 0) return;
588
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
591
  const E = w.at(-1);
592
- if (E && h) {
592
+ if (E && y) {
593
593
  const $ = a.routeAttrs.get(E);
594
- a.routeAttrs.set(E, { ...$, ...h }), a.componentKeys.set(
594
+ a.routeAttrs.set(E, { ...$, ...y }), a.componentKeys.set(
595
595
  E,
596
596
  (a.componentKeys.get(E) || 0) + 1
597
597
  );
598
598
  }
599
- const R = a.activePath;
600
- (O = o == null ? void 0 : o.trackPageLeave) == null || O.call(o, R, R, b), a.fromPath = R, a.toPath = b, a.activePath = b, (I = o == null ? void 0 : o.trackPageEnter) == null || I.call(o, b, R, b);
599
+ const S = a.activePath;
600
+ (O = o == null ? void 0 : o.trackPageLeave) == null || O.call(o, S, S, b), a.fromPath = S, a.toPath = b, a.activePath = b, (I = o == null ? void 0 : o.trackPageEnter) == null || I.call(o, b, S, b);
601
601
  }
602
- async function M(p, h) {
602
+ async function M(m, y) {
603
603
  var b, E;
604
- const v = W(p), D = B(v);
604
+ const v = W(m), D = B(v);
605
605
  await Promise.all(
606
- D.map((R) => s.asyncLoaders.get(R)).filter((R) => !!R).map((R) => ne(R))
606
+ D.map((S) => s.asyncLoaders.get(S)).filter((S) => !!S).map((S) => ne(S))
607
607
  );
608
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);
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, y && _(v, y), (E = o == null ? void 0 : o.trackPageEnter) == null || E.call(o, v, w, v);
610
610
  }
611
- function _(p, h) {
612
- const v = B(p).at(-1);
611
+ function _(m, y) {
612
+ const v = B(m).at(-1);
613
613
  if (!v) return;
614
614
  const D = a.routeAttrs.get(v);
615
- a.routeAttrs.set(v, { ...D, ...h });
615
+ a.routeAttrs.set(v, { ...D, ...y });
616
616
  }
617
- function T(p, h) {
618
- const v = a.routeAttrs.get(p);
619
- a.routeAttrs.set(p, { ...v, ...h });
617
+ function T(m, y) {
618
+ const v = a.routeAttrs.get(m);
619
+ a.routeAttrs.set(m, { ...v, ...y });
620
620
  }
621
- function g(p) {
622
- return a.routeAttrs.get(p);
621
+ function g(m) {
622
+ return a.routeAttrs.get(m);
623
623
  }
624
- async function m(p, h) {
625
- if (!p && p !== 0) return;
626
- if (typeof p == "number" && p < 0) {
627
- L(Math.abs(p), h);
624
+ async function p(m, y) {
625
+ if (!m && m !== 0) return;
626
+ if (typeof m == "number" && m < 0) {
627
+ L(Math.abs(m), y);
628
628
  return;
629
629
  }
630
- const v = p.toString();
630
+ const v = m.toString();
631
631
  if (v.startsWith("/")) {
632
- const E = B(v), R = B(a.activePath);
633
- if (E.length < R.length && E.every(($, se) => R[se] === $)) {
634
- if (R.length - E.length === 1)
635
- L(1, h);
632
+ const E = B(v), S = B(a.activePath);
633
+ if (E.length < S.length && E.every(($, se) => S[se] === $)) {
634
+ if (S.length - E.length === 1)
635
+ L(1, y);
636
636
  else {
637
- const se = R.slice(0, E.length + 1), Ie = K(se);
638
- for (let re = E.length + 1; re < R.length; re++)
639
- a.routeAttrs.delete(R[re]);
640
- a.activePath = Ie, await k(), L(1, h);
637
+ const se = S.slice(0, E.length + 1), Ie = K(se);
638
+ for (let re = E.length + 1; re < S.length; re++)
639
+ a.routeAttrs.delete(S[re]);
640
+ a.activePath = Ie, await k(), L(1, y);
641
641
  }
642
642
  return;
643
643
  }
644
644
  const I = E.at(-1);
645
- I && R.at(-1) === I && a.routeKeys.set(
645
+ I && S.at(-1) === I && a.routeKeys.set(
646
646
  I,
647
647
  (a.routeKeys.get(I) || 0) + 1
648
- ), await M(v, h);
648
+ ), await M(v, y);
649
649
  return;
650
650
  }
651
651
  const D = B(a.activePath), w = D.indexOf(v);
652
652
  if (w !== -1) {
653
653
  const E = D.length - (w + 1);
654
654
  if (E === 1)
655
- L(1, h);
655
+ L(1, y);
656
656
  else if (E > 1) {
657
- const R = D.slice(0, w + 2), O = K(R);
657
+ const S = D.slice(0, w + 2), O = K(S);
658
658
  for (let I = w + 2; I < D.length; I++)
659
659
  a.routeAttrs.delete(D[I]);
660
- a.activePath = O, await k(), L(1, h);
660
+ a.activePath = O, await k(), L(1, y);
661
661
  } else
662
662
  a.routeKeys.set(v, (a.routeKeys.get(v) || 0) + 1), await M(
663
663
  K(D.slice(0, w + 1)),
664
- h
664
+ y
665
665
  );
666
666
  return;
667
667
  }
668
668
  const b = K([...D, v]);
669
- await M(b, h);
669
+ await M(b, y);
670
670
  }
671
- function l(p) {
672
- if (typeof p == "number" && p < 0) {
673
- const w = B(a.activePath), b = Math.min(Math.abs(p), w.length - 1);
671
+ function l(m) {
672
+ if (typeof m == "number" && m < 0) {
673
+ const w = B(a.activePath), b = Math.min(Math.abs(m), w.length - 1);
674
674
  return b <= 0 ? a.activePath : K(w.slice(0, -b));
675
675
  }
676
- const h = p.toString();
677
- if (h.startsWith("/")) return W(h);
678
- const v = B(a.activePath), D = v.indexOf(h);
679
- return D !== -1 ? K(v.slice(0, D + 1)) : K([...v, h]);
676
+ const y = m.toString();
677
+ if (y.startsWith("/")) return W(y);
678
+ const v = B(a.activePath), D = v.indexOf(y);
679
+ return D !== -1 ? K(v.slice(0, D + 1)) : K([...v, y]);
680
680
  }
681
- const r = { getRoute: (p) => s.routes.get(p) };
682
- async function P(p, h) {
681
+ const r = { getRoute: (m) => s.routes.get(m) };
682
+ async function P(m, y) {
683
683
  var v;
684
684
  if (!f.value) {
685
685
  f.value = !0;
686
686
  try {
687
687
  const D = (((v = t.beforeEach) == null ? void 0 : v.length) ?? 0) > 0, w = s.routes.size > 0;
688
- if ((D || w) && p) {
689
- const R = l(p), O = W(a.activePath);
690
- if (!await Ee(R, O, t, r)) {
688
+ if ((D || w) && m) {
689
+ const S = l(m), O = W(a.activePath);
690
+ if (!await Ee(S, O, t, r)) {
691
691
  f.value = !1;
692
692
  return;
693
693
  }
694
694
  }
695
695
  const b = W(a.activePath);
696
- await m(p, h);
696
+ await p(m, y);
697
697
  const E = W(a.activePath);
698
- y == null || y.record(E, h), He(E, b, t.afterEach), s.preloadAdjacent(B(a.activePath)), u.schedule(() => {
698
+ h == null || h.record(E, y), He(E, b, t.afterEach), s.preloadAdjacent(B(a.activePath)), u.schedule(() => {
699
699
  f.value = !1;
700
700
  }, i);
701
701
  } catch (D) {
@@ -703,19 +703,19 @@ function Ze(e, o) {
703
703
  }
704
704
  }
705
705
  }
706
- const y = c.enabled ? qe(c, async (p) => {
707
- const h = B(a.activePath), v = B(p);
708
- if (v.length < h.length && v.every((w, b) => h[b] === w)) {
709
- const w = h.length - v.length;
706
+ const h = c.enabled ? qe(c, async (m) => {
707
+ const y = B(a.activePath), v = B(m);
708
+ if (v.length < y.length && v.every((w, b) => y[b] === w)) {
709
+ const w = y.length - v.length;
710
710
  await P(-w);
711
711
  } else
712
- await P(p);
712
+ await P(m);
713
713
  }) : void 0;
714
- y && y.record(W(n));
715
- const S = Qe({
714
+ h && h.record(W(n));
715
+ const C = Qe({
716
716
  getActivePath: () => a.activePath,
717
- pushCore: m,
718
- runGuards: (p, h) => Ee(p, h, t, r),
717
+ pushCore: p,
718
+ runGuards: (m, y) => Ee(m, y, t, r),
719
719
  scheduleUnlock: () => u.schedule(() => {
720
720
  f.value = !1;
721
721
  }, i),
@@ -729,24 +729,24 @@ function Ze(e, o) {
729
729
  stepDelay: i
730
730
  });
731
731
  return {
732
- activePath: C(() => a.activePath),
733
- fromPath: C(() => a.fromPath),
734
- toPath: C(() => a.toPath),
735
- activePage: C(() => H(a.activePath)),
736
- fromPage: C(() => H(a.fromPath)),
737
- toPage: C(() => H(a.toPath)),
738
- isNavigating: C(() => f.value),
739
- resolveRoutes: A,
732
+ activePath: A(() => a.activePath),
733
+ fromPath: A(() => a.fromPath),
734
+ toPath: A(() => a.toPath),
735
+ activePage: A(() => H(a.activePath)),
736
+ fromPage: A(() => H(a.fromPath)),
737
+ toPage: A(() => H(a.toPath)),
738
+ isNavigating: A(() => f.value),
739
+ resolveRoutes: R,
740
740
  push: P,
741
- stepWisePush: S.stepWisePush,
742
- stepWiseBack: S.stepWiseBack,
741
+ stepWisePush: C.stepWisePush,
742
+ stepWiseBack: C.stepWiseBack,
743
743
  registerRoute: s.registerRoute,
744
744
  registerRoutes: s.registerRoutes,
745
745
  updateRouteAttrs: T,
746
746
  getRouteAttrs: g,
747
747
  preloadRoute: s.preloadRoute,
748
748
  routes: s.routes,
749
- history: y,
749
+ history: h,
750
750
  cleanup: u.cleanup
751
751
  };
752
752
  }
@@ -848,8 +848,8 @@ function et(e) {
848
848
  }, s = H(e.defaultPath);
849
849
  return X(n.activePage, (a, d) => {
850
850
  if (!d) return;
851
- const A = t.currentControl.value;
852
- d === s && a !== s && o.trackGuiLeave(A), a === s && d !== s && o.trackGuiEnter(A);
851
+ const R = t.currentControl.value;
852
+ d === s && a !== s && o.trackGuiLeave(R), a === s && d !== s && o.trackGuiEnter(R);
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 () => {
@@ -952,12 +952,12 @@ 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
954
  let c = 0, u = 0, s = 0, f = !1, a = null, d = null;
955
- function A() {
955
+ function R() {
956
956
  const l = o.containerRef.value;
957
957
  return l ? "$el" in l ? l.$el : l : null;
958
958
  }
959
959
  function L() {
960
- const l = A();
960
+ const l = R();
961
961
  if (!l) return { current: null, previous: null };
962
962
  const r = l.querySelectorAll(".route-page");
963
963
  return r.length < 2 ? { current: r[r.length - 1] ?? null, previous: null } : {
@@ -966,13 +966,13 @@ function tt(e, o) {
966
966
  };
967
967
  }
968
968
  function M(l) {
969
- var S;
969
+ var C;
970
970
  if (!o.canGoBack() || l.clientX > n) return;
971
971
  const { current: r, previous: P } = L();
972
972
  if (!r) return;
973
973
  f = !0, c = l.clientX, u = l.clientY, s = Date.now(), a = r, d = P;
974
- const y = A();
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";
974
+ const h = R();
975
+ (C = h == null ? void 0 : h.setPointerCapture) == null || C.call(h, 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;
@@ -981,34 +981,34 @@ function tt(e, o) {
981
981
  g();
982
982
  return;
983
983
  }
984
- const y = r / window.innerWidth;
984
+ const h = r / window.innerWidth;
985
985
  if (a.style.transform = `translateX(${r}px)`, d) {
986
- const S = -20 + 20 * y;
987
- d.style.transform = `translateX(${S}%)`;
986
+ const C = -20 + 20 * h;
987
+ d.style.transform = `translateX(${C}%)`;
988
988
  }
989
989
  }
990
990
  function T(l) {
991
991
  if (!f || !a) return;
992
992
  if (!a.isConnected) {
993
- m(), f = !1;
993
+ p(), f = !1;
994
994
  return;
995
995
  }
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
- m(), o.goBack();
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;
996
+ const r = l.clientX - c, P = Date.now() - s, h = r / P;
997
+ r / window.innerWidth > i || h > 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
+ p(), o.goBack();
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(p, 200)), f = !1;
1000
1000
  }
1001
1001
  function g() {
1002
- f && (a && (a.style.transition = "transform 0.15s ease-out", a.style.transform = "translateX(0)"), d && (d.style.transition = "transform 0.15s ease-out", d.style.transform = "translateX(-20%)"), setTimeout(m, 150), f = !1);
1002
+ f && (a && (a.style.transition = "transform 0.15s ease-out", a.style.transform = "translateX(0)"), d && (d.style.transition = "transform 0.15s ease-out", d.style.transform = "translateX(-20%)"), setTimeout(p, 150), f = !1);
1003
1003
  }
1004
- function m() {
1004
+ function p() {
1005
1005
  a && (a.style.willChange = "", a.style.transition = "", a.style.transform = ""), d && (d.style.willChange = "", d.style.transition = "", d.style.transform = ""), a = null, d = null;
1006
1006
  }
1007
1007
  q(() => {
1008
- const l = A();
1008
+ const l = R();
1009
1009
  l != null && l.addEventListener && (l.addEventListener("pointerdown", M, { passive: !0 }), l.addEventListener("pointermove", _, { passive: !0 }), l.addEventListener("pointerup", T, { passive: !0 }), l.addEventListener("pointercancel", g, { passive: !0 }));
1010
1010
  }), he(() => {
1011
- const l = A();
1011
+ const l = R();
1012
1012
  l != null && l.removeEventListener && (l.removeEventListener("pointerdown", M), l.removeEventListener("pointermove", _), l.removeEventListener("pointerup", T), l.removeEventListener("pointercancel", g));
1013
1013
  });
1014
1014
  }
@@ -1051,7 +1051,7 @@ 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 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);
1054
+ const s = ee(null), f = ee(null), a = A(() => n.dialog.transition ?? "scale"), d = A(() => n.dialog.transitionDuration != null ? n.dialog.transitionDuration : a.value === "slide" ? 500 : 300), R = A(() => n.dialog.position ?? "standard"), L = A(() => n.dialog.seamless ?? !1);
1055
1055
  function M() {
1056
1056
  return s.value ? Array.from(
1057
1057
  s.value.querySelectorAll(st)
@@ -1070,8 +1070,8 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1070
1070
  r.preventDefault(), (v = s.value) == null || v.focus();
1071
1071
  return;
1072
1072
  }
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());
1073
+ const h = P[0], C = P[P.length - 1], m = document.activeElement, y = !!((D = s.value) != null && D.contains(m));
1074
+ r.shiftKey ? (!y || m === h) && (r.preventDefault(), C.focus()) : (!y || m === C) && (r.preventDefault(), h.focus());
1075
1075
  }
1076
1076
  function T(r) {
1077
1077
  n.dialog.persistent || r.target === r.currentTarget && i("close", n.dialog.path);
@@ -1086,7 +1086,7 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1086
1086
  P.remove(), r();
1087
1087
  }, 50);
1088
1088
  }
1089
- function m() {
1089
+ function p() {
1090
1090
  u || (u = !0, f.value = document.activeElement, at(), k(() => {
1091
1091
  s.value && g(() => {
1092
1092
  if (!s.value) return;
@@ -1095,17 +1095,20 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1095
1095
  }));
1096
1096
  }
1097
1097
  function l() {
1098
+ var m;
1098
1099
  if (!u) return;
1099
1100
  u = !1, it();
1100
1101
  const r = f.value;
1101
- f.value = null, r && typeof r.focus == "function" && document.contains(r) && r.focus();
1102
+ f.value = null;
1103
+ const P = document.activeElement, h = !!((m = s.value) != null && m.contains(P)), C = !P || P === document.body;
1104
+ r && typeof r.focus == "function" && document.contains(r) && (h || C) && r.focus();
1102
1105
  }
1103
1106
  return N(Te, n.dialog.path), N(ae, () => t(n.dialog.path)), N(ie, (r) => {
1104
1107
  c(n.dialog.path, r);
1105
1108
  }), X(
1106
1109
  () => n.dialog.activated,
1107
1110
  (r) => {
1108
- r && m();
1111
+ r && p();
1109
1112
  }
1110
1113
  ), X(
1111
1114
  () => n.dialog.closing,
@@ -1113,13 +1116,13 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1113
1116
  !r && !n.dialog.activated && u && l();
1114
1117
  }
1115
1118
  ), q(() => {
1116
- n.dialog.activated && m();
1119
+ n.dialog.activated && p();
1117
1120
  }), he(() => {
1118
1121
  u && l();
1119
1122
  }), (r, P) => (G(), F(Ke, { to: "body" }, [
1120
1123
  j("div", {
1121
1124
  class: Q(["micro-dialog-portal", [
1122
- `micro-dialog--${A.value}`,
1125
+ `micro-dialog--${R.value}`,
1123
1126
  e.dialog.fullscreen && "micro-dialog--fullscreen",
1124
1127
  L.value && "micro-dialog--seamless"
1125
1128
  ]]),
@@ -1189,9 +1192,9 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1189
1192
  nested: { type: Boolean }
1190
1193
  },
1191
1194
  setup(e) {
1192
- var m, l;
1195
+ var p, l;
1193
1196
  const o = e, n = et(o.config);
1194
- (m = o.plugins) != null && m.length && nt(o.plugins, n);
1197
+ (p = o.plugins) != null && p.length && nt(o.plugins, n);
1195
1198
  const {
1196
1199
  resolveRoutes: i,
1197
1200
  resolveDialogs: t,
@@ -1200,17 +1203,17 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1200
1203
  toPath: s,
1201
1204
  isNavigating: f,
1202
1205
  closeDialog: a
1203
- } = n, d = ee(null), A = C(() => {
1206
+ } = n, d = ee(null), R = A(() => {
1204
1207
  const r = u.value.split("/").filter(Boolean), P = new Set(s.value.split("/").filter(Boolean));
1205
- return r.some((y) => P.has(y));
1206
- }), L = C(() => c.value.length > 0), M = C(() => {
1208
+ return r.some((h) => P.has(h));
1209
+ }), L = A(() => c.value.length > 0), M = A(() => {
1207
1210
  const r = i.value.at(-1);
1208
1211
  return (r == null ? void 0 : r.transition) ?? "slide";
1209
- }), _ = C(() => M.value === "none" ? "" : M.value === "fade" ? "page-fade" : "page-slide"), T = C(() => {
1212
+ }), _ = A(() => M.value === "none" ? "" : M.value === "fade" ? "page-fade" : "page-slide"), T = A(() => {
1210
1213
  const r = i.value.at(-1);
1211
1214
  return r != null && r.transitionDuration ? r.transitionDuration : M.value === "fade" ? 300 : 500;
1212
- }), g = C(
1213
- () => A.value && M.value !== "none"
1215
+ }), g = A(
1216
+ () => R.value && M.value !== "none"
1214
1217
  );
1215
1218
  return (l = o.config.gesture) != null && l.enabled && tt(o.config.gesture, {
1216
1219
  containerRef: d,
@@ -1224,23 +1227,23 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1224
1227
  css: g.value
1225
1228
  }, {
1226
1229
  default: ce(() => [
1227
- (G(!0), V(te, null, ue(Y(i), (y, S) => (G(), F(ut, {
1228
- key: y.key || y.path,
1229
- "route-path": y.path,
1230
+ (G(!0), V(te, null, ue(Y(i), (h, C) => (G(), F(ut, {
1231
+ key: h.key || h.path,
1232
+ "route-path": h.path,
1230
1233
  class: Q({
1231
- deactivate: Y(i).length > 1 && S !== Y(i).length - 1,
1234
+ deactivate: Y(i).length > 1 && C !== Y(i).length - 1,
1232
1235
  "micro-router--navigating": Y(f)
1233
1236
  }),
1234
1237
  style: be({
1235
1238
  transition: g.value ? `transform ${T.value}ms cubic-bezier(0.65, 0, 0.35, 1), opacity ${T.value}ms ease` : "none",
1236
- zIndex: 10 + S,
1239
+ zIndex: 10 + C,
1237
1240
  "--mr-page-height": e.nested ? "100%" : "100dvh"
1238
1241
  })
1239
1242
  }, {
1240
1243
  default: ce(() => [
1241
- (G(), F(ye(y.component), Pe({
1242
- key: y.componentKey
1243
- }, { ref_for: !0 }, Y(n).getRouteAttrs(y.path)), null, 16))
1244
+ (G(), F(ye(h.component), Pe({
1245
+ key: h.componentKey
1246
+ }, { ref_for: !0 }, Y(n).getRouteAttrs(h.path)), null, 16))
1244
1247
  ]),
1245
1248
  _: 2
1246
1249
  }, 1032, ["route-path", "class", "style"]))), 128))
@@ -1255,18 +1258,18 @@ const st = 'button:not([disabled]), [href], input:not([disabled]), select:not([d
1255
1258
  }, [
1256
1259
  Re(Se, { name: "control-fade" }, {
1257
1260
  default: ce(() => [
1258
- (G(!0), V(te, null, ue(Y(c), (y) => (G(), F(ot, {
1259
- key: y.name + "-" + (y.componentKey || 0),
1260
- control: y
1261
+ (G(!0), V(te, null, ue(Y(c), (h) => (G(), F(ot, {
1262
+ key: h.name + "-" + (h.componentKey || 0),
1263
+ control: h
1261
1264
  }, null, 8, ["control"]))), 128))
1262
1265
  ]),
1263
1266
  _: 1
1264
1267
  })
1265
1268
  ], 2),
1266
- (G(!0), V(te, null, ue(Y(t), (y, S) => (G(), F(rt, {
1267
- key: "dialog-" + y.path,
1268
- dialog: y,
1269
- "stack-index": S,
1269
+ (G(!0), V(te, null, ue(Y(t), (h, C) => (G(), F(rt, {
1270
+ key: "dialog-" + h.path,
1271
+ dialog: h,
1272
+ "stack-index": C,
1270
1273
  onClose: Y(a)
1271
1274
  }, null, 8, ["dialog", "stack-index", "onClose"]))), 128))
1272
1275
  ], 64));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-micro-router",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "type": "module",
5
5
  "description": "Mobile-app-style navigation for Vue 3 — animated page stacks, modal dialogs, HUD controls. No URL routing.",
6
6
  "author": {