@forinda/kickjs-view-language-server 0.0.0-stage → 0.0.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 +31 -2
- package/bin/kick-view-ls.js +2 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +18 -0
- package/dist/main.js.map +1 -0
- package/dist/server-BINLQyYR.js +1149 -0
- package/dist/server-BINLQyYR.js.map +1 -0
- package/package.json +63 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Felix Orinda
|
|
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,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @forinda/kickjs-view-language-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A language server for KickJS `.kick` views, built on [Volar](https://volarjs.dev/).
|
|
4
|
+
|
|
5
|
+
- Errors as you type, from the same `parse` + `check` the runtime uses.
|
|
6
|
+
- Completion for `@` keywords, pipes, components and their inputs, layout and slot names, and names in scope.
|
|
7
|
+
- HTML, CSS and Emmet inside templates.
|
|
8
|
+
- Hover, go to definition and formatting.
|
|
9
|
+
|
|
10
|
+
When the client says the workspace is trusted, it loads the project's own `@forinda/kickjs-view` so the editor agrees with the build, and falls back to its bundled copy (with one warning) when the project has none.
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
The KickJS VS Code extension bundles this server. For other editors:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pnpm add -D @forinda/kickjs-view-language-server
|
|
18
|
+
kick-view-ls --stdio
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Initialization options, relative to the workspace folder:
|
|
22
|
+
|
|
23
|
+
| option | default |
|
|
24
|
+
| --------------- | ------------------------------------------------------------------------------------------------ |
|
|
25
|
+
| `viewsDir` | `src/views` |
|
|
26
|
+
| `componentsDir` | `components` |
|
|
27
|
+
| `pipesFile` | `<viewsDir>/pipes.ts` |
|
|
28
|
+
| `trusted` | `false` — only `true` imports the project's `@forinda/kickjs-view` (its code runs in the server) |
|
|
29
|
+
|
|
30
|
+
The custom request `kick/templateNames` returns every template name except components.
|
|
31
|
+
|
|
32
|
+
See the [views guide](https://kickjs.app/guide/views#editor-support).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
import { URI } from "vscode-uri";
|
|
3
|
+
import * as View from "@forinda/kickjs-view";
|
|
4
|
+
import { Diagnostic, LanguageServicePlugin } from "@volar/language-service";
|
|
5
|
+
import { CodeMapping, IScriptSnapshot, LanguagePlugin, VirtualCode } from "@volar/language-core";
|
|
6
|
+
//#region src/server.d.ts
|
|
7
|
+
/** `initializationOptions`; paths are relative to the workspace folder. */
|
|
8
|
+
interface ServerOptions {
|
|
9
|
+
/** Default `src/views`. */
|
|
10
|
+
viewsDir?: string;
|
|
11
|
+
/** Default `components`, inside the views folder. */
|
|
12
|
+
componentsDir?: string;
|
|
13
|
+
/** Default `<viewsDir>/pipes.ts`. */
|
|
14
|
+
pipesFile?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The editor trusts the workspace, so the project's own `@forinda/kickjs-view`
|
|
17
|
+
* may be imported. Otherwise the bundled copy is used. Default `false`.
|
|
18
|
+
*/
|
|
19
|
+
trusted?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function startServer(): void;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/pipes.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Where each pipe in `pipes.ts` is declared and what it takes — for hover and
|
|
26
|
+
* go to definition. Read lexically, like the engine's `readPipeExports`: only
|
|
27
|
+
* `export const|let|var name = (…) =>` and `export function name(…)` forms.
|
|
28
|
+
*/
|
|
29
|
+
interface PipeDeclaration {
|
|
30
|
+
/** 0-based. */
|
|
31
|
+
line: number;
|
|
32
|
+
column: number;
|
|
33
|
+
signature: string;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/workspace.d.ts
|
|
37
|
+
type ViewModule = typeof View;
|
|
38
|
+
interface WorkspaceOptions {
|
|
39
|
+
root: string;
|
|
40
|
+
/** Absolute. */
|
|
41
|
+
viewsDir: string;
|
|
42
|
+
componentsDir: string;
|
|
43
|
+
/** Absolute. */
|
|
44
|
+
pipesFile: string;
|
|
45
|
+
view: ViewModule;
|
|
46
|
+
read(path: string): Promise<string | undefined>;
|
|
47
|
+
/** Every `.kick` file (absolute paths) under `dir`. */
|
|
48
|
+
list(dir: string): Promise<string[]>;
|
|
49
|
+
}
|
|
50
|
+
export declare class Workspace {
|
|
51
|
+
private readonly opts;
|
|
52
|
+
private readonly entries;
|
|
53
|
+
private readonly cache;
|
|
54
|
+
private pipes;
|
|
55
|
+
private pipeDecls;
|
|
56
|
+
constructor(opts: WorkspaceOptions);
|
|
57
|
+
get view(): ViewModule;
|
|
58
|
+
load(): Promise<void>;
|
|
59
|
+
private nameOfPath;
|
|
60
|
+
nameOf(uri: string): string | undefined;
|
|
61
|
+
uriOf(name: string): string;
|
|
62
|
+
componentsDir(): string;
|
|
63
|
+
pathOf(name: string): string;
|
|
64
|
+
names(): string[];
|
|
65
|
+
textOf(name: string): string | undefined;
|
|
66
|
+
astOf(name: string): View.TemplateAst | undefined;
|
|
67
|
+
/** An editor buffer for `uri`; `undefined` drops it and the file on disk applies again. */
|
|
68
|
+
setBuffer(uri: string, text: string | undefined): void;
|
|
69
|
+
/** `setBuffer`, skipped when the buffer is already `text`. */
|
|
70
|
+
sync(uri: string, text: string): void;
|
|
71
|
+
fileChanged(path: string): Promise<void>;
|
|
72
|
+
fileDeleted(path: string): Promise<void>;
|
|
73
|
+
private loadPipes;
|
|
74
|
+
private update;
|
|
75
|
+
private remove;
|
|
76
|
+
/** Drop cached diagnostics for `name` and every template that uses it, transitively. */
|
|
77
|
+
private invalidate;
|
|
78
|
+
/** Templates that use `name` as a component or a layout — a layout even after it's gone. */
|
|
79
|
+
dependentsOf(name: string): Set<string>;
|
|
80
|
+
pipeNames(): string[];
|
|
81
|
+
/** Where an app pipe is declared in `pipes.ts`, and its parameters. */
|
|
82
|
+
pipeDeclaration(name: string): PipeDeclaration | undefined;
|
|
83
|
+
pipesFile(): string;
|
|
84
|
+
project(): View.Project;
|
|
85
|
+
/** Parse errors, else everything `check` reports — as LSP diagnostics. */
|
|
86
|
+
diagnosticsFor(uri: string): Diagnostic[];
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/language-plugin.d.ts
|
|
90
|
+
export declare class KickVirtualCode implements VirtualCode {
|
|
91
|
+
readonly text: string;
|
|
92
|
+
readonly id = "root";
|
|
93
|
+
readonly languageId = "kick";
|
|
94
|
+
readonly snapshot: IScriptSnapshot;
|
|
95
|
+
readonly mappings: CodeMapping[];
|
|
96
|
+
readonly embeddedCodes: VirtualCode[];
|
|
97
|
+
constructor(text: string);
|
|
98
|
+
}
|
|
99
|
+
export declare const kickLanguagePlugin: LanguagePlugin<URI>;
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/plugin/index.d.ts
|
|
102
|
+
export declare function createKickServicePlugin(ws: Workspace): LanguageServicePlugin;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/view-module.d.ts
|
|
105
|
+
export declare function loadViewModule(root: string, warn: (message: string) => void,
|
|
106
|
+
/** The editor trusts this workspace: only then is the project's code imported. */
|
|
107
|
+
trusted: boolean): Promise<{
|
|
108
|
+
view: ViewModule;
|
|
109
|
+
source: 'project' | 'bundled';
|
|
110
|
+
version: string;
|
|
111
|
+
}>;
|
|
112
|
+
//#endregion
|
|
113
|
+
export type { ServerOptions, ViewModule, WorkspaceOptions };
|
|
114
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/server.ts","../src/pipes.ts","../src/workspace.ts","../src/language-plugin.ts","../src/plugin/index.ts","../src/view-module.ts"],"mappings":";;;;;;;UAmBiB;;EAEf;;EAEA;;EAEA;;;;;EAKA;;wBAcc;;;;;;;;UCvCC;;EAEf;EACA;EACA;;;;KCKU,oBAAoB;UAEf;EACf;;EAEA;EACA;;EAEA;EACA,MAAM;EACN,KAAK,eAAe;;EAEpB,KAAK,cAAc;;qBAaR;mBAMkB;mBALZ;mBACA;UACT;UACA;EAER,YAA6B,MAAM;MAE/B,QAAQ;EAIN,QAAQ;UAUN;EAMR,OAAO;EAIP,MAAM;EAIN;EAIA,OAAO;EAIP;EAIA,OAAO;EAKP,MAAM,eAAe,KAAK;;EAO1B,UAAU,aAAa;;EAYvB,KAAK,aAAa;EAIZ,YAAY,eAAe;EAc3B,YAAY,eAAe;UAenB;UAON;UA8BA;;UAMA;;EAkBR,aAAa,eAAe;EAc5B;;EAKA,gBAAgB,eAAe;EAI/B;EAIA,WAAW,KAAK;;EAShB,eAAe,cAAc;;;;qBCNlB,2BAA2B;WAOjB;WANZ;WACA;WACA,UAAU;WACV,UAAU;WACV,eAAe;EAExB,YAAqB;;qBA0CV,oBAAoB,eAAe;;;wBC/QhC,wBAAwB,IAAI,YAAY;;;wBC0ClC,eACpB,cACA,OAAO;;AAEP,mBACC;EAAU,MAAM;EAAY;EAA+B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-view-language-server v0.0.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
export { a as KickVirtualCode, n as Workspace, i as createKickServicePlugin, o as kickLanguagePlugin, r as loadViewModule, t as startServer } from "./server-BINLQyYR.js";
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-view-language-server v0.0.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { t as startServer } from "./server-BINLQyYR.js";
|
|
12
|
+
//#region src/main.ts
|
|
13
|
+
/** Runs the server — the entry editors launch (the bin and the VS Code bundle). */
|
|
14
|
+
startServer();
|
|
15
|
+
//#endregion
|
|
16
|
+
export {};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":[],"sources":["../src/main.ts"],"sourcesContent":["/** Runs the server — the entry editors launch (the bin and the VS Code bundle). */\nimport { startServer } from './server'\n\nstartServer()\n"],"mappings":";;;;;;;;;;;;;AAGA,YAAY"}
|