@44-audio/components 0.1.0-dev.1
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/AudioPlayer-bUgQMAfs.mjs +2595 -0
- package/dist/player.es.js +217 -0
- package/dist/recorder.es.js +780 -0
- package/package.json +25 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { h as Q, t as ne, d as le, c as W, p as X, a as Y, b as M, s as d, f as m, A as de, e as h, g as b, i as k, j as i, k as Z, l as R, m as P, n as f, u as ce, r as y, o as I, q as z, v as S, w as V, x as N, y as ue, z as ve, B as ge } from "./AudioPlayer-bUgQMAfs.mjs";
|
|
2
|
+
function fe(a, t, s, r) {
|
|
3
|
+
var n = a.__style;
|
|
4
|
+
if (Q || n !== t) {
|
|
5
|
+
var c = ne(t);
|
|
6
|
+
(!Q || c !== a.getAttribute("style")) && (c == null ? a.removeAttribute("style") : a.style.cssText = c), a.__style = t;
|
|
7
|
+
}
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
function me(a, t) {
|
|
11
|
+
d(t, !f(t));
|
|
12
|
+
}
|
|
13
|
+
var pe = m('• <button class="link svelte-8utcjm"> </button>', 1), _e = (a, t) => d(t, !0), he = m(' <button class="link svelte-8utcjm">Show more</button>', 1), be = (a, t) => d(t, !1), ye = m(' <button class="link svelte-8utcjm">Show less</button>', 1), ke = m('<div class="details svelte-8utcjm"><div class="title svelte-8utcjm">Transcription <!></div> <div class="transcription"><!></div></div>'), xe = m('<div class="container svelte-8utcjm" role="group" aria-label="44 audio player"><div class="display svelte-8utcjm"><!></div> <!></div>');
|
|
14
|
+
const je = {
|
|
15
|
+
hash: "svelte-8utcjm",
|
|
16
|
+
code: "button.svelte-8utcjm {font:inherit;margin:0;padding:0;box-sizing:border-box;border:none;background:none;cursor:pointer;}.link.svelte-8utcjm {background:none;border:none;color:var(--44-color-2);cursor:pointer;padding:0;font:inherit;}.link.svelte-8utcjm:hover {color:var(--44-color-3);text-decoration:underline;}.container.svelte-8utcjm {padding:16px;}.display.svelte-8utcjm {display:flex;align-items:center;gap:12px;}.details.svelte-8utcjm .title:where(.svelte-8utcjm) {font-weight:bold;margin-top:16px;margin-bottom:8px;}"
|
|
17
|
+
};
|
|
18
|
+
function $(a, t) {
|
|
19
|
+
X(t, !0), Y(a, je);
|
|
20
|
+
let s = M(t, "recordingId", 7), r = M(t, "recording", 7), n = M(t, "audioRef", 7), c = R(!1), p = R(!1), E = R(0), _ = R("idle");
|
|
21
|
+
n().addEventListener("play", () => {
|
|
22
|
+
d(_, "playing");
|
|
23
|
+
}), n().addEventListener("pause", () => {
|
|
24
|
+
d(_, "paused");
|
|
25
|
+
}), n().addEventListener("ended", () => {
|
|
26
|
+
d(_, "idle"), d(E, 0);
|
|
27
|
+
}), n().addEventListener("timeupdate", () => {
|
|
28
|
+
d(E, n().currentTime * 1e3);
|
|
29
|
+
});
|
|
30
|
+
var F = {
|
|
31
|
+
get recordingId() {
|
|
32
|
+
return s();
|
|
33
|
+
},
|
|
34
|
+
set recordingId(e) {
|
|
35
|
+
s(e), P();
|
|
36
|
+
},
|
|
37
|
+
get recording() {
|
|
38
|
+
return r();
|
|
39
|
+
},
|
|
40
|
+
set recording(e) {
|
|
41
|
+
r(e), P();
|
|
42
|
+
},
|
|
43
|
+
get audioRef() {
|
|
44
|
+
return n();
|
|
45
|
+
},
|
|
46
|
+
set audioRef(e) {
|
|
47
|
+
n(e), P();
|
|
48
|
+
}
|
|
49
|
+
}, v = xe(), x = b(v), O = b(x);
|
|
50
|
+
{
|
|
51
|
+
let e = ce(() => `https://44hz.zuuu.us/recordings/${s()}/audio.mp3`);
|
|
52
|
+
de(O, {
|
|
53
|
+
get audioURL() {
|
|
54
|
+
return f(e);
|
|
55
|
+
},
|
|
56
|
+
get waveform() {
|
|
57
|
+
return r().waveform;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
y(x);
|
|
62
|
+
var U = h(x, 2);
|
|
63
|
+
{
|
|
64
|
+
var B = (e) => {
|
|
65
|
+
var o = ke(), L = b(o), D = h(b(L));
|
|
66
|
+
{
|
|
67
|
+
var G = (l) => {
|
|
68
|
+
var g = pe(), T = h(I(g));
|
|
69
|
+
T.__click = [me, c];
|
|
70
|
+
var J = b(T, !0);
|
|
71
|
+
y(T), z(() => S(J, f(c) ? "Original" : "Translation")), i(l, g);
|
|
72
|
+
};
|
|
73
|
+
k(D, (l) => {
|
|
74
|
+
r().translation && l(G);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
y(L);
|
|
78
|
+
var u = h(L, 2), H = b(u);
|
|
79
|
+
{
|
|
80
|
+
var ee = (l) => {
|
|
81
|
+
var g = V();
|
|
82
|
+
z(() => S(g, r().translation)), i(l, g);
|
|
83
|
+
}, te = (l) => {
|
|
84
|
+
var g = N(), T = I(g);
|
|
85
|
+
{
|
|
86
|
+
var J = (j) => {
|
|
87
|
+
var q = N(), ae = I(q);
|
|
88
|
+
{
|
|
89
|
+
var oe = (w) => {
|
|
90
|
+
var A = he(), C = I(A), K = h(C);
|
|
91
|
+
K.__click = [_e, p], z((se) => S(C, `${se ?? ""}... `), [() => r().transcription.slice(0, 200)]), i(w, A);
|
|
92
|
+
}, ie = (w) => {
|
|
93
|
+
var A = ye(), C = I(A), K = h(C);
|
|
94
|
+
K.__click = [be, p], z(() => S(C, `${r().transcription ?? ""} `)), i(w, A);
|
|
95
|
+
};
|
|
96
|
+
k(ae, (w) => {
|
|
97
|
+
f(p) ? w(ie, !1) : w(oe);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
i(j, q);
|
|
101
|
+
}, re = (j) => {
|
|
102
|
+
var q = V();
|
|
103
|
+
z(() => S(q, r().transcription)), i(j, q);
|
|
104
|
+
};
|
|
105
|
+
k(
|
|
106
|
+
T,
|
|
107
|
+
(j) => {
|
|
108
|
+
r().transcription.length > 200 ? j(J) : j(re, !1);
|
|
109
|
+
},
|
|
110
|
+
!0
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
i(l, g);
|
|
114
|
+
};
|
|
115
|
+
k(H, (l) => {
|
|
116
|
+
f(c) ? l(ee) : l(te, !1);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
y(u), y(o), i(e, o);
|
|
120
|
+
};
|
|
121
|
+
k(U, (e) => {
|
|
122
|
+
r().transcription && e(B);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return y(v), i(a, v), Z(F);
|
|
126
|
+
}
|
|
127
|
+
le(["click"]);
|
|
128
|
+
W($, { recordingId: {}, recording: {}, audioRef: {} }, [], [], !0);
|
|
129
|
+
var we = m("<p>Loading...</p>"), Ie = m("<p>Error loading recording.</p>"), ze = m('<div class="container svelte-1kcle3q" role="group" aria-label="44 audio player"><!> <audio></audio></div>');
|
|
130
|
+
const Re = {
|
|
131
|
+
hash: "svelte-1kcle3q",
|
|
132
|
+
code: ":host {display:inline-block;font-size:inherit;font-family:system-ui;line-height:1.35;color:var(--44-color-1);}.container.svelte-1kcle3q {width:100%;border-radius:16px;background:var(--44-color-0);color:var(--44-color-1);}"
|
|
133
|
+
};
|
|
134
|
+
function Ee(a, t) {
|
|
135
|
+
X(t, !0), Y(a, Re);
|
|
136
|
+
let s = M(t, "recordingId", 7), r = M(t, "theme", 7);
|
|
137
|
+
const c = r().split(",").map((e) => e.trim()).map((e, o) => `--44-color-${o}: ${e};`).join(" ");
|
|
138
|
+
let p, E = R(!0), _ = R(null);
|
|
139
|
+
ue(async () => {
|
|
140
|
+
try {
|
|
141
|
+
const e = await fetch(`https://44hz.zuuu.us/recordings/${s()}/player`);
|
|
142
|
+
if (!e.ok)
|
|
143
|
+
throw new Error("Failed to fetch data");
|
|
144
|
+
const o = await e.json();
|
|
145
|
+
o.status === "ready" && d(_, o, !0);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
console.error(e);
|
|
148
|
+
} finally {
|
|
149
|
+
d(E, !1);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
var F = {
|
|
153
|
+
get recordingId() {
|
|
154
|
+
return s();
|
|
155
|
+
},
|
|
156
|
+
set recordingId(e) {
|
|
157
|
+
s(e), P();
|
|
158
|
+
},
|
|
159
|
+
get theme() {
|
|
160
|
+
return r();
|
|
161
|
+
},
|
|
162
|
+
set theme(e) {
|
|
163
|
+
r(e), P();
|
|
164
|
+
}
|
|
165
|
+
}, v = ze(), x = b(v);
|
|
166
|
+
{
|
|
167
|
+
var O = (e) => {
|
|
168
|
+
var o = we();
|
|
169
|
+
i(e, o);
|
|
170
|
+
}, U = (e) => {
|
|
171
|
+
var o = N(), L = I(o);
|
|
172
|
+
{
|
|
173
|
+
var D = (u) => {
|
|
174
|
+
$(u, {
|
|
175
|
+
get recordingId() {
|
|
176
|
+
return s();
|
|
177
|
+
},
|
|
178
|
+
get recording() {
|
|
179
|
+
return f(_);
|
|
180
|
+
},
|
|
181
|
+
get audioRef() {
|
|
182
|
+
return p;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}, G = (u) => {
|
|
186
|
+
var H = Ie();
|
|
187
|
+
i(u, H);
|
|
188
|
+
};
|
|
189
|
+
k(
|
|
190
|
+
L,
|
|
191
|
+
(u) => {
|
|
192
|
+
f(_) ? u(D) : u(G, !1);
|
|
193
|
+
},
|
|
194
|
+
!0
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
i(e, o);
|
|
198
|
+
};
|
|
199
|
+
k(x, (e) => {
|
|
200
|
+
f(E) ? e(O) : e(U, !1);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
var B = h(x, 2);
|
|
204
|
+
return ve(B, (e) => p = e, () => p), y(v), z(() => {
|
|
205
|
+
fe(v, c), ge(B, "src", `https://44hz.zuuu.us/recordings/${s() ?? ""}/audio.mp3`);
|
|
206
|
+
}), i(a, v), Z(F);
|
|
207
|
+
}
|
|
208
|
+
customElements.define("fortyfour-audio-player", W(
|
|
209
|
+
Ee,
|
|
210
|
+
{
|
|
211
|
+
recordingId: { attribute: "recording-id" },
|
|
212
|
+
theme: { attribute: "theme" }
|
|
213
|
+
},
|
|
214
|
+
[],
|
|
215
|
+
[],
|
|
216
|
+
!0
|
|
217
|
+
));
|