@dudgy/podcast-widget 0.1.1 → 0.3.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/dist/index.d.cts CHANGED
@@ -25,9 +25,19 @@ interface Episode {
25
25
  feedImage?: string;
26
26
  artwork?: string;
27
27
  }
28
- /** Persisted player state (current episode + volume). */
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
- currentEpisodeIndex: number;
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
- cleanupPositions(currentEpisodeIds: string[]): void;
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 index, volume)
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;
@@ -175,6 +193,7 @@ interface ControlsConfig {
175
193
  progress?: boolean;
176
194
  playlist?: boolean;
177
195
  expand?: boolean;
196
+ download?: boolean;
178
197
  }
179
198
  /**
180
199
  * The core player controller. Manages the relationship between
@@ -191,6 +210,9 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
191
210
  readonly config: ResolvedConfig;
192
211
  private provider;
193
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. */
194
216
  private currentIndex;
195
217
  private saveInterval;
196
218
  private cleanupFns;
@@ -198,13 +220,16 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
198
220
  loadEpisodes(): Promise<Episode[]>;
199
221
  getEpisodes(): Episode[];
200
222
  getCurrentEpisode(): Episode | null;
223
+ /** Index of the current episode in the list, or -1 if none or not listed. */
201
224
  getCurrentIndex(): number;
202
225
  loadEpisode(index: number, autoPlay?: boolean): void;
226
+ private select;
203
227
  playEpisode(index: number): void;
204
228
  play(): Promise<void>;
205
229
  pause(): void;
206
230
  setSpeed(speed: number): void;
207
231
  setVolume(v: number): void;
232
+ private persistState;
208
233
  getPlaylistHtml(feedPageUrl?: (feedId: number) => string): string;
209
234
  private startPositionSaving;
210
235
  private stopPositionSaving;
@@ -288,10 +313,12 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
288
313
  private render;
289
314
  private bindEvents;
290
315
  private updateDisplay;
316
+ private setHeroBackground;
291
317
  private updatePlayPauseState;
292
318
  private refreshPlaylist;
293
319
  private bindPlaylistClicks;
294
320
  private updatePlaylistHighlight;
321
+ private downloadCurrentEpisode;
295
322
  private addClick;
296
323
  private addInput;
297
324
  private addChange;
@@ -309,6 +336,8 @@ declare const ICONS: {
309
336
  volume: string;
310
337
  info: string;
311
338
  playlist: string;
339
+ note: string;
340
+ download: string;
312
341
  };
313
342
  /** Speed options for the speed select dropdown. */
314
343
  declare const SPEED_OPTIONS: number[];
@@ -339,4 +368,4 @@ declare function getEpisodeImage(episode: {
339
368
  artwork?: string;
340
369
  }): string;
341
370
 
342
- 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
- /** Persisted player state (current episode + volume). */
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
- currentEpisodeIndex: number;
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
- cleanupPositions(currentEpisodeIds: string[]): void;
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 index, volume)
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;
@@ -175,6 +193,7 @@ interface ControlsConfig {
175
193
  progress?: boolean;
176
194
  playlist?: boolean;
177
195
  expand?: boolean;
196
+ download?: boolean;
178
197
  }
179
198
  /**
180
199
  * The core player controller. Manages the relationship between
@@ -191,6 +210,9 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
191
210
  readonly config: ResolvedConfig;
192
211
  private provider;
193
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. */
194
216
  private currentIndex;
195
217
  private saveInterval;
196
218
  private cleanupFns;
@@ -198,13 +220,16 @@ declare class PlayerController extends EventEmitter<PlayerEventMap> {
198
220
  loadEpisodes(): Promise<Episode[]>;
199
221
  getEpisodes(): Episode[];
200
222
  getCurrentEpisode(): Episode | null;
223
+ /** Index of the current episode in the list, or -1 if none or not listed. */
201
224
  getCurrentIndex(): number;
202
225
  loadEpisode(index: number, autoPlay?: boolean): void;
226
+ private select;
203
227
  playEpisode(index: number): void;
204
228
  play(): Promise<void>;
205
229
  pause(): void;
206
230
  setSpeed(speed: number): void;
207
231
  setVolume(v: number): void;
232
+ private persistState;
208
233
  getPlaylistHtml(feedPageUrl?: (feedId: number) => string): string;
209
234
  private startPositionSaving;
210
235
  private stopPositionSaving;
@@ -288,10 +313,12 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
288
313
  private render;
289
314
  private bindEvents;
290
315
  private updateDisplay;
316
+ private setHeroBackground;
291
317
  private updatePlayPauseState;
292
318
  private refreshPlaylist;
293
319
  private bindPlaylistClicks;
294
320
  private updatePlaylistHighlight;
321
+ private downloadCurrentEpisode;
295
322
  private addClick;
296
323
  private addInput;
297
324
  private addChange;
@@ -309,6 +336,8 @@ declare const ICONS: {
309
336
  volume: string;
310
337
  info: string;
311
338
  playlist: string;
339
+ note: string;
340
+ download: string;
312
341
  };
313
342
  /** Speed options for the speed select dropdown. */
314
343
  declare const SPEED_OPTIONS: number[];
@@ -339,4 +368,4 @@ declare function getEpisodeImage(episode: {
339
368
  artwork?: string;
340
369
  }): string;
341
370
 
342
- 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 };