@hydranium/protocol 1.0.0-next.38 → 1.0.0-next.381
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 +44 -83
- package/lib/abstract-logger.d.ts +11 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +16 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +303 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +534 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +18 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +26 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +34 -24
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +694 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1158 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +15 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +15 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +6 -4
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +4 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +69 -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 +173 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +225 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +94 -0
- package/lib/client/worker-handshake.d.ts.map +1 -0
- package/lib/client/worker-handshake.js +51 -0
- package/lib/client/worker-handshake.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 +50 -10
- 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 +13 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +176 -49
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +144 -33
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +84 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +7 -4
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +10 -10
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +243 -41
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +400 -55
- package/lib/errors.js.map +1 -1
- package/lib/format-log-arg.d.ts +33 -0
- package/lib/format-log-arg.d.ts.map +1 -0
- package/lib/format-log-arg.js +158 -0
- package/lib/format-log-arg.js.map +1 -0
- package/lib/glsp-edits-settled-actions.d.ts +54 -0
- package/lib/glsp-edits-settled-actions.d.ts.map +1 -0
- package/lib/glsp-edits-settled-actions.js +28 -0
- package/lib/glsp-edits-settled-actions.js.map +1 -0
- 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 +55 -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 +11 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +10 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js +2 -0
- package/lib/latency-collector.js.map +1 -1
- package/lib/logger.d.ts +38 -7
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +42 -4
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +4 -2
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +17 -4
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/primitives.d.ts +59 -4
- package/lib/messages/primitives.d.ts.map +1 -1
- package/lib/messages/primitives.js +97 -4
- package/lib/messages/primitives.js.map +1 -1
- 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 +67 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +44 -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/node/index.d.ts +10 -0
- 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 +63 -35
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +171 -25
- package/lib/patch-merge.js.map +1 -1
- package/lib/pending-work-tracker.d.ts +30 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +47 -0
- package/lib/pending-work-tracker.js.map +1 -0
- package/lib/profile-session.d.ts +24 -8
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js +13 -4
- package/lib/profile-session.js.map +1 -1
- package/lib/profiling.d.ts +15 -2
- package/lib/profiling.d.ts.map +1 -1
- package/lib/profiling.js.map +1 -1
- package/lib/project.d.ts +6 -2
- package/lib/project.d.ts.map +1 -1
- package/lib/project.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 +70 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +69 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +6 -2
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +17 -7
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +3 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/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/save-text-document.d.ts +40 -0
- package/lib/save-text-document.d.ts.map +1 -0
- package/lib/save-text-document.js +34 -0
- package/lib/save-text-document.js.map +1 -0
- package/lib/testing/catalogue-audit.js.map +1 -1
- package/lib/testing/data-doubles.d.ts +41 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +56 -8
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +17 -2
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +61 -46
- 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 +4 -3
- 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/transfer-node-builder.d.ts +81 -0
- package/lib/testing/transfer-node-builder.d.ts.map +1 -0
- package/lib/testing/transfer-node-builder.js +47 -0
- package/lib/testing/transfer-node-builder.js.map +1 -0
- package/lib/testing/wait-for.d.ts +9 -3
- package/lib/testing/wait-for.d.ts.map +1 -1
- package/lib/testing/wait-for.js +57 -11
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js +5 -9
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +11 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +17 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +96 -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/transfer-element.d.ts +4 -4
- package/lib/types.d.ts +32 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/{model-service/args.js → types.js} +2 -2
- package/lib/types.js.map +1 -0
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -4
- package/lib/util.js.map +1 -1
- package/package.json +24 -40
- package/src/abstract-logger.ts +18 -0
- package/src/client/data-connection.ts +654 -0
- package/src/client/data-events.ts +38 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1479 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +6 -4
- package/src/client/post-message-transport.ts +224 -4
- package/src/client/rpc-connection.ts +302 -0
- package/src/client/worker-handshake.ts +121 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +68 -10
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +14 -4
- package/src/data/data-server-protocol.ts +203 -49
- package/src/data/events.ts +150 -33
- package/src/data/requests.ts +90 -11
- package/src/debouncer.ts +11 -11
- package/src/errors.ts +500 -65
- package/src/format-log-arg.ts +176 -0
- package/src/glsp-edits-settled-actions.ts +62 -0
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +64 -0
- package/src/index.ts +11 -0
- package/src/latency-collector.ts +10 -3
- package/src/logger.ts +44 -8
- package/src/messages/index.ts +12 -2
- package/src/messages/primitives.ts +129 -5
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +75 -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 +230 -45
- package/src/pending-work-tracker.ts +47 -0
- package/src/profile-session.ts +31 -11
- package/src/profiling.ts +15 -2
- package/src/project.ts +6 -2
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +131 -0
- package/src/rpc/README.md +6 -6
- package/src/rpc/bind-rpc-methods.ts +18 -8
- package/src/rpc/create-rpc-proxy.ts +6 -1
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/save-text-document.ts +39 -0
- package/src/testing/data-doubles.ts +141 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/index.ts +4 -3
- 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/testing/transfer-node-builder.ts +107 -0
- package/src/testing/wait-for.ts +61 -13
- package/src/tracer.ts +5 -9
- package/src/transfer-diagnostic.ts +17 -0
- package/src/transfer-document.ts +116 -34
- package/src/transfer-element.ts +4 -4
- package/src/types.ts +30 -0
- package/src/util.ts +33 -6
- 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
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from '../transfer-element';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
|
-
import type { TransferDocument } from '../transfer-document';
|
|
12
|
+
import type { TransferCreatedDocument, TransferDocument, TransferSavedDocument, TransferWatchedDocument } from '../transfer-document';
|
|
13
13
|
import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
|
|
14
14
|
import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
|
|
15
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
|
|
16
|
-
import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs } from './requests';
|
|
15
|
+
import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from './events';
|
|
16
|
+
import type { CloseSessionArgs, CreateModelDocumentArgs, CreateSessionArgs, GetModelDocumentArgs, GetProjectForUriArgs, TransferDeleteDocumentArgs, TransferPersistDocumentArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs, TransferUpdateDocumentsArgs } from './requests';
|
|
17
17
|
/**
|
|
18
18
|
* Document-scoped slice of the data-server wire contract: the per-document
|
|
19
19
|
* lifecycle (get / update / save), the per-`(uri, clientId)` watch
|
|
@@ -32,34 +32,76 @@ import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentAr
|
|
|
32
32
|
*/
|
|
33
33
|
export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* {@link getModelDocument} returns, except that `version` is taken from
|
|
40
|
-
* the text-document store so the caller's first `baseVersion` write
|
|
41
|
-
* cannot self-conflict. Idempotent in registration terms: opening an
|
|
42
|
-
* already-open document refreshes the client registration. Note it does
|
|
43
|
-
* NOT avoid a rebuild — a second client attaching triggers
|
|
44
|
-
* `refreshContent`, which fires a change event, so mounting a form on a
|
|
45
|
-
* document already open in a text editor rebuilds it.
|
|
35
|
+
* Register `args.clientId` as a client session owned by this connection.
|
|
36
|
+
* Rejects with a `DuplicateClientIdError` code when the id is live anywhere
|
|
37
|
+
* in the server process, and with a `ReservedClientIdError` code when the
|
|
38
|
+
* framework reserves it.
|
|
46
39
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
40
|
+
* A request carrying a registered id acts as that session: it writes only
|
|
41
|
+
* what the session has open, failing with a `DocumentNotOpenError` code
|
|
42
|
+
* otherwise, and opens nothing implicitly; its open reads the file and takes
|
|
43
|
+
* no `languageId`, `version` or `text` seed. The session ends with
|
|
44
|
+
* {@link closeSession} or when the connection closes, and either closes
|
|
45
|
+
* every document it has open.
|
|
46
|
+
*
|
|
47
|
+
* A registration carrying the `resumeToken` an earlier registration of the
|
|
48
|
+
* same id carried ends that session first, from any connection, so a client
|
|
49
|
+
* whose connection dropped can register again before the server notices.
|
|
50
|
+
*/
|
|
51
|
+
createSession(args: CreateSessionArgs): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* End a session this connection registered: close every document it has
|
|
54
|
+
* open, drop its watches, and free its id. A no-op for an id this
|
|
55
|
+
* connection did not register.
|
|
51
56
|
*/
|
|
52
|
-
|
|
57
|
+
closeSession(args: CloseSessionArgs): Promise<void>;
|
|
53
58
|
/**
|
|
54
|
-
*
|
|
55
|
-
* {@link openModelDocument}
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
59
|
+
* Create a document with `args.text`, open for the session, and return it
|
|
60
|
+
* as {@link openModelDocument} does, with the version the create made in
|
|
61
|
+
* `created`. The answer is read after the create, so it can already hold
|
|
62
|
+
* another client's write or an integrity repair; a write based on
|
|
63
|
+
* `created.version` then conflicts. It reaches disk with the first save.
|
|
64
|
+
* Fails when the file exists, any client has the URI open, or a lost
|
|
65
|
+
* client's unsaved text is held for it, and with a
|
|
66
|
+
* `SessionClosedError` code when `args.clientId` is not a session
|
|
67
|
+
* registered on this connection.
|
|
68
|
+
*/
|
|
69
|
+
createModelDocument(args: CreateModelDocumentArgs): Promise<TransferCreatedDocument<TTransfer, TDiagnostic>>;
|
|
70
|
+
/**
|
|
71
|
+
* Write several documents the session has open, all or none: a conflict, a
|
|
72
|
+
* document not open, or a model for a document whose parse lacks some of
|
|
73
|
+
* its text fails the whole set before any text applies.
|
|
74
|
+
* Resolves to the documents in the order given, once the language client
|
|
75
|
+
* has answered the push of each, or the server-side bound on that wait
|
|
76
|
+
* passes, as {@link updateModelDocument} does. Only for a session
|
|
77
|
+
* registered on this connection.
|
|
78
|
+
*/
|
|
79
|
+
updateModelDocuments(args: TransferUpdateDocumentsArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Open a document for the client session `clientId` and return its current
|
|
82
|
+
* state. `clientId` must be a session this connection registered with
|
|
83
|
+
* {@link createSession}; any other id fails with the closed-session code,
|
|
84
|
+
* as every document request here does. The document is read from disk
|
|
85
|
+
* unless a client has it open already, so the request carries no
|
|
86
|
+
* `languageId`, `version` or `text` seed. Returns the document at
|
|
87
|
+
* the server's configured target phase, as {@link getModelDocument} does.
|
|
88
|
+
* A repeat open changes nothing.
|
|
89
|
+
*
|
|
90
|
+
* Pair with {@link watchModelDocument} to receive subsequent build-phase
|
|
91
|
+
* events (open returns a one-shot snapshot; later validation diagnostics
|
|
92
|
+
* arrive on the watch channel).
|
|
93
|
+
*/
|
|
94
|
+
openModelDocument(args: Pick<OpenModelArgs, 'uri' | 'clientId' | 'options'>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
95
|
+
/**
|
|
96
|
+
* Close the session's open of `uri`. Counterpart to
|
|
97
|
+
* {@link openModelDocument}; the document stays open until every client
|
|
98
|
+
* has closed it, and then the server releases it, by default reverting it
|
|
99
|
+
* to disk. The default
|
|
100
|
+
* `DataServer` impl ALSO releases any watch for the same
|
|
101
|
+
* `(uri, clientId)` (a forgotten {@link unwatchModelDocument} would
|
|
102
|
+
* otherwise leak dispatch; the implicit unwatch is idempotent).
|
|
103
|
+
* `watchModelDocument` is NOT coupled the other way: opening does not force
|
|
104
|
+
* a watch, so a snapshot reader can open without streaming.
|
|
63
105
|
*/
|
|
64
106
|
closeModelDocument(args: CloseModelArgs): Promise<void>;
|
|
65
107
|
/**
|
|
@@ -70,32 +112,71 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
|
|
|
70
112
|
*/
|
|
71
113
|
getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
72
114
|
/**
|
|
73
|
-
* Update a document's content
|
|
74
|
-
*
|
|
75
|
-
* response.
|
|
115
|
+
* Update a document's content as the session `clientId`, which must have
|
|
116
|
+
* it open. The response carries the latest built state including
|
|
117
|
+
* diagnostics; callers observe convergence via that response. It is sent
|
|
118
|
+
* once the language client has answered the push of the text, or the
|
|
119
|
+
* server-side bound on that wait passes, as {@link saveModelDocument}'s
|
|
120
|
+
* is, so an editor already shows the write when it arrives. A model, not
|
|
121
|
+
* text, for a document whose parse lacks some of its text fails with a
|
|
122
|
+
* `DocumentSyntaxError` code, unless the write is a `restore`.
|
|
76
123
|
*/
|
|
77
124
|
updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
78
125
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
126
|
+
* Write a document as the session `clientId`, which must have it open, and
|
|
127
|
+
* persist it to disk. The response is the build of the text written, with
|
|
128
|
+
* its version in `persisted`, sent once the language client has answered
|
|
129
|
+
* the push of that text, applied or refused, or a server-side bound on
|
|
130
|
+
* that wait passes; it does not wait again for a push that wait already
|
|
131
|
+
* gave up on and the client has not answered since. Save semantics depend
|
|
132
|
+
* on the filesystem-provider wiring; rejection paths surface as awaited
|
|
133
|
+
* promise rejections, as a model for a document whose parse lacks some of
|
|
134
|
+
* its text does with a `DocumentSyntaxError` code.
|
|
83
135
|
*/
|
|
84
|
-
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<
|
|
136
|
+
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
137
|
+
/**
|
|
138
|
+
* Persist the text the server holds for a document the session `clientId`
|
|
139
|
+
* has open, as it is: no update and no serialisation, so another client's
|
|
140
|
+
* unsaved text keeps its formatting. `baseVersion` is checked in the step
|
|
141
|
+
* that takes the text, so text that moved on fails with a `ConflictError`
|
|
142
|
+
* code. The saved event names this session, whoever wrote the text.
|
|
143
|
+
* Answers after the same language-client wait as {@link saveModelDocument},
|
|
144
|
+
* with the document's latest build, read after that wait, so another
|
|
145
|
+
* session's write during it shows; `persisted` carries the version written.
|
|
146
|
+
*/
|
|
147
|
+
persistModelDocument(args: TransferPersistDocumentArgs): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
148
|
+
/**
|
|
149
|
+
* Delete a document the session `clientId` has open, at once: its file,
|
|
150
|
+
* then the document, as a deletion a file watcher reports removes it. Every
|
|
151
|
+
* session's open of it closes and every client hears
|
|
152
|
+
* {@link DocumentClientProtocol.onDocumentDeleted} naming this session; the
|
|
153
|
+
* session's own watch is released, as {@link closeModelDocument} releases
|
|
154
|
+
* it. `baseVersion` is checked in the step that marks the document for
|
|
155
|
+
* deletion, so text that moved on fails with a `ConflictError` code. A file
|
|
156
|
+
* already gone deletes only the document; a file that cannot be removed
|
|
157
|
+
* fails the call and changes nothing. Resolves once the build that removes
|
|
158
|
+
* the document has run; a read then answers the URI without a model, unless
|
|
159
|
+
* an editor still has it open, whose buffer the document is built from.
|
|
160
|
+
*/
|
|
161
|
+
deleteModelDocument(args: TransferDeleteDocumentArgs): Promise<void>;
|
|
85
162
|
/**
|
|
86
163
|
* Start watching `(uri, clientId)`. The server starts dispatching
|
|
87
164
|
* {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
|
|
88
165
|
* for every build-phase event on `uri`.
|
|
89
166
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
167
|
+
* Answers with the key the watch's events name the document by, whether
|
|
168
|
+
* a document exists, taken once the watch is in place and the document
|
|
169
|
+
* is loaded as a read loads it, the text held at that moment, and the
|
|
170
|
+
* position of the last update or deletion event sent as of it, so an event
|
|
171
|
+
* the client heard while the watch was in flight tells by its own position
|
|
172
|
+
* whether it is newer than the answer. No handle: the event channel is the
|
|
173
|
+
* client interface. Callers fan out a single inbound `onDocumentUpdated` to
|
|
174
|
+
* multiple local listeners with their own `Emitter<T>` (matching Theia's
|
|
175
|
+
* pattern). Pair every `watchModelDocument` with
|
|
176
|
+
* {@link unwatchModelDocument} when no longer needed; the server holds the
|
|
177
|
+
* watch record until the matching unwatch lands.
|
|
97
178
|
*/
|
|
98
|
-
watchModelDocument(args: WatchModelDocumentArgs): Promise<
|
|
179
|
+
watchModelDocument(args: WatchModelDocumentArgs): Promise<TransferWatchedDocument>;
|
|
99
180
|
/**
|
|
100
181
|
* Stop watching `(uri, clientId)` previously started by
|
|
101
182
|
* {@link watchModelDocument}. Idempotent — unwatching twice is a no-op.
|
|
@@ -171,6 +252,19 @@ export interface ProjectServerProtocol<TProject extends Project = Project> {
|
|
|
171
252
|
*/
|
|
172
253
|
export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {
|
|
173
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* The diagnostic shape a server answers with, read back off its own
|
|
257
|
+
* declaration.
|
|
258
|
+
*
|
|
259
|
+
* This is what lets a client tier stay generic over the server alone and still
|
|
260
|
+
* describe what it hands back. Both parameters must be inferred: naming
|
|
261
|
+
* {@link TransferElement} for the transfer instead fails to match while that
|
|
262
|
+
* parameter is still generic, and a default declared against the constraint
|
|
263
|
+
* then stops satisfying it.
|
|
264
|
+
*/
|
|
265
|
+
export type DiagnosticOf<TServer> = TServer extends DocumentServerProtocol<infer _TTransfer, infer TDiagnostic> ? TDiagnostic : TransferDiagnostic;
|
|
266
|
+
/** The project shape a server answers with, read back off its own declaration. */
|
|
267
|
+
export type ProjectOf<TServer> = TServer extends ProjectServerProtocol<infer TProject> ? TProject : Project;
|
|
174
268
|
/**
|
|
175
269
|
* Cross-reference / naming slice of the server surface — scope-aware
|
|
176
270
|
* queries that resolve against the language's reference services. NOT part
|
|
@@ -181,11 +275,11 @@ export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnost
|
|
|
181
275
|
* source/URI (an `ElementSource` with no URI resolves to the sole
|
|
182
276
|
* registered language; a multi-language workspace overrides).
|
|
183
277
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
278
|
+
* Not generic over a server's root type: {@link resolveReference} answers with
|
|
279
|
+
* a node a reference names, which is no document root, and candidates and
|
|
280
|
+
* names are diagnostic-free.
|
|
187
281
|
*/
|
|
188
|
-
export interface ReferenceServerProtocol
|
|
282
|
+
export interface ReferenceServerProtocol {
|
|
189
283
|
/**
|
|
190
284
|
* List the reference candidates reachable for the property named in `ctx`
|
|
191
285
|
* from its (possibly synthetic) source. Backed by the language's
|
|
@@ -197,8 +291,11 @@ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
|
|
|
197
291
|
* target's document URI, display fields, and the resolved node's encoded
|
|
198
292
|
* transfer subtree. Resolves via the language's reference services;
|
|
199
293
|
* `undefined` when the reference does not resolve.
|
|
294
|
+
*
|
|
295
|
+
* `TElement` is the caller's claim about the target node's type; nothing
|
|
296
|
+
* checks it, so leave it at the default unless the reference names one type.
|
|
200
297
|
*/
|
|
201
|
-
resolveReference(ref: ReferenceRequest): Promise<ReferenceTarget<
|
|
298
|
+
resolveReference<TElement extends TransferElement = TransferElement>(ref: ReferenceRequest): Promise<ReferenceTarget<TElement> | undefined>;
|
|
202
299
|
/**
|
|
203
300
|
* Compute the next free name for a new element of `args.type` based on
|
|
204
301
|
* `args.proposal`, unique within the `args.tier` scope (default
|
|
@@ -235,6 +332,36 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
|
|
|
235
332
|
* codepath, not a subscription codepath).
|
|
236
333
|
*/
|
|
237
334
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
335
|
+
/**
|
|
336
|
+
* Delivered when a subscribed document's text starts or stops differing
|
|
337
|
+
* from its file, as the server last knew it. Gated like
|
|
338
|
+
* {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
|
|
339
|
+
* the documents the server sends. After a reconnect, a `DataSession`
|
|
340
|
+
* delivers here the answer of each document it restored, when that differs
|
|
341
|
+
* from the last this client was told: the flips while the connection was
|
|
342
|
+
* down reached no one.
|
|
343
|
+
*/
|
|
344
|
+
onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
|
|
345
|
+
/**
|
|
346
|
+
* Delivered when a document's backing file was removed. Separate from
|
|
347
|
+
* {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
|
|
348
|
+
* and more strongly: there is no built state to deliver, and the build-phase
|
|
349
|
+
* path cannot report a deletion at all.
|
|
350
|
+
*
|
|
351
|
+
* Ungated, because on a browser host — where the workspace lives behind the
|
|
352
|
+
* head — no other source can observe a file disappearing. Recipients that
|
|
353
|
+
* only care about their own documents filter by URI.
|
|
354
|
+
*/
|
|
355
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
356
|
+
/**
|
|
357
|
+
* Delivered once per build, naming the documents that reached the
|
|
358
|
+
* subscription phase and that
|
|
359
|
+
* nobody on this connection watches — chiefly the ones rebuilt as a cascade
|
|
360
|
+
* from a dependency's change, which no filesystem watcher can see because
|
|
361
|
+
* their own files did not change. The complement of
|
|
362
|
+
* {@link onDocumentUpdated}; carries URIs and no documents.
|
|
363
|
+
*/
|
|
364
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
238
365
|
}
|
|
239
366
|
/**
|
|
240
367
|
* Project-scoped slice of the client surface — the project-registry change
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-server-protocol.d.ts","sourceRoot":"","sources":["../../src/data/data-server-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,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CACjE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAChC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,CAElC,SAAQ,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC;CAAG"}
|
package/lib/data/events.d.ts
CHANGED
|
@@ -9,69 +9,180 @@
|
|
|
9
9
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from '../transfer-element';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
|
-
import type { TransferDocument } from '../transfer-document';
|
|
12
|
+
import type { TextState, TransferDocument } from '../transfer-document';
|
|
13
13
|
/**
|
|
14
14
|
* Why an update event fired. Subscribers filter on reason for behaviour
|
|
15
15
|
* decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
|
|
16
16
|
*
|
|
17
|
-
* - `'changed'` — the
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
|
|
25
|
-
* build (dependency graph re-derivation), without itself being passed to
|
|
26
|
-
* `documentBuilder.update`. The complement of `'changed'`.
|
|
17
|
+
* - `'changed'` — the server's first update event for the document's current
|
|
18
|
+
* version: its content changed since the last one. A write whose build a
|
|
19
|
+
* later write cancelled is still `'changed'` in the build that takes over.
|
|
20
|
+
* - `'rebuilt'` — a later event for a version the server already delivered,
|
|
21
|
+
* whether or not any client watched it then: something the document depends
|
|
22
|
+
* on changed, or the document was built again with the same content. The
|
|
23
|
+
* complement of `'changed'`.
|
|
27
24
|
* - `'saved'` — emitted by adopters that synthesise a unified update stream
|
|
28
25
|
* from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
|
|
29
26
|
* `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
|
|
30
27
|
* `DataClientProtocol.onDocumentSaved` channel.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* The version rule needs a version the server keeps and builds that validate.
|
|
30
|
+
* For a document no client has opened, or when rebuilds do not validate,
|
|
31
|
+
* `'changed'` means the URI was passed to `DocumentBuilder.update` for this
|
|
32
|
+
* build. A document that a validating build skips is `'changed'` every time.
|
|
33
|
+
*
|
|
34
|
+
* Deletion is deliberately NOT a member. An update event carries a built
|
|
35
|
+
* document, which a deleted one has none of, and the phase-driven path that
|
|
36
|
+
* produces these events never runs for a deleted URI — the builder drops the
|
|
37
|
+
* document before deriving the rebuild set. It travels as
|
|
38
|
+
* {@link TransferDocumentDeletedEvent} on its own channel instead.
|
|
33
39
|
*/
|
|
34
|
-
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved'
|
|
40
|
+
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
|
|
35
41
|
/**
|
|
36
42
|
* Delivered on the data-server when a document's content (or existence)
|
|
37
43
|
* changed. Subscribers receive this via `DocumentServerProtocol.watchModelDocument`.
|
|
38
|
-
*
|
|
39
|
-
* The `document` field carries the latest built state — diagnostics + root
|
|
40
|
-
* are coherent with each other at the time the event fired.
|
|
41
44
|
*/
|
|
42
45
|
export interface TransferDocumentUpdatedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
|
|
46
|
+
/** The latest built state: diagnostics and root are coherent with each other at the time the event fired. */
|
|
43
47
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
44
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The client whose write this event echoes: the author of the version on a
|
|
50
|
+
* `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
|
|
51
|
+
* write. A recipient compares it against its own id to recognise its echo.
|
|
52
|
+
* The build that follows a document's release names the release id
|
|
53
|
+
* instead.
|
|
54
|
+
*/
|
|
45
55
|
sourceClientId: string;
|
|
56
|
+
/** See {@link TransferDocumentUpdateReason} for which reasons the framework sends. */
|
|
46
57
|
reason: TransferDocumentUpdateReason;
|
|
58
|
+
/**
|
|
59
|
+
* The position of this event among the update and deletion events the
|
|
60
|
+
* server sent on this connection, which a watch's answer carries as of
|
|
61
|
+
* the moment it was taken: a greater one was sent later.
|
|
62
|
+
*/
|
|
63
|
+
sequence: number;
|
|
47
64
|
}
|
|
48
65
|
/** Callback shape for `DataClientProtocol.onDocumentUpdated`. */
|
|
49
66
|
export type TransferDocumentUpdatedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>) => void;
|
|
50
67
|
/**
|
|
51
|
-
* Delivered on the data-server when a document was
|
|
52
|
-
*
|
|
53
|
-
* {@link TransferDocumentUpdatedEvent}: subscribers that only
|
|
54
|
-
* persistence (external sync, editor "saved" indicators,
|
|
55
|
-
* clear) listen for this event family instead of filtering an
|
|
56
|
-
* stream for `reason: 'saved'`.
|
|
57
|
-
*
|
|
58
|
-
* The `document` field carries the post-save built state — same shape
|
|
59
|
-
* the synchronous `saveModelDocument` RPC response returns, delivered
|
|
60
|
-
* to subscribers (`DataClientProtocol.onDocumentSaved`) so non-caller
|
|
61
|
-
* clients see the persistence event too.
|
|
68
|
+
* Delivered on the data-server when a subscribed document was saved to disk,
|
|
69
|
+
* whichever client saved it, an editor's save through the LSP head included.
|
|
70
|
+
* Distinct from {@link TransferDocumentUpdatedEvent}: subscribers that only
|
|
71
|
+
* care about persistence (external sync, editor "saved" indicators,
|
|
72
|
+
* dirty-flag clear) listen for this event family instead of filtering an
|
|
73
|
+
* update stream for `reason: 'saved'`.
|
|
62
74
|
*/
|
|
63
75
|
export interface TransferDocumentSavedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
|
|
76
|
+
/** The latest built state, taken after the save. */
|
|
64
77
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
65
78
|
/**
|
|
66
|
-
* The client whose
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
79
|
+
* The client whose save produced this, also when another client wrote the
|
|
80
|
+
* persisted text: the caller of `saveModelDocument` or
|
|
81
|
+
* `persistModelDocument`, or `LANGUAGE_CLIENT_ID` for an editor's save
|
|
82
|
+
* through the LSP head. Every subscriber receives the event, the saving
|
|
83
|
+
* client included, so compare against your own id to drop the echo.
|
|
70
84
|
*/
|
|
71
85
|
sourceClientId: string;
|
|
72
86
|
}
|
|
73
87
|
/** Callback shape for `DataClientProtocol.onDocumentSaved`. */
|
|
74
88
|
export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Delivered on the data-server when a watched document's text starts or stops
|
|
91
|
+
* differing from its file, as the server last knew the file. The current
|
|
92
|
+
* answer rides on every transfer document the server sends as `text.dirty`;
|
|
93
|
+
* this carries only its changes, so a client that follows it needs no rebuild
|
|
94
|
+
* to learn of a save.
|
|
95
|
+
*/
|
|
96
|
+
export interface TransferDocumentDirtyChangedEvent {
|
|
97
|
+
/** Canonical URI, keyed as the subscription is. */
|
|
98
|
+
readonly uri: string;
|
|
99
|
+
/**
|
|
100
|
+
* The text the answer was decided on. It is sent before that text is
|
|
101
|
+
* built, so a `text.version` ahead of the model a client holds means an
|
|
102
|
+
* update at this version or a later one follows. Absent when the document
|
|
103
|
+
* no longer exists, or when the build that follows its release failed.
|
|
104
|
+
*/
|
|
105
|
+
readonly text?: TextState;
|
|
106
|
+
}
|
|
107
|
+
/** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
|
|
108
|
+
export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Delivered on the data-server when a document's backing file was removed.
|
|
111
|
+
* Carries no document, and cannot: the state a
|
|
112
|
+
* {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
|
|
113
|
+
* the time anyone can be told. That is also why deletion is not a `reason` on
|
|
114
|
+
* the update stream — `DocumentBuilder.update` drops the document before
|
|
115
|
+
* deriving the rebuild set, so the phase-driven path that produces update
|
|
116
|
+
* events never runs for it.
|
|
117
|
+
*
|
|
118
|
+
* **Delivered for EVERY document, not only watched ones**, unlike
|
|
119
|
+
* `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
|
|
120
|
+
* channels are gated is whether any OTHER source can observe the fact on the
|
|
121
|
+
* least capable host: a browser-hosted client's workspace lives behind the
|
|
122
|
+
* head, so nothing there can see a file disappear, and gating the notification
|
|
123
|
+
* would leave it blind. (A Theia frontend's filesystem watcher would cover it,
|
|
124
|
+
* which is why this is a host argument and not a structure-versus-content one.)
|
|
125
|
+
* A watcher is told about its own document's deletion here too, the update
|
|
126
|
+
* channel being silent for deletions by construction. Filter on {@link uri} if
|
|
127
|
+
* the receiver only cares about documents it opened.
|
|
128
|
+
*
|
|
129
|
+
* A watch survives the deletion, so a file that comes back resumes delivering
|
|
130
|
+
* `onDocumentUpdated` to the same subscribers with no re-subscription. A
|
|
131
|
+
* client that responds by closing its editor releases the watch through
|
|
132
|
+
* `closeModelDocument` as usual, and `deleteModelDocument` releases the
|
|
133
|
+
* deleting session's own.
|
|
134
|
+
*/
|
|
135
|
+
export interface TransferDocumentDeletedEvent {
|
|
136
|
+
/** Canonical URI of the removed document, keyed as the subscription is. */
|
|
137
|
+
readonly uri: string;
|
|
138
|
+
/**
|
|
139
|
+
* The session whose `deleteModelDocument` removed the file, so it can tell
|
|
140
|
+
* its own deletion from another's; the unknown-client id for a file
|
|
141
|
+
* removed outside any session, as a file watcher reports one, and for one
|
|
142
|
+
* a `DataConnection` found gone after a reconnect, which no event named.
|
|
143
|
+
*/
|
|
144
|
+
readonly sourceClientId: string;
|
|
145
|
+
/**
|
|
146
|
+
* The position of this event among the update and deletion events the
|
|
147
|
+
* server sent on this connection, as on an update; absent on a deletion a
|
|
148
|
+
* `DataConnection` found after a reconnect, which the server never sent.
|
|
149
|
+
*/
|
|
150
|
+
readonly sequence?: number;
|
|
151
|
+
}
|
|
152
|
+
/** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
|
|
153
|
+
export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Delivered on the data-server once per build, naming the documents that reached
|
|
156
|
+
* the configured subscription phase (`DataServerOptions.subscriptionPhase`,
|
|
157
|
+
* `Validated` by default) and that NO client on the connection is watching. Not
|
|
158
|
+
* the integrity-settled landmark, which is a different point and a different
|
|
159
|
+
* word in this framework.
|
|
160
|
+
*
|
|
161
|
+
* The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
|
|
162
|
+
* URI: together the two cover every document a build touched. This one exists
|
|
163
|
+
* for the case no source outside the server can observe — a document rebuilt
|
|
164
|
+
* because something it DEPENDS ON changed. Its own file never changed, so a
|
|
165
|
+
* filesystem watcher cannot see it, and it has no subscriber, so the update
|
|
166
|
+
* channel does not report it. A consumer showing data derived from such a
|
|
167
|
+
* document (a tree label, a decorator) would otherwise hold a stale value with
|
|
168
|
+
* nothing to invalidate it.
|
|
169
|
+
*
|
|
170
|
+
* Carries URIs and no documents: a recipient re-reads what it displays, through
|
|
171
|
+
* `getModelDocument` or its own request. That keeps the bandwidth property the
|
|
172
|
+
* per-URI subscription exists for, without gating the message.
|
|
173
|
+
*
|
|
174
|
+
* Not sent when the set is empty, which is the normal case while editing — the
|
|
175
|
+
* document being edited is watched by its own editor and therefore excluded.
|
|
176
|
+
* Workspace initialisation sends nothing either: it does not build to the
|
|
177
|
+
* subscription phase. The largest message a workspace can produce is therefore
|
|
178
|
+
* a whole-workspace rebuild at that phase, which is one message of URIs.
|
|
179
|
+
*/
|
|
180
|
+
export interface TransferDocumentsBuiltEvent {
|
|
181
|
+
/** Canonical URIs, keyed as subscriptions are. Never empty. */
|
|
182
|
+
readonly uris: readonly string[];
|
|
183
|
+
}
|
|
184
|
+
/** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
|
|
185
|
+
export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
|
|
75
186
|
/**
|
|
76
187
|
* Why a project-change event fired. `added` — the project was newly
|
|
77
188
|
* registered (descriptor discovered); `updated` — the project's
|
package/lib/data/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,4BAA4B,CAC1C,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IAE3D,6GAA6G;IAC7G,QAAQ,EAAE,gBAAgB,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