@hydranium/protocol 1.0.0-next.39 → 1.0.0-next.391
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 +46 -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 +11 -2
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +13 -1
- 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 +762 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1253 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +16 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +16 -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/working-copy.d.ts +420 -0
- package/lib/client/working-copy.d.ts.map +1 -0
- package/lib/client/working-copy.js +958 -0
- package/lib/client/working-copy.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 +7 -0
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +160 -50
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +75 -31
- 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 +241 -48
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +395 -60
- 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 +58 -11
- 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 +33 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +48 -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 +36 -11
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +47 -9
- 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/harness.d.ts +9 -0
- package/lib/testing/harness.d.ts.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 +2 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +3 -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/node/unhandled-rejections.d.ts +20 -0
- package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
- package/lib/testing/node/unhandled-rejections.js +35 -0
- package/lib/testing/node/unhandled-rejections.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 +108 -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 +15 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1606 -137
- package/src/client/index.ts +16 -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/working-copy.ts +1116 -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 +8 -1
- package/src/data/data-server-protocol.ts +184 -49
- package/src/data/events.ts +77 -31
- package/src/data/requests.ts +90 -11
- package/src/debouncer.ts +11 -11
- package/src/errors.ts +496 -71
- 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 +62 -17
- 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 +48 -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 +119 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/harness.ts +10 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +3 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/testing/node/unhandled-rejections.ts +31 -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 +130 -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
|
@@ -8,47 +8,123 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { TransferDiagnostic } from './transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from './transfer-element';
|
|
11
|
+
import { type ModelVersion, type TextVersion } from './model-service/base-version';
|
|
12
|
+
/** The model a data server built for a document, encoded for the wire. */
|
|
13
|
+
export interface TransferModelSnapshot<TRoot extends TransferElement, TDiagnostic = TransferDiagnostic> {
|
|
14
|
+
root: TRoot;
|
|
15
|
+
/** Absent until the document is validated; `[]` once it is and nothing was found. */
|
|
16
|
+
diagnostics?: TDiagnostic[];
|
|
17
|
+
/**
|
|
18
|
+
* The version of the text `root` was parsed from. A caller that mutates the
|
|
19
|
+
* model sends this back as the `baseVersion` of its write, and the server
|
|
20
|
+
* rejects the write with `ConflictError` once its text has moved past it.
|
|
21
|
+
*/
|
|
22
|
+
version: ModelVersion;
|
|
23
|
+
/**
|
|
24
|
+
* The data server's fingerprint of `root` and `diagnostics`, or under its
|
|
25
|
+
* `'text-diagnostics'` strategy of the text `root` was parsed from and
|
|
26
|
+
* `diagnostics`.
|
|
27
|
+
* Independent of `version`; an equal hash also means equally validated.
|
|
28
|
+
*/
|
|
29
|
+
hash: string;
|
|
30
|
+
}
|
|
31
|
+
/** The text a data server held for a document when it sent it. */
|
|
32
|
+
export interface TextState {
|
|
33
|
+
/**
|
|
34
|
+
* The server's version of that text. A `TransferModelSnapshot.version` below it
|
|
35
|
+
* means the model was parsed from older text, and an update at this version
|
|
36
|
+
* or a later one follows.
|
|
37
|
+
*/
|
|
38
|
+
version: TextVersion;
|
|
39
|
+
/**
|
|
40
|
+
* What `textHash` makes of the text alone: equal texts hash equal whatever
|
|
41
|
+
* their version or dirty state, across a revert or a server restart that
|
|
42
|
+
* numbers versions afresh.
|
|
43
|
+
*/
|
|
44
|
+
hash: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the text differs from the file, as the server last knew the file.
|
|
47
|
+
* A later change arrives as `onDocumentDirtyChanged` to a client watching
|
|
48
|
+
* the document.
|
|
49
|
+
*/
|
|
50
|
+
dirty: boolean;
|
|
51
|
+
}
|
|
11
52
|
/**
|
|
12
53
|
* Wire envelope exchanged between the model-server's data-server head and
|
|
13
|
-
* its clients
|
|
14
|
-
*
|
|
54
|
+
* its clients: the server's model of a document and the text it holds for it,
|
|
55
|
+
* each absent where the server has none.
|
|
15
56
|
*
|
|
16
57
|
* The constraint `TTransfer extends TransferElement` pins the type system
|
|
17
58
|
* to the wire data shape (no `$container` cycles, references as strings;
|
|
18
|
-
* see {@link TransferElement}).
|
|
19
|
-
* `AstDocument<TAst extends AstNode, TDiagnostic>` in
|
|
20
|
-
* `@hydranium/core` — same structural shape, different generic
|
|
21
|
-
* constraint, used at the AST layer before the `TransferEncoder`
|
|
22
|
-
* translation produces a {@link TransferDocument}.
|
|
59
|
+
* see {@link TransferElement}).
|
|
23
60
|
*/
|
|
24
61
|
export interface TransferDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> {
|
|
62
|
+
/** Need not be spelled as the request named it. */
|
|
25
63
|
uri: string;
|
|
26
64
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* (or `TransferSaveArgs.baseVersion`) so the server can detect stale-based
|
|
31
|
-
* updates and reject them with `ConflictError`.
|
|
32
|
-
*
|
|
33
|
-
* See `@hydranium/protocol#errors` for the conflict-detection contract.
|
|
65
|
+
* Absent when the document does not exist: the server answers an unknown
|
|
66
|
+
* URI with a shaped envelope rather than an error, so absence is an
|
|
67
|
+
* ordinary branch and not a catch.
|
|
34
68
|
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
* with a shaped envelope rather than an error, so absence is an ordinary
|
|
39
|
-
* branch and not a catch. Declared required it reads as a guarantee, and
|
|
40
|
-
* every `root.x` compiles into a throw.
|
|
41
|
-
*/
|
|
42
|
-
root?: TTransfer;
|
|
43
|
-
diagnostics: TDiagnostic[];
|
|
69
|
+
model?: TransferModelSnapshot<TTransfer, TDiagnostic>;
|
|
70
|
+
/** Absent when the server holds no text for the document. */
|
|
71
|
+
text?: TextState;
|
|
44
72
|
}
|
|
45
73
|
/**
|
|
46
|
-
* A {@link TransferDocument} the server actually had, so `
|
|
74
|
+
* A {@link TransferDocument} the server actually had, so `model` is present.
|
|
47
75
|
* Narrowed to by {@link TransferDocument.isLoaded} / {@link TransferDocument.assertLoaded}.
|
|
48
76
|
*/
|
|
49
77
|
export type LoadedTransferDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
50
|
-
|
|
78
|
+
model: TransferModelSnapshot<TTransfer, TDiagnostic>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* What a save or a persist answers: the document, and in `persisted` the
|
|
82
|
+
* version of the text it wrote to the file. That can differ from
|
|
83
|
+
* `model.version` either way, since writes land between the build and the
|
|
84
|
+
* take, so a client marking a version saved takes it from here.
|
|
85
|
+
*/
|
|
86
|
+
export type TransferSavedDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
87
|
+
persisted: {
|
|
88
|
+
version: TextVersion;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* What an update answers: the document, and in `written` the version its text
|
|
93
|
+
* took. A `model.version` past it means the document was built from a later
|
|
94
|
+
* text, which holds a later write or an integrity repair too. A text
|
|
95
|
+
* version, not a model version, because the server may have normalized the
|
|
96
|
+
* text, so the writer does not hold the text at that version.
|
|
97
|
+
*/
|
|
98
|
+
export type TransferWrittenDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
99
|
+
written: {
|
|
100
|
+
version: TextVersion;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* What a create answers: the document as a read after the create finds it,
|
|
105
|
+
* and in `created` the version the create's text took. Another client's write
|
|
106
|
+
* or an integrity repair can land between the create and that read, so
|
|
107
|
+
* `model.version` can be past it, and a write based on it would carry that
|
|
108
|
+
* text as the creator's; a write based on `created.version` conflicts instead.
|
|
109
|
+
* A model version, not a text version, because the creator holds the text at
|
|
110
|
+
* that version: it sent it.
|
|
111
|
+
*/
|
|
112
|
+
export type TransferCreatedDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
113
|
+
created: {
|
|
114
|
+
version: ModelVersion;
|
|
115
|
+
};
|
|
51
116
|
};
|
|
117
|
+
/** What a watch answers, once it is in place. */
|
|
118
|
+
export interface TransferWatchedDocument {
|
|
119
|
+
/** The key the watch's events name the document by, which need not be the spelling the watch was asked with. */
|
|
120
|
+
readonly uri: string;
|
|
121
|
+
/** Whether a document exists there; one the server fails to load counts, only a missing one does not. */
|
|
122
|
+
readonly exists: boolean;
|
|
123
|
+
/** The position of the last update or deletion event sent before `exists` was taken; an event past it was sent after. */
|
|
124
|
+
readonly sequence: number;
|
|
125
|
+
/** The text the server held when `exists` was taken, as a read answers it; absent when it held none. */
|
|
126
|
+
readonly text?: TextState;
|
|
127
|
+
}
|
|
52
128
|
export declare namespace TransferDocument {
|
|
53
129
|
/**
|
|
54
130
|
* Whether the server had this document. Branch on it where absence is an
|
|
@@ -56,18 +132,18 @@ export declare namespace TransferDocument {
|
|
|
56
132
|
*/
|
|
57
133
|
function isLoaded<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(document: TransferDocument<TTransfer, TDiagnostic>): document is LoadedTransferDocument<TTransfer, TDiagnostic>;
|
|
58
134
|
/**
|
|
59
|
-
* The same document with `
|
|
135
|
+
* The same document with `model` no longer optional, or a throw. For call
|
|
60
136
|
* sites where absence is a bug rather than a branch; the whole envelope is
|
|
61
|
-
* returned because a caller needing `
|
|
137
|
+
* returned because a caller needing `model` usually needs `uri` or `text`
|
|
62
138
|
* with it.
|
|
63
139
|
*/
|
|
64
140
|
function assertLoaded<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(document: TransferDocument<TTransfer, TDiagnostic>): LoadedTransferDocument<TTransfer, TDiagnostic>;
|
|
141
|
+
/** The envelope for a document the server does not have. */
|
|
142
|
+
function absent<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string): TransferDocument<TTransfer, TDiagnostic>;
|
|
65
143
|
/**
|
|
66
|
-
* Construct a {@link TransferDocument} envelope
|
|
67
|
-
*
|
|
68
|
-
* "no diagnostics yet" code paths don't need to repeat the empty array
|
|
69
|
-
* at every call site.
|
|
144
|
+
* Construct a {@link TransferDocument} envelope with a model, its version
|
|
145
|
+
* marked as coming from a read. `diagnostics` absent means not validated.
|
|
70
146
|
*/
|
|
71
|
-
function create<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string, version: number, root: TTransfer, diagnostics?: TDiagnostic[]): TransferDocument<TTransfer, TDiagnostic>;
|
|
147
|
+
function create<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string, version: number, root: TTransfer, hash: string, diagnostics?: TDiagnostic[], text?: TextState): TransferDocument<TTransfer, TDiagnostic>;
|
|
72
148
|
}
|
|
73
149
|
//# sourceMappingURL=transfer-document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-document.d.ts","sourceRoot":"","sources":["../src/transfer-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"transfer-document.d.ts","sourceRoot":"","sources":["../src/transfer-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEnG,0EAA0E;AAC1E,MAAM,WAAW,qBAAqB,CAAC,KAAK,SAAS,eAAe,EAAE,WAAW,GAAG,kBAAkB;IACnG,IAAI,EAAE,KAAK,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,MAAM,EACf,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,WAAW,EAAE,EAC3B,IAAI,CAAC,EAAE,SAAS,GAChB,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAM1C;CACH"}
|
package/lib/transfer-document.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.TransferDocument = void 0;
|
|
12
|
+
const base_version_1 = require("./model-service/base-version");
|
|
12
13
|
var TransferDocument;
|
|
13
14
|
(function (TransferDocument) {
|
|
14
15
|
/**
|
|
@@ -16,13 +17,13 @@ var TransferDocument;
|
|
|
16
17
|
* ordinary state — a view bound to a file that may not exist yet.
|
|
17
18
|
*/
|
|
18
19
|
function isLoaded(document) {
|
|
19
|
-
return document.
|
|
20
|
+
return document.model !== undefined;
|
|
20
21
|
}
|
|
21
22
|
TransferDocument.isLoaded = isLoaded;
|
|
22
23
|
/**
|
|
23
|
-
* The same document with `
|
|
24
|
+
* The same document with `model` no longer optional, or a throw. For call
|
|
24
25
|
* sites where absence is a bug rather than a branch; the whole envelope is
|
|
25
|
-
* returned because a caller needing `
|
|
26
|
+
* returned because a caller needing `model` usually needs `uri` or `text`
|
|
26
27
|
* with it.
|
|
27
28
|
*/
|
|
28
29
|
function assertLoaded(document) {
|
|
@@ -32,14 +33,21 @@ var TransferDocument;
|
|
|
32
33
|
return document;
|
|
33
34
|
}
|
|
34
35
|
TransferDocument.assertLoaded = assertLoaded;
|
|
36
|
+
/** The envelope for a document the server does not have. */
|
|
37
|
+
function absent(uri) {
|
|
38
|
+
return { uri };
|
|
39
|
+
}
|
|
40
|
+
TransferDocument.absent = absent;
|
|
35
41
|
/**
|
|
36
|
-
* Construct a {@link TransferDocument} envelope
|
|
37
|
-
*
|
|
38
|
-
* "no diagnostics yet" code paths don't need to repeat the empty array
|
|
39
|
-
* at every call site.
|
|
42
|
+
* Construct a {@link TransferDocument} envelope with a model, its version
|
|
43
|
+
* marked as coming from a read. `diagnostics` absent means not validated.
|
|
40
44
|
*/
|
|
41
|
-
function create(uri, version, root, diagnostics
|
|
42
|
-
return {
|
|
45
|
+
function create(uri, version, root, hash, diagnostics, text) {
|
|
46
|
+
return {
|
|
47
|
+
uri,
|
|
48
|
+
model: { root, version: (0, base_version_1.asModelVersion)(version), hash, ...(diagnostics === undefined ? {} : { diagnostics }) },
|
|
49
|
+
...(text === undefined ? {} : { text })
|
|
50
|
+
};
|
|
43
51
|
}
|
|
44
52
|
TransferDocument.create = create;
|
|
45
53
|
})(TransferDocument || (exports.TransferDocument = TransferDocument = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-document.js","sourceRoot":"","sources":["../src/transfer-document.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"transfer-document.js","sourceRoot":"","sources":["../src/transfer-document.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAIlF,+DAAmG;AAoInG,IAAiB,gBAAgB,CAmDhC;AAnDD,WAAiB,gBAAgB;IAC9B;;;OAGG;IACH,SAAgB,QAAQ,CACrB,QAAkD;QAElD,OAAO,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC;IACvC,CAAC;IAJe,iBAAA,QAAQ,WAIvB,CAAA;IAED;;;;;OAKG;IACH,SAAgB,YAAY,CACzB,QAAkD;QAElD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,QAAQ,CAAC;IACnB,CAAC;IAPe,iBAAA,YAAY,eAO3B,CAAA;IAED,4DAA4D;IAC5D,SAAgB,MAAM,CACnB,GAAW;QAEX,OAAO,EAAE,GAAG,EAAE,CAAC;IAClB,CAAC;IAJe,iBAAA,MAAM,SAIrB,CAAA;IAED;;;OAGG;IACH,SAAgB,MAAM,CACnB,GAAW,EACX,OAAe,EACf,IAAe,EACf,IAAY,EACZ,WAA2B,EAC3B,IAAgB;QAEhB,OAAO;YACJ,GAAG;YACH,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAA,6BAAc,EAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;YAC9G,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;SACzC,CAAC;IACL,CAAC;IAbe,iBAAA,MAAM,SAarB,CAAA;AACJ,CAAC,EAnDgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAmDhC"}
|
|
@@ -26,10 +26,10 @@ export interface TransferElement {
|
|
|
26
26
|
* declared wire shape — or fall back to the structural base
|
|
27
27
|
* {@link TransferElement} when no entry is declared.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* `TransferElement` — the framework default behaves
|
|
32
|
-
* overlay (no autocomplete, but no compile error either).
|
|
29
|
+
* The transfer-model generator emits the overlay as `<LanguageId>TransferTypes`;
|
|
30
|
+
* an encoder that relabels a type overrides that entry. Types not in the
|
|
31
|
+
* overlay resolve to `TransferElement` — the framework default behaves
|
|
32
|
+
* correctly without an overlay (no autocomplete, but no compile error either).
|
|
33
33
|
*
|
|
34
34
|
* The lookup is compile-time only; no runtime cost.
|
|
35
35
|
*/
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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 keys of a type map, Langium's `<LanguageName>AstType` or the generated
|
|
11
|
+
* `<LanguageId>TransferTypes`, that a node can carry as its `$type`: those
|
|
12
|
+
* listed in their own type's `$type`. A union, or an abstract type whose
|
|
13
|
+
* `$type` names only its subtypes, has a constant too, but building one would
|
|
14
|
+
* yield a node that no guard accepts. A concrete type with subtypes lists its
|
|
15
|
+
* own name beside theirs, as Langium writes it, and stays buildable.
|
|
16
|
+
*/
|
|
17
|
+
export type ConcreteTypeName<TMap> = {
|
|
18
|
+
[K in keyof TMap]: K extends (TMap[K] extends {
|
|
19
|
+
readonly $type: infer TType;
|
|
20
|
+
} ? TType : never) ? K : never;
|
|
21
|
+
}[keyof TMap] & string;
|
|
22
|
+
type IsUnion<T, TAll = T> = T extends unknown ? ([TAll] extends [T] ? false : true) : never;
|
|
23
|
+
/**
|
|
24
|
+
* Intersected onto a builder's type-constant parameter, refuses a constant
|
|
25
|
+
* typed by a union of type names: the init would hold only the members' common
|
|
26
|
+
* fields, so either type could be built incomplete.
|
|
27
|
+
*/
|
|
28
|
+
export type SingleTypeName<TType> = true extends IsUnion<TType> ? {
|
|
29
|
+
readonly $type: never;
|
|
30
|
+
} : unknown;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,CAAC,IAAI,IAAI;KACjC,CAAC,IAAI,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,KAAK,CAAA;KAAE,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK;CAC5G,CAAC,MAAM,IAAI,CAAC,GACV,MAAM,CAAC;AAEV,KAAK,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,IAAI,SAAS,OAAO,CAAC,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,OAAO,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2026
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
4
|
*
|
|
5
5
|
* This program and the accompanying materials are made available under the
|
|
6
6
|
* terms of the MIT License which is available in the project root.
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF"}
|
package/lib/uri.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../src/uri.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC;AAEzE,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../src/uri.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC;AAEzE,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,YAAqC,CAAC;AAErF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,iBAA+C,CAAC"}
|
package/lib/uri.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../src/uri.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAuClF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,EAAgB,EAAE,CAAC,KAAqB,CAAC;AAAxE,QAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../src/uri.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAuClF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,EAAgB,EAAE,CAAC,KAAqB,CAAC;AAAxE,QAAA,cAAc,GAAd,cAAc,CAA0D;AAErF;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAqB,EAAE,CAAC,KAA0B,CAAC;AAAvF,QAAA,mBAAmB,GAAnB,mBAAmB,CAAoE"}
|
package/lib/util.d.ts
CHANGED
|
@@ -102,8 +102,6 @@ export type Mutable<T> = {
|
|
|
102
102
|
};
|
|
103
103
|
/** Returns the same value typed as a {@link Mutable}. Compile-time only. */
|
|
104
104
|
export declare function asMutable<T>(item: T): Mutable<T>;
|
|
105
|
-
/** Type-guard variant: narrows `item` to `Mutable<T> | undefined` if `guard` accepts it. */
|
|
106
|
-
export declare function toMutable<T>(item: unknown, guard: TypeGuard<T>): item is Mutable<T> | undefined;
|
|
107
105
|
/**
|
|
108
106
|
* Wrap `text` in `quoteChar`, escaping interior occurrences with `replaceChar`.
|
|
109
107
|
*
|
|
@@ -144,4 +142,12 @@ export declare function unreachable(input: never): never;
|
|
|
144
142
|
* uncertain, then narrow with a type-guard.
|
|
145
143
|
*/
|
|
146
144
|
export declare function getAt<T = unknown>(obj: unknown, path: string[]): T | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* A stable, non-cryptographic digest of `text`, equal on every host for equal
|
|
147
|
+
* text: the `TextState.hash` a data server stamps, so a client can
|
|
148
|
+
* hash text of its own to compare. An array is read as its elements joined, so
|
|
149
|
+
* a large text is hashed in parts without concatenating it. It tells whether a
|
|
150
|
+
* text changed, not who could forge one.
|
|
151
|
+
*/
|
|
152
|
+
export declare function textHash(text: string | readonly string[]): string;
|
|
147
153
|
//# sourceMappingURL=util.d.ts.map
|
package/lib/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,qCAAqC;AACrC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACxB,OAAO,IAAI,IAAI,CAAC;CAClB;AAED,yBAAiB,UA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E,GAAG,MAAM,CAAC;AAC/E,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC;AAWjH,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAS9E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAGjE"}
|
package/lib/util.js
CHANGED
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.Deferred = exports.DisposableCollection = exports.Disposable = void 0;
|
|
12
12
|
exports.isPromiseLike = isPromiseLike;
|
|
13
13
|
exports.asMutable = asMutable;
|
|
14
|
-
exports.toMutable = toMutable;
|
|
15
14
|
exports.quote = quote;
|
|
16
15
|
exports.unquote = unquote;
|
|
17
16
|
exports.toPascal = toPascal;
|
|
@@ -20,6 +19,7 @@ exports.identity = identity;
|
|
|
20
19
|
exports.findNextUnique = findNextUnique;
|
|
21
20
|
exports.unreachable = unreachable;
|
|
22
21
|
exports.getAt = getAt;
|
|
22
|
+
exports.textHash = textHash;
|
|
23
23
|
var Disposable;
|
|
24
24
|
(function (Disposable) {
|
|
25
25
|
function create(dispose) {
|
|
@@ -122,9 +122,6 @@ function isPromiseLike(value) {
|
|
|
122
122
|
function asMutable(item) {
|
|
123
123
|
return item;
|
|
124
124
|
}
|
|
125
|
-
function toMutable(item, guard) {
|
|
126
|
-
return guard ? guard(item) : true;
|
|
127
|
-
}
|
|
128
125
|
/**
|
|
129
126
|
* Wrap `text` in `quoteChar`, escaping interior occurrences with `replaceChar`.
|
|
130
127
|
*
|
|
@@ -208,4 +205,35 @@ function getAt(obj, path) {
|
|
|
208
205
|
}
|
|
209
206
|
return cur;
|
|
210
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* A stable, non-cryptographic digest of `text`, equal on every host for equal
|
|
210
|
+
* text: the `TextState.hash` a data server stamps, so a client can
|
|
211
|
+
* hash text of its own to compare. An array is read as its elements joined, so
|
|
212
|
+
* a large text is hashed in parts without concatenating it. It tells whether a
|
|
213
|
+
* text changed, not who could forge one.
|
|
214
|
+
*/
|
|
215
|
+
function textHash(text) {
|
|
216
|
+
const { high, low } = cyrb53(typeof text === 'string' ? [text] : text);
|
|
217
|
+
return high.toString(16).padStart(8, '0') + low.toString(16).padStart(8, '0');
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The two 32-bit words cyrb53 ends on, each unsigned, for `parts` read as one
|
|
221
|
+
* string. It needs no `node:*` module, so every host runs it.
|
|
222
|
+
*/
|
|
223
|
+
function cyrb53(parts) {
|
|
224
|
+
let h1 = 0xdeadbeef;
|
|
225
|
+
let h2 = 0x41c6ce57;
|
|
226
|
+
for (const part of parts) {
|
|
227
|
+
for (let i = 0; i < part.length; i++) {
|
|
228
|
+
const code = part.charCodeAt(i);
|
|
229
|
+
h1 = Math.imul(h1 ^ code, 2654435761);
|
|
230
|
+
h2 = Math.imul(h2 ^ code, 1597334677);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
234
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
235
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
236
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
237
|
+
return { high: h2 >>> 0, low: h1 >>> 0 };
|
|
238
|
+
}
|
|
211
239
|
//# sourceMappingURL=util.js.map
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;AAmBlF,IAAiB,UAAU,CAY1B;AAZD,WAAiB,UAAU;IACxB,SAAgB,MAAM,CAAC,OAAmB;QACvC,OAAO,EAAE,OAAO,EAAE,CAAC;IACtB,CAAC;IAFe,WAAA,MAAM,SAErB,CAAA;IACD;;;;;;OAMG;IACU,gBAAK,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;AAChF,CAAC,EAZgB,UAAU,aAAV,UAAU,GAAV,UAAU,QAY1B;AAED;;;;;;;;;;;;;;;GAeG;AACH;IACsB,WAAW,GAAiB,EAAE,CAAC;IACxC,SAAS,GAAG,KAAK,CAAC;IAE5B,IAAI,QAAQ;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,UAAsB;QACxB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACL,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,UAAU,CAAC;IACrB,CAAC;IAED,OAAO;QACJ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,OAAO;QACV,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC;gBACF,IAAI,CAAC,WAAW,CAAC,GAAG,EAAG,CAAC,OAAO,EAAE,CAAC;YAC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;QACzC,CAAC;IACJ,CAAC;IACD,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7C,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9C,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7C,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/protocol",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.391",
|
|
4
4
|
"description": "Generic, language-agnostic types, constants, and pure utilities for the hydranium framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hydranium",
|
|
@@ -14,16 +14,23 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/eclipse-emfcloud/hydranium/issues"
|
|
16
16
|
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Hydranium Team"
|
|
20
|
+
},
|
|
17
21
|
"repository": {
|
|
18
22
|
"type": "git",
|
|
19
23
|
"url": "https://github.com/eclipse-emfcloud/hydranium.git",
|
|
20
24
|
"directory": "packages/protocol"
|
|
21
25
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
+
"files": [
|
|
27
|
+
"lib",
|
|
28
|
+
"src",
|
|
29
|
+
"!lib/**/*.tsbuildinfo"
|
|
30
|
+
],
|
|
26
31
|
"sideEffects": false,
|
|
32
|
+
"main": "lib/index.js",
|
|
33
|
+
"types": "lib/index.d.ts",
|
|
27
34
|
"exports": {
|
|
28
35
|
".": {
|
|
29
36
|
"types": "./lib/index.d.ts",
|
|
@@ -33,10 +40,6 @@
|
|
|
33
40
|
"types": "./lib/client/index.d.ts",
|
|
34
41
|
"default": "./lib/client/index.js"
|
|
35
42
|
},
|
|
36
|
-
"./lib/client": {
|
|
37
|
-
"types": "./lib/client/index.d.ts",
|
|
38
|
-
"default": "./lib/client/index.js"
|
|
39
|
-
},
|
|
40
43
|
"./data": {
|
|
41
44
|
"types": "./lib/data/index.d.ts",
|
|
42
45
|
"default": "./lib/data/index.js"
|
|
@@ -45,9 +48,9 @@
|
|
|
45
48
|
"types": "./lib/messages/index.d.ts",
|
|
46
49
|
"default": "./lib/messages/index.js"
|
|
47
50
|
},
|
|
48
|
-
"./
|
|
49
|
-
"types": "./lib/
|
|
50
|
-
"default": "./lib/
|
|
51
|
+
"./node": {
|
|
52
|
+
"types": "./lib/node/index.d.ts",
|
|
53
|
+
"default": "./lib/node/index.js"
|
|
51
54
|
},
|
|
52
55
|
"./testing": {
|
|
53
56
|
"types": "./lib/testing/index.d.ts",
|
|
@@ -56,31 +59,15 @@
|
|
|
56
59
|
"./testing/node": {
|
|
57
60
|
"types": "./lib/testing/node/index.d.ts",
|
|
58
61
|
"default": "./lib/testing/node/index.js"
|
|
59
|
-
},
|
|
60
|
-
"./lib/data": {
|
|
61
|
-
"types": "./lib/data/index.d.ts",
|
|
62
|
-
"default": "./lib/data/index.js"
|
|
63
|
-
},
|
|
64
|
-
"./lib/testing": {
|
|
65
|
-
"types": "./lib/testing/index.d.ts",
|
|
66
|
-
"default": "./lib/testing/index.js"
|
|
67
|
-
},
|
|
68
|
-
"./lib/testing/node": {
|
|
69
|
-
"types": "./lib/testing/node/index.d.ts",
|
|
70
|
-
"default": "./lib/testing/node/index.js"
|
|
71
62
|
}
|
|
72
63
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"lib",
|
|
77
|
-
"src",
|
|
78
|
-
"!lib/**/*.tsbuildinfo"
|
|
79
|
-
],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
80
67
|
"scripts": {
|
|
81
68
|
"build": "tsc -b",
|
|
82
69
|
"clean": "rimraf lib tsconfig.tsbuildinfo",
|
|
83
|
-
"lint": "
|
|
70
|
+
"lint": "oxlint --format stylish --config ../../oxlint.config.cjs src test --max-warnings 0",
|
|
84
71
|
"prepack": "node -e \"const m=require('./package.json'),fs=require('node:fs');const missing=[m.main,...Object.values(m.bin||{})].filter(entry=>entry&&!fs.existsSync(entry));if(missing.length){console.error('prepack '+m.name+': not built ('+missing.join(', ')+' missing). Run the build before packing: a files entry that matches nothing is skipped silently, so the tarball would ship src only.');process.exit(1);}\"",
|
|
85
72
|
"test": "npm run typecheck:test && vitest run",
|
|
86
73
|
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
@@ -92,18 +79,15 @@
|
|
|
92
79
|
"devDependencies": {
|
|
93
80
|
"fast-check": "^3.23.2",
|
|
94
81
|
"rimraf": "^5.0.0",
|
|
95
|
-
"typescript": "^
|
|
96
|
-
"vscode-jsonrpc": "9.0.
|
|
82
|
+
"typescript": "^7.0.2",
|
|
83
|
+
"vscode-jsonrpc": "9.0.0"
|
|
97
84
|
},
|
|
98
85
|
"peerDependencies": {
|
|
99
|
-
"vscode-jsonrpc": "9.0.
|
|
86
|
+
"vscode-jsonrpc": "^9.0.0"
|
|
100
87
|
},
|
|
101
88
|
"engines": {
|
|
102
89
|
"node": ">=22.13"
|
|
103
90
|
},
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
"//peerDependencies": "`vscode-jsonrpc` is EXACT rather than a range, because it is one link of an atomic chain with no independently movable link: `vscode-languageserver-protocol` depends on it at exactly 9.0.1, so any other value an adopter supplies is a SECOND physical copy rather than an upgrade. This wire stack breaks on copy identity rather than on structure — `ParameterStructures.auto` is a singleton compared by `===` in connection.js, so a request type built by one copy and sent over a connection owned by the other throws `Unknown parameter structure auto`. A caret or union range was rejected because npm then resolves a `vscode-jsonrpc@8.2.0` tree SILENTLY, with no diagnostic at all, and the failure surfaces only later at server init. Exact does not fail the install either — npm downgrades an unsatisfiable peer to a warning — but it is a NAMED ERESOLVE warning printing the required version beside the found one, and a hard error for anyone installing with `--strict-peer-deps`. It does NOT prevent a NESTED copy — `@eclipse-glsp/*` carries its own exact `vscode-jsonrpc@8.2.0` dependency and root `overrides` do not ship — so a consumer of the GLSP head must pin the chain in its own manifest.",
|
|
108
|
-
"//prepack": "The publish guard, and it deliberately is NOT a `prepare`: npm runs a workspace `prepare` BEFORE the root `postinstall` that applies patches/vscode-jsonrpc+9.0.1.patch, so building there fails on a cold clone and npm rolls the entire install back. `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. It FAILS rather than rebuilds, because the rebuild is exactly the part that ordering defeats. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error."
|
|
91
|
+
"//peerDependencies": "`vscode-jsonrpc` takes a caret, so the framework shares the transport the LSP connection resolves, which an `init` scaffold pins: each `vscode-languageserver-protocol` release pins its transport exactly, so an exact peer would name a copy a fresh install rarely holds. The caret excludes 8.x, so a tree whose top holds GLSP's copy fails the peer with a named ERESOLVE warning, an error under `--strict-peer-deps`, rather than resolving silently. No peer reaches a NESTED copy, such as GLSP's or one the LSP packages nest. The wire compares message types and `ResponseError`s by copy identity, so the framework sends typed messages by method name and recognises errors with `isResponseError` rather than `instanceof`.",
|
|
92
|
+
"//prepack": "The publish guard, a `prepack` rather than a `prepare`: `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error."
|
|
109
93
|
}
|
package/src/abstract-logger.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { type Clock, SystemClock } from './clock';
|
|
11
|
+
import { formatLogArg } from './format-log-arg';
|
|
11
12
|
import { Format, LEVEL_LABELS, type LogLevel, Logger, type LogThreshold } from './logger';
|
|
12
13
|
|
|
13
14
|
/** Default time source for every {@link AbstractLogger}; overridable per subclass via {@link AbstractLogger.clock}. */
|
|
@@ -46,6 +47,23 @@ export abstract class AbstractLogger implements Logger {
|
|
|
46
47
|
return Format.timestamp(new Date(this.clock().now()));
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The `[Label - HH:MM:SS.mmm] [component]` prefix every sink starts a line
|
|
52
|
+
* with. The label is padded to the widest, so timestamps line up across sinks.
|
|
53
|
+
*/
|
|
54
|
+
protected formatLinePrefix(label: string): string {
|
|
55
|
+
return `[${label.padEnd(5)} - ${this.timestamp()}]${this.component ? ` [${this.component}]` : ''}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* One log argument as the text a sink appends to its line; {@link formatLogArg}
|
|
60
|
+
* by default. `ConsoleLogger` hands its arguments to the console instead.
|
|
61
|
+
* Never throws, since a log call that throws loses the line.
|
|
62
|
+
*/
|
|
63
|
+
protected formatArg(arg: unknown): string {
|
|
64
|
+
return formatLogArg(arg);
|
|
65
|
+
}
|
|
66
|
+
|
|
49
67
|
error(message?: string, ...args: unknown[]): this {
|
|
50
68
|
this.send('error', message, args);
|
|
51
69
|
return this;
|