@hydranium/protocol 1.0.0-next.18 → 1.0.0-next.180
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 +35 -1
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +157 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +236 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +25 -23
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +440 -78
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +697 -106
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +13 -8
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +13 -8
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +9 -3
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +11 -5
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +149 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +202 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/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 +11 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +111 -31
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +103 -14
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +67 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +163 -17
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +219 -22
- package/lib/errors.js.map +1 -1
- 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 +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -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.js.map +1 -1
- package/lib/messages/index.d.ts +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +58 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/based-on.d.ts +57 -0
- package/lib/model-service/based-on.d.ts.map +1 -0
- package/lib/model-service/based-on.js +37 -0
- package/lib/model-service/based-on.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/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 +28 -27
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +66 -22
- package/lib/patch-merge.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -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/wire-prefix.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +13 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +19 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- package/lib/testing/fake-clock.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +34 -5
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +14 -1
- package/lib/transfer-document.js.map +1 -1
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +27 -18
- package/src/client/data-connection.ts +314 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +26 -24
- package/src/client/data-session.ts +881 -123
- package/src/client/index.ts +13 -8
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +268 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/data/data-protocol-methods.ts +11 -3
- package/src/data/data-server-protocol.ts +132 -31
- package/src/data/events.ts +109 -14
- package/src/data/requests.ts +71 -11
- package/src/errors.ts +259 -24
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +6 -0
- package/src/latency-collector.ts +8 -3
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +63 -18
- package/src/model-service/based-on.ts +63 -0
- package/src/model-service/index.ts +4 -5
- package/src/patch-merge.ts +90 -37
- package/src/profile-session.ts +9 -4
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +42 -17
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +4 -1
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +41 -6
- package/src/util.ts +33 -0
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js +0 -11
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
package/lib/patch-merge.js
CHANGED
|
@@ -13,31 +13,32 @@ exports.augmentWithTestOps = augmentWithTestOps;
|
|
|
13
13
|
exports.reconcileByPatchReplay = reconcileByPatchReplay;
|
|
14
14
|
const fast_json_patch_1 = require("fast-json-patch");
|
|
15
15
|
/**
|
|
16
|
-
* Augment a user-intent JSON patch (computed `
|
|
16
|
+
* Augment a user-intent JSON patch (computed `base → ours`) with
|
|
17
17
|
* `test` ops so a strict `applyPatch` against freshly-fetched server state
|
|
18
18
|
* fails loudly when a foreign writer changed a path the user also changed.
|
|
19
19
|
*
|
|
20
20
|
* `fast-json-patch`'s `validateOperation: true` validates op structure and
|
|
21
21
|
* path resolvability but NOT the pre-existing value — a plain `replace` /
|
|
22
22
|
* `remove` silently overwrites whatever the foreign writer put there. For each
|
|
23
|
-
* `replace` / `remove` op we prepend a `test` op carrying the
|
|
23
|
+
* `replace` / `remove` op we prepend a `test` op carrying the base value at
|
|
24
24
|
* that path, so a same-path divergence becomes a `TEST_OPERATION_FAILED` throw.
|
|
25
25
|
* The caller treats that as a real field-level conflict (drop + refetch) rather
|
|
26
26
|
* than silently clobbering the foreign edit.
|
|
27
27
|
*
|
|
28
|
-
* `add` ops
|
|
29
|
-
* to test
|
|
28
|
+
* `add` ops get no `test` op: the path is new, so there is no base value
|
|
29
|
+
* to test. {@link reconcileByPatchReplay} checks them against theirs
|
|
30
|
+
* instead; a caller applying this patch itself does not get that check.
|
|
30
31
|
*
|
|
31
32
|
* Used behind the framework's `ConflictError` contract by every reconcile
|
|
32
33
|
* path — the GLSP recording command's undo/redo and forward-write, via
|
|
33
34
|
* {@link ReconcilingConflictResolver}, and an adopter's form-widget save — so
|
|
34
35
|
* they share one collision-detection rule.
|
|
35
36
|
*/
|
|
36
|
-
function augmentWithTestOps(
|
|
37
|
+
function augmentWithTestOps(base, userPatch) {
|
|
37
38
|
const augmented = [];
|
|
38
39
|
for (const op of userPatch) {
|
|
39
40
|
if (op.op === 'replace' || op.op === 'remove') {
|
|
40
|
-
augmented.push({ op: 'test', path: op.path, value: (0, fast_json_patch_1.getValueByPointer)(
|
|
41
|
+
augmented.push({ op: 'test', path: op.path, value: (0, fast_json_patch_1.getValueByPointer)(base, op.path) });
|
|
41
42
|
}
|
|
42
43
|
augmented.push(op);
|
|
43
44
|
}
|
|
@@ -45,36 +46,79 @@ function augmentWithTestOps(baseline, userPatch) {
|
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Shared three-way reconcile for a `ConflictError`: diff the user's intent
|
|
48
|
-
* (`
|
|
49
|
+
* (`base → ours`), refetch the server's current root (theirs), and replay the
|
|
49
50
|
* intent on top under strict, {@link augmentWithTestOps}-guarded `applyPatch`.
|
|
50
51
|
*
|
|
51
|
-
* - `no-op` — the user's root equals the
|
|
52
|
+
* - `no-op` — the user's root equals the base, so the gate fired on a
|
|
52
53
|
* benign version drift; nothing to replay (refetch is skipped).
|
|
53
54
|
* - `unavailable` — the refetch produced nothing; caller falls back.
|
|
54
55
|
* - `merged` — the foreign writer touched only paths the user did not; the
|
|
55
56
|
* merged root carries both intents.
|
|
56
|
-
* - `conflict` — a same-path divergence tripped a `test` op
|
|
57
|
-
* write and
|
|
57
|
+
* - `conflict` — a same-path divergence tripped a `test` op, or an `add`
|
|
58
|
+
* collides with one the foreign writer made; caller drops the write and
|
|
59
|
+
* surfaces `theirs`.
|
|
58
60
|
*
|
|
59
61
|
* I/O is the caller's: `refetch` supplies the current root, and applying the
|
|
60
|
-
* `merged` result (update vs save,
|
|
62
|
+
* `merged` result (update vs save, new base, UI refresh) stays at the call
|
|
61
63
|
* site so form and GLSP paths keep their own persistence semantics.
|
|
62
64
|
*/
|
|
63
|
-
async function reconcileByPatchReplay(
|
|
64
|
-
const userPatch = (0, fast_json_patch_1.compare)(
|
|
65
|
+
async function reconcileByPatchReplay(base, ours, refetch) {
|
|
66
|
+
const userPatch = (0, fast_json_patch_1.compare)(base, ours);
|
|
65
67
|
if (userPatch.length === 0) {
|
|
66
68
|
return { status: 'no-op' };
|
|
67
69
|
}
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
+
const theirs = await refetch();
|
|
71
|
+
if (!theirs) {
|
|
70
72
|
return { status: 'unavailable' };
|
|
71
73
|
}
|
|
74
|
+
if (addsCollide(base, theirs, userPatch)) {
|
|
75
|
+
return { status: 'conflict', theirs };
|
|
76
|
+
}
|
|
72
77
|
try {
|
|
73
|
-
const merged = (0, fast_json_patch_1.applyPatch)((0, fast_json_patch_1.deepClone)(
|
|
78
|
+
const merged = (0, fast_json_patch_1.applyPatch)((0, fast_json_patch_1.deepClone)(theirs), augmentWithTestOps(base, userPatch), true).newDocument;
|
|
74
79
|
return { status: 'merged', merged };
|
|
75
80
|
}
|
|
76
81
|
catch {
|
|
77
|
-
return { status: 'conflict',
|
|
82
|
+
return { status: 'conflict', theirs };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether an `add` of `userPatch` collides with one the foreign writer made:
|
|
87
|
+
* it inserts a value into an array that `theirs` holds more often than
|
|
88
|
+
* `base` did, or it adds an object key that `theirs` already holds.
|
|
89
|
+
*
|
|
90
|
+
* Replayed, the first inserts the value a second time and the second replaces
|
|
91
|
+
* the foreign value. Identical values conflict rather than being skipped:
|
|
92
|
+
* skipping drops one of two additions that merely happen to be equal.
|
|
93
|
+
*/
|
|
94
|
+
function addsCollide(base, theirs, userPatch) {
|
|
95
|
+
// Through JSON, as `compare` clones the add values: an undefined-valued key
|
|
96
|
+
// in `theirs` would otherwise make an equal element count as another.
|
|
97
|
+
const comparable = JSON.parse(JSON.stringify(theirs));
|
|
98
|
+
return userPatch.some(op => {
|
|
99
|
+
if (op.op !== 'add') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const cut = op.path.lastIndexOf('/');
|
|
103
|
+
const before = valueAt(base, op.path.slice(0, cut));
|
|
104
|
+
const now = valueAt(comparable, op.path.slice(0, cut));
|
|
105
|
+
if (Array.isArray(before)) {
|
|
106
|
+
return Array.isArray(now) && occurrences(now, op.value) > occurrences(before, op.value);
|
|
107
|
+
}
|
|
108
|
+
return typeof now === 'object' && now !== null && Object.hasOwn(now, (0, fast_json_patch_1.unescapePathComponent)(op.path.slice(cut + 1)));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** How many elements of `array` deeply equal `value`, whatever their key order. */
|
|
112
|
+
function occurrences(array, value) {
|
|
113
|
+
return array.filter(element => (0, fast_json_patch_1._areEquals)(element, value)).length;
|
|
114
|
+
}
|
|
115
|
+
/** The value at `pointer`, or `undefined` when a step of it is missing. */
|
|
116
|
+
function valueAt(document, pointer) {
|
|
117
|
+
try {
|
|
118
|
+
return (0, fast_json_patch_1.getValueByPointer)(document, pointer);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return undefined;
|
|
78
122
|
}
|
|
79
123
|
}
|
|
80
124
|
/**
|
|
@@ -84,20 +128,20 @@ async function reconcileByPatchReplay(baseline, attempted, refetch) {
|
|
|
84
128
|
* clobbered.
|
|
85
129
|
*/
|
|
86
130
|
class ReconcilingConflictResolver {
|
|
87
|
-
resolve(
|
|
88
|
-
return reconcileByPatchReplay(
|
|
131
|
+
resolve(base, ours, refetch) {
|
|
132
|
+
return reconcileByPatchReplay(base, ours, refetch);
|
|
89
133
|
}
|
|
90
134
|
}
|
|
91
135
|
exports.ReconcilingConflictResolver = ReconcilingConflictResolver;
|
|
92
136
|
/**
|
|
93
|
-
* Last-writer-wins {@link ConflictResolver}: always reports the `
|
|
137
|
+
* Last-writer-wins {@link ConflictResolver}: always reports the `ours`
|
|
94
138
|
* state as merged, without refetching or guarding. Suitable for single-client
|
|
95
139
|
* tools or always-regenerated artifacts where a concurrent foreign edit may be
|
|
96
140
|
* overwritten. A foreign edit to any field is clobbered.
|
|
97
141
|
*/
|
|
98
142
|
class ForceConflictResolver {
|
|
99
|
-
async resolve(
|
|
100
|
-
return { status: 'merged', merged:
|
|
143
|
+
async resolve(_base, ours, _refetch) {
|
|
144
|
+
return { status: 'merged', merged: ours };
|
|
101
145
|
}
|
|
102
146
|
}
|
|
103
147
|
exports.ForceConflictResolver = ForceConflictResolver;
|
package/lib/patch-merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-merge.js","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"patch-merge.js","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAElF,qDAQyB;AAEzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4BAAmC,IAAY,EAAE,SAA4C;IAC1F,MAAM,SAAS,GAAyB,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,mCAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACpB,CAAC;AA6C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ACH;IACG,OAAO,CAAmB,IAAO,EAAE,IAAO,EAAE,OAAqC;QAC9E,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACH;;AAED;;;;;GAKG;AACH;IACG,KAAK,CAAC,OAAO,CAAmB,KAAQ,EAAE,IAAO,EAAE,QAAsC;QACtF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;CACH"}
|
package/lib/profile-session.d.ts
CHANGED
|
@@ -56,7 +56,12 @@ export interface ProfileSession {
|
|
|
56
56
|
/** The same aggregate as structured records, for tests / programmatic use. */
|
|
57
57
|
records(): readonly ProfileRecord[];
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* One in-flight {@link ProfileSession.scope} call. Held on the `protected`
|
|
61
|
+
* {@link DefaultProfileSession.stack} and named by
|
|
62
|
+
* {@link DefaultProfileSession.closeFrame}, so a subclass has to name it too.
|
|
63
|
+
*/
|
|
64
|
+
export interface ProfileScopeFrame {
|
|
60
65
|
readonly id: string;
|
|
61
66
|
/** Session-stopwatch reading when this scope began. */
|
|
62
67
|
readonly start: number;
|
|
@@ -73,15 +78,14 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
73
78
|
protected readonly identifier: string;
|
|
74
79
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
75
80
|
protected readonly sessionStopwatch: Stopwatch;
|
|
76
|
-
protected readonly stack:
|
|
81
|
+
protected readonly stack: ProfileScopeFrame[];
|
|
77
82
|
protected readonly entries: Map<string, number[]>;
|
|
78
83
|
constructor(logger: Logger, clock: Clock, identifier: string);
|
|
79
84
|
scope<T>(id: string, fn: () => Promise<T>): Promise<T>;
|
|
80
85
|
scope<T>(id: string, fn: () => T): T;
|
|
81
86
|
/** Pop `frame`, charge its full duration to the parent, and record its self-time. */
|
|
82
|
-
protected closeFrame(frame:
|
|
87
|
+
protected closeFrame(frame: ProfileScopeFrame): void;
|
|
83
88
|
records(): readonly ProfileRecord[];
|
|
84
89
|
report(logLevel?: LogThreshold): void;
|
|
85
90
|
}
|
|
86
|
-
export {};
|
|
87
91
|
//# sourceMappingURL=profile-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC3B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC5B;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAErC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAEtC,8EAA8E;IAC9E,OAAO,IAAI,SAAS,aAAa,EAAE,CAAC;CACtC;AAED,
|
|
1
|
+
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KA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AE,iBAAiB,EAAE,CAAM;IACnD,SAAS,CAAC,QAAQ,CAAC,OAAO,wBAA+B;IAEzD,YACsB,MAAM,EAAE,MAAM,EACjC,KAAK,EAAE,KAAK,EACO,UAAU,EAAE,MAAM,EAGvC;IAED,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IA2BrC,qFAAqF;IACrF,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAcnD;IAED,OAAO,IAAI,SAAS,aAAa,EAAE,CAQlC;IAED,MAAM,CAAC,QAAQ,GAAE,YAAsB,GAAG,IAAI,CAgB7C;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;
|
|
1
|
+
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;AAmE7D;;;;GAIG;AACH;IAOyB,MAAM;IAEN,UAAU;IARhC,6FAA6F;IAC1E,gBAAgB,CAAY;IAC5B,KAAK,GAAwB,EAAE,CAAC;IAChC,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD,YACsB,MAAc,EACjC,KAAY,EACO,UAAkB;sBAFlB,MAAM;0BAEN,UAAU;QAE7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAID,KAAK,CAAI,EAAU,EAAE,EAAwB;QAC1C,MAAM,KAAK,GAAsB,EAAE,EAAE,EAAE,KAAK,EAAE,I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GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,eAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtI,CAAC;QACD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,CAAC;QAC5C,IAAI,aAAa,IAAI,GAAG,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,mBAAmB,GAAG,KAAK,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACJ,CAAC;CACH"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import type
|
|
9
|
+
import { ResponseError, type MessageConnection } from 'vscode-jsonrpc';
|
|
10
10
|
import type { LatencyCollector } from '../latency-collector';
|
|
11
11
|
import { type Disposable } from '../util';
|
|
12
12
|
/**
|
|
@@ -62,6 +62,30 @@ export interface BindRpcMethodsOptions {
|
|
|
62
62
|
* Requests and notifications are both timed. Absent by default (no overhead).
|
|
63
63
|
*/
|
|
64
64
|
readonly latency?: LatencyCollector;
|
|
65
|
+
/**
|
|
66
|
+
* Produce the `message` an outgoing rejection carries, so a user-facing
|
|
67
|
+
* error is rendered by the side that knows the reading user's language.
|
|
68
|
+
* Applied at this one chokepoint, which is what covers a caller's
|
|
69
|
+
* additional methods as well as the framework's own.
|
|
70
|
+
*
|
|
71
|
+
* Only a `ResponseError` is routed through it — a plain `Error` carries no
|
|
72
|
+
* identity to render from, and rewriting its message would relabel a
|
|
73
|
+
* developer-facing failure as a translated one. The rejection is
|
|
74
|
+
* RECONSTRUCTED rather than mutated, because the thrown value may be a
|
|
75
|
+
* shared constant; nothing is lost, since only `code`, `message` and `data`
|
|
76
|
+
* cross the wire and `instanceof` does not survive reconstruction anyway.
|
|
77
|
+
*
|
|
78
|
+
* Notifications are not covered, and "they have no reply channel" is only
|
|
79
|
+
* half the reason — a notification's own PAYLOAD can carry prose. What makes
|
|
80
|
+
* this sound is where that prose comes from: the only user-facing text on
|
|
81
|
+
* the data head's client surface is the diagnostics riding the
|
|
82
|
+
* document-updated and document-saved events, and those are read off
|
|
83
|
+
* `LangiumDocument.diagnostics`, which the document builder has already
|
|
84
|
+
* rendered at `Validated`. So they arrive rendered rather than escaping
|
|
85
|
+
* unrendered. A notification that ever carries prose of its OWN needs its
|
|
86
|
+
* own render at the raise site, as GLSP's actions do.
|
|
87
|
+
*/
|
|
88
|
+
readonly renderErrorMessage?: (error: ResponseError<unknown>) => string;
|
|
65
89
|
}
|
|
66
90
|
/**
|
|
67
91
|
* Register each named method on `target` as a handler on `connection`
|
|
@@ -82,8 +106,10 @@ export interface BindRpcMethodsOptions {
|
|
|
82
106
|
*
|
|
83
107
|
* Errors thrown synchronously from a request handler — or surfaced as a
|
|
84
108
|
* rejected promise — propagate back to the caller through vscode-jsonrpc's
|
|
85
|
-
* standard error envelope
|
|
86
|
-
*
|
|
109
|
+
* standard error envelope, with the message rendered when
|
|
110
|
+
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied. Errors from a
|
|
111
|
+
* notification handler cannot propagate, and are routed to
|
|
112
|
+
* {@link BindRpcMethodsOptions.onNotificationError} instead.
|
|
87
113
|
*
|
|
88
114
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
89
115
|
* registrations queue until the connection resolves, then attach. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-rpc-methods.d.ts","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"bind-rpc-methods.d.ts","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAwB,MAAM,SAAS,CAAC;AAIhE;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACnC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAE1D;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAE1E;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC;CAC1E;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC5C,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAC1D,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAC1C,OAAO,GAAE,qBAA0B,GACnC,UAAU,CAgFZ"}
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.bindRpcMethods = bindRpcMethods;
|
|
12
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
12
13
|
const util_1 = require("../util");
|
|
13
14
|
const create_rpc_proxy_1 = require("./create-rpc-proxy");
|
|
14
15
|
const wire_prefix_1 = require("./wire-prefix");
|
|
16
|
+
/** The rejection to throw in place of `err`, with its message rendered. */
|
|
17
|
+
function renderRejection(err, render) {
|
|
18
|
+
return err instanceof vscode_jsonrpc_1.ResponseError ? new vscode_jsonrpc_1.ResponseError(err.code, render(err), err.data) : err;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* Register each named method on `target` as a handler on `connection`
|
|
17
22
|
* under the wire-name `<prefix><methodName>`. Notification methods (by
|
|
@@ -31,8 +36,10 @@ const wire_prefix_1 = require("./wire-prefix");
|
|
|
31
36
|
*
|
|
32
37
|
* Errors thrown synchronously from a request handler — or surfaced as a
|
|
33
38
|
* rejected promise — propagate back to the caller through vscode-jsonrpc's
|
|
34
|
-
* standard error envelope
|
|
35
|
-
*
|
|
39
|
+
* standard error envelope, with the message rendered when
|
|
40
|
+
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied. Errors from a
|
|
41
|
+
* notification handler cannot propagate, and are routed to
|
|
42
|
+
* {@link BindRpcMethodsOptions.onNotificationError} instead.
|
|
36
43
|
*
|
|
37
44
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
38
45
|
* registrations queue until the connection resolves, then attach. The
|
|
@@ -84,7 +91,19 @@ function bindRpcMethods(connection, target, methodNames, options = {}) {
|
|
|
84
91
|
}));
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
|
-
|
|
94
|
+
const render = options.renderErrorMessage;
|
|
95
|
+
disposables.push(resolved.onRequest(wireName, async (params) => {
|
|
96
|
+
if (!render) {
|
|
97
|
+
return dispatch(params);
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
// Awaited inside the try, or a rejected promise escapes it.
|
|
101
|
+
return await dispatch(params);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
throw renderRejection(err, render);
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-rpc-methods.js","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"bind-rpc-methods.js","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAuE;AAEvE,kCAAgE;AAChE,yDAA2D;AAC3D,+CAA2D;AAsF3D,2EAA2E;AAC3E,SAAS,eAAe,CAAC,GAAY,EAAE,MAAiD;IACrF,OAAO,GAAG,YAAY,8BAAa,CAAC,CAAC,CAAC,IAAI,8BAAa,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAClG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBACG,UAA0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CAAC;IACT,CAAC;SAAM,CAAC;QACL,MAAM,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED,OAAO;QACJ,OAAO;YACJ,SAAS,GAAG,IAAI,CAAC;YACjB,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KACH,CAAC;AACL,CAAC"}
|
|
@@ -127,6 +127,13 @@ export interface CreateRpcProxyOptions<TLocal extends object = never> {
|
|
|
127
127
|
* `bindRpcMethods` call) still capture per-method latency. Absent by default.
|
|
128
128
|
*/
|
|
129
129
|
readonly latency?: BindRpcMethodsOptions['latency'];
|
|
130
|
+
/**
|
|
131
|
+
* Forwarded to the inbound {@link localTarget} binding: renders the message
|
|
132
|
+
* an outgoing rejection carries. Only the inbound direction has rejections
|
|
133
|
+
* to render — the outbound proxy is this side making requests, and a
|
|
134
|
+
* rejection it receives was rendered by whoever answered.
|
|
135
|
+
*/
|
|
136
|
+
readonly renderErrorMessage?: BindRpcMethodsOptions['renderErrorMessage'];
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
132
139
|
* Default notification discriminator — `on`-followed-by-an-uppercase-letter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.d.ts","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,KAAK,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,oBAAoB,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,iBAAiB;IAC/B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qEAAqE;AACrE,M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AAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,MAAM,GAAG,KAAK;IACjE;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAE1D;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;OASG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAE3D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,EAC3E,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAC1D,OAAO,GAAE,qBAAqB,CAAC,MAAM,CAAM,GAC3C,QAAQ,CAAC,CAAC,CAAC,CA+Eb"}
|
|
@@ -92,7 +92,12 @@ function createRpcProxy(connection, options = {}) {
|
|
|
92
92
|
// connection; see `localTarget` for why no `Disposable` is surfaced.
|
|
93
93
|
const { localTarget, localMethods } = options;
|
|
94
94
|
if (localTarget && localMethods && localMethods.length > 0) {
|
|
95
|
-
const binding = (0, bind_rpc_methods_1.bindRpcMethods)(connection, localTarget, localMethods, {
|
|
95
|
+
const binding = (0, bind_rpc_methods_1.bindRpcMethods)(connection, localTarget, localMethods, {
|
|
96
|
+
methodNamespace,
|
|
97
|
+
isNotification,
|
|
98
|
+
latency: options.latency,
|
|
99
|
+
renderErrorMessage: options.renderErrorMessage
|
|
100
|
+
});
|
|
96
101
|
resolvedConnection.then(conn => conn.onClose(() => binding.dispose())).catch(() => undefined);
|
|
97
102
|
}
|
|
98
103
|
const onDidOpenConnectionEmitter = new vscode_jsonrpc_1.Emitter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAElF,mDAA6E;AAC7E,yDAAgF;AAChF,+CAA2D;AAyI3D;;;;;;;;;;;;;;;GAeG;AACH,+BAAsC,UAAkB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAe;IACvD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACZ,eAAe,QAAQ,iBAAiB,IAAI,CAAC,MAAM,2DAA2D;YAC3G,uDAAuD,CAC5D,CAAC;IACL,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBACG,UAA0D,EAC1D,OAAO,GAAkC,EAAE;IAE3C,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IACtD,IAAA,wCAA0B,EAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,qBAAqB,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AAC,CAAC,CAAC;qBAC7D,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;oBACrB,IAAI,GAAG,YAAY,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;wBAC/C,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,8BAA8B,aAAa,CAAC,KAAK,EAAE,CAAC;oBAC9F,CAAC;oBACD,MAAM,GAAG,CAAC;gBACb,CAAC,CAAC,CAAC;YACT,CAAC,CAAC;QACL,CAAC;KACH,CAAgB,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-prefix.js","sourceRoot":"","sources":["../../src/rpc/wire-prefix.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"wire-prefix.js","sourceRoot":"","sources":["../../src/rpc/wire-prefix.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,oCAA2C,eAAuB,EAAE,MAAc;IAC/E,IAAI,eAAe,KAAK,EAAE,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3D,OAAO;IACV,CAAC;IACD,MAAM,IAAI,SAAS,CAChB,GAAG,MAAM,sBAAsB,eAAe,qCAAqC;QAChF,qFAAqF;QACrF,yDAAyD,eAAe,cAAc;QACtF,6CAA6C,eAAe,gBAAgB;QAC5E,gBAAgB,eAAe,2CAA2C,CAC/E,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
* Audit a translation catalogue against the codes that actually exist.
|
|
11
|
+
*
|
|
12
|
+
* **The one failure mode a catalogue has, and the only one nothing else
|
|
13
|
+
* catches.** A key naming no declared code falls back to the English — which is
|
|
14
|
+
* byte-identical to a deliberate omission, so a typo is invisible at runtime and
|
|
15
|
+
* indistinguishable from the partial-catalogue behaviour every adopter relies
|
|
16
|
+
* on. Nothing on the render path can tell them apart, `theia nls-extract`
|
|
17
|
+
* reports what the SOURCE declares rather than whether a catalogue matches it,
|
|
18
|
+
* and the framework's own gates see only the framework's own files.
|
|
19
|
+
*
|
|
20
|
+
* Shipped as test support rather than as a runtime check on purpose: an
|
|
21
|
+
* orphaned key is an authoring mistake, and failing a server boot over one would
|
|
22
|
+
* take a running product down for a cosmetic defect.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Flatten a nested catalogue into the `/`-joined keys a message code is spelled
|
|
26
|
+
* with, dropping `_`-prefixed keys as notes to a human reader.
|
|
27
|
+
*
|
|
28
|
+
* Nesting is a HOST convention, not the framework's: Theia flattens a nested
|
|
29
|
+
* catalogue by joining keys with `/`, which is the separator a code already
|
|
30
|
+
* uses, so an adopter on that host writes the file nested and one handed
|
|
31
|
+
* straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
|
|
32
|
+
*
|
|
33
|
+
* `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
|
|
34
|
+
* name, so a second note added to a file cannot silently become a catalogue
|
|
35
|
+
* entry. A code is three `/`-separated segments, so no real entry can begin
|
|
36
|
+
* with `_`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function flattenCatalogue(catalogue: Record<string, unknown>, prefix?: string): Record<string, string>;
|
|
39
|
+
/** Options for {@link findUndeclaredCodes}. */
|
|
40
|
+
export interface CatalogueAuditOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Key prefixes to skip, for entries whose codes are NOT declared through a
|
|
43
|
+
* `defineMessage` barrel.
|
|
44
|
+
*
|
|
45
|
+
* The real case is a host's own mechanism: Theia's `nls.localize` takes its
|
|
46
|
+
* key as an inline literal at the call site, so those keys exist only in
|
|
47
|
+
* source text and no barrel can enumerate them. Keep this as narrow as the
|
|
48
|
+
* host layer actually is — exempting a namespace is exempting every typo in
|
|
49
|
+
* it, which is what this function exists to find.
|
|
50
|
+
*/
|
|
51
|
+
readonly exemptPrefixes?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Every catalogue key that names no code any of `barrels` declares.
|
|
55
|
+
*
|
|
56
|
+
* Barrels are taken as opaque objects and read with {@link collectMessages},
|
|
57
|
+
* which is what lets a caller pass a `import * as messages` namespace directly:
|
|
58
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
59
|
+
* filtering that union will not narrow to a `MessageDefinition`.
|
|
60
|
+
*
|
|
61
|
+
* Returns the offending keys rather than a boolean, so a failing assertion names
|
|
62
|
+
* WHICH key is wrong — a count says only that something is.
|
|
63
|
+
*/
|
|
64
|
+
export declare function findUndeclaredCodes(catalogueKeys: readonly string[], barrels: readonly object[], options?: CatalogueAuditOptions): string[];
|
|
65
|
+
/**
|
|
66
|
+
* Keys present in more than one catalogue — the shape a split catalogue rots
|
|
67
|
+
* into.
|
|
68
|
+
*
|
|
69
|
+
* Exactly one side renders a given message, so two catalogues holding one code
|
|
70
|
+
* are two authorities over one sentence and they diverge on the first reword.
|
|
71
|
+
* Nothing at runtime notices: both sides render, and whichever ran last wins on
|
|
72
|
+
* its own surface.
|
|
73
|
+
*
|
|
74
|
+
* Takes the key sets rather than a boolean answer for the same reason as
|
|
75
|
+
* {@link findUndeclaredCodes}, and reports NOTHING when a set is empty — an
|
|
76
|
+
* empty catalogue shares no key with anything, so a caller must assert
|
|
77
|
+
* non-emptiness separately or a failed read passes this vacuously.
|
|
78
|
+
*/
|
|
79
|
+
export declare function findSharedCodes(first: readonly string[], second: readonly string[]): string[];
|
|
80
|
+
//# sourceMappingURL=catalogue-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue-audit.d.ts","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,SAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcxG;AAED,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACnC;;;;;;;;;OASG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAChC,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,qBAA0B,GACnC,MAAM,EAAE,CAIV;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAG7F"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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.flattenCatalogue = flattenCatalogue;
|
|
12
|
+
exports.findUndeclaredCodes = findUndeclaredCodes;
|
|
13
|
+
exports.findSharedCodes = findSharedCodes;
|
|
14
|
+
const primitives_1 = require("../messages/primitives");
|
|
15
|
+
/**
|
|
16
|
+
* Audit a translation catalogue against the codes that actually exist.
|
|
17
|
+
*
|
|
18
|
+
* **The one failure mode a catalogue has, and the only one nothing else
|
|
19
|
+
* catches.** A key naming no declared code falls back to the English — which is
|
|
20
|
+
* byte-identical to a deliberate omission, so a typo is invisible at runtime and
|
|
21
|
+
* indistinguishable from the partial-catalogue behaviour every adopter relies
|
|
22
|
+
* on. Nothing on the render path can tell them apart, `theia nls-extract`
|
|
23
|
+
* reports what the SOURCE declares rather than whether a catalogue matches it,
|
|
24
|
+
* and the framework's own gates see only the framework's own files.
|
|
25
|
+
*
|
|
26
|
+
* Shipped as test support rather than as a runtime check on purpose: an
|
|
27
|
+
* orphaned key is an authoring mistake, and failing a server boot over one would
|
|
28
|
+
* take a running product down for a cosmetic defect.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Flatten a nested catalogue into the `/`-joined keys a message code is spelled
|
|
32
|
+
* with, dropping `_`-prefixed keys as notes to a human reader.
|
|
33
|
+
*
|
|
34
|
+
* Nesting is a HOST convention, not the framework's: Theia flattens a nested
|
|
35
|
+
* catalogue by joining keys with `/`, which is the separator a code already
|
|
36
|
+
* uses, so an adopter on that host writes the file nested and one handed
|
|
37
|
+
* straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
|
|
38
|
+
*
|
|
39
|
+
* `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
|
|
40
|
+
* name, so a second note added to a file cannot silently become a catalogue
|
|
41
|
+
* entry. A code is three `/`-separated segments, so no real entry can begin
|
|
42
|
+
* with `_`.
|
|
43
|
+
*/
|
|
44
|
+
function flattenCatalogue(catalogue, prefix = '') {
|
|
45
|
+
const flat = {};
|
|
46
|
+
for (const [key, value] of Object.entries(catalogue)) {
|
|
47
|
+
if (key.startsWith('_')) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const joined = prefix ? `${prefix}/${key}` : key;
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
flat[joined] = value;
|
|
53
|
+
}
|
|
54
|
+
else if (typeof value === 'object' && value !== null) {
|
|
55
|
+
Object.assign(flat, flattenCatalogue(value, joined));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return flat;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Every catalogue key that names no code any of `barrels` declares.
|
|
62
|
+
*
|
|
63
|
+
* Barrels are taken as opaque objects and read with {@link collectMessages},
|
|
64
|
+
* which is what lets a caller pass a `import * as messages` namespace directly:
|
|
65
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
66
|
+
* filtering that union will not narrow to a `MessageDefinition`.
|
|
67
|
+
*
|
|
68
|
+
* Returns the offending keys rather than a boolean, so a failing assertion names
|
|
69
|
+
* WHICH key is wrong — a count says only that something is.
|
|
70
|
+
*/
|
|
71
|
+
function findUndeclaredCodes(catalogueKeys, barrels, options = {}) {
|
|
72
|
+
const declared = new Set(barrels.flatMap(barrel => (0, primitives_1.collectMessages)(barrel).map(message => message.code)));
|
|
73
|
+
const exempt = options.exemptPrefixes ?? [];
|
|
74
|
+
return catalogueKeys.filter(key => !exempt.some(prefix => key.startsWith(prefix)) && !declared.has(key));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Keys present in more than one catalogue — the shape a split catalogue rots
|
|
78
|
+
* into.
|
|
79
|
+
*
|
|
80
|
+
* Exactly one side renders a given message, so two catalogues holding one code
|
|
81
|
+
* are two authorities over one sentence and they diverge on the first reword.
|
|
82
|
+
* Nothing at runtime notices: both sides render, and whichever ran last wins on
|
|
83
|
+
* its own surface.
|
|
84
|
+
*
|
|
85
|
+
* Takes the key sets rather than a boolean answer for the same reason as
|
|
86
|
+
* {@link findUndeclaredCodes}, and reports NOTHING when a set is empty — an
|
|
87
|
+
* empty catalogue shares no key with anything, so a caller must assert
|
|
88
|
+
* non-emptiness separately or a failed read passes this vacuously.
|
|
89
|
+
*/
|
|
90
|
+
function findSharedCodes(first, second) {
|
|
91
|
+
const other = new Set(second);
|
|
92
|
+
return first.filter(key => other.has(key));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=catalogue-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue-audit.js","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAElF,uDAAyD;AAEzD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,0BAAiC,SAAkC,EAAE,MAAM,GAAG,EAAE;IAC7E,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,SAAS;QACZ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAgC,EAAE,MAAM,CAAC,CAAC,CAAC;QACnF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACf,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,6BACG,aAAgC,EAChC,OAA0B,EAC1B,OAAO,GAA0B,EAAE;IAEnC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAA,4BAAe,EAAC,MAAM,CA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