vue-micro-router 1.0.30 → 1.0.33
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 +3 -1
- package/dist/use-audio-manager.mjs +47 -43
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,26 +6,26 @@ class C {
|
|
|
6
6
|
}).catch(() => {
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
async play(s,
|
|
9
|
+
async play(s, u = {}) {
|
|
10
10
|
if (this.stop(), !this.HowlCtor) {
|
|
11
|
-
const
|
|
12
|
-
this.HowlCtor =
|
|
11
|
+
const l = await import("howler");
|
|
12
|
+
this.HowlCtor = l.Howl;
|
|
13
13
|
}
|
|
14
14
|
this.sound = new this.HowlCtor({
|
|
15
15
|
src: [s],
|
|
16
16
|
autoplay: !0,
|
|
17
|
-
loop:
|
|
17
|
+
loop: u.loop ?? !1,
|
|
18
18
|
volume: 0
|
|
19
|
-
}), this.sound.play(), this.sound.fade(0,
|
|
19
|
+
}), this.sound.play(), this.sound.fade(0, u.volume ?? 1, 200);
|
|
20
20
|
}
|
|
21
21
|
/** Fully synchronous play — uses preloaded HowlCtor. No-op if not preloaded yet. */
|
|
22
|
-
playSync(s,
|
|
22
|
+
playSync(s, u = {}) {
|
|
23
23
|
this.HowlCtor && (this.stop(), this.sound = new this.HowlCtor({
|
|
24
24
|
src: [s],
|
|
25
25
|
autoplay: !0,
|
|
26
|
-
loop:
|
|
26
|
+
loop: u.loop ?? !1,
|
|
27
27
|
volume: 0
|
|
28
|
-
}), this.sound.play(), this.sound.fade(0,
|
|
28
|
+
}), this.sound.play(), this.sound.fade(0, u.volume ?? 1, 200));
|
|
29
29
|
}
|
|
30
30
|
stop() {
|
|
31
31
|
try {
|
|
@@ -41,9 +41,9 @@ class C {
|
|
|
41
41
|
resume() {
|
|
42
42
|
this.sound && this.state() === "loaded" && this.sound.play();
|
|
43
43
|
}
|
|
44
|
-
fade(s,
|
|
44
|
+
fade(s, u, l) {
|
|
45
45
|
var e;
|
|
46
|
-
(e = this.sound) != null && e.playing() && this.sound.fade(s,
|
|
46
|
+
(e = this.sound) != null && e.playing() && this.sound.fade(s, u, l);
|
|
47
47
|
}
|
|
48
48
|
isPlaying() {
|
|
49
49
|
var s;
|
|
@@ -62,21 +62,21 @@ function k(t) {
|
|
|
62
62
|
function B(t) {
|
|
63
63
|
return t.split("/").filter(Boolean);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function L(t) {
|
|
66
66
|
return `/${t.join("/")}`;
|
|
67
67
|
}
|
|
68
68
|
function b(t) {
|
|
69
69
|
const s = t.lastIndexOf("/");
|
|
70
70
|
return s === -1 ? t : t.substring(s + 1);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function x(t) {
|
|
73
73
|
try {
|
|
74
74
|
return w(t);
|
|
75
75
|
} catch {
|
|
76
76
|
return t;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function A(t) {
|
|
80
80
|
return typeof t == "function" && !("__name" in t) && !("setup" in t) && !("render" in t);
|
|
81
81
|
}
|
|
82
82
|
async function M(t) {
|
|
@@ -87,38 +87,42 @@ async function M(t) {
|
|
|
87
87
|
}
|
|
88
88
|
function R(t) {
|
|
89
89
|
let s = !1;
|
|
90
|
-
const
|
|
91
|
-
let
|
|
92
|
-
const e = (t == null ? void 0 : t.adapter) ?? new C(),
|
|
93
|
-
var
|
|
94
|
-
return (((
|
|
90
|
+
const u = (t == null ? void 0 : t.defaultBgm) ?? "";
|
|
91
|
+
let l = "";
|
|
92
|
+
const e = (t == null ? void 0 : t.adapter) ?? new C(), n = S(""), d = H(() => {
|
|
93
|
+
var o;
|
|
94
|
+
return (((o = t == null ? void 0 : t.volumeRef) == null ? void 0 : o.value) || 0) / 100;
|
|
95
95
|
});
|
|
96
|
-
async function
|
|
96
|
+
async function c(o, r = !1) {
|
|
97
97
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const a = o === "default" ? u : o;
|
|
99
|
+
if (!a || e.isPlaying() && n.value === a) return;
|
|
100
|
+
l = n.value, n.value = a, e.stop(), await e.play(a, { loop: o === "default" ? !0 : r, volume: d.value });
|
|
101
|
+
} catch (a) {
|
|
102
|
+
console.error("Sound playback failed:", a), e.stop();
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
+
function p(o, r = !1) {
|
|
105
106
|
try {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const a = o === "default" ? u : o;
|
|
108
|
+
if (!a || e.isPlaying() && n.value === a) return;
|
|
109
|
+
l = n.value, n.value = a, e.stop();
|
|
110
|
+
const i = o === "default" ? !0 : r;
|
|
111
|
+
e.playSync ? e.playSync(a, { loop: i, volume: d.value }) : e.play(a, { loop: i, volume: d.value });
|
|
112
|
+
} catch (a) {
|
|
113
|
+
console.error("Sound playback failed:", a), e.stop();
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
function
|
|
116
|
+
function h() {
|
|
113
117
|
e.stop();
|
|
114
118
|
}
|
|
115
|
-
async function y(
|
|
116
|
-
if (
|
|
119
|
+
async function y(o, r) {
|
|
120
|
+
if (r)
|
|
117
121
|
try {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
} catch (
|
|
121
|
-
console.error("Error updating background music:",
|
|
122
|
+
const a = b(o) || "home", i = r.get(a), f = (i == null ? void 0 : i.bgm) || u;
|
|
123
|
+
f && l !== f && await c(f, !0);
|
|
124
|
+
} catch (a) {
|
|
125
|
+
console.error("Error updating background music:", a);
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
function m() {
|
|
@@ -132,12 +136,12 @@ function R(t) {
|
|
|
132
136
|
function v() {
|
|
133
137
|
e.cleanup();
|
|
134
138
|
}
|
|
135
|
-
return g(
|
|
136
|
-
e.isPlaying() ? e.fade(
|
|
139
|
+
return g(d, (o, r) => {
|
|
140
|
+
e.isPlaying() ? e.fade(r ?? 0, o, 300) : o > 0 && n.value && c(n.value, !0);
|
|
137
141
|
}), {
|
|
138
|
-
playSound:
|
|
139
|
-
playSoundSync:
|
|
140
|
-
stopSound:
|
|
142
|
+
playSound: c,
|
|
143
|
+
playSoundSync: p,
|
|
144
|
+
stopSound: h,
|
|
141
145
|
updateBackgroundMusic: y,
|
|
142
146
|
isStarted: () => e.isPlaying() || e.state() === "loaded",
|
|
143
147
|
handleVisibilityChange: m,
|
|
@@ -146,12 +150,12 @@ function R(t) {
|
|
|
146
150
|
}
|
|
147
151
|
export {
|
|
148
152
|
C as H,
|
|
149
|
-
|
|
153
|
+
L as b,
|
|
150
154
|
b as g,
|
|
151
|
-
|
|
155
|
+
A as i,
|
|
152
156
|
k as n,
|
|
153
157
|
B as p,
|
|
154
|
-
|
|
158
|
+
x as s,
|
|
155
159
|
R as u,
|
|
156
160
|
M as w
|
|
157
161
|
};
|