-
-
diff --git a/test/unit/node/test-plugin/src/index.ts b/test/unit/node/test-plugin/src/index.ts
deleted file mode 100644
index 22ef723bac1a..000000000000
--- a/test/unit/node/test-plugin/src/index.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import * as cs from "code-server"
-import * as fspath from "path"
-
-export const plugin: cs.Plugin = {
- displayName: "Test Plugin",
- routerPath: "/test-plugin",
- homepageURL: "https://example.com",
- description: "Plugin used in code-server tests.",
-
- init(config) {
- config.logger.debug("test-plugin loaded!")
- },
-
- router() {
- const r = cs.express.Router()
- r.get("/test-app", (_, res) => {
- res.sendFile(fspath.resolve(__dirname, "../public/index.html"))
- })
- r.get("/goland/icon.svg", (_, res) => {
- res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
- })
- r.get("/error", () => {
- throw new cs.HttpError("error", cs.HttpCode.LargePayload)
- })
- return r
- },
-
- wsRouter() {
- const wr = cs.WsRouter()
- wr.ws("/test-app", (req) => {
- cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => {
- req.ws.resume()
- ws.send("hello")
- })
- })
- return wr
- },
-
- applications() {
- return [
- {
- name: "Test App",
- version: "4.0.1",
- iconPath: "/icon.svg",
- path: "/test-app",
-
- description: "This app does XYZ.",
- homepageURL: "https://example.com",
- },
- ]
- },
-}
diff --git a/test/unit/node/test-plugin/tsconfig.json b/test/unit/node/test-plugin/tsconfig.json
deleted file mode 100644
index 194af1418df9..000000000000
--- a/test/unit/node/test-plugin/tsconfig.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "compilerOptions": {
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
-
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- // "lib": [], /* Specify library files to be included in the compilation. */
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- // "declaration": true, /* Generates corresponding '.d.ts' file. */
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- "outDir": "./out" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
-
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
-
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
-
- /* Module Resolution Options */
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
- "baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
- "paths": {
- "code-server": ["../../../../typings/pluginapi"]
- } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
-
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
-
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
-
- /* Advanced Options */
- "skipLibCheck": true /* Skip type checking of declaration files. */,
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
- }
-}
diff --git a/typings/pluginapi.d.ts b/typings/pluginapi.d.ts
deleted file mode 100644
index 829709b2d163..000000000000
--- a/typings/pluginapi.d.ts
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * This file describes the code-server plugin API for adding new applications.
- */
-import { field, Level, Logger } from "@coder/logger"
-import * as express from "express"
-import * as expressCore from "express-serve-static-core"
-import ProxyServer from "http-proxy"
-import * as stream from "stream"
-import Websocket from "ws"
-
-/**
- * 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,
- * icons and provider plugins. When one clicks on an app's icon, they will be directed
- * to // to access the application.
- */
-
-/**
- * Plugins
- *
- * Plugins are just node modules that contain a top level export "plugin" that implements
- * the Plugin interface.
- *
- * 1. code-server uses $CS_PLUGIN to find plugins.
- *
- * e.g. CS_PLUGIN=/tmp/will:/tmp/teffen will cause code-server to load
- * /tmp/will and /tmp/teffen as plugins.
- *
- * 2. code-server uses $CS_PLUGIN_PATH to find plugins. Each subdirectory in
- * $CS_PLUGIN_PATH with a package.json where the engine is code-server is
- * a valid plugin.
- *
- * e.g. CS_PLUGIN_PATH=/tmp/nhooyr:/tmp/ash will cause code-server to search
- * /tmp/nhooyr and then /tmp/ash for plugins.
- *
- * CS_PLUGIN_PATH defaults to
- * ~/.local/share/code-server/plugins:/usr/share/code-server/plugins
- * if unset.
- *
- *
- * 3. Built in plugins are loaded from __dirname/../plugins
- *
- * Plugins are required as soon as they are found and then initialized.
- * See the Plugin interface for details.
- *
- * If two plugins are found with the exact same name, then code-server will
- * use the first one and emit a warning.
- *
- */
-
-/**
- * Programmability
- *
- * There is also a /api/applications endpoint to allow programmatic access to all
- * available applications. It could be used to create a custom application dashboard
- * for example. An important difference with the API is that all application paths
- * will be absolute (i.e have the plugin path prepended) so that they may be used
- * directly.
- *
- * Example output:
- *
- * [
- * {
- * "name": "Test App",
- * "version": "4.0.1",
- * "iconPath": "/test-plugin/test-app/icon.svg",
- * "path": "/test-plugin/test-app",
- * "description": "This app does XYZ.",
- * "homepageURL": "https://example.com",
- * "plugin": {
- * "name": "test-plugin",
- * "version": "1.0.0",
- * "modulePath": "/Users/nhooyr/src/coder/code-server/test/test-plugin",
- * "displayName": "Test Plugin",
- * "description": "Plugin used in code-server tests.",
- * "routerPath": "/test-plugin",
- * "homepageURL": "https://example.com"
- * }
- * }
- * ]
- */
-
-export enum HttpCode {
- Ok = 200,
- Redirect = 302,
- NotFound = 404,
- BadRequest = 400,
- Unauthorized = 401,
- LargePayload = 413,
- ServerError = 500,
-}
-
-export declare class HttpError extends Error {
- constructor(message: string, status: HttpCode, details?: object)
-}
-
-export interface WebsocketRequest extends express.Request {
- ws: stream.Duplex
- head: Buffer
-}
-
-export type WebSocketHandler = (
- req: WebsocketRequest,
- res: express.Response,
- next: express.NextFunction,
-) => void | Promise
-
-export interface WebsocketRouter {
- readonly router: express.Router
- ws(route: expressCore.PathParams, ...handlers: WebSocketHandler[]): void
-}
-
-/**
- * Create a router for websocket routes.
- */
-export function WsRouter(): WebsocketRouter
-
-/**
- * The websocket server used by code-server.
- */
-export const wss: Websocket.Server
-
-/**
- * The Express import used by code-server.
- *
- * Re-exported so plugins don't have to import duplicate copies of Express and
- * to avoid potential version differences or issues caused by running separate
- * instances.
- */
-export { express }
-/**
- * Use to add a field to a log.
- *
- * Re-exported so plugins don't have to import duplicate copies of the logger.
- */
-export { field, Level, Logger }
-
-/**
- * code-server's proxy server.
- */
-export const proxy: ProxyServer
-
-/**
- * Middleware to ensure the user is authenticated. Throws if they are not.
- */
-export function ensureAuthenticated(
- req: express.Request,
- res?: express.Response,
- next?: express.NextFunction,
-): Promise
-
-/**
- * Returns true if the user is authenticated.
- */
-export function authenticated(req: express.Request): Promise
-
-/**
- * Replace variables in HTML: TO, BASE, CS_STATIC_BASE, and OPTIONS.
- */
-export function replaceTemplates(
- req: express.Request,
- content: string,
- extraOpts?: Omit,
-): string
-
-/**
- * Your plugin module must have a top level export "plugin" that implements this interface.
- *
- * The plugin's router will be mounted at /
- */
-export interface Plugin {
- /**
- * name is used as the plugin's unique identifier.
- * No two plugins may share the same name.
- *
- * Fetched from package.json.
- */
- readonly name?: string
-
- /**
- * The version for the plugin in the overlay.
- *
- * Fetched from package.json.
- */
- readonly version?: string
-
- /**
- * Name used in the overlay.
- */
- readonly displayName: string
-
- /**
- * Used in overlay.
- * Should be a full sentence describing the plugin.
- */
- readonly description: string
-
- /**
- * The path at which the plugin router is to be registered.
- */
- readonly routerPath: string
-
- /**
- * Link to plugin homepage.
- */
- readonly homepageURL: string
-
- /**
- * init is called so that the plugin may initialize itself with the config.
- */
- init(config: PluginConfig): void
-
- /**
- * Called when the plugin should dispose/shutdown everything.
- */
- deinit?(): Promise
-
- /**
- * Returns the plugin's router.
- *
- * Mounted at /
- *
- * If not present, the plugin provides no routes.
- */
- router?(): express.Router
-
- /**
- * Returns the plugin's websocket router.
- *
- * Mounted at /
- *
- * If not present, the plugin provides no websockets.
- */
- wsRouter?(): WebsocketRouter
-
- /**
- * code-server uses this to collect the list of applications that
- * the plugin can currently provide.
- * It is called when /api/applications is hit or the overlay needs to
- * refresh the list of applications
- *
- * Ensure this is as fast as possible.
- *
- * If not present, the plugin provides no applications.
- */
- applications?(): Application[] | Promise
-}
-
-/**
- * PluginConfig contains the configuration required for initializing
- * a plugin.
- */
-export interface PluginConfig {
- /**
- * All plugin logs should be logged via this logger.
- */
- readonly logger: Logger
-
- /**
- * This can be specified by the user on the command line. Plugins should
- * default to this directory when applicable. For example, the Jupyter plugin
- * uses this to launch in this directory.
- */
- readonly workingDirectory?: string
-}
-
-/**
- * Application represents a user accessible application.
- */
-export interface Application {
- readonly name: string
- readonly version: string
-
- /**
- * When the user clicks on the icon in the overlay, they will be
- * redirected to //
- * where the application should be accessible.
- *
- * If undefined, then / is used.
- */
- readonly path?: string
-
- readonly description?: string
-
- /**
- * The path at which the icon for this application can be accessed.
- * ///
- */
- readonly iconPath: string
-
- /**
- * Link to application homepage.
- */
- readonly homepageURL: string
-}