@hydranium/glsp-server 1.0.0-next.29 → 1.0.0-next.299

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 (217) hide show
  1. package/README.md +78 -88
  2. package/lib/browser/start-glsp-server-in-worker.d.ts +43 -42
  3. package/lib/browser/start-glsp-server-in-worker.d.ts.map +1 -1
  4. package/lib/browser/start-glsp-server-in-worker.js +62 -13
  5. package/lib/browser/start-glsp-server-in-worker.js.map +1 -1
  6. package/lib/command/diagram-edit-dropped-error.d.ts +31 -0
  7. package/lib/command/diagram-edit-dropped-error.d.ts.map +1 -0
  8. package/lib/command/diagram-edit-dropped-error.js +48 -0
  9. package/lib/command/diagram-edit-dropped-error.js.map +1 -0
  10. package/lib/command/hydranium-glsp-command-stack.d.ts +33 -0
  11. package/lib/command/hydranium-glsp-command-stack.d.ts.map +1 -0
  12. package/lib/command/hydranium-glsp-command-stack.js +63 -0
  13. package/lib/command/hydranium-glsp-command-stack.js.map +1 -0
  14. package/lib/command/hydranium-glsp-operation-action-handler.d.ts +64 -0
  15. package/lib/command/hydranium-glsp-operation-action-handler.d.ts.map +1 -0
  16. package/lib/command/hydranium-glsp-operation-action-handler.js +142 -0
  17. package/lib/command/hydranium-glsp-operation-action-handler.js.map +1 -0
  18. package/lib/command/hydranium-glsp-operation-command.d.ts +250 -0
  19. package/lib/command/hydranium-glsp-operation-command.d.ts.map +1 -0
  20. package/lib/command/hydranium-glsp-operation-command.js +491 -0
  21. package/lib/command/hydranium-glsp-operation-command.js.map +1 -0
  22. package/lib/command/hydranium-glsp-recording-command.d.ts +26 -87
  23. package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
  24. package/lib/command/hydranium-glsp-recording-command.js +40 -117
  25. package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
  26. package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts +23 -0
  27. package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts.map +1 -0
  28. package/lib/command/hydranium-glsp-undo-redo-action-handler.js +41 -0
  29. package/lib/command/hydranium-glsp-undo-redo-action-handler.js.map +1 -0
  30. package/lib/command/index.d.ts +5 -0
  31. package/lib/command/index.d.ts.map +1 -1
  32. package/lib/command/index.js +5 -0
  33. package/lib/command/index.js.map +1 -1
  34. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts +1 -1
  35. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts.map +1 -1
  36. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js +2 -2
  37. package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js.map +1 -1
  38. package/lib/dispatcher/server-action-dispatcher.d.ts +25 -24
  39. package/lib/dispatcher/server-action-dispatcher.d.ts.map +1 -1
  40. package/lib/dispatcher/server-action-dispatcher.js +38 -26
  41. package/lib/dispatcher/server-action-dispatcher.js.map +1 -1
  42. package/lib/index.d.ts +1 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +1 -0
  45. package/lib/index.js.map +1 -1
  46. package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts +35 -59
  47. package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts.map +1 -1
  48. package/lib/launcher/abstract-hydranium-glsp-diagram-module.js +60 -71
  49. package/lib/launcher/abstract-hydranium-glsp-diagram-module.js.map +1 -1
  50. package/lib/launcher/drop-notifications-to-gone-client.d.ts +23 -0
  51. package/lib/launcher/drop-notifications-to-gone-client.d.ts.map +1 -0
  52. package/lib/launcher/drop-notifications-to-gone-client.js +43 -0
  53. package/lib/launcher/drop-notifications-to-gone-client.js.map +1 -0
  54. package/lib/launcher/glsp-app-module.d.ts +1 -2
  55. package/lib/launcher/glsp-app-module.d.ts.map +1 -1
  56. package/lib/launcher/glsp-app-module.js.map +1 -1
  57. package/lib/launcher/glsp-connection-logger.d.ts +19 -0
  58. package/lib/launcher/glsp-connection-logger.d.ts.map +1 -0
  59. package/lib/launcher/glsp-connection-logger.js +24 -0
  60. package/lib/launcher/glsp-connection-logger.js.map +1 -0
  61. package/lib/launcher/glsp-server-overrides.d.ts +10 -8
  62. package/lib/launcher/glsp-server-overrides.d.ts.map +1 -1
  63. package/lib/launcher/glsp-server-overrides.js +25 -11
  64. package/lib/launcher/glsp-server-overrides.js.map +1 -1
  65. package/lib/launcher/hydranium-glsp-server.d.ts +60 -15
  66. package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -1
  67. package/lib/launcher/hydranium-glsp-server.js +145 -22
  68. package/lib/launcher/hydranium-glsp-server.js.map +1 -1
  69. package/lib/launcher/index.d.ts +2 -0
  70. package/lib/launcher/index.d.ts.map +1 -1
  71. package/lib/launcher/index.js +5 -4
  72. package/lib/launcher/index.js.map +1 -1
  73. package/lib/logging/glsp-client-logger.d.ts +10 -6
  74. package/lib/logging/glsp-client-logger.d.ts.map +1 -1
  75. package/lib/logging/glsp-client-logger.js +14 -7
  76. package/lib/logging/glsp-client-logger.js.map +1 -1
  77. package/lib/messages/index.d.ts +11 -6
  78. package/lib/messages/index.d.ts.map +1 -1
  79. package/lib/messages/index.js +11 -6
  80. package/lib/messages/index.js.map +1 -1
  81. package/lib/node/start-glsp-server.d.ts +30 -8
  82. package/lib/node/start-glsp-server.d.ts.map +1 -1
  83. package/lib/node/start-glsp-server.js +49 -10
  84. package/lib/node/start-glsp-server.js.map +1 -1
  85. package/lib/state/abstract-hydranium-glsp-state.d.ts +326 -102
  86. package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
  87. package/lib/state/abstract-hydranium-glsp-state.js +529 -139
  88. package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
  89. package/lib/state/diagram-status.d.ts +38 -0
  90. package/lib/state/diagram-status.d.ts.map +1 -0
  91. package/lib/state/diagram-status.js +27 -0
  92. package/lib/state/diagram-status.js.map +1 -0
  93. package/lib/state/full-text-hydranium-glsp-state.d.ts +22 -9
  94. package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
  95. package/lib/state/full-text-hydranium-glsp-state.js +45 -18
  96. package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
  97. package/lib/state/hydranium-glsp-index.d.ts +40 -29
  98. package/lib/state/hydranium-glsp-index.d.ts.map +1 -1
  99. package/lib/state/hydranium-glsp-index.js +82 -45
  100. package/lib/state/hydranium-glsp-index.js.map +1 -1
  101. package/lib/state/hydranium-shared-core-services.d.ts +16 -29
  102. package/lib/state/hydranium-shared-core-services.d.ts.map +1 -1
  103. package/lib/state/hydranium-shared-core-services.js +15 -28
  104. package/lib/state/hydranium-shared-core-services.js.map +1 -1
  105. package/lib/state/index.d.ts +1 -0
  106. package/lib/state/index.d.ts.map +1 -1
  107. package/lib/state/index.js +1 -0
  108. package/lib/state/index.js.map +1 -1
  109. package/lib/state/model-ready-timeout-error.d.ts.map +1 -1
  110. package/lib/state/model-ready-timeout-error.js.map +1 -1
  111. package/lib/state/reconcile-source-model-write.d.ts +13 -27
  112. package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
  113. package/lib/state/reconcile-source-model-write.js +44 -32
  114. package/lib/state/reconcile-source-model-write.js.map +1 -1
  115. package/lib/state/reconciling-multi-document-glsp-state.d.ts +125 -69
  116. package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
  117. package/lib/state/reconciling-multi-document-glsp-state.js +242 -100
  118. package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
  119. package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +36 -28
  120. package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
  121. package/lib/state/reconciling-transfer-hydranium-glsp-state.js +59 -42
  122. package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
  123. package/lib/status/diagram-status-reporter.d.ts +44 -0
  124. package/lib/status/diagram-status-reporter.d.ts.map +1 -0
  125. package/lib/status/diagram-status-reporter.js +88 -0
  126. package/lib/status/diagram-status-reporter.js.map +1 -0
  127. package/lib/status/hydranium-glsp-request-model-action-handler.d.ts +27 -0
  128. package/lib/status/hydranium-glsp-request-model-action-handler.d.ts.map +1 -0
  129. package/lib/status/hydranium-glsp-request-model-action-handler.js +52 -0
  130. package/lib/status/hydranium-glsp-request-model-action-handler.js.map +1 -0
  131. package/lib/status/hydranium-glsp-set-edit-mode-action-handler.d.ts +27 -0
  132. package/lib/status/hydranium-glsp-set-edit-mode-action-handler.d.ts.map +1 -0
  133. package/lib/status/hydranium-glsp-set-edit-mode-action-handler.js +53 -0
  134. package/lib/status/hydranium-glsp-set-edit-mode-action-handler.js.map +1 -0
  135. package/lib/status/index.d.ts +12 -0
  136. package/lib/status/index.d.ts.map +1 -0
  137. package/lib/status/index.js +12 -0
  138. package/lib/status/index.js.map +1 -0
  139. package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts +30 -0
  140. package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts.map +1 -0
  141. package/lib/storage/hydranium-glsp-request-save-model-action-handler.js +47 -0
  142. package/lib/storage/hydranium-glsp-request-save-model-action-handler.js.map +1 -0
  143. package/lib/storage/hydranium-glsp-storage.d.ts +324 -143
  144. package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
  145. package/lib/storage/hydranium-glsp-storage.js +569 -213
  146. package/lib/storage/hydranium-glsp-storage.js.map +1 -1
  147. package/lib/storage/index.d.ts +2 -1
  148. package/lib/storage/index.d.ts.map +1 -1
  149. package/lib/storage/index.js +2 -1
  150. package/lib/storage/index.js.map +1 -1
  151. package/lib/storage/save-delivery-policy.d.ts +51 -0
  152. package/lib/storage/save-delivery-policy.d.ts.map +1 -0
  153. package/lib/storage/{save-conflict-policy.js → save-delivery-policy.js} +7 -8
  154. package/lib/storage/save-delivery-policy.js.map +1 -0
  155. package/lib/submission/hydranium-glsp-submission-handler.d.ts +44 -4
  156. package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -1
  157. package/lib/submission/hydranium-glsp-submission-handler.js +82 -6
  158. package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -1
  159. package/lib/testing/glsp-harness.d.ts +34 -7
  160. package/lib/testing/glsp-harness.d.ts.map +1 -1
  161. package/lib/testing/glsp-harness.js +47 -19
  162. package/lib/testing/glsp-harness.js.map +1 -1
  163. package/lib/validation/diagnostic-markers.d.ts +3 -3
  164. package/lib/validation/diagnostic-markers.d.ts.map +1 -1
  165. package/lib/validation/diagnostic-markers.js +1 -1
  166. package/lib/validation/diagnostic-markers.js.map +1 -1
  167. package/lib/validation/hydranium-glsp-model-validator.d.ts +1 -2
  168. package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -1
  169. package/lib/validation/hydranium-glsp-model-validator.js +1 -1
  170. package/lib/validation/hydranium-glsp-model-validator.js.map +1 -1
  171. package/package.json +31 -52
  172. package/src/browser/start-glsp-server-in-worker.ts +79 -51
  173. package/src/command/diagram-edit-dropped-error.ts +51 -0
  174. package/src/command/hydranium-glsp-command-stack.ts +47 -0
  175. package/src/command/hydranium-glsp-operation-action-handler.ts +141 -0
  176. package/src/command/hydranium-glsp-operation-command.ts +602 -0
  177. package/src/command/hydranium-glsp-recording-command.ts +40 -121
  178. package/src/command/hydranium-glsp-undo-redo-action-handler.ts +29 -0
  179. package/src/command/index.ts +10 -0
  180. package/src/computed-bounds/hydranium-glsp-computed-bounds-action-handler.ts +2 -2
  181. package/src/dispatcher/server-action-dispatcher.ts +39 -31
  182. package/src/index.ts +1 -0
  183. package/src/launcher/abstract-hydranium-glsp-diagram-module.ts +79 -91
  184. package/src/launcher/drop-notifications-to-gone-client.ts +47 -0
  185. package/src/launcher/glsp-app-module.ts +1 -2
  186. package/src/launcher/glsp-connection-logger.ts +27 -0
  187. package/src/launcher/glsp-server-overrides.ts +27 -11
  188. package/src/launcher/hydranium-glsp-server.ts +153 -23
  189. package/src/launcher/index.ts +5 -4
  190. package/src/logging/glsp-client-logger.ts +16 -9
  191. package/src/messages/index.ts +16 -6
  192. package/src/node/start-glsp-server.ts +60 -14
  193. package/src/state/abstract-hydranium-glsp-state.ts +609 -154
  194. package/src/state/diagram-status.ts +41 -0
  195. package/src/state/full-text-hydranium-glsp-state.ts +46 -18
  196. package/src/state/hydranium-glsp-index.ts +85 -41
  197. package/src/state/hydranium-shared-core-services.ts +16 -29
  198. package/src/state/index.ts +1 -0
  199. package/src/state/reconcile-source-model-write.ts +51 -53
  200. package/src/state/reconciling-multi-document-glsp-state.ts +276 -102
  201. package/src/state/reconciling-transfer-hydranium-glsp-state.ts +67 -45
  202. package/src/status/diagram-status-reporter.ts +106 -0
  203. package/src/status/hydranium-glsp-request-model-action-handler.ts +43 -0
  204. package/src/status/hydranium-glsp-set-edit-mode-action-handler.ts +38 -0
  205. package/src/status/index.ts +12 -0
  206. package/src/storage/hydranium-glsp-request-save-model-action-handler.ts +40 -0
  207. package/src/storage/hydranium-glsp-storage.ts +647 -223
  208. package/src/storage/index.ts +2 -1
  209. package/src/storage/save-delivery-policy.ts +49 -0
  210. package/src/submission/hydranium-glsp-submission-handler.ts +91 -5
  211. package/src/testing/glsp-harness.ts +67 -25
  212. package/src/validation/diagnostic-markers.ts +3 -3
  213. package/src/validation/hydranium-glsp-model-validator.ts +4 -5
  214. package/lib/storage/save-conflict-policy.d.ts +0 -56
  215. package/lib/storage/save-conflict-policy.d.ts.map +0 -1
  216. package/lib/storage/save-conflict-policy.js.map +0 -1
  217. package/src/storage/save-conflict-policy.ts +0 -52
@@ -0,0 +1,63 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
+ 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;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ };
15
+ var __metadata = (this && this.__metadata) || function (k, v) {
16
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
+ };
18
+ import { DefaultCommandStack, ModelState } from '@eclipse-glsp/server';
19
+ import { inject, injectable } from 'inversify';
20
+ import { HydraniumTypes } from '../state/hydranium-shared-core-services.js';
21
+ /**
22
+ * GLSP's command stack with the diagram's dirty state read from the text store:
23
+ * dirty while any document the diagram's client session has open differs from
24
+ * its file, as the store last knew the file. Undo and redo are GLSP's.
25
+ *
26
+ * GLSP's own answer counts the diagram's commands since its last save, so it
27
+ * misses every change the diagram did not make: another client's unsaved edit
28
+ * leaves it clean, and a save it did not make of a document other than the
29
+ * diagram's own leaves it dirty. Every `SetDirtyStateAction` GLSP sends reads
30
+ * this answer.
31
+ */
32
+ let HydraniumGlspCommandStack = class HydraniumGlspCommandStack extends DefaultCommandStack {
33
+ modelState;
34
+ sharedServices;
35
+ get isDirty() {
36
+ const textDocuments = this.sharedServices.workspace.TextDocuments;
37
+ const clientId = this.modelState.clientId;
38
+ return textDocuments.openDocuments().some(open => open.clients.includes(clientId) && textDocuments.isDirty(open.uri));
39
+ }
40
+ /**
41
+ * Lifted from `@eclipse-glsp/server` 2.7.0's `DefaultCommandStack.handleError`
42
+ * without its `error` line: the failure is rethrown, and whoever ends it
43
+ * logs it. The accompanying test pins upstream's source.
44
+ */
45
+ handleError(error) {
46
+ this.flush();
47
+ this.logger.debug('A command failed; the command stack was flushed');
48
+ throw error;
49
+ }
50
+ };
51
+ __decorate([
52
+ inject(ModelState),
53
+ __metadata("design:type", Object)
54
+ ], HydraniumGlspCommandStack.prototype, "modelState", void 0);
55
+ __decorate([
56
+ inject(HydraniumTypes.SharedCoreServices),
57
+ __metadata("design:type", Object)
58
+ ], HydraniumGlspCommandStack.prototype, "sharedServices", void 0);
59
+ HydraniumGlspCommandStack = __decorate([
60
+ injectable()
61
+ ], HydraniumGlspCommandStack);
62
+ export { HydraniumGlspCommandStack };
63
+ //# sourceMappingURL=hydranium-glsp-command-stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydranium-glsp-command-stack.js","sourceRoot":"","sources":["../../src/command/hydranium-glsp-command-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;AAElF,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E;;;;;;;;;;GAUG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,mBAAmB;IACxB,UAAU,CAAc;IACD,cAAc,CAAwB;IAEpG,IAAa,OAAO;QACjB,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,aAAa,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1C,OAAO,aAAa,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzH,CAAC;IAED;;;;OAIG;IACgB,WAAW,CAAC,KAAc;QAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,MAAM,KAAK,CAAC;IACf,CAAC;CACH,CAAA;AAnByC;IAAtC,MAAM,CAAC,UAAU,CAAC;;6DAA4C;AACD;IAA7D,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC;;iEAA0D;AAF1F,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAoBrC"}
@@ -0,0 +1,64 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type Action, ActionDispatcher, type AnyObject, GLSPClientProxy, Logger, type Operation, OperationActionHandler, type OperationHandler } from '@eclipse-glsp/server';
10
+ import { type HydraniumGlspRecordingState } from './hydranium-glsp-recording-command.js';
11
+ /**
12
+ * GLSP's operation action handler, running each operation as a
13
+ * {@link HydraniumGlspOperationCommand} inside the state's `runExclusive`,
14
+ * which covers the operation, its write, the command-stack push and the
15
+ * submit, so neither another operation, an undo nor the storage's capture
16
+ * lands between them.
17
+ *
18
+ * An operation dispatched while another is open, as a handler's plain
19
+ * `dispatch` does, is queued behind it and its dispatch resolves at once;
20
+ * awaited inside the open operation, it would wait for the operation awaiting
21
+ * it. It writes, pushes and submits on its own, and a failure is reported to
22
+ * the client as GLSP reports a failed client action.
23
+ *
24
+ * Only operations are queued that way, and only while one is open, its undo's
25
+ * side effects included. Code running inside the boundary otherwise must not
26
+ * dispatch an operation and await it: a GModel factory or a submit after an
27
+ * operation, an undo's write and submit, the storage's render. Nor may any code
28
+ * inside the boundary await a dispatched undo, redo or model request, which
29
+ * take the boundary themselves. Each waits for the section awaiting it.
30
+ */
31
+ export declare class HydraniumGlspOperationActionHandler extends OperationActionHandler {
32
+ protected modelState: HydraniumGlspRecordingState<AnyObject>;
33
+ protected readonly actionDispatcher: ActionDispatcher;
34
+ protected readonly logger: Logger;
35
+ protected readonly clientProxy: GLSPClientProxy;
36
+ protected executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]>;
37
+ /**
38
+ * Run `operation`; push it when its command was written, and submit the
39
+ * model when it executed one, written or dropped.
40
+ */
41
+ protected runOperation(operation: Operation, handler: OperationHandler): Promise<Action[]>;
42
+ /**
43
+ * Deliver what a queued operation answered: a message straight to the
44
+ * client, as {@link reportFailure} sends one, the rest through the
45
+ * dispatcher. A failure to deliver is logged, not reported as the
46
+ * operation's.
47
+ */
48
+ protected deliverQueued(actions: Action[]): void;
49
+ /**
50
+ * Log `error` with {@link logActionFailure}, as the server logs a failed
51
+ * action, and send the client the error message GLSP sends for one. A
52
+ * queued operation that fails once its diagram has closed, which the
53
+ * storage's dispose marks by clearing the state's session, is logged at
54
+ * `debug` and told to no client, as the server treats an ended session.
55
+ */
56
+ protected reportFailure(operation: Operation, error: unknown): void;
57
+ /**
58
+ * Send `action` straight to the client, as GLSP's server sends a failed
59
+ * action's message. Sent through the dispatcher instead, an action of a
60
+ * kind the client registered no handler for is rejected.
61
+ */
62
+ protected sendToClient(action: Action): void;
63
+ }
64
+ //# sourceMappingURL=hydranium-glsp-operation-action-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydranium-glsp-operation-action-handler.d.ts","sourceRoot":"","sources":["../../src/command/hydranium-glsp-operation-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,MAAM,EACX,gBAAgB,EAChB,KAAK,SAAS,EACd,eAAe,EAEf,MAAM,EAEN,KAAK,SAAS,EACd,sBAAsB,EACtB,KAAK,gBAAgB,EACvB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,mCAAoC,SAAQ,sBAAsB;IAC5E,UAAkB,UAAU,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC3C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAG,gBAAgB,CAAC;IACjE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAG,eAAe,CAAC;IAE1E,UAAmB,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAWpG;IAED;;;OAGG;IACH,UAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgB/F;IAED;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAQ/C;IAED;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAclE;IAED;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAM3C;CACH"}
@@ -0,0 +1,142 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
+ 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;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ };
15
+ var __metadata = (this && this.__metadata) || function (k, v) {
16
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
+ };
18
+ import { ActionDispatcher, GLSPClientProxy, GLSPServerError, Logger, MessageAction, OperationActionHandler } from '@eclipse-glsp/server';
19
+ import { describeErrorWithStack } from '@hydranium/protocol';
20
+ import { inject, injectable } from 'inversify';
21
+ import { logActionFailure } from './diagram-edit-dropped-error.js';
22
+ import { HydraniumGlspOperationCommand, openOperationOf, runOperation } from './hydranium-glsp-operation-command.js';
23
+ /**
24
+ * GLSP's operation action handler, running each operation as a
25
+ * {@link HydraniumGlspOperationCommand} inside the state's `runExclusive`,
26
+ * which covers the operation, its write, the command-stack push and the
27
+ * submit, so neither another operation, an undo nor the storage's capture
28
+ * lands between them.
29
+ *
30
+ * An operation dispatched while another is open, as a handler's plain
31
+ * `dispatch` does, is queued behind it and its dispatch resolves at once;
32
+ * awaited inside the open operation, it would wait for the operation awaiting
33
+ * it. It writes, pushes and submits on its own, and a failure is reported to
34
+ * the client as GLSP reports a failed client action.
35
+ *
36
+ * Only operations are queued that way, and only while one is open, its undo's
37
+ * side effects included. Code running inside the boundary otherwise must not
38
+ * dispatch an operation and await it: a GModel factory or a submit after an
39
+ * operation, an undo's write and submit, the storage's render. Nor may any code
40
+ * inside the boundary await a dispatched undo, redo or model request, which
41
+ * take the boundary themselves. Each waits for the section awaiting it.
42
+ */
43
+ let HydraniumGlspOperationActionHandler = class HydraniumGlspOperationActionHandler extends OperationActionHandler {
44
+ actionDispatcher;
45
+ logger;
46
+ clientProxy;
47
+ executeHandler(operation, handler) {
48
+ const queued = openOperationOf(this.modelState) !== undefined;
49
+ const run = this.modelState.runExclusive(() => this.runOperation(operation, handler));
50
+ if (!queued) {
51
+ return run;
52
+ }
53
+ run.then(actions => this.deliverQueued(actions), (error) => this.reportFailure(operation, error));
54
+ return Promise.resolve([]);
55
+ }
56
+ /**
57
+ * Run `operation`; push it when its command was written, and submit the
58
+ * model when it executed one, written or dropped.
59
+ */
60
+ async runOperation(operation, handler) {
61
+ // A queued operation can find the diagram read-only by the time it runs.
62
+ if (this.modelState.isReadonly) {
63
+ return [
64
+ MessageAction.create(`Server is in readonly-mode! Could not execute operation: ${operation.kind}`, { severity: 'WARNING' })
65
+ ];
66
+ }
67
+ const command = new HydraniumGlspOperationCommand(this.modelState);
68
+ const outcome = await runOperation(command, () => handler.execute(operation));
69
+ if (outcome === 'none') {
70
+ return [];
71
+ }
72
+ if (outcome === 'executed') {
73
+ await this.executeCommand(command);
74
+ }
75
+ return this.submitModel();
76
+ }
77
+ /**
78
+ * Deliver what a queued operation answered: a message straight to the
79
+ * client, as {@link reportFailure} sends one, the rest through the
80
+ * dispatcher. A failure to deliver is logged, not reported as the
81
+ * operation's.
82
+ */
83
+ deliverQueued(actions) {
84
+ const messages = actions.filter(action => MessageAction.is(action));
85
+ messages.forEach(message => this.sendToClient(message));
86
+ this.actionDispatcher
87
+ .dispatchAll(actions.filter(action => !MessageAction.is(action)))
88
+ .catch((error) => this.logger.warn(`Could not deliver the result of a queued operation: ${describeErrorWithStack(error)}`));
89
+ }
90
+ /**
91
+ * Log `error` with {@link logActionFailure}, as the server logs a failed
92
+ * action, and send the client the error message GLSP sends for one. A
93
+ * queued operation that fails once its diagram has closed, which the
94
+ * storage's dispose marks by clearing the state's session, is logged at
95
+ * `debug` and told to no client, as the server treats an ended session.
96
+ */
97
+ reportFailure(operation, error) {
98
+ // Queued only after a load registered the session, so none now means the diagram has closed.
99
+ if (this.modelState.modelSession === undefined) {
100
+ this.logger.debug(`Operation '${operation.kind}' ended with its diagram: ${describeErrorWithStack(error)}`);
101
+ return;
102
+ }
103
+ logActionFailure(this.logger, operation, error);
104
+ let message = `Could not process action: '${operation.kind}`;
105
+ let details = error instanceof Error ? error.toString() : String(error);
106
+ if (error instanceof GLSPServerError) {
107
+ details = String(error.cause);
108
+ message = error.message;
109
+ }
110
+ this.sendToClient(MessageAction.create(message, { severity: 'ERROR', details }));
111
+ }
112
+ /**
113
+ * Send `action` straight to the client, as GLSP's server sends a failed
114
+ * action's message. Sent through the dispatcher instead, an action of a
115
+ * kind the client registered no handler for is rejected.
116
+ */
117
+ sendToClient(action) {
118
+ try {
119
+ this.clientProxy.process({ clientId: this.modelState.clientId, action });
120
+ }
121
+ catch (error) {
122
+ this.logger.warn(`Could not send '${action.kind}' to the client: ${describeErrorWithStack(error)}`);
123
+ }
124
+ }
125
+ };
126
+ __decorate([
127
+ inject(ActionDispatcher),
128
+ __metadata("design:type", Object)
129
+ ], HydraniumGlspOperationActionHandler.prototype, "actionDispatcher", void 0);
130
+ __decorate([
131
+ inject(Logger),
132
+ __metadata("design:type", Logger)
133
+ ], HydraniumGlspOperationActionHandler.prototype, "logger", void 0);
134
+ __decorate([
135
+ inject(GLSPClientProxy),
136
+ __metadata("design:type", Object)
137
+ ], HydraniumGlspOperationActionHandler.prototype, "clientProxy", void 0);
138
+ HydraniumGlspOperationActionHandler = __decorate([
139
+ injectable()
140
+ ], HydraniumGlspOperationActionHandler);
141
+ export { HydraniumGlspOperationActionHandler };
142
+ //# sourceMappingURL=hydranium-glsp-operation-action-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydranium-glsp-operation-action-handler.js","sourceRoot":"","sources":["../../src/command/hydranium-glsp-operation-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;AAElF,OAAO,EAEJ,gBAAgB,EAEhB,eAAe,EACf,eAAe,EACf,MAAM,EACN,aAAa,EAEb,sBAAsB,EAExB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAGrH;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,mCAAmC,GAAzC,MAAM,mCAAoC,SAAQ,sBAAsB;IAE/B,gBAAgB,CAAoB;IAC9C,MAAM,CAAU;IACP,WAAW,CAAmB;IAEvD,cAAc,CAAC,SAAoB,E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AAK,CAAC,CAAC;YAC9B,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;IAED;;;;OAIG;IACO,YAAY,CAAC,MAAc;QAClC,IAAI,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,IAAI,oBAAoB,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvG,CAAC;IACJ,CAAC;CACH,CAAA;AA1F+C;IAA5C,MAAM,CAAC,gBAAgB,CAAC;;6EAAwD;AAC9C;IAAlC,MAAM,CAAC,MAAM,CAAC;8BAA6B,MAAM;mEAAC;AACP;IAA3C,MAAM,CAAC,eAAe,CAAC;;wEAAkD;AAJhE,mCAAmC;IAD/C,UAAU,EAAE;GACA,mCAAmC,CA4F/C"}
@@ -0,0 +1,250 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type AnyObject, Command, type MaybePromise } from '@eclipse-glsp/server';
10
+ import { type AstNode, type MultiReference, type Reference } from '@hydranium/langium';
11
+ import { type ModelVersion } from '@hydranium/protocol';
12
+ import { type HydraniumGlspRecordingState } from './hydranium-glsp-recording-command.js';
13
+ /**
14
+ * What becomes of an operation {@link HydraniumGlspOperationCommand} ran: its
15
+ * command written, its write dropped, or no command.
16
+ */
17
+ export type OperationOutcome = 'executed' | 'dropped' | 'none';
18
+ /**
19
+ * One executed side effect the operation undoes and redoes: a recording
20
+ * command's bridge, or a command that does not record.
21
+ */
22
+ export interface OperationSideEffect {
23
+ undo(): MaybePromise<void>;
24
+ redo(): MaybePromise<void>;
25
+ }
26
+ /** The source model an operation changed, before and after it; a redo applies `from → to`, an undo the reverse. */
27
+ export interface OperationTransition<TSourceModel> {
28
+ readonly from: TSourceModel;
29
+ readonly to: TSourceModel;
30
+ }
31
+ /** Whether an undo or a redo of an operation runs. */
32
+ export type UndoRedoDirection = 'undo' | 'redo';
33
+ /**
34
+ * The members of an operation the framework's state, recording command and
35
+ * operation action handler call; reached through {@link openOperationOf} and
36
+ * {@link runOperation}, not through the operation itself.
37
+ */
38
+ export interface OperationInternals {
39
+ run(create: () => MaybePromise<Command | undefined>): Promise<OperationOutcome>;
40
+ workingRootOf(key: string, built: AstNode): AstNode;
41
+ existingWorkingRootOf(key: string): AstNode | undefined;
42
+ workingUriOf(node: AstNode): string | undefined;
43
+ builtNodeOf<T extends AstNode>(node: T): T;
44
+ recordWrittenRoot(root: AstNode): void;
45
+ recordDropped(current: AstNode | undefined): void;
46
+ recordExecuted(step: OperationSideEffect): void;
47
+ assertNotDuringUndoRedo(label: string): void;
48
+ amendBefore(update: (before: AnyObject) => AnyObject): void;
49
+ }
50
+ /**
51
+ * The canonical URI of the document whose working copy `node` belongs to;
52
+ * `undefined` for a node of no copy. A copy has no `$document`, so a lookup
53
+ * that routes by a node's document routes a copy node through this instead.
54
+ */
55
+ export declare function workingUriOfCopy(node: AstNode): string | undefined;
56
+ /** The operation open on `state`, executing, undoing or redoing its side effects; `undefined` between operations. */
57
+ export declare function openOperationOf(state: object): OperationInternals | undefined;
58
+ /** Run `operation` as {@link HydraniumGlspOperationCommand} describes. */
59
+ export declare function runOperation<TSourceModel extends AnyObject>(operation: HydraniumGlspOperationCommand<TSourceModel>, create: () => MaybePromise<Command | undefined>): Promise<OperationOutcome>;
60
+ /**
61
+ * One GLSP operation as a transaction, and the command-stack entry that undoes
62
+ * and redoes it.
63
+ *
64
+ * {@link runOperation} executes the operation's command against copies of the
65
+ * built roots and writes their projection once; a reader of a built root never
66
+ * sees an edit its write has not committed, and an edit the write drops stays
67
+ * out of every built root. Call it inside `runExclusive`: the copies, the write
68
+ * and the capture that follows assume no other operation, undo or storage
69
+ * capture runs meanwhile.
70
+ *
71
+ * The entry holds one model transition, from the copies' projection before the
72
+ * command to their projection after it, both as the documents hold them after
73
+ * a write (see `normalizeTransition`), and the side effects that executed, in
74
+ * order: each command that does not record, a `CompoundCommand`'s children
75
+ * counted one by one, and the bridge of each recording command at any depth.
76
+ * Rollback and undo run them in reverse, redo in order. A recording command
77
+ * executed inside an open operation writes nothing, and its own undo and redo
78
+ * do nothing there.
79
+ */
80
+ export declare class HydraniumGlspOperationCommand<TSourceModel extends AnyObject = AnyObject> implements Command {
81
+ protected readonly modelState: HydraniumGlspRecordingState<TSourceModel>;
82
+ /** Working copies by canonical URI. */
83
+ protected readonly workingRoots: Map<string, AstNode>;
84
+ /** Built node to copy and copy to built node, across every working root, as `AstUtils.copyAstNode` records it. */
85
+ protected readonly trace: Map<AstNode, AstNode>;
86
+ /** The source root captured when the operation opened. */
87
+ protected sourceRootAtOpen?: AstNode;
88
+ /** The version of {@link sourceRootAtOpen}, which the write is gated on. */
89
+ protected baseVersionAtOpen?: ModelVersion;
90
+ /**
91
+ * The primary root to capture when the operation closes: the one its write
92
+ * produced, or the document's built one after a dropped write or one the
93
+ * document already held.
94
+ */
95
+ protected writtenRoot?: AstNode;
96
+ /** Whether the write's reconcile dropped the edit. */
97
+ protected dropped: boolean;
98
+ /** The command the operation executed. */
99
+ protected command?: Command;
100
+ /** The side effects that executed, in execution order. */
101
+ protected readonly steps: OperationSideEffect[];
102
+ /**
103
+ * The copies' projection when the operation opened, amended as documents
104
+ * join or leave the write set during it.
105
+ */
106
+ protected before?: TSourceModel;
107
+ protected transition?: OperationTransition<TSourceModel>;
108
+ /** Whether an undo or redo is running the side effects, on copies it discards. */
109
+ protected undoingOrRedoing: boolean;
110
+ constructor(modelState: HydraniumGlspRecordingState<TSourceModel>);
111
+ /**
112
+ * Open the operation, execute the command `create` makes, write the result
113
+ * once, and close the operation.
114
+ *
115
+ * `create` runs inside the operation, because handlers resolve their
116
+ * targets there. On any failure, `create`, the command or the write, the
117
+ * executed commands' side effects are undone, nothing is written, and the
118
+ * error is rethrown; after a write whose reconcile dropped the edit, the
119
+ * side effects are undone the same way and this answers `'dropped'`. The
120
+ * operation closes either way: the copies are dropped and the source root
121
+ * is captured again, with the base version, every tracked version and the
122
+ * index.
123
+ */
124
+ protected run(create: () => MaybePromise<Command | undefined>): Promise<'executed' | 'dropped' | 'none'>;
125
+ /**
126
+ * Awaited where the operation, or an undo or redo of it, yields to code it
127
+ * does not control: before creating the command, before each side effect
128
+ * executes, is undone or redone, rolls back or is compensated, before
129
+ * projecting the copies, before resolving an undo or redo. Does nothing; a
130
+ * test overrides it to land a foreign edit or a failure there.
131
+ */
132
+ protected checkpoint(_point: 'create' | 'execute' | 'project' | 'resolve' | UndoRedoDirection | 'rollback' | 'compensate'): Promise<void>;
133
+ /**
134
+ * Does nothing: {@link runOperation} executed the command; the command stack
135
+ * calls this when it pushes the entry.
136
+ */
137
+ execute(): Promise<void>;
138
+ undo(): Promise<void>;
139
+ redo(): Promise<void>;
140
+ canUndo(): boolean;
141
+ /** The working copy of `built`, the root of the document whose canonical URI is `key`, made on the first request. */
142
+ protected workingRootOf(key: string, built: AstNode): AstNode;
143
+ /** The canonical URI of the working root `node` belongs to; `undefined` for a node of no copy. */
144
+ protected workingUriOf(node: AstNode): string | undefined;
145
+ /**
146
+ * The built node `node` was copied from; `node` itself for a node of no copy
147
+ * and for a node the operation created.
148
+ */
149
+ protected builtNodeOf<T extends AstNode>(node: T): T;
150
+ /**
151
+ * Copy the source root, and point the index at the copy, so the nodes a
152
+ * handler resolves by id are the nodes it edits.
153
+ */
154
+ protected open(): void;
155
+ /**
156
+ * Drop the copies, move every id added through `indexSemanticElement` from
157
+ * a copy back to the built node it was copied from, and capture the source
158
+ * root again, whether or not the write changed it.
159
+ */
160
+ protected close(): void;
161
+ /**
162
+ * Undo the side effects of the executed commands, newest first, each step
163
+ * on its own: a step that fails is logged and the rest are still undone.
164
+ * The operation's own error is the one thrown.
165
+ */
166
+ protected rollback(): Promise<void>;
167
+ /**
168
+ * Run each of `actions`, each reverting a side effect of its own: a failure
169
+ * is logged as `what` failing and the rest still run, so one step that
170
+ * cannot be reverted leaves no other step applied. The caller reports its
171
+ * own failure, not these.
172
+ */
173
+ protected runEach(actions: ReadonlyArray<() => MaybePromise<void>>, what: string, point: 'rollback' | 'compensate'): Promise<void>;
174
+ /**
175
+ * `command` with every side effect it executes recorded as a step: the
176
+ * command itself, or for a `CompoundCommand` each child, at any depth. A
177
+ * tracked command's own undo and redo do nothing, so a `CompoundCommand`
178
+ * reverting its children when a later one throws leaves that to the steps.
179
+ *
180
+ * The children are read from GLSP's protected `CompoundCommand.commands`;
181
+ * should that field stop being readable, a compound becomes one step and
182
+ * its children's side effects no longer interleave with the bridges.
183
+ */
184
+ protected tracked(command: Command): Command;
185
+ /** The model projected from the working copies, cloned; `undefined` for a state that projects none. */
186
+ protected project(): Promise<TSourceModel | undefined>;
187
+ /**
188
+ * Resolve the transition onto the current model, run the commands' side
189
+ * effects, then write once, gated on the versions the model was read at. A
190
+ * collision does nothing but warn; a transition with nothing left to apply,
191
+ * or one the model already holds, still runs the side effects.
192
+ *
193
+ * The caller holds `runExclusive`, which nothing here takes again.
194
+ */
195
+ protected undoOrRedo(direction: UndoRedoDirection): Promise<void>;
196
+ /**
197
+ * Write `model` once through the state's write path, gated on the versions
198
+ * read when the operation opened, a conflict reconciled as for any write of
199
+ * the state; `false` when the reconcile dropped it.
200
+ */
201
+ protected write(model: TSourceModel): Promise<boolean>;
202
+ /**
203
+ * Run the recorded steps of an undo or redo against fresh copies of the
204
+ * built roots, made on demand as in an operation and discarded unwritten,
205
+ * then write `merged`, the resolved transition, through {@link write}: that
206
+ * write is what changes the model, and a step that edits `sourceRoot` must
207
+ * not reach the root every reader shares. A recording command executed here
208
+ * throws.
209
+ *
210
+ * When a step or the write throws, or the write's reconcile drops it, the
211
+ * steps already run are run the other way, newest first, and the error is
212
+ * rethrown with nothing written; GLSP's command stack then flushes, as it
213
+ * does for any undo or redo that fails.
214
+ */
215
+ protected undoOrRedoSideEffects(direction: UndoRedoDirection, merged?: TSourceModel): Promise<void>;
216
+ /**
217
+ * Run `steps`, which a failed undo or redo already ran, the other way, each
218
+ * on its own as {@link rollback} does; the undo or redo's own error is the
219
+ * one thrown.
220
+ */
221
+ protected compensate(steps: readonly OperationSideEffect[], direction: UndoRedoDirection): Promise<void>;
222
+ /**
223
+ * The transition and the recorded steps as `direction` runs them: an undo
224
+ * runs the transition backwards and each step's undo, newest first, and is
225
+ * reverted by each step's redo; a redo the other way round.
226
+ */
227
+ protected inDirection(direction: UndoRedoDirection): {
228
+ readonly transition?: OperationTransition<TSourceModel>;
229
+ readonly steps: readonly OperationSideEffect[];
230
+ run(step: OperationSideEffect): MaybePromise<void>;
231
+ revert(step: OperationSideEffect): MaybePromise<void>;
232
+ };
233
+ /**
234
+ * The copy's stand-in for `original`: its target is the copy of
235
+ * `original`'s target once one exists, read when asked so a copy made later
236
+ * in the operation is found, else that target itself. A handler compares a
237
+ * target by identity with nodes it resolved from a copy.
238
+ */
239
+ protected buildWorkingReference(original: Reference): Reference;
240
+ /** {@link buildWorkingReference} for a reference with several targets. */
241
+ protected buildWorkingMultiReference(original: MultiReference): MultiReference;
242
+ /**
243
+ * Replace every multi-reference under `working` with a working one.
244
+ * `AstUtils.copyAstNode` rebuilds single references only and leaves a
245
+ * multi-reference object shared with the built root, whose targets are
246
+ * built nodes.
247
+ */
248
+ protected rebuildWorkingMultiReferences(working: AstNode): void;
249
+ }
250
+ //# sourceMappingURL=hydranium-glsp-operation-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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