@hydranium/glsp-server 1.0.0-next.317 → 1.0.0-next.319

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 (46) hide show
  1. package/lib/command/hydranium-glsp-command-stack.d.ts +13 -2
  2. package/lib/command/hydranium-glsp-command-stack.d.ts.map +1 -1
  3. package/lib/command/hydranium-glsp-command-stack.js +49 -2
  4. package/lib/command/hydranium-glsp-command-stack.js.map +1 -1
  5. package/lib/command/hydranium-glsp-operation-command.d.ts +21 -2
  6. package/lib/command/hydranium-glsp-operation-command.d.ts.map +1 -1
  7. package/lib/command/hydranium-glsp-operation-command.js +29 -3
  8. package/lib/command/hydranium-glsp-operation-command.js.map +1 -1
  9. package/lib/command/hydranium-glsp-recording-command.d.ts +7 -0
  10. package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
  11. package/lib/command/hydranium-glsp-recording-command.js +12 -1
  12. package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
  13. package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts +58 -1
  14. package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts.map +1 -1
  15. package/lib/command/hydranium-glsp-undo-redo-action-handler.js +116 -1
  16. package/lib/command/hydranium-glsp-undo-redo-action-handler.js.map +1 -1
  17. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts +11 -1
  18. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts.map +1 -1
  19. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js +22 -3
  20. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js.map +1 -1
  21. package/lib/messages/index.d.ts +3 -0
  22. package/lib/messages/index.d.ts.map +1 -1
  23. package/lib/messages/index.js +3 -0
  24. package/lib/messages/index.js.map +1 -1
  25. package/lib/state/abstract-hydranium-glsp-state.d.ts +12 -1
  26. package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
  27. package/lib/state/abstract-hydranium-glsp-state.js +17 -1
  28. package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
  29. package/lib/status/diagram-status-reporter.d.ts +23 -3
  30. package/lib/status/diagram-status-reporter.d.ts.map +1 -1
  31. package/lib/status/diagram-status-reporter.js +28 -2
  32. package/lib/status/diagram-status-reporter.js.map +1 -1
  33. package/lib/submission/hydranium-glsp-submission-handler.d.ts +12 -1
  34. package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -1
  35. package/lib/submission/hydranium-glsp-submission-handler.js +30 -4
  36. package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -1
  37. package/package.json +7 -7
  38. package/src/command/hydranium-glsp-command-stack.ts +52 -2
  39. package/src/command/hydranium-glsp-operation-command.ts +42 -3
  40. package/src/command/hydranium-glsp-recording-command.ts +14 -1
  41. package/src/command/hydranium-glsp-undo-redo-action-handler.ts +146 -1
  42. package/src/computed-bounds/hydranium-glsp-computed-bounds-action-handler.ts +21 -3
  43. package/src/messages/index.ts +12 -0
  44. package/src/state/abstract-hydranium-glsp-state.ts +19 -1
  45. package/src/status/diagram-status-reporter.ts +37 -4
  46. package/src/submission/hydranium-glsp-submission-handler.ts +26 -5
@@ -9,6 +9,7 @@
9
9
 
10
10
  import {
11
11
  type Action,
12
+ ClientSessionManager,
12
13
  type DirtyStateChangeReason,
13
14
  type GModelRootSchema,
14
15
  type LayoutOperation,
@@ -59,6 +60,7 @@ import { DiagramStatus } from '../state/diagram-status.js';
59
60
  @injectable()
60
61
  export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel = string> extends ModelSubmissionHandler {
61
62
  @inject(ModelState) declare protected modelState: AbstractHydraniumGlspState<TRoot, TSourceModel>;
63
+ @inject(ClientSessionManager) protected readonly sessionManager!: ClientSessionManager;
62
64
 
63
65
  /**
64
66
  * Document-state gate awaited before {@link submitModel} delegates to
@@ -176,16 +178,26 @@ export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel
176
178
  * Never rejects: GLSP runs it from a debounce that drops the result, so a
177
179
  * failure here would go unhandled. A validator that throws is logged as an
178
180
  * error, markers that cannot be sent as a warning.
181
+ *
182
+ * GLSP does not cancel that debounce when the session ends, so it also runs
183
+ * for a diagram just closed: that run is skipped, and markers it could not
184
+ * send because the session ended meanwhile are logged for diagnosis only.
179
185
  */
180
186
  protected override async performLiveValidation(validator: ModelValidator): Promise<void> {
187
+ if (this.sessionEnded()) {
188
+ return;
189
+ }
181
190
  this.modelState.setStatus(DiagramStatus.VALIDATION, { message: 'Validate Model...', severity: 'INFO' });
182
191
  try {
183
192
  const markers = await validator.validate([this.modelState.root], MarkersReason.LIVE);
184
- await this.actionDispatcher
185
- .dispatch(SetMarkersAction.create(markers, { reason: MarkersReason.LIVE }))
186
- .catch((error: unknown) =>
187
- this.modelState.logger.warn(`Could not send the live-validation markers: ${describeErrorWithStack(error)}`)
188
- );
193
+ await this.actionDispatcher.dispatch(SetMarkersAction.create(markers, { reason: MarkersReason.LIVE })).catch((error: unknown) => {
194
+ const message = `Could not send the live-validation markers: ${describeErrorWithStack(error)}`;
195
+ if (this.sessionEnded()) {
196
+ this.modelState.logger.debug(message);
197
+ } else {
198
+ this.modelState.logger.warn(message);
199
+ }
200
+ });
189
201
  } catch (error: unknown) {
190
202
  this.modelState.logger.error(`Live validation failed: ${describeErrorWithStack(error)}`);
191
203
  } finally {
@@ -193,6 +205,15 @@ export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel
193
205
  }
194
206
  }
195
207
 
208
+ /**
209
+ * Whether the client session this handler serves has ended. By its
210
+ * dispatcher rather than its id: a client that reopens a diagram under the
211
+ * same id gets a new session, which this handler does not serve.
212
+ */
213
+ protected sessionEnded(): boolean {
214
+ return this.sessionManager.getSession(this.modelState.clientId)?.actionDispatcher !== this.actionDispatcher;
215
+ }
216
+
196
217
  /**
197
218
  * Serialise the model-bearing actions of a submission into a comparable
198
219
  * signature.