@braccato/core 0.1.6 → 0.1.7
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.js +204 -203
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,19 +11,19 @@ function B(t) {
|
|
|
11
11
|
if (o === "s") return Math.round(n * 1e3);
|
|
12
12
|
if (o === "ms") return Math.round(n);
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
let
|
|
14
|
+
const a = t.split(":").map((n) => n.replace(/[^0-9.]/g, ""));
|
|
15
|
+
let r = 0;
|
|
16
16
|
try {
|
|
17
|
-
return
|
|
17
|
+
return a.length === 1 ? r = Number.parseFloat(a[0]) * 1e3 : a.length === 2 ? r = Number.parseInt(a[0], 10) * 6e4 + Number.parseFloat(a[1]) * 1e3 : a.length === 3 && (r = Number.parseInt(a[0], 10) * 36e5 + Number.parseInt(a[1], 10) * 6e4 + Number.parseFloat(a[2]) * 1e3), Math.round(r);
|
|
18
18
|
} catch {
|
|
19
19
|
return 0;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
function I(t, e) {
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
for (const
|
|
26
|
-
if (
|
|
23
|
+
const a = t.getAttribute(e);
|
|
24
|
+
if (a !== null) return a;
|
|
25
|
+
for (const r of t.attributes)
|
|
26
|
+
if (r.localName === e) return r.value;
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
function Y(t) {
|
|
@@ -34,23 +34,23 @@ function Y(t) {
|
|
|
34
34
|
role: I(t, "role") ?? void 0,
|
|
35
35
|
children: []
|
|
36
36
|
};
|
|
37
|
-
for (const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
e.text +=
|
|
41
|
-
} else
|
|
37
|
+
for (const a of t.childNodes)
|
|
38
|
+
if (a.nodeType === 3) {
|
|
39
|
+
const r = a.textContent ?? "";
|
|
40
|
+
e.text += r, e.children.push({ text: r, children: [] });
|
|
41
|
+
} else a.nodeType === 1 && e.children.push(Y(a));
|
|
42
42
|
return e;
|
|
43
43
|
}
|
|
44
|
-
function $(t, e,
|
|
45
|
-
let
|
|
44
|
+
function $(t, e, a = !1) {
|
|
45
|
+
let r = "";
|
|
46
46
|
const n = [];
|
|
47
47
|
let o = !1;
|
|
48
48
|
for (const i of t) {
|
|
49
|
-
const s =
|
|
49
|
+
const s = a || i.role === "x-bg";
|
|
50
50
|
if (i.children.length > 0)
|
|
51
|
-
if (s && !
|
|
51
|
+
if (s && !a) {
|
|
52
52
|
const c = $(i.children, e, !0);
|
|
53
|
-
|
|
53
|
+
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
54
54
|
} else if (i.begin !== void 0 && i.end !== void 0) {
|
|
55
55
|
const c = i.children.map((f) => f.text).join("") || i.text;
|
|
56
56
|
n.push({
|
|
@@ -58,13 +58,13 @@ function $(t, e, r = !1) {
|
|
|
58
58
|
durationMs: i.end - i.begin,
|
|
59
59
|
words: c,
|
|
60
60
|
isBackground: s || void 0
|
|
61
|
-
}),
|
|
61
|
+
}), r += c, o = !0;
|
|
62
62
|
} else {
|
|
63
63
|
const c = $(i.children, e, s);
|
|
64
|
-
|
|
64
|
+
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
65
65
|
}
|
|
66
66
|
else if (i.text)
|
|
67
|
-
if (
|
|
67
|
+
if (r += i.text, i.begin !== void 0 && i.end !== void 0)
|
|
68
68
|
n.push({
|
|
69
69
|
startTimeMs: i.begin,
|
|
70
70
|
durationMs: i.end - i.begin,
|
|
@@ -81,34 +81,34 @@ function $(t, e, r = !1) {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return o ? { parts: n, text:
|
|
84
|
+
return o ? { parts: n, text: r, isWordSynced: o } : { parts: [], text: r, isWordSynced: !1 };
|
|
85
85
|
}
|
|
86
|
-
function ut(t, e,
|
|
86
|
+
function ut(t, e, a) {
|
|
87
87
|
if (t.length === 0) return t;
|
|
88
|
-
const
|
|
88
|
+
const r = [], n = (s, c) => ({
|
|
89
89
|
startTimeMs: s,
|
|
90
90
|
durationMs: c,
|
|
91
91
|
words: "",
|
|
92
92
|
parts: [],
|
|
93
93
|
isInstrumental: !0
|
|
94
94
|
});
|
|
95
|
-
t[0].startTimeMs >
|
|
95
|
+
t[0].startTimeMs > a && r.push(n(0, t[0].startTimeMs));
|
|
96
96
|
for (let s = 0; s < t.length; s++)
|
|
97
|
-
if (
|
|
97
|
+
if (r.push(t[s]), s < t.length - 1) {
|
|
98
98
|
const c = t[s].startTimeMs + t[s].durationMs, f = t[s + 1].startTimeMs - c;
|
|
99
|
-
f >
|
|
99
|
+
f > a && r.push(n(c, f));
|
|
100
100
|
}
|
|
101
101
|
const o = t[t.length - 1], i = o.startTimeMs + o.durationMs;
|
|
102
|
-
return e - i >
|
|
102
|
+
return e - i > a && r.push(n(i, e - i)), r;
|
|
103
103
|
}
|
|
104
104
|
function mt(t, e = {}) {
|
|
105
|
-
const
|
|
105
|
+
const a = t.replace(/\\"/g, '"'), r = new DOMParser().parseFromString(a, "text/xml"), n = r.querySelector("tt"), o = (n ? I(n, "lang") : null) ?? void 0, i = r.querySelector("body");
|
|
106
106
|
if (!i) return { lyrics: [], isWordSynced: !1, language: o };
|
|
107
107
|
const s = i.getAttribute("dur"), c = s ? B(s) : 0, f = i.querySelectorAll("p"), d = /* @__PURE__ */ new Map();
|
|
108
108
|
let l = !1;
|
|
109
109
|
const m = /* @__PURE__ */ new Map(), p = [
|
|
110
|
-
...
|
|
111
|
-
...
|
|
110
|
+
...r.querySelectorAll("agent"),
|
|
111
|
+
...r.getElementsByTagNameNS("http://www.w3.org/ns/ttml#metadata", "agent")
|
|
112
112
|
];
|
|
113
113
|
let w = 0;
|
|
114
114
|
for (const _ of p) {
|
|
@@ -128,7 +128,7 @@ function mt(t, e = {}) {
|
|
|
128
128
|
key: L
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const b =
|
|
131
|
+
const b = r.querySelectorAll("translations");
|
|
132
132
|
for (const _ of b) {
|
|
133
133
|
const h = _.getAttribute("lang");
|
|
134
134
|
if (!h) continue;
|
|
@@ -141,7 +141,7 @@ function mt(t, e = {}) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const v =
|
|
144
|
+
const v = r.querySelectorAll("transliterations");
|
|
145
145
|
for (const _ of v) {
|
|
146
146
|
const h = _.querySelectorAll("transliteration");
|
|
147
147
|
for (const M of h) {
|
|
@@ -174,27 +174,27 @@ function tt(t) {
|
|
|
174
174
|
if (!t) return 0;
|
|
175
175
|
if (typeof t == "number") return t;
|
|
176
176
|
const e = t.split(":");
|
|
177
|
-
let
|
|
177
|
+
let a = 0;
|
|
178
178
|
try {
|
|
179
179
|
if (e.length === 1)
|
|
180
|
-
|
|
180
|
+
a = Number.parseFloat(e[0]) * 1e3;
|
|
181
181
|
else if (e.length === 2) {
|
|
182
|
-
const
|
|
183
|
-
|
|
182
|
+
const r = Number.parseInt(e[0], 10), n = Number.parseFloat(e[1]);
|
|
183
|
+
a = r * 60 * 1e3 + n * 1e3;
|
|
184
184
|
} else if (e.length === 3) {
|
|
185
|
-
const
|
|
186
|
-
|
|
185
|
+
const r = Number.parseInt(e[0], 10), n = Number.parseInt(e[1], 10), o = Number.parseFloat(e[2]);
|
|
186
|
+
a = r * 3600 * 1e3 + n * 60 * 1e3 + o * 1e3;
|
|
187
187
|
}
|
|
188
|
-
return Math.round(
|
|
188
|
+
return Math.round(a);
|
|
189
189
|
} catch {
|
|
190
190
|
return 0;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
function ht(t, e) {
|
|
194
|
-
var
|
|
195
|
-
const
|
|
194
|
+
var a;
|
|
195
|
+
const r = t.split(`
|
|
196
196
|
`), n = [], o = {};
|
|
197
|
-
for (const i of
|
|
197
|
+
for (const i of r) {
|
|
198
198
|
const s = i.trim(), c = s.match(/^\[(\w+):(.*)\]$/);
|
|
199
199
|
if (c && pt.includes(c[1])) {
|
|
200
200
|
o[c[1]] = c[2];
|
|
@@ -243,17 +243,17 @@ function ht(t, e) {
|
|
|
243
243
|
let i = Number(o.offset);
|
|
244
244
|
Number.isNaN(i) && (i = 0), i = i * 1e3;
|
|
245
245
|
for (const s of n)
|
|
246
|
-
s.startTimeMs -= i, (
|
|
246
|
+
s.startTimeMs -= i, (a = s.parts) == null || a.forEach((c) => {
|
|
247
247
|
c.startTimeMs -= i;
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
return n;
|
|
251
251
|
}
|
|
252
252
|
function bt(t) {
|
|
253
|
-
for (const
|
|
254
|
-
if (
|
|
255
|
-
for (let n = 1; n <
|
|
256
|
-
const o =
|
|
253
|
+
for (const r of t)
|
|
254
|
+
if (r.parts)
|
|
255
|
+
for (let n = 1; n < r.parts.length; n++) {
|
|
256
|
+
const o = r.parts[n], i = r.parts[n - 1];
|
|
257
257
|
if (o.words === " " && i.words !== " ") {
|
|
258
258
|
const s = o.durationMs - i.durationMs;
|
|
259
259
|
if (Math.abs(s) <= 15 || o.durationMs <= 100) {
|
|
@@ -262,22 +262,22 @@ function bt(t) {
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
let e = 0,
|
|
266
|
-
for (const
|
|
267
|
-
if (!(!
|
|
268
|
-
for (let n = 0; n <
|
|
269
|
-
const o =
|
|
270
|
-
o.words !== " " && (o.durationMs <= 100 && e++,
|
|
265
|
+
let e = 0, a = 0;
|
|
266
|
+
for (const r of t)
|
|
267
|
+
if (!(!r.parts || r.parts.length === 0))
|
|
268
|
+
for (let n = 0; n < r.parts.length - 2; n++) {
|
|
269
|
+
const o = r.parts[n];
|
|
270
|
+
o.words !== " " && (o.durationMs <= 100 && e++, a++);
|
|
271
271
|
}
|
|
272
|
-
if (
|
|
273
|
-
for (let
|
|
274
|
-
const n = t[
|
|
272
|
+
if (a > 0 && e / a > 0.5)
|
|
273
|
+
for (let r = 0; r < t.length; r++) {
|
|
274
|
+
const n = t[r];
|
|
275
275
|
if (!(!n.parts || n.parts.length === 0))
|
|
276
276
|
for (let o = 0; o < n.parts.length; o++) {
|
|
277
277
|
const i = n.parts[o];
|
|
278
278
|
if (i.words !== " " && i.durationMs <= 400) {
|
|
279
279
|
let s = null;
|
|
280
|
-
o + 1 < n.parts.length ? s = n.parts[o + 1] :
|
|
280
|
+
o + 1 < n.parts.length ? s = n.parts[o + 1] : r + 1 < t.length && t[r + 1].parts && t[r + 1].parts.length > 0 && (s = t[r + 1].parts[0]), s === null ? i.durationMs = 300 : s.words === " " ? (i.durationMs += s.durationMs, s.startTimeMs += s.durationMs, s.durationMs = 0) : i.durationMs = s.startTimeMs - i.startTimeMs;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
|
@@ -287,36 +287,36 @@ const gt = {
|
|
|
287
287
|
return /\[\d+:\d+\.\d+\]/.test(t);
|
|
288
288
|
},
|
|
289
289
|
parse(t, e = 0) {
|
|
290
|
-
const
|
|
291
|
-
return bt(
|
|
290
|
+
const a = ht(t, e);
|
|
291
|
+
return bt(a), a;
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
294
|
function et(t) {
|
|
295
295
|
const e = t.trim().match(/^(\d+):(\d+):(\d+)[,.](\d+)$/);
|
|
296
296
|
if (!e) return 0;
|
|
297
|
-
const
|
|
298
|
-
return
|
|
297
|
+
const a = Number.parseInt(e[1], 10), r = Number.parseInt(e[2], 10), n = Number.parseInt(e[3], 10), o = Number.parseInt(e[4].padEnd(3, "0").slice(0, 3), 10);
|
|
298
|
+
return a * 36e5 + r * 6e4 + n * 1e3 + o;
|
|
299
299
|
}
|
|
300
300
|
const yt = {
|
|
301
301
|
detect(t) {
|
|
302
302
|
return /\d+\r?\n\d{2}:\d{2}:\d{2}[,.]\d+ --> \d{2}:\d{2}:\d{2}[,.]\d+/.test(t);
|
|
303
303
|
},
|
|
304
304
|
parse(t, e = 0) {
|
|
305
|
-
const
|
|
306
|
-
for (const n of
|
|
305
|
+
const a = t.trim().split(/\r?\n\r?\n/), r = [];
|
|
306
|
+
for (const n of a) {
|
|
307
307
|
const o = n.split(/\r?\n/);
|
|
308
308
|
if (o.length < 2) continue;
|
|
309
309
|
const i = o.find((p) => p.includes("-->"));
|
|
310
310
|
if (!i) continue;
|
|
311
311
|
const [s, c] = i.split("-->").map((p) => p.trim()), f = et(s), d = et(c), l = o.indexOf(i), m = o.slice(l + 1).join(`
|
|
312
312
|
`).replace(/<[^>]+>/g, "").trim();
|
|
313
|
-
m &&
|
|
313
|
+
m && r.push({
|
|
314
314
|
startTimeMs: f,
|
|
315
315
|
words: m,
|
|
316
316
|
durationMs: d - f
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
-
return
|
|
319
|
+
return r;
|
|
320
320
|
}
|
|
321
321
|
}, ct = {
|
|
322
322
|
detect(t) {
|
|
@@ -324,9 +324,9 @@ const yt = {
|
|
|
324
324
|
},
|
|
325
325
|
parse(t, e = 0) {
|
|
326
326
|
return t.split(`
|
|
327
|
-
`).map((
|
|
327
|
+
`).map((a) => ({
|
|
328
328
|
startTimeMs: 0,
|
|
329
|
-
words:
|
|
329
|
+
words: a,
|
|
330
330
|
durationMs: 0
|
|
331
331
|
}));
|
|
332
332
|
}
|
|
@@ -335,9 +335,9 @@ const yt = {
|
|
|
335
335
|
return /\[\d+,\d+\]/.test(t) && /\(\d+,\d+\)/.test(t);
|
|
336
336
|
},
|
|
337
337
|
parse(t, e = 0) {
|
|
338
|
-
const
|
|
339
|
-
`),
|
|
340
|
-
for (const n of
|
|
338
|
+
const a = t.split(`
|
|
339
|
+
`), r = [];
|
|
340
|
+
for (const n of a) {
|
|
341
341
|
const o = n.trim().match(/^\[(\d+),(\d+)\](.*)$/);
|
|
342
342
|
if (!o) continue;
|
|
343
343
|
const i = Number.parseInt(o[1], 10), s = Number.parseInt(o[2], 10), c = o[3], f = [];
|
|
@@ -347,14 +347,14 @@ const yt = {
|
|
|
347
347
|
const p = m[1], w = Number.parseInt(m[2], 10), b = Number.parseInt(m[3], 10);
|
|
348
348
|
d += p, f.push({ startTimeMs: w, words: p, durationMs: b });
|
|
349
349
|
}
|
|
350
|
-
|
|
350
|
+
r.push({
|
|
351
351
|
startTimeMs: i,
|
|
352
352
|
words: d,
|
|
353
353
|
durationMs: s,
|
|
354
354
|
parts: f.length > 0 ? f : void 0
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
|
-
return
|
|
357
|
+
return r;
|
|
358
358
|
}
|
|
359
359
|
}, vt = [ft, gt, yt, St, ct];
|
|
360
360
|
function wt(t) {
|
|
@@ -378,28 +378,28 @@ function _t() {
|
|
|
378
378
|
function Mt(t) {
|
|
379
379
|
t.skipScrollsDecayTimes = [], t.doneFirstInstantScroll = !1, t.queuedScroll = !1;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function at(t) {
|
|
382
382
|
t.wasUserScrolling = !0, t.scrollResumeTime = Date.now() + Tt;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function rt(t) {
|
|
385
385
|
t.scrollResumeTime = 0;
|
|
386
386
|
}
|
|
387
387
|
function At(t) {
|
|
388
388
|
return t.scrollResumeTime > Date.now();
|
|
389
389
|
}
|
|
390
390
|
function Et(t, e) {
|
|
391
|
-
let
|
|
392
|
-
for (;
|
|
391
|
+
let a = 0;
|
|
392
|
+
for (; a < t.skipScrollsDecayTimes.length && !(t.skipScrollsDecayTimes[a] > e); a++)
|
|
393
393
|
;
|
|
394
|
-
t.skipScrollsDecayTimes = t.skipScrollsDecayTimes.slice(
|
|
394
|
+
t.skipScrollsDecayTimes = t.skipScrollsDecayTimes.slice(a), t.skipScrolls -= a, t.skipScrolls < 1 && (t.skipScrolls = 1);
|
|
395
395
|
}
|
|
396
|
-
const W = "braccato--animating",
|
|
396
|
+
const W = "braccato--animating", H = "braccato--pre-animating", q = "braccato--paused", nt = "braccato--active", Ct = "braccato--user-scrolling", Lt = 0.5, xt = 0.5, Nt = 0.62, kt = 0.37, It = 150, Q = /* @__PURE__ */ new Map();
|
|
397
397
|
function Dt(t) {
|
|
398
398
|
return t ? t.endsWith("ms") ? Number.parseFloat(t.slice(0, -2)) : t.endsWith("s") ? Number.parseFloat(t.slice(0, -1)) * 1e3 : 0 : 0;
|
|
399
399
|
}
|
|
400
400
|
function U(t, e) {
|
|
401
|
-
let
|
|
402
|
-
return
|
|
401
|
+
let a = Q.get(e);
|
|
402
|
+
return a === void 0 && (a = Dt(getComputedStyle(t).getPropertyValue(e)), Q.set(e, a)), a;
|
|
403
403
|
}
|
|
404
404
|
function it(t) {
|
|
405
405
|
t.offsetHeight;
|
|
@@ -418,8 +418,8 @@ function Pt(t) {
|
|
|
418
418
|
Mt(t.scroll), t.lastActiveElements = [], Q.clear();
|
|
419
419
|
}
|
|
420
420
|
function zt(t, e) {
|
|
421
|
-
const
|
|
422
|
-
let { currentTime:
|
|
421
|
+
const a = Date.now();
|
|
422
|
+
let { currentTime: r, isPlaying: n, smoothScroll: o } = e;
|
|
423
423
|
const {
|
|
424
424
|
eventCreationTime: i,
|
|
425
425
|
lyricsData: s,
|
|
@@ -429,14 +429,14 @@ function zt(t, e) {
|
|
|
429
429
|
earlyScrollConsider: l = Nt,
|
|
430
430
|
queueScrollMs: m = It
|
|
431
431
|
} = e;
|
|
432
|
-
if (
|
|
433
|
-
const p = Math.abs(
|
|
434
|
-
t.lastTime =
|
|
435
|
-
const w = n ?
|
|
436
|
-
|
|
432
|
+
if (r === 0 && !n) return;
|
|
433
|
+
const p = Math.abs(r - t.lastTime - (i - t.lastEventCreationTime) / 1e3) > Lt;
|
|
434
|
+
t.lastTime = r, t.lastPlayState = n, t.lastEventCreationTime = i;
|
|
435
|
+
const w = n ? a - i : 0;
|
|
436
|
+
r += w / 1e3;
|
|
437
437
|
const { lines: b, container: v, syncType: P } = s;
|
|
438
|
-
P === "richsync" ?
|
|
439
|
-
const T =
|
|
438
|
+
P === "richsync" ? r += U(v, "--braccato-richsync-timing-offset") / 1e3 : r += U(v, "--braccato-timing-offset") / 1e3;
|
|
439
|
+
const T = r + U(v, "--braccato-scroll-timing-offset") / 1e3, _ = c.getBoundingClientRect().height;
|
|
440
440
|
let h = c.scrollTop;
|
|
441
441
|
const M = [], L = [];
|
|
442
442
|
let k = p;
|
|
@@ -444,9 +444,9 @@ function zt(t, e) {
|
|
|
444
444
|
const u = b[y], g = u.time, A = y + 1 < b.length ? b[y + 1].time : Number.POSITIVE_INFINITY;
|
|
445
445
|
T >= g - l && (T < A || T < g + u.duration) ? (M.push(u), !t.lastActiveElements.includes(u) && T >= g && (k = !0), t.selectedElementIndex = y, u.isScrolled || (u.element.classList.add(nt), u.isScrolled = !0)) : u.isScrolled && (u.element.classList.remove(nt), u.isScrolled = !1);
|
|
446
446
|
const x = n ? 2 : 0, N = Math.max(A, g + u.duration + 0.05);
|
|
447
|
-
if (
|
|
447
|
+
if (r + x >= g && r < N) {
|
|
448
448
|
u.isSelected = !0;
|
|
449
|
-
const O =
|
|
449
|
+
const O = r - g, z = (a - u.animationStartTimeMs) / 1e3 - O;
|
|
450
450
|
if (u.accumulatedOffsetMs = u.accumulatedOffsetMs / 1.08, u.accumulatedOffsetMs += z * 1e3 * 0.4, u.isAnimating && Math.abs(u.accumulatedOffsetMs) > 100 && n && (u.isAnimating = !1), n !== u.isAnimationPlayStatePlaying) {
|
|
451
451
|
u.isAnimationPlayStatePlaying = n;
|
|
452
452
|
const J = [u, ...u.parts];
|
|
@@ -456,13 +456,13 @@ function zt(t, e) {
|
|
|
456
456
|
u.isAnimating = !1;
|
|
457
457
|
} else
|
|
458
458
|
for (const F of J)
|
|
459
|
-
F.animationStartTimeMs >
|
|
459
|
+
F.animationStartTimeMs > a ? (F.element.classList.remove(W), F.element.classList.remove(H)) : F.element.classList.add(q);
|
|
460
460
|
}
|
|
461
461
|
u.isAnimating || L.push(u);
|
|
462
462
|
} else if (u.isSelected) {
|
|
463
463
|
const O = [u, ...u.parts];
|
|
464
464
|
for (const z of O)
|
|
465
|
-
z.element.style.setProperty("--braccato-swipe-delay", ""), z.element.style.setProperty("--braccato-anim-delay", ""), z.element.classList.remove(W), z.element.classList.remove(
|
|
465
|
+
z.element.style.setProperty("--braccato-swipe-delay", ""), z.element.style.setProperty("--braccato-anim-delay", ""), z.element.classList.remove(W), z.element.classList.remove(H), z.element.classList.remove(q), z.animationStartTimeMs = Number.POSITIVE_INFINITY;
|
|
466
466
|
u.isSelected = !1, u.isAnimating = !1;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
@@ -470,43 +470,43 @@ function zt(t, e) {
|
|
|
470
470
|
for (const y of L) {
|
|
471
471
|
const u = [y, ...y.parts];
|
|
472
472
|
for (const g of u) {
|
|
473
|
-
const A =
|
|
474
|
-
g.element.classList.remove(W), g.element.classList.remove(q), g.element.style.setProperty("--braccato-swipe-delay", `${-A - g.duration * 0.1}s`), g.element.style.setProperty("--braccato-anim-delay", `${-A}s`), g.element.classList.add(
|
|
473
|
+
const A = r - g.time;
|
|
474
|
+
g.element.classList.remove(W), g.element.classList.remove(q), g.element.style.setProperty("--braccato-swipe-delay", `${-A - g.duration * 0.1}s`), g.element.style.setProperty("--braccato-anim-delay", `${-A}s`), g.element.classList.add(H);
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
it(L[0].element);
|
|
478
478
|
for (const y of L) {
|
|
479
479
|
const u = [y, ...y.parts];
|
|
480
480
|
for (const g of u) {
|
|
481
|
-
const A =
|
|
482
|
-
g.element.classList.add(W), g.animationStartTimeMs =
|
|
481
|
+
const A = r - g.time;
|
|
482
|
+
g.element.classList.add(W), g.animationStartTimeMs = a - A * 1e3;
|
|
483
483
|
}
|
|
484
|
-
y.isAnimating = !0, y.lastAnimSetupAt =
|
|
484
|
+
y.isAnimating = !0, y.lastAnimSetupAt = a, y.isAnimationPlayStatePlaying = !0, y.accumulatedOffsetMs = 0;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
const S = t.scroll;
|
|
488
|
-
if (S.scrollResumeTime <
|
|
488
|
+
if (S.scrollResumeTime < a || S.scrollPos === -1) {
|
|
489
489
|
M.length === 0 && M.push(b[0]), t.lastActiveElements = M.filter((N) => T >= N.time);
|
|
490
490
|
const y = _ * f, u = M[M.length - 1], g = M.filter((N, O) => T < N.time + N.duration - d || O === M.length - 1).map((N) => N.position + N.height / 2);
|
|
491
491
|
let x = g.reduce((N, O) => N + O, 0) / g.length - y;
|
|
492
492
|
if (x = Math.min(x, M[0].position), x = Math.max(x, u.position - _ + u.height), x = Math.min(x, u.position), x = Math.max(0, x), h === 0 && !S.doneFirstInstantScroll && (o = !1, S.doneFirstInstantScroll = !0, S.nextScrollAllowedTime = 0), S.wasUserScrolling || k || S.queuedScroll)
|
|
493
|
-
if (
|
|
493
|
+
if (a > S.nextScrollAllowedTime) {
|
|
494
494
|
if (S.queuedScroll = !1, o && Math.abs(h - x) > 2) {
|
|
495
495
|
v.style.transitionTimingFunction = "", v.style.transitionProperty = "", v.style.transitionDuration = "";
|
|
496
496
|
const N = U(v, "transition-duration");
|
|
497
|
-
v.style.transition = "none", v.style.transform = `translate(0px, ${-(h - x)}px)`, it(v), v.style.transition = "", v.style.transform = "translate(0px, 0px)", S.nextScrollAllowedTime = N +
|
|
497
|
+
v.style.transition = "none", v.style.transform = `translate(0px, ${-(h - x)}px)`, it(v), v.style.transition = "", v.style.transform = "translate(0px, 0px)", S.nextScrollAllowedTime = N + a + 20;
|
|
498
498
|
}
|
|
499
|
-
h = x, S.scrollPos = h, c.scrollTop = h, S.skipScrolls += 1, S.skipScrollsDecayTimes.push(
|
|
500
|
-
} else (S.nextScrollAllowedTime -
|
|
499
|
+
h = x, S.scrollPos = h, c.scrollTop = h, S.skipScrolls += 1, S.skipScrollsDecayTimes.push(a + 2e3);
|
|
500
|
+
} else (S.nextScrollAllowedTime - a < m || p) && (S.queuedScroll = !0);
|
|
501
501
|
}
|
|
502
|
-
S.wasUserScrolling && S.scrollResumeTime <
|
|
502
|
+
S.wasUserScrolling && S.scrollResumeTime < a && (v.classList.remove(Ct), S.wasUserScrolling = !1), Et(S, a);
|
|
503
503
|
}
|
|
504
504
|
const C = "http://www.w3.org/2000/svg", Ot = "braccato--instrumental", Ft = "braccato--instrumental-icon", Bt = "braccato--instrumental-bg", Wt = "braccato--instrumental-fill", qt = "braccato--wave-clip", Ut = "braccato--wave-rect", $t = "braccato--wave-path", st = "M10 21q-1.65 0-2.825-1.175T6 17t1.175-2.825T10 13q.575 0 1.063.138t.937.412V4q0-.425.288-.712T13 3h4q.425 0 .713.288T18 4v2q0 .425-.288.713T17 7h-3v10q0 1.65-1.175 2.825T10 21";
|
|
505
|
-
function
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
const
|
|
509
|
-
|
|
505
|
+
function Ht(t, e) {
|
|
506
|
+
const a = document.createElement("div");
|
|
507
|
+
a.classList.add(Ot), a.style.setProperty("--braccato-duration", `${t}ms`);
|
|
508
|
+
const r = document.createElementNS(C, "svg");
|
|
509
|
+
r.classList.add(Ft), r.setAttribute("viewBox", "0 0 24 24");
|
|
510
510
|
const n = document.createElementNS(C, "defs"), o = `braccato-glow-${e}`, i = `braccato-wave-clip-${e}`, s = document.createElementNS(C, "filter");
|
|
511
511
|
s.setAttribute("id", o), s.setAttribute("x", "-100%"), s.setAttribute("y", "-100%"), s.setAttribute("width", "300%"), s.setAttribute("height", "300%");
|
|
512
512
|
const c = document.createElementNS(C, "feGaussianBlur");
|
|
@@ -522,117 +522,118 @@ function Gt(t, e) {
|
|
|
522
522
|
const w = document.createElementNS(C, "path");
|
|
523
523
|
w.classList.add(Ut), w.setAttribute("d", "M -4 3.9 L 30 3.9 L 30 30 L -4 30 Z"), p.appendChild(w);
|
|
524
524
|
const b = document.createElementNS(C, "path");
|
|
525
|
-
b.classList.add($t), b.setAttribute("d", "M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z"), p.appendChild(b), n.appendChild(p),
|
|
525
|
+
b.classList.add($t), b.setAttribute("d", "M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z"), p.appendChild(b), n.appendChild(p), r.appendChild(n);
|
|
526
526
|
const v = document.createElementNS(C, "path");
|
|
527
|
-
v.classList.add(Bt), v.setAttribute("d", st),
|
|
527
|
+
v.classList.add(Bt), v.setAttribute("d", st), r.appendChild(v);
|
|
528
528
|
const P = document.createElementNS(C, "g");
|
|
529
529
|
P.setAttribute("filter", `url(#${o})`);
|
|
530
530
|
const T = document.createElementNS(C, "path");
|
|
531
|
-
return T.classList.add(Wt), T.setAttribute("clip-path", `url(#${i})`), T.setAttribute("d", st), P.appendChild(T),
|
|
531
|
+
return T.classList.add(Wt), T.setAttribute("clip-path", `url(#${i})`), T.setAttribute("d", st), P.appendChild(T), r.appendChild(P), a.appendChild(r), a;
|
|
532
532
|
}
|
|
533
|
-
const
|
|
533
|
+
const Gt = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}]/u;
|
|
534
534
|
function j(t) {
|
|
535
|
-
return
|
|
535
|
+
return Gt.test(t);
|
|
536
536
|
}
|
|
537
|
-
const Yt = /[\s\p{Dash_Punctuation}]/u, Qt = /\s+$/, jt = 5;
|
|
538
|
-
function
|
|
537
|
+
const Yt = /[\s\p{Dash_Punctuation}]/u, Qt = /\s+$/, jt = 5, Vt = /[\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Hangul}\p{sc=Thai}\p{sc=Lao}\p{sc=Khmer}\p{sc=Myanmar}]/u;
|
|
538
|
+
function Zt(t) {
|
|
539
539
|
const e = t.replace(Qt, "");
|
|
540
540
|
return e.length <= jt ? !1 : !Yt.test(e);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function Kt(t) {
|
|
543
543
|
try {
|
|
544
|
-
const e = new Intl.Segmenter(void 0, { granularity: "word" }),
|
|
545
|
-
if (
|
|
546
|
-
|
|
547
|
-
|
|
544
|
+
const e = new Intl.Segmenter(void 0, { granularity: "word" }), a = Array.from(e.segment(t), (n) => n.segment);
|
|
545
|
+
if (a.length > 1) return a;
|
|
546
|
+
if (!Vt.test(t)) return [t];
|
|
547
|
+
const r = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
548
|
+
return Array.from(r.segment(t), (n) => n.segment);
|
|
548
549
|
} catch {
|
|
549
550
|
return Array.from(t);
|
|
550
551
|
}
|
|
551
552
|
}
|
|
552
|
-
function
|
|
553
|
-
if (!
|
|
553
|
+
function Jt(t) {
|
|
554
|
+
if (!Zt(t.words))
|
|
554
555
|
return [{ ...t, isWrapAfter: !1 }];
|
|
555
|
-
const e =
|
|
556
|
+
const e = Kt(t.words);
|
|
556
557
|
if (e.length <= 1)
|
|
557
558
|
return [{ ...t, isWrapAfter: !1 }];
|
|
558
|
-
const
|
|
559
|
-
return e.map((
|
|
560
|
-
startTimeMs: t.startTimeMs + n *
|
|
561
|
-
durationMs:
|
|
562
|
-
words:
|
|
559
|
+
const a = t.durationMs / e.length;
|
|
560
|
+
return e.map((r, n) => ({
|
|
561
|
+
startTimeMs: t.startTimeMs + n * a,
|
|
562
|
+
durationMs: a,
|
|
563
|
+
words: r,
|
|
563
564
|
isBackground: t.isBackground,
|
|
564
565
|
isWrapAfter: n < e.length - 1
|
|
565
566
|
}));
|
|
566
567
|
}
|
|
567
|
-
const
|
|
568
|
-
function ie(t, e) {
|
|
569
|
-
for (let r = e - 1; r >= 0; r--)
|
|
570
|
-
if (!t[r].isInstrumental && t[r].agent) return t[r].agent;
|
|
571
|
-
for (let r = e + 1; r < t.length; r++)
|
|
572
|
-
if (!t[r].isInstrumental && t[r].agent) return t[r].agent;
|
|
573
|
-
}
|
|
568
|
+
const Xt = "braccato--line", te = "braccato--word", ee = "braccato--break", V = "braccato-background-lyric", Z = "braccato-rtl", ae = "braccato-zero-dur-animate", re = "braccato--romanized", ne = "braccato--translated", ie = /[\s\p{Dash_Punctuation}]/u;
|
|
574
569
|
function se(t, e) {
|
|
575
|
-
|
|
570
|
+
for (let a = e - 1; a >= 0; a--)
|
|
571
|
+
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
572
|
+
for (let a = e + 1; a < t.length; a++)
|
|
573
|
+
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
574
|
+
}
|
|
575
|
+
function oe(t, e) {
|
|
576
|
+
var a, r;
|
|
576
577
|
for (let n = e - 1; n >= 0; n--)
|
|
577
|
-
if (!t[n].isInstrumental && ((r = t[n].words) != null && r.trim())) return j(t[n].words);
|
|
578
|
-
for (let n = e + 1; n < t.length; n++)
|
|
579
578
|
if (!t[n].isInstrumental && ((a = t[n].words) != null && a.trim())) return j(t[n].words);
|
|
579
|
+
for (let n = e + 1; n < t.length; n++)
|
|
580
|
+
if (!t[n].isInstrumental && ((r = t[n].words) != null && r.trim())) return j(t[n].words);
|
|
580
581
|
return !1;
|
|
581
582
|
}
|
|
582
|
-
function
|
|
583
|
-
const
|
|
584
|
-
|
|
583
|
+
function G(t, e) {
|
|
584
|
+
const a = document.createElement("span");
|
|
585
|
+
a.classList.add(ee), a.style.order = String(e), t.appendChild(a);
|
|
585
586
|
}
|
|
586
|
-
function
|
|
587
|
-
let
|
|
587
|
+
function ce(t, e) {
|
|
588
|
+
let a = [], r = !1;
|
|
588
589
|
const n = () => {
|
|
589
|
-
if (
|
|
590
|
+
if (a.length > 0) {
|
|
590
591
|
const o = document.createElement("span");
|
|
591
|
-
for (const i of
|
|
592
|
-
|
|
592
|
+
for (const i of a) o.appendChild(i);
|
|
593
|
+
r && o.classList.add(V), t.appendChild(o), a = [];
|
|
593
594
|
}
|
|
594
595
|
};
|
|
595
596
|
for (const o of e) {
|
|
596
597
|
const i = o.classList.contains(V);
|
|
597
|
-
|
|
598
|
-
const s = o.textContent ?? "", c = s.length > 0 &&
|
|
598
|
+
r !== i && (n(), r = i), a.push(o);
|
|
599
|
+
const s = o.textContent ?? "", c = s.length > 0 && ie.test(s[s.length - 1]), f = o.dataset.wrapAfter === "true";
|
|
599
600
|
(c || f) && n();
|
|
600
601
|
}
|
|
601
602
|
n();
|
|
602
603
|
}
|
|
603
|
-
function ot(t, e,
|
|
604
|
+
function ot(t, e, a, r) {
|
|
604
605
|
let n = [], o = !0;
|
|
605
606
|
const i = [];
|
|
606
607
|
for (const s of t) {
|
|
607
608
|
const c = j(s.words);
|
|
608
609
|
!c && s.words.trim().length > 0 && (o = !1, n.reverse().forEach((d) => i.push(d)), n = []);
|
|
609
|
-
const f =
|
|
610
|
+
const f = Jt(s);
|
|
610
611
|
for (const d of f) {
|
|
611
612
|
const l = document.createElement("span");
|
|
612
|
-
l.classList.add(
|
|
613
|
+
l.classList.add(te), d.durationMs === 0 && l.classList.add(ae), c && l.classList.add(Z);
|
|
613
614
|
const m = {
|
|
614
615
|
time: d.startTimeMs / 1e3,
|
|
615
616
|
duration: d.durationMs / 1e3,
|
|
616
617
|
element: l,
|
|
617
618
|
animationStartTimeMs: Number.POSITIVE_INFINITY
|
|
618
619
|
};
|
|
619
|
-
l.textContent = d.words, l.dataset.time = String(m.time), l.dataset.duration = String(m.duration), l.dataset.content = d.words, l.style.setProperty("--braccato-duration", `${d.durationMs}ms`), d.durationMs >
|
|
620
|
+
l.textContent = d.words, l.dataset.time = String(m.time), l.dataset.duration = String(m.duration), l.dataset.content = d.words, l.style.setProperty("--braccato-duration", `${d.durationMs}ms`), d.durationMs > r && (l.dataset.longWord = "true"), d.isBackground && l.classList.add(V), d.isWrapAfter && (l.dataset.wrapAfter = "true"), d.words.trim().length === 0 && (l.style.display = "inline"), d.words.trim().length !== 0 && e.parts.push(m), c ? n.push(l) : i.push(l);
|
|
620
621
|
}
|
|
621
622
|
}
|
|
622
623
|
if (o && n.length > 0) {
|
|
623
|
-
|
|
624
|
+
a.classList.add(Z);
|
|
624
625
|
for (const s of n) i.push(s);
|
|
625
626
|
} else n.length > 0 && n.reverse().forEach((s) => i.push(s));
|
|
626
|
-
|
|
627
|
+
ce(a, i);
|
|
627
628
|
}
|
|
628
|
-
function
|
|
629
|
-
const { longWordThreshold:
|
|
629
|
+
function le(t, e, a = {}) {
|
|
630
|
+
const { longWordThreshold: r = 1500, lineSyncedAnimationDelay: n = 50, disableRichsync: o = !1 } = a;
|
|
630
631
|
e.replaceChildren();
|
|
631
632
|
let s = t.every((d) => d.startTimeMs === 0) ? "none" : "synced";
|
|
632
633
|
const c = [];
|
|
633
634
|
for (let d = 0; d < t.length; d++) {
|
|
634
|
-
const l = t[d], m = l.isInstrumental ?
|
|
635
|
-
m.classList.add(
|
|
635
|
+
const l = t[d], m = l.isInstrumental ? Ht(l.durationMs, d) : document.createElement("div");
|
|
636
|
+
m.classList.add(Xt);
|
|
636
637
|
const p = {
|
|
637
638
|
element: m,
|
|
638
639
|
time: l.startTimeMs / 1e3,
|
|
@@ -650,8 +651,8 @@ function ce(t, e, r = {}) {
|
|
|
650
651
|
};
|
|
651
652
|
if (l.isInstrumental) {
|
|
652
653
|
m.dataset.instrumental = "true", m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(d);
|
|
653
|
-
const b =
|
|
654
|
-
b && (m.dataset.agent = b),
|
|
654
|
+
const b = se(t, d);
|
|
655
|
+
b && (m.dataset.agent = b), oe(t, d) && m.classList.add(Z), c.push(p), e.appendChild(m);
|
|
655
656
|
continue;
|
|
656
657
|
}
|
|
657
658
|
let w = l.parts ?? [];
|
|
@@ -659,16 +660,16 @@ function ce(t, e, r = {}) {
|
|
|
659
660
|
startTimeMs: l.startTimeMs + v * n,
|
|
660
661
|
words: b.trim().length < 1 ? b : `${b} `,
|
|
661
662
|
durationMs: 0
|
|
662
|
-
}))), w.every((b) => b.durationMs === 0) || (s = "richsync"), ot(w, p, m,
|
|
663
|
-
|
|
663
|
+
}))), w.every((b) => b.durationMs === 0) || (s = "richsync"), ot(w, p, m, r), G(m, 1), m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(d), m.style.setProperty("--braccato-duration", `${l.durationMs}ms`), l.agent && (m.dataset.agent = l.agent), l.romanization) {
|
|
664
|
+
G(m, 4);
|
|
664
665
|
const b = document.createElement("div");
|
|
665
|
-
b.classList.add(re), b.style.order = "5", l.timedRomanization && l.timedRomanization.length > 0 && !o ? ot(l.timedRomanization, p, b,
|
|
666
|
+
b.classList.add(re), b.style.order = "5", l.timedRomanization && l.timedRomanization.length > 0 && !o ? ot(l.timedRomanization, p, b, r) : b.textContent = `
|
|
666
667
|
${l.romanization}`, m.appendChild(b);
|
|
667
668
|
}
|
|
668
669
|
if (l.translation) {
|
|
669
|
-
|
|
670
|
+
G(m, 6);
|
|
670
671
|
const b = document.createElement("div");
|
|
671
|
-
b.classList.add(
|
|
672
|
+
b.classList.add(ne), b.style.order = "7", b.textContent = `
|
|
672
673
|
${l.translation.text}`, m.appendChild(b);
|
|
673
674
|
}
|
|
674
675
|
c.push(p), e.appendChild(m);
|
|
@@ -683,13 +684,13 @@ ${l.translation.text}`, m.appendChild(b);
|
|
|
683
684
|
container: e
|
|
684
685
|
};
|
|
685
686
|
}
|
|
686
|
-
const le = ':host{display:block;overflow-y:auto;position:relative;container-type:size;scrollbar-width:none}:host::-webkit-scrollbar{display:none}:host(:has(.braccato--user-scrolling)){scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar{display:block;width:6px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-thumb{background:#ffffff26;border-radius:3px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-track{background:transparent}.braccato-container{font-family:var(--braccato-font-family);font-size:var(--braccato-font-size);font-weight:var(--braccato-font-weight);isolation:isolate;line-height:var(--braccato-line-height);position:relative;z-index:1;transition:transform var(--braccato-scroll-duration) var(--braccato-scroll-timing-function) 0s;padding-top:2rem;padding-bottom:var(--braccato-padding-bottom)}.braccato-container>div{cursor:pointer;padding:var(--braccato-padding) 0;transform-origin:left center;word-break:break-word;transition:filter calc(var(--braccato-duration) / 3) .4s,opacity calc(var(--braccato-duration) / 2) .166s,transform .166s var(--braccato-anim-delay, 0s)}.braccato-container:has(.braccato--active):not(.braccato--user-scrolling)>div:not(.braccato--active):not(.braccato--active~div){opacity:.33;filter:blur(2.5px)}.braccato-container>div.braccato--active{opacity:1;filter:blur(0px)}.braccato-container>div.braccato--active~div{opacity:.66;filter:blur(0px)}.braccato-container>.braccato--animating{opacity:1!important;filter:blur(0px)!important}.braccato-container>div:hover{opacity:1!important;filter:blur(0px)!important;transform:scale(var(--braccato-hover-scale, 1.01));transition:all .3s ease}.braccato--active{cursor:default}:not(.braccato-background-lyric){order:0}.braccato-background-lyric{order:2}.braccato--line>span>span.braccato-background-lyric{font-size:.675em;font-weight:400}.braccato--line{transform:scale(var(--braccato-scale));transition-property:transform;transition-duration:var(--braccato-scale-transition-duration);transition-timing-function:ease;display:flex;flex-flow:row wrap;align-items:start;align-content:flex-start;padding-left:.25em;padding-right:.25em;box-sizing:border-box}.braccato--line.braccato--animating{transform:scale(var(--braccato-active-scale));transition-delay:var(--braccato-anim-delay)}.braccato--line>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--word{white-space:pre;display:inline-block;transform:translateY(0);position:relative}.braccato--line.braccato--pre-animating,.braccato--line.braccato--pre-animating .braccato--word{will-change:transform}.braccato--break{flex-basis:100%;height:0}.braccato--word.braccato--animating{animation:braccato-wobble var(--braccato-wobble-duration) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running}.braccato--word.braccato--animating.braccato--paused{animation-play-state:paused}.braccato--word:after{position:absolute;content:attr(data-content);top:-2rem;left:-2rem;white-space:pre-wrap;padding:2rem;pointer-events:none;color:transparent;box-sizing:content-box;width:100%;background-image:linear-gradient(90deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px));opacity:0;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;--braccato-glow-color: color(display-p3 1 1 1 / .0001);transition:--lyric-transition-amount-start 1s linear 1000s,--lyric-transition-amount-end 1s linear 1000s,opacity .5s ease;-webkit-background-clip:text;background-clip:text}.braccato--word[data-long-word]:after{--braccato-glow-color: color(display-p3 1 1 1 / 1)}.braccato--word.braccato--pre-animating:not(.braccato--animating):after{transition:none;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;opacity:0}.braccato--word.braccato--pre-animating:not(.braccato--animating):not(.braccato-zero-dur-animate):after{opacity:1}.braccato--word.braccato--animating:after{opacity:1;animation:braccato-glow max(calc(var(--braccato-duration) * 1.2),1.2s) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running;--lyric-transition-amount-start: 1.4;--lyric-transition-amount-end: 1.5;transition-property:--lyric-transition-amount-start,--lyric-transition-amount-end,opacity;transition-duration:calc(var(--braccato-duration) * 1.6),calc(var(--braccato-duration) * 1.6),var(--braccato-highlight-fade-in-duration);transition-timing-function:linear,linear,ease;transition-delay:var(--braccato-swipe-delay),var(--braccato-swipe-delay),var(--braccato-anim-delay)}.braccato--word.braccato--animating.braccato--paused:after{transition-duration:100000000s,100000000s,100000000s;--lyric-transition-amount-start: 10;--lyric-transition-amount-end: 10;opacity:.5;animation-play-state:paused}.braccato--translated,.braccato--romanized{display:block;font-size:var(--braccato-translated-font-size);font-weight:var(--braccato-translated-font-weight);font-family:var(--braccato-translated-font-family);color:var(--braccato-translated-color);white-space:normal;line-height:1.1;margin-top:8px}.braccato--romanized>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--romanized{width:fit-content;font-size:calc(var(--braccato-translated-font-size) / 1.25);background:#ffffff0d;padding:.375rem .75rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem}.braccato-rtl{direction:rtl}.braccato-rtl.braccato--word:after{background-image:linear-gradient(270deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px))}.braccato--line[data-agent=v2],.braccato--line[data-agent=v3]{justify-content:flex-end;text-align:right;transform-origin:right center!important}.braccato--line[data-agent=v1000]{justify-content:center;text-align:center;transform-origin:center center!important}.braccato--instrumental-icon{height:var(--braccato-font-size);width:calc(var(--braccato-font-size) + var(--braccato-font-size) / 3);overflow:visible;margin-left:calc(var(--braccato-font-size) / -3)}.braccato-rtl.braccato--instrumental .braccato--instrumental-icon,.braccato--instrumental[data-agent=v2] .braccato--instrumental-icon,.braccato--instrumental[data-agent=v3] .braccato--instrumental-icon{margin-left:0;margin-right:calc(var(--braccato-font-size) / -3)}.braccato--instrumental[data-agent=v1000] .braccato--instrumental-icon{margin-left:0;margin-right:0}.braccato--instrumental-bg{fill:var(--braccato-inactive-color)}.braccato--instrumental-fill{fill:var(--braccato-active-color);transition:opacity var(--braccato-highlight-fade-out-duration, .5s) ease;opacity:0}.braccato--instrumental.braccato--animating .braccato--instrumental-fill{transition:none;opacity:1}.braccato--instrumental:not(.braccato--pre-animating) .braccato--wave-clip{transition-property:transform;transition-duration:1000000s;transition-delay:0s;transform:translateY(0)}.braccato--instrumental.braccato--pre-animating:not(.braccato--animating) .braccato--wave-clip{animation:none;transform:translateY(78%)}.braccato--instrumental.braccato--animating .braccato--wave-clip{transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:linear;transition-delay:var(--braccato-anim-delay);transform:translateY(-4%)}.braccato--paused .braccato--wave-clip{transition-duration:100000000s!important;transform:translateY(100%)!important}.braccato--wave-path{transform-box:fill-box;transform-origin:bottom;animation:braccato-wave 1.25s ease-in-out infinite;animation-play-state:paused;transform:scaleY(1.2)}.braccato--instrumental.braccato--animating:not(.braccato--paused) .braccato--wave-path{animation-play-state:running;transform:scaleY(0);transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:ease-in;transition-delay:var(--braccato-anim-delay)}.braccato--instrumental.braccato--animating.braccato--paused .braccato--wave-path{transform:scaleY(.0001);transition-duration:10000000000s;transition-property:transform;transition-timing-function:ease-out;transition-delay:0s}@keyframes braccato-wave{0%,to{d:path("M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z")}50%{d:path("M -4 3 Q 1 4 5 3 Q 10 2 14 3 Q 18 4 22 3 Q 26 2 30 3 L 30 4 L -4 4 Z")}}.braccato--spacer{padding:0;margin:0}.braccato-autoscroll-btn{font-family:var(--braccato-font-family);position:absolute;display:block;font-size:1.75rem;font-weight:600;white-space:normal;line-height:1.1;width:fit-content;background:#ffffff0d;padding:.5rem 1rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem;color:#fff;left:50%;transform:translate(-50%,2em);-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;z-index:100;transition:opacity .15s linear .05s,transform .2s cubic-bezier(.5,1,.89,1)}.braccato-autoscroll-btn[hidden]{transition:opacity .1s linear,transform .15s ease-in;opacity:0;pointer-events:none;transform:translate(-50%,-3em)}@keyframes braccato-wobble{0%{transform:translateY(0)}to{transform:translateY(-.0375em)}}@keyframes braccato-glow{0%{filter:drop-shadow(0 0 .8rem var(--braccato-glow-color))}to{filter:drop-shadow(0 0 0rem var(--braccato-glow-color))}}', de = ':host{--braccato-text-color: color(display-p3 1 1 1 / 1);--braccato-glow-color: color(display-p3 1 1 1 / .5);--braccato-active-color: var(--braccato-text-color);--braccato-inactive-color: color( from var(--braccato-text-color) display-p3 r g b / var(--braccato-inactive-opacity, .3) );--braccato-active-opacity: 1;--braccato-inactive-opacity: .3;--braccato-richsync-timing-offset: .15s;--braccato-timing-offset: .115s;--braccato-scroll-timing-offset: .5s;--braccato-font-family: "Satoshi", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--braccato-font-size: 3rem;--braccato-font-weight: 600;--braccato-line-height: 1.333;--braccato-translated-font-size: 2rem;--braccato-translated-font-weight: 600;--braccato-translated-font-family: var(--braccato-font-family);--braccato-translated-color: color(display-p3 1 1 1 / var(--braccato-translated-opacity, .6));--braccato-scale-transition-duration: .166s;--braccato-highlight-fade-in-duration: .33s;--braccato-highlight-fade-out-duration: .5s;--braccato-wobble-duration: 1s;--braccato-padding: 1.25rem;--braccato-padding-bottom: 50cqh;--braccato-scale: .95;--braccato-active-scale: 1;--braccato-scroll-duration: .75s;--braccato-scroll-timing-function: cubic-bezier(.86, 0, .07, 1)}';
|
|
687
|
-
var
|
|
687
|
+
const de = ':host{display:block;overflow-y:auto;position:relative;container-type:size;scrollbar-width:none}:host::-webkit-scrollbar{display:none}:host(:has(.braccato--user-scrolling)){scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar{display:block;width:6px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-thumb{background:#ffffff26;border-radius:3px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-track{background:transparent}.braccato-container{font-family:var(--braccato-font-family);font-size:var(--braccato-font-size);font-weight:var(--braccato-font-weight);isolation:isolate;line-height:var(--braccato-line-height);position:relative;z-index:1;transition:transform var(--braccato-scroll-duration) var(--braccato-scroll-timing-function) 0s;padding-top:2rem;padding-bottom:var(--braccato-padding-bottom)}.braccato-container>div{cursor:pointer;padding:var(--braccato-padding) 0;transform-origin:left center;word-break:break-word;transition:filter calc(var(--braccato-duration) / 3) .4s,opacity calc(var(--braccato-duration) / 2) .166s,transform .166s var(--braccato-anim-delay, 0s)}.braccato-container:has(.braccato--active):not(.braccato--user-scrolling)>div:not(.braccato--active):not(.braccato--active~div){opacity:.33;filter:blur(2.5px)}.braccato-container>div.braccato--active{opacity:1;filter:blur(0px)}.braccato-container>div.braccato--active~div{opacity:.66;filter:blur(0px)}.braccato-container>.braccato--animating{opacity:1!important;filter:blur(0px)!important}.braccato-container>div:hover{opacity:1!important;filter:blur(0px)!important;transform:scale(var(--braccato-hover-scale, 1.01));transition:all .3s ease}.braccato--active{cursor:default}:not(.braccato-background-lyric){order:0}.braccato-background-lyric{order:2}.braccato--line>span>span.braccato-background-lyric{font-size:.675em;font-weight:400}.braccato--line{transform:scale(var(--braccato-scale));transition-property:transform;transition-duration:var(--braccato-scale-transition-duration);transition-timing-function:ease;display:flex;flex-flow:row wrap;align-items:start;align-content:flex-start;padding-left:.25em;padding-right:.25em;box-sizing:border-box}.braccato--line.braccato--animating{transform:scale(var(--braccato-active-scale));transition-delay:var(--braccato-anim-delay)}.braccato--line>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--word{white-space:pre;display:inline-block;transform:translateY(0);position:relative}.braccato--line.braccato--pre-animating,.braccato--line.braccato--pre-animating .braccato--word{will-change:transform}.braccato--break{flex-basis:100%;height:0}.braccato--word.braccato--animating{animation:braccato-wobble var(--braccato-wobble-duration) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running}.braccato--word.braccato--animating.braccato--paused{animation-play-state:paused}.braccato--word:after{position:absolute;content:attr(data-content);top:-2rem;left:-2rem;white-space:pre-wrap;padding:2rem;pointer-events:none;color:transparent;box-sizing:content-box;width:100%;background-image:linear-gradient(90deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px));opacity:0;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;--braccato-glow-color: color(display-p3 1 1 1 / .0001);transition:--lyric-transition-amount-start 1s linear 1000s,--lyric-transition-amount-end 1s linear 1000s,opacity .5s ease;-webkit-background-clip:text;background-clip:text}.braccato--word[data-long-word]:after{--braccato-glow-color: color(display-p3 1 1 1 / 1)}.braccato--word.braccato--pre-animating:not(.braccato--animating):after{transition:none;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;opacity:0}.braccato--word.braccato--pre-animating:not(.braccato--animating):not(.braccato-zero-dur-animate):after{opacity:1}.braccato--word.braccato--animating:after{opacity:1;animation:braccato-glow max(calc(var(--braccato-duration) * 1.2),1.2s) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running;--lyric-transition-amount-start: 1.4;--lyric-transition-amount-end: 1.5;transition-property:--lyric-transition-amount-start,--lyric-transition-amount-end,opacity;transition-duration:calc(var(--braccato-duration) * 1.6),calc(var(--braccato-duration) * 1.6),var(--braccato-highlight-fade-in-duration);transition-timing-function:linear,linear,ease;transition-delay:var(--braccato-swipe-delay),var(--braccato-swipe-delay),var(--braccato-anim-delay)}.braccato--word.braccato--animating.braccato--paused:after{transition-duration:100000000s,100000000s,100000000s;--lyric-transition-amount-start: 10;--lyric-transition-amount-end: 10;opacity:.5;animation-play-state:paused}.braccato--translated,.braccato--romanized{display:block;font-size:var(--braccato-translated-font-size);font-weight:var(--braccato-translated-font-weight);font-family:var(--braccato-translated-font-family);color:var(--braccato-translated-color);white-space:normal;line-height:1.1;margin-top:8px}.braccato--romanized>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--romanized{width:fit-content;font-size:calc(var(--braccato-translated-font-size) / 1.25);background:#ffffff0d;padding:.375rem .75rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem}.braccato-rtl{direction:rtl}.braccato-rtl.braccato--word:after{background-image:linear-gradient(270deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px))}.braccato--line[data-agent=v2],.braccato--line[data-agent=v3]{justify-content:flex-end;text-align:right;transform-origin:right center!important}.braccato--line[data-agent=v1000]{justify-content:center;text-align:center;transform-origin:center center!important}.braccato--instrumental-icon{height:var(--braccato-font-size);width:calc(var(--braccato-font-size) + var(--braccato-font-size) / 3);overflow:visible;margin-left:calc(var(--braccato-font-size) / -3)}.braccato-rtl.braccato--instrumental .braccato--instrumental-icon,.braccato--instrumental[data-agent=v2] .braccato--instrumental-icon,.braccato--instrumental[data-agent=v3] .braccato--instrumental-icon{margin-left:0;margin-right:calc(var(--braccato-font-size) / -3)}.braccato--instrumental[data-agent=v1000] .braccato--instrumental-icon{margin-left:0;margin-right:0}.braccato--instrumental-bg{fill:var(--braccato-inactive-color)}.braccato--instrumental-fill{fill:var(--braccato-active-color);transition:opacity var(--braccato-highlight-fade-out-duration, .5s) ease;opacity:0}.braccato--instrumental.braccato--animating .braccato--instrumental-fill{transition:none;opacity:1}.braccato--instrumental:not(.braccato--pre-animating) .braccato--wave-clip{transition-property:transform;transition-duration:1000000s;transition-delay:0s;transform:translateY(0)}.braccato--instrumental.braccato--pre-animating:not(.braccato--animating) .braccato--wave-clip{animation:none;transform:translateY(78%)}.braccato--instrumental.braccato--animating .braccato--wave-clip{transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:linear;transition-delay:var(--braccato-anim-delay);transform:translateY(-4%)}.braccato--paused .braccato--wave-clip{transition-duration:100000000s!important;transform:translateY(100%)!important}.braccato--wave-path{transform-box:fill-box;transform-origin:bottom;animation:braccato-wave 1.25s ease-in-out infinite;animation-play-state:paused;transform:scaleY(1.2)}.braccato--instrumental.braccato--animating:not(.braccato--paused) .braccato--wave-path{animation-play-state:running;transform:scaleY(0);transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:ease-in;transition-delay:var(--braccato-anim-delay)}.braccato--instrumental.braccato--animating.braccato--paused .braccato--wave-path{transform:scaleY(.0001);transition-duration:10000000000s;transition-property:transform;transition-timing-function:ease-out;transition-delay:0s}@keyframes braccato-wave{0%,to{d:path("M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z")}50%{d:path("M -4 3 Q 1 4 5 3 Q 10 2 14 3 Q 18 4 22 3 Q 26 2 30 3 L 30 4 L -4 4 Z")}}.braccato--spacer{padding:0;margin:0}.braccato-autoscroll-btn{font-family:var(--braccato-font-family);position:absolute;display:block;font-size:1.75rem;font-weight:600;white-space:normal;line-height:1.1;width:fit-content;background:#ffffff0d;padding:.5rem 1rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem;color:#fff;left:50%;transform:translate(-50%,2em);-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;z-index:100;transition:opacity .15s linear .05s,transform .2s cubic-bezier(.5,1,.89,1)}.braccato-autoscroll-btn[hidden]{transition:opacity .1s linear,transform .15s ease-in;opacity:0;pointer-events:none;transform:translate(-50%,-3em)}@keyframes braccato-wobble{0%{transform:translateY(0)}to{transform:translateY(-.0375em)}}@keyframes braccato-glow{0%{filter:drop-shadow(0 0 .8rem var(--braccato-glow-color))}to{filter:drop-shadow(0 0 0rem var(--braccato-glow-color))}}', ue = ':host{--braccato-text-color: color(display-p3 1 1 1 / 1);--braccato-glow-color: color(display-p3 1 1 1 / .5);--braccato-active-color: var(--braccato-text-color);--braccato-inactive-color: color( from var(--braccato-text-color) display-p3 r g b / var(--braccato-inactive-opacity, .3) );--braccato-active-opacity: 1;--braccato-inactive-opacity: .3;--braccato-richsync-timing-offset: .15s;--braccato-timing-offset: .115s;--braccato-scroll-timing-offset: .5s;--braccato-font-family: "Satoshi", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--braccato-font-size: 3rem;--braccato-font-weight: 600;--braccato-line-height: 1.333;--braccato-translated-font-size: 2rem;--braccato-translated-font-weight: 600;--braccato-translated-font-family: var(--braccato-font-family);--braccato-translated-color: color(display-p3 1 1 1 / var(--braccato-translated-opacity, .6));--braccato-scale-transition-duration: .166s;--braccato-highlight-fade-in-duration: .33s;--braccato-highlight-fade-out-duration: .5s;--braccato-wobble-duration: 1s;--braccato-padding: 1.25rem;--braccato-padding-bottom: 50cqh;--braccato-scale: .95;--braccato-active-scale: 1;--braccato-scroll-duration: .75s;--braccato-scroll-timing-function: cubic-bezier(.86, 0, .07, 1)}';
|
|
688
|
+
var me = Object.defineProperty, R = (t, e, a, r) => {
|
|
688
689
|
for (var n = void 0, o = t.length - 1, i; o >= 0; o--)
|
|
689
|
-
(i = t[o]) && (n = i(e,
|
|
690
|
-
return n &&
|
|
690
|
+
(i = t[o]) && (n = i(e, a, n) || n);
|
|
691
|
+
return n && me(e, a, n), n;
|
|
691
692
|
};
|
|
692
|
-
function
|
|
693
|
+
function fe() {
|
|
693
694
|
if (!(typeof CSS > "u" || !CSS.registerProperty))
|
|
694
695
|
try {
|
|
695
696
|
CSS.registerProperty({
|
|
@@ -706,7 +707,7 @@ function me() {
|
|
|
706
707
|
} catch {
|
|
707
708
|
}
|
|
708
709
|
}
|
|
709
|
-
|
|
710
|
+
fe();
|
|
710
711
|
const K = class K extends lt {
|
|
711
712
|
constructor() {
|
|
712
713
|
super(...arguments), this.lyrics = [], this.currentTime = 0, this.playing = !1, this.scrollMode = "internal", this.scrollContainer = null, this.dir = "auto", this.longWordThreshold = 1500, this.lineSyncedDelay = 50, this.disableRichsync = !1, this.debug = !1, this.source = null, this.src = null, this._lyricsData = null, this._animState = Rt(), this._rafId = null, this._lastLyrics = [], this._resizeObserver = null, this._mediaElement = null, this._lastSrc = null, this._srcAbortController = null, this._tickCount = 0, this._onScroll = () => {
|
|
@@ -715,7 +716,7 @@ const K = class K extends lt {
|
|
|
715
716
|
e.skipScrolls--;
|
|
716
717
|
return;
|
|
717
718
|
}
|
|
718
|
-
At(e) ?
|
|
719
|
+
At(e) ? at(e) : (at(e), this.dispatchEvent(
|
|
719
720
|
new CustomEvent("braccato:scroll-state", {
|
|
720
721
|
detail: { userScrolling: !0 },
|
|
721
722
|
bubbles: !0,
|
|
@@ -753,12 +754,12 @@ const K = class K extends lt {
|
|
|
753
754
|
this._log("_injectLyrics: no lyrics, clearing"), e.replaceChildren(), this._lyricsData = null;
|
|
754
755
|
return;
|
|
755
756
|
}
|
|
756
|
-
const
|
|
757
|
+
const a = {
|
|
757
758
|
longWordThreshold: this.longWordThreshold,
|
|
758
759
|
lineSyncedAnimationDelay: this.lineSyncedDelay,
|
|
759
760
|
disableRichsync: this.disableRichsync
|
|
760
761
|
};
|
|
761
|
-
this._lyricsData =
|
|
762
|
+
this._lyricsData = le(this.lyrics, e, a), this._log("_injectLyrics: rendered", {
|
|
762
763
|
lineCount: this._lyricsData.lines.length,
|
|
763
764
|
syncType: this._lyricsData.syncType,
|
|
764
765
|
firstLineTime: (o = this._lyricsData.lines[0]) == null ? void 0 : o.time,
|
|
@@ -767,8 +768,8 @@ const K = class K extends lt {
|
|
|
767
768
|
});
|
|
768
769
|
for (let c = 0; c < this._lyricsData.lines.length; c++)
|
|
769
770
|
this._lyricsData.lines[c].element.addEventListener("click", (d) => this._handleLineClick(d, c));
|
|
770
|
-
const
|
|
771
|
-
this._log("_injectLyrics: scrollContainer",
|
|
771
|
+
const r = this._getScrollContainer();
|
|
772
|
+
this._log("_injectLyrics: scrollContainer", r.tagName, r.className), r.addEventListener("scroll", this._onScroll, { passive: !0 }), (s = this._resizeObserver) == null || s.disconnect(), this._resizeObserver = new ResizeObserver(() => this._recalculatePositions()), this._resizeObserver.observe(e), this._recalculatePositions(), this.dispatchEvent(
|
|
772
773
|
new CustomEvent("braccato:lyrics-loaded", {
|
|
773
774
|
detail: { syncType: this._lyricsData.syncType, lineCount: this._lyricsData.lines.length },
|
|
774
775
|
bubbles: !0,
|
|
@@ -781,9 +782,9 @@ const K = class K extends lt {
|
|
|
781
782
|
if (!this._lyricsData) return;
|
|
782
783
|
const e = this._lyricsData.container;
|
|
783
784
|
this._lyricsData.width = e.clientWidth, this._lyricsData.height = e.clientHeight;
|
|
784
|
-
for (const
|
|
785
|
-
const
|
|
786
|
-
|
|
785
|
+
for (const a of this._lyricsData.lines) {
|
|
786
|
+
const r = a.element.getBoundingClientRect(), n = e.getBoundingClientRect();
|
|
787
|
+
a.position = r.top - n.top + e.scrollTop, a.height = r.height;
|
|
787
788
|
}
|
|
788
789
|
this._animState.scroll.wasUserScrolling = !0;
|
|
789
790
|
}
|
|
@@ -813,11 +814,11 @@ const K = class K extends lt {
|
|
|
813
814
|
isUserScrolling: this._animState.scroll.wasUserScrolling
|
|
814
815
|
});
|
|
815
816
|
}
|
|
816
|
-
const e = this._mediaElement,
|
|
817
|
+
const e = this._mediaElement, a = e ? e.currentTime * 1e3 : this.currentTime, r = e ? !e.paused : this.playing;
|
|
817
818
|
zt(this._animState, {
|
|
818
|
-
currentTime:
|
|
819
|
+
currentTime: a / 1e3,
|
|
819
820
|
eventCreationTime: Date.now(),
|
|
820
|
-
isPlaying:
|
|
821
|
+
isPlaying: r,
|
|
821
822
|
smoothScroll: !0,
|
|
822
823
|
lyricsData: this._lyricsData,
|
|
823
824
|
scrollContainer: this._getScrollContainer()
|
|
@@ -828,18 +829,18 @@ const K = class K extends lt {
|
|
|
828
829
|
return this.scrollMode === "external" && this.scrollContainer ? this.scrollContainer : this;
|
|
829
830
|
}
|
|
830
831
|
// -- Events --------------------------
|
|
831
|
-
_handleLineClick(e,
|
|
832
|
+
_handleLineClick(e, a) {
|
|
832
833
|
var o, i;
|
|
833
|
-
const
|
|
834
|
-
if (!
|
|
835
|
-
const n =
|
|
836
|
-
if (this._log("lineClick", { lineIndex:
|
|
834
|
+
const r = (o = this._lyricsData) == null ? void 0 : o.lines[a];
|
|
835
|
+
if (!r) return;
|
|
836
|
+
const n = r.time * 1e3;
|
|
837
|
+
if (this._log("lineClick", { lineIndex: a, time: n, lineTimeSec: r.time, currentTime: this.currentTime }), e.altKey && ((i = this._lyricsData) == null ? void 0 : i.syncType) === "richsync") {
|
|
837
838
|
const s = e.target.closest(".braccato--word");
|
|
838
839
|
if (s) {
|
|
839
|
-
const c = Number.parseFloat(s.dataset.time || "0") * 1e3, f =
|
|
840
|
+
const c = Number.parseFloat(s.dataset.time || "0") * 1e3, f = r.parts.findIndex((d) => d.element === s);
|
|
840
841
|
this.dispatchEvent(
|
|
841
842
|
new CustomEvent("braccato:word-click", {
|
|
842
|
-
detail: { time: c, lineIndex:
|
|
843
|
+
detail: { time: c, lineIndex: a, wordIndex: f },
|
|
843
844
|
bubbles: !0,
|
|
844
845
|
composed: !0
|
|
845
846
|
})
|
|
@@ -849,11 +850,11 @@ const K = class K extends lt {
|
|
|
849
850
|
}
|
|
850
851
|
this._mediaElement && (this._mediaElement.currentTime = n / 1e3, this._mediaElement.paused && this._mediaElement.play()), this.dispatchEvent(
|
|
851
852
|
new CustomEvent("braccato:line-click", {
|
|
852
|
-
detail: { time: n, lineIndex:
|
|
853
|
+
detail: { time: n, lineIndex: a },
|
|
853
854
|
bubbles: !0,
|
|
854
855
|
composed: !0
|
|
855
856
|
})
|
|
856
|
-
),
|
|
857
|
+
), rt(this._animState.scroll);
|
|
857
858
|
}
|
|
858
859
|
// -- Source Binding --------------------------
|
|
859
860
|
_resolveMediaElement() {
|
|
@@ -865,26 +866,26 @@ const K = class K extends lt {
|
|
|
865
866
|
e instanceof HTMLMediaElement ? this._mediaElement = e : (this._mediaElement = null, this._log("source: no media element found for selector", this.source));
|
|
866
867
|
}
|
|
867
868
|
async _fetchLyricsFromSrc() {
|
|
868
|
-
var
|
|
869
|
-
if ((
|
|
869
|
+
var a;
|
|
870
|
+
if ((a = this._srcAbortController) == null || a.abort(), !this.src) {
|
|
870
871
|
this.lyrics = [];
|
|
871
872
|
return;
|
|
872
873
|
}
|
|
873
874
|
const e = new AbortController();
|
|
874
875
|
this._srcAbortController = e;
|
|
875
876
|
try {
|
|
876
|
-
const
|
|
877
|
-
if (!
|
|
878
|
-
this._emitError(new Error(`Failed to fetch lyrics: ${
|
|
877
|
+
const r = await fetch(this.src, { signal: e.signal });
|
|
878
|
+
if (!r.ok) {
|
|
879
|
+
this._emitError(new Error(`Failed to fetch lyrics: ${r.status} ${r.statusText}`));
|
|
879
880
|
return;
|
|
880
881
|
}
|
|
881
|
-
const n = await
|
|
882
|
+
const n = await r.text();
|
|
882
883
|
if (e.signal.aborted) return;
|
|
883
884
|
const o = this._mediaElement ? this._mediaElement.duration * 1e3 : 3e5, i = wt(n);
|
|
884
885
|
this.lyrics = i.parse(n, o);
|
|
885
|
-
} catch (
|
|
886
|
-
if (
|
|
887
|
-
this._emitError(
|
|
886
|
+
} catch (r) {
|
|
887
|
+
if (r instanceof DOMException && r.name === "AbortError") return;
|
|
888
|
+
this._emitError(r instanceof Error ? r : new Error(String(r)));
|
|
888
889
|
}
|
|
889
890
|
}
|
|
890
891
|
_emitError(e) {
|
|
@@ -898,13 +899,13 @@ const K = class K extends lt {
|
|
|
898
899
|
}
|
|
899
900
|
// -- Public Methods --------------------------
|
|
900
901
|
resumeAutoscroll() {
|
|
901
|
-
|
|
902
|
+
rt(this._animState.scroll);
|
|
902
903
|
}
|
|
903
904
|
recalculatePositions() {
|
|
904
905
|
this._recalculatePositions();
|
|
905
906
|
}
|
|
906
907
|
};
|
|
907
|
-
K.styles = [X(
|
|
908
|
+
K.styles = [X(ue), X(de)];
|
|
908
909
|
let E = K;
|
|
909
910
|
R([
|
|
910
911
|
D({ type: Array })
|