@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.
@@ -1,173 +1,166 @@
1
- var D = Object.defineProperty;
2
- var I = (c, t, e) => t in c ? D(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
- var h = (c, t, e) => (I(c, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { Container as B } from "@pixi/display";
5
- import { Application as k } from "@pixi/app";
6
- import { BlurFilter as g } from "@pixi/filter-blur";
7
- import { ColorMatrixFilter as P } from "@pixi/filter-color-matrix";
8
- import { Texture as N } from "@pixi/core";
9
- import { Sprite as S } from "@pixi/sprite";
10
- import { create as O } from "jss";
11
- import $ from "jss-preset-default";
12
- const q = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
13
- function b(c) {
14
- var e, n, s;
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 R(c) {
23
- const e = new DOMParser().parseFromString(
18
+ function I(c) {
19
+ const t = new DOMParser().parseFromString(
24
20
  c,
25
21
  "application/xml"
26
22
  );
27
- let n = "v1";
28
- for (const a of e.querySelectorAll("ttm\\:agent"))
29
- if (a.getAttribute("type") === "person") {
30
- const l = a.getAttribute("xml:id");
31
- l && (n = l);
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 s = [];
34
- for (const a of e.querySelectorAll("body p[begin][end]")) {
35
- const l = {
29
+ const n = [];
30
+ for (const h of t.querySelectorAll("body p[begin][end]")) {
31
+ const s = {
36
32
  words: [],
37
- startTime: b(a.getAttribute("begin") ?? "0:0"),
38
- endTime: b(a.getAttribute("end") ?? "0:0"),
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: a.getAttribute("ttm:agent") !== n
38
+ isDuet: h.getAttribute("ttm:agent") !== i
43
39
  };
44
- let i = null;
45
- for (const r of a.childNodes)
46
- if (r.nodeType === Node.TEXT_NODE) {
47
- const o = r.textContent ?? "";
48
- /^(\s+)$/.test(o) ? l.words.push({
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
- }) : l.words.push({
53
- word: o,
48
+ }) : s.words.push({
49
+ word: l,
54
50
  startTime: 0,
55
51
  endTime: 0
56
52
  });
57
- } else if (r.nodeType === Node.ELEMENT_NODE) {
58
- const o = r, d = o.getAttribute("ttm:role");
59
- if (o.nodeName === "span" && d)
60
- if (d === "x-bg") {
61
- const u = {
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: l.startTime,
64
- endTime: l.endTime,
59
+ startTime: s.startTime,
60
+ endTime: s.endTime,
65
61
  translatedLyric: "",
66
62
  romanLyric: "",
67
63
  isBG: !0,
68
- isDuet: l.isDuet
64
+ isDuet: s.isDuet
69
65
  };
70
- for (const p of o.childNodes)
66
+ for (const p of l.childNodes)
71
67
  if (p.nodeType === Node.TEXT_NODE) {
72
- const y = p.textContent ?? "";
73
- /^(\s+)$/.test(y) ? u.words.push({
68
+ const f = p.textContent ?? "";
69
+ /^(\s+)$/.test(f) ? d.words.push({
74
70
  word: " ",
75
71
  startTime: 0,
76
72
  endTime: 0
77
- }) : u.words.push({
78
- word: y,
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 y = p, T = y.getAttribute("ttm:role");
84
- if (y.nodeName === "span" && T)
85
- T === "x-translation" ? u.translatedLyric = y.innerHTML.trim() : T === "x-roman" && (u.romanLyric = y.innerHTML.trim());
86
- else if (y.hasAttribute("begin") && y.hasAttribute("end")) {
87
- const E = {
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: b(y.getAttribute("begin")),
90
- endTime: b(y.getAttribute("end"))
85
+ startTime: T(f.getAttribute("begin")),
86
+ endTime: T(f.getAttribute("end"))
91
87
  };
92
- u.words.push(E);
88
+ d.words.push(x);
93
89
  }
94
90
  }
95
- const f = u.words[0];
96
- u.startTime = f.startTime, f != null && f.word.startsWith("(") && (f.word = f.word.substring(1));
97
- const m = u.words[u.words.length - 1];
98
- u.endTime = m.endTime, m != null && m.word.endsWith(")") && (m.word = m.word.substring(
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
- m.word.length - 1
101
- )), i = u;
96
+ u.word.length - 1
97
+ )), r = d;
102
98
  } else
103
- d === "x-translation" ? l.translatedLyric = o.innerHTML : d === "x-roman" && (l.romanLyric = o.innerHTML);
104
- else if (o.hasAttribute("begin") && o.hasAttribute("end")) {
105
- const u = {
106
- word: r.textContent ?? "",
107
- startTime: b(o.getAttribute("begin")),
108
- endTime: b(o.getAttribute("end"))
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
- l.words.push(u);
106
+ s.words.push(d);
111
107
  }
112
108
  }
113
- s.push(l), i && s.push(i);
109
+ n.push(s), r && n.push(r);
114
110
  }
115
- return console.log(s), s;
111
+ return console.log(n), n;
116
112
  }
117
- const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
113
+ const Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
118
114
  __proto__: null,
119
- parseTTML: R
115
+ parseTTML: I
120
116
  }, Symbol.toStringTag, { value: "Module" }));
121
- class F extends B {
122
- constructor() {
123
- super(...arguments);
124
- h(this, "time", 0);
125
- }
117
+ class B extends v {
118
+ time = 0;
126
119
  }
127
- class _ {
128
- constructor(t) {
129
- h(this, "observer");
130
- h(this, "app");
131
- h(this, "curContainer");
132
- h(this, "lastContainer", /* @__PURE__ */ new Set());
133
- h(this, "onTick", (t) => {
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(t), this.app = new k({
159
- view: t,
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(t) {
170
- this.flowSpeed = t;
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(t) {
179
- this.currerntRenderScale = t;
180
- const e = this.canvas.getBoundingClientRect();
181
- this.canvas.width = Math.max(1, e.width), this.canvas.height = Math.max(1, e.height), this.app.renderer.resize(
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 t = Math.min(this.canvas.width, this.canvas.height), e = new P();
188
- e.saturate(1.2, !1);
189
- const n = new P();
190
- n.brightness(0.6, !1);
191
- const s = new P();
192
- s.contrast(0.3, !0), this.app.stage.filters = [], this.app.stage.filters.push(new g(5, 1)), this.app.stage.filters.push(new g(10, 1)), this.app.stage.filters.push(new g(20, 2)), this.app.stage.filters.push(new g(40, 2)), t > 512 && this.app.stage.filters.push(new g(80, 2)), t > 768 && this.app.stage.filters.push(new g(160, 4)), t > 768 * 2 && this.app.stage.filters.push(new g(320, 4)), this.app.stage.filters.push(e, n, s), this.app.stage.filters.push(new g(5, 1));
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(t) {
201
- this.app.ticker.maxFPS = t;
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(t) {
220
- const e = await N.fromURL(t), n = new F(), s = new S(e), a = new S(e), l = new S(e), i = new S(e);
221
- s.anchor.set(0.5, 0.5), a.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), i.anchor.set(0.5, 0.5), s.rotation = Math.random() * Math.PI * 2, a.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, i.rotation = Math.random() * Math.PI * 2, n.addChild(s, a, l, i), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = n, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0;
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 le extends _ {
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 W = (c, t) => c.size === t.size && [...c].every((e) => t.has(e));
242
- function G(c) {
243
- const e = 2.5949095;
244
- return c < 0.5 ? Math.pow(2 * c, 2) * ((e + 1) * 2 * c - e) / 2 : (Math.pow(2 * c - 2, 2) * ((e + 1) * (c * 2 - 2) + e) + 2) / 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 L = (c, t, e) => Math.max(c, Math.min(t, e));
247
- class X {
248
- constructor(t) {
249
- h(this, "element", document.createElement("div"));
250
- h(this, "dot0", document.createElement("span"));
251
- h(this, "dot1", document.createElement("span"));
252
- h(this, "dot2", document.createElement("span"));
253
- h(this, "left", 0);
254
- h(this, "top", 0);
255
- h(this, "scale", 1);
256
- h(this, "lastStyle", "");
257
- h(this, "currentInterlude");
258
- h(this, "currentTime", 0);
259
- h(this, "targetBreatheDuration", 1500);
260
- this.lyricPlayer = t, this.element.className = this.lyricPlayer.style.classes.interludeDots, this.element.appendChild(this.dot0), this.element.appendChild(this.dot1), this.element.appendChild(this.dot2);
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(t = this.left, e = this.top) {
266
- this.left = t, this.top = e, this.update();
257
+ setTransform(e = this.left, t = this.top) {
258
+ this.left = e, this.top = t, this.update();
267
259
  }
268
- setInterlude(t) {
269
- this.currentInterlude = t, this.currentTime = (t == null ? void 0 : t[0]) ?? 0;
260
+ setInterlude(e) {
261
+ this.currentInterlude = e, this.currentTime = e?.[0] ?? 0;
270
262
  }
271
- update(t = 0) {
272
- this.currentTime += t;
273
- let e = "";
274
- if (e += `transform:translate(${this.left}px, ${this.top}px)`, this.currentInterlude) {
275
- const n = this.currentInterlude[1] - this.currentInterlude[0], s = this.currentTime - this.currentInterlude[0];
276
- if (s <= n) {
277
- const a = n / Math.ceil(n / this.targetBreatheDuration);
278
- let l = 1, i = 1;
279
- l *= Math.sin(1.5 * Math.PI - s / a * 2) / 10 + 1, s < 1e3 && (l *= 1 - Math.pow((1e3 - s) / 1e3, 2)), s < 500 ? i = 0 : s < 1e3 && (i *= (s - 500) / 500), n - s < 750 && (l *= 1 - G(
280
- (750 - (n - s)) / 750 / 2
281
- )), n - s < 375 && (i *= L(
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
- (n - s) / 375,
275
+ (i - n) / 375,
284
276
  1
285
- )), l = Math.max(0, l), e += ` scale(${l})`;
286
- const r = L(
277
+ )), s = Math.max(0, s), t += ` scale(${s})`;
278
+ const a = g(
287
279
  0.25,
288
- s * 3 / n * 0.75,
280
+ n * 3 / i * 0.75,
289
281
  1
290
- ), o = L(
282
+ ), l = g(
291
283
  0.25,
292
- (s - n / 3) * 3 / n * 0.75,
284
+ (n - i / 3) * 3 / i * 0.75,
293
285
  1
294
- ), d = L(
286
+ ), o = g(
295
287
  0.25,
296
- (s - n / 3 * 2) * 3 / n * 0.75,
288
+ (n - i / 3 * 2) * 3 / i * 0.75,
297
289
  1
298
290
  );
299
- this.dot0.style.opacity = `${L(
291
+ this.dot0.style.opacity = `${g(
300
292
  0,
301
- Math.max(0, i * r),
293
+ Math.max(0, r * a),
302
294
  1
303
- )}`, this.dot1.style.opacity = `${L(
295
+ )}`, this.dot1.style.opacity = `${g(
304
296
  0,
305
- Math.max(0, i * o),
297
+ Math.max(0, r * l),
306
298
  1
307
- )}`, this.dot2.style.opacity = `${L(
299
+ )}`, this.dot2.style.opacity = `${g(
308
300
  0,
309
- Math.max(0, i * d),
301
+ Math.max(0, r * o),
310
302
  1
311
303
  )}`;
312
304
  } else
313
- e += " scale(0)", this.dot0.style.opacity = "0", this.dot1.style.opacity = "0", this.dot2.style.opacity = "0";
305
+ t += " scale(0)", this.dot0.style.opacity = "0", this.dot1.style.opacity = "0", this.dot2.style.opacity = "0";
314
306
  } else
315
- e += " scale(0)", this.dot0.style.opacity = "0", this.dot1.style.opacity = "0", this.dot2.style.opacity = "0";
316
- e += ";", this.lastStyle !== e && (this.element.setAttribute("style", e), this.lastStyle = e);
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 x {
323
- constructor(t = 0) {
324
- h(this, "currentPosition", 0);
325
- h(this, "targetPosition", 0);
326
- h(this, "currentTime", 0);
327
- h(this, "params", {});
328
- h(this, "currentSolver");
329
- h(this, "getV");
330
- h(this, "queueParams");
331
- h(this, "queuePosition");
332
- this.targetPosition = t, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
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 t = this.getV(this.currentTime);
336
- this.currentTime = 0, this.currentSolver = Y(
327
+ const e = this.getV(this.currentTime);
328
+ this.currentTime = 0, this.currentSolver = $(
337
329
  this.currentPosition,
338
- t,
330
+ e,
339
331
  this.targetPosition,
340
332
  0,
341
333
  this.params
342
- ), this.getV = j(this.currentSolver);
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(t) {
348
- this.targetPosition = t, this.currentPosition = t, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
339
+ setPosition(e) {
340
+ this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
349
341
  }
350
- update(t = 0) {
351
- this.currentTime += t, this.currentPosition = this.currentSolver(this.currentTime), this.queueParams && (this.queueParams.time -= t, this.queueParams.time <= 0 && this.updateParams({
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 -= t, this.queuePosition.time <= 0 && this.setTargetPosition(this.queuePosition.position)), this.arrived() && this.setPosition(this.targetPosition);
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(t, e = 0) {
356
- e > 0 ? this.queueParams = {
357
- ...t,
358
- time: e
347
+ updateParams(e, t = 0) {
348
+ t > 0 ? this.queueParams = {
349
+ ...e,
350
+ time: t
359
351
  } : (this.params = {
360
352
  ...this.params,
361
- ...t
353
+ ...e
362
354
  }, this.resetSolver());
363
355
  }
364
- setTargetPosition(t, e = 0) {
365
- e > 0 ? this.queuePosition = {
366
- position: t,
367
- time: e
368
- } : (this.queuePosition = void 0, this.targetPosition = t, this.resetSolver());
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 Y(c, t, e, n = 0, s) {
375
- const a = (s == null ? void 0 : s.soft) ?? !1, l = (s == null ? void 0 : s.stiffness) ?? 100, i = (s == null ? void 0 : s.damping) ?? 10, r = (s == null ? void 0 : s.mass) ?? 1, o = e - c;
376
- if (a || 1 <= i / (2 * Math.sqrt(l * r))) {
377
- const d = -Math.sqrt(l / r), u = -d * o - t;
378
- return (f) => (f -= n, f < 0 ? c : e - (o + f * u) * Math.E ** (f * d));
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 d = Math.sqrt(
381
- 4 * r * l - i ** 2
382
- ), u = (i * o - 2 * r * t) / d, f = 0.5 * d / r, m = -(0.5 * i) / r;
383
- return (p) => (p -= n, p < 0 ? c : e - (Math.cos(p * f) * o + Math.sin(p * f) * u) * Math.E ** (p * m));
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 V(c) {
387
- return (e) => (c(e + 1e-3) - c(e - 1e-3)) / (2 * 1e-3);
378
+ function q(c) {
379
+ return (t) => (c(t + 1e-3) - c(t - 1e-3)) / (2 * 1e-3);
388
380
  }
389
- function j(c) {
390
- return V(c);
381
+ function R(c) {
382
+ return q(c);
391
383
  }
392
- const w = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
393
- function U(c, t = "rgba(0,0,0,1)", e = "rgba(0,0,0,0.5)") {
394
- const n = 2 + c, s = c / n, a = (1 - s) / 2;
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,${t} ${a * 100}%,${e} ${(a + s) * 100}%)`,
397
- s,
398
- n
388
+ `linear-gradient(to right,${e} ${h * 100}%,${t} ${(h + n) * 100}%)`,
389
+ n,
390
+ i
399
391
  ];
400
392
  }
401
- function v(c) {
393
+ function E(c) {
402
394
  return c.endTime - c.startTime >= 1e3 && c.word.length <= 7;
403
395
  }
404
- class H {
405
- constructor(t, e = {
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
- h(this, "element", document.createElement("div"));
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 n = this.element.children[0], s = this.element.children[1], a = this.element.children[2];
436
- n.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), s.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), a.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
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 t = this.element.children[0];
441
- this.splittedWords.forEach((e) => {
442
- e.elementAnimations.forEach((n) => {
443
- n.currentTime = 0, n.playbackRate = 1, n.play();
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
- }), t.classList.add("active");
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 t = [
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 = ""), t;
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 t = this.element.children[0];
458
- this.splittedWords.forEach((e) => {
459
- e.elementAnimations.forEach((n) => {
460
- n.id === "float-word" && (n.playbackRate = -1, n.play());
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
- }), t.classList.remove("active");
452
+ }), e.classList.remove("active");
463
453
  }
464
- setLine(t) {
465
- this.lyricLine = t, 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(
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 t = `transform:translate(${this.lineTransforms.posX.getCurrentPosition()}px,${this.lineTransforms.posY.getCurrentPosition()}px) scale(${this.lineTransforms.scale.getCurrentPosition()});`;
487
- !this.lyricPlayer.getEnableSpring() && this.isInSight && (t += `transition-delay:${this.delay}ms;`), t += `filter:blur(${Math.min(32, this.blur)}px);`, t !== this.lastStyle && (this.lastStyle = t, this.element.setAttribute("style", t));
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 t = this.element.children[0], e = this.element.children[1], n = this.element.children[2];
491
- this.splittedWords = [], this.lyricLine.words.forEach((r) => {
492
- if (w.test(r.word))
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
- ...r,
486
+ ...a,
495
487
  width: 0,
496
488
  height: 0,
497
489
  elements: [],
498
490
  elementAnimations: [],
499
- shouldEmphasize: v(r)
491
+ shouldEmphasize: E(a)
500
492
  });
501
493
  else {
502
- const o = /(\s*)(\S*)(\s*)/.exec(r.word);
503
- o && (o[1].length > 0 && this.splittedWords.push({
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: o[2],
514
- startTime: r.startTime,
515
- endTime: r.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: v(r)
521
- }), o[3].length > 0 && this.splittedWords.push({
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 s = [], a = [];
534
- function l(r) {
535
- for (; r.firstChild; )
536
- r.firstChild.nodeType === Node.ELEMENT_NODE ? s.push(t.firstChild) : r.firstChild.nodeType === Node.TEXT_NODE && a.push(t.firstChild), r.removeChild(r.firstChild), l(r.firstChild);
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
- l(t);
539
- let i = null;
540
- this.splittedWords.forEach((r) => {
541
- if (r.word.trim().length > 0)
542
- if (r.shouldEmphasize) {
543
- const o = s.pop() ?? document.createElement("span");
544
- o.className = "emphasize", r.elements = [o];
545
- for (const d of r.word) {
546
- const u = s.pop() ?? document.createElement("span");
547
- u.className = "", u.innerText = d, o.appendChild(u), r.elements.push(u);
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 (r.elementAnimations = this.initEmphasizeAnimation(r), console.log(r.word, w.test(r.word)), i && !w.test(r.word))
550
- if (i.childElementCount > 0)
551
- i.appendChild(o);
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 d = s.pop() ?? document.createElement("span");
554
- d.className = "", i.remove(), d.appendChild(i), d.appendChild(o), t.appendChild(d), i = d;
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
- i = w.test(r.word) ? null : o, t.appendChild(o);
558
+ r = b.test(a.word) ? null : l, e.appendChild(l);
558
559
  } else {
559
- const o = s.pop() ?? document.createElement("span");
560
- if (o.className = "", o.innerText = r.word, r.elements = [o], r.elementAnimations.push(this.initFloatAnimation(r, o)), i)
561
- if (i.childElementCount > 0)
562
- i.appendChild(o);
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 d = s.pop() ?? document.createElement("span");
565
- d.className = "", i.remove(), d.appendChild(i), d.appendChild(o), t.appendChild(d), i = d;
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
- i = o, t.appendChild(o);
569
+ r = l, e.appendChild(l);
569
570
  }
570
- else if (r.word.length > 0) {
571
- const o = a.pop() ?? document.createTextNode(" ");
572
- t.appendChild(o), i = null;
571
+ else if (a.word.length > 0) {
572
+ const l = h.pop() ?? document.createTextNode(" ");
573
+ e.appendChild(l), r = null;
573
574
  } else
574
- i = null;
575
- }), e.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
575
+ r = null;
576
+ }), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
576
577
  }
577
- initFloatAnimation(t, e) {
578
- const n = e.animate(
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, t.endTime - t.startTime),
589
- delay: t.startTime - this.lyricLine.startTime,
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 n.pause(), n;
596
+ return i.pause(), i;
596
597
  }
597
- initEmphasizeAnimation(t) {
598
- const e = t.startTime - this.lyricLine.startTime, n = t.endTime - t.startTime;
599
- return t.elements.map((s, a, l) => {
600
- if (a === 0)
601
- return this.initFloatAnimation(t, s);
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 i = s.animate(
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, t.endTime - t.startTime),
623
- delay: e + n / (l.length - 1) * (a - 1),
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 i.pause(), i;
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((t) => {
636
- const e = t.elements[0];
637
- if (e) {
638
- t.width = e.clientWidth, t.height = e.clientHeight;
639
- const [n, s, a] = U(
640
- 16 / t.width,
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
- ), l = `${a * 100}% 100%`;
644
- this.lyricPlayer.supportMaskImage ? (e.style.maskImage = n, e.style.maskOrigin = "left", e.style.maskSize = l) : (e.style.webkitMaskImage = n, e.style.webkitMaskOrigin = "left", e.style.webkitMaskSize = l);
645
- const i = t.width + 16, r = `clamp(${-i}px,calc(${-i}px + (var(--amll-player-time) - ${t.startTime})*${i / Math.abs(t.endTime - t.startTime)}px),0px) 0px, left top`;
646
- e.style.maskPosition = r, e.style.webkitMaskPosition = r;
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(t = this.left, e = this.top, n = this.scale, s = 1, a = 0, l = !1, i = 0) {
654
- this.left = t, this.top = e, this.scale = n, this.delay = i * 1e3 | 0;
655
- const r = this.element.children[0];
656
- r.style.opacity = `${s}`, l || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, a), l && this.element.classList.add(
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(t), this.lineTransforms.posY.setPosition(e), this.lineTransforms.scale.setPosition(n), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), l && requestAnimationFrame(() => {
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(t, i), this.lineTransforms.posY.setTargetPosition(e, i), this.lineTransforms.scale.setTargetPosition(n), this.blur !== Math.min(32, a) && (this.blur = Math.min(32, a), this.element.style.filter = `blur(${Math.min(32, a)}px)`));
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(t = 0) {
665
- this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(t), this.lineTransforms.posY.update(t), this.lineTransforms.scale.update(t), this.isInSight ? this.show() : this.hide());
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 t = this.lineTransforms.posX.getCurrentPosition(), e = this.lineTransforms.posY.getCurrentPosition(), n = t + this.lineSize[0], s = e + this.lineSize[1], a = this.lyricPlayer.pos[0], l = this.lyricPlayer.pos[1], i = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], r = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
669
- return !(t > i || e > r || n < a || s < l);
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 J = O($());
676
- class he extends EventTarget {
677
- constructor() {
678
- super();
679
- h(this, "element", document.createElement("div"));
680
- h(this, "currentTime", 0);
681
- h(this, "lyricLines", []);
682
- h(this, "processedLines", []);
683
- h(this, "lyricLinesEl", []);
684
- h(this, "lyricLinesSize", /* @__PURE__ */ new Map());
685
- h(this, "hotLines", /* @__PURE__ */ new Set());
686
- h(this, "bufferedLines", /* @__PURE__ */ new Set());
687
- h(this, "scrollToIndex", 0);
688
- h(this, "resizeObserver", new ResizeObserver((e) => {
689
- const n = e[0].contentRect;
690
- this.size[0] = n.width, this.size[1] = n.height, this.pos[0] = n.left, this.pos[1] = n.top, this.rebuildStyle(), this.calcLayout(!0), this.lyricLinesEl.forEach((s) => s.updateMaskImage());
691
- }));
692
- h(this, "posXSpringParams", {
693
- mass: 1,
694
- damping: 10,
695
- stiffness: 100
696
- });
697
- h(this, "posYSpringParams", {
698
- mass: 1,
699
- damping: 15,
700
- stiffness: 100
701
- });
702
- h(this, "scaleSpringParams", {
703
- mass: 1,
704
- damping: 20,
705
- stiffness: 100
706
- });
707
- h(this, "enableBlur", !0);
708
- h(this, "interludeDots");
709
- h(this, "interludeDotsSize", [0, 0]);
710
- h(this, "supportPlusLighter", CSS.supports("mix-blend-mode", "plus-lighter"));
711
- h(this, "supportMaskImage", CSS.supports("mask-image", "none"));
712
- h(this, "disableSpring", !1);
713
- h(this, "alignAnchor", 0.5);
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, n = this.scrollToIndex;
857
- if (n === 0) {
858
- if ((s = this.processedLines[0]) != null && s.startTime && this.processedLines[0].startTime > e)
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 ((a = this.processedLines[n]) != null && a.endTime && ((l = this.processedLines[n + 1]) != null && l.startTime) && this.processedLines[n + 1].startTime > e && this.processedLines[n].endTime < e)
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[n].endTime,
863
- this.processedLines[n + 1].startTime
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 n = 750;
889
- this.processedLines = e.map((s, a, l) => {
890
- if (s.isBG)
887
+ const t = 750;
888
+ this.processedLines = e.map((i, n, h) => {
889
+ if (i.isBG)
891
890
  return {
892
- ...s
891
+ ...i
893
892
  };
894
893
  {
895
- const i = l[a - 1], r = l[a - 2];
896
- if (i != null && i.isBG && r) {
897
- if (r.endTime < s.startTime)
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
- ...s,
900
- startTime: Math.max(r.endTime, s.startTime - n) || s.startTime
898
+ ...i,
899
+ startTime: Math.max(r.endTime, i.startTime - t) || i.startTime
901
900
  };
902
- } else if (i != null && i.endTime && i.endTime < s.startTime)
901
+ } else if (s?.endTime && s.endTime < i.startTime)
903
902
  return {
904
- ...s,
905
- startTime: Math.max(i == null ? void 0 : i.endTime, s.startTime - n) || s.startTime
903
+ ...i,
904
+ startTime: Math.max(s?.endTime, i.startTime - t) || i.startTime
906
905
  };
907
906
  return {
908
- ...s
907
+ ...i
909
908
  };
910
909
  }
911
- }), this.processedLines.forEach((s, a, l) => {
912
- const i = l[a + 1], r = s.words[s.words.length - 1];
913
- r && v(r) && (i ? i.startTime > s.endTime && (s.endTime = Math.min(s.endTime + 1500, i.startTime)) : s.endTime = s.endTime + 1500);
914
- }), this.processedLines.forEach((s, a, l) => {
915
- if (s.isBG)
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 i = l[a + 1];
918
- i != null && i.isBG && (i.startTime = Math.min(i.startTime, s.startTime));
919
- }), this.lyricLinesEl.forEach((s) => s.dispose()), this.lyricLinesEl = this.processedLines.map(
920
- (s) => new H(this, s)
921
- ), this.lyricLinesEl.forEach((s) => {
922
- this.element.appendChild(s.getElement()), s.updateMaskImage();
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
- var d, u, f;
941
- e && (this.lyricLinesEl.forEach((m) => {
942
- const p = m.measureSize();
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 n = 0.95;
946
- let a = -this.lyricLinesEl.slice(0, this.scrollToIndex).reduce(
947
- (m, p) => {
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
- a += this.element.clientHeight / 2;
955
- const m = this.lyricLinesEl[this.scrollToIndex];
956
- if (m) {
957
- const p = ((d = this.lyricLinesSize.get(m)) == null ? void 0 : d[1]) ?? 0;
958
- a -= p / 2;
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
- a += this.element.clientHeight * this.alignAnchor;
962
- const m = this.lyricLinesEl[this.scrollToIndex];
963
- if (m) {
964
- const p = ((u = this.lyricLinesSize.get(m)) == null ? void 0 : u[1]) ?? 0;
965
- a -= p / 2;
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 l = this.currentTime === 0 ? void 0 : this.getCurrentInterlude();
969
- let i = 0;
970
- if (l && (i = l[1] - l[0], i >= 5e3)) {
971
- const m = this.currentTime === 0 ? this.lyricLinesEl[0] : this.lyricLinesEl[this.scrollToIndex + 1];
972
- m && (a -= ((f = this.lyricLinesSize.get(m)) == null ? void 0 : f[1]) ?? 0);
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 o = 0;
976
- this.lyricLinesEl.forEach((m, p) => {
977
- var C, z, A;
978
- const y = this.bufferedLines.has(p), T = y || p >= this.scrollToIndex && p < r, E = m.getLine();
979
- let M = 0;
980
- E.isDuet && (M = this.size[0] - (((C = this.lyricLinesSize.get(m)) == null ? void 0 : C[0]) ?? 0)), p === this.scrollToIndex + 1 && i >= 5e3 && (this.interludeDots.setTransform(0, a), this.interludeDots.setInterlude(this.getCurrentInterlude()), a += this.interludeDotsSize[1]), m.setTransform(
981
- M,
982
- a,
983
- T ? 1 : n,
984
- y ? 1 : 1 / 3,
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
- o
988
- ), E.isBG && T ? a += ((z = this.lyricLinesSize.get(m)) == null ? void 0 : z[1]) ?? 0 : E.isBG || (a += ((A = this.lyricLinesSize.get(m)) == null ? void 0 : A[1]) ?? 0), a >= 0 && (o += 0.05);
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, n = !1) {
1024
+ setCurrentTime(e, t = !1) {
1031
1025
  this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`);
1032
- const s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
1033
- this.hotLines.forEach((i) => {
1034
- const r = this.processedLines[i];
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 o = this.processedLines[i + 1];
1038
- if (o != null && o.isBG) {
1039
- const d = Math.min(r.startTime, o == null ? void 0 : o.startTime), u = Math.max(r.endTime, o == null ? void 0 : o.endTime);
1040
- (d > e || u <= e) && (this.hotLines.delete(i), s.add(i), this.hotLines.delete(i + 1), s.add(i + 1), n && (this.lyricLinesEl[i].disable(), this.lyricLinesEl[i + 1].disable()));
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(i), s.add(i), n && this.lyricLinesEl[i].disable());
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(i), s.add(i), n && this.lyricLinesEl[i].disable();
1045
- }), this.processedLines.forEach((i, r, o) => {
1046
- var d;
1047
- !i.isBG && i.startTime <= e && i.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), l.add(r), n && this.lyricLinesEl[r].enable(), (d = o[r + 1]) != null && d.isBG && (this.hotLines.add(r + 1), l.add(r + 1), n && this.lyricLinesEl[r + 1].enable())));
1048
- }), this.bufferedLines.forEach((i) => {
1049
- this.hotLines.has(i) || (a.add(i), n && this.lyricLinesEl[i].disable());
1050
- }), n ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
1051
- (i) => i.startTime >= e
1052
- ), this.bufferedLines.clear(), this.hotLines.forEach((i) => this.bufferedLines.add(i)), this.calcLayout(!0)) : (a.size > 0 || l.size > 0) && (a.size === 0 && l.size > 0 ? (l.forEach((i) => {
1053
- this.bufferedLines.add(i), this.lyricLinesEl[i].enable();
1054
- }), this.scrollToIndex = Math.min(...this.bufferedLines)) : l.size === 0 && a.size > 0 ? W(a, this.bufferedLines) && this.bufferedLines.forEach((i) => {
1055
- this.hotLines.has(i) || (this.bufferedLines.delete(i), this.lyricLinesEl[i].disable());
1056
- }) : (l.forEach((i) => {
1057
- this.bufferedLines.add(i), this.lyricLinesEl[i].enable();
1058
- }), a.forEach((i) => {
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 n = e / 1e3;
1070
- this.interludeDots.update(e), this.lyricLinesEl.forEach((s) => s.update(n));
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
- (n) => n.lineTransforms.posX.updateParams(this.posXSpringParams)
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
- (n) => n.lineTransforms.posY.updateParams(this.posYSpringParams)
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
- (n) => n.lineTransforms.scale.updateParams(this.scaleSpringParams)
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
- le as BackgroundRender,
1117
- he as LyricPlayer,
1118
- ae as ttml
1109
+ Z as BackgroundRender,
1110
+ ee as LyricPlayer,
1111
+ Q as ttml
1119
1112
  };
1120
1113
  //# sourceMappingURL=amll-core.mjs.map