@eclipse-glsp/server 1.1.0-next.f692ea4.55 → 2.1.0-next.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/launch/worker-server-launcher.js +2 -2
- package/lib/browser/launch/worker-server-launcher.js.map +1 -1
- package/lib/common/actions/action-dispatcher.d.ts +2 -1
- package/lib/common/actions/action-dispatcher.d.ts.map +1 -1
- package/lib/common/actions/action-dispatcher.js +9 -7
- package/lib/common/actions/action-dispatcher.js.map +1 -1
- package/lib/common/actions/action-handler-registry.js +4 -4
- package/lib/common/actions/action-handler-registry.js.map +1 -1
- package/lib/common/actions/client-action-handler.d.ts +17 -8
- package/lib/common/actions/client-action-handler.d.ts.map +1 -1
- package/lib/common/actions/client-action-handler.js +32 -22
- package/lib/common/actions/client-action-handler.js.map +1 -1
- package/lib/common/actions/global-action-provider.d.ts +6 -21
- package/lib/common/actions/global-action-provider.d.ts.map +1 -1
- package/lib/common/actions/global-action-provider.js +17 -22
- package/lib/common/actions/global-action-provider.js.map +1 -1
- package/lib/common/command/command-stack.js +2 -2
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/command.js +1 -1
- package/lib/common/command/command.js.map +1 -1
- package/lib/common/command/recording-command.d.ts +9 -15
- package/lib/common/command/recording-command.d.ts.map +1 -1
- package/lib/common/command/recording-command.js +12 -26
- package/lib/common/command/recording-command.js.map +1 -1
- package/lib/common/command/undo-redo-action-handler.js +2 -2
- package/lib/common/command/undo-redo-action-handler.js.map +1 -1
- package/lib/common/di/binding-target.d.ts.map +1 -1
- package/lib/common/di/binding-target.js +3 -2
- package/lib/common/di/binding-target.js.map +1 -1
- package/lib/common/di/client-session-module.d.ts +9 -1
- package/lib/common/di/client-session-module.d.ts.map +1 -1
- package/lib/common/di/client-session-module.js +9 -9
- package/lib/common/di/client-session-module.js.map +1 -1
- package/lib/common/di/diagram-module.d.ts +23 -1
- package/lib/common/di/diagram-module.d.ts.map +1 -1
- package/lib/common/di/diagram-module.js +23 -53
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/di/glsp-module.js +2 -2
- package/lib/common/di/glsp-module.js.map +1 -1
- package/lib/common/di/server-module.d.ts +0 -1
- package/lib/common/di/server-module.d.ts.map +1 -1
- package/lib/common/di/server-module.js +0 -1
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/diagram/diagram-configuration.js +1 -1
- package/lib/common/diagram/diagram-configuration.js.map +1 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts.map +1 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +2 -2
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -1
- package/lib/common/features/contextactions/command-palette-action-provider.js +2 -2
- package/lib/common/features/contextactions/command-palette-action-provider.js.map +1 -1
- package/lib/common/features/contextactions/context-actions-provider-registry.js +2 -2
- package/lib/common/features/contextactions/context-actions-provider-registry.js.map +1 -1
- package/lib/common/features/contextactions/context-menu-item-provider.js +2 -2
- package/lib/common/features/contextactions/context-menu-item-provider.js.map +1 -1
- package/lib/common/features/contextactions/request-context-actions-handler.js +2 -2
- package/lib/common/features/contextactions/request-context-actions-handler.js.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.js +4 -4
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
- package/lib/common/features/directediting/context-edit-validator-registry.js +2 -2
- package/lib/common/features/directediting/context-edit-validator-registry.js.map +1 -1
- package/lib/common/features/directediting/label-edit-validator.js +2 -2
- package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
- package/lib/common/features/directediting/request-edit-validation-handler.js +2 -2
- package/lib/common/features/directediting/request-edit-validation-handler.js.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js +2 -2
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +2 -2
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/gmodel-factory.js +2 -2
- package/lib/common/features/model/gmodel-factory.js.map +1 -1
- package/lib/common/features/model/gmodel-index.js +2 -2
- package/lib/common/features/model/gmodel-index.js.map +1 -1
- package/lib/common/features/model/gmodel-serializer.d.ts +10 -10
- package/lib/common/features/model/gmodel-serializer.d.ts.map +1 -1
- package/lib/common/features/model/gmodel-serializer.js +2 -2
- package/lib/common/features/model/gmodel-serializer.js.map +1 -1
- package/lib/common/features/model/model-state.d.ts.map +1 -1
- package/lib/common/features/model/model-state.js +5 -2
- package/lib/common/features/model/model-state.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +30 -3
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +73 -9
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/request-model-action-handler.d.ts +5 -6
- package/lib/common/features/model/request-model-action-handler.d.ts.map +1 -1
- package/lib/common/features/model/request-model-action-handler.js +37 -15
- package/lib/common/features/model/request-model-action-handler.js.map +1 -1
- package/lib/common/features/model/save-model-action-handler.js +2 -2
- package/lib/common/features/model/save-model-action-handler.js.map +1 -1
- package/lib/common/features/navigation/navigation-target-provider-registry.js +2 -2
- package/lib/common/features/navigation/navigation-target-provider-registry.js.map +1 -1
- package/lib/common/features/navigation/navigation-target-resolver.js +2 -2
- package/lib/common/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js +2 -2
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js.map +1 -1
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js +2 -2
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js.map +1 -1
- package/lib/common/features/popup/request-popup-model-action-handler.js +2 -2
- package/lib/common/features/popup/request-popup-model-action-handler.js.map +1 -1
- package/lib/common/features/progress/progress-service.d.ts +44 -0
- package/lib/common/features/progress/progress-service.d.ts.map +1 -0
- package/lib/common/features/progress/progress-service.js +51 -0
- package/lib/common/features/progress/progress-service.js.map +1 -0
- package/lib/common/features/type-hints/edge-creation-checker.d.ts +42 -0
- package/lib/common/features/type-hints/edge-creation-checker.d.ts.map +1 -0
- package/lib/common/features/type-hints/edge-creation-checker.js +20 -0
- package/lib/common/features/type-hints/edge-creation-checker.js.map +1 -0
- package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts +29 -0
- package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts.map +1 -0
- package/lib/common/features/type-hints/request-check-edge-action-handler.js +72 -0
- package/lib/common/features/type-hints/request-check-edge-action-handler.js.map +1 -0
- package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.d.ts +2 -3
- package/lib/common/features/type-hints/request-type-hints-action-handler.d.ts.map +1 -0
- package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.js +3 -4
- package/lib/common/features/type-hints/request-type-hints-action-handler.js.map +1 -0
- package/lib/common/features/validation/model-validator.d.ts +47 -2
- package/lib/common/features/validation/model-validator.d.ts.map +1 -1
- package/lib/common/features/validation/model-validator.js +80 -1
- package/lib/common/features/validation/model-validator.js.map +1 -1
- package/lib/common/features/validation/request-markers-handler.d.ts +15 -0
- package/lib/common/features/validation/request-markers-handler.d.ts.map +1 -1
- package/lib/common/features/validation/request-markers-handler.js +5 -11
- package/lib/common/features/validation/request-markers-handler.js.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +2 -2
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js +2 -2
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +2 -2
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/cut-operation-handler.js +7 -5
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.d.ts +1 -1
- package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.js +7 -7
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +3 -3
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +2 -2
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +3 -3
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +2 -2
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.js +2 -2
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
- package/lib/common/gmodel/gmodel-operation-handler.js +1 -1
- package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +2 -2
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +2 -2
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +3 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/launch/glsp-server-launcher.js +2 -2
- package/lib/common/launch/glsp-server-launcher.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.js +2 -2
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
- package/lib/common/operations/compound-operation-handler.d.ts +5 -0
- package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +12 -12
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/create-operation-handler.d.ts +19 -5
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/create-operation-handler.js +3 -2
- package/lib/common/operations/create-operation-handler.js.map +1 -1
- package/lib/common/operations/json-operation-handler.d.ts +94 -0
- package/lib/common/operations/json-operation-handler.d.ts.map +1 -0
- package/lib/common/operations/json-operation-handler.js +120 -0
- package/lib/common/operations/json-operation-handler.js.map +1 -0
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-action-handler.js +3 -3
- package/lib/common/operations/operation-action-handler.js.map +1 -1
- package/lib/common/operations/operation-handler-registry.d.ts +1 -9
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
- package/lib/common/operations/operation-handler-registry.js +4 -14
- package/lib/common/operations/operation-handler-registry.js.map +1 -1
- package/lib/common/operations/operation-handler.d.ts +2 -2
- package/lib/common/operations/operation-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-handler.js +2 -2
- package/lib/common/operations/operation-handler.js.map +1 -1
- package/lib/common/protocol/client-action.d.ts +31 -0
- package/lib/common/protocol/client-action.d.ts.map +1 -0
- package/lib/common/protocol/client-action.js +35 -0
- package/lib/common/protocol/client-action.js.map +1 -0
- package/lib/common/protocol/glsp-server.d.ts +1 -1
- package/lib/common/protocol/glsp-server.d.ts.map +1 -1
- package/lib/common/protocol/glsp-server.js +9 -11
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/session/client-session-factory.js +5 -5
- package/lib/common/session/client-session-factory.js.map +1 -1
- package/lib/common/session/client-session-manager.js +2 -2
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/common/utils/args-util.js +2 -2
- package/lib/common/utils/args-util.js.map +1 -1
- package/lib/common/utils/client-options-util.d.ts +3 -0
- package/lib/common/utils/client-options-util.d.ts.map +1 -1
- package/lib/common/utils/client-options-util.js +5 -15
- package/lib/common/utils/client-options-util.js.map +1 -1
- package/lib/common/utils/console-logger.js +2 -2
- package/lib/common/utils/console-logger.js.map +1 -1
- package/lib/common/utils/logger.d.ts.map +1 -1
- package/lib/common/utils/logger.js +5 -4
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/common/utils/promise-queue.d.ts.map +1 -1
- package/lib/common/utils/promise-queue.js +3 -6
- package/lib/common/utils/promise-queue.js.map +1 -1
- package/lib/common/utils/registry.d.ts +3 -1
- package/lib/common/utils/registry.d.ts.map +1 -1
- package/lib/common/utils/registry.js +15 -6
- package/lib/common/utils/registry.js.map +1 -1
- package/lib/node/abstract-json-model-storage.d.ts.map +1 -1
- package/lib/node/abstract-json-model-storage.js +10 -4
- package/lib/node/abstract-json-model-storage.js.map +1 -1
- package/lib/node/gmodel/gmodel-storage.d.ts.map +1 -1
- package/lib/node/gmodel/gmodel-storage.js +4 -3
- package/lib/node/gmodel/gmodel-storage.js.map +1 -1
- package/lib/node/launch/cli-parser.js +1 -1
- package/lib/node/launch/cli-parser.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.js +2 -2
- package/lib/node/launch/socket-server-launcher.js.map +1 -1
- package/lib/node/launch/websocket-server-launcher.js +2 -2
- package/lib/node/launch/websocket-server-launcher.js.map +1 -1
- package/package.json +7 -6
- package/src/common/actions/action-dispatcher.spec.ts +3 -2
- package/src/common/actions/action-dispatcher.ts +8 -5
- package/src/common/actions/client-action-handler.ts +28 -18
- package/src/common/actions/global-action-provider.spec.ts +4 -15
- package/src/common/actions/global-action-provider.ts +21 -25
- package/src/common/command/recording-command.spec.ts +15 -5
- package/src/common/command/recording-command.ts +16 -27
- package/src/common/di/binding-target.ts +1 -0
- package/src/common/di/client-session-module.ts +17 -10
- package/src/common/di/diagram-module.ts +31 -70
- package/src/common/di/server-module.ts +0 -1
- package/src/common/features/clipboard/request-clipboard-data-action-handler.ts +3 -3
- package/src/common/features/model/gmodel-serializer.ts +11 -11
- package/src/common/features/model/model-state.ts +3 -0
- package/src/common/features/model/model-submission-handler.ts +64 -7
- package/src/common/features/model/request-model-action-handler.ts +37 -17
- package/src/common/features/progress/progress-service.ts +74 -0
- package/src/common/features/type-hints/edge-creation-checker.ts +44 -0
- package/src/common/features/type-hints/request-check-edge-action-handler.ts +62 -0
- package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.spec.ts +2 -2
- package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.ts +2 -3
- package/src/common/features/validation/model-validator.ts +75 -3
- package/src/common/features/validation/request-markers-handler.ts +4 -10
- package/src/common/gmodel/cut-operation-handler.ts +5 -3
- package/src/common/gmodel/delete-operation-handler.ts +6 -5
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +3 -3
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +3 -3
- package/src/common/gmodel/paste-operation-handler.ts +2 -2
- package/src/common/index.ts +3 -1
- package/src/common/operations/compound-operation-handler.ts +6 -1
- package/src/common/operations/create-operation-handler.ts +22 -5
- package/src/common/operations/json-operation-handler.ts +147 -0
- package/src/common/operations/operation-action-handler.ts +2 -2
- package/src/common/operations/operation-handler-registry.ts +1 -12
- package/src/common/operations/operation-handler.ts +2 -2
- package/src/common/protocol/client-action.ts +38 -0
- package/src/common/protocol/glsp-server.spec.ts +11 -10
- package/src/common/protocol/glsp-server.ts +11 -14
- package/src/common/session/client-session-factory.spec.ts +2 -2
- package/src/common/session/client-session-factory.ts +3 -3
- package/src/common/session/client-session-manager.spec.ts +4 -3
- package/src/common/utils/args-util.ts +1 -1
- package/src/common/utils/client-options-util.ts +8 -0
- package/src/common/utils/logger.ts +2 -1
- package/src/common/utils/promise-queue.ts +4 -5
- package/src/common/utils/registry.spec.ts +3 -1
- package/src/common/utils/registry.ts +8 -3
- package/src/node/abstract-json-model-storage.ts +8 -2
- package/src/node/gmodel/gmodel-storage.ts +3 -3
- package/src/node/launch/cli-parser.ts +1 -1
- package/lib/common/diagram/request-type-hints-action-handler.d.ts.map +0 -1
- package/lib/common/diagram/request-type-hints-action-handler.js.map +0 -1
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { Action, Disposable, flatPush, MaybeArray, RequestAction, ResponseAction, UpdateModelAction } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
|
-
import {
|
|
18
|
+
import { ClientId } from '../di/service-identifiers';
|
|
19
19
|
import { GLSPServerError } from '../utils/glsp-server-error';
|
|
20
20
|
import { Logger } from '../utils/logger';
|
|
21
21
|
import { PromiseQueue } from '../utils/promise-queue';
|
|
22
22
|
import { ActionHandler } from './action-handler';
|
|
23
23
|
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
24
|
+
import { ClientActionForwarder } from './client-action-handler';
|
|
24
25
|
|
|
25
26
|
export const ActionDispatcher = Symbol('ActionDispatcher');
|
|
26
27
|
|
|
@@ -62,8 +63,8 @@ export class DefaultActionDispatcher implements ActionDispatcher, Disposable {
|
|
|
62
63
|
@inject(ActionHandlerRegistry)
|
|
63
64
|
protected actionHandlerRegistry: ActionHandlerRegistry;
|
|
64
65
|
|
|
65
|
-
@inject(
|
|
66
|
-
protected
|
|
66
|
+
@inject(ClientActionForwarder)
|
|
67
|
+
protected clientActionForwarder: ClientActionForwarder;
|
|
67
68
|
|
|
68
69
|
@inject(Logger)
|
|
69
70
|
private logger: Logger;
|
|
@@ -76,7 +77,7 @@ export class DefaultActionDispatcher implements ActionDispatcher, Disposable {
|
|
|
76
77
|
|
|
77
78
|
dispatch(action: Action): Promise<void> {
|
|
78
79
|
// Dont queue actions that are just delegated to the client
|
|
79
|
-
if (this.
|
|
80
|
+
if (this.clientActionForwarder.shouldForwardToClient(action)) {
|
|
80
81
|
return this.doDispatch(action);
|
|
81
82
|
}
|
|
82
83
|
return this.actionQueue.enqueue(() => this.doDispatch(action));
|
|
@@ -84,8 +85,10 @@ export class DefaultActionDispatcher implements ActionDispatcher, Disposable {
|
|
|
84
85
|
|
|
85
86
|
protected async doDispatch(action: Action): Promise<void> {
|
|
86
87
|
this.logger.debug('Dispatch action:', action.kind);
|
|
88
|
+
const handledOnClient = this.clientActionForwarder.handle(action);
|
|
89
|
+
|
|
87
90
|
const actionHandlers = this.actionHandlerRegistry.get(action.kind);
|
|
88
|
-
if (actionHandlers.length === 0) {
|
|
91
|
+
if (!handledOnClient && actionHandlers.length === 0) {
|
|
89
92
|
throw new GLSPServerError(`No handler registered for action kind: ${action.kind}`);
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -13,37 +13,47 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action, ActionMessage, GLSPClientProxy } from '@eclipse-glsp/protocol';
|
|
17
|
-
import { inject, injectable
|
|
16
|
+
import { Action, ActionMessage, GLSPClientProxy, ResponseAction } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
18
|
import { ClientActionKinds, ClientId } from '../di/service-identifiers';
|
|
19
|
+
import { ClientAction } from '../protocol/client-action';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* Component responsible for forwarding actions that are (also) handled by the
|
|
23
|
+
* client
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
25
|
@injectable()
|
|
26
|
-
export class
|
|
26
|
+
export class ClientActionForwarder {
|
|
27
27
|
@inject(GLSPClientProxy)
|
|
28
|
-
|
|
29
|
-
protected glspClient?: GLSPClientProxy;
|
|
28
|
+
protected glspClient: GLSPClientProxy;
|
|
30
29
|
|
|
31
30
|
@inject(ClientId)
|
|
32
31
|
protected readonly clientId: string;
|
|
33
32
|
|
|
34
|
-
constructor(@inject(ClientActionKinds)
|
|
33
|
+
constructor(@inject(ClientActionKinds) public actionKinds: Set<string>) {}
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Processes the given action and checks wether it is a
|
|
37
|
+
* `clientAction` i.e. an action that should be forwarded to
|
|
38
|
+
* the client to be handled there. If the check is successful
|
|
39
|
+
* the action is wrapped in an {@link ActionMessage} and sent to the client.
|
|
40
|
+
*
|
|
41
|
+
* @param action The action to check and forward
|
|
42
|
+
* @return `true` if the action was forwarded to the client, `false` otherwise
|
|
43
|
+
*/
|
|
44
|
+
handle(action: Action): boolean {
|
|
45
|
+
if (this.shouldForwardToClient(action)) {
|
|
46
|
+
const message: ActionMessage = { action, clientId: this.clientId };
|
|
47
|
+
this.glspClient.process(message);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.glspClient.process(message);
|
|
45
|
-
return;
|
|
53
|
+
shouldForwardToClient(action: Action): boolean {
|
|
54
|
+
if (ClientAction.is(action)) {
|
|
55
|
+
return false;
|
|
46
56
|
}
|
|
47
|
-
|
|
57
|
+
return this.actionKinds.has(action.kind) || ResponseAction.is(action);
|
|
48
58
|
}
|
|
49
59
|
}
|
|
@@ -13,21 +13,20 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { expect } from 'chai';
|
|
16
17
|
import { Container, ContainerModule } from 'inversify';
|
|
17
|
-
import
|
|
18
|
+
import * as sinon from 'sinon';
|
|
19
|
+
import { DiagramModules, InjectionContainer } from '../di/service-identifiers';
|
|
18
20
|
import { ClientSessionInitializer } from '../session/client-session-initializer';
|
|
19
21
|
import * as mock from '../test/mock-util';
|
|
20
22
|
import { Logger } from '../utils/logger';
|
|
21
23
|
import { ActionHandler } from './action-handler';
|
|
22
24
|
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
23
25
|
import { DefaultGlobalActionProvider } from './global-action-provider';
|
|
24
|
-
import * as sinon from 'sinon';
|
|
25
|
-
import { expect } from 'chai';
|
|
26
26
|
|
|
27
27
|
describe('test DefaultGlobalActionProvider', () => {
|
|
28
28
|
const container = new Container();
|
|
29
29
|
const serverActions = ['A1', 'A2', 'A3'];
|
|
30
|
-
const clientActions = ['C1', 'C2'];
|
|
31
30
|
const diagramType = 'myDiagramType';
|
|
32
31
|
|
|
33
32
|
const handler1Actions = ['A1', 'A2'];
|
|
@@ -44,8 +43,6 @@ describe('test DefaultGlobalActionProvider', () => {
|
|
|
44
43
|
bind(ActionHandler).toConstantValue(new mock.StubActionHandler(handler1Actions));
|
|
45
44
|
bind(ActionHandler).toConstantValue(new mock.StubActionHandler(handler2Actions));
|
|
46
45
|
bind(ActionHandlerRegistry).toConstantValue(handlerRegistry);
|
|
47
|
-
bind(ClientActionKinds).toConstantValue(clientActions[0]);
|
|
48
|
-
bind(ClientActionKinds).toConstantValue(clientActions[1]);
|
|
49
46
|
});
|
|
50
47
|
|
|
51
48
|
const diagramModules = new Map<string, ContainerModule[]>();
|
|
@@ -62,18 +59,10 @@ describe('test DefaultGlobalActionProvider', () => {
|
|
|
62
59
|
const actionProvider = container.resolve(DefaultGlobalActionProvider);
|
|
63
60
|
|
|
64
61
|
it('serverActionsKinds', () => {
|
|
65
|
-
const result = actionProvider.
|
|
62
|
+
const result = actionProvider.actionKinds;
|
|
66
63
|
expect(result.size).to.be.equal(1);
|
|
67
64
|
const resultServerActions = result.get(diagramType);
|
|
68
65
|
expect(resultServerActions).to.not.be.undefined;
|
|
69
66
|
expect(serverActions.every(action => resultServerActions!.includes(action))).true;
|
|
70
67
|
});
|
|
71
|
-
|
|
72
|
-
it('clientActionKinds', () => {
|
|
73
|
-
const result = actionProvider.clientActionKinds;
|
|
74
|
-
expect(result.size).to.be.equal(1);
|
|
75
|
-
const resultClientActions = result.get(diagramType);
|
|
76
|
-
expect(resultClientActions).to.not.be.undefined;
|
|
77
|
-
expect(clientActions.every(action => resultClientActions!.includes(action))).true;
|
|
78
|
-
});
|
|
79
68
|
});
|
|
@@ -13,60 +13,56 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { distinctAdd } from '@eclipse-glsp/protocol';
|
|
16
17
|
import { Container, ContainerModule, inject, injectable } from 'inversify';
|
|
17
|
-
import {
|
|
18
|
+
import { createClientSessionModule } from '../di/client-session-module';
|
|
19
|
+
import { DiagramModules, InjectionContainer } from '../di/service-identifiers';
|
|
18
20
|
import { ClientSessionInitializer } from '../session/client-session-initializer';
|
|
19
21
|
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
20
|
-
import { ClientActionHandler } from './client-action-handler';
|
|
21
22
|
|
|
22
23
|
export const GlobalActionProvider = Symbol('GlobalActionProvider');
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Provides a map of handled action kinds grouped by `diagramType`
|
|
27
|
+
*/
|
|
24
28
|
export interface GlobalActionProvider {
|
|
25
|
-
readonly
|
|
26
|
-
readonly clientActionKinds: Map<string, string[]>;
|
|
29
|
+
readonly actionKinds: Map<string, string[]>;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
@injectable()
|
|
30
33
|
export class DefaultGlobalActionProvider implements GlobalActionProvider {
|
|
31
|
-
public readonly
|
|
32
|
-
public readonly clientActionKinds: Map<string, string[]>;
|
|
34
|
+
public readonly actionKinds: Map<string, string[]>;
|
|
33
35
|
|
|
34
36
|
constructor(
|
|
35
37
|
@inject(InjectionContainer) serverContainer: Container,
|
|
36
38
|
@inject(DiagramModules) diagramModules: Map<string, ContainerModule[]>
|
|
37
39
|
) {
|
|
38
|
-
this.
|
|
39
|
-
this.clientActionKinds = new Map();
|
|
40
|
+
this.actionKinds = new Map();
|
|
40
41
|
diagramModules.forEach((modules, diagramType) => {
|
|
41
42
|
const container = this.createDiagramContainer(serverContainer, modules);
|
|
42
43
|
const initializers = container.getAll<ClientSessionInitializer>(ClientSessionInitializer);
|
|
43
44
|
initializers.forEach(service => service.initialize());
|
|
44
|
-
this.
|
|
45
|
-
this.loadClientActionKinds(diagramType, container);
|
|
45
|
+
this.loadActionKinds(diagramType, container);
|
|
46
46
|
container.unbindAll();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
createDiagramContainer(serverContainer: Container, modules: ContainerModule[]): Container {
|
|
51
51
|
const container = serverContainer.createChild();
|
|
52
|
-
|
|
52
|
+
const clientSessionModule = createClientSessionModule({
|
|
53
|
+
clientId: 'tempId',
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
55
|
+
glspClient: { process: () => {} },
|
|
56
|
+
clientActionKinds: []
|
|
57
|
+
});
|
|
58
|
+
container.load(...modules, clientSessionModule);
|
|
53
59
|
return container;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
loadActionKinds(diagramType: string, diagramContainer: Container): void {
|
|
57
63
|
const handlerRegistry = diagramContainer.get<ActionHandlerRegistry>(ActionHandlerRegistry);
|
|
58
|
-
const diagramServerActions = this.
|
|
59
|
-
handlerRegistry
|
|
60
|
-
|
|
61
|
-
.filter(handler => !(handler instanceof ClientActionHandler))
|
|
62
|
-
.forEach(handler => diagramServerActions.push(...handler.actionKinds));
|
|
63
|
-
this.serverActionKinds.set(diagramType, [...new Set(diagramServerActions)]);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
loadClientActionKinds(diagramType: string, diagramContainer: Container): void {
|
|
67
|
-
const clientActionKinds = diagramContainer.getAll<string>(ClientActionKinds);
|
|
68
|
-
const diagramClientActions = this.clientActionKinds.get(diagramType) ?? [];
|
|
69
|
-
diagramClientActions.push(...clientActionKinds);
|
|
70
|
-
this.clientActionKinds.set(diagramType, diagramClientActions);
|
|
64
|
+
const diagramServerActions = this.actionKinds.get(diagramType) ?? [];
|
|
65
|
+
handlerRegistry.getAll().forEach(handler => distinctAdd(diagramServerActions, ...handler.actionKinds));
|
|
66
|
+
this.actionKinds.set(diagramType, diagramServerActions);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import { AnyObject } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { AnyObject, MaybePromise } from '@eclipse-glsp/protocol';
|
|
18
18
|
import { expect } from 'chai';
|
|
19
|
-
import {
|
|
19
|
+
import { AbstractRecordingCommand } from './recording-command';
|
|
20
20
|
|
|
21
21
|
interface TestModel {
|
|
22
22
|
string: string;
|
|
@@ -27,6 +27,16 @@ interface TestModel {
|
|
|
27
27
|
|
|
28
28
|
let jsonObject: TestModel;
|
|
29
29
|
|
|
30
|
+
class TestRecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
|
|
31
|
+
constructor(protected jsonObject: JsonObject, protected doExecute: () => MaybePromise<void>) {
|
|
32
|
+
super();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected getJsonObject(): MaybePromise<JsonObject> {
|
|
36
|
+
return this.jsonObject;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
describe('RecordingCommand', () => {
|
|
31
41
|
let beforeState: TestModel;
|
|
32
42
|
|
|
@@ -41,14 +51,14 @@ describe('RecordingCommand', () => {
|
|
|
41
51
|
|
|
42
52
|
it('should be undoable after execution', async () => {
|
|
43
53
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
44
|
-
const command = new
|
|
54
|
+
const command = new TestRecordingCommand(jsonObject, () => {});
|
|
45
55
|
expect(command.canUndo()).to.be.false;
|
|
46
56
|
await command.execute();
|
|
47
57
|
expect(command.canUndo()).to.be.true;
|
|
48
58
|
});
|
|
49
59
|
|
|
50
60
|
it('should restore the pre execution state when undo is called', async () => {
|
|
51
|
-
const command = new
|
|
61
|
+
const command = new TestRecordingCommand(jsonObject, () => {
|
|
52
62
|
jsonObject.string = 'bar';
|
|
53
63
|
jsonObject.flag = false;
|
|
54
64
|
jsonObject.maybe = { hello: 'world' };
|
|
@@ -60,7 +70,7 @@ describe('RecordingCommand', () => {
|
|
|
60
70
|
});
|
|
61
71
|
|
|
62
72
|
it('should restore the post execution state when redo is called', async () => {
|
|
63
|
-
const command = new
|
|
73
|
+
const command = new TestRecordingCommand(jsonObject, () => {
|
|
64
74
|
jsonObject.string = 'bar';
|
|
65
75
|
jsonObject.flag = false;
|
|
66
76
|
jsonObject.maybe = { hello: 'world' };
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import { GModelRootSchema } from '@eclipse-glsp/
|
|
18
|
-
import { AnyObject, MaybePromise } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { AnyObject, GModelElementSchema, GModelRootSchema, MaybePromise } from '@eclipse-glsp/protocol';
|
|
19
18
|
import * as jsonPatch from 'fast-json-patch';
|
|
20
19
|
import { GModelSerializer } from '../features/model/gmodel-serializer';
|
|
21
20
|
import { ModelState } from '../features/model/model-state';
|
|
@@ -34,6 +33,7 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
34
33
|
const afterState = await this.getJsonObject();
|
|
35
34
|
this.undoPatch = jsonPatch.compare(afterState, beforeState);
|
|
36
35
|
this.redoPatch = jsonPatch.compare(beforeState, afterState);
|
|
36
|
+
this.postChange?.(afterState);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -48,8 +48,8 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
48
48
|
*/
|
|
49
49
|
protected abstract doExecute(): MaybePromise<void>;
|
|
50
50
|
|
|
51
|
-
protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]):
|
|
52
|
-
jsonPatch.applyPatch(object, patch, false, true);
|
|
51
|
+
protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): jsonPatch.PatchResult<JsonObject> {
|
|
52
|
+
return jsonPatch.applyPatch(object, patch, false, true);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -64,33 +64,28 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
64
64
|
|
|
65
65
|
async undo(): Promise<void> {
|
|
66
66
|
if (this.undoPatch) {
|
|
67
|
-
|
|
67
|
+
const result = this.applyPatch(await this.getJsonObject(), this.undoPatch);
|
|
68
|
+
this.postChange?.(result.newDocument);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
async redo(): Promise<void> {
|
|
72
73
|
if (this.redoPatch) {
|
|
73
|
-
|
|
74
|
+
const result = this.applyPatch(await this.getJsonObject(), this.redoPatch);
|
|
75
|
+
this.postChange?.(result.newDocument);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
canUndo(): boolean {
|
|
78
80
|
return !!this.undoPatch && !!this.redoPatch;
|
|
79
81
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Simple base implementation of {@link AbstractRecordingCommand} that records the changes made to the given JSON object during
|
|
84
|
-
* the the given `doExecute` function.
|
|
85
|
-
*/
|
|
86
|
-
export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
|
|
87
|
-
constructor(protected jsonObject: JsonObject, protected doExecute: () => MaybePromise<void>) {
|
|
88
|
-
super();
|
|
89
|
-
}
|
|
90
82
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Optional hook that (if implemented) will be
|
|
85
|
+
* executed after every command-driven action that changed
|
|
86
|
+
* the underlying model i.e. command execute, undo and redo.
|
|
87
|
+
*/
|
|
88
|
+
protected postChange?(newModel: JsonObject): MaybePromise<void>;
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
/**
|
|
@@ -102,18 +97,12 @@ export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootS
|
|
|
102
97
|
super();
|
|
103
98
|
}
|
|
104
99
|
|
|
105
|
-
override async execute(): Promise<void> {
|
|
106
|
-
await super.execute();
|
|
107
|
-
this.modelState.index.indexRoot(this.modelState.root);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
100
|
protected getJsonObject(): MaybePromise<GModelRootSchema> {
|
|
111
101
|
return this.serializer.createSchema(this.modelState.root);
|
|
112
102
|
}
|
|
113
103
|
|
|
114
|
-
protected override
|
|
115
|
-
|
|
116
|
-
const newRoot = this.serializer.createRoot(rootSchema);
|
|
104
|
+
protected override postChange(newModel: GModelElementSchema): MaybePromise<void> {
|
|
105
|
+
const newRoot = this.serializer.createRoot(newModel);
|
|
117
106
|
this.modelState.updateRoot(newRoot);
|
|
118
107
|
}
|
|
119
108
|
}
|
|
@@ -13,17 +13,24 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { GLSPClientProxy } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { GLSPClientProxy, bindOrRebind } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import { ClientId } from './service-identifiers';
|
|
18
|
+
import { ClientActionKinds, ClientId } from './service-identifiers';
|
|
19
19
|
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
export interface ClientSessionModuleOptions {
|
|
21
|
+
clientId: string;
|
|
22
|
+
glspClient: GLSPClientProxy;
|
|
23
|
+
clientActionKinds: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates the DI module that binds client session specific configuration
|
|
28
|
+
*/
|
|
29
|
+
export function createClientSessionModule(options: ClientSessionModuleOptions): ContainerModule {
|
|
30
|
+
return new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
31
|
+
const context = { bind, unbind, isBound, rebind };
|
|
32
|
+
bindOrRebind(context, ClientId).toConstantValue(options.clientId);
|
|
33
|
+
bind(GLSPClientProxy).toConstantValue(options.glspClient);
|
|
34
|
+
bind(ClientActionKinds).toConstantValue(new Set(options.clientActionKinds));
|
|
28
35
|
});
|
|
29
36
|
}
|