@quolu/lattice 0.69.5 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (605) hide show
  1. package/README.ja.md +5 -1
  2. package/package.json +1 -1
  3. package/sensor/dist/bin/lattice-sensor.js +746 -323
  4. package/sensor/dist/bin/viewer-gate.d.ts +17 -0
  5. package/sensor/dist/bin/viewer-gate.d.ts.map +1 -0
  6. package/sensor/dist/bin/viewer-gate.js +31 -0
  7. package/sensor/dist/bin/viewer-gate.js.map +1 -0
  8. package/sensor/dist/context/formatter.d.ts +7 -1
  9. package/sensor/dist/context/formatter.d.ts.map +1 -1
  10. package/sensor/dist/context/formatter.js +12 -6
  11. package/sensor/dist/context/formatter.js.map +1 -1
  12. package/sensor/dist/context/index.d.ts +12 -0
  13. package/sensor/dist/context/index.d.ts.map +1 -1
  14. package/sensor/dist/context/index.js +103 -16
  15. package/sensor/dist/context/index.js.map +1 -1
  16. package/sensor/dist/db/index.d.ts +23 -2
  17. package/sensor/dist/db/index.d.ts.map +1 -1
  18. package/sensor/dist/db/index.js +109 -31
  19. package/sensor/dist/db/index.js.map +1 -1
  20. package/sensor/dist/db/migrations.d.ts +1 -1
  21. package/sensor/dist/db/migrations.d.ts.map +1 -1
  22. package/sensor/dist/db/migrations.js +68 -1
  23. package/sensor/dist/db/migrations.js.map +1 -1
  24. package/sensor/dist/db/queries.d.ts +583 -6
  25. package/sensor/dist/db/queries.d.ts.map +1 -1
  26. package/sensor/dist/db/queries.js +1425 -57
  27. package/sensor/dist/db/queries.js.map +1 -1
  28. package/sensor/dist/db/schema.sql +27 -4
  29. package/sensor/dist/db/sqlite-adapter.d.ts +2 -0
  30. package/sensor/dist/db/sqlite-adapter.d.ts.map +1 -1
  31. package/sensor/dist/db/sqlite-adapter.js +56 -7
  32. package/sensor/dist/db/sqlite-adapter.js.map +1 -1
  33. package/sensor/dist/db/synthesis-stage.d.ts +12 -0
  34. package/sensor/dist/db/synthesis-stage.d.ts.map +1 -0
  35. package/sensor/dist/db/synthesis-stage.js +93 -0
  36. package/sensor/dist/db/synthesis-stage.js.map +1 -0
  37. package/sensor/dist/db/wal-valve.d.ts +32 -12
  38. package/sensor/dist/db/wal-valve.d.ts.map +1 -1
  39. package/sensor/dist/db/wal-valve.js +65 -22
  40. package/sensor/dist/db/wal-valve.js.map +1 -1
  41. package/sensor/dist/db/wsl-shared-index.d.ts +53 -0
  42. package/sensor/dist/db/wsl-shared-index.d.ts.map +1 -0
  43. package/sensor/dist/db/wsl-shared-index.js +121 -0
  44. package/sensor/dist/db/wsl-shared-index.js.map +1 -0
  45. package/sensor/dist/directory.d.ts +126 -2
  46. package/sensor/dist/directory.d.ts.map +1 -1
  47. package/sensor/dist/directory.js +285 -16
  48. package/sensor/dist/directory.js.map +1 -1
  49. package/sensor/dist/errors.d.ts +14 -0
  50. package/sensor/dist/errors.d.ts.map +1 -1
  51. package/sensor/dist/errors.js +16 -1
  52. package/sensor/dist/errors.js.map +1 -1
  53. package/sensor/dist/extraction/cfml-extractor.d.ts +1 -0
  54. package/sensor/dist/extraction/cfml-extractor.d.ts.map +1 -1
  55. package/sensor/dist/extraction/cfml-extractor.js +15 -3
  56. package/sensor/dist/extraction/cfml-extractor.js.map +1 -1
  57. package/sensor/dist/extraction/dfm-extractor.d.ts.map +1 -1
  58. package/sensor/dist/extraction/dfm-extractor.js +14 -10
  59. package/sensor/dist/extraction/dfm-extractor.js.map +1 -1
  60. package/sensor/dist/extraction/extraction-version.d.ts +1 -1
  61. package/sensor/dist/extraction/extraction-version.d.ts.map +1 -1
  62. package/sensor/dist/extraction/extraction-version.js +3 -1
  63. package/sensor/dist/extraction/extraction-version.js.map +1 -1
  64. package/sensor/dist/extraction/function-ref.d.ts +6 -4
  65. package/sensor/dist/extraction/function-ref.d.ts.map +1 -1
  66. package/sensor/dist/extraction/function-ref.js +35 -14
  67. package/sensor/dist/extraction/function-ref.js.map +1 -1
  68. package/sensor/dist/extraction/generated-detection.d.ts +48 -12
  69. package/sensor/dist/extraction/generated-detection.d.ts.map +1 -1
  70. package/sensor/dist/extraction/generated-detection.js +176 -11
  71. package/sensor/dist/extraction/generated-detection.js.map +1 -1
  72. package/sensor/dist/extraction/grammars.d.ts +38 -0
  73. package/sensor/dist/extraction/grammars.d.ts.map +1 -1
  74. package/sensor/dist/extraction/grammars.js +115 -3
  75. package/sensor/dist/extraction/grammars.js.map +1 -1
  76. package/sensor/dist/extraction/index.d.ts +218 -14
  77. package/sensor/dist/extraction/index.d.ts.map +1 -1
  78. package/sensor/dist/extraction/index.js +887 -175
  79. package/sensor/dist/extraction/index.js.map +1 -1
  80. package/sensor/dist/extraction/languages/c-cpp.d.ts +58 -0
  81. package/sensor/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  82. package/sensor/dist/extraction/languages/c-cpp.js +310 -19
  83. package/sensor/dist/extraction/languages/c-cpp.js.map +1 -1
  84. package/sensor/dist/extraction/languages/dart.d.ts.map +1 -1
  85. package/sensor/dist/extraction/languages/dart.js +8 -3
  86. package/sensor/dist/extraction/languages/dart.js.map +1 -1
  87. package/sensor/dist/extraction/languages/erlang.d.ts.map +1 -1
  88. package/sensor/dist/extraction/languages/erlang.js +58 -22
  89. package/sensor/dist/extraction/languages/erlang.js.map +1 -1
  90. package/sensor/dist/extraction/languages/javascript.js +1 -1
  91. package/sensor/dist/extraction/languages/javascript.js.map +1 -1
  92. package/sensor/dist/extraction/languages/kotlin.d.ts.map +1 -1
  93. package/sensor/dist/extraction/languages/kotlin.js +169 -36
  94. package/sensor/dist/extraction/languages/kotlin.js.map +1 -1
  95. package/sensor/dist/extraction/languages/lua.d.ts.map +1 -1
  96. package/sensor/dist/extraction/languages/lua.js +4 -1
  97. package/sensor/dist/extraction/languages/lua.js.map +1 -1
  98. package/sensor/dist/extraction/languages/objc.d.ts.map +1 -1
  99. package/sensor/dist/extraction/languages/objc.js +4 -0
  100. package/sensor/dist/extraction/languages/objc.js.map +1 -1
  101. package/sensor/dist/extraction/languages/python.d.ts.map +1 -1
  102. package/sensor/dist/extraction/languages/python.js +71 -0
  103. package/sensor/dist/extraction/languages/python.js.map +1 -1
  104. package/sensor/dist/extraction/languages/rust.d.ts +20 -0
  105. package/sensor/dist/extraction/languages/rust.d.ts.map +1 -1
  106. package/sensor/dist/extraction/languages/rust.js +50 -20
  107. package/sensor/dist/extraction/languages/rust.js.map +1 -1
  108. package/sensor/dist/extraction/languages/scala.d.ts.map +1 -1
  109. package/sensor/dist/extraction/languages/scala.js +18 -3
  110. package/sensor/dist/extraction/languages/scala.js.map +1 -1
  111. package/sensor/dist/extraction/languages/swift.d.ts +15 -0
  112. package/sensor/dist/extraction/languages/swift.d.ts.map +1 -1
  113. package/sensor/dist/extraction/languages/swift.js +50 -0
  114. package/sensor/dist/extraction/languages/swift.js.map +1 -1
  115. package/sensor/dist/extraction/languages/typescript.d.ts.map +1 -1
  116. package/sensor/dist/extraction/languages/typescript.js +9 -2
  117. package/sensor/dist/extraction/languages/typescript.js.map +1 -1
  118. package/sensor/dist/extraction/liquid-extractor.d.ts +18 -0
  119. package/sensor/dist/extraction/liquid-extractor.d.ts.map +1 -1
  120. package/sensor/dist/extraction/liquid-extractor.js +98 -22
  121. package/sensor/dist/extraction/liquid-extractor.js.map +1 -1
  122. package/sensor/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  123. package/sensor/dist/extraction/mybatis-extractor.js +6 -4
  124. package/sensor/dist/extraction/mybatis-extractor.js.map +1 -1
  125. package/sensor/dist/extraction/parse-pool.d.ts +7 -0
  126. package/sensor/dist/extraction/parse-pool.d.ts.map +1 -1
  127. package/sensor/dist/extraction/parse-pool.js +20 -1
  128. package/sensor/dist/extraction/parse-pool.js.map +1 -1
  129. package/sensor/dist/extraction/syntax-tokens.d.ts +103 -0
  130. package/sensor/dist/extraction/syntax-tokens.d.ts.map +1 -0
  131. package/sensor/dist/extraction/syntax-tokens.js +381 -0
  132. package/sensor/dist/extraction/syntax-tokens.js.map +1 -0
  133. package/sensor/dist/extraction/tree-sitter-helpers.d.ts +5 -0
  134. package/sensor/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  135. package/sensor/dist/extraction/tree-sitter-helpers.js +17 -0
  136. package/sensor/dist/extraction/tree-sitter-helpers.js.map +1 -1
  137. package/sensor/dist/extraction/tree-sitter-types.d.ts +31 -3
  138. package/sensor/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  139. package/sensor/dist/extraction/tree-sitter.d.ts +101 -18
  140. package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -1
  141. package/sensor/dist/extraction/tree-sitter.js +928 -134
  142. package/sensor/dist/extraction/tree-sitter.js.map +1 -1
  143. package/sensor/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  144. package/sensor/dist/file-limits.d.ts +40 -0
  145. package/sensor/dist/file-limits.d.ts.map +1 -0
  146. package/sensor/dist/file-limits.js +147 -0
  147. package/sensor/dist/file-limits.js.map +1 -0
  148. package/sensor/dist/graph/branch-guards.d.ts +265 -0
  149. package/sensor/dist/graph/branch-guards.d.ts.map +1 -0
  150. package/sensor/dist/graph/branch-guards.js +2325 -0
  151. package/sensor/dist/graph/branch-guards.js.map +1 -0
  152. package/sensor/dist/graph/dead-code.d.ts +251 -0
  153. package/sensor/dist/graph/dead-code.d.ts.map +1 -0
  154. package/sensor/dist/graph/dead-code.js +776 -0
  155. package/sensor/dist/graph/dead-code.js.map +1 -0
  156. package/sensor/dist/graph/dynamic-boundary-report.d.ts +121 -0
  157. package/sensor/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  158. package/sensor/dist/graph/dynamic-boundary-report.js +283 -0
  159. package/sensor/dist/graph/dynamic-boundary-report.js.map +1 -0
  160. package/sensor/dist/graph/index.d.ts +4 -0
  161. package/sensor/dist/graph/index.d.ts.map +1 -1
  162. package/sensor/dist/graph/index.js +16 -1
  163. package/sensor/dist/graph/index.js.map +1 -1
  164. package/sensor/dist/graph/named-symbol-flow.d.ts +125 -0
  165. package/sensor/dist/graph/named-symbol-flow.d.ts.map +1 -0
  166. package/sensor/dist/graph/named-symbol-flow.js +552 -0
  167. package/sensor/dist/graph/named-symbol-flow.js.map +1 -0
  168. package/sensor/dist/graph/queries.d.ts.map +1 -1
  169. package/sensor/dist/graph/queries.js +2 -0
  170. package/sensor/dist/graph/queries.js.map +1 -1
  171. package/sensor/dist/graph/symbol-lookup.d.ts +83 -0
  172. package/sensor/dist/graph/symbol-lookup.d.ts.map +1 -0
  173. package/sensor/dist/graph/symbol-lookup.js +181 -0
  174. package/sensor/dist/graph/symbol-lookup.js.map +1 -0
  175. package/sensor/dist/graph/traversal.d.ts +9 -0
  176. package/sensor/dist/graph/traversal.d.ts.map +1 -1
  177. package/sensor/dist/graph/traversal.js +62 -36
  178. package/sensor/dist/graph/traversal.js.map +1 -1
  179. package/sensor/dist/graph/type-hierarchy.d.ts +155 -0
  180. package/sensor/dist/graph/type-hierarchy.d.ts.map +1 -0
  181. package/sensor/dist/graph/type-hierarchy.js +382 -0
  182. package/sensor/dist/graph/type-hierarchy.js.map +1 -0
  183. package/sensor/dist/index.d.ts +272 -10
  184. package/sensor/dist/index.d.ts.map +1 -1
  185. package/sensor/dist/index.js +510 -34
  186. package/sensor/dist/index.js.map +1 -1
  187. package/sensor/dist/mcp/answer-freshness.d.ts +10 -0
  188. package/sensor/dist/mcp/answer-freshness.d.ts.map +1 -0
  189. package/sensor/dist/mcp/answer-freshness.js +68 -0
  190. package/sensor/dist/mcp/answer-freshness.js.map +1 -0
  191. package/sensor/dist/mcp/daemon-manager.d.ts +1 -1
  192. package/sensor/dist/mcp/daemon-manager.d.ts.map +1 -1
  193. package/sensor/dist/mcp/daemon-manager.js +17 -1
  194. package/sensor/dist/mcp/daemon-manager.js.map +1 -1
  195. package/sensor/dist/mcp/daemon-paths.d.ts +8 -0
  196. package/sensor/dist/mcp/daemon-paths.d.ts.map +1 -1
  197. package/sensor/dist/mcp/daemon-paths.js +65 -2
  198. package/sensor/dist/mcp/daemon-paths.js.map +1 -1
  199. package/sensor/dist/mcp/daemon-registry.d.ts +17 -4
  200. package/sensor/dist/mcp/daemon-registry.d.ts.map +1 -1
  201. package/sensor/dist/mcp/daemon-registry.js +133 -23
  202. package/sensor/dist/mcp/daemon-registry.js.map +1 -1
  203. package/sensor/dist/mcp/daemon.d.ts +26 -13
  204. package/sensor/dist/mcp/daemon.d.ts.map +1 -1
  205. package/sensor/dist/mcp/daemon.js +126 -32
  206. package/sensor/dist/mcp/daemon.js.map +1 -1
  207. package/sensor/dist/mcp/dynamic-boundaries.d.ts +1 -10
  208. package/sensor/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  209. package/sensor/dist/mcp/dynamic-boundaries.js +46 -42
  210. package/sensor/dist/mcp/dynamic-boundaries.js.map +1 -1
  211. package/sensor/dist/mcp/engine.d.ts +31 -9
  212. package/sensor/dist/mcp/engine.d.ts.map +1 -1
  213. package/sensor/dist/mcp/engine.js +190 -79
  214. package/sensor/dist/mcp/engine.js.map +1 -1
  215. package/sensor/dist/mcp/explore-dedup.d.ts +140 -0
  216. package/sensor/dist/mcp/explore-dedup.d.ts.map +1 -0
  217. package/sensor/dist/mcp/explore-dedup.js +239 -0
  218. package/sensor/dist/mcp/explore-dedup.js.map +1 -0
  219. package/sensor/dist/mcp/explore-diagnostics.d.ts +289 -0
  220. package/sensor/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  221. package/sensor/dist/mcp/explore-diagnostics.js +558 -0
  222. package/sensor/dist/mcp/explore-diagnostics.js.map +1 -0
  223. package/sensor/dist/mcp/explore-session-state.d.ts +217 -0
  224. package/sensor/dist/mcp/explore-session-state.d.ts.map +1 -0
  225. package/sensor/dist/mcp/explore-session-state.js +322 -0
  226. package/sensor/dist/mcp/explore-session-state.js.map +1 -0
  227. package/sensor/dist/mcp/index-freshness-worker.d.ts +2 -0
  228. package/sensor/dist/mcp/index-freshness-worker.d.ts.map +1 -0
  229. package/sensor/dist/mcp/index-freshness-worker.js +30 -0
  230. package/sensor/dist/mcp/index-freshness-worker.js.map +1 -0
  231. package/sensor/dist/mcp/index-freshness.d.ts +7 -0
  232. package/sensor/dist/mcp/index-freshness.d.ts.map +1 -0
  233. package/sensor/dist/mcp/index-freshness.js +94 -0
  234. package/sensor/dist/mcp/index-freshness.js.map +1 -0
  235. package/sensor/dist/mcp/index.d.ts +3 -1
  236. package/sensor/dist/mcp/index.d.ts.map +1 -1
  237. package/sensor/dist/mcp/index.js +109 -12
  238. package/sensor/dist/mcp/index.js.map +1 -1
  239. package/sensor/dist/mcp/liveness-watchdog.d.ts +4 -1
  240. package/sensor/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  241. package/sensor/dist/mcp/liveness-watchdog.js +11 -2
  242. package/sensor/dist/mcp/liveness-watchdog.js.map +1 -1
  243. package/sensor/dist/mcp/project-lifecycle.d.ts +9 -0
  244. package/sensor/dist/mcp/project-lifecycle.d.ts.map +1 -0
  245. package/sensor/dist/mcp/project-lifecycle.js +182 -0
  246. package/sensor/dist/mcp/project-lifecycle.js.map +1 -0
  247. package/sensor/dist/mcp/proxy.d.ts.map +1 -1
  248. package/sensor/dist/mcp/proxy.js +15 -1
  249. package/sensor/dist/mcp/proxy.js.map +1 -1
  250. package/sensor/dist/mcp/query-pool.d.ts +2 -2
  251. package/sensor/dist/mcp/query-pool.d.ts.map +1 -1
  252. package/sensor/dist/mcp/query-pool.js +9 -7
  253. package/sensor/dist/mcp/query-pool.js.map +1 -1
  254. package/sensor/dist/mcp/query-worker.js +2 -2
  255. package/sensor/dist/mcp/query-worker.js.map +1 -1
  256. package/sensor/dist/mcp/server-instructions.d.ts +2 -2
  257. package/sensor/dist/mcp/server-instructions.d.ts.map +1 -1
  258. package/sensor/dist/mcp/server-instructions.js +13 -6
  259. package/sensor/dist/mcp/server-instructions.js.map +1 -1
  260. package/sensor/dist/mcp/session.d.ts +16 -0
  261. package/sensor/dist/mcp/session.d.ts.map +1 -1
  262. package/sensor/dist/mcp/session.js +36 -13
  263. package/sensor/dist/mcp/session.js.map +1 -1
  264. package/sensor/dist/mcp/startup-handshake.d.ts +3 -1
  265. package/sensor/dist/mcp/startup-handshake.d.ts.map +1 -1
  266. package/sensor/dist/mcp/startup-handshake.js +10 -2
  267. package/sensor/dist/mcp/startup-handshake.js.map +1 -1
  268. package/sensor/dist/mcp/tools.d.ts +496 -38
  269. package/sensor/dist/mcp/tools.d.ts.map +1 -1
  270. package/sensor/dist/mcp/tools.js +4021 -772
  271. package/sensor/dist/mcp/tools.js.map +1 -1
  272. package/sensor/dist/mcp/writer-lock.d.ts +61 -0
  273. package/sensor/dist/mcp/writer-lock.d.ts.map +1 -0
  274. package/sensor/dist/mcp/writer-lock.js +260 -0
  275. package/sensor/dist/mcp/writer-lock.js.map +1 -0
  276. package/sensor/dist/project-config.d.ts +23 -0
  277. package/sensor/dist/project-config.d.ts.map +1 -1
  278. package/sensor/dist/project-config.js +39 -2
  279. package/sensor/dist/project-config.js.map +1 -1
  280. package/sensor/dist/resolution/alias-binding.d.ts +56 -0
  281. package/sensor/dist/resolution/alias-binding.d.ts.map +1 -0
  282. package/sensor/dist/resolution/alias-binding.js +127 -0
  283. package/sensor/dist/resolution/alias-binding.js.map +1 -0
  284. package/sensor/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  285. package/sensor/dist/resolution/c-fnptr-synthesizer.js +21 -19
  286. package/sensor/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  287. package/sensor/dist/resolution/callback-synthesizer.d.ts +23 -1
  288. package/sensor/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  289. package/sensor/dist/resolution/callback-synthesizer.js +356 -155
  290. package/sensor/dist/resolution/callback-synthesizer.js.map +1 -1
  291. package/sensor/dist/resolution/cpp-constructor.d.ts +4 -0
  292. package/sensor/dist/resolution/cpp-constructor.d.ts.map +1 -0
  293. package/sensor/dist/resolution/cpp-constructor.js +123 -0
  294. package/sensor/dist/resolution/cpp-constructor.js.map +1 -0
  295. package/sensor/dist/resolution/cpp-macro-visibility.d.ts +12 -0
  296. package/sensor/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
  297. package/sensor/dist/resolution/cpp-macro-visibility.js +342 -0
  298. package/sensor/dist/resolution/cpp-macro-visibility.js.map +1 -0
  299. package/sensor/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  300. package/sensor/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  301. package/sensor/dist/resolution/expo-router-synthesizer.js +189 -0
  302. package/sensor/dist/resolution/expo-router-synthesizer.js.map +1 -0
  303. package/sensor/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  304. package/sensor/dist/resolution/frameworks/csharp.js +96 -2
  305. package/sensor/dist/resolution/frameworks/csharp.js.map +1 -1
  306. package/sensor/dist/resolution/frameworks/expo-router.d.ts +189 -0
  307. package/sensor/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  308. package/sensor/dist/resolution/frameworks/expo-router.js +785 -0
  309. package/sensor/dist/resolution/frameworks/expo-router.js.map +1 -0
  310. package/sensor/dist/resolution/frameworks/express.d.ts.map +1 -1
  311. package/sensor/dist/resolution/frameworks/express.js +251 -16
  312. package/sensor/dist/resolution/frameworks/express.js.map +1 -1
  313. package/sensor/dist/resolution/frameworks/index.d.ts +5 -0
  314. package/sensor/dist/resolution/frameworks/index.d.ts.map +1 -1
  315. package/sensor/dist/resolution/frameworks/index.js +29 -1
  316. package/sensor/dist/resolution/frameworks/index.js.map +1 -1
  317. package/sensor/dist/resolution/frameworks/java.d.ts.map +1 -1
  318. package/sensor/dist/resolution/frameworks/java.js +79 -47
  319. package/sensor/dist/resolution/frameworks/java.js.map +1 -1
  320. package/sensor/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  321. package/sensor/dist/resolution/frameworks/laravel.js +294 -4
  322. package/sensor/dist/resolution/frameworks/laravel.js.map +1 -1
  323. package/sensor/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  324. package/sensor/dist/resolution/frameworks/nestjs.js +6 -14
  325. package/sensor/dist/resolution/frameworks/nestjs.js.map +1 -1
  326. package/sensor/dist/resolution/frameworks/nextjs.d.ts +76 -0
  327. package/sensor/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  328. package/sensor/dist/resolution/frameworks/nextjs.js +328 -0
  329. package/sensor/dist/resolution/frameworks/nextjs.js.map +1 -0
  330. package/sensor/dist/resolution/frameworks/object-literal.d.ts +32 -0
  331. package/sensor/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  332. package/sensor/dist/resolution/frameworks/object-literal.js +139 -0
  333. package/sensor/dist/resolution/frameworks/object-literal.js.map +1 -0
  334. package/sensor/dist/resolution/frameworks/package-deps.d.ts +14 -0
  335. package/sensor/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  336. package/sensor/dist/resolution/frameworks/package-deps.js +78 -0
  337. package/sensor/dist/resolution/frameworks/package-deps.js.map +1 -0
  338. package/sensor/dist/resolution/frameworks/python.d.ts.map +1 -1
  339. package/sensor/dist/resolution/frameworks/python.js +166 -0
  340. package/sensor/dist/resolution/frameworks/python.js.map +1 -1
  341. package/sensor/dist/resolution/frameworks/react-native.d.ts +26 -0
  342. package/sensor/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  343. package/sensor/dist/resolution/frameworks/react-native.js +153 -14
  344. package/sensor/dist/resolution/frameworks/react-native.js.map +1 -1
  345. package/sensor/dist/resolution/frameworks/react-router.d.ts +46 -0
  346. package/sensor/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  347. package/sensor/dist/resolution/frameworks/react-router.js +187 -0
  348. package/sensor/dist/resolution/frameworks/react-router.js.map +1 -0
  349. package/sensor/dist/resolution/frameworks/react.d.ts +2 -1
  350. package/sensor/dist/resolution/frameworks/react.d.ts.map +1 -1
  351. package/sensor/dist/resolution/frameworks/react.js +188 -139
  352. package/sensor/dist/resolution/frameworks/react.js.map +1 -1
  353. package/sensor/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  354. package/sensor/dist/resolution/frameworks/svelte.js +6 -1
  355. package/sensor/dist/resolution/frameworks/svelte.js.map +1 -1
  356. package/sensor/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  357. package/sensor/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  358. package/sensor/dist/resolution/frameworks/sveltekit-router.js +156 -0
  359. package/sensor/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  360. package/sensor/dist/resolution/frameworks/swift.d.ts.map +1 -1
  361. package/sensor/dist/resolution/frameworks/swift.js +140 -99
  362. package/sensor/dist/resolution/frameworks/swift.js.map +1 -1
  363. package/sensor/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  364. package/sensor/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  365. package/sensor/dist/resolution/frameworks/tanstack-router.js +437 -0
  366. package/sensor/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  367. package/sensor/dist/resolution/frameworks/vue-router.d.ts +82 -0
  368. package/sensor/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  369. package/sensor/dist/resolution/frameworks/vue-router.js +377 -0
  370. package/sensor/dist/resolution/frameworks/vue-router.js.map +1 -0
  371. package/sensor/dist/resolution/import-resolver.d.ts +38 -0
  372. package/sensor/dist/resolution/import-resolver.d.ts.map +1 -1
  373. package/sensor/dist/resolution/import-resolver.js +394 -28
  374. package/sensor/dist/resolution/import-resolver.js.map +1 -1
  375. package/sensor/dist/resolution/index.d.ts +89 -25
  376. package/sensor/dist/resolution/index.d.ts.map +1 -1
  377. package/sensor/dist/resolution/index.js +573 -148
  378. package/sensor/dist/resolution/index.js.map +1 -1
  379. package/sensor/dist/resolution/js-builtins.d.ts +13 -0
  380. package/sensor/dist/resolution/js-builtins.d.ts.map +1 -0
  381. package/sensor/dist/resolution/js-builtins.js +46 -0
  382. package/sensor/dist/resolution/js-builtins.js.map +1 -0
  383. package/sensor/dist/resolution/name-matcher.d.ts +99 -22
  384. package/sensor/dist/resolution/name-matcher.d.ts.map +1 -1
  385. package/sensor/dist/resolution/name-matcher.js +2220 -86
  386. package/sensor/dist/resolution/name-matcher.js.map +1 -1
  387. package/sensor/dist/resolution/next-router-synthesizer.d.ts +27 -0
  388. package/sensor/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  389. package/sensor/dist/resolution/next-router-synthesizer.js +113 -0
  390. package/sensor/dist/resolution/next-router-synthesizer.js.map +1 -0
  391. package/sensor/dist/resolution/path-aliases.d.ts +6 -4
  392. package/sensor/dist/resolution/path-aliases.d.ts.map +1 -1
  393. package/sensor/dist/resolution/path-aliases.js +125 -17
  394. package/sensor/dist/resolution/path-aliases.js.map +1 -1
  395. package/sensor/dist/resolution/react-router-synthesizer.d.ts +33 -0
  396. package/sensor/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  397. package/sensor/dist/resolution/react-router-synthesizer.js +126 -0
  398. package/sensor/dist/resolution/react-router-synthesizer.js.map +1 -0
  399. package/sensor/dist/resolution/resolver-pool.d.ts +2 -0
  400. package/sensor/dist/resolution/resolver-pool.d.ts.map +1 -1
  401. package/sensor/dist/resolution/resolver-pool.js +4 -0
  402. package/sensor/dist/resolution/resolver-pool.js.map +1 -1
  403. package/sensor/dist/resolution/strip-comments.d.ts +6 -0
  404. package/sensor/dist/resolution/strip-comments.d.ts.map +1 -1
  405. package/sensor/dist/resolution/strip-comments.js +58 -0
  406. package/sensor/dist/resolution/strip-comments.js.map +1 -1
  407. package/sensor/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  408. package/sensor/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  409. package/sensor/dist/resolution/sveltekit-synthesizer.js +173 -0
  410. package/sensor/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  411. package/sensor/dist/resolution/swift-type-visibility.d.ts +52 -0
  412. package/sensor/dist/resolution/swift-type-visibility.d.ts.map +1 -0
  413. package/sensor/dist/resolution/swift-type-visibility.js +328 -0
  414. package/sensor/dist/resolution/swift-type-visibility.js.map +1 -0
  415. package/sensor/dist/resolution/synth-utils.d.ts +26 -0
  416. package/sensor/dist/resolution/synth-utils.d.ts.map +1 -0
  417. package/sensor/dist/resolution/synth-utils.js +75 -0
  418. package/sensor/dist/resolution/synth-utils.js.map +1 -0
  419. package/sensor/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  420. package/sensor/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  421. package/sensor/dist/resolution/tanstack-router-synthesizer.js +114 -0
  422. package/sensor/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  423. package/sensor/dist/resolution/tier-synthesizer.d.ts +54 -0
  424. package/sensor/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  425. package/sensor/dist/resolution/tier-synthesizer.js +1294 -0
  426. package/sensor/dist/resolution/tier-synthesizer.js.map +1 -0
  427. package/sensor/dist/resolution/types.d.ts +78 -2
  428. package/sensor/dist/resolution/types.d.ts.map +1 -1
  429. package/sensor/dist/resolution/types.js +64 -0
  430. package/sensor/dist/resolution/types.js.map +1 -1
  431. package/sensor/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  432. package/sensor/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  433. package/sensor/dist/resolution/vue-router-synthesizer.js +115 -0
  434. package/sensor/dist/resolution/vue-router-synthesizer.js.map +1 -0
  435. package/sensor/dist/search/identifier-segments.d.ts +10 -0
  436. package/sensor/dist/search/identifier-segments.d.ts.map +1 -1
  437. package/sensor/dist/search/identifier-segments.js +29 -0
  438. package/sensor/dist/search/identifier-segments.js.map +1 -1
  439. package/sensor/dist/search/query-paths.d.ts +106 -0
  440. package/sensor/dist/search/query-paths.d.ts.map +1 -0
  441. package/sensor/dist/search/query-paths.js +513 -0
  442. package/sensor/dist/search/query-paths.js.map +1 -0
  443. package/sensor/dist/search/query-utils.d.ts +22 -2
  444. package/sensor/dist/search/query-utils.d.ts.map +1 -1
  445. package/sensor/dist/search/query-utils.js +56 -16
  446. package/sensor/dist/search/query-utils.js.map +1 -1
  447. package/sensor/dist/sync/watch-policy.d.ts +14 -0
  448. package/sensor/dist/sync/watch-policy.d.ts.map +1 -1
  449. package/sensor/dist/sync/watch-policy.js +19 -0
  450. package/sensor/dist/sync/watch-policy.js.map +1 -1
  451. package/sensor/dist/sync/watcher.d.ts +74 -35
  452. package/sensor/dist/sync/watcher.d.ts.map +1 -1
  453. package/sensor/dist/sync/watcher.js +281 -99
  454. package/sensor/dist/sync/watcher.js.map +1 -1
  455. package/sensor/dist/telemetry/index.d.ts +4 -2
  456. package/sensor/dist/telemetry/index.d.ts.map +1 -1
  457. package/sensor/dist/telemetry/index.js +92 -41
  458. package/sensor/dist/telemetry/index.js.map +1 -1
  459. package/sensor/dist/types.d.ts +18 -2
  460. package/sensor/dist/types.d.ts.map +1 -1
  461. package/sensor/dist/types.js +2 -0
  462. package/sensor/dist/types.js.map +1 -1
  463. package/sensor/dist/ui-server/api/deadcode.d.ts +84 -0
  464. package/sensor/dist/ui-server/api/deadcode.d.ts.map +1 -0
  465. package/sensor/dist/ui-server/api/deadcode.js +136 -0
  466. package/sensor/dist/ui-server/api/deadcode.js.map +1 -0
  467. package/sensor/dist/ui-server/api/effects.d.ts +94 -0
  468. package/sensor/dist/ui-server/api/effects.d.ts.map +1 -0
  469. package/sensor/dist/ui-server/api/effects.js +527 -0
  470. package/sensor/dist/ui-server/api/effects.js.map +1 -0
  471. package/sensor/dist/ui-server/api/entrypoints.d.ts +92 -0
  472. package/sensor/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  473. package/sensor/dist/ui-server/api/entrypoints.js +361 -0
  474. package/sensor/dist/ui-server/api/entrypoints.js.map +1 -0
  475. package/sensor/dist/ui-server/api/events.d.ts +183 -0
  476. package/sensor/dist/ui-server/api/events.d.ts.map +1 -0
  477. package/sensor/dist/ui-server/api/events.js +430 -0
  478. package/sensor/dist/ui-server/api/events.js.map +1 -0
  479. package/sensor/dist/ui-server/api/file.d.ts +66 -0
  480. package/sensor/dist/ui-server/api/file.d.ts.map +1 -0
  481. package/sensor/dist/ui-server/api/file.js +235 -0
  482. package/sensor/dist/ui-server/api/file.js.map +1 -0
  483. package/sensor/dist/ui-server/api/filecode.d.ts +126 -0
  484. package/sensor/dist/ui-server/api/filecode.d.ts.map +1 -0
  485. package/sensor/dist/ui-server/api/filecode.js +205 -0
  486. package/sensor/dist/ui-server/api/filecode.js.map +1 -0
  487. package/sensor/dist/ui-server/api/flow.d.ts +226 -0
  488. package/sensor/dist/ui-server/api/flow.d.ts.map +1 -0
  489. package/sensor/dist/ui-server/api/flow.js +612 -0
  490. package/sensor/dist/ui-server/api/flow.js.map +1 -0
  491. package/sensor/dist/ui-server/api/hierarchy.d.ts +81 -0
  492. package/sensor/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  493. package/sensor/dist/ui-server/api/hierarchy.js +92 -0
  494. package/sensor/dist/ui-server/api/hierarchy.js.map +1 -0
  495. package/sensor/dist/ui-server/api/index.d.ts +90 -0
  496. package/sensor/dist/ui-server/api/index.d.ts.map +1 -0
  497. package/sensor/dist/ui-server/api/index.js +332 -0
  498. package/sensor/dist/ui-server/api/index.js.map +1 -0
  499. package/sensor/dist/ui-server/api/map.d.ts +256 -0
  500. package/sensor/dist/ui-server/api/map.d.ts.map +1 -0
  501. package/sensor/dist/ui-server/api/map.js +760 -0
  502. package/sensor/dist/ui-server/api/map.js.map +1 -0
  503. package/sensor/dist/ui-server/api/node.d.ts +81 -0
  504. package/sensor/dist/ui-server/api/node.d.ts.map +1 -0
  505. package/sensor/dist/ui-server/api/node.js +388 -0
  506. package/sensor/dist/ui-server/api/node.js.map +1 -0
  507. package/sensor/dist/ui-server/api/nodes.d.ts +25 -0
  508. package/sensor/dist/ui-server/api/nodes.d.ts.map +1 -0
  509. package/sensor/dist/ui-server/api/nodes.js +45 -0
  510. package/sensor/dist/ui-server/api/nodes.js.map +1 -0
  511. package/sensor/dist/ui-server/api/program.d.ts +139 -0
  512. package/sensor/dist/ui-server/api/program.d.ts.map +1 -0
  513. package/sensor/dist/ui-server/api/program.js +315 -0
  514. package/sensor/dist/ui-server/api/program.js.map +1 -0
  515. package/sensor/dist/ui-server/api/respond.d.ts +76 -0
  516. package/sensor/dist/ui-server/api/respond.d.ts.map +1 -0
  517. package/sensor/dist/ui-server/api/respond.js +186 -0
  518. package/sensor/dist/ui-server/api/respond.js.map +1 -0
  519. package/sensor/dist/ui-server/api/route-roots.d.ts +39 -0
  520. package/sensor/dist/ui-server/api/route-roots.d.ts.map +1 -0
  521. package/sensor/dist/ui-server/api/route-roots.js +96 -0
  522. package/sensor/dist/ui-server/api/route-roots.js.map +1 -0
  523. package/sensor/dist/ui-server/api/routes.d.ts +59 -0
  524. package/sensor/dist/ui-server/api/routes.d.ts.map +1 -0
  525. package/sensor/dist/ui-server/api/routes.js +108 -0
  526. package/sensor/dist/ui-server/api/routes.js.map +1 -0
  527. package/sensor/dist/ui-server/api/screens.d.ts +117 -0
  528. package/sensor/dist/ui-server/api/screens.d.ts.map +1 -0
  529. package/sensor/dist/ui-server/api/screens.js +611 -0
  530. package/sensor/dist/ui-server/api/screens.js.map +1 -0
  531. package/sensor/dist/ui-server/api/search.d.ts +29 -0
  532. package/sensor/dist/ui-server/api/search.d.ts.map +1 -0
  533. package/sensor/dist/ui-server/api/search.js +232 -0
  534. package/sensor/dist/ui-server/api/search.js.map +1 -0
  535. package/sensor/dist/ui-server/api/session.d.ts +52 -0
  536. package/sensor/dist/ui-server/api/session.d.ts.map +1 -0
  537. package/sensor/dist/ui-server/api/session.js +196 -0
  538. package/sensor/dist/ui-server/api/session.js.map +1 -0
  539. package/sensor/dist/ui-server/api/source.d.ts +200 -0
  540. package/sensor/dist/ui-server/api/source.d.ts.map +1 -0
  541. package/sensor/dist/ui-server/api/source.js +422 -0
  542. package/sensor/dist/ui-server/api/source.js.map +1 -0
  543. package/sensor/dist/ui-server/api/stats.d.ts +27 -0
  544. package/sensor/dist/ui-server/api/stats.d.ts.map +1 -0
  545. package/sensor/dist/ui-server/api/stats.js +164 -0
  546. package/sensor/dist/ui-server/api/stats.js.map +1 -0
  547. package/sensor/dist/ui-server/api/steps.d.ts +274 -0
  548. package/sensor/dist/ui-server/api/steps.d.ts.map +1 -0
  549. package/sensor/dist/ui-server/api/steps.js +1544 -0
  550. package/sensor/dist/ui-server/api/steps.js.map +1 -0
  551. package/sensor/dist/ui-server/api/trail-store.d.ts +142 -0
  552. package/sensor/dist/ui-server/api/trail-store.d.ts.map +1 -0
  553. package/sensor/dist/ui-server/api/trail-store.js +325 -0
  554. package/sensor/dist/ui-server/api/trail-store.js.map +1 -0
  555. package/sensor/dist/ui-server/api/trails.d.ts +163 -0
  556. package/sensor/dist/ui-server/api/trails.d.ts.map +1 -0
  557. package/sensor/dist/ui-server/api/trails.js +369 -0
  558. package/sensor/dist/ui-server/api/trails.js.map +1 -0
  559. package/sensor/dist/ui-server/api/when.d.ts +133 -0
  560. package/sensor/dist/ui-server/api/when.d.ts.map +1 -0
  561. package/sensor/dist/ui-server/api/when.js +275 -0
  562. package/sensor/dist/ui-server/api/when.js.map +1 -0
  563. package/sensor/dist/ui-server/api/wire.d.ts +179 -0
  564. package/sensor/dist/ui-server/api/wire.d.ts.map +1 -0
  565. package/sensor/dist/ui-server/api/wire.js +231 -0
  566. package/sensor/dist/ui-server/api/wire.js.map +1 -0
  567. package/sensor/dist/ui-server/assets.d.ts +40 -0
  568. package/sensor/dist/ui-server/assets.d.ts.map +1 -0
  569. package/sensor/dist/ui-server/assets.js +110 -0
  570. package/sensor/dist/ui-server/assets.js.map +1 -0
  571. package/sensor/dist/ui-server/constants.d.ts +32 -0
  572. package/sensor/dist/ui-server/constants.d.ts.map +1 -0
  573. package/sensor/dist/ui-server/constants.js +35 -0
  574. package/sensor/dist/ui-server/constants.js.map +1 -0
  575. package/sensor/dist/ui-server/highlight/index.d.ts +113 -0
  576. package/sensor/dist/ui-server/highlight/index.d.ts.map +1 -0
  577. package/sensor/dist/ui-server/highlight/index.js +307 -0
  578. package/sensor/dist/ui-server/highlight/index.js.map +1 -0
  579. package/sensor/dist/ui-server/highlight/languages.d.ts +36 -0
  580. package/sensor/dist/ui-server/highlight/languages.d.ts.map +1 -0
  581. package/sensor/dist/ui-server/highlight/languages.js +50 -0
  582. package/sensor/dist/ui-server/highlight/languages.js.map +1 -0
  583. package/sensor/dist/ui-server/index.d.ts +92 -0
  584. package/sensor/dist/ui-server/index.d.ts.map +1 -0
  585. package/sensor/dist/ui-server/index.js +399 -0
  586. package/sensor/dist/ui-server/index.js.map +1 -0
  587. package/sensor/dist/ui-server/open-browser.d.ts +31 -0
  588. package/sensor/dist/ui-server/open-browser.d.ts.map +1 -0
  589. package/sensor/dist/ui-server/open-browser.js +79 -0
  590. package/sensor/dist/ui-server/open-browser.js.map +1 -0
  591. package/sensor/dist/ui-server/security.d.ts +127 -0
  592. package/sensor/dist/ui-server/security.d.ts.map +1 -0
  593. package/sensor/dist/ui-server/security.js +332 -0
  594. package/sensor/dist/ui-server/security.js.map +1 -0
  595. package/sensor/dist/ui-server/static.d.ts +45 -0
  596. package/sensor/dist/ui-server/static.d.ts.map +1 -0
  597. package/sensor/dist/ui-server/static.js +165 -0
  598. package/sensor/dist/ui-server/static.js.map +1 -0
  599. package/sensor/dist/utils.d.ts +14 -2
  600. package/sensor/dist/utils.d.ts.map +1 -1
  601. package/sensor/dist/utils.js +25 -10
  602. package/sensor/dist/utils.js.map +1 -1
  603. package/src/cli-help.mjs +4 -2
  604. package/src/sensor-adapter.mjs +5 -1
  605. package/src/todo-cli.mjs +88 -11
@@ -0,0 +1,1544 @@
1
+ "use strict";
2
+ /**
3
+ * `GET /api/steps` — what happens from here: a screen, a handler or any
4
+ * symbol as the ANCHOR, and everything it sets in motion drawn as typed steps.
5
+ *
6
+ * The Screens view (`screens.ts`) is already a picture of steps with one step
7
+ * type: it folds `HomeScreen → ItemsGrid → ItemCard → openObjectDetail` into
8
+ * one arrow labelled with its condition, because the reader wants the
9
+ * transition, not the plumbing. This endpoint keeps that fold and widens the
10
+ * set of things worth a box. Walking FORWARD from the anchor over calls,
11
+ * renders, handler bindings and navigations, a node is a step when it is:
12
+ *
13
+ * - a **screen** (a route reached over a `navigates` edge),
14
+ * - a **trigger** — a function wired as a value (`onPress={handleX}`,
15
+ * `addListener('x', handleX)`), the user's or the platform's way in,
16
+ * - a **bridge** call — the language changes under the call, JS → native
17
+ * (the React Native bridge resolver's edges, or any family crossing),
18
+ * - a native **event** landing back in JS (`sendEvent(withName:)` → the
19
+ * listener, via the RN event channel),
20
+ * - a **store** action — a function in a store file, the state it writes,
21
+ * - an **effect** — a call that leaves the index into the network, storage,
22
+ * the device or telemetry, drawn as its own box beside the function that
23
+ * makes it.
24
+ *
25
+ * Everything else — hooks, helpers, services, the components between a
26
+ * screen and its handlers — is `via`: listed on the link, never a box. The
27
+ * branch conditions along the folded chain join into the link's `when`, read
28
+ * from the source at request time exactly as the Screens view reads them.
29
+ *
30
+ * The picture is finite because it is ANCHORED and CAPPED, not because the
31
+ * graph is small: a bounded depth in steps, a bounded fan-out per node, a
32
+ * bounded number of nodes folded per step, and hubs and shared chrome (a top
33
+ * bar rendered on ten screens) are dead ends rather than paths. Every cap
34
+ * that fired is reported on the step it fired at, so a short picture never
35
+ * reads as "nothing else happens here".
36
+ *
37
+ * Read from the graph at request time, never cached: the `when` labels and
38
+ * the effect sites are read from the source as it stands.
39
+ */
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.STORE_FILE = exports.MAX_LIMIT = exports.DEFAULT_LIMIT = exports.MAX_DEPTH = exports.DEFAULT_DEPTH = void 0;
42
+ exports.crossing = crossing;
43
+ exports.isStoreFile = isStoreFile;
44
+ exports.effectCategory = effectCategory;
45
+ exports.buildSteps = buildSteps;
46
+ exports.projectKind = projectKind;
47
+ const respond_1 = require("./respond");
48
+ const when_1 = require("./when");
49
+ const program_1 = require("./program");
50
+ const effects_1 = require("./effects");
51
+ const branch_guards_1 = require("../../graph/branch-guards");
52
+ const route_roots_1 = require("./route-roots");
53
+ const nextjs_1 = require("../../resolution/frameworks/nextjs");
54
+ const routes_1 = require("./routes");
55
+ const wire_1 = require("./wire");
56
+ const query_utils_1 = require("../../search/query-utils");
57
+ // =============================================================================
58
+ // Caps
59
+ // =============================================================================
60
+ exports.DEFAULT_DEPTH = 8;
61
+ exports.MAX_DEPTH = 14;
62
+ exports.DEFAULT_LIMIT = 120;
63
+ exports.MAX_LIMIT = 400;
64
+ /** Nodes folded while exploring from ONE step before the walk stops. */
65
+ const MAX_FOLDED_PER_STEP = 300;
66
+ /** Hops of folded plumbing between two steps. */
67
+ const MAX_FOLD_DEPTH = 7;
68
+ /** Outgoing edges followed from one node; past this the node is a god function and the rest is announced. */
69
+ const MAX_FANOUT = 80;
70
+ /** Unresolved-reference scans (for effects) per request. */
71
+ const MAX_EFFECT_SCANS = 800;
72
+ /** Call sites read for conditions and arguments per request. */
73
+ const MAX_WHEN_SITES = 1600;
74
+ /** Call sites read for the callee as written (effect classification) per request — lookups on trees the guards parsed anyway. */
75
+ const MAX_CALL_SITES = 4000;
76
+ /** Longest effect-box label before its argument list is cut. */
77
+ const MAX_EFFECT_LABEL = 56;
78
+ /**
79
+ * A component rendered by this many distinct parents is chrome (a top bar, a
80
+ * button), not a screen's own behaviour. Higher than the Screens view's 3: that
81
+ * one attributes navigations, where three screens sharing a link is already
82
+ * chrome; this one decides what to WALK INTO, and a capture component shared
83
+ * by three capture flows is the screen's whole body.
84
+ */
85
+ const SHARED_CHROME_MIN = 5;
86
+ /** Edges walked forward. `contains` only function → function (a hook's handlers); `references` only function-as-value. */
87
+ const WALK_KINDS = ['calls', 'instantiates', 'navigates', 'references', 'contains'];
88
+ // =============================================================================
89
+ // Classification
90
+ // =============================================================================
91
+ const JS_FAMILY = new Set(['javascript', 'typescript', 'tsx', 'jsx']);
92
+ const NATIVE_FAMILY = new Set(['swift', 'objc', 'java', 'kotlin']);
93
+ /**
94
+ * JS → native is a bridge call; native → JS is an event. Anything else is one
95
+ * family — unless the edge itself says which way it crosses: a synthesized
96
+ * channel (`resolution/tier-synthesizer.ts`) marks a client's request onto its
97
+ * own route `client→server`, a socket message back `server→client`, and a
98
+ * queue job or a bus event as a `channel` whose landing is an arrival; a
99
+ * server action called from a client file is marked `client→server` at
100
+ * request time, by its directive.
101
+ */
102
+ function crossing(from, to, meta = {}) {
103
+ if (meta.tier === 'client→server')
104
+ return 'bridge';
105
+ if (meta.tier === 'server→client')
106
+ return 'event';
107
+ if (meta.channel === 'queue' || meta.channel === 'event' || meta.channel === 'socket')
108
+ return 'event';
109
+ if (JS_FAMILY.has(from) && NATIVE_FAMILY.has(to))
110
+ return 'bridge';
111
+ if (NATIVE_FAMILY.has(from) && JS_FAMILY.has(to))
112
+ return 'event';
113
+ return null;
114
+ }
115
+ /**
116
+ * A file that holds state: a store, a slice, a reducer. The graph has no
117
+ * "store" kind — a Zustand action is an ordinary function node — so the file
118
+ * is the evidence, and the legend says so.
119
+ */
120
+ exports.STORE_FILE = /(?:^|\/)(?:stores?|storage|state|slices?|reducers?)\/|\.(?:store|storage|slice|reducer)\.[cm]?[jt]sx?$/i;
121
+ function isStoreFile(file) {
122
+ return exports.STORE_FILE.test(file.replace(/\\/g, '/'));
123
+ }
124
+ /**
125
+ * What a call is when it leaves the index, by the reference text alone — the
126
+ * mobile app's table, kept for callers that have no language in hand. The
127
+ * Steps walk itself classifies on the call AS WRITTEN with the language and
128
+ * the project kind (`effects.ts`).
129
+ */
130
+ function effectCategory(referenceName) {
131
+ return (0, effects_1.classifyEffect)({ text: referenceName, kind: 'calls' })?.category ?? null;
132
+ }
133
+ /** A method of a repository / DAO / mapper, by the container's name — the ORM boundary in a project that types it. */
134
+ const REPOSITORY_CONTAINER = /(?:Repository|Repositories|Repo|Dao|DAO|Mapper|Store|Datastore)$/;
135
+ /** Decorators that gate a handler: guards, interceptors, pipes, roles, auth, validation, transactions, throttles. */
136
+ const GUARD_DECORATOR = /^(?:UseGuards|UseInterceptors|UsePipes|UseFilters|Roles|Auth|Public|Permissions|Throttle|SkipThrottle|Authorize|AllowAnonymous|PreAuthorize|PostAuthorize|Secured|RolesAllowed|PermitAll|DenyAll|Transactional|Validated|login_required|permission_required|user_passes_test|staff_member_required|require_http_methods|require_POST|require_GET|csrf_exempt|csrf_protect|ratelimit|throttle_classes|permission_classes|authentication_classes|cache_page|ValidateAntiForgeryToken|RequireAuthorization|RequireRole|RequireHttps|EnableCors|CrossOrigin|Cacheable|CacheEvict|CachePut|RateLimiter|CircuitBreaker|Retry|Timeout|Bulkhead|jwt_required|Security|ApiBearerAuth|ApiKeyAuth|BearerAuth|OAuth|Scopes|Roles|HasRole|HasPermission|Idempotent|Lock|Locked|Retryable|Recover)$|Guard|Interceptor|Pipe$|Filter$|Auth|Role|Permission|Throttle|Valid|Transaction|Csrf|Limit/i;
137
+ /** Decorators that ARE the route, the DI wiring, or documentation — never a guard. */
138
+ const NOT_A_GUARD = /^(?:Get|Post|Put|Patch|Delete|Head|Options|All|Controller|RestController|Resolver|Query|Mutation|Subscription|Injectable|Module|Api\w*|Http(?:Get|Post|Put|Patch|Delete|Head|Options)|Route|RequestMapping|\w+Mapping|Component|Service|Repository|Bean|Autowired|Override|Inject|Param|Body|Res|Req|Headers|Ip|HostParam|Session|UploadedFiles?|HttpCode|Header|Redirect|Render|Version|SerializeOptions|ResponseBody|ResponseStatus|Produces|Consumes|FromBody|FromRoute|FromQuery|FromForm|FromHeader|FromServices|Path|PathVariable|RequestParam|RequestBody|RequestHeader|ModelAttribute|Valid|Args|Context|Parent|Info|Field|ObjectType|InputType|ArgsType|Entity|Column|PrimaryGeneratedColumn|OneToMany|ManyToOne|Prop|Schema|Type|Expose|Exclude|Transform|IsString|IsNumber|IsOptional|Length|Min|Max|Deprecated|SuppressWarnings|FunctionalInterface|Slf4j|Data|Builder|Getter|Setter|NoArgsConstructor|AllArgsConstructor|RequiredArgsConstructor|Value|ConfigurationProperties|Configuration|EnableScheduling|SpringBootApplication|Profile|Order|Primary|Qualifier|Lazy|Scope|JsonProperty|JsonIgnore|Nullable|NonNull|NotNull|Size|Pattern|Email|Positive|router\.\w+|app\.\w+|api\.\w+|bp\.\w+|blueprint\.\w+|\w+\.(?:route|get|post|put|patch|delete))$/;
139
+ /** Decorators that fire a function from outside a request: a job, an event, a message, a schedule. */
140
+ const CONSUMER_DECORATOR = /^(?:Process|Processor|OnEvent|OnQueueEvent|OnWorkerEvent|OnGlobalQueueEvent|Cron|Interval|Timeout|MessagePattern|EventPattern|SubscribeMessage|Scheduled|Schedules?|KafkaListener|RabbitListener|RabbitSubscribe|RabbitRPC|JmsListener|SqsListener|SqsMessageHandler|EventListener|TransactionalEventListener|StreamListener|ServiceActivator|receiver|shared_task|task|periodic_task|app\.task|celery\.task|on|hears|command|event|listen|listener|Consume|Consumer|Subscribe|Subscriber|CapSubscribe|Function|FunctionName|TimerTrigger|QueueTrigger|ServiceBusTrigger|EventGridTrigger|BlobTrigger|CosmosDBTrigger|Job|job|Worker|worker|EventHandler|CommandHandler|QueryHandler|OnMessage|MessageHandler|GrpcMethod|GrpcStreamMethod|WebSocketGateway|dramatiq\.actor|actor|huey\.task|db_task|Signal|signal|hook|Hook|OnModuleInit|OnApplicationBootstrap|PostConstruct|PreDestroy|Bean|Startup|Shutdown)$/;
141
+ /** The name of a decorator, before its arguments. */
142
+ function decoratorName(text) {
143
+ return text.replace(/\(.*$/s, '').trim();
144
+ }
145
+ /** The first string literal in a decorator's arguments — `'email'` of `@Process('email')`. */
146
+ function decoratorLiteral(text) {
147
+ const m = /\(\s*(['"`])((?:(?!\1).)*)\1/.exec(text);
148
+ return m ? `'${m[2]}'` : null;
149
+ }
150
+ function isGuardDecorator(text) {
151
+ const name = decoratorName(text);
152
+ if (NOT_A_GUARD.test(name))
153
+ return false;
154
+ return GUARD_DECORATOR.test(name);
155
+ }
156
+ /** FastAPI: `dependencies=[Depends(auth), Depends(rate_limit)]` inside the route decorator. */
157
+ function dependenciesIn(text) {
158
+ const m = /dependencies\s*=\s*\[([^\]]*)\]/.exec(text);
159
+ if (!m)
160
+ return [];
161
+ return m[1].split(/,(?![^()]*\))/).map((x) => x.trim()).filter(Boolean);
162
+ }
163
+ /**
164
+ * The string a Java / Kotlin return expression builds, when it starts with a
165
+ * literal: `"owners/ownerDetails"`, `"redirect:/owners/" + owner.getId()` →
166
+ * `redirect:/owners/${…}`. Null for anything else — a variable, a call.
167
+ */
168
+ function springViewString(expression) {
169
+ let out = '';
170
+ let rest = expression.trim();
171
+ let first = true;
172
+ while (rest.length > 0) {
173
+ const lit = /^"((?:[^"\\]|\\.)*)"/.exec(rest);
174
+ if (lit) {
175
+ out += lit[1].replace(/\$\{[^}]*\}|\$\w+/g, '${…}');
176
+ rest = rest.slice(lit[0].length).trim();
177
+ }
178
+ else {
179
+ if (first)
180
+ return null;
181
+ const operand = /^[^+]+/.exec(rest);
182
+ out += '${…}';
183
+ rest = rest.slice(operand ? operand[0].length : rest.length).trim();
184
+ }
185
+ first = false;
186
+ if (rest.startsWith('+'))
187
+ rest = rest.slice(1).trim();
188
+ else
189
+ break;
190
+ }
191
+ return first ? null : out;
192
+ }
193
+ async function buildSteps(cg, projectRoot, query) {
194
+ const started = Date.now();
195
+ const depthCap = (0, respond_1.intParam)(query, 'depth', { min: 1, max: exports.MAX_DEPTH, default: exports.DEFAULT_DEPTH });
196
+ const limit = (0, respond_1.intParam)(query, 'limit', { min: 20, max: exports.MAX_LIMIT, default: exports.DEFAULT_LIMIT });
197
+ const through = query.get('through') === '1';
198
+ const stats = cg.getStats();
199
+ const index = { lastIndexedAt: cg.getLastIndexedAt() ?? null, edges: stats.edgeCount, files: stats.fileCount };
200
+ const { anchor, ambiguous } = resolveAnchor(cg, query);
201
+ // Route → where its code starts: the handler a resolver named, the page a
202
+ // screen file exports, or the route itself standing in for an inline
203
+ // handler (`route-roots.ts`) — and what kind of project this is, for the
204
+ // words the viewer uses.
205
+ const routes = cg.getNodesByKind('route');
206
+ const roots = (0, route_roots_1.routeRoots)(cg, routes);
207
+ const project = projectKind(routes, stats.edgesByKind?.navigates ?? 0);
208
+ const reader = (0, when_1.createSiteReader)(cg, projectRoot, MAX_WHEN_SITES);
209
+ const calls = (0, when_1.createSiteReader)(cg, projectRoot, MAX_CALL_SITES);
210
+ /** The conditions a site runs under, structured — one read, joined where a string is wanted. */
211
+ const guardsAt = (caller, site) => reader.guards(caller, site);
212
+ /** The loops a site is written inside — a run of calls that happens once per item. */
213
+ const loopsAt = (caller, site) => reader.loops(caller, site);
214
+ const argsAt = (caller, site) => reader.args(caller, site);
215
+ const withArgs = async (site, caller, at) => {
216
+ const args = await argsAt(caller, at);
217
+ return args === null ? site : { ...site, args };
218
+ };
219
+ /** The call as written at a site, and what it passes — one read for both. */
220
+ const callAt = (caller, site) => calls.callSite(caller, site);
221
+ /** A hop's position with its call's span and enclosing call, read from the tree; the bare position when unreadable. */
222
+ const hopAt = async (caller, at, callee) => {
223
+ const line = at.line ?? caller.startLine;
224
+ const column = at.column ?? 0;
225
+ const read = at.line ? await callAt(caller, { ...at, ...(callee ? { callee } : {}) }) : null;
226
+ // The read must be THIS call. An inline handler's edges carry the ROUTE's
227
+ // line (`router.post('/users/login', async (req, res) => {`), where the
228
+ // only call is the registration itself — and taking its span would make
229
+ // every call in the handler read as written inside it, and so as running
230
+ // first. A miss is a bare position: no span to nest by, no `within`.
231
+ const last = (n) => n.replace(/\([^()]*\)/g, '').split(/[.:]/).pop() ?? n;
232
+ const usable = read !== null && (!callee || last(read.callee) === last(callee));
233
+ if (!usable)
234
+ return { file: caller.filePath, line, column, end: { line, column }, within: null };
235
+ return {
236
+ file: caller.filePath,
237
+ line: read.span?.start.line ?? line,
238
+ column: read.span?.start.column ?? column,
239
+ end: read.span?.end ?? { line, column },
240
+ within: read.within ?? null,
241
+ };
242
+ };
243
+ const pointHop = (caller, at) => {
244
+ const line = at.line ?? caller.startLine;
245
+ const column = at.column ?? 0;
246
+ return { file: caller.filePath, line, column, end: { line, column }, within: null };
247
+ };
248
+ // The declared type of a receiver: `OwnerRepository owners` in a Spring
249
+ // controller makes `owners.save` the database; `private readonly
250
+ // usersService: UsersService` in a Nest controller says where
251
+ // `this.usersService.findByEmail` goes. The index keeps the first in a
252
+ // field's signature and nothing of the second, so the class body is read
253
+ // from the tree at request time, once per class.
254
+ const fileTypes = new Map();
255
+ const classTypes = new Map();
256
+ const receiverTypeFor = async (caller, callee) => {
257
+ const first = callee.replace(/^(?:this|self)\./, '').split(/[.:(]/)[0] ?? '';
258
+ if (!first || /^[A-Z]/.test(first))
259
+ return null;
260
+ const declared = await memberTypesOf(caller);
261
+ const own = declared.get(first) ?? declared.get(first.replace(/^_/, '')) ?? null;
262
+ if (own)
263
+ return own;
264
+ let types = fileTypes.get(caller.filePath);
265
+ if (!types) {
266
+ types = new Map();
267
+ for (const n of cg.getNodesInFile(caller.filePath)) {
268
+ if ((n.kind !== 'field' && n.kind !== 'property' && n.kind !== 'variable' && n.kind !== 'parameter') || !n.signature)
269
+ continue;
270
+ const sig = n.signature.replace(/\s+/g, ' ').trim();
271
+ // `OwnerRepository owners`, `private final OwnerRepository owners`, `owners: OwnerRepository`, `val owners: OwnerRepository`.
272
+ const typed = new RegExp(`(?:^|\\s)([A-Z][\\w<>,?. ]*?)\\s+${n.name}\\b`).exec(sig) ?? new RegExp(`\\b${n.name}\\s*:\\s*([A-Z][\\w<>,?. ]*)`).exec(sig);
273
+ if (typed && !types.has(n.name))
274
+ types.set(n.name, typed[1].trim());
275
+ }
276
+ fileTypes.set(caller.filePath, types);
277
+ }
278
+ return types.get(first) ?? null;
279
+ };
280
+ const memberTypesOf = async (node) => {
281
+ const key = `${node.filePath}:${node.startLine}`;
282
+ let types = classTypes.get(key);
283
+ if (!types) {
284
+ types = await calls.memberTypes(node);
285
+ classTypes.set(key, types);
286
+ }
287
+ return types;
288
+ };
289
+ // Where a member call really goes, by the receiver's declared type: the
290
+ // class named by the type, and its method of the call's name. Null when the
291
+ // type names nothing in the index (an ORM's `Repository<Cat>`) — then the
292
+ // call leaves the index, and the effect table says as what.
293
+ const classByName = new Map();
294
+ /** The class / interface / struct a declared type names in the index, or null for a library's. */
295
+ const classOfType = async (type) => {
296
+ const typeName = type.replace(/<.*$/, '').replace(/^[*&]+/, '').replace(/[?!]$/, '').split(/[.:]/).pop()?.trim() ?? '';
297
+ if (!typeName || /^(?:string|number|boolean|any|unknown|object|void|String|Integer|Long|Boolean|int|long|bool|var|dynamic|Object|List|Map|Set|Array|Promise|Optional|Task|IEnumerable|Iterable)$/.test(typeName))
298
+ return null;
299
+ let cls = classByName.get(typeName);
300
+ if (cls === undefined) {
301
+ const found = cg.getNodesByName(typeName).filter((n) => n.kind === 'class' || n.kind === 'interface' || n.kind === 'struct');
302
+ cls = found.find((n) => !(0, query_utils_1.isTestPath)(n.filePath)) ?? found[0] ?? null;
303
+ classByName.set(typeName, cls);
304
+ }
305
+ return cls;
306
+ };
307
+ // Swift has no per-symbol imports: a type the project declares shadows the
308
+ // SDK name the effect table keys on — IceCubesApp's `Notifications`
309
+ // endpoint enum is not expo-notifications. An `extension Timer {}` declares
310
+ // nothing, so it does not count.
311
+ const projectTypes = new Map();
312
+ const declaresSwiftType = async (callee) => {
313
+ const root = callee.replace(/^(?:self|Self)\./, '').split(/[.(:<]/)[0] ?? '';
314
+ if (!/^[A-Z]\w*$/.test(root))
315
+ return false;
316
+ let known = projectTypes.get(root);
317
+ if (known === undefined) {
318
+ known = false;
319
+ for (const n of cg.getNodesByName(root)) {
320
+ if (n.language !== 'swift' || !['class', 'struct', 'enum', 'interface', 'protocol'].includes(n.kind))
321
+ continue;
322
+ if (!(await reader.swiftExtension(n))) {
323
+ known = true;
324
+ break;
325
+ }
326
+ }
327
+ projectTypes.set(root, known);
328
+ }
329
+ return known;
330
+ };
331
+ const resolveByReceiver = async (caller, callee) => {
332
+ const segments = callee.replace(/\([^()]*\)/g, '').split(/[.:]+/).filter(Boolean);
333
+ if (segments.length < 2)
334
+ return null;
335
+ const type = await receiverTypeFor(caller, callee);
336
+ if (!type)
337
+ return null;
338
+ const cls = await classOfType(type);
339
+ if (!cls)
340
+ return null;
341
+ const method = segments[segments.length - 1];
342
+ const members = cg.getNodesInFile(cls.filePath).filter((n) => (n.kind === 'method' || n.kind === 'function') && n.name === method && n.startLine >= cls.startLine && n.endLine <= cls.endLine);
343
+ return members[0] ?? null;
344
+ };
345
+ /**
346
+ * A name-match that the call as written disproves: the target is a method of
347
+ * the CALLER's own class, but the call names a receiver that is not `this` —
348
+ * and in the JS family a method of your own class cannot be called any other
349
+ * way. Only there: `self.` is a convention elsewhere, not a rule.
350
+ */
351
+ const ownMethodWithoutReceiver = (caller, target, written) => {
352
+ if (!JS_FAMILY.has(caller.language) || target.kind !== 'method')
353
+ return false;
354
+ if (/^(?:this|self)[.?]/.test(written))
355
+ return false;
356
+ const container = (q) => q.replace(/[.:]+[^.:]*$/, '');
357
+ return caller.filePath === target.filePath && container(caller.qualifiedName) === container(target.qualifiedName);
358
+ };
359
+ /** A method the walk cannot enter (an interface's, an ORM's) on a repository-shaped container. */
360
+ const repositoryMethod = (target) => {
361
+ if (target.kind !== 'method' && target.kind !== 'function')
362
+ return false;
363
+ if ((0, query_utils_1.isTestPath)(target.filePath))
364
+ return false;
365
+ const container = target.qualifiedName.replace(/[.:]+[^.:]*$/, '').split(/[.:]+/).pop() ?? '';
366
+ if (!REPOSITORY_CONTAINER.test(container) && !/(?:^|\/)(?:repositories|repository|dao|daos|mappers)\//i.test(posix(target.filePath)))
367
+ return false;
368
+ return cg.getOutgoingEdgesFrom([target.id], WALK_KINDS).length === 0;
369
+ };
370
+ /** What runs before a route's handler: the middleware arguments at the registration, or the guard decorators on it. */
371
+ const chainFor = async (route, root) => {
372
+ const after = [];
373
+ if (JS_FAMILY.has(route.language)) {
374
+ const site = await calls.callSite(route, { line: route.startLine, column: 0 });
375
+ if (site && /\.(?:get|post|put|patch|delete|all|use|head|options|route)$/i.test(site.callee)) {
376
+ const args = site.argList.slice(1);
377
+ if (args.length > 0 && !/^\{/.test(args[args.length - 1]))
378
+ args.pop();
379
+ for (const a of args)
380
+ if (a && !/^\{ ?…? ?\}$/.test(a))
381
+ after.push(a);
382
+ }
383
+ }
384
+ if (root && root.id !== route.id) {
385
+ const decs = await calls.decorators(root);
386
+ if (decs) {
387
+ for (const d of [...decs.class, ...decs.own]) {
388
+ if (!JS_FAMILY.has(root.language) && !/^(?:python)$/.test(root.language)) {
389
+ if (isGuardDecorator(d))
390
+ after.push(d);
391
+ continue;
392
+ }
393
+ for (const dep of dependenciesIn(d))
394
+ after.push(dep);
395
+ if (isGuardDecorator(d))
396
+ after.push(d);
397
+ }
398
+ }
399
+ }
400
+ return [...new Set(after)];
401
+ };
402
+ /** The request a route's handler serves, as its trigger; a Next page's own work fires from its load. */
403
+ const requestTrigger = async (route, root) => {
404
+ const { method, path } = (0, routes_1.splitRouteName)(route.name);
405
+ if (method === null) {
406
+ if ((0, nextjs_1.nextRouteForFile)(route.filePath)?.kind === 'page')
407
+ return { kind: 'load', name: 'GET', of: path, in: basename(route.filePath) };
408
+ return null;
409
+ }
410
+ const after = await chainFor(route, root);
411
+ return { kind: 'request', name: method, of: path, in: basename(route.filePath), ...(after.length > 0 ? { after } : {}) };
412
+ };
413
+ /** A job, an event, a message or a schedule that fires a function, from its decorators. */
414
+ const consumerTrigger = async (node) => {
415
+ if (node.kind !== 'function' && node.kind !== 'method')
416
+ return null;
417
+ const decs = await calls.decorators(node);
418
+ if (!decs)
419
+ return null;
420
+ for (const d of decs.own) {
421
+ const name = decoratorName(d);
422
+ const last = name.split('.').pop() ?? name;
423
+ if (!CONSUMER_DECORATOR.test(name) && !CONSUMER_DECORATOR.test(last))
424
+ continue;
425
+ const guards = [...decs.class, ...decs.own].filter((x) => x !== d && isGuardDecorator(x));
426
+ return { kind: 'decorator', name, of: decoratorLiteral(d), in: basename(node.filePath), ...(guards.length > 0 ? { after: guards } : {}) };
427
+ }
428
+ return null;
429
+ };
430
+ /**
431
+ * The decision a site's innermost condition belongs to. The innermost guard
432
+ * is the one decided AT the call — the ternary whose two arms return two
433
+ * different routes — while the ones outside it are the context both arms
434
+ * share, so it is the innermost that says which way this site went.
435
+ */
436
+ const decisionOf = (guards) => {
437
+ const g = guards[guards.length - 1];
438
+ if (!g || !g.branch)
439
+ return null;
440
+ // A one-sided guard (`if (!product) throw`) is a guard clause, not a
441
+ // choice with two drawn ways; it keeps its condition on the line.
442
+ if (g.form === 'guard')
443
+ return null;
444
+ return {
445
+ branch: g.branch,
446
+ on: (0, branch_guards_1.guardLabel)([{ ...g, negated: false }]),
447
+ arm: (0, branch_guards_1.guardLabel)([g]),
448
+ form: g.form === 'case' ? 'switch' : g.form === 'ternary' ? 'ternary' : g.form === 'catch' ? 'try' : 'if',
449
+ ...(g.negated ? { not: true } : {}),
450
+ };
451
+ };
452
+ const steps = new Map();
453
+ const links = new Map();
454
+ /**
455
+ * What happens in each function, in the code's own order — the rail's
456
+ * material, recorded by the SAME pass that makes the links so the two
457
+ * readings can never hold different steps. Keyed by the function's node id,
458
+ * then by the site's position and what it reaches: a helper folded from two
459
+ * different steps is walked twice and must not be written twice.
460
+ */
461
+ const programs = new Map();
462
+ const record = (fn, hop, guards, what, trigger = null, loops = []) => {
463
+ let sites = programs.get(fn.id);
464
+ if (!sites) {
465
+ sites = new Map();
466
+ programs.set(fn.id, sites);
467
+ }
468
+ const key = `${hop.line}:${hop.column}:${what.step ?? what.into ?? ''}`;
469
+ if (sites.has(key))
470
+ return;
471
+ sites.set(key, {
472
+ ...what,
473
+ at: { line: hop.line, column: hop.column, end: hop.end },
474
+ ...(hop.within ? { within: hop.within } : {}),
475
+ guards: [...guards],
476
+ ...(loops.length > 0 ? { loops: [...loops] } : {}),
477
+ ...(trigger ? { trigger } : {}),
478
+ });
479
+ };
480
+ const truncated = { steps: 0, hubs: 0, chrome: 0 };
481
+ let effectScans = 0;
482
+ const fanIn = new Map();
483
+ const chromeParents = new Map();
484
+ const fileScopeRefs = new Map();
485
+ const fileScopeUnresolved = new Map();
486
+ /**
487
+ * The spans of the calls that became effect steps, per function — and the
488
+ * step a binding written inside one arrives from. `Alert.prompt('Add
489
+ * Folder', …, [{ onPress: (name) => createBackgroundFolder(name) }])` is
490
+ * two facts: the prompt is a device box, and the prompt's button FIRES the
491
+ * handler — so the handler's line belongs to the prompt, not to the screen
492
+ * the prompt is written on, which fires everything and says nothing. A site
493
+ * is rewired only when its own trigger names the call (`onPress ·
494
+ * Alert.prompt(…)`) and its position falls inside that call's span in the
495
+ * same function; the innermost such span wins. An `onSubmit · useFormik(…)`
496
+ * names no effect and stays where it was.
497
+ */
498
+ const firedSpans = new Map();
499
+ const firedByEffect = (fnId, at, of) => {
500
+ if (at.line === undefined)
501
+ return null;
502
+ const spans = firedSpans.get(fnId);
503
+ if (!spans)
504
+ return null;
505
+ const last = (n) => n.replace(/\([^()]*\)/g, '').split(/[.:]/).pop() ?? n;
506
+ const want = last(of);
507
+ const line = at.line;
508
+ const column = at.column ?? 0;
509
+ let best = null;
510
+ for (const s of spans) {
511
+ if (line < s.start.line || line > s.end.line)
512
+ continue;
513
+ if (line === s.start.line && column < s.start.column)
514
+ continue;
515
+ if (line === s.end.line && column > s.end.column)
516
+ continue;
517
+ if (!s.step.effect?.apis.some((api) => last(api) === want))
518
+ continue;
519
+ if (best === null || s.start.line > best.start.line || (s.start.line === best.start.line && s.start.column > best.start.column)) {
520
+ best = s;
521
+ }
522
+ }
523
+ return best?.step ?? null;
524
+ };
525
+ const stepFor = (node, kind, depth, extra = {}) => {
526
+ const existing = steps.get(node.id);
527
+ if (existing) {
528
+ // A listener the screen registers is a handler when first met, and the
529
+ // native event's landing when the walk arrives from the other side —
530
+ // the second is the fuller fact, and it names the event.
531
+ if (existing.kind === 'trigger' && kind === 'event') {
532
+ existing.kind = 'event';
533
+ if (extra.event)
534
+ existing.event = extra.event;
535
+ }
536
+ if (kind === 'event' && extra.event) {
537
+ existing.events = existing.events ?? (existing.event ? [existing.event] : []);
538
+ if (!existing.events.includes(extra.event))
539
+ existing.events.push(extra.event);
540
+ }
541
+ return existing;
542
+ }
543
+ if (steps.size >= limit) {
544
+ truncated.steps++;
545
+ return null;
546
+ }
547
+ const isRoute = node.kind === 'route';
548
+ const routeRoot = isRoute ? (roots.get(node.id) ?? null) : null;
549
+ const record = {
550
+ id: node.id,
551
+ // A route is a screen or an endpoint — except one reached across a
552
+ // tier (`fetch('/api/users')` onto its own route), which is the crossing.
553
+ kind: isRoute && kind !== 'bridge' ? 'screen' : kind,
554
+ anchor: false,
555
+ node: (0, wire_1.toNodeRef)(node),
556
+ label: node.name,
557
+ // A screen says its component, an endpoint its handler; a route the
558
+ // graph bound to nothing says only where it is registered.
559
+ sub: isRoute
560
+ ? routeRoot === null
561
+ ? basename(node.filePath)
562
+ : routeRoot.inline
563
+ ? `inline handler · ${basename(node.filePath)}`
564
+ : routeRoot.node.name
565
+ : posix(node.filePath),
566
+ depth,
567
+ cut: null,
568
+ ...extra,
569
+ root: isRoute ? (routeRoot?.node ?? null) : node,
570
+ };
571
+ if (kind === 'event' && extra.event)
572
+ record.events = [extra.event];
573
+ if (isRoute) {
574
+ record.screen = {
575
+ path: node.name,
576
+ component: routeRoot !== null && !routeRoot.inline ? (0, wire_1.toNodeRef)(routeRoot.node) : null,
577
+ endpoint: (0, routes_1.splitRouteName)(node.name).method !== null,
578
+ inline: routeRoot?.inline ?? false,
579
+ };
580
+ }
581
+ steps.set(node.id, record);
582
+ return record;
583
+ };
584
+ // One box per (function, category): `uploadARCapture` makes one network
585
+ // call, three storage calls and three telemetry calls — three boxes, each
586
+ // listing its calls, not seven. A reply is the exception: its identity is
587
+ // the outcome, so `authUser` answering 200 or 401 is two boxes — each
588
+ // line into them then carries its own condition on the picture, the
589
+ // Screens view's idiom — and the sites whose status cannot be read share
590
+ // one `response` box labelled by the call.
591
+ const effectSub = (e, by) => [e.category, e.model, e.access, by.name].filter((x) => !!x).join(' · ');
592
+ const effectStep = (by, ref, effect, depth, status = null) => {
593
+ const category = effect.category;
594
+ const id = status !== null ? `effect:${by.id}:${category}:${status}` : `effect:${by.id}:${category}`;
595
+ const existing = steps.get(id);
596
+ if (existing) {
597
+ const e = existing.effect;
598
+ if (!e.apis.includes(ref.referenceName)) {
599
+ e.apis.push(ref.referenceName);
600
+ existing.label = `${e.apis[0]} +${e.apis.length - 1}`;
601
+ }
602
+ // Several models behind one box: list them; several accesses: say both.
603
+ if (effect.model && e.model !== effect.model) {
604
+ const models = new Set((e.model ?? '').split(', ').filter(Boolean));
605
+ models.add(effect.model);
606
+ e.model = [...models].slice(0, 3).join(', ') + (models.size > 3 ? ', …' : '');
607
+ }
608
+ if (effect.access && e.access && e.access !== effect.access)
609
+ e.access = undefined;
610
+ existing.sub = effectSub(e, by);
611
+ return existing;
612
+ }
613
+ if (steps.size >= limit) {
614
+ truncated.steps++;
615
+ return null;
616
+ }
617
+ const e = {
618
+ api: ref.referenceName,
619
+ apis: [ref.referenceName],
620
+ category,
621
+ by: (0, wire_1.toNodeRef)(by),
622
+ line: ref.line,
623
+ ...(effect.model ? { model: effect.model } : {}),
624
+ ...(effect.access ? { access: effect.access } : {}),
625
+ };
626
+ const record = {
627
+ id,
628
+ kind: 'effect',
629
+ anchor: false,
630
+ node: null,
631
+ label: ref.referenceName,
632
+ sub: effectSub(e, by),
633
+ depth,
634
+ cut: null,
635
+ effect: e,
636
+ root: null,
637
+ };
638
+ steps.set(id, record);
639
+ return record;
640
+ };
641
+ /**
642
+ * How a Spring MVC handler answers: each `return` of a view name — a string,
643
+ * or a same-class constant holding one (`VIEWS_OWNER_CREATE_OR_UPDATE_FORM`)
644
+ * — renders that view (200); `"redirect:/owners/" + id` sends a 302 and
645
+ * `"forward:/x"` hands the request on. Only for a mapped method of a class
646
+ * that renders views: a `@RestController` or `@ResponseBody` method returns
647
+ * its body, and a returned value that is not a literal is not guessed at.
648
+ */
649
+ const springMvcReplies = async (node) => {
650
+ if ((node.language !== 'java' && node.language !== 'kotlin') || node.kind !== 'method')
651
+ return [];
652
+ const decs = await calls.decorators(node);
653
+ if (!decs || !decs.own.some((d) => /^(?:Get|Post|Put|Patch|Delete|Request)Mapping\b/.test(d)))
654
+ return [];
655
+ if (decs.class.some((d) => /^RestController\b/.test(d)) || decs.own.some((d) => /^ResponseBody\b/.test(d)))
656
+ return [];
657
+ const out = [];
658
+ for (const r of await calls.returns(node)) {
659
+ const view = r.value ?? springViewString(r.expression);
660
+ if (view === null)
661
+ continue;
662
+ const redirect = /^redirect:(.*)$/.exec(view);
663
+ const forward = /^forward:(.*)$/.exec(view);
664
+ out.push({
665
+ text: redirect ? `redirect:${redirect[1]}` : forward ? `forward:${forward[1]}` : `view ${view}`,
666
+ status: redirect ? 302 : forward ? null : 200,
667
+ line: r.line,
668
+ column: r.column,
669
+ });
670
+ }
671
+ return out;
672
+ };
673
+ /** One effect site: the call as written, what it passes, when, what fires it, and — for a response — the status. */
674
+ const effectLink = async (step, fold, ref, trigger, fallbackArgs = null, requireReceiver = false,
675
+ /** A site that is no call — a handler's `return "redirect:/x"` — arrives already classified. */
676
+ preset = null) => {
677
+ const at = { line: ref.line, column: ref.column };
678
+ const site = preset ? null : await callAt(fold.node, { ...at, callee: ref.referenceName });
679
+ // The site read must be THIS call: its last segment is the reference's.
680
+ const last = (n) => n.replace(/\([^()]*\)/g, '').split(/[.:]/).pop() ?? n;
681
+ const usable = !!site && site.callee !== '' && last(site.callee) === last(ref.referenceName);
682
+ const text = usable ? site.callee : ref.referenceName;
683
+ if (requireReceiver && !/[.:>]/.test(text))
684
+ return false;
685
+ const args = usable ? site.args : fallbackArgs;
686
+ // The receiver's declared type counts only when the call leaves the
687
+ // index through it: a library's `Repository<Cat>`, or the project's own
688
+ // `OwnerRepository` interface whose `save` comes from Spring Data — never
689
+ // a project class that declares the method, which is a place to walk into.
690
+ let effect = preset?.effect ?? null;
691
+ if (!preset) {
692
+ const declared = await receiverTypeFor(fold.node, text);
693
+ const receiverType = declared && (await resolveByReceiver(fold.node, text)) === null ? declared : null;
694
+ effect = (0, effects_1.classifyEffect)({
695
+ text,
696
+ kind: ref.referenceKind,
697
+ language: fold.node.language,
698
+ project,
699
+ receiverType,
700
+ args,
701
+ projectType: fold.node.language === 'swift' && (await declaresSwiftType(text)),
702
+ });
703
+ }
704
+ if (effect === null)
705
+ return false;
706
+ // A reply's status, read before its box exists — the box is per outcome.
707
+ // `NextResponse.json(user, { status: 201 })`: the code sits in an object
708
+ // the abbreviation reduced to its keys; the site reader kept it. And a
709
+ // body-sending reply that sets none is a 200, so a success has a box of
710
+ // its own beside the 401's.
711
+ const status = preset
712
+ ? preset.status
713
+ : effect.category === 'response'
714
+ ? ((0, effects_1.responseStatus)(text, args, ref.referenceKind) ?? (usable && typeof site.status === 'number' ? site.status : null) ?? (0, effects_1.implicitResponseStatus)(text))
715
+ : null;
716
+ // What fires this call, read before its box is made: a call bound inside
717
+ // ANOTHER effect's arguments — the axios.delete in a confirm dialog's
718
+ // button — hangs off that box, one step deeper, not off the screen.
719
+ const fired = trigger ?? (await triggerAt(fold.node, at));
720
+ const from = fired?.of ? (firedByEffect(fold.node.id, at, fired.of) ?? step) : step;
721
+ const target = effectStep(fold.node, { referenceName: text, line: ref.line }, effect, from.depth + 1, status);
722
+ if (target === null)
723
+ return true;
724
+ const guards = await guardsAt(fold.node, at);
725
+ const when = (0, branch_guards_1.guardLabel)(guards);
726
+ const wireSite = { file: posix(fold.node.filePath), line: ref.line, text, when: '' };
727
+ if (args !== null)
728
+ wireSite.args = args;
729
+ if (status !== null)
730
+ wireSite.status = status;
731
+ const effectDecision = decisionOf(guards);
732
+ if (effectDecision)
733
+ wireSite.decision = effectDecision;
734
+ // Where the call is written HERE — in this function, at this line. The
735
+ // rail places the step by it; the tree's row order uses the hop out of the
736
+ // step's root, which is the same position when nothing was folded.
737
+ const local = {
738
+ file: fold.node.filePath,
739
+ line: site?.span?.start.line ?? ref.line,
740
+ column: site?.span?.start.column ?? ref.column ?? 0,
741
+ end: site?.span?.end ?? { line: ref.line, column: ref.column ?? 0 },
742
+ within: site?.within ?? null,
743
+ };
744
+ // This call's own span, for the bindings written inside its arguments.
745
+ if (usable && site?.span) {
746
+ const list = firedSpans.get(fold.node.id) ?? [];
747
+ list.push({ start: { line: local.line, column: local.column }, end: local.end, step: target });
748
+ firedSpans.set(fold.node.id, list);
749
+ }
750
+ const hop = fold.first ?? local;
751
+ if (!target.first)
752
+ target.first = hop;
753
+ if (!target.region)
754
+ target.region = regionOf(from, fold.chain);
755
+ const id = link(from, target, 'effect', fold.chain, [...fold.whens, when], wireSite, null, fired, hop.within);
756
+ record(fold.node, local, guards, { step: target.id, link: id }, fired, await loopsAt(fold.node, at));
757
+ return true;
758
+ };
759
+ const link = (from, to, kind, chain, whens, site, edge, trigger = null, within = null) => {
760
+ const meta = (edge?.metadata ?? {});
761
+ const synthesized = edge?.provenance === 'heuristic';
762
+ const confidence = typeof meta.confidence === 'number' ? meta.confidence : null;
763
+ const via = chain.map(wire_1.toNodeRef);
764
+ const viaKey = via.map((v) => v.id).join('>');
765
+ const id = `${from.id} ${to.id} ${viaKey}`;
766
+ const when = whens.filter((w, i) => w && whens.indexOf(w) === i).join(' && ');
767
+ const stamped = { ...site, when, ...(trigger ? { trigger } : {}) };
768
+ // A `contains` edge is how a nested handler is FOUND, not a place it is
769
+ // called from: its row stays only while no call site has been seen.
770
+ const structural = (s) => s.text.startsWith('defines ');
771
+ const existing = links.get(id);
772
+ if (existing) {
773
+ if (structural(stamped) && existing.sites.some((s) => !structural(s)))
774
+ return id;
775
+ if (!structural(stamped) && existing.sites.every(structural))
776
+ existing.sites.length = 0;
777
+ // One statement, two references (`res.status(201)` and its `.json(…)`):
778
+ // the outer call is the site, the inner one folds into it.
779
+ const sameLine = existing.sites.findIndex((s) => s.file === site.file && s.line === site.line);
780
+ if (sameLine < 0)
781
+ existing.sites.push(stamped);
782
+ else if (stamped.text.startsWith(existing.sites[sameLine].text) && stamped.text.length > existing.sites[sameLine].text.length) {
783
+ existing.sites[sameLine] = stamped;
784
+ }
785
+ if (!existing.trigger && trigger)
786
+ existing.trigger = trigger;
787
+ if (!existing.within && within)
788
+ existing.within = within;
789
+ if (when !== existing.when) {
790
+ if (!when || !existing.when)
791
+ existing.when = '';
792
+ else if (!existing.when.split(' || ').includes(when))
793
+ existing.when = `${existing.when} || ${when}`;
794
+ }
795
+ return id;
796
+ }
797
+ links.set(id, {
798
+ id,
799
+ from: from.id,
800
+ to: to.id,
801
+ kind,
802
+ via,
803
+ when,
804
+ label: hopLabel(meta, synthesized),
805
+ synthesized,
806
+ uncertain: confidence !== null && confidence < wire_1.UNCERTAIN_BELOW,
807
+ sites: [stamped],
808
+ ...(trigger ? { trigger } : {}),
809
+ ...(within ? { within } : {}),
810
+ });
811
+ if (trigger && to.kind === 'trigger' && !to.trigger)
812
+ to.trigger = trigger;
813
+ return id;
814
+ };
815
+ /** What fires a site, with the function it is written in. */
816
+ const triggerAt = async (caller, at) => {
817
+ const t = await reader.trigger(caller, at);
818
+ return t ? { ...t, in: caller.name } : null;
819
+ };
820
+ // The anchor: a screen keeps its kind and explores from its component; an
821
+ // endpoint says the request that fires it and what runs before its handler;
822
+ // a function says the job, event or schedule written on it.
823
+ const first = stepFor(anchor, 'anchor', 0);
824
+ first.anchor = true;
825
+ if (anchor.kind === 'route') {
826
+ const t = await requestTrigger(anchor, first.root);
827
+ if (t)
828
+ first.trigger = t;
829
+ }
830
+ else {
831
+ const t = await consumerTrigger(anchor);
832
+ if (t)
833
+ first.trigger = t;
834
+ }
835
+ // A screen's picture is laid out by REGION — the part of the screen each
836
+ // step belongs to. The evidence is the walk's own: a step reached out of the
837
+ // anchor descends through the fold's chain, whose FIRST node is the
838
+ // top-level component (or hook) of the screen's tree; a chain of nothing is
839
+ // a call written in the screen body itself; and a step reached from any
840
+ // other step belongs where its first-reaching parent does. First reach wins,
841
+ // as `first` does — a shared store is one box, in the region that got there
842
+ // first, and every other region's way in is a link. An endpoint or a
843
+ // function reads in the code's order and carries none of this.
844
+ const regions = first.kind === 'screen' && !first.screen?.endpoint;
845
+ const regionOf = (from, chain) => {
846
+ if (!regions)
847
+ return undefined;
848
+ if (!from.anchor)
849
+ return from.region;
850
+ const head = chain[0];
851
+ if (head)
852
+ return { id: head.id, label: head.name };
853
+ return { id: from.root?.id ?? from.id, label: from.root?.name ?? from.label };
854
+ };
855
+ const queue = [first];
856
+ /** Steps whose exploration has been queued — each is explored once, from the first row it appears on. */
857
+ const explored = new Set([first.id]);
858
+ while (queue.length > 0) {
859
+ const step = queue.shift();
860
+ if (step.root === null)
861
+ continue;
862
+ // Another screen is a chapter of its own: the Screens view draws the way
863
+ // between screens, and a picture that walked on through Home would be the
864
+ // whole app. Drawn as a boundary, entered on request.
865
+ // An endpoint reached across a tier is the same kind of boundary: the
866
+ // request's own picture starts at its handler, entered on request.
867
+ if ((step.kind === 'screen' || (step.kind === 'bridge' && step.node?.kind === 'route')) && !step.anchor && !through) {
868
+ step.cut = 'screen';
869
+ continue;
870
+ }
871
+ // A native event that lands in a COMPONENT — the capture overlay taking
872
+ // `onCaptureProgress` — lands on another screen's body: its picture is
873
+ // that screen's, not this one's. A boundary too, entered on request.
874
+ if (step.kind === 'event' && !step.anchor && !through && (0, route_roots_1.looksLikeComponent)(step.root)) {
875
+ step.cut = 'component';
876
+ continue;
877
+ }
878
+ if (step.depth >= depthCap) {
879
+ // Something to explore, and no room in the picture for it.
880
+ if (cg.getOutgoingEdgesFrom([step.root.id], WALK_KINDS).length > 0)
881
+ step.cut = 'depth';
882
+ continue;
883
+ }
884
+ // Breadth-first through the plumbing until the next steps.
885
+ const visited = new Set([step.root.id]);
886
+ let frontier = [{ node: step.root, chain: [], whens: [], first: null }];
887
+ for (let hop = 0; hop <= MAX_FOLD_DEPTH && frontier.length > 0; hop++) {
888
+ const next = [];
889
+ const ids = frontier.map((f) => f.node.id);
890
+ const outgoing = cg.getOutgoingEdgesFrom(ids, WALK_KINDS);
891
+ const bySource = new Map();
892
+ for (const e of outgoing) {
893
+ const list = bySource.get(e.source) ?? [];
894
+ list.push(e);
895
+ bySource.set(e.source, list);
896
+ }
897
+ // `const Memoized = memo(CaptureComponent)`: the wrapper is a component
898
+ // node with no edges of its own — the inner component is referenced
899
+ // from the FILE scope, at the wrapper's line. Lend the wrapper those
900
+ // references, so the screen that renders `<Memoized/>` walks on into
901
+ // what the component does.
902
+ // The same for a value a registration is written inside — `const
903
+ // worker = new Worker('q', async (job) => { … })`: the arrow's calls
904
+ // belong to the file scope and the constant spans them; a queue job
905
+ // lands on the constant, and the walk goes on into what the handler does.
906
+ for (const fold of frontier) {
907
+ const value = fold.node.kind === 'constant' || fold.node.kind === 'variable';
908
+ // Edges the walk would follow as BEHAVIOUR. `const signIn =
909
+ // validatedAction(schema, async (data) => { … })` holds a plain
910
+ // `references` edge to its schema and nothing else: counting that as
911
+ // "it has edges of its own" left the whole handler body unlent, and the
912
+ // picture showed one call out of nine.
913
+ const behaviour = (bySource.get(fold.node.id) ?? []).filter((e) => e.kind !== 'references' || e.metadata?.fnRef === true).length;
914
+ if ((fold.node.kind !== 'component' && !value) || behaviour > 0)
915
+ continue;
916
+ for (const e of fileScopeEdgesWithin(cg, fold.node, fileScopeRefs, value)) {
917
+ const list = bySource.get(fold.node.id) ?? [];
918
+ list.push({ ...e, source: fold.node.id });
919
+ bySource.set(fold.node.id, list);
920
+ }
921
+ }
922
+ const targetIds = new Set();
923
+ for (const list of bySource.values())
924
+ for (const e of list)
925
+ targetIds.add(e.target);
926
+ const targets = targetIds.size === 0 ? new Map() : cg.getNodesByIds([...targetIds]);
927
+ // Hubs and chrome are judged on the nodes about to be entered.
928
+ const unknownFanIn = [...targetIds].filter((id) => !fanIn.has(id));
929
+ if (unknownFanIn.length > 0)
930
+ for (const [id, n] of cg.getFanIn(unknownFanIn))
931
+ fanIn.set(id, n);
932
+ for (const fold of frontier) {
933
+ // A call a synthesized channel already follows — the `fetch` that
934
+ // reaches its own route, the `queue.add` its consumer picks up — is
935
+ // the crossing, not also a call outside the index.
936
+ const channelLines = new Set();
937
+ /** Per line, the last segment of each call a channel follows there (`add` of `emailQueue.add`). */
938
+ const channelCalls = new Map();
939
+ for (const e of bySource.get(fold.node.id) ?? []) {
940
+ const m = e.metadata;
941
+ if (typeof m?.channel !== 'string' || typeof e.line !== 'number')
942
+ continue;
943
+ channelLines.add(e.line);
944
+ if (typeof m.callee === 'string') {
945
+ const set = channelCalls.get(e.line) ?? new Set();
946
+ set.add(m.callee.split(/[.:]/).pop() ?? m.callee);
947
+ channelCalls.set(e.line, set);
948
+ }
949
+ }
950
+ // Effects made by this node, folded or not. A value a handler is
951
+ // written inside (`const authUser = asyncHandler(async (req, res) =>
952
+ // …)`) made none itself — the arrow's calls belong to the file scope —
953
+ // so it is lent the file's, within its lines, as its call edges are.
954
+ if (effectScans < MAX_EFFECT_SCANS) {
955
+ effectScans++;
956
+ let refs = [];
957
+ try {
958
+ refs = cg.getUnresolvedReferencesFrom(fold.node.id);
959
+ if (refs.length === 0 && (fold.node.kind === 'constant' || fold.node.kind === 'variable'))
960
+ refs = fileScopeRefsWithin(cg, fold.node, fileScopeUnresolved);
961
+ }
962
+ catch {
963
+ refs = [];
964
+ }
965
+ for (const ref of [...refs].sort((a, b) => a.line - b.line || a.column - b.column)) {
966
+ if (ref.referenceKind !== 'calls' && ref.referenceKind !== 'instantiates')
967
+ continue;
968
+ if (channelLines.has(ref.line))
969
+ continue;
970
+ await effectLink(step, fold, { referenceName: ref.referenceName, referenceKind: ref.referenceKind, line: ref.line, column: ref.column }, null);
971
+ }
972
+ // A Spring MVC handler answers by what it returns, which is no call.
973
+ for (const reply of await springMvcReplies(fold.node)) {
974
+ await effectLink(step, fold, { referenceName: reply.text, referenceKind: 'calls', line: reply.line, column: reply.column }, null, null, false, { effect: { category: 'response' }, status: reply.status });
975
+ }
976
+ }
977
+ let edges = (bySource.get(fold.node.id) ?? []).slice();
978
+ edges = edges.filter((e) => {
979
+ const meta = (e.metadata ?? {});
980
+ if (e.kind === 'references')
981
+ return meta.fnRef === true;
982
+ if (e.kind === 'contains') {
983
+ // A function's nested handlers; and, when the walk STARTS at a
984
+ // class (a ViewSet, a class-based view bound to a route), its
985
+ // methods — never a class met on the way, whose methods are not
986
+ // what the caller reached.
987
+ const t = targets.get(e.target);
988
+ const fromFunction = fold.node.kind === 'function' || fold.node.kind === 'method';
989
+ const fromRootClass = fold.node.kind === 'class' && fold.chain.length === 0 && fold.node.id === step.root?.id;
990
+ return (fromFunction || fromRootClass) && !!t && (t.kind === 'function' || t.kind === 'method');
991
+ }
992
+ return true;
993
+ });
994
+ edges.sort((a, b) => (a.line ?? 0) - (b.line ?? 0) || a.target.localeCompare(b.target));
995
+ if (edges.length > MAX_FANOUT) {
996
+ step.cut = 'fan-out';
997
+ edges = edges.slice(0, MAX_FANOUT);
998
+ }
999
+ const arrivals = [];
1000
+ const fromTest = (0, query_utils_1.isTestPath)(fold.node.filePath);
1001
+ for (const e of edges) {
1002
+ const found = targets.get(e.target);
1003
+ if (!found || found.kind === 'file')
1004
+ continue;
1005
+ const meta = (e.metadata ?? {});
1006
+ // A member call the index kept only the last segment of (`create`
1007
+ // for `prisma.user.create`) resolves by name alone — a guess, and
1008
+ // often the wrong one. The call AS WRITTEN decides first: an effect
1009
+ // is drawn as one and the guessed edge is not walked. A call through
1010
+ // a project-made value (`client.post` on the axios instance) is the
1011
+ // same case with the constant as the target.
1012
+ let target = targets.get(e.target);
1013
+ let retargeted = false;
1014
+ // `api.get('/users')` resolves to the `api` constant — and
1015
+ // `this.audioQueue.add('transcode')` to some `add` by name — AND,
1016
+ // on the same line, a channel follows the call: the channel is the story.
1017
+ if (typeof meta.channel !== 'string' && e.kind === 'calls' && channelLines.has(e.line ?? -1)) {
1018
+ const written = typeof meta.refName === 'string' ? meta.refName : target.name;
1019
+ const last = written.split(/[.:]/).pop() ?? written;
1020
+ if (target.kind === 'constant' || target.kind === 'variable' || channelCalls.get(e.line)?.has(last))
1021
+ continue;
1022
+ }
1023
+ if (e.kind === 'calls' && typeof meta.synthesizedBy !== 'string' && e.provenance !== 'heuristic') {
1024
+ const refName = typeof meta.refName === 'string' ? meta.refName : target.name;
1025
+ const bare = !refName.includes('.');
1026
+ // A member call whose receiver is declared as a type the index
1027
+ // holds no class for (`DataStore<UserPreferences>`) leaves the
1028
+ // index too, whatever name-matched — an `updateData` on a test
1029
+ // double, say.
1030
+ let external = false;
1031
+ if (!bare && target.kind !== 'constant' && target.kind !== 'variable') {
1032
+ const declared = await receiverTypeFor(fold.node, refName);
1033
+ external = !!declared && (await classOfType(declared)) === null;
1034
+ }
1035
+ if (bare || external || target.kind === 'constant' || target.kind === 'variable') {
1036
+ const drawn = await effectLink(step, fold, { referenceName: refName, referenceKind: 'calls', line: e.line ?? fold.node.startLine, column: e.column }, null, null, true);
1037
+ if (drawn)
1038
+ continue;
1039
+ // Not an effect: does the receiver's declared type say where the
1040
+ // call goes? A class in the index wins over the name-only guess.
1041
+ if (bare) {
1042
+ const written = await callAt(fold.node, { line: e.line, column: e.column, callee: refName });
1043
+ if (written && /[.:]/.test(written.callee) && (written.callee.split(/[.:]/).pop() ?? '') === refName) {
1044
+ const real = await resolveByReceiver(fold.node, written.callee);
1045
+ if (real && real.id !== target.id) {
1046
+ target = real;
1047
+ retargeted = true;
1048
+ }
1049
+ else if (real === null && ownMethodWithoutReceiver(fold.node, target, written.callee)) {
1050
+ // `crypto.createHash('sha256').update(…)` in a method of a
1051
+ // class that happens to have an `update`: the index kept
1052
+ // only `update` and matched it by name. In this family a
1053
+ // method of your own class is written `this.update(…)`, so
1054
+ // a receiver that is not `this` proves the guess wrong. The
1055
+ // call leaves the index — say nothing rather than the wrong thing.
1056
+ continue;
1057
+ }
1058
+ }
1059
+ }
1060
+ }
1061
+ }
1062
+ if (target.id === fold.node.id)
1063
+ continue;
1064
+ // A production walk never enters a test double: an interface's
1065
+ // dispatch into `TestUserDataRepository`, or a `DataStore` name-matched
1066
+ // to the in-memory one, is the test suite's story. Judged after the
1067
+ // call as written had its chance to be an effect.
1068
+ if (!fromTest && (0, query_utils_1.isTestPath)(target.filePath))
1069
+ continue;
1070
+ const site = {
1071
+ file: posix(fold.node.filePath),
1072
+ line: e.line ?? fold.node.startLine,
1073
+ text: siteText(e, meta, target),
1074
+ when: '',
1075
+ };
1076
+ // What fires this hop, when the site is written under an event:
1077
+ // the JSX prop, the `on*` option, the runs-later call. Read for
1078
+ // every call-shaped hop, so a store action or an effect fired by
1079
+ // a tap says so on its link too.
1080
+ const isCall = e.kind === 'calls' || e.kind === 'instantiates' || (e.kind === 'references' && meta.fnRef === true);
1081
+ const trigger = isCall ? await triggerAt(fold.node, { line: e.line, column: e.column }) : null;
1082
+ // A server action, by its directive: a function in a `'use server'`
1083
+ // file (or opening with the directive) called from a file that is
1084
+ // not — the call crosses to the server, whatever the import says.
1085
+ if (e.provenance !== 'heuristic' &&
1086
+ (e.kind === 'calls' || (e.kind === 'references' && meta.fnRef === true)) &&
1087
+ (target.kind === 'function' || target.kind === 'method') &&
1088
+ JS_FAMILY.has(target.language) &&
1089
+ JS_FAMILY.has(fold.node.language)) {
1090
+ const callee = await calls.directive(target);
1091
+ if ((callee.file === 'server' || callee.own) && (await calls.directive(fold.node)).file !== 'server') {
1092
+ meta.tier = 'client→server';
1093
+ meta.channel = 'server-action';
1094
+ }
1095
+ }
1096
+ // What kind of step, if any, this edge arrives at.
1097
+ let kind = null;
1098
+ let linkKind = 'calls';
1099
+ const extra = {};
1100
+ if (target.kind === 'route' && meta.tier !== 'client→server') {
1101
+ kind = 'screen';
1102
+ linkKind = 'navigates';
1103
+ }
1104
+ else {
1105
+ // A language change under the code is a step only on evidence: a
1106
+ // bridge resolver's edge (`bridge`, or a framework resolution), or
1107
+ // a synthesized channel's. A plain name-matched call across the
1108
+ // families (`arr.flat()` landing on a Swift `flat`) is noise, and
1109
+ // is neither drawn nor walked.
1110
+ const cross = crossing(fold.node.language, target.language, meta);
1111
+ const evidenced = e.provenance === 'heuristic' || meta.bridge === 'react-native' || meta.resolvedBy === 'framework' || meta.channel === 'server-action';
1112
+ if (cross !== null && !evidenced)
1113
+ continue;
1114
+ if (cross === 'event') {
1115
+ kind = 'event';
1116
+ linkKind = 'event';
1117
+ if (typeof meta.event === 'string')
1118
+ extra.event = meta.event;
1119
+ }
1120
+ else if (cross === 'bridge') {
1121
+ kind = 'bridge';
1122
+ linkKind = 'bridge';
1123
+ }
1124
+ else if ((target.kind === 'function' || target.kind === 'method') &&
1125
+ isStoreFile(target.filePath) &&
1126
+ !isStoreFile(fold.node.filePath)) {
1127
+ // A store action fired straight from a tap stays a store
1128
+ // action; the tap is on its link.
1129
+ kind = 'store';
1130
+ linkKind = 'store';
1131
+ }
1132
+ else if ((target.kind === 'function' || target.kind === 'method') &&
1133
+ !(0, route_roots_1.looksLikeComponent)(target) &&
1134
+ ((e.kind === 'references' && meta.fnRef === true) || trigger !== null)) {
1135
+ // A handler: a function passed as a value (`onPress={handleX}`,
1136
+ // `addListener('x', handleX)`), or one called from under an
1137
+ // event binding (`onPress={() => handleLogin(values)}`,
1138
+ // `useFormik({ onSubmit: (v) => handleLogin(v) })`). A
1139
+ // component passed as a value (`memo(CaptureComponent)`) is a
1140
+ // render hop and folds like one.
1141
+ kind = 'trigger';
1142
+ linkKind = 'handler';
1143
+ if (trigger)
1144
+ extra.trigger = trigger;
1145
+ }
1146
+ }
1147
+ if (retargeted)
1148
+ meta.resolvedBy = 'receiver-type';
1149
+ arrivals.push({ e, target, meta, site, kind, linkKind, extra, trigger });
1150
+ }
1151
+ for (const a of arrivals) {
1152
+ if (a.kind === null)
1153
+ continue;
1154
+ const at = { line: a.e.line, column: a.e.column };
1155
+ // A binding written inside an effect call's arguments — the dialog's
1156
+ // `onPress` — arrives from that box, not from the step that owns
1157
+ // the fold: the prompt fires it.
1158
+ const firedBy = a.trigger?.of ? firedByEffect(fold.node.id, at, a.trigger.of) : null;
1159
+ const from = firedBy ?? step;
1160
+ const fresh = !steps.has(a.target.id);
1161
+ const to = stepFor(a.target, a.kind, from.depth + 1, a.extra);
1162
+ if (to === null)
1163
+ continue;
1164
+ if (fresh && !to.trigger) {
1165
+ const t = a.target.kind === 'route' ? await requestTrigger(a.target, to.root) : await consumerTrigger(a.target);
1166
+ if (t)
1167
+ to.trigger = t;
1168
+ }
1169
+ const guards = await guardsAt(fold.node, at);
1170
+ const when = (0, branch_guards_1.guardLabel)(guards);
1171
+ // A call-shaped hop says what it passes; a navigation already says
1172
+ // its href, a handler binding and a native event channel pass
1173
+ // nothing. A hop over a synthesized channel is a call in the source
1174
+ // — `fetch('/api/users', {…})`, `emailQueue.add('welcome', {…})` —
1175
+ // and its site reads as written.
1176
+ let site = a.site;
1177
+ if (typeof a.meta.channel === 'string' && a.meta.channel !== 'server-action') {
1178
+ const written = await callAt(fold.node, at);
1179
+ site = written && written.callee ? { ...a.site, text: written.callee, args: written.args } : await withArgs(a.site, fold.node, at);
1180
+ }
1181
+ else if (a.linkKind === 'bridge' ||
1182
+ a.linkKind === 'store' ||
1183
+ a.linkKind === 'calls' ||
1184
+ // A handler BOUND passes nothing (`onPress={handleX}`), but a
1185
+ // handler CALLED from under a binding is a call like any other —
1186
+ // and `tryCatchSync(onClosePress)`'s argument is the whole answer
1187
+ // to what a wrapper wraps.
1188
+ (a.linkKind === 'handler' && (a.e.kind === 'calls' || a.e.kind === 'instantiates'))) {
1189
+ site = await withArgs(a.site, fold.node, at);
1190
+ }
1191
+ // Where this step is first reached from: the hop out of the root
1192
+ // this fold descends from, else this site — its position orders the row.
1193
+ const isCallHop = a.e.kind === 'calls' || a.e.kind === 'instantiates' || a.e.kind === 'navigates';
1194
+ const local = isCallHop ? await hopAt(fold.node, at, a.target.name) : pointHop(fold.node, at);
1195
+ const hop = fold.first ?? local;
1196
+ if (!to.first)
1197
+ to.first = hop;
1198
+ if (!to.region)
1199
+ to.region = regionOf(from, fold.chain);
1200
+ const decision = decisionOf(guards);
1201
+ if (decision)
1202
+ site = { ...site, decision };
1203
+ const id = link(from, to, a.linkKind, fold.chain, [...fold.whens, when], site, a.e, a.trigger, hop.within);
1204
+ record(fold.node, local, guards, { step: to.id, link: id }, a.trigger, await loopsAt(fold.node, at));
1205
+ if (to.root !== null && !explored.has(to.id)) {
1206
+ explored.add(to.id);
1207
+ queue.push(to);
1208
+ }
1209
+ }
1210
+ for (const a of arrivals) {
1211
+ if (a.kind !== null)
1212
+ continue;
1213
+ const { e, target, meta } = a;
1214
+ // A call through a VALUE the effect table knows — `client.post` on
1215
+ // the axios instance the project made itself resolves to the
1216
+ // `client` constant, not to anything outside the index. The call
1217
+ // text is the evidence: the call is the effect, the constant is not
1218
+ // a place to walk into.
1219
+ // A thrown exception the framework answers with (`throw new
1220
+ // NotFoundException(…)` on a class the project defines) is a
1221
+ // response, not a place to walk into; a repository's method the
1222
+ // walk cannot enter (an interface's, the ORM's) is the database.
1223
+ if (e.kind === 'instantiates' && target.kind === 'class') {
1224
+ if (await effectLink(step, fold, { referenceName: target.name, referenceKind: 'instantiates', line: e.line ?? fold.node.startLine, column: e.column }, a.trigger))
1225
+ continue;
1226
+ }
1227
+ if (e.kind === 'calls' && repositoryMethod(target)) {
1228
+ const container = target.qualifiedName.replace(/[.:]+[^.:]*$/, '').split(/[.:]+/).pop() ?? '';
1229
+ const api = typeof meta.refName === 'string' && meta.refName.includes('.') ? meta.refName : `${container}.${target.name}`;
1230
+ if (await effectLink(step, fold, { referenceName: api, referenceKind: 'calls', line: e.line ?? fold.node.startLine, column: e.column }, a.trigger))
1231
+ continue;
1232
+ }
1233
+ // Already a step, reached here by a plain call: a link, not a fold.
1234
+ const known = steps.get(target.id);
1235
+ if (known) {
1236
+ if (known.id !== step.id) {
1237
+ const at = { line: e.line, column: e.column };
1238
+ const firedBy = a.trigger?.of ? firedByEffect(fold.node.id, at, a.trigger.of) : null;
1239
+ const guards = await guardsAt(fold.node, at);
1240
+ const local = await hopAt(fold.node, at, target.name);
1241
+ const hop = fold.first ?? local;
1242
+ const knownDecision = decisionOf(guards);
1243
+ const knownSite = await withArgs(a.site, fold.node, at);
1244
+ const id = link(firedBy ?? step, known, 'calls', fold.chain, [...fold.whens, (0, branch_guards_1.guardLabel)(guards)], knownDecision ? { ...knownSite, decision: knownDecision } : knownSite, e, a.trigger, hop.within);
1245
+ record(fold.node, local, guards, { step: known.id, link: id }, a.trigger, await loopsAt(fold.node, at));
1246
+ }
1247
+ continue;
1248
+ }
1249
+ // Plumbing: fold it and keep walking, unless it is a dead end.
1250
+ if (visited.has(target.id))
1251
+ continue;
1252
+ if ((fanIn.get(target.id) ?? 0) >= wire_1.HUB_THRESHOLD) {
1253
+ truncated.hubs++;
1254
+ continue;
1255
+ }
1256
+ if (meta.synthesizedBy === 'jsx-render' && isSharedChrome(cg, target, chromeParents)) {
1257
+ truncated.chrome++;
1258
+ continue;
1259
+ }
1260
+ if (visited.size >= MAX_FOLDED_PER_STEP) {
1261
+ step.cut = step.cut ?? 'folded';
1262
+ continue;
1263
+ }
1264
+ visited.add(target.id);
1265
+ const at = { line: e.line, column: e.column };
1266
+ const guards = await guardsAt(fold.node, at);
1267
+ const local = e.kind === 'calls' || e.kind === 'instantiates' ? await hopAt(fold.node, at, target.name) : pointHop(fold.node, at);
1268
+ const first = fold.first ?? local;
1269
+ // The helper is drawn where it is CALLED: its own records are its
1270
+ // body, and this is the site the rail nests them under.
1271
+ record(fold.node, local, guards, { into: target.id }, a.trigger, await loopsAt(fold.node, at));
1272
+ next.push({ node: target, chain: [...fold.chain, target], whens: [...fold.whens, (0, branch_guards_1.guardLabel)(guards)], first });
1273
+ }
1274
+ }
1275
+ frontier = next;
1276
+ }
1277
+ }
1278
+ // An effect box with ONE call behind it says what that call passes —
1279
+ // `axios.post('/auth/login', { email, password })` is the fact a reader
1280
+ // scans for; several calls list themselves in the panel instead.
1281
+ const sitesByStep = new Map();
1282
+ for (const l of links.values()) {
1283
+ const list = sitesByStep.get(l.to) ?? [];
1284
+ list.push(...l.sites);
1285
+ sitesByStep.set(l.to, list);
1286
+ }
1287
+ for (const step of steps.values()) {
1288
+ if (step.kind !== 'effect' || !step.effect)
1289
+ continue;
1290
+ const sites = sitesByStep.get(step.id) ?? [];
1291
+ // A response box is one outcome of the endpoint's contract: its status,
1292
+ // when literal, is its label (one per box by construction); the rows say
1293
+ // when. The box of unreadable statuses holds none and is labelled by its
1294
+ // call below.
1295
+ if (step.effect.category === 'response') {
1296
+ const statuses = [...new Set(sites.map((s) => s.status).filter((x) => typeof x === 'number'))].sort((a, b) => a - b);
1297
+ if (statuses.length > 0) {
1298
+ step.effect.statuses = statuses;
1299
+ step.label = statuses.join(' · ');
1300
+ continue;
1301
+ }
1302
+ }
1303
+ if (step.effect.apis.length !== 1)
1304
+ continue;
1305
+ if (sites.length !== 1 || sites[0].args === undefined)
1306
+ continue;
1307
+ const label = `${step.effect.api}(${sites[0].args})`;
1308
+ step.label = label.length > MAX_EFFECT_LABEL ? `${label.slice(0, MAX_EFFECT_LABEL - 2)}…)` : label;
1309
+ }
1310
+ // A row reads in the code's order: by the position of the hop that first
1311
+ // reached each step, a hop written inside another site's arguments before
1312
+ // that site — `generateToken(…)` in `res.json({ token: generateToken(…) })`
1313
+ // signs the token before the 200 is sent, so it comes first.
1314
+ const byDepth = new Map();
1315
+ for (const s of steps.values())
1316
+ byDepth.set(s.depth, [...(byDepth.get(s.depth) ?? []), s]);
1317
+ for (const row of byDepth.values()) {
1318
+ row.sort((a, b) => hopCompare(a.first, b.first) || a.label.localeCompare(b.label) || a.id.localeCompare(b.id));
1319
+ row.forEach((s, i) => {
1320
+ s.order = i;
1321
+ });
1322
+ }
1323
+ const ordered = [...steps.values()].sort((a, b) => a.depth - b.depth || (a.order ?? 0) - (b.order ?? 0) || a.id.localeCompare(b.id));
1324
+ // The second reading: the same steps in the code's order. A step the walk
1325
+ // ENTERED reads on into its own body; a boundary (another screen, an
1326
+ // endpoint across a tier) does not — it is a chapter of its own, exactly as
1327
+ // on the picture.
1328
+ const nodesById = new Map();
1329
+ for (const s of steps.values())
1330
+ if (s.root)
1331
+ nodesById.set(s.root.id, s.root);
1332
+ const program = (0, program_1.buildProgram)({
1333
+ sites: new Map([...programs].map(([fn, sites]) => [fn, [...sites.values()]])),
1334
+ root: first.root?.id ?? null,
1335
+ node: (id) => {
1336
+ const found = nodesById.get(id) ?? cg.getNode(id);
1337
+ return found ? (0, wire_1.toNodeRef)(found) : null;
1338
+ },
1339
+ step: (id) => {
1340
+ const s = steps.get(id);
1341
+ if (!s)
1342
+ return null;
1343
+ return { reply: s.effect?.category === 'response', into: s.cut === null && s.root ? s.root.id : null };
1344
+ },
1345
+ });
1346
+ return {
1347
+ anchor: (0, wire_1.toNodeRef)(anchor),
1348
+ ambiguous,
1349
+ project,
1350
+ steps: ordered.map(({ root: _root, first: _first, ...step }) => step),
1351
+ links: [...links.values()].sort((a, b) => a.id.localeCompare(b.id)),
1352
+ program,
1353
+ // A screen is a set of handlers with no order between them; anything with a
1354
+ // body — a handler, an endpoint, any function — reads in the code's order.
1355
+ defaultView: program !== null && !(first.kind === 'screen' && !first.screen?.endpoint) ? 'order' : 'tree',
1356
+ depth: depthCap,
1357
+ limit,
1358
+ through,
1359
+ truncated,
1360
+ index,
1361
+ timing: { elapsedMs: Date.now() - started },
1362
+ };
1363
+ }
1364
+ // =============================================================================
1365
+ // Helpers
1366
+ // =============================================================================
1367
+ /**
1368
+ * The anchor: `anchor=<id>`, or `symbol=<name>` resolved to the most
1369
+ * screen-like symbol of that name — a route first, then a component or
1370
+ * function, then a method — with the rest reported as `ambiguous`.
1371
+ */
1372
+ function resolveAnchor(cg, query) {
1373
+ const id = query.get('anchor');
1374
+ if (id !== null && id.trim() !== '') {
1375
+ const node = cg.getNode(id);
1376
+ if (!node)
1377
+ throw (0, respond_1.notFound)(`No symbol with id "${id}" in this index.`, 'It may have moved in a re-index; open it from search or the Screens view.');
1378
+ return { anchor: node, ambiguous: [] };
1379
+ }
1380
+ const name = query.get('symbol');
1381
+ if (name === null || name.trim() === '')
1382
+ throw (0, respond_1.badRequest)('Give the picture an anchor: ?anchor=<node id> or ?symbol=<name>.');
1383
+ const rank = { route: 0, component: 1, function: 2, method: 3, class: 4, constant: 5, variable: 6 };
1384
+ const matches = cg
1385
+ .getNodesByName(name.trim())
1386
+ .filter((n) => n.kind !== 'file' && n.kind !== 'import' && n.kind !== 'export')
1387
+ .sort((a, b) => (rank[a.kind] ?? 9) - (rank[b.kind] ?? 9) || a.filePath.localeCompare(b.filePath) || a.startLine - b.startLine);
1388
+ const anchor = matches[0];
1389
+ if (!anchor)
1390
+ throw (0, respond_1.notFound)(`Nothing in this index is named "${name}".`, 'Try the search box; names are matched exactly.');
1391
+ return { anchor, ambiguous: matches.slice(1, 9).map(wire_1.toNodeRef) };
1392
+ }
1393
+ /** How many distinct parents render this node as a JSX child. Memoised per request. */
1394
+ function renderParents(cg, node, memo) {
1395
+ let parents = memo.get(node.id);
1396
+ if (parents === undefined) {
1397
+ const incoming = cg.getIncomingEdgesTo([node.id], ['calls']);
1398
+ const sources = new Set();
1399
+ for (const e of incoming) {
1400
+ if (e.metadata?.synthesizedBy === 'jsx-render')
1401
+ sources.add(e.source);
1402
+ }
1403
+ parents = sources.size;
1404
+ memo.set(node.id, parents);
1405
+ }
1406
+ return parents;
1407
+ }
1408
+ /** A component rendered by several distinct parents is chrome. */
1409
+ function isSharedChrome(cg, component, memo) {
1410
+ return renderParents(cg, component, memo) >= SHARED_CHROME_MIN;
1411
+ }
1412
+ /**
1413
+ * What kind of project the picture is of, by what its routes are: endpoints
1414
+ * (`POST /users`) make an API; screens with navigation between them make an
1415
+ * app; both — pages and the endpoints behind them — make a web app.
1416
+ */
1417
+ function projectKind(routes, navigates) {
1418
+ let endpoints = 0;
1419
+ let pages = 0;
1420
+ for (const r of routes) {
1421
+ if ((0, routes_1.splitRouteName)(r.name).method !== null)
1422
+ endpoints++;
1423
+ else if (r.name.startsWith('/')) {
1424
+ pages++;
1425
+ // A Next page is a web page whatever else the index holds.
1426
+ if ((0, nextjs_1.nextRouteForFile)(r.filePath)?.kind === 'page')
1427
+ return 'web';
1428
+ }
1429
+ }
1430
+ if (endpoints === 0)
1431
+ return 'app';
1432
+ return navigates > 0 || pages > 0 ? 'web' : 'api';
1433
+ }
1434
+ function basename(p) {
1435
+ const s = posix(p);
1436
+ return s.slice(s.lastIndexOf('/') + 1);
1437
+ }
1438
+ /**
1439
+ * Function-as-value references — and, for a value, calls — made at a file's
1440
+ * top level within a node's lines: what `const Memoized = memo(CaptureComponent)`
1441
+ * leaves behind (the reference belongs to the file scope, the wrapper node
1442
+ * spans the line), and what `const worker = new Worker('q', async (job) =>
1443
+ * { … })` leaves behind (the handler's calls belong to the file scope, the
1444
+ * constant spans them).
1445
+ */
1446
+ function fileScopeEdgesWithin(cg, node, memo, calls) {
1447
+ let refs = memo.get(node.filePath);
1448
+ if (refs === undefined) {
1449
+ const file = cg.getNodesInFile(node.filePath).find((n) => n.kind === 'file');
1450
+ refs = file
1451
+ ? cg
1452
+ .getOutgoingEdgesFrom([file.id], ['references', 'calls', 'navigates'])
1453
+ .filter((e) => e.kind !== 'references' || e.metadata?.fnRef === true)
1454
+ : [];
1455
+ memo.set(node.filePath, refs);
1456
+ }
1457
+ return refs.filter((e) => (calls || e.kind === 'references') && typeof e.line === 'number' && e.line >= node.startLine && e.line <= node.endLine);
1458
+ }
1459
+ /** The file scope's unresolved calls within a value's lines — what a wrapped handler's arrow body leaves on the file node. */
1460
+ function fileScopeRefsWithin(cg, node, memo) {
1461
+ let refs = memo.get(node.filePath);
1462
+ if (refs === undefined) {
1463
+ const file = cg.getNodesInFile(node.filePath).find((n) => n.kind === 'file');
1464
+ try {
1465
+ refs = file ? cg.getUnresolvedReferencesFrom(file.id) : [];
1466
+ }
1467
+ catch {
1468
+ refs = [];
1469
+ }
1470
+ memo.set(node.filePath, refs);
1471
+ }
1472
+ return refs.filter((r) => r.line >= node.startLine && r.line <= node.endLine);
1473
+ }
1474
+ /** `push /capture`, `renders <Button>`, `via rn-event-channel`, `calls`. */
1475
+ function siteText(edge, meta, target) {
1476
+ if (edge.kind === 'navigates') {
1477
+ const method = edge.provenance === 'heuristic' ? 'returns' : typeof meta.navMethod === 'string' ? meta.navMethod : 'push';
1478
+ return `${method} ${typeof meta.href === 'string' ? meta.href : target.name}`;
1479
+ }
1480
+ if (meta.synthesizedBy === 'jsx-render')
1481
+ return `renders <${target.name}>`;
1482
+ if (edge.kind === 'references')
1483
+ return `passes ${target.name}`;
1484
+ if (edge.kind === 'contains')
1485
+ return `defines ${target.name}`;
1486
+ if (edge.kind === 'instantiates')
1487
+ return `new ${target.name}`;
1488
+ if (meta.bridge === 'react-native')
1489
+ return `bridge ${typeof meta.module === 'string' ? meta.module + '.' : ''}${target.name}`;
1490
+ if (meta.channel === 'http')
1491
+ return `${typeof meta.method === 'string' ? meta.method : 'GET'} ${typeof meta.href === 'string' ? meta.href : target.name}`;
1492
+ if (typeof meta.synthesizedBy === 'string')
1493
+ return `via ${meta.synthesizedBy}`;
1494
+ return `calls ${target.name}`;
1495
+ }
1496
+ /** The words on a hop that was not a plain call — the Flow strip's connector label, in short. */
1497
+ function hopLabel(meta, synthesized) {
1498
+ const parts = [];
1499
+ if (typeof meta.synthesizedBy === 'string')
1500
+ parts.push(`via ${meta.synthesizedBy}`);
1501
+ else if (synthesized)
1502
+ parts.push('inferred');
1503
+ if (meta.channel === 'server-action')
1504
+ parts.push('server action');
1505
+ if (meta.channel === 'http' && typeof meta.method === 'string')
1506
+ parts.push(`${meta.method} ${typeof meta.href === 'string' ? meta.href : ''}`.trim());
1507
+ if (meta.tier === 'client→server')
1508
+ parts.push('to the server');
1509
+ else if (meta.tier === 'server→client')
1510
+ parts.push('from the server');
1511
+ if (meta.resolvedBy === 'receiver-type')
1512
+ parts.push('by the receiver’s declared type');
1513
+ if (typeof meta.event === 'string')
1514
+ parts.push(`${meta.channel === 'queue' ? 'job' : meta.channel === 'socket' ? 'message' : 'event'} ${meta.event}`);
1515
+ if (typeof meta.queue === 'string')
1516
+ parts.push(`queue ${meta.queue}`);
1517
+ if (meta.bridge === 'react-native')
1518
+ parts.push(`React Native bridge${typeof meta.module === 'string' ? ` · ${meta.module}` : ''}`);
1519
+ if (typeof meta.registeredAt === 'string')
1520
+ parts.push(`registered at ${meta.registeredAt}`);
1521
+ return parts.join(' · ');
1522
+ }
1523
+ /** Source order of two hops: a hop written inside the other's call runs first; else by position; another file sorts after. */
1524
+ function hopCompare(a, b) {
1525
+ if (!a || !b)
1526
+ return a ? -1 : b ? 1 : 0;
1527
+ if (a.file !== b.file)
1528
+ return a.file.localeCompare(b.file);
1529
+ if (hopInside(a, b))
1530
+ return -1;
1531
+ if (hopInside(b, a))
1532
+ return 1;
1533
+ return a.line - b.line || a.column - b.column;
1534
+ }
1535
+ /** `x` starts strictly after `y` starts and before `y` ends. */
1536
+ function hopInside(x, y) {
1537
+ const afterStart = x.line > y.line || (x.line === y.line && x.column > y.column);
1538
+ const beforeEnd = x.line < y.end.line || (x.line === y.end.line && x.column < y.end.column);
1539
+ return afterStart && beforeEnd;
1540
+ }
1541
+ function posix(p) {
1542
+ return p.replace(/\\/g, '/');
1543
+ }
1544
+ //# sourceMappingURL=steps.js.map