@applemusic-like-lyrics/core 0.0.14 → 0.0.15
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/amll-core.js +1 -1
- package/dist/amll-core.js.map +1 -1
- package/dist/amll-core.mjs +150 -107
- package/dist/amll-core.mjs.map +1 -1
- package/dist/interfaces.d.ts +9 -7
- package/dist/lyric-player/index.d.ts +4 -0
- package/dist/lyric-player/lyric-line.d.ts +2 -2
- package/package.json +1 -1
package/dist/amll-core.mjs
CHANGED
|
@@ -2,15 +2,15 @@ import { Container as C } from "@pixi/display";
|
|
|
2
2
|
import { Application as z } from "@pixi/app";
|
|
3
3
|
import { BlurFilter as y } from "@pixi/filter-blur";
|
|
4
4
|
import { ColorMatrixFilter as P } from "@pixi/filter-color-matrix";
|
|
5
|
-
import { Texture as
|
|
5
|
+
import { Texture as D } from "@pixi/core";
|
|
6
6
|
import { Sprite as S } from "@pixi/sprite";
|
|
7
7
|
import { BulgePinchFilter as b } from "@pixi/filter-bulge-pinch";
|
|
8
|
-
import { create as
|
|
9
|
-
import
|
|
10
|
-
class
|
|
8
|
+
import { create as I } from "jss";
|
|
9
|
+
import k from "jss-preset-default";
|
|
10
|
+
class B extends C {
|
|
11
11
|
time = 0;
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class A {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
this.canvas = e;
|
|
16
16
|
const t = e.getBoundingClientRect();
|
|
@@ -142,28 +142,28 @@ class B {
|
|
|
142
142
|
let i = 5, s;
|
|
143
143
|
for (; !s?.baseTexture?.resource?.valid && i > 0; )
|
|
144
144
|
try {
|
|
145
|
-
await t.decode(), s =
|
|
145
|
+
await t.decode(), s = D.from(t, {
|
|
146
146
|
resourceOptions: {
|
|
147
147
|
autoLoad: !1
|
|
148
148
|
}
|
|
149
149
|
}), await s.baseTexture.resource.load();
|
|
150
|
-
} catch (
|
|
150
|
+
} catch (h) {
|
|
151
151
|
console.warn(
|
|
152
152
|
`failed on loading album image, retrying (${i})`,
|
|
153
153
|
e,
|
|
154
|
-
|
|
154
|
+
h
|
|
155
155
|
), s = void 0, i--;
|
|
156
156
|
}
|
|
157
157
|
if (!s)
|
|
158
158
|
return;
|
|
159
|
-
const r = new
|
|
160
|
-
n.anchor.set(0.5, 0.5), a.anchor.set(0.5, 0.5),
|
|
159
|
+
const r = new B(), n = new S(s), a = new S(s), o = new S(s), l = new S(s);
|
|
160
|
+
n.anchor.set(0.5, 0.5), a.anchor.set(0.5, 0.5), o.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), n.rotation = Math.random() * Math.PI * 2, a.rotation = Math.random() * Math.PI * 2, o.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, r.addChild(n, a, o, l), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = r, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
|
|
161
161
|
}
|
|
162
162
|
dispose() {
|
|
163
163
|
this.observer.disconnect(), this.app.ticker.remove(this.onTick), this.app.destroy(!0);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
class se extends
|
|
166
|
+
class se extends A {
|
|
167
167
|
element;
|
|
168
168
|
constructor() {
|
|
169
169
|
const e = document.createElement("canvas");
|
|
@@ -176,7 +176,7 @@ class se extends B {
|
|
|
176
176
|
super.dispose(), this.element.remove();
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
const
|
|
179
|
+
const O = (c, e) => c.size === e.size && [...c].every((t) => e.has(t));
|
|
180
180
|
class L {
|
|
181
181
|
currentPosition = 0;
|
|
182
182
|
targetPosition = 0;
|
|
@@ -232,25 +232,25 @@ class L {
|
|
|
232
232
|
return this.currentPosition;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
function F(
|
|
236
|
-
const r = s?.soft ?? !1, n = s?.stiffness ?? 100, a = s?.damping ?? 10,
|
|
237
|
-
if (r || 1 <= a / (2 * Math.sqrt(n *
|
|
238
|
-
const
|
|
239
|
-
return (
|
|
235
|
+
function F(c, e, t, i = 0, s) {
|
|
236
|
+
const r = s?.soft ?? !1, n = s?.stiffness ?? 100, a = s?.damping ?? 10, o = s?.mass ?? 1, l = t - c;
|
|
237
|
+
if (r || 1 <= a / (2 * Math.sqrt(n * o))) {
|
|
238
|
+
const h = -Math.sqrt(n / o), u = -h * l - e;
|
|
239
|
+
return (p) => (p -= i, p < 0 ? c : t - (l + p * u) * Math.E ** (p * h));
|
|
240
240
|
} else {
|
|
241
|
-
const
|
|
242
|
-
4 *
|
|
243
|
-
),
|
|
244
|
-
return (d) => (d -= i, d < 0 ?
|
|
241
|
+
const h = Math.sqrt(
|
|
242
|
+
4 * o * n - a ** 2
|
|
243
|
+
), u = (a * l - 2 * o * e) / h, p = 0.5 * h / o, f = -(0.5 * a) / o;
|
|
244
|
+
return (d) => (d -= i, d < 0 ? c : t - (Math.cos(d * p) * l + Math.sin(d * p) * u) * Math.E ** (d * f));
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
return (t) => (
|
|
247
|
+
function $(c) {
|
|
248
|
+
return (t) => (c(t + 1e-3) - c(t - 1e-3)) / (2 * 1e-3);
|
|
249
249
|
}
|
|
250
|
-
function x(
|
|
251
|
-
return
|
|
250
|
+
function x(c) {
|
|
251
|
+
return $(c);
|
|
252
252
|
}
|
|
253
|
-
class
|
|
253
|
+
class Y {
|
|
254
254
|
constructor(e) {
|
|
255
255
|
this.lyricPlayer = e, this.element.setAttribute(
|
|
256
256
|
"class",
|
|
@@ -307,11 +307,11 @@ class O {
|
|
|
307
307
|
this.element.remove();
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function _(c) {
|
|
311
311
|
const t = 2.5949095;
|
|
312
|
-
return
|
|
312
|
+
return c < 0.5 ? Math.pow(2 * c, 2) * ((t + 1) * 2 * c - t) / 2 : (Math.pow(2 * c - 2, 2) * ((t + 1) * (c * 2 - 2) + t) + 2) / 2;
|
|
313
313
|
}
|
|
314
|
-
const g = (
|
|
314
|
+
const g = (c, e, t) => Math.max(c, Math.min(e, t));
|
|
315
315
|
class q {
|
|
316
316
|
constructor(e) {
|
|
317
317
|
this.lyricPlayer = e, this.element.className = this.lyricPlayer.style.classes.interludeDots, this.element.appendChild(this.dot0), this.element.appendChild(this.dot1), this.element.appendChild(this.dot2);
|
|
@@ -346,14 +346,14 @@ class q {
|
|
|
346
346
|
if (s <= i) {
|
|
347
347
|
const r = i / Math.ceil(i / this.targetBreatheDuration);
|
|
348
348
|
let n = 1, a = 1;
|
|
349
|
-
n *= Math.sin(1.5 * Math.PI - s / r * 2) / 10 + 1, s < 1e3 && (n *= 1 - Math.pow((1e3 - s) / 1e3, 2)), s < 500 ? a = 0 : s < 1e3 && (a *= (s - 500) / 500), i - s < 750 && (n *= 1 -
|
|
349
|
+
n *= Math.sin(1.5 * Math.PI - s / r * 2) / 10 + 1, s < 1e3 && (n *= 1 - Math.pow((1e3 - s) / 1e3, 2)), s < 500 ? a = 0 : s < 1e3 && (a *= (s - 500) / 500), i - s < 750 && (n *= 1 - _(
|
|
350
350
|
(750 - (i - s)) / 750 / 2
|
|
351
351
|
)), i - s < 375 && (a *= g(
|
|
352
352
|
0,
|
|
353
353
|
(i - s) / 375,
|
|
354
354
|
1
|
|
355
355
|
)), n = Math.max(0, n), t += ` scale(${n})`;
|
|
356
|
-
const
|
|
356
|
+
const o = g(
|
|
357
357
|
0.25,
|
|
358
358
|
s * 3 / i * 0.75,
|
|
359
359
|
1
|
|
@@ -361,14 +361,14 @@ class q {
|
|
|
361
361
|
0.25,
|
|
362
362
|
(s - i / 3) * 3 / i * 0.75,
|
|
363
363
|
1
|
|
364
|
-
),
|
|
364
|
+
), h = g(
|
|
365
365
|
0.25,
|
|
366
366
|
(s - i / 3 * 2) * 3 / i * 0.75,
|
|
367
367
|
1
|
|
368
368
|
);
|
|
369
369
|
this.dot0.style.opacity = `${g(
|
|
370
370
|
0,
|
|
371
|
-
Math.max(0, a *
|
|
371
|
+
Math.max(0, a * o),
|
|
372
372
|
1
|
|
373
373
|
)}`, this.dot1.style.opacity = `${g(
|
|
374
374
|
0,
|
|
@@ -376,7 +376,7 @@ class q {
|
|
|
376
376
|
1
|
|
377
377
|
)}`, this.dot2.style.opacity = `${g(
|
|
378
378
|
0,
|
|
379
|
-
Math.max(0, a *
|
|
379
|
+
Math.max(0, a * h),
|
|
380
380
|
1
|
|
381
381
|
)}`;
|
|
382
382
|
} else
|
|
@@ -390,32 +390,32 @@ class q {
|
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
const R = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
|
|
393
|
-
function
|
|
394
|
-
const i = 2 +
|
|
393
|
+
function W(c, e = "rgba(0,0,0,0.85)", t = "rgba(0,0,0,0.5)") {
|
|
394
|
+
const i = 2 + c, s = c / i, r = (1 - s) / 2;
|
|
395
395
|
return [
|
|
396
396
|
`linear-gradient(to right,${e} ${r * 100}%,${t} ${(r + s) * 100}%)`,
|
|
397
397
|
s,
|
|
398
398
|
i
|
|
399
399
|
];
|
|
400
400
|
}
|
|
401
|
-
function X(
|
|
401
|
+
function X(c, e) {
|
|
402
402
|
let t = [], i = [];
|
|
403
403
|
const s = [];
|
|
404
|
-
for (const r of
|
|
404
|
+
for (const r of c) {
|
|
405
405
|
const n = e(r);
|
|
406
406
|
t.push(n), i.push(r), n.length > 0 && n.trim().length === 0 ? (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), s.push(r), t = [], i = []) : (!/^\s*[^\s]*\s*$/.test(t.join("")) || R.test(n)) && (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), t = [n], i = [r]);
|
|
407
407
|
}
|
|
408
408
|
return i.length === 1 ? s.push(i[0]) : s.push(i), s;
|
|
409
409
|
}
|
|
410
|
-
function v(
|
|
411
|
-
return
|
|
410
|
+
function v(c) {
|
|
411
|
+
return c.endTime - c.startTime >= 1e3 && c.word.length <= 7;
|
|
412
412
|
}
|
|
413
|
-
class
|
|
413
|
+
class H extends MouseEvent {
|
|
414
414
|
constructor(e, t) {
|
|
415
415
|
super(t.type, t), this.line = e;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
class
|
|
418
|
+
class G extends EventTarget {
|
|
419
419
|
// rome-ignore lint/correctness/noUnreachableSuper: <explanation>
|
|
420
420
|
constructor(e, t = {
|
|
421
421
|
words: [],
|
|
@@ -449,17 +449,20 @@ class V extends EventTarget {
|
|
|
449
449
|
};
|
|
450
450
|
listenersMap = /* @__PURE__ */ new Map();
|
|
451
451
|
onMouseEvent = (e) => {
|
|
452
|
-
|
|
452
|
+
const t = new H(this, e);
|
|
453
|
+
for (const i of this.listenersMap.get(e.type) ?? [])
|
|
454
|
+
i.call(this, t);
|
|
455
|
+
if (!this.dispatchEvent(t) || t.defaultPrevented)
|
|
453
456
|
return e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), !1;
|
|
454
457
|
};
|
|
455
|
-
|
|
456
|
-
if (
|
|
458
|
+
addMouseEventListener(e, t, i) {
|
|
459
|
+
if (t) {
|
|
457
460
|
const s = this.listenersMap.get(e) ?? /* @__PURE__ */ new Set();
|
|
458
461
|
s.size === 0 && this.element.addEventListener(e, this.onMouseEvent), s.add(t), this.listenersMap.set(e, s);
|
|
459
462
|
}
|
|
460
463
|
}
|
|
461
|
-
|
|
462
|
-
if (
|
|
464
|
+
removeMouseEventListener(e, t, i) {
|
|
465
|
+
if (t) {
|
|
463
466
|
const s = this.listenersMap.get(e);
|
|
464
467
|
s && (s.delete(t), s.size === 0 && this.element.removeEventListener(e, this.onMouseEvent));
|
|
465
468
|
}
|
|
@@ -529,27 +532,27 @@ class V extends EventTarget {
|
|
|
529
532
|
e.innerHTML = "", this.splittedWords = [];
|
|
530
533
|
for (const r of s)
|
|
531
534
|
if (r instanceof Array) {
|
|
532
|
-
const n = r.map((l) => v(l)).reduce((l,
|
|
533
|
-
(l,
|
|
535
|
+
const n = r.map((l) => v(l)).reduce((l, h) => l || h, !1), a = r.reduce(
|
|
536
|
+
(l, h) => (l.endTime = Math.max(l.endTime, h.endTime), l.startTime = Math.min(l.startTime, h.startTime), l.word += h.word, l),
|
|
534
537
|
{ word: "", startTime: 1 / 0, endTime: -1 / 0 }
|
|
535
|
-
),
|
|
538
|
+
), o = document.createElement("span");
|
|
536
539
|
for (const l of r) {
|
|
537
|
-
const
|
|
540
|
+
const h = document.createElement("span"), u = this.initFloatAnimation(
|
|
538
541
|
a,
|
|
539
|
-
|
|
542
|
+
h
|
|
540
543
|
);
|
|
541
544
|
if (n) {
|
|
542
|
-
|
|
543
|
-
const
|
|
545
|
+
h.classList.add("emphasize");
|
|
546
|
+
const p = [];
|
|
544
547
|
for (const d of l.word.trim().split("")) {
|
|
545
548
|
const m = document.createElement("span");
|
|
546
|
-
m.innerText = d,
|
|
549
|
+
m.innerText = d, p.push(m), h.appendChild(m);
|
|
547
550
|
}
|
|
548
551
|
const f = {
|
|
549
552
|
...l,
|
|
550
|
-
mainElement:
|
|
551
|
-
subElements:
|
|
552
|
-
elementAnimations: [
|
|
553
|
+
mainElement: h,
|
|
554
|
+
subElements: p,
|
|
555
|
+
elementAnimations: [u],
|
|
553
556
|
width: 0,
|
|
554
557
|
height: 0,
|
|
555
558
|
shouldEmphasize: n
|
|
@@ -558,22 +561,22 @@ class V extends EventTarget {
|
|
|
558
561
|
...this.initEmphasizeAnimation(f)
|
|
559
562
|
), this.splittedWords.push(f);
|
|
560
563
|
} else
|
|
561
|
-
|
|
564
|
+
h.innerText = l.word, this.splittedWords.push({
|
|
562
565
|
...l,
|
|
563
|
-
mainElement:
|
|
566
|
+
mainElement: h,
|
|
564
567
|
subElements: [],
|
|
565
|
-
elementAnimations: [
|
|
568
|
+
elementAnimations: [u],
|
|
566
569
|
width: 0,
|
|
567
570
|
height: 0,
|
|
568
571
|
shouldEmphasize: n
|
|
569
572
|
});
|
|
570
|
-
|
|
573
|
+
o.appendChild(h);
|
|
571
574
|
}
|
|
572
|
-
a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(
|
|
575
|
+
a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(o), a.word.trimEnd() !== a.word && e.appendChild(document.createTextNode(" "));
|
|
573
576
|
} else if (r.word.trim().length === 0)
|
|
574
577
|
e.appendChild(document.createTextNode(" "));
|
|
575
578
|
else {
|
|
576
|
-
const n = v(r), a = document.createElement("span"),
|
|
579
|
+
const n = v(r), a = document.createElement("span"), o = {
|
|
577
580
|
...r,
|
|
578
581
|
mainElement: a,
|
|
579
582
|
subElements: [],
|
|
@@ -585,16 +588,16 @@ class V extends EventTarget {
|
|
|
585
588
|
if (n) {
|
|
586
589
|
a.classList.add("emphasize");
|
|
587
590
|
const l = [];
|
|
588
|
-
for (const
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
+
for (const h of r.word.trim().split("")) {
|
|
592
|
+
const u = document.createElement("span");
|
|
593
|
+
u.innerText = h, l.push(u), a.appendChild(u);
|
|
591
594
|
}
|
|
592
|
-
|
|
593
|
-
...this.initEmphasizeAnimation(
|
|
595
|
+
o.subElements = l, o.elementAnimations.push(
|
|
596
|
+
...this.initEmphasizeAnimation(o)
|
|
594
597
|
);
|
|
595
598
|
} else
|
|
596
599
|
a.innerText = r.word.trim();
|
|
597
|
-
r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(a), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(
|
|
600
|
+
r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(a), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(o);
|
|
598
601
|
}
|
|
599
602
|
t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
|
|
600
603
|
}
|
|
@@ -621,7 +624,7 @@ class V extends EventTarget {
|
|
|
621
624
|
initEmphasizeAnimation(e) {
|
|
622
625
|
const t = e.startTime - this.lyricLine.startTime, i = e.endTime - e.startTime;
|
|
623
626
|
return e.subElements.map((s, r, n) => {
|
|
624
|
-
const a = Math.max(1e3, e.endTime - e.startTime),
|
|
627
|
+
const a = Math.max(1e3, e.endTime - e.startTime), o = t + i / n.length * r, l = s.animate(
|
|
625
628
|
[
|
|
626
629
|
{
|
|
627
630
|
offset: 0,
|
|
@@ -641,7 +644,7 @@ class V extends EventTarget {
|
|
|
641
644
|
],
|
|
642
645
|
{
|
|
643
646
|
duration: isFinite(a) ? a : 0,
|
|
644
|
-
delay: isFinite(
|
|
647
|
+
delay: isFinite(o) ? o : 0,
|
|
645
648
|
id: "glow-word",
|
|
646
649
|
iterations: 1,
|
|
647
650
|
composite: "replace",
|
|
@@ -657,13 +660,13 @@ class V extends EventTarget {
|
|
|
657
660
|
const t = e.mainElement;
|
|
658
661
|
if (t) {
|
|
659
662
|
e.width = t.clientWidth, e.height = t.clientHeight;
|
|
660
|
-
const i = e.height / 2, [s, r, n] =
|
|
663
|
+
const i = e.height / 2, [s, r, n] = W(
|
|
661
664
|
i / e.width,
|
|
662
|
-
"rgba(0,0,0,
|
|
665
|
+
"rgba(0,0,0,0.85)",
|
|
663
666
|
"rgba(0,0,0,0.25)"
|
|
664
667
|
), a = `${n * 100}% 100%`;
|
|
665
|
-
this.lyricPlayer.supportMaskImage ? (t.style.maskImage = s, t.style.maskOrigin = "left", t.style.maskSize = a) : (t.style.webkitMaskImage = s, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = a);
|
|
666
|
-
const
|
|
668
|
+
this.lyricPlayer.supportMaskImage ? (t.style.maskImage = s, t.style.maskRepeat = "no-repeat", t.style.maskOrigin = "left", t.style.maskSize = a) : (t.style.webkitMaskImage = s, t.style.webkitMaskRepeat = "no-repeat", t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = a);
|
|
669
|
+
const o = e.width + i, l = `clamp(${-o}px,calc(${-o}px + (var(--amll-player-time) - ${e.startTime})*${o / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
|
|
667
670
|
t.style.maskPosition = l, t.style.webkitMaskPosition = l;
|
|
668
671
|
}
|
|
669
672
|
}), this._hide && (this._prevParentEl && this.element.remove(), this.element.style.display = "none", this.element.style.visibility = "");
|
|
@@ -672,17 +675,17 @@ class V extends EventTarget {
|
|
|
672
675
|
return this.element;
|
|
673
676
|
}
|
|
674
677
|
setTransform(e = this.left, t = this.top, i = this.scale, s = 1, r = 0, n = !1, a = 0) {
|
|
675
|
-
const
|
|
678
|
+
const o = this.isInSight, l = this.lyricPlayer.getEnableSpring();
|
|
676
679
|
this.left = e, this.top = t, this.scale = i, this.delay = a * 1e3 | 0;
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
680
|
+
const h = this.element.children[0], u = this.element.children[1], p = this.element.children[2];
|
|
681
|
+
if (h.style.opacity = `${s}`, u.style.opacity = `${s / 2}`, p.style.opacity = `${s / 2}`, n || !l) {
|
|
679
682
|
if (this.blur = Math.min(32, r), n && this.element.classList.add(
|
|
680
683
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
681
684
|
), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(i), l)
|
|
682
685
|
this.rebuildStyle();
|
|
683
686
|
else {
|
|
684
687
|
const f = this.isInSight;
|
|
685
|
-
|
|
688
|
+
o || f ? this.show() : this.hide();
|
|
686
689
|
}
|
|
687
690
|
n && requestAnimationFrame(() => {
|
|
688
691
|
this.element.classList.remove(
|
|
@@ -706,8 +709,8 @@ class V extends EventTarget {
|
|
|
706
709
|
this.element.remove();
|
|
707
710
|
}
|
|
708
711
|
}
|
|
709
|
-
const
|
|
710
|
-
class
|
|
712
|
+
const V = I(k());
|
|
713
|
+
class N extends MouseEvent {
|
|
711
714
|
constructor(e, t, i) {
|
|
712
715
|
super(`line-${i.type}`, i), this.lineIndex = e, this.line = t;
|
|
713
716
|
}
|
|
@@ -763,10 +766,11 @@ class ne extends EventTarget {
|
|
|
763
766
|
alignAnchor = "center";
|
|
764
767
|
alignPosition = 0.5;
|
|
765
768
|
isNonDynamic = !1;
|
|
769
|
+
scrollBoundary = [0, 0];
|
|
766
770
|
size = [0, 0];
|
|
767
771
|
innerSize = [0, 0];
|
|
768
772
|
onLineClickedHandler = (e) => {
|
|
769
|
-
const t = new
|
|
773
|
+
const t = new N(
|
|
770
774
|
this.lyricLinesIndexes.get(e.line) ?? -1,
|
|
771
775
|
e.line,
|
|
772
776
|
e
|
|
@@ -811,7 +815,7 @@ class ne extends EventTarget {
|
|
|
811
815
|
getEnableScale() {
|
|
812
816
|
return this.enableScale;
|
|
813
817
|
}
|
|
814
|
-
style =
|
|
818
|
+
style = V.createStyleSheet({
|
|
815
819
|
lyricPlayer: {
|
|
816
820
|
userSelect: "none",
|
|
817
821
|
fontSize: "var(--amll-lyric-player-font-size,max(min(5vh, 10vw), 12px))",
|
|
@@ -936,12 +940,51 @@ class ne extends EventTarget {
|
|
|
936
940
|
this.calcLayout(!0, !0);
|
|
937
941
|
};
|
|
938
942
|
constructor() {
|
|
939
|
-
super(), this.interludeDots = new q(this), this.bottomLine = new
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
+
super(), this.interludeDots = new q(this), this.bottomLine = new Y(this), this.element.setAttribute("class", this.style.classes.lyricPlayer), this.disableSpring && this.element.classList.add(this.style.classes.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow);
|
|
944
|
+
let e = 0, t = "none", i = 0, s = 0, r = 0, n = Symbol("amll-scroll"), a = 0, o = 0;
|
|
945
|
+
this.element.addEventListener("touchstart", (l) => {
|
|
946
|
+
this.beginScrollHandler() && (l.preventDefault(), e = this.scrollOffset, i = l.touches[0].screenY, a = i, s = Date.now(), r = 0);
|
|
947
|
+
}), this.element.addEventListener("touchmove", (l) => {
|
|
948
|
+
if (this.beginScrollHandler()) {
|
|
949
|
+
l.preventDefault();
|
|
950
|
+
const h = l.touches[0].screenY, u = h - i, p = h - a, f = p > 0 ? "down" : p < 0 ? "up" : "none";
|
|
951
|
+
t !== f ? (t = f, e = this.scrollOffset, i = h, s = Date.now()) : this.scrollOffset = e - u, a = h, o = Date.now(), this.limitScrollOffset(), this.calcLayout(!0);
|
|
952
|
+
}
|
|
953
|
+
}), this.element.addEventListener("touchend", (l) => {
|
|
954
|
+
if (this.beginScrollHandler()) {
|
|
955
|
+
l.preventDefault(), i = 0;
|
|
956
|
+
const h = Date.now();
|
|
957
|
+
if (h - o > 100)
|
|
958
|
+
return this.endScrollHandler();
|
|
959
|
+
const u = h - s;
|
|
960
|
+
r = (this.scrollOffset - e) / u * 1e3;
|
|
961
|
+
let p = 0;
|
|
962
|
+
const f = Symbol("amll-scroll");
|
|
963
|
+
n = f;
|
|
964
|
+
const d = (m) => {
|
|
965
|
+
p ||= m, n === f && this.beginScrollHandler() && (this.scrollOffset += r * (m - p) / 1e3, r *= 0.99, this.limitScrollOffset(), this.calcLayout(!0), Math.abs(r) > 1 && !this.scrollBoundary.includes(this.scrollOffset) && requestAnimationFrame(d), this.endScrollHandler(), p = m);
|
|
966
|
+
};
|
|
967
|
+
requestAnimationFrame(d), this.endScrollHandler();
|
|
968
|
+
}
|
|
969
|
+
}), this.element.addEventListener("wheel", (l) => {
|
|
970
|
+
this.beginScrollHandler() && (l.deltaMode === l.DOM_DELTA_PIXEL ? (this.scrollOffset += l.deltaY, this.limitScrollOffset(), this.calcLayout(!0)) : (this.scrollOffset += l.deltaY * 50, this.limitScrollOffset(), this.calcLayout(!1)), this.endScrollHandler());
|
|
943
971
|
});
|
|
944
972
|
}
|
|
973
|
+
beginScrollHandler() {
|
|
974
|
+
const e = this.allowScroll;
|
|
975
|
+
return e && (this.isScrolled = !0, this.invokedByScrollEvent = !0, clearTimeout(this.scrolledHandler), this.scrolledHandler = setTimeout(() => {
|
|
976
|
+
this.isScrolled = !1, this.scrollOffset = 0;
|
|
977
|
+
}, 5e3)), e;
|
|
978
|
+
}
|
|
979
|
+
endScrollHandler() {
|
|
980
|
+
this.invokedByScrollEvent = !1;
|
|
981
|
+
}
|
|
982
|
+
limitScrollOffset() {
|
|
983
|
+
this.scrollOffset = Math.max(
|
|
984
|
+
Math.min(this.scrollBoundary[1], this.scrollOffset),
|
|
985
|
+
this.scrollBoundary[0]
|
|
986
|
+
);
|
|
987
|
+
}
|
|
945
988
|
/**
|
|
946
989
|
* 获取当前播放时间里是否处于间奏区间
|
|
947
990
|
* 如果是则会返回单位为毫秒的始末时间
|
|
@@ -1044,10 +1087,10 @@ class ne extends EventTarget {
|
|
|
1044
1087
|
const n = r[s + 1];
|
|
1045
1088
|
n?.isBG && (n.startTime = Math.min(n.startTime, i.startTime));
|
|
1046
1089
|
}), this.lyricLinesEl.forEach((i) => {
|
|
1047
|
-
i.
|
|
1090
|
+
i.removeMouseEventListener("click", this.onLineClickedHandler), i.removeMouseEventListener("contextmenu", this.onLineClickedHandler), i.dispose();
|
|
1048
1091
|
}), this.lyricLinesEl = this.processedLines.map((i) => {
|
|
1049
|
-
const s = new
|
|
1050
|
-
return s.
|
|
1092
|
+
const s = new G(this, i);
|
|
1093
|
+
return s.addMouseEventListener("click", this.onLineClickedHandler), s.addMouseEventListener("contextmenu", this.onLineClickedHandler), s;
|
|
1051
1094
|
}), this.lyricLinesEl.forEach((i, s) => {
|
|
1052
1095
|
this.element.appendChild(i.getElement()), this.lyricLinesIndexes.set(i, s), i.updateMaskImage();
|
|
1053
1096
|
}), this.interludeDots.setInterlude(void 0), this.hotLines.clear(), this.bufferedLines.clear(), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0, !0);
|
|
@@ -1085,11 +1128,11 @@ class ne extends EventTarget {
|
|
|
1085
1128
|
const i = this.getCurrentInterlude();
|
|
1086
1129
|
let s = -this.scrollOffset, r = this.scrollToIndex, n = 0;
|
|
1087
1130
|
i ? (n = i[1] - i[0], n >= 5e3 && this.lyricLinesEl[i[2] + 1] && (r = i[2] + 1)) : this.interludeDots.setInterlude(void 0);
|
|
1088
|
-
const a = this.enableScale ? 0.95 : 1,
|
|
1131
|
+
const a = this.enableScale ? 0.95 : 1, o = this.lyricLinesEl.slice(0, r).reduce(
|
|
1089
1132
|
(d, m) => d + (m.getLine().isBG ? 0 : this.lyricLinesSize.get(m)?.[1] ?? 0),
|
|
1090
1133
|
0
|
|
1091
1134
|
);
|
|
1092
|
-
s -=
|
|
1135
|
+
this.scrollBoundary[0] = -o, s -= o, s += this.size[1] * this.alignPosition;
|
|
1093
1136
|
const l = this.lyricLinesEl[r];
|
|
1094
1137
|
if (l) {
|
|
1095
1138
|
const d = this.lyricLinesSize.get(l)?.[1] ?? 0;
|
|
@@ -1102,10 +1145,10 @@ class ne extends EventTarget {
|
|
|
1102
1145
|
break;
|
|
1103
1146
|
}
|
|
1104
1147
|
}
|
|
1105
|
-
const
|
|
1106
|
-
let
|
|
1148
|
+
const h = Math.max(...this.bufferedLines);
|
|
1149
|
+
let u = 0, p = 0.05, f = !1;
|
|
1107
1150
|
this.lyricLinesEl.forEach((d, m) => {
|
|
1108
|
-
const T = this.bufferedLines.has(m), w = T || m >= this.scrollToIndex && m <
|
|
1151
|
+
const T = this.bufferedLines.has(m), w = T || m >= this.scrollToIndex && m < h, E = d.getLine();
|
|
1109
1152
|
E.isDuet && this.size[0] - (this.lyricLinesSize.get(d)?.[0] ?? 0), !f && n >= 5e3 && (m === this.scrollToIndex && i?.[2] === -2 || m === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(this.padding, s), i && this.interludeDots.setInterlude([i[0], i[1]]), s += this.interludeDotsSize[1]);
|
|
1110
1153
|
const M = this.hidePassedLines && m < (i ? i[2] + 1 : this.scrollToIndex) ? 0 : T ? 1 : 1 / 3;
|
|
1111
1154
|
d.setTransform(
|
|
@@ -1113,11 +1156,11 @@ class ne extends EventTarget {
|
|
|
1113
1156
|
s,
|
|
1114
1157
|
w ? 1 : a,
|
|
1115
1158
|
M,
|
|
1116
|
-
!this.invokedByScrollEvent && this.enableBlur ? w ? 0 : 1 + (m < this.scrollToIndex ? Math.abs(this.scrollToIndex - m) : Math.abs(m - Math.max(this.scrollToIndex,
|
|
1159
|
+
!this.invokedByScrollEvent && this.enableBlur ? w ? 0 : 1 + (m < this.scrollToIndex ? Math.abs(this.scrollToIndex - m) : Math.abs(m - Math.max(this.scrollToIndex, h))) : 0,
|
|
1117
1160
|
e,
|
|
1118
|
-
|
|
1119
|
-
), E.isBG && w ? s += this.lyricLinesSize.get(d)?.[1] ?? 0 : E.isBG || (s += this.lyricLinesSize.get(d)?.[1] ?? 0), s >= 0 && (
|
|
1120
|
-
}), this.bottomLine.setTransform(this.padding, s, e,
|
|
1161
|
+
u
|
|
1162
|
+
), E.isBG && w ? s += this.lyricLinesSize.get(d)?.[1] ?? 0 : E.isBG || (s += this.lyricLinesSize.get(d)?.[1] ?? 0), s >= 0 && (u += p, p /= 1.2);
|
|
1163
|
+
}), this.scrollBoundary[1] = s + this.scrollOffset - this.size[1] / 2, this.bottomLine.setTransform(this.padding, s, e, u);
|
|
1121
1164
|
}
|
|
1122
1165
|
/**
|
|
1123
1166
|
* 获取当前歌词的播放位置
|
|
@@ -1186,23 +1229,23 @@ class ne extends EventTarget {
|
|
|
1186
1229
|
if (a) {
|
|
1187
1230
|
if (a.isBG)
|
|
1188
1231
|
return;
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1191
|
-
const l = Math.min(a.startTime,
|
|
1192
|
-
(l > e ||
|
|
1232
|
+
const o = this.processedLines[n + 1];
|
|
1233
|
+
if (o?.isBG) {
|
|
1234
|
+
const l = Math.min(a.startTime, o?.startTime), h = Math.max(a.endTime, o?.endTime);
|
|
1235
|
+
(l > e || h <= e) && (this.hotLines.delete(n), i.add(n), this.hotLines.delete(n + 1), i.add(n + 1), t && (this.lyricLinesEl[n].disable(), this.lyricLinesEl[n + 1].disable()));
|
|
1193
1236
|
} else
|
|
1194
1237
|
(a.startTime > e || a.endTime <= e) && (this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable());
|
|
1195
1238
|
} else
|
|
1196
1239
|
this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable();
|
|
1197
|
-
}), this.processedLines.forEach((n, a,
|
|
1198
|
-
!n.isBG && n.startTime <= e && n.endTime > e && (this.hotLines.has(a) || (this.hotLines.add(a), r.add(a), t && this.lyricLinesEl[a].enable(),
|
|
1240
|
+
}), this.processedLines.forEach((n, a, o) => {
|
|
1241
|
+
!n.isBG && n.startTime <= e && n.endTime > e && (this.hotLines.has(a) || (this.hotLines.add(a), r.add(a), t && this.lyricLinesEl[a].enable(), o[a + 1]?.isBG && (this.hotLines.add(a + 1), r.add(a + 1), t && this.lyricLinesEl[a + 1].enable())));
|
|
1199
1242
|
}), this.bufferedLines.forEach((n) => {
|
|
1200
1243
|
this.hotLines.has(n) || (s.add(n), t && this.lyricLinesEl[n].disable());
|
|
1201
1244
|
}), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
|
|
1202
1245
|
(n) => n.startTime >= e
|
|
1203
1246
|
), this.bufferedLines.clear(), this.hotLines.forEach((n) => this.bufferedLines.add(n)), this.calcLayout(!0)) : (s.size > 0 || r.size > 0) && (s.size === 0 && r.size > 0 ? (r.forEach((n) => {
|
|
1204
1247
|
this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
|
|
1205
|
-
}), this.scrollToIndex = Math.min(...this.bufferedLines), this.calcLayout()) : r.size === 0 && s.size > 0 ?
|
|
1248
|
+
}), this.scrollToIndex = Math.min(...this.bufferedLines), this.calcLayout()) : r.size === 0 && s.size > 0 ? O(s, this.bufferedLines) && (this.bufferedLines.forEach((n) => {
|
|
1206
1249
|
this.hotLines.has(n) || (this.bufferedLines.delete(n), this.lyricLinesEl[n].disable());
|
|
1207
1250
|
}), this.calcLayout()) : (r.forEach((n) => {
|
|
1208
1251
|
this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
|