@applemusic-like-lyrics/core 0.0.6 → 0.0.8
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 +595 -625
- package/dist/amll-core.mjs.map +1 -1
- package/dist/lyric-player/index.d.ts +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 E } 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(d) {
|
|
11
|
+
const e = D.exec(d);
|
|
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
|
|
24
|
-
|
|
18
|
+
function I(d) {
|
|
19
|
+
const t = new DOMParser().parseFromString(
|
|
20
|
+
d,
|
|
25
21
|
"application/xml"
|
|
26
22
|
);
|
|
27
|
-
let
|
|
28
|
-
for (const a of
|
|
23
|
+
let i = "v1";
|
|
24
|
+
for (const a of t.querySelectorAll("ttm\\:agent"))
|
|
29
25
|
if (a.getAttribute("type") === "person") {
|
|
30
|
-
const
|
|
31
|
-
|
|
26
|
+
const s = a.getAttribute("xml:id");
|
|
27
|
+
s && (i = s);
|
|
32
28
|
}
|
|
33
|
-
const
|
|
34
|
-
for (const a of
|
|
35
|
-
const
|
|
29
|
+
const n = [];
|
|
30
|
+
for (const a of t.querySelectorAll("body p[begin][end]")) {
|
|
31
|
+
const s = {
|
|
36
32
|
words: [],
|
|
37
|
-
startTime:
|
|
38
|
-
endTime:
|
|
33
|
+
startTime: T(a.getAttribute("begin") ?? "0:0"),
|
|
34
|
+
endTime: T(a.getAttribute("end") ?? "0:0"),
|
|
39
35
|
translatedLyric: "",
|
|
40
36
|
romanLyric: "",
|
|
41
37
|
isBG: !1,
|
|
42
|
-
isDuet: a.getAttribute("ttm:agent") !==
|
|
38
|
+
isDuet: a.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 l of a.childNodes)
|
|
42
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
43
|
+
const h = l.textContent ?? "";
|
|
44
|
+
/^(\s+)$/.test(h) ? s.words.push({
|
|
49
45
|
word: " ",
|
|
50
46
|
startTime: 0,
|
|
51
47
|
endTime: 0
|
|
52
|
-
}) :
|
|
53
|
-
word:
|
|
48
|
+
}) : s.words.push({
|
|
49
|
+
word: h,
|
|
54
50
|
startTime: 0,
|
|
55
51
|
endTime: 0
|
|
56
52
|
});
|
|
57
|
-
} else if (
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
53
|
+
} else if (l.nodeType === Node.ELEMENT_NODE) {
|
|
54
|
+
const h = l, o = h.getAttribute("ttm:role");
|
|
55
|
+
if (h.nodeName === "span" && o)
|
|
56
|
+
if (o === "x-bg") {
|
|
57
|
+
const c = {
|
|
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
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
/^(\s+)$/.test(
|
|
66
|
+
for (const u of h.childNodes)
|
|
67
|
+
if (u.nodeType === Node.TEXT_NODE) {
|
|
68
|
+
const f = u.textContent ?? "";
|
|
69
|
+
/^(\s+)$/.test(f) ? c.words.push({
|
|
74
70
|
word: " ",
|
|
75
71
|
startTime: 0,
|
|
76
72
|
endTime: 0
|
|
77
|
-
}) :
|
|
78
|
-
word:
|
|
73
|
+
}) : c.words.push({
|
|
74
|
+
word: f,
|
|
79
75
|
startTime: 0,
|
|
80
76
|
endTime: 0
|
|
81
77
|
});
|
|
82
|
-
} else if (
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
else if (
|
|
87
|
-
const
|
|
88
|
-
word:
|
|
89
|
-
startTime:
|
|
90
|
-
endTime:
|
|
78
|
+
} else if (u.nodeType === Node.ELEMENT_NODE) {
|
|
79
|
+
const f = u, b = f.getAttribute("ttm:role");
|
|
80
|
+
if (f.nodeName === "span" && b)
|
|
81
|
+
b === "x-translation" ? c.translatedLyric = f.innerHTML.trim() : b === "x-roman" && (c.romanLyric = f.innerHTML.trim());
|
|
82
|
+
else if (f.hasAttribute("begin") && f.hasAttribute("end")) {
|
|
83
|
+
const x = {
|
|
84
|
+
word: u.textContent,
|
|
85
|
+
startTime: T(f.getAttribute("begin")),
|
|
86
|
+
endTime: T(f.getAttribute("end"))
|
|
91
87
|
};
|
|
92
|
-
|
|
88
|
+
c.words.push(x);
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
91
|
+
const m = c.words[0];
|
|
92
|
+
c.startTime = m.startTime, m?.word.startsWith("(") && (m.word = m.word.substring(1));
|
|
93
|
+
const p = c.words[c.words.length - 1];
|
|
94
|
+
c.endTime = p.endTime, p?.word.endsWith(")") && (p.word = p.word.substring(
|
|
99
95
|
0,
|
|
100
|
-
|
|
101
|
-
)),
|
|
96
|
+
p.word.length - 1
|
|
97
|
+
)), r = c;
|
|
102
98
|
} else
|
|
103
|
-
|
|
104
|
-
else if (
|
|
105
|
-
const
|
|
106
|
-
word:
|
|
107
|
-
startTime:
|
|
108
|
-
endTime:
|
|
99
|
+
o === "x-translation" ? s.translatedLyric = h.innerHTML : o === "x-roman" && (s.romanLyric = h.innerHTML);
|
|
100
|
+
else if (h.hasAttribute("begin") && h.hasAttribute("end")) {
|
|
101
|
+
const c = {
|
|
102
|
+
word: l.textContent ?? "",
|
|
103
|
+
startTime: T(h.getAttribute("begin")),
|
|
104
|
+
endTime: T(h.getAttribute("end"))
|
|
109
105
|
};
|
|
110
|
-
|
|
106
|
+
s.words.push(c);
|
|
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, a] = 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), a.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, a.width = s * 0.25, a.height = a.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, a.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), 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);
|
|
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 E();
|
|
181
|
+
t.saturate(1.2, !1);
|
|
182
|
+
const i = new E();
|
|
183
|
+
i.brightness(0.6, !1);
|
|
184
|
+
const n = new E();
|
|
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), a = new L(t), s = new L(t), r = new L(t);
|
|
214
|
+
n.anchor.set(0.5, 0.5), a.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, a.rotation = Math.random() * Math.PI * 2, s.rotation = Math.random() * Math.PI * 2, r.rotation = Math.random() * Math.PI * 2, i.addChild(n, a, 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
|
|
233
|
+
const N = (d, e) => d.size === e.size && [...d].every((t) => e.has(t));
|
|
234
|
+
function O(d) {
|
|
235
|
+
const t = 2.5949095;
|
|
236
|
+
return d < 0.5 ? Math.pow(2 * d, 2) * ((t + 1) * 2 * d - t) / 2 : (Math.pow(2 * d - 2, 2) * ((t + 1) * (d * 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 = (d, e, t) => Math.max(d, Math.min(e, t));
|
|
239
|
+
class $ {
|
|
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 a =
|
|
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 a = i / Math.ceil(i / this.targetBreatheDuration);
|
|
270
|
+
let s = 1, r = 1;
|
|
271
|
+
s *= Math.sin(1.5 * Math.PI - n / a * 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 l = g(
|
|
287
279
|
0.25,
|
|
288
|
-
|
|
280
|
+
n * 3 / i * 0.75,
|
|
289
281
|
1
|
|
290
|
-
),
|
|
282
|
+
), h = 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 * l),
|
|
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 * h),
|
|
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 S {
|
|
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 = q(
|
|
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 a =
|
|
376
|
-
if (a || 1 <=
|
|
377
|
-
const
|
|
378
|
-
return (
|
|
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));
|
|
379
371
|
} else {
|
|
380
|
-
const
|
|
381
|
-
4 *
|
|
382
|
-
),
|
|
383
|
-
return (
|
|
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));
|
|
384
376
|
}
|
|
385
377
|
}
|
|
386
|
-
function
|
|
387
|
-
return (
|
|
378
|
+
function F(d) {
|
|
379
|
+
return (t) => (d(t + 1e-3) - d(t - 1e-3)) / (2 * 1e-3);
|
|
388
380
|
}
|
|
389
|
-
function
|
|
390
|
-
return
|
|
381
|
+
function R(d) {
|
|
382
|
+
return F(d);
|
|
391
383
|
}
|
|
392
384
|
const w = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
|
|
393
|
-
function
|
|
394
|
-
const
|
|
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;
|
|
395
387
|
return [
|
|
396
|
-
`linear-gradient(to right,${
|
|
397
|
-
|
|
398
|
-
|
|
388
|
+
`linear-gradient(to right,${e} ${a * 100}%,${t} ${(a + n) * 100}%)`,
|
|
389
|
+
n,
|
|
390
|
+
i
|
|
399
391
|
];
|
|
400
392
|
}
|
|
401
|
-
function
|
|
402
|
-
return
|
|
393
|
+
function P(d) {
|
|
394
|
+
return d.endTime - d.startTime >= 1e3 && d.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], a = this.element.children[2];
|
|
411
|
+
i.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), n.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), a.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 S(0),
|
|
424
|
+
posY: new S(0),
|
|
425
|
+
scale: new S(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,16 @@ 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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
height: 0,
|
|
497
|
-
elements: [],
|
|
498
|
-
elementAnimations: [],
|
|
499
|
-
shouldEmphasize: v(r)
|
|
500
|
-
});
|
|
501
|
-
else {
|
|
502
|
-
const o = /(\s*)(\S*)(\s*)/.exec(r.word);
|
|
503
|
-
o && (o[1].length > 0 && this.splittedWords.push({
|
|
482
|
+
const e = this.element.children[0], t = this.element.children[1], i = this.element.children[2];
|
|
483
|
+
this.splittedWords = [], this.lyricLine.words.forEach((l) => {
|
|
484
|
+
const h = l.word.split(/\s+/), o = h.reduce((m, p) => m + p.length, 0);
|
|
485
|
+
let c = 0;
|
|
486
|
+
h.forEach((m, p) => {
|
|
487
|
+
p > 0 && this.splittedWords.push({
|
|
504
488
|
word: " ",
|
|
505
489
|
startTime: 0,
|
|
506
490
|
endTime: 0,
|
|
@@ -510,72 +494,63 @@ class H {
|
|
|
510
494
|
elementAnimations: [],
|
|
511
495
|
shouldEmphasize: !1
|
|
512
496
|
}), this.splittedWords.push({
|
|
513
|
-
word:
|
|
514
|
-
startTime:
|
|
515
|
-
endTime:
|
|
497
|
+
word: m,
|
|
498
|
+
startTime: l.startTime + (l.endTime - l.startTime) / o * c,
|
|
499
|
+
endTime: l.startTime + (l.endTime - l.startTime) / o * (c + m.length),
|
|
516
500
|
width: 0,
|
|
517
501
|
height: 0,
|
|
518
502
|
elements: [],
|
|
519
503
|
elementAnimations: [],
|
|
520
|
-
shouldEmphasize:
|
|
521
|
-
}),
|
|
522
|
-
|
|
523
|
-
startTime: 0,
|
|
524
|
-
endTime: 0,
|
|
525
|
-
width: 0,
|
|
526
|
-
height: 0,
|
|
527
|
-
elements: [],
|
|
528
|
-
elementAnimations: [],
|
|
529
|
-
shouldEmphasize: !1
|
|
530
|
-
}));
|
|
531
|
-
}
|
|
504
|
+
shouldEmphasize: P(l)
|
|
505
|
+
}), c += m.length;
|
|
506
|
+
});
|
|
532
507
|
});
|
|
533
|
-
const
|
|
534
|
-
function l
|
|
535
|
-
for (;
|
|
536
|
-
|
|
508
|
+
const n = [], a = [];
|
|
509
|
+
function s(l) {
|
|
510
|
+
for (; l.firstChild; )
|
|
511
|
+
l.firstChild.nodeType === Node.ELEMENT_NODE ? n.push(e.firstChild) : l.firstChild.nodeType === Node.TEXT_NODE && a.push(e.firstChild), l.removeChild(l.firstChild), s(l.firstChild);
|
|
537
512
|
}
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
this.splittedWords.forEach((
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
for (const
|
|
546
|
-
const
|
|
547
|
-
|
|
513
|
+
s(e);
|
|
514
|
+
let r = null;
|
|
515
|
+
this.splittedWords.forEach((l) => {
|
|
516
|
+
if (l.word.trim().length > 0)
|
|
517
|
+
if (l.shouldEmphasize) {
|
|
518
|
+
const h = n.pop() ?? document.createElement("span");
|
|
519
|
+
h.className = "emphasize", l.elements = [h];
|
|
520
|
+
for (const o of l.word) {
|
|
521
|
+
const c = n.pop() ?? document.createElement("span");
|
|
522
|
+
c.className = "", c.innerText = o, h.appendChild(c), l.elements.push(c);
|
|
548
523
|
}
|
|
549
|
-
if (
|
|
550
|
-
if (
|
|
551
|
-
|
|
524
|
+
if (l.elementAnimations = this.initEmphasizeAnimation(l), console.log(l.word, w.test(l.word)), r && !w.test(l.word))
|
|
525
|
+
if (r.childElementCount > 0)
|
|
526
|
+
r.appendChild(h);
|
|
552
527
|
else {
|
|
553
|
-
const
|
|
554
|
-
|
|
528
|
+
const o = n.pop() ?? document.createElement("span");
|
|
529
|
+
o.className = "", r.remove(), o.appendChild(r), o.appendChild(h), e.appendChild(o), r = o;
|
|
555
530
|
}
|
|
556
531
|
else
|
|
557
|
-
|
|
532
|
+
r = w.test(l.word) ? null : h, e.appendChild(h);
|
|
558
533
|
} else {
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
if (
|
|
562
|
-
|
|
534
|
+
const h = n.pop() ?? document.createElement("span");
|
|
535
|
+
if (h.className = "", h.innerText = l.word, l.elements = [h], l.elementAnimations.push(this.initFloatAnimation(l, h)), r)
|
|
536
|
+
if (r.childElementCount > 0)
|
|
537
|
+
r.appendChild(h);
|
|
563
538
|
else {
|
|
564
|
-
const
|
|
565
|
-
|
|
539
|
+
const o = n.pop() ?? document.createElement("span");
|
|
540
|
+
o.className = "", r.remove(), o.appendChild(r), o.appendChild(h), e.appendChild(o), r = o;
|
|
566
541
|
}
|
|
567
542
|
else
|
|
568
|
-
|
|
543
|
+
r = h, e.appendChild(h);
|
|
569
544
|
}
|
|
570
|
-
else if (
|
|
571
|
-
const
|
|
572
|
-
|
|
545
|
+
else if (l.word.length > 0) {
|
|
546
|
+
const h = a.pop() ?? document.createTextNode(" ");
|
|
547
|
+
e.appendChild(h), r = null;
|
|
573
548
|
} else
|
|
574
|
-
|
|
575
|
-
}),
|
|
549
|
+
r = null;
|
|
550
|
+
}), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
|
|
576
551
|
}
|
|
577
|
-
initFloatAnimation(
|
|
578
|
-
const n = e.animate(
|
|
552
|
+
initFloatAnimation(e, t) {
|
|
553
|
+
const i = e.startTime - this.lyricLine.startTime, n = Math.max(1e3, e.endTime - e.startTime), a = t.animate(
|
|
579
554
|
[
|
|
580
555
|
{
|
|
581
556
|
transform: "translateY(0px)"
|
|
@@ -585,22 +560,22 @@ class H {
|
|
|
585
560
|
}
|
|
586
561
|
],
|
|
587
562
|
{
|
|
588
|
-
duration:
|
|
589
|
-
delay:
|
|
563
|
+
duration: isFinite(n) ? n : 0,
|
|
564
|
+
delay: isFinite(i) ? i : 0,
|
|
590
565
|
id: "float-word",
|
|
591
566
|
composite: "add",
|
|
592
567
|
fill: "both"
|
|
593
568
|
}
|
|
594
569
|
);
|
|
595
|
-
return
|
|
570
|
+
return a.pause(), a;
|
|
596
571
|
}
|
|
597
|
-
initEmphasizeAnimation(
|
|
598
|
-
const
|
|
599
|
-
return
|
|
572
|
+
initEmphasizeAnimation(e) {
|
|
573
|
+
const t = e.startTime - this.lyricLine.startTime, i = e.endTime - e.startTime;
|
|
574
|
+
return e.elements.map((n, a, s) => {
|
|
600
575
|
if (a === 0)
|
|
601
|
-
return this.initFloatAnimation(
|
|
576
|
+
return this.initFloatAnimation(e, n);
|
|
602
577
|
{
|
|
603
|
-
const
|
|
578
|
+
const r = n.animate(
|
|
604
579
|
[
|
|
605
580
|
{
|
|
606
581
|
offset: 0,
|
|
@@ -619,211 +594,98 @@ class H {
|
|
|
619
594
|
}
|
|
620
595
|
],
|
|
621
596
|
{
|
|
622
|
-
duration: Math.max(1e3,
|
|
623
|
-
delay:
|
|
597
|
+
duration: Math.max(1e3, e.endTime - e.startTime),
|
|
598
|
+
delay: t + i / (s.length - 1) * (a - 1),
|
|
624
599
|
id: "glow-word",
|
|
625
600
|
iterations: 1,
|
|
626
601
|
composite: "replace",
|
|
627
602
|
fill: "both"
|
|
628
603
|
}
|
|
629
604
|
);
|
|
630
|
-
return
|
|
605
|
+
return r.pause(), r;
|
|
631
606
|
}
|
|
632
607
|
});
|
|
633
608
|
}
|
|
634
609
|
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 /
|
|
610
|
+
this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden"), this.splittedWords.forEach((e) => {
|
|
611
|
+
const t = e.elements[0];
|
|
612
|
+
if (t) {
|
|
613
|
+
e.width = t.clientWidth, e.height = t.clientHeight;
|
|
614
|
+
const [i, n, a] = W(
|
|
615
|
+
16 / e.width,
|
|
641
616
|
"rgba(0,0,0,0.75)",
|
|
642
617
|
"rgba(0,0,0,0.25)"
|
|
643
|
-
),
|
|
644
|
-
this.lyricPlayer.supportMaskImage ? (
|
|
645
|
-
const
|
|
646
|
-
|
|
618
|
+
), s = `${a * 100}% 100%`;
|
|
619
|
+
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);
|
|
620
|
+
const r = e.width + 16, l = `clamp(${-r}px,calc(${-r}px + (var(--amll-player-time) - ${e.startTime})*${r / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
|
|
621
|
+
t.style.maskPosition = l, t.style.webkitMaskPosition = l;
|
|
647
622
|
}
|
|
648
623
|
}), this._hide && (this.element.style.display = "none", this.element.style.visibility = "");
|
|
649
624
|
}
|
|
650
625
|
getElement() {
|
|
651
626
|
return this.element;
|
|
652
627
|
}
|
|
653
|
-
setTransform(
|
|
654
|
-
this.left =
|
|
655
|
-
const
|
|
656
|
-
|
|
628
|
+
setTransform(e = this.left, t = this.top, i = this.scale, n = 1, a = 0, s = !1, r = 0) {
|
|
629
|
+
this.left = e, this.top = t, this.scale = i, this.delay = r * 1e3 | 0;
|
|
630
|
+
const l = this.element.children[0];
|
|
631
|
+
l.style.opacity = `${n}`, s || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, a), s && this.element.classList.add(
|
|
657
632
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
658
|
-
), this.lineTransforms.posX.setPosition(
|
|
633
|
+
), 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
634
|
this.element.classList.remove(
|
|
660
635
|
this.lyricPlayer.style.classes.tmpDisableTransition
|
|
661
636
|
);
|
|
662
|
-
})) : (this.lineTransforms.posX.setTargetPosition(
|
|
637
|
+
})) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(i), this.blur !== Math.min(32, a) && (this.blur = Math.min(32, a), this.element.style.filter = `blur(${Math.min(32, a)}px)`));
|
|
663
638
|
}
|
|
664
|
-
update(
|
|
665
|
-
this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(
|
|
639
|
+
update(e = 0) {
|
|
640
|
+
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
641
|
}
|
|
667
642
|
get isInSight() {
|
|
668
|
-
const
|
|
669
|
-
return !(
|
|
643
|
+
const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], n = t + this.lineSize[1], a = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], l = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
|
|
644
|
+
return !(e > r || t > l || i < a || n < s);
|
|
670
645
|
}
|
|
671
646
|
dispose() {
|
|
672
647
|
this.element.remove();
|
|
673
648
|
}
|
|
674
649
|
}
|
|
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
|
-
}
|
|
650
|
+
const G = z(A());
|
|
651
|
+
class ee extends EventTarget {
|
|
652
|
+
element = document.createElement("div");
|
|
653
|
+
currentTime = 0;
|
|
654
|
+
lyricLines = [];
|
|
655
|
+
processedLines = [];
|
|
656
|
+
lyricLinesEl = [];
|
|
657
|
+
lyricLinesSize = /* @__PURE__ */ new Map();
|
|
658
|
+
hotLines = /* @__PURE__ */ new Set();
|
|
659
|
+
bufferedLines = /* @__PURE__ */ new Set();
|
|
660
|
+
scrollToIndex = 0;
|
|
661
|
+
resizeObserver = new ResizeObserver((e) => {
|
|
662
|
+
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, this.rebuildStyle(), this.calcLayout(!0), this.lyricLinesEl.forEach((i) => i.updateMaskImage());
|
|
664
|
+
});
|
|
665
|
+
posXSpringParams = {
|
|
666
|
+
mass: 1,
|
|
667
|
+
damping: 10,
|
|
668
|
+
stiffness: 100
|
|
669
|
+
};
|
|
670
|
+
posYSpringParams = {
|
|
671
|
+
mass: 1,
|
|
672
|
+
damping: 15,
|
|
673
|
+
stiffness: 100
|
|
674
|
+
};
|
|
675
|
+
scaleSpringParams = {
|
|
676
|
+
mass: 1,
|
|
677
|
+
damping: 20,
|
|
678
|
+
stiffness: 100
|
|
679
|
+
};
|
|
680
|
+
enableBlur = !0;
|
|
681
|
+
interludeDots;
|
|
682
|
+
interludeDotsSize = [0, 0];
|
|
683
|
+
supportPlusLighter = CSS.supports("mix-blend-mode", "plus-lighter");
|
|
684
|
+
supportMaskImage = CSS.supports("mask-image", "none");
|
|
685
|
+
disableSpring = !1;
|
|
686
|
+
alignAnchor = 0.5;
|
|
687
|
+
size = [0, 0];
|
|
688
|
+
pos = [0, 0];
|
|
827
689
|
/**
|
|
828
690
|
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
829
691
|
*
|
|
@@ -841,6 +703,118 @@ class he extends EventTarget {
|
|
|
841
703
|
getEnableSpring() {
|
|
842
704
|
return !this.disableSpring;
|
|
843
705
|
}
|
|
706
|
+
style = G.createStyleSheet({
|
|
707
|
+
lyricPlayer: {
|
|
708
|
+
userSelect: "none",
|
|
709
|
+
padding: "1rem",
|
|
710
|
+
boxSizing: "border-box",
|
|
711
|
+
fontSize: "max(5vh, 12px)",
|
|
712
|
+
fontWeight: "bold",
|
|
713
|
+
width: "100%",
|
|
714
|
+
height: "100%",
|
|
715
|
+
overflow: "hidden",
|
|
716
|
+
maxWidth: "100%",
|
|
717
|
+
maxHeight: "100%",
|
|
718
|
+
zIndex: 1,
|
|
719
|
+
color: "var(--amll-lyric-line-color)",
|
|
720
|
+
mixBlendMode: "plus-lighter",
|
|
721
|
+
contain: "strict"
|
|
722
|
+
},
|
|
723
|
+
lyricLine: {
|
|
724
|
+
position: "absolute",
|
|
725
|
+
transformOrigin: "left",
|
|
726
|
+
maxWidth: "65%",
|
|
727
|
+
padding: "max(2vh, 1rem) 1rem",
|
|
728
|
+
contain: "content",
|
|
729
|
+
transition: "filter 0.25s",
|
|
730
|
+
margin: "max(2vh, 1rem) -1rem"
|
|
731
|
+
},
|
|
732
|
+
"@media (max-width: 1024px)": {
|
|
733
|
+
lyricLine: {
|
|
734
|
+
maxWidth: "75%",
|
|
735
|
+
padding: "max(1vh, 1rem) 1rem",
|
|
736
|
+
margin: "0 -1rem"
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
lyricDuetLine: {
|
|
740
|
+
textAlign: "right",
|
|
741
|
+
transformOrigin: "right"
|
|
742
|
+
},
|
|
743
|
+
lyricBgLine: {
|
|
744
|
+
opacity: 0,
|
|
745
|
+
fontSize: "max(50%, 10px)",
|
|
746
|
+
transition: "opacity 0.25s",
|
|
747
|
+
"&.active": {
|
|
748
|
+
transition: "opacity 0.25s 0.25s",
|
|
749
|
+
opacity: 1
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
lyricMainLine: {
|
|
753
|
+
transition: "opacity 0.3s 0.25s",
|
|
754
|
+
margin: "-1rem",
|
|
755
|
+
padding: "1rem",
|
|
756
|
+
"& span": {
|
|
757
|
+
display: "inline-block",
|
|
758
|
+
margin: "-1rem",
|
|
759
|
+
padding: "1rem"
|
|
760
|
+
},
|
|
761
|
+
"& > span": {
|
|
762
|
+
whiteSpace: "pre-wrap",
|
|
763
|
+
wordBreak: "keep-all",
|
|
764
|
+
maxLines: "1",
|
|
765
|
+
"&.emphasize": {
|
|
766
|
+
margin: "-1rem",
|
|
767
|
+
padding: "1rem",
|
|
768
|
+
transformStyle: "preserve-3d",
|
|
769
|
+
perspective: "50vw"
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
lyricSubLine: {
|
|
774
|
+
fontSize: "max(50%, 10px)",
|
|
775
|
+
opacity: 0.5
|
|
776
|
+
},
|
|
777
|
+
disableSpring: {
|
|
778
|
+
"& > *": {
|
|
779
|
+
transition: "filter 0.25s, transform 0.5s"
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
interludeDots: {
|
|
783
|
+
height: "min(1rem,2.5vh)",
|
|
784
|
+
transformOrigin: "center",
|
|
785
|
+
width: "fit-content",
|
|
786
|
+
padding: "2.5% 0",
|
|
787
|
+
position: "absolute",
|
|
788
|
+
display: "flex",
|
|
789
|
+
gap: "0.5rem",
|
|
790
|
+
"& > *": {
|
|
791
|
+
width: "100%",
|
|
792
|
+
display: "inline-block",
|
|
793
|
+
borderRadius: "50%",
|
|
794
|
+
aspectRatio: "1 / 1",
|
|
795
|
+
backgroundColor: "var(--amll-lyric-line-color)",
|
|
796
|
+
marginRight: "4px"
|
|
797
|
+
},
|
|
798
|
+
"&.duet": {
|
|
799
|
+
right: "1rem",
|
|
800
|
+
transformOrigin: "center"
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
"@supports (mix-blend-mode: plus-lighter)": {
|
|
804
|
+
lyricSubLine: {
|
|
805
|
+
opacity: 0.3
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
tmpDisableTransition: {
|
|
809
|
+
transition: "none !important"
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
onPageShow = () => {
|
|
813
|
+
this.calcLayout(!0);
|
|
814
|
+
};
|
|
815
|
+
constructor() {
|
|
816
|
+
super(), this.interludeDots = new $(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);
|
|
817
|
+
}
|
|
844
818
|
/**
|
|
845
819
|
* 获取当前播放时间里是否处于间奏区间
|
|
846
820
|
* 如果是则会返回单位为毫秒的始末时间
|
|
@@ -850,17 +824,17 @@ class he extends EventTarget {
|
|
|
850
824
|
* @returns [开始时间,结束时间] 或 undefined 如果不处于间奏区间
|
|
851
825
|
*/
|
|
852
826
|
getCurrentInterlude() {
|
|
853
|
-
var s, a, l;
|
|
854
827
|
if (this.bufferedLines.size > 0)
|
|
855
828
|
return;
|
|
856
|
-
const e = this.currentTime + 20,
|
|
857
|
-
if (
|
|
858
|
-
if (
|
|
859
|
-
return [0, this.processedLines[0].startTime];
|
|
860
|
-
} else if (
|
|
829
|
+
const e = this.currentTime + 20, t = this.scrollToIndex;
|
|
830
|
+
if (t === 0) {
|
|
831
|
+
if (this.processedLines[0]?.startTime && this.processedLines[0].startTime > e)
|
|
832
|
+
return [0, this.processedLines[0].startTime, -2];
|
|
833
|
+
} else if (this.processedLines[t]?.endTime && this.processedLines[t + 1]?.startTime && this.processedLines[t + 1].startTime > e && this.processedLines[t].endTime < e)
|
|
861
834
|
return [
|
|
862
|
-
this.processedLines[
|
|
863
|
-
this.processedLines[
|
|
835
|
+
this.processedLines[t].endTime,
|
|
836
|
+
this.processedLines[t + 1].startTime,
|
|
837
|
+
t
|
|
864
838
|
];
|
|
865
839
|
}
|
|
866
840
|
/**
|
|
@@ -885,41 +859,43 @@ class he extends EventTarget {
|
|
|
885
859
|
*/
|
|
886
860
|
setLyricLines(e) {
|
|
887
861
|
this.lyricLines = e;
|
|
888
|
-
const
|
|
889
|
-
this.processedLines = e.
|
|
890
|
-
|
|
862
|
+
const t = 750;
|
|
863
|
+
this.processedLines = e.filter(
|
|
864
|
+
(i) => i.words.reduce((n, a) => n + a.word.trim().length, 0) > 0
|
|
865
|
+
).map((i, n, a) => {
|
|
866
|
+
if (i.isBG)
|
|
891
867
|
return {
|
|
892
|
-
...
|
|
868
|
+
...i
|
|
893
869
|
};
|
|
894
870
|
{
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
if (r.endTime <
|
|
871
|
+
const s = a[n - 1], r = a[n - 2];
|
|
872
|
+
if (s?.isBG && r) {
|
|
873
|
+
if (r.endTime < i.startTime)
|
|
898
874
|
return {
|
|
899
|
-
...
|
|
900
|
-
startTime: Math.max(r.endTime,
|
|
875
|
+
...i,
|
|
876
|
+
startTime: Math.max(r.endTime, i.startTime - t) || i.startTime
|
|
901
877
|
};
|
|
902
|
-
} else if (
|
|
878
|
+
} else if (s?.endTime && s.endTime < i.startTime)
|
|
903
879
|
return {
|
|
904
|
-
...
|
|
905
|
-
startTime: Math.max(
|
|
880
|
+
...i,
|
|
881
|
+
startTime: Math.max(s?.endTime, i.startTime - t) || i.startTime
|
|
906
882
|
};
|
|
907
883
|
return {
|
|
908
|
-
...
|
|
884
|
+
...i
|
|
909
885
|
};
|
|
910
886
|
}
|
|
911
|
-
}), this.processedLines.forEach((
|
|
912
|
-
const
|
|
913
|
-
r &&
|
|
914
|
-
}), this.processedLines.forEach((
|
|
915
|
-
if (
|
|
887
|
+
}), this.processedLines.forEach((i, n, a) => {
|
|
888
|
+
const s = a[n + 1], r = i.words[i.words.length - 1];
|
|
889
|
+
r && P(r) && (s ? s.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, s.startTime)) : i.endTime = i.endTime + 1500);
|
|
890
|
+
}), this.processedLines.forEach((i, n, a) => {
|
|
891
|
+
if (i.isBG)
|
|
916
892
|
return;
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
}), this.lyricLinesEl.forEach((
|
|
920
|
-
(
|
|
921
|
-
), this.lyricLinesEl.forEach((
|
|
922
|
-
this.element.appendChild(
|
|
893
|
+
const s = a[n + 1];
|
|
894
|
+
s?.isBG && (s.startTime = Math.min(s.startTime, i.startTime));
|
|
895
|
+
}), this.lyricLinesEl.forEach((i) => i.dispose()), this.lyricLinesEl = this.processedLines.map(
|
|
896
|
+
(i) => new _(this, i)
|
|
897
|
+
), this.lyricLinesEl.forEach((i) => {
|
|
898
|
+
this.element.appendChild(i.getElement()), i.updateMaskImage();
|
|
923
899
|
}), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0);
|
|
924
900
|
}
|
|
925
901
|
/**
|
|
@@ -937,55 +913,50 @@ class he extends EventTarget {
|
|
|
937
913
|
* @param reflow 是否进行重新布局(重新计算每行歌词大小)
|
|
938
914
|
*/
|
|
939
915
|
calcLayout(e = !1) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
this.lyricLinesSize.set(m, p), m.lineSize = p;
|
|
916
|
+
e && (this.lyricLinesEl.forEach((o) => {
|
|
917
|
+
const c = o.measureSize();
|
|
918
|
+
this.lyricLinesSize.set(o, c), o.lineSize = c;
|
|
944
919
|
}), 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
|
-
},
|
|
920
|
+
const t = 0.95;
|
|
921
|
+
let n = -this.lyricLinesEl.slice(0, this.scrollToIndex).reduce(
|
|
922
|
+
(o, c) => o + (c.getLine().isBG ? 0 : this.lyricLinesSize.get(c)?.[1] ?? 0),
|
|
951
923
|
0
|
|
952
924
|
);
|
|
953
925
|
if (this.alignAnchor === "bottom") {
|
|
954
|
-
|
|
955
|
-
const
|
|
956
|
-
if (
|
|
957
|
-
const
|
|
958
|
-
|
|
926
|
+
n += this.element.clientHeight / 2;
|
|
927
|
+
const o = this.lyricLinesEl[this.scrollToIndex];
|
|
928
|
+
if (o) {
|
|
929
|
+
const c = this.lyricLinesSize.get(o)?.[1] ?? 0;
|
|
930
|
+
n -= c / 2;
|
|
959
931
|
}
|
|
960
932
|
} else if (typeof this.alignAnchor == "number") {
|
|
961
|
-
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
|
|
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;
|
|
966
938
|
}
|
|
967
939
|
}
|
|
968
|
-
const
|
|
969
|
-
let
|
|
970
|
-
if (
|
|
971
|
-
const
|
|
972
|
-
|
|
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);
|
|
973
945
|
}
|
|
974
946
|
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,
|
|
947
|
+
let l = 0, h = !1;
|
|
948
|
+
this.lyricLinesEl.forEach((o, c) => {
|
|
949
|
+
const m = this.bufferedLines.has(c), p = m || c >= this.scrollToIndex && c < r, u = o.getLine();
|
|
950
|
+
let f = 0;
|
|
951
|
+
u.isDuet && (f = this.size[0] - (this.lyricLinesSize.get(o)?.[0] ?? 0)), !h && s >= 5e3 && (c === this.scrollToIndex && a?.[2] === -2 || c === this.scrollToIndex + 1) && (h = !0, this.interludeDots.setTransform(0, n), a && this.interludeDots.setInterlude([a[0], a[1]]), n += this.interludeDotsSize[1]), o.setTransform(
|
|
952
|
+
f,
|
|
953
|
+
n,
|
|
954
|
+
p ? 1 : t,
|
|
955
|
+
m ? 1 : 1 / 3,
|
|
956
|
+
this.enableBlur ? 3 * (p ? 0 : 1 + (c < this.scrollToIndex ? Math.abs(this.scrollToIndex - c) : Math.abs(c - Math.max(this.scrollToIndex, r)))) : 0,
|
|
986
957
|
e,
|
|
987
|
-
|
|
988
|
-
),
|
|
958
|
+
l
|
|
959
|
+
), u.isBG && p ? n += this.lyricLinesSize.get(o)?.[1] ?? 0 : u.isBG || (n += this.lyricLinesSize.get(o)?.[1] ?? 0), n >= 0 && (l += 0.05);
|
|
989
960
|
});
|
|
990
961
|
}
|
|
991
962
|
/**
|
|
@@ -1027,36 +998,35 @@ class he extends EventTarget {
|
|
|
1027
998
|
* 调用完成后,可以每帧调用 `update` 函数来执行歌词动画效果
|
|
1028
999
|
* @param time 当前播放进度,单位为毫秒
|
|
1029
1000
|
*/
|
|
1030
|
-
setCurrentTime(e,
|
|
1001
|
+
setCurrentTime(e, t = !1) {
|
|
1031
1002
|
this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`);
|
|
1032
|
-
const
|
|
1033
|
-
this.hotLines.forEach((
|
|
1034
|
-
const r = this.processedLines[
|
|
1003
|
+
const i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
1004
|
+
this.hotLines.forEach((s) => {
|
|
1005
|
+
const r = this.processedLines[s];
|
|
1035
1006
|
if (!r.isBG)
|
|
1036
1007
|
if (r) {
|
|
1037
|
-
const
|
|
1038
|
-
if (
|
|
1039
|
-
const
|
|
1040
|
-
(
|
|
1008
|
+
const l = this.processedLines[s + 1];
|
|
1009
|
+
if (l?.isBG) {
|
|
1010
|
+
const h = Math.min(r.startTime, l?.startTime), o = Math.max(r.endTime, l?.endTime);
|
|
1011
|
+
(h > 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
1012
|
} else
|
|
1042
|
-
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(
|
|
1013
|
+
(r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), i.add(s), t && this.lyricLinesEl[s].disable());
|
|
1043
1014
|
} 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();
|
|
1015
|
+
this.hotLines.delete(s), i.add(s), t && this.lyricLinesEl[s].disable();
|
|
1016
|
+
}), this.processedLines.forEach((s, r, l) => {
|
|
1017
|
+
!s.isBG && s.startTime <= e && s.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), a.add(r), t && this.lyricLinesEl[r].enable(), l[r + 1]?.isBG && (this.hotLines.add(r + 1), a.add(r + 1), t && this.lyricLinesEl[r + 1].enable())));
|
|
1018
|
+
}), this.bufferedLines.forEach((s) => {
|
|
1019
|
+
this.hotLines.has(s) || (n.add(s), t && this.lyricLinesEl[s].disable());
|
|
1020
|
+
}), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
|
|
1021
|
+
(s) => s.startTime >= e
|
|
1022
|
+
), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (n.size > 0 || a.size > 0) && (n.size === 0 && a.size > 0 ? (a.forEach((s) => {
|
|
1023
|
+
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1024
|
+
}), this.scrollToIndex = Math.min(...this.bufferedLines)) : a.size === 0 && n.size > 0 ? N(n, this.bufferedLines) && this.bufferedLines.forEach((s) => {
|
|
1025
|
+
this.hotLines.has(s) || (this.bufferedLines.delete(s), this.lyricLinesEl[s].disable());
|
|
1026
|
+
}) : (a.forEach((s) => {
|
|
1027
|
+
this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
|
|
1028
|
+
}), n.forEach((s) => {
|
|
1029
|
+
this.bufferedLines.delete(s), this.lyricLinesEl[s].disable();
|
|
1060
1030
|
}), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines))), this.calcLayout());
|
|
1061
1031
|
}
|
|
1062
1032
|
/**
|
|
@@ -1066,8 +1036,8 @@ class he extends EventTarget {
|
|
|
1066
1036
|
* @param delta 距离上一次被调用到现在的时长,单位为毫秒(可为浮点数)
|
|
1067
1037
|
*/
|
|
1068
1038
|
update(e = 0) {
|
|
1069
|
-
const
|
|
1070
|
-
this.interludeDots.update(e), this.lyricLinesEl.forEach((
|
|
1039
|
+
const t = e / 1e3;
|
|
1040
|
+
this.interludeDots.update(e), this.lyricLinesEl.forEach((i) => i.update(t));
|
|
1071
1041
|
}
|
|
1072
1042
|
/**
|
|
1073
1043
|
* 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
|
|
@@ -1079,7 +1049,7 @@ class he extends EventTarget {
|
|
|
1079
1049
|
...this.posXSpringParams,
|
|
1080
1050
|
...e
|
|
1081
1051
|
}, this.lyricLinesEl.forEach(
|
|
1082
|
-
(
|
|
1052
|
+
(t) => t.lineTransforms.posX.updateParams(this.posXSpringParams)
|
|
1083
1053
|
);
|
|
1084
1054
|
}
|
|
1085
1055
|
/**
|
|
@@ -1092,7 +1062,7 @@ class he extends EventTarget {
|
|
|
1092
1062
|
...this.posYSpringParams,
|
|
1093
1063
|
...e
|
|
1094
1064
|
}, this.lyricLinesEl.forEach(
|
|
1095
|
-
(
|
|
1065
|
+
(t) => t.lineTransforms.posY.updateParams(this.posYSpringParams)
|
|
1096
1066
|
);
|
|
1097
1067
|
}
|
|
1098
1068
|
/**
|
|
@@ -1105,7 +1075,7 @@ class he extends EventTarget {
|
|
|
1105
1075
|
...this.scaleSpringParams,
|
|
1106
1076
|
...e
|
|
1107
1077
|
}, this.lyricLinesEl.forEach(
|
|
1108
|
-
(
|
|
1078
|
+
(t) => t.lineTransforms.scale.updateParams(this.scaleSpringParams)
|
|
1109
1079
|
);
|
|
1110
1080
|
}
|
|
1111
1081
|
dispose() {
|
|
@@ -1113,8 +1083,8 @@ class he extends EventTarget {
|
|
|
1113
1083
|
}
|
|
1114
1084
|
}
|
|
1115
1085
|
export {
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1086
|
+
Z as BackgroundRender,
|
|
1087
|
+
ee as LyricPlayer,
|
|
1088
|
+
Q as ttml
|
|
1119
1089
|
};
|
|
1120
1090
|
//# sourceMappingURL=amll-core.mjs.map
|