@eclipse-glsp/vscode-integration-webview 1.1.0-next.e56e93f.46 → 1.1.0-next.e5a109d.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.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/lib/{copy-paste-handler-provider.d.ts → default-modules.d.ts} +5 -9
  3. package/lib/default-modules.d.ts.map +1 -0
  4. package/lib/default-modules.js +27 -0
  5. package/lib/default-modules.js.map +1 -0
  6. package/lib/diagram-identifier.d.ts +14 -0
  7. package/lib/diagram-identifier.d.ts.map +1 -0
  8. package/lib/{diagram-identifer.js → diagram-identifier.js} +11 -5
  9. package/lib/diagram-identifier.js.map +1 -0
  10. package/lib/{copy-paste-handler-provider.js → features/copyPaste/copy-paste-module.d.ts} +4 -6
  11. package/lib/features/copyPaste/copy-paste-module.d.ts.map +1 -0
  12. package/lib/features/copyPaste/copy-paste-module.js +28 -0
  13. package/lib/features/copyPaste/copy-paste-module.js.map +1 -0
  14. package/{src/copy-paste-handler-provider.ts → lib/features/copyPaste/copy-paste-startup.d.ts} +11 -5
  15. package/lib/features/copyPaste/copy-paste-startup.d.ts.map +1 -0
  16. package/lib/{glsp-vscode-diagram-widget.js → features/copyPaste/copy-paste-startup.js} +37 -32
  17. package/lib/features/copyPaste/copy-paste-startup.js.map +1 -0
  18. package/lib/{diagram-identifer.d.ts → features/default/default-module.d.ts} +4 -11
  19. package/lib/features/default/default-module.d.ts.map +1 -0
  20. package/lib/features/default/default-module.js +30 -0
  21. package/lib/features/default/default-module.js.map +1 -0
  22. package/lib/{extension-action-handler.d.ts → features/default/extension-action-handler.d.ts} +17 -10
  23. package/lib/features/default/extension-action-handler.d.ts.map +1 -0
  24. package/lib/features/default/extension-action-handler.js +85 -0
  25. package/lib/features/default/extension-action-handler.js.map +1 -0
  26. package/lib/features/default/vscode-glsp-modelsource.d.ts +40 -0
  27. package/lib/features/default/vscode-glsp-modelsource.d.ts.map +1 -0
  28. package/lib/features/default/vscode-glsp-modelsource.js +68 -0
  29. package/lib/features/default/vscode-glsp-modelsource.js.map +1 -0
  30. package/lib/features/export/export-module.d.ts +18 -0
  31. package/lib/features/export/export-module.d.ts.map +1 -0
  32. package/lib/features/export/export-module.js +24 -0
  33. package/lib/features/export/export-module.js.map +1 -0
  34. package/lib/features/navigation/navigation-module.d.ts +18 -0
  35. package/lib/features/navigation/navigation-module.d.ts.map +1 -0
  36. package/lib/features/navigation/navigation-module.js +24 -0
  37. package/lib/features/navigation/navigation-module.js.map +1 -0
  38. package/lib/glsp-diagram-widget.d.ts +32 -0
  39. package/lib/glsp-diagram-widget.d.ts.map +1 -0
  40. package/lib/glsp-diagram-widget.js +89 -0
  41. package/lib/glsp-diagram-widget.js.map +1 -0
  42. package/lib/glsp-starter.d.ts +43 -9
  43. package/lib/glsp-starter.d.ts.map +1 -1
  44. package/lib/glsp-starter.js +53 -66
  45. package/lib/glsp-starter.js.map +1 -1
  46. package/lib/index.d.ts +11 -2
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +25 -16
  49. package/lib/index.js.map +1 -1
  50. package/lib/webview-glsp-client.d.ts +56 -0
  51. package/lib/webview-glsp-client.d.ts.map +1 -0
  52. package/lib/webview-glsp-client.js +103 -0
  53. package/lib/webview-glsp-client.js.map +1 -0
  54. package/package.json +17 -16
  55. package/src/default-modules.ts +27 -0
  56. package/src/{diagram-identifer.ts → diagram-identifier.ts} +16 -5
  57. package/src/features/copyPaste/copy-paste-module.ts +39 -0
  58. package/src/features/copyPaste/copy-paste-startup.ts +50 -0
  59. package/src/features/default/default-module.ts +31 -0
  60. package/src/{extension-action-handler.ts → features/default/extension-action-handler.ts} +40 -13
  61. package/src/features/default/vscode-glsp-modelsource.ts +63 -0
  62. package/src/features/export/export-module.ts +22 -0
  63. package/src/features/navigation/navigation-module.ts +22 -0
  64. package/src/glsp-diagram-widget.ts +79 -0
  65. package/src/glsp-starter.ts +69 -85
  66. package/src/index.ts +12 -2
  67. package/src/webview-glsp-client.ts +132 -0
  68. package/lib/copy-paste-handler-provider.d.ts.map +0 -1
  69. package/lib/copy-paste-handler-provider.js.map +0 -1
  70. package/lib/diagram-identifer.d.ts.map +0 -1
  71. package/lib/diagram-identifer.js.map +0 -1
  72. package/lib/extension-action-handler.d.ts.map +0 -1
  73. package/lib/extension-action-handler.js +0 -30
  74. package/lib/extension-action-handler.js.map +0 -1
  75. package/lib/glsp-vscode-diagram-widget.d.ts +0 -6
  76. package/lib/glsp-vscode-diagram-widget.d.ts.map +0 -1
  77. package/lib/glsp-vscode-diagram-widget.js.map +0 -1
  78. package/lib/glsp-vscode-diagramserver.d.ts +0 -33
  79. package/lib/glsp-vscode-diagramserver.d.ts.map +0 -1
  80. package/lib/glsp-vscode-diagramserver.js +0 -108
  81. package/lib/glsp-vscode-diagramserver.js.map +0 -1
  82. package/src/glsp-vscode-diagram-widget.ts +0 -42
  83. package/src/glsp-vscode-diagramserver.ts +0 -111
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-glsp-client.d.ts","sourceRoot":"","sources":["../src/webview-glsp-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EACH,MAAM,EACN,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,OAAO,EACP,KAAK,EACL,UAAU,EACV,iCAAiC,EACjC,oBAAoB,EACpB,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,MAAM,WAAW,wBAAyB,SAAQ,UAAU,CAAC,OAAO;IAChE,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,eAAO,MAAM,yBAAyB,EAAE,gBAAgB,CAAC,aAAa,CAA+B,CAAC;AACtG,eAAO,MAAM,YAAY,EAAE,W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,IAAI;IAIhB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,iBAAiB,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI;IAIvD,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,UAAU;IAI1D,OAAO,IAAI,IAAI;CAGlB"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2023 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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.WebviewGlspClient = exports.StopRequest = exports.ShutdownServerNotification = exports.DisposeClientSessionRequest = exports.InitializeClientSessionRequest = exports.InitializeServerRequest = exports.StartRequest = exports.ActionMessageNotification = void 0;
19
+ const client_1 = require("@eclipse-glsp/client");
20
+ const vscode_messenger_common_1 = require("vscode-messenger-common");
21
+ const vscode_messenger_webview_1 = require("vscode-messenger-webview");
22
+ exports.ActionMessageNotification = { method: 'actionMessage' };
23
+ exports.StartRequest = { method: 'start' };
24
+ exports.InitializeServerRequest = { method: 'initializeServer' };
25
+ exports.InitializeClientSessionRequest = { method: 'initializeClientSession' };
26
+ exports.DisposeClientSessionRequest = { method: 'disposeClientSession' };
27
+ exports.ShutdownServerNotification = { method: 'shutdownServer' };
28
+ exports.StopRequest = { method: 'stop' };
29
+ /**
30
+ * GLSP client implementation for the diagram webview. This is proxy implementation
31
+ * that communicates with the actual GLSP client running in the host extension.
32
+ * via the vscode-messenger protocol
33
+ */
34
+ class WebviewGlspClient {
35
+ get currentState() {
36
+ return this._currentState;
37
+ }
38
+ get initializeResult() {
39
+ return this._initializeResult;
40
+ }
41
+ get onServerInitialized() {
42
+ return this.onServerInitializedEmitter.event;
43
+ }
44
+ constructor(options) {
45
+ var _a;
46
+ this.toDispose = new client_1.DisposableCollection();
47
+ this.onActionMessageEmitter = new client_1.Emitter();
48
+ this._currentState = client_1.ClientState.Starting;
49
+ this.onServerInitializedEmitter = new client_1.Emitter();
50
+ this.id = options.id;
51
+ this.messenger = (_a = options.messenger) !== null && _a !== void 0 ? _a : new vscode_messenger_webview_1.Messenger();
52
+ this.toDispose.push(this.onActionMessageEmitter, this.onServerInitializedEmitter);
53
+ this.messenger.onNotification(exports.ActionMessageNotification, msg => this.onActionMessageEmitter.fire(msg));
54
+ }
55
+ async start() {
56
+ try {
57
+ this._currentState = client_1.ClientState.Starting;
58
+ await this.messenger.sendRequest(exports.StartRequest, vscode_messenger_common_1.HOST_EXTENSION);
59
+ this._currentState = client_1.ClientState.Running;
60
+ }
61
+ catch (error) {
62
+ console.error('Failed to start connection to server', error);
63
+ this._currentState = client_1.ClientState.StartFailed;
64
+ }
65
+ }
66
+ async initializeServer(params) {
67
+ if (this.initializeResult) {
68
+ return this.initializeResult;
69
+ }
70
+ const result = await this.messenger.sendRequest(exports.InitializeServerRequest, vscode_messenger_common_1.HOST_EXTENSION, params);
71
+ this._initializeResult = result;
72
+ this.onServerInitializedEmitter.fire(result);
73
+ return result;
74
+ }
75
+ initializeClientSession(params) {
76
+ return this.messenger.sendRequest(exports.InitializeClientSessionRequest, vscode_messenger_common_1.HOST_EXTENSION, params);
77
+ }
78
+ disposeClientSession(params) {
79
+ return this.messenger.sendRequest(exports.DisposeClientSessionRequest, vscode_messenger_common_1.HOST_EXTENSION, params);
80
+ }
81
+ shutdownServer() {
82
+ this.messenger.sendNotification(exports.ShutdownServerNotification, vscode_messenger_common_1.HOST_EXTENSION);
83
+ }
84
+ async stop() {
85
+ if (this._currentState === client_1.ClientState.Stopped) {
86
+ return;
87
+ }
88
+ this._currentState = client_1.ClientState.Stopping;
89
+ await this.messenger.sendRequest(exports.StopRequest, vscode_messenger_common_1.HOST_EXTENSION);
90
+ this._currentState = client_1.ClientState.Stopped;
91
+ }
92
+ sendActionMessage(message) {
93
+ this.messenger.sendNotification(exports.ActionMessageNotification, vscode_messenger_common_1.HOST_EXTENSION, message);
94
+ }
95
+ onActionMessage(handler) {
96
+ return this.onActionMessageEmitter.event(handler);
97
+ }
98
+ dispose() {
99
+ this.toDispose.dispose();
100
+ }
101
+ }
102
+ exports.WebviewGlspClient = WebviewGlspClient;
103
+ //# sourceMappingURL=webview-glsp-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-glsp-client.js","sourceRoot":"","sources":["../src/webview-glsp-client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,iDAc8B;AAC9B,qEAAwF;AACxF,uEAAqD;AAMxC,QAAA,yBAAyB,GAAoC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACzF,QAAA,YAAY,GAAiC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACjE,QAAA,uBAAuB,GAAwD,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;AAC9G,QAAA,8BAA8B,GAAyD,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;AAC7H,QAAA,2BAA2B,GAAsD,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;AACpH,QAAA,0BAA0B,GAA2B,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AAClF,QAAA,WAAW,GAAiC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5E;;;;GAIG;AACH,MAAa,iBAAiB;IAO1B,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAGD,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC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C7B,CAAC;CACJ;AAjFD,8CAiFC"}
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@eclipse-glsp/vscode-integration-webview",
3
- "version": "1.1.0-next.e56e93f.46+e56e93f",
3
+ "version": "1.1.0-next.e5a109d.70+e5a109d",
4
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
5
  "keywords": [
7
6
  "vscode",
8
7
  "graph",
@@ -12,13 +11,14 @@
12
11
  ],
13
12
  "homepage": "https://www.eclipse.org/glsp/",
14
13
  "bugs": "https://github.com/eclipse-glsp/glsp/issues",
15
- "author": {
16
- "name": "Eclipse GLSP"
17
- },
18
14
  "repository": {
19
15
  "type": "git",
20
16
  "url": "https://github.com/eclipse-glsp/glsp-vscode-integration.git"
21
17
  },
18
+ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
19
+ "author": {
20
+ "name": "Eclipse GLSP"
21
+ },
22
22
  "contributors": [
23
23
  {
24
24
  "name": "Eclipse GLSP Project",
@@ -26,29 +26,30 @@
26
26
  "url": "https://projects.eclipse.org/projects/ecd.glsp"
27
27
  }
28
28
  ],
29
+ "main": "lib/index",
30
+ "types": "lib/index",
29
31
  "files": [
30
32
  "lib",
31
33
  "src",
32
34
  "css"
33
35
  ],
36
+ "scripts": {
37
+ "build": "tsc -b",
38
+ "clean": "rimraf lib tsconfig.tsbuildinfo ",
39
+ "lint": "eslint --ext .ts,.tsx ./src",
40
+ "lint:ci": "yarn lint -o eslint.xml -f checkstyle",
41
+ "prepare": "yarn clean && yarn build",
42
+ "watch": "tsc -w"
43
+ },
34
44
  "dependencies": {
35
45
  "@eclipse-glsp/client": "next",
36
- "sprotty-vscode-webview": "~0.3.1"
46
+ "vscode-messenger-webview": "^0.4.5"
37
47
  },
38
48
  "devDependencies": {
39
49
  "reflect-metadata": "^0.1.13"
40
50
  },
41
- "scripts": {
42
- "prepare": "yarn clean && yarn build && yarn lint",
43
- "clean": "rimraf lib tsconfig.tsbuildinfo",
44
- "build": "tsc",
45
- "watch": "tsc -w",
46
- "lint": "eslint -c ./.eslintrc.js --ext .ts ./src"
47
- },
48
51
  "publishConfig": {
49
52
  "access": "public"
50
53
  },
51
- "main": "lib/index",
52
- "types": "lib/index",
53
- "gitHead": "e56e93f016b6c43e5145e5011ae2db7133e90301"
54
+ "gitHead": "e5a109d5721e55b0a67a4193b1742014c16d3414"
54
55
  }
@@ -0,0 +1,27 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import { ModuleConfiguration } from '@eclipse-glsp/client';
18
+ import { vscodeCopyPasteModule } from './features/copyPaste/copy-paste-module';
19
+ import { vscodeDefaultModule } from './features/default/default-module';
20
+ import { vscodeExportModule } from './features/export/export-module';
21
+ import { vscodeNavigationModule } from './features/navigation/navigation-module';
22
+
23
+ export const VSCODE_DEFAULT_MODULES = [vscodeDefaultModule, vscodeCopyPasteModule, vscodeExportModule, vscodeNavigationModule] as const;
24
+
25
+ export const VSCODE_DEFAULT_MODULE_CONFIG: ModuleConfiguration = {
26
+ add: [...VSCODE_DEFAULT_MODULES]
27
+ };
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2021-2022 EclipseSource and others.
2
+ * Copyright (c) 2021-2023 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -13,7 +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 { hasStringProp, InitializeResult } from '@eclipse-glsp/client';
16
+ import { AnyObject, hasStringProp } from '@eclipse-glsp/client';
17
17
 
18
18
  export const GLSPDiagramIdentifier = Symbol('GLSPDiagramIdentifier');
19
19
 
@@ -21,15 +21,26 @@ export interface GLSPDiagramIdentifier {
21
21
  clientId: string;
22
22
  diagramType: string;
23
23
  uri: string;
24
- initializeResult?: InitializeResult;
25
24
  }
26
25
 
27
26
  export function isDiagramIdentifier(object: any): object is GLSPDiagramIdentifier {
28
27
  return (
29
- object !== undefined &&
30
- typeof object === 'object' &&
28
+ AnyObject.is(object) && //
31
29
  hasStringProp(object, 'clientId') &&
32
30
  hasStringProp(object, 'diagramType') &&
33
31
  hasStringProp(object, 'uri')
34
32
  );
35
33
  }
34
+
35
+ // ----------------------------------
36
+ // Initial Handshake
37
+
38
+ export interface WebviewReadyMessage {
39
+ readyMessage: string;
40
+ }
41
+
42
+ export namespace WebviewReadyMessage {
43
+ export function is(object: unknown): object is WebviewReadyMessage {
44
+ return AnyObject.is(object) && hasStringProp(object, 'readyMessage');
45
+ }
46
+ }
@@ -0,0 +1,39 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import {
18
+ FeatureModule,
19
+ ICopyPasteHandler,
20
+ RequestClipboardDataAction,
21
+ SetClipboardDataAction,
22
+ TYPES,
23
+ bindAsService,
24
+ copyPasteModule
25
+ } from '@eclipse-glsp/client';
26
+ import { ExtensionActionKind } from '../default/extension-action-handler';
27
+ import { CopyPasteHandlerProvider, CopyPasteStartup } from './copy-paste-startup';
28
+
29
+ export const vscodeCopyPasteModule = new FeatureModule(
30
+ bind => {
31
+ bind(CopyPasteHandlerProvider).toProvider(
32
+ ctx => () => new Promise<ICopyPasteHandler>(resolve => resolve(ctx.container.get<ICopyPasteHandler>(TYPES.ICopyPasteHandler)))
33
+ );
34
+ bindAsService(bind, TYPES.IDiagramStartup, CopyPasteStartup);
35
+ bind(ExtensionActionKind).toConstantValue(RequestClipboardDataAction.KIND);
36
+ bind(ExtensionActionKind).toConstantValue(SetClipboardDataAction.KIND);
37
+ },
38
+ { requires: copyPasteModule }
39
+ );
@@ -0,0 +1,50 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import { ICopyPasteHandler, IDiagramStartup, MaybePromise } from '@eclipse-glsp/client';
18
+ import { inject, injectable } from 'inversify';
19
+
20
+ export const CopyPasteHandlerProvider = Symbol('CopyPasteHandlerProvider');
21
+ /**
22
+ * Service identifier and type definition to bind the {@link ICopyPasteHandler} to an provider.
23
+ * This enables asynchronous injections and can be used to bypass circular dependency issues.
24
+ */
25
+ export type CopyPasteHandlerProvider = () => Promise<ICopyPasteHandler>;
26
+
27
+ /**
28
+ * Startup service to hook up the copy&paste event handler
29
+ */
30
+ @injectable()
31
+ export class CopyPasteStartup implements IDiagramStartup {
32
+ @inject(CopyPasteHandlerProvider)
33
+ protected copyPasteHandlerProvider: CopyPasteHandlerProvider;
34
+
35
+ preInitialize(): MaybePromise<void> {
36
+ this.copyPasteHandlerProvider().then(copyPasteHandler => {
37
+ document.addEventListener('copy', (e: ClipboardEvent) => {
38
+ copyPasteHandler.handleCopy(e);
39
+ });
40
+
41
+ document.addEventListener('cut', (e: ClipboardEvent) => {
42
+ copyPasteHandler.handleCut(e);
43
+ });
44
+
45
+ document.addEventListener('paste', (e: ClipboardEvent) => {
46
+ copyPasteHandler.handlePaste(e);
47
+ });
48
+ });
49
+ }
50
+ }
@@ -0,0 +1,31 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import { FeatureModule, GLSPModelSource, TYPES, bindAsService, defaultModule } from '@eclipse-glsp/client';
18
+ import { GLSPDiagramWidget, GLSPDiagramWidgetFactory } from '../../glsp-diagram-widget';
19
+ import { HostExtensionActionHandler } from './extension-action-handler';
20
+ import { VsCodeGLSPModelSource } from './vscode-glsp-modelsource';
21
+
22
+ export const vscodeDefaultModule = new FeatureModule(
23
+ (bind, _unbind, _isBound, rebind) => {
24
+ bind(GLSPDiagramWidget).toSelf().inSingletonScope();
25
+ bind(GLSPDiagramWidgetFactory).toFactory(context => () => context.container.get<GLSPDiagramWidget>(GLSPDiagramWidget));
26
+ bind(VsCodeGLSPModelSource).toSelf().inSingletonScope();
27
+ rebind(GLSPModelSource).toService(VsCodeGLSPModelSource);
28
+ bindAsService(bind, TYPES.IActionHandlerInitializer, HostExtensionActionHandler);
29
+ },
30
+ { requires: defaultModule }
31
+ );
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2021-2022 EclipseSource and others.
2
+ * Copyright (c) 2021-2023 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -13,21 +13,48 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Action, ActionHandlerRegistry, IActionHandler, IActionHandlerInitializer, ICommand } from '@eclipse-glsp/client';
17
- import { SprottyDiagramIdentifier } from 'sprotty-vscode-webview';
18
- import { VsCodeApi } from 'sprotty-vscode-webview/lib/services';
16
+ import {
17
+ Action,
18
+ ActionHandlerRegistry,
19
+ GLSPClient,
20
+ IActionHandler,
21
+ IActionHandlerInitializer,
22
+ ICommand,
23
+ IDiagramOptions,
24
+ TYPES
25
+ } from '@eclipse-glsp/client';
26
+ import { inject, injectable, multiInject, optional, postConstruct } from 'inversify';
19
27
 
20
28
  /**
21
- * Delegates actions that should be handled inside of the glsp vscode extension instead
29
+ * Service identifier to define action kinds that should be delegated to the vscode extension.
30
+ *
31
+ * Usage:
32
+ * ```ts
33
+ * bind(ExtensionActionKind).toConstantValue(SomeAction.KIND)
34
+ * ```
35
+ */
36
+ export const ExtensionActionKind = Symbol('ExtensionActionKind');
37
+
38
+ /**
39
+ * Delegates actions that should be handled inside of the glsp host extension instead
22
40
  * of the webview. This enables the implementation of action handlers that require access
23
41
  * to the vscode API and/or node backend.
24
42
  */
25
- export class GLSPVscodeExtensionActionHandler implements IActionHandler, IActionHandlerInitializer {
26
- constructor(
27
- protected readonly actionKinds: string[],
28
- protected readonly diagramIdentifier: SprottyDiagramIdentifier,
29
- protected vscodeApi: VsCodeApi
30
- ) {}
43
+ @injectable()
44
+ export class HostExtensionActionHandler implements IActionHandler, IActionHandlerInitializer {
45
+ @multiInject(ExtensionActionKind)
46
+ @optional()
47
+ protected actionKinds: string[] = [];
48
+
49
+ @inject(TYPES.IDiagramOptions)
50
+ protected diagramOptions: IDiagramOptions;
51
+
52
+ protected glspClient?: GLSPClient;
53
+
54
+ @postConstruct()
55
+ protected postConstruct(): void {
56
+ this.diagramOptions.glspClientProvider().then(glspClient => (this.glspClient = glspClient));
57
+ }
31
58
 
32
59
  initialize(registry: ActionHandlerRegistry): void {
33
60
  this.actionKinds.forEach(kind => registry.register(kind, this));
@@ -36,11 +63,11 @@ export class GLSPVscodeExtensionActionHandler implements IActionHandler, IAction
36
63
  handle(action: Action): void | Action | ICommand {
37
64
  if (this.actionKinds.includes(action.kind)) {
38
65
  const message = {
39
- clientId: this.diagramIdentifier.clientId,
66
+ clientId: this.diagramOptions.clientId,
40
67
  action,
41
68
  __localDispatch: true
42
69
  };
43
- this.vscodeApi.postMessage(message);
70
+ this.glspClient?.sendActionMessage(message);
44
71
  }
45
72
  }
46
73
  }
@@ -0,0 +1,63 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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, ActionMessage, GLSPModelSource, ServerAction } from '@eclipse-glsp/client';
17
+ import { injectable } from 'inversify';
18
+
19
+ /**
20
+ * A helper interface that allows the webview to mark actions that have been received directly from the vscode extension
21
+ * (i.e. they are not forwarded to the GLSP Server).
22
+ */
23
+ export interface ExtensionAction extends Action {
24
+ __localDispatch: true;
25
+ }
26
+
27
+ export namespace ExtensionAction {
28
+ export function is(object: unknown): object is ExtensionAction {
29
+ return Action.is(object) && '__localDispatch' in object && object.__localDispatch === true;
30
+ }
31
+
32
+ /**
33
+ * Mark the given action as {@link ServerAction} by attaching the "_receivedFromServer" property
34
+ * @param action The action that should be marked as server action
35
+ */
36
+ export function mark(action: Action): void {
37
+ (action as ExtensionAction).__localDispatch = true;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Customization of the default {@link GLSPModelSource} for the vscode integration.
43
+ * Also takes locally dispatched actions (i.e. actions that are originating from or intended for the host extension) into consideration.
44
+ */
45
+ @injectable()
46
+ export class VsCodeGLSPModelSource extends GLSPModelSource {
47
+ protected override messageReceived(message: ActionMessage): void {
48
+ if (this.clientId !== message.clientId) {
49
+ return;
50
+ }
51
+ this.checkMessageOrigin(message);
52
+ const action = message.action;
53
+ this.logger.log(this, 'receiving', action);
54
+ this.actionDispatcher.dispatch(action);
55
+ }
56
+
57
+ protected checkMessageOrigin(message: ActionMessage): void {
58
+ const isLocalDispatch = (message as any)['__localDispatch'] ?? false;
59
+ if (!isLocalDispatch) {
60
+ ServerAction.mark(message.action);
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,22 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import { ExportSvgAction, FeatureModule } from '@eclipse-glsp/client';
18
+ import { ExtensionActionKind } from '../default/extension-action-handler';
19
+
20
+ export const vscodeExportModule = new FeatureModule(bind => {
21
+ bind(ExtensionActionKind).toConstantValue(ExportSvgAction.KIND);
22
+ });
@@ -0,0 +1,22 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+
17
+ import { FeatureModule, NavigateToExternalTargetAction, navigationModule } from '@eclipse-glsp/client';
18
+ import { ExtensionActionKind } from '../default/extension-action-handler';
19
+
20
+ export const vscodeNavigationModule = new FeatureModule(bind => {
21
+ bind(ExtensionActionKind).toConstantValue(NavigateToExternalTargetAction.KIND);
22
+ }, navigationModule);
@@ -0,0 +1,79 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2018 TypeFox and others.
3
+ * Modifications: (c) 2020-2023 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
+ // based on https://github.com/eclipse-sprotty/sprotty-vscode/blob/v0.3.0/sprotty-vscode-webview/src/vscode-diagram-widget.ts
18
+ import {
19
+ DiagramLoader,
20
+ DiagramLoadingOptions,
21
+ IActionDispatcher,
22
+ IDiagramOptions,
23
+ ModelSource,
24
+ TYPES,
25
+ ViewerOptions
26
+ } from '@eclipse-glsp/client';
27
+ import { inject, injectable, postConstruct } from 'inversify';
28
+
29
+ export const GLSPDiagramWidgetFactory = Symbol('GLSPDiagramWidgetFactory');
30
+ export type GLSPDiagramWidgetFactory = () => GLSPDiagramWidget;
31
+
32
+ @injectable()
33
+ export abstract class GLSPDiagramWidget {
34
+ @inject(TYPES.IActionDispatcher)
35
+ protected actionDispatcher: IActionDispatcher;
36
+
37
+ @inject(TYPES.ModelSource)
38
+ protected modelSource: ModelSource;
39
+
40
+ @inject(TYPES.IDiagramOptions)
41
+ protected diagramOptions: IDiagramOptions;
42
+
43
+ @inject(TYPES.ViewerOptions)
44
+ protected viewerOptions: ViewerOptions;
45
+
46
+ @inject(DiagramLoader)
47
+ protected diagramLoader: DiagramLoader;
48
+
49
+ get clientId(): string {
50
+ return this.diagramOptions.clientId;
51
+ }
52
+
53
+ @postConstruct()
54
+ initialize(): void {
55
+ this.initializeHtml();
56
+ this.loadDiagram();
57
+ }
58
+
59
+ protected initializeHtml(): void {
60
+ const containerDiv = document.getElementById(this.clientId + '_container');
61
+ if (containerDiv) {
62
+ const svgContainer = document.createElement('div');
63
+ svgContainer.id = this.viewerOptions.baseDiv;
64
+ containerDiv.appendChild(svgContainer);
65
+
66
+ const hiddenContainer = document.createElement('div');
67
+ hiddenContainer.id = this.viewerOptions.hiddenDiv;
68
+ document.body.appendChild(hiddenContainer);
69
+ }
70
+ }
71
+
72
+ protected createDiagramLoadingOptions(): DiagramLoadingOptions | undefined {
73
+ return undefined;
74
+ }
75
+
76
+ loadDiagram(): Promise<void> {
77
+ return this.diagramLoader.load(this.createDiagramLoadingOptions());
78
+ }
79
+ }