Skip to content

Commit

Permalink
Merge pull request #348 from Stremio/typings
Browse files Browse the repository at this point in the history
Core Typings
  • Loading branch information
jaruba authored May 23, 2023
2 parents 4ffa1a0 + 7804d1a commit 89ae8d5
Show file tree
Hide file tree
Showing 38 changed files with 551 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const comparatorWithPriorities = require('./comparatorWithPriorities');
const CONSTANTS = require('./CONSTANTS');
const { withCoreSuspender, useCoreSuspender } = require('./CoreSuspender');
const getVisibleChildrenRange = require('./getVisibleChildrenRange');
const interfaceLanguages = require('./interfaceLanguages');
const languageNames = require('./languageNames');
const interfaceLanguages = require('./interfaceLanguages.json');
const languageNames = require('./languageNames.json');
const routesRegexp = require('./routesRegexp');
const translateOption = require('./translateOption');
const useAnimationFrame = require('./useAnimationFrame');
Expand Down
2 changes: 2 additions & 0 deletions src/common/useProfile.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useProfile: () => Profile;
export = useProfile;
2 changes: 2 additions & 0 deletions src/common/useStreamingServer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useStreamingServer: () => StreamingServer;
export = useStreamingServer;
2 changes: 2 additions & 0 deletions src/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '*';
declare module 'classnames';
2 changes: 2 additions & 0 deletions src/routes/Addons/useInstalledAddons.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useInstalledAddons: (urlParams: UrlParams) => InstalledAddons;
export = useInstalledAddons;
2 changes: 2 additions & 0 deletions src/routes/Addons/useRemoteAddons.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useRemoteAddons: (urlParams: UrlParams) => RemoteAddons;
export = useRemoteAddons;
2 changes: 2 additions & 0 deletions src/routes/Board/useBoard.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useBoard: () => [Board, ({ start, end }: { start: number, end: number }) => void];
export = useBoard;
2 changes: 2 additions & 0 deletions src/routes/Discover/useDiscover.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useDiscover: (urlParams: UrlParams, searchParams: URLSearchParams) => [Discover, () => void];
export = useDiscover;
2 changes: 2 additions & 0 deletions src/routes/Library/useLibrary.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useLibrary: (model: string, urlParams: UrlParams, searchParams: URLSearchParams) => Library;
export = useLibrary;
2 changes: 2 additions & 0 deletions src/routes/MetaDetails/useMetaDetails.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useMetaDetails: (urlParams: UrlParams) => MetaDetails;
export = useMetaDetails;
2 changes: 2 additions & 0 deletions src/routes/Player/usePlayer.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions src/routes/Player/useSettings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useSettings: () => [Settings, (settings: any) => void];
export = useSettings;
2 changes: 2 additions & 0 deletions src/routes/Search/useSearch.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useSearch: (searchParams: URLSearchParams) => [Search, (range: number) => void];
export = useSearch;
2 changes: 2 additions & 0 deletions src/services/Core/Core.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function Core(): Core;
export = Core;
2 changes: 2 additions & 0 deletions src/services/Core/CoreTransport.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function CoreTransport(): CoreTransport;
export = CoreTransport;
12 changes: 12 additions & 0 deletions src/services/Core/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type CoreEvent = {
name: string,
args: any[],
};

declare global {
interface Window {
onCoreEvent: (event: CoreEvent) => void;
}
}

export {};
28 changes: 28 additions & 0 deletions src/services/Core/types.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions src/services/ServicesContext/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type ServicesContext = {
core: Core,
shell: any,
chromecast: any,
keyboardShortcuts: any,
dragAndDrop: any,
};
2 changes: 2 additions & 0 deletions src/services/ServicesContext/useServices.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const useService: () => ServicesContext;
export = useService;
20 changes: 20 additions & 0 deletions src/types/Addon.d.ts
Original file line number Diff line number Diff line change
@@ -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,
};
34 changes: 34 additions & 0 deletions src/types/LibraryItem.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 32 additions & 0 deletions src/types/MetaItem.d.ts
Original file line number Diff line number Diff line change
@@ -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,
};

type MetaItem = MetaItemPreview & {
videos: Video[],
}

type MetaItemDeepLinks = {
metaDetailsVideos: string | null,
metaDetailsStreams: string | null,
player: string | null,
};
27 changes: 27 additions & 0 deletions src/types/Selectable.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions src/types/Stream.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions src/types/Video.d.ts
Original file line number Diff line number Diff line change
@@ -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[],
};
1 change: 1 addition & 0 deletions src/types/models/Board.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Board = CatalogsWithExtra;
11 changes: 11 additions & 0 deletions src/types/models/CatalogsWithExtra.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type MetaItemPreviewCatalogsWithExtra = MetaItemPreview & {
deepLinks: MetaItemDeepLinks,
};

type CatalogsWithExtra = {
catalogs: Catalog<Loadable<MetaItemPreviewCatalogsWithExtra[]>, DiscoverDeepLinks>[] | null,
selected: {
type: string | null,
extra: [string, string][]
} | null,
};
47 changes: 47 additions & 0 deletions src/types/models/Ctx.d.ts
Original file line number Diff line number Diff line change
@@ -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,
};
26 changes: 26 additions & 0 deletions src/types/models/Discover.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type DiscoverDeepLinks = {
discover: string,
};

type MetaItemPreviewDiscover = MetaItemPreview & {
inLibrary: boolean,
deepLinks: MetaItemDeepLinks,
};

type DiscoverCatalogOption<T> = 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,
};
12 changes: 12 additions & 0 deletions src/types/models/InstalledAddons.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type InstalledAddons = {
catalog: Addon[],
selectable: {
catalogs: SelectableCatalog<AddonsDeepLinks>[],
types: SelectableType<AddonsDeepLinks>[],
},
selected: {
request: {
type: string,
}
} | null,
};
Loading

0 comments on commit 89ae8d5

Please sign in to comment.