-
Notifications
You must be signed in to change notification settings - Fork 297
Add typescript types #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add typescript types #343
Changes from 5 commits
c1d1b71
bb216c7
297acdd
cd2a081
9352656
909521c
08ffcd6
6caf1aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { | ||
| Manifest, | ||
| AddonInterface, | ||
| Cache, | ||
| MetaPreview, | ||
| MetaDetail, | ||
| Stream, | ||
| Subtitle, | ||
| AddonCatalog, | ||
| DefaultConfig, | ||
| CatalogHandlerArgs, | ||
| MetaHandlerArgs, | ||
| StreamHandlerArgs, | ||
| SubtitlesHandlerArgs, | ||
| AddonCatalogHandlerArgs | ||
| } from './types'; | ||
|
|
||
| /** | ||
| * Creates an addon builder object with a given manifest. | ||
| * | ||
| * The manifest will determine the basic information of your addon (name, description, images), but most importantly, it will determine when and how your addon will be invoked by Stremio. | ||
| * | ||
| * Throws an error if the manifest is not valid. | ||
| */ | ||
| declare class addonBuilder { | ||
| /** | ||
| * Creates an addon builder object with a given manifest. | ||
| */ | ||
| constructor(manifest: Manifest); | ||
|
|
||
| /** | ||
| * Handles catalog requests, including search. | ||
| * | ||
| * Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineCatalogHandler.md | ||
| */ | ||
| defineCatalogHandler<Config = DefaultConfig>(handler: (args: CatalogHandlerArgs<Config>) => Promise<{ metas: MetaPreview[] } & Cache>): this; | ||
|
|
||
| /** | ||
| * Handles metadata requests (title, year, poster, background, etc.). | ||
| * | ||
| * Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineMetaHandler.md | ||
| */ | ||
| defineMetaHandler<Config = DefaultConfig>( | ||
| handler: (args: MetaHandlerArgs<Config>) => Promise<{ meta: MetaDetail } & Cache>, | ||
| ): this; | ||
|
|
||
| /** | ||
| * Handles stream requests. | ||
| * | ||
| * The stream responses should be ordered from highest to lowest quality. | ||
| * | ||
| * Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineStreamHandler.md | ||
| */ | ||
| defineStreamHandler<Config = DefaultConfig>( | ||
| handler: (args: StreamHandlerArgs<Config>) => Promise<{ streams: Stream[] } & Cache>, | ||
| ): this; | ||
|
|
||
| /** | ||
| * Handles subtitle requests. | ||
| * | ||
| * Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineSubtitlesHandler.md | ||
| */ | ||
| defineSubtitlesHandler<Config = DefaultConfig>( | ||
| handler: (args: SubtitlesHandlerArgs<Config>) => Promise<{ subtitles: Subtitle[] } & Cache>, | ||
| ): this; | ||
|
|
||
| /** | ||
| * Handles addon catalog requests | ||
| * | ||
| * As opposed to defineCatalogHandler() which handles meta catalogs, this method handles catalogs of addon manifests. | ||
| * This means that an addon can be used to just pass a list of other addons that can be installed in Stremio. | ||
| * | ||
| * Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineResourceHandler.md | ||
| */ | ||
| defineResourceHandler<Config = DefaultConfig>(resource: string, handler: (args: AddonCatalogHandlerArgs<Config>) => Promise<{ addons: AddonCatalog[] } & Cache>): this; | ||
|
|
||
| /** | ||
| * Turns the addon into an addonInterface, which is an immutable (frozen) object that has {manifest, get} where: | ||
| * | ||
| * * manifest is a regular manifest object | ||
| * * get is a function that takes one argument of the form { resource, type, id, extra } and returns a Promise | ||
| */ | ||
| getInterface(): AddonInterface; | ||
| } | ||
|
|
||
| export = addonBuilder; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { AddonInterface } from './types'; | ||
|
|
||
| /** | ||
| * Turns the addonInterface into an express router that serves the addon according to the protocol and a landing page on the root (/). | ||
| */ | ||
| declare function getRouter(addonInterface: AddonInterface): any; | ||
|
|
||
| export = getRouter; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export { default as addonBuilder } from './builder'; | ||
| export { default as serveHTTP } from './serveHTTP'; | ||
| export { default as getRouter } from './getRouter'; | ||
| export { default as publishToCentral } from './publishToCentral'; | ||
| export { default as landingTemplate } from './landingTemplate'; | ||
| export * from './types'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ module.exports = { | |
| serveHTTP: require('./serveHTTP'), | ||
| getRouter: require('./getRouter'), | ||
| publishToCentral: require('./publishToCentral'), | ||
| landingTemplate: require('./landingTemplate'), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: The EN+ addon, and likely others as well, rely on this function. In the past, I worked around this by importing it directly from |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Manifest } from './types'; | ||
|
|
||
| /** | ||
| * Generates an HTML landing page for the addon. | ||
| * | ||
| * This template creates a web page that displays the addon information and provides | ||
| * an installation button for Stremio. If the addon has configuration options, | ||
| * it will also generate a form for users to configure the addon before installation. | ||
| */ | ||
| declare function landingTemplate(manifest: Manifest): string; | ||
|
|
||
| export = landingTemplate; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /** | ||
| * Publish your addon to the central server. | ||
| * | ||
| * This method expects a string with the url to your manifest.json file. | ||
| * | ||
| * After using this method your addon will be available in the Community Addons list in Stremio for users to install and use. | ||
| * Please note that your addon needs to be publicly available with a URL in order for this to happen, as local addons that are not publicly available cannot be used by other Stremio users. | ||
| */ | ||
| declare function publishToCentral(url: string, apiURL?: string): Promise<any>; | ||
|
|
||
| export = publishToCentral; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { AddonInterface } from './types'; | ||
|
|
||
| /** | ||
| * Starts the addon server | ||
| * | ||
| * This method is also special in that it will react to certain process arguments, such as: | ||
| * * --launch: launches Stremio in the web browser, and automatically installs/upgrades the addon | ||
| * * --install: installs the addon in the desktop version of Stremio | ||
| */ | ||
| declare function serveHTTP( | ||
| addonInterface: AddonInterface, | ||
| options?: { | ||
| port?: number | undefined; | ||
| /** | ||
| * (in seconds) cacheMaxAge means the Cache-Control header being set to max-age=$cacheMaxAge | ||
| */ | ||
| cacheMaxAge?: number | undefined; | ||
| /** | ||
| * Static directory to serve. | ||
| */ | ||
| static?: string | undefined; | ||
| }, | ||
| ): void; | ||
sleeyax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export = serveHTTP; | ||
Uh oh!
There was an error while loading. Please reload this page.