@lensmap/language-server 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +37 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +90 -0
- package/dist/preview/assets/playground-BtGyjknt.js +383 -0
- package/dist/preview/assets/preview-B84it-Jd.js +1 -0
- package/dist/preview/assets/preview-fhnbHE6T.css +1 -0
- package/dist/preview/assets/styles-D4WWbpX1.css +1 -0
- package/dist/preview/assets/styles-HT2Xrmtw.js +22 -0
- package/dist/preview/index.html +15 -0
- package/dist/preview/preview.html +17 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +601 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lensmap 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
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lensmap/language-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Experimental Lensmap stdio language server and authenticated loopback browser
|
|
4
|
+
preview. Includes its compiled browser assets; npm installs the document engine
|
|
5
|
+
and other runtime dependencies before startup. No workspace checkout, pnpm,
|
|
6
|
+
Rust, runtime dependency download or separate web server is needed to run it.
|
|
7
|
+
|
|
8
|
+
Requires Node 24.16 or newer. ESM only. The API and document format are
|
|
9
|
+
experimental. Native host integration is currently qualified on Linux/X11;
|
|
10
|
+
other platforms are not yet qualified. Automatic browser launching uses
|
|
11
|
+
`xdg-open`; `--no-open` leaves opening the preview URL to the host/client.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --global @lensmap/language-server@next
|
|
15
|
+
lensmap-lsp --help
|
|
16
|
+
lensmap-lsp --configure-zed --zed /usr/bin/zeditor
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The last command **prints** settings, without modifying your editor. Use your
|
|
20
|
+
verified Zed executable path. Keep the Node installation and package path stable,
|
|
21
|
+
and regenerate settings if either changes. Zed still requires the separately
|
|
22
|
+
installed Lensmap **dev extension** from the source repository's `editors/zed`
|
|
23
|
+
directory; the npm package does not install or register an editor extension.
|
|
24
|
+
|
|
25
|
+
The editor launches `lensmap-lsp --stdio`. Its stdout is reserved for LSP; it is
|
|
26
|
+
not a standalone saved-file viewer or persistent background web daemon. Attach a
|
|
27
|
+
`.lensmap` buffer and invoke **Lensmap: Open preview** through editor code
|
|
28
|
+
actions. The server defaults to its package-local built viewer. `--assets PATH`
|
|
29
|
+
remains available for development/custom assets.
|
|
30
|
+
|
|
31
|
+
Preview URLs and API tokens are private per-run credentials. Do not log, paste
|
|
32
|
+
or retain them in traces. The server binds to loopback, validates Host/Origin,
|
|
33
|
+
and limits source access to attached buffers. Content writes use revision checks
|
|
34
|
+
and live-buffer readback, **not atomic compare-and-swap**.
|
|
35
|
+
|
|
36
|
+
See [Zed setup, API and limitations](https://github.com/nicodoggie/lensmap/blob/main/docs/zed-browser.md).
|
|
37
|
+
The library export exposes `startServer` and its TypeScript declarations; custom
|
|
38
|
+
hosts supply their own `assets` and host callbacks. MIT licensed; see `LICENSE`.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { startServer } from "./server.js";
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import { startServer } from "./server.js";
|
|
7
|
+
const { values } = parseArgs({
|
|
8
|
+
options: {
|
|
9
|
+
stdio: { type: "boolean" },
|
|
10
|
+
assets: { type: "string" },
|
|
11
|
+
zed: { type: "string", default: "zeditor" },
|
|
12
|
+
"zed-data-dir": { type: "string" },
|
|
13
|
+
"no-open": { type: "boolean" },
|
|
14
|
+
"configure-zed": { type: "boolean" },
|
|
15
|
+
help: { type: "boolean", short: "h" },
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const assets = resolve(values.assets ?? resolve(import.meta.dirname, "preview"));
|
|
19
|
+
if (values.help) {
|
|
20
|
+
process.stdout.write("Lensmap experimental language server + loopback preview\n\nUsage: lensmap-lsp --stdio [--assets PATH] [--zed EXECUTABLE]\n --assets PATH Override the bundled browser preview assets\n --no-open Return preview links without launching a browser\n --zed-data-dir DIR Target a private Zed profile for source reveal\n --configure-zed Print workspace settings for the local dev extension\n\nInstalled packages include the browser preview. For source checkouts, run pnpm build.\nPreview URLs/tokens are private per-run credentials; retrieve them through\nLensmap's code actions or lensmap.session LSP command.\nEditor writes use revision checks/readback, not atomic compare-and-swap.\n");
|
|
21
|
+
}
|
|
22
|
+
else if (values["configure-zed"]) {
|
|
23
|
+
process.stdout.write(`${JSON.stringify({
|
|
24
|
+
file_types: { YAML: ["lensmap"] },
|
|
25
|
+
languages: { YAML: { language_servers: ["lensmap", "..."] } },
|
|
26
|
+
lsp: {
|
|
27
|
+
lensmap: {
|
|
28
|
+
binary: {
|
|
29
|
+
path: process.execPath,
|
|
30
|
+
arguments: [
|
|
31
|
+
fileURLToPath(import.meta.url),
|
|
32
|
+
"--stdio",
|
|
33
|
+
"--assets",
|
|
34
|
+
assets,
|
|
35
|
+
"--zed",
|
|
36
|
+
values.zed,
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}, null, 2)}\n`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const launch = (executable, args) => new Promise((done, reject) => {
|
|
45
|
+
const child = spawn(executable, args, { stdio: "ignore" });
|
|
46
|
+
child.once("error", () => reject(new Error("Host opener could not start.")));
|
|
47
|
+
child.once("exit", (code) => code === 0 ? done() : reject(new Error("Host opener failed.")));
|
|
48
|
+
});
|
|
49
|
+
const reveal = async ({ uri, range, source }) => {
|
|
50
|
+
if (!uri.startsWith("file:"))
|
|
51
|
+
throw new Error("This host reveals attached file documents only.");
|
|
52
|
+
const line = source.split("\n")[range.start.line] ?? "";
|
|
53
|
+
const column = Buffer.byteLength(line.slice(0, range.start.character), "utf8") + 1;
|
|
54
|
+
const location = `${fileURLToPath(uri)}:${range.start.line + 1}:${column}`;
|
|
55
|
+
await launch(values.zed ?? "zeditor", [
|
|
56
|
+
...(values["zed-data-dir"]
|
|
57
|
+
? ["--user-data-dir", values["zed-data-dir"]]
|
|
58
|
+
: []),
|
|
59
|
+
"--existing",
|
|
60
|
+
location,
|
|
61
|
+
]);
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const server = await startServer({
|
|
65
|
+
input: process.stdin,
|
|
66
|
+
output: process.stdout,
|
|
67
|
+
assets,
|
|
68
|
+
reveal,
|
|
69
|
+
open: values["no-open"]
|
|
70
|
+
? undefined
|
|
71
|
+
: async (url) => {
|
|
72
|
+
if (process.platform !== "linux")
|
|
73
|
+
throw new Error("Browser launching is currently qualified on Linux only; use the returned preview URL.");
|
|
74
|
+
await launch("xdg-open", [url]);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
process.stderr.write(`Lensmap ready at ${server.origin}; use the Open preview code action.\n`);
|
|
78
|
+
const stop = () => {
|
|
79
|
+
void server.close().finally(() => {
|
|
80
|
+
process.stdin.destroy();
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
process.once("SIGTERM", stop);
|
|
84
|
+
process.once("SIGINT", stop);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
process.stderr.write("Lensmap could not start. Check the preview asset directory; rebuild source checkouts with pnpm build or reinstall the npm package. See --help.\n");
|
|
88
|
+
process.exitCode = 1;
|
|
89
|
+
}
|
|
90
|
+
}
|