@applemusic-like-lyrics/core 0.0.6 → 0.0.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/amll-core.js +1 -1
- package/dist/amll-core.js.map +1 -1
- package/dist/amll-core.mjs +599 -606
- package/dist/amll-core.mjs.map +1 -1
- package/package.json +5 -2
package/dist/amll-core.mjs
CHANGED
|
@@ -1,173 +1,166 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const t = q.exec(c);
|
|
16
|
-
if (t) {
|
|
17
|
-
const a = Number(((e = t.groups) == null ? void 0 : e.hour) || "0"), l = Number(((n = t.groups) == null ? void 0 : n.min) || "0"), i = Number(((s = t.groups) == null ? void 0 : s.sec.replace(/:/, ".")) || "0");
|
|
18
|
-
return Math.floor((a * 3600 + l * 60 + i) * 1e3);
|
|
1
|
+
import { Container as v } from "@pixi/display";
|
|
2
|
+
import { Application as M } from "@pixi/app";
|
|
3
|
+
import { BlurFilter as y } from "@pixi/filter-blur";
|
|
4
|
+
import { ColorMatrixFilter as w } from "@pixi/filter-color-matrix";
|
|
5
|
+
import { Texture as C } from "@pixi/core";
|
|
6
|
+
import { Sprite as L } from "@pixi/sprite";
|
|
7
|
+
import { create as z } from "jss";
|
|
8
|
+
import A from "jss-preset-default";
|
|
9
|
+
const D = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
|
|
10
|
+
function T(c) {
|
|
11
|
+
const e = D.exec(c);
|
|
12
|
+
if (e) {
|
|
13
|
+
const t = Number(e.groups?.hour || "0"), i = Number(e.groups?.min || "0"), n = Number(e.groups?.sec.replace(/:/, ".") || "0");
|
|
14
|
+
return Math.floor((t * 3600 + i * 60 + n) * 1e3);
|
|
19
15
|
} else
|
|
20
16
|
throw new TypeError("时间戳字符串解析失败");
|
|
21
17
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
18
|
+
function I(c) {
|
|
19
|
+
const t = new DOMParser().parseFromString(
|
|
24
20
|
c,
|
|
25
21
|
"application/xml"
|
|
26
22
|
);
|
|
27
|
-
let
|
|
28
|
-
for (const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
|
|
23
|
+
let i = "v1";
|
|
24
|
+
for (const h of t.querySelectorAll("ttm\\:agent"))
|
|
25
|
+
if (h.getAttribute("type") === "person") {
|
|
26
|
+
const s = h.getAttribute("xml:id");
|
|
27
|
+
s && (i = s);
|
|
32
28
|
}
|
|
33
|
-
const
|
|
34
|
-
for (const
|
|
35
|
-
const
|
|
29
|
+
const n = [];
|
|
30
|
+
for (const h of t.querySelectorAll("body p[begin][end]")) {
|
|
31
|
+
const s = {
|
|
36
32
|
words: [],
|
|
37
|
-
startTime:
|
|
38
|
-
endTime:
|
|
33
|
+
startTime: T(h.getAttribute("begin") ?? "0:0"),
|
|
34
|
+
endTime: T(h.getAttribute("end") ?? "0:0"),
|
|
39
35
|
translatedLyric: "",
|
|
40
36
|
romanLyric: "",
|
|
41
37
|
isBG: !1,
|
|
42
|
-
isDuet:
|
|
38
|
+
isDuet: h.getAttribute("ttm:agent") !== i
|
|
43
39
|
};
|
|
44
|
-
let
|
|
45
|
-
for (const
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
/^(\s+)$/.test(
|
|
40
|
+
let r = null;
|
|
41
|
+
for (const a of h.childNodes)
|
|
42
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
43
|
+
const l = a.textContent ?? "";
|
|
44
|
+
/^(\s+)$/.test(l) ? s.words.push({
|
|
49
45
|
word: " ",
|
|
50
46
|
startTime: 0,
|
|
51
47
|
endTime: 0
|
|
52
|
-
}) :
|
|
53
|
-
word:
|
|
48
|
+
}) : s.words.push({
|
|
49
|
+
word: l,
|
|
54
50
|
startTime: 0,
|
|
55
51
|
endTime: 0
|
|
56
52
|
});
|
|
57
|
-
} else if (
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
53
|
+
} else if (a.nodeType === Node.ELEMENT_NODE) {
|
|
54
|
+
const l = a, o = l.getAttribute("ttm:role");
|
|
55
|
+
if (l.nodeName === "span" && o)
|
|
56
|
+
if (o === "x-bg") {
|
|
57
|
+
const d = {
|
|
62
58
|
words: [],
|
|
63
|
-
startTime:
|
|
64
|
-
endTime:
|
|
59
|
+
startTime: s.startTime,
|
|
60
|
+
endTime: s.endTime,
|
|
65
61
|
translatedLyric: "",
|
|
66
62
|
romanLyric: "",
|
|
67
63
|
isBG: !0,
|
|
68
|
-
isDuet:
|
|
64
|
+
isDuet: s.isDuet
|
|
69
65
|
};
|
|
70
|
-
for (const p of
|
|
66
|
+
for (const p of l.childNodes)
|
|
71
67
|
if (p.nodeType === Node.TEXT_NODE) {
|
|
72
|
-
const
|
|
73
|
-
/^(\s+)$/.test(
|
|
68
|
+
const f = p.textContent ?? "";
|
|
69
|
+
/^(\s+)$/.test(f) ? d.words.push({
|
|
74
70
|
word: " ",
|
|
75
71
|
startTime: 0,
|
|
76
72
|
endTime: 0
|
|
77
|
-
}) :
|
|
78
|
-
word:
|
|
73
|
+
}) : d.words.push({
|
|
74
|
+
word: f,
|
|
79
75
|
startTime: 0,
|
|
80
76
|
endTime: 0
|
|
81
77
|
});
|
|
82
78
|
} else if (p.nodeType === Node.ELEMENT_NODE) {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
else if (
|
|
87
|
-
const
|
|
79
|
+
const f = p, S = f.getAttribute("ttm:role");
|
|
80
|
+
if (f.nodeName === "span" && S)
|
|
81
|
+
S === "x-translation" ? d.translatedLyric = f.innerHTML.trim() : S === "x-roman" && (d.romanLyric = f.innerHTML.trim());
|
|
82
|
+
else if (f.hasAttribute("begin") && f.hasAttribute("end")) {
|
|
83
|
+
const x = {
|
|
88
84
|
word: p.textContent,
|
|
89
|
-
startTime:
|
|
90
|
-
endTime:
|
|
85
|
+
startTime: T(f.getAttribute("begin")),
|
|
86
|
+
endTime: T(f.getAttribute("end"))
|
|
91
87
|
};
|
|
92
|
-
|
|
88
|
+
d.words.push(x);
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
91
|
+
const m = d.words[0];
|
|
92
|
+
d.startTime = m.startTime, m?.word.startsWith("(") && (m.word = m.word.substring(1));
|
|
93
|
+
const u = d.words[d.words.length - 1];
|
|
94
|
+
d.endTime = u.endTime, u?.word.endsWith(")") && (u.word = u.word.substring(
|
|
99
95
|
0,
|
|
100
|
-
|
|
101
|
-
)),
|
|
96
|
+
u.word.length - 1
|
|
97
|
+
)), r = d;
|
|
102
98
|
} else
|
|
103
|
-
|
|
104
|
-
else if (
|
|
105
|
-
const
|
|
106
|
-
word:
|
|
107
|
-
startTime:
|
|
108
|
-
endTime:
|
|
99
|
+
o === "x-translation" ? s.translatedLyric = l.innerHTML : o === "x-roman" && (s.romanLyric = l.innerHTML);
|
|
100
|
+
else if (l.hasAttribute("begin") && l.hasAttribute("end")) {
|
|
101
|
+
const d = {
|
|
102
|
+
word: a.textContent ?? "",
|
|
103
|
+
startTime: T(l.getAttribute("begin")),
|
|
104
|
+
endTime: T(l.getAttribute("end"))
|
|
109
105
|
};
|
|
110
|
-
|
|
106
|
+
s.words.push(d);
|
|
111
107
|
}
|
|
112
108
|
}
|
|
113
|
-
|
|
109
|
+
n.push(s), r && n.push(r);
|
|
114
110
|
}
|
|
115
|
-
return console.log(
|
|
111
|
+
return console.log(n), n;
|
|
116
112
|
}
|
|
117
|
-
const
|
|
113
|
+
const Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
118
114
|
__proto__: null,
|
|
119
|
-
parseTTML:
|
|
115
|
+
parseTTML: I
|
|
120
116
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
121
|
-
class
|
|
122
|
-
|
|
123
|
-
super(...arguments);
|
|
124
|
-
h(this, "time", 0);
|
|
125
|
-
}
|
|
117
|
+
class B extends v {
|
|
118
|
+
time = 0;
|
|
126
119
|
}
|
|
127
|
-
class
|
|
128
|
-
constructor(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (const e of this.lastContainer)
|
|
135
|
-
e.alpha = Math.max(0, e.alpha - t / 60), e.alpha <= 0 && (this.app.stage.removeChild(e), this.lastContainer.delete(e));
|
|
136
|
-
if (this.curContainer) {
|
|
137
|
-
this.curContainer.alpha = Math.min(
|
|
138
|
-
1,
|
|
139
|
-
this.curContainer.alpha + t / 60
|
|
140
|
-
);
|
|
141
|
-
const [e, n, s, a] = this.curContainer.children, l = Math.max(this.app.screen.width, this.app.screen.height);
|
|
142
|
-
e.position.set(this.app.screen.width / 2, this.app.screen.height / 2), n.position.set(
|
|
143
|
-
this.app.screen.width / 2.5,
|
|
144
|
-
this.app.screen.height / 2.5
|
|
145
|
-
), s.position.set(this.app.screen.width / 2, this.app.screen.height / 2), a.position.set(this.app.screen.width / 2, this.app.screen.height / 2), e.width = l * Math.sqrt(2), e.height = e.width, n.width = l * 0.8, n.height = n.width, s.width = l * 0.5, s.height = s.width, a.width = l * 0.25, a.height = a.width, this.curContainer.time += t * this.flowSpeed, e.rotation += t / 1e3 * this.flowSpeed, n.rotation -= t / 500 * this.flowSpeed, s.rotation += t / 1e3 * this.flowSpeed, a.rotation -= t / 750 * this.flowSpeed, s.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), s.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), a.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), a.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
h(this, "flowSpeed", 2);
|
|
149
|
-
h(this, "currerntRenderScale", 0.75);
|
|
150
|
-
this.canvas = t;
|
|
151
|
-
const e = t.getBoundingClientRect();
|
|
152
|
-
this.canvas.width = e.width * this.currerntRenderScale, this.canvas.height = e.height * this.currerntRenderScale, this.observer = new ResizeObserver(() => {
|
|
153
|
-
const n = t.getBoundingClientRect();
|
|
154
|
-
this.canvas.width = Math.max(1, n.width), this.canvas.height = Math.max(1, n.height), this.app.renderer.resize(
|
|
120
|
+
class k {
|
|
121
|
+
constructor(e) {
|
|
122
|
+
this.canvas = e;
|
|
123
|
+
const t = e.getBoundingClientRect();
|
|
124
|
+
this.canvas.width = t.width * this.currerntRenderScale, this.canvas.height = t.height * this.currerntRenderScale, this.observer = new ResizeObserver(() => {
|
|
125
|
+
const i = e.getBoundingClientRect();
|
|
126
|
+
this.canvas.width = Math.max(1, i.width), this.canvas.height = Math.max(1, i.height), this.app.renderer.resize(
|
|
155
127
|
this.canvas.width * this.currerntRenderScale,
|
|
156
128
|
this.canvas.height * this.currerntRenderScale
|
|
157
129
|
), this.rebuildFilters();
|
|
158
|
-
}), this.observer.observe(
|
|
159
|
-
view:
|
|
130
|
+
}), this.observer.observe(e), this.app = new M({
|
|
131
|
+
view: e,
|
|
160
132
|
resizeTo: this.canvas,
|
|
161
133
|
powerPreference: "low-power",
|
|
162
134
|
backgroundAlpha: 0
|
|
163
135
|
}), this.rebuildFilters(), this.app.ticker.add(this.onTick), this.app.ticker.start();
|
|
164
136
|
}
|
|
137
|
+
observer;
|
|
138
|
+
app;
|
|
139
|
+
curContainer;
|
|
140
|
+
lastContainer = /* @__PURE__ */ new Set();
|
|
141
|
+
onTick = (e) => {
|
|
142
|
+
for (const t of this.lastContainer)
|
|
143
|
+
t.alpha = Math.max(0, t.alpha - e / 60), t.alpha <= 0 && (this.app.stage.removeChild(t), this.lastContainer.delete(t));
|
|
144
|
+
if (this.curContainer) {
|
|
145
|
+
this.curContainer.alpha = Math.min(
|
|
146
|
+
1,
|
|
147
|
+
this.curContainer.alpha + e / 60
|
|
148
|
+
);
|
|
149
|
+
const [t, i, n, h] = this.curContainer.children, s = Math.max(this.app.screen.width, this.app.screen.height);
|
|
150
|
+
t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), i.position.set(
|
|
151
|
+
this.app.screen.width / 2.5,
|
|
152
|
+
this.app.screen.height / 2.5
|
|
153
|
+
), n.position.set(this.app.screen.width / 2, this.app.screen.height / 2), h.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = s * Math.sqrt(2), t.height = t.width, i.width = s * 0.8, i.height = i.width, n.width = s * 0.5, n.height = n.width, h.width = s * 0.25, h.height = h.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, i.rotation -= e / 500 * this.flowSpeed, n.rotation += e / 1e3 * this.flowSpeed, h.rotation -= e / 750 * this.flowSpeed, n.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), n.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), h.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), h.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
flowSpeed = 2;
|
|
157
|
+
currerntRenderScale = 0.75;
|
|
165
158
|
/**
|
|
166
159
|
* 修改背景的流动速度,数字越大越快,默认为 2
|
|
167
160
|
* @param speed 背景的流动速度,默认为 2
|
|
168
161
|
*/
|
|
169
|
-
setFlowSpeed(
|
|
170
|
-
this.flowSpeed =
|
|
162
|
+
setFlowSpeed(e) {
|
|
163
|
+
this.flowSpeed = e;
|
|
171
164
|
}
|
|
172
165
|
/**
|
|
173
166
|
* 修改背景的渲染比例,默认是 0.5
|
|
@@ -175,21 +168,21 @@ class _ {
|
|
|
175
168
|
* 一般情况下这个程度既没有明显瑕疵也不会特别吃性能
|
|
176
169
|
* @param scale 背景的渲染比例
|
|
177
170
|
*/
|
|
178
|
-
setRenderScale(
|
|
179
|
-
this.currerntRenderScale =
|
|
180
|
-
const
|
|
181
|
-
this.canvas.width = Math.max(1,
|
|
171
|
+
setRenderScale(e) {
|
|
172
|
+
this.currerntRenderScale = e;
|
|
173
|
+
const t = this.canvas.getBoundingClientRect();
|
|
174
|
+
this.canvas.width = Math.max(1, t.width), this.canvas.height = Math.max(1, t.height), this.app.renderer.resize(
|
|
182
175
|
this.canvas.width * this.currerntRenderScale,
|
|
183
176
|
this.canvas.height * this.currerntRenderScale
|
|
184
177
|
), this.rebuildFilters();
|
|
185
178
|
}
|
|
186
179
|
rebuildFilters() {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
180
|
+
const e = Math.min(this.canvas.width, this.canvas.height), t = new w();
|
|
181
|
+
t.saturate(1.2, !1);
|
|
182
|
+
const i = new w();
|
|
183
|
+
i.brightness(0.6, !1);
|
|
184
|
+
const n = new w();
|
|
185
|
+
n.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, i, n), this.app.stage.filters.push(new y(5, 1));
|
|
193
186
|
}
|
|
194
187
|
/**
|
|
195
188
|
* 修改背景动画帧率,默认是 30 FPS
|
|
@@ -197,8 +190,8 @@ class _ {
|
|
|
197
190
|
* 如果设置成 0 则会停止动画
|
|
198
191
|
* @param fps 目标帧率,默认 30 FPS
|
|
199
192
|
*/
|
|
200
|
-
setFPS(
|
|
201
|
-
this.app.ticker.maxFPS =
|
|
193
|
+
setFPS(e) {
|
|
194
|
+
this.app.ticker.maxFPS = e;
|
|
202
195
|
}
|
|
203
196
|
/**
|
|
204
197
|
* 暂停背景动画,画面即便是更新了图片也不会发生变化
|
|
@@ -216,20 +209,19 @@ class _ {
|
|
|
216
209
|
* 设置背景专辑图片,图片材质加载并设置完成后会返回
|
|
217
210
|
* @param albumUrl 图片的目标链接
|
|
218
211
|
*/
|
|
219
|
-
async setAlbumImage(
|
|
220
|
-
const
|
|
221
|
-
|
|
212
|
+
async setAlbumImage(e) {
|
|
213
|
+
const t = await C.fromURL(e), i = new B(), n = new L(t), h = new L(t), s = new L(t), r = new L(t);
|
|
214
|
+
n.anchor.set(0.5, 0.5), h.anchor.set(0.5, 0.5), s.anchor.set(0.5, 0.5), r.anchor.set(0.5, 0.5), n.rotation = Math.random() * Math.PI * 2, h.rotation = Math.random() * Math.PI * 2, s.rotation = Math.random() * Math.PI * 2, r.rotation = Math.random() * Math.PI * 2, i.addChild(n, h, s, r), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = i, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0;
|
|
222
215
|
}
|
|
223
216
|
dispose() {
|
|
224
217
|
this.observer.disconnect(), this.app.ticker.remove(this.onTick);
|
|
225
218
|
}
|
|
226
219
|
}
|
|
227
|
-
class
|
|
220
|
+
class Z extends k {
|
|
221
|
+
element;
|
|
228
222
|
constructor() {
|
|
229
223
|
const e = document.createElement("canvas");
|
|
230
|
-
super(e);
|
|
231
|
-
h(this, "element");
|
|
232
|
-
this.element = e, e.style.pointerEvents = "none", e.style.zIndex = "-1";
|
|
224
|
+
super(e), this.element = e, e.style.pointerEvents = "none", e.style.zIndex = "-1";
|
|
233
225
|
}
|
|
234
226
|
getElement() {
|
|
235
227
|
return this.element;
|
|
@@ -238,171 +230,171 @@ class le extends _ {
|
|
|
238
230
|
super.dispose(), this.element.remove();
|
|
239
231
|
}
|
|
240
232
|
}
|
|
241
|
-
const
|
|
242
|
-
function
|
|
243
|
-
const
|
|
244
|
-
return c < 0.5 ? Math.pow(2 * c, 2) * ((
|
|
233
|
+
const N = (c, e) => c.size === e.size && [...c].every((t) => e.has(t));
|
|
234
|
+
function O(c) {
|
|
235
|
+
const t = 2.5949095;
|
|
236
|
+
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;
|
|
245
237
|
}
|
|
246
|
-
const
|
|
247
|
-
class
|
|
248
|
-
constructor(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
238
|
+
const g = (c, e, t) => Math.max(c, Math.min(e, t));
|
|
239
|
+
class W {
|
|
240
|
+
constructor(e) {
|
|
241
|
+
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
|
+
}
|
|
243
|
+
element = document.createElement("div");
|
|
244
|
+
dot0 = document.createElement("span");
|
|
245
|
+
dot1 = document.createElement("span");
|
|
246
|
+
dot2 = document.createElement("span");
|
|
247
|
+
left = 0;
|
|
248
|
+
top = 0;
|
|
249
|
+
scale = 1;
|
|
250
|
+
lastStyle = "";
|
|
251
|
+
currentInterlude;
|
|
252
|
+
currentTime = 0;
|
|
253
|
+
targetBreatheDuration = 1500;
|
|
262
254
|
getElement() {
|
|
263
255
|
return this.element;
|
|
264
256
|
}
|
|
265
|
-
setTransform(
|
|
266
|
-
this.left =
|
|
257
|
+
setTransform(e = this.left, t = this.top) {
|
|
258
|
+
this.left = e, this.top = t, this.update();
|
|
267
259
|
}
|
|
268
|
-
setInterlude(
|
|
269
|
-
this.currentInterlude =
|
|
260
|
+
setInterlude(e) {
|
|
261
|
+
this.currentInterlude = e, this.currentTime = e?.[0] ?? 0;
|
|
270
262
|
}
|
|
271
|
-
update(
|
|
272
|
-
this.currentTime +=
|
|
273
|
-
let
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
const
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
(750 - (
|
|
281
|
-
)),
|
|
263
|
+
update(e = 0) {
|
|
264
|
+
this.currentTime += e;
|
|
265
|
+
let t = "";
|
|
266
|
+
if (t += `transform:translate(${this.left}px, ${this.top}px)`, this.currentInterlude) {
|
|
267
|
+
const i = this.currentInterlude[1] - this.currentInterlude[0], n = this.currentTime - this.currentInterlude[0];
|
|
268
|
+
if (n <= i) {
|
|
269
|
+
const h = i / Math.ceil(i / this.targetBreatheDuration);
|
|
270
|
+
let s = 1, r = 1;
|
|
271
|
+
s *= Math.sin(1.5 * Math.PI - n / h * 2) / 10 + 1, n < 1e3 && (s *= 1 - Math.pow((1e3 - n) / 1e3, 2)), n < 500 ? r = 0 : n < 1e3 && (r *= (n - 500) / 500), i - n < 750 && (s *= 1 - O(
|
|
272
|
+
(750 - (i - n)) / 750 / 2
|
|
273
|
+
)), i - n < 375 && (r *= g(
|
|
282
274
|
0,
|
|
283
|
-
(
|
|
275
|
+
(i - n) / 375,
|
|
284
276
|
1
|
|
285
|
-
)),
|
|
286
|
-
const
|
|
277
|
+
)), s = Math.max(0, s), t += ` scale(${s})`;
|
|
278
|
+
const a = g(
|
|
287
279
|
0.25,
|
|
288
|
-
|
|
280
|
+
n * 3 / i * 0.75,
|
|
289
281
|
1
|
|
290
|
-
),
|
|
282
|
+
), l = g(
|
|
291
283
|
0.25,
|
|
292
|
-
(
|
|
284
|
+
(n - i / 3) * 3 / i * 0.75,
|
|
293
285
|
1
|
|
294
|
-
),
|
|
286
|
+
), o = g(
|
|
295
287
|
0.25,
|
|
296
|
-
(
|
|
288
|
+
(n - i / 3 * 2) * 3 / i * 0.75,
|
|
297
289
|
1
|
|
298
290
|
);
|
|
299
|
-
this.dot0.style.opacity = `${
|
|
291
|
+
this.dot0.style.opacity = `${g(
|
|
300
292
|
0,
|
|
301
|
-
Math.max(0,
|
|
293
|
+
Math.max(0, r * a),
|
|
302
294
|
1
|
|
303
|
-
)}`, this.dot1.style.opacity = `${
|
|
295
|
+
)}`, this.dot1.style.opacity = `${g(
|
|
304
296
|
0,
|
|
305
|
-
Math.max(0,
|
|
297
|
+
Math.max(0, r * l),
|
|
306
298
|
1
|
|
307
|
-
)}`, this.dot2.style.opacity = `${
|
|
299
|
+
)}`, this.dot2.style.opacity = `${g(
|
|
308
300
|
0,
|
|
309
|
-
Math.max(0,
|
|
301
|
+
Math.max(0, r * o),
|
|
310
302
|
1
|
|
311
303
|
)}`;
|
|
312
304
|
} else
|
|
313
|
-
|
|
305
|
+
t += " scale(0)", this.dot0.style.opacity = "0", this.dot1.style.opacity = "0", this.dot2.style.opacity = "0";
|
|
314
306
|
} else
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
t += " scale(0)", this.dot0.style.opacity = "0", this.dot1.style.opacity = "0", this.dot2.style.opacity = "0";
|
|
308
|
+
t += ";", this.lastStyle !== t && (this.element.setAttribute("style", t), this.lastStyle = t);
|
|
317
309
|
}
|
|
318
310
|
dispose() {
|
|
319
311
|
this.element.remove();
|
|
320
312
|
}
|
|
321
313
|
}
|
|
322
|
-
class
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.targetPosition =
|
|
314
|
+
class P {
|
|
315
|
+
currentPosition = 0;
|
|
316
|
+
targetPosition = 0;
|
|
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;
|
|
333
325
|
}
|
|
334
326
|
resetSolver() {
|
|
335
|
-
const
|
|
336
|
-
this.currentTime = 0, this.currentSolver =
|
|
327
|
+
const e = this.getV(this.currentTime);
|
|
328
|
+
this.currentTime = 0, this.currentSolver = $(
|
|
337
329
|
this.currentPosition,
|
|
338
|
-
|
|
330
|
+
e,
|
|
339
331
|
this.targetPosition,
|
|
340
332
|
0,
|
|
341
333
|
this.params
|
|
342
|
-
), this.getV =
|
|
334
|
+
), this.getV = R(this.currentSolver);
|
|
343
335
|
}
|
|
344
336
|
arrived() {
|
|
345
337
|
return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
|
|
346
338
|
}
|
|
347
|
-
setPosition(
|
|
348
|
-
this.targetPosition =
|
|
339
|
+
setPosition(e) {
|
|
340
|
+
this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
|
|
349
341
|
}
|
|
350
|
-
update(
|
|
351
|
-
this.currentTime +=
|
|
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({
|
|
352
344
|
...this.queueParams
|
|
353
|
-
})), this.queuePosition && (this.queuePosition.time -=
|
|
345
|
+
})), this.queuePosition && (this.queuePosition.time -= e, this.queuePosition.time <= 0 && this.setTargetPosition(this.queuePosition.position)), this.arrived() && this.setPosition(this.targetPosition);
|
|
354
346
|
}
|
|
355
|
-
updateParams(
|
|
356
|
-
|
|
357
|
-
...
|
|
358
|
-
time:
|
|
347
|
+
updateParams(e, t = 0) {
|
|
348
|
+
t > 0 ? this.queueParams = {
|
|
349
|
+
...e,
|
|
350
|
+
time: t
|
|
359
351
|
} : (this.params = {
|
|
360
352
|
...this.params,
|
|
361
|
-
...
|
|
353
|
+
...e
|
|
362
354
|
}, this.resetSolver());
|
|
363
355
|
}
|
|
364
|
-
setTargetPosition(
|
|
365
|
-
|
|
366
|
-
position:
|
|
367
|
-
time:
|
|
368
|
-
} : (this.queuePosition = void 0, this.targetPosition =
|
|
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());
|
|
369
361
|
}
|
|
370
362
|
getCurrentPosition() {
|
|
371
363
|
return this.currentPosition;
|
|
372
364
|
}
|
|
373
365
|
}
|
|
374
|
-
function
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
377
|
-
const
|
|
378
|
-
return (
|
|
366
|
+
function $(c, e, t, i = 0, n) {
|
|
367
|
+
const h = n?.soft ?? !1, s = n?.stiffness ?? 100, r = n?.damping ?? 10, a = n?.mass ?? 1, l = t - c;
|
|
368
|
+
if (h || 1 <= r / (2 * Math.sqrt(s * a))) {
|
|
369
|
+
const o = -Math.sqrt(s / a), d = -o * l - e;
|
|
370
|
+
return (m) => (m -= i, m < 0 ? c : t - (l + m * d) * Math.E ** (m * o));
|
|
379
371
|
} else {
|
|
380
|
-
const
|
|
381
|
-
4 *
|
|
382
|
-
),
|
|
383
|
-
return (p) => (p -=
|
|
372
|
+
const o = Math.sqrt(
|
|
373
|
+
4 * a * s - r ** 2
|
|
374
|
+
), d = (r * l - 2 * a * e) / o, m = 0.5 * o / a, u = -(0.5 * r) / a;
|
|
375
|
+
return (p) => (p -= i, p < 0 ? c : t - (Math.cos(p * m) * l + Math.sin(p * m) * d) * Math.E ** (p * u));
|
|
384
376
|
}
|
|
385
377
|
}
|
|
386
|
-
function
|
|
387
|
-
return (
|
|
378
|
+
function q(c) {
|
|
379
|
+
return (t) => (c(t + 1e-3) - c(t - 1e-3)) / (2 * 1e-3);
|
|
388
380
|
}
|
|
389
|
-
function
|
|
390
|
-
return
|
|
381
|
+
function R(c) {
|
|
382
|
+
return q(c);
|
|
391
383
|
}
|
|
392
|
-
const
|
|
393
|
-
function
|
|
394
|
-
const
|
|
384
|
+
const b = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
|
|
385
|
+
function F(c, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
|
|
386
|
+
const i = 2 + c, n = c / i, h = (1 - n) / 2;
|
|
395
387
|
return [
|
|
396
|
-
`linear-gradient(to right,${
|
|
397
|
-
|
|
398
|
-
|
|
388
|
+
`linear-gradient(to right,${e} ${h * 100}%,${t} ${(h + n) * 100}%)`,
|
|
389
|
+
n,
|
|
390
|
+
i
|
|
399
391
|
];
|
|
400
392
|
}
|
|
401
|
-
function
|
|
393
|
+
function E(c) {
|
|
402
394
|
return c.endTime - c.startTime >= 1e3 && c.word.length <= 7;
|
|
403
395
|
}
|
|
404
|
-
class
|
|
405
|
-
constructor(
|
|
396
|
+
class _ {
|
|
397
|
+
constructor(e, t = {
|
|
406
398
|
words: [],
|
|
407
399
|
translatedLyric: "",
|
|
408
400
|
romanLyric: "",
|
|
@@ -411,64 +403,64 @@ class H {
|
|
|
411
403
|
isBG: !1,
|
|
412
404
|
isDuet: !1
|
|
413
405
|
}) {
|
|
414
|
-
|
|
415
|
-
h(this, "left", 0);
|
|
416
|
-
h(this, "top", 0);
|
|
417
|
-
h(this, "scale", 1);
|
|
418
|
-
h(this, "blur", 0);
|
|
419
|
-
h(this, "delay", 0);
|
|
420
|
-
h(this, "splittedWords", []);
|
|
421
|
-
// 由 LyricPlayer 来设置
|
|
422
|
-
h(this, "lineSize", [0, 0]);
|
|
423
|
-
h(this, "lineTransforms", {
|
|
424
|
-
posX: new x(0),
|
|
425
|
-
posY: new x(0),
|
|
426
|
-
scale: new x(1)
|
|
427
|
-
});
|
|
428
|
-
h(this, "isEnabled", !1);
|
|
429
|
-
h(this, "_hide", !0);
|
|
430
|
-
h(this, "lastStyle", "");
|
|
431
|
-
this.lyricPlayer = t, this.lyricLine = e, this.element.setAttribute(
|
|
406
|
+
this.lyricPlayer = e, this.lyricLine = t, this.element.setAttribute(
|
|
432
407
|
"class",
|
|
433
408
|
this.lyricPlayer.style.classes.lyricLine
|
|
434
409
|
), 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"));
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
}
|
|
410
|
+
const i = this.element.children[0], n = this.element.children[1], h = this.element.children[2];
|
|
411
|
+
i.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), n.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), h.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
|
|
412
|
+
}
|
|
413
|
+
element = document.createElement("div");
|
|
414
|
+
left = 0;
|
|
415
|
+
top = 0;
|
|
416
|
+
scale = 1;
|
|
417
|
+
blur = 0;
|
|
418
|
+
delay = 0;
|
|
419
|
+
splittedWords = [];
|
|
420
|
+
// 由 LyricPlayer 来设置
|
|
421
|
+
lineSize = [0, 0];
|
|
422
|
+
lineTransforms = {
|
|
423
|
+
posX: new P(0),
|
|
424
|
+
posY: new P(0),
|
|
425
|
+
scale: new P(1)
|
|
426
|
+
};
|
|
427
|
+
isEnabled = !1;
|
|
438
428
|
enable() {
|
|
439
429
|
this.isEnabled = !0, this.element.classList.add("active");
|
|
440
|
-
const
|
|
441
|
-
this.splittedWords.forEach((
|
|
442
|
-
|
|
443
|
-
|
|
430
|
+
const e = this.element.children[0];
|
|
431
|
+
this.splittedWords.forEach((t) => {
|
|
432
|
+
t.elementAnimations.forEach((i) => {
|
|
433
|
+
i.currentTime = 0, i.playbackRate = 1, i.play();
|
|
444
434
|
});
|
|
445
|
-
}),
|
|
435
|
+
}), e.classList.add("active");
|
|
446
436
|
}
|
|
447
437
|
measureSize() {
|
|
448
438
|
this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden");
|
|
449
|
-
const
|
|
439
|
+
const e = [
|
|
450
440
|
this.element.clientWidth,
|
|
451
441
|
this.element.clientHeight
|
|
452
442
|
];
|
|
453
|
-
return this._hide && (this.element.style.display = "none", this.element.style.visibility = ""),
|
|
443
|
+
return this._hide && (this.element.style.display = "none", this.element.style.visibility = ""), e;
|
|
454
444
|
}
|
|
455
445
|
disable() {
|
|
456
446
|
this.isEnabled = !1, this.element.classList.remove("active");
|
|
457
|
-
const
|
|
458
|
-
this.splittedWords.forEach((
|
|
459
|
-
|
|
460
|
-
|
|
447
|
+
const e = this.element.children[0];
|
|
448
|
+
this.splittedWords.forEach((t) => {
|
|
449
|
+
t.elementAnimations.forEach((i) => {
|
|
450
|
+
i.id === "float-word" && (i.playbackRate = -1, i.play());
|
|
461
451
|
});
|
|
462
|
-
}),
|
|
452
|
+
}), e.classList.remove("active");
|
|
463
453
|
}
|
|
464
|
-
setLine(
|
|
465
|
-
this.lyricLine =
|
|
454
|
+
setLine(e) {
|
|
455
|
+
this.lyricLine = e, this.lyricLine.isBG ? this.element.classList.add(this.lyricPlayer.style.classes.lyricBgLine) : this.element.classList.remove(this.lyricPlayer.style.classes.lyricBgLine), this.lyricLine.isDuet ? this.element.classList.add(this.lyricPlayer.style.classes.lyricDuetLine) : this.element.classList.remove(
|
|
466
456
|
this.lyricPlayer.style.classes.lyricDuetLine
|
|
467
457
|
), this.rebuildElement(), this.rebuildStyle();
|
|
468
458
|
}
|
|
469
459
|
getLine() {
|
|
470
460
|
return this.lyricLine;
|
|
471
461
|
}
|
|
462
|
+
_hide = !0;
|
|
463
|
+
lastStyle = "";
|
|
472
464
|
show() {
|
|
473
465
|
this._hide = !1, this.rebuildStyle();
|
|
474
466
|
}
|
|
@@ -483,24 +475,24 @@ class H {
|
|
|
483
475
|
));
|
|
484
476
|
return;
|
|
485
477
|
}
|
|
486
|
-
let
|
|
487
|
-
!this.lyricPlayer.getEnableSpring() && this.isInSight && (
|
|
478
|
+
let e = `transform:translate(${this.lineTransforms.posX.getCurrentPosition()}px,${this.lineTransforms.posY.getCurrentPosition()}px) scale(${this.lineTransforms.scale.getCurrentPosition()});`;
|
|
479
|
+
!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));
|
|
488
480
|
}
|
|
489
481
|
rebuildElement() {
|
|
490
|
-
const
|
|
491
|
-
this.splittedWords = [], this.lyricLine.words.forEach((
|
|
492
|
-
if (
|
|
482
|
+
const e = this.element.children[0], t = this.element.children[1], i = this.element.children[2];
|
|
483
|
+
this.splittedWords = [], this.lyricLine.words.forEach((a) => {
|
|
484
|
+
if (b.test(a.word))
|
|
493
485
|
this.splittedWords.push({
|
|
494
|
-
...
|
|
486
|
+
...a,
|
|
495
487
|
width: 0,
|
|
496
488
|
height: 0,
|
|
497
489
|
elements: [],
|
|
498
490
|
elementAnimations: [],
|
|
499
|
-
shouldEmphasize:
|
|
491
|
+
shouldEmphasize: E(a)
|
|
500
492
|
});
|
|
501
493
|
else {
|
|
502
|
-
const
|
|
503
|
-
|
|
494
|
+
const l = /^(\s*)(\S*)(\s*)$/.exec(a.word);
|
|
495
|
+
l ? (l[1].length > 0 && this.splittedWords.push({
|
|
504
496
|
word: " ",
|
|
505
497
|
startTime: 0,
|
|
506
498
|
endTime: 0,
|
|
@@ -510,15 +502,15 @@ class H {
|
|
|
510
502
|
elementAnimations: [],
|
|
511
503
|
shouldEmphasize: !1
|
|
512
504
|
}), this.splittedWords.push({
|
|
513
|
-
word:
|
|
514
|
-
startTime:
|
|
515
|
-
endTime:
|
|
505
|
+
word: l[2],
|
|
506
|
+
startTime: a.startTime,
|
|
507
|
+
endTime: a.endTime,
|
|
516
508
|
width: 0,
|
|
517
509
|
height: 0,
|
|
518
510
|
elements: [],
|
|
519
511
|
elementAnimations: [],
|
|
520
|
-
shouldEmphasize:
|
|
521
|
-
}),
|
|
512
|
+
shouldEmphasize: E(a)
|
|
513
|
+
}), l[3].length > 0 && this.splittedWords.push({
|
|
522
514
|
word: " ",
|
|
523
515
|
startTime: 0,
|
|
524
516
|
endTime: 0,
|
|
@@ -527,55 +519,64 @@ class H {
|
|
|
527
519
|
elements: [],
|
|
528
520
|
elementAnimations: [],
|
|
529
521
|
shouldEmphasize: !1
|
|
530
|
-
}))
|
|
522
|
+
})) : a.word.trim().length > 0 && this.splittedWords.push({
|
|
523
|
+
word: a.word.trim(),
|
|
524
|
+
startTime: a.startTime,
|
|
525
|
+
endTime: a.endTime,
|
|
526
|
+
width: 0,
|
|
527
|
+
height: 0,
|
|
528
|
+
elements: [],
|
|
529
|
+
elementAnimations: [],
|
|
530
|
+
shouldEmphasize: E(a)
|
|
531
|
+
});
|
|
531
532
|
}
|
|
532
533
|
});
|
|
533
|
-
const
|
|
534
|
-
function
|
|
535
|
-
for (;
|
|
536
|
-
|
|
534
|
+
const n = [], h = [];
|
|
535
|
+
function s(a) {
|
|
536
|
+
for (; a.firstChild; )
|
|
537
|
+
a.firstChild.nodeType === Node.ELEMENT_NODE ? n.push(e.firstChild) : a.firstChild.nodeType === Node.TEXT_NODE && h.push(e.firstChild), a.removeChild(a.firstChild), s(a.firstChild);
|
|
537
538
|
}
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
this.splittedWords.forEach((
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
for (const
|
|
546
|
-
const
|
|
547
|
-
|
|
539
|
+
s(e);
|
|
540
|
+
let r = null;
|
|
541
|
+
this.splittedWords.forEach((a) => {
|
|
542
|
+
if (a.word.trim().length > 0)
|
|
543
|
+
if (a.shouldEmphasize) {
|
|
544
|
+
const l = n.pop() ?? document.createElement("span");
|
|
545
|
+
l.className = "emphasize", a.elements = [l];
|
|
546
|
+
for (const o of a.word) {
|
|
547
|
+
const d = n.pop() ?? document.createElement("span");
|
|
548
|
+
d.className = "", d.innerText = o, l.appendChild(d), a.elements.push(d);
|
|
548
549
|
}
|
|
549
|
-
if (
|
|
550
|
-
if (
|
|
551
|
-
|
|
550
|
+
if (a.elementAnimations = this.initEmphasizeAnimation(a), console.log(a.word, b.test(a.word)), r && !b.test(a.word))
|
|
551
|
+
if (r.childElementCount > 0)
|
|
552
|
+
r.appendChild(l);
|
|
552
553
|
else {
|
|
553
|
-
const
|
|
554
|
-
|
|
554
|
+
const o = n.pop() ?? document.createElement("span");
|
|
555
|
+
o.className = "", r.remove(), o.appendChild(r), o.appendChild(l), e.appendChild(o), r = o;
|
|
555
556
|
}
|
|
556
557
|
else
|
|
557
|
-
|
|
558
|
+
r = b.test(a.word) ? null : l, e.appendChild(l);
|
|
558
559
|
} else {
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
if (
|
|
562
|
-
|
|
560
|
+
const l = n.pop() ?? document.createElement("span");
|
|
561
|
+
if (l.className = "", l.innerText = a.word, a.elements = [l], a.elementAnimations.push(this.initFloatAnimation(a, l)), r)
|
|
562
|
+
if (r.childElementCount > 0)
|
|
563
|
+
r.appendChild(l);
|
|
563
564
|
else {
|
|
564
|
-
const
|
|
565
|
-
|
|
565
|
+
const o = n.pop() ?? document.createElement("span");
|
|
566
|
+
o.className = "", r.remove(), o.appendChild(r), o.appendChild(l), e.appendChild(o), r = o;
|
|
566
567
|
}
|
|
567
568
|
else
|
|
568
|
-
|
|
569
|
+
r = l, e.appendChild(l);
|
|
569
570
|
}
|
|
570
|
-
else if (
|
|
571
|
-
const
|
|
572
|
-
|
|
571
|
+
else if (a.word.length > 0) {
|
|
572
|
+
const l = h.pop() ?? document.createTextNode(" ");
|
|
573
|
+
e.appendChild(l), r = null;
|
|
573
574
|
} else
|
|
574
|
-
|
|
575
|
-
}),
|
|
575
|
+
r = null;
|
|
576
|
+
}), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
|
|
576
577
|
}
|
|
577
|
-
initFloatAnimation(
|
|
578
|
-
const
|
|
578
|
+
initFloatAnimation(e, t) {
|
|
579
|
+
const i = t.animate(
|
|
579
580
|
[
|
|
580
581
|
{
|
|
581
582
|
transform: "translateY(0px)"
|
|
@@ -585,22 +586,22 @@ class H {
|
|
|
585
586
|
}
|
|
586
587
|
],
|
|
587
588
|
{
|
|
588
|
-
duration: Math.max(1e3,
|
|
589
|
-
delay:
|
|
589
|
+
duration: Math.max(1e3, e.endTime - e.startTime),
|
|
590
|
+
delay: e.startTime - this.lyricLine.startTime,
|
|
590
591
|
id: "float-word",
|
|
591
592
|
composite: "add",
|
|
592
593
|
fill: "both"
|
|
593
594
|
}
|
|
594
595
|
);
|
|
595
|
-
return
|
|
596
|
+
return i.pause(), i;
|
|
596
597
|
}
|
|
597
|
-
initEmphasizeAnimation(
|
|
598
|
-
const
|
|
599
|
-
return
|
|
600
|
-
if (
|
|
601
|
-
return this.initFloatAnimation(
|
|
598
|
+
initEmphasizeAnimation(e) {
|
|
599
|
+
const t = e.startTime - this.lyricLine.startTime, i = e.endTime - e.startTime;
|
|
600
|
+
return e.elements.map((n, h, s) => {
|
|
601
|
+
if (h === 0)
|
|
602
|
+
return this.initFloatAnimation(e, n);
|
|
602
603
|
{
|
|
603
|
-
const
|
|
604
|
+
const r = n.animate(
|
|
604
605
|
[
|
|
605
606
|
{
|
|
606
607
|
offset: 0,
|
|
@@ -619,211 +620,98 @@ class H {
|
|
|
619
620
|
}
|
|
620
621
|
],
|
|
621
622
|
{
|
|
622
|
-
duration: Math.max(1e3,
|
|
623
|
-
delay:
|
|
623
|
+
duration: Math.max(1e3, e.endTime - e.startTime),
|
|
624
|
+
delay: t + i / (s.length - 1) * (h - 1),
|
|
624
625
|
id: "glow-word",
|
|
625
626
|
iterations: 1,
|
|
626
627
|
composite: "replace",
|
|
627
628
|
fill: "both"
|
|
628
629
|
}
|
|
629
630
|
);
|
|
630
|
-
return
|
|
631
|
+
return r.pause(), r;
|
|
631
632
|
}
|
|
632
633
|
});
|
|
633
634
|
}
|
|
634
635
|
updateMaskImage() {
|
|
635
|
-
this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden"), this.splittedWords.forEach((
|
|
636
|
-
const
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
const [
|
|
640
|
-
16 /
|
|
636
|
+
this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden"), this.splittedWords.forEach((e) => {
|
|
637
|
+
const t = e.elements[0];
|
|
638
|
+
if (t) {
|
|
639
|
+
e.width = t.clientWidth, e.height = t.clientHeight;
|
|
640
|
+
const [i, n, h] = F(
|
|
641
|
+
16 / e.width,
|
|
641
642
|
"rgba(0,0,0,0.75)",
|
|
642
643
|
"rgba(0,0,0,0.25)"
|
|
643
|
-
),
|
|
644
|
-
this.lyricPlayer.supportMaskImage ? (
|
|
645
|
-
const
|
|
646
|
-
|
|
644
|
+
), s = `${h * 100}% 100%`;
|
|
645
|
+
this.lyricPlayer.supportMaskImage ? (t.style.maskImage = i, t.style.maskOrigin = "left", t.style.maskSize = s) : (t.style.webkitMaskImage = i, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = s);
|
|
646
|
+
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`;
|
|
647
|
+
t.style.maskPosition = a, t.style.webkitMaskPosition = a;
|
|
647
648
|
}
|
|
648
649
|
}), this._hide && (this.element.style.display = "none", this.element.style.visibility = "");
|
|
649
650
|
}
|
|
650
651
|
getElement() {
|
|
651
652
|
return this.element;
|
|
652
653
|
}
|
|
653
|
-
setTransform(
|
|
654
|
-
this.left =
|
|
655
|
-
const
|
|
656
|
-
|
|
654
|
+
setTransform(e = this.left, t = this.top, i = this.scale, n = 1, h = 0, s = !1, r = 0) {
|
|
655
|
+
this.left = e, this.top = t, this.scale = i, this.delay = r * 1e3 | 0;
|
|
656
|
+
const a = this.element.children[0];
|
|
657
|
+
a.style.opacity = `${n}`, s || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, h), s && this.element.classList.add(
|
|
657
658
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
658
|
-
), this.lineTransforms.posX.setPosition(
|
|
659
|
+
), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(i), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), s && requestAnimationFrame(() => {
|
|
659
660
|
this.element.classList.remove(
|
|
660
661
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
661
662
|
);
|
|
662
|
-
})) : (this.lineTransforms.posX.setTargetPosition(
|
|
663
|
+
})) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(i), this.blur !== Math.min(32, h) && (this.blur = Math.min(32, h), this.element.style.filter = `blur(${Math.min(32, h)}px)`));
|
|
663
664
|
}
|
|
664
|
-
update(
|
|
665
|
-
this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(
|
|
665
|
+
update(e = 0) {
|
|
666
|
+
this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.lineTransforms.scale.update(e), this.isInSight ? this.show() : this.hide());
|
|
666
667
|
}
|
|
667
668
|
get isInSight() {
|
|
668
|
-
const
|
|
669
|
-
return !(
|
|
669
|
+
const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], n = t + this.lineSize[1], h = 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];
|
|
670
|
+
return !(e > r || t > a || i < h || n < s);
|
|
670
671
|
}
|
|
671
672
|
dispose() {
|
|
672
673
|
this.element.remove();
|
|
673
674
|
}
|
|
674
675
|
}
|
|
675
|
-
const
|
|
676
|
-
class
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
h(this, "size", [0, 0]);
|
|
715
|
-
h(this, "pos", [0, 0]);
|
|
716
|
-
h(this, "style", J.createStyleSheet({
|
|
717
|
-
lyricPlayer: {
|
|
718
|
-
userSelect: "none",
|
|
719
|
-
padding: "1rem",
|
|
720
|
-
boxSizing: "border-box",
|
|
721
|
-
fontSize: "max(5vh, 12px)",
|
|
722
|
-
fontWeight: "bold",
|
|
723
|
-
width: "100%",
|
|
724
|
-
height: "100%",
|
|
725
|
-
overflow: "hidden",
|
|
726
|
-
maxWidth: "100%",
|
|
727
|
-
maxHeight: "100%",
|
|
728
|
-
zIndex: 1,
|
|
729
|
-
color: "var(--amll-lyric-line-color)",
|
|
730
|
-
mixBlendMode: "plus-lighter",
|
|
731
|
-
contain: "strict"
|
|
732
|
-
},
|
|
733
|
-
lyricLine: {
|
|
734
|
-
position: "absolute",
|
|
735
|
-
transformOrigin: "left",
|
|
736
|
-
maxWidth: "65%",
|
|
737
|
-
padding: "max(2vh, 1rem) 1rem",
|
|
738
|
-
contain: "content",
|
|
739
|
-
transition: "filter 0.25s",
|
|
740
|
-
margin: "max(2vh, 1rem) -1rem"
|
|
741
|
-
},
|
|
742
|
-
"@media (max-width: 1024px)": {
|
|
743
|
-
lyricLine: {
|
|
744
|
-
maxWidth: "75%",
|
|
745
|
-
padding: "max(1vh, 1rem) 1rem",
|
|
746
|
-
margin: "0 -1rem"
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
lyricDuetLine: {
|
|
750
|
-
textAlign: "right",
|
|
751
|
-
transformOrigin: "right"
|
|
752
|
-
},
|
|
753
|
-
lyricBgLine: {
|
|
754
|
-
opacity: 0,
|
|
755
|
-
fontSize: "max(50%, 10px)",
|
|
756
|
-
transition: "opacity 0.25s",
|
|
757
|
-
"&.active": {
|
|
758
|
-
transition: "opacity 0.25s 0.25s",
|
|
759
|
-
opacity: 1
|
|
760
|
-
}
|
|
761
|
-
},
|
|
762
|
-
lyricMainLine: {
|
|
763
|
-
transition: "opacity 0.3s 0.25s",
|
|
764
|
-
margin: "-1rem",
|
|
765
|
-
padding: "1rem",
|
|
766
|
-
"& span": {
|
|
767
|
-
display: "inline-block",
|
|
768
|
-
margin: "-1rem",
|
|
769
|
-
padding: "1rem"
|
|
770
|
-
},
|
|
771
|
-
"& > span": {
|
|
772
|
-
whiteSpace: "pre-wrap",
|
|
773
|
-
wordBreak: "keep-all",
|
|
774
|
-
maxLines: "1",
|
|
775
|
-
"&.emphasize": {
|
|
776
|
-
margin: "-1rem",
|
|
777
|
-
padding: "1rem",
|
|
778
|
-
transformStyle: "preserve-3d",
|
|
779
|
-
perspective: "50vw"
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
lyricSubLine: {
|
|
784
|
-
fontSize: "max(50%, 10px)",
|
|
785
|
-
opacity: 0.5
|
|
786
|
-
},
|
|
787
|
-
disableSpring: {
|
|
788
|
-
"& > *": {
|
|
789
|
-
transition: "filter 0.25s, transform 0.5s"
|
|
790
|
-
}
|
|
791
|
-
},
|
|
792
|
-
interludeDots: {
|
|
793
|
-
height: "min(1rem,2.5vh)",
|
|
794
|
-
transformOrigin: "center",
|
|
795
|
-
width: "fit-content",
|
|
796
|
-
padding: "2.5% 0",
|
|
797
|
-
position: "absolute",
|
|
798
|
-
display: "flex",
|
|
799
|
-
gap: "0.5rem",
|
|
800
|
-
"& > *": {
|
|
801
|
-
width: "100%",
|
|
802
|
-
display: "inline-block",
|
|
803
|
-
borderRadius: "50%",
|
|
804
|
-
aspectRatio: "1 / 1",
|
|
805
|
-
backgroundColor: "var(--amll-lyric-line-color)",
|
|
806
|
-
marginRight: "4px"
|
|
807
|
-
},
|
|
808
|
-
"&.duet": {
|
|
809
|
-
right: "1rem",
|
|
810
|
-
transformOrigin: "center"
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
"@supports (mix-blend-mode: plus-lighter)": {
|
|
814
|
-
lyricSubLine: {
|
|
815
|
-
opacity: 0.3
|
|
816
|
-
}
|
|
817
|
-
},
|
|
818
|
-
tmpDisableTransition: {
|
|
819
|
-
transition: "none !important"
|
|
820
|
-
}
|
|
821
|
-
}));
|
|
822
|
-
h(this, "onPageShow", () => {
|
|
823
|
-
this.calcLayout(!0);
|
|
824
|
-
});
|
|
825
|
-
this.interludeDots = new X(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.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow);
|
|
826
|
-
}
|
|
676
|
+
const G = z(A());
|
|
677
|
+
class ee extends EventTarget {
|
|
678
|
+
element = document.createElement("div");
|
|
679
|
+
currentTime = 0;
|
|
680
|
+
lyricLines = [];
|
|
681
|
+
processedLines = [];
|
|
682
|
+
lyricLinesEl = [];
|
|
683
|
+
lyricLinesSize = /* @__PURE__ */ new Map();
|
|
684
|
+
hotLines = /* @__PURE__ */ new Set();
|
|
685
|
+
bufferedLines = /* @__PURE__ */ new Set();
|
|
686
|
+
scrollToIndex = 0;
|
|
687
|
+
resizeObserver = new ResizeObserver((e) => {
|
|
688
|
+
const t = e[0].contentRect;
|
|
689
|
+
this.size[0] = t.width, this.size[1] = t.height, this.pos[0] = t.left, this.pos[1] = t.top, this.rebuildStyle(), this.calcLayout(!0), this.lyricLinesEl.forEach((i) => i.updateMaskImage());
|
|
690
|
+
});
|
|
691
|
+
posXSpringParams = {
|
|
692
|
+
mass: 1,
|
|
693
|
+
damping: 10,
|
|
694
|
+
stiffness: 100
|
|
695
|
+
};
|
|
696
|
+
posYSpringParams = {
|
|
697
|
+
mass: 1,
|
|
698
|
+
damping: 15,
|
|
699
|
+
stiffness: 100
|
|
700
|
+
};
|
|
701
|
+
scaleSpringParams = {
|
|
702
|
+
mass: 1,
|
|
703
|
+
damping: 20,
|
|
704
|
+
stiffness: 100
|
|
705
|
+
};
|
|
706
|
+
enableBlur = !0;
|
|
707
|
+
interludeDots;
|
|
708
|
+
interludeDotsSize = [0, 0];
|
|
709
|
+
supportPlusLighter = CSS.supports("mix-blend-mode", "plus-lighter");
|
|
710
|
+
supportMaskImage = CSS.supports("mask-image", "none");
|
|
711
|
+
disableSpring = !1;
|
|
712
|
+
alignAnchor = 0.5;
|
|
713
|
+
size = [0, 0];
|
|
714
|
+
pos = [0, 0];
|
|
827
715
|
/**
|
|
828
716
|
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
829
717
|
*
|
|
@@ -841,6 +729,118 @@ class he extends EventTarget {
|
|
|
841
729
|
getEnableSpring() {
|
|
842
730
|
return !this.disableSpring;
|
|
843
731
|
}
|
|
732
|
+
style = G.createStyleSheet({
|
|
733
|
+
lyricPlayer: {
|
|
734
|
+
userSelect: "none",
|
|
735
|
+
padding: "1rem",
|
|
736
|
+
boxSizing: "border-box",
|
|
737
|
+
fontSize: "max(5vh, 12px)",
|
|
738
|
+
fontWeight: "bold",
|
|
739
|
+
width: "100%",
|
|
740
|
+
height: "100%",
|
|
741
|
+
overflow: "hidden",
|
|
742
|
+
maxWidth: "100%",
|
|
743
|
+
maxHeight: "100%",
|
|
744
|
+
zIndex: 1,
|
|
745
|
+
color: "var(--amll-lyric-line-color)",
|
|
746
|
+
mixBlendMode: "plus-lighter",
|
|
747
|
+
contain: "strict"
|
|
748
|
+
},
|
|
749
|
+
lyricLine: {
|
|
750
|
+
position: "absolute",
|
|
751
|
+
transformOrigin: "left",
|
|
752
|
+
maxWidth: "65%",
|
|
753
|
+
padding: "max(2vh, 1rem) 1rem",
|
|
754
|
+
contain: "content",
|
|
755
|
+
transition: "filter 0.25s",
|
|
756
|
+
margin: "max(2vh, 1rem) -1rem"
|
|
757
|
+
},
|
|
758
|
+
"@media (max-width: 1024px)": {
|
|
759
|
+
lyricLine: {
|
|
760
|
+
maxWidth: "75%",
|
|
761
|
+
padding: "max(1vh, 1rem) 1rem",
|
|
762
|
+
margin: "0 -1rem"
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
lyricDuetLine: {
|
|
766
|
+
textAlign: "right",
|
|
767
|
+
transformOrigin: "right"
|
|
768
|
+
},
|
|
769
|
+
lyricBgLine: {
|
|
770
|
+
opacity: 0,
|
|
771
|
+
fontSize: "max(50%, 10px)",
|
|
772
|
+
transition: "opacity 0.25s",
|
|
773
|
+
"&.active": {
|
|
774
|
+
transition: "opacity 0.25s 0.25s",
|
|
775
|
+
opacity: 1
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
lyricMainLine: {
|
|
779
|
+
transition: "opacity 0.3s 0.25s",
|
|
780
|
+
margin: "-1rem",
|
|
781
|
+
padding: "1rem",
|
|
782
|
+
"& span": {
|
|
783
|
+
display: "inline-block",
|
|
784
|
+
margin: "-1rem",
|
|
785
|
+
padding: "1rem"
|
|
786
|
+
},
|
|
787
|
+
"& > span": {
|
|
788
|
+
whiteSpace: "pre-wrap",
|
|
789
|
+
wordBreak: "keep-all",
|
|
790
|
+
maxLines: "1",
|
|
791
|
+
"&.emphasize": {
|
|
792
|
+
margin: "-1rem",
|
|
793
|
+
padding: "1rem",
|
|
794
|
+
transformStyle: "preserve-3d",
|
|
795
|
+
perspective: "50vw"
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
lyricSubLine: {
|
|
800
|
+
fontSize: "max(50%, 10px)",
|
|
801
|
+
opacity: 0.5
|
|
802
|
+
},
|
|
803
|
+
disableSpring: {
|
|
804
|
+
"& > *": {
|
|
805
|
+
transition: "filter 0.25s, transform 0.5s"
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
interludeDots: {
|
|
809
|
+
height: "min(1rem,2.5vh)",
|
|
810
|
+
transformOrigin: "center",
|
|
811
|
+
width: "fit-content",
|
|
812
|
+
padding: "2.5% 0",
|
|
813
|
+
position: "absolute",
|
|
814
|
+
display: "flex",
|
|
815
|
+
gap: "0.5rem",
|
|
816
|
+
"& > *": {
|
|
817
|
+
width: "100%",
|
|
818
|
+
display: "inline-block",
|
|
819
|
+
borderRadius: "50%",
|
|
820
|
+
aspectRatio: "1 / 1",
|
|
821
|
+
backgroundColor: "var(--amll-lyric-line-color)",
|
|
822
|
+
marginRight: "4px"
|
|
823
|
+
},
|
|
824
|
+
"&.duet": {
|
|
825
|
+
right: "1rem",
|
|
826
|
+
transformOrigin: "center"
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
"@supports (mix-blend-mode: plus-lighter)": {
|
|
830
|
+
lyricSubLine: {
|
|
831
|
+
opacity: 0.3
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
tmpDisableTransition: {
|
|
835
|
+
transition: "none !important"
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
onPageShow = () => {
|
|
839
|
+
this.calcLayout(!0);
|
|
840
|
+
};
|
|
841
|
+
constructor() {
|
|
842
|
+
super(), this.interludeDots = new W(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.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow);
|
|
843
|
+
}
|
|
844
844
|
/**
|
|
845
845
|
* 获取当前播放时间里是否处于间奏区间
|
|
846
846
|
* 如果是则会返回单位为毫秒的始末时间
|
|
@@ -850,17 +850,16 @@ class he extends EventTarget {
|
|
|
850
850
|
* @returns [开始时间,结束时间] 或 undefined 如果不处于间奏区间
|
|
851
851
|
*/
|
|
852
852
|
getCurrentInterlude() {
|
|
853
|
-
var s, a, l;
|
|
854
853
|
if (this.bufferedLines.size > 0)
|
|
855
854
|
return;
|
|
856
|
-
const e = this.currentTime + 20,
|
|
857
|
-
if (
|
|
858
|
-
if (
|
|
855
|
+
const e = this.currentTime + 20, t = this.scrollToIndex;
|
|
856
|
+
if (t === 0) {
|
|
857
|
+
if (this.processedLines[0]?.startTime && this.processedLines[0].startTime > e)
|
|
859
858
|
return [0, this.processedLines[0].startTime];
|
|
860
|
-
} else if (
|
|
859
|
+
} else if (this.processedLines[t]?.endTime && this.processedLines[t + 1]?.startTime && this.processedLines[t + 1].startTime > e && this.processedLines[t].endTime < e)
|
|
861
860
|
return [
|
|
862
|
-
this.processedLines[
|
|
863
|
-
this.processedLines[
|
|
861
|
+
this.processedLines[t].endTime,
|
|
862
|
+
this.processedLines[t + 1].startTime
|
|
864
863
|
];
|
|
865
864
|
}
|
|
866
865
|
/**
|
|
@@ -885,41 +884,41 @@ class he extends EventTarget {
|
|
|
885
884
|
*/
|
|
886
885
|
setLyricLines(e) {
|
|
887
886
|
this.lyricLines = e;
|
|
888
|
-
const
|
|
889
|
-
this.processedLines = e.map((
|
|
890
|
-
if (
|
|
887
|
+
const t = 750;
|
|
888
|
+
this.processedLines = e.map((i, n, h) => {
|
|
889
|
+
if (i.isBG)
|
|
891
890
|
return {
|
|
892
|
-
...
|
|
891
|
+
...i
|
|
893
892
|
};
|
|
894
893
|
{
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
if (r.endTime <
|
|
894
|
+
const s = h[n - 1], r = h[n - 2];
|
|
895
|
+
if (s?.isBG && r) {
|
|
896
|
+
if (r.endTime < i.startTime)
|
|
898
897
|
return {
|
|
899
|
-
...
|
|
900
|
-
startTime: Math.max(r.endTime,
|
|
898
|
+
...i,
|
|
899
|
+
startTime: Math.max(r.endTime, i.startTime - t) || i.startTime
|
|
901
900
|
};
|
|
902
|
-
} else if (
|
|
901
|
+
} else if (s?.endTime && s.endTime < i.startTime)
|
|
903
902
|
return {
|
|
904
|
-
...
|
|
905
|
-
startTime: Math.max(
|
|
903
|
+
...i,
|
|
904
|
+
startTime: Math.max(s?.endTime, i.startTime - t) || i.startTime
|
|
906
905
|
};
|
|
907
906
|
return {
|
|
908
|
-
...
|
|
907
|
+
...i
|
|
909
908
|
};
|
|
910
909
|
}
|
|
911
|
-
}), this.processedLines.forEach((
|
|
912
|
-
const
|
|
913
|
-
r &&
|
|
914
|
-
}), this.processedLines.forEach((
|
|
915
|
-
if (
|
|
910
|
+
}), this.processedLines.forEach((i, n, h) => {
|
|
911
|
+
const s = h[n + 1], r = i.words[i.words.length - 1];
|
|
912
|
+
r && E(r) && (s ? s.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, s.startTime)) : i.endTime = i.endTime + 1500);
|
|
913
|
+
}), this.processedLines.forEach((i, n, h) => {
|
|
914
|
+
if (i.isBG)
|
|
916
915
|
return;
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
}), this.lyricLinesEl.forEach((
|
|
920
|
-
(
|
|
921
|
-
), this.lyricLinesEl.forEach((
|
|
922
|
-
this.element.appendChild(
|
|
916
|
+
const s = h[n + 1];
|
|
917
|
+
s?.isBG && (s.startTime = Math.min(s.startTime, i.startTime));
|
|
918
|
+
}), this.lyricLinesEl.forEach((i) => i.dispose()), this.lyricLinesEl = this.processedLines.map(
|
|
919
|
+
(i) => new _(this, i)
|
|
920
|
+
), this.lyricLinesEl.forEach((i) => {
|
|
921
|
+
this.element.appendChild(i.getElement()), i.updateMaskImage();
|
|
923
922
|
}), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0);
|
|
924
923
|
}
|
|
925
924
|
/**
|
|
@@ -937,55 +936,50 @@ class he extends EventTarget {
|
|
|
937
936
|
* @param reflow 是否进行重新布局(重新计算每行歌词大小)
|
|
938
937
|
*/
|
|
939
938
|
calcLayout(e = !1) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
this.lyricLinesSize.set(m, p), m.lineSize = p;
|
|
939
|
+
e && (this.lyricLinesEl.forEach((l) => {
|
|
940
|
+
const o = l.measureSize();
|
|
941
|
+
this.lyricLinesSize.set(l, o), l.lineSize = o;
|
|
944
942
|
}), this.interludeDotsSize[0] = this.interludeDots.getElement().clientWidth, this.interludeDotsSize[1] = this.interludeDots.getElement().clientHeight);
|
|
945
|
-
const
|
|
946
|
-
let
|
|
947
|
-
(
|
|
948
|
-
var y;
|
|
949
|
-
return m + (p.getLine().isBG ? 0 : ((y = this.lyricLinesSize.get(p)) == null ? void 0 : y[1]) ?? 0);
|
|
950
|
-
},
|
|
943
|
+
const t = 0.95;
|
|
944
|
+
let n = -this.lyricLinesEl.slice(0, this.scrollToIndex).reduce(
|
|
945
|
+
(l, o) => l + (o.getLine().isBG ? 0 : this.lyricLinesSize.get(o)?.[1] ?? 0),
|
|
951
946
|
0
|
|
952
947
|
);
|
|
953
948
|
if (this.alignAnchor === "bottom") {
|
|
954
|
-
|
|
955
|
-
const
|
|
956
|
-
if (
|
|
957
|
-
const
|
|
958
|
-
|
|
949
|
+
n += this.element.clientHeight / 2;
|
|
950
|
+
const l = this.lyricLinesEl[this.scrollToIndex];
|
|
951
|
+
if (l) {
|
|
952
|
+
const o = this.lyricLinesSize.get(l)?.[1] ?? 0;
|
|
953
|
+
n -= o / 2;
|
|
959
954
|
}
|
|
960
955
|
} else if (typeof this.alignAnchor == "number") {
|
|
961
|
-
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
|
|
956
|
+
n += this.element.clientHeight * this.alignAnchor;
|
|
957
|
+
const l = this.lyricLinesEl[this.scrollToIndex];
|
|
958
|
+
if (l) {
|
|
959
|
+
const o = this.lyricLinesSize.get(l)?.[1] ?? 0;
|
|
960
|
+
n -= o / 2;
|
|
966
961
|
}
|
|
967
962
|
}
|
|
968
|
-
const
|
|
969
|
-
let
|
|
970
|
-
if (
|
|
971
|
-
const
|
|
972
|
-
|
|
963
|
+
const h = this.currentTime === 0 ? void 0 : this.getCurrentInterlude();
|
|
964
|
+
let s = 0;
|
|
965
|
+
if (h && (s = h[1] - h[0], s >= 5e3)) {
|
|
966
|
+
const l = this.currentTime === 0 ? this.lyricLinesEl[0] : this.lyricLinesEl[this.scrollToIndex + 1];
|
|
967
|
+
l && (n -= this.lyricLinesSize.get(l)?.[1] ?? 0);
|
|
973
968
|
}
|
|
974
969
|
const r = Math.max(...this.bufferedLines);
|
|
975
|
-
let
|
|
976
|
-
this.lyricLinesEl.forEach((
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
this.enableBlur ? 3 * (T ? 0 : 1 + (p < this.scrollToIndex ? Math.abs(this.scrollToIndex - p) : Math.abs(p - Math.max(this.scrollToIndex, r)))) : 0,
|
|
970
|
+
let a = 0;
|
|
971
|
+
this.lyricLinesEl.forEach((l, o) => {
|
|
972
|
+
const d = this.bufferedLines.has(o), m = d || o >= this.scrollToIndex && o < r, u = l.getLine();
|
|
973
|
+
let p = 0;
|
|
974
|
+
u.isDuet && (p = this.size[0] - (this.lyricLinesSize.get(l)?.[0] ?? 0)), o === this.scrollToIndex + 1 && s >= 5e3 && (this.interludeDots.setTransform(0, n), this.interludeDots.setInterlude(this.getCurrentInterlude()), n += this.interludeDotsSize[1]), l.setTransform(
|
|
975
|
+
p,
|
|
976
|
+
n,
|
|
977
|
+
m ? 1 : t,
|
|
978
|
+
d ? 1 : 1 / 3,
|
|
979
|
+
this.enableBlur ? 3 * (m ? 0 : 1 + (o < this.scrollToIndex ? Math.abs(this.scrollToIndex - o) : Math.abs(o - Math.max(this.scrollToIndex, r)))) : 0,
|
|
986
980
|
e,
|
|
987
|
-
|
|
988
|
-
),
|
|
981
|
+
a
|
|
982
|
+
), u.isBG && m ? n += this.lyricLinesSize.get(l)?.[1] ?? 0 : u.isBG || (n += this.lyricLinesSize.get(l)?.[1] ?? 0), n >= 0 && (a += 0.05);
|
|
989
983
|
});
|
|
990
984
|
}
|
|
991
985
|
/**
|
|
@@ -1027,36 +1021,35 @@ class he extends EventTarget {
|
|
|
1027
1021
|
* 调用完成后,可以每帧调用 `update` 函数来执行歌词动画效果
|
|
1028
1022
|
* @param time 当前播放进度,单位为毫秒
|
|
1029
1023
|
*/
|
|
1030
|
-
setCurrentTime(e,
|
|
1024
|
+
setCurrentTime(e, t = !1) {
|
|
1031
1025
|
this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`);
|
|
1032
|
-
const
|
|
1033
|
-
this.hotLines.forEach((
|
|
1034
|
-
const r = this.processedLines[
|
|
1026
|
+
const i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
|
|
1027
|
+
this.hotLines.forEach((s) => {
|
|
1028
|
+
const r = this.processedLines[s];
|
|
1035
1029
|
if (!r.isBG)
|
|
1036
1030
|
if (r) {
|
|
1037
|
-
const
|
|
1038
|
-
if (
|
|
1039
|
-
const
|
|
1040
|
-
(
|
|
1031
|
+
const a = this.processedLines[s + 1];
|
|
1032
|
+
if (a?.isBG) {
|
|
1033
|
+
const l = Math.min(r.startTime, a?.startTime), o = Math.max(r.endTime, a?.endTime);
|
|
1034
|
+
(l > e || o <= e) && (this.hotLines.delete(s), i.add(s), this.hotLines.delete(s + 1), i.add(s + 1), t && (this.lyricLinesEl[s].disable(), this.lyricLinesEl[s + 1].disable()));
|
|
1041
1035
|
} else
|
|
1042
|
-
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(
|
|
1036
|
+
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), i.add(s), t && this.lyricLinesEl[s].disable());
|
|
1043
1037
|
} else
|
|
1044
|
-
this.hotLines.delete(
|
|
1045
|
-
}), this.processedLines.forEach((
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
this.bufferedLines.delete(i), this.lyricLinesEl[i].disable();
|
|
1038
|
+
this.hotLines.delete(s), i.add(s), t && this.lyricLinesEl[s].disable();
|
|
1039
|
+
}), this.processedLines.forEach((s, r, a) => {
|
|
1040
|
+
!s.isBG && s.startTime <= e && s.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), h.add(r), t && this.lyricLinesEl[r].enable(), a[r + 1]?.isBG && (this.hotLines.add(r + 1), h.add(r + 1), t && this.lyricLinesEl[r + 1].enable())));
|
|
1041
|
+
}), this.bufferedLines.forEach((s) => {
|
|
1042
|
+
this.hotLines.has(s) || (n.add(s), t && this.lyricLinesEl[s].disable());
|
|
1043
|
+
}), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
|
|
1044
|
+
(s) => s.startTime >= e
|
|
1045
|
+
), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (n.size > 0 || h.size > 0) && (n.size === 0 && h.size > 0 ? (h.forEach((s) => {
|
|
1046
|
+
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1047
|
+
}), this.scrollToIndex = Math.min(...this.bufferedLines)) : h.size === 0 && n.size > 0 ? N(n, this.bufferedLines) && this.bufferedLines.forEach((s) => {
|
|
1048
|
+
this.hotLines.has(s) || (this.bufferedLines.delete(s), this.lyricLinesEl[s].disable());
|
|
1049
|
+
}) : (h.forEach((s) => {
|
|
1050
|
+
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1051
|
+
}), n.forEach((s) => {
|
|
1052
|
+
this.bufferedLines.delete(s), this.lyricLinesEl[s].disable();
|
|
1060
1053
|
}), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines))), this.calcLayout());
|
|
1061
1054
|
}
|
|
1062
1055
|
/**
|
|
@@ -1066,8 +1059,8 @@ class he extends EventTarget {
|
|
|
1066
1059
|
* @param delta 距离上一次被调用到现在的时长,单位为毫秒(可为浮点数)
|
|
1067
1060
|
*/
|
|
1068
1061
|
update(e = 0) {
|
|
1069
|
-
const
|
|
1070
|
-
this.interludeDots.update(e), this.lyricLinesEl.forEach((
|
|
1062
|
+
const t = e / 1e3;
|
|
1063
|
+
this.interludeDots.update(e), this.lyricLinesEl.forEach((i) => i.update(t));
|
|
1071
1064
|
}
|
|
1072
1065
|
/**
|
|
1073
1066
|
* 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
|
|
@@ -1079,7 +1072,7 @@ class he extends EventTarget {
|
|
|
1079
1072
|
...this.posXSpringParams,
|
|
1080
1073
|
...e
|
|
1081
1074
|
}, this.lyricLinesEl.forEach(
|
|
1082
|
-
(
|
|
1075
|
+
(t) => t.lineTransforms.posX.updateParams(this.posXSpringParams)
|
|
1083
1076
|
);
|
|
1084
1077
|
}
|
|
1085
1078
|
/**
|
|
@@ -1092,7 +1085,7 @@ class he extends EventTarget {
|
|
|
1092
1085
|
...this.posYSpringParams,
|
|
1093
1086
|
...e
|
|
1094
1087
|
}, this.lyricLinesEl.forEach(
|
|
1095
|
-
(
|
|
1088
|
+
(t) => t.lineTransforms.posY.updateParams(this.posYSpringParams)
|
|
1096
1089
|
);
|
|
1097
1090
|
}
|
|
1098
1091
|
/**
|
|
@@ -1105,7 +1098,7 @@ class he extends EventTarget {
|
|
|
1105
1098
|
...this.scaleSpringParams,
|
|
1106
1099
|
...e
|
|
1107
1100
|
}, this.lyricLinesEl.forEach(
|
|
1108
|
-
(
|
|
1101
|
+
(t) => t.lineTransforms.scale.updateParams(this.scaleSpringParams)
|
|
1109
1102
|
);
|
|
1110
1103
|
}
|
|
1111
1104
|
dispose() {
|
|
@@ -1113,8 +1106,8 @@ class he extends EventTarget {
|
|
|
1113
1106
|
}
|
|
1114
1107
|
}
|
|
1115
1108
|
export {
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1109
|
+
Z as BackgroundRender,
|
|
1110
|
+
ee as LyricPlayer,
|
|
1111
|
+
Q as ttml
|
|
1119
1112
|
};
|
|
1120
1113
|
//# sourceMappingURL=amll-core.mjs.map
|