@hydranium/glsp-server 1.0.0-next.31 → 1.0.0-next.315
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 +80 -88
- package/lib/browser/start-glsp-server-in-worker.d.ts +43 -42
- package/lib/browser/start-glsp-server-in-worker.d.ts.map +1 -1
- package/lib/browser/start-glsp-server-in-worker.js +62 -13
- package/lib/browser/start-glsp-server-in-worker.js.map +1 -1
- package/lib/command/diagram-edit-dropped-error.d.ts +31 -0
- package/lib/command/diagram-edit-dropped-error.d.ts.map +1 -0
- package/lib/command/diagram-edit-dropped-error.js +48 -0
- package/lib/command/diagram-edit-dropped-error.js.map +1 -0
- package/lib/command/hydranium-glsp-command-stack.d.ts +33 -0
- package/lib/command/hydranium-glsp-command-stack.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-command-stack.js +63 -0
- package/lib/command/hydranium-glsp-command-stack.js.map +1 -0
- package/lib/command/hydranium-glsp-operation-action-handler.d.ts +64 -0
- package/lib/command/hydranium-glsp-operation-action-handler.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-operation-action-handler.js +142 -0
- package/lib/command/hydranium-glsp-operation-action-handler.js.map +1 -0
- package/lib/command/hydranium-glsp-operation-command.d.ts +250 -0
- package/lib/command/hydranium-glsp-operation-command.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-operation-command.js +491 -0
- package/lib/command/hydranium-glsp-operation-command.js.map +1 -0
- package/lib/command/hydranium-glsp-recording-command.d.ts +26 -87
- package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
- package/lib/command/hydranium-glsp-recording-command.js +40 -117
- package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
- package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts +23 -0
- package/lib/command/hydranium-glsp-undo-redo-action-handler.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-undo-redo-action-handler.js +41 -0
- package/lib/command/hydranium-glsp-undo-redo-action-handler.js.map +1 -0
- package/lib/command/index.d.ts +5 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +5 -0
- package/lib/command/index.js.map +1 -1
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts +1 -1
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts.map +1 -1
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js +2 -2
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js.map +1 -1
- package/lib/dispatcher/server-action-dispatcher.d.ts +25 -24
- package/lib/dispatcher/server-action-dispatcher.d.ts.map +1 -1
- package/lib/dispatcher/server-action-dispatcher.js +38 -26
- package/lib/dispatcher/server-action-dispatcher.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts +35 -59
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts.map +1 -1
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js +60 -71
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js.map +1 -1
- package/lib/launcher/drop-notifications-to-gone-client.d.ts +23 -0
- package/lib/launcher/drop-notifications-to-gone-client.d.ts.map +1 -0
- package/lib/launcher/drop-notifications-to-gone-client.js +43 -0
- package/lib/launcher/drop-notifications-to-gone-client.js.map +1 -0
- package/lib/launcher/glsp-app-module.d.ts +1 -2
- package/lib/launcher/glsp-app-module.d.ts.map +1 -1
- package/lib/launcher/glsp-app-module.js.map +1 -1
- package/lib/launcher/glsp-connection-logger.d.ts +19 -0
- package/lib/launcher/glsp-connection-logger.d.ts.map +1 -0
- package/lib/launcher/glsp-connection-logger.js +24 -0
- package/lib/launcher/glsp-connection-logger.js.map +1 -0
- package/lib/launcher/glsp-server-overrides.d.ts +10 -8
- package/lib/launcher/glsp-server-overrides.d.ts.map +1 -1
- package/lib/launcher/glsp-server-overrides.js +25 -11
- package/lib/launcher/glsp-server-overrides.js.map +1 -1
- package/lib/launcher/hydranium-glsp-server.d.ts +60 -15
- package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -1
- package/lib/launcher/hydranium-glsp-server.js +145 -22
- package/lib/launcher/hydranium-glsp-server.js.map +1 -1
- package/lib/launcher/index.d.ts +2 -0
- package/lib/launcher/index.d.ts.map +1 -1
- package/lib/launcher/index.js +5 -4
- package/lib/launcher/index.js.map +1 -1
- package/lib/logging/glsp-client-logger.d.ts +10 -6
- package/lib/logging/glsp-client-logger.d.ts.map +1 -1
- package/lib/logging/glsp-client-logger.js +14 -7
- package/lib/logging/glsp-client-logger.js.map +1 -1
- package/lib/messages/index.d.ts +11 -6
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +11 -6
- package/lib/messages/index.js.map +1 -1
- package/lib/node/start-glsp-server.d.ts +50 -15
- package/lib/node/start-glsp-server.d.ts.map +1 -1
- package/lib/node/start-glsp-server.js +97 -30
- package/lib/node/start-glsp-server.js.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.d.ts +326 -102
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.js +529 -139
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
- package/lib/state/diagram-status.d.ts +38 -0
- package/lib/state/diagram-status.d.ts.map +1 -0
- package/lib/state/diagram-status.js +27 -0
- package/lib/state/diagram-status.js.map +1 -0
- package/lib/state/full-text-hydranium-glsp-state.d.ts +22 -9
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.js +45 -18
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
- package/lib/state/hydranium-glsp-index.d.ts +40 -29
- package/lib/state/hydranium-glsp-index.d.ts.map +1 -1
- package/lib/state/hydranium-glsp-index.js +82 -45
- package/lib/state/hydranium-glsp-index.js.map +1 -1
- package/lib/state/hydranium-shared-core-services.d.ts +16 -29
- package/lib/state/hydranium-shared-core-services.d.ts.map +1 -1
- package/lib/state/hydranium-shared-core-services.js +15 -28
- package/lib/state/hydranium-shared-core-services.js.map +1 -1
- package/lib/state/index.d.ts +1 -0
- package/lib/state/index.d.ts.map +1 -1
- package/lib/state/index.js +1 -0
- package/lib/state/index.js.map +1 -1
- package/lib/state/model-ready-timeout-error.d.ts.map +1 -1
- package/lib/state/model-ready-timeout-error.js.map +1 -1
- package/lib/state/reconcile-source-model-write.d.ts +13 -27
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
- package/lib/state/reconcile-source-model-write.js +44 -32
- package/lib/state/reconcile-source-model-write.js.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +125 -69
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.js +242 -100
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +36 -28
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +59 -42
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
- package/lib/status/diagram-status-reporter.d.ts +44 -0
- package/lib/status/diagram-status-reporter.d.ts.map +1 -0
- package/lib/status/diagram-status-reporter.js +88 -0
- package/lib/status/diagram-status-reporter.js.map +1 -0
- package/lib/status/hydranium-glsp-request-model-action-handler.d.ts +27 -0
- package/lib/status/hydranium-glsp-request-model-action-handler.d.ts.map +1 -0
- package/lib/status/hydranium-glsp-request-model-action-handler.js +52 -0
- package/lib/status/hydranium-glsp-request-model-action-handler.js.map +1 -0
- package/lib/status/hydranium-glsp-set-edit-mode-action-handler.d.ts +27 -0
- package/lib/status/hydranium-glsp-set-edit-mode-action-handler.d.ts.map +1 -0
- package/lib/status/hydranium-glsp-set-edit-mode-action-handler.js +53 -0
- package/lib/status/hydranium-glsp-set-edit-mode-action-handler.js.map +1 -0
- package/lib/status/index.d.ts +12 -0
- package/lib/status/index.d.ts.map +1 -0
- package/lib/status/index.js +12 -0
- package/lib/status/index.js.map +1 -0
- package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts +30 -0
- package/lib/storage/hydranium-glsp-request-save-model-action-handler.d.ts.map +1 -0
- package/lib/storage/hydranium-glsp-request-save-model-action-handler.js +47 -0
- package/lib/storage/hydranium-glsp-request-save-model-action-handler.js.map +1 -0
- package/lib/storage/hydranium-glsp-storage.d.ts +324 -143
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
- package/lib/storage/hydranium-glsp-storage.js +569 -213
- package/lib/storage/hydranium-glsp-storage.js.map +1 -1
- package/lib/storage/index.d.ts +2 -1
- package/lib/storage/index.d.ts.map +1 -1
- package/lib/storage/index.js +2 -1
- package/lib/storage/index.js.map +1 -1
- package/lib/storage/save-delivery-policy.d.ts +51 -0
- package/lib/storage/save-delivery-policy.d.ts.map +1 -0
- package/lib/storage/{save-conflict-policy.js → save-delivery-policy.js} +7 -8
- package/lib/storage/save-delivery-policy.js.map +1 -0
- package/lib/submission/hydranium-glsp-submission-handler.d.ts +44 -4
- package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -1
- package/lib/submission/hydranium-glsp-submission-handler.js +82 -6
- package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -1
- package/lib/testing/glsp-harness.d.ts +34 -7
- package/lib/testing/glsp-harness.d.ts.map +1 -1
- package/lib/testing/glsp-harness.js +47 -19
- package/lib/testing/glsp-harness.js.map +1 -1
- package/lib/validation/diagnostic-markers.d.ts +3 -3
- package/lib/validation/diagnostic-markers.d.ts.map +1 -1
- package/lib/validation/diagnostic-markers.js +1 -1
- package/lib/validation/diagnostic-markers.js.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.d.ts +1 -2
- package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js.map +1 -1
- package/package.json +31 -52
- package/src/browser/start-glsp-server-in-worker.ts +79 -51
- package/src/command/diagram-edit-dropped-error.ts +51 -0
- package/src/command/hydranium-glsp-command-stack.ts +47 -0
- package/src/command/hydranium-glsp-operation-action-handler.ts +141 -0
- package/src/command/hydranium-glsp-operation-command.ts +602 -0
- package/src/command/hydranium-glsp-recording-command.ts +40 -121
- package/src/command/hydranium-glsp-undo-redo-action-handler.ts +29 -0
- package/src/command/index.ts +10 -0
- package/src/computed-bounds/hydranium-glsp-computed-bounds-action-handler.ts +2 -2
- package/src/dispatcher/server-action-dispatcher.ts +39 -31
- package/src/index.ts +1 -0
- package/src/launcher/abstract-hydranium-glsp-diagram-module.ts +79 -91
- package/src/launcher/drop-notifications-to-gone-client.ts +47 -0
- package/src/launcher/glsp-app-module.ts +1 -2
- package/src/launcher/glsp-connection-logger.ts +27 -0
- package/src/launcher/glsp-server-overrides.ts +27 -11
- package/src/launcher/hydranium-glsp-server.ts +153 -23
- package/src/launcher/index.ts +5 -4
- package/src/logging/glsp-client-logger.ts +16 -9
- package/src/messages/index.ts +16 -6
- package/src/node/start-glsp-server.ts +133 -40
- package/src/state/abstract-hydranium-glsp-state.ts +609 -154
- package/src/state/diagram-status.ts +41 -0
- package/src/state/full-text-hydranium-glsp-state.ts +46 -18
- package/src/state/hydranium-glsp-index.ts +85 -41
- package/src/state/hydranium-shared-core-services.ts +16 -29
- package/src/state/index.ts +1 -0
- package/src/state/reconcile-source-model-write.ts +51 -53
- package/src/state/reconciling-multi-document-glsp-state.ts +276 -102
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +67 -45
- package/src/status/diagram-status-reporter.ts +106 -0
- package/src/status/hydranium-glsp-request-model-action-handler.ts +43 -0
- package/src/status/hydranium-glsp-set-edit-mode-action-handler.ts +38 -0
- package/src/status/index.ts +12 -0
- package/src/storage/hydranium-glsp-request-save-model-action-handler.ts +40 -0
- package/src/storage/hydranium-glsp-storage.ts +647 -223
- package/src/storage/index.ts +2 -1
- package/src/storage/save-delivery-policy.ts +49 -0
- package/src/submission/hydranium-glsp-submission-handler.ts +91 -5
- package/src/testing/glsp-harness.ts +67 -25
- package/src/validation/diagnostic-markers.ts +3 -3
- package/src/validation/hydranium-glsp-model-validator.ts +4 -5
- package/lib/storage/save-conflict-policy.d.ts +0 -56
- package/lib/storage/save-conflict-policy.d.ts.map +0 -1
- package/lib/storage/save-conflict-policy.js.map +0 -1
- package/src/storage/save-conflict-policy.ts +0 -52
package/README.md
CHANGED
|
@@ -1,39 +1,20 @@
|
|
|
1
1
|
# `@hydranium/glsp-server`
|
|
2
2
|
|
|
3
|
-
The graphical-editing head of
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
The graphical-editing head of
|
|
4
|
+
[Hydranium](https://github.com/eclipse-emfcloud/hydranium): a
|
|
5
|
+
[GLSP](https://eclipse.dev/glsp/) server that draws diagrams from your model
|
|
6
|
+
and writes their edits back to it. Install it in the server that composes
|
|
7
|
+
`@hydranium/core`; `@hydranium/glsp-client` is its client in any host, and
|
|
8
|
+
`@hydranium/glsp-client-theia` in Theia.
|
|
8
9
|
|
|
9
10
|
## What it gives you
|
|
10
11
|
|
|
11
|
-
-
|
|
12
|
-
the
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`AbstractHydraniumGlspState`, with the ready-made
|
|
18
|
-
`ReconcilingTransferHydraniumGlspState`, `ReconcilingMultiDocumentGlspState`
|
|
19
|
-
and `FullTextHydraniumGlspState` specialisations, plus `HydraniumGlspIndex`
|
|
20
|
-
over the GModel.
|
|
21
|
-
- **Load / save against the live AST.** `HydraniumGlspStorage` loads a document
|
|
22
|
-
on diagram open and writes user operations back through the shared model
|
|
23
|
-
coordination layer, with `SaveConflictPolicy` deciding what a concurrent
|
|
24
|
-
external write means. `HydraniumGlspRecordingCommand` is the operation-handler
|
|
25
|
-
seam — the framework provides no base handler class.
|
|
26
|
-
- **A submission and dispatch lifecycle that waits for the model.**
|
|
27
|
-
`HydraniumGlspSubmissionHandler` gates submit on the readiness event,
|
|
28
|
-
`HydraniumGlspServerActionDispatcher` adds timing and direction to dispatch,
|
|
29
|
-
and `HydraniumGlspComputedBoundsActionHandler` is handshake-aware.
|
|
30
|
-
- **Diagram diagnostics for free.** `HydraniumGlspModelValidator` and
|
|
31
|
-
`diagnosticsToMarkers` project the language server's diagnostics onto GLSP
|
|
32
|
-
markers, so a validation error shows on the diagram and in the text editor from
|
|
33
|
-
one source.
|
|
34
|
-
- **Two bringups from one composition:** `startGlspServer` over a socket at
|
|
35
|
-
`./node`, `startGlspServerInWorker` over a transferred `MessagePort` at
|
|
36
|
-
`./browser`. Both load the same framework overrides and adopter app modules.
|
|
12
|
+
- Diagrams on the same workspace as the text editor: an edit in the diagram is
|
|
13
|
+
written to the shared document, and every other head sees it.
|
|
14
|
+
- A per-diagram module and base classes for its state, storage and submission.
|
|
15
|
+
You write the GModel factory and the operation handlers.
|
|
16
|
+
- The language's diagnostics as markers on the diagram, when you bind
|
|
17
|
+
`HydraniumGlspModelValidator` as the diagram's model validator.
|
|
37
18
|
|
|
38
19
|
## Install
|
|
39
20
|
|
|
@@ -41,66 +22,77 @@ the diagram model is adopter-side, bound per diagram module.
|
|
|
41
22
|
npm install @hydranium/glsp-server
|
|
42
23
|
```
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
25
|
+
| Peer | Range |
|
|
26
|
+
| ----------------------------- | ------------- |
|
|
27
|
+
| `@eclipse-glsp/server` | `^2.6.0` |
|
|
28
|
+
| `@hydranium/core` | `^1.0.0-next` |
|
|
29
|
+
| `@hydranium/langium` | `^1.0.0-next` |
|
|
30
|
+
| `@hydranium/protocol` | `^1.0.0-next` |
|
|
31
|
+
| `inversify` | `^6.0.0` |
|
|
32
|
+
| `reflect-metadata` | `^0.2.2` |
|
|
33
|
+
| `vscode-jsonrpc` | `^9.0.0` |
|
|
34
|
+
| `vscode-languageserver-types` | `^3.17.5` |
|
|
35
|
+
|
|
36
|
+
Import `reflect-metadata` once, first, in your server's entry point: the DI
|
|
37
|
+
decorators need it.
|
|
38
|
+
|
|
39
|
+
## Wiring
|
|
40
|
+
|
|
41
|
+
1. Subclass `AbstractHydraniumGlspDiagramModule` per diagram, and bind your
|
|
42
|
+
model state, storage, submission handler, configuration and GModel factory.
|
|
43
|
+
2. Start the head on the shared services with `startGlspServer` from `./node`:
|
|
44
|
+
your diagram modules in `serverModule`,
|
|
45
|
+
`new HydraniumGlspAppModule({ shared })` in `appModules`, and a
|
|
46
|
+
`GlspClientLogger` from `createLogger`. Pass `lspConnection` and
|
|
47
|
+
`portCommand` to tell the client its port. Without an LSP head, pass the
|
|
48
|
+
workspace root as `workspace`: the head brings the workspace up before it
|
|
49
|
+
listens.
|
|
50
|
+
3. In a browser, start it with `startGlspServerInWorker` from `./browser`
|
|
51
|
+
instead, on a transferred `MessagePort`.
|
|
52
|
+
|
|
53
|
+
See *Make a diagram editable* and *Host in a browser* in
|
|
54
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
55
|
+
|
|
56
|
+
## Things to know
|
|
57
|
+
|
|
58
|
+
- **Replace the launcher with `rebind`.** Each head binds GLSP's launcher token
|
|
59
|
+
before your `appModules` load, so a second `bind` fails the start with
|
|
60
|
+
`Ambiguous match found for serviceIdentifier`.
|
|
61
|
+
- **A replacement launcher extends the Hydranium one**,
|
|
62
|
+
`HydraniumGlspSocketServerLauncher` or `HydraniumGlspWorkerServerLauncher`.
|
|
63
|
+
If it overrides `createConnection`, it passes
|
|
64
|
+
`createGlspConnectionLogger(this.logger)` as the connection's logger, or the
|
|
65
|
+
connection logs to `console` or nowhere instead of your logger. It also wraps
|
|
66
|
+
the result in `dropNotificationsToGoneClient(connection, this.logger)`, or
|
|
67
|
+
every client that disconnects leaves an unhandled rejection in the server.
|
|
68
|
+
- **GLSP brings its own copy of `vscode-jsonrpc`.** A typed message built by
|
|
69
|
+
one copy and sent over a connection from another throws
|
|
70
|
+
`Unknown parameter structure auto`. Wrap a connection you hand GLSP, or send
|
|
71
|
+
GLSP's typed messages over, with `sendByMethodName` from
|
|
72
|
+
`@hydranium/protocol`.
|
|
73
|
+
|
|
74
|
+
## Entry points
|
|
75
|
+
|
|
76
|
+
| Subpath | Use it for | Runs in |
|
|
77
|
+
| ------------ | ------------------------------------------------------------ | --------------- |
|
|
78
|
+
| `.` | The app and diagram modules and the bases you subclass | browser-neutral |
|
|
79
|
+
| `./browser` | Starting the head in a web worker | browser-only |
|
|
80
|
+
| `./node` | Starting the head on a socket | Node-only |
|
|
81
|
+
| `./messages` | The codes of the messages this package raises | browser-neutral |
|
|
82
|
+
| `./testing` | A harness and logger doubles for diagram tests | browser-neutral |
|
|
83
|
+
|
|
84
|
+
The subpaths need a TypeScript `moduleResolution` that reads `exports`
|
|
85
|
+
(`NodeNext` or `Bundler`); see *Requirements* in
|
|
86
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
96
87
|
|
|
97
88
|
## Status
|
|
98
89
|
|
|
99
|
-
Alpha
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
Alpha: every release is a prerelease that may break the API, so pin an exact
|
|
91
|
+
version. Guides and known limitations:
|
|
92
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
102
93
|
|
|
103
94
|
## License
|
|
104
95
|
|
|
105
|
-
`MIT` — see this package's [`LICENSE`](./LICENSE)
|
|
106
|
-
|
|
96
|
+
`MIT` — see this package's [`LICENSE`](./LICENSE), and the repository
|
|
97
|
+
[`NOTICE.md`](https://github.com/eclipse-emfcloud/hydranium/blob/main/NOTICE.md)
|
|
98
|
+
for third-party notices.
|
|
@@ -6,42 +6,39 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { type Logger as GlspLogger, type ServerModule } from '@eclipse-glsp/server/browser.js';
|
|
10
|
-
import {
|
|
11
|
-
import type
|
|
9
|
+
import { type Logger as GlspLogger, type ServerModule, type WorkerLaunchOptions, WorkerServerLauncher } from '@eclipse-glsp/server/browser.js';
|
|
10
|
+
import { ContainerModule } from 'inversify';
|
|
11
|
+
import { type Logger, type TransferredMessagePort } from '@hydranium/protocol';
|
|
12
12
|
import type { IntegratedServer } from '@hydranium/core';
|
|
13
|
+
export type { TransferredMessagePort } from '@hydranium/protocol';
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* The default worker launcher of {@link startGlspServerInWorker}: GLSP's
|
|
16
|
+
* own, with its connection built over `createMessagePortTransport` rather than
|
|
17
|
+
* over `BrowserMessageReader`/`BrowserMessageWriter`, which never report a
|
|
18
|
+
* close. So the client disposing its connection closes this one, and upstream
|
|
19
|
+
* disposes the server instance, and with it every client session, as it does
|
|
20
|
+
* when a socket closes.
|
|
15
21
|
*
|
|
16
|
-
*
|
|
17
|
-
* without the DOM lib, which is what keeps `document` / `window` compile errors
|
|
18
|
-
* here — so `MessagePort` has no name either and the contract has to be spelled
|
|
19
|
-
* out.
|
|
22
|
+
* Requires `context`: unlike upstream it never falls back to the worker global.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* and naming it here turns "never bind a head to the global" from a rule in a
|
|
25
|
-
* document into a compile error at the call site.
|
|
26
|
-
*
|
|
27
|
-
* **That compile error happens at the ADOPTER, not here.** This project resolves
|
|
28
|
-
* neither `MessagePort` nor `Worker` as a type, so nothing in this package can
|
|
29
|
-
* demonstrate the rejection; a host compiling its worker against `lib.webworker`
|
|
30
|
-
* (or a page against `lib.dom`) is where the names resolve and the guard bites.
|
|
31
|
-
* Measured there: passing the worker global fails with `Property 'start' is
|
|
32
|
-
* missing in type 'DedicatedWorkerGlobalScope'`.
|
|
33
|
-
*
|
|
34
|
-
* `addEventListener` is not a discriminator — `postMessage` plus `start` already
|
|
35
|
-
* excludes the other two — and nothing in this module calls any of the three
|
|
36
|
-
* (the reader assigns `onmessage`, which starts a port implicitly). It is listed
|
|
37
|
-
* because it is part of what the reader uses, so the interface reads as the
|
|
38
|
-
* contract rather than as a minimal trick.
|
|
24
|
+
* The connection sends GLSP's typed messages by method name: it comes from this
|
|
25
|
+
* package's copy of `vscode-jsonrpc` and the types from GLSP's own copy, and a
|
|
26
|
+
* type sent over another copy's connection throws.
|
|
39
27
|
*/
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
addEventListener(type: 'message', listener: (event: unknown) => void, options?: unknown): void;
|
|
43
|
-
start(): void;
|
|
28
|
+
export declare class HydraniumGlspWorkerServerLauncher extends WorkerServerLauncher {
|
|
29
|
+
protected createConnection(options: WorkerLaunchOptions): ReturnType<WorkerServerLauncher['createConnection']>;
|
|
44
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Binds GLSP's own `WorkerServerLauncher` token to
|
|
33
|
+
* {@link HydraniumGlspWorkerServerLauncher}. {@link startGlspServerInWorker}
|
|
34
|
+
* loads it before the adopter's `appModules`, so an adopter replaces the launcher
|
|
35
|
+
* with `rebind`; a second `bind` makes the resolve ambiguous and the start throws.
|
|
36
|
+
* A replacement extends {@link HydraniumGlspWorkerServerLauncher}: GLSP's own
|
|
37
|
+
* launcher builds its connection from GLSP's copy, so framework errors lose
|
|
38
|
+
* their code, and GLSP's typed messages throw where its packages nest
|
|
39
|
+
* separate copies.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createGlspWorkerLauncherModule(): ContainerModule;
|
|
45
42
|
/**
|
|
46
43
|
* Options for {@link startGlspServerInWorker}.
|
|
47
44
|
*
|
|
@@ -55,14 +52,15 @@ export interface BrowserGlspServerOptions {
|
|
|
55
52
|
/**
|
|
56
53
|
* The port the host transferred into the worker for this head.
|
|
57
54
|
*
|
|
58
|
-
* **Required
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
55
|
+
* **Required: the worker global is no substitute.** A head on the global
|
|
56
|
+
* receives every other head's traffic — a reader filters nothing, so this is
|
|
57
|
+
* not a race under load but every message delivered to the wrong reader — and
|
|
58
|
+
* GLSP's launcher posts its startup string through the global `postMessage`
|
|
59
|
+
* regardless of the connection it was given, which no JSON-RPC reader parses.
|
|
60
|
+
* Unlike upstream's, this head's launcher never falls back to the global.
|
|
61
|
+
*
|
|
62
|
+
* The page's end must connect through `createMessagePortTransport` as well:
|
|
63
|
+
* the head reads its close signal from the port, and posts one on it.
|
|
66
64
|
*/
|
|
67
65
|
readonly context: TransferredMessagePort;
|
|
68
66
|
/**
|
|
@@ -82,8 +80,10 @@ export interface BrowserGlspServerOptions {
|
|
|
82
80
|
readonly serverModule: ServerModule;
|
|
83
81
|
/**
|
|
84
82
|
* Additional Inversify modules to load on the app container AFTER GLSP's
|
|
85
|
-
* own app module
|
|
86
|
-
*
|
|
83
|
+
* own app module, the framework overrides and
|
|
84
|
+
* {@link createGlspWorkerLauncherModule}. Adopters wire language-services
|
|
85
|
+
* bindings (e.g. their own shared-services symbol) here, and replace the
|
|
86
|
+
* launcher with `rebind`.
|
|
87
87
|
*/
|
|
88
88
|
readonly appModules?: ReadonlyArray<ContainerModule>;
|
|
89
89
|
/**
|
|
@@ -114,8 +114,9 @@ export interface BrowserGlspServerOptions {
|
|
|
114
114
|
* below. There is no transport handshake to wait on: the port arrived live,
|
|
115
115
|
* and the launcher's own readiness signal is a string it posts on the worker
|
|
116
116
|
* global, which nothing here reads.
|
|
117
|
-
* - `stopped` resolves when the connection closes,
|
|
118
|
-
* error.
|
|
117
|
+
* - `stopped` resolves when the connection closes, which the client disposing
|
|
118
|
+
* its connection causes, and rejects on a connection error. Nothing reports a
|
|
119
|
+
* page that dies, because the port cannot.
|
|
119
120
|
*/
|
|
120
121
|
export declare function startGlspServerInWorker(options: BrowserGlspServerOptions): IntegratedServer;
|
|
121
122
|
//# sourceMappingURL=start-glsp-server-in-worker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-glsp-server-in-worker.d.ts","sourceRoot":"","sources":["../../src/browser/start-glsp-server-in-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"start-glsp-server-in-worker.d.ts","sourceRoot":"","sources":["../../src/browser/start-glsp-server-in-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,oBAAoB,EAEtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAa,eAAe,EAAc,MAAM,WAAW,CAAC;AACnE,OAAO,EAIJ,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,qBACa,iCAAkC,SAAQ,oBAAoB;IACxE,UAAmB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,UAAU,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAMtH;CACH;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,IAAI,eAAe,CAIhE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACtC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;IACvD;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACrD;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CA0E3F"}
|
|
@@ -6,10 +6,59 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
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;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
9
15
|
import { WorkerServerLauncher, createAppModule } from '@eclipse-glsp/server/browser.js';
|
|
10
|
-
import { Container } from 'inversify';
|
|
16
|
+
import { Container, ContainerModule, injectable } from 'inversify';
|
|
17
|
+
import { createMessagePortTransport, describeErrorWithStack, sendByMethodName } from '@hydranium/protocol';
|
|
18
|
+
import { createMessageConnection } from 'vscode-jsonrpc/browser';
|
|
19
|
+
import { dropNotificationsToGoneClient } from '../launcher/drop-notifications-to-gone-client.js';
|
|
20
|
+
import { createGlspConnectionLogger } from '../launcher/glsp-connection-logger.js';
|
|
11
21
|
import { createGlspFrameworkOverrides } from '../launcher/glsp-framework-overrides.js';
|
|
12
22
|
import { createGlspServerOverrides } from '../launcher/glsp-server-overrides.js';
|
|
23
|
+
/**
|
|
24
|
+
* The default worker launcher of {@link startGlspServerInWorker}: GLSP's
|
|
25
|
+
* own, with its connection built over `createMessagePortTransport` rather than
|
|
26
|
+
* over `BrowserMessageReader`/`BrowserMessageWriter`, which never report a
|
|
27
|
+
* close. So the client disposing its connection closes this one, and upstream
|
|
28
|
+
* disposes the server instance, and with it every client session, as it does
|
|
29
|
+
* when a socket closes.
|
|
30
|
+
*
|
|
31
|
+
* Requires `context`: unlike upstream it never falls back to the worker global.
|
|
32
|
+
*
|
|
33
|
+
* The connection sends GLSP's typed messages by method name: it comes from this
|
|
34
|
+
* package's copy of `vscode-jsonrpc` and the types from GLSP's own copy, and a
|
|
35
|
+
* type sent over another copy's connection throws.
|
|
36
|
+
*/
|
|
37
|
+
let HydraniumGlspWorkerServerLauncher = class HydraniumGlspWorkerServerLauncher extends WorkerServerLauncher {
|
|
38
|
+
createConnection(options) {
|
|
39
|
+
const transport = createMessagePortTransport(options.context);
|
|
40
|
+
return dropNotificationsToGoneClient(sendByMethodName(createMessageConnection(transport.reader, transport.writer, createGlspConnectionLogger(this.logger))), this.logger);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
HydraniumGlspWorkerServerLauncher = __decorate([
|
|
44
|
+
injectable()
|
|
45
|
+
], HydraniumGlspWorkerServerLauncher);
|
|
46
|
+
export { HydraniumGlspWorkerServerLauncher };
|
|
47
|
+
/**
|
|
48
|
+
* Binds GLSP's own `WorkerServerLauncher` token to
|
|
49
|
+
* {@link HydraniumGlspWorkerServerLauncher}. {@link startGlspServerInWorker}
|
|
50
|
+
* loads it before the adopter's `appModules`, so an adopter replaces the launcher
|
|
51
|
+
* with `rebind`; a second `bind` makes the resolve ambiguous and the start throws.
|
|
52
|
+
* A replacement extends {@link HydraniumGlspWorkerServerLauncher}: GLSP's own
|
|
53
|
+
* launcher builds its connection from GLSP's copy, so framework errors lose
|
|
54
|
+
* their code, and GLSP's typed messages throw where its packages nest
|
|
55
|
+
* separate copies.
|
|
56
|
+
*/
|
|
57
|
+
export function createGlspWorkerLauncherModule() {
|
|
58
|
+
return new ContainerModule(bind => {
|
|
59
|
+
bind(WorkerServerLauncher).to(HydraniumGlspWorkerServerLauncher);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
13
62
|
/**
|
|
14
63
|
* Start a GLSP head on a transferred `MessagePort` inside a web worker, with no
|
|
15
64
|
* Node runtime and no backend process.
|
|
@@ -32,8 +81,9 @@ import { createGlspServerOverrides } from '../launcher/glsp-server-overrides.js'
|
|
|
32
81
|
* below. There is no transport handshake to wait on: the port arrived live,
|
|
33
82
|
* and the launcher's own readiness signal is a string it posts on the worker
|
|
34
83
|
* global, which nothing here reads.
|
|
35
|
-
* - `stopped` resolves when the connection closes,
|
|
36
|
-
* error.
|
|
84
|
+
* - `stopped` resolves when the connection closes, which the client disposing
|
|
85
|
+
* its connection causes, and rejects on a connection error. Nothing reports a
|
|
86
|
+
* page that dies, because the port cannot.
|
|
37
87
|
*/
|
|
38
88
|
export function startGlspServerInWorker(options) {
|
|
39
89
|
const lifecycle = options.logger;
|
|
@@ -47,18 +97,17 @@ export function startGlspServerInWorker(options) {
|
|
|
47
97
|
// configured is unbound a line later.
|
|
48
98
|
const glspAppModule = createAppModule({ consoleLog: false });
|
|
49
99
|
const appContainer = new Container();
|
|
50
|
-
appContainer.load(glspAppModule, createGlspFrameworkOverrides(options.createLogger), ...(options.appModules ?? []));
|
|
51
|
-
const launcher = appContainer.
|
|
100
|
+
appContainer.load(glspAppModule, createGlspFrameworkOverrides(options.createLogger), createGlspWorkerLauncherModule(), ...(options.appModules ?? []));
|
|
101
|
+
const launcher = appContainer.get(WorkerServerLauncher);
|
|
52
102
|
// Additional module rather than an app-container binding, as on Node: the
|
|
53
|
-
// launcher loads these into the per-connection SERVER container, the
|
|
54
|
-
//
|
|
55
|
-
// rebindable.
|
|
103
|
+
// launcher loads these into the per-connection SERVER container, the tier
|
|
104
|
+
// where each connection gets a server of its own.
|
|
56
105
|
launcher.configure(options.serverModule, createGlspServerOverrides());
|
|
57
106
|
try {
|
|
58
|
-
// Upstream declares `WorkerLaunchOptions.context` as `Worker`,
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
107
|
+
// Upstream declares `WorkerLaunchOptions.context` as `Worker`, and
|
|
108
|
+
// `HydraniumGlspWorkerServerLauncher.createConnection` reads it as a
|
|
109
|
+
// port — so the value that is CORRECT here is the one the declaration
|
|
110
|
+
// names as wrong.
|
|
62
111
|
//
|
|
63
112
|
// **The cast is currently redundant, and is kept deliberately.** `Worker`
|
|
64
113
|
// does not resolve under this package's `lib`, so `skipLibCheck` leaves
|
|
@@ -88,7 +137,7 @@ export function startGlspServerInWorker(options) {
|
|
|
88
137
|
if (connection === undefined) {
|
|
89
138
|
const error = new Error('startGlspServerInWorker: the launcher built no connection synchronously — ' +
|
|
90
139
|
'WorkerServerLauncher.run has become asynchronous and readiness now needs a real signal');
|
|
91
|
-
lifecycle?.error(`[GlspServer] ${error
|
|
140
|
+
lifecycle?.error(`[GlspServer] ${describeErrorWithStack(error)}`);
|
|
92
141
|
return { started: Promise.reject(error), stopped: stoppedPromise };
|
|
93
142
|
}
|
|
94
143
|
lifecycle?.info('[GlspServer] Ready to accept client requests on the transferred port');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-glsp-server-in-worker.js","sourceRoot":"","sources":["../../src/browser/start-glsp-server-in-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"start-glsp-server-in-worker.js","sourceRoot":"","sources":["../../src/browser/start-glsp-server-in-worker.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { type Action, type Logger } from '@eclipse-glsp/server';
|
|
10
|
+
/**
|
|
11
|
+
* Thrown when the reconcile of a diagram edit's write dropped it: a foreign
|
|
12
|
+
* edit changed a field the edit writes. Declined by design rather than failed,
|
|
13
|
+
* and the reconcile has logged it, so whoever ends it tells the client without
|
|
14
|
+
* logging it again. It never crosses a wire, so it carries no error code.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DiagramEditDroppedError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether `error` is a {@link DiagramEditDroppedError}, by name, so one thrown
|
|
21
|
+
* by another installed copy of this package counts too.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isDiagramEditDroppedError(error: unknown): error is DiagramEditDroppedError;
|
|
24
|
+
/**
|
|
25
|
+
* Log an action that failed, once, at the level of what happened: a dropped
|
|
26
|
+
* edit at `debug`, since its reconcile has logged it, a conflict at `warn`
|
|
27
|
+
* naming its versions, since it was declined, and anything else at `error`.
|
|
28
|
+
* A request is named by its id too, which its client's reject carries.
|
|
29
|
+
*/
|
|
30
|
+
export declare function logActionFailure(logger: Logger, action: Action, error: unknown): void;
|
|
31
|
+
//# sourceMappingURL=diagram-edit-dropped-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram-edit-dropped-error.d.ts","sourceRoot":"","sources":["../../src/command/diagram-edit-dropped-error.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAiB,MAAM,sBAAsB,CAAC;AAG/E;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAC/C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACH;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAE1F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAWrF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import { RequestAction } from '@eclipse-glsp/server';
|
|
10
|
+
import { describeError, describeErrorWithStack, isConflictError } from '@hydranium/protocol';
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when the reconcile of a diagram edit's write dropped it: a foreign
|
|
13
|
+
* edit changed a field the edit writes. Declined by design rather than failed,
|
|
14
|
+
* and the reconcile has logged it, so whoever ends it tells the client without
|
|
15
|
+
* logging it again. It never crosses a wire, so it carries no error code.
|
|
16
|
+
*/
|
|
17
|
+
export class DiagramEditDroppedError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'DiagramEditDroppedError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether `error` is a {@link DiagramEditDroppedError}, by name, so one thrown
|
|
25
|
+
* by another installed copy of this package counts too.
|
|
26
|
+
*/
|
|
27
|
+
export function isDiagramEditDroppedError(error) {
|
|
28
|
+
return error instanceof Error && error.name === 'DiagramEditDroppedError';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Log an action that failed, once, at the level of what happened: a dropped
|
|
32
|
+
* edit at `debug`, since its reconcile has logged it, a conflict at `warn`
|
|
33
|
+
* naming its versions, since it was declined, and anything else at `error`.
|
|
34
|
+
* A request is named by its id too, which its client's reject carries.
|
|
35
|
+
*/
|
|
36
|
+
export function logActionFailure(logger, action, error) {
|
|
37
|
+
const named = `'${action.kind}'${RequestAction.is(action) ? ` (${action.requestId})` : ''}`;
|
|
38
|
+
if (isDiagramEditDroppedError(error)) {
|
|
39
|
+
logger.debug(`Could not process action ${named}: ${describeError(error)}`);
|
|
40
|
+
}
|
|
41
|
+
else if (isConflictError(error)) {
|
|
42
|
+
logger.warn(`Could not process action ${named}: ${describeError(error)} (model v${error.baseVersion} / text v${error.actualVersion})`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
logger.error(`Could not process action ${named}: ${describeErrorWithStack(error)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=diagram-edit-dropped-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram-edit-dropped-error.js","sourceRoot":"","sources":["../../src/command/diagram-edit-dropped-error.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAA4B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACzC,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACrD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,yBAAyB,CAAC;AAC7E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,MAAc,EAAE,KAAc;IAC5E,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC5F,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;SAAM,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CACR,4BAA4B,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,WAAW,YAAY,KAAK,CAAC,aAAa,GAAG,CAC3H,CAAC;IACL,CAAC;SAAM,CAAC;QACL,MAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,KAAK,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { DefaultCommandStack, ModelState } from '@eclipse-glsp/server';
|
|
10
|
+
import { type ServerSharedServices } from '@hydranium/core';
|
|
11
|
+
/**
|
|
12
|
+
* GLSP's command stack with the diagram's dirty state read from the text store:
|
|
13
|
+
* dirty while any document the diagram's client session has open differs from
|
|
14
|
+
* its file, as the store last knew the file. Undo and redo are GLSP's.
|
|
15
|
+
*
|
|
16
|
+
* GLSP's own answer counts the diagram's commands since its last save, so it
|
|
17
|
+
* misses every change the diagram did not make: another client's unsaved edit
|
|
18
|
+
* leaves it clean, and a save it did not make of a document other than the
|
|
19
|
+
* diagram's own leaves it dirty. Every `SetDirtyStateAction` GLSP sends reads
|
|
20
|
+
* this answer.
|
|
21
|
+
*/
|
|
22
|
+
export declare class HydraniumGlspCommandStack extends DefaultCommandStack {
|
|
23
|
+
protected readonly modelState: ModelState;
|
|
24
|
+
protected readonly sharedServices: ServerSharedServices;
|
|
25
|
+
get isDirty(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Lifted from `@eclipse-glsp/server` 2.7.0's `DefaultCommandStack.handleError`
|
|
28
|
+
* without its `error` line: the failure is rethrown, and whoever ends it
|
|
29
|
+
* logs it. The accompanying test pins upstream's source.
|
|
30
|
+
*/
|
|
31
|
+
protected handleError(error: unknown): never;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=hydranium-glsp-command-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydranium-glsp-command-stack.d.ts","sourceRoot":"","sources":["../../src/command/hydranium-glsp-command-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI5D;;;;;;;;;;GAUG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC3C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAG,UAAU,CAAC;IACpB,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAG,oBAAoB,CAAC;IAEpG,IAAa,OAAO,IAAI,OAAO,CAI9B;IAED;;;;OAIG;IACH,UAAmB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAIpD;CACH"}
|