@ngxsp/core 0.1.0 → 0.2.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.
Files changed (65) hide show
  1. package/commands.d.ts +40 -0
  2. package/config/default-config.d.ts +34 -0
  3. package/domain/audio-identification-routine.d.ts +47 -0
  4. package/domain/audio-identification.d.ts +78 -0
  5. package/domain/audio-library.d.ts +59 -0
  6. package/domain/audio-metadata-harmony.d.ts +29 -0
  7. package/domain/device-playback.d.ts +40 -0
  8. package/domain/media-item.d.ts +22 -0
  9. package/domain/media-library-model.d.ts +75 -0
  10. package/domain/media-source.d.ts +115 -0
  11. package/domain/queue.d.ts +12 -0
  12. package/domain/remote-playback.d.ts +82 -0
  13. package/domain/ringtone.d.ts +46 -0
  14. package/domain/shake.d.ts +55 -0
  15. package/domain/vault.d.ts +55 -0
  16. package/engine/capability-report.d.ts +35 -0
  17. package/engine/engine-factory.d.ts +19 -0
  18. package/engine/engine-profile.d.ts +27 -0
  19. package/engine/native.engine.d.ts +23 -0
  20. package/engine/native.factory.d.ts +2 -0
  21. package/engine/playback-capabilities.d.ts +29 -0
  22. package/engine/playback-engine.d.ts +44 -0
  23. package/engine/remote-playback.engine.d.ts +77 -0
  24. package/engine/types.d.ts +15 -0
  25. package/events/event-bus.d.ts +15 -0
  26. package/facade/player-facade.d.ts +125 -0
  27. package/index.d.ts +60 -2491
  28. package/online/acoustid.d.ts +29 -0
  29. package/online/cast-v2.d.ts +62 -0
  30. package/online/dlna-renderer.d.ts +19 -0
  31. package/online/dlna.d.ts +48 -0
  32. package/online/internet-archive.d.ts +105 -0
  33. package/online/jellyfin.d.ts +24 -0
  34. package/online/lyrics.d.ts +69 -0
  35. package/online/md5.d.ts +5 -0
  36. package/online/mdns.d.ts +61 -0
  37. package/online/media-cache.d.ts +61 -0
  38. package/online/musicbrainz.d.ts +41 -0
  39. package/online/online-http.d.ts +10 -0
  40. package/online/playback-transfer.d.ts +106 -0
  41. package/online/radio-browser.d.ts +42 -0
  42. package/online/subsonic.d.ts +16 -0
  43. package/online/upnp.d.ts +30 -0
  44. package/online/webdav.d.ts +21 -0
  45. package/online/xml-text.d.ts +19 -0
  46. package/package.json +1 -1
  47. package/plugins/ads/ssai.plugin.d.ts +14 -0
  48. package/plugins/metadata/metadata.types.d.ts +28 -0
  49. package/plugins/metadata/providers/local-metadata.provider.d.ts +11 -0
  50. package/plugins/plugin.d.ts +20 -0
  51. package/plugins/progress/progress.plugin.d.ts +10 -0
  52. package/plugins/resilience/resilience.plugin.d.ts +12 -0
  53. package/plugins/subtitles/providers/local-subtitle.provider.d.ts +9 -0
  54. package/plugins/subtitles/subtitle-file.d.ts +14 -0
  55. package/plugins/subtitles/subtitles.types.d.ts +22 -0
  56. package/ports/http.port.d.ts +3 -0
  57. package/ports/log.port.d.ts +12 -0
  58. package/ports/ports.d.ts +14 -0
  59. package/ports/storage.port.d.ts +11 -0
  60. package/ports/telemetry.port.d.ts +7 -0
  61. package/remote-config/remote-config.d.ts +8 -0
  62. package/telemetry/telemetry.types.d.ts +11 -0
  63. package/types.d.ts +345 -0
  64. package/utils/cache-store.d.ts +12 -0
  65. package/index.d.cts +0 -2491
package/commands.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type PlayerCommand = {
2
+ type: 'play';
3
+ } | {
4
+ type: 'pause';
5
+ } | {
6
+ type: 'toggle';
7
+ } | {
8
+ type: 'seek';
9
+ to: number;
10
+ } | {
11
+ type: 'setPlaybackRate';
12
+ rate: number;
13
+ } | {
14
+ type: 'setVolume';
15
+ volume: number;
16
+ } | {
17
+ type: 'setMuted';
18
+ muted: boolean;
19
+ } | {
20
+ type: 'selectTextTrack';
21
+ id: string;
22
+ } | {
23
+ type: 'disableTextTrack';
24
+ } | {
25
+ type: 'selectAudioTrack';
26
+ id: string;
27
+ } | {
28
+ type: 'requestPiP';
29
+ } | {
30
+ type: 'exitPiP';
31
+ } | {
32
+ type: 'requestFullscreen';
33
+ } | {
34
+ type: 'exitFullscreen';
35
+ } | {
36
+ type: 'requestCast';
37
+ } | {
38
+ type: 'stopCast';
39
+ };
40
+ export declare function isCategorizedEventType(type: string): boolean;
@@ -0,0 +1,34 @@
1
+ import type { AdsConfig, MetadataConfig, PlayerConfig, PlayerSource, ProgressConfig, ResilienceConfig, SubtitlesConfig, UiConfig } from '../types';
2
+ /**
3
+ * Sensible, framework-agnostic defaults for the mandatory sub-configs of
4
+ * {@link PlayerConfig}. They mirror the values used by the existing
5
+ * consumers (local audio/video players) so a brand new integration can get a
6
+ * valid config without restating every field.
7
+ */
8
+ export declare const DEFAULT_PROGRESS_CONFIG: ProgressConfig;
9
+ export declare const DEFAULT_UI_CONFIG: UiConfig;
10
+ export declare const DEFAULT_RESILIENCE_CONFIG: ResilienceConfig;
11
+ export declare const DEFAULT_SUBTITLES_CONFIG: SubtitlesConfig;
12
+ export declare const DEFAULT_METADATA_CONFIG: MetadataConfig;
13
+ export declare const DEFAULT_ADS_CONFIG: AdsConfig;
14
+ /**
15
+ * Build a complete, type-safe {@link PlayerConfig} from a minimal set of
16
+ * overrides. Only `source` is required; the mandatory sub-configs
17
+ * (`progress`, `ui`, `resilience`, `subtitles`, `metadata`, `ads`) are filled
18
+ * with the defaults above and shallow-merged with any override provided.
19
+ *
20
+ * Optional top-level fields (`profile`, `drm`, `series`, `playlist`,
21
+ * `offline`, `remoteConfig`, ...) are passed through untouched when present.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const config = createDefaultConfig({
26
+ * source: { type: 'hls', url: 'https://cdn.example.com/movie.m3u8' },
27
+ * drm: { keySystems: { 'com.widevine.alpha': { licenseServerUrl: 'https://drm/widevine' } } },
28
+ * subtitles: { enabled: true, providers: ['local'], preferredLang: 'fr' },
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function createDefaultConfig(overrides: Partial<PlayerConfig> & {
33
+ source: PlayerSource;
34
+ }): PlayerConfig;
@@ -0,0 +1,47 @@
1
+ import { type AudioIdentification, type AudioIdentificationInput, type AudioIdentificationMatch, type AudioIdentificationMethod } from './audio-identification';
2
+ /** A library item as the routine reads it: the identification state and what tells a changed file apart. */
3
+ export interface IdentifiableItem extends AudioIdentificationInput {
4
+ id: string;
5
+ identification?: AudioIdentification;
6
+ size: number;
7
+ /** Modification time in milliseconds; with the size it says whether the file changed. */
8
+ mtimeMs: number;
9
+ }
10
+ /** What the routine needs from a library, on the desktop as on a phone. */
11
+ export interface IdentificationLibrary<TItem extends IdentifiableItem = IdentifiableItem> {
12
+ identificationCandidates(): readonly TItem[];
13
+ recordIdentification(id: string, identification: AudioIdentification): void;
14
+ setIdentificationProgress(progress: {
15
+ identifying: boolean;
16
+ identified: number;
17
+ identifyTotal: number;
18
+ }): void;
19
+ notifyChanged(): void;
20
+ /** Writes the index; the routine calls it once a run is over. */
21
+ flush(): Promise<void> | void;
22
+ }
23
+ export interface IdentificationRoutineOptions<TItem extends IdentifiableItem = IdentifiableItem> {
24
+ library: IdentificationLibrary<TItem>;
25
+ identify(item: TItem): Promise<AudioIdentificationMatch>;
26
+ /** Methods available now; unmatched tracks are tried again when a stronger one appears (fingerprints). */
27
+ methods?: readonly AudioIdentificationMethod[];
28
+ source?: AudioIdentification['source'];
29
+ now?: () => number;
30
+ retryIntervalMs?: number;
31
+ /** Offline or service down: a run stops after this many failures in a row. */
32
+ maxConsecutiveErrors?: number;
33
+ onError?: (error: unknown) => void;
34
+ }
35
+ export interface IdentificationRoutine {
36
+ /** Runs once now; a call during a run schedules another pass, so new files are never missed. */
37
+ run(): Promise<void>;
38
+ /** Runs now and then every `retryIntervalMs`. */
39
+ start(): void;
40
+ dispose(): void;
41
+ }
42
+ /** `size:mtime`, which changes when the file behind an item changes. */
43
+ export declare function fileKeyFor(item: {
44
+ size: number;
45
+ mtimeMs: number;
46
+ }): string;
47
+ export declare function createIdentificationRoutine<TItem extends IdentifiableItem>(options: IdentificationRoutineOptions<TItem>): IdentificationRoutine;
@@ -0,0 +1,78 @@
1
+ import type { AcoustIdResult } from '../online/acoustid';
2
+ import type { MusicBrainzRecording } from '../online/musicbrainz';
3
+ /** Bump when the matching rules change: tracks left unmatched by an older version are checked again once. */
4
+ export declare const AUDIO_IDENTIFICATION_VERSION = 1;
5
+ /** Unmatched tracks are retried after 30 days, failed checks (offline, service down) after an hour. */
6
+ export declare const AUDIO_IDENTIFICATION_RETRY_MS: {
7
+ readonly unmatched: number;
8
+ readonly error: 3600000;
9
+ };
10
+ export type AudioIdentifiableField = 'title' | 'artist' | 'albumArtist' | 'album' | 'year' | 'trackNo';
11
+ export interface AudioIdentificationInput {
12
+ title: string;
13
+ artist?: string;
14
+ albumArtist?: string;
15
+ album?: string;
16
+ year?: number;
17
+ trackNo?: number;
18
+ durationSec?: number;
19
+ /** Fields guessed from file and folder names instead of read from tags. */
20
+ inferredFields?: readonly AudioIdentifiableField[];
21
+ }
22
+ /**
23
+ * - `trusted`: tags were complete, nothing to look up.
24
+ * - `matched`: an online source confirmed the track; its fields fill what the tags lacked.
25
+ * - `unmatched`: no reliable answer; retried much later.
26
+ * - `error`: the check could not run; retried soon.
27
+ */
28
+ export type AudioIdentificationStatus = 'trusted' | 'matched' | 'unmatched' | 'error';
29
+ /** `fingerprint`: Chromaprint + AcoustID recognise the sound itself; `text`: MusicBrainz search on title, artist and duration. */
30
+ export type AudioIdentificationMethod = 'fingerprint' | 'text';
31
+ export interface AudioIdentification {
32
+ version: number;
33
+ status: AudioIdentificationStatus;
34
+ checkedAt: number;
35
+ /** File size and modification time at check time: a changed file is checked again. */
36
+ fileKey: string;
37
+ source?: 'musicbrainz';
38
+ /** Strongest method used for this check; a track left unmatched by text search is retried once fingerprints are available. */
39
+ method?: AudioIdentificationMethod;
40
+ recordingId?: string;
41
+ releaseId?: string;
42
+ confidence?: number;
43
+ fields?: Partial<Pick<AudioIdentificationInput, AudioIdentifiableField>>;
44
+ }
45
+ export interface AudioIdentificationMatch {
46
+ status: 'matched' | 'unmatched';
47
+ method?: AudioIdentificationMethod;
48
+ recordingId?: string;
49
+ releaseId?: string;
50
+ confidence: number;
51
+ fields: Partial<Pick<AudioIdentificationInput, AudioIdentifiableField>>;
52
+ }
53
+ /** Fields worth checking online: guessed from names or missing. Empty when tags are complete. */
54
+ export declare function audioIdentificationDoubts(input: AudioIdentificationInput): AudioIdentifiableField[];
55
+ /**
56
+ * Up-to-date tracks (trusted or matched) are never checked again while their file is unchanged. Unmatched tracks are
57
+ * retried when a stronger method or newer rules become available, or after a long delay; failed checks soon.
58
+ */
59
+ export declare function needsAudioIdentification(previous: AudioIdentification | undefined, fileKey: string, now: number, methods?: readonly AudioIdentificationMethod[]): boolean;
60
+ /**
61
+ * Picks the MusicBrainz recording behind a fingerprint. The sound decides; names only break ties between the
62
+ * recordings AcoustID links to the same fingerprint.
63
+ */
64
+ export declare function pickAcoustIdRecording(input: AudioIdentificationInput, results: readonly AcoustIdResult[]): {
65
+ recordingId: string;
66
+ confidence: number;
67
+ } | null;
68
+ /** Metadata of a recording recognised by its fingerprint; album rules are the same as for text matches. */
69
+ export declare function matchFingerprintedRecording(input: AudioIdentificationInput, recording: MusicBrainzRecording | null, confidence: number): AudioIdentificationMatch;
70
+ /**
71
+ * Accepts a recording only when title, artist and duration agree with the file. Without an artist a name search is
72
+ * never trusted ("Track 07" exists many times over): only a fingerprint can identify such files. Album data is taken from a release
73
+ * with the same album title, or from the artist's own album when the file has no album at all, so folders stay
74
+ * grouped the way the user organised them.
75
+ */
76
+ export declare function matchMusicBrainzRecording(input: AudioIdentificationInput, recordings: readonly MusicBrainzRecording[]): AudioIdentificationMatch;
77
+ /** Identification fills guessed or missing fields only: values read from tags are never overwritten. */
78
+ export declare function applyAudioIdentification<TItem extends AudioIdentificationInput>(item: TItem, identification: AudioIdentification | undefined): TItem;
@@ -0,0 +1,59 @@
1
+ import type { MediaItem } from './media-item';
2
+ export interface AudioTrack extends MediaItem {
3
+ kind: 'audio';
4
+ artist?: string;
5
+ album?: string;
6
+ albumArtist?: string;
7
+ genre?: string;
8
+ trackNo?: number;
9
+ discNo?: number;
10
+ year?: number;
11
+ }
12
+ export interface AudioAlbum<TTrack extends AudioTrack = AudioTrack> {
13
+ id: string;
14
+ title: string;
15
+ artist?: string;
16
+ artwork?: string;
17
+ year?: number;
18
+ tracks: TTrack[];
19
+ }
20
+ export interface AudioArtist<TTrack extends AudioTrack = AudioTrack> {
21
+ id: string;
22
+ name: string;
23
+ artwork?: string;
24
+ tracks: TTrack[];
25
+ }
26
+ export interface AudioGenre<TTrack extends AudioTrack = AudioTrack> {
27
+ id: string;
28
+ name: string;
29
+ tracks: TTrack[];
30
+ }
31
+ export interface AudioPlaylist {
32
+ id: string;
33
+ name: string;
34
+ description?: string;
35
+ artwork?: string;
36
+ trackIds: string[];
37
+ }
38
+ export type AudioPlaylistRef = AudioPlaylist;
39
+ export interface AudioLibrarySnapshot<TTrack extends AudioTrack = AudioTrack> {
40
+ tracks: TTrack[];
41
+ albums: AudioAlbum<TTrack>[];
42
+ artists: AudioArtist<TTrack>[];
43
+ genres: AudioGenre<TTrack>[];
44
+ playlists: AudioPlaylist[];
45
+ }
46
+ export interface AudioLibrarySearchResult<TTrack extends AudioTrack = AudioTrack> extends AudioLibrarySnapshot<TTrack> {
47
+ active: boolean;
48
+ query: string;
49
+ directTrackIds: string[];
50
+ matchedTrackIds: string[];
51
+ matchedAlbumIds: string[];
52
+ matchedArtistIds: string[];
53
+ matchedGenreIds: string[];
54
+ matchedPlaylistIds: string[];
55
+ }
56
+ export declare function createAudioLibrarySnapshot<TTrack extends AudioTrack>(tracks: readonly TTrack[], playlists?: readonly AudioPlaylist[]): AudioLibrarySnapshot<TTrack>;
57
+ export declare function searchAudioLibrarySnapshot<TTrack extends AudioTrack>(snapshot: AudioLibrarySnapshot<TTrack>, searchTerm: string): AudioLibrarySearchResult<TTrack>;
58
+ export declare function normalizeAudioSearchText(value: string): string;
59
+ export declare function audioTrackMatchesSearch(track: AudioTrack, searchTerm: string): boolean;
@@ -0,0 +1,29 @@
1
+ import type { AudioTrack } from './audio-library';
2
+ /** Number of tracks whose metadata was changed, per kind of correction. */
3
+ export interface AudioMetadataCorrections {
4
+ /** Artist or album artist spelled differently from the rest of the library, or prefixed by a track number. */
5
+ artists: number;
6
+ /** Album titles unified within the same album, disc suffixes moved to the disc number. */
7
+ albums: number;
8
+ /** Genres merged with their other spellings. */
9
+ genres: number;
10
+ /** Titles freed from a track number or artist prefix. */
11
+ titles: number;
12
+ /** Missing album artist, year, genre or track number filled from the rest of the same album. */
13
+ filled: number;
14
+ }
15
+ export interface AudioMetadataHarmony<TTrack extends AudioTrack> {
16
+ tracks: TTrack[];
17
+ corrections: AudioMetadataCorrections;
18
+ /** Tracks with at least one correction. */
19
+ correctedTracks: number;
20
+ }
21
+ /**
22
+ * Makes a library consistent without inventing information: spellings of the same artist, album or genre are
23
+ * unified on their most frequent form, and gaps are only filled from other tracks of the same album.
24
+ */
25
+ export declare function harmonizeAudioMetadata<TTrack extends AudioTrack>(tracks: readonly TTrack[]): AudioMetadataHarmony<TTrack>;
26
+ /** Removes track-number prefixes (`01.Corneille`, `03 - Corneille`) and file-name underscores from a name. */
27
+ export declare function cleanAudioArtistName(value: string | undefined): string | undefined;
28
+ /** Case, accent and punctuation insensitive key: `Jay-Z`, `JAY Z` and `jay z` share one key. Works for any media name. */
29
+ export declare function mediaMetadataKey(value: string): string;
@@ -0,0 +1,40 @@
1
+ import type { RemotePlaybackKind } from './remote-playback';
2
+ export type DevicePlaybackKind = RemotePlaybackKind;
3
+ export type DevicePlaybackStatus = 'idle' | 'connecting' | 'playing' | 'failed';
4
+ export interface PlaybackDevice {
5
+ id: string;
6
+ name: string;
7
+ kind: DevicePlaybackKind;
8
+ address: string;
9
+ model?: string;
10
+ connected?: boolean;
11
+ }
12
+ export interface DevicePlaybackState {
13
+ status: DevicePlaybackStatus;
14
+ activeDeviceId: string | null;
15
+ activeDeviceName: string | null;
16
+ targetUrl?: string;
17
+ message?: string;
18
+ error?: string;
19
+ }
20
+ export type DevicePlaybackEvent = {
21
+ type: 'connect';
22
+ device: PlaybackDevice;
23
+ targetUrl: string;
24
+ message?: string;
25
+ } | {
26
+ type: 'playing';
27
+ deviceId: string;
28
+ message?: string;
29
+ } | {
30
+ type: 'fail';
31
+ deviceId: string;
32
+ error: string;
33
+ message?: string;
34
+ } | {
35
+ type: 'stop';
36
+ deviceId?: string;
37
+ message?: string;
38
+ };
39
+ export declare function createIdleDevicePlaybackState(message?: string): DevicePlaybackState;
40
+ export declare function reduceDevicePlaybackState(state: DevicePlaybackState, event: DevicePlaybackEvent): DevicePlaybackState;
@@ -0,0 +1,22 @@
1
+ export type MediaKind = 'audio' | 'video';
2
+ export interface MediaArtwork {
3
+ src: string;
4
+ kind?: 'cover' | 'poster' | 'backdrop' | 'thumbnail';
5
+ }
6
+ export interface MediaProgress {
7
+ currentTimeSec: number;
8
+ durationSec?: number;
9
+ updatedAt: number;
10
+ }
11
+ export interface MediaItem {
12
+ id: string;
13
+ kind: MediaKind;
14
+ title: string;
15
+ path?: string;
16
+ url?: string;
17
+ subtitle?: string;
18
+ artwork?: MediaArtwork[];
19
+ durationSec?: number;
20
+ sizeBytes?: number;
21
+ mtimeMs?: number;
22
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Media library model shared by the desktop and mobile shells: file filtering, title cleanup and audio/video
3
+ * classification from tags, file names and folders. Paths are relative to the library folder and use "/".
4
+ */
5
+ /** Bump when classification changes: indexed files are read again once. */
6
+ export declare const MEDIA_LIBRARY_MODEL_VERSION = 3;
7
+ export type MediaLibraryKind = 'audio' | 'video';
8
+ export type AudioInferredField = 'title' | 'artist' | 'albumArtist' | 'album' | 'trackNo';
9
+ /** The subset of music-metadata results the model reads. */
10
+ export interface MediaTags {
11
+ title?: string;
12
+ artist?: string;
13
+ artists?: string[];
14
+ albumartist?: string;
15
+ album?: string;
16
+ genre?: string | string[];
17
+ track?: {
18
+ no?: number | null;
19
+ };
20
+ disk?: {
21
+ no?: number | null;
22
+ };
23
+ year?: number;
24
+ stik?: number;
25
+ tvShow?: string;
26
+ tvSeason?: number;
27
+ tvEpisode?: number;
28
+ }
29
+ export interface MediaFormat {
30
+ duration?: number;
31
+ }
32
+ export interface MediaTagsInput {
33
+ /** Path of the file inside the library folder, e.g. `Artist/Album/01 - Song.mp3`. */
34
+ relativePath: string;
35
+ common?: MediaTags;
36
+ format?: MediaFormat;
37
+ }
38
+ export interface AudioLibraryFields {
39
+ title: string;
40
+ artist?: string;
41
+ albumArtist?: string;
42
+ album?: string;
43
+ genre?: string;
44
+ trackNo?: number;
45
+ discNo?: number;
46
+ year?: number;
47
+ durationSec?: number;
48
+ /** Fields guessed from file and folder names: identification may correct them, never tagged values. */
49
+ inferredFields?: AudioInferredField[];
50
+ }
51
+ export interface VideoLibraryFields {
52
+ category: 'movie' | 'episode' | 'other';
53
+ title: string;
54
+ series?: string;
55
+ season?: number;
56
+ episode?: number;
57
+ year?: number;
58
+ durationSec?: number;
59
+ }
60
+ export declare function mediaFileExtension(fileName: string): string;
61
+ export declare function isMediaFileName(fileName: string, kind: MediaLibraryKind): boolean;
62
+ export declare function isImageFileName(fileName: string): boolean;
63
+ export declare function isIgnoredDirectoryName(name: string): boolean;
64
+ export declare function mediaContentType(fileName: string): string;
65
+ /** Rank of a folder image as album or poster art (0 is best), -1 when it is not one. */
66
+ export declare function folderArtworkRank(fileName: string): number;
67
+ export declare function cleanMediaTitle(fileStemValue: string): string;
68
+ export declare function parseEpisodeFileName(stem: string): {
69
+ series?: string;
70
+ season?: number;
71
+ episode?: number;
72
+ episodeTitle?: string;
73
+ } | null;
74
+ export declare function audioFieldsFromTags({ relativePath, common, format }: MediaTagsInput): AudioLibraryFields;
75
+ export declare function videoFieldsFromTags({ relativePath, common, format }: MediaTagsInput): VideoLibraryFields;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Media servers the apps can browse and play from: a home server (Jellyfin), a UPnP/DLNA server, a Subsonic music
3
+ * server or a plain WebDAV share. Connectors translate each protocol into the same containers and items, so the
4
+ * library views and the queue treat every source alike.
5
+ */
6
+ export type MediaSourceKind = 'jellyfin' | 'dlna' | 'subsonic' | 'webdav';
7
+ /** What the listener fills in to connect a server. */
8
+ export interface MediaSourceInput {
9
+ kind: MediaSourceKind;
10
+ /** Address of the server, with or without scheme; connectors normalise it. */
11
+ address: string;
12
+ name?: string;
13
+ username?: string;
14
+ password?: string;
15
+ }
16
+ /**
17
+ * A connected server. `secret` is the credential kept to reach it again (an access token when the server issues one,
18
+ * the password otherwise); applications store it with their own preferences and never send it anywhere else.
19
+ */
20
+ export interface MediaSourceAccount {
21
+ id: string;
22
+ kind: MediaSourceKind;
23
+ name: string;
24
+ baseUrl: string;
25
+ username?: string;
26
+ secret?: string;
27
+ /** Account identifier on the server, when it has one. */
28
+ userId?: string;
29
+ }
30
+ /** A browsable node: a library, a folder, an album, a series. */
31
+ export interface MediaSourceContainer {
32
+ id: string;
33
+ title: string;
34
+ subtitle?: string;
35
+ artworkUrl?: string;
36
+ /** What it holds, when the server says so. */
37
+ kind?: 'audio' | 'video' | 'mixed';
38
+ childCount?: number;
39
+ }
40
+ /** A playable file, in the shape the libraries already use. */
41
+ export interface MediaSourceItem {
42
+ id: string;
43
+ kind: 'audio' | 'video';
44
+ title: string;
45
+ url: string;
46
+ artworkUrl?: string;
47
+ durationSec?: number;
48
+ artist?: string;
49
+ albumArtist?: string;
50
+ album?: string;
51
+ genre?: string;
52
+ year?: number;
53
+ trackNo?: number;
54
+ discNo?: number;
55
+ series?: string;
56
+ season?: number;
57
+ episode?: number;
58
+ container?: string;
59
+ }
60
+ export interface MediaSourcePage {
61
+ containers: MediaSourceContainer[];
62
+ items: MediaSourceItem[];
63
+ /** Total number of items in the container, when the server reports it. */
64
+ total?: number;
65
+ }
66
+ export interface MediaSourceRequest {
67
+ url: string;
68
+ method?: 'GET' | 'POST' | 'PROPFIND';
69
+ headers?: Record<string, string>;
70
+ json?: unknown;
71
+ body?: string;
72
+ signal?: AbortSignal;
73
+ /** For a request that waits on purpose (another device asking its user); transports keep their own otherwise. */
74
+ timeoutMs?: number;
75
+ }
76
+ export interface MediaSourceResponse {
77
+ status: number;
78
+ json(): Promise<unknown>;
79
+ text(): Promise<string>;
80
+ }
81
+ /** Transport used by connectors; applications plug their HTTP client here. */
82
+ export interface MediaSourceHttp {
83
+ send(request: MediaSourceRequest): Promise<MediaSourceResponse>;
84
+ }
85
+ export interface MediaSourceBrowseOptions {
86
+ containerId?: string;
87
+ /** Filters what the container returns, for apps that only play one kind. */
88
+ kind?: 'audio' | 'video';
89
+ search?: string;
90
+ startIndex?: number;
91
+ limit?: number;
92
+ signal?: AbortSignal;
93
+ }
94
+ export interface MediaSourceConnector {
95
+ kind: MediaSourceKind;
96
+ /** Checks the address and credentials, and returns the account to keep. */
97
+ connect(input: MediaSourceInput, http: MediaSourceHttp): Promise<MediaSourceAccount>;
98
+ /** Libraries and folders at the root, then their contents. */
99
+ browse(account: MediaSourceAccount, options: MediaSourceBrowseOptions, http: MediaSourceHttp): Promise<MediaSourcePage>;
100
+ /**
101
+ * Lyrics the server holds for a track, as LRC text or plain words, or null when it has none. Servers that keep
102
+ * no lyrics leave this out.
103
+ */
104
+ lyrics?(account: MediaSourceAccount, item: MediaSourceItem, http: MediaSourceHttp): Promise<string | null>;
105
+ }
106
+ /** `https://host:port/path` without a trailing slash; plain http is kept for servers on a local network. */
107
+ export declare function normalizeMediaSourceAddress(address: string): string;
108
+ /** Stable id of an item or container inside an account, so queues and playlists survive a restart. */
109
+ export declare function mediaSourceItemId(accountId: string, remoteId: string): string;
110
+ export declare function parseMediaSourceItemId(id: string): {
111
+ accountId: string;
112
+ remoteId: string;
113
+ } | null;
114
+ /** Ticks used by Jellyfin and Emby (100 ns units) to seconds. */
115
+ export declare function ticksToSeconds(ticks: unknown): number | undefined;
@@ -0,0 +1,12 @@
1
+ export type RepeatMode = 'off' | 'one' | 'all';
2
+ export interface QueueItem<TItem = unknown> {
3
+ id: string;
4
+ item: TItem;
5
+ }
6
+ export interface QueueSnapshot<TItem = unknown> {
7
+ items: QueueItem<TItem>[];
8
+ currentIndex: number;
9
+ shuffle: boolean;
10
+ repeat: RepeatMode;
11
+ history: number[];
12
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Playing on another device of the local network: a DLNA renderer (TV, network speaker), a Chromecast, an AirPlay
3
+ * receiver. Each protocol exposes the same session, so the apps drive a remote device like their own player.
4
+ */
5
+ export type RemotePlaybackKind = 'dlna' | 'chromecast' | 'airplay';
6
+ /** What is sent to the device. The address must be reachable from the device itself, not only from the app. */
7
+ export interface RemotePlaybackMedia {
8
+ url: string;
9
+ contentType: string;
10
+ kind: 'audio' | 'video';
11
+ title: string;
12
+ artist?: string;
13
+ album?: string;
14
+ artworkUrl?: string;
15
+ durationSec?: number;
16
+ /** Position to start from, to continue what the app was playing. */
17
+ startSec?: number;
18
+ /** Radios and live streams: no duration, no seeking. */
19
+ live?: boolean;
20
+ /**
21
+ * A stream the app converts on the fly into a format the device reads. It cannot seek: it starts where it is asked
22
+ * to, at `at(position)`, and the device counts from there.
23
+ */
24
+ conversion?: {
25
+ at(startSec: number): string;
26
+ };
27
+ }
28
+ export type RemotePlayerState = 'idle' | 'loading' | 'buffering' | 'playing' | 'paused' | 'stopped';
29
+ /**
30
+ * Why a device did not play a media, for the apps to explain it in their own words:
31
+ * - `unsupported-format`: the device does not read this format at all; nothing was sent (`format` names it);
32
+ * - `load-failed`: the device tried and gave up (codec it cannot decode, address it cannot reach);
33
+ * - `timeout`: the device did not answer.
34
+ */
35
+ export type RemotePlaybackErrorCode = 'unsupported-format' | 'load-failed' | 'timeout';
36
+ export declare class RemotePlaybackError extends Error {
37
+ readonly code: RemotePlaybackErrorCode;
38
+ readonly format?: string | undefined;
39
+ constructor(code: RemotePlaybackErrorCode, message: string, format?: string | undefined);
40
+ }
41
+ /** The player error code a device failure is reported under: `REMOTE_UNSUPPORTED_FORMAT`, `REMOTE_LOAD_FAILED`… */
42
+ export declare function remotePlaybackErrorCode(code: RemotePlaybackErrorCode): string;
43
+ /**
44
+ * The device failure behind a player error, if it is one: raised when the media was sent (a `RemotePlaybackError`),
45
+ * or reported later by the device while playing (`REMOTE_PLAYBACK`, which means it gave up on the media).
46
+ */
47
+ export declare function remotePlaybackFailure(error: {
48
+ code?: string;
49
+ details?: unknown;
50
+ } | null | undefined): {
51
+ code: RemotePlaybackErrorCode;
52
+ format?: string;
53
+ } | null;
54
+ export interface RemotePlaybackStatus {
55
+ state: RemotePlayerState;
56
+ positionSec?: number;
57
+ durationSec?: number;
58
+ /** 0 to 1. */
59
+ volume?: number;
60
+ /** Set when the device gave up on the media (unreachable address, unsupported format). */
61
+ error?: string;
62
+ /** The media played to its end (devices that tell it apart from a stop). */
63
+ ended?: boolean;
64
+ }
65
+ export interface RemotePlaybackSession {
66
+ readonly kind: RemotePlaybackKind;
67
+ load(media: RemotePlaybackMedia): Promise<void>;
68
+ play(): Promise<void>;
69
+ pause(): Promise<void>;
70
+ seek(positionSec: number): Promise<void>;
71
+ /** 0 to 1. */
72
+ setVolume(level: number): Promise<void>;
73
+ /** Ends playback on the device. */
74
+ stop(): Promise<void>;
75
+ status(): Promise<RemotePlaybackStatus>;
76
+ /** Leaves the device; what it plays keeps playing unless `stop` was called. */
77
+ close(): Promise<void>;
78
+ }
79
+ /** `H:MM:SS` as UPnP and most devices write positions. */
80
+ export declare function formatRemoteClock(seconds: number): string;
81
+ /** `H+:MM:SS[.F+]` to seconds; undefined for "NOT_IMPLEMENTED" and other placeholders. */
82
+ export declare function parseRemoteClock(value: string | undefined): number | undefined;