@hydranium/protocol 1.0.0-next.244 → 1.0.0-next.246
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 +44 -86
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
# `@hydranium/protocol`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[Hydranium](https://github.com/eclipse-emfcloud/hydranium)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
The contract shared between
|
|
4
|
+
[Hydranium](https://github.com/eclipse-emfcloud/hydranium) servers and their
|
|
5
|
+
clients. With `vscode-jsonrpc`, it is the only Hydranium package a pure client
|
|
6
|
+
needs: a form editor, a tree view or a code generator talking to the data head
|
|
7
|
+
never depends on `@hydranium/core`, which carries the Langium runtime.
|
|
8
|
+
|
|
9
|
+
## What it gives you
|
|
10
|
+
|
|
11
|
+
- Type your client against `DataServerProtocol` and `DataClientProtocol`.
|
|
12
|
+
- Connect, reconnect and open documents through one client tier, in a Theia
|
|
13
|
+
frontend, a VS Code extension or webview, or a plain browser page.
|
|
14
|
+
- Declare your own RPC contract as a TypeScript interface and use it on both
|
|
15
|
+
ends of a connection.
|
|
16
|
+
- Test your client, and audit your translation catalogues (see *Translate your
|
|
17
|
+
language* in
|
|
18
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md)).
|
|
17
19
|
|
|
18
20
|
## Install
|
|
19
21
|
|
|
20
22
|
```bash
|
|
21
|
-
npm install @hydranium/protocol
|
|
23
|
+
npm install @hydranium/protocol vscode-jsonrpc
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`vscode-jsonrpc`
|
|
27
|
-
the Langium runtime and does not bundle for a client.
|
|
26
|
+
| Peer | Range |
|
|
27
|
+
| ---------------- | -------- |
|
|
28
|
+
| `vscode-jsonrpc` | `^9.0.0` |
|
|
28
29
|
|
|
29
30
|
## The RPC pattern
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
between the two is hand-written, and the compiler is what keeps the ends
|
|
35
|
-
agreeing.
|
|
32
|
+
You declare a contract `T`, bind it on the server with `bindRpcMethods`, and
|
|
33
|
+
call it with `createRpcProxy<T>`. Nothing between the two is hand-written, so
|
|
34
|
+
the compiler keeps the ends agreeing.
|
|
36
35
|
|
|
37
36
|
```
|
|
38
|
-
|
|
37
|
+
your contract T your contract T
|
|
39
38
|
│ │
|
|
40
39
|
▼ ▼
|
|
41
40
|
bindRpcMethods createRpcProxy<T>
|
|
@@ -45,74 +44,33 @@ agreeing.
|
|
|
45
44
|
(vscode-jsonrpc)
|
|
46
45
|
```
|
|
47
46
|
|
|
48
|
-
The
|
|
49
|
-
|
|
50
|
-
a contract written once works on both ends with no per-method configuration.
|
|
51
|
-
Both are exported from the package root; there is no `/rpc` subpath.
|
|
52
|
-
|
|
53
|
-
Full reference — the options both ends must agree on, the reserved property
|
|
54
|
-
names, a worked example — is in
|
|
55
|
-
[`src/rpc/README.md`](./src/rpc/README.md), which ships in the tarball.
|
|
56
|
-
|
|
57
|
-
## Subpaths
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
@hydranium/protocol # transfer documents, references, RPC machinery
|
|
61
|
-
@hydranium/protocol/data # DataServerProtocol / DataClientProtocol
|
|
62
|
-
@hydranium/protocol/client # the host-neutral client tier
|
|
63
|
-
@hydranium/protocol/messages # every message it raises, by code
|
|
64
|
-
@hydranium/protocol/node # process memory and heap-snapshot helpers
|
|
65
|
-
@hydranium/protocol/testing # test doubles, waiters, catalogue audit
|
|
66
|
-
@hydranium/protocol/testing/node # the Node-only doubles
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
The root barrel re-exports `data` and `client`, so those two subpaths buy a
|
|
70
|
-
narrower surface rather than reach; `node` and `testing` are only reachable by
|
|
71
|
-
their own specifiers, which keeps `node:*` imports out of a browser bundle and
|
|
72
|
-
the doubles out of a production bundle. The RPC
|
|
73
|
-
machinery documents itself in [`src/rpc/README.md`](./src/rpc/README.md).
|
|
74
|
-
|
|
75
|
-
### Auditing a translation catalogue
|
|
76
|
-
|
|
77
|
-
An adopter with i18n has one failure mode nothing else catches: a catalogue key
|
|
78
|
-
naming no declared code falls back to the English, which is byte-identical to
|
|
79
|
-
the deliberately-partial behaviour every adopter relies on. So a typo is
|
|
80
|
-
invisible at runtime, and `theia nls-extract` reports what the source declares
|
|
81
|
-
rather than whether a catalogue matches it.
|
|
47
|
+
The options both ends must agree on, and a worked example, are in
|
|
48
|
+
[`src/rpc/README.md`](./src/rpc/README.md).
|
|
82
49
|
|
|
83
|
-
|
|
84
|
-
test, over your own barrels:
|
|
50
|
+
## Entry points
|
|
85
51
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// Every key names a code some barrel declares. `exemptPrefixes` is for keys no
|
|
97
|
-
// barrel CAN declare — a host mechanism taking its key as an inline literal.
|
|
98
|
-
expect(findUndeclaredCodes(keys, [protocolMessages])).toEqual([]);
|
|
99
|
-
```
|
|
52
|
+
| Subpath | Use it for | Runs in |
|
|
53
|
+
| ---------------- | ----------------------------------------------------------- | --------------- |
|
|
54
|
+
| `.` | The production surface, `./data` and `./client` included | browser-neutral |
|
|
55
|
+
| `./data` | The data-head protocol types alone | browser-neutral |
|
|
56
|
+
| `./client` | The client tier alone | browser-neutral |
|
|
57
|
+
| `./messages` | The message codes this package raises | browser-neutral |
|
|
58
|
+
| `./node` | Process-memory and heap-snapshot diagnostics | Node-only |
|
|
59
|
+
| `./testing` | Test doubles, waiters and the translation-catalogue audit | browser-neutral |
|
|
60
|
+
| `./testing/node` | In-memory stream and port pairs for tests | Node-only |
|
|
100
61
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
it. `findSharedCodes` covers the other half: exactly one side renders a given
|
|
105
|
-
message, so two catalogues holding one code are two authorities over one
|
|
106
|
-
sentence — assert both key sets non-empty first, since an empty one satisfies
|
|
107
|
-
disjointness while proving nothing.
|
|
62
|
+
The subpaths need a TypeScript `moduleResolution` that reads `exports`
|
|
63
|
+
(`NodeNext` or `Bundler`); see *Requirements* in
|
|
64
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
108
65
|
|
|
109
66
|
## Status
|
|
110
67
|
|
|
111
|
-
Alpha
|
|
112
|
-
|
|
113
|
-
|
|
68
|
+
Alpha: every release is a prerelease that may break the API, so pin an exact
|
|
69
|
+
version. Guides and known limitations:
|
|
70
|
+
[Adopting Hydranium](https://github.com/eclipse-emfcloud/hydranium/blob/main/docs/ADOPTING.md).
|
|
114
71
|
|
|
115
72
|
## License
|
|
116
73
|
|
|
117
74
|
`MIT` — see this package's [`LICENSE`](./LICENSE), and the repository
|
|
118
|
-
[`NOTICE.md`](
|
|
75
|
+
[`NOTICE.md`](https://github.com/eclipse-emfcloud/hydranium/blob/main/NOTICE.md)
|
|
76
|
+
for third-party notices.
|
package/package.json
CHANGED