@applemusic-like-lyrics/core 0.0.8 → 0.0.11
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/README.md +2 -0
- package/dist/amll-core.js +1 -1
- package/dist/amll-core.js.map +1 -1
- package/dist/amll-core.mjs +495 -374
- package/dist/amll-core.mjs.map +1 -1
- package/dist/bg-render/pixi-renderer.d.ts +6 -0
- package/dist/lyric-player/bottom-line.d.ts +26 -0
- package/dist/lyric-player/index.d.ts +38 -8
- package/package.json +3 -1
package/dist/amll-core.mjs
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { Container as
|
|
1
|
+
import { Container as C } from "@pixi/display";
|
|
2
2
|
import { Application as M } from "@pixi/app";
|
|
3
3
|
import { BlurFilter as y } from "@pixi/filter-blur";
|
|
4
4
|
import { ColorMatrixFilter as E } from "@pixi/filter-color-matrix";
|
|
5
|
-
import { Texture as
|
|
6
|
-
import { Sprite as
|
|
7
|
-
import { create as
|
|
5
|
+
import { Texture as z } from "@pixi/core";
|
|
6
|
+
import { Sprite as w } from "@pixi/sprite";
|
|
7
|
+
import { create as D } from "jss";
|
|
8
8
|
import A from "jss-preset-default";
|
|
9
|
-
const
|
|
10
|
-
function T(
|
|
11
|
-
const e =
|
|
9
|
+
const I = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
|
|
10
|
+
function T(h) {
|
|
11
|
+
const e = I.exec(h);
|
|
12
12
|
if (e) {
|
|
13
|
-
const t = Number(e.groups?.hour || "0"),
|
|
14
|
-
return Math.floor((t * 3600 +
|
|
13
|
+
const t = Number(e.groups?.hour || "0"), n = Number(e.groups?.min || "0"), i = Number(e.groups?.sec.replace(/:/, ".") || "0");
|
|
14
|
+
return Math.floor((t * 3600 + n * 60 + i) * 1e3);
|
|
15
15
|
} else
|
|
16
16
|
throw new TypeError("时间戳字符串解析失败");
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function B(h) {
|
|
19
19
|
const t = new DOMParser().parseFromString(
|
|
20
|
-
|
|
20
|
+
h,
|
|
21
21
|
"application/xml"
|
|
22
22
|
);
|
|
23
|
-
let
|
|
24
|
-
for (const
|
|
25
|
-
if (
|
|
26
|
-
const s =
|
|
27
|
-
s && (
|
|
23
|
+
let n = "v1";
|
|
24
|
+
for (const l of t.querySelectorAll("ttm\\:agent"))
|
|
25
|
+
if (l.getAttribute("type") === "person") {
|
|
26
|
+
const s = l.getAttribute("xml:id");
|
|
27
|
+
s && (n = s);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
for (const
|
|
29
|
+
const i = [];
|
|
30
|
+
for (const l of t.querySelectorAll("body p[begin][end]")) {
|
|
31
31
|
const s = {
|
|
32
32
|
words: [],
|
|
33
|
-
startTime: T(
|
|
34
|
-
endTime: T(
|
|
33
|
+
startTime: T(l.getAttribute("begin") ?? "0:0"),
|
|
34
|
+
endTime: T(l.getAttribute("end") ?? "0:0"),
|
|
35
35
|
translatedLyric: "",
|
|
36
36
|
romanLyric: "",
|
|
37
37
|
isBG: !1,
|
|
38
|
-
isDuet:
|
|
38
|
+
isDuet: l.getAttribute("ttm:agent") !== n
|
|
39
39
|
};
|
|
40
40
|
let r = null;
|
|
41
|
-
for (const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
/^(\s+)$/.test(
|
|
41
|
+
for (const a of l.childNodes)
|
|
42
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
43
|
+
const o = a.textContent ?? "";
|
|
44
|
+
/^(\s+)$/.test(o) ? s.words.push({
|
|
45
45
|
word: " ",
|
|
46
46
|
startTime: 0,
|
|
47
47
|
endTime: 0
|
|
48
48
|
}) : s.words.push({
|
|
49
|
-
word:
|
|
49
|
+
word: o,
|
|
50
50
|
startTime: 0,
|
|
51
51
|
endTime: 0
|
|
52
52
|
});
|
|
53
|
-
} else if (
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
53
|
+
} else if (a.nodeType === Node.ELEMENT_NODE) {
|
|
54
|
+
const o = a, c = o.getAttribute("ttm:role");
|
|
55
|
+
if (o.nodeName === "span" && c)
|
|
56
|
+
if (c === "x-bg") {
|
|
57
|
+
const d = {
|
|
58
58
|
words: [],
|
|
59
59
|
startTime: s.startTime,
|
|
60
60
|
endTime: s.endTime,
|
|
@@ -63,70 +63,70 @@ function I(d) {
|
|
|
63
63
|
isBG: !0,
|
|
64
64
|
isDuet: s.isDuet
|
|
65
65
|
};
|
|
66
|
-
for (const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
/^(\s+)$/.test(
|
|
66
|
+
for (const m of o.childNodes)
|
|
67
|
+
if (m.nodeType === Node.TEXT_NODE) {
|
|
68
|
+
const p = m.textContent ?? "";
|
|
69
|
+
/^(\s+)$/.test(p) ? d.words.push({
|
|
70
70
|
word: " ",
|
|
71
71
|
startTime: 0,
|
|
72
72
|
endTime: 0
|
|
73
|
-
}) :
|
|
74
|
-
word:
|
|
73
|
+
}) : d.words.push({
|
|
74
|
+
word: p,
|
|
75
75
|
startTime: 0,
|
|
76
76
|
endTime: 0
|
|
77
77
|
});
|
|
78
|
-
} else if (
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
else if (
|
|
83
|
-
const
|
|
84
|
-
word:
|
|
85
|
-
startTime: T(
|
|
86
|
-
endTime: T(
|
|
78
|
+
} else if (m.nodeType === Node.ELEMENT_NODE) {
|
|
79
|
+
const p = m, L = p.getAttribute("ttm:role");
|
|
80
|
+
if (p.nodeName === "span" && L)
|
|
81
|
+
L === "x-translation" ? d.translatedLyric = p.innerHTML.trim() : L === "x-roman" && (d.romanLyric = p.innerHTML.trim());
|
|
82
|
+
else if (p.hasAttribute("begin") && p.hasAttribute("end")) {
|
|
83
|
+
const b = {
|
|
84
|
+
word: m.textContent,
|
|
85
|
+
startTime: T(p.getAttribute("begin")),
|
|
86
|
+
endTime: T(p.getAttribute("end"))
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
d.words.push(b);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
91
|
+
const u = d.words[0];
|
|
92
|
+
d.startTime = u.startTime, u?.word.startsWith("(") && (u.word = u.word.substring(1));
|
|
93
|
+
const f = d.words[d.words.length - 1];
|
|
94
|
+
d.endTime = f.endTime, f?.word.endsWith(")") && (f.word = f.word.substring(
|
|
95
95
|
0,
|
|
96
|
-
|
|
97
|
-
)), r =
|
|
96
|
+
f.word.length - 1
|
|
97
|
+
)), r = d;
|
|
98
98
|
} else
|
|
99
|
-
|
|
100
|
-
else if (
|
|
101
|
-
const
|
|
102
|
-
word:
|
|
103
|
-
startTime: T(
|
|
104
|
-
endTime: T(
|
|
99
|
+
c === "x-translation" ? s.translatedLyric = o.innerHTML : c === "x-roman" && (s.romanLyric = o.innerHTML);
|
|
100
|
+
else if (o.hasAttribute("begin") && o.hasAttribute("end")) {
|
|
101
|
+
const d = {
|
|
102
|
+
word: a.textContent ?? "",
|
|
103
|
+
startTime: T(o.getAttribute("begin")),
|
|
104
|
+
endTime: T(o.getAttribute("end"))
|
|
105
105
|
};
|
|
106
|
-
s.words.push(
|
|
106
|
+
s.words.push(d);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
i.push(s), r && i.push(r);
|
|
110
110
|
}
|
|
111
|
-
return
|
|
111
|
+
return i;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
114
114
|
__proto__: null,
|
|
115
|
-
parseTTML:
|
|
115
|
+
parseTTML: B
|
|
116
116
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
117
|
-
class
|
|
117
|
+
class k extends C {
|
|
118
118
|
time = 0;
|
|
119
119
|
}
|
|
120
|
-
class
|
|
120
|
+
class N {
|
|
121
121
|
constructor(e) {
|
|
122
122
|
this.canvas = e;
|
|
123
123
|
const t = e.getBoundingClientRect();
|
|
124
124
|
this.canvas.width = t.width * this.currerntRenderScale, this.canvas.height = t.height * this.currerntRenderScale, this.observer = new ResizeObserver(() => {
|
|
125
|
-
const
|
|
126
|
-
this.canvas.width = Math.max(1,
|
|
125
|
+
const n = e.getBoundingClientRect();
|
|
126
|
+
this.canvas.width = Math.max(1, n.width), this.canvas.height = Math.max(1, n.height), this.app.renderer.resize(
|
|
127
127
|
this.canvas.width * this.currerntRenderScale,
|
|
128
128
|
this.canvas.height * this.currerntRenderScale
|
|
129
|
-
), this.rebuildFilters();
|
|
129
|
+
), this.app.ticker.start(), this.rebuildFilters();
|
|
130
130
|
}), this.observer.observe(e), this.app = new M({
|
|
131
131
|
view: e,
|
|
132
132
|
resizeTo: this.canvas,
|
|
@@ -137,6 +137,7 @@ class k {
|
|
|
137
137
|
observer;
|
|
138
138
|
app;
|
|
139
139
|
curContainer;
|
|
140
|
+
staticMode = !1;
|
|
140
141
|
lastContainer = /* @__PURE__ */ new Set();
|
|
141
142
|
onTick = (e) => {
|
|
142
143
|
for (const t of this.lastContainer)
|
|
@@ -146,11 +147,11 @@ class k {
|
|
|
146
147
|
1,
|
|
147
148
|
this.curContainer.alpha + e / 60
|
|
148
149
|
);
|
|
149
|
-
const [t,
|
|
150
|
-
t.position.set(this.app.screen.width / 2, this.app.screen.height / 2),
|
|
150
|
+
const [t, n, i, l] = this.curContainer.children, s = Math.max(this.app.screen.width, this.app.screen.height);
|
|
151
|
+
t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), n.position.set(
|
|
151
152
|
this.app.screen.width / 2.5,
|
|
152
153
|
this.app.screen.height / 2.5
|
|
153
|
-
),
|
|
154
|
+
), i.position.set(this.app.screen.width / 2, this.app.screen.height / 2), l.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = s * Math.sqrt(2), t.height = t.width, n.width = s * 0.8, n.height = n.width, i.width = s * 0.5, i.height = i.width, l.width = s * 0.25, l.height = l.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, n.rotation -= e / 500 * this.flowSpeed, i.rotation += e / 1e3 * this.flowSpeed, l.rotation -= e / 750 * this.flowSpeed, i.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), i.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), l.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), l.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
|
|
154
155
|
}
|
|
155
156
|
};
|
|
156
157
|
flowSpeed = 2;
|
|
@@ -179,10 +180,17 @@ class k {
|
|
|
179
180
|
rebuildFilters() {
|
|
180
181
|
const e = Math.min(this.canvas.width, this.canvas.height), t = new E();
|
|
181
182
|
t.saturate(1.2, !1);
|
|
182
|
-
const i = new E();
|
|
183
|
-
i.brightness(0.6, !1);
|
|
184
183
|
const n = new E();
|
|
185
|
-
n.
|
|
184
|
+
n.brightness(0.6, !1);
|
|
185
|
+
const i = new E();
|
|
186
|
+
i.contrast(0.3, !0), this.app.stage.filters = [], this.app.stage.filters.push(new y(5, 1)), this.app.stage.filters.push(new y(10, 1)), this.app.stage.filters.push(new y(20, 2)), this.app.stage.filters.push(new y(40, 2)), e > 512 && this.app.stage.filters.push(new y(80, 2)), e > 768 && this.app.stage.filters.push(new y(160, 4)), e > 768 * 2 && this.app.stage.filters.push(new y(320, 4)), this.app.stage.filters.push(t, n, i), this.app.stage.filters.push(new y(5, 1));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能
|
|
190
|
+
* @param enable 是否启用静态模式
|
|
191
|
+
*/
|
|
192
|
+
setStaticMode(e = !1) {
|
|
193
|
+
this.staticMode = e, this.app.ticker.start();
|
|
186
194
|
}
|
|
187
195
|
/**
|
|
188
196
|
* 修改背景动画帧率,默认是 30 FPS
|
|
@@ -210,14 +218,14 @@ class k {
|
|
|
210
218
|
* @param albumUrl 图片的目标链接
|
|
211
219
|
*/
|
|
212
220
|
async setAlbumImage(e) {
|
|
213
|
-
const t = await
|
|
214
|
-
|
|
221
|
+
const t = await z.fromURL(e), n = new k(), i = new w(t), l = new w(t), s = new w(t), r = new w(t);
|
|
222
|
+
i.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), s.anchor.set(0.5, 0.5), r.anchor.set(0.5, 0.5), i.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, s.rotation = Math.random() * Math.PI * 2, r.rotation = Math.random() * Math.PI * 2, n.addChild(i, l, s, r), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = n, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
|
|
215
223
|
}
|
|
216
224
|
dispose() {
|
|
217
225
|
this.observer.disconnect(), this.app.ticker.remove(this.onTick);
|
|
218
226
|
}
|
|
219
227
|
}
|
|
220
|
-
class
|
|
228
|
+
class te extends N {
|
|
221
229
|
element;
|
|
222
230
|
constructor() {
|
|
223
231
|
const e = document.createElement("canvas");
|
|
@@ -230,13 +238,140 @@ class Z extends k {
|
|
|
230
238
|
super.dispose(), this.element.remove();
|
|
231
239
|
}
|
|
232
240
|
}
|
|
233
|
-
const
|
|
234
|
-
|
|
241
|
+
const O = (h, e) => h.size === e.size && [...h].every((t) => e.has(t));
|
|
242
|
+
class S {
|
|
243
|
+
currentPosition = 0;
|
|
244
|
+
targetPosition = 0;
|
|
245
|
+
currentTime = 0;
|
|
246
|
+
params = {};
|
|
247
|
+
currentSolver;
|
|
248
|
+
getV;
|
|
249
|
+
queueParams;
|
|
250
|
+
queuePosition;
|
|
251
|
+
constructor(e = 0) {
|
|
252
|
+
this.targetPosition = e, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
|
|
253
|
+
}
|
|
254
|
+
resetSolver() {
|
|
255
|
+
const e = this.getV(this.currentTime);
|
|
256
|
+
this.currentTime = 0, this.currentSolver = $(
|
|
257
|
+
this.currentPosition,
|
|
258
|
+
e,
|
|
259
|
+
this.targetPosition,
|
|
260
|
+
0,
|
|
261
|
+
this.params
|
|
262
|
+
), this.getV = q(this.currentSolver);
|
|
263
|
+
}
|
|
264
|
+
arrived() {
|
|
265
|
+
return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
|
|
266
|
+
}
|
|
267
|
+
setPosition(e) {
|
|
268
|
+
this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
|
|
269
|
+
}
|
|
270
|
+
update(e = 0) {
|
|
271
|
+
this.currentTime += e, this.currentPosition = this.currentSolver(this.currentTime), this.queueParams && (this.queueParams.time -= e, this.queueParams.time <= 0 && this.updateParams({
|
|
272
|
+
...this.queueParams
|
|
273
|
+
})), this.queuePosition && (this.queuePosition.time -= e, this.queuePosition.time <= 0 && this.setTargetPosition(this.queuePosition.position)), this.arrived() && this.setPosition(this.targetPosition);
|
|
274
|
+
}
|
|
275
|
+
updateParams(e, t = 0) {
|
|
276
|
+
t > 0 ? this.queueParams = {
|
|
277
|
+
...e,
|
|
278
|
+
time: t
|
|
279
|
+
} : (this.params = {
|
|
280
|
+
...this.params,
|
|
281
|
+
...e
|
|
282
|
+
}, this.resetSolver());
|
|
283
|
+
}
|
|
284
|
+
setTargetPosition(e, t = 0) {
|
|
285
|
+
t > 0 ? this.queuePosition = {
|
|
286
|
+
position: e,
|
|
287
|
+
time: t
|
|
288
|
+
} : (this.queuePosition = void 0, this.targetPosition = e, this.resetSolver());
|
|
289
|
+
}
|
|
290
|
+
getCurrentPosition() {
|
|
291
|
+
return this.currentPosition;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function $(h, e, t, n = 0, i) {
|
|
295
|
+
const l = i?.soft ?? !1, s = i?.stiffness ?? 100, r = i?.damping ?? 10, a = i?.mass ?? 1, o = t - h;
|
|
296
|
+
if (l || 1 <= r / (2 * Math.sqrt(s * a))) {
|
|
297
|
+
const c = -Math.sqrt(s / a), d = -c * o - e;
|
|
298
|
+
return (u) => (u -= n, u < 0 ? h : t - (o + u * d) * Math.E ** (u * c));
|
|
299
|
+
} else {
|
|
300
|
+
const c = Math.sqrt(
|
|
301
|
+
4 * a * s - r ** 2
|
|
302
|
+
), d = (r * o - 2 * a * e) / c, u = 0.5 * c / a, f = -(0.5 * r) / a;
|
|
303
|
+
return (m) => (m -= n, m < 0 ? h : t - (Math.cos(m * u) * o + Math.sin(m * u) * d) * Math.E ** (m * f));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function _(h) {
|
|
307
|
+
return (t) => (h(t + 1e-3) - h(t - 1e-3)) / (2 * 1e-3);
|
|
308
|
+
}
|
|
309
|
+
function q(h) {
|
|
310
|
+
return _(h);
|
|
311
|
+
}
|
|
312
|
+
class F {
|
|
313
|
+
constructor(e) {
|
|
314
|
+
this.lyricPlayer = e, this.element.setAttribute(
|
|
315
|
+
"class",
|
|
316
|
+
this.lyricPlayer.style.classes.lyricLine
|
|
317
|
+
), this.rebuildStyle();
|
|
318
|
+
}
|
|
319
|
+
element = document.createElement("div");
|
|
320
|
+
left = 0;
|
|
321
|
+
top = 0;
|
|
322
|
+
delay = 0;
|
|
323
|
+
// 由 LyricPlayer 来设置
|
|
324
|
+
lineSize = [0, 0];
|
|
325
|
+
lineTransforms = {
|
|
326
|
+
posX: new S(0),
|
|
327
|
+
posY: new S(0)
|
|
328
|
+
};
|
|
329
|
+
measureSize() {
|
|
330
|
+
return [
|
|
331
|
+
this.element.clientWidth,
|
|
332
|
+
this.element.clientHeight
|
|
333
|
+
];
|
|
334
|
+
}
|
|
335
|
+
lastStyle = "";
|
|
336
|
+
show() {
|
|
337
|
+
this.rebuildStyle();
|
|
338
|
+
}
|
|
339
|
+
hide() {
|
|
340
|
+
this.rebuildStyle();
|
|
341
|
+
}
|
|
342
|
+
rebuildStyle() {
|
|
343
|
+
let e = `transform:translate(${this.lineTransforms.posX.getCurrentPosition()}px,${this.lineTransforms.posY.getCurrentPosition()}px);`;
|
|
344
|
+
!this.lyricPlayer.getEnableSpring() && this.isInSight && (e += `transition-delay:${this.delay}ms;`), e !== this.lastStyle && (this.lastStyle = e, this.element.setAttribute("style", e));
|
|
345
|
+
}
|
|
346
|
+
getElement() {
|
|
347
|
+
return this.element;
|
|
348
|
+
}
|
|
349
|
+
setTransform(e = this.left, t = this.top, n = !1, i = 0) {
|
|
350
|
+
this.left = e, this.top = t, this.delay = i * 1e3 | 0, n || !this.lyricPlayer.getEnableSpring() ? (n && this.element.classList.add(
|
|
351
|
+
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
352
|
+
), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), n && requestAnimationFrame(() => {
|
|
353
|
+
this.element.classList.remove(
|
|
354
|
+
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
355
|
+
);
|
|
356
|
+
})) : (this.lineTransforms.posX.setTargetPosition(e, i), this.lineTransforms.posY.setTargetPosition(t, i));
|
|
357
|
+
}
|
|
358
|
+
update(e = 0) {
|
|
359
|
+
this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.isInSight ? this.show() : this.hide());
|
|
360
|
+
}
|
|
361
|
+
get isInSight() {
|
|
362
|
+
const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
|
|
363
|
+
return !(e > r || t > a || n < l || i < s);
|
|
364
|
+
}
|
|
365
|
+
dispose() {
|
|
366
|
+
this.element.remove();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function X(h) {
|
|
235
370
|
const t = 2.5949095;
|
|
236
|
-
return
|
|
371
|
+
return h < 0.5 ? Math.pow(2 * h, 2) * ((t + 1) * 2 * h - t) / 2 : (Math.pow(2 * h - 2, 2) * ((t + 1) * (h * 2 - 2) + t) + 2) / 2;
|
|
237
372
|
}
|
|
238
|
-
const g = (
|
|
239
|
-
class
|
|
373
|
+
const g = (h, e, t) => Math.max(h, Math.min(e, t));
|
|
374
|
+
class R {
|
|
240
375
|
constructor(e) {
|
|
241
376
|
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);
|
|
242
377
|
}
|
|
@@ -264,41 +399,41 @@ class $ {
|
|
|
264
399
|
this.currentTime += e;
|
|
265
400
|
let t = "";
|
|
266
401
|
if (t += `transform:translate(${this.left}px, ${this.top}px)`, this.currentInterlude) {
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
402
|
+
const n = this.currentInterlude[1] - this.currentInterlude[0], i = this.currentTime - this.currentInterlude[0];
|
|
403
|
+
if (i <= n) {
|
|
404
|
+
const l = n / Math.ceil(n / this.targetBreatheDuration);
|
|
270
405
|
let s = 1, r = 1;
|
|
271
|
-
s *= Math.sin(1.5 * Math.PI -
|
|
272
|
-
(750 - (
|
|
273
|
-
)),
|
|
406
|
+
s *= Math.sin(1.5 * Math.PI - i / l * 2) / 10 + 1, i < 1e3 && (s *= 1 - Math.pow((1e3 - i) / 1e3, 2)), i < 500 ? r = 0 : i < 1e3 && (r *= (i - 500) / 500), n - i < 750 && (s *= 1 - X(
|
|
407
|
+
(750 - (n - i)) / 750 / 2
|
|
408
|
+
)), n - i < 375 && (r *= g(
|
|
274
409
|
0,
|
|
275
|
-
(
|
|
410
|
+
(n - i) / 375,
|
|
276
411
|
1
|
|
277
412
|
)), s = Math.max(0, s), t += ` scale(${s})`;
|
|
278
|
-
const
|
|
413
|
+
const a = g(
|
|
279
414
|
0.25,
|
|
280
|
-
|
|
415
|
+
i * 3 / n * 0.75,
|
|
281
416
|
1
|
|
282
|
-
),
|
|
417
|
+
), o = g(
|
|
283
418
|
0.25,
|
|
284
|
-
(
|
|
419
|
+
(i - n / 3) * 3 / n * 0.75,
|
|
285
420
|
1
|
|
286
|
-
),
|
|
421
|
+
), c = g(
|
|
287
422
|
0.25,
|
|
288
|
-
(
|
|
423
|
+
(i - n / 3 * 2) * 3 / n * 0.75,
|
|
289
424
|
1
|
|
290
425
|
);
|
|
291
426
|
this.dot0.style.opacity = `${g(
|
|
292
427
|
0,
|
|
293
|
-
Math.max(0, r *
|
|
428
|
+
Math.max(0, r * a),
|
|
294
429
|
1
|
|
295
430
|
)}`, this.dot1.style.opacity = `${g(
|
|
296
431
|
0,
|
|
297
|
-
Math.max(0, r *
|
|
432
|
+
Math.max(0, r * o),
|
|
298
433
|
1
|
|
299
434
|
)}`, this.dot2.style.opacity = `${g(
|
|
300
435
|
0,
|
|
301
|
-
Math.max(0, r *
|
|
436
|
+
Math.max(0, r * c),
|
|
302
437
|
1
|
|
303
438
|
)}`;
|
|
304
439
|
} else
|
|
@@ -311,89 +446,19 @@ class $ {
|
|
|
311
446
|
this.element.remove();
|
|
312
447
|
}
|
|
313
448
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
currentTime = 0;
|
|
318
|
-
params = {};
|
|
319
|
-
currentSolver;
|
|
320
|
-
getV;
|
|
321
|
-
queueParams;
|
|
322
|
-
queuePosition;
|
|
323
|
-
constructor(e = 0) {
|
|
324
|
-
this.targetPosition = e, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
|
|
325
|
-
}
|
|
326
|
-
resetSolver() {
|
|
327
|
-
const e = this.getV(this.currentTime);
|
|
328
|
-
this.currentTime = 0, this.currentSolver = q(
|
|
329
|
-
this.currentPosition,
|
|
330
|
-
e,
|
|
331
|
-
this.targetPosition,
|
|
332
|
-
0,
|
|
333
|
-
this.params
|
|
334
|
-
), this.getV = R(this.currentSolver);
|
|
335
|
-
}
|
|
336
|
-
arrived() {
|
|
337
|
-
return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
|
|
338
|
-
}
|
|
339
|
-
setPosition(e) {
|
|
340
|
-
this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
|
|
341
|
-
}
|
|
342
|
-
update(e = 0) {
|
|
343
|
-
this.currentTime += e, this.currentPosition = this.currentSolver(this.currentTime), this.queueParams && (this.queueParams.time -= e, this.queueParams.time <= 0 && this.updateParams({
|
|
344
|
-
...this.queueParams
|
|
345
|
-
})), this.queuePosition && (this.queuePosition.time -= e, this.queuePosition.time <= 0 && this.setTargetPosition(this.queuePosition.position)), this.arrived() && this.setPosition(this.targetPosition);
|
|
346
|
-
}
|
|
347
|
-
updateParams(e, t = 0) {
|
|
348
|
-
t > 0 ? this.queueParams = {
|
|
349
|
-
...e,
|
|
350
|
-
time: t
|
|
351
|
-
} : (this.params = {
|
|
352
|
-
...this.params,
|
|
353
|
-
...e
|
|
354
|
-
}, this.resetSolver());
|
|
355
|
-
}
|
|
356
|
-
setTargetPosition(e, t = 0) {
|
|
357
|
-
t > 0 ? this.queuePosition = {
|
|
358
|
-
position: e,
|
|
359
|
-
time: t
|
|
360
|
-
} : (this.queuePosition = void 0, this.targetPosition = e, this.resetSolver());
|
|
361
|
-
}
|
|
362
|
-
getCurrentPosition() {
|
|
363
|
-
return this.currentPosition;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
function q(d, e, t, i = 0, n) {
|
|
367
|
-
const a = n?.soft ?? !1, s = n?.stiffness ?? 100, r = n?.damping ?? 10, l = n?.mass ?? 1, h = t - d;
|
|
368
|
-
if (a || 1 <= r / (2 * Math.sqrt(s * l))) {
|
|
369
|
-
const o = -Math.sqrt(s / l), c = -o * h - e;
|
|
370
|
-
return (m) => (m -= i, m < 0 ? d : t - (h + m * c) * Math.E ** (m * o));
|
|
371
|
-
} else {
|
|
372
|
-
const o = Math.sqrt(
|
|
373
|
-
4 * l * s - r ** 2
|
|
374
|
-
), c = (r * h - 2 * l * e) / o, m = 0.5 * o / l, p = -(0.5 * r) / l;
|
|
375
|
-
return (u) => (u -= i, u < 0 ? d : t - (Math.cos(u * m) * h + Math.sin(u * m) * c) * Math.E ** (u * p));
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function F(d) {
|
|
379
|
-
return (t) => (d(t + 1e-3) - d(t - 1e-3)) / (2 * 1e-3);
|
|
380
|
-
}
|
|
381
|
-
function R(d) {
|
|
382
|
-
return F(d);
|
|
383
|
-
}
|
|
384
|
-
const w = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
|
|
385
|
-
function W(d, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
|
|
386
|
-
const i = 2 + d, n = d / i, a = (1 - n) / 2;
|
|
449
|
+
const v = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
|
|
450
|
+
function W(h, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
|
|
451
|
+
const n = 2 + h, i = h / n, l = (1 - i) / 2;
|
|
387
452
|
return [
|
|
388
|
-
`linear-gradient(to right,${e} ${
|
|
389
|
-
|
|
390
|
-
|
|
453
|
+
`linear-gradient(to right,${e} ${l * 100}%,${t} ${(l + i) * 100}%)`,
|
|
454
|
+
i,
|
|
455
|
+
n
|
|
391
456
|
];
|
|
392
457
|
}
|
|
393
|
-
function
|
|
394
|
-
return
|
|
458
|
+
function x(h) {
|
|
459
|
+
return h.endTime - h.startTime >= 1e3 && h.word.length <= 7;
|
|
395
460
|
}
|
|
396
|
-
class
|
|
461
|
+
class Y {
|
|
397
462
|
constructor(e, t = {
|
|
398
463
|
words: [],
|
|
399
464
|
translatedLyric: "",
|
|
@@ -407,8 +472,8 @@ class _ {
|
|
|
407
472
|
"class",
|
|
408
473
|
this.lyricPlayer.style.classes.lyricLine
|
|
409
474
|
), this.lyricLine.isBG && this.element.classList.add(this.lyricPlayer.style.classes.lyricBgLine), this.lyricLine.isDuet && this.element.classList.add(this.lyricPlayer.style.classes.lyricDuetLine), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div"));
|
|
410
|
-
const
|
|
411
|
-
|
|
475
|
+
const n = this.element.children[0], i = this.element.children[1], l = this.element.children[2];
|
|
476
|
+
n.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), i.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), l.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
|
|
412
477
|
}
|
|
413
478
|
element = document.createElement("div");
|
|
414
479
|
left = 0;
|
|
@@ -429,8 +494,8 @@ class _ {
|
|
|
429
494
|
this.isEnabled = !0, this.element.classList.add("active");
|
|
430
495
|
const e = this.element.children[0];
|
|
431
496
|
this.splittedWords.forEach((t) => {
|
|
432
|
-
t.elementAnimations.forEach((
|
|
433
|
-
|
|
497
|
+
t.elementAnimations.forEach((n) => {
|
|
498
|
+
n.currentTime = 0, n.playbackRate = 1, n.play();
|
|
434
499
|
});
|
|
435
500
|
}), e.classList.add("active");
|
|
436
501
|
}
|
|
@@ -446,8 +511,8 @@ class _ {
|
|
|
446
511
|
this.isEnabled = !1, this.element.classList.remove("active");
|
|
447
512
|
const e = this.element.children[0];
|
|
448
513
|
this.splittedWords.forEach((t) => {
|
|
449
|
-
t.elementAnimations.forEach((
|
|
450
|
-
|
|
514
|
+
t.elementAnimations.forEach((n) => {
|
|
515
|
+
n.id === "float-word" && (n.playbackRate = -1, n.play());
|
|
451
516
|
});
|
|
452
517
|
}), e.classList.remove("active");
|
|
453
518
|
}
|
|
@@ -479,12 +544,18 @@ class _ {
|
|
|
479
544
|
!this.lyricPlayer.getEnableSpring() && this.isInSight && (e += `transition-delay:${this.delay}ms;`), e += `filter:blur(${Math.min(32, this.blur)}px);`, e !== this.lastStyle && (this.lastStyle = e, this.element.setAttribute("style", e));
|
|
480
545
|
}
|
|
481
546
|
rebuildElement() {
|
|
482
|
-
const e = this.element.children[0], t = this.element.children[1],
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
547
|
+
const e = this.element.children[0], t = this.element.children[1], n = this.element.children[2];
|
|
548
|
+
if (this.lyricPlayer._getIsNonDynamic()) {
|
|
549
|
+
for (; e.firstChild; )
|
|
550
|
+
e.removeChild(e.firstChild), s(e.firstChild);
|
|
551
|
+
e.innerText = this.lyricLine.words.map((a) => a.word).join(""), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
this.splittedWords = [], this.lyricLine.words.forEach((a) => {
|
|
555
|
+
const o = a.word.split(/\s+/), c = o.reduce((u, f) => u + f.length, 0);
|
|
556
|
+
let d = 0;
|
|
557
|
+
o.forEach((u, f) => {
|
|
558
|
+
f > 0 && this.splittedWords.push({
|
|
488
559
|
word: " ",
|
|
489
560
|
startTime: 0,
|
|
490
561
|
endTime: 0,
|
|
@@ -494,63 +565,63 @@ class _ {
|
|
|
494
565
|
elementAnimations: [],
|
|
495
566
|
shouldEmphasize: !1
|
|
496
567
|
}), this.splittedWords.push({
|
|
497
|
-
word:
|
|
498
|
-
startTime:
|
|
499
|
-
endTime:
|
|
568
|
+
word: u,
|
|
569
|
+
startTime: a.startTime + (a.endTime - a.startTime) / c * d,
|
|
570
|
+
endTime: a.startTime + (a.endTime - a.startTime) / c * (d + u.length),
|
|
500
571
|
width: 0,
|
|
501
572
|
height: 0,
|
|
502
573
|
elements: [],
|
|
503
574
|
elementAnimations: [],
|
|
504
|
-
shouldEmphasize:
|
|
505
|
-
}),
|
|
575
|
+
shouldEmphasize: x(a)
|
|
576
|
+
}), d += u.length;
|
|
506
577
|
});
|
|
507
578
|
});
|
|
508
|
-
const
|
|
509
|
-
function s(
|
|
510
|
-
for (;
|
|
511
|
-
|
|
579
|
+
const i = [], l = [];
|
|
580
|
+
function s(a) {
|
|
581
|
+
for (; a.firstChild; )
|
|
582
|
+
a.firstChild.nodeType === Node.ELEMENT_NODE ? i.push(e.firstChild) : a.firstChild.nodeType === Node.TEXT_NODE && l.push(e.firstChild), a.removeChild(a.firstChild), s(a.firstChild);
|
|
512
583
|
}
|
|
513
584
|
s(e);
|
|
514
585
|
let r = null;
|
|
515
|
-
this.splittedWords.forEach((
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
for (const
|
|
521
|
-
const
|
|
522
|
-
|
|
586
|
+
this.splittedWords.forEach((a) => {
|
|
587
|
+
if (a.word.trim().length > 0)
|
|
588
|
+
if (a.shouldEmphasize) {
|
|
589
|
+
const o = i.pop() ?? document.createElement("span");
|
|
590
|
+
o.className = "emphasize", a.elements = [o];
|
|
591
|
+
for (const c of a.word) {
|
|
592
|
+
const d = i.pop() ?? document.createElement("span");
|
|
593
|
+
d.className = "", d.innerText = c, o.appendChild(d), a.elements.push(d);
|
|
523
594
|
}
|
|
524
|
-
if (
|
|
595
|
+
if (a.elementAnimations = this.initEmphasizeAnimation(a), r && !v.test(a.word))
|
|
525
596
|
if (r.childElementCount > 0)
|
|
526
|
-
r.appendChild(
|
|
597
|
+
r.appendChild(o);
|
|
527
598
|
else {
|
|
528
|
-
const
|
|
529
|
-
|
|
599
|
+
const c = i.pop() ?? document.createElement("span");
|
|
600
|
+
c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
|
|
530
601
|
}
|
|
531
602
|
else
|
|
532
|
-
r =
|
|
603
|
+
r = v.test(a.word) ? null : o, e.appendChild(o);
|
|
533
604
|
} else {
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
605
|
+
const o = i.pop() ?? document.createElement("span");
|
|
606
|
+
if (o.className = "", o.innerText = a.word, a.elements = [o], a.elementAnimations.push(this.initFloatAnimation(a, o)), r)
|
|
536
607
|
if (r.childElementCount > 0)
|
|
537
|
-
r.appendChild(
|
|
608
|
+
r.appendChild(o);
|
|
538
609
|
else {
|
|
539
|
-
const
|
|
540
|
-
|
|
610
|
+
const c = i.pop() ?? document.createElement("span");
|
|
611
|
+
c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
|
|
541
612
|
}
|
|
542
613
|
else
|
|
543
|
-
r =
|
|
614
|
+
r = o, e.appendChild(o);
|
|
544
615
|
}
|
|
545
|
-
else if (
|
|
546
|
-
const
|
|
547
|
-
e.appendChild(
|
|
616
|
+
else if (a.word.length > 0) {
|
|
617
|
+
const o = l.pop() ?? document.createTextNode(" ");
|
|
618
|
+
e.appendChild(o), r = null;
|
|
548
619
|
} else
|
|
549
620
|
r = null;
|
|
550
|
-
}), t.innerText = this.lyricLine.translatedLyric,
|
|
621
|
+
}), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
|
|
551
622
|
}
|
|
552
623
|
initFloatAnimation(e, t) {
|
|
553
|
-
const
|
|
624
|
+
const n = e.startTime - this.lyricLine.startTime, i = Math.max(1e3, e.endTime - e.startTime), l = t.animate(
|
|
554
625
|
[
|
|
555
626
|
{
|
|
556
627
|
transform: "translateY(0px)"
|
|
@@ -560,49 +631,49 @@ class _ {
|
|
|
560
631
|
}
|
|
561
632
|
],
|
|
562
633
|
{
|
|
563
|
-
duration: isFinite(
|
|
564
|
-
delay: isFinite(
|
|
634
|
+
duration: isFinite(i) ? i : 0,
|
|
635
|
+
delay: isFinite(n) ? n : 0,
|
|
565
636
|
id: "float-word",
|
|
566
637
|
composite: "add",
|
|
567
638
|
fill: "both"
|
|
568
639
|
}
|
|
569
640
|
);
|
|
570
|
-
return
|
|
641
|
+
return l.pause(), l;
|
|
571
642
|
}
|
|
572
643
|
initEmphasizeAnimation(e) {
|
|
573
|
-
const t = e.startTime - this.lyricLine.startTime,
|
|
574
|
-
return e.elements.map((
|
|
575
|
-
if (
|
|
576
|
-
return this.initFloatAnimation(e,
|
|
644
|
+
const t = e.startTime - this.lyricLine.startTime, n = e.endTime - e.startTime;
|
|
645
|
+
return e.elements.map((i, l, s) => {
|
|
646
|
+
if (l === 0)
|
|
647
|
+
return this.initFloatAnimation(e, i);
|
|
577
648
|
{
|
|
578
|
-
const r = n.animate(
|
|
649
|
+
const r = Math.max(1e3, e.endTime - e.startTime), a = t + n / (s.length - 1) * (l - 1), o = i.animate(
|
|
579
650
|
[
|
|
580
651
|
{
|
|
581
652
|
offset: 0,
|
|
582
653
|
transform: "translate3d(0, 0px, 0px)",
|
|
583
|
-
filter: "drop-shadow(0 0 0 var(--amll-lyric-
|
|
654
|
+
filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
|
|
584
655
|
},
|
|
585
656
|
{
|
|
586
657
|
offset: 0.5,
|
|
587
658
|
transform: "translate3d(0, -2%, 20px)",
|
|
588
|
-
filter: "drop-shadow(0 0 0.
|
|
659
|
+
filter: "drop-shadow(0 0 0.05em var(--amll-lyric-view-color,white))"
|
|
589
660
|
},
|
|
590
661
|
{
|
|
591
662
|
offset: 1,
|
|
592
663
|
transform: "translate3d(0, 0px, 0)",
|
|
593
|
-
filter: "drop-shadow(0 0 0 var(--amll-lyric-
|
|
664
|
+
filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
|
|
594
665
|
}
|
|
595
666
|
],
|
|
596
667
|
{
|
|
597
|
-
duration:
|
|
598
|
-
delay:
|
|
668
|
+
duration: isFinite(r) ? r : 0,
|
|
669
|
+
delay: isFinite(a) ? a : 0,
|
|
599
670
|
id: "glow-word",
|
|
600
671
|
iterations: 1,
|
|
601
672
|
composite: "replace",
|
|
602
673
|
fill: "both"
|
|
603
674
|
}
|
|
604
675
|
);
|
|
605
|
-
return
|
|
676
|
+
return o.pause(), o;
|
|
606
677
|
}
|
|
607
678
|
});
|
|
608
679
|
}
|
|
@@ -611,44 +682,44 @@ class _ {
|
|
|
611
682
|
const t = e.elements[0];
|
|
612
683
|
if (t) {
|
|
613
684
|
e.width = t.clientWidth, e.height = t.clientHeight;
|
|
614
|
-
const [
|
|
685
|
+
const [n, i, l] = W(
|
|
615
686
|
16 / e.width,
|
|
616
687
|
"rgba(0,0,0,0.75)",
|
|
617
688
|
"rgba(0,0,0,0.25)"
|
|
618
|
-
), s = `${
|
|
619
|
-
this.lyricPlayer.supportMaskImage ? (t.style.maskImage =
|
|
620
|
-
const r = e.width + 16,
|
|
621
|
-
t.style.maskPosition =
|
|
689
|
+
), s = `${l * 100}% 100%`;
|
|
690
|
+
this.lyricPlayer.supportMaskImage ? (t.style.maskImage = n, t.style.maskOrigin = "left", t.style.maskSize = s) : (t.style.webkitMaskImage = n, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = s);
|
|
691
|
+
const r = e.width + 16, a = `clamp(${-r}px,calc(${-r}px + (var(--amll-player-time) - ${e.startTime})*${r / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
|
|
692
|
+
t.style.maskPosition = a, t.style.webkitMaskPosition = a;
|
|
622
693
|
}
|
|
623
694
|
}), this._hide && (this.element.style.display = "none", this.element.style.visibility = "");
|
|
624
695
|
}
|
|
625
696
|
getElement() {
|
|
626
697
|
return this.element;
|
|
627
698
|
}
|
|
628
|
-
setTransform(e = this.left, t = this.top,
|
|
629
|
-
this.left = e, this.top = t, this.scale =
|
|
630
|
-
const
|
|
631
|
-
|
|
699
|
+
setTransform(e = this.left, t = this.top, n = this.scale, i = 1, l = 0, s = !1, r = 0) {
|
|
700
|
+
this.left = e, this.top = t, this.scale = n, this.delay = r * 1e3 | 0;
|
|
701
|
+
const a = this.element.children[0];
|
|
702
|
+
a.style.opacity = `${i}`, s || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, l), s && this.element.classList.add(
|
|
632
703
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
633
|
-
), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(
|
|
704
|
+
), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(n), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), s && requestAnimationFrame(() => {
|
|
634
705
|
this.element.classList.remove(
|
|
635
706
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
636
707
|
);
|
|
637
|
-
})) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(
|
|
708
|
+
})) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(n), this.blur !== Math.min(32, l) && (this.blur = Math.min(32, l), this.element.style.filter = `blur(${Math.min(32, l)}px)`));
|
|
638
709
|
}
|
|
639
710
|
update(e = 0) {
|
|
640
711
|
this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.lineTransforms.scale.update(e), this.isInSight ? this.show() : this.hide());
|
|
641
712
|
}
|
|
642
713
|
get isInSight() {
|
|
643
|
-
const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(),
|
|
644
|
-
return !(e > r || t >
|
|
714
|
+
const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
|
|
715
|
+
return !(e > r || t > a || n < l || i < s);
|
|
645
716
|
}
|
|
646
717
|
dispose() {
|
|
647
718
|
this.element.remove();
|
|
648
719
|
}
|
|
649
720
|
}
|
|
650
|
-
const G =
|
|
651
|
-
class
|
|
721
|
+
const G = D(A());
|
|
722
|
+
class ie extends EventTarget {
|
|
652
723
|
element = document.createElement("div");
|
|
653
724
|
currentTime = 0;
|
|
654
725
|
lyricLines = [];
|
|
@@ -658,9 +729,16 @@ class ee extends EventTarget {
|
|
|
658
729
|
hotLines = /* @__PURE__ */ new Set();
|
|
659
730
|
bufferedLines = /* @__PURE__ */ new Set();
|
|
660
731
|
scrollToIndex = 0;
|
|
732
|
+
allowScroll = !0;
|
|
733
|
+
scrolledHandler = 0;
|
|
734
|
+
isScrolled = !1;
|
|
735
|
+
invokedByScrollEvent = !1;
|
|
736
|
+
scrollOffset = 0;
|
|
661
737
|
resizeObserver = new ResizeObserver((e) => {
|
|
662
738
|
const t = e[0].contentRect;
|
|
663
|
-
this.size[0] = t.width, this.size[1] = t.height, this.pos[0] = t.left, this.pos[1] = t.top
|
|
739
|
+
this.size[0] = t.width, this.size[1] = t.height, this.pos[0] = t.left, this.pos[1] = t.top;
|
|
740
|
+
const n = getComputedStyle(e[0].target), i = this.element.clientWidth - parseFloat(n.paddingLeft) - parseFloat(n.paddingRight), l = this.element.clientHeight - parseFloat(n.paddingTop) - parseFloat(n.paddingBottom);
|
|
741
|
+
this.innerSize[0] = i, this.innerSize[1] = l, this.rebuildStyle(), this.calcLayout(!0, !0), this.lyricLinesEl.forEach((s) => s.updateMaskImage());
|
|
664
742
|
});
|
|
665
743
|
posXSpringParams = {
|
|
666
744
|
mass: 1,
|
|
@@ -680,12 +758,19 @@ class ee extends EventTarget {
|
|
|
680
758
|
enableBlur = !0;
|
|
681
759
|
interludeDots;
|
|
682
760
|
interludeDotsSize = [0, 0];
|
|
761
|
+
bottomLine;
|
|
683
762
|
supportPlusLighter = CSS.supports("mix-blend-mode", "plus-lighter");
|
|
684
763
|
supportMaskImage = CSS.supports("mask-image", "none");
|
|
685
764
|
disableSpring = !1;
|
|
686
|
-
alignAnchor =
|
|
765
|
+
alignAnchor = "center";
|
|
766
|
+
alignPosition = 0.5;
|
|
767
|
+
isNonDynamic = !1;
|
|
687
768
|
size = [0, 0];
|
|
769
|
+
innerSize = [0, 0];
|
|
688
770
|
pos = [0, 0];
|
|
771
|
+
_getIsNonDynamic() {
|
|
772
|
+
return this.isNonDynamic;
|
|
773
|
+
}
|
|
689
774
|
/**
|
|
690
775
|
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
691
776
|
*
|
|
@@ -706,34 +791,34 @@ class ee extends EventTarget {
|
|
|
706
791
|
style = G.createStyleSheet({
|
|
707
792
|
lyricPlayer: {
|
|
708
793
|
userSelect: "none",
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
fontWeight: "bold",
|
|
794
|
+
fontSize: "var(--amll-lyric-player-font-size,max(5vh, 12px))",
|
|
795
|
+
padding: "1em",
|
|
796
|
+
margin: "-1em",
|
|
713
797
|
width: "100%",
|
|
714
798
|
height: "100%",
|
|
715
799
|
overflow: "hidden",
|
|
716
800
|
maxWidth: "100%",
|
|
717
801
|
maxHeight: "100%",
|
|
718
802
|
zIndex: 1,
|
|
719
|
-
color: "var(--amll-lyric-
|
|
803
|
+
color: "var(--amll-lyric-view-color,white)",
|
|
720
804
|
mixBlendMode: "plus-lighter",
|
|
721
805
|
contain: "strict"
|
|
722
806
|
},
|
|
723
807
|
lyricLine: {
|
|
724
808
|
position: "absolute",
|
|
725
809
|
transformOrigin: "left",
|
|
726
|
-
maxWidth: "
|
|
727
|
-
|
|
810
|
+
maxWidth: "var(--amll-lyric-player-width,100%)",
|
|
811
|
+
minWidth: "var(--amll-lyric-player-width,100%)",
|
|
812
|
+
width: "var(--amll-lyric-player-width,100%)",
|
|
813
|
+
padding: "2vh 0.05em",
|
|
728
814
|
contain: "content",
|
|
815
|
+
willChange: "filter,transform,opacity",
|
|
729
816
|
transition: "filter 0.25s",
|
|
730
|
-
|
|
817
|
+
boxSizing: "border-box"
|
|
731
818
|
},
|
|
732
819
|
"@media (max-width: 1024px)": {
|
|
733
820
|
lyricLine: {
|
|
734
|
-
|
|
735
|
-
padding: "max(1vh, 1rem) 1rem",
|
|
736
|
-
margin: "0 -1rem"
|
|
821
|
+
padding: "1vh 0"
|
|
737
822
|
}
|
|
738
823
|
},
|
|
739
824
|
lyricDuetLine: {
|
|
@@ -746,27 +831,27 @@ class ee extends EventTarget {
|
|
|
746
831
|
transition: "opacity 0.25s",
|
|
747
832
|
"&.active": {
|
|
748
833
|
transition: "opacity 0.25s 0.25s",
|
|
749
|
-
opacity:
|
|
834
|
+
opacity: 0.75
|
|
750
835
|
}
|
|
751
836
|
},
|
|
752
837
|
lyricMainLine: {
|
|
753
838
|
transition: "opacity 0.3s 0.25s",
|
|
754
|
-
|
|
755
|
-
|
|
839
|
+
willChange: "opacity",
|
|
840
|
+
margin: "-1em",
|
|
841
|
+
padding: "1em",
|
|
756
842
|
"& span": {
|
|
757
|
-
display: "inline-block"
|
|
758
|
-
margin: "-1rem",
|
|
759
|
-
padding: "1rem"
|
|
843
|
+
display: "inline-block"
|
|
760
844
|
},
|
|
761
845
|
"& > span": {
|
|
762
846
|
whiteSpace: "pre-wrap",
|
|
763
847
|
wordBreak: "keep-all",
|
|
764
848
|
maxLines: "1",
|
|
849
|
+
// willChange: "transform,display,mask-image",
|
|
765
850
|
"&.emphasize": {
|
|
766
|
-
margin: "-1rem",
|
|
767
|
-
padding: "1rem",
|
|
768
851
|
transformStyle: "preserve-3d",
|
|
769
|
-
perspective: "50vw"
|
|
852
|
+
perspective: "50vw",
|
|
853
|
+
padding: "1em",
|
|
854
|
+
margin: "-1em"
|
|
770
855
|
}
|
|
771
856
|
}
|
|
772
857
|
},
|
|
@@ -780,23 +865,24 @@ class ee extends EventTarget {
|
|
|
780
865
|
}
|
|
781
866
|
},
|
|
782
867
|
interludeDots: {
|
|
783
|
-
height: "
|
|
868
|
+
height: "clamp(0.5em,1vh,3em)",
|
|
784
869
|
transformOrigin: "center",
|
|
785
870
|
width: "fit-content",
|
|
786
871
|
padding: "2.5% 0",
|
|
787
872
|
position: "absolute",
|
|
788
873
|
display: "flex",
|
|
789
|
-
gap: "0.
|
|
874
|
+
gap: "0.25em",
|
|
875
|
+
left: "1em",
|
|
790
876
|
"& > *": {
|
|
791
|
-
|
|
877
|
+
height: "100%",
|
|
792
878
|
display: "inline-block",
|
|
793
879
|
borderRadius: "50%",
|
|
794
880
|
aspectRatio: "1 / 1",
|
|
795
|
-
backgroundColor: "var(--amll-lyric-
|
|
881
|
+
backgroundColor: "var(--amll-lyric-view-color,white)",
|
|
796
882
|
marginRight: "4px"
|
|
797
883
|
},
|
|
798
884
|
"&.duet": {
|
|
799
|
-
right: "
|
|
885
|
+
right: "1em",
|
|
800
886
|
transformOrigin: "center"
|
|
801
887
|
}
|
|
802
888
|
},
|
|
@@ -810,10 +896,14 @@ class ee extends EventTarget {
|
|
|
810
896
|
}
|
|
811
897
|
});
|
|
812
898
|
onPageShow = () => {
|
|
813
|
-
this.calcLayout(!0);
|
|
899
|
+
this.calcLayout(!0, !0);
|
|
814
900
|
};
|
|
815
901
|
constructor() {
|
|
816
|
-
super(), this.interludeDots = new
|
|
902
|
+
super(), this.interludeDots = new R(this), this.bottomLine = new F(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), this.element.addEventListener("wheel", (e) => {
|
|
903
|
+
this.allowScroll && (this.isScrolled = !0, clearTimeout(this.scrolledHandler), this.scrolledHandler = setTimeout(() => {
|
|
904
|
+
this.isScrolled = !1, this.scrollOffset = 0;
|
|
905
|
+
}, 5e3), this.invokedByScrollEvent = !0, e.deltaMode === e.DOM_DELTA_PIXEL ? (this.scrollOffset += e.deltaY, this.calcLayout(!0)) : (this.scrollOffset += e.deltaY * 50, this.calcLayout(!1)), this.invokedByScrollEvent = !1);
|
|
906
|
+
});
|
|
817
907
|
}
|
|
818
908
|
/**
|
|
819
909
|
* 获取当前播放时间里是否处于间奏区间
|
|
@@ -821,7 +911,7 @@ class ee extends EventTarget {
|
|
|
821
911
|
* 否则返回 undefined
|
|
822
912
|
*
|
|
823
913
|
* 这个只允许内部调用
|
|
824
|
-
* @returns [
|
|
914
|
+
* @returns [开始时间,结束时间,大概处于的歌词行ID,下一句是否为对唱歌词] 或 undefined 如果不处于间奏区间
|
|
825
915
|
*/
|
|
826
916
|
getCurrentInterlude() {
|
|
827
917
|
if (this.bufferedLines.size > 0)
|
|
@@ -829,12 +919,18 @@ class ee extends EventTarget {
|
|
|
829
919
|
const e = this.currentTime + 20, t = this.scrollToIndex;
|
|
830
920
|
if (t === 0) {
|
|
831
921
|
if (this.processedLines[0]?.startTime && this.processedLines[0].startTime > e)
|
|
832
|
-
return [
|
|
922
|
+
return [
|
|
923
|
+
e,
|
|
924
|
+
this.processedLines[0].startTime,
|
|
925
|
+
-2,
|
|
926
|
+
this.processedLines[0].isDuet
|
|
927
|
+
];
|
|
833
928
|
} else if (this.processedLines[t]?.endTime && this.processedLines[t + 1]?.startTime && this.processedLines[t + 1].startTime > e && this.processedLines[t].endTime < e)
|
|
834
929
|
return [
|
|
835
|
-
this.processedLines[t].endTime,
|
|
930
|
+
Math.max(this.processedLines[t].endTime, e),
|
|
836
931
|
this.processedLines[t + 1].startTime,
|
|
837
|
-
t
|
|
932
|
+
t,
|
|
933
|
+
this.processedLines[t + 1].isDuet
|
|
838
934
|
];
|
|
839
935
|
}
|
|
840
936
|
/**
|
|
@@ -844,7 +940,7 @@ class ee extends EventTarget {
|
|
|
844
940
|
*/
|
|
845
941
|
rebuildStyle() {
|
|
846
942
|
let e = "";
|
|
847
|
-
e += "--amll-lyric-player-width:", e += this.
|
|
943
|
+
e += "--amll-lyric-player-width:", e += this.innerSize[0], e += "px;", e += "--amll-lyric-player-height:", e += this.innerSize[1], e += "px;", e += "--amll-player-time:", e += this.currentTime, e += ";", this.element.setAttribute("style", e);
|
|
848
944
|
}
|
|
849
945
|
/**
|
|
850
946
|
* 设置是否启用歌词行的模糊效果
|
|
@@ -861,47 +957,57 @@ class ee extends EventTarget {
|
|
|
861
957
|
this.lyricLines = e;
|
|
862
958
|
const t = 750;
|
|
863
959
|
this.processedLines = e.filter(
|
|
864
|
-
(i) => i.words.reduce((
|
|
865
|
-
).map((i,
|
|
960
|
+
(i) => i.words.reduce((l, s) => l + s.word.trim().length, 0) > 0
|
|
961
|
+
).map((i, l, s) => {
|
|
866
962
|
if (i.isBG)
|
|
867
963
|
return {
|
|
868
964
|
...i
|
|
869
965
|
};
|
|
870
966
|
{
|
|
871
|
-
const
|
|
872
|
-
if (
|
|
873
|
-
if (
|
|
967
|
+
const r = s[l - 1], a = s[l - 2];
|
|
968
|
+
if (r?.isBG && a) {
|
|
969
|
+
if (a.endTime < i.startTime)
|
|
874
970
|
return {
|
|
875
971
|
...i,
|
|
876
|
-
startTime: Math.max(
|
|
972
|
+
startTime: Math.max(a.endTime, i.startTime - t) || i.startTime
|
|
877
973
|
};
|
|
878
|
-
} else if (
|
|
974
|
+
} else if (r?.endTime && r.endTime < i.startTime)
|
|
879
975
|
return {
|
|
880
976
|
...i,
|
|
881
|
-
startTime: Math.max(
|
|
977
|
+
startTime: Math.max(r?.endTime, i.startTime - t) || i.startTime
|
|
882
978
|
};
|
|
883
979
|
return {
|
|
884
980
|
...i
|
|
885
981
|
};
|
|
886
982
|
}
|
|
887
|
-
}), this.
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
983
|
+
}), this.isNonDynamic = !0;
|
|
984
|
+
for (const i of this.processedLines)
|
|
985
|
+
if (i.words.length > 1) {
|
|
986
|
+
this.isNonDynamic = !1;
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
this.processedLines.forEach((i, l, s) => {
|
|
990
|
+
const r = s[l + 1], a = i.words[i.words.length - 1];
|
|
991
|
+
a && x(a) && (r ? r.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, r.startTime)) : i.endTime = i.endTime + 1500);
|
|
992
|
+
}), this.processedLines.forEach((i, l, s) => {
|
|
891
993
|
if (i.isBG)
|
|
892
994
|
return;
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
})
|
|
896
|
-
|
|
897
|
-
|
|
995
|
+
const r = s[l + 1];
|
|
996
|
+
r?.isBG && (r.startTime = Math.min(r.startTime, i.startTime));
|
|
997
|
+
});
|
|
998
|
+
const n = this.lyricLinesEl;
|
|
999
|
+
for (this.lyricLinesEl = this.processedLines.map((i, l) => this.lyricLinesEl[l] ?? new Y(this, i)); n.length > this.processedLines.length; )
|
|
1000
|
+
n.pop()?.dispose();
|
|
1001
|
+
this.lyricLinesEl.forEach((i) => {
|
|
898
1002
|
this.element.appendChild(i.getElement()), i.updateMaskImage();
|
|
899
|
-
}), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0);
|
|
1003
|
+
}), 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);
|
|
900
1004
|
}
|
|
901
1005
|
/**
|
|
902
1006
|
* 重新布局定位歌词行的位置,调用完成后再逐帧调用 `update`
|
|
903
1007
|
* 函数即可让歌词通过动画移动到目标位置。
|
|
904
1008
|
*
|
|
1009
|
+
* 函数有一个 `force` 参数,用于指定是否强制修改布局,也就是不经过动画直接调整元素位置和大小。
|
|
1010
|
+
*
|
|
905
1011
|
* 此函数还有一个 `reflow` 参数,用于指定是否需要重新计算布局
|
|
906
1012
|
*
|
|
907
1013
|
* 因为计算布局必定会导致浏览器重排布局,所以会大幅度影响流畅度和性能,故请只在以下情况下将其设置为 true:
|
|
@@ -910,54 +1016,48 @@ class ee extends EventTarget {
|
|
|
910
1016
|
* 2. 加载了新的歌词时(不论前后歌词是否完全一样)
|
|
911
1017
|
* 3. 用户自行跳转了歌曲播放位置(不论距离远近)
|
|
912
1018
|
*
|
|
1019
|
+
* @param force 是否不经过动画直接修改布局定位
|
|
913
1020
|
* @param reflow 是否进行重新布局(重新计算每行歌词大小)
|
|
914
1021
|
*/
|
|
915
|
-
calcLayout(e = !1) {
|
|
916
|
-
|
|
917
|
-
const
|
|
918
|
-
this.lyricLinesSize.set(
|
|
919
|
-
}), this.interludeDotsSize[0] = this.interludeDots.getElement().clientWidth, this.interludeDotsSize[1] = this.interludeDots.getElement().clientHeight);
|
|
920
|
-
const
|
|
921
|
-
let
|
|
922
|
-
|
|
1022
|
+
calcLayout(e = !1, t = !1) {
|
|
1023
|
+
t && (this.lyricLinesEl.forEach((m) => {
|
|
1024
|
+
const p = m.measureSize();
|
|
1025
|
+
this.lyricLinesSize.set(m, p), m.lineSize = p;
|
|
1026
|
+
}), this.interludeDotsSize[0] = this.interludeDots.getElement().clientWidth, this.interludeDotsSize[1] = this.interludeDots.getElement().clientHeight, this.bottomLine.lineSize = this.bottomLine.measureSize());
|
|
1027
|
+
const n = this.getCurrentInterlude();
|
|
1028
|
+
let i = -this.scrollOffset, l = this.scrollToIndex, s = 0;
|
|
1029
|
+
n ? (s = n[1] - n[0], s >= 5e3 && this.lyricLinesEl[n[2] + 1] && (l = n[2] + 1)) : this.interludeDots.setInterlude(void 0);
|
|
1030
|
+
const r = 0.95, a = this.lyricLinesEl.slice(0, l).reduce(
|
|
1031
|
+
(m, p) => m + (p.getLine().isBG ? 0 : this.lyricLinesSize.get(p)?.[1] ?? 0),
|
|
923
1032
|
0
|
|
924
1033
|
);
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1034
|
+
i -= a, i += this.size[1] * this.alignPosition;
|
|
1035
|
+
const o = this.lyricLinesEl[l];
|
|
1036
|
+
if (o) {
|
|
1037
|
+
const m = this.lyricLinesSize.get(o)?.[1] ?? 0;
|
|
1038
|
+
switch (this.alignAnchor) {
|
|
1039
|
+
case "bottom":
|
|
1040
|
+
i -= m;
|
|
1041
|
+
break;
|
|
1042
|
+
case "center":
|
|
1043
|
+
i -= m / 2;
|
|
1044
|
+
break;
|
|
931
1045
|
}
|
|
932
|
-
} else if (typeof this.alignAnchor == "number") {
|
|
933
|
-
n += this.element.clientHeight * this.alignAnchor;
|
|
934
|
-
const o = this.lyricLinesEl[this.scrollToIndex];
|
|
935
|
-
if (o) {
|
|
936
|
-
const c = this.lyricLinesSize.get(o)?.[1] ?? 0;
|
|
937
|
-
n -= c / 2;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
const a = this.getCurrentInterlude();
|
|
941
|
-
let s = 0;
|
|
942
|
-
if (a && (s = a[1] - a[0], s >= 5e3)) {
|
|
943
|
-
const o = this.lyricLinesEl[a[2] + 1];
|
|
944
|
-
o && (n -= this.lyricLinesSize.get(o)?.[1] ?? 0);
|
|
945
1046
|
}
|
|
946
|
-
const
|
|
947
|
-
let
|
|
948
|
-
this.lyricLinesEl.forEach((
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
this.enableBlur ? 3 * (p ? 0 : 1 + (c < this.scrollToIndex ? Math.abs(this.scrollToIndex - c) : Math.abs(c - Math.max(this.scrollToIndex, r)))) : 0,
|
|
1047
|
+
const c = Math.max(...this.bufferedLines);
|
|
1048
|
+
let d = 0, u = 0.05, f = !1;
|
|
1049
|
+
this.lyricLinesEl.forEach((m, p) => {
|
|
1050
|
+
const L = this.bufferedLines.has(p), b = L || p >= this.scrollToIndex && p < c, P = m.getLine();
|
|
1051
|
+
P.isDuet && this.size[0] - (this.lyricLinesSize.get(m)?.[0] ?? 0), !f && s >= 5e3 && (p === this.scrollToIndex && n?.[2] === -2 || p === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(32, i), n && this.interludeDots.setInterlude([n[0], n[1]]), i += this.interludeDotsSize[1]), m.setTransform(
|
|
1052
|
+
0,
|
|
1053
|
+
i,
|
|
1054
|
+
b ? 1 : r,
|
|
1055
|
+
L ? 1 : 1 / 3,
|
|
1056
|
+
!this.invokedByScrollEvent && this.enableBlur ? b ? 0 : 1 + (p < this.scrollToIndex ? Math.abs(this.scrollToIndex - p) : Math.abs(p - Math.max(this.scrollToIndex, c))) : 0,
|
|
957
1057
|
e,
|
|
958
|
-
|
|
959
|
-
),
|
|
960
|
-
});
|
|
1058
|
+
d
|
|
1059
|
+
), P.isBG && b ? i += this.lyricLinesSize.get(m)?.[1] ?? 0 : P.isBG || (i += this.lyricLinesSize.get(m)?.[1] ?? 0), i >= 0 && (d += u, u /= 1.2);
|
|
1060
|
+
}), this.bottomLine.setTransform(0, i, e, d);
|
|
961
1061
|
}
|
|
962
1062
|
/**
|
|
963
1063
|
* 获取当前歌词的播放位置
|
|
@@ -981,16 +1081,35 @@ class ee extends EventTarget {
|
|
|
981
1081
|
return this.element;
|
|
982
1082
|
}
|
|
983
1083
|
/**
|
|
984
|
-
*
|
|
1084
|
+
* 获取一个特殊的底栏元素,默认是空白的,可以往内部添加任意元素
|
|
985
1085
|
*
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
1086
|
+
* 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息
|
|
1087
|
+
*
|
|
1088
|
+
* 但是请勿删除该元素,只能在内部存放元素
|
|
1089
|
+
*
|
|
1090
|
+
* @returns 一个元素,可以往内部添加任意元素
|
|
1091
|
+
*/
|
|
1092
|
+
getBottomLineElement() {
|
|
1093
|
+
return this.bottomLine.getElement();
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* 设置目标歌词行的对齐方式,默认为 `center`
|
|
1097
|
+
*
|
|
1098
|
+
* - 设置成 `top` 的话将会向目标歌词行的顶部对齐
|
|
1099
|
+
* - 设置成 `bottom` 的话将会向目标歌词行的底部对齐
|
|
1100
|
+
* - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐
|
|
989
1101
|
* @param alignAnchor 歌词行对齐方式,详情见函数说明
|
|
990
1102
|
*/
|
|
991
1103
|
setAlignAnchor(e) {
|
|
992
1104
|
this.alignAnchor = e;
|
|
993
1105
|
}
|
|
1106
|
+
/**
|
|
1107
|
+
* 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,默认为 `0.5`
|
|
1108
|
+
* @param alignPosition 一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置
|
|
1109
|
+
*/
|
|
1110
|
+
setAlignPosition(e) {
|
|
1111
|
+
this.alignPosition = e;
|
|
1112
|
+
}
|
|
994
1113
|
/**
|
|
995
1114
|
* 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息
|
|
996
1115
|
* 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好
|
|
@@ -999,33 +1118,35 @@ class ee extends EventTarget {
|
|
|
999
1118
|
* @param time 当前播放进度,单位为毫秒
|
|
1000
1119
|
*/
|
|
1001
1120
|
setCurrentTime(e, t = !1) {
|
|
1002
|
-
this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`)
|
|
1003
|
-
|
|
1121
|
+
if (this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`), this.isScrolled)
|
|
1122
|
+
return;
|
|
1123
|
+
const n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
|
|
1004
1124
|
this.hotLines.forEach((s) => {
|
|
1005
1125
|
const r = this.processedLines[s];
|
|
1006
|
-
if (
|
|
1007
|
-
if (r)
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), i.add(s), t && this.lyricLinesEl[s].disable());
|
|
1126
|
+
if (r) {
|
|
1127
|
+
if (r.isBG)
|
|
1128
|
+
return;
|
|
1129
|
+
const a = this.processedLines[s + 1];
|
|
1130
|
+
if (a?.isBG) {
|
|
1131
|
+
const o = Math.min(r.startTime, a?.startTime), c = Math.max(r.endTime, a?.endTime);
|
|
1132
|
+
(o > e || c <= e) && (this.hotLines.delete(s), n.add(s), this.hotLines.delete(s + 1), n.add(s + 1), t && (this.lyricLinesEl[s].disable(), this.lyricLinesEl[s + 1].disable()));
|
|
1014
1133
|
} else
|
|
1015
|
-
this.hotLines.delete(s),
|
|
1016
|
-
|
|
1017
|
-
|
|
1134
|
+
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable());
|
|
1135
|
+
} else
|
|
1136
|
+
this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable();
|
|
1137
|
+
}), this.processedLines.forEach((s, r, a) => {
|
|
1138
|
+
!s.isBG && s.startTime <= e && s.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), l.add(r), t && this.lyricLinesEl[r].enable(), a[r + 1]?.isBG && (this.hotLines.add(r + 1), l.add(r + 1), t && this.lyricLinesEl[r + 1].enable())));
|
|
1018
1139
|
}), this.bufferedLines.forEach((s) => {
|
|
1019
|
-
this.hotLines.has(s) || (
|
|
1140
|
+
this.hotLines.has(s) || (i.add(s), t && this.lyricLinesEl[s].disable());
|
|
1020
1141
|
}), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
|
|
1021
1142
|
(s) => s.startTime >= e
|
|
1022
|
-
), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (
|
|
1143
|
+
), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (i.size > 0 || l.size > 0) && (i.size === 0 && l.size > 0 ? (l.forEach((s) => {
|
|
1023
1144
|
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1024
|
-
}), this.scrollToIndex = Math.min(...this.bufferedLines)) :
|
|
1145
|
+
}), this.scrollToIndex = Math.min(...this.bufferedLines)) : l.size === 0 && i.size > 0 ? O(i, this.bufferedLines) && this.bufferedLines.forEach((s) => {
|
|
1025
1146
|
this.hotLines.has(s) || (this.bufferedLines.delete(s), this.lyricLinesEl[s].disable());
|
|
1026
|
-
}) : (
|
|
1147
|
+
}) : (l.forEach((s) => {
|
|
1027
1148
|
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1028
|
-
}),
|
|
1149
|
+
}), i.forEach((s) => {
|
|
1029
1150
|
this.bufferedLines.delete(s), this.lyricLinesEl[s].disable();
|
|
1030
1151
|
}), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines))), this.calcLayout());
|
|
1031
1152
|
}
|
|
@@ -1037,7 +1158,7 @@ class ee extends EventTarget {
|
|
|
1037
1158
|
*/
|
|
1038
1159
|
update(e = 0) {
|
|
1039
1160
|
const t = e / 1e3;
|
|
1040
|
-
this.interludeDots.update(e), this.lyricLinesEl.forEach((
|
|
1161
|
+
this.interludeDots.update(e), this.bottomLine.update(t), this.lyricLinesEl.forEach((n) => n.update(t));
|
|
1041
1162
|
}
|
|
1042
1163
|
/**
|
|
1043
1164
|
* 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
|
|
@@ -1048,7 +1169,7 @@ class ee extends EventTarget {
|
|
|
1048
1169
|
this.posXSpringParams = {
|
|
1049
1170
|
...this.posXSpringParams,
|
|
1050
1171
|
...e
|
|
1051
|
-
}, this.lyricLinesEl.forEach(
|
|
1172
|
+
}, this.bottomLine.lineTransforms.posX.updateParams(this.posXSpringParams), this.lyricLinesEl.forEach(
|
|
1052
1173
|
(t) => t.lineTransforms.posX.updateParams(this.posXSpringParams)
|
|
1053
1174
|
);
|
|
1054
1175
|
}
|
|
@@ -1061,7 +1182,7 @@ class ee extends EventTarget {
|
|
|
1061
1182
|
this.posYSpringParams = {
|
|
1062
1183
|
...this.posYSpringParams,
|
|
1063
1184
|
...e
|
|
1064
|
-
}, this.lyricLinesEl.forEach(
|
|
1185
|
+
}, this.bottomLine.lineTransforms.posY.updateParams(this.posYSpringParams), this.lyricLinesEl.forEach(
|
|
1065
1186
|
(t) => t.lineTransforms.posY.updateParams(this.posYSpringParams)
|
|
1066
1187
|
);
|
|
1067
1188
|
}
|
|
@@ -1079,12 +1200,12 @@ class ee extends EventTarget {
|
|
|
1079
1200
|
);
|
|
1080
1201
|
}
|
|
1081
1202
|
dispose() {
|
|
1082
|
-
this.element.remove(), this.resizeObserver.disconnect(), this.style.detach(), this.lyricLinesEl.forEach((e) => e.dispose()), window.removeEventListener("pageshow", this.onPageShow);
|
|
1203
|
+
this.element.remove(), this.resizeObserver.disconnect(), this.style.detach(), this.lyricLinesEl.forEach((e) => e.dispose()), window.removeEventListener("pageshow", this.onPageShow), this.bottomLine.dispose(), this.interludeDots.dispose();
|
|
1083
1204
|
}
|
|
1084
1205
|
}
|
|
1085
1206
|
export {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1207
|
+
te as BackgroundRender,
|
|
1208
|
+
ie as LyricPlayer,
|
|
1209
|
+
ee as ttml
|
|
1089
1210
|
};
|
|
1090
1211
|
//# sourceMappingURL=amll-core.mjs.map
|