@hydranium/protocol 1.0.0-next.22 → 1.0.0-next.220
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 +39 -3
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +157 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +237 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +24 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +471 -81
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +738 -108
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +14 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +14 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +9 -3
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +11 -5
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +149 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +202 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +12 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +132 -41
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +117 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +69 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +187 -29
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +270 -29
- package/lib/errors.js.map +1 -1
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +8 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js.map +1 -1
- package/lib/logger.d.ts +22 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +31 -3
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +59 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/base-version.d.ts +64 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +43 -0
- package/lib/model-service/base-version.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +4 -5
- package/lib/model-service/index.js.map +1 -1
- package/lib/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.map +1 -1
- package/lib/{model-service/args.js → node/index.d.ts} +2 -3
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- package/lib/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +35 -32
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +67 -23
- package/lib/patch-merge.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +65 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +67 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +33 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +32 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +10 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +12 -2
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- package/lib/rpc/wire-prefix.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 +39 -15
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +57 -10
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- package/lib/testing/fake-clock.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 +5 -2
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.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/lib/transfer-document.d.ts +70 -32
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +17 -9
- package/lib/transfer-document.js.map +1 -1
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +29 -37
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +315 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +25 -23
- package/src/client/data-session.ts +946 -126
- package/src/client/index.ts +14 -9
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +268 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +13 -4
- package/src/data/data-server-protocol.ts +157 -41
- package/src/data/events.ts +123 -21
- package/src/data/requests.ts +74 -11
- package/src/errors.ts +322 -36
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +10 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +28 -2
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +63 -18
- package/src/model-service/base-version.ts +72 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +97 -42
- package/src/profile-session.ts +9 -4
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +124 -0
- package/src/rpc/README.md +2 -3
- package/src/rpc/bind-rpc-methods.ts +59 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +141 -25
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +5 -2
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +87 -34
- package/src/util.ts +33 -0
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
package/src/data/events.ts
CHANGED
|
@@ -10,30 +10,36 @@
|
|
|
10
10
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
11
11
|
import type { TransferElement } from '../transfer-element';
|
|
12
12
|
import type { Project } from '../project';
|
|
13
|
-
import type { TransferDocument } from '../transfer-document';
|
|
13
|
+
import type { TextState, TransferDocument } from '../transfer-document';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Why an update event fired. Subscribers filter on reason for behaviour
|
|
17
17
|
* decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
|
|
18
18
|
*
|
|
19
|
-
* - `'changed'` — the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
|
|
27
|
-
* build (dependency graph re-derivation), without itself being passed to
|
|
28
|
-
* `documentBuilder.update`. The complement of `'changed'`.
|
|
19
|
+
* - `'changed'` — the server's first update event for the document's current
|
|
20
|
+
* version: its content changed since the last one. A write whose build a
|
|
21
|
+
* later write cancelled is still `'changed'` in the build that takes over.
|
|
22
|
+
* - `'rebuilt'` — a later event for a version the server already delivered,
|
|
23
|
+
* whether or not any client watched it then: something the document depends
|
|
24
|
+
* on changed, or the document was built again with the same content. The
|
|
25
|
+
* complement of `'changed'`.
|
|
29
26
|
* - `'saved'` — emitted by adopters that synthesise a unified update stream
|
|
30
27
|
* from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
|
|
31
28
|
* `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
|
|
32
29
|
* `DataClientProtocol.onDocumentSaved` channel.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* The version rule needs a version the server keeps and builds that validate.
|
|
32
|
+
* For a document no client has opened, or when rebuilds do not validate,
|
|
33
|
+
* `'changed'` means the URI was passed to `DocumentBuilder.update` for this
|
|
34
|
+
* build. A document that a validating build skips is `'changed'` every time.
|
|
35
|
+
*
|
|
36
|
+
* Deletion is deliberately NOT a member. An update event carries a built
|
|
37
|
+
* document, which a deleted one has none of, and the phase-driven path that
|
|
38
|
+
* produces these events never runs for a deleted URI — the builder drops the
|
|
39
|
+
* document before deriving the rebuild set. It travels as
|
|
40
|
+
* {@link TransferDocumentDeletedEvent} on its own channel instead.
|
|
35
41
|
*/
|
|
36
|
-
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved'
|
|
42
|
+
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* Delivered on the data-server when a document's content (or existence)
|
|
@@ -47,7 +53,13 @@ export interface TransferDocumentUpdatedEvent<
|
|
|
47
53
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic
|
|
48
54
|
> {
|
|
49
55
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
50
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The client whose write this event echoes: the author of the version on a
|
|
58
|
+
* `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
|
|
59
|
+
* write. A recipient compares it against its own id to recognise its echo.
|
|
60
|
+
* The build that follows a document's release names the release id
|
|
61
|
+
* instead.
|
|
62
|
+
*/
|
|
51
63
|
sourceClientId: string;
|
|
52
64
|
reason: TransferDocumentUpdateReason;
|
|
53
65
|
}
|
|
@@ -60,8 +72,8 @@ export type TransferDocumentUpdatedListener<
|
|
|
60
72
|
|
|
61
73
|
/**
|
|
62
74
|
* Delivered on the data-server when a document was persisted to disk via
|
|
63
|
-
* `DataServerProtocol.saveModelDocument`. Distinct
|
|
64
|
-
* {@link TransferDocumentUpdatedEvent}: subscribers that only care about
|
|
75
|
+
* `DataServerProtocol.saveModelDocument` or `persistModelDocument`. Distinct
|
|
76
|
+
* from {@link TransferDocumentUpdatedEvent}: subscribers that only care about
|
|
65
77
|
* persistence (external sync, editor "saved" indicators, dirty-flag
|
|
66
78
|
* clear) listen for this event family instead of filtering an update
|
|
67
79
|
* stream for `reason: 'saved'`.
|
|
@@ -77,10 +89,11 @@ export interface TransferDocumentSavedEvent<
|
|
|
77
89
|
> {
|
|
78
90
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
79
91
|
/**
|
|
80
|
-
* The client whose `saveModelDocument`
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
92
|
+
* The client whose `saveModelDocument` or `persistModelDocument` call
|
|
93
|
+
* produced this, also when another client wrote the persisted text. Every
|
|
94
|
+
* subscriber receives the event including the originator, which already had
|
|
95
|
+
* the same state as the RPC response — compare against your own id to drop
|
|
96
|
+
* the echo rather than re-rendering from it.
|
|
84
97
|
*/
|
|
85
98
|
sourceClientId: string;
|
|
86
99
|
}
|
|
@@ -91,6 +104,95 @@ export type TransferDocumentSavedListener<
|
|
|
91
104
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic
|
|
92
105
|
> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
|
|
93
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Delivered on the data-server when a watched document's text starts or stops
|
|
109
|
+
* differing from its file, as the server last knew the file. The current
|
|
110
|
+
* answer rides on every transfer document the server sends as `text.dirty`;
|
|
111
|
+
* this carries only its changes, so a client that follows it needs no rebuild
|
|
112
|
+
* to learn of a save.
|
|
113
|
+
*/
|
|
114
|
+
export interface TransferDocumentDirtyChangedEvent {
|
|
115
|
+
/** Canonical URI, keyed as the subscription is. */
|
|
116
|
+
readonly uri: string;
|
|
117
|
+
/**
|
|
118
|
+
* The text the answer was decided on. It is sent before that text is
|
|
119
|
+
* built, so a `text.version` ahead of the model a client holds means an
|
|
120
|
+
* update at this version or a later one follows. Absent when the document
|
|
121
|
+
* no longer exists, or when the build that follows its release failed.
|
|
122
|
+
*/
|
|
123
|
+
readonly text?: TextState;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
|
|
127
|
+
export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Delivered on the data-server when a document's backing file was removed.
|
|
131
|
+
* Carries no document, and cannot: the state a
|
|
132
|
+
* {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
|
|
133
|
+
* the time anyone can be told. That is also why deletion is not a `reason` on
|
|
134
|
+
* the update stream — `DocumentBuilder.update` drops the document before
|
|
135
|
+
* deriving the rebuild set, so the phase-driven path that produces update
|
|
136
|
+
* events never runs for it.
|
|
137
|
+
*
|
|
138
|
+
* **Delivered for EVERY document, not only watched ones**, unlike
|
|
139
|
+
* `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
|
|
140
|
+
* channels are gated is whether any OTHER source can observe the fact on the
|
|
141
|
+
* least capable host: a browser-hosted client's workspace lives behind the
|
|
142
|
+
* head, so nothing there can see a file disappear, and gating the notification
|
|
143
|
+
* would leave it blind. (A Theia frontend's filesystem watcher would cover it,
|
|
144
|
+
* which is why this is a host argument and not a structure-versus-content one.)
|
|
145
|
+
* A watcher is told about its own document's deletion here too, the update
|
|
146
|
+
* channel being silent for deletions by construction. Filter on {@link uri} if
|
|
147
|
+
* the receiver only cares about documents it opened.
|
|
148
|
+
*
|
|
149
|
+
* A watch survives the deletion, so a file that comes back resumes delivering
|
|
150
|
+
* `onDocumentUpdated` to the same subscribers with no re-subscription. A
|
|
151
|
+
* client that responds by closing its editor releases the watch through
|
|
152
|
+
* `closeModelDocument` as usual.
|
|
153
|
+
*/
|
|
154
|
+
export interface TransferDocumentDeletedEvent {
|
|
155
|
+
/** Canonical URI of the removed document, keyed as the subscription is. */
|
|
156
|
+
readonly uri: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
|
|
160
|
+
export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Delivered on the data-server once per build, naming the documents that reached
|
|
164
|
+
* the configured subscription phase (`DataServerOptions.subscriptionPhase`,
|
|
165
|
+
* `Validated` by default) and that NO client on the connection is watching. Not
|
|
166
|
+
* the integrity-settled landmark, which is a different point and a different
|
|
167
|
+
* word in this framework.
|
|
168
|
+
*
|
|
169
|
+
* The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
|
|
170
|
+
* URI: together the two cover every document a build touched. This one exists
|
|
171
|
+
* for the case no source outside the server can observe — a document rebuilt
|
|
172
|
+
* because something it DEPENDS ON changed. Its own file never changed, so a
|
|
173
|
+
* filesystem watcher cannot see it, and it has no subscriber, so the update
|
|
174
|
+
* channel does not report it. A consumer showing data derived from such a
|
|
175
|
+
* document (a tree label, a decorator) would otherwise hold a stale value with
|
|
176
|
+
* nothing to invalidate it.
|
|
177
|
+
*
|
|
178
|
+
* Carries URIs and no documents: a recipient re-reads what it displays, through
|
|
179
|
+
* `getModelDocument` or its own request. That keeps the bandwidth property the
|
|
180
|
+
* per-URI subscription exists for, without gating the message.
|
|
181
|
+
*
|
|
182
|
+
* Not sent when the set is empty, which is the normal case while editing — the
|
|
183
|
+
* document being edited is watched by its own editor and therefore excluded.
|
|
184
|
+
* Workspace initialisation sends nothing either: it does not build to the
|
|
185
|
+
* subscription phase. The largest message a workspace can produce is therefore
|
|
186
|
+
* a whole-workspace rebuild at that phase, which is one message of URIs.
|
|
187
|
+
*/
|
|
188
|
+
export interface TransferDocumentsBuiltEvent {
|
|
189
|
+
/** Canonical URIs, keyed as subscriptions are. Never empty. */
|
|
190
|
+
readonly uris: readonly string[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
|
|
194
|
+
export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
|
|
195
|
+
|
|
94
196
|
/**
|
|
95
197
|
* Why a project-change event fired. `added` — the project was newly
|
|
96
198
|
* registered (descriptor discovered); `updated` — the project's
|
package/src/data/requests.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { BaseVersion } from '../model-service/base-version';
|
|
11
11
|
|
|
12
12
|
/** Get the current state of a single document. The server returns the latest built version. */
|
|
13
13
|
export interface GetModelDocumentArgs {
|
|
@@ -41,24 +41,87 @@ export interface GetProjectForUriArgs {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Update a document
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* without an args mapping.
|
|
44
|
+
* Update a document the session `clientId` has open. Generic over `TTransfer`
|
|
45
|
+
* so adopters parameterise the structured shape against their grammar's
|
|
46
|
+
* transfer-model overlay; passing a string is always allowed.
|
|
48
47
|
*/
|
|
49
|
-
export
|
|
48
|
+
export interface TransferUpdateDocumentArgs<TTransfer> {
|
|
49
|
+
/** Document URI. */
|
|
50
|
+
uri: string;
|
|
51
|
+
/** The id of a live session registered on this connection. */
|
|
52
|
+
clientId: string;
|
|
53
|
+
/** The whole structured model root, or its serialised textual form. */
|
|
54
|
+
model: TTransfer | string;
|
|
55
|
+
/**
|
|
56
|
+
* What this write was authored against. A `ModelVersion` is compared
|
|
57
|
+
* against the server's current text-document version for `uri` and throws
|
|
58
|
+
* `ConflictError` on mismatch; `'any'` writes unconditionally.
|
|
59
|
+
*
|
|
60
|
+
* **Required so that an ungated write is a decision rather than an
|
|
61
|
+
* omission.** An optional gate is indistinguishable from a forgotten one at
|
|
62
|
+
* the call site, and a file of twenty writes hides the one that lost the
|
|
63
|
+
* field. Nothing else here can see that, since the defect is an absence.
|
|
64
|
+
*/
|
|
65
|
+
baseVersion: BaseVersion;
|
|
66
|
+
}
|
|
50
67
|
|
|
51
|
-
/**
|
|
52
|
-
|
|
68
|
+
/** Update a document the session `clientId` has open, then persist it to disk. */
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
70
|
+
export interface TransferSaveDocumentArgs<TTransfer> extends TransferUpdateDocumentArgs<TTransfer> {}
|
|
71
|
+
|
|
72
|
+
/** Persist the text the server holds for a document the session `clientId` has open, without writing a model. */
|
|
73
|
+
export type TransferPersistDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model'>;
|
|
74
|
+
|
|
75
|
+
/** Register a client session on the connection. */
|
|
76
|
+
export interface CreateSessionArgs {
|
|
77
|
+
/** The session's id, minted by the client; unique in the server process while the session is live. */
|
|
78
|
+
clientId: string;
|
|
79
|
+
/** What the participant is; kept as the server session's `label`. */
|
|
80
|
+
label?: string;
|
|
81
|
+
/**
|
|
82
|
+
* A token the client keeps for the session's lifetime. It is no secret: the
|
|
83
|
+
* wire carries no authentication. A later `createSession` for the same id
|
|
84
|
+
* carrying the same token, from any connection, ends the session it names
|
|
85
|
+
* and registers the id afresh, so a client whose connection dropped before
|
|
86
|
+
* the server noticed can register again. Without it the id stays refused
|
|
87
|
+
* until the server notices.
|
|
88
|
+
*/
|
|
89
|
+
resumeToken?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** End a client session registered on the connection. */
|
|
93
|
+
export interface CloseSessionArgs {
|
|
94
|
+
clientId: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Create a document that exists nowhere yet, open for the session creating it. */
|
|
98
|
+
export interface CreateModelDocumentArgs {
|
|
99
|
+
uri: string;
|
|
100
|
+
/** The id of a live session registered on this connection. */
|
|
101
|
+
clientId: string;
|
|
102
|
+
/** The document's initial content; it reaches disk with the first save. */
|
|
103
|
+
text: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Write several documents a session has open, all or none. `clientId` is on
|
|
108
|
+
* the set rather than on each update: an id per update would allow a set
|
|
109
|
+
* mixing clients, which the server would have to refuse.
|
|
110
|
+
*/
|
|
111
|
+
export interface TransferUpdateDocumentsArgs<TTransfer> {
|
|
112
|
+
/** The id of a live session registered on this connection. */
|
|
113
|
+
clientId: string;
|
|
114
|
+
updates: Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>[];
|
|
115
|
+
}
|
|
53
116
|
|
|
54
117
|
/**
|
|
55
118
|
* Identifies a per-document watch on the data server. Shared by both
|
|
56
119
|
* `watchModelDocument` and `unwatchModelDocument` — the `(uri, clientId)`
|
|
57
120
|
* pair is the watch key, so unwatching names the same watch that was
|
|
58
121
|
* started. The `clientId` identifies the originator the same way it does
|
|
59
|
-
* on
|
|
60
|
-
* `
|
|
61
|
-
* bucket so multiple watchers on the same wire stay distinct, AND it lets
|
|
122
|
+
* on the document writes (`TransferUpdateDocumentArgs.clientId`,
|
|
123
|
+
* `TransferSaveDocumentArgs.clientId`): it keys the per-`(uri, clientId)`
|
|
124
|
+
* watch bucket so multiple watchers on the same wire stay distinct, AND it lets
|
|
62
125
|
* each watcher recognise its own echo on inbound `onDocumentUpdated` events
|
|
63
126
|
* (the wire shape's `sourceClientId` carries the originating mutation's
|
|
64
127
|
* `clientId`).
|