Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-glsp/protocol

Package Overview
Dependencies
Maintainers
5
Versions
297
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-glsp/protocol - npm Package Compare versions

Comparing version 0.9.0-next.3d174f20 to 0.9.0-next.45db2ab6

105

lib/glsp-client.d.ts
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 EclipseSource and others.
*

@@ -16,3 +16,15 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import { ActionMessage } from 'sprotty';
/**
* A key-value pair structure for primitive typed custom arguments.
*/
export interface Args {
[key: string]: string | number | boolean;
}
/**
* A key-value pair structure to map a diagramType to its server-handled action kinds.
*/
export interface ServerActions {
[key: string]: string[];
}
export interface InitializeParameters {

@@ -24,6 +36,47 @@ /**

/**
* Options that can include application-specific parameters.
* GLSP protocol version that this client is implementing.
*/
options?: any;
protocolVersion: string;
/**
* Additional custom arguments e.g. application specific parameters.
*/
args?: Args;
}
export interface InitializeResult {
/**
* GLSP protocol version that the server is implementing.
*/
protocolVersion: string;
/**
* The actions (grouped by diagramType) that the server can handle.
*/
serverActions: ServerActions;
}
/**
* Known server actions i.e. action kinds that the server can handle for a specific diagram type.
*/
export interface InitializeClientSessionParameters {
/**
* Unique identifier for the new client session.
*/
clientSessionId: string;
/**
* Unique identifier of the diagram type for which the session should be configured.
*/
diagramType: string;
/**
* Additional custom arguments.
*/
args?: Args;
}
export interface DisposeClientSessionParameters {
/**
* Unique identifier of the client session that should be disposed.
*/
clientSessionId: string;
/**
* Additional custom arguments.
*/
args?: Args;
}
export declare class ApplicationIdProvider {

@@ -70,21 +123,38 @@ private static _applicationId?;

/**
* Client name.
*/
readonly name: string;
/**
* Current client state.
*/
currentState(): ClientState;
readonly currentState: ClientState;
/**
* Initializes the client and the server connection. During the start procedure the client is in the `Starting` state and will transition to either `Running` or `StartFailed`.
* Initializes the client and the server connection. During the start procedure the client is in the
* `Starting` state and will transition to either `Running` or `StartFailed`.
*
* @returns A promise that resolves if the startup was successful.
*/
start(): Promise<void>;
/**
* Send an `initialize` request to the server. The server needs to be initialized in order to accept and process action messages.
* Send an `initialize` request to the server. The server needs to be initialized in order to accept and
* process other requests and notifications.
*
* @param params Initialize parameter
* @returns true if the initialization was successful
* @param params Initialize parameters
* @returns A promise of the {@link InitializeResult}.
*/
initializeServer(params: InitializeParameters): Promise<Boolean>;
initializeServer(params: InitializeParameters): Promise<InitializeResult>;
/**
* Send an `initializeClientSession` request to the server. One client application may open several session.
* Each individual diagram on the client side counts as one session and has to provide
* a unique clientId.
*
* @param params InitializeClientSession parameters
* @returns A promise that resolves if the initialization was successful
*/
initializeClientSession(params: InitializeClientSessionParameters): Promise<void>;
/**
* Sends a `disposeClientSession` request to the server. This request has to be sent at the end of client session lifecycle
* e.g. when an editor widget is closed.
*
* @param params DisposeClientSession parameters
* @returns A promise that resolves if the disposal was successful
*/
disposeClientSession(params: DisposeClientSessionParameters): Promise<void>;
/**
* Send a `shutdown` notification to the server.

@@ -94,3 +164,6 @@ */

/**
* Stops the client and disposes any resources. During the stop procedure the client is in the `Stopping` state and will transition to either `Stopped` or `ServerError`.
* Stops the client and disposes any resources. During the stop procedure the client is in the `Stopping` state and will
* transition to either `Stopped` or `ServerError`.
*
* @returns A promise that resolves after the server was stopped and disposed.
*/

@@ -114,6 +187,6 @@ stop(): Promise<void>;

id: string;
name: string;
}
function isOptions(object: any): object is Options;
const protocolVersion = "0.9.0";
}
//# sourceMappingURL=glsp-client.d.ts.map

4

lib/glsp-client.js

@@ -51,7 +51,7 @@ "use strict";

function isOptions(object) {
return object !== undefined && "id" in object && typeof object["id"] === "string"
&& "name" in object && typeof object["name"] === "string";
return object !== undefined && 'id' in object && typeof object['id'] === 'string';
}
GLSPClient.isOptions = isOptions;
GLSPClient.protocolVersion = '0.9.0';
})(GLSPClient = exports.GLSPClient || (exports.GLSPClient = {}));
//# sourceMappingURL=glsp-client.js.map
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 EclipseSource and others.
*

@@ -16,8 +16,7 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import { Message, MessageConnection } from "vscode-ws-jsonrpc";
import { ActionMessageHandler, ClientState, GLSPClient, InitializeParameters } from "../glsp-client";
import { ConnectionProvider, JsonrpcGLSPClient } from "./glsp-jsonrpc-client";
import { ActionMessage } from 'sprotty';
import { Message, MessageConnection } from 'vscode-ws-jsonrpc';
import { ActionMessageHandler, ClientState, DisposeClientSessionParameters, GLSPClient, InitializeClientSessionParameters, InitializeParameters, InitializeResult } from '../glsp-client';
import { ConnectionProvider, JsonrpcGLSPClient } from './glsp-jsonrpc-client';
export declare class BaseJsonrpcGLSPClient implements GLSPClient {
readonly name: string;
readonly id: string;

@@ -31,3 +30,5 @@ protected readonly connectionProvider: ConnectionProvider;

shutdownServer(): void;
initializeServer(params: InitializeParameters): Promise<Boolean>;
initializeServer(params: InitializeParameters): Promise<InitializeResult>;
initializeClientSession(params: InitializeClientSessionParameters): Promise<void>;
disposeClientSession(params: DisposeClientSessionParameters): Promise<void>;
onActionMessage(handler: ActionMessageHandler): void;

@@ -43,4 +44,4 @@ sendActionMessage(message: ActionMessage): void;

protected isConnectionActive(): boolean;
currentState(): ClientState;
get currentState(): ClientState;
}
//# sourceMappingURL=base-jsonrpc-glsp-client.d.ts.map

@@ -56,4 +56,16 @@ "use strict";

}
return Promise.resolve(false);
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
};
BaseJsonrpcGLSPClient.prototype.initializeClientSession = function (params) {
if (this.checkConnectionState()) {
return this.resolvedConnection.sendRequest(glsp_jsonrpc_client_1.JsonrpcGLSPClient.InitializeClientSessionRequest, params);
}
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
};
BaseJsonrpcGLSPClient.prototype.disposeClientSession = function (params) {
if (this.checkConnectionState()) {
return this.resolvedConnection.sendRequest(glsp_jsonrpc_client_1.JsonrpcGLSPClient.DisposeClientSessionRequest, params);
}
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
};
BaseJsonrpcGLSPClient.prototype.onActionMessage = function (handler) {

@@ -173,5 +185,9 @@ if (this.checkConnectionState()) {

};
BaseJsonrpcGLSPClient.prototype.currentState = function () {
return this.state;
};
Object.defineProperty(BaseJsonrpcGLSPClient.prototype, "currentState", {
get: function () {
return this.state;
},
enumerable: false,
configurable: true
});
return BaseJsonrpcGLSPClient;

@@ -178,0 +194,0 @@ }());

/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 EclipseSource and others.
*

@@ -16,6 +16,6 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import { MessageConnection, NotificationType, RequestType } from "vscode-jsonrpc";
import { Logger, NotificationType0 } from "vscode-ws-jsonrpc";
import { GLSPClient, InitializeParameters } from "../glsp-client";
import { ActionMessage } from 'sprotty';
import { MessageConnection, NotificationType, RequestType } from 'vscode-jsonrpc';
import { Logger, NotificationType0 } from 'vscode-ws-jsonrpc';
import { DisposeClientSessionParameters, GLSPClient, InitializeClientSessionParameters, InitializeParameters, InitializeResult } from '../glsp-client';
export declare type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;

@@ -29,3 +29,5 @@ export declare type ConnectionProvider = MessageConnection | (() => MaybePromise<MessageConnection>);

const ActionMessageNotification: NotificationType<ActionMessage, void>;
const InitializeRequest: RequestType<InitializeParameters, Boolean, void, void>;
const InitializeRequest: RequestType<InitializeParameters, InitializeResult, void, void>;
const InitializeClientSessionRequest: RequestType<InitializeClientSessionParameters, void, void, void>;
const DisposeClientSessionRequest: RequestType<DisposeClientSessionParameters, void, void, void>;
const ShutdownNotification: NotificationType0<void>;

@@ -32,0 +34,0 @@ const ClientNotReadyMsg = "JsonrpcGLSPClient is not ready yet";

@@ -10,3 +10,3 @@ "use strict";

function isOptions(object) {
return glsp_client_1.GLSPClient.isOptions(object) && "connectionProvider" in object;
return glsp_client_1.GLSPClient.isOptions(object) && 'connectionProvider' in object;
}

@@ -16,2 +16,4 @@ JsonrpcGLSPClient.isOptions = isOptions;

JsonrpcGLSPClient.InitializeRequest = new vscode_jsonrpc_1.RequestType('initialize');
JsonrpcGLSPClient.InitializeClientSessionRequest = new vscode_jsonrpc_1.RequestType('initializeClientSession');
JsonrpcGLSPClient.DisposeClientSessionRequest = new vscode_jsonrpc_1.RequestType('disposeClientSession');
JsonrpcGLSPClient.ShutdownNotification = new vscode_ws_jsonrpc_1.NotificationType0('shutdown');

@@ -18,0 +20,0 @@ JsonrpcGLSPClient.ClientNotReadyMsg = 'JsonrpcGLSPClient is not ready yet';

@@ -25,3 +25,3 @@ "use strict";

function getPort(argsKey, defaultPort) {
argsKey = "--" + argsKey.replace("--", "").replace("=", "") + "=";
argsKey = "--" + argsKey.replace('--', '').replace('=', '') + "=";
var args = process.argv.filter(function (a) { return a.startsWith(argsKey); });

@@ -28,0 +28,0 @@ if (args.length > 0) {

{
"name": "@eclipse-glsp/protocol",
"version": "0.9.0-next.3d174f20",
"version": "0.9.0-next.45db2ab6",
"description": "The protocol definition for client-server communication in GLSP",

@@ -15,32 +15,22 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

],
"homepage": "https://www.eclipse.org/glsp/",
"bugs": "https://github.com/eclipse-glsp/glsp-client/issues",
"files": [
"lib",
"src"
],
"author": {
"name": "Eclipse GLSP"
},
"homepage": "https://www.eclipse.org/glsp/",
"repository": {
"type": "git",
"url": "https://github.com/eclipse-glsp/glsp-client.git"
},
"bugs": "https://github.com/eclipse-glsp/glsp/issues",
"contributors": [
{
"name": "Philip Langer",
"email": "planger@eclipsesource.com",
"url": "https://www.eclipsesource.com"
},
{
"name": "Tobias Ortmayr",
"email": "tortmayr@eclipsesource.com",
"url": "https://www.eclipsesource.com"
},
{
"name": "Martin Fleck",
"email": "mfleck@eclipsesource.com",
"url": "https://www.eclipsesource.com"
"name": "Eclipse GLSP Project",
"email": "glsp-dev@eclipse.org",
"url": "https://projects.eclipse.org/projects/ecd.glsp"
}
],
"repository": {
"type": "git",
"url": "https://github.com/eclipse-glsp/glsp-client.git"
},
"files": [
"lib",
"src"
],
"dependencies": {

@@ -54,10 +44,9 @@ "uuid": "7.0.3",

"rimraf": "^2.6.1",
"tslint": "^5.5.0",
"typescript": "^3.9.2"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"prepare": "yarn clean && yarn build && yarn lint",
"clean": "rimraf lib",
"build": "tsc && yarn run lint",
"lint": "tslint -c ../../tslint.json --project ./tsconfig.json",
"build": "tsc",
"lint": "eslint -c ./.eslintrc.js --ext .ts ./src",
"watch": "tsc -w"

@@ -64,0 +53,0 @@ },

/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 EclipseSource and others.
*

@@ -16,6 +16,16 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import * as uuid from "uuid";
import { ActionMessage } from 'sprotty';
import * as uuid from 'uuid';
export interface InitializeParameters<> {
/**
* A key-value pair structure for primitive typed custom arguments.
*/
export interface Args { [key: string]: string | number | boolean }
/**
* A key-value pair structure to map a diagramType to its server-handled action kinds.
*/
export interface ServerActions { [key: string]: string[] }
export interface InitializeParameters {
/**

@@ -27,7 +37,57 @@ * Unique identifier for the current client application.

/**
* Options that can include application-specific parameters.
* GLSP protocol version that this client is implementing.
*/
options?: any
protocolVersion: string;
/**
* Additional custom arguments e.g. application specific parameters.
*/
args?: Args;
}
export interface InitializeResult {
/**
* GLSP protocol version that the server is implementing.
*/
protocolVersion: string;
/**
* The actions (grouped by diagramType) that the server can handle.
*/
serverActions: ServerActions;
}
/**
* Known server actions i.e. action kinds that the server can handle for a specific diagram type.
*/
export interface InitializeClientSessionParameters {
/**
* Unique identifier for the new client session.
*/
clientSessionId: string;
/**
* Unique identifier of the diagram type for which the session should be configured.
*/
diagramType: string;
/**
* Additional custom arguments.
*/
args?: Args;
}
export interface DisposeClientSessionParameters {
/**
* Unique identifier of the client session that should be disposed.
*/
clientSessionId: string;
/**
* Additional custom arguments.
*/
args?: Args;
}
export class ApplicationIdProvider {

@@ -83,31 +143,52 @@ private static _applicationId?: string;

/**
* Client name.
* Current client state.
*/
readonly name: string;
readonly currentState: ClientState;
/**
* Current client state.
* Initializes the client and the server connection. During the start procedure the client is in the
* `Starting` state and will transition to either `Running` or `StartFailed`.
*
* @returns A promise that resolves if the startup was successful.
*/
currentState(): ClientState;
start(): Promise<void>;
/**
* Initializes the client and the server connection. During the start procedure the client is in the `Starting` state and will transition to either `Running` or `StartFailed`.
* Send an `initialize` request to the server. The server needs to be initialized in order to accept and
* process other requests and notifications.
*
* @param params Initialize parameters
* @returns A promise of the {@link InitializeResult}.
*/
start(): Promise<void>;
initializeServer(params: InitializeParameters): Promise<InitializeResult>;
/**
* Send an `initialize` request to the server. The server needs to be initialized in order to accept and process action messages.
* Send an `initializeClientSession` request to the server. One client application may open several session.
* Each individual diagram on the client side counts as one session and has to provide
* a unique clientId.
*
* @param params Initialize parameter
* @returns true if the initialization was successful
* @param params InitializeClientSession parameters
* @returns A promise that resolves if the initialization was successful
*/
initializeServer(params: InitializeParameters): Promise<Boolean>;
initializeClientSession(params: InitializeClientSessionParameters): Promise<void>;
/**
* Sends a `disposeClientSession` request to the server. This request has to be sent at the end of client session lifecycle
* e.g. when an editor widget is closed.
*
* @param params DisposeClientSession parameters
* @returns A promise that resolves if the disposal was successful
*/
disposeClientSession(params: DisposeClientSessionParameters): Promise<void>;
/**
* Send a `shutdown` notification to the server.
*/
shutdownServer(): void
shutdownServer(): void;
/**
* Stops the client and disposes any resources. During the stop procedure the client is in the `Stopping` state and will transition to either `Stopped` or `ServerError`.
* Stops the client and disposes any resources. During the stop procedure the client is in the `Stopping` state and will
* transition to either `Stopped` or `ServerError`.
*
* @returns A promise that resolves after the server was stopped and disposed.
*/

@@ -130,13 +211,12 @@ stop(): Promise<void>;

}
export namespace GLSPClient {
export interface Options {
id: string;
name: string;
}
export function isOptions(object: any): object is Options {
return object !== undefined && "id" in object && typeof object["id"] === "string"
&& "name" in object && typeof object["name"] === "string";
return object !== undefined && 'id' in object && typeof object['id'] === 'string';
}
export const protocolVersion = '0.9.0';
}
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 EclipseSource and others.
*

@@ -16,11 +16,18 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import { Message, MessageConnection } from "vscode-ws-jsonrpc";
import { ActionMessage } from 'sprotty';
import { Message, MessageConnection } from 'vscode-ws-jsonrpc';
import { ActionMessageHandler, ClientState, GLSPClient, InitializeParameters } from "../glsp-client";
import { ConnectionProvider, JsonrpcGLSPClient } from "./glsp-jsonrpc-client";
import {
ActionMessageHandler,
ClientState,
DisposeClientSessionParameters,
GLSPClient,
InitializeClientSessionParameters,
InitializeParameters,
InitializeResult
} from '../glsp-client';
import { ConnectionProvider, JsonrpcGLSPClient } from './glsp-jsonrpc-client';
export class BaseJsonrpcGLSPClient implements GLSPClient {
readonly name: string;
readonly id: string;

@@ -44,9 +51,23 @@ protected readonly connectionProvider: ConnectionProvider;

initializeServer(params: InitializeParameters): Promise<Boolean> {
initializeServer(params: InitializeParameters): Promise<InitializeResult> {
if (this.checkConnectionState()) {
return this.resolvedConnection!.sendRequest(JsonrpcGLSPClient.InitializeRequest, params);
}
return Promise.resolve(false);
return Promise.reject(JsonrpcGLSPClient.ClientNotReadyMsg);
}
initializeClientSession(params: InitializeClientSessionParameters): Promise<void> {
if (this.checkConnectionState()) {
return this.resolvedConnection!.sendRequest(JsonrpcGLSPClient.InitializeClientSessionRequest, params);
}
return Promise.reject(JsonrpcGLSPClient.ClientNotReadyMsg);
}
disposeClientSession(params: DisposeClientSessionParameters): Promise<void> {
if (this.checkConnectionState()) {
return this.resolvedConnection!.sendRequest(JsonrpcGLSPClient.DisposeClientSessionRequest, params);
}
return Promise.reject(JsonrpcGLSPClient.ClientNotReadyMsg);
}
onActionMessage(handler: ActionMessageHandler): void {

@@ -144,5 +165,5 @@ if (this.checkConnectionState()) {

currentState(): ClientState {
get currentState(): ClientState {
return this.state;
}
}
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 EclipseSource and others.
*

@@ -16,4 +16,4 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import { MessageConnection, NotificationType, RequestType } from "vscode-jsonrpc";
import { ActionMessage } from 'sprotty';
import { MessageConnection, NotificationType, RequestType } from 'vscode-jsonrpc';
import {

@@ -26,7 +26,12 @@ createMessageConnection,

WebSocketMessageWriter
} from "vscode-ws-jsonrpc";
} from 'vscode-ws-jsonrpc';
import { GLSPClient, InitializeParameters } from "../glsp-client";
import {
DisposeClientSessionParameters,
GLSPClient,
InitializeClientSessionParameters,
InitializeParameters,
InitializeResult
} from '../glsp-client';
export type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;

@@ -41,7 +46,10 @@ export type ConnectionProvider = MessageConnection | (() => MaybePromise<MessageConnection>);

export function isOptions(object: any): object is Options {
return GLSPClient.isOptions(object) && "connectionProvider" in object;
return GLSPClient.isOptions(object) && 'connectionProvider' in object;
}
export const ActionMessageNotification = new NotificationType<ActionMessage, void>('process');
export const InitializeRequest = new RequestType<InitializeParameters, Boolean, void, void>('initialize');
export const InitializeRequest = new RequestType<InitializeParameters, InitializeResult, void, void>('initialize');
export const InitializeClientSessionRequest = new RequestType<InitializeClientSessionParameters, void, void, void>('initializeClientSession');
export const DisposeClientSessionRequest = new RequestType<DisposeClientSessionParameters, void, void, void>('disposeClientSession');
export const ShutdownNotification = new NotificationType0<void>('shutdown');

@@ -58,3 +66,2 @@ export const ClientNotReadyMsg = 'JsonrpcGLSPClient is not ready yet';

export function error(message: string, ...optionalParams: any[]): void {

@@ -61,0 +68,0 @@ console.error(`[JsonrpcGLSPClient] ${message}`, optionalParams);

@@ -23,3 +23,3 @@ /********************************************************************************

export function getPort(argsKey: string, defaultPort?: number): number {
argsKey = `--${argsKey.replace("--", "").replace("=", "")}=`;
argsKey = `--${argsKey.replace('--', '').replace('=', '')}=`;
const args = process.argv.filter(a => a.startsWith(argsKey));

@@ -26,0 +26,0 @@ if (args.length > 0) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc