@eclipse-glsp/vscode-integration-webview 1.1.0-next.ef526c6.51 → 2.0.0

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 (89) hide show
  1. package/README.md +1 -1
  2. package/lib/default-modules.d.ts +19 -0
  3. package/lib/default-modules.d.ts.map +1 -0
  4. package/lib/default-modules.js +34 -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/lib/{copy-paste-handler-provider.d.ts → features/copyPaste/copy-paste-startup.d.ts} +10 -3
  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 +31 -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} +18 -11
  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/features/notification/notification-module.d.ts +18 -0
  39. package/lib/features/notification/notification-module.d.ts.map +1 -0
  40. package/lib/features/notification/notification-module.js +27 -0
  41. package/lib/features/notification/notification-module.js.map +1 -0
  42. package/lib/glsp-diagram-widget.d.ts +32 -0
  43. package/lib/glsp-diagram-widget.d.ts.map +1 -0
  44. package/lib/glsp-diagram-widget.js +89 -0
  45. package/lib/glsp-diagram-widget.js.map +1 -0
  46. package/lib/glsp-starter.d.ts +43 -9
  47. package/lib/glsp-starter.d.ts.map +1 -1
  48. package/lib/glsp-starter.js +53 -66
  49. package/lib/glsp-starter.js.map +1 -1
  50. package/lib/index.d.ts +12 -2
  51. package/lib/index.d.ts.map +1 -1
  52. package/lib/index.js +26 -16
  53. package/lib/index.js.map +1 -1
  54. package/lib/webview-glsp-client.d.ts +56 -0
  55. package/lib/webview-glsp-client.d.ts.map +1 -0
  56. package/lib/webview-glsp-client.js +103 -0
  57. package/lib/webview-glsp-client.js.map +1 -0
  58. package/package.json +15 -15
  59. package/src/default-modules.ts +34 -0
  60. package/src/{diagram-identifer.ts → diagram-identifier.ts} +16 -5
  61. package/src/features/copyPaste/copy-paste-module.ts +39 -0
  62. package/src/features/copyPaste/copy-paste-startup.ts +50 -0
  63. package/src/features/default/default-module.ts +32 -0
  64. package/src/features/default/extension-action-handler.ts +73 -0
  65. package/src/features/default/vscode-glsp-modelsource.ts +63 -0
  66. package/src/{copy-paste-handler-provider.ts → features/export/export-module.ts} +6 -8
  67. package/src/features/navigation/navigation-module.ts +22 -0
  68. package/src/features/notification/notification-module.ts +25 -0
  69. package/src/glsp-diagram-widget.ts +79 -0
  70. package/src/glsp-starter.ts +69 -85
  71. package/src/index.ts +13 -2
  72. package/src/webview-glsp-client.ts +132 -0
  73. package/lib/copy-paste-handler-provider.d.ts.map +0 -1
  74. package/lib/copy-paste-handler-provider.js.map +0 -1
  75. package/lib/diagram-identifer.d.ts.map +0 -1
  76. package/lib/diagram-identifer.js.map +0 -1
  77. package/lib/extension-action-handler.d.ts.map +0 -1
  78. package/lib/extension-action-handler.js +0 -30
  79. package/lib/extension-action-handler.js.map +0 -1
  80. package/lib/glsp-vscode-diagram-widget.d.ts +0 -6
  81. package/lib/glsp-vscode-diagram-widget.d.ts.map +0 -1
  82. package/lib/glsp-vscode-diagram-widget.js.map +0 -1
  83. package/lib/glsp-vscode-diagramserver.d.ts +0 -33
  84. package/lib/glsp-vscode-diagramserver.d.ts.map +0 -1
  85. package/lib/glsp-vscode-diagramserver.js +0 -108
  86. package/lib/glsp-vscode-diagramserver.js.map +0 -1
  87. package/src/extension-action-handler.ts +0 -46
  88. package/src/glsp-vscode-diagram-widget.ts +0 -42
  89. package/src/glsp-vscode-diagramserver.ts +0 -111
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GLSPVscodeDiagramServer = exports.localDispatchProperty = exports.receivedFromServerProperty = void 0;
13
- /********************************************************************************
14
- * Copyright (c) 2020-2022 EclipseSource and others.
15
- *
16
- * This program and the accompanying materials are made available under the
17
- * terms of the Eclipse Public License v. 2.0 which is available at
18
- * http://www.eclipse.org/legal/epl-2.0.
19
- *
20
- * This Source Code may also be made available under the following Secondary
21
- * Licenses when the conditions for such availability set forth in the Eclipse
22
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
- * with the GNU Classpath Exception which is available at
24
- * https://www.gnu.org/software/classpath/license.html.
25
- *
26
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
- ********************************************************************************/
28
- const client_1 = require("@eclipse-glsp/client");
29
- const selection_service_1 = require("@eclipse-glsp/client/lib/features/select/selection-service");
30
- const inversify_1 = require("inversify");
31
- const vscode_diagram_server_1 = require("sprotty-vscode-webview/lib/vscode-diagram-server");
32
- const copy_paste_handler_provider_1 = require("./copy-paste-handler-provider");
33
- exports.receivedFromServerProperty = '__receivedFromServer';
34
- exports.localDispatchProperty = '__localDispatch';
35
- class GLSPVscodeDiagramServer extends vscode_diagram_server_1.VscodeDiagramServer {
36
- initialize(registry) {
37
- (0, client_1.registerDefaultGLSPServerActions)(registry, this);
38
- this.clientId = this.viewerOptions.baseDiv;
39
- window.addEventListener('message', message => {
40
- if ('data' in message && client_1.ActionMessage.is(message.data)) {
41
- this.messageReceived(message.data);
42
- }
43
- });
44
- this.copyPasteHandlerProvider().then(copyPasteHandler => {
45
- document.addEventListener('copy', (e) => {
46
- copyPasteHandler.handleCopy(e);
47
- });
48
- document.addEventListener('cut', (e) => {
49
- copyPasteHandler.handleCut(e);
50
- });
51
- document.addEventListener('paste', (e) => {
52
- copyPasteHandler.handlePaste(e);
53
- });
54
- });
55
- }
56
- handleLocally(action) {
57
- if (client_1.SetEditModeAction.is(action)) {
58
- return this.handleSetEditModeAction(action);
59
- }
60
- if (client_1.DeleteElementOperation.is(action)) {
61
- return this.handleDeleteElementOperation(action);
62
- }
63
- return super.handleLocally(action);
64
- }
65
- messageReceived(data) {
66
- const object = typeof data === 'string' ? JSON.parse(data) : data;
67
- if (client_1.ActionMessage.is(object) && object.action) {
68
- if (!object.clientId || object.clientId === this.clientId) {
69
- this.checkMessageOrigin(object);
70
- this.logger.log(this, 'receiving', object);
71
- this.actionDispatcher.dispatch(object.action).then(() => {
72
- this.storeNewModel(object.action);
73
- });
74
- }
75
- }
76
- else {
77
- this.logger.error(this, 'received data is not an action message', object);
78
- }
79
- }
80
- checkMessageOrigin(message) {
81
- const isLocalDispatch = message[exports.localDispatchProperty] || false;
82
- if (!isLocalDispatch) {
83
- message.action[exports.receivedFromServerProperty] = true;
84
- }
85
- }
86
- handleComputedBounds(action) {
87
- return true;
88
- }
89
- handleDeleteElementOperation(operation) {
90
- if (operation.elementIds.length === 0) {
91
- operation.elementIds.push(...this.selectionService.getSelectedElementIDs());
92
- }
93
- return true;
94
- }
95
- handleSetEditModeAction(action) {
96
- return action[exports.receivedFromServerProperty] !== true;
97
- }
98
- }
99
- __decorate([
100
- (0, inversify_1.inject)(client_1.TYPES.SelectionService),
101
- __metadata("design:type", selection_service_1.SelectionService)
102
- ], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
103
- __decorate([
104
- (0, inversify_1.inject)(copy_paste_handler_provider_1.CopyPasteHandlerProvider),
105
- __metadata("design:type", Function)
106
- ], GLSPVscodeDiagramServer.prototype, "copyPasteHandlerProvider", void 0);
107
- exports.GLSPVscodeDiagramServer = GLSPVscodeDiagramServer;
108
- //# sourceMappingURL=glsp-vscode-diagramserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAS8B;AAC9B,kGAA8F;AAC9F,yCAAmC;AACnC,4FAAuF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,4BAA4B,CAAC,SAAiC;QACpE,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YACnC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,CAAC;SAC/E;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAES,uBAAuB,CAAC,MAAyB;QACvD,OAAQ,MAAc,CAAC,kCAA0B,CAAC,KAAK,IAAI,CAAC;IAChE,CAAC;CACJ;AA7EG;IAAC,IAAA,kBAAM,EAAC,cAAK,CAAC,gBAAgB,CAAC;8BACH,oCAAgB;iEAAC;AAE7C;IAAC,IAAA,kBAAM,EAAC,sDAAwB,CAAC;;yEAC4B;AALjE,0DA8EC"}
@@ -1,46 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2021-2022 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 '@eclipse-glsp/client';
17
- import { SprottyDiagramIdentifier } from 'sprotty-vscode-webview';
18
- import { VsCodeApi } from 'sprotty-vscode-webview/lib/services';
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
- constructor(
27
- protected readonly actionKinds: string[],
28
- protected readonly diagramIdentifier: SprottyDiagramIdentifier,
29
- protected vscodeApi: VsCodeApi
30
- ) {}
31
-
32
- initialize(registry: ActionHandlerRegistry): void {
33
- this.actionKinds.forEach(kind => registry.register(kind, this));
34
- }
35
-
36
- handle(action: Action): void | Action | ICommand {
37
- if (this.actionKinds.includes(action.kind)) {
38
- const message = {
39
- clientId: this.diagramIdentifier.clientId,
40
- action,
41
- __localDispatch: true
42
- };
43
- this.vscodeApi.postMessage(message);
44
- }
45
- }
46
- }
@@ -1,42 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2020-2022 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 { DiagramServerProxy, EnableToolPaletteAction, RequestModelAction, RequestTypeHintsAction } from '@eclipse-glsp/client';
17
- import { injectable } from 'inversify';
18
- import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
19
-
20
- @injectable()
21
- export abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
22
- protected override initializeSprotty(): void {
23
- if (this.modelSource instanceof DiagramServerProxy) {
24
- this.modelSource.clientId = this.diagramIdentifier.clientId;
25
- }
26
- this.actionDispatcher.dispatch(
27
- RequestModelAction.create({
28
- options: {
29
- sourceUri: decodeURI(this.diagramIdentifier.uri),
30
- diagramType: this.diagramIdentifier.diagramType
31
- }
32
- })
33
- );
34
-
35
- this.actionDispatcher.dispatch(RequestTypeHintsAction.create());
36
- this.actionDispatcher.dispatch(EnableToolPaletteAction.create());
37
- }
38
- }
39
-
40
- export function decodeURI(uri: string): string {
41
- return decodeURIComponent(uri.replace(/\+/g, ' '));
42
- }
@@ -1,111 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2020-2022 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 {
17
- Action,
18
- ActionHandlerRegistry,
19
- ActionMessage,
20
- ComputedBoundsAction,
21
- DeleteElementOperation,
22
- registerDefaultGLSPServerActions,
23
- SetEditModeAction,
24
- TYPES
25
- } from '@eclipse-glsp/client';
26
- import { SelectionService } from '@eclipse-glsp/client/lib/features/select/selection-service';
27
- import { inject } from 'inversify';
28
- import { VscodeDiagramServer } from 'sprotty-vscode-webview/lib/vscode-diagram-server';
29
- import { CopyPasteHandlerProvider } from './copy-paste-handler-provider';
30
- export const receivedFromServerProperty = '__receivedFromServer';
31
- export const localDispatchProperty = '__localDispatch';
32
-
33
- export class GLSPVscodeDiagramServer extends VscodeDiagramServer {
34
- @inject(TYPES.SelectionService)
35
- protected selectionService: SelectionService;
36
-
37
- @inject(CopyPasteHandlerProvider)
38
- protected copyPasteHandlerProvider: CopyPasteHandlerProvider;
39
-
40
- override initialize(registry: ActionHandlerRegistry): void {
41
- registerDefaultGLSPServerActions(registry, this);
42
- this.clientId = this.viewerOptions.baseDiv;
43
-
44
- window.addEventListener('message', message => {
45
- if ('data' in message && ActionMessage.is(message.data)) {
46
- this.messageReceived(message.data);
47
- }
48
- });
49
-
50
- this.copyPasteHandlerProvider().then(copyPasteHandler => {
51
- document.addEventListener('copy', (e: ClipboardEvent) => {
52
- copyPasteHandler.handleCopy(e);
53
- });
54
-
55
- document.addEventListener('cut', (e: ClipboardEvent) => {
56
- copyPasteHandler.handleCut(e);
57
- });
58
-
59
- document.addEventListener('paste', (e: ClipboardEvent) => {
60
- copyPasteHandler.handlePaste(e);
61
- });
62
- });
63
- }
64
-
65
- override handleLocally(action: Action): boolean {
66
- if (SetEditModeAction.is(action)) {
67
- return this.handleSetEditModeAction(action);
68
- }
69
- if (DeleteElementOperation.is(action)) {
70
- return this.handleDeleteElementOperation(action);
71
- }
72
- return super.handleLocally(action);
73
- }
74
-
75
- protected override messageReceived(data: any): void {
76
- const object = typeof data === 'string' ? JSON.parse(data) : data;
77
- if (ActionMessage.is(object) && object.action) {
78
- if (!object.clientId || object.clientId === this.clientId) {
79
- this.checkMessageOrigin(object);
80
- this.logger.log(this, 'receiving', object);
81
- this.actionDispatcher.dispatch(object.action).then(() => {
82
- this.storeNewModel(object.action);
83
- });
84
- }
85
- } else {
86
- this.logger.error(this, 'received data is not an action message', object);
87
- }
88
- }
89
-
90
- protected checkMessageOrigin(message: ActionMessage): void {
91
- const isLocalDispatch = (message as any)[localDispatchProperty] || false;
92
- if (!isLocalDispatch) {
93
- (message.action as any)[receivedFromServerProperty] = true;
94
- }
95
- }
96
-
97
- protected override handleComputedBounds(action: ComputedBoundsAction): boolean {
98
- return true;
99
- }
100
-
101
- protected handleDeleteElementOperation(operation: DeleteElementOperation): boolean {
102
- if (operation.elementIds.length === 0) {
103
- operation.elementIds.push(...this.selectionService.getSelectedElementIDs());
104
- }
105
- return true;
106
- }
107
-
108
- protected handleSetEditModeAction(action: SetEditModeAction): boolean {
109
- return (action as any)[receivedFromServerProperty] !== true;
110
- }
111
- }