@likec4/language-services 1.54.0 → 1.55.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/README.md CHANGED
@@ -79,11 +79,6 @@ const model = await likec4.layoutedModel()
79
79
  const projects = likec4.projects()
80
80
  ```
81
81
 
82
- > [!NOTE]
83
- > There is a separate entry point for node.js environment without MCP support: `@likec4/language-services/node/without-mcp`
84
- >
85
- > Useful to reduce bundle size
86
-
87
82
  ## API
88
83
 
89
84
  ### Factory Functions
@@ -1,8 +1,8 @@
1
1
  import { loggable, rootLogger } from "@likec4/log";
2
- import { extname } from "pathe";
2
+ import { URI, UriUtils } from "langium";
3
3
  import k from "tinyrainbow";
4
4
  import { LikeC4ProjectConfigOps, isLikeC4JsonConfig } from "@likec4/config";
5
- import { URI, UriUtils } from "langium";
5
+ import { extname } from "pathe";
6
6
  import { entries, flatMap, hasAtLeast, join, map, partition, pipe, prop } from "remeda";
7
7
  const isErrorDiagnostic = (diagnostic) => {
8
8
  return diagnostic.severity === 1;
@@ -1,28 +1,43 @@
1
1
  import { i as LikeC4, n as handleInitOptions, r as DefaultInitOptions, t as createFromSources } from "../_chunks/createFromSources.mjs";
2
- import { t as configureLogger$1 } from "../_chunks/configureLogger.mjs";
3
- import { loggable, rootLogger } from "@likec4/log";
2
+ import { rootLogger } from "@likec4/log";
4
3
  import defu from "defu";
5
- import { basename, resolve } from "pathe";
4
+ import { URI } from "langium";
5
+ import { basename, resolve } from "node:path";
6
6
  import k from "tinyrainbow";
7
7
  import { withTrailingSlash } from "ufo";
8
- import { pathToFileURL } from "url";
8
+ import { configureLanguageServerLogger } from "@likec4/language-server";
9
+ import { isColorSupported } from "std-env";
9
10
  import { WithFileSystem, WithLikeC4ManualLayouts } from "@likec4/language-server/filesystem";
10
- import { WithMCPServer } from "@likec4/language-server/mcp";
11
11
  import { NoFileSystem, NoLikeC4ManualLayouts, WithGraphviz, createLanguageServices } from "@likec4/language-server/module";
12
12
  import { GraphvizWasmAdapter } from "@likec4/layouts";
13
13
  import { GraphvizBinaryAdapter } from "@likec4/layouts/graphviz/binary";
14
+ function configureLogger$1(options) {
15
+ const opt = options?.configureLogger ?? false;
16
+ if (opt === false) return;
17
+ if (opt === "stderr" || options?.mcp === "stdio") {
18
+ configureLanguageServerLogger({
19
+ useStdErr: true,
20
+ colors: false,
21
+ logLevel: options?.logLevel
22
+ });
23
+ return;
24
+ }
25
+ configureLanguageServerLogger({
26
+ colors: isColorSupported,
27
+ logLevel: options?.logLevel
28
+ });
29
+ }
14
30
  function createLanguageServices$1(opts) {
15
31
  const logger = rootLogger.getChild("lang");
16
32
  const options = defu(opts, {
17
33
  useFileSystem: true,
18
34
  manualLayouts: true,
19
35
  watch: false,
20
- graphviz: "wasm",
21
- mcp: false
36
+ graphviz: "wasm"
22
37
  });
23
38
  const useDotBin = options.graphviz === "binary";
24
39
  logger.info(`${k.dim("layout")} ${useDotBin ? "binary" : "wasm"}`);
25
- const langium = createLanguageServices({
40
+ return createLanguageServices({
26
41
  ...options.useFileSystem ? {
27
42
  ...WithFileSystem(options.watch),
28
43
  ...options.manualLayouts ? WithLikeC4ManualLayouts : NoLikeC4ManualLayouts
@@ -30,16 +45,8 @@ function createLanguageServices$1(opts) {
30
45
  ...NoFileSystem,
31
46
  ...NoLikeC4ManualLayouts
32
47
  },
33
- ...options.mcp ? WithMCPServer(options.mcp === "stdio" ? "stdio" : options.mcp) : {},
34
48
  ...WithGraphviz(useDotBin ? new GraphvizBinaryAdapter() : new GraphvizWasmAdapter())
35
49
  });
36
- if (typeof options.mcp === "object" && options.mcp.port) langium.likec4.mcp.Server.start(options.mcp.port).catch((e) => {
37
- logger.error(loggable(e));
38
- });
39
- if (options.mcp === "stdio") langium.likec4.mcp.Server.start().catch((e) => {
40
- logger.error(loggable(e));
41
- });
42
- return langium;
43
50
  }
44
51
  /**
45
52
  * Create a LikeC4 instance from a workspace directory
@@ -50,14 +57,13 @@ function createLanguageServices$1(opts) {
50
57
  */
51
58
  async function fromWorkspace(path, options) {
52
59
  const workspacePath = resolve(path);
53
- const workspaceUri = withTrailingSlash(pathToFileURL(workspacePath).toString());
60
+ const workspaceUri = withTrailingSlash(URI.file(workspacePath).toString());
54
61
  const logger = rootLogger.getChild("lang");
55
62
  const opts = defu(options, {
56
63
  ...DefaultInitOptions,
57
64
  useFileSystem: true,
58
65
  manualLayouts: true,
59
- watch: false,
60
- mcp: false
66
+ watch: false
61
67
  });
62
68
  configureLogger$1(opts);
63
69
  const langium = createLanguageServices$1(opts);
@@ -70,7 +76,7 @@ async function fromWorkspace(path, options) {
70
76
  WorkspaceManager.initialize({
71
77
  capabilities: {},
72
78
  processId: null,
73
- rootUri: null,
79
+ rootUri: workspace.uri,
74
80
  workspaceFolders: [workspace]
75
81
  });
76
82
  await WorkspaceManager.initializeWorkspace([workspace]);
@@ -113,8 +119,7 @@ async function fromSources(sources, options) {
113
119
  ...DefaultInitOptions,
114
120
  useFileSystem: false,
115
121
  watch: false,
116
- manualLayouts: false,
117
- mcp: false
122
+ manualLayouts: false
118
123
  })), logger, sources, options);
119
124
  }
120
125
  /**
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.54.0",
4
+ "version": "1.55.1",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -46,14 +46,6 @@
46
46
  "default": "./dist/browser/index.mjs"
47
47
  }
48
48
  },
49
- "./node/without-mcp": {
50
- "sources": "./src/node/without-mcp/index.ts",
51
- "default": {
52
- "types": "./dist/node/without-mcp/index.d.mts",
53
- "import": "./dist/node/without-mcp/index.mjs",
54
- "default": "./dist/node/without-mcp/index.mjs"
55
- }
56
- },
57
49
  "./node": {
58
50
  "sources": "./src/node/index.ts",
59
51
  "default": {
@@ -69,8 +61,8 @@
69
61
  "access": "public"
70
62
  },
71
63
  "dependencies": {
72
- "defu": "^6.1.6",
73
- "remeda": "^2.33.6",
64
+ "defu": "^6.1.7",
65
+ "remeda": "^2.33.7",
74
66
  "langium": "3.5.0",
75
67
  "tinyrainbow": "^3.0.3",
76
68
  "pathe": "^2.0.3",
@@ -78,24 +70,24 @@
78
70
  "std-env": "^3.10.0",
79
71
  "type-fest": "^4.41.0",
80
72
  "vscode-languageserver-types": "3.17.5",
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",
73
+ "@likec4/generators": "1.55.1",
74
+ "@likec4/language-server": "1.55.1",
75
+ "@likec4/core": "1.55.1",
76
+ "@likec4/config": "1.55.1",
86
77
  "@likec4/icons": "1.46.4",
87
- "@likec4/log": "1.54.0"
78
+ "@likec4/log": "1.55.1",
79
+ "@likec4/layouts": "1.55.1"
88
80
  },
89
81
  "devDependencies": {
90
82
  "@types/node": "~22.19.15",
91
83
  "obuild": "0.4.31",
92
- "oxlint": "1.55.0",
84
+ "oxlint": "1.59.0",
93
85
  "tsx": "4.21.0",
94
- "turbo": "2.8.21",
86
+ "turbo": "2.9.5",
95
87
  "typescript": "5.9.3",
96
- "vitest": "4.1.0",
88
+ "vitest": "4.1.3",
97
89
  "@likec4/devops": "1.42.0",
98
- "@likec4/tsconfig": "1.54.0"
90
+ "@likec4/tsconfig": "1.55.1"
99
91
  },
100
92
  "scripts": {
101
93
  "typecheck": "tsc -b --verbose",
@@ -1,19 +0,0 @@
1
- import { configureLanguageServerLogger } from "@likec4/language-server";
2
- import { isColorSupported } from "std-env";
3
- function configureLogger(options) {
4
- const opt = options?.configureLogger ?? false;
5
- if (opt === false) return;
6
- if (opt === "stderr" || options?.mcp === "stdio") {
7
- configureLanguageServerLogger({
8
- useStdErr: true,
9
- colors: false,
10
- logLevel: options?.logLevel
11
- });
12
- return;
13
- }
14
- configureLanguageServerLogger({
15
- colors: isColorSupported,
16
- logLevel: options?.logLevel
17
- });
18
- }
19
- export { configureLogger as t };
@@ -1,43 +0,0 @@
1
- import { i as LikeC4Langium, n as InitOptions, r as LikeC4, t as FromWorkspaceOptions } from "../../_chunks/options.mjs";
2
-
3
- //#region src/node/without-mcp/index.d.ts
4
- /**
5
- * Create a LikeC4 instance from a workspace directory
6
- *
7
- * @param path - The workspace directory path
8
- * @param options - Optional configuration options
9
- * @returns A Promise that resolves to a LikeC4 instance
10
- */
11
- declare function fromWorkspace(path: string, options?: FromWorkspaceOptions): Promise<LikeC4>;
12
- /**
13
- * Create a LikeC4 instance from the current working directory
14
- * @param options - Optional configuration options
15
- * @returns A Promise that resolves to a LikeC4 instance
16
- */
17
- declare function fromWorkdir(options?: FromWorkspaceOptions): Promise<LikeC4>;
18
- /**
19
- * Create a LikeC4 instance from a record of source files
20
- *
21
- * @example
22
- * ```ts
23
- * const likec4 = await fromSources({
24
- * 'likec4.config.json': '...', // optional, stringified LikeC4Config
25
- * 'model.c4': 'model { ... }',
26
- * 'path/views.c4': 'views { ... }',
27
- * })
28
- * ```
29
- *
30
- * @param sources - A record of file paths to source content
31
- * @param options - Optional configuration options
32
- * @returns A Promise that resolves to a LikeC4 instance
33
- */
34
- declare function fromSources(sources: Record<string, string>, options?: InitOptions): Promise<LikeC4>;
35
- /**
36
- * Create a LikeC4 instance from a single source string
37
- * @param source - The LikeC4 source code
38
- * @param options - Optional configuration options
39
- * @returns A Promise that resolves to a LikeC4 instance
40
- */
41
- declare function fromSource(source: string, options?: InitOptions): Promise<LikeC4>;
42
- //#endregion
43
- export { type FromWorkspaceOptions, type InitOptions, LikeC4, type LikeC4Langium, fromSource, fromSources, fromWorkdir, fromWorkspace };
@@ -1,117 +0,0 @@
1
- import { i as LikeC4, n as handleInitOptions, r as DefaultInitOptions, t as createFromSources } from "../../_chunks/createFromSources.mjs";
2
- import { t as configureLogger$1 } from "../../_chunks/configureLogger.mjs";
3
- import { rootLogger } from "@likec4/log";
4
- import defu from "defu";
5
- import { basename, resolve } from "pathe";
6
- import k from "tinyrainbow";
7
- import { pathToFileURL } from "url";
8
- import { WithFileSystem, WithLikeC4ManualLayouts } from "@likec4/language-server/filesystem";
9
- import { NoFileSystem, NoLikeC4ManualLayouts, WithGraphviz, createLanguageServices } from "@likec4/language-server/module";
10
- import { GraphvizWasmAdapter } from "@likec4/layouts";
11
- import { GraphvizBinaryAdapter } from "@likec4/layouts/graphviz/binary";
12
- function createLanguageServices$1(opts) {
13
- const logger = rootLogger.getChild("lang");
14
- const options = defu(opts, {
15
- useFileSystem: true,
16
- manualLayouts: true,
17
- watch: false,
18
- graphviz: "wasm"
19
- });
20
- const useDotBin = options.graphviz === "binary";
21
- logger.info(`${k.dim("layout")} ${useDotBin ? "binary" : "wasm"}`);
22
- return createLanguageServices({
23
- ...options.useFileSystem ? {
24
- ...WithFileSystem(options.watch),
25
- ...options.manualLayouts ? WithLikeC4ManualLayouts : NoLikeC4ManualLayouts
26
- } : {
27
- ...NoFileSystem,
28
- ...NoLikeC4ManualLayouts
29
- },
30
- ...WithGraphviz(useDotBin ? new GraphvizBinaryAdapter() : new GraphvizWasmAdapter())
31
- });
32
- }
33
- /**
34
- * Create a LikeC4 instance from a workspace directory
35
- *
36
- * @param path - The workspace directory path
37
- * @param options - Optional configuration options
38
- * @returns A Promise that resolves to a LikeC4 instance
39
- */
40
- async function fromWorkspace(path, options) {
41
- const workspacePath = resolve(path);
42
- const folderUri = pathToFileURL(workspacePath).toString();
43
- const workspaceUri = folderUri.endsWith("/") ? folderUri : folderUri + "/";
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]
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);
74
- }
75
- /**
76
- * Create a LikeC4 instance from the current working directory
77
- * @param options - Optional configuration options
78
- * @returns A Promise that resolves to a LikeC4 instance
79
- */
80
- async function fromWorkdir(options) {
81
- return fromWorkspace(".", options);
82
- }
83
- /**
84
- * Create a LikeC4 instance from a record of source files
85
- *
86
- * @example
87
- * ```ts
88
- * const likec4 = await fromSources({
89
- * 'likec4.config.json': '...', // optional, stringified LikeC4Config
90
- * 'model.c4': 'model { ... }',
91
- * 'path/views.c4': 'views { ... }',
92
- * })
93
- * ```
94
- *
95
- * @param sources - A record of file paths to source content
96
- * @param options - Optional configuration options
97
- * @returns A Promise that resolves to a LikeC4 instance
98
- */
99
- async function fromSources(sources, options) {
100
- configureLogger$1(options);
101
- const logger = rootLogger.getChild("lang");
102
- return await createFromSources(createLanguageServices$1(defu(options, {
103
- useFileSystem: false,
104
- watch: false,
105
- manualLayouts: false
106
- })), logger, sources, options);
107
- }
108
- /**
109
- * Create a LikeC4 instance from a single source string
110
- * @param source - The LikeC4 source code
111
- * @param options - Optional configuration options
112
- * @returns A Promise that resolves to a LikeC4 instance
113
- */
114
- async function fromSource(source, options) {
115
- return fromSources({ "source.c4": source }, options);
116
- }
117
- export { LikeC4, fromSource, fromSources, fromWorkdir, fromWorkspace };
@@ -1,4 +0,0 @@
1
- {
2
- "types": "../../dist/node/without-mcp/index.d.mts",
3
- "module": "../../dist/node/without-mcp/index.mjs"
4
- }