@eclipse-glsp/server 1.1.0-RC05 → 1.1.0-RC06

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 (78) hide show
  1. package/lib/browser/launch/worker-server-launcher.d.ts +8 -5
  2. package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -1
  3. package/lib/browser/launch/worker-server-launcher.js +9 -11
  4. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  5. package/lib/common/command/command-stack.d.ts +7 -6
  6. package/lib/common/command/command-stack.d.ts.map +1 -1
  7. package/lib/common/command/command-stack.js +6 -6
  8. package/lib/common/command/command-stack.js.map +1 -1
  9. package/lib/common/command/command-stack.spec.js +31 -31
  10. package/lib/common/command/command-stack.spec.js.map +1 -1
  11. package/lib/common/command/command.d.ts +7 -6
  12. package/lib/common/command/command.d.ts.map +1 -1
  13. package/lib/common/command/command.js +19 -15
  14. package/lib/common/command/command.js.map +1 -1
  15. package/lib/common/command/command.spec.js +8 -8
  16. package/lib/common/command/command.spec.js.map +1 -1
  17. package/lib/common/command/recording-command.d.ts +15 -15
  18. package/lib/common/command/recording-command.d.ts.map +1 -1
  19. package/lib/common/command/recording-command.js +10 -10
  20. package/lib/common/command/recording-command.js.map +1 -1
  21. package/lib/common/command/recording-command.spec.js +8 -8
  22. package/lib/common/command/recording-command.spec.js.map +1 -1
  23. package/lib/common/command/undo-redo-action-handler.d.ts +2 -2
  24. package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -1
  25. package/lib/common/command/undo-redo-action-handler.js +4 -4
  26. package/lib/common/command/undo-redo-action-handler.js.map +1 -1
  27. package/lib/common/features/layout/computed-bounds-action-handler.js +1 -1
  28. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
  29. package/lib/common/index.d.ts +3 -1
  30. package/lib/common/index.d.ts.map +1 -1
  31. package/lib/common/index.js +3 -1
  32. package/lib/common/index.js.map +1 -1
  33. package/lib/common/launch/glsp-server-launcher.d.ts +7 -6
  34. package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
  35. package/lib/common/launch/glsp-server-launcher.js +25 -2
  36. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  37. package/lib/common/operations/operation-action-handler.d.ts +1 -1
  38. package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
  39. package/lib/common/operations/operation-action-handler.js +3 -3
  40. package/lib/common/operations/operation-action-handler.js.map +1 -1
  41. package/lib/common/test/mock-util.d.ts +7 -1
  42. package/lib/common/test/mock-util.d.ts.map +1 -1
  43. package/lib/common/test/mock-util.js +23 -1
  44. package/lib/common/test/mock-util.js.map +1 -1
  45. package/lib/common/utils/layout-util.d.ts +1 -1
  46. package/lib/common/utils/layout-util.d.ts.map +1 -1
  47. package/lib/common/utils/layout-util.js +3 -3
  48. package/lib/common/utils/layout-util.js.map +1 -1
  49. package/lib/node/index.d.ts +1 -0
  50. package/lib/node/index.d.ts.map +1 -1
  51. package/lib/node/index.js +1 -0
  52. package/lib/node/index.js.map +1 -1
  53. package/lib/node/launch/socket-server-launcher.d.ts +2 -1
  54. package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
  55. package/lib/node/launch/socket-server-launcher.js +11 -10
  56. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  57. package/lib/node/launch/websocket-server-launcher.d.ts +59 -0
  58. package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -0
  59. package/lib/node/launch/websocket-server-launcher.js +145 -0
  60. package/lib/node/launch/websocket-server-launcher.js.map +1 -0
  61. package/package.json +8 -6
  62. package/src/browser/launch/worker-server-launcher.ts +16 -12
  63. package/src/common/command/command-stack.spec.ts +32 -32
  64. package/src/common/command/command-stack.ts +10 -9
  65. package/src/common/command/command.spec.ts +9 -10
  66. package/src/common/command/command.ts +23 -19
  67. package/src/common/command/recording-command.spec.ts +8 -8
  68. package/src/common/command/recording-command.ts +19 -19
  69. package/src/common/command/undo-redo-action-handler.ts +4 -4
  70. package/src/common/features/layout/computed-bounds-action-handler.ts +2 -2
  71. package/src/common/index.ts +3 -1
  72. package/src/common/launch/glsp-server-launcher.ts +13 -7
  73. package/src/common/operations/operation-action-handler.ts +3 -3
  74. package/src/common/test/mock-util.ts +21 -0
  75. package/src/common/utils/layout-util.ts +1 -1
  76. package/src/node/index.ts +1 -0
  77. package/src/node/launch/socket-server-launcher.ts +13 -7
  78. package/src/node/launch/websocket-server-launcher.ts +164 -0
@@ -16,7 +16,7 @@
16
16
  import { expect } from 'chai';
17
17
  import { Container, ContainerModule } from 'inversify';
18
18
  import * as sinon from 'sinon';
19
- import { StubCommand, StubLogger } from '../test/mock-util';
19
+ import { expectToThrowAsync, StubCommand, StubLogger } from '../test/mock-util';
20
20
  import { Logger } from '../utils/logger';
21
21
  import { DefaultCommandStack } from './command-stack';
22
22
 
@@ -41,17 +41,17 @@ describe('test DefaultCommandStack', () => {
41
41
  });
42
42
 
43
43
  describe('execute', () => {
44
- it('should execute the given command and become dirty', () => {
44
+ it('should execute the given command and become dirty', async () => {
45
45
  expect(commandStack.isDirty).to.be.false;
46
- commandStack.execute(command1);
46
+ await commandStack.execute(command1);
47
47
  expect(command1.execute.calledOnce).to.be.true;
48
48
  expect(commandStack.isDirty).to.be.true;
49
49
  });
50
50
 
51
- it('should execute the given commands in order and become dirty', () => {
51
+ it('should execute the given commands in order and become dirty', async () => {
52
52
  expect(commandStack.isDirty).to.be.false;
53
- commandStack.execute(command1);
54
- commandStack.execute(command2);
53
+ await commandStack.execute(command1);
54
+ await commandStack.execute(command2);
55
55
 
56
56
  expect(command1.execute.calledOnce).to.be.true;
57
57
  expect(command2.execute.calledOnce).to.be.true;
@@ -59,112 +59,112 @@ describe('test DefaultCommandStack', () => {
59
59
  expect(commandStack.isDirty).to.be.true;
60
60
  });
61
61
 
62
- it('should be able to undo after execute', () => {
62
+ it('should be able to undo after execute', async () => {
63
63
  expect(commandStack.canUndo()).to.be.false;
64
- commandStack.execute(command1);
64
+ await commandStack.execute(command1);
65
65
  expect(commandStack.canUndo()).to.be.true;
66
66
  });
67
67
 
68
- it('should clear the redo stack after execution', () => {
68
+ it('should clear the redo stack after execution', async () => {
69
69
  commandStack['commands'].push(command2);
70
70
  commandStack['top'] = -1;
71
71
  expect(commandStack.canRedo()).to.be.true;
72
72
 
73
- commandStack.execute(command1);
73
+ await commandStack.execute(command1);
74
74
  expect(commandStack.canRedo()).to.be.false;
75
75
  });
76
76
 
77
- it('should flush the stack in case of an execution error', () => {
77
+ it('should flush the stack in case of an execution error', async () => {
78
78
  command2.execute.throwsException();
79
79
  const flushSpy = sandbox.spy(commandStack, 'flush');
80
80
 
81
- expect(() => commandStack.execute(command2)).to.throw();
81
+ await expectToThrowAsync(() => commandStack.execute(command2));
82
82
  expect(command2.execute.calledOnce).to.be.true;
83
83
  expect(flushSpy.calledOnce).to.be.true;
84
84
  });
85
85
  });
86
86
 
87
87
  describe('undo', () => {
88
- it('should do nothing if the command stack is empty', () => {
88
+ it('should do nothing if the command stack is empty', async () => {
89
89
  expect(commandStack.isDirty).to.be.false;
90
90
 
91
- commandStack.undo();
91
+ await commandStack.undo();
92
92
  expect(commandStack.canUndo()).to.be.false;
93
93
  expect(commandStack.canRedo()).to.be.false;
94
94
  expect(commandStack.isDirty).to.be.false;
95
95
  });
96
96
 
97
- it('should undo the command and become non-dirty again', () => {
97
+ it('should undo the command and become non-dirty again', async () => {
98
98
  commandStack['commands'].push(command1);
99
99
  commandStack['top'] = 0;
100
100
  expect(commandStack.isDirty).to.be.true;
101
101
  expect(commandStack.canUndo()).to.be.true;
102
102
  expect(commandStack.canRedo()).to.be.false;
103
103
 
104
- commandStack.undo();
104
+ await commandStack.undo();
105
105
  expect(command1.undo.calledOnce).to.be.true;
106
106
  expect(commandStack.isDirty).to.be.false;
107
107
  expect(commandStack.canRedo()).to.be.true;
108
108
  expect(commandStack.canUndo()).to.be.false;
109
109
  });
110
110
 
111
- it('should undo multiple command and become non-dirty again', () => {
111
+ it('should undo multiple command and become non-dirty again', async () => {
112
112
  commandStack['commands'].push(command1, command2);
113
113
  commandStack['top'] = 1;
114
114
  expect(commandStack.isDirty).to.be.true;
115
115
  expect(commandStack.canUndo()).to.be.true;
116
116
  expect(commandStack.canRedo()).to.be.false;
117
117
 
118
- commandStack.undo();
118
+ await commandStack.undo();
119
119
  expect(command2.undo.calledOnce).to.be.true;
120
120
  expect(commandStack.canRedo()).to.be.true;
121
121
  expect(commandStack.canUndo()).to.be.true;
122
122
  expect(commandStack.isDirty).to.be.true;
123
123
 
124
- commandStack.undo();
124
+ await commandStack.undo();
125
125
  expect(command1.undo.calledOnce).to.be.true;
126
126
  expect(command1.undo.calledAfter(command2.undo)).to.be.true;
127
127
  expect(commandStack.isDirty).to.be.false;
128
128
  expect(commandStack.canRedo()).to.be.true;
129
129
  expect(commandStack.canUndo()).to.be.false;
130
130
  });
131
- it('should flush the stack in case of an execution error', () => {
131
+ it('should flush the stack in case of an execution error', async () => {
132
132
  command2.undo.throwsException();
133
133
  const flushSpy = sandbox.spy(commandStack, 'flush');
134
134
  commandStack['commands'].push(command2);
135
135
  commandStack['top'] = 0;
136
136
 
137
- expect(() => commandStack.undo()).to.throw();
137
+ await expectToThrowAsync(() => commandStack.undo());
138
138
  expect(command2.undo.calledOnce).to.be.true;
139
139
  expect(flushSpy.calledOnce).to.be.true;
140
140
  });
141
141
  });
142
142
 
143
143
  describe('redo', () => {
144
- it('should do nothing if the command stack is empty', () => {
144
+ it('should do nothing if the command stack is empty', async () => {
145
145
  expect(commandStack.isDirty).to.be.false;
146
146
 
147
- commandStack.redo();
147
+ await commandStack.redo();
148
148
  expect(commandStack.canUndo()).to.be.false;
149
149
  expect(commandStack.canRedo()).to.be.false;
150
150
  expect(commandStack.isDirty).to.be.false;
151
151
  });
152
152
 
153
- it('should redo the command and become dirty again', () => {
153
+ it('should redo the command and become dirty again', async () => {
154
154
  commandStack['commands'].push(command1);
155
155
  commandStack['top'] = -1;
156
156
  expect(commandStack.isDirty).to.be.false;
157
157
  expect(commandStack.canUndo()).to.be.false;
158
158
  expect(commandStack.canRedo()).to.be.true;
159
159
 
160
- commandStack.redo();
160
+ await commandStack.redo();
161
161
  expect(command1.redo.calledOnce).to.be.true;
162
162
  expect(commandStack.isDirty).to.be.true;
163
163
  expect(commandStack.canRedo()).to.be.false;
164
164
  expect(commandStack.canUndo()).to.be.true;
165
165
  });
166
166
 
167
- it('should undo multiple command and become non-dirty again', () => {
167
+ it('should undo multiple command and become non-dirty again', async () => {
168
168
  commandStack['commands'].push(command2, command1);
169
169
  commandStack['top'] = -1;
170
170
  commandStack['saveIndex'] = -1;
@@ -172,34 +172,34 @@ describe('test DefaultCommandStack', () => {
172
172
  expect(commandStack.canUndo()).to.be.false;
173
173
  expect(commandStack.canRedo()).to.be.true;
174
174
 
175
- commandStack.redo();
175
+ await commandStack.redo();
176
176
  expect(command2.redo.calledOnce).to.be.true;
177
177
  expect(commandStack.canRedo()).to.be.true;
178
178
  expect(commandStack.canUndo()).to.be.true;
179
179
  expect(commandStack.isDirty).to.be.true;
180
180
 
181
- commandStack.redo();
181
+ await commandStack.redo();
182
182
  expect(command1.redo.calledOnce).to.be.true;
183
183
  expect(command1.redo.calledAfter(command2.redo)).to.be.true;
184
184
  expect(commandStack.isDirty).to.be.true;
185
185
  expect(commandStack.canRedo()).to.be.false;
186
186
  expect(commandStack.canUndo()).to.be.true;
187
187
  });
188
- it('should flush the stack in case of an execution error', () => {
188
+ it('should flush the stack in case of an execution error', async () => {
189
189
  command2.redo.throwsException();
190
190
  const flushSpy = sandbox.spy(commandStack, 'flush');
191
191
  commandStack['commands'].push(command2);
192
192
  commandStack['top'] = -1;
193
193
 
194
- expect(() => commandStack.redo()).to.throw();
194
+ await expectToThrowAsync(() => commandStack.redo());
195
195
  expect(command2.redo.calledOnce).to.be.true;
196
196
  expect(flushSpy.calledOnce).to.be.true;
197
197
  });
198
- it('should be able to undo after redo', () => {
198
+ it('should be able to undo after redo', async () => {
199
199
  commandStack['commands'].push(command1);
200
200
  commandStack['top'] = -1;
201
201
  expect(commandStack.canUndo()).to.be.false;
202
- commandStack.redo();
202
+ await commandStack.redo();
203
203
  expect(commandStack.canUndo()).to.be.true;
204
204
  });
205
205
  });
@@ -14,6 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import { inject, injectable } from 'inversify';
17
+ import { MaybePromise } from '..';
17
18
  import { Logger } from '../utils/logger';
18
19
  import { Command } from './command';
19
20
 
@@ -31,12 +32,12 @@ export interface CommandStack {
31
32
  * Clears any redoable commands not yet redone, adds the command to the stack and then invokes {@link Command.execute}.
32
33
  * @param command the command to execute.
33
34
  */
34
- execute(command: Command): void;
35
+ execute(command: Command): MaybePromise<void>;
35
36
 
36
37
  /**
37
38
  * Removes the topmost (i.e. last executed) command from the stack and invokes {@link Command.undo}.
38
39
  */
39
- undo(): void;
40
+ undo(): MaybePromise<void>;
40
41
 
41
42
  /**
42
43
  * Returns `true` if the top command on the stack can be undone.
@@ -46,7 +47,7 @@ export interface CommandStack {
46
47
  /**
47
48
  * Re-adds the last undo command on top of the stack and invokes {@link Command.redo}
48
49
  */
49
- redo(): void;
50
+ redo(): MaybePromise<void>;
50
51
 
51
52
  /**
52
53
  * Returns `true` if there are redoable commands in the stack.
@@ -86,9 +87,9 @@ export class DefaultCommandStack implements CommandStack {
86
87
  */
87
88
  protected saveIndex = -1;
88
89
 
89
- execute(command: Command): void {
90
+ async execute(command: Command): Promise<void> {
90
91
  try {
91
- command.execute();
92
+ await command.execute();
92
93
  } catch (error) {
93
94
  this.handleError(error);
94
95
  }
@@ -104,11 +105,11 @@ export class DefaultCommandStack implements CommandStack {
104
105
  }
105
106
  }
106
107
 
107
- undo(): void {
108
+ async undo(): Promise<void> {
108
109
  if (this.canUndo()) {
109
110
  const command = this.commands[this.top--];
110
111
  try {
111
- command.undo();
112
+ await command.undo();
112
113
  } catch (error) {
113
114
  this.handleError(error);
114
115
  }
@@ -121,11 +122,11 @@ export class DefaultCommandStack implements CommandStack {
121
122
  : false;
122
123
  }
123
124
 
124
- redo(): void {
125
+ async redo(): Promise<void> {
125
126
  if (this.canRedo()) {
126
127
  const command = this.commands[++this.top];
127
128
  try {
128
- command.redo();
129
+ await command.redo();
129
130
  } catch (error) {
130
131
  this.handleError(error);
131
132
  }
@@ -15,7 +15,7 @@
15
15
  ********************************************************************************/
16
16
  import { expect } from 'chai';
17
17
  import * as sinon from 'sinon';
18
- import { StubCommand } from '../test/mock-util';
18
+ import { expectToThrowAsync, StubCommand } from '../test/mock-util';
19
19
  import { CompoundCommand } from './command';
20
20
 
21
21
  describe('CompoundCommand', () => {
@@ -32,18 +32,18 @@ describe('CompoundCommand', () => {
32
32
  });
33
33
 
34
34
  describe('execute', () => {
35
- it('Should execute the subcommands in order', () => {
36
- compoundCommand.execute();
35
+ it('Should execute the subcommands in order', async () => {
36
+ await compoundCommand.execute();
37
37
  expect(command1.execute.calledOnce).to.be.true;
38
38
  expect(command2.execute.calledOnce).to.be.true;
39
39
  expect(command3.execute.calledOnce).to.be.true;
40
40
  expect(command1.execute.calledBefore(command2.execute)).to.be.true;
41
41
  expect(command2.execute.calledBefore(command3.execute)).to.be.true;
42
42
  });
43
- it('Should undo partially executed subcommands in case of an error', () => {
43
+ it('Should undo partially executed subcommands in case of an error', async () => {
44
44
  command3.execute.throwsException();
45
45
 
46
- expect(() => compoundCommand.execute()).to.throw();
46
+ await expectToThrowAsync(() => compoundCommand.execute());
47
47
 
48
48
  expect(command1.execute.calledOnce).to.be.true;
49
49
  expect(command2.execute.calledOnce).to.be.true;
@@ -54,8 +54,8 @@ describe('CompoundCommand', () => {
54
54
  });
55
55
 
56
56
  describe('undo', () => {
57
- it('Should undo the subcommands in reverse order', () => {
58
- compoundCommand.undo();
57
+ it('Should undo the subcommands in reverse order', async () => {
58
+ await compoundCommand.undo();
59
59
  expect(command1.undo.calledOnce).to.be.true;
60
60
  expect(command2.undo.calledOnce).to.be.true;
61
61
  expect(command3.undo.calledOnce).to.be.true;
@@ -63,10 +63,9 @@ describe('CompoundCommand', () => {
63
63
  expect(command2.undo.calledAfter(command3.undo)).to.be.true;
64
64
  });
65
65
 
66
- it('Should redo partially undone subcommands in case of an error', () => {
66
+ it('Should redo partially undone subcommands in case of an error', async () => {
67
67
  command1.undo.throwsException();
68
-
69
- expect(() => compoundCommand.undo()).to.throw();
68
+ await expectToThrowAsync(() => compoundCommand.undo());
70
69
 
71
70
  expect(command1.undo.calledOnce).to.be.true;
72
71
  expect(command2.undo.calledOnce).to.be.true;
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { flatPush, MaybeArray } from '@eclipse-glsp/protocol';
17
+ import { flatPush, MaybeArray, MaybePromise } from '@eclipse-glsp/protocol';
18
18
 
19
19
  /**
20
20
  * A command implements a specific modification of the source model, which can be applied by invoking `execute()`.
@@ -30,19 +30,19 @@ export interface Command {
30
30
  /**
31
31
  * Performs the command activity required for the effect (e.g. source model change).
32
32
  */
33
- execute(): void;
33
+ execute(): MaybePromise<void>;
34
34
 
35
35
  /**
36
36
  * Performs the command activity required to `undo` the effects of a preceding `execute` (or `redo`).
37
37
  * The effect, if any, of calling `undo` before `execute` or `redo` have been called, is undefined.
38
38
  */
39
- undo(): void;
39
+ undo(): MaybePromise<void>;
40
40
 
41
41
  /**
42
42
  * Performs the command activity required to `redo` the effect after undoing the effect.
43
43
  * The effect, if any, of calling `redo` before `undo` is called is undefined.
44
44
  */
45
- redo(): void;
45
+ redo(): MaybePromise<void>;
46
46
 
47
47
  /**
48
48
  * Returns whether the command can be undone.
@@ -71,18 +71,18 @@ export class CompoundCommand implements Command {
71
71
  flatPush(this.commands, commands);
72
72
  }
73
73
 
74
- execute(): void {
74
+ async execute(): Promise<void> {
75
75
  const alreadyExecuted: Command[] = [];
76
76
 
77
77
  try {
78
- this.commands.forEach(command => {
79
- command.execute();
78
+ for (const command of this.commands) {
79
+ await command.execute();
80
80
  alreadyExecuted.unshift(command);
81
- });
81
+ }
82
82
  } catch (err) {
83
83
  for (const command of alreadyExecuted) {
84
84
  if (Command.canUndo(command)) {
85
- command.undo();
85
+ await command.undo();
86
86
  } else {
87
87
  break;
88
88
  }
@@ -91,29 +91,33 @@ export class CompoundCommand implements Command {
91
91
  }
92
92
  }
93
93
 
94
- undo(): void {
94
+ async undo(): Promise<void> {
95
95
  const alreadyUndone: Command[] = [];
96
96
  try {
97
- [...this.commands].reverse().forEach(command => {
98
- command.undo();
97
+ for (const command of [...this.commands].reverse()) {
98
+ await command.undo();
99
99
  alreadyUndone.unshift(command);
100
- });
100
+ }
101
101
  } catch (err) {
102
- alreadyUndone.forEach(command => command.redo());
102
+ for (const command of alreadyUndone) {
103
+ await command.redo();
104
+ }
103
105
  throw err;
104
106
  }
105
107
  }
106
108
 
107
- redo(): void {
109
+ async redo(): Promise<void> {
108
110
  const alreadyRedone: Command[] = [];
109
111
 
110
112
  try {
111
- this.commands.forEach(command => {
112
- command.redo();
113
+ for (const command of this.commands) {
114
+ await command.redo();
113
115
  alreadyRedone.unshift(command);
114
- });
116
+ }
115
117
  } catch (err) {
116
- alreadyRedone.forEach(command => command.undo());
118
+ for (const command of alreadyRedone) {
119
+ await command.undo();
120
+ }
117
121
  throw err;
118
122
  }
119
123
  }
@@ -39,36 +39,36 @@ describe('RecordingCommand', () => {
39
39
  beforeState = JSON.parse(JSON.stringify(jsonObject));
40
40
  });
41
41
 
42
- it('should be undoable after execution', () => {
42
+ it('should be undoable after execution', async () => {
43
43
  // eslint-disable-next-line @typescript-eslint/no-empty-function
44
44
  const command = new RecordingCommand(jsonObject, () => {});
45
45
  expect(command.canUndo()).to.be.false;
46
- command.execute();
46
+ await command.execute();
47
47
  expect(command.canUndo()).to.be.true;
48
48
  });
49
49
 
50
- it('should restore the pre execution state when undo is called', () => {
50
+ it('should restore the pre execution state when undo is called', async () => {
51
51
  const command = new RecordingCommand(jsonObject, () => {
52
52
  jsonObject.string = 'bar';
53
53
  jsonObject.flag = false;
54
54
  jsonObject.maybe = { hello: 'world' };
55
55
  });
56
- command.execute();
56
+ await command.execute();
57
57
  expect(jsonObject).to.not.be.deep.equals(beforeState);
58
- command.undo();
58
+ await command.undo();
59
59
  expect(jsonObject).to.be.deep.equals(beforeState);
60
60
  });
61
61
 
62
- it('should restore the post execution state when redo is called', () => {
62
+ it('should restore the post execution state when redo is called', async () => {
63
63
  const command = new RecordingCommand(jsonObject, () => {
64
64
  jsonObject.string = 'bar';
65
65
  jsonObject.flag = false;
66
66
  jsonObject.maybe = { hello: 'world' };
67
67
  });
68
- command.execute();
68
+ await command.execute();
69
69
  const afterState = JSON.parse(JSON.stringify(jsonObject));
70
70
  jsonObject = JSON.parse(JSON.stringify(afterState));
71
- command.redo();
71
+ await command.redo();
72
72
  expect(jsonObject).to.be.deep.equals(afterState);
73
73
  });
74
74
  });
@@ -15,7 +15,7 @@
15
15
  ********************************************************************************/
16
16
 
17
17
  import { GModelRootSchema } from '@eclipse-glsp/graph';
18
- import { AnyObject } from '@eclipse-glsp/protocol';
18
+ import { AnyObject, MaybePromise } from '@eclipse-glsp/protocol';
19
19
  import * as jsonPatch from 'fast-json-patch';
20
20
  import { GModelSerializer } from '../features/model/gmodel-serializer';
21
21
  import { ModelState } from '../features/model/model-state';
@@ -28,10 +28,10 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
28
28
  protected undoPatch?: jsonPatch.Operation[];
29
29
  protected redoPatch?: jsonPatch.Operation[];
30
30
 
31
- execute(): void {
32
- const beforeState = this.deepClone(this.getJsonObject());
33
- this.doExecute();
34
- const afterState = this.getJsonObject();
31
+ async execute(): Promise<void> {
32
+ const beforeState = this.deepClone(await this.getJsonObject());
33
+ await this.doExecute();
34
+ const afterState = await this.getJsonObject();
35
35
  this.undoPatch = jsonPatch.compare(afterState, beforeState);
36
36
  this.redoPatch = jsonPatch.compare(beforeState, afterState);
37
37
  }
@@ -41,14 +41,14 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
41
41
  * right after {@link AbstractRecordingCommand.doExecute} to derive the undo & redo patches.
42
42
  * @returns The current state of the JSON object
43
43
  */
44
- protected abstract getJsonObject(): JsonObject;
44
+ protected abstract getJsonObject(): MaybePromise<JsonObject>;
45
45
 
46
46
  /**
47
47
  * The actual execution i.e. series of changes applied to the JSOn object that should be captured.
48
48
  */
49
- protected abstract doExecute(): void;
49
+ protected abstract doExecute(): MaybePromise<void>;
50
50
 
51
- protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): void {
51
+ protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): MaybePromise<void> {
52
52
  jsonPatch.applyPatch(object, patch, false, true);
53
53
  }
54
54
 
@@ -62,15 +62,15 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
62
62
  return jsonPatch.deepClone(object);
63
63
  }
64
64
 
65
- undo(): void {
65
+ async undo(): Promise<void> {
66
66
  if (this.undoPatch) {
67
- this.applyPatch(this.getJsonObject(), this.undoPatch);
67
+ return this.applyPatch(await this.getJsonObject(), this.undoPatch);
68
68
  }
69
69
  }
70
70
 
71
- redo(): void {
71
+ async redo(): Promise<void> {
72
72
  if (this.redoPatch) {
73
- this.applyPatch(this.getJsonObject(), this.redoPatch);
73
+ return this.applyPatch(await this.getJsonObject(), this.redoPatch);
74
74
  }
75
75
  }
76
76
 
@@ -84,11 +84,11 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
84
84
  * the the given `doExecute` function.
85
85
  */
86
86
  export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
87
- constructor(protected jsonObject: JsonObject, protected doExecute: () => void) {
87
+ constructor(protected jsonObject: JsonObject, protected doExecute: () => MaybePromise<void>) {
88
88
  super();
89
89
  }
90
90
 
91
- protected getJsonObject(): JsonObject {
91
+ protected getJsonObject(): MaybePromise<JsonObject> {
92
92
  return this.jsonObject;
93
93
  }
94
94
  }
@@ -98,20 +98,20 @@ export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends
98
98
  * to the `GModelRoot` ({@link ModelState.root}) during the given `doExecute` function
99
99
  */
100
100
  export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootSchema> {
101
- constructor(protected modelState: ModelState, protected serializer: GModelSerializer, protected doExecute: () => void) {
101
+ constructor(protected modelState: ModelState, protected serializer: GModelSerializer, protected doExecute: () => MaybePromise<void>) {
102
102
  super();
103
103
  }
104
104
 
105
- override execute(): void {
106
- super.execute();
105
+ override async execute(): Promise<void> {
106
+ await super.execute();
107
107
  this.modelState.index.indexRoot(this.modelState.root);
108
108
  }
109
109
 
110
- protected getJsonObject(): GModelRootSchema {
110
+ protected getJsonObject(): MaybePromise<GModelRootSchema> {
111
111
  return this.serializer.createSchema(this.modelState.root);
112
112
  }
113
113
 
114
- protected override applyPatch(rootSchema: GModelRootSchema, patch: jsonPatch.Operation[]): void {
114
+ protected override applyPatch(rootSchema: GModelRootSchema, patch: jsonPatch.Operation[]): MaybePromise<void> {
115
115
  super.applyPatch(rootSchema, patch);
116
116
  const newRoot = this.serializer.createRoot(rootSchema);
117
117
  this.modelState.updateRoot(newRoot);
@@ -39,17 +39,17 @@ export class UndoRedoActionHandler implements ActionHandler {
39
39
  return [];
40
40
  }
41
41
 
42
- protected undo(): MaybePromise<Action[]> {
42
+ protected async undo(): Promise<Action[]> {
43
43
  if (this.commandStack.canUndo()) {
44
- this.commandStack.undo();
44
+ await this.commandStack.undo();
45
45
  return this.modelSubmissionHandler.submitModel('undo');
46
46
  }
47
47
  return [];
48
48
  }
49
49
 
50
- protected redo(): MaybePromise<Action[]> {
50
+ protected async redo(): Promise<Action[]> {
51
51
  if (this.commandStack.canRedo()) {
52
- this.commandStack.redo();
52
+ await this.commandStack.redo();
53
53
  return this.modelSubmissionHandler.submitModel('redo');
54
54
  }
55
55
  return [];
@@ -17,7 +17,7 @@ import { GModelRoot } from '@eclipse-glsp/graph';
17
17
  import { Action, ComputedBoundsAction, MaybePromise } from '@eclipse-glsp/protocol';
18
18
  import { inject, injectable } from 'inversify';
19
19
  import { ActionHandler } from '../../actions/action-handler';
20
- import { applyAlignment, applyBounds, applyRoute } from '../../utils/layout-util';
20
+ import { applyAlignment, applyElementAndBounds, applyRoute } from '../../utils/layout-util';
21
21
  import { ModelState } from '../model/model-state';
22
22
  import { ModelSubmissionHandler } from '../model/model-submission-handler';
23
23
 
@@ -47,7 +47,7 @@ export class ComputedBoundsActionHandler implements ActionHandler {
47
47
 
48
48
  protected applyBounds(root: GModelRoot, action: ComputedBoundsAction): void {
49
49
  const index = this.modelState.index;
50
- action.bounds.forEach(bounds => applyBounds(bounds, index));
50
+ action.bounds.forEach(bounds => applyElementAndBounds(bounds, index));
51
51
  (action.alignments ?? []).forEach(alignment => applyAlignment(alignment, index));
52
52
  (action.routes ?? []).forEach(route => applyRoute(route, index));
53
53
  }
@@ -23,6 +23,8 @@ export * from './actions/client-action-handler';
23
23
  export * from './actions/global-action-provider';
24
24
  export * from './command/command';
25
25
  export * from './command/command-stack';
26
+ export * from './command/recording-command';
27
+ export * from './command/undo-redo-action-handler';
26
28
  export * from './di/binding-target';
27
29
  export * from './di/client-session-module';
28
30
  export * from './di/diagram-module';
@@ -65,7 +67,6 @@ export * from './features/popup/popup-model-factory';
65
67
  export * from './features/popup/request-popup-model-action-handler';
66
68
  export * from './features/validation/model-validator';
67
69
  export * from './features/validation/request-markers-handler';
68
- export * from './gmodel/cut-operation-handler';
69
70
  export * from './gmodel/index';
70
71
  export * from './launch/glsp-server-launcher';
71
72
  export * from './operations/compound-operation-handler';
@@ -84,6 +85,7 @@ export * from './session/client-session-manager';
84
85
  export * from './utils/args-util';
85
86
  export * from './utils/client-options-util';
86
87
  export * from './utils/glsp-server-error';
88
+ export * from './utils/layout-util';
87
89
  export * from './utils/logger';
88
90
  export * from './utils/promise-queue';
89
91
  export * from './utils/registry';