@dudgy/podcast-widget 0.1.0 → 0.2.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 +3 -2
- package/dist/index.cjs +21 -2
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +21 -2
- package/dist/podcast-player.css +41 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ const mini = new MiniPlayer({
|
|
|
37
37
|
const full = new FullPlayer({
|
|
38
38
|
container: document.getElementById('full-player')!,
|
|
39
39
|
controller,
|
|
40
|
-
controls: { playPause: true, skipForward: true, skipBackward: true, volume: true, speed: true, progress: true, playlist: true },
|
|
40
|
+
controls: { playPause: true, skipForward: true, skipBackward: true, volume: true, speed: true, progress: true, playlist: true, download: true },
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// 3. Wire them together
|
|
@@ -97,6 +97,7 @@ interface ControlsConfig {
|
|
|
97
97
|
progress?: boolean;
|
|
98
98
|
playlist?: boolean; // Inline dropdown playlist (mini) or full playlist (full)
|
|
99
99
|
expand?: boolean; // Button to emit 'expand' event
|
|
100
|
+
download?: boolean; // Download button for current episode
|
|
100
101
|
}
|
|
101
102
|
```
|
|
102
103
|
|
|
@@ -123,7 +124,7 @@ mini.destroy(); // Cleanup when done
|
|
|
123
124
|
|
|
124
125
|
### FullPlayer
|
|
125
126
|
|
|
126
|
-
Modal overlay with hero section (blurred artwork background), controls, and scrollable playlist. Defaults: all controls enabled.
|
|
127
|
+
Modal overlay with hero section (blurred artwork background), controls, and scrollable playlist. Defaults: all controls enabled. Each playlist item includes a download button.
|
|
127
128
|
|
|
128
129
|
```typescript
|
|
129
130
|
const full = new FullPlayer({
|
package/dist/index.cjs
CHANGED
|
@@ -379,7 +379,8 @@ var ICONS = {
|
|
|
379
379
|
close: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
|
|
380
380
|
volume: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',
|
|
381
381
|
info: '<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>',
|
|
382
|
-
playlist: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>'
|
|
382
|
+
playlist: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>',
|
|
383
|
+
download: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>'
|
|
383
384
|
};
|
|
384
385
|
var SPEED_OPTIONS = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
|
|
385
386
|
function renderPlaylistItem(episode, index, opts) {
|
|
@@ -405,6 +406,7 @@ function renderPlaylistItem(episode, index, opts) {
|
|
|
405
406
|
</div>
|
|
406
407
|
<div class="pw-episode-actions">
|
|
407
408
|
<div class="pw-episode-duration">${escapeHtml(duration)}</div>
|
|
409
|
+
<a href="${escapeHtml(episode.audioUrl)}" download="${escapeHtml(episode.title)}" target="_blank" class="pw-download-btn" title="Download episode" data-download>${ICONS.download}</a>
|
|
408
410
|
${feedLinkHtml}
|
|
409
411
|
</div>
|
|
410
412
|
</div>
|
|
@@ -815,6 +817,7 @@ var FullPlayer = (_class5 = class extends EventEmitter {
|
|
|
815
817
|
speed: true,
|
|
816
818
|
progress: true,
|
|
817
819
|
playlist: true,
|
|
820
|
+
download: true,
|
|
818
821
|
...opts.controls
|
|
819
822
|
};
|
|
820
823
|
this.feedPageUrl = opts.feedPageUrl;
|
|
@@ -869,6 +872,9 @@ var FullPlayer = (_class5 = class extends EventEmitter {
|
|
|
869
872
|
).join("");
|
|
870
873
|
secondaryHtml += `<select class="pw-speed-select" aria-label="Playback speed">${options}</select>`;
|
|
871
874
|
}
|
|
875
|
+
if (c.download) {
|
|
876
|
+
secondaryHtml += `<button class="pw-btn pw-btn--download" aria-label="Download episode">${ICONS.download}</button>`;
|
|
877
|
+
}
|
|
872
878
|
const progressHtml = c.progress ? `<div class="pw-progress pw-progress-container" role="slider" aria-label="Seek" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><div class="pw-progress-bar"></div></div>` : "";
|
|
873
879
|
const playlistHtml = c.playlist ? `<div class="pw-playlist"><div class="pw-playlist-header">Latest Episodes</div><div class="pw-playlist-items"><div class="pw-playlist-item pw-loading">Loading episodes...</div></div></div>` : "";
|
|
874
880
|
this.container.innerHTML = `
|
|
@@ -919,6 +925,7 @@ var FullPlayer = (_class5 = class extends EventEmitter {
|
|
|
919
925
|
this.addClick(".pw-btn--skip-fwd", () => engine.skipForward());
|
|
920
926
|
this.addInput(".pw-volume-slider", (val) => this.controller.setVolume(parseInt(val) / 100));
|
|
921
927
|
this.addChange(".pw-speed-select", (val) => this.controller.setSpeed(parseFloat(val)));
|
|
928
|
+
this.addClick(".pw-btn--download", () => this.downloadCurrentEpisode());
|
|
922
929
|
if (this.progressContainer) {
|
|
923
930
|
const handler = (e) => {
|
|
924
931
|
const rect = this.progressContainer.getBoundingClientRect();
|
|
@@ -1025,7 +1032,7 @@ var FullPlayer = (_class5 = class extends EventEmitter {
|
|
|
1025
1032
|
if (!this.playlistEl) return;
|
|
1026
1033
|
this.playlistEl.querySelectorAll(".pw-playlist-item").forEach((item) => {
|
|
1027
1034
|
item.addEventListener("click", (e) => {
|
|
1028
|
-
if (e.target.closest("[data-feed-link]")) return;
|
|
1035
|
+
if (e.target.closest("[data-feed-link]") || e.target.closest("[data-download]")) return;
|
|
1029
1036
|
const index = parseInt(item.dataset.index || "0");
|
|
1030
1037
|
this.controller.playEpisode(index);
|
|
1031
1038
|
});
|
|
@@ -1037,6 +1044,18 @@ var FullPlayer = (_class5 = class extends EventEmitter {
|
|
|
1037
1044
|
item.classList.toggle("pw-playing", i === index);
|
|
1038
1045
|
});
|
|
1039
1046
|
}
|
|
1047
|
+
// ─── Download ────────────────────────────────────────────────
|
|
1048
|
+
downloadCurrentEpisode() {
|
|
1049
|
+
const episode = this.controller.getCurrentEpisode();
|
|
1050
|
+
if (!episode) return;
|
|
1051
|
+
const a = document.createElement("a");
|
|
1052
|
+
a.href = episode.audioUrl;
|
|
1053
|
+
a.target = "_blank";
|
|
1054
|
+
a.download = episode.title || "episode";
|
|
1055
|
+
document.body.appendChild(a);
|
|
1056
|
+
a.click();
|
|
1057
|
+
document.body.removeChild(a);
|
|
1058
|
+
}
|
|
1040
1059
|
// ─── Helpers ───────────────────────────────────────────────────
|
|
1041
1060
|
addClick(selector, handler) {
|
|
1042
1061
|
const el = this.container.querySelector(selector);
|
package/dist/index.d.cts
CHANGED
|
@@ -175,6 +175,7 @@ interface ControlsConfig {
|
|
|
175
175
|
progress?: boolean;
|
|
176
176
|
playlist?: boolean;
|
|
177
177
|
expand?: boolean;
|
|
178
|
+
download?: boolean;
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
181
|
* The core player controller. Manages the relationship between
|
|
@@ -292,6 +293,7 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
|
|
|
292
293
|
private refreshPlaylist;
|
|
293
294
|
private bindPlaylistClicks;
|
|
294
295
|
private updatePlaylistHighlight;
|
|
296
|
+
private downloadCurrentEpisode;
|
|
295
297
|
private addClick;
|
|
296
298
|
private addInput;
|
|
297
299
|
private addChange;
|
|
@@ -309,6 +311,7 @@ declare const ICONS: {
|
|
|
309
311
|
volume: string;
|
|
310
312
|
info: string;
|
|
311
313
|
playlist: string;
|
|
314
|
+
download: string;
|
|
312
315
|
};
|
|
313
316
|
/** Speed options for the speed select dropdown. */
|
|
314
317
|
declare const SPEED_OPTIONS: number[];
|
package/dist/index.d.ts
CHANGED
|
@@ -175,6 +175,7 @@ interface ControlsConfig {
|
|
|
175
175
|
progress?: boolean;
|
|
176
176
|
playlist?: boolean;
|
|
177
177
|
expand?: boolean;
|
|
178
|
+
download?: boolean;
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
181
|
* The core player controller. Manages the relationship between
|
|
@@ -292,6 +293,7 @@ declare class FullPlayer extends EventEmitter<Pick<PlayerEventMap, 'close'>> {
|
|
|
292
293
|
private refreshPlaylist;
|
|
293
294
|
private bindPlaylistClicks;
|
|
294
295
|
private updatePlaylistHighlight;
|
|
296
|
+
private downloadCurrentEpisode;
|
|
295
297
|
private addClick;
|
|
296
298
|
private addInput;
|
|
297
299
|
private addChange;
|
|
@@ -309,6 +311,7 @@ declare const ICONS: {
|
|
|
309
311
|
volume: string;
|
|
310
312
|
info: string;
|
|
311
313
|
playlist: string;
|
|
314
|
+
download: string;
|
|
312
315
|
};
|
|
313
316
|
/** Speed options for the speed select dropdown. */
|
|
314
317
|
declare const SPEED_OPTIONS: number[];
|
package/dist/index.js
CHANGED
|
@@ -379,7 +379,8 @@ var ICONS = {
|
|
|
379
379
|
close: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
|
|
380
380
|
volume: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',
|
|
381
381
|
info: '<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>',
|
|
382
|
-
playlist: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>'
|
|
382
|
+
playlist: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>',
|
|
383
|
+
download: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>'
|
|
383
384
|
};
|
|
384
385
|
var SPEED_OPTIONS = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
|
|
385
386
|
function renderPlaylistItem(episode, index, opts) {
|
|
@@ -405,6 +406,7 @@ function renderPlaylistItem(episode, index, opts) {
|
|
|
405
406
|
</div>
|
|
406
407
|
<div class="pw-episode-actions">
|
|
407
408
|
<div class="pw-episode-duration">${escapeHtml(duration)}</div>
|
|
409
|
+
<a href="${escapeHtml(episode.audioUrl)}" download="${escapeHtml(episode.title)}" target="_blank" class="pw-download-btn" title="Download episode" data-download>${ICONS.download}</a>
|
|
408
410
|
${feedLinkHtml}
|
|
409
411
|
</div>
|
|
410
412
|
</div>
|
|
@@ -815,6 +817,7 @@ var FullPlayer = class extends EventEmitter {
|
|
|
815
817
|
speed: true,
|
|
816
818
|
progress: true,
|
|
817
819
|
playlist: true,
|
|
820
|
+
download: true,
|
|
818
821
|
...opts.controls
|
|
819
822
|
};
|
|
820
823
|
this.feedPageUrl = opts.feedPageUrl;
|
|
@@ -869,6 +872,9 @@ var FullPlayer = class extends EventEmitter {
|
|
|
869
872
|
).join("");
|
|
870
873
|
secondaryHtml += `<select class="pw-speed-select" aria-label="Playback speed">${options}</select>`;
|
|
871
874
|
}
|
|
875
|
+
if (c.download) {
|
|
876
|
+
secondaryHtml += `<button class="pw-btn pw-btn--download" aria-label="Download episode">${ICONS.download}</button>`;
|
|
877
|
+
}
|
|
872
878
|
const progressHtml = c.progress ? `<div class="pw-progress pw-progress-container" role="slider" aria-label="Seek" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><div class="pw-progress-bar"></div></div>` : "";
|
|
873
879
|
const playlistHtml = c.playlist ? `<div class="pw-playlist"><div class="pw-playlist-header">Latest Episodes</div><div class="pw-playlist-items"><div class="pw-playlist-item pw-loading">Loading episodes...</div></div></div>` : "";
|
|
874
880
|
this.container.innerHTML = `
|
|
@@ -919,6 +925,7 @@ var FullPlayer = class extends EventEmitter {
|
|
|
919
925
|
this.addClick(".pw-btn--skip-fwd", () => engine.skipForward());
|
|
920
926
|
this.addInput(".pw-volume-slider", (val) => this.controller.setVolume(parseInt(val) / 100));
|
|
921
927
|
this.addChange(".pw-speed-select", (val) => this.controller.setSpeed(parseFloat(val)));
|
|
928
|
+
this.addClick(".pw-btn--download", () => this.downloadCurrentEpisode());
|
|
922
929
|
if (this.progressContainer) {
|
|
923
930
|
const handler = (e) => {
|
|
924
931
|
const rect = this.progressContainer.getBoundingClientRect();
|
|
@@ -1025,7 +1032,7 @@ var FullPlayer = class extends EventEmitter {
|
|
|
1025
1032
|
if (!this.playlistEl) return;
|
|
1026
1033
|
this.playlistEl.querySelectorAll(".pw-playlist-item").forEach((item) => {
|
|
1027
1034
|
item.addEventListener("click", (e) => {
|
|
1028
|
-
if (e.target.closest("[data-feed-link]")) return;
|
|
1035
|
+
if (e.target.closest("[data-feed-link]") || e.target.closest("[data-download]")) return;
|
|
1029
1036
|
const index = parseInt(item.dataset.index || "0");
|
|
1030
1037
|
this.controller.playEpisode(index);
|
|
1031
1038
|
});
|
|
@@ -1037,6 +1044,18 @@ var FullPlayer = class extends EventEmitter {
|
|
|
1037
1044
|
item.classList.toggle("pw-playing", i === index);
|
|
1038
1045
|
});
|
|
1039
1046
|
}
|
|
1047
|
+
// ─── Download ────────────────────────────────────────────────
|
|
1048
|
+
downloadCurrentEpisode() {
|
|
1049
|
+
const episode = this.controller.getCurrentEpisode();
|
|
1050
|
+
if (!episode) return;
|
|
1051
|
+
const a = document.createElement("a");
|
|
1052
|
+
a.href = episode.audioUrl;
|
|
1053
|
+
a.target = "_blank";
|
|
1054
|
+
a.download = episode.title || "episode";
|
|
1055
|
+
document.body.appendChild(a);
|
|
1056
|
+
a.click();
|
|
1057
|
+
document.body.removeChild(a);
|
|
1058
|
+
}
|
|
1040
1059
|
// ─── Helpers ───────────────────────────────────────────────────
|
|
1041
1060
|
addClick(selector, handler) {
|
|
1042
1061
|
const el = this.container.querySelector(selector);
|
package/dist/podcast-player.css
CHANGED
|
@@ -707,14 +707,53 @@
|
|
|
707
707
|
background: rgba(var(--player-on-surface-rgb), 0.08);
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
+
.pw-download-btn {
|
|
711
|
+
display: flex;
|
|
712
|
+
align-items: center;
|
|
713
|
+
justify-content: center;
|
|
714
|
+
width: 24px;
|
|
715
|
+
height: 24px;
|
|
716
|
+
border-radius: 50%;
|
|
717
|
+
color: var(--player-on-surface-variant);
|
|
718
|
+
opacity: 0.5;
|
|
719
|
+
transition: all 100ms cubic-bezier(0.4, 0.0, 0.2, 1);
|
|
720
|
+
text-decoration: none;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.pw-download-btn svg {
|
|
724
|
+
width: 16px;
|
|
725
|
+
height: 16px;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.pw-download-btn:hover {
|
|
729
|
+
opacity: 1;
|
|
730
|
+
color: var(--md-primary);
|
|
731
|
+
background: rgba(var(--player-on-surface-rgb), 0.08);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.pw-btn--download {
|
|
735
|
+
width: 32px;
|
|
736
|
+
height: 32px;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.pw-btn--download svg {
|
|
740
|
+
width: 18px;
|
|
741
|
+
height: 18px;
|
|
742
|
+
}
|
|
743
|
+
|
|
710
744
|
/* ================================================================
|
|
711
745
|
RESPONSIVE
|
|
712
746
|
================================================================ */
|
|
713
747
|
|
|
714
748
|
@media (max-width: 768px) {
|
|
715
749
|
.pw-full {
|
|
716
|
-
width:
|
|
717
|
-
|
|
750
|
+
width: 100%;
|
|
751
|
+
height: 100%;
|
|
752
|
+
max-height: 100dvh;
|
|
753
|
+
top: 0;
|
|
754
|
+
left: 0;
|
|
755
|
+
transform: none;
|
|
756
|
+
border-radius: 0;
|
|
718
757
|
}
|
|
719
758
|
|
|
720
759
|
.pw-mini {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudgy/podcast-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Framework-agnostic podcast player widget with configurable player modes, theming via CSS custom properties, and optional PodcastIndex API client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|