Makes typings easier to override (#30)

This commit is contained in:
Ollie Taylor
2023-02-25 01:46:24 +00:00
committed by GitHub
3 changed files with 20 additions and 17 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'svelte-podcast': patch
---
fix to allow override of internal types
+11 -13
View File
@@ -16,7 +16,7 @@ import type { AudioLoadData, AudioLoadOptions } from '$lib/types';
import { secondsToTimestamp } from '$lib/utility/seconds-to-timestamp'; import { secondsToTimestamp } from '$lib/utility/seconds-to-timestamp';
import { info, warn } from '$pkg/log'; import { info, warn } from '$pkg/log';
import clamp from 'just-clamp'; import clamp from 'just-clamp';
import { derived } from 'svelte/store'; import { derived, type Readable } from 'svelte/store';
export { default as AudioLoader } from '$lib/audio/audio-loader.svelte'; export { default as AudioLoader } from '$lib/audio/audio-loader.svelte';
export const podcast_time = derived([_current_time, _ended], ([$seconds, $ended]) => ({ export const podcast_time = derived([_current_time, _ended], ([$seconds, $ended]) => ({
@@ -25,22 +25,20 @@ export const podcast_time = derived([_current_time, _ended], ([$seconds, $ended]
ended: $ended, ended: $ended,
})); }));
export const podcast_data = derived( export const podcast_data: Readable<AudioLoadData> = derived(
[_src, _metadata], [_src, _metadata],
([$src, $metadata]) => ([$src, $metadata]) => ({
({ ...$metadata,
...$metadata, src: $src,
src: $src, }),
} satisfies AudioLoadData),
); );
export const podcast_options = derived( export const podcast_options: Readable<AudioLoadOptions> = derived(
[_start_at, _autoplay], [_start_at, _autoplay],
([$start_at, $autoplay]) => ([$start_at, $autoplay]) => ({
({ start_at: $start_at,
start_at: $start_at, autoplay: $autoplay,
autoplay: $autoplay, }),
} satisfies AudioLoadOptions),
); );
export const podcast_duration = { subscribe: _duration.subscribe }; export const podcast_duration = { subscribe: _duration.subscribe };
+4 -4
View File
@@ -1,9 +1,9 @@
export type AudioPlayerElement = HTMLAudioElement | undefined; export type AudioPlayerElement = HTMLAudioElement | undefined;
export type AudioMetadata = Partial<{ export interface AudioMetadata {
title: string; title?: string;
artwork: string; artwork?: string;
}>; }
export interface AudioLoadData extends AudioMetadata { export interface AudioLoadData extends AudioMetadata {
src: string; src: string;