@applemusic-like-lyrics/core 0.0.11 → 0.0.12

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.
@@ -5,7 +5,28 @@
5
5
  */
6
6
  import type { Disposable, HasElement, LyricLine } from "../interfaces";
7
7
  import { SpringParams } from "../utils/spring";
8
- export declare class LyricLineClickedEvent extends MouseEvent {
8
+ import { LyricLineEl } from "./lyric-line";
9
+ /**
10
+ * 歌词行鼠标相关事件,可以获取到歌词行的索引和歌词行元素
11
+ */
12
+ export declare class LyricLineMouseEvent extends MouseEvent {
13
+ /**
14
+ * 歌词行索引
15
+ */
16
+ readonly lineIndex: number;
17
+ /**
18
+ * 歌词行元素
19
+ */
20
+ readonly line: LyricLineEl;
21
+ constructor(
22
+ /**
23
+ * 歌词行索引
24
+ */
25
+ lineIndex: number,
26
+ /**
27
+ * 歌词行元素
28
+ */
29
+ line: LyricLineEl, event: MouseEvent);
9
30
  }
10
31
  /**
11
32
  * 歌词播放组件,本框架的核心组件
@@ -19,6 +40,7 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
19
40
  private processedLines;
20
41
  private lyricLinesEl;
21
42
  private lyricLinesSize;
43
+ private lyricLinesIndexes;
22
44
  private hotLines;
23
45
  private bufferedLines;
24
46
  private scrollToIndex;
@@ -26,12 +48,15 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
26
48
  private scrolledHandler;
27
49
  private isScrolled;
28
50
  private invokedByScrollEvent;
51
+ private padding;
29
52
  private scrollOffset;
53
+ private hidePassedLines;
30
54
  private resizeObserver;
31
55
  private posXSpringParams;
32
56
  private posYSpringParams;
33
57
  private scaleSpringParams;
34
58
  private enableBlur;
59
+ private enableScale;
35
60
  private interludeDots;
36
61
  private interludeDotsSize;
37
62
  private bottomLine;
@@ -43,7 +68,7 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
43
68
  private isNonDynamic;
44
69
  readonly size: [number, number];
45
70
  readonly innerSize: [number, number];
46
- readonly pos: [number, number];
71
+ private readonly onLineClickedHandler;
47
72
  _getIsNonDynamic(): boolean;
48
73
  /**
49
74
  * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
@@ -58,6 +83,20 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
58
83
  * @returns 是否启用物理弹簧
59
84
  */
60
85
  getEnableSpring(): boolean;
86
+ /**
87
+ * 是否启用歌词行缩放效果,默认启用
88
+ *
89
+ * 如果启用,非选中的歌词行会轻微缩小以凸显当前播放歌词行效果
90
+ *
91
+ * 此效果对性能影响微乎其微,推荐启用
92
+ * @param enable 是否启用歌词行缩放效果
93
+ */
94
+ setEnableScale(enable?: boolean): void;
95
+ /**
96
+ * 获取当前是否启用了歌词行缩放效果
97
+ * @returns 是否启用歌词行缩放效果
98
+ */
99
+ getEnableScale(): boolean;
61
100
  readonly style: import("jss").StyleSheet<"lyricPlayer" | "lyricLine" | "@media (max-width: 1024px)" | "lyricDuetLine" | "lyricBgLine" | "lyricMainLine" | "lyricSubLine" | "disableSpring" | "interludeDots" | "@supports (mix-blend-mode: plus-lighter)" | "tmpDisableTransition">;
62
101
  private onPageShow;
63
102
  constructor();
@@ -76,6 +115,11 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
76
115
  * 这个只允许内部调用
77
116
  */
78
117
  rebuildStyle(): void;
118
+ /**
119
+ * 设置是否隐藏已经播放过的歌词行,默认不隐藏
120
+ * @param hide 是否隐藏已经播放过的歌词行,默认不隐藏
121
+ */
122
+ setHidePassedLines(hide: boolean): void;
79
123
  /**
80
124
  * 设置是否启用歌词行的模糊效果
81
125
  * @param enable 是否启用
@@ -86,6 +130,12 @@ export declare class LyricPlayer extends EventTarget implements HasElement, Disp
86
130
  * @param lines 歌词数组
87
131
  */
88
132
  setLyricLines(lines: LyricLine[]): void;
133
+ /**
134
+ * 重置用户滚动状态
135
+ *
136
+ * 请在用户完成滚动点击跳转歌词时调用本事件再调用 `calcLayout` 以正确滚动到目标位置
137
+ */
138
+ resetScroll(): void;
89
139
  /**
90
140
  * 重新布局定位歌词行的位置,调用完成后再逐帧调用 `update`
91
141
  * 函数即可让歌词通过动画移动到目标位置。
@@ -2,7 +2,16 @@ import { LyricPlayer } from ".";
2
2
  import { Disposable, HasElement, LyricLine, LyricWord } from "../interfaces";
3
3
  import { Spring } from "../utils/spring";
4
4
  export declare function shouldEmphasize(word: LyricWord): boolean;
5
- export declare class LyricLineEl implements HasElement, Disposable {
5
+ export declare class RawLyricLineMouseEvent extends MouseEvent {
6
+ readonly line: LyricLineEl;
7
+ constructor(line: LyricLineEl, event: MouseEvent);
8
+ }
9
+ type MouseEventMap = {
10
+ [evt in keyof HTMLElementEventMap]: HTMLElementEventMap[evt] extends MouseEvent ? evt : never;
11
+ };
12
+ type MouseEventTypes = MouseEventMap[keyof MouseEventMap];
13
+ type MouseEventListener = (this: LyricLineEl, ev: RawLyricLineMouseEvent) => void;
14
+ export declare class LyricLineEl extends EventTarget implements HasElement, Disposable {
6
15
  private lyricPlayer;
7
16
  private lyricLine;
8
17
  private element;
@@ -19,6 +28,10 @@ export declare class LyricLineEl implements HasElement, Disposable {
19
28
  scale: Spring;
20
29
  };
21
30
  constructor(lyricPlayer: LyricPlayer, lyricLine?: LyricLine);
31
+ private listenersMap;
32
+ private readonly onMouseEvent;
33
+ addEventListener(type: MouseEventTypes, callback: MouseEventListener | null, options?: boolean | AddEventListenerOptions | undefined): void;
34
+ removeEventListener(type: MouseEventTypes, callback: MouseEventListener | null, options?: boolean | EventListenerOptions | undefined): void;
22
35
  private isEnabled;
23
36
  enable(): void;
24
37
  measureSize(): [number, number];
@@ -40,3 +53,4 @@ export declare class LyricLineEl implements HasElement, Disposable {
40
53
  get isInSight(): boolean;
41
54
  dispose(): void;
42
55
  }
56
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@applemusic-like-lyrics/core",
3
3
  "packageManager": "yarn@3.6.1",
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "description": "AMLL 的纯 JS 核心组件框架,包括歌词显示组件和背景组件等其它可以复用的组件",
6
6
  "repository": {
7
7
  "url": "https://github.com/Steve-xmh/applemusic-like-lyrics.git",
@@ -15,6 +15,7 @@
15
15
  "scripts": {
16
16
  "build:docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts",
17
17
  "build": "vite build",
18
+ "build:dev": "vite build",
18
19
  "fmt": "rome format --write ./src",
19
20
  "dev": "vite dev"
20
21
  },
@@ -34,11 +35,11 @@
34
35
  "lil-gui": "^0.18.2",
35
36
  "rome": "^12.1.3",
36
37
  "stats.js": "^0.17.0",
37
- "typedoc": "^0.24.8",
38
- "typedoc-plugin-markdown": "^3.15.3",
39
- "typescript": "^5.1.6",
40
- "vite": "^4.4.7",
41
- "vite-plugin-dts": "^3.3.1",
38
+ "typedoc": "^0.25.2",
39
+ "typedoc-plugin-markdown": "^3.16.0",
40
+ "typescript": "^5.2.2",
41
+ "vite": "^4.4.11",
42
+ "vite-plugin-dts": "^3.6.0",
42
43
  "vite-plugin-top-level-await": "^1.3.1",
43
44
  "vite-plugin-wasm": "^3.2.2"
44
45
  },
@@ -47,9 +48,13 @@
47
48
  "@pixi/core": "*",
48
49
  "@pixi/display": "*",
49
50
  "@pixi/filter-blur": "*",
51
+ "@pixi/filter-bulge-pinch": "*",
50
52
  "@pixi/filter-color-matrix": "*",
51
53
  "@pixi/sprite": "*",
52
54
  "jss": "*",
53
55
  "jss-preset-default": "*"
56
+ },
57
+ "dependencies": {
58
+ "node-vibrant": "^3.2.1-alpha.1"
54
59
  }
55
60
  }