@likec4/language-server 1.49.0 → 1.51.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.
- package/LICENSE +21 -0
- package/README.md +5 -25
- package/bin/likec4-language-server.mjs +2 -3
- package/dist/_chunks/LikeC4FileSystem.mjs +3 -3
- package/dist/_chunks/common-exports.mjs +0 -0
- package/dist/_chunks/likec4lib.mjs +2 -0
- package/dist/_chunks/mcp.mjs +1154 -0
- package/dist/_chunks/{index.d.mts → module.d.mts} +326 -24
- package/dist/_chunks/module.mjs +35 -0
- package/dist/_chunks/noop.mjs +1 -0
- package/dist/_chunks/protocol.d.mts +315 -0
- package/dist/_chunks/utils.mjs +1 -1
- package/dist/_chunks/workspace.mjs +1 -0
- package/dist/browser/index.d.mts +8 -3
- package/dist/browser/index.mjs +1 -1
- package/dist/browser/worker.mjs +1 -1
- package/dist/filesystem/index.d.mts +3 -2
- package/dist/filesystem/index.mjs +1 -1
- package/dist/index.d.mts +3 -39
- package/dist/index.mjs +1 -1
- package/dist/likec4lib.mjs +1 -1
- package/dist/mcp/index.d.mts +3 -2
- package/dist/mcp/index.mjs +1 -1
- package/dist/module.d.mts +3 -126
- package/dist/module.mjs +1 -1
- package/dist/protocol.d.mts +1 -314
- package/dist/protocol.mjs +1 -1
- package/package.json +23 -33
- package/bundled/package.json +0 -4
- package/dist/THIRD-PARTY-LICENSES.md +0 -178
- package/dist/_chunks/ConfigurableLayouter.mjs +0 -1
- package/dist/_chunks/LikeC4Views.mjs +0 -34
- package/dist/_chunks/ProjectsManager.mjs +0 -1
- package/dist/_chunks/WithMCPServer.mjs +0 -481
- package/dist/_chunks/icons.mjs +0 -2
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +0 -1
- package/dist/_chunks/libs/eventemitter3.mjs +0 -1
- package/dist/_chunks/libs/fast-equals.mjs +0 -1
- package/dist/_chunks/libs/p-queue.mjs +0 -1
- package/dist/_chunks/libs/parse-ms.mjs +0 -1
- package/dist/_chunks/libs/picomatch.mjs +0 -1
- package/dist/_chunks/libs/pretty-ms.mjs +0 -1
- package/dist/_chunks/libs/remeda.mjs +0 -1
- package/dist/_chunks/libs/strip-indent.mjs +0 -1
- package/dist/_chunks/libs/ufo.mjs +0 -1
- package/dist/_chunks/logger.mjs +0 -1
- package/dist/_chunks/rolldown-runtime.mjs +0 -1
- package/dist/bundled.d.mts +0 -27
- package/dist/bundled.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r}from"./likec4lib.mjs";import{B as i,Bt as a,Ct as o,H as s,Hn as c,I as ee,J as te,Kt as l,N as u,Tr as d,Tt as f,U as ne,V as p,X as re,at as ie,cn as ae,en as oe,ln as se,mt as ce,n as le,nr as ue,nt as m,o as de,qt as h,sn as g,ut as _,wr as v,yt as y,z as b}from"./utils.mjs";import{AstUtils as x,DefaultAstNodeDescriptionProvider as fe,DefaultIndexManager as pe,DefaultLangiumDocuments as me,DefaultWorkspaceManager as he,Disposable as S,URI as C,UriUtils as w,isAstNode as ge,isOperationCancelled as T,stream as E}from"langium";import{DefaultMap as D,compareNaturalHierarchically as O,invariant as k,isString as A,nonNullable as j,nonexhaustive as M,stringHash as N}from"@likec4/core/utils";import{loggable as P,wrapError as F}from"@likec4/log";import{clamp as I,find as L,groupBy as _e,hasAtLeast as R,isEmptyish as z,isNullish as B,isTruthy as ve,map as V,pipe as ye,prop as H,purry as U,uniqueBy as be}from"remeda";import{invariant as W}from"@likec4/core";import{LikeC4ProjectConfigOps as G}from"@likec4/config";import K from"picomatch";import{cleanDoubleSlashes as xe,hasProtocol as Se,isRelative as Ce,joinRelativeURL as we,joinURL as Te,withTrailingSlash as Ee,withoutProtocol as q,withoutTrailingSlash as J}from"ufo";import De from"pretty-ms";import{URI as Y}from"vscode-uri";const X=Symbol.for(`idattr`),Oe={writeId(e,t){return e[X]=t,e},readId(e){return e[X]}},ke={writeId(e,t){return B(t)?e[X]=void 0:e[X]=t,e},readId(e){return e[X]}};function isLikeC4LangiumDocument(e){return e?.textDocument.languageId===de.languageId}function parseMarkdownAsString(e){return e?.markdown||e?.text}function parseAstPercent(e){let t=parseFloat(e);return isNaN(t)?100:I(t,{min:0,max:100})}function parseAstOpacityProperty({value:e}){return parseAstPercent(e)}function parseAstSizeValue({value:e}){switch(e){case`xs`:case`sm`:case`md`:case`lg`:case`xl`:return e;case`xsmall`:return`xs`;case`small`:return`sm`;case`medium`:return`md`;case`large`:return`lg`;case`xlarge`:return`xl`;default:M(e)}}function parseAstIconPositionValue({value:e}){switch(e){case`left`:case`right`:case`top`:case`bottom`:return e;default:M(e)}}function toRelationshipStyle(e,t){let n={};if(!e||e.length===0)return n;for(let r of e)if(t(r))switch(!0){case ee(r):{let e=toColor(r);ve(e)&&(n.color=e);break}case oe(r):n.line=r.value;break;case u(r):switch(r.key){case`head`:n.head=r.value;break;case`tail`:n.tail=r.value;break;default:M(r)}break;default:M(r)}return n}function toColor(e){return e?.themeColor??e?.customColor?.$refText}function toAutoLayout(e){let t=e.rankSep,n=e.nodeSep,r;switch(e.direction){case`TopBottom`:r=`TB`;break;case`BottomTop`:r=`BT`;break;case`LeftRight`:r=`LR`;break;case`RightLeft`:r=`RL`;break;default:M(e.direction)}return{direction:r,...n&&{nodeSep:n},...t&&{rankSep:t}}}function toAstViewLayoutDirection(e){switch(e){case`TB`:return`TopBottom`;case`BT`:return`BottomTop`;case`LR`:return`LeftRight`;case`RL`:return`RightLeft`;default:M(e)}}function getViewRulePredicateContainer(e){return x.getContainerOfType(e,e=>ue(e)||re(e)||ie(e))}const _isModel=e=>g(e)||_(e)||f(e)||y(e)||m(e)||ce(e),_isDeployment=e=>ae(e)||te(e)||ne(e)||o(e)||i(e);function isFqnRefInsideGlobals(e){for(;;){if(_isDeployment(e)||_isModel(e))return!1;if(a(e)||se(e))return!0;if(e.$container)e=e.$container;else return!1}}function isFqnRefInsideModel(e){for(;;){if(_isDeployment(e))return!1;if(_isModel(e))return!0;if(e.$container)e=e.$container;else return!1}}function isFqnRefInsideDeployment(e){for(;;){if(_isModel(e))return!1;if(_isDeployment(e))return!0;if(e.$container)e=e.$container;else return!1}}const Ae={mcpServer:()=>new NoopLikeC4MCPServer,mcpServerFactory:()=>new NoopLikeC4MCPServerFactory};var NoopLikeC4MCPServer=class{get mcp(){throw Error(`NoopLikeC4MCPServer does not have a McpServer`)}get isStarted(){return!1}get port(){return NaN}start(){return Promise.resolve()}stop(){return Promise.resolve()}},NoopLikeC4MCPServerFactory=class{create(e){throw Error(`NoopLikeC4MCPServerFactory`)}},AstNodeDescriptionProvider=class extends fe{constructor(e){super(e),this.services=e}createDescription(e,t,n){n??=x.getDocument(e);let i=super.createDescription(e,t,n);return r(n.uri)||(n.likec4ProjectId??=this.services.shared.workspace.ProjectsManager.ownerProjectId(n),i.likec4ProjectId=n.likec4ProjectId),i}},IndexManager=class extends pe{constructor(e){super(e),this.services=e}async updateContent(e,t){e.likec4ProjectId=this.services.workspace.ProjectsManager.ownerProjectId(e),await super.updateContent(e,t)}projectElements(e,t,n){let r=this.services.workspace.ProjectsManager;return E(this.symbolIndex.keys()).filter(t=>n&&!n.has(t)?!1:r.isIncluded(e,t)).flatMap(e=>this.getFileDescriptions(e,t))}};const je=O(`/`),ensureOrder=(e,t)=>je(e.uri.path,t.uri.path),isLikeC4UserDocument=e=>isLikeC4LangiumDocument(e)&&t(e);var LangiumDocuments=class extends me{constructor(e){super(e),this.services=e}get projectsManager(){return this.services.workspace.ProjectsManager}addDocument(e){let t=e.uri.toString();if(this.documentMap.has(t))throw Error(`A document with the URI '${t}' is already present.`);let n=[...this.documentMap.values(),e].sort(ensureOrder);this.documentMap.clear();for(let e of n)this.documentMap.set(e.uri.toString(),e);isLikeC4UserDocument(e)&&(e.likec4ProjectId=this.projectsManager.ownerProjectId(e))}getDocument(e){let t=super.getDocument(e);return isLikeC4UserDocument(t)&&(t.likec4ProjectId=this.projectsManager.ownerProjectId(t)),t}get userDocuments(){return E(this.documentMap.values()).filter(e=>isLikeC4UserDocument(e)&&!this.projectsManager.isExcluded(e))}get all(){return E(this.documentMap.values()).map(e=>(isLikeC4UserDocument(e)&&(e.likec4ProjectId=this.projectsManager.ownerProjectId(e)),e))}projectDocuments(e){let t=this.services.workspace.ProjectsManager;return E(this.documentMap.values()).filter(n=>isLikeC4UserDocument(n)&&t.isIncluded(e,n)?(n.likec4ProjectId=e,!0):!1)}groupedByProject(){let e=this.services.workspace.ProjectsManager;return ye(this.userDocuments.toArray(),V(t=>(t.likec4ProjectId=e.ownerProjectId(t),t)),_e(H(`likec4ProjectId`)))}resetProjectIds(){let e=[];for(let t of this.documentMap.values())delete t.likec4ProjectId,isLikeC4UserDocument(t)&&!this.projectsManager.isExcluded(t)&&e.push(t.uri);return e}},ADisposable=class{toDispose=[];isDisposed=!1;onDispose(...e){this.toDispose.push(...e)}dispose(){this.throwIfDisposed(),this.isDisposed=!0;let e;for(;e=this.toDispose.pop();)try{e.dispose()}catch(e){v(e)}}throwIfDisposed(){if(this.isDisposed)throw Error(`This has already been disposed`)}};function elementRef(e){try{let t=c(e)?e.el.ref:e.modelElement.value.ref;return t?.$type===`Imported`&&(t=t.imported.ref),t?.$type===`Element`?t:void 0}catch{return}}function readStrictFqn(e){let t=[e.$type===`StrictFqnRef`?e.value.$refText:e.el.$refText],n=e.parent;for(;n;)t.push(n.$type===`StrictFqnRef`?n.value.$refText:n.el.$refText),n=n.parent;return t.length===1?t[0]:t.reverse().join(`.`)}function referenceableParent(e){for(;e.parent;)e=e.parent;return e.value.ref??null}function instanceRef(e){let t;for(;t=e.value?.ref;){if(s(t))return null;if(b(t))return t;if(B(e.parent))return null;e=e.parent}return null}function importsRef(e){let t=referenceableParent(e);return t?.$type===`Imported`?t:null}function isReferenceToDeploymentModel(e){let t;for(;t=e.value?.ref;){if(p(t))return!0;if(B(e.parent))return!1;e=e.parent}return!1}function projectIdFrom(e){if(l(e)){for(;e.$type===`Imported`&&e.$container;)e=e.$container;W(h(e))}if(h(e))return e.project;let t=ge(e)?x.getDocument(e):e;return t.likec4ProjectId?t.likec4ProjectId:(d.warn`Document ${t.uri.fsPath} does not have a project ID assigned, this may lead to unexpected behavior.`,$.DefaultProjectId)}function stringHash$1(...e){return N(e.length>1?e.join(`:::`):e[0])}function safeCall(e){try{return e()}catch(e){d.trace(`Safe call failed`,{error:e});return}}function performanceNow(){try{return globalThis.performance.now()}catch{return Date.now()}}function performanceMark(){let e=performanceNow();return{get ms(){return performanceNow()-e},get pretty(){return De(performanceNow()-e)}}}const Z=d.getChild(`projects`);function isLangiumDocument(e){return typeof e==`object`&&`uri`in e&&`textDocument`in e}function normalizeUri(e){return isLangiumDocument(e)?e.uri.toString():typeof e==`string`?Se(e,{acceptRelative:!1,strict:!0})?e:C.file(e).toString():e.toString()}const Me=O(`/`,!0),compareUri=(e,t)=>Me(J(e.path),J(t.path));function isParentFolderFor(e){return t=>e.startsWith(A(t)?t:t.folder)}function _overlaps(e,t){let n=A(e)?e:e.folder,r=A(t)?t:t.folder;return n.startsWith(r)||r.startsWith(n)}function overlaps(...e){return U(_overlaps,e)}function _includes(e,t){return t.startsWith(e.folder)||e.includePaths?.some(isParentFolderFor(t))?!_excludes(e,t):!1}function _excludes(e,t){return e.exclude?.(q(t))??!1}function includes(...e){return U(_includes,e)}function excludes(...e){return U(_excludes,e)}function ProjectFolder(e){return e=normalizeUri(e),Ee(e)}const compareProjectByFolder=(e,t)=>compareUri(e.folderUri,t.folderUri);function ensureProjectsOrder(e){return e.sort(compareProjectByFolder)}const Q={id:`default`,config:{name:`default`,exclude:[`**/node_modules/**`]},exclude:K(`**/node_modules/**`,{dot:!0}),includeConfig:{paths:[],maxDepth:3,fileThreshold:30}};function isExcludedByDefault(e){return Q.exclude(q(e))}function parseRegisterOptions(e){if(`configUri`in e){k(!z(e.configUri),`configUri is emptyish`);let t=C.isUri(e.configUri)?e.configUri:C.parse(normalizeUri(e.configUri)),n=ProjectFolder(w.dirname(t));return{configUri:t,folder:n,folderUri:C.parse(n)}}k(!z(e.folderUri),`folderUri is emptyish`);let t=ProjectFolder(e.folderUri),n=C.parse(t);return{configUri:w.joinPath(n,`likec4.config.json`),folder:t,folderUri:n}}var $=class ProjectsManager{static DefaultProjectId=Q.id;#e=[];#t=void 0;#n=[];#r=new D(e=>{if(e===ProjectsManager.DefaultProjectId){let t=this.getWorkspaceFolder(),n=w.joinPath(t,`likec4.config.json`),r=ProjectFolder(t);return{id:e,config:Q.config,folder:r,folderUri:C.parse(r),configUri:n,exclude:Q.exclude,includeConfig:{...Q.includeConfig}}}return j(this.#n.find(t=>t.id===e),`Project ${e} not found`)});#i=new D(e=>{let t=normalizeUri(e),n=this.#a.get(t);return n?excludes(n,t)?!this.#n.some(includes(t)):!1:isExcludedByDefault(t)});#a=new D(e=>{let t=isParentFolderFor(e);return this.#n.find(t)??this.#n.find(includes(e))??null});constructor(e){this.services=e,Z.debug`created`}get defaultProjectId(){if(this.#t)return this.#t;if(!(this.#n.length>1))return R(this.#n,1)?this.#n[0].id:ProjectsManager.DefaultProjectId}set defaultProjectId(e){if(e!==this.#t){if(this.#t=void 0,!e||e===ProjectsManager.DefaultProjectId){Z.debug`reset default project ID`;return}k(this.#n.find(t=>t.id===e),`Project "${e}" not found`),Z.debug`set default project ID to ${e}`,this.#t=e}}get default(){return this.#r.get(this.defaultProjectId??ProjectsManager.DefaultProjectId)}get all(){if(R(this.#n,1)){let e=[...V(this.#n,H(`id`)),Q.id];if(this.#t){let t=e.findIndex(e=>e===this.#t);t>0&&(e.splice(t,1),e.unshift(this.#t))}return e}return[Q.id]}getProject(e){let t=typeof e==`string`?e:e.likec4ProjectId??this.ownerProjectId(e);return this.#r.get(t)}findOverlaped(e){let t=overlaps(ProjectFolder(e));return this.#n.filter(e=>t(e)||!!e.includePaths&&!!L(e.includePaths,t))}ensureProjectId(e){return e===ProjectsManager.DefaultProjectId?this.defaultProjectId??ProjectsManager.DefaultProjectId:e?(k(this.#n.some(t=>e===t.id),`Project ID ${e} is not registered`),e):j(this.defaultProjectId,()=>`Specify exact project, known: [${V(this.#n,H(`id`)).join(`, `)}]`)}ensureProject(e){return e=this.ensureProjectId(e),this.getProject(e)}hasMultipleProjects(){return this.#n.length>1}isExcluded(...e){let t=e.length===1?e[0]:e[1];return isLangiumDocument(t)&&r(t)?!0:e.length===1?this.#i.get(normalizeUri(t)):excludes(this.#r.get(e[0]),normalizeUri(t))}isIncluded(e,t){let n=normalizeUri(t);return R(this.#n,1)?e===ProjectsManager.DefaultProjectId?!this.#a.get(n)&&!isExcludedByDefault(n):includes(this.#r.get(e),normalizeUri(t)):!isExcludedByDefault(n)}async registerConfigFile(e,t){if(isExcludedByDefault(normalizeUri(e)))throw Error(`Failed to register project config, path ${e.fsPath} is excluded by: ${Q.config.exclude.map(e=>`"${e}"`).join(`, `)}`);try{let n=await this.services.workspace.FileSystemProvider.loadProjectConfig(e);return await this.registerProject({config:n,configUri:e},t)}catch(t){if(!T(t))throw F(t,`Failed to register project config ${e.fsPath}:\n`);return Promise.reject(t)}}async registerProject(e,t){let n=G.validate(e.config),{configUri:r,folder:i,folderUri:a}=parseRegisterOptions(e),o=G.normalizeInclude(n.include),s=this.#n.find(e=>e.folder===i);return s?(s.config.name!==n.name&&(Z.info`project name changed from ${s.config.name} to ${n.name}`,Z.info`unregistering ${s.id}`,s.id=this.uniqueProjectId(n.name),Z.info`register ${s.id}`),this.warnIfConfigOverride(s,r),s.config=n,s.folder=i,s.folderUri=a,s.configUri=r,s.includeConfig=o):(s={id:this.uniqueProjectId(n.name),config:n,folder:i,configUri:r,folderUri:a,includeConfig:o},this.#n=ensureProjectsOrder([...this.#n,s]),Z.info`register ${s.id}`),safeCall(()=>this.updateIncludesExcludes(s)),this.#o?s:(this.resetCaches(),this.notifyListeners(),await this.rebuildProject(s.id,t).catch(e=>T(e)?Promise.reject(e):(Z.warn(`Failed to rebuild project {projectId} after config change`,{projectId:s.id,error:e}),Promise.resolve())),s)}ownerProjectId(e){return this.#a.get(normalizeUri(e))?.id??this.#t??ProjectsManager.DefaultProjectId}#o=null;async reloadProjects(e){return this.#o?(Z.debug`reload projects is already in progress, waiting`,await this.#o.catch(()=>{})):(Z.debug`schedule reload projects`,this.#o=Promise.resolve().then(()=>this._reloadProjects(e)).catch(e=>(T(e)||Z.warn(`Failed to reload projects`,{error:e}),Promise.reject(e))).finally(()=>{this.#o=null,this.notifyListeners()}),await this.#o)}async _reloadProjects(e){let t=this.services.workspace.WorkspaceManager.workspaceFolders;if(!t||t.length===0){Z.warn(`Failed to reloadProjects, no workspace folders found`);return}Z.debug`start reload projects`;let n=[];for(let e of t){let t=C.parse(e.uri);Z.debug`scan projects in ${t.fsPath}`;try{let e=await this.services.workspace.FileSystemProvider.scanProjectFiles(t);for(let r of e)Z.debug`found config ${w.relative(t,r.uri)}`,n.push(r.uri)}catch(e){Z.warn(`Failed on scanProjectFiles in {folder}`,{folder:t.fsPath,error:e})}}if(n.length===0){if(this.#n.length===0){Z.warning(`No config files found`);return}Z.warning(`no config files found, but {count} projects were registered before`,{count:this.#n.length}),Z.warning(`reset`)}n.sort(compareUri);let r=new Map(this.#n.map(e=>[e.configUri.toString(),e]));this.#n=[],this.#r.clear();for(let e of n)try{await this.registerConfigFile(e)}catch(t){Z.warn(P(t));let n=r.get(e.toString());n&&(Z.debug`Update failed, restore project ${n.id}`,await this.registerProject(n).catch(e=>{Z.warn(`fail to restore project ${n.id}, ignoring`,{error:e})}))}this.resetCaches(),this.notifyListeners(),await this.services.workspace.WorkspaceManager.rebuildAll(e)}uniqueProjectId(e){let t=new Set(V(this.#n,H(`id`))),n=e;if(!t.has(n))return n;Z.warn`Project "${e}" already exists, generating unique ID`;let r=1;for(;t.has(n);)n=`${e}-${r++}`;return n}resetCaches(){Z.trace(`resetCaches`),this.#t&&!this.#n.some(e=>e.id===this.#t)&&(this.#t=void 0),this.#r.clear(),this.#a.clear(),this.#i.clear()}async rebuildProject(e,t){let n=this.#n.find(t=>t.id===e);if(!n)return e===ProjectsManager.DefaultProjectId?Z.info`Rebuilding all documents `:Z.warn`Project ${e} not found, rebuilding all`,await this.services.workspace.WorkspaceManager.rebuildAll(t);let r=Z.getChild(n.id),i=this.services.workspace.LangiumDocuments.userDocuments.filter(e=>includes(n,normalizeUri(e))).map(e=>e.uri).toArray();if(i.length===0){r.debug`no documents found for project ${n.id}, skipping rebuild`;return}r.info(`rebuild project documents: {docs}`,{docs:i.length}),this.resetCaches(),await this.services.workspace.DocumentBuilder.update(i,[],t).catch(e=>{r.warn(`Failed to rebuild project`,{error:e})})}getAllIncludePaths(){let e=[];for(let t of this.#n)if(t.includePaths)for(let n of t.includePaths)e.push({projectId:t.id,includePath:n.uri,includeConfig:t.includeConfig});return e}onProjectsUpdate(e){return this.#e.push(e),S.create(()=>{let t=this.#e.indexOf(e);t>=0&&this.#e.splice(t,1)})}getWorkspaceFolder(){try{return this.services.workspace.WorkspaceManager.workspaceUri}catch(e){return Z.warn(`Failed to get workspace URI, using default folder`,{error:e}),C.file(`/`)}}notifyListeners(){for(let e of this.#e)try{e()}catch(e){Z.warn(P(e))}}updateIncludesExcludes(e){let t=e.config;switch(delete e.includePaths,delete e.exclude,!0){case B(t.exclude):e.exclude=Q.exclude;break;case t.exclude&&R(t.exclude,1):e.exclude=K(V(t.exclude,t=>(!Ce(t)&&!t.startsWith(`**`)&&(t=Te(`**`,t)),xe(we(e.folderUri.path,t)))),{contains:!0,dot:!0});break}let n=e.includeConfig.paths;if(!R(n,1))return e;e.includePaths=V(n,t=>{let n=w.resolvePath(e.folderUri,t);return{uri:n,folder:ProjectFolder(n)}}),Z.debug`project ${e.id} include paths: ${e.includePaths.map(e=>e.uri.fsPath).join(`, `)}`;for(let t of e.includePaths)for(let n of this.#n)n.id!==e.id&&(overlaps(t,n)&&Z.warn(`Project "{projectId}" include path "{includePath}" overlaps with project "{otherProjectId}" folder. Files in overlapping areas will only belong to one project.`,{projectId:e.id,includePath:t.folder,otherProjectId:n.id}),n.includePaths?.forEach(r=>{overlaps(t,r)&&Z.warn(`Project "{projectId}" include path "{includePath}" overlaps with project "{otherProjectId}" include path "{otherIncludePath}". Files in overlapping areas will only belong to one project.`,{projectId:e.id,includePath:t.folder,otherProjectId:n.id,otherIncludePath:r.folder})}));return e}warnIfConfigOverride(e,t){try{let[n,r]=V([e.configUri,t],w.basename);n!==r&&Z.warn`config ${r} overrides ${n} in folder ${e.folder}`}catch{}}},LikeC4WorkspaceManager=class extends he{documentFactory;fileSystemProvider;#e=[];initialBuildOptions={eagerLinking:!0,validation:!0};constructor(e){super(e),this.services=e,this.documentFactory=e.workspace.LangiumDocumentFactory,this.fileSystemProvider=e.workspace.FileSystemProvider}async performStartup(e){this.folders??=e;let t=[];for(let n of e)try{let e=Y.parse(n.uri),r=await this.fileSystemProvider.scanProjectFiles(e);t.push(...r),this.services.workspace.FileSystemWatcher.watch(e.fsPath)}catch(e){v(e)}let n=this.services.workspace.ProjectsManager;for(let e of t)try{await n.registerConfigFile(e.uri)}catch(e){v(e)}return await super.performStartup(e)}async loadAdditionalDocuments(t,r){r(this.documentFactory.fromString(e,Y.parse(n)));let i=this.services.workspace.ProjectsManager.getAllIncludePaths(),a=0,o=[];for(let{projectId:e,includePath:t,includeConfig:n}of i)try{d.debug`scanning include path ${t.fsPath} for project ${e}`;let r=await this.fileSystemProvider.readDirectory(t,{recursive:!0,maxDepth:n.maxDepth});o.push(...r),r.length===0&&d.debug`loaded ${r.length} files from include path ${t.fsPath}`}catch(e){d.warn(`Failed to scan include path ${t.fsPath}`,{error:e})}for(let e of be(o,e=>e.uri.path))try{r(await this.langiumDocuments.getOrCreateDocument(e.uri)),a++}catch(t){d.warn(`Failed to load document ${e.uri.fsPath}`,{error:t})}if(i.length>0&&a>0){let e=Math.min(...i.map(e=>e.includeConfig.fileThreshold));a>e?d.warn(`Loaded ${a} files from include paths (threshold: ${e}). Large include directories may slow workspace initialization. Consider adjusting "include.fileThreshold" or "include.maxDepth" in your project configuration.`):d.info`loaded ${a} total files from ${i.length} include paths`}}includeEntry(e,t,n){let r=w.basename(t.uri);return t.isDirectory?!le(r):t.isFile?(n.fileExtensions.includes(w.extname(t.uri))||n.fileNames.includes(r))&&!this.services.workspace.ProjectsManager.isExcluded(t.uri):!1}workspace(){return this.folders&&R(this.folders,1)?this.folders[0]:null}async rebuildAll(e){let t=this.services.workspace.LangiumDocuments.resetProjectIds();d.info(`invalidate and rebuild all {docs} documents`,{docs:t.length}),this.forceCleanCaches(),await this.documentBuilder.update(t,[],e)}get workspaceUri(){let e=this.workspace();return W(e,`Workspace not initialized`),Y.parse(e.uri)}get workspaceURL(){let e=this.workspace();return W(e,`Workspace not initialized`),new URL(e.uri)}forceCleanCaches(){for(let e of this.#e)e();this.services.workspace.ManualLayouts.clearCaches(),this.services.workspace.Cache.clear()}onForceCleanCache(e){return this.#e.push(e),S.create(()=>{this.#e=this.#e.filter(t=>t!==e)})}};export{toAstViewLayoutDirection as A,isFqnRefInsideModel as C,parseAstPercent as D,parseAstOpacityProperty as E,toColor as M,toRelationshipStyle as N,parseAstSizeValue as O,isFqnRefInsideGlobals as S,parseAstIconPositionValue as T,NoopLikeC4MCPServer as _,stringHash$1 as a,getViewRulePredicateContainer as b,instanceRef as c,readStrictFqn as d,ADisposable as f,Ae as g,AstNodeDescriptionProvider as h,safeCall as i,toAutoLayout as j,parseMarkdownAsString as k,isReferenceToDeploymentModel as l,IndexManager as m,$ as n,projectIdFrom as o,LangiumDocuments as p,performanceMark as r,importsRef as s,LikeC4WorkspaceManager as t,elementRef as u,ke as v,isLikeC4LangiumDocument as w,isFqnRefInsideDeployment as x,Oe as y};
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { B as FileSystemWatcher, C as ViewLocateResult, D as LangiumDocuments, E as LikeC4WorkspaceManager, F as NoFileSystemWatcher, G as Project, H as LikeC4ManualLayouts, I as NoLikeC4ManualLayouts, K as ProjectData, P as NoFileSystem, R as FileSystemModuleContext, S as LikeC4ModelLocator, T as FqnIndex, U as LikeC4ManualLayoutsModuleContext, V as FileSystemWatcherModuleContext, d as DocumentParser, f as LikeC4ModelParser, g as LikeC4ViewsModuleContext, n as LikeC4AddedServices, o as LikeC4SharedServices, q as ProjectsManager, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as LikeC4LanguageServices, v as WithWasmGraphviz, w as LikeC4ModelBuilder, x as NoMCPServer, y as LikeC4Views, z as FileSystemProvider } from "../_chunks/module.mjs";
|
|
2
|
+
import "../_chunks/protocol.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/browser/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Starts the LikeC4 language server in the browser, connected via the given port (e.g. a worker).
|
|
7
|
+
* @param port - MessagePort or DedicatedWorkerGlobalScope for LSP communication.
|
|
8
|
+
* @returns Shared and LikeC4-specific services after the connection is initialized.
|
|
9
|
+
*/
|
|
5
10
|
declare function startLanguageServer(port: MessagePort | DedicatedWorkerGlobalScope): {
|
|
6
11
|
shared: LikeC4SharedServices;
|
|
7
12
|
likec4: LikeC4Services;
|
|
8
13
|
};
|
|
9
14
|
//#endregion
|
|
10
|
-
export { DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FqnIndex, LangiumDocuments, LanguageServicesContext, LikeC4AddedServices, LikeC4LanguageServices, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser, LikeC4Services, LikeC4SharedServices, LikeC4Views, LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, NoMCPServer, Project, ProjectData, ProjectsManager, ViewLocateResult, createLanguageServices, startLanguageServer };
|
|
15
|
+
export { DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FqnIndex, LangiumDocuments, LanguageServicesContext, LikeC4AddedServices, LikeC4LanguageServices, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser, LikeC4Services, LikeC4SharedServices, LikeC4Views, LikeC4ViewsModuleContext, LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, NoMCPServer, Project, ProjectData, ProjectsManager, ViewLocateResult, WithWasmGraphviz, createLanguageServices, startLanguageServer };
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"../_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import{g as r}from"../_chunks/workspace.mjs";import{t as i}from"../_chunks/module.mjs";import"../_chunks/common-exports.mjs";import{configureLogger as a,getConsoleSink as o,getTextFormatter as s}from"@likec4/log";import{startLanguageServer as c}from"langium/lsp";import{BrowserMessageReader as l,BrowserMessageWriter as u,createConnection as d}from"vscode-languageserver/browser";function startLanguageServer(e){let t=d(new l(e),new u(e));a({sinks:{console:o({formatter:s({format:({level:e,category:t,message:n})=>`${e} ${t} ${n}`})})},loggers:[{category:`likec4`,sinks:[`console`],lowestLevel:`debug`}]});let n=i({connection:t});return c(n.shared),n}export{n as NoFileSystem,e as NoFileSystemWatcher,t as NoLikeC4ManualLayouts,r as NoMCPServer,i as createLanguageServices,startLanguageServer};
|
package/dist/browser/worker.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{startLanguageServer}from"./index.mjs";
|
|
1
|
+
import"../_chunks/likec4lib.mjs";import"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import"../_chunks/workspace.mjs";import"../_chunks/module.mjs";import"../_chunks/common-exports.mjs";import{startLanguageServer as e}from"./index.mjs";function errToString(e){switch(!0){case e instanceof Error:return e.message;case typeof e==`object`&&!!e:try{return JSON.stringify(e)}catch{return`[unserializable value]`}case typeof e==`string`:return e;case e==null:return``;case typeof e==`number`||typeof e==`boolean`:return String(e);case typeof e==`symbol`:return e.toString();default:return`unknown`}}const log=(e,t)=>{let n=t==null?e:`${e} ${errToString(t)}`;try{console.error(`[LikeC4 LSP worker]`,n)}catch{}};self.onerror=e=>(log(`Uncaught error`,e.message??e.error),!1),self.onunhandledrejection=e=>{log(`Unhandled rejection`,e.reason)};try{e(self)}catch(e){throw log(`Failed to start language server`,e),e}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
|
|
1
|
+
import { B as FileSystemWatcher, F as NoFileSystemWatcher, H as LikeC4ManualLayouts, I as NoLikeC4ManualLayouts, L as FileNode, M as WithChokidarWatcher, N as WithFileSystem, P as NoFileSystem, R as FileSystemModuleContext, U as LikeC4ManualLayoutsModuleContext, V as FileSystemWatcherModuleContext, W as ManualLayoutsSnapshot, j as WithLikeC4ManualLayouts, z as FileSystemProvider } from "../_chunks/module.mjs";
|
|
2
|
+
import "../_chunks/protocol.mjs";
|
|
3
|
+
export { FileNode, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, ManualLayoutsSnapshot, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithChokidarWatcher, WithFileSystem, WithLikeC4ManualLayouts };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"../_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import{n as r,r as i,t as a}from"../_chunks/LikeC4FileSystem.mjs";export{n as NoFileSystem,e as NoFileSystemWatcher,t as NoLikeC4ManualLayouts,r as WithChokidarWatcher,a as WithFileSystem,i as WithLikeC4ManualLayouts};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
|
|
4
|
-
import { Connection } from "vscode-languageserver";
|
|
5
|
-
|
|
6
|
-
//#region src/index.d.ts
|
|
7
|
-
type StartLanguageServerOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* The Language Server Protocol connection to use.
|
|
10
|
-
*/
|
|
11
|
-
connection?: Connection;
|
|
12
|
-
/**
|
|
13
|
-
* Whether to enable the file system watcher.
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
enableWatcher?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* @default true
|
|
19
|
-
*/
|
|
20
|
-
enableTelemetry?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Whether to enable the MCP server.
|
|
23
|
-
* @default 'sse'
|
|
24
|
-
*/
|
|
25
|
-
enableMCP?: false | 'stdio' | 'sse' | {
|
|
26
|
-
port: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Whether to enable manual layouts, stored in json5 files.
|
|
30
|
-
* @default true
|
|
31
|
-
*/
|
|
32
|
-
enableManualLayouts?: boolean;
|
|
33
|
-
};
|
|
34
|
-
declare function startLanguageServer(options?: StartLanguageServerOptions): {
|
|
35
|
-
shared: LikeC4SharedServices;
|
|
36
|
-
likec4: LikeC4Services;
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FqnIndex, LangiumDocuments, LanguageServicesContext, LikeC4AddedServices, LikeC4LanguageServices, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser, LikeC4Services, LikeC4SharedServices, LikeC4Views, LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, NoMCPServer, Project, ProjectData, ProjectsManager, ViewLocateResult, WithFileSystem, WithLikeC4ManualLayouts, WithMCPServer, createLanguageServices, startLanguageServer };
|
|
1
|
+
import { B as FileSystemWatcher, C as ViewLocateResult, D as LangiumDocuments, E as LikeC4WorkspaceManager, F as NoFileSystemWatcher, G as Project, H as LikeC4ManualLayouts, I as NoLikeC4ManualLayouts, K as ProjectData, N as WithFileSystem, P as NoFileSystem, R as FileSystemModuleContext, S as LikeC4ModelLocator, T as FqnIndex, U as LikeC4ManualLayoutsModuleContext, V as FileSystemWatcherModuleContext, b as WithMCPServer, d as DocumentParser, f as LikeC4ModelParser, g as LikeC4ViewsModuleContext, h as configureLanguageServerLogger, j as WithLikeC4ManualLayouts, m as ConfigureLanguageServerLoggerOptions, n as LikeC4AddedServices, o as LikeC4SharedServices, p as startLanguageServer, q as ProjectsManager, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as LikeC4LanguageServices, v as WithWasmGraphviz, w as LikeC4ModelBuilder, x as NoMCPServer, y as LikeC4Views, z as FileSystemProvider } from "./_chunks/module.mjs";
|
|
2
|
+
import "./_chunks/protocol.mjs";
|
|
3
|
+
export { ConfigureLanguageServerLoggerOptions, DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FqnIndex, LangiumDocuments, LanguageServicesContext, LikeC4AddedServices, LikeC4LanguageServices, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser, LikeC4Services, LikeC4SharedServices, LikeC4Views, LikeC4ViewsModuleContext, LikeC4WorkspaceManager, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, NoMCPServer, Project, ProjectData, ProjectsManager, ViewLocateResult, WithFileSystem, WithLikeC4ManualLayouts, WithMCPServer, WithWasmGraphviz, configureLanguageServerLogger, createLanguageServices, startLanguageServer };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"./_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"./_chunks/noop.mjs";import{Cr as r,Tr as i}from"./_chunks/utils.mjs";import{r as a,t as o}from"./_chunks/LikeC4FileSystem.mjs";import{g as s}from"./_chunks/workspace.mjs";import{i as c,t as l}from"./_chunks/module.mjs";import"./_chunks/common-exports.mjs";import{t as u}from"./_chunks/mcp.mjs";import{configureLogger as d,getAnsiColorFormatter as f,getConsoleSink as p,getConsoleStderrSink as m,getTextFormatter as h}from"@likec4/log";import{isEmpty as g}from"remeda";import{startLanguageServer as _}from"langium/lsp";import{GraphvizWasmAdapter as v,QueueGraphvizLayoter as y}from"@likec4/layouts";import{GraphvizBinaryAdapter as b}from"@likec4/layouts/graphviz/binary";import{defu as x}from"defu";import{isDevelopment as S}from"std-env";import C from"which";function configureLanguageServerLogger({lspConnection:e,enableTelemetry:t=!!e,useStdErr:n=!1,logLevel:a=S?`debug`:`warning`,nonBlocking:o=!1,colors:s=!1}={}){let c=!!e&&t&&!S;d({reset:!0,sinks:{console:n?m({formatter:h()}):p({formatter:s?f():h(),nonBlocking:o}),...c&&{telemetry:r(e)}},loggers:[{category:[`likec4`],sinks:[`console`,...c?[`telemetry`]:[]],lowestLevel:a}]}),i.trace(`logger configured`)}function graphvizBinPath(){try{return C.sync(`dot`)}catch(e){return i.error(`Error checking for native Graphviz:`,{error:e}),null}}const w={likec4:{Layouter(e){i.debug(`Creating ConfigurableLayouter`);let t=e.likec4.Graphviz,n=new y({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=g(a)?graphvizBinPath():a;if(!g(t)){n.changePort(new b(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 v),i.info(`use graphviz wasm`)}catch(e){i.error(`Failed to update configuration`,{error:e})}}),n}}};function startLanguageServer(e){let t=e?.connection,n=x(e,{enableWatcher:!0,enableMCP:`sse`,enableManualLayouts:!0,graphviz:`wasm`,configureLogger:!1});n.configureLogger!==!1&&(n.configureLogger===`stderr`||n.enableMCP===`stdio`?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=l({...t&&{connection:t},...o(n.enableWatcher),...!!n.enableMCP&&u(n.enableMCP),...n.enableManualLayouts&&a,...c(n.graphviz===`binary`?new b:new v)},t?{likec4:{...w.likec4}}:void 0);return _(r.shared),r}export{n as NoFileSystem,e as NoFileSystemWatcher,t as NoLikeC4ManualLayouts,s as NoMCPServer,o as WithFileSystem,a as WithLikeC4ManualLayouts,u as WithMCPServer,configureLanguageServerLogger,l as createLanguageServices,startLanguageServer};
|
package/dist/likec4lib.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./_chunks/likec4lib.mjs";export{e as Content,i as Scheme,n as Uri,r as isLikeC4Builtin,t as isNotLikeC4Builtin};
|
package/dist/mcp/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { A as LikeC4MCPServerModuleContext, O as LikeC4MCPServer, b as WithMCPServer, k as LikeC4MCPServerFactory, x as NoMCPServer } from "../_chunks/module.mjs";
|
|
2
|
+
import "../_chunks/protocol.mjs";
|
|
3
|
+
export { LikeC4MCPServer, LikeC4MCPServerFactory, LikeC4MCPServerModuleContext, NoMCPServer, WithMCPServer };
|
package/dist/mcp/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"../_chunks/likec4lib.mjs";import"../_chunks/utils.mjs";import{g as e}from"../_chunks/workspace.mjs";import{t}from"../_chunks/mcp.mjs";export{e as NoMCPServer,t as WithMCPServer};
|
package/dist/module.d.mts
CHANGED
|
@@ -1,126 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
|
|
4
|
-
import { DefaultSharedModuleContext, LangiumServices, LangiumSharedServices, PartialLangiumServices } from "langium/lsp";
|
|
5
|
-
import { QueueGraphvizLayoter } from "@likec4/layouts";
|
|
6
|
-
|
|
7
|
-
//#region src/module.d.ts
|
|
8
|
-
type LanguageServicesContext = Omit<DefaultSharedModuleContext, 'fileSystemProvider'> & FileSystemModuleContext & LikeC4MCPServerModuleContext & LikeC4ManualLayoutsModuleContext;
|
|
9
|
-
interface LikeC4AddedSharedServices {
|
|
10
|
-
lsp: {
|
|
11
|
-
NodeKindProvider: NodeKindProvider$1;
|
|
12
|
-
WorkspaceSymbolProvider: WorkspaceSymbolProvider;
|
|
13
|
-
};
|
|
14
|
-
workspace: {
|
|
15
|
-
Cache: WorkspaceCache<string, any>;
|
|
16
|
-
ProjectsManager: ProjectsManager;
|
|
17
|
-
IndexManager: IndexManager;
|
|
18
|
-
LangiumDocuments: LangiumDocuments;
|
|
19
|
-
WorkspaceManager: LikeC4WorkspaceManager;
|
|
20
|
-
FileSystemProvider: FileSystemProvider$1;
|
|
21
|
-
FileSystemWatcher: FileSystemWatcher;
|
|
22
|
-
ManualLayouts: LikeC4ManualLayouts;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
type LikeC4SharedServices = LangiumSharedServices & LikeC4AddedSharedServices;
|
|
26
|
-
/**
|
|
27
|
-
* Declaration of custom services - add your own service classes here.
|
|
28
|
-
*/
|
|
29
|
-
interface LikeC4AddedServices {
|
|
30
|
-
documentation: {
|
|
31
|
-
DocumentationProvider: LikeC4DocumentationProvider;
|
|
32
|
-
};
|
|
33
|
-
validation: {
|
|
34
|
-
DocumentValidator: LikeC4DocumentValidator;
|
|
35
|
-
};
|
|
36
|
-
Rpc: Rpc;
|
|
37
|
-
mcp: {
|
|
38
|
-
Server: LikeC4MCPServer;
|
|
39
|
-
ServerFactory: LikeC4MCPServerFactory;
|
|
40
|
-
};
|
|
41
|
-
likec4: {
|
|
42
|
-
LanguageServices: LikeC4LanguageServices;
|
|
43
|
-
Views: LikeC4Views;
|
|
44
|
-
Layouter: QueueGraphvizLayoter;
|
|
45
|
-
DeploymentsIndex: DeploymentsIndex;
|
|
46
|
-
FqnIndex: FqnIndex;
|
|
47
|
-
ModelParser: LikeC4ModelParser;
|
|
48
|
-
ModelBuilder: LikeC4ModelBuilder;
|
|
49
|
-
ModelLocator: LikeC4ModelLocator;
|
|
50
|
-
ModelChanges: LikeC4ModelChanges;
|
|
51
|
-
LastSeen: LastSeenArtifacts;
|
|
52
|
-
};
|
|
53
|
-
lsp: {
|
|
54
|
-
CompletionProvider: LikeC4CompletionProvider;
|
|
55
|
-
DocumentHighlightProvider: LikeC4DocumentHighlightProvider;
|
|
56
|
-
DocumentSymbolProvider: LikeC4DocumentSymbolProvider;
|
|
57
|
-
SemanticTokenProvider: LikeC4SemanticTokenProvider;
|
|
58
|
-
HoverProvider: LikeC4HoverProvider;
|
|
59
|
-
CodeLensProvider: LikeC4CodeLensProvider;
|
|
60
|
-
DocumentLinkProvider: LikeC4DocumentLinkProvider;
|
|
61
|
-
Formatter: LikeC4Formatter;
|
|
62
|
-
CodeActionProvider: LikeC4CodeActionProvider;
|
|
63
|
-
};
|
|
64
|
-
references: {
|
|
65
|
-
NameProvider: LikeC4NameProvider;
|
|
66
|
-
ScopeComputation: LikeC4ScopeComputation;
|
|
67
|
-
ScopeProvider: LikeC4ScopeProvider;
|
|
68
|
-
};
|
|
69
|
-
shared?: LikeC4SharedServices;
|
|
70
|
-
parser: {
|
|
71
|
-
ValueConverter: LikeC4ValueConverter;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
type LikeC4Services = LangiumServices & LikeC4AddedServices;
|
|
75
|
-
/**
|
|
76
|
-
* Most probably you don't need to use this function directly.
|
|
77
|
-
* Use {@link createLanguageServices} instead.
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
declare function createLikeC4Module(context: LikeC4MCPServerModuleContext): Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices>;
|
|
81
|
-
/**
|
|
82
|
-
* Create and initialize likec4 language services with the given context
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* const { shared, likec4 } = createLanguageServices({
|
|
86
|
-
* ...WithFileSystem(enableWatcher = true),
|
|
87
|
-
* ...WithLikeC4ManualLayouts(),
|
|
88
|
-
* ...NoMcpServer(),
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* It is possible to extend/override the context with additional modules
|
|
93
|
-
* See Langium documentation for more details (or at the CliContext in packages/likec4/src/language/module.ts).
|
|
94
|
-
*/
|
|
95
|
-
declare function createLanguageServices(): {
|
|
96
|
-
shared: LikeC4SharedServices;
|
|
97
|
-
likec4: LikeC4Services;
|
|
98
|
-
};
|
|
99
|
-
declare function createLanguageServices(context: Partial<LanguageServicesContext>): {
|
|
100
|
-
shared: LikeC4SharedServices;
|
|
101
|
-
likec4: LikeC4Services;
|
|
102
|
-
};
|
|
103
|
-
declare function createLanguageServices(context: Partial<LanguageServicesContext>): {
|
|
104
|
-
shared: LikeC4SharedServices;
|
|
105
|
-
likec4: LikeC4Services;
|
|
106
|
-
};
|
|
107
|
-
declare function createLanguageServices<I1, I extends I1 & LikeC4Services>(context: Partial<LanguageServicesContext>, module: Module<I, I1> | undefined): {
|
|
108
|
-
shared: LikeC4SharedServices;
|
|
109
|
-
likec4: I;
|
|
110
|
-
};
|
|
111
|
-
declare function createLanguageServices<I1, I2, I extends I1 & I2 & LikeC4Services>(context: Partial<LanguageServicesContext>, module: Module<I, I1>, module2: Module<I, I2>): {
|
|
112
|
-
shared: LikeC4SharedServices;
|
|
113
|
-
likec4: I;
|
|
114
|
-
};
|
|
115
|
-
declare function createLanguageServices<I1, I2, I3, I extends I1 & I2 & I3 & LikeC4Services>(context: Partial<LanguageServicesContext>, module: Module<I, I1>, module2: Module<I, I2>, module3: Module<I, I3>): {
|
|
116
|
-
shared: LikeC4SharedServices;
|
|
117
|
-
likec4: I;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Most probably you don't need to use this function directly.
|
|
121
|
-
* Use {@link createLanguageServices} instead.
|
|
122
|
-
* @internal
|
|
123
|
-
*/
|
|
124
|
-
declare function createSharedServices(context?: Partial<LanguageServicesContext>): LikeC4SharedServices;
|
|
125
|
-
//#endregion
|
|
126
|
-
export { LanguageServicesContext, LikeC4AddedServices, LikeC4Services, LikeC4SharedServices, NoFileSystem, NoLikeC4ManualLayouts, NoMCPServer, createLanguageServices, createLikeC4Module, createSharedServices };
|
|
1
|
+
import { I as NoLikeC4ManualLayouts, P as NoFileSystem, _ as WithGraphviz, a as LikeC4SharedModuleContext, c as createLikeC4Module, i as LikeC4ServicesContext, l as createSharedServices, n as LikeC4AddedServices, o as LikeC4SharedServices, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, v as WithWasmGraphviz, x as NoMCPServer } from "./_chunks/module.mjs";
|
|
2
|
+
import "./_chunks/protocol.mjs";
|
|
3
|
+
export { LanguageServicesContext, LikeC4AddedServices, LikeC4Services, LikeC4ServicesContext, LikeC4SharedModuleContext, LikeC4SharedServices, NoFileSystem, NoLikeC4ManualLayouts, NoMCPServer, WithGraphviz, WithWasmGraphviz, createLanguageServices, createLikeC4Module, createSharedServices };
|
package/dist/module.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./_chunks/likec4lib.mjs";import{r as e,t}from"./_chunks/noop.mjs";import"./_chunks/utils.mjs";import{g as n}from"./_chunks/workspace.mjs";import{a as r,i,n as a,r as o,t as s}from"./_chunks/module.mjs";export{t as NoFileSystem,e as NoLikeC4ManualLayouts,n as NoMCPServer,i as WithGraphviz,r as WithWasmGraphviz,s as createLanguageServices,a as createLikeC4Module,o as createSharedServices};
|
package/dist/protocol.d.mts
CHANGED
|
@@ -1,315 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ColorLiteral, ComputedLikeC4ModelData, DeploymentFqn, DiagramView, Fqn, LayoutedLikeC4ModelData, LayoutedProjectsView, NonEmptyArray, ProjectId, RelationId, ViewChange, ViewId } from "@likec4/core";
|
|
3
|
-
import { LikeC4ProjectJsonConfig } from "@likec4/config";
|
|
4
|
-
import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
|
|
5
|
-
|
|
6
|
-
//#region src/protocol.d.ts
|
|
7
|
-
declare namespace DidChangeModelNotification {
|
|
8
|
-
const type: NotificationType<string>;
|
|
9
|
-
type Type = typeof type;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Triggered by the language server when projects changed
|
|
13
|
-
* (number of projects changed, names changed, etc)
|
|
14
|
-
*/
|
|
15
|
-
declare namespace DidChangeProjectsNotification {
|
|
16
|
-
const type: NotificationType0;
|
|
17
|
-
type Type = typeof type;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* When the snapshot of a manual layout changes
|
|
21
|
-
* Send by the editor to the language server
|
|
22
|
-
*/
|
|
23
|
-
declare namespace DidChangeSnapshotNotification {
|
|
24
|
-
type Params = {
|
|
25
|
-
snapshotUri: DocumentUri;
|
|
26
|
-
};
|
|
27
|
-
const Method: "likec4/onDidChangeSnapshot";
|
|
28
|
-
const type: NotificationType<Params>;
|
|
29
|
-
type Type = typeof type;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* When server requests to open a likec4 preview panel
|
|
33
|
-
* (available only in the editor).
|
|
34
|
-
* (not the best place, but seems to be working)
|
|
35
|
-
*/
|
|
36
|
-
declare namespace DidRequestOpenViewNotification {
|
|
37
|
-
type Params = {
|
|
38
|
-
viewId: ViewId;
|
|
39
|
-
projectId: ProjectId;
|
|
40
|
-
};
|
|
41
|
-
const type: NotificationType<Params>;
|
|
42
|
-
type Type = typeof type;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Request to fetch the computed model data
|
|
46
|
-
* If LSP has multiple projects, the projectId is required.
|
|
47
|
-
* otherwise throws an error.
|
|
48
|
-
*/
|
|
49
|
-
declare namespace FetchComputedModel {
|
|
50
|
-
type Params = {
|
|
51
|
-
projectId?: string | undefined;
|
|
52
|
-
cleanCaches?: boolean | undefined;
|
|
53
|
-
};
|
|
54
|
-
type Res = {
|
|
55
|
-
model: ComputedLikeC4ModelData | null;
|
|
56
|
-
};
|
|
57
|
-
const req: RequestType<Params, Res, void>;
|
|
58
|
-
type Req = typeof req;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Request to fetch all views of all projects
|
|
62
|
-
*/
|
|
63
|
-
declare namespace FetchViewsFromAllProjects {
|
|
64
|
-
type Res = {
|
|
65
|
-
views: Array<{
|
|
66
|
-
id: ViewId;
|
|
67
|
-
title: string;
|
|
68
|
-
projectId: ProjectId;
|
|
69
|
-
}>;
|
|
70
|
-
};
|
|
71
|
-
const req: RequestType0<Res, void>;
|
|
72
|
-
type Req = typeof req;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Request to fetch the layouted model data
|
|
76
|
-
* If LSP has multiple projects, the projectId is required.
|
|
77
|
-
* otherwise throws an error.
|
|
78
|
-
*/
|
|
79
|
-
declare namespace FetchLayoutedModel {
|
|
80
|
-
type Params = {
|
|
81
|
-
projectId?: string | undefined;
|
|
82
|
-
};
|
|
83
|
-
type Res = {
|
|
84
|
-
model: LayoutedLikeC4ModelData | null;
|
|
85
|
-
};
|
|
86
|
-
const req: RequestType<Params, Res, void>;
|
|
87
|
-
type Req = typeof req;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Request to layout a view.
|
|
91
|
-
* If LSP has multiple projects, the projectId is required.
|
|
92
|
-
*/
|
|
93
|
-
declare namespace LayoutView {
|
|
94
|
-
type Params = {
|
|
95
|
-
viewId: ViewId;
|
|
96
|
-
projectId?: string | undefined;
|
|
97
|
-
layoutType?: 'auto' | 'manual' | undefined;
|
|
98
|
-
};
|
|
99
|
-
type Res = {
|
|
100
|
-
result: {
|
|
101
|
-
dot: string;
|
|
102
|
-
diagram: DiagramView;
|
|
103
|
-
} | null;
|
|
104
|
-
};
|
|
105
|
-
const req: RequestType<Params, Res, void>;
|
|
106
|
-
type Req = typeof req;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Request to validate all views
|
|
110
|
-
* If projects ID is provided, it will validate only the views of that project.
|
|
111
|
-
*/
|
|
112
|
-
declare namespace ValidateLayout {
|
|
113
|
-
type Params = {
|
|
114
|
-
projectId?: string;
|
|
115
|
-
};
|
|
116
|
-
type Res = {
|
|
117
|
-
result: {
|
|
118
|
-
uri: string;
|
|
119
|
-
viewId: ViewId;
|
|
120
|
-
message: string;
|
|
121
|
-
severity: DiagnosticSeverity;
|
|
122
|
-
range: {
|
|
123
|
-
start: Position;
|
|
124
|
-
end: Position;
|
|
125
|
-
};
|
|
126
|
-
}[] | null;
|
|
127
|
-
};
|
|
128
|
-
const req: RequestType<Params, Res, void>;
|
|
129
|
-
type Req = typeof req;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Request to reload projects.
|
|
133
|
-
*/
|
|
134
|
-
declare namespace ReloadProjects {
|
|
135
|
-
type Params = never;
|
|
136
|
-
type Res = void;
|
|
137
|
-
const req: RequestType0<void, void>;
|
|
138
|
-
type Req = typeof req;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Fetch all non-empty projects.
|
|
142
|
-
*/
|
|
143
|
-
declare namespace FetchProjects {
|
|
144
|
-
type Params = never;
|
|
145
|
-
type Res = {
|
|
146
|
-
projects: {
|
|
147
|
-
[projectId: ProjectId]: {
|
|
148
|
-
folder: URI;
|
|
149
|
-
config: {
|
|
150
|
-
name: string;
|
|
151
|
-
title?: string | undefined;
|
|
152
|
-
};
|
|
153
|
-
docs: NonEmptyArray<DocumentUri>;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
const req: RequestType0<Res, void>;
|
|
158
|
-
type Req = typeof req;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Request from the client to register a project.
|
|
162
|
-
*/
|
|
163
|
-
declare namespace RegisterProject {
|
|
164
|
-
type Params = {
|
|
165
|
-
folderUri: URI;
|
|
166
|
-
config: LikeC4ProjectJsonConfig;
|
|
167
|
-
configUri?: never;
|
|
168
|
-
} | {
|
|
169
|
-
configUri: URI;
|
|
170
|
-
folderUri?: never;
|
|
171
|
-
config?: never;
|
|
172
|
-
};
|
|
173
|
-
type Res = {
|
|
174
|
-
id: ProjectId;
|
|
175
|
-
};
|
|
176
|
-
const req: RequestType<Params, Res, void>;
|
|
177
|
-
type Req = typeof req;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Request to build documents.
|
|
181
|
-
*/
|
|
182
|
-
declare namespace BuildDocuments {
|
|
183
|
-
type Params = {
|
|
184
|
-
docs: DocumentUri[];
|
|
185
|
-
};
|
|
186
|
-
const req: RequestType<Params, void, void>;
|
|
187
|
-
type Req = typeof req;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Request to locate an element, relation, deployment or view.
|
|
191
|
-
* If LSP has multiple projects, the projectId is required.
|
|
192
|
-
*/
|
|
193
|
-
declare namespace Locate {
|
|
194
|
-
type Params =
|
|
195
|
-
/**
|
|
196
|
-
* Locate an element by its fqn
|
|
197
|
-
*/
|
|
198
|
-
{
|
|
199
|
-
element: Fqn;
|
|
200
|
-
projectId?: string | undefined;
|
|
201
|
-
property?: string;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Locate a relation by its id
|
|
205
|
-
*/
|
|
206
|
-
| {
|
|
207
|
-
projectId?: string | undefined;
|
|
208
|
-
relation: RelationId;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Locate a deployment by its fqn
|
|
212
|
-
*/
|
|
213
|
-
| {
|
|
214
|
-
deployment: DeploymentFqn;
|
|
215
|
-
projectId?: string | undefined;
|
|
216
|
-
property?: string;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Locate a step in a dynamic view by its astPath
|
|
220
|
-
*/
|
|
221
|
-
| {
|
|
222
|
-
view: ViewId;
|
|
223
|
-
astPath: string;
|
|
224
|
-
projectId?: string | undefined;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Locate a view by its id
|
|
228
|
-
*/
|
|
229
|
-
| {
|
|
230
|
-
view: ViewId;
|
|
231
|
-
projectId?: string | undefined;
|
|
232
|
-
};
|
|
233
|
-
type Res = Location | null;
|
|
234
|
-
const req: RequestType<Params, Res, void>;
|
|
235
|
-
type Req = typeof req;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Request to change the view
|
|
239
|
-
* If LSP has multiple projects, the projectId is required.
|
|
240
|
-
*/
|
|
241
|
-
declare namespace ChangeView {
|
|
242
|
-
type Params = {
|
|
243
|
-
viewId: ViewId;
|
|
244
|
-
change: ViewChange;
|
|
245
|
-
projectId?: string | undefined;
|
|
246
|
-
};
|
|
247
|
-
type Res = {
|
|
248
|
-
success: true;
|
|
249
|
-
location: Location | null;
|
|
250
|
-
} | {
|
|
251
|
-
success: false;
|
|
252
|
-
location?: Location | null;
|
|
253
|
-
error: string;
|
|
254
|
-
};
|
|
255
|
-
const req: RequestType<Params, Res, void>;
|
|
256
|
-
type Req = typeof req;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Request to fetch telemetry metrics
|
|
260
|
-
*/
|
|
261
|
-
declare namespace FetchTelemetryMetrics {
|
|
262
|
-
type Res = {
|
|
263
|
-
metrics: null | {
|
|
264
|
-
elementKinds: number;
|
|
265
|
-
deploymentKinds: number;
|
|
266
|
-
relationshipKinds: number;
|
|
267
|
-
tags: number;
|
|
268
|
-
customColors: number;
|
|
269
|
-
elements: number;
|
|
270
|
-
deploymentNodes: number;
|
|
271
|
-
relationships: number;
|
|
272
|
-
views: number;
|
|
273
|
-
projects: number;
|
|
274
|
-
};
|
|
275
|
-
};
|
|
276
|
-
const req: RequestType0<Res, void>;
|
|
277
|
-
type Req = typeof req;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Request to fetch all tags of a document
|
|
281
|
-
*/
|
|
282
|
-
declare namespace GetDocumentTags {
|
|
283
|
-
type Params = {
|
|
284
|
-
documentUri: DocumentUri;
|
|
285
|
-
};
|
|
286
|
-
type Res = {
|
|
287
|
-
/**
|
|
288
|
-
* Project ID this document belongs to (if any)
|
|
289
|
-
*/
|
|
290
|
-
projectId: ProjectId;
|
|
291
|
-
/**
|
|
292
|
-
* Used tags in the document
|
|
293
|
-
*/
|
|
294
|
-
tags: Array<{
|
|
295
|
-
name: string;
|
|
296
|
-
range: Range;
|
|
297
|
-
color: ColorLiteral;
|
|
298
|
-
isSpecification?: boolean;
|
|
299
|
-
}>;
|
|
300
|
-
};
|
|
301
|
-
const req: RequestType<Params, Res, void>;
|
|
302
|
-
type Req = typeof req;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Request to fetch projects overview diagram
|
|
306
|
-
*/
|
|
307
|
-
declare namespace FetchProjectsOverview {
|
|
308
|
-
type Res = {
|
|
309
|
-
projectsView: LayoutedProjectsView | null;
|
|
310
|
-
};
|
|
311
|
-
const req: RequestType0<Res, void>;
|
|
312
|
-
type Req = typeof req;
|
|
313
|
-
}
|
|
314
|
-
//#endregion
|
|
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";
|
|
315
2
|
export { BuildDocuments, ChangeView, DidChangeModelNotification, DidChangeProjectsNotification, DidChangeSnapshotNotification, DidRequestOpenViewNotification, FetchComputedModel, FetchLayoutedModel, FetchProjects, FetchProjectsOverview, FetchTelemetryMetrics, FetchViewsFromAllProjects, GetDocumentTags, LayoutView, Locate, RegisterProject, ReloadProjects, ValidateLayout };
|