scip-query 0.19.6 → 0.19.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +28 -15
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-2465DLHK.js +3 -0
- package/dist/{chunk-2CVXCGL4.js → chunk-24GTWJ3N.js} +2 -2
- package/dist/{chunk-XVJ3V7LM.js → chunk-2SNGN6U4.js} +2 -2
- package/dist/{chunk-FKGN4A4E.js → chunk-2U3OLUNJ.js} +2 -2
- package/dist/{chunk-UUJBLG6J.js → chunk-33KUO7CG.js} +2 -2
- package/dist/{chunk-N3SE646F.js → chunk-33XTHFKR.js} +2 -2
- package/dist/{chunk-WXAAURU7.js → chunk-3EDFLQ6A.js} +2 -2
- package/dist/chunk-3ZSJ3PWF.js +16 -0
- package/dist/{chunk-G4UQL4CP.js → chunk-43KC6EQZ.js} +2 -2
- package/dist/{chunk-NQLSSVOB.js → chunk-464PLI5O.js} +2 -2
- package/dist/chunk-46XGSFNI.js +2 -0
- package/dist/{chunk-NN4ZIRPK.js → chunk-47BU5Z4T.js} +2 -2
- package/dist/chunk-4BV4QAZJ.js +5 -0
- package/dist/chunk-4YTUWQ6M.js +18 -0
- package/dist/{chunk-LMFVTUW2.js → chunk-5ML2BNRH.js} +2 -2
- package/dist/{chunk-OP3MTFJR.js → chunk-5YLUDDAF.js} +2 -2
- package/dist/chunk-67QRR5YC.js +6 -0
- package/dist/{chunk-273W2U4Y.js → chunk-6GXYN7YA.js} +2 -2
- package/dist/{chunk-JELJLXEE.js → chunk-6M7RONVB.js} +2 -2
- package/dist/{chunk-MLGTCX56.js → chunk-7FT5Y65S.js} +2 -2
- package/dist/{chunk-F42A3AKG.js → chunk-7KYNAMMH.js} +2 -2
- package/dist/{chunk-VP542C25.js → chunk-7LSVMFX7.js} +2 -2
- package/dist/{chunk-YWB2EBNB.js → chunk-7QHY3H7P.js} +2 -2
- package/dist/{chunk-UQK5CRUK.js → chunk-7RAG65VK.js} +2 -2
- package/dist/{chunk-CYJM7CYF.js → chunk-7SWJEWJF.js} +2 -2
- package/dist/{chunk-47X75ZKH.js → chunk-7VCOXZH3.js} +2 -2
- package/dist/chunk-A2TNXAXO.js +8 -0
- package/dist/{chunk-TYQ76QHQ.js → chunk-A3QXWFBK.js} +2 -2
- package/dist/{chunk-S2GP3CU3.js → chunk-AA4UWRNL.js} +2 -2
- package/dist/{chunk-OBKDTVZ3.js → chunk-ACAM6O5R.js} +2 -2
- package/dist/chunk-AQOFWNQJ.js +1 -0
- package/dist/chunk-AZFUMCQB.js +2 -0
- package/dist/{chunk-IYAOX36F.js → chunk-BDOIKGDI.js} +2 -2
- package/dist/{chunk-7E3TH5ZN.js → chunk-BNXICU42.js} +2 -2
- package/dist/chunk-C5Q44Q5D.js +3 -0
- package/dist/{chunk-OQ2A4G2G.js → chunk-CTF2GDEX.js} +2 -2
- package/dist/chunk-DHEQMPLW.js +2 -0
- package/dist/{chunk-EVOC5I5I.js → chunk-DQBCO2UY.js} +2 -2
- package/dist/{chunk-YLVE3SXZ.js → chunk-DQGSM7RZ.js} +2 -2
- package/dist/chunk-E2LAW7SL.js +30 -0
- package/dist/chunk-E3HYEQO7.js +2 -0
- package/dist/chunk-E4NFOAD4.js +6 -0
- package/dist/chunk-E5HNT4X2.js +3 -0
- package/dist/{chunk-6XHTISLI.js → chunk-ELLMY7XJ.js} +2 -2
- package/dist/chunk-FD3HFKXR.js +5 -0
- package/dist/{chunk-RJHCPSZ7.js → chunk-FIJCV235.js} +2 -2
- package/dist/{chunk-KLVJABXA.js → chunk-FJ5UDTQF.js} +2 -2
- package/dist/{chunk-SHKZ7OVJ.js → chunk-GHKEJTCE.js} +2 -2
- package/dist/{chunk-JERWGHQT.js → chunk-GLZTVKAB.js} +3 -3
- package/dist/{chunk-A43URCQ3.js → chunk-GNC4JVAN.js} +2 -2
- package/dist/chunk-HIB452NU.js +949 -0
- package/dist/{chunk-U5CNPPTZ.js → chunk-HZYDQPNY.js} +2 -2
- package/dist/chunk-IF6FP6B2.js +66 -0
- package/dist/{chunk-CSTYYXKC.js → chunk-JAY7YWS3.js} +2 -2
- package/dist/{chunk-6XFC7PQ5.js → chunk-JHF3E4YM.js} +2 -2
- package/dist/chunk-JORHF5AL.js +108 -0
- package/dist/{chunk-QBYYWGAT.js → chunk-K2WO7XY7.js} +2 -2
- package/dist/chunk-KFZNKUNT.js +2 -0
- package/dist/{chunk-J7VT2CRB.js → chunk-KJ2IIBZN.js} +2 -2
- package/dist/{chunk-336DC5NJ.js → chunk-KKME5ZAI.js} +2 -2
- package/dist/chunk-KSGTULOS.js +9 -0
- package/dist/{chunk-E2ZXPB7J.js → chunk-KXDJAG4N.js} +3 -3
- package/dist/{chunk-Z2LHPIOM.js → chunk-L4S2A7BV.js} +2 -2
- package/dist/chunk-LP3ARJKF.js +8 -0
- package/dist/chunk-LSOR3LQG.js +3 -0
- package/dist/{chunk-FHCTEANE.js → chunk-MLFZP76A.js} +2 -2
- package/dist/{chunk-RBFFD4V2.js → chunk-MNSTUIDD.js} +2 -2
- package/dist/{chunk-3OIKRYU5.js → chunk-MSBDMFER.js} +2 -2
- package/dist/{chunk-7LABSJSR.js → chunk-MZZBAITE.js} +5 -5
- package/dist/{chunk-QQWOFXNW.js → chunk-NE3TZUCI.js} +2 -2
- package/dist/{chunk-JZNLMHWY.js → chunk-NTUMF2X3.js} +2 -2
- package/dist/{chunk-DD5BOU5I.js → chunk-O23I56NA.js} +2 -2
- package/dist/{chunk-YHXBD52M.js → chunk-O3O4XXO6.js} +2 -2
- package/dist/{chunk-FQTPPXNA.js → chunk-OUBAF226.js} +2 -2
- package/dist/chunk-P3UO3EH3.js +2 -0
- package/dist/{chunk-5OC3HWP5.js → chunk-QGGLL3UH.js} +2 -2
- package/dist/chunk-QIQ63BHW.js +16 -0
- package/dist/{chunk-RWRLUZ6U.js → chunk-QJIVBYEK.js} +2 -2
- package/dist/chunk-QOXBSI6G.js +20 -0
- package/dist/{chunk-7Q6VYYCH.js → chunk-QXK6UUSM.js} +2 -2
- package/dist/{chunk-ZTTISZ7J.js → chunk-RA3AYNWP.js} +2 -2
- package/dist/chunk-RJMDJR3A.js +2 -0
- package/dist/{chunk-TFUU5MQQ.js → chunk-RLH5VUMG.js} +2 -2
- package/dist/{chunk-OHWZKLVA.js → chunk-S4S2WOIX.js} +2 -2
- package/dist/{chunk-YTUD45PU.js → chunk-SERUIGV5.js} +2 -2
- package/dist/{chunk-2OXVAGGT.js → chunk-SMQWE25B.js} +2 -2
- package/dist/{chunk-K42M2KWT.js → chunk-TAVELHYR.js} +2 -2
- package/dist/{chunk-MGBJHRFB.js → chunk-TWMJ3Y3G.js} +2 -2
- package/dist/chunk-VAXNI5NE.js +146 -0
- package/dist/chunk-VVY2G5ET.js +2 -0
- package/dist/{chunk-XF3KLXN3.js → chunk-W3DBTGL4.js} +2 -2
- package/dist/{chunk-26X7KCJR.js → chunk-WANA4KAQ.js} +2 -2
- package/dist/chunk-WJL2L6MV.js +60 -0
- package/dist/chunk-WUW7YUAH.js +11 -0
- package/dist/{chunk-PC44K7RF.js → chunk-WWKWUPSU.js} +2 -2
- package/dist/{chunk-2EZSOTSY.js → chunk-WY45BHKQ.js} +2 -2
- package/dist/chunk-X4FR5BZF.js +9 -0
- package/dist/chunk-X6RKPDY7.js +2 -0
- package/dist/{chunk-GK3GRUJX.js → chunk-YLFORA5G.js} +2 -2
- package/dist/{chunk-NBRUH7OE.js → chunk-YTVWB7YJ.js} +2 -2
- package/dist/{chunk-YGQN3XGZ.js → chunk-ZCEJ63SP.js} +2 -2
- package/dist/{chunk-2GSQR6YA.js → chunk-ZJ5CBXK3.js} +2 -2
- package/dist/chunk-ZL2OGDCD.js +2 -0
- package/dist/cli.js +8 -3
- package/dist/command-descriptors-ZW5J4ZEM.js +631 -0
- package/dist/{config-types-BWQ5xPGI.d.ts → config-types-B6MEoRNy.d.ts} +4 -0
- package/dist/{db-B0r1o7Vt.d.ts → db-DYLKr9Wn.d.ts} +1 -1
- package/dist/direct-navigation-42YHQPOI.js +3 -0
- package/dist/{health-CFnlCiTz.d.ts → health-DgxIDXJC.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/postinstall.js +1 -1
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +2 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +2 -2
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +3 -3
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +26 -25
- package/dist/reindex.d.ts +7 -3
- package/dist/reindex.js +34 -33
- package/dist/runtime.d.ts +3 -10
- package/dist/runtime.js +3 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-DCvnlZCu.d.ts → scip-cli-Cc6c00-a.d.ts} +2 -2
- package/dist/watch-server.js +5 -5
- package/docs/AGENT_GUIDE.md +19 -3
- package/docs/CLI_JSON_OUTPUT.md +86 -1
- package/docs/COMMAND_REFERENCE.md +5 -3
- package/docs/SECURITY_MODEL.md +129 -0
- package/docs/TELEMETRY_RETENTION.md +5 -0
- package/docs/schemas/cli-output-page.schema.json +104 -0
- package/package.json +8 -7
- package/skills/_shared/SKILL.md +4 -2
- package/skills/scip-audit/SKILL.md +3 -2
- package/skills/scip-explore/SKILL.md +1 -1
- package/skills/scip-improve/SKILL.md +1 -1
- package/skills/scip-plan/SKILL.md +1 -1
- package/skills/scip-verify/SKILL.md +7 -2
- package/dist/chunk-24QNP7MN.js +0 -2
- package/dist/chunk-2ZOCHAL2.js +0 -8
- package/dist/chunk-35SQLYCQ.js +0 -2
- package/dist/chunk-4CGVLUDP.js +0 -18
- package/dist/chunk-4RI4BJGT.js +0 -8
- package/dist/chunk-52HQTTPB.js +0 -2
- package/dist/chunk-A63U2W3P.js +0 -3
- package/dist/chunk-ADFSIJP2.js +0 -16
- package/dist/chunk-AOLE4DYM.js +0 -6
- package/dist/chunk-B5MHCHP3.js +0 -107
- package/dist/chunk-DGAGY7RJ.js +0 -60
- package/dist/chunk-DGMCFMPG.js +0 -11
- package/dist/chunk-GA64UPMI.js +0 -6
- package/dist/chunk-HEBAY673.js +0 -2
- package/dist/chunk-HELS7KFF.js +0 -2
- package/dist/chunk-IPDCSB6N.js +0 -6
- package/dist/chunk-JJJCO4QC.js +0 -945
- package/dist/chunk-KP4KBDVF.js +0 -3
- package/dist/chunk-LRTP3DKL.js +0 -3
- package/dist/chunk-P6HBYNBE.js +0 -5
- package/dist/chunk-QHKUY4FW.js +0 -2
- package/dist/chunk-QHRL4LKM.js +0 -2
- package/dist/chunk-UXP636P5.js +0 -144
- package/dist/chunk-VEVBIAOJ.js +0 -16
- package/dist/chunk-VKRQDBW5.js +0 -9
- package/dist/chunk-VOQFGC2W.js +0 -67
- package/dist/chunk-WMXRRBII.js +0 -8
- package/dist/chunk-X3NLZHPA.js +0 -20
- package/dist/chunk-Z5QQPJ3U.js +0 -30
- package/dist/chunk-ZLJLE6LK.js +0 -2
- package/dist/command-descriptors-SJDZ7QGR.js +0 -617
- package/dist/direct-navigation-HTKOZEOM.js +0 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{a as X}from"./chunk-P5XHIJHI.js";import{A as ne,B as Ae,C as St,D as an,E as _e,F as te,G as Rt,H as bt,I as Ne,J as ht,L as cn,N as ln,O as un,l as dt,t as mt,u as me,x as V,y as Fe,z as ee}from"./chunk-FD3HFKXR.js";import{d as we,e as yt,f as Ee,g as Pe,h as q,r as gt}from"./chunk-LSOR3LQG.js";import{b as ft,e as $,f as Te,h as pt,j as de,s as K,t as ke}from"./chunk-RA3AYNWP.js";import{a as pe,f as Ce,n as lt,p as ut}from"./chunk-MZZBAITE.js";import{A as ct,a as nt,b as tt,o as rn,x as at}from"./chunk-WUW7YUAH.js";import{A as w,C as xe,D as on,E as sn,F as ue,H as it,J as ot,K as fe,M as st,i as Gn,k as Qn,l as Zn,o as nn,q as tn,s as Xn,u as et,y as N,z as rt}from"./chunk-JORHF5AL.js";import{a as ve}from"./chunk-64MNV6AB.js";import{g as le,i as O,k as Yn,l as H,m as Me,p as De,q as W,r as Jn,v as en}from"./chunk-VVY2G5ET.js";function It(n){let e=new Map,t=Yr(n),r=new Map;return i=>{let o=Vr(i),s=r.get(o);if(s!==void 0)return s;if(!t.has(i.file))return r.set(o,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Jr(K(n,i.file)),e.set(i.file,a));let c=Gr(a,i);return r.set(o,c),c}}function Vr(n){return`${n.file}\0${n.symbol}\0${n.line}`}function Yr(n){return new Set(n.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Jr(n){let e=new Map,t=new Map;for(let r of n){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let o=t.get(r.startLine);o?o.push(r):t.set(r.startLine,[r])}return{definitions:n,byLeaf:e,byStartLine:t}}function Gr(n,e){if(n.definitions.length===0)return e.symbol;let t=Xr(e.symbol),r=Qr(n.byLeaf,t),i=Zr(r,e.line);if(i)return i.symbol;let o=n.byStartLine.get(e.line)??[];return o.length===1?o[0].symbol:e.symbol}function Qr(n,e){let t=[],r=new Set;for(let i of e)for(let o of n.get(i)??[])r.has(o.symbolId)||(r.add(o.symbolId),t.push(o));return t}function Zr(n,e){let t=null;for(let r of n)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!t||r.endLine-r.startLine<t.endLine-t.startLine)&&(t=r)}return t}function Xr(n){let e=new Set([n]),r=n.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Mt(n,e){let r=ut(n,e).map(i=>ni(e,i));return{usage:r,positions:ti(n,e,r)}}function Dt(n,e){return{importUsage(t){let r=n.importUsageFacts(t);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(t,r.positions);return i.available?ei(r.usage,i.sourcePaths):r.usage}}}function ei(n,e){return n.map((t,r)=>{let i=e.get(String(r));return i?{...t,sourcePath:i}:t})}function ni(n,e){let t=e.isTypeOnly===!0,r=e.kind==="side-effect"||t||e.used;return{importer:n,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:t,isUsed:r,isTypeUsed:t,isValueUsed:e.kind==="side-effect"||!t&&e.used,references:[]}}function ti(n,e,t){let r=ct(n,e);if(!r)return[];let i=ri(r.rootNode),o=new Map;for(let a of i){let c=o.get(pn(a.importedName,a.localName));c?c.push(a.position):o.set(pn(a.importedName,a.localName),[a.position])}let s=[];return t.forEach((a,c)=>{let u=o.get(pn(a.importedName,a.localName??a.importedName))?.shift();u&&s.push({...u,id:String(c),file:e})}),s}function ri(n){let e=[];for(let t of n.descendantsOfType("use_declaration")){let r=t.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Le(r,""))}return e.filter(t=>t.importedName!=="*")}function Le(n,e){switch(n.type){case"identifier":case"super":case"self":case"crate":return[{importedName:n.text,localName:n.text,position:fn(n,n.text)}];case"scoped_identifier":{let t=n.text.split("::").pop()??n.text;return[{importedName:t,localName:t,position:fn(n,t)}]}case"scoped_use_list":{let t=n.namedChild(0),r=n.namedChild(1);if(!t||!r)return[];let i=lt(e,t.text);return r.namedChildren.flatMap(o=>Le(o,i))}case"use_list":return n.namedChildren.flatMap(t=>Le(t,e));case"use_as_clause":{let t=n.namedChild(0),r=n.namedChild(1);return!t||!r?[]:Le(t,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let t=n.namedChild(0),r="*";return[{importedName:r,localName:r,position:fn(t??n,r)}]}default:return[]}}function fn(n,e){let t=Math.max(0,n.text.lastIndexOf(e));return{id:"",file:"",line:n.startPosition.row,column:n.startPosition.column+t+ii(e)}}function ii(n){return Math.max(0,Math.min(n.length-1,1))}function pn(n,e){return`${n}\0${e}`}import{spawnSync as Dn}from"child_process";import{existsSync as vn}from"fs";import{fileURLToPath as eo}from"url";function Oe(n){let e=mt(dt,n),t=e.runnable;return{available:t,dependencyAvailable:t,resolvedBinary:e.resolvedBinary??void 0,reason:t?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as Oi,mkdtempSync as $t,rmSync as Rn}from"fs";import{tmpdir as Vt}from"os";import{join as bn}from"path";import{fileURLToPath as ze,pathToFileURL as Ui}from"url";import{SHARE_ENV as qi,Worker as Bi}from"worker_threads";function z(n,e,t=new Set){let r=new Map;for(let i of n)t.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function Y(n,e,t){let r=X(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(n/Math.max(1,t)));return Math.max(12e4,3e4+i*e)}import{spawn as Di}from"child_process";import{createHash as vi,randomUUID as xi}from"crypto";import{existsSync as Ut,realpathSync as Ci,rmSync as Ti}from"fs";import{tmpdir as ki}from"os";import{resolve as ie}from"path";import{execFileSync as pi}from"child_process";import{existsSync as oi}from"fs";import{deserializeSCIP as si,SymbolRole as ai}from"@c4312/scip";import{realpathSync as As}from"fs";import{basename as Ns,dirname as Ls,join as Os,relative as Us,sep as qs}from"path";import{fileURLToPath as js,pathToFileURL as Ws}from"url";function Ue(n){let e=new Map;for(let t of n)e.set(`${t.file}\0${t.line}\0${t.column}`,t);return[...e.values()].sort((t,r)=>{let i=t.file.localeCompare(r.file);return i!==0?i:t.line!==r.line?t.line-r.line:t.column-r.column})}var dn=new WeakMap,ci="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function vt(n,e){let t=new Map,r=qe(),i=e.filter(s=>Tt(s,r));if(i.length===0)return t;let o=kt(n);if(!o)return t;for(let s of i){let a=Ct(o,s);a!==null&&t.set(s.symbolId,a)}return t}function xt(n,e){if(!Tt(e,qe()))return null;let t=kt(n);return t?Ct(t,e):null}function Ct(n,e){return n.referencesBySymbol.get(e.symbol)??[]}function Tt(n,e="safe"){if(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||de(n.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(n.symbol))return!1;if(e==="all")return!0;let t=Te(n.symbol);if(t==="method")return!0;if(t!=="term")return!1;let r=ft(n.symbol);return"kind"in r?!1:!li(r)}function li(n){for(let e=0;e<n.descriptors.length-1;e+=1)if(n.descriptors[e]?.suffix==="type")return!0;return!1}function kt(n){if(dn.has(n))return dn.get(n)??null;let e=ui(n);return dn.set(n,e),e}function ui(n){if(!n.generation.indexPath||!oi(n.generation.indexPath))return null;try{let e=si(De(n.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:Me})),t=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||n.isIgnored(i)))for(let o of r.occurrences??[]){if(!o.symbol||(o.symbolRoles&ai.Definition)!==0)continue;let s=fi(i,o.range);if(!s)continue;let a=t.get(o.symbol)??[];a.push(s),t.set(o.symbol,a)}}for(let[r,i]of t)t.set(r,Ue(i));return{referencesBySymbol:t}}catch{return null}}function fi(n,e){if(e.length<3)return null;let t=e[0],r=e[1];return!Number.isInteger(t)||!Number.isInteger(r)?null:{file:n,line:t,column:r}}function qe(){return process.env[ci]==="all"?"all":"safe"}var wt=new Map;function mn(n){let t=Oe(n).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:t,version:t?di(n,t):"unavailable"}}function yn(n){return{...mn(n),scipOccurrenceReferenceMode:qe()}}function di(n,e){let t=`${n}\0${e}`,r=wt.get(t);if(r)return r;let i;try{i=pi(e,["--version"],{cwd:n,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return wt.set(t,i),i}import{createHash as mi}from"crypto";var yi=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function Et(n){let e=st(n,{includePath:Si});return mi("sha256").update(JSON.stringify(e)).digest("hex")}function Si(n){let e=n.replaceAll("\\","/"),t=e.split("/").at(-1)??e;return e.endsWith(".rs")||yi.has(t)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}import{createHash as gi}from"crypto";import{resolve as Ri}from"path";var re=3;function gn(n){return gi("sha256").update(me({kind:"scip-query-durable-rust-mailbox",protocolVersion:re,sessionDir:Ri(n)})).digest("hex")}function At(n,e){return le(n)?n.protocolVersion!==re?Ft(n.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(n.protocolVersion)}`):n.mailboxVersion!==V||n.id!==e.requestId||n.operationKey!==e.operationKey||n.sessionIdentity!==e.sessionIdentity||n.deadlineAtMs!==e.deadlineAtMs?Ft("helper wrote an incompatible response identity"):typeof n.completedAtMs!="number"||!Number.isFinite(n.completedAtMs)||n.completedAtMs>e.deadlineAtMs||e.nowMs>e.deadlineAtMs?{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:n.ok===!1?typeof n.error!="string"||!Mi(n.errorCode)?Sn("helper wrote an invalid rejection response"):{ok:!1,code:n.errorCode,error:n.error}:n.ok!==!0||n.session!=="created"&&n.session!=="reused"&&n.session!=="invalidated"||!bi(n.response,e.requestKind)?Sn("helper wrote an invalid success response"):{ok:!0,session:n.session,response:n.response}:Sn("helper wrote an invalid response object")}function bi(n,e){return!le(n)||typeof n.available!="boolean"||n.reason!==void 0&&typeof n.reason!="string"?!1:e==="import-definitions"?Array.isArray(n.sourcePaths)&&n.sourcePaths.every(t=>Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&(t[1]===null||typeof t[1]=="string")):Pt(n.references,hi)&&(n.incompleteReferenceSymbolIds===void 0||Array.isArray(n.incompleteReferenceSymbolIds)&&n.incompleteReferenceSymbolIds.every(t=>Number.isSafeInteger(t)))&&(n.callees===void 0||Pt(n.callees,Ii))&&(n.signatures===void 0||Array.isArray(n.signatures)&&n.signatures.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&(t[1]===null||typeof t[1]=="string")))}function Pt(n,e){return Array.isArray(n)&&n.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&Array.isArray(t[1])&&t[1].every(e))}function hi(n){return le(n)&&typeof n.file=="string"&&O(n.line)&&O(n.column)}function Ii(n){return le(n)&&typeof n.symbol=="string"&&typeof n.file=="string"&&O(n.line)}function Mi(n){return n==="unsupported-protocol"||n==="malformed-request"||n==="expired-request"||n==="handler-error"}function Sn(n){return{ok:!1,code:"malformed-response",error:n}}function Ft(n){return{ok:!1,code:"incompatible-response",error:n}}var wi=5e3,qt=10,Ei=3e4;function _t(n,e,t,r=zt){let i=r.engineIdentity(n),o={protocolVersion:re,projectRoot:r.canonicalProjectRoot(n),projectFingerprint:r.projectFingerprint(n),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:jt(r.environment())};return{key:Ht(me(o)),...o}}function Be(n,e,t,r){if(n.protocolVersion!==re||!t(n.pid))return!1;if(!n.processIdentity)return!0;let i=r?.(n.pid);return i!=null&&Ee(n.processIdentity,i)}function Bt(n,e,t){let r;try{r=en(e,{maxBytes:H,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let i=Ht(me({projectRoot:ie(n),serverPath:ie(e),serverFingerprint:r})).slice(0,20);return ie(t,`scip-query-rust-session-${i}`)}function Nt(n){let e=n===void 0?Number.NaN:Number(n);return Number.isInteger(e)&&e>=0?e:0}function jt(n){return Object.fromEntries(Object.entries(n).filter(([e])=>Kt(e)).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t??null]))}function Wt(n,e){let t=e.runtime??Li,r=e.identityRuntime??zt,i=Bt(n,e.serverPath,e.tempRoot??ki()),o=!1,s=(a,c)=>{if(o)throw new Error("Durable Rust semantic session was already disposed.");return Fi(i,e.serverPath,e.semanticWorkerPath,a,c,t,e.mailboxLimits)};return{requestSemantic(a,c){let u=_t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"semantic",identityKey:u.key,workerEnvironment:Ot(),request:{...l,referenceRetryTimeoutMs:Pi(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Nt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let u=_t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"import-definitions",identityKey:u.key,workerEnvironment:Ot(),request:{...l,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Nt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){o=!0}}}function Pi(n,e){return e!==void 0?e:n===void 0?Ei:void 0}function Fi(n,e,t,r,i,o,s={}){let a=o.now(),c=a+i,u=(o.monotonicNow??q)(),f=u+i,l=ee("rust-semantic-v3",r),p=ne(l),d=Fe(n),S=gn(n),h=Ae(d,{mailboxVersion:V,protocolVersion:re,id:p,operationKey:l,clientId:o.randomId(),enqueuedAtMs:a,deadlineAtMs:c,sessionIdentity:S,request:r},{nowMs:a,limits:s});for(Lt(n,e,t,f,o);(o.monotonicNow??q)()<=f;){if(Ut(h.responsePath)){let y=Ai(W(h.responsePath,{maxBytes:s.maxItemBytes??H,inputKind:"durable Rust semantic mailbox response"}),{requestId:p,operationKey:l,sessionIdentity:S,deadlineAtMs:h.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:o.now()});if(!y.ok)throw new Error(y.error);return N()&&xe({type:"span",name:"rust.semantic.durable-session.request",durationMs:(o.monotonicNow??q)()-u,ok:!0,session:y.session,kind:r.kind}),y.response}let g=je(n);(!g||!Be(g,o.now(),o.isProcessAlive,o.readProcessIdentity))&&Lt(n,e,t,f,o),o.sleep(qt)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}function Lt(n,e,t,r,i){let o=je(n);if(o&&Be(o,i.now(),i.isProcessAlive,i.readProcessIdentity))return;Ti(ie(n,"server.json"),{force:!0}),i.spawnServer(e,n,t);let s=i.monotonicNow??q,a=Math.min(r,s()+wi);for(;s()<=a;){let c=je(n);if(c&&Be(c,i.now(),i.isProcessAlive,i.readProcessIdentity))return;i.sleep(qt)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function je(n){try{let e=JSON.parse(W(ie(n,"server.json"),{maxBytes:Yn,inputKind:"durable Rust session state"}));if(typeof e.protocolVersion!="number"||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||e.sessionIdentity!==gn(n))||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"||e.mailbox!==void 0&&!_i(e.mailbox))return null;let t=e.processIdentity===void 0?null:yt(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:{protocolVersion:e.protocolVersion,...e.sessionIdentity===void 0?{}:{sessionIdentity:e.sessionIdentity},pid:e.pid,...t?{processIdentity:t}:{},heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs},...e.mailbox===void 0?{}:{mailbox:e.mailbox}}}catch{return null}}function Ai(n,e){try{return At(JSON.parse(n),e)}catch(t){return{ok:!1,code:"malformed-response",error:`helper wrote malformed JSON: ${t instanceof Error?t.message:String(t)}`}}}function _i(n){if(!n||typeof n!="object")return!1;let e=n;return O(e.pending)&&O(e.inflight)&&O(e.responses)&&O(e.deadLetters)&&O(e.invalid)&&O(e.totalItems)&&typeof e.totalBytes=="number"&&Number.isFinite(e.totalBytes)&&e.totalBytes>=0&&(e.oldestPendingAt===void 0||Number.isFinite(Date.parse(e.oldestPendingAt)))}function Ot(){return Object.fromEntries(Object.entries(process.env).filter(([n])=>Ni(n)).sort(([n],[e])=>n.localeCompare(e)).map(([n,e])=>[n,e??null]))}function Kt(n){return n==="HOME"||n==="PATH"||n.startsWith("CARGO_")||n.startsWith("RA_")||n.startsWith("RUST")}function Ni(n){return Kt(n)||n.startsWith("SCIP_RUST_")||n==="SCIP_QUERY_PROFILE"||n==="SCIP_QUERY_PROFILE_CACHE_STATE"||n==="SCIP_QUERY_PROFILE_COMMAND"||n==="SCIP_QUERY_PROFILE_OUT"||n==="SCIP_QUERY_PROFILE_RUN_ID"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||n==="SCIP_QUERY_PROFILE_MIN_MS"}var zt={canonicalProjectRoot(n){try{return Ci(n)}catch{return ie(n)}},projectFingerprint(n){return Et(n)},engineIdentity:mn,fileFingerprint(n){return en(n,{maxBytes:H,inputKind:"Rust semantic engine artifact"})},environment(){return jt(process.env)}},Li={now:Date.now,monotonicNow:q,randomId:xi,isProcessAlive:we,readProcessIdentity:Pe,spawnServer(n,e,t){if(!Ut(n))throw new Error(`Durable Rust semantic session helper was not found at ${n}. Run npm run build first.`);Di(process.execPath,[n,e,t],{detached:!0,stdio:"ignore"}).unref()},sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)}};function Ht(n){return vi("sha256").update(n).digest("hex")}var Yt=15e3,Jt=8,Qt=5e3,ji=64,Wi=96,In=class{constructor(e,t,r={}){this.projectRoot=e;this.status=t;this.opts=r;this.requester=r.requester??$i(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,references:ye(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,references:z(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ye(e)}}}calleesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,callees:Se(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,callees:hn(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:Se(e)}}}referencesAndCalleesForDefinitions(e,t){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ye(e),callees:Se(t)};let i=[...e,...t];try{let o=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:t.length>0,referenceDefinitions:e,calleeDefinitions:t});return{available:o.available,resolvedBinary:r.resolvedBinary,reason:o.reason,references:z(e,new Map(o.references),new Set(o.incompleteReferenceSymbolIds??[])),callees:hn(t,new Map(o.callees??[]))}}catch(o){return this.fallbackReferencesAndCallees(r,e,t,o)}}signaturesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,signatures:Gt(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,signatures:Qi(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Gt(e)}}}importDefinitionsForFile(e,t){let r=this.status(this.projectRoot);if(t.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(t.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,t);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(t.map(o=>[o.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,t,r){let i=We(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yt),o=Ke(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),s=We(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Jt),a=Ke(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,u=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,f=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,l=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,...r}),p={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...t],...c?{referenceDefinitions:c}:{},...u?{calleeDefinitions:u}:{},...f?{signatureDefinitions:f}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:s,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=Zi(p);return w("rust.semantic.session.request",()=>this.requester.requestSemantic(p,Y(d,Mn(i,p.referenceRetryTimeoutMs),s)),()=>({definitions:t.length,operationDefinitions:d,referenceDefinitions:p.referenceDefinitions?.length,calleeDefinitions:p.calleeDefinitions?.length,signatureDefinitions:p.signatureDefinitions?.length,references:p.includeReferences!==!1,callees:p.includeCallees===!0,signatures:p.includeSignatures===!0,referenceRetryTimeoutMs:p.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,t,r,i){let o=t.length===0?{available:!0,references:ye(t)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(t),s=r.length===0?{available:!0,callees:Se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return o&&s?{available:o.available&&s.available,resolvedBinary:o.resolvedBinary??s.resolvedBinary??e.resolvedBinary,reason:o.reason??s.reason,references:z(t,o.references),callees:hn(r,s.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ye(t),callees:Se(r)}}requestImportDefinitions(e,t,r){let i=We(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yt),o=We(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Jt),s=Ke(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Ke(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Qt),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:t,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:s,settleDelayMs:a,concurrency:o};return w("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,Y(r.length,i,o)),()=>({file:t,positions:r.length}))}};function Zt(n,e,t={}){return new In(n,e,t)}function ge(n,e){let t=er(n);if(t!==null)return t;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ji||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Wi?0:Qt}function Ki(n){let e=n?.trim().toLowerCase(),t=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:t||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||t||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function zi(n){return Ki(n).transport}function Hi(n,e){let t=null,r=!1,i=!1,o=!1,s=()=>t??=e(),a=()=>{i||(n.shutdown(),i=!0)},c=(f,l,p)=>{let d=Gi(f);r=!0;try{a()}catch{}N()&&xe({type:"span",name:"rust.semantic.durable-session.request",durationMs:p,ok:!1,kind:l,session:"worker-fallback",reason:d})},u=(f,l,p)=>{if(o)throw new Error("Rust semantic failover session was already disposed.");if(r)return p(s());let d=performance.now();try{return l(n)}catch(S){c(S,f,performance.now()-d)}return p(s())};return{requestSemantic(f,l){return u("semantic",p=>p.requestSemantic(f,l),p=>p.requestSemantic(f,l))},requestImportDefinitions(f,l){return u("import-definitions",p=>p.requestImportDefinitions(f,l),p=>p.requestImportDefinitions(f,l))},shutdown(){if(o)return;o=!0;let f=[];try{a()}catch(l){f.push(l)}try{t?.shutdown()}catch(l){f.push(l)}if(f.length>0)throw f[0]}}}function $i(n,e,t={worker:()=>Vi(),durable:()=>Wt(n,{serverPath:ze(Xi()),semanticWorkerPath:ze(Xt())})}){return zi(e)==="durable"?Hi(t.durable(),t.worker):t.worker()}function Vi(n={}){let e=null,t=null,r=1,i=!1,o=()=>{t&&(Rn(t,{recursive:!0,force:!0}),t=null)},s=()=>{let u=e;e=null,u&&u.terminate(),o()},a=()=>{if(e)return e;let u=n.semanticWorkerPath?Ui(n.semanticWorkerPath):Xt();if(!Oi(ze(u)))throw new Error(`Rust semantic session worker was not found at ${ze(u)}. Run npm run build before using built semantic Rust queries.`);return t=$t(bn(Vt(),"scip-query-rust-session-")),e=new Bi(u,n.shareEnvironment?{env:qi}:void 0),e.unref(),e},c=()=>{let u=t??$t(bn(Vt(),"scip-query-rust-session-"));return t=u,bn(u,`${r++}.json`)};return{requestSemantic(u,f){if(i)throw new Error("Rust semantic session was already disposed.");let l=a(),p=c(),d=new SharedArrayBuffer(4),S=new Int32Array(d);if(l.postMessage({kind:"semantic",request:u,responsePath:p,sharedBuffer:d}),Atomics.wait(S,0,0,f)==="timed-out")throw s(),new Error(`Rust semantic session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let g=Yi(W(p,{maxBytes:H,inputKind:"Rust semantic worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Rn(p,{force:!0})}},requestImportDefinitions(u,f){if(i)throw new Error("Rust semantic session was already disposed.");let l=a(),p=c(),d=new SharedArrayBuffer(4),S=new Int32Array(d);if(l.postMessage({kind:"import-definitions",request:u,responsePath:p,sharedBuffer:d}),Atomics.wait(S,0,0,f)==="timed-out")throw s(),new Error(`Rust semantic import-definition session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let g=Ji(W(p,{maxBytes:H,inputKind:"Rust import-definition worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Rn(p,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){o();return}let u=c(),f=new SharedArrayBuffer(4),l=new Int32Array(f);e.postMessage({kind:"shutdown",responsePath:u,sharedBuffer:f}),Atomics.wait(l,0,0,5e3),s()}}}function Yi(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ji(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Gi(n){let e=n instanceof Error?`${n.name} ${n.message}`.toLowerCase():String(n).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ye(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Se(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Gt(n){return new Map(n.map(e=>[e.symbolId,null]))}function hn(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??[]]))}function Qi(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Zi(n){let e=0;return n.includeReferences!==!1&&(e+=(n.referenceDefinitions??n.definitions).length),n.includeCallees===!0&&(e+=(n.calleeDefinitions??n.definitions).length),n.includeSignatures===!0&&(e+=(n.signatureDefinitions??n.definitions).length),Math.max(1,e)}function Mn(n,e){return e&&e>0?Math.max(n,e):n}function Xt(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Xi(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function We(n,e){return X(n)??e}function Ke(n,e){return er(n)??e}function er(n){if(!n)return null;let e=Number(n);return Number.isInteger(e)&&e>=0?e:null}var xn=15e3,Cn=8;function ir(n,e={}){let t=e.status??Oe,r=ro(n,t),i=io(n,t),o=oo(n,t),s=e.referenceResolver||e.calleeResolver||e.signatureResolver||!no(e)?null:Zt(n,t,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:o}),a=e.referenceResolver??s??r,c=e.calleeResolver??s??i,u=e.signatureResolver??s??o,f=e.importUsageResolver??Dt(e.sourceImportUsageResolver??to(),e.importDefinitionResolver??s),l=e.calleeSymbolResolver,p=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,S=new Map,h=new Map,g=null,y=null,k=()=>(g??=t(n),g),P=()=>{let R=k();return R.dependencyAvailable?y??R:R},I=R=>{if(R.length===0)return new Map;let m=Re(R);try{let b=a.referencesForDefinitions(m),T=k();return y={...T,available:b.available,resolvedBinary:b.resolvedBinary??T.resolvedBinary,reason:b.reason??T.reason},b.available?new Map(b.references):z(m,b.references)}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},J(m)}},C=R=>{if(R.length===0)return new Map;let m=Re(R),b=m.filter(nr);if(b.length===0)return G(m);let T=new Map,j=rr(b,d),A=[];for(let D of b)h.has(D.symbolId)?T.set(D.symbolId,h.get(D.symbolId)??[]):j.has(D.symbolId)?T.set(D.symbolId,j.get(D.symbolId)??[]):tr(D,p)?T.set(D.symbolId,[]):A.push(D);if(A.length===0)return oe(m,T,void 0);try{let D=c.calleesForDefinitions(A),_=k();y={..._,available:D.available,resolvedBinary:D.resolvedBinary??_.resolvedBinary,reason:D.reason??_.reason};let E=oe(A,D.callees,l);for(let[Z,Qe]of E)T.set(Z,Qe);return oe(m,T,void 0)}catch(D){return y={...k(),available:!1,reason:D instanceof Error?D.message:String(D)},G(m)}},x=(R,m)=>{let b=Re(R),T=Re(m),j=T.filter(nr),A=new Map,D=rr(j,d),_=[];for(let E of j)D.has(E.symbolId)?A.set(E.symbolId,D.get(E.symbolId)??[]):tr(E,p)?A.set(E.symbolId,[]):_.push(E);if(b.length===0&&_.length===0)return{references:J(b),callees:oe(T,A,void 0)};try{let E=s?s.referencesAndCalleesForDefinitions(b,_):lo(a,c,{referenceDefinitions:b,calleeDefinitions:_}),Z=k();y={...Z,available:E.available,resolvedBinary:E.resolvedBinary??Z.resolvedBinary,reason:E.reason??Z.reason};let Qe=E.available?new Map(E.references):z(b,E.references);for(let[Ze,Xe]of E.callees)A.set(Ze,Xe);let Vn=oe(T,A,l);for(let[Ze,Xe]of Vn)h.set(Ze,Xe);return{references:Qe,callees:Vn}}catch(E){return y={...k(),available:!1,reason:E instanceof Error?E.message:String(E)},{references:J(b),callees:G(T)}}},M=R=>{if(R.length===0)return new Map;let m=Re(R);try{let b=u.signaturesForDefinitions(m),T=k();return y={...T,available:b.available,resolvedBinary:b.resolvedBinary??T.resolvedBinary,reason:b.reason??T.reason},or(m,b.signatures)}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},He(m)}};return{language:"rust",availability:P,dispose:()=>{s?.dispose()},importUsage:R=>{let m=S.get(R);if(m)return m;try{let b=f.importUsage(R);return S.set(R,b),b}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},[]}},referencesFor:R=>I([R]).get(R.symbolId)??[],referencesForDefinitions:I,referencesAndCalleesForDefinitions:x,calleesFor:R=>C([R]).get(R.symbolId)??[],calleesForDefinitions:C,signatureFor:R=>M([R]).get(R.symbolId)??null}}function no(n){if(n.usePersistentSession!==void 0)return n.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function to(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function Re(n){return n.map(e=>{let t=e;return{...e,leaf:typeof t.leaf=="string"?t.leaf:$(e.symbol),parentTypeName:t.parentTypeName??null,isFunctionLike:typeof t.isFunctionLike=="boolean"?t.isFunctionLike:pt(e.symbol),isTypeLike:t.isTypeLike??!1,kind:t.kind??null,documentation:t.documentation??null,enclosingSymbol:t.enclosingSymbol??null}})}function nr(n){return n.isFunctionLike}function tr(n,e){if(!e)return!1;try{return e(n)}catch{return!1}}function rr(n,e){if(!e||n.length===0)return new Map;try{return e(n)}catch{return new Map}}function ro(n,e){return{referencesForDefinitions:t=>so(n,e,t)}}function io(n,e){return{calleesForDefinitions:t=>ao(n,e,t)}}function oo(n,e){return{signaturesForDefinitions:t=>co(n,e,t)}}function so(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:J(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:J(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=$e(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),c=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),u=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!0}),f={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,...s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:c,settleDelayMs:u,concurrency:a},l=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(f),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,Mn(o,f.referenceRetryTimeoutMs),a)}),p=kn(l.stdout);if(p)return{available:p.available,resolvedBinary:r.resolvedBinary,reason:p.reason,references:z(t,new Map(p.references),new Set(p.incompleteReferenceSymbolIds??[]))};let d=l.error instanceof Error?l.error.message:l.stderr.trim()||`Rust semantic worker exited with status ${l.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:J(t)}}function ao(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:G(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:G(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),a=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!0},f=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),l=kn(f.stdout);if(l)return{available:l.available,resolvedBinary:r.resolvedBinary,reason:l.reason,callees:oe(t,new Map(l.callees??[]),void 0)};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,callees:G(t)}}function co(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:He(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:He(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),a=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!1,includeSignatures:!0},f=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),l=kn(f.stdout);if(l)return{available:l.available,resolvedBinary:r.resolvedBinary,reason:l.reason,signatures:or(t,new Map(l.signatures??[]))};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,signatures:He(t)}}function lo(n,e,t){let r=t.referenceDefinitions.length>0?n.referencesForDefinitions(t.referenceDefinitions):{available:!0,references:J(t.referenceDefinitions)},i=t.calleeDefinitions.length>0?e.calleesForDefinitions(t.calleeDefinitions):{available:!0,callees:G(t.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function J(n){return new Map(n.map(e=>[e.symbolId,[]]))}function G(n){return new Map(n.map(e=>[e.symbolId,[]]))}function He(n){return new Map(n.map(e=>[e.symbolId,null]))}function oe(n,e,t){let r=0,i=0;return w("rust.semantic.callees.complete-map",()=>{let o=new Map;for(let s of n){let a=e.get(s.symbolId)??[];a.length>0&&(r+=1),i+=a.length,o.set(s.symbolId,a.map(c=>({...c,symbol:t?t(c):c.symbol})))}return o},()=>({definitions:n.length,rows:r,callees:i,resolveSymbols:!!t}))}function or(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Tn(){return eo(new URL("./rust-semantic-worker.js",import.meta.url))}function kn(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e;return typeof t.available!="boolean"||!Array.isArray(t.references)?null:{available:t.available,reason:typeof t.reason=="string"?t.reason:void 0,references:t.references,incompleteReferenceSymbolIds:Array.isArray(t.incompleteReferenceSymbolIds)?t.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(t.callees)?t.callees:void 0,signatures:Array.isArray(t.signatures)?t.signatures:void 0}}catch{return null}}function se(n,e){return X(n)??e}function $e(n,e){if(!n)return e;let t=Number(n);return Number.isInteger(t)&&t>=0?t:e}import{existsSync as uo}from"fs";import{deserializeSCIP as fo,SymbolRole as po}from"@c4312/scip";var wn=new WeakMap;function ar(n,e){let t=e.filter(mo);if(t.length===0)return new Map;let r=!1,i=0,o=0;return w("rust.scip-occurrence.callees",()=>{let s=go(n);if(r=!!s,!s)return new Map;let a=new Map;for(let c of t){let u=yo(n,s,c);u!==null&&(a.set(c.symbolId,u),i+=1,o+=u.length)}return a},()=>({definitions:e.length,candidates:t.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:o}))}function mo(n){return!(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||!n.isFunctionLike||n.leaf==="main"||de(n.symbol))}function yo(n,e,t){let r=Ce(n,t.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(u=>u.startLine!==t.startLine||u.endLine!==t.endLine?!1:u.name===t.leaf||t.leaf.endsWith(u.name)||u.name.endsWith(t.leaf));if(!i)return null;let o=r.callSites.filter(u=>u.line>=i.startLine&&u.line<=i.endLine);if(o.length===0)return null;let s=(e.occurrencesByFile.get(t.relativePath)??[]).filter(u=>u.line>=i.startLine&&u.line<=i.endLine&&u.callee.symbol!==t.symbol);if(s.some(u=>u.traitImplMember)||!So(o,s))return null;let a=[],c=new Set;for(let u of s){let f=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;c.has(f)||(c.add(f),a.push(u.callee))}return a}function So(n,e){let t=sr(n),r=sr(e);if(t.size!==r.size)return!1;for(let[i,o]of t)if(r.get(i)!==o)return!1;return!0}function sr(n){let e=new Map;for(let t of n){let r=t.calleeLeaf??t.leaf;if(!r)continue;let i=`${t.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function go(n){if(wn.has(n))return wn.get(n)??null;let e=Ro(n);return wn.set(n,e),e}function Ro(n){if(!n.generation.indexPath||!uo(n.generation.indexPath))return null;try{let e=ke(n).filter(o=>o.symbol.startsWith("rust-analyzer ")&&o.relativePath.endsWith(".rs")&&o.isFunctionLike),t=new Map(e.map(o=>[o.symbol,o])),r=fo(De(n.generation.indexPath,{inputKind:"SCIP occurrence-callee index",maxBytes:Me})),i=new Map;for(let o of r.documents??[]){let s=o.relativePath;if(!s||!s.endsWith(".rs")||n.isIgnored(s))continue;let a=[];for(let c of o.occurrences??[]){if(!c.symbol||(c.symbolRoles&po.Definition)!==0)continue;let u=t.get(c.symbol);if(!u)continue;let f=c.range?.[0];Number.isInteger(f)&&a.push({line:f,leaf:u.leaf,traitImplMember:de(u.symbol),callee:{symbol:u.symbol,file:u.relativePath,line:u.startLine}})}i.set(s,a)}return{occurrencesByFile:i}}catch{return null}}var Ve=class{sessions=new WeakMap;getOrCreate(e,t,r){let i=bo(e,t),o=this.sessions.get(e);o||(o=new Map,this.sessions.set(e,o));let s=o.get(i);if(s)return s.hits+=1,s.lastUsedAtMs=Date.now(),s.provider;let a=Date.now(),c=r();return o.set(i,{key:i,language:t,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let t=this.sessions.get(e);if(t)for(let r of t.values())r.provider.dispose?.();this.sessions.delete(e)}};function bo(n,e){return`${n.config.projectRoot}:${e}-workspace`}import{randomUUID as Ho}from"crypto";import{existsSync as $o}from"fs";import{dirname as Vo}from"path";import{performance as v}from"perf_hooks";function L(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}import ur from"path";import{realpathSync as cr}from"fs";function ho(n,e){return n.getReferences().map(t=>{let r=t.getNode();return Ye(r,e)})}function Io(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function fr(n,e,t,r){let i=[];for(let o of Io(n))for(let s of ho(o,r))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||i.push(s);for(let o of t)i.push(o);return ae(i)}function pr(n,e,t,r){let i=[],o=t?.getStart();for(let s of n.getReferences()){let a=s.getNode();ce(r,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:Ye(a,r),node:a}))}return i}function Ye(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:ce(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function dr(n,e,t){let r=n.getSourceFile(),i=Pn(r,n),o=n.getText(),s=new RegExp(`\\b${pe(o)}\\b`,"g"),a=r.getFullText().split(`
|
|
2
|
+
`),c=[];for(let u=0;u<a.length;u++){if(u===i)continue;let f=a[u]??"";s.lastIndex=0;let l;for(;(l=s.exec(f))!==null;)c.push({file:e,line:u,column:l.index})}return ae(c.filter(u=>ce(t,ur.join(t,u.file))===e))}function En(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 Pn(n,e){return n.getLineAndColumnAtPos(e.getStart()).line-1}function ae(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 ce(n,e){let t=n||process.cwd(),r=lr(t,e);if(r)return r;try{return lr(cr(t),cr(e))}catch{return null}}function lr(n,e){let t=ur.relative(n,e).replace(/\\/g,"/");return!t||t===".."||t.startsWith("../")?null:t}function mr(n,e,t,r){let i=Mo(e,r);return i.size===0?new Map:Do(n,t,i)}function Mo(n,e){let t=new Map;for(let r of K(n,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push(r)}return t}function Do(n,e,t){let r=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of vo(n,o)){let a=t.get(s);if(!a)continue;let c=Pn(e,o);for(let u of a){if(c<u.startLine-1||c>u.endLine+1)continue;let f=Math.abs(c-u.startLine),l=i.get(u.symbolId);l!==void 0&&l<=f||(i.set(u.symbolId,f),r.set(u.symbolId,o))}}}),r}function vo(n,e){let t=[],r=i=>{i&&!t.includes(i)&&t.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return n.Node.isIdentifier(e)&&r(e.getText()),t}var xo=Qn("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function yr(n,e,t,r){let i=_n(n,e),o=Fn(i.get(r)??[],t);if(o)return o;let s=[];for(let a of i.values())for(let c of a)((c.leaf||$(c.symbol)||"").includes(r)||c.symbol.includes(r))&&s.push(c);return Fn(s,t)}function An(n,e,t,r){return Fn(_n(n,e).get(r)??[],t)}function Sr(n,e){let t=new Map;for(let[r,i]of _n(n,e)){let o=i[0];o&&t.set(r,o)}return t}function _n(n,e){return xo.get(n,e,()=>{let t=new Map;for(let r of K(n,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push({...r,leaf:i})}for(let r of t.values())r.sort((i,o)=>i.startLine-o.startLine||i.endLine-o.endLine||i.symbolId-o.symbolId);return t})}function Fn(n,e){let t=null,r=Number.POSITIVE_INFINITY;for(let i of n){let o=Math.abs(i.startLine-e);(o<r||o===r&&t&&i.startLine<t.startLine)&&(t=i,r=o)}return t}import Co from"path";import{realpathSync as To}from"fs";function gr(n,e){let t=new Map,r=null,i=null,o=()=>(i??=ve(n,{extensions:_e}),i),s=()=>(r??=w("typescript.source-file-index",()=>ko(n.config.projectRoot,e,o()),()=>({projects:e.length,indexedDocuments:o().length})),r),a=c=>te(c)?L(t,c,()=>{let u=Rr(n.config.projectRoot,c);if(!u)return null;for(let{project:f,sourceFiles:l}of s()){let p=l.get(u)??null;if(p||(p=f.addSourceFileAtPathIfExists(u)??null,p&&Nn(l,p)),p)return{project:f,sourceFile:p}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:o}}function ko(n,e,t){let r=e.map(({project:i})=>{let o=new Map;for(let s of i.getSourceFiles())Nn(o,s);return{project:i,sourceFiles:o}});for(let i of t){let o=Rr(n,i);if(o)for(let s of r){if(s.sourceFiles.has(o))break;let a=s.project.addSourceFileAtPathIfExists(o)??null;if(a){Nn(s.sourceFiles,a);break}}}return r}function Nn(n,e){let t=Ln(e.getFilePath());n.set(t,e);try{n.set(Ln(To(t)),e)}catch(r){if(!fe(r))throw r}}function Rr(n,e){try{return Ln(it(n,e,{inputKind:"indexed TypeScript source file"}).absolutePath)}catch(t){if(!fe(t))throw t;return null}}function Ln(n){return Co.resolve(n)}function On(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function br(n){let e=`${n.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as be}from"fs";import F from"path";var Un=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function qn(n,e){let r=e?F.dirname(F.join(n,e)):n,i=F.resolve(n);for(;r.startsWith(i);){for(let s of Un){let a=F.join(r,s);if(be(a))return a}let o=F.dirname(r);if(o===r)break;r=o}for(let o of Un){let s=F.join(n,o);if(be(s))return s}return null}function hr(n){let e=n.config.projectRoot,t=new Set(wo(e,n.config.semantic?.typescript?.tsconfigs)),r=ve(n,{includeIgnored:!1,extensions:_e});for(let i of r){let o=qn(e,i);o&&t.add(F.resolve(o))}if(t.size===0){let i=qn(e);i&&t.add(F.resolve(i))}return[...t].filter(i=>!Ir(e,i)).sort((i,o)=>i.localeCompare(o))}function wo(n,e=[]){let t=new Set;for(let r of e){let i=F.isAbsolute(r)?r:F.join(n,r);be(i)&&t.add(F.resolve(i))}for(let r of Eo(n))for(let i of Un){let o=F.join(r,i);be(o)&&t.add(F.resolve(o))}if(t.size===0){let r=qn(n);r&&t.add(F.resolve(r))}return[...t].filter(r=>!Ir(n,r)).sort((r,i)=>r.localeCompare(i))}function Eo(n){let e=F.join(n,"package.json");if(!be(e))return[];let t;try{t=JSON.parse(Jn(e,"project package manifest"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>tt(n,i))}function Ir(n,e){let t=F.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}var Po=32;function Tr(n,e){let t=w("typescript.provider.load",()=>Rt());if(!t)return Ne("ts-morph is not installed");let r=w("typescript.provider.tsconfig-discovery",()=>hr(n));if(r.length===0)return Ne("no tsconfig found");try{let i=w("typescript.provider.project-bundles",()=>bt(t,r),()=>({tsconfigs:r.length}));return Fo(n,t,i)}catch(i){return Ne(i instanceof Error?i.message:String(i),r[0],r)}}function Fo(n,e,t,r={}){return w("typescript.provider.construct",()=>new jn(n,e,t),()=>({tsconfigs:t.length,reusedProjects:r.reusedProjects===!0}))}var jn=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=nt(e.config.projectRoot),this.sourceFiles=gr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return L(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let r=_o();return w("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,t,r),()=>({file:e,...r}))})}referencesFor(e){return L(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,t)})}referencesForDefinitions(e,t={}){let r=new Map,i=N(),o=[];for(let f of e){let l=this.referencesCache.get(f.symbolId);l?r.set(f.symbolId,l):o.push(f)}if(o.length===0)return r;let s=o,a=t.exact?[]:o.filter(f=>!Dr(f));if(a.length>=Po){let f=this.referencesForDefinitionsBySymbolScan(a);for(let l of a){let p=f.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,p),r.set(l.symbolId,p)}if(s=o.filter(l=>Dr(l)),s.length===0)return r}let c=new Map;for(let f of s){let l=c.get(f.relativePath);l?l.push(f):c.set(f.relativePath,[f])}let u=[];for(let[f,l]of c){let p=vr();w("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(f);for(let S of l){i&&(p.cacheMisses+=1);let h=d.get(S.symbolId)??null;i&&(h?p.nodeHits+=1:p.nodeMisses+=1);try{let g=this.referencesForDefinitionNode(S,h,i?p:void 0);this.referencesCache.set(S.symbolId,g),r.set(S.symbolId,g)}catch{p.preciseSearchFailures+=1,u.push(S)}}},()=>({relativePath:f,definitions:l.length,...xr(p)}))}if(u.length>0){let f=this.referencesForDefinitionsBySymbolScan(u);for(let l of u){let p=f.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,p),r.set(l.symbolId,p)}}return r}referenceFragmentsForFiles(e){let t=ke(this.db).filter(o=>te(o.relativePath)),r=e.filter(o=>this.sourceFiles.sourceFile(o)!==null),i=this.referencesForDefinitionsBySymbolScan(t,r);return ht(t,i,r)}referencesForDefinitionsBySymbolScan(e,t){let r=N(),i=vr(),o=new Map,s=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)o.set(c.symbolId,[]);return w("typescript.references-map.inverted-scan",()=>{let c=r?v.now():0,u=t?this.packageImportReferencesForFiles(t):this.packageImportReferences();for(let g of e){let y=u.get(g.symbolId)??[];if(y.length>0){let k=o.get(g.symbolId)??[];k.push(...y),o.set(g.symbolId,k)}r&&(i.packageReferenceCount+=y.length)}r&&(i.packageRefsMs+=v.now()-c);let f=new Map,l=new Map,p=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(g=>g.leaf).filter(Boolean)),S=r?v.now():0;for(let g of t??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(g))continue;let y=this.sourceFiles.sourceFile(g);y&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(y,g,s,a,p,d,f,l,o,r?i:void 0))}r&&(i.scanMs+=v.now()-S);let h=r?v.now():0;this.addHierarchyMemberReferences(e,o,r?i:void 0),r&&(i.hierarchyMs+=v.now()-h);for(let[g,y]of o){let k=ae(y);o.set(g,k),r&&(i.referenceCount+=k.length)}},()=>({definitions:e.length,...xr(i)})),o}addReferencesFromSourceFileScan(e,t,r,i,o,s,a,c,u,f){let l=this.compilerCheckerForSourceFile(e),p=e.compilerNode,d=Oo(e),S=h=>{if(this.tsMorph.ts.isIdentifier(h)){if(f&&(f.identifiers+=1),!s.has(h.text)&&!d.has(h.text)){this.tsMorph.ts.forEachChild(h,S);return}let g=this.compilerReferenceSymbol(l,h,f);if(g){let y;a.has(g)?y=a.get(g)??null:(y=this.referenceDefinitionFromCompilerSymbol(g),a.set(g,y)),f&&(y?f.targetHits+=1:f.targetMisses+=1);let k=L(c,g,()=>this.compilerSymbolKeys(g)),P=null,I=null,C=y&&r.has(y.symbolId)?i.get(y.symbolId):void 0;if(C&&(P=Bn(p,h),!Mr(C,t,P))){let x=p.getLineAndCharacterOfPosition(h.getStart(p));I={file:t,line:x.line,column:x.character};let M=u.get(C.symbolId)??[];M.push(I),u.set(C.symbolId,M),f&&(f.requestedHits+=1)}for(let x of k)for(let M of o.get(x)?.values()??[]){if(P??=Bn(p,h),Mr(M,t,P))continue;if(!I){let m=p.getLineAndCharacterOfPosition(h.getStart(p));I={file:t,line:m.line,column:m.character}}let R=u.get(M.symbolId)??[];R.push(I),u.set(M.symbolId,R),f&&(f.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(h,S)};S(p)}hierarchyTargetsForDefinitions(e){let t=new Map;for(let r of e){let i=this.nodeForDefinition(r),o=i?.compilerNode;if(!o||!this.isHierarchyMethod(o))continue;let s=o.parent;if(!this.isHierarchyContainer(s))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(o.name);if(c)for(let u of this.hierarchyMemberSymbols(a,s,c))for(let f of this.compilerSymbolKeys(u)){let l=t.get(f)??new Map;l.set(r.symbolId,r),t.set(f,l)}}return t}hierarchyMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(!o.has(a)){o.add(a),i.add(c);for(let f of u){let l=f.getProperty(r.name);l&&s(f,l,this.hierarchyAncestorTypesForType(e,f))}}};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}addHierarchyMemberReferences(e,t,r){let i=new Map;for(let o of e){let s=this.nodeForDefinition(o),a=s?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let u=this.compilerCheckerForSourceFile(s.getSourceFile()),f=u.getSymbolAtLocation(a.name);if(!f)continue;let l=a.getSourceFile(),p=l.getLineAndCharacterOfPosition(a.name.getStart(l)),d={definition:o,location:{file:o.relativePath,line:p.line,column:p.character}},S=t.get(o.symbolId)??[];for(let g of this.hierarchyMemberSymbols(u,c,f))if(g!==f)for(let y of this.compilerSymbolLocations(g))S.push(y),r&&(r.hierarchyReferences+=1);t.set(o.symbolId,S);let h=this.hierarchyRootMemberSymbols(u,c,f);for(let g of h){let y=i.get(g)??new Map;y.set(o.symbolId,d),i.set(g,y)}r&&(r.hierarchyDefinitions+=1)}for(let o of i.values())if(!(o.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:s}of o.values()){let a=t.get(s.symbolId)??[];for(let c of o.values())c.definition.symbolId!==s.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));t.set(s.symbolId,a)}}}hierarchyRootMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(o.has(a))return;o.add(a);let f=!1;for(let l of u){let p=l.getProperty(r.name);p&&(f=!0,s(l,p,this.hierarchyAncestorTypesForType(e,l)))}if(!f)for(let l of this.compilerSymbolKeys(c))i.add(l)};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(t=>{let r=t.getSourceFile();return`${r.fileName}\0${t.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let t=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),o=ce(this.db.config.projectRoot,i.fileName);if(!o)continue;let s=r.name,a=i.getLineAndCharacterOfPosition((s??r).getStart(i));t.push({file:o,line:a.line,column:a.character})}return t}baseTypes(e,t){try{return e.getBaseTypes(t)??[]}catch{return[]}}hierarchyAncestorTypes(e,t){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(t)));for(let i of t.heritageClauses??[])for(let o of i.types)r.add(e.getTypeAtLocation(o));return[...r]}hierarchyAncestorTypesForType(e,t){let r=new Set(this.baseTypes(e,t));for(let i of t.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let o of i.heritageClauses??[])for(let s of o.types)r.add(e.getTypeAtLocation(s));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,t,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(t);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return L(this.calleesCache,e.symbolId,()=>L(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let t=new Map,r=new Map;for(let i of e){let o=r.get(i.relativePath);o?o.push(i):r.set(i.relativePath,[i])}for(let[i,o]of r){let s=this.fileCalleesCache.get(i),a=new Set(o.map(u=>u.symbolId)),c=s??this.calleeMapForFile(i,a);for(let u of o){let f=c.get(u.symbolId)??[];this.calleesCache.set(u.symbolId,f),t.set(u.symbolId,f)}}return t}referencesForDefinitionNode(e,t,r){let i=r?v.now():0,o=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=v.now()-i,r.packageReferenceCount+=o.length),!t)return o;let s=r?v.now():0,a=fr(t,e,o,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=v.now()-s,r.referenceCount+=a.length),a}signatureFor(e){return L(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 Cr(c)}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${Cr(o)}`})}importUsageForSourceFile(e,t,r){let i=[],o=new Map;for(let s of t.getImportDeclarations()){r.declarations+=1;let a=rn(this.db,e,s.getModuleSpecifierValue()),c=s.getImportClause()?.isTypeOnly()??!1;for(let u of Wn(s)){r.entries+=1;let f=c?null:u.identifier?.getSymbol()?.compilerSymbol??null;!c&&u.identifier&&(f?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let l={sourcePath:a,entry:u,typeOnlyDeclaration:c,bindingSymbol:f,references:[]};if(i.push(l),c||!u.localName||!f)continue;let p=o.get(u.localName);p?p.push(l):o.set(u.localName,[l])}}return o.size>0&&t.forEachDescendant(s=>{if(s.getKindName()!=="Identifier")return;let a=o.get(s.getText());if(!a||No(s))return;r.scannedIdentifiers+=1;let c=s.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let u of a)if(u.bindingSymbol===c){u.references.push({location:Ye(s,this.db.config.projectRoot),node:s}),r.matchedReferences+=1;break}}}),i.map(s=>s.typeOnlyDeclaration?Ao(e,s.sourcePath,s.entry):s.entry.identifier&&!s.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,s.sourcePath,s.entry)):this.valueImportUsageFromLocations(e,s.sourcePath,s.entry,s.references))}valueImportUsageForEntry(e,t,r){let i=r.identifier?r.identifier.findReferences():[],o=[];for(let s of i)for(let a of pr(s,e,r.identifier,this.db.config.projectRoot))o.push(a);return this.valueImportUsageFromLocations(e,t,r,o)}valueImportUsageFromLocations(e,t,r,i){let o=i.some(c=>!En(c.node)),s=i.some(c=>En(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||s,isValueUsed:o,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let t=new Map,r=new Set;for(let o of e){let s=this.sourceFiles.sourceFile(o);if(s)for(let a of s.getImportDeclarations()){let c=On(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return t;let i=this.packageExportsForNames(r);for(let o of e)this.addPackageImportReferencesForDocument(t,i,o);for(let[o,s]of t)t.set(o,ae(s));return t}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,r);for(let[r,i]of e)e.set(r,ae(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,r,o)}addPackageImportReferencesForDeclaration(e,t,r,i){let o=On(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of Wn(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let u=dr(a.identifier,r,this.db.config.projectRoot);u.length>0&&jo(e,c,u)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let t=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let o of br(r))this.collectPackageExports(r,o,i,new Set);i.size>0&&t.set(r.name,i)}return t}collectPackageExports(e,t,r,i){if(i.has(t))return;i.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?rn(this.db,t,a):t;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let u=s.getNamedExports();if(u.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let f of u){let l=f.getNameNode().getText(),p=f.getAliasNode()?.getText()??l,d=this.indexedDefinitionByLeaf(c,l);if(!d)continue;let S=r.get(p);S||(S=new Set,r.set(p,S)),S.add(d.symbolId)}}}indexedDefinitionByLeaf(e,t){return L(this.indexedDefinitionLeafCache,e,()=>Sr(this.db,e)).get(t)??null}nodeForDefinition(e){return L(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return L(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?mr(this.tsMorph,this.db,t,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,t,r=!1){let i=e.name,o=t?v.now():0,s=e.declarations??[];t&&(t.declarationsMs+=v.now()-o,t.declarationChecks+=s.length);for(let a of s){let c=t?v.now():0,u=a.getSourceFile(),f=ce(this.db.config.projectRoot,u.fileName),l=u.getLineAndCharacterOfPosition(a.getStart(u)).line;if(t&&(t.declarationLocationMs+=v.now()-c),!f||this.db.isIgnored(f))continue;let p=t?v.now():0,d=this.compilerDeclarationName(a),S=r?An(this.db,f,l,i)??(d&&d!==i?An(this.db,f,l,d):null):yr(this.db,f,l,i);if(t&&(t.indexedLookupMs+=v.now()-p),S)return{symbolId:S.symbolId,symbol:S.symbol,file:S.relativePath,line:S.startLine}}return null}compilerDeclarationName(e){let t=e.name;return t&&this.tsMorph.ts.isIdentifier(t)?t.text:null}calleeMapForFile(e,t){let r=N(),i=0,o=0,s=0,a=0,c=0,u=0,f=0,l=0,p=r?qo():void 0;return w("typescript.callee-map.file",()=>{let d=r?v.now():0,S=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(v.now()-d)),!S)return new Map;let h=r?v.now():0,g=K(this.db,e).sort((R,m)=>R.startLine-m.startLine||m.endLine-R.endLine);if(r&&(u=Math.round(v.now()-h)),i=g.length,g.length===0)return new Map;let y=new Map,k=r?v.now():0,P=this.compilerCheckerForSourceFile(S),I=S.compilerNode;r&&(f=Math.round(v.now()-k));let C=new Map,x=R=>{if(this.tsMorph.ts.isCallExpression(R)||this.tsMorph.ts.isNewExpression(R)){r&&(o+=1);let m=this.semanticCalleeForCallNode(P,I,g,R,C,t,p);m&&(r&&(s+=1),Lo(y,m.callerId,m.target))}this.tsMorph.ts.forEachChild(R,x)},M=r?v.now():0;x(I),r&&(l=Math.round(v.now()-M));for(let[R,m]of y)y.set(R,Wo(m));return a=y.size,y},()=>({relativePath:e,definitions:i,callNodes:o,resolvedCallees:s,outputRows:a,requestedDefinitions:t?.size??i,sourceFileLookupMs:c,definitionsLoadMs:u,checkerLookupMs:f,traversalMs:l,...p?Bo(p):{}}))}semanticCalleeForCallNode(e,t,r,i,o,s,a){let c=a?v.now():0,u=Uo(r,Bn(t,i));if(a&&(a.callerLookupMs+=v.now()-c),!u)return null;if(s&&!s.has(u.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let f=i.expression,l=this.compilerSymbolForExpression(e,f,a),p=null;if(l)if(a&&(a.targetSymbolHits+=1),o.has(l))a&&(a.compilerSymbolCacheHits+=1),p=o.get(l)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?v.now():0;p=this.definitionFromCompilerSymbol(l,a),a&&(a.targetLookupMs+=v.now()-d),o.set(l,p)}else a&&(a.targetMisses+=1);return p?{callerId:u.symbolId,target:{symbol:p.symbol,file:p.file,line:p.line}}:null}compilerSymbolForExpression(e,t,r){let i=r?v.now():0,o=e.getSymbolAtLocation(t);if(r&&(r.expressionSymbolMs+=v.now()-i),o)return o;r&&(r.typeFallbacks+=1);let s=r?v.now():0,a=e.getTypeAtLocation(t).getSymbol();return r&&(r.typeSymbolMs+=v.now()-s),a}compilerCheckerForSourceFile(e){let t=e.getProject(),r=this.compilerCheckerCache.get(t);return r||(r=t.getTypeChecker().compilerObject,this.compilerCheckerCache.set(t,r)),r}};function Wn(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 Ao(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 _o(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function No(n){for(let e=n;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function Lo(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function Oo(n){let e=new Set;for(let t of n.getImportDeclarations())for(let r of Wn(t))r.localName&&e.add(r.localName);return e}function Uo(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 Bn(n,e){return n.getLineAndCharacterOfPosition(e.getStart(n)).line}function Mr(n,e,t){return e===n.relativePath&&t>=n.startLine&&t<=n.endLine}function Dr(n){return n.symbol.includes("#")?Te(n.symbol)==="type"&&n.relativePath.endsWith(".d.ts"):!1}function qo(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function Bo(n){return{...n,callerLookupMs:Math.round(n.callerLookupMs),expressionSymbolMs:Math.round(n.expressionSymbolMs),typeSymbolMs:Math.round(n.typeSymbolMs),targetLookupMs:Math.round(n.targetLookupMs),declarationsMs:Math.round(n.declarationsMs),declarationLocationMs:Math.round(n.declarationLocationMs),indexedLookupMs:Math.round(n.indexedLookupMs)}}function vr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function xr(n){return{...n,scanMs:Math.round(n.scanMs),packageRefsMs:Math.round(n.packageRefsMs),semanticRefsMs:Math.round(n.semanticRefsMs),hierarchyMs:Math.round(n.hierarchyMs)}}function jo(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function Wo(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 Cr(n){return n.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{join as Ko}from"path";var Je=3;var zo="typescript-semantic";function kr(n){let e=Ko(n,zo),t=Fe(e);return{...t,requestDir:t.legacyRequestDir}}var Yo=12e4,Jo=5;function Pr(n,e,t={}){let r=new Kn(n,t),i=null,o=null,s=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Tr(n,e),i),c=(l,p,d)=>{if(s)return d();try{return p(r.request(l))}catch{return s=!0,d()}},u=(l,p)=>c({kind:"references",definitions:[...l],...p?.exact?{exact:!0}:{}},d=>Er(d),()=>a().referencesForDefinitions?.(l,p)??new Map(l.map(d=>[d.symbolId,a().referencesFor(d)]))),f=l=>c({kind:"callees",definitions:[...l]},p=>Er(p),()=>a().calleesForDefinitions?.(l)??new Map(l.map(p=>[p.symbolId,a().calleesFor(p)])));return{language:"typescript",availability:()=>(o??=c({kind:"availability"},Zo,()=>a().availability()),o),importUsage:l=>c({kind:"import-usage",file:l},p=>p,()=>a().importUsage(l)),referencesFor:l=>u([l]).get(l.symbolId)??[],referencesForDefinitions:u,referenceFragmentsForFiles:l=>c({kind:"reference-fragments",files:[...l]},p=>Qo(p),()=>a().referenceFragmentsForFiles?.(l)??new Map),calleesFor:l=>f([l]).get(l.symbolId)??[],calleesForDefinitions:f,signatureFor:l=>c({kind:"signature",definition:l},Xo,()=>a().signatureFor(l)),dispose:()=>i?.dispose?.()}}var Kn=class{constructor(e,t={}){this.db=e;this.runtime=t.runtime??ns,this.timeoutMs=t.timeoutMs??es(),this.mailboxLimits=t.mailboxLimits??{},this.cacheDir=Vo(e.config.dbPath),this.projectRoot=gt(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(e){let t=St(this.cacheDir),r=kr(this.cacheDir),i=an(t.statePath);if(!wr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let o=this.db.generation.identity;if(!o)throw new Error("Published TypeScript generation identity is unavailable.");let s=this.runtime.now(),a=s+this.timeoutMs,c=(this.runtime.monotonicNow??q)()+this.timeoutMs,u=rt(),f=ee("typescript-semantic-v3",{generation:o,profileEnvironment:u,request:e}),l=ne(f),p=Ae(r,{mailboxVersion:V,operationKey:f,clientId:this.runtime.randomId(),enqueuedAtMs:s,deadlineAtMs:a,protocolVersion:Je,id:l,generation:o,profileEnvironment:u,request:e},{nowMs:s,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??q)()<=c;){if($o(p.responsePath))return Go(W(p.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),l,o,f);let d=an(t.statePath);if(!wr(d,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Jo)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function wr(n,e,t){let r=n?.processIdentity?t.readProcessIdentity?.(n.pid):null;return n!==null&&n.projectRoot===e&&n.typescriptSemantic?.protocolVersion===Je&&t.isProcessAlive(n.pid)&&(!n.processIdentity||r!=null&&Ee(n.processIdentity,r))}function Go(n,e,t,r){let i=JSON.parse(n);if(i.protocolVersion!==Je||i.id!==e||i.operationKey!==r||i.ok===!0&&i.generation!==t)throw new Error("TypeScript semantic service wrote an incompatible response.");if(i.ok===!0)return i.response;throw new Error(typeof i.error=="string"?i.error:"TypeScript semantic service request failed.")}function Er(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(n)}function Qo(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(n)}function Zo(n){if(!n||typeof n!="object"||typeof n.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return n}function Xo(n){if(n!==null&&typeof n!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return n}function es(){let n=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(n)&&n>0?n:Yo}var ns={now:Date.now,monotonicNow:q,randomId:Ho,sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)},isProcessAlive:we,readProcessIdentity:Pe};var Fr=new Ve;Gn({name:"semantic-provider",groups:["semantic-provider"],clearAll:n=>Fr.clear(n)});function Q(n,e){let t=U(e)??"typescript";return Fr.getOrCreate(n,t,()=>t==="rust"?ir(n.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Mt(n,r)},calleeSymbolResolver:It(n),sourceZeroCalleeOracle:r=>ts(n,r),scipOccurrenceCalleeOracle:r=>ar(n,r)}):Pr(n,e))}function U(n){return n?at(n)==="rust"?"rust":te(n)?"typescript":null:"typescript"}function ts(n,e){let t=Ce(n,e.relativePath);if(!t||t.language!=="rust")return!1;let r=t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!t.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}function Cl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT
|
|
3
|
+
m.symbol_id,
|
|
4
|
+
d.relative_path,
|
|
5
|
+
COUNT(*) AS ref_count
|
|
6
|
+
FROM mentions m
|
|
7
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
8
|
+
JOIN documents d ON c.document_id = d.id
|
|
9
|
+
WHERE m.role != 1
|
|
10
|
+
${r}
|
|
11
|
+
${n.pathExclusionsFor("d")}
|
|
12
|
+
GROUP BY m.symbol_id, d.relative_path`,...t??[])})}function Tl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path
|
|
13
|
+
FROM mentions m
|
|
14
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
15
|
+
JOIN documents d ON c.document_id = d.id
|
|
16
|
+
WHERE m.role != 1
|
|
17
|
+
${r}
|
|
18
|
+
${n.pathExclusionsFor("d")}`,...t??[])}).filter(t=>t.symbol_id!==null)}function kl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id
|
|
19
|
+
FROM mentions m
|
|
20
|
+
WHERE m.role != 1
|
|
21
|
+
${r}`,...t??[])}).filter(t=>t.symbol_id!==null)}function Ar(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
|
|
22
|
+
c.start_line AS chunk_start, c.end_line AS chunk_end
|
|
23
|
+
FROM mentions m
|
|
24
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
25
|
+
JOIN documents d ON c.document_id = d.id
|
|
26
|
+
WHERE m.role != 1
|
|
27
|
+
${r}
|
|
28
|
+
${n.pathExclusionsFor("d")}
|
|
29
|
+
ORDER BY d.relative_path, c.start_line`,...t??[])})}function Ge(n,e,t){if(!e)return t();if(e.length===0)return[];let r=[];for(let i=0;i<e.length;i+=750)r.push(...t(e.slice(i,i+750)));return r}var rs=/^[A-Za-z_][A-Za-z0-9_]*$/,_r=/\bDefault::default\b/g,is=/^\.\.\s*Default::default\b/;function Nr(n,e){let t=new Map,r=new Map;for(let i of e){let o=zn(n,i,r);o!==null&&t.set(i.symbolId,o)}return t}function zn(n,e,t=new Map){let r=ss(e.symbol);if(!r)return null;let i=Ar(n,[e.symbolId]);if(i.length===0)return null;let o=new RegExp(`(^|[^A-Za-z0-9_])${pe(r)}::default\\b`,"g"),s=new RegExp(`(^|[^A-Za-z0-9_])${pe(r)}\\s*$`),a=os(n,e.symbolId),c=[];for(let u of i){let f=as(n,u.relative_path,t);if(f===null)return null;let l=f.split(/\r?\n/),p=0,d=[],S=0;for(let h=u.chunk_start;h<=u.chunk_end&&h<l.length;h+=1){let y=l[h]??"",k=new Set;o.lastIndex=0;let P;for(;P=o.exec(y);)c.push({file:u.relative_path,line:h,column:P.index+P[1].length+r.length+2}),S+=1;for(let I=0;I<y.length;I+=1){let C=is.exec(y.slice(I));if(C){if(a&&d.includes(p)){let M=I+C[0].lastIndexOf("default");c.push({file:u.relative_path,line:h,column:M}),k.add(M),S+=1}I+=C[0].length-1;continue}let x=y[I];if(x==="{"){let M=s.test(y.slice(0,I));p+=1,M&&d.push(p);continue}if(x==="}")for(p=Math.max(0,p-1);d.length>0&&d[d.length-1]>p;)d.pop()}for(_r.lastIndex=0;P=_r.exec(y);){let I=P.index+9;if(!k.has(I))return null}}if(S===0)return null}return Ue(c)}function os(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function ss(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!rs.test(e)?null:e}function as(n,e,t){if(t.has(e))return t.get(e)??null;let r=n.get("SELECT text FROM documents WHERE relative_path = ?",e),i=typeof r?.text=="string"?r.text:cs(n,e);return t.set(e,i),i}function cs(n,e){try{return ot(n.config.projectRoot,e,{inputKind:"indexed Rust source file"})}catch(t){if(!fe(t))throw t;return null}}function Lr(n){let e=new Map;for(let t of n){let r=e.get(t.relativePath)??[];r.push(t),e.set(t.relativePath,r)}return e}var ls="typescript-import-usage-v1",us="typescript-signatures-v1",Hn=Zn("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),Or=sn({kind:"semantic-import-usage",invalidation:ue("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:Hr}),Ur=sn({kind:"semantic-signatures",invalidation:ue("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:hs}),qr=on({kind:"typescript-import-usage",invalidation:ue("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:Hr}),Br=on({kind:"typescript-signatures",invalidation:ue("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:Is});function Ie(n){let e=new Map,t=new Set;return{capability:(r,i)=>$r(n,r,i),importUsage:r=>ps(n,r),references:r=>Wr(n,r),materializeReferences:(r,i)=>Kr(n,r,e,t,i),callerMap:r=>ds(n,r,e,t),calleeMap:r=>gs(n,r),signature:r=>Rs(n,r)}}function fs(n,e){if(e.size===0)return;let t=Hn.get(n,()=>new Map);for(let[r,i]of e)t.set(r,[...i])}function Vl(n,e){if(!Hn.has(n))return{hits:[],misses:[...e]};let t=Hn.get(n,()=>new Map),r=[],i=[];for(let o of e)t.has(o.symbolId)?r.push({definition:o,callees:t.get(o.symbolId)??[]}):i.push(o);return{hits:r,misses:i}}function Yl(n,e){return Ie(n).importUsage(e)}function ps(n,e){if(U(e)==="typescript"){let o="fallback",s=0,a=0,c=0,u=0;return w("typescript.import-usage.materialize",()=>{let f=cn(n,e,ls);if(f?.key){s=1;let p=qr.read(n,e,f.key);if(p)return o="hit",a=1,p;c=1;let d=B(n,e);if(!d)return o="unavailable",[];let S=d.importUsage(e);return qr.write(n,e,f.key,S),o="computed",S}u=1;let l=B(n,e);return l?(o="direct-fallback",l.importUsage(e)):(o="unavailable",[])},()=>({state:o,eligible:s,cacheHits:a,cacheMisses:c,fallbacks:u}))}let t=zr(n,"semantic-import-usage",e);if(t){let o=Or.read(n,e,t);if(o)return o}let r=B(n,e);if(!r)return[];let i=r.importUsage(e);return t&&Or.write(n,e,t,i),i}function Jl(n,e){return Ie(n).references(e)}function Wr(n,e){let t=zn(n,e);if(t)return t;let r=xt(n,e);if(r)return r;let i=B(n,e.relativePath);return i?i.referencesFor(e):[]}function Gl(n,e){return Ie(n).callerMap(e)}function Ql(n,e){let t=new Map,r=new Map;for(let i of e){if(U(i.relativePath)==="typescript"){let o=B(n,i.relativePath);if(!o)continue;let s=r.get(o)??[];s.push(i),r.set(o,s);continue}$n(n,t,i,Wr(n,i))}for(let[i,o]of r){let s=un(n,o,c=>Q(n,c)),a=s?.references??(i.referencesForDefinitions?i.referencesForDefinitions(o,{exact:!0}):new Map(o.map(c=>[c.symbolId,i.referencesFor(c)])));!s&&N()&&ln(n,o,a,c=>Q(n,c));for(let c of o)$n(n,t,c,a.get(c.symbolId)??[])}return t}function ds(n,e,t=new Map,r=new Set){let i=new Map,o=Kr(n,e,t,r),s=0;return w("semantic.callers.from-references",()=>{for(let a of e)s+=$n(n,i,a,t.get(a.symbolId)??[])},()=>({definitions:e.length,materialized:o.definitions,inMemoryHits:o.inMemoryHits,incompleteInMemoryHits:o.incompleteInMemoryHits,resultRows:i.size,callerFiles:s})),i}function Kr(n,e,t,r,i={}){let o=tn(n),s=[],a=[],c=[],u=0,f=0,l=0,p=0,d=0,S=0,h=0,g=0,y=0,k=0,P=0,I=0,C=[],x=new Map,M=e.filter(m=>U(m.relativePath)==="typescript"&&!t.has(m.symbolId)&&!r.has(m.symbolId)),R=un(n,M,m=>Q(n,m));if(R){y=M.length,k=R.cacheHits,P=R.cacheMisses,I=R.computedFiles;for(let m of M)t.set(m.symbolId,R.references.get(m.symbolId)??[])}if(w("semantic.references.cache-scan",()=>{for(let[m,b]of Lr(e)){let T=[];for(let D of b)t.has(D.symbolId)?f+=1:r.has(D.symbolId)?g+=1:T.push(D);if(T.length===0){h+=1;continue}let j=ms(n,o,m);if(!j){for(let D of T)U(D.relativePath)||(u+=1),c.push(D);continue}S+=1;let A=Xn(n,m,j);for(let D of T){let _=A.get(D.symbol)??null;if(_!==null){let E=Ss(_);if(E){l+=1,t.set(D.symbolId,E);continue}p+=1}a.push({definition:D,cacheFingerprint:j})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:u,cacheHits:l,parseFailures:p,misses:a.length,unkeyed:c.length,inMemoryHits:f,incompleteInMemoryHits:g,fullyInMemoryFiles:h,cacheReadFiles:S})),a.length>0||c.length>0){C=[...c,...a.map(m=>m.definition)],x=w("semantic.references.compute-misses",()=>{let m=ys(n,C,i);return d=m.size,m},()=>({definitions:C.length,misses:a.length,unkeyed:c.length,rows:d}));for(let m of C)x.has(m.symbolId)?(t.set(m.symbolId,x.get(m.symbolId)??[]),r.delete(m.symbolId)):r.add(m.symbolId);for(let{definition:m,cacheFingerprint:b}of a)x.has(m.symbolId)&&$r(n,"semantic-references",m.relativePath).available&&s.push({relativePath:m.relativePath,symbol:m.symbol,projectFingerprint:b,payload:JSON.stringify(x.get(m.symbolId)??[])})}return s.length>0&&w("semantic.references.cache-write",()=>et(n,s),()=>({entries:s.length})),x.size>0&&ln(n,C,x,m=>Q(n,m)),{definitions:e.length,inMemoryHits:f,incompleteInMemoryHits:g,cacheHits:l,misses:a.length,unkeyed:c.length,skippedUnsupportedLanguage:u,parseFailures:p,computed:d,incomplete:r.size,cacheWrites:s.length,fragmentDefinitions:y,fragmentCacheHits:k,fragmentCacheMisses:P,fragmentComputedFiles:I}}function ms(n,e,t){if(!e)return null;let r=U(t);return r==="typescript"?e:r==="rust"?nn(JSON.stringify({kind:"semantic-references",language:r,engine:yn(n.config.projectRoot),projectFingerprint:e})):null}function ys(n,e,t={}){let r=N(),i=new Map,o=0,s=0,a=0,c=0,u=0,f=0,l=0,p=0,d=0;return w("semantic.references.provider-loop",()=>{let S=Nr(n,e),h=vt(n,e),g=new Map,y=t.prefetchCallees?new Map:null,k=[];for(let I of e){let C,x=()=>(C??=B(n,I.relativePath),C);if(y){let b=x();if(b?.referencesAndCalleesForDefinitions){let T=y.get(b);T?T.push(I):y.set(b,[I]),d+=1}}let M=S.get(I.symbolId);if(M){a+=1,c+=M.length,he(i,I.symbolId,M,r,b=>{l+=1,p+=b});continue}let R=h.get(I.symbolId);if(R){u+=1,f+=R.length,he(i,I.symbolId,R,r,b=>{l+=1,p+=b});continue}let m=x();if(!m){r&&(s+=1);continue}if(r&&(o+=1),m.referencesForDefinitions){let b=g.get(m);b?b.push(I):g.set(m,[I])}else k.push({provider:m,definition:I})}let P=new Set;if(y)for(let[I,C]of y){if(!I.referencesAndCalleesForDefinitions)continue;let x=g.get(I)??[],M=I.referencesAndCalleesForDefinitions(x,C);P.add(I),fs(n,M.callees);for(let R of x){if(!M.references.has(R.symbolId))continue;let m=M.references.get(R.symbolId)??[];he(i,R.symbolId,m,r,b=>{l+=1,p+=b})}}for(let[I,C]of g){if(P.has(I))continue;let x=I.referencesForDefinitions(C);for(let M of C){if(!x.has(M.symbolId))continue;let R=x.get(M.symbolId)??[];he(i,M.symbolId,R,r,m=>{l+=1,p+=m})}}for(let{provider:I,definition:C}of k){let x=I.referencesFor(C);he(i,C.symbolId,x,r,M=>{l+=1,p+=M})}return i},()=>({definitions:e.length,providerHits:o,providerMisses:s,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:c,rustScipOccurrenceFastPathRows:u,rustScipOccurrenceFastPathReferences:f,prefetchCalleeDefinitions:d,definitionsWithReferences:l,referenceCount:p,rows:i.size}))}function he(n,e,t,r,i){n.set(e,t),r&&t.length>0&&i(t.length)}function $n(n,e,t,r){let i=0;for(let o of r){if(o.file===t.relativePath||n.isIgnored(o.file))continue;let s=e.get(t.symbolId);s||(s=new Set,e.set(t.symbolId,s));let a=s.size;s.add(o.file),s.size!==a&&(i+=1)}return i}function Ss(n){try{return JSON.parse(n)}catch{return null}}function Zl(n,e){return Ie(n).calleeMap(e)}function gs(n,e){let t=N(),r=new Map,i=0,o=0,s=0,a=0;return w("semantic.callees.provider-loop",()=>{let c=new Map,u=[];for(let f of e){let l=B(n,f.relativePath);if(!l){t&&(o+=1);continue}t&&(i+=1);let p=f;if(l.calleesForDefinitions){let d=c.get(l);d?d.push(p):c.set(l,[p])}else u.push({provider:l,definition:p})}for(let[f,l]of c){let p=f.calleesForDefinitions(l);for(let d of l){let S=p.get(d.symbolId)??[];jr(r,d.symbolId,S,t,h=>{s+=1,a+=h})}}for(let{provider:f,definition:l}of u){let p=f.calleesFor(l);jr(r,l.symbolId,p,t,d=>{s+=1,a+=d})}return r},()=>({definitions:e.length,providerHits:i,providerMisses:o,definitionsWithCallees:s,calleeCount:a,rows:r.size}))}function jr(n,e,t,r,i){t.length>0&&(n.set(e,t),r&&i(t.length))}function Xl(n,e){return Ie(n).signature(e)}function Rs(n,e){if(U(e.relativePath)==="typescript"){let s="fallback",a=0,c=0,u=0,f=0;return w("typescript.signature.materialize",()=>{let l=cn(n,e.relativePath,us);if(l?.key){a=1;let d=Br.read(n,e.relativePath,l.key)??{};if(Object.prototype.hasOwnProperty.call(d,e.symbol))return s="hit",c=1,d[e.symbol]??null;u=1;let S=B(n,e.relativePath);if(!S)return s="unavailable",null;let h=S.signatureFor(e);return Br.write(n,e.relativePath,l.key,{...d,[e.symbol]:h}),s="computed",h}f=1;let p=B(n,e.relativePath);return p?(s="direct-fallback",p.signatureFor(e)):(s="unavailable",null)},()=>({state:s,eligible:a,cacheHits:c,cacheMisses:u,fallbacks:f}))}let t=zr(n,"semantic-signatures",e.relativePath),r=bs(e);if(t){let s=Ur.read(n,r,t);if(s)return s.signature}let i=B(n,e.relativePath);if(!i)return null;let o=i.signatureFor(e);return t&&Ur.write(n,r,t,{signature:o}),o}function zr(n,e,t){let r=tn(n);if(!r)return null;let i=U(t);return i!=="rust"?null:nn(JSON.stringify({kind:e,language:i,engine:yn(n.config.projectRoot),projectFingerprint:r}))}function bs(n){return`${n.relativePath}\0${n.symbol}`}function Hr(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:null}catch{return null}}function hs(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e.signature;return t!==null&&typeof t!="string"?null:{signature:t}}catch{return null}}function Is(n){try{let e=JSON.parse(n);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let t of Object.values(e))if(t!==null&&typeof t!="string")return null;return e}catch{return null}}function $r(n,e,t){let r=U(t);if(!r)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:r,...Q(n,t).availability()}}catch(i){return{slot:e,language:r,available:!1,reason:i instanceof Error?i.message:String(i)}}}function B(n,e){if(!U(e))return null;let t=Q(n,e);return t.availability().available?t:null}export{Cl as a,Tl as b,kl as c,Ar as d,Lr as e,yn as f,U as g,Ie as h,Vl as i,Yl as j,Jl as k,Gl as l,Ql as m,ys as n,Zl as o,Xl as p};
|
|
30
|
+
//# sourceMappingURL=chunk-E2LAW7SL.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as f,b as p}from"./chunk-QZ4JVECJ.js";import{a as g}from"./chunk-MZZBAITE.js";import{A as m,x as d}from"./chunk-WUW7YUAH.js";import{J as c,K as u,O as l}from"./chunk-JORHF5AL.js";import{readdirSync as k}from"fs";import{basename as S,join as y}from"path";function b(t,e,r={}){let n=new Set(t),a=new Set(e),o=[...a].filter(s=>!n.has(s)).sort(),i=r.allowExtra?[]:[...n].filter(s=>!a.has(s)).sort();return{missing:o,extra:i}}function N(t,e){let r=R(t,e.file,e.keys);if(!r.ok)return{name:e.name,file:e.file,status:"unavailable",missing:[],extra:[],unavailableReason:r.reason};let n=A(t.config.projectRoot,e.mustEqual),a=b(r.keys,n,{allowExtra:e.allowExtra??!1}),o=a.missing.length>0||a.extra.length>0?"violated":"ok";return{name:e.name,file:e.file,status:o,missing:a.missing,extra:a.extra}}function I(t,e){return e.map(r=>N(t,r))}function W(t,e){if(e.has(t.file))return!0;let r=t.mustEqual;switch(r.type){case"top-level-dirs":return[...e].some(n=>n===r.path||n.startsWith(`${r.path}/`));case"file-glob":return[...e].some(n=>f(r.pattern,n));case"registered-commands":return e.has("docs/COMMAND_REFERENCE.md");case"builtin-skills":return[...e].some(n=>n.startsWith("skills/"))}}function z(t){if(t.status==="unavailable")return`[coverage-contract] ${t.name}: DISCLOSED \u2014 could not evaluate (${t.unavailableReason})`;let e=[];return t.missing.length>0&&e.push(`missing ${t.missing.join(", ")}`),t.extra.length>0&&e.push(`extra ${t.extra.join(", ")}`),`[coverage-contract] ${t.name}: ${e.join("; ")}`}function R(t,e,r){return r.type==="markdown-list"?L(t,e,r.marker):D(t,e,r)}function D(t,e,r){if(!l(t,e))return{ok:!1,reason:`file not found: ${e}`};let a=d(e);if(!a)return{ok:!1,reason:`unsupported file type for ${r.type} extraction: ${e}`};let o=m(t,e);if(!o)return{ok:!1,reason:`tree-sitter parser unavailable for ${a} (${e}) \u2014 contract skipped, not silently passed`,disclosedUnavailable:{language:a,reason:"parser-unavailable"}};let i=r.type==="object-literal-keys"?$(o,r.identifier):T(o,r.identifier);return i===null?{ok:!1,reason:`no ${r.type==="object-literal-keys"?"object literal":"string array"} named "${r.identifier}" found in ${e}`}:{ok:!0,keys:i}}function v(t){let e=t.childForFieldName("value");return e?e.type==="as_expression"||e.type==="satisfies_expression"?e.namedChild(0):e:null}function $(t,e){for(let r of t.rootNode.descendantsOfType("variable_declarator")){if(r.childForFieldName("name")?.text!==e)continue;let a=v(r);if(a?.type==="object")return w(a)}return null}function w(t){let e=new Set;for(let r of t.namedChildren)if(r.type==="pair"){let n=r.childForFieldName("key");n&&e.add(x(n.text))}else r.type==="shorthand_property_identifier"&&e.add(r.text);return[...e].sort()}function T(t,e){for(let r of t.rootNode.descendantsOfType("variable_declarator")){if(r.childForFieldName("name")?.text!==e)continue;let a=v(r);if(a?.type!=="array")continue;let o=new Set;for(let i of a.namedChildren)i.type==="string"&&o.add(x(i.text));return[...o].sort()}return null}function x(t){return t.length>=2&&(t[0]==="'"&&t.endsWith("'")||t[0]==='"'&&t.endsWith('"'))?t.slice(1,-1):t}function L(t,e,r){let n=l(t,e);if(!n)return{ok:!1,reason:`file not found: ${e}`};let a=E(n,r);return a===null?{ok:!1,reason:`no <!-- BEGIN GENERATED ${r} --> ... <!-- END GENERATED ${r} --> block in ${e}`}:{ok:!0,keys:h(a)}}function E(t,e){let r=g(e),a=new RegExp(`<!--\\s*BEGIN GENERATED ${r}\\s*-->([\\s\\S]*?)<!--\\s*END GENERATED ${r}\\s*-->`).exec(t);return a?a[1]:null}function h(t){let e=new Set;for(let r of t.matchAll(/`([a-z][a-z0-9-]*)`/g))e.add(r[1]);for(let r of t.matchAll(/\[([a-z][a-z0-9-]*)\]\([^)]*\)/g))e.add(r[1]);return[...e].sort()}function A(t,e){switch(e.type){case"top-level-dirs":return C(y(t,e.path));case"file-glob":return[...new Set(p(t,e.pattern).map(r=>S(r)))].sort();case"registered-commands":return j(t);case"builtin-skills":return C(y(t,"skills"))}}function C(t){let e;try{e=k(t,{withFileTypes:!0})}catch{return[]}return e.filter(r=>r.isDirectory()&&!r.name.startsWith(".")).map(r=>r.name).sort()}function j(t){let e;try{e=c(t,"docs/COMMAND_REFERENCE.md",{maxBytes:8*1024*1024,inputKind:"generated command reference"})}catch(n){if(!u(n))throw n;return[]}let r=E(e,"COMMAND REFERENCE");return r?h(r):[]}var q={dead:{minLoc:3,skipBarrels:!0,deadCodeOnly:!0},isolated:{minLoc:3},similar:{minSimilarity:.6,limit:50,minCallees:4},duplicateBodies:{maxLoc:15,limit:50},extract:{minLoc:15,minCallees:5,limit:50},wrappers:{maxLoc:15,limit:50},passthroughs:{maxLoc:15,limit:50},stale:{minLoc:3,limit:50},drift:{},twinDrift:{minSimilarity:.3}};export{N as a,I as b,W as c,z as d,q as e};
|
|
2
|
+
//# sourceMappingURL=chunk-E3HYEQO7.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as d}from"./chunk-33XTHFKR.js";import{a as f}from"./chunk-SMQWE25B.js";import{d as m}from"./chunk-RA3AYNWP.js";import{J as u,K as p}from"./chunk-JORHF5AL.js";import{extname as y}from"path";function C(t,e,a={}){let{context:s=0}=a,r=L(e);if(r)return R(t,r.filePath,r.startLine,r.endLine,s);let i=f(t,e);return i?x(t,i,s):null}function L(t){let e=t.match(/^(.+\.\w+):(\d+)-(\d+)$/);return e?{filePath:e[1],startLine:parseInt(e[2],10),endLine:parseInt(e[3],10)}:null}function x(t,e,a){let s=t.get("SELECT language FROM documents WHERE relative_path = ?",e.relativePath),r;try{r=u(t.config.projectRoot,e.relativePath,{inputKind:"indexed source file"})}catch(c){if(!p(c))throw c;return null}let i=r.split(`
|
|
2
|
+
`),n=Math.max(0,e.startLine-a),l=Math.min(i.length-1,e.endLine+a),o=i.slice(n,l+1).join(`
|
|
3
|
+
`);return{symbol:e.symbol,shortName:m(e.symbol),relativePath:e.relativePath,startLine:n,endLine:l,language:s?.language??v(e.relativePath),source:o}}function R(t,e,a,s,r){let i=d(t,e);if(!i)return null;let n=t.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",i);if(!n)return null;let l;try{l=u(t.config.projectRoot,n.relative_path,{inputKind:"indexed source file"})}catch(h){if(!p(h))throw h;return null}let o=l.split(`
|
|
4
|
+
`),c=Math.max(0,a-1-r),g=Math.min(o.length-1,s-1+r),b=o.slice(c,g+1).join(`
|
|
5
|
+
`);return{symbol:`${n.relative_path}:${a}-${s}`,shortName:`${n.relative_path}:${a}-${s}`,relativePath:n.relative_path,startLine:c,endLine:g,language:n.language??v(n.relative_path),source:b}}function v(t){switch(y(t).toLowerCase()){case".ts":case".tsx":case".mts":case".cts":return"typescript";case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".py":case".pyi":return"python";case".rs":return"rust";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":return"scala";case".rb":return"ruby";case".php":return"php";case".cs":return"csharp";case".vb":return"vb";case".dart":return"dart";case".c":case".h":return"c";case".cc":case".cpp":case".cxx":case".hpp":case".hh":case".hxx":return"cpp";case".vue":return"vue";default:return null}}export{C as a};
|
|
6
|
+
//# sourceMappingURL=chunk-E4NFOAD4.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as le}from"./chunk-ACAM6O5R.js";import{c as T}from"./chunk-2SNGN6U4.js";import{b as Q,e as ee,f as te,g as ne}from"./chunk-LP3ARJKF.js";import{b as ce}from"./chunk-B75HZHUP.js";import{b as P}from"./chunk-KXDJAG4N.js";import{h as oe,n as N}from"./chunk-GLZTVKAB.js";import{a as ie,b as re,c as se,m as ae}from"./chunk-E2LAW7SL.js";import{B as E,d as $,e as J,g as K,h as q,i as G,j as V,k as X,w as Y}from"./chunk-RA3AYNWP.js";import{p as Z}from"./chunk-MZZBAITE.js";import{A as x,x as H}from"./chunk-WUW7YUAH.js";import{A as b,D as j,F as W,O as I,P as z,j as w,p as U}from"./chunk-JORHF5AL.js";import{a as S}from"./chunk-64MNV6AB.js";import{d as L}from"./chunk-VVY2G5ET.js";var _=new WeakMap,ue=j({kind:"definition-exclusions",invalidation:W("definition-exclusions"),serialize:e=>JSON.stringify(e),deserialize:Ie});function fe(e,t){let n=H(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let r=I(e,t);if(!r)return[];let o=U(e,t,r),c=ue.read(e,t,o);if(c)return c;let u=n==="rust"?Oe(e,t):ke(e,t);return ue.write(e,t,o,u),u}function Ie(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=t.map(Pe);return n.some(i=>i===null)?null:n}catch{return null}}function Pe(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"||t.containerName!==void 0&&typeof t.containerName!="string")return null;let n=t.disposition===void 0?Ge(t.reason):t.disposition;return n!=="exclude"&&n!=="implicit-usage"?null:{startLine:t.startLine,endLine:t.endLine,reason:t.reason,disposition:n,...t.containerName?{containerName:t.containerName}:{}}}var me=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),Ne=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,Te=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function ke(e,t){let n=I(e,t);if(!n||!Ae(n))return[];let i=x(e,t);if(!i)return[];let r=_.get(i);if(r)return r;let o=!1,c=i.rootNode;for(let l of c.namedChildren){if(l.type!=="expression_statement")continue;let d=l.namedChild(0);if(!d||d.type!=="call_expression")continue;let s=d.namedChild(0);if(!s)continue;let a=s.type==="member_expression"?s.namedChild(s.namedChildCount-1)?.text:s.text;if(a&&me.has(a)){o=!0;break}}let u=[];o&&u.push({startLine:0,endLine:c.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)",disposition:"exclude"});for(let l of c.namedChildren){let d=null,s=null;if(l.type==="function_declaration")d=l.namedChild(0)?.text??null,s=l;else if(l.type==="export_statement"){let a=l.namedChild(0);a?.type==="function_declaration"&&(d=a.namedChild(0)?.text??null,s=a)}else if(l.type==="lexical_declaration"){let a=l.namedChild(0);if(a?.type==="variable_declarator"){let m=a.namedChild(0)?.text,p=a.namedChild(1);m&&(p?.type==="arrow_function"||p?.type==="function_expression")&&(d=m,s=a)}}d&&/^use[A-Z]/.test(d)&&s&&u.push({startLine:s.startPosition.row,endLine:s.endPosition.row,reason:"React custom hook (use*)",disposition:"exclude"})}return u.push(...pe(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),_.set(i,u),u}function Ae(e){if(e.includes("scip-query"))return!0;let t=!1;for(let n of me)if(e.includes(n)){t=!0;break}return t&&Ne.test(e)?!0:e.includes("use")&&Te.test(e)}var Fe=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function Me(e){return Fe.test(e)}function pe(e,t,n){let i=[],r=o=>{if(t.has(o.type)&&o.parent){let u=o.parent.children,l=-1;for(let d=0;d<u.length;d+=1)if(u[d].startIndex===o.startIndex&&u[d].type===o.type){l=d;break}if(l>0)for(let d=l-1;d>=0;d-=1){let s=u[d];if(n.has(s.type)){if(Me(s.text)){i.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"scip-query suppression comment",disposition:"exclude"});break}continue}if(!(s.type==="attribute_item"||s.type==="inner_attribute_item"))break}}for(let c of o.namedChildren)r(c)};return r(e.rootNode),i}function Oe(e,t){let n=x(e,t);if(!n)return[];let i=_.get(n);if(i)return i;let r=[],o=Be(n);return o?(_.set(n,o),o):(ye(n.rootNode,r,!1,!1),r.push(...pe(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),r.push(...Ke(n.rootNode)),_.set(n,r),r)}function Be(e){return Ve(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)",disposition:"exclude"}]:null}function ye(e,t,n,i){let r=n,o=i;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)",disposition:"implicit-usage"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)",disposition:"implicit-usage"})),e.type==="function_item"||e.type==="function_signature_item"?Ue(e,t,n,i):i&&Je(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)",disposition:"implicit-usage"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?je(e,t,n):e.type==="mod_item"&&k(e).some(c=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(c))&&(r=!0);for(let c of e.namedChildren)ye(c,t,r,o)}function Ue(e,t,n,i){let r=k(e),o=null;i?o={reason:"trait impl method (dynamic dispatch)",disposition:"implicit-usage"}:n&&(o={reason:"inside #[cfg(test)] mod",disposition:"exclude"});for(let c of r){if(be(c)){o={reason:"#[allow(dead_code)]",disposition:"exclude"};break}let u=Ze(c);if(u){o=u;break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o.reason,disposition:o.disposition})}function je(e,t,n){let i=k(e),r=e.namedChildren.find(o=>o.type==="type_identifier")?.text;i.some($e)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(...)] - generated impl may access fields",disposition:"implicit-usage",containerName:r}),i.some(be)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",disposition:"exclude",containerName:r}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",disposition:"exclude",containerName:r})}function k(e){let t=e.parent;if(!t)return[];let n=t.children,i=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){i=o;break}if(i<=0)return[];let r=[];for(let o=i-1;o>=0;o-=1){let c=n[o];if(c.type==="attribute_item"||c.type==="inner_attribute_item")r.push(c.text);else{if(c.type==="line_comment"||c.type==="block_comment")continue;break}}return r}var We=new Set(["test","bench","tokio::test","async_std::test"]),ze=new Set(["no_mangle","export_name","link_name","used","macro_export","proc_macro","proc_macro_derive","proc_macro_attribute"]),He=new Set(["allow","warn","deny","forbid","cfg","cfg_attr","doc","inline","cold","must_use","deprecated","repr","derive","automatically_derived","non_exhaustive","path","link","link_section","global_allocator","panic_handler"]);function Ze(e){if(/#\[\s*cfg\s*\(\s*test\s*\)/.test(e))return{reason:"#[cfg(test)]",disposition:"exclude"};let t=qe(e);return t?We.has(t)?{reason:`#[${t}]`,disposition:"exclude"}:ze.has(t)?{reason:`Rust ABI/export attribute #[${t}]`,disposition:"implicit-usage"}:He.has(t)?null:{reason:`Rust attribute macro #[${t}]`,disposition:"implicit-usage"}:null}function $e(e){return/#\[\s*derive\s*\(/.test(e)}function be(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function Je(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Ke(e){let t=Xe(e);if(t.size===0)return[];let n=[];for(let i of e.descendantsOfType("mod_item")){let r=i.childForFieldName("name")?.text;r&&t.has(r)&&n.push({startLine:i.startPosition.row,endLine:i.endPosition.row,reason:'attribute `with = "..."` module - body may be invoked via reflection',disposition:"implicit-usage",containerName:r})}return n}function qe(e){let t=/^#!?\[\s*([A-Za-z_][A-Za-z0-9_]*(?:\s*::\s*[A-Za-z_][A-Za-z0-9_]*)*)/.exec(e);return t?t[1].replace(/\s+/g,""):null}function Ge(e){return e==="#[tauri::command]"||e==="#[command]"||e==="#[wasm_bindgen]"||e==="#[no_mangle]"||e==="#[napi]"||e==="#[pyfunction]"||e==="#[pymethod]"||e==="#[pyo3]"||e==="#[doc(hidden)]"||e.startsWith("trait ")||e.startsWith("#[derive(<reflective>)]")||e.startsWith("#[derive(...)]")||e.startsWith('serde `with = "')||e.startsWith('attribute `with = "')||e.startsWith("Rust attribute macro #[")||e.startsWith("Rust ABI/export attribute #[")?"implicit-usage":"exclude"}function Ve(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var de=/\bwith\s*=\s*"([^"]+)"/g;function Xe(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){de.lastIndex=0;let i;for(;(i=de.exec(n.text))!==null;){let r=i[1],o=r.split("::").pop()??r;o&&t.add(o)}}return t}function ge(e){let t=A(e);return(n,i,r,o)=>t(n,i,r,o)?.disposition==="exclude"}function A(e){let t=new Map,n=i=>{let r=t.get(i);if(r)return r;let o=fe(e,i),c=new Map;for(let u of o){if(!u.containerName)continue;let l=c.get(u.containerName)??[];l.push(u),c.set(u.containerName,l)}return r={ranges:o,containers:c},t.set(i,r),r};return(i,r,o,c)=>{let u=n(i),l=[];for(let s of u.ranges)r>=s.startLine&&r<=s.endLine&&l.push(s);let d=new Set;c&&d.add(c);for(let s of E(o))d.add(s);for(let s of d){let a=u.containers.get(s);a&&l.push(...a)}return Ye(l)}}function Ye(e){if(e.length===0)return null;let n=e.find(i=>i.disposition==="exclude")??e[0];return{disposition:n.disposition,reason:n.reason}}function vt(e,t={}){w(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function he(e,t,n={}){w(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function xe(e,t){if(t.isIgnoredPath(e.relativePath))return y("ignored-file");if(G(e.symbol))return y("module-like-symbol");if(!R(e.symbol))return y("non-value-symbol");if(!e.isFunctionLike&&e.enclosingSymbol&&R(e.enclosingSymbol))return y("nested-non-callable-value");if(!t.includeTests&&!Qe(e.relativePath))return y("test-file");if(!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName))return y("excluded-file-region");let n=J(e.symbol);if(n==="<constructor>")return y("implicit-constructor");if(e.symbol.startsWith("scip-python ")){if(n==="__all__")return y("python-runtime-metadata");if(/^__[^_].*__$/.test(n))return y("python-protocol-member")}return t.isDeclarationOnlyCallable()?y("declaration-only-callable"):t.isFrameworkContractCallable()?y("framework-contract-member"):V(e.symbol)?y("rust-trait-impl-member"):X(e.symbol)?y("rust-test-module"):!t.includeMembers&&!et(e)?y("member"):e.endLine-e.startLine+1<t.minLoc?y("below-min-loc"):{accepted:!0}}function Qe(e){return Q(e)!=="test"}function y(e){return{accepted:!1,rejectionReason:e}}function R(e){return q(e)||e.endsWith("().")||e.endsWith(".")}function et(e){return K(e.symbol)||E(e.symbol).length===0}function _e(){return new Map}function Se(e,t,n){let i=new Map;for(let r of ie(e,n))e.isIgnored(r.relative_path)||t.has(r.relative_path)||v(i,r.symbol_id,r.relative_path,r.ref_count,"scip-mention");return i}function Ee(e,t,n,i={}){let r=new Set;if(i.conservative||n.size===0){for(let o of se(e,t))r.add(o.symbol_id);return r}for(let o of re(e,t))e.isIgnored(o.relative_path)||n.has(o.relative_path)||r.add(o.symbol_id);return r}function F(e,t){let n=e.get(t);if(!n)return!1;for(let i of n.values())if(i.occurrences>0)return!0;return!1}function C(e,t,n){let i=e.get(t);if(!i)return!1;for(let[r,o]of i)if(r!==n&&o.occurrences>0)return!0;return!1}function Re(e){return e?.occurrences??0}function v(e,t,n,i,r="source-fallback"){if(i<=0)return;let o=ve(e,t,n);o.occurrences+=i,o.sources.add(r)}function Ce(e,t,n,i,r){if(i<=0)return;let o=ve(e,t,n);o.occurrences=Math.max(i,o.occurrences),o.sources.add(r)}function ve(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));let r=i.get(n);return r||(r={occurrences:0,sources:new Set},i.set(n,r)),r}var tt=1e3,nt=300;function Qt(e,t={}){let{scope:n,minLoc:i=1,includeTests:r=!1,skipBarrels:o=!1,includeMembers:c=!1,deadCodeOnly:u=!1,scanLimit:l,semantic:d=!0}=t,s=0,a=b("dead.candidates",()=>{let f=ce(it(e,{scope:n,minLoc:i,includeTests:r,includeMembers:c}),l);return s=f.length,f},()=>({definitions:s})),m=0,p=o?b("dead.inactive-barrels",()=>{let f=new Set(ee(e));return m=f.size,f},()=>({paths:m})):new Set,M=0,g=u?_e():b("dead.mention-reference-counts",()=>{let f=Se(e,p,a.map(D=>D.symbolId));return M=f.size,f},()=>({definitions:a.length,symbolsWithReferences:M})),O=0,Le=u?b("dead.mentioned-symbol-ids",()=>{let f=Ee(e,a.map(D=>D.symbolId),p,{conservative:p.size===0});return O=f.size,f},()=>({definitions:a.length,referencedSymbols:O})):new Set,h=u?a.filter(f=>!Le.has(f.symbolId)):a.filter(f=>!C(g,f.symbolId,f.relativePath));u?b("dead.source-fallback.dead-code-only",()=>ut(e,h,g,{inactiveBarrelPaths:p}),()=>({definitions:h.length,testReferencesIncluded:!0})):b("dead.source-fallback.ast",()=>lt(e,h,g,{inactiveBarrelPaths:p}),()=>({definitions:h.length,testReferencesIncluded:!0}));let B=u?h.filter(f=>!F(g,f.symbolId)):h.filter(f=>!C(g,f.symbolId,f.relativePath));b("dead.caller-map-supplement",()=>yt(e,B,g,{inactiveBarrelPaths:p,includeSemantic:!u&&d}),()=>({definitions:B.length,semantic:!u&&d}));let we=u?h.filter(f=>!F(g,f.symbolId)):a;return ct(e,ot(we,g))}function it(e,t){let n=ge(e),i=[];for(let r of Y(e,{scope:t.scope,symbolMatches:R,sqlPrefilter:"function-like"}))xe(r,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:c=>e.isIgnored(c),isExcludedRegion:n,isDeclarationOnlyCallable:()=>st(e,r),isFrameworkContractCallable:()=>le(e,r)}).accepted&&i.push(r);return i}var rt=["method_signature","abstract_method_signature","call_signature","construct_signature"];function st(e,t){if(!t.parentTypeName||!/\.[cm]?[jt]sx?$/.test(t.relativePath))return!1;let n=x(e,t.relativePath);if(n)return n.rootNode.descendantsOfType([...rt]).some(r=>r.startPosition.row<=t.startLine&&r.endPosition.row>=t.endLine);let i=z(e,t.relativePath).slice(t.startLine,t.endLine+1).join(`
|
|
2
|
+
`).trim();return i.endsWith(";")&&!i.includes("=>")&&!i.includes("{")}function ot(e,t){return e.map(n=>at(n,t)).filter(n=>n.cross_file_refs===0).sort((n,i)=>i.loc-n.loc||n.relative_path.localeCompare(i.relative_path)||n.start_line-i.start_line)}function at(e,t){let n=t.get(e.symbolId)??new Map,i=Re(n.get(e.relativePath)),r=0;for(let[o,c]of n)o!==e.relativePath&&(r+=c.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,parent_type_name:e.parentTypeName,same_file_refs:i,cross_file_refs:r}}function ct(e,t){let n=A(e),i=[],r=0,o=0,c=0,u=0,l=0,d=0;for(let s of t){if(e.isIgnored(s.relative_path))continue;if(te(e,s.relative_path)){u++;continue}if(ne(e,s.symbol,s.relative_path)){l++;continue}let a=n(s.relative_path,s.start_line,s.symbol,s.parent_type_name),m=a?.disposition==="implicit-usage"?a.reason:void 0,p=m?"implicit-usage":s.same_file_refs===0?"dead-code":"file-internal";p==="dead-code"?r++:p==="file-internal"?o++:c++,d+=s.loc,i.push({relativePath:s.relative_path,startLine:s.start_line,endLine:s.end_line,loc:s.loc,symbol:s.symbol,shortName:$(s.symbol),sameFileRefs:s.same_file_refs,kind:p,...m?{implicitUsageReason:m}:{}})}return{symbols:i,counts:{total:i.length,deadCode:r,fileInternal:o,implicitUsage:c,loc:d},applicability:{entrySurfaceExcluded:u,externalRootExcluded:l,implicitUsageSignals:c},totalCount:i.length,deadCodeCount:r,fileInternalCount:o,implicitUsageCount:c,totalLoc:d}}function lt(e,t,n,i){if(t.length===0)return;let r=new T(e),o=new Set(t.map(l=>l.symbolId)),c=new Set(t.map(l=>l.leaf).filter(Boolean)),u=new Set(r.sourceFiles());for(let l of S(e))u.add(l);r.scanSourceReferences({paths:u,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:c,skipPath:l=>i.inactiveBarrelPaths.has(l)},l=>{o.has(l.target.symbolId)&&(mt(e,l)||v(n,l.target.symbolId,l.sourceFile,pt(l),"source-fallback"))})}function ut(e,t,n,i){if(t.length===0)return;let r=new T(e),o=dt(t),c=new Set(r.sourceFiles());for(let s of S(e))c.add(s);let u=new Set(o.keys()),l=new Map,d=s=>{let a=l.get(s);return a||(a=oe(e,s),l.set(s,a)),a};r.scanSourceReferences({paths:c,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:u,skipPath:s=>i.inactiveBarrelPaths.has(s),resolveTargets:({sourceFile:s,name:a,kind:m})=>{let p=o.get(a);return p?ft(s,a,p,()=>d(s),{permissive:m!=="cross-language-dispatch"}):[]},afterPath:s=>{l.delete(s),he(e,s)}},s=>{let a=s.kind==="identifier"&&s.sourceFile===s.target.relativePath?Math.max(0,s.occurrences-1):s.occurrences;s.kind==="identifier"&&De(e,{sourceFile:s.sourceFile,name:s.name,target:s.target,occurrences:a})||v(n,s.target.symbolId,s.sourceFile,a,"source-fallback")})}function dt(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let i=t.get(n.leaf)??[];i.push(n),t.set(n.leaf,i)}return t}function ft(e,t,n,i,r){let o=n.filter(d=>d.relativePath===e);if(o.length>0)return o;if(!r.permissive&&n.length===1)return[...n];let c=i(),u=c.get(t);if(u)for(let d of u){let s=n.filter(a=>L(d,a.relativePath));if(s.length>0)return s}let l=new Set;for(let d of c.values())for(let s of d)l.add(s);for(let d of l){let s=n.filter(a=>L(d,a.relativePath));if(s.length>0&&s.length===n.length)return s}return r.permissive?[...n]:[]}function mt(e,t){return t.kind==="cross-language-dispatch"&&t.target.relativePath===t.sourceFile?!0:t.kind==="identifier"&&De(e,t)}function pt(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function De(e,t){return t.occurrences>1?!1:Z(e,t.sourceFile).some(n=>n.used||n.sourcePath!==t.target.relativePath?!1:n.importedName===t.name||n.localName===t.name)}function yt(e,t,n,i){let r=i.includeSemantic!==!1,o=r&&t.length>=tt&&S(e).length>=nt,c=(s,a)=>{a===s.relativePath||e.isIgnored(a)||i.inactiveBarrelPaths.has(a)||Ce(n,s.symbolId,a,1,"caller-map")};if(o?b("dead.caller-map.per-symbol-non-semantic",()=>{for(let s of t){let a=P(e,s,{semantic:!1,semanticEvidence:N});for(let m of a)c(s,m.file)}},()=>({definitions:t.length,semantic:!1})):b("dead.caller-map.per-symbol",()=>{for(let s of t){let a=P(e,s,{semantic:r,semanticEvidence:N});if(a.length!==0)for(let m of a)c(s,m.file)}},()=>({definitions:t.length,semantic:r})),!o)return;let u=0,l=b("dead.caller-map.semantic-candidates",()=>{let s=t.filter(a=>!C(n,a.symbolId,a.relativePath));return u=s.length,s},()=>({definitions:t.length,semanticCandidates:u}));if(l.length===0)return;let d=ae(e,l);for(let s of l){let a=d.get(s.symbolId);if(a)for(let m of a)c(s,m)}}export{vt as a,Qt as b};
|
|
3
|
+
//# sourceMappingURL=chunk-E5HNT4X2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as c}from"./chunk-DQGSM7RZ.js";function j(e,s={}){let{minSimilarity:t=.5,limit:n=15,scope:i,minChainLength:r=3,maxChainLength:l=8}=s,a=c(e,i),o=y(a,r,l);if(o.length===0)return[];let f=d(o);return f.length<2?[]:S(x(f,t,n),n)}function d(e){let s=m(e),t=[];for(let n of e){let i=n.filter(r=>!s.has(r));i.length>=2&&t.push({original:n,filtered:i})}return t}function m(e){let{nodeFreq:s,tailFreq:t}=p(e),n=e.length*.9,i=e.length*.8,r=new Set;for(let[a,o]of s)o>n&&r.add(a);for(let[a,o]of t)o>i&&r.add(a);let l=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let a of s.keys()){let o=a.split("/").pop()??"";l.includes(o)&&r.add(a)}return r}function p(e){let s=new Map,t=new Map;for(let n of e){let i=new Set;for(let r of n)i.has(r)||(s.set(r,(s.get(r)??0)+1),i.add(r));for(let r=Math.max(0,n.length-2);r<n.length;r++)t.set(n[r],(t.get(n[r])??0)+1)}return{nodeFreq:s,tailFreq:t}}function x(e,s,t){let n=[];for(let i=0;i<e.length;i++){for(let r=i+1;r<e.length;r++){let l=b(e[i],e[r],s);l&&n.push(l)}if(n.length>t*10)break}return n.sort((i,r)=>Math.abs(r.similarity-i.similarity)>.01?r.similarity-i.similarity:i.divergencePoints.length-r.divergencePoints.length),n}function b(e,s,t){if(!C(e.filtered,s.filtered))return null;let{distance:n,ops:i}=A(e.filtered,s.filtered),r=Math.max(e.filtered.length,s.filtered.length);if(r===0)return null;let l=1-n/r;if(l<t||n===0)return null;let a=i.filter(f=>f.type==="substitute").map(f=>({index:f.indexA,nodeA:e.filtered[f.indexA],nodeB:s.filtered[f.indexB]}));return a.length===0||i.filter(f=>f.type==="match").length<2?null:{chainA:e.original,chainB:s.original,similarity:l,editDistance:n,divergencePoints:a,commonPrefix:F(e.original,s.original),commonSuffix:B(e.original,s.original)}}function C(e,s){let t=new Set(e);return s.some(n=>t.has(n))}function S(e,s){let t=[];for(let n of e)if(t.some(r=>h(n.chainA,r.chainA)&&h(n.chainB,r.chainB))||t.push(n),t.length>=s)break;return t}function y(e,s,t){let n=[];for(let r of e.keys()){if(n.length>=500)break;g(e,r,[r],new Set([r]),s,t,n,500)}return n}function g(e,s,t,n,i,r,l,a){if(l.length>=a)return;if(t.length>=r){t.length>=i&&l.push([...t]);return}let o=e.get(s);if(!o||o.size===0){t.length>=i&&l.push([...t]);return}let f=!1;for(let u of o)if(!n.has(u)&&(n.add(u),t.push(u),g(e,u,t,n,i,r,l,a),t.pop(),n.delete(u),f=!0,l.length>=a))return;!f&&t.length>=i&&l.push([...t])}function A(e,s){let t=e.length,n=s.length,i=Array.from({length:t+1},()=>Array(n+1).fill(0));for(let o=0;o<=t;o++)i[o][0]=o;for(let o=0;o<=n;o++)i[0][o]=o;for(let o=1;o<=t;o++)for(let f=1;f<=n;f++)e[o-1]===s[f-1]?i[o][f]=i[o-1][f-1]:i[o][f]=1+Math.min(i[o-1][f],i[o][f-1],i[o-1][f-1]);let r=[],l=t,a=n;for(;l>0||a>0;)l>0&&a>0&&e[l-1]===s[a-1]?(r.unshift({type:"match",indexA:l-1,indexB:a-1}),l--,a--):l>0&&a>0&&i[l][a]===i[l-1][a-1]+1?(r.unshift({type:"substitute",indexA:l-1,indexB:a-1}),l--,a--):a>0&&i[l][a]===i[l][a-1]+1?(r.unshift({type:"insert",indexA:l,indexB:a-1}),a--):(r.unshift({type:"delete",indexA:l-1,indexB:a}),l--);return{distance:i[t][n],ops:r}}function F(e,s){let t=[];for(let n=0;n<Math.min(e.length,s.length)&&e[n]===s[n];n++)t.push(e[n]);return t}function B(e,s){let t=[],n=e.length-1,i=s.length-1;for(;n>=0&&i>=0&&e[n]===s[i];)t.unshift(e[n]),n--,i--;return t}function h(e,s){if(e.length>s.length)return!1;let t=s.join("\u2192"),n=e.join("\u2192");return t.includes(n)}export{j as a};
|
|
2
|
+
//# sourceMappingURL=chunk-ELLMY7XJ.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as Fe,c as Te,e as C,f as Ae,h as Be,k as Z,l as ee,m as F}from"./chunk-LSOR3LQG.js";import{a as L}from"./chunk-DQGSM7RZ.js";import{A as Y,D as Re,F as we,H as Pe,I as ve,a as ge,b as be,e as N,g as Se,l as Me,o as X}from"./chunk-JORHF5AL.js";import{a as Ie}from"./chunk-64MNV6AB.js";import{h as he,i as p,o as xe,r as h}from"./chunk-VVY2G5ET.js";import{execFileSync as De}from"child_process";import{createHash as nt}from"crypto";import{existsSync as q,statSync as rt}from"fs";import{createRequire as it}from"module";import{platform as ot}from"os";import{dirname as Ee,join as T}from"path";var at=it(import.meta.url),Nn={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function te(t){return[t.indexerBinary,...t.binaryAliases??[]]}function st(t){let e=te(t);return e.length===1?e[0]:e.join(" or ")}function ne(t){for(let e of te(t)){let n=Te(e);if(n)return n}return dt(t)}function Ln(t){return ne(t)!==null||ct(t)}function ct(t){return je(t)!==null}function dt(t){let e=je(t);if(!e)return null;let r=JSON.parse(h(e,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return T(Ee(e),r);for(let i of te(t)){let o=r[i];if(o)return T(Ee(e),o)}return null}function je(t){if(!t.bundledNpmPackage)return null;try{return at.resolve(`${t.bundledNpmPackage}/package.json`)}catch{return null}}function lt(t,e){for(let n of t.projectLocalBinaries??[]){let r=T(e,n);if(q(r))return r}return null}function ut(t,e){for(let n of t.projectLocalBinaries??[]){let r=T(e,n);if(q(r))return ke(e,n,r)}return null}function Cn(t,e){let n=pt(t,e);if(!n||n.canonicalPath!==e.canonicalPath||n.sha256!==e.sha256||n.size!==e.size||n.mtimeMs!==e.mtimeMs||n.device!==e.device||n.inode!==e.inode||n.executable!==e.executable)throw new Error(`refusing changed project-local indexer ${e.relativePath}; review the current file and rerun with --trust-project-tools`)}function pt(t,e){try{return ke(t,e.relativePath,e.configuredPath)}catch{return null}}function ke(t,e,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Pe(t,e,r),o=ve(t,e,r),a=rt(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:e,sha256:nt("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(a.mode&73)!==0}}function ft(t,e,n={}){return(n.trustProjectTools?ut(t,e)?.canonicalPath:null)??ne(t)}function qn(t,e=process.env,n=t.indexerBinary){if(t.indexerBinary!=="scip-dotnet"||re(n,e))return e;let r=Ne(n,e);return r?{...e,DOTNET_ROOT:r}:e}function On(t,e,n={}){let r=st(t),i=e?ft(t,e,n):ne(t);if(!i)return{language:t.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:t.installUrl,...e&<(t,e)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(t.indexerBinary!=="scip-dotnet")return{language:t.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=mt(i);return{language:t.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:t.installUrl,note:o.note}}function mt(t){if(re(t,process.env))return{runnable:!0};let e=Ne(t,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let n=Le(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function Ne(t,e){for(let n of Le(e))if(re(t,{...e,DOTNET_ROOT:n}))return n;return null}function Le(t){let e=[],n=t.DOTNET_ROOT;if(n&&q(n)&&e.push(n),ot()==="darwin"&&Fe("brew"))try{let r=De("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=T(r,"libexec");q(i)&&!e.includes(i)&&e.push(i)}catch{}return e}function re(t,e){try{return De(t,["--version"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function Gn(t,e,n={}){Z(t,Ce(e,n),{durability:"visibility",runtime:n.runtime})}function Wn(t,e,n={}){return Z(t,Ce(e,n),{durability:"durable",runtime:n.runtime})}function Ce(t,e){let n=JSON.stringify(t,null,e.spacing);return e.trailingNewline?`${n}
|
|
2
|
+
`:n}var yt=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function O(t){let e=t.toLowerCase();return yt.some(n=>e.endsWith(n))}function $(t){let e=_(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(c=>[c.path,c])),i=t.snapshot.files.filter(c=>{let y=ge(c.path,["typescript"]);return y==="config"||y==="ambient"}).map(c=>c.path),o=_([...e,...i]),a=o.find(c=>!r.has(c)),s=new Set(t.snapshot.files.map(c=>c.path)).size!==t.snapshot.files.length,d=!a&&o.some(c=>qe(r.get(c))),u=X(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:_(t.snapshot.typescriptProjects),membership:e})),l=new Map;return{identityFor(c,y){if(!n.has(c))return R("target-outside-project");if(s)return R("duplicate-input-path");if(a)return R("missing-input-fingerprint");if(d)return R("unreadable-input");let S=[],f,x;if(t.graph===null)S.push("dependency-graph-unavailable"),x="whole-project",f=o;else{let k=bt(c,t.graph,l);if(k.find(Q=>!r.has(Q)))return R("missing-input-fingerprint");if(f=_([...k,...i]),f.some(Q=>qe(r.get(Q))))return R("unreadable-input");x="dependency-closure"}let j=f.map(k=>ht(r.get(k)));return{version:1,key:X(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:y,projectIdentity:u,inputs:j})),mode:x,inputFiles:f,reasons:S}}}}function gt(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let a of[...e.get(o)??[]].sort())n.has(a)||r.push(a)}}return[...n].sort()}function bt(t,e,n){let r=n.get(t);if(r)return r;let i=gt(t,e);return n.set(t,i),i}function ht(t){return{path:t.path,size:t.size,hash:t.hash}}function qe(t){return t.size<0||t.hash==="unreadable"}function R(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function _(t){return[...new Set(t)].sort()}import{createRequire as St}from"module";var Oe=St(import.meta.url),A,G;function xt(){if(A!==void 0)return A;try{A=Oe("ts-morph")}catch{A=null}return A}function W(){if(G)return G;let t=xt();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=Oe("ts-morph/package.json").version??"unknown"}catch{}return G=`ts-morph:${e}:typescript:${t.ts.version}`,G}function Qn(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function Xn(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var Mt=Me("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function ie(t,e,n){let r=Mt.get(t,()=>It(t));if(!r)return null;let i=`${n}\0${e}`,o=r.identities.get(i);if(o)return o;let a=r.builder.identityFor(e,n);return r.identities.set(i,a),a}function B(t){return Ie(t,{includeIgnored:!1}).filter(O).sort()}function It(t){try{if(!t.generation.metadataRaw)return null;let e=N(t.generation.metadataRaw);if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache)return null;let n=be(e.metadata.fingerprint);return n?{builder:$({projectFiles:B(t),snapshot:n,graph:L(t),engineIdentity:W()}),identities:new Map}:null}catch{return null}}function J(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let o of i){let a=n.get(o.targetSymbol);a&&r.get(a.symbolId).push(o.location)}for(let[i,o]of r)r.set(i,Rt(o));return r}function Ge(t,e,n){let r=$e(t,e),i=$e(t,n),o=[...r].filter(c=>!i.has(c)).sort(),a=[...i].filter(c=>!r.has(c)).sort(),s=_e(t,e),d=_e(t,n),u=[...s].filter(c=>!d.has(c)).sort(),l=[...d].filter(c=>!s.has(c)).sort();return{passed:o.length===0&&a.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:a,callerFiles:{passed:u.length===0&&l.length===0,expectedCount:s.size,actualCount:d.size,missing:u,extra:l}}}function _e(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function cr(t,e,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of t)for(let a of e.get(o.symbolId)??[])r.has(a.file)&&i.get(a.file).push({targetSymbol:o.symbol,location:a});for(let[o,a]of i)i.set(o,wt(a));return i}function $e(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function Rt(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(We)}function wt(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||We(n.location,r.location))}function We(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var oe="typescript-reference-fragment-v2",H=Re({kind:"typescript-reference-fragments",invalidation:we("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:vt});function hr(t,e,n,r=t){let i=B(t),o=$({projectFiles:i,snapshot:e,graph:L(t),engineIdentity:W()}),a=[...n].map(([s,d])=>({relativePath:s,contentHash:o.identityFor(s,oe).key,value:[...d]}));if(a.some(s=>s.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return H.writeBatch(r,a.map(s=>({...s,contentHash:s.contentHash}))),a.length}function Sr(t,e,n,r){let i=e.filter(a=>O(a.relativePath));if(i.length===0)return z("no TypeScript definitions");let o=z("shadow did not run");return Y("typescript.reference-fragments.shadow",()=>{try{let a=r(i[0].relativePath);if(!a.availability().available||!a.referenceFragmentsForFiles)return o=z("TypeScript reference fragment provider is unavailable"),o;let s=B(t),d=new Set(s),u=a.referenceFragmentsForFiles(s),l=J(i,u),c=Ge(i,Pt(n,d),l);if(!c.passed)return o={state:"failing",files:s.length,keyedFiles:0,writtenFiles:0,...c},o;let y=[];for(let S of s){let f=ie(t,S,oe);f?.key&&y.push({relativePath:S,contentHash:f.key,value:u.get(S)??[]})}return H.writeBatch(t,y),o={state:"passing",files:s.length,keyedFiles:y.length,writtenFiles:y.length,...c},o}catch(a){return o=z(a instanceof Error?a.message:String(a)),o}},()=>({...o}))}function Pt(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function xr(t,e,n){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,a=0,s=0;return Y("typescript.reference-fragments.materialize",()=>{try{let d=B(t);i=d.length;let u=new Map,l=new Map,c=[];for(let f of d){let x=ie(t,f,oe);if(!x?.key)return null;u.set(f,x.key);let j=H.read(t,f,x.key);j===null?(a+=1,c.push(f)):(o+=1,l.set(f,j))}if(a===0)return r="hit",{references:J(e,l),files:i,cacheHits:o,cacheMisses:a,computedFiles:s};let y=n(e[0].relativePath);if(!y.availability().available||!y.referenceFragmentsForFiles)return null;let S=y.referenceFragmentsForFiles(c);if(c.some(f=>!S.has(f)))return null;s=S.size,H.writeBatch(t,c.map(f=>({relativePath:f,contentHash:u.get(f),value:S.get(f)??[]})));for(let[f,x]of S)l.set(f,x);return r="computed",{references:J(e,l),files:i,cacheHits:o,cacheMisses:a,computedFiles:s}}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:a,computedFiles:s}))}function z(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function vt(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(Ft)?null:e}catch{return null}}function Ft(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as Tt}from"crypto";import{existsSync as V,statSync as de}from"fs";import{basename as At,dirname as le,join as I}from"path";var Bt=1,Et=1,Dt=".scipquery-generations",jt="manifest.json";function ue(t){return I(le(t),Dt)}function kt(t){try{let e=JSON.parse(h(I(ue(t),"state.json"),"SQLite generation state"));return Gt(e)?e:null}catch{return null}}function Nt(t,e){return Lt(ue(t),e)}function Lt(t,e){try{let n=JSON.parse(h(I(t,e,jt),"SQLite generation manifest"));return $t(n,e)?n:null}catch{return null}}function Fr(t){let e=kt(t.dbPath);if(e){let n=qt(t,e.currentGeneration);if(n)return n;if(e.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${e.currentGeneration} is missing or invalid.`)}if(V(I(le(t.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return Ot(t,e?.currentGeneration)}function Ct(t){return Se(N(t))??t}function qt(t,e){try{let n=I(ue(t.dbPath),e),r=Nt(t.dbPath,e);if(!r)return null;let i=ae(n,r.database),o=r.index?ae(n,r.index):void 0,a=r.metadata?ae(n,r.metadata):void 0;return!se(i,r.database)||r.index&&(!o||!se(o,r.index))||r.metadata&&(!a||!se(a,r.metadata))?null:{identity:e,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:h(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function Ot(t,e){let n=Je(t.dbPath),r=I(le(t.dbPath),"meta.json"),i=V(r)?h(r,"reindex metadata"):void 0,o=V(t.indexPath)?t.indexPath:void 0;return{identity:e??_t(t.dbPath,i),databasePath:t.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function _t(t,e){let n=Tt("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&n.update(Ct(e)),n.update(`\0${Je(t)}`),n.digest("hex")}function Je(t){let e=de(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function ae(t,e){if(At(e.file)!==e.file||e.file==="."||e.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return I(t,e.file)}function se(t,e){return V(t)&&de(t).isFile()&&de(t).size===e.size}function $t(t,e){return t.version===Et&&t.identity===e&&ce(t.database)&&(t.index===void 0||ce(t.index))&&(t.metadata===void 0||ce(t.metadata))}function ce(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.file=="string"&&!!e.file&&Number.isSafeInteger(e.size)&&(e.size??-1)>=0&&typeof e.sha256=="string"&&/^[a-f0-9]{64}$/.test(e.sha256)}function Gt(t){return t.version===Bt&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&Wt(t.stableMirrors)&&Jt(t.previousGeneration)&&zt(t.publication)}function Wt(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.databaseFileIdentity=="string"&&!!e.databaseFileIdentity&&(e.indexFileIdentity===void 0||typeof e.indexFileIdentity=="string"&&!!e.indexFileIdentity)}function Jt(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.generationIdentity=="string"&&!!e.generationIdentity&&typeof e.databasePath=="string"&&!!e.databasePath&&(e.metadataPath===void 0||typeof e.metadataPath=="string"&&!!e.metadataPath)}function zt(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,n=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(r=>r!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}import{createHash as Ht,randomUUID as Ke}from"crypto";import{existsSync as v,lstatSync as D,mkdirSync as Vt,readdirSync as P,renameSync as Qe,rmSync as M}from"fs";import{basename as pe,dirname as Ut,join as m}from"path";function U(t){return Array.isArray(t)?`[${t.map(U).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${U(n)}`).join(",")}}`:JSON.stringify(t)}var Kt=1,Qt=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),w=class extends Error{constructor(n,r,i,o){let a=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${a}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Xt=".owner.json",Yt={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Or(t){return{rootDir:t,pendingDir:m(t,"pending"),inflightDir:m(t,"inflight"),responseDir:m(t,"responses"),deadLetterDir:m(t,"dead-letter"),legacyRequestDir:m(t,"requests")}}function Zt(t={}){let e={...Qt,...t};for(let[n,r]of Object.entries(e))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return e}function Xe(t){for(let e of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir])Vt(e,{recursive:!0})}function _r(t,e){return Ht("sha256").update(U({namespace:t,payload:e})).digest("hex")}function en(t){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${t}`}function $r(t,e,n={}){let r=Zt(n.limits),i=n.nowMs??Date.now();return Xe(t),dn(e),nn(t,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??Be,()=>{tn(t,i,r);let o=m(t.pendingDir,`${e.id}.json`),a=m(t.responseDir,`${e.id}.json`),s=ze(t,e.id);if(s){let c=He(s,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:c.deadlineAtMs??e.deadlineAtMs}}let d=`${JSON.stringify(e)}
|
|
3
|
+
`,u=Buffer.byteLength(d),l=Ye(t);if(u>r.maxItemBytes)throw new w("item-too-large",l,r,u);if(l.totalItems+1>r.maxItems)throw new w("item-capacity",l,r,u);if(l.totalBytes+u>r.maxBytes)throw new w("byte-capacity",l,r,u);n.onBeforePublish?.();try{return ee(o,d,{durability:"durable"}),{disposition:"accepted",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:e.deadlineAtMs}}catch(c){if(c.code!=="EEXIST")throw c;let y=ze(t,e.id);if(!y)throw c;let S=He(y,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:S.deadlineAtMs??e.deadlineAtMs}}})}function tn(t,e,n,r=Yt){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let a of me(t.inflightDir)){if(o<=0)break;let s=m(t.responseDir,`${a.requestId}.json`);if(v(s)){M(a.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(a.claimExpiresAtMs>e||sn(t,a.ownerId,r)!=="dead")continue;let d=m(t.pendingDir,a.originalFile);try{Qe(a.path,d),i.reclaimed++}catch(u){if(u.code!=="EEXIST")throw u;M(a.path,{force:!0})}F(Ut(a.path)),F(t.pendingDir),o--}o=Ve(t.responseDir,o,(a,s)=>s+n.responseRetentionMs,e,()=>{i.responsesRemoved++}),o=Ve(t.deadLetterDir,o,(a,s)=>s+n.deadLetterRetentionMs,e,()=>{i.deadLettersRemoved++});for(let a of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir]){if(o<=0)break;for(let s of Ze(a)){if(o<=0)break;pe(s).includes(".tmp-")&&(D(s).mtimeMs+n.temporaryRetentionMs>e||(M(s,{force:!0}),i.temporaryFilesRemoved++,o--))}}return ln(t.inflightDir),i}function Ye(t){Xe(t);let e=[...E(t.pendingDir).map(d=>({path:d,pending:!0})),...E(t.legacyRequestDir).map(d=>({path:d,pending:!0}))],n=me(t.inflightDir).map(d=>({path:d.path,pending:!1})),r=E(t.responseDir).map(d=>({path:d,pending:!1})),i=E(t.deadLetterDir).map(d=>({path:d,pending:!1})),o=[...e,...n,...r,...i],a=0,s;for(let d of e){let u=ye(d.path);if(!u){a++;continue}let l=u.enqueuedAtMs??D(d.path).mtimeMs;s=s===void 0?l:Math.min(s,l)}return{pending:e.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:a,totalItems:o.length,totalBytes:o.reduce((d,u)=>d+un(u.path),0),...s===void 0?{}:{oldestPendingAt:new Date(s).toISOString()}}}function nn(t,e,n,r,i){let o=m(t.rootDir,".admission.lock"),a=`${process.pid}-${Ke()}`,s=r()+Math.max(0,n);for(;!rn(t.rootDir,o,a);){if(on(o),r()>=s)throw new w("admission-busy",Ye(t),e,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return i()}finally{try{fe(o).ownerToken===a&&(M(o,{recursive:!0,force:!0}),F(t.rootDir))}catch{}}}function rn(t,e,n){let r=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
|
|
4
|
+
`;try{return ee(e,r,{durability:"durable"}),!0}catch(i){if(i.code==="EEXIST")return!1;try{fe(e).ownerToken===n&&(M(e,{force:!0}),F(t))}catch{}throw i}}function on(t){let e=null;try{let r=fe(t);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(e=Number(r.pid))}catch{}if(e===null||an(e))return;let n=`${t}.stale-${Ke()}`;try{Qe(t,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}M(n,{recursive:!0,force:!0})}function fe(t){try{return JSON.parse(h(t,"mailbox lock record"))}catch(e){if(e.code!=="EISDIR"&&!(e instanceof xe&&e.reason==="not-regular"))throw e;return JSON.parse(h(m(t,"owner.json"),"mailbox lock owner record"))}}function an(t){try{return process.kill(t,0),!0}catch(e){let n=e.code;return n==="EPERM"||n!=="ESRCH"}}function sn(t,e,n){let r=cn(m(t.inflightDir,et(e),Xt));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?Ae(r.processIdentity,i)?"live":"dead":"unknown"}function cn(t){try{let e=JSON.parse(h(t,"mailbox owner record"));if(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)return null;let n=e.processIdentity===void 0?null:C(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,ownerId:e.ownerId,pid:e.pid,...n?{processIdentity:n}:{}}}catch{return null}}function ze(t,e){for(let n of[m(t.pendingDir,`${e}.json`),m(t.legacyRequestDir,`${e}.json`),m(t.responseDir,`${e}.json`)])if(v(n))return n;for(let n of me(t.inflightDir))if(n.requestId===e)return n.path;return null}function He(t,e,n){let r=ye(t);if(!r||r.operationKey!==e)throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`);return r}function dn(t){if(t.mailboxVersion!==Kt||t.id!==en(t.operationKey)||!t.clientId.trim()||!Number.isFinite(t.enqueuedAtMs)||!Number.isFinite(t.deadlineAtMs)||t.deadlineAtMs<t.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function me(t){if(!v(t))return[];let e=[];for(let n of P(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Ue(n.name);if(r===null)continue;let i=m(t,n.name);for(let o of P(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let a=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!a)continue;let s=Ue(a[1]),d=Number(a[2]);if(s===null||pe(s)!==s||!s.endsWith(".json")||!Number.isSafeInteger(d))continue;let u=m(i,o.name),l=ye(u)??{id:pe(s,".json")},c=D(u);e.push({requestId:l.id,ownerId:r,path:u,originalFile:s,claimedAtMs:c.mtimeMs,claimExpiresAtMs:d,byteLength:c.size,...l.operationKey?{operationKey:l.operationKey}:{},...l.clientId?{clientId:l.clientId}:{},...l.enqueuedAtMs===void 0?{}:{enqueuedAtMs:l.enqueuedAtMs},...l.deadlineAtMs===void 0?{}:{deadlineAtMs:l.deadlineAtMs},legacy:l.operationKey===void 0})}}return e.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function ye(t){try{let e=JSON.parse(h(t,"mailbox record"));return typeof e.id!="string"||!e.id?null:{id:e.id,...typeof e.operationKey=="string"?{operationKey:e.operationKey}:{},...typeof e.clientId=="string"?{clientId:e.clientId}:{},...typeof e.enqueuedAtMs=="number"?{enqueuedAtMs:e.enqueuedAtMs}:{},...typeof e.deadlineAtMs=="number"?{deadlineAtMs:e.deadlineAtMs}:{}}}catch{return null}}function Ve(t,e,n,r,i){for(let o of E(t)){if(e<=0)break;let a=D(o);n(o,a.mtimeMs)>r||(M(o,{force:!0}),i(),e--)}return e}function E(t){return v(t)?P(t,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>m(t,e.name)).sort():[]}function Ze(t){if(!v(t))return[];let e=[];for(let n of P(t,{withFileTypes:!0})){let r=m(t,n.name);n.isFile()?e.push(r):n.isDirectory()&&e.push(...Ze(r))}return e.sort()}function ln(t){if(v(t))for(let e of P(t,{withFileTypes:!0})){if(!e.isDirectory())continue;let n=m(t,e.name);P(n).some(r=>r.endsWith(".claim"))||M(n,{recursive:!0,force:!0})}}function un(t){try{return D(t).size}catch{return 0}}function et(t){return Buffer.from(t,"utf8").toString("base64url")}function Ue(t){try{let e=Buffer.from(t,"base64url").toString("utf8");return et(e)===t?e:null}catch{return null}}import{join as K}from"path";var pn="watch.lock",fn="watch-state.json",mn="watch-activity.json",yn="watch-refresh-requests";function Vr(t){return{lockPath:K(t,pn),statePath:K(t,fn),activityPath:K(t,mn),refreshRequestsPath:K(t,yn)}}function Ur(t){try{return gn(JSON.parse(h(t,"watch service state")))}catch{return null}}function gn(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!b(e.startedAt)||!b(e.heartbeatAt)||!b(e.lastActivityAt)||!bn(e.watcher)||e.idleDeadlineAt!==void 0&&!b(e.idleDeadlineAt))return null;if(e.processIdentity!==void 0){let n=C(e.processIdentity);if(!n||n.pid!==e.pid)return null;e.processIdentity=n}return e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!hn(e.lastError)||e.lastRefresh!==void 0&&!Sn(e.lastRefresh)||e.reindexActivity!==void 0&&!xn(e.reindexActivity)||e.refreshRequests!==void 0&&!Mn(e.refreshRequests)||e.typescriptSemantic!==void 0&&!In(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!Rn(e.typescriptIndex)?null:e}function b(t){return he(t)}function bn(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return g(e.changedFiles)&&g(e.reindexAt);case"indexing":return g(e.startedAt);case"cooldown":return g(e.until)&&typeof e.dirty=="boolean";case"draining":return g(e.startedAt)&&typeof e.reason=="string";default:return!1}}function hn(t){if(!t||typeof t!="object")return!1;let e=t;return b(e.at)&&typeof e.message=="string"}function Sn(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&b(e.startedAt)&&b(e.completedAt)&&g(e.durationMs)}function xn(t){if(!t||typeof t!="object")return!1;let e=t;return!b(e.windowStartedAt)||!b(e.windowEndedAt)||!p(e.runs)||!p(e.rebuilt)||!p(e.reused)||!p(e.failed)||!p(e.suppressed)||!g(e.estimatedLogicalOutputBytes)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"?!1:Object.values(e.byTrigger).every(n=>n===void 0||p(n))}function Mn(t){if(!t||typeof t!="object")return!1;let e=t;return p(e.pending)&&p(e.claimed)&&p(e.completed)&&p(e.expired)&&p(e.invalid)&&(e.oldestPendingAt===void 0||b(e.oldestPendingAt))}function In(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&g(e.requests)&&g(e.sessionsCreated)&&g(e.sessionsReused)&&g(e.sessionsRefreshed)&&g(e.sessionsReplaced)&&g(e.projectsCreated)&&(e.lastRequestAt===void 0||b(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||b(e.busyUntil))&&(e.mailbox===void 0||tt(e.mailbox))}function Rn(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&p(e.requests)&&p(e.sessionsCreated)&&p(e.sessionsReplaced)&&p(e.initializations)&&p(e.programUpdates)&&p(e.documentsEmitted)&&p(e.documentsRemoved)&&(e.lastRequestAt===void 0||b(e.lastRequestAt))&&(e.lastDurationMs===void 0||g(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||b(e.busyUntil))&&(e.mailbox===void 0||tt(e.mailbox))}function tt(t){if(!t||typeof t!="object")return!1;let e=t;return p(e.pending)&&p(e.inflight)&&p(e.responses)&&p(e.deadLetters)&&p(e.invalid)&&p(e.totalItems)&&g(e.totalBytes)&&e.totalBytes>=0&&e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters&&(e.oldestPendingAt===void 0||b(e.oldestPendingAt))}function g(t){return typeof t=="number"&&Number.isFinite(t)}export{Bt as a,Et as b,Dt as c,jt as d,ue as e,kt as f,Nt as g,Lt as h,Fr as i,Ct as j,Je as k,Nn as l,st as m,ne as n,Ln as o,lt as p,ut as q,Cn as r,qn as s,On as t,U as u,Gn as v,Wn as w,Kt as x,Or as y,_r as z,en as A,$r as B,Vr as C,Ur as D,yt as E,O as F,xt as G,Qn as H,Xn as I,cr as J,$ as K,ie as L,hr as M,Sr as N,xr as O};
|
|
5
|
+
//# sourceMappingURL=chunk-FD3HFKXR.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as f}from"./chunk-2SNGN6U4.js";import{a as L}from"./chunk-SMQWE25B.js";import{d as i,e as b,f as u,l as c}from"./chunk-RA3AYNWP.js";import{f as l}from"./chunk-MZZBAITE.js";import{x as a}from"./chunk-WUW7YUAH.js";function S(o,s){let t=L(o,s);if(!t)return[];let e=new f(o).definitionsForFile(t.relativePath).filter(r=>r.symbol!==t.symbol).filter(r=>c(t.symbol,r.symbol)).sort((r,m)=>r.startLine-m.startLine||r.endLine-m.endLine).map(r=>({symbol:r.symbol,shortName:i(r.symbol),startLine:r.startLine,endLine:r.endLine,kind:u(r.symbol)??"unknown"}));return a(t.relativePath)!=="clojure"?e:d(e,y(o,t))}function y(o,s){let t=b(s.symbol);if(!t)return[];let n=i(s.symbol);return(l(o,s.relativePath)?.clojureMembers??[]).filter(e=>e.ownerName===t).map(e=>({symbol:`${s.symbol}${e.memberName}().`,shortName:`${n}:${e.memberName}()`,startLine:e.startLine,endLine:e.endLine,kind:e.memberKind}))}function d(o,s){let t=new Map;for(let n of[...o,...s])t.set(`${n.shortName}:${n.startLine}:${n.endLine}`,n);return[...t.values()].sort((n,e)=>n.startLine-e.startLine||n.endLine-e.endLine)}export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FIJCV235.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as x}from"./chunk-ACAM6O5R.js";import{c as k}from"./chunk-2SNGN6U4.js";import{b as L}from"./chunk-LP3ARJKF.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as n}from"./chunk-BGBBVSH4.js";import{l as v}from"./chunk-E2LAW7SL.js";import{d as S}from"./chunk-RA3AYNWP.js";import{A as a}from"./chunk-JORHF5AL.js";function E(c,f={}){let{scope:P,minLoc:F=3,scanLimit:d}=f,l=new k(c),b=f.semantic!==!1,y=0,m=a("isolated.candidates",()=>{let s=g(l.productionCallableDefinitions({scope:P,minLoc:F,excludeEntrySurfaces:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0,includeSuppressed:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:typeof d=="number"&&d>0}),d).filter(R=>!x(c,R));return y=s.length,s},()=>({definitions:y})),p=0,i=a("isolated.strict-callees",()=>{let e=l.symbolsWithNonSelfCallees(m,{additive:!1,semantic:!1});return p=e.size,e},()=>({definitions:m.length,symbols:p})),r=m.filter(e=>!i.has(e.symbolId)),C=0,N=a("isolated.scip-callers",()=>{let e=l.crossFileCallerMap(r,{semantic:!1});return C=e.size,e},()=>({definitions:r.length,symbols:C})),o=new Set(N.keys());for(let e of l.frameworkReferencedSymbolIds(r))o.add(e);let t=r.filter(e=>!o.has(e.symbolId));if(b&&t.length>0){for(let e of v(c,t).keys())o.add(e);for(let e of l.symbolsWithNonSelfCallees(t,{additive:!1,semantic:!0}))i.add(e);t=t.filter(e=>!o.has(e.symbolId)).filter(e=>!i.has(e.symbolId))}let h=0,W=a("isolated.source-fallback-callers",()=>{let e=l.sourceFallbackCallerFiles(t,{skipPath:s=>L(s)==="test"});return h=e.size,e},()=>({definitions:t.length,symbols:h}));for(let e of W.keys())o.add(e);let u=t.filter(e=>!o.has(e.symbolId)),I=0,M=a("isolated.additive-callees",()=>{let e=l.symbolsWithNonSelfCallees(u,{additive:!0,semantic:b});return I=e.size,e},()=>({definitions:u.length,symbols:I}));for(let e of M)i.add(e);return u.filter(e=>!i.has(e.symbolId)).sort((e,s)=>n(s)-n(e)||e.relativePath.localeCompare(s.relativePath)||e.startLine-s.startLine).map(e=>({symbol:e.symbol,shortName:S(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:n(e)}))}export{E as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FJ5UDTQF.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as m}from"./chunk-
|
|
1
|
+
import{b as m}from"./chunk-33XTHFKR.js";import{x as o}from"./chunk-RA3AYNWP.js";function h(t,l){let s=m(t,l);if(s.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let d=s.map(()=>"?").join(", "),i=t.all(`SELECT relative_path FROM documents
|
|
2
2
|
WHERE relative_path IN (${d})
|
|
3
3
|
ORDER BY relative_path`,...s).map(e=>e.relative_path).filter(e=>!t.isIgnored(e)),n=o(t,i,{onlyDocumented:!0,sort:!0}).map(({relativePath:e,...c})=>c),a=t.all(`SELECT DISTINCT d2.relative_path
|
|
4
4
|
FROM mentions m
|
|
@@ -32,4 +32,4 @@ import{b as m}from"./chunk-N3SE646F.js";import{x as o}from"./chunk-ZTTISZ7J.js";
|
|
|
32
32
|
WHERE d2.relative_path IN (${d})
|
|
33
33
|
AND d1.relative_path NOT IN (${d})
|
|
34
34
|
ORDER BY d1.relative_path`,...s,...s).map(e=>e.relative_path).filter(e=>!t.isIgnored(e));return{files:i,symbols:n,dependsOn:a,dependedOnBy:r}}export{h as a};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-GHKEJTCE.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as re,e as oe,f as se,g as M,h as T,i as ce,k as le,n as fe,o as me}from"./chunk-
|
|
1
|
+
import{d as re,e as oe,f as se,g as M,h as T,i as ce,k as le,n as fe,o as me}from"./chunk-E2LAW7SL.js";import{d as R}from"./chunk-SMQWE25B.js";import{L as ae}from"./chunk-FD3HFKXR.js";import{a as te}from"./chunk-DQGSM7RZ.js";import{e as S,s as ne,z as ie}from"./chunk-RA3AYNWP.js";import{a as K,b as Q,f as L,p as v}from"./chunk-MZZBAITE.js";import{H as A,x as ee}from"./chunk-WUW7YUAH.js";import{A as y,O as p,k as d,l as V,o as w,p as E,r as X,t as F,y as q}from"./chunk-JORHF5AL.js";import{b as W,d as I}from"./chunk-VVY2G5ET.js";function D(e,i,n,t={}){if(!n)return[];let r=p(e,i);return r?r.indexOf(n)===-1?[]:(O(e,i).get(n)??[]).filter(o=>!Le(o,t)):[]}function Le(e,i){return typeof i.excludeStartLine=="number"&&typeof i.excludeEndLine=="number"&&e>=i.excludeStartLine&&e<=i.excludeEndLine}var ve=d("file-identifiers",{clearGroups:["whole-project","source-file"]});function ue(e,i){let n=L(e,i);return n?n.fileIdentifiers:ve.get(e,i,()=>new Set(O(e,i).keys()))}var Re=d("file-ident-lines",{clearGroups:["whole-project","source-file"]});function O(e,i){let n=L(e,i);return n?n.identifierLineMap:Re.get(e,i,()=>De(e,i))}var Me=d("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function qe(e,i){let n=L(e,i);return n?n.identifiersByLine:Me.get(e,i,()=>{let t=O(e,i),r=0;for(let o of t.values()){let c=o[o.length-1];c!==void 0&&c>r&&(r=c)}let s=new Array(r+1);for(let o=0;o<=r;o+=1)s[o]=new Set;for(let[o,c]of t)for(let a of c)s[a].add(o);return s})}function De(e,i){let n=new Map,t=(c,a)=>{let l=n.get(c);if(!l){n.set(c,[a]);return}l[l.length-1]!==a&&l.push(a)},r=p(e,i);if(!r)return n;let s=Q(r).split(/\r?\n/),o=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<s.length;c+=1){let a=s[c]??"";for(let l of a.matchAll(o))l[1]&&t(l[1],c)}return n}function rt(e,i){let n=pe(e);return n?i.filter(t=>pe(t.file)===n):i}function ot(e,i,n,t){let r=n.find(s=>s.file===i);if(r)return r;if(t){let s=new Set(v(e,i).map(o=>o.sourcePath).filter(o=>!!o));for(let o of n)for(let c of s)if(I(c,o.file))return o;return null}return n.length===1?n[0]:null}function pe(e){let i=ee(e);return i?i==="typescript"||i==="tsx"||i==="javascript"?"javascript-family":i:null}var _e=V("global-leaf-index",{clearGroups:["whole-project"]});function j(e){return _e.get(e,()=>{let i=e.all(`SELECT gs.id, gs.symbol,
|
|
2
2
|
COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
|
|
3
3
|
FROM global_symbols gs
|
|
4
4
|
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
@@ -12,5 +12,5 @@ import{d as re,e as oe,f as se,g as M,h as T,i as ce,k as le,n as fe,o as me}fro
|
|
|
12
12
|
GROUP BY m.symbol_id
|
|
13
13
|
) mention_doc ON mention_doc.symbol_id = gs.id
|
|
14
14
|
WHERE 1 = 1
|
|
15
|
-
${e.symbolNoiseFor("gs")}`),n=new Map;for(let t of i){if(!t.relative_path||e.isIgnored(t.relative_path))continue;let r=S(t.symbol);if(!r)continue;let s=n.get(r);s||(s=[],n.set(r,s)),s.some(o=>o.symbolId===t.id)||s.push({symbol:t.symbol,symbolId:t.id,file:t.relative_path})}return n})}var xe=d("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function ge(e,i){let n=
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
${e.symbolNoiseFor("gs")}`),n=new Map;for(let t of i){if(!t.relative_path||e.isIgnored(t.relative_path))continue;let r=S(t.symbol);if(!r)continue;let s=n.get(r);s||(s=[],n.set(r,s)),s.some(o=>o.symbolId===t.id)||s.push({symbol:t.symbol,symbolId:t.id,file:t.relative_path})}return n})}var xe=d("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function ge(e,i){let n=W(i);return xe.get(e,n,()=>Pe(e,n))}function Pe(e,i){let n=new Map;for(let t of v(e,i)){if(!t.sourcePath)continue;let r=t.localName??t.importedName;if(r&&de(n,r,t.sourcePath),t.kind==="namespace")for(let s of t.usedMembers)de(n,s,t.sourcePath)}return n}function de(e,i,n){let t=e.get(i);t||(t=new Set,e.set(i,t)),t.add(n)}var he=/[A-Za-z_$][A-Za-z0-9_$]*/g,ye=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ne=512;function H(e){let i=[],n=!1;for(let t of e)t&&(n=!0,ye.test(t)||i.push(t));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:i}}function Se(e,i){let n=ke(i)?i:H(i);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=Ne){for(let r of n.candidateNames)if(r){if(ye.test(r)){if(we(r).test(e))return!0;continue}if(e.includes(r))return!0}return!1}he.lastIndex=0;let t;for(;(t=he.exec(e))!==null;)if(n.candidateNames.has(t[0]))return!0;for(let r of n.nonIdentifierNames)if(e.includes(r))return!0;return!1}function ke(e){return"candidateNames"in e}function we(e){return new RegExp(`(?<![A-Za-z_$0-9])${K(e)}(?![A-Za-z_$0-9])`)}function z(e,i,n){let t=j(e).get(n);if(!t||t.length===0)return[];if(t.length===1)return[C(t[0])];let r=t.filter(a=>a.file===i);if(r.length>0)return r.map(C);let s=ge(e,i),o=s.get(n);if(o)for(let a of o){let l=t.filter(m=>I(a,m.file));if(l.length>0)return l.map(C)}let c=new Set;for(let a of s.values())for(let l of a)c.add(l);for(let a of c){let l=t.filter(m=>I(a,m.file));if(l.length>0&&l.length===t.length)return l.map(C)}return[]}function Lt(e,i,n){let t=z(e,i,n);if(t.length>0)return t;let r=j(e).get(n);return!r||r.length===0?[]:r.map(C)}function be(e,i,n={}){let t=R(e,i);if(!t)return[];let r=S(t.symbol);if(!r)return[];if(n.semantic!==!1&&n.semanticEvidence){let o=n.semanticEvidence.references(e,{...t,leaf:r,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(o.length>0){let c=new Map;for(let a of o){let l=c.get(a.file)??[];l.push(a.line),c.set(a.file,l)}return _(e,c)}}let s=new Map;for(let o of A(e)){let c=p(e,o);if(!c||c.indexOf(r)===-1||o!==t.relativePath&&!z(e,o,r).some(m=>m.symbolId===t.symbolId))continue;let a=D(e,o,r,o===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});a.length>0&&s.set(o,a)}return _(e,s)}function vt(e,i,n={}){let t=new Map;for(let a of i){if(!a.leaf)continue;let l=t.get(a.leaf)??[];l.push(a),t.set(a.leaf,l)}if(t.size===0)return new Map;let r=new Set(i.map(a=>a.symbolId)),s=new Set(t.keys()),o=H(s),c=new Map;for(let a of A(e)){if(n.skipPath?.(a)||!Se(p(e,a),o))continue;let l=ue(e,a);if(l.size!==0){for(let m of l)if(t.has(m))for(let g of z(e,a,m)){if(!r.has(g.symbolId)||a===g.relativePath)continue;let h=c.get(g.symbolId);h||(h=new Set,c.set(g.symbolId,h)),h.add(a)}}}return c}function C(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function _(e,i){let n=[],t=new Set;for(let[r,s]of i){let o=ne(e,r);for(let c of s){let a=ie(o,c),l=`${r}|${c}|${a?.symbol??""}`;t.has(l)||(t.add(l),n.push({file:r,line:c,enclosingSymbol:a?.symbol??null}))}}return n}function Fe(e,i){let n=ze(e,i);return n?_(e,Te(e,n.match,n.identifier)):[]}function Nt(e,i,n={}){return Ae(e,i,n).map(t=>({file:t.file,line:t.line,enclosingSymbol:t.enclosingSymbol}))}function Ae(e,i,n={}){let t=be(e,i,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),r=t.length>0?Ie(t,"source-attribution"):Ie(Fe(e,i),"scip-reference-chunk");return n.includeIgnored===!0?r:r.filter(s=>!e.isIgnored(s.file))}function Ie(e,i){return e.map(n=>({...n,provenance:i}))}function Te(e,i,n){let t=new Map;for(let[r,s]of Oe(e,i.symbolId))t.set(r,je(e,r,s,i,n));return t}function Oe(e,i){let n=new Map;for(let t of re(e,[i])){if(e.isIgnored(t.relative_path))continue;let r=n.get(t.relative_path);r||(r=[],n.set(t.relative_path,r)),r.push({start_line:t.chunk_start,end_line:t.chunk_end})}return n}function je(e,i,n,t,r){let s=i===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{},o=r?D(e,i,r,s):[];return n.flatMap(c=>He(o,c))}function He(e,i){let n=e.filter(t=>t>=i.start_line&&t<=i.end_line);return n.length>0?n:[i.start_line]}function ze(e,i){let n=R(e,i);return n?{match:n,identifier:S(n.symbol)||null}:null}var $t={references:le,referenceMap:fe,callerMap:(e,i)=>T(e).callerMap(i),calleeMap:Be};function Be(e,i){let n=q(),t=new Map,r=ce(e,i),s=[],o=[],c=0,a=0,l=0,m=0,g=0,h=0,B=0;for(let{definition:f,callees:u}of r.hits)g+=1,u.length>0&&(h+=1,B+=u.length,t.set(f.symbolId,u));let b=Ge(e,r.hits);if(b.entries.length>0&&y("semantic.callees.prefetch-cache-write",()=>F(e,b.entries),()=>({entries:b.entries.length,sourceMissing:b.sourceMissing,skippedUnsupportedLanguage:b.skippedUnsupportedLanguage})),y("semantic.callees.cache-scan",()=>{for(let[f,u]of oe(r.misses)){if(!M(f)){n&&(c+=u.length);continue}let J=p(e,f);if(!J){n&&(a+=u.length),o.push(...u);continue}let Z=E(e,f,J),P=Ce(e,f);if(!P){o.push(...u);continue}let Ee=X(e,f,Z,P);for(let N of u){let Y=Ee.get(N.symbol)??null;if(Y!==null){let k=Ue(Y);if(k){n&&(l+=1),k.length>0&&t.set(N.symbolId,k);continue}n&&(m+=1)}s.push({def:N,contentHash:Z,depsDigest:P})}}},()=>({definitions:i.length,skippedUnsupportedLanguage:c,sourceMissing:a,cacheHits:l,parseFailures:m,misses:s.length,unkeyed:o.length,inMemoryHits:g,inMemoryRows:h,inMemoryCalleeCount:B,resultRows:t.size})),s.length===0&&o.length===0)return t;let G=[...o,...s.map(f=>f.def)],$=0,U=y("semantic.callees.compute-misses",()=>{let f=me(e,G);return $=f.size,f},()=>({definitions:G.length,misses:s.length,unkeyed:o.length,rows:$}));for(let[f,u]of U)t.set(f,u);let x=s.filter(f=>T(e).capability("semantic-callees",f.def.relativePath).available).map(f=>({relativePath:f.def.relativePath,symbol:f.def.symbol,contentHash:f.contentHash,depsDigest:f.depsDigest,payload:JSON.stringify(U.get(f.def.symbolId)??[])}));return x.length>0?y("semantic.callees.cache-write",()=>F(e,x),()=>({entries:x.length})):y("semantic.callees.cache-write-skip",()=>{},()=>({reason:"provider-unavailable",misses:s.length})),t}function Ge(e,i){let n=[],t=new Map,r=0,s=0;for(let{definition:o,callees:c}of i){if(!M(o.relativePath)){s+=1;continue}if(!t.has(o.relativePath)){let l=p(e,o.relativePath),m=l?Ce(e,o.relativePath):null;t.set(o.relativePath,l&&m?{contentHash:E(e,o.relativePath,l),depsDigest:m}:null)}let a=t.get(o.relativePath);if(!a){r+=1;continue}n.push({relativePath:o.relativePath,symbol:o.symbol,contentHash:a.contentHash,depsDigest:a.depsDigest,payload:JSON.stringify(c)})}return{entries:n,sourceMissing:r,skippedUnsupportedLanguage:s}}var $e="typescript-callees-v1";function Ce(e,i){let n=M(i);if(n==="typescript")return ae(e,i,$e)?.key??null;let t=Ze(e,i);return n==="rust"?w(JSON.stringify({kind:"semantic-callees",language:n,engine:se(e.config.projectRoot),positionMapping:"nearby-leaf-v1",depsDigest:t})):t}function Ue(e){try{return JSON.parse(e)}catch{return null}}var Je=d("semantic-deps-digest",{clearGroups:["whole-project","source-file"]});function Ze(e,i){return Je.get(e,i,()=>{let t=[...te(e).get(i)??[]].sort().map(r=>`${r}:${E(e,r,p(e,r))}`);return w(t.join("|"))})}export{O as a,qe as b,rt as c,ot as d,j as e,H as f,Se as g,ge as h,z as i,Lt as j,vt as k,Fe as l,Nt as m,$t as n};
|
|
16
|
+
//# sourceMappingURL=chunk-GLZTVKAB.js.map
|