@hydranium/glsp-server 1.0.0-next.10
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/LICENSE +21 -0
- package/README.md +97 -0
- package/lib/browser/index.d.ts +10 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +15 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/start-glsp-server-in-worker.d.ts +121 -0
- package/lib/browser/start-glsp-server-in-worker.d.ts.map +1 -0
- package/lib/browser/start-glsp-server-in-worker.js +102 -0
- package/lib/browser/start-glsp-server-in-worker.js.map +1 -0
- package/lib/command/hydranium-glsp-recording-command.d.ts +132 -0
- package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-recording-command.js +159 -0
- package/lib/command/hydranium-glsp-recording-command.js.map +1 -0
- package/lib/command/index.d.ts +10 -0
- package/lib/command/index.d.ts.map +1 -0
- package/lib/command/index.js +10 -0
- package/lib/command/index.js.map +1 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts +61 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js +93 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js.map +1 -0
- package/lib/computed-bounds/index.d.ts +10 -0
- package/lib/computed-bounds/index.d.ts.map +1 -0
- package/lib/computed-bounds/index.js +10 -0
- package/lib/computed-bounds/index.js.map +1 -0
- package/lib/dispatcher/index.d.ts +10 -0
- package/lib/dispatcher/index.d.ts.map +1 -0
- package/lib/dispatcher/index.js +10 -0
- package/lib/dispatcher/index.js.map +1 -0
- package/lib/dispatcher/server-action-dispatcher.d.ts +52 -0
- package/lib/dispatcher/server-action-dispatcher.d.ts.map +1 -0
- package/lib/dispatcher/server-action-dispatcher.js +79 -0
- package/lib/dispatcher/server-action-dispatcher.js.map +1 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts +75 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts.map +1 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js +100 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js.map +1 -0
- package/lib/launcher/glsp-app-module.d.ts +87 -0
- package/lib/launcher/glsp-app-module.d.ts.map +1 -0
- package/lib/launcher/glsp-app-module.js +71 -0
- package/lib/launcher/glsp-app-module.js.map +1 -0
- package/lib/launcher/glsp-framework-overrides.d.ts +32 -0
- package/lib/launcher/glsp-framework-overrides.d.ts.map +1 -0
- package/lib/launcher/glsp-framework-overrides.js +49 -0
- package/lib/launcher/glsp-framework-overrides.js.map +1 -0
- package/lib/launcher/glsp-server-overrides.d.ts +39 -0
- package/lib/launcher/glsp-server-overrides.d.ts.map +1 -0
- package/lib/launcher/glsp-server-overrides.js +45 -0
- package/lib/launcher/glsp-server-overrides.js.map +1 -0
- package/lib/launcher/hydranium-glsp-server.d.ts +62 -0
- package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -0
- package/lib/launcher/hydranium-glsp-server.js +101 -0
- package/lib/launcher/hydranium-glsp-server.js.map +1 -0
- package/lib/launcher/index.d.ts +12 -0
- package/lib/launcher/index.d.ts.map +1 -0
- package/lib/launcher/index.js +22 -0
- package/lib/launcher/index.js.map +1 -0
- package/lib/logging/glsp-client-logger.d.ts +110 -0
- package/lib/logging/glsp-client-logger.d.ts.map +1 -0
- package/lib/logging/glsp-client-logger.js +151 -0
- package/lib/logging/glsp-client-logger.js.map +1 -0
- package/lib/logging/index.d.ts +10 -0
- package/lib/logging/index.d.ts.map +1 -0
- package/lib/logging/index.js +10 -0
- package/lib/logging/index.js.map +1 -0
- package/lib/node/index.d.ts +10 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +13 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/start-glsp-server.d.ts +122 -0
- package/lib/node/start-glsp-server.d.ts.map +1 -0
- package/lib/node/start-glsp-server.js +103 -0
- package/lib/node/start-glsp-server.js.map +1 -0
- package/lib/state/abstract-hydranium-glsp-state.d.ts +333 -0
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/abstract-hydranium-glsp-state.js +451 -0
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -0
- package/lib/state/full-text-hydranium-glsp-state.d.ts +43 -0
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/full-text-hydranium-glsp-state.js +60 -0
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -0
- package/lib/state/hydranium-glsp-index.d.ts +220 -0
- package/lib/state/hydranium-glsp-index.d.ts.map +1 -0
- package/lib/state/hydranium-glsp-index.js +320 -0
- package/lib/state/hydranium-glsp-index.js.map +1 -0
- package/lib/state/hydranium-shared-core-services.d.ts +90 -0
- package/lib/state/hydranium-shared-core-services.d.ts.map +1 -0
- package/lib/state/hydranium-shared-core-services.js +89 -0
- package/lib/state/hydranium-shared-core-services.js.map +1 -0
- package/lib/state/index.d.ts +17 -0
- package/lib/state/index.d.ts.map +1 -0
- package/lib/state/index.js +17 -0
- package/lib/state/index.js.map +1 -0
- package/lib/state/model-ready-timeout-error.d.ts +28 -0
- package/lib/state/model-ready-timeout-error.d.ts.map +1 -0
- package/lib/state/model-ready-timeout-error.js +36 -0
- package/lib/state/model-ready-timeout-error.js.map +1 -0
- package/lib/state/reconcile-source-model-write.d.ts +43 -0
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -0
- package/lib/state/reconcile-source-model-write.js +47 -0
- package/lib/state/reconcile-source-model-write.js.map +1 -0
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +164 -0
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -0
- package/lib/state/reconciling-multi-document-glsp-state.js +222 -0
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +91 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +129 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -0
- package/lib/storage/hydranium-glsp-storage.d.ts +348 -0
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -0
- package/lib/storage/hydranium-glsp-storage.js +634 -0
- package/lib/storage/hydranium-glsp-storage.js.map +1 -0
- package/lib/storage/index.d.ts +11 -0
- package/lib/storage/index.d.ts.map +1 -0
- package/lib/storage/index.js +11 -0
- package/lib/storage/index.js.map +1 -0
- package/lib/storage/save-conflict-policy.d.ts +56 -0
- package/lib/storage/save-conflict-policy.d.ts.map +1 -0
- package/lib/storage/save-conflict-policy.js +19 -0
- package/lib/storage/save-conflict-policy.js.map +1 -0
- package/lib/submission/hydranium-glsp-submission-handler.d.ts +109 -0
- package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -0
- package/lib/submission/hydranium-glsp-submission-handler.js +157 -0
- package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -0
- package/lib/submission/index.d.ts +10 -0
- package/lib/submission/index.d.ts.map +1 -0
- package/lib/submission/index.js +10 -0
- package/lib/submission/index.js.map +1 -0
- package/lib/testing/glsp-harness.d.ts +170 -0
- package/lib/testing/glsp-harness.d.ts.map +1 -0
- package/lib/testing/glsp-harness.js +231 -0
- package/lib/testing/glsp-harness.js.map +1 -0
- package/lib/testing/index.d.ts +11 -0
- package/lib/testing/index.d.ts.map +1 -0
- package/lib/testing/index.js +13 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/testing/make-noop-glsp-logger.d.ts +42 -0
- package/lib/testing/make-noop-glsp-logger.d.ts.map +1 -0
- package/lib/testing/make-noop-glsp-logger.js +47 -0
- package/lib/testing/make-noop-glsp-logger.js.map +1 -0
- package/lib/util/index.d.ts +10 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +10 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/service-identifier.d.ts +46 -0
- package/lib/util/service-identifier.d.ts.map +1 -0
- package/lib/util/service-identifier.js +47 -0
- package/lib/util/service-identifier.js.map +1 -0
- package/lib/validation/diagnostic-markers.d.ts +48 -0
- package/lib/validation/diagnostic-markers.d.ts.map +1 -0
- package/lib/validation/diagnostic-markers.js +68 -0
- package/lib/validation/diagnostic-markers.js.map +1 -0
- package/lib/validation/hydranium-glsp-model-validator.d.ts +51 -0
- package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -0
- package/lib/validation/hydranium-glsp-model-validator.js +118 -0
- package/lib/validation/hydranium-glsp-model-validator.js.map +1 -0
- package/lib/validation/index.d.ts +11 -0
- package/lib/validation/index.d.ts.map +1 -0
- package/lib/validation/index.js +11 -0
- package/lib/validation/index.js.map +1 -0
- package/package.json +111 -0
- package/src/browser/index.ts +15 -0
- package/src/browser/start-glsp-server-in-worker.ts +202 -0
- package/src/command/hydranium-glsp-recording-command.ts +183 -0
- package/src/command/index.ts +10 -0
- package/src/computed-bounds/hydranium-glsp-computed-bounds-action-handler.ts +103 -0
- package/src/computed-bounds/index.ts +10 -0
- package/src/dispatcher/index.ts +10 -0
- package/src/dispatcher/server-action-dispatcher.ts +72 -0
- package/src/index.ts +20 -0
- package/src/launcher/abstract-hydranium-glsp-diagram-module.ts +117 -0
- package/src/launcher/glsp-app-module.ts +106 -0
- package/src/launcher/glsp-framework-overrides.ts +51 -0
- package/src/launcher/glsp-server-overrides.ts +46 -0
- package/src/launcher/hydranium-glsp-server.ts +104 -0
- package/src/launcher/index.ts +22 -0
- package/src/logging/glsp-client-logger.ts +184 -0
- package/src/logging/index.ts +10 -0
- package/src/node/index.ts +13 -0
- package/src/node/start-glsp-server.ts +214 -0
- package/src/state/abstract-hydranium-glsp-state.ts +503 -0
- package/src/state/full-text-hydranium-glsp-state.ts +63 -0
- package/src/state/hydranium-glsp-index.ts +337 -0
- package/src/state/hydranium-shared-core-services.ts +92 -0
- package/src/state/index.ts +17 -0
- package/src/state/model-ready-timeout-error.ts +33 -0
- package/src/state/reconcile-source-model-write.ts +77 -0
- package/src/state/reconciling-multi-document-glsp-state.ts +248 -0
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +132 -0
- package/src/storage/hydranium-glsp-storage.ts +660 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/save-conflict-policy.ts +52 -0
- package/src/submission/hydranium-glsp-submission-handler.ts +170 -0
- package/src/submission/index.ts +10 -0
- package/src/testing/glsp-harness.ts +422 -0
- package/src/testing/index.ts +14 -0
- package/src/testing/make-noop-glsp-logger.ts +66 -0
- package/src/util/index.ts +10 -0
- package/src/util/service-identifier.ts +49 -0
- package/src/validation/diagnostic-markers.ts +93 -0
- package/src/validation/hydranium-glsp-model-validator.ts +105 -0
- package/src/validation/index.ts +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# `@hydranium/glsp-server`
|
|
2
|
+
|
|
3
|
+
The graphical-editing head of [hydranium](../../README.md): a generic
|
|
4
|
+
[GLSP](https://eclipse.dev/glsp/) server, built on `@eclipse-glsp/server`, that
|
|
5
|
+
treats the shared Langium AST as its source of truth. Installed by the server
|
|
6
|
+
process that already composes [`@hydranium/core`](../core); the translation to
|
|
7
|
+
the diagram model is adopter-side, bound per diagram module.
|
|
8
|
+
|
|
9
|
+
## What it gives you
|
|
10
|
+
|
|
11
|
+
- **DI composition against the shared workspace.** `HydraniumGlspAppModule` binds
|
|
12
|
+
the `HydraniumTypes` token registry onto an already-composed
|
|
13
|
+
`ServerSharedServices` tree and exposes a `configureAdditionalBindings` hook;
|
|
14
|
+
`AbstractHydraniumGlspDiagramModule` and `bindDiagramLanguage` carry the per-diagram
|
|
15
|
+
half.
|
|
16
|
+
- **Base model state, so an adopter binds a factory rather than a lifecycle:**
|
|
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.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @hydranium/glsp-server
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Peers: `@eclipse-glsp/server` and `@eclipse-glsp/protocol`, `inversify` and
|
|
45
|
+
`reflect-metadata` (the DI runtime — import `reflect-metadata` once at your entry
|
|
46
|
+
point), `@hydranium/core`, `@hydranium/protocol`, `@hydranium/langium`,
|
|
47
|
+
`vscode-jsonrpc` and `vscode-languageserver-types`. The only bundled runtime
|
|
48
|
+
dependency is `uuid`. You must already have a composed hydranium shared services
|
|
49
|
+
tree, a grammar, and a GModel factory of your own — there is no framework GModel
|
|
50
|
+
factory.
|
|
51
|
+
|
|
52
|
+
## Exports
|
|
53
|
+
|
|
54
|
+
| subpath | holds | platform |
|
|
55
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
|
|
56
|
+
| `.` | Composition and the head itself: app / diagram modules, state, storage, submission, command, dispatcher, computed-bounds, validation, logging, `serviceIdentifier`. | browser-neutral |
|
|
57
|
+
| `./browser` | `startGlspServerInWorker` and `BrowserGlspServerOptions` — the web-worker bringup on GLSP's `WorkerServerLauncher`. | browser-only |
|
|
58
|
+
| `./node` | `startGlspServer`, `GlspServerOptions`, `StartedGlspServer` — the socket bringup on GLSP's `SocketServerLauncher`. | Node-only |
|
|
59
|
+
| `./testing` | `makeGlspHarness`, `makeNoopGlspLogger`, `makeCapturingGlspLogger`. | browser-neutral |
|
|
60
|
+
|
|
61
|
+
This is the one head with three platform subpaths
|
|
62
|
+
([why](../../docs/concepts/head-module-maps.md#hydraniumglsp-server--graphical-head)). `.` and
|
|
63
|
+
`./testing` are
|
|
64
|
+
gated as browser-neutral in CI (`scripts/check-neutral-bundles.mjs`), which
|
|
65
|
+
depends on `.` naming only the bare `@eclipse-glsp/server` specifier: a slip back
|
|
66
|
+
to a `/node` subpath in the portable tree fails that gate. `./browser` is
|
|
67
|
+
browser-only rather than neutral — no portability is claimed for it. What the
|
|
68
|
+
gate does and does not promise is [what "gated neutral" does and does not promise](../../docs/concepts/browser-hosting.md#a-note-on-what-gated-neutral-does-and-does-not-promise).
|
|
69
|
+
Each subpath also has a `./lib/…` twin for consumers on
|
|
70
|
+
`moduleResolution: "Node"`.
|
|
71
|
+
|
|
72
|
+
## Getting oriented
|
|
73
|
+
|
|
74
|
+
Build the app container, load `HydraniumGlspAppModule` plus your own app modules,
|
|
75
|
+
and hand the result to `startGlspServer` (or `startGlspServerInWorker`, whose
|
|
76
|
+
`context` is a required transferred `MessagePort`). Per diagram open, storage
|
|
77
|
+
loads the document, your GModel factory renders it, and user operations travel
|
|
78
|
+
back into the shared AST through the recording command, after which the GModel is
|
|
79
|
+
re-derived and every listener on that document is notified. The module-by-module
|
|
80
|
+
map is in
|
|
81
|
+
[`docs/concepts/head-module-maps.md`](../../docs/concepts/head-module-maps.md);
|
|
82
|
+
the worker bringup and its two bundler accommodations are in
|
|
83
|
+
[`docs/concepts/browser-hosting.md`](../../docs/concepts/browser-hosting.md); the
|
|
84
|
+
framework/adopter seams are in
|
|
85
|
+
[`docs/concepts/framework-vs-adopter.md`](../../docs/concepts/framework-vs-adopter.md).
|
|
86
|
+
The Theia-side client wiring lives in `@hydranium/glsp-client-theia`.
|
|
87
|
+
|
|
88
|
+
## Status
|
|
89
|
+
|
|
90
|
+
Alpha — pre-v0, not yet published. The API is not stable and may change without a
|
|
91
|
+
deprecation cycle. See the [repository README](../../README.md) for the current
|
|
92
|
+
status and known limitations.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
`MIT` — see this package's [`LICENSE`](./LICENSE). Third-party notices for the
|
|
97
|
+
repository are recorded in [`NOTICE.md`](../../NOTICE.md).
|
|
@@ -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 * from './start-glsp-server-in-worker.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAOlF,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
// Browser-only entry (`@hydranium/glsp-server/browser`). Holds the worker
|
|
10
|
+
// launcher, which binds GLSP's `WorkerServerLauncher` from
|
|
11
|
+
// `@eclipse-glsp/server/browser`. The portable `.` entry stays free of that
|
|
12
|
+
// import for the same reason it stays free of the node one: it must resolve
|
|
13
|
+
// under both platforms, and a build that names one has picked.
|
|
14
|
+
export * from './start-glsp-server-in-worker.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,0EAA0E;AAC1E,2DAA2D;AAC3D,4EAA4E;AAC5E,4EAA4E;AAC5E,+DAA+D;AAC/D,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 Logger as GlspLogger, type ServerModule } from '@eclipse-glsp/server/browser.js';
|
|
10
|
+
import { type ContainerModule } from 'inversify';
|
|
11
|
+
import type { Logger } from '@hydranium/protocol';
|
|
12
|
+
import type { IntegratedServer } from '@hydranium/core';
|
|
13
|
+
/**
|
|
14
|
+
* A `MessagePort` the host transferred into the worker, described structurally.
|
|
15
|
+
*
|
|
16
|
+
* This package inherits `tsconfig.base.json`'s `lib: ["ES2022"]` and so compiles
|
|
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.
|
|
20
|
+
*
|
|
21
|
+
* **The member set is chosen to admit a `MessagePort` and REJECT a `Worker` or
|
|
22
|
+
* the worker global**, both of which the launcher's own reader would otherwise
|
|
23
|
+
* accept. Only a port needs starting, so `start` is what tells the three apart,
|
|
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.
|
|
39
|
+
*/
|
|
40
|
+
export interface TransferredMessagePort {
|
|
41
|
+
postMessage(message: unknown): void;
|
|
42
|
+
addEventListener(type: 'message', listener: (event: unknown) => void, options?: unknown): void;
|
|
43
|
+
start(): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link startGlspServerInWorker}.
|
|
47
|
+
*
|
|
48
|
+
* The socket variant's options have no counterpart here and are deliberately
|
|
49
|
+
* absent rather than ignored: there is no port to bind, none to discover, and
|
|
50
|
+
* so nothing to publish over an LSP connection.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link startGlspServerInWorker} for the lifecycle semantics.
|
|
53
|
+
*/
|
|
54
|
+
export interface BrowserGlspServerOptions {
|
|
55
|
+
/**
|
|
56
|
+
* The port the host transferred into the worker for this head.
|
|
57
|
+
*
|
|
58
|
+
* **Required, and that is the whole point.** GLSP's
|
|
59
|
+
* `WorkerServerLauncher.createConnection` falls back to the worker global
|
|
60
|
+
* when it is omitted, and a head on the global receives every other head's
|
|
61
|
+
* traffic — `BrowserMessageReader` filters nothing, so this is not a race
|
|
62
|
+
* under load but every message delivered to the wrong reader. The global is
|
|
63
|
+
* unusable even for a single head, because the launcher posts its startup
|
|
64
|
+
* string through the global `postMessage` regardless of the connection it
|
|
65
|
+
* was given, and no JSON-RPC reader can parse that.
|
|
66
|
+
*/
|
|
67
|
+
readonly context: TransferredMessagePort;
|
|
68
|
+
/**
|
|
69
|
+
* Adopter-supplied logger factory. Called once per Inversify resolution
|
|
70
|
+
* (with `caller` set to the requesting parent's class name) AND once
|
|
71
|
+
* per `LoggerFactory` invocation.
|
|
72
|
+
*
|
|
73
|
+
* The GLSP log threshold is a property of the logger this returns, and there
|
|
74
|
+
* is deliberately no launcher-level `logLevel` beside it — see the socket
|
|
75
|
+
* variant's note on the same member.
|
|
76
|
+
*/
|
|
77
|
+
readonly createLogger: (caller?: string) => GlspLogger;
|
|
78
|
+
/**
|
|
79
|
+
* The GLSP {@link ServerModule} with per-diagram modules pre-configured via
|
|
80
|
+
* `new ServerModule().configureDiagramModule(...)`.
|
|
81
|
+
*/
|
|
82
|
+
readonly serverModule: ServerModule;
|
|
83
|
+
/**
|
|
84
|
+
* Additional Inversify modules to load on the app container AFTER GLSP's
|
|
85
|
+
* own app module and the framework overrides. Adopters wire language-services
|
|
86
|
+
* bindings (e.g. their own shared-services symbol) here.
|
|
87
|
+
*/
|
|
88
|
+
readonly appModules?: ReadonlyArray<ContainerModule>;
|
|
89
|
+
/**
|
|
90
|
+
* Optional framework-lifecycle logger, for the launcher's own bringup and
|
|
91
|
+
* failure lines. The GLSP container's logger handles application-level logs.
|
|
92
|
+
*/
|
|
93
|
+
readonly logger?: Logger;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Start a GLSP head on a transferred `MessagePort` inside a web worker, with no
|
|
97
|
+
* Node runtime and no backend process.
|
|
98
|
+
*
|
|
99
|
+
* The worker counterpart of `startGlspServer`,
|
|
100
|
+
* and deliberately a separate function rather than a mode of it. The two share
|
|
101
|
+
* a shape — app module, framework overrides, adopter modules, resolve launcher,
|
|
102
|
+
* configure the {@link ServerModule}, start — and almost nothing else: a
|
|
103
|
+
* different launcher, a different upstream `createAppModule` whose options carry
|
|
104
|
+
* no `fileLog`, and no `'listening'` event to resolve readiness on. Over half of
|
|
105
|
+
* the socket options are meaningless here, so threading a flag would leave a
|
|
106
|
+
* function whose contract depends on which branch the caller is in.
|
|
107
|
+
*
|
|
108
|
+
* Returns an {@link IntegratedServer} — the socket variant's `port` is the one
|
|
109
|
+
* member a worker head has no answer for, so it is absent rather than
|
|
110
|
+
* `undefined`.
|
|
111
|
+
*
|
|
112
|
+
* - `started` resolves once the launcher has built its connection and the
|
|
113
|
+
* server instance behind it, which is CHECKED rather than assumed — see
|
|
114
|
+
* below. There is no transport handshake to wait on: the port arrived live,
|
|
115
|
+
* and the launcher's own readiness signal is a string it posts on the worker
|
|
116
|
+
* global, which nothing here reads.
|
|
117
|
+
* - `stopped` resolves when the connection closes, and rejects on a connection
|
|
118
|
+
* error.
|
|
119
|
+
*/
|
|
120
|
+
export declare function startGlspServerInWorker(options: BrowserGlspServerOptions): IntegratedServer;
|
|
121
|
+
//# sourceMappingURL=start-glsp-server-in-worker.d.ts.map
|
|
@@ -0,0 +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,EAInB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,sBAAsB;IACpC,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/F,KAAK,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACtC;;;;;;;;;;;OAWG;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;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACrD;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CAsE3F"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { WorkerServerLauncher, createAppModule } from '@eclipse-glsp/server/browser.js';
|
|
10
|
+
import { Container } from 'inversify';
|
|
11
|
+
import { createGlspFrameworkOverrides } from '../launcher/glsp-framework-overrides.js';
|
|
12
|
+
import { createGlspServerOverrides } from '../launcher/glsp-server-overrides.js';
|
|
13
|
+
/**
|
|
14
|
+
* Start a GLSP head on a transferred `MessagePort` inside a web worker, with no
|
|
15
|
+
* Node runtime and no backend process.
|
|
16
|
+
*
|
|
17
|
+
* The worker counterpart of `startGlspServer`,
|
|
18
|
+
* and deliberately a separate function rather than a mode of it. The two share
|
|
19
|
+
* a shape — app module, framework overrides, adopter modules, resolve launcher,
|
|
20
|
+
* configure the {@link ServerModule}, start — and almost nothing else: a
|
|
21
|
+
* different launcher, a different upstream `createAppModule` whose options carry
|
|
22
|
+
* no `fileLog`, and no `'listening'` event to resolve readiness on. Over half of
|
|
23
|
+
* the socket options are meaningless here, so threading a flag would leave a
|
|
24
|
+
* function whose contract depends on which branch the caller is in.
|
|
25
|
+
*
|
|
26
|
+
* Returns an {@link IntegratedServer} — the socket variant's `port` is the one
|
|
27
|
+
* member a worker head has no answer for, so it is absent rather than
|
|
28
|
+
* `undefined`.
|
|
29
|
+
*
|
|
30
|
+
* - `started` resolves once the launcher has built its connection and the
|
|
31
|
+
* server instance behind it, which is CHECKED rather than assumed — see
|
|
32
|
+
* below. There is no transport handshake to wait on: the port arrived live,
|
|
33
|
+
* and the launcher's own readiness signal is a string it posts on the worker
|
|
34
|
+
* global, which nothing here reads.
|
|
35
|
+
* - `stopped` resolves when the connection closes, and rejects on a connection
|
|
36
|
+
* error.
|
|
37
|
+
*/
|
|
38
|
+
export function startGlspServerInWorker(options) {
|
|
39
|
+
const lifecycle = options.logger;
|
|
40
|
+
// GLSP's own app module first, as on Node, so the framework tracks the
|
|
41
|
+
// resolved GLSP version's app bindings instead of re-deriving them. This is
|
|
42
|
+
// the BROWSER build's `createAppModule`, whose options are `LoggerConfigOptions`
|
|
43
|
+
// — no `fileLog`, because there is no file to log to. `consoleLog` is forced
|
|
44
|
+
// off so GLSP binds a throwaway NullLogger; the overrides below replace it
|
|
45
|
+
// with the adopter's, which is also why no log level is passed here: with
|
|
46
|
+
// `consoleLog` off, GLSP discards it, and the binding it would have
|
|
47
|
+
// configured is unbound a line later.
|
|
48
|
+
const glspAppModule = createAppModule({ consoleLog: false });
|
|
49
|
+
const appContainer = new Container();
|
|
50
|
+
appContainer.load(glspAppModule, createGlspFrameworkOverrides(options.createLogger), ...(options.appModules ?? []));
|
|
51
|
+
const launcher = appContainer.resolve(WorkerServerLauncher);
|
|
52
|
+
// Additional module rather than an app-container binding, as on Node: the
|
|
53
|
+
// launcher loads these into the per-connection SERVER container, the only
|
|
54
|
+
// tier where the adopter's `ServerModule` binding of `GLSPServer` is
|
|
55
|
+
// rebindable.
|
|
56
|
+
launcher.configure(options.serverModule, createGlspServerOverrides());
|
|
57
|
+
try {
|
|
58
|
+
// Upstream declares `WorkerLaunchOptions.context` as `Worker`, narrower
|
|
59
|
+
// than the `MessagePort | Worker | DedicatedWorkerGlobalScope` its own
|
|
60
|
+
// `BrowserMessageReader` accepts — so the value that is CORRECT here is
|
|
61
|
+
// the one the declaration names as wrong.
|
|
62
|
+
//
|
|
63
|
+
// **The cast is currently redundant, and is kept deliberately.** `Worker`
|
|
64
|
+
// does not resolve under this package's `lib`, so `skipLibCheck` leaves
|
|
65
|
+
// the option an error type and the assignment compiles without it —
|
|
66
|
+
// measured, not assumed. Removing it would mean this file type-checks by
|
|
67
|
+
// the same accident that let upstream's own `?? self` default pass, and
|
|
68
|
+
// would break the day the name resolves. The cast states the intent
|
|
69
|
+
// instead, and costs one line to do so.
|
|
70
|
+
const launchOptions = { context: options.context };
|
|
71
|
+
// `start` resolves only when the connection closes, so it is the `stopped`
|
|
72
|
+
// promise. The launcher builds the connection and the server instance
|
|
73
|
+
// synchronously before returning it, which is what makes "we got here"
|
|
74
|
+
// equal to "accepting traffic".
|
|
75
|
+
const stoppedPromise = Promise.resolve(launcher.start(launchOptions));
|
|
76
|
+
// Attached here and not left to the caller: a worker has no console
|
|
77
|
+
// anyone is watching, so a connection error on a `stopped` nobody awaits
|
|
78
|
+
// becomes an unhandled rejection that reaches no one. The handler also
|
|
79
|
+
// marks the promise handled, which the caller's own `await` still sees.
|
|
80
|
+
stoppedPromise.catch((error) => lifecycle?.error('[GlspServer] Worker connection error:', error));
|
|
81
|
+
// The `started`-equals-synchronous-construction assumption above is
|
|
82
|
+
// upstream's, so it is verified rather than trusted: `run` awaiting
|
|
83
|
+
// anything before building the connection would leave `started` resolving
|
|
84
|
+
// on a head that cannot yet answer, and a client's first request would
|
|
85
|
+
// hang with nothing logged. The field is `protected`, reached by property
|
|
86
|
+
// indexing as the socket launcher's `netServer` is.
|
|
87
|
+
const connection = launcher.connection;
|
|
88
|
+
if (connection === undefined) {
|
|
89
|
+
const error = new Error('startGlspServerInWorker: the launcher built no connection synchronously — ' +
|
|
90
|
+
'WorkerServerLauncher.run has become asynchronous and readiness now needs a real signal');
|
|
91
|
+
lifecycle?.error(`[GlspServer] ${error.message}`);
|
|
92
|
+
return { started: Promise.reject(error), stopped: stoppedPromise };
|
|
93
|
+
}
|
|
94
|
+
lifecycle?.info('[GlspServer] Ready to accept client requests on the transferred port');
|
|
95
|
+
return { started: Promise.resolve(), stopped: stoppedPromise };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
lifecycle?.error('Error in GLSP server worker launcher:', error);
|
|
99
|
+
return { started: Promise.reject(error), stopped: Promise.resolve() };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=start-glsp-server-in-worker.js.map
|
|
@@ -0,0 +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;AAElF,OAAO,EAIJ,oBAAoB,EACpB,eAAe,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAG5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAsFjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAiC;IACtE,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjC,uEAAuE;IACvE,4EAA4E;IAC5E,iFAAiF;IACjF,6EAA6E;IAC7E,2EAA2E;IAC3E,0EAA0E;IAC1E,oEAAoE;IACpE,sCAAsC;IACtC,MAAM,aAAa,GAAG,eAAe,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG,IAAI,SAAS,EAAE,CAAC;IACrC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,4BAA4B,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpH,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAuB,oBAAoB,CAAC,CAAC;IAClF,0EAA0E;IAC1E,0EAA0E;IAC1E,qEAAqE;IACrE,cAAc;IACd,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAEtE,IAAI,CAAC;QACF,wEAAwE;QACxE,uEAAuE;QACvE,wEAAwE;QACxE,0CAA0C;QAC1C,EAAE;QACF,0EAA0E;QAC1E,wEAAwE;QACxE,oEAAoE;QACpE,yEAAyE;QACzE,wEAAwE;QACxE,oEAAoE;QACpE,wCAAwC;QACxC,MAAM,aAAa,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAoC,CAAC;QACrF,2EAA2E;QAC3E,sEAAsE;QACtE,uEAAuE;QACvE,gCAAgC;QAChC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACtE,oEAAoE;QACpE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,cAAc,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC,CAAC;QAE3G,oEAAoE;QACpE,oEAAoE;QACpE,0EAA0E;QAC1E,uEAAuE;QACvE,0EAA0E;QAC1E,oDAAoD;QACpD,MAAM,UAAU,GAAI,QAAgD,CAAC,UAAU,CAAC;QAChF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,KAAK,CACpB,4EAA4E;gBACzE,wFAAwF,CAC7F,CAAC;YACF,SAAS,EAAE,KAAK,CAAC,gBAAgB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;QACtE,CAAC;QAED,SAAS,EAAE,IAAI,CAAC,sEAAsE,CAAC,CAAC;QACxF,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACd,SAAS,EAAE,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IACzE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023-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 AnyObject, type JsonModelState, JsonRecordingCommand, type MaybePromise } from '@eclipse-glsp/server';
|
|
10
|
+
import { type AstNode } from '@hydranium/langium';
|
|
11
|
+
import { type AbstractHydraniumGlspState } from '../state/abstract-hydranium-glsp-state.js';
|
|
12
|
+
/**
|
|
13
|
+
* Source-model state shape consumed by {@link HydraniumGlspRecordingCommand}.
|
|
14
|
+
* The intersection ties together GLSP's read-side
|
|
15
|
+
* {@link JsonModelState.sourceModel} getter with the framework's typed
|
|
16
|
+
* `logger` and `sourceUri` accessors (used for time-labelled logging) and
|
|
17
|
+
* the lifted `updateSourceModel` abstract from
|
|
18
|
+
* {@link AbstractHydraniumGlspState.updateSourceModel}. Adopter states satisfy both
|
|
19
|
+
* naturally by implementing `JsonModelState<TSourceModel>` on
|
|
20
|
+
* their framework-state subclass.
|
|
21
|
+
*/
|
|
22
|
+
export type HydraniumGlspRecordingState<TSourceModel extends AnyObject> = AbstractHydraniumGlspState<AstNode, TSourceModel> & JsonModelState<TSourceModel>;
|
|
23
|
+
/**
|
|
24
|
+
* GLSP {@link JsonRecordingCommand} base shared by all hydranium adopters.
|
|
25
|
+
* Adds two things on top of GLSP's class:
|
|
26
|
+
*
|
|
27
|
+
* 1. A **time-labelled execute wrapper** so log lines record how long a
|
|
28
|
+
* user-facing operation takes end-to-end — including the `postChange`
|
|
29
|
+
* source-model update that re-parses the document. Otherwise the diff +
|
|
30
|
+
* patch + persist work happens silently and is hard to attribute when
|
|
31
|
+
* something is slow.
|
|
32
|
+
* 2. A typed `state` field that exposes `updateSourceModel` for the
|
|
33
|
+
* `postChange` bridge AND the framework `logger` for time-labelled
|
|
34
|
+
* logging. GLSP's base class only types `modelState: JsonModelState`,
|
|
35
|
+
* which lacks the framework's logger surface.
|
|
36
|
+
*
|
|
37
|
+
* **Optional undo/redo bridge hooks.** An adopter command can supply
|
|
38
|
+
* `undoAction` / `redoAction` callbacks invoked alongside the patch apply, to
|
|
39
|
+
* re-emit a side-effect the patch itself does not carry. Provided as optional
|
|
40
|
+
* constructor args so adopters get that composition surface without
|
|
41
|
+
* subclassing. Operation handlers that don't need bridge callbacks omit them.
|
|
42
|
+
*
|
|
43
|
+
* **postChange semantics.** GLSP's `JsonRecordingCommand.postChange` calls
|
|
44
|
+
* `modelState.updateSourceModel(newModel)` with the model only. The
|
|
45
|
+
* framework lift overrides `postChange` so it also threads the based-on
|
|
46
|
+
* version captured at command start — letting the downstream
|
|
47
|
+
* `ModelService.update` opt into the `ConflictError` gate. Undo / redo
|
|
48
|
+
* postChange calls run with version `undefined` (no gating): the user
|
|
49
|
+
* authored against the recorded patch, not against a specific server
|
|
50
|
+
* version, so re-applying it should succeed regardless of intervening
|
|
51
|
+
* edits. The recorded patch itself encodes the semantic intent.
|
|
52
|
+
*/
|
|
53
|
+
export declare class HydraniumGlspRecordingCommand<TSourceModel extends AnyObject> extends JsonRecordingCommand<TSourceModel> {
|
|
54
|
+
/** Human-readable label for the operation; appears in the timing-pair log line. */
|
|
55
|
+
protected readonly label: string;
|
|
56
|
+
/** Optional bridge invoked alongside undo patch application; for adopters
|
|
57
|
+
* that need to re-emit a side-effect the patch does not carry. */
|
|
58
|
+
protected readonly undoAction?: (() => MaybePromise<void>) | undefined;
|
|
59
|
+
/** Optional bridge invoked alongside redo patch application. */
|
|
60
|
+
protected readonly redoAction?: (() => MaybePromise<void>) | undefined;
|
|
61
|
+
protected modelState: HydraniumGlspRecordingState<TSourceModel>;
|
|
62
|
+
/**
|
|
63
|
+
* Based-on version captured at {@link execute} start; threaded into
|
|
64
|
+
* {@link postChange} so {@link AbstractHydraniumGlspState.updateSourceModel}
|
|
65
|
+
* sees the version the user authored against. Cleared after `execute`
|
|
66
|
+
* returns so undo / redo paths fall through to `updateSourceModel`
|
|
67
|
+
* without a version (no gating).
|
|
68
|
+
*/
|
|
69
|
+
protected activeVersion?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Source-model snapshots captured at {@link execute} — the state the
|
|
72
|
+
* command left ({@link afterSnapshot}) and the state it started from
|
|
73
|
+
* ({@link beforeSnapshot}). {@link undo} / {@link redo} reconcile the
|
|
74
|
+
* recorded transition against the *current* source model via the state's
|
|
75
|
+
* {@link AbstractHydraniumGlspState.conflictResolver}, so under the default
|
|
76
|
+
* reconciling policy a concurrent edit to another field survives and a
|
|
77
|
+
* same-field collision is dropped rather than clobbered.
|
|
78
|
+
*/
|
|
79
|
+
protected beforeSnapshot?: TSourceModel;
|
|
80
|
+
protected afterSnapshot?: TSourceModel;
|
|
81
|
+
constructor(modelState: HydraniumGlspRecordingState<TSourceModel>,
|
|
82
|
+
/** Human-readable label for the operation; appears in the timing-pair log line. */
|
|
83
|
+
label: string, doExecute: () => MaybePromise<void>,
|
|
84
|
+
/** Optional bridge invoked alongside undo patch application; for adopters
|
|
85
|
+
* that need to re-emit a side-effect the patch does not carry. */
|
|
86
|
+
undoAction?: (() => MaybePromise<void>) | undefined,
|
|
87
|
+
/** Optional bridge invoked alongside redo patch application. */
|
|
88
|
+
redoAction?: (() => MaybePromise<void>) | undefined);
|
|
89
|
+
/**
|
|
90
|
+
* Time-label the full execute path: pre-state snapshot + `doExecute` +
|
|
91
|
+
* post-state snapshot + patch-derive + `postChange` (which writes back
|
|
92
|
+
* via {@link AbstractHydraniumGlspState.updateSourceModel}). The label combines
|
|
93
|
+
* the operation name with the source-uri-stamped logger.
|
|
94
|
+
*
|
|
95
|
+
* Captures {@link AbstractHydraniumGlspState.version} at start so {@link postChange}
|
|
96
|
+
* can thread the based-on version into `updateSourceModel`. The capture
|
|
97
|
+
* is `try`/`finally`-scoped so undo / redo paths invoked later do not
|
|
98
|
+
* see a stale captured version.
|
|
99
|
+
*/
|
|
100
|
+
execute(): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Override of GLSP's {@link JsonRecordingCommand.postChange} so the
|
|
103
|
+
* call to {@link AbstractHydraniumGlspState.updateSourceModel} threads the
|
|
104
|
+
* captured based-on version alongside the new model.
|
|
105
|
+
*
|
|
106
|
+
* During {@link execute} the version is the snapshot captured at
|
|
107
|
+
* command start; during {@link undo} / {@link redo} it is `undefined`
|
|
108
|
+
* — replaying a recorded patch does not author against a specific
|
|
109
|
+
* server version, so no gate applies.
|
|
110
|
+
*/
|
|
111
|
+
protected postChange(newModel: TSourceModel): MaybePromise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reconcile the recorded `after → before` transition against the
|
|
114
|
+
* *current* source model via the state's
|
|
115
|
+
* {@link AbstractHydraniumGlspState.conflictResolver}, invoke the optional adopter
|
|
116
|
+
* `undoAction`, and persist via `postChange`. Under the default reconciling
|
|
117
|
+
* policy the revert is replayed guarded by `test` ops, so a concurrent edit
|
|
118
|
+
* to another field is preserved (merged) and a same-field collision is
|
|
119
|
+
* dropped rather than clobbered; a force policy clobbers (last-writer-wins).
|
|
120
|
+
* On anything but a clean merge the undo is a logged no-op — the side-effect
|
|
121
|
+
* bridge and `postChange` only run on a merged result, preserving a
|
|
122
|
+
* "bridge before commit" order.
|
|
123
|
+
*/
|
|
124
|
+
undo(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Reconcile the recorded `before → after` transition against the current
|
|
127
|
+
* source model, invoke the optional adopter `redoAction`, and persist via
|
|
128
|
+
* `postChange`. Same guarded merge / drop semantics as {@link undo}.
|
|
129
|
+
*/
|
|
130
|
+
redo(): Promise<void>;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=hydranium-glsp-recording-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydranium-glsp-recording-command.d.ts","sourceRoot":"","sources":["../../src/command/hydranium-glsp-recording-command.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAE5F;;;;;;;;;GASG;AACH,MAAM,MAAM,2BAA2B,CAAC,YAAY,SAAS,SAAS,IAAI,0BAA0B,CAAC,OAAO,EAAE,YAAY,CAAC,GACxH,cAAc,CAAC,YAAY,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,6BAA6B,CAAC,YAAY,SAAS,SAAS,CAAE,SAAQ,oBAAoB,CAAC,YAAY,CAAC;IA0B/G,mFAAmF;IACnF,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAEhC;uEACmE;IACnE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAE,MAAM,YAAY,CAAC,IAAI,CAAC;IACxD,gEAAgE;IAChE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAE,MAAM,YAAY,CAAC,IAAI,CAAC;IAhC3D,UAAkB,UAAU,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEjC;;;;;;;;OAQG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC;gBAGpC,UAAU,EAAE,2BAA2B,CAAC,YAAY,CAAC;IACrD,mFAAmF;IAChE,KAAK,EAAE,MAAM,EAChC,SAAS,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC;IACnC;uEACmE;IAChD,UAAU,CAAC,GAAE,MAAM,YAAY,CAAC,IAAI,CAAC,aAAA;IACxD,gEAAgE;IAC7C,UAAU,CAAC,GAAE,MAAM,YAAY,CAAC,IAAI,CAAC,aAAA;IAK3D;;;;;;;;;;OAUG;IACY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAavC;;;;;;;;;OASG;cACgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC;IAIzE;;;;;;;;;;;OAWG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBpC;;;;OAIG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBtC"}
|