@zenwave360/lsp-js 0.1.0-next.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZenWave's Authors and Contributors
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,96 @@
1
+ # @zenwave360/lsp-js
2
+
3
+ The ZenWave language server for JavaScript runtimes: ZDL, ZFL, the architecture manifest, AsyncAPI,
4
+ OpenAPI and Avro. It is the Kotlin `lsp-core` compiled to JavaScript, speaking the Language Server
5
+ Protocol through `vscode-languageserver`.
6
+
7
+ The package ships two self-contained entry points. Neither needs `node_modules` at run time and
8
+ neither needs a bundler.
9
+
10
+ | Export | File | Runtime | Transport |
11
+ | --- | --- | --- | --- |
12
+ | `@zenwave360/lsp-js/node` | `dist/node/zenwave-lsp-server.js` | Node child process (CommonJS, Node 18+) | child-process IPC |
13
+ | `@zenwave360/lsp-js/worker` | `dist/browser/zenwave-lsp-worker.js` | browser Web Worker (classic script) | `postMessage` |
14
+
15
+ The worker bundle uses no Node API. The build fails if one reaches it.
16
+
17
+ ## Desktop: Node child process over IPC
18
+
19
+ ```ts
20
+ import { LanguageClient, TransportKind } from 'vscode-languageclient/node';
21
+
22
+ const module = require.resolve('@zenwave360/lsp-js/node'); // or a path inside your extension
23
+ const client = new LanguageClient('zenwave', 'ZenWave', {
24
+ run: { module, transport: TransportKind.ipc },
25
+ debug: { module, transport: TransportKind.ipc },
26
+ }, clientOptions);
27
+ ```
28
+
29
+ The server uses IPC when it is forked without transport arguments. It also honours `--node-ipc`,
30
+ `--stdio`, `--socket=<port>` and `--pipe=<name>`.
31
+
32
+ ## Browser: Web Worker
33
+
34
+ ```ts
35
+ import { LanguageClient } from 'vscode-languageclient/browser';
36
+
37
+ const worker = new Worker(workerUrl); // URL of dist/browser/zenwave-lsp-worker.js
38
+ const client = new LanguageClient('zenwave', 'ZenWave', clientOptions, worker);
39
+ ```
40
+
41
+ The worker connects with `BrowserMessageReader(self)` and `BrowserMessageWriter(self)`, so the client
42
+ talks to it through the `Worker` object. In the browser there is no filesystem. Documents the client
43
+ opens arrive through `textDocument/didOpen`, and other content can only be reached over HTTP.
44
+
45
+ ## Capabilities
46
+
47
+ `initialize` returns the standard capabilities the language modules support: incremental text sync,
48
+ hover, definition, references, document symbols and formatting. `capabilities.experimental` also carries:
49
+
50
+ - `moduleSelectors`: `{ languageId, extensions }[]`, one entry per language module;
51
+ - `customRequests`: `string[]`, the `zenwave/*` requests this server answers. The list is built from the
52
+ server's handler registration, so a client can rely on it. A request that is not listed is answered
53
+ with JSON-RPC `-32601`. lsp-jvm advertises the same list.
54
+
55
+ ## Custom requests
56
+
57
+ | Method | Params | Result |
58
+ | --- | --- | --- |
59
+ | `zenwave/hierarchy` | `{ uri }` | hierarchy nodes `{ id, label, kind, language, sourceUri, sourceRange, children, relatedResources, uiHints, viewNodeIds }[]` |
60
+ | `zenwave/forwardReferences`, `zenwave/reverseReferences` | `{ uri, semanticId }` | navigation targets |
61
+ | `zenwave/organizeZflServices` | `{ uri }` | the reorganised ZFL text, or `null` |
62
+ | `zenwave/eventFlowViews` | `{ textDocument: { uri } }` | `{ flowGraph, serviceGraph }`: dsl-kotlin's laid-out flow and service view models, each with its `schema` (`zfl.eventflow.view@1`, `zfl.services.view@1`) |
63
+ | `zenwave/preview` | `{ textDocument: { uri }, sequenceRenderMode?: "SEPARATE_VARIANTS" \| "ALT_BLOCKS" \| "AUTO" }` | `{ representations: { id, title, format: "MARKDOWN" \| "MERMAID" \| "HTML", content }[], defaultRepresentationId }` |
64
+ | `zenwave/symbolAt` | `{ textDocument: { uri }, position: { line, character } }` | `{ uri, semanticId, range? }`, the input of the two reference requests, or `null` when nothing is declared or referenced there |
65
+
66
+ `zenwave/hierarchy` answers whether or not the document is open. An open document is answered from the
67
+ editor's content; any other document is read by the server: files through Node's `fs` (the Node entry point),
68
+ `http(s):` through `fetch` (both entry points). A document it cannot read fails with `-32803`
69
+ `documentNotFound`; the worker cannot read `file:` documents, nor schemes such as `vscode-vfs:`. A document no
70
+ module builds hierarchies for answers `[]`. In a ZFL hierarchy the systems, services and commands that the
71
+ annotated ZDL declares point at that ZDL (`sourceUri`/`sourceRange`), open or read, and list where the flow
72
+ refers to them as a `referenced-by` related resource. `viewNodeIds` names the ids of the nodes and service
73
+ groups of the same document's `zenwave/eventFlowViews` that stand for the node's concept (`command:createOrder`,
74
+ `event:OrderCreated`, `event:OrderCreated@Orders>OrderService`, `group:Orders>OrderService`, `policy:�`); it
75
+ is empty when the diagram has no counterpart.
76
+
77
+ `zenwave/preview` answers for ZDL (one Mermaid `class-diagram`) and ZFL (a `flowchart`, then one
78
+ `sequence:<outcome>:<index>` per end outcome; the first sequence is the default). `sequenceRenderMode`
79
+ defaults to `ALT_BLOCKS`. Null properties are omitted from every result.
80
+
81
+ Both visualisation requests read open documents. When a document cannot answer they fail with JSON-RPC
82
+ `-32803` and `data.kind`: `documentUnreadable` (a syntax error; `data.diagnostics` holds LSP diagnostics),
83
+ `documentNotFound` (not open) or `unsupportedDocument` (a kind of document the request does not cover).
84
+ Malformed params fail with `-32602`. An empty model is a successful, empty result.
85
+
86
+ The worker bundle carries elkjs for the flow layout. elkjs' in-process layout worker script would take over
87
+ the Web Worker's `onmessage` when it detects a worker global; `build.mjs` disables that detection when bundling,
88
+ and the build fails if an elkjs upgrade changes it.
89
+
90
+ Initialization options take the form `{ zenwave: { configUri?, projectManifestUri? } }`.
91
+
92
+ ## Building
93
+
94
+ This package is built by the zenwave-lsp Gradle build (`./gradlew :lsp-js:lspJsBundle`, or
95
+ `:lsp-js:lspJsNpmPack` for a tarball in `lsp-js/build/npm-pack`). `:lsp-js:check` runs both wire tests:
96
+ `nodeIpcTest` forks the Node entry point, and `jsBrowserTest` loads the worker in headless Chromium.