@hydranium/glsp-server 1.0.0-next.14 → 1.0.0-next.148

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 (108) hide show
  1. package/README.md +20 -5
  2. package/lib/browser/start-glsp-server-in-worker.d.ts +30 -39
  3. package/lib/browser/start-glsp-server-in-worker.d.ts.map +1 -1
  4. package/lib/browser/start-glsp-server-in-worker.js +45 -11
  5. package/lib/browser/start-glsp-server-in-worker.js.map +1 -1
  6. package/lib/command/hydranium-glsp-command-stack.d.ts +27 -0
  7. package/lib/command/hydranium-glsp-command-stack.d.ts.map +1 -0
  8. package/lib/command/hydranium-glsp-command-stack.js +53 -0
  9. package/lib/command/hydranium-glsp-command-stack.js.map +1 -0
  10. package/lib/command/hydranium-glsp-recording-command.d.ts +22 -22
  11. package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
  12. package/lib/command/hydranium-glsp-recording-command.js +25 -26
  13. package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
  14. package/lib/command/index.d.ts +1 -0
  15. package/lib/command/index.d.ts.map +1 -1
  16. package/lib/command/index.js +1 -0
  17. package/lib/command/index.js.map +1 -1
  18. package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts +12 -3
  19. package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts.map +1 -1
  20. package/lib/launcher/abstract-hydranium-glsp-diagram-module.js +18 -2
  21. package/lib/launcher/abstract-hydranium-glsp-diagram-module.js.map +1 -1
  22. package/lib/launcher/glsp-server-overrides.d.ts +9 -8
  23. package/lib/launcher/glsp-server-overrides.d.ts.map +1 -1
  24. package/lib/launcher/glsp-server-overrides.js +12 -10
  25. package/lib/launcher/glsp-server-overrides.js.map +1 -1
  26. package/lib/launcher/hydranium-glsp-server.d.ts +14 -10
  27. package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -1
  28. package/lib/launcher/hydranium-glsp-server.js +20 -10
  29. package/lib/launcher/hydranium-glsp-server.js.map +1 -1
  30. package/lib/messages/index.d.ts +24 -0
  31. package/lib/messages/index.d.ts.map +1 -0
  32. package/lib/messages/index.js +24 -0
  33. package/lib/messages/index.js.map +1 -0
  34. package/lib/node/start-glsp-server.d.ts +1 -1
  35. package/lib/node/start-glsp-server.d.ts.map +1 -1
  36. package/lib/node/start-glsp-server.js +3 -4
  37. package/lib/node/start-glsp-server.js.map +1 -1
  38. package/lib/state/abstract-hydranium-glsp-state.d.ts +110 -43
  39. package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
  40. package/lib/state/abstract-hydranium-glsp-state.js +139 -60
  41. package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
  42. package/lib/state/full-text-hydranium-glsp-state.d.ts +6 -6
  43. package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
  44. package/lib/state/full-text-hydranium-glsp-state.js +6 -10
  45. package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
  46. package/lib/state/reconcile-source-model-write.d.ts +9 -8
  47. package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
  48. package/lib/state/reconcile-source-model-write.js +8 -8
  49. package/lib/state/reconcile-source-model-write.js.map +1 -1
  50. package/lib/state/reconciling-multi-document-glsp-state.d.ts +59 -59
  51. package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
  52. package/lib/state/reconciling-multi-document-glsp-state.js +84 -82
  53. package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
  54. package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +19 -18
  55. package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
  56. package/lib/state/reconciling-transfer-hydranium-glsp-state.js +26 -30
  57. package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
  58. package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts +30 -0
  59. package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts.map +1 -0
  60. package/lib/storage/hydranium-glsp-request-save-model-action-handler.js +47 -0
  61. package/lib/storage/hydranium-glsp-request-save-model-action-handler.js.map +1 -0
  62. package/lib/storage/hydranium-glsp-storage.d.ts +313 -86
  63. package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
  64. package/lib/storage/hydranium-glsp-storage.js +456 -104
  65. package/lib/storage/hydranium-glsp-storage.js.map +1 -1
  66. package/lib/storage/index.d.ts +2 -1
  67. package/lib/storage/index.d.ts.map +1 -1
  68. package/lib/storage/index.js +2 -1
  69. package/lib/storage/index.js.map +1 -1
  70. package/lib/storage/save-delivery-policy.d.ts +46 -0
  71. package/lib/storage/save-delivery-policy.d.ts.map +1 -0
  72. package/lib/storage/{save-conflict-policy.js → save-delivery-policy.js} +7 -8
  73. package/lib/storage/save-delivery-policy.js.map +1 -0
  74. package/lib/testing/glsp-harness.js +4 -4
  75. package/lib/testing/glsp-harness.js.map +1 -1
  76. package/lib/validation/diagnostic-markers.d.ts +2 -2
  77. package/lib/validation/diagnostic-markers.d.ts.map +1 -1
  78. package/lib/validation/diagnostic-markers.js +7 -0
  79. package/lib/validation/diagnostic-markers.js.map +1 -1
  80. package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -1
  81. package/lib/validation/hydranium-glsp-model-validator.js +1 -1
  82. package/lib/validation/hydranium-glsp-model-validator.js.map +1 -1
  83. package/package.json +17 -8
  84. package/src/browser/start-glsp-server-in-worker.ts +43 -47
  85. package/src/command/hydranium-glsp-command-stack.ts +36 -0
  86. package/src/command/hydranium-glsp-recording-command.ts +26 -26
  87. package/src/command/index.ts +1 -0
  88. package/src/launcher/abstract-hydranium-glsp-diagram-module.ts +27 -3
  89. package/src/launcher/glsp-server-overrides.ts +14 -10
  90. package/src/launcher/hydranium-glsp-server.ts +20 -10
  91. package/src/messages/index.ts +30 -0
  92. package/src/node/start-glsp-server.ts +3 -5
  93. package/src/state/abstract-hydranium-glsp-state.ts +174 -73
  94. package/src/state/full-text-hydranium-glsp-state.ts +7 -11
  95. package/src/state/reconcile-source-model-write.ts +18 -15
  96. package/src/state/reconciling-multi-document-glsp-state.ts +86 -83
  97. package/src/state/reconciling-transfer-hydranium-glsp-state.ts +27 -31
  98. package/src/storage/hydranium-glsp-request-save-model-action-handler.ts +40 -0
  99. package/src/storage/hydranium-glsp-storage.ts +520 -113
  100. package/src/storage/index.ts +2 -1
  101. package/src/storage/save-delivery-policy.ts +44 -0
  102. package/src/testing/glsp-harness.ts +4 -4
  103. package/src/validation/diagnostic-markers.ts +10 -3
  104. package/src/validation/hydranium-glsp-model-validator.ts +3 -3
  105. package/lib/storage/save-conflict-policy.d.ts +0 -56
  106. package/lib/storage/save-conflict-policy.d.ts.map +0 -1
  107. package/lib/storage/save-conflict-policy.js.map +0 -1
  108. package/src/storage/save-conflict-policy.ts +0 -52
@@ -9,8 +9,8 @@
9
9
  import { DefaultModelState, type MaybePromise } from '@eclipse-glsp/server';
10
10
  import { Emitter, type Event } from 'vscode-jsonrpc';
11
11
  import { type AstNode, DocumentState } from '@hydranium/langium';
12
- import { type HydraniumScopeProvider, type LanguageTarget, type NameProvider, type ReferenceCandidateProvider, type ServerLanguageServices, type ServerSharedServices } from '@hydranium/core';
13
- import type { ConflictResolver, Logger, Tracer } from '@hydranium/protocol';
12
+ import { type ClientSession, type HydraniumScopeProvider, type LanguageTarget, type NameProvider, type ReferenceCandidateProvider, type ServerLanguageServices, type ServerSharedServices } from '@hydranium/core';
13
+ import { type BasedOn, type SnapshotVersion, type ConflictResolver, type Logger, type Tracer } from '@hydranium/protocol';
14
14
  import { type HydraniumGlspIndex } from './hydranium-glsp-index.js';
15
15
  import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
16
16
  /**
@@ -71,12 +71,31 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
71
71
  protected readonly baseTracer: Tracer;
72
72
  /** Narrows {@link DefaultModelState.index} to the framework-extended index type. */
73
73
  readonly index: HydraniumGlspIndex;
74
+ /**
75
+ * The client session this diagram works as, registered under `clientId` by
76
+ * the source-model storage and ended with the GLSP client session.
77
+ * `undefined` for GLSP's placeholder client, and when the id was held by
78
+ * another participant, in which case the diagram does not load.
79
+ *
80
+ * Every write of the diagram goes through this session, which writes only a
81
+ * document it has open and opens nothing. A one-shot write to a document
82
+ * outside the write set goes through
83
+ * {@link ClientSession.withOpen}, and a document the diagram brings into
84
+ * existence through {@link ClientSession.create}.
85
+ */
86
+ modelSession?: ClientSession<AstNode>;
87
+ /**
88
+ * {@link modelSession}, or a throw without one: the diagram never loaded or
89
+ * has ended. Looking `clientId` up through `ModelService.getSession` instead
90
+ * would write as whichever participant holds that id.
91
+ */
92
+ protected requireModelSession(): ClientSession<AstNode>;
74
93
  protected _sourceUri: string;
75
94
  protected _sourceRoot: TRoot;
76
95
  protected _tracer?: Tracer;
77
- protected _version: number;
78
- /** Based-on versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
79
- protected readonly _secondaryVersions: Map<string, number>;
96
+ protected _basedOn: SnapshotVersion;
97
+ /** Snapshot versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
98
+ protected readonly _secondaryVersions: Map<string, SnapshotVersion>;
80
99
  /** Backing emitter for {@link onSecondaryUrisChanged}; fired only on a membership change. */
81
100
  protected readonly secondaryUrisChangedEmitter: Emitter<void>;
82
101
  /** Default of one minute. */
@@ -170,27 +189,35 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
170
189
  /** URI-tagged once {@link setSourceRoot} has run; the class-tagged injected {@link baseTracer} before that. */
171
190
  get tracer(): Tracer;
172
191
  /**
173
- * Text-document version captured at the last {@link setSourceRoot}
174
- * call. Mirrors the server-side `TextDocuments.version(uri)` counter
175
- * at that point in time — frozen until the next `setSourceRoot`, then
176
- * re-read from `LangiumDocuments`.
192
+ * Snapshot version taken at the last {@link setSourceRoot} call — frozen
193
+ * until the next one, then re-read from the document store.
177
194
  *
178
195
  * Threaded by `HydraniumGlspRecordingCommand` into
179
- * {@link updateSourceModel}'s optional `version` parameter so the
180
- * downstream `ModelService.update` / `.save` call can opt into the
181
- * conflict gate against the captured based-on version. See
196
+ * {@link updateSourceModel} so the downstream session `update` / `save`
197
+ * gates against what the command was authored on. See
182
198
  * `@hydranium/protocol#ConflictError` for the detection contract.
183
199
  *
200
+ * **This, not a number read at write time, is what a write must be gated
201
+ * on.** A version read when the write is issued is the store's current one,
202
+ * so it matches by construction and the gate can never fire.
203
+ */
204
+ get basedOn(): SnapshotVersion;
205
+ /**
206
+ * Text-document version of {@link basedOn}. Mirrors the server-side
207
+ * `TextDocuments.version(uri)` counter as of the snapshot, or is
208
+ * `NO_MATCHING_VERSION` when the store's text could not be tied to the
209
+ * root (see {@link readSnapshotVersion}).
210
+ *
184
211
  * Falls back to `0` when the document is absent from `LangiumDocuments`
185
- * at capture time — the same observable state callers see for a doc
186
- * that was never opened. Callers that need to distinguish
212
+ * when the snapshot is taken — the same observable state callers see for a
213
+ * doc that was never opened. Callers that need to distinguish
187
214
  * "never-versioned" from "v0" must consult the document registry
188
215
  * directly.
189
216
  */
190
217
  get version(): number;
191
218
  /**
192
- * Register `uri` as a document this state also writes, capturing its current
193
- * text-document version.
219
+ * Register `uri` as a document this state also writes, snapshotting its
220
+ * current text-document version.
194
221
  *
195
222
  * A diagram whose layout lives in its own file, or whose canvas creates
196
223
  * elements in a referenced semantic document, writes more than the document
@@ -203,7 +230,7 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
203
230
  * identified once the operation names the node. What the framework supplies
204
231
  * is the part an adopter cannot reconstruct after the fact — the version each
205
232
  * document was at BEFORE the command mutated anything (see
206
- * {@link capturedVersionOf}). Idempotent; registering the primary is ignored,
233
+ * {@link snapshotVersionOf}). Idempotent; registering the primary is ignored,
207
234
  * since {@link version} already tracks it. Registering a URI not already in
208
235
  * the set fires {@link onSecondaryUrisChanged}.
209
236
  */
@@ -215,14 +242,15 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
215
242
  untrackSecondaryDocuments(): void;
216
243
  /**
217
244
  * Fires whenever the secondary write set gains or loses a URI — never when a
218
- * tracked document's captured version is merely refreshed, which happens on
245
+ * tracked document's snapshot version is merely refreshed, which happens on
219
246
  * every {@link setSourceRoot} and changes nothing a subscriber cares about.
220
247
  *
221
248
  * **This exists so no caller has to know when the set can change.** The set is
222
249
  * usually discovered rather than known, and the discovery point is an
223
- * operation handler naming a node — not a capture. A subscriber that instead
224
- * re-derived the set after each capture would miss exactly that case, and miss
225
- * it silently: the document would simply never be watched, with nothing logged.
250
+ * operation handler naming a node — not a read of the source root. A
251
+ * subscriber that instead re-derived the set after each such read would miss
252
+ * exactly that case, and miss it silently: the document would simply never be
253
+ * watched, with nothing logged.
226
254
  * Announcing the change here moves the obligation to the one place that can
227
255
  * always discharge it.
228
256
  *
@@ -235,25 +263,43 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
235
263
  /** Registered secondary document URIs, in registration order. */
236
264
  get secondaryUris(): readonly string[];
237
265
  /**
238
- * Based-on version captured for `uri` — {@link version} for the primary, the
239
- * value captured at {@link trackSecondaryDocument} (refreshed by
240
- * {@link setSourceRoot}) for a secondary, `undefined` for anything untracked.
266
+ * Snapshot version for `uri` — {@link basedOn} for the primary, the version
267
+ * taken at {@link trackSecondaryDocument} (refreshed by {@link setSourceRoot})
268
+ * for a secondary, `undefined` for anything untracked.
241
269
  *
242
- * `undefined` rather than `0` for an untracked URI deliberately: `0` is a real
270
+ * `undefined` rather than v0 for an untracked URI deliberately: `0` is a real
243
271
  * version meaning "present but never edited", so collapsing the two would let
244
- * a caller gate a write against a document it never captured.
272
+ * a caller gate a write against a document this state never read.
245
273
  */
246
- capturedVersionOf(uri: string): number | undefined;
274
+ snapshotVersionOf(uri: string): SnapshotVersion | undefined;
247
275
  /**
248
- * Read a document's current text-document version through the model service's
249
- * canonicalizing gateway, so a URI spelled through a symlink still resolves to
250
- * the document keyed by its real path rather than stranding at `0` (which
251
- * would silently weaken the conflict gate). Optional-chained on `textDocument`
252
- * so a fixture that omits it does not throw; real Langium documents always
253
- * populate it.
276
+ * Read a document's version out of the live store and mark it as a snapshot,
277
+ * through the model service's canonicalizing gateway so a URI spelled through
278
+ * a symlink still resolves to the document keyed by its real path rather than
279
+ * stranding at `0` (which would silently weaken the conflict gate).
280
+ *
281
+ * **Call this only at the point the source root is read.** It is the one
282
+ * place the framework turns a live version into a snapshot one, and the value
283
+ * is true only because that is where it is called. Called at write time it
284
+ * answers with the version the write is about to be compared against, so the
285
+ * gate passes unconditionally.
286
+ *
287
+ * Falls back to v0 for a URI neither store knows, matching what
288
+ * {@link version} reports for a document that was never opened.
289
+ *
290
+ * **The version of the text store, which the gate compares against.**
291
+ * When the store holds the text the root was parsed from, that is its
292
+ * version, even while the built document still carries an older number.
293
+ * When the store holds other text, `NO_MATCHING_VERSION`, so the write
294
+ * conflicts instead of overwriting text the root never saw: the
295
+ * reconciling states reconcile it, `FullTextHydraniumGlspState` throws the
296
+ * `ConflictError`. When the root keeps no syntax tree to read its text
297
+ * from, the built document's text stands in for it, unless the built
298
+ * document IS the store's, whose text says nothing about what was parsed;
299
+ * that also gets `NO_MATCHING_VERSION`.
254
300
  */
255
- protected readDocumentVersion(uri: string): number;
256
- /** Re-read every registered secondary's version from the document store. */
301
+ protected readSnapshotVersion(uri: string): SnapshotVersion;
302
+ /** Re-take every registered secondary's snapshot version from the document store. */
257
303
  protected refreshSecondaryVersions(): void;
258
304
  /**
259
305
  * Re-capture the source root from the current Langium document,
@@ -263,6 +309,18 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
263
309
  * handlers) must see the root the freshly built document carries.
264
310
  */
265
311
  protected refreshSourceRoot(): void;
312
+ /**
313
+ * The root that `uri`'s text parses to (the text store's, or the built
314
+ * document's when the store holds none), read once the document has
315
+ * validated; `undefined` when it cannot be read.
316
+ *
317
+ * **Parsed afresh, never the built root.** Operation handlers edit the
318
+ * built root in place, so until a rebuild replaces it, it already holds
319
+ * the edit being reconciled, and replaying the edit onto it applies it
320
+ * twice. The root is parsed, not linked: an encoder hook reading a
321
+ * reference's `ref` sees `undefined` on it.
322
+ */
323
+ protected readCurrentRoot(uri: string): Promise<AstNode | undefined>;
266
324
  /**
267
325
  * Wait until the captured document reaches `state`, then run
268
326
  * {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
@@ -320,14 +378,23 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
320
378
  * `JsonModelState` shape meet the framework state via structural
321
379
  * intersection at the recording-command call site.
322
380
  *
323
- * `version` is the based-on text-document version captured at command
324
- * start by `HydraniumGlspRecordingCommand.execute`. Adopters that
325
- * route through `ModelService.update` / `.save` pass it as the args'
326
- * `version` field to opt into the conflict gate; adopters that don't
327
- * care (or whose write path doesn't go through `ModelService`) ignore
328
- * the parameter. Undefined when the writer is not the recording-command
329
- * (e.g. external storage refresh paths).
381
+ * `basedOn` is the snapshot version taken at command start by
382
+ * `HydraniumGlspRecordingCommand.execute`. Adopters that write through the
383
+ * diagram's session forward it as the args' `basedOn` field; adopters whose
384
+ * write path doesn't go through the session ignore it.
385
+ * `'anything'` when the writer is not the recording command (an external
386
+ * storage refresh, an undo replaying a recorded patch), which is a write
387
+ * authored against no particular server version.
388
+ *
389
+ * **Optional, and every implementation must default it to {@link basedOn}
390
+ * rather than to `'anything'`.** Optional is forced: GLSP's `JsonModelState`
391
+ * declares a one-parameter `updateSourceModel` and calls it with one
392
+ * argument, so a second required parameter makes the state unassignable to
393
+ * the slot it has to fill. Defaulting to the state's own snapshot version is
394
+ * what keeps that from costing anything — an operation handler calling
395
+ * `updateSourceModel(model)` gets the gate, and skipping it has to be typed
396
+ * out as `'anything'`.
330
397
  */
331
- abstract updateSourceModel(model: TSourceModel, version?: number): MaybePromise<void>;
398
+ abstract updateSourceModel(model: TSourceModel, basedOn?: BasedOn): MaybePromise<void>;
332
399
  }
333
400
  //# sourceMappingURL=abstract-hydranium-glsp-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-hydranium-glsp-state.d.ts","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ARG } from '@eclipse-glsp/server';
20
20
  import { Emitter } from 'vscode-jsonrpc';
21
21
  import { inject, injectable, optional } from 'inversify';
22
22
  import { DocumentState, URI } from '@hydranium/langium';
23
+ import { asSnapshotVersion, NO_MATCHING_VERSION, TIMED_OUT } from '@hydranium/protocol';
23
24
  import { HydraniumTypes } from './hydranium-shared-core-services.js';
24
25
  import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
25
26
  /**
@@ -79,11 +80,35 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
79
80
  * getters fall back to it before then, so logging is never `undefined`.
80
81
  */
81
82
  baseTracer;
83
+ /**
84
+ * The client session this diagram works as, registered under `clientId` by
85
+ * the source-model storage and ended with the GLSP client session.
86
+ * `undefined` for GLSP's placeholder client, and when the id was held by
87
+ * another participant, in which case the diagram does not load.
88
+ *
89
+ * Every write of the diagram goes through this session, which writes only a
90
+ * document it has open and opens nothing. A one-shot write to a document
91
+ * outside the write set goes through
92
+ * {@link ClientSession.withOpen}, and a document the diagram brings into
93
+ * existence through {@link ClientSession.create}.
94
+ */
95
+ modelSession;
96
+ /**
97
+ * {@link modelSession}, or a throw without one: the diagram never loaded or
98
+ * has ended. Looking `clientId` up through `ModelService.getSession` instead
99
+ * would write as whichever participant holds that id.
100
+ */
101
+ requireModelSession() {
102
+ if (!this.modelSession) {
103
+ throw new Error(`No client session is registered for ${this.clientId}; the diagram cannot write`);
104
+ }
105
+ return this.modelSession;
106
+ }
82
107
  _sourceUri;
83
108
  _sourceRoot;
84
109
  _tracer;
85
- _version = 0;
86
- /** Based-on versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
110
+ _basedOn = asSnapshotVersion(0);
111
+ /** Snapshot versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
87
112
  _secondaryVersions = new Map();
88
113
  /** Backing emitter for {@link onSecondaryUrisChanged}; fired only on a membership change. */
89
114
  secondaryUrisChangedEmitter = new Emitter();
@@ -103,7 +128,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
103
128
  setSourceRoot(uri, root) {
104
129
  this._sourceUri = uri;
105
130
  this._sourceRoot = root;
106
- this._version = this.readDocumentVersion(uri);
131
+ this._basedOn = this.readSnapshotVersion(uri);
107
132
  // Re-read the secondary write set for the same reason the primary is
108
133
  // re-read: the write that brought us here advanced their versions too, and
109
134
  // a stale based-on version would gate the NEXT command against a
@@ -112,7 +137,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
112
137
  this.refreshSecondaryVersions();
113
138
  this.set(SOURCE_URI_ARG, uri);
114
139
  this._tracer = this.baseTracer.withUri(uri);
115
- this.tracer.debug(`Captured source root at doc.version=v${this._version}`);
140
+ this.tracer.debug(`Captured source root at doc.version=v${this._basedOn}`);
116
141
  this.checkDeclaredLanguage(uri);
117
142
  this.index.indexSourceRoot(root, uri);
118
143
  }
@@ -218,32 +243,42 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
218
243
  return this._tracer ?? this.baseTracer;
219
244
  }
220
245
  /**
221
- * Text-document version captured at the last {@link setSourceRoot}
222
- * call. Mirrors the server-side `TextDocuments.version(uri)` counter
223
- * at that point in time — frozen until the next `setSourceRoot`, then
224
- * re-read from `LangiumDocuments`.
246
+ * Snapshot version taken at the last {@link setSourceRoot} call — frozen
247
+ * until the next one, then re-read from the document store.
225
248
  *
226
249
  * Threaded by `HydraniumGlspRecordingCommand` into
227
- * {@link updateSourceModel}'s optional `version` parameter so the
228
- * downstream `ModelService.update` / `.save` call can opt into the
229
- * conflict gate against the captured based-on version. See
250
+ * {@link updateSourceModel} so the downstream session `update` / `save`
251
+ * gates against what the command was authored on. See
230
252
  * `@hydranium/protocol#ConflictError` for the detection contract.
231
253
  *
254
+ * **This, not a number read at write time, is what a write must be gated
255
+ * on.** A version read when the write is issued is the store's current one,
256
+ * so it matches by construction and the gate can never fire.
257
+ */
258
+ get basedOn() {
259
+ return this._basedOn;
260
+ }
261
+ /**
262
+ * Text-document version of {@link basedOn}. Mirrors the server-side
263
+ * `TextDocuments.version(uri)` counter as of the snapshot, or is
264
+ * `NO_MATCHING_VERSION` when the store's text could not be tied to the
265
+ * root (see {@link readSnapshotVersion}).
266
+ *
232
267
  * Falls back to `0` when the document is absent from `LangiumDocuments`
233
- * at capture time — the same observable state callers see for a doc
234
- * that was never opened. Callers that need to distinguish
268
+ * when the snapshot is taken — the same observable state callers see for a
269
+ * doc that was never opened. Callers that need to distinguish
235
270
  * "never-versioned" from "v0" must consult the document registry
236
271
  * directly.
237
272
  */
238
273
  get version() {
239
- return this._version;
274
+ return this._basedOn;
240
275
  }
241
276
  // ============================================================
242
277
  // Secondary documents — the write set beyond the primary
243
278
  // ============================================================
244
279
  /**
245
- * Register `uri` as a document this state also writes, capturing its current
246
- * text-document version.
280
+ * Register `uri` as a document this state also writes, snapshotting its
281
+ * current text-document version.
247
282
  *
248
283
  * A diagram whose layout lives in its own file, or whose canvas creates
249
284
  * elements in a referenced semantic document, writes more than the document
@@ -256,7 +291,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
256
291
  * identified once the operation names the node. What the framework supplies
257
292
  * is the part an adopter cannot reconstruct after the fact — the version each
258
293
  * document was at BEFORE the command mutated anything (see
259
- * {@link capturedVersionOf}). Idempotent; registering the primary is ignored,
294
+ * {@link snapshotVersionOf}). Idempotent; registering the primary is ignored,
260
295
  * since {@link version} already tracks it. Registering a URI not already in
261
296
  * the set fires {@link onSecondaryUrisChanged}.
262
297
  */
@@ -265,7 +300,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
265
300
  return;
266
301
  }
267
302
  const added = !this._secondaryVersions.has(uri);
268
- this._secondaryVersions.set(uri, this.readDocumentVersion(uri));
303
+ this._secondaryVersions.set(uri, this.readSnapshotVersion(uri));
269
304
  if (added) {
270
305
  this.secondaryUrisChangedEmitter.fire();
271
306
  }
@@ -283,14 +318,15 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
283
318
  }
284
319
  /**
285
320
  * Fires whenever the secondary write set gains or loses a URI — never when a
286
- * tracked document's captured version is merely refreshed, which happens on
321
+ * tracked document's snapshot version is merely refreshed, which happens on
287
322
  * every {@link setSourceRoot} and changes nothing a subscriber cares about.
288
323
  *
289
324
  * **This exists so no caller has to know when the set can change.** The set is
290
325
  * usually discovered rather than known, and the discovery point is an
291
- * operation handler naming a node — not a capture. A subscriber that instead
292
- * re-derived the set after each capture would miss exactly that case, and miss
293
- * it silently: the document would simply never be watched, with nothing logged.
326
+ * operation handler naming a node — not a read of the source root. A
327
+ * subscriber that instead re-derived the set after each such read would miss
328
+ * exactly that case, and miss it silently: the document would simply never be
329
+ * watched, with nothing logged.
294
330
  * Announcing the change here moves the obligation to the one place that can
295
331
  * always discharge it.
296
332
  *
@@ -307,35 +343,67 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
307
343
  return [...this._secondaryVersions.keys()];
308
344
  }
309
345
  /**
310
- * Based-on version captured for `uri` — {@link version} for the primary, the
311
- * value captured at {@link trackSecondaryDocument} (refreshed by
312
- * {@link setSourceRoot}) for a secondary, `undefined` for anything untracked.
346
+ * Snapshot version for `uri` — {@link basedOn} for the primary, the version
347
+ * taken at {@link trackSecondaryDocument} (refreshed by {@link setSourceRoot})
348
+ * for a secondary, `undefined` for anything untracked.
313
349
  *
314
- * `undefined` rather than `0` for an untracked URI deliberately: `0` is a real
350
+ * `undefined` rather than v0 for an untracked URI deliberately: `0` is a real
315
351
  * version meaning "present but never edited", so collapsing the two would let
316
- * a caller gate a write against a document it never captured.
352
+ * a caller gate a write against a document this state never read.
317
353
  */
318
- capturedVersionOf(uri) {
354
+ snapshotVersionOf(uri) {
319
355
  if (uri === this._sourceUri) {
320
- return this._version;
356
+ return this._basedOn;
321
357
  }
322
358
  return this._secondaryVersions.get(uri);
323
359
  }
324
360
  /**
325
- * Read a document's current text-document version through the model service's
326
- * canonicalizing gateway, so a URI spelled through a symlink still resolves to
327
- * the document keyed by its real path rather than stranding at `0` (which
328
- * would silently weaken the conflict gate). Optional-chained on `textDocument`
329
- * so a fixture that omits it does not throw; real Langium documents always
330
- * populate it.
361
+ * Read a document's version out of the live store and mark it as a snapshot,
362
+ * through the model service's canonicalizing gateway so a URI spelled through
363
+ * a symlink still resolves to the document keyed by its real path rather than
364
+ * stranding at `0` (which would silently weaken the conflict gate).
365
+ *
366
+ * **Call this only at the point the source root is read.** It is the one
367
+ * place the framework turns a live version into a snapshot one, and the value
368
+ * is true only because that is where it is called. Called at write time it
369
+ * answers with the version the write is about to be compared against, so the
370
+ * gate passes unconditionally.
371
+ *
372
+ * Falls back to v0 for a URI neither store knows, matching what
373
+ * {@link version} reports for a document that was never opened.
374
+ *
375
+ * **The version of the text store, which the gate compares against.**
376
+ * When the store holds the text the root was parsed from, that is its
377
+ * version, even while the built document still carries an older number.
378
+ * When the store holds other text, `NO_MATCHING_VERSION`, so the write
379
+ * conflicts instead of overwriting text the root never saw: the
380
+ * reconciling states reconcile it, `FullTextHydraniumGlspState` throws the
381
+ * `ConflictError`. When the root keeps no syntax tree to read its text
382
+ * from, the built document's text stands in for it, unless the built
383
+ * document IS the store's, whose text says nothing about what was parsed;
384
+ * that also gets `NO_MATCHING_VERSION`.
331
385
  */
332
- readDocumentVersion(uri) {
333
- return this.sharedServices.model.ModelService.getDocument(uri)?.textDocument?.version ?? 0;
386
+ readSnapshotVersion(uri) {
387
+ const document = this.sharedServices.model.ModelService.getDocument(uri);
388
+ const stored = document && this.sharedServices.workspace.TextDocuments.get(uri);
389
+ if (stored) {
390
+ const parsed = document.parseResult.value.$cstNode?.root.fullText;
391
+ if (parsed !== undefined) {
392
+ return parsed === stored.getText() ? asSnapshotVersion(stored.version) : NO_MATCHING_VERSION;
393
+ }
394
+ if (document.textDocument === stored) {
395
+ return NO_MATCHING_VERSION;
396
+ }
397
+ if (stored.version !== document.textDocument.version && stored.getText() === document.textDocument.getText()) {
398
+ return asSnapshotVersion(stored.version);
399
+ }
400
+ }
401
+ return this.sharedServices.model.ModelService.snapshot(uri)?.version ?? asSnapshotVersion(0);
334
402
  }
335
- /** Re-read every registered secondary's version from the document store. */
403
+ /** Re-take every registered secondary's snapshot version from the document store. */
336
404
  refreshSecondaryVersions() {
337
405
  for (const uri of [...this._secondaryVersions.keys()]) {
338
- this._secondaryVersions.set(uri, this.readDocumentVersion(uri));
406
+ this._secondaryVersions.set(uri, this.readSnapshotVersion(uri));
339
407
  }
340
408
  }
341
409
  /**
@@ -359,6 +427,27 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
359
427
  this.setSourceRoot(this._sourceUri, root);
360
428
  }
361
429
  }
430
+ /**
431
+ * The root that `uri`'s text parses to (the text store's, or the built
432
+ * document's when the store holds none), read once the document has
433
+ * validated; `undefined` when it cannot be read.
434
+ *
435
+ * **Parsed afresh, never the built root.** Operation handlers edit the
436
+ * built root in place, so until a rebuild replaces it, it already holds
437
+ * the edit being reconciled, and replaying the edit onto it applies it
438
+ * twice. The root is parsed, not linked: an encoder hook reading a
439
+ * reference's `ref` sees `undefined` on it.
440
+ */
441
+ async readCurrentRoot(uri) {
442
+ const modelService = this.sharedServices.model.ModelService;
443
+ if (!(await modelService.validated(uri).catch(() => undefined))) {
444
+ return undefined;
445
+ }
446
+ const text = this.sharedServices.workspace.TextDocuments.get(uri)?.getText() ?? modelService.getDocument(uri)?.textDocument.getText();
447
+ return text === undefined
448
+ ? undefined
449
+ : this.sharedServices.workspace.LangiumDocumentFactory.fromString(text, URI.parse(uri)).parseResult.value;
450
+ }
362
451
  /**
363
452
  * Wait until the captured document reaches `state`, then run
364
453
  * {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
@@ -378,29 +467,19 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
378
467
  async readyWithTimeout(state) {
379
468
  const uri = this._sourceUri;
380
469
  const stopwatch = this.sharedServices.Clock.stopwatch();
381
- let timer;
382
- const timeout = new Promise((resolve, reject) => {
383
- timer = this.sharedServices.Clock.setTimer(() => {
384
- const elapsed = Math.round(stopwatch.elapsedMs);
385
- // Via the canonicalizing gateway (see `readDocumentVersion`), so a
386
- // symlinked `_sourceUri` is not reported as a hard timeout.
387
- const doc = this.sharedServices.model.ModelService.getDocument(uri);
388
- if (doc && doc.state >= state) {
389
- this.logger.warn(`Missed '${DocumentState[state]}' notification after ${elapsed}ms; document is already at state ` +
390
- `'${DocumentState[doc.state]}'. Likely a Langium build-phase event race.`);
391
- resolve();
392
- }
393
- else {
394
- reject(this.buildReadyTimeoutError(state, elapsed));
395
- }
396
- }, this.readyTimeoutMs);
397
- });
398
- try {
399
- await Promise.race([this.sharedServices.model.ModelService.waitForDocumentState(uri, state), timeout]);
470
+ const reached = this.sharedServices.model.ModelService.waitForDocumentState(uri, state);
471
+ if ((await this.sharedServices.Clock.raceTimer(reached, this.readyTimeoutMs)) !== TIMED_OUT) {
472
+ return;
400
473
  }
401
- finally {
402
- timer?.dispose();
474
+ const elapsed = Math.round(stopwatch.elapsedMs);
475
+ // Through the model service's canonicalizing gateway, so a symlinked
476
+ // `_sourceUri` is not reported as a hard timeout.
477
+ const doc = this.sharedServices.model.ModelService.getDocument(uri);
478
+ if (!doc || doc.state < state) {
479
+ throw this.buildReadyTimeoutError(state, elapsed);
403
480
  }
481
+ this.logger.warn(`Missed '${DocumentState[state]}' notification after ${elapsed}ms; document is already at state ` +
482
+ `'${DocumentState[doc.state]}'. Likely a Langium build-phase event race.`);
404
483
  }
405
484
  /**
406
485
  * Hook for post-{@link ready} work. Default refreshes the captured
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-hydranium-glsp-state.js","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;;AAElF,OAAO,EAAE,iBAAiB,EAAqB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAc,MAA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CAihB/C"}
@@ -8,7 +8,7 @@
8
8
  ********************************************************************************/
9
9
  import { type JsonModelState } from '@eclipse-glsp/server';
10
10
  import { type AstNode } from '@hydranium/langium';
11
- import { type MaybePromise } from '@hydranium/protocol';
11
+ import { type BasedOn, type MaybePromise } from '@hydranium/protocol';
12
12
  import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
13
13
  /** Whole-document-text source model: the serialised text of the source root. */
14
14
  export interface FullTextSourceModel {
@@ -27,17 +27,17 @@ export interface FullTextSourceModel {
27
27
  * `serializer.Serializer` reached via `sharedServices.ServiceRegistry`
28
28
  * (so multi-grammar workspaces route to the right serializer). `MaybePromise`
29
29
  * because serialization may be async; the sync fast path is preserved.
30
- * - {@link updateSourceModel} pushes the text back through
31
- * `ModelService.update` (which accepts a raw text payload) and captures the
32
- * re-parsed root.
30
+ * - {@link updateSourceModel} pushes the text back through the diagram's
31
+ * session (`update` accepts a raw text payload) and captures the re-parsed
32
+ * root, gated on the caller's `basedOn`; it throws without a session.
33
33
  *
34
- * No `baseline` / conflict reconcile: a whole-document model has exactly one
34
+ * No `base` / conflict reconcile: a whole-document model has exactly one
35
35
  * field, so every concurrent edit is a same-field collision and undo / redo
36
36
  * degrade to drop-on-divergence. Adopters that need field-level undo use
37
37
  * `ReconcilingTransferHydraniumGlspState` instead.
38
38
  */
39
39
  export declare class FullTextHydraniumGlspState<TRoot extends AstNode> extends AbstractHydraniumGlspState<TRoot, FullTextSourceModel> implements JsonModelState<FullTextSourceModel> {
40
40
  get sourceModel(): MaybePromise<FullTextSourceModel>;
41
- updateSourceModel(model: FullTextSourceModel): Promise<void>;
41
+ updateSourceModel(model: FullTextSourceModel, basedOn?: BasedOn): Promise<void>;
42
42
  }
43
43
  //# sourceMappingURL=full-text-hydranium-glsp-state.d.ts.map