@hydranium/data-server 1.0.0-next.32 → 1.0.0-next.321
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 +57 -73
- 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-data-server-in-worker.d.ts +23 -0
- package/lib/browser/start-data-server-in-worker.d.ts.map +1 -0
- package/lib/browser/start-data-server-in-worker.js +29 -0
- package/lib/browser/start-data-server-in-worker.js.map +1 -0
- package/lib/data-server.d.ts +440 -286
- package/lib/data-server.d.ts.map +1 -1
- package/lib/data-server.js +743 -501
- package/lib/data-server.js.map +1 -1
- package/lib/messages/index.d.ts +1 -1
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +1 -1
- package/lib/messages/index.js.map +1 -1
- package/lib/node/node-diagnostics-provider.d.ts.map +1 -1
- package/lib/node/node-diagnostics-provider.js +2 -1
- package/lib/node/node-diagnostics-provider.js.map +1 -1
- package/lib/testing/data-server-harness.d.ts +31 -14
- package/lib/testing/data-server-harness.d.ts.map +1 -1
- package/lib/testing/data-server-harness.js +8 -3
- package/lib/testing/data-server-harness.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js.map +1 -1
- package/package.json +35 -43
- package/src/browser/index.ts +15 -0
- package/src/browser/start-data-server-in-worker.ts +35 -0
- package/src/data-server.ts +899 -540
- package/src/messages/index.ts +8 -1
- package/src/node/node-diagnostics-provider.ts +2 -8
- package/src/testing/data-server-harness.ts +55 -26
- package/src/testing/index.ts +5 -2
package/README.md
CHANGED
|
@@ -1,42 +1,21 @@
|
|
|
1
1
|
# `@hydranium/data-server`
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[`@hydranium/core`](../core); a client needs only
|
|
8
|
-
[`@hydranium/protocol`](../protocol).
|
|
3
|
+
The data head of [Hydranium](https://github.com/eclipse-emfcloud/hydranium): it
|
|
4
|
+
serves your model over JSON-RPC to clients other than a text editor, such as
|
|
5
|
+
forms, tree views and code generators. Install it in the server that composes
|
|
6
|
+
`@hydranium/core`; a client talks to it through `@hydranium/protocol`.
|
|
9
7
|
|
|
10
8
|
## What it gives you
|
|
11
9
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
`
|
|
20
|
-
`
|
|
21
|
-
`waitForReady` for clients that must not race workspace initialisation.
|
|
22
|
-
- **Push notifications instead of polling:** `onDocumentUpdated` when a
|
|
23
|
-
subscribed document reaches the configured build phase
|
|
24
|
-
(`DataServerOptions.subscriptionPhase`, `DocumentState.Validated` by default),
|
|
25
|
-
`onDocumentSaved` on a separate channel, and `onProjectsChanged` from the
|
|
26
|
-
project registry.
|
|
27
|
-
- **Projects as first-class:** `getProjects` and `getProjectForUri`, answered from
|
|
28
|
-
the framework's `ProjectManager`.
|
|
29
|
-
- **An opt-in reference/naming slice** — `findReferenceCandidates`,
|
|
30
|
-
`resolveReference`, `findNextName` — implemented here but deliberately outside
|
|
31
|
-
the `DataServerProtocol` composition, so a pure data consumer does not pay for
|
|
32
|
-
it. Compose `ReferenceServerProtocol` onto the connection explicitly.
|
|
33
|
-
- **A diagnostics seam,** `DataServerDiagnosticsProvider`, with the Node
|
|
34
|
-
implementation `nodeDataServerDiagnostics()` behind `./node` so the portable
|
|
35
|
-
entry keeps bundling for a browser.
|
|
36
|
-
|
|
37
|
-
The projection itself is not this package's: it delegates to `TransferEncoder`
|
|
38
|
-
and `ModelService` from `@hydranium/core`, so there is no second in-memory model
|
|
39
|
-
to keep in sync.
|
|
10
|
+
- Typed reads, updates and saves of documents in the shared workspace, as your
|
|
11
|
+
transfer model. An edit from a data client reaches the other heads.
|
|
12
|
+
- Notifications when a document is rebuilt, saved or deleted, so a client
|
|
13
|
+
never polls.
|
|
14
|
+
- Your own methods on the same connection, through a `DataServer` subclass and
|
|
15
|
+
its `additionalMethods` option.
|
|
16
|
+
- An optional reference and naming slice: pass
|
|
17
|
+
`REFERENCE_SERVER_PROTOCOL_METHODS` from `@hydranium/protocol/data` in
|
|
18
|
+
`additionalMethods`.
|
|
40
19
|
|
|
41
20
|
## Install
|
|
42
21
|
|
|
@@ -44,48 +23,53 @@ to keep in sync.
|
|
|
44
23
|
npm install @hydranium/data-server
|
|
45
24
|
```
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
hydranium
|
|
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
|
-
|
|
26
|
+
| Peer | Range |
|
|
27
|
+
| ------------------------------------ | ------------- |
|
|
28
|
+
| `@hydranium/core` | `^1.0.0-next` |
|
|
29
|
+
| `@hydranium/langium` | `^1.0.0-next` |
|
|
30
|
+
| `@hydranium/protocol` | `^1.0.0-next` |
|
|
31
|
+
| `vscode-jsonrpc` | `^9.0.0` |
|
|
32
|
+
| `vscode-languageserver-textdocument` | `^1.0.12` |
|
|
33
|
+
|
|
34
|
+
## Wiring
|
|
35
|
+
|
|
36
|
+
The head adds no services module: it reads the shared services you composed
|
|
37
|
+
with `@hydranium/core`.
|
|
38
|
+
|
|
39
|
+
1. Start a launcher from `@hydranium/core/node`: `startSocketServer` beside the
|
|
40
|
+
LSP head, with `publishPortOnLspConnection` to tell the client its port, or
|
|
41
|
+
`startStdioServer` for a data head alone. Without an LSP head, give it the
|
|
42
|
+
workspace root as `workspace`.
|
|
43
|
+
2. In its connection callback, create `new DataServer(connection, shared)`. It
|
|
44
|
+
cleans up when the connection closes.
|
|
45
|
+
3. In a web worker, start it with `startDataServerInWorker` from `./browser`
|
|
46
|
+
on the port the page transferred for it; its callback creates the server.
|
|
47
|
+
|
|
48
|
+
See *Add a data-server method* and *Connect a data client* in
|
|
49
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
50
|
+
|
|
51
|
+
## Entry points
|
|
52
|
+
|
|
53
|
+
| Subpath | Use it for | Runs in |
|
|
54
|
+
| ------------ | ---------------------------------------------------------- | --------------- |
|
|
55
|
+
| `.` | `DataServer`, its options, and the diagnostics seam | browser-neutral |
|
|
56
|
+
| `./node` | The Node implementation of the diagnostics seam | Node-only |
|
|
57
|
+
| `./browser` | Starting the head in a web worker | browser-only |
|
|
58
|
+
| `./messages` | The codes of the messages this package raises | browser-neutral |
|
|
59
|
+
| `./testing` | A harness that drives a real data head in-process | Node-only |
|
|
60
|
+
|
|
61
|
+
The subpaths need a TypeScript `moduleResolution` that reads `exports`
|
|
62
|
+
(`NodeNext` or `Bundler`); see *Requirements* in
|
|
63
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
81
64
|
|
|
82
65
|
## Status
|
|
83
66
|
|
|
84
|
-
Alpha
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
Alpha: every release is a prerelease that may break the API, so pin an exact
|
|
68
|
+
version. Guides and known limitations:
|
|
69
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
87
70
|
|
|
88
71
|
## License
|
|
89
72
|
|
|
90
|
-
`MIT` — see this package's [`LICENSE`](./LICENSE)
|
|
91
|
-
|
|
73
|
+
`MIT` — see this package's [`LICENSE`](./LICENSE), and the repository
|
|
74
|
+
[`NOTICE.md`](https://github.com/eclipse-emfcloud/hydranium/blob/main/NOTICE.md)
|
|
75
|
+
for third-party notices.
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from './start-data-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 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/data-server/browser`). Holds the worker
|
|
10
|
+
// starter, whose connection comes from `vscode-jsonrpc/browser`. The portable
|
|
11
|
+
// `.` entry stays free of that import for the same reason it stays free of the
|
|
12
|
+
// node one: it must resolve under both platforms, and a build that names one
|
|
13
|
+
// has picked.
|
|
14
|
+
export * from './start-data-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,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,cAAc;AACd,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 TransferredMessagePort } from '@hydranium/protocol';
|
|
10
|
+
import type { ServerSharedServicesMinimal } from '@hydranium/core';
|
|
11
|
+
import { type MessageConnection } from 'vscode-jsonrpc/browser';
|
|
12
|
+
/**
|
|
13
|
+
* Start the data head on the port the page transferred for it, on the same
|
|
14
|
+
* shared tier the LSP head runs on, and return the server `create` built.
|
|
15
|
+
*
|
|
16
|
+
* `create` constructs the adopter's `DataServer`, or a subclass of it, around
|
|
17
|
+
* the connection, as a Node host's socket callback does, and the connection
|
|
18
|
+
* listens once it has returned, in the order the Node launcher uses. The
|
|
19
|
+
* page's end of the port closing disposes the server, which ends every
|
|
20
|
+
* session this connection registered.
|
|
21
|
+
*/
|
|
22
|
+
export declare function startDataServerInWorker<TServer>(port: TransferredMessagePort, shared: Pick<ServerSharedServicesMinimal, 'Logger'>, create: (connection: MessageConnection) => TServer): TServer;
|
|
23
|
+
//# sourceMappingURL=start-data-server-in-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-data-server-in-worker.d.ts","sourceRoot":"","sources":["../../src/browser/start-data-server-in-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAA8B,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEzF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAC5C,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,EACnD,MAAM,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,OAAO,GAClD,OAAO,CAOT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { createMessagePortTransport } from '@hydranium/protocol';
|
|
10
|
+
import { createMessageConnection } from 'vscode-jsonrpc/browser';
|
|
11
|
+
/**
|
|
12
|
+
* Start the data head on the port the page transferred for it, on the same
|
|
13
|
+
* shared tier the LSP head runs on, and return the server `create` built.
|
|
14
|
+
*
|
|
15
|
+
* `create` constructs the adopter's `DataServer`, or a subclass of it, around
|
|
16
|
+
* the connection, as a Node host's socket callback does, and the connection
|
|
17
|
+
* listens once it has returned, in the order the Node launcher uses. The
|
|
18
|
+
* page's end of the port closing disposes the server, which ends every
|
|
19
|
+
* session this connection registered.
|
|
20
|
+
*/
|
|
21
|
+
export function startDataServerInWorker(port, shared, create) {
|
|
22
|
+
// Both ends use `createMessagePortTransport`; see it for why.
|
|
23
|
+
const transport = createMessagePortTransport(port);
|
|
24
|
+
const connection = createMessageConnection(transport.reader, transport.writer, shared.Logger.with('ModelServer'));
|
|
25
|
+
const server = create(connection);
|
|
26
|
+
connection.listen();
|
|
27
|
+
return server;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=start-data-server-in-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-data-server-in-worker.js","sourceRoot":"","sources":["../../src/browser/start-data-server-in-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,0BAA0B,EAA+B,MAAM,qBAAqB,CAAC;AAE9F,OAAO,EAAE,uBAAuB,EAA0B,MAAM,wBAAwB,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACpC,IAA4B,EAC5B,MAAmD,EACnD,MAAkD;IAElD,8DAA8D;IAC9D,MAAM,SAAS,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,uBAAuB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAClH,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,CAAC,MAAM,EAAE,CAAC;IACpB,OAAO,MAAM,CAAC;AACjB,CAAC"}
|