Archived
1
0

plugin.d.ts: Add explicit path field and adjust types to reflect

See my discussion with Will in the PR.
This commit is contained in:
Anmol Sethi 2020-11-03 17:09:28 -05:00
parent 8d3a7721fe
commit 6638daf6f0
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB

54
typings/plugin.d.ts vendored
View File

@ -10,7 +10,7 @@ import * as express from "express"
* The homepage of code-server will launch into VS Code. However, there will be an overlay * The homepage of code-server will launch into VS Code. However, there will be an overlay
* button that when clicked, will show all available applications with their names, * button that when clicked, will show all available applications with their names,
* icons and provider plugins. When one clicks on an app's icon, they will be directed * icons and provider plugins. When one clicks on an app's icon, they will be directed
* to <code-server-root>/<plugin-name>/<app-name> to access the application. * to <code-server-root>/<plugin-path>/<app-path> to access the application.
*/ */
/** /**
@ -51,11 +51,35 @@ import * as express from "express"
/** /**
* Your plugin module must implement this interface. * Your plugin module must implement this interface.
* *
* The plugin's name, description and version are fetched from its module's package.json * The plugin's router will be mounted at <code-sever-root>/<plugin-path>
*
* The plugin's router will be mounted at <code-sever-root>/<plugin-name>
*/ */
export interface Plugin { export interface Plugin {
/**
* name is used as the plugin's unique identifier.
* No two plugins may share the same name.
*
* Fetched from package.json.
*/
name?: string
/**
* The version for the plugin in the overlay.
*
* Fetched from package.json.
*/
version?: string
/**
* These two are used in the overlay.
*/
displayName: string
description: string
/**
* The path at which the plugin router is to be registered.
*/
path: string
/** /**
* init is called so that the plugin may initialize itself with the config. * init is called so that the plugin may initialize itself with the config.
*/ */
@ -63,6 +87,8 @@ export interface Plugin {
/** /**
* Returns the plugin's router. * Returns the plugin's router.
*
* Mounted at <code-sever-root>/<plugin-path>
*/ */
router(): express.Router router(): express.Router
@ -90,21 +116,25 @@ export interface PluginConfig {
/** /**
* Application represents a user accessible application. * Application represents a user accessible application.
*
* When the user clicks on the icon in the overlay, they will be
* redirected to <code-server-root>/<plugin-name>/<app-name>
* where the application should be accessible.
*
* If the app's name is the same as the plugin's name then
* <code-server-root>/<plugin-name> will be used instead.
*/ */
export interface Application { export interface Application {
readonly name: string readonly name: string
readonly version: string readonly version: string
/**
* When the user clicks on the icon in the overlay, they will be
* redirected to <code-server-root>/<plugin-path>/<app-path>
* where the application should be accessible.
*
* If undefined, then <code-server-root>/<plugin-path> is used.
*/
readonly path?: string
readonly description?: string
/** /**
* The path at which the icon for this application can be accessed. * The path at which the icon for this application can be accessed.
* <code-server-root>/<plugin-name>/<app-name>/<icon-path> * <code-server-root>/<plugin-path>/<app-path>/<icon-path>
*/ */
readonly iconPath: string readonly iconPath: string
} }