@likec4/language-services 1.56.0 → 1.58.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.
|
@@ -146,10 +146,12 @@ Please specify a project folder`);
|
|
|
146
146
|
return [...this.LangiumDocuments.userDocuments].length;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* Subscribe to model updates
|
|
150
|
+
* @param listener Function called when the model is updated - receives the project ID that was updated
|
|
151
|
+
* @returns A function to dispose the listener
|
|
150
152
|
*/
|
|
151
153
|
onModelUpdate(listener) {
|
|
152
|
-
const sib = this.modelBuilder.onModelParsed(() => listener());
|
|
154
|
+
const sib = this.modelBuilder.onModelParsed((projectId) => listener(projectId));
|
|
153
155
|
return () => {
|
|
154
156
|
sib.dispose();
|
|
155
157
|
};
|
|
@@ -192,11 +194,15 @@ const DefaultInitOptions = {
|
|
|
192
194
|
const validationErrorsToError = (likec4) => /* @__PURE__ */ new Error(`Invalid model:\n${likec4.getErrors().map((e) => ` ${e.sourceFsPath}:${e.line} ${e.message.slice(0, 200)}`).join("\n")}`);
|
|
193
195
|
async function handleInitOptions(langium, logger = rootLogger, options) {
|
|
194
196
|
const likec4 = new LikeC4(langium, logger);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
const throwIfInvalid = options?.throwIfInvalid ?? DefaultInitOptions.throwIfInvalid;
|
|
198
|
+
const printErrors = options?.printErrors ?? DefaultInitOptions.printErrors;
|
|
199
|
+
if ((throwIfInvalid || printErrors) && likec4.hasErrors()) {
|
|
200
|
+
if (throwIfInvalid) {
|
|
201
|
+
await likec4.dispose();
|
|
202
|
+
return Promise.reject(validationErrorsToError(likec4));
|
|
203
|
+
}
|
|
204
|
+
likec4.printErrors();
|
|
198
205
|
}
|
|
199
|
-
if ((options?.printErrors ?? DefaultInitOptions.printErrors) && likec4.hasErrors()) likec4.printErrors();
|
|
200
206
|
return likec4;
|
|
201
207
|
}
|
|
202
208
|
//#endregion
|
|
@@ -2,6 +2,7 @@ import { Logger } from "@likec4/log";
|
|
|
2
2
|
import { LikeC4LanguageServices, LikeC4ModelBuilder, LikeC4Services, LikeC4SharedServices, LikeC4Views, ProjectsManager } from "@likec4/language-server";
|
|
3
3
|
import { LikeC4Model } from "@likec4/core/model";
|
|
4
4
|
import { LayoutedView, NonEmptyArray, ProjectId } from "@likec4/core/types";
|
|
5
|
+
import { URI } from "vscode-uri";
|
|
5
6
|
|
|
6
7
|
//#region src/common/LikeC4.d.ts
|
|
7
8
|
interface LikeC4Langium {
|
|
@@ -15,15 +16,15 @@ declare class LikeC4 {
|
|
|
15
16
|
/**
|
|
16
17
|
* File system path to the workspace root
|
|
17
18
|
*/
|
|
18
|
-
get workspace():
|
|
19
|
+
get workspace(): string;
|
|
19
20
|
/**
|
|
20
21
|
* URI of the workspace root
|
|
21
22
|
*/
|
|
22
|
-
get workspaceURI():
|
|
23
|
+
get workspaceURI(): URI;
|
|
23
24
|
/**
|
|
24
25
|
* URL of the workspace root
|
|
25
26
|
*/
|
|
26
|
-
get workspaceURL():
|
|
27
|
+
get workspaceURL(): URL;
|
|
27
28
|
get languageServices(): LikeC4LanguageServices;
|
|
28
29
|
get projectsManager(): ProjectsManager;
|
|
29
30
|
get viewsService(): LikeC4Views;
|
|
@@ -82,9 +83,11 @@ declare class LikeC4 {
|
|
|
82
83
|
*/
|
|
83
84
|
documentCount(): number;
|
|
84
85
|
/**
|
|
85
|
-
*
|
|
86
|
+
* Subscribe to model updates
|
|
87
|
+
* @param listener Function called when the model is updated - receives the project ID that was updated
|
|
88
|
+
* @returns A function to dispose the listener
|
|
86
89
|
*/
|
|
87
|
-
onModelUpdate(listener: () => void): () => void;
|
|
90
|
+
onModelUpdate(listener: (projectId: ProjectId) => void): () => void;
|
|
88
91
|
/**
|
|
89
92
|
* Formats documents and returns a map of document URI → formatted source text.
|
|
90
93
|
*
|
|
@@ -143,7 +146,7 @@ interface InitOptions {
|
|
|
143
146
|
/**
|
|
144
147
|
* Whether to configure the logger.
|
|
145
148
|
*
|
|
146
|
-
* - `false` - don't configure the logger
|
|
149
|
+
* - `false` - don't configure the logger (assume it's already configured)
|
|
147
150
|
* - `'console'` - configure the logger with console sink
|
|
148
151
|
* - `'stderr'` - configure the logger with stderr (for LSP or MCP)
|
|
149
152
|
*
|
package/dist/browser/index.mjs
CHANGED
package/dist/node/index.mjs
CHANGED
|
@@ -88,7 +88,10 @@ async function fromWorkspace(path, options) {
|
|
|
88
88
|
const userDocuments = langium.shared.workspace.LangiumDocuments.userDocuments.toArray();
|
|
89
89
|
if (userDocuments.length === 0) {
|
|
90
90
|
logger.error(`no LikeC4 sources found`);
|
|
91
|
-
if (options?.throwIfInvalid)
|
|
91
|
+
if (options?.throwIfInvalid) {
|
|
92
|
+
await langium.likec4.likec4.LanguageServices.dispose();
|
|
93
|
+
throw new Error(`no LikeC4 sources found`);
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
logger.info(`${k.dim("workspace:")} found ${userDocuments.length} source files`);
|
|
94
97
|
return handleInitOptions(langium, rootLogger, options);
|
|
@@ -99,7 +102,7 @@ async function fromWorkspace(path, options) {
|
|
|
99
102
|
* @returns A Promise that resolves to a LikeC4 instance
|
|
100
103
|
*/
|
|
101
104
|
async function fromWorkdir(options) {
|
|
102
|
-
return fromWorkspace(".", options);
|
|
105
|
+
return await fromWorkspace(".", options);
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
108
|
* Create a LikeC4 instance from a record of source files
|
|
@@ -133,7 +136,7 @@ async function fromSources(sources, options) {
|
|
|
133
136
|
* @param options - Optional configuration options
|
|
134
137
|
* @returns A Promise that resolves to a LikeC4 instance
|
|
135
138
|
*/
|
|
136
|
-
|
|
139
|
+
function fromSource(source, options) {
|
|
137
140
|
return fromSources({ "source.c4": source }, options);
|
|
138
141
|
}
|
|
139
142
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-services",
|
|
3
3
|
"description": "LikeC4 Language Services",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.58.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -62,32 +62,33 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"defu": "^6.1.7",
|
|
65
|
-
"remeda": "^2.
|
|
65
|
+
"remeda": "^2.37.0",
|
|
66
66
|
"langium": "3.5.0",
|
|
67
67
|
"tinyrainbow": "^3.1.0",
|
|
68
68
|
"pathe": "^2.0.3",
|
|
69
|
-
"ufo": "1.6.
|
|
70
|
-
"std-env": "^
|
|
69
|
+
"ufo": "1.6.4",
|
|
70
|
+
"std-env": "^4.1.0",
|
|
71
71
|
"type-fest": "^4.41.0",
|
|
72
|
+
"vscode-uri": "3.1.0",
|
|
72
73
|
"vscode-languageserver-types": "3.17.5",
|
|
73
|
-
"@likec4/config": "1.
|
|
74
|
-
"@likec4/
|
|
75
|
-
"@likec4/
|
|
76
|
-
"@likec4/core": "1.56.0",
|
|
74
|
+
"@likec4/config": "1.58.0",
|
|
75
|
+
"@likec4/core": "1.58.0",
|
|
76
|
+
"@likec4/generators": "1.58.0",
|
|
77
77
|
"@likec4/icons": "1.46.4",
|
|
78
|
-
"@likec4/
|
|
79
|
-
"@likec4/
|
|
78
|
+
"@likec4/language-server": "1.58.0",
|
|
79
|
+
"@likec4/layouts": "1.58.0",
|
|
80
|
+
"@likec4/log": "1.58.0"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
|
-
"@types/node": "~22.19.
|
|
83
|
+
"@types/node": "~22.19.19",
|
|
83
84
|
"obuild": "0.4.31",
|
|
84
|
-
"oxlint": "1.
|
|
85
|
-
"tsx": "4.
|
|
86
|
-
"turbo": "2.9.
|
|
87
|
-
"typescript": "
|
|
88
|
-
"vitest": "4.1.
|
|
89
|
-
"@likec4/devops": "1.
|
|
90
|
-
"@likec4/tsconfig": "1.
|
|
85
|
+
"oxlint": "1.68.0",
|
|
86
|
+
"tsx": "4.22.4",
|
|
87
|
+
"turbo": "2.9.16",
|
|
88
|
+
"typescript": "6.0.3",
|
|
89
|
+
"vitest": "4.1.8",
|
|
90
|
+
"@likec4/devops": "1.58.0",
|
|
91
|
+
"@likec4/tsconfig": "1.58.0"
|
|
91
92
|
},
|
|
92
93
|
"scripts": {
|
|
93
94
|
"typecheck": "tsc -b --verbose",
|