@likec4/language-server 1.50.0 → 1.52.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -25
  3. package/bin/likec4-language-server.mjs +2 -3
  4. package/dist/_chunks/LikeC4FileSystem.mjs +2 -2
  5. package/dist/_chunks/{WithMCPServer.mjs → mcp.mjs} +5 -5
  6. package/dist/_chunks/module.d.mts +124 -30
  7. package/dist/_chunks/module.mjs +19 -19
  8. package/dist/_chunks/utils.mjs +1 -1
  9. package/dist/_chunks/workspace.mjs +1 -1
  10. package/dist/browser/index.d.mts +2 -2
  11. package/dist/browser/index.mjs +1 -1
  12. package/dist/browser/worker.mjs +1 -1
  13. package/dist/filesystem/index.d.mts +1 -1
  14. package/dist/filesystem/index.mjs +1 -1
  15. package/dist/index.d.mts +2 -2
  16. package/dist/index.mjs +1 -1
  17. package/dist/mcp/index.d.mts +1 -1
  18. package/dist/mcp/index.mjs +1 -1
  19. package/dist/module.d.mts +2 -2
  20. package/dist/module.mjs +1 -1
  21. package/package.json +23 -35
  22. package/bundled/package.json +0 -4
  23. package/dist/THIRD-PARTY-LICENSES.md +0 -178
  24. package/dist/_chunks/ConfigurableLayouter.mjs +0 -1
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +0 -1
  26. package/dist/_chunks/libs/eventemitter3.mjs +0 -1
  27. package/dist/_chunks/libs/fast-equals.mjs +0 -1
  28. package/dist/_chunks/libs/p-queue.mjs +0 -1
  29. package/dist/_chunks/libs/parse-ms.mjs +0 -1
  30. package/dist/_chunks/libs/picomatch.mjs +0 -1
  31. package/dist/_chunks/libs/pretty-ms.mjs +0 -1
  32. package/dist/_chunks/libs/remeda.mjs +0 -2
  33. package/dist/_chunks/libs/strip-indent.mjs +0 -1
  34. package/dist/_chunks/libs/ufo.mjs +0 -1
  35. package/dist/_chunks/rolldown-runtime.mjs +0 -1
  36. package/dist/bundled.d.mts +0 -27
  37. package/dist/bundled.mjs +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{a as t,i as n,n as r,r as i}from"./likec4lib.mjs";import{B as a,Bt as o,Ct as s,Er as c,I as ee,J as te,N as ne,Tr as l,Tt as re,U as ie,X as ae,at as oe,cn as u,en as se,ln as ce,mt as le,n as ue,nr as de,nt as d,o as fe,sn as pe,ut as me,yt as f}from"./utils.mjs";import{B as p,I as m,S as h,U as g,V as he,b as _,g as ge,i as _e,k as ve,n as ye,o as v,p as y,z as b}from"./libs/remeda.mjs";import{t as x}from"./libs/picomatch.mjs";import{a as S,d as C,i as w,o as T,r as E,s as D,t as O,u as k}from"./libs/ufo.mjs";import{AstUtils as A,DefaultAstNodeDescriptionProvider as j,DefaultIndexManager as M,DefaultLangiumDocuments as N,DefaultWorkspaceManager as P,Disposable as F,URI as I,UriUtils as L,isOperationCancelled as R,stream as z}from"langium";import{DefaultMap as B,compareNaturalHierarchically as V,invariant as H,isString as U,nonNullable as W,nonexhaustive as G}from"@likec4/core/utils";import{loggable as K,wrapError as be}from"@likec4/log";import{invariant as q}from"@likec4/core";import{LikeC4ProjectConfigOps as J}from"@likec4/config";import{URI as Y}from"vscode-uri";const X=Symbol.for(`idattr`),xe={writeId(e,t){return e[X]=t,e},readId(e){return e[X]}},Se={writeId(e,t){return _(t)?e[X]=void 0:e[X]=t,e},readId(e){return e[X]}};function isLikeC4LangiumDocument(e){return e?.textDocument.languageId===fe.languageId}function parseMarkdownAsString(e){return e?.markdown||e?.text}function parseAstPercent(e){let t=parseFloat(e);return isNaN(t)?100:he(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:G(e)}}function parseAstIconPositionValue({value:e}){switch(e){case`left`:case`right`:case`top`:case`bottom`:return e;default:G(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);ge(e)&&(n.color=e);break}case se(r):n.line=r.value;break;case ne(r):switch(r.key){case`head`:n.head=r.value;break;case`tail`:n.tail=r.value;break;default:G(r)}break;default:G(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:G(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:G(e)}}function getViewRulePredicateContainer(e){return A.getContainerOfType(e,e=>de(e)||ae(e)||oe(e))}const _isModel=e=>pe(e)||me(e)||re(e)||f(e)||d(e)||le(e),_isDeployment=e=>u(e)||te(e)||ie(e)||s(e)||a(e);function isFqnRefInsideGlobals(e){for(;;){if(_isDeployment(e)||_isModel(e))return!1;if(o(e)||ce(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 Ce={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 j{constructor(e){super(e),this.services=e}createDescription(e,t,n){n??=A.getDocument(e);let r=super.createDescription(e,t,n);return i(n.uri)||(n.likec4ProjectId??=this.services.shared.workspace.ProjectsManager.ownerProjectId(n),r.likec4ProjectId=n.likec4ProjectId),r}},IndexManager=class extends M{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 z(this.symbolIndex.keys()).filter(t=>n&&!n.has(t)?!1:r.isIncluded(e,t)).flatMap(e=>this.getFileDescriptions(e,t))}};const we=V(`/`),ensureOrder=(e,t)=>we(e.uri.path,t.uri.path),isLikeC4UserDocument=e=>isLikeC4LangiumDocument(e)&&n(e);var LangiumDocuments=class extends N{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 z(this.documentMap.values()).filter(e=>isLikeC4UserDocument(e)&&!this.projectsManager.isExcluded(e))}get all(){return z(this.documentMap.values()).map(e=>(isLikeC4UserDocument(e)&&(e.likec4ProjectId=this.projectsManager.ownerProjectId(e)),e))}projectDocuments(e){let t=this.services.workspace.ProjectsManager;return z(this.documentMap.values()).filter(n=>isLikeC4UserDocument(n)&&t.isIncluded(e,n)?(n.likec4ProjectId=e,!0):!1)}groupedByProject(){let e=this.services.workspace.ProjectsManager;return p(this.userDocuments.toArray(),y(t=>(t.likec4ProjectId=e.ownerProjectId(t),t)),ve(v(`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}},Z=e(x(),1);const Q=c.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`?E(e)?e:I.file(e).toString():e.toString()}const Te=V(`/`,!0),compareUri=(e,t)=>Te(C(e.path),C(t.path));function isParentFolderFor(e){return t=>e.startsWith(U(t)?t:t.folder)}function _overlaps(e,t){let n=U(e)?e:e.folder,r=U(t)?t:t.folder;return n.startsWith(r)||r.startsWith(n)}function overlaps(...e){return g(_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?.(k(t))??!1}function includes(...e){return g(_includes,e)}function excludes(...e){return g(_excludes,e)}function ProjectFolder(e){return e=normalizeUri(e),D(e)}const $={id:`default`,config:{name:`default`,exclude:[`**/node_modules/**`]},exclude:(0,Z.default)(`**/node_modules/**`,{dot:!0}),includeConfig:{paths:[],maxDepth:3,fileThreshold:30}};function isExcludedByDefault(e){return $.exclude(k(e))}function parseRegisterOptions(e){if(`configUri`in e){H(!h(e.configUri),`configUri is emptyish`);let t=I.isUri(e.configUri)?e.configUri:I.parse(normalizeUri(e.configUri)),n=ProjectFolder(L.dirname(t));return{configUri:t,folder:n,folderUri:I.parse(n)}}H(!h(e.folderUri),`folderUri is emptyish`);let t=ProjectFolder(e.folderUri),n=I.parse(t);return{configUri:L.joinPath(n,`likec4.config.json`),folder:t,folderUri:n}}var Ee=class ProjectsManager{static DefaultProjectId=$.id;#e=[];#t=void 0;#n=void 0;#r=[];#i=new B(e=>{if(e===ProjectsManager.DefaultProjectId){let t=this.getWorkspaceFolder(),n=L.joinPath(t,`.likec4rc`),r=ProjectFolder(t);return{id:e,config:$.config,folder:r,folderUri:I.parse(r),configUri:n,exclude:$.exclude,includeConfig:$.includeConfig}}return W(this.#r.find(t=>t.id===e),`Project ${e} not found`)});#a=new B(e=>{let t=normalizeUri(e),n=this.#o.get(t);return n?excludes(n,t)?!this.#r.some(includes(t)):!1:isExcludedByDefault(t)});#o=new B(e=>{let t=isParentFolderFor(e);return this.#r.find(t)??this.#r.find(includes(e))??null});constructor(e){this.services=e,Q.debug`created`}get defaultProjectId(){if(this.#t)return this.#t;if(!(this.#r.length>1))return b(this.#r,1)?this.#r[0].id:ProjectsManager.DefaultProjectId}set defaultProjectId(e){if(e!==this.#t){if(this.#n=void 0,!e||e===ProjectsManager.DefaultProjectId){Q.debug`reset default project ID`,this.#t=void 0;return}H(this.#r.find(t=>t.id===e),`Project "${e}" not found`),Q.debug`set default project ID to ${e}`,this.#t=e}}get default(){if(!this.#n){let e=this.defaultProjectId??ProjectsManager.DefaultProjectId;this.#n=this.#i.get(e)}return this.#n}get all(){if(b(this.#r,1)){let e=[...y(this.#r,v(`id`)),$.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[$.id]}getProject(e){let t=typeof e==`string`?e:e.likec4ProjectId||this.ownerProjectId(e);return this.#i.get(t)}findOverlaped(e){let t=overlaps(ProjectFolder(e));return this.#r.filter(e=>t(e)||!!e.includePaths&&!!m(e.includePaths,t))}ensureProjectId(e){return e===ProjectsManager.DefaultProjectId?this.defaultProjectId??ProjectsManager.DefaultProjectId:e?(H(this.#r.some(t=>e===t.id),`Project ID ${e} is not registered`),e):W(this.defaultProjectId,()=>`Specify exact project, known: [${y(this.#r,v(`id`)).join(`, `)}]`)}ensureProject(e){return e=this.ensureProjectId(e),this.getProject(e)}hasMultipleProjects(){return this.#r.length>1}isExcluded(...e){let t=e.length===1?e[0]:e[1];return isLangiumDocument(t)&&i(t)?!0:e.length===1?this.#a.get(normalizeUri(t)):excludes(this.#i.get(e[0]),normalizeUri(t))}isIncluded(e,t){let n=normalizeUri(t);return b(this.#r,1)?e===ProjectsManager.DefaultProjectId?!this.#o.get(n)&&!isExcludedByDefault(n):includes(this.#i.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: ${$.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(!R(t))throw be(t,`Failed to register project config ${e.fsPath}:\n`);return Promise.reject(t)}}async registerProject(e,t){let n=J.validate(e.config),{configUri:r,folder:i,folderUri:a}=parseRegisterOptions(e),o=J.normalizeInclude(n.include),s=this.#r.find(e=>e.folder===i);return s?(s.config.name!==n.name&&(s.id=this.uniqueProjectId(n.name),Q.info`re-register ${s.id}`),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.#r=p([...this.#r,s],_e((e,t)=>compareUri(e.folderUri,t.folderUri))),Q.info`register ${s.id}`),this.updateIncludesExcludes(s),this.resetCaches(),this.#s?s:(this.notifyListeners(),await this.rebuildProject(s.id,t).catch(e=>R(e)?Promise.reject(e):(Q.warn(`Failed to rebuild project {projectId} after config change`,{projectId:s.id,error:e}),Promise.resolve())),s)}ownerProjectId(e){return this.#o.get(normalizeUri(e))?.id??this.#t??ProjectsManager.DefaultProjectId}#s=null;async reloadProjects(e){return this.#s?(Q.debug`reload projects is already in progress, waiting`,await this.#s.catch(()=>{})):(Q.debug`schedule reload projects`,this.#s=Promise.resolve().then(()=>this._reloadProjects(e)).catch(e=>(R(e)||Q.warn(`Failed to reload projects`,{error:e}),Promise.reject(e))).finally(()=>{this.#s=null,this.notifyListeners()}),await this.#s)}async _reloadProjects(e){let t=this.services.workspace.WorkspaceManager.workspaceFolders;if(!t||t.length===0){Q.warn(`Failed to reloadProjects, no workspace folders found`);return}Q.debug`start reload projects`;let n=[];for(let e of t){let t=I.parse(e.uri);Q.debug`scan projects in ${t.fsPath}`;try{let e=await this.services.workspace.FileSystemProvider.scanProjectFiles(t);for(let r of e)Q.debug`found config ${L.relative(t,r.uri)}`,n.push(r.uri)}catch(e){Q.warn(`Failed on scanProjectFiles in {folder}`,{folder:t.fsPath,error:e})}}if(n.length===0){if(this.#r.length===0){Q.warning(`No config files found`);return}Q.warning(`No config files found, but {count} projects were registered before`,{count:this.#r.length})}n.sort(compareUri);let r=new Map(this.#r.map(e=>[e.configUri.toString(),e]));this.#r=[],this.#i.clear();for(let e of n)try{await this.registerConfigFile(e)}catch(t){Q.warn(K(t));let n=r.get(e.toString());n&&(Q.debug`Update failed, restore project ${n.id}`,await this.registerProject(n))}this.resetCaches(),this.notifyListeners(),await this.services.workspace.WorkspaceManager.rebuildAll(e)}uniqueProjectId(e){let t=new Set(y(this.#r,v(`id`))),n=e;if(!t.has(n))return n;Q.warn`Project "${e}" already exists, generating unique ID`;let r=1;for(;t.has(n);)n=`${e}-${r++}`;return n}resetCaches(){Q.trace(`resetCaches`),this.#n=void 0,this.#t&&!this.#r.some(e=>e.id===this.#t)&&(this.#t=void 0),this.#i.clear(),this.#o.clear(),this.#a.clear()}async rebuildProject(e,t){let n=this.#r.find(t=>t.id===e);if(!n)return e===ProjectsManager.DefaultProjectId?Q.info`Rebuilding all documents `:Q.warn`Project ${e} not found, rebuilding all`,await this.services.workspace.WorkspaceManager.rebuildAll(t);let r=Q.getChild(n.id),i=this.services.workspace.LangiumDocuments.resetProjectIds().filter(e=>includes(n,normalizeUri(e)));i.length!==0&&(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.#r)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),F.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 Q.warn(`Failed to get workspace URI, using default folder`,{error:e}),I.file(`/`)}}notifyListeners(){for(let e of this.#e)try{e()}catch(e){Q.warn(K(e))}}updateIncludesExcludes(e){let t=e.config;switch(!0){case _(t.exclude):e.exclude=$.exclude;break;case t.exclude&&b(t.exclude,1):e.exclude=(0,Z.default)(y(t.exclude,t=>(!w(t)&&!t.startsWith(`**`)&&(t=T(`**`,t)),O(S(e.folderUri.path,t)))),{contains:!0,dot:!0});break;default:delete e.exclude}let n=e.includeConfig.paths;if(!b(n,1))return delete e.includePaths,e;e.includePaths=y(n,t=>{let n=L.resolvePath(e.folderUri,t);return{uri:n,folder:ProjectFolder(n)}}),Q.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.#r)n.id!==e.id&&(overlaps(t,n)&&Q.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)&&Q.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}},LikeC4WorkspaceManager=class extends P{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){l(e)}let n=this.services.workspace.ProjectsManager;for(let e of t)try{await n.registerConfigFile(e.uri)}catch(e){l(e)}return await super.performStartup(e)}async loadAdditionalDocuments(e,n){n(this.documentFactory.fromString(t,Y.parse(r)));let i=this.services.workspace.ProjectsManager.getAllIncludePaths(),a=0,o=[];for(let{projectId:e,includePath:t,includeConfig:n}of i)try{c.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&&c.debug`loaded ${r.length} files from include path ${t.fsPath}`}catch(e){c.warn(`Failed to scan include path ${t.fsPath}`,{error:e})}for(let e of ye(o,e=>e.uri.path))try{n(await this.langiumDocuments.getOrCreateDocument(e.uri)),a++}catch(t){c.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?c.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.`):c.info`loaded ${a} total files from ${i.length} include paths`}}includeEntry(e,t,n){let r=L.basename(t.uri);return t.isDirectory?!ue(r):t.isFile?(n.fileExtensions.includes(L.extname(t.uri))||n.fileNames.includes(r))&&!this.services.workspace.ProjectsManager.isExcluded(t.uri):!1}workspace(){return this.folders&&b(this.folders,1)?this.folders[0]:null}async rebuildAll(e){let t=this.services.workspace.LangiumDocuments.resetProjectIds();c.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 q(e,`Workspace not initialized`),Y.parse(e.uri)}get workspaceURL(){let e=this.workspace();return q(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),F.create(()=>{this.#e=this.#e.filter(t=>t!==e)})}};export{toRelationshipStyle as C,toColor as S,parseAstPercent as _,AstNodeDescriptionProvider as a,toAstViewLayoutDirection as b,Se as c,isFqnRefInsideDeployment as d,isFqnRefInsideGlobals as f,parseAstOpacityProperty as g,parseAstIconPositionValue as h,IndexManager as i,xe as l,isLikeC4LangiumDocument as m,Ee as n,Ce as o,isFqnRefInsideModel as p,LangiumDocuments as r,NoopLikeC4MCPServer as s,LikeC4WorkspaceManager as t,getViewRulePredicateContainer as u,parseAstSizeValue as v,toAutoLayout as x,parseMarkdownAsString as y};
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};
@@ -1,4 +1,4 @@
1
- import { B as ProjectsManager, D as NoFileSystem, F as LikeC4ManualLayouts, I as LikeC4ManualLayoutsModuleContext, M as FileSystemProvider, N as FileSystemWatcher, O as NoFileSystemWatcher, P as FileSystemWatcherModuleContext, R as Project, _ as LikeC4ModelBuilder, a as createLanguageServices, b as LangiumDocuments, c as LikeC4LanguageServices, f as LikeC4Views, g as ViewLocateResult, h as LikeC4ModelLocator, i as LikeC4SharedServices, j as FileSystemModuleContext, k as NoLikeC4ManualLayouts, l as DocumentParser, m as NoMCPServer, n as LikeC4AddedServices, r as LikeC4Services, t as LanguageServicesContext, u as LikeC4ModelParser, v as FqnIndex, y as LikeC4WorkspaceManager, z as ProjectData } from "../_chunks/module.mjs";
1
+ import { B as FileSystemProvider, C as LikeC4ModelLocator, D as LikeC4WorkspaceManager, E as FqnIndex, F as NoFileSystem, H as FileSystemWatcherModuleContext, I as NoFileSystemWatcher, J as ProjectsManager, K as Project, L as NoLikeC4ManualLayouts, O as LangiumDocuments, S as NoMCPServer, T as LikeC4ModelBuilder, U as LikeC4ManualLayouts, V as FileSystemWatcher, W as LikeC4ManualLayoutsModuleContext, _ as LikeC4ViewsModuleContext, b as LikeC4Views, d as LikeC4LanguageServices, f as DocumentParser, n as LikeC4AddedServices, o as LikeC4SharedServices, p as LikeC4ModelParser, q as ProjectData, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as FormatOptions, w as ViewLocateResult, y as WithWasmGraphviz, z as FileSystemModuleContext } from "../_chunks/module.mjs";
2
2
  import "../_chunks/protocol.mjs";
3
3
 
4
4
  //#region src/browser/index.d.ts
@@ -12,4 +12,4 @@ declare function startLanguageServer(port: MessagePort | DedicatedWorkerGlobalSc
12
12
  likec4: LikeC4Services;
13
13
  };
14
14
  //#endregion
15
- 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, FormatOptions, 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 };
@@ -1 +1 @@
1
- import"../_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/remeda.mjs";import{o as r}from"../_chunks/workspace.mjs";import{t as i}from"../_chunks/module.mjs";import"../_chunks/libs/picomatch.mjs";import"../_chunks/libs/ufo.mjs";import"../_chunks/libs/parse-ms.mjs";import"../_chunks/libs/pretty-ms.mjs";import"../_chunks/libs/fast-equals.mjs";import"../_chunks/libs/@msgpack/msgpack.mjs";import"../_chunks/libs/strip-indent.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};
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};
@@ -1 +1 @@
1
- import"../_chunks/likec4lib.mjs";import"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/remeda.mjs";import"../_chunks/workspace.mjs";import"../_chunks/module.mjs";import"../_chunks/libs/picomatch.mjs";import"../_chunks/libs/ufo.mjs";import"../_chunks/libs/parse-ms.mjs";import"../_chunks/libs/pretty-ms.mjs";import"../_chunks/libs/fast-equals.mjs";import"../_chunks/libs/@msgpack/msgpack.mjs";import"../_chunks/libs/strip-indent.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
+ 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,3 +1,3 @@
1
- import { A as FileNode, D as NoFileSystem, E as WithFileSystem, F as LikeC4ManualLayouts, I as LikeC4ManualLayoutsModuleContext, L as ManualLayoutsSnapshot, M as FileSystemProvider, N as FileSystemWatcher, O as NoFileSystemWatcher, P as FileSystemWatcherModuleContext, T as WithChokidarWatcher, j as FileSystemModuleContext, k as NoLikeC4ManualLayouts, w as WithLikeC4ManualLayouts } from "../_chunks/module.mjs";
1
+ import { B as FileSystemProvider, F as NoFileSystem, G as ManualLayoutsSnapshot, H as FileSystemWatcherModuleContext, I as NoFileSystemWatcher, L as NoLikeC4ManualLayouts, M as WithLikeC4ManualLayouts, N as WithChokidarWatcher, P as WithFileSystem, R as FileNode, U as LikeC4ManualLayouts, V as FileSystemWatcher, W as LikeC4ManualLayoutsModuleContext, z as FileSystemModuleContext } from "../_chunks/module.mjs";
2
2
  import "../_chunks/protocol.mjs";
3
3
  export { FileNode, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, LikeC4ManualLayouts, LikeC4ManualLayoutsModuleContext, ManualLayoutsSnapshot, NoFileSystem, NoFileSystemWatcher, NoLikeC4ManualLayouts, WithChokidarWatcher, WithFileSystem, WithLikeC4ManualLayouts };
@@ -1 +1 @@
1
- import"../_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"../_chunks/noop.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/eventemitter3.mjs";import"../_chunks/libs/p-queue.mjs";import"../_chunks/libs/remeda.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};
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,3 +1,3 @@
1
- import { B as ProjectsManager, D as NoFileSystem, E as WithFileSystem, F as LikeC4ManualLayouts, I as LikeC4ManualLayoutsModuleContext, M as FileSystemProvider, N as FileSystemWatcher, O as NoFileSystemWatcher, P as FileSystemWatcherModuleContext, R as Project, _ as LikeC4ModelBuilder, a as createLanguageServices, b as LangiumDocuments, c as LikeC4LanguageServices, d as startLanguageServer, f as LikeC4Views, g as ViewLocateResult, h as LikeC4ModelLocator, i as LikeC4SharedServices, j as FileSystemModuleContext, k as NoLikeC4ManualLayouts, l as DocumentParser, m as NoMCPServer, n as LikeC4AddedServices, p as WithMCPServer, r as LikeC4Services, t as LanguageServicesContext, u as LikeC4ModelParser, v as FqnIndex, w as WithLikeC4ManualLayouts, y as LikeC4WorkspaceManager, z as ProjectData } from "./_chunks/module.mjs";
1
+ import { B as FileSystemProvider, C as LikeC4ModelLocator, D as LikeC4WorkspaceManager, E as FqnIndex, F as NoFileSystem, H as FileSystemWatcherModuleContext, I as NoFileSystemWatcher, J as ProjectsManager, K as Project, L as NoLikeC4ManualLayouts, M as WithLikeC4ManualLayouts, O as LangiumDocuments, P as WithFileSystem, S as NoMCPServer, T as LikeC4ModelBuilder, U as LikeC4ManualLayouts, V as FileSystemWatcher, W as LikeC4ManualLayoutsModuleContext, _ as LikeC4ViewsModuleContext, b as LikeC4Views, d as LikeC4LanguageServices, f as DocumentParser, g as configureLanguageServerLogger, h as ConfigureLanguageServerLoggerOptions, m as startLanguageServer, n as LikeC4AddedServices, o as LikeC4SharedServices, p as LikeC4ModelParser, q as ProjectData, r as LikeC4Services, s as createLanguageServices, t as LanguageServicesContext, u as FormatOptions, w as ViewLocateResult, x as WithMCPServer, y as WithWasmGraphviz, z as FileSystemModuleContext } from "./_chunks/module.mjs";
2
2
  import "./_chunks/protocol.mjs";
3
- 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 };
3
+ export { ConfigureLanguageServerLoggerOptions, DocumentParser, FileSystemModuleContext, FileSystemProvider, FileSystemWatcher, FileSystemWatcherModuleContext, FormatOptions, 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"./_chunks/likec4lib.mjs";import{n as e,r as t,t as n}from"./_chunks/noop.mjs";import{Er as r,wr as i}from"./_chunks/utils.mjs";import"./_chunks/libs/eventemitter3.mjs";import"./_chunks/libs/p-queue.mjs";import"./_chunks/libs/remeda.mjs";import{r as a,t as o}from"./_chunks/LikeC4FileSystem.mjs";import{o as s}from"./_chunks/workspace.mjs";import{t as c}from"./_chunks/module.mjs";import"./_chunks/libs/picomatch.mjs";import"./_chunks/libs/ufo.mjs";import"./_chunks/libs/parse-ms.mjs";import"./_chunks/libs/pretty-ms.mjs";import"./_chunks/libs/fast-equals.mjs";import"./_chunks/libs/@msgpack/msgpack.mjs";import"./_chunks/libs/strip-indent.mjs";import"./_chunks/common-exports.mjs";import{t as l}from"./_chunks/WithMCPServer.mjs";import"./mcp/index.mjs";import{t as u}from"./_chunks/ConfigurableLayouter.mjs";import{configureLogger as d,getConsoleSink as f,getConsoleStderrSink as p,getTextFormatter as m}from"@likec4/log";import{startLanguageServer as h}from"langium/lsp";import{defu as g}from"defu";import{isDevelopment as _}from"std-env";function startLanguageServer(e){let t=e?.connection,n=g(e,{enableWatcher:!0,enableMCP:`sse`,enableTelemetry:!!t,enableManualLayouts:!0}),s=!!t&&n.enableTelemetry&&!_;d({sinks:{console:n.enableMCP===`stdio`||t?p({formatter:m()}):f({formatter:m()}),...s&&{telemetry:i(t)}},loggers:[{category:[`likec4`],sinks:[`console`,...s?[`telemetry`]:[]],lowestLevel:_?`trace`:`debug`}]}),t?r.info(`Starting LikeC4 language server`):r.warn(`Starting LikeC4 language server (headless - no LSP connection)`);let v=c({...t&&{connection:t},...o(n.enableWatcher),...!!n.enableMCP&&l(n.enableMCP),...n.enableManualLayouts&&a},t?{likec4:{...u.likec4}}:void 0);return h(v.shared),v}export{n as NoFileSystem,e as NoFileSystemWatcher,t as NoLikeC4ManualLayouts,s as NoMCPServer,o as WithFileSystem,a as WithLikeC4ManualLayouts,l as WithMCPServer,c as createLanguageServices,startLanguageServer};
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};
@@ -1,3 +1,3 @@
1
- import { C as LikeC4MCPServerModuleContext, S as LikeC4MCPServerFactory, m as NoMCPServer, p as WithMCPServer, x as LikeC4MCPServer } from "../_chunks/module.mjs";
1
+ import { A as LikeC4MCPServerFactory, S as NoMCPServer, j as LikeC4MCPServerModuleContext, k as LikeC4MCPServer, x as WithMCPServer } from "../_chunks/module.mjs";
2
2
  import "../_chunks/protocol.mjs";
3
3
  export { LikeC4MCPServer, LikeC4MCPServerFactory, LikeC4MCPServerModuleContext, NoMCPServer, WithMCPServer };
@@ -1 +1 @@
1
- import"../_chunks/likec4lib.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/remeda.mjs";import{o as e}from"../_chunks/workspace.mjs";import"../_chunks/libs/picomatch.mjs";import"../_chunks/libs/ufo.mjs";import{t}from"../_chunks/WithMCPServer.mjs";export{e as NoMCPServer,t as WithMCPServer};
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,3 +1,3 @@
1
- import { D as NoFileSystem, a as createLanguageServices, i as LikeC4SharedServices, k as NoLikeC4ManualLayouts, m as NoMCPServer, n as LikeC4AddedServices, o as createLikeC4Module, r as LikeC4Services, s as createSharedServices, t as LanguageServicesContext } from "./_chunks/module.mjs";
1
+ import { F as NoFileSystem, L as NoLikeC4ManualLayouts, S as NoMCPServer, 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 WithGraphviz, y as WithWasmGraphviz } from "./_chunks/module.mjs";
2
2
  import "./_chunks/protocol.mjs";
3
- export { LanguageServicesContext, LikeC4AddedServices, LikeC4Services, LikeC4SharedServices, NoFileSystem, NoLikeC4ManualLayouts, NoMCPServer, createLanguageServices, createLikeC4Module, createSharedServices };
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"./_chunks/likec4lib.mjs";import{r as e,t}from"./_chunks/noop.mjs";import"./_chunks/utils.mjs";import"./_chunks/libs/remeda.mjs";import{o as n}from"./_chunks/workspace.mjs";import{n as r,r as i,t as a}from"./_chunks/module.mjs";import"./_chunks/libs/picomatch.mjs";import"./_chunks/libs/ufo.mjs";import"./_chunks/libs/parse-ms.mjs";import"./_chunks/libs/pretty-ms.mjs";import"./_chunks/libs/fast-equals.mjs";import"./_chunks/libs/@msgpack/msgpack.mjs";import"./_chunks/libs/strip-indent.mjs";export{t as NoFileSystem,e as NoLikeC4ManualLayouts,n as NoMCPServer,a as createLanguageServices,r as createLikeC4Module,i as createSharedServices};
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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.50.0",
4
+ "version": "1.52.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/language-server"
22
22
  },
23
23
  "engines": {
24
- "node": ">=22.22.0"
24
+ "node": ">=22.22.1"
25
25
  },
26
26
  "type": "module",
27
27
  "sideEffects": false,
@@ -53,14 +53,6 @@
53
53
  "default": "./dist/index.mjs"
54
54
  }
55
55
  },
56
- "./bundled": {
57
- "sources": "./src/bundled.ts",
58
- "default": {
59
- "types": "./dist/bundled.d.mts",
60
- "import": "./dist/bundled.mjs",
61
- "default": "./dist/bundled.mjs"
62
- }
63
- },
64
56
  "./likec4lib": {
65
57
  "sources": "./src/likec4lib.ts",
66
58
  "default": {
@@ -124,35 +116,42 @@
124
116
  "access": "public"
125
117
  },
126
118
  "dependencies": {
127
- "@hono/mcp": "^0.2.3",
128
- "@hono/node-server": "^1.19.9",
129
- "hono": "^4.11.10",
119
+ "@hono/mcp": "^0.2.4",
120
+ "@hono/node-server": "^1.19.10",
130
121
  "@hpcc-js/wasm-graphviz": "1.21.0",
131
- "@smithy/util-base64": "^4.3.0",
132
122
  "chokidar": "^5.0.0",
133
123
  "defu": "^6.1.4",
124
+ "fast-equals": "^6.0.0",
134
125
  "fdir": "6.4.0",
126
+ "hono": "^4.12.4",
135
127
  "immer": "^11.1.4",
128
+ "indent-string": "^5.0.0",
136
129
  "json5": "^2.2.3",
137
130
  "langium": "3.5.0",
138
131
  "nano-spawn": "^2.0.0",
132
+ "p-queue": "8.1.1",
133
+ "picomatch": "^4.0.3",
134
+ "pretty-ms": "^9.3.0",
135
+ "remeda": "^2.33.6",
139
136
  "std-env": "^3.10.0",
137
+ "strip-indent": "^4.1.1",
140
138
  "type-fest": "^4.41.0",
139
+ "ufo": "1.6.3",
141
140
  "vscode-jsonrpc": "8.2.1",
142
- "vscode-languageserver": "9.0.1",
143
141
  "vscode-languageserver-protocol": "3.17.5",
144
142
  "vscode-languageserver-textdocument": "1.0.11",
145
143
  "vscode-languageserver-types": "3.17.5",
144
+ "vscode-languageserver": "9.0.1",
146
145
  "vscode-uri": "3.1.0",
147
146
  "which": "^5.0.0",
148
147
  "zod": "^3.25.76",
149
- "@likec4/config": "1.50.0",
150
- "@likec4/log": "1.50.0",
151
- "@likec4/layouts": "1.50.0",
152
- "@likec4/core": "1.50.0"
148
+ "@likec4/config": "1.52.0",
149
+ "@likec4/core": "1.52.0",
150
+ "@likec4/layouts": "1.52.0",
151
+ "@likec4/log": "1.52.0"
153
152
  },
154
153
  "peerDependencies": {
155
- "@modelcontextprotocol/sdk": "^1.27.0",
154
+ "@modelcontextprotocol/sdk": "^1.27.1",
156
155
  "bundle-require": "^5.1.0",
157
156
  "esbuild": "0.27.3"
158
157
  },
@@ -168,8 +167,7 @@
168
167
  }
169
168
  },
170
169
  "devDependencies": {
171
- "@modelcontextprotocol/sdk": "^1.27.0",
172
- "@msgpack/msgpack": "^3.1.2",
170
+ "@modelcontextprotocol/sdk": "^1.27.1",
173
171
  "@types/natural-compare-lite": "^1.4.2",
174
172
  "@types/node": "~22.19.11",
175
173
  "@types/picomatch": "^4.0.2",
@@ -177,26 +175,16 @@
177
175
  "@types/which": "^3.0.4",
178
176
  "bundle-require": "^5.1.0",
179
177
  "esbuild": "0.27.3",
180
- "fast-equals": "^6.0.0",
181
- "indent-string": "^5.0.0",
182
178
  "langium-cli": "3.5.2",
183
179
  "obuild": "^0.4.31",
184
180
  "oxlint": "1.43.0",
185
- "p-debounce": "5.1.0",
186
- "p-queue": "8.1.1",
187
- "p-timeout": "7.0.1",
188
- "picomatch": "^4.0.3",
189
- "pretty-ms": "^9.3.0",
190
- "remeda": "^2.33.5",
191
- "strip-indent": "^4.1.1",
192
181
  "tsx": "4.21.0",
193
- "turbo": "2.8.10",
182
+ "turbo": "2.8.13",
194
183
  "typescript": "5.9.3",
195
- "ufo": "1.6.3",
196
184
  "vitest": "4.0.18",
197
185
  "@likec4/devops": "1.42.0",
198
- "@likec4/icons": "1.46.4",
199
- "@likec4/tsconfig": "1.50.0"
186
+ "@likec4/tsconfig": "1.52.0",
187
+ "@likec4/icons": "1.46.4"
200
188
  },
201
189
  "scripts": {
202
190
  "typecheck": "tsc -b --verbose",
@@ -1,4 +0,0 @@
1
- {
2
- "types": "../dist/bundled.d.mts",
3
- "module": "../dist/bundled.mjs"
4
- }
@@ -1,178 +0,0 @@
1
- # Licenses of Bundled Dependencies
2
-
3
- The published artifact additionally contains code with the following licenses:
4
- ISC, MIT
5
-
6
- # Bundled Dependencies
7
-
8
- ## @msgpack/msgpack
9
-
10
- License: ISC
11
- By: The MessagePack community
12
- Repository: https://github.com/msgpack/msgpack-javascript
13
-
14
- > Copyright 2019 The MessagePack Community.
15
- >
16
- > Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
17
- >
18
- > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
-
20
- ---------------------------------------
21
-
22
- ## eventemitter3
23
-
24
- License: MIT
25
- By: Arnout Kazemier
26
- Repository: https://github.com/primus/eventemitter3
27
-
28
- > The MIT License (MIT)
29
- >
30
- > Copyright (c) 2014 Arnout Kazemier
31
- >
32
- > Permission is hereby granted, free of charge, to any person obtaining a copy
33
- > of this software and associated documentation files (the "Software"), to deal
34
- > in the Software without restriction, including without limitation the rights
35
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
- > copies of the Software, and to permit persons to whom the Software is
37
- > furnished to do so, subject to the following conditions:
38
- >
39
- > The above copyright notice and this permission notice shall be included in all
40
- > copies or substantial portions of the Software.
41
- >
42
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
- > SOFTWARE.
49
-
50
- ---------------------------------------
51
-
52
- ## fast-equals
53
-
54
- License: MIT
55
- By: Tony Quetano
56
- Repository: https://github.com/planttheidea/fast-equals
57
-
58
- > MIT License
59
- >
60
- > Copyright (c) 2025 Tony Quetano
61
- >
62
- > Permission is hereby granted, free of charge, to any person obtaining a copy
63
- > of this software and associated documentation files (the "Software"), to deal
64
- > in the Software without restriction, including without limitation the rights
65
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
- > copies of the Software, and to permit persons to whom the Software is
67
- > furnished to do so, subject to the following conditions:
68
- >
69
- > The above copyright notice and this permission notice shall be included in all
70
- > copies or substantial portions of the Software.
71
- >
72
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
78
- > SOFTWARE.
79
-
80
- ---------------------------------------
81
-
82
- ## p-queue, p-timeout, parse-ms, pretty-ms, strip-indent
83
-
84
- License: MIT
85
- Repository: https://github.com/sindresorhus/p-queue
86
-
87
- License: MIT
88
- By: Sindre Sorhus
89
- Repository: https://github.com/sindresorhus/p-timeout
90
-
91
- License: MIT
92
- By: Sindre Sorhus
93
- Repository: https://github.com/sindresorhus/parse-ms
94
-
95
- License: MIT
96
- By: Sindre Sorhus
97
- Repository: https://github.com/sindresorhus/pretty-ms
98
-
99
- License: MIT
100
- By: Sindre Sorhus
101
- Repository: https://github.com/sindresorhus/strip-indent
102
-
103
- > MIT License
104
- >
105
- > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
106
- >
107
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
108
- >
109
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
110
- >
111
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
112
-
113
- ---------------------------------------
114
-
115
- ## picomatch
116
-
117
- License: MIT
118
- By: Jon Schlinkert
119
- Repository: https://github.com/micromatch/picomatch
120
-
121
- > The MIT License (MIT)
122
- >
123
- > Copyright (c) 2017-present, Jon Schlinkert.
124
- >
125
- > Permission is hereby granted, free of charge, to any person obtaining a copy
126
- > of this software and associated documentation files (the "Software"), to deal
127
- > in the Software without restriction, including without limitation the rights
128
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
129
- > copies of the Software, and to permit persons to whom the Software is
130
- > furnished to do so, subject to the following conditions:
131
- >
132
- > The above copyright notice and this permission notice shall be included in
133
- > all copies or substantial portions of the Software.
134
- >
135
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
136
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
137
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
138
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
139
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
140
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
141
- > THE SOFTWARE.
142
-
143
- ---------------------------------------
144
-
145
- ## remeda
146
-
147
- License: MIT
148
- By: Łukasz Sentkiewicz
149
- Repository: https://github.com/remeda/remeda
150
-
151
- ---------------------------------------
152
-
153
- ## ufo
154
-
155
- License: MIT
156
- Repository: https://github.com/unjs/ufo
157
-
158
- > MIT License
159
- >
160
- > Copyright (c) Pooya Parsa <pooya@pi0.io>
161
- >
162
- > Permission is hereby granted, free of charge, to any person obtaining a copy
163
- > of this software and associated documentation files (the "Software"), to deal
164
- > in the Software without restriction, including without limitation the rights
165
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
166
- > copies of the Software, and to permit persons to whom the Software is
167
- > furnished to do so, subject to the following conditions:
168
- >
169
- > The above copyright notice and this permission notice shall be included in all
170
- > copies or substantial portions of the Software.
171
- >
172
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
174
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
175
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
176
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
177
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
178
- > SOFTWARE.
@@ -1 +0,0 @@
1
- import{Er as e}from"./utils.mjs";import{C as t}from"./libs/remeda.mjs";import{GraphvizWasmAdapter as n,QueueGraphvizLayoter as r}from"@likec4/layouts";import{GraphvizBinaryAdapter as i}from"@likec4/layouts/graphviz/binary";import a from"which";function graphvizBinPath(){try{return a.sync(`dot`)}catch(t){return e.error(`Error checking for native Graphviz:`,{error:t}),null}}const o={likec4:{Layouter(a){e.debug(`Creating ConfigurableLayouter`);let o=new r;return a.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate(r=>{if(e.debug(`Configuration update: {update}`,{update:r}),r.section!==a.LanguageMetaData.languageId){e.debug(`Ignoring configuration update as it is not for ${a.LanguageMetaData.languageId}`);return}try{let{mode:s,path:c}=r.configuration.graphviz??{mode:`wasm`,path:``};if(s!==`wasm`){let n=t(c)?graphvizBinPath():c;if(!t(n)){o.changePort(new i(n)),e.info`use graphviz binary: ${n}`;return}e.warn(`No Graphviz binaries found on PATH, use graphviz wasm`),a.shared.lsp.Connection?.window.showWarningMessage(`No Graphviz binaries found on PATH, set path to binaries in settings.`)}o.changePort(new n),e.info(`use graphviz wasm`)}catch(t){e.error(`Failed to update configuration`,{error:t})}}),o}}};export{o as t};
@@ -1 +0,0 @@
1
- new TextEncoder;function utf8DecodeJs(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=4096&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const e=new TextDecoder;function utf8DecodeTD(t,n,r){let i=t.subarray(n,n+r);return e.decode(i)}function utf8Decode(e,t,n){return n>200?utf8DecodeTD(e,t,n):utf8DecodeJs(e,t,n)}var ExtData=class{constructor(e,t){this.type=e,this.data=t}},t=class DecodeError extends Error{constructor(e){super(e);let t=Object.create(DecodeError.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,`name`,{configurable:!0,enumerable:!1,value:DecodeError.name})}};const n=4294967295;function setInt64(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function getInt64(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function getUint64(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}function encodeTimeSpecToTimestamp({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=17179869183)if(t===0&&e<=4294967295){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),setInt64(r,4,e),n}}function encodeDateToTimeSpec(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function encodeTimestampExtension(e){return e instanceof Date?encodeTimeSpecToTimestamp(encodeDateToTimeSpec(e)):null}function decodeTimestampToTimeSpec(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:n.getUint32(0),nsec:0};case 8:{let e=n.getUint32(0),t=n.getUint32(4);return{sec:(e&3)*4294967296+t,nsec:e>>>2}}case 12:return{sec:getInt64(n,4),nsec:n.getUint32(0)};default:throw new t(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function decodeTimestampExtension(e){let t=decodeTimestampToTimeSpec(e);return new Date(t.sec*1e3+t.nsec/1e6)}const r={type:-1,encode:encodeTimestampExtension,decode:decodeTimestampExtension};var ExtensionCodec=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(r)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ExtData(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ExtData(n,i)}}return e instanceof ExtData?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new ExtData(t,e)}};ExtensionCodec.defaultCodec=new ExtensionCodec;function isArrayBufferLike(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function ensureUint8Array(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):isArrayBufferLike(e)?new Uint8Array(e):Uint8Array.from(e)}function prettyByte(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var CachedKeyDecoder=class{constructor(e=16,t=16){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let i=utf8DecodeJs(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}};const i=`array`,a=`map_key`,o=`map_value`,mapKeyConverter=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new t(`The type of key must be string or number but `+typeof e)};var StackPool=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=i,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=a,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===i){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===a||e.type===o){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}};const s=new DataView(new ArrayBuffer(0)),c=new Uint8Array(s.buffer);try{s.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}const l=RangeError(`Insufficient data`),u=new CachedKeyDecoder;var d=class Decoder{constructor(e){this.totalPos=0,this.pos=0,this.view=s,this.bytes=c,this.headByte=-1,this.stack=new StackPool,this.entered=!1,this.extensionCodec=e?.extensionCodec??ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??n,this.maxBinLength=e?.maxBinLength??n,this.maxArrayLength=e?.maxArrayLength??n,this.maxMapLength=e?.maxMapLength??n,this.maxExtLength=e?.maxExtLength??n,this.keyDecoder=e?.keyDecoder===void 0?u:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??mapKeyConverter}clone(){return new Decoder({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=-1,this.stack.reset()}setBuffer(e){let t=ensureUint8Array(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===-1&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=ensureUint8Array(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${prettyByte(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),n;if(e>=224)n=e-256;else if(e<192)if(e<128)n=e;else if(e<144){let t=e-128;if(t!==0){this.pushMapState(t),this.complete();continue DECODE}else n={}}else if(e<160){let t=e-144;if(t!==0){this.pushArrayState(t),this.complete();continue DECODE}else n=[]}else{let t=e-160;n=this.decodeString(t,0)}else if(e===192)n=null;else if(e===194)n=!1;else if(e===195)n=!0;else if(e===202)n=this.readF32();else if(e===203)n=this.readF64();else if(e===204)n=this.readU8();else if(e===205)n=this.readU16();else if(e===206)n=this.readU32();else if(e===207)n=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)n=this.readI8();else if(e===209)n=this.readI16();else if(e===210)n=this.readI32();else if(e===211)n=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();n=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();n=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();n=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else n=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else n=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else n={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else n={}}else if(e===196){let e=this.lookU8();n=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();n=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();n=this.decodeBinary(e,4)}else if(e===212)n=this.decodeExtension(1,0);else if(e===213)n=this.decodeExtension(2,0);else if(e===214)n=this.decodeExtension(4,0);else if(e===215)n=this.decodeExtension(8,0);else if(e===216)n=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();n=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();n=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();n=this.decodeExtension(e,4)}else throw new t(`Unrecognized type byte: ${prettyByte(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let e=r.top();if(e.type===i)if(e.array[e.position]=n,e.position++,e.position===e.size)n=e.array,r.release(e);else continue DECODE;else if(e.type===a){if(n===`__proto__`)throw new t(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(n),e.type=o;continue DECODE}else if(e.map[e.key]=n,e.readCount++,e.readCount===e.size)n=e.map,r.release(e);else{e.key=null,e.type=a;continue DECODE}}return n}}readHeadByte(){return this.headByte===-1&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=-1}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new t(`Unrecognized array type byte: ${prettyByte(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new t(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new t(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,n){if(e>this.maxStrLength)throw new t(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+n+e)throw l;let r=this.pos+n,i;return i=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,r,e):utf8Decode(this.bytes,r,e),this.pos+=n+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===a:!1}decodeBinary(e,n){if(e>this.maxBinLength)throw new t(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+n))throw l;let r=this.pos+n,i=this.bytes.subarray(r,r+e);return this.pos+=n+e,i}decodeExtension(e,n){if(e>this.maxExtLength)throw new t(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+n),i=this.decodeBinary(e,n+1);return this.extensionCodec.decode(i,r,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=getUint64(this.view,this.pos);return this.pos+=8,e}readI64(){let e=getInt64(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function decode(e,t){return new d(t).decode(e)}export{decode as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"../rolldown-runtime.mjs";var n=e(t(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function Events(){}Object.create&&(Events.prototype=Object.create(null),new Events().__proto__||(r=!1));function EE(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function addListener(e,t,n,i,a){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var o=new EE(n,i||e,a),s=r?r+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function clearEvent(e,t){--e._eventsCount===0?e._events=new Events:delete e._events[t]}function EventEmitter(){this._events=new Events,this._eventsCount=0}EventEmitter.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},EventEmitter.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},EventEmitter.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},EventEmitter.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},EventEmitter.prototype.on=function(e,t,n){return addListener(this,e,t,n,!1)},EventEmitter.prototype.once=function(e,t,n){return addListener(this,e,t,n,!0)},EventEmitter.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return clearEvent(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&clearEvent(this,a);else{for(var s=0,c=[],l=o.length;s<l;s++)(o[s].fn!==t||i&&!o[s].once||n&&o[s].context!==n)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:clearEvent(this,a)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&clearEvent(this,t)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=r,EventEmitter.EventEmitter=EventEmitter,t!==void 0&&(t.exports=EventEmitter)}))(),1);export{n as t};
@@ -1 +0,0 @@
1
- const{getOwnPropertyNames:e,getOwnPropertySymbols:t}=Object,{hasOwnProperty:n}=Object.prototype;function combineComparators(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function createIsCircular(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function getStrictProperties(n){return e(n).concat(t(n))}const r=Object.hasOwn||((e,t)=>n.call(e,t)),{getOwnPropertyDescriptor:i,keys:a}=Object,o=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function strictEqual(e,t){return e===t}function areArrayBuffersEqual(e,t){return e.byteLength===t.byteLength&&areTypedArraysEqual(new Uint8Array(e),new Uint8Array(t))}function areArraysEqual(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function areDataViewsEqual(e,t){return e.byteLength===t.byteLength&&areTypedArraysEqual(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function areDatesEqual(e,t){return o(e.getTime(),t.getTime())}function areErrorsEqual(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function areMapsEqual(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function areObjectsEqual(e,t,n){let r=a(e),i=r.length;if(a(t).length!==i)return!1;for(;i-- >0;)if(!isPropertyEqual(e,t,n,r[i]))return!1;return!0}function areObjectsEqualStrict(e,t,n){let r=getStrictProperties(e),a=r.length;if(getStrictProperties(t).length!==a)return!1;let o,s,c;for(;a-- >0;)if(o=r[a],!isPropertyEqual(e,t,n,o)||(s=i(e,o),c=i(t,o),(s||c)&&(!s||!c||s.configurable!==c.configurable||s.enumerable!==c.enumerable||s.writable!==c.writable)))return!1;return!0}function arePrimitiveWrappersEqual(e,t){return o(e.valueOf(),t.valueOf())}function areRegExpsEqual(e,t){return e.source===t.source&&e.flags===t.flags}function areSetsEqual(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function areTypedArraysEqual(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function areUrlsEqual(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function isPropertyEqual(e,t,n,i){return(i===`_owner`||i===`__o`||i===`__v`)&&(e.$$typeof||t.$$typeof)?!0:r(t,i)&&n.equals(e[i],t[i],i,i,e,t,n)}const s=Object.prototype.toString;function createEqualityComparator(e){let t=createSupportedComparatorMap(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:c,areRegExpsEqual:l,areSetsEqual:u,getUnsupportedCustomComparator:d}=e;return function(e,f,p){if(e===f)return!0;if(e==null||f==null)return!1;let m=typeof e;if(m!==typeof f)return!1;if(m!==`object`)return m===`number`||m===`bigint`?o(e,f,p):m===`function`?i(e,f,p):!1;let h=e.constructor;if(h!==f.constructor)return!1;if(h===Object)return c(e,f,p);if(h===Array)return n(e,f,p);if(h===Date)return r(e,f,p);if(h===RegExp)return l(e,f,p);if(h===Map)return a(e,f,p);if(h===Set)return u(e,f,p);if(h===Promise)return!1;if(Array.isArray(e))return n(e,f,p);let g=s.call(e),_=t[g];if(_)return _(e,f,p);let v=d&&d(e,f,p,g);return v?v(e,f,p):!1}}function createEqualityComparatorConfig({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual,areArraysEqual:n?areObjectsEqualStrict:areArraysEqual,areDataViewsEqual,areDatesEqual,areErrorsEqual,areFunctionsEqual:strictEqual,areMapsEqual:n?combineComparators(areMapsEqual,areObjectsEqualStrict):areMapsEqual,areNumbersEqual:o,areObjectsEqual:n?areObjectsEqualStrict:areObjectsEqual,arePrimitiveWrappersEqual,areRegExpsEqual,areSetsEqual:n?combineComparators(areSetsEqual,areObjectsEqualStrict):areSetsEqual,areTypedArraysEqual:n?combineComparators(areTypedArraysEqual,areObjectsEqualStrict):areTypedArraysEqual,areUrlsEqual,getUnsupportedCustomComparator:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=createIsCircular(r.areArraysEqual),t=createIsCircular(r.areMapsEqual),n=createIsCircular(r.areObjectsEqual),i=createIsCircular(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function createInternalEqualityComparator(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function createIsEqual({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function createSupportedComparatorMap({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}const c=createCustomEqual();createCustomEqual({strict:!0}),createCustomEqual({circular:!0}),createCustomEqual({circular:!0,strict:!0}),createCustomEqual({createInternalComparator:()=>o}),createCustomEqual({strict:!0,createInternalComparator:()=>o}),createCustomEqual({circular:!0,createInternalComparator:()=>o}),createCustomEqual({circular:!0,createInternalComparator:()=>o,strict:!0});function createCustomEqual(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=createEqualityComparator(createEqualityComparatorConfig(e));return createIsEqual({circular:t,comparator:a,createState:r,equals:n?n(a):createInternalEqualityComparator(a),strict:i})}export{c as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./eventemitter3.mjs";var TimeoutError=class extends Error{constructor(e){super(e),this.name=`TimeoutError`}},AbortError=class extends Error{constructor(e){super(),this.name=`AbortError`,this.message=e}};const getDOMException=e=>globalThis.DOMException===void 0?new AbortError(e):new DOMException(e),getAbortedReason=e=>{let t=e.reason===void 0?getDOMException(`This operation was aborted.`):e.reason;return t instanceof Error?t:getDOMException(t)};function pTimeout(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout}}=t,o,abortHandler,s=new Promise((s,c)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(t.signal){let{signal:e}=t;e.aborted&&c(getAbortedReason(e)),abortHandler=()=>{c(getAbortedReason(e))},e.addEventListener(`abort`,abortHandler,{once:!0})}if(n===1/0){e.then(s,c);return}let l=new TimeoutError;o=a.setTimeout.call(void 0,()=>{if(r){try{s(r())}catch(e){c(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?s():i instanceof Error?c(i):(l.message=i??`Promise timed out after ${n} milliseconds`,c(l))},n),(async()=>{try{s(await e)}catch(e){c(e)}})()}).finally(()=>{s.clear(),abortHandler&&t.signal&&t.signal.removeEventListener(`abort`,abortHandler)});return s.clear=()=>{a.clearTimeout.call(void 0,o),o=void 0},s}function lowerBound(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var PriorityQueue=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,id:t.id,run:e};if(this.size===0||this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let r=lowerBound(this.#e,n,(e,t)=>t.priority-e.priority);this.#e.splice(r,0,n)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}},PQueue=class extends e.default{#e;#t;#n=0;#r;#i;#a=0;#o;#s;#c;#l;#u=0;#d;#f;#p;#m=1n;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:PriorityQueue,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#i=e.interval,this.#c=new e.queueClass,this.#l=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#p=e.throwOnTimeout===!0,this.#f=e.autoStart===!1}get#h(){return this.#t||this.#n<this.#r}get#g(){return this.#u<this.#d}#_(){this.#u--,this.#b(),this.emit(`next`)}#v(){this.#S(),this.#x(),this.#s=void 0}get#y(){let e=Date.now();if(this.#o===void 0){let t=this.#a-e;if(t<0)this.#n=this.#e?this.#u:0;else return this.#s===void 0&&(this.#s=setTimeout(()=>{this.#v()},t)),!0}return!1}#b(){if(this.#c.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit(`empty`),this.#u===0&&this.emit(`idle`),!1;if(!this.#f){let e=!this.#y;if(this.#h&&this.#g){let t=this.#c.dequeue();return t?(this.emit(`active`),t(),e&&this.#x(),!0):!1}}return!1}#x(){this.#t||this.#o!==void 0||(this.#o=setInterval(()=>{this.#S()},this.#i),this.#a=Date.now()+this.#i)}#S(){this.#n===0&&this.#u===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#n=this.#e?this.#u:0,this.#C()}#C(){for(;this.#b(););}get concurrency(){return this.#d}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#d=e,this.#C()}async#w(e){return new Promise((t,n)=>{e.addEventListener(`abort`,()=>{n(e.reason)},{once:!0})})}setPriority(e,t){this.#c.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#m++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#p,...t},new Promise((n,r)=>{this.#c.enqueue(async()=>{this.#u++;try{t.signal?.throwIfAborted(),this.#n++;let r=e({signal:t.signal});t.timeout&&(r=pTimeout(Promise.resolve(r),{milliseconds:t.timeout})),t.signal&&(r=Promise.race([r,this.#w(t.signal)]));let i=await r;n(i),this.emit(`completed`,i)}catch(e){if(e instanceof TimeoutError&&!t.throwOnTimeout){n();return}r(e),this.emit(`error`,e)}finally{this.#_()}},t),this.emit(`add`),this.#b()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#f?(this.#f=!1,this.#C(),this):this}pause(){this.#f=!0}clear(){this.#c=new this.#l}async onEmpty(){this.#c.size!==0&&await this.#T(`empty`)}async onSizeLessThan(e){this.#c.size<e||await this.#T(`next`,()=>this.#c.size<e)}async onIdle(){this.#u===0&&this.#c.size===0||await this.#T(`idle`)}async#T(e,t){return new Promise(n=>{let listener=()=>{t&&!t()||(this.off(e,listener),n())};this.on(e,listener)})}get size(){return this.#c.size}sizeBy(e){return this.#c.filter(e).length}get pending(){return this.#u}get isPaused(){return this.#f}};export{PQueue as t};
@@ -1 +0,0 @@
1
- const toZeroIfInfinity=e=>Number.isFinite(e)?e:0;function parseNumber(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(toZeroIfInfinity(e*1e3)%1e3),nanoseconds:Math.trunc(toZeroIfInfinity(e*1e6)%1e3)}}function parseBigint(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function parseMilliseconds(e){switch(typeof e){case`number`:if(Number.isFinite(e))return parseNumber(e);break;case`bigint`:return parseBigint(e)}throw TypeError(`Expected a finite number or bigint`)}export{parseMilliseconds as t};