@likec4/language-server 1.58.0 → 1.59.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.
@@ -1,2 +1,2 @@
1
- import { A as WithFileSystem, B as LikeC4ManualLayoutsModuleContext, F as FileSystemModuleContext, I as FileSystemProvider, L as FileSystemWatcher, M as NoFileSystemWatcher, N as NoLikeC4ManualLayouts, O as WithLikeC4ManualLayouts, P as FileNode, R as FileSystemWatcherModuleContext, V as ManualLayoutsSnapshot, j as NoFileSystem, k as WithChokidarWatcher, z as LikeC4ManualLayouts } from "../_chunks/module.mjs";
2
- export { FileNode, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, ManualLayoutsSnapshot, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithChokidarWatcher, WithFileSystem, WithLikeC4ManualLayouts };
1
+ import { A as WithFileSystem, B as LikeC4ManualLayoutsModuleContext, F as FileSystemModuleContext, I as FileSystemProvider, L as FileSystemWatcher, M as NoFileSystemWatcher, N as NoLikeC4ManualLayouts, O as WithLikeC4ManualLayouts, P as FileNode, R as FileSystemWatcherModuleContext, V as ManualLayoutsSnapshot, j as NoFileSystem, k as WithChokidarWatcher, z as LikeC4ManualLayouts } from "../chunks/module.mjs";
2
+ export { type FileNode, type FileSystemModuleContext, type FileSystemProvider, type FileSystemWatcher, type FileSystemWatcherModuleContext, type LikeC4ManualLayouts, type LikeC4ManualLayoutsModuleContext, type ManualLayoutsSnapshot, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithChokidarWatcher, WithFileSystem, WithLikeC4ManualLayouts };
@@ -1 +1,4 @@
1
- import{ai as e,oi as t,si as n}from"../_chunks/utils.mjs";import{n as r,r as i,t as a}from"../_chunks/LikeC4FileSystem.mjs";export{e as NoFileSystem,t as NoFileSystemWatcher,n as NoLikeC4ManualLayouts,r as WithChokidarWatcher,a as WithFileSystem,i as WithLikeC4ManualLayouts};
1
+ import { Lr as NoFileSystem, Rr as NoFileSystemWatcher, zr as NoLikeC4ManualLayouts } from "../chunks/utils.mjs";
2
+ import { n as WithChokidarWatcher, r as WithLikeC4ManualLayouts, t as WithFileSystem } from "../chunks/LikeC4FileSystem.mjs";
3
+
4
+ export { NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithChokidarWatcher, WithFileSystem, WithLikeC4ManualLayouts };
package/dist/icons.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as iconRegistry, i as iconGroups, n as IconGroup, t as GroupedIcons } from "./_chunks/icons.mjs";
1
+ import { a as iconRegistry, i as iconGroups, n as IconGroup, t as GroupedIcons } from "./chunks/icons.mjs";
2
2
  export { type GroupedIcons, type IconGroup, iconGroups, iconRegistry };
package/dist/icons.mjs CHANGED
@@ -1 +1,3 @@
1
- import{n as e,r as t}from"./_chunks/icons.mjs";export{e as iconGroups,t as iconRegistry};
1
+ import { n as iconGroups, r as iconRegistry } from "./chunks/icons.mjs";
2
+
3
+ export { iconGroups, iconRegistry };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as WithFileSystem, B as LikeC4ManualLayoutsModuleContext, C as ViewLocateResult, D as LangiumDocuments, E as LikeC4WorkspaceManager, F as FileSystemModuleContext, H as Project, I as FileSystemProvider, L as FileSystemWatcher, M as NoFileSystemWatcher, N as NoLikeC4ManualLayouts, O as WithLikeC4ManualLayouts, R as FileSystemWatcherModuleContext, S as LikeC4ModelLocator, T as FqnIndex, U as ProjectData, W as ProjectsManager, _ as LikeC4ViewsModuleContext, b as LayoutViewParams, d as LikeC4LanguageServices, f as DocumentParser, g as configureLanguageServerLogger, h as ConfigureLanguageServerLoggerOptions, j as NoFileSystem, m as startLanguageServer, n as LikeC4AddedServices, o as LikeC4SharedServices, p as LikeC4ModelParser, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as FormatOptions, w as LikeC4ModelBuilder, x as LikeC4Views, y as WithWasmGraphviz, z as LikeC4ManualLayouts } from "./_chunks/module.mjs";
2
- export { ConfigureLanguageServerLoggerOptions, DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FormatOptions, FqnIndex, LangiumDocuments, LanguageServicesContext, LayoutViewParams, LikeC4AddedServices, LikeC4LanguageServices, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser, LikeC4Services, LikeC4SharedServices, LikeC4Views, LikeC4ViewsModuleContext, LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, Project, ProjectData, ProjectsManager, ViewLocateResult, WithFileSystem, WithLikeC4ManualLayouts, WithWasmGraphviz, configureLanguageServerLogger, createLanguageServices, startLanguageServer };
1
+ import { A as WithFileSystem, B as LikeC4ManualLayoutsModuleContext, C as ViewLocateResult, D as LangiumDocuments, E as LikeC4WorkspaceManager, F as FileSystemModuleContext, H as Project, I as FileSystemProvider, L as FileSystemWatcher, M as NoFileSystemWatcher, N as NoLikeC4ManualLayouts, O as WithLikeC4ManualLayouts, R as FileSystemWatcherModuleContext, S as LikeC4ModelLocator, T as FqnIndex, U as ProjectData, W as ProjectsManager, _ as LikeC4ViewsModuleContext, b as LayoutViewParams, d as LikeC4LanguageServices, f as DocumentParser, g as configureLanguageServerLogger, h as ConfigureLanguageServerLoggerOptions, j as NoFileSystem, m as startLanguageServer, n as LikeC4AddedServices, o as LikeC4SharedServices, p as LikeC4ModelParser, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as FormatOptions, w as LikeC4ModelBuilder, x as LikeC4Views, y as WithWasmGraphviz, z as LikeC4ManualLayouts } from "./chunks/module.mjs";
2
+ export { type ConfigureLanguageServerLoggerOptions, type DocumentParser, type FileSystemModuleContext, type FileSystemProvider, type FileSystemWatcher, type FileSystemWatcherModuleContext, type FormatOptions, type FqnIndex, type LangiumDocuments, type LanguageServicesContext, type LayoutViewParams, type LikeC4AddedServices, type LikeC4LanguageServices, type LikeC4ManualLayouts, type LikeC4ManualLayoutsModuleContext, type LikeC4ModelBuilder, type LikeC4ModelLocator, type LikeC4ModelParser, type LikeC4Services, type LikeC4SharedServices, type LikeC4Views, type LikeC4ViewsModuleContext, type LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, type Project, type ProjectData, type ProjectsManager, type ViewLocateResult, WithFileSystem, WithLikeC4ManualLayouts, type WithWasmGraphviz, configureLanguageServerLogger, createLanguageServices, startLanguageServer };
package/dist/index.mjs CHANGED
@@ -1 +1,110 @@
1
- import{ai as e,ci as t,oi as n,si as r,ui as i}from"./_chunks/utils.mjs";import{r as a,t as o}from"./_chunks/LikeC4FileSystem.mjs";import{i as s,t as c}from"./_chunks/module.mjs";import"./_chunks/common-exports.mjs";import{configureLogger as l,getAnsiColorFormatter as u,getConsoleSink as d,getConsoleStderrSink as f,getTextFormatter as p}from"@likec4/log";import{isEmpty as m}from"remeda";import{startLanguageServer as h}from"langium/lsp";import{GraphvizWasmAdapter as g,QueueGraphvizLayoter as _}from"@likec4/layouts";import{GraphvizBinaryAdapter as v}from"@likec4/layouts/graphviz/binary";import{defu as y}from"defu";import{isDevelopment as b}from"std-env";import x from"which";function configureLanguageServerLogger({lspConnection:e,enableTelemetry:n=!!e,useStdErr:r=!1,logLevel:a=b?`debug`:`warning`,nonBlocking:o=!1,colors:s=!1}={}){let c=!!e&&n&&!b;l({reset:!0,sinks:{console:r?f({formatter:p()}):d({formatter:s?u():p(),nonBlocking:o}),...c&&{telemetry:t(e)}},loggers:[{category:[`likec4`],sinks:[`console`,...c?[`telemetry`]:[]],lowestLevel:a}]}),i.trace(`logger configured`)}function graphvizBinPath(){try{return x.sync(`dot`)}catch(e){return i.error(`Error checking for native Graphviz:`,{error:e}),null}}const S={likec4:{Layouter(e){i.debug(`Creating ConfigurableLayouter`);let t=e.likec4.Graphviz,n=new _({graphviz:t});return e.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate(t=>{if(i.debug(`Configuration update: {update}`,{update:t}),t.section!==e.LanguageMetaData.languageId){i.debug(`Ignoring configuration update as it is not for ${e.LanguageMetaData.languageId}`);return}try{let{mode:r,path:a}=t.configuration.graphviz??{mode:`wasm`,path:``};if(r!==`wasm`){let t=m(a)?graphvizBinPath():a;if(!m(t)){n.changePort(new v(t)),i.info`use graphviz binary: ${t}`;return}i.warn(`No Graphviz binaries found on PATH, use graphviz wasm`),e.shared.lsp.Connection?.window.showWarningMessage(`No Graphviz binaries found on PATH, set path to binaries in settings.`)}n.changePort(new g),i.info(`use graphviz wasm`)}catch(e){i.error(`Failed to update configuration`,{error:e})}}),n}}};function startLanguageServer(e){let t=e?.connection,n=y(e,{enableWatcher:!0,enableManualLayouts:!0,graphviz:`wasm`,configureLogger:!1});n.configureLogger!==!1&&(n.configureLogger===`stderr`?configureLanguageServerLogger({lspConnection:t,enableTelemetry:!1,useStdErr:!0}):n.configureLogger===`console`&&configureLanguageServerLogger({lspConnection:t})),t?i.info(`Starting LikeC4 language server`):i.warn(`Starting LikeC4 language server (headless - no LSP connection)`);let r=c({...t&&{connection:t},...o(n.enableWatcher),...n.enableManualLayouts&&a,...s(n.graphviz===`binary`?new v:new g)},t?{likec4:{...S.likec4}}:void 0);return h(r.shared),r}export{e as NoFileSystem,n as NoFileSystemWatcher,r as NoLikeC4ManualLayouts,o as WithFileSystem,a as WithLikeC4ManualLayouts,configureLanguageServerLogger,c as createLanguageServices,startLanguageServer};
1
+ import { t as __name } from "./chunks/rolldown-runtime.mjs";
2
+ import { Br as getTelemetrySink, Hr as logger$1, Lr as NoFileSystem, Rr as NoFileSystemWatcher, zr as NoLikeC4ManualLayouts } from "./chunks/utils.mjs";
3
+ import { i as WithGraphviz, t as createLanguageServices } from "./chunks/module.mjs";
4
+ import { r as WithLikeC4ManualLayouts, t as WithFileSystem } from "./chunks/LikeC4FileSystem.mjs";
5
+ import { configureLogger, getAnsiColorFormatter, getConsoleSink, getConsoleStderrSink, getTextFormatter } from "@likec4/log";
6
+ import { isEmpty } from "remeda";
7
+ import { startLanguageServer as startLanguageServer$1 } from "langium/lsp";
8
+ import { GraphvizWasmAdapter, QueueGraphvizLayoter } from "@likec4/layouts";
9
+ import { GraphvizBinaryAdapter } from "@likec4/layouts/graphviz/binary";
10
+ import { defu } from "defu";
11
+ import { isDevelopment } from "std-env";
12
+ import which from "which";
13
+
14
+ //#region src/configureLogger.ts
15
+ function configureLanguageServerLogger({ lspConnection: connection, enableTelemetry = !!connection, useStdErr = false, logLevel: lowestLevel = isDevelopment ? "debug" : "warning", nonBlocking = false, colors = false } = {}) {
16
+ const telemetry = !!connection && enableTelemetry && !isDevelopment;
17
+ configureLogger({
18
+ reset: true,
19
+ sinks: {
20
+ console: useStdErr ? getConsoleStderrSink({ formatter: getTextFormatter() }) : getConsoleSink({
21
+ formatter: colors ? getAnsiColorFormatter() : getTextFormatter(),
22
+ nonBlocking
23
+ }),
24
+ ...telemetry && { telemetry: getTelemetrySink(connection) }
25
+ },
26
+ loggers: [{
27
+ category: ["likec4"],
28
+ sinks: ["console", ...telemetry ? ["telemetry"] : []],
29
+ lowestLevel
30
+ }]
31
+ });
32
+ logger$1.trace("logger configured");
33
+ }
34
+
35
+ //#endregion
36
+ //#region src/views/ConfigurableLayouter.ts
37
+ function graphvizBinPath() {
38
+ try {
39
+ return which.sync("dot");
40
+ } catch (error) {
41
+ logger$1.error("Error checking for native Graphviz:", { error });
42
+ return null;
43
+ }
44
+ }
45
+ const ConfigurableLayouter = { likec4: { Layouter(services) {
46
+ logger$1.debug("Creating ConfigurableLayouter");
47
+ const defaultGraphviz = services.likec4.Graphviz;
48
+ const layouter = new QueueGraphvizLayoter({ graphviz: defaultGraphviz });
49
+ services.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate((update) => {
50
+ logger$1.debug("Configuration update: {update}", { update });
51
+ if (update.section !== services.LanguageMetaData.languageId) {
52
+ logger$1.debug(`Ignoring configuration update as it is not for ${services.LanguageMetaData.languageId}`);
53
+ return;
54
+ }
55
+ try {
56
+ const { mode, path } = update.configuration.graphviz ?? {
57
+ mode: "wasm",
58
+ path: ""
59
+ };
60
+ if (mode !== "wasm") {
61
+ let binaryPath = isEmpty(path) ? graphvizBinPath() : path;
62
+ if (!isEmpty(binaryPath)) {
63
+ layouter.changePort(new GraphvizBinaryAdapter(binaryPath));
64
+ logger$1.info`use graphviz binary: ${binaryPath}`;
65
+ return;
66
+ }
67
+ logger$1.warn(`No Graphviz binaries found on PATH, use graphviz wasm`);
68
+ services.shared.lsp.Connection?.window.showWarningMessage("No Graphviz binaries found on PATH, set path to binaries in settings.");
69
+ }
70
+ layouter.changePort(new GraphvizWasmAdapter());
71
+ logger$1.info("use graphviz wasm");
72
+ } catch (error) {
73
+ logger$1.error("Failed to update configuration", { error });
74
+ }
75
+ });
76
+ return layouter;
77
+ } } };
78
+
79
+ //#endregion
80
+ //#region src/index.ts
81
+ function startLanguageServer(options) {
82
+ const connection = options?.connection;
83
+ const opts = defu(options, {
84
+ enableWatcher: true,
85
+ enableManualLayouts: true,
86
+ graphviz: "wasm",
87
+ configureLogger: false
88
+ });
89
+ if (opts.configureLogger !== false) {
90
+ if (opts.configureLogger === "stderr") configureLanguageServerLogger({
91
+ lspConnection: connection,
92
+ enableTelemetry: false,
93
+ useStdErr: true
94
+ });
95
+ else if (opts.configureLogger === "console") configureLanguageServerLogger({ lspConnection: connection });
96
+ }
97
+ if (connection) logger$1.info("Starting LikeC4 language server");
98
+ else logger$1.warn("Starting LikeC4 language server (headless - no LSP connection)");
99
+ const services = createLanguageServices({
100
+ ...connection && { connection },
101
+ ...WithFileSystem(opts.enableWatcher),
102
+ ...opts.enableManualLayouts && WithLikeC4ManualLayouts,
103
+ ...WithGraphviz(opts.graphviz === "binary" ? new GraphvizBinaryAdapter() : new GraphvizWasmAdapter())
104
+ }, connection ? { likec4: { ...ConfigurableLayouter.likec4 } } : void 0);
105
+ startLanguageServer$1(services.shared);
106
+ return services;
107
+ }
108
+
109
+ //#endregion
110
+ export { NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithFileSystem, WithLikeC4ManualLayouts, configureLanguageServerLogger, createLanguageServices, startLanguageServer };
@@ -1,6 +1,6 @@
1
- import { r as LibIcons } from "./_chunks/icons.mjs";
1
+ import { t as __name } from "./chunks/rolldown-runtime.mjs";
2
+ import { r as LibIcons } from "./chunks/icons.mjs";
2
3
  import { URI } from "vscode-uri";
3
-
4
4
  //#region src/likec4lib.d.ts
5
5
  declare const Scheme = "likec4builtin";
6
6
  declare const Uri: "likec4builtin:///likec4/lib/icons.c4";
@@ -1 +1,15 @@
1
- import{t as e}from"./_chunks/icons.mjs";const t=`likec4builtin`,n=`${t}:///likec4/lib/icons.c4`;function isLikeC4Builtin(e){return(`uri`in e?e.uri:e).scheme===t}function isNotLikeC4Builtin(e){return!isLikeC4Builtin(e)}export{e as Content,t as Scheme,n as Uri,isLikeC4Builtin,isNotLikeC4Builtin};
1
+ import { t as __name } from "./chunks/rolldown-runtime.mjs";
2
+ import { t as LibIcons } from "./chunks/icons.mjs";
3
+
4
+ //#region src/likec4lib.ts
5
+ const Scheme = "likec4builtin";
6
+ const Uri = `${Scheme}:///likec4/lib/icons.c4`;
7
+ function isLikeC4Builtin(uri) {
8
+ return ("uri" in uri ? uri.uri : uri).scheme === Scheme;
9
+ }
10
+ function isNotLikeC4Builtin(uri) {
11
+ return !isLikeC4Builtin(uri);
12
+ }
13
+
14
+ //#endregion
15
+ export { LibIcons as Content, Scheme, Uri, isLikeC4Builtin, isNotLikeC4Builtin };
package/dist/module.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { N as NoLikeC4ManualLayouts, a as LikeC4SharedModuleContext, c as createLikeC4Module, i as LikeC4ServicesContext, j as NoFileSystem, l as createSharedServices, n as LikeC4AddedServices, o as LikeC4SharedServices, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, v as WithGraphviz, y as WithWasmGraphviz } from "./_chunks/module.mjs";
1
+ import { N as NoLikeC4ManualLayouts, a as LikeC4SharedModuleContext, c as createLikeC4Module, i as LikeC4ServicesContext, j as NoFileSystem, l as createSharedServices, n as LikeC4AddedServices, o as LikeC4SharedServices, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, v as WithGraphviz, y as WithWasmGraphviz } from "./chunks/module.mjs";
2
2
  export { LanguageServicesContext, LikeC4AddedServices, LikeC4Services, LikeC4ServicesContext, LikeC4SharedModuleContext, LikeC4SharedServices, NoFileSystem, NoLikeC4ManualLayouts, WithGraphviz, WithWasmGraphviz, createLanguageServices, createLikeC4Module, createSharedServices };
package/dist/module.mjs CHANGED
@@ -1 +1,4 @@
1
- import{ai as e,si as t}from"./_chunks/utils.mjs";import{a as n,i as r,n as i,r as a,t as o}from"./_chunks/module.mjs";export{e as NoFileSystem,t as NoLikeC4ManualLayouts,r as WithGraphviz,n as WithWasmGraphviz,o as createLanguageServices,i as createLikeC4Module,a as createSharedServices};
1
+ import { Lr as NoFileSystem, zr as NoLikeC4ManualLayouts } from "./chunks/utils.mjs";
2
+ import { a as WithWasmGraphviz, i as WithGraphviz, n as createLikeC4Module, r as createSharedServices, t as createLanguageServices } from "./chunks/module.mjs";
3
+
4
+ export { NoFileSystem, NoLikeC4ManualLayouts, WithGraphviz, WithWasmGraphviz, createLanguageServices, createLikeC4Module, createSharedServices };
@@ -1,2 +1,2 @@
1
- import { _ as ReloadProjects, a as DidChangeSnapshotNotification, c as FetchLayoutedModel, d as FetchTelemetryMetrics, f as FetchViewsFromAllProjects, g as RegisterProject, h as Locate, i as DidChangeProjectsNotification, l as FetchProjects, m as LayoutView, n as ChangeView, o as DidRequestOpenViewNotification, p as GetDocumentTags, r as DidChangeModelNotification, s as FetchComputedModel, t as BuildDocuments, u as FetchProjectsOverview, v as ValidateLayout } from "./_chunks/protocol.mjs";
1
+ import { _ as ReloadProjects, a as DidChangeSnapshotNotification, c as FetchLayoutedModel, d as FetchTelemetryMetrics, f as FetchViewsFromAllProjects, g as RegisterProject, h as Locate, i as DidChangeProjectsNotification, l as FetchProjects, m as LayoutView, n as ChangeView, o as DidRequestOpenViewNotification, p as GetDocumentTags, r as DidChangeModelNotification, s as FetchComputedModel, t as BuildDocuments, u as FetchProjectsOverview, v as ValidateLayout } from "./chunks/protocol.mjs";
2
2
  export { BuildDocuments, ChangeView, DidChangeModelNotification, DidChangeProjectsNotification, DidChangeSnapshotNotification, DidRequestOpenViewNotification, FetchComputedModel, FetchLayoutedModel, FetchProjects, FetchProjectsOverview, FetchTelemetryMetrics, FetchViewsFromAllProjects, GetDocumentTags, LayoutView, Locate, RegisterProject, ReloadProjects, ValidateLayout };
package/dist/protocol.mjs CHANGED
@@ -1 +1,79 @@
1
- import{NotificationType as e,NotificationType0 as t,RequestType as n,RequestType0 as r}from"vscode-jsonrpc";let i;(function(t){t.type=new e(`likec4/onDidChangeModel`)})(i||={});let a;(function(e){e.type=new t(`likec4/onDidChangeProjects`)})(a||={});let o;(function(t){t.type=new e(t.Method=`likec4/onDidChangeSnapshot`)})(o||={});let s;(function(t){t.type=new e(`likec4/onRequestOpenView`)})(s||={});let c;(function(e){e.req=new n(`likec4/fetchComputedModel`)})(c||={});let l;(function(e){e.req=new r(`likec4/fetchViewsFromAllProjects`)})(l||={});let u;(function(e){e.req=new n(`likec4/fetchLayoutedModel`)})(u||={});let d;(function(e){e.req=new n(`likec4/layout-view`)})(d||={});let f;(function(e){e.req=new n(`likec4/validate-layout`)})(f||={});let p;(function(e){e.req=new r(`likec4/reload-projects`)})(p||={});let m;(function(e){e.req=new r(`likec4/fetch-projects`)})(m||={});let h;(function(e){e.req=new n(`likec4/register-project`)})(h||={});let g;(function(e){e.req=new n(`likec4/build`)})(g||={});let _;(function(e){e.req=new n(`likec4/locate`)})(_||={});let v;(function(e){e.req=new n(`likec4/change-view`)})(v||={});let y;(function(e){e.req=new r(`likec4/metrics`)})(y||={});let b;(function(e){e.req=new n(`likec4/document-tags`)})(b||={});let x;(function(e){e.req=new r(`likec4/fetch-projects-overview`)})(x||={});export{g as BuildDocuments,v as ChangeView,i as DidChangeModelNotification,a as DidChangeProjectsNotification,o as DidChangeSnapshotNotification,s as DidRequestOpenViewNotification,c as FetchComputedModel,u as FetchLayoutedModel,m as FetchProjects,x as FetchProjectsOverview,y as FetchTelemetryMetrics,l as FetchViewsFromAllProjects,b as GetDocumentTags,d as LayoutView,_ as Locate,h as RegisterProject,p as ReloadProjects,f as ValidateLayout};
1
+ import { t as __name } from "./chunks/rolldown-runtime.mjs";
2
+ import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
3
+
4
+ //#region src/protocol.ts
5
+ let DidChangeModelNotification;
6
+ (function(_DidChangeModelNotification) {
7
+ _DidChangeModelNotification.type = new NotificationType("likec4/onDidChangeModel");
8
+ })(DidChangeModelNotification || (DidChangeModelNotification = {}));
9
+ let DidChangeProjectsNotification;
10
+ (function(_DidChangeProjectsNotification) {
11
+ _DidChangeProjectsNotification.type = new NotificationType0("likec4/onDidChangeProjects");
12
+ })(DidChangeProjectsNotification || (DidChangeProjectsNotification = {}));
13
+ let DidChangeSnapshotNotification;
14
+ (function(_DidChangeSnapshotNotification) {
15
+ _DidChangeSnapshotNotification.type = new NotificationType(_DidChangeSnapshotNotification.Method = "likec4/onDidChangeSnapshot");
16
+ })(DidChangeSnapshotNotification || (DidChangeSnapshotNotification = {}));
17
+ let DidRequestOpenViewNotification;
18
+ (function(_DidRequestOpenViewNotification) {
19
+ _DidRequestOpenViewNotification.type = new NotificationType("likec4/onRequestOpenView");
20
+ })(DidRequestOpenViewNotification || (DidRequestOpenViewNotification = {}));
21
+ let FetchComputedModel;
22
+ (function(_FetchComputedModel) {
23
+ _FetchComputedModel.req = new RequestType("likec4/fetchComputedModel");
24
+ })(FetchComputedModel || (FetchComputedModel = {}));
25
+ let FetchViewsFromAllProjects;
26
+ (function(_FetchViewsFromAllProjects) {
27
+ _FetchViewsFromAllProjects.req = new RequestType0("likec4/fetchViewsFromAllProjects");
28
+ })(FetchViewsFromAllProjects || (FetchViewsFromAllProjects = {}));
29
+ let FetchLayoutedModel;
30
+ (function(_FetchLayoutedModel) {
31
+ _FetchLayoutedModel.req = new RequestType("likec4/fetchLayoutedModel");
32
+ })(FetchLayoutedModel || (FetchLayoutedModel = {}));
33
+ let LayoutView;
34
+ (function(_LayoutView) {
35
+ _LayoutView.req = new RequestType("likec4/layout-view");
36
+ })(LayoutView || (LayoutView = {}));
37
+ let ValidateLayout;
38
+ (function(_ValidateLayout) {
39
+ _ValidateLayout.req = new RequestType("likec4/validate-layout");
40
+ })(ValidateLayout || (ValidateLayout = {}));
41
+ let ReloadProjects;
42
+ (function(_ReloadProjects) {
43
+ _ReloadProjects.req = new RequestType0("likec4/reload-projects");
44
+ })(ReloadProjects || (ReloadProjects = {}));
45
+ let FetchProjects;
46
+ (function(_FetchProjects) {
47
+ _FetchProjects.req = new RequestType0("likec4/fetch-projects");
48
+ })(FetchProjects || (FetchProjects = {}));
49
+ let RegisterProject;
50
+ (function(_RegisterProject) {
51
+ _RegisterProject.req = new RequestType("likec4/register-project");
52
+ })(RegisterProject || (RegisterProject = {}));
53
+ let BuildDocuments;
54
+ (function(_BuildDocuments) {
55
+ _BuildDocuments.req = new RequestType("likec4/build");
56
+ })(BuildDocuments || (BuildDocuments = {}));
57
+ let Locate;
58
+ (function(_Locate) {
59
+ _Locate.req = new RequestType("likec4/locate");
60
+ })(Locate || (Locate = {}));
61
+ let ChangeView;
62
+ (function(_ChangeView) {
63
+ _ChangeView.req = new RequestType("likec4/change-view");
64
+ })(ChangeView || (ChangeView = {}));
65
+ let FetchTelemetryMetrics;
66
+ (function(_FetchTelemetryMetrics) {
67
+ _FetchTelemetryMetrics.req = new RequestType0("likec4/metrics");
68
+ })(FetchTelemetryMetrics || (FetchTelemetryMetrics = {}));
69
+ let GetDocumentTags;
70
+ (function(_GetDocumentTags) {
71
+ _GetDocumentTags.req = new RequestType("likec4/document-tags");
72
+ })(GetDocumentTags || (GetDocumentTags = {}));
73
+ let FetchProjectsOverview;
74
+ (function(_FetchProjectsOverview) {
75
+ _FetchProjectsOverview.req = new RequestType0("likec4/fetch-projects-overview");
76
+ })(FetchProjectsOverview || (FetchProjectsOverview = {}));
77
+
78
+ //#endregion
79
+ export { BuildDocuments, ChangeView, DidChangeModelNotification, DidChangeProjectsNotification, DidChangeSnapshotNotification, DidRequestOpenViewNotification, FetchComputedModel, FetchLayoutedModel, FetchProjects, FetchProjectsOverview, FetchTelemetryMetrics, FetchViewsFromAllProjects, GetDocumentTags, LayoutView, Locate, RegisterProject, ReloadProjects, ValidateLayout };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.58.0",
4
+ "version": "1.59.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -118,12 +118,12 @@
118
118
  "access": "public"
119
119
  },
120
120
  "dependencies": {
121
- "@hpcc-js/wasm-graphviz": "1.21.6",
121
+ "@hpcc-js/wasm-graphviz": "1.22.2",
122
122
  "chokidar": "^5.0.0",
123
123
  "defu": "^6.1.7",
124
124
  "fast-equals": "^6.0.0",
125
125
  "fdir": "6.4.0",
126
- "immer": "^11.1.8",
126
+ "immer": "^11.1.9",
127
127
  "indent-string": "^5.0.0",
128
128
  "json5": "^2.2.3",
129
129
  "langium": "3.5.0",
@@ -132,7 +132,7 @@
132
132
  "p-queue": "8.1.1",
133
133
  "p-timeout": "7.0.1",
134
134
  "pathe": "^2.0.3",
135
- "picomatch": "^4.0.4",
135
+ "picomatch": "^4.0.5",
136
136
  "pretty-ms": "^9.3.0",
137
137
  "remeda": "^2.37.0",
138
138
  "std-env": "^4.1.0",
@@ -148,15 +148,15 @@
148
148
  "vscode-uri": "3.1.0",
149
149
  "which": "^5.0.0",
150
150
  "zod": "^4.4.3",
151
- "@likec4/config": "1.58.0",
152
- "@likec4/core": "1.58.0",
153
- "@likec4/generators": "1.58.0",
154
- "@likec4/layouts": "1.58.0",
155
- "@likec4/log": "1.58.0"
151
+ "@likec4/config": "1.59.0",
152
+ "@likec4/core": "1.59.0",
153
+ "@likec4/generators": "1.59.0",
154
+ "@likec4/layouts": "1.59.0",
155
+ "@likec4/log": "1.59.0"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "bundle-require": "^5.1.0",
159
- "esbuild": "0.28.0"
159
+ "esbuild": "0.28.1"
160
160
  },
161
161
  "peerDependenciesMeta": {
162
162
  "esbuild": {
@@ -173,22 +173,22 @@
173
173
  "@types/vscode": "^1.115.0",
174
174
  "@types/which": "^3.0.4",
175
175
  "bundle-require": "^5.1.0",
176
- "esbuild": "0.28.0",
176
+ "esbuild": "0.28.1",
177
177
  "langium-cli": "3.5.2",
178
- "memfs": "^4.57.3",
179
- "obuild": "0.4.31",
180
- "oxlint": "1.68.0",
181
- "tsx": "4.22.4",
182
- "turbo": "2.9.16",
178
+ "memfs": "^4.57.8",
179
+ "tsdown": "^0.22.9",
180
+ "oxlint": "1.72.0",
181
+ "tsx": "4.22.5",
182
+ "turbo": "2.10.5",
183
183
  "typescript": "6.0.3",
184
- "vitest": "4.1.8",
185
- "@likec4/devops": "1.58.0",
184
+ "vitest": "4.1.9",
185
+ "@likec4/devops": "1.59.0",
186
186
  "@likec4/icons": "1.46.4",
187
- "@likec4/tsconfig": "1.58.0"
187
+ "@likec4/tsconfig": "1.59.0"
188
188
  },
189
189
  "scripts": {
190
190
  "typecheck": "tsc -b --verbose",
191
- "build": "obuild",
191
+ "build": "tsdown",
192
192
  "pack": "pnpm pack",
193
193
  "pregenerate": "node -e \"const fs=require('fs');const p=require('path');const d='src/generated';if(fs.existsSync(d)){fs.readdirSync(d).forEach(f=>{try{fs.unlinkSync(p.join(d,f))}catch(e){}})}\"",
194
194
  "watch:langium": "langium generate --watch",
package/src/test/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './testServices'
2
+ export * from './vitestFixture'
@@ -2,7 +2,7 @@ import type { LikeC4ProjectJsonConfig } from '@likec4/config'
2
2
  import type { ComputedLikeC4ModelData, ProjectId } from '@likec4/core'
3
3
  import { type LangiumDocument, DocumentState, TextDocument, UriUtils } from 'langium'
4
4
  import * as assert from 'node:assert'
5
- import { entries, once } from 'remeda'
5
+ import { entries, flatMap, join, once, pipe } from 'remeda'
6
6
  import stripIndent from 'strip-indent'
7
7
  import type { LiteralUnion } from 'type-fest'
8
8
  import { DiagnosticSeverity } from 'vscode-languageserver-types'
@@ -98,6 +98,30 @@ export function createTestServices(options?: {
98
98
  diagnostics,
99
99
  warnings,
100
100
  errors,
101
+ get error(): string {
102
+ return errors.join('\n')
103
+ },
104
+ get formattedError(): string {
105
+ return pipe(
106
+ diagnostics,
107
+ flatMap(validationError => {
108
+ const line = validationError.range.start.line
109
+ const messages = validationError.message.split('\n')
110
+ if (messages.length > 5) {
111
+ messages.length = 5
112
+ messages.push('...')
113
+ }
114
+ return messages
115
+ .map((message, i) => {
116
+ if (i === 0) {
117
+ return `Line ${line}: ${message}`
118
+ }
119
+ return ' '.repeat(10) + message
120
+ })
121
+ }),
122
+ join('\n'),
123
+ )
124
+ },
101
125
  }
102
126
  }
103
127
 
@@ -168,6 +192,17 @@ export function createTestServices(options?: {
168
192
  buildLikeC4Model,
169
193
  resetState,
170
194
  format,
195
+ get likec4() {
196
+ return services.likec4
197
+ },
198
+ [Symbol.dispose]: () => {
199
+ services.likec4.LanguageServices.dispose().catch(err => {
200
+ console.error(err)
201
+ })
202
+ },
203
+ [Symbol.asyncDispose]: async () => {
204
+ await services.likec4.LanguageServices.dispose()
205
+ },
171
206
  }
172
207
  }
173
208
 
@@ -255,6 +290,10 @@ export async function createMultiProjectTestServices<const Projects extends Reco
255
290
  buildModel,
256
291
  buildLikeC4Model,
257
292
  resetState,
293
+
294
+ [Symbol.asyncDispose]: async () => {
295
+ await services.likec4.LanguageServices.dispose()
296
+ },
258
297
  }
259
298
  }
260
299
 
@@ -0,0 +1,58 @@
1
+ import { type TestFunction, test as _test } from 'vitest'
2
+ import { createTestServices } from './testServices'
3
+
4
+ type TestServices = ReturnType<typeof createTestServices>
5
+
6
+ export const test = _test.extend<{
7
+ t: TestServices
8
+ create: (options?: Parameters<typeof createTestServices>[0]) => TestServices
9
+ }>({
10
+ t: async ({}, use) => {
11
+ using services = createTestServices()
12
+ await use(services)
13
+ },
14
+ create: async ({}, use) => {
15
+ const toDispose: Array<TestServices> = []
16
+ await use((options) => {
17
+ const services = createTestServices(options)
18
+ toDispose.push(services)
19
+ return services
20
+ })
21
+ toDispose.forEach(services => services[Symbol.dispose]())
22
+ },
23
+ })
24
+
25
+ export const testFileScope = _test.extend<{
26
+ $file: {
27
+ /**
28
+ * Test services shared across all tests in the same file
29
+ * @internal
30
+ * @use `t` fixture instead
31
+ */
32
+ tshared: TestServices
33
+ }
34
+ $test: {
35
+ /**
36
+ * Test services for the current test
37
+ * Auto-cleaned up after each test
38
+ */
39
+ t: TestServices
40
+ }
41
+ }>({
42
+ tshared: [async ({}, use) => {
43
+ using services = createTestServices()
44
+ await use(services)
45
+ }, { scope: 'file' }],
46
+ t: async ({ tshared }, use) => {
47
+ await use(tshared)
48
+ await tshared.resetState()
49
+ },
50
+ })
51
+ .extend('validate', async ({ t }) => {
52
+ return t.validate
53
+ })
54
+ export type TestFileScope = typeof testFileScope
55
+ export type FileScopeTestFunction = TestFunction<{
56
+ t: TestServices
57
+ validate: TestServices['validate']
58
+ }>
@@ -1,3 +0,0 @@
1
- import{t as e}from"./icons.mjs";import{isLikeC4Builtin as t}from"../likec4lib.mjs";import{c as n,ii as r,l as i,n as a,o,oi as s,s as c,ui as l}from"./utils.mjs";import{compareNaturalHierarchically as u,onNextTick as d,stringHash as f}from"@likec4/core/utils";import{isLikeC4Config as p,loadConfig as m}from"@likec4/config/node";import{fdir as h}from"fdir";import{Disposable as g,SimpleCache as _,URI as v,UriUtils as y}from"langium";import{NodeFileSystemProvider as b}from"langium/node";import{mkdirSync as x,statSync as S}from"node:fs";import{unlink as C,writeFile as w}from"node:fs/promises";import{basename as T,dirname as E}from"node:path";import D from"chokidar";import O from"p-queue";import{exact as k}from"@likec4/core";import A from"json5";import j from"p-limit";import{indexBy as M,prop as N}from"remeda";import{Position as P,Range as F}from"vscode-languageserver-types";const I=l.getChild(`manual-layouts`),L=`.likec4.snap`,isManualLayoutFile=e=>e!==L&&e.endsWith(L);function fileName(e){return`${e}${L}`}function viewIdFromURI(e){let t=y.basename(e);return isManualLayoutFile(t)?t.slice(0,-12):null}function getManualLayoutsOutDir(e){return y.resolvePath(e.folderUri,e.config.manualLayouts?.outDir??`.likec4`)}const R={manualLayouts:e=>new DefaultLikeC4ManualLayouts(e)},z=`file://./`;var DefaultLikeC4ManualLayouts=class extends r{services;cache;listeners=[];#e=j(1);constructor(e){super(),this.services=e,this.cache=new _,this.onDispose(g.create(()=>{this.listeners.length=0,this.cache.clear()})),d(()=>{this.onDispose(e.workspace.ProjectsManager.onProjectsUpdate(()=>{this.clearCaches()}))})}async handleFileSystemUpdate(e){let t=e.update??e.delete,n=viewIdFromURI(t)??void 0,r=this.services.workspace.ProjectsManager.ownerProjectId(t);if(this.cache.delete(r),`delete`in e){this.triggerUpdate(k({removed:t,projectId:r,viewId:n}));return}let i=this.services.workspace.ProjectsManager.getProject(r);if(!n){let e=await this.readSnapshot(t,i);e?n=e.id:(I.error(`Snapshot ${t.fsPath} does not exist or is invalid`),n=`index`)}this.triggerUpdate({updated:t,projectId:r,viewId:n})}onManualLayoutUpdate(e){return this.listeners.push(e),{dispose:()=>{let t=this.listeners.indexOf(e);t!==-1&&this.listeners.splice(t,1)}}}async readManualLayouts(e){let t=I.getChild(e.id),n=this.services.workspace.FileSystemProvider,r=getManualLayoutsOutDir(e),i=[],a=`${r.toString()}`;try{let o=await n.scanDirectory(r,isManualLayoutFile);if(o.length===0)return null;o.sort((e,t)=>e.uri.path.localeCompare(t.uri.path));for(let r of o)try{let t=await n.readFile(r.uri),o=A.parse(t);a=f(a+r.uri.toString()+t);let s=this.resolveIconPathsAfterRead(o,e.folderUri);i.push({...s,_layout:`manual`})}catch(e){t.warn(`Failed to read view snapshot ${r.uri.fsPath}`,{err:e})}i.length&&t.trace`read manual layouts for ${e.id}, found ${i.length}`}catch(n){t.warn(`Failed to read manual layouts for ${e.folderUri.fsPath}`,{err:n})}if(i.length===0)return null;let o=M(i,N(`id`));return{hash:a,views:o}}async readSnapshot(e,t){let n=this.services.workspace.FileSystemProvider;try{let r=await n.readFile(e),i=A.parse(r);if(!t){let n=this.services.workspace.ProjectsManager.ownerProjectId(e);t=this.services.workspace.ProjectsManager.getProject(n)}return{...this.resolveIconPathsAfterRead(i,t.folderUri),_layout:`manual`}}catch(t){return I.warn(`Failed to read view snapshot ${e.fsPath}`,{err:t}),null}}async read(e){return await this.#e(async()=>{let t=this.cache.get(e.id);if(t!==void 0)return I.trace`cache hit project ${e.id}`,t;let n=await this.readManualLayouts(e);return this.cache.set(e.id,n),n})}async write(e,t){this.cache.delete(e.id);let n=I.getChild(e.id),r=getManualLayoutsOutDir(e),i=y.joinPath(r,fileName(t.id));if(`manualLayout`in t){let{manualLayout:e,...n}=t;t=n}let a=A.stringify(this.normalizeIconPathsForWrite(t,e.folderUri),{space:2,quote:`'`}),o={uri:i.toString(),range:F.create(P.create(0,0),P.create(a.split(`
2
- `).length-1,1))};n.debug`write snapshot of ${t.id} in project ${e.id} to ${i.fsPath}`;let s=this.services.workspace.FileSystemProvider;try{await s.writeFile(i,a+`
3
- `),this.triggerUpdate({updated:i,projectId:e.id,viewId:t.id})}catch(e){n.warn(`Failed to write snapshot ${t.id} to ${i.fsPath}`,{err:e})}return o}async remove(e,t){this.cache.delete(e.id);let n=I.getChild(e.id),r=getManualLayoutsOutDir(e),i=y.joinPath(r,fileName(t));n.debug`delete snapshot of ${t} in project ${e.id}. File: ${i.fsPath}`;let a={uri:i.toString(),range:F.create(0,0,0,0)};try{if(!await this.services.workspace.FileSystemProvider.deleteFile(i))return n.warn`Snapshot ${t} did not exist at ${i.fsPath}`,null;this.triggerUpdate({removed:i,projectId:e.id,viewId:t})}catch(e){n.warn(`Failed to delete snapshot ${t} from ${i.fsPath}`,{err:e})}return a}clearCaches(){I.trace`clear caches`,this.cache.clear()}triggerUpdate(e){let t=[...this.listeners];for(let n of t)a(()=>n(e))}normalizeIconPathsForWrite(e,t){let n=e.nodes.map(e=>{if(!e.icon||typeof e.icon!=`string`)return e;if(e.icon.startsWith(`file://`)){let n=v.parse(e.icon),r=y.relative(t,n);return r.startsWith(`..`)?e:{...e,icon:`${z}${r}`}}return e});return{...e,nodes:n}}resolveIconPathsAfterRead(e,t){let n=e.nodes.map(e=>{if(!e.icon||typeof e.icon!=`string`)return e;if(e.icon.startsWith(z)){let n=e.icon.substring(9),r=y.joinPath(t,n);return{...e,icon:r.toString()}}return e});return{...e,nodes:n}}};const B=l.getChild(`chokidar`),V={fileSystemWatcher:e=>new ChokidarFileSystemWatcher(e)},isAnyLikeC4File=e=>{let t=T(e);return c(t)||p(t)||isManualLayoutFile(t)};var ChokidarFileSystemWatcher=class{services;watcher;queue=new O({concurrency:1,timeout:5e3});constructor(e){this.services=e,B.debug`ChokidarFileSystemWatcher created`}watch(e){if(this.watcher){B.debug`add watching folder: ${e}`,this.watcher.add(e);return}this.watcher=this.createWatcher(e)}async dispose(){if(this.watcher){let e=this.watcher;this.watcher=void 0;try{await e.close()}catch{}}}createWatcher(e){B.debug`create watcher for folder: ${e}`;let t=D.watch(e,{ignored:[e=>n(e),(e,t)=>!!t&&t.isFile()&&!isAnyLikeC4File(e)],followSymlinks:!0,ignoreInitial:!0}),onAddOrChange=(e,t)=>{t?.isDirectory()||this.enqueueFileOp(`addOrChange: `+e,async()=>{await this.onAddOrChange(e)})};return t.on(`add`,onAddOrChange).on(`change`,onAddOrChange).on(`unlink`,(e,t)=>{t?.isDirectory()||this.enqueueFileOp(`remove: `+e,async()=>{await this.onRemove(e)})}).on(`unlinkDir`,e=>{this.enqueueFileOp(`removeDir: `+e,async()=>{await this.onRemoveDir(e)})}),t}enqueueFileOp(e,t){this.queue.add(async()=>{try{await t()}catch(t){B.warn(`Failed on {fileop}`,{fileop:e,error:t})}}).catch(t=>{B.error(`Error on {fileop}`,{fileop:e,error:t})})}async onAddOrChange(e){let t=this.services.workspace,n=T(e),r=v.file(e);switch(!0){case p(n):B.debug`project config changed: ${e}`,t.ManualLayouts.clearCaches(),await t.ProjectsManager.registerConfigFile(r);break;case isManualLayoutFile(n):B.debug`manual layout file changed: ${e}`,await t.ManualLayouts.handleFileSystemUpdate({update:r});break;case c(n):B.debug`file changed: ${e}`,await t.DocumentBuilder.update([r],[]);break;default:B.warn`Unknown file change: ${e}`}}async onRemove(e){let t=this.services.workspace,n=T(e),r=v.file(e);switch(!0){case p(n):B.debug`project file removed: ${e}`,t.ManualLayouts.clearCaches(),await t.ProjectsManager.reloadProjects();break;case c(n):B.debug`file removed: ${e}`,await t.DocumentBuilder.update([],[r]);break;case isManualLayoutFile(n):B.debug`manual layout file removed: ${e}`,await t.ManualLayouts.handleFileSystemUpdate({delete:r});break;default:B.warn`Unknown file removal: ${e}`}}async onRemoveDir(e){B.debug`directory removed: ${e}`;let t=this.services.workspace;t.ProjectsManager.findOverlaped(e).length>0&&(t.ManualLayouts.clearCaches(),await t.ProjectsManager.reloadProjects())}};const H=l.getChild(`filesystem`);function isLikeC4ConfigFile(e,t=!1){return!t&&p(T(e))}function isLikeC4File(e,t=!1){return!t&&c(T(e))}const WithFileSystem=(e=!1)=>({fileSystemProvider:()=>new SymLinkTraversingFileSystemProvider,...e?V:s});var SymLinkTraversingFileSystemProvider=class extends b{async readFile(n){if(t(n))return Promise.resolve(e);try{return await super.readFile(n)}catch(e){return H.warn(`Failed to read file ${n.fsPath}`,{error:e}),``}}async readDirectory(e,t){let n=t?.recursive??!0,r=t?.maxDepth??1/0,a=[];try{let t=new h().withSymlinks({resolvePaths:!1}).exclude(i).withFullPaths().filter(isLikeC4File);n?r!==1/0&&(t=t.withMaxDepth(r)):t=t.withMaxDepth(1);let o=await t.crawl(e.fsPath).withPromise();for(let e of o)a.push({isFile:!0,isDirectory:!1,uri:v.file(e)})}catch(t){H.warn(`Failed to read directory ${e.fsPath}`,{error:t})}return a.sort(o)}async scanProjectFiles(e){let t=await this.scanDirectory(e,isLikeC4ConfigFile);if(t.length<=1)return t;let n=u(`/`,!0);return t.sort((e,t)=>n(e.uri.path,t.uri.path))}async scanDirectory(e,t){let n=[];try{let r=await new h().withSymlinks({resolvePaths:!1}).exclude(i).withFullPaths().filter(t).crawl(e.fsPath).withPromise();for(let e of r)n.push({isFile:!0,isDirectory:!1,uri:v.file(e)})}catch(t){H.warn(`Failed to scan directory {path}`,{path:e.fsPath,error:t})}return n}async loadProjectConfig(e){return await m(e)}async writeFile(e,t){let n=E(e.fsPath),r=S(n,{throwIfNoEntry:!1});if(r?.isFile())throw Error(`Cannot create directory ${n} because a file with the same name exists.`);return r||(H.debug(`creating directory {path}`,{path:n}),x(n,{recursive:!0})),H.debug(`writing file {path}`,{path:e.fsPath}),await w(e.fsPath,t,{encoding:`utf-8`})}async deleteFile(e){try{let t=e.fsPath,n=S(t,{throwIfNoEntry:!1});return n?.isFile()||n?.isSymbolicLink()?(await C(t),H.debug(`deleted file {path}`,{path:t}),!0):(H.warn(`deleteFile failed: {path} does not exist, or is not a file`,{path:t}),!1)}catch(t){H.warn(`Failed to delete file ${e.fsPath}`,{error:t})}return!1}};export{V as n,R as r,WithFileSystem as t};
@@ -1 +0,0 @@
1
- import"./utils.mjs";import"./module.mjs";