mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
refactor: add typings
This commit is contained in:
parent
9d3d6a5f9f
commit
3e3e97ee76
32 changed files with 475 additions and 1 deletions
|
|
@ -27,7 +27,7 @@ const comparatorWithPriorities = require('./comparatorWithPriorities');
|
|||
const CONSTANTS = require('./CONSTANTS');
|
||||
const { withCoreSuspender, useCoreSuspender } = require('./CoreSuspender');
|
||||
const getVisibleChildrenRange = require('./getVisibleChildrenRange');
|
||||
const languageNames = require('./languageNames');
|
||||
const languageNames = require('./languageNames.json');
|
||||
const routesRegexp = require('./routesRegexp');
|
||||
const useAnimationFrame = require('./useAnimationFrame');
|
||||
const useBinaryState = require('./useBinaryState');
|
||||
|
|
|
|||
2
src/common/useProfile.d.ts
vendored
Normal file
2
src/common/useProfile.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useProfile: () => Profile;
|
||||
export = useProfile;
|
||||
2
src/common/useStreamingServer.d.ts
vendored
Normal file
2
src/common/useStreamingServer.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useStreamingServer: () => StreamingServer;
|
||||
export = useStreamingServer;
|
||||
2
src/modules.d.ts
vendored
Normal file
2
src/modules.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare module '*';
|
||||
declare module 'classnames';
|
||||
2
src/routes/Addons/useInstalledAddons.d.ts
vendored
Normal file
2
src/routes/Addons/useInstalledAddons.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useInstalledAddons: (urlParams: UrlParams) => InstalledAddons;
|
||||
export = useInstalledAddons;
|
||||
2
src/routes/Addons/useRemoteAddons.d.ts
vendored
Normal file
2
src/routes/Addons/useRemoteAddons.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useRemoteAddons: (urlParams: UrlParams) => RemoteAddons;
|
||||
export = useRemoteAddons;
|
||||
2
src/routes/Board/useBoard.d.ts
vendored
Normal file
2
src/routes/Board/useBoard.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useBoard: () => [Board, ({ start, end }: { start: number, end: number }) => void];
|
||||
export = useBoard;
|
||||
2
src/routes/Discover/useDiscover.d.ts
vendored
Normal file
2
src/routes/Discover/useDiscover.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useDiscover: (urlParams: UrlParams, searchParams: URLSearchParams) => [Discover, () => void];
|
||||
export = useDiscover;
|
||||
2
src/routes/Library/useLibrary.d.ts
vendored
Normal file
2
src/routes/Library/useLibrary.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useLibrary: (model: string, urlParams: UrlParams, searchParams: URLSearchParams) => Library;
|
||||
export = useLibrary;
|
||||
2
src/routes/MetaDetails/useMetaDetails.d.ts
vendored
Normal file
2
src/routes/MetaDetails/useMetaDetails.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useMetaDetails: (urlParams: UrlParams) => MetaDetails;
|
||||
export = useMetaDetails;
|
||||
2
src/routes/Player/usePlayer.d.ts
vendored
Normal file
2
src/routes/Player/usePlayer.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const usePlayer: (urlParams: UrlParams, videoParams: any) => [Player, (time: number, duration: number, device: string) => void, (paused: boolean) => void, () => void, () => void];
|
||||
export = usePlayer;
|
||||
2
src/routes/Player/useSettings.d.ts
vendored
Normal file
2
src/routes/Player/useSettings.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useSettings: () => [Settings, (settings: any) => void];
|
||||
export = useSettings;
|
||||
2
src/routes/Search/useSearch.d.ts
vendored
Normal file
2
src/routes/Search/useSearch.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useSearch: (searchParams: URLSearchParams) => [Search, (range: number) => void];
|
||||
export = useSearch;
|
||||
2
src/services/Core/Core.d.ts
vendored
Normal file
2
src/services/Core/Core.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare function Core(): Core;
|
||||
export = Core;
|
||||
2
src/services/Core/CoreTransport.d.ts
vendored
Normal file
2
src/services/Core/CoreTransport.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare function CoreTransport(): CoreTransport;
|
||||
export = CoreTransport;
|
||||
12
src/services/Core/globals.d.ts
vendored
Normal file
12
src/services/Core/globals.d.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
type CoreEvent = {
|
||||
name: string,
|
||||
args: any[],
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
onCoreEvent: (event: CoreEvent) => void;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
28
src/services/Core/types.d.ts
vendored
Normal file
28
src/services/Core/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
type Action = {
|
||||
action: string,
|
||||
args?: {
|
||||
model?: string,
|
||||
action?: string,
|
||||
args?: any,
|
||||
}
|
||||
};
|
||||
|
||||
type AnalyticsEvent = {
|
||||
event: string,
|
||||
args: object,
|
||||
};
|
||||
|
||||
interface CoreTransport {
|
||||
start: (args: object) => Promise<void>,
|
||||
getState: (model: string) => Promise<object>,
|
||||
dispatch: (action: Action, model?: string) => Promise<void>,
|
||||
decodeStream: (stream: string) => Promise<Stream>,
|
||||
analytics: (event: AnalyticsEvent) => Promise<void>,
|
||||
on: (name: string, listener: () => void) => void,
|
||||
off: (name: string, listener: () => void) => void,
|
||||
}
|
||||
|
||||
interface Core {
|
||||
active: boolean,
|
||||
transport: CoreTransport,
|
||||
}
|
||||
7
src/services/ServicesContext/types.d.ts
vendored
Normal file
7
src/services/ServicesContext/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
type ServicesContext = {
|
||||
core: Core,
|
||||
shell: any,
|
||||
chromecast: any,
|
||||
keyboardShortcuts: any,
|
||||
dragAndDrop: any,
|
||||
};
|
||||
2
src/services/ServicesContext/useServices.d.ts
vendored
Normal file
2
src/services/ServicesContext/useServices.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
declare const useService: () => ServicesContext;
|
||||
export = useService;
|
||||
1
src/types/Board.d.ts
vendored
Normal file
1
src/types/Board.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
type Board = CatalogsWithExtra;
|
||||
7
src/types/CatalogsWithExtra.d.ts
vendored
Normal file
7
src/types/CatalogsWithExtra.d.ts
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
type CatalogsWithExtra = {
|
||||
catalogs: Catalog<Loadable<MetaItem[]>, DiscoverDeepLinks>[] | null,
|
||||
selected: {
|
||||
type: string | null,
|
||||
extra: [string, string][]
|
||||
} | null,
|
||||
};
|
||||
47
src/types/Ctx.d.ts
vendored
Normal file
47
src/types/Ctx.d.ts
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
type Auth = {
|
||||
key: string,
|
||||
user: {
|
||||
_id: string,
|
||||
avatar: string,
|
||||
email: string,
|
||||
trakt: {
|
||||
access_token: string,
|
||||
created_at: number,
|
||||
expires_in: number,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
type Settings = {
|
||||
audioLanguage: string,
|
||||
audioPassthrough: boolean,
|
||||
autoFrameRateMatching: boolean,
|
||||
bingeWatching: boolean,
|
||||
hardwareDecoding: boolean,
|
||||
interfaceLanguage: string,
|
||||
nextVideoNotificationDuration: number,
|
||||
playInBackground: boolean,
|
||||
playerType: string | null,
|
||||
secondaryAudioLanguage: string | null,
|
||||
secondarySubtitlesLanguage: string | null,
|
||||
seekTimeDuration: number,
|
||||
streamingServerUrl: string,
|
||||
streamingServerWarningDismissed: Date | null,
|
||||
subtitlesBackgroundColor: string,
|
||||
subtitlesBold: boolean,
|
||||
subtitlesFont: string,
|
||||
subtitlesLanguage: string,
|
||||
subtitlesOffset: number,
|
||||
subtitlesOutlineColor: string,
|
||||
subtitlesSize: number,
|
||||
subtitlesTextColor: string,
|
||||
};
|
||||
|
||||
type Profile = {
|
||||
auth: Auth | null,
|
||||
settings: Settings,
|
||||
};
|
||||
|
||||
type Ctx = {
|
||||
profile: Profile,
|
||||
};
|
||||
16
src/types/Discover.d.ts
vendored
Normal file
16
src/types/Discover.d.ts
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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,
|
||||
};
|
||||
12
src/types/InstalledAddons.d.ts
vendored
Normal file
12
src/types/InstalledAddons.d.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
type InstalledAddons = {
|
||||
catalog: Addon[],
|
||||
selectable: {
|
||||
catalogs: CatalogOption<AddonsDeepLinks>[],
|
||||
types: TypeOption<AddonsDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: {
|
||||
type: string,
|
||||
}
|
||||
} | null,
|
||||
};
|
||||
24
src/types/Library.d.ts
vendored
Normal file
24
src/types/Library.d.ts
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type LibraryDeepLinks = {
|
||||
library: string,
|
||||
}
|
||||
|
||||
type LibraryPage = {
|
||||
deepLinks: LibraryDeepLinks,
|
||||
} | null;
|
||||
|
||||
type Library = {
|
||||
catalog: LibraryItem[],
|
||||
selectable: {
|
||||
nextPage: LibraryPage,
|
||||
prevPage: LibraryPage,
|
||||
sorts: SortOption<LibraryDeepLinks>[],
|
||||
types: TypeOption<LibraryDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: {
|
||||
page: number,
|
||||
sort: string,
|
||||
type: string | null,
|
||||
}
|
||||
} | null,
|
||||
};
|
||||
20
src/types/MetaDetails.d.ts
vendored
Normal file
20
src/types/MetaDetails.d.ts
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
type MetaDetails = {
|
||||
metaExtensions: {
|
||||
url: string,
|
||||
name: string,
|
||||
addon: Addon,
|
||||
}[],
|
||||
metaItem: {
|
||||
addon: Addon,
|
||||
content: Loadable<MetaItem>,
|
||||
} | null,
|
||||
selected: {
|
||||
metaPath: ResourceRequestPath,
|
||||
streamPath: ResourceRequestPath,
|
||||
} | null,
|
||||
streams: {
|
||||
addon: Addon,
|
||||
content: Loadable<Stream[]>
|
||||
}[],
|
||||
title: string | null,
|
||||
};
|
||||
18
src/types/Player.d.ts
vendored
Normal file
18
src/types/Player.d.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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,
|
||||
};
|
||||
10
src/types/RemoteAddons.d.ts
vendored
Normal file
10
src/types/RemoteAddons.d.ts
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
type RemoteAddons = {
|
||||
catalog: Catalog<Loadable<Addon[]>>,
|
||||
selectable: {
|
||||
catalogs: CatalogOption<AddonsDeepLinks>[],
|
||||
types: TypeOption<AddonsDeepLinks>[],
|
||||
},
|
||||
selected: {
|
||||
request: ResourceRequest,
|
||||
} | null,
|
||||
};
|
||||
1
src/types/Search.d.ts
vendored
Normal file
1
src/types/Search.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
type Search = CatalogsWithExtra;
|
||||
21
src/types/StremingServer.d.ts
vendored
Normal file
21
src/types/StremingServer.d.ts
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
type StreamingServerSettings = {
|
||||
appPath: string,
|
||||
btDownloadSpeedHardLimit: number,
|
||||
btDownloadSpeedSoftLimit: number,
|
||||
btHandshakeTimeout: number,
|
||||
btMaxConnections: number,
|
||||
btMinPeersForStable: number,
|
||||
btRequestTimeout: number,
|
||||
cacheRoot: string,
|
||||
cacheSize: number,
|
||||
serverVersion: string,
|
||||
};
|
||||
|
||||
type StreamingServer = {
|
||||
baseUrl: Loadable<string> | null,
|
||||
selected: {
|
||||
transportUrl: string,
|
||||
} | null,
|
||||
settings: Loadable<StreamingServerSettings> | null,
|
||||
torrent: [string, Loadable<Torrent>] | null,
|
||||
};
|
||||
200
src/types/common.d.ts
vendored
Normal file
200
src/types/common.d.ts
vendored
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
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,
|
||||
}
|
||||
20
tsconfig.json
Normal file
20
tsconfig.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["DOM", "DOM.Iterable"],
|
||||
"jsx": "preserve",
|
||||
"rootDir": "./src",
|
||||
"moduleResolution": "node",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"stremio/*": ["src/*"],
|
||||
},
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"noEmit": true,
|
||||
"strict": false
|
||||
},
|
||||
"include": [
|
||||
"./src",
|
||||
],
|
||||
}
|
||||
Loading…
Reference in a new issue