@applemusic-like-lyrics/core 0.0.11 → 0.0.13

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,133 +1,134 @@
1
- import { Container as C } from "@pixi/display";
2
- import { Application as M } from "@pixi/app";
1
+ import { Container as z } from "@pixi/display";
2
+ import { Application as A } from "@pixi/app";
3
3
  import { BlurFilter as y } from "@pixi/filter-blur";
4
- import { ColorMatrixFilter as E } from "@pixi/filter-color-matrix";
5
- import { Texture as z } from "@pixi/core";
6
- import { Sprite as w } from "@pixi/sprite";
4
+ import { ColorMatrixFilter as v } from "@pixi/filter-color-matrix";
5
+ import { Texture as I } from "@pixi/core";
6
+ import { Sprite as S } from "@pixi/sprite";
7
+ import { BulgePinchFilter as E } from "@pixi/filter-bulge-pinch";
7
8
  import { create as D } from "jss";
8
- import A from "jss-preset-default";
9
- const I = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
9
+ import k from "jss-preset-default";
10
+ const B = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
10
11
  function T(h) {
11
- const e = I.exec(h);
12
+ const e = B.exec(h);
12
13
  if (e) {
13
- const t = Number(e.groups?.hour || "0"), n = Number(e.groups?.min || "0"), i = Number(e.groups?.sec.replace(/:/, ".") || "0");
14
- return Math.floor((t * 3600 + n * 60 + i) * 1e3);
14
+ const t = Number(e.groups?.hour || "0"), i = Number(e.groups?.min || "0"), s = Number(e.groups?.sec.replace(/:/, ".") || "0");
15
+ return Math.floor((t * 3600 + i * 60 + s) * 1e3);
15
16
  } else
16
17
  throw new TypeError("时间戳字符串解析失败");
17
18
  }
18
- function B(h) {
19
+ function $(h) {
19
20
  const t = new DOMParser().parseFromString(
20
21
  h,
21
22
  "application/xml"
22
23
  );
23
- let n = "v1";
24
- for (const l of t.querySelectorAll("ttm\\:agent"))
25
- if (l.getAttribute("type") === "person") {
26
- const s = l.getAttribute("xml:id");
27
- s && (n = s);
24
+ let i = "v1";
25
+ for (const r of t.querySelectorAll("ttm\\:agent"))
26
+ if (r.getAttribute("type") === "person") {
27
+ const n = r.getAttribute("xml:id");
28
+ n && (i = n);
28
29
  }
29
- const i = [];
30
- for (const l of t.querySelectorAll("body p[begin][end]")) {
31
- const s = {
30
+ const s = [];
31
+ for (const r of t.querySelectorAll("body p[begin][end]")) {
32
+ const n = {
32
33
  words: [],
33
- startTime: T(l.getAttribute("begin") ?? "0:0"),
34
- endTime: T(l.getAttribute("end") ?? "0:0"),
34
+ startTime: T(r.getAttribute("begin") ?? "0:0"),
35
+ endTime: T(r.getAttribute("end") ?? "0:0"),
35
36
  translatedLyric: "",
36
37
  romanLyric: "",
37
38
  isBG: !1,
38
- isDuet: l.getAttribute("ttm:agent") !== n
39
+ isDuet: r.getAttribute("ttm:agent") !== i
39
40
  };
40
- let r = null;
41
- for (const a of l.childNodes)
42
- if (a.nodeType === Node.TEXT_NODE) {
43
- const o = a.textContent ?? "";
44
- /^(\s+)$/.test(o) ? s.words.push({
41
+ let a = null;
42
+ for (const l of r.childNodes)
43
+ if (l.nodeType === Node.TEXT_NODE) {
44
+ const o = l.textContent ?? "";
45
+ /^(\s+)$/.test(o) ? n.words.push({
45
46
  word: " ",
46
47
  startTime: 0,
47
48
  endTime: 0
48
- }) : s.words.push({
49
+ }) : n.words.push({
49
50
  word: o,
50
51
  startTime: 0,
51
52
  endTime: 0
52
53
  });
53
- } else if (a.nodeType === Node.ELEMENT_NODE) {
54
- const o = a, c = o.getAttribute("ttm:role");
54
+ } else if (l.nodeType === Node.ELEMENT_NODE) {
55
+ const o = l, c = o.getAttribute("ttm:role");
55
56
  if (o.nodeName === "span" && c)
56
57
  if (c === "x-bg") {
57
- const d = {
58
+ const m = {
58
59
  words: [],
59
- startTime: s.startTime,
60
- endTime: s.endTime,
60
+ startTime: n.startTime,
61
+ endTime: n.endTime,
61
62
  translatedLyric: "",
62
63
  romanLyric: "",
63
64
  isBG: !0,
64
- isDuet: s.isDuet
65
+ isDuet: n.isDuet
65
66
  };
66
- for (const m of o.childNodes)
67
- if (m.nodeType === Node.TEXT_NODE) {
68
- const p = m.textContent ?? "";
69
- /^(\s+)$/.test(p) ? d.words.push({
67
+ for (const p of o.childNodes)
68
+ if (p.nodeType === Node.TEXT_NODE) {
69
+ const d = p.textContent ?? "";
70
+ /^(\s+)$/.test(d) ? m.words.push({
70
71
  word: " ",
71
72
  startTime: 0,
72
73
  endTime: 0
73
- }) : d.words.push({
74
- word: p,
74
+ }) : m.words.push({
75
+ word: d,
75
76
  startTime: 0,
76
77
  endTime: 0
77
78
  });
78
- } else if (m.nodeType === Node.ELEMENT_NODE) {
79
- const p = m, L = p.getAttribute("ttm:role");
80
- if (p.nodeName === "span" && L)
81
- L === "x-translation" ? d.translatedLyric = p.innerHTML.trim() : L === "x-roman" && (d.romanLyric = p.innerHTML.trim());
82
- else if (p.hasAttribute("begin") && p.hasAttribute("end")) {
79
+ } else if (p.nodeType === Node.ELEMENT_NODE) {
80
+ const d = p, g = d.getAttribute("ttm:role");
81
+ if (d.nodeName === "span" && g)
82
+ g === "x-translation" ? m.translatedLyric = d.innerHTML.trim() : g === "x-roman" && (m.romanLyric = d.innerHTML.trim());
83
+ else if (d.hasAttribute("begin") && d.hasAttribute("end")) {
83
84
  const b = {
84
- word: m.textContent,
85
- startTime: T(p.getAttribute("begin")),
86
- endTime: T(p.getAttribute("end"))
85
+ word: p.textContent,
86
+ startTime: T(d.getAttribute("begin")),
87
+ endTime: T(d.getAttribute("end"))
87
88
  };
88
- d.words.push(b);
89
+ m.words.push(b);
89
90
  }
90
91
  }
91
- const u = d.words[0];
92
- d.startTime = u.startTime, u?.word.startsWith("(") && (u.word = u.word.substring(1));
93
- const f = d.words[d.words.length - 1];
94
- d.endTime = f.endTime, f?.word.endsWith(")") && (f.word = f.word.substring(
92
+ const u = m.words[0];
93
+ m.startTime = u.startTime, u?.word.startsWith("(") && (u.word = u.word.substring(1));
94
+ const f = m.words[m.words.length - 1];
95
+ m.endTime = f.endTime, f?.word.endsWith(")") && (f.word = f.word.substring(
95
96
  0,
96
97
  f.word.length - 1
97
- )), r = d;
98
+ )), a = m;
98
99
  } else
99
- c === "x-translation" ? s.translatedLyric = o.innerHTML : c === "x-roman" && (s.romanLyric = o.innerHTML);
100
+ c === "x-translation" ? n.translatedLyric = o.innerHTML : c === "x-roman" && (n.romanLyric = o.innerHTML);
100
101
  else if (o.hasAttribute("begin") && o.hasAttribute("end")) {
101
- const d = {
102
- word: a.textContent ?? "",
102
+ const m = {
103
+ word: l.textContent ?? "",
103
104
  startTime: T(o.getAttribute("begin")),
104
105
  endTime: T(o.getAttribute("end"))
105
106
  };
106
- s.words.push(d);
107
+ n.words.push(m);
107
108
  }
108
109
  }
109
- i.push(s), r && i.push(r);
110
+ s.push(n), a && s.push(a);
110
111
  }
111
- return i;
112
+ return s;
112
113
  }
113
- const ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
+ const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
115
  __proto__: null,
115
- parseTTML: B
116
+ parseTTML: $
116
117
  }, Symbol.toStringTag, { value: "Module" }));
117
- class k extends C {
118
+ class O extends z {
118
119
  time = 0;
119
120
  }
120
- class N {
121
+ class W {
121
122
  constructor(e) {
122
123
  this.canvas = e;
123
124
  const t = e.getBoundingClientRect();
124
125
  this.canvas.width = t.width * this.currerntRenderScale, this.canvas.height = t.height * this.currerntRenderScale, this.observer = new ResizeObserver(() => {
125
- const n = e.getBoundingClientRect();
126
- this.canvas.width = Math.max(1, n.width), this.canvas.height = Math.max(1, n.height), this.app.renderer.resize(
126
+ const i = e.getBoundingClientRect();
127
+ this.canvas.width = Math.max(1, i.width), this.canvas.height = Math.max(1, i.height), this.app.renderer.resize(
127
128
  this.canvas.width * this.currerntRenderScale,
128
129
  this.canvas.height * this.currerntRenderScale
129
130
  ), this.app.ticker.start(), this.rebuildFilters();
130
- }), this.observer.observe(e), this.app = new M({
131
+ }), this.observer.observe(e), this.app = new A({
131
132
  view: e,
132
133
  resizeTo: this.canvas,
133
134
  powerPreference: "low-power",
@@ -141,17 +142,17 @@ class N {
141
142
  lastContainer = /* @__PURE__ */ new Set();
142
143
  onTick = (e) => {
143
144
  for (const t of this.lastContainer)
144
- t.alpha = Math.max(0, t.alpha - e / 60), t.alpha <= 0 && (this.app.stage.removeChild(t), this.lastContainer.delete(t));
145
+ t.alpha = Math.max(0, t.alpha - e / 60), t.alpha <= 0 && (this.app.stage.removeChild(t), this.lastContainer.delete(t), t.destroy(!0));
145
146
  if (this.curContainer) {
146
147
  this.curContainer.alpha = Math.min(
147
148
  1,
148
149
  this.curContainer.alpha + e / 60
149
150
  );
150
- const [t, n, i, l] = this.curContainer.children, s = Math.max(this.app.screen.width, this.app.screen.height);
151
- t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), n.position.set(
151
+ const [t, i, s, r] = this.curContainer.children, n = Math.max(this.app.screen.width, this.app.screen.height);
152
+ t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), i.position.set(
152
153
  this.app.screen.width / 2.5,
153
154
  this.app.screen.height / 2.5
154
- ), i.position.set(this.app.screen.width / 2, this.app.screen.height / 2), l.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = s * Math.sqrt(2), t.height = t.width, n.width = s * 0.8, n.height = n.width, i.width = s * 0.5, i.height = i.width, l.width = s * 0.25, l.height = l.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, n.rotation -= e / 500 * this.flowSpeed, i.rotation += e / 1e3 * this.flowSpeed, l.rotation -= e / 750 * this.flowSpeed, i.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), i.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), l.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), l.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
155
+ ), s.position.set(this.app.screen.width / 2, this.app.screen.height / 2), r.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = n * Math.sqrt(2), t.height = t.width, i.width = n * 0.8, i.height = i.width, s.width = n * 0.5, s.height = s.width, r.width = n * 0.25, r.height = r.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, i.rotation -= e / 500 * this.flowSpeed, s.rotation += e / 1e3 * this.flowSpeed, r.rotation -= e / 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), r.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), r.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
155
156
  }
156
157
  };
157
158
  flowSpeed = 2;
@@ -178,12 +179,38 @@ class N {
178
179
  ), this.rebuildFilters();
179
180
  }
180
181
  rebuildFilters() {
181
- const e = Math.min(this.canvas.width, this.canvas.height), t = new E();
182
- t.saturate(1.2, !1);
183
- const n = new E();
184
- n.brightness(0.6, !1);
185
- const i = new E();
186
- i.contrast(0.3, !0), this.app.stage.filters = [], this.app.stage.filters.push(new y(5, 1)), this.app.stage.filters.push(new y(10, 1)), this.app.stage.filters.push(new y(20, 2)), this.app.stage.filters.push(new y(40, 2)), e > 512 && this.app.stage.filters.push(new y(80, 2)), e > 768 && this.app.stage.filters.push(new y(160, 4)), e > 768 * 2 && this.app.stage.filters.push(new y(320, 4)), this.app.stage.filters.push(t, n, i), this.app.stage.filters.push(new y(5, 1));
182
+ const e = Math.min(this.canvas.width, this.canvas.height), t = Math.max(this.canvas.width, this.canvas.height), i = new v();
183
+ i.saturate(1.2, !1);
184
+ const s = new v();
185
+ s.brightness(0.6, !1);
186
+ const r = new v();
187
+ r.contrast(0.3, !0), this.app.stage.filters?.forEach((n) => {
188
+ n.destroy();
189
+ }), 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)), 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(i, s, r), this.app.stage.filters.push(new y(5, 1)), Math.random() > 0.5 ? (this.app.stage.filters.push(
190
+ new E({
191
+ radius: (t + e) / 2,
192
+ strength: 1,
193
+ center: [0.25, 1]
194
+ })
195
+ ), this.app.stage.filters.push(
196
+ new E({
197
+ radius: (t + e) / 2,
198
+ strength: 1,
199
+ center: [0.75, 0]
200
+ })
201
+ )) : (this.app.stage.filters.push(
202
+ new E({
203
+ radius: (t + e) / 2,
204
+ strength: 1,
205
+ center: [0.75, 1]
206
+ })
207
+ ), this.app.stage.filters.push(
208
+ new E({
209
+ radius: (t + e) / 2,
210
+ strength: 1,
211
+ center: [0.25, 0]
212
+ })
213
+ ));
187
214
  }
188
215
  /**
189
216
  * 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能
@@ -218,14 +245,33 @@ class N {
218
245
  * @param albumUrl 图片的目标链接
219
246
  */
220
247
  async setAlbumImage(e) {
221
- const t = await z.fromURL(e), n = new k(), i = new w(t), l = new w(t), s = new w(t), r = new w(t);
222
- i.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), s.anchor.set(0.5, 0.5), r.anchor.set(0.5, 0.5), i.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, s.rotation = Math.random() * Math.PI * 2, r.rotation = Math.random() * Math.PI * 2, n.addChild(i, l, s, r), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = n, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
248
+ const t = new Image();
249
+ t.src = e, t.crossOrigin = "anonymous";
250
+ let i = 5, s;
251
+ for (; !s?.baseTexture?.resource?.valid && i > 0; )
252
+ try {
253
+ await t.decode(), s = I.from(t, {
254
+ resourceOptions: {
255
+ autoLoad: !1
256
+ }
257
+ }), await s.baseTexture.resource.load();
258
+ } catch (c) {
259
+ console.warn(
260
+ `failed on loading album image, retrying (${i})`,
261
+ e,
262
+ c
263
+ ), s = void 0, i--;
264
+ }
265
+ if (!s)
266
+ return;
267
+ const r = new O(), n = new S(s), a = new S(s), l = new S(s), o = new S(s);
268
+ n.anchor.set(0.5, 0.5), a.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), o.anchor.set(0.5, 0.5), n.rotation = Math.random() * Math.PI * 2, a.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, o.rotation = Math.random() * Math.PI * 2, r.addChild(n, a, l, o), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = r, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
223
269
  }
224
270
  dispose() {
225
- this.observer.disconnect(), this.app.ticker.remove(this.onTick);
271
+ this.observer.disconnect(), this.app.ticker.remove(this.onTick), this.app.destroy(!0);
226
272
  }
227
273
  }
228
- class te extends N {
274
+ class oe extends W {
229
275
  element;
230
276
  constructor() {
231
277
  const e = document.createElement("canvas");
@@ -238,34 +284,35 @@ class te extends N {
238
284
  super.dispose(), this.element.remove();
239
285
  }
240
286
  }
241
- const O = (h, e) => h.size === e.size && [...h].every((t) => e.has(t));
242
- class S {
287
+ const N = (h, e) => h.size === e.size && [...h].every((t) => e.has(t));
288
+ class w {
243
289
  currentPosition = 0;
244
290
  targetPosition = 0;
245
291
  currentTime = 0;
246
292
  params = {};
247
293
  currentSolver;
248
294
  getV;
295
+ getV2;
249
296
  queueParams;
250
297
  queuePosition;
251
298
  constructor(e = 0) {
252
- this.targetPosition = e, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
299
+ this.targetPosition = e, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0, this.getV2 = () => 0;
253
300
  }
254
301
  resetSolver() {
255
302
  const e = this.getV(this.currentTime);
256
- this.currentTime = 0, this.currentSolver = $(
303
+ this.currentTime = 0, this.currentSolver = q(
257
304
  this.currentPosition,
258
305
  e,
259
306
  this.targetPosition,
260
307
  0,
261
308
  this.params
262
- ), this.getV = q(this.currentSolver);
309
+ ), this.getV = M(this.currentSolver), this.getV2 = M(this.getV);
263
310
  }
264
311
  arrived() {
265
- return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
312
+ return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.getV2(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
266
313
  }
267
314
  setPosition(e) {
268
- this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0;
315
+ this.targetPosition = e, this.currentPosition = e, this.currentSolver = () => this.targetPosition, this.getV = () => 0, this.getV2 = () => 0;
269
316
  }
270
317
  update(e = 0) {
271
318
  this.currentTime += e, this.currentPosition = this.currentSolver(this.currentTime), this.queueParams && (this.queueParams.time -= e, this.queueParams.time <= 0 && this.updateParams({
@@ -274,15 +321,17 @@ class S {
274
321
  }
275
322
  updateParams(e, t = 0) {
276
323
  t > 0 ? this.queueParams = {
324
+ ...this.queuePosition ?? {},
277
325
  ...e,
278
326
  time: t
279
- } : (this.params = {
327
+ } : (this.queuePosition = void 0, this.params = {
280
328
  ...this.params,
281
329
  ...e
282
330
  }, this.resetSolver());
283
331
  }
284
332
  setTargetPosition(e, t = 0) {
285
333
  t > 0 ? this.queuePosition = {
334
+ ...this.queuePosition ?? {},
286
335
  position: e,
287
336
  time: t
288
337
  } : (this.queuePosition = void 0, this.targetPosition = e, this.resetSolver());
@@ -291,25 +340,25 @@ class S {
291
340
  return this.currentPosition;
292
341
  }
293
342
  }
294
- function $(h, e, t, n = 0, i) {
295
- const l = i?.soft ?? !1, s = i?.stiffness ?? 100, r = i?.damping ?? 10, a = i?.mass ?? 1, o = t - h;
296
- if (l || 1 <= r / (2 * Math.sqrt(s * a))) {
297
- const c = -Math.sqrt(s / a), d = -c * o - e;
298
- return (u) => (u -= n, u < 0 ? h : t - (o + u * d) * Math.E ** (u * c));
343
+ function q(h, e, t, i = 0, s) {
344
+ const r = s?.soft ?? !1, n = s?.stiffness ?? 100, a = s?.damping ?? 10, l = s?.mass ?? 1, o = t - h;
345
+ if (r || 1 <= a / (2 * Math.sqrt(n * l))) {
346
+ const c = -Math.sqrt(n / l), m = -c * o - e;
347
+ return (u) => (u -= i, u < 0 ? h : t - (o + u * m) * Math.E ** (u * c));
299
348
  } else {
300
349
  const c = Math.sqrt(
301
- 4 * a * s - r ** 2
302
- ), d = (r * o - 2 * a * e) / c, u = 0.5 * c / a, f = -(0.5 * r) / a;
303
- return (m) => (m -= n, m < 0 ? h : t - (Math.cos(m * u) * o + Math.sin(m * u) * d) * Math.E ** (m * f));
350
+ 4 * l * n - a ** 2
351
+ ), m = (a * o - 2 * l * e) / c, u = 0.5 * c / l, f = -(0.5 * a) / l;
352
+ return (p) => (p -= i, p < 0 ? h : t - (Math.cos(p * u) * o + Math.sin(p * u) * m) * Math.E ** (p * f));
304
353
  }
305
354
  }
306
- function _(h) {
355
+ function F(h) {
307
356
  return (t) => (h(t + 1e-3) - h(t - 1e-3)) / (2 * 1e-3);
308
357
  }
309
- function q(h) {
310
- return _(h);
358
+ function M(h) {
359
+ return F(h);
311
360
  }
312
- class F {
361
+ class R {
313
362
  constructor(e) {
314
363
  this.lyricPlayer = e, this.element.setAttribute(
315
364
  "class",
@@ -323,8 +372,8 @@ class F {
323
372
  // 由 LyricPlayer 来设置
324
373
  lineSize = [0, 0];
325
374
  lineTransforms = {
326
- posX: new S(0),
327
- posY: new S(0)
375
+ posX: new w(0),
376
+ posY: new w(0)
328
377
  };
329
378
  measureSize() {
330
379
  return [
@@ -346,32 +395,32 @@ class F {
346
395
  getElement() {
347
396
  return this.element;
348
397
  }
349
- setTransform(e = this.left, t = this.top, n = !1, i = 0) {
350
- this.left = e, this.top = t, this.delay = i * 1e3 | 0, n || !this.lyricPlayer.getEnableSpring() ? (n && this.element.classList.add(
398
+ setTransform(e = this.left, t = this.top, i = !1, s = 0) {
399
+ this.left = e, this.top = t, this.delay = s * 1e3 | 0, i || !this.lyricPlayer.getEnableSpring() ? (i && this.element.classList.add(
351
400
  this.lyricPlayer.style.classes.tmpDisableTransition
352
- ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), n && requestAnimationFrame(() => {
401
+ ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), i && requestAnimationFrame(() => {
353
402
  this.element.classList.remove(
354
403
  this.lyricPlayer.style.classes.tmpDisableTransition
355
404
  );
356
- })) : (this.lineTransforms.posX.setTargetPosition(e, i), this.lineTransforms.posY.setTargetPosition(t, i));
405
+ })) : (this.lineTransforms.posX.setTargetPosition(e, s), this.lineTransforms.posY.setTargetPosition(t, s));
357
406
  }
358
407
  update(e = 0) {
359
408
  this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.isInSight ? this.show() : this.hide());
360
409
  }
361
410
  get isInSight() {
362
- const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
363
- return !(e > r || t > a || n < l || i < s);
411
+ const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], s = t + this.lineSize[1], r = this.lyricPlayer.size[0], n = this.lyricPlayer.size[1];
412
+ return !(e > r || t > n || i < 0 || s < 0);
364
413
  }
365
414
  dispose() {
366
415
  this.element.remove();
367
416
  }
368
417
  }
369
- function X(h) {
418
+ function _(h) {
370
419
  const t = 2.5949095;
371
420
  return h < 0.5 ? Math.pow(2 * h, 2) * ((t + 1) * 2 * h - t) / 2 : (Math.pow(2 * h - 2, 2) * ((t + 1) * (h * 2 - 2) + t) + 2) / 2;
372
421
  }
373
- const g = (h, e, t) => Math.max(h, Math.min(e, t));
374
- class R {
422
+ const L = (h, e, t) => Math.max(h, Math.min(e, t));
423
+ class X {
375
424
  constructor(e) {
376
425
  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);
377
426
  }
@@ -399,41 +448,41 @@ class R {
399
448
  this.currentTime += e;
400
449
  let t = "";
401
450
  if (t += `transform:translate(${this.left}px, ${this.top}px)`, this.currentInterlude) {
402
- const n = this.currentInterlude[1] - this.currentInterlude[0], i = this.currentTime - this.currentInterlude[0];
403
- if (i <= n) {
404
- const l = n / Math.ceil(n / this.targetBreatheDuration);
405
- let s = 1, r = 1;
406
- s *= Math.sin(1.5 * Math.PI - i / l * 2) / 10 + 1, i < 1e3 && (s *= 1 - Math.pow((1e3 - i) / 1e3, 2)), i < 500 ? r = 0 : i < 1e3 && (r *= (i - 500) / 500), n - i < 750 && (s *= 1 - X(
407
- (750 - (n - i)) / 750 / 2
408
- )), n - i < 375 && (r *= g(
451
+ const i = this.currentInterlude[1] - this.currentInterlude[0], s = this.currentTime - this.currentInterlude[0];
452
+ if (s <= i) {
453
+ const r = i / Math.ceil(i / this.targetBreatheDuration);
454
+ let n = 1, a = 1;
455
+ n *= Math.sin(1.5 * Math.PI - s / r * 2) / 10 + 1, s < 1e3 && (n *= 1 - Math.pow((1e3 - s) / 1e3, 2)), s < 500 ? a = 0 : s < 1e3 && (a *= (s - 500) / 500), i - s < 750 && (n *= 1 - _(
456
+ (750 - (i - s)) / 750 / 2
457
+ )), i - s < 375 && (a *= L(
409
458
  0,
410
- (n - i) / 375,
459
+ (i - s) / 375,
411
460
  1
412
- )), s = Math.max(0, s), t += ` scale(${s})`;
413
- const a = g(
461
+ )), n = Math.max(0, n), t += ` scale(${n})`;
462
+ const l = L(
414
463
  0.25,
415
- i * 3 / n * 0.75,
464
+ s * 3 / i * 0.75,
416
465
  1
417
- ), o = g(
466
+ ), o = L(
418
467
  0.25,
419
- (i - n / 3) * 3 / n * 0.75,
468
+ (s - i / 3) * 3 / i * 0.75,
420
469
  1
421
- ), c = g(
470
+ ), c = L(
422
471
  0.25,
423
- (i - n / 3 * 2) * 3 / n * 0.75,
472
+ (s - i / 3 * 2) * 3 / i * 0.75,
424
473
  1
425
474
  );
426
- this.dot0.style.opacity = `${g(
475
+ this.dot0.style.opacity = `${L(
427
476
  0,
428
- Math.max(0, r * a),
477
+ Math.max(0, a * l),
429
478
  1
430
- )}`, this.dot1.style.opacity = `${g(
479
+ )}`, this.dot1.style.opacity = `${L(
431
480
  0,
432
- Math.max(0, r * o),
481
+ Math.max(0, a * o),
433
482
  1
434
- )}`, this.dot2.style.opacity = `${g(
483
+ )}`, this.dot2.style.opacity = `${L(
435
484
  0,
436
- Math.max(0, r * c),
485
+ Math.max(0, a * c),
437
486
  1
438
487
  )}`;
439
488
  } else
@@ -446,19 +495,34 @@ class R {
446
495
  this.element.remove();
447
496
  }
448
497
  }
449
- const v = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
450
- function W(h, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
451
- const n = 2 + h, i = h / n, l = (1 - i) / 2;
498
+ const Y = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
499
+ function G(h, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
500
+ const i = 2 + h, s = h / i, r = (1 - s) / 2;
452
501
  return [
453
- `linear-gradient(to right,${e} ${l * 100}%,${t} ${(l + i) * 100}%)`,
454
- i,
455
- n
502
+ `linear-gradient(to right,${e} ${r * 100}%,${t} ${(r + s) * 100}%)`,
503
+ s,
504
+ i
456
505
  ];
457
506
  }
507
+ function V(h, e) {
508
+ let t = [], i = [];
509
+ const s = [];
510
+ for (const r of h) {
511
+ const n = e(r);
512
+ t.push(n), i.push(r), n.length > 0 && n.trim().length === 0 ? (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), s.push(r), t = [], i = []) : (!/^\s*[^\s]*\s*$/.test(t.join("")) || Y.test(n)) && (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), t = [n], i = [r]);
513
+ }
514
+ return i.length === 1 ? s.push(i[0]) : s.push(i), s;
515
+ }
458
516
  function x(h) {
459
517
  return h.endTime - h.startTime >= 1e3 && h.word.length <= 7;
460
518
  }
461
- class Y {
519
+ class H extends MouseEvent {
520
+ constructor(e, t) {
521
+ super(t.type, t), this.line = e;
522
+ }
523
+ }
524
+ class j extends EventTarget {
525
+ // rome-ignore lint/correctness/noUnreachableSuper: <explanation>
462
526
  constructor(e, t = {
463
527
  words: [],
464
528
  translatedLyric: "",
@@ -468,12 +532,12 @@ class Y {
468
532
  isBG: !1,
469
533
  isDuet: !1
470
534
  }) {
471
- this.lyricPlayer = e, this.lyricLine = t, this.element.setAttribute(
535
+ super(), this.lyricPlayer = e, this.lyricLine = t, this.element.setAttribute(
472
536
  "class",
473
537
  this.lyricPlayer.style.classes.lyricLine
474
538
  ), 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"));
475
- const n = this.element.children[0], i = this.element.children[1], l = this.element.children[2];
476
- n.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), i.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), l.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
539
+ const i = this.element.children[0], s = this.element.children[1], r = this.element.children[2];
540
+ i.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), s.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), r.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
477
541
  }
478
542
  element = document.createElement("div");
479
543
  left = 0;
@@ -485,17 +549,34 @@ class Y {
485
549
  // 由 LyricPlayer 来设置
486
550
  lineSize = [0, 0];
487
551
  lineTransforms = {
488
- posX: new S(0),
489
- posY: new S(0),
490
- scale: new S(1)
552
+ posX: new w(0),
553
+ posY: new w(0),
554
+ scale: new w(1)
555
+ };
556
+ listenersMap = /* @__PURE__ */ new Map();
557
+ onMouseEvent = (e) => {
558
+ if (!this.dispatchEvent(new H(this, e)))
559
+ return e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), !1;
491
560
  };
561
+ addEventListener(e, t, i) {
562
+ if (super.addEventListener(e, t, i), t) {
563
+ const s = this.listenersMap.get(e) ?? /* @__PURE__ */ new Set();
564
+ s.size === 0 && this.element.addEventListener(e, this.onMouseEvent), s.add(t), this.listenersMap.set(e, s);
565
+ }
566
+ }
567
+ removeEventListener(e, t, i) {
568
+ if (super.removeEventListener(e, t, i), t) {
569
+ const s = this.listenersMap.get(e);
570
+ s && (s.delete(t), s.size === 0 && this.element.removeEventListener(e, this.onMouseEvent));
571
+ }
572
+ }
492
573
  isEnabled = !1;
493
574
  enable() {
494
575
  this.isEnabled = !0, this.element.classList.add("active");
495
576
  const e = this.element.children[0];
496
577
  this.splittedWords.forEach((t) => {
497
- t.elementAnimations.forEach((n) => {
498
- n.currentTime = 0, n.playbackRate = 1, n.play();
578
+ t.elementAnimations.forEach((i) => {
579
+ i.currentTime = 0, i.playbackRate = 1, i.play();
499
580
  });
500
581
  }), e.classList.add("active");
501
582
  }
@@ -511,8 +592,8 @@ class Y {
511
592
  this.isEnabled = !1, this.element.classList.remove("active");
512
593
  const e = this.element.children[0];
513
594
  this.splittedWords.forEach((t) => {
514
- t.elementAnimations.forEach((n) => {
515
- n.id === "float-word" && (n.playbackRate = -1, n.play());
595
+ t.elementAnimations.forEach((i) => {
596
+ i.id === "float-word" && (i.playbackRate = -1, i.play());
516
597
  });
517
598
  }), e.classList.remove("active");
518
599
  }
@@ -544,84 +625,86 @@ class Y {
544
625
  !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));
545
626
  }
546
627
  rebuildElement() {
547
- const e = this.element.children[0], t = this.element.children[1], n = this.element.children[2];
628
+ const e = this.element.children[0], t = this.element.children[1], i = this.element.children[2];
548
629
  if (this.lyricPlayer._getIsNonDynamic()) {
549
- for (; e.firstChild; )
550
- e.removeChild(e.firstChild), s(e.firstChild);
551
- e.innerText = this.lyricLine.words.map((a) => a.word).join(""), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
630
+ e.innerText = this.lyricLine.words.map((r) => r.word).join(""), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
552
631
  return;
553
632
  }
554
- this.splittedWords = [], this.lyricLine.words.forEach((a) => {
555
- const o = a.word.split(/\s+/), c = o.reduce((u, f) => u + f.length, 0);
556
- let d = 0;
557
- o.forEach((u, f) => {
558
- f > 0 && this.splittedWords.push({
559
- word: " ",
560
- startTime: 0,
561
- endTime: 0,
562
- width: 0,
563
- height: 0,
564
- elements: [],
565
- elementAnimations: [],
566
- shouldEmphasize: !1
567
- }), this.splittedWords.push({
568
- word: u,
569
- startTime: a.startTime + (a.endTime - a.startTime) / c * d,
570
- endTime: a.startTime + (a.endTime - a.startTime) / c * (d + u.length),
633
+ const s = V(this.lyricLine.words, (r) => r.word);
634
+ e.innerHTML = "", this.splittedWords = [];
635
+ for (const r of s)
636
+ if (r instanceof Array) {
637
+ const n = r.map((o) => x(o)).reduce((o, c) => o || c, !1), a = r.reduce(
638
+ (o, c) => (o.endTime = Math.max(o.endTime, c.endTime), o.startTime = Math.min(o.startTime, c.startTime), o.word += c.word, o),
639
+ { word: "", startTime: 1 / 0, endTime: -1 / 0 }
640
+ ), l = document.createElement("span");
641
+ for (const o of r) {
642
+ const c = document.createElement("span"), m = this.initFloatAnimation(
643
+ a,
644
+ c
645
+ );
646
+ if (n) {
647
+ c.classList.add("emphasize");
648
+ const u = [];
649
+ for (const p of o.word.trim().split("")) {
650
+ const d = document.createElement("span");
651
+ d.innerText = p, u.push(d), c.appendChild(d);
652
+ }
653
+ const f = {
654
+ ...o,
655
+ mainElement: c,
656
+ subElements: u,
657
+ elementAnimations: [m],
658
+ width: 0,
659
+ height: 0,
660
+ shouldEmphasize: n
661
+ };
662
+ f.elementAnimations.push(
663
+ ...this.initEmphasizeAnimation(f)
664
+ ), this.splittedWords.push(f);
665
+ } else
666
+ c.innerText = o.word, this.splittedWords.push({
667
+ ...o,
668
+ mainElement: c,
669
+ subElements: [],
670
+ elementAnimations: [m],
671
+ width: 0,
672
+ height: 0,
673
+ shouldEmphasize: n
674
+ });
675
+ l.appendChild(c);
676
+ }
677
+ a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(l), a.word.trimEnd() !== a.word && e.appendChild(document.createTextNode(" "));
678
+ } else if (r.word.trim().length === 0)
679
+ e.appendChild(document.createTextNode(" "));
680
+ else {
681
+ const n = x(r), a = document.createElement("span"), l = {
682
+ ...r,
683
+ mainElement: a,
684
+ subElements: [],
685
+ elementAnimations: [this.initFloatAnimation(r, a)],
571
686
  width: 0,
572
687
  height: 0,
573
- elements: [],
574
- elementAnimations: [],
575
- shouldEmphasize: x(a)
576
- }), d += u.length;
577
- });
578
- });
579
- const i = [], l = [];
580
- function s(a) {
581
- for (; a.firstChild; )
582
- a.firstChild.nodeType === Node.ELEMENT_NODE ? i.push(e.firstChild) : a.firstChild.nodeType === Node.TEXT_NODE && l.push(e.firstChild), a.removeChild(a.firstChild), s(a.firstChild);
583
- }
584
- s(e);
585
- let r = null;
586
- this.splittedWords.forEach((a) => {
587
- if (a.word.trim().length > 0)
588
- if (a.shouldEmphasize) {
589
- const o = i.pop() ?? document.createElement("span");
590
- o.className = "emphasize", a.elements = [o];
591
- for (const c of a.word) {
592
- const d = i.pop() ?? document.createElement("span");
593
- d.className = "", d.innerText = c, o.appendChild(d), a.elements.push(d);
688
+ shouldEmphasize: n
689
+ };
690
+ if (n) {
691
+ a.classList.add("emphasize");
692
+ const o = [];
693
+ for (const c of r.word.trim().split("")) {
694
+ const m = document.createElement("span");
695
+ m.innerText = c, o.push(m), a.appendChild(m);
594
696
  }
595
- if (a.elementAnimations = this.initEmphasizeAnimation(a), r && !v.test(a.word))
596
- if (r.childElementCount > 0)
597
- r.appendChild(o);
598
- else {
599
- const c = i.pop() ?? document.createElement("span");
600
- c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
601
- }
602
- else
603
- r = v.test(a.word) ? null : o, e.appendChild(o);
604
- } else {
605
- const o = i.pop() ?? document.createElement("span");
606
- if (o.className = "", o.innerText = a.word, a.elements = [o], a.elementAnimations.push(this.initFloatAnimation(a, o)), r)
607
- if (r.childElementCount > 0)
608
- r.appendChild(o);
609
- else {
610
- const c = i.pop() ?? document.createElement("span");
611
- c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
612
- }
613
- else
614
- r = o, e.appendChild(o);
615
- }
616
- else if (a.word.length > 0) {
617
- const o = l.pop() ?? document.createTextNode(" ");
618
- e.appendChild(o), r = null;
619
- } else
620
- r = null;
621
- }), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
697
+ l.subElements = o, l.elementAnimations.push(
698
+ ...this.initEmphasizeAnimation(l)
699
+ );
700
+ } else
701
+ a.innerText = r.word.trim();
702
+ r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(a), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(l);
703
+ }
704
+ t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
622
705
  }
623
706
  initFloatAnimation(e, t) {
624
- const n = e.startTime - this.lyricLine.startTime, i = Math.max(1e3, e.endTime - e.startTime), l = t.animate(
707
+ const i = e.startTime - this.lyricLine.startTime, s = Math.max(1e3, e.endTime - e.startTime), r = t.animate(
625
708
  [
626
709
  {
627
710
  transform: "translateY(0px)"
@@ -631,101 +714,117 @@ class Y {
631
714
  }
632
715
  ],
633
716
  {
634
- duration: isFinite(i) ? i : 0,
635
- delay: isFinite(n) ? n : 0,
717
+ duration: isFinite(s) ? s : 0,
718
+ delay: isFinite(i) ? i : 0,
636
719
  id: "float-word",
637
720
  composite: "add",
638
721
  fill: "both"
639
722
  }
640
723
  );
641
- return l.pause(), l;
724
+ return r.pause(), r;
642
725
  }
643
726
  initEmphasizeAnimation(e) {
644
- const t = e.startTime - this.lyricLine.startTime, n = e.endTime - e.startTime;
645
- return e.elements.map((i, l, s) => {
646
- if (l === 0)
647
- return this.initFloatAnimation(e, i);
648
- {
649
- const r = Math.max(1e3, e.endTime - e.startTime), a = t + n / (s.length - 1) * (l - 1), o = i.animate(
650
- [
651
- {
652
- offset: 0,
653
- transform: "translate3d(0, 0px, 0px)",
654
- filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
655
- },
656
- {
657
- offset: 0.5,
658
- transform: "translate3d(0, -2%, 20px)",
659
- filter: "drop-shadow(0 0 0.05em var(--amll-lyric-view-color,white))"
660
- },
661
- {
662
- offset: 1,
663
- transform: "translate3d(0, 0px, 0)",
664
- filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
665
- }
666
- ],
727
+ const t = e.startTime - this.lyricLine.startTime, i = e.endTime - e.startTime;
728
+ return e.subElements.map((s, r, n) => {
729
+ const a = Math.max(1e3, e.endTime - e.startTime), l = t + i / n.length * r, o = s.animate(
730
+ [
731
+ {
732
+ offset: 0,
733
+ transform: "translate3d(0, 0, 0px)",
734
+ filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
735
+ },
736
+ {
737
+ offset: 0.5,
738
+ transform: "translate3d(0, -0.02em, 20px)",
739
+ filter: "drop-shadow(0 0 0.05em var(--amll-lyric-view-color,white))"
740
+ },
667
741
  {
668
- duration: isFinite(r) ? r : 0,
669
- delay: isFinite(a) ? a : 0,
670
- id: "glow-word",
671
- iterations: 1,
672
- composite: "replace",
673
- fill: "both"
742
+ offset: 1,
743
+ transform: "translate3d(0, 0, 0)",
744
+ filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
674
745
  }
675
- );
676
- return o.pause(), o;
677
- }
746
+ ],
747
+ {
748
+ duration: isFinite(a) ? a : 0,
749
+ delay: isFinite(l) ? l : 0,
750
+ id: "glow-word",
751
+ iterations: 1,
752
+ composite: "replace",
753
+ easing: "ease-in-out",
754
+ fill: "both"
755
+ }
756
+ );
757
+ return o.pause(), o;
678
758
  });
679
759
  }
680
760
  updateMaskImage() {
681
761
  this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden"), this.splittedWords.forEach((e) => {
682
- const t = e.elements[0];
762
+ const t = e.mainElement;
683
763
  if (t) {
684
764
  e.width = t.clientWidth, e.height = t.clientHeight;
685
- const [n, i, l] = W(
686
- 16 / e.width,
687
- "rgba(0,0,0,0.75)",
765
+ const i = e.height / 2, [s, r, n] = G(
766
+ i / e.width,
767
+ "rgba(0,0,0,1)",
688
768
  "rgba(0,0,0,0.25)"
689
- ), s = `${l * 100}% 100%`;
690
- this.lyricPlayer.supportMaskImage ? (t.style.maskImage = n, t.style.maskOrigin = "left", t.style.maskSize = s) : (t.style.webkitMaskImage = n, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = s);
691
- const r = e.width + 16, a = `clamp(${-r}px,calc(${-r}px + (var(--amll-player-time) - ${e.startTime})*${r / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
692
- t.style.maskPosition = a, t.style.webkitMaskPosition = a;
769
+ ), a = `${n * 100}% 100%`;
770
+ this.lyricPlayer.supportMaskImage ? (t.style.maskImage = s, t.style.maskOrigin = "left", t.style.maskSize = a) : (t.style.webkitMaskImage = s, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = a);
771
+ const l = e.width + i, o = `clamp(${-l}px,calc(${-l}px + (var(--amll-player-time) - ${e.startTime})*${l / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
772
+ t.style.maskPosition = o, t.style.webkitMaskPosition = o;
693
773
  }
694
774
  }), this._hide && (this.element.style.display = "none", this.element.style.visibility = "");
695
775
  }
696
776
  getElement() {
697
777
  return this.element;
698
778
  }
699
- setTransform(e = this.left, t = this.top, n = this.scale, i = 1, l = 0, s = !1, r = 0) {
700
- this.left = e, this.top = t, this.scale = n, this.delay = r * 1e3 | 0;
701
- const a = this.element.children[0];
702
- a.style.opacity = `${i}`, s || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, l), s && this.element.classList.add(
703
- this.lyricPlayer.style.classes.tmpDisableTransition
704
- ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(n), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), s && requestAnimationFrame(() => {
705
- this.element.classList.remove(
779
+ setTransform(e = this.left, t = this.top, i = this.scale, s = 1, r = 0, n = !1, a = 0) {
780
+ const l = this.isInSight, o = this.lyricPlayer.getEnableSpring();
781
+ this.left = e, this.top = t, this.scale = i, this.delay = a * 1e3 | 0;
782
+ const c = this.element.children[0], m = this.element.children[1], u = this.element.children[2];
783
+ if (c.style.opacity = `${s}`, m.style.opacity = `${s / 2}`, u.style.opacity = `${s / 2}`, n || !o) {
784
+ if (this.blur = Math.min(32, r), n && this.element.classList.add(
706
785
  this.lyricPlayer.style.classes.tmpDisableTransition
707
- );
708
- })) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(n), this.blur !== Math.min(32, l) && (this.blur = Math.min(32, l), this.element.style.filter = `blur(${Math.min(32, l)}px)`));
786
+ ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(i), o)
787
+ this.rebuildStyle();
788
+ else {
789
+ const f = this.isInSight;
790
+ l || f ? this.show() : this.hide();
791
+ }
792
+ n && requestAnimationFrame(() => {
793
+ this.element.classList.remove(
794
+ this.lyricPlayer.style.classes.tmpDisableTransition
795
+ );
796
+ });
797
+ } else
798
+ this.lineTransforms.posX.setTargetPosition(e, a), this.lineTransforms.posY.setTargetPosition(t, a), this.lineTransforms.scale.setTargetPosition(i), this.blur !== Math.min(32, r) && (this.blur = Math.min(32, r), this.element.style.filter = `blur(${Math.min(32, r)}px)`);
709
799
  }
710
800
  update(e = 0) {
711
801
  this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.lineTransforms.scale.update(e), this.isInSight ? this.show() : this.hide());
712
802
  }
803
+ _getDebugTargetPos() {
804
+ return `[位移: ${this.left}, ${this.top}; 缩放: ${this.scale}; 延时: ${this.delay}]`;
805
+ }
713
806
  get isInSight() {
714
- const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
715
- return !(e > r || t > a || n < l || i < s);
807
+ const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], s = t + this.lineSize[1], r = this.lyricPlayer.size[0], n = this.lyricPlayer.size[1];
808
+ return !(e > r || i < 0 || t > n || s < 0);
716
809
  }
717
810
  dispose() {
718
811
  this.element.remove();
719
812
  }
720
813
  }
721
- const G = D(A());
722
- class ie extends EventTarget {
814
+ const U = D(k());
815
+ class J extends MouseEvent {
816
+ constructor(e, t, i) {
817
+ super(`line-${i.type}`, i), this.lineIndex = e, this.line = t;
818
+ }
819
+ }
820
+ class le extends EventTarget {
723
821
  element = document.createElement("div");
724
822
  currentTime = 0;
725
823
  lyricLines = [];
726
824
  processedLines = [];
727
825
  lyricLinesEl = [];
728
- lyricLinesSize = /* @__PURE__ */ new Map();
826
+ lyricLinesSize = /* @__PURE__ */ new WeakMap();
827
+ lyricLinesIndexes = /* @__PURE__ */ new WeakMap();
729
828
  hotLines = /* @__PURE__ */ new Set();
730
829
  bufferedLines = /* @__PURE__ */ new Set();
731
830
  scrollToIndex = 0;
@@ -734,11 +833,12 @@ class ie extends EventTarget {
734
833
  isScrolled = !1;
735
834
  invokedByScrollEvent = !1;
736
835
  scrollOffset = 0;
836
+ hidePassedLines = !1;
737
837
  resizeObserver = new ResizeObserver((e) => {
738
838
  const t = e[0].contentRect;
739
- this.size[0] = t.width, this.size[1] = t.height, this.pos[0] = t.left, this.pos[1] = t.top;
740
- const n = getComputedStyle(e[0].target), i = this.element.clientWidth - parseFloat(n.paddingLeft) - parseFloat(n.paddingRight), l = this.element.clientHeight - parseFloat(n.paddingTop) - parseFloat(n.paddingBottom);
741
- this.innerSize[0] = i, this.innerSize[1] = l, this.rebuildStyle(), this.calcLayout(!0, !0), this.lyricLinesEl.forEach((s) => s.updateMaskImage());
839
+ this.size[0] = t.width, this.size[1] = t.height;
840
+ const i = getComputedStyle(e[0].target), s = this.element.clientWidth - parseFloat(i.paddingLeft) - parseFloat(i.paddingRight), r = this.element.clientHeight - parseFloat(i.paddingTop) - parseFloat(i.paddingBottom);
841
+ this.innerSize[0] = s, this.innerSize[1] = r, this.rebuildStyle(), this.calcLayout(!0, !0), this.lyricLinesEl.forEach((n) => n.updateMaskImage());
742
842
  });
743
843
  posXSpringParams = {
744
844
  mass: 1,
@@ -755,7 +855,10 @@ class ie extends EventTarget {
755
855
  damping: 20,
756
856
  stiffness: 100
757
857
  };
858
+ emUnit = Math.max(Math.min(innerHeight * 0.05, innerWidth * 0.1), 12);
859
+ padding = this.emUnit;
758
860
  enableBlur = !0;
861
+ enableScale = !0;
759
862
  interludeDots;
760
863
  interludeDotsSize = [0, 0];
761
864
  bottomLine;
@@ -767,7 +870,14 @@ class ie extends EventTarget {
767
870
  isNonDynamic = !1;
768
871
  size = [0, 0];
769
872
  innerSize = [0, 0];
770
- pos = [0, 0];
873
+ onLineClickedHandler = (e) => {
874
+ const t = new J(
875
+ this.lyricLinesIndexes.get(e.line) ?? -1,
876
+ e.line,
877
+ e
878
+ );
879
+ this.dispatchEvent(t) || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation());
880
+ };
771
881
  _getIsNonDynamic() {
772
882
  return this.isNonDynamic;
773
883
  }
@@ -788,10 +898,28 @@ class ie extends EventTarget {
788
898
  getEnableSpring() {
789
899
  return !this.disableSpring;
790
900
  }
791
- style = G.createStyleSheet({
901
+ /**
902
+ * 是否启用歌词行缩放效果,默认启用
903
+ *
904
+ * 如果启用,非选中的歌词行会轻微缩小以凸显当前播放歌词行效果
905
+ *
906
+ * 此效果对性能影响微乎其微,推荐启用
907
+ * @param enable 是否启用歌词行缩放效果
908
+ */
909
+ setEnableScale(e = !0) {
910
+ this.enableScale = e, this.calcLayout();
911
+ }
912
+ /**
913
+ * 获取当前是否启用了歌词行缩放效果
914
+ * @returns 是否启用歌词行缩放效果
915
+ */
916
+ getEnableScale() {
917
+ return this.enableScale;
918
+ }
919
+ style = U.createStyleSheet({
792
920
  lyricPlayer: {
793
921
  userSelect: "none",
794
- fontSize: "var(--amll-lyric-player-font-size,max(5vh, 12px))",
922
+ fontSize: "var(--amll-lyric-player-font-size,max(min(5vh, 10vw), 12px))",
795
923
  padding: "1em",
796
924
  margin: "-1em",
797
925
  width: "100%",
@@ -802,7 +930,12 @@ class ie extends EventTarget {
802
930
  zIndex: 1,
803
931
  color: "var(--amll-lyric-view-color,white)",
804
932
  mixBlendMode: "plus-lighter",
805
- contain: "strict"
933
+ contain: "strict",
934
+ "&:hover": {
935
+ "& $lyricLine": {
936
+ filter: "unset !important"
937
+ }
938
+ }
806
939
  },
807
940
  lyricLine: {
808
941
  position: "absolute",
@@ -810,15 +943,24 @@ class ie extends EventTarget {
810
943
  maxWidth: "var(--amll-lyric-player-width,100%)",
811
944
  minWidth: "var(--amll-lyric-player-width,100%)",
812
945
  width: "var(--amll-lyric-player-width,100%)",
813
- padding: "2vh 0.05em",
946
+ padding: "2vh 1.05em",
947
+ margin: "0 -1em",
814
948
  contain: "content",
815
949
  willChange: "filter,transform,opacity",
816
- transition: "filter 0.25s",
817
- boxSizing: "border-box"
950
+ transition: "filter 0.25s, background-color 0.25s, box-shadow 0.25s",
951
+ boxSizing: "content-box",
952
+ borderRadius: "8px",
953
+ "&:hover": {
954
+ backgroundColor: "var(--amll-lyric-view-hover-bg-color,#fff1)",
955
+ boxShadow: "0 0 0 8px var(--amll-lyric-view-hover-bg-color,#fff1)"
956
+ },
957
+ "&:active": {
958
+ boxShadow: "0 0 0 4px var(--amll-lyric-view-hover-bg-color,#fff1)"
959
+ }
818
960
  },
819
961
  "@media (max-width: 1024px)": {
820
962
  lyricLine: {
821
- padding: "1vh 0"
963
+ padding: "1vh 1em"
822
964
  }
823
965
  },
824
966
  lyricDuetLine: {
@@ -844,7 +986,6 @@ class ie extends EventTarget {
844
986
  },
845
987
  "& > span": {
846
988
  whiteSpace: "pre-wrap",
847
- wordBreak: "keep-all",
848
989
  maxLines: "1",
849
990
  // willChange: "transform,display,mask-image",
850
991
  "&.emphasize": {
@@ -856,12 +997,13 @@ class ie extends EventTarget {
856
997
  }
857
998
  },
858
999
  lyricSubLine: {
859
- fontSize: "max(50%, 10px)",
1000
+ fontSize: "max(0.5em, 10px)",
1001
+ transition: "opacity 0.3s 0.25s",
860
1002
  opacity: 0.5
861
1003
  },
862
1004
  disableSpring: {
863
1005
  "& > *": {
864
- transition: "filter 0.25s, transform 0.5s"
1006
+ transition: "filter 0.25s, transform 0.5s, background-color 0.25s, box-shadow 0.25s"
865
1007
  }
866
1008
  },
867
1009
  interludeDots: {
@@ -874,7 +1016,7 @@ class ie extends EventTarget {
874
1016
  gap: "0.25em",
875
1017
  left: "1em",
876
1018
  "& > *": {
877
- height: "100%",
1019
+ height: "clamp(0.5em,1vh,3em)",
878
1020
  display: "inline-block",
879
1021
  borderRadius: "50%",
880
1022
  aspectRatio: "1 / 1",
@@ -899,7 +1041,7 @@ class ie extends EventTarget {
899
1041
  this.calcLayout(!0, !0);
900
1042
  };
901
1043
  constructor() {
902
- super(), this.interludeDots = new R(this), this.bottomLine = new F(this), this.element.setAttribute("class", this.style.classes.lyricPlayer), this.disableSpring && this.element.classList.add(this.style.classes.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow), this.element.addEventListener("wheel", (e) => {
1044
+ super(), this.interludeDots = new X(this), this.bottomLine = new R(this), this.element.setAttribute("class", this.style.classes.lyricPlayer), this.disableSpring && this.element.classList.add(this.style.classes.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow), this.element.addEventListener("wheel", (e) => {
903
1045
  this.allowScroll && (this.isScrolled = !0, clearTimeout(this.scrolledHandler), this.scrolledHandler = setTimeout(() => {
904
1046
  this.isScrolled = !1, this.scrollOffset = 0;
905
1047
  }, 5e3), this.invokedByScrollEvent = !0, e.deltaMode === e.DOM_DELTA_PIXEL ? (this.scrollOffset += e.deltaY, this.calcLayout(!0)) : (this.scrollOffset += e.deltaY * 50, this.calcLayout(!1)), this.invokedByScrollEvent = !1);
@@ -940,7 +1082,14 @@ class ie extends EventTarget {
940
1082
  */
941
1083
  rebuildStyle() {
942
1084
  let e = "";
943
- e += "--amll-lyric-player-width:", e += this.innerSize[0], e += "px;", e += "--amll-lyric-player-height:", e += this.innerSize[1], e += "px;", e += "--amll-player-time:", e += this.currentTime, e += ";", this.element.setAttribute("style", e);
1085
+ e += "--amll-lyric-player-width:", e += this.innerSize[0] - this.padding * 2, e += "px;", e += "--amll-lyric-player-height:", e += this.innerSize[1] - this.padding * 2, e += "px;", e += "--amll-player-time:", e += this.currentTime, e += ";", this.element.setAttribute("style", e);
1086
+ }
1087
+ /**
1088
+ * 设置是否隐藏已经播放过的歌词行,默认不隐藏
1089
+ * @param hide 是否隐藏已经播放过的歌词行,默认不隐藏
1090
+ */
1091
+ setHidePassedLines(e) {
1092
+ this.hidePassedLines = e, this.calcLayout();
944
1093
  }
945
1094
  /**
946
1095
  * 设置是否启用歌词行的模糊效果
@@ -957,24 +1106,29 @@ class ie extends EventTarget {
957
1106
  this.lyricLines = e;
958
1107
  const t = 750;
959
1108
  this.processedLines = e.filter(
960
- (i) => i.words.reduce((l, s) => l + s.word.trim().length, 0) > 0
961
- ).map((i, l, s) => {
1109
+ (i) => i.words.reduce((s, r) => s + r.word.trim().length, 0) > 0
1110
+ ).map((i, s, r) => {
962
1111
  if (i.isBG)
963
1112
  return {
964
1113
  ...i
965
1114
  };
1115
+ if (s === 0)
1116
+ return {
1117
+ ...i,
1118
+ startTime: Math.max(i.startTime - t, 0)
1119
+ };
966
1120
  {
967
- const r = s[l - 1], a = s[l - 2];
968
- if (r?.isBG && a) {
1121
+ const n = r[s - 1], a = r[s - 2];
1122
+ if (n?.isBG && a) {
969
1123
  if (a.endTime < i.startTime)
970
1124
  return {
971
1125
  ...i,
972
1126
  startTime: Math.max(a.endTime, i.startTime - t) || i.startTime
973
1127
  };
974
- } else if (r?.endTime && r.endTime < i.startTime)
1128
+ } else if (n?.endTime && n.endTime < i.startTime)
975
1129
  return {
976
1130
  ...i,
977
- startTime: Math.max(r?.endTime, i.startTime - t) || i.startTime
1131
+ startTime: Math.max(n?.endTime, i.startTime - t) || i.startTime
978
1132
  };
979
1133
  return {
980
1134
  ...i
@@ -986,22 +1140,31 @@ class ie extends EventTarget {
986
1140
  this.isNonDynamic = !1;
987
1141
  break;
988
1142
  }
989
- this.processedLines.forEach((i, l, s) => {
990
- const r = s[l + 1], a = i.words[i.words.length - 1];
991
- a && x(a) && (r ? r.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, r.startTime)) : i.endTime = i.endTime + 1500);
992
- }), this.processedLines.forEach((i, l, s) => {
1143
+ this.processedLines.forEach((i, s, r) => {
1144
+ const n = r[s + 1], a = i.words[i.words.length - 1];
1145
+ a && x(a) && (n ? n.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, n.startTime)) : i.endTime = i.endTime + 1500);
1146
+ }), this.processedLines.forEach((i, s, r) => {
993
1147
  if (i.isBG)
994
1148
  return;
995
- const r = s[l + 1];
996
- r?.isBG && (r.startTime = Math.min(r.startTime, i.startTime));
997
- });
998
- const n = this.lyricLinesEl;
999
- for (this.lyricLinesEl = this.processedLines.map((i, l) => this.lyricLinesEl[l] ?? new Y(this, i)); n.length > this.processedLines.length; )
1000
- n.pop()?.dispose();
1001
- this.lyricLinesEl.forEach((i) => {
1002
- this.element.appendChild(i.getElement()), i.updateMaskImage();
1149
+ const n = r[s + 1];
1150
+ n?.isBG && (n.startTime = Math.min(n.startTime, i.startTime));
1151
+ }), this.lyricLinesEl.forEach((i) => {
1152
+ i.removeEventListener("click", this.onLineClickedHandler), i.removeEventListener("contextmenu", this.onLineClickedHandler), i.dispose();
1153
+ }), this.lyricLinesEl = this.processedLines.map((i) => {
1154
+ const s = new j(this, i);
1155
+ return s.addEventListener("click", this.onLineClickedHandler), s.addEventListener("contextmenu", this.onLineClickedHandler), s;
1156
+ }), this.lyricLinesEl.forEach((i, s) => {
1157
+ this.element.appendChild(i.getElement()), this.lyricLinesIndexes.set(i, s), i.updateMaskImage();
1003
1158
  }), this.interludeDots.setInterlude(void 0), this.hotLines.clear(), this.bufferedLines.clear(), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0, !0);
1004
1159
  }
1160
+ /**
1161
+ * 重置用户滚动状态
1162
+ *
1163
+ * 请在用户完成滚动点击跳转歌词时调用本事件再调用 `calcLayout` 以正确滚动到目标位置
1164
+ */
1165
+ resetScroll() {
1166
+ this.isScrolled = !1, this.scrollOffset = 0, this.invokedByScrollEvent = !1, clearTimeout(this.scrolledHandler), this.scrolledHandler = 0;
1167
+ }
1005
1168
  /**
1006
1169
  * 重新布局定位歌词行的位置,调用完成后再逐帧调用 `update`
1007
1170
  * 函数即可让歌词通过动画移动到目标位置。
@@ -1020,44 +1183,46 @@ class ie extends EventTarget {
1020
1183
  * @param reflow 是否进行重新布局(重新计算每行歌词大小)
1021
1184
  */
1022
1185
  calcLayout(e = !1, t = !1) {
1023
- t && (this.lyricLinesEl.forEach((m) => {
1024
- const p = m.measureSize();
1025
- this.lyricLinesSize.set(m, p), m.lineSize = p;
1186
+ t && (this.emUnit = parseFloat(getComputedStyle(this.element).fontSize), this.lyricLinesEl.forEach((p) => {
1187
+ const d = p.measureSize();
1188
+ this.lyricLinesSize.set(p, d), p.lineSize = d;
1026
1189
  }), this.interludeDotsSize[0] = this.interludeDots.getElement().clientWidth, this.interludeDotsSize[1] = this.interludeDots.getElement().clientHeight, this.bottomLine.lineSize = this.bottomLine.measureSize());
1027
- const n = this.getCurrentInterlude();
1028
- let i = -this.scrollOffset, l = this.scrollToIndex, s = 0;
1029
- n ? (s = n[1] - n[0], s >= 5e3 && this.lyricLinesEl[n[2] + 1] && (l = n[2] + 1)) : this.interludeDots.setInterlude(void 0);
1030
- const r = 0.95, a = this.lyricLinesEl.slice(0, l).reduce(
1031
- (m, p) => m + (p.getLine().isBG ? 0 : this.lyricLinesSize.get(p)?.[1] ?? 0),
1190
+ const i = this.getCurrentInterlude();
1191
+ let s = -this.scrollOffset, r = this.scrollToIndex, n = 0;
1192
+ i ? (n = i[1] - i[0], n >= 5e3 && this.lyricLinesEl[i[2] + 1] && (r = i[2] + 1)) : this.interludeDots.setInterlude(void 0);
1193
+ const a = this.enableScale ? 0.95 : 1, l = this.lyricLinesEl.slice(0, r).reduce(
1194
+ (p, d) => p + (d.getLine().isBG ? 0 : this.lyricLinesSize.get(d)?.[1] ?? 0),
1032
1195
  0
1033
1196
  );
1034
- i -= a, i += this.size[1] * this.alignPosition;
1035
- const o = this.lyricLinesEl[l];
1197
+ s -= l, s += this.size[1] * this.alignPosition;
1198
+ const o = this.lyricLinesEl[r];
1036
1199
  if (o) {
1037
- const m = this.lyricLinesSize.get(o)?.[1] ?? 0;
1200
+ const p = this.lyricLinesSize.get(o)?.[1] ?? 0;
1038
1201
  switch (this.alignAnchor) {
1039
1202
  case "bottom":
1040
- i -= m;
1203
+ s -= p;
1041
1204
  break;
1042
1205
  case "center":
1043
- i -= m / 2;
1206
+ s -= p / 2;
1044
1207
  break;
1045
1208
  }
1046
1209
  }
1047
1210
  const c = Math.max(...this.bufferedLines);
1048
- let d = 0, u = 0.05, f = !1;
1049
- this.lyricLinesEl.forEach((m, p) => {
1050
- const L = this.bufferedLines.has(p), b = L || p >= this.scrollToIndex && p < c, P = m.getLine();
1051
- P.isDuet && this.size[0] - (this.lyricLinesSize.get(m)?.[0] ?? 0), !f && s >= 5e3 && (p === this.scrollToIndex && n?.[2] === -2 || p === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(32, i), n && this.interludeDots.setInterlude([n[0], n[1]]), i += this.interludeDotsSize[1]), m.setTransform(
1052
- 0,
1053
- i,
1054
- b ? 1 : r,
1055
- L ? 1 : 1 / 3,
1056
- !this.invokedByScrollEvent && this.enableBlur ? b ? 0 : 1 + (p < this.scrollToIndex ? Math.abs(this.scrollToIndex - p) : Math.abs(p - Math.max(this.scrollToIndex, c))) : 0,
1211
+ let m = 0, u = 0.05, f = !1;
1212
+ this.lyricLinesEl.forEach((p, d) => {
1213
+ const g = this.bufferedLines.has(d), b = g || d >= this.scrollToIndex && d < c, P = p.getLine();
1214
+ P.isDuet && this.size[0] - (this.lyricLinesSize.get(p)?.[0] ?? 0), !f && n >= 5e3 && (d === this.scrollToIndex && i?.[2] === -2 || d === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(this.padding, s), i && this.interludeDots.setInterlude([i[0], i[1]]), s += this.interludeDotsSize[1]);
1215
+ const C = this.hidePassedLines && d < (i ? i[2] + 1 : this.scrollToIndex) ? 0 : g ? 1 : 1 / 3;
1216
+ p.setTransform(
1217
+ this.padding,
1218
+ s,
1219
+ b ? 1 : a,
1220
+ C,
1221
+ !this.invokedByScrollEvent && this.enableBlur ? b ? 0 : 1 + (d < this.scrollToIndex ? Math.abs(this.scrollToIndex - d) : Math.abs(d - Math.max(this.scrollToIndex, c))) : 0,
1057
1222
  e,
1058
- d
1059
- ), P.isBG && b ? i += this.lyricLinesSize.get(m)?.[1] ?? 0 : P.isBG || (i += this.lyricLinesSize.get(m)?.[1] ?? 0), i >= 0 && (d += u, u /= 1.2);
1060
- }), this.bottomLine.setTransform(0, i, e, d);
1223
+ m
1224
+ ), P.isBG && b ? s += this.lyricLinesSize.get(p)?.[1] ?? 0 : P.isBG || (s += this.lyricLinesSize.get(p)?.[1] ?? 0), s >= 0 && (m += u, u /= 1.2);
1225
+ }), this.bottomLine.setTransform(this.padding, s, e, m);
1061
1226
  }
1062
1227
  /**
1063
1228
  * 获取当前歌词的播放位置
@@ -1120,35 +1285,35 @@ class ie extends EventTarget {
1120
1285
  setCurrentTime(e, t = !1) {
1121
1286
  if (this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`), this.isScrolled)
1122
1287
  return;
1123
- const n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
1124
- this.hotLines.forEach((s) => {
1125
- const r = this.processedLines[s];
1126
- if (r) {
1127
- if (r.isBG)
1288
+ const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
1289
+ this.hotLines.forEach((n) => {
1290
+ const a = this.processedLines[n];
1291
+ if (a) {
1292
+ if (a.isBG)
1128
1293
  return;
1129
- const a = this.processedLines[s + 1];
1130
- if (a?.isBG) {
1131
- const o = Math.min(r.startTime, a?.startTime), c = Math.max(r.endTime, a?.endTime);
1132
- (o > e || c <= e) && (this.hotLines.delete(s), n.add(s), this.hotLines.delete(s + 1), n.add(s + 1), t && (this.lyricLinesEl[s].disable(), this.lyricLinesEl[s + 1].disable()));
1294
+ const l = this.processedLines[n + 1];
1295
+ if (l?.isBG) {
1296
+ const o = Math.min(a.startTime, l?.startTime), c = Math.max(a.endTime, l?.endTime);
1297
+ (o > e || c <= e) && (this.hotLines.delete(n), i.add(n), this.hotLines.delete(n + 1), i.add(n + 1), t && (this.lyricLinesEl[n].disable(), this.lyricLinesEl[n + 1].disable()));
1133
1298
  } else
1134
- (r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable());
1299
+ (a.startTime > e || a.endTime <= e) && (this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable());
1135
1300
  } else
1136
- this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable();
1137
- }), this.processedLines.forEach((s, r, a) => {
1138
- !s.isBG && s.startTime <= e && s.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), l.add(r), t && this.lyricLinesEl[r].enable(), a[r + 1]?.isBG && (this.hotLines.add(r + 1), l.add(r + 1), t && this.lyricLinesEl[r + 1].enable())));
1139
- }), this.bufferedLines.forEach((s) => {
1140
- this.hotLines.has(s) || (i.add(s), t && this.lyricLinesEl[s].disable());
1301
+ this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable();
1302
+ }), this.processedLines.forEach((n, a, l) => {
1303
+ !n.isBG && n.startTime <= e && n.endTime > e && (this.hotLines.has(a) || (this.hotLines.add(a), r.add(a), t && this.lyricLinesEl[a].enable(), l[a + 1]?.isBG && (this.hotLines.add(a + 1), r.add(a + 1), t && this.lyricLinesEl[a + 1].enable())));
1304
+ }), this.bufferedLines.forEach((n) => {
1305
+ this.hotLines.has(n) || (s.add(n), t && this.lyricLinesEl[n].disable());
1141
1306
  }), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
1142
- (s) => s.startTime >= e
1143
- ), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (i.size > 0 || l.size > 0) && (i.size === 0 && l.size > 0 ? (l.forEach((s) => {
1144
- this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
1145
- }), this.scrollToIndex = Math.min(...this.bufferedLines)) : l.size === 0 && i.size > 0 ? O(i, this.bufferedLines) && this.bufferedLines.forEach((s) => {
1146
- this.hotLines.has(s) || (this.bufferedLines.delete(s), this.lyricLinesEl[s].disable());
1147
- }) : (l.forEach((s) => {
1148
- this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
1149
- }), i.forEach((s) => {
1150
- this.bufferedLines.delete(s), this.lyricLinesEl[s].disable();
1151
- }), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines))), this.calcLayout());
1307
+ (n) => n.startTime >= e
1308
+ ), this.bufferedLines.clear(), this.hotLines.forEach((n) => this.bufferedLines.add(n)), this.calcLayout(!0)) : (s.size > 0 || r.size > 0) && (s.size === 0 && r.size > 0 ? (r.forEach((n) => {
1309
+ this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
1310
+ }), this.scrollToIndex = Math.min(...this.bufferedLines), this.calcLayout()) : r.size === 0 && s.size > 0 ? N(s, this.bufferedLines) && (this.bufferedLines.forEach((n) => {
1311
+ this.hotLines.has(n) || (this.bufferedLines.delete(n), this.lyricLinesEl[n].disable());
1312
+ }), this.calcLayout()) : (r.forEach((n) => {
1313
+ this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
1314
+ }), s.forEach((n) => {
1315
+ this.bufferedLines.delete(n), this.lyricLinesEl[n].disable();
1316
+ }), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines)), this.calcLayout()));
1152
1317
  }
1153
1318
  /**
1154
1319
  * 更新动画,这个函数应该被逐帧调用或者在以下情况下调用一次:
@@ -1158,7 +1323,7 @@ class ie extends EventTarget {
1158
1323
  */
1159
1324
  update(e = 0) {
1160
1325
  const t = e / 1e3;
1161
- this.interludeDots.update(e), this.bottomLine.update(t), this.lyricLinesEl.forEach((n) => n.update(t));
1326
+ this.interludeDots.update(e), this.bottomLine.update(t), this.lyricLinesEl.forEach((i) => i.update(t));
1162
1327
  }
1163
1328
  /**
1164
1329
  * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
@@ -1204,8 +1369,8 @@ class ie extends EventTarget {
1204
1369
  }
1205
1370
  }
1206
1371
  export {
1207
- te as BackgroundRender,
1208
- ie as LyricPlayer,
1209
- ee as ttml
1372
+ oe as BackgroundRender,
1373
+ le as LyricPlayer,
1374
+ ae as ttml
1210
1375
  };
1211
1376
  //# sourceMappingURL=amll-core.mjs.map