@hydranium/protocol 1.0.0-next.7 → 1.0.0-next.70

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 (104) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +103 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +114 -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 +16 -21
  11. package/lib/client/data-port.d.ts.map +1 -1
  12. package/lib/client/data-session.d.ts +56 -74
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +67 -101
  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 +131 -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 +21 -1
  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 +25 -6
  41. package/lib/errors.d.ts.map +1 -1
  42. package/lib/errors.js +32 -12
  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 +2 -2
  57. package/lib/model-server.d.ts.map +1 -1
  58. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  59. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  60. package/lib/rpc/bind-rpc-methods.js +22 -3
  61. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  62. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  63. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  64. package/lib/rpc/create-rpc-proxy.js +6 -1
  65. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  66. package/lib/testing/catalogue-audit.d.ts +80 -0
  67. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  68. package/lib/testing/catalogue-audit.js +94 -0
  69. package/lib/testing/catalogue-audit.js.map +1 -0
  70. package/lib/testing/data-doubles.d.ts +11 -12
  71. package/lib/testing/data-doubles.d.ts.map +1 -1
  72. package/lib/testing/data-doubles.js +14 -5
  73. package/lib/testing/data-doubles.js.map +1 -1
  74. package/lib/testing/index.d.ts +1 -0
  75. package/lib/testing/index.d.ts.map +1 -1
  76. package/lib/testing/index.js +4 -1
  77. package/lib/testing/index.js.map +1 -1
  78. package/lib/transfer-diagnostic.d.ts +33 -0
  79. package/lib/transfer-diagnostic.d.ts.map +1 -1
  80. package/lib/transfer-diagnostic.js +23 -0
  81. package/lib/transfer-diagnostic.js.map +1 -1
  82. package/package.json +11 -2
  83. package/src/client/data-connection.ts +160 -0
  84. package/src/client/data-events.ts +24 -1
  85. package/src/client/data-port.ts +16 -22
  86. package/src/client/data-session.ts +86 -124
  87. package/src/client/index.ts +10 -7
  88. package/src/client/message-relay.ts +28 -6
  89. package/src/client/rpc-connection.ts +222 -0
  90. package/src/client-ids.ts +45 -0
  91. package/src/data/data-protocol-methods.ts +6 -3
  92. package/src/data/data-server-protocol.ts +29 -1
  93. package/src/data/events.ts +74 -3
  94. package/src/errors.ts +38 -14
  95. package/src/index.ts +5 -0
  96. package/src/messages/index.ts +35 -0
  97. package/src/messages/primitives.ts +215 -0
  98. package/src/model-server.ts +2 -2
  99. package/src/rpc/bind-rpc-methods.ts +49 -4
  100. package/src/rpc/create-rpc-proxy.ts +14 -1
  101. package/src/testing/catalogue-audit.ts +111 -0
  102. package/src/testing/data-doubles.ts +33 -17
  103. package/src/testing/index.ts +4 -1
  104. package/src/transfer-diagnostic.ts +40 -0
package/README.md CHANGED
@@ -60,7 +60,7 @@ names, a worked example — is in
60
60
  @hydranium/protocol # transfer documents, references, RPC machinery
61
61
  @hydranium/protocol/data # DataServerProtocol / DataClientProtocol
62
62
  @hydranium/protocol/client # the host-neutral client tier
63
- @hydranium/protocol/testing # test doubles and waiters
63
+ @hydranium/protocol/testing # test doubles, waiters, catalogue audit
64
64
  @hydranium/protocol/testing/node # the Node-only doubles
65
65
  ```
66
66
 
@@ -69,6 +69,40 @@ narrower surface rather than reach; `testing` is only reachable by its own
69
69
  specifier, which is what keeps the doubles out of a production bundle. The RPC
70
70
  machinery documents itself in [`src/rpc/README.md`](./src/rpc/README.md).
71
71
 
72
+ ### Auditing a translation catalogue
73
+
74
+ An adopter with i18n has one failure mode nothing else catches: a catalogue key
75
+ naming no declared code falls back to the English, which is byte-identical to
76
+ the deliberately-partial behaviour every adopter relies on. So a typo is
77
+ invisible at runtime, and `theia nls-extract` reports what the source declares
78
+ rather than whether a catalogue matches it.
79
+
80
+ `@hydranium/protocol/testing` ships the audit for it — call it from your own
81
+ test, over your own barrels:
82
+
83
+ <!-- snippet-preamble
84
+ import { flattenCatalogue, findUndeclaredCodes, findSharedCodes } from '@hydranium/protocol/testing';
85
+ import * as protocolMessages from '@hydranium/protocol';
86
+ declare const readFileSync: (path: string, encoding: string) => string;
87
+ declare const expect: (actual: unknown) => { toEqual(expected: unknown): void };
88
+ -->
89
+
90
+ ```ts
91
+ const keys = Object.keys(flattenCatalogue(JSON.parse(readFileSync('nls/de.json', 'utf-8'))));
92
+
93
+ // Every key names a code some barrel declares. `exemptPrefixes` is for keys no
94
+ // barrel CAN declare — a host mechanism taking its key as an inline literal.
95
+ expect(findUndeclaredCodes(keys, [protocolMessages])).toEqual([]);
96
+ ```
97
+
98
+ `flattenCatalogue` joins nested keys with `/` (the separator a code already
99
+ uses, and what Theia does to a nested catalogue) and drops `_`-prefixed note
100
+ keys, so a flat server-side catalogue and a nested host-side one both go through
101
+ it. `findSharedCodes` covers the other half: exactly one side renders a given
102
+ message, so two catalogues holding one code are two authorities over one
103
+ sentence — assert both key sets non-empty first, since an empty one satisfies
104
+ disjointness while proving nothing.
105
+
72
106
  ## Status
73
107
 
74
108
  Alpha — pre-v0. The package is being populated incrementally, and its API is
@@ -0,0 +1,103 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type DataClientProtocol, type DataServerProtocol } from '../data';
10
+ import type { TransferElement } from '../transfer-element';
11
+ import { DataEvents } from './data-events';
12
+ import type { DataPort } from './data-port';
13
+ import { DataSession } from './data-session';
14
+ import { RpcConnection, type RpcConnectionLifecycle } from './rpc-connection';
15
+ /** Options for {@link DataConnection}. */
16
+ export interface DataConnectionOptions extends RpcConnectionLifecycle {
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
+ /** {@link DataConnectionOptions} for a client that does not speak {@link DataClientProtocol}. */
27
+ export interface DataConnectionOptionsWithMethods<TClient extends object> extends DataConnectionOptions {
28
+ /**
29
+ * Method names of the client to bind as inbound handlers. Declare it
30
+ * `as const satisfies ReadonlyArray<keyof YourClient & string>` so the list
31
+ * cannot drift from the interface.
32
+ */
33
+ readonly clientMethods: readonly (keyof TClient & string)[];
34
+ }
35
+ /**
36
+ * Trailing constructor arguments, required only when the client cannot take
37
+ * the framework's default method list.
38
+ *
39
+ * `bindRpcMethods` throws for a name the target does not implement, so a
40
+ * request/response-only client binding the default list fails at wire-up. The
41
+ * conditional turns that into a compile error.
42
+ */
43
+ export type DataConnectionArgs<TTransfer extends TransferElement, TClient extends object> = TClient extends DataClientProtocol<TTransfer> ? [options?: DataConnectionOptions & Partial<DataConnectionOptionsWithMethods<TClient>>] : [options: DataConnectionOptionsWithMethods<TClient>];
44
+ /**
45
+ * A {@link RpcConnection} to the data head, carrying as many participants as
46
+ * the host has interested parties.
47
+ *
48
+ * Document operations live on the participants rather than here: they carry a
49
+ * `clientId`, which identifies a participant rather than a wire, and the server
50
+ * keys its holds and watches per `(uri, clientId)`. Two parties sharing one
51
+ * identity cannot tell each other's writes from their own echoes.
52
+ *
53
+ * Generic over the transfer root so this file names no grammar. An adopter
54
+ * binds the concrete root (or the union of them, for a multi-grammar head) at
55
+ * its own edge.
56
+ */
57
+ export declare class DataConnection<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>, TClient extends object = DataClientProtocol<TTransfer>> extends RpcConnection<TServer, TClient> {
58
+ protected readonly sessions: Set<DataSession<TTransfer, TServer>>;
59
+ constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient>);
60
+ /**
61
+ * Mint a participant on this connection under `clientId`.
62
+ *
63
+ * `clientId` must be distinct per participant and stable for its lifetime:
64
+ * it keys the server's per-`(uri, clientId)` hold and watch, and it is the
65
+ * echo key an inbound `onDocumentUpdated` is matched against.
66
+ *
67
+ * Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
68
+ * SERVER emits rather than participants, so a session holding one would read
69
+ * the framework's own broadcasts as its own echoes and drop them. Nothing
70
+ * about that fails on its own: the document simply stops following, which
71
+ * looks like a dead connection.
72
+ */
73
+ createSession(clientId: string): DataSession<TTransfer, TServer>;
74
+ /**
75
+ * Sessions are detached rather than disposed: the server releases every hold
76
+ * on a connection it sees close, so closing each document first sends
77
+ * requests over a connection this call is about to dispose.
78
+ */
79
+ dispose(): void;
80
+ }
81
+ /**
82
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
83
+ * with several interested parties does not have to supply one.
84
+ *
85
+ * **The client slot holds exactly one object, and that is why this exists.**
86
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
87
+ * maps to one handler — a second registration replaces the first silently. So a
88
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
89
+ * slot and both subscribe to it.
90
+ *
91
+ * Use {@link DataConnection} directly instead when the client is yours: an
92
+ * adopter service that implements the protocol plus its own methods, a single
93
+ * consumer that IS the client, or a request/response-only client that binds
94
+ * nothing.
95
+ */
96
+ export declare class DataConnectionWithEvents<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>> extends DataConnection<TTransfer, TServer, DataEvents<TTransfer>> {
97
+ /** Server pushes, fanned out to as many local listeners as the host has. */
98
+ readonly events: DataEvents<TTransfer>;
99
+ constructor(port: DataPort, options?: DataConnectionOptions);
100
+ /** Disposes the fan-out it created, which no caller else holds. */
101
+ dispose(): void;
102
+ }
103
+ //# sourceMappingURL=data-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-connection.d.ts","sourceRoot":"","sources":["../../src/client/data-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAyD,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,0CAA0C;AAC1C,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IAClE;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,iGAAiG;AACjG,MAAM,WAAW,gCAAgC,CAAC,OAAO,SAAS,MAAM,CAAE,SAAQ,qBAAqB;IACpG;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC;CAC9D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,eAAe,EAAE,OAAO,SAAS,MAAM,IACrF,OAAO,SAAS,kBAAkB,CAAC,SAAS,CAAC,GACxC,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC,GACtF,CAAC,OAAO,EAAE,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc,CACxB,SAAS,SAAS,eAAe,EACjC,OAAO,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,EAC7E,OAAO,SAAS,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CACvD,SAAQ,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,QAAQ,CAAC,QAAQ,uCAA8C;gBAE7D,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC;IAY5F;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IAahE;;;;OAIG;IACM,OAAO,IAAI,IAAI;CAO1B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,wBAAwB,CAClC,SAAS,SAAS,eAAe,EACjC,OAAO,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAC9E,SAAQ,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAChE,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;gBAE3B,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAQ3D,mEAAmE;IAC1D,OAAO,IAAI,IAAI;CAI1B"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the MIT License which is available in the project root.
7
+ *
8
+ * SPDX-License-Identifier: MIT
9
+ ********************************************************************************/
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.DataConnectionWithEvents = exports.DataConnection = void 0;
12
+ const client_ids_1 = require("../client-ids");
13
+ const data_1 = require("../data");
14
+ const data_events_1 = require("./data-events");
15
+ const data_session_1 = require("./data-session");
16
+ const rpc_connection_1 = require("./rpc-connection");
17
+ /**
18
+ * A {@link RpcConnection} to the data head, carrying as many participants as
19
+ * the host has interested parties.
20
+ *
21
+ * Document operations live on the participants rather than here: they carry a
22
+ * `clientId`, which identifies a participant rather than a wire, and the server
23
+ * keys its holds and watches per `(uri, clientId)`. Two parties sharing one
24
+ * identity cannot tell each other's writes from their own echoes.
25
+ *
26
+ * Generic over the transfer root so this file names no grammar. An adopter
27
+ * binds the concrete root (or the union of them, for a multi-grammar head) at
28
+ * its own edge.
29
+ */
30
+ class DataConnection extends rpc_connection_1.RpcConnection {
31
+ sessions = new Set();
32
+ constructor(port, client, ...rest) {
33
+ const [options = {}] = rest;
34
+ super(port, client, {
35
+ methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
36
+ // The default is reachable only where `TClient` satisfies
37
+ // `DataClientProtocol`, which the constructor's conditional enforces;
38
+ // the compiler cannot carry that through to the generic parameter.
39
+ clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
40
+ lifecycle: options
41
+ });
42
+ }
43
+ /**
44
+ * Mint a participant on this connection under `clientId`.
45
+ *
46
+ * `clientId` must be distinct per participant and stable for its lifetime:
47
+ * it keys the server's per-`(uri, clientId)` hold and watch, and it is the
48
+ * echo key an inbound `onDocumentUpdated` is matched against.
49
+ *
50
+ * Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
51
+ * SERVER emits rather than participants, so a session holding one would read
52
+ * the framework's own broadcasts as its own echoes and drop them. Nothing
53
+ * about that fails on its own: the document simply stops following, which
54
+ * looks like a dead connection.
55
+ */
56
+ createSession(clientId) {
57
+ this.assertLive();
58
+ if (client_ids_1.FRAMEWORK_CLIENT_IDS.includes(clientId)) {
59
+ throw new Error(`clientId '${clientId}' is reserved by the framework and cannot identify a participant`);
60
+ }
61
+ const session = new data_session_1.DataSession(clientId, {
62
+ connected: () => this.connected(),
63
+ releaseSession: released => this.sessions.delete(released)
64
+ });
65
+ this.sessions.add(session);
66
+ return session;
67
+ }
68
+ /**
69
+ * Sessions are detached rather than disposed: the server releases every hold
70
+ * on a connection it sees close, so closing each document first sends
71
+ * requests over a connection this call is about to dispose.
72
+ */
73
+ dispose() {
74
+ for (const session of [...this.sessions]) {
75
+ session.detach();
76
+ }
77
+ this.sessions.clear();
78
+ super.dispose();
79
+ }
80
+ }
81
+ exports.DataConnection = DataConnection;
82
+ /**
83
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
84
+ * with several interested parties does not have to supply one.
85
+ *
86
+ * **The client slot holds exactly one object, and that is why this exists.**
87
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
88
+ * maps to one handler — a second registration replaces the first silently. So a
89
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
90
+ * slot and both subscribe to it.
91
+ *
92
+ * Use {@link DataConnection} directly instead when the client is yours: an
93
+ * adopter service that implements the protocol plus its own methods, a single
94
+ * consumer that IS the client, or a request/response-only client that binds
95
+ * nothing.
96
+ */
97
+ class DataConnectionWithEvents extends DataConnection {
98
+ /** Server pushes, fanned out to as many local listeners as the host has. */
99
+ events;
100
+ constructor(port, options) {
101
+ // Built as a local because `this` is unavailable before `super`, then
102
+ // read back onto the field.
103
+ const events = new data_events_1.DataEvents();
104
+ super(port, events, options);
105
+ this.events = events;
106
+ }
107
+ /** Disposes the fan-out it created, which no caller else holds. */
108
+ dispose() {
109
+ super.dispose();
110
+ this.events.dispose();
111
+ }
112
+ }
113
+ exports.DataConnectionWithEvents = DataConnectionWithEvents;
114
+ //# sourceMappingURL=data-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-connection.js","sourceRoot":"","sources":["../../src/client/data-connection.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,8CAAqD;AACrD,kCAAkI;AAElI,+CAA2C;AAE3C,iDAA6C;AAC7C,qDAA8E;AAqC9E;;;;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,CAAC;IACnB,CAAC;CACH;AAzDD,wCAyDC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAa,wBAGX,SAAQ,cAAyD;IAChE,4EAA4E;IACnE,MAAM,CAAwB;IAEvC,YAAY,IAAc,EAAE,OAA+B;QACxD,sEAAsE;QACtE,4BAA4B;QAC5B,MAAM,MAAM,GAAG,IAAI,wBAAU,EAAa,CAAC;QAC3C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,mEAAmE;IAC1D,OAAO;QACb,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACH;AApBD,4DAoBC"}
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
  import { Emitter, type Event } from 'vscode-jsonrpc';
10
- import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data';
10
+ import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data';
11
11
  import type { Project } from '../project';
12
12
  import type { TransferDiagnostic } from '../transfer-diagnostic';
13
13
  import type { TransferElement } from '../transfer-element';
@@ -34,15 +34,23 @@ import type { TransferElement } from '../transfer-element';
34
34
  export declare class DataEvents<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> implements DataClientProtocol<TTransfer, TDiagnostic, TProject> {
35
35
  protected readonly documentUpdatedEmitter: Emitter<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
36
36
  protected readonly documentSavedEmitter: Emitter<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
37
+ protected readonly documentDeletedEmitter: Emitter<TransferDocumentDeletedEvent>;
38
+ protected readonly documentsBuiltEmitter: Emitter<TransferDocumentsBuiltEvent>;
37
39
  protected readonly projectsChangedEmitter: Emitter<ProjectsChangedEvent<TProject>>;
38
40
  /** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
39
41
  readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
40
42
  /** A watched document was persisted to disk. */
41
43
  readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
44
+ /** A document's backing file was removed, watched or not. Any watch survives. */
45
+ readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent>;
46
+ /** Documents built that nobody watches — re-read anything derived from them. */
47
+ readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent>;
42
48
  /** The project set changed. */
43
49
  readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>>;
44
50
  onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
45
51
  onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
52
+ onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
53
+ onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
46
54
  onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
47
55
  dispose(): void;
48
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAClI,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAA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AC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIpF,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIhF,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI;IAI5D,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI;IAI1D,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI;IAI9D,OAAO,IAAI,IAAI;CAOjB"}
@@ -33,11 +33,17 @@ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
33
33
  class DataEvents {
34
34
  documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
35
35
  documentSavedEmitter = new vscode_jsonrpc_1.Emitter();
36
+ documentDeletedEmitter = new vscode_jsonrpc_1.Emitter();
37
+ documentsBuiltEmitter = new vscode_jsonrpc_1.Emitter();
36
38
  projectsChangedEmitter = new vscode_jsonrpc_1.Emitter();
37
39
  /** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
38
40
  onDidUpdateDocument = this.documentUpdatedEmitter.event;
39
41
  /** A watched document was persisted to disk. */
40
42
  onDidSaveDocument = this.documentSavedEmitter.event;
43
+ /** A document's backing file was removed, watched or not. Any watch survives. */
44
+ onDidDeleteDocument = this.documentDeletedEmitter.event;
45
+ /** Documents built that nobody watches — re-read anything derived from them. */
46
+ onDidBuildDocuments = this.documentsBuiltEmitter.event;
41
47
  /** The project set changed. */
42
48
  onDidChangeProjects = this.projectsChangedEmitter.event;
43
49
  // --- DataClientProtocol (wire names) ---
@@ -47,12 +53,20 @@ class DataEvents {
47
53
  onDocumentSaved(event) {
48
54
  this.documentSavedEmitter.fire(event);
49
55
  }
56
+ onDocumentDeleted(event) {
57
+ this.documentDeletedEmitter.fire(event);
58
+ }
59
+ onDocumentsBuilt(event) {
60
+ this.documentsBuiltEmitter.fire(event);
61
+ }
50
62
  onProjectsChanged(event) {
51
63
  this.projectsChangedEmitter.fire(event);
52
64
  }
53
65
  dispose() {
54
66
  this.documentUpdatedEmitter.dispose();
55
67
  this.documentSavedEmitter.dispose();
68
+ this.documentDeletedEmitter.dispose();
69
+ this.documentsBuiltEmitter.dispose();
56
70
  this.projectsChangedEmitter.dispose();
57
71
  }
58
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAqD;AAMrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,UAAU;IAKD,sBAAsB,GAAG,IAAI,wBAAO,EAAwD,CAAC;IAC7F,oBAAoB,GAAG,IAAI,wBAAO,EAAsD,CAAC;IACzF,sBAAsB,GAAG,IAAI,wBAAO,EAAkC,CAAC;IAE1F,4FAA4F;IACnF,mBAAmB,GAAgE,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAC9H,gDAAgD;IACvC,iBAAiB,GAA8D,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;IACxH,+BAA+B;IACtB,mBAAmB,GAA0C,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAExG,0CAA0C;IAE1C,iBAAiB,CAAC,KAA2D;QAC1E,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,eAAe,CAAC,KAAyD;QACtE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,iBAAiB,CAAC,KAAqC;QACpD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC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CAAC,KAAqC;QACpD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACH;AAnDD,gCAmDC"}
@@ -7,14 +7,18 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
  import type { Event, MessageConnection } from 'vscode-jsonrpc';
10
+ import type { ResolvedMessage } from '../messages/primitives';
10
11
  /**
11
12
  * The one thing a host has to supply for the data head: a live JSON-RPC
12
- * connection to the data server, plus the identity and failure sink that go
13
- * with it.
13
+ * connection to the data server, plus the failure sink that goes with it.
14
14
  *
15
- * "Port" in the hexagonal sense — the host implements it, `DataSession`
15
+ * "Port" in the hexagonal sense — the host implements it, `DataConnection`
16
16
  * consumes it, and nothing on either side of the boundary imports the other.
17
17
  *
18
+ * Carries no identity. A `clientId` names a participant, and one transport
19
+ * serves as many as the host has; binding an identity here is what makes two
20
+ * of them share one, so it lives on `DataSession` instead.
21
+ *
18
22
  * **This deliberately does NOT wrap the protocol methods.** `createRpcProxy`
19
23
  * already takes a promise of a connection and produces the whole typed
20
24
  * `DataServerProtocol` surface, so wrapping it would re-derive the framework's
@@ -43,21 +47,6 @@ import type { Event, MessageConnection } from 'vscode-jsonrpc';
43
47
  * calls on the promise but never calls `listen` itself.
44
48
  */
45
49
  export interface DataPort {
46
- /**
47
- * Stable identity of this client on the data server, passed as `clientId`
48
- * on every document request.
49
- *
50
- * It has to be stable for the session because it is the echo key: an
51
- * inbound `onDocumentUpdated` carries the originating mutation's
52
- * `clientId` as `sourceClientId`, and a client that cannot recognise its
53
- * own echo treats its own write as a concurrent third-party one. It also
54
- * has to be distinct per client, since it keys the server's per-
55
- * `(uri, clientId)` watch bucket.
56
- *
57
- * Avoid the three values the framework itself uses as sentinels —
58
- * `'language-client'`, `'unknown'` and `'revert-on-close'`.
59
- */
60
- readonly clientId: string;
61
50
  /**
62
51
  * Open the transport and hand back a listening `MessageConnection`.
63
52
  *
@@ -73,10 +62,16 @@ export interface DataPort {
73
62
  *
74
63
  * It exists because the alternative is worse in both directions: this tier
75
64
  * cannot import a host's UI, and swallowing the error makes a dead
76
- * connection look like an empty model. `context` names what was being
77
- * attempted, not where in the code it happened.
65
+ * connection look like an empty model.
66
+ *
67
+ * `reported` is a complete sentence plus the identity needed to render it in
68
+ * another language. It carries a value rather than using a protocol field
69
+ * because this tier does not know whether a process hop intervenes — in a
70
+ * webview host the render happens across one — and a `ResolvedMessage` is
71
+ * structured-clone safe either way. Render it with `renderFrameworkMessage`;
72
+ * passing no translation map yields the English.
78
73
  */
79
- reportError(error: unknown, context: string): void;
74
+ reportError(error: unknown, reported: ResolvedMessage): void;
80
75
  /**
81
76
  * Fires when the host tears the transport down and the current connection
82
77
  * is no longer usable — a language-server restart being the case that
@@ -1 +1 @@
1
- {"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,QAAQ;IACtB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC;;;;;;;;OAQG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnD;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC"}
1
+ {"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,WAAW,QAAQ;IACtB;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAE7D;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC"}
@@ -6,81 +6,52 @@
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, TransferSaveDocumentArgs, TransferUpdateDocumentArgs } 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>;
32
- }
13
+ /** Update a document through a session; the session supplies `clientId`. */
14
+ export type DataSessionUpdateArgs<TTransfer> = Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>;
15
+ /** Persist a document through a session; the session supplies `clientId`. */
16
+ export type DataSessionSaveArgs<TTransfer> = Omit<TransferSaveDocumentArgs<TTransfer>, 'clientId'>;
33
17
  /**
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.
18
+ * What a {@link DataSession} needs from the connection that minted it.
37
19
  *
38
- * Three jobs, and deliberately no fourth:
20
+ * Narrower than the connection itself so the dependency points one way:
21
+ * `DataConnection` constructs sessions, and nothing here imports it back.
22
+ */
23
+ export interface DataSessionHost<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer>> {
24
+ connected(): Promise<RpcProxy<TServer>>;
25
+ releaseSession(session: DataSession<TTransfer, TServer>): void;
26
+ }
27
+ /**
28
+ * One participant on a data connection: a properties panel, a tree, a
29
+ * form editor.
39
30
  *
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.
31
+ * The server keys every hold and watch per `(uri, clientId)`, so the identity
32
+ * belongs to the participant rather than to the wire — several sessions share
33
+ * one connection, and two participants forced to share one identity cannot
34
+ * distinguish each other's writes from their own echoes.
49
35
  *
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.
36
+ * Every document operation stamps {@link clientId} itself. A caller that
37
+ * passed its own could pass another participant's, and the server would
38
+ * attribute the write and release the hold accordingly.
54
39
  *
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.
40
+ * Generic over the transfer root so this file names no grammar.
58
41
  */
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>;
42
+ export declare class DataSession<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>> {
43
+ readonly clientId: string;
44
+ protected readonly host: DataSessionHost<TTransfer, TServer>;
45
+ /** URIs this session holds open, so {@link dispose} can release exactly those. */
46
+ protected readonly openUris: Set<string>;
65
47
  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;
48
+ constructor(clientId: string, host: DataSessionHost<TTransfer, TServer>);
72
49
  /**
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.
50
+ * The connected, READY server proxy, for protocol methods this session does
51
+ * not wrap — the ones carrying no `clientId`, so no identity can be got
52
+ * wrong through them.
82
53
  */
83
- connected(): Promise<RpcProxy<DataServerProtocol<TTransfer>>>;
54
+ connected(): Promise<RpcProxy<TServer>>;
84
55
  /**
85
56
  * Open `uri` for editing and start watching it, in that order, returning
86
57
  * the opened snapshot.
@@ -105,25 +76,36 @@ export declare class DataSession<TTransfer extends TransferElement> {
105
76
  * {@link openDocument} and needs no separate unwatch.
106
77
  */
107
78
  closeDocument(uri: string): Promise<void>;
79
+ /** Write `args.model` back as this session. */
80
+ updateDocument(args: DataSessionUpdateArgs<TTransfer>): Promise<TransferDocument<TTransfer>>;
81
+ /** Persist `args.model` to disk as this session. */
82
+ saveDocument(args: DataSessionSaveArgs<TTransfer>): Promise<TransferDocument<TTransfer>>;
108
83
  /**
109
- * Whether `event.sourceClientId` identifies this session's own write.
84
+ * Whether `sourceClientId` identifies this session's own write.
110
85
  *
111
86
  * Every watcher needs this and the check is one comparison, so getting it
112
87
  * wrong is cheap to do and expensive to find: an unfiltered echo looks
113
88
  * exactly like a concurrent third-party edit.
114
89
  */
115
90
  isOwnEcho(sourceClientId: string): boolean;
116
- /** Tear down the current connection and stop tracking the port. Idempotent. */
91
+ /**
92
+ * Release this session's holds and detach it from the connection.
93
+ * Idempotent, and leaves the connection usable by its other sessions.
94
+ *
95
+ * The closes are fired without being awaited, because a `Disposable` cannot
96
+ * be: a host disposing a widget has nowhere to put the promise. A close
97
+ * that fails is no worse than the leak this exists to prevent, so the
98
+ * rejection is swallowed rather than surfaced from a teardown.
99
+ */
117
100
  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
101
  /**
123
- * Discard the current generation, disposing its connection if it opened.
124
- * The next {@link connected} builds a fresh one.
102
+ * Come off the connection because it is going away.
103
+ *
104
+ * Sends no close, unlike {@link dispose}: the server releases every hold on
105
+ * a connection it sees close, and the close would travel over the very
106
+ * connection being disposed.
125
107
  */
126
- protected dropGeneration(): void;
108
+ detach(): void;
109
+ protected assertLive(): void;
127
110
  }
128
- export {};
129
111
  //# 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,0FAA0F;IAC1F,SAAS,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