@eclipse-glsp/vscode-integration-webview 0.9.0-next.6f6ae7f8 → 0.9.0-next.ecc539e1
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/LICENSE +642 -276
- package/lib/diagram-identifer.d.ts +25 -0
- package/lib/diagram-identifer.d.ts.map +1 -0
- package/lib/diagram-identifer.js +14 -0
- package/lib/diagram-identifer.js.map +1 -0
- package/lib/glsp-starter.d.ts +3 -1
- package/lib/glsp-starter.d.ts.map +1 -1
- package/lib/glsp-starter.js +31 -3
- package/lib/glsp-starter.js.map +1 -1
- package/lib/glsp-vscode-diagram-widget.d.ts.map +1 -1
- package/lib/glsp-vscode-diagram-widget.js +1 -2
- package/lib/glsp-vscode-diagram-widget.js.map +1 -1
- package/lib/glsp-vscode-diagramserver.js +7 -7
- package/lib/glsp-vscode-diagramserver.js.map +1 -1
- package/package.json +3 -3
- package/src/diagram-identifer.ts +36 -0
- package/src/glsp-starter.ts +40 -3
- package/src/glsp-vscode-diagram-widget.ts +1 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { InitializeResult } from '@eclipse-glsp/client';
|
|
17
|
+
export declare const GLSPDiagramIdentifier: unique symbol;
|
|
18
|
+
export interface GLSPDiagramIdentifier {
|
|
19
|
+
clientId: string;
|
|
20
|
+
diagramType: string;
|
|
21
|
+
uri: string;
|
|
22
|
+
initializeResult?: InitializeResult;
|
|
23
|
+
}
|
|
24
|
+
export declare function isDiagramIdentifier(object: any): object is GLSPDiagramIdentifier;
|
|
25
|
+
//# sourceMappingURL=diagram-identifer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram-identifer.d.ts","sourceRoot":"","sources":["../src/diagram-identifer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,qBAAqB,CAQhF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDiagramIdentifier = exports.GLSPDiagramIdentifier = void 0;
|
|
4
|
+
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
5
|
+
exports.GLSPDiagramIdentifier = Symbol('GLSPDiagramIdentifier');
|
|
6
|
+
function isDiagramIdentifier(object) {
|
|
7
|
+
return (object !== undefined &&
|
|
8
|
+
typeof object === 'object' &&
|
|
9
|
+
(0, protocol_1.isString)(object, 'clientId') &&
|
|
10
|
+
(0, protocol_1.isString)(object, 'diagramType') &&
|
|
11
|
+
(0, protocol_1.isString)(object, 'uri'));
|
|
12
|
+
}
|
|
13
|
+
exports.isDiagramIdentifier = isDiagramIdentifier;
|
|
14
|
+
//# sourceMappingURL=diagram-identifer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram-identifer.js","sourceRoot":"","sources":["../src/diagram-identifer.ts"],"names":[],"mappings":";;;AAgBA,qDAAkD;AAErC,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AASrE,SAAgB,mBAAmB,CAAC,MAAW;IAC3C,OAAO,CACH,MAAM,KAAK,SAAS;QACpB,OAAO,MAAM,KAAK,QAAQ;QAC1B,IAAA,mBAAQ,EAAC,MAAM,EAAE,UAAU,CAAC;QAC5B,IAAA,mBAAQ,EAAC,MAAM,EAAE,aAAa,CAAC;QAC/B,IAAA,mBAAQ,EAAC,MAAM,EAAE,KAAK,CAAC,CAC1B,CAAC;AACN,CAAC;AARD,kDAQC"}
|
package/lib/glsp-starter.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Container } from 'inversify';
|
|
2
2
|
import { SprottyDiagramIdentifier, SprottyStarter } from 'sprotty-vscode-webview';
|
|
3
|
+
import { GLSPDiagramIdentifier } from './diagram-identifer';
|
|
3
4
|
export declare abstract class GLSPStarter extends SprottyStarter {
|
|
4
|
-
protected
|
|
5
|
+
protected acceptDiagramIdentifier(): void;
|
|
6
|
+
protected addVscodeBindings(container: Container, diagramIdentifier: GLSPDiagramIdentifier): void;
|
|
5
7
|
protected configureExtensionActionHandler(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void;
|
|
6
8
|
/**
|
|
7
9
|
* All kinds of actions that should (also) be delegated to and handled by the vscode extension
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-starter.d.ts","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glsp-starter.d.ts","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACH,wBAAwB,EACxB,cAAc,EAIjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAuB,MAAM,qBAAqB,CAAC;AAKjF,8BAAsB,WAAY,SAAQ,cAAc;IACpD,SAAS,CAAC,uBAAuB,IAAI,IAAI;IA2BzC,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,qBAAqB,GAAG,IAAI;IAgBjG,SAAS,CAAC,+BAA+B,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,GAAG,IAAI;IAMlH;;OAEG;IACH,SAAS,KAAK,oBAAoB,IAAI,MAAM,EAAE,CAQ7C;CACJ"}
|
package/lib/glsp-starter.js
CHANGED
|
@@ -17,18 +17,46 @@ exports.GLSPStarter = void 0;
|
|
|
17
17
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
18
18
|
********************************************************************************/
|
|
19
19
|
const client_1 = require("@eclipse-glsp/client");
|
|
20
|
-
const copy_paste_actions_1 = require("@eclipse-glsp/client/lib/features/copy-paste/copy-paste-actions");
|
|
21
20
|
const sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
|
|
21
|
+
const diagram_identifer_1 = require("./diagram-identifer");
|
|
22
22
|
const extension_action_handler_1 = require("./extension-action-handler");
|
|
23
23
|
const glsp_vscode_diagram_widget_1 = require("./glsp-vscode-diagram-widget");
|
|
24
24
|
const glsp_vscode_diagramserver_1 = require("./glsp-vscode-diagramserver");
|
|
25
25
|
class GLSPStarter extends sprotty_vscode_webview_1.SprottyStarter {
|
|
26
|
+
acceptDiagramIdentifier() {
|
|
27
|
+
console.log('Waiting for diagram identifier...');
|
|
28
|
+
const eventListener = (message) => {
|
|
29
|
+
if ((0, diagram_identifer_1.isDiagramIdentifier)(message.data)) {
|
|
30
|
+
console.log(message);
|
|
31
|
+
if (this.container) {
|
|
32
|
+
const oldIdentifier = this.container.get(diagram_identifer_1.GLSPDiagramIdentifier);
|
|
33
|
+
const newIdentifier = message.data;
|
|
34
|
+
oldIdentifier.diagramType = newIdentifier.diagramType;
|
|
35
|
+
oldIdentifier.uri = newIdentifier.uri;
|
|
36
|
+
const diagramWidget = this.container.get(sprotty_vscode_webview_1.VscodeDiagramWidget);
|
|
37
|
+
diagramWidget.requestModel();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.log('...received...', message);
|
|
41
|
+
const diagramIdentifier = message.data;
|
|
42
|
+
this.container = this.createContainer(diagramIdentifier);
|
|
43
|
+
this.addVscodeBindings(this.container, diagramIdentifier);
|
|
44
|
+
if (diagramIdentifier.initializeResult) {
|
|
45
|
+
(0, client_1.configureServerActions)(diagramIdentifier.initializeResult, diagramIdentifier.diagramType, this.container);
|
|
46
|
+
}
|
|
47
|
+
this.container.get(sprotty_vscode_webview_1.VscodeDiagramWidget);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
window.addEventListener('message', eventListener);
|
|
52
|
+
}
|
|
26
53
|
addVscodeBindings(container, diagramIdentifier) {
|
|
27
54
|
container.bind(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
|
|
28
55
|
container.bind(sprotty_vscode_webview_1.VscodeDiagramWidget).toService(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget);
|
|
29
56
|
container
|
|
30
57
|
.bind(sprotty_vscode_webview_1.VscodeDiagramWidgetFactory)
|
|
31
58
|
.toFactory(context => () => context.container.get(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget));
|
|
59
|
+
container.bind(diagram_identifer_1.GLSPDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
32
60
|
container.bind(sprotty_vscode_webview_1.SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
33
61
|
container.bind(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer).toSelf().inSingletonScope();
|
|
34
62
|
container.bind(sprotty_vscode_webview_1.VscodeDiagramServer).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
|
|
@@ -47,8 +75,8 @@ class GLSPStarter extends sprotty_vscode_webview_1.SprottyStarter {
|
|
|
47
75
|
get extensionActionKinds() {
|
|
48
76
|
return [
|
|
49
77
|
client_1.NavigateToExternalTargetAction.KIND,
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
client_1.RequestClipboardDataAction.KIND,
|
|
79
|
+
client_1.SetClipboardDataAction.KIND,
|
|
52
80
|
client_1.SelectAction.KIND,
|
|
53
81
|
client_1.ExportSvgAction.KIND
|
|
54
82
|
];
|
package/lib/glsp-starter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-starter.js","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"glsp-starter.js","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAS8B;AAE9B,mEAMgC;AAChC,2DAAiF;AACjF,yEAA8E;AAC9E,6EAAuE;AACvE,2EAAsE;AAEtE,MAAsB,WAAY,SAAQ,uCAAc;IAC1C,uBAAuB;QAC7B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,MAAM,aAAa,GAAG,CAAC,OAAY,EAAQ,EAAE;YACzC,IAAI,IAAA,uCAAmB,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrB,IAAI,IAAI,CAAC,SAAS,EAAE;oBAChB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAwB,yCAAqB,CAAC,CAAC;oBACvF,MAAM,aAAa,GAAG,OAAO,CAAC,IAA6B,CAAC;oBAC5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ram-widget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagram-widget.d.ts","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,8BACsB,uBAAwB,SAAQ,mBAAmB;IACrE,SAAS,CAAC,iBAAiB,IAAI,IAAI;CActC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
|
@@ -30,7 +30,6 @@ let GLSPVscodeDiagramWidget = class GLSPVscodeDiagramWidget extends sprotty_vsco
|
|
|
30
30
|
if (this.modelSource instanceof client_1.DiagramServer) {
|
|
31
31
|
this.modelSource.clientId = this.diagramIdentifier.clientId;
|
|
32
32
|
}
|
|
33
|
-
this.actionDispatcher.dispatch(new client_1.InitializeClientSessionAction(this.diagramIdentifier.clientId));
|
|
34
33
|
this.actionDispatcher.dispatch(new client_1.RequestModelAction({
|
|
35
34
|
sourceUri: decodeURI(this.diagramIdentifier.uri),
|
|
36
35
|
diagramType: this.diagramIdentifier.diagramType
|
|
@@ -40,7 +39,7 @@ let GLSPVscodeDiagramWidget = class GLSPVscodeDiagramWidget extends sprotty_vsco
|
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
GLSPVscodeDiagramWidget = __decorate([
|
|
43
|
-
inversify_1.injectable()
|
|
42
|
+
(0, inversify_1.injectable)()
|
|
44
43
|
], GLSPVscodeDiagramWidget);
|
|
45
44
|
exports.GLSPVscodeDiagramWidget = GLSPVscodeDiagramWidget;
|
|
46
45
|
function decodeURI(uri) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-vscode-diagram-widget.js","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagram-widget.js","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAA0H;AAC1H,yCAAuC;AACvC,mEAA6D;AAG7D,IAAsB,uBAAuB,GAA7C,MAAsB,uBAAwB,SAAQ,4CAAmB;IAC3D,iBAAiB;QACvB,IAAI,IAAI,CAAC,WAAW,YAAY,sBAAa,EAAE;YAC3C,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;SAC/D;QACD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC1B,IAAI,2BAAkB,CAAC;YACnB,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAChD,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,WAAW;SAClD,CAAC,CACL,CAAC;QAEF,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,+BAAsB,CAAC,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;QAC/F,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,gCAAuB,EAAE,CAAC,CAAC;IAClE,CAAC;CACJ,CAAA;AAfqB,uBAAuB;IAD5C,IAAA,sBAAU,GAAE;GACS,uBAAuB,CAe5C;AAfqB,0DAAuB;AAiB7C,SAAgB,SAAS,CAAC,GAAW;IACjC,OAAO,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,8BAEC"}
|
|
@@ -33,10 +33,10 @@ exports.receivedFromServerProperty = '__receivedFromServer';
|
|
|
33
33
|
exports.localDispatchProperty = '__localDispatch';
|
|
34
34
|
class GLSPVscodeDiagramServer extends sprotty_vscode_webview_1.VscodeDiagramServer {
|
|
35
35
|
initialize(registry) {
|
|
36
|
-
client_1.registerDefaultGLSPServerActions(registry, this);
|
|
36
|
+
(0, client_1.registerDefaultGLSPServerActions)(registry, this);
|
|
37
37
|
this.clientId = this.viewerOptions.baseDiv;
|
|
38
38
|
window.addEventListener('message', message => {
|
|
39
|
-
if ('data' in message && sprotty_vscode_webview_1.isActionMessage(message.data)) {
|
|
39
|
+
if ('data' in message && (0, sprotty_vscode_webview_1.isActionMessage)(message.data)) {
|
|
40
40
|
this.messageReceived(message.data);
|
|
41
41
|
}
|
|
42
42
|
});
|
|
@@ -51,17 +51,17 @@ class GLSPVscodeDiagramServer extends sprotty_vscode_webview_1.VscodeDiagramServ
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
handleLocally(action) {
|
|
54
|
-
if (client_1.isSetEditModeAction(action)) {
|
|
54
|
+
if ((0, client_1.isSetEditModeAction)(action)) {
|
|
55
55
|
return this.handleSetEditModeAction(action);
|
|
56
56
|
}
|
|
57
|
-
if (client_1.isDeleteElementOperation(action)) {
|
|
57
|
+
if ((0, client_1.isDeleteElementOperation)(action)) {
|
|
58
58
|
return this.handleDeleteElementOperation(action);
|
|
59
59
|
}
|
|
60
60
|
return super.handleLocally(action);
|
|
61
61
|
}
|
|
62
62
|
messageReceived(data) {
|
|
63
63
|
const object = typeof data === 'string' ? JSON.parse(data) : data;
|
|
64
|
-
if (sprotty_vscode_webview_1.isActionMessage(object) && object.action) {
|
|
64
|
+
if ((0, sprotty_vscode_webview_1.isActionMessage)(object) && object.action) {
|
|
65
65
|
if (!object.clientId || object.clientId === this.clientId) {
|
|
66
66
|
this.checkMessageOrigin(object);
|
|
67
67
|
this.logger.log(this, 'receiving', object);
|
|
@@ -94,11 +94,11 @@ class GLSPVscodeDiagramServer extends sprotty_vscode_webview_1.VscodeDiagramServ
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
__decorate([
|
|
97
|
-
inversify_1.inject(client_1.GLSP_TYPES.SelectionService),
|
|
97
|
+
(0, inversify_1.inject)(client_1.GLSP_TYPES.SelectionService),
|
|
98
98
|
__metadata("design:type", selection_service_1.SelectionService)
|
|
99
99
|
], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
|
|
100
100
|
__decorate([
|
|
101
|
-
inversify_1.inject(client_1.GLSP_TYPES.ICopyPasteHandler),
|
|
101
|
+
(0, inversify_1.inject)(client_1.GLSP_TYPES.ICopyPasteHandler),
|
|
102
102
|
__metadata("design:type", Object)
|
|
103
103
|
], GLSPVscodeDiagramServer.prototype, "copyPasteHandler", void 0);
|
|
104
104
|
exports.GLSPVscodeDiagramServer = GLSPVscodeDiagramServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAY8B;AAC9B,kGAA8F;AAC9F,yCAAmC;AACnC,mEAA8E;AAEjE,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AACpD,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,MAAa,uBAAwB,SAAQ,4CAAmB;IAI5D,UAAU,CAAC,QAA+B;QACtC,yCAAgC,
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAY8B;AAC9B,kGAA8F;AAC9F,yCAAmC;AACnC,mEAA8E;AAEjE,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AACpD,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,MAAa,uBAAwB,SAAQ,4CAAmB;IAI5D,UAAU,CAAC,QAA+B;QACtC,IAAA,yCAAgC,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAC3C,MAAM,CAAC,gBAAgB,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C;AAC5C;IAArC,IAAA,kBAAM,EAAC,mBAAU,CAAC,iBAAiB,CAAC;;iEAA+C;AAFxF,0DAwEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/vscode-integration-webview",
|
|
3
|
-
"version": "0.9.0-next.
|
|
3
|
+
"version": "0.9.0-next.ecc539e1",
|
|
4
4
|
"description": "Integration of a GLSP diagram in a VS Code extensions (WebView part)",
|
|
5
5
|
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
|
|
6
6
|
"keywords": [
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@eclipse-glsp/client": "next",
|
|
36
|
-
"reflect-metadata": "^0.1.12",
|
|
37
36
|
"sprotty-vscode-webview": "0.1.2"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
39
|
+
"reflect-metadata": "^0.1.13",
|
|
40
40
|
"rimraf": "latest",
|
|
41
|
-
"typescript": "
|
|
41
|
+
"typescript": "^4.4.3"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prepare": "yarn clean && yarn build && yarn lint",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { InitializeResult } from '@eclipse-glsp/client';
|
|
17
|
+
import { isString } from '@eclipse-glsp/protocol';
|
|
18
|
+
|
|
19
|
+
export const GLSPDiagramIdentifier = Symbol('GLSPDiagramIdentifier');
|
|
20
|
+
|
|
21
|
+
export interface GLSPDiagramIdentifier {
|
|
22
|
+
clientId: string;
|
|
23
|
+
diagramType: string;
|
|
24
|
+
uri: string;
|
|
25
|
+
initializeResult?: InitializeResult;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isDiagramIdentifier(object: any): object is GLSPDiagramIdentifier {
|
|
29
|
+
return (
|
|
30
|
+
object !== undefined &&
|
|
31
|
+
typeof object === 'object' &&
|
|
32
|
+
isString(object, 'clientId') &&
|
|
33
|
+
isString(object, 'diagramType') &&
|
|
34
|
+
isString(object, 'uri')
|
|
35
|
+
);
|
|
36
|
+
}
|
package/src/glsp-starter.ts
CHANGED
|
@@ -13,8 +13,16 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import {
|
|
17
|
+
configureServerActions,
|
|
18
|
+
DiagramServer,
|
|
19
|
+
ExportSvgAction,
|
|
20
|
+
NavigateToExternalTargetAction,
|
|
21
|
+
RequestClipboardDataAction,
|
|
22
|
+
SelectAction,
|
|
23
|
+
SetClipboardDataAction,
|
|
24
|
+
TYPES
|
|
25
|
+
} from '@eclipse-glsp/client';
|
|
18
26
|
import { Container } from 'inversify';
|
|
19
27
|
import {
|
|
20
28
|
SprottyDiagramIdentifier,
|
|
@@ -23,17 +31,46 @@ import {
|
|
|
23
31
|
VscodeDiagramWidget,
|
|
24
32
|
VscodeDiagramWidgetFactory
|
|
25
33
|
} from 'sprotty-vscode-webview';
|
|
34
|
+
import { GLSPDiagramIdentifier, isDiagramIdentifier } from './diagram-identifer';
|
|
26
35
|
import { GLSPVscodeExtensionActionHandler } from './extension-action-handler';
|
|
27
36
|
import { GLSPVscodeDiagramWidget } from './glsp-vscode-diagram-widget';
|
|
28
37
|
import { GLSPVscodeDiagramServer } from './glsp-vscode-diagramserver';
|
|
29
38
|
|
|
30
39
|
export abstract class GLSPStarter extends SprottyStarter {
|
|
31
|
-
protected
|
|
40
|
+
protected acceptDiagramIdentifier(): void {
|
|
41
|
+
console.log('Waiting for diagram identifier...');
|
|
42
|
+
const eventListener = (message: any): void => {
|
|
43
|
+
if (isDiagramIdentifier(message.data)) {
|
|
44
|
+
console.log(message);
|
|
45
|
+
if (this.container) {
|
|
46
|
+
const oldIdentifier = this.container.get<GLSPDiagramIdentifier>(GLSPDiagramIdentifier);
|
|
47
|
+
const newIdentifier = message.data as GLSPDiagramIdentifier;
|
|
48
|
+
oldIdentifier.diagramType = newIdentifier.diagramType;
|
|
49
|
+
oldIdentifier.uri = newIdentifier.uri;
|
|
50
|
+
const diagramWidget = this.container.get(VscodeDiagramWidget);
|
|
51
|
+
diagramWidget.requestModel();
|
|
52
|
+
} else {
|
|
53
|
+
console.log('...received...', message);
|
|
54
|
+
const diagramIdentifier = message.data as GLSPDiagramIdentifier;
|
|
55
|
+
this.container = this.createContainer(diagramIdentifier);
|
|
56
|
+
this.addVscodeBindings(this.container, diagramIdentifier);
|
|
57
|
+
if (diagramIdentifier.initializeResult) {
|
|
58
|
+
configureServerActions(diagramIdentifier.initializeResult, diagramIdentifier.diagramType, this.container);
|
|
59
|
+
}
|
|
60
|
+
this.container.get(VscodeDiagramWidget);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
window.addEventListener('message', eventListener);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected addVscodeBindings(container: Container, diagramIdentifier: GLSPDiagramIdentifier): void {
|
|
32
68
|
container.bind(GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
|
|
33
69
|
container.bind(VscodeDiagramWidget).toService(GLSPVscodeDiagramWidget);
|
|
34
70
|
container
|
|
35
71
|
.bind(VscodeDiagramWidgetFactory)
|
|
36
72
|
.toFactory(context => () => context.container.get<GLSPVscodeDiagramWidget>(GLSPVscodeDiagramWidget));
|
|
73
|
+
container.bind(GLSPDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
37
74
|
container.bind(SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
38
75
|
container.bind(GLSPVscodeDiagramServer).toSelf().inSingletonScope();
|
|
39
76
|
container.bind(VscodeDiagramServer).toService(GLSPVscodeDiagramServer);
|
|
@@ -13,13 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
DiagramServer,
|
|
18
|
-
EnableToolPaletteAction,
|
|
19
|
-
InitializeClientSessionAction,
|
|
20
|
-
RequestModelAction,
|
|
21
|
-
RequestTypeHintsAction
|
|
22
|
-
} from '@eclipse-glsp/client';
|
|
16
|
+
import { DiagramServer, EnableToolPaletteAction, RequestModelAction, RequestTypeHintsAction } from '@eclipse-glsp/client';
|
|
23
17
|
import { injectable } from 'inversify';
|
|
24
18
|
import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
|
|
25
19
|
|
|
@@ -29,7 +23,6 @@ export abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
|
|
|
29
23
|
if (this.modelSource instanceof DiagramServer) {
|
|
30
24
|
this.modelSource.clientId = this.diagramIdentifier.clientId;
|
|
31
25
|
}
|
|
32
|
-
this.actionDispatcher.dispatch(new InitializeClientSessionAction(this.diagramIdentifier.clientId));
|
|
33
26
|
this.actionDispatcher.dispatch(
|
|
34
27
|
new RequestModelAction({
|
|
35
28
|
sourceUri: decodeURI(this.diagramIdentifier.uri),
|