move types to types file

This commit is contained in:
Ollie Taylor
2023-02-24 22:59:12 +00:00
parent b6874a6e0b
commit c025b3e1a8
9 changed files with 36 additions and 35 deletions
+2 -2
View File
@@ -12,12 +12,12 @@
audio_start_at, audio_start_at,
} from '$lib/context/audio-internals'; } from '$lib/context/audio-internals';
import { user_preferences } from '$lib/context/user-preferences'; import { user_preferences } from '$lib/context/user-preferences';
import type { PlayerElement } from '$lib/types/types'; import type { AudioPlayerElement } from '$lib/types';
import { load_podcast_state } from '$lib/utility/use-state'; import { load_podcast_state } from '$lib/utility/use-state';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
// readonly values // readonly values
let element: PlayerElement; let element: AudioPlayerElement;
let current_time = $audio_start_at; let current_time = $audio_start_at;
let duration = 0; let duration = 0;
let ended = true; let ended = true;
+2 -2
View File
@@ -1,9 +1,9 @@
import type { PlayerElement } from '$lib/types/types'; import type { AudioPlayerElement } from '$lib/types';
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
// readonly - stores will update when bindings change // readonly - stores will update when bindings change
export const audio_current_time = writable<number>(0); export const audio_current_time = writable<number>(0);
export const audio_element = writable<PlayerElement>(); export const audio_element = writable<AudioPlayerElement>();
export const audio_duration = writable<number>(0); export const audio_duration = writable<number>(0);
export const audio_ended = writable<boolean>(false); export const audio_ended = writable<boolean>(false);
export const audio_loading = writable<boolean>(false); export const audio_loading = writable<boolean>(false);
+1 -5
View File
@@ -1,8 +1,4 @@
import type { AudioMetadata } from '$lib/types';
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
export type AudioMetadata = {
title: string;
artwork: string;
};
export const audio_metadata = writable<AudioMetadata | null>(null); export const audio_metadata = writable<AudioMetadata | null>(null);
+2 -8
View File
@@ -10,9 +10,10 @@ import {
audio_src, audio_src,
audio_start_at, audio_start_at,
} from '$lib/context/audio-internals'; } from '$lib/context/audio-internals';
import { audio_metadata, type AudioMetadata } from '$lib/context/audio-metadata'; import { audio_metadata } from '$lib/context/audio-metadata';
import { episode_progress } from '$lib/context/episode-progress'; import { episode_progress } from '$lib/context/episode-progress';
import { user_preferences } from '$lib/context/user-preferences'; import { user_preferences } from '$lib/context/user-preferences';
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';
@@ -105,13 +106,6 @@ function unmute(type: HandleType = 'set') {
} }
} }
export type AudioLoadData = AudioMetadata & { src: string };
export type AudioLoadOptions = {
autoplay: boolean;
start_at?: number;
};
const load = (data: AudioLoadData, opts: AudioLoadOptions) => { const load = (data: AudioLoadData, opts: AudioLoadOptions) => {
episode_progress.stash(); episode_progress.stash();
+2 -5
View File
@@ -1,11 +1,8 @@
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { audio, type AudioLoadOptions } from '$lib/context/audio'; import { audio } from '$lib/context/audio';
import type { AudioLoadOptions, EpisodeProgress } from '$lib/types';
import { error, info, warn } from '$lib/utility/package/log'; import { error, info, warn } from '$lib/utility/package/log';
export type EpisodeProgress = {
current_time: number;
};
const episode_progress_map = new Map<string, EpisodeProgress>(); const episode_progress_map = new Map<string, EpisodeProgress>();
function stash_episode() { function stash_episode() {
+1 -5
View File
@@ -1,13 +1,9 @@
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import type { UserPreferences } from '$lib/types';
import { info, warn } from '$lib/utility/package/log'; import { info, warn } from '$lib/utility/package/log';
import clamp from 'just-clamp'; import clamp from 'just-clamp';
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
export type UserPreferences = {
playback_rate: number;
volume: number;
};
const default_user_preferences = { const default_user_preferences = {
playback_rate: 1, playback_rate: 1,
volume: 1, volume: 1,
+24
View File
@@ -0,0 +1,24 @@
export type AudioPlayerElement = HTMLAudioElement | undefined;
export interface AudioMetadata {
title: string;
artwork: string;
}
export interface AudioLoadData extends AudioMetadata {
src: string;
}
export interface AudioLoadOptions {
autoplay: boolean;
start_at?: number;
}
export interface EpisodeProgress {
current_time: number;
}
export interface UserPreferences {
playback_rate: number;
volume: number;
}
-1
View File
@@ -1 +0,0 @@
export type PlayerElement = HTMLAudioElement | undefined;
+2 -7
View File
@@ -1,11 +1,6 @@
<script lang="ts"> <script lang="ts">
import { import { audio, episode_progress, save_podcast_state, user_preferences } from '$lib';
audio, import type { AudioLoadData } from '$lib/types';
episode_progress,
save_podcast_state,
user_preferences,
type AudioLoadData,
} from '$lib';
const sources = { const sources = {
syntax: { syntax: {