@hydranium/protocol 1.0.0-next.8 → 1.0.0-next.86

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 (124) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +114 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +128 -0
  5. package/lib/client/data-connection.js.map +1 -0
  6. package/lib/client/data-events.d.ts +9 -1
  7. package/lib/client/data-events.d.ts.map +1 -1
  8. package/lib/client/data-events.js +14 -0
  9. package/lib/client/data-events.js.map +1 -1
  10. package/lib/client/data-port.d.ts +17 -22
  11. package/lib/client/data-port.d.ts.map +1 -1
  12. package/lib/client/data-session.d.ts +95 -78
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +115 -108
  15. package/lib/client/data-session.js.map +1 -1
  16. package/lib/client/index.d.ts +10 -7
  17. package/lib/client/index.d.ts.map +1 -1
  18. package/lib/client/index.js +10 -7
  19. package/lib/client/index.js.map +1 -1
  20. package/lib/client/message-relay.d.ts +8 -2
  21. package/lib/client/message-relay.d.ts.map +1 -1
  22. package/lib/client/message-relay.js +10 -4
  23. package/lib/client/message-relay.js.map +1 -1
  24. package/lib/client/rpc-connection.d.ts +139 -0
  25. package/lib/client/rpc-connection.d.ts.map +1 -0
  26. package/lib/client/rpc-connection.js +171 -0
  27. package/lib/client/rpc-connection.js.map +1 -0
  28. package/lib/client-ids.d.ts +41 -0
  29. package/lib/client-ids.d.ts.map +1 -0
  30. package/lib/client-ids.js +44 -0
  31. package/lib/client-ids.js.map +1 -0
  32. package/lib/data/data-protocol-methods.d.ts +2 -2
  33. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  34. package/lib/data/data-protocol-methods.js +6 -1
  35. package/lib/data/data-protocol-methods.js.map +1 -1
  36. package/lib/data/data-server-protocol.d.ts +35 -2
  37. package/lib/data/data-server-protocol.d.ts.map +1 -1
  38. package/lib/data/events.d.ts +70 -3
  39. package/lib/data/events.d.ts.map +1 -1
  40. package/lib/errors.d.ts +28 -11
  41. package/lib/errors.d.ts.map +1 -1
  42. package/lib/errors.js +35 -17
  43. package/lib/errors.js.map +1 -1
  44. package/lib/index.d.ts +2 -0
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +5 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/messages/index.d.ts +28 -0
  49. package/lib/messages/index.d.ts.map +1 -0
  50. package/lib/messages/index.js +52 -0
  51. package/lib/messages/index.js.map +1 -0
  52. package/lib/messages/primitives.d.ts +141 -0
  53. package/lib/messages/primitives.d.ts.map +1 -0
  54. package/lib/messages/primitives.js +138 -0
  55. package/lib/messages/primitives.js.map +1 -0
  56. package/lib/model-server.d.ts +27 -10
  57. package/lib/model-server.d.ts.map +1 -1
  58. package/lib/model-server.js +4 -2
  59. package/lib/model-server.js.map +1 -1
  60. package/lib/model-service/args.d.ts +14 -13
  61. package/lib/model-service/args.d.ts.map +1 -1
  62. package/lib/model-service/based-on.d.ts +55 -0
  63. package/lib/model-service/based-on.d.ts.map +1 -0
  64. package/lib/model-service/based-on.js +34 -0
  65. package/lib/model-service/based-on.js.map +1 -0
  66. package/lib/model-service/index.d.ts +1 -0
  67. package/lib/model-service/index.d.ts.map +1 -1
  68. package/lib/model-service/index.js +1 -0
  69. package/lib/model-service/index.js.map +1 -1
  70. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  71. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  72. package/lib/rpc/bind-rpc-methods.js +22 -3
  73. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  74. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  75. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  76. package/lib/rpc/create-rpc-proxy.js +6 -1
  77. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  78. package/lib/testing/catalogue-audit.d.ts +80 -0
  79. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  80. package/lib/testing/catalogue-audit.js +94 -0
  81. package/lib/testing/catalogue-audit.js.map +1 -0
  82. package/lib/testing/data-doubles.d.ts +11 -12
  83. package/lib/testing/data-doubles.d.ts.map +1 -1
  84. package/lib/testing/data-doubles.js +14 -5
  85. package/lib/testing/data-doubles.js.map +1 -1
  86. package/lib/testing/index.d.ts +1 -0
  87. package/lib/testing/index.d.ts.map +1 -1
  88. package/lib/testing/index.js +4 -1
  89. package/lib/testing/index.js.map +1 -1
  90. package/lib/transfer-diagnostic.d.ts +33 -0
  91. package/lib/transfer-diagnostic.d.ts.map +1 -1
  92. package/lib/transfer-diagnostic.js +23 -0
  93. package/lib/transfer-diagnostic.js.map +1 -1
  94. package/lib/transfer-document.d.ts +15 -5
  95. package/lib/transfer-document.d.ts.map +1 -1
  96. package/lib/transfer-document.js +14 -1
  97. package/lib/transfer-document.js.map +1 -1
  98. package/package.json +11 -2
  99. package/src/client/data-connection.ts +181 -0
  100. package/src/client/data-events.ts +24 -1
  101. package/src/client/data-port.ts +17 -23
  102. package/src/client/data-session.ts +172 -131
  103. package/src/client/index.ts +10 -7
  104. package/src/client/message-relay.ts +28 -6
  105. package/src/client/rpc-connection.ts +230 -0
  106. package/src/client-ids.ts +45 -0
  107. package/src/data/data-protocol-methods.ts +6 -3
  108. package/src/data/data-server-protocol.ts +46 -2
  109. package/src/data/events.ts +74 -3
  110. package/src/errors.ts +41 -19
  111. package/src/index.ts +5 -0
  112. package/src/messages/index.ts +35 -0
  113. package/src/messages/primitives.ts +215 -0
  114. package/src/model-server.ts +30 -11
  115. package/src/model-service/args.ts +15 -13
  116. package/src/model-service/based-on.ts +60 -0
  117. package/src/model-service/index.ts +1 -0
  118. package/src/rpc/bind-rpc-methods.ts +49 -4
  119. package/src/rpc/create-rpc-proxy.ts +14 -1
  120. package/src/testing/catalogue-audit.ts +111 -0
  121. package/src/testing/data-doubles.ts +33 -17
  122. package/src/testing/index.ts +4 -1
  123. package/src/transfer-diagnostic.ts +40 -0
  124. package/src/transfer-document.ts +22 -6
@@ -6,84 +6,84 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import type { MessageConnection } from 'vscode-jsonrpc';
10
- import { type DataClientProtocol, type DataServerProtocol } from '../data';
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
- import type { DataPort } from './data-port';
15
- /** Options for {@link DataSession}. */
16
- export interface DataSessionOptions {
17
- /**
18
- * Wire namespace the server is addressed under. Defaults to the
19
- * framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
20
- * `DataServer` binds. Override only alongside the server's own
21
- * `methodNamespace` option — a mismatch turns every request into
22
- * "Unhandled method" rather than failing at wire-up.
23
- */
24
- readonly methodNamespace?: string;
25
- }
26
- /** One connection generation: its connection, its proxy, and its readiness. */
27
- interface Generation<TTransfer extends TransferElement> {
28
- readonly connection: Promise<MessageConnection>;
29
- readonly server: RpcProxy<DataServerProtocol<TTransfer>>;
30
- /** Set on first use; the shared readiness gate for this generation. */
31
- ready?: Promise<void>;
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
- * The host-invariant half of talking to the data head: everything above
35
- * {@link DataPort} that would otherwise be re-derived by every host
36
- * adapter.
44
+ * One participant on a data connection: a properties panel, a tree, a
45
+ * form editor.
37
46
  *
38
- * Three jobs, and deliberately no fourth:
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
- * 1. **Build the typed proxy** over the port's connection, with the framework's
41
- * wire prefix and its drift-proof client-method allowlist.
42
- * 2. **Own the readiness gate** — `waitForReady` once per connection, shared
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
- * It does **not** wrap the protocol methods; callers reach them through
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
- * Generic over the transfer root so this file names no grammar. An adopter
56
- * binds the concrete root (or the union of them, for a multi-grammar head) at
57
- * its own edge.
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
- protected readonly port: DataPort;
61
- protected readonly client: DataClientProtocol<TTransfer>;
62
- protected readonly methodNamespace: string;
63
- /** The current generation, or `undefined` before the first request / after a teardown. */
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
- protected readonly portDisposeListener: {
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;
72
71
  /**
73
- * The connected, READY server proxy.
74
- *
75
- * Returns the proxy rather than `void` on purpose. A reconnect replaces the
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.
72
+ * Disposed through {@link detach} rather than {@link dispose}, so nothing may
73
+ * be sent. Folding it into {@link disposed} costs {@link openDocument} the
74
+ * distinction, and its close would then go out on a detached session.
82
75
  */
83
- connected(): Promise<RpcProxy<DataServerProtocol<TTransfer>>>;
76
+ protected detached: boolean;
77
+ constructor(clientId: string, host: DataSessionHost<TTransfer, TServer>);
84
78
  /**
85
- * Open `uri` for editing and start watching it, in that order, returning
86
- * the opened snapshot.
79
+ * The connected, READY server proxy, for protocol methods this session does
80
+ * not wrap — the ones carrying no `clientId`, so no identity can be got
81
+ * wrong through them.
82
+ */
83
+ connected(): Promise<RpcProxy<TServer>>;
84
+ /**
85
+ * Open `args.uri` for editing and start watching it, in that order,
86
+ * returning the opened snapshot.
87
87
  *
88
88
  * **The order is the whole reason this method exists.**
89
89
  * `watchModelDocument` baselines its dedup fingerprint from the *current*
@@ -98,32 +98,49 @@ export declare class DataSession<TTransfer extends TransferElement> {
98
98
  * valid: `open` settles at the integrity landmark, not at validation.
99
99
  * Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
100
100
  * from `getModelDocument({ includeDiagnostics: true })`.
101
+ *
102
+ * A dispose landing between the two awaits is handled here rather than in
103
+ * {@link dispose}, which cannot release a hold that does not exist yet: it
104
+ * reads {@link openUris}, and this method fills it only once both calls have
105
+ * returned. Left to `dispose`, the hold and its watch outlive the participant
106
+ * and go only when the connection closes.
101
107
  */
102
- openDocument(uri: string): Promise<TransferDocument<TTransfer>>;
108
+ openDocument(args: DataSessionOpenArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
103
109
  /**
104
- * Close `uri`. The server unwatches implicitly, so this is the dual of
110
+ * Close `args.uri`. The server unwatches implicitly, so this is the dual of
105
111
  * {@link openDocument} and needs no separate unwatch.
106
112
  */
107
- closeDocument(uri: string): Promise<void>;
113
+ closeDocument(args: DataSessionCloseArgs<TTransfer, TServer>): Promise<void>;
114
+ /** Write `args.model` back as this session. */
115
+ updateDocument(args: DataSessionUpdateArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
116
+ /** Persist `args.model` to disk as this session. */
117
+ saveDocument(args: DataSessionSaveArgs<TTransfer, TServer>): Promise<DataSessionDocument<TTransfer, TServer>>;
108
118
  /**
109
- * Whether `event.sourceClientId` identifies this session's own write.
119
+ * Whether `sourceClientId` identifies this session's own write.
110
120
  *
111
121
  * Every watcher needs this and the check is one comparison, so getting it
112
122
  * wrong is cheap to do and expensive to find: an unfiltered echo looks
113
123
  * exactly like a concurrent third-party edit.
114
124
  */
115
125
  isOwnEcho(sourceClientId: string): boolean;
116
- /** Tear down the current connection and stop tracking the port. Idempotent. */
126
+ /**
127
+ * Release this session's holds and detach it from the connection.
128
+ * Idempotent, and leaves the connection usable by its other sessions.
129
+ *
130
+ * The closes are fired without being awaited, because a `Disposable` cannot
131
+ * be: a host disposing a widget has nowhere to put the promise. A close
132
+ * that fails is no worse than the leak this exists to prevent, so the
133
+ * rejection is swallowed rather than surfaced from a teardown.
134
+ */
117
135
  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
136
  /**
123
- * Discard the current generation, disposing its connection if it opened.
124
- * The next {@link connected} builds a fresh one.
137
+ * Come off the connection because it is going away.
138
+ *
139
+ * Sends no close, unlike {@link dispose}: the server releases every hold on
140
+ * a connection it sees close, and the close would travel over the very
141
+ * connection being disposed.
125
142
  */
126
- protected dropGeneration(): void;
143
+ detach(): void;
144
+ protected assertLive(): void;
127
145
  }
128
- export {};
129
146
  //# 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,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAyD,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClI,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,+EAA+E;AAC/E,UAAU,UAAU,CAAC,SAAS,SAAS,eAAe;IACnD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,WAAW,CAAC,SAAS,SAAS,eAAe;IAQpD,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ;IACjC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,SAAS,CAAC;IAR3D,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAC3C,0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O,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAwBnH;;;OAGG;IACG,aAAa,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlF,+CAA+C;IACzC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,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;IAMd,SAAS,CAAC,UAAU,IAAI,IAAI;CAK9B"}
@@ -9,77 +9,59 @@
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
- * The host-invariant half of talking to the data head: everything above
16
- * {@link DataPort} that would otherwise be re-derived by every host
17
- * adapter.
13
+ * One participant on a data connection: a properties panel, a tree, a
14
+ * form editor.
18
15
  *
19
- * Three jobs, and deliberately no fourth:
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
- * 1. **Build the typed proxy** over the port's connection, with the framework's
22
- * wire prefix and its drift-proof client-method allowlist.
23
- * 2. **Own the readiness gate** — `waitForReady` once per connection, shared
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
- * It does **not** wrap the protocol methods; callers reach them through
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
- * Generic over the transfer root so this file names no grammar. An adopter
37
- * binds the concrete root (or the union of them, for a multi-grammar head) at
38
- * its own edge.
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
- port;
42
- client;
43
- methodNamespace;
44
- /** The current generation, or `undefined` before the first request / after a teardown. */
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
- portDisposeListener;
48
- constructor(port, client, options = {}) {
49
- this.port = port;
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
+ /**
41
+ * Disposed through {@link detach} rather than {@link dispose}, so nothing may
42
+ * be sent. Folding it into {@link disposed} costs {@link openDocument} the
43
+ * distinction, and its close would then go out on a detached session.
44
+ */
45
+ detached = false;
46
+ constructor(clientId, host) {
47
+ this.clientId = clientId;
48
+ this.host = host;
57
49
  }
58
50
  /**
59
- * The connected, READY server proxy.
60
- *
61
- * Returns the proxy rather than `void` on purpose. A reconnect replaces the
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.
51
+ * The connected, READY server proxy, for protocol methods this session does
52
+ * not wrap — the ones carrying no `clientId`, so no identity can be got
53
+ * wrong through them.
68
54
  */
69
55
  async connected() {
70
- if (this.disposed) {
71
- throw new Error('DataSession is disposed');
72
- }
73
- const generation = this.currentGeneration();
74
- if (!generation.ready) {
75
- generation.ready = this.awaitReady(generation);
76
- }
77
- await generation.ready;
78
- return generation.server;
56
+ // `async` so a disposed session REJECTS rather than throwing
57
+ // synchronously: the connection's own `connected` rejects, and a caller
58
+ // reaching for `.catch` on one of them would not catch the other.
59
+ this.assertLive();
60
+ return this.host.connected();
79
61
  }
80
62
  /**
81
- * Open `uri` for editing and start watching it, in that order, returning
82
- * the opened snapshot.
63
+ * Open `args.uri` for editing and start watching it, in that order,
64
+ * returning the opened snapshot.
83
65
  *
84
66
  * **The order is the whole reason this method exists.**
85
67
  * `watchModelDocument` baselines its dedup fingerprint from the *current*
@@ -94,23 +76,62 @@ class DataSession {
94
76
  * valid: `open` settles at the integrity landmark, not at validation.
95
77
  * Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
96
78
  * from `getModelDocument({ includeDiagnostics: true })`.
79
+ *
80
+ * A dispose landing between the two awaits is handled here rather than in
81
+ * {@link dispose}, which cannot release a hold that does not exist yet: it
82
+ * reads {@link openUris}, and this method fills it only once both calls have
83
+ * returned. Left to `dispose`, the hold and its watch outlive the participant
84
+ * and go only when the connection closes.
97
85
  */
98
- async openDocument(uri) {
86
+ async openDocument(args) {
99
87
  const server = await this.connected();
100
- const document = await server.openModelDocument({ uri, clientId: this.clientId });
101
- await server.watchModelDocument({ uri, clientId: this.clientId });
88
+ const document = await server.openModelDocument({ ...args, clientId: this.clientId });
89
+ await server.watchModelDocument({ uri: args.uri, clientId: this.clientId });
90
+ if (this.disposed) {
91
+ // Registering the URI BEFORE the open, so `dispose` could close on
92
+ // intent, is NOT the same fix and can invert into the leak it is meant
93
+ // to prevent: the close would then be issued while the open is still in
94
+ // flight, and a peer that does not serialise the two can complete the
95
+ // close first, after which the open re-registers the hold. Closing
96
+ // strictly after the open has resolved is the only ordering with no
97
+ // losing interleaving.
98
+ if (!this.detached) {
99
+ void server.closeModelDocument({ uri: args.uri, clientId: this.clientId }).catch(() => undefined);
100
+ }
101
+ // Returned rather than thrown: the caller that reaches this window is
102
+ // one that never awaited the open, so a rejection here surfaces as an
103
+ // unhandled one against a participant already gone.
104
+ return document;
105
+ }
106
+ this.openUris.add(args.uri);
102
107
  return document;
103
108
  }
104
109
  /**
105
- * Close `uri`. The server unwatches implicitly, so this is the dual of
110
+ * Close `args.uri`. The server unwatches implicitly, so this is the dual of
106
111
  * {@link openDocument} and needs no separate unwatch.
107
112
  */
108
- async closeDocument(uri) {
113
+ async closeDocument(args) {
114
+ const server = await this.connected();
115
+ await server.closeModelDocument({ ...args, clientId: this.clientId });
116
+ // Untracked only once the close has actually landed. Dropping it first
117
+ // gives a FAILED close the same effect as a successful one: the hold
118
+ // survives on the server and `dispose` no longer knows to retry it.
119
+ // A `dispose` racing this therefore closes the same URI twice, which the
120
+ // server answers as a no-op for a client that no longer holds it.
121
+ this.openUris.delete(args.uri);
122
+ }
123
+ /** Write `args.model` back as this session. */
124
+ async updateDocument(args) {
109
125
  const server = await this.connected();
110
- await server.closeModelDocument({ uri, clientId: this.clientId });
126
+ return server.updateModelDocument({ ...args, clientId: this.clientId });
127
+ }
128
+ /** Persist `args.model` to disk as this session. */
129
+ async saveDocument(args) {
130
+ const server = await this.connected();
131
+ return server.saveModelDocument({ ...args, clientId: this.clientId });
111
132
  }
112
133
  /**
113
- * Whether `event.sourceClientId` identifies this session's own write.
134
+ * Whether `sourceClientId` identifies this session's own write.
114
135
  *
115
136
  * Every watcher needs this and the check is one comparison, so getting it
116
137
  * wrong is cheap to do and expensive to find: an unfiltered echo looks
@@ -119,60 +140,46 @@ class DataSession {
119
140
  isOwnEcho(sourceClientId) {
120
141
  return sourceClientId === this.clientId;
121
142
  }
122
- /** Tear down the current connection and stop tracking the port. Idempotent. */
143
+ /**
144
+ * Release this session's holds and detach it from the connection.
145
+ * Idempotent, and leaves the connection usable by its other sessions.
146
+ *
147
+ * The closes are fired without being awaited, because a `Disposable` cannot
148
+ * be: a host disposing a widget has nowhere to put the promise. A close
149
+ * that fails is no worse than the leak this exists to prevent, so the
150
+ * rejection is swallowed rather than surfaced from a teardown.
151
+ */
123
152
  dispose() {
124
153
  if (this.disposed) {
125
154
  return;
126
155
  }
127
156
  this.disposed = true;
128
- this.portDisposeListener.dispose();
129
- this.dropGeneration();
130
- }
131
- /** The live generation, building one if there is none. */
132
- currentGeneration() {
133
- if (this.generation) {
134
- return this.generation;
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;
157
+ const uris = [...this.openUris];
158
+ this.openUris.clear();
159
+ this.host.releaseSession(this);
160
+ for (const uri of uris) {
161
+ void this.host
162
+ .connected()
163
+ .then(server => server.closeModelDocument({ uri, clientId: this.clientId }))
164
+ .catch(() => undefined);
163
165
  }
164
166
  }
165
167
  /**
166
- * Discard the current generation, disposing its connection if it opened.
167
- * The next {@link connected} builds a fresh one.
168
+ * Come off the connection because it is going away.
169
+ *
170
+ * Sends no close, unlike {@link dispose}: the server releases every hold on
171
+ * a connection it sees close, and the close would travel over the very
172
+ * connection being disposed.
168
173
  */
169
- dropGeneration() {
170
- const generation = this.generation;
171
- this.generation = undefined;
172
- if (!generation) {
173
- return;
174
+ detach() {
175
+ this.disposed = true;
176
+ this.detached = true;
177
+ this.openUris.clear();
178
+ }
179
+ assertLive() {
180
+ if (this.disposed) {
181
+ throw new Error('DataSession is disposed');
174
182
  }
175
- generation.connection.then(connection => connection.dispose()).catch(() => undefined);
176
183
  }
177
184
  }
178
185
  exports.DataSession = DataSession;
@@ -1 +1 @@
1
- {"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,kCAAkI;AAClI,gCAAuD;AAyBvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,WAAW;IAQC;IACA;IARH,eAAe,CAAS;IAC3C,0FAA0F;IAChF,UAAU,CAAyB;IACnC,QAAQ,GAAG,KAAK,CAAC;IACR,mBAAmB,CAAsB;IAE5D,YACsB,IAAc,EACd,MAAqC,EACxD,UAA8B,EAAE;QAFb,SAAI,GAAJ,IAAI,CAAU;QACd,WAAM,GAAN,MAAM,CAA+B;QAGxD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,8BAAuB,CAAC;QAC1E,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,+EAA+E;IAC/E,IAAI,QAAQ;QACT,OAAO,IA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AAC,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;AAjKD,kCAiKC"}
@@ -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 lifecycle above it (`DataSession` —
16
- * readiness gate, open/watch ordering, echo recognition, reconnect), the inbound
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`: its `AbstractDataServiceFrontend` solves the
29
- * same problem against Theia's channel transport, and its `EmitterDataClient`
30
- * is the Theia-bound counterpart of `DataEvents`. Prefer this tier for
31
- * anything new, and reach for the Theia package only for what genuinely needs
32
- * Theia DI.
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC"}
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"}
@@ -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 lifecycle above it (`DataSession` —
32
- * readiness gate, open/watch ordering, echo recognition, reconnect), the inbound
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`: its `AbstractDataServiceFrontend` solves the
45
- * same problem against Theia's channel transport, and its `EmitterDataClient`
46
- * is the Theia-bound counterpart of `DataEvents`. Prefer this tier for
47
- * anything new, and reach for the Theia package only for what genuinely needs
48
- * Theia DI.
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