Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Add Plugin spec #2

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"tabWidth": 4,
"singleQuote": false
"singleQuote": false,
"overrides": [
{
"files": [".prettierrc", "**/*.{json,yaml}"],
"options": {
"tabWidth": 2
}
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@cromefire_/nativeshell-api-definition",
"name": "@cromefire_/nativeshell-api",
"version": "1.0.0",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"license": "Apache-2.0",
"sideEffects": false,
"scripts": {
"build": "tsc -b tsconfig.json",
"lint": "eslint src/**",
Expand Down
47 changes: 43 additions & 4 deletions src/AppHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface IAppHost {
/**
* Return a boolean value indicating if a command is supported in the app.
*
* _For supported commands check: {@link Command}_
* _For supported commands check: [[`Command`]]_
*
* @param command command that should be checked
*/
Expand Down Expand Up @@ -73,109 +73,134 @@ export interface IAppHost {
/**
* Command available
*
* See also: {@link IAppHost.supports}
* See also: [[`IAppHost.supports`]]
*/
export enum Command {
/**
* TODO: Add info
*/
CAST_MENU_HASH_CHANGE = "castmenuhashchange",

/**
* TODO: Add info
*/
CHROMECAST = "chromecast",

/**
* TODO: Add info
*/
DISPLAY_LANGUAGE = "displaylanguage",

/**
* TODO: Add info
*/
DISPLAY_MODE = "displaymode",

/**
* TODO: Add info
*/
EXIT = "exit",

/**
* TODO: Add info
*/
EXTERNAL_LINKS = "externallinks",

/**
* TODO: Add info
*/
EXTERNAL_PLAYER_INTENT = "externalplayerintent",

/**
* TODO: Add info
*/
FILE_DOWNLOAD = "filedownload",

/**
* TODO: Add info
*/
FILE_INPUT = "fileinput",

/**
* TODO: Add info
*/
FULLSCREEN_CHANGE = "fullscreenchange",

/**
* TODO: Add info
*/
HTML_VIDEO_AUTOPLAY = "htmlvideoautoplay",

/**
* TODO: Add info
*/
IMAGE_ANALYSIS = "imageanalysis",

/**
* TODO: Add info
*/
MULTI_SERVER = "multiserver",

/**
* TODO: Add info
*/
PHYSICAL_VOLUME_CONTROL = "physicalvolumecontrol",

/**
* TODO: Add info
*/
REMOTE_AUDIO = "remoteaudio",

/**
* TODO: Add info
*/
REMOTE_CONTROL = "remotecontrol",

/**
* TODO: Add info
*/
REMOTE_VIDEO = "remotevideo",

/**
* TODO: Add info
*/
RUN_AT_STARTUP = "runatstartup",

/**
* TODO: Add info
*/
SCREENSAVER = "screensaver",

/**
* TODO: Add info
*/
SHARING = "sharing",

/**
* TODO: Add info
*/
SKINS = "skins",

/**
* TODO: Add info
*/
SOUNDEFFECTS = "soundeffects",

/**
* TODO: Add info
*/
SUBTITLE_APPEARANCE_SETTINGS = "subtitleappearancesettings",

/**
* TODO: Add info
*/
SUBTITLE_BURN_SETTINGS = "subtitleburnsettings",

/**
* TODO: Add info
*/
SYNC = "sync",

/**
* TODO: Add info
*/
Expand All @@ -185,36 +210,50 @@ export enum Command {
/**
* Available layouts
*
* See also: {@link IAppHost.getDefaultLayout}
* See also: [[`IAppHost.getDefaultLayout`]]
*/
export enum Layout {
/**
* Layout optimized for mobile
*/
MOBILE = "mobile",

/**
* Layout optimized for desktops
*/
DESKTOP = "desktop",

/**
* Layout optimized for TVs
*/
TV = "tv",
}

/**
* Basic info about the app
*
* See also: {@link IAppHost.init}
* See also: [[`IAppHost.init`]]
*/
export interface IAppInfo {
/**
* A unique and persistent device identifier
*/
deviceId: string;

/**
* A display name from the device
*
* _Example: My Phone_
*/
deviceName: string;

/**
* The display name for the app
*
* _Example: Jellyfin for Platform X_
*/
appName: string;

/**
* The version of the App
*
Expand Down
51 changes: 47 additions & 4 deletions src/NativeShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
*/
import { IAppHost } from "./AppHost";
import { IFileSystem } from "./FileSystem";
import { PluginBuilder } from "./plugin";

export interface INativeShell {
/**
* Return an array of require.js module names of plugins.
*/
getPlugins(): string[];
getPlugins(): Array<string | Promise<PluginBuilder>>;

/**
* Provide a method of opening external urls. Alternative to target="_blank" in browsers.
Expand Down Expand Up @@ -65,17 +66,19 @@ export interface INativeShell {
/**
* Information to start a download to the local file system
*
* See also: {@link INativeShell.downloadFile}
* See also: [[`INativeShell.downloadFile`]]
*/
export interface IDownloadInfo {
/**
* The url to download the file from
*/
url: string;

/**
* The title of the file to display to the user (e.g. a Movie title; might no be supported/used on any platform)
*/
title: string;

/**
* The (preferred) filename to save the file as (might no be supported/used on any platform)
*/
Expand All @@ -85,21 +88,24 @@ export interface IDownloadInfo {
/**
* A description of a Server that was discovered automatically
*
* See also: {@link INativeShell.findServers}
* See also: [[`INativeShell.findServers`]]
*/
export interface IDiscoveredServer {
/**
* Id of the server
*/
Id: string;

/**
* Example: `"http://127.0.0.1:8096"`
*/
Address: "http://127.0.0.1:8096";

/**
* Example: `"http://example.com:8096"`
*/
EndpointAddress: string; // This seems to only be used for servers that are not local? Maybe a remnant from Emby Connect?

/**
* Display name of the server
*/
Expand All @@ -109,24 +115,61 @@ export interface IDiscoveredServer {
/**
* Info about the currently playing media
*
* See also: {@link INativeShell.updateMediaSession}
* See also: [[`INativeShell.updateMediaSession`]]
*/
export interface IMediaInfo {
/**
* TODO: Add documentation
*/
action: string;

/**
* TODO: Add documentation
*/
isLocalPlayer: boolean;

/**
* TODO: Add documentation
*/
itemId: string;

/**
* TODO: Add documentation
*/
title: string;

/**
* TODO: Add documentation
*/
artist: string;

/**
* TODO: Add documentation
*/
album: string;

/**
* Float
*/
duration: number;

/**
* Float
*/
position: number;

/**
* TODO: Add documentation
*/
imageUrl: string;

/**
* TODO: Add documentation
*/
canSeek: boolean;

/**
* TODO: Add documentation
*/
isPaused: boolean;
}
14 changes: 14 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Media types available.
*/
export enum MediaType {
/**
* Videos
*/
VIDEO = "Video",

/**
* Audio tracks
*/
AUDIO = "Audio",
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from "./common";
export * from "./NativeShell";
export * from "./AppHost";
export * from "./FileSystem";
export * from "./plugin";
Loading