mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 10:42:12 +00:00
refactor: improve typings
This commit is contained in:
parent
3e3e97ee76
commit
2483583454
22 changed files with 324 additions and 249 deletions
20
src/types/Addon.d.ts
vendored
Normal file
20
src/types/Addon.d.ts
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
type AddonManifest = {
|
||||
id: string,
|
||||
version: string,
|
||||
name: string,
|
||||
description: string,
|
||||
contactEmail: string,
|
||||
logo: string,
|
||||
background: string,
|
||||
types: string[],
|
||||
};
|
||||
|
||||
type Addon = {
|
||||
installed: boolean,
|
||||
manifest: AddonManifest,
|
||||
transportUrl: string,
|
||||
};
|
||||
|
||||
type AddonsDeepLinks = {
|
||||
addons: string,
|
||||
};
|
||||
7
src/types/CatalogsWithExtra.d.ts
vendored
7
src/types/CatalogsWithExtra.d.ts
vendored
|
|
@ -1,7 +0,0 @@
|
|||
type CatalogsWithExtra = {
|
||||
catalogs: Catalog<Loadable<MetaItem[]>, DiscoverDeepLinks>[] | null,
|
||||
selected: {
|
||||
type: string | null,
|
||||
extra: [string, string][]
|
||||
} | null,
|
||||
};
|
||||
16
src/types/Discover.d.ts
vendored
16
src/types/Discover.d.ts
vendored
|
|
@ -1,16 +0,0 @@
|
|||
type DiscoverDeepLinks = {
|
||||
discover: string,
|
||||
};
|
||||
|
||||
type Discover = {
|
||||
catalog: Catalog<Loadable<MetaItem[]>> | null,
|
||||
selectable: {
|
||||
catalogs: DiscoverCatalogOption<DiscoverDeepLinks>,
|
||||
extra: ExtraOption<DiscoverDeepLinks>[],
|
||||
types: TypeOption<DiscoverDeepLinks>[],
|
||||
nextPage: boolean,
|
||||
},
|
||||
selected: {
|
||||
request: ResourceRequest,
|
||||
} | null,
|
||||
};
|
||||
34
src/types/LibraryItem.d.ts
vendored
Normal file
34
src/types/LibraryItem.d.ts
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
type LibraryItemState = {
|
||||
lastWatched: string,
|
||||
timeWatched: number,
|
||||
timesWatched: number,
|
||||
flaggedWatched: number,
|
||||
overallTimeWatched: number,
|
||||
timeOffset: number,
|
||||
duration: number,
|
||||
video_id: string,
|
||||
watched: string,
|
||||
lastVidReleased: string,
|
||||
noNotif: boolean,
|
||||
};
|
||||
|
||||
type LibraryItem = {
|
||||
_id: string,
|
||||
name: string,
|
||||
type: string,
|
||||
poster: string,
|
||||
posterShape: PosterShape,
|
||||
removed: number,
|
||||
temp: number,
|
||||
_ctime: string,
|
||||
_mtime: number,
|
||||
state: LibraryItemState,
|
||||
behaviorHints: BehaviorHints,
|
||||
};
|
||||
|
||||
type LibraryItemDeepLinks = {
|
||||
metaDetailsVideos: string | null,
|
||||
metaDetailsStreams: string | null,
|
||||
player: string | null,
|
||||
externalPlayer: ExternalPlayerLinks | null,
|
||||
};
|
||||
32
src/types/MetaItem.d.ts
vendored
Normal file
32
src/types/MetaItem.d.ts
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
type Link = {
|
||||
name: string,
|
||||
category: string,
|
||||
url: string,
|
||||
};
|
||||
|
||||
type MetaItemPreview = {
|
||||
id: string,
|
||||
type: string,
|
||||
name: string,
|
||||
description: string | null,
|
||||
logo: string | null,
|
||||
background: string | null,
|
||||
poster: string | null,
|
||||
posterShape: PosterShape,
|
||||
releaseInfo: string | null,
|
||||
runtime: string | null,
|
||||
released: string | null,
|
||||
trailerStreams: TrailerStream[],
|
||||
links: Link[],
|
||||
behaviorHints: BehaviorHints,
|
||||
};
|
||||
|
||||
interface MetaItem extends MetaItemPreview {
|
||||
videos: Video[],
|
||||
}
|
||||
|
||||
type MetaItemDeepLinks = {
|
||||
metaDetailsVideos: string | null,
|
||||
metaDetailsStreams: string | null,
|
||||
player: string | null,
|
||||
};
|
||||
18
src/types/Player.d.ts
vendored
18
src/types/Player.d.ts
vendored
|
|
@ -1,18 +0,0 @@
|
|||
type Player = {
|
||||
addon: Addon | null,
|
||||
libraryItem: LibraryItem | null,
|
||||
metaItem: Loadable<MetaItem> | null,
|
||||
nextVideo: Video | null,
|
||||
selected: {
|
||||
stream: Stream,
|
||||
metaRequest: ResourceRequest,
|
||||
streamRequest: ResourceRequest,
|
||||
subtitlesPath: ResourceRequestPath,
|
||||
} | null,
|
||||
seriesInfo: {
|
||||
season: number,
|
||||
episode: number,
|
||||
} | null,
|
||||
subtitles: Subtitle[],
|
||||
title: string | null,
|
||||
};
|
||||
27
src/types/Selectable.d.ts
vendored
Normal file
27
src/types/Selectable.d.ts
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
type SelectableType<T> = {
|
||||
type: string,
|
||||
selected: boolean,
|
||||
deepLinks: T
|
||||
};
|
||||
|
||||
type SelectableSort<T> = {
|
||||
sort: string,
|
||||
selected: boolean,
|
||||
deepLinks: T
|
||||
};
|
||||
|
||||
type SelectableExtra<T> = {
|
||||
isRequired: boolean,
|
||||
name: string,
|
||||
options: {
|
||||
deepLinks: T,
|
||||
selected: boolean,
|
||||
value: string | null,
|
||||
}
|
||||
};
|
||||
|
||||
type SelectableCatalog<T> = {
|
||||
name: string,
|
||||
selected: boolean,
|
||||
deepLinks: T,
|
||||
};
|
||||
18
src/types/Stream.d.ts
vendored
Normal file
18
src/types/Stream.d.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
type StreamDeepLinks = {
|
||||
player: string | null,
|
||||
externalPlayer: ExternalPlayerLinks,
|
||||
}
|
||||
|
||||
type Stream = {
|
||||
ytId?: string,
|
||||
name: string,
|
||||
description: string,
|
||||
infoHash?: string,
|
||||
fileIdx?: string,
|
||||
externalUrl?: string,
|
||||
deepLinks: {
|
||||
player: string,
|
||||
externalPlayer: ExternalPlayerLinks,
|
||||
},
|
||||
};
|
||||
17
src/types/Video.d.ts
vendored
Normal file
17
src/types/Video.d.ts
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
type VideoDeepLinks = {
|
||||
metaDetailsStreams: string,
|
||||
player: string | null,
|
||||
externalPlayer: ExternalPlayerLinks | null,
|
||||
};
|
||||
|
||||
type Video = {
|
||||
id: string,
|
||||
title: string,
|
||||
overview: string | null,
|
||||
released: string | null,
|
||||
thumbnail: string | null,
|
||||
season?: number,
|
||||
episode?: number,
|
||||
streams: Stream[],
|
||||
trailerStreams: TrailerStream[],
|
||||
};
|
||||
200
src/types/common.d.ts
vendored
200
src/types/common.d.ts
vendored
|
|
@ -1,200 +0,0 @@
|
|||
interface UrlParams extends Record<string, string> {
|
||||
path: string,
|
||||
}
|
||||
|
||||
type LoadableError = string | {
|
||||
type: string,
|
||||
content: {
|
||||
code: number,
|
||||
message: string,
|
||||
}
|
||||
};
|
||||
|
||||
type Loadable<T> = {
|
||||
type: 'Ready' | 'Loading' | 'Err',
|
||||
content: T | LoadableError,
|
||||
};
|
||||
|
||||
type ResourceRequestPath = {
|
||||
id: string,
|
||||
type: string,
|
||||
resource: string,
|
||||
extra: [string, string][]
|
||||
};
|
||||
|
||||
type ResourceRequest = {
|
||||
base: string,
|
||||
path: ResourceRequestPath,
|
||||
};
|
||||
|
||||
type ExternalPlayerDeepLinks = {
|
||||
androidTv: string | null,
|
||||
download: string | null,
|
||||
fileName: string | null,
|
||||
href: string | null,
|
||||
tizen: string | null,
|
||||
webos: string | null,
|
||||
};
|
||||
|
||||
type AddonsDeepLinks = {
|
||||
addons: string,
|
||||
};
|
||||
|
||||
type Torrent = [
|
||||
{
|
||||
extra: any[],
|
||||
id: string,
|
||||
resource: string,
|
||||
type: string,
|
||||
},
|
||||
{
|
||||
metaDetailsStreams: string | null,
|
||||
metaDetailsVideos: string | null,
|
||||
player: string | null,
|
||||
}
|
||||
];
|
||||
|
||||
type Subtitle = {
|
||||
id: string,
|
||||
lang: string,
|
||||
origin: string,
|
||||
url: string,
|
||||
};
|
||||
|
||||
type Addon = {
|
||||
installed: boolean,
|
||||
manifest: {
|
||||
id: string,
|
||||
types: string[],
|
||||
name: string,
|
||||
description: string,
|
||||
version: string,
|
||||
logo: string | null,
|
||||
background: string | null,
|
||||
},
|
||||
transportUrl: string,
|
||||
};
|
||||
|
||||
type Stream = {
|
||||
ytId?: string,
|
||||
name: string,
|
||||
description: string,
|
||||
infoHash?: string,
|
||||
fileIdx?: string,
|
||||
externalUrl?: string,
|
||||
deepLinks: {
|
||||
player: string,
|
||||
externalPlayer: ExternalPlayerDeepLinks,
|
||||
},
|
||||
};
|
||||
|
||||
type TrailerStream = {
|
||||
ytId: string,
|
||||
description: string,
|
||||
deepLinks: {
|
||||
player: string,
|
||||
externalPlayer: ExternalPlayerDeepLinks,
|
||||
},
|
||||
};
|
||||
|
||||
type Video = {
|
||||
id: string,
|
||||
title: string,
|
||||
overview: string,
|
||||
released: string,
|
||||
thumbnail: string,
|
||||
season?: number,
|
||||
episode?: number,
|
||||
watched: boolean,
|
||||
deepLinks: {
|
||||
externalPlayer: ExternalPlayerDeepLinks | null,
|
||||
metaDetailsStreams: string | null,
|
||||
player: string | null,
|
||||
}
|
||||
};
|
||||
|
||||
type Link = {
|
||||
name: string,
|
||||
category: string,
|
||||
url: string,
|
||||
};
|
||||
|
||||
type Item = {
|
||||
type: string,
|
||||
name: string,
|
||||
poster: string,
|
||||
posterShape: string,
|
||||
};
|
||||
|
||||
interface LibraryItem extends Item {
|
||||
_id: string,
|
||||
progress: number,
|
||||
state: {
|
||||
timeOffset: number,
|
||||
video_id: string,
|
||||
},
|
||||
}
|
||||
|
||||
interface MetaItem extends Item {
|
||||
id: string,
|
||||
description: string,
|
||||
logo: string,
|
||||
background: string,
|
||||
releaseInfo: string,
|
||||
released: string,
|
||||
runtime: string,
|
||||
videos: Video[],
|
||||
trailerStreams: TrailerStream[],
|
||||
links: Link[],
|
||||
inLibrary: boolean,
|
||||
watched: boolean,
|
||||
deepLinks: {
|
||||
metaDetailsStreams: string | null,
|
||||
metaDetailsVideos: string | null,
|
||||
player: string | null,
|
||||
}
|
||||
}
|
||||
|
||||
type Catalog<T, D = any> = {
|
||||
title?: string,
|
||||
content: T,
|
||||
installed?: boolean,
|
||||
deepLinks?: D,
|
||||
};
|
||||
|
||||
type TypeOption<T> = {
|
||||
type: string,
|
||||
selected: boolean,
|
||||
deepLinks: T
|
||||
};
|
||||
|
||||
type SortOption<T> = {
|
||||
sort: string,
|
||||
selected: boolean,
|
||||
deepLinks: T
|
||||
};
|
||||
|
||||
type ExtraOption<T> = {
|
||||
isRequired: boolean,
|
||||
name: string,
|
||||
options: {
|
||||
deepLinks: T,
|
||||
selected: boolean,
|
||||
value: string | null,
|
||||
}
|
||||
};
|
||||
|
||||
type CatalogOption<T> = {
|
||||
name: string,
|
||||
selected: boolean,
|
||||
deepLinks: T,
|
||||
};
|
||||
|
||||
interface DiscoverCatalogOption<T> extends CatalogOption<T> {
|
||||
id: string,
|
||||
addon: Addon,
|
||||
}
|
||||
|
||||
interface AddonCatalogOption<T> extends CatalogOption<T> {
|
||||
id?: string,
|
||||
}
|
||||
11
src/types/models/CatalogsWithExtra.d.ts
vendored
Normal file
11
src/types/models/CatalogsWithExtra.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
interface MetaItemPreviewCatalogsWithExtra extends MetaItemPreview {
|
||||
deepLinks: MetaItemDeepLinks,
|
||||
}
|
||||
|
||||
type CatalogsWithExtra = {
|
||||
catalogs: Catalog<Loadable<MetaItemPreviewCatalogsWithExtra[]>, DiscoverDeepLinks>[] | null,
|
||||
selected: {
|
||||
type: string | null,
|
||||
extra: [string, string][]
|
||||
} | null,
|
||||
};
|
||||
26
src/types/models/Discover.d.ts
vendored
Normal file
26
src/types/models/Discover.d.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
type DiscoverDeepLinks = {
|
||||
discover: string,
|
||||
};
|
||||
|
||||
interface MetaItemPreviewDiscover extends MetaItemPreview {
|
||||
inLibrary: boolean,
|
||||
deepLinks: MetaItemDeepLinks,
|
||||
}
|
||||
|
||||
interface DiscoverCatalogOption<T> extends SelectableCatalog<T> {
|
||||
id: string,
|
||||
addon: Addon,
|
||||
}
|
||||
|
||||
type Discover = {
|
||||
catalog: Catalog<Loadable<MetaItemPreviewDiscover[]>> | null,
|
||||
selectable: {
|
||||
catalogs: DiscoverCatalogOption<DiscoverDeepLinks>,
|
||||
extra: SelectableExtra<DiscoverDeepLinks>[],
|
||||
types: SelectableType<DiscoverDeepLinks>[],
|
||||
nextPage: boolean,
|
||||
},
|
||||
selected: {
|
||||
request: ResourceRequest,
|
||||
} | null,
|
||||
};
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
type InstalledAddons = {
|
||||
catalog: Addon[],
|
||||
selectable: {
|
||||
catalogs: CatalogOption<AddonsDeepLinks>[],
|
||||
types: TypeOption<AddonsDeepLinks>[],
|
||||
catalogs: SelectableCatalog<AddonsDeepLinks>[],
|
||||
types: SelectableType<AddonsDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: {
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
interface LibraryItemLibrary extends LibraryItem {
|
||||
progress: number,
|
||||
deepLinks: LibraryItemDeepLinks,
|
||||
}
|
||||
|
||||
type LibraryDeepLinks = {
|
||||
library: string,
|
||||
}
|
||||
|
|
@ -7,12 +12,12 @@ type LibraryPage = {
|
|||
} | null;
|
||||
|
||||
type Library = {
|
||||
catalog: LibraryItem[],
|
||||
catalog: LibraryItemLibrary[],
|
||||
selectable: {
|
||||
nextPage: LibraryPage,
|
||||
prevPage: LibraryPage,
|
||||
sorts: SortOption<LibraryDeepLinks>[],
|
||||
types: TypeOption<LibraryDeepLinks>[],
|
||||
sorts: SelectableSort<LibraryDeepLinks>[],
|
||||
types: SelectableType<LibraryDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: {
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
interface MetaItemMetaDetails extends MetaItem {
|
||||
inLibrary: boolean,
|
||||
watched: boolean,
|
||||
deepLinks: MetaItemDeepLinks,
|
||||
}
|
||||
|
||||
type MetaDetails = {
|
||||
metaExtensions: {
|
||||
url: string,
|
||||
|
|
@ -6,7 +12,7 @@ type MetaDetails = {
|
|||
}[],
|
||||
metaItem: {
|
||||
addon: Addon,
|
||||
content: Loadable<MetaItem>,
|
||||
content: Loadable<MetaItemMetaDetails>,
|
||||
} | null,
|
||||
selected: {
|
||||
metaPath: ResourceRequestPath,
|
||||
45
src/types/models/Player.d.ts
vendored
Normal file
45
src/types/models/Player.d.ts
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
interface PlayerVideo extends Video {
|
||||
upcomming: boolean,
|
||||
watched: boolean,
|
||||
progress: boolean | null,
|
||||
scheduled: boolean,
|
||||
deepLinks: VideoDeepLinks,
|
||||
}
|
||||
|
||||
interface PlayerMetaItem extends Video {
|
||||
videos: PlayerVideo[],
|
||||
}
|
||||
|
||||
interface NextVideo extends Video {
|
||||
deepLinks: VideoDeepLinks,
|
||||
}
|
||||
|
||||
interface SelectedStream extends Stream {
|
||||
deepLinks: StreamDeepLinks,
|
||||
}
|
||||
|
||||
type Subtitle = {
|
||||
id: string,
|
||||
lang: string,
|
||||
origin: string,
|
||||
url: string,
|
||||
};
|
||||
|
||||
type Player = {
|
||||
addon: Addon | null,
|
||||
libraryItem: LibraryItem | null,
|
||||
metaItem: Loadable<PlayerMetaItem> | null,
|
||||
nextVideo: NextVideo | null,
|
||||
selected: {
|
||||
stream: SelectedStream,
|
||||
metaRequest: ResourceRequest,
|
||||
streamRequest: ResourceRequest,
|
||||
subtitlesPath: ResourceRequestPath,
|
||||
} | null,
|
||||
seriesInfo: {
|
||||
season: number,
|
||||
episode: number,
|
||||
} | null,
|
||||
subtitles: Subtitle[],
|
||||
title: string | null,
|
||||
};
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
type RemoteAddons = {
|
||||
catalog: Catalog<Loadable<Addon[]>>,
|
||||
selectable: {
|
||||
catalogs: CatalogOption<AddonsDeepLinks>[],
|
||||
types: TypeOption<AddonsDeepLinks>[],
|
||||
catalogs: SelectableCatalog<AddonsDeepLinks>[],
|
||||
types: SelectableType<AddonsDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: ResourceRequest,
|
||||
|
|
@ -1,3 +1,17 @@
|
|||
type Torrent = [
|
||||
{
|
||||
extra: any[],
|
||||
id: string,
|
||||
resource: string,
|
||||
type: string,
|
||||
},
|
||||
{
|
||||
metaDetailsStreams: string | null,
|
||||
metaDetailsVideos: string | null,
|
||||
player: string | null,
|
||||
}
|
||||
];
|
||||
|
||||
type StreamingServerSettings = {
|
||||
appPath: string,
|
||||
btDownloadSpeedHardLimit: number,
|
||||
61
src/types/types.d.ts
vendored
Normal file
61
src/types/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
interface UrlParams extends Record<string, string> {
|
||||
path: string,
|
||||
}
|
||||
|
||||
type LoadableError = string | {
|
||||
type: string,
|
||||
content: {
|
||||
code: number,
|
||||
message: string,
|
||||
}
|
||||
};
|
||||
|
||||
type Loadable<T> = {
|
||||
type: 'Ready' | 'Loading' | 'Err',
|
||||
content: T | LoadableError,
|
||||
};
|
||||
|
||||
type ResourceRequestPath = {
|
||||
id: string,
|
||||
type: string,
|
||||
resource: string,
|
||||
extra: [string, string][]
|
||||
};
|
||||
|
||||
type ResourceRequest = {
|
||||
base: string,
|
||||
path: ResourceRequestPath,
|
||||
};
|
||||
|
||||
type ExternalPlayerLinks = {
|
||||
androidTv: string | null,
|
||||
download: string | null,
|
||||
fileName: string | null,
|
||||
href: string | null,
|
||||
tizen: string | null,
|
||||
webos: string | null,
|
||||
};
|
||||
|
||||
type TrailerStream = {
|
||||
ytId: string,
|
||||
description: string,
|
||||
deepLinks: {
|
||||
player: string,
|
||||
externalPlayer: ExternalPlayerLinks,
|
||||
},
|
||||
};
|
||||
|
||||
type BehaviorHints = {
|
||||
defaultVideoId: string | null,
|
||||
featuredVideoId: string | null,
|
||||
hasScheduledVideos: boolean,
|
||||
};
|
||||
|
||||
type PosterShape = 'square' | 'landscape' | 'poster' | null;
|
||||
|
||||
type Catalog<T, D = any> = {
|
||||
title?: string,
|
||||
content: T,
|
||||
installed?: boolean,
|
||||
deepLinks?: D,
|
||||
};
|
||||
Loading…
Reference in a new issue