New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-glsp/protocol

Package Overview
Dependencies
Maintainers
5
Versions
310
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.f54fd689 to 0.9.0-next.fd1a8bb6

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

35

lib/glsp-client.js
"use strict";
/********************************************************************************
* Copyright (c) 2020-2021 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
********************************************************************************/
/* eslint-disable @typescript-eslint/naming-convention */
Object.defineProperty(exports, "__esModule", { value: true });
exports.GLSPClient = exports.ClientState = exports.ApplicationIdProvider = void 0;
var uuid = require("uuid");
var ApplicationIdProvider = /** @class */ (function () {
function ApplicationIdProvider() {
}
ApplicationIdProvider.get = function () {
const uuid = require("uuid");
class ApplicationIdProvider {
static get() {
if (!ApplicationIdProvider._applicationId) {

@@ -13,6 +27,6 @@ ApplicationIdProvider._applicationId = uuid.v4();

return ApplicationIdProvider._applicationId;
};
return ApplicationIdProvider;
}());
}
}
exports.ApplicationIdProvider = ApplicationIdProvider;
// eslint-disable-next-line no-shadow
var ClientState;

@@ -51,8 +65,9 @@ (function (ClientState) {

(function (GLSPClient) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function isOptions(object) {
return object !== undefined && "id" in object && typeof object["id"] === "string"
&& "name" in object && typeof object["name"] === "string";
return typeof object === 'object' && '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
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseJsonrpcGLSPClient = void 0;
var glsp_client_1 = require("../glsp-client");
var glsp_jsonrpc_client_1 = require("./glsp-jsonrpc-client");
var BaseJsonrpcGLSPClient = /** @class */ (function () {
function BaseJsonrpcGLSPClient(options) {
const glsp_client_1 = require("../glsp-client");
const glsp_jsonrpc_client_1 = require("./glsp-jsonrpc-client");
class BaseJsonrpcGLSPClient {
constructor(options) {
Object.assign(this, options);
this.state = glsp_client_1.ClientState.Initial;
}
BaseJsonrpcGLSPClient.prototype.shutdownServer = function () {
shutdownServer() {
if (this.checkConnectionState()) {
this.resolvedConnection.sendNotification(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ShutdownNotification);
}
};
BaseJsonrpcGLSPClient.prototype.initializeServer = function (params) {
}
initializeServer(params) {
if (this.checkConnectionState()) {
return this.resolvedConnection.sendRequest(glsp_jsonrpc_client_1.JsonrpcGLSPClient.InitializeRequest, params);
}
return Promise.resolve(false);
};
BaseJsonrpcGLSPClient.prototype.onActionMessage = function (handler) {
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
}
initializeClientSession(params) {
if (this.checkConnectionState()) {
return this.resolvedConnection.sendRequest(glsp_jsonrpc_client_1.JsonrpcGLSPClient.InitializeClientSessionRequest, params);
}
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
}
disposeClientSession(params) {
if (this.checkConnectionState()) {
return this.resolvedConnection.sendRequest(glsp_jsonrpc_client_1.JsonrpcGLSPClient.DisposeClientSessionRequest, params);
}
return Promise.reject(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);
}
onActionMessage(handler) {
if (this.checkConnectionState()) {
this.resolvedConnection.onNotification(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ActionMessageNotification, handler);
}
};
BaseJsonrpcGLSPClient.prototype.sendActionMessage = function (message) {
}
sendActionMessage(message) {
if (this.checkConnectionState()) {
this.resolvedConnection.sendNotification(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ActionMessageNotification, message);
}
};
BaseJsonrpcGLSPClient.prototype.checkConnectionState = function () {
}
checkConnectionState() {
if (!this.isConnectionActive()) {

@@ -73,30 +49,17 @@ throw new Error(glsp_jsonrpc_client_1.JsonrpcGLSPClient.ClientNotReadyMsg);

return true;
};
BaseJsonrpcGLSPClient.prototype.start = function () {
return __awaiter(this, void 0, void 0, function () {
var connection, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
this.state = glsp_client_1.ClientState.Starting;
return [4 /*yield*/, this.resolveConnection()];
case 1:
connection = _a.sent();
connection.listen();
this.resolvedConnection = connection;
this.state = glsp_client_1.ClientState.Running;
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
glsp_jsonrpc_client_1.JsonrpcGLSPClient.error('Failed to start connection to server', error_1);
this.state = glsp_client_1.ClientState.StartFailed;
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
}
});
});
};
BaseJsonrpcGLSPClient.prototype.stop = function () {
var _this = this;
}
async start() {
try {
this.state = glsp_client_1.ClientState.Starting;
const connection = await this.resolveConnection();
connection.listen();
this.resolvedConnection = connection;
this.state = glsp_client_1.ClientState.Running;
}
catch (error) {
glsp_jsonrpc_client_1.JsonrpcGLSPClient.error('Failed to start connection to server', error);
this.state = glsp_client_1.ClientState.StartFailed;
}
}
stop() {
if (!this.connectionPromise) {

@@ -110,11 +73,11 @@ this.state = glsp_client_1.ClientState.Stopped;

this.state = glsp_client_1.ClientState.Stopping;
return this.onStop = this.resolveConnection().then(function (connection) {
return (this.onStop = this.resolveConnection().then(connection => {
connection.dispose();
_this.state = glsp_client_1.ClientState.Stopped;
_this.onStop = undefined;
_this.connectionPromise = undefined;
_this.resolvedConnection = undefined;
});
};
BaseJsonrpcGLSPClient.prototype.resolveConnection = function () {
this.state = glsp_client_1.ClientState.Stopped;
this.onStop = undefined;
this.connectionPromise = undefined;
this.resolvedConnection = undefined;
}));
}
resolveConnection() {
if (!this.connectionPromise) {

@@ -124,33 +87,15 @@ this.connectionPromise = this.doCreateConnection();

return this.connectionPromise;
};
BaseJsonrpcGLSPClient.prototype.doCreateConnection = function () {
return __awaiter(this, void 0, void 0, function () {
var connection, _a;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(typeof this.connectionProvider === 'function')) return [3 /*break*/, 2];
return [4 /*yield*/, this.connectionProvider()];
case 1:
_a = _b.sent();
return [3 /*break*/, 3];
case 2:
_a = this.connectionProvider;
_b.label = 3;
case 3:
connection = _a;
connection.onError(function (data) { return _this.handleConnectionError(data[0], data[1], data[2]); });
connection.onClose(function () { return _this.handleConnectionClosed(); });
return [2 /*return*/, connection];
}
});
});
};
BaseJsonrpcGLSPClient.prototype.handleConnectionError = function (error, message, count) {
}
async doCreateConnection() {
const connection = typeof this.connectionProvider === 'function' ? await this.connectionProvider() : this.connectionProvider;
connection.onError((data) => this.handleConnectionError(data[0], data[1], data[2]));
connection.onClose(() => this.handleConnectionClosed());
return connection;
}
handleConnectionError(error, message, count) {
glsp_jsonrpc_client_1.JsonrpcGLSPClient.error('Connection to server is erroring. Shutting down server.', error);
this.stop();
this.state = glsp_client_1.ClientState.ServerError;
};
BaseJsonrpcGLSPClient.prototype.handleConnectionClosed = function () {
}
handleConnectionClosed() {
if (this.state === glsp_client_1.ClientState.Stopping || this.state === glsp_client_1.ClientState.Stopped) {

@@ -171,12 +116,11 @@ return;

this.state = glsp_client_1.ClientState.ServerError;
};
BaseJsonrpcGLSPClient.prototype.isConnectionActive = function () {
}
isConnectionActive() {
return this.state === glsp_client_1.ClientState.Running && !!this.resolvedConnection;
};
BaseJsonrpcGLSPClient.prototype.currentState = function () {
}
get currentState() {
return this.state;
};
return BaseJsonrpcGLSPClient;
}());
}
}
exports.BaseJsonrpcGLSPClient = BaseJsonrpcGLSPClient;
//# sourceMappingURL=base-jsonrpc-glsp-client.js.map
/********************************************************************************
* 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";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonrpcGLSPClient = void 0;
var vscode_jsonrpc_1 = require("vscode-jsonrpc");
var vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc");
var glsp_client_1 = require("../glsp-client");
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
const vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc");
const glsp_client_1 = require("../glsp-client");
var JsonrpcGLSPClient;
(function (JsonrpcGLSPClient) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function isOptions(object) {
return glsp_client_1.GLSPClient.isOptions(object) && "connectionProvider" in object;
return glsp_client_1.GLSPClient.isOptions(object) && 'connectionProvider' in object;
}

@@ -15,17 +16,15 @@ 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');
JsonrpcGLSPClient.ClientNotReadyMsg = 'JsonrpcGLSPClient is not ready yet';
function createWebsocketConnectionProvider(websocket, logger) {
var socket = vscode_ws_jsonrpc_1.toSocket(websocket);
var reader = new vscode_ws_jsonrpc_1.WebSocketMessageReader(socket);
var writer = new vscode_ws_jsonrpc_1.WebSocketMessageWriter(socket);
const socket = vscode_ws_jsonrpc_1.toSocket(websocket);
const reader = new vscode_ws_jsonrpc_1.WebSocketMessageReader(socket);
const writer = new vscode_ws_jsonrpc_1.WebSocketMessageWriter(socket);
return vscode_ws_jsonrpc_1.createMessageConnection(reader, writer, logger);
}
JsonrpcGLSPClient.createWebsocketConnectionProvider = createWebsocketConnectionProvider;
function error(message) {
var optionalParams = [];
for (var _i = 1; _i < arguments.length; _i++) {
optionalParams[_i - 1] = arguments[_i];
}
console.error("[JsonrpcGLSPClient] " + message, optionalParams);
function error(message, ...optionalParams) {
console.error(`[JsonrpcGLSPClient] ${message}`, optionalParams);
}

@@ -32,0 +31,0 @@ JsonrpcGLSPClient.error = error;

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

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

"use strict";
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 EclipseSource and others.
*

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

function getPort(argsKey, defaultPort) {
argsKey = "--" + argsKey.replace("--", "").replace("=", "") + "=";
var args = process.argv.filter(function (a) { return a.startsWith(argsKey); });
argsKey = `--${argsKey.replace('--', '').replace('=', '')}=`;
const args = process.argv.filter(a => a.startsWith(argsKey));
if (args.length > 0) {

@@ -29,0 +29,0 @@ return Number.parseInt(args[0].substring(argsKey.length), 10);

{
"name": "@eclipse-glsp/protocol",
"version": "0.9.0-next.f54fd689",
"version": "0.9.0-next.fd1a8bb6",
"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,22 @@ * This program and the accompanying materials are made available under the

********************************************************************************/
import { ActionMessage } from "sprotty";
import * as uuid from "uuid";
/* eslint-disable @typescript-eslint/naming-convention */
export interface InitializeParameters<> {
import { ActionMessage } from 'sprotty';
import * as uuid from 'uuid';
/**
* 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 +43,56 @@ * 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 {

@@ -45,2 +110,3 @@ private static _applicationId?: string;

// eslint-disable-next-line no-shadow
export enum ClientState {

@@ -84,31 +150,52 @@ /**

/**
* 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.
*/

@@ -131,13 +218,13 @@ stop(): Promise<void>;

}
export namespace GLSPClient {
export interface Options {
id: string;
name: string;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
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 typeof object === 'object' && '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,17 @@ * 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 +50,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 {

@@ -93,3 +113,3 @@ if (this.checkConnectionState()) {

this.state = ClientState.Stopping;
return this.onStop = this.resolveConnection().then(connection => {
return (this.onStop = this.resolveConnection().then(connection => {
connection.dispose();

@@ -100,3 +120,3 @@ this.state = ClientState.Stopped;

this.resolvedConnection = undefined;
});
}));
}

@@ -146,5 +166,5 @@

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,11 @@ createMessageConnection,

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

@@ -40,8 +44,14 @@ export type ConnectionProvider = MessageConnection | (() => MaybePromise<MessageConnection>);

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
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 +68,2 @@ export const ClientNotReadyMsg = 'JsonrpcGLSPClient is not ready yet';

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

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

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

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

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));

@@ -31,2 +31,1 @@ 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

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