@hydranium/core 1.0.0-next.114 → 1.0.0-next.117

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 (66) hide show
  1. package/README.md +3 -1
  2. package/lib/documents/ast-document-manager.d.ts +52 -2
  3. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  4. package/lib/documents/ast-document-manager.js +67 -5
  5. package/lib/documents/ast-document-manager.js.map +1 -1
  6. package/lib/documents/client-session-errors.d.ts +44 -0
  7. package/lib/documents/client-session-errors.d.ts.map +1 -0
  8. package/lib/documents/client-session-errors.js +57 -0
  9. package/lib/documents/client-session-errors.js.map +1 -0
  10. package/lib/documents/client-session-registry.d.ts +118 -0
  11. package/lib/documents/client-session-registry.d.ts.map +1 -0
  12. package/lib/documents/client-session-registry.js +171 -0
  13. package/lib/documents/client-session-registry.js.map +1 -0
  14. package/lib/documents/hydranium-text-documents.d.ts +77 -25
  15. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  16. package/lib/documents/hydranium-text-documents.js +143 -52
  17. package/lib/documents/hydranium-text-documents.js.map +1 -1
  18. package/lib/documents/index.d.ts +2 -0
  19. package/lib/documents/index.d.ts.map +1 -1
  20. package/lib/documents/index.js +2 -0
  21. package/lib/documents/index.js.map +1 -1
  22. package/lib/langium/integrity/integrity-rule.d.ts +13 -5
  23. package/lib/langium/integrity/integrity-rule.d.ts.map +1 -1
  24. package/lib/langium/integrity/integrity-rule.js.map +1 -1
  25. package/lib/langium/integrity/integrity-service.d.ts +37 -6
  26. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  27. package/lib/langium/integrity/integrity-service.js +81 -17
  28. package/lib/langium/integrity/integrity-service.js.map +1 -1
  29. package/lib/langium/model-service/client-session.d.ts +120 -0
  30. package/lib/langium/model-service/client-session.d.ts.map +1 -0
  31. package/lib/langium/model-service/client-session.js +175 -0
  32. package/lib/langium/model-service/client-session.js.map +1 -0
  33. package/lib/langium/model-service/index.d.ts +1 -0
  34. package/lib/langium/model-service/index.d.ts.map +1 -1
  35. package/lib/langium/model-service/index.js +1 -0
  36. package/lib/langium/model-service/index.js.map +1 -1
  37. package/lib/langium/model-service/model-service.d.ts +76 -8
  38. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  39. package/lib/langium/model-service/model-service.js +148 -21
  40. package/lib/langium/model-service/model-service.js.map +1 -1
  41. package/lib/lsp/hydranium-document-update-handler.d.ts +6 -0
  42. package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
  43. package/lib/lsp/hydranium-document-update-handler.js +20 -3
  44. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  45. package/lib/testing/stub-ast-document-manager.d.ts +4 -3
  46. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  47. package/lib/testing/stub-ast-document-manager.js +3 -0
  48. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  49. package/lib/testing/stub-hydranium-text-documents.d.ts +13 -5
  50. package/lib/testing/stub-hydranium-text-documents.d.ts.map +1 -1
  51. package/lib/testing/stub-hydranium-text-documents.js +45 -14
  52. package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
  53. package/package.json +5 -5
  54. package/src/documents/ast-document-manager.ts +107 -6
  55. package/src/documents/client-session-errors.ts +54 -0
  56. package/src/documents/client-session-registry.ts +211 -0
  57. package/src/documents/hydranium-text-documents.ts +158 -55
  58. package/src/documents/index.ts +2 -0
  59. package/src/langium/integrity/integrity-rule.ts +13 -5
  60. package/src/langium/integrity/integrity-service.ts +84 -17
  61. package/src/langium/model-service/client-session.ts +257 -0
  62. package/src/langium/model-service/index.ts +1 -0
  63. package/src/langium/model-service/model-service.ts +176 -21
  64. package/src/lsp/hydranium-document-update-handler.ts +22 -4
  65. package/src/testing/stub-ast-document-manager.ts +7 -2
  66. package/src/testing/stub-hydranium-text-documents.ts +62 -18
package/README.md CHANGED
@@ -27,7 +27,9 @@ and so does every other head package (`@hydranium/data-server`,
27
27
  `HydraniumTextDocuments`, `WritableFileSystemProvider` and `SelfSaveRegistry`
28
28
  generalise the LSP document lifecycle to several co-editing heads, so an edit
29
29
  made on one surface is observable on the others without a head-to-head
30
- synchronisation protocol.
30
+ synchronisation protocol. A participant works through a `ClientSession` from
31
+ `ModelService.createSession`, which writes only what it has open; see
32
+ [client sessions](../../docs/concepts/client-sessions.md).
31
33
  - **The projection the non-LSP heads build on:** `ModelService` (the in-process
32
34
  workspace facade), `TransferEncoder` (AST → transfer model), and the
33
35
  `Serializer` slot.
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import { type CloseModelArgs, type Tracer, type TransferSavedEvent, type TransferUpdatedEvent, type OpenModelArgs, type SnapshotVersion } from '@hydranium/protocol';
9
+ import { type CanonicalUri, type CloseModelArgs, type Tracer, type TransferSavedEvent, type TransferUpdatedEvent, type OpenModelArgs, type SnapshotVersion } from '@hydranium/protocol';
10
10
  import { type AstNode, type DocumentBuilder, type FileSystemProvider, type LangiumDocument, type LangiumDocuments } from '@hydranium/langium';
11
11
  import { type LogNameOptions } from '../langium/diagnostics/logger.js';
12
12
  import { type AstDiagnostic } from '../langium/validation/document-validator.js';
@@ -131,7 +131,18 @@ export type AstDocumentUpdatedEvent<TAst extends AstNode, TDiagnostic extends As
131
131
  /** Save event delivered by {@link AstDocumentManager.onSave} — typed alias over the generic event wrapper. */
132
132
  export type AstDocumentSavedEvent<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic> = TransferSavedEvent<AstDocument<TAst, TDiagnostic>>;
133
133
  /** Construction options for {@link AstDocumentManager}. */
134
- export type AstDocumentManagerOptions = LogNameOptions;
134
+ export interface AstDocumentManagerOptions extends LogNameOptions {
135
+ /**
136
+ * Skip a queued save of a URI when a newer save of it is queued behind. The
137
+ * newer save took its text later, so disk ends the same with fewer writes.
138
+ * A skipped save announces nothing and takes the newer save's outcome: it
139
+ * resolves when that one lands and rejects with its error when it fails,
140
+ * since disk then holds neither text. Defaults to `false`: every save
141
+ * writes. The framework binds the manager without options, so turning this
142
+ * on means rebinding `AstDocumentManager` with them.
143
+ */
144
+ readonly coalesceSaves?: boolean;
145
+ }
135
146
  /**
136
147
  * The document slot the model server and the integrity service talk to:
137
148
  * open/close/update/save plus the AST-typed event streams, with the LSP
@@ -152,7 +163,27 @@ export interface AstDocumentManager<TAst extends AstNode, TDiagnostic extends As
152
163
  isOpen(uri: string): boolean;
153
164
  /** Apply `text` as `clientId`'s edit. Resolves to the resulting text-document version. */
154
165
  update(uri: string, text: string, clientId: string): Promise<number>;
166
+ /**
167
+ * Write the document's current text to disk through the URI's disk queue.
168
+ * The text is taken when this is called, so saves of one URI land in the
169
+ * order they were called.
170
+ */
155
171
  save(uri: string, clientId: string): Promise<void>;
172
+ /**
173
+ * Run `task` once every disk task already queued for `uri` has settled, and
174
+ * before any queued after it. Every server-side disk access of a file that
175
+ * must not interleave with its saves goes through here: two writes of one
176
+ * file that bypass it can land in either order, and the older text then
177
+ * stays on disk. Tasks of different URIs run in parallel. A task that has
178
+ * nothing to do still resolves once the tasks before it have settled.
179
+ *
180
+ * A task must not await a build, nor a save, another disk task or an open
181
+ * of a document no client has open, all of the same URI: a build's
182
+ * integrity repair queues its own write here and the build waits for it,
183
+ * and such an open reads the file here, so a task waiting on either queued
184
+ * behind it never resolves, which wedges the URI's queue for good.
185
+ */
186
+ queueDiskTask<T>(uri: string, task: () => Promise<T>): Promise<T>;
156
187
  onUpdate(uri: string, listener: (event: AstDocumentUpdatedEvent<TAst, TDiagnostic>) => void): Disposable;
157
188
  onSave(uri: string, listener: (event: AstDocumentSavedEvent<TAst, TDiagnostic>) => void | Promise<void>): Disposable;
158
189
  onClientClosed(uri: string, clientId: string, listener: () => void): Disposable;
@@ -194,6 +225,16 @@ export interface AstDocumentManager<TAst extends AstNode, TDiagnostic extends As
194
225
  export declare class DefaultAstDocumentManager<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic> implements AstDocumentManager<TAst, TDiagnostic> {
195
226
  protected readonly services: ServerSharedServices;
196
227
  protected lastUpdate?: UpdateInfo;
228
+ /**
229
+ * Per canonical URI, the settling of the last disk task queued for it; the
230
+ * next task chains behind it. An entry leaves once its URI's queue is idle.
231
+ * Kept outside the workspace lock, whose `write` cancels the write before
232
+ * it: a save cancelled that way reports success for text it never wrote.
233
+ */
234
+ protected readonly diskQueues: Map<CanonicalUri, Promise<void>>;
235
+ /** Per canonical URI, the newest save queued for it, which {@link coalesceSaves} lets older queued saves defer to. */
236
+ protected readonly newestSaves: Map<CanonicalUri, Promise<void>>;
237
+ protected readonly coalesceSaves: boolean;
197
238
  protected readonly textDocuments: HydraniumTextDocuments<TextDocument>;
198
239
  protected readonly fileSystemProvider: WritableFileSystemProvider;
199
240
  protected readonly langiumDocs: LangiumDocuments;
@@ -262,6 +303,12 @@ export declare class DefaultAstDocumentManager<TAst extends AstNode, TDiagnostic
262
303
  * callers don't need to pass it — the manager owns content and version
263
304
  * sequencing.
264
305
  *
306
+ * The text is taken synchronously, before the save waits in the URI's disk
307
+ * queue; the compare and the write run in the queue. Taken later, a save
308
+ * that waits behind another writes whatever the store holds when its turn
309
+ * comes, edits made after the call included, and announces that text under
310
+ * its own client id.
311
+ *
265
312
  * **The write is skipped when the file already holds that text; the
266
313
  * notification is not.** A save announces that the content is on disk, which
267
314
  * is true either way — so a subscriber clearing a dirty marker or reacting to
@@ -271,6 +318,9 @@ export declare class DefaultAstDocumentManager<TAst extends AstNode, TDiagnostic
271
318
  * Throws if no document is open for `uri`.
272
319
  */
273
320
  save(uri: string, clientId: string): Promise<void>;
321
+ /** Write `text` to `uri` unless the file already holds it, then announce the save. Runs inside the URI's disk queue. */
322
+ protected writeSave(uri: CanonicalUri, text: string, clientId: string): Promise<void>;
323
+ queueDiskTask<T>(uri: string, task: () => Promise<T>): Promise<T>;
274
324
  /**
275
325
  * Whether the file at `uri` already holds `text`.
276
326
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ast-document-manager.d.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aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgBjE;;;;;;;;OAQG;cACa,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOxE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAKtC;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;cAIrC,kCAAkC,CAC/C,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,MAAoC,EAChD,OAAO,SAAI,EACX,IAAI,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;IAW5B;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;CAGpF"}
@@ -72,6 +72,16 @@ export var AstDocument;
72
72
  export class DefaultAstDocumentManager {
73
73
  services;
74
74
  lastUpdate;
75
+ /**
76
+ * Per canonical URI, the settling of the last disk task queued for it; the
77
+ * next task chains behind it. An entry leaves once its URI's queue is idle.
78
+ * Kept outside the workspace lock, whose `write` cancels the write before
79
+ * it: a save cancelled that way reports success for text it never wrote.
80
+ */
81
+ diskQueues = new Map();
82
+ /** Per canonical URI, the newest save queued for it, which {@link coalesceSaves} lets older queued saves defer to. */
83
+ newestSaves = new Map();
84
+ coalesceSaves;
75
85
  textDocuments;
76
86
  fileSystemProvider;
77
87
  langiumDocs;
@@ -86,10 +96,17 @@ export class DefaultAstDocumentManager {
86
96
  this.documentBuilder = services.workspace.DocumentBuilder;
87
97
  this.uriPolicy = services.workspace.DocumentUriPolicy;
88
98
  this.tracer = services.Tracer.for(options.logName ?? 'AstDocumentManager').trace('instantiated');
99
+ this.coalesceSaves = options.coalesceSaves ?? false;
89
100
  this.textDocuments.onDidOpen(event => this.open({ clientId: event.clientId, uri: event.document.uri, languageId: event.document.languageId }));
90
101
  this.textDocuments.onDidClose(event => this.close({ clientId: event.clientId, uri: event.document.uri }));
91
102
  this.documentBuilder.onUpdate((changed, deleted) => {
92
103
  this.lastUpdate = { changed, deleted };
104
+ // The only place a deletion is observable: `DocumentBuilder.update`
105
+ // removes a deleted document before it builds anything, so no phase
106
+ // listener ever sees it.
107
+ for (const uri of deleted) {
108
+ this.textDocuments.notifyDocumentDeleted(uri.toString());
109
+ }
93
110
  });
94
111
  // Content transitions for CLOSED documents bypass the text store: the
95
112
  // last-close revert and watched-file changes rebuild from disk into a
@@ -268,6 +285,12 @@ export class DefaultAstDocumentManager {
268
285
  * callers don't need to pass it — the manager owns content and version
269
286
  * sequencing.
270
287
  *
288
+ * The text is taken synchronously, before the save waits in the URI's disk
289
+ * queue; the compare and the write run in the queue. Taken later, a save
290
+ * that waits behind another writes whatever the store holds when its turn
291
+ * comes, edits made after the call included, and announces that text under
292
+ * its own client id.
293
+ *
271
294
  * **The write is skipped when the file already holds that text; the
272
295
  * notification is not.** A save announces that the content is on disk, which
273
296
  * is true either way — so a subscriber clearing a dirty marker or reacting to
@@ -286,12 +309,44 @@ export class DefaultAstDocumentManager {
286
309
  throw new Error(`Document ${uri} hasn't been opened for saving yet`);
287
310
  }
288
311
  const text = document.getText();
289
- if (!(await this.matchesDisk(canonical, text))) {
290
- await this.tracer.with(canonical).time(`Write file (${text.length} bytes, from ${clientId})`,
312
+ let supersededBy;
313
+ const saved = this.queueDiskTask(canonical, async () => {
314
+ const newest = this.newestSaves.get(canonical);
315
+ if (this.coalesceSaves && newest !== saved) {
316
+ supersededBy = newest;
317
+ return;
318
+ }
319
+ await this.writeSave(canonical, text, clientId);
320
+ })
321
+ .then(() => supersededBy)
322
+ .finally(() => {
323
+ if (this.newestSaves.get(canonical) === saved) {
324
+ this.newestSaves.delete(canonical);
325
+ }
326
+ });
327
+ this.newestSaves.set(canonical, saved);
328
+ return saved;
329
+ }
330
+ /** Write `text` to `uri` unless the file already holds it, then announce the save. Runs inside the URI's disk queue. */
331
+ async writeSave(uri, text, clientId) {
332
+ if (!(await this.matchesDisk(uri, text))) {
333
+ await this.tracer.with(uri).time(`Write file (${text.length} bytes, from ${clientId})`,
291
334
  // Async write so a slow disk does not block the event loop for the duration of the fs call.
292
- () => this.fileSystemProvider.writeFile(UriUtils.toUri(canonical), text), 'debug');
335
+ () => this.fileSystemProvider.writeFile(UriUtils.toUri(uri), text), 'debug');
293
336
  }
294
- this.textDocuments.notifyDidSaveTextDocument({ textDocument: TextDocumentIdentifier.create(canonical), text }, clientId);
337
+ this.textDocuments.notifyDidSaveTextDocument({ textDocument: TextDocumentIdentifier.create(uri), text }, clientId);
338
+ }
339
+ queueDiskTask(uri, task) {
340
+ const key = this.uriPolicy.canonicalUri(uri);
341
+ const result = (this.diskQueues.get(key) ?? Promise.resolve()).then(task);
342
+ const settled = result.then(() => undefined, () => undefined);
343
+ this.diskQueues.set(key, settled);
344
+ void settled.then(() => {
345
+ if (this.diskQueues.get(key) === settled) {
346
+ this.diskQueues.delete(key);
347
+ }
348
+ });
349
+ return result;
295
350
  }
296
351
  /**
297
352
  * Whether the file at `uri` already holds `text`.
@@ -326,7 +381,14 @@ export class DefaultAstDocumentManager {
326
381
  return this.langiumDocs.getDocument(UriUtils.toUri(this.uriPolicy.canonicalUri(uri)));
327
382
  }
328
383
  async createDocumentFromTextOrFileSystem(uri, languageId = this.resolveLanguageId(uri), version = 0, text) {
329
- return { uri, languageId, version, text: text ?? (await this.fileSystemProvider.readFile(UriUtils.toUri(uri))) };
384
+ // Read in the disk queue: a read beside a queued save of the file returns
385
+ // the text from before it, and the document then opens on that.
386
+ return {
387
+ uri,
388
+ languageId,
389
+ version,
390
+ text: text ?? (await this.queueDiskTask(uri, () => this.fileSystemProvider.readFile(UriUtils.toUri(uri))))
391
+ };
330
392
  }
331
393
  /**
332
394
  * Hook for subclasses that want to re-shape the emitted document (e.g. inject
@@ -1 +1 @@
1
- {"version":3,"file":"ast-document-manager.js","sourceRoot":"","sources":["../../src/documents/ast-document-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAMJ,iBAAiB,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGJ,aAAa,EAIb,QAAQ,EACV,MAAM,oBAAoB,CAAC;AAqD5B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAyB,MAAM,gCAAgC,CAAC;AAE/F,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAqCpD,MAAM,KAAW,WAAW,CA6C3B;AA7CD,WAAiB,WAAW;IACzB;;;;;OAKG;IACH,SAAgB,MAAM,CACnB,GAAW,EACX,OAAe,EACf,IAAU,EACV,cAA6B,EAAE;QAE/B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC1E,CAAC;IAPe,kBAAM,SAOrB,CAAA;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAgB,IAAI,CACjB,QAAyB;QAEzB,OAAO,MAAM,CACV,QAAQ,CAAC,YAAY,CAAC,GAAG,EACzB,QAAQ,CAAC,YAAY,CAAC,OAAO,EAC7B,QAAQ,CAAC,WAAW,CAAC,KAAa,EAClC,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAkB,CAC/C,CAAC;IACL,CAAC;IATe,gBAAI,OASnB,CAAA;AACJ,CAAC,EA7CgB,WAAW,KAAX,WAAW,QA6C3B;AA4DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO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,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;IAES,KAAK,CAAC,kCAAkC,CAC/C,GAAW,EACX,aAAqB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAChD,OAAO,GAAG,CAAC,EACX,IAAa;QAEb,0EAA0E;QAC1E,gEAAgE;QAChE,OAAO;YACJ,GAAG;YACH,UAAU;YACV,OAAO;YACP,IAAI,EAAE,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC5G,CAAC;IACL,CAAC;IAED;;;;OAIG;IACO,aAAa,CAAC,QAAyB;QAC9C,OAAO,WAAW,CAAC,IAAI,CAAoB,QAAQ,CAAC,CAAC;IACxD,CAAC;CACH"}
@@ -0,0 +1,44 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, 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
+ /**
10
+ * Thrown by every call on a client session after it ended, and by an open that
11
+ * was still in flight when its session ended.
12
+ *
13
+ * The message names the client id, so it is addressed to whoever composes the
14
+ * system rather than to an end user.
15
+ */
16
+ export declare class SessionClosedError extends Error {
17
+ readonly clientId: string;
18
+ constructor(clientId: string);
19
+ }
20
+ /**
21
+ * Thrown when a client session writes a document it does not have open.
22
+ *
23
+ * A session writes only what it has open, so this is the answer both to a write
24
+ * that never opened and to one whose open was closed underneath it — by the
25
+ * session itself, or by the document being deleted.
26
+ */
27
+ export declare class DocumentNotOpenError extends Error {
28
+ readonly uri: string;
29
+ readonly clientId: string;
30
+ constructor(uri: string, clientId: string);
31
+ }
32
+ /**
33
+ * Thrown when a client session is started under an id that is already live in
34
+ * the process, or that the framework reserves for itself.
35
+ *
36
+ * Ids are unique process-wide because the id is also the author label on every
37
+ * version and the key a client recognises its own echoes by; two participants
38
+ * sharing one would each take the other's writes for their own.
39
+ */
40
+ export declare class DuplicateClientIdError extends Error {
41
+ readonly clientId: string;
42
+ constructor(clientId: string);
43
+ }
44
+ //# sourceMappingURL=client-session-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-session-errors.d.ts","sourceRoot":"","sources":["../../src/documents/client-session-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAIvC;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBADhB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM;CAK9B;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAIvC"}
@@ -0,0 +1,57 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, 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
+ /**
10
+ * Thrown by every call on a client session after it ended, and by an open that
11
+ * was still in flight when its session ended.
12
+ *
13
+ * The message names the client id, so it is addressed to whoever composes the
14
+ * system rather than to an end user.
15
+ */
16
+ export class SessionClosedError extends Error {
17
+ clientId;
18
+ constructor(clientId) {
19
+ super(`Client session ${clientId} is closed`);
20
+ this.clientId = clientId;
21
+ this.name = 'SessionClosedError';
22
+ }
23
+ }
24
+ /**
25
+ * Thrown when a client session writes a document it does not have open.
26
+ *
27
+ * A session writes only what it has open, so this is the answer both to a write
28
+ * that never opened and to one whose open was closed underneath it — by the
29
+ * session itself, or by the document being deleted.
30
+ */
31
+ export class DocumentNotOpenError extends Error {
32
+ uri;
33
+ clientId;
34
+ constructor(uri, clientId) {
35
+ super(`Document ${uri} is not open in client session ${clientId}`);
36
+ this.uri = uri;
37
+ this.clientId = clientId;
38
+ this.name = 'DocumentNotOpenError';
39
+ }
40
+ }
41
+ /**
42
+ * Thrown when a client session is started under an id that is already live in
43
+ * the process, or that the framework reserves for itself.
44
+ *
45
+ * Ids are unique process-wide because the id is also the author label on every
46
+ * version and the key a client recognises its own echoes by; two participants
47
+ * sharing one would each take the other's writes for their own.
48
+ */
49
+ export class DuplicateClientIdError extends Error {
50
+ clientId;
51
+ constructor(clientId) {
52
+ super(`Client id ${clientId} is already in use`);
53
+ this.clientId = clientId;
54
+ this.name = 'DuplicateClientIdError';
55
+ }
56
+ }
57
+ //# sourceMappingURL=client-session-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-session-errors.js","sourceRoot":"","sources":["../../src/documents/client-session-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;GAMG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACrB;IAArB,YAAqB,QAAgB;QAClC,KAAK,CAAC,kBAAkB,QAAQ,YAAY,CAAC,CAAC;QAD5B,aAAQ,GAAR,QAAQ,CAAQ;QAElC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACpC,CAAC;CACH;AAED;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAEhC;IACA;IAFZ,YACY,GAAW,EACX,QAAgB;QAEzB,KAAK,CAAC,YAAY,GAAG,kCAAkC,QAAQ,EAAE,CAAC,CAAC;QAH1D,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAQ;QAGzB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACtC,CAAC;CACH;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACzB;IAArB,YAAqB,QAAgB;QAClC,KAAK,CAAC,aAAa,QAAQ,oBAAoB,CAAC,CAAC;QAD/B,aAAQ,GAAR,QAAQ,CAAQ;QAElC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACxC,CAAC;CACH"}
@@ -0,0 +1,118 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, 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 CanonicalUri } from '@hydranium/protocol';
10
+ import { Emitter, type Event } from 'vscode-languageserver';
11
+ /**
12
+ * What a client session states about one of its opens, kept per
13
+ * `(session, uri)` for as long as that open lasts.
14
+ *
15
+ * Any object type: an adopter declares the fields its own open path reads and
16
+ * passes that type as a session's `TOpenOptions`. Stored per open rather than
17
+ * per document, so two sessions opening one document with different options
18
+ * each keep their own.
19
+ */
20
+ export type OpenOptions = object;
21
+ /**
22
+ * `'closing'` covers the span in which a session's opens are being closed. The
23
+ * id is still taken then, and the session can open nothing more, so an open
24
+ * issued from a close listener cannot outlive the session that made it.
25
+ */
26
+ export type ClientSessionState = 'live' | 'closing';
27
+ /** Delivered by {@link ClientSessionRegistry.onDidCloseSession}. */
28
+ export interface ClientSessionClosedEvent {
29
+ readonly clientId: string;
30
+ }
31
+ /**
32
+ * The ids no client session may be started under: the wire's well-known ids and
33
+ * the integrity author. Each names a framework participant rather than a
34
+ * client, and a session holding one would have its writes read as that
35
+ * participant's.
36
+ */
37
+ export declare const RESERVED_CLIENT_IDS: readonly string[];
38
+ /**
39
+ * Which client has which document open, and which client ids are registered
40
+ * sessions — the open facts every head shares, composed by
41
+ * `HydraniumTextDocuments`.
42
+ *
43
+ * Opens are recorded for every client id, registered or not. An id that was
44
+ * never registered is a client that predates sessions and writes through the
45
+ * flat `clientId` calls; its opens are tracked exactly as a session's are, and
46
+ * only the session table ignores it. Requiring registration before an open
47
+ * would refuse every such client.
48
+ *
49
+ * One open per `(client, uri)`, with no reference count: a repeat open changes
50
+ * nothing, and one close ends it.
51
+ *
52
+ * Pure bookkeeping. Closing a document is the store's job, because a close has
53
+ * to reach the text store and its listeners; the store asks this class what to
54
+ * close and records each close here.
55
+ */
56
+ export declare class ClientSessionRegistry {
57
+ protected readonly sessions: Map<string, ClientSessionState>;
58
+ protected readonly clientsByUri: Map<CanonicalUri, Set<string>>;
59
+ /** Each client's opens, with the options it opened them with. */
60
+ protected readonly opensByClient: Map<string, Map<CanonicalUri, object | undefined>>;
61
+ protected readonly reservedIds: ReadonlySet<string>;
62
+ protected readonly sessionClosedEmitter: Emitter<ClientSessionClosedEvent>;
63
+ /** Fires once a session has been removed from the table, after all its opens closed. */
64
+ get onDidCloseSession(): Event<ClientSessionClosedEvent>;
65
+ /**
66
+ * Enter `clientId` in the session table.
67
+ *
68
+ * Throws {@link DuplicateClientIdError} when the id is live anywhere in the
69
+ * process: reserved, registered (including by a session that is still
70
+ * closing), or holding opens as a client that is not a session. The last
71
+ * matters because the id is the author label and the echo key, and a
72
+ * session sharing one with another client would take that client's writes
73
+ * for its own.
74
+ */
75
+ register(clientId: string): void;
76
+ /** Whether `clientId` is in the session table, live or closing. */
77
+ isRegistered(clientId: string): boolean;
78
+ /**
79
+ * Mark `clientId` as closing and return every URI it has open, as a copy the
80
+ * caller can close while this registry changes underneath it.
81
+ */
82
+ beginClose(clientId: string): CanonicalUri[];
83
+ /** Remove `clientId` from the session table and announce it. A no-op for an id that is not registered. */
84
+ unregister(clientId: string): void;
85
+ /**
86
+ * Record that `clientId` opened `uri`, with no options. Returns `false` when
87
+ * it already had it open, in which case nothing changes.
88
+ *
89
+ * Throws {@link SessionClosedError} for a session that is closing.
90
+ */
91
+ addOpen(uri: CanonicalUri, clientId: string): boolean;
92
+ /** Record that `clientId` closed `uri`. Returns `false` when it did not have it open. */
93
+ removeOpen(uri: CanonicalUri, clientId: string): boolean;
94
+ /** Whether `clientId` has `uri` open. */
95
+ isOpenIn(uri: CanonicalUri, clientId: string): boolean;
96
+ /** Whether any client has `uri` open. */
97
+ isOpen(uri: CanonicalUri): boolean;
98
+ /** The clients that have `uri` open, in the order they opened it. */
99
+ clientsOf(uri: CanonicalUri): string[];
100
+ /** The URIs `clientId` has open, in the order it opened them. */
101
+ opensOf(clientId: string): CanonicalUri[];
102
+ /** Every document open in at least one client, with the clients that have it open. */
103
+ openDocuments(): Array<{
104
+ readonly uri: CanonicalUri;
105
+ readonly clients: string[];
106
+ }>;
107
+ /** The options `clientId` opened `uri` with, or `undefined` when it gave none or does not have it open. */
108
+ openOptions(uri: CanonicalUri, clientId: string): OpenOptions | undefined;
109
+ /** Replace the options of an existing open. Does nothing when `clientId` does not have `uri` open. */
110
+ setOpenOptions(uri: CanonicalUri, clientId: string, options: OpenOptions | undefined): void;
111
+ /**
112
+ * Forget every session and open without announcing anything. Subscriptions
113
+ * stay, so a listener registered before the clear hears the sessions that
114
+ * end after it.
115
+ */
116
+ clear(): void;
117
+ }
118
+ //# sourceMappingURL=client-session-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-session-registry.d.ts","sourceRoot":"","sources":["../../src/documents/client-session-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM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