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.e0bc9960 to 0.2.0-next.e135e793

lib/model-source/glsp-server-status.d.ts

24

lib/base/command-stack.d.ts
import { CommandStack, IActionDispatcher, SModelRoot } from "sprotty/lib";
/**
* Provides access to the current `SModelRoot` instance.
*
* This is useful if you need to query the model for some tasks,
* e.g., determine the list of elements, etc.
*
* Note that this provider will only return a copy of the current instance.
* Thus, changes to the returned `SModelRoot` won't have any effect.
* Changes of the `SModelRoot` should be performed inside a command.
*/
export interface IReadonlyModelAccess {
/**
* The current `SModelRoot` instance.
*
* Note that this is a copy of the current instance.
* Thus, changes to the returned `SModelRoot` won't have any effect.
* Changes of the `SModelRoot` should be performed inside a command.
*/
readonly model: Promise<SModelRoot>;
}
export declare type IReadonlyModelAccessProvider = () => Promise<IReadonlyModelAccess>;
export declare class GLSPCommandStack extends CommandStack implements IReadonlyModelAccess {
export declare class GLSPCommandStack extends CommandStack {
protected actionDispatcher: () => Promise<IActionDispatcher>;
readonly model: Promise<SModelRoot>;
undo(): Promise<SModelRoot>;

@@ -27,0 +5,0 @@ redo(): Promise<SModelRoot>;

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

}
Object.defineProperty(GLSPCommandStack.prototype, "model", {
get: function () {
var _this = this;
return this.currentPromise.then(function (state) { return _this.modelFactory.createRoot(state.root); });
},
enumerable: true,
configurable: true
});
GLSPCommandStack.prototype.undo = function () {

@@ -58,0 +50,0 @@ this.actionDispatcher().then(function (dispatcher) { return dispatcher.dispatch(new model_1.GlspUndoAction()); });

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

var lib_1 = require("sprotty/lib");
var set_operations_1 = require("../features/operation/set-operations");
var types_1 = require("../types");

@@ -27,9 +28,10 @@ var command_stack_1 = require("./command-stack");

var viewer_options_1 = require("./views/viewer-options");
var defaultGLSPModule = new inversify_1.ContainerModule(function (bind, unbind, isBound, rebind) {
var defaultGLSPModule = new inversify_1.ContainerModule(function (bind, _unbind, isBound, rebind) {
var context = { bind: bind, _unbind: _unbind, isBound: isBound, rebind: rebind };
// Tool manager initialization ------------------------------------
bind(lib_1.TYPES.IActionHandlerInitializer).to(tool_manager_action_handler_1.ToolManagerActionHandler);
lib_1.configureActionHandler(context, set_operations_1.SetOperationsAction.KIND, tool_manager_action_handler_1.GLSPToolManagerActionHandler);
bind(types_1.GLSP_TYPES.IToolFactory).toFactory((tool_manager_action_handler_1.createToolFactory()));
// Model update initialization ------------------------------------
lib_1.configureCommand({ bind: bind, isBound: isBound }, update_model_command_1.FeedbackAwareUpdateModelCommand);
bind(lib_1.TYPES.IActionHandlerInitializer).to(update_model_command_1.SetModelActionHandler);
lib_1.configureCommand(context, update_model_command_1.FeedbackAwareUpdateModelCommand);
lib_1.configureActionHandler(context, lib_1.SetModelCommand.KIND, update_model_command_1.SetModelActionHandler);
rebind(lib_1.TYPES.ICommandStack).to(command_stack_1.GLSPCommandStack);

@@ -36,0 +38,0 @@ bind(types_1.GLSP_TYPES.ViewerOptions).toConstantValue(viewer_options_1.defaultGLSPViewerOptions());

@@ -1,6 +0,5 @@

import { Action, ActionHandlerRegistry, CommandExecutionContext, CommandResult, ILogger, SetModelAction, SModelRoot } from "sprotty/lib";
import { Action, ActionHandlerRegistry, CommandExecutionContext, CommandReturn, IActionHandler, 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 {
export declare class SetModelActionHandler implements IActionHandler {
handle(action: Action): Action | void;

@@ -23,5 +22,5 @@ handledActionKinds: string[];

constructor(action: UpdateModelAction, logger: ILogger, feedbackActionDispatcher: IFeedbackActionDispatcher, actionHandlerRegistryProvider: () => Promise<ActionHandlerRegistry>, modelRootListeners?: SModelRootListener[]);
protected performUpdate(oldRoot: SModelRoot, newRoot: SModelRoot, context: CommandExecutionContext): CommandResult;
protected performUpdate(oldRoot: SModelRoot, newRoot: SModelRoot, context: CommandExecutionContext): CommandReturn;
private getFeedbackCommands;
}
//# sourceMappingURL=update-model-command.d.ts.map

@@ -48,11 +48,7 @@ "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);
var SetModelActionHandler = /** @class */ (function () {
function SetModelActionHandler() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handledActionKinds = [lib_1.SetModelCommand.KIND];
return _this;
this.handledActionKinds = [lib_1.SetModelCommand.KIND];
}

@@ -64,4 +60,7 @@ SetModelActionHandler.prototype.handle = function (action) {

};
SetModelActionHandler = __decorate([
inversify_1.injectable()
], SetModelActionHandler);
return SetModelActionHandler;
}(tool_manager_action_handler_1.SelfInitializingActionHandler));
}());
exports.SetModelActionHandler = SetModelActionHandler;

@@ -68,0 +67,0 @@ function isSetModelAction(action) {

@@ -17,13 +17,7 @@ /********************************************************************************

import { interfaces } from "inversify";
import { Action, ActionHandlerRegistry, IActionHandler, IActionHandlerInitializer, ICommand, Tool, ToolManager } from "sprotty/lib";
import { Action, IActionHandler, ICommand, Tool, ToolManager } from "sprotty/lib";
import { SetOperationsAction } from "../../features/operation/set-operations";
export declare abstract class SelfInitializingActionHandler implements IActionHandler, IActionHandlerInitializer {
initialize(registry: ActionHandlerRegistry): void;
abstract handle(action: Action): ICommand | Action | void;
abstract handledActionKinds: string[];
}
export declare class ToolManagerActionHandler extends SelfInitializingActionHandler {
export declare class GLSPToolManagerActionHandler implements IActionHandler {
readonly toolFactory: (operationKind: string) => Tool;
readonly toolManager: ToolManager;
readonly handledActionKinds: string[];
handle(action: Action): void | ICommand | Action;

@@ -30,0 +24,0 @@ configure(action: SetOperationsAction): any;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -66,23 +53,6 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

var types_1 = require("../../types");
var SelfInitializingActionHandler = /** @class */ (function () {
function SelfInitializingActionHandler() {
var GLSPToolManagerActionHandler = /** @class */ (function () {
function GLSPToolManagerActionHandler() {
}
SelfInitializingActionHandler.prototype.initialize = function (registry) {
var _this = this;
this.handledActionKinds.forEach(function (kind) { return registry.register(kind, _this); });
};
SelfInitializingActionHandler = __decorate([
inversify_1.injectable()
], SelfInitializingActionHandler);
return SelfInitializingActionHandler;
}());
exports.SelfInitializingActionHandler = SelfInitializingActionHandler;
var ToolManagerActionHandler = /** @class */ (function (_super) {
__extends(ToolManagerActionHandler, _super);
function ToolManagerActionHandler() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handledActionKinds = [set_operations_1.SetOperationsAction.KIND];
return _this;
}
ToolManagerActionHandler.prototype.handle = function (action) {
GLSPToolManagerActionHandler.prototype.handle = function (action) {
if (set_operations_1.isSetOperationsAction(action)) {

@@ -92,3 +62,3 @@ this.configure(action);

};
ToolManagerActionHandler.prototype.configure = function (action) {
GLSPToolManagerActionHandler.prototype.configure = function (action) {
var _this = this;

@@ -108,13 +78,13 @@ var _a;

__metadata("design:type", Function)
], ToolManagerActionHandler.prototype, "toolFactory", void 0);
], GLSPToolManagerActionHandler.prototype, "toolFactory", void 0);
__decorate([
inversify_1.inject(lib_1.TYPES.IToolManager),
__metadata("design:type", lib_1.ToolManager)
], ToolManagerActionHandler.prototype, "toolManager", void 0);
ToolManagerActionHandler = __decorate([
], GLSPToolManagerActionHandler.prototype, "toolManager", void 0);
GLSPToolManagerActionHandler = __decorate([
inversify_1.injectable()
], ToolManagerActionHandler);
return ToolManagerActionHandler;
}(SelfInitializingActionHandler));
exports.ToolManagerActionHandler = ToolManagerActionHandler;
], GLSPToolManagerActionHandler);
return GLSPToolManagerActionHandler;
}());
exports.GLSPToolManagerActionHandler = GLSPToolManagerActionHandler;
function isTypeAware(tool) {

@@ -121,0 +91,0 @@ return tool["elementTypeId"] !== undefined && typeof tool["elementTypeId"] === "string";

@@ -16,8 +16,10 @@ /********************************************************************************

********************************************************************************/
import { Action, LabeledAction } from "sprotty/lib";
import { Action, LabeledAction, Point } from "sprotty/lib";
export declare class RequestCommandPaletteActions implements Action {
readonly selectedElementsIDs: string[];
readonly selectedElementIds: string[];
readonly text: string;
readonly lastMousePosition?: Point | undefined;
static readonly KIND = "requestCommandPaletteActions";
kind: string;
constructor(selectedElementsIDs?: string[]);
constructor(selectedElementIds: string[], text: string, lastMousePosition?: Point | undefined);
}

@@ -24,0 +26,0 @@ export declare class SetCommandPaletteActions implements Action {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RequestCommandPaletteActions = /** @class */ (function () {
function RequestCommandPaletteActions(selectedElementsIDs) {
if (selectedElementsIDs === void 0) { selectedElementsIDs = []; }
this.selectedElementsIDs = selectedElementsIDs;
function RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition) {
if (selectedElementIds === void 0) { selectedElementIds = []; }
this.selectedElementIds = selectedElementIds;
this.text = text;
this.lastMousePosition = lastMousePosition;
this.kind = RequestCommandPaletteActions.KIND;

@@ -8,0 +10,0 @@ }

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

import { Action, ICommandPaletteActionProvider, ILogger, LabeledAction, SModelElement } from "sprotty/lib";
import { Action, ICommandPaletteActionProvider, ILogger, LabeledAction, Point, SModelElement } from "sprotty/lib";
import { RequestResponseSupport } from "../request-response/support";

@@ -11,5 +11,5 @@ export declare class NavigationCommandPaletteActionProvider implements ICommandPaletteActionProvider {

constructor(requestResponseSupport: RequestResponseSupport);
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]>;
getActions(root: Readonly<SModelElement>, text: string, lastMousePosition?: Point): Promise<LabeledAction[]>;
getPaletteActionsFromResponse(action: Action): LabeledAction[];
}
//# sourceMappingURL=action-provider.d.ts.map

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

.filter(lib_1.isNameable)
.map(function (nameable) { return new lib_1.LabeledAction("Select " + lib_1.name(nameable), [new lib_1.SelectAction([nameable.id]), new lib_1.CenterAction([nameable.id])]); })));
.map(function (nameable) { return new lib_1.LabeledAction("Select " + lib_1.name(nameable), [new lib_1.SelectAction([nameable.id]), new lib_1.CenterAction([nameable.id])], 'fa-object-group'); })));
};

@@ -59,5 +59,5 @@ NavigationCommandPaletteActionProvider = __decorate([

}
ServerCommandPaletteActionProvider.prototype.getActions = function (root) {
var selectedElementIDs = Array.from(root.index.all().filter(smodel_util_1.isSelected).map(function (e) { return e.id; }));
var requestAction = new action_definitions_1.RequestCommandPaletteActions(selectedElementIDs);
ServerCommandPaletteActionProvider.prototype.getActions = function (root, text, lastMousePosition) {
var selectedElementIds = Array.from(root.index.all().filter(smodel_util_1.isSelected).map(function (e) { return e.id; }));
var requestAction = new action_definitions_1.RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition);
var responseHandler = this.getPaletteActionsFromResponse;

@@ -64,0 +64,0 @@ var promise = this.requestResponseSupport.dispatchRequest(requestAction, responseHandler);

@@ -21,6 +21,7 @@ "use strict";

var types_1 = require("../../types");
var action_definition_1 = require("./action-definition");
var type_hints_action_initializer_1 = require("./type-hints-action-initializer");
var modelHintsModule = new inversify_1.ContainerModule(function (bind, _unbind, isBound) {
bind(type_hints_action_initializer_1.TypeHintsEditConfigProvider).toSelf().inSingletonScope();
bind(lib_1.TYPES.IActionHandlerInitializer).toService(type_hints_action_initializer_1.TypeHintsEditConfigProvider);
lib_1.configureActionHandler({ bind: bind, isBound: isBound }, action_definition_1.SetTypeHintsAction.KIND, type_hints_action_initializer_1.TypeHintsEditConfigProvider);
bind(types_1.GLSP_TYPES.IEditConfigProvider).toService(type_hints_action_initializer_1.TypeHintsEditConfigProvider);

@@ -27,0 +28,0 @@ lib_1.configureCommand({ bind: bind, isBound: isBound }, type_hints_action_initializer_1.ApplyEditConfigCommand);

@@ -1,4 +0,3 @@

import { Action, CommandExecutionContext, CommandResult, ICommand, SModelElement, SModelElementSchema } from "sprotty/lib";
import { Action, CommandExecutionContext, CommandReturn, IActionHandler, ICommand, SModelElement, SModelElementSchema } from "sprotty/lib";
import { EdgeEditConfig, EditConfig, IEditConfigProvider, NodeEditConfig } from "../../base/edit-config/edit-config";
import { SelfInitializingActionHandler } from "../../base/tool-manager/tool-manager-action-handler";
import { IFeedbackActionDispatcher } from "../tool-feedback/feedback-action-dispatcher";

@@ -17,8 +16,7 @@ import { FeedbackCommand } from "../tool-feedback/model";

constructor(action: ApplyEditConfigAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}
export declare class TypeHintsEditConfigProvider extends SelfInitializingActionHandler implements IEditConfigProvider {
export declare class TypeHintsEditConfigProvider implements IActionHandler, IEditConfigProvider {
protected feedbackActionDispatcher: IFeedbackActionDispatcher;
protected editConfigs: Map<string, EditConfig>;
readonly handledActionKinds: string[];
handle(action: Action): ICommand | Action | void;

@@ -25,0 +23,0 @@ getEditConfig(input: SModelElement | SModelElementSchema | string): EditConfig | undefined;

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

var edit_config_1 = require("../../base/edit-config/edit-config");
var tool_manager_action_handler_1 = require("../../base/tool-manager/tool-manager-action-handler");
var types_1 = require("../../types");

@@ -91,9 +90,5 @@ var array_utils_1 = require("../../utils/array-utils");

exports.ApplyEditConfigCommand = ApplyEditConfigCommand;
var TypeHintsEditConfigProvider = /** @class */ (function (_super) {
__extends(TypeHintsEditConfigProvider, _super);
var TypeHintsEditConfigProvider = /** @class */ (function () {
function TypeHintsEditConfigProvider() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.editConfigs = new Map;
_this.handledActionKinds = [action_definition_1.SetTypeHintsAction.KIND];
return _this;
this.editConfigs = new Map;
}

@@ -137,3 +132,3 @@ TypeHintsEditConfigProvider.prototype.handle = function (action) {

return TypeHintsEditConfigProvider;
}(tool_manager_action_handler_1.SelfInitializingActionHandler));
}());
exports.TypeHintsEditConfigProvider = TypeHintsEditConfigProvider;

@@ -140,0 +135,0 @@ function createNodeEditConfig(hint) {

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

import { Action, Bounds, Command, CommandExecutionContext, CommandResult, ElementAndBounds, ElementMove, IActionDispatcher, KeyListener, Point, SModelElement } from "sprotty";
import { Action, Command, CommandExecutionContext, CommandReturn, Dimension, ElementAndBounds, ElementMove, IActionDispatcher, KeyListener, Point, SModelElement } from "sprotty";
import { SelectableBoundsAware } from "../../utils/smodel-util";

@@ -100,3 +100,3 @@ import { SelectionService } from "../select/selection-service";

constructor(action: ResizeElementsAction, actionDispatcher: IActionDispatcher, selectionService: SelectionService);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
resizeWidth(elements: SelectableBoundsAware[]): void;

@@ -107,4 +107,4 @@ resizeHeight(elements: SelectableBoundsAware[]): void;

createElementAndBounds(element: SelectableBoundsAware, change: (element: SelectableBoundsAware, bounds: WriteableElementAndBounds) => void): WriteableElementAndBounds;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}

@@ -117,3 +117,3 @@ export declare class AlignElementsCommand extends LayoutElementsCommand {

constructor(action: AlignElementsAction, actionDispatcher: IActionDispatcher, selectionService: SelectionService);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
alignLeft(elements: SelectableBoundsAware[]): void;

@@ -128,4 +128,4 @@ alignCenter(elements: SelectableBoundsAware[]): void;

createElementAndBounds(element: SelectableBoundsAware, move: ElementMove): ElementAndBounds;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}

@@ -143,12 +143,11 @@ export declare class LayoutKeyboardListener extends KeyListener {

}
interface WriteableElementAndBounds extends ElementAndBounds {
newBounds: WriteableBounds;
}
interface WriteableBounds extends Bounds {
x: number;
y: number;
interface WriteableDimension extends Dimension {
width: number;
height: number;
}
interface WriteableElementAndBounds extends ElementAndBounds {
newPosition: WriteablePoint;
newSize: WriteableDimension;
}
export {};
//# sourceMappingURL=layout-commands.d.ts.map

@@ -264,4 +264,4 @@ "use strict";

var halfDiffWidth = 0.5 * (targetWidth - element.bounds.width);
bounds.newBounds.x = element.bounds.x - halfDiffWidth;
bounds.newBounds.width = targetWidth;
bounds.newPosition.x = element.bounds.x - halfDiffWidth;
bounds.newSize.width = targetWidth;
});

@@ -275,4 +275,4 @@ };

var halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
bounds.newBounds.y = element.bounds.y - halfDiffHeight;
bounds.newBounds.height = targetHeight;
bounds.newPosition.y = element.bounds.y - halfDiffHeight;
bounds.newSize.height = targetHeight;
});

@@ -288,6 +288,6 @@ };

var halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
bounds.newBounds.x = element.bounds.x - halfDiffWidth;
bounds.newBounds.y = element.bounds.y - halfDiffHeight;
bounds.newBounds.width = targetWidth;
bounds.newBounds.height = targetHeight;
bounds.newPosition.x = element.bounds.x - halfDiffWidth;
bounds.newPosition.y = element.bounds.y - halfDiffHeight;
bounds.newSize.width = targetWidth;
bounds.newSize.height = targetHeight;
});

@@ -304,5 +304,7 @@ };

elementId: element.id,
newBounds: {
newPosition: {
x: element.bounds.x,
y: element.bounds.y,
y: element.bounds.y
},
newSize: {
width: element.bounds.width,

@@ -435,5 +437,7 @@ height: element.bounds.height

elementId: element.id,
newBounds: {
newPosition: {
x: move.toPosition.x,
y: move.toPosition.y,
y: move.toPosition.y
},
newSize: {
width: element.bounds.width,

@@ -440,0 +444,0 @@ height: element.bounds.height

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

var mouse_tool_1 = require("./mouse-tool");
var glspMouseToolModule = new inversify_1.ContainerModule(function (bind, unbind, isBound, rebind) {
var glspMouseToolModule = new inversify_1.ContainerModule(function (bind, _unbind, _isBound, rebind) {
bind(mouse_tool_1.RankingMouseTool).toSelf().inSingletonScope();

@@ -25,0 +25,0 @@ bind(types_1.GLSP_TYPES.MouseTool).toService(mouse_tool_1.RankingMouseTool);

@@ -38,3 +38,3 @@ import { Command, CommandExecutionContext, SelectAction, SelectAllAction, SModelElement, SModelRoot, SParentElement } from "sprotty";

selectionService: SelectionService;
static readonly KIND: string;
static readonly KIND = "elementSelected";
protected selected: SModelElement[];

@@ -50,3 +50,3 @@ protected deselected: SModelElement[];

selectionService: SelectionService;
static readonly KIND: string;
static readonly KIND = "allSelected";
protected previousSelection: Map<string, boolean>;

@@ -53,0 +53,0 @@ constructor(action: SelectAllAction, selectionService: SelectionService);

import { VNode } from "snabbdom/vnode";
import { Action, Bounds, CommandExecutionContext, CommandResult, MouseListener, Point, SModelElement } from "sprotty/lib";
import { Action, Bounds, CommandExecutionContext, CommandReturn, MouseListener, Point, SModelElement } from "sprotty/lib";
import { GLSPViewerOptions } from "../../base/views/viewer-options";

@@ -18,3 +18,3 @@ import { FeedbackCommand } from "./model";

constructor(action: ShowChangeBoundsToolResizeFeedbackAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -25,3 +25,3 @@ export declare class HideChangeBoundsToolResizeFeedbackCommand extends FeedbackCommand {

constructor(action: HideChangeBoundsToolResizeFeedbackAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -28,0 +28,0 @@ /**

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

import { Action, AnchorComputerRegistry, CommandExecutionContext, CommandResult, MouseListener, SDanglingAnchor, SModelElement, SModelRoot, SRoutableElement } from "sprotty/lib";
import { Action, AnchorComputerRegistry, CommandExecutionContext, CommandReturn, MouseListener, SDanglingAnchor, SModelElement, SModelRoot, SRoutableElement } from "sprotty/lib";
import { FeedbackCommand } from "./model";

@@ -13,3 +13,3 @@ export declare class DrawFeedbackEdgeAction implements Action {

constructor(action: DrawFeedbackEdgeAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -22,3 +22,3 @@ export declare class RemoveFeedbackEdgeAction implements Action {

static readonly KIND = "removeFeedbackEdgeCommand";
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -25,0 +25,0 @@ export declare class FeedbackEdgeEnd extends SDanglingAnchor {

@@ -46,6 +46,6 @@ "use strict";

lib_1.configureCommand({ bind: bind, isBound: isBound }, edge_edit_tool_feedback_1.SwitchRoutingModeCommand);
bind(lib_1.TYPES.IVNodeDecorator).to(lib_1.LocationDecorator);
bind(lib_1.TYPES.HiddenVNodeDecorator).to(lib_1.LocationDecorator);
bind(lib_1.TYPES.IVNodePostprocessor).to(lib_1.LocationPostprocessor);
bind(lib_1.TYPES.HiddenVNodePostprocessor).to(lib_1.LocationPostprocessor);
});
exports.default = toolFeedbackModule;
//# sourceMappingURL=di.config.js.map
import { VNode } from "snabbdom/vnode";
import { Action, AnchorComputerRegistry, CommandExecutionContext, CommandResult, EdgeRouterRegistry, MouseListener, Point, SModelElement, SRoutingHandle, SwitchEditModeAction, SwitchEditModeCommand } from "sprotty/lib";
import { Action, AnchorComputerRegistry, CommandExecutionContext, CommandReturn, EdgeRouterRegistry, MouseListener, Point, SModelElement, SRoutingHandle, SwitchEditModeAction, SwitchEditModeCommand } from "sprotty/lib";
import { FeedbackEdgeEndMovingMouseListener } from "./creation-tool-feedback";

@@ -21,3 +21,3 @@ import { FeedbackCommand } from "./model";

constructor(action: ShowEdgeReconnectHandlesFeedbackAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -28,3 +28,3 @@ export declare class HideEdgeReconnectHandlesFeedbackCommand extends FeedbackCommand {

constructor(action: HideEdgeReconnectHandlesFeedbackAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -54,3 +54,3 @@ /**

constructor(action: DrawFeedbackEdgeSourceAction);
execute(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
}

@@ -57,0 +57,0 @@ /**

@@ -16,9 +16,9 @@ /********************************************************************************

********************************************************************************/
import { Command, CommandExecutionContext, CommandResult } from "sprotty/lib";
import { Command, CommandExecutionContext, CommandReturn } from "sprotty/lib";
export declare abstract class FeedbackCommand extends Command {
readonly priority: number;
abstract execute(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
abstract execute(context: CommandExecutionContext): CommandReturn;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}
//# sourceMappingURL=model.d.ts.map

@@ -21,9 +21,12 @@ "use strict";

var lib_1 = require("sprotty/lib");
var set_operations_1 = require("../operation/set-operations");
var tool_palette_1 = require("./tool-palette");
var toolPaletteModule = new inversify_1.ContainerModule(function (bind) {
var toolPaletteModule = new inversify_1.ContainerModule(function (bind, _unbind, isBound) {
bind(tool_palette_1.ToolPalette).toSelf().inSingletonScope();
bind(lib_1.TYPES.IUIExtension).toService(tool_palette_1.ToolPalette);
bind(lib_1.TYPES.IActionHandlerInitializer).to(tool_palette_1.ToolPaletteActionHandler);
bind(tool_palette_1.ToolPaletteActionHandler).toSelf().inSingletonScope();
lib_1.configureActionHandler({ bind: bind, isBound: isBound }, set_operations_1.SetOperationsAction.KIND, tool_palette_1.ToolPaletteActionHandler);
lib_1.configureActionHandler({ bind: bind, isBound: isBound }, lib_1.EnableDefaultToolsAction.KIND, tool_palette_1.ToolPaletteActionHandler);
});
exports.default = toolPaletteModule;
//# sourceMappingURL=di.config.js.map

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

import { AbstractUIExtension, Action, IActionDispatcher, ICommand, SModelRoot } from "sprotty/lib";
import { SelfInitializingActionHandler } from "../../base/tool-manager/tool-manager-action-handler";
import { AbstractUIExtension, Action, IActionDispatcher, IActionHandler, ICommand, SModelRoot } from "sprotty/lib";
import { Operation } from "../operation/set-operations";

@@ -23,7 +22,6 @@ export declare class ToolPalette extends AbstractUIExtension {

}
export declare class ToolPaletteActionHandler extends SelfInitializingActionHandler {
export declare class ToolPaletteActionHandler implements IActionHandler {
protected readonly toolPalette: ToolPalette;
readonly handledActionKinds: string[];
handle(action: Action): ICommand | Action | void;
}
//# sourceMappingURL=tool-palette.d.ts.map

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

var lib_1 = require("sprotty/lib");
var tool_manager_action_handler_1 = require("../../base/tool-manager/tool-manager-action-handler");
var set_operations_1 = require("../operation/set-operations");

@@ -219,8 +218,4 @@ var creation_tool_1 = require("../tools/creation-tool");

}
var ToolPaletteActionHandler = /** @class */ (function (_super) {
__extends(ToolPaletteActionHandler, _super);
var ToolPaletteActionHandler = /** @class */ (function () {
function ToolPaletteActionHandler() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handledActionKinds = [set_operations_1.SetOperationsAction.KIND, lib_1.EnableDefaultToolsAction.KIND];
return _this;
}

@@ -244,4 +239,4 @@ ToolPaletteActionHandler.prototype.handle = function (action) {

return ToolPaletteActionHandler;
}(tool_manager_action_handler_1.SelfInitializingActionHandler));
}());
exports.ToolPaletteActionHandler = ToolPaletteActionHandler;
//# sourceMappingURL=tool-palette.js.map

@@ -285,4 +285,4 @@ "use strict";

function createChangeBoundsAction(element) {
if (isValidBoundChange(element, element.bounds)) {
return [new operation_actions_1.ChangeBoundsOperationAction([{ elementId: element.id, newBounds: element.bounds }])];
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [new operation_actions_1.ChangeBoundsOperationAction([smodel_util_1.toElementAndBounds(element)])];
}

@@ -292,4 +292,4 @@ return [];

function createElementAndBounds(element) {
if (isValidBoundChange(element, element.bounds)) {
return [{ elementId: element.id, newBounds: element.bounds }];
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [smodel_util_1.toElementAndBounds(element)];
}

@@ -299,10 +299,11 @@ return [];

function createSetBoundsAction(element, x, y, width, height) {
var bounds = { x: x, y: y, width: width, height: height };
if (isValidBoundChange(element, bounds)) {
return [new lib_1.SetBoundsAction([{ elementId: element.id, newBounds: bounds }])];
var newPosition = { x: x, y: y };
var newSize = { width: width, height: height };
if (isValidBoundChange(element, newPosition, newSize)) {
return [new lib_1.SetBoundsAction([{ elementId: element.id, newPosition: newPosition, newSize: newSize }])];
}
return [];
}
function isValidBoundChange(element, bounds) {
return bounds.width >= minWidth(element) && bounds.height >= minHeight(element);
function isValidBoundChange(element, newPosition, newSize) {
return newSize.width >= minWidth(element) && newSize.height >= minHeight(element);
}

@@ -309,0 +310,0 @@ function minWidth(element) {

@@ -58,4 +58,8 @@ import { Action, AnchorComputerRegistry, SModelElement, Tool } from "sprotty/lib";

nonDraggingMouseUp(element: SModelElement, event: MouseEvent): Action[];
private isSourceSelected;
private isTargetSelected;
mouseOver(target: SModelElement, event: MouseEvent): Action[];
private isAllowedSource;
private isAllowedTarget;
}
//# sourceMappingURL=creation-tool.d.ts.map

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

if (event.button === 0) {
if (this.source === undefined) {
if (!this.isSourceSelected()) {
if (this.currentTarget && this.allowedTarget) {

@@ -213,3 +213,3 @@ this.source = this.currentTarget.id;

}
if (this.source !== undefined && this.target !== undefined) {
if (this.isSourceSelected() && this.isTargetSelected()) {
result.push(new operation_actions_1.CreateConnectionOperationAction(this.elementTypeId, this.source, this.target));

@@ -229,2 +229,8 @@ if (!lib_1.isCtrlOrCmd(event)) {

};
EdgeCreationToolMouseListener.prototype.isSourceSelected = function () {
return this.source !== undefined;
};
EdgeCreationToolMouseListener.prototype.isTargetSelected = function () {
return this.target !== undefined;
};
EdgeCreationToolMouseListener.prototype.mouseOver = function (target, event) {

@@ -235,5 +241,10 @@ var newCurrentTarget = lib_1.findParentByFeature(target, lib_1.isConnectable);

if (this.currentTarget) {
this.allowedTarget = this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(this.currentTarget) : false;
if (!this.isSourceSelected()) {
this.allowedTarget = this.isAllowedSource(newCurrentTarget);
}
else if (!this.isTargetSelected()) {
this.allowedTarget = this.isAllowedTarget(newCurrentTarget);
}
if (this.allowedTarget) {
var action = this.source === undefined ? new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_SOURCE) :
var action = !this.isSourceSelected() ? new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_SOURCE) :
new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_TARGET);

@@ -247,2 +258,8 @@ return [action];

};
EdgeCreationToolMouseListener.prototype.isAllowedSource = function (element) {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false;
};
EdgeCreationToolMouseListener.prototype.isAllowedTarget = function (element) {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false;
};
EdgeCreationToolMouseListener = __decorate([

@@ -249,0 +266,0 @@ inversify_1.injectable(),

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

import { Action, Command, CommandExecutionContext, CommandResult, IActionDispatcher } from "sprotty/lib";
import { Action, Command, CommandExecutionContext, CommandReturn, IActionDispatcher } from "sprotty/lib";
import { Marker } from "../../utils/marker";

@@ -51,5 +51,5 @@ import { IFeedbackActionDispatcher, IFeedbackEmitter } from "../tool-feedback/feedback-action-dispatcher";

constructor(action: SetMarkersAction);
execute(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}

@@ -72,5 +72,5 @@ /**

constructor(action: ApplyMarkersAction);
execute(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}

@@ -92,6 +92,6 @@ /**

constructor(action: ClearMarkersAction);
execute(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandResult;
redo(context: CommandExecutionContext): CommandResult;
execute(context: CommandExecutionContext): CommandReturn;
undo(context: CommandExecutionContext): CommandReturn;
redo(context: CommandExecutionContext): CommandReturn;
}
//# sourceMappingURL=validate.d.ts.map

@@ -66,4 +66,5 @@ /********************************************************************************

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

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

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

@@ -30,2 +30,13 @@ /********************************************************************************

export declare type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;
export declare function toElementAndBounds(element: SModelElement & BoundsAware): {
elementId: string;
newPosition: {
x: number;
y: number;
};
newSize: {
width: number;
height: number;
};
};
//# sourceMappingURL=smodel-util.d.ts.map

@@ -120,2 +120,16 @@ "use strict";

exports.isNonRoutableSelectedBoundsAware = isNonRoutableSelectedBoundsAware;
function toElementAndBounds(element) {
return {
elementId: element.id,
newPosition: {
x: element.bounds.x,
y: element.bounds.y
},
newSize: {
width: element.bounds.width,
height: element.bounds.height
}
};
}
exports.toElementAndBounds = toElementAndBounds;
//# sourceMappingURL=smodel-util.js.map
{
"name": "@glsp/sprotty-client",
"version": "0.2.0-next.e0bc9960",
"version": "0.2.0-next.e135e793",
"description": "A sprotty-based client for GLSP",

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

"autocompleter": "^4.0.2",
"sprotty": "0.7.0-next.cea0e2b",
"sprotty": "0.7.0-next.3f7128d",
"vscode-ws-jsonrpc": "^0.0.2-1"

@@ -34,0 +34,0 @@ },

@@ -21,36 +21,7 @@ /********************************************************************************

/**
* Provides access to the current `SModelRoot` instance.
*
* This is useful if you need to query the model for some tasks,
* e.g., determine the list of elements, etc.
*
* Note that this provider will only return a copy of the current instance.
* Thus, changes to the returned `SModelRoot` won't have any effect.
* Changes of the `SModelRoot` should be performed inside a command.
*/
export interface IReadonlyModelAccess {
/**
* The current `SModelRoot` instance.
*
* Note that this is a copy of the current instance.
* Thus, changes to the returned `SModelRoot` won't have any effect.
* Changes of the `SModelRoot` should be performed inside a command.
*/
readonly model: Promise<SModelRoot>;
}
export type IReadonlyModelAccessProvider = () => Promise<IReadonlyModelAccess>;
@injectable()
export class GLSPCommandStack extends CommandStack implements IReadonlyModelAccess {
export class GLSPCommandStack extends CommandStack {
@inject(TYPES.IActionDispatcherProvider) protected actionDispatcher: () => Promise<IActionDispatcher>;
get model(): Promise<SModelRoot> {
return this.currentPromise.then(
state => this.modelFactory.createRoot(state.root)
);
}
undo(): Promise<SModelRoot> {

@@ -57,0 +28,0 @@ this.actionDispatcher().then(dispatcher => dispatcher.dispatch(new GlspUndoAction()));

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

import { ContainerModule } from "inversify";
import { configureCommand, Tool, TYPES } from "sprotty/lib";
import { configureActionHandler, configureCommand, SetModelCommand, Tool, TYPES } from "sprotty/lib";
import { SetOperationsAction } from "../features/operation/set-operations";
import { GLSP_TYPES } from "../types";
import { GLSPCommandStack } from "./command-stack";
import { FeedbackAwareUpdateModelCommand, SetModelActionHandler } from "./model/update-model-command";
import { createToolFactory, ToolManagerActionHandler } from "./tool-manager/tool-manager-action-handler";
import { createToolFactory, GLSPToolManagerActionHandler } from "./tool-manager/tool-manager-action-handler";
import { defaultGLSPViewerOptions, GLSPViewerOptions } from "./views/viewer-options";
const defaultGLSPModule = new ContainerModule((bind, unbind, isBound, rebind) => {
const defaultGLSPModule = new ContainerModule((bind, _unbind, isBound, rebind) => {
const context = { bind, _unbind, isBound, rebind };
// Tool manager initialization ------------------------------------
bind(TYPES.IActionHandlerInitializer).to(ToolManagerActionHandler);
configureActionHandler(context, SetOperationsAction.KIND, GLSPToolManagerActionHandler);
bind(GLSP_TYPES.IToolFactory).toFactory<Tool>((createToolFactory()));
// Model update initialization ------------------------------------
configureCommand({ bind, isBound }, FeedbackAwareUpdateModelCommand);
bind(TYPES.IActionHandlerInitializer).to(SetModelActionHandler);
configureCommand(context, FeedbackAwareUpdateModelCommand);
configureActionHandler(context, SetModelCommand.KIND, SetModelActionHandler);

@@ -37,0 +39,0 @@ rebind(TYPES.ICommandStack).to(GLSPCommandStack);

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

CommandExecutionContext,
CommandResult,
CommandReturn,
IActionHandler,
ILogger,

@@ -36,7 +37,7 @@ SetModelAction,

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 {
@injectable()
export class SetModelActionHandler implements IActionHandler {
handle(action: Action): Action | void {

@@ -74,3 +75,3 @@ if (isSetModelAction(action)) {

protected performUpdate(oldRoot: SModelRoot, newRoot: SModelRoot, context: CommandExecutionContext): CommandResult {
protected performUpdate(oldRoot: SModelRoot, newRoot: SModelRoot, context: CommandExecutionContext): CommandReturn {
if (this.feedbackActionDispatcher) {

@@ -77,0 +78,0 @@ // Create a temporary context wich defines the `newRoot` as `root`

@@ -17,12 +17,3 @@ /********************************************************************************

import { inject, injectable, interfaces } from "inversify";
import {
Action,
ActionHandlerRegistry,
IActionHandler,
IActionHandlerInitializer,
ICommand,
Tool,
ToolManager,
TYPES,
} from "sprotty/lib";
import { Action, IActionHandler, ICommand, Tool, ToolManager, TYPES } from "sprotty/lib";

@@ -35,19 +26,6 @@ import { isSetOperationsAction, OperationKind, SetOperationsAction } from "../../features/operation/set-operations";

@injectable()
export abstract class SelfInitializingActionHandler implements IActionHandler, IActionHandlerInitializer {
initialize(registry: ActionHandlerRegistry) {
this.handledActionKinds.forEach(kind => registry.register(kind, this));
}
abstract handle(action: Action): ICommand | Action | void;
abstract handledActionKinds: string[];
}
@injectable()
export class ToolManagerActionHandler extends SelfInitializingActionHandler {
export class GLSPToolManagerActionHandler implements IActionHandler {
@inject(GLSP_TYPES.IToolFactory) readonly toolFactory: (operationKind: string) => Tool;
@inject(TYPES.IToolManager) readonly toolManager: ToolManager;
readonly handledActionKinds = [SetOperationsAction.KIND];
handle(action: Action): void | ICommand | Action {

@@ -54,0 +32,0 @@ if (isSetOperationsAction(action)) {

@@ -16,3 +16,3 @@ /********************************************************************************

********************************************************************************/
import { Action, LabeledAction } from "sprotty/lib";
import { Action, LabeledAction, Point } from "sprotty/lib";

@@ -22,3 +22,6 @@ export class RequestCommandPaletteActions implements Action {

kind = RequestCommandPaletteActions.KIND;
constructor(public readonly selectedElementsIDs: string[] = []) { }
constructor(
public readonly selectedElementIds: string[] = [],
public readonly text: string,
public readonly lastMousePosition?: Point) { }
}

@@ -25,0 +28,0 @@

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

name,
Point,
SelectAction,
SModelElement,
TYPES,
TYPES
} from "sprotty/lib";

@@ -40,10 +41,9 @@ import { toArray } from "sprotty/lib/utils/iterable";

constructor(
constructor(@inject(TYPES.ILogger) protected logger: ILogger) { }
@inject(TYPES.ILogger) protected logger: ILogger) { }
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]> {
return Promise.resolve(toArray(root.index.all()
.filter(isNameable)
.map(nameable => new LabeledAction(`Select ${name(nameable)}`, [new SelectAction([nameable.id]), new CenterAction([nameable.id])]))));
.map(nameable => new LabeledAction(`Select ${name(nameable)}`,
[new SelectAction([nameable.id]), new CenterAction([nameable.id])], 'fa-object-group'))));
}

@@ -54,8 +54,8 @@ }

export class ServerCommandPaletteActionProvider implements ICommandPaletteActionProvider {
constructor(@inject(GLSP_TYPES.RequestResponseSupport) protected requestResponseSupport: RequestResponseSupport) {
}
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]> {
const selectedElementIDs = Array.from(root.index.all().filter(isSelected).map(e => e.id));
const requestAction = new RequestCommandPaletteActions(selectedElementIDs);
constructor(@inject(GLSP_TYPES.RequestResponseSupport) protected requestResponseSupport: RequestResponseSupport) { }
getActions(root: Readonly<SModelElement>, text: string, lastMousePosition?: Point): Promise<LabeledAction[]> {
const selectedElementIds = Array.from(root.index.all().filter(isSelected).map(e => e.id));
const requestAction = new RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition);
const responseHandler = this.getPaletteActionsFromResponse;

@@ -62,0 +62,0 @@ const promise = this.requestResponseSupport.dispatchRequest(requestAction, responseHandler);

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

import { ContainerModule } from "inversify";
import { configureCommand, TYPES } from "sprotty/lib";
import { configureActionHandler, configureCommand } from "sprotty/lib";
import { GLSP_TYPES } from "../../types";
import { SetTypeHintsAction } from "./action-definition";
import { ApplyEditConfigCommand, TypeHintsEditConfigProvider } from "./type-hints-action-initializer";

@@ -25,3 +26,3 @@

bind(TypeHintsEditConfigProvider).toSelf().inSingletonScope();
bind(TYPES.IActionHandlerInitializer).toService(TypeHintsEditConfigProvider);
configureActionHandler({ bind, isBound }, SetTypeHintsAction.KIND, TypeHintsEditConfigProvider);
bind(GLSP_TYPES.IEditConfigProvider).toService(TypeHintsEditConfigProvider);

@@ -28,0 +29,0 @@ configureCommand({ bind, isBound }, ApplyEditConfigCommand);

@@ -20,7 +20,8 @@ /********************************************************************************

CommandExecutionContext,
CommandResult,
CommandReturn,
IActionHandler,
ICommand,
SModelElement,
SModelElementSchema,
TYPES,
TYPES
} from "sprotty/lib";

@@ -36,5 +37,4 @@

NodeEditConfig,
nodeEditConfig,
nodeEditConfig
} from "../../base/edit-config/edit-config";
import { SelfInitializingActionHandler } from "../../base/tool-manager/tool-manager-action-handler";
import { GLSP_TYPES } from "../../types";

@@ -44,3 +44,3 @@ import { contains } from "../../utils/array-utils";

import { FeedbackCommand } from "../tool-feedback/model";
import { EdgeTypeHint, isSetTypeHintsAction, NodeTypeHint, SetTypeHintsAction } from "./action-definition";
import { EdgeTypeHint, isSetTypeHintsAction, NodeTypeHint } from "./action-definition";

@@ -61,3 +61,3 @@

}
execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
context.root.index.all().forEach(element => {

@@ -74,7 +74,6 @@ const config = this.action.editConfigs.get(element.type);

@injectable()
export class TypeHintsEditConfigProvider extends SelfInitializingActionHandler implements IEditConfigProvider {
export class TypeHintsEditConfigProvider implements IActionHandler, IEditConfigProvider {
@inject(GLSP_TYPES.IFeedbackActionDispatcher) protected feedbackActionDispatcher: IFeedbackActionDispatcher;
protected editConfigs: Map<string, EditConfig> = new Map;
readonly handledActionKinds = [SetTypeHintsAction.KIND];

@@ -81,0 +80,0 @@ handle(action: Action): ICommand | Action | void {

@@ -19,6 +19,6 @@ /********************************************************************************

Action,
Bounds,
Command,
CommandExecutionContext,
CommandResult,
CommandReturn,
Dimension,
ElementAndBounds,

@@ -175,3 +175,3 @@ ElementMove,

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const elements = this.getActionElements(context);

@@ -199,4 +199,4 @@ if (elements.length > 1) {

const halfDiffWidth = 0.5 * (targetWidth - element.bounds.width);
bounds.newBounds.x = element.bounds.x - halfDiffWidth;
bounds.newBounds.width = targetWidth;
bounds.newPosition.x = element.bounds.x - halfDiffWidth;
bounds.newSize.width = targetWidth;
});

@@ -210,4 +210,4 @@ }

const halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
bounds.newBounds.y = element.bounds.y - halfDiffHeight;
bounds.newBounds.height = targetHeight;
bounds.newPosition.y = element.bounds.y - halfDiffHeight;
bounds.newSize.height = targetHeight;
});

@@ -223,6 +223,6 @@ }

const halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
bounds.newBounds.x = element.bounds.x - halfDiffWidth;
bounds.newBounds.y = element.bounds.y - halfDiffHeight;
bounds.newBounds.width = targetWidth;
bounds.newBounds.height = targetHeight;
bounds.newPosition.x = element.bounds.x - halfDiffWidth;
bounds.newPosition.y = element.bounds.y - halfDiffHeight;
bounds.newSize.width = targetWidth;
bounds.newSize.height = targetHeight;
});

@@ -240,5 +240,7 @@ }

elementId: element.id,
newBounds: {
newPosition: {
x: element.bounds.x,
y: element.bounds.y,
y: element.bounds.y
},
newSize: {
width: element.bounds.width,

@@ -252,3 +254,3 @@ height: element.bounds.height

undo(context: CommandExecutionContext): CommandResult {
undo(context: CommandExecutionContext): CommandReturn {
// we dispatch another action which can be undone, so no explicit implementation necessary

@@ -258,3 +260,3 @@ return context.root;

redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
// we dispatch another action which can be redone, so no explicit implementation necessary

@@ -275,3 +277,3 @@ return context.root;

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const elements = this.getActionElements(context);

@@ -377,5 +379,7 @@ if (elements.length > 1) {

elementId: element.id,
newBounds: {
newPosition: {
x: move.toPosition.x,
y: move.toPosition.y,
y: move.toPosition.y
},
newSize: {
width: element.bounds.width,

@@ -387,3 +391,3 @@ height: element.bounds.height

undo(context: CommandExecutionContext): CommandResult {
undo(context: CommandExecutionContext): CommandReturn {
// we dispatch another action which can be undone, so no explicit implementation necessary

@@ -393,3 +397,3 @@ return context.root;

redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
// we dispatch another action which can be redone, so no explicit implementation necessary

@@ -422,11 +426,9 @@ return context.root;

interface WriteableDimension extends Dimension {
width: number
height: number
}
interface WriteableElementAndBounds extends ElementAndBounds {
newBounds: WriteableBounds;
newPosition: WriteablePoint;
newSize: WriteableDimension
}
interface WriteableBounds extends Bounds {
x: number;
y: number;
width: number;
height: number;
}

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

const glspMouseToolModule = new ContainerModule((bind, unbind, isBound, rebind) => {
const glspMouseToolModule = new ContainerModule((bind, _unbind, _isBound, rebind) => {
bind(RankingMouseTool).toSelf().inSingletonScope();

@@ -25,0 +25,0 @@ bind(GLSP_TYPES.MouseTool).toService(RankingMouseTool);

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

CommandExecutionContext,
CommandResult,
CommandReturn,
ElementMove,

@@ -63,3 +63,3 @@ findParentByFeature,

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const index = context.root.index;

@@ -86,3 +86,3 @@ index.all().filter(isResizeable).forEach(removeResizeHandles);

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const index = context.root.index;

@@ -89,0 +89,0 @@ index.all().filter(isResizeable).forEach(removeResizeHandles);

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

CommandExecutionContext,
CommandResult,
CommandReturn,
euclideanDistance,

@@ -60,3 +60,3 @@ findChildrenAtPosition,

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
drawFeedbackEdge(context, this.action.sourceId, this.action.elementTypeId);

@@ -76,3 +76,3 @@ return context.root;

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
removeFeedbackEdge(context.root);

@@ -79,0 +79,0 @@ return context.root;

@@ -17,3 +17,3 @@ /********************************************************************************

import { ContainerModule } from "inversify";
import { configureCommand, configureView, LocationDecorator, MoveCommand, TYPES } from "sprotty/lib";
import { configureCommand, configureView, LocationPostprocessor, MoveCommand, TYPES } from "sprotty/lib";

@@ -61,6 +61,6 @@ import { GLSP_TYPES } from "../../types";

bind(TYPES.IVNodeDecorator).to(LocationDecorator);
bind(TYPES.HiddenVNodeDecorator).to(LocationDecorator);
bind(TYPES.IVNodePostprocessor).to(LocationPostprocessor);
bind(TYPES.HiddenVNodePostprocessor).to(LocationPostprocessor);
});
export default toolFeedbackModule;

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

CommandExecutionContext,
CommandResult,
CommandReturn,
EdgeRouterRegistry,

@@ -79,3 +79,3 @@ ElementMove,

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const index = context.root.index;

@@ -102,3 +102,3 @@ index.all().filter(isRoutable).forEach(removeReconnectHandles);

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const index = context.root.index;

@@ -140,3 +140,3 @@ index.all().filter(isRoutable).forEach(removeReconnectHandles);

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
drawFeedbackEdgeSource(context, this.action.targetId, this.action.elementTypeId);

@@ -143,0 +143,0 @@ return context.root;

@@ -16,3 +16,3 @@ /********************************************************************************

********************************************************************************/
import { Command, CommandExecutionContext, CommandResult } from "sprotty/lib";
import { Command, CommandExecutionContext, CommandReturn } from "sprotty/lib";

@@ -23,8 +23,8 @@ export abstract class FeedbackCommand extends Command {

abstract execute(context: CommandExecutionContext): CommandResult;
undo(context: CommandExecutionContext): CommandResult {
abstract execute(context: CommandExecutionContext): CommandReturn;
undo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
return context.root;

@@ -31,0 +31,0 @@ }

@@ -19,12 +19,15 @@ /********************************************************************************

import { ContainerModule } from "inversify";
import { TYPES } from "sprotty/lib";
import { configureActionHandler, EnableDefaultToolsAction, TYPES } from "sprotty/lib";
import { SetOperationsAction } from "../operation/set-operations";
import { ToolPalette, ToolPaletteActionHandler } from "./tool-palette";
const toolPaletteModule = new ContainerModule((bind) => {
const toolPaletteModule = new ContainerModule((bind, _unbind, isBound) => {
bind(ToolPalette).toSelf().inSingletonScope();
bind(TYPES.IUIExtension).toService(ToolPalette);
bind(TYPES.IActionHandlerInitializer).to(ToolPaletteActionHandler);
bind(ToolPaletteActionHandler).toSelf().inSingletonScope();
configureActionHandler({ bind, isBound }, SetOperationsAction.KIND, ToolPaletteActionHandler);
configureActionHandler({ bind, isBound }, EnableDefaultToolsAction.KIND, ToolPaletteActionHandler);
});
export default toolPaletteModule;

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

IActionDispatcher,
IActionHandler,
ICommand,

@@ -30,4 +31,3 @@ SetUIExtensionVisibilityAction,

import { SelfInitializingActionHandler } from "../../base/tool-manager/tool-manager-action-handler";
import { isSetOperationsAction, Operation, parentGroup, SetOperationsAction } from "../operation/set-operations";
import { isSetOperationsAction, Operation, parentGroup } from "../operation/set-operations";
import { deriveToolId } from "../tools/creation-tool";

@@ -195,7 +195,5 @@ import { MouseDeleteTool } from "../tools/delete-tool";

@injectable()
export class ToolPaletteActionHandler extends SelfInitializingActionHandler {
export class ToolPaletteActionHandler implements IActionHandler {
@inject(ToolPalette) protected readonly toolPalette: ToolPalette;
readonly handledActionKinds = [SetOperationsAction.KIND, EnableDefaultToolsAction.KIND];
handle(action: Action): ICommand | Action | void {

@@ -202,0 +200,0 @@ if (isSetOperationsAction(action)) {

@@ -19,4 +19,4 @@ /********************************************************************************

Action,
Bounds,
BoundsAware,
Dimension,
ElementAndBounds,

@@ -37,3 +37,3 @@ findParentByFeature,

import { GLSP_TYPES } from "../../types";
import { forEachElement, isNonRoutableSelectedBoundsAware, isSelected } from "../../utils/smodel-util";
import { forEachElement, isNonRoutableSelectedBoundsAware, isSelected, toElementAndBounds } from "../../utils/smodel-util";
import { isBoundsAwareMoveable, isResizeable, ResizeHandleLocation, SResizeHandle } from "../change-bounds/model";

@@ -285,4 +285,4 @@ import { IMouseTool } from "../mouse-tool/mouse-tool";

function createChangeBoundsAction(element: SModelElement & BoundsAware): Action[] {
if (isValidBoundChange(element, element.bounds)) {
return [new ChangeBoundsOperationAction([{ elementId: element.id, newBounds: element.bounds }])];
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [new ChangeBoundsOperationAction([toElementAndBounds(element)])];
}

@@ -293,4 +293,4 @@ return [];

function createElementAndBounds(element: SModelElement & BoundsAware): ElementAndBounds[] {
if (isValidBoundChange(element, element.bounds)) {
return [{ elementId: element.id, newBounds: element.bounds }];
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [toElementAndBounds(element)];
}

@@ -301,5 +301,7 @@ return [];

function createSetBoundsAction(element: SModelElement & BoundsAware, x: number, y: number, width: number, height: number): Action[] {
const bounds = { x: x, y: y, width: width, height: height };
if (isValidBoundChange(element, bounds)) {
return [new SetBoundsAction([{ elementId: element.id, newBounds: bounds }])];
const newPosition = { x, y };
const newSize = { width, height };
if (isValidBoundChange(element, newPosition, newSize)) {
return [new SetBoundsAction([{ elementId: element.id, newPosition, newSize }])];
}

@@ -309,4 +311,5 @@ return [];

function isValidBoundChange(element: SModelElement & BoundsAware, bounds: Bounds): boolean {
return bounds.width >= minWidth(element) && bounds.height >= minHeight(element);
function isValidBoundChange(element: SModelElement & BoundsAware, newPosition: Point, newSize: Dimension): boolean {
return newSize.width >= minWidth(element) && newSize.height >= minHeight(element);
}

@@ -323,1 +326,3 @@

}

@@ -184,3 +184,3 @@ /********************************************************************************

if (event.button === 0) {
if (this.source === undefined) {
if (!this.isSourceSelected()) {
if (this.currentTarget && this.allowedTarget) {

@@ -195,3 +195,3 @@ this.source = this.currentTarget.id;

}
if (this.source !== undefined && this.target !== undefined) {
if (this.isSourceSelected() && this.isTargetSelected()) {
result.push(new CreateConnectionOperationAction(this.elementTypeId, this.source, this.target));

@@ -210,2 +210,11 @@ if (!isCtrlOrCmd(event)) {

private isSourceSelected() {
return this.source !== undefined;
}
private isTargetSelected() {
return this.target !== undefined;
}
mouseOver(target: SModelElement, event: MouseEvent): Action[] {

@@ -216,5 +225,9 @@ const newCurrentTarget = findParentByFeature(target, isConnectable);

if (this.currentTarget) {
this.allowedTarget = this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(this.currentTarget) : false;
if (!this.isSourceSelected()) {
this.allowedTarget = this.isAllowedSource(newCurrentTarget);
} else if (!this.isTargetSelected()) {
this.allowedTarget = this.isAllowedTarget(newCurrentTarget);
}
if (this.allowedTarget) {
const action = this.source === undefined ? new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_SOURCE) :
const action = !this.isSourceSelected() ? new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_SOURCE) :
new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_TARGET);

@@ -228,2 +241,10 @@ return [action];

}
private isAllowedSource(element: SModelElement | undefined): boolean {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false;
}
private isAllowedTarget(element: SModelElement | undefined): boolean {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false;
}
}

@@ -21,3 +21,3 @@ /********************************************************************************

CommandExecutionContext,
CommandResult,
CommandReturn,
IActionDispatcher,

@@ -112,3 +112,3 @@ SIssue,

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const markers: Marker[] = this.action.markers;

@@ -120,7 +120,7 @@ const applyMarkersAction: ApplyMarkersAction = new ApplyMarkersAction(markers);

undo(context: CommandExecutionContext): CommandResult {
undo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
return this.execute(context);

@@ -152,3 +152,3 @@ }

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const markers: Marker[] = this.action.markers;

@@ -166,7 +166,7 @@ for (const marker of markers) {

undo(context: CommandExecutionContext): CommandResult {
undo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
return this.execute(context);

@@ -264,3 +264,3 @@ }

execute(context: CommandExecutionContext): CommandResult {
execute(context: CommandExecutionContext): CommandReturn {
const markers: Marker[] = this.action.markers;

@@ -287,9 +287,9 @@ for (const marker of markers) {

undo(context: CommandExecutionContext): CommandResult {
undo(context: CommandExecutionContext): CommandReturn {
return context.root;
}
redo(context: CommandExecutionContext): CommandResult {
redo(context: CommandExecutionContext): CommandReturn {
return this.execute(context);
}
}

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

export * from './utils/viewpoint-util';
export * from "./model-source/glsp-server-status";
export {

@@ -69,0 +71,0 @@ validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, //

@@ -67,3 +67,3 @@ /********************************************************************************

if (action instanceof RequestModelAction && action.options !== undefined)
this._sourceUri = action.options.sourceUri;
this._sourceUri = <string>action.options.sourceUri;
return super.handle(action);

@@ -70,0 +70,0 @@ }

@@ -90,1 +90,15 @@ /********************************************************************************

export type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;
export function toElementAndBounds(element: SModelElement & BoundsAware) {
return {
elementId: element.id,
newPosition: {
x: element.bounds.x,
y: element.bounds.y
},
newSize: {
width: element.bounds.width,
height: element.bounds.height
}
};
}

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

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

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