@hydranium/protocol 1.0.0-next.123 → 1.0.0-next.127

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 (94) hide show
  1. package/lib/client/data-connection.d.ts +35 -4
  2. package/lib/client/data-connection.d.ts.map +1 -1
  3. package/lib/client/data-connection.js +67 -5
  4. package/lib/client/data-connection.js.map +1 -1
  5. package/lib/client/data-events.d.ts +5 -1
  6. package/lib/client/data-events.d.ts.map +1 -1
  7. package/lib/client/data-events.js +7 -0
  8. package/lib/client/data-events.js.map +1 -1
  9. package/lib/client/data-session.d.ts +76 -8
  10. package/lib/client/data-session.d.ts.map +1 -1
  11. package/lib/client/data-session.js +108 -19
  12. package/lib/client/data-session.js.map +1 -1
  13. package/lib/client/index.d.ts +3 -1
  14. package/lib/client/index.d.ts.map +1 -1
  15. package/lib/client/index.js +3 -1
  16. package/lib/client/index.js.map +1 -1
  17. package/lib/client/message-relay.d.ts +1 -1
  18. package/lib/client/message-relay.js +1 -1
  19. package/lib/client/post-message-transport.d.ts +64 -3
  20. package/lib/client/post-message-transport.d.ts.map +1 -1
  21. package/lib/client/post-message-transport.js +175 -1
  22. package/lib/client/post-message-transport.js.map +1 -1
  23. package/lib/client/rpc-connection.d.ts +6 -0
  24. package/lib/client/rpc-connection.d.ts.map +1 -1
  25. package/lib/client/rpc-connection.js +9 -1
  26. package/lib/client/rpc-connection.js.map +1 -1
  27. package/lib/clock.d.ts +38 -0
  28. package/lib/clock.d.ts.map +1 -1
  29. package/lib/clock.js +36 -1
  30. package/lib/clock.js.map +1 -1
  31. package/lib/data/data-protocol-methods.d.ts +2 -2
  32. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  33. package/lib/data/data-protocol-methods.js +1 -0
  34. package/lib/data/data-protocol-methods.js.map +1 -1
  35. package/lib/data/data-server-protocol.d.ts +11 -1
  36. package/lib/data/data-server-protocol.d.ts.map +1 -1
  37. package/lib/data/events.d.ts +14 -0
  38. package/lib/data/events.d.ts.map +1 -1
  39. package/lib/errors.d.ts +20 -9
  40. package/lib/errors.d.ts.map +1 -1
  41. package/lib/errors.js +18 -9
  42. package/lib/errors.js.map +1 -1
  43. package/lib/glsp-save-model-actions.d.ts +50 -0
  44. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  45. package/lib/glsp-save-model-actions.js +28 -0
  46. package/lib/glsp-save-model-actions.js.map +1 -0
  47. package/lib/index.d.ts +1 -0
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js +1 -0
  50. package/lib/index.js.map +1 -1
  51. package/lib/messages/index.d.ts +1 -1
  52. package/lib/messages/index.d.ts.map +1 -1
  53. package/lib/messages/index.js +2 -1
  54. package/lib/messages/index.js.map +1 -1
  55. package/lib/testing/data-doubles.d.ts +3 -1
  56. package/lib/testing/data-doubles.d.ts.map +1 -1
  57. package/lib/testing/data-doubles.js +6 -1
  58. package/lib/testing/data-doubles.js.map +1 -1
  59. package/lib/testing/fake-clock.d.ts +9 -1
  60. package/lib/testing/fake-clock.d.ts.map +1 -1
  61. package/lib/testing/fake-clock.js +54 -45
  62. package/lib/testing/fake-clock.js.map +1 -1
  63. package/lib/testing/node/index.d.ts +1 -0
  64. package/lib/testing/node/index.d.ts.map +1 -1
  65. package/lib/testing/node/index.js +2 -2
  66. package/lib/testing/node/index.js.map +1 -1
  67. package/lib/testing/node/message-port-pair.d.ts +25 -0
  68. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  69. package/lib/testing/node/message-port-pair.js +26 -0
  70. package/lib/testing/node/message-port-pair.js.map +1 -0
  71. package/lib/transfer-document.d.ts +8 -0
  72. package/lib/transfer-document.d.ts.map +1 -1
  73. package/lib/transfer-document.js.map +1 -1
  74. package/package.json +1 -1
  75. package/src/client/data-connection.ts +72 -6
  76. package/src/client/data-events.ts +9 -0
  77. package/src/client/data-session.ts +125 -21
  78. package/src/client/index.ts +3 -1
  79. package/src/client/message-relay.ts +1 -1
  80. package/src/client/post-message-transport.ts +219 -4
  81. package/src/client/rpc-connection.ts +10 -1
  82. package/src/clock.ts +56 -0
  83. package/src/data/data-protocol-methods.ts +1 -0
  84. package/src/data/data-server-protocol.ts +12 -0
  85. package/src/data/events.ts +16 -0
  86. package/src/errors.ts +24 -9
  87. package/src/glsp-save-model-actions.ts +59 -0
  88. package/src/index.ts +1 -0
  89. package/src/messages/index.ts +1 -1
  90. package/src/testing/data-doubles.ts +10 -1
  91. package/src/testing/fake-clock.ts +62 -47
  92. package/src/testing/node/index.ts +2 -2
  93. package/src/testing/node/message-port-pair.ts +40 -0
  94. package/src/transfer-document.ts +8 -0
@@ -16,6 +16,7 @@ import type { ReferenceCandidate, ReferenceTarget } from '../model-service/refer
16
16
  import type {
17
17
  ProjectsChangedEvent,
18
18
  TransferDocumentDeletedEvent,
19
+ TransferDocumentDirtyChangedEvent,
19
20
  TransferDocumentSavedEvent,
20
21
  TransferDocumentsBuiltEvent,
21
22
  TransferDocumentUpdatedEvent
@@ -329,6 +330,17 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
329
330
  */
330
331
  onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
331
332
 
333
+ /**
334
+ * Delivered when a subscribed document's text starts or stops differing
335
+ * from its file, as the server last knew it. Gated like
336
+ * {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
337
+ * the documents the server sends. After a reconnect, a `DataSession`
338
+ * delivers here the answer of each document it restored, when that differs
339
+ * from the last this client was told: the flips while the connection was
340
+ * down reached no one.
341
+ */
342
+ onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
343
+
332
344
  /**
333
345
  * Delivered when a document's backing file was removed. Separate from
334
346
  * {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
@@ -95,6 +95,22 @@ export type TransferDocumentSavedListener<
95
95
  TDiagnostic extends TransferDiagnostic = TransferDiagnostic
96
96
  > = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
97
97
 
98
+ /**
99
+ * Delivered on the data-server when a watched document's text starts or stops
100
+ * differing from its file, as the server last knew the file. The current
101
+ * answer rides on every transfer document the server sends as `dirty`; this
102
+ * carries only its changes, so a client that follows it needs no rebuild to
103
+ * learn of a save.
104
+ */
105
+ export interface TransferDocumentDirtyChangedEvent {
106
+ /** Canonical URI, keyed as the subscription is. */
107
+ readonly uri: string;
108
+ readonly dirty: boolean;
109
+ }
110
+
111
+ /** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
112
+ export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
113
+
98
114
  /**
99
115
  * Delivered on the data-server when a document's backing file was removed.
100
116
  * Carries no document, and cannot: the state a
package/src/errors.ts CHANGED
@@ -124,18 +124,33 @@ export const DOCUMENT_NOT_OPEN_ERROR_CODE = 1005;
124
124
  /** JSON-RPC code for {@link DuplicateClientIdError}. */
125
125
  export const DUPLICATE_CLIENT_ID_ERROR_CODE = 1006;
126
126
 
127
+ /**
128
+ * The catalogue declaration behind {@link SessionClosedError}'s default
129
+ * sentence. It names no client id: the sentence can reach an end user, and the
130
+ * id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
131
+ */
132
+ export const SESSION_CLOSED = defineMessage('hydranium/protocol/session-closed', 'The editing session has ended.');
133
+
134
+ /** Structured payload carried in {@link SessionClosedError.data}. */
135
+ export interface SessionClosedErrorData extends HydraniumMessageData {
136
+ readonly clientId: string;
137
+ }
138
+
127
139
  /**
128
140
  * Thrown by every call on a client session after it ended, and by an open that
129
- * was still in flight when its session ended.
130
- *
131
- * The message names the client id, so it is addressed to whoever composes the
132
- * system rather than to an end user, and carries no message identity. A client
133
- * recognises it after an RPC with {@link isSessionClosedError}.
141
+ * was still in flight when its session ended: by the server for its sessions,
142
+ * and by a client-side `DataSession` once disposed, so a caller handles both
143
+ * the same way. A caller recognises it with {@link isSessionClosedError}, never
144
+ * by its sentence.
134
145
  */
135
- export class SessionClosedError extends ResponseError<{ readonly clientId: string }> {
136
- /** `message` replaces the default sentence, for a caller that knows more than that the session is gone. */
137
- constructor(clientId: string, message = `Client session ${clientId} is closed`) {
138
- super(SESSION_CLOSED_ERROR_CODE, message, { clientId });
146
+ export class SessionClosedError extends ResponseError<SessionClosedErrorData> {
147
+ /**
148
+ * `message` replaces the default English, for a caller that knows more than
149
+ * that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
150
+ * translating renderer renders the catalogue sentence in its place.
151
+ */
152
+ constructor(clientId: string, message = SESSION_CLOSED.format()) {
153
+ super(SESSION_CLOSED_ERROR_CODE, message, { clientId, ...messageData(SESSION_CLOSED) });
139
154
  this.name = 'SessionClosedError';
140
155
  // `ResponseError` resets the prototype to its own; see `ConflictError`.
141
156
  Object.setPrototypeOf(this, SessionClosedError.prototype);
@@ -0,0 +1,59 @@
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
+ // Declared field by field rather than extending GLSP's action types: this
11
+ // package carries no GLSP dependency, and both GLSP heads already depend on it.
12
+ // The fields are GLSP's own, so both actions are assignable to GLSP's
13
+ // `RequestAction` and `ResponseAction`.
14
+
15
+ /**
16
+ * A save of a diagram's model that the server answers, with a
17
+ * {@link ModelSavedAction} once the save has finished or a GLSP
18
+ * `RejectAction` when it fails.
19
+ *
20
+ * It carries what GLSP's `SaveModelAction` carries, and the server saves it the
21
+ * same way. GLSP's `SaveModelAction` is not answered: the server's only
22
+ * reply is a dirty-state change, which the client drops when the dirty flag
23
+ * does not change, so a client cannot tell which save an answer belongs to or
24
+ * whether a save failed.
25
+ */
26
+ export interface RequestSaveModelAction {
27
+ kind: typeof RequestSaveModelAction.KIND;
28
+ /** The id the response echoes as its `responseId`. Empty until the dispatcher assigns one. */
29
+ requestId: string;
30
+ /** How long the receiver waits for its own handler, in milliseconds. */
31
+ timeout?: number;
32
+ /** The file to save to, as in GLSP's `SaveModelAction`; absent saves to the diagram's source. */
33
+ fileUri?: string;
34
+ /** GLSP's typing marker for the response. Never set. */
35
+ readonly _?: ModelSavedAction;
36
+ }
37
+
38
+ export namespace RequestSaveModelAction {
39
+ export const KIND = 'hydraniumRequestSaveModel';
40
+
41
+ export function create(options: { fileUri?: string; requestId?: string } = {}): RequestSaveModelAction {
42
+ return { kind: KIND, requestId: '', ...options };
43
+ }
44
+ }
45
+
46
+ /** The server's answer to a {@link RequestSaveModelAction} that saved. */
47
+ export interface ModelSavedAction {
48
+ kind: typeof ModelSavedAction.KIND;
49
+ /** The `requestId` of the save this answers. The server's dispatcher sets it. */
50
+ responseId: string;
51
+ }
52
+
53
+ export namespace ModelSavedAction {
54
+ export const KIND = 'hydraniumModelSaved';
55
+
56
+ export function create(options: { responseId?: string } = {}): ModelSavedAction {
57
+ return { kind: KIND, responseId: '', ...options };
58
+ }
59
+ }
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from './clock';
21
21
  export * from './data';
22
22
  export * from './browser-runtime';
23
23
  export * from './debouncer';
24
+ export * from './glsp-save-model-actions';
24
25
  export * from './errors';
25
26
  export * from './host-diagnostics';
26
27
  export * from './logger';
@@ -25,7 +25,7 @@
25
25
 
26
26
  export * from './primitives';
27
27
 
28
- export { STALE_BASED_UPDATE } from '../errors';
28
+ export { SESSION_CLOSED, STALE_BASED_UPDATE } from '../errors';
29
29
  export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
30
30
  export { DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
31
31
  export {
@@ -37,6 +37,7 @@ import type { DataClientProtocol } from '../data/data-server-protocol';
37
37
  import type {
38
38
  ProjectsChangedEvent,
39
39
  TransferDocumentDeletedEvent,
40
+ TransferDocumentDirtyChangedEvent,
40
41
  TransferDocumentSavedEvent,
41
42
  TransferDocumentsBuiltEvent,
42
43
  TransferDocumentUpdatedEvent
@@ -132,6 +133,8 @@ export interface CapturingDataClient<
132
133
  readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
133
134
  /** Every `onDocumentSaved` event, in arrival order. */
134
135
  readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
136
+ /** Every `onDocumentDirtyChanged` event, in arrival order. */
137
+ readonly dirtyChanges: TransferDocumentDirtyChangedEvent[];
135
138
  /** Every `onDocumentDeleted` event, in arrival order. */
136
139
  readonly deletions: TransferDocumentDeletedEvent[];
137
140
  /** Every `onDocumentsBuilt` event, in arrival order. */
@@ -160,6 +163,7 @@ export function makeCapturingDataClient<
160
163
  >(overrides: Partial<DataClientProtocol<TTransfer, TDiagnostic, TProject>> = {}): CapturingDataClient<TTransfer, TDiagnostic, TProject> {
161
164
  const updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[] = [];
162
165
  const saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[] = [];
166
+ const dirtyChanges: TransferDocumentDirtyChangedEvent[] = [];
163
167
  const deletions: TransferDocumentDeletedEvent[] = [];
164
168
  const builds: TransferDocumentsBuiltEvent[] = [];
165
169
  const projectsChanges: ProjectsChangedEvent<TProject>[] = [];
@@ -174,6 +178,11 @@ export function makeCapturingDataClient<
174
178
  (event => {
175
179
  saves.push(event);
176
180
  }),
181
+ onDocumentDirtyChanged:
182
+ overrides.onDocumentDirtyChanged ??
183
+ (event => {
184
+ dirtyChanges.push(event);
185
+ }),
177
186
  onDocumentDeleted:
178
187
  overrides.onDocumentDeleted ??
179
188
  (event => {
@@ -190,5 +199,5 @@ export function makeCapturingDataClient<
190
199
  projectsChanges.push(event);
191
200
  })
192
201
  };
193
- return { client, updates, saves, deletions, builds, projectsChanges };
202
+ return { client, updates, saves, dirtyChanges, deletions, builds, projectsChanges };
194
203
  }
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import { type Clock, type Stopwatch, type Timed } from '../clock';
10
+ import { type Clock, type Stopwatch, SystemClock } from '../clock';
11
11
  import { Disposable } from '../util';
12
12
 
13
13
  /** A {@link Clock} whose time only moves when the test calls {@link FakeClock.advance}. */
@@ -17,9 +17,13 @@ export interface FakeClock extends Clock {
17
17
  * whose deadline falls within the window — in chronological order, each at
18
18
  * its own deadline (so `now()` inside a callback reads the fire instant, not
19
19
  * the advance target). Timers scheduled by a callback fire too if they fall
20
- * within the same window.
20
+ * within the same window. A {@link Clock.raceTimer} over a promise that
21
+ * settles through a chain still pending loses to the timer, so let that
22
+ * chain settle before advancing.
21
23
  */
22
24
  advance(ms: number): void;
25
+ /** How many {@link Clock.setTimer} timers have neither fired nor been disposed. */
26
+ pendingTimers(): number;
23
27
  }
24
28
 
25
29
  interface FakeTimer {
@@ -39,68 +43,79 @@ interface FakeTimer {
39
43
  *
40
44
  * Server-free and DI-free — lives in `@hydranium/protocol/testing` so every
41
45
  * head can bind it without pulling in a server package.
46
+ *
47
+ * The clock is a `SystemClock` with its time replaced, so its methods live on
48
+ * its prototype and a spread of it carries none of them. Replace one by
49
+ * assigning it onto the clock, or layer over the clock with `Object.create`.
42
50
  */
43
51
  export function makeFakeClock(options: { now?: number } = {}): FakeClock {
44
- let current = options.now ?? 0;
45
- const timers: FakeTimer[] = [];
52
+ return new VirtualClock(options.now ?? 0);
53
+ }
54
+
55
+ /**
56
+ * A `SystemClock` whose time, stopwatches and timers read one virtual axis, so
57
+ * the `measure` and `raceTimer` it inherits run on that axis too.
58
+ */
59
+ class VirtualClock extends SystemClock implements FakeClock {
60
+ protected readonly timers: FakeTimer[] = [];
46
61
 
47
- const makeStopwatch = (): Stopwatch => {
48
- const start = current;
49
- let lastLap = current;
62
+ constructor(protected current: number) {
63
+ super();
64
+ }
65
+
66
+ override now(): number {
67
+ return this.current;
68
+ }
69
+
70
+ override setTimer(callback: () => void, ms: number): Disposable {
71
+ const timer: FakeTimer = { at: this.current + ms, callback, disposed: false, fired: false };
72
+ this.timers.push(timer);
73
+ return Disposable.create(() => {
74
+ timer.disposed = true;
75
+ });
76
+ }
77
+
78
+ override stopwatch(): Stopwatch {
79
+ const read = (): number => this.current;
80
+ const start = read();
81
+ let lastLap = start;
50
82
  let stopped: number | undefined;
51
83
  return {
52
84
  get elapsedMs(): number {
53
- return (stopped ?? current) - start;
85
+ return (stopped ?? read()) - start;
54
86
  },
55
87
  lap(): number {
56
- const at = stopped ?? current;
88
+ const at = stopped ?? read();
57
89
  const split = at - lastLap;
58
90
  lastLap = at;
59
91
  return split;
60
92
  },
61
93
  stop(): number {
62
- if (stopped === undefined) {
63
- stopped = current;
64
- }
94
+ stopped ??= read();
65
95
  return stopped - start;
66
96
  }
67
97
  };
68
- };
98
+ }
69
99
 
70
- return {
71
- now: () => current,
72
- setTimer(callback: () => void, ms: number): Disposable {
73
- const timer: FakeTimer = { at: current + ms, callback, disposed: false, fired: false };
74
- timers.push(timer);
75
- return Disposable.create(() => {
76
- timer.disposed = true;
77
- });
78
- },
79
- stopwatch: makeStopwatch,
80
- measure: (<T>(callback: () => T | Promise<T>): Timed<T> | Promise<Timed<T>> => {
81
- const stopwatch = makeStopwatch();
82
- const result = callback();
83
- if (result instanceof Promise) {
84
- return (result as Promise<T>).then(value => ({ result: value, elapsedMs: stopwatch.elapsedMs }));
85
- }
86
- return { result: result as T, elapsedMs: stopwatch.elapsedMs };
87
- }) as Clock['measure'],
88
- advance(ms: number): void {
89
- const target = current + ms;
90
- // Fire due timers one at a time, re-scanning after each so a callback
91
- // that schedules a nearer timer still fires within this window.
92
- for (;;) {
93
- const next = timers
94
- .filter(timer => !timer.disposed && !timer.fired && timer.at <= target)
95
- .sort((left, right) => left.at - right.at)[0];
96
- if (!next) {
97
- break;
98
- }
99
- current = next.at;
100
- next.fired = true;
101
- next.callback();
100
+ pendingTimers(): number {
101
+ return this.timers.filter(timer => !timer.disposed && !timer.fired).length;
102
+ }
103
+
104
+ advance(ms: number): void {
105
+ const target = this.current + ms;
106
+ // Fire due timers one at a time, re-scanning after each so a callback
107
+ // that schedules a nearer timer still fires within this window.
108
+ for (;;) {
109
+ const next = this.timers
110
+ .filter(timer => !timer.disposed && !timer.fired && timer.at <= target)
111
+ .sort((left, right) => left.at - right.at)[0];
112
+ if (!next) {
113
+ break;
102
114
  }
103
- current = target;
115
+ this.current = next.at;
116
+ next.fired = true;
117
+ next.callback();
104
118
  }
105
- };
119
+ this.current = target;
120
+ }
106
121
  }
@@ -8,8 +8,7 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  // Subpath barrel for `@hydranium/protocol/testing/node` — the test transports
11
- // that need a Node runtime: a crossed `PassThrough` pair and the in-process
12
- // `MessageConnection` bridge over it.
11
+ // that need a Node runtime.
13
12
  //
14
13
  // Separate from `./testing` because a `PassThrough` is in `DuplexStreamPair`'s
15
14
  // exported type and `StreamMessageReader` comes from `vscode-jsonrpc/node`, so
@@ -20,3 +19,4 @@
20
19
 
21
20
  export * from './duplex-connection';
22
21
  export * from './duplex-stream';
22
+ export * from './message-port-pair';
@@ -0,0 +1,40 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import { MessageChannel } from 'node:worker_threads';
11
+ import type { TransferredMessagePort } from '../../client/post-message-transport';
12
+
13
+ /**
14
+ * The two ends of a `worker_threads` `MessageChannel`, typed as the transferred
15
+ * browser ports `createMessagePortTransport` takes. Node's port clones and keeps
16
+ * order as a browser's does, which is what lets a headless test stand in for a
17
+ * worker.
18
+ *
19
+ * `dispose` closes both ports. Node reports that as a close and a browser port
20
+ * reports nothing, so a test that asserts on a close does so before teardown.
21
+ */
22
+ export interface MessagePortPair {
23
+ readonly port1: TransferredMessagePort;
24
+ readonly port2: TransferredMessagePort;
25
+ dispose(): void;
26
+ }
27
+
28
+ export function makeMessagePortPair(): MessagePortPair {
29
+ const channel = new MessageChannel();
30
+ return {
31
+ // Node's port satisfies the structural type at runtime; the cast records
32
+ // one platform's port standing in for the other's.
33
+ port1: channel.port1 as unknown as TransferredMessagePort,
34
+ port2: channel.port2 as unknown as TransferredMessagePort,
35
+ dispose(): void {
36
+ channel.port1.close();
37
+ channel.port2.close();
38
+ }
39
+ };
40
+ }
@@ -43,6 +43,14 @@ export interface TransferDocument<TTransfer extends TransferElement, TDiagnostic
43
43
  */
44
44
  root?: TTransfer;
45
45
  diagnostics: TDiagnostic[];
46
+ /**
47
+ * Whether the server holds text for this document that its file does not,
48
+ * as the server last knew the file: set on every document a data server
49
+ * answers or sends that the server holds, and absent otherwise. A change
50
+ * after this snapshot arrives as `onDocumentDirtyChanged` to a client
51
+ * watching the document.
52
+ */
53
+ dirty?: boolean;
46
54
  }
47
55
 
48
56
  /**