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

@glsp/sprotty-client

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glsp/sprotty-client - npm Package Compare versions

Comparing version 0.2.0-next.cdfbfee4 to 0.2.0-next.d67106f6

lib/features/edit-label-validation/di.config.d.ts

5

lib/base/command-stack.d.ts

@@ -1,2 +0,2 @@

import { CommandStack, SModelRoot } from "sprotty/lib";
import { CommandStack, IActionDispatcher, SModelRoot } from "sprotty/lib";
/**

@@ -24,4 +24,7 @@ * Provides access to the current `SModelRoot` instance.

export declare class GLSPCommandStack extends CommandStack implements IReadonlyModelAccess {
protected actionDispatcher: () => Promise<IActionDispatcher>;
readonly model: Promise<SModelRoot>;
undo(): Promise<SModelRoot>;
redo(): Promise<SModelRoot>;
}
//# sourceMappingURL=command-stack.d.ts.map

@@ -21,2 +21,5 @@ "use strict";

};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -40,2 +43,3 @@ /********************************************************************************

var lib_1 = require("sprotty/lib");
var model_1 = require("../features/undo-redo/model");
var GLSPCommandStack = /** @class */ (function (_super) {

@@ -54,2 +58,14 @@ __extends(GLSPCommandStack, _super);

});
GLSPCommandStack.prototype.undo = function () {
this.actionDispatcher().then(function (dispatcher) { return dispatcher.dispatch(new model_1.GlspUndoAction()); });
return this.thenUpdate();
};
GLSPCommandStack.prototype.redo = function () {
this.actionDispatcher().then(function (dispatcher) { return dispatcher.dispatch(new model_1.GlspRedoAction()); });
return this.thenUpdate();
};
__decorate([
inversify_1.inject(lib_1.TYPES.IActionDispatcherProvider),
__metadata("design:type", Function)
], GLSPCommandStack.prototype, "actionDispatcher", void 0);
GLSPCommandStack = __decorate([

@@ -56,0 +72,0 @@ inversify_1.injectable()

3

lib/base/di.config.js

@@ -22,2 +22,3 @@ "use strict";

var types_1 = require("../types");
var command_stack_1 = require("./command-stack");
var update_model_command_1 = require("./model/update-model-command");

@@ -32,2 +33,4 @@ var tool_manager_action_handler_1 = require("./tool-manager/tool-manager-action-handler");

lib_1.configureCommand({ bind: bind, isBound: isBound }, update_model_command_1.FeedbackAwareUpdateModelCommand);
bind(lib_1.TYPES.IActionHandlerInitializer).to(update_model_command_1.SetModelActionHandler);
rebind(lib_1.TYPES.ICommandStack).to(command_stack_1.GLSPCommandStack);
bind(types_1.GLSP_TYPES.ViewerOptions).toConstantValue(viewer_options_1.defaultGLSPViewerOptions());

@@ -34,0 +37,0 @@ if (isBound(lib_1.TYPES.ViewerOptions)) {

@@ -1,4 +0,10 @@

import { ActionHandlerRegistry, CommandExecutionContext, CommandResult, ILogger, SModelRoot } from "sprotty/lib";
import { Action, ActionHandlerRegistry, CommandExecutionContext, CommandResult, ILogger, SetModelAction, SModelRoot } from "sprotty/lib";
import { UpdateModelAction, UpdateModelCommand } from "sprotty/lib/features/update/update-model";
import { IFeedbackActionDispatcher } from "src/features/tool-feedback/feedback-action-dispatcher";
import { SelfInitializingActionHandler } from "../tool-manager/tool-manager-action-handler";
export declare class SetModelActionHandler extends SelfInitializingActionHandler {
handle(action: Action): Action | void;
handledActionKinds: string[];
}
export declare function isSetModelAction(action: Action): action is SetModelAction;
export interface SModelRootListener {

@@ -5,0 +11,0 @@ modelRootChanged(root: Readonly<SModelRoot>): void;

@@ -48,2 +48,25 @@ "use strict";

var types_1 = require("../../types");
var tool_manager_action_handler_1 = require("../tool-manager/tool-manager-action-handler");
/* ActionHandler that transforms a SetModelAction into an (feedback-aware) UpdateModelAction. This can be done because in sprotty
* UpdateModel behaves the same as SetModel if no model is present yet.*/
var SetModelActionHandler = /** @class */ (function (_super) {
__extends(SetModelActionHandler, _super);
function SetModelActionHandler() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handledActionKinds = [lib_1.SetModelCommand.KIND];
return _this;
}
SetModelActionHandler.prototype.handle = function (action) {
if (isSetModelAction(action)) {
return new update_model_1.UpdateModelAction(action.newRoot, false);
}
};
return SetModelActionHandler;
}(tool_manager_action_handler_1.SelfInitializingActionHandler));
exports.SetModelActionHandler = SetModelActionHandler;
function isSetModelAction(action) {
return action !== undefined && (action.kind === lib_1.SetModelCommand.KIND)
&& action.newRoot !== undefined;
}
exports.isSetModelAction = isSetModelAction;
/**

@@ -50,0 +73,0 @@ * A special`UpdateModelCommand` that retrieves all registered `actions` from the `IFeedbackActionDispatcher` (if present) and applies their feedback

@@ -59,3 +59,2 @@ "use strict";

var operation_actions_1 = require("../operation/operation-actions");
var model_2 = require("../reconnect/model");
var selection_service_1 = require("../select/selection-service");

@@ -178,3 +177,3 @@ var change_bounds_tool_feedback_1 = require("../tool-feedback/change-bounds-tool-feedback");

var newBounds_1 = [];
smodel_util_1.forEachElement(target, isNonRoutableSelectedBoundsAware, function (element) {
smodel_util_1.forEachElement(target, smodel_util_1.isNonRoutableSelectedBoundsAware, function (element) {
return createElementAndBounds(element).forEach(function (bounds) { return newBounds_1.push(bounds); });

@@ -317,5 +316,2 @@ });

}
function isNonRoutableSelectedBoundsAware(element) {
return lib_1.isBoundsAware(element) && smodel_util_1.isSelected(element) && !model_2.isRoutable(element);
}
//# sourceMappingURL=change-bounds-tool.js.map

@@ -194,3 +194,5 @@ "use strict";

this.target = undefined;
this.tool.dispatchFeedback([new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.OPERATION_NOT_ALLOWED)]);
this.currentTarget = undefined;
this.allowedTarget = false;
this.tool.dispatchFeedback([new creation_tool_feedback_1.RemoveFeedbackEdgeAction()]);
};

@@ -197,0 +199,0 @@ EdgeCreationToolMouseListener.prototype.nonDraggingMouseUp = function (element, event) {

@@ -18,4 +18,6 @@ /********************************************************************************

import glspCommandPaletteModule from "./features/command-palette/di.config";
import glspEditLabelValidationModule from "./features/edit-label-validation/di.config";
import executeModule from "./features/execute/di.config";
import modelHintsModule from "./features/hints/di.config";
import layoutCommandsModule from "./features/layout/di.config";
import glspMouseToolModule from "./features/mouse-tool/di.config";

@@ -56,3 +58,5 @@ import requestResponseModule from "./features/request-response/di.config";

export * from './features/tools/delete-tool';
export * from './features/undo-redo/model';
export * from './features/validation/validate';
export * from './features/layout/layout-commands';
export * from './lib/model';

@@ -64,4 +68,5 @@ export * from './types';

export * from './utils/viewpoint-util';
export * from "./model-source/glsp-server-status";
export { validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, //
glspSelectModule, glspMouseToolModule };
glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule };
//# sourceMappingURL=index.d.ts.map

@@ -25,20 +25,24 @@ "use strict";

exports.glspCommandPaletteModule = di_config_2.default;
var di_config_3 = require("./features/execute/di.config");
exports.executeModule = di_config_3.default;
var di_config_4 = require("./features/hints/di.config");
exports.modelHintsModule = di_config_4.default;
var di_config_5 = require("./features/mouse-tool/di.config");
exports.glspMouseToolModule = di_config_5.default;
var di_config_6 = require("./features/request-response/di.config");
exports.requestResponseModule = di_config_6.default;
var di_config_7 = require("./features/save/di.config");
exports.saveModule = di_config_7.default;
var di_config_8 = require("./features/select/di.config");
exports.glspSelectModule = di_config_8.default;
var di_config_9 = require("./features/tool-feedback/di.config");
exports.toolFeedbackModule = di_config_9.default;
var di_config_10 = require("./features/tool-palette/di.config");
exports.paletteModule = di_config_10.default;
var di_config_11 = require("./features/validation/di.config");
exports.validationModule = di_config_11.default;
var di_config_3 = require("./features/edit-label-validation/di.config");
exports.glspEditLabelValidationModule = di_config_3.default;
var di_config_4 = require("./features/execute/di.config");
exports.executeModule = di_config_4.default;
var di_config_5 = require("./features/hints/di.config");
exports.modelHintsModule = di_config_5.default;
var di_config_6 = require("./features/layout/di.config");
exports.layoutCommandsModule = di_config_6.default;
var di_config_7 = require("./features/mouse-tool/di.config");
exports.glspMouseToolModule = di_config_7.default;
var di_config_8 = require("./features/request-response/di.config");
exports.requestResponseModule = di_config_8.default;
var di_config_9 = require("./features/save/di.config");
exports.saveModule = di_config_9.default;
var di_config_10 = require("./features/select/di.config");
exports.glspSelectModule = di_config_10.default;
var di_config_11 = require("./features/tool-feedback/di.config");
exports.toolFeedbackModule = di_config_11.default;
var di_config_12 = require("./features/tool-palette/di.config");
exports.paletteModule = di_config_12.default;
var di_config_13 = require("./features/validation/di.config");
exports.validationModule = di_config_13.default;
__export(require("sprotty/lib"));

@@ -72,3 +76,5 @@ __export(require("./base/edit-config/edit-config"));

__export(require("./features/tools/delete-tool"));
__export(require("./features/undo-redo/model"));
__export(require("./features/validation/validate"));
__export(require("./features/layout/layout-commands"));
__export(require("./lib/model"));

@@ -80,2 +86,3 @@ __export(require("./types"));

__export(require("./utils/viewpoint-util"));
__export(require("./model-source/glsp-server-status"));
//# sourceMappingURL=index.js.map

@@ -1,9 +0,14 @@

import { Action, ActionHandlerRegistry, DiagramServer, ICommand, WebSocketDiagramServer } from "sprotty";
export declare class GLSPWebsocketDiagramServer extends WebSocketDiagramServer {
import { Action, ActionHandlerRegistry, ActionMessage, ComputedBoundsAction, DiagramServer, ICommand } from "sprotty";
import * as rpc from "vscode-ws-jsonrpc";
export declare class GLSPWebsocketDiagramServer extends DiagramServer {
protected _sourceUri: string;
protected connection: rpc.MessageConnection;
listen(webSocket: WebSocket): void;
protected sendMessage(message: ActionMessage): void;
initialize(registry: ActionHandlerRegistry): void;
handle(action: Action): void | ICommand | Action;
getSourceURI(): string;
protected handleComputedBounds(action: ComputedBoundsAction): boolean;
}
export declare function registerDefaultGLSPServerActions(registry: ActionHandlerRegistry, diagramServer: DiagramServer): void;
//# sourceMappingURL=websocket-diagram-server.d.ts.map

@@ -39,2 +39,4 @@ "use strict";

var sprotty_1 = require("sprotty");
var rpc = require("vscode-ws-jsonrpc");
var vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc");
var action_definitions_1 = require("../features/command-palette/action-definitions");

@@ -46,2 +48,3 @@ var execute_command_1 = require("../features/execute/execute-command");

var save_1 = require("../features/save/save");
var model_1 = require("../features/undo-redo/model");
var validate_1 = require("../features/validation/validate");

@@ -53,2 +56,21 @@ var GLSPWebsocketDiagramServer = /** @class */ (function (_super) {

}
GLSPWebsocketDiagramServer.prototype.listen = function (webSocket) {
var _this = this;
rpc.listen({
webSocket: webSocket,
onConnection: function (connection) {
connection.listen();
connection.onNotification(ActionMessageNotification.type, function (message) { return _this.messageReceived(message); });
_this.connection = connection;
}
});
};
GLSPWebsocketDiagramServer.prototype.sendMessage = function (message) {
if (this.connection) {
this.connection.sendNotification(ActionMessageNotification.type, message);
}
else {
throw new Error('WebSocket is not connected');
}
};
GLSPWebsocketDiagramServer.prototype.initialize = function (registry) {

@@ -66,2 +88,5 @@ registerDefaultGLSPServerActions(registry, this);

};
GLSPWebsocketDiagramServer.prototype.handleComputedBounds = function (action) {
return true;
};
GLSPWebsocketDiagramServer = __decorate([

@@ -71,3 +96,3 @@ inversify_1.injectable()

return GLSPWebsocketDiagramServer;
}(sprotty_1.WebSocketDiagramServer));
}(sprotty_1.DiagramServer));
exports.GLSPWebsocketDiagramServer = GLSPWebsocketDiagramServer;

@@ -77,2 +102,4 @@ function registerDefaultGLSPServerActions(registry, diagramServer) {

registry.register(save_1.SaveModelAction.KIND, diagramServer);
registry.register(model_1.GlspUndoAction.KIND, diagramServer);
registry.register(model_1.GlspRedoAction.KIND, diagramServer);
registry.register(set_operations_1.OperationKind.CREATE_CONNECTION, diagramServer);

@@ -99,2 +126,3 @@ registry.register(set_operations_1.OperationKind.RECONNECT_CONNECTION, diagramServer);

registry.register(sprotty_1.LayoutAction.KIND, diagramServer);
registry.register(sprotty_1.ApplyLabelEditAction.KIND, diagramServer);
// Register an empty handler for SwitchEditMode, to avoid runtime exceptions.

@@ -106,2 +134,6 @@ // We don't want to support SwitchEditMode, but sprotty still sends some corresponding

exports.registerDefaultGLSPServerActions = registerDefaultGLSPServerActions;
var ActionMessageNotification;
(function (ActionMessageNotification) {
ActionMessageNotification.type = new vscode_ws_jsonrpc_1.NotificationType('process');
})(ActionMessageNotification || (ActionMessageNotification = {}));
//# sourceMappingURL=websocket-diagram-server.js.map

@@ -16,6 +16,7 @@ /********************************************************************************

********************************************************************************/
import { Selectable, SModelElement, SParentElement } from "sprotty/lib";
import { BoundsAware, Selectable, SModelElement, SParentElement } from "sprotty/lib";
import { NodeEditConfig } from "../base/edit-config/edit-config";
export declare function getIndex(element: SModelElement): import("sprotty").SModelIndex<SModelElement>;
export declare function forEachElement<T>(element: SModelElement, predicate: (element: SModelElement) => element is SModelElement & T, runnable: (element: SModelElement & T) => void): void;
export declare function getMatchingElements<T>(element: SModelElement, predicate: (element: SModelElement) => element is SModelElement & T): (SModelElement & T)[];
export declare function hasSelectedElements(element: SModelElement): boolean;

@@ -28,2 +29,4 @@ export declare function getSelectedElementCount(element: SModelElement): number;

export declare function isContainmentAllowed(element: SModelElement, containableElementTypeId: string): element is SParentElement & NodeEditConfig;
export declare function isNonRoutableSelectedBoundsAware(element: SModelElement): element is SelectableBoundsAware;
export declare type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;
//# sourceMappingURL=smodel-util.d.ts.map

@@ -30,2 +30,3 @@ "use strict";

var edit_config_1 = require("../base/edit-config/edit-config");
var model_1 = require("../features/reconnect/model");
function getIndex(element) {

@@ -41,2 +42,8 @@ return element.root.index;

exports.forEachElement = forEachElement;
function getMatchingElements(element, predicate) {
var matching = [];
forEachElement(element, predicate, function (item) { return matching.push(item); });
return matching;
}
exports.getMatchingElements = getMatchingElements;
function hasSelectedElements(element) {

@@ -111,2 +118,6 @@ return getSelectedElementCount(element) > 0;

exports.isContainmentAllowed = isContainmentAllowed;
function isNonRoutableSelectedBoundsAware(element) {
return lib_1.isBoundsAware(element) && isSelected(element) && !model_1.isRoutable(element);
}
exports.isNonRoutableSelectedBoundsAware = isNonRoutableSelectedBoundsAware;
//# sourceMappingURL=smodel-util.js.map
{
"name": "@glsp/sprotty-client",
"version": "0.2.0-next.cdfbfee4",
"version": "0.2.0-next.d67106f6",
"description": "A sprotty-based client for GLSP",

@@ -31,3 +31,4 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

"autocompleter": "^4.0.2",
"sprotty": "0.7.0-next.9d330d7"
"sprotty": "0.7.0-next.cea0e2b",
"vscode-ws-jsonrpc": "^0.0.2-1"
},

@@ -34,0 +35,0 @@ "devDependencies": {

@@ -16,5 +16,7 @@ /********************************************************************************

********************************************************************************/
import { injectable } from "inversify";
import { CommandStack, SModelRoot } from "sprotty/lib";
import { inject, injectable } from "inversify";
import { CommandStack, IActionDispatcher, SModelRoot, TYPES } from "sprotty/lib";
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model";
/**

@@ -46,2 +48,4 @@ * Provides access to the current `SModelRoot` instance.

@inject(TYPES.IActionDispatcherProvider) protected actionDispatcher: () => Promise<IActionDispatcher>;
get model(): Promise<SModelRoot> {

@@ -52,3 +56,13 @@ return this.currentPromise.then(

}
undo(): Promise<SModelRoot> {
this.actionDispatcher().then(dispatcher => dispatcher.dispatch(new GlspUndoAction()));
return this.thenUpdate();
}
redo(): Promise<SModelRoot> {
this.actionDispatcher().then(dispatcher => dispatcher.dispatch(new GlspRedoAction()));
return this.thenUpdate();
}
}

@@ -22,3 +22,4 @@ /********************************************************************************

import { GLSP_TYPES } from "../types";
import { FeedbackAwareUpdateModelCommand } from "./model/update-model-command";
import { GLSPCommandStack } from "./command-stack";
import { FeedbackAwareUpdateModelCommand, SetModelActionHandler } from "./model/update-model-command";
import { createToolFactory, ToolManagerActionHandler } from "./tool-manager/tool-manager-action-handler";

@@ -34,3 +35,5 @@ import { defaultGLSPViewerOptions, GLSPViewerOptions } from "./views/viewer-options";

configureCommand({ bind, isBound }, FeedbackAwareUpdateModelCommand);
bind(TYPES.IActionHandlerInitializer).to(SetModelActionHandler);
rebind(TYPES.ICommandStack).to(GLSPCommandStack);

@@ -37,0 +40,0 @@ bind<GLSPViewerOptions>(GLSP_TYPES.ViewerOptions).toConstantValue(defaultGLSPViewerOptions());

@@ -18,2 +18,3 @@ /********************************************************************************

import {
Action,
ActionHandlerRegistry,

@@ -25,2 +26,4 @@ Command,

ILogger,
SetModelAction,
SetModelCommand,
SModelRoot,

@@ -34,4 +37,21 @@ TYPES

import { GLSP_TYPES } from "../../types";
import { SelfInitializingActionHandler } from "../tool-manager/tool-manager-action-handler";
/* ActionHandler that transforms a SetModelAction into an (feedback-aware) UpdateModelAction. This can be done because in sprotty
* UpdateModel behaves the same as SetModel if no model is present yet.*/
export class SetModelActionHandler extends SelfInitializingActionHandler {
handle(action: Action): Action | void {
if (isSetModelAction(action)) {
return new UpdateModelAction(action.newRoot, false);
}
}
handledActionKinds = [SetModelCommand.KIND];
}
export function isSetModelAction(action: Action): action is SetModelAction {
return action !== undefined && (action.kind === SetModelCommand.KIND)
&& (<SetModelAction>action).newRoot !== undefined;
}
export interface SModelRootListener {

@@ -38,0 +58,0 @@ modelRootChanged(root: Readonly<SModelRoot>): void

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

findParentByFeature,
isBoundsAware,
isViewport,

@@ -29,3 +28,2 @@ KeyTool,

Point,
Selectable,
SetBoundsAction,

@@ -40,7 +38,6 @@ SModelElement,

import { GLSP_TYPES } from "../../types";
import { forEachElement, isSelected } from "../../utils/smodel-util";
import { forEachElement, isNonRoutableSelectedBoundsAware, isSelected } from "../../utils/smodel-util";
import { isBoundsAwareMoveable, isResizeable, ResizeHandleLocation, SResizeHandle } from "../change-bounds/model";
import { IMouseTool } from "../mouse-tool/mouse-tool";
import { ChangeBoundsOperationAction } from "../operation/operation-actions";
import { isRoutable } from "../reconnect/model";
import { SelectionListener, SelectionService } from "../select/selection-service";

@@ -323,5 +320,1 @@ import {

}
function isNonRoutableSelectedBoundsAware(element: SModelElement): element is SModelElement & BoundsAware & Selectable {
return isBoundsAware(element) && isSelected(element) && !isRoutable(element);
}

@@ -102,4 +102,2 @@ /********************************************************************************

}
return result;

@@ -179,3 +177,5 @@ }

this.target = undefined;
this.tool.dispatchFeedback([new ApplyCursorCSSFeedbackAction(CursorCSS.OPERATION_NOT_ALLOWED)]);
this.currentTarget = undefined;
this.allowedTarget = false;
this.tool.dispatchFeedback([new RemoveFeedbackEdgeAction()]);
}

@@ -182,0 +182,0 @@

@@ -18,4 +18,6 @@ /********************************************************************************

import glspCommandPaletteModule from "./features/command-palette/di.config";
import glspEditLabelValidationModule from "./features/edit-label-validation/di.config";
import executeModule from "./features/execute/di.config";
import modelHintsModule from "./features/hints/di.config";
import layoutCommandsModule from "./features/layout/di.config";
import glspMouseToolModule from "./features/mouse-tool/di.config";

@@ -57,3 +59,5 @@ import requestResponseModule from "./features/request-response/di.config";

export * from './features/tools/delete-tool';
export * from './features/undo-redo/model';
export * from './features/validation/validate';
export * from './features/layout/layout-commands';
export * from './lib/model';

@@ -65,7 +69,9 @@ export * from './types';

export * from './utils/viewpoint-util';
export * from "./model-source/glsp-server-status";
export {
validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, //
glspSelectModule, glspMouseToolModule
glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule
};

@@ -18,20 +18,10 @@ /********************************************************************************

import {
Action,
ActionHandlerRegistry,
CollapseExpandAction,
CollapseExpandAllAction,
ComputedBoundsAction,
DiagramServer,
ExportSvgAction,
ICommand,
LayoutAction,
OpenAction,
RequestBoundsCommand,
RequestModelAction,
RequestPopupModelAction,
ServerStatusAction,
SwitchEditModeCommand,
WebSocketDiagramServer
Action, ActionHandlerRegistry, ActionMessage,
ApplyLabelEditAction, CollapseExpandAction, CollapseExpandAllAction,
ComputedBoundsAction, DiagramServer, ExportSvgAction, ICommand, LayoutAction,
OpenAction, RequestBoundsCommand, RequestModelAction, RequestPopupModelAction,
ServerStatusAction, SwitchEditModeCommand
} from "sprotty";
import * as rpc from "vscode-ws-jsonrpc";
import { NotificationType } from "vscode-ws-jsonrpc";
import { RequestCommandPaletteActions } from "../features/command-palette/action-definitions";

@@ -43,9 +33,30 @@ import { ExecuteServerCommandAction } from "../features/execute/execute-command";

import { SaveModelAction } from "../features/save/save";
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model";
import { RequestMarkersAction } from "../features/validation/validate";
@injectable()
export class GLSPWebsocketDiagramServer extends WebSocketDiagramServer {
export class GLSPWebsocketDiagramServer extends DiagramServer {
protected _sourceUri: string;
protected connection: rpc.MessageConnection;
listen(webSocket: WebSocket): void {
rpc.listen({
webSocket,
onConnection: (connection: rpc.MessageConnection) => {
connection.listen();
connection.onNotification(ActionMessageNotification.type, (message: ActionMessage) => this.messageReceived(message));
this.connection = connection;
}
});
}
protected sendMessage(message: ActionMessage): void {
if (this.connection) {
this.connection.sendNotification(ActionMessageNotification.type, message);
} else {
throw new Error('WebSocket is not connected');
}
}
initialize(registry: ActionHandlerRegistry): void {

@@ -55,2 +66,3 @@ registerDefaultGLSPServerActions(registry, this);

}
handle(action: Action): void | ICommand | Action {

@@ -65,2 +77,6 @@ if (action instanceof RequestModelAction && action.options !== undefined)

}
protected handleComputedBounds(action: ComputedBoundsAction): boolean {
return true;
}
}

@@ -71,2 +87,4 @@

registry.register(SaveModelAction.KIND, diagramServer);
registry.register(GlspUndoAction.KIND, diagramServer);
registry.register(GlspRedoAction.KIND, diagramServer);
registry.register(OperationKind.CREATE_CONNECTION, diagramServer);

@@ -93,2 +111,3 @@ registry.register(OperationKind.RECONNECT_CONNECTION, diagramServer);

registry.register(LayoutAction.KIND, diagramServer);
registry.register(ApplyLabelEditAction.KIND, diagramServer);

@@ -100,1 +119,6 @@ // Register an empty handler for SwitchEditMode, to avoid runtime exceptions.

}
namespace ActionMessageNotification {
export const type = new NotificationType<ActionMessage, void>('process');
}

@@ -16,5 +16,6 @@ /********************************************************************************

********************************************************************************/
import { isSelectable, Selectable, SModelElement, SParentElement } from "sprotty/lib";
import { BoundsAware, isBoundsAware, isSelectable, Selectable, SModelElement, SParentElement } from "sprotty/lib";
import { isConfigurableNode, NodeEditConfig } from "../base/edit-config/edit-config";
import { isRoutable } from "../features/reconnect/model";

@@ -31,2 +32,8 @@ export function getIndex(element: SModelElement) {

export function getMatchingElements<T>(element: SModelElement, predicate: (element: SModelElement) => element is SModelElement & T): (SModelElement & T)[] {
const matching: (SModelElement & T)[] = [];
forEachElement(element, predicate, item => matching.push(item));
return matching;
}
export function hasSelectedElements(element: SModelElement) {

@@ -79,1 +86,7 @@ return getSelectedElementCount(element) > 0;

}
export function isNonRoutableSelectedBoundsAware(element: SModelElement): element is SelectableBoundsAware {
return isBoundsAware(element) && isSelected(element) && !isRoutable(element);
}
export type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;

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

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

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