@stateward/language-server 0.0.0-stage → 1.0.1-rc.1
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 +12 -2
- package/dist/adoption.d.ts +73 -0
- package/dist/adoption.js +122 -0
- package/dist/baseline.d.ts +17 -0
- package/dist/baseline.js +32 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.js +9 -0
- package/dist/configs.d.ts +13 -0
- package/dist/configs.js +53 -0
- package/dist/explain.d.ts +11 -0
- package/dist/explain.js +22 -0
- package/dist/fix-all.d.ts +44 -0
- package/dist/fix-all.js +92 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/inlay-hints.d.ts +22 -0
- package/dist/inlay-hints.js +34 -0
- package/dist/mapping.d.ts +52 -0
- package/dist/mapping.js +193 -0
- package/dist/memory.d.ts +13 -0
- package/dist/memory.js +16 -0
- package/dist/merge.d.ts +16 -0
- package/dist/merge.js +20 -0
- package/dist/progress.d.ts +16 -0
- package/dist/progress.js +22 -0
- package/dist/report.d.ts +21 -0
- package/dist/report.js +70 -0
- package/dist/server.d.ts +34 -0
- package/dist/server.js +1041 -0
- package/dist/watch.d.ts +31 -0
- package/dist/watch.js +59 -0
- package/package.json +49 -3
package/dist/watch.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ChangeKind = "config" | "config-import" | "source" | "ignored";
|
|
2
|
+
/**
|
|
3
|
+
* JavaScript files the server asks the editor to watch: a config can import a local `.mjs` or `.js`
|
|
4
|
+
* file (a team's shared rules), whose change must reload that config.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SCRIPT_GLOB = "**/*.{js,mjs,cjs}";
|
|
7
|
+
/**
|
|
8
|
+
* Whether `file` is a JSON file a program may import (`resolveJsonModule`), so the editor's unsaved
|
|
9
|
+
* text of it matters: not one in `node_modules`, not `package.json` or the lockfile, not a
|
|
10
|
+
* tsconfig or a stateward file (those are read as configuration, never as an import).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isImportableJson(file: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* What a change to `file` (outside the editor) means: a config changed (in any folder: each config
|
|
15
|
+
* has its own engine), a local file a config imports changed (`configImports`, TypeScript paths),
|
|
16
|
+
* some other file changed, or the change does not count: in `node_modules`, a JavaScript file no
|
|
17
|
+
* config imports (build output must not start a check), or `package.json` and the lockfile (a
|
|
18
|
+
* tsconfig, a stateward file and any other `.json` a program may import count as a source change).
|
|
19
|
+
*/
|
|
20
|
+
export declare function classifyChange(file: string, configImports?: ReadonlySet<string>): ChangeKind;
|
|
21
|
+
/**
|
|
22
|
+
* Remembers the last error shown, so the same error is not shown again on every check. A success
|
|
23
|
+
* forgets it: the same error after a recovery is news again.
|
|
24
|
+
*/
|
|
25
|
+
export type ErrorGate = {
|
|
26
|
+
/** True when `text` differs from the last error shown, and remembers it. */
|
|
27
|
+
shouldShow(text: string): boolean;
|
|
28
|
+
recovered(): void;
|
|
29
|
+
};
|
|
30
|
+
export declare function createErrorGate(): ErrorGate;
|
|
31
|
+
//# sourceMappingURL=watch.d.ts.map
|
package/dist/watch.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { toTypeScriptPath } from "@stateward/core/internal";
|
|
3
|
+
const CONFIG_NAME = /^stateward\.config\.(?:ts|mts|js|mjs)$/;
|
|
4
|
+
const SCRIPT = /\.[cm]?js$/;
|
|
5
|
+
/** JSON files no program imports and that change often: they must not cost a pass. */
|
|
6
|
+
const NOT_SOURCE_JSON = new Set(["package.json", "package-lock.json"]);
|
|
7
|
+
/**
|
|
8
|
+
* JavaScript files the server asks the editor to watch: a config can import a local `.mjs` or `.js`
|
|
9
|
+
* file (a team's shared rules), whose change must reload that config.
|
|
10
|
+
*/
|
|
11
|
+
export const SCRIPT_GLOB = "**/*.{js,mjs,cjs}";
|
|
12
|
+
/**
|
|
13
|
+
* Whether `file` is a JSON file a program may import (`resolveJsonModule`), so the editor's unsaved
|
|
14
|
+
* text of it matters: not one in `node_modules`, not `package.json` or the lockfile, not a
|
|
15
|
+
* tsconfig or a stateward file (those are read as configuration, never as an import).
|
|
16
|
+
*/
|
|
17
|
+
export function isImportableJson(file) {
|
|
18
|
+
const normal = toTypeScriptPath(file);
|
|
19
|
+
if (!normal.endsWith(".json") || normal.includes("/node_modules/"))
|
|
20
|
+
return false;
|
|
21
|
+
const name = path.basename(file);
|
|
22
|
+
return !(NOT_SOURCE_JSON.has(name) ||
|
|
23
|
+
/^tsconfig.*\.json$/.test(name) ||
|
|
24
|
+
/^stateward\..*\.json$/.test(name));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* What a change to `file` (outside the editor) means: a config changed (in any folder: each config
|
|
28
|
+
* has its own engine), a local file a config imports changed (`configImports`, TypeScript paths),
|
|
29
|
+
* some other file changed, or the change does not count: in `node_modules`, a JavaScript file no
|
|
30
|
+
* config imports (build output must not start a check), or `package.json` and the lockfile (a
|
|
31
|
+
* tsconfig, a stateward file and any other `.json` a program may import count as a source change).
|
|
32
|
+
*/
|
|
33
|
+
export function classifyChange(file, configImports = new Set()) {
|
|
34
|
+
const normal = toTypeScriptPath(file);
|
|
35
|
+
if (normal.includes("/node_modules/"))
|
|
36
|
+
return "ignored";
|
|
37
|
+
if (CONFIG_NAME.test(path.basename(file)))
|
|
38
|
+
return "config";
|
|
39
|
+
if (configImports.has(normal))
|
|
40
|
+
return "config-import";
|
|
41
|
+
if (NOT_SOURCE_JSON.has(path.basename(file)))
|
|
42
|
+
return "ignored";
|
|
43
|
+
return SCRIPT.test(normal) ? "ignored" : "source";
|
|
44
|
+
}
|
|
45
|
+
export function createErrorGate() {
|
|
46
|
+
let last;
|
|
47
|
+
return {
|
|
48
|
+
shouldShow(text) {
|
|
49
|
+
if (text === last)
|
|
50
|
+
return false;
|
|
51
|
+
last = text;
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
recovered() {
|
|
55
|
+
last = undefined;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=watch.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stateward/language-server",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1-rc.1",
|
|
4
|
+
"description": "The stateward language server: exclusive states and predictable code paths in any editor that speaks LSP, with findings, quick fixes and hints.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/khoing1111/ts-stateward.git",
|
|
9
|
+
"directory": "packages/language-server"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/khoing1111/ts-stateward/tree/main/packages/language-server#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/khoing1111/ts-stateward/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"bin": {
|
|
22
|
+
"stateward-language-server": "./dist/bin.js"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"source": "./src/index.ts",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./bin": {
|
|
31
|
+
"source": "./src/bin.ts",
|
|
32
|
+
"default": "./dist/bin.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"!dist/test",
|
|
38
|
+
"!dist/**/*.map",
|
|
39
|
+
"!dist/**/*.tsbuildinfo"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"vscode-languageserver": "^11.0.0",
|
|
43
|
+
"vscode-languageserver-textdocument": "^1.0.16",
|
|
44
|
+
"@stateward/core": "1.0.1-rc.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/react": "^19.3.0",
|
|
48
|
+
"react": "^19.3.1",
|
|
49
|
+
"vscode-jsonrpc": "10.0.0",
|
|
50
|
+
"@stateward/plugin-react-context": "1.0.1-rc.1"
|
|
51
|
+
}
|
|
6
52
|
}
|