@hydranium/protocol 1.0.0-next.33 → 1.0.0-next.331
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 +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 +302 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +533 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +17 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +25 -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 +684 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1148 -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 +4 -4
- 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 +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 +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +86 -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 +170 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +137 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +71 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +3 -3
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +6 -9
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +183 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +268 -32
- package/lib/errors.js.map +1 -1
- package/lib/glsp-edits-settled-actions.d.ts +52 -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 +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 +10 -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 +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 +15 -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 +29 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +46 -0
- package/lib/pending-work-tracker.js.map +1 -0
- 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/project.d.ts +4 -1
- 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 +67 -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.d.ts +1 -1
- package/lib/testing/catalogue-audit.js +1 -1
- 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.js.map +1 -1
- package/lib/transfer-document.d.ts +95 -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 +8 -0
- package/src/client/data-connection.ts +653 -0
- package/src/client/data-events.ts +37 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1469 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +4 -4
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client/worker-handshake.ts +113 -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 +197 -48
- package/src/data/events.ts +143 -21
- package/src/data/requests.ts +77 -11
- package/src/debouncer.ts +7 -10
- package/src/errors.ts +326 -40
- package/src/glsp-edits-settled-actions.ts +60 -0
- 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 +44 -8
- package/src/messages/index.ts +4 -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 +46 -0
- package/src/profile-session.ts +9 -4
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +128 -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/catalogue-audit.ts +1 -1
- 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-document.ts +115 -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
|
@@ -0,0 +1,157 @@
|
|
|
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 { MessageConnection } from 'vscode-jsonrpc';
|
|
10
|
+
import { type ResolvedMessage } from '../messages/primitives';
|
|
11
|
+
import { type RpcProxy } from '../rpc';
|
|
12
|
+
import type { DataPort } from './data-port';
|
|
13
|
+
/**
|
|
14
|
+
* The transport never opened. A complete sentence rather than a fragment: a
|
|
15
|
+
* fragment is nested inside a sentence the framework does not own, so no
|
|
16
|
+
* translator controls the whole and the composition cannot be made to read
|
|
17
|
+
* correctly in every language.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DATA_SERVER_CONNECT_FAILED: import("../messages/primitives").MessageDefinition<"Could not connect to the data server: {detail}">;
|
|
20
|
+
export declare const DATA_SERVER_NOT_READY: import("../messages/primitives").MessageDefinition<"The data server did not become ready: {detail}">;
|
|
21
|
+
/** The one method a connection needs of any server: its startup gate. */
|
|
22
|
+
export interface ReadyServer {
|
|
23
|
+
waitForReady(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Lifecycle reporting, for a host that raises warm-up UI around the two waits.
|
|
27
|
+
*
|
|
28
|
+
* Nothing fires until something asks for the connection — the generation is
|
|
29
|
+
* built on the first {@link RpcConnection.connected}. A host that wants the
|
|
30
|
+
* sequence at startup drives that call itself, or a workspace where nobody
|
|
31
|
+
* opens a document reports neither the connect nor the readiness its UI waits
|
|
32
|
+
* on.
|
|
33
|
+
*/
|
|
34
|
+
export interface RpcConnectionLifecycle {
|
|
35
|
+
/** A generation is opening its transport, including on each reconnect. */
|
|
36
|
+
readonly onConnecting?: () => void;
|
|
37
|
+
/** The server's readiness gate has settled for a generation. */
|
|
38
|
+
readonly onReady?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* A generation failed to connect or to become ready. The failure is still
|
|
41
|
+
* reported through {@link DataPort.reportError} and still rejects the
|
|
42
|
+
* awaiting caller; this is for a host that also drives its own UI.
|
|
43
|
+
*/
|
|
44
|
+
readonly onFailed?: (error: unknown) => void;
|
|
45
|
+
}
|
|
46
|
+
/** Everything {@link RpcConnection} needs once a subclass has resolved its defaults. */
|
|
47
|
+
export interface ResolvedRpcConnectionOptions<TClient extends object> {
|
|
48
|
+
readonly methodNamespace: string;
|
|
49
|
+
readonly clientMethods: readonly (keyof TClient & string)[];
|
|
50
|
+
readonly lifecycle: RpcConnectionLifecycle;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One connection generation: its connection, its proxy, and its readiness.
|
|
54
|
+
*
|
|
55
|
+
* Named by the `protected` reconnect seams {@link RpcConnection.currentGeneration}
|
|
56
|
+
* and {@link RpcConnection.awaitReady}, so an override has to name it too.
|
|
57
|
+
*/
|
|
58
|
+
export interface RpcConnectionGeneration<TServer extends object> {
|
|
59
|
+
readonly connection: Promise<MessageConnection>;
|
|
60
|
+
readonly server: RpcProxy<TServer>;
|
|
61
|
+
/** Set on first use; the shared readiness gate for this generation. */
|
|
62
|
+
ready?: Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* One JSON-RPC connection to a head, with the three jobs every host adapter
|
|
66
|
+
* would otherwise re-derive above {@link DataPort}:
|
|
67
|
+
*
|
|
68
|
+
* 1. **Build the typed proxy** over the port's connection, with the caller's
|
|
69
|
+
* wire prefix and client-method allowlist.
|
|
70
|
+
* 2. **Own the readiness gate** — `waitForReady` once per connection, shared
|
|
71
|
+
* across concurrent callers. A client can connect before the workspace walk
|
|
72
|
+
* finishes, and an early request is then answered correctly from an empty
|
|
73
|
+
* registry, which reads as a broken project tier rather than as a race.
|
|
74
|
+
* 3. **Own the reconnect policy**, by dropping its generation when the port
|
|
75
|
+
* disposes and building a fresh one on the next request.
|
|
76
|
+
*
|
|
77
|
+
* Bounded only by {@link ReadyServer}, so a head serving a slice of the data
|
|
78
|
+
* protocol — diagnostics alone, or one with methods excluded — is still a
|
|
79
|
+
* legal server here. `DataConnection` narrows the bound because its sessions
|
|
80
|
+
* call the document methods; nothing at this layer does.
|
|
81
|
+
*/
|
|
82
|
+
export declare class RpcConnection<TServer extends ReadyServer, TClient extends object> {
|
|
83
|
+
protected readonly port: DataPort;
|
|
84
|
+
protected readonly client: TClient;
|
|
85
|
+
protected readonly methodNamespace: string;
|
|
86
|
+
protected readonly clientMethods: readonly (keyof TClient & string)[];
|
|
87
|
+
protected readonly lifecycle: RpcConnectionLifecycle;
|
|
88
|
+
/** The current generation, or `undefined` before the first request / after a teardown. */
|
|
89
|
+
protected generation?: RpcConnectionGeneration<TServer>;
|
|
90
|
+
protected disposed: boolean;
|
|
91
|
+
protected readonly portDisposeListener: {
|
|
92
|
+
dispose(): void;
|
|
93
|
+
};
|
|
94
|
+
constructor(port: DataPort, client: TClient, options: ResolvedRpcConnectionOptions<TClient>);
|
|
95
|
+
/**
|
|
96
|
+
* The connected, READY server proxy.
|
|
97
|
+
*
|
|
98
|
+
* Returns the proxy rather than `void` on purpose. A reconnect replaces the
|
|
99
|
+
* proxy, so a caller that cached one from an earlier call would go on
|
|
100
|
+
* addressing a dead connection with no error — handing it back per call
|
|
101
|
+
* makes the stale reference unrepresentable.
|
|
102
|
+
*
|
|
103
|
+
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
104
|
+
* awaited once per generation and not once per caller.
|
|
105
|
+
*/
|
|
106
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
107
|
+
/**
|
|
108
|
+
* The current generation's proxy WITHOUT awaiting readiness — calls queue
|
|
109
|
+
* against the connection promise.
|
|
110
|
+
*
|
|
111
|
+
* **Protected, and that is the point.** An early request is answered
|
|
112
|
+
* correctly from a registry the workspace walk has not filled yet, which
|
|
113
|
+
* reads as a broken project tier rather than as a race — so every caller has
|
|
114
|
+
* to interpose the gate, and every caller forgetting to is a silent bug.
|
|
115
|
+
* {@link connected} is the public route and returns this same proxy once the
|
|
116
|
+
* gate has settled, which leaves nothing to forget. The one caller that
|
|
117
|
+
* cannot use it is {@link awaitReady}, whose whole job is running the gate.
|
|
118
|
+
*
|
|
119
|
+
* Read per access, never cached: a reconnect replaces the generation, and a
|
|
120
|
+
* held reference would address the dead one.
|
|
121
|
+
*/
|
|
122
|
+
protected get server(): RpcProxy<TServer>;
|
|
123
|
+
/**
|
|
124
|
+
* Surface a failure the way this host does, through the port's sink.
|
|
125
|
+
*
|
|
126
|
+
* Here rather than only on the port so every participant sharing the
|
|
127
|
+
* connection reports through one route without being handed the transport.
|
|
128
|
+
*/
|
|
129
|
+
reportError(error: unknown, reported: ResolvedMessage): void;
|
|
130
|
+
/** Tear down the current connection and stop tracking the port. Idempotent. */
|
|
131
|
+
dispose(): void;
|
|
132
|
+
/** The live generation, building one if there is none. */
|
|
133
|
+
protected currentGeneration(): RpcConnectionGeneration<TServer>;
|
|
134
|
+
/**
|
|
135
|
+
* The object whose {@link clientMethods} answer the server on each new
|
|
136
|
+
* generation: {@link client} itself. A subclass that must see a call before
|
|
137
|
+
* the client does returns an object that forwards each of them to it.
|
|
138
|
+
*/
|
|
139
|
+
protected localTarget(): TClient;
|
|
140
|
+
/** Await the connection and the server's startup gate for one generation. */
|
|
141
|
+
protected awaitReady(generation: RpcConnectionGeneration<TServer>): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Called once `generation` has passed its readiness gate, whichever request
|
|
144
|
+
* brought it up. A generation can replace one that failed at readiness
|
|
145
|
+
* without {@link dropGeneration}, so this, not a drop, is where state kept
|
|
146
|
+
* on the server is put back. It runs inside the readiness gate, so a throw
|
|
147
|
+
* from an override fails the generation as a refused gate would.
|
|
148
|
+
*/
|
|
149
|
+
protected generationReady(_generation: RpcConnectionGeneration<TServer>): void;
|
|
150
|
+
/**
|
|
151
|
+
* Discard the current generation, disposing its connection if it opened.
|
|
152
|
+
* The next {@link connected} builds a fresh one.
|
|
153
|
+
*/
|
|
154
|
+
protected dropGeneration(): void;
|
|
155
|
+
protected assertLive(): void;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=rpc-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-connection.d.ts","sourceRoot":"","sources":["../../src/client/rpc-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAyC,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,sGAGtC,CAAC;AAEF,eAAO,MAAM,qBAAqB,sGAGjC,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,WAAW;IACzB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IACnC,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;;;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ACsB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,OAAO,EAClC,OAAO,EAAE,4BAA4B,CAAC,OAAO,CAAC,EAMhD;IAED;;;;;;;;;;OAUG;IACG,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAa5C;IAED;;;;;;;;;;;;;;OAcG;IACH,SAAS,KAAK,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,CAGxC;IAED;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAE3D;IAED,+EAA+E;IAC/E,OAAO,IAAI,IAAI,CAOd;IAED,0DAA0D;IAC1D,SAAS,CAAC,iBAAiB,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAmB9D;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,IAAI,OAAO,CAE/B;IAED,6EAA6E;IAC7E,UAAgB,UAAU,CAAC,UAAU,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BtF;IAED;;;;;;OAMG;IACH,SAAS,CAAC,eAAe,CAAC,WAAW,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAE7E;IAED;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI,CAO/B;IAED,SAAS,CAAC,UAAU,IAAI,IAAI,CAI3B;CACH"}
|
|
@@ -0,0 +1,214 @@
|
|
|
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.RpcConnection = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = void 0;
|
|
12
|
+
const primitives_1 = require("../messages/primitives");
|
|
13
|
+
const rpc_1 = require("../rpc");
|
|
14
|
+
/**
|
|
15
|
+
* The transport never opened. A complete sentence rather than a fragment: a
|
|
16
|
+
* fragment is nested inside a sentence the framework does not own, so no
|
|
17
|
+
* translator controls the whole and the composition cannot be made to read
|
|
18
|
+
* correctly in every language.
|
|
19
|
+
*/
|
|
20
|
+
exports.DATA_SERVER_CONNECT_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/data-server-connect-failed', 'Could not connect to the data server: {detail}');
|
|
21
|
+
exports.DATA_SERVER_NOT_READY = (0, primitives_1.defineMessage)('hydranium/protocol/data-server-not-ready', 'The data server did not become ready: {detail}');
|
|
22
|
+
/** Calls each distinct lifecycle's hooks in order; one passed twice is called once. */
|
|
23
|
+
function composeLifecycles(...lifecycles) {
|
|
24
|
+
const present = [...new Set(lifecycles)].filter((lifecycle) => lifecycle !== undefined);
|
|
25
|
+
return {
|
|
26
|
+
onConnecting: () => present.forEach(lifecycle => lifecycle.onConnecting?.()),
|
|
27
|
+
onReady: () => present.forEach(lifecycle => lifecycle.onReady?.()),
|
|
28
|
+
onFailed: error => present.forEach(lifecycle => lifecycle.onFailed?.(error))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One JSON-RPC connection to a head, with the three jobs every host adapter
|
|
33
|
+
* would otherwise re-derive above {@link DataPort}:
|
|
34
|
+
*
|
|
35
|
+
* 1. **Build the typed proxy** over the port's connection, with the caller's
|
|
36
|
+
* wire prefix and client-method allowlist.
|
|
37
|
+
* 2. **Own the readiness gate** — `waitForReady` once per connection, shared
|
|
38
|
+
* across concurrent callers. A client can connect before the workspace walk
|
|
39
|
+
* finishes, and an early request is then answered correctly from an empty
|
|
40
|
+
* registry, which reads as a broken project tier rather than as a race.
|
|
41
|
+
* 3. **Own the reconnect policy**, by dropping its generation when the port
|
|
42
|
+
* disposes and building a fresh one on the next request.
|
|
43
|
+
*
|
|
44
|
+
* Bounded only by {@link ReadyServer}, so a head serving a slice of the data
|
|
45
|
+
* protocol — diagnostics alone, or one with methods excluded — is still a
|
|
46
|
+
* legal server here. `DataConnection` narrows the bound because its sessions
|
|
47
|
+
* call the document methods; nothing at this layer does.
|
|
48
|
+
*/
|
|
49
|
+
class RpcConnection {
|
|
50
|
+
port;
|
|
51
|
+
client;
|
|
52
|
+
methodNamespace;
|
|
53
|
+
clientMethods;
|
|
54
|
+
lifecycle;
|
|
55
|
+
/** The current generation, or `undefined` before the first request / after a teardown. */
|
|
56
|
+
generation;
|
|
57
|
+
disposed = false;
|
|
58
|
+
portDisposeListener;
|
|
59
|
+
constructor(port, client, options) {
|
|
60
|
+
this.port = port;
|
|
61
|
+
this.client = client;
|
|
62
|
+
this.methodNamespace = options.methodNamespace;
|
|
63
|
+
this.clientMethods = options.clientMethods;
|
|
64
|
+
this.lifecycle = composeLifecycles(port.connectionLifecycle, options.lifecycle);
|
|
65
|
+
this.portDisposeListener = this.port.onDispose(() => this.dropGeneration());
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The connected, READY server proxy.
|
|
69
|
+
*
|
|
70
|
+
* Returns the proxy rather than `void` on purpose. A reconnect replaces the
|
|
71
|
+
* proxy, so a caller that cached one from an earlier call would go on
|
|
72
|
+
* addressing a dead connection with no error — handing it back per call
|
|
73
|
+
* makes the stale reference unrepresentable.
|
|
74
|
+
*
|
|
75
|
+
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
76
|
+
* awaited once per generation and not once per caller.
|
|
77
|
+
*/
|
|
78
|
+
async connected() {
|
|
79
|
+
this.assertLive();
|
|
80
|
+
const generation = this.currentGeneration();
|
|
81
|
+
if (!generation.ready) {
|
|
82
|
+
generation.ready = this.awaitReady(generation);
|
|
83
|
+
}
|
|
84
|
+
await generation.ready;
|
|
85
|
+
// Dropped while it opened: its transport is gone, so the call goes to the
|
|
86
|
+
// next generation, or rejects once this connection is disposed.
|
|
87
|
+
if (this.generation !== generation) {
|
|
88
|
+
return this.connected();
|
|
89
|
+
}
|
|
90
|
+
return generation.server;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The current generation's proxy WITHOUT awaiting readiness — calls queue
|
|
94
|
+
* against the connection promise.
|
|
95
|
+
*
|
|
96
|
+
* **Protected, and that is the point.** An early request is answered
|
|
97
|
+
* correctly from a registry the workspace walk has not filled yet, which
|
|
98
|
+
* reads as a broken project tier rather than as a race — so every caller has
|
|
99
|
+
* to interpose the gate, and every caller forgetting to is a silent bug.
|
|
100
|
+
* {@link connected} is the public route and returns this same proxy once the
|
|
101
|
+
* gate has settled, which leaves nothing to forget. The one caller that
|
|
102
|
+
* cannot use it is {@link awaitReady}, whose whole job is running the gate.
|
|
103
|
+
*
|
|
104
|
+
* Read per access, never cached: a reconnect replaces the generation, and a
|
|
105
|
+
* held reference would address the dead one.
|
|
106
|
+
*/
|
|
107
|
+
get server() {
|
|
108
|
+
this.assertLive();
|
|
109
|
+
return this.currentGeneration().server;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Surface a failure the way this host does, through the port's sink.
|
|
113
|
+
*
|
|
114
|
+
* Here rather than only on the port so every participant sharing the
|
|
115
|
+
* connection reports through one route without being handed the transport.
|
|
116
|
+
*/
|
|
117
|
+
reportError(error, reported) {
|
|
118
|
+
this.port.reportError(error, reported);
|
|
119
|
+
}
|
|
120
|
+
/** Tear down the current connection and stop tracking the port. Idempotent. */
|
|
121
|
+
dispose() {
|
|
122
|
+
if (this.disposed) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.disposed = true;
|
|
126
|
+
this.portDisposeListener.dispose();
|
|
127
|
+
this.dropGeneration();
|
|
128
|
+
}
|
|
129
|
+
/** The live generation, building one if there is none. */
|
|
130
|
+
currentGeneration() {
|
|
131
|
+
if (this.generation) {
|
|
132
|
+
return this.generation;
|
|
133
|
+
}
|
|
134
|
+
this.lifecycle.onConnecting?.();
|
|
135
|
+
const connection = this.port.connect();
|
|
136
|
+
// Rejection is reported here rather than left to float: an unhandled
|
|
137
|
+
// rejection on a connection promise is the failure mode that reads as
|
|
138
|
+
// "the model is empty" instead of "the transport never opened".
|
|
139
|
+
connection.catch((error) => this.port.reportError(error, (0, primitives_1.resolve)(exports.DATA_SERVER_CONNECT_FAILED, { detail: (0, primitives_1.describeError)(error) })));
|
|
140
|
+
const server = (0, rpc_1.createRpcProxy)(connection, {
|
|
141
|
+
methodNamespace: this.methodNamespace,
|
|
142
|
+
localTarget: this.localTarget(),
|
|
143
|
+
localMethods: this.clientMethods
|
|
144
|
+
});
|
|
145
|
+
this.generation = { connection, server };
|
|
146
|
+
return this.generation;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The object whose {@link clientMethods} answer the server on each new
|
|
150
|
+
* generation: {@link client} itself. A subclass that must see a call before
|
|
151
|
+
* the client does returns an object that forwards each of them to it.
|
|
152
|
+
*/
|
|
153
|
+
localTarget() {
|
|
154
|
+
return this.client;
|
|
155
|
+
}
|
|
156
|
+
/** Await the connection and the server's startup gate for one generation. */
|
|
157
|
+
async awaitReady(generation) {
|
|
158
|
+
try {
|
|
159
|
+
await generation.connection;
|
|
160
|
+
// Dropped meanwhile: writing the request would hit a closed transport.
|
|
161
|
+
if (this.generation !== generation) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
await generation.server.waitForReady();
|
|
165
|
+
// Before `onReady`, so a failing restore reports a failure alone.
|
|
166
|
+
this.generationReady(generation);
|
|
167
|
+
this.lifecycle.onReady?.();
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// A dropped generation's request fails with its transport, which says
|
|
171
|
+
// nothing about whether the server is ready.
|
|
172
|
+
if (this.generation !== generation) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.lifecycle.onFailed?.(error);
|
|
176
|
+
// Drop the generation so the next request retries rather than
|
|
177
|
+
// re-awaiting a settled rejection forever.
|
|
178
|
+
if (this.generation === generation) {
|
|
179
|
+
this.generation = undefined;
|
|
180
|
+
}
|
|
181
|
+
this.port.reportError(error, (0, primitives_1.resolve)(exports.DATA_SERVER_NOT_READY, { detail: (0, primitives_1.describeError)(error) }));
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Called once `generation` has passed its readiness gate, whichever request
|
|
187
|
+
* brought it up. A generation can replace one that failed at readiness
|
|
188
|
+
* without {@link dropGeneration}, so this, not a drop, is where state kept
|
|
189
|
+
* on the server is put back. It runs inside the readiness gate, so a throw
|
|
190
|
+
* from an override fails the generation as a refused gate would.
|
|
191
|
+
*/
|
|
192
|
+
generationReady(_generation) {
|
|
193
|
+
// Nothing to put back at this layer.
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Discard the current generation, disposing its connection if it opened.
|
|
197
|
+
* The next {@link connected} builds a fresh one.
|
|
198
|
+
*/
|
|
199
|
+
dropGeneration() {
|
|
200
|
+
const generation = this.generation;
|
|
201
|
+
this.generation = undefined;
|
|
202
|
+
if (!generation) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
generation.connection.then(connection => connection.dispose()).catch(() => undefined);
|
|
206
|
+
}
|
|
207
|
+
assertLive() {
|
|
208
|
+
if (this.disposed) {
|
|
209
|
+
throw new Error(`${this.constructor.name} is disposed`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.RpcConnection = RpcConnection;
|
|
214
|
+
//# sourceMappingURL=rpc-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-connection.js","sourceRoot":"","sources":["../../src/client/rpc-connection.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,uDAAqG;AACrG,gCAAuD;AAGvD;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,IAAA,0BAAa,EACpD,+CAA+C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,6CAA6C;YAC7C,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAClC,OAAO;YACV,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;YACjC,8DAA8D;YAC9D,2CAA2C;YAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAClC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC/B,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,IAAA,oBAAO,EAAC,QAAA,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/F,MAAM,KAAK,CAAC;QACf,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACO,eAAe,CAAC,WAA6C;QACpE,qCAAqC;IACxC,CAAC;IAED;;;OAGG;IACO,cAAc;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,EAAE,CAAC;YACf,OAAO;QACV,CAAC;QACD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACzF,CAAC;IAES,UAAU;QACjB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,cAAc,CAAC,CAAC;QAC3D,CAAC;IACJ,CAAC;CACH"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
/**
|
|
10
|
+
* The handshake between a page and the worker hosting its heads, shared by
|
|
11
|
+
* both ends so neither can drift from the other.
|
|
12
|
+
*
|
|
13
|
+
* **Every head gets its own `MessagePort`; none is bound to the worker
|
|
14
|
+
* global.** The heads share one worker so they share one Langium store, and
|
|
15
|
+
* that makes the global contended: a head bound to it receives every other
|
|
16
|
+
* head's traffic, since a JSON-RPC reader filters nothing. The global is
|
|
17
|
+
* unusable even for a single head: GLSP's worker launcher posts its startup
|
|
18
|
+
* handshake through the global `postMessage` regardless of the connection it
|
|
19
|
+
* was configured with, a plain string no JSON-RPC reader can parse.
|
|
20
|
+
*
|
|
21
|
+
* The global therefore carries the host protocol: the bootstrap in, the ready
|
|
22
|
+
* message and failure reports out, and whatever else the host adds for
|
|
23
|
+
* itself. A message that belongs to a head belongs on that head's port.
|
|
24
|
+
*
|
|
25
|
+
* The ports are {@link TransferredMessagePort}s, because this package compiles
|
|
26
|
+
* without the DOM lib and the structural type is also what rejects a `Worker`
|
|
27
|
+
* or the worker global at an adopter's call site.
|
|
28
|
+
*/
|
|
29
|
+
import type { TransferredMessagePort } from './post-message-transport';
|
|
30
|
+
/** Discriminator of the bootstrap message a page posts on the worker global. */
|
|
31
|
+
export declare const WORKER_BOOTSTRAP_MESSAGE_TYPE = "hydranium/bootstrap";
|
|
32
|
+
/** One transferred port per head. */
|
|
33
|
+
export interface HeadPorts {
|
|
34
|
+
readonly lsp: TransferredMessagePort;
|
|
35
|
+
readonly data: TransferredMessagePort;
|
|
36
|
+
readonly glsp: TransferredMessagePort;
|
|
37
|
+
}
|
|
38
|
+
/** The one message the worker answers, by starting its heads on the ports. */
|
|
39
|
+
export interface WorkerBootstrapMessage {
|
|
40
|
+
readonly type: typeof WORKER_BOOTSTRAP_MESSAGE_TYPE;
|
|
41
|
+
readonly ports: HeadPorts;
|
|
42
|
+
}
|
|
43
|
+
export declare function isWorkerBootstrapMessage(value: unknown): value is WorkerBootstrapMessage;
|
|
44
|
+
/**
|
|
45
|
+
* Discriminator of the message the worker posts on the global once every head
|
|
46
|
+
* is up. Until it arrives, the page takes the `Worker`'s `error` event as a
|
|
47
|
+
* worker that never started and ends the heads; after it, as an uncaught error
|
|
48
|
+
* the worker runs on from, which it reports and keeps the heads through.
|
|
49
|
+
*/
|
|
50
|
+
export declare const WORKER_READY_MESSAGE_TYPE = "hydranium/ready";
|
|
51
|
+
export interface WorkerReadyMessage {
|
|
52
|
+
readonly type: typeof WORKER_READY_MESSAGE_TYPE;
|
|
53
|
+
/** The files the heads came up on, when the worker's host named a root to read them under. */
|
|
54
|
+
readonly workspace?: WorkerWorkspace;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What the worker's filesystem holds under {@link rootUri} once its heads are
|
|
58
|
+
* up, which is what a page opens its editors on: once a store can differ from
|
|
59
|
+
* the seed, an editor opened on the seed overwrites the restored document.
|
|
60
|
+
*/
|
|
61
|
+
export interface WorkerWorkspace {
|
|
62
|
+
readonly rootUri: string;
|
|
63
|
+
/** Every file's content, keyed by its path relative to {@link rootUri}. */
|
|
64
|
+
readonly files: Readonly<Record<string, string>>;
|
|
65
|
+
/** The paths of {@link files} that came out of the store rather than the seed. */
|
|
66
|
+
readonly restored: readonly string[];
|
|
67
|
+
}
|
|
68
|
+
export declare function isWorkerReadyMessage(value: unknown): value is WorkerReadyMessage;
|
|
69
|
+
/**
|
|
70
|
+
* Discriminator of a failure report the worker posts on the global.
|
|
71
|
+
*
|
|
72
|
+
* A worker has no console anyone is looking at, and the failures that matter
|
|
73
|
+
* most reach nobody by default: a workspace walk that throws has no reply to
|
|
74
|
+
* reject, so it looks exactly like a workspace with no documents in it.
|
|
75
|
+
*/
|
|
76
|
+
export declare const WORKER_ERROR_MESSAGE_TYPE = "hydranium/worker-error";
|
|
77
|
+
/** The phase a failed bootstrap reports under; no head answers after it. */
|
|
78
|
+
export declare const WORKER_BOOTSTRAP_PHASE = "bootstrap";
|
|
79
|
+
export interface WorkerErrorMessage {
|
|
80
|
+
readonly type: typeof WORKER_ERROR_MESSAGE_TYPE;
|
|
81
|
+
/** What the worker was doing, {@link WORKER_BOOTSTRAP_PHASE} for a failed bootstrap. */
|
|
82
|
+
readonly phase: string;
|
|
83
|
+
readonly message: string;
|
|
84
|
+
}
|
|
85
|
+
export declare function isWorkerErrorMessage(value: unknown): value is WorkerErrorMessage;
|
|
86
|
+
//# sourceMappingURL=worker-handshake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-handshake.d.ts","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AAEnE,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACvB,QAAQ,CAAC,GAAG,EAAE,sBAAsB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;CACxC;AAED,8EAA8E;AAC9E,MAAM,WAAW,sBAAsB;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,6BAA6B,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAMxF;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,yBAAyB,CAAC;IAChD,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAElE,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD,MAAM,WAAW,kBAAkB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,yBAAyB,CAAC;IAChD,wFAAwF;IACxF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAMhF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 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.WORKER_BOOTSTRAP_PHASE = exports.WORKER_ERROR_MESSAGE_TYPE = exports.WORKER_READY_MESSAGE_TYPE = exports.WORKER_BOOTSTRAP_MESSAGE_TYPE = void 0;
|
|
12
|
+
exports.isWorkerBootstrapMessage = isWorkerBootstrapMessage;
|
|
13
|
+
exports.isWorkerReadyMessage = isWorkerReadyMessage;
|
|
14
|
+
exports.isWorkerErrorMessage = isWorkerErrorMessage;
|
|
15
|
+
/** Discriminator of the bootstrap message a page posts on the worker global. */
|
|
16
|
+
exports.WORKER_BOOTSTRAP_MESSAGE_TYPE = 'hydranium/bootstrap';
|
|
17
|
+
function isWorkerBootstrapMessage(value) {
|
|
18
|
+
if (typeof value !== 'object' || value === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const candidate = value;
|
|
22
|
+
return candidate.type === exports.WORKER_BOOTSTRAP_MESSAGE_TYPE && typeof candidate.ports === 'object' && candidate.ports !== null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Discriminator of the message the worker posts on the global once every head
|
|
26
|
+
* is up. Until it arrives, the page takes the `Worker`'s `error` event as a
|
|
27
|
+
* worker that never started and ends the heads; after it, as an uncaught error
|
|
28
|
+
* the worker runs on from, which it reports and keeps the heads through.
|
|
29
|
+
*/
|
|
30
|
+
exports.WORKER_READY_MESSAGE_TYPE = 'hydranium/ready';
|
|
31
|
+
function isWorkerReadyMessage(value) {
|
|
32
|
+
return typeof value === 'object' && value !== null && value.type === exports.WORKER_READY_MESSAGE_TYPE;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Discriminator of a failure report the worker posts on the global.
|
|
36
|
+
*
|
|
37
|
+
* A worker has no console anyone is looking at, and the failures that matter
|
|
38
|
+
* most reach nobody by default: a workspace walk that throws has no reply to
|
|
39
|
+
* reject, so it looks exactly like a workspace with no documents in it.
|
|
40
|
+
*/
|
|
41
|
+
exports.WORKER_ERROR_MESSAGE_TYPE = 'hydranium/worker-error';
|
|
42
|
+
/** The phase a failed bootstrap reports under; no head answers after it. */
|
|
43
|
+
exports.WORKER_BOOTSTRAP_PHASE = 'bootstrap';
|
|
44
|
+
function isWorkerErrorMessage(value) {
|
|
45
|
+
if (typeof value !== 'object' || value === null) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const candidate = value;
|
|
49
|
+
return candidate.type === exports.WORKER_ERROR_MESSAGE_TYPE && typeof candidate.phase === 'string' && typeof candidate.message === 'string';
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=worker-handshake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-handshake.js","sourceRoot":"","sources":["../../src/client/worker-handshake.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;AAyBlF,gFAAgF;AACnE,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAenE,kCAAyC,KAAc;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAwC,CAAC;IAC3D,OAAO,SAAS,CAAC,IAAI,KAAK,QAAA,6BAA6B,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACU,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAqB3D,8BAAqC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAqC,CAAC,IAAI,KAAK,QAAA,yBAAyB,CAAC;AACnI,CAAC;AAED;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,wBAAwB,CAAC;AAElE,4EAA4E;AAC/D,QAAA,sBAAsB,GAAG,WAAW,CAAC;AASlD,8BAAqC,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAoC,CAAC;IACvD,OAAO,SAAS,CAAC,IAAI,KAAK,QAAA,yBAAyB,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC;AACvI,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Well-known values of the wire's `clientId` / `sourceClientId` field.
|
|
11
|
+
*
|
|
12
|
+
* The framework tracks each document as belonging to one or more "clients" —
|
|
13
|
+
* typically an LSP-text client (Monaco, VS Code, …), a GLSP diagram client,
|
|
14
|
+
* and/or a structured-form client — and keys its holds and watches per
|
|
15
|
+
* `(uri, clientId)`. These three values are not real participants, so a client
|
|
16
|
+
* minting its own id must avoid them.
|
|
17
|
+
*
|
|
18
|
+
* **Here rather than in the server package, because the side that has to
|
|
19
|
+
* RECOGNISE them is the client.** An inbound `onDocumentUpdated` carries
|
|
20
|
+
* `sourceClientId`, and a consumer deciding what to do with it is asking which
|
|
21
|
+
* of these it is — so a frontend would otherwise have to depend on the server
|
|
22
|
+
* tier to name three strings, and in practice retypes the literal instead.
|
|
23
|
+
*/
|
|
24
|
+
/** Identifier for an LSP-text client (Monaco, VS Code, …). */
|
|
25
|
+
export declare const LANGUAGE_CLIENT_ID = "language-client";
|
|
26
|
+
/**
|
|
27
|
+
* The id an event names when no single client is behind it: the source of a
|
|
28
|
+
* `'rebuilt'` event, a document no client authored, or a build with more than
|
|
29
|
+
* one cause.
|
|
30
|
+
*/
|
|
31
|
+
export declare const UNKNOWN_CLIENT_ID = "unknown";
|
|
32
|
+
/**
|
|
33
|
+
* Synthetic author id on the `onDocumentUpdated` broadcast a data-server
|
|
34
|
+
* emits for the build that follows a document's release, once no client holds
|
|
35
|
+
* it; by default that build reverts the document to its disk content,
|
|
36
|
+
* discarding unsaved edits. Not a real client: it lets consumers tell the
|
|
37
|
+
* release broadcast from client-authored updates.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DOCUMENT_RELEASE_CLIENT_ID = "document-release";
|
|
40
|
+
/**
|
|
41
|
+
* Every id the framework reserves, for a client checking that the identity it
|
|
42
|
+
* is about to mint collides with none of them.
|
|
43
|
+
*/
|
|
44
|
+
export declare const FRAMEWORK_CLIENT_IDS: readonly string[];
|
|
45
|
+
//# sourceMappingURL=client-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-ids.d.ts","sourceRoot":"","sources":["../src/client-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAwE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.FRAMEWORK_CLIENT_IDS = exports.DOCUMENT_RELEASE_CLIENT_ID = exports.UNKNOWN_CLIENT_ID = exports.LANGUAGE_CLIENT_ID = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Well-known values of the wire's `clientId` / `sourceClientId` field.
|
|
14
|
+
*
|
|
15
|
+
* The framework tracks each document as belonging to one or more "clients" —
|
|
16
|
+
* typically an LSP-text client (Monaco, VS Code, …), a GLSP diagram client,
|
|
17
|
+
* and/or a structured-form client — and keys its holds and watches per
|
|
18
|
+
* `(uri, clientId)`. These three values are not real participants, so a client
|
|
19
|
+
* minting its own id must avoid them.
|
|
20
|
+
*
|
|
21
|
+
* **Here rather than in the server package, because the side that has to
|
|
22
|
+
* RECOGNISE them is the client.** An inbound `onDocumentUpdated` carries
|
|
23
|
+
* `sourceClientId`, and a consumer deciding what to do with it is asking which
|
|
24
|
+
* of these it is — so a frontend would otherwise have to depend on the server
|
|
25
|
+
* tier to name three strings, and in practice retypes the literal instead.
|
|
26
|
+
*/
|
|
27
|
+
/** Identifier for an LSP-text client (Monaco, VS Code, …). */
|
|
28
|
+
exports.LANGUAGE_CLIENT_ID = 'language-client';
|
|
29
|
+
/**
|
|
30
|
+
* The id an event names when no single client is behind it: the source of a
|
|
31
|
+
* `'rebuilt'` event, a document no client authored, or a build with more than
|
|
32
|
+
* one cause.
|
|
33
|
+
*/
|
|
34
|
+
exports.UNKNOWN_CLIENT_ID = 'unknown';
|
|
35
|
+
/**
|
|
36
|
+
* Synthetic author id on the `onDocumentUpdated` broadcast a data-server
|
|
37
|
+
* emits for the build that follows a document's release, once no client holds
|
|
38
|
+
* it; by default that build reverts the document to its disk content,
|
|
39
|
+
* discarding unsaved edits. Not a real client: it lets consumers tell the
|
|
40
|
+
* release broadcast from client-authored updates.
|
|
41
|
+
*/
|
|
42
|
+
exports.DOCUMENT_RELEASE_CLIENT_ID = 'document-release';
|
|
43
|
+
/**
|
|
44
|
+
* Every id the framework reserves, for a client checking that the identity it
|
|
45
|
+
* is about to mint collides with none of them.
|
|
46
|
+
*/
|
|
47
|
+
exports.FRAMEWORK_CLIENT_IDS = [exports.LANGUAGE_CLIENT_ID, exports.UNKNOWN_CLIENT_ID, exports.DOCUMENT_RELEASE_CLIENT_ID];
|
|
48
|
+
//# sourceMappingURL=client-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-ids.js","sourceRoot":"","sources":["../src/client-ids.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,8DAA8D;AACjD,QAAA,kBAAkB,GAAG,iBAAiB,CAAC;AAEpD;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C;;;;;;GAMG;AACU,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;GAGG;AACU,QAAA,oBAAoB,GAAsB,CAAC,QAAA,kBAAkB,EAAE,QAAA,iBAAiB,EAAE,QAAA,0BAA0B,CAAC,CAAC"}
|