@eclipse-glsp/theia-integration
Version:
Glue code to integrate GLSP clients into Eclipse Theia
87 lines • 5.02 kB
TypeScript
/********************************************************************************
* Copyright (c) 2020-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Channel, Disposable, MaybePromise } from '@theia/core';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { RawProcess } from '@theia/process/lib/node/raw-process';
import * as net from 'net';
import { WebSocket } from 'ws';
import { WebSocketConnectionInfo } from '../common';
import { BaseGLSPServerContribution, GLSPServerContributionOptions } from './glsp-server-contribution';
/**
* Message that is expected to be printed by the embedded server process to the stdout once the
* server process startup routine has been completed and is ready to accept incoming connections.
*/
export declare const START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed";
export interface GLSPSocketServerContributionOptions extends GLSPServerContributionOptions {
/**
* Path to the location of the server executable that should be launched as process
* Has to be either be a *.jar (Java) or *.js (Node ) file.
*/
executable?: string;
/** Socket connection options for new client connections */
socketConnectionOptions: SocketConnectionOptions;
/** Additional arguments that should be passed when starting the server process. */
additionalArgs?: string[];
}
export type SocketConnectionOptions = net.TcpSocketConnectOpts | WebSocketConnectionInfo;
export declare namespace GLSPSocketServerContributionOptions {
/** Default values for {@link JavaGLSPServerLaunchOptions }**/
function createDefaultOptions(): GLSPSocketServerContributionOptions;
/**
* Utility function to partially set the launch options. Default values (from 'defaultOptions') are used for
* options that are not specified.
* @param options (partial) launch options that should be extended with default values (if necessary)
*/
function configure(options?: Partial<GLSPSocketServerContributionOptions>): GLSPSocketServerContributionOptions;
}
/**
* A reusable base implementation for {@link GLSPServerContribution}s that are using a socket connection to communicate
* with a Java or Node based GLSP server.
**/
export declare abstract class GLSPSocketServerContribution extends BaseGLSPServerContribution {
options: GLSPSocketServerContributionOptions;
protected onReadyDeferred: Deferred<void>;
protected initialize(): void;
abstract createContributionOptions(): Partial<GLSPSocketServerContributionOptions>;
doConnect(clientChannel: Channel): MaybePromise<Disposable>;
launch(): Promise<void>;
protected getPortFromStartupMessage(message: string): number | undefined;
protected launchJavaProcess(): Promise<RawProcess>;
protected getJavaProcessJvmArgs(): string[];
protected launchNodeProcess(): Promise<RawProcess>;
protected processLogInfo(line: string): void;
protected useWebSocket(): boolean;
protected checkServerPort(): void;
protected connectToSocketServer(clientChannel: Channel): Promise<Disposable>;
protected forwardToSocketConnection(clientChannel: Channel, socket: net.Socket): Disposable;
protected connectToWebSocketServer(clientChannel: Channel, webSocketAddress: string | undefined): Promise<Disposable>;
protected forwardToWebSocketConnection(clientChannel: Channel, webSocket: WebSocket): Disposable;
}
/**
* Utility function to parse a server port that is defined via command line arg.
* @param argsKey Name/Key of the commandLine arg
* @param defaultPort Default port that should be returned if no (valid) port was passed via CLI#
* @returns the path value of the given argument if set, default value or `NaN` instead.
*/
export declare function getPort(argsKey: string, defaultPort?: number): number;
/**
* Utility function to parse the WebSocket Server path if the GLSP Server should be started in WebSocket mode.#
* @param argsKey Name/Key of the commandLine arg
* @param defaultPath Default path that should be returned if no path was passed via CLI
* @returns the path value of the given argument if set, default value or `undefined` instead.
*/
export declare function getWebSocketPath(argsKey: string, defaultPath?: string): string | undefined;
//# sourceMappingURL=glsp-socket-server-contribution.d.ts.map