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.
- package/LICENSE +21 -0
- package/README.md +167 -52
- package/dist/__testfixtures__/cdpMessages.d.ts +43 -0
- package/dist/__testfixtures__/cdpMessages.d.ts.map +1 -0
- package/dist/__testfixtures__/cdpMessages.js +118 -0
- package/dist/__testfixtures__/cdpMessages.js.map +1 -0
- package/dist/__testfixtures__/connectionTargets.d.ts +21 -0
- package/dist/__testfixtures__/connectionTargets.d.ts.map +1 -0
- package/dist/__testfixtures__/connectionTargets.js +59 -0
- package/dist/__testfixtures__/connectionTargets.js.map +1 -0
- package/dist/__tests__/integration/session-files.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/session-files.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/session-files.integration.test.js +66 -0
- package/dist/__tests__/integration/session-files.integration.test.js.map +1 -0
- package/dist/__testutils__/FakeClock.d.ts +67 -0
- package/dist/__testutils__/FakeClock.d.ts.map +1 -0
- package/dist/__testutils__/FakeClock.js +132 -0
- package/dist/__testutils__/FakeClock.js.map +1 -0
- package/dist/__testutils__/FakeWebSocket.d.ts +106 -0
- package/dist/__testutils__/FakeWebSocket.d.ts.map +1 -0
- package/dist/__testutils__/FakeWebSocket.js +213 -0
- package/dist/__testutils__/FakeWebSocket.js.map +1 -0
- package/dist/__testutils__/assertions.d.ts +33 -0
- package/dist/__testutils__/assertions.d.ts.map +1 -0
- package/dist/__testutils__/assertions.js +57 -0
- package/dist/__testutils__/assertions.js.map +1 -0
- package/dist/__testutils__/index.d.ts +15 -0
- package/dist/__testutils__/index.d.ts.map +1 -0
- package/dist/__testutils__/index.js +15 -0
- package/dist/__testutils__/index.js.map +1 -0
- package/dist/__testutils__/testClock.d.ts +28 -0
- package/dist/__testutils__/testClock.d.ts.map +1 -0
- package/dist/__testutils__/testClock.js +81 -0
- package/dist/__testutils__/testClock.js.map +1 -0
- package/dist/__testutils__/testFixtures.d.ts +15 -0
- package/dist/__testutils__/testFixtures.d.ts.map +1 -0
- package/dist/__testutils__/testFixtures.js +23 -0
- package/dist/__testutils__/testFixtures.js.map +1 -0
- package/dist/__testutils__/testProcess.d.ts +46 -0
- package/dist/__testutils__/testProcess.d.ts.map +1 -0
- package/dist/__testutils__/testProcess.js +77 -0
- package/dist/__testutils__/testProcess.js.map +1 -0
- package/dist/cli/collectors/dom.d.ts +8 -0
- package/dist/cli/collectors/dom.d.ts.map +1 -0
- package/dist/cli/collectors/dom.js +361 -0
- package/dist/cli/collectors/dom.js.map +1 -0
- package/dist/cli/collectors/helpers/domCache.d.ts +40 -0
- package/dist/cli/collectors/helpers/domCache.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/domCache.js +79 -0
- package/dist/cli/collectors/helpers/domCache.js.map +1 -0
- package/dist/cli/collectors/helpers/domQuery.d.ts +45 -0
- package/dist/cli/collectors/helpers/domQuery.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/domQuery.js +100 -0
- package/dist/cli/collectors/helpers/domQuery.js.map +1 -0
- package/dist/cli/collectors/helpers/selectorParser.d.ts +20 -0
- package/dist/cli/collectors/helpers/selectorParser.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/selectorParser.js +20 -0
- package/dist/cli/collectors/helpers/selectorParser.js.map +1 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.d.ts +24 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.js +467 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.js.map +1 -0
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts +2 -0
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/ipcTest.test.js +37 -0
- package/dist/cli/commands/__tests__/ipcTest.test.js.map +1 -0
- package/dist/cli/commands/cdp.d.ts +8 -0
- package/dist/cli/commands/cdp.d.ts.map +1 -0
- package/dist/cli/commands/cdp.js +45 -0
- package/dist/cli/commands/cdp.js.map +1 -0
- package/dist/cli/commands/cleanup.d.ts +8 -0
- package/dist/cli/commands/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/cleanup.js +130 -0
- package/dist/cli/commands/cleanup.js.map +1 -0
- package/dist/cli/commands/console.d.ts +8 -0
- package/dist/cli/commands/console.d.ts.map +1 -0
- package/dist/cli/commands/console.js +97 -0
- package/dist/cli/commands/console.js.map +1 -0
- package/dist/cli/commands/details.d.ts +8 -0
- package/dist/cli/commands/details.d.ts.map +1 -0
- package/dist/cli/commands/details.js +68 -0
- package/dist/cli/commands/details.js.map +1 -0
- package/dist/cli/commands/dom/helpers/domCache.d.ts +36 -0
- package/dist/cli/commands/dom/helpers/domCache.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/domCache.js +65 -0
- package/dist/cli/commands/dom/helpers/domCache.js.map +1 -0
- package/dist/cli/commands/dom/helpers/domQuery.d.ts +48 -0
- package/dist/cli/commands/dom/helpers/domQuery.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/domQuery.js +104 -0
- package/dist/cli/commands/dom/helpers/domQuery.js.map +1 -0
- package/dist/cli/commands/dom/helpers/errorHandler.d.ts +45 -0
- package/dist/cli/commands/dom/helpers/errorHandler.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/errorHandler.js +70 -0
- package/dist/cli/commands/dom/helpers/errorHandler.js.map +1 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.d.ts +52 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.js +75 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.js.map +1 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts +35 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.js +51 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.js.map +1 -0
- package/dist/cli/commands/dom/helpers/selectorParser.d.ts +20 -0
- package/dist/cli/commands/dom/helpers/selectorParser.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/selectorParser.js +20 -0
- package/dist/cli/commands/dom/helpers/selectorParser.js.map +1 -0
- package/dist/cli/commands/dom/index.d.ts +8 -0
- package/dist/cli/commands/dom/index.d.ts.map +1 -0
- package/dist/cli/commands/dom/index.js +257 -0
- package/dist/cli/commands/dom/index.js.map +1 -0
- package/dist/cli/commands/ipcTest.d.ts +23 -0
- package/dist/cli/commands/ipcTest.d.ts.map +1 -0
- package/dist/cli/commands/ipcTest.js +181 -0
- package/dist/cli/commands/ipcTest.js.map +1 -0
- package/dist/cli/commands/network.d.ts +8 -0
- package/dist/cli/commands/network.d.ts.map +1 -0
- package/dist/cli/commands/network.js +40 -0
- package/dist/cli/commands/network.js.map +1 -0
- package/dist/cli/commands/peek.d.ts +8 -0
- package/dist/cli/commands/peek.d.ts.map +1 -0
- package/dist/cli/commands/peek.js +109 -0
- package/dist/cli/commands/peek.js.map +1 -0
- package/dist/cli/commands/query.d.ts +9 -0
- package/dist/cli/commands/query.d.ts.map +1 -0
- package/dist/cli/commands/query.js +127 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/start.d.ts +9 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +78 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +9 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +84 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +8 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +146 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/formatters/detailsFormatter.d.ts +10 -0
- package/dist/cli/formatters/detailsFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/detailsFormatter.js +63 -0
- package/dist/cli/formatters/detailsFormatter.js.map +1 -0
- package/dist/cli/formatters/previewFormatter.d.ts +27 -0
- package/dist/cli/formatters/previewFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/previewFormatter.js +160 -0
- package/dist/cli/formatters/previewFormatter.js.map +1 -0
- package/dist/cli/formatters/statusFormatter.d.ts +34 -0
- package/dist/cli/formatters/statusFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/statusFormatter.js +108 -0
- package/dist/cli/formatters/statusFormatter.js.map +1 -0
- package/dist/cli/handlers/ChromeBootstrap.d.ts +24 -0
- package/dist/cli/handlers/ChromeBootstrap.d.ts.map +1 -0
- package/dist/cli/handlers/ChromeBootstrap.js +50 -0
- package/dist/cli/handlers/ChromeBootstrap.js.map +1 -0
- package/dist/cli/handlers/CommandRunner.d.ts +60 -0
- package/dist/cli/handlers/CommandRunner.d.ts.map +1 -0
- package/dist/cli/handlers/CommandRunner.js +81 -0
- package/dist/cli/handlers/CommandRunner.js.map +1 -0
- package/dist/cli/handlers/OutputBuilder.d.ts +60 -0
- package/dist/cli/handlers/OutputBuilder.d.ts.map +1 -0
- package/dist/cli/handlers/OutputBuilder.js +138 -0
- package/dist/cli/handlers/OutputBuilder.js.map +1 -0
- package/dist/cli/handlers/OutputWriter.d.ts +15 -0
- package/dist/cli/handlers/OutputWriter.d.ts.map +1 -0
- package/dist/cli/handlers/OutputWriter.js +34 -0
- package/dist/cli/handlers/OutputWriter.js.map +1 -0
- package/dist/cli/handlers/PreviewWriter.d.ts +52 -0
- package/dist/cli/handlers/PreviewWriter.d.ts.map +1 -0
- package/dist/cli/handlers/PreviewWriter.js +119 -0
- package/dist/cli/handlers/PreviewWriter.js.map +1 -0
- package/dist/cli/handlers/SessionLock.d.ts +16 -0
- package/dist/cli/handlers/SessionLock.d.ts.map +1 -0
- package/dist/cli/handlers/SessionLock.js +38 -0
- package/dist/cli/handlers/SessionLock.js.map +1 -0
- package/dist/cli/handlers/SessionLoop.d.ts +19 -0
- package/dist/cli/handlers/SessionLoop.d.ts.map +1 -0
- package/dist/cli/handlers/SessionLoop.js +47 -0
- package/dist/cli/handlers/SessionLoop.js.map +1 -0
- package/dist/cli/handlers/ShutdownController.d.ts +38 -0
- package/dist/cli/handlers/ShutdownController.d.ts.map +1 -0
- package/dist/cli/handlers/ShutdownController.js +83 -0
- package/dist/cli/handlers/ShutdownController.js.map +1 -0
- package/dist/cli/handlers/SignalHandler.d.ts +35 -0
- package/dist/cli/handlers/SignalHandler.d.ts.map +1 -0
- package/dist/cli/handlers/SignalHandler.js +81 -0
- package/dist/cli/handlers/SignalHandler.js.map +1 -0
- package/dist/cli/handlers/TargetSetup.d.ts +42 -0
- package/dist/cli/handlers/TargetSetup.d.ts.map +1 -0
- package/dist/cli/handlers/TargetSetup.js +87 -0
- package/dist/cli/handlers/TargetSetup.js.map +1 -0
- package/dist/cli/handlers/commonOptions.d.ts +54 -0
- package/dist/cli/handlers/commonOptions.d.ts.map +1 -0
- package/dist/cli/handlers/commonOptions.js +64 -0
- package/dist/cli/handlers/commonOptions.js.map +1 -0
- package/dist/cli/handlers/daemonSessionController.d.ts +23 -0
- package/dist/cli/handlers/daemonSessionController.d.ts.map +1 -0
- package/dist/cli/handlers/daemonSessionController.js +108 -0
- package/dist/cli/handlers/daemonSessionController.js.map +1 -0
- package/dist/cli/handlers/sessionController.d.ts +21 -0
- package/dist/cli/handlers/sessionController.d.ts.map +1 -0
- package/dist/cli/handlers/sessionController.js +55 -0
- package/dist/cli/handlers/sessionController.js.map +1 -0
- package/dist/cli/registry.d.ts +11 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +46 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/collectors/__tests__/network.contract.test.d.ts +28 -0
- package/dist/collectors/__tests__/network.contract.test.d.ts.map +1 -0
- package/dist/collectors/__tests__/network.contract.test.js +525 -0
- package/dist/collectors/__tests__/network.contract.test.js.map +1 -0
- package/dist/collectors/console.d.ts +5 -3
- package/dist/collectors/console.d.ts.map +1 -1
- package/dist/collectors/console.js +48 -26
- package/dist/collectors/console.js.map +1 -1
- package/dist/collectors/dom.d.ts +2 -2
- package/dist/collectors/dom.d.ts.map +1 -1
- package/dist/collectors/dom.js +23 -12
- package/dist/collectors/dom.js.map +1 -1
- package/dist/collectors/network.d.ts +18 -4
- package/dist/collectors/network.d.ts.map +1 -1
- package/dist/collectors/network.js +111 -34
- package/dist/collectors/network.js.map +1 -1
- package/dist/connection/__tests__/cdp.contract.test.d.ts +16 -0
- package/dist/connection/__tests__/cdp.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/cdp.contract.test.js +378 -0
- package/dist/connection/__tests__/cdp.contract.test.js.map +1 -0
- package/dist/connection/__tests__/finder.contract.test.d.ts +2 -0
- package/dist/connection/__tests__/finder.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/finder.contract.test.js +239 -0
- package/dist/connection/__tests__/finder.contract.test.js.map +1 -0
- package/dist/connection/__tests__/tabs.contract.test.d.ts +2 -0
- package/dist/connection/__tests__/tabs.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/tabs.contract.test.js +137 -0
- package/dist/connection/__tests__/tabs.contract.test.js.map +1 -0
- package/dist/connection/cdp.d.ts +165 -16
- package/dist/connection/cdp.d.ts.map +1 -1
- package/dist/connection/cdp.js +342 -122
- package/dist/connection/cdp.js.map +1 -1
- package/dist/connection/finder.d.ts +5 -4
- package/dist/connection/finder.d.ts.map +1 -1
- package/dist/connection/finder.js +10 -16
- package/dist/connection/finder.js.map +1 -1
- package/dist/connection/launcher.d.ts +18 -11
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +148 -82
- package/dist/connection/launcher.js.map +1 -1
- package/dist/connection/tabs.d.ts +47 -14
- package/dist/connection/tabs.d.ts.map +1 -1
- package/dist/connection/tabs.js +493 -132
- package/dist/connection/tabs.js.map +1 -1
- package/dist/constants.d.ts +209 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +232 -0
- package/dist/constants.js.map +1 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.d.ts +23 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.js +401 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.js.map +1 -0
- package/dist/daemon/__tests__/launcher.unit.test.d.ts +8 -0
- package/dist/daemon/__tests__/launcher.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/launcher.unit.test.js +20 -0
- package/dist/daemon/__tests__/launcher.unit.test.js.map +1 -0
- package/dist/daemon/ipcServer.d.ts +83 -0
- package/dist/daemon/ipcServer.d.ts.map +1 -0
- package/dist/daemon/ipcServer.js +670 -0
- package/dist/daemon/ipcServer.js.map +1 -0
- package/dist/daemon/launcher.d.ts +31 -0
- package/dist/daemon/launcher.d.ts.map +1 -0
- package/dist/daemon/launcher.js +137 -0
- package/dist/daemon/launcher.js.map +1 -0
- package/dist/daemon/startSession.d.ts +51 -0
- package/dist/daemon/startSession.d.ts.map +1 -0
- package/dist/daemon/startSession.js +149 -0
- package/dist/daemon/startSession.js.map +1 -0
- package/dist/daemon/worker.d.ts +18 -0
- package/dist/daemon/worker.d.ts.map +1 -0
- package/dist/daemon/worker.js +623 -0
- package/dist/daemon/worker.js.map +1 -0
- package/dist/daemon/workerIpc.d.ts +33 -0
- package/dist/daemon/workerIpc.d.ts.map +1 -0
- package/dist/daemon/workerIpc.js +8 -0
- package/dist/daemon/workerIpc.js.map +1 -0
- package/dist/daemon.d.ts +10 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +32 -0
- package/dist/daemon.js.map +1 -0
- package/dist/index.js +41 -420
- package/dist/index.js.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.d.ts +23 -0
- package/dist/ipc/__tests__/client.contract.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/client.contract.test.js +466 -0
- package/dist/ipc/__tests__/client.contract.test.js.map +1 -0
- package/dist/ipc/client.d.ts +109 -0
- package/dist/ipc/client.d.ts.map +1 -0
- package/dist/ipc/client.js +220 -0
- package/dist/ipc/client.js.map +1 -0
- package/dist/ipc/commands.d.ts +208 -0
- package/dist/ipc/commands.d.ts.map +1 -0
- package/dist/ipc/commands.js +69 -0
- package/dist/ipc/commands.js.map +1 -0
- package/dist/ipc/responseValidator.d.ts +40 -0
- package/dist/ipc/responseValidator.d.ts.map +1 -0
- package/dist/ipc/responseValidator.js +28 -0
- package/dist/ipc/responseValidator.js.map +1 -0
- package/dist/ipc/types.d.ts +193 -0
- package/dist/ipc/types.d.ts.map +1 -0
- package/dist/ipc/types.js +21 -0
- package/dist/ipc/types.js.map +1 -0
- package/dist/session/BdgSession.d.ts +71 -4
- package/dist/session/BdgSession.d.ts.map +1 -1
- package/dist/session/BdgSession.js +173 -75
- package/dist/session/BdgSession.js.map +1 -1
- package/dist/session/chrome.d.ts +46 -0
- package/dist/session/chrome.d.ts.map +1 -0
- package/dist/session/chrome.js +92 -0
- package/dist/session/chrome.js.map +1 -0
- package/dist/session/cleanup.d.ts +45 -0
- package/dist/session/cleanup.d.ts.map +1 -0
- package/dist/session/cleanup.js +230 -0
- package/dist/session/cleanup.js.map +1 -0
- package/dist/session/index.d.ts +15 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +23 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/lock.d.ts +57 -0
- package/dist/session/lock.d.ts.map +1 -0
- package/dist/session/lock.js +154 -0
- package/dist/session/lock.js.map +1 -0
- package/dist/session/metadata.d.ts +59 -0
- package/dist/session/metadata.d.ts.map +1 -0
- package/dist/session/metadata.js +71 -0
- package/dist/session/metadata.js.map +1 -0
- package/dist/session/output.d.ts +18 -0
- package/dist/session/output.d.ts.map +1 -0
- package/dist/session/output.js +24 -0
- package/dist/session/output.js.map +1 -0
- package/dist/session/paths.d.ts +73 -0
- package/dist/session/paths.d.ts.map +1 -0
- package/dist/session/paths.js +84 -0
- package/dist/session/paths.js.map +1 -0
- package/dist/session/pid.d.ts +40 -0
- package/dist/session/pid.d.ts.map +1 -0
- package/dist/session/pid.js +73 -0
- package/dist/session/pid.js.map +1 -0
- package/dist/session/process.d.ts +45 -0
- package/dist/session/process.d.ts.map +1 -0
- package/dist/session/process.js +88 -0
- package/dist/session/process.js.map +1 -0
- package/dist/types.d.ts +114 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/__tests__/filters.unit.test.d.ts +2 -0
- package/dist/utils/__tests__/filters.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/filters.unit.test.js +239 -0
- package/dist/utils/__tests__/filters.unit.test.js.map +1 -0
- package/dist/utils/__tests__/session.contract.test.d.ts +2 -0
- package/dist/utils/__tests__/session.contract.test.d.ts.map +1 -0
- package/dist/utils/__tests__/session.contract.test.js +234 -0
- package/dist/utils/__tests__/session.contract.test.js.map +1 -0
- package/dist/utils/atomicFile.d.ts +38 -0
- package/dist/utils/atomicFile.d.ts.map +1 -0
- package/dist/utils/atomicFile.js +71 -0
- package/dist/utils/atomicFile.js.map +1 -0
- package/dist/utils/cdpHandlers.d.ts +31 -0
- package/dist/utils/cdpHandlers.d.ts.map +1 -0
- package/dist/utils/cdpHandlers.js +38 -0
- package/dist/utils/cdpHandlers.js.map +1 -0
- package/dist/utils/chromeDiagnostics.d.ts +28 -0
- package/dist/utils/chromeDiagnostics.d.ts.map +1 -0
- package/dist/utils/chromeDiagnostics.js +88 -0
- package/dist/utils/chromeDiagnostics.js.map +1 -0
- package/dist/utils/errors.d.ts +82 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +88 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exitCodes.d.ts +32 -0
- package/dist/utils/exitCodes.d.ts.map +1 -0
- package/dist/utils/exitCodes.js +36 -0
- package/dist/utils/exitCodes.js.map +1 -0
- package/dist/utils/filters.d.ts +108 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +304 -0
- package/dist/utils/filters.js.map +1 -0
- package/dist/utils/formatters/network.d.ts +23 -0
- package/dist/utils/formatters/network.d.ts.map +1 -0
- package/dist/utils/formatters/network.js +35 -0
- package/dist/utils/formatters/network.js.map +1 -0
- package/dist/utils/http.d.ts +34 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +48 -0
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/logger.d.ts +42 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +43 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/objects.d.ts +23 -0
- package/dist/utils/objects.d.ts.map +1 -0
- package/dist/utils/objects.js +25 -0
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/url/safeParseUrl.d.ts +63 -0
- package/dist/utils/url/safeParseUrl.d.ts.map +1 -0
- package/dist/utils/url/safeParseUrl.js +84 -0
- package/dist/utils/url/safeParseUrl.js.map +1 -0
- package/dist/utils/url.d.ts +63 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +152 -2
- package/dist/utils/url.js.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/version.d.ts +3 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +27 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +57 -10
- package/dist/utils/pageLoad.d.ts +0 -21
- package/dist/utils/pageLoad.d.ts.map +0 -1
- package/dist/utils/pageLoad.js +0 -85
- package/dist/utils/pageLoad.js.map +0 -1
- package/dist/utils/session.d.ts +0 -104
- package/dist/utils/session.d.ts.map +0 -1
- package/dist/utils/session.js +0 -244
- package/dist/utils/session.js.map +0 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session lock management for preventing concurrent sessions.
|
|
3
|
+
*
|
|
4
|
+
* Uses exclusive file creation (wx flag) with PID tracking for atomic lock acquisition.
|
|
5
|
+
* WHY: Prevents race conditions when multiple bdg processes try to start simultaneously.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import { getSessionFilePath, ensureSessionDir } from './paths.js';
|
|
9
|
+
import { isProcessAlive } from './process.js';
|
|
10
|
+
/**
|
|
11
|
+
* Acquire session lock atomically.
|
|
12
|
+
*
|
|
13
|
+
* Uses exclusive file creation (wx flag) to ensure only one session can run.
|
|
14
|
+
* If lock file exists but process is dead, automatically removes stale lock and retries.
|
|
15
|
+
*
|
|
16
|
+
* @returns True if lock was acquired, false if another session is running
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* if (!acquireSessionLock()) {
|
|
21
|
+
* console.error('Another session is already running');
|
|
22
|
+
* process.exit(1);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function acquireSessionLock() {
|
|
27
|
+
ensureSessionDir();
|
|
28
|
+
const lockPath = getSessionFilePath('LOCK');
|
|
29
|
+
try {
|
|
30
|
+
// 'wx' flag creates file exclusively - fails if exists
|
|
31
|
+
fs.writeFileSync(lockPath, process.pid.toString(), { flag: 'wx' });
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof Error && 'code' in error && error.code === 'EEXIST') {
|
|
36
|
+
// Lock file exists - check if process is still alive
|
|
37
|
+
try {
|
|
38
|
+
const lockPidStr = fs.readFileSync(lockPath, 'utf-8').trim();
|
|
39
|
+
const lockPid = parseInt(lockPidStr, 10);
|
|
40
|
+
if (!isNaN(lockPid) && isProcessAlive(lockPid)) {
|
|
41
|
+
// Lock is held by active process
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Stale lock file - remove it and try again
|
|
46
|
+
fs.unlinkSync(lockPath);
|
|
47
|
+
return acquireSessionLock();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Can't read lock file - assume it's stale
|
|
52
|
+
try {
|
|
53
|
+
fs.unlinkSync(lockPath);
|
|
54
|
+
return acquireSessionLock();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Release session lock.
|
|
66
|
+
*
|
|
67
|
+
* Removes the lock file to allow other sessions to start.
|
|
68
|
+
* Safe to call multiple times (idempotent).
|
|
69
|
+
*/
|
|
70
|
+
export function releaseSessionLock() {
|
|
71
|
+
const lockPath = getSessionFilePath('LOCK');
|
|
72
|
+
try {
|
|
73
|
+
if (fs.existsSync(lockPath)) {
|
|
74
|
+
fs.unlinkSync(lockPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Ignore errors during cleanup
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Acquire daemon lock atomically.
|
|
83
|
+
*
|
|
84
|
+
* Uses exclusive file creation (wx flag) to ensure only one daemon can start.
|
|
85
|
+
* If lock file exists but process is dead, automatically removes stale lock and retries.
|
|
86
|
+
*
|
|
87
|
+
* WHY: Prevents race condition where two concurrent bdg commands spawn 2 daemons.
|
|
88
|
+
*
|
|
89
|
+
* @returns True if lock was acquired, false if another daemon startup is in progress
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* if (!acquireDaemonLock()) {
|
|
94
|
+
* console.error('Another daemon is starting up');
|
|
95
|
+
* process.exit(1);
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export function acquireDaemonLock() {
|
|
100
|
+
ensureSessionDir();
|
|
101
|
+
const lockPath = getSessionFilePath('DAEMON_LOCK');
|
|
102
|
+
try {
|
|
103
|
+
// 'wx' flag creates file exclusively - fails if exists
|
|
104
|
+
fs.writeFileSync(lockPath, process.pid.toString(), { flag: 'wx' });
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error instanceof Error && 'code' in error && error.code === 'EEXIST') {
|
|
109
|
+
// Lock file exists - check if process is still alive
|
|
110
|
+
try {
|
|
111
|
+
const lockPidStr = fs.readFileSync(lockPath, 'utf-8').trim();
|
|
112
|
+
const lockPid = parseInt(lockPidStr, 10);
|
|
113
|
+
if (!isNaN(lockPid) && isProcessAlive(lockPid)) {
|
|
114
|
+
// Lock is held by active process
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Stale lock file - remove it and try again
|
|
119
|
+
fs.unlinkSync(lockPath);
|
|
120
|
+
return acquireDaemonLock();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Can't read lock file - assume it's stale
|
|
125
|
+
try {
|
|
126
|
+
fs.unlinkSync(lockPath);
|
|
127
|
+
return acquireDaemonLock();
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Release daemon lock.
|
|
139
|
+
*
|
|
140
|
+
* Removes the daemon lock file to allow other daemon startups.
|
|
141
|
+
* Safe to call multiple times (idempotent).
|
|
142
|
+
*/
|
|
143
|
+
export function releaseDaemonLock() {
|
|
144
|
+
const lockPath = getSessionFilePath('DAEMON_LOCK');
|
|
145
|
+
try {
|
|
146
|
+
if (fs.existsSync(lockPath)) {
|
|
147
|
+
fs.unlinkSync(lockPath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Ignore errors during cleanup
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=lock.js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AC,CAAC;gBAEzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC/C,iCAAiC;oBACjC,OAAO,KAAK,CAAC;gBACf,CAAC;qBAAM,CAAC;oBACN,4CAA4C;oBAC5C,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;oBACxB,OAAO,iBAAiB,EAAE,CAAC;gBAC7B,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,2CAA2C;gBAC3C,IAAI,CAAC;oBACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;oBACxB,OAAO,iBAAiB,EAAE,CAAC;gBAC7B,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAEnD,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session metadata management.
|
|
3
|
+
*
|
|
4
|
+
* Handles reading/writing session metadata (Chrome PID, CDP port, target info, etc).
|
|
5
|
+
* WHY: Metadata persistence enables `bdg status` and other commands to inspect active sessions.
|
|
6
|
+
*/
|
|
7
|
+
import type { CollectorType } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Session metadata stored in ~/.bdg/session.meta.json
|
|
10
|
+
*/
|
|
11
|
+
export interface SessionMetadata {
|
|
12
|
+
bdgPid: number;
|
|
13
|
+
chromePid?: number | undefined;
|
|
14
|
+
startTime: number;
|
|
15
|
+
port: number;
|
|
16
|
+
targetId?: string | undefined;
|
|
17
|
+
webSocketDebuggerUrl?: string | undefined;
|
|
18
|
+
activeCollectors?: CollectorType[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Write session metadata atomically.
|
|
22
|
+
*
|
|
23
|
+
* Uses atomic write (tmp file + rename) to prevent corruption.
|
|
24
|
+
*
|
|
25
|
+
* @param metadata - Session metadata to write
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* writeSessionMetadata({
|
|
30
|
+
* bdgPid: process.pid,
|
|
31
|
+
* chromePid: 12345,
|
|
32
|
+
* startTime: Date.now(),
|
|
33
|
+
* port: 9222,
|
|
34
|
+
* activeCollectors: ['network', 'console', 'dom']
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function writeSessionMetadata(metadata: SessionMetadata): void;
|
|
39
|
+
/**
|
|
40
|
+
* Read session metadata.
|
|
41
|
+
*
|
|
42
|
+
* WHY: P1 Fix #2 - Now logs warnings when metadata is corrupted.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Options for error handling
|
|
45
|
+
* @returns Session metadata if file exists and is valid, null otherwise
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const metadata = readSessionMetadata({ warnOnCorruption: true });
|
|
50
|
+
* if (metadata) {
|
|
51
|
+
* console.log(`Session started at: ${new Date(metadata.startTime)}`);
|
|
52
|
+
* console.log(`Chrome PID: ${metadata.chromePid}`);
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function readSessionMetadata(options?: {
|
|
57
|
+
warnOnCorruption?: boolean;
|
|
58
|
+
}): SessionMetadata | null;
|
|
59
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/session/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAS7C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,gBAAgB,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAIpE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,eAAe,GAAG,IAAI,CAkBzB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session metadata management.
|
|
3
|
+
*
|
|
4
|
+
* Handles reading/writing session metadata (Chrome PID, CDP port, target info, etc).
|
|
5
|
+
* WHY: Metadata persistence enables `bdg status` and other commands to inspect active sessions.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import { AtomicFileWriter } from '../utils/atomicFile.js';
|
|
9
|
+
import { getErrorMessage } from '../utils/errors.js';
|
|
10
|
+
import { createLogger } from '../utils/logger.js';
|
|
11
|
+
import { getSessionFilePath, ensureSessionDir } from './paths.js';
|
|
12
|
+
const log = createLogger('session');
|
|
13
|
+
/**
|
|
14
|
+
* Write session metadata atomically.
|
|
15
|
+
*
|
|
16
|
+
* Uses atomic write (tmp file + rename) to prevent corruption.
|
|
17
|
+
*
|
|
18
|
+
* @param metadata - Session metadata to write
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* writeSessionMetadata({
|
|
23
|
+
* bdgPid: process.pid,
|
|
24
|
+
* chromePid: 12345,
|
|
25
|
+
* startTime: Date.now(),
|
|
26
|
+
* port: 9222,
|
|
27
|
+
* activeCollectors: ['network', 'console', 'dom']
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function writeSessionMetadata(metadata) {
|
|
32
|
+
ensureSessionDir();
|
|
33
|
+
const metaPath = getSessionFilePath('METADATA');
|
|
34
|
+
AtomicFileWriter.writeSync(metaPath, JSON.stringify(metadata, null, 2));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read session metadata.
|
|
38
|
+
*
|
|
39
|
+
* WHY: P1 Fix #2 - Now logs warnings when metadata is corrupted.
|
|
40
|
+
*
|
|
41
|
+
* @param options - Options for error handling
|
|
42
|
+
* @returns Session metadata if file exists and is valid, null otherwise
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const metadata = readSessionMetadata({ warnOnCorruption: true });
|
|
47
|
+
* if (metadata) {
|
|
48
|
+
* console.log(`Session started at: ${new Date(metadata.startTime)}`);
|
|
49
|
+
* console.log(`Chrome PID: ${metadata.chromePid}`);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function readSessionMetadata(options) {
|
|
54
|
+
const metaPath = getSessionFilePath('METADATA');
|
|
55
|
+
if (!fs.existsSync(metaPath)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const content = fs.readFileSync(metaPath, 'utf-8');
|
|
60
|
+
return JSON.parse(content);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// P1 Fix #2: Warn when metadata is corrupted
|
|
64
|
+
if (options?.warnOnCorruption) {
|
|
65
|
+
log(`Session metadata corrupted (cannot read details): ${getErrorMessage(error)}`);
|
|
66
|
+
log('Troubleshooting: Run "bdg cleanup" to remove corrupted files');
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/session/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,GAAG,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAepC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAyB;IAC5D,gBAAgB,EAAE,CAAC;IACnB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAChD,gBAAgB,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAEnC;IACC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAEhD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,6CAA6C;QAC7C,IAAI,OAAO,EAAE,gBAAgB,EAAE,CAAC;YAC9B,GAAG,CAAC,qDAAqD,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACnF,GAAG,CAAC,8DAA8D,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session output file management.
|
|
3
|
+
*
|
|
4
|
+
* Handles writing final session output to disk.
|
|
5
|
+
* Note: Live preview/details now use IPC streaming instead of file writes.
|
|
6
|
+
*/
|
|
7
|
+
import type { BdgOutput } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Write session output to the final JSON file.
|
|
10
|
+
*
|
|
11
|
+
* This is written once at the end of a session.
|
|
12
|
+
* Note: Preview/details data is now accessed via IPC streaming during collection.
|
|
13
|
+
*
|
|
14
|
+
* @param output - The BdgOutput data to write
|
|
15
|
+
* @param compact - If true, use compact JSON format (no indentation)
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeSessionOutput(output: BdgOutput, compact?: boolean): void;
|
|
18
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/session/output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI,CAKpF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session output file management.
|
|
3
|
+
*
|
|
4
|
+
* Handles writing final session output to disk.
|
|
5
|
+
* Note: Live preview/details now use IPC streaming instead of file writes.
|
|
6
|
+
*/
|
|
7
|
+
import { AtomicFileWriter } from '../utils/atomicFile.js';
|
|
8
|
+
import { getSessionFilePath, ensureSessionDir } from './paths.js';
|
|
9
|
+
/**
|
|
10
|
+
* Write session output to the final JSON file.
|
|
11
|
+
*
|
|
12
|
+
* This is written once at the end of a session.
|
|
13
|
+
* Note: Preview/details data is now accessed via IPC streaming during collection.
|
|
14
|
+
*
|
|
15
|
+
* @param output - The BdgOutput data to write
|
|
16
|
+
* @param compact - If true, use compact JSON format (no indentation)
|
|
17
|
+
*/
|
|
18
|
+
export function writeSessionOutput(output, compact = false) {
|
|
19
|
+
ensureSessionDir();
|
|
20
|
+
const outputPath = getSessionFilePath('OUTPUT');
|
|
21
|
+
const jsonString = compact ? JSON.stringify(output) : JSON.stringify(output, null, 2);
|
|
22
|
+
AtomicFileWriter.writeSync(outputPath, jsonString);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/session/output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,UAAmB,KAAK;IAC5E,gBAAgB,EAAE,CAAC;IACnB,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAChD,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;IACtF,gBAAgB,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session path generation and management.
|
|
3
|
+
*
|
|
4
|
+
* Centralized path generation for all session-related files in ~/.bdg/
|
|
5
|
+
* WHY: Single source of truth for file locations prevents path inconsistencies.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Session file paths relative to ~/.bdg/
|
|
9
|
+
* Centralized definition for all session-related files.
|
|
10
|
+
*/
|
|
11
|
+
declare const SESSION_FILES: {
|
|
12
|
+
readonly PID: "session.pid";
|
|
13
|
+
readonly OUTPUT: "session.json";
|
|
14
|
+
readonly LOCK: "session.lock";
|
|
15
|
+
readonly METADATA: "session.meta.json";
|
|
16
|
+
readonly CHROME_PID: "chrome.pid";
|
|
17
|
+
readonly DAEMON_PID: "daemon.pid";
|
|
18
|
+
readonly DAEMON_SOCKET: "daemon.sock";
|
|
19
|
+
readonly DAEMON_LOCK: "daemon.lock";
|
|
20
|
+
readonly DOM_QUERY_CACHE: "last-query.json";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Session file type for type-safe path generation
|
|
24
|
+
*/
|
|
25
|
+
export type SessionFileType = keyof typeof SESSION_FILES;
|
|
26
|
+
/**
|
|
27
|
+
* Get the session directory path (~/.bdg)
|
|
28
|
+
*
|
|
29
|
+
* Uses os.homedir() dynamically to support test environment variable changes.
|
|
30
|
+
*
|
|
31
|
+
* @returns Full path to session directory
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSessionDir(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the path to a session file by type.
|
|
36
|
+
*
|
|
37
|
+
* @param fileType - The type of session file
|
|
38
|
+
* @returns Full path to the session file
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* getSessionFilePath('PID') // → ~/.bdg/session.pid
|
|
43
|
+
* getSessionFilePath('DAEMON_PID') // → ~/.bdg/daemon.pid
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSessionFilePath(fileType: SessionFileType): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get the path to the worker Unix domain socket.
|
|
49
|
+
*
|
|
50
|
+
* WHY: Single canonical place for worker UDS path; predictable cleanup; avoids collisions.
|
|
51
|
+
*
|
|
52
|
+
* @param workerPid - Worker process ID
|
|
53
|
+
* @returns Full path to worker socket
|
|
54
|
+
*/
|
|
55
|
+
export declare function getWorkerSocketPath(workerPid: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* Get the path to the DOM query cache file.
|
|
58
|
+
*
|
|
59
|
+
* WHY: Stores last DOM query results for index-based element references.
|
|
60
|
+
*
|
|
61
|
+
* @returns Full path to DOM query cache file
|
|
62
|
+
*/
|
|
63
|
+
export declare function getDomQueryCachePath(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Ensure the session directory exists.
|
|
66
|
+
*
|
|
67
|
+
* Creates ~/.bdg/ if it doesn't exist. Safe to call multiple times (idempotent).
|
|
68
|
+
*
|
|
69
|
+
* @throws Error if directory creation fails due to permissions
|
|
70
|
+
*/
|
|
71
|
+
export declare function ensureSessionDir(): void;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/session/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;CAUT,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,aAAa,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session path generation and management.
|
|
3
|
+
*
|
|
4
|
+
* Centralized path generation for all session-related files in ~/.bdg/
|
|
5
|
+
* WHY: Single source of truth for file locations prevents path inconsistencies.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as os from 'os';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
/**
|
|
11
|
+
* Session file paths relative to ~/.bdg/
|
|
12
|
+
* Centralized definition for all session-related files.
|
|
13
|
+
*/
|
|
14
|
+
const SESSION_FILES = {
|
|
15
|
+
PID: 'session.pid',
|
|
16
|
+
OUTPUT: 'session.json',
|
|
17
|
+
LOCK: 'session.lock',
|
|
18
|
+
METADATA: 'session.meta.json',
|
|
19
|
+
CHROME_PID: 'chrome.pid',
|
|
20
|
+
DAEMON_PID: 'daemon.pid',
|
|
21
|
+
DAEMON_SOCKET: 'daemon.sock',
|
|
22
|
+
DAEMON_LOCK: 'daemon.lock',
|
|
23
|
+
DOM_QUERY_CACHE: 'last-query.json',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Get the session directory path (~/.bdg)
|
|
27
|
+
*
|
|
28
|
+
* Uses os.homedir() dynamically to support test environment variable changes.
|
|
29
|
+
*
|
|
30
|
+
* @returns Full path to session directory
|
|
31
|
+
*/
|
|
32
|
+
export function getSessionDir() {
|
|
33
|
+
return path.join(os.homedir(), '.bdg');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the path to a session file by type.
|
|
37
|
+
*
|
|
38
|
+
* @param fileType - The type of session file
|
|
39
|
+
* @returns Full path to the session file
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* getSessionFilePath('PID') // → ~/.bdg/session.pid
|
|
44
|
+
* getSessionFilePath('DAEMON_PID') // → ~/.bdg/daemon.pid
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function getSessionFilePath(fileType) {
|
|
48
|
+
return path.join(getSessionDir(), SESSION_FILES[fileType]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the path to the worker Unix domain socket.
|
|
52
|
+
*
|
|
53
|
+
* WHY: Single canonical place for worker UDS path; predictable cleanup; avoids collisions.
|
|
54
|
+
*
|
|
55
|
+
* @param workerPid - Worker process ID
|
|
56
|
+
* @returns Full path to worker socket
|
|
57
|
+
*/
|
|
58
|
+
export function getWorkerSocketPath(workerPid) {
|
|
59
|
+
return path.join(getSessionDir(), `worker.${workerPid}.sock`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the path to the DOM query cache file.
|
|
63
|
+
*
|
|
64
|
+
* WHY: Stores last DOM query results for index-based element references.
|
|
65
|
+
*
|
|
66
|
+
* @returns Full path to DOM query cache file
|
|
67
|
+
*/
|
|
68
|
+
export function getDomQueryCachePath() {
|
|
69
|
+
return getSessionFilePath('DOM_QUERY_CACHE');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Ensure the session directory exists.
|
|
73
|
+
*
|
|
74
|
+
* Creates ~/.bdg/ if it doesn't exist. Safe to call multiple times (idempotent).
|
|
75
|
+
*
|
|
76
|
+
* @throws Error if directory creation fails due to permissions
|
|
77
|
+
*/
|
|
78
|
+
export function ensureSessionDir() {
|
|
79
|
+
const dir = getSessionDir();
|
|
80
|
+
if (!fs.existsSync(dir)) {
|
|
81
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @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SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session PID file management.
|
|
3
|
+
*
|
|
4
|
+
* Handles reading/writing the main session PID file for tracking active sessions.
|
|
5
|
+
* WHY: Centralized PID operations prevent inconsistencies in session tracking.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Write the current process PID to the session file atomically.
|
|
9
|
+
*
|
|
10
|
+
* Uses atomic write (tmp file + rename) to prevent corruption if process crashes.
|
|
11
|
+
*
|
|
12
|
+
* @param pid - Process ID to write
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* writePid(process.pid);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function writePid(pid: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Read the PID from the session file.
|
|
22
|
+
*
|
|
23
|
+
* @returns The PID if file exists and is valid, null otherwise
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const sessionPid = readPid();
|
|
28
|
+
* if (sessionPid && isProcessAlive(sessionPid)) {
|
|
29
|
+
* console.log('Session is running');
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function readPid(): number | null;
|
|
34
|
+
/**
|
|
35
|
+
* Remove the PID file.
|
|
36
|
+
*
|
|
37
|
+
* Safe to call multiple times (idempotent).
|
|
38
|
+
*/
|
|
39
|
+
export declare function cleanupPidFile(): void;
|
|
40
|
+
//# sourceMappingURL=pid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pid.d.ts","sourceRoot":"","sources":["../../src/session/pid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,IAAI,MAAM,GAAG,IAAI,CAmBvC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAUrC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session PID file management.
|
|
3
|
+
*
|
|
4
|
+
* Handles reading/writing the main session PID file for tracking active sessions.
|
|
5
|
+
* WHY: Centralized PID operations prevent inconsistencies in session tracking.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import { AtomicFileWriter } from '../utils/atomicFile.js';
|
|
9
|
+
import { getSessionFilePath, ensureSessionDir } from './paths.js';
|
|
10
|
+
/**
|
|
11
|
+
* Write the current process PID to the session file atomically.
|
|
12
|
+
*
|
|
13
|
+
* Uses atomic write (tmp file + rename) to prevent corruption if process crashes.
|
|
14
|
+
*
|
|
15
|
+
* @param pid - Process ID to write
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* writePid(process.pid);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function writePid(pid) {
|
|
23
|
+
ensureSessionDir();
|
|
24
|
+
const pidPath = getSessionFilePath('PID');
|
|
25
|
+
AtomicFileWriter.writeSync(pidPath, pid.toString());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read the PID from the session file.
|
|
29
|
+
*
|
|
30
|
+
* @returns The PID if file exists and is valid, null otherwise
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const sessionPid = readPid();
|
|
35
|
+
* if (sessionPid && isProcessAlive(sessionPid)) {
|
|
36
|
+
* console.log('Session is running');
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function readPid() {
|
|
41
|
+
const pidPath = getSessionFilePath('PID');
|
|
42
|
+
if (!fs.existsSync(pidPath)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const pidStr = fs.readFileSync(pidPath, 'utf-8').trim();
|
|
47
|
+
const pid = parseInt(pidStr, 10);
|
|
48
|
+
if (isNaN(pid)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return pid;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove the PID file.
|
|
59
|
+
*
|
|
60
|
+
* Safe to call multiple times (idempotent).
|
|
61
|
+
*/
|
|
62
|
+
export function cleanupPidFile() {
|
|
63
|
+
const pidPath = getSessionFilePath('PID');
|
|
64
|
+
if (fs.existsSync(pidPath)) {
|
|
65
|
+
try {
|
|
66
|
+
fs.unlinkSync(pidPath);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Ignore errors during cleanup
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=pid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pid.js","sourceRoot":"","sources":["../../src/session/pid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,gBAAgB,EAAE,CAAC;IACnB,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1C,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;GAYG;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