@magic5644/graph-it-live 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/graph-it.js +1 -1
  2. package/package.json +1 -1
package/dist/graph-it.js CHANGED
@@ -42475,7 +42475,7 @@ node "${d}" %*
42475
42475
  Ensure ${s} is in your PATH.`}var $y,NL,rpe,vft,Sft=Ki(()=>{"use strict";$y=$l(require("node:fs")),NL=$l(require("node:path")),rpe=$l(require("node:os")),vft=$l(require("node:readline"));yx()});var Eft=$l(require("node:path")),xft=require("node:util");yx();aN();var PD=$l(require("node:fs")),jv=$l(require("node:path"));var Cnt=$l(require("node:fs")),g3=$l(require("node:path")),Pnt=require("node:worker_threads");Wh();var sN=Rd("AstWorkerHost"),YM=class{worker=null;nextId=1;pendingRequests=new Map;workerPath;extensionPath;constructor(i,s){if(this.extensionPath=s,i)this.workerPath=i;else{let m=[g3.join(__dirname,"astWorker.js"),g3.join(__dirname,"../../../dist/astWorker.js"),g3.join(__dirname,"../../../../dist/astWorker.js"),g3.join(process.cwd(),"dist/astWorker.js")],u="";for(let y of m)if(Cnt.existsSync(y)){u=y;break}this.workerPath=u||g3.join(process.cwd(),"dist/astWorker.js")}}async start(){if(this.worker){sN.warn("AstWorker already started");return}sN.info(`Starting AstWorker from ${this.workerPath}`);try{this.worker=new Pnt.Worker(this.workerPath,{workerData:{extensionPath:this.extensionPath}}),this.worker.on("message",i=>{this.handleResponse(i)}),this.worker.on("error",i=>{sN.error("AstWorker error:",i);for(let[s,m]of this.pendingRequests)m.reject(new Error(`AstWorker crashed: ${i.message}`)),this.pendingRequests.delete(s)}),this.worker.on("exit",i=>{i!==0&&sN.error(`AstWorker exited with code ${i}`),this.worker=null}),sN.info("AstWorker started successfully")}catch(i){let s=i instanceof Error?i.message:String(i);throw sN.error(`Failed to start AstWorker: ${s}`),new Error(`Failed to start AstWorker: ${s}`,{cause:i})}}async stop(){if(this.worker){sN.info("Stopping AstWorker");for(let[i,s]of this.pendingRequests)s.reject(new Error("AstWorker stopped")),this.pendingRequests.delete(i);await this.worker.terminate(),this.worker=null,sN.info("AstWorker stopped")}}async analyzeFile(i,s){return await this.sendRequest({type:"analyzeFile",id:0,filePath:i,content:s})}async getInternalExportDependencyGraph(i,s){let u=await this.sendRequest({type:"getInternalExportDeps",id:0,filePath:i,content:s});return new Map(Object.entries(u).map(([y,A])=>[y,new Set(A)]))}async extractSignatures(i,s){return await this.sendRequest({type:"extractSignatures",id:0,filePath:i,content:s})}async extractInterfaceMembers(i,s){let u=await this.sendRequest({type:"extractInterfaceMembers",id:0,filePath:i,content:s});return new Map(Object.entries(u))}async extractTypeAliases(i,s){return await this.sendRequest({type:"extractTypeAliases",id:0,filePath:i,content:s})}async compareSignatures(i,s){return await this.sendRequest({type:"compareSignatures",id:0,oldSig:i,newSig:s})}async analyzeBreakingChanges(i,s,m){return await this.sendRequest({type:"analyzeBreakingChanges",id:0,filePath:i,oldContent:s,newContent:m})}async reset(){await this.sendRequest({type:"reset",id:0})}async getFileCount(){return await this.sendRequest({type:"getFileCount",id:0})}async sendRequest(i){this.worker||await this.start();let s=this.nextId++,m={...i,id:s};return new Promise((u,y)=>{this.pendingRequests.set(s,{resolve:u,reject:y}),this.worker?.postMessage(m)})}handleResponse(i){let s=this.pendingRequests.get(i.id);if(!s){sN.warn(`Received response for unknown request ${i.id}`);return}if(this.pendingRequests.delete(i.id),i.type==="success")s.resolve(i.result);else{let m=new Error(i.error);i.stack&&(m.stack=i.stack),s.reject(m)}}};var TO=$l(require("node:fs/promises")),sie=$l(require("node:fs"));yg();Wh();var xGt=Rd("FileReader"),AGt=5*1024*1024,IGt=64*1024,DGt=3e4,cy=class{maxSize;chunkSize;timeout;constructor(i={}){this.maxSize=i.maxSize??AGt,this.chunkSize=i.chunkSize??IGt,this.timeout=i.timeout??DGt}async getFileSize(i){try{let s=await TO.stat(i);return{size:s.size,isLarge:s.size>this.maxSize,path:i}}catch(s){throw xp.fromError(s,i)}}async readFile(i,s){let m=s?.maxSize??this.maxSize,u=s?.timeout??this.timeout,y=s?.streaming??!1,A=new Promise((O,Y)=>{setTimeout(()=>{Y(new xp(`File read timed out after ${u}ms: ${i}`,"TIMEOUT",{filePath:i}))},u)});try{let O=await TO.stat(i);if(O.size>m)throw new xp(`File too large: ${i} (${this.formatSize(O.size)} > ${this.formatSize(m)})`,"FILE_TOO_LARGE",{filePath:i});return y||O.size>1024*1024?(xGt.debug(`Streaming read for large file: ${i} (${this.formatSize(O.size)})`),await Promise.race([this.readFileStreaming(i),A])):await Promise.race([TO.readFile(i,"utf-8"),A])}catch(O){throw O instanceof xp?O:xp.fromError(O,i)}}async readFileStreaming(i){return new Promise((s,m)=>{let u=[],y=sie.createReadStream(i,{highWaterMark:this.chunkSize});y.on("data",A=>{u.push(Buffer.isBuffer(A)?A:Buffer.from(A))}),y.on("end",()=>{let A=Buffer.concat(u).toString("utf-8");s(A)}),y.on("error",A=>{m(xp.fromError(A,i))})})}async readFileIfExists(i){try{return await this.readFile(i)}catch(s){if(s instanceof xp&&s.code==="FILE_NOT_FOUND")return null;throw s}}async canRead(i){try{return await TO.access(i,sie.constants.R_OK),!0}catch{return!1}}formatSize(i){return i<1024?`${i}B`:i<1024*1024?`${(i/1024).toFixed(1)}KB`:`${(i/(1024*1024)).toFixed(1)}MB`}};Wh();function Vb(d){let s=/^(.+\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|vue|svelte|gql|graphql)):(.+)$/i.exec(d);if(!s)return d;let m=s[1];return s[3]?(m.length>1&&m[1]===":"&&/^[a-zA-Z]:/.test(m),Rd("PathExtractor").warn(`Symbol ID detected where file path expected: ${d}. Extracting file path: ${m}`),m):d}var ZM=$l(require("node:fs/promises")),Dl=$l(require("node:path"));bU();yg();var mD=class{pathAliases=new Map;tsConfigPromise;tsConfigPath;isConfigLoaded=!1;excludeNodeModules;workspaceRoot;directoryToPackageJson=new Map;directoryToTsConfig=new Map;tsConfigPathAliases=new Map;packageJsonImports=new Map;packageJsonLoadPromises=new Map;tsConfigLoadPromises=new Map;constructor(i,s=!0,m){this.excludeNodeModules=s,this.tsConfigPath=i,this.workspaceRoot=m??(i?Dl.dirname(i):void 0)}updateConfig(i){this.excludeNodeModules=i}async ensureTsConfigLoaded(){this.isConfigLoaded||!this.tsConfigPath||(this.tsConfigPromise??=this.loadTsConfig(this.tsConfigPath),await this.tsConfigPromise,this.tsConfigPromise=void 0,this.isConfigLoaded=!0)}async loadTsConfig(i){try{let s=await ZM.readFile(i,"utf-8"),m=JSON.parse(s),u=m?.compilerOptions?.paths,y=m?.compilerOptions?.baseUrl||".";if(u)for(let[A,O]of Object.entries(u)){let Y=A.replace(/\/\*$/,""),me=O[0]?.replace(/\/\*$/,"");if(me){let Ee=Dl.dirname(i),we=Dl.resolve(Ee,y,me);this.pathAliases.set(Y,eo(we))}}}catch{}}async tryTsConfigAliases(i,s){let m=this.resolveAlias(s);if(m)return this.resolveWithExtensions(m);let u=await this.resolveDynamicTsConfigAlias(i,s);return u?this.resolveWithExtensions(u):null}async tryPythonImports(i,s){if(!this.isPythonFile(i))return null;if(this.isPythonRelativeImport(s)){let m=await this.resolvePythonRelativeImport(i,s);if(m)return m}if(s.includes(".")&&!s.includes("/")){let m=await this.resolvePythonModule(i,s);if(m)return m}return null}async trySpecialModulePatterns(i,s){if(this.isSubpathImport(s))return this.resolveSubpathImport(i,s);let m=await this.resolveRustModule(i,s);return m||(this.isPackageJsonAliasCandidate(s)?this.resolveScopedPackage(i,s):null)}async tryRelativePath(i,s){if(!this.isRelativePath(s))return null;let m=Dl.dirname(i),u=Dl.resolve(m,s);if(this.isPythonFile(i)&&!this.hasFileExtension(s)){let y=await this.resolveWithExtensions(u);if(y)return y}return this.resolveWithExtensions(u)}async resolve(i,s){await this.ensureTsConfigLoaded();let m=await this.tryTsConfigAliases(i,s);if(m)return m;let u=await this.trySpecialModulePatterns(i,s);if(u)return u;let y=await this.tryPythonImports(i,s);return y||(this.isNodeModule(s)?this.excludeNodeModules?null:s:this.tryRelativePath(i,s))}async resolveSubpathImport(i,s){let m=await this.resolvePackageJsonImport(i,s);return m?this.resolveWithExtensions(m):null}async resolveScopedPackage(i,s){let m=await this.resolvePackageJsonImport(i,s);if(m)return this.resolveWithExtensions(m);let u=await this.resolveWorkspacePackage(i,s);return u||(this.excludeNodeModules?null:s)}async resolveDynamicTsConfigAlias(i,s){if(!this.isPackageJsonAliasCandidate(s))return null;let m=await this.findNearestTsConfig(i);if(!m)return null;let u=await this.getTsConfigPathAliases(m);for(let[y,A]of u.entries())if(s===y||s.startsWith(y+"/")){let O=s.replace(y,A);return eo(O)}return null}async findNearestTsConfig(i){let s=Dl.dirname(i);return this.directoryToTsConfig.has(s)?this.directoryToTsConfig.get(s)??null:await this.searchTsConfigUpward(s)}async searchTsConfigUpward(i){let s=[],m=i;for(;!this.shouldStopSearch(m);){s.push(m);let u=this.directoryToTsConfig.get(m);if(u!==void 0)return this.cacheTsConfigResultForDirs(s,u),u;let y=Dl.join(m,"tsconfig.json");if(await this.fileExists(y))return this.cacheTsConfigResultForDirs(s,y),y;let O=Dl.dirname(m);if(O===m)break;m=O}return this.cacheTsConfigResultForDirs(s,null),null}cacheTsConfigResultForDirs(i,s){for(let m of i)this.directoryToTsConfig.set(m,s)}async getTsConfigPathAliases(i){if(this.tsConfigPathAliases.has(i))return this.tsConfigPathAliases.get(i);if(this.tsConfigLoadPromises.has(i))return this.tsConfigLoadPromises.get(i);let s=this.loadTsConfigPathAliases(i);this.tsConfigLoadPromises.set(i,s);try{let m=await s;return this.tsConfigPathAliases.set(i,m),m}finally{this.tsConfigLoadPromises.delete(i)}}async loadTsConfigPathAliases(i){let s=new Map,m=new Set;return await this.loadTsConfigPathAliasesRecursive(i,s,m),s}async loadTsConfigPathAliasesRecursive(i,s,m){let u=Dl.resolve(i);if(!m.has(u)){m.add(u);try{let y=await ZM.readFile(i,"utf-8"),A=JSON.parse(y),O=Dl.dirname(i);if(A.extends){let Ee=Dl.resolve(O,A.extends),we=Ee.endsWith(".json")?Ee:Ee+".json",de=await this.fileExists(we)?we:Ee;await this.fileExists(de)&&await this.loadTsConfigPathAliasesRecursive(de,s,m)}let Y=A?.compilerOptions?.paths,me=A?.compilerOptions?.baseUrl||".";if(Y)for(let[Ee,we]of Object.entries(Y)){let de=Ee.replace(/\/\*$/,""),ht=we[0]?.replace(/\/\*$/,"");if(ht){let Je=Dl.resolve(O,me,ht);s.set(de,eo(Je))}}}catch{}}}resolveAlias(i){for(let[s,m]of this.pathAliases.entries())if(i===s||i.startsWith(s+"/"))return i.replace(s,m);return null}async resolveWithExtensions(i){let s=cie;if(await this.fileExists(i))return eo(i);for(let m of s){let u=i+m;if(await this.fileExists(u))return eo(u)}for(let m of s){let u=Dl.join(i,`index${m}`);if(await this.fileExists(u))return eo(u)}return null}async fileExists(i){try{return(await ZM.stat(i)).isFile()}catch{return!1}}isRelativePath(i){return i.startsWith("./")||i.startsWith("../")}async resolveRustModule(i,s){if(!i.endsWith(".rs")||s.startsWith(".")||s.startsWith("@")||s.startsWith("#")||s.startsWith("/")||!/^\w+(?:::\w+)*$/u.test(s))return null;let u=Dl.dirname(i),y=s.replaceAll("::",Dl.sep),A=[Dl.join(u,`${y}.rs`),Dl.join(u,y,"mod.rs")];for(let O of A)if(await this.fileExists(O))return eo(O);return null}isNodeModule(i){return!i.startsWith(".")&&!i.startsWith("/")&&!i.startsWith("#")&&!i.startsWith("@")}isSubpathImport(i){return i.startsWith("#")}isPackageJsonAliasCandidate(i){return i.startsWith("@")}isPythonFile(i){return lie.some(s=>i.endsWith(s))}hasFileExtension(i){let s=Dl.basename(i);return s.includes(".")&&!s.startsWith(".")}isPythonRelativeImport(i){return(i.startsWith(".")||i.startsWith(".."))&&!i.includes("/")&&i!=="."&&i!==".."}async resolvePythonRelativeImport(i,s){let m=Dl.dirname(i),u=0,y=s;for(;y.startsWith(".");)u++,y=y.substring(1);let A=m;for(let O=1;O<u;O++)A=Dl.dirname(A);if(y){let O=Dl.join(A,y+".py");if(await this.fileExists(O))return eo(O);let Y=Dl.join(A,y,"__init__.py");if(await this.fileExists(Y))return eo(Y)}return null}async resolvePythonModule(i,s){let m=s.replaceAll(".","/"),u=Dl.dirname(i),y=this.workspaceRoot||u,A=u;for(;;){let O=Dl.resolve(A,m+".py");if(await this.fileExists(O))return eo(O);let Y=Dl.resolve(A,m,"__init__.py");if(await this.fileExists(Y))return eo(Y);if(eo(A)===eo(y))break;let me=Dl.dirname(A);if(me===A)break;A=me}return null}async resolvePackageJsonImport(i,s){let m=await this.findNearestPackageJson(i);if(!m)return null;let u=await this.getPackageJsonImports(m),y=Dl.dirname(m);if(u.has(s)){let A=u.get(s);return eo(Dl.resolve(y,A))}for(let[A,O]of u.entries())if(A.endsWith("/*")){let Y=A.slice(0,-2);if(s.startsWith(Y+"/")){let me=s.slice(Y.length+1),Ee=O.endsWith("/*")?O.slice(0,-2):O,we=Dl.resolve(y,Ee,me);return eo(we)}}return null}async findNearestPackageJson(i){let s=Dl.dirname(i);return this.directoryToPackageJson.has(s)?this.directoryToPackageJson.get(s)??null:await this.searchPackageJsonUpward(s)}async searchPackageJsonUpward(i){let s=[],m=i;for(;!this.shouldStopSearch(m);){s.push(m);let u=this.directoryToPackageJson.get(m);if(u!==void 0)return this.cacheResultForDirs(s,u),u;let y=Dl.join(m,"package.json");if(await this.fileExists(y))return this.cacheResultForDirs(s,y),y;let A=Dl.dirname(m);if(A===m)break;m=A}return this.cacheResultForDirs(s,null),null}shouldStopSearch(i){return!!(this.workspaceRoot&&i===Dl.dirname(this.workspaceRoot))}cacheResultForDirs(i,s){for(let m of i)this.directoryToPackageJson.set(m,s)}async getPackageJsonImports(i){if(this.packageJsonImports.has(i))return this.packageJsonImports.get(i);if(this.packageJsonLoadPromises.has(i))return this.packageJsonLoadPromises.get(i);let s=this.loadPackageJsonImports(i);this.packageJsonLoadPromises.set(i,s);try{let m=await s;return this.packageJsonImports.set(i,m),m}finally{this.packageJsonLoadPromises.delete(i)}}async loadPackageJsonImports(i){let s=new Map;try{let m=await ZM.readFile(i,"utf-8"),u=JSON.parse(m);this.parseImportsField(u?.imports,s),this.parseAliasesField(u?.aliases,s)}catch{}return s}parseImportsField(i,s){if(!(!i||typeof i!="object"))for(let[m,u]of Object.entries(i)){let y=this.resolveImportTarget(u);y&&s.set(m,y)}}resolveImportTarget(i){if(typeof i=="string")return i;if(typeof i=="object"&&i!==null){let s=i,m=s.default??s.import??s.require??s.node;if(typeof m=="string")return m}return null}parseAliasesField(i,s){if(!(!i||typeof i!="object"))for(let[m,u]of Object.entries(i))typeof u=="string"&&s.set(m,u)}async resolveWorkspacePackage(i,s){if(!s.startsWith("@"))return null;let u=/^@([^/]+)\/([^/]+)(\/.*)?$/.exec(s);if(!u)return null;let[,,y,A]=u,O=s.split("/").slice(0,2).join("/"),Y=await this.resolveFileDependency(i,O);if(Y)return this.resolvePackageEntry(Y,s,A);if(this.workspaceRoot){let me=await this.findWorkspacePackageDir(y);if(me)return this.resolvePackageEntry(me,s,A)}return null}async resolveFileDependency(i,s){let u=Dl.dirname(i);for(;!this.shouldStopSearch(u);){let y=Dl.join(u,"package.json");if(await this.fileExists(y)){let O=await this.findFileDependencyInPackageJson(y,s);if(O)return O}let A=Dl.dirname(u);if(A===u)break;u=A}return null}async findFileDependencyInPackageJson(i,s){try{let m=await ZM.readFile(i,"utf-8"),u=JSON.parse(m),y=Dl.dirname(i),O={...u.dependencies,...u.devDependencies,...u.peerDependencies}[s];if(typeof O=="string"&&O.startsWith("file:")){let Y=O.slice(5),me=Dl.resolve(y,Y),Ee=eo(me),we=Dl.join(me,"package.json");if(await this.fileExists(we))return Ee}}catch{}return null}async findWorkspacePackageDir(i){if(!this.workspaceRoot)return null;let s=["packages","libs","modules"];for(let m of s){let u=Dl.join(this.workspaceRoot,m,i),y=Dl.join(u,"package.json");if(await this.fileExists(y))return u}return null}async resolvePackageEntry(i,s,m){let u=Dl.join(i,"package.json");try{let y=await ZM.readFile(u,"utf-8"),A=JSON.parse(y),O=s.split("/").slice(0,2).join("/"),Y=s.split("/").slice(1,2).join("/"),me=A.name;if(me!==O&&me!==Y)return null;if(m){let Ee=A.source?Dl.dirname(A.source):"src",we=Dl.join(i,Ee,m);return this.resolveWithExtensions(we)}return this.findPackageEntryPoint(i,A)}catch{return null}}async findPackageEntryPoint(i,s){let m=s.main||s.module||"index",u=[Dl.join(i,"src","index"),Dl.join(i,m),Dl.join(i,"index")];for(let y of u){let A=await this.resolveWithExtensions(y);if(A)return A}return null}};var y3=class{fileReader;pathResolver;constructor(i){this.fileReader=new cy,this.pathResolver=new mD(i)}patterns={importFrom:/import\s+(?:[^;'"]|'[^']*'|"[^"]*")*?\s+from\s+['"]([^'"]+)['"]/g,exportFrom:/export\s+(?:[^;'"]|'[^']*'|"[^"]*")*?\s+from\s+['"]([^'"]+)['"]/g,require:/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,dynamicImport:/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,graphqlImport:/#import\s+['"]([^'"]+)['"]/g};parse(i,s){s&&(s.endsWith(".vue")||s.endsWith(".svelte"))&&(i=this.extractScript(i));let m=[],u=new Set;return s?.endsWith(".gql")||s?.endsWith(".graphql")?(this.extractImports(i,this.patterns.graphqlImport,"import",m,u),m):(i=this.stripComments(i),this.extractImports(i,this.patterns.importFrom,"import",m,u),this.extractImports(i,this.patterns.exportFrom,"export",m,u),this.extractImports(i,this.patterns.require,"require",m,u),this.extractImports(i,this.patterns.dynamicImport,"dynamic",m,u),m)}extractScript(i){let s=/<script[^>]*>([\s\S]*?)<\/script\s*[^>]*>/gi;return[...i.matchAll(s)].map(u=>u[1]).join(`
42476
42476
  `)}stripComments(i){let s=/'[^']*'|"[^"]*"/,m=/\/\/[^\n]*|\/\*[\s\S]*?\*\//,u=new RegExp(`(${s.source})|(${m.source})`,"g");return i.replaceAll(u,(y,A,O)=>A||O.replaceAll(/[^\n]/g," "))}extractImports(i,s,m,u,y){let A;for(s.lastIndex=0;(A=s.exec(i))!==null;){let O=A[1];if(y.has(O))continue;y.add(O);let Y=this.getLineNumber(i,A.index);u.push({module:O,type:m,line:Y})}}getLineNumber(i,s){return i.substring(0,s).split(`
42477
42477
  `).length}async parseImports(i){let s=Vb(i),m=await this.fileReader.readFile(s);return this.parse(m,s).map(y=>({path:"",type:y.type,line:y.line,module:y.module}))}async resolvePath(i,s){let m=Vb(i);return this.pathResolver.resolve(m,s)}};var QM=class{cache=new Map;maxSize;enableLRU;hits=0;misses=0;evictions=0;constructor(i={}){this.maxSize=i.maxSize??0,this.enableLRU=i.enableLRU??!0}get(i){let s=this.cache.get(i);if(s!==void 0)return this.hits++,this.enableLRU&&this.maxSize>0&&(this.cache.delete(i),this.cache.set(i,s)),s;this.misses++}set(i,s){this.cache.has(i)?this.cache.delete(i):this.maxSize>0&&this.cache.size>=this.maxSize&&this.evictOldest(),this.cache.set(i,s)}has(i){return this.cache.has(i)}clear(){this.cache.clear(),this.resetStats()}delete(i){return this.cache.delete(i)}get size(){return this.cache.size}getStats(){let i=this.hits+this.misses;return{hits:this.hits,misses:this.misses,evictions:this.evictions,size:this.cache.size,maxSize:this.maxSize,hitRate:i>0?this.hits/i:0}}resetStats(){this.hits=0,this.misses=0,this.evictions=0}keys(){return this.cache.keys()}entries(){return this.cache.entries()}evictOldest(){let i=this.cache.keys().next().value;i!==void 0&&(this.cache.delete(i),this.evictions++)}};Wh();var MGt=Rd("IndexerStatus"),v3=class{_state="idle";_processed=0;_total=0;_currentFile;_startTime;_errorMessage;_cancelled=!1;_listeners=new Set;_lastNotifyTime=0;_notifyThrottleMs;constructor(i){this._notifyThrottleMs=i?.notifyThrottleMs??250}subscribe(i){return this._listeners.add(i),i(this.getSnapshot()),()=>this._listeners.delete(i)}getSnapshot(){let i=this._total>0?Math.round(this._processed/this._total*100):0,s;if(this._startTime&&this._processed>0&&this._total>0&&this._state==="indexing"){let u=(Date.now()-this._startTime)/this._processed,y=this._total-this._processed;s=Math.round(u*y)}return{state:this._state,processed:this._processed,total:this._total,currentFile:this._currentFile,percentage:i,startTime:this._startTime,estimatedTimeRemaining:s,errorMessage:this._errorMessage,cancelled:this._cancelled}}startCounting(){this._state="counting",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=Date.now(),this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}setTotal(i){this._total=i,this._notifyListeners(!0)}startIndexing(){this._state="indexing",this._startTime=Date.now(),this._notifyListeners(!0)}startValidating(){this._state="validating",this._notifyListeners(!0)}updateProgress(i,s){this._processed=i,this._currentFile=s,this._notifyListeners(!1)}complete(){this._state="complete",this._currentFile=void 0,this._notifyListeners(!0)}setError(i){this._state="error",this._errorMessage=i,this._currentFile=void 0,this._notifyListeners(!0)}setCancelled(){this._cancelled=!0,this._state="idle",this._currentFile=void 0,this._notifyListeners(!0)}reset(){this._state="idle",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=void 0,this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}isActive(){return this._state==="counting"||this._state==="indexing"||this._state==="validating"}isReady(){return this._state==="complete"}_notifyListeners(i){let s=Date.now();if(!i&&s-this._lastNotifyTime<this._notifyThrottleMs)return;this._lastNotifyTime=s;let m=this.getSnapshot();for(let u of this._listeners)try{u(m)}catch(y){MGt.error("Listener error:",y)}}get state(){return this._state}get total(){return this._total}get processed(){return this._processed}};var clt=$l(require("node:path"));var bu=$l(ilt());Wh();function hLe(d){switch(d){case"FunctionDeclaration":case"ArrowFunction":case"MethodDeclaration":case"GetAccessor":case"SetAccessor":return"function";case"ClassDeclaration":return"class";case"InterfaceDeclaration":return"interface";case"TypeAliasDeclaration":return"type";case"VariableDeclaration":case"PropertyDeclaration":case"EnumDeclaration":return"variable";default:return"other"}}var olt=Rd("SymbolAnalyzer"),Kce=class{project;maxFiles;fileCount=0;fileReader;constructor(i,s={}){this.maxFiles=s.maxFiles??100,this.project=this.createProject(),this.fileReader=new cy}createProject(){return new bu.Project({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0,compilerOptions:{target:99,module:99}})}maybeResetProject(){this.fileCount>=this.maxFiles&&(olt.debug(`Resetting ts-morph project (${this.fileCount} files in memory)`),this.project=this.createProject(),this.fileCount=0)}getFileCount(){return this.fileCount}reset(){olt.debug("Forcing ts-morph project reset"),this.project=this.createProject(),this.fileCount=0}analyzeFileContent(i,s){this.maybeResetProject();let m=this.getOrCreateSourceFile(i,s),u=[],y=[],A=this.extractExportedSymbols(m,i,u);return this.extractNonExportedSymbols(m,i,A,u),this.buildDependencies(m,y),{symbols:u,dependencies:y}}getOrCreateSourceFile(i,s){let m=this.project.getSourceFile(i);return m?m.replaceWithText(s):(m=this.project.createSourceFile(i,s),this.fileCount++),m}extractExportedSymbols(i,s,m){let u=i.getExportedDeclarations(),y=new Set(u.keys());for(let[A,O]of u){let Y=O[0];Y&&(this.addSymbol(m,A,Y.getKindName(),Y.getStartLineNumber(),s,!0),Y.getKindName()==="ClassDeclaration"&&bu.Node.isClassDeclaration(Y)&&this.extractClassMembers(Y,s,m))}return y}extractNonExportedSymbols(i,s,m,u){let y=i.getStatements();for(let A of y)bu.Node.isVariableStatement(A)?this.extractVariableDeclarations(A,s,m,u):this.extractOtherDeclarations(A,s,m,u)}extractVariableDeclarations(i,s,m,u){let y=i.getDeclarations();for(let A of y){let O=A.getName();m.has(O)||this.addSymbol(u,O,"VariableDeclaration",A.getStartLineNumber(),s,!1)}}extractOtherDeclarations(i,s,m,u){let y=this.getDeclarationInfo(i);!y||m.has(y.name)||(this.addSymbol(u,y.name,y.kind,i.getStartLineNumber(),s,!1),y.isClass&&bu.Node.isClassDeclaration(i)&&this.extractClassMembers(i,s,u))}getDeclarationInfo(i){if(bu.Node.isClassDeclaration(i)){let s=i.getName();if(s)return{name:s,kind:"ClassDeclaration",isClass:!0}}else if(bu.Node.isFunctionDeclaration(i)){let s=i.getName();if(s)return{name:s,kind:"FunctionDeclaration",isClass:!1}}else{if(bu.Node.isInterfaceDeclaration(i))return{name:i.getName(),kind:"InterfaceDeclaration",isClass:!1};if(bu.Node.isTypeAliasDeclaration(i))return{name:i.getName(),kind:"TypeAliasDeclaration",isClass:!1};if(bu.Node.isEnumDeclaration(i))return{name:i.getName(),kind:"EnumDeclaration",isClass:!1}}return null}addSymbol(i,s,m,u,y,A){i.push({name:s,kind:m,line:u,isExported:A,id:`${y}:${s}`,category:hLe(m)})}buildDependencies(i,s){let m=this.buildImportMap(i),u=this.findSymbolUsage(i,m);for(let[y,A]of Object.entries(u))for(let O of A)s.push({sourceSymbolId:y,targetSymbolId:O.symbolId,targetFilePath:O.filePath,isTypeOnly:O.isTypeOnly})}getInternalExportDependencyGraph(i,s){this.maybeResetProject();let u=this.getOrCreateSourceFile(i,s).getExportedDeclarations(),y=new Set(u.keys()),A=new Map;for(let[O,Y]of u){let me=`${i}:${O}`,Ee=this.getOrCreateDependencySet(A,me);this.collectExportDependencies(Y,O,y,i,Ee)}return A}getOrCreateDependencySet(i,s){let m=i.get(s);return m||(m=new Set,i.set(s,m)),m}collectExportDependencies(i,s,m,u,y){for(let A of i){let O=A.getDescendantsOfKind(bu.SyntaxKind.Identifier);for(let Y of O){let me=Y.getText();this.isValidDependency(me,s,m)&&y.add(`${u}:${me}`)}}}isValidDependency(i,s,m){return m.has(i)&&i!==s}buildImportMap(i){let s=new Map,m=i.getImportDeclarations();for(let u of m){let y=u.getModuleSpecifierValue(),A=u.isTypeOnly(),O=u.getDefaultImport();if(O){let Ee=O.getText();s.set(Ee,{originalName:"default",modulePath:y,isType:A})}let Y=u.getNamedImports();for(let Ee of Y){let we=Ee.getNameNode().getText(),de=Ee.getAliasNode(),ht=de?de.getText():we;s.set(ht,{originalName:we,modulePath:y,isType:A||Ee.isTypeOnly()})}let me=u.getNamespaceImport();if(me){let Ee=me.getText();s.set(Ee,{originalName:"*",modulePath:y,isType:A})}}return s}extractIntraFileCalls(i,s){let m=[],u=s.getFilePath(),y=this.collectFunctionNames(s),A=i.getDescendantsOfKind(bu.SyntaxKind.CallExpression);for(let O of A)this.processCallExpression(O,y,u,m);return m}collectFunctionNames(i){let s=new Set;for(let m of i.getFunctions()){let u=m.getName();u&&s.add(u)}for(let m of i.getClasses())for(let u of m.getMethods()){let y=u.getName();y&&s.add(y)}return s}processCallExpression(i,s,m,u){if(!bu.Node.isCallExpression(i))return;let y=i.getExpression();if(bu.Node.isIdentifier(y)){this.addDirectFunctionCall(y,s,m,u);return}bu.Node.isPropertyAccessExpression(y)&&this.addPropertyAccessCall(y,s,m,u)}addDirectFunctionCall(i,s,m,u){let y=i.getText();s.has(y)&&u.push({symbolId:`${m}:${y}`,filePath:m,isTypeOnly:!1})}addPropertyAccessCall(i,s,m,u){if(bu.Node.isPropertyAccessExpression(i)){let y=i.getName();s.has(y)&&u.push({symbolId:`${m}:${y}`,filePath:m,isTypeOnly:!1})}}findSymbolUsage(i,s){let m={},u=i.getFilePath(),y=[...i.getFunctions(),...i.getClasses(),...i.getVariableDeclarations()];for(let Y of y){let me=Y.getName();if(!me)continue;let Ee=`${u}:${me}`,we=this.extractSymbolDependencies(Y,s),de=this.extractIntraFileCalls(Y,i);we.push(...de),m[Ee]=we}let A=i.getStatements(),O=[];for(let Y of A){if(bu.Node.isFunctionDeclaration(Y)||bu.Node.isClassDeclaration(Y)||bu.Node.isVariableStatement(Y)||bu.Node.isInterfaceDeclaration(Y)||bu.Node.isTypeAliasDeclaration(Y)||bu.Node.isEnumDeclaration(Y)||bu.Node.isImportDeclaration(Y))continue;let me=this.extractSymbolDependencies(Y,s);O.push(...me)}if(O.length>0){let Y=`${u}:(file)`;m[Y]=O}return m}extractSymbolDependencies(i,s){let m=[];return this.extractStaticImportDependencies(i,s,m),this.extractDynamicImportDependencies(i,m),m}extractStaticImportDependencies(i,s,m){let u=i.getDescendantsOfKind(bu.SyntaxKind.Identifier);for(let y of u){let A=s.get(y.getText());if(!A)continue;let O=this.buildTargetSymbolId(A);m.some(Y=>Y.symbolId===O)||m.push({symbolId:O,filePath:A.modulePath,isTypeOnly:A.isType})}}extractDynamicImportDependencies(i,s){let m=i.getDescendantsOfKind(bu.SyntaxKind.CallExpression);for(let u of m){let y=this.extractDynamicImportPath(u);if(!y)continue;let A=`${y}:default`;s.some(O=>O.symbolId===A)||s.push({symbolId:A,filePath:y,isTypeOnly:!1})}}extractDynamicImportPath(i){if(!bu.Node.isCallExpression(i)||i.getExpression().getKind()!==bu.SyntaxKind.ImportKeyword)return null;let m=i.getArguments();if(m.length===0)return null;let u=m[0];return bu.Node.isStringLiteral(u)?u.getLiteralValue():null}buildTargetSymbolId(i){return i.originalName==="default"?`${i.modulePath}:default`:`${i.modulePath}:${i.originalName}`}extractClassMembers(i,s,m){let u=i.getName();if(!u)return;let y=`${s}:${u}`,A=i.getMembers();for(let O of A){let Y=O.getKindName();if(!bu.Node.isMethodDeclaration(O)&&!bu.Node.isPropertyDeclaration(O)&&!bu.Node.isGetAccessorDeclaration(O)&&!bu.Node.isSetAccessorDeclaration(O))continue;let me=O.getName();if(!me)continue;let Ee=O.isStatic()??!1,we=`${u}.${me}`,de=Ee?`Static${Y}`:Y;m.push({name:we,kind:de,line:O.getStartLineNumber(),isExported:!1,id:`${s}:${we}`,parentSymbolId:y,category:hLe(Y)})}}getExportedSymbols(i,s){let m=this.project.getSourceFile(i);m?m.replaceWithText(s):m=this.project.createSourceFile(i,s);let u=[],y=m.getExportedDeclarations();for(let[A,O]of y){let Y=O[0];if(!Y)continue;let me=Y.getKindName();u.push({name:A,kind:me,line:Y.getStartLineNumber(),isExported:!0,id:`${i}:${A}`,category:hLe(me)})}return u}filterRuntimeSymbols(i){let s=new Set(["InterfaceDeclaration","TypeAliasDeclaration","TypeParameter"]);return i.filter(m=>!s.has(m.kind))}async analyzeFile(i){let s=await this.fileReader.readFile(i),m=this.analyzeFileContent(i,s),u=new Map;for(let y of m.symbols)u.set(y.id,y);return u}async getSymbolDependencies(i){let s=await this.fileReader.readFile(i);return this.analyzeFileContent(i,s).dependencies}};var gLe=$l(require("node:fs/promises")),$b=$l(require("node:path"));tI();yg();$3();var Jce=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(i,s){this.fileReader=new cy,this.rootDir=i||process.cwd(),this.extensionPath=s}async ensureInitialized(){if(!this.parser){if(this.initPromise)return this.initPromise;this.initPromise=(async()=>{let i=await this.resolveExtensionPath();if(!i)throw new Error("Extension path required for WASM parser initialization. Ensure PythonParser is constructed with extensionPath parameter.");try{let s=xx.getInstance(),m=$b.default.join(i,"dist","wasm","tree-sitter.wasm");await s.init(m);let u=$b.default.join(i,"dist","wasm","tree-sitter-python.wasm");this.parser=await s.getParser("python",u)}catch(s){this.initPromise=null;let m=s instanceof Error?s.message:String(s);throw new Error(`Failed to initialize Python WASM parser: ${m}`,{cause:s})}})(),await this.initPromise}}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let i=process.cwd(),s=$b.default.join(i,"dist","wasm","tree-sitter.wasm");try{return await gLe.default.access(s),i}catch{return}}async parseImports(i){try{await this.ensureInitialized();let s=Vb(i),m=await this.fileReader.readFile(s),u=this.parser.parse(m);if(!u)throw new Error(`Failed to parse Python file: ${s}`);let y=[],A=new Set;return this.traverseTree(u.rootNode,O=>{O.type==="import_statement"?this.extractImportStatement(O,y,A,m):O.type==="import_from_statement"&&this.extractImportFromStatement(O,y,A,m)}),y}catch(s){throw xp.fromError(s,i)}}async resolvePath(i,s){try{await this.ensureInitialized();let m=Vb(i),u=$b.default.dirname(m);return s.startsWith(".")?await this.resolveRelativeImport(u,s):await this.resolveAbsoluteImport(u,s)}catch{return null}}extractImportStatement(i,s,m,u){let y=this.findChildrenByType(i,"dotted_name");for(let A of y){let O=this.getNodeText(A,u);O&&!m.has(O)&&(m.add(O),s.push({path:"",type:"import",line:A.startPosition.row+1,module:O}))}}extractImportFromStatement(i,s,m,u){let y=null,A=this.findChildByType(i,"relative_import");if(A)y=this.getNodeText(A,u);else{let O=this.findChildByType(i,"dotted_name");O&&(y=this.getNodeText(O,u))}y&&!m.has(y)&&(m.add(y),s.push({path:"",type:"import",line:i.startPosition.row+1,module:y}))}async resolveRelativeImport(i,s){let m=/^\.*/u.exec(s),u=m?m[0].length:0,y=s.slice(u).replaceAll(".","/"),A=i;for(let Y=1;Y<u;Y++)A=$b.default.dirname(A);let O=[$b.default.join(A,y+".py"),$b.default.join(A,y+".pyi"),$b.default.join(A,y,"__init__.py"),$b.default.join(A,y,"__init__.pyi")];for(let Y of O)if(await this.fileExists(Y))return eo(Y);return null}async resolveAbsoluteImport(i,s){let m=s.replaceAll(".","/"),u=eo(this.rootDir),y=new Set,A=async Y=>{let me=eo(Y);if(y.has(me))return null;y.add(me);let Ee=[$b.default.join(Y,m+".py"),$b.default.join(Y,m+".pyi"),$b.default.join(Y,m,"__init__.py"),$b.default.join(Y,m,"__init__.pyi")];for(let we of Ee)if(await this.fileExists(we))return eo(we);return null},O=i;for(;;){let Y=await A(O);if(Y)return Y;let me=$b.default.dirname(O);if(me===O)break;if(eo(me)===u){let Ee=await A(me);if(Ee)return Ee;break}O=me}if(!y.has(u)){let Y=await A(this.rootDir);if(Y)return Y}return null}async fileExists(i){try{return await gLe.default.access(i),!0}catch{return!1}}traverseTree(i,s){s(i);for(let m of i.children)this.traverseTree(m,s)}findChildrenByType(i,s){let m=[];for(let u of i.children)u.type===s&&m.push(u);return m}findChildByType(i,s){for(let m of i.children)if(m.type===s)return m;return null}getNodeText(i,s){return s.slice(i.startIndex,i.endIndex)}};var slt=$l(require("node:fs/promises")),$ce=$l(require("node:path"));tI();yg();$3();var qce=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(i,s){this.extensionPath=s??i,this.fileReader=new cy}async ensureInitialized(){if(!this.parser){if(this.initPromise)return this.initPromise;this.initPromise=(async()=>{let i=await this.resolveExtensionPath();if(!i)throw new Error("Extension path required for WASM parser initialization. Ensure PythonSymbolAnalyzer is constructed with extensionPath parameter.");try{let s=xx.getInstance(),m=$ce.default.join(i,"dist","wasm","tree-sitter.wasm");await s.init(m);let u=$ce.default.join(i,"dist","wasm","tree-sitter-python.wasm");this.parser=await s.getParser("python",u)}catch(s){this.initPromise=null;let m=s instanceof Error?s.message:String(s);throw new Error(`Failed to initialize Python WASM parser for symbol analysis: ${m}`,{cause:s})}})(),await this.initPromise}}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let i=process.cwd(),s=$ce.default.join(i,"dist","wasm","tree-sitter.wasm");try{return await slt.default.access(s),i}catch{return}}async analyzeFile(i){try{await this.ensureInitialized();let s=await this.fileReader.readFile(i);return this.analyzeFileFromContent(i,s)}catch(s){throw xp.fromError(s,i)}}analyzeFileFromContent(i,s){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let m=this.parser.parse(s);if(!m)throw new Error(`Failed to parse Python file: ${i}`);let u=new Map,y=eo(i);return this.extractSymbols(m.rootNode,y,s,u),u}analyzeFileContent(i,s){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let m=this.parser.parse(s);if(!m)throw new Error(`Failed to parse Python file: ${i}`);let u=new Map,y=[],A=eo(i);this.extractSymbols(m.rootNode,A,s,u);let O=this.buildImportMap(m.rootNode,s);return this.extractDependencies(m.rootNode,A,s,y,u,void 0,O),{symbols:Array.from(u.values()),dependencies:y}}async getSymbolDependencies(i){try{await this.ensureInitialized();let s=await this.fileReader.readFile(i);return this.analyzeFileContent(i,s).dependencies}catch(s){throw xp.fromError(s,i)}}extractSymbols(i,s,m,u,y){this.tryExtractSymbolFromNode(i,s,m,u,y)||this.extractSymbolsFromChildren(i,s,m,u,y)}tryExtractSymbolFromNode(i,s,m,u,y){return i.type==="function_definition"?(this.handleFunctionDefinition(i,s,m,u,y),!0):i.type==="class_definition"?(this.handleClassDefinition(i,s,m,u,y),!0):i.type==="decorated_definition"?(this.handleDecoratedDefinition(i,s,m,u,y),!0):!1}handleFunctionDefinition(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`,me=this.hasChild(i,"async");u.set(Y,{name:O,kind:me?"AsyncFunction":"FunctionDeclaration",line:A.startPosition.row+1,isExported:this.isExported(i,m),id:Y,parentSymbolId:y,category:"function"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleClassDefinition(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`;u.set(Y,{name:O,kind:"ClassDeclaration",line:A.startPosition.row+1,isExported:this.isExported(i,m),id:Y,parentSymbolId:y,category:"class"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleDecoratedDefinition(i,s,m,u,y){for(let A of i.children)(A.type==="function_definition"||A.type==="class_definition")&&this.extractSymbols(A,s,m,u,y)}extractSymbolsFromChildren(i,s,m,u,y){for(let A of i.children)this.extractSymbols(A,s,m,u,y)}buildImportMap(i,s){let m=new Map;return this.traverseForImports(i,m,s),m}traverseForImports(i,s,m){i.type==="import_from_statement"?this.processFromImport(i,s,m):i.type==="import_statement"&&this.processImportStatement(i,s,m);for(let u of i.children)this.traverseForImports(u,s,m)}processFromImport(i,s,m){let u=i.childForFieldName("module_name");if(!u)return;let y=this.getNodeText(u,m);for(let A of i.children)this.processFromImportChild(A,s,m,y)}processFromImportChild(i,s,m,u){if(i.type==="aliased_import"){this.addAliasedFromImport(i,s,m,u);return}if(i.type==="dotted_name"||i.type==="identifier"){let y=this.getNodeText(i,m);if(y===u||i.parent?.type==="aliased_import")return;s.set(y,u)}}addAliasedFromImport(i,s,m,u){let y=i.childForFieldName("name");if(!y)return;let A=this.getNodeText(y,m),O=i.childForFieldName("alias"),Y=O?this.getNodeText(O,m):A;s.set(Y,u)}processImportStatement(i,s,m){for(let u of i.children)this.processImportStatementChild(u,s,m)}processImportStatementChild(i,s,m){if(i.type==="aliased_import"){let u=i.childForFieldName("name");if(!u)return;let y=this.getNodeText(u,m),A=i.childForFieldName("alias"),O=A?this.getNodeText(A,m):y;s.set(O,y);return}if(i.type==="dotted_name"||i.type==="identifier"){let u=this.getNodeText(i,m);u!=="import"&&s.set(u,u)}}extractDependencies(i,s,m,u,y,A,O){let Y=this.getScopeForNode(i,s,m,A);this.addCallDependencyIfAny(i,s,m,u,y,Y,O);for(let me of i.children)this.extractDependencies(me,s,m,u,y,Y,O)}getScopeForNode(i,s,m,u){if(i.type!=="function_definition"&&i.type!=="class_definition")return u;let y=i.childForFieldName("name");if(!y)return u;let A=this.getNodeText(y,m);return`${s}:${A}`}addCallDependencyIfAny(i,s,m,u,y,A,O){if(i.type!=="call")return;let Y=i.childForFieldName("function");if(!Y||!A)return;let me=this.getCalledName(Y,m),Ee=`${s}:${me}`;if(y.has(Ee)){u.push({sourceSymbolId:A,targetSymbolId:Ee,targetFilePath:s,isTypeOnly:!1});return}if(O?.has(me)){let we=O.get(me);u.push({sourceSymbolId:A,targetSymbolId:`${we}:${me}`,targetFilePath:we,isTypeOnly:!1})}}getCalledName(i,s){if(i.type!=="attribute")return this.getNodeText(i,s);let m=i.childForFieldName("attribute");return m?this.getNodeText(m,s):this.getNodeText(i,s)}isExported(i,s){let m=i.childForFieldName("name");return m?!this.getNodeText(m,s).startsWith("_"):!1}hasChild(i,s){for(let m of i.children)if(m.type===s)return!0;return!1}getNodeText(i,s){return s.slice(i.startIndex,i.endIndex)}};var yLe=$l(require("node:fs/promises")),fN=$l(require("node:path"));tI();yg();$3();var Xce=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(i,s){this.fileReader=new cy,this.rootDir=i||process.cwd(),this.extensionPath=s}async ensureInitialized(){if(!this.parser){if(this.initPromise)return this.initPromise;this.initPromise=(async()=>{let i=await this.resolveExtensionPath();if(!i)throw new Error("Extension path required for WASM parser initialization. Ensure RustParser is constructed with extensionPath parameter.");try{let s=xx.getInstance(),m=fN.default.join(i,"dist","wasm","tree-sitter.wasm");await s.init(m);let u=fN.default.join(i,"dist","wasm","tree-sitter-rust.wasm");this.parser=await s.getParser("rust",u)}catch(s){this.initPromise=null;let m=s instanceof Error?s.message:String(s);throw new Error(`Failed to initialize Rust WASM parser: ${m}`,{cause:s})}})(),await this.initPromise}}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let i=process.cwd(),s=fN.default.join(i,"dist","wasm","tree-sitter.wasm");try{return await yLe.default.access(s),i}catch{return}}async parseImports(i){try{await this.ensureInitialized();let s=Vb(i),m=await this.fileReader.readFile(s),u=this.parser.parse(m);if(!u)throw new Error(`Failed to parse Rust file: ${s}`);let y=[],A=new Set;return this.traverseTree(u.rootNode,O=>{O.type==="use_declaration"?this.extractUseDeclaration(O,y,A,m):O.type==="mod_item"?this.extractModItem(O,y,A,m,i):O.type==="extern_crate_declaration"&&this.extractExternCrate(O,y,A,m)}),y}catch(s){throw xp.fromError(s,i)}}async resolvePath(i,s){try{await this.ensureInitialized();let m=s.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(m))return null;let y=Vb(i),A=fN.default.dirname(y);return s.startsWith("self::")||s.startsWith("super::")||s.startsWith("crate::")?await this.resolveRelativeModule(i,s):await this.resolveModDeclaration(A,s)}catch{return null}}extractUseDeclaration(i,s,m,u){let y=this.collectIdentifiers(i,u);for(let A of y){if(!A)continue;let O=A.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(O))continue;let me=A.toLowerCase();m.has(me)||(m.add(me),s.push({path:"",type:"import",line:i.startPosition.row+1,module:me}))}}extractModItem(i,s,m,u,y){if(this.findChildByType(i,"declaration_list"))return;let O=this.findChildByType(i,"identifier");if(O){let Y=this.getNodeText(O,u);Y=Y.toLowerCase(),Y&&!m.has(Y)&&(m.add(Y),s.push({path:"",type:"import",line:i.startPosition.row+1,module:Y}))}}extractExternCrate(i,s,m,u){let y=this.findChildByType(i,"identifier");if(y){let A=this.getNodeText(y,u);if(!A||new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(A))return;let Y=A.toLowerCase();m.has(Y)||(m.add(Y),s.push({path:"",type:"import",line:i.startPosition.row+1,module:Y}))}}collectIdentifiers(i,s){let m=[],u=this.findAllByType(i,"scoped_identifier");for(let A of u){let O=this.getNodeText(A,s);O&&m.push(O)}let y=this.findAllByType(i,"identifier");for(let A of y){let O=this.getNodeText(A,s);if(!O||O==="self"||O==="super"||O==="crate")continue;let Y=O.charAt(0);Y===Y.toUpperCase()&&Y!==Y.toLowerCase()||m.push(O)}return m}async resolveRelativeModule(i,s){let m=fN.default.dirname(i);if(s.startsWith("crate::")){let u=s.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(this.rootDir,u)}if(s.startsWith("super::")){let u=fN.default.dirname(m),y=s.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(u,y)}if(s.startsWith("self::")){let u=s.slice(6).replaceAll("::","/");return await this.resolveModDeclaration(m,u)}return null}async resolveModDeclaration(i,s){if(s!==s.toLowerCase())return null;let m=s.replaceAll("::","/");m=m.toLowerCase();let u=[fN.default.join(i,m+".rs"),fN.default.join(i,m,"mod.rs")];for(let y of u)if(await this.fileExists(y))return eo(y);return null}async fileExists(i){try{return await yLe.default.access(i),!0}catch{return!1}}traverseTree(i,s){s(i);for(let m of i.children)this.traverseTree(m,s)}findChildByType(i,s){for(let m of i.children)if(m.type===s)return m;return null}findAllByType(i,s){let m=[],u=y=>{y.type===s&&m.push(y);for(let A of y.children)u(A)};return u(i),m}getNodeText(i,s){return s.slice(i.startIndex,i.endIndex)}};var llt=$l(require("node:fs/promises")),Yce=$l(require("node:path"));tI();yg();$3();var Zce=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(i,s){this.extensionPath=s??i,this.fileReader=new cy}async ensureInitialized(){if(!this.parser){if(this.initPromise)return this.initPromise;this.initPromise=(async()=>{let i=await this.resolveExtensionPath();if(!i)throw new Error("Extension path required for WASM parser initialization. Ensure RustSymbolAnalyzer is constructed with extensionPath parameter.");try{let s=xx.getInstance(),m=Yce.default.join(i,"dist","wasm","tree-sitter.wasm");await s.init(m);let u=Yce.default.join(i,"dist","wasm","tree-sitter-rust.wasm");this.parser=await s.getParser("rust",u)}catch(s){this.initPromise=null;let m=s instanceof Error?s.message:String(s);throw new Error(`Failed to initialize Rust WASM parser for symbol analysis: ${m}`,{cause:s})}})(),await this.initPromise}}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let i=process.cwd(),s=Yce.default.join(i,"dist","wasm","tree-sitter.wasm");try{return await llt.default.access(s),i}catch{return}}async analyzeFile(i){try{await this.ensureInitialized();let s=await this.fileReader.readFile(i);return this.analyzeFileFromContent(i,s)}catch(s){throw xp.fromError(s,i)}}analyzeFileFromContent(i,s){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let m=this.parser.parse(s);if(!m)throw new Error(`Failed to parse Rust file: ${i}`);let u=new Map,y=eo(i);return this.extractSymbols(m.rootNode,y,s,u),u}analyzeFileContent(i,s){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let m=this.parser.parse(s);if(!m)throw new Error(`Failed to parse Rust file: ${i}`);let u=new Map,y=[],A=eo(i);this.extractSymbols(m.rootNode,A,s,u);let O=this.buildImportMap(m.rootNode,s);return this.extractDependencies(m.rootNode,A,s,y,u,void 0,O),{symbols:Array.from(u.values()),dependencies:y}}async getSymbolDependencies(i){try{await this.ensureInitialized();let s=await this.fileReader.readFile(i);return this.analyzeFileContent(i,s).dependencies}catch(s){throw xp.fromError(s,i)}}extractSymbols(i,s,m,u,y){this.tryExtractSymbolFromNode(i,s,m,u,y)||this.extractSymbolsFromChildren(i,s,m,u,y)}tryExtractSymbolFromNode(i,s,m,u,y){return i.type==="function_item"?(this.handleFunctionItem(i,s,m,u,y),!0):i.type==="struct_item"?(this.handleStructItem(i,s,m,u,y),!0):i.type==="enum_item"?(this.handleEnumItem(i,s,m,u,y),!0):i.type==="trait_item"?(this.handleTraitItem(i,s,m,u,y),!0):i.type==="impl_item"?(this.handleImplItem(i,s,m,u,y),!0):!1}handleFunctionItem(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`,me=this.hasModifier(i,"async"),Ee=this.hasVisibilityModifier(i,"pub");u.set(Y,{name:O,kind:me?"AsyncFunction":"FunctionDeclaration",line:A.startPosition.row+1,isExported:Ee,id:Y,parentSymbolId:y,category:"function"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleStructItem(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`,me=this.hasVisibilityModifier(i,"pub");u.set(Y,{name:O,kind:"StructDeclaration",line:A.startPosition.row+1,isExported:me,id:Y,parentSymbolId:y,category:"class"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleEnumItem(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`,me=this.hasVisibilityModifier(i,"pub");u.set(Y,{name:O,kind:"EnumDeclaration",line:A.startPosition.row+1,isExported:me,id:Y,parentSymbolId:y,category:"type"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleTraitItem(i,s,m,u,y){let A=i.childForFieldName("name");if(!A)return;let O=this.getNodeText(A,m),Y=`${s}:${O}`,me=this.hasVisibilityModifier(i,"pub");u.set(Y,{name:O,kind:"InterfaceDeclaration",line:A.startPosition.row+1,isExported:me,id:Y,parentSymbolId:y,category:"type"}),this.extractSymbolsFromChildren(i,s,m,u,Y)}handleImplItem(i,s,m,u,y){this.extractSymbolsFromChildren(i,s,m,u,y)}extractSymbolsFromChildren(i,s,m,u,y){for(let A of i.children)this.extractSymbols(A,s,m,u,y)}buildImportMap(i,s){let m=new Map,u=y=>{if(y.type==="use_declaration"&&this.extractUseDeclarationImports(y,s,m),y.type==="mod_item"){let A=y.childForFieldName("name");if(A){let O=this.getNodeText(A,s);m.set(O,O)}}for(let A of y.children)u(A)};return u(i),m}extractUseDeclarationImports(i,s,m){this.extractFromUseLists(i,s,m),this.extractFromScopedIdentifiers(i,s,m),this.extractFromUseAsClauses(i,s,m)}extractFromUseLists(i,s,m){let u=this.findAllByType(i,"use_list");for(let y of u){let A=this.findBaseModuleForUseList(y,s);this.extractIdentifiersFromUseList(y,A,s,m)}}findBaseModuleForUseList(i,s){let m=i.parent;for(;m;){if(m.type==="scoped_use_list"){let u=this.findScopedIdentifierInChildren(m,s);if(u)return u}m=m.parent}return""}findScopedIdentifierInChildren(i,s){for(let m of i.children)if(m.type==="scoped_identifier")return this.getNodeText(m,s);return""}extractIdentifiersFromUseList(i,s,m,u){for(let y of i.children)if(y.type==="identifier"){let A=this.getNodeText(y,m);u.set(A,s)}}extractFromScopedIdentifiers(i,s,m){let u=this.findAllByType(i,"scoped_identifier");for(let y of u){if(this.hasAncestorOfType(y,"use_list"))continue;let A=this.getNodeText(y,s),{localName:O,modulePath:Y}=this.splitModulePath(A);m.set(O,Y)}}splitModulePath(i){let s=i.split("::"),m=s.at(-1),u=s.slice(0,-1).join("::");return{localName:m,modulePath:u}}extractFromUseAsClauses(i,s,m){let u=this.findAllByType(i,"use_as_clause");for(let y of u){let A=y.childForFieldName("path"),O=y.childForFieldName("alias");if(A&&O){let Y=this.getNodeText(A,s),me=this.getNodeText(O,s);m.set(me,Y)}}}extractDependencies(i,s,m,u,y,A,O){let Y=this.getScopeForNode(i,s,m,A);this.addCallDependencyIfAny(i,s,m,u,y,Y,O);for(let me of i.children)this.extractDependencies(me,s,m,u,y,Y,O)}getScopeForNode(i,s,m,u){if(i.type!=="function_item")return u;let y=i.childForFieldName("name");if(!y)return u;let A=this.getNodeText(y,m);return`${s}:${A}`}addCallDependencyIfAny(i,s,m,u,y,A,O){if(i.type!=="call_expression")return;let Y=i.childForFieldName("function");if(!Y||!A)return;let{moduleName:me,symbolName:Ee}=this.extractModuleAndSymbolName(Y,m),we=`${s}:${Ee}`;if(y.has(we)){u.push({sourceSymbolId:A,targetSymbolId:we,targetFilePath:s,isTypeOnly:!1});return}if(me&&O?.has(me)){let de=O.get(me);u.push({sourceSymbolId:A,targetSymbolId:`${de}:${Ee}`,targetFilePath:de,isTypeOnly:!1});return}if(O?.has(Ee)){let de=O.get(Ee);u.push({sourceSymbolId:A,targetSymbolId:`${de}:${Ee}`,targetFilePath:de,isTypeOnly:!1})}}extractModuleAndSymbolName(i,s){if(i.type==="field_expression"){let m=i.childForFieldName("field");if(m)return{moduleName:void 0,symbolName:this.getNodeText(m,s)}}if(i.type==="scoped_identifier"){let u=this.getNodeText(i,s).split("::");if(u.length>=2){let y=u.at(-1);return{moduleName:u.slice(0,-1).join("::"),symbolName:y}}return{moduleName:void 0,symbolName:u[0]}}return{moduleName:void 0,symbolName:this.getNodeText(i,s)}}hasVisibilityModifier(i,s){if(i.childForFieldName("visibility_modifier"))return!0;for(let u of i.children)if(u.type==="visibility_modifier")return!0;return!1}hasAncestorOfType(i,s){let m=i.parent;for(;m;){if(m.type===s)return!0;m=m.parent}return!1}hasModifier(i,s){for(let m of i.children)if(m.type===s)return!0;return!1}findAllByType(i,s){let m=[],u=y=>{y.type===s&&m.push(y);for(let A of y.children)u(A)};return u(i),m}getNodeText(i,s){return s.slice(i.startIndex,i.endIndex)}};var q3=class d{static typeScriptParsers=new Map;static typeScriptSymbolAnalyzers=new Map;static pythonParsers=new Map;static pythonSymbolAnalyzers=new Map;static rustParsers=new Map;static rustSymbolAnalyzers=new Map;rootDir;extensionPath;constructor(i,s,m){this.rootDir=i,this.extensionPath=m}getAnalyzer(i){let s=Vb(i);return d.getAnalyzer(s,this.rootDir,this.extensionPath)}getSymbolAnalyzer(i){let s=Vb(i);return d.getSymbolAnalyzer(s,this.rootDir,this.extensionPath)}static detectLanguage(i){let s=Vb(i);switch(clt.default.extname(s).toLowerCase()){case".ts":case".tsx":case".js":case".jsx":case".mjs":case".cjs":case".vue":case".svelte":case".gql":case".graphql":return"typescript";case".py":case".pyi":return"python";case".rs":case".toml":return"rust";default:return"unknown"}}static getAnalyzer(i,s,m){let u=Vb(i);switch(this.detectLanguage(u)){case"typescript":{let A=this.buildCacheKey(s),O=this.typeScriptParsers.get(A);if(O)return O;let Y=new y3(s);return this.typeScriptParsers.set(A,Y),Y}case"python":{let A=this.buildCacheKey(s,m),O=this.pythonParsers.get(A);if(O)return O;let Y=new Jce(s,m);return this.pythonParsers.set(A,Y),Y}case"rust":{let A=this.buildCacheKey(s,m),O=this.rustParsers.get(A);if(O)return O;let Y=new Xce(s,m);return this.rustParsers.set(A,Y),Y}default:throw new Error(`Unsupported language for file: ${i}`)}}static getSymbolAnalyzer(i,s,m){let u=Vb(i);switch(this.detectLanguage(u)){case"typescript":{let A=this.buildCacheKey(s),O=this.typeScriptSymbolAnalyzers.get(A);if(O)return O;let Y=new Kce(s);return this.typeScriptSymbolAnalyzers.set(A,Y),Y}case"python":{let A=this.buildCacheKey(s,m),O=this.pythonSymbolAnalyzers.get(A);if(O)return O;let Y=new qce(s,m);return this.pythonSymbolAnalyzers.set(A,Y),Y}case"rust":{let A=this.buildCacheKey(s,m),O=this.rustSymbolAnalyzers.get(A);if(O)return O;let Y=new Zce(s,m);return this.rustSymbolAnalyzers.set(A,Y),Y}default:throw new Error(`Unsupported language for file: ${i}`)}}static isSupported(i){return this.detectLanguage(i)!=="unknown"}static reset(){this.typeScriptParsers.clear(),this.typeScriptSymbolAnalyzers.clear(),this.pythonParsers.clear(),this.pythonSymbolAnalyzers.clear(),this.rustParsers.clear(),this.rustSymbolAnalyzers.clear()}static buildCacheKey(...i){return i.map(s=>s??"").join("\0")}};Wh();yg();var dlt=Rd("ReferencingFilesFinder"),X3=class{sourceFileCollector;getRootDir;getConcurrency;findReferenceInFile;constructor(i){this.sourceFileCollector=i.sourceFileCollector,this.getRootDir=i.getRootDir,this.getConcurrency=i.getConcurrency,this.findReferenceInFile=i.findReferenceInFile}async findReferencingFilesFallback(i){let s=eo(i),m=this.extractBasename(s);if(!m)return[];dlt.debug("findReferencingFilesFallback for",s,"basename:",m);let u=await this.sourceFileCollector.collectAllSourceFiles(this.getRootDir()),y=[],A=this.getConcurrency()??8;for(let O=0;O<u.length;O+=A){let Y=u.slice(O,O+A),me=await Promise.all(Y.filter(Ee=>eo(Ee)!==s).map(Ee=>this.findReferenceInFile(Ee,s,m)));for(let Ee of me)Ee&&y.push(Ee)}return dlt.debug("findReferencingFilesFallback found",y.length,"referencing files"),y}extractBasename(i){return i.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}};var plt=$l(require("node:fs/promises"));yg();Wh();var ult=Rd("ReverseIndex"),vLe=1,mL=class d{reverseMap=new Map;fileHashes=new Map;rootDir;constructor(i){this.rootDir=eo(i)}addDependencies(i,s,m){let u=eo(i);this.removeDependenciesFromSource(u);for(let y of s){let A=eo(y.path),O={sourcePath:u,type:y.type,line:y.line,module:y.module},Y=this.reverseMap.get(A);Y||(Y=new Map,this.reverseMap.set(A,Y)),Y.set(u,O)}m&&this.fileHashes.set(u,m)}removeDependenciesFromSource(i){let s=eo(i);for(let[,m]of this.reverseMap)m.delete(s);this.fileHashes.delete(s)}getReferencingFiles(i){let s=eo(i),m=this.reverseMap.get(s);return m?.size===0?(this.reverseMap.delete(s),[]):m?Array.from(m.values()).map(u=>({path:u.sourcePath,type:u.type,line:u.line,module:u.module})):[]}getCallerCount(i){let s=eo(i);return this.reverseMap.get(s)?.size??0}isFileStale(i,s){let m=eo(i),u=this.fileHashes.get(m);return u?u.mtime!==s.mtime||u.size!==s.size:!0}getFileHash(i){return this.fileHashes.get(eo(i))}updateFileHash(i,s){this.fileHashes.set(eo(i),s)}hasEntries(){return this.reverseMap.size>0}hasFile(i){return this.fileHashes.has(eo(i))}get indexedFileCount(){return this.fileHashes.size}get targetFileCount(){return this.reverseMap.size}clear(){this.reverseMap.clear(),this.fileHashes.clear()}cleanup(){let i=0,s=[];for(let[m,u]of this.reverseMap)u.size===0&&s.push(m);for(let m of s)this.reverseMap.delete(m),i++;return i}static async getFileHashFromDisk(i){try{let s=await plt.stat(i);return{mtime:s.mtimeMs,size:s.size}}catch{return null}}serialize(){let i={};for(let[m,u]of this.reverseMap)i[m]=Array.from(u.values());let s={};for(let[m,u]of this.fileHashes)s[m]=u;return{version:vLe,timestamp:Date.now(),rootDir:this.rootDir,reverseMap:i,fileHashes:s}}static deserialize(i,s){let m=eo(s),u=eo(i.rootDir);if(i.version!==vLe)return ult.warn("Version mismatch:",i.version,"!==",vLe),null;if(u!==m)return ult.warn("Root dir mismatch:",i.rootDir,"!==",s),null;let y=new d(s);for(let[A,O]of Object.entries(i.fileHashes))y.fileHashes.set(eo(A),O);for(let[A,O]of Object.entries(i.reverseMap)){let Y=eo(A),me=new Map;for(let Ee of O){let we=eo(Ee.sourcePath);me.set(we,{...Ee,sourcePath:we})}y.reverseMap.set(Y,me)}return y}async validateIndex(i=.2){let s=[],m=[];for(let O of this.fileHashes.keys()){let Y=await d.getFileHashFromDisk(O);if(!Y){m.push(O);continue}this.isFileStale(O,Y)&&s.push(O)}let u=this.fileHashes.size,y=s.length+m.length,A=u>0?y/u:0;return{isValid:A<=i,staleFiles:s,stalePercentage:A,missingFiles:m}}getStats(){let i=0;for(let s of this.reverseMap.values())i+=s.size;return{indexedFiles:this.fileHashes.size,targetFiles:this.reverseMap.size,totalReferences:i}}};bLe();var Q3=class{constructor(i){this.rootDir=i}reverseIndex=null;symbolReverseIndex=null;enable(i){let s=!1;if(this.reverseIndex??=new mL(this.rootDir),this.symbolReverseIndex??=new Y3(this.rootDir),i)try{let m=JSON.parse(i),u=mL.deserialize(m,this.rootDir);u&&(this.reverseIndex=u,s=!0)}catch{s=!1}return s}disable(){this.reverseIndex?.clear(),this.reverseIndex=null,this.symbolReverseIndex?.clear(),this.symbolReverseIndex=null}clear(){this.reverseIndex?.clear(),this.symbolReverseIndex?.clear()}isEnabled(){return this.reverseIndex!==null}hasEntries(){return this.reverseIndex?.hasEntries()??!1}ensure(){this.reverseIndex??=new mL(this.rootDir)}addDependencies(i,s,m){this.reverseIndex?.addDependencies(i,s,m)}removeDependenciesFromSource(i){this.reverseIndex?.removeDependenciesFromSource(i)}getReferencingFiles(i){return this.reverseIndex?this.reverseIndex.getReferencingFiles(i):[]}getCallerCount(i){return this.reverseIndex?this.reverseIndex.getCallerCount(i):0}getSerialized(){return this.reverseIndex?JSON.stringify(this.reverseIndex.serialize()):null}validate(i=.2){return this.reverseIndex?.validateIndex(i)??null}getStats(){return this.reverseIndex?.getStats()}addSymbolDependencies(i,s,m){this.symbolReverseIndex?.addDependencies(i,s,m)}removeSymbolDependenciesFromSource(i){this.symbolReverseIndex?.removeDependenciesFromSource(i)}getSymbolReferencingFiles(i){return this.symbolReverseIndex?.getCallerFiles(i)??[]}getSymbolStats(){return this.symbolReverseIndex?.getStats()}};Qce();Qce();yg();var ez=class{constructor(i,s,m){this.dependencyCache=i;this.symbolCache=s;this.reverseIndexManager=m}clearAll(){this.dependencyCache.clear(),this.symbolCache.clear(),this.reverseIndexManager.clear()}invalidateFile(i){let s=eo(i),m=this.dependencyCache.has(s);return this.dependencyCache.delete(s),this.symbolCache.delete(s),this.reverseIndexManager.removeDependenciesFromSource(s),m}invalidateFiles(i){let s=0;for(let m of i)this.invalidateFile(m)&&s++;return s}handleFileDeleted(i){let s=eo(i);this.dependencyCache.delete(s),this.symbolCache.delete(s),this.reverseIndexManager.removeDependenciesFromSource(s)}};yg();Wh();var tz=Rd("SpiderDependencyAnalyzer"),nz=class{constructor(i,s,m,u){this.languageService=i;this.resolver=s;this.dependencyCache=m;this.reverseIndexManager=u}async analyze(i){let s=eo(i),m=this.dependencyCache.get(s);if(m)return tz.debug(`Returning ${m.length} cached dependencies for ${i}`),await this.updateReverseIndexIfEnabled(i,s,m),m;tz.debug(`Analyzing ${i}...`);try{let u=this.languageService.getAnalyzer(i),y=await u.parseImports(i);tz.debug(`Parsed ${y.length} imports from ${i}`);let A=[],O=new Set;for(let Y of y){let me=await u.resolvePath(i,Y.module);if(!me){tz.debug(`Failed to resolve module "${Y.module}" from ${i}`);continue}let Ee=eo(me);O.has(Ee)||(O.add(Ee),A.push({path:Ee,type:Y.type,line:Y.line,module:Y.module}))}return tz.debug(`Resolved ${A.length} dependencies for ${i}`),this.dependencyCache.set(s,A),await this.updateReverseIndexIfEnabled(i,s,A),A}catch(u){let y=xp.fromError(u,i);throw tz.error("Analysis failed:",y.toUserMessage(),y.code),y}}async resolveModuleSpecifier(i,s){try{return await this.resolver.resolve(i,s)}catch{return null}}invalidateDependencyCache(i){this.dependencyCache.delete(eo(i))}async updateReverseIndexIfEnabled(i,s,m){if(!this.reverseIndexManager.isEnabled()||m.length===0)return;let u=await mL.getFileHashFromDisk(i);u&&this.reverseIndexManager.addDependencies(s,m,u)}};yg();bU();yg();function GO(d){let s=eo(d).split("/");for(let m=0;m<s.length-1;m++)if(die.includes(s[m]))return!0;return!1}Wh();var hL=Rd("SpiderGraphCrawler"),rz=class{constructor(i,s){this.dependencyAnalyzer=i;this.getConfig=s}async crawl(i){let s=new Set,m=[],u=new Set,y=new Set,A={};hL.debug(`Starting crawl from: ${i}`);let O=async(Y,me)=>{let Ee=eo(Y),we=this.getConfig().maxDepth??3;if(me>we){hL.debug(`Skipping ${Y}: max depth ${we} reached`);return}if(y.has(Ee)){hL.debug(`Skipping ${Y}: already visited`);return}y.add(Ee),s.add(Ee);try{let de=await this.dependencyAnalyzer.analyze(Y);hL.debug(`Found ${de.length} dependencies for ${Y}`);for(let ht of de){s.add(ht.path);let Je=`${Ee}->${ht.path}`;u.has(Je)||(u.add(Je),m.push({source:Ee,target:ht.path}),hL.debug(`Added edge: ${Ee} -> ${ht.path}`)),ht.module.startsWith("@")&&ht.module.includes("/")&&!ht.module.startsWith("@/")&&(A[ht.path]=ht.module),GO(ht.path)?hL.debug(`Skipping ${ht.path}: in ignored directory`):await O(ht.path,me+1)}}catch(de){hL.debug(`Failed to analyze ${Y}: ${de}`)}};return await O(i,0),hL.debug(`Crawl completed: ${s.size} nodes, ${m.length} edges`),{nodes:Array.from(s),edges:m,nodeLabels:Object.keys(A).length>0?A:void 0}}async crawlFrom(i,s,m=10,u){let y=new Set,A=[],O=new Set,Y={},me=new Set(Array.from(s).map(Gn=>eo(Gn))),Ee=eo(i),we=new Set,de=[],ht=new Set,Je={},et=u?.batchSize??200,yr=()=>{if(u?.signal?.aborted){let Gn=new Error("Expansion cancelled");throw Gn.name="AbortError",Gn}},Gr=(Gn,bn)=>bn>m?!0:Gn===Ee?bn!==0&&O.has(Gn):O.has(Gn),Ei=Gn=>{me.has(Gn)||(y.add(Gn),we.add(Gn))},$o=(Gn,bn)=>{let gi=`${bn}->${Gn.path}`;ht.has(gi)||(ht.add(gi),A.push({source:bn,target:Gn.path}),de.push({source:bn,target:Gn.path})),!O.has(Gn.path)&&!me.has(Gn.path)&&(y.add(Gn.path),we.add(Gn.path)),Gn.module.startsWith("@")&&Gn.module.includes("/")&&!Gn.module.startsWith("@/")&&(Y[Gn.path]=Gn.module,Je[Gn.path]=Gn.module)},Ja=async()=>{if(!u?.onBatch){we.clear(),de.length=0;return}if(we.size===0&&de.length===0)return;let Gn={nodes:Array.from(we),edges:[...de],nodeLabels:Object.keys(Je).length>0?{...Je}:void 0};we.clear(),de.length=0;for(let bn of Object.keys(Je))delete Je[bn];await u.onBatch(Gn)},No=async(Gn,bn)=>{yr();let gi=eo(Gn);if(!Gr(gi,bn)){O.add(gi),Ei(gi);try{let Ur=await this.dependencyAnalyzer.analyze(Gn);for(let cr of Ur)$o(cr,gi),GO(cr.path)||await No(cr.path,bn+1);we.size+de.length>=et&&await Ja()}catch{}}};return await No(i,0),await Ja(),{nodes:Array.from(y),edges:A,nodeLabels:Object.keys(Y).length>0?Y:void 0}}};var iz=class{cancelled=!1;reset(){this.cancelled=!1}cancel(){this.cancelled=!0}isCancelled(){return this.cancelled}};Wh();yg();function oz(){return new Promise(d=>setTimeout(d,1))}var az=50;var VO=Rd("SpiderIndexingService"),sz=class{constructor(i,s,m,u,y,A,O,Y,me,Ee){this.dependencyAnalyzer=i;this.dependencyCache=s;this.reverseIndexManager=m;this.sourceFileCollector=u;this.indexerStatus=y;this.workerManager=A;this.cancellation=O;this.getConfig=Y;this.yieldToEventLoop=me;this.getSymbolGraph=Ee}cancel(){this.cancellation.cancel(),this.workerManager.cancel()}disposeWorker(){this.workerManager.dispose()}async analyzeFileForIndex(i,s){try{if(await this.dependencyAnalyzer.analyze(i),this.getSymbolGraph&&s<(this.getConfig().maxSymbolAnalyzerFiles??100))try{let m=await this.getSymbolGraph(i);m.dependencies.length>0&&this.reverseIndexManager.addSymbolDependencies(i,m.dependencies)}catch{}return!0}catch{return!1}}checkCancellation(i){if(this.cancellation.isCancelled())return this.indexerStatus.setCancelled(),{indexedFiles:i,duration:Date.now()-(this.indexerStatus.getSnapshot().startTime??Date.now()),cancelled:!0}}async buildFullIndex(i){this.reverseIndexManager.ensure(),this.cancellation.reset(),this.indexerStatus.startCounting();let s=await this.sourceFileCollector.collectAllSourceFiles(this.getConfig().rootDir),m=this.checkCancellation(0);if(m)return m;let u=s.length;this.indexerStatus.setTotal(u),await this.yieldToEventLoop(),this.indexerStatus.startIndexing();let y=0,A=Date.now();try{for(let me of s){let Ee=this.checkCancellation(y);if(Ee)return Ee;await this.analyzeFileForIndex(me,y),y++,this.indexerStatus.updateProgress(y,me),i?.(y,u,me),Date.now()-A>=az&&(await this.yieldToEventLoop(),A=Date.now())}this.indexerStatus.complete();let O=this.indexerStatus.getSnapshot(),Y=Date.now()-(O.startTime??Date.now());return{indexedFiles:y,duration:Y,cancelled:!1}}catch(O){let Y=xp.fromError(O);throw this.indexerStatus.setError(Y.toUserMessage()),VO.error("Indexing failed:",Y.toUserMessage(),Y.code),Y}}async buildFullIndexInWorker(i,s){let m=this.getConfig();return this.workerManager.buildFullIndexInWorker({workerPath:i,progressCallback:s,config:{rootDir:m.rootDir,excludeNodeModules:m.excludeNodeModules,tsConfigPath:m.tsConfigPath,progressInterval:m.indexingProgressInterval,extensionPath:m.extensionPath}})}async reindexStaleFiles(i,s){if(!this.reverseIndexManager.isEnabled())return 0;VO.info(`Re-indexing ${i.length} stale files`);let m=this.getConfig().indexingConcurrency??8,u=0;for(let y=0;y<i.length;y+=m){let A=i.slice(y,y+m);await Promise.all(A.map(async O=>{let Y=eo(O);VO.debug(`Re-indexing stale file: ${O}`);try{this.reverseIndexManager.removeDependenciesFromSource(Y),this.dependencyCache.delete(Y),VO.debug(`Deleted cache for ${O}, re-analyzing...`),await this.dependencyAnalyzer.analyze(O),VO.debug(`Successfully re-analyzed ${O}`)}catch(me){VO.error(`Failed to re-index ${O}:`,me),this.reverseIndexManager.removeDependenciesFromSource(Y)}})),u+=A.length,s?.(u,i.length,A.at(-1)),await this.yieldToEventLoop()}return VO.info(`Completed re-indexing ${u} files`),u}};yg();var lz=class{constructor(i,s,m){this.reverseIndexManager=i;this.dependencyAnalyzer=s;this.fileReader=m}fallbackFinder=null;_fallbackCache=new Map;_fallbackCacheVersion=0;_fallbackCacheEntryVersion=new Map;setFallbackFinder(i){this.fallbackFinder=i}clearFallbackCache(){this._fallbackCacheVersion++}async findReferencingFiles(i){if(this.reverseIndexManager.hasEntries())return this.reverseIndexManager.getReferencingFiles(i);if(this._fallbackCacheEntryVersion.get(i)===this._fallbackCacheVersion){let u=this._fallbackCache.get(i);if(u!==void 0)return u}let m=this.fallbackFinder?await this.fallbackFinder.findReferencingFilesFallback(i):[];return this._fallbackCache.set(i,m),this._fallbackCacheEntryVersion.set(i,this._fallbackCacheVersion),m}async findReferenceInFile(i,s,m){try{if(!(await this.fileReader.readFile(i)).includes(m))return null;let A=(await this.dependencyAnalyzer.analyze(i)).find(O=>eo(O.path)===s);return A?{path:eo(i),type:A.type,line:A.line,module:A.module}:null}catch{return null}}};var blt=$l(require("node:path"));yg();Wh();var jO=Rd("SpiderSymbolService"),cz=class{constructor(i,s,m,u,y,A,O,Y){this.astWorkerHost=i;this.symbolCache=s;this.fileReader=m;this.resolver=u;this.symbolDependencyHelper=y;this.getConfig=A;this.findReferencingFiles=O;this.languageService=Y}async getSymbolGraph(i){if(!blt.default.isAbsolute(i))try{let u=await this.resolveModuleSpecifier(this.getConfig().rootDir,i);u&&(i=u)}catch{}let s=eo(i),m=this.symbolCache.get(s);if(m)return m;try{let u=await this.fileReader.readFile(i),y=await this.astWorkerHost.analyzeFile(s,u),A=await Promise.all(y.dependencies.map(async Y=>{try{let Ee=await this.languageService.getAnalyzer(s).resolvePath(s,Y.targetFilePath);if(Ee)return{...Y,targetFilePath:eo(Ee)}}catch{}return Y})),O={symbols:y.symbols,dependencies:A};return this.symbolCache.set(s,O),O}catch(u){let y=xp.fromError(u,i);if(jO.error("Symbol analysis failed:",y.toUserMessage()),y.isRecoverable())return{symbols:[],dependencies:[]};throw y}}async findUnusedSymbols(i){try{let s=eo(i),{symbols:m}=await this.getSymbolGraph(s),u=m.filter(Ee=>Ee.isExported);if(u.length===0)return[];let y=await this.findReferencingFiles(s),A=await this.collectUsedSymbolIds(y,s),O=await this.fileReader.readFile(s),Y=await this.astWorkerHost.getInternalExportDependencyGraph(s,O),me=this.expandUsedSymbolsViaInternalGraph(A,Y);return u.filter(Ee=>!me.has(Ee.id))}catch(s){let m=xp.fromError(s,i);return jO.error("Find unused symbols failed:",m.toUserMessage()),[]}}async getSymbolDependents(i,s){let m=await this.findReferencingFiles(i);return this.collectSymbolDependents(m,i,s)}async traceFunctionExecution(i,s,m=10){let u=`${i}:${s}`,y=[],A=new Set,O=!1,Y=async(me,Ee,we)=>{if(we>m){O=!0;return}let de=`${me}:${Ee}`;if(!A.has(de)){A.add(de);try{let{symbols:ht,dependencies:Je}=await this.getSymbolGraph(me),et=ht.find(Gr=>Gr.name===Ee);if(!et)return;let yr=Je.filter(Gr=>Gr.sourceSymbolId===et.id);for(let Gr of yr){let Ei=null;try{Ei=await this.resolver.resolve(me,Gr.targetFilePath)}catch{}let $o=Gr.targetSymbolId.split(":").pop()||"";y.push({depth:we,callerSymbolId:de,calledSymbolId:Gr.targetSymbolId,calledFilePath:Gr.targetFilePath,resolvedFilePath:Ei}),Ei&&!GO(Ei)&&await Y(Ei,$o,we+1)}}catch(ht){let Je=xp.fromError(ht,me);jO.error("Trace execution failed:",de,Je.toUserMessage())}}};return await Y(i,s,1),{rootSymbol:{id:u,filePath:i,symbolName:s},callChain:y,visitedSymbols:Array.from(A),maxDepthReached:O}}async resolveModuleSpecifier(i,s){try{return await this.resolver.resolve(i,s)}catch{return null}}expandUsedSymbolsViaInternalGraph(i,s){let m=new Set(i),u=Array.from(m);for(;u.length>0;){let y=u.pop(),A=s.get(y);if(A)for(let O of A)m.has(O)||(m.add(O),u.push(O))}return m}async collectUsedSymbolIds(i,s){let m=new Set;for(let u of i){let{dependencies:y}=await this.getSymbolGraph(u.path);for(let A of y)if(await this.symbolDependencyHelper.doesDependencyTargetFile(A,u.path,s)){let Y=this.symbolDependencyHelper.extractSymbolName(A.targetSymbolId);m.add(this.symbolDependencyHelper.buildUsedSymbolId(s,Y))}}return m}async collectSymbolDependents(i,s,m){let u=[],y=eo(s);for(let A of i){let{dependencies:O}=await this.getSymbolGraph(A.path);for(let Y of O)await this.symbolDependencyHelper.doesDependencyTargetFile(Y,A.path,y)&&this.symbolDependencyHelper.extractSymbolName(Y.targetSymbolId)===m&&u.push(Y)}return u}async verifyDependencyUsage(i,s){try{let m=eo(i),u=eo(s);if(GO(u))return!0;if(this.isGraphQLFile(m))return jO.debug(`Skipping symbol analysis for GraphQL file: ${m}`),!0;let{dependencies:y}=await this.getSymbolGraph(m);if(y.length===0)return!1;let A=u.split("/").pop()||"",O=y.filter(Y=>Y.targetFilePath===u||Y.targetFilePath.includes(A)||!Y.targetFilePath.startsWith("/"));for(let Y of O)if(await this.symbolDependencyHelper.doesDependencyTargetFile(Y,m,u))return!0;return!1}catch(m){let u=xp.fromError(m,i);return jO.warn("Usage verification failed, assuming used:",u.message),!0}}async verifyDependencyUsageBatch(i,s){try{let m=eo(i);if(this.isGraphQLFile(m))return jO.debug(`Skipping symbol analysis for GraphQL file: ${m}`),this.markAllAsUsed(s);let{dependencies:u}=await this.getSymbolGraph(m);if(u.length===0)return this.markAllAsUnused(s);let y=await this.buildResolvedTargetsSet(u,m);return this.checkTargetsAgainstResolved(s,y)}catch(m){let u=xp.fromError(m,i);return jO.warn("Batch usage verification failed, assuming all used:",u.message),this.markAllAsUsed(s)}}markAllAsUsed(i){let s=new Map;for(let m of i)s.set(eo(m),!0);return s}markAllAsUnused(i){let s=new Map;for(let m of i)s.set(eo(m),!1);return s}async buildResolvedTargetsSet(i,s){let m=new Set;for(let u of i)try{let y=await this.symbolDependencyHelper.resolveTargetPath(u,s);y&&m.add(eo(y))}catch{}return m}checkTargetsAgainstResolved(i,s){let m=new Map;for(let u of i){let y=eo(u);if(GO(y)){m.set(y,!0);continue}m.set(y,s.has(y))}return m}isGraphQLFile(i){return i.endsWith(".gql")||i.endsWith(".graphql")}};var Slt=require("node:worker_threads"),Tlt=$l(require("node:path")),ede=class{worker=null;statusCallbacks=new Set;currentState="idle";currentProgress=0;currentTotal=0;currentFile="";startTime=void 0;cancelled=!1;workerPath;constructor(i){this.workerPath=i??Tlt.join(__dirname,"indexerWorker.js")}subscribeToStatus(i){return this.statusCallbacks.add(i),i(this.getSnapshot()),()=>this.statusCallbacks.delete(i)}getSnapshot(){let i=this.currentTotal>0?Math.round(this.currentProgress/this.currentTotal*100):0;return{state:this.currentState,processed:this.currentProgress,total:this.currentTotal,currentFile:this.currentFile,percentage:i,startTime:this.startTime,cancelled:this.cancelled}}notifySubscribers(){let i=this.getSnapshot();for(let s of this.statusCallbacks)try{s(i)}catch{}}updateState(i,s=0,m=0,u=""){this.currentState=i,this.currentProgress=s,this.currentTotal=m,this.currentFile=u,this.notifySubscribers()}async startIndexing(i){if(this.worker)throw new Error("Indexing already in progress");return this.cancelled=!1,this.startTime=Date.now(),this.updateState("counting"),new Promise((s,m)=>{try{this.worker=new Slt.Worker(this.workerPath,{workerData:i});let u={indexedFiles:0,duration:0,cancelled:!1,data:[]};this.worker.on("message",y=>{switch(y.type){case"counting":this.updateState("counting");break;case"progress":y.data&&this.updateState("indexing",y.data.processed??0,y.data.total??0,y.data.currentFile??"");break;case"complete":y.data&&(u={indexedFiles:y.data.processed??0,duration:y.data.duration??0,cancelled:this.cancelled,data:y.data.indexData??[]}),this.updateState("complete"),this.cleanupWorker(),s(u);break;case"error":this.updateState("error"),this.cleanupWorker(),m(new Error(y.error??"Unknown worker error"));break}}),this.worker.on("error",y=>{this.updateState("error"),this.cleanupWorker(),m(y)}),this.worker.on("exit",y=>{y!==0&&this.currentState!=="complete"&&this.currentState!=="error"&&(this.updateState("error"),this.cleanupWorker(),m(new Error(`Worker stopped with exit code ${y}`)))}),this.worker.postMessage({type:"start"})}catch(u){this.updateState("error"),this.cleanupWorker(),m(u)}})}cancel(){this.cancelled=!0,this.worker&&this.worker.postMessage({type:"cancel"})}isIndexing(){return this.currentState==="indexing"||this.currentState==="counting"}cleanupWorker(){this.worker&&(this.worker.removeAllListeners(),this.worker.terminate().catch(()=>{}),this.worker=null)}dispose(){this.cancel(),this.cleanupWorker(),this.statusCallbacks.clear()}};yg();var dz=class{constructor(i,s,m){this.indexerStatus=i;this.reverseIndexManager=s;this.dependencyCache=m}workerHost=null;async buildFullIndexInWorker(i){let{workerPath:s,config:m,progressCallback:u}=i;this.workerHost??=new ede(s),this.reverseIndexManager.ensure();let y=this.workerHost.subscribeToStatus(A=>{switch(A.state){case"counting":this.indexerStatus.startCounting();break;case"indexing":A.total>0&&(this.indexerStatus.setTotal(A.total),this.indexerStatus.startIndexing()),this.indexerStatus.updateProgress(A.processed,A.currentFile);break;case"complete":this.indexerStatus.complete();break;case"error":this.indexerStatus.setError(A.errorMessage??"Unknown error");break}u&&A.state==="indexing"&&u(A.processed,A.total,A.currentFile)});try{let A=await this.workerHost.startIndexing({rootDir:m.rootDir,excludeNodeModules:m.excludeNodeModules,tsConfigPath:m.tsConfigPath,extensionPath:m.extensionPath});return this.importWorkerResult(A),{indexedFiles:A.indexedFiles,duration:A.duration,cancelled:A.cancelled}}finally{y()}}cancel(){this.workerHost?.cancel()}dispose(){this.workerHost?.dispose(),this.workerHost=null}importWorkerResult(i){for(let s of i.data){let m=eo(s.filePath);this.dependencyCache.set(m,s.dependencies),this.reverseIndexManager.addDependencies(m,s.dependencies,{mtime:s.mtime,size:s.size})}}};yg();Wh();var uz=Rd("SymbolDependencyHelper"),pz=class{resolveFn;constructor(i){this.resolveFn=i.resolve}async doesDependencyTargetFile(i,s,m){let u=eo(i.targetFilePath),y=eo(m);if(uz.debug(`Comparing: dep.targetFilePath='${u}' vs targetFilePath='${y}'`),u===y)return uz.debug("\u2713 Direct match"),!0;uz.debug(`Attempting fallback resolution for '${i.targetFilePath}' from '${s}'`);let A=await this.resolveFn(s,i.targetFilePath);if(A){let O=eo(A);uz.debug(`Resolved to: '${O}'`);let Y=O===y;return uz.debug(Y?"\u2713 Fallback match":"\u2717 No match after resolution"),Y}return uz.debug("\u2717 Resolution failed, no match"),!1}extractSymbolName(i){return i.split(":").pop()||""}extractBasename(i){return i.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}buildUsedSymbolId(i,s){return`${eo(i)}:${s}`}async resolveTargetPath(i,s){let m=eo(i.targetFilePath);if(m.startsWith("/")||/^[a-zA-Z]:\//.test(m))return m;try{let u=await this.resolveFn(s,i.targetFilePath);return u?eo(u):null}catch{return null}}};var tde=class{config;languageService;resolver;cache;symbolCache;fileReader;astWorkerHost;reverseIndexManager;indexerStatus;workerManager;cancellation;sourceFileCollector;referencingFilesFinder;symbolDependencyHelper;dependencyAnalyzer;referenceLookup;symbolService;graphCrawler;indexingService;cacheCoordinator;constructor(i){if("dependencyAnalyzer"in i){let s=i;this.config=s.config,this.languageService=s.languageService,this.resolver=s.resolver,this.cache=s.cache,this.symbolCache=s.symbolCache,this.fileReader=s.fileReader,this.astWorkerHost=s.astWorkerHost,this.reverseIndexManager=s.reverseIndexManager,this.indexerStatus=s.indexerStatus,this.workerManager=s.workerManager,this.cancellation=s.cancellation,this.sourceFileCollector=s.sourceFileCollector,this.referencingFilesFinder=s.referencingFilesFinder,this.symbolDependencyHelper=s.symbolDependencyHelper,this.dependencyAnalyzer=s.dependencyAnalyzer,this.referenceLookup=s.referenceLookup,this.symbolService=s.symbolService,this.graphCrawler=s.graphCrawler,this.indexingService=s.indexingService,this.cacheCoordinator=s.cacheCoordinator}else{let s=i;this.config={maxDepth:50,excludeNodeModules:!0,enableReverseIndex:!1,indexingConcurrency:4,maxCacheSize:500,maxSymbolCacheSize:200,maxSymbolAnalyzerFiles:100,...s},this.languageService=new q3(s.rootDir,s.tsConfigPath,s.extensionPath),this.resolver=new mD(s.tsConfigPath,this.config.excludeNodeModules,s.rootDir),this.cache=new QM({maxSize:this.config.maxCacheSize,enableLRU:!0}),this.symbolCache=new QM({maxSize:this.config.maxSymbolCacheSize,enableLRU:!0}),this.astWorkerHost=new YM(void 0,s.extensionPath),this.reverseIndexManager=new Q3(this.config.rootDir),this.fileReader=new cy,this.indexerStatus=new v3,this.cancellation=new iz,this.workerManager=new dz(this.indexerStatus,this.reverseIndexManager,this.cache),this.dependencyAnalyzer=new nz(this.languageService,this.resolver,this.cache,this.reverseIndexManager),this.sourceFileCollector=new _L({excludeNodeModules:this.config.excludeNodeModules??!0,yieldIntervalMs:az,yieldCallback:()=>oz(),isCancelled:()=>this.cancellation.isCancelled()}),this.referenceLookup=new lz(this.reverseIndexManager,this.dependencyAnalyzer,this.fileReader),this.referencingFilesFinder=new X3({sourceFileCollector:this.sourceFileCollector,getRootDir:()=>this.config.rootDir,getConcurrency:()=>this.config.indexingConcurrency,findReferenceInFile:(m,u,y)=>this.referenceLookup.findReferenceInFile(m,u,y)}),this.referenceLookup.setFallbackFinder(this.referencingFilesFinder),this.symbolDependencyHelper=new pz({resolve:async(m,u)=>{try{return await this.resolver.resolve(m,u)}catch{return null}}}),this.symbolService=new cz(this.astWorkerHost,this.symbolCache,this.fileReader,this.resolver,this.symbolDependencyHelper,()=>this.config,m=>this.findReferencingFiles(m),this.languageService),this.graphCrawler=new rz(this.dependencyAnalyzer,()=>this.config),this.indexingService=new sz(this.dependencyAnalyzer,this.cache,this.reverseIndexManager,this.sourceFileCollector,this.indexerStatus,this.workerManager,this.cancellation,()=>this.config,()=>oz(),m=>this.symbolService.getSymbolGraph(m)),this.cacheCoordinator=new ez(this.cache,this.symbolCache,this.reverseIndexManager),s.enableReverseIndex&&this.enableReverseIndex()}}async dispose(){await this.astWorkerHost.stop()}updateConfig(i){this.config.excludeNodeModules=i.excludeNodeModules??this.config.excludeNodeModules,this.config.maxDepth=i.maxDepth??this.config.maxDepth,i.excludeNodeModules!==void 0&&(this.resolver.updateConfig(i.excludeNodeModules),this.sourceFileCollector.updateOptions({excludeNodeModules:i.excludeNodeModules})),i.enableReverseIndex!==void 0&&(this.config.enableReverseIndex=i.enableReverseIndex,i.enableReverseIndex?this.reverseIndexManager.enable():this.reverseIndexManager.disable()),i.indexingConcurrency!==void 0&&(this.config.indexingConcurrency=i.indexingConcurrency),this.clearCache()}async analyze(i){return this.dependencyAnalyzer.analyze(i)}clearCache(){this.cacheCoordinator.clearAll(),this.referenceLookup.clearFallbackCache()}invalidateFile(i){return this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.invalidateFile(i)}invalidateFiles(i){return this.cacheCoordinator.invalidateFiles(i)}async reanalyzeFile(i){this.invalidateFile(i);try{return await this.analyze(i)}catch{return null}}handleFileDeleted(i){this.cacheCoordinator.handleFileDeleted(i)}enableReverseIndex(i){let s=this.reverseIndexManager.enable(i);return this.config.enableReverseIndex=!0,s}disableReverseIndex(){this.config.enableReverseIndex=!1,this.reverseIndexManager.disable()}getSerializedReverseIndex(){return this.reverseIndexManager.getSerialized()}async validateReverseIndex(i=.2){return this.reverseIndexManager.validate(i)}getIndexStatus(){return this.indexerStatus.getSnapshot()}subscribeToIndexStatus(i){return this.indexerStatus.subscribe(i)}hasReverseIndex(){return this.reverseIndexManager.hasEntries()}getCallerCount(i){return this.reverseIndexManager.hasEntries()?this.reverseIndexManager.getCallerCount(i):0}cancelIndexing(){this.indexingService.cancel()}async buildFullIndex(i){return this.indexingService.buildFullIndex(i)}async buildFullIndexInWorker(i,s){return this.indexingService.buildFullIndexInWorker(i,s)}disposeWorker(){this.indexingService.disposeWorker()}async reindexStaleFiles(i,s){return this.indexingService.reindexStaleFiles(i,s)}async crawl(i){return this.graphCrawler.crawl(i)}async crawlFrom(i,s,m=10,u){return this.graphCrawler.crawlFrom(i,s,m,u)}async findReferencingFiles(i){return this.referenceLookup.findReferencingFiles(i)}getSymbolReferencingFiles(i){if(!this.reverseIndexManager.hasEntries())return new Set;let s=this.reverseIndexManager.getSymbolReferencingFiles(i);return new Set(s)}async getSymbolGraph(i){return this.symbolService.getSymbolGraph(i)}async resolveModuleSpecifier(i,s){return this.dependencyAnalyzer.resolveModuleSpecifier(i,s)}async findUnusedSymbols(i){return this.symbolService.findUnusedSymbols(i)}async verifyDependencyUsage(i,s){return this.symbolService.verifyDependencyUsage(i,s)}async verifyDependencyUsageBatch(i,s){return this.symbolService.verifyDependencyUsageBatch(i,s)}async getSymbolDependents(i,s){return this.symbolService.getSymbolDependents(i,s)}async traceFunctionExecution(i,s,m=10){return this.symbolService.traceFunctionExecution(i,s,m)}getCacheStats(){return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:0,reverseIndexStats:this.reverseIndexManager.getStats()}}async getCacheStatsAsync(){let i=0;try{i=await this.astWorkerHost.getFileCount()}catch{}return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:i,reverseIndexStats:this.reverseIndexManager.getStats()}}};var nde=class{rootDir;tsConfigPath;extensionPath;maxDepth=50;excludeNodeModules=!0;enableReverseIndex=!1;indexingConcurrency=4;maxCacheSize=500;maxSymbolCacheSize=200;maxSymbolAnalyzerFiles=100;indexingProgressInterval;customCache;customSymbolCache;customLanguageService;customPathResolver;customAstWorkerHost;customReverseIndexManager;withRootDir(i){return this.rootDir=i,this}withTsConfigPath(i){return this.tsConfigPath=i,this}withExtensionPath(i){return this.extensionPath=i,this}withMaxDepth(i){return this.maxDepth=i,this}withExcludeNodeModules(i){return this.excludeNodeModules=i,this}withReverseIndex(i){return this.enableReverseIndex=i,this}withIndexingConcurrency(i){return this.indexingConcurrency=i,this}withCacheConfig(i){return i.maxCacheSize!==void 0&&(this.maxCacheSize=i.maxCacheSize),i.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=i.maxSymbolCacheSize),i.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=i.maxSymbolAnalyzerFiles),this}withIndexingProgressInterval(i){return this.indexingProgressInterval=i,this}withConfig(i){return this.rootDir=i.rootDir,i.tsConfigPath!==void 0&&(this.tsConfigPath=i.tsConfigPath),i.extensionPath!==void 0&&(this.extensionPath=i.extensionPath),i.maxDepth!==void 0&&(this.maxDepth=i.maxDepth),i.excludeNodeModules!==void 0&&(this.excludeNodeModules=i.excludeNodeModules),i.enableReverseIndex!==void 0&&(this.enableReverseIndex=i.enableReverseIndex),i.indexingConcurrency!==void 0&&(this.indexingConcurrency=i.indexingConcurrency),i.maxCacheSize!==void 0&&(this.maxCacheSize=i.maxCacheSize),i.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=i.maxSymbolCacheSize),i.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=i.maxSymbolAnalyzerFiles),i.indexingProgressInterval!==void 0&&(this.indexingProgressInterval=i.indexingProgressInterval),this}withCache(i){return this.customCache=i,this}withSymbolCache(i){return this.customSymbolCache=i,this}withLanguageService(i){return this.customLanguageService=i,this}withPathResolver(i){return this.customPathResolver=i,this}withAstWorkerHost(i){return this.customAstWorkerHost=i,this}withReverseIndexManager(i){return this.customReverseIndexManager=i,this}build(){this.validate();let i=this.initializeServices();return new tde(i)}initializeServices(){let i=this.buildConfig(),s=this.customLanguageService??new q3(this.rootDir,this.tsConfigPath,this.extensionPath),m=this.customPathResolver??new mD(this.tsConfigPath,this.excludeNodeModules,this.rootDir),u=this.customCache??new QM({maxSize:this.maxCacheSize,enableLRU:!0}),y=this.customSymbolCache??new QM({maxSize:this.maxSymbolCacheSize,enableLRU:!0}),A=this.customAstWorkerHost??new YM(void 0,this.extensionPath),O=this.customReverseIndexManager??new Q3(this.rootDir),Y=new cy,me=new v3,Ee=new iz,we=new dz(me,O,u),de=new nz(s,m,u,O),ht=new _L({excludeNodeModules:this.excludeNodeModules,yieldIntervalMs:az,yieldCallback:()=>oz(),isCancelled:()=>Ee.isCancelled()}),Je=new lz(O,de,Y),et=new X3({sourceFileCollector:ht,getRootDir:()=>this.rootDir,getConcurrency:()=>this.indexingConcurrency,findReferenceInFile:(No,Gn,bn)=>Je.findReferenceInFile(No,Gn,bn)});Je.setFallbackFinder(et);let yr=new pz({resolve:async(No,Gn)=>{try{return await m.resolve(No,Gn)}catch{return null}}}),Gr=new cz(A,y,Y,m,yr,()=>i,No=>Je.findReferencingFiles(No),s),Ei=new rz(de,()=>i),$o=new sz(de,u,O,ht,me,we,Ee,()=>i,()=>oz(),No=>Gr.getSymbolGraph(No)),Ja=new ez(u,y,O);return this.enableReverseIndex&&O.enable(),{config:i,languageService:s,resolver:m,cache:u,symbolCache:y,fileReader:Y,astWorkerHost:A,reverseIndexManager:O,indexerStatus:me,workerManager:we,cancellation:Ee,sourceFileCollector:ht,referencingFilesFinder:et,symbolDependencyHelper:yr,dependencyAnalyzer:de,referenceLookup:Je,symbolService:Gr,graphCrawler:Ei,indexingService:$o,cacheCoordinator:Ja}}validate(){if(!this.rootDir)throw new Error("rootDir is required");if(this.maxDepth<0)throw new Error("maxDepth must be non-negative");if(this.indexingConcurrency<1)throw new Error("indexingConcurrency must be at least 1");if(this.maxCacheSize<0)throw new Error("maxCacheSize must be non-negative");if(this.maxSymbolCacheSize<0)throw new Error("maxSymbolCacheSize must be non-negative");if(this.maxSymbolAnalyzerFiles<0)throw new Error("maxSymbolAnalyzerFiles must be non-negative")}buildConfig(){return{rootDir:this.rootDir,tsConfigPath:this.tsConfigPath,extensionPath:this.extensionPath,maxDepth:this.maxDepth,excludeNodeModules:this.excludeNodeModules,enableReverseIndex:this.enableReverseIndex,indexingConcurrency:this.indexingConcurrency,maxCacheSize:this.maxCacheSize,maxSymbolCacheSize:this.maxSymbolCacheSize,maxSymbolAnalyzerFiles:this.maxSymbolAnalyzerFiles,indexingProgressInterval:this.indexingProgressInterval}}};OE();Wh();yx();Int({createLogger(d,i){return new rie(d,i)}});oie.setDefaultLevel(Dnt("LOG_LEVEL"));var TLe=Rd("CliRuntime");function Elt(d){let i=jv.resolve(d),{root:s}=jv.parse(i);for(;i!==s;){if(PD.existsSync(jv.join(i,"package.json"))||PD.existsSync(jv.join(i,"tsconfig.json")))return i;i=jv.dirname(i)}return jv.resolve(d)}function jHt(d){let i=jv.join(d,"tsconfig.json");return PD.existsSync(i)?i:void 0}var rde=class{workspaceRoot;stateDir;_initialized=!1;constructor(i){this.workspaceRoot=jv.resolve(i),this.stateDir=jv.join(this.workspaceRoot,".graph-it")}get initialized(){return this._initialized}async init(){if(this._initialized)return;PD.mkdirSync(this.stateDir,{recursive:!0});let i=jHt(this.workspaceRoot);Pa.parser=new y3,Pa.resolver=new mD(i,!0,this.workspaceRoot),Pa.astWorkerHost=new YM(void 0,void 0),await Pa.astWorkerHost.start();let s=new nde().withRootDir(this.workspaceRoot).withMaxDepth(50).withExcludeNodeModules(!0).withReverseIndex(!0);i&&s.withTsConfigPath(i),Pa.spider=s.build(),Pa.config={rootDir:this.workspaceRoot,tsConfigPath:i,excludeNodeModules:!0,maxDepth:50,extensionPath:jv.resolve(__dirname,"..")},Pa.isReady=!0,this._initialized=!0,TLe.info("Runtime initialized for",this.workspaceRoot)}async ensureIndexed(){if(!this._initialized||!Pa.spider)throw new yu("Runtime not initialized. Call init() first.",Hc.WORKSPACE_NOT_FOUND);let i=Pa.spider,s=Date.now(),m=i.subscribeToIndexStatus(u=>{u.state==="indexing"&&process.stderr.write(`\r Indexing: ${u.processed}/${u.total} files...`)});try{let u=await i.buildFullIndex(),y=Date.now()-s;return process.stderr.write(`
42478
- `),TLe.info("Indexed",u.indexedFiles,"files in",u.duration,"ms"),this.saveState({lastScanTimestamp:new Date().toISOString(),filesIndexed:u.indexedFiles,workspaceRoot:this.workspaceRoot}),Pa.warmupInfo={completed:!0,durationMs:u.duration,filesIndexed:u.indexedFiles},{filesIndexed:u.indexedFiles,durationMs:y}}finally{m()}}async dispose(){Pa.astWorkerHost&&await Pa.astWorkerHost.stop(),Pa.spider&&await Pa.spider.dispose(),Pa.reset(),this._initialized=!1}saveState(i){try{PD.writeFileSync(jv.join(this.stateDir,"state.json"),JSON.stringify(i,null,2))}catch(s){TLe.warn("Could not save state:",s instanceof Error?s.message:String(s))}}loadState(){try{let i=PD.readFileSync(jv.join(this.stateDir,"state.json"),"utf-8");return JSON.parse(i)}catch{return null}}};var $qt="0.0.1",Tft=`
42478
+ `),TLe.info("Indexed",u.indexedFiles,"files in",u.duration,"ms"),this.saveState({lastScanTimestamp:new Date().toISOString(),filesIndexed:u.indexedFiles,workspaceRoot:this.workspaceRoot}),Pa.warmupInfo={completed:!0,durationMs:u.duration,filesIndexed:u.indexedFiles},{filesIndexed:u.indexedFiles,durationMs:y}}finally{m()}}async dispose(){Pa.astWorkerHost&&await Pa.astWorkerHost.stop(),Pa.spider&&await Pa.spider.dispose(),Pa.reset(),this._initialized=!1}saveState(i){try{PD.writeFileSync(jv.join(this.stateDir,"state.json"),JSON.stringify(i,null,2))}catch(s){TLe.warn("Could not save state:",s instanceof Error?s.message:String(s))}}loadState(){try{let i=PD.readFileSync(jv.join(this.stateDir,"state.json"),"utf-8");return JSON.parse(i)}catch{return null}}};var $qt="1.0.1",Tft=`
42479
42479
  graph-it \u2014 Graph-It-Live standalone CLI
42480
42480
 
42481
42481
  Usage: graph-it <command> [options]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@magic5644/graph-it-live",
3
3
  "displayName": "Graph-It-Live",
4
4
  "description": "AI-first dependency graph & code intelligence for VS Code. Visualize file imports, symbol call hierarchies, and cross-file call graphs. Detect circular dependencies, dead code, and breaking changes. Built-in MCP Server with 21 tools for GitHub Copilot, Cursor, Claude, Windsurf, and Antigravity. Generate AI-friendly codemaps. TypeScript, JavaScript, Python, Rust, Vue, Svelte, GraphQL.",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "publisher": "magic5644",
7
7
  "author": {
8
8
  "name": "magic56"