@hydranium/protocol 1.0.0-next.60 → 1.0.0-next.61

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.
@@ -7,118 +7,64 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import type { MessageConnection } from 'vscode-jsonrpc';
11
- import { DATA_CLIENT_PROTOCOL_METHODS, DATA_SERVER_WIRE_PREFIX, type DataClientProtocol, type DataServerProtocol } from '../data';
12
- import { defineMessage, describeError, resolve } from '../messages/primitives';
13
- import { type RpcProxy, createRpcProxy } from '../rpc';
10
+ import type { DataServerProtocol, TransferSaveDocumentArgs, TransferUpdateDocumentArgs } from '../data';
11
+ import type { RpcProxy } from '../rpc';
14
12
  import type { TransferDocument } from '../transfer-document';
15
13
  import type { TransferElement } from '../transfer-element';
16
- import type { DataPort } from './data-port';
17
14
 
18
- /**
19
- * The transport never opened. A complete sentence rather than a fragment: a
20
- * fragment is nested inside a sentence the framework does not own, so no
21
- * translator controls the whole and the composition cannot be made to read
22
- * correctly in every language.
23
- */
24
- export const DATA_SERVER_CONNECT_FAILED = defineMessage(
25
- 'hydranium/protocol/data-server-connect-failed',
26
- 'Could not connect to the data server: {detail}'
27
- );
28
-
29
- export const DATA_SERVER_NOT_READY = defineMessage(
30
- 'hydranium/protocol/data-server-not-ready',
31
- 'The data server did not become ready: {detail}'
32
- );
15
+ /** Update a document through a session; the session supplies `clientId`. */
16
+ export type DataSessionUpdateArgs<TTransfer> = Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>;
33
17
 
34
- /** Options for {@link DataSession}. */
35
- export interface DataSessionOptions {
36
- /**
37
- * Wire namespace the server is addressed under. Defaults to the
38
- * framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
39
- * `DataServer` binds. Override only alongside the server's own
40
- * `methodNamespace` option — a mismatch turns every request into
41
- * "Unhandled method" rather than failing at wire-up.
42
- */
43
- readonly methodNamespace?: string;
44
- }
18
+ /** Persist a document through a session; the session supplies `clientId`. */
19
+ export type DataSessionSaveArgs<TTransfer> = Omit<TransferSaveDocumentArgs<TTransfer>, 'clientId'>;
45
20
 
46
- /** One connection generation: its connection, its proxy, and its readiness. */
47
- interface Generation<TTransfer extends TransferElement> {
48
- readonly connection: Promise<MessageConnection>;
49
- readonly server: RpcProxy<DataServerProtocol<TTransfer>>;
50
- /** Set on first use; the shared readiness gate for this generation. */
51
- ready?: Promise<void>;
21
+ /**
22
+ * What a {@link DataSession} needs from the connection that minted it.
23
+ *
24
+ * Narrower than the connection itself so the dependency points one way:
25
+ * `DataConnection` constructs sessions, and nothing here imports it back.
26
+ */
27
+ export interface DataSessionHost<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer>> {
28
+ connected(): Promise<RpcProxy<TServer>>;
29
+ releaseSession(session: DataSession<TTransfer, TServer>): void;
52
30
  }
53
31
 
54
32
  /**
55
- * The host-invariant half of talking to the data head: everything above
56
- * {@link DataPort} that would otherwise be re-derived by every host
57
- * adapter.
58
- *
59
- * Three jobs, and deliberately no fourth:
33
+ * One participant on a data connection: a properties panel, a tree, a
34
+ * form editor.
60
35
  *
61
- * 1. **Build the typed proxy** over the port's connection, with the framework's
62
- * wire prefix and its drift-proof client-method allowlist.
63
- * 2. **Own the readiness gate** — `waitForReady` once per connection, shared
64
- * across concurrent callers. A socket client can connect before the
65
- * workspace walk finishes, and an early request is then answered correctly
66
- * from an empty registry, which reads as a broken project tier rather than
67
- * as a race.
68
- * 3. **Own the reconnect policy**, by dropping its connection generation when
69
- * the port disposes and building a fresh one on the next request.
36
+ * The server keys every hold and watch per `(uri, clientId)`, so the identity
37
+ * belongs to the participant rather than to the wire — several sessions share
38
+ * one connection, and two participants forced to share one identity cannot
39
+ * distinguish each other's writes from their own echoes.
70
40
  *
71
- * It does **not** wrap the protocol methods; callers reach them through
72
- * {@link connected}. The one exception is {@link openDocument}, which exists
73
- * because the open/watch *order* is silently wrong the other way round — see
74
- * its own doc.
41
+ * Every document operation stamps {@link clientId} itself. A caller that
42
+ * passed its own could pass another participant's, and the server would
43
+ * attribute the write and release the hold accordingly.
75
44
  *
76
- * Generic over the transfer root so this file names no grammar. An adopter
77
- * binds the concrete root (or the union of them, for a multi-grammar head) at
78
- * its own edge.
45
+ * Generic over the transfer root so this file names no grammar.
79
46
  */
80
- export class DataSession<TTransfer extends TransferElement> {
81
- protected readonly methodNamespace: string;
82
- /** The current generation, or `undefined` before the first request / after a teardown. */
83
- protected generation?: Generation<TTransfer>;
47
+ export class DataSession<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>> {
48
+ /** URIs this session holds open, so {@link dispose} can release exactly those. */
49
+ protected readonly openUris = new Set<string>();
84
50
  protected disposed = false;
85
- protected readonly portDisposeListener: { dispose(): void };
86
51
 
87
52
  constructor(
88
- protected readonly port: DataPort,
89
- protected readonly client: DataClientProtocol<TTransfer>,
90
- options: DataSessionOptions = {}
91
- ) {
92
- this.methodNamespace = options.methodNamespace ?? DATA_SERVER_WIRE_PREFIX;
93
- this.portDisposeListener = this.port.onDispose(() => this.dropGeneration());
94
- }
95
-
96
- /** The identity every request is made under — the port's, not a second one. */
97
- get clientId(): string {
98
- return this.port.clientId;
99
- }
53
+ readonly clientId: string,
54
+ protected readonly host: DataSessionHost<TTransfer, TServer>
55
+ ) {}
100
56
 
101
57
  /**
102
- * The connected, READY server proxy.
103
- *
104
- * Returns the proxy rather than `void` on purpose. A reconnect replaces the
105
- * proxy, so a caller that cached one from an earlier call would go on
106
- * addressing a dead connection with no error — handing it back per call
107
- * makes the stale reference unrepresentable.
108
- *
109
- * Concurrent callers share one readiness promise, so `waitForReady` is
110
- * awaited once per generation and not once per caller.
58
+ * The connected, READY server proxy, for protocol methods this session does
59
+ * not wrap — the ones carrying no `clientId`, so no identity can be got
60
+ * wrong through them.
111
61
  */
112
- async connected(): Promise<RpcProxy<DataServerProtocol<TTransfer>>> {
113
- if (this.disposed) {
114
- throw new Error('DataSession is disposed');
115
- }
116
- const generation = this.currentGeneration();
117
- if (!generation.ready) {
118
- generation.ready = this.awaitReady(generation);
119
- }
120
- await generation.ready;
121
- return generation.server;
62
+ async connected(): Promise<RpcProxy<TServer>> {
63
+ // `async` so a disposed session REJECTS rather than throwing
64
+ // synchronously: the connection's own `connected` rejects, and a caller
65
+ // reaching for `.catch` on one of them would not catch the other.
66
+ this.assertLive();
67
+ return this.host.connected();
122
68
  }
123
69
 
124
70
  /**
@@ -143,6 +89,7 @@ export class DataSession<TTransfer extends TransferElement> {
143
89
  const server = await this.connected();
144
90
  const document = await server.openModelDocument({ uri, clientId: this.clientId });
145
91
  await server.watchModelDocument({ uri, clientId: this.clientId });
92
+ this.openUris.add(uri);
146
93
  return document;
147
94
  }
148
95
 
@@ -152,11 +99,24 @@ export class DataSession<TTransfer extends TransferElement> {
152
99
  */
153
100
  async closeDocument(uri: string): Promise<void> {
154
101
  const server = await this.connected();
102
+ this.openUris.delete(uri);
155
103
  await server.closeModelDocument({ uri, clientId: this.clientId });
156
104
  }
157
105
 
106
+ /** Write `args.model` back as this session. */
107
+ async updateDocument(args: DataSessionUpdateArgs<TTransfer>): Promise<TransferDocument<TTransfer>> {
108
+ const server = await this.connected();
109
+ return server.updateModelDocument({ ...args, clientId: this.clientId });
110
+ }
111
+
112
+ /** Persist `args.model` to disk as this session. */
113
+ async saveDocument(args: DataSessionSaveArgs<TTransfer>): Promise<TransferDocument<TTransfer>> {
114
+ const server = await this.connected();
115
+ return server.saveModelDocument({ ...args, clientId: this.clientId });
116
+ }
117
+
158
118
  /**
159
- * Whether `event.sourceClientId` identifies this session's own write.
119
+ * Whether `sourceClientId` identifies this session's own write.
160
120
  *
161
121
  * Every watcher needs this and the check is one comparison, so getting it
162
122
  * wrong is cheap to do and expensive to find: an unfiltered echo looks
@@ -166,63 +126,46 @@ export class DataSession<TTransfer extends TransferElement> {
166
126
  return sourceClientId === this.clientId;
167
127
  }
168
128
 
169
- /** Tear down the current connection and stop tracking the port. Idempotent. */
129
+ /**
130
+ * Release this session's holds and detach it from the connection.
131
+ * Idempotent, and leaves the connection usable by its other sessions.
132
+ *
133
+ * The closes are fired without being awaited, because a `Disposable` cannot
134
+ * be: a host disposing a widget has nowhere to put the promise. A close
135
+ * that fails is no worse than the leak this exists to prevent, so the
136
+ * rejection is swallowed rather than surfaced from a teardown.
137
+ */
170
138
  dispose(): void {
171
139
  if (this.disposed) {
172
140
  return;
173
141
  }
174
142
  this.disposed = true;
175
- this.portDisposeListener.dispose();
176
- this.dropGeneration();
177
- }
178
-
179
- /** The live generation, building one if there is none. */
180
- protected currentGeneration(): Generation<TTransfer> {
181
- if (this.generation) {
182
- return this.generation;
183
- }
184
- const connection = this.port.connect();
185
- // Rejection is reported here rather than left to float: an unhandled
186
- // rejection on a connection promise is the failure mode that reads as
187
- // "the model is empty" instead of "the transport never opened".
188
- connection.catch((error: unknown) =>
189
- this.port.reportError(error, resolve(DATA_SERVER_CONNECT_FAILED, { detail: describeError(error) }))
190
- );
191
- const server = createRpcProxy<DataServerProtocol<TTransfer>, DataClientProtocol<TTransfer>>(connection, {
192
- methodNamespace: this.methodNamespace,
193
- localTarget: this.client,
194
- localMethods: DATA_CLIENT_PROTOCOL_METHODS
195
- });
196
- this.generation = { connection, server };
197
- return this.generation;
198
- }
199
-
200
- /** Await the connection and the server's startup gate for one generation. */
201
- protected async awaitReady(generation: Generation<TTransfer>): Promise<void> {
202
- try {
203
- await generation.connection;
204
- await generation.server.waitForReady();
205
- } catch (error: unknown) {
206
- // Drop the generation so the next request retries rather than
207
- // re-awaiting a settled rejection forever.
208
- if (this.generation === generation) {
209
- this.generation = undefined;
210
- }
211
- this.port.reportError(error, resolve(DATA_SERVER_NOT_READY, { detail: describeError(error) }));
212
- throw error;
143
+ const uris = [...this.openUris];
144
+ this.openUris.clear();
145
+ this.host.releaseSession(this);
146
+ for (const uri of uris) {
147
+ void this.host
148
+ .connected()
149
+ .then(server => server.closeModelDocument({ uri, clientId: this.clientId }))
150
+ .catch(() => undefined);
213
151
  }
214
152
  }
215
153
 
216
154
  /**
217
- * Discard the current generation, disposing its connection if it opened.
218
- * The next {@link connected} builds a fresh one.
155
+ * Come off the connection because it is going away.
156
+ *
157
+ * Sends no close, unlike {@link dispose}: the server releases every hold on
158
+ * a connection it sees close, and the close would travel over the very
159
+ * connection being disposed.
219
160
  */
220
- protected dropGeneration(): void {
221
- const generation = this.generation;
222
- this.generation = undefined;
223
- if (!generation) {
224
- return;
161
+ detach(): void {
162
+ this.disposed = true;
163
+ this.openUris.clear();
164
+ }
165
+
166
+ protected assertLive(): void {
167
+ if (this.disposed) {
168
+ throw new Error('DataSession is disposed');
225
169
  }
226
- generation.connection.then(connection => connection.dispose()).catch(() => undefined);
227
170
  }
228
171
  }
@@ -13,8 +13,9 @@
13
13
  *
14
14
  * Where `./data` is the wire *contract* and `./rpc` is the machinery that lowers
15
15
  * it onto a connection, this is what a client wraps around both: the seam a host
16
- * fills in (`DataPort`), the lifecycle above it (`DataSession` —
17
- * readiness gate, open/watch ordering, echo recognition, reconnect), the inbound
16
+ * fills in (`DataPort`), the connection above it (`DataConnection` — readiness
17
+ * gate and reconnect), the participants on that connection (`DataSession` —
18
+ * identity, open/watch ordering, echo recognition), the inbound
18
19
  * fan-out (`DataEvents`), and the two halves of the hop for hosts whose
19
20
  * client cannot hold a socket — `createPostMessageTransport` on the client
20
21
  * side and `relayToPostMessageChannel` on the side that does hold it.
@@ -33,8 +34,10 @@
33
34
  * Theia DI.
34
35
  */
35
36
 
37
+ export * from './data-connection';
36
38
  export * from './data-events';
37
39
  export * from './data-port';
38
40
  export * from './data-session';
39
41
  export * from './message-relay';
40
42
  export * from './post-message-transport';
43
+ export * from './rpc-connection';
@@ -0,0 +1,205 @@
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
+ import type { MessageConnection } from 'vscode-jsonrpc';
11
+ import { defineMessage, describeError, resolve } from '../messages/primitives';
12
+ import { type RpcProxy, createRpcProxy } from '../rpc';
13
+ import type { DataPort } from './data-port';
14
+
15
+ /**
16
+ * The transport never opened. A complete sentence rather than a fragment: a
17
+ * fragment is nested inside a sentence the framework does not own, so no
18
+ * translator controls the whole and the composition cannot be made to read
19
+ * correctly in every language.
20
+ */
21
+ export const DATA_SERVER_CONNECT_FAILED = defineMessage(
22
+ 'hydranium/protocol/data-server-connect-failed',
23
+ 'Could not connect to the data server: {detail}'
24
+ );
25
+
26
+ export const DATA_SERVER_NOT_READY = defineMessage(
27
+ 'hydranium/protocol/data-server-not-ready',
28
+ 'The data server did not become ready: {detail}'
29
+ );
30
+
31
+ /** The one method a connection needs of any server: its startup gate. */
32
+ export interface ReadyServer {
33
+ waitForReady(): Promise<void>;
34
+ }
35
+
36
+ /** Lifecycle reporting, for a host that raises warm-up UI around the two waits. */
37
+ export interface RpcConnectionLifecycle {
38
+ /** A generation is opening its transport, including on each reconnect. */
39
+ readonly onConnecting?: () => void;
40
+ /** The server's readiness gate has settled for a generation. */
41
+ readonly onReady?: () => void;
42
+ /**
43
+ * A generation failed to connect or to become ready. The failure is still
44
+ * reported through {@link DataPort.reportError} and still rejects the
45
+ * awaiting caller; this is for a host that also drives its own UI.
46
+ */
47
+ readonly onFailed?: (error: unknown) => void;
48
+ }
49
+
50
+ /** Everything {@link RpcConnection} needs once a subclass has resolved its defaults. */
51
+ export interface ResolvedRpcConnectionOptions<TClient extends object> {
52
+ readonly methodNamespace: string;
53
+ readonly clientMethods: readonly (keyof TClient & string)[];
54
+ readonly lifecycle: RpcConnectionLifecycle;
55
+ }
56
+
57
+ /** One connection generation: its connection, its proxy, and its readiness. */
58
+ interface Generation<TServer extends object> {
59
+ readonly connection: Promise<MessageConnection>;
60
+ readonly server: RpcProxy<TServer>;
61
+ /** Set on first use; the shared readiness gate for this generation. */
62
+ ready?: Promise<void>;
63
+ }
64
+
65
+ /**
66
+ * One JSON-RPC connection to a head, with the three jobs every host adapter
67
+ * would otherwise re-derive above {@link DataPort}:
68
+ *
69
+ * 1. **Build the typed proxy** over the port's connection, with the caller's
70
+ * wire prefix and client-method allowlist.
71
+ * 2. **Own the readiness gate** — `waitForReady` once per connection, shared
72
+ * across concurrent callers. A client can connect before the workspace walk
73
+ * finishes, and an early request is then answered correctly from an empty
74
+ * registry, which reads as a broken project tier rather than as a race.
75
+ * 3. **Own the reconnect policy**, by dropping its generation when the port
76
+ * disposes and building a fresh one on the next request.
77
+ *
78
+ * Bounded only by {@link ReadyServer}, so a head serving a slice of the data
79
+ * protocol — diagnostics alone, or one with methods excluded — is still a
80
+ * legal server here. `DataConnection` narrows the bound because its sessions
81
+ * call the document methods; nothing at this layer does.
82
+ */
83
+ export class RpcConnection<TServer extends ReadyServer, TClient extends object> {
84
+ protected readonly methodNamespace: string;
85
+ protected readonly clientMethods: readonly (keyof TClient & string)[];
86
+ protected readonly lifecycle: RpcConnectionLifecycle;
87
+ /** The current generation, or `undefined` before the first request / after a teardown. */
88
+ protected generation?: Generation<TServer>;
89
+ protected disposed = false;
90
+ protected readonly portDisposeListener: { dispose(): void };
91
+
92
+ constructor(
93
+ protected readonly port: DataPort,
94
+ protected readonly client: TClient,
95
+ options: ResolvedRpcConnectionOptions<TClient>
96
+ ) {
97
+ this.methodNamespace = options.methodNamespace;
98
+ this.clientMethods = options.clientMethods;
99
+ this.lifecycle = options.lifecycle;
100
+ this.portDisposeListener = this.port.onDispose(() => this.dropGeneration());
101
+ }
102
+
103
+ /**
104
+ * The connected, READY server proxy.
105
+ *
106
+ * Returns the proxy rather than `void` on purpose. A reconnect replaces the
107
+ * proxy, so a caller that cached one from an earlier call would go on
108
+ * addressing a dead connection with no error — handing it back per call
109
+ * makes the stale reference unrepresentable.
110
+ *
111
+ * Concurrent callers share one readiness promise, so `waitForReady` is
112
+ * awaited once per generation and not once per caller.
113
+ */
114
+ async connected(): Promise<RpcProxy<TServer>> {
115
+ this.assertLive();
116
+ const generation = this.currentGeneration();
117
+ if (!generation.ready) {
118
+ generation.ready = this.awaitReady(generation);
119
+ }
120
+ await generation.ready;
121
+ return generation.server;
122
+ }
123
+
124
+ /**
125
+ * The current generation's proxy WITHOUT awaiting readiness — calls queue
126
+ * against the connection promise.
127
+ *
128
+ * Read per access, never cached: a reconnect replaces the generation, and a
129
+ * held reference would address the dead one. Prefer {@link connected}, which
130
+ * also waits for the server's startup gate.
131
+ */
132
+ get server(): RpcProxy<TServer> {
133
+ this.assertLive();
134
+ return this.currentGeneration().server;
135
+ }
136
+
137
+ /** Tear down the current connection and stop tracking the port. Idempotent. */
138
+ dispose(): void {
139
+ if (this.disposed) {
140
+ return;
141
+ }
142
+ this.disposed = true;
143
+ this.portDisposeListener.dispose();
144
+ this.dropGeneration();
145
+ }
146
+
147
+ /** The live generation, building one if there is none. */
148
+ protected currentGeneration(): Generation<TServer> {
149
+ if (this.generation) {
150
+ return this.generation;
151
+ }
152
+ this.lifecycle.onConnecting?.();
153
+ const connection = this.port.connect();
154
+ // Rejection is reported here rather than left to float: an unhandled
155
+ // rejection on a connection promise is the failure mode that reads as
156
+ // "the model is empty" instead of "the transport never opened".
157
+ connection.catch((error: unknown) =>
158
+ this.port.reportError(error, resolve(DATA_SERVER_CONNECT_FAILED, { detail: describeError(error) }))
159
+ );
160
+ const server = createRpcProxy<TServer, TClient>(connection, {
161
+ methodNamespace: this.methodNamespace,
162
+ localTarget: this.client,
163
+ localMethods: this.clientMethods
164
+ });
165
+ this.generation = { connection, server };
166
+ return this.generation;
167
+ }
168
+
169
+ /** Await the connection and the server's startup gate for one generation. */
170
+ protected async awaitReady(generation: Generation<TServer>): Promise<void> {
171
+ try {
172
+ await generation.connection;
173
+ await generation.server.waitForReady();
174
+ this.lifecycle.onReady?.();
175
+ } catch (error: unknown) {
176
+ this.lifecycle.onFailed?.(error);
177
+ // Drop the generation so the next request retries rather than
178
+ // re-awaiting a settled rejection forever.
179
+ if (this.generation === generation) {
180
+ this.generation = undefined;
181
+ }
182
+ this.port.reportError(error, resolve(DATA_SERVER_NOT_READY, { detail: describeError(error) }));
183
+ throw error;
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Discard the current generation, disposing its connection if it opened.
189
+ * The next {@link connected} builds a fresh one.
190
+ */
191
+ protected dropGeneration(): void {
192
+ const generation = this.generation;
193
+ this.generation = undefined;
194
+ if (!generation) {
195
+ return;
196
+ }
197
+ generation.connection.then(connection => connection.dispose()).catch(() => undefined);
198
+ }
199
+
200
+ protected assertLive(): void {
201
+ if (this.disposed) {
202
+ throw new Error(`${this.constructor.name} is disposed`);
203
+ }
204
+ }
205
+ }
@@ -26,7 +26,7 @@
26
26
  export * from './primitives';
27
27
 
28
28
  export { STALE_BASED_UPDATE } from '../errors';
29
- export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/data-session';
29
+ export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
30
30
  export {
31
31
  RELAY_REPLAY_FAILED,
32
32
  RELAY_TRANSPORT_OPEN_FAILED,
@@ -58,13 +58,6 @@ export interface FakeDataPortOptions {
58
58
  * which the consumer surfaces through {@link FakeDataPort.reported}.
59
59
  */
60
60
  connect(): MessageConnection | Promise<MessageConnection>;
61
- /**
62
- * Stable client identity. Defaults to `'fake-data-port'`, which avoids the
63
- * three sentinels the framework reserves (`'language-client'`, `'unknown'`,
64
- * `'revert-on-close'`); override it when a test needs two distinguishable
65
- * clients on one server.
66
- */
67
- clientId?: string;
68
61
  }
69
62
 
70
63
  /** A {@link DataPort} that records what passed through it. */
@@ -107,7 +100,6 @@ export function makeFakeDataPort(options: FakeDataPortOptions): FakeDataPort {
107
100
  const reported: { error: unknown; message: ResolvedMessage }[] = [];
108
101
  const disposeEmitter = new Emitter<void>();
109
102
  return {
110
- clientId: options.clientId ?? 'fake-data-port',
111
103
  connections,
112
104
  reported,
113
105
  onDispose: disposeEmitter.event,