scip-query 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-4IYG2SKW.js +2 -0
- package/dist/call-graph-WQNXMNNN.js +2 -0
- package/dist/{chunk-5QM7QT5B.js → chunk-25GWKRUZ.js} +2 -2
- package/dist/chunk-2BTJALUS.js +454 -0
- package/dist/{chunk-4ZCLDH6T.js → chunk-2KVU55CW.js} +2 -2
- package/dist/{chunk-CQVDALWQ.js → chunk-2OXVP5U5.js} +2 -2
- package/dist/{chunk-I2LY3KN7.js → chunk-2RE5OCHZ.js} +2 -2
- package/dist/{chunk-5J3A6RBZ.js → chunk-2XCGSDIT.js} +2 -2
- package/dist/{chunk-4KIPF45P.js → chunk-2YC7YNKT.js} +2 -2
- package/dist/{chunk-ZNW5A5VX.js → chunk-3QXC54FQ.js} +2 -2
- package/dist/{chunk-SGSPCEFC.js → chunk-3TJY6M3B.js} +2 -2
- package/dist/chunk-42W3LFUK.js +13 -0
- package/dist/chunk-44T4DUAA.js +2 -0
- package/dist/{chunk-YBWE6J32.js → chunk-4GAQ6FI4.js} +2 -2
- package/dist/{chunk-OU6SDWAM.js → chunk-4HE7MVWD.js} +2 -2
- package/dist/{chunk-QN2AI3D2.js → chunk-4TQU4TX2.js} +2 -2
- package/dist/{chunk-OMVNRPST.js → chunk-56NQAEPJ.js} +2 -2
- package/dist/{chunk-O4PZFAXA.js → chunk-57N6LN2A.js} +2 -2
- package/dist/{chunk-7MUHSZGN.js → chunk-5H5WTJSD.js} +2 -2
- package/dist/{chunk-J4HUBIVF.js → chunk-5YRQIE2B.js} +2 -2
- package/dist/{chunk-3XQLJG7V.js → chunk-5ZMBRQFC.js} +2 -2
- package/dist/{chunk-H2RBDP5S.js → chunk-6HRZQLOI.js} +2 -2
- package/dist/{chunk-PJBYDCBQ.js → chunk-6NC3YSPY.js} +2 -2
- package/dist/{chunk-MLTSTKXD.js → chunk-6VEFRPTD.js} +2 -2
- package/dist/{chunk-JLZWYDCZ.js → chunk-7C26EKLZ.js} +2 -2
- package/dist/{chunk-LXMW6ZAX.js → chunk-7IQXARSQ.js} +2 -2
- package/dist/chunk-7JYHQAH2.js +22 -0
- package/dist/{chunk-YA72ZUKO.js → chunk-7KSO2OAP.js} +2 -2
- package/dist/{chunk-YT4IQBET.js → chunk-7U2YQSDE.js} +2 -2
- package/dist/{chunk-XDOEHEET.js → chunk-7XA3OM44.js} +2 -2
- package/dist/{chunk-BCTCADNB.js → chunk-7XZGZBSQ.js} +2 -2
- package/dist/{chunk-3KXFB2FM.js → chunk-7YQOCABQ.js} +2 -2
- package/dist/chunk-A77SCPW2.js +3 -0
- package/dist/chunk-AK3PYTIK.js +5 -0
- package/dist/{chunk-6X4KO5A7.js → chunk-AMIMMNA4.js} +2 -2
- package/dist/{chunk-PWEQ6CZZ.js → chunk-AQ2PORIO.js} +2 -2
- package/dist/{chunk-E6N6YTVM.js → chunk-ARVO6TTW.js} +2 -2
- package/dist/{chunk-U7DOYZDH.js → chunk-AUY5BL74.js} +2 -2
- package/dist/{chunk-B3AREUQK.js → chunk-AYPDH2LU.js} +2 -2
- package/dist/{chunk-HR5JYLVV.js → chunk-AZS7YPCB.js} +2 -2
- package/dist/{chunk-ZQUNCTEZ.js → chunk-BDGTPN27.js} +2 -2
- package/dist/{chunk-DZNWXJN2.js → chunk-BDHFVH2M.js} +2 -2
- package/dist/{chunk-743MEVFJ.js → chunk-BECZLYNU.js} +2 -2
- package/dist/{chunk-4IASLUOP.js → chunk-BJT7LSPK.js} +2 -2
- package/dist/{chunk-X5MWO4DM.js → chunk-BTVKZGWT.js} +2 -2
- package/dist/{chunk-HYU4W353.js → chunk-BUTEIZKP.js} +2 -2
- package/dist/{chunk-UXNXOMXJ.js → chunk-BVFYEEBH.js} +2 -2
- package/dist/{chunk-UM56ZET4.js → chunk-BWVQP3LB.js} +2 -2
- package/dist/chunk-BYDAFMSR.js +57 -0
- package/dist/{chunk-P3UFF22M.js → chunk-C76O5MDS.js} +2 -2
- package/dist/chunk-C7IJMOFP.js +134 -0
- package/dist/{chunk-IM23CSG5.js → chunk-CBBHFNLX.js} +2 -2
- package/dist/{chunk-IZKJQQCQ.js → chunk-CKRWA452.js} +2 -2
- package/dist/{chunk-YLNCTPOI.js → chunk-CLG6DWVS.js} +2 -2
- package/dist/{chunk-DXEJ4FLZ.js → chunk-D2MVJSP4.js} +8 -8
- package/dist/chunk-D35XIZGN.js +2 -0
- package/dist/{chunk-AQF35NGT.js → chunk-DEAB5TGT.js} +2 -2
- package/dist/{chunk-7G2WIVIX.js → chunk-DJAO2OZJ.js} +2 -2
- package/dist/{chunk-PRLU3I7G.js → chunk-DKM723YF.js} +4 -4
- package/dist/{chunk-RSUH7G5T.js → chunk-DPWKKNKI.js} +2 -2
- package/dist/chunk-E44IVWIJ.js +367 -0
- package/dist/{chunk-W7HN6V4E.js → chunk-EDMB6SSO.js} +2 -2
- package/dist/{chunk-YCXQQ3YB.js → chunk-EELG7D3Q.js} +2 -2
- package/dist/{chunk-T2PBOVDI.js → chunk-EELPBR7E.js} +2 -2
- package/dist/{chunk-PAZSBPJR.js → chunk-EETGXQY7.js} +2 -2
- package/dist/{chunk-DUDUIT5P.js → chunk-ENWQWA2R.js} +2 -2
- package/dist/{chunk-QH5Q6M5C.js → chunk-ERCYGVAM.js} +2 -2
- package/dist/{chunk-ZGDHC5AT.js → chunk-EWWY2ZFL.js} +2 -2
- package/dist/{chunk-LJMWILX6.js → chunk-F24G5NBE.js} +2 -2
- package/dist/{chunk-XNF5T4T2.js → chunk-F24QUEQP.js} +2 -2
- package/dist/{chunk-IH3K5J6K.js → chunk-FBCVASUG.js} +2 -2
- package/dist/{chunk-EPLE5O5O.js → chunk-FELGD32K.js} +2 -2
- package/dist/{chunk-PU6XDQ2X.js → chunk-FFJQZG6J.js} +5 -5
- package/dist/{chunk-JGMD6JGB.js → chunk-FGNCOQUX.js} +2 -2
- package/dist/chunk-FKGQOTKD.js +2 -0
- package/dist/{chunk-27OUNZW5.js → chunk-GDRJB3SB.js} +2 -2
- package/dist/chunk-GH5YSGZL.js +5 -0
- package/dist/{chunk-IHGK3SZ7.js → chunk-GIQ6CSL4.js} +2 -2
- package/dist/{chunk-ITF3CWS5.js → chunk-GPGRZJ3R.js} +2 -2
- package/dist/{chunk-EJHNTAEE.js → chunk-GQIDEID3.js} +2 -2
- package/dist/{chunk-UEQORB2A.js → chunk-GRX7JOXQ.js} +2 -2
- package/dist/{chunk-6QN4FYQW.js → chunk-GVOMSPGL.js} +2 -2
- package/dist/{chunk-NT4NVEHU.js → chunk-GY7CCCEZ.js} +2 -2
- package/dist/{chunk-BVR44XXB.js → chunk-H7CG6LOE.js} +2 -2
- package/dist/{chunk-67FK5KGV.js → chunk-HCVJR2V4.js} +2 -2
- package/dist/{chunk-FOP7HD6H.js → chunk-HG722PO7.js} +2 -2
- package/dist/{chunk-YR7VRWNX.js → chunk-HISEUIL2.js} +2 -2
- package/dist/{chunk-Y2S4YNLH.js → chunk-HXOU4XNH.js} +2 -2
- package/dist/{chunk-DZA7MQMU.js → chunk-I6UTXNHU.js} +2 -2
- package/dist/{chunk-QZCACNV5.js → chunk-IJMD6BRI.js} +2 -2
- package/dist/{chunk-QGVUPYBC.js → chunk-IKVNEGTW.js} +2 -2
- package/dist/chunk-IMKZEXZG.js +2 -0
- package/dist/{chunk-LGVTIZPV.js → chunk-ISIQLPJ2.js} +2 -2
- package/dist/{chunk-BYXWXLKM.js → chunk-ISWFRGJ6.js} +2 -2
- package/dist/chunk-IW5XQG5G.js +2 -0
- package/dist/{chunk-ZMS4YCY7.js → chunk-IXESDH3J.js} +2 -2
- package/dist/{chunk-K63CAPS2.js → chunk-JAT6C3VX.js} +2 -2
- package/dist/{chunk-U2MNECDU.js → chunk-JFQBRL3J.js} +2 -2
- package/dist/{chunk-4SZJF4GK.js → chunk-JHH5SCZ3.js} +2 -2
- package/dist/{chunk-AAOEROT3.js → chunk-JJ62MTQH.js} +2 -2
- package/dist/chunk-JT6XX7QY.js +8 -0
- package/dist/{chunk-OY7PCALC.js → chunk-JUN5DOAK.js} +2 -2
- package/dist/{chunk-DXYMTQZ4.js → chunk-K3XFWJI2.js} +2 -2
- package/dist/{chunk-ZP2WUVZ5.js → chunk-KFVSJX25.js} +2 -2
- package/dist/{chunk-ND3BWIVN.js → chunk-KQHJEU6V.js} +2 -2
- package/dist/{chunk-KGKCJFWZ.js → chunk-KZYID5KV.js} +2 -2
- package/dist/{chunk-2LJLEM5B.js → chunk-LO5JSW2C.js} +2 -2
- package/dist/{chunk-CNT4ND5O.js → chunk-LRI5OMPE.js} +2 -2
- package/dist/{chunk-FCGMQETU.js → chunk-LXQUF2RP.js} +2 -2
- package/dist/{chunk-FSPENGSU.js → chunk-MHIEP7EG.js} +2 -2
- package/dist/{chunk-LIWIV26I.js → chunk-MSR2QRUE.js} +2 -2
- package/dist/chunk-N7FP5H5U.js +57 -0
- package/dist/{chunk-527HV7JY.js → chunk-NEIQPFBI.js} +2 -2
- package/dist/chunk-NK3JMP22.js +2 -0
- package/dist/{chunk-DK6MB565.js → chunk-NRBNAECH.js} +2 -2
- package/dist/{chunk-4HQYNZ3P.js → chunk-NVSZNESQ.js} +2 -2
- package/dist/{chunk-QLWZUFDT.js → chunk-OJNK5ALA.js} +2 -2
- package/dist/{chunk-MRXBLYRE.js → chunk-OPSAW5DT.js} +2 -2
- package/dist/{chunk-4TOU7HHQ.js → chunk-OTSPRVNW.js} +2 -2
- package/dist/{chunk-IQMGNIGY.js → chunk-OXYAWIEA.js} +2 -2
- package/dist/chunk-OZETODHH.js +2 -0
- package/dist/chunk-PBUH2P5S.js +3 -0
- package/dist/{chunk-5BJPJUXF.js → chunk-PIFTZEEM.js} +2 -2
- package/dist/{chunk-C52Q3JEQ.js → chunk-PLJUQFQN.js} +2 -2
- package/dist/{chunk-NODZYYGC.js → chunk-PLYUVM4F.js} +2 -2
- package/dist/{chunk-47WX6UC4.js → chunk-PXXYQK55.js} +2 -2
- package/dist/{chunk-SBFDPHKH.js → chunk-Q55NF3ZG.js} +2 -2
- package/dist/{chunk-N4EFQIRX.js → chunk-Q5TA4OY4.js} +2 -2
- package/dist/{chunk-HW7FASEL.js → chunk-Q6T2CAJL.js} +2 -2
- package/dist/chunk-Q7GBK5T7.js +81 -0
- package/dist/{chunk-CXT3GZSQ.js → chunk-QKT4UI2Y.js} +2 -2
- package/dist/{chunk-DGM2RJ3I.js → chunk-QLBSG7U5.js} +2 -2
- package/dist/chunk-QWKHW6VZ.js +2 -0
- package/dist/{chunk-3T5U2EQ2.js → chunk-R6M456QG.js} +2 -2
- package/dist/{chunk-RZWBTKXO.js → chunk-RDULNRSJ.js} +2 -2
- package/dist/{chunk-YKHL4J3G.js → chunk-RHHCLWQ6.js} +2 -2
- package/dist/{chunk-YF25RQER.js → chunk-RNKPYYYE.js} +2 -2
- package/dist/{chunk-XKM5D2XS.js → chunk-RPL3ARU7.js} +2 -2
- package/dist/{chunk-XFRHBAIT.js → chunk-RYOYJMGF.js} +2 -2
- package/dist/chunk-SB25YMEQ.js +2 -0
- package/dist/{chunk-SRIZDEWX.js → chunk-SVHTMVA4.js} +2 -2
- package/dist/{chunk-AFRS7WJU.js → chunk-SWK4XPUS.js} +2 -2
- package/dist/{chunk-YDTK77JP.js → chunk-T6QD2ZQB.js} +2 -2
- package/dist/{chunk-Z2QB75BS.js → chunk-TAYD3AE7.js} +2 -2
- package/dist/chunk-TD7VKJ2Y.js +117 -0
- package/dist/{chunk-K2DZCH2K.js → chunk-TH6IC56G.js} +2 -2
- package/dist/{chunk-FIO44MVK.js → chunk-TKDNDQA7.js} +2 -2
- package/dist/{chunk-Q4MRRB3C.js → chunk-TNG2FYS5.js} +2 -2
- package/dist/chunk-TQZV7KV4.js +2 -0
- package/dist/{chunk-NSDPPUDY.js → chunk-TUQIPUDS.js} +2 -2
- package/dist/chunk-TUSPIVZ3.js +4 -0
- package/dist/{chunk-RNKRYK6B.js → chunk-U2N2KE7A.js} +2 -2
- package/dist/{chunk-G47MFF47.js → chunk-UAQ4T73O.js} +2 -2
- package/dist/{chunk-5KIJMEPC.js → chunk-UDY7MIAW.js} +2 -2
- package/dist/{chunk-MLTKGHD2.js → chunk-URSGGIZX.js} +2 -2
- package/dist/{chunk-IGBQVEHE.js → chunk-UT7TADJX.js} +2 -2
- package/dist/{chunk-Z67JOKRE.js → chunk-V4NG5OMS.js} +105 -105
- package/dist/{chunk-OA2BO4DR.js → chunk-VMWUV6WB.js} +2 -2
- package/dist/{chunk-PX6QNUYF.js → chunk-VTCIYFEK.js} +2 -2
- package/dist/{chunk-6DO3VBLV.js → chunk-VU6LIWHT.js} +2 -2
- package/dist/{chunk-CTO3TRX7.js → chunk-VUSKPCUB.js} +2 -2
- package/dist/{chunk-V6XENWOF.js → chunk-VXJJTQYE.js} +2 -2
- package/dist/{chunk-BM4OTGSY.js → chunk-VZ7NXSHV.js} +2 -2
- package/dist/{chunk-ARGPDW2Y.js → chunk-WHADK6OS.js} +2 -2
- package/dist/chunk-WN3TCGJ4.js +2 -0
- package/dist/{chunk-GBZCVYWA.js → chunk-WOOAY3PA.js} +2 -2
- package/dist/{chunk-FLSVYEPL.js → chunk-WSLEJSFR.js} +2 -2
- package/dist/{chunk-BMKTDJI6.js → chunk-WYZIHUPZ.js} +2 -2
- package/dist/{chunk-WZ7V4BQV.js → chunk-XE33FV5W.js} +2 -2
- package/dist/{chunk-JO6FK3Q5.js → chunk-XFMVKFSF.js} +2 -2
- package/dist/{chunk-3YETOKNO.js → chunk-XGGBK66W.js} +2 -2
- package/dist/{chunk-BZCRHP46.js → chunk-XJX6LGHL.js} +2 -2
- package/dist/{chunk-OFZVFIDF.js → chunk-XN22RGSR.js} +2 -2
- package/dist/{chunk-VJAD5WX5.js → chunk-XSWYJCAK.js} +2 -2
- package/dist/{chunk-WV6R37XV.js → chunk-XU75YQN4.js} +2 -2
- package/dist/{chunk-UBETC3Q2.js → chunk-Y2VM4CJC.js} +2 -2
- package/dist/{chunk-7YZGSLW6.js → chunk-Y334QQU5.js} +2 -2
- package/dist/{chunk-TP2X2C2Y.js → chunk-YAGYMBEX.js} +2 -2
- package/dist/{chunk-KBIC6JHJ.js → chunk-YIHNPKWD.js} +2 -2
- package/dist/{chunk-5Z2H76VD.js → chunk-YXPUP5G2.js} +2 -2
- package/dist/{chunk-G6VV7ROY.js → chunk-Z2AWCTN6.js} +2 -2
- package/dist/{chunk-O3EX5STE.js → chunk-Z2PZVKPR.js} +2 -2
- package/dist/{chunk-OG5UK2K7.js → chunk-ZAZGGSM3.js} +2 -2
- package/dist/{chunk-GTZFKDP3.js → chunk-ZGW4HLPD.js} +2 -2
- package/dist/chunk-ZOXKSQQB.js +2 -0
- package/dist/{chunk-KFFQURUZ.js → chunk-ZPASRBLF.js} +2 -2
- package/dist/{chunk-WZRNEVYC.js → chunk-ZYM4HOFA.js} +2 -2
- package/dist/{chunk-FUUDUAKM.js → chunk-ZZ3Z7D56.js} +2 -2
- package/dist/cli-main.js +2 -2
- package/dist/code-EQJFDT6I.js +2 -0
- package/dist/code-result-json-7UWIWBOO.js +2 -0
- package/dist/{command-descriptors-6INSCKLW.js → command-descriptors-ORNTVNYV.js} +89 -89
- package/dist/dataflow-6VL54GX5.js +2 -0
- package/dist/dependence-slice-DT2NUHD2.js +2 -0
- package/dist/deps-DB7H5IKC.js +2 -0
- package/dist/direct-navigation-O3LUAYWQ.js +3 -0
- package/dist/entry-map-6K62RV3D.js +2 -0
- package/dist/files-MSLD7MO6.js +2 -0
- package/dist/hierarchy-IVBXAKFA.js +2 -0
- package/dist/imports-FRAVZ3Y2.js +2 -0
- package/dist/index.js +1 -1
- package/dist/members-KJOJDYGO.js +2 -0
- package/dist/methods-2AYABBT3.js +2 -0
- package/dist/output-continuation-command-JHMPH6NC.js +3 -0
- package/dist/project-reindex-HYO4WD7Z.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +11 -0
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +2 -2
- package/dist/refs-ARMA6XUJ.js +2 -0
- package/dist/{refs-pagination-SRCUOYRD.js → refs-pagination-VUGIWN6U.js} +2 -2
- package/dist/reindex-worker.js +64 -22
- package/dist/reindex.js +74 -32
- package/dist/runtime.js +1 -1
- 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/slice-YOB5YFAM.js +2 -0
- package/dist/surface-VY5EFWTW.js +2 -0
- package/dist/{symbol-resolution-SVSMX4RN.js → symbol-resolution-DGQN4XIV.js} +2 -2
- package/dist/system-2KQ3QD2P.js +2 -0
- package/dist/trace-HTIPTXAE.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/value-flow-5FV3VQI7.js +2 -0
- package/dist/watch-server.js +3 -3
- package/package.json +1 -1
- package/dist/by-kind-XXGZGNZ6.js +0 -2
- package/dist/call-graph-VGY3R4L3.js +0 -2
- package/dist/chunk-3XZELASU.js +0 -2
- package/dist/chunk-63TFRBMB.js +0 -2
- package/dist/chunk-6LS3IG2I.js +0 -13
- package/dist/chunk-7Z4GMCHM.js +0 -117
- package/dist/chunk-ANCHW2R4.js +0 -57
- package/dist/chunk-C7WSQA6A.js +0 -21
- package/dist/chunk-DNPETNXT.js +0 -2
- package/dist/chunk-E7CJ6O72.js +0 -2
- package/dist/chunk-FYCH2EYQ.js +0 -2
- package/dist/chunk-GSHTVE56.js +0 -3
- package/dist/chunk-JSHDCVUM.js +0 -81
- package/dist/chunk-L7WRUNKJ.js +0 -2
- package/dist/chunk-LFWB7TOJ.js +0 -2
- package/dist/chunk-MFBVUQJZ.js +0 -2
- package/dist/chunk-MR4ZKWO6.js +0 -57
- package/dist/chunk-NP4JFCLE.js +0 -133
- package/dist/chunk-NQXWWE6S.js +0 -8
- package/dist/chunk-O2VY47Y5.js +0 -325
- package/dist/chunk-SIGVQT43.js +0 -2
- package/dist/chunk-UAQQR55F.js +0 -2
- package/dist/chunk-VRJG7N3I.js +0 -453
- package/dist/chunk-WCIKJ2E3.js +0 -3
- package/dist/chunk-WEXQYJY3.js +0 -5
- package/dist/chunk-WOPZX5GM.js +0 -2
- package/dist/chunk-XDQX6LDT.js +0 -4
- package/dist/chunk-XIPGCT3D.js +0 -5
- package/dist/chunk-Z2KGMIL4.js +0 -2
- package/dist/code-AXLJBZ6T.js +0 -2
- package/dist/code-result-json-CTZHAQXJ.js +0 -2
- package/dist/dataflow-AFXY423Q.js +0 -2
- package/dist/dependence-slice-2G4X6VSJ.js +0 -2
- package/dist/deps-LMCAV5DO.js +0 -2
- package/dist/direct-navigation-2ONV22Y2.js +0 -3
- package/dist/entry-map-ZOC3VXO5.js +0 -2
- package/dist/files-WJQJLHMH.js +0 -2
- package/dist/hierarchy-ASNIHAX4.js +0 -2
- package/dist/imports-JICEKDKK.js +0 -2
- package/dist/members-C5H2K3MS.js +0 -2
- package/dist/methods-KZOZHSD4.js +0 -2
- package/dist/output-continuation-command-NX3RH3TP.js +0 -3
- package/dist/project-reindex-A2SXUH2H.js +0 -3
- package/dist/refs-ZOORVRQC.js +0 -2
- package/dist/slice-NOTBWA7S.js +0 -2
- package/dist/surface-BTBCLKNA.js +0 -2
- package/dist/system-2EIUFP6B.js +0 -2
- package/dist/trace-BB2GHQPG.js +0 -2
- package/dist/value-flow-OA7AHSUG.js +0 -2
package/dist/watch-server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ze,c as Je,g as dt,j as ut,k as X,l as ht,m as Ie}from"./chunk-W7HN6V4E.js";import{a as K,b as St,c as vt}from"./chunk-3KXFB2FM.js";import{a as ke,b as kt,c as Pt,d as Tt,e as Pe,f as Ct,g as Te,h as Wt,i as Et,j as Mt,k as At,l as Lt,m as _t,n as jt}from"./chunk-U7DOYZDH.js";import{a as wt}from"./chunk-MXNGIEPU.js";import{a as Rt,c as Y}from"./chunk-UXNXOMXJ.js";import"./chunk-4SZJF4GK.js";import{d as B,e as Q,f as xe,g as bt}from"./chunk-WOPZX5GM.js";import"./chunk-DHEQMPLW.js";import{a as Z,b as It,c as xt}from"./chunk-DUDUIT5P.js";import{H as pt,c as nt,d as ye,g as q}from"./chunk-SIGVQT43.js";import{e as ct}from"./chunk-PRLU3I7G.js";import{a as ge,d as He}from"./chunk-DXYMTQZ4.js";import{a as lt}from"./chunk-DK6MB565.js";import"./chunk-FYCH2EYQ.js";import"./chunk-O4PZFAXA.js";import{a as E,c as Se,h as ft,j as ve,n as gt,o as mt,p as Re,q as we,r as be,s as yt}from"./chunk-NQXWWE6S.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as P,d as T,e as Xe}from"./chunk-Z2KGMIL4.js";import{G as Ke,H as F,I as Ye,K as Qe,L as O,N,R as Ze,S as et,V as tt,W as rt,X as me,Y as it,aa as st,ba as ot,h as R,l as fe,n as Ve,ra as at}from"./chunk-XIPGCT3D.js";import v from"process";import{rmSync as mr}from"fs";import{resolve as Mi}from"path";import{pathToFileURL as Ai}from"url";import{lstatSync as wr}from"fs";function Dt(t,e){let r=ee(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=ee(e);if(i.kind!=="directory")throw new Error(`Git control path is not a directory: ${e}`);return{projectRoot:t,projectDirectory:r,gitControlDirectory:{path:e,identity:i}}}function Ft(t){try{if(!Gt(t.projectDirectory,ee(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Gt(e.identity,ee(e.path))}catch{return!1}}function ee(t){let e=wr(t,{bigint:!0}),r=e.isDirectory()?"directory":e.isFile()?"file":void 0;if(!r||e.isSymbolicLink())throw new Error(`Unsupported watcher identity path: ${t}`);return{device:e.dev,inode:e.ino,birthtimeNs:e.birthtimeNs,kind:r}}function Gt(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Me,lstatSync as Ir,statSync as Xt,watch as xr}from"fs";import{EventEmitter as kr}from"events";import{basename as Pr,dirname as Tr,isAbsolute as Ae,join as b,relative as Kt,resolve as Yt}from"path";import{watch as Cr}from"chokidar";import Wr from"ignore";var Qt=5e3,ie=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=Q(e.config),this.outputDb=e.outputDb??b(Ke(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=Zr(this.projectRoot,Tr(this.outputDb)),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??_r,Zt.set(this,ei(e.stopTimeoutMs??Qt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??Ur(),this.subscriptionFactory=e.subscriptionFactory??jr,this.budgetInspector=e.budgetInspector??ht,er.set(this,{projectRoot:e.projectRoot,config:e.config,gitReader:e.gitReader??Ze,languages:rr(e.languages??e.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=lt(e.projectRoot),this.extraIgnore=Wr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),Vt(this)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,re(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...re(this).closures],n=Mr(this),s=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,s,n).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`),!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=Ce(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,ignorePermissionErrors:!0,...e?{interval:5e3,binaryInterval:1e4}:{}});r.on("all",(i,n)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Hr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Ar(re(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;if(Bt(i,this.localCacheWatchPath))return!0;let n=r?`${i}/`:i;return this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e,r){let i=this.relativeWatchPath(r);if(!i||i===".."||i.startsWith("../")||Bt(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Pr(i).startsWith(dt))return;i===".scipquery.json"&&zt(this,this.projectRoot);let n=Jt(this,e,i);n!==null&&(n||this.markPendingChangesIncomplete(`unsupported-source-event:${e}`),this.scheduleReindex({kind:"watch-source",detail:i},n?[{path:i,kind:n}]:void 0,n!==void 0))}relativeWatchPath(e){let r=Ae(e)?e:b(this.projectRoot,e);return Kt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=Ce(this.pendingTrigger,e),i||this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`);for(let s of r??[])this.recordPendingChange(s);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});let s=this.activeOperation;s&&L.get(this)!==s&&(L.set(this,s),s.cancel().then(a=>{a.state==="degraded"&&!this.stopped&&this.onError(new Error(a.reason))},a=>{this.stopped||this.onError(a instanceof Error?a:new Error(String(a)))}));return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget(),r=this.watchConfig.allowExpensiveRebuild&&e.state!=="paused";if(e.state==="paused"&&e.reason!=="rebuild-count"){this.dirty=!0;let c=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:c,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,c-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let c=this.watchConfig.cooldownMs-i;this.dirty=!0;let l=this.wallNow()+c;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},c);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let s=this.consumePendingChangeJournal(),a=this.wallNow();this.setStatus({state:"indexing",startedAt:a});let o=this.reindexRunner.start(this.reindexRequest(n,r,s));this.activeOperation=o,o.completion.then(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),te.set(this,0),this.stopped)return;if(L.get(this)===o){if(this.restorePendingChangeJournal(s),this.dirty){let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"});return}Vt(this);let l=!1;try{l=this.onReindexComplete(c,n,{pendingChanges:this.dirty})===!0}catch(u){this.onError(u instanceof Error?u:new Error(String(u)))}if(this.dirty&&!this.stopped){if(l){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let l=c instanceof Error?c:new Error(String(c));this.restorePendingChangeJournal(s);let u=tr(l),d=0;if(u?(d=(te.get(this)??0)+1,te.set(this,d),this.dirty=!0,this.pendingTrigger=Ce(this.pendingTrigger,n)):te.set(this,0),!u&&L.get(this)!==o&&(this.onReindexError(l,n),this.onError(l)),this.dirty){let h=u?$r(this.watchConfig.cooldownMs,d):this.watchConfig.cooldownMs,p=this.wallNow()+h;this.setStatus({state:"cooldown",until:p,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},h);return}this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===o&&(this.activeOperation=null),L.get(this)===o&&L.delete(this)})}async finishStop(e,r,i,n,s){let a=[],o=e.map(async h=>{try{await h.close()}catch(p){a.push(`watch subscription close failed: ${String(p)}`)}});o.push(...r),i&&o.push((async()=>{try{let h=await i.cancel();h.state==="degraded"&&a.push(h.reason)}catch(h){a.push(`reindex cancellation failed: ${h instanceof Error?h.message:String(h)}`)}})());let c=o.length,l=o.map(h=>h.finally(()=>{c-=1})),u=await Er(l,n,this.clock),d=re(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${c} operation(s) still pending`),Promise.all(l).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e,r=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e,changeJournal:i,allowExpensiveRebuild:r}}setStatus(e){this.status=e,this.onStatus(e)}recordPendingChange(e){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(e.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let r=this.pendingChanges.get(e.path),i=Jr(r,e.kind);i===null?this.pendingChanges.delete(e.path):this.pendingChanges.set(e.path,i)}markPendingChangesIncomplete(e){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=e}consumePendingChangeJournal(){let e=q(this.outputDb),r=[...this.pendingChanges.entries()].map(([a,o])=>({path:a,kind:o})).sort((a,o)=>a.path.localeCompare(o.path)),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;e||(i=!1,n??="accepted-generation-unavailable");let s={version:1,baseGeneration:e,complete:i,...n?{incompleteReason:n}:{},entries:r};return Ie(s)||(s={version:1,baseGeneration:e,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),s}restorePendingChangeJournal(e){let r=[...this.pendingChanges.entries()].map(([s,a])=>({path:s,kind:a})),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;this.resetPendingChanges(),e.complete||this.markPendingChangesIncomplete(e.incompleteReason??"failed-reindex");for(let s of e.entries)this.recordPendingChange(s);i||this.markPendingChangesIncomplete(n??"failed-reindex");for(let s of r)this.recordPendingChange(s)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(x(this).stagedIndexEntries=Ht(this.projectRoot,x(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;if(!i&&!n)return;let s=x(this),a=s.stagedIndexEntries,o=Ht(this.projectRoot,s.gitReader);s.stagedIndexEntries=o;let c=ni(this.projectRoot,s.gitReader,e,r,a,o,i,n),l=null;if(c!==null&&(c.includes(".scipquery.json")&&zt(this,this.projectRoot),l=c.filter(d=>Jt(this,"add",d)!==null),l.length===0))return;let u=l?.map(d=>({path:d,kind:Me(b(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:We("HEAD and index changed",l)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:We("HEAD changed",l)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:We(r.indexPath??"index changed",l)},u,u!==void 0)}readGitState(){if(this.preferFilesystemGitState){let e=this.readFilesystemGitState();if(e)return e}return this.readGitStateFromGit()}readFilesystemGitState(){let e=this.watchGitLayout??Xr(this.projectRoot);if(!e)return null;this.watchGitLayout=e;let r=Kr(e.gitDir);return r?Ut(r,e.indexPath):null}readGitStateFromGit(){let e=x(this).gitReader,r=me(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=it(this.projectRoot,r);return Ut(me(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Er(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),s=null,a=new Promise(c=>{s=r.setTimeout(()=>c(!1),n)}),o=await Promise.race([i,a]);return o&&s&&r.clearTimeout(s),o}var Nt=new WeakMap,Zt=new WeakMap,er=new WeakMap,L=new WeakMap,te=new WeakMap;function re(t){let e=Nt.get(t);if(e)return e;let r={closures:new Set,errors:[]};return Nt.set(t,r),r}function Mr(t){return Zt.get(t)??Qt}function x(t){let e=er.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function Ar(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let s=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(s),r(new Error(s))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Lr(t,e=P){let{projectRoot:r,config:i,languages:n,pnpmWorkspaces:s,typescriptProjectMode:a,typescriptProjects:o,clojureConfigPath:c,indexerConcurrency:l,trigger:u}=t,d=B(r),h=Object.keys(d).length>0?d:i,p=O(r,h),m=h.indexer?.typescript,f=h.indexer?.clojure,y=e(process.pid);if(!y)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:p.indexPath,SCIP_REINDEX_OUTPUT_DB:p.dbPath,SCIP_REINDEX_LANGUAGES:(h.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(h.indexerConcurrency??l??""),SCIP_REINDEX_PNPM_WORKSPACES:m?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:m?.projectMode??a,projects:m?.projects??o??[],maxHeapMb:m?.maxHeapMb}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:t.changeJournal?Ie(t.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:t.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(y)}}}var _r={now:T,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},jr=(t,e)=>Gr(process.platform,e.usePolling)?new Ee(t):Cr(t,e);function Gr(t,e){return t==="darwin"&&e!==!0}var $=class extends Error{constructor(e,r){super(e,r===void 0?void 0:{cause:r}),this.name="RecursiveSourceWatchError"}},Ee=class{events=new kr;watcher;constructor(e){this.watcher=xr(e,{recursive:!0},(r,i)=>{if(i===null){this.events.emit("error",new $("Recursive source watcher omitted the changed path."));return}let n=b(e,i.toString());this.events.emit("all",Dr(r,n),n)}),this.watcher.on("error",r=>{this.events.emit("error",new $(`Recursive source watcher failed: ${r.message}`,r))})}on=(e,r)=>(this.events.on(e,r),this);close(){this.watcher.close()}};function Dr(t,e){return t==="change"?"change":Me(e)?Xt(e).isDirectory()?"addDir":"add":"unlink"}var Fr=15*6e4,Or=1e3,Nr=64*1024;function qr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function qt(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
|
|
2
|
-
${i}`:r}function Br(t,e){return Object.assign(new Error(t,e===void 0?void 0:{cause:e}),{retryable:!0})}function tr(t){return t instanceof Error&&"retryable"in t&&t.retryable===!0}function $r(t,e){let r=t*2**Math.min(5,Math.max(0,e-1));return Math.max(t,Math.min(3e4,r))}function Ur(t={}){let e=t.timeoutMs??Fr,r=t.terminationGraceMs??Or,i=t.maxOutputBytes??Nr,n=t.resolveLaunch??Lr;return{start(s){let a=n(s),o=new AbortController,c=qr(),l=!1,u=
|
|
3
|
-
`)){if(r.startsWith("#")||r.startsWith("^"))continue;let i=r.indexOf(" ");if(i===-1)continue;let n=r.slice(0,i);if(r.slice(i+1).trim()===e&&Le.test(n))return n.toLowerCase()}}catch{return}}function Ut(t,e){let r={head:t,indexPath:e};try{let i=Xt(e);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}function Zr(t,e){let r=Kt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function ei(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function rr(t){return t&&t.length>0?[...t]:ge}function zt(t,e){try{let r=x(t);r.config=B(e),r.languages=rr(r.config.languages)}catch{x(t).languages=ge}}function Jt(t,e,r){let i=x(t);if(fe(r,i.languages)==="other")return null;let s=zr(e);if(r===".scipquery.json"||st(r))return i.typeScriptInputPaths=null,s;if(!ti(r,i.languages))return s;let a=i.typeScriptInputPaths;if(!a)return s;let o=a.has(r);if(s!=="add")return o?s:null;if(o)return"change";let c=ir(t);return c?c.has(r)?"add":null:s}function Vt(t){let e=x(t);if(!e.languages.includes("typescript")){e.typeScriptInputPaths=null;return}let r=ri(e.projectRoot,e.config,e.languages);e.typeScriptInputPaths=r??ir(t)}function ir(t){let e=x(t);if(!e.languages.includes("typescript"))return e.typeScriptInputPaths=null,null;try{let r=e.config.indexer?.typescript,i=ot(e.projectRoot,r?.projectMode,r?.projects);return e.typeScriptInputPaths=i,i}catch{return e.typeScriptInputPaths=null,null}}function ti(t,e){if(!e.includes("typescript"))return!1;let r=fe(t,["typescript","javascript"]);return r==="source"||r==="ambient"}function ri(t,e,r){try{let i=He(R(O(t,e).metaPath,"reindex metadata"));if(i.kind!=="supported"&&i.kind!=="legacy")return null;let n=Ve(i.metadata.fingerprint);return!n||!ii(n,r,e)?null:new Set(n.files.map(s=>s.path))}catch{return null}}function ii(t,e,r){let i=at(e,{pnpmWorkspaces:r.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:r.indexer?.typescript?.projectMode,typescriptProjects:r.indexer?.typescript?.projects,clojureConfigPath:r.indexer?.clojure?.configPath});return t.version===i.version&&JSON.stringify([...t.languages].sort())===JSON.stringify(i.languages)&&t.pnpmWorkspaces===i.pnpmWorkspaces&&t.typescriptProjectMode===i.typescriptProjectMode&&JSON.stringify([...t.typescriptProjects].sort())===JSON.stringify(i.typescriptProjects)&&t.clojureConfigPath===i.clojureConfigPath}function ni(t,e,r,i,n,s,a,o){let c=new Set;if(a){if(!r.head||!i.head)return null;let l=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,i.head,"--"]);if(l.kind!=="success")return null;for(let u of si(l.output))c.add(u)}if(o){if(n===null||s===null)return null;for(let l of ai(n,s))c.add(l)}return[...c].sort()}function Ht(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?oi(r.output):null}function si(t){return t.split("\0").filter(e=>e.length>0)}function oi(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let i=0;i<e.length;i+=2){let n=e[i],s=e[i+1];if(!n.startsWith(":")||!s)return null;r.set(s,n)}return r}function ai(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function We(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as ne,lstatSync as U,readdirSync as or,realpathSync as nr,rmSync as _,statSync as ci}from"fs";import{join as S,resolve as z,sep as ar}from"path";var li=3600*1e3,di=2*1024*1024*1024,se=300*1e3,ui="gc-state.json",hi="gc.lock";function pi(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=fi(t.leases,t.locks),i={};for(let o of t.generations)r.has(o.generationId)||(i[o.generationId]=o.unreferencedAt??t.nowMs);let n=t.generations.filter(o=>!r.has(o.generationId)).sort((o,c)=>i[o.generationId]-i[c.generationId]||o.generationId.localeCompare(c.generationId)),s=new Set;for(let o of n)t.nowMs-i[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let a=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,c)=>o+c.size,0);for(let o of n){if(a<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete i[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function fi(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function cr(t,e,r={}){if(!Qe())return{kind:"disabled"};let i=r.repositoryId===void 0?et(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(F(),"repositories",i),s=(r.now??Date.now)(),a=ne(n)?lr(t,n,i,e,s,r):{kind:"unavailable"};return gi(t,i,e,s,r),a}function lr(t,e,r,i,n,s){let a=S(e,"gc-state.json"),o=vi(a);if(!s.force&&o&&n-Date.parse(o.lastSweepAt)<se)return{kind:"throttled",sweptAt:o.lastSweepAt};let c=nt(e,{now:()=>n});if(!c)return{kind:"busy"};try{let l=mi(t,e,r,o?.unreferencedSince??{}),u=pi({nowMs:n,...l,policy:{generationTtlMs:s.policy?.generationTtlMs??li,budgetBytes:s.policy?.budgetBytes??di}}),d=0,h=0;for(let f of u.deleteWorktrees){if(!Ge(f.lease))continue;if(!ne(f.lease.localCacheDir)){_(f.leasePath,{force:!0}),h+=1;continue}if(!yi(f.lease))continue;let y=ye(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(_e(f.lease,!0))continue;try{Mt({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:i})}catch{continue}if(_e(f.lease,!0))continue;_(f.lease.localCacheDir,{recursive:!0,force:!0}),_(f.leasePath,{force:!0}),h+=1}finally{y.release()}}for(let f of u.deleteLocks)_(f.path,{force:!0});for(let f of u.deleteTemporaries)_(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)_(f.path,{recursive:!0,force:!0}),d+=f.size;ct(S(e,"evidence.db"));let p={kind:"swept",sweptAt:new Date(n).toISOString(),deletedWorktrees:h,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},m={version:1,lastSweepAt:p.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:p};return Se(a,m,{spacing:2,trailingNewline:!0}),p}catch(l){return{kind:"failed",error:l instanceof Error?l.message:String(l)}}finally{c.release()}}function gi(t,e,r,i,n){let s=S(F(),"repositories");if(!ne(s))return;let a=S(s,ui),o=Ri(a);if(!n.force&&o!==void 0&&i-o<se)return;let c=ye(S(s,hi));if(c)try{for(let l of J(s)){if(l===e||!/^[a-f0-9]{24}$/.test(l))continue;let u=S(s,l),d;try{d=U(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let h=Si(u)??t;lr(h,u,l,r,i,n)}Se(a,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function mi(t,e,r,i){let n=new Set(rt(t).map(l=>z(l.path))),s=[];for(let l of J(S(e,"worktrees"))){if(!l.endsWith(".json"))continue;let u=S(e,"worktrees",l),d=dr(u);if(!d)continue;let h=z(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&Ge(d),live:n.has(h)||ne(h),busy:_e(d)})}let a=[];for(let l of J(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(l);if(!u)continue;let d=S(e,"locks",l),h=je(d),p=h!==void 0&&E(h),m=u[1];a.push({generationId:m,path:d,live:p})}let o=[],c=[];for(let l of J(S(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(l);if(u){let p=S(e,"generations",l),m=Number(u[1]);try{c.push({path:p,size:sr(p),live:Number.isSafeInteger(m)&&E(m)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(l))continue;let d=S(e,"generations",l),h;try{h=U(d)}catch{continue}!h.isDirectory()||h.isSymbolicLink()||o.push({generationId:l,path:d,size:sr(d),...i[l]===void 0?{}:{unreferencedAt:i[l]}})}return{leases:s,generations:o,locks:a,temporaries:c}}function Ge(t){if(t.ownershipChecksum!==pt(t)||N(t.localCacheDir)!==N(Ye(t.projectRoot)))return!1;let e=N(S(F(),"projects"));return N(t.localCacheDir).startsWith(`${e}${ar}`)}function yi(t){if(!Ge(t))return!1;let e=z(F()),r=z(S(e,"projects")),i=z(t.localCacheDir);try{let n=U(e),s=U(r),a=U(i);if(!n.isDirectory()||n.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=nr(r);return nr(i).startsWith(`${o}${ar}`)}catch{return!1}}function Si(t){for(let e of J(S(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=dr(S(t,"worktrees",e));if(r)return r.projectRoot}}function _e(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=je(S(t.localCacheDir,i));if(n!==void 0&&E(n))return!0}let r=je(Y(t.localCacheDir).lockPath);return r!==void 0&&E(r)}function dr(t){try{let e=JSON.parse(R(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function je(t){try{let e=JSON.parse(R(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function vi(t){try{let e=JSON.parse(R(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function Ri(t){try{let e=JSON.parse(R(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function J(t){try{return or(t)}catch{return[]}}function sr(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of or(i,{withFileTypes:!0})){let s=S(i,n.name);n.isDirectory()?r.push(s):n.isFile()&&(e+=ci(s).size)}}return e}var oe=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Te(e)}initializeAfterOwnershipAcquired(){let e=Ct(this.root),r=Wt(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){kt(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Pt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(wi(i)),!0}catch(n){throw Pe(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Tt(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(Pe(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Te(this.root)}};function wi(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as Ii}from"crypto";import{Worker as xi}from"worker_threads";var ae=class{constructor(e){this.options=e;if(this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout,e.maxWorkerFailureRetries!==void 0&&(!Number.isInteger(e.maxWorkerFailureRetries)||e.maxWorkerFailureRetries<0))throw new Error("Worker maxWorkerFailureRetries must be a non-negative integer.")}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;idleTimer=null;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}hasWorker(){return this.worker!==null}start(e){if(!this.canAccept())return!1;if(this.clearIdleTimer(),e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(n){this.closed=!0,this.options.onFatal(De(n))}return!0}let r=this.ensureWorker(),i=this.deadlineTimer(e);this.active={request:e,timer:i,workerFailureRetries:0,workerFailureReasons:[]};try{r.postMessage({kind:"request",...e})}catch(n){this.failActiveAfterTermination(Fe(n),!0)}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.clearIdleTimer(),this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`,!0)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`,!0))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=bi(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active,s;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status),s=this.options.retireAfterResponse?.(i.status)??!1}catch(a){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(De(a));return}this.releaseActive(n),s?this.terminateWorker():this.scheduleIdleTermination()}async failActiveAfterTermination(e,r=!1){if(this.activeFailure){await this.activeFailure;return}let i=this.active;if(!i){await this.terminateWorker();return}this.clearTimer(i.timer),r&&i.workerFailureReasons.push(e);let n=(async()=>{if(!await this.terminateWorker())return;let a=this.options.maxWorkerFailureRetries??0;if(r&&!this.closed&&i.workerFailureRetries<a&&this.now()<=i.request.deadlineAtMs){i.workerFailureRetries+=1;try{let c=this.ensureWorker();i.timer=this.deadlineTimer(i.request),c.postMessage({kind:"request",...i.request});return}catch(c){let l=`Cold Worker retry failed: ${Fe(c)}`;if(i.workerFailureReasons.push(l),e=`${e} ${l}`,!await this.terminateWorker())return}}let o=i.workerFailureReasons.length===0?e:[...new Set([...i.workerFailureReasons,e])].join(" Cold Worker retry: ");try{this.options.onReject(i.request,o)}catch(c){this.closed=!0,this.options.onFatal(De(c));return}this.releaseActive(i)})();this.activeFailure=n;try{await n}finally{this.activeFailure===n&&(this.activeFailure=null)}}deadlineTimer(e){let r=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now()));return this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},r)}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}scheduleIdleTermination(){let e=this.options.idleTtlMs;!e||e<=0||this.closed||this.active||!this.worker||(this.clearIdleTimer(),this.idleTimer=this.setTimer(()=>{this.idleTimer=null,!(this.closed||this.active||!this.worker)&&this.terminateWorker()},e))}clearIdleTimer(){this.idleTimer&&(this.clearTimer(this.idleTimer),this.idleTimer=null)}async terminateWorker(){if(this.clearIdleTimer(),this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Fe(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function bi(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function De(t){return t instanceof Error?t:new Error(String(t))}function Fe(t){return t instanceof Error?t.message:String(t)}var ki=6e4,Pi=10*6e4;function ur(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??Ci(t.workerHeapMb),i=()=>({protocolVersion:K,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,sessionsEvicted:0,activeSessions:0,maxActiveSessions:e,softMemoryLimitBytes:r*1024*1024,retireRequested:!1,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return pr({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:i,parseEnvelope:vt,createWorker:()=>gr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath,maxActiveSessions:e,softMemoryLimitMb:r}),complete(n,s,a,o){Re(t.paths,n,{ok:!0,protocolVersion:K,id:s.id,baseGeneration:s.baseGeneration,response:a},{nowMs:o,limits:t.limits})},reject(n,s,a,o){we(t.paths,n,{ok:!1,protocolVersion:K,id:s,error:a},a,{nowMs:o,limits:t.limits})},idleTtlMs:t.workerIdleMs??Pi,maxWorkerFailureRetries:1,retireAfterResponse:n=>n.retireRequested===!0,statusWhenWorkerAbsent:n=>({...n,state:"idle",activeSessions:0,heapUsedBytes:0,retireRequested:!1}),onBusy:t.onBusy,onFatal:t.onFatal})}function hr(t){let e=()=>({protocolVersion:Z,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return pr({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:xt,createWorker:()=>gr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,s){Re(t.paths,r,{ok:!0,protocolVersion:Z,id:i.id,generation:i.generation,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){we(t.paths,r,{ok:!1,protocolVersion:Z,id:i,error:n},n,{nowMs:s,limits:t.limits})},idleTtlMs:ki,onBusy:t.onBusy,onFatal:t.onFatal})}function pr(t){let e=t.now??Date.now,r=P(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${Ii()}`,s={...t.limits,maxBatch:1},a=null,o=t.initialStatus(),c=!1,l=p=>{c=!0,t.onFatal(p)},u=new ae({name:t.name,createWorker:t.createWorker,now:e,idleTtlMs:t.idleTtlMs,maxWorkerFailureRetries:t.maxWorkerFailureRetries,retireAfterResponse:t.retireAfterResponse,onComplete(p,m,f){let y=d(p.requestId);o=f;let k=e();try{t.complete(y.claim,y.envelope,m,k)}catch(I){if(!(I instanceof ft)||I.code!=="item-too-large")throw I;t.reject(y.claim,y.envelope.id,I.message,k)}h(y)},onReject(p,m,f){let y=d(p.requestId);f!==void 0&&(o=f),t.reject(y.claim,y.envelope.id,m,e()),h(y)},onStatus(p){o=p},onFatal:l});return{poll(){if(c||!u.canAccept())return 0;let p=gt(t.paths,{ownerId:n,nowMs:e(),limits:s,owner:i,liveness:{isProcessAlive:E,readProcessIdentity:P}})[0];if(!p)return 0;let m=p.requestId;try{let f=t.parseEnvelope(mt(p,s));if(m=f.id,f.id!==p.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(f.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(a={claim:p,envelope:f},t.onBusy?.(f.deadlineAtMs),!u.start({requestId:f.id,deadlineAtMs:f.deadlineAtMs,payload:f}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(f){let y=Ei(f);try{t.reject(p,m,y,e()),a?.claim===p&&h(a)}catch(k){l(Wi(k))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?o:t.statusWhenWorkerAbsent(o),mailbox:yt(t.paths)}},async close(p){await u.close(p)}};function d(p){let m=a;if(!m||m.envelope.id!==p)throw new Error(`${t.name} parent lost the active mailbox claim.`);return m}function h(p){a===p&&(a=null,t.onBusy?.(void 0))}}var Ti=6144;function fr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:Ti}function Ci(t){return Math.max(1,Math.floor((t??fr())*.9))}function gr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new xi(r,{workerData:e,resourceLimits:{maxOldGenerationSizeMb:t.workerHeapMb??fr()}})}function Wi(t){return t instanceof Error?t:new Error(String(t))}function Ei(t){return t instanceof Error?t.message:String(t)}var yr=2e3,Li=5e3,_i=5e3,ji=6e4,Gi=10,Di=50,Fi=1e4;function Oi(t,e=1){return Xe(t,e,Gi,Di,Fi,8)}function Ni(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function qi(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,s=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!0};let a=Oi(n,s);return await e.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!1,delayMs:a}}function Bi(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}function $i(t){At(t.statePath,{version:1,protocolVersion:Rt,pid:v.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{},projectRoot:t.projectRoot,...t.worktreeId?{worktreeId:t.worktreeId}:{},cliVersion:t.cliVersion,startedAt:new Date(t.startedAtMs).toISOString(),heartbeatAt:new Date(t.nowMs).toISOString(),lastActivityAt:new Date(t.lastActivityAtMs).toISOString(),...t.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(t.lastActivityAtMs+t.idleTimeoutMs).toISOString()},watcher:t.watcherStatus,...t.watcherStatus.state==="idle"&&t.indexGeneration?{indexGeneration:t.indexGeneration}:{},...t.lastRefresh?{lastRefresh:t.lastRefresh}:{},...t.lastError?{lastError:t.lastError}:{},reindexActivity:t.reindexActivity,refreshRequests:t.refreshCoordinator.status(),typescriptSemantic:{...t.semanticLane.status(),...t.semanticBusyUntilMs===void 0?{}:{busyUntil:new Date(t.semanticBusyUntilMs).toISOString()}},typescriptIndex:{...t.indexLane.status(),...t.indexBusyUntilMs===void 0?{}:{busyUntil:new Date(t.indexBusyUntilMs).toISOString()}}},{durability:t.durability})}function Ui(t){let e=0,r=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return({processedRequests:a})=>{let o=T();if(o-i>=_i&&(i=o,!Ft(t.worktreeLiveness))){t.requestStop();return}if(o-s>=ji&&(s=o,be(t.indexMailboxPaths),be(t.semanticMailboxPaths)),o-n>=se&&(n=o,cr(t.projectRoot,t.cliVersion)),o-r>=Li){r=o;let c=Lt(t.activityPath);c&&t.updateObservedActivity(c.atMs,o),c?.refreshRequestedAtMs!==void 0&&c.refreshRequestedAtMs>e&&(e=c.refreshRequestedAtMs,t.refreshCoordinator.observeLegacyRequest(c.refreshRequestedAtMs,c.refreshDetail??"stale index observed by a legacy command"))}t.refreshCoordinator.poll(t.watcherStatus(),c=>{t.recordActivity(),t.requestRefresh(c)}),a>0&&(t.recordActivity(),t.persistState(!0,"visibility")),t.persistState()}}async function zi(t){let e,r=0,i=!1,n,s;v.once("SIGINT",t.stopSignal),v.once("SIGTERM",t.stopSignal);try{t.watcher.start();let o=t.initializeFreshness();for(t.recordActivity(),t.markReady(),t.persistState(!0),e=setInterval(()=>t.persistState(),yr),e.unref?.(),o&&t.requestRefresh(o);!t.stopRequested();){let c=await qi(r,{processIndexRequests:t.processIndexRequests,processSemanticRequests:t.processSemanticRequests,afterMailboxPoll:t.afterMailboxPoll,shouldStop:t.shouldStop,wait:t.wait});if(r=c.consecutiveIdlePolls,c.stopped)break}}catch(o){i=!0,n=o}finally{v.off("SIGINT",t.stopSignal),v.off("SIGTERM",t.stopSignal),e!==void 0&&clearInterval(e);let o=t.shutdown.begin();await t.closeLanes();let c=await o;c.state==="stopped"?t.finalizeStopped():s=t.finalizeDegraded(c.reasons)}let a=t.mailboxFatalError();if(!i&&a&&(i=!0,n=a),i&&s)throw new AggregateError([n,s],"Watch service execution and shutdown both failed.");if(i)throw n;if(s)throw s}function Ji(t){let e=hr({paths:t.semanticPaths,projectRoot:t.projectRoot,onBusy:t.onSemanticBusy,onFatal:t.onFatal}),r=t.config.indexer?.typescript,i=ur({paths:t.indexPaths,projectRoot:t.projectRoot,dbPath:t.dbPath,...r?.maxWarmSessions===void 0?{}:{maxActiveSessions:r.maxWarmSessions},...r?.workerIdleMs===void 0?{}:{workerIdleMs:r.workerIdleMs},...r?.workerSoftMemoryMb===void 0?{}:{workerSoftMemoryMb:r.workerSoftMemoryMb},...r?.workerHeapMb===void 0?{}:{workerHeapMb:r.workerHeapMb},onBusy:t.onIndexBusy,onFatal:t.onFatal});return{semanticLane:e,indexLane:i}}async function Vi(t,e,r={}){let i=Et(t,e),n=i.projectRoot,s=i.worktreeKind==="git"?Hi(n,i.worktreeId):void 0,a=Dt(n,s),o=B(n);o.watch={...o.watch,...r};let c=Q(o);if(!c.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=O(n,o),u=Y(l.cacheDir),d=P(v.pid),h=_t(u.lockPath,n,{readProcessIdentity:g=>g===v.pid?d:P(g)});if(!h.acquired)return;let p=new oe(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,c.cooldownMs)});p.initializeAfterOwnershipAcquired();let m=Date.now(),f=T(),y=m,k=f,I={state:"idle"},j,ce,C,le,de=X(l.dbPath),V=!1,Oe=!1,Ne=Number.NEGATIVE_INFINITY,qe,Be,G=It(l.cacheDir),D=St(l.cacheDir);ve(G),ve(D);let $e=ke([D.pendingDir,D.legacyRequestDir,G.pendingDir,G.legacyRequestDir,u.refreshRequestsPath]),w=(g=!1,W=g?"durable":"visibility")=>{if(!Oe)return;let pe=Date.now(),A=T();!g&&A-Ne<yr||(Ne=A,$i({statePath:u.statePath,durability:W,processIdentity:d,projectRoot:n,worktreeId:i.worktreeId,cliVersion:e,startedAtMs:m,nowMs:pe,lastActivityAtMs:y,idleTimeoutMs:c.idleTimeoutMs,watcherStatus:I,indexGeneration:j,lastRefresh:ce,lastError:C,reindexActivity:de,refreshCoordinator:p,semanticLane:ue,indexLane:he,semanticBusyUntilMs:qe,indexBusyUntilMs:Be}))},M=()=>{y=Date.now(),k=T()},Sr=g=>{M(),le??=g,C={at:new Date().toISOString(),message:g.message},w(!0,"visibility")},{semanticLane:ue,indexLane:he}=Ji({semanticPaths:G,indexPaths:D,projectRoot:n,dbPath:l.dbPath,config:o,onSemanticBusy(g){qe=g===void 0?void 0:g+5e3,w(!0,"visibility")},onIndexBusy(g){Be=g===void 0?void 0:g+5e3,w(!0,"visibility")},onFatal:Sr}),H=new ie({projectRoot:n,config:{...o,watch:c},outputDb:l.dbPath,languages:o.languages,onStatus(g){I=g,g.state!=="idle"&&(j=void 0),g.state!=="idle"&&M(),w(!0)},onReindexComplete(g,W,pe){M();let A=pe?.pendingChanges!==!1?xe(n,o,l):bt(l);return ce=A.lastRefresh,j=A.state==="fresh"?q(l.dbPath)??void 0:void 0,de=X(l.dbPath),p.completeActive(),C=void 0,w(!0),A.state==="fresh"},onReindexError(){p.failActive()},onRefreshSuppressed(g){let W=ut(l.dbPath,g);W.state==="failed"&&(C={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${W.reason}`},w(!0,"visibility")),de=X(l.dbPath)},onError(g){M(),j=void 0,C={at:new Date().toISOString(),message:g.message},w(!0)}}),Ue=Ni(H,{requestStop(){V=!0},closeWake(){$e.close()}}),vr=()=>{Ue.begin()},Rr=Ui({worktreeLiveness:a,indexMailboxPaths:D,semanticMailboxPaths:G,projectRoot:n,cliVersion:e,activityPath:u.activityPath,refreshCoordinator:p,watcherStatus:()=>I,requestRefresh:g=>H.requestRefresh({kind:"watch-demand",detail:g},{immediate:!0}),requestStop:()=>{V=!0},recordActivity:M,updateObservedActivity(g,W){g<=y||(y=g,k=W)},persistState:w});await zi({watcher:H,shutdown:Ue,stopSignal:vr,initializeFreshness(){let g=xe(n,o,l);return ce=g.lastRefresh,j=g.state==="fresh"?q(l.dbPath)??void 0:void 0,Bi(g.state)},markReady:()=>{Oe=!0},recordActivity:M,persistState:w,requestRefresh:g=>H.requestRefresh(g,{immediate:!0}),stopRequested:()=>V,processIndexRequests:()=>he.poll(),processSemanticRequests:()=>ue.poll(),afterMailboxPoll:Rr,shouldStop:()=>V||le!==void 0||jt({watcher:I,lastActivityAtMs:k,nowMs:T(),idleTimeoutMs:c.idleTimeoutMs}),wait:g=>$e.wait(g),closeLanes:()=>Promise.all([ue.close("TypeScript semantic service stopped before completing the request."),he.close("TypeScript index service stopped before completing the request.")]).then(()=>{}),mailboxFatalError:()=>le,finalizeStopped(){mr(u.statePath,{force:!0}),mr(u.activityPath,{force:!0}),h.release()},finalizeDegraded(g){return C={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${g.join("; ")}`},w(!0),new Error(C.message)}})}function Hi(t,e){let r=tt(t);if(r.kind!=="worktree"||r.identity.worktreeId!==e)throw new Error(`Git worktree identity changed while starting the watch service for ${t}.`);return r.identity.gitDir}function Xi(t,e={report:r=>console.error(r),exit:r=>v.exit(r)}){return e.report(`watch-service: ${wt(t instanceof Error?t.message:String(t))}`),e.exit(1)}var Ki=v.argv[1]?Ai(Mi(v.argv[1])).href:null;if(Ki===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Yi(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Vi(t,e,r)}catch(i){Xi(i)}}function Yi(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{ke as createPathChangeWake,Ni as createWatchServiceShutdown,qi as runWatchServiceLoopIteration,Vi as runWatchServiceServer,Bi as startupRefreshTrigger,Xi as terminateWatchServiceProcess,Oi as watchServiceLoopDelayMs};
|
|
1
|
+
import{b as Je,c as Ve,g as ut,j as ht,k as X,l as pt,m as xe}from"./chunk-EDMB6SSO.js";import{a as K,b as St,c as vt}from"./chunk-7YQOCABQ.js";import{a as Pe,b as kt,c as Pt,d as Tt,e as Te,f as Ct,g as Ce,h as Wt,i as Et,j as Mt,k as At,l as Lt,m as _t,n as jt}from"./chunk-AUY5BL74.js";import{a as wt}from"./chunk-MXNGIEPU.js";import{a as Rt,c as Y}from"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import{d as B,e as Q,f as ke,g as bt}from"./chunk-QWKHW6VZ.js";import"./chunk-DHEQMPLW.js";import{a as Z,b as It,c as xt}from"./chunk-ENWQWA2R.js";import{L as ft,c as st,d as ye,g as q}from"./chunk-WN3TCGJ4.js";import{e as lt}from"./chunk-DKM723YF.js";import{a as ge,d as Xe}from"./chunk-K3XFWJI2.js";import{a as dt}from"./chunk-NRBNAECH.js";import"./chunk-IW5XQG5G.js";import"./chunk-57N6LN2A.js";import{a as M,c as Se,h as ve,j as Re,n as gt,o as mt,p as we,q as be,r as Ie,s as yt}from"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as T,d as C,e as Ke}from"./chunk-SB25YMEQ.js";import{H as Ye,I as F,J as Qe,L as Ze,M as O,O as N,S as et,T as tt,W as rt,X as it,Y as me,Z as nt,ba as ot,ea as at,h as R,m as fe,o as He,ua as ct}from"./chunk-AK3PYTIK.js";import v from"process";import{rmSync as mr}from"fs";import{resolve as Ai}from"path";import{pathToFileURL as Li}from"url";import{lstatSync as wr}from"fs";function Dt(t,e){let r=ee(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=ee(e);if(i.kind!=="directory")throw new Error(`Git control path is not a directory: ${e}`);return{projectRoot:t,projectDirectory:r,gitControlDirectory:{path:e,identity:i}}}function Ft(t){try{if(!Gt(t.projectDirectory,ee(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Gt(e.identity,ee(e.path))}catch{return!1}}function ee(t){let e=wr(t,{bigint:!0}),r=e.isDirectory()?"directory":e.isFile()?"file":void 0;if(!r||e.isSymbolicLink())throw new Error(`Unsupported watcher identity path: ${t}`);return{device:e.dev,inode:e.ino,birthtimeNs:e.birthtimeNs,kind:r}}function Gt(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Ae,lstatSync as Ir,statSync as Xt,watch as xr}from"fs";import{EventEmitter as kr}from"events";import{basename as Pr,dirname as Tr,isAbsolute as Le,join as b,relative as Kt,resolve as Yt}from"path";import{watch as Cr}from"chokidar";import Wr from"ignore";var Qt=5e3,ie=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=Q(e.config),this.outputDb=e.outputDb??b(Ye(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=Zr(this.projectRoot,Tr(this.outputDb)),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??_r,Zt.set(this,ei(e.stopTimeoutMs??Qt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??Ur(),this.subscriptionFactory=e.subscriptionFactory??jr,this.budgetInspector=e.budgetInspector??pt,er.set(this,{projectRoot:e.projectRoot,config:e.config,gitReader:e.gitReader??et,languages:rr(e.languages??e.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=dt(e.projectRoot),this.extraIgnore=Wr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),Vt(this)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,re(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...re(this).closures],n=Mr(this),s=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,s,n).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`),!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=We(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,ignorePermissionErrors:!0,...e?{interval:5e3,binaryInterval:1e4}:{}});r.on("all",(i,n)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Hr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Ar(re(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;if(Bt(i,this.localCacheWatchPath))return!0;let n=r?`${i}/`:i;return this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e,r){let i=this.relativeWatchPath(r);if(!i||i===".."||i.startsWith("../")||Bt(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Pr(i).startsWith(ut))return;i===".scipquery.json"&&zt(this,this.projectRoot);let n=Jt(this,e,i);n!==null&&(n||this.markPendingChangesIncomplete(`unsupported-source-event:${e}`),this.scheduleReindex({kind:"watch-source",detail:i},n?[{path:i,kind:n}]:void 0,n!==void 0))}relativeWatchPath(e){let r=Le(e)?e:b(this.projectRoot,e);return Kt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=We(this.pendingTrigger,e),i||this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`);for(let s of r??[])this.recordPendingChange(s);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});let s=this.activeOperation;s&&_.get(this)!==s&&(_.set(this,s),s.cancel().then(a=>{a.state==="degraded"&&!this.stopped&&this.onError(new Error(a.reason))},a=>{this.stopped||this.onError(a instanceof Error?a:new Error(String(a)))}));return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget(),r=this.watchConfig.allowExpensiveRebuild&&e.state!=="paused";if(e.state==="paused"&&e.reason!=="rebuild-count"){this.dirty=!0;let c=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:c,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,c-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let c=this.watchConfig.cooldownMs-i;this.dirty=!0;let l=this.wallNow()+c;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},c);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let s=this.consumePendingChangeJournal(),a=this.wallNow();this.setStatus({state:"indexing",startedAt:a});let o=this.reindexRunner.start(this.reindexRequest(n,r,s));this.activeOperation=o,o.completion.then(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),te.set(this,0),this.stopped)return;if(_.get(this)===o){if(this.restorePendingChangeJournal(s),this.dirty){let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"});return}Vt(this);let l=!1;try{l=this.onReindexComplete(c,n,{pendingChanges:this.dirty})===!0}catch(u){this.onError(u instanceof Error?u:new Error(String(u)))}if(this.dirty&&!this.stopped){if(l){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let l=c instanceof Error?c:new Error(String(c));this.restorePendingChangeJournal(s);let u=tr(l),d=0;if(u?(d=(te.get(this)??0)+1,te.set(this,d),this.dirty=!0,this.pendingTrigger=We(this.pendingTrigger,n)):te.set(this,0),!u&&_.get(this)!==o&&(this.onReindexError(l,n),this.onError(l)),this.dirty){let h=u?$r(this.watchConfig.cooldownMs,d):this.watchConfig.cooldownMs,p=this.wallNow()+h;this.setStatus({state:"cooldown",until:p,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},h);return}this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===o&&(this.activeOperation=null),_.get(this)===o&&_.delete(this)})}async finishStop(e,r,i,n,s){let a=[],o=e.map(async h=>{try{await h.close()}catch(p){a.push(`watch subscription close failed: ${String(p)}`)}});o.push(...r),i&&o.push((async()=>{try{let h=await i.cancel();h.state==="degraded"&&a.push(h.reason)}catch(h){a.push(`reindex cancellation failed: ${h instanceof Error?h.message:String(h)}`)}})());let c=o.length,l=o.map(h=>h.finally(()=>{c-=1})),u=await Er(l,n,this.clock),d=re(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${c} operation(s) still pending`),Promise.all(l).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e,r=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e,changeJournal:i,allowExpensiveRebuild:r}}setStatus(e){this.status=e,this.onStatus(e)}recordPendingChange(e){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(e.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let r=this.pendingChanges.get(e.path),i=Jr(r,e.kind);i===null?this.pendingChanges.delete(e.path):this.pendingChanges.set(e.path,i)}markPendingChangesIncomplete(e){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=e}consumePendingChangeJournal(){let e=q(this.outputDb),r=[...this.pendingChanges.entries()].map(([a,o])=>({path:a,kind:o})).sort((a,o)=>a.path.localeCompare(o.path)),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;e||(i=!1,n??="accepted-generation-unavailable");let s={version:1,baseGeneration:e,complete:i,...n?{incompleteReason:n}:{},entries:r};return xe(s)||(s={version:1,baseGeneration:e,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),s}restorePendingChangeJournal(e){let r=[...this.pendingChanges.entries()].map(([s,a])=>({path:s,kind:a})),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;this.resetPendingChanges(),e.complete||this.markPendingChangesIncomplete(e.incompleteReason??"failed-reindex");for(let s of e.entries)this.recordPendingChange(s);i||this.markPendingChangesIncomplete(n??"failed-reindex");for(let s of r)this.recordPendingChange(s)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(I(this).stagedIndexEntries=Ht(this.projectRoot,I(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;if(!i&&!n)return;let s=I(this),a=s.stagedIndexEntries,o=Ht(this.projectRoot,s.gitReader);s.stagedIndexEntries=o;let c=ni(this.projectRoot,s.gitReader,e,r,a,o,i,n),l=null;if(c!==null&&(c.includes(".scipquery.json")&&zt(this,this.projectRoot),l=c.filter(d=>Jt(this,"add",d)!==null),l.length===0))return;let u=l?.map(d=>({path:d,kind:Ae(b(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:Ee("HEAD and index changed",l)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:Ee("HEAD changed",l)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:Ee(r.indexPath??"index changed",l)},u,u!==void 0)}readGitState(){if(this.preferFilesystemGitState){let e=this.readFilesystemGitState();if(e)return e}return this.readGitStateFromGit()}readFilesystemGitState(){let e=this.watchGitLayout??Xr(this.projectRoot);if(!e)return null;this.watchGitLayout=e;let r=Kr(e.gitDir);return r?Ut(r,e.indexPath):null}readGitStateFromGit(){let e=I(this).gitReader,r=me(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=nt(this.projectRoot,r);return Ut(me(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Er(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),s=null,a=new Promise(c=>{s=r.setTimeout(()=>c(!1),n)}),o=await Promise.race([i,a]);return o&&s&&r.clearTimeout(s),o}var Nt=new WeakMap,Zt=new WeakMap,er=new WeakMap,_=new WeakMap,te=new WeakMap;function re(t){let e=Nt.get(t);if(e)return e;let r={closures:new Set,errors:[]};return Nt.set(t,r),r}function Mr(t){return Zt.get(t)??Qt}function I(t){let e=er.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function Ar(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let s=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(s),r(new Error(s))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Lr(t,e=T){let{projectRoot:r,config:i,languages:n,pnpmWorkspaces:s,typescriptProjectMode:a,typescriptProjects:o,clojureConfigPath:c,indexerConcurrency:l,trigger:u}=t,d=B(r),h=Object.keys(d).length>0?d:i,p=O(r,h),m=h.indexer?.typescript,f=h.indexer?.clojure,y=e(process.pid);if(!y)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:p.indexPath,SCIP_REINDEX_OUTPUT_DB:p.dbPath,SCIP_REINDEX_LANGUAGES:(h.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(h.indexerConcurrency??l??""),SCIP_REINDEX_PNPM_WORKSPACES:m?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:m?.projectMode??a,projects:m?.projects??o??[],maxHeapMb:m?.maxHeapMb}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:t.changeJournal?xe(t.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:t.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(y)}}}var _r={now:C,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},jr=(t,e)=>Gr(process.platform,e.usePolling)?new Me(t):Cr(t,e);function Gr(t,e){return t==="darwin"&&e!==!0}var $=class extends Error{constructor(e,r){super(e,r===void 0?void 0:{cause:r}),this.name="RecursiveSourceWatchError"}},Me=class{events=new kr;watcher;constructor(e){this.watcher=xr(e,{recursive:!0},(r,i)=>{if(i===null){this.events.emit("error",new $("Recursive source watcher omitted the changed path."));return}let n=b(e,i.toString());this.events.emit("all",Dr(r,n),n)}),this.watcher.on("error",r=>{this.events.emit("error",new $(`Recursive source watcher failed: ${r.message}`,r))})}on=(e,r)=>(this.events.on(e,r),this);close(){this.watcher.close()}};function Dr(t,e){return t==="change"?"change":Ae(e)?Xt(e).isDirectory()?"addDir":"add":"unlink"}var Fr=15*6e4,Or=1e3,Nr=64*1024;function qr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function qt(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
|
|
2
|
+
${i}`:r}function Br(t,e){return Object.assign(new Error(t,e===void 0?void 0:{cause:e}),{retryable:!0})}function tr(t){return t instanceof Error&&"retryable"in t&&t.retryable===!0}function $r(t,e){let r=t*2**Math.min(5,Math.max(0,e-1));return Math.max(t,Math.min(3e4,r))}function Ur(t={}){let e=t.timeoutMs??Fr,r=t.terminationGraceMs??Or,i=t.maxOutputBytes??Nr,n=t.resolveLaunch??Lr;return{start(s){let a=n(s),o=new AbortController,c=qr(),l=!1,u=Ve({command:process.execPath,args:[...process.execArgv,a.workerPath],label:"watch reindex worker",env:a.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:o.signal,detached:!0}).then(d=>{if(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0){let h=qt(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),c);throw d.status===75?Br(h):new Error(h)}return d.durationMs}).catch(d=>{throw tr(d)?d:(d instanceof Je&&(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(qt(d,c),{cause:d}))}).finally(()=>{l=!0});return{completion:u,async cancel(){l||o.abort();try{await u}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function We(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function zr(t){if(t==="add")return"add";if(t==="change")return"change";if(t==="unlink")return"delete"}function Jr(t,e){return t?t==="add"?e==="delete"?null:"add":t==="delete"&&e==="add"?"change":e:e}function Vr(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}function Hr(t){return t instanceof $||Vr(t)}var _e=/^[0-9a-f]{40,64}$/i;function Bt(t,e){return t===".git"||t.startsWith(".git/")||t==="node_modules"||t.startsWith("node_modules/")||t.endsWith("/node_modules")||t.includes("/node_modules/")?!0:e!==void 0&&(t===e||t.startsWith(`${e}/`))}function Xr(t){let e=b(t,".git");try{let r=Ir(e),i;if(r.isDirectory())i=e;else if(r.isFile()){let n=/^gitdir:\s*(.+)\s*$/m.exec(R(e,"Git directory marker"));if(!n?.[1])return null;let s=n[1].trim();i=Le(s)?s:Yt(t,s)}else return null;return Ae(i)?{gitDir:i,indexPath:b(i,"index")}:null}catch{return null}}function Kr(t){let e;try{e=R(b(t,"HEAD"),"Git HEAD").trim()}catch{return}if(_e.test(e))return e.toLowerCase();let r=/^ref:\s*(.+)$/.exec(e)?.[1]?.trim();if(!r)return;let i=Yr(t);return $t(t,r)??$t(i,r)??Qr(i,r)}function Yr(t){try{let e=R(b(t,"commondir"),"Git common-directory marker").trim();return e?Le(e)?e:Yt(t,e):t}catch{return t}}function $t(t,e){try{let r=R(b(t,e),"Git reference").trim();return _e.test(r)?r.toLowerCase():void 0}catch{return}}function Qr(t,e){try{for(let r of R(b(t,"packed-refs"),"Git packed references").split(`
|
|
3
|
+
`)){if(r.startsWith("#")||r.startsWith("^"))continue;let i=r.indexOf(" ");if(i===-1)continue;let n=r.slice(0,i);if(r.slice(i+1).trim()===e&&_e.test(n))return n.toLowerCase()}}catch{return}}function Ut(t,e){let r={head:t,indexPath:e};try{let i=Xt(e);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}function Zr(t,e){let r=Kt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function ei(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function rr(t){return t&&t.length>0?[...t]:ge}function zt(t,e){try{let r=I(t);r.config=B(e),r.languages=rr(r.config.languages)}catch{I(t).languages=ge}}function Jt(t,e,r){let i=I(t);if(fe(r,i.languages)==="other")return null;let s=zr(e);if(r===".scipquery.json"||ot(r))return i.typeScriptInputPaths=null,s;if(!ti(r,i.languages))return s;let a=i.typeScriptInputPaths;if(!a)return s;let o=a.has(r);if(s!=="add")return o?s:null;if(o)return"change";let c=ir(t);return c?c.has(r)?"add":null:s}function Vt(t){let e=I(t);if(!e.languages.includes("typescript")){e.typeScriptInputPaths=null;return}let r=ri(e.projectRoot,e.config,e.languages);e.typeScriptInputPaths=r??ir(t)}function ir(t){let e=I(t);if(!e.languages.includes("typescript"))return e.typeScriptInputPaths=null,null;try{let r=e.config.indexer?.typescript,i=at(e.projectRoot,r?.projectMode,r?.projects);return e.typeScriptInputPaths=i,i}catch{return e.typeScriptInputPaths=null,null}}function ti(t,e){if(!e.includes("typescript"))return!1;let r=fe(t,["typescript","javascript"]);return r==="source"||r==="ambient"}function ri(t,e,r){try{let i=Xe(R(O(t,e).metaPath,"reindex metadata"));if(i.kind!=="supported"&&i.kind!=="legacy")return null;let n=He(i.metadata.fingerprint);return!n||!ii(n,r,e)?null:new Set(n.files.map(s=>s.path))}catch{return null}}function ii(t,e,r){let i=ct(e,{pnpmWorkspaces:r.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:r.indexer?.typescript?.projectMode,typescriptProjects:r.indexer?.typescript?.projects,clojureConfigPath:r.indexer?.clojure?.configPath});return t.version===i.version&&JSON.stringify([...t.languages].sort())===JSON.stringify(i.languages)&&t.pnpmWorkspaces===i.pnpmWorkspaces&&t.typescriptProjectMode===i.typescriptProjectMode&&JSON.stringify([...t.typescriptProjects].sort())===JSON.stringify(i.typescriptProjects)&&t.clojureConfigPath===i.clojureConfigPath}function ni(t,e,r,i,n,s,a,o){let c=new Set;if(a){if(!r.head||!i.head)return null;let l=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,i.head,"--"]);if(l.kind!=="success")return null;for(let u of si(l.output))c.add(u)}if(o){if(n===null||s===null)return null;for(let l of ai(n,s))c.add(l)}return[...c].sort()}function Ht(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?oi(r.output):null}function si(t){return t.split("\0").filter(e=>e.length>0)}function oi(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let i=0;i<e.length;i+=2){let n=e[i],s=e[i+1];if(!n.startsWith(":")||!s)return null;r.set(s,n)}return r}function ai(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function Ee(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as ne,lstatSync as U,readdirSync as or,realpathSync as nr,rmSync as j,statSync as ci}from"fs";import{join as S,resolve as z,sep as ar}from"path";var li=3600*1e3,di=2*1024*1024*1024,se=300*1e3,ui="gc-state.json",hi="gc.lock";function pi(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=fi(t.leases,t.locks),i={};for(let o of t.generations)r.has(o.generationId)||(i[o.generationId]=o.unreferencedAt??t.nowMs);let n=t.generations.filter(o=>!r.has(o.generationId)).sort((o,c)=>i[o.generationId]-i[c.generationId]||o.generationId.localeCompare(c.generationId)),s=new Set;for(let o of n)t.nowMs-i[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let a=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,c)=>o+c.size,0);for(let o of n){if(a<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete i[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function fi(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function cr(t,e,r={}){if(!Ze())return{kind:"disabled"};let i=r.repositoryId===void 0?tt(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(F(),"repositories",i),s=(r.now??Date.now)(),a=ne(n)?lr(t,n,i,e,s,r):{kind:"unavailable"};return gi(t,i,e,s,r),a}function lr(t,e,r,i,n,s){let a=S(e,"gc-state.json"),o=vi(a);if(!s.force&&o&&n-Date.parse(o.lastSweepAt)<se)return{kind:"throttled",sweptAt:o.lastSweepAt};let c=st(e,{now:()=>n});if(!c)return{kind:"busy"};try{let l=mi(t,e,r,o?.unreferencedSince??{}),u=pi({nowMs:n,...l,policy:{generationTtlMs:s.policy?.generationTtlMs??li,budgetBytes:s.policy?.budgetBytes??di}}),d=0,h=0;for(let f of u.deleteWorktrees){if(!De(f.lease))continue;if(!ne(f.lease.localCacheDir)){j(f.leasePath,{force:!0}),h+=1;continue}if(!yi(f.lease))continue;let y=ye(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(je(f.lease,!0))continue;try{Mt({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:i})}catch{continue}if(je(f.lease,!0))continue;j(f.lease.localCacheDir,{recursive:!0,force:!0}),j(f.leasePath,{force:!0}),h+=1}finally{y.release()}}for(let f of u.deleteLocks)j(f.path,{force:!0});for(let f of u.deleteTemporaries)j(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)j(f.path,{recursive:!0,force:!0}),d+=f.size;lt(S(e,"evidence.db"));let p={kind:"swept",sweptAt:new Date(n).toISOString(),deletedWorktrees:h,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},m={version:1,lastSweepAt:p.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:p};return Se(a,m,{spacing:2,trailingNewline:!0}),p}catch(l){return{kind:"failed",error:l instanceof Error?l.message:String(l)}}finally{c.release()}}function gi(t,e,r,i,n){let s=S(F(),"repositories");if(!ne(s))return;let a=S(s,ui),o=Ri(a);if(!n.force&&o!==void 0&&i-o<se)return;let c=ye(S(s,hi));if(c)try{for(let l of J(s)){if(l===e||!/^[a-f0-9]{24}$/.test(l))continue;let u=S(s,l),d;try{d=U(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let h=Si(u)??t;lr(h,u,l,r,i,n)}Se(a,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function mi(t,e,r,i){let n=new Set(it(t).map(l=>z(l.path))),s=[];for(let l of J(S(e,"worktrees"))){if(!l.endsWith(".json"))continue;let u=S(e,"worktrees",l),d=dr(u);if(!d)continue;let h=z(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&De(d),live:n.has(h)||ne(h),busy:je(d)})}let a=[];for(let l of J(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(l);if(!u)continue;let d=S(e,"locks",l),h=Ge(d),p=h!==void 0&&M(h),m=u[1];a.push({generationId:m,path:d,live:p})}let o=[],c=[];for(let l of J(S(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(l);if(u){let p=S(e,"generations",l),m=Number(u[1]);try{c.push({path:p,size:sr(p),live:Number.isSafeInteger(m)&&M(m)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(l))continue;let d=S(e,"generations",l),h;try{h=U(d)}catch{continue}!h.isDirectory()||h.isSymbolicLink()||o.push({generationId:l,path:d,size:sr(d),...i[l]===void 0?{}:{unreferencedAt:i[l]}})}return{leases:s,generations:o,locks:a,temporaries:c}}function De(t){if(t.ownershipChecksum!==ft(t)||N(t.localCacheDir)!==N(Qe(t.projectRoot)))return!1;let e=N(S(F(),"projects"));return N(t.localCacheDir).startsWith(`${e}${ar}`)}function yi(t){if(!De(t))return!1;let e=z(F()),r=z(S(e,"projects")),i=z(t.localCacheDir);try{let n=U(e),s=U(r),a=U(i);if(!n.isDirectory()||n.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=nr(r);return nr(i).startsWith(`${o}${ar}`)}catch{return!1}}function Si(t){for(let e of J(S(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=dr(S(t,"worktrees",e));if(r)return r.projectRoot}}function je(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=Ge(S(t.localCacheDir,i));if(n!==void 0&&M(n))return!0}let r=Ge(Y(t.localCacheDir).lockPath);return r!==void 0&&M(r)}function dr(t){try{let e=JSON.parse(R(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function Ge(t){try{let e=JSON.parse(R(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function vi(t){try{let e=JSON.parse(R(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function Ri(t){try{let e=JSON.parse(R(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function J(t){try{return or(t)}catch{return[]}}function sr(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of or(i,{withFileTypes:!0})){let s=S(i,n.name);n.isDirectory()?r.push(s):n.isFile()&&(e+=ci(s).size)}}return e}var oe=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Ce(e)}initializeAfterOwnershipAcquired(){let e=Ct(this.root),r=Wt(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){kt(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Pt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(wi(i)),!0}catch(n){throw Te(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Tt(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(Te(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Ce(this.root)}};function wi(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as Ii}from"crypto";import{rmSync as xi}from"fs";import{Worker as ki}from"worker_threads";var ae=class{constructor(e){this.options=e;if(this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout,e.maxWorkerFailureRetries!==void 0&&(!Number.isInteger(e.maxWorkerFailureRetries)||e.maxWorkerFailureRetries<0))throw new Error("Worker maxWorkerFailureRetries must be a non-negative integer.")}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;idleTimer=null;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}hasWorker(){return this.worker!==null}start(e){if(!this.canAccept())return!1;if(this.clearIdleTimer(),e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(n){this.closed=!0,this.options.onFatal(Fe(n))}return!0}let r=this.ensureWorker(),i=this.deadlineTimer(e);this.active={request:e,timer:i,workerFailureRetries:0,workerFailureReasons:[]};try{r.postMessage({kind:"request",...e})}catch(n){this.failActiveAfterTermination(Oe(n),!0)}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.clearIdleTimer(),this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`,!0)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`,!0))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=bi(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active,s;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status),s=this.options.retireAfterResponse?.(i.status)??!1}catch(a){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Fe(a));return}this.releaseActive(n),s?this.terminateWorker():this.scheduleIdleTermination()}async failActiveAfterTermination(e,r=!1){if(this.activeFailure){await this.activeFailure;return}let i=this.active;if(!i){await this.terminateWorker();return}this.clearTimer(i.timer),r&&i.workerFailureReasons.push(e);let n=(async()=>{if(!await this.terminateWorker())return;let a=this.options.maxWorkerFailureRetries??0;if(r&&!this.closed&&i.workerFailureRetries<a&&this.now()<=i.request.deadlineAtMs){i.workerFailureRetries+=1;try{let c=this.ensureWorker();i.timer=this.deadlineTimer(i.request),c.postMessage({kind:"request",...i.request});return}catch(c){let l=`Cold Worker retry failed: ${Oe(c)}`;if(i.workerFailureReasons.push(l),e=`${e} ${l}`,!await this.terminateWorker())return}}let o=i.workerFailureReasons.length===0?e:[...new Set([...i.workerFailureReasons,e])].join(" Cold Worker retry: ");try{this.options.onReject(i.request,o)}catch(c){this.closed=!0,this.options.onFatal(Fe(c));return}this.releaseActive(i)})();this.activeFailure=n;try{await n}finally{this.activeFailure===n&&(this.activeFailure=null)}}deadlineTimer(e){let r=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now()));return this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},r)}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}scheduleIdleTermination(){let e=this.options.idleTtlMs;!e||e<=0||this.closed||this.active||!this.worker||(this.clearIdleTimer(),this.idleTimer=this.setTimer(()=>{this.idleTimer=null,!(this.closed||this.active||!this.worker)&&this.terminateWorker()},e))}clearIdleTimer(){this.idleTimer&&(this.clearTimer(this.idleTimer),this.idleTimer=null)}async terminateWorker(){if(this.clearIdleTimer(),this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Oe(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function bi(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function Fe(t){return t instanceof Error?t:new Error(String(t))}function Oe(t){return t instanceof Error?t.message:String(t)}var Pi=6e4,Ti=10*6e4;function ur(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??Wi(t.workerHeapMb),i=()=>({protocolVersion:K,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,sessionsEvicted:0,activeSessions:0,maxActiveSessions:e,softMemoryLimitBytes:r*1024*1024,retireRequested:!1,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return pr({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:i,parseEnvelope:vt,createWorker:()=>gr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath,maxActiveSessions:e,softMemoryLimitMb:r}),complete(n,s,a,o){we(t.paths,n,{ok:!0,protocolVersion:K,id:s.id,baseGeneration:s.baseGeneration,response:a},{nowMs:o,limits:t.limits})},reject(n,s,a,o){be(t.paths,n,{ok:!1,protocolVersion:K,id:s,error:a},a,{nowMs:o,limits:t.limits})},idleTtlMs:t.workerIdleMs??Ti,maxWorkerFailureRetries:1,retireAfterResponse:n=>n.retireRequested===!0,statusWhenWorkerAbsent:n=>({...n,state:"idle",activeSessions:0,heapUsedBytes:0,retireRequested:!1}),onBusy:t.onBusy,onFatal:t.onFatal})}function hr(t){let e=()=>({protocolVersion:Z,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return pr({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:xt,createWorker:()=>gr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,s){we(t.paths,r,{ok:!0,protocolVersion:Z,id:i.id,generation:i.generation,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){be(t.paths,r,{ok:!1,protocolVersion:Z,id:i,error:n},n,{nowMs:s,limits:t.limits})},idleTtlMs:Pi,onBusy:t.onBusy,onFatal:t.onFatal})}function pr(t){let e=t.now??Date.now,r=T(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${Ii()}`,s={...t.limits,maxBatch:1},a=null,o=t.initialStatus(),c=!1,l=p=>{c=!0,t.onFatal(p)},u=new ae({name:t.name,createWorker:t.createWorker,now:e,idleTtlMs:t.idleTtlMs,maxWorkerFailureRetries:t.maxWorkerFailureRetries,retireAfterResponse:t.retireAfterResponse,onComplete(p,m,f){let y=d(p.requestId);o=f;let x=e();try{t.complete(y.claim,y.envelope,m,x)}catch(k){if(!(k instanceof ve))throw k;try{t.reject(y.claim,y.envelope.id,k.message,x)}catch(P){if(!(P instanceof ve))throw P;xi(y.claim.path,{force:!0})}}h(y)},onReject(p,m,f){let y=d(p.requestId);f!==void 0&&(o=f),t.reject(y.claim,y.envelope.id,m,e()),h(y)},onStatus(p){o=p},onFatal:l});return{poll(){if(c||!u.canAccept())return 0;let p=gt(t.paths,{ownerId:n,nowMs:e(),limits:s,owner:i,liveness:{isProcessAlive:M,readProcessIdentity:T}})[0];if(!p)return 0;let m=p.requestId;try{let f=t.parseEnvelope(mt(p,s));if(m=f.id,f.id!==p.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(f.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(a={claim:p,envelope:f},t.onBusy?.(f.deadlineAtMs),!u.start({requestId:f.id,deadlineAtMs:f.deadlineAtMs,payload:f}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(f){let y=Mi(f);try{t.reject(p,m,y,e()),a?.claim===p&&h(a)}catch(x){l(Ei(x))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?o:t.statusWhenWorkerAbsent(o),mailbox:yt(t.paths)}},async close(p){await u.close(p)}};function d(p){let m=a;if(!m||m.envelope.id!==p)throw new Error(`${t.name} parent lost the active mailbox claim.`);return m}function h(p){a===p&&(a=null,t.onBusy?.(void 0))}}var Ci=6144;function fr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:Ci}function Wi(t){return Math.max(1,Math.floor((t??fr())*.9))}function gr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new ki(r,{workerData:e,resourceLimits:{maxOldGenerationSizeMb:t.workerHeapMb??fr()}})}function Ei(t){return t instanceof Error?t:new Error(String(t))}function Mi(t){return t instanceof Error?t.message:String(t)}var yr=2e3,_i=5e3,ji=5e3,Gi=6e4,Di=10,Fi=50,Oi=1e4;function Ni(t,e=1){return Ke(t,e,Di,Fi,Oi,8)}function qi(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function Bi(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,s=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!0};let a=Ni(n,s);return await e.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!1,delayMs:a}}function $i(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}function Ui(t){At(t.statePath,{version:1,protocolVersion:Rt,pid:v.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{},projectRoot:t.projectRoot,...t.worktreeId?{worktreeId:t.worktreeId}:{},cliVersion:t.cliVersion,startedAt:new Date(t.startedAtMs).toISOString(),heartbeatAt:new Date(t.nowMs).toISOString(),lastActivityAt:new Date(t.lastActivityAtMs).toISOString(),...t.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(t.lastActivityAtMs+t.idleTimeoutMs).toISOString()},watcher:t.watcherStatus,...t.watcherStatus.state==="idle"&&t.indexGeneration?{indexGeneration:t.indexGeneration}:{},...t.lastRefresh?{lastRefresh:t.lastRefresh}:{},...t.lastError?{lastError:t.lastError}:{},reindexActivity:t.reindexActivity,refreshRequests:t.refreshCoordinator.status(),typescriptSemantic:{...t.semanticLane.status(),...t.semanticBusyUntilMs===void 0?{}:{busyUntil:new Date(t.semanticBusyUntilMs).toISOString()}},typescriptIndex:{...t.indexLane.status(),...t.indexBusyUntilMs===void 0?{}:{busyUntil:new Date(t.indexBusyUntilMs).toISOString()}}},{durability:t.durability})}function zi(t){let e=0,r=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return({processedRequests:a})=>{let o=C();if(o-i>=ji&&(i=o,!Ft(t.worktreeLiveness))){t.requestStop();return}if(o-s>=Gi&&(s=o,Ie(t.indexMailboxPaths),Ie(t.semanticMailboxPaths)),o-n>=se&&(n=o,cr(t.projectRoot,t.cliVersion)),o-r>=_i){r=o;let c=Lt(t.activityPath);c&&t.updateObservedActivity(c.atMs,o),c?.refreshRequestedAtMs!==void 0&&c.refreshRequestedAtMs>e&&(e=c.refreshRequestedAtMs,t.refreshCoordinator.observeLegacyRequest(c.refreshRequestedAtMs,c.refreshDetail??"stale index observed by a legacy command"))}t.refreshCoordinator.poll(t.watcherStatus(),c=>{t.recordActivity(),t.requestRefresh(c)}),a>0&&(t.recordActivity(),t.persistState(!0,"visibility")),t.persistState()}}async function Ji(t){let e,r=0,i=!1,n,s;v.once("SIGINT",t.stopSignal),v.once("SIGTERM",t.stopSignal);try{t.watcher.start();let o=t.initializeFreshness();for(t.recordActivity(),t.markReady(),t.persistState(!0),e=setInterval(()=>t.persistState(),yr),e.unref?.(),o&&t.requestRefresh(o);!t.stopRequested();){let c=await Bi(r,{processIndexRequests:t.processIndexRequests,processSemanticRequests:t.processSemanticRequests,afterMailboxPoll:t.afterMailboxPoll,shouldStop:t.shouldStop,wait:t.wait});if(r=c.consecutiveIdlePolls,c.stopped)break}}catch(o){i=!0,n=o}finally{v.off("SIGINT",t.stopSignal),v.off("SIGTERM",t.stopSignal),e!==void 0&&clearInterval(e);let o=t.shutdown.begin();await t.closeLanes();let c=await o;c.state==="stopped"?t.finalizeStopped():s=t.finalizeDegraded(c.reasons)}let a=t.mailboxFatalError();if(!i&&a&&(i=!0,n=a),i&&s)throw new AggregateError([n,s],"Watch service execution and shutdown both failed.");if(i)throw n;if(s)throw s}function Vi(t){let e=hr({paths:t.semanticPaths,projectRoot:t.projectRoot,onBusy:t.onSemanticBusy,onFatal:t.onFatal}),r=t.config.indexer?.typescript,i=ur({paths:t.indexPaths,projectRoot:t.projectRoot,dbPath:t.dbPath,...r?.maxWarmSessions===void 0?{}:{maxActiveSessions:r.maxWarmSessions},...r?.workerIdleMs===void 0?{}:{workerIdleMs:r.workerIdleMs},...r?.workerSoftMemoryMb===void 0?{}:{workerSoftMemoryMb:r.workerSoftMemoryMb},...r?.workerHeapMb===void 0?{}:{workerHeapMb:r.workerHeapMb},onBusy:t.onIndexBusy,onFatal:t.onFatal});return{semanticLane:e,indexLane:i}}async function Hi(t,e,r={}){let i=Et(t,e),n=i.projectRoot,s=i.worktreeKind==="git"?Xi(n,i.worktreeId):void 0,a=Dt(n,s),o=B(n);o.watch={...o.watch,...r};let c=Q(o);if(!c.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=O(n,o),u=Y(l.cacheDir),d=T(v.pid),h=_t(u.lockPath,n,{readProcessIdentity:g=>g===v.pid?d:T(g)});if(!h.acquired)return;let p=new oe(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,c.cooldownMs)});p.initializeAfterOwnershipAcquired();let m=Date.now(),f=C(),y=m,x=f,k={state:"idle"},P,ce,W,le,de=X(l.dbPath),V=!1,Ne=!1,qe=Number.NEGATIVE_INFINITY,Be,$e,G=It(l.cacheDir),D=St(l.cacheDir);Re(G),Re(D);let Ue=Pe([D.pendingDir,D.legacyRequestDir,G.pendingDir,G.legacyRequestDir,u.refreshRequestsPath]),w=(g=!1,E=g?"durable":"visibility")=>{if(!Ne)return;let pe=Date.now(),L=C();!g&&L-qe<yr||(qe=L,Ui({statePath:u.statePath,durability:E,processIdentity:d,projectRoot:n,worktreeId:i.worktreeId,cliVersion:e,startedAtMs:m,nowMs:pe,lastActivityAtMs:y,idleTimeoutMs:c.idleTimeoutMs,watcherStatus:k,indexGeneration:P,lastRefresh:ce,lastError:W,reindexActivity:de,refreshCoordinator:p,semanticLane:ue,indexLane:he,semanticBusyUntilMs:Be,indexBusyUntilMs:$e}))},A=()=>{y=Date.now(),x=C()},Sr=g=>{A(),le??=g,W={at:new Date().toISOString(),message:g.message},w(!0,"visibility")},{semanticLane:ue,indexLane:he}=Vi({semanticPaths:G,indexPaths:D,projectRoot:n,dbPath:l.dbPath,config:o,onSemanticBusy(g){Be=g===void 0?void 0:g+5e3,w(!0,"visibility")},onIndexBusy(g){$e=g===void 0?void 0:g+5e3,w(!0,"visibility")},onFatal:Sr}),H=new ie({projectRoot:n,config:{...o,watch:c},outputDb:l.dbPath,languages:o.languages,onStatus(g){k=g,g.state!=="idle"&&(P=void 0),g.state!=="idle"&&A(),w(!0)},onReindexComplete(g,E,pe){A();let L=pe?.pendingChanges!==!1?ke(n,o,l):bt(l);return ce=L.lastRefresh,P=L.state==="fresh"?q(l.dbPath)??void 0:void 0,de=X(l.dbPath),p.completeActive(),W=void 0,w(!0),L.state==="fresh"},onReindexError(){p.failActive()},onRefreshSuppressed(g){let E=ht(l.dbPath,g);E.state==="failed"&&(W={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${E.reason}`},w(!0,"visibility")),de=X(l.dbPath)},onError(g){A(),P=void 0,W={at:new Date().toISOString(),message:g.message},w(!0)}}),ze=qi(H,{requestStop(){V=!0},closeWake(){Ue.close()}}),vr=()=>{ze.begin()},Rr=zi({worktreeLiveness:a,indexMailboxPaths:D,semanticMailboxPaths:G,projectRoot:n,cliVersion:e,activityPath:u.activityPath,refreshCoordinator:p,watcherStatus:()=>k,requestRefresh:g=>H.requestRefresh({kind:"watch-demand",detail:g},{immediate:!0}),requestStop:()=>{V=!0},recordActivity:A,updateObservedActivity(g,E){g<=y||(y=g,x=E)},persistState:w});await Ji({watcher:H,shutdown:ze,stopSignal:vr,initializeFreshness(){let g=ke(n,o,l);return ce=g.lastRefresh,P=g.state==="fresh"?q(l.dbPath)??void 0:void 0,$i(g.state)},markReady:()=>{Ne=!0},recordActivity:A,persistState:w,requestRefresh:g=>H.requestRefresh(g,{immediate:!0}),stopRequested:()=>V,processIndexRequests:()=>he.poll(),processSemanticRequests:()=>ue.poll(),afterMailboxPoll:Rr,shouldStop:()=>V||le!==void 0||jt({watcher:k,lastActivityAtMs:x,nowMs:C(),idleTimeoutMs:c.idleTimeoutMs}),wait:g=>Ue.wait(g),closeLanes:()=>Promise.all([ue.close("TypeScript semantic service stopped before completing the request."),he.close("TypeScript index service stopped before completing the request.")]).then(()=>{}),mailboxFatalError:()=>le,finalizeStopped(){mr(u.statePath,{force:!0}),mr(u.activityPath,{force:!0}),h.release()},finalizeDegraded(g){return W={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${g.join("; ")}`},w(!0),new Error(W.message)}})}function Xi(t,e){let r=rt(t);if(r.kind!=="worktree"||r.identity.worktreeId!==e)throw new Error(`Git worktree identity changed while starting the watch service for ${t}.`);return r.identity.gitDir}function Ki(t,e={report:r=>console.error(r),exit:r=>v.exit(r)}){return e.report(`watch-service: ${wt(t instanceof Error?t.message:String(t))}`),e.exit(1)}var Yi=v.argv[1]?Li(Ai(v.argv[1])).href:null;if(Yi===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Qi(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Hi(t,e,r)}catch(i){Ki(i)}}function Qi(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{Pe as createPathChangeWake,qi as createWatchServiceShutdown,Bi as runWatchServiceLoopIteration,Hi as runWatchServiceServer,$i as startupRefreshTrigger,Ki as terminateWatchServiceProcess,Ni as watchServiceLoopDelayMs};
|
|
4
4
|
//# sourceMappingURL=watch-server.js.map
|
package/package.json
CHANGED
package/dist/by-kind-XXGZGNZ6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-K63CAPS2.js";import"./chunk-MTDBHTSF.js";import"./chunk-NP4JFCLE.js";import"./chunk-5Z2H76VD.js";import"./chunk-DRENNWRG.js";import"./chunk-PRLU3I7G.js";import"./chunk-DXYMTQZ4.js";import"./chunk-FYCH2EYQ.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-XIPGCT3D.js";export{a as byKind,b as kindCounts};
|
|
2
|
-
//# sourceMappingURL=by-kind-XXGZGNZ6.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-EJHNTAEE.js";import"./chunk-7KCZELVM.js";import"./chunk-BGBBVSH4.js";import"./chunk-PJBYDCBQ.js";import"./chunk-MTDBHTSF.js";import"./chunk-ZMS4YCY7.js";import"./chunk-IQMGNIGY.js";import"./chunk-MFBVUQJZ.js";import"./chunk-5J3A6RBZ.js";import"./chunk-WRQXLNYE.js";import"./chunk-YDTK77JP.js";import"./chunk-T2PBOVDI.js";import"./chunk-4IASLUOP.js";import"./chunk-FLSVYEPL.js";import"./chunk-CTO3TRX7.js";import"./chunk-F4FNK44D.js";import"./chunk-67FK5KGV.js";import"./chunk-PAZSBPJR.js";import"./chunk-UAQQR55F.js";import"./chunk-NP4JFCLE.js";import"./chunk-5Z2H76VD.js";import"./chunk-DRENNWRG.js";import"./chunk-UXNXOMXJ.js";import"./chunk-4SZJF4GK.js";import"./chunk-DUDUIT5P.js";import"./chunk-PRLU3I7G.js";import"./chunk-DXYMTQZ4.js";import"./chunk-FYCH2EYQ.js";import"./chunk-NQXWWE6S.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-Z2KGMIL4.js";import"./chunk-XIPGCT3D.js";export{a as callGraph};
|
|
2
|
-
//# sourceMappingURL=call-graph-VGY3R4L3.js.map
|
package/dist/chunk-3XZELASU.js
DELETED
package/dist/chunk-63TFRBMB.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{h as I}from"./chunk-GSHTVE56.js";import{a as y,e as g}from"./chunk-7Z4GMCHM.js";import{z as v}from"./chunk-C7WSQA6A.js";import{c as b,i as D,j as _,r as F,t as p,w as E,y as x}from"./chunk-JSHDCVUM.js";import{spawnSync as O}from"child_process";import{createHash as U}from"crypto";import{existsSync as k}from"fs";import{dirname as L,join as T}from"path";import{fileURLToPath as j}from"url";var N=b("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),M=E({kind:"consumer-file-usage",invalidation:x("consumer-file-usage"),serialize:Q,deserialize:W});function Le(e,n){return{forDefinitions(r,i){return V(e,n,r,i)}}}function Me(e){let n=new Map;for(let[r,i]of e)n.set(r,new Set(i.files.map(t=>t.file)));return n}function Re(e,n,r){return w(e,n,r).partition}function V(e,n,r,i){let t=h(r.length),s=F()?_(e):null,a=s?B(r,i,s):void 0,o=a?{workIdentity:a,workOutcome:"computed"}:{};return p("consumer-evidence.product",()=>{let l=p("consumer-evidence.provenance",()=>z(e,n,r,i),()=>({...o,definitions:r.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),u=new Map;t={...t,...l.counters};let c=Y(r,l.sources);return p("consumer-evidence.classify",()=>{let f=q(e,r,l.sources,c);for(let d of r){let m=f.get(d.symbolId)??H();t.realFiles+=m.partition.realConsumers.length,t.reexportOnlyFiles+=m.partition.barrelConsumers,t.importOnlyFiles+=m.partition.importOnlyConsumers,u.set(d.symbolId,{definition:d,files:m.files,...m.partition})}},()=>({...o,...c,realFiles:t.realFiles,reexportOnlyFiles:t.reexportOnlyFiles,importOnlyFiles:t.importOnlyFiles})),u},()=>({...o,...t}))}function B(e,n,r){let i=U("sha256").update("consumer-evidence-v1\0").update(r).update("\0").update(n.semantic?"semantic\0":"indexed\0").update(n.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let t of e.map(s=>s.symbol).sort())i.update("\0").update(t);return i.digest("hex").slice(0,24)}function h(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function z(e,n,r,i){let t=h(r.length),s=new Map;return S(s,t,"indexed",n.crossFileCallerMap(r,{semantic:!1})),i.semantic&&S(s,t,"semantic",I(e,r)),i.sourceFallback!==!1&&S(s,t,"source-fallback",n.sourceFallbackCallerFiles(r)),t.totalFiles=[...s.values()].reduce((a,o)=>a+o.size,0),{sources:s,counters:t}}function Y(e,n){return{definitions:e.length,consumerFiles:[...n.values()].reduce((r,i)=>r+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function S(e,n,r,i){let t=0;for(let[s,a]of i){let o=e.get(s);o||(o=new Map,e.set(s,o));for(let l of a){t++;let u=o.get(l)??new Set;u.add(r),o.set(l,u)}}r==="indexed"?n.indexedFiles+=t:r==="semantic"?n.semanticFiles+=t:n.fallbackFiles+=t}function q(e,n,r,i){let t=re(e,n,r,i);return t||$(e,n,r)}function $(e,n,r){let i=new Map;for(let t of n){let s=r.get(t.symbolId)??new Map;i.set(t.symbolId,w(e,t,[...s.keys()],s))}return i}function w(e,n,r,i=new Map){let t=[],s=0,a=0,o=g(n.symbol),l=[];for(let u of r){let c;X(e,u,n.relativePath,o)?(s++,c="reexport-only"):J(e,u,o)?(a++,c="import-only"):(t.push(u),c="real"),l.push({file:u,sources:[...i.get(u)??[]],classification:c})}return{partition:{realConsumers:t,barrelConsumers:s,importOnlyConsumers:a},files:l}}function H(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function J(e,n,r){if(!r)return!1;let i=v(n);if(!i)return!1;let t=N.get(e,n,()=>A(e,n,i));return t.importedLeaves.has(r)&&!t.usedLeaves.has(r)}function A(e,n,r){let i=y(e).forFile(n,{text:!0,ast:!0}),t=i.text;if(!t)return G();let s=D(e,n,t),a=M.read(e,n,s);if(a)return a;let o=K(i.ast,r);return M.write(e,n,s,o),o}function K(e,n){let r=new Set,i=new Set;if(!e)return{importedLeaves:r,usedLeaves:i};let t=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),s=(a,o)=>{let l=o||t.has(a.type);(a.type==="identifier"||a.type==="type_identifier"||a.type==="property_identifier"||a.type==="field_identifier")&&(l?r.add(a.text):i.add(a.text));for(let u of a.children)s(u,l)};return s(e.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function G(){return{importedLeaves:new Set,usedLeaves:new Set}}function Q(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function W(e){try{let n=JSON.parse(e);return!Array.isArray(n.importedLeaves)||!Array.isArray(n.usedLeaves)?null:{importedLeaves:new Set(n.importedLeaves.filter(r=>typeof r=="string")),usedLeaves:new Set(n.usedLeaves.filter(r=>typeof r=="string"))}}catch{return null}}function X(e,n,r,i){if(!i)return!1;let t=y(e).forFile(n,{lines:!0,reexports:!0}),s=t.lines??[];if(s.length===0)return!1;let a=t.reexports??[];return P(s,a,i)}function P(e,n,r){if(e.length===0||n.length===0)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`\\b${i}\\b`),s=0;for(let a=0;a<e.length;a++){if(!t.test(e[a]??""))continue;if(s++,!n.find(l=>l.startLine<=a&&a<=l.endLine))return!1}return s>0}var Z="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY",ee="SCIP_QUERY_NATIVE_KERNELS_BIN",ne="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",R=1e3,ie=5e3,te=64*1024*1024,C;function re(e,n,r,i){let t=process.env[Z]?.toLowerCase();if(t!=="1"&&t!=="true")return i.nativeReason=t==="0"||t==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<fe())return i.nativeReason="below-threshold",null;let s=me();if(!s)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let a=se(e,n,r),o=O(s,["consumer-classify"],{input:JSON.stringify(a),encoding:"utf8",timeout:ie,maxBuffer:te});if(o.status!==0||o.error)return i.nativeReason=o.error?`spawn-error:${o.error.message}`:`exit-${o.status??"null"}`,null;try{let l=JSON.parse(o.stdout),u=ae(l,n);return u?(i.nativeUsed=!0,i.nativeReason="used",u):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function se(e,n,r){let i=new Map,t=[];for(let o of n){let l=g(o.symbol),c=[...(r.get(o.symbolId)??new Map).entries()].map(([f,d])=>{let m=i.get(f)??new Set;return l&&m.add(l),i.set(f,m),{file:f,sources:[...d]}});t.push({symbol_id:o.symbolId,leaf:l,consumer_files:c})}let s={},a={};for(let[o,l]of i){let u=v(o);if(u){let f=N.get(e,o,()=>A(e,o,u));s[o]={imported_leaves:[...f.importedLeaves],used_leaves:[...f.usedLeaves]}}let c=oe(e,o,l);c.length>0&&(a[o]=c)}return{definitions:t,file_usages:s,reexport_only_leaves:a}}function oe(e,n,r){if(r.size===0)return[];let i=y(e).forFile(n,{lines:!0,reexports:!0}),t=i.lines??[],s=i.reexports??[];return t.length===0||s.length===0?[]:[...r].filter(a=>P(t,s,a))}function ae(e,n){if(!Array.isArray(e.entries)||e.entries.length!==n.length)return null;let r=new Set(n.map(t=>t.symbolId)),i=new Map;for(let t of e.entries){let s=le(t);if(!s||!r.has(s.symbol_id))return null;i.set(s.symbol_id,{partition:{realConsumers:s.real_consumers,barrelConsumers:s.barrel_consumers,importOnlyConsumers:s.import_only_consumers},files:s.files})}for(let t of r)if(!i.has(t))return null;return i}function le(e){if(!e||typeof e!="object")return null;let n=e;if(typeof n.symbol_id!="number"||!Array.isArray(n.real_consumers)||typeof n.barrel_consumers!="number"||typeof n.import_only_consumers!="number"||!Array.isArray(n.files)||!n.real_consumers.every(i=>typeof i=="string"))return null;let r=[];for(let i of n.files){if(!i||typeof i!="object")return null;let t=i;if(typeof t.file!="string"||!Array.isArray(t.sources)||!t.sources.every(ue)||!ce(t.classification))return null;r.push({file:t.file,sources:t.sources,classification:t.classification})}return{symbol_id:n.symbol_id,real_consumers:n.real_consumers,barrel_consumers:n.barrel_consumers,import_only_consumers:n.import_only_consumers,files:r}}function ue(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function ce(e){return e==="real"||e==="reexport-only"||e==="import-only"}function fe(){let e=process.env[ne];if(!e)return R;let n=Number(e);return Number.isFinite(n)&&n>=0?n:R}function me(){if(C!==void 0)return C;let e=process.env[ee],n=process.platform==="win32"?"scip-query-kernels.exe":"scip-query-kernels";return C=[...e?[e]:[],...de().map(i=>T(i,"target","release",n))].find(i=>k(i))??null,C}function de(){let e=new Set,n=L(j(import.meta.url));for(let r=0;r<5;r++)e.add(n),n=L(n);return[...e]}export{Le as a,Me as b,Re as c,J as d};
|
|
2
|
-
//# sourceMappingURL=chunk-63TFRBMB.js.map
|
package/dist/chunk-6LS3IG2I.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{A as Q,B as Qe,C as D,D as Z,E as Ze,F as be,G as et,H as ie,J as tt,e as qe,f as Ve,g as P,h as ze,i as We,j as He,k as q,l as Ke,m as K,n as Je,o as Xe,p as Ge,q as F,r as J,s as L,t as ge,u as Se,v as S,w as he,x as Ye,y as xe,z as Y}from"./chunk-C7WSQA6A.js";import{a as Ue,c as U,f as oe,i as H,p as ye,w as X,y as G,z as A}from"./chunk-JSHDCVUM.js";import{c as W,ua as $e,va as Be}from"./chunk-WEXQYJY3.js";function O(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vt(e){return e.replace(/'''[\s\S]*?'''/g,k).replace(/"""[\s\S]*?"""/g,k).replace(/#.*$/gm,k).replace(/\/\/.*$/gm,k).replace(/\/\*[\s\S]*?\*\//g,k).replace(/`(?:\\[\s\S]|[^`])*`/g,k).replace(/'(?:\\.|[^'\\\r\n])*'/g,k).replace(/"(?:\\.|[^"\\\r\n])*"/g,k)}function ns(e){return rt(e,{maskStrings:!1})}function ss(e){return rt(e,{maskStrings:!0})}function rt(e,r){let t="",n=0,s=e.length;for(;n<s;){if(e[n]==="/"&&e[n+1]==="/"){let i=e.indexOf(`
|
|
2
|
-
`,n),a=i===-1?s:i;t+=Ne(e,n,a),n=a;continue}if(e[n]==="/"&&e[n+1]==="*"){let i=e.indexOf("*/",n+2),a=i===-1?s:i+2;t+=Ne(e,n,a),n=a;continue}let o=e[n];if(o==="`"||o==="'"||o==='"'){let i=o,a=n+1;for(;a<s;){if(e[a]==="\\"){a+=2;continue}if(e[a]===i){a+=1;break}if(i!=="`"&&e[a]===`
|
|
3
|
-
`)break;a+=1}t+=r.maskStrings?Ne(e,n,a):e.slice(n,a),n=a;continue}t+=o,n+=1}return t}function Ne(e,r,t){let n="";for(let s=r;s<t;s+=1)n+=e[s]===`
|
|
4
|
-
`?`
|
|
5
|
-
`:" ";return n}function k(e){return e.replace(/[^\r\n]/g," ")}var os=oe("stripped-lines",{clearGroups:["whole-project","source-file"]});Ue({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{ae=null,ee=""},clearFile:()=>{ae=null,ee=""}});var ae=null,ee="";function Mt(e){return ae===e||(ae=e,ee=vt(e)),ee}function w(e,r,t){let n=Mt(e);return`${n.slice(0,r)}${" ".repeat(t-r)}${n.slice(t)}`}function x(e,r){return new RegExp(`\\b${O(r)}\\b`,"m").test(e)}function V(e,r){let t=new Set,n=new RegExp(`\\b${O(r)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let s of e.matchAll(n)){let o=s[1];o&&t.add(o)}return[...t]}function Ie(e){let r=0;for(let t of e)t==="("&&(r+=1),t===")"&&(r-=1);return r}function Ce(e,r){r(e);for(let t of e.namedChildren)Ce(t,r)}function $t(e,r,t){let n=null;return Ce(e,s=>{!/(?:function|method|lambda)/u.test(s.type)&&s.type!=="arrow_function"||s.startPosition.row>r||s.endPosition.row<t||(!n||s.endIndex-s.startIndex<n.endIndex-n.startIndex)&&(n=s)}),n}function nt(e,r,t){if(e.startPosition.row>r||e.endPosition.row<t)return null;for(let n of e.namedChildren){let s=nt(n,r,t);if(s)return s}return e}function Bt(e){let r=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(r.type)&&r.namedChildren.length>0;)r=r.namedChildren[0];return r}function _e(e){if(e.type==="identifier")return e.text;let r=e.childForFieldName("name")??e.childForFieldName("pattern");return r?_e(r):e.namedChildren.find(t=>t.type==="identifier")?.text??null}function Ut(e){return(e.childForFieldName("parameters")??e.namedChildren.find(t=>/parameters/u.test(t.type)))?.namedChildren.map(_e)??[]}var qt=new Set(["identifier","type_identifier","field_identifier"]),Vt=new Set(["identifier"]),zt=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Wt=new Set(["rust","python"]),Ht=/\{([^{}]*)\}/g,Kt=/\b([A-Za-z_][\w]*)\b/g;function st(e,r){return Jt(r).has(e.type)}function ot(e,r){return Wt.has(r)&&e.type==="string_content"}function Pe(e){let r=0;for(let n of e.values()){let s=n[n.length-1];s!==void 0&&s>r&&(r=s)}let t=new Array(r+1);for(let n=0;n<=r;n+=1)t[n]=new Set;for(let[n,s]of e)for(let o of s)t[o].add(n);return t}function Jt(e){return e==="rust"?qt:e==="python"?Vt:zt}function it(e,r){let t=e.startPosition.row;for(let n of e.text.matchAll(Ht)){let s=n[1]??"";for(let o of s.matchAll(Kt))o[1]&&r(o[1],t)}}var Xt=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],Gt=/^#!?\[\s*serde\s*\(/,Yt=/^#!?\[\s*schemars\s*\(/,Qt=/^#!?\[\s*validate\s*\(/,Zt=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function at(e,r,t){if(r!=="typescript"&&r!=="tsx"&&r!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let s=be(n);if(!s||!Zt.has(s))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let i=o.namedChild(0);if(!i||i.type!=="string")return;let a=i.namedChildren.find(c=>c.type==="string_fragment");a&&t.add(a.text)}function ct(e,r){let t=Gt.test(e),n=Yt.test(e),s=Qt.test(e);if(!(!t&&!n&&!s))for(let o of Xt){o.lastIndex=0;let i;for(;(i=o.exec(e))!==null;){let a=i[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&r.add(c)}}}function lt(e,r){let t=new Map,n=(i,a)=>{if(i===a)return;let c=t.get(i);c||(c=new Set,t.set(i,c)),c.add(a)},s=r==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(i,a)=>{let c=l=>{s.has(l.type)&&l.text!==a&&n(l.text,a);for(let p of l.children)c(p)};for(let l of i.children)c(l)};if(r==="rust")for(let i of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=i.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=i.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),i.type==="type_item"&&o(i,a)}else if(r==="python")for(let i of e.rootNode.descendantsOfType("class_definition")){let a=i.namedChildren.find(p=>p.type==="identifier")?.text;if(!a)continue;let c=i.childForFieldName("superclasses");c&&o(c,a);let l=i.namedChildren.find(p=>p.type==="block");if(l)for(let p of l.descendantsOfType("type"))for(let u of p.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let i of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=i.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(i,a)}return t}var er=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),Te=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function pt(e){let r=[],t=[],n=[],s=new Map,o=[],i=0,a=0,c=(l,p)=>{let u=s.get(l);if(!u){s.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)};for(;a<e.length;){let l=e[a];if(l===`
|
|
6
|
-
`){i+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=le(e,a);continue}if(l==='"'){let h=re(e,a,i);i=h.line,a=h.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:i,endLine:i,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let h=o.pop();h&&(h.endLine=i,tr(h,{callables:r,callSites:t,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(h)),a+=1;continue}if(Re(l)){a+=1;continue}let p=i,u=a;for(;a<e.length&&!Ee(e[a]);)a+=1;let m=e.slice(u,a);if(!m)continue;let f={text:m,line:p};rr(o[o.length-1],f),c(N(m),p)}return{language:"clojure",callables:r,callSites:t,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:s,identifiersByLine:ar(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function tr(e,r){if(e.kind!=="("||e.headTokens.length===0)return;let t=e.headTokens[0],n=N(t.text),s=er.get(t.text);if(s){let i=e.headTokens[1];if(i){let a=N(i.text);r.recordIdentifier(a,i.line),r.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:i.line,isLiteralPassthrough:!1,clojureKind:s})}}if(nr(e,r),!n||Te.has(t.text)||Te.has(n)||n.startsWith(":"))return;let o=ir(t.text);r.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:t.line})}function rr(e,r){e&&(e.headTokens.length<2&&e.headTokens.push(r),e.tokens.length<200&&e.tokens.push(r))}function nr(e,r){let t=N(e.tokens[0]?.text??"");if(t==="defprotocol"){let n=N(e.tokens[1]?.text??"");if(!n)return;for(let s of ce(e))te(r,n,"protocol",s,"protocol-method");return}if(t==="defrecord"||t==="deftype"){let n=N(e.tokens[1]?.text??"");if(!n)return;let s=t==="defrecord"?"record":"type",o=t==="defrecord"?"record-method":"type-method";for(let i of ce(e))te(r,n,s,i,o);return}if(t==="extend-type"){let n=N(e.tokens[1]?.text??"");if(!n)return;for(let s of ce(e))te(r,n,"extension",s,"extension-method");return}if(t==="extend-protocol"){let n=N(e.tokens[1]?.text??"");for(let s of ce(e)){n&&te(r,n,"extension",s,"extension-method");let o=or(e,s.startLine);o&&o!==n&&te(r,o,"extension",s,"extension-method")}}}function ce(e){return e.children.filter(sr)}function sr(e){if(e.kind!=="(")return!1;let r=N(e.tokens[0]?.text??"");return!!(r&&!Te.has(r)&&!r.startsWith(":"))}function te(e,r,t,n,s){let o=n.tokens[0],i=N(o?.text??"");!o||!i||(e.recordIdentifier(i,o.line),e.clojureMembers.push({ownerName:r,ownerKind:t,memberName:i,memberKind:s,startLine:n.startLine,endLine:n.endLine}))}function or(e,r){let t=null;for(let n=2;n<e.tokens.length;n+=1){let s=e.tokens[n];if(s.line>r)break;let o=N(s.text);o&&!o.startsWith(":")&&(t=o)}return t}function N(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function ir(e){let r=e.replace(/^#?['`~@]+/,""),t=r.lastIndexOf("/"),n=N(r);if(t<=0)return{leaf:n,text:r};let s=r.slice(0,t);return{leaf:n,qualifier:s,text:r}}function le(e,r){let t=r;for(;t<e.length&&e[t]!==`
|
|
7
|
-
`;)t+=1;return t}function re(e,r,t){let n=r+1,s=t;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
|
|
8
|
-
`&&(s+=1),n+=1,o==='"')break}return{index:n,line:s}}function Re(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function Ee(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function ar(e){let r=[];for(let[t,n]of e)for(let s of n)r[s]??=new Set,r[s].add(t);return r}var ut=6,cr=oe("source-facts",{clearGroups:["whole-project","source-file"]}),Fe=X({kind:"source-facts",invalidation:G("source-facts"),serialize:mr,deserialize:fr});function R(e,r){return lr(e,r).facts}function lr(e,r){let t=A(e,r);if(!t)return{facts:null};let n=pr(e,r,t);return n?cr.get(e,r,t,()=>ur(e,r,n,t)):{facts:null}}function pr(e,r,t){return Q(r)?Qe(e,r,t)?.language??null:Y(r)}function ur(e,r,t,n){let s=H(e,r,n),o=Fe.read(e,r,s);if(o&&o.language===t)return{facts:o};if(t==="clojure"){let c=pt(n);return Fe.write(e,r,s,c),{facts:c}}let i=D(e,r);if(!i)return{facts:null,unavailable:{language:t,reason:"parser-unavailable"}};let a=hr(i,t);return Fe.write(e,r,s,a),{facts:a}}function mr(e){let r={version:ut,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([t,n])=>[t,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(r)}function fr(e){try{let r=JSON.parse(e);if(r.version!==ut||r.language==="clojure"&&(r.clojureMembers===void 0||r.callSites.some(n=>n.calleeText===void 0)))return null;let t=new Map(r.identifierLineMap);return{language:r.language,callables:r.callables,callSites:r.callSites,clojureMembers:r.clojureMembers??[],typeContainerMap:new Map(r.typeContainerMap.map(([n,s])=>[n,new Set(s)])),identifierLineMap:t,identifiersByLine:Pe(t),fileIdentifiers:new Set(t.keys()),rustAttrReferencedNames:new Set(r.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(r.crossLanguageDispatchNames)}}catch{return null}}function dr(e,r,t,n){let s=R(e,r);return s?Sr(s,t,n)?.isLiteralPassthrough??!0:!0}function gr(e,r){return r.relativePath.includes(".clj-kondo/hooks/")?!0:R(e,r.relativePath)?.callables.find(n=>n.startLine===r.startLine&&n.endLine===r.endLine)?.clojureKind==="macro"}function Sr(e,r,t){return e.callables.find(n=>n.startLine===r&&n.endLine===t)??null}function hr(e,r){let t=[],n=[],s=new Set,o=new Set,i=new Map,a=(l,p)=>{let u=i.get(l);if(!u){i.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)},c=l=>{let p=ie(l,r);p&&t.push(p);let u=Ze(l,r);u&&n.push(u),at(l,r,o),r==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&ct(l.text,s),st(l,r)&&a(l.text,l.startPosition.row),ot(l,r)&&it(l,a);for(let m of l.children)c(m)};return c(e.rootNode),{language:r,callables:t,callSites:n,clojureMembers:[],typeContainerMap:lt(e,r),identifierLineMap:i,identifiersByLine:Pe(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:s,crossLanguageDispatchNames:o}}var mt=new Set(["rust","typescript","tsx","javascript","python","clojure"]),xr=new Set(["rust","typescript","tsx","javascript","python"]);function yr(e,r){let t=R(e,r);return!t||!mt.has(t.language)?null:t.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function br(e,r){if(!xr.has(r))return null;let t=[];for(let n of e.descendantsOfType([...et(r)])){let s=ie(n,r);s&&t.push({name:s.name,startLine:s.startLine,endLine:s.endLine})}return t}function Nr(e,r){let t=R(e,r);return!t||!mt.has(t.language)?null:t.callSites}function Ir(e,r){return R(e,r)?.typeContainerMap??new Map}function Cr(e,r,t={}){let n=R(e,r);if(!n)return[];let s=[];if(t.includeCrossLanguageDispatchNames)for(let o of n.crossLanguageDispatchNames)s.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(t.includeRustAttributeNames&&n.language==="rust")for(let o of n.rustAttrReferencedNames)s.push({name:o,kind:"rust-attribute",occurrences:1});return s}import{basename as ft}from"path";var _r=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function y(e){let r=[],t=0,n=0;for(let s=0;s<e.length;s++){let o=e[s];(o==="{"||o==="["||o==="(")&&t++,(o==="}"||o==="]"||o===")")&&t--,o===","&&t===0&&(r.push(e.slice(n,s)),n=s+1)}return r.push(e.slice(n)),r}function b(e,r){for(let t of e.namedChildren)if(t.type===r)return t;return null}function g(e,r){let t=new Set,n=(s,o)=>{let i=o||r.has(s.type);!i&&_r.has(s.type)&&t.add(s.text);for(let a of s.children)n(a,i)};return n(e.rootNode,!1),t}function T(e,r,t,n,s,o,i){return{importedName:s,localName:o,sourcePath:i??S(e,n,Ge(r)),kind:"named",used:x(t,o),usedMembers:[]}}function d(e,r,t,n,s="named",o={}){return{importedName:e,localName:r,sourcePath:t,kind:s,used:n.has(r),usedMembers:[],isTypeOnly:o.isTypeOnly}}function E(e,r,t,n,s="named",o=[],i={}){return{importedName:e,localName:r,sourcePath:t,kind:s,used:n,usedMembers:o,isTypeOnly:i.isTypeOnly}}function v(e,r){return{importedName:e,localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]}}function M(e,r,t={}){return{importedName:e,localName:t.localName??null,sourcePath:r,kind:"namespace",used:t.used??!0,usedMembers:t.usedMembers??[],isTypeOnly:t.isTypeOnly}}function I(e,r,t){let n=[];for(let s of e.matchAll(r)){let o=s[0];if(!o||typeof s.index!="number")continue;let i=w(e,s.index,s.index+o.length);for(let a of t(s,i))n.push(a)}return n}function C(e,r,t,n,s){let o=Z(e,r,s)?.tree??null;if(o){let i=t(o);if(i)return i}return n()}function pe(e,r,t,n,s){let o=Z(e,r,s)?.tree??null,i=Y(r),a=i?t[i]:void 0;return o&&a?a(o):n()}function dt(e,r,t){return C(e,r,n=>Tr(e,r,n),()=>Pr(e,r,t),t)}function Pr(e,r,t){return I(t,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,s)=>{let o=n[1]?.trim();if(!o)return[];let i=ft(o).replace(/\.[^.]+$/,"");return[E(o,i,Se(e,r,o),x(s,i))]})}function Tr(e,r,t){let n=g(t,new Set(["preproc_include"])),s=[];for(let o of t.rootNode.descendantsOfType("preproc_include")){let i=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){i=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){i=c.namedChildren.find(p=>p.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!i)continue;let a=ft(i).replace(/\.[^.]+$/,"");s.push(d(i,a,Se(e,r,i),n))}return s}var Rr=new Set([":require",":require-macros",":use"]),ke=String.raw`A-Za-z0-9_$*+!?.<>=-`;function St(e,r,t){let n=Mr(t);if(!n)return[];let s=vr(t,n.start,n.end),o=[];for(let i of n.children.slice(2)){if(i.type!=="list"||i.children.length===0)continue;let a=_(i.children[0]);if(a){if(Rr.has(a)){for(let c of Lr(i.children.slice(1)))o.push(...Fr(e,c,s));continue}if(a===":import")for(let c of kr(i.children.slice(1)))o.push(c)}}return o}function Er(e){return e.type==="list"&&_(e.children[0])==="ns"}function Fr(e,r,t){let n=Ye(e,r.namespace),s=r.alias??r.namespace,o=jr(t,s),i=[{importedName:r.namespace,localName:s,sourcePath:n,kind:"namespace",used:r.refers.length>0||r.referAll||o.length>0||Dr(t,r.namespace),usedMembers:o}];r.referAll&&i.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of r.refers)i.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Or(t,a),usedMembers:[]});return i}function Lr(e){return e.flatMap(r=>ue(r,null))}function ue(e,r){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:Ae(r,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&_(e.children[0])===null?e.children.flatMap(t=>ue(t,r)):Ar(e,r);if(e.type==="list"&&e.children.length>0){let t=_(e.children[0]);return t?!t||t.startsWith(":")?[]:e.children.slice(1).flatMap(n=>ue(n,Ae(r,t))):e.children.flatMap(n=>ue(n,r))}return[]}function Ar(e,r){let t=_(e.children[0]);if(!t||t.startsWith(":"))return[];let n={namespace:Ae(r,t),alias:null,refers:[],referAll:!1};for(let s=1;s<e.children.length;s+=1){let o=_(e.children[s]);if(!o?.startsWith(":"))continue;let i=e.children[s+1];if((o===":as"||o===":as-alias")&&i){n.alias=_(i),s+=1;continue}o===":refer"&&i&&(_(i)===":all"?n.referAll=!0:(i.type==="vector"||i.type==="list")&&n.refers.push(...i.children.map(_).filter(wr)),s+=1)}return[n]}function kr(e){let r=[];for(let t of e){if(t.type==="atom"){let s=t.text.split(".").pop()??t.text;r.push(E(s,s,null,!0));continue}if(t.type!=="vector")continue;let n=_(t.children[0]);if(n)for(let s of t.children.slice(1)){let o=_(s);o&&r.push(E(`${n}.${o}`,o,null,!0))}}return r}function Ae(e,r){return e?`${e}.${r}`:r}function _(e){return e?.type==="atom"?e.text:null}function wr(e){return!!(e&&!e.startsWith(":"))}function jr(e,r){let t=new Set,n=new RegExp(`${we()}${O(r)}\\s*/\\s*([${ke}]+)`,"g");for(let s of e.matchAll(n)){let o=s[1];o&&t.add(o)}return[...t]}function Dr(e,r){return new RegExp(`${we()}${O(r)}\\s*/`,"m").test(e)}function Or(e,r){return new RegExp(`${we()}${O(r)}(?![${ke}])`,"m").test(e)}function we(){return`(?<![${ke}])`}function vr(e,r,t){let n="",s=0;for(;s<e.length;){if(s>=r&&s<t){n+=e[s]===`
|
|
9
|
-
`?`
|
|
10
|
-
`:" ",s+=1;continue}let o=e[s];if(o===";"){let i=le(e,s);n+=gt(e.slice(s,i)),s=i;continue}if(o==='"'){let i=re(e,s,0).index;n+=gt(e.slice(s,i)),s=i;continue}n+=o,s+=1}return n}function Mr(e){let r=0;for(;r<e.length&&(r=je(e,r),!(r>=e.length));){let t=me(e,r);if(!t){r+=1;continue}if(Er(t.form))return t.form;r=t.index}return null}function me(e,r){let t=je(e,r);if(e.startsWith("#?@",t)||e.startsWith("#?",t))return $r(e,t);if(e.startsWith("#_",t)){let s=me(e,t+2);return s?{form:{type:"atom",text:"",start:t,end:s.index},index:s.index}:null}for(;Re(e[t]);)t+=1;let n=e[t];return n?n==="("?Le(e,t,"list",")"):n==="["?Le(e,t,"vector","]"):n==="{"?Le(e,t,"map","}"):n==='"'?{form:{type:"atom",text:"",start:t,end:re(e,t,0).index},index:re(e,t,0).index}:Ur(e,t):null}function $r(e,r){let t=e.startsWith("#?@",r)?3:2,n=me(e,r+t);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?Br(n.form.children):[],start:r,end:n.index},index:n.index}:null}function Br(e){let r=[];for(let t=0;t<e.length;t+=2){let n=_(e[t]),s=e[t+1];n?.startsWith(":")&&s&&r.push(s)}return r}function Le(e,r,t,n){let s=[],o=r+1;for(;o<e.length;){if(o=je(e,o),e[o]===n)return{form:{type:t,children:s,start:r,end:o+1},index:o+1};let i=me(e,o);if(!i){o+=1;continue}i.form.type==="atom"&&i.form.text===""||s.push(i.form),o=i.index}return{form:{type:t,children:s,start:r,end:e.length},index:e.length}}function Ur(e,r){let t=r;for(;t<e.length&&!Ee(e[t]);)t+=1;return{form:{type:"atom",text:e.slice(r,t),start:r,end:t},index:t}}function je(e,r){let t=r;for(;t<e.length;){let n=e[t];if(/\s|,/.test(n)){t+=1;continue}if(n===";"){t=le(e,t);continue}break}return t}function gt(e){return e.replace(/[^\r\n]/g," ")}function ht(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=s[1]?.trim(),i=s[2]?.trim()??null,a=s[0];if(!o||!a||typeof s.index!="number")continue;let c=w(t,s.index,s.index+a.length);n.push({importedName:o,localName:i,sourcePath:he(e,r,o),kind:i?"namespace":"side-effect",used:i?x(c,i):!0,usedMembers:i?V(c,i):[]})}return n}function xt(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=s[1]?.trim();o&&n.push({specifier:o,sourcePath:he(e,r,o)})}return n}function yt(e,r,t){return pe(e,r,{csharp:n=>Vr(e,r,n),vb:n=>qr(e,r,n)},()=>{let n=Xe(r)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return I(t,n,(s,o)=>{let i=s[1]?.trim();if(!i)return[];let[a,c]=i.split(/\s*=\s*/),l=!!c,p=(l?c:a)?.trim()??i,u=p.split(".").pop()??p,m=l?a?.trim()??u:u;return[T(e,r,o,p,u,m,S(e,p,q))]})},t)}function qr(e,r,t){let n=g(t,new Set(["imports_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("imports_statement")){let i=o.namedChildren.filter(m=>m.type==="namespace_name");if(i.length===0)continue;let a=i[i.length-1],c=i.length>1?i[0]:null,l=a.text,p=l.split(".").pop()??l,u=c?.text??p;s.push(d(p,u,S(e,l,q),n,c?"namespace":"named"))}return s}function Vr(e,r,t){let n=g(t,new Set(["using_directive"])),s=[];for(let o of t.rootNode.descendantsOfType("using_directive")){let i=o.namedChildren;if(i.length===0)continue;let a=null,c;i.length>=2&&i[0].type==="identifier"&&(i[1].type==="qualified_name"||i[1].type==="identifier")?(a=i[0],c=i[1]):c=i[i.length-1];let l=c.text,p=l.split(".").pop()??l,u=a?.text??p;s.push(d(p,u,S(e,l,q),n,a?"namespace":"named"))}return s}var zr=U("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function bt(e,r){return zr.get(e,r,()=>{let t=new Set,n=A(e,r);if(!n)return t;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,i=>i.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,i=>i.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\r\n]/g," "));for(let i of o.matchAll(/[A-Za-z_$][\w$]*/g))t.add(i[0]);return t})}function De(e,r,t){return C(e,r,n=>Hr(e,r,n),()=>Wr(e,r,t),t)}function Wr(e,r,t){return nn(t).flatMap(n=>sn(e,r,n.clause,n.specifier,n.start,n.end,t))}function Hr(e,r,t){let n=Kr(e,r,t),s=[];for(let o of t.rootNode.descendantsOfType("import_statement"))s.push(...Jr(e,r,t,o,n));return s}function Kr(e,r,t){let n=g(t,new Set(["import_statement"]));if(Q(r))for(let s of bt(e,r))n.add(s);return n}function Jr(e,r,t,n,s){let o=Zr(n);if(!o)return[];let i=F(e,r,o),a=b(n,"import_clause");return a?Xr(t,a,i,s,en(n.text)):[v("*",i)]}function Xr(e,r,t,n,s){let o=[];for(let i of r.namedChildren)if(i.type==="identifier")o.push(Gr(i.text,t,n,s));else if(i.type==="namespace_import"){let a=Yr(e,i,t,n,s);a&&o.push(a)}else i.type==="named_imports"&&o.push(...Qr(i,t,n,s));return o}function Gr(e,r,t,n){return d("default",e,r,t,"default",{isTypeOnly:n})}function Yr(e,r,t,n,s){let i=b(r,"identifier")?.text??"";if(!i)return null;let a=rn(e,i);return M("*",t,{localName:i,usedMembers:a,isTypeOnly:s,used:a.length>0||n.has(i)})}function Qr(e,r,t,n){let s=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let i=o.namedChild(0),a=o.namedChild(1);if(!i)continue;let c=i.text,l=a?.text??c;s.push(d(c,l,r,t,"named",{isTypeOnly:n||tn(o.text)}))}return s}function Zr(e){let r=b(e,"string");if(!r)return null;let t=b(r,"string_fragment");return t?t.text:null}function en(e){return/^\s*import\s+type\b/.test(e)}function tn(e){return/^\s*type\b/.test(e.trim())}function rn(e,r){let t=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let s=n.namedChild(0),o=n.namedChild(1);!s||!o||s.type!=="identifier"||s.text!==r||(o.type==="property_identifier"||o.type==="identifier")&&t.add(o.text)}return[...t]}function nn(e){let r=[],t=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(t)){let o=s[0],i=s[1],a=s[2];!o||!a||typeof s.index!="number"||r.push({clause:i,specifier:a,start:s.index,end:s.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(n)){let o=s[0],i=s[1];!o||!i||typeof s.index!="number"||r.push({clause:null,specifier:i,start:s.index,end:s.index+o.length})}return r.sort((s,o)=>s.start-o.start)}function sn(e,r,t,n,s,o,i){let a=F(e,r,n),c=w(i,s,o);return t?on(t).map(p=>({...p,sourcePath:a})).map(p=>{if(p.kind==="namespace"){let u=V(c,p.localName);return M(p.importedName,p.sourcePath,{localName:p.localName,usedMembers:u,used:u.length>0||x(c,p.localName),isTypeOnly:p.isTypeOnly})}return p.kind==="side-effect"?v(p.importedName,p.sourcePath):E(p.importedName,p.localName??"",p.sourcePath,p.localName?x(c,p.localName):!1,p.kind,[],{isTypeOnly:p.isTypeOnly})}):[v("*",a)]}function on(e){let r=e.trim(),t=/^type\b/.test(r),n=r.replace(/^type\s+/,""),[s,o]=an(n),i=[];return s&&i.push(...Nt(s,t)),o&&i.push(...Nt(o,t)),i}function Nt(e,r){let t=e.trim();if(!t)return[];if(t.startsWith("{")){let n=t.slice(1,-1).trim();return n?y(n).map(s=>{let o=s.trim(),i=r||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:i}}):[]}return t.startsWith("* as ")?[{importedName:"*",localName:t.slice(5).trim(),kind:"namespace",isTypeOnly:r}]:[{importedName:"default",localName:t,kind:"default",isTypeOnly:r}]}function an(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];if(n==="{"&&r++,n==="}"&&r--,n===","&&r===0)return[e.slice(0,t).trim(),e.slice(t+1).trim()]}return[e.trim(),null]}function Oe(e,r,t){let n=D(e,r);return n?fn(e,r,n):cn(e,r,t)}function cn(e,r,t){return[...ln(e,r,t),...pn(e,r,t),...un(e,r,t)]}function ln(e,r,t){let n=[],s=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[1]??"",a=o[2]??"",c=y(i).map(u=>mn(u.trim())).filter(u=>!!u),l=z(t,o.index),p=z(t,o.index+o[0].length-1);n.push({kind:"named",sourcePath:F(e,r,a),names:c,startLine:l,endLine:p})}return n}function pn(e,r,t){let n=[],s=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[2]??"",a=z(t,o.index),c=z(t,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:F(e,r,i),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return n}function un(e,r,t){let n=[],s=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[1]??"",a=z(t,o.index),c=z(t,o.index+o[0].length-1);n.push({kind:"star",sourcePath:F(e,r,i),names:[],startLine:a,endLine:c})}return n}function mn(e){if(!e)return null;let r=e.replace(/^type\s+/,"").trim();if(!r)return null;let t=r.match(/^(\w+)\s+as\s+(\w+)$/);if(t)return t[2]??null;let n=r.match(/^(\w+)$/);return n?n[1]??null:null}function z(e,r){let t=0;for(let n=0;n<r&&n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function fn(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("export_statement")){let o=dn(e,r,s);if(o===void 0)continue;let i=s.startPosition.row,a=s.endPosition.row,c=gn(s,o,i,a);n.push(c)}return n}function dn(e,r,t){let n=b(t,"string");if(!n)return;let s=b(n,"string_fragment");if(s)return F(e,r,s.text)}function gn(e,r,t,n){let s=b(e,"export_clause");if(s){let i=[];for(let a of s.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&i.push((l??c).text)}return{kind:"named",sourcePath:r,names:i,startLine:t,endLine:n}}let o=b(e,"namespace_export");if(o){let i=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:r,names:i?[i]:[],startLine:t,endLine:n}}return{kind:"star",sourcePath:r,names:[],startLine:t,endLine:n}}function It(e,r,t){return pe(e,r,{java:n=>Sn(e,r,n),kotlin:n=>hn(e,r,n),scala:n=>xn(e,r,n)},()=>I(t,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,s)=>{let o=n[1]?.trim();return o?yn(e,r,o,s):[]}),t)}function Sn(e,r,t){let n=g(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(i){s.push(M("*",S(e,l,P)));continue}let p=l.split(".").pop()??l;s.push(d(p,p,S(e,l,P),n))}return s}function hn(e,r,t){let n=g(t,new Set(["import_header","import_list"])),s=[];for(let o of t.rootNode.descendantsOfType("import_header")){let i=o.namedChildren.find(f=>f.type==="identifier");if(!i)continue;let a=o.namedChildren.some(f=>f.type==="wildcard_import"),c=o.namedChildren.find(f=>f.type==="import_alias");if(a){s.push(M("*",S(e,i.text,P)));continue}let l=i.text,p=l.split(".").pop()??l,m=c?.namedChild(0)?.text??p;s.push(d(p,m,S(e,l,P),n))}return s}function xn(e,r,t){let n=g(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==i&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(i?.type==="namespace_wildcard"){s.push(M("*",S(e,c,P)));continue}if(i?.type==="namespace_selectors"){for(let u of i.namedChildren)if(u.type==="arrow_renamed_identifier"){let[m,f]=u.namedChildren;if(!m)continue;let h=m.text,$=f?.text??h;if(h==="_")continue;s.push(d(h,$,S(e,`${c}.${h}`,P),n))}else if(u.type==="identifier"){let m=u.text;s.push(d(m,m,S(e,`${c}.${m}`,P),n))}continue}let l=a[a.length-1]?.text??c,p=a.slice(0,-1).map(u=>u.text).join(".")||c;s.push(d(l,l,S(e,p&&a.length>1?`${p}.${l}`:c,P),n))}return s}function yn(e,r,t,n){if(t.includes("{")&&t.includes("}")){let s=t.slice(0,t.indexOf("{")).replace(/\.$/,"").trim(),o=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim();return y(o).flatMap(i=>{let a=i.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),p=c?.trim();if(!p||p==="_")return[];let u=(l??p.split(".").pop()??p).trim(),m=p==="_"?s:`${s}.${p}`.replace(/\.\./g,".");return[T(e,r,n,m,p,u)]})}return[T(e,r,n,t,t.split(".").pop()??t,t.split(".").pop()??t)]}function _t(e,r,t){return C(e,r,n=>bn(e,r,n),()=>I(t,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,s)=>{let o=n[1]?.trim();return o?y(o).flatMap(i=>{let a=i.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),p=c?.trim()??a,u=p.split("\\").pop()??p,m=(l??u).trim();return[T(e,r,s,p,u,m,S(e,p.replace(/\\/g,"."),K))]}):[]}),t)}function bn(e,r,t){let n=g(t,new Set(["namespace_use_declaration"])),s=[],o=(i,a,c)=>{s.push(d(a,c,S(e,i.replace(/\\/g,"."),K),n))};for(let i of t.rootNode.descendantsOfType("namespace_use_declaration")){let a=i.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=i.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:p,localName:u,qualified:m}=Ct(l,c);p&&o(m,p,u)}continue}for(let c of i.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:p,qualified:u}=Ct(c,"");l&&o(u,l,p)}}return s}function Ct(e,r){let t=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),s="";t?s=t.text:n.length>=1&&(s=n[0].text);let o=t&&n.length>0?n[n.length-1]:null,i=s.split("\\").pop()??s,a=o?.text??i,c=r?`${r}\\${s}`:s;return{importedName:i,localName:a,qualified:c}}function Tt(e,r,t){return C(e,r,n=>Nn(e,r,n),()=>Cn(t).flatMap(n=>Pn(e,r,n,t)),t)}function Nn(e,r,t){let n=g(t,new Set(["import_statement","import_from_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("import_statement"))for(let i of o.namedChildren){let a=Pt(i);if(!a)continue;let c=J(e,r,a.qualifiedName);s.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of t.rootNode.descendantsOfType("import_from_statement")){let i=o.namedChild(0);if(!i)continue;let a=In(i);if(a===null)continue;let c=J(e,r,a);for(let l=1;l<o.namedChildCount;l+=1){let p=o.namedChild(l);if(p.type==="wildcard_import"){s.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=Pt(p);u&&s.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return s}function Pt(e){if(e.type==="aliased_import"){let r=e.namedChild(0),t=e.namedChild(1);return!r||!t?null:{qualifiedName:r.text,localName:t.text}}if(e.type==="dotted_name"){let r=e.text;return{qualifiedName:r,localName:r.split(".")[0]??r}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function In(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let r=b(e,"import_prefix")?.text??"",t=b(e,"dotted_name")?.text??"";return`${r}${t}`}return null}function Cn(e){let r=e.split(`
|
|
11
|
-
`),t=[],n=0;for(let s=0;s<r.length;s++){let o=r[s],i=o.trimStart(),a=n;if(n+=o.length+1,!i.startsWith("import ")&&!i.startsWith("from "))continue;let c=o,l=a+o.length,p=Ie(o);for(;s+1<r.length&&(p>0||c.trimEnd().endsWith("\\"));){s++;let m=r[s];c+=`
|
|
12
|
-
${m}`,l+=1+m.length,p+=Ie(m),n+=m.length+1}let u=_n(c);u&&t.push({...u,start:a,end:l})}return t}function _n(e){let r=e.replace(/\\\s*\n/g," ").trim();if(r.startsWith("import "))return{kind:"import",module:null,clause:r.slice(7).trim()};let t=r.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!t)return null;let n=t[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:t[1],clause:n}}function Pn(e,r,t,n){let s=w(n,t.start,t.end),o=t.clause.replace(/\n/g," ").trim();if(t.kind==="import")return y(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[p,u]=l.split(/\s+as\s+/),m=p.trim(),f=(u??m.split(".")[0]??m).trim(),h=J(e,r,m),$=V(s,f);return[{importedName:m,localName:f,sourcePath:h,kind:"namespace",used:x(s,f)||$.length>0,usedMembers:$}]});let i=t.module?J(e,r,t.module):null,a=[];for(let c of y(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:i,kind:"side-effect",used:!0,usedMembers:[]});continue}let[p,u]=l.split(/\s+as\s+/),m=(u??p).trim();a.push({importedName:p.trim(),localName:m,sourcePath:i,kind:"named",used:x(s,m),usedMembers:[]})}return a}import{basename as Tn}from"path";function Rt(e,r,t){return C(e,r,n=>En(e,r,n),()=>Rn(e,r,t),t)}function Rn(e,r,t){return I(t,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,s)=>{let o=n[1],i=n[2];if(!o||!i)return[];let a=o==="require_relative"?ge(e,r,i):null;if(a){let c=Et(i);return[E(c,c,a,x(s,c))]}return[v(i,a)]})}function En(e,r,t){let n=g(t,new Set([])),s=[],o=new Set(["require","require_relative","load"]);for(let i of t.rootNode.descendantsOfType("call")){let a=i.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=i.namedChildren.find(f=>f.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(f=>f.type==="string_content")?.text;if(!u)continue;let m=a.text==="require_relative"?ge(e,r,u):null;if(m){let f=Et(u);s.push(d(f,f,m,n))}else s.push(v(u,m))}return s}function Et(e){return tt(Tn(e).replace(/\.[^.]+$/,""),/_/)}function Ft(e,r,t){return C(e,r,n=>Fn(e,r,n),()=>I(t,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,s)=>{let o=n[1]?.trim();return o?Ln(e,r,o,s):[]}),t)}function Fn(e,r,t){let n=g(t,new Set(["use_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("use_declaration")){let i=o.namedChild(0);if(i)for(let a of ne(i,"")){if(!a.importedName||a.importedName==="*")continue;let c=L(e,r,a.qualifiedName)??L(e,r,a.qualifiedName.split("::").slice(0,-1).join("::"));s.push(d(a.importedName,a.localName,c,n))}}return s}function ne(e,r){switch(e.type){case"identifier":case"super":case"crate":{let t=e.text;return[{qualifiedName:fe(r,t),importedName:t,localName:t}]}case"self":{let t=r.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:r||"self",importedName:t,localName:t}]}case"scoped_identifier":{let t=e.text,n=t.split("::").pop()??t;return[{qualifiedName:fe(r,t),importedName:n,localName:n}]}case"scoped_use_list":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=fe(r,t.text),o=[];for(let i of n.namedChildren)o.push(...ne(i,s));return o}case"use_list":{let t=[];for(let n of e.namedChildren)t.push(...ne(n,r));return t}case"use_as_clause":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=ne(t,r),o=n.text;return s.map(i=>({...i,localName:o}))}case"use_wildcard":{let t=e.namedChild(0),n=t?t.text:"";return[{qualifiedName:fe(r,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function fe(e,r){return e?r?`${e}::${r}`:e:r}function Ln(e,r,t,n){let s=t.trim();if(s.includes("{")&&s.includes("}")){let p=s.slice(0,s.indexOf("{")).replace(/::$/,"").trim(),u=s.slice(s.indexOf("{")+1,s.lastIndexOf("}")).trim();return y(u).flatMap(m=>{let f=m.trim();if(!f)return[];if(f==="self"){let de=p.split("::").filter(Boolean).pop();return de?[T(e,r,n,p,de,de)]:[]}let[h,$]=f.split(/\s+as\s+/),B=h?.trim();if(!B)return[];let Dt=($??B.split("::").pop()??B).trim(),Ot=`${p}::${B}`.replace(/::::/g,"::");return[T(e,r,n,Ot,B.split("::").pop()??B,Dt,L(e,r,p))]})}let[o,i]=s.split(/\s+as\s+/),a=o?.trim()??s,c=(i??a.split("::").pop()??a).trim(),l=L(e,r,a)??L(e,r,a.split("::").slice(0,-1).join("::"));return[T(e,r,n,a,a.split("::").pop()??a,c,l)]}function Lt(e,r,t){let n=D(e,r);if(n)return An(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let i=o[1]?.trim();i&&s.push(...wn(e,r,i))}return s}function An(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("use_declaration")){if(!kn(s))continue;let o=s.namedChildren.find(i=>i.type!=="visibility_modifier");if(o)for(let i of ne(o,""))i.importedName&&n.push(ve(e,r,i.qualifiedName))}return n}function kn(e){for(let r of e.children)if(r.type==="visibility_modifier"&&r.text.startsWith("pub"))return!0;return!1}function wn(e,r,t){let n=t.trim();if(n.includes("{")&&n.includes("}")){let s=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return y(o).flatMap(i=>{let a=i.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${s}::${c?.trim()??a}`.replace(/::::/g,"::");return[ve(e,r,l)]})}return[ve(e,r,n)]}function ve(e,r,t){return{specifier:t,sourcePath:L(e,r,t)??L(e,r,t.split("::").slice(0,-1).join("::"))}}function j({language:e,extensions:r,imports:t,parseImports:n}){return{language:e,extensions:r,capabilities:{imports:t},parseImports:n}}function At(e,r){let t=r.toLowerCase();for(let n of e)for(let s of n.extensions)if(t.endsWith(s))return n;return null}var jn={language:"javascript",extensions:qe,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:De,parseReExports:Oe},Dn=j({language:"python",extensions:Ve,imports:"ast-with-regex-fallback",parseImports:Tt}),On=j({language:"jvm",extensions:P,imports:"ast-dispatch-with-regex-fallback",parseImports:It}),vn={language:"rust",extensions:ze,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Ft,parseExports:Lt},Mn=j({language:"ruby",extensions:We,imports:"ast-with-regex-fallback",parseImports:Rt}),$n=j({language:"c/cpp",extensions:He,imports:"ast-with-regex-fallback",parseImports:dt}),Bn=j({language:"dotnet",extensions:q,imports:"ast-dispatch-with-regex-fallback",parseImports:yt}),Un={language:"dart",extensions:Ke,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:ht,parseExports:xt},qn=j({language:"php",extensions:K,imports:"ast-with-regex-fallback",parseImports:_t}),Vn=j({language:"clojure",extensions:Je,imports:"regex-only",parseImports:St}),zn=[jn,Dn,On,vn,Mn,$n,Bn,Un,qn,Vn];function se(e){return At(zn,e)}var Me={clearGroups:["whole-project","source-file"]},Wn=U("source-imports",Me),Hn=U("source-exports",Me),Kn=U("source-reexports",Me),kt=X({kind:"source-imports",invalidation:G("source-imports"),serialize:Xn,deserialize:Gn}),wt=X({kind:"source-reexports",invalidation:G("source-reexports"),serialize:Yn,deserialize:Qn});function di(e,r){let t=W(r);return Kn.get(e,t,()=>{let n=se(t);if(!n?.parseReExports)return[];let s=A(e,t);if(!s)return[];let o=H(e,t,s),i=xe(e),a=wt.read(e,t,o);if(a?.resolutionFingerprint===i)return a.reExports;let c=n.parseReExports(e,t,s);return wt.write(e,t,o,{resolutionFingerprint:i,reExports:c}),c})}function Jn(e,r){let t=W(r);return Wn.get(e,t,()=>{let n=se(t);if(!n)return[];let s=A(e,t);return s?jt(e,t,s,n):[]})}function gi(e,r){let t=W(r),n=se(t);if(!n)return[];let s;try{s=$e(e.config.projectRoot,t,{inputKind:"indexed source file"})}catch(o){if(Be(o))return[];throw o}return jt(e,t,s,n)}function jt(e,r,t,n){let s=H(e,r,t),o=xe(e),i=kt.read(e,r,s);if(i?.resolutionFingerprint===o)return i.imports;let a=n.parseImports(e,r,t);return kt.write(e,r,s,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function Si(e,r,t){let n=Jn(e,r).filter(s=>s.kind==="named"&&s.isTypeOnly!==!0&&s.localName===t&&s.sourcePath!==null);return n.length===1?n[0]:null}function hi(e,r){let t=W(r);return Hn.get(e,t,()=>{let n=se(t);if(!n?.parseExports)return[];let s=A(e,t);return s?n.parseExports(e,t,s):[]})}function Xn(e){return JSON.stringify(e)}function Gn(e){try{let r=JSON.parse(e);return!ye(r)||r.parserVersion!==2||typeof r.resolutionFingerprint!="string"||!Array.isArray(r.imports)?null:{parserVersion:2,resolutionFingerprint:r.resolutionFingerprint,imports:r.imports}}catch{return null}}function Yn(e){return JSON.stringify(e)}function Qn(e){try{let r=JSON.parse(e);return!ye(r)||typeof r.resolutionFingerprint!="string"||!Array.isArray(r.reExports)?null:{resolutionFingerprint:r.resolutionFingerprint,reExports:r.reExports}}catch{return null}}export{O as a,vt as b,ns as c,ss as d,Ie as e,Ce as f,$t as g,nt as h,Bt as i,_e as j,Ut as k,R as l,lr as m,dr as n,gr as o,yr as p,br as q,Nr as r,Ir as s,Cr as t,fe as u,di as v,Jn as w,gi as x,Si as y,hi as z};
|
|
13
|
-
//# sourceMappingURL=chunk-6LS3IG2I.js.map
|