browser-debugger-cli 0.0.1-alpha.0 → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -52
  3. package/dist/__testfixtures__/cdpMessages.d.ts +43 -0
  4. package/dist/__testfixtures__/cdpMessages.d.ts.map +1 -0
  5. package/dist/__testfixtures__/cdpMessages.js +118 -0
  6. package/dist/__testfixtures__/cdpMessages.js.map +1 -0
  7. package/dist/__testfixtures__/connectionTargets.d.ts +21 -0
  8. package/dist/__testfixtures__/connectionTargets.d.ts.map +1 -0
  9. package/dist/__testfixtures__/connectionTargets.js +59 -0
  10. package/dist/__testfixtures__/connectionTargets.js.map +1 -0
  11. package/dist/__tests__/integration/session-files.integration.test.d.ts +2 -0
  12. package/dist/__tests__/integration/session-files.integration.test.d.ts.map +1 -0
  13. package/dist/__tests__/integration/session-files.integration.test.js +66 -0
  14. package/dist/__tests__/integration/session-files.integration.test.js.map +1 -0
  15. package/dist/__testutils__/FakeClock.d.ts +67 -0
  16. package/dist/__testutils__/FakeClock.d.ts.map +1 -0
  17. package/dist/__testutils__/FakeClock.js +132 -0
  18. package/dist/__testutils__/FakeClock.js.map +1 -0
  19. package/dist/__testutils__/FakeWebSocket.d.ts +106 -0
  20. package/dist/__testutils__/FakeWebSocket.d.ts.map +1 -0
  21. package/dist/__testutils__/FakeWebSocket.js +213 -0
  22. package/dist/__testutils__/FakeWebSocket.js.map +1 -0
  23. package/dist/__testutils__/assertions.d.ts +33 -0
  24. package/dist/__testutils__/assertions.d.ts.map +1 -0
  25. package/dist/__testutils__/assertions.js +57 -0
  26. package/dist/__testutils__/assertions.js.map +1 -0
  27. package/dist/__testutils__/index.d.ts +15 -0
  28. package/dist/__testutils__/index.d.ts.map +1 -0
  29. package/dist/__testutils__/index.js +15 -0
  30. package/dist/__testutils__/index.js.map +1 -0
  31. package/dist/__testutils__/testClock.d.ts +28 -0
  32. package/dist/__testutils__/testClock.d.ts.map +1 -0
  33. package/dist/__testutils__/testClock.js +81 -0
  34. package/dist/__testutils__/testClock.js.map +1 -0
  35. package/dist/__testutils__/testFixtures.d.ts +15 -0
  36. package/dist/__testutils__/testFixtures.d.ts.map +1 -0
  37. package/dist/__testutils__/testFixtures.js +23 -0
  38. package/dist/__testutils__/testFixtures.js.map +1 -0
  39. package/dist/__testutils__/testProcess.d.ts +46 -0
  40. package/dist/__testutils__/testProcess.d.ts.map +1 -0
  41. package/dist/__testutils__/testProcess.js +77 -0
  42. package/dist/__testutils__/testProcess.js.map +1 -0
  43. package/dist/cli/collectors/dom.d.ts +8 -0
  44. package/dist/cli/collectors/dom.d.ts.map +1 -0
  45. package/dist/cli/collectors/dom.js +361 -0
  46. package/dist/cli/collectors/dom.js.map +1 -0
  47. package/dist/cli/collectors/helpers/domCache.d.ts +40 -0
  48. package/dist/cli/collectors/helpers/domCache.d.ts.map +1 -0
  49. package/dist/cli/collectors/helpers/domCache.js +79 -0
  50. package/dist/cli/collectors/helpers/domCache.js.map +1 -0
  51. package/dist/cli/collectors/helpers/domQuery.d.ts +45 -0
  52. package/dist/cli/collectors/helpers/domQuery.d.ts.map +1 -0
  53. package/dist/cli/collectors/helpers/domQuery.js +100 -0
  54. package/dist/cli/collectors/helpers/domQuery.js.map +1 -0
  55. package/dist/cli/collectors/helpers/selectorParser.d.ts +20 -0
  56. package/dist/cli/collectors/helpers/selectorParser.d.ts.map +1 -0
  57. package/dist/cli/collectors/helpers/selectorParser.js +20 -0
  58. package/dist/cli/collectors/helpers/selectorParser.js.map +1 -0
  59. package/dist/cli/commands/__tests__/cdp.contract.test.d.ts +24 -0
  60. package/dist/cli/commands/__tests__/cdp.contract.test.d.ts.map +1 -0
  61. package/dist/cli/commands/__tests__/cdp.contract.test.js +467 -0
  62. package/dist/cli/commands/__tests__/cdp.contract.test.js.map +1 -0
  63. package/dist/cli/commands/__tests__/ipcTest.test.d.ts +2 -0
  64. package/dist/cli/commands/__tests__/ipcTest.test.d.ts.map +1 -0
  65. package/dist/cli/commands/__tests__/ipcTest.test.js +37 -0
  66. package/dist/cli/commands/__tests__/ipcTest.test.js.map +1 -0
  67. package/dist/cli/commands/cdp.d.ts +8 -0
  68. package/dist/cli/commands/cdp.d.ts.map +1 -0
  69. package/dist/cli/commands/cdp.js +45 -0
  70. package/dist/cli/commands/cdp.js.map +1 -0
  71. package/dist/cli/commands/cleanup.d.ts +8 -0
  72. package/dist/cli/commands/cleanup.d.ts.map +1 -0
  73. package/dist/cli/commands/cleanup.js +130 -0
  74. package/dist/cli/commands/cleanup.js.map +1 -0
  75. package/dist/cli/commands/console.d.ts +8 -0
  76. package/dist/cli/commands/console.d.ts.map +1 -0
  77. package/dist/cli/commands/console.js +97 -0
  78. package/dist/cli/commands/console.js.map +1 -0
  79. package/dist/cli/commands/details.d.ts +8 -0
  80. package/dist/cli/commands/details.d.ts.map +1 -0
  81. package/dist/cli/commands/details.js +68 -0
  82. package/dist/cli/commands/details.js.map +1 -0
  83. package/dist/cli/commands/dom/helpers/domCache.d.ts +36 -0
  84. package/dist/cli/commands/dom/helpers/domCache.d.ts.map +1 -0
  85. package/dist/cli/commands/dom/helpers/domCache.js +65 -0
  86. package/dist/cli/commands/dom/helpers/domCache.js.map +1 -0
  87. package/dist/cli/commands/dom/helpers/domQuery.d.ts +48 -0
  88. package/dist/cli/commands/dom/helpers/domQuery.d.ts.map +1 -0
  89. package/dist/cli/commands/dom/helpers/domQuery.js +104 -0
  90. package/dist/cli/commands/dom/helpers/domQuery.js.map +1 -0
  91. package/dist/cli/commands/dom/helpers/errorHandler.d.ts +45 -0
  92. package/dist/cli/commands/dom/helpers/errorHandler.d.ts.map +1 -0
  93. package/dist/cli/commands/dom/helpers/errorHandler.js +70 -0
  94. package/dist/cli/commands/dom/helpers/errorHandler.js.map +1 -0
  95. package/dist/cli/commands/dom/helpers/evalHelpers.d.ts +52 -0
  96. package/dist/cli/commands/dom/helpers/evalHelpers.d.ts.map +1 -0
  97. package/dist/cli/commands/dom/helpers/evalHelpers.js +75 -0
  98. package/dist/cli/commands/dom/helpers/evalHelpers.js.map +1 -0
  99. package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts +35 -0
  100. package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts.map +1 -0
  101. package/dist/cli/commands/dom/helpers/optionsBuilder.js +51 -0
  102. package/dist/cli/commands/dom/helpers/optionsBuilder.js.map +1 -0
  103. package/dist/cli/commands/dom/helpers/selectorParser.d.ts +20 -0
  104. package/dist/cli/commands/dom/helpers/selectorParser.d.ts.map +1 -0
  105. package/dist/cli/commands/dom/helpers/selectorParser.js +20 -0
  106. package/dist/cli/commands/dom/helpers/selectorParser.js.map +1 -0
  107. package/dist/cli/commands/dom/index.d.ts +8 -0
  108. package/dist/cli/commands/dom/index.d.ts.map +1 -0
  109. package/dist/cli/commands/dom/index.js +257 -0
  110. package/dist/cli/commands/dom/index.js.map +1 -0
  111. package/dist/cli/commands/ipcTest.d.ts +23 -0
  112. package/dist/cli/commands/ipcTest.d.ts.map +1 -0
  113. package/dist/cli/commands/ipcTest.js +181 -0
  114. package/dist/cli/commands/ipcTest.js.map +1 -0
  115. package/dist/cli/commands/network.d.ts +8 -0
  116. package/dist/cli/commands/network.d.ts.map +1 -0
  117. package/dist/cli/commands/network.js +40 -0
  118. package/dist/cli/commands/network.js.map +1 -0
  119. package/dist/cli/commands/peek.d.ts +8 -0
  120. package/dist/cli/commands/peek.d.ts.map +1 -0
  121. package/dist/cli/commands/peek.js +109 -0
  122. package/dist/cli/commands/peek.js.map +1 -0
  123. package/dist/cli/commands/query.d.ts +9 -0
  124. package/dist/cli/commands/query.d.ts.map +1 -0
  125. package/dist/cli/commands/query.js +127 -0
  126. package/dist/cli/commands/query.js.map +1 -0
  127. package/dist/cli/commands/start.d.ts +9 -0
  128. package/dist/cli/commands/start.d.ts.map +1 -0
  129. package/dist/cli/commands/start.js +78 -0
  130. package/dist/cli/commands/start.js.map +1 -0
  131. package/dist/cli/commands/status.d.ts +9 -0
  132. package/dist/cli/commands/status.d.ts.map +1 -0
  133. package/dist/cli/commands/status.js +84 -0
  134. package/dist/cli/commands/status.js.map +1 -0
  135. package/dist/cli/commands/stop.d.ts +8 -0
  136. package/dist/cli/commands/stop.d.ts.map +1 -0
  137. package/dist/cli/commands/stop.js +146 -0
  138. package/dist/cli/commands/stop.js.map +1 -0
  139. package/dist/cli/formatters/detailsFormatter.d.ts +10 -0
  140. package/dist/cli/formatters/detailsFormatter.d.ts.map +1 -0
  141. package/dist/cli/formatters/detailsFormatter.js +63 -0
  142. package/dist/cli/formatters/detailsFormatter.js.map +1 -0
  143. package/dist/cli/formatters/previewFormatter.d.ts +27 -0
  144. package/dist/cli/formatters/previewFormatter.d.ts.map +1 -0
  145. package/dist/cli/formatters/previewFormatter.js +160 -0
  146. package/dist/cli/formatters/previewFormatter.js.map +1 -0
  147. package/dist/cli/formatters/statusFormatter.d.ts +34 -0
  148. package/dist/cli/formatters/statusFormatter.d.ts.map +1 -0
  149. package/dist/cli/formatters/statusFormatter.js +108 -0
  150. package/dist/cli/formatters/statusFormatter.js.map +1 -0
  151. package/dist/cli/handlers/ChromeBootstrap.d.ts +24 -0
  152. package/dist/cli/handlers/ChromeBootstrap.d.ts.map +1 -0
  153. package/dist/cli/handlers/ChromeBootstrap.js +50 -0
  154. package/dist/cli/handlers/ChromeBootstrap.js.map +1 -0
  155. package/dist/cli/handlers/CommandRunner.d.ts +60 -0
  156. package/dist/cli/handlers/CommandRunner.d.ts.map +1 -0
  157. package/dist/cli/handlers/CommandRunner.js +81 -0
  158. package/dist/cli/handlers/CommandRunner.js.map +1 -0
  159. package/dist/cli/handlers/OutputBuilder.d.ts +60 -0
  160. package/dist/cli/handlers/OutputBuilder.d.ts.map +1 -0
  161. package/dist/cli/handlers/OutputBuilder.js +138 -0
  162. package/dist/cli/handlers/OutputBuilder.js.map +1 -0
  163. package/dist/cli/handlers/OutputWriter.d.ts +15 -0
  164. package/dist/cli/handlers/OutputWriter.d.ts.map +1 -0
  165. package/dist/cli/handlers/OutputWriter.js +34 -0
  166. package/dist/cli/handlers/OutputWriter.js.map +1 -0
  167. package/dist/cli/handlers/PreviewWriter.d.ts +52 -0
  168. package/dist/cli/handlers/PreviewWriter.d.ts.map +1 -0
  169. package/dist/cli/handlers/PreviewWriter.js +119 -0
  170. package/dist/cli/handlers/PreviewWriter.js.map +1 -0
  171. package/dist/cli/handlers/SessionLock.d.ts +16 -0
  172. package/dist/cli/handlers/SessionLock.d.ts.map +1 -0
  173. package/dist/cli/handlers/SessionLock.js +38 -0
  174. package/dist/cli/handlers/SessionLock.js.map +1 -0
  175. package/dist/cli/handlers/SessionLoop.d.ts +19 -0
  176. package/dist/cli/handlers/SessionLoop.d.ts.map +1 -0
  177. package/dist/cli/handlers/SessionLoop.js +47 -0
  178. package/dist/cli/handlers/SessionLoop.js.map +1 -0
  179. package/dist/cli/handlers/ShutdownController.d.ts +38 -0
  180. package/dist/cli/handlers/ShutdownController.d.ts.map +1 -0
  181. package/dist/cli/handlers/ShutdownController.js +83 -0
  182. package/dist/cli/handlers/ShutdownController.js.map +1 -0
  183. package/dist/cli/handlers/SignalHandler.d.ts +35 -0
  184. package/dist/cli/handlers/SignalHandler.d.ts.map +1 -0
  185. package/dist/cli/handlers/SignalHandler.js +81 -0
  186. package/dist/cli/handlers/SignalHandler.js.map +1 -0
  187. package/dist/cli/handlers/TargetSetup.d.ts +42 -0
  188. package/dist/cli/handlers/TargetSetup.d.ts.map +1 -0
  189. package/dist/cli/handlers/TargetSetup.js +87 -0
  190. package/dist/cli/handlers/TargetSetup.js.map +1 -0
  191. package/dist/cli/handlers/commonOptions.d.ts +54 -0
  192. package/dist/cli/handlers/commonOptions.d.ts.map +1 -0
  193. package/dist/cli/handlers/commonOptions.js +64 -0
  194. package/dist/cli/handlers/commonOptions.js.map +1 -0
  195. package/dist/cli/handlers/daemonSessionController.d.ts +23 -0
  196. package/dist/cli/handlers/daemonSessionController.d.ts.map +1 -0
  197. package/dist/cli/handlers/daemonSessionController.js +108 -0
  198. package/dist/cli/handlers/daemonSessionController.js.map +1 -0
  199. package/dist/cli/handlers/sessionController.d.ts +21 -0
  200. package/dist/cli/handlers/sessionController.d.ts.map +1 -0
  201. package/dist/cli/handlers/sessionController.js +55 -0
  202. package/dist/cli/handlers/sessionController.js.map +1 -0
  203. package/dist/cli/registry.d.ts +11 -0
  204. package/dist/cli/registry.d.ts.map +1 -0
  205. package/dist/cli/registry.js +46 -0
  206. package/dist/cli/registry.js.map +1 -0
  207. package/dist/collectors/__tests__/network.contract.test.d.ts +28 -0
  208. package/dist/collectors/__tests__/network.contract.test.d.ts.map +1 -0
  209. package/dist/collectors/__tests__/network.contract.test.js +525 -0
  210. package/dist/collectors/__tests__/network.contract.test.js.map +1 -0
  211. package/dist/collectors/console.d.ts +5 -3
  212. package/dist/collectors/console.d.ts.map +1 -1
  213. package/dist/collectors/console.js +48 -26
  214. package/dist/collectors/console.js.map +1 -1
  215. package/dist/collectors/dom.d.ts +2 -2
  216. package/dist/collectors/dom.d.ts.map +1 -1
  217. package/dist/collectors/dom.js +23 -12
  218. package/dist/collectors/dom.js.map +1 -1
  219. package/dist/collectors/network.d.ts +18 -4
  220. package/dist/collectors/network.d.ts.map +1 -1
  221. package/dist/collectors/network.js +111 -34
  222. package/dist/collectors/network.js.map +1 -1
  223. package/dist/connection/__tests__/cdp.contract.test.d.ts +16 -0
  224. package/dist/connection/__tests__/cdp.contract.test.d.ts.map +1 -0
  225. package/dist/connection/__tests__/cdp.contract.test.js +378 -0
  226. package/dist/connection/__tests__/cdp.contract.test.js.map +1 -0
  227. package/dist/connection/__tests__/finder.contract.test.d.ts +2 -0
  228. package/dist/connection/__tests__/finder.contract.test.d.ts.map +1 -0
  229. package/dist/connection/__tests__/finder.contract.test.js +239 -0
  230. package/dist/connection/__tests__/finder.contract.test.js.map +1 -0
  231. package/dist/connection/__tests__/tabs.contract.test.d.ts +2 -0
  232. package/dist/connection/__tests__/tabs.contract.test.d.ts.map +1 -0
  233. package/dist/connection/__tests__/tabs.contract.test.js +137 -0
  234. package/dist/connection/__tests__/tabs.contract.test.js.map +1 -0
  235. package/dist/connection/cdp.d.ts +165 -16
  236. package/dist/connection/cdp.d.ts.map +1 -1
  237. package/dist/connection/cdp.js +342 -122
  238. package/dist/connection/cdp.js.map +1 -1
  239. package/dist/connection/finder.d.ts +5 -4
  240. package/dist/connection/finder.d.ts.map +1 -1
  241. package/dist/connection/finder.js +10 -16
  242. package/dist/connection/finder.js.map +1 -1
  243. package/dist/connection/launcher.d.ts +18 -11
  244. package/dist/connection/launcher.d.ts.map +1 -1
  245. package/dist/connection/launcher.js +148 -82
  246. package/dist/connection/launcher.js.map +1 -1
  247. package/dist/connection/tabs.d.ts +47 -14
  248. package/dist/connection/tabs.d.ts.map +1 -1
  249. package/dist/connection/tabs.js +493 -132
  250. package/dist/connection/tabs.js.map +1 -1
  251. package/dist/constants.d.ts +209 -0
  252. package/dist/constants.d.ts.map +1 -0
  253. package/dist/constants.js +232 -0
  254. package/dist/constants.js.map +1 -0
  255. package/dist/daemon/__tests__/ipcServer.contract.test.d.ts +23 -0
  256. package/dist/daemon/__tests__/ipcServer.contract.test.d.ts.map +1 -0
  257. package/dist/daemon/__tests__/ipcServer.contract.test.js +401 -0
  258. package/dist/daemon/__tests__/ipcServer.contract.test.js.map +1 -0
  259. package/dist/daemon/__tests__/launcher.unit.test.d.ts +8 -0
  260. package/dist/daemon/__tests__/launcher.unit.test.d.ts.map +1 -0
  261. package/dist/daemon/__tests__/launcher.unit.test.js +20 -0
  262. package/dist/daemon/__tests__/launcher.unit.test.js.map +1 -0
  263. package/dist/daemon/ipcServer.d.ts +83 -0
  264. package/dist/daemon/ipcServer.d.ts.map +1 -0
  265. package/dist/daemon/ipcServer.js +670 -0
  266. package/dist/daemon/ipcServer.js.map +1 -0
  267. package/dist/daemon/launcher.d.ts +31 -0
  268. package/dist/daemon/launcher.d.ts.map +1 -0
  269. package/dist/daemon/launcher.js +137 -0
  270. package/dist/daemon/launcher.js.map +1 -0
  271. package/dist/daemon/startSession.d.ts +51 -0
  272. package/dist/daemon/startSession.d.ts.map +1 -0
  273. package/dist/daemon/startSession.js +149 -0
  274. package/dist/daemon/startSession.js.map +1 -0
  275. package/dist/daemon/worker.d.ts +18 -0
  276. package/dist/daemon/worker.d.ts.map +1 -0
  277. package/dist/daemon/worker.js +623 -0
  278. package/dist/daemon/worker.js.map +1 -0
  279. package/dist/daemon/workerIpc.d.ts +33 -0
  280. package/dist/daemon/workerIpc.d.ts.map +1 -0
  281. package/dist/daemon/workerIpc.js +8 -0
  282. package/dist/daemon/workerIpc.js.map +1 -0
  283. package/dist/daemon.d.ts +10 -0
  284. package/dist/daemon.d.ts.map +1 -0
  285. package/dist/daemon.js +32 -0
  286. package/dist/daemon.js.map +1 -0
  287. package/dist/index.js +41 -420
  288. package/dist/index.js.map +1 -1
  289. package/dist/ipc/__tests__/client.contract.test.d.ts +23 -0
  290. package/dist/ipc/__tests__/client.contract.test.d.ts.map +1 -0
  291. package/dist/ipc/__tests__/client.contract.test.js +466 -0
  292. package/dist/ipc/__tests__/client.contract.test.js.map +1 -0
  293. package/dist/ipc/client.d.ts +109 -0
  294. package/dist/ipc/client.d.ts.map +1 -0
  295. package/dist/ipc/client.js +220 -0
  296. package/dist/ipc/client.js.map +1 -0
  297. package/dist/ipc/commands.d.ts +208 -0
  298. package/dist/ipc/commands.d.ts.map +1 -0
  299. package/dist/ipc/commands.js +69 -0
  300. package/dist/ipc/commands.js.map +1 -0
  301. package/dist/ipc/responseValidator.d.ts +40 -0
  302. package/dist/ipc/responseValidator.d.ts.map +1 -0
  303. package/dist/ipc/responseValidator.js +28 -0
  304. package/dist/ipc/responseValidator.js.map +1 -0
  305. package/dist/ipc/types.d.ts +193 -0
  306. package/dist/ipc/types.d.ts.map +1 -0
  307. package/dist/ipc/types.js +21 -0
  308. package/dist/ipc/types.js.map +1 -0
  309. package/dist/session/BdgSession.d.ts +71 -4
  310. package/dist/session/BdgSession.d.ts.map +1 -1
  311. package/dist/session/BdgSession.js +173 -75
  312. package/dist/session/BdgSession.js.map +1 -1
  313. package/dist/session/chrome.d.ts +46 -0
  314. package/dist/session/chrome.d.ts.map +1 -0
  315. package/dist/session/chrome.js +92 -0
  316. package/dist/session/chrome.js.map +1 -0
  317. package/dist/session/cleanup.d.ts +45 -0
  318. package/dist/session/cleanup.d.ts.map +1 -0
  319. package/dist/session/cleanup.js +230 -0
  320. package/dist/session/cleanup.js.map +1 -0
  321. package/dist/session/index.d.ts +15 -0
  322. package/dist/session/index.d.ts.map +1 -0
  323. package/dist/session/index.js +23 -0
  324. package/dist/session/index.js.map +1 -0
  325. package/dist/session/lock.d.ts +57 -0
  326. package/dist/session/lock.d.ts.map +1 -0
  327. package/dist/session/lock.js +154 -0
  328. package/dist/session/lock.js.map +1 -0
  329. package/dist/session/metadata.d.ts +59 -0
  330. package/dist/session/metadata.d.ts.map +1 -0
  331. package/dist/session/metadata.js +71 -0
  332. package/dist/session/metadata.js.map +1 -0
  333. package/dist/session/output.d.ts +18 -0
  334. package/dist/session/output.d.ts.map +1 -0
  335. package/dist/session/output.js +24 -0
  336. package/dist/session/output.js.map +1 -0
  337. package/dist/session/paths.d.ts +73 -0
  338. package/dist/session/paths.d.ts.map +1 -0
  339. package/dist/session/paths.js +84 -0
  340. package/dist/session/paths.js.map +1 -0
  341. package/dist/session/pid.d.ts +40 -0
  342. package/dist/session/pid.d.ts.map +1 -0
  343. package/dist/session/pid.js +73 -0
  344. package/dist/session/pid.js.map +1 -0
  345. package/dist/session/process.d.ts +45 -0
  346. package/dist/session/process.d.ts.map +1 -0
  347. package/dist/session/process.js +88 -0
  348. package/dist/session/process.js.map +1 -0
  349. package/dist/types.d.ts +114 -38
  350. package/dist/types.d.ts.map +1 -1
  351. package/dist/utils/__tests__/filters.unit.test.d.ts +2 -0
  352. package/dist/utils/__tests__/filters.unit.test.d.ts.map +1 -0
  353. package/dist/utils/__tests__/filters.unit.test.js +239 -0
  354. package/dist/utils/__tests__/filters.unit.test.js.map +1 -0
  355. package/dist/utils/__tests__/session.contract.test.d.ts +2 -0
  356. package/dist/utils/__tests__/session.contract.test.d.ts.map +1 -0
  357. package/dist/utils/__tests__/session.contract.test.js +234 -0
  358. package/dist/utils/__tests__/session.contract.test.js.map +1 -0
  359. package/dist/utils/atomicFile.d.ts +38 -0
  360. package/dist/utils/atomicFile.d.ts.map +1 -0
  361. package/dist/utils/atomicFile.js +71 -0
  362. package/dist/utils/atomicFile.js.map +1 -0
  363. package/dist/utils/cdpHandlers.d.ts +31 -0
  364. package/dist/utils/cdpHandlers.d.ts.map +1 -0
  365. package/dist/utils/cdpHandlers.js +38 -0
  366. package/dist/utils/cdpHandlers.js.map +1 -0
  367. package/dist/utils/chromeDiagnostics.d.ts +28 -0
  368. package/dist/utils/chromeDiagnostics.d.ts.map +1 -0
  369. package/dist/utils/chromeDiagnostics.js +88 -0
  370. package/dist/utils/chromeDiagnostics.js.map +1 -0
  371. package/dist/utils/errors.d.ts +82 -0
  372. package/dist/utils/errors.d.ts.map +1 -0
  373. package/dist/utils/errors.js +88 -0
  374. package/dist/utils/errors.js.map +1 -0
  375. package/dist/utils/exitCodes.d.ts +32 -0
  376. package/dist/utils/exitCodes.d.ts.map +1 -0
  377. package/dist/utils/exitCodes.js +36 -0
  378. package/dist/utils/exitCodes.js.map +1 -0
  379. package/dist/utils/filters.d.ts +108 -0
  380. package/dist/utils/filters.d.ts.map +1 -0
  381. package/dist/utils/filters.js +304 -0
  382. package/dist/utils/filters.js.map +1 -0
  383. package/dist/utils/formatters/network.d.ts +23 -0
  384. package/dist/utils/formatters/network.d.ts.map +1 -0
  385. package/dist/utils/formatters/network.js +35 -0
  386. package/dist/utils/formatters/network.js.map +1 -0
  387. package/dist/utils/http.d.ts +34 -0
  388. package/dist/utils/http.d.ts.map +1 -0
  389. package/dist/utils/http.js +48 -0
  390. package/dist/utils/http.js.map +1 -0
  391. package/dist/utils/logger.d.ts +42 -0
  392. package/dist/utils/logger.d.ts.map +1 -0
  393. package/dist/utils/logger.js +43 -0
  394. package/dist/utils/logger.js.map +1 -0
  395. package/dist/utils/objects.d.ts +23 -0
  396. package/dist/utils/objects.d.ts.map +1 -0
  397. package/dist/utils/objects.js +25 -0
  398. package/dist/utils/objects.js.map +1 -0
  399. package/dist/utils/url/safeParseUrl.d.ts +63 -0
  400. package/dist/utils/url/safeParseUrl.d.ts.map +1 -0
  401. package/dist/utils/url/safeParseUrl.js +84 -0
  402. package/dist/utils/url/safeParseUrl.js.map +1 -0
  403. package/dist/utils/url.d.ts +63 -1
  404. package/dist/utils/url.d.ts.map +1 -1
  405. package/dist/utils/url.js +152 -2
  406. package/dist/utils/url.js.map +1 -1
  407. package/dist/utils/validation.d.ts +1 -1
  408. package/dist/utils/validation.d.ts.map +1 -1
  409. package/dist/utils/version.d.ts +3 -0
  410. package/dist/utils/version.d.ts.map +1 -0
  411. package/dist/utils/version.js +27 -0
  412. package/dist/utils/version.js.map +1 -0
  413. package/package.json +57 -10
  414. package/dist/utils/pageLoad.d.ts +0 -21
  415. package/dist/utils/pageLoad.d.ts.map +0 -1
  416. package/dist/utils/pageLoad.js +0 -85
  417. package/dist/utils/pageLoad.js.map +0 -1
  418. package/dist/utils/session.d.ts +0 -104
  419. package/dist/utils/session.d.ts.map +0 -1
  420. package/dist/utils/session.js +0 -244
  421. package/dist/utils/session.js.map +0 -1
@@ -0,0 +1,81 @@
1
+ import { OutputBuilder } from '../handlers/OutputBuilder.js';
2
+ import { getErrorMessage } from '../../utils/errors.js';
3
+ import { EXIT_CODES } from '../../utils/exitCodes.js';
4
+ /**
5
+ * Run a command with consistent error handling, output formatting, and exit codes.
6
+ * Eliminates boilerplate try-catch and JSON output logic from command handlers.
7
+ *
8
+ * This helper:
9
+ * - Wraps command logic in try-catch
10
+ * - Handles IPC connection errors (ENOENT, ECONNREFUSED)
11
+ * - Formats output as JSON or human-readable based on --json flag
12
+ * - Calls process.exit() with appropriate exit code
13
+ *
14
+ * @param handler - Command logic that returns CommandResult or throws
15
+ * @param options - Command options (must include json flag)
16
+ * @param formatter - Optional human-readable formatter (if not provided, outputs raw JSON)
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * await runCommand(
21
+ * async (opts) => {
22
+ * const data = await fetchData(opts.url);
23
+ * return { success: true, data };
24
+ * },
25
+ * options,
26
+ * formatData
27
+ * );
28
+ * ```
29
+ */
30
+ export async function runCommand(handler, options, formatter) {
31
+ try {
32
+ const result = await handler(options);
33
+ if (!result.success) {
34
+ // Error result from handler
35
+ if (options.json) {
36
+ console.log(JSON.stringify(OutputBuilder.buildJsonError(result.error ?? 'Unknown error'), null, 2));
37
+ }
38
+ else {
39
+ console.error(`Error: ${result.error ?? 'Unknown error'}`);
40
+ }
41
+ process.exit(result.exitCode ?? EXIT_CODES.UNHANDLED_EXCEPTION);
42
+ }
43
+ // Success - output data
44
+ if (options.json) {
45
+ console.log(JSON.stringify(result.data, null, 2));
46
+ }
47
+ else if (formatter) {
48
+ formatter(result.data);
49
+ }
50
+ else {
51
+ // Fallback: JSON output if no formatter provided
52
+ console.log(JSON.stringify(result.data, null, 2));
53
+ }
54
+ process.exit(EXIT_CODES.SUCCESS);
55
+ }
56
+ catch (error) {
57
+ const errorMessage = getErrorMessage(error);
58
+ // Detect daemon connection errors
59
+ if (errorMessage.includes('ENOENT') || errorMessage.includes('ECONNREFUSED')) {
60
+ if (options.json) {
61
+ console.log(JSON.stringify(OutputBuilder.buildJsonError('Daemon not running', {
62
+ suggestion: 'Start it with: bdg <url>',
63
+ }), null, 2));
64
+ }
65
+ else {
66
+ console.error('Error: Daemon not running');
67
+ console.error('Start it with: bdg <url>');
68
+ }
69
+ process.exit(EXIT_CODES.RESOURCE_NOT_FOUND);
70
+ }
71
+ // Generic error
72
+ if (options.json) {
73
+ console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMessage), null, 2));
74
+ }
75
+ else {
76
+ console.error(`Error: ${errorMessage}`);
77
+ }
78
+ process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
79
+ }
80
+ }
81
+ //# sourceMappingURL=CommandRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandRunner.js","sourceRoot":"","sources":["../../../src/cli/handlers/CommandRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAwClD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA0C,EAC1C,OAAiB,EACjB,SAAqC;IAErC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,4BAA4B;YAC5B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CACvF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAAC;QAClE,CAAC;QAED,wBAAwB;QACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;aAAM,IAAI,SAAS,EAAE,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CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { BdgOutput, CDPTarget, NetworkRequest, ConsoleMessage, DOMData, CollectorType } from '../../types.js';
2
+ /**
3
+ * Output mode determines what data is included and how partial flag is set
4
+ */
5
+ export type OutputMode = 'preview' | 'full' | 'final';
6
+ /**
7
+ * Options for building output payloads
8
+ */
9
+ export interface OutputBuilderOptions {
10
+ mode: OutputMode;
11
+ target: CDPTarget;
12
+ startTime: number;
13
+ networkRequests: NetworkRequest[];
14
+ consoleLogs: ConsoleMessage[];
15
+ domData?: DOMData;
16
+ activeCollectors: CollectorType[];
17
+ }
18
+ /**
19
+ * Helper: build output payloads for different modes with consistent metadata.
20
+ * Modes: preview (metadata only), full (with bodies), final (complete with DOM).
21
+ */
22
+ export declare class OutputBuilder {
23
+ /**
24
+ * Build session output with consistent metadata.
25
+ *
26
+ * @param options - Configuration for output construction
27
+ * @returns BdgOutput payload
28
+ */
29
+ static build(options: OutputBuilderOptions): BdgOutput;
30
+ /**
31
+ * Build error output with consistent structure.
32
+ *
33
+ * @param error - Error object or string
34
+ * @param startTime - Session start timestamp
35
+ * @param target - Optional target information
36
+ * @returns BdgOutput payload with error
37
+ */
38
+ static buildError(error: unknown, startTime: number, target?: CDPTarget): BdgOutput;
39
+ /**
40
+ * Build a simple JSON error response for commands.
41
+ * Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
42
+ *
43
+ * @param error - Error message or Error object
44
+ * @param options - Optional fields (exitCode, additional data)
45
+ * @returns JSON-serializable error object
46
+ */
47
+ static buildJsonError(error: string | Error, options?: {
48
+ exitCode?: number;
49
+ [key: string]: unknown;
50
+ }): Record<string, unknown>;
51
+ /**
52
+ * Build a simple JSON success response for commands.
53
+ * Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
54
+ *
55
+ * @param data - Response data
56
+ * @returns JSON-serializable success object
57
+ */
58
+ static buildJsonSuccess(data: Record<string, unknown>): Record<string, unknown>;
59
+ }
60
+ //# sourceMappingURL=OutputBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputBuilder.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/OutputBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,cAAc,EACd,OAAO,EACP,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,aAAa,EAAE,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS;IA4FtD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAYnF;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CACnB,KAAK,EAAE,MAAM,GAAG,KAAK,EACrB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACtD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAS1B;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOhF"}
@@ -0,0 +1,138 @@
1
+ import { getErrorMessage } from '../../utils/errors.js';
2
+ import { VERSION } from '../../utils/version.js';
3
+ /**
4
+ * Helper: build output payloads for different modes with consistent metadata.
5
+ * Modes: preview (metadata only), full (with bodies), final (complete with DOM).
6
+ */
7
+ export class OutputBuilder {
8
+ /**
9
+ * Build session output with consistent metadata.
10
+ *
11
+ * @param options - Configuration for output construction
12
+ * @returns BdgOutput payload
13
+ */
14
+ static build(options) {
15
+ const { mode, target, startTime, networkRequests, consoleLogs, domData, activeCollectors } = options;
16
+ const baseOutput = {
17
+ version: VERSION,
18
+ success: true,
19
+ timestamp: new Date().toISOString(),
20
+ duration: Date.now() - startTime,
21
+ target: {
22
+ url: target.url,
23
+ title: target.title,
24
+ },
25
+ // Only final outputs are complete (partial=false)
26
+ partial: mode !== 'final',
27
+ };
28
+ if (mode === 'preview') {
29
+ // Lightweight preview: metadata only, last 1000 items
30
+ const previewData = {};
31
+ if (activeCollectors.includes('network')) {
32
+ previewData['network'] = networkRequests.slice(-1000).map((req) => ({
33
+ requestId: req.requestId,
34
+ url: req.url,
35
+ method: req.method,
36
+ timestamp: req.timestamp,
37
+ status: req.status,
38
+ mimeType: req.mimeType,
39
+ // Exclude requestBody, responseBody, headers for lightweight preview
40
+ }));
41
+ }
42
+ if (activeCollectors.includes('console')) {
43
+ previewData['console'] = consoleLogs.slice(-1000).map((msg) => ({
44
+ type: msg.type,
45
+ text: msg.text,
46
+ timestamp: msg.timestamp,
47
+ // Exclude args for lightweight preview
48
+ }));
49
+ }
50
+ // DOM omitted in preview (only captured on stop)
51
+ return {
52
+ ...baseOutput,
53
+ data: previewData,
54
+ };
55
+ }
56
+ if (mode === 'full') {
57
+ // Full mode: complete data with bodies
58
+ const fullData = {};
59
+ if (activeCollectors.includes('network')) {
60
+ fullData['network'] = networkRequests; // All data with bodies
61
+ }
62
+ if (activeCollectors.includes('console')) {
63
+ fullData['console'] = consoleLogs; // All data with args
64
+ }
65
+ // DOM omitted (only captured on stop)
66
+ return {
67
+ ...baseOutput,
68
+ data: fullData,
69
+ };
70
+ }
71
+ // Final mode - includes DOM, partial=false
72
+ const finalData = {};
73
+ if (activeCollectors.includes('network')) {
74
+ finalData['network'] = networkRequests;
75
+ }
76
+ if (activeCollectors.includes('console')) {
77
+ finalData['console'] = consoleLogs;
78
+ }
79
+ if (activeCollectors.includes('dom') && domData) {
80
+ finalData['dom'] = domData;
81
+ }
82
+ return {
83
+ ...baseOutput,
84
+ partial: false,
85
+ data: finalData,
86
+ };
87
+ }
88
+ /**
89
+ * Build error output with consistent structure.
90
+ *
91
+ * @param error - Error object or string
92
+ * @param startTime - Session start timestamp
93
+ * @param target - Optional target information
94
+ * @returns BdgOutput payload with error
95
+ */
96
+ static buildError(error, startTime, target) {
97
+ return {
98
+ version: VERSION,
99
+ success: false,
100
+ timestamp: new Date().toISOString(),
101
+ duration: Date.now() - startTime,
102
+ target: target ? { url: target.url, title: target.title } : { url: '', title: '' },
103
+ data: {},
104
+ error: getErrorMessage(error),
105
+ };
106
+ }
107
+ /**
108
+ * Build a simple JSON error response for commands.
109
+ * Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
110
+ *
111
+ * @param error - Error message or Error object
112
+ * @param options - Optional fields (exitCode, additional data)
113
+ * @returns JSON-serializable error object
114
+ */
115
+ static buildJsonError(error, options) {
116
+ return {
117
+ version: VERSION,
118
+ success: false,
119
+ error: error instanceof Error ? error.message : error,
120
+ ...options,
121
+ };
122
+ }
123
+ /**
124
+ * Build a simple JSON success response for commands.
125
+ * Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
126
+ *
127
+ * @param data - Response data
128
+ * @returns JSON-serializable success object
129
+ */
130
+ static buildJsonSuccess(data) {
131
+ return {
132
+ version: VERSION,
133
+ success: true,
134
+ ...data,
135
+ };
136
+ }
137
+ }
138
+ //# sourceMappingURL=OutputBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":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,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { BdgOutput } from '../../types.js';
2
+ /**
3
+ * Handles writing session output to files and console
4
+ */
5
+ export declare class OutputWriter {
6
+ /**
7
+ * Write session output to file and stdout.
8
+ *
9
+ * @param output - The output payload to write
10
+ * @param exitCode - 0 for success, 1 for error
11
+ * @param compact - If true, use compact JSON format (no indentation)
12
+ */
13
+ writeSessionOutput(output: BdgOutput, exitCode: 0 | 1, compact?: boolean): void;
14
+ }
15
+ //# sourceMappingURL=OutputWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputWriter.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/OutputWriter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI;CAsBvF"}
@@ -0,0 +1,34 @@
1
+ import { writeSessionOutput } from '../../session/output.js';
2
+ /**
3
+ * Handles writing session output to files and console
4
+ */
5
+ export class OutputWriter {
6
+ /**
7
+ * Write session output to file and stdout.
8
+ *
9
+ * @param output - The output payload to write
10
+ * @param exitCode - 0 for success, 1 for error
11
+ * @param compact - If true, use compact JSON format (no indentation)
12
+ */
13
+ writeSessionOutput(output, exitCode, compact = false) {
14
+ // Write output to file for 'bdg stop' to read
15
+ try {
16
+ const message = exitCode === 0 ? 'Writing session output...' : 'Writing error output...';
17
+ console.error(message);
18
+ writeSessionOutput(output, compact);
19
+ const successMessage = exitCode === 0
20
+ ? 'Session output written successfully'
21
+ : 'Error output written successfully';
22
+ console.error(successMessage);
23
+ }
24
+ catch (writeError) {
25
+ const errorMessage = exitCode === 0 ? 'Failed to write session output:' : 'Failed to write error output:';
26
+ console.error(errorMessage, writeError);
27
+ console.error('Write error details:', writeError);
28
+ }
29
+ // Output to stdout (for foreground use)
30
+ const jsonString = compact ? JSON.stringify(output) : JSON.stringify(output, null, 2);
31
+ console.log(jsonString);
32
+ }
33
+ }
34
+ //# sourceMappingURL=OutputWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputWriter.js","sourceRoot":"","sources":["../../../src/cli/handlers/OutputWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAiB,EAAE,QAAe,EAAE,UAAmB,KAAK;QAC7E,8CAA8C;QAC9C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,yBAAyB,CAAC;YACzF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACpC,MAAM,cAAc,GAClB,QAAQ,KAAK,CAAC;gBACZ,CAAC,CAAC,qCAAqC;gBACvC,CAAC,CAAC,mCAAmC,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,MAAM,YAAY,GAChB,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,+BAA+B,CAAC;YACvF,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC;QAED,wCAAwC;QACxC,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ import type { CDPTarget, NetworkRequest, ConsoleMessage, CollectorType } from '../../types.js';
2
+ /**
3
+ * Interface for accessing session data without direct coupling
4
+ */
5
+ export interface PreviewDataSource {
6
+ getTarget: () => CDPTarget;
7
+ getNetworkRequests: () => NetworkRequest[];
8
+ getConsoleLogs: () => ConsoleMessage[];
9
+ getActiveCollectors: () => CollectorType[];
10
+ isConnected: () => boolean;
11
+ }
12
+ /**
13
+ * Manages two-tier preview system with async I/O and mutex
14
+ *
15
+ * Periodically writes both lightweight preview and full data files
16
+ * to enable efficient monitoring without stopping collection.
17
+ */
18
+ export declare class PreviewWriter {
19
+ private dataSource;
20
+ private startTime;
21
+ private intervalMs;
22
+ private compact;
23
+ private interval;
24
+ private pendingWrite;
25
+ private isWriting;
26
+ constructor(dataSource: PreviewDataSource, startTime: number, intervalMs?: number, compact?: boolean);
27
+ /**
28
+ * Start periodic preview writes.
29
+ */
30
+ start(): void;
31
+ /**
32
+ * Stop preview writes and clear interval.
33
+ */
34
+ stop(): void;
35
+ /**
36
+ * Wait for any in-flight write to complete.
37
+ * Called during shutdown to prevent race conditions.
38
+ */
39
+ waitForPendingWrite(): Promise<void>;
40
+ /**
41
+ * Execute a single preview write cycle (internal)
42
+ */
43
+ private writePreview;
44
+ /**
45
+ * Perform the actual write operation (internal)
46
+ *
47
+ * Passes original arrays for active collectors, empty arrays for inactive ones.
48
+ * No cloning needed - OutputBuilder serializes immediately, avoiding unnecessary copies.
49
+ */
50
+ private doWrite;
51
+ }
52
+ //# sourceMappingURL=PreviewWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewWriter.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/PreviewWriter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKxF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,SAAS,CAAC;IAC3B,kBAAkB,EAAE,MAAM,cAAc,EAAE,CAAC;IAC3C,cAAc,EAAE,MAAM,cAAc,EAAE,CAAC;IACvC,mBAAmB,EAAE,MAAM,aAAa,EAAE,CAAC;IAC3C,WAAW,EAAE,MAAM,OAAO,CAAC;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IAMtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,SAAS,CAAS;gBAGhB,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAAa,EACzB,OAAO,GAAE,OAAe;IAGlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAY1C;;OAEG;IACH,OAAO,CAAC,YAAY;IAsBpB;;;;;OAKG;YACW,OAAO;CAqCtB"}
@@ -0,0 +1,119 @@
1
+ import { writePartialOutputAsync, writeFullOutputAsync } from '../../session/output.js';
2
+ import { getErrorMessage } from '../../utils/errors.js';
3
+ import { OutputBuilder } from './OutputBuilder.js';
4
+ /**
5
+ * Manages two-tier preview system with async I/O and mutex
6
+ *
7
+ * Periodically writes both lightweight preview and full data files
8
+ * to enable efficient monitoring without stopping collection.
9
+ */
10
+ export class PreviewWriter {
11
+ dataSource;
12
+ startTime;
13
+ intervalMs;
14
+ compact;
15
+ interval = null;
16
+ pendingWrite = null;
17
+ isWriting = false;
18
+ constructor(dataSource, startTime, intervalMs = 5000, compact = false) {
19
+ this.dataSource = dataSource;
20
+ this.startTime = startTime;
21
+ this.intervalMs = intervalMs;
22
+ this.compact = compact;
23
+ }
24
+ /**
25
+ * Start periodic preview writes.
26
+ */
27
+ start() {
28
+ this.interval = setInterval(() => {
29
+ this.writePreview();
30
+ }, this.intervalMs);
31
+ }
32
+ /**
33
+ * Stop preview writes and clear interval.
34
+ */
35
+ stop() {
36
+ if (this.interval) {
37
+ clearInterval(this.interval);
38
+ this.interval = null;
39
+ }
40
+ }
41
+ /**
42
+ * Wait for any in-flight write to complete.
43
+ * Called during shutdown to prevent race conditions.
44
+ */
45
+ async waitForPendingWrite() {
46
+ if (this.pendingWrite) {
47
+ console.error('Waiting for in-flight write to complete...');
48
+ try {
49
+ await this.pendingWrite;
50
+ console.error('In-flight write completed');
51
+ }
52
+ catch (error) {
53
+ console.error('Error in pending write (ignoring):', error);
54
+ }
55
+ }
56
+ }
57
+ /**
58
+ * Execute a single preview write cycle (internal)
59
+ */
60
+ writePreview() {
61
+ // Skip if previous write in progress or disconnected
62
+ if (this.isWriting || !this.dataSource.isConnected()) {
63
+ if (this.isWriting) {
64
+ console.error('[PERF] Skipping preview write (previous write still in progress)');
65
+ }
66
+ return;
67
+ }
68
+ this.isWriting = true;
69
+ // Create and track the write promise so shutdown can await it
70
+ this.pendingWrite = this.doWrite()
71
+ .catch((error) => {
72
+ console.error('Warning: Failed to write preview data:', getErrorMessage(error));
73
+ })
74
+ .finally(() => {
75
+ this.isWriting = false;
76
+ this.pendingWrite = null;
77
+ });
78
+ }
79
+ /**
80
+ * Perform the actual write operation (internal)
81
+ *
82
+ * Passes original arrays for active collectors, empty arrays for inactive ones.
83
+ * No cloning needed - OutputBuilder serializes immediately, avoiding unnecessary copies.
84
+ */
85
+ async doWrite() {
86
+ const target = this.dataSource.getTarget();
87
+ const activeCollectors = this.dataSource.getActiveCollectors();
88
+ // Pass original arrays when active, empty arrays when inactive (no cloning needed)
89
+ const networkRequests = activeCollectors.includes('network')
90
+ ? this.dataSource.getNetworkRequests()
91
+ : [];
92
+ const consoleLogs = activeCollectors.includes('console')
93
+ ? this.dataSource.getConsoleLogs()
94
+ : [];
95
+ // Build both preview and full outputs
96
+ const previewOutput = OutputBuilder.build({
97
+ mode: 'preview',
98
+ target,
99
+ startTime: this.startTime,
100
+ networkRequests,
101
+ consoleLogs,
102
+ activeCollectors,
103
+ });
104
+ const fullOutput = OutputBuilder.build({
105
+ mode: 'full',
106
+ target,
107
+ startTime: this.startTime,
108
+ networkRequests,
109
+ consoleLogs,
110
+ activeCollectors,
111
+ });
112
+ // Write both files in parallel (async, non-blocking)
113
+ await Promise.all([
114
+ writePartialOutputAsync(previewOutput, this.compact), // ~500KB - for 'bdg peek'
115
+ writeFullOutputAsync(fullOutput, this.compact), // ~87MB - for 'bdg details'
116
+ ]);
117
+ }
118
+ }
119
+ //# sourceMappingURL=PreviewWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewWriter.js","sourceRoot":"","sources":["../../../src/cli/handlers/PreviewWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAMd;IACA;IACA;IACA;IARF,QAAQ,GAA0B,IAAI,CAAC;IACvC,YAAY,GAAyB,IAAI,CAAC;IAC1C,SAAS,GAAG,KAAK,CAAC;IAE1B,YACU,UAA6B,EAC7B,SAAiB,EACjB,aAAqB,IAAI,EACzB,UAAmB,KAAK;QAHxB,eAAU,GAAV,UAAU,CAAmB;QAC7B,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAe;QACzB,YAAO,GAAP,OAAO,CAAiB;IAC/B,CAAC;IAEJ;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ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'../../types.js';
2
+ /**
3
+ * Handles session lock acquisition and validation
4
+ */
5
+ export declare class SessionLock {
6
+ /**
7
+ * Acquire session lock and validate inputs
8
+ *
9
+ * @param url - Target URL to monitor
10
+ * @param collectors - Collector types to enable
11
+ * @returns Normalized URL
12
+ * @throws Error if session already running or validation fails
13
+ */
14
+ static acquire(url: string, collectors: CollectorType[]): string;
15
+ }
16
+ //# sourceMappingURL=SessionLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLock.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLock.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,MAAM;CAsBjE"}
@@ -0,0 +1,38 @@
1
+ import { cleanupSession } from '../../session/cleanup.js';
2
+ import { acquireSessionLock } from '../../session/lock.js';
3
+ import { readPid } from '../../session/pid.js';
4
+ import { isProcessAlive } from '../../session/process.js';
5
+ import { normalizeUrl } from '../../utils/url.js';
6
+ import { validateCollectorTypes } from '../../utils/validation.js';
7
+ /**
8
+ * Handles session lock acquisition and validation
9
+ */
10
+ export class SessionLock {
11
+ /**
12
+ * Acquire session lock and validate inputs
13
+ *
14
+ * @param url - Target URL to monitor
15
+ * @param collectors - Collector types to enable
16
+ * @returns Normalized URL
17
+ * @throws Error if session already running or validation fails
18
+ */
19
+ static acquire(url, collectors) {
20
+ const existingPid = readPid();
21
+ // Check for stale session before trying to acquire lock
22
+ if (existingPid && !isProcessAlive(existingPid)) {
23
+ console.error(`Found stale session (PID ${existingPid} not running)`);
24
+ console.error('Cleaning up stale session files...');
25
+ cleanupSession();
26
+ console.error('Stale session cleaned up');
27
+ }
28
+ if (!acquireSessionLock()) {
29
+ const currentPid = readPid();
30
+ throw new Error(`Session already running (PID ${currentPid}). Stop it with: bdg stop`);
31
+ }
32
+ // Validate collector types
33
+ validateCollectorTypes(collectors);
34
+ // Normalize URL - add http:// if no protocol specified
35
+ return normalizeUrl(url);
36
+ }
37
+ }
38
+ //# sourceMappingURL=SessionLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLock.js","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,UAA2B;QACrD,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;QAE9B,wDAAwD;QACxD,IAAI,WAAW,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,4BAA4B,WAAW,eAAe,CAAC,CAAC;YACtE,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACpD,cAAc,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC1B,MAAM,UAAU,GAAG,OAAO,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,gCAAgC,UAAU,2BAA2B,CAAC,CAAC;QACzF,CAAC;QAED,2BAA2B;QAC3B,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAEnC,uDAAuD;QACvD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { BdgSession } from '../../session/BdgSession.js';
2
+ import type { CDPTarget } from '../../types.js';
3
+ /**
4
+ * Manages the session monitoring loop
5
+ */
6
+ export declare class SessionLoop {
7
+ /**
8
+ * Run session loop until stopped or error
9
+ *
10
+ * Monitors WebSocket connection and target lifecycle.
11
+ * Throws error if connection lost or tab closed.
12
+ *
13
+ * @param session - Active BDG session instance
14
+ * @param target - CDP target being monitored
15
+ * @throws Error if WebSocket connection lost or browser tab closed
16
+ */
17
+ static run(session: BdgSession, target: CDPTarget): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=SessionLoop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionLoop.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLoop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAA4B,MAAM,SAAS,CAAC;AAEnE;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;OASG;WACU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CxE"}