@likec4/language-services 1.53.0 → 1.54.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.
@@ -7,14 +7,6 @@ import { entries, flatMap, hasAtLeast, join, map, partition, pipe, prop } from "
7
7
  const isErrorDiagnostic = (diagnostic) => {
8
8
  return diagnostic.severity === 1;
9
9
  };
10
- const firstFiveLines = (message) => {
11
- const messages = message.split("\n");
12
- if (messages.length > 5) {
13
- messages.length = 5;
14
- messages.push("...");
15
- }
16
- return messages.join("\n");
17
- };
18
10
  var LikeC4 = class {
19
11
  langium;
20
12
  logger;
@@ -109,7 +101,7 @@ Please specify a project folder`);
109
101
  getErrors() {
110
102
  return [...this.LangiumDocuments.userDocuments].flatMap((doc) => {
111
103
  return (doc.diagnostics?.filter(isErrorDiagnostic) ?? []).map(({ message, range }) => ({
112
- message: firstFiveLines(message),
104
+ message,
113
105
  line: range.start.line,
114
106
  range,
115
107
  sourceFsPath: doc.uri.fsPath
@@ -130,9 +122,14 @@ Please specify a project folder`);
130
122
  const errors = doc.diagnostics?.filter(isErrorDiagnostic) ?? [];
131
123
  if (!hasAtLeast(errors, 1)) continue;
132
124
  hasErrors = true;
133
- const messages = pipe(errors, flatMap((error) => {
134
- const line = error.range.start.line;
135
- return firstFiveLines(error.message).split("\n").map((message, i) => {
125
+ const messages = pipe(errors, flatMap((validationError) => {
126
+ const line = validationError.range.start.line;
127
+ const messages = validationError.message.split("\n");
128
+ if (messages.length > 5) {
129
+ messages.length = 5;
130
+ messages.push("...");
131
+ }
132
+ return messages.map((message, i) => {
136
133
  if (i === 0) return " " + k.dim(`Line ${line}: `) + k.red(message);
137
134
  return " ".repeat(10) + k.red(message);
138
135
  });
@@ -3,7 +3,6 @@ import { i as LikeC4Langium, n as InitOptions, r as LikeC4, t as FromWorkspaceOp
3
3
  //#region src/node/index.d.ts
4
4
  /**
5
5
  * Create a LikeC4 instance from a workspace directory
6
- * The instance is cached in globalThis to avoid creating multiple instances for the same workspace
7
6
  *
8
7
  * @param path - The workspace directory path
9
8
  * @param options - Optional configuration options
@@ -1,6 +1,5 @@
1
1
  import { i as LikeC4, n as handleInitOptions, r as DefaultInitOptions, t as createFromSources } from "../_chunks/createFromSources.mjs";
2
2
  import { t as configureLogger$1 } from "../_chunks/configureLogger.mjs";
3
- import { memoizeProp } from "@likec4/core";
4
3
  import { loggable, rootLogger } from "@likec4/log";
5
4
  import defu from "defu";
6
5
  import { basename, resolve } from "pathe";
@@ -44,7 +43,6 @@ function createLanguageServices$1(opts) {
44
43
  }
45
44
  /**
46
45
  * Create a LikeC4 instance from a workspace directory
47
- * The instance is cached in globalThis to avoid creating multiple instances for the same workspace
48
46
  *
49
47
  * @param path - The workspace directory path
50
48
  * @param options - Optional configuration options
@@ -53,38 +51,36 @@ function createLanguageServices$1(opts) {
53
51
  async function fromWorkspace(path, options) {
54
52
  const workspacePath = resolve(path);
55
53
  const workspaceUri = withTrailingSlash(pathToFileURL(workspacePath).toString());
56
- return memoizeProp(globalThis, "likec4:" + workspacePath, async () => {
57
- const logger = rootLogger.getChild("lang");
58
- const opts = defu(options, {
59
- ...DefaultInitOptions,
60
- useFileSystem: true,
61
- manualLayouts: true,
62
- watch: false,
63
- mcp: false
64
- });
65
- configureLogger$1(opts);
66
- const langium = createLanguageServices$1(opts);
67
- const workspace = {
68
- name: basename(workspacePath),
69
- uri: workspaceUri
70
- };
71
- const WorkspaceManager = langium.shared.workspace.WorkspaceManager;
72
- logger.info(`${k.dim("workspace:")} ${workspacePath}`);
73
- WorkspaceManager.initialize({
74
- capabilities: {},
75
- processId: null,
76
- rootUri: null,
77
- workspaceFolders: [workspace]
78
- });
79
- await WorkspaceManager.initializeWorkspace([workspace]);
80
- const userDocuments = langium.shared.workspace.LangiumDocuments.userDocuments.toArray();
81
- if (userDocuments.length === 0) {
82
- logger.error(`no LikeC4 sources found`);
83
- if (options?.throwIfInvalid) throw new Error(`no LikeC4 sources found`);
84
- }
85
- logger.info(`${k.dim("workspace:")} found ${userDocuments.length} source files`);
86
- return handleInitOptions(langium, rootLogger, options);
54
+ const logger = rootLogger.getChild("lang");
55
+ const opts = defu(options, {
56
+ ...DefaultInitOptions,
57
+ useFileSystem: true,
58
+ manualLayouts: true,
59
+ watch: false,
60
+ mcp: false
61
+ });
62
+ configureLogger$1(opts);
63
+ const langium = createLanguageServices$1(opts);
64
+ const workspace = {
65
+ name: basename(workspacePath),
66
+ uri: workspaceUri
67
+ };
68
+ const WorkspaceManager = langium.shared.workspace.WorkspaceManager;
69
+ logger.info(`${k.dim("workspace:")} ${workspacePath}`);
70
+ WorkspaceManager.initialize({
71
+ capabilities: {},
72
+ processId: null,
73
+ rootUri: null,
74
+ workspaceFolders: [workspace]
87
75
  });
76
+ await WorkspaceManager.initializeWorkspace([workspace]);
77
+ const userDocuments = langium.shared.workspace.LangiumDocuments.userDocuments.toArray();
78
+ if (userDocuments.length === 0) {
79
+ logger.error(`no LikeC4 sources found`);
80
+ if (options?.throwIfInvalid) throw new Error(`no LikeC4 sources found`);
81
+ }
82
+ logger.info(`${k.dim("workspace:")} found ${userDocuments.length} source files`);
83
+ return handleInitOptions(langium, rootLogger, options);
88
84
  }
89
85
  /**
90
86
  * Create a LikeC4 instance from the current working directory
@@ -3,7 +3,6 @@ import { i as LikeC4Langium, n as InitOptions, r as LikeC4, t as FromWorkspaceOp
3
3
  //#region src/node/without-mcp/index.d.ts
4
4
  /**
5
5
  * Create a LikeC4 instance from a workspace directory
6
- * The instance is cached in globalThis to avoid creating multiple instances for the same workspace
7
6
  *
8
7
  * @param path - The workspace directory path
9
8
  * @param options - Optional configuration options
@@ -1,6 +1,5 @@
1
1
  import { i as LikeC4, n as handleInitOptions, r as DefaultInitOptions, t as createFromSources } from "../../_chunks/createFromSources.mjs";
2
2
  import { t as configureLogger$1 } from "../../_chunks/configureLogger.mjs";
3
- import { memoizeProp } from "@likec4/core";
4
3
  import { rootLogger } from "@likec4/log";
5
4
  import defu from "defu";
6
5
  import { basename, resolve } from "pathe";
@@ -33,7 +32,6 @@ function createLanguageServices$1(opts) {
33
32
  }
34
33
  /**
35
34
  * Create a LikeC4 instance from a workspace directory
36
- * The instance is cached in globalThis to avoid creating multiple instances for the same workspace
37
35
  *
38
36
  * @param path - The workspace directory path
39
37
  * @param options - Optional configuration options
@@ -43,38 +41,36 @@ async function fromWorkspace(path, options) {
43
41
  const workspacePath = resolve(path);
44
42
  const folderUri = pathToFileURL(workspacePath).toString();
45
43
  const workspaceUri = folderUri.endsWith("/") ? folderUri : folderUri + "/";
46
- return memoizeProp(globalThis, "likec4:" + workspacePath, async () => {
47
- const logger = rootLogger.getChild("lang");
48
- const mergedOptions = defu(options, {
49
- ...DefaultInitOptions,
50
- useFileSystem: true,
51
- manualLayouts: true,
52
- watch: false
53
- });
54
- configureLogger$1(mergedOptions);
55
- if (mergedOptions.mcp) throw new Error("MCP server is not supported in this build");
56
- const langium = createLanguageServices$1(mergedOptions);
57
- const workspace = {
58
- name: basename(workspacePath),
59
- uri: workspaceUri
60
- };
61
- const WorkspaceManager = langium.shared.workspace.WorkspaceManager;
62
- logger.info(`${k.dim("workspace:")} ${workspacePath}`);
63
- WorkspaceManager.initialize({
64
- capabilities: {},
65
- processId: null,
66
- rootUri: null,
67
- workspaceFolders: [workspace]
68
- });
69
- await WorkspaceManager.initializeWorkspace([workspace]);
70
- const userDocuments = langium.shared.workspace.LangiumDocuments.userDocuments.toArray();
71
- if (userDocuments.length === 0) {
72
- logger.error(`no LikeC4 sources found`);
73
- throw new Error(`no LikeC4 sources found`);
74
- }
75
- logger.info(`${k.dim("workspace:")} found ${userDocuments.length} source files`);
76
- return handleInitOptions(langium, rootLogger, options);
44
+ const logger = rootLogger.getChild("lang");
45
+ const mergedOptions = defu(options, {
46
+ ...DefaultInitOptions,
47
+ useFileSystem: true,
48
+ manualLayouts: true,
49
+ watch: false
50
+ });
51
+ configureLogger$1(mergedOptions);
52
+ if (mergedOptions.mcp) throw new Error("MCP server is not supported in this build");
53
+ const langium = createLanguageServices$1(mergedOptions);
54
+ const workspace = {
55
+ name: basename(workspacePath),
56
+ uri: workspaceUri
57
+ };
58
+ const WorkspaceManager = langium.shared.workspace.WorkspaceManager;
59
+ logger.info(`${k.dim("workspace:")} ${workspacePath}`);
60
+ WorkspaceManager.initialize({
61
+ capabilities: {},
62
+ processId: null,
63
+ rootUri: null,
64
+ workspaceFolders: [workspace]
77
65
  });
66
+ await WorkspaceManager.initializeWorkspace([workspace]);
67
+ const userDocuments = langium.shared.workspace.LangiumDocuments.userDocuments.toArray();
68
+ if (userDocuments.length === 0) {
69
+ logger.error(`no LikeC4 sources found`);
70
+ throw new Error(`no LikeC4 sources found`);
71
+ }
72
+ logger.info(`${k.dim("workspace:")} found ${userDocuments.length} source files`);
73
+ return handleInitOptions(langium, rootLogger, options);
78
74
  }
79
75
  /**
80
76
  * Create a LikeC4 instance from the current working directory
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.53.0",
4
+ "version": "1.54.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -69,7 +69,7 @@
69
69
  "access": "public"
70
70
  },
71
71
  "dependencies": {
72
- "defu": "^6.1.4",
72
+ "defu": "^6.1.6",
73
73
  "remeda": "^2.33.6",
74
74
  "langium": "3.5.0",
75
75
  "tinyrainbow": "^3.0.3",
@@ -78,24 +78,24 @@
78
78
  "std-env": "^3.10.0",
79
79
  "type-fest": "^4.41.0",
80
80
  "vscode-languageserver-types": "3.17.5",
81
- "@likec4/config": "1.53.0",
82
- "@likec4/core": "1.53.0",
81
+ "@likec4/config": "1.54.0",
82
+ "@likec4/core": "1.54.0",
83
+ "@likec4/language-server": "1.54.0",
84
+ "@likec4/generators": "1.54.0",
85
+ "@likec4/layouts": "1.54.0",
83
86
  "@likec4/icons": "1.46.4",
84
- "@likec4/language-server": "1.53.0",
85
- "@likec4/layouts": "1.53.0",
86
- "@likec4/generators": "1.53.0",
87
- "@likec4/log": "1.53.0"
87
+ "@likec4/log": "1.54.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/node": "~22.19.15",
91
91
  "obuild": "0.4.31",
92
92
  "oxlint": "1.55.0",
93
93
  "tsx": "4.21.0",
94
- "turbo": "2.8.17",
94
+ "turbo": "2.8.21",
95
95
  "typescript": "5.9.3",
96
96
  "vitest": "4.1.0",
97
97
  "@likec4/devops": "1.42.0",
98
- "@likec4/tsconfig": "1.53.0"
98
+ "@likec4/tsconfig": "1.54.0"
99
99
  },
100
100
  "scripts": {
101
101
  "typecheck": "tsc -b --verbose",