@hydranium/data-server 1.0.0-next.298 → 1.0.0-next.299
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 +3 -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-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/package.json +11 -7
- package/src/browser/index.ts +15 -0
- package/src/browser/start-data-server-in-worker.ts +35 -0
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ with `@hydranium/core`.
|
|
|
41
41
|
`startStdioServer` for a data head alone.
|
|
42
42
|
2. In its connection callback, create `new DataServer(connection, shared)`. It
|
|
43
43
|
cleans up when the connection closes.
|
|
44
|
+
3. In a web worker, start it with `startDataServerInWorker` from `./browser`
|
|
45
|
+
on the port the page transferred for it; its callback creates the server.
|
|
44
46
|
|
|
45
47
|
See *Add a data-server method* and *Connect a data client* in
|
|
46
48
|
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
@@ -51,6 +53,7 @@ See *Add a data-server method* and *Connect a data client* in
|
|
|
51
53
|
| ------------ | ---------------------------------------------------------- | --------------- |
|
|
52
54
|
| `.` | `DataServer`, its options, and the diagnostics seam | browser-neutral |
|
|
53
55
|
| `./node` | The Node implementation of the diagnostics seam | Node-only |
|
|
56
|
+
| `./browser` | Starting the head in a web worker | browser-only |
|
|
54
57
|
| `./messages` | The codes of the messages this package raises | browser-neutral |
|
|
55
58
|
| `./testing` | A harness that drives a real data head in-process | Node-only |
|
|
56
59
|
|
|
@@ -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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/data-server",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.299",
|
|
4
4
|
"description": "Typed-RPC protocol head for the hydranium framework. Peer of @hydranium/core/lsp and @hydranium/glsp-server; built on @hydranium/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-server",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"types": "./lib/node/index.d.ts",
|
|
45
45
|
"default": "./lib/node/index.js"
|
|
46
46
|
},
|
|
47
|
+
"./browser": {
|
|
48
|
+
"types": "./lib/browser/index.d.ts",
|
|
49
|
+
"default": "./lib/browser/index.js"
|
|
50
|
+
},
|
|
47
51
|
"./messages": {
|
|
48
52
|
"types": "./lib/messages/index.d.ts",
|
|
49
53
|
"default": "./lib/messages/index.js"
|
|
@@ -66,18 +70,18 @@
|
|
|
66
70
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
|
-
"@hydranium/core": "1.0.0-next.
|
|
70
|
-
"@hydranium/langium": "1.0.0-next.
|
|
71
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
73
|
+
"@hydranium/core": "1.0.0-next.299",
|
|
74
|
+
"@hydranium/langium": "1.0.0-next.299",
|
|
75
|
+
"@hydranium/protocol": "1.0.0-next.299",
|
|
72
76
|
"rimraf": "^5.0.0",
|
|
73
77
|
"typescript": "^7.0.2",
|
|
74
78
|
"vscode-jsonrpc": "9.0.0",
|
|
75
79
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
76
80
|
},
|
|
77
81
|
"peerDependencies": {
|
|
78
|
-
"@hydranium/core": "1.0.0-next.
|
|
79
|
-
"@hydranium/langium": "1.0.0-next.
|
|
80
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
82
|
+
"@hydranium/core": "1.0.0-next.299",
|
|
83
|
+
"@hydranium/langium": "1.0.0-next.299",
|
|
84
|
+
"@hydranium/protocol": "1.0.0-next.299",
|
|
81
85
|
"vscode-jsonrpc": "^9.0.0",
|
|
82
86
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
83
87
|
},
|
|
@@ -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
|
+
|
|
10
|
+
// Browser-only entry (`@hydranium/data-server/browser`). Holds the worker
|
|
11
|
+
// starter, whose connection comes from `vscode-jsonrpc/browser`. The portable
|
|
12
|
+
// `.` entry stays free of that import for the same reason it stays free of the
|
|
13
|
+
// node one: it must resolve under both platforms, and a build that names one
|
|
14
|
+
// has picked.
|
|
15
|
+
export * from './start-data-server-in-worker.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
|
|
10
|
+
import { createMessagePortTransport, type TransferredMessagePort } from '@hydranium/protocol';
|
|
11
|
+
import type { ServerSharedServicesMinimal } from '@hydranium/core';
|
|
12
|
+
import { createMessageConnection, type MessageConnection } from 'vscode-jsonrpc/browser';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Start the data head on the port the page transferred for it, on the same
|
|
16
|
+
* shared tier the LSP head runs on, and return the server `create` built.
|
|
17
|
+
*
|
|
18
|
+
* `create` constructs the adopter's `DataServer`, or a subclass of it, around
|
|
19
|
+
* the connection, as a Node host's socket callback does, and the connection
|
|
20
|
+
* listens once it has returned, in the order the Node launcher uses. The
|
|
21
|
+
* page's end of the port closing disposes the server, which ends every
|
|
22
|
+
* session this connection registered.
|
|
23
|
+
*/
|
|
24
|
+
export function startDataServerInWorker<TServer>(
|
|
25
|
+
port: TransferredMessagePort,
|
|
26
|
+
shared: Pick<ServerSharedServicesMinimal, 'Logger'>,
|
|
27
|
+
create: (connection: MessageConnection) => TServer
|
|
28
|
+
): TServer {
|
|
29
|
+
// Both ends use `createMessagePortTransport`; see it for why.
|
|
30
|
+
const transport = createMessagePortTransport(port);
|
|
31
|
+
const connection = createMessageConnection(transport.reader, transport.writer, shared.Logger.with('ModelServer'));
|
|
32
|
+
const server = create(connection);
|
|
33
|
+
connection.listen();
|
|
34
|
+
return server;
|
|
35
|
+
}
|