@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.
@@ -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 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 R(c) {
23
- const e = new DOMParser().parseFromString(
24
- c,
18
+ function I(d) {
19
+ const t = new DOMParser().parseFromString(
20
+ d,
25
21
  "application/xml"
26
22
  );
27
- let n = "v1";
28
- for (const a of e.querySelectorAll("ttm\\:agent"))
23
+ let i = "v1";
24
+ for (const a of t.querySelectorAll("ttm\\:agent"))
29
25
  if (a.getAttribute("type") === "person") {
30
- const l = a.getAttribute("xml:id");
31
- l && (n = l);
26
+ const s = a.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 a 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(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") !== n
38
+ isDuet: a.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 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
- }) : l.words.push({
53
- word: o,
48
+ }) : s.words.push({
49
+ word: h,
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 (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: 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)
71
- if (p.nodeType === Node.TEXT_NODE) {
72
- const y = p.textContent ?? "";
73
- /^(\s+)$/.test(y) ? u.words.push({
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
- }) : u.words.push({
78
- word: y,
73
+ }) : c.words.push({
74
+ word: f,
79
75
  startTime: 0,
80
76
  endTime: 0
81
77
  });
82
- } 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 = {
88
- word: p.textContent,
89
- startTime: b(y.getAttribute("begin")),
90
- endTime: b(y.getAttribute("end"))
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
- u.words.push(E);
88
+ c.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 = 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
- m.word.length - 1
101
- )), i = u;
96
+ p.word.length - 1
97
+ )), r = c;
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 = 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
- l.words.push(u);
106
+ s.words.push(c);
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, 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(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 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(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), 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 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 = (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 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 = (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(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 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
- (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 l = g(
287
279
  0.25,
288
- s * 3 / n * 0.75,
280
+ n * 3 / i * 0.75,
289
281
  1
290
- ), o = L(
282
+ ), h = 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 * l),
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 * h),
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 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 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 = q(
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 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 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 * 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 V(c) {
387
- return (e) => (c(e + 1e-3) - c(e - 1e-3)) / (2 * 1e-3);
378
+ function F(d) {
379
+ return (t) => (d(t + 1e-3) - d(t - 1e-3)) / (2 * 1e-3);
388
380
  }
389
- function j(c) {
390
- return V(c);
381
+ function R(d) {
382
+ return F(d);
391
383
  }
392
384
  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;
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,${t} ${a * 100}%,${e} ${(a + s) * 100}%)`,
397
- s,
398
- n
388
+ `linear-gradient(to right,${e} ${a * 100}%,${t} ${(a + n) * 100}%)`,
389
+ n,
390
+ i
399
391
  ];
400
392
  }
401
- function v(c) {
402
- return c.endTime - c.startTime >= 1e3 && c.word.length <= 7;
393
+ function P(d) {
394
+ return d.endTime - d.startTime >= 1e3 && d.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], 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 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,16 @@ 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))
493
- this.splittedWords.push({
494
- ...r,
495
- width: 0,
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: o[2],
514
- startTime: r.startTime,
515
- endTime: r.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: v(r)
521
- }), o[3].length > 0 && this.splittedWords.push({
522
- word: " ",
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 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);
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
- 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);
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 (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);
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 d = s.pop() ?? document.createElement("span");
554
- d.className = "", i.remove(), d.appendChild(i), d.appendChild(o), t.appendChild(d), i = d;
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
- i = w.test(r.word) ? null : o, t.appendChild(o);
532
+ r = w.test(l.word) ? null : h, e.appendChild(h);
558
533
  } 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);
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 d = s.pop() ?? document.createElement("span");
565
- d.className = "", i.remove(), d.appendChild(i), d.appendChild(o), t.appendChild(d), i = d;
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
- i = o, t.appendChild(o);
543
+ r = h, e.appendChild(h);
569
544
  }
570
- else if (r.word.length > 0) {
571
- const o = a.pop() ?? document.createTextNode(" ");
572
- t.appendChild(o), i = null;
545
+ else if (l.word.length > 0) {
546
+ const h = a.pop() ?? document.createTextNode(" ");
547
+ e.appendChild(h), r = null;
573
548
  } else
574
- i = null;
575
- }), e.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
549
+ r = null;
550
+ }), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
576
551
  }
577
- initFloatAnimation(t, e) {
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: Math.max(1e3, t.endTime - t.startTime),
589
- delay: t.startTime - this.lyricLine.startTime,
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 n.pause(), n;
570
+ return a.pause(), a;
596
571
  }
597
- initEmphasizeAnimation(t) {
598
- const e = t.startTime - this.lyricLine.startTime, n = t.endTime - t.startTime;
599
- return t.elements.map((s, a, l) => {
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(t, s);
576
+ return this.initFloatAnimation(e, n);
602
577
  {
603
- const i = s.animate(
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, t.endTime - t.startTime),
623
- delay: e + n / (l.length - 1) * (a - 1),
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 i.pause(), i;
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((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,
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
- ), 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;
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(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(
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(t), this.lineTransforms.posY.setPosition(e), this.lineTransforms.scale.setPosition(n), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), l && requestAnimationFrame(() => {
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(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)`));
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(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());
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 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);
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 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
- }
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, n = this.scrollToIndex;
857
- if (n === 0) {
858
- if ((s = this.processedLines[0]) != null && s.startTime && this.processedLines[0].startTime > e)
859
- 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)
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[n].endTime,
863
- this.processedLines[n + 1].startTime
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 n = 750;
889
- this.processedLines = e.map((s, a, l) => {
890
- if (s.isBG)
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
- ...s
868
+ ...i
893
869
  };
894
870
  {
895
- const i = l[a - 1], r = l[a - 2];
896
- if (i != null && i.isBG && r) {
897
- if (r.endTime < s.startTime)
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
- ...s,
900
- startTime: Math.max(r.endTime, s.startTime - n) || s.startTime
875
+ ...i,
876
+ startTime: Math.max(r.endTime, i.startTime - t) || i.startTime
901
877
  };
902
- } else if (i != null && i.endTime && i.endTime < s.startTime)
878
+ } else if (s?.endTime && s.endTime < i.startTime)
903
879
  return {
904
- ...s,
905
- startTime: Math.max(i == null ? void 0 : i.endTime, s.startTime - n) || s.startTime
880
+ ...i,
881
+ startTime: Math.max(s?.endTime, i.startTime - t) || i.startTime
906
882
  };
907
883
  return {
908
- ...s
884
+ ...i
909
885
  };
910
886
  }
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)
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 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();
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
- var d, u, f;
941
- e && (this.lyricLinesEl.forEach((m) => {
942
- const p = m.measureSize();
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 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
- },
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
- 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;
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
- 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;
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 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);
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 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,
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
- 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);
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, n = !1) {
1001
+ setCurrentTime(e, t = !1) {
1031
1002
  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];
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 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()));
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(i), s.add(i), n && this.lyricLinesEl[i].disable());
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(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();
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 n = e / 1e3;
1070
- this.interludeDots.update(e), this.lyricLinesEl.forEach((s) => s.update(n));
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
- (n) => n.lineTransforms.posX.updateParams(this.posXSpringParams)
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
- (n) => n.lineTransforms.posY.updateParams(this.posYSpringParams)
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
- (n) => n.lineTransforms.scale.updateParams(this.scaleSpringParams)
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
- le as BackgroundRender,
1117
- he as LyricPlayer,
1118
- ae as ttml
1086
+ Z as BackgroundRender,
1087
+ ee as LyricPlayer,
1088
+ Q as ttml
1119
1089
  };
1120
1090
  //# sourceMappingURL=amll-core.mjs.map