@hydranium/protocol 1.0.0-next.7 → 1.0.0-next.71
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.
- package/README.md +35 -1
- package/lib/client/data-connection.d.ts +103 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +114 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +16 -21
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +83 -78
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +81 -108
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +10 -7
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +10 -7
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +8 -2
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +10 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +139 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +171 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +41 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +44 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +34 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +25 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +32 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +28 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +52 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +141 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +11 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +14 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +167 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +16 -22
- package/src/client/data-session.ts +138 -131
- package/src/client/index.ts +10 -7
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +230 -0
- package/src/client-ids.ts +45 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +45 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +38 -14
- package/src/index.ts +5 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +215 -0
- package/src/model-server.ts +2 -2
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +33 -17
- package/src/testing/index.ts +4 -1
- package/src/transfer-diagnostic.ts +40 -0
|
@@ -6,84 +6,78 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import type {
|
|
10
|
-
import
|
|
11
|
-
import { type RpcProxy } from '../rpc';
|
|
9
|
+
import type { DataServerProtocol, DiagnosticOf } from '../data';
|
|
10
|
+
import type { RpcProxy } from '../rpc';
|
|
12
11
|
import type { TransferDocument } from '../transfer-document';
|
|
13
12
|
import type { TransferElement } from '../transfer-element';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
/**
|
|
14
|
+
* What one of `TServer`'s document methods takes, minus the `clientId` a
|
|
15
|
+
* {@link DataSession} stamps itself.
|
|
16
|
+
*
|
|
17
|
+
* Read off the SERVER's signature, not off the framework's own arg type: an
|
|
18
|
+
* adopter server widens these, and a wrapper declared against the narrow
|
|
19
|
+
* shape rejects the extra field on a fresh object literal, so that call
|
|
20
|
+
* cannot go through a session at all.
|
|
21
|
+
*/
|
|
22
|
+
export type DataSessionArgs<TMethod extends (args: never) => unknown> = Omit<Parameters<TMethod>[0], 'clientId'>;
|
|
23
|
+
/** Open a document through a session; the session supplies `clientId`. */
|
|
24
|
+
export type DataSessionOpenArgs<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = DataSessionArgs<TServer['openModelDocument']>;
|
|
25
|
+
/** Close a document through a session; the session supplies `clientId`. */
|
|
26
|
+
export type DataSessionCloseArgs<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = DataSessionArgs<TServer['closeModelDocument']>;
|
|
27
|
+
/** Update a document through a session; the session supplies `clientId`. */
|
|
28
|
+
export type DataSessionUpdateArgs<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = DataSessionArgs<TServer['updateModelDocument']>;
|
|
29
|
+
/** Persist a document through a session; the session supplies `clientId`. */
|
|
30
|
+
export type DataSessionSaveArgs<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = DataSessionArgs<TServer['saveModelDocument']>;
|
|
31
|
+
/** The document a session hands back, carrying its server's diagnostic shape. */
|
|
32
|
+
export type DataSessionDocument<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = TransferDocument<TTransfer, DiagnosticOf<TServer>>;
|
|
33
|
+
/**
|
|
34
|
+
* What a {@link DataSession} needs from the connection that minted it.
|
|
35
|
+
*
|
|
36
|
+
* Narrower than the connection itself so the dependency points one way:
|
|
37
|
+
* `DataConnection` constructs sessions, and nothing here imports it back.
|
|
38
|
+
*/
|
|
39
|
+
export interface DataSessionHost<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>>> {
|
|
40
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
41
|
+
releaseSession(session: DataSession<TTransfer, TServer>): void;
|
|
32
42
|
}
|
|
33
43
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* adapter.
|
|
44
|
+
* One participant on a data connection: a properties panel, a tree, a
|
|
45
|
+
* form editor.
|
|
37
46
|
*
|
|
38
|
-
*
|
|
47
|
+
* The server keys every hold and watch per `(uri, clientId)`, so the identity
|
|
48
|
+
* belongs to the participant rather than to the wire — several sessions share
|
|
49
|
+
* one connection, and two participants forced to share one identity cannot
|
|
50
|
+
* distinguish each other's writes from their own echoes.
|
|
39
51
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* across concurrent callers. A socket client can connect before the
|
|
44
|
-
* workspace walk finishes, and an early request is then answered correctly
|
|
45
|
-
* from an empty registry, which reads as a broken project tier rather than
|
|
46
|
-
* as a race.
|
|
47
|
-
* 3. **Own the reconnect policy**, by dropping its connection generation when
|
|
48
|
-
* the port disposes and building a fresh one on the next request.
|
|
52
|
+
* Every document operation stamps {@link clientId} itself. A caller that
|
|
53
|
+
* passed its own could pass another participant's, and the server would
|
|
54
|
+
* attribute the write and release the hold accordingly.
|
|
49
55
|
*
|
|
50
|
-
*
|
|
51
|
-
* {@link connected}. The one exception is {@link openDocument}, which exists
|
|
52
|
-
* because the open/watch *order* is silently wrong the other way round — see
|
|
53
|
-
* its own doc.
|
|
56
|
+
* Generic over the transfer root so this file names no grammar.
|
|
54
57
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
+
* `TServer` is bound to a server answering with ITS OWN diagnostic shape, read
|
|
59
|
+
* back off the parameter being bound. Simplifying that to
|
|
60
|
+
* `DataServerProtocol<TTransfer>` compiles and costs the wrappers their
|
|
61
|
+
* return type: every call through `TServer` would resolve against that looser
|
|
62
|
+
* bound, so an adopter's diagnostics would come back as the framework's and
|
|
63
|
+
* the document would have to be cast on the way out.
|
|
58
64
|
*/
|
|
59
|
-
export declare class DataSession<TTransfer extends TransferElement
|
|
60
|
-
|
|
61
|
-
protected readonly
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
protected generation?: Generation<TTransfer>;
|
|
65
|
+
export declare class DataSession<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> {
|
|
66
|
+
readonly clientId: string;
|
|
67
|
+
protected readonly host: DataSessionHost<TTransfer, TServer>;
|
|
68
|
+
/** URIs this session holds open, so {@link dispose} can release exactly those. */
|
|
69
|
+
protected readonly openUris: Set<string>;
|
|
65
70
|
protected disposed: boolean;
|
|
66
|
-
|
|
67
|
-
dispose(): void;
|
|
68
|
-
};
|
|
69
|
-
constructor(port: DataPort, client: DataClientProtocol<TTransfer>, options?: DataSessionOptions);
|
|
70
|
-
/** The identity every request is made under — the port's, not a second one. */
|
|
71
|
-
get clientId(): string;
|
|
71
|
+
constructor(clientId: string, host: DataSessionHost<TTransfer, TServer>);
|
|
72
72
|
/**
|
|
73
|
-
* The connected, READY server proxy
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* proxy, so a caller that cached one from an earlier call would go on
|
|
77
|
-
* addressing a dead connection with no error — handing it back per call
|
|
78
|
-
* makes the stale reference unrepresentable.
|
|
79
|
-
*
|
|
80
|
-
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
81
|
-
* awaited once per generation and not once per caller.
|
|
73
|
+
* The connected, READY server proxy, for protocol methods this session does
|
|
74
|
+
* not wrap — the ones carrying no `clientId`, so no identity can be got
|
|
75
|
+
* wrong through them.
|
|
82
76
|
*/
|
|
83
|
-
connected(): Promise<RpcProxy<
|
|
77
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
84
78
|
/**
|
|
85
|
-
* Open `uri` for editing and start watching it, in that order,
|
|
86
|
-
* the opened snapshot.
|
|
79
|
+
* Open `args.uri` for editing and start watching it, in that order,
|
|
80
|
+
* returning the opened snapshot.
|
|
87
81
|
*
|
|
88
82
|
* **The order is the whole reason this method exists.**
|
|
89
83
|
* `watchModelDocument` baselines its dedup fingerprint from the *current*
|
|
@@ -99,31 +93,42 @@ export declare class DataSession<TTransfer extends TransferElement> {
|
|
|
99
93
|
* Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
|
|
100
94
|
* from `getModelDocument({ includeDiagnostics: true })`.
|
|
101
95
|
*/
|
|
102
|
-
openDocument(
|
|
96
|
+
openDocument(args: DataSessionOpenArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
|
|
103
97
|
/**
|
|
104
|
-
* Close `uri`. The server unwatches implicitly, so this is the dual of
|
|
98
|
+
* Close `args.uri`. The server unwatches implicitly, so this is the dual of
|
|
105
99
|
* {@link openDocument} and needs no separate unwatch.
|
|
106
100
|
*/
|
|
107
|
-
closeDocument(
|
|
101
|
+
closeDocument(args: DataSessionCloseArgs<TTransfer, TServer>): Promise<void>;
|
|
102
|
+
/** Write `args.model` back as this session. */
|
|
103
|
+
updateDocument(args: DataSessionUpdateArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
|
|
104
|
+
/** Persist `args.model` to disk as this session. */
|
|
105
|
+
saveDocument(args: DataSessionSaveArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
|
|
108
106
|
/**
|
|
109
|
-
* Whether `
|
|
107
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
110
108
|
*
|
|
111
109
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
112
110
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
113
111
|
* exactly like a concurrent third-party edit.
|
|
114
112
|
*/
|
|
115
113
|
isOwnEcho(sourceClientId: string): boolean;
|
|
116
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Release this session's holds and detach it from the connection.
|
|
116
|
+
* Idempotent, and leaves the connection usable by its other sessions.
|
|
117
|
+
*
|
|
118
|
+
* The closes are fired without being awaited, because a `Disposable` cannot
|
|
119
|
+
* be: a host disposing a widget has nowhere to put the promise. A close
|
|
120
|
+
* that fails is no worse than the leak this exists to prevent, so the
|
|
121
|
+
* rejection is swallowed rather than surfaced from a teardown.
|
|
122
|
+
*/
|
|
117
123
|
dispose(): void;
|
|
118
|
-
/** The live generation, building one if there is none. */
|
|
119
|
-
protected currentGeneration(): Generation<TTransfer>;
|
|
120
|
-
/** Await the connection and the server's startup gate for one generation. */
|
|
121
|
-
protected awaitReady(generation: Generation<TTransfer>): Promise<void>;
|
|
122
124
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
+
* Come off the connection because it is going away.
|
|
126
|
+
*
|
|
127
|
+
* Sends no close, unlike {@link dispose}: the server releases every hold on
|
|
128
|
+
* a connection it sees close, and the close would travel over the very
|
|
129
|
+
* connection being disposed.
|
|
125
130
|
*/
|
|
126
|
-
|
|
131
|
+
detach(): void;
|
|
132
|
+
protected assertLive(): void;
|
|
127
133
|
}
|
|
128
|
-
export {};
|
|
129
134
|
//# sourceMappingURL=data-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,IAA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AAC,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAKvH,oDAAoD;IAC9C,YAAY,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAKnH;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;;;;OAQG;IACH,OAAO,IAAI,IAAI;IAgBf;;;;;;OAMG;IACH,MAAM,IAAI,IAAI;IAKd,SAAS,CAAC,UAAU,IAAI,IAAI;CAK9B"}
|
|
@@ -9,77 +9,53 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.DataSession = void 0;
|
|
12
|
-
const data_1 = require("../data");
|
|
13
|
-
const rpc_1 = require("../rpc");
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* adapter.
|
|
13
|
+
* One participant on a data connection: a properties panel, a tree, a
|
|
14
|
+
* form editor.
|
|
18
15
|
*
|
|
19
|
-
*
|
|
16
|
+
* The server keys every hold and watch per `(uri, clientId)`, so the identity
|
|
17
|
+
* belongs to the participant rather than to the wire — several sessions share
|
|
18
|
+
* one connection, and two participants forced to share one identity cannot
|
|
19
|
+
* distinguish each other's writes from their own echoes.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* across concurrent callers. A socket client can connect before the
|
|
25
|
-
* workspace walk finishes, and an early request is then answered correctly
|
|
26
|
-
* from an empty registry, which reads as a broken project tier rather than
|
|
27
|
-
* as a race.
|
|
28
|
-
* 3. **Own the reconnect policy**, by dropping its connection generation when
|
|
29
|
-
* the port disposes and building a fresh one on the next request.
|
|
21
|
+
* Every document operation stamps {@link clientId} itself. A caller that
|
|
22
|
+
* passed its own could pass another participant's, and the server would
|
|
23
|
+
* attribute the write and release the hold accordingly.
|
|
30
24
|
*
|
|
31
|
-
*
|
|
32
|
-
* {@link connected}. The one exception is {@link openDocument}, which exists
|
|
33
|
-
* because the open/watch *order* is silently wrong the other way round — see
|
|
34
|
-
* its own doc.
|
|
25
|
+
* Generic over the transfer root so this file names no grammar.
|
|
35
26
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
27
|
+
* `TServer` is bound to a server answering with ITS OWN diagnostic shape, read
|
|
28
|
+
* back off the parameter being bound. Simplifying that to
|
|
29
|
+
* `DataServerProtocol<TTransfer>` compiles and costs the wrappers their
|
|
30
|
+
* return type: every call through `TServer` would resolve against that looser
|
|
31
|
+
* bound, so an adopter's diagnostics would come back as the framework's and
|
|
32
|
+
* the document would have to be cast on the way out.
|
|
39
33
|
*/
|
|
40
34
|
class DataSession {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
generation;
|
|
35
|
+
clientId;
|
|
36
|
+
host;
|
|
37
|
+
/** URIs this session holds open, so {@link dispose} can release exactly those. */
|
|
38
|
+
openUris = new Set();
|
|
46
39
|
disposed = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
this.client = client;
|
|
51
|
-
this.methodNamespace = options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX;
|
|
52
|
-
this.portDisposeListener = this.port.onDispose(() => this.dropGeneration());
|
|
53
|
-
}
|
|
54
|
-
/** The identity every request is made under — the port's, not a second one. */
|
|
55
|
-
get clientId() {
|
|
56
|
-
return this.port.clientId;
|
|
40
|
+
constructor(clientId, host) {
|
|
41
|
+
this.clientId = clientId;
|
|
42
|
+
this.host = host;
|
|
57
43
|
}
|
|
58
44
|
/**
|
|
59
|
-
* The connected, READY server proxy
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* proxy, so a caller that cached one from an earlier call would go on
|
|
63
|
-
* addressing a dead connection with no error — handing it back per call
|
|
64
|
-
* makes the stale reference unrepresentable.
|
|
65
|
-
*
|
|
66
|
-
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
67
|
-
* awaited once per generation and not once per caller.
|
|
45
|
+
* The connected, READY server proxy, for protocol methods this session does
|
|
46
|
+
* not wrap — the ones carrying no `clientId`, so no identity can be got
|
|
47
|
+
* wrong through them.
|
|
68
48
|
*/
|
|
69
49
|
async connected() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
generation.ready = this.awaitReady(generation);
|
|
76
|
-
}
|
|
77
|
-
await generation.ready;
|
|
78
|
-
return generation.server;
|
|
50
|
+
// `async` so a disposed session REJECTS rather than throwing
|
|
51
|
+
// synchronously: the connection's own `connected` rejects, and a caller
|
|
52
|
+
// reaching for `.catch` on one of them would not catch the other.
|
|
53
|
+
this.assertLive();
|
|
54
|
+
return this.host.connected();
|
|
79
55
|
}
|
|
80
56
|
/**
|
|
81
|
-
* Open `uri` for editing and start watching it, in that order,
|
|
82
|
-
* the opened snapshot.
|
|
57
|
+
* Open `args.uri` for editing and start watching it, in that order,
|
|
58
|
+
* returning the opened snapshot.
|
|
83
59
|
*
|
|
84
60
|
* **The order is the whole reason this method exists.**
|
|
85
61
|
* `watchModelDocument` baselines its dedup fingerprint from the *current*
|
|
@@ -95,22 +71,34 @@ class DataSession {
|
|
|
95
71
|
* Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
|
|
96
72
|
* from `getModelDocument({ includeDiagnostics: true })`.
|
|
97
73
|
*/
|
|
98
|
-
async openDocument(
|
|
74
|
+
async openDocument(args) {
|
|
99
75
|
const server = await this.connected();
|
|
100
|
-
const document = await server.openModelDocument({
|
|
101
|
-
await server.watchModelDocument({ uri, clientId: this.clientId });
|
|
76
|
+
const document = await server.openModelDocument({ ...args, clientId: this.clientId });
|
|
77
|
+
await server.watchModelDocument({ uri: args.uri, clientId: this.clientId });
|
|
78
|
+
this.openUris.add(args.uri);
|
|
102
79
|
return document;
|
|
103
80
|
}
|
|
104
81
|
/**
|
|
105
|
-
* Close `uri`. The server unwatches implicitly, so this is the dual of
|
|
82
|
+
* Close `args.uri`. The server unwatches implicitly, so this is the dual of
|
|
106
83
|
* {@link openDocument} and needs no separate unwatch.
|
|
107
84
|
*/
|
|
108
|
-
async closeDocument(
|
|
85
|
+
async closeDocument(args) {
|
|
86
|
+
const server = await this.connected();
|
|
87
|
+
this.openUris.delete(args.uri);
|
|
88
|
+
await server.closeModelDocument({ ...args, clientId: this.clientId });
|
|
89
|
+
}
|
|
90
|
+
/** Write `args.model` back as this session. */
|
|
91
|
+
async updateDocument(args) {
|
|
109
92
|
const server = await this.connected();
|
|
110
|
-
|
|
93
|
+
return server.updateModelDocument({ ...args, clientId: this.clientId });
|
|
94
|
+
}
|
|
95
|
+
/** Persist `args.model` to disk as this session. */
|
|
96
|
+
async saveDocument(args) {
|
|
97
|
+
const server = await this.connected();
|
|
98
|
+
return server.saveModelDocument({ ...args, clientId: this.clientId });
|
|
111
99
|
}
|
|
112
100
|
/**
|
|
113
|
-
* Whether `
|
|
101
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
114
102
|
*
|
|
115
103
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
116
104
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
@@ -119,60 +107,45 @@ class DataSession {
|
|
|
119
107
|
isOwnEcho(sourceClientId) {
|
|
120
108
|
return sourceClientId === this.clientId;
|
|
121
109
|
}
|
|
122
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Release this session's holds and detach it from the connection.
|
|
112
|
+
* Idempotent, and leaves the connection usable by its other sessions.
|
|
113
|
+
*
|
|
114
|
+
* The closes are fired without being awaited, because a `Disposable` cannot
|
|
115
|
+
* be: a host disposing a widget has nowhere to put the promise. A close
|
|
116
|
+
* that fails is no worse than the leak this exists to prevent, so the
|
|
117
|
+
* rejection is swallowed rather than surfaced from a teardown.
|
|
118
|
+
*/
|
|
123
119
|
dispose() {
|
|
124
120
|
if (this.disposed) {
|
|
125
121
|
return;
|
|
126
122
|
}
|
|
127
123
|
this.disposed = true;
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const connection = this.port.connect();
|
|
137
|
-
// Rejection is reported here rather than left to float: an unhandled
|
|
138
|
-
// rejection on a connection promise is the failure mode that reads as
|
|
139
|
-
// "the model is empty" instead of "the transport never opened".
|
|
140
|
-
connection.catch((error) => this.port.reportError(error, 'connecting to the data server'));
|
|
141
|
-
const server = (0, rpc_1.createRpcProxy)(connection, {
|
|
142
|
-
methodNamespace: this.methodNamespace,
|
|
143
|
-
localTarget: this.client,
|
|
144
|
-
localMethods: data_1.DATA_CLIENT_PROTOCOL_METHODS
|
|
145
|
-
});
|
|
146
|
-
this.generation = { connection, server };
|
|
147
|
-
return this.generation;
|
|
148
|
-
}
|
|
149
|
-
/** Await the connection and the server's startup gate for one generation. */
|
|
150
|
-
async awaitReady(generation) {
|
|
151
|
-
try {
|
|
152
|
-
await generation.connection;
|
|
153
|
-
await generation.server.waitForReady();
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
// Drop the generation so the next request retries rather than
|
|
157
|
-
// re-awaiting a settled rejection forever.
|
|
158
|
-
if (this.generation === generation) {
|
|
159
|
-
this.generation = undefined;
|
|
160
|
-
}
|
|
161
|
-
this.port.reportError(error, 'waiting for the data server to become ready');
|
|
162
|
-
throw error;
|
|
124
|
+
const uris = [...this.openUris];
|
|
125
|
+
this.openUris.clear();
|
|
126
|
+
this.host.releaseSession(this);
|
|
127
|
+
for (const uri of uris) {
|
|
128
|
+
void this.host
|
|
129
|
+
.connected()
|
|
130
|
+
.then(server => server.closeModelDocument({ uri, clientId: this.clientId }))
|
|
131
|
+
.catch(() => undefined);
|
|
163
132
|
}
|
|
164
133
|
}
|
|
165
134
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
135
|
+
* Come off the connection because it is going away.
|
|
136
|
+
*
|
|
137
|
+
* Sends no close, unlike {@link dispose}: the server releases every hold on
|
|
138
|
+
* a connection it sees close, and the close would travel over the very
|
|
139
|
+
* connection being disposed.
|
|
168
140
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
141
|
+
detach() {
|
|
142
|
+
this.disposed = true;
|
|
143
|
+
this.openUris.clear();
|
|
144
|
+
}
|
|
145
|
+
assertLive() {
|
|
146
|
+
if (this.disposed) {
|
|
147
|
+
throw new Error('DataSession is disposed');
|
|
174
148
|
}
|
|
175
|
-
generation.connection.then(connection => connection.dispose()).catch(() => undefined);
|
|
176
149
|
}
|
|
177
150
|
}
|
|
178
151
|
exports.DataSession = DataSession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AA2DlF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,WAAW;IAST;IACU;IANtB,kFAAkF;IAC/D,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,QAAQ,GAAG,KAAK,CAAC;IAE3B,YACY,QAAgB,EACN,IAAyC;QADnD,aAAQ,GAAR,QAAQ,CAAQ;QACN,SAAI,GAAJ,IAAI,CAAqC;IAC5D,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,SAAS;QACZ,6DAA6D;QAC7D,wEAAwE;QACxE,kEAAkE;QAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,CAAC;IAED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EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,cAAsB;QAC7B,OAAO,cAAc,KAAK,IAAI,CAAC,QAAQ,CAAC;IAC3C,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO;QACJ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO;QACV,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACtB,KAAK,IAAI,CAAC,IAAI;iBACV,SAAS,EAAE;iBACX,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC3E,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAES,UAAU;QACjB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC9C,CAAC;IACJ,CAAC;CACH;AA/HD,kCA+HC"}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Where `./data` is the wire *contract* and `./rpc` is the machinery that lowers
|
|
14
14
|
* it onto a connection, this is what a client wraps around both: the seam a host
|
|
15
|
-
* fills in (`DataPort`), the
|
|
16
|
-
*
|
|
15
|
+
* fills in (`DataPort`), the connection above it (`DataConnection` — readiness
|
|
16
|
+
* gate and reconnect), the participants on that connection (`DataSession` —
|
|
17
|
+
* identity, open/watch ordering, echo recognition), the inbound
|
|
17
18
|
* fan-out (`DataEvents`), and the two halves of the hop for hosts whose
|
|
18
19
|
* client cannot hold a socket — `createPostMessageTransport` on the client
|
|
19
20
|
* side and `relayToPostMessageChannel` on the side that does hold it.
|
|
@@ -25,15 +26,17 @@
|
|
|
25
26
|
* carries the entries.
|
|
26
27
|
*
|
|
27
28
|
* The Theia-specific mounting of the same contract lives in
|
|
28
|
-
* `@hydranium/data-client-theia
|
|
29
|
-
*
|
|
30
|
-
* is the Theia-bound counterpart of `DataEvents`.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* `@hydranium/data-client-theia`, and is now only the TRANSPORT: its
|
|
30
|
+
* `ChannelDataPort` fills the `DataPort` seam over a Theia channel, and its
|
|
31
|
+
* `EmitterDataClient` is the Theia-bound counterpart of `DataEvents`.
|
|
32
|
+
* Everything above the port is here, so a Theia frontend and a browser page
|
|
33
|
+
* differ by which port they construct and nothing else.
|
|
33
34
|
*/
|
|
35
|
+
export * from './data-connection';
|
|
34
36
|
export * from './data-events';
|
|
35
37
|
export * from './data-port';
|
|
36
38
|
export * from './data-session';
|
|
37
39
|
export * from './message-relay';
|
|
38
40
|
export * from './post-message-transport';
|
|
41
|
+
export * from './rpc-connection';
|
|
39
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
|
package/lib/client/index.js
CHANGED
|
@@ -28,8 +28,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
*
|
|
29
29
|
* Where `./data` is the wire *contract* and `./rpc` is the machinery that lowers
|
|
30
30
|
* it onto a connection, this is what a client wraps around both: the seam a host
|
|
31
|
-
* fills in (`DataPort`), the
|
|
32
|
-
*
|
|
31
|
+
* fills in (`DataPort`), the connection above it (`DataConnection` — readiness
|
|
32
|
+
* gate and reconnect), the participants on that connection (`DataSession` —
|
|
33
|
+
* identity, open/watch ordering, echo recognition), the inbound
|
|
33
34
|
* fan-out (`DataEvents`), and the two halves of the hop for hosts whose
|
|
34
35
|
* client cannot hold a socket — `createPostMessageTransport` on the client
|
|
35
36
|
* side and `relayToPostMessageChannel` on the side that does hold it.
|
|
@@ -41,15 +42,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
42
|
* carries the entries.
|
|
42
43
|
*
|
|
43
44
|
* The Theia-specific mounting of the same contract lives in
|
|
44
|
-
* `@hydranium/data-client-theia
|
|
45
|
-
*
|
|
46
|
-
* is the Theia-bound counterpart of `DataEvents`.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
45
|
+
* `@hydranium/data-client-theia`, and is now only the TRANSPORT: its
|
|
46
|
+
* `ChannelDataPort` fills the `DataPort` seam over a Theia channel, and its
|
|
47
|
+
* `EmitterDataClient` is the Theia-bound counterpart of `DataEvents`.
|
|
48
|
+
* Everything above the port is here, so a Theia frontend and a browser page
|
|
49
|
+
* differ by which port they construct and nothing else.
|
|
49
50
|
*/
|
|
51
|
+
__exportStar(require("./data-connection"), exports);
|
|
50
52
|
__exportStar(require("./data-events"), exports);
|
|
51
53
|
__exportStar(require("./data-port"), exports);
|
|
52
54
|
__exportStar(require("./data-session"), exports);
|
|
53
55
|
__exportStar(require("./message-relay"), exports);
|
|
54
56
|
__exportStar(require("./post-message-transport"), exports);
|
|
57
|
+
__exportStar(require("./rpc-connection"), exports);
|
|
55
58
|
//# sourceMappingURL=index.js.map
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,oDAAkC;AAClC,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B;AAC/B,kDAAgC;AAChC,2DAAyC;AACzC,mDAAiC"}
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Disposable, type Event, type MessageReader, type MessageWriter } from 'vscode-jsonrpc';
|
|
10
|
+
import { type ResolvedMessage } from '../messages/primitives';
|
|
10
11
|
import type { PostMessageChannel } from './post-message-transport';
|
|
12
|
+
export declare const RELAY_TRANSPORT_OPEN_FAILED: import("../messages/primitives").MessageDefinition<"Could not open the transport to relay: {detail}">;
|
|
13
|
+
export declare const RELAY_TRANSPORT_READ_FAILED: import("../messages/primitives").MessageDefinition<"Could not read from the relayed transport: {detail}">;
|
|
14
|
+
export declare const RELAY_TRANSPORT_WRITE_FAILED: import("../messages/primitives").MessageDefinition<"Could not write to the relayed transport: {detail}">;
|
|
15
|
+
export declare const RELAY_REPLAY_FAILED: import("../messages/primitives").MessageDefinition<"Could not replay a buffered message to the relayed transport: {detail}">;
|
|
11
16
|
/**
|
|
12
17
|
* The framed side of a relay: the reader/writer pair over whatever transport the
|
|
13
18
|
* host actually holds — a TCP socket to the data-server, a child process' stdio,
|
|
@@ -27,13 +32,14 @@ export interface RelayTransport {
|
|
|
27
32
|
export interface MessageRelayOptions {
|
|
28
33
|
/**
|
|
29
34
|
* Surface a failure the way the host does. Same contract as
|
|
30
|
-
* `DataPort.reportError`: `
|
|
35
|
+
* `DataPort.reportError`: `reported` is a complete sentence plus the identity
|
|
36
|
+
* needed to render it in another language.
|
|
31
37
|
*
|
|
32
38
|
* A relay has no other way to report — it sits between two transports and
|
|
33
39
|
* owns neither, so a swallowed error here presents as a form that never
|
|
34
40
|
* populates.
|
|
35
41
|
*/
|
|
36
|
-
readonly reportError?: (error: unknown,
|
|
42
|
+
readonly reportError?: (error: unknown, reported: ResolvedMessage) => void;
|
|
37
43
|
}
|
|
38
44
|
/** A live relay. Dispose to tear both directions down. */
|
|
39
45
|
export interface MessageRelay extends Disposable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,KAAK,EAAgB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gEAAgE;IAChE,OAAO,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC
|
|
1
|
+
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF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