@braccato/core 0.1.5 → 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 +368 -336
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement as lt, unsafeCSS as X, html as dt } from "lit";
|
|
2
|
-
import { property as
|
|
3
|
-
function
|
|
2
|
+
import { property as D } from "lit/decorators.js";
|
|
3
|
+
function B(t) {
|
|
4
4
|
if (!t) return 0;
|
|
5
5
|
if (typeof t == "number") return t;
|
|
6
6
|
const e = t.match(/^([\d.]+)(h|m|s|ms)$/);
|
|
@@ -19,65 +19,65 @@ function q(t) {
|
|
|
19
19
|
return 0;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function I(t, e) {
|
|
23
23
|
const a = t.getAttribute(e);
|
|
24
24
|
if (a !== null) return a;
|
|
25
25
|
for (const r of t.attributes)
|
|
26
26
|
if (r.localName === e) return r.value;
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function Y(t) {
|
|
30
30
|
const e = {
|
|
31
31
|
text: "",
|
|
32
|
-
begin:
|
|
33
|
-
end:
|
|
34
|
-
role:
|
|
32
|
+
begin: I(t, "begin") ? B(I(t, "begin")) : void 0,
|
|
33
|
+
end: I(t, "end") ? B(I(t, "end")) : void 0,
|
|
34
|
+
role: I(t, "role") ?? void 0,
|
|
35
35
|
children: []
|
|
36
36
|
};
|
|
37
37
|
for (const a of t.childNodes)
|
|
38
38
|
if (a.nodeType === 3) {
|
|
39
39
|
const r = a.textContent ?? "";
|
|
40
40
|
e.text += r, e.children.push({ text: r, children: [] });
|
|
41
|
-
} else a.nodeType === 1 && e.children.push(
|
|
41
|
+
} else a.nodeType === 1 && e.children.push(Y(a));
|
|
42
42
|
return e;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function $(t, e, a = !1) {
|
|
45
45
|
let r = "";
|
|
46
46
|
const n = [];
|
|
47
47
|
let o = !1;
|
|
48
|
-
for (const
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
if (
|
|
52
|
-
const c =
|
|
48
|
+
for (const i of t) {
|
|
49
|
+
const s = a || i.role === "x-bg";
|
|
50
|
+
if (i.children.length > 0)
|
|
51
|
+
if (s && !a) {
|
|
52
|
+
const c = $(i.children, e, !0);
|
|
53
53
|
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
54
|
-
} else if (
|
|
55
|
-
const c =
|
|
54
|
+
} else if (i.begin !== void 0 && i.end !== void 0) {
|
|
55
|
+
const c = i.children.map((f) => f.text).join("") || i.text;
|
|
56
56
|
n.push({
|
|
57
|
-
startTimeMs:
|
|
58
|
-
durationMs:
|
|
57
|
+
startTimeMs: i.begin,
|
|
58
|
+
durationMs: i.end - i.begin,
|
|
59
59
|
words: c,
|
|
60
|
-
isBackground:
|
|
60
|
+
isBackground: s || void 0
|
|
61
61
|
}), r += c, o = !0;
|
|
62
62
|
} else {
|
|
63
|
-
const c =
|
|
63
|
+
const c = $(i.children, e, s);
|
|
64
64
|
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
65
65
|
}
|
|
66
|
-
else if (
|
|
67
|
-
if (r +=
|
|
66
|
+
else if (i.text)
|
|
67
|
+
if (r += i.text, i.begin !== void 0 && i.end !== void 0)
|
|
68
68
|
n.push({
|
|
69
|
-
startTimeMs:
|
|
70
|
-
durationMs:
|
|
71
|
-
words:
|
|
72
|
-
isBackground:
|
|
69
|
+
startTimeMs: i.begin,
|
|
70
|
+
durationMs: i.end - i.begin,
|
|
71
|
+
words: i.text,
|
|
72
|
+
isBackground: s || void 0
|
|
73
73
|
}), o = !0;
|
|
74
74
|
else {
|
|
75
75
|
const c = n[n.length - 1];
|
|
76
76
|
n.push({
|
|
77
77
|
startTimeMs: c ? c.startTimeMs + c.durationMs : e,
|
|
78
78
|
durationMs: 0,
|
|
79
|
-
words:
|
|
80
|
-
isBackground:
|
|
79
|
+
words: i.text,
|
|
80
|
+
isBackground: s || void 0
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -85,85 +85,82 @@ function Y(t, e, a = !1) {
|
|
|
85
85
|
}
|
|
86
86
|
function ut(t, e, a) {
|
|
87
87
|
if (t.length === 0) return t;
|
|
88
|
-
const r = [], n = (
|
|
89
|
-
startTimeMs:
|
|
88
|
+
const r = [], n = (s, c) => ({
|
|
89
|
+
startTimeMs: s,
|
|
90
90
|
durationMs: c,
|
|
91
91
|
words: "",
|
|
92
92
|
parts: [],
|
|
93
93
|
isInstrumental: !0
|
|
94
94
|
});
|
|
95
95
|
t[0].startTimeMs > a && r.push(n(0, t[0].startTimeMs));
|
|
96
|
-
for (let
|
|
97
|
-
if (r.push(t[
|
|
98
|
-
const c = t[
|
|
99
|
-
|
|
96
|
+
for (let s = 0; s < t.length; s++)
|
|
97
|
+
if (r.push(t[s]), s < t.length - 1) {
|
|
98
|
+
const c = t[s].startTimeMs + t[s].durationMs, f = t[s + 1].startTimeMs - c;
|
|
99
|
+
f > a && r.push(n(c, f));
|
|
100
100
|
}
|
|
101
|
-
const o = t[t.length - 1],
|
|
102
|
-
return e -
|
|
101
|
+
const o = t[t.length - 1], i = o.startTimeMs + o.durationMs;
|
|
102
|
+
return e - i > a && r.push(n(i, e - i)), r;
|
|
103
103
|
}
|
|
104
104
|
function mt(t, e = {}) {
|
|
105
|
-
const a = t.replace(/\\"/g, '"'), r = new DOMParser().parseFromString(a, "text/xml"), n = r.querySelector("tt"), o = (n ?
|
|
106
|
-
if (!
|
|
107
|
-
const
|
|
108
|
-
let
|
|
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
|
+
if (!i) return { lyrics: [], isWordSynced: !1, language: o };
|
|
107
|
+
const s = i.getAttribute("dur"), c = s ? B(s) : 0, f = i.querySelectorAll("p"), d = /* @__PURE__ */ new Map();
|
|
108
|
+
let l = !1;
|
|
109
109
|
const m = /* @__PURE__ */ new Map(), p = [
|
|
110
110
|
...r.querySelectorAll("agent"),
|
|
111
111
|
...r.getElementsByTagNameNS("http://www.w3.org/ns/ttml#metadata", "agent")
|
|
112
112
|
];
|
|
113
|
-
let
|
|
114
|
-
for (const
|
|
115
|
-
const h =
|
|
116
|
-
h && (m.has(h) || (
|
|
117
|
-
}
|
|
118
|
-
for (const
|
|
119
|
-
const h =
|
|
120
|
-
(g) => g.nodeType === 1 ?
|
|
121
|
-
),
|
|
122
|
-
|
|
123
|
-
agent:
|
|
124
|
-
durationMs:
|
|
125
|
-
parts:
|
|
113
|
+
let w = 0;
|
|
114
|
+
for (const _ of p) {
|
|
115
|
+
const h = I(_, "id"), M = I(_, "type");
|
|
116
|
+
h && (m.has(h) || (M === "person" || M === "character" ? (w++, m.set(h, `v${w}`)) : m.set(h, "v1000")));
|
|
117
|
+
}
|
|
118
|
+
for (const _ of f) {
|
|
119
|
+
const h = B(I(_, "begin") ?? void 0), M = B(I(_, "end") ?? void 0), L = I(_, "key") ?? String(d.size), k = I(_, "agent") ?? void 0, S = k ? m.get(k) ?? k : void 0, y = Array.from(_.childNodes).filter((g) => g.nodeType === 1 || g.nodeType === 3).map(
|
|
120
|
+
(g) => g.nodeType === 1 ? Y(g) : { text: g.textContent ?? "", children: [] }
|
|
121
|
+
), u = $(y, h);
|
|
122
|
+
u.isWordSynced && (l = !0), d.set(L, {
|
|
123
|
+
agent: S,
|
|
124
|
+
durationMs: M - h,
|
|
125
|
+
parts: u.parts,
|
|
126
126
|
startTimeMs: h,
|
|
127
|
-
words:
|
|
127
|
+
words: u.text,
|
|
128
128
|
key: L
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
const b = r.querySelectorAll("translations");
|
|
132
|
-
for (const
|
|
133
|
-
const h =
|
|
132
|
+
for (const _ of b) {
|
|
133
|
+
const h = _.getAttribute("lang");
|
|
134
134
|
if (!h) continue;
|
|
135
|
-
const
|
|
136
|
-
for (const L of
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
|
|
135
|
+
const M = _.querySelectorAll("translation");
|
|
136
|
+
for (const L of M) {
|
|
137
|
+
const k = L.getAttribute("for"), S = L.querySelector("text"), y = S == null ? void 0 : S.textContent;
|
|
138
|
+
if (k && y) {
|
|
139
|
+
const u = d.get(k);
|
|
140
|
+
u && (u.translation = { text: y, lang: h });
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
const v = r.querySelectorAll("transliterations");
|
|
145
|
-
for (const
|
|
146
|
-
const h =
|
|
147
|
-
for (const
|
|
148
|
-
const L =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
), C = Y(P, x.startTimeMs);
|
|
159
|
-
S += C.text, d.push(...C.parts);
|
|
145
|
+
for (const _ of v) {
|
|
146
|
+
const h = _.querySelectorAll("transliteration");
|
|
147
|
+
for (const M of h) {
|
|
148
|
+
const L = M.querySelectorAll("text");
|
|
149
|
+
for (const k of L) {
|
|
150
|
+
const S = k.getAttribute("for");
|
|
151
|
+
if (!S) continue;
|
|
152
|
+
const y = d.get(S);
|
|
153
|
+
if (!y) continue;
|
|
154
|
+
const u = Array.from(k.childNodes).filter((A) => A.nodeType === 1 || A.nodeType === 3).map(
|
|
155
|
+
(A) => A.nodeType === 1 ? Y(A) : { text: A.textContent ?? "", children: [] }
|
|
156
|
+
), g = $(u, y.startTimeMs);
|
|
157
|
+
y.romanization = g.text, g.parts.length > 0 && (y.timedRomanization = g.parts);
|
|
160
158
|
}
|
|
161
|
-
x.romanization = S, d.length > 0 && (x.timedRomanization = d);
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
let
|
|
165
|
-
const
|
|
166
|
-
return c > 0 && (
|
|
161
|
+
let P = Array.from(d.values());
|
|
162
|
+
const T = e.instrumentalGapMs ?? 5e3;
|
|
163
|
+
return c > 0 && (P = ut(P, c, T)), { lyrics: P, isWordSynced: l, language: o };
|
|
167
164
|
}
|
|
168
165
|
const ft = {
|
|
169
166
|
detect(t) {
|
|
@@ -197,57 +194,57 @@ function ht(t, e) {
|
|
|
197
194
|
var a;
|
|
198
195
|
const r = t.split(`
|
|
199
196
|
`), n = [], o = {};
|
|
200
|
-
for (const
|
|
201
|
-
const
|
|
197
|
+
for (const i of r) {
|
|
198
|
+
const s = i.trim(), c = s.match(/^\[(\w+):(.*)\]$/);
|
|
202
199
|
if (c && pt.includes(c[1])) {
|
|
203
200
|
o[c[1]] = c[2];
|
|
204
201
|
continue;
|
|
205
202
|
}
|
|
206
|
-
const
|
|
207
|
-
for (const
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
const m =
|
|
211
|
-
let
|
|
212
|
-
m.split(
|
|
213
|
-
if (
|
|
214
|
-
let h =
|
|
203
|
+
const f = /\[(\d+:\d+\.\d+)\]/g, d = /<(\d+:\d+\.\d+)>/g, l = [];
|
|
204
|
+
for (const T of s.matchAll(f))
|
|
205
|
+
l.push(tt(T[1]));
|
|
206
|
+
if (l.length === 0) continue;
|
|
207
|
+
const m = s.replace(f, "").trim(), p = [];
|
|
208
|
+
let w = null, b = "";
|
|
209
|
+
m.split(d).forEach((T, _) => {
|
|
210
|
+
if (_ % 2 === 0) {
|
|
211
|
+
let h = T;
|
|
215
212
|
h.length > 0 && h[0] === " " && (h = h.substring(1)), h.length > 0 && h[h.length - 1] === " " && (h = h.substring(0, h.length - 1)), b += h, p.length > 0 && p[p.length - 1].startTimeMs && (p[p.length - 1].words += h);
|
|
216
213
|
} else {
|
|
217
|
-
const h = tt(
|
|
218
|
-
|
|
214
|
+
const h = tt(T);
|
|
215
|
+
w !== null && p.length > 0 && (p[p.length - 1].durationMs = h - w), p.push({ startTimeMs: h, words: "", durationMs: 0 }), w = h;
|
|
219
216
|
}
|
|
220
217
|
});
|
|
221
|
-
const v = Math.min(...
|
|
218
|
+
const v = Math.min(...l), P = Math.max(...l) - v;
|
|
222
219
|
n.push({
|
|
223
220
|
startTimeMs: v,
|
|
224
221
|
words: b.trim(),
|
|
225
|
-
durationMs:
|
|
222
|
+
durationMs: P,
|
|
226
223
|
parts: p.length > 0 ? p : void 0
|
|
227
224
|
});
|
|
228
225
|
}
|
|
229
|
-
for (let
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
const c = n[
|
|
233
|
-
if (
|
|
234
|
-
let
|
|
235
|
-
for (const
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
226
|
+
for (let i = 0; i < n.length; i++) {
|
|
227
|
+
const s = n[i];
|
|
228
|
+
if (i + 1 < n.length) {
|
|
229
|
+
const c = n[i + 1];
|
|
230
|
+
if (s.durationMs === 0 && (s.durationMs = Math.max(c.startTimeMs - s.startTimeMs, 0)), s.parts && s.parts.length > 0) {
|
|
231
|
+
let f = c.startTimeMs;
|
|
232
|
+
for (const l of s.parts)
|
|
233
|
+
f = Math.max(f, l.startTimeMs);
|
|
234
|
+
const d = s.parts[s.parts.length - 1];
|
|
235
|
+
d.durationMs = Math.max(c.startTimeMs - d.startTimeMs, 0), s.durationMs = Math.max(f - s.startTimeMs, 0);
|
|
239
236
|
}
|
|
240
|
-
} else if (
|
|
241
|
-
const c =
|
|
237
|
+
} else if (s.durationMs === 0 && (s.durationMs = e - s.startTimeMs), s.parts && s.parts.length > 0) {
|
|
238
|
+
const c = s.parts[s.parts.length - 1];
|
|
242
239
|
c.durationMs = e - c.startTimeMs;
|
|
243
240
|
}
|
|
244
241
|
}
|
|
245
242
|
if (o.offset) {
|
|
246
|
-
let
|
|
247
|
-
Number.isNaN(
|
|
248
|
-
for (const
|
|
249
|
-
|
|
250
|
-
c.startTimeMs -=
|
|
243
|
+
let i = Number(o.offset);
|
|
244
|
+
Number.isNaN(i) && (i = 0), i = i * 1e3;
|
|
245
|
+
for (const s of n)
|
|
246
|
+
s.startTimeMs -= i, (a = s.parts) == null || a.forEach((c) => {
|
|
247
|
+
c.startTimeMs -= i;
|
|
251
248
|
});
|
|
252
249
|
}
|
|
253
250
|
return n;
|
|
@@ -256,12 +253,12 @@ function bt(t) {
|
|
|
256
253
|
for (const r of t)
|
|
257
254
|
if (r.parts)
|
|
258
255
|
for (let n = 1; n < r.parts.length; n++) {
|
|
259
|
-
const o = r.parts[n],
|
|
260
|
-
if (o.words === " " &&
|
|
261
|
-
const
|
|
262
|
-
if (Math.abs(
|
|
256
|
+
const o = r.parts[n], i = r.parts[n - 1];
|
|
257
|
+
if (o.words === " " && i.words !== " ") {
|
|
258
|
+
const s = o.durationMs - i.durationMs;
|
|
259
|
+
if (Math.abs(s) <= 15 || o.durationMs <= 100) {
|
|
263
260
|
const c = o.durationMs;
|
|
264
|
-
|
|
261
|
+
i.durationMs += c, o.durationMs -= c, o.startTimeMs += c;
|
|
265
262
|
}
|
|
266
263
|
}
|
|
267
264
|
}
|
|
@@ -277,10 +274,10 @@ function bt(t) {
|
|
|
277
274
|
const n = t[r];
|
|
278
275
|
if (!(!n.parts || n.parts.length === 0))
|
|
279
276
|
for (let o = 0; o < n.parts.length; o++) {
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
let
|
|
283
|
-
o + 1 < n.parts.length ?
|
|
277
|
+
const i = n.parts[o];
|
|
278
|
+
if (i.words !== " " && i.durationMs <= 400) {
|
|
279
|
+
let s = null;
|
|
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;
|
|
284
281
|
}
|
|
285
282
|
}
|
|
286
283
|
}
|
|
@@ -309,14 +306,14 @@ const yt = {
|
|
|
309
306
|
for (const n of a) {
|
|
310
307
|
const o = n.split(/\r?\n/);
|
|
311
308
|
if (o.length < 2) continue;
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
const [
|
|
309
|
+
const i = o.find((p) => p.includes("-->"));
|
|
310
|
+
if (!i) continue;
|
|
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(`
|
|
315
312
|
`).replace(/<[^>]+>/g, "").trim();
|
|
316
313
|
m && r.push({
|
|
317
|
-
startTimeMs:
|
|
314
|
+
startTimeMs: f,
|
|
318
315
|
words: m,
|
|
319
|
-
durationMs:
|
|
316
|
+
durationMs: d - f
|
|
320
317
|
});
|
|
321
318
|
}
|
|
322
319
|
return r;
|
|
@@ -343,18 +340,18 @@ const yt = {
|
|
|
343
340
|
for (const n of a) {
|
|
344
341
|
const o = n.trim().match(/^\[(\d+),(\d+)\](.*)$/);
|
|
345
342
|
if (!o) continue;
|
|
346
|
-
const
|
|
347
|
-
let
|
|
348
|
-
const
|
|
349
|
-
for (const m of c.matchAll(
|
|
350
|
-
const p = m[1],
|
|
351
|
-
|
|
343
|
+
const i = Number.parseInt(o[1], 10), s = Number.parseInt(o[2], 10), c = o[3], f = [];
|
|
344
|
+
let d = "";
|
|
345
|
+
const l = /([^(]*)\((\d+),(\d+)\)/g;
|
|
346
|
+
for (const m of c.matchAll(l)) {
|
|
347
|
+
const p = m[1], w = Number.parseInt(m[2], 10), b = Number.parseInt(m[3], 10);
|
|
348
|
+
d += p, f.push({ startTimeMs: w, words: p, durationMs: b });
|
|
352
349
|
}
|
|
353
350
|
r.push({
|
|
354
|
-
startTimeMs:
|
|
355
|
-
words:
|
|
356
|
-
durationMs:
|
|
357
|
-
parts:
|
|
351
|
+
startTimeMs: i,
|
|
352
|
+
words: d,
|
|
353
|
+
durationMs: s,
|
|
354
|
+
parts: f.length > 0 ? f : void 0
|
|
358
355
|
});
|
|
359
356
|
}
|
|
360
357
|
return r;
|
|
@@ -390,19 +387,19 @@ function rt(t) {
|
|
|
390
387
|
function At(t) {
|
|
391
388
|
return t.scrollResumeTime > Date.now();
|
|
392
389
|
}
|
|
393
|
-
function
|
|
390
|
+
function Et(t, e) {
|
|
394
391
|
let a = 0;
|
|
395
392
|
for (; a < t.skipScrollsDecayTimes.length && !(t.skipScrollsDecayTimes[a] > e); a++)
|
|
396
393
|
;
|
|
397
394
|
t.skipScrollsDecayTimes = t.skipScrollsDecayTimes.slice(a), t.skipScrolls -= a, t.skipScrolls < 1 && (t.skipScrolls = 1);
|
|
398
395
|
}
|
|
399
|
-
const
|
|
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();
|
|
400
397
|
function Dt(t) {
|
|
401
398
|
return t ? t.endsWith("ms") ? Number.parseFloat(t.slice(0, -2)) : t.endsWith("s") ? Number.parseFloat(t.slice(0, -1)) * 1e3 : 0 : 0;
|
|
402
399
|
}
|
|
403
|
-
function
|
|
404
|
-
let a =
|
|
405
|
-
return a === void 0 && (a = Dt(getComputedStyle(t).getPropertyValue(e)),
|
|
400
|
+
function U(t, e) {
|
|
401
|
+
let a = Q.get(e);
|
|
402
|
+
return a === void 0 && (a = Dt(getComputedStyle(t).getPropertyValue(e)), Q.set(e, a)), a;
|
|
406
403
|
}
|
|
407
404
|
function it(t) {
|
|
408
405
|
t.offsetHeight;
|
|
@@ -418,194 +415,229 @@ function Rt() {
|
|
|
418
415
|
};
|
|
419
416
|
}
|
|
420
417
|
function Pt(t) {
|
|
421
|
-
Mt(t.scroll), t.lastActiveElements = [],
|
|
418
|
+
Mt(t.scroll), t.lastActiveElements = [], Q.clear();
|
|
422
419
|
}
|
|
423
420
|
function zt(t, e) {
|
|
424
421
|
const a = Date.now();
|
|
425
422
|
let { currentTime: r, isPlaying: n, smoothScroll: o } = e;
|
|
426
423
|
const {
|
|
427
|
-
eventCreationTime:
|
|
428
|
-
lyricsData:
|
|
424
|
+
eventCreationTime: i,
|
|
425
|
+
lyricsData: s,
|
|
429
426
|
scrollContainer: c,
|
|
430
|
-
scrollPosRatio:
|
|
431
|
-
endingThreshold:
|
|
432
|
-
earlyScrollConsider:
|
|
427
|
+
scrollPosRatio: f = kt,
|
|
428
|
+
endingThreshold: d = xt,
|
|
429
|
+
earlyScrollConsider: l = Nt,
|
|
433
430
|
queueScrollMs: m = It
|
|
434
431
|
} = e;
|
|
435
432
|
if (r === 0 && !n) return;
|
|
436
|
-
const p = Math.abs(r - t.lastTime - (
|
|
437
|
-
t.lastTime = r, t.lastPlayState = n, t.lastEventCreationTime =
|
|
438
|
-
const
|
|
439
|
-
r +=
|
|
440
|
-
const { lines: b, container: v, syncType:
|
|
441
|
-
|
|
442
|
-
const
|
|
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
|
+
const { lines: b, container: v, syncType: P } = s;
|
|
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;
|
|
443
440
|
let h = c.scrollTop;
|
|
444
|
-
const
|
|
445
|
-
let
|
|
446
|
-
for (let
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
if (r +
|
|
451
|
-
|
|
452
|
-
const O = r - g, z = (a -
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
const
|
|
441
|
+
const M = [], L = [];
|
|
442
|
+
let k = p;
|
|
443
|
+
for (let y = 0; y < b.length; y++) {
|
|
444
|
+
const u = b[y], g = u.time, A = y + 1 < b.length ? b[y + 1].time : Number.POSITIVE_INFINITY;
|
|
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
|
+
const x = n ? 2 : 0, N = Math.max(A, g + u.duration + 0.05);
|
|
447
|
+
if (r + x >= g && r < N) {
|
|
448
|
+
u.isSelected = !0;
|
|
449
|
+
const O = r - g, z = (a - u.animationStartTimeMs) / 1e3 - O;
|
|
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
|
+
u.isAnimationPlayStatePlaying = n;
|
|
452
|
+
const J = [u, ...u.parts];
|
|
456
453
|
if (n) {
|
|
457
|
-
for (const F of
|
|
458
|
-
F.element.classList.remove(
|
|
459
|
-
|
|
454
|
+
for (const F of J)
|
|
455
|
+
F.element.classList.remove(q);
|
|
456
|
+
u.isAnimating = !1;
|
|
460
457
|
} else
|
|
461
|
-
for (const F of
|
|
462
|
-
F.animationStartTimeMs > a ? (F.element.classList.remove(
|
|
458
|
+
for (const F of J)
|
|
459
|
+
F.animationStartTimeMs > a ? (F.element.classList.remove(W), F.element.classList.remove(H)) : F.element.classList.add(q);
|
|
463
460
|
}
|
|
464
|
-
|
|
465
|
-
} else if (
|
|
466
|
-
const O = [
|
|
461
|
+
u.isAnimating || L.push(u);
|
|
462
|
+
} else if (u.isSelected) {
|
|
463
|
+
const O = [u, ...u.parts];
|
|
467
464
|
for (const z of O)
|
|
468
|
-
z.element.style.setProperty("--braccato-swipe-delay", ""), z.element.style.setProperty("--braccato-anim-delay", ""), z.element.classList.remove(
|
|
469
|
-
|
|
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
|
+
u.isSelected = !1, u.isAnimating = !1;
|
|
470
467
|
}
|
|
471
468
|
}
|
|
472
469
|
if (L.length > 0) {
|
|
473
|
-
for (const
|
|
474
|
-
const
|
|
475
|
-
for (const g of
|
|
476
|
-
const
|
|
477
|
-
g.element.classList.remove(
|
|
470
|
+
for (const y of L) {
|
|
471
|
+
const u = [y, ...y.parts];
|
|
472
|
+
for (const g of u) {
|
|
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);
|
|
478
475
|
}
|
|
479
476
|
}
|
|
480
477
|
it(L[0].element);
|
|
481
|
-
for (const
|
|
482
|
-
const
|
|
483
|
-
for (const g of
|
|
484
|
-
const
|
|
485
|
-
g.element.classList.add(
|
|
478
|
+
for (const y of L) {
|
|
479
|
+
const u = [y, ...y.parts];
|
|
480
|
+
for (const g of u) {
|
|
481
|
+
const A = r - g.time;
|
|
482
|
+
g.element.classList.add(W), g.animationStartTimeMs = a - A * 1e3;
|
|
486
483
|
}
|
|
487
|
-
|
|
484
|
+
y.isAnimating = !0, y.lastAnimSetupAt = a, y.isAnimationPlayStatePlaying = !0, y.accumulatedOffsetMs = 0;
|
|
488
485
|
}
|
|
489
486
|
}
|
|
490
|
-
const
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
let
|
|
495
|
-
if (
|
|
496
|
-
if (a >
|
|
497
|
-
if (
|
|
487
|
+
const S = t.scroll;
|
|
488
|
+
if (S.scrollResumeTime < a || S.scrollPos === -1) {
|
|
489
|
+
M.length === 0 && M.push(b[0]), t.lastActiveElements = M.filter((N) => T >= N.time);
|
|
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
|
+
let x = g.reduce((N, O) => N + O, 0) / g.length - y;
|
|
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 (a > S.nextScrollAllowedTime) {
|
|
494
|
+
if (S.queuedScroll = !1, o && Math.abs(h - x) > 2) {
|
|
498
495
|
v.style.transitionTimingFunction = "", v.style.transitionProperty = "", v.style.transitionDuration = "";
|
|
499
|
-
const
|
|
500
|
-
v.style.transition = "none", v.style.transform = `translate(0px, ${-(h -
|
|
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 + a + 20;
|
|
501
498
|
}
|
|
502
|
-
h =
|
|
503
|
-
} else (
|
|
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);
|
|
504
501
|
}
|
|
505
|
-
|
|
502
|
+
S.wasUserScrolling && S.scrollResumeTime < a && (v.classList.remove(Ct), S.wasUserScrolling = !1), Et(S, a);
|
|
506
503
|
}
|
|
507
|
-
const
|
|
508
|
-
function
|
|
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 Ht(t, e) {
|
|
509
506
|
const a = document.createElement("div");
|
|
510
507
|
a.classList.add(Ot), a.style.setProperty("--braccato-duration", `${t}ms`);
|
|
511
|
-
const r = document.createElementNS(
|
|
508
|
+
const r = document.createElementNS(C, "svg");
|
|
512
509
|
r.classList.add(Ft), r.setAttribute("viewBox", "0 0 24 24");
|
|
513
|
-
const n = document.createElementNS(
|
|
514
|
-
|
|
515
|
-
const c = document.createElementNS(
|
|
516
|
-
c.setAttribute("in", "SourceGraphic"), c.setAttribute("stdDeviation", "5"), c.setAttribute("result", "blur"),
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const m = document.createElementNS(
|
|
522
|
-
m.setAttribute("in", "SourceGraphic"),
|
|
523
|
-
const p = document.createElementNS(
|
|
524
|
-
p.setAttribute("id",
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
const b = document.createElementNS(
|
|
510
|
+
const n = document.createElementNS(C, "defs"), o = `braccato-glow-${e}`, i = `braccato-wave-clip-${e}`, s = document.createElementNS(C, "filter");
|
|
511
|
+
s.setAttribute("id", o), s.setAttribute("x", "-100%"), s.setAttribute("y", "-100%"), s.setAttribute("width", "300%"), s.setAttribute("height", "300%");
|
|
512
|
+
const c = document.createElementNS(C, "feGaussianBlur");
|
|
513
|
+
c.setAttribute("in", "SourceGraphic"), c.setAttribute("stdDeviation", "5"), c.setAttribute("result", "blur"), s.appendChild(c);
|
|
514
|
+
const f = document.createElementNS(C, "feColorMatrix");
|
|
515
|
+
f.setAttribute("in", "blur"), f.setAttribute("type", "matrix"), f.setAttribute("values", "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.6 0"), f.setAttribute("result", "fadedBlur"), s.appendChild(f);
|
|
516
|
+
const d = document.createElementNS(C, "feMerge"), l = document.createElementNS(C, "feMergeNode");
|
|
517
|
+
l.setAttribute("in", "fadedBlur"), d.appendChild(l);
|
|
518
|
+
const m = document.createElementNS(C, "feMergeNode");
|
|
519
|
+
m.setAttribute("in", "SourceGraphic"), d.appendChild(m), s.appendChild(d), n.appendChild(s);
|
|
520
|
+
const p = document.createElementNS(C, "clipPath");
|
|
521
|
+
p.setAttribute("id", i), p.classList.add(qt);
|
|
522
|
+
const w = document.createElementNS(C, "path");
|
|
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
|
+
const b = document.createElementNS(C, "path");
|
|
528
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);
|
|
529
|
-
const v = document.createElementNS(
|
|
530
|
-
v.classList.add(
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
const
|
|
534
|
-
return
|
|
526
|
+
const v = document.createElementNS(C, "path");
|
|
527
|
+
v.classList.add(Bt), v.setAttribute("d", st), r.appendChild(v);
|
|
528
|
+
const P = document.createElementNS(C, "g");
|
|
529
|
+
P.setAttribute("filter", `url(#${o})`);
|
|
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), r.appendChild(P), a.appendChild(r), a;
|
|
535
532
|
}
|
|
536
533
|
const Gt = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}]/u;
|
|
537
|
-
function
|
|
534
|
+
function j(t) {
|
|
538
535
|
return Gt.test(t);
|
|
539
536
|
}
|
|
540
|
-
const
|
|
541
|
-
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
|
+
const e = t.replace(Qt, "");
|
|
540
|
+
return e.length <= jt ? !1 : !Yt.test(e);
|
|
541
|
+
}
|
|
542
|
+
function Kt(t) {
|
|
543
|
+
try {
|
|
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);
|
|
549
|
+
} catch {
|
|
550
|
+
return Array.from(t);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function Jt(t) {
|
|
554
|
+
if (!Zt(t.words))
|
|
555
|
+
return [{ ...t, isWrapAfter: !1 }];
|
|
556
|
+
const e = Kt(t.words);
|
|
557
|
+
if (e.length <= 1)
|
|
558
|
+
return [{ ...t, isWrapAfter: !1 }];
|
|
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,
|
|
564
|
+
isBackground: t.isBackground,
|
|
565
|
+
isWrapAfter: n < e.length - 1
|
|
566
|
+
}));
|
|
567
|
+
}
|
|
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;
|
|
569
|
+
function se(t, e) {
|
|
542
570
|
for (let a = e - 1; a >= 0; a--)
|
|
543
571
|
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
544
572
|
for (let a = e + 1; a < t.length; a++)
|
|
545
573
|
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
546
574
|
}
|
|
547
|
-
function
|
|
575
|
+
function oe(t, e) {
|
|
548
576
|
var a, r;
|
|
549
577
|
for (let n = e - 1; n >= 0; n--)
|
|
550
|
-
if (!t[n].isInstrumental && ((a = t[n].words) != null && a.trim())) return
|
|
578
|
+
if (!t[n].isInstrumental && ((a = t[n].words) != null && a.trim())) return j(t[n].words);
|
|
551
579
|
for (let n = e + 1; n < t.length; n++)
|
|
552
|
-
if (!t[n].isInstrumental && ((r = t[n].words) != null && r.trim())) return
|
|
580
|
+
if (!t[n].isInstrumental && ((r = t[n].words) != null && r.trim())) return j(t[n].words);
|
|
553
581
|
return !1;
|
|
554
582
|
}
|
|
555
|
-
function
|
|
583
|
+
function G(t, e) {
|
|
556
584
|
const a = document.createElement("span");
|
|
557
|
-
a.classList.add(
|
|
558
|
-
}
|
|
559
|
-
function
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
n && s.classList.add($), t.appendChild(s), r = [];
|
|
585
|
+
a.classList.add(ee), a.style.order = String(e), t.appendChild(a);
|
|
586
|
+
}
|
|
587
|
+
function ce(t, e) {
|
|
588
|
+
let a = [], r = !1;
|
|
589
|
+
const n = () => {
|
|
590
|
+
if (a.length > 0) {
|
|
591
|
+
const o = document.createElement("span");
|
|
592
|
+
for (const i of a) o.appendChild(i);
|
|
593
|
+
r && o.classList.add(V), t.appendChild(o), a = [];
|
|
567
594
|
}
|
|
568
595
|
};
|
|
569
|
-
for (const
|
|
570
|
-
const i =
|
|
571
|
-
|
|
596
|
+
for (const o of e) {
|
|
597
|
+
const i = o.classList.contains(V);
|
|
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";
|
|
600
|
+
(c || f) && n();
|
|
572
601
|
}
|
|
573
|
-
|
|
602
|
+
n();
|
|
574
603
|
}
|
|
575
604
|
function ot(t, e, a, r) {
|
|
576
605
|
let n = [], o = !0;
|
|
577
|
-
const
|
|
578
|
-
for (const
|
|
579
|
-
const c =
|
|
580
|
-
!c &&
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
606
|
+
const i = [];
|
|
607
|
+
for (const s of t) {
|
|
608
|
+
const c = j(s.words);
|
|
609
|
+
!c && s.words.trim().length > 0 && (o = !1, n.reverse().forEach((d) => i.push(d)), n = []);
|
|
610
|
+
const f = Jt(s);
|
|
611
|
+
for (const d of f) {
|
|
612
|
+
const l = document.createElement("span");
|
|
613
|
+
l.classList.add(te), d.durationMs === 0 && l.classList.add(ae), c && l.classList.add(Z);
|
|
614
|
+
const m = {
|
|
615
|
+
time: d.startTimeMs / 1e3,
|
|
616
|
+
duration: d.durationMs / 1e3,
|
|
617
|
+
element: l,
|
|
618
|
+
animationStartTimeMs: Number.POSITIVE_INFINITY
|
|
619
|
+
};
|
|
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);
|
|
621
|
+
}
|
|
590
622
|
}
|
|
591
623
|
if (o && n.length > 0) {
|
|
592
624
|
a.classList.add(Z);
|
|
593
|
-
for (const
|
|
594
|
-
} else n.length > 0 && n.reverse().forEach((
|
|
595
|
-
|
|
625
|
+
for (const s of n) i.push(s);
|
|
626
|
+
} else n.length > 0 && n.reverse().forEach((s) => i.push(s));
|
|
627
|
+
ce(a, i);
|
|
596
628
|
}
|
|
597
|
-
function
|
|
629
|
+
function le(t, e, a = {}) {
|
|
598
630
|
const { longWordThreshold: r = 1500, lineSyncedAnimationDelay: n = 50, disableRichsync: o = !1 } = a;
|
|
599
631
|
e.replaceChildren();
|
|
600
|
-
let
|
|
632
|
+
let s = t.every((d) => d.startTimeMs === 0) ? "none" : "synced";
|
|
601
633
|
const c = [];
|
|
602
|
-
for (let
|
|
603
|
-
const
|
|
604
|
-
m.classList.add(
|
|
634
|
+
for (let d = 0; d < t.length; d++) {
|
|
635
|
+
const l = t[d], m = l.isInstrumental ? Ht(l.durationMs, d) : document.createElement("div");
|
|
636
|
+
m.classList.add(Xt);
|
|
605
637
|
const p = {
|
|
606
638
|
element: m,
|
|
607
|
-
time:
|
|
608
|
-
duration:
|
|
639
|
+
time: l.startTimeMs / 1e3,
|
|
640
|
+
duration: l.durationMs / 1e3,
|
|
609
641
|
parts: [],
|
|
610
642
|
isScrolled: !1,
|
|
611
643
|
animationStartTimeMs: Number.POSITIVE_INFINITY,
|
|
@@ -617,48 +649,48 @@ function ee(t, e, a = {}) {
|
|
|
617
649
|
height: -1,
|
|
618
650
|
position: -1
|
|
619
651
|
};
|
|
620
|
-
if (
|
|
621
|
-
m.dataset.instrumental = "true", m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(
|
|
622
|
-
const b =
|
|
623
|
-
b && (m.dataset.agent = b),
|
|
652
|
+
if (l.isInstrumental) {
|
|
653
|
+
m.dataset.instrumental = "true", m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(d);
|
|
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);
|
|
624
656
|
continue;
|
|
625
657
|
}
|
|
626
|
-
let
|
|
627
|
-
if ((
|
|
628
|
-
startTimeMs:
|
|
658
|
+
let w = l.parts ?? [];
|
|
659
|
+
if ((w.length === 0 || o) && (w = l.words.split(" ").map((b, v) => ({
|
|
660
|
+
startTimeMs: l.startTimeMs + v * n,
|
|
629
661
|
words: b.trim().length < 1 ? b : `${b} `,
|
|
630
662
|
durationMs: 0
|
|
631
|
-
}))),
|
|
632
|
-
|
|
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);
|
|
633
665
|
const b = document.createElement("div");
|
|
634
|
-
b.classList.add(
|
|
635
|
-
${
|
|
666
|
+
b.classList.add(re), b.style.order = "5", l.timedRomanization && l.timedRomanization.length > 0 && !o ? ot(l.timedRomanization, p, b, r) : b.textContent = `
|
|
667
|
+
${l.romanization}`, m.appendChild(b);
|
|
636
668
|
}
|
|
637
|
-
if (
|
|
638
|
-
|
|
669
|
+
if (l.translation) {
|
|
670
|
+
G(m, 6);
|
|
639
671
|
const b = document.createElement("div");
|
|
640
|
-
b.classList.add(
|
|
641
|
-
${
|
|
672
|
+
b.classList.add(ne), b.style.order = "7", b.textContent = `
|
|
673
|
+
${l.translation.text}`, m.appendChild(b);
|
|
642
674
|
}
|
|
643
675
|
c.push(p), e.appendChild(m);
|
|
644
676
|
}
|
|
645
|
-
e.dataset.sync =
|
|
646
|
-
const
|
|
647
|
-
return
|
|
677
|
+
e.dataset.sync = s;
|
|
678
|
+
const f = document.createElement("div");
|
|
679
|
+
return f.className = "braccato--spacer", f.style.height = "100px", e.appendChild(f), {
|
|
648
680
|
lines: c,
|
|
649
|
-
syncType:
|
|
681
|
+
syncType: s,
|
|
650
682
|
width: e.clientWidth,
|
|
651
683
|
height: e.clientHeight,
|
|
652
684
|
container: e
|
|
653
685
|
};
|
|
654
686
|
}
|
|
655
|
-
const ae = ':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))}}', re = ':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)}';
|
|
656
|
-
var
|
|
657
|
-
for (var n = void 0, o = t.length - 1,
|
|
658
|
-
(
|
|
659
|
-
return n &&
|
|
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) => {
|
|
689
|
+
for (var n = void 0, o = t.length - 1, i; o >= 0; o--)
|
|
690
|
+
(i = t[o]) && (n = i(e, a, n) || n);
|
|
691
|
+
return n && me(e, a, n), n;
|
|
660
692
|
};
|
|
661
|
-
function
|
|
693
|
+
function fe() {
|
|
662
694
|
if (!(typeof CSS > "u" || !CSS.registerProperty))
|
|
663
695
|
try {
|
|
664
696
|
CSS.registerProperty({
|
|
@@ -675,8 +707,8 @@ function ie() {
|
|
|
675
707
|
} catch {
|
|
676
708
|
}
|
|
677
709
|
}
|
|
678
|
-
|
|
679
|
-
const
|
|
710
|
+
fe();
|
|
711
|
+
const K = class K extends lt {
|
|
680
712
|
constructor() {
|
|
681
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 = () => {
|
|
682
714
|
const e = this._animState.scroll;
|
|
@@ -712,7 +744,7 @@ const J = class J extends lt {
|
|
|
712
744
|
this.debug && console.log("[braccato]", ...e);
|
|
713
745
|
}
|
|
714
746
|
_injectLyrics() {
|
|
715
|
-
var n, o,
|
|
747
|
+
var n, o, i, s;
|
|
716
748
|
const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".braccato-container");
|
|
717
749
|
if (!e) {
|
|
718
750
|
this._log("_injectLyrics: no container found in shadowRoot");
|
|
@@ -727,17 +759,17 @@ const J = class J extends lt {
|
|
|
727
759
|
lineSyncedAnimationDelay: this.lineSyncedDelay,
|
|
728
760
|
disableRichsync: this.disableRichsync
|
|
729
761
|
};
|
|
730
|
-
this._lyricsData =
|
|
762
|
+
this._lyricsData = le(this.lyrics, e, a), this._log("_injectLyrics: rendered", {
|
|
731
763
|
lineCount: this._lyricsData.lines.length,
|
|
732
764
|
syncType: this._lyricsData.syncType,
|
|
733
765
|
firstLineTime: (o = this._lyricsData.lines[0]) == null ? void 0 : o.time,
|
|
734
|
-
lastLineTime: (
|
|
766
|
+
lastLineTime: (i = this._lyricsData.lines[this._lyricsData.lines.length - 1]) == null ? void 0 : i.time,
|
|
735
767
|
containerSize: { w: e.clientWidth, h: e.clientHeight }
|
|
736
768
|
});
|
|
737
769
|
for (let c = 0; c < this._lyricsData.lines.length; c++)
|
|
738
|
-
this._lyricsData.lines[c].element.addEventListener("click", (
|
|
770
|
+
this._lyricsData.lines[c].element.addEventListener("click", (d) => this._handleLineClick(d, c));
|
|
739
771
|
const r = this._getScrollContainer();
|
|
740
|
-
this._log("_injectLyrics: scrollContainer", r.tagName, r.className), r.addEventListener("scroll", this._onScroll, { passive: !0 }), (
|
|
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(
|
|
741
773
|
new CustomEvent("braccato:lyrics-loaded", {
|
|
742
774
|
detail: { syncType: this._lyricsData.syncType, lineCount: this._lyricsData.lines.length },
|
|
743
775
|
bubbles: !0,
|
|
@@ -769,7 +801,7 @@ const J = class J extends lt {
|
|
|
769
801
|
_tick() {
|
|
770
802
|
if (!this._lyricsData || this._lyricsData.syncType === "none") return;
|
|
771
803
|
if (this._tickCount++, this.debug && this._tickCount % 60 === 0) {
|
|
772
|
-
const n = this._lyricsData.lines.filter((
|
|
804
|
+
const n = this._lyricsData.lines.filter((i) => i.isScrolled), o = this._lyricsData.lines.filter((i) => i.isAnimating);
|
|
773
805
|
this._log("tick", {
|
|
774
806
|
currentTime: this.currentTime,
|
|
775
807
|
currentTimeSec: this.currentTime / 1e3,
|
|
@@ -798,17 +830,17 @@ const J = class J extends lt {
|
|
|
798
830
|
}
|
|
799
831
|
// -- Events --------------------------
|
|
800
832
|
_handleLineClick(e, a) {
|
|
801
|
-
var o,
|
|
833
|
+
var o, i;
|
|
802
834
|
const r = (o = this._lyricsData) == null ? void 0 : o.lines[a];
|
|
803
835
|
if (!r) return;
|
|
804
836
|
const n = r.time * 1e3;
|
|
805
|
-
if (this._log("lineClick", { lineIndex: a, time: n, lineTimeSec: r.time, currentTime: this.currentTime }), e.altKey && ((
|
|
806
|
-
const
|
|
807
|
-
if (
|
|
808
|
-
const c = Number.parseFloat(
|
|
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") {
|
|
838
|
+
const s = e.target.closest(".braccato--word");
|
|
839
|
+
if (s) {
|
|
840
|
+
const c = Number.parseFloat(s.dataset.time || "0") * 1e3, f = r.parts.findIndex((d) => d.element === s);
|
|
809
841
|
this.dispatchEvent(
|
|
810
842
|
new CustomEvent("braccato:word-click", {
|
|
811
|
-
detail: { time: c, lineIndex: a, wordIndex:
|
|
843
|
+
detail: { time: c, lineIndex: a, wordIndex: f },
|
|
812
844
|
bubbles: !0,
|
|
813
845
|
composed: !0
|
|
814
846
|
})
|
|
@@ -849,8 +881,8 @@ const J = class J extends lt {
|
|
|
849
881
|
}
|
|
850
882
|
const n = await r.text();
|
|
851
883
|
if (e.signal.aborted) return;
|
|
852
|
-
const o = this._mediaElement ? this._mediaElement.duration * 1e3 : 3e5,
|
|
853
|
-
this.lyrics =
|
|
884
|
+
const o = this._mediaElement ? this._mediaElement.duration * 1e3 : 3e5, i = wt(n);
|
|
885
|
+
this.lyrics = i.parse(n, o);
|
|
854
886
|
} catch (r) {
|
|
855
887
|
if (r instanceof DOMException && r.name === "AbortError") return;
|
|
856
888
|
this._emitError(r instanceof Error ? r : new Error(String(r)));
|
|
@@ -873,43 +905,43 @@ const J = class J extends lt {
|
|
|
873
905
|
this._recalculatePositions();
|
|
874
906
|
}
|
|
875
907
|
};
|
|
876
|
-
|
|
877
|
-
let E =
|
|
878
|
-
|
|
879
|
-
|
|
908
|
+
K.styles = [X(ue), X(de)];
|
|
909
|
+
let E = K;
|
|
910
|
+
R([
|
|
911
|
+
D({ type: Array })
|
|
880
912
|
], E.prototype, "lyrics");
|
|
881
|
-
|
|
882
|
-
|
|
913
|
+
R([
|
|
914
|
+
D({ attribute: "current-time", type: Number })
|
|
883
915
|
], E.prototype, "currentTime");
|
|
884
|
-
|
|
885
|
-
|
|
916
|
+
R([
|
|
917
|
+
D({ type: Boolean, reflect: !0 })
|
|
886
918
|
], E.prototype, "playing");
|
|
887
|
-
|
|
888
|
-
|
|
919
|
+
R([
|
|
920
|
+
D({ attribute: "scroll-mode", type: String, reflect: !0 })
|
|
889
921
|
], E.prototype, "scrollMode");
|
|
890
|
-
|
|
891
|
-
|
|
922
|
+
R([
|
|
923
|
+
D({ attribute: !1 })
|
|
892
924
|
], E.prototype, "scrollContainer");
|
|
893
|
-
|
|
894
|
-
|
|
925
|
+
R([
|
|
926
|
+
D({ type: String, reflect: !0 })
|
|
895
927
|
], E.prototype, "dir");
|
|
896
|
-
|
|
897
|
-
|
|
928
|
+
R([
|
|
929
|
+
D({ attribute: "long-word-threshold", type: Number })
|
|
898
930
|
], E.prototype, "longWordThreshold");
|
|
899
|
-
|
|
900
|
-
|
|
931
|
+
R([
|
|
932
|
+
D({ attribute: "line-synced-delay", type: Number })
|
|
901
933
|
], E.prototype, "lineSyncedDelay");
|
|
902
|
-
|
|
903
|
-
|
|
934
|
+
R([
|
|
935
|
+
D({ attribute: "disable-richsync", type: Boolean })
|
|
904
936
|
], E.prototype, "disableRichsync");
|
|
905
|
-
|
|
906
|
-
|
|
937
|
+
R([
|
|
938
|
+
D({ type: Boolean })
|
|
907
939
|
], E.prototype, "debug");
|
|
908
|
-
|
|
909
|
-
|
|
940
|
+
R([
|
|
941
|
+
D({ type: String, reflect: !0 })
|
|
910
942
|
], E.prototype, "source");
|
|
911
|
-
|
|
912
|
-
|
|
943
|
+
R([
|
|
944
|
+
D({ type: String, reflect: !0 })
|
|
913
945
|
], E.prototype, "src");
|
|
914
946
|
customElements.define("braccato-lyrics", E);
|
|
915
947
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@braccato/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Synchronized lyrics web component with word-by-word animations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,16 +36,20 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"lit": "^3.2.1",
|
|
39
|
-
"@braccato/parsers": "^0.1.
|
|
39
|
+
"@braccato/parsers": "^0.1.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"jsdom": "^28.1.0",
|
|
42
43
|
"typescript": "^5.7.3",
|
|
43
44
|
"vite": "^6.0.7",
|
|
44
|
-
"vite-plugin-dts": "^4.3.0"
|
|
45
|
+
"vite-plugin-dts": "^4.3.0",
|
|
46
|
+
"vitest": "^3.0.4"
|
|
45
47
|
},
|
|
46
48
|
"scripts": {
|
|
47
49
|
"build": "vite build",
|
|
48
50
|
"dev": "vite build --watch",
|
|
49
|
-
"typecheck": "tsc --noEmit"
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest"
|
|
50
54
|
}
|
|
51
55
|
}
|