@vforsh/argus-watcher 0.1.2 → 0.1.4

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 (355) hide show
  1. package/README.md +67 -14
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/artifacts.d.ts +13 -0
  4. package/dist/artifacts.d.ts.map +1 -0
  5. package/dist/artifacts.js +27 -0
  6. package/dist/artifacts.js.map +1 -0
  7. package/dist/buffer/LogBuffer.d.ts +8 -3
  8. package/dist/buffer/LogBuffer.d.ts.map +1 -1
  9. package/dist/buffer/LogBuffer.js +9 -1
  10. package/dist/buffer/LogBuffer.js.map +1 -1
  11. package/dist/buffer/NetBuffer.d.ts +29 -0
  12. package/dist/buffer/NetBuffer.d.ts.map +1 -0
  13. package/dist/buffer/NetBuffer.js +85 -0
  14. package/dist/buffer/NetBuffer.js.map +1 -0
  15. package/dist/cdp/accessibility.d.ts +18 -0
  16. package/dist/cdp/accessibility.d.ts.map +1 -0
  17. package/dist/cdp/accessibility.js +300 -0
  18. package/dist/cdp/accessibility.js.map +1 -0
  19. package/dist/cdp/connection.d.ts +39 -0
  20. package/dist/cdp/connection.d.ts.map +1 -0
  21. package/dist/cdp/connection.js +131 -0
  22. package/dist/cdp/connection.js.map +1 -0
  23. package/dist/cdp/dom/fill.d.ts +22 -0
  24. package/dist/cdp/dom/fill.d.ts.map +1 -0
  25. package/dist/cdp/dom/fill.js +59 -0
  26. package/dist/cdp/dom/fill.js.map +1 -0
  27. package/dist/cdp/dom/info.d.ts +14 -0
  28. package/dist/cdp/dom/info.d.ts.map +1 -0
  29. package/dist/cdp/dom/info.js +52 -0
  30. package/dist/cdp/dom/info.js.map +1 -0
  31. package/dist/cdp/dom/insert.d.ts +19 -0
  32. package/dist/cdp/dom/insert.d.ts.map +1 -0
  33. package/dist/cdp/dom/insert.js +30 -0
  34. package/dist/cdp/dom/insert.js.map +1 -0
  35. package/dist/cdp/dom/modify.d.ts +50 -0
  36. package/dist/cdp/dom/modify.d.ts.map +1 -0
  37. package/dist/cdp/dom/modify.js +100 -0
  38. package/dist/cdp/dom/modify.js.map +1 -0
  39. package/dist/cdp/dom/remove.d.ts +17 -0
  40. package/dist/cdp/dom/remove.d.ts.map +1 -0
  41. package/dist/cdp/dom/remove.js +27 -0
  42. package/dist/cdp/dom/remove.js.map +1 -0
  43. package/dist/cdp/dom/selector.d.ts +19 -0
  44. package/dist/cdp/dom/selector.d.ts.map +1 -0
  45. package/dist/cdp/dom/selector.js +86 -0
  46. package/dist/cdp/dom/selector.js.map +1 -0
  47. package/dist/cdp/dom/setFile.d.ts +21 -0
  48. package/dist/cdp/dom/setFile.d.ts.map +1 -0
  49. package/dist/cdp/dom/setFile.js +25 -0
  50. package/dist/cdp/dom/setFile.js.map +1 -0
  51. package/dist/cdp/dom/submit.d.ts +15 -0
  52. package/dist/cdp/dom/submit.d.ts.map +1 -0
  53. package/dist/cdp/dom/submit.js +130 -0
  54. package/dist/cdp/dom/submit.js.map +1 -0
  55. package/dist/cdp/dom/tree.d.ts +16 -0
  56. package/dist/cdp/dom/tree.d.ts.map +1 -0
  57. package/dist/cdp/dom/tree.js +100 -0
  58. package/dist/cdp/dom/tree.js.map +1 -0
  59. package/dist/cdp/dom/types.d.ts +15 -0
  60. package/dist/cdp/dom/types.d.ts.map +1 -0
  61. package/dist/cdp/dom/types.js +2 -0
  62. package/dist/cdp/dom/types.js.map +1 -0
  63. package/dist/cdp/dom.d.ts +15 -0
  64. package/dist/cdp/dom.d.ts.map +1 -0
  65. package/dist/cdp/dom.js +9 -0
  66. package/dist/cdp/dom.js.map +1 -0
  67. package/dist/cdp/editor.d.ts +23 -0
  68. package/dist/cdp/editor.d.ts.map +1 -0
  69. package/dist/cdp/editor.js +266 -0
  70. package/dist/cdp/editor.js.map +1 -0
  71. package/dist/cdp/emulation.d.ts +16 -0
  72. package/dist/cdp/emulation.d.ts.map +1 -0
  73. package/dist/cdp/emulation.js +40 -0
  74. package/dist/cdp/emulation.js.map +1 -0
  75. package/dist/cdp/eval.d.ts +11 -0
  76. package/dist/cdp/eval.d.ts.map +1 -0
  77. package/dist/cdp/eval.js +79 -0
  78. package/dist/cdp/eval.js.map +1 -0
  79. package/dist/cdp/keyboard.d.ts +38 -0
  80. package/dist/cdp/keyboard.d.ts.map +1 -0
  81. package/dist/cdp/keyboard.js +148 -0
  82. package/dist/cdp/keyboard.js.map +1 -0
  83. package/dist/cdp/mouse.d.ts +49 -0
  84. package/dist/cdp/mouse.d.ts.map +1 -0
  85. package/dist/cdp/mouse.js +203 -0
  86. package/dist/cdp/mouse.js.map +1 -0
  87. package/dist/cdp/networkCapture.d.ts +11 -0
  88. package/dist/cdp/networkCapture.d.ts.map +1 -0
  89. package/dist/cdp/networkCapture.js +99 -0
  90. package/dist/cdp/networkCapture.js.map +1 -0
  91. package/dist/cdp/pageIndicator.d.ts +41 -0
  92. package/dist/cdp/pageIndicator.d.ts.map +1 -0
  93. package/dist/cdp/pageIndicator.js +395 -0
  94. package/dist/cdp/pageIndicator.js.map +1 -0
  95. package/dist/cdp/redaction.d.ts +3 -0
  96. package/dist/cdp/redaction.d.ts.map +1 -0
  97. package/dist/cdp/redaction.js +35 -0
  98. package/dist/cdp/redaction.js.map +1 -0
  99. package/dist/cdp/remoteObject.d.ts +6 -0
  100. package/dist/cdp/remoteObject.d.ts.map +1 -0
  101. package/dist/cdp/remoteObject.js +94 -0
  102. package/dist/cdp/remoteObject.js.map +1 -0
  103. package/dist/cdp/screenshot.d.ts +10 -0
  104. package/dist/cdp/screenshot.d.ts.map +1 -0
  105. package/dist/cdp/screenshot.js +83 -0
  106. package/dist/cdp/screenshot.js.map +1 -0
  107. package/dist/cdp/storageLocal.d.ts +8 -0
  108. package/dist/cdp/storageLocal.d.ts.map +1 -0
  109. package/dist/cdp/storageLocal.js +70 -0
  110. package/dist/cdp/storageLocal.js.map +1 -0
  111. package/dist/cdp/text-filter.d.ts +6 -0
  112. package/dist/cdp/text-filter.d.ts.map +1 -0
  113. package/dist/cdp/text-filter.js +36 -0
  114. package/dist/cdp/text-filter.js.map +1 -0
  115. package/dist/cdp/throttle.d.ts +6 -0
  116. package/dist/cdp/throttle.d.ts.map +1 -0
  117. package/dist/cdp/throttle.js +9 -0
  118. package/dist/cdp/throttle.js.map +1 -0
  119. package/dist/cdp/tracing.d.ts +15 -0
  120. package/dist/cdp/tracing.d.ts.map +1 -0
  121. package/dist/cdp/tracing.js +159 -0
  122. package/dist/cdp/tracing.js.map +1 -0
  123. package/dist/cdp/watcher.d.ts +17 -2
  124. package/dist/cdp/watcher.d.ts.map +1 -1
  125. package/dist/cdp/watcher.js +124 -175
  126. package/dist/cdp/watcher.js.map +1 -1
  127. package/dist/emulation/EmulationController.d.ts +12 -0
  128. package/dist/emulation/EmulationController.d.ts.map +1 -0
  129. package/dist/emulation/EmulationController.js +83 -0
  130. package/dist/emulation/EmulationController.js.map +1 -0
  131. package/dist/events.d.ts +86 -0
  132. package/dist/events.d.ts.map +1 -0
  133. package/dist/events.js +2 -0
  134. package/dist/events.js.map +1 -0
  135. package/dist/fileLogs/WatcherFileLogger.d.ts +5 -2
  136. package/dist/fileLogs/WatcherFileLogger.d.ts.map +1 -1
  137. package/dist/fileLogs/WatcherFileLogger.js +30 -12
  138. package/dist/fileLogs/WatcherFileLogger.js.map +1 -1
  139. package/dist/http/httpUtils.d.ts +25 -0
  140. package/dist/http/httpUtils.d.ts.map +1 -0
  141. package/dist/http/httpUtils.js +170 -0
  142. package/dist/http/httpUtils.js.map +1 -0
  143. package/dist/http/router.d.ts +5 -0
  144. package/dist/http/router.d.ts.map +1 -0
  145. package/dist/http/router.js +85 -0
  146. package/dist/http/router.js.map +1 -0
  147. package/dist/http/routes/getEmulation.d.ts +3 -0
  148. package/dist/http/routes/getEmulation.d.ts.map +1 -0
  149. package/dist/http/routes/getEmulation.js +8 -0
  150. package/dist/http/routes/getEmulation.js.map +1 -0
  151. package/dist/http/routes/getLogs.d.ts +3 -0
  152. package/dist/http/routes/getLogs.d.ts.map +1 -0
  153. package/dist/http/routes/getLogs.js +28 -0
  154. package/dist/http/routes/getLogs.js.map +1 -0
  155. package/dist/http/routes/getNet.d.ts +3 -0
  156. package/dist/http/routes/getNet.d.ts.map +1 -0
  157. package/dist/http/routes/getNet.js +17 -0
  158. package/dist/http/routes/getNet.js.map +1 -0
  159. package/dist/http/routes/getNetTail.d.ts +3 -0
  160. package/dist/http/routes/getNetTail.d.ts.map +1 -0
  161. package/dist/http/routes/getNetTail.js +18 -0
  162. package/dist/http/routes/getNetTail.js.map +1 -0
  163. package/dist/http/routes/getStatus.d.ts +3 -0
  164. package/dist/http/routes/getStatus.d.ts.map +1 -0
  165. package/dist/http/routes/getStatus.js +21 -0
  166. package/dist/http/routes/getStatus.js.map +1 -0
  167. package/dist/http/routes/getTail.d.ts +3 -0
  168. package/dist/http/routes/getTail.d.ts.map +1 -0
  169. package/dist/http/routes/getTail.js +28 -0
  170. package/dist/http/routes/getTail.js.map +1 -0
  171. package/dist/http/routes/getTargets.d.ts +3 -0
  172. package/dist/http/routes/getTargets.d.ts.map +1 -0
  173. package/dist/http/routes/getTargets.js +16 -0
  174. package/dist/http/routes/getTargets.js.map +1 -0
  175. package/dist/http/routes/getThrottle.d.ts +3 -0
  176. package/dist/http/routes/getThrottle.d.ts.map +1 -0
  177. package/dist/http/routes/getThrottle.js +8 -0
  178. package/dist/http/routes/getThrottle.js.map +1 -0
  179. package/dist/http/routes/postAttach.d.ts +3 -0
  180. package/dist/http/routes/postAttach.d.ts.map +1 -0
  181. package/dist/http/routes/postAttach.js +24 -0
  182. package/dist/http/routes/postAttach.js.map +1 -0
  183. package/dist/http/routes/postCodeEdit.d.ts +3 -0
  184. package/dist/http/routes/postCodeEdit.d.ts.map +1 -0
  185. package/dist/http/routes/postCodeEdit.js +32 -0
  186. package/dist/http/routes/postCodeEdit.js.map +1 -0
  187. package/dist/http/routes/postCodeGrep.d.ts +3 -0
  188. package/dist/http/routes/postCodeGrep.d.ts.map +1 -0
  189. package/dist/http/routes/postCodeGrep.js +26 -0
  190. package/dist/http/routes/postCodeGrep.js.map +1 -0
  191. package/dist/http/routes/postCodeList.d.ts +3 -0
  192. package/dist/http/routes/postCodeList.d.ts.map +1 -0
  193. package/dist/http/routes/postCodeList.js +20 -0
  194. package/dist/http/routes/postCodeList.js.map +1 -0
  195. package/dist/http/routes/postCodeRead.d.ts +3 -0
  196. package/dist/http/routes/postCodeRead.d.ts.map +1 -0
  197. package/dist/http/routes/postCodeRead.js +30 -0
  198. package/dist/http/routes/postCodeRead.js.map +1 -0
  199. package/dist/http/routes/postDetach.d.ts +3 -0
  200. package/dist/http/routes/postDetach.d.ts.map +1 -0
  201. package/dist/http/routes/postDetach.js +24 -0
  202. package/dist/http/routes/postDetach.js.map +1 -0
  203. package/dist/http/routes/postDomAdd.d.ts +7 -0
  204. package/dist/http/routes/postDomAdd.d.ts.map +1 -0
  205. package/dist/http/routes/postDomAdd.js +97 -0
  206. package/dist/http/routes/postDomAdd.js.map +1 -0
  207. package/dist/http/routes/postDomClick.d.ts +3 -0
  208. package/dist/http/routes/postDomClick.d.ts.map +1 -0
  209. package/dist/http/routes/postDomClick.js +85 -0
  210. package/dist/http/routes/postDomClick.js.map +1 -0
  211. package/dist/http/routes/postDomFill.d.ts +3 -0
  212. package/dist/http/routes/postDomFill.d.ts.map +1 -0
  213. package/dist/http/routes/postDomFill.js +58 -0
  214. package/dist/http/routes/postDomFill.js.map +1 -0
  215. package/dist/http/routes/postDomFocus.d.ts +3 -0
  216. package/dist/http/routes/postDomFocus.d.ts.map +1 -0
  217. package/dist/http/routes/postDomFocus.js +40 -0
  218. package/dist/http/routes/postDomFocus.js.map +1 -0
  219. package/dist/http/routes/postDomHover.d.ts +3 -0
  220. package/dist/http/routes/postDomHover.d.ts.map +1 -0
  221. package/dist/http/routes/postDomHover.js +40 -0
  222. package/dist/http/routes/postDomHover.js.map +1 -0
  223. package/dist/http/routes/postDomInfo.d.ts +3 -0
  224. package/dist/http/routes/postDomInfo.d.ts.map +1 -0
  225. package/dist/http/routes/postDomInfo.js +40 -0
  226. package/dist/http/routes/postDomInfo.js.map +1 -0
  227. package/dist/http/routes/postDomKeydown.d.ts +3 -0
  228. package/dist/http/routes/postDomKeydown.d.ts.map +1 -0
  229. package/dist/http/routes/postDomKeydown.js +36 -0
  230. package/dist/http/routes/postDomKeydown.js.map +1 -0
  231. package/dist/http/routes/postDomModify.d.ts +3 -0
  232. package/dist/http/routes/postDomModify.d.ts.map +1 -0
  233. package/dist/http/routes/postDomModify.js +45 -0
  234. package/dist/http/routes/postDomModify.js.map +1 -0
  235. package/dist/http/routes/postDomRemove.d.ts +3 -0
  236. package/dist/http/routes/postDomRemove.d.ts.map +1 -0
  237. package/dist/http/routes/postDomRemove.js +39 -0
  238. package/dist/http/routes/postDomRemove.js.map +1 -0
  239. package/dist/http/routes/postDomScroll.d.ts +3 -0
  240. package/dist/http/routes/postDomScroll.d.ts.map +1 -0
  241. package/dist/http/routes/postDomScroll.js +75 -0
  242. package/dist/http/routes/postDomScroll.js.map +1 -0
  243. package/dist/http/routes/postDomScrollTo.d.ts +3 -0
  244. package/dist/http/routes/postDomScrollTo.d.ts.map +1 -0
  245. package/dist/http/routes/postDomScrollTo.js +69 -0
  246. package/dist/http/routes/postDomScrollTo.js.map +1 -0
  247. package/dist/http/routes/postDomSetFile.d.ts +3 -0
  248. package/dist/http/routes/postDomSetFile.d.ts.map +1 -0
  249. package/dist/http/routes/postDomSetFile.js +58 -0
  250. package/dist/http/routes/postDomSetFile.js.map +1 -0
  251. package/dist/http/routes/postDomSubmit.d.ts +3 -0
  252. package/dist/http/routes/postDomSubmit.d.ts.map +1 -0
  253. package/dist/http/routes/postDomSubmit.js +49 -0
  254. package/dist/http/routes/postDomSubmit.js.map +1 -0
  255. package/dist/http/routes/postDomTree.d.ts +3 -0
  256. package/dist/http/routes/postDomTree.d.ts.map +1 -0
  257. package/dist/http/routes/postDomTree.js +41 -0
  258. package/dist/http/routes/postDomTree.js.map +1 -0
  259. package/dist/http/routes/postEmulation.d.ts +3 -0
  260. package/dist/http/routes/postEmulation.d.ts.map +1 -0
  261. package/dist/http/routes/postEmulation.js +70 -0
  262. package/dist/http/routes/postEmulation.js.map +1 -0
  263. package/dist/http/routes/postEval.d.ts +3 -0
  264. package/dist/http/routes/postEval.d.ts.map +1 -0
  265. package/dist/http/routes/postEval.js +27 -0
  266. package/dist/http/routes/postEval.js.map +1 -0
  267. package/dist/http/routes/postReload.d.ts +3 -0
  268. package/dist/http/routes/postReload.d.ts.map +1 -0
  269. package/dist/http/routes/postReload.js +20 -0
  270. package/dist/http/routes/postReload.js.map +1 -0
  271. package/dist/http/routes/postScreenshot.d.ts +3 -0
  272. package/dist/http/routes/postScreenshot.d.ts.map +1 -0
  273. package/dist/http/routes/postScreenshot.js +17 -0
  274. package/dist/http/routes/postScreenshot.js.map +1 -0
  275. package/dist/http/routes/postShutdown.d.ts +3 -0
  276. package/dist/http/routes/postShutdown.d.ts.map +1 -0
  277. package/dist/http/routes/postShutdown.js +13 -0
  278. package/dist/http/routes/postShutdown.js.map +1 -0
  279. package/dist/http/routes/postSnapshot.d.ts +3 -0
  280. package/dist/http/routes/postSnapshot.d.ts.map +1 -0
  281. package/dist/http/routes/postSnapshot.js +28 -0
  282. package/dist/http/routes/postSnapshot.js.map +1 -0
  283. package/dist/http/routes/postStorageLocal.d.ts +3 -0
  284. package/dist/http/routes/postStorageLocal.d.ts.map +1 -0
  285. package/dist/http/routes/postStorageLocal.js +31 -0
  286. package/dist/http/routes/postStorageLocal.js.map +1 -0
  287. package/dist/http/routes/postThrottle.d.ts +3 -0
  288. package/dist/http/routes/postThrottle.d.ts.map +1 -0
  289. package/dist/http/routes/postThrottle.js +38 -0
  290. package/dist/http/routes/postThrottle.js.map +1 -0
  291. package/dist/http/routes/postTraceStart.d.ts +3 -0
  292. package/dist/http/routes/postTraceStart.d.ts.map +1 -0
  293. package/dist/http/routes/postTraceStart.js +17 -0
  294. package/dist/http/routes/postTraceStart.js.map +1 -0
  295. package/dist/http/routes/postTraceStop.d.ts +3 -0
  296. package/dist/http/routes/postTraceStop.d.ts.map +1 -0
  297. package/dist/http/routes/postTraceStop.js +17 -0
  298. package/dist/http/routes/postTraceStop.js.map +1 -0
  299. package/dist/http/routes/types.d.ts +9 -0
  300. package/dist/http/routes/types.d.ts.map +1 -0
  301. package/dist/http/routes/types.js +10 -0
  302. package/dist/http/routes/types.js.map +1 -0
  303. package/dist/http/server.d.ts +42 -1
  304. package/dist/http/server.d.ts.map +1 -1
  305. package/dist/http/server.js +3 -82
  306. package/dist/http/server.js.map +1 -1
  307. package/dist/index.d.ts +117 -14
  308. package/dist/index.d.ts.map +1 -1
  309. package/dist/index.js +349 -44
  310. package/dist/index.js.map +1 -1
  311. package/dist/native-messaging/messaging.d.ts +18 -0
  312. package/dist/native-messaging/messaging.d.ts.map +1 -0
  313. package/dist/native-messaging/messaging.js +94 -0
  314. package/dist/native-messaging/messaging.js.map +1 -0
  315. package/dist/native-messaging/session-manager.d.ts +108 -0
  316. package/dist/native-messaging/session-manager.d.ts.map +1 -0
  317. package/dist/native-messaging/session-manager.js +267 -0
  318. package/dist/native-messaging/session-manager.js.map +1 -0
  319. package/dist/native-messaging/types.d.ts +112 -0
  320. package/dist/native-messaging/types.d.ts.map +1 -0
  321. package/dist/native-messaging/types.js +6 -0
  322. package/dist/native-messaging/types.js.map +1 -0
  323. package/dist/registry/registry.d.ts +9 -2
  324. package/dist/registry/registry.d.ts.map +1 -1
  325. package/dist/registry/registry.js +53 -9
  326. package/dist/registry/registry.js.map +1 -1
  327. package/dist/scripts/install-host.d.ts +10 -0
  328. package/dist/scripts/install-host.d.ts.map +1 -0
  329. package/dist/scripts/install-host.js +189 -0
  330. package/dist/scripts/install-host.js.map +1 -0
  331. package/dist/sources/cdp-source.d.ts +24 -0
  332. package/dist/sources/cdp-source.d.ts.map +1 -0
  333. package/dist/sources/cdp-source.js +49 -0
  334. package/dist/sources/cdp-source.js.map +1 -0
  335. package/dist/sources/extension-frame-state.d.ts +64 -0
  336. package/dist/sources/extension-frame-state.d.ts.map +1 -0
  337. package/dist/sources/extension-frame-state.js +117 -0
  338. package/dist/sources/extension-frame-state.js.map +1 -0
  339. package/dist/sources/extension-log-events.d.ts +15 -0
  340. package/dist/sources/extension-log-events.d.ts.map +1 -0
  341. package/dist/sources/extension-log-events.js +101 -0
  342. package/dist/sources/extension-log-events.js.map +1 -0
  343. package/dist/sources/extension-source.d.ts +15 -0
  344. package/dist/sources/extension-source.d.ts.map +1 -0
  345. package/dist/sources/extension-source.js +487 -0
  346. package/dist/sources/extension-source.js.map +1 -0
  347. package/dist/sources/types.d.ts +109 -0
  348. package/dist/sources/types.d.ts.map +1 -0
  349. package/dist/sources/types.js +7 -0
  350. package/dist/sources/types.js.map +1 -0
  351. package/dist/throttle/ThrottleController.d.ts +12 -0
  352. package/dist/throttle/ThrottleController.d.ts.map +1 -0
  353. package/dist/throttle/ThrottleController.js +67 -0
  354. package/dist/throttle/ThrottleController.js.map +1 -0
  355. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -1,108 +1,413 @@
1
+ import os from 'node:os';
1
2
  import path from 'node:path';
2
- import { startCdpWatcher } from './cdp/watcher.js';
3
+ import Emittery from 'emittery';
3
4
  import { LogBuffer } from './buffer/LogBuffer.js';
5
+ import { NetBuffer } from './buffer/NetBuffer.js';
4
6
  import { startHttpServer } from './http/server.js';
5
- import { announceWatcher, removeWatcher, startRegistryHeartbeat } from './registry/registry.js';
7
+ import { announceWatcher, removeWatcher, startRegistryHeartbeat, resolveUniqueWatcherId } from './registry/registry.js';
6
8
  import { WatcherFileLogger } from './fileLogs/WatcherFileLogger.js';
7
9
  import { buildIgnoreMatcher } from './cdp/ignoreList.js';
10
+ import { createNetworkCapture } from './cdp/networkCapture.js';
11
+ import { createTraceRecorder } from './cdp/tracing.js';
12
+ import { createScreenshotter } from './cdp/screenshot.js';
13
+ import { createRuntimeEditor } from './cdp/editor.js';
14
+ import { createCdpSessionHandle } from './cdp/connection.js';
15
+ import { createPageIndicatorController, validatePageIndicatorOptions, } from './cdp/pageIndicator.js';
16
+ import { createEmulationController } from './emulation/EmulationController.js';
17
+ import { createThrottleController } from './throttle/ThrottleController.js';
18
+ import { createCdpSource } from './sources/cdp-source.js';
19
+ import { createExtensionSource } from './sources/extension-source.js';
8
20
  /**
9
- * Start a watcher that connects to Chrome CDP, buffers console logs, and exposes the HTTP API.
10
- * @param options - Configuration for binding, CDP matching, and buffering.
21
+ * Start a watcher that connects to Chrome (via CDP or extension), buffers console logs, and exposes the HTTP API.
22
+ * @param options - Configuration for binding, source mode, and buffering.
11
23
  * @returns A handle that can be closed to stop the watcher and clean up registry state.
12
24
  */
13
25
  export const startWatcher = async (options) => {
14
26
  if (!options.id) {
15
27
  throw new Error('Watcher id is required');
16
28
  }
29
+ const watcherId = await resolveUniqueWatcherId(options.id);
30
+ const sourceMode = options.source ?? 'cdp';
17
31
  const host = options.host ?? '127.0.0.1';
18
32
  const port = options.port ?? 0;
19
33
  const chrome = options.chrome ?? { host: '127.0.0.1', port: 9222 };
20
34
  const bufferSize = options.bufferSize ?? 50_000;
35
+ const netBufferSize = options.bufferSize ?? 50_000;
21
36
  const startedAt = Date.now();
22
- const includeTimestamps = options.includeTimestamps ?? false;
23
37
  const ignoreMatcher = buildIgnoreMatcher(options.ignoreList);
24
38
  const stripUrlPrefixes = options.location?.stripUrlPrefixes;
39
+ // Resolve artifacts configuration
40
+ const artifactsBaseDir = resolveArtifactsBaseDir(options.artifacts?.base, watcherId);
41
+ const logsEnabled = options.artifacts?.logs?.enabled === true;
42
+ const logsDir = path.join(artifactsBaseDir, 'logs');
43
+ const includeTimestamps = options.artifacts?.logs?.includeTimestamps ?? false;
44
+ const maxFiles = resolveMaxFiles(options.artifacts?.logs?.maxFiles);
45
+ // Network capture is opt-in (disabled by default) and only in CDP mode
46
+ const netEnabled = sourceMode === 'cdp' && options.net?.enabled === true;
47
+ // Page console logging (default: minimal)
48
+ const pageConsoleLogging = options.pageConsoleLogging ?? 'minimal';
49
+ const events = new Emittery();
25
50
  const buffer = new LogBuffer(bufferSize);
51
+ const netBuffer = netEnabled ? new NetBuffer(netBufferSize) : null;
52
+ let closing = false;
53
+ let readyForShutdown = false;
54
+ let shutdownRequested = false;
55
+ let closeOnce = null;
26
56
  let cdpStatus = { attached: false, target: null };
27
- const fileLogs = options.fileLogs;
28
- const logsDir = fileLogs ? resolveLogsDir(fileLogs.logsDir) : null;
29
- const maxFiles = fileLogs ? resolveMaxFiles(fileLogs.maxFiles) : null;
30
- const fileLogger = logsDir
57
+ const fileLogger = logsEnabled
31
58
  ? new WatcherFileLogger({
32
- watcherId: options.id,
59
+ watcherId,
33
60
  startedAt,
34
61
  logsDir,
35
- chrome,
62
+ chrome: sourceMode === 'cdp' ? chrome : undefined,
36
63
  match: options.match,
37
- maxFiles: maxFiles ?? 5,
64
+ maxFiles,
38
65
  includeTimestamps,
66
+ buildFilename: options.artifacts?.logs?.buildFilename,
39
67
  })
40
68
  : null;
41
69
  const record = {
42
- id: options.id,
70
+ id: watcherId,
43
71
  host,
44
72
  port,
45
73
  pid: process.pid,
46
74
  cwd: process.cwd(),
47
75
  startedAt,
48
76
  updatedAt: Date.now(),
49
- match: options.match,
50
- chrome,
77
+ match: sourceMode === 'cdp' ? options.match : undefined,
78
+ chrome: sourceMode === 'cdp' ? chrome : undefined,
51
79
  includeTimestamps,
80
+ source: sourceMode,
81
+ };
82
+ // Create session handle for CDP mode (used by network capture, tracing, etc.)
83
+ const sessionHandle = createCdpSessionHandle();
84
+ // Emulation controller (shared across CDP and extension modes)
85
+ const emulationController = createEmulationController();
86
+ // Throttle controller (CPU, network, cache — shared across CDP and extension modes)
87
+ const throttleController = createThrottleController();
88
+ const logToPageConsole = (message) => {
89
+ if (pageConsoleLogging === 'none') {
90
+ return;
91
+ }
92
+ if (!sourceHandle?.session.isAttached()) {
93
+ return;
94
+ }
95
+ const fullMessage = `[ARGUS] ${watcherId} :: ${message}`;
96
+ queueMicrotask(() => {
97
+ sourceHandle?.session
98
+ .sendAndWait('Runtime.evaluate', {
99
+ expression: `console.log(${JSON.stringify(fullMessage)})`,
100
+ silent: true,
101
+ })
102
+ .catch(() => { });
103
+ });
104
+ };
105
+ validatePageIndicatorOptions(options.pageIndicator);
106
+ const indicatorEnabled = options.pageIndicator?.enabled === true;
107
+ let indicatorController = null;
108
+ let indicatorAttachedAt = null;
109
+ if (indicatorEnabled) {
110
+ indicatorController = createPageIndicatorController(options.pageIndicator);
111
+ }
112
+ const updateCdpStatus = (status) => {
113
+ const prevAttached = cdpStatus.attached;
114
+ cdpStatus = status;
115
+ if (status.attached && !prevAttached) {
116
+ const url = status.target?.url ?? 'unknown';
117
+ logToPageConsole(`attached (url=${url})`);
118
+ void events.emit('cdpAttached', {
119
+ ts: Date.now(),
120
+ watcherId,
121
+ target: status.target,
122
+ });
123
+ return;
124
+ }
125
+ if (!status.attached && prevAttached) {
126
+ void events.emit('cdpDetached', {
127
+ ts: Date.now(),
128
+ watcherId,
129
+ target: status.target,
130
+ reason: status.reason ?? 'unknown',
131
+ });
132
+ }
133
+ };
134
+ const buildIndicatorInfo = (target) => ({
135
+ watcherId,
136
+ watcherHost: host,
137
+ watcherPort: record.port,
138
+ watcherPid: process.pid,
139
+ targetTitle: target?.title ?? null,
140
+ targetUrl: target?.url ?? null,
141
+ attachedAt: indicatorAttachedAt ?? Date.now(),
142
+ });
143
+ const onIndicatorNavigation = (session, info) => {
144
+ if (!indicatorController) {
145
+ return;
146
+ }
147
+ indicatorController.onNavigation(session, buildIndicatorInfo({ title: null, url: info.url }));
148
+ };
149
+ const onIndicatorLoad = () => {
150
+ indicatorController?.reinstall();
52
151
  };
152
+ const getIndicatorSession = () => sourceHandle.pageSession ?? sourceHandle.session;
153
+ const onIndicatorAttach = (session, target) => {
154
+ if (!indicatorController) {
155
+ return;
156
+ }
157
+ indicatorAttachedAt = Date.now();
158
+ indicatorController.onAttach(session, {
159
+ id: target.id,
160
+ title: target.title,
161
+ url: target.url,
162
+ type: target.type ?? 'page',
163
+ parentId: target.parentId ?? null,
164
+ webSocketDebuggerUrl: '',
165
+ }, buildIndicatorInfo({ title: target.title, url: target.url }));
166
+ };
167
+ const maybeInjectOnAttach = async (session, target) => {
168
+ if (!options.inject?.script) {
169
+ return;
170
+ }
171
+ if (!session.isAttached()) {
172
+ return;
173
+ }
174
+ const trimmedScript = options.inject.script.trim();
175
+ if (trimmedScript === '') {
176
+ console.warn(`[Watcher] Inject script is empty for watcher ${record.id}. Skipping.`);
177
+ return;
178
+ }
179
+ const attachedAt = Date.now();
180
+ const exposeArgus = options.inject.exposeArgus ?? true;
181
+ const argusPayload = exposeArgus
182
+ ? {
183
+ watcherId: record.id,
184
+ watcherHost: record.host,
185
+ watcherPort: record.port,
186
+ watcherPid: record.pid,
187
+ attachedAt,
188
+ target: {
189
+ title: target.title ?? null,
190
+ url: target.url ?? null,
191
+ type: target.type ?? 'page',
192
+ parentId: target.parentId ?? null,
193
+ },
194
+ }
195
+ : null;
196
+ const expression = buildInjectExpression(trimmedScript, argusPayload);
197
+ try {
198
+ await session.sendAndWait('Page.addScriptToEvaluateOnNewDocument', { source: expression });
199
+ }
200
+ catch (error) {
201
+ console.warn(`[Watcher] Failed to register inject script for watcher ${record.id}: ${formatError(error)}`);
202
+ }
203
+ try {
204
+ await session.sendAndWait('Runtime.evaluate', { expression, silent: true });
205
+ }
206
+ catch (error) {
207
+ console.warn(`[Watcher] Failed to run inject script for watcher ${record.id}: ${formatError(error)}`);
208
+ }
209
+ };
210
+ // Create the appropriate source based on mode
211
+ let sourceHandle;
212
+ let networkCapture = null;
213
+ let traceRecorder;
214
+ let screenshotter;
215
+ let runtimeEditor;
216
+ if (sourceMode === 'extension') {
217
+ // Extension mode
218
+ sourceHandle = createExtensionSource({
219
+ events: {
220
+ onLog: (event) => {
221
+ buffer.add(event);
222
+ fileLogger?.writeEvent(event);
223
+ },
224
+ onStatus: updateCdpStatus,
225
+ onPageNavigation: (info) => {
226
+ fileLogger?.rotate(info);
227
+ onIndicatorNavigation(getIndicatorSession(), info);
228
+ runtimeEditor?.reset();
229
+ },
230
+ onPageLoad: onIndicatorLoad,
231
+ onPageIntl: (info) => {
232
+ fileLogger?.setPageIntl(info);
233
+ },
234
+ onAttach: async (session, target) => {
235
+ runtimeEditor?.rebind();
236
+ await emulationController.onAttach(session);
237
+ await throttleController.onAttach(session);
238
+ onIndicatorAttach(session, target);
239
+ await maybeInjectOnAttach(session, target);
240
+ },
241
+ onTargetChanged: (session, target) => {
242
+ onIndicatorAttach(session, target);
243
+ },
244
+ onDetach: () => {
245
+ runtimeEditor?.rebind();
246
+ indicatorController?.onDetach();
247
+ },
248
+ },
249
+ watcherId,
250
+ watcherHost: host,
251
+ watcherPort: record.port,
252
+ ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
253
+ stripUrlPrefixes,
254
+ });
255
+ // Create trace/screenshot with proxy session
256
+ traceRecorder = createTraceRecorder({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
257
+ screenshotter = createScreenshotter({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
258
+ runtimeEditor = createRuntimeEditor(sourceHandle.session);
259
+ }
260
+ else {
261
+ // CDP mode
262
+ networkCapture = netBuffer ? createNetworkCapture({ session: sessionHandle.session, buffer: netBuffer }) : null;
263
+ traceRecorder = createTraceRecorder({ session: sessionHandle.session, artifactsDir: artifactsBaseDir });
264
+ screenshotter = createScreenshotter({ session: sessionHandle.session, artifactsDir: artifactsBaseDir });
265
+ runtimeEditor = createRuntimeEditor(sessionHandle.session);
266
+ sourceHandle = createCdpSource({
267
+ chrome,
268
+ match: options.match,
269
+ sessionHandle,
270
+ events: {
271
+ onLog: (event) => {
272
+ buffer.add(event);
273
+ fileLogger?.writeEvent(event);
274
+ },
275
+ onStatus: updateCdpStatus,
276
+ onPageNavigation: (info) => {
277
+ fileLogger?.rotate(info);
278
+ onIndicatorNavigation(sessionHandle.session, info);
279
+ runtimeEditor?.reset();
280
+ },
281
+ onPageLoad: onIndicatorLoad,
282
+ onPageIntl: (info) => {
283
+ fileLogger?.setPageIntl(info);
284
+ },
285
+ onAttach: async (session, target) => {
286
+ runtimeEditor?.rebind();
287
+ await emulationController.onAttach(session);
288
+ await throttleController.onAttach(session);
289
+ await networkCapture?.onAttached();
290
+ onIndicatorAttach(session, target);
291
+ await maybeInjectOnAttach(session, target);
292
+ },
293
+ onDetach: (reason) => {
294
+ runtimeEditor?.rebind();
295
+ networkCapture?.onDetached();
296
+ traceRecorder.onDetached(reason);
297
+ indicatorController?.onDetach();
298
+ },
299
+ },
300
+ watcherId,
301
+ ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
302
+ stripUrlPrefixes,
303
+ });
304
+ }
53
305
  const server = await startHttpServer({
54
306
  host,
55
307
  port,
56
308
  buffer,
309
+ netBuffer,
57
310
  getWatcher: () => record,
58
311
  getCdpStatus: () => cdpStatus,
312
+ cdpSession: sourceHandle.session,
313
+ traceRecorder,
314
+ screenshotter,
315
+ runtimeEditor,
316
+ emulationController,
317
+ throttleController,
318
+ // Extension mode endpoints
319
+ sourceHandle: sourceMode === 'extension' ? sourceHandle : undefined,
320
+ onRequest: (event) => {
321
+ if (pageConsoleLogging === 'full') {
322
+ logToPageConsole(`http ${event.endpoint}`);
323
+ }
324
+ void events.emit('httpRequested', {
325
+ ...event,
326
+ watcherId,
327
+ });
328
+ },
329
+ onShutdown: () => {
330
+ if (!readyForShutdown || !closeOnce) {
331
+ shutdownRequested = true;
332
+ return;
333
+ }
334
+ void closeOnce();
335
+ },
59
336
  });
60
337
  record.port = server.port;
338
+ sourceHandle.syncWatcherInfo?.({
339
+ watcherId,
340
+ watcherHost: host,
341
+ watcherPort: record.port,
342
+ watcherPid: process.pid,
343
+ });
61
344
  await announceWatcher(record);
62
345
  const heartbeat = startRegistryHeartbeat(() => record, options.heartbeatMs ?? 15_000);
63
- const cdp = startCdpWatcher({
64
- chrome,
65
- match: options.match,
66
- ignoreMatcher,
67
- stripUrlPrefixes,
68
- onLog: (event) => {
69
- buffer.add(event);
70
- fileLogger?.writeEvent(event);
71
- },
72
- onPageNavigation: (info) => {
73
- fileLogger?.rotate(info);
74
- },
75
- onPageIntl: (info) => {
76
- fileLogger?.setPageIntl(info);
77
- },
78
- onStatus: (status) => {
79
- cdpStatus = status;
80
- },
81
- });
346
+ closeOnce = async () => {
347
+ if (closing) {
348
+ return;
349
+ }
350
+ closing = true;
351
+ heartbeat.stop();
352
+ indicatorController?.stop();
353
+ if (cdpStatus.attached) {
354
+ logToPageConsole('detached (reason=watcher_stopped)');
355
+ }
356
+ await sourceHandle.stop();
357
+ await fileLogger?.close();
358
+ traceRecorder.onDetached('watcher_stopped');
359
+ await server.close();
360
+ await removeWatcher(record.id);
361
+ events.clearListeners();
362
+ };
363
+ readyForShutdown = true;
364
+ if (shutdownRequested) {
365
+ void closeOnce();
366
+ }
82
367
  return {
83
368
  watcher: record,
369
+ events,
84
370
  close: async () => {
85
- heartbeat.stop();
86
- await cdp.stop();
87
- await fileLogger?.close();
88
- await server.close();
89
- await removeWatcher(record.id);
371
+ await closeOnce?.();
90
372
  },
91
373
  };
92
374
  };
93
- const resolveLogsDir = (logsDir) => {
94
- if (typeof logsDir !== 'string' || logsDir.trim() === '') {
95
- throw new Error('fileLogs.logsDir is required');
375
+ const resolveArtifactsBaseDir = (base, watcherId) => {
376
+ if (base !== undefined && base !== null) {
377
+ if (typeof base !== 'string' || base.trim() === '') {
378
+ throw new Error('artifacts.base must be a non-empty string when provided');
379
+ }
380
+ return path.resolve(base);
96
381
  }
97
- return path.resolve(logsDir);
382
+ return path.join(os.tmpdir(), 'argus', watcherId);
98
383
  };
99
384
  const resolveMaxFiles = (maxFiles) => {
100
385
  if (maxFiles === undefined) {
101
386
  return 5;
102
387
  }
103
388
  if (!Number.isInteger(maxFiles) || maxFiles < 1) {
104
- throw new Error('fileLogs.maxFiles must be an integer >= 1');
389
+ throw new Error('artifacts.logs.maxFiles must be an integer >= 1');
105
390
  }
106
391
  return maxFiles;
107
392
  };
393
+ const buildInjectExpression = (script, argusPayload) => {
394
+ const lines = ['(() => {'];
395
+ if (argusPayload) {
396
+ lines.push(`window.__ARGUS__ = ${JSON.stringify(argusPayload)};`);
397
+ }
398
+ lines.push(`const __argusScript = ${JSON.stringify(script)};`);
399
+ lines.push('const __argusFn = new Function(__argusScript);');
400
+ lines.push('__argusFn();');
401
+ lines.push('})();');
402
+ return lines.join('\n');
403
+ };
404
+ const formatError = (error) => {
405
+ if (!error) {
406
+ return 'Unknown error';
407
+ }
408
+ if (error instanceof Error) {
409
+ return error.message;
410
+ }
411
+ return String(error);
412
+ };
108
413
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAiDxD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAA4B,EAA0B,EAAE;IAC1F,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAAA;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAA;IAC9B,MA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AQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,CAAA;IACT,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IACnE,CAAC;IACD,OAAO,QAAQ,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC7B,MAAc,EACd,YAOQ,EACC,EAAE;IACX,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,CAAA;IAC1B,IAAI,YAAY,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IAClE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC9D,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAA;IAC5D,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC1B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,KAAc,EAAU,EAAE;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,eAAe,CAAA;IACvB,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Native Messaging protocol handler for stdin/stdout communication.
3
+ * Chrome Native Messaging uses length-prefixed 32-bit messages.
4
+ */
5
+ import type { ExtensionToHost, HostToExtension } from './types.js';
6
+ export type NativeMessagingHandler = {
7
+ onMessage: (callback: (message: ExtensionToHost) => void) => void;
8
+ onDisconnect: (callback: () => void) => void;
9
+ send: (message: HostToExtension) => void;
10
+ start: () => void;
11
+ stop: () => void;
12
+ };
13
+ /**
14
+ * Create a Native Messaging handler for stdin/stdout communication.
15
+ * Messages are length-prefixed with a 32-bit little-endian integer.
16
+ */
17
+ export declare const createNativeMessaging: () => NativeMessagingHandler;
18
+ //# sourceMappingURL=messaging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/native-messaging/messaging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,KAAK,IAAI,CAAA;IACjE,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IAC5C,IAAI,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAA;IACxC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,sBAoGxC,CAAA"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Native Messaging protocol handler for stdin/stdout communication.
3
+ * Chrome Native Messaging uses length-prefixed 32-bit messages.
4
+ */
5
+ /**
6
+ * Create a Native Messaging handler for stdin/stdout communication.
7
+ * Messages are length-prefixed with a 32-bit little-endian integer.
8
+ */
9
+ export const createNativeMessaging = () => {
10
+ let messageCallback = null;
11
+ let disconnectCallback = null;
12
+ let buffer = Buffer.alloc(0);
13
+ let running = false;
14
+ const processBuffer = () => {
15
+ // Need at least 4 bytes for the length prefix
16
+ while (buffer.length >= 4) {
17
+ const messageLength = buffer.readUInt32LE(0);
18
+ // Wait for the full message
19
+ if (buffer.length < 4 + messageLength) {
20
+ break;
21
+ }
22
+ // Extract the message
23
+ const messageBytes = buffer.subarray(4, 4 + messageLength);
24
+ buffer = buffer.subarray(4 + messageLength);
25
+ try {
26
+ const message = JSON.parse(messageBytes.toString('utf8'));
27
+ if (messageCallback) {
28
+ messageCallback(message);
29
+ }
30
+ }
31
+ catch (err) {
32
+ console.error('[NativeMessaging] Failed to parse message:', err);
33
+ }
34
+ }
35
+ };
36
+ const onData = (chunk) => {
37
+ buffer = Buffer.concat([buffer, chunk]);
38
+ processBuffer();
39
+ };
40
+ const onEnd = () => {
41
+ running = false;
42
+ if (disconnectCallback) {
43
+ disconnectCallback();
44
+ }
45
+ };
46
+ return {
47
+ onMessage: (callback) => {
48
+ messageCallback = callback;
49
+ },
50
+ onDisconnect: (callback) => {
51
+ disconnectCallback = callback;
52
+ },
53
+ send: (message) => {
54
+ if (!running) {
55
+ return;
56
+ }
57
+ const messageStr = JSON.stringify(message);
58
+ const messageBytes = Buffer.from(messageStr, 'utf8');
59
+ const lengthPrefix = Buffer.alloc(4);
60
+ lengthPrefix.writeUInt32LE(messageBytes.length, 0);
61
+ process.stdout.write(lengthPrefix);
62
+ process.stdout.write(messageBytes);
63
+ },
64
+ start: () => {
65
+ if (running) {
66
+ return;
67
+ }
68
+ running = true;
69
+ console.error('[NativeMessaging] Starting...');
70
+ console.error('[NativeMessaging] stdin.isTTY:', process.stdin.isTTY);
71
+ console.error('[NativeMessaging] stdin.readable:', process.stdin.readable);
72
+ // Set stdin to raw mode for binary data
73
+ if (process.stdin.setRawMode) {
74
+ process.stdin.setRawMode(true);
75
+ }
76
+ process.stdin.resume();
77
+ process.stdin.on('data', onData);
78
+ process.stdin.on('end', onEnd);
79
+ process.stdin.on('close', onEnd);
80
+ console.error('[NativeMessaging] Started, listening on stdin');
81
+ },
82
+ stop: () => {
83
+ if (!running) {
84
+ return;
85
+ }
86
+ running = false;
87
+ process.stdin.removeListener('data', onData);
88
+ process.stdin.removeListener('end', onEnd);
89
+ process.stdin.removeListener('close', onEnd);
90
+ process.stdin.pause();
91
+ },
92
+ };
93
+ };
94
+ //# sourceMappingURL=messaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/native-messaging/messaging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAA2B,EAAE;IACjE,IAAI,eAAe,GAAgD,IAAI,CAAA;IACvE,IAAI,kBAAkB,GAAwB,IAAI,CAAA;IAClD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,IAAI,OAAO,GAAG,KAAK,CAAA;IAEnB,MAAM,aAAa,GAAG,GAAS,EAAE;QAChC,8CAA8C;QAC9C,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;YAE5C,4BAA4B;YAC5B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,aAAa,EAAE,CAAC;gBACvC,MAAK;YACN,CAAC;YAED,sBAAsB;YACtB,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAA;YAC1D,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,aAAa,CAAC,CAAA;YAE3C,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAoB,CAAA;gBAC5E,IAAI,eAAe,EAAE,CAAC;oBACrB,eAAe,CAAC,OAAO,CAAC,CAAA;gBACzB,CAAC;YACF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CA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