@hydranium/glsp-client 0.0.0-stage → 1.0.0-next

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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/lib/action-dispatcher.d.ts +89 -0
  4. package/lib/action-dispatcher.d.ts.map +1 -0
  5. package/lib/action-dispatcher.js +257 -0
  6. package/lib/action-dispatcher.js.map +1 -0
  7. package/lib/diagram-load-failed.d.ts +20 -0
  8. package/lib/diagram-load-failed.d.ts.map +1 -0
  9. package/lib/diagram-load-failed.js +24 -0
  10. package/lib/diagram-load-failed.js.map +1 -0
  11. package/lib/diagram-loader.d.ts +124 -0
  12. package/lib/diagram-loader.d.ts.map +1 -0
  13. package/lib/diagram-loader.js +154 -0
  14. package/lib/diagram-loader.js.map +1 -0
  15. package/lib/edge.d.ts +40 -0
  16. package/lib/edge.d.ts.map +1 -0
  17. package/lib/edge.js +56 -0
  18. package/lib/edge.js.map +1 -0
  19. package/lib/glsp-client-module.d.ts +36 -0
  20. package/lib/glsp-client-module.d.ts.map +1 -0
  21. package/lib/glsp-client-module.js +63 -0
  22. package/lib/glsp-client-module.js.map +1 -0
  23. package/lib/glsp-client.d.ts +17 -0
  24. package/lib/glsp-client.d.ts.map +1 -0
  25. package/lib/glsp-client.js +23 -0
  26. package/lib/glsp-client.js.map +1 -0
  27. package/lib/hidden-bounds-updater.d.ts +119 -0
  28. package/lib/hidden-bounds-updater.d.ts.map +1 -0
  29. package/lib/hidden-bounds-updater.js +210 -0
  30. package/lib/hidden-bounds-updater.js.map +1 -0
  31. package/lib/index.d.ts +19 -0
  32. package/lib/index.d.ts.map +1 -0
  33. package/lib/index.js +40 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/messages/index.d.ts +10 -0
  36. package/lib/messages/index.d.ts.map +1 -0
  37. package/lib/messages/index.js +20 -0
  38. package/lib/messages/index.js.map +1 -0
  39. package/lib/sprotty-logger-adapter.d.ts +61 -0
  40. package/lib/sprotty-logger-adapter.d.ts.map +1 -0
  41. package/lib/sprotty-logger-adapter.js +130 -0
  42. package/lib/sprotty-logger-adapter.js.map +1 -0
  43. package/lib/status-overlay.d.ts +23 -0
  44. package/lib/status-overlay.d.ts.map +1 -0
  45. package/lib/status-overlay.js +52 -0
  46. package/lib/status-overlay.js.map +1 -0
  47. package/lib/testing/bind-recorder.d.ts +67 -0
  48. package/lib/testing/bind-recorder.d.ts.map +1 -0
  49. package/lib/testing/bind-recorder.js +72 -0
  50. package/lib/testing/bind-recorder.js.map +1 -0
  51. package/lib/testing/index.d.ts +10 -0
  52. package/lib/testing/index.d.ts.map +1 -0
  53. package/lib/testing/index.js +28 -0
  54. package/lib/testing/index.js.map +1 -0
  55. package/lib/types.d.ts +27 -0
  56. package/lib/types.d.ts.map +1 -0
  57. package/lib/types.js +33 -0
  58. package/lib/types.js.map +1 -0
  59. package/package.json +79 -4
  60. package/src/action-dispatcher.ts +273 -0
  61. package/src/diagram-load-failed.ts +22 -0
  62. package/src/diagram-loader.ts +173 -0
  63. package/src/edge.ts +65 -0
  64. package/src/glsp-client-module.ts +75 -0
  65. package/src/glsp-client.ts +20 -0
  66. package/src/hidden-bounds-updater.ts +210 -0
  67. package/src/index.ts +24 -0
  68. package/src/messages/index.ts +17 -0
  69. package/src/sprotty-logger-adapter.ts +121 -0
  70. package/src/status-overlay.ts +43 -0
  71. package/src/testing/bind-recorder.ts +126 -0
  72. package/src/testing/index.ts +13 -0
  73. package/src/types.ts +34 -0
@@ -0,0 +1,119 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type Action, type ElementAndRoutingPoints, type GModelElement, type GRoutableElement, GLSPHiddenBoundsUpdater, RequestBoundsAction } from '@eclipse-glsp/client';
10
+ import { type Clock, type Logger } from '@hydranium/protocol';
11
+ import { type VNode } from 'snabbdom';
12
+ /**
13
+ * Instruments sprotty's hidden-bounds pass and repairs degenerate routes before
14
+ * they go on the wire.
15
+ *
16
+ * **Why the framework owns this.** Every GLSP head runs the hidden-bounds pass on
17
+ * every model update, and it is the one client-side phase that scales with the
18
+ * *rendered element count* rather than the model size — labels, compartments and
19
+ * edge decorations expand a modest node count into orders of magnitude more DOM
20
+ * elements. Without a timing line there is no way to tell a slow measurement pass
21
+ * apart from slow edge routing or a slow server round trip; with one,
22
+ * `bounds-request` either exonerates the client in a sentence or names the
23
+ * dominant cost.
24
+ *
25
+ * Emits exactly one `trace` line per bounds request — `trace` because the
26
+ * frequency matches the per-action traffic `HydraniumGlspActionDispatcher` logs
27
+ * there (a bounds request is driven by those actions), so it belongs with them
28
+ * rather than above them. The line carries:
29
+ *
30
+ * - `server` / `local` — whether the request came from the server or from a
31
+ * client-local {@link LocalRequestBoundsAction}
32
+ * - `scope=<ids>` — the elements a scoped request named; absent when the request
33
+ * covers the whole diagram
34
+ * - `measured=N` — DOM elements whose bounds were read. Exceeds the scoped id
35
+ * count because the base class expands each requested element to its
36
+ * descendants
37
+ * - `getBBox=Nms` — {@link getBoundsFromDOM} **only**: the layout pass and the
38
+ * `ComputedBoundsAction` assembly stay outside it, so the number isolates raw
39
+ * measurement cost
40
+ *
41
+ * Composed from {@link Clock.measure} rather than `Tracer.time`, matching
42
+ * `HydraniumDocumentBuilder`'s phase instrumentation. `Tracer.time` is for "tell
43
+ * me when this is slow" and is deliberately silent on a fast success, which would
44
+ * drop the element count on every normal pass — and forcing it to emit costs a
45
+ * paired `[#N start]` line per request. This is a per-occurrence record, so it
46
+ * measures and composes its own line.
47
+ *
48
+ * Bound by `createGlspClientModule` via `rebind(GLSPHiddenBoundsUpdater)`.
49
+ */
50
+ export declare class HydraniumHiddenBoundsUpdater extends GLSPHiddenBoundsUpdater {
51
+ protected readonly hydraniumLogger: Logger;
52
+ /** The diagram container's {@link Clock}, or a `SystemClock`; it only measures. */
53
+ protected readonly clock: Clock;
54
+ /**
55
+ * Scope description for the in-flight request, read from the `cause` in
56
+ * {@link postUpdate} and consumed by {@link getBoundsFromDOM} — which the base
57
+ * class calls with no arguments, so the cause cannot be threaded through.
58
+ */
59
+ protected currentScope?: string;
60
+ decorate(vnode: VNode, element: GModelElement): VNode;
61
+ /**
62
+ * Replace the routing entry the base class just pushed when it carries fewer
63
+ * than two points, which is not a valid route for any edge.
64
+ *
65
+ * `calcElementAndRoute` already guards the case where the registered router
66
+ * returns *nothing* — it falls back to source + own routing points + target.
67
+ * The hole is one step further in: `calcRoute` filters duplicate points at
68
+ * `Number.EPSILON`, so while obstacles still carry sprotty's unmeasured-bounds
69
+ * sentinel `(100, 100, -1, -1)` the source and target coincide and a valid
70
+ * two-point route collapses to a single point. That result is defined, so the
71
+ * upstream truthiness guard never fires and the single point ships.
72
+ *
73
+ * The substitute is deliberately upstream's own fallback shape rather than a
74
+ * new invention, so a repaired route is indistinguishable from a route the
75
+ * base class would have produced had it noticed. Only already-invalid payloads
76
+ * are touched, so a head with a working router is unaffected.
77
+ */
78
+ protected repairLastRoute(element: GRoutableElement): void;
79
+ /** A route needs at least a start and an end point to describe an edge. */
80
+ protected hasValidRoute(route: ElementAndRoutingPoints): boolean;
81
+ /** Upstream's `calcElementAndRoute` no-router fallback: the element's own
82
+ * bendpoints framed by its source and target anchor positions. */
83
+ protected toSourceTargetRoute(element: GRoutableElement): ElementAndRoutingPoints;
84
+ protected getBoundsFromDOM(): void;
85
+ /** Format the per-request line. Override to change the wording. */
86
+ protected formatBoundsRequest(scope: string, measured: number, elapsedMs: number): string;
87
+ postUpdate(cause?: Action): void;
88
+ /**
89
+ * Scope facts for the log line: where the request came from, and which
90
+ * elements it asked for.
91
+ *
92
+ * Origin is read from {@link ServerAction}, the `__receivedFromServer` marker
93
+ * `GLSPModelSource` stamps on inbound actions, rather than from
94
+ * `LocalRequestBoundsAction.is`. The latter would answer the same today, but
95
+ * only incidentally: its `elementIDs` check is declared optional, so it is
96
+ * really just "a bounds request that did not come from the server". Keying on
97
+ * the marker states that directly, and keeps an *unscoped* local request from
98
+ * being mislabelled `server` if GLSP ever tightens that guard.
99
+ */
100
+ protected formatCause(cause: Action): string;
101
+ /**
102
+ * Name the elements a scoped request asked for, or `undefined` when it covers
103
+ * the whole diagram.
104
+ *
105
+ * Deliberately the ids and not their count. A scoped request in practice names
106
+ * a single element, so a count is always `1` and says nothing, while the id
107
+ * says *which* element was re-measured — and it is the only part of the line
108
+ * that distinguishes one such request from the next. It also stops the line
109
+ * reading as a contradiction: `scope=node0, measured=6` is coherent (the base
110
+ * class expands a requested element to its descendants, so one id measures six
111
+ * DOM elements), where `scoped=1, measured=6` invites the reader to wonder
112
+ * which number is wrong.
113
+ *
114
+ * A request naming only the root is treated as unscoped: it measures
115
+ * everything, so the id adds nothing over the absence of a `scope` tag.
116
+ */
117
+ protected formatScope(cause: RequestBoundsAction): string | undefined;
118
+ }
119
+ //# sourceMappingURL=hidden-bounds-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hidden-bounds-updater.d.ts","sourceRoot":"","sources":["../src/hidden-bounds-updater.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,MAAM,EACX,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,uBAAuB,EAGvB,mBAAmB,EAGrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBACa,4BAA6B,SAAQ,uBAAuB;IACjC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAG,MAAM,CAAC;IAEjF,mFAAmF;IACnC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAqB;IAEpG;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,CAM7D;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAMzD;IAED,2EAA2E;IAC3E,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAE/D;IAED;uEACmE;IACnE,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,uBAAuB,CAKhF;IAED,UAAmB,gBAAgB,IAAI,IAAI,CAW1C;IAED,mEAAmE;IACnE,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAExF;IAEQ,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAWxC;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3C;IAED;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAapE;CACH"}
@@ -0,0 +1,210 @@
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
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
16
+ var __metadata = (this && this.__metadata) || function (k, v) {
17
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.HydraniumHiddenBoundsUpdater = void 0;
21
+ const client_1 = require("@eclipse-glsp/client");
22
+ const protocol_1 = require("@hydranium/protocol");
23
+ const inversify_1 = require("inversify");
24
+ const types_1 = require("./types");
25
+ /** How many scoped element ids the log line names before summarising the rest.
26
+ * A scoped request names one element in practice; the cap only stops a
27
+ * pathological caller from writing a thousand ids into the log. */
28
+ const SCOPE_ID_CAP = 3;
29
+ /**
30
+ * Instruments sprotty's hidden-bounds pass and repairs degenerate routes before
31
+ * they go on the wire.
32
+ *
33
+ * **Why the framework owns this.** Every GLSP head runs the hidden-bounds pass on
34
+ * every model update, and it is the one client-side phase that scales with the
35
+ * *rendered element count* rather than the model size — labels, compartments and
36
+ * edge decorations expand a modest node count into orders of magnitude more DOM
37
+ * elements. Without a timing line there is no way to tell a slow measurement pass
38
+ * apart from slow edge routing or a slow server round trip; with one,
39
+ * `bounds-request` either exonerates the client in a sentence or names the
40
+ * dominant cost.
41
+ *
42
+ * Emits exactly one `trace` line per bounds request — `trace` because the
43
+ * frequency matches the per-action traffic `HydraniumGlspActionDispatcher` logs
44
+ * there (a bounds request is driven by those actions), so it belongs with them
45
+ * rather than above them. The line carries:
46
+ *
47
+ * - `server` / `local` — whether the request came from the server or from a
48
+ * client-local {@link LocalRequestBoundsAction}
49
+ * - `scope=<ids>` — the elements a scoped request named; absent when the request
50
+ * covers the whole diagram
51
+ * - `measured=N` — DOM elements whose bounds were read. Exceeds the scoped id
52
+ * count because the base class expands each requested element to its
53
+ * descendants
54
+ * - `getBBox=Nms` — {@link getBoundsFromDOM} **only**: the layout pass and the
55
+ * `ComputedBoundsAction` assembly stay outside it, so the number isolates raw
56
+ * measurement cost
57
+ *
58
+ * Composed from {@link Clock.measure} rather than `Tracer.time`, matching
59
+ * `HydraniumDocumentBuilder`'s phase instrumentation. `Tracer.time` is for "tell
60
+ * me when this is slow" and is deliberately silent on a fast success, which would
61
+ * drop the element count on every normal pass — and forcing it to emit costs a
62
+ * paired `[#N start]` line per request. This is a per-occurrence record, so it
63
+ * measures and composes its own line.
64
+ *
65
+ * Bound by `createGlspClientModule` via `rebind(GLSPHiddenBoundsUpdater)`.
66
+ */
67
+ let HydraniumHiddenBoundsUpdater = class HydraniumHiddenBoundsUpdater extends client_1.GLSPHiddenBoundsUpdater {
68
+ hydraniumLogger;
69
+ /** The diagram container's {@link Clock}, or a `SystemClock`; it only measures. */
70
+ clock = new protocol_1.SystemClock();
71
+ /**
72
+ * Scope description for the in-flight request, read from the `cause` in
73
+ * {@link postUpdate} and consumed by {@link getBoundsFromDOM} — which the base
74
+ * class calls with no arguments, so the cause cannot be threaded through.
75
+ */
76
+ currentScope;
77
+ decorate(vnode, element) {
78
+ super.decorate(vnode, element);
79
+ if ((0, client_1.isRoutable)(element)) {
80
+ this.repairLastRoute(element);
81
+ }
82
+ return vnode;
83
+ }
84
+ /**
85
+ * Replace the routing entry the base class just pushed when it carries fewer
86
+ * than two points, which is not a valid route for any edge.
87
+ *
88
+ * `calcElementAndRoute` already guards the case where the registered router
89
+ * returns *nothing* — it falls back to source + own routing points + target.
90
+ * The hole is one step further in: `calcRoute` filters duplicate points at
91
+ * `Number.EPSILON`, so while obstacles still carry sprotty's unmeasured-bounds
92
+ * sentinel `(100, 100, -1, -1)` the source and target coincide and a valid
93
+ * two-point route collapses to a single point. That result is defined, so the
94
+ * upstream truthiness guard never fires and the single point ships.
95
+ *
96
+ * The substitute is deliberately upstream's own fallback shape rather than a
97
+ * new invention, so a repaired route is indistinguishable from a route the
98
+ * base class would have produced had it noticed. Only already-invalid payloads
99
+ * are touched, so a head with a working router is unaffected.
100
+ */
101
+ repairLastRoute(element) {
102
+ const addedRoute = this.element2route.pop();
103
+ if (addedRoute === undefined) {
104
+ return;
105
+ }
106
+ this.element2route.push(this.hasValidRoute(addedRoute) ? addedRoute : this.toSourceTargetRoute(element));
107
+ }
108
+ /** A route needs at least a start and an end point to describe an edge. */
109
+ hasValidRoute(route) {
110
+ return route.newRoutingPoints !== undefined && route.newRoutingPoints.length >= 2;
111
+ }
112
+ /** Upstream's `calcElementAndRoute` no-router fallback: the element's own
113
+ * bendpoints framed by its source and target anchor positions. */
114
+ toSourceTargetRoute(element) {
115
+ return {
116
+ elementId: element.id,
117
+ newRoutingPoints: [element.source?.position ?? client_1.Point.ORIGIN, ...element.routingPoints, element.target?.position ?? client_1.Point.ORIGIN]
118
+ };
119
+ }
120
+ getBoundsFromDOM() {
121
+ if (this.currentScope === undefined) {
122
+ // Not inside an instrumented `postUpdate` (a subclass calling directly);
123
+ // with no cause there is nothing to attribute a measurement to.
124
+ super.getBoundsFromDOM();
125
+ return;
126
+ }
127
+ // Read before the pass: the base class clears the map on its way out.
128
+ const measured = this.getElement2BoundsData().size;
129
+ const { elapsedMs } = this.clock.measure(() => super.getBoundsFromDOM());
130
+ this.hydraniumLogger.trace(this.formatBoundsRequest(this.currentScope, measured, elapsedMs));
131
+ }
132
+ /** Format the per-request line. Override to change the wording. */
133
+ formatBoundsRequest(scope, measured, elapsedMs) {
134
+ return `bounds-request[${scope}] measured=${measured} getBBox=${elapsedMs.toFixed(0)}ms`;
135
+ }
136
+ postUpdate(cause) {
137
+ if (cause?.kind !== client_1.RequestBoundsAction.KIND) {
138
+ super.postUpdate(cause);
139
+ return;
140
+ }
141
+ this.currentScope = this.formatCause(cause);
142
+ try {
143
+ super.postUpdate(cause);
144
+ }
145
+ finally {
146
+ this.currentScope = undefined;
147
+ }
148
+ }
149
+ /**
150
+ * Scope facts for the log line: where the request came from, and which
151
+ * elements it asked for.
152
+ *
153
+ * Origin is read from {@link ServerAction}, the `__receivedFromServer` marker
154
+ * `GLSPModelSource` stamps on inbound actions, rather than from
155
+ * `LocalRequestBoundsAction.is`. The latter would answer the same today, but
156
+ * only incidentally: its `elementIDs` check is declared optional, so it is
157
+ * really just "a bounds request that did not come from the server". Keying on
158
+ * the marker states that directly, and keeps an *unscoped* local request from
159
+ * being mislabelled `server` if GLSP ever tightens that guard.
160
+ */
161
+ formatCause(cause) {
162
+ const origin = client_1.ServerAction.is(cause) ? 'server' : 'local';
163
+ const scope = this.formatScope(cause);
164
+ return scope ? `${origin} scope=${scope}` : origin;
165
+ }
166
+ /**
167
+ * Name the elements a scoped request asked for, or `undefined` when it covers
168
+ * the whole diagram.
169
+ *
170
+ * Deliberately the ids and not their count. A scoped request in practice names
171
+ * a single element, so a count is always `1` and says nothing, while the id
172
+ * says *which* element was re-measured — and it is the only part of the line
173
+ * that distinguishes one such request from the next. It also stops the line
174
+ * reading as a contradiction: `scope=node0, measured=6` is coherent (the base
175
+ * class expands a requested element to its descendants, so one id measures six
176
+ * DOM elements), where `scoped=1, measured=6` invites the reader to wonder
177
+ * which number is wrong.
178
+ *
179
+ * A request naming only the root is treated as unscoped: it measures
180
+ * everything, so the id adds nothing over the absence of a `scope` tag.
181
+ */
182
+ formatScope(cause) {
183
+ const scopedIds = cause.elementIDs;
184
+ if (!scopedIds || scopedIds.length === 0) {
185
+ return undefined;
186
+ }
187
+ const named = scopedIds.filter(id => id !== cause.newRoot?.id);
188
+ if (named.length === 0) {
189
+ return undefined;
190
+ }
191
+ if (named.length > SCOPE_ID_CAP) {
192
+ return `${named.slice(0, SCOPE_ID_CAP).join(',')},+${named.length - SCOPE_ID_CAP} more`;
193
+ }
194
+ return named.join(',');
195
+ }
196
+ };
197
+ exports.HydraniumHiddenBoundsUpdater = HydraniumHiddenBoundsUpdater;
198
+ __decorate([
199
+ (0, inversify_1.inject)(types_1.HydraniumClientTypes.Logger),
200
+ __metadata("design:type", Object)
201
+ ], HydraniumHiddenBoundsUpdater.prototype, "hydraniumLogger", void 0);
202
+ __decorate([
203
+ (0, inversify_1.inject)(types_1.HydraniumClientTypes.Clock),
204
+ (0, inversify_1.optional)(),
205
+ __metadata("design:type", Object)
206
+ ], HydraniumHiddenBoundsUpdater.prototype, "clock", void 0);
207
+ exports.HydraniumHiddenBoundsUpdater = HydraniumHiddenBoundsUpdater = __decorate([
208
+ (0, inversify_1.injectable)()
209
+ ], HydraniumHiddenBoundsUpdater);
210
+ //# sourceMappingURL=hidden-bounds-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hidden-bounds-updater.js","sourceRoot":"","sources":["../src/hidden-bounds-updater.ts"],"names":[],"mappings":"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"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
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
+ export * from './action-dispatcher';
10
+ export * from './diagram-load-failed';
11
+ export * from './diagram-loader';
12
+ export * from './edge';
13
+ export * from './glsp-client';
14
+ export * from './glsp-client-module';
15
+ export * from './hidden-bounds-updater';
16
+ export * from './sprotty-logger-adapter';
17
+ export * from './status-overlay';
18
+ export * from './types';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAOlF,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,40 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ // The host-neutral GLSP client classes and the binder that mounts them. This
26
+ // root is browser-bound, not neutral: it loads `@eclipse-glsp/client`, whose
27
+ // graph imports stylesheets, so it needs a bundler with a CSS loader. It is
28
+ // free of Node and of any host platform, which is the claim `check:neutral`
29
+ // gates.
30
+ __exportStar(require("./action-dispatcher"), exports);
31
+ __exportStar(require("./diagram-load-failed"), exports);
32
+ __exportStar(require("./diagram-loader"), exports);
33
+ __exportStar(require("./edge"), exports);
34
+ __exportStar(require("./glsp-client"), exports);
35
+ __exportStar(require("./glsp-client-module"), exports);
36
+ __exportStar(require("./hidden-bounds-updater"), exports);
37
+ __exportStar(require("./sprotty-logger-adapter"), exports);
38
+ __exportStar(require("./status-overlay"), exports);
39
+ __exportStar(require("./types"), exports);
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,SAAS;AACT,sDAAoC;AACpC,wDAAsC;AACtC,mDAAiC;AACjC,yCAAuB;AACvB,gDAA8B;AAC9B,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,mDAAiC;AACjC,0CAAwB"}
@@ -0,0 +1,10 @@
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
+ export { DIAGRAM_LOAD_FAILED } from '../diagram-load-failed';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AASlF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,20 @@
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.DIAGRAM_LOAD_FAILED = void 0;
12
+ // Every user-facing message `@hydranium/glsp-client` raises. The client tier
13
+ // renders only its own messages, which fire when no server could have worded
14
+ // them: the loader formats the English, and a host that knows the reading
15
+ // user's locale renders the code through its own mechanism instead, as the
16
+ // Theia loader does through `nls`. The barrel is how an adopter rendering their
17
+ // own diagram chrome discovers the codes exist.
18
+ var diagram_load_failed_1 = require("../diagram-load-failed");
19
+ Object.defineProperty(exports, "DIAGRAM_LOAD_FAILED", { enumerable: true, get: function () { return diagram_load_failed_1.DIAGRAM_LOAD_FAILED; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,gFAAgF;AAChF,gDAAgD;AAEhD,8DAA6D;AAApD,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,61 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type ILogger, LogLevel } from '@eclipse-glsp/client';
10
+ import { Logger } from '@hydranium/protocol';
11
+ /**
12
+ * sprotty's `ILogger` over the host's {@link Logger}, so sprotty's own lines
13
+ * reach the same sink as the framework's: a view-registration failure lands in
14
+ * the Theia Output channel beside the action traffic, or on a page's console.
15
+ * sprotty binds a `NullLogger` by default, which drops those failures.
16
+ *
17
+ * sprotty's `error` and `warn` keep their levels and their parameters, where
18
+ * the parameter is the useful part, such as the element type that has no view.
19
+ *
20
+ * Its `info` is diagnosis, chatty on every hover's feedback, so it goes to
21
+ * `debug`; the one anomaly reported there, a request GLSP resolved silently
22
+ * after its timeout, goes to `warn`, where a default threshold shows it.
23
+ *
24
+ * Its `log` fires per action, per command and per render with the whole action
25
+ * or model as a parameter, so it goes to `trace`, where the framework
26
+ * dispatcher logs that traffic. **At `info` and `log` a parameter is reduced to
27
+ * its name**, an action's `kind` or an object's class, never forwarded whole:
28
+ * the Theia channel logger stringifies every parameter as JSON, so forwarding
29
+ * them would write the model into the Output channel on every action.
30
+ *
31
+ * Each line goes through a logger nested under the host's for the calling
32
+ * class, cached per class, so the origin is a tag the host renders inside its
33
+ * own, `[GLSP client :: Viewer]`, not a prefix inside the message. Where
34
+ * sprotty passes a sentence instead of the caller, as its layout registries
35
+ * do, the sentence prefixes the message. The adapter's own `logLevel` is
36
+ * sprotty's most verbose, so only the framework threshold filters; `info` and
37
+ * `log` check it first, since they run on every action and render and would
38
+ * otherwise format a line the threshold drops.
39
+ *
40
+ * Bound by `createGlspClientModule` via `rebind(TYPES.ILogger)`.
41
+ */
42
+ export declare class SprottyLoggerAdapter implements ILogger {
43
+ protected readonly logger: Logger;
44
+ logLevel: LogLevel;
45
+ /** Loggers derived per calling class; sprotty logs from a few dozen classes. */
46
+ protected readonly loggers: Map<string, Logger>;
47
+ error(thisArg: unknown, message: string, ...params: unknown[]): void;
48
+ warn(thisArg: unknown, message: string, ...params: unknown[]): void;
49
+ info(thisArg: unknown, message: string, ...params: unknown[]): void;
50
+ log(thisArg: unknown, message: string, ...params: unknown[]): void;
51
+ /** The host's logger with the calling class nested under its tag, or the
52
+ * host's own when the caller is not an object. */
53
+ protected loggerFor(thisArg: unknown): Logger;
54
+ /** The message, behind the sentence sprotty sometimes passes as the caller,
55
+ * followed by the parameters' names. */
56
+ protected formatMessage(thisArg: unknown, message: string, params?: readonly unknown[]): string;
57
+ /** An action's `kind`, also inside the message GLSP sends an action in, a
58
+ * string as it is, any other object's class, else nothing. */
59
+ protected nameOf(value: unknown): string | undefined;
60
+ }
61
+ //# sourceMappingURL=sprotty-logger-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprotty-logger-adapter.d.ts","sourceRoot":"","sources":["../src/sprotty-logger-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAQ7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,oBAAqB,YAAW,OAAO;IACZ,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAExE,QAAQ,EAAE,QAAQ,CAAgB;IAElC,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,OAAO,sBAA6B;IAEvD,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAEnE;IAED,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAElE;IAED,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAMlE;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAIjE;IAED;uDACmD;IACnD,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAW5C;IAED;6CACyC;IACzC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,OAAO,EAAO,GAAG,MAAM,CAGlG;IAED;mEAC+D;IAC/D,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAenD;CACH"}
@@ -0,0 +1,130 @@
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
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
16
+ var __metadata = (this && this.__metadata) || function (k, v) {
17
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.SprottyLoggerAdapter = void 0;
21
+ const client_1 = require("@eclipse-glsp/client");
22
+ const protocol_1 = require("@hydranium/protocol");
23
+ const inversify_1 = require("inversify");
24
+ const types_1 = require("./types");
25
+ /** GLSP's wording for a request it resolved silently after its timeout. If
26
+ * upstream rewords it, the notice degrades to `debug` with the rest of `info`. */
27
+ const REQUEST_TIMED_OUT = /\btime out after \d+ms\b/;
28
+ /**
29
+ * sprotty's `ILogger` over the host's {@link Logger}, so sprotty's own lines
30
+ * reach the same sink as the framework's: a view-registration failure lands in
31
+ * the Theia Output channel beside the action traffic, or on a page's console.
32
+ * sprotty binds a `NullLogger` by default, which drops those failures.
33
+ *
34
+ * sprotty's `error` and `warn` keep their levels and their parameters, where
35
+ * the parameter is the useful part, such as the element type that has no view.
36
+ *
37
+ * Its `info` is diagnosis, chatty on every hover's feedback, so it goes to
38
+ * `debug`; the one anomaly reported there, a request GLSP resolved silently
39
+ * after its timeout, goes to `warn`, where a default threshold shows it.
40
+ *
41
+ * Its `log` fires per action, per command and per render with the whole action
42
+ * or model as a parameter, so it goes to `trace`, where the framework
43
+ * dispatcher logs that traffic. **At `info` and `log` a parameter is reduced to
44
+ * its name**, an action's `kind` or an object's class, never forwarded whole:
45
+ * the Theia channel logger stringifies every parameter as JSON, so forwarding
46
+ * them would write the model into the Output channel on every action.
47
+ *
48
+ * Each line goes through a logger nested under the host's for the calling
49
+ * class, cached per class, so the origin is a tag the host renders inside its
50
+ * own, `[GLSP client :: Viewer]`, not a prefix inside the message. Where
51
+ * sprotty passes a sentence instead of the caller, as its layout registries
52
+ * do, the sentence prefixes the message. The adapter's own `logLevel` is
53
+ * sprotty's most verbose, so only the framework threshold filters; `info` and
54
+ * `log` check it first, since they run on every action and render and would
55
+ * otherwise format a line the threshold drops.
56
+ *
57
+ * Bound by `createGlspClientModule` via `rebind(TYPES.ILogger)`.
58
+ */
59
+ let SprottyLoggerAdapter = class SprottyLoggerAdapter {
60
+ logger;
61
+ logLevel = client_1.LogLevel.log;
62
+ /** Loggers derived per calling class; sprotty logs from a few dozen classes. */
63
+ loggers = new Map();
64
+ error(thisArg, message, ...params) {
65
+ this.loggerFor(thisArg).error(this.formatMessage(thisArg, message), ...params);
66
+ }
67
+ warn(thisArg, message, ...params) {
68
+ this.loggerFor(thisArg).warn(this.formatMessage(thisArg, message), ...params);
69
+ }
70
+ info(thisArg, message, ...params) {
71
+ if (REQUEST_TIMED_OUT.test(message)) {
72
+ this.loggerFor(thisArg).warn(this.formatMessage(thisArg, message, params));
73
+ }
74
+ else if (protocol_1.Logger.isLevelEnabled('debug')) {
75
+ this.loggerFor(thisArg).debug(this.formatMessage(thisArg, message, params));
76
+ }
77
+ }
78
+ log(thisArg, message, ...params) {
79
+ if (protocol_1.Logger.isLevelEnabled('trace')) {
80
+ this.loggerFor(thisArg).trace(this.formatMessage(thisArg, message, params));
81
+ }
82
+ }
83
+ /** The host's logger with the calling class nested under its tag, or the
84
+ * host's own when the caller is not an object. */
85
+ loggerFor(thisArg) {
86
+ const caller = typeof thisArg === 'object' && thisArg !== null ? this.nameOf(thisArg) : undefined;
87
+ if (caller === undefined) {
88
+ return this.logger;
89
+ }
90
+ let derived = this.loggers.get(caller);
91
+ if (derived === undefined) {
92
+ derived = this.logger.sub(caller);
93
+ this.loggers.set(caller, derived);
94
+ }
95
+ return derived;
96
+ }
97
+ /** The message, behind the sentence sprotty sometimes passes as the caller,
98
+ * followed by the parameters' names. */
99
+ formatMessage(thisArg, message, params = []) {
100
+ const text = typeof thisArg === 'string' ? `${thisArg}${message}` : message;
101
+ return [text, ...params.map(param => this.nameOf(param)).filter(name => name !== undefined)].join(' ');
102
+ }
103
+ /** An action's `kind`, also inside the message GLSP sends an action in, a
104
+ * string as it is, any other object's class, else nothing. */
105
+ nameOf(value) {
106
+ if (typeof value === 'string') {
107
+ return value;
108
+ }
109
+ if (typeof value !== 'object' || value === null) {
110
+ return undefined;
111
+ }
112
+ const { kind, action } = value;
113
+ if (typeof kind === 'string') {
114
+ return kind;
115
+ }
116
+ if (typeof action?.kind === 'string') {
117
+ return action.kind;
118
+ }
119
+ return value.constructor?.name;
120
+ }
121
+ };
122
+ exports.SprottyLoggerAdapter = SprottyLoggerAdapter;
123
+ __decorate([
124
+ (0, inversify_1.inject)(types_1.HydraniumClientTypes.Logger),
125
+ __metadata("design:type", Object)
126
+ ], SprottyLoggerAdapter.prototype, "logger", void 0);
127
+ exports.SprottyLoggerAdapter = SprottyLoggerAdapter = __decorate([
128
+ (0, inversify_1.injectable)()
129
+ ], SprottyLoggerAdapter);
130
+ //# sourceMappingURL=sprotty-logger-adapter.js.map