@music-lyric-player/base 0.9.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.comm.js +1 -1
- package/dist/index.comm.js.map +1 -1
- package/dist/index.ecma.d.ts +106 -14
- package/dist/index.ecma.js +1308 -63
- package/dist/index.ecma.js.map +1 -1
- package/package.json +7 -3
package/dist/index.ecma.d.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { ConfigManager } from '@music-lyric-player/utils';
|
|
2
|
+
import { DeepRequired } from '@music-lyric-player/utils';
|
|
2
3
|
import { Event as Event_2 } from '@music-lyric-player/utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { Lyric } from '@music-lyric-kit/lyric';
|
|
5
|
+
import { NestedKeys } from '@music-lyric-player/utils';
|
|
5
6
|
|
|
6
7
|
export declare class BaseLyricPlayer {
|
|
7
|
-
readonly config:
|
|
8
|
-
driver?: "timer" | "animation" | undefined;
|
|
9
|
-
}, "driver">;
|
|
8
|
+
readonly config: BaseLyricPlayerConfig.RootManager;
|
|
10
9
|
readonly event: Event_2<BaseLyricPlayerEventMap>;
|
|
11
10
|
private state;
|
|
12
11
|
private active;
|
|
13
12
|
private time;
|
|
13
|
+
private offset;
|
|
14
14
|
private info;
|
|
15
15
|
constructor();
|
|
16
|
+
private onConfigUpdate;
|
|
16
17
|
private handleGetCurrentTime;
|
|
18
|
+
private handleGetEffectiveTime;
|
|
19
|
+
private handleRefreshOffset;
|
|
17
20
|
private handleGetLineTime;
|
|
18
21
|
private handleGetActiveIndex;
|
|
22
|
+
private handleBridgeActive;
|
|
23
|
+
private handleEmitLinesUpdate;
|
|
19
24
|
private handleSyncTime;
|
|
20
25
|
private handleUpdateActiveLines;
|
|
21
26
|
private onTick;
|
|
22
|
-
updateLyric(info: Info): void;
|
|
27
|
+
updateLyric(info: Lyric.Info): void;
|
|
23
28
|
/**
|
|
24
29
|
* Start playback
|
|
25
30
|
* @param time Optional time in ms to seek to before starting playback. If not provided, playback will start from the current position.
|
|
@@ -33,14 +38,27 @@ export declare class BaseLyricPlayer {
|
|
|
33
38
|
* Stop playback
|
|
34
39
|
*/
|
|
35
40
|
dispose(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Update the temp offset in ms (the user's temporary adjustment).
|
|
43
|
+
* Stacked on top of the global config offset and the lyric's meta offset, then resyncs immediately.
|
|
44
|
+
* @param value temp offset in ms; non-finite values are treated as 0.
|
|
45
|
+
*/
|
|
46
|
+
updateTempOffset(value: number): void;
|
|
36
47
|
/**
|
|
37
48
|
* Find all active lines at the given time (ms). Does not mutate internal state.
|
|
49
|
+
* Assumes `info.lines` is sorted by `time.start` ascending.
|
|
38
50
|
* @param time time in ms to find active lines for.
|
|
39
51
|
*/
|
|
40
52
|
matchLinesWithTime(time: number): {
|
|
41
|
-
lines: Line[];
|
|
53
|
+
lines: Lyric.Line[];
|
|
42
54
|
index: number[];
|
|
43
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Convert a content (lyric) time to the playback clock by removing the active offset.
|
|
58
|
+
* Seeking playback to the returned time makes a line at `contentTime` become active.
|
|
59
|
+
* @param contentTime content time in ms (e.g. a line's start).
|
|
60
|
+
*/
|
|
61
|
+
convertContentTime(contentTime: number): number;
|
|
44
62
|
/**
|
|
45
63
|
* Whether the player is currently playing.
|
|
46
64
|
*/
|
|
@@ -48,7 +66,7 @@ export declare class BaseLyricPlayer {
|
|
|
48
66
|
/**
|
|
49
67
|
* Current active lines.
|
|
50
68
|
*/
|
|
51
|
-
get currentLines(): Line[];
|
|
69
|
+
get currentLines(): Lyric.Line[];
|
|
52
70
|
/**
|
|
53
71
|
* Indices of currently active lines.
|
|
54
72
|
*/
|
|
@@ -60,11 +78,27 @@ export declare class BaseLyricPlayer {
|
|
|
60
78
|
/**
|
|
61
79
|
* The current lyric info object.
|
|
62
80
|
*/
|
|
63
|
-
get currentInfo(): Info;
|
|
81
|
+
get currentInfo(): Lyric.Info;
|
|
64
82
|
/**
|
|
65
83
|
* The current playback time in ms.
|
|
66
84
|
*/
|
|
67
85
|
get currentTime(): number;
|
|
86
|
+
/**
|
|
87
|
+
* The current effective lyric offset in ms (config offset + lyric meta offset + temp offset).
|
|
88
|
+
*/
|
|
89
|
+
get currentOffset(): number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export declare namespace BaseLyricPlayerConfig {
|
|
93
|
+
export {
|
|
94
|
+
Offset,
|
|
95
|
+
Root,
|
|
96
|
+
RootRequired,
|
|
97
|
+
RootKeys,
|
|
98
|
+
RootKeySet,
|
|
99
|
+
RootManager,
|
|
100
|
+
DEFAULT
|
|
101
|
+
}
|
|
68
102
|
}
|
|
69
103
|
|
|
70
104
|
export declare interface BaseLyricPlayerEventMap {
|
|
@@ -82,7 +116,7 @@ export declare interface BaseLyricPlayerEventMap {
|
|
|
82
116
|
* When the entire lyric information is updated (e.g., loading a new lyric/song).
|
|
83
117
|
* @param info The newly loaded lyric information object.
|
|
84
118
|
*/
|
|
85
|
-
lyricUpdate: (info: Info) => void;
|
|
119
|
+
lyricUpdate: (info: Lyric.Info) => void;
|
|
86
120
|
/**
|
|
87
121
|
* When the currently active lyric lines change during playback.
|
|
88
122
|
* @param lines An array of the currently active lyric lines.
|
|
@@ -90,17 +124,75 @@ export declare interface BaseLyricPlayerEventMap {
|
|
|
90
124
|
* @param firstIndex The index of the first currently active lyric line (-1 if none).
|
|
91
125
|
* @param isSeek Is seek.
|
|
92
126
|
*/
|
|
93
|
-
linesUpdate: (lines: Line[], indexs: number[], index: number, isSeek: boolean) => void;
|
|
127
|
+
linesUpdate: (lines: Lyric.Line[], indexs: number[], index: number, isSeek: boolean) => void;
|
|
94
128
|
}
|
|
95
129
|
|
|
96
|
-
declare
|
|
130
|
+
declare const DEFAULT: Root;
|
|
131
|
+
|
|
132
|
+
declare interface Offset {
|
|
133
|
+
/**
|
|
134
|
+
* Global offset in ms, applied to every song.
|
|
135
|
+
*
|
|
136
|
+
* @default 0
|
|
137
|
+
*/
|
|
138
|
+
global?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Whether to apply the offset carried by the lyric's own meta (`MetaType.Offset`).
|
|
141
|
+
*
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
useMeta?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Whether loading a new lyric via `updateLyric` resets the temp offset (set via `updateTempOffset`) back to 0.
|
|
147
|
+
*
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
resetTempOnLyricChange?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare interface Root {
|
|
97
154
|
/**
|
|
98
155
|
* Driver type for playback scheduling.
|
|
99
156
|
* - `animation`: use requestAnimationFrame
|
|
100
157
|
* - `timer`: use setTimeout
|
|
101
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* @default 'animation'
|
|
160
|
+
*/
|
|
161
|
+
driver?: 'timer' | 'animation';
|
|
162
|
+
/**
|
|
163
|
+
* Whether to bridge gaps between simultaneously active lines.
|
|
164
|
+
*
|
|
165
|
+
* Active lines may not be consecutive — a line in the middle could have already ended (`played`) while its neighbors are still active, producing a `[active, played, active]` pattern.
|
|
166
|
+
*
|
|
167
|
+
* Enabling this promotes the sandwiched lines back to active so the visual reads as one continuous `[active, active, active]` block.
|
|
168
|
+
*
|
|
169
|
+
* @default true
|
|
102
170
|
*/
|
|
103
|
-
|
|
171
|
+
bridgeActive?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Lyric time offset settings.
|
|
174
|
+
*/
|
|
175
|
+
offset?: Offset;
|
|
104
176
|
}
|
|
105
177
|
|
|
178
|
+
/**
|
|
179
|
+
* All config keys
|
|
180
|
+
*/
|
|
181
|
+
declare type RootKeys = NestedKeys<Root>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Set of config key paths that changed since the previous value, as emitted by `ConfigManager.event['update']`.
|
|
185
|
+
*/
|
|
186
|
+
declare type RootKeySet = Set<RootKeys>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Runtime config manager bound to this module's {@link Config} shape.
|
|
190
|
+
*/
|
|
191
|
+
declare type RootManager = ConfigManager<RootRequired, Root>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Fully‑resolved config in which every field is required, produced by deep‑requiring the user‑facing {@link Config}.
|
|
195
|
+
*/
|
|
196
|
+
declare type RootRequired = DeepRequired<Root>;
|
|
197
|
+
|
|
106
198
|
export { }
|