@valbuild/language-server 0.98.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.md +7 -0
- package/bin.js +3 -0
- package/dist/declarations/src/EditorFsHost.d.ts +30 -0
- package/dist/declarations/src/ValProject.d.ts +76 -0
- package/dist/declarations/src/codeActions.d.ts +26 -0
- package/dist/declarations/src/completionContext.d.ts +77 -0
- package/dist/declarations/src/completions.d.ts +50 -0
- package/dist/declarations/src/diagnostics.d.ts +105 -0
- package/dist/declarations/src/index.d.ts +13 -0
- package/dist/declarations/src/modulePathMap.d.ts +60 -0
- package/dist/declarations/src/protocol.d.ts +200 -0
- package/dist/declarations/src/publicValFiles.d.ts +29 -0
- package/dist/declarations/src/server.d.ts +47 -0
- package/dist/declarations/src/uri.d.ts +28 -0
- package/dist/declarations/src/valModulesRegistry.d.ts +32 -0
- package/dist/declarations/src/version.d.ts +10 -0
- package/dist/valbuild-language-server.cjs.d.ts +2 -0
- package/dist/valbuild-language-server.cjs.dev.js +2497 -0
- package/dist/valbuild-language-server.cjs.js +7 -0
- package/dist/valbuild-language-server.cjs.prod.js +2497 -0
- package/dist/valbuild-language-server.esm.js +2451 -0
- package/package.json +53 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists the files a Val module may reference.
|
|
3
|
+
*
|
|
4
|
+
* Val stores referenced files under `/public/val` by convention (configurable
|
|
5
|
+
* via `files.directory` in val.config), and a reference is written as the path
|
|
6
|
+
* *including* the `/public` prefix — so this returns Val-style refs directly.
|
|
7
|
+
*/
|
|
8
|
+
/** Default directory, matching `files.directory` in val.config. */
|
|
9
|
+
export declare const DEFAULT_FILES_DIRECTORY = "/public/val";
|
|
10
|
+
export type PublicValFile = {
|
|
11
|
+
/** Val-style reference, for example `/public/val/images/logo.png`. */
|
|
12
|
+
ref: string;
|
|
13
|
+
/** Absolute path on disk. */
|
|
14
|
+
filePath: string;
|
|
15
|
+
/** Mime type derived from the extension, when recognised. */
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
};
|
|
18
|
+
export type PublicValFiles = {
|
|
19
|
+
/** Files under `directory`, defaulting to the project's files directory. */
|
|
20
|
+
list(directory?: string): PublicValFile[];
|
|
21
|
+
/** As {@link list}, but only files whose mime type starts with `image/`. */
|
|
22
|
+
images(directory?: string): PublicValFile[];
|
|
23
|
+
invalidate(): void;
|
|
24
|
+
};
|
|
25
|
+
export declare function createPublicValFiles({ valRoot, directory, now, }: {
|
|
26
|
+
valRoot: string;
|
|
27
|
+
directory?: string;
|
|
28
|
+
now?: () => number;
|
|
29
|
+
}): PublicValFiles;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TextDocuments, type Connection, type InitializeParams } from "vscode-languageserver/node";
|
|
2
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
+
import { type ValClientCapabilities, type ValFeature, type ValInitializationOptions } from "./protocol.js";
|
|
4
|
+
/**
|
|
5
|
+
* Everything resolved during `initialize` that the rest of the server needs.
|
|
6
|
+
* Held in one object so that later phases (diagnostics, completions, commands)
|
|
7
|
+
* have a single place to read session state from.
|
|
8
|
+
*/
|
|
9
|
+
export type ValSession = {
|
|
10
|
+
valRoot: string;
|
|
11
|
+
clientCapabilities: ValClientCapabilities;
|
|
12
|
+
protocolVersion: number;
|
|
13
|
+
features: ValFeature[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Read and sanity-check the client's `initializationOptions`.
|
|
17
|
+
*
|
|
18
|
+
* A client that predates these options, or a bare LSP client such as a
|
|
19
|
+
* hand-written Neovim config, may send nothing useful. Rather than failing, we
|
|
20
|
+
* fall back to the workspace root and to the narrowest protocol range, so the
|
|
21
|
+
* server still starts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseInitializationOptions(params: InitializeParams): ValInitializationOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Apply `VAL_*` overrides the client forwarded, so an editor session can be
|
|
26
|
+
* pointed at a non-production Val backend without restarting the editor with a
|
|
27
|
+
* modified environment.
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyEnvOverrides(options: ValInitializationOptions): void;
|
|
30
|
+
/**
|
|
31
|
+
* Wire up a Val language server on an existing connection.
|
|
32
|
+
*
|
|
33
|
+
* Split out from {@link main} so `main` stays a thin transport choice.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createValLanguageServer(connection: Connection): {
|
|
36
|
+
documents: TextDocuments<TextDocument>;
|
|
37
|
+
/** Session state resolved during `initialize`; `undefined` until then. */
|
|
38
|
+
getSession: () => ValSession | undefined;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Entry point used by `bin.js`.
|
|
42
|
+
*
|
|
43
|
+
* `createConnection` picks its transport from argv (`--stdio`, `--node-ipc`,
|
|
44
|
+
* `--socket=`), so the same binary serves VS Code (IPC) and any other LSP
|
|
45
|
+
* client (stdio).
|
|
46
|
+
*/
|
|
47
|
+
export declare function main(): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ModuleFilePath } from "@valbuild/core";
|
|
2
|
+
export declare function isValModuleUri(uri: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* `file:///a/b.val.ts` -> `/a/b.val.ts`
|
|
5
|
+
*
|
|
6
|
+
* Percent escapes are decoded, Windows drive letters lose the leading slash
|
|
7
|
+
* (`file:///c%3A/a` -> `c:/a`), and a URI with an authority is read as a UNC
|
|
8
|
+
* path (`file://host/share/a` -> `//host/share/a`). Anything that is not a
|
|
9
|
+
* `file:` URI is passed through unchanged, since callers also hand us plain
|
|
10
|
+
* paths.
|
|
11
|
+
*/
|
|
12
|
+
export declare function uriToPath(uri: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* `/a/b.val.ts` -> `file:///a/b.val.ts`
|
|
15
|
+
*
|
|
16
|
+
* The escaping matches what VS Code produces (drive-letter colons included), so
|
|
17
|
+
* that a URI built here can be looked up in the open-document map keyed by the
|
|
18
|
+
* URIs the client sent.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pathToUri(fsPath: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a document URI into the `ModuleFilePath` Val addresses it by: a
|
|
23
|
+
* POSIX-style path relative to the Val root, with a leading slash.
|
|
24
|
+
*
|
|
25
|
+
* Returns `undefined` when the file lies outside the Val root — one server
|
|
26
|
+
* serves exactly one root, so another root's files are not its business.
|
|
27
|
+
*/
|
|
28
|
+
export declare function toModuleFilePath(valRoot: string, uri: string): ModuleFilePath | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { ModuleFilePath } from "@valbuild/core";
|
|
3
|
+
/**
|
|
4
|
+
* Works out which Val modules a `val.modules.{ts,js}` file registers.
|
|
5
|
+
*
|
|
6
|
+
* Val only serves modules listed there, so an unregistered `.val.ts` file
|
|
7
|
+
* silently does nothing.
|
|
8
|
+
*
|
|
9
|
+
* Rather than pattern-matching the accepted authoring shapes — `config.modules([…])`
|
|
10
|
+
* vs `modules(config, […])`, bare `import("./x.val")` vs
|
|
11
|
+
* `{ def: () => import("./x.val") }` — this collects *every* dynamic import
|
|
12
|
+
* specifier in the file. That is deliberate:
|
|
13
|
+
*
|
|
14
|
+
* - it covers all current shapes with one rule, and any shape added later;
|
|
15
|
+
* - when in doubt it over-reports registration, so a new authoring form makes
|
|
16
|
+
* the diagnostic go quiet rather than firing a false "missing module" on
|
|
17
|
+
* every file, which is the failure mode that actually hurts.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findRegisteredModuleSpecifiers(sourceFile: ts.SourceFile): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether `moduleFilePath` is registered by the given `val.modules` file.
|
|
22
|
+
*
|
|
23
|
+
* @param valModulesDir directory containing the val.modules file, relative to
|
|
24
|
+
* the Val root (`""` when it sits at the root).
|
|
25
|
+
* @param moduleFilePath the module's path, Val-style: root-relative, leading
|
|
26
|
+
* slash, with extension (for example `/content/page.val.ts`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function isModuleRegistered({ sourceFile, valModulesDir, moduleFilePath, }: {
|
|
29
|
+
sourceFile: ts.SourceFile;
|
|
30
|
+
valModulesDir: string;
|
|
31
|
+
moduleFilePath: ModuleFilePath;
|
|
32
|
+
}): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version of this package, read from its own package.json.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors how `@valbuild/core` reports `Internal.VERSION.core`
|
|
5
|
+
* (see `packages/core/src/index.ts`): the built output lives one directory
|
|
6
|
+
* below the package root, so `../package.json` resolves correctly. Returns
|
|
7
|
+
* `null` rather than throwing if the file cannot be read — the version is only
|
|
8
|
+
* ever used for display, never for behaviour.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLanguageServerVersion(): string | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsYnVpbGQtbGFuZ3VhZ2Utc2VydmVyLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|