scip-query 0.6.5 → 0.6.7

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 (169) hide show
  1. package/README.md +63 -7
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/chunk-2AUZ3PLO.js +2 -0
  4. package/dist/{chunk-EB5IVUNU.js → chunk-2CC7RA6B.js} +2 -2
  5. package/dist/{chunk-OQZF2DQJ.js → chunk-2R7OKZE5.js} +2 -2
  6. package/dist/{chunk-YDKWDTAW.js → chunk-2YA36CXK.js} +2 -2
  7. package/dist/chunk-3A2M7AF3.js +4 -0
  8. package/dist/chunk-3EJRPTTB.js +2 -0
  9. package/dist/chunk-3SWWYJPB.js +6 -0
  10. package/dist/chunk-4M4FEWBL.js +7 -0
  11. package/dist/{chunk-QFCK6WV2.js → chunk-4Y6KUJDO.js} +2 -2
  12. package/dist/{chunk-MO65UK5V.js → chunk-55ZJ2FCW.js} +2 -2
  13. package/dist/chunk-6FLGPRBR.js +5 -0
  14. package/dist/chunk-6XRB6ATD.js +16 -0
  15. package/dist/{chunk-WIIZF5FP.js → chunk-7EQ4J66C.js} +2 -2
  16. package/dist/{chunk-Z5CTXSWT.js → chunk-7TGEXAN5.js} +2 -2
  17. package/dist/chunk-ABLXPGAZ.js +2 -0
  18. package/dist/{chunk-F4KR22Z2.js → chunk-BG7YU4DJ.js} +2 -2
  19. package/dist/chunk-D2R6IIEO.js +2 -0
  20. package/dist/{chunk-LT2CPEQ4.js → chunk-E47WMJ5F.js} +2 -2
  21. package/dist/chunk-EEA3R37V.js +11 -0
  22. package/dist/chunk-FAN2CVZT.js +2 -0
  23. package/dist/{chunk-PFMGJ4BR.js → chunk-FYO3FPFH.js} +2 -2
  24. package/dist/chunk-G47V5V3U.js +90 -0
  25. package/dist/chunk-GS55K4WJ.js +85 -0
  26. package/dist/{chunk-BNCTPTVX.js → chunk-HADDFTMU.js} +2 -2
  27. package/dist/chunk-HTJ5BOYP.js +10 -0
  28. package/dist/chunk-IARIBTCL.js +2 -0
  29. package/dist/{chunk-5YYMKE3G.js → chunk-IBWYWAWE.js} +2 -2
  30. package/dist/{chunk-URUVLDM7.js → chunk-ILQSK2KJ.js} +2 -2
  31. package/dist/{chunk-DRLWW74T.js → chunk-JVMXNDRU.js} +2 -2
  32. package/dist/{chunk-YDNCX5PF.js → chunk-K345WFTU.js} +2 -2
  33. package/dist/{chunk-FHSD5RKF.js → chunk-K6ULLR7M.js} +2 -2
  34. package/dist/chunk-KCC3GMCX.js +2 -0
  35. package/dist/{chunk-7LSCW7NF.js → chunk-KQWFRAQI.js} +2 -2
  36. package/dist/chunk-KRVRD6KZ.js +5 -0
  37. package/dist/{chunk-QFZE73XF.js → chunk-KYGNCIJ6.js} +8 -8
  38. package/dist/chunk-LHLXHH43.js +2 -0
  39. package/dist/{chunk-RT5PV5JQ.js → chunk-M7GBLQG4.js} +2 -2
  40. package/dist/{chunk-5LQ6CVX3.js → chunk-MEVK6R7N.js} +2 -2
  41. package/dist/{chunk-Q2ALKKSE.js → chunk-OCQN6WF4.js} +2 -2
  42. package/dist/{chunk-ERRUE5G4.js → chunk-PQTGBYXV.js} +2 -2
  43. package/dist/{chunk-ZHHMG4UC.js → chunk-QYWGC7JV.js} +2 -2
  44. package/dist/{chunk-TLRA5TR6.js → chunk-R373SHXM.js} +2 -2
  45. package/dist/{chunk-MXWC53GJ.js → chunk-RRWPHKZA.js} +2 -2
  46. package/dist/{chunk-C5BFS23M.js → chunk-RUAJV3TN.js} +2 -2
  47. package/dist/{chunk-MKFH7QJG.js → chunk-S57GUI2T.js} +2 -2
  48. package/dist/chunk-SVUVC5VS.js +2 -0
  49. package/dist/{chunk-MO32JMOD.js → chunk-T426XELO.js} +2 -2
  50. package/dist/{chunk-HUASU3AD.js → chunk-TBJDUS4E.js} +7 -7
  51. package/dist/chunk-TX7BHRMT.js +2 -0
  52. package/dist/{chunk-PK4U6NWP.js → chunk-TYRPQE6R.js} +2 -2
  53. package/dist/chunk-WPY46NIL.js +5 -0
  54. package/dist/{chunk-U5MVUPOO.js → chunk-X3Z4KZNX.js} +2 -2
  55. package/dist/{chunk-7X7FLQC5.js → chunk-ZNNCDAYX.js} +2 -2
  56. package/dist/cli.js +159 -148
  57. package/dist/{db-BZPa7dzJ.d.ts → db-DdlToIC-.d.ts} +1 -0
  58. package/dist/index.d.ts +12 -9
  59. package/dist/index.js +11 -11
  60. package/dist/queries/affected.d.ts +1 -1
  61. package/dist/queries/affected.js +1 -1
  62. package/dist/queries/bottlenecks.d.ts +1 -1
  63. package/dist/queries/bottlenecks.js +1 -1
  64. package/dist/queries/by-kind.d.ts +1 -1
  65. package/dist/queries/by-kind.js +1 -1
  66. package/dist/queries/call-graph.d.ts +1 -1
  67. package/dist/queries/call-graph.js +1 -1
  68. package/dist/queries/change-surface.d.ts +1 -1
  69. package/dist/queries/change-surface.js +1 -1
  70. package/dist/queries/code.d.ts +1 -1
  71. package/dist/queries/code.js +1 -1
  72. package/dist/queries/complexity-hotspots.d.ts +2 -1
  73. package/dist/queries/complexity-hotspots.js +1 -1
  74. package/dist/queries/complexity.d.ts +1 -1
  75. package/dist/queries/complexity.js +1 -1
  76. package/dist/queries/convergence.d.ts +1 -1
  77. package/dist/queries/convergence.js +1 -1
  78. package/dist/queries/coupling.d.ts +1 -1
  79. package/dist/queries/coupling.js +1 -1
  80. package/dist/queries/cycles.d.ts +1 -1
  81. package/dist/queries/cycles.js +1 -1
  82. package/dist/queries/dataflow.d.ts +1 -1
  83. package/dist/queries/dataflow.js +1 -1
  84. package/dist/queries/dead.d.ts +1 -1
  85. package/dist/queries/dead.js +1 -1
  86. package/dist/queries/deep-chains.d.ts +1 -1
  87. package/dist/queries/deep-chains.js +1 -1
  88. package/dist/queries/deps.d.ts +1 -1
  89. package/dist/queries/deps.js +1 -1
  90. package/dist/queries/diff-impact.d.ts +20 -2
  91. package/dist/queries/diff-impact.js +1 -1
  92. package/dist/queries/drift.d.ts +1 -1
  93. package/dist/queries/drift.js +1 -1
  94. package/dist/queries/extract-candidates.d.ts +2 -1
  95. package/dist/queries/extract-candidates.js +1 -1
  96. package/dist/queries/fan.d.ts +1 -1
  97. package/dist/queries/fan.js +1 -1
  98. package/dist/queries/files.d.ts +1 -1
  99. package/dist/queries/health-cache-control.d.ts +15 -0
  100. package/dist/queries/health-cache-control.js +2 -0
  101. package/dist/queries/health.d.ts +66 -2
  102. package/dist/queries/health.js +1 -1
  103. package/dist/queries/hierarchy.d.ts +1 -1
  104. package/dist/queries/hierarchy.js +1 -1
  105. package/dist/queries/hotspots.d.ts +1 -1
  106. package/dist/queries/hotspots.js +1 -1
  107. package/dist/queries/imports.d.ts +1 -1
  108. package/dist/queries/imports.js +1 -1
  109. package/dist/queries/index.d.ts +3 -3
  110. package/dist/queries/index.js +1 -1
  111. package/dist/queries/isolated.d.ts +1 -1
  112. package/dist/queries/isolated.js +1 -1
  113. package/dist/queries/members.d.ts +1 -1
  114. package/dist/queries/members.js +1 -1
  115. package/dist/queries/methods.d.ts +1 -1
  116. package/dist/queries/methods.js +1 -1
  117. package/dist/queries/outline.d.ts +1 -1
  118. package/dist/queries/outline.js +1 -1
  119. package/dist/queries/passthrough-candidates.d.ts +2 -1
  120. package/dist/queries/passthrough-candidates.js +1 -1
  121. package/dist/queries/redundant-reexports.d.ts +1 -1
  122. package/dist/queries/redundant-reexports.js +1 -1
  123. package/dist/queries/refs.d.ts +1 -1
  124. package/dist/queries/refs.js +1 -1
  125. package/dist/queries/similar-chains.d.ts +1 -1
  126. package/dist/queries/similar-chains.js +1 -1
  127. package/dist/queries/similar-files.d.ts +1 -1
  128. package/dist/queries/similar-files.js +1 -1
  129. package/dist/queries/similar-signatures.d.ts +1 -1
  130. package/dist/queries/similar-signatures.js +1 -1
  131. package/dist/queries/similar.d.ts +2 -1
  132. package/dist/queries/similar.js +1 -1
  133. package/dist/queries/slice.d.ts +1 -1
  134. package/dist/queries/slice.js +1 -1
  135. package/dist/queries/stale-abstractions.d.ts +4 -2
  136. package/dist/queries/stale-abstractions.js +1 -1
  137. package/dist/queries/stats.d.ts +1 -1
  138. package/dist/queries/surface.d.ts +1 -1
  139. package/dist/queries/surface.js +1 -1
  140. package/dist/queries/symbols.d.ts +1 -1
  141. package/dist/queries/symbols.js +1 -1
  142. package/dist/queries/system.d.ts +1 -1
  143. package/dist/queries/system.js +1 -1
  144. package/dist/queries/trace.d.ts +1 -1
  145. package/dist/queries/trace.js +1 -1
  146. package/dist/queries/wrapper-candidates.d.ts +2 -1
  147. package/dist/queries/wrapper-candidates.js +1 -1
  148. package/dist/reindex-worker.js +1 -1
  149. package/package.json +2 -2
  150. package/dist/chunk-2ZGHRI2A.js +0 -5
  151. package/dist/chunk-32R4VYYA.js +0 -2
  152. package/dist/chunk-3UB2DPLP.js +0 -2
  153. package/dist/chunk-4X7C236P.js +0 -84
  154. package/dist/chunk-A5UNS4DR.js +0 -4
  155. package/dist/chunk-FG6A6ZUP.js +0 -2
  156. package/dist/chunk-FVVEIGP3.js +0 -5
  157. package/dist/chunk-GBDZY73J.js +0 -2
  158. package/dist/chunk-IJWIYZO5.js +0 -2
  159. package/dist/chunk-K6H3XJQW.js +0 -7
  160. package/dist/chunk-KTCODJNQ.js +0 -5
  161. package/dist/chunk-M5QTG55L.js +0 -2
  162. package/dist/chunk-MTK3JAJT.js +0 -2
  163. package/dist/chunk-PBFMZKXE.js +0 -6
  164. package/dist/chunk-ROWAEEOD.js +0 -2
  165. package/dist/chunk-WHGCGENP.js +0 -16
  166. package/dist/chunk-WNMAH3P7.js +0 -2
  167. package/dist/chunk-XV3XUZ3X.js +0 -11
  168. package/dist/chunk-YU25IHJX.js +0 -90
  169. package/dist/chunk-ZFCQQ4B5.js +0 -2
@@ -1,90 +0,0 @@
1
- import{A as z,b as B,p as F}from"./chunk-QFZE73XF.js";import f from"path";import{createRequire as $e}from"module";import{existsSync as T,readdirSync as Ue,readFileSync as ie}from"fs";import{existsSync as L}from"fs";import{basename as le,dirname as S,extname as m,join as d,relative as N,resolve as p}from"path";var ue=B("indexed-paths"),D=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],M=[".py",".pyi"],Y=[".java",".scala",".kt",".kts"],P=[".rs"],O=[".rb"],G=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],q=[".cs",".vb"],j=[".dart"],Q=[".php"],pe=[D,M,Y,P,O,G,q,j,Q];function h(n,e){return e.includes(m(n).toLowerCase())}function de(n){return h(n,M)}function fe(n){return h(n,Y)}function ge(n){return h(n,P)}function me(n){return h(n,O)}function Se(n){return h(n,G)}function he(n){return h(n,q)}function gt(n){return m(n).toLowerCase()===".vb"}function ye(n){return h(n,j)}function Ie(n){return h(n,Q)}function xe(n){let e=m(n).toLowerCase();for(let t of pe)if(t.includes(e))return t;return D}function Ee(n){return fe(n)||he(n)||Ie(n)}function A(n,e,t){return de(e)?be(n,e,t):ge(e)?ve(n,e,t):me(e)?ke(n,e,t):Se(e)?Re(n,e,t):Ee(e)?De(n,t.replace(/\\/g,"."),xe(e)):ye(e)?Le(n,e,t):Ne(n,e,t)}function Ne(n,e,t){if(!t.startsWith(".")&&!t.startsWith("/"))return null;let r=S(d(n.config.projectRoot,e)),i=p(r,t),o=b(n);for(let s of Me(i)){let a=I(N(n.config.projectRoot,s));if(o.has(a)||L(s))return a}return I(N(n.config.projectRoot,i))}function be(n,e,t){let r=b(n),i;if(t.startsWith(".")){let o=t.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=S(d(n.config.projectRoot,e));for(let l=1;l<s;l++)c=S(c);i=a?p(c,a.replace(/\./g,"/")):c}else i=p(n.config.projectRoot,t.replace(/\./g,"/"));for(let o of Te(i)){let s=I(N(n.config.projectRoot,o));if(r.has(s)||L(o))return s}return null}function ve(n,e,t){if(!t)return null;let r=t.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=S(d(n.config.projectRoot,e)),o;return r.startsWith("crate::")?o=p(n.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=p(i,r.slice(6).replace(/::/g,"/")):o=p(S(i),r.slice(7).replace(/::/g,"/")),w(n,Ce(o))}function ke(n,e,t){let r=S(d(n.config.projectRoot,e)),i=p(r,t);return w(n,_e(i))}function Re(n,e,t){let r=S(d(n.config.projectRoot,e)),i=[p(r,t),p(n.config.projectRoot,t),p(n.config.projectRoot,"include",t),p(n.config.projectRoot,"src",t)];return w(n,i)}function De(n,e,t){let r=b(n),i=e.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of t){let l=`${o}${c}`,g=[...r].find(y=>y.endsWith(l));if(g)return g}for(let c of t){let l=[...r].find(g=>le(g)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>t.includes(m(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Le(n,e,t){let r=b(n);if(t.startsWith("package:")){let s=t.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=I(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=S(d(n.config.projectRoot,e)),o=p(i,t);for(let s of Fe(o)){let a=I(N(n.config.projectRoot,s));if(r.has(a)||L(s))return a}return null}function Te(n){let e=m(n);return M.includes(e)?[n]:[`${n}.py`,`${n}.pyi`,d(n,"__init__.py"),d(n,"__init__.pyi")]}function w(n,e){let t=b(n);for(let r of e){let i=I(N(n.config.projectRoot,r));if(t.has(i)||L(r))return i}return null}function Ce(n){let e=m(n);return P.includes(e)?[n]:[`${n}.rs`,d(n,"mod.rs")]}function _e(n){let e=m(n);return O.includes(e)?[n]:[`${n}.rb`,d(n,"index.rb")]}function Fe(n){let e=m(n);return j.includes(e)?[n]:[`${n}.dart`,n]}function Me(n){let e=m(n),t=new Set;if(e){t.add(n);for(let r of D)t.add(n.slice(0,-e.length)+r)}else for(let r of D)t.add(`${n}${r}`),t.add(d(n,`index${r}`));return[...t]}function b(n){return ue.get(n,()=>new Set(n.all(`SELECT relative_path
2
- FROM documents
3
- WHERE 1 = 1
4
- ${n.pathExclusionsFor("documents")}`).map(e=>I(e.relative_path)).filter(e=>!n.isIgnored(e))))}function I(n){return n.replace(/\\/g,"/")}import{existsSync as v,readFileSync as Pe,readdirSync as Oe,statSync as je}from"fs";import u from"path";var $=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function U(n,e){let r=e?u.dirname(u.join(n,e)):n,i=u.resolve(n);for(;r.startsWith(i);){for(let s of $){let a=u.join(r,s);if(v(a))return a}let o=u.dirname(r);if(o===r)break;r=o}for(let o of $){let s=u.join(n,o);if(v(s))return s}return null}function Z(n){let e=n.config.projectRoot,t=new Set(Ae(e,n.config.semantic?.typescript?.tsconfigs)),r=n.all(`SELECT relative_path
5
- FROM documents
6
- WHERE (
7
- relative_path LIKE '%.ts'
8
- OR relative_path LIKE '%.tsx'
9
- OR relative_path LIKE '%.mts'
10
- OR relative_path LIKE '%.cts'
11
- OR relative_path LIKE '%.js'
12
- OR relative_path LIKE '%.jsx'
13
- OR relative_path LIKE '%.mjs'
14
- OR relative_path LIKE '%.cjs'
15
- )
16
- ${n.pathExclusionsFor("documents")}`);for(let i of r){if(n.isIgnored(i.relative_path))continue;let o=U(e,i.relative_path);o&&t.add(u.resolve(o))}if(t.size===0){let i=U(e);i&&t.add(u.resolve(i))}return[...t].filter(i=>!ee(e,i)).sort((i,o)=>i.localeCompare(o))}function Ae(n,e=[]){let t=new Set;for(let r of e){let i=u.isAbsolute(r)?r:u.join(n,r);v(i)&&t.add(u.resolve(i))}for(let r of we(n))for(let i of $){let o=u.join(r,i);v(o)&&t.add(u.resolve(o))}if(t.size===0){let r=U(n);r&&t.add(u.resolve(r))}return[...t].filter(r=>!ee(n,r)).sort((r,i)=>r.localeCompare(i))}function we(n){let e=u.join(n,"package.json");if(!v(e))return[];let t;try{t=JSON.parse(Pe(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>We(n,i))}function We(n,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=u.join(n,e);return W(s)?[s]:[]}let t=e.indexOf("*"),r=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=u.join(n,r||".");return W(o)?Oe(o).map(s=>u.join(o,s,i)).filter(W):[]}function W(n){try{return je(n).isDirectory()}catch{return!1}}function ee(n,e){let t=u.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}var Ke=$e(import.meta.url),k;function oe(n,e){let t=He();if(!t)return K("ts-morph is not installed");let r=Z(n);if(r.length===0)return K("no tsconfig found");try{let i=r.map(o=>({tsconfigPath:o,project:new t.Project({tsConfigFilePath:o,skipFileDependencyResolution:!1})}));return new H(n,t,i)}catch(i){return K(i instanceof Error?i.message:String(i),r[0],r)}}function He(){if(k!==void 0)return k;try{k=Ke("ts-morph")}catch{k=null}return k}function K(n,e,t){return{language:"typescript",availability:()=>({available:!1,reason:n,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var H=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=Ve(e.config.projectRoot)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;sourceFileCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return x(this.importUsageCache,e,()=>{let t=this.sourceFile(e);if(!t)return[];let r=[];for(let i of t.getImportDeclarations())r.push(...this.importUsageForDeclaration(e,i));return r})}referencesFor(e){return x(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),r=this.packageImportReferencesForDefinition(e);if(!t)return r;let i=Qe(t);return J([...i.flatMap(o=>qe(o,this.db.config.projectRoot)).filter(o=>o.file!==e.relativePath||o.line<e.startLine||o.line>e.endLine),...r])})}calleesFor(e){return x(this.calleesCache,e.symbolId,()=>x(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return x(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let r=t.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return re(c)}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${re(o)}`})}importUsageForDeclaration(e,t){let r=A(this.db,e,t.getModuleSpecifierValue()),i=te(t);return t.getImportClause()?.isTypeOnly()?i.map(o=>Je(e,r,o)):i.map(o=>this.valueImportUsageForEntry(e,r,o))}valueImportUsageForEntry(e,t,r){let o=(r.identifier?r.identifier.findReferences():[]).flatMap(l=>Ze(l,e,r.identifier,this.db.config.projectRoot)),s=o.some(l=>!ne(l.node)),a=o.some(l=>ne(l.node)),c=r.isTypeOnly;return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:c,isUsed:c||o.length>0,isTypeUsed:c||a,isValueUsed:s,references:o.map(l=>l.location)}}sourceFile(e){return this.sourceFileMatch(e)?.sourceFile??null}sourceFileMatch(e){return at(e)?x(this.sourceFileCache,e,()=>{let t=f.join(this.db.config.projectRoot,e);for(let{project:r}of this.projects){let i=r.getSourceFile(t)??r.addSourceFileAtPathIfExists(t)??null;if(i)return{project:r,sourceFile:i}}return null}):null}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let r of this.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,r);for(let[r,i]of e)e.set(r,J(i));return this.packageImportReferenceIndex=e,e}indexedTypeScriptLikeDocuments(){return this.db.all(`SELECT relative_path
17
- FROM documents
18
- WHERE (
19
- relative_path LIKE '%.ts'
20
- OR relative_path LIKE '%.tsx'
21
- OR relative_path LIKE '%.mts'
22
- OR relative_path LIKE '%.cts'
23
- OR relative_path LIKE '%.js'
24
- OR relative_path LIKE '%.jsx'
25
- OR relative_path LIKE '%.mjs'
26
- OR relative_path LIKE '%.cjs'
27
- )
28
- ${this.db.pathExclusionsFor("documents")}`).map(e=>e.relative_path)}addPackageImportReferencesForDocument(e,t,r){if(this.db.isIgnored(r))return;let i=this.sourceFileMatch(r);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,r,o)}addPackageImportReferencesForDeclaration(e,t,r,i){let o=Ye(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of te(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let l=et(a.identifier,r,this.db.config.projectRoot);l.length>0&&ot(e,c,l)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let r=new Map;for(let i of Ge(t))this.collectPackageExports(t,i,r,new Set);r.size>0&&e.set(t.name,r)}return this.packageExportIndex=e,e}collectPackageExports(e,t,r,i){if(i.has(t))return;i.add(t);let o=this.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?A(this.db,t,a):t;if(!c||!c.startsWith(`${e.sourceRootRelative}/`))continue;let l=s.getNamedExports();if(l.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let g of l){let y=g.getNameNode().getText(),X=g.getAliasNode()?.getText()??y,V=this.indexedDefinitionByLeaf(c,y);if(!V)continue;let R=r.get(X);R||(R=new Set,r.set(X,R)),R.add(V.symbolId)}}}indexedDefinitionByLeaf(e,t){return x(this.indexedDefinitionLeafCache,e,()=>rt(this.db,e)).get(t)??null}nodeForDefinition(e){let t=this.sourceFile(e.relativePath);if(!t)return null;let r=F(e.symbol)??e.leaf,i=[];return t.forEachDescendant(o=>{if(!tt(this.tsMorph,o,r))return;let s=E(t,o);s<e.startLine-1||s>e.endLine+1||i.push(o)}),i.sort((o,s)=>Math.abs(E(t,o)-e.startLine)-Math.abs(E(t,s)-e.startLine))[0]??null}definitionFromSymbol(e){let t=e.getDeclarations();for(let r of t){let i=r.getSourceFile(),o=C(this.db.config.projectRoot,i.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=E(i,r),a=nt(this.db,o,s,e.getName());if(a)return{symbol:a.symbol,file:a.relativePath,line:a.startLine}}return null}calleeMapForFile(e){let t=this.sourceFile(e);if(!t)return new Map;let r=z(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(r.length===0)return new Map;let i=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,r,o);s&&Xe(i,s.callerId,s.target)});for(let[o,s]of i)i.set(o,st(s));return i}semanticCalleeForCallNode(e,t,r){let i=it(t,E(e,r));if(!i)return null;let o=r.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:i.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function te(n){let e=[],t=n.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});let r=n.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});for(let i of n.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(n.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Je(n,e,t){return{importer:n,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function Xe(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function Ve(n){let e=f.join(n,"package.json");if(!T(e))return[];let t;try{t=JSON.parse(ie(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>Be(n,i)).flatMap(i=>ze(n,i))}function Be(n,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=f.join(n,e);return T(f.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),r=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=f.join(n,r||".");if(!T(o))return[];try{return Ue(o).map(s=>f.join(o,s,i)).filter(s=>T(f.join(s,"package.json")))}catch{return[]}}function ze(n,e){try{let t=JSON.parse(ie(f.join(e,"package.json"),"utf8"));if(!t.name)return[];let r=f.relative(n,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:r,sourceRootRelative:`${r}/src`}]}catch{return[]}}function Ye(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function Ge(n){return[`${n.sourceRootRelative}/index.ts`,`${n.sourceRootRelative}/index.tsx`,`${n.sourceRootRelative}/index.mts`,`${n.sourceRootRelative}/index.cts`]}function qe(n,e){return n.getReferences().map(t=>{let r=t.getNode();return se(r,e)})}function Qe(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function Ze(n,e,t,r){return n.getReferences().map(i=>i.getNode()).filter(i=>C(r,i.getSourceFile().getFilePath())===e).filter(i=>!t||i.getStart()!==t.getStart()).map(i=>({location:se(i,r),node:i}))}function se(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:C(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function et(n,e,t){let r=n.getSourceFile(),i=E(r,n),o=n.getText(),s=new RegExp(`\\b${ct(o)}\\b`,"g"),a=r.getFullText().split(`
29
- `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let g=a[l]??"";s.lastIndex=0;let y;for(;(y=s.exec(g))!==null;)c.push({file:e,line:l,column:y.index})}return J(c.filter(l=>C(t,f.join(t,l.file))===e))}function ne(n){for(let e=n;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function tt(n,e,t){return"getNameNode"in e&&typeof e.getNameNode=="function"&&e.getNameNode()?.getText()===t||"getName"in e&&typeof e.getName=="function"&&e.getName()===t?!0:n.Node.isIdentifier(e)&&e.getText()===t}function nt(n,e,t,r){return n.all(`SELECT
30
- gs.id AS symbolId,
31
- gs.symbol,
32
- d.relative_path AS relativePath,
33
- COALESCE(der.start_line, c.start_line) AS startLine,
34
- COALESCE(der.end_line, c.end_line) AS endLine,
35
- COALESCE(gs.display_name, '') AS leaf,
36
- NULL AS parentTypeName,
37
- CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
38
- CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
39
- gs.kind AS kind,
40
- gs.documentation AS documentation,
41
- gs.enclosing_symbol AS enclosingSymbol
42
- FROM global_symbols gs
43
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
44
- LEFT JOIN chunks c ON c.document_id = der.document_id
45
- JOIN documents d ON d.id = der.document_id
46
- WHERE d.relative_path = ?
47
- AND COALESCE(gs.display_name, gs.symbol) LIKE ?
48
- ORDER BY ABS(COALESCE(der.start_line, c.start_line) - ?)
49
- LIMIT 5`,e,`%${r}%`,t)[0]??null}function rt(n,e){let t=n.all(`SELECT
50
- d.id AS documentId,
51
- gs.id AS symbolId,
52
- gs.symbol,
53
- d.relative_path AS relativePath,
54
- der.start_line AS startLine,
55
- der.end_line AS endLine,
56
- COALESCE(gs.display_name, '') AS leaf,
57
- NULL AS parentTypeName,
58
- CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
59
- CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
60
- gs.kind AS kind,
61
- gs.documentation AS documentation,
62
- gs.enclosing_symbol AS enclosingSymbol
63
- FROM global_symbols gs
64
- JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
65
- JOIN documents d ON d.id = der.document_id
66
- WHERE d.relative_path = ?
67
- UNION ALL
68
- SELECT
69
- d.id AS documentId,
70
- gs.id AS symbolId,
71
- gs.symbol,
72
- d.relative_path AS relativePath,
73
- MIN(c.start_line) AS startLine,
74
- MAX(c.end_line) AS endLine,
75
- COALESCE(gs.display_name, '') AS leaf,
76
- NULL AS parentTypeName,
77
- CASE WHEN gs.kind IN (6, 12, 13) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
78
- CASE WHEN gs.kind IN (5, 8, 11) THEN 1 ELSE 0 END AS isTypeLike,
79
- gs.kind AS kind,
80
- gs.documentation AS documentation,
81
- gs.enclosing_symbol AS enclosingSymbol
82
- FROM global_symbols gs
83
- JOIN mentions m ON m.symbol_id = gs.id
84
- JOIN chunks c ON c.id = m.chunk_id
85
- JOIN documents d ON d.id = c.document_id
86
- WHERE d.relative_path = ?
87
- AND m.role = 1
88
- GROUP BY gs.id, gs.symbol, d.id, d.relative_path, gs.display_name, gs.kind, gs.documentation, gs.enclosing_symbol
89
- ORDER BY startLine, endLine`,e,e),r=new Set,i=new Map;for(let o of t){if(r.has(o.symbolId))continue;r.add(o.symbolId);let s=o.leaf||F(o.symbol);!s||i.has(s)||i.set(s,{...o,leaf:s})}return i}function it(n,e){let t=null;for(let r of n)e<r.startLine||e>r.endLine||(!t||r.startLine>=t.startLine)&&(t=r);return t}function E(n,e){return n.getLineAndColumnAtPos(e.getStart()).line-1}function J(n){let e=new Set,t=[];for(let r of n){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),t.push(r))}return t}function ot(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function st(n){let e=new Set,t=[];for(let r of n){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),t.push(r))}return t}function x(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}function C(n,e){let t=f.relative(n||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function at(n){return/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/.test(n)}function re(n){return n.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}function ct(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ae=new WeakMap;function ce(n,e){let t=`${n.config.projectRoot}:typescript-workspace`,r=ae.get(n);r||(r=new Map,ae.set(n,r));let i=r.get(t);if(i)return i;let o=oe(n,e);return r.set(t,o),o}function Ct(n,e){let t=_(n,e);return t?t.importUsage(e):[]}function lt(n,e){let t=_(n,e.relativePath);return t?t.referencesFor(e):[]}function _t(n,e){let t=new Map;for(let r of e)for(let i of lt(n,r)){if(i.file===r.relativePath||n.isIgnored(i.file))continue;let o=t.get(r.symbolId);o||(o=new Set,t.set(r.symbolId,o)),o.add(i.file)}return t}function Ft(n,e){let t=new Map;for(let r of e){let i=_(n,r.relativePath);if(!i)continue;let o=i.calleesFor(r);o.length>0&&t.set(r.symbolId,o)}return t}function Mt(n,e){let t=_(n,e.relativePath);return t?t.signatureFor(e):null}function _(n,e){if(!ut(e))return null;let t=ce(n,e);return t.availability().available?t:null}function ut(n){return/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/.test(n)}export{Y as a,q as b,Q as c,gt as d,xe as e,A as f,be as g,ve as h,ke as i,Re as j,De as k,Le as l,I as m,Ct as n,lt as o,_t as p,Ft as q,Mt as r};
90
- //# sourceMappingURL=chunk-YU25IHJX.js.map
@@ -1,2 +0,0 @@
1
- import{a as m}from"./chunk-32R4VYYA.js";import{a as l}from"./chunk-ZHHMG4UC.js";import{p as r,r as a}from"./chunk-QFZE73XF.js";import{basename as d}from"path";function g(t,c){let o=l(t,c);if(!o)return[];let s=r(o.symbol),i=new m(t).definitionsForFile(o.relativePath).filter(e=>a(e.symbol)),n=i.filter(e=>e.parentTypeName===s||e.symbol.includes(s));return(n.length>0?n:p(d(o.relativePath))===s?i.filter(e=>e.symbol.includes("<invalid-global-code>")):[]).map(e=>({startLine:e.startLine,endLine:e.endLine,name:r(e.symbol)}))}function p(t){return t.replace(/\.[^.]+$/,"")}export{g as a};
2
- //# sourceMappingURL=chunk-ZFCQQ4B5.js.map