@hydranium/glsp-server 1.0.0-next.31 → 1.0.0-next.315

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 +80 -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 +50 -15
  82. package/lib/node/start-glsp-server.d.ts.map +1 -1
  83. package/lib/node/start-glsp-server.js +97 -30
  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 +133 -40
  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
@@ -13,7 +13,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
13
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14
14
  };
15
15
  import { injectable } from 'inversify';
16
+ import { asModelVersion, describeErrorWithStack } from '@hydranium/protocol';
16
17
  import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
18
+ import { openOperationOf } from '../command/hydranium-glsp-operation-command.js';
17
19
  import { reconcileSourceModelWrite } from './reconcile-source-model-write.js';
18
20
  /**
19
21
  * Editable GLSP state for a diagram whose edits span SEVERAL Langium documents —
@@ -28,43 +30,33 @@ import { reconcileSourceModelWrite } from './reconcile-source-model-write.js';
28
30
  * defines them over the primary plus the secondary write set registered through
29
31
  * {@link AbstractHydraniumGlspState.trackSecondaryDocument}.
30
32
  *
31
- * **Writes are NOT atomic, deliberately, and the window is real.** Each document
32
- * goes through its own `ModelService.update`, so a failure after the first write
33
- * has landed leaves the set inconsistent on disk. There is no multi-document
34
- * transaction to lean on: `WorkspaceLock` serialises builds but does not roll
35
- * back, and the document store commits per URI. An adopter that cannot accept the
36
- * window should not span documents in one operation.
33
+ * **The write set is written all or none.** {@link persist} hands every
34
+ * changed document to one `ClientSession.updateAll` on the diagram's session,
35
+ * so a conflict on any document leaves every document of the set as it was,
36
+ * and write order carries no meaning.
37
37
  *
38
- * **What makes the window tolerable is write ORDER, and the rule is
39
- * referenced-before-referencing** — not "secondaries first" as such. Write the
40
- * document whose content the others point AT before the documents that point at
41
- * it, so a partial write leaves an unreferenced element (inert, and the direction
42
- * an integrity rule can repair) rather than a reference to something that does
43
- * not exist (a linking error). {@link persist} implements that as
44
- * secondaries-then-primary, which is correct for the common shape where the
45
- * primary is the DIAGRAM and the semantics it references are secondaries: the
46
- * user opened the diagram, so it is also the document the conflict gate should
47
- * guard. **An adopter whose primary is the referenced document — a semantic file
48
- * as the diagram source, with layout in a secondary — has the ordering backwards
49
- * and must override {@link persist} to write the primary first.** Overriding it
50
- * is the supported route; the base order is a default for the common case, not an
51
- * invariant of the class.
38
+ * **Every document of the set is gated.** The primary on the caller's
39
+ * `baseVersion`, each secondary on {@link secondaryBaseVersion}, by default the version
40
+ * it had when the source root was last read. A conflict on any of them is
41
+ * reconciled against the whole write set, and the merged retry is gated on
42
+ * the versions its refetch read. A write based on `'any'` — an undo or redo
43
+ * applying a recorded patch — forces every document of the set.
52
44
  *
53
- * **The conflict gate covers the primary only.** Secondaries are written without
54
- * a based-on version, so a concurrent foreign edit to one is overwritten rather
55
- * than reconciled. Gating them too would need a per-document reconcile whose
56
- * outcomes can disagree (merge one, conflict another) with no way to un-write the
57
- * merged one — the atomicity problem again, one layer up. The captured versions
58
- * ARE available via {@link AbstractHydraniumGlspState.capturedVersionOf}, so an
59
- * adopter that wants a coarser check can compare before writing.
45
+ * A secondary is written only while the diagram's session has it open. The
46
+ * storage opens it as it joins the write set, and {@link openForWrite} opens it
47
+ * again before each write; an adopter whose write set can name a document that
48
+ * does not exist yet overrides {@link openForWrite} to create it through
49
+ * {@link createSecondaryDocument}.
60
50
  */
61
51
  let ReconcilingMultiDocumentGlspState = class ReconcilingMultiDocumentGlspState extends AbstractHydraniumGlspState {
62
52
  /**
63
- * Last in-sync projection across the whole write set, captured on every
64
- * {@link setSourceRoot}. Same role as the single-document baseline: the state a
65
- * forward-write conflict reconciles the user's intent against.
53
+ * The projection across the whole write set that a forward-write conflict
54
+ * reconciles the user's intent from, taken from the built roots on every
55
+ * capture.
66
56
  */
67
- baseline;
57
+ base;
58
+ /** The documents {@link createSecondaryDocument} created for the {@link persist} under way, with the version each was created at. */
59
+ createdForWrite = new Map();
68
60
  /**
69
61
  * Projection of the primary plus every registered secondary, in the framework
70
62
  * encoder's `'grammar'` mode (authored state only — cross-references as
@@ -84,25 +76,85 @@ let ReconcilingMultiDocumentGlspState = class ReconcilingMultiDocumentGlspState
84
76
  secondaries[uri] = projection;
85
77
  }
86
78
  }
87
- return { primary: this.projectRoot(this._sourceRoot), secondaries };
79
+ return { primary: this.projectRoot(this.sourceRoot), secondaries };
88
80
  }
89
- setSourceRoot(uri, root) {
90
- super.setSourceRoot(uri, root);
81
+ captureSourceRoot(uri, root) {
82
+ super.captureSourceRoot(uri, root);
91
83
  this.trackWriteSet(uri);
92
- this.baseline = this.sourceModel;
84
+ this.base = this.sourceModel;
85
+ }
86
+ /**
87
+ * Each document whose ends differ, either end serialized for its URI and
88
+ * parsed back; a document equal on both ends is left as it is, since it
89
+ * stays out of the transition's patch anyway.
90
+ */
91
+ async normalizeTransition(transition) {
92
+ const from = { primary: transition.from.primary, secondaries: { ...transition.from.secondaries } };
93
+ const to = { primary: transition.to.primary, secondaries: { ...transition.to.secondaries } };
94
+ if (JSON.stringify(from.primary) !== JSON.stringify(to.primary)) {
95
+ from.primary = this.projectRoot(await this.roundTrip(this._sourceUri, from.primary));
96
+ to.primary = this.projectRoot(await this.roundTrip(this._sourceUri, to.primary));
97
+ }
98
+ for (const uri of new Set([...Object.keys(from.secondaries), ...Object.keys(to.secondaries)])) {
99
+ if (JSON.stringify(from.secondaries[uri]) === JSON.stringify(to.secondaries[uri])) {
100
+ continue;
101
+ }
102
+ for (const end of [from, to]) {
103
+ const secondary = end.secondaries[uri];
104
+ if (secondary !== undefined) {
105
+ end.secondaries[uri] = this.projectRoot(await this.roundTrip(uri, secondary));
106
+ }
107
+ }
108
+ }
109
+ return { from, to };
110
+ }
111
+ /**
112
+ * Also takes a secondary first tracked during an operation into the base
113
+ * and into the operation's projection from before its command, both from
114
+ * the root its version was read from: a conflict on it reconciles from the
115
+ * revision the operation's copy describes, and undoing the operation
116
+ * restores it. A document that does not exist yet has no projection to
117
+ * restore, so an undo leaves what the operation wrote into it.
118
+ */
119
+ trackSecondaryDocument(uri) {
120
+ const added = uri !== this._sourceUri && !this.secondaryUris.includes(uri);
121
+ super.trackSecondaryDocument(uri);
122
+ const root = this.capturedRootOf(uri);
123
+ if (root === undefined) {
124
+ return;
125
+ }
126
+ const projection = this.projectRoot(root);
127
+ if (this.base !== undefined && !(uri in this.base.secondaries)) {
128
+ this.base = { ...this.base, secondaries: { ...this.base.secondaries, [uri]: projection } };
129
+ }
130
+ if (added) {
131
+ openOperationOf(this)?.amendBefore(before => isMultiDocumentModel(before) ? { ...before, secondaries: { ...before.secondaries, [uri]: projection } } : before);
132
+ }
133
+ }
134
+ /**
135
+ * During an operation, also drops the untracked documents from its
136
+ * projection from before its command: they are not written, so the
137
+ * operation's undo and redo leave them as they are.
138
+ */
139
+ untrackSecondaryDocuments() {
140
+ const untracked = this.secondaryUris;
141
+ super.untrackSecondaryDocuments();
142
+ openOperationOf(this)?.amendBefore(before => isMultiDocumentModel(before)
143
+ ? { ...before, secondaries: Object.fromEntries(Object.entries(before.secondaries).filter(([uri]) => !untracked.includes(uri))) }
144
+ : before);
93
145
  }
94
146
  /**
95
147
  * Register the secondary documents that belong to the primary at `uri`, via
96
148
  * {@link AbstractHydraniumGlspState.trackSecondaryDocument}. Called on every
97
- * {@link setSourceRoot}, after the primary is captured (so `sourceUri` is
98
- * current) and BEFORE the baseline is taken (so the baseline includes them).
149
+ * capture, after the primary is captured (so `sourceUri` is current) and
150
+ * BEFORE the base is taken (so the base includes them).
99
151
  * Default: no secondaries.
100
152
  *
101
153
  * This hook exists because that ordering is a trap an adopter would otherwise
102
- * hit silently. Registering from an overridden `setSourceRoot` *after*
103
- * `super.setSourceRoot(...)` runs too late — the baseline has already been
154
+ * hit silently. Registering from an overridden `captureSourceRoot` *after*
155
+ * `super.captureSourceRoot(...)` runs too late — the base has already been
104
156
  * captured without the secondaries, so the first conflict reconcile measures
105
- * the user's intent against a baseline missing half the write set and the
157
+ * the user's intent against a base missing half the write set and the
106
158
  * secondary edits look like foreign changes. Registering *before* the super
107
159
  * call is too early for a URI derived from the new primary. Overriding this
108
160
  * instead removes the choice.
@@ -112,102 +164,189 @@ let ReconcilingMultiDocumentGlspState = class ReconcilingMultiDocumentGlspState
112
164
  }
113
165
  /**
114
166
  * Persist the whole write set, then capture the resulting primary root. On a
115
- * `ConflictError` from the primary, reconcile via the injected policy exactly
116
- * as the single-document state does — the orchestration is shared.
167
+ * `ConflictError` from any document of the set, reconcile via the injected
168
+ * policy exactly as the single-document state does — the orchestration is
169
+ * shared.
117
170
  */
118
- async updateSourceModel(model, version) {
119
- return reconcileSourceModelWrite(model, version, {
120
- persist: async (candidate, baseVersion) => {
121
- const { root } = await this.persist(candidate, baseVersion);
122
- this.setSourceRoot(this._sourceUri, root);
171
+ async updateSourceModel(model, baseVersion = this.baseVersion) {
172
+ let secondaryVersions;
173
+ return reconcileSourceModelWrite(model, baseVersion, {
174
+ persist: async (candidate, candidateBaseVersion) => {
175
+ const { root } = await this.persist(candidate, candidateBaseVersion, secondaryVersions);
176
+ this.captureWrittenRoot(root);
177
+ },
178
+ refetch: async () => {
179
+ const refetched = await this.refetch();
180
+ secondaryVersions = refetched?.secondaryVersions;
181
+ return refetched;
123
182
  },
124
- refetch: () => this.refetch(),
125
- baseline: this.baseline,
183
+ base: this.base,
126
184
  conflictResolver: this.conflictResolver,
127
185
  logger: this.logger,
128
- onConflictDropped: () => this.refreshSourceRoot()
186
+ onConflictDropped: () => this.writeDropped(),
187
+ onAlreadyApplied: () => this.captureBuiltRoot(),
188
+ maxWrites: this.maxSourceModelWrites
129
189
  });
130
190
  }
131
191
  /**
132
- * Write hook — secondaries first (ungated), primary last (gated on
133
- * `baseVersion`). The order is the failure-mode choice documented on the
134
- * class, not incidental: override this when the primary is the document the
135
- * others REFERENCE, since then this order writes the references first.
192
+ * Write hook — every document of `model` that changed, opened first through
193
+ * {@link openForWrite}, in one `updateAll` on the diagram's session: the
194
+ * primary gated on `baseVersion`, each secondary on its entry in
195
+ * `secondaryVersions` (a refetch's) or else {@link secondaryBaseVersion}, or
196
+ * every document on `'any'` when `baseVersion` is `'any'`. Resolves to
197
+ * the primary's root, the one already captured when the primary did not
198
+ * change. A write that bypasses `updateAll` gives up the all-or-none
199
+ * guarantee the class describes. Throws without a session
200
+ * ({@link requireModelSession}). An override that serializes otherwise than
201
+ * `ModelService.modelToText` overrides {@link normalizeTransition} alongside.
202
+ *
203
+ * A write that fails closes every document {@link createSecondaryDocument}
204
+ * created for it that {@link closesCreatedDocument} accepts.
136
205
  */
137
- async persist(model, baseVersion) {
138
- for (const [uri, secondary] of Object.entries(model.secondaries)) {
139
- if (this.hasChanged(this.baseline?.secondaries[uri], secondary)) {
140
- await this.persistSecondary(uri, secondary);
206
+ async persist(model, baseVersion, secondaryVersions) {
207
+ const primaryChanged = this.hasChanged(this.base.primary, model.primary);
208
+ const changedSecondaries = Object.entries(model.secondaries).filter(([uri, secondary]) => this.hasChanged(this.base.secondaries[uri], secondary));
209
+ if (!primaryChanged && changedSecondaries.length === 0) {
210
+ return { root: this._sourceRoot };
211
+ }
212
+ const session = this.requireModelSession();
213
+ this.createdForWrite.clear();
214
+ try {
215
+ if (primaryChanged) {
216
+ await this.openForWrite(session, this._sourceUri);
217
+ }
218
+ for (const [uri] of changedSecondaries) {
219
+ await this.openForWrite(session, uri);
220
+ }
221
+ // Based after the opens, so a secondary created there is gated on the version it was created at.
222
+ const updates = primaryChanged
223
+ ? [{ uri: this._sourceUri, model: model.primary, baseVersion }]
224
+ : [];
225
+ for (const [uri, secondary] of changedSecondaries) {
226
+ updates.push({
227
+ uri,
228
+ model: secondary,
229
+ baseVersion: baseVersion === 'any' ? 'any' : (secondaryVersions?.[uri] ?? this.secondaryBaseVersion(uri))
230
+ });
141
231
  }
232
+ const documents = await session.updateAll({ updates });
233
+ return { root: primaryChanged ? documents[0].root : this._sourceRoot };
142
234
  }
143
- if (!this.hasChanged(this.baseline?.primary, model.primary)) {
144
- // Nothing to write, so nothing to gate either — return the root already
145
- // captured rather than round-tripping the document for no reason.
146
- return { root: this._sourceRoot };
235
+ catch (error) {
236
+ for (const [uri, created] of this.createdForWrite) {
237
+ try {
238
+ if (this.closesCreatedDocument(uri, created)) {
239
+ await session.close(uri);
240
+ }
241
+ }
242
+ catch (closeError) {
243
+ this.logger.warn(`Could not close ${uri}, created for a write that failed: ${describeErrorWithStack(closeError)}`);
244
+ }
245
+ }
246
+ throw error;
247
+ }
248
+ finally {
249
+ this.createdForWrite.clear();
147
250
  }
148
- return this.persistPrimary(model.primary, baseVersion);
149
251
  }
150
252
  /**
151
- * Whether `candidate` differs from the baseline projection of the same
253
+ * Whether a write that failed closes `uri`, which
254
+ * {@link createSecondaryDocument} created for it at `createdVersion`.
255
+ * Default: while it still holds the text it was created with. Left open, it
256
+ * would stay in the diagram's session, and the diagram's next save would
257
+ * write it to disk though no write landed in it. One whose text moved on,
258
+ * because the set failed after applying or another client wrote to it,
259
+ * stays open: closing it would drop that text.
260
+ */
261
+ closesCreatedDocument(uri, createdVersion) {
262
+ return this.sharedServices.workspace.TextDocuments.version(uri) === createdVersion;
263
+ }
264
+ /**
265
+ * Whether `candidate` differs from the base projection of the same
152
266
  * document, and therefore needs writing.
153
267
  *
154
268
  * **Skipping unchanged documents is correctness, not an optimisation.** A
155
- * write goes through `ModelService.update`, which re-serializes from the AST —
156
- * so writing a document that did not change still rewrites its text, and a
157
- * serializer is free to normalise formatting and cannot preserve comments.
158
- * Persisting the whole write set unconditionally therefore means a pure layout
159
- * drag reflows the semantic file and strips its comments, which is a data
160
- * loss the user never asked for and would struggle to attribute.
269
+ * write re-serializes from the AST, so writing a document that did not
270
+ * change still rewrites its text in the serializer's own layout. Persisting
271
+ * the whole write set unconditionally therefore means a pure layout drag
272
+ * reflows the semantic file, a change the user never asked for and would
273
+ * struggle to attribute. Comments survive that rewrite, but the
274
+ * hand-formatting around them does not.
161
275
  *
162
276
  * Compared by serialised form. Both sides come from the same encoder walking
163
277
  * the same shape, so key order is stable and a string compare is sound here;
164
278
  * it is also cheap enough to run per document per write.
165
279
  */
166
- hasChanged(baseline, candidate) {
167
- return baseline === undefined || JSON.stringify(baseline) !== JSON.stringify(candidate);
168
- }
169
- /** Write the primary document, opting into the conflict gate when `baseVersion` is given. */
170
- async persistPrimary(model, baseVersion) {
171
- const document = await this.sharedServices.model.ModelService.update({
172
- uri: this._sourceUri,
173
- model,
174
- clientId: this.clientId,
175
- baseVersion
176
- });
177
- return document;
280
+ hasChanged(base, candidate) {
281
+ return base === undefined || JSON.stringify(base) !== JSON.stringify(candidate);
178
282
  }
179
283
  /**
180
- * Write one secondary document. Ungated by design (see the class doc); override
181
- * alongside {@link persistPrimary} when the round-trip differs per document
182
- * role — a layout file and a semantic file need not share a serializer.
284
+ * Make sure the diagram's session has `uri` open before the write set is
285
+ * written. Default: open it, a no-op for a document the session already
286
+ * has open. Override to create a document the write set names before it
287
+ * exists, through {@link createSecondaryDocument}: `updateAll` opens nothing.
183
288
  */
184
- async persistSecondary(uri, model) {
185
- await this.sharedServices.model.ModelService.update({ uri, model, clientId: this.clientId });
289
+ openForWrite(session, uri) {
290
+ return session.open(uri);
186
291
  }
187
292
  /**
188
- * Refetch hook — the current settled projection across the write set, used by
189
- * the conflict resolver to replay the user's intent against fresh state.
190
- * Returns `undefined` when the PRIMARY cannot be read, since a reconcile
191
- * without it has nothing to merge into; an unreadable secondary is omitted the
192
- * same way {@link sourceModel} omits one.
293
+ * Create the secondary `uri` holding `text` through `session.create`, and
294
+ * base its write on the version the created document took. The version
295
+ * recorded while it did not exist matches no write, so the write conflicts.
296
+ * Make `text` with `ModelService.modelToText`, not the bare serializer,
297
+ * which leaves the file without the ending a write would give it.
298
+ */
299
+ async createSecondaryDocument(session, uri, text) {
300
+ const created = await session.create(uri, text);
301
+ this.createdForWrite.set(uri, created);
302
+ if (this._secondaryVersions.has(uri)) {
303
+ this._secondaryVersions.set(uri, asModelVersion(created));
304
+ }
305
+ }
306
+ /**
307
+ * What a secondary write declares it was based on. Default: the version the
308
+ * secondary had when the source root was last read
309
+ * ({@link AbstractHydraniumGlspState.baseVersionOf}), so a foreign edit
310
+ * to it since is reported as a conflict and reconciled rather than
311
+ * overwritten; `'any'` for a secondary with no recorded version.
312
+ * Return `'any'` to force secondary writes.
313
+ */
314
+ secondaryBaseVersion(uri) {
315
+ return this.baseVersionOf(uri) ?? 'any';
316
+ }
317
+ /**
318
+ * Refetch hook — the current projection across the write set, each document
319
+ * read through {@link AbstractHydraniumGlspState.readCurrentRoot}, with the
320
+ * versions read alongside: theirs, which the conflict resolver replays the
321
+ * user's intent onto. Returns `undefined` when the PRIMARY cannot be read,
322
+ * since a reconcile without it has nothing to merge into; an unreadable
323
+ * secondary is omitted the same way {@link sourceModel} omits one.
193
324
  */
194
325
  async refetch() {
195
- const fresh = await this.sharedServices.model.ModelService.validated(this._sourceUri).catch(() => undefined);
196
- if (!fresh) {
326
+ const theirs = await this.readCurrentRoot(this._sourceUri);
327
+ if (!theirs) {
197
328
  return undefined;
198
329
  }
199
330
  const secondaries = {};
331
+ const secondaryVersions = {};
200
332
  for (const uri of this.secondaryUris) {
201
- const settled = await this.sharedServices.model.ModelService.validated(uri).catch(() => undefined);
202
- if (settled) {
203
- secondaries[uri] = this.projectRoot(settled.root);
333
+ const read = await this.readCurrentRoot(uri);
334
+ if (read) {
335
+ secondaries[uri] = this.projectRoot(read.root);
336
+ secondaryVersions[uri] = read.version;
204
337
  }
205
338
  }
206
- return { primary: this.projectRoot(fresh.root), secondaries };
339
+ return { model: { primary: this.projectRoot(theirs.root), secondaries }, baseVersion: theirs.version, secondaryVersions };
207
340
  }
208
- /** Project a currently-loaded document's root, or `undefined` when it is not loaded. */
341
+ /**
342
+ * Project a currently-loaded document's root, or `undefined` when it is not
343
+ * loaded: the open operation's copy of it when there is one, which is where
344
+ * a handler's edit of it is, else the root its version was read from.
345
+ */
209
346
  projectDocument(uri) {
210
- const root = this.sharedServices.model.ModelService.getDocument(uri)?.parseResult?.value;
347
+ const root = this.existingWorkingRootOf(uri) ??
348
+ this.capturedRootOf(uri) ??
349
+ this.sharedServices.model.ModelService.getDocument(uri)?.parseResult?.value;
211
350
  return root ? this.projectRoot(root) : undefined;
212
351
  }
213
352
  /** Grammar-mode transfer projection of one AST root. The single projection seam. */
@@ -219,4 +358,7 @@ ReconcilingMultiDocumentGlspState = __decorate([
219
358
  injectable()
220
359
  ], ReconcilingMultiDocumentGlspState);
221
360
  export { ReconcilingMultiDocumentGlspState };
361
+ function isMultiDocumentModel(value) {
362
+ return 'secondaries' in value && typeof value.secondaries === 'object' && value.secondaries !== null;
363
+ }
222
364
  //# sourceMappingURL=reconciling-multi-document-glsp-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reconciling-multi-document-glsp-state.js","sourceRoot":"","sources":["../../src/state/reconciling-multi-document-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;AAGlF,OAAO,EAAE,UAAU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,CAAC,IAA0B,CAAC,CAAC;YAC3E,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAA0B,CAAa,EAAE,WAAW,EAAE,CAAC;IACnG,CAAC;IAED,wFAAwF;IAC9E,eAAe,CAAC,GAAW;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC;QACzF,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpD,CAAC;IAED,oFAAoF;IAC1E,WAAW,CAA8C,IAAa;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAiB,CAAC;IAChG,CAAC;CACH,CAAA;AA1KY,iCAAiC;IAD7C,UAAU,EAAE;GACA,iCAAiC,CA0K7C"}
1
+ {"version":3,"file":"reconciling-multi-document-glsp-state.js","sourceRoot":"","sources":["../../src/state/reconciling-multi-document-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EACJ,cAAc,EAMd,sBAAsB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAA4B,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAC3G,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AA0B9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,iCAAiC,GAAvC,MAAM,iCACV,SAAQ,0BAAqE;IAG7E;;;;OAIG;IACO,IAAI,CAAsC;IAEpD,qIAAqI;I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AAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/C,iBAAiB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;YACzC,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAW,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACvI,CAAC;IAED;;;;OAIG;IACO,eAAe,CAAC,GAAW;QAClC,MAAM,IAAI,GACP,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC;YAC/B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;YACxB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC;QAC/E,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpD,CAAC;IAED,oFAAoF;IAC1E,WAAW,CAA8C,IAAa;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAiB,CAAC;IAChG,CAAC;CACH,CAAA;AA/UY,iCAAiC;IAD7C,UAAU,EAAE;GACA,iCAAiC,CA+U7C;;AAED,SAAS,oBAAoB,CAAC,KAAa;IACxC,OAAO,aAAa,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC;AACxG,CAAC"}
@@ -8,7 +8,8 @@
8
8
  ********************************************************************************/
9
9
  import { type JsonModelState } from '@eclipse-glsp/server';
10
10
  import { type AstNode } from '@hydranium/langium';
11
- import { type TransferElement } from '@hydranium/protocol';
11
+ import { type BaseVersion, type TransferElement, type VersionedModel } from '@hydranium/protocol';
12
+ import { type OperationTransition } from '../command/hydranium-glsp-operation-command.js';
12
13
  import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
13
14
  /**
14
15
  * Editable GLSP state for adopters whose source model is a **structured
@@ -23,16 +24,16 @@ import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
23
24
  * field-level shape is what lets `fast-json-patch` diff per field, so undo /
24
25
  * redo and forward-write reconcile act per field instead of clobbering the
25
26
  * whole document.
26
- * - {@link baseline} — the last in-sync projection, captured on every
27
- * {@link setSourceRoot}. A forward-write conflict reconciles the user's
28
- * intent (baseline → attempted) against the fresh server root.
27
+ * - {@link base} — the last in-sync projection, taken on every capture of
28
+ * the built root. A forward-write conflict reconciles the user's
29
+ * intent (base → ours) against the server's current root (theirs).
29
30
  * - {@link updateSourceModel} — the concrete reconcile template: persist,
30
31
  * and on a `ConflictError` consult the injected `conflictResolver` and act
31
- * on the merged / no-op / conflict / unavailable outcome.
32
+ * on its outcome.
32
33
  * - {@link persist} / {@link refetch} — the only I/O seams. Defaults route
33
- * through `ModelService.update` / `.validated` (reachable from the base via
34
- * `sharedServices.model`); adopters whose document round-trip differs
35
- * override these without touching the orchestration.
34
+ * through the diagram session's `update` and `ModelService.validated`;
35
+ * adopters whose document round-trip differs override these without
36
+ * touching the orchestration.
36
37
  *
37
38
  * Adopters whose source model is whole-document text (a bare `{ text }`
38
39
  * source model) or that are read-only do NOT extend this class — they extend
@@ -43,13 +44,10 @@ import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
43
44
  */
44
45
  export declare class ReconcilingTransferHydraniumGlspState<TRoot extends AstNode, TSourceModel extends TransferElement> extends AbstractHydraniumGlspState<TRoot, TSourceModel> implements JsonModelState<TSourceModel> {
45
46
  /**
46
- * Last in-sync source-model projection, captured on every
47
- * {@link setSourceRoot} (initial load + post-update). The baseline a
48
- * forward-write conflict reconciles against: it stays the pre-command
49
- * state because operation handlers mutate `_sourceRoot` in place during
50
- * `execute` while `setSourceRoot` only re-runs once the write commits.
47
+ * The projection a forward-write conflict reconciles the user's intent
48
+ * from, taken from the built root on every capture.
51
49
  */
52
- protected baseline?: TSourceModel;
50
+ protected base: TSourceModel;
53
51
  /**
54
52
  * Persisted-shape projection of the current source root, consumed by GLSP's
55
53
  * {@link JsonModelState} read side and recorded for field-level undo / redo.
@@ -59,33 +57,43 @@ export declare class ReconcilingTransferHydraniumGlspState<TRoot extends AstNode
59
57
  * Synchronous — the encoder walks the in-memory AST without serialising.
60
58
  */
61
59
  get sourceModel(): TSourceModel;
62
- setSourceRoot(uri: string, root: TRoot): void;
60
+ /**
61
+ * The source model of `root`. The single projection seam: the source
62
+ * model, the refetch and {@link normalizeTransition} all project through it.
63
+ */
64
+ protected projectRoot(root: AstNode): TSourceModel;
65
+ /** Both ends serialized for the source document and parsed back, unless they are equal. */
66
+ normalizeTransition(transition: OperationTransition<TSourceModel>): Promise<OperationTransition<TSourceModel>>;
67
+ protected captureSourceRoot(uri: string, root: TRoot): void;
63
68
  /**
64
69
  * Persist `model` back to the document store, then capture the resulting
65
- * AST root. On a `ConflictError` (the based-on version was superseded),
66
- * reconcile the user's intent against the fresh server root via the bound
70
+ * AST root. On a `ConflictError` (the base version was superseded),
71
+ * reconcile the user's intent against the server's current root via the bound
67
72
  * `conflictResolver` and act on the outcome — one declarative policy
68
73
  * (force = last-writer-wins, reconciling = field-level merge) shared with
69
74
  * undo / redo.
70
75
  */
71
- updateSourceModel(model: TSourceModel, version?: number): Promise<void>;
76
+ updateSourceModel(model: TSourceModel, baseVersion?: BaseVersion): Promise<void>;
72
77
  /**
73
78
  * Persist hook — the only write-side I/O. Default routes the structured
74
- * model through `ModelService.update` (serialize → reparse), opting into
75
- * the `ConflictError` gate when `version` is given. Adopters whose document
76
- * round-trip differs override this; the orchestration in
79
+ * model through the diagram session's `update` (serialize → reparse),
80
+ * opting into the `ConflictError` gate unless `baseVersion` is `'any'`,
81
+ * and throws without a session. Adopters whose document
82
+ * round-trip differs override this, and {@link normalizeTransition}
83
+ * alongside so undo compares what this writes; the orchestration in
77
84
  * {@link updateSourceModel} is unchanged.
78
85
  */
79
- protected persist(model: TSourceModel, baseVersion?: number): Promise<{
86
+ protected persist(model: TSourceModel, baseVersion: BaseVersion): Promise<{
80
87
  root: TRoot;
81
88
  }>;
82
89
  /**
83
- * Refetch hook — reads the current settled server root as a persisted-shape
84
- * projection (or `undefined` when unavailable). The `conflictResolver`
85
- * replays the user's intent against this fresh state. Default uses
86
- * `ModelService.validated` + the framework encoder's `'grammar'` mode;
87
- * adopters override alongside {@link persist}.
90
+ * Refetch hook — the stored text parsed afresh, as a persisted-shape
91
+ * projection with the version of that text (or `undefined` when
92
+ * unavailable): theirs, which the `conflictResolver` replays the user's
93
+ * intent onto. Default uses {@link AbstractHydraniumGlspState.readCurrentRoot}
94
+ * + the framework encoder's `'grammar'` mode; adopters override alongside
95
+ * {@link persist}.
88
96
  */
89
- protected refetch(): Promise<TSourceModel | undefined>;
97
+ protected refetch(): Promise<VersionedModel<TSourceModel> | undefined>;
90
98
  }
91
99
  //# sourceMappingURL=reconciling-transfer-hydranium-glsp-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reconciling-transfer-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/reconciling-transfer-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,qCAAqC,CAAC,KAAK,SAAS,OAAO,EA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