@dudgy/podcast-widget 0.2.0 → 0.3.1
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 +28 -3
- package/dist/index.cjs +189 -103
- package/dist/index.d.cts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +158 -72
- package/dist/podcast-player.css +138 -36
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -25,9 +25,19 @@ interface Episode {
|
|
|
25
25
|
feedImage?: string;
|
|
26
26
|
artwork?: string;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/** Current version of the persisted {@link PlayerState} format. */
|
|
29
|
+
declare const PLAYER_STATE_VERSION = 2;
|
|
30
|
+
/**
|
|
31
|
+
* Persisted player state (current episode + volume).
|
|
32
|
+
*
|
|
33
|
+
* The current episode is stored as a full snapshot, not a reference into the
|
|
34
|
+
* episode list: the list reorders and drops episodes as feeds publish, but the
|
|
35
|
+
* player should still restore what the listener had loaded.
|
|
36
|
+
*/
|
|
29
37
|
interface PlayerState {
|
|
30
|
-
|
|
38
|
+
v: typeof PLAYER_STATE_VERSION;
|
|
39
|
+
/** Snapshot of the loaded episode, or null if none. */
|
|
40
|
+
episode: Episode | null;
|
|
31
41
|
volume: number;
|
|
32
42
|
}
|
|
33
43
|
/** Configuration for the player and its sub-modules. */
|
|
@@ -134,11 +144,12 @@ declare class PlaybackStorage {
|
|
|
134
144
|
savePosition(episodeId: string, position: number, duration?: number): void;
|
|
135
145
|
getPosition(episodeId: string): number | null;
|
|
136
146
|
removePosition(episodeId: string): void;
|
|
137
|
-
|
|
147
|
+
/** Remove saved positions for episodes whose IDs aren't in `keepIds`. */
|
|
148
|
+
cleanupPositions(keepIds: string[]): void;
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
/**
|
|
141
|
-
* Manages localStorage for player-level state (current episode
|
|
152
|
+
* Manages localStorage for player-level state (current episode, volume)
|
|
142
153
|
* and playback speed preference.
|
|
143
154
|
*/
|
|
144
155
|
declare class PlayerStateStorage {
|
|
@@ -146,6 +157,13 @@ declare class PlayerStateStorage {
|
|
|
146
157
|
private speedKey;
|
|
147
158
|
constructor(config: ResolvedConfig);
|
|
148
159
|
saveState(state: PlayerState): void;
|
|
160
|
+
/**
|
|
161
|
+
* Load saved state, migrating older formats. Returns null if nothing usable
|
|
162
|
+
* is saved.
|
|
163
|
+
*
|
|
164
|
+
* Unversioned (v1) state stored only an index into the episode list, which
|
|
165
|
+
* can't be trusted once the list changes, so only its volume is kept.
|
|
166
|
+
*/
|
|
149
167
|
loadState(): PlayerState | null;
|
|
150
168
|
saveSpeed(speed: number): void;
|
|
151
169
|
loadSpeed(): number | null;
|
|
@@ -192,6 +210,9 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
|
|
|
192
210
|
readonly config: ResolvedConfig;
|
|
193
211
|
private provider;
|
|
194
212
|
private episodes;
|
|
213
|
+
/** The loaded episode. May not be in `episodes` (e.g. restored after its feed moved on). */
|
|
214
|
+
private currentEpisode;
|
|
215
|
+
/** Index of `currentEpisode` in `episodes`, or -1 if it isn't in the list. */
|
|
195
216
|
private currentIndex;
|
|
196
217
|
private saveInterval;
|
|
197
218
|
private cleanupFns;
|
|
@@ -199,13 +220,16 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
|
|
|
199
220
|
loadEpisodes(): Promise<Episode[]>;
|
|
200
221
|
getEpisodes(): Episode[];
|
|
201
222
|
getCurrentEpisode(): Episode | null;
|
|
223
|
+
/** Index of the current episode in the list, or -1 if none or not listed. */
|
|
202
224
|
getCurrentIndex(): number;
|
|
203
225
|
loadEpisode(index: number, autoPlay?: boolean): void;
|
|
226
|
+
private select;
|
|
204
227
|
playEpisode(index: number): void;
|
|
205
228
|
play(): Promise<void>;
|
|
206
229
|
pause(): void;
|
|
207
230
|
setSpeed(speed: number): void;
|
|
208
231
|
setVolume(v: number): void;
|
|
232
|
+
private persistState;
|
|
209
233
|
getPlaylistHtml(feedPageUrl?: (feedId: number) => string): string;
|
|
210
234
|
private startPositionSaving;
|
|
211
235
|
private stopPositionSaving;
|
|
@@ -289,6 +313,7 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
|
|
|
289
313
|
private render;
|
|
290
314
|
private bindEvents;
|
|
291
315
|
private updateDisplay;
|
|
316
|
+
private setHeroBackground;
|
|
292
317
|
private updatePlayPauseState;
|
|
293
318
|
private refreshPlaylist;
|
|
294
319
|
private bindPlaylistClicks;
|
|
@@ -311,6 +336,7 @@ declare const ICONS: {
|
|
|
311
336
|
volume: string;
|
|
312
337
|
info: string;
|
|
313
338
|
playlist: string;
|
|
339
|
+
note: string;
|
|
314
340
|
download: string;
|
|
315
341
|
};
|
|
316
342
|
/** Speed options for the speed select dropdown. */
|
|
@@ -342,4 +368,4 @@ declare function getEpisodeImage(episode: {
|
|
|
342
368
|
artwork?: string;
|
|
343
369
|
}): string;
|
|
344
370
|
|
|
345
|
-
export { AudioEngine, type AudioEventMap, type ControlsConfig, DEFAULT_CONFIG, type Episode, type EpisodeProvider, EventEmitter, FetchEpisodeProvider, FullPlayer, type FullPlayerOptions, ICONS, MiniPlayer, type MiniPlayerOptions, PlaybackStorage, type PlayerConfig, PlayerController, type PlayerEventMap, type PlayerState, PlayerStateStorage, type ResolvedConfig, SPEED_OPTIONS, escapeHtml, formatDate, formatDuration, formatTime, getEpisodeImage, renderPlaylist, renderPlaylistItem, resolveConfig };
|
|
371
|
+
export { AudioEngine, type AudioEventMap, type ControlsConfig, DEFAULT_CONFIG, type Episode, type EpisodeProvider, EventEmitter, FetchEpisodeProvider, FullPlayer, type FullPlayerOptions, ICONS, MiniPlayer, type MiniPlayerOptions, PLAYER_STATE_VERSION, PlaybackStorage, type PlayerConfig, PlayerController, type PlayerEventMap, type PlayerState, PlayerStateStorage, type ResolvedConfig, SPEED_OPTIONS, escapeHtml, formatDate, formatDuration, formatTime, getEpisodeImage, renderPlaylist, renderPlaylistItem, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,9 +25,19 @@ interface Episode {
|
|
|
25
25
|
feedImage?: string;
|
|
26
26
|
artwork?: string;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/** Current version of the persisted {@link PlayerState} format. */
|
|
29
|
+
declare const PLAYER_STATE_VERSION = 2;
|
|
30
|
+
/**
|
|
31
|
+
* Persisted player state (current episode + volume).
|
|
32
|
+
*
|
|
33
|
+
* The current episode is stored as a full snapshot, not a reference into the
|
|
34
|
+
* episode list: the list reorders and drops episodes as feeds publish, but the
|
|
35
|
+
* player should still restore what the listener had loaded.
|
|
36
|
+
*/
|
|
29
37
|
interface PlayerState {
|
|
30
|
-
|
|
38
|
+
v: typeof PLAYER_STATE_VERSION;
|
|
39
|
+
/** Snapshot of the loaded episode, or null if none. */
|
|
40
|
+
episode: Episode | null;
|
|
31
41
|
volume: number;
|
|
32
42
|
}
|
|
33
43
|
/** Configuration for the player and its sub-modules. */
|
|
@@ -134,11 +144,12 @@ declare class PlaybackStorage {
|
|
|
134
144
|
savePosition(episodeId: string, position: number, duration?: number): void;
|
|
135
145
|
getPosition(episodeId: string): number | null;
|
|
136
146
|
removePosition(episodeId: string): void;
|
|
137
|
-
|
|
147
|
+
/** Remove saved positions for episodes whose IDs aren't in `keepIds`. */
|
|
148
|
+
cleanupPositions(keepIds: string[]): void;
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
/**
|
|
141
|
-
* Manages localStorage for player-level state (current episode
|
|
152
|
+
* Manages localStorage for player-level state (current episode, volume)
|
|
142
153
|
* and playback speed preference.
|
|
143
154
|
*/
|
|
144
155
|
declare class PlayerStateStorage {
|
|
@@ -146,6 +157,13 @@ declare class PlayerStateStorage {
|
|
|
146
157
|
private speedKey;
|
|
147
158
|
constructor(config: ResolvedConfig);
|
|
148
159
|
saveState(state: PlayerState): void;
|
|
160
|
+
/**
|
|
161
|
+
* Load saved state, migrating older formats. Returns null if nothing usable
|
|
162
|
+
* is saved.
|
|
163
|
+
*
|
|
164
|
+
* Unversioned (v1) state stored only an index into the episode list, which
|
|
165
|
+
* can't be trusted once the list changes, so only its volume is kept.
|
|
166
|
+
*/
|
|
149
167
|
loadState(): PlayerState | null;
|
|
150
168
|
saveSpeed(speed: number): void;
|
|
151
169
|
loadSpeed(): number | null;
|
|
@@ -192,6 +210,9 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
|
|
|
192
210
|
readonly config: ResolvedConfig;
|
|
193
211
|
private provider;
|
|
194
212
|
private episodes;
|
|
213
|
+
/** The loaded episode. May not be in `episodes` (e.g. restored after its feed moved on). */
|
|
214
|
+
private currentEpisode;
|
|
215
|
+
/** Index of `currentEpisode` in `episodes`, or -1 if it isn't in the list. */
|
|
195
216
|
private currentIndex;
|
|
196
217
|
private saveInterval;
|
|
197
218
|
private cleanupFns;
|
|
@@ -199,13 +220,16 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
|
|
|
199
220
|
loadEpisodes(): Promise<Episode[]>;
|
|
200
221
|
getEpisodes(): Episode[];
|
|
201
222
|
getCurrentEpisode(): Episode | null;
|
|
223
|
+
/** Index of the current episode in the list, or -1 if none or not listed. */
|
|
202
224
|
getCurrentIndex(): number;
|
|
203
225
|
loadEpisode(index: number, autoPlay?: boolean): void;
|
|
226
|
+
private select;
|
|
204
227
|
playEpisode(index: number): void;
|
|
205
228
|
play(): Promise<void>;
|
|
206
229
|
pause(): void;
|
|
207
230
|
setSpeed(speed: number): void;
|
|
208
231
|
setVolume(v: number): void;
|
|
232
|
+
private persistState;
|
|
209
233
|
getPlaylistHtml(feedPageUrl?: (feedId: number) => string): string;
|
|
210
234
|
private startPositionSaving;
|
|
211
235
|
private stopPositionSaving;
|
|
@@ -289,6 +313,7 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
|
|
|
289
313
|
private render;
|
|
290
314
|
private bindEvents;
|
|
291
315
|
private updateDisplay;
|
|
316
|
+
private setHeroBackground;
|
|
292
317
|
private updatePlayPauseState;
|
|
293
318
|
private refreshPlaylist;
|
|
294
319
|
private bindPlaylistClicks;
|
|
@@ -311,6 +336,7 @@ declare const ICONS: {
|
|
|
311
336
|
volume: string;
|
|
312
337
|
info: string;
|
|
313
338
|
playlist: string;
|
|
339
|
+
note: string;
|
|
314
340
|
download: string;
|
|
315
341
|
};
|
|
316
342
|
/** Speed options for the speed select dropdown. */
|
|
@@ -342,4 +368,4 @@ declare function getEpisodeImage(episode: {
|
|
|
342
368
|
artwork?: string;
|
|
343
369
|
}): string;
|
|
344
370
|
|
|
345
|
-
export { AudioEngine, type AudioEventMap, type ControlsConfig, DEFAULT_CONFIG, type Episode, type EpisodeProvider, EventEmitter, FetchEpisodeProvider, FullPlayer, type FullPlayerOptions, ICONS, MiniPlayer, type MiniPlayerOptions, PlaybackStorage, type PlayerConfig, PlayerController, type PlayerEventMap, type PlayerState, PlayerStateStorage, type ResolvedConfig, SPEED_OPTIONS, escapeHtml, formatDate, formatDuration, formatTime, getEpisodeImage, renderPlaylist, renderPlaylistItem, resolveConfig };
|
|
371
|
+
export { AudioEngine, type AudioEventMap, type ControlsConfig, DEFAULT_CONFIG, type Episode, type EpisodeProvider, EventEmitter, FetchEpisodeProvider, FullPlayer, type FullPlayerOptions, ICONS, MiniPlayer, type MiniPlayerOptions, PLAYER_STATE_VERSION, PlaybackStorage, type PlayerConfig, PlayerController, type PlayerEventMap, type PlayerState, PlayerStateStorage, type ResolvedConfig, SPEED_OPTIONS, escapeHtml, formatDate, formatDuration, formatTime, getEpisodeImage, renderPlaylist, renderPlaylistItem, resolveConfig };
|