@eclipse-glsp/vscode-integration-webview 0.9.0-next.2e7eec38

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.
@@ -0,0 +1,26 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2020-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 { Container } from 'inversify';
17
+ import { SprottyDiagramIdentifier, SprottyStarter } from 'sprotty-vscode-webview';
18
+ export declare abstract class GLSPStarter extends SprottyStarter {
19
+ protected addVscodeBindings(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void;
20
+ protected configureExtensionActionHandler(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void;
21
+ /**
22
+ * All kinds of actions that should (also) be delegated to and handled by the vscode extension
23
+ */
24
+ protected get extensionActionKinds(): string[];
25
+ }
26
+ //# sourceMappingURL=glsp-starter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-starter.d.ts","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAYtC,OAAO,EACH,wBAAwB,EACxB,cAAc,EAIjB,MAAM,wBAAwB,CAAC;AAMhC,8BAAsB,WAAY,SAAQ,cAAc;IACpD,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,GAAG,IAAI;IAcpG,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"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.GLSPStarter = void 0;
19
+ var client_1 = require("@eclipse-glsp/client");
20
+ var copy_paste_actions_1 = require("@eclipse-glsp/client/lib/features/copy-paste/copy-paste-actions");
21
+ var sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
22
+ var extension_action_handler_1 = require("./extension-action-handler");
23
+ var glsp_vscode_diagram_widget_1 = require("./glsp-vscode-diagram-widget");
24
+ var glsp_vscode_diagramserver_1 = require("./glsp-vscode-diagramserver");
25
+ var GLSPStarter = /** @class */ (function (_super) {
26
+ __extends(GLSPStarter, _super);
27
+ function GLSPStarter() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ GLSPStarter.prototype.addVscodeBindings = function (container, diagramIdentifier) {
31
+ container.bind(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
32
+ container.bind(sprotty_vscode_webview_1.VscodeDiagramWidget).toService(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget);
33
+ container.bind(sprotty_vscode_webview_1.VscodeDiagramWidgetFactory).toFactory(function (context) { return function () { return context.container.get(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget); }; });
34
+ container.bind(sprotty_vscode_webview_1.SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
35
+ container.bind(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer).toSelf().inSingletonScope();
36
+ container.bind(sprotty_vscode_webview_1.VscodeDiagramServer).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
37
+ container.bind(client_1.TYPES.ModelSource).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
38
+ container.bind(client_1.DiagramServer).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
39
+ this.configureExtensionActionHandler(container, diagramIdentifier);
40
+ };
41
+ GLSPStarter.prototype.configureExtensionActionHandler = function (container, diagramIdentifier) {
42
+ var extensionActionHandler = new extension_action_handler_1.GLSPVscodeExtensionActionHandler(this.extensionActionKinds, diagramIdentifier);
43
+ container.bind(extension_action_handler_1.GLSPVscodeExtensionActionHandler).toConstantValue(extensionActionHandler);
44
+ container.bind(client_1.TYPES.IActionHandlerInitializer).toService(extension_action_handler_1.GLSPVscodeExtensionActionHandler);
45
+ };
46
+ Object.defineProperty(GLSPStarter.prototype, "extensionActionKinds", {
47
+ /**
48
+ * All kinds of actions that should (also) be delegated to and handled by the vscode extension
49
+ */
50
+ get: function () {
51
+ return [
52
+ client_1.NavigateToExternalTargetAction.KIND,
53
+ copy_paste_actions_1.RequestClipboardDataAction.KIND,
54
+ copy_paste_actions_1.SetClipboardDataAction.KIND,
55
+ client_1.SelectAction.KIND,
56
+ client_1.ExportSvgAction.KIND
57
+ ];
58
+ },
59
+ enumerable: false,
60
+ configurable: true
61
+ });
62
+ return GLSPStarter;
63
+ }(sprotty_vscode_webview_1.SprottyStarter));
64
+ exports.GLSPStarter = GLSPSt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C,SAAoB,EAAE,iBAA2C;QACvG,IAAM,sBAAsB,GAAG,IAAI,2DAAgC,CAAC,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;QAClH,SAAS,CAAC,IAAI,CAAC,2DAAgC,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;QACzF,SAAS,CAAC,IAAI,CAAC,cAAK,CAAC,yBAAyB,CAAC,CAAC,SAAS,CAAC,2DAAgC,CAAC,CAAC;IAChG,CAAC;IAKD,sBAAc,6CAAoB;QAHlC;;WAEG;aACH;YACI,OAAO;gBACH,uCAA8B,CAAC,IAAI;gBACnC,+CAA0B,CAAC,IAAI;gBAC/B,2CAAsB,CAAC,IAAI;gBAC3B,qBAAY,CAAC,IAAI;gBACjB,wBAAe,CAAC,IAAI;aACvB,CAAC;QACN,CAAC;;;OAAA;IACL,kBAAC;AAAD,CAAC,AAjCD,CAA0C,uCAAc,GAiCvD;AAjCqB,kCAAW"}
@@ -0,0 +1,6 @@
1
+ import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
2
+ export declare abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
3
+ protected initializeSprotty(): void;
4
+ }
5
+ export declare function decodeURI(uri: string): string;
6
+ //# sourceMappingURL=glsp-vscode-diagram-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-vscode-diagram-widget.d.ts","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,8BACsB,uBAAwB,SAAQ,mBAAmB;IACrE,SAAS,CAAC,iBAAiB,IAAI,IAAI;CAatC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.decodeURI = exports.GLSPVscodeDiagramWidget = void 0;
25
+ /********************************************************************************
26
+ * Copyright (c) 2020-2021 EclipseSource and others.
27
+ *
28
+ * This program and the accompanying materials are made available under the
29
+ * terms of the Eclipse Public License v. 2.0 which is available at
30
+ * http://www.eclipse.org/legal/epl-2.0.
31
+ *
32
+ * This Source Code may also be made available under the following Secondary
33
+ * Licenses when the conditions for such availability set forth in the Eclipse
34
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
35
+ * with the GNU Classpath Exception which is available at
36
+ * https://www.gnu.org/software/classpath/license.html.
37
+ *
38
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
39
+ ********************************************************************************/
40
+ var client_1 = require("@eclipse-glsp/client");
41
+ var inversify_1 = require("inversify");
42
+ var sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
43
+ var GLSPVscodeDiagramWidget = /** @class */ (function (_super) {
44
+ __extends(GLSPVscodeDiagramWidget, _super);
45
+ function GLSPVscodeDiagramWidget() {
46
+ return _super !== null && _super.apply(this, arguments) || this;
47
+ }
48
+ GLSPVscodeDiagramWidget.prototype.initializeSprotty = function () {
49
+ if (this.modelSource instanceof client_1.DiagramServer) {
50
+ this.modelSource.clientId = this.diagramIdentifier.clientId;
51
+ }
52
+ this.actionDispatcher.dispatch(new client_1.InitializeClientSessionAction(this.diagramIdentifier.clientId));
53
+ this.actionDispatcher.dispatch(new client_1.RequestModelAction({
54
+ sourceUri: decodeURI(this.diagramIdentifier.uri),
55
+ diagramType: this.diagramIdentifier.diagramType
56
+ }));
57
+ this.actionDispatcher.dispatch(new client_1.RequestTypeHintsAction(this.diagramIdentifier.diagramType));
58
+ this.actionDispatcher.dispatch(new client_1.EnableToolPaletteAction());
59
+ };
60
+ GLSPVscodeDiagramWidget = __decorate([
61
+ inversify_1.injectable()
62
+ ], GLSPVscodeDiagramWidget);
63
+ return GLSPVscodeDiagramWidget;
64
+ }(sprotty_vscode_webview_1.VscodeDiagramWidget));
65
+ exports.GLSPVscodeDiagramWidget = GLSPVscodeDiagramWidget;
66
+ function decodeURI(uri) {
67
+ return decodeURIComponent(uri.replace(/\+/g, ' '));
68
+ }
69
+ exports.decodeURI = decodeURI;
70
+ //# sourceMappingURL=glsp-vscode-diagram-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-vscode-diagram-widget.js","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,+CAM8B;AAC9B,uCAAuC;AACvC,iEAA6D;AAG7D;IAAsD,2CAAmB;IAAzE;;IAcA,CAAC;IAba,mDAAiB,GAA3B;QACI,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,CAAC,IAAI,sCAA6B,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,2BAAkB,CAAC;YAClD,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAChD,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,WAAW;SAClD,CAAC,CAAC,CAAC;QAEJ,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;IAbiB,uBAAuB;QAD5C,sBAAU,EAAE;OACS,uBAAuB,CAc5C;IAAD,8BAAC;CAAA,AAdD,CAAsD,4CAAmB,GAcxE;AAdqB,0DAAuB;AAgB7C,SAAgB,SAAS,CAAC,GAAW;IACjC,OAAO,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,8BAEC"}
@@ -0,0 +1,32 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2020-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 { Action, ActionHandlerRegistry, ActionMessage, ComputedBoundsAction, DeleteElementOperation, SetEditModeAction, ICopyPasteHandler } from '@eclipse-glsp/client';
17
+ import { SelectionService } from '@eclipse-glsp/client/lib/features/select/selection-service';
18
+ import { VscodeDiagramServer } from 'sprotty-vscode-webview';
19
+ export declare const receivedFromServerProperty = "__receivedFromServer";
20
+ export declare const localDispatchProperty = "__localDispatch";
21
+ export declare class GLSPVscodeDiagramServer extends VscodeDiagramServer {
22
+ protected selectionService: SelectionService;
23
+ protected copyPasteHandler: ICopyPasteHandler;
24
+ initialize(registry: ActionHandlerRegistry): void;
25
+ handleLocally(action: Action): boolean;
26
+ protected messageReceived(data: any): void;
27
+ protected checkMessageOrigin(message: ActionMessage): void;
28
+ protected handleComputedBounds(action: ComputedBoundsAction): boolean;
29
+ protected handleDeleteElementOperation(operation: DeleteElementOperation): boolean;
30
+ protected handleSetEditModeAction(action: SetEditModeAction): boolean;
31
+ }
32
+ //# sourceMappingURL=glsp-vscode-diagramserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-vscode-diagramserver.d.ts","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EAKtB,iBAAiB,EACjB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAE9F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,qBAAa,uBAAwB,SAAQ,mBAAmB;IACvB,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,SAAS,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAEpF,UAAU,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAsBjD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUtC,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAe1C,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAO1D,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO;IAIrE,SAAS,CAAC,4BAA4B,CAAC,SAAS,EAAE,sBAAsB,GAAG,OAAO;IAOlF,SAAS,CAAC,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;CAIxE"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ var __read = (this && this.__read) || function (o, n) {
27
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
28
+ if (!m) return o;
29
+ var i = m.call(o), r, ar = [], e;
30
+ try {
31
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
32
+ }
33
+ catch (error) { e = { error: error }; }
34
+ finally {
35
+ try {
36
+ if (r && !r.done && (m = i["return"])) m.call(i);
37
+ }
38
+ finally { if (e) throw e.error; }
39
+ }
40
+ return ar;
41
+ };
42
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
43
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
44
+ to[j] = from[i];
45
+ return to;
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.GLSPVscodeDiagramServer = exports.localDispatchProperty = exports.receivedFromServerProperty = void 0;
49
+ /********************************************************************************
50
+ * Copyright (c) 2020-2021 EclipseSource and others.
51
+ *
52
+ * This program and the accompanying materials are made available under the
53
+ * terms of the Eclipse Public License v. 2.0 which is available at
54
+ * http://www.eclipse.org/legal/epl-2.0.
55
+ *
56
+ * This Source Code may also be made available under the following Secondary
57
+ * Licenses when the conditions for such availability set forth in the Eclipse
58
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
59
+ * with the GNU Classpath Exception which is available at
60
+ * https://www.gnu.org/software/classpath/license.html.
61
+ *
62
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
63
+ ********************************************************************************/
64
+ var client_1 = require("@eclipse-glsp/client");
65
+ var selection_service_1 = require("@eclipse-glsp/client/lib/features/select/selection-service");
66
+ var inversify_1 = require("inversify");
67
+ var sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
68
+ exports.receivedFromServerProperty = '__receivedFromServer';
69
+ exports.localDispatchProperty = '__localDispatch';
70
+ var GLSPVscodeDiagramServer = /** @class */ (function (_super) {
71
+ __extends(GLSPVscodeDiagramServer, _super);
72
+ function GLSPVscodeDiagramServer() {
73
+ return _super !== null && _super.apply(this, arguments) || this;
74
+ }
75
+ GLSPVscodeDiagramServer.prototype.initialize = function (registry) {
76
+ var _this = this;
77
+ client_1.registerDefaultGLSPServerActions(registry, this);
78
+ this.clientId = this.viewerOptions.baseDiv;
79
+ window.addEventListener('message', function (message) {
80
+ if ('data' in message && sprotty_vscode_webview_1.isActionMessage(message.data)) {
81
+ _this.messageReceived(message.data);
82
+ }
83
+ });
84
+ window.addEventListener('copy', function (e) {
85
+ _this.copyPasteHandler.handleCopy(e);
86
+ });
87
+ window.addEventListener('cut', function (e) {
88
+ _this.copyPasteHandler.handleCut(e);
89
+ });
90
+ window.addEventListener('paste', function (e) {
91
+ _this.copyPasteHandler.handlePaste(e);
92
+ });
93
+ };
94
+ GLSPVscodeDiagramServer.prototype.handleLocally = function (action) {
95
+ if (client_1.isSetEditModeAction(action)) {
96
+ return this.handleSetEditModeAction(action);
97
+ }
98
+ if (client_1.isDeleteElementOperation(action)) {
99
+ return this.handleDeleteElementOperation(action);
100
+ }
101
+ return _super.prototype.handleLocally.call(this, action);
102
+ };
103
+ GLSPVscodeDiagramServer.prototype.messageReceived = function (data) {
104
+ var _this = this;
105
+ var object = typeof (data) === 'string' ? JSON.parse(data) : data;
106
+ if (sprotty_vscode_webview_1.isActionMessage(object) && object.action) {
107
+ if (!object.clientId || object.clientId === this.clientId) {
108
+ this.checkMessageOrigin(object);
109
+ this.logger.log(this, 'receiving', object);
110
+ this.actionDispatcher.dispatch(object.action).then(function () {
111
+ _this.storeNewModel(object.action);
112
+ });
113
+ }
114
+ }
115
+ else {
116
+ this.logger.error(this, 'received data is not an action message', object);
117
+ }
118
+ };
119
+ GLSPVscodeDiagramServer.prototype.checkMessageOrigin = function (message) {
120
+ var isLocalDispatch = message[exports.localDispatchProperty] || false;
121
+ if (!isLocalDispatch) {
122
+ message.action[exports.receivedFromServerProperty] = true;
123
+ }
124
+ };
125
+ GLSPVscodeDiagramServer.prototype.handleComputedBounds = function (action) {
126
+ return true;
127
+ };
128
+ GLSPVscodeDiagramServer.prototype.handleDeleteElementOperation = function (operation) {
129
+ var _a;
130
+ if (operation.elementIds.length === 0) {
131
+ (_a = operation.elementIds).push.apply(_a, __spreadArray([], __read(this.selectionService.getSelectedElementIDs())));
132
+ }
133
+ return true;
134
+ };
135
+ GLSPVscodeDiagramServer.prototype.handleSetEditModeAction = function (action) {
136
+ return action[exports.receivedFromServerProperty] !== true;
137
+ };
138
+ __decorate([
139
+ inversify_1.inject(client_1.GLSP_TYPES.SelectionService),
140
+ __metadata("design:type", selection_service_1.SelectionService)
141
+ ], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
142
+ __decorate([
143
+ inversify_1.inject(client_1.GLSP_TYPES.ICopyPasteHandler),
144
+ __metadata("design:type", Object)
145
+ ], GLSPVscodeDiagramServer.prototype, "copyPasteHandler", void 0);
146
+ return GLSPVscodeDiagramServer;
147
+ }(sprotty_vscode_webview_1.VscodeDiagramServer));
148
+ exports.GLSPVscodeDiagramServer = GLSPVscodeDiagramServer;
149
+ //# sourceMappingURL=glsp-vscode-diagramserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,+CAY8B;AAC9B,gGAA8F;AAC9F,uCAAmC;AACnC,iEAA8E;AAEjE,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AACpD,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD;IAA6C,2CAAmB;IAAhE;;IAyEA,CAAC;IArEG,4CAAU,GAAV,UAAW,QAA+B;QA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,MAAyB;QACvD,OAAQ,MAAc,CAAC,kCAA0B,CAAC,KAAK,IAAI,CAAC;IAChE,CAAC;IAtEoC;QAApC,kBAAM,CAAC,mBAAU,CAAC,gBAAgB,CAAC;kCAA6B,oCAAgB;qEAAC;IAC5C;QAArC,kBAAM,CAAC,mBAAU,CAAC,iBAAiB,CAAC;;qEAA+C;IAuExF,8BAAC;CAAA,AAzED,CAA6C,4CAAmB,GAyE/D;AAzEY,0DAAuB"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2020 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
+ export * from './glsp-starter';
17
+ export * from './glsp-vscode-diagramserver';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2020 EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the Eclipse Public License v. 2.0 which is available at
7
+ * http://www.eclipse.org/legal/epl-2.0.
8
+ *
9
+ * This Source Code may also be made available under the following Secondary
10
+ * Licenses when the conditions for such availability set forth in the Eclipse
11
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ * with the GNU Classpath Exception which is available at
13
+ * https://www.gnu.org/software/classpath/license.html.
14
+ *
15
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ ********************************************************************************/
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ __exportStar(require("./glsp-starter"), exports);
29
+ __exportStar(require("./glsp-vscode-diagramserver"), exports);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAElF,iDAA+B;AAC/B,8DAA4C"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@eclipse-glsp/vscode-integration-webview",
3
+ "version": "0.9.0-next.2e7eec38",
4
+ "description": "Integration of a GLSP diagram in a VS Code extensions (WebView part)",
5
+ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
6
+ "keywords": [
7
+ "vscode",
8
+ "graph",
9
+ "diagram",
10
+ "layout",
11
+ "glsp"
12
+ ],
13
+ "homepage": "https://www.eclipse.org/glsp/",
14
+ "bugs": "https://github.com/eclipse-glsp/glsp/issues",
15
+ "author": {
16
+ "name": "Eclipse GLSP"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/eclipse-glsp/glsp-vscode-integration.git"
21
+ },
22
+ "contributors": [
23
+ {
24
+ "name": "Eclipse GLSP Project",
25
+ "email": "glsp-dev@eclipse.org",
26
+ "url": "https://projects.eclipse.org/projects/ecd.glsp"
27
+ }
28
+ ],
29
+ "files": [
30
+ "lib",
31
+ "src",
32
+ "css"
33
+ ],
34
+ "dependencies": {
35
+ "@eclipse-glsp/client": "next",
36
+ "reflect-metadata": "^0.1.12",
37
+ "sprotty-vscode-webview": "0.1.2"
38
+ },
39
+ "devDependencies": {
40
+ "rimraf": "latest",
41
+ "typescript": "latest"
42
+ },
43
+ "scripts": {
44
+ "prepare": "yarn clean && yarn build && yarn lint",
45
+ "clean": "rimraf lib",
46
+ "build": "tsc",
47
+ "watch": "tsc -w",
48
+ "lint": "eslint -c ./.eslintrc.js --ext .ts ./src"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "main": "lib/index",
54
+ "types": "lib/index"
55
+ }
@@ -0,0 +1,45 @@
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 { Action, ActionHandlerRegistry, IActionHandler, IActionHandlerInitializer, ICommand } from 'sprotty';
17
+ import { SprottyDiagramIdentifier } from 'sprotty-vscode-webview';
18
+ import { vscodeApi } from 'sprotty-vscode-webview/lib/vscode-api';
19
+
20
+ /**
21
+ * Delegates actions that should be handled inside of the glsp vscode extension instead
22
+ * of the webview. This enables the implementation of action handlers that require access
23
+ * to the vscode API and/or node backend.
24
+ */
25
+ export class GLSPVscodeExtensionActionHandler implements IActionHandler, IActionHandlerInitializer {
26
+
27
+ constructor(protected readonly actionKinds: string[],
28
+ protected readonly diagramIdentifier: SprottyDiagramIdentifier) {
29
+ }
30
+
31
+ initialize(registry: ActionHandlerRegistry): void {
32
+ this.actionKinds.forEach(kind => registry.register(kind, this));
33
+ }
34
+
35
+ handle(action: Action): void | Action | ICommand {
36
+ if (this.actionKinds.includes(action.kind)) {
37
+ const message = {
38
+ clientId: this.diagramIdentifier.clientId,
39
+ action,
40
+ __localDispatch: true
41
+ };
42
+ vscodeApi.postMessage(message);
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,73 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2020-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 { Container } from 'inversify';
17
+ import {
18
+ DiagramServer,
19
+ NavigateToExternalTargetAction,
20
+ ExportSvgAction,
21
+ SelectAction,
22
+ TYPES
23
+ } from '@eclipse-glsp/client';
24
+ import {
25
+ RequestClipboardDataAction,
26
+ SetClipboardDataAction
27
+ } from '@eclipse-glsp/client/lib/features/copy-paste/copy-paste-actions';
28
+ import {
29
+ SprottyDiagramIdentifier,
30
+ SprottyStarter,
31
+ VscodeDiagramServer,
32
+ VscodeDiagramWidget,
33
+ VscodeDiagramWidgetFactory
34
+ } from 'sprotty-vscode-webview';
35
+
36
+ import { GLSPVscodeExtensionActionHandler } from './extension-action-handler';
37
+ import { GLSPVscodeDiagramWidget } from './glsp-vscode-diagram-widget';
38
+ import { GLSPVscodeDiagramServer } from './glsp-vscode-diagramserver';
39
+
40
+ export abstract class GLSPStarter extends SprottyStarter {
41
+ protected addVscodeBindings(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void {
42
+ container.bind(GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
43
+ container.bind(VscodeDiagramWidget).toService(GLSPVscodeDiagramWidget);
44
+ container.bind(VscodeDiagramWidgetFactory).toFactory(
45
+ context => () => context.container.get<GLSPVscodeDiagramWidget>(GLSPVscodeDiagramWidget));
46
+ container.bind(SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
47
+ container.bind(GLSPVscodeDiagramServer).toSelf().inSingletonScope();
48
+ container.bind(VscodeDiagramServer).toService(GLSPVscodeDiagramServer);
49
+ container.bind(TYPES.ModelSource).toService(GLSPVscodeDiagramServer);
50
+ container.bind(DiagramServer).toService(GLSPVscodeDiagramServer);
51
+
52
+ this.configureExtensionActionHandler(container, diagramIdentifier);
53
+ }
54
+
55
+ protected configureExtensionActionHandler(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void {
56
+ const extensionActionHandler = new GLSPVscodeExtensionActionHandler(this.extensionActionKinds, diagramIdentifier);
57
+ container.bind(GLSPVscodeExtensionActionHandler).toConstantValue(extensionActionHandler);
58
+ container.bind(TYPES.IActionHandlerInitializer).toService(GLSPVscodeExtensionActionHandler);
59
+ }
60
+
61
+ /**
62
+ * All kinds of actions that should (also) be delegated to and handled by the vscode extension
63
+ */
64
+ protected get extensionActionKinds(): string[] {
65
+ return [
66
+ NavigateToExternalTargetAction.KIND,
67
+ RequestClipboardDataAction.KIND,
68
+ SetClipboardDataAction.KIND,
69
+ SelectAction.KIND,
70
+ ExportSvgAction.KIND
71
+ ];
72
+ }
73
+ }