browser-debugger-cli 0.1.0-alpha.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -68
- package/dist/__testfixtures__/cdpMessages.d.ts +1 -1
- package/dist/__testfixtures__/connectionTargets.d.ts +1 -1
- package/dist/__testutils__/assertions.d.ts +1 -1
- package/dist/__testutils__/testFixtures.d.ts +1 -1
- package/dist/cli/commands/cdp.js +1 -1
- package/dist/cli/commands/cleanup.d.ts.map +1 -1
- package/dist/cli/commands/cleanup.js +12 -13
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/console.js +2 -2
- package/dist/cli/commands/details.js +3 -3
- package/dist/cli/commands/details.js.map +1 -1
- package/dist/cli/commands/dom/helpers/errorHandler.d.ts.map +1 -1
- package/dist/cli/commands/dom/helpers/errorHandler.js +4 -3
- package/dist/cli/commands/dom/helpers/errorHandler.js.map +1 -1
- package/dist/cli/commands/dom/index.js +1 -1
- package/dist/cli/commands/dom.d.ts.map +1 -0
- package/dist/cli/commands/dom.js +257 -0
- package/dist/cli/commands/dom.js.map +1 -0
- package/dist/cli/commands/domErrorHandler.d.ts +45 -0
- package/dist/cli/commands/domErrorHandler.d.ts.map +1 -0
- package/dist/cli/commands/domErrorHandler.js +71 -0
- package/dist/cli/commands/domErrorHandler.js.map +1 -0
- package/dist/cli/commands/domEvalHelpers.d.ts +52 -0
- package/dist/cli/commands/domEvalHelpers.d.ts.map +1 -0
- package/dist/cli/commands/domEvalHelpers.js +76 -0
- package/dist/cli/commands/domEvalHelpers.js.map +1 -0
- package/dist/cli/commands/domOptionsBuilder.d.ts +35 -0
- package/dist/cli/commands/domOptionsBuilder.d.ts.map +1 -0
- package/dist/cli/commands/domOptionsBuilder.js +51 -0
- package/dist/cli/commands/domOptionsBuilder.js.map +1 -0
- package/dist/cli/{collectors/helpers/selectorParser.d.ts → commands/domSelectorParser.d.ts} +1 -1
- package/dist/cli/commands/domSelectorParser.d.ts.map +1 -0
- package/dist/cli/{collectors/helpers/selectorParser.js → commands/domSelectorParser.js} +1 -1
- package/dist/cli/commands/domSelectorParser.js.map +1 -0
- package/dist/cli/commands/network.d.ts.map +1 -1
- package/dist/cli/commands/network.js +8 -5
- package/dist/cli/commands/network.js.map +1 -1
- package/dist/cli/commands/peek.d.ts.map +1 -1
- package/dist/cli/commands/peek.js +7 -7
- package/dist/cli/commands/peek.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +19 -2
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +13 -10
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/stop.d.ts.map +1 -1
- package/dist/cli/commands/stop.js +7 -6
- package/dist/cli/commands/stop.js.map +1 -1
- package/dist/cli/formatters/detailsFormatter.d.ts +1 -1
- package/dist/cli/formatters/previewFormatter.d.ts +1 -1
- package/dist/cli/formatters/previewFormatter.js +1 -1
- package/dist/cli/formatters/previewFormatter.js.map +1 -1
- package/dist/cli/formatters/statusFormatter.d.ts +6 -1
- package/dist/cli/formatters/statusFormatter.d.ts.map +1 -1
- package/dist/cli/formatters/statusFormatter.js +49 -4
- package/dist/cli/formatters/statusFormatter.js.map +1 -1
- package/dist/cli/handlers/CommandRunner.d.ts.map +1 -1
- package/dist/cli/handlers/CommandRunner.js +5 -5
- package/dist/cli/handlers/CommandRunner.js.map +1 -1
- package/dist/cli/handlers/OutputBuilder.d.ts +1 -1
- package/dist/cli/handlers/daemonSessionController.d.ts +1 -1
- package/dist/cli/handlers/daemonSessionController.d.ts.map +1 -1
- package/dist/cli/handlers/daemonSessionController.js +16 -45
- package/dist/cli/handlers/daemonSessionController.js.map +1 -1
- package/dist/cli/handlers/landingPage.d.ts +8 -0
- package/dist/cli/handlers/landingPage.d.ts.map +1 -0
- package/dist/cli/handlers/landingPage.js +8 -0
- package/dist/cli/handlers/landingPage.js.map +1 -0
- package/dist/cli/registry.js +10 -10
- package/dist/cli/registry.js.map +1 -1
- package/dist/collectors/__tests__/network.contract.test.js +25 -10
- package/dist/collectors/__tests__/network.contract.test.js.map +1 -1
- package/dist/collectors/console.d.ts +1 -1
- package/dist/collectors/console.js.map +1 -1
- package/dist/collectors/dom.d.ts +1 -1
- package/dist/collectors/network.d.ts +1 -1
- package/dist/collectors/network.js.map +1 -1
- package/dist/commandRegistry.d.ts +11 -0
- package/dist/commandRegistry.d.ts.map +1 -0
- package/dist/commandRegistry.js +45 -0
- package/dist/commandRegistry.js.map +1 -0
- package/dist/commands/__tests__/cdp.contract.test.d.ts +24 -0
- package/dist/commands/__tests__/cdp.contract.test.d.ts.map +1 -0
- package/dist/commands/__tests__/cdp.contract.test.js +467 -0
- package/dist/commands/__tests__/cdp.contract.test.js.map +1 -0
- package/dist/commands/cdp.d.ts +8 -0
- package/dist/commands/cdp.d.ts.map +1 -0
- package/dist/commands/cdp.js +45 -0
- package/dist/commands/cdp.js.map +1 -0
- package/dist/commands/cleanup.d.ts +8 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +129 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/console.d.ts +8 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +92 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/details.d.ts +8 -0
- package/dist/commands/details.d.ts.map +1 -0
- package/dist/commands/details.js +68 -0
- package/dist/commands/details.js.map +1 -0
- package/dist/commands/dom.d.ts +8 -0
- package/dist/commands/dom.d.ts.map +1 -0
- package/dist/commands/dom.js +257 -0
- package/dist/commands/dom.js.map +1 -0
- package/dist/commands/domErrorHandler.d.ts +45 -0
- package/dist/commands/domErrorHandler.d.ts.map +1 -0
- package/dist/commands/domErrorHandler.js +71 -0
- package/dist/commands/domErrorHandler.js.map +1 -0
- package/dist/commands/domEvalHelpers.d.ts +52 -0
- package/dist/commands/domEvalHelpers.d.ts.map +1 -0
- package/dist/commands/domEvalHelpers.js +76 -0
- package/dist/commands/domEvalHelpers.js.map +1 -0
- package/dist/commands/domOptionsBuilder.d.ts +35 -0
- package/dist/commands/domOptionsBuilder.d.ts.map +1 -0
- package/dist/commands/domOptionsBuilder.js +51 -0
- package/dist/commands/domOptionsBuilder.js.map +1 -0
- package/dist/commands/domSelectorParser.d.ts +20 -0
- package/dist/commands/domSelectorParser.d.ts.map +1 -0
- package/dist/commands/domSelectorParser.js +20 -0
- package/dist/commands/domSelectorParser.js.map +1 -0
- package/dist/commands/network.d.ts +8 -0
- package/dist/commands/network.d.ts.map +1 -0
- package/dist/commands/network.js +43 -0
- package/dist/commands/network.js.map +1 -0
- package/dist/commands/peek.d.ts +8 -0
- package/dist/commands/peek.d.ts.map +1 -0
- package/dist/commands/peek.js +114 -0
- package/dist/commands/peek.js.map +1 -0
- package/dist/commands/shared/CommandRunner.d.ts +60 -0
- package/dist/commands/shared/CommandRunner.d.ts.map +1 -0
- package/dist/commands/shared/CommandRunner.js +81 -0
- package/dist/commands/shared/CommandRunner.js.map +1 -0
- package/dist/commands/shared/OutputBuilder.d.ts +60 -0
- package/dist/commands/shared/OutputBuilder.d.ts.map +1 -0
- package/dist/commands/shared/OutputBuilder.js +138 -0
- package/dist/commands/shared/OutputBuilder.js.map +1 -0
- package/dist/commands/shared/commonOptions.d.ts +54 -0
- package/dist/commands/shared/commonOptions.d.ts.map +1 -0
- package/dist/commands/shared/commonOptions.js +64 -0
- package/dist/commands/shared/commonOptions.js.map +1 -0
- package/dist/commands/shared/daemonSessionController.d.ts +23 -0
- package/dist/commands/shared/daemonSessionController.d.ts.map +1 -0
- package/dist/commands/shared/daemonSessionController.js +79 -0
- package/dist/commands/shared/daemonSessionController.js.map +1 -0
- package/dist/commands/shared/landingPage.d.ts +8 -0
- package/dist/commands/shared/landingPage.d.ts.map +1 -0
- package/dist/commands/shared/landingPage.js +8 -0
- package/dist/commands/shared/landingPage.js.map +1 -0
- package/dist/commands/shared/sessionController.d.ts +21 -0
- package/dist/commands/shared/sessionController.d.ts.map +1 -0
- package/dist/commands/shared/sessionController.js +55 -0
- package/dist/commands/shared/sessionController.js.map +1 -0
- package/dist/commands/start.d.ts +9 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +85 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/{cli/commands/query.d.ts → commands/status.d.ts} +3 -3
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +87 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +8 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +150 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands.d.ts +11 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +45 -0
- package/dist/commands.js.map +1 -0
- package/dist/connection/__tests__/cdp.contract.test.js +1 -1
- package/dist/connection/__tests__/finder.contract.test.js +1 -1
- package/dist/connection/__tests__/finder.contract.test.js.map +1 -1
- package/dist/connection/cdp.d.ts +1 -1
- package/dist/connection/cdp.js.map +1 -1
- package/dist/connection/domOperations.d.ts +48 -0
- package/dist/connection/domOperations.d.ts.map +1 -0
- package/dist/connection/domOperations.js +104 -0
- package/dist/connection/domOperations.js.map +1 -0
- package/dist/connection/finder.js.map +1 -1
- package/dist/connection/launcher.d.ts +7 -3
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +72 -21
- package/dist/connection/launcher.js.map +1 -1
- package/dist/constants.d.ts +17 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -1
- package/dist/daemon/__tests__/ipcServer.contract.test.js +25 -11
- package/dist/daemon/__tests__/ipcServer.contract.test.js.map +1 -1
- package/dist/daemon/ipcServer.d.ts.map +1 -1
- package/dist/daemon/ipcServer.js +86 -6
- package/dist/daemon/ipcServer.js.map +1 -1
- package/dist/daemon/launcher.d.ts.map +1 -1
- package/dist/daemon/launcher.js +8 -6
- package/dist/daemon/launcher.js.map +1 -1
- package/dist/daemon/startSession.d.ts +2 -2
- package/dist/daemon/startSession.d.ts.map +1 -1
- package/dist/daemon/startSession.js +12 -11
- package/dist/daemon/startSession.js.map +1 -1
- package/dist/daemon/worker.d.ts +1 -1
- package/dist/daemon/worker.js +97 -41
- package/dist/daemon/worker.js.map +1 -1
- package/dist/{cli/collectors/helpers/domCache.d.ts → dom/cache.d.ts} +1 -5
- package/dist/dom/cache.d.ts.map +1 -0
- package/dist/{cli/collectors/helpers/domCache.js → dom/cache.js} +5 -19
- package/dist/dom/cache.js.map +1 -0
- package/dist/dom/index.d.ts +9 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +9 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/{cli/collectors/helpers/domQuery.d.ts → dom/query.d.ts} +5 -2
- package/dist/dom/query.d.ts.map +1 -0
- package/dist/{cli/collectors/helpers/domQuery.js → dom/query.js} +11 -7
- package/dist/dom/query.js.map +1 -0
- package/dist/index.js +117 -35
- package/dist/index.js.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.js +11 -1
- package/dist/ipc/__tests__/client.contract.test.js.map +1 -1
- package/dist/ipc/client.d.ts +4 -4
- package/dist/ipc/client.d.ts.map +1 -1
- package/dist/ipc/client.js +10 -6
- package/dist/ipc/client.js.map +1 -1
- package/dist/ipc/commands.d.ts +33 -1
- package/dist/ipc/commands.d.ts.map +1 -1
- package/dist/ipc/commands.js +4 -0
- package/dist/ipc/commands.js.map +1 -1
- package/dist/ipc/types.d.ts +34 -3
- package/dist/ipc/types.d.ts.map +1 -1
- package/dist/ipc/types.js.map +1 -1
- package/dist/session/metadata.d.ts +2 -2
- package/dist/session/metadata.d.ts.map +1 -1
- package/dist/session/output.d.ts +1 -1
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +4 -3
- package/dist/session/process.js.map +1 -1
- package/dist/session/queryCache.d.ts +36 -0
- package/dist/session/queryCache.d.ts.map +1 -0
- package/dist/session/queryCache.js +66 -0
- package/dist/session/queryCache.js.map +1 -0
- package/dist/telemetry/__tests__/network.contract.test.d.ts +28 -0
- package/dist/telemetry/__tests__/network.contract.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/network.contract.test.js +540 -0
- package/dist/telemetry/__tests__/network.contract.test.js.map +1 -0
- package/dist/telemetry/console.d.ts +19 -0
- package/dist/telemetry/console.d.ts.map +1 -0
- package/dist/telemetry/console.js +87 -0
- package/dist/telemetry/console.js.map +1 -0
- package/dist/telemetry/dom.d.ts +21 -0
- package/dist/telemetry/dom.d.ts.map +1 -0
- package/dist/telemetry/dom.js +99 -0
- package/dist/telemetry/dom.js.map +1 -0
- package/dist/telemetry/network.d.ts +33 -0
- package/dist/telemetry/network.d.ts.map +1 -0
- package/dist/telemetry/network.js +191 -0
- package/dist/telemetry/network.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/ui/formatters/cookies.d.ts +32 -0
- package/dist/ui/formatters/cookies.d.ts.map +1 -0
- package/dist/ui/formatters/cookies.js +48 -0
- package/dist/ui/formatters/cookies.js.map +1 -0
- package/dist/ui/formatters/details.d.ts +10 -0
- package/dist/ui/formatters/details.d.ts.map +1 -0
- package/dist/ui/formatters/details.js +63 -0
- package/dist/ui/formatters/details.js.map +1 -0
- package/dist/ui/formatters/index.d.ts +10 -0
- package/dist/ui/formatters/index.d.ts.map +1 -0
- package/dist/ui/formatters/index.js +10 -0
- package/dist/ui/formatters/index.js.map +1 -0
- package/dist/ui/formatters/preview.d.ts +25 -0
- package/dist/ui/formatters/preview.d.ts.map +1 -0
- package/dist/ui/formatters/preview.js +177 -0
- package/dist/ui/formatters/preview.js.map +1 -0
- package/dist/ui/formatters/status.d.ts +39 -0
- package/dist/ui/formatters/status.d.ts.map +1 -0
- package/dist/ui/formatters/status.js +153 -0
- package/dist/ui/formatters/status.js.map +1 -0
- package/dist/ui/formatting.d.ts +197 -0
- package/dist/ui/formatting.d.ts.map +1 -0
- package/dist/ui/formatting.js +318 -0
- package/dist/ui/formatting.js.map +1 -0
- package/dist/ui/messages/chrome.d.ts +102 -0
- package/dist/ui/messages/chrome.d.ts.map +1 -0
- package/dist/ui/messages/chrome.js +162 -0
- package/dist/ui/messages/chrome.js.map +1 -0
- package/dist/ui/messages/commands.d.ts +88 -0
- package/dist/ui/messages/commands.d.ts.map +1 -0
- package/dist/ui/messages/commands.js +150 -0
- package/dist/ui/messages/commands.js.map +1 -0
- package/dist/ui/messages/consoleMessages.d.ts +39 -0
- package/dist/ui/messages/consoleMessages.d.ts.map +1 -0
- package/dist/ui/messages/consoleMessages.js +48 -0
- package/dist/ui/messages/consoleMessages.js.map +1 -0
- package/dist/ui/messages/debug.d.ts +180 -0
- package/dist/ui/messages/debug.d.ts.map +1 -0
- package/dist/ui/messages/debug.js +241 -0
- package/dist/ui/messages/debug.js.map +1 -0
- package/dist/ui/messages/errors.d.ts +80 -0
- package/dist/ui/messages/errors.d.ts.map +1 -0
- package/dist/ui/messages/errors.js +122 -0
- package/dist/ui/messages/errors.js.map +1 -0
- package/dist/ui/messages/index.d.ts +12 -0
- package/dist/ui/messages/index.d.ts.map +1 -0
- package/dist/ui/messages/index.js +12 -0
- package/dist/ui/messages/index.js.map +1 -0
- package/dist/ui/messages/internal.d.ts +30 -0
- package/dist/ui/messages/internal.d.ts.map +1 -0
- package/dist/ui/messages/internal.js +42 -0
- package/dist/ui/messages/internal.js.map +1 -0
- package/dist/ui/messages/preview.d.ts +27 -0
- package/dist/ui/messages/preview.d.ts.map +1 -0
- package/dist/ui/messages/preview.js +45 -0
- package/dist/ui/messages/preview.js.map +1 -0
- package/dist/ui/messages/session.d.ts +54 -0
- package/dist/ui/messages/session.d.ts.map +1 -0
- package/dist/ui/messages/session.js +77 -0
- package/dist/ui/messages/session.js.map +1 -0
- package/dist/ui/messages/validation.d.ts +20 -0
- package/dist/ui/messages/validation.d.ts.map +1 -0
- package/dist/ui/messages/validation.js +22 -0
- package/dist/ui/messages/validation.js.map +1 -0
- package/dist/utils/__tests__/filters.unit.test.js +1 -1
- package/dist/utils/cdpHandlers.d.ts +1 -1
- package/dist/utils/cdpHandlers.js +1 -1
- package/dist/utils/chromeDiagnostics.d.ts +0 -12
- package/dist/utils/chromeDiagnostics.d.ts.map +1 -1
- package/dist/utils/chromeDiagnostics.js +0 -51
- package/dist/utils/chromeDiagnostics.js.map +1 -1
- package/dist/utils/http.d.ts +1 -1
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/logger.d.ts +68 -12
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +62 -12
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/pageReadiness.d.ts +51 -0
- package/dist/utils/pageReadiness.d.ts.map +1 -0
- package/dist/utils/pageReadiness.js +271 -0
- package/dist/utils/pageReadiness.js.map +1 -0
- package/dist/utils/ui.d.ts +36 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/ui.js +47 -0
- package/dist/utils/ui.js.map +1 -0
- package/dist/utils/url.d.ts +6 -24
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +6 -67
- package/dist/utils/url.js.map +1 -1
- package/package.json +2 -2
- package/dist/cli/collectors/dom.d.ts.map +0 -1
- package/dist/cli/collectors/dom.js +0 -361
- package/dist/cli/collectors/dom.js.map +0 -1
- package/dist/cli/collectors/helpers/domCache.d.ts.map +0 -1
- package/dist/cli/collectors/helpers/domCache.js.map +0 -1
- package/dist/cli/collectors/helpers/domQuery.d.ts.map +0 -1
- package/dist/cli/collectors/helpers/domQuery.js.map +0 -1
- package/dist/cli/collectors/helpers/selectorParser.d.ts.map +0 -1
- package/dist/cli/collectors/helpers/selectorParser.js.map +0 -1
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts +0 -2
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts.map +0 -1
- package/dist/cli/commands/__tests__/ipcTest.test.js +0 -37
- package/dist/cli/commands/__tests__/ipcTest.test.js.map +0 -1
- package/dist/cli/commands/ipcTest.d.ts +0 -23
- package/dist/cli/commands/ipcTest.d.ts.map +0 -1
- package/dist/cli/commands/ipcTest.js +0 -181
- package/dist/cli/commands/ipcTest.js.map +0 -1
- package/dist/cli/commands/query.d.ts.map +0 -1
- package/dist/cli/commands/query.js +0 -127
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/handlers/ChromeBootstrap.d.ts +0 -24
- package/dist/cli/handlers/ChromeBootstrap.d.ts.map +0 -1
- package/dist/cli/handlers/ChromeBootstrap.js +0 -50
- package/dist/cli/handlers/ChromeBootstrap.js.map +0 -1
- package/dist/cli/handlers/OutputWriter.d.ts +0 -15
- package/dist/cli/handlers/OutputWriter.d.ts.map +0 -1
- package/dist/cli/handlers/OutputWriter.js +0 -34
- package/dist/cli/handlers/OutputWriter.js.map +0 -1
- package/dist/cli/handlers/PreviewWriter.d.ts +0 -52
- package/dist/cli/handlers/PreviewWriter.d.ts.map +0 -1
- package/dist/cli/handlers/PreviewWriter.js +0 -119
- package/dist/cli/handlers/PreviewWriter.js.map +0 -1
- package/dist/cli/handlers/SessionLock.d.ts +0 -16
- package/dist/cli/handlers/SessionLock.d.ts.map +0 -1
- package/dist/cli/handlers/SessionLock.js +0 -38
- package/dist/cli/handlers/SessionLock.js.map +0 -1
- package/dist/cli/handlers/SessionLoop.d.ts +0 -19
- package/dist/cli/handlers/SessionLoop.d.ts.map +0 -1
- package/dist/cli/handlers/SessionLoop.js +0 -47
- package/dist/cli/handlers/SessionLoop.js.map +0 -1
- package/dist/cli/handlers/ShutdownController.d.ts +0 -38
- package/dist/cli/handlers/ShutdownController.d.ts.map +0 -1
- package/dist/cli/handlers/ShutdownController.js +0 -83
- package/dist/cli/handlers/ShutdownController.js.map +0 -1
- package/dist/cli/handlers/SignalHandler.d.ts +0 -35
- package/dist/cli/handlers/SignalHandler.d.ts.map +0 -1
- package/dist/cli/handlers/SignalHandler.js +0 -81
- package/dist/cli/handlers/SignalHandler.js.map +0 -1
- package/dist/cli/handlers/TargetSetup.d.ts +0 -42
- package/dist/cli/handlers/TargetSetup.d.ts.map +0 -1
- package/dist/cli/handlers/TargetSetup.js +0 -87
- package/dist/cli/handlers/TargetSetup.js.map +0 -1
- package/dist/connection/__tests__/tabs.contract.test.d.ts +0 -2
- package/dist/connection/__tests__/tabs.contract.test.d.ts.map +0 -1
- package/dist/connection/__tests__/tabs.contract.test.js +0 -137
- package/dist/connection/__tests__/tabs.contract.test.js.map +0 -1
- package/dist/connection/tabs.d.ts +0 -82
- package/dist/connection/tabs.d.ts.map +0 -1
- package/dist/connection/tabs.js +0 -577
- package/dist/connection/tabs.js.map +0 -1
- package/dist/session/BdgSession.d.ts +0 -129
- package/dist/session/BdgSession.d.ts.map +0 -1
- package/dist/session/BdgSession.js +0 -270
- package/dist/session/BdgSession.js.map +0 -1
- package/dist/session/index.d.ts +0 -15
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js +0 -23
- package/dist/session/index.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -12
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -20
- package/dist/utils/validation.js.map +0 -1
- /package/dist/cli/{collectors → commands}/dom.d.ts +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard options supported by CommandRunner.
|
|
3
|
+
* All commands that use CommandRunner must extend this interface.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseCommandOptions {
|
|
6
|
+
/** Output as JSON instead of human-readable format */
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Result from a command handler.
|
|
11
|
+
* Handler functions should return this structure to indicate success/failure.
|
|
12
|
+
*/
|
|
13
|
+
export interface CommandResult<T = unknown> {
|
|
14
|
+
/** Whether the command succeeded */
|
|
15
|
+
success: boolean;
|
|
16
|
+
/** Data to output (for successful commands) */
|
|
17
|
+
data?: T;
|
|
18
|
+
/** Error message (for failed commands) */
|
|
19
|
+
error?: string;
|
|
20
|
+
/** Optional exit code override (defaults: SUCCESS=0, error codes from EXIT_CODES) */
|
|
21
|
+
exitCode?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Handler function type.
|
|
25
|
+
* Command logic should be implemented as a function matching this signature.
|
|
26
|
+
*/
|
|
27
|
+
export type CommandHandler<TOptions extends BaseCommandOptions, TResult = unknown> = (options: TOptions) => Promise<CommandResult<TResult>>;
|
|
28
|
+
/**
|
|
29
|
+
* Formatter function type for human-readable output.
|
|
30
|
+
* Receives the command result data and outputs to console.
|
|
31
|
+
*/
|
|
32
|
+
export type CommandFormatter<TResult = unknown> = (data: TResult) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Run a command with consistent error handling, output formatting, and exit codes.
|
|
35
|
+
* Eliminates boilerplate try-catch and JSON output logic from command handlers.
|
|
36
|
+
*
|
|
37
|
+
* This helper:
|
|
38
|
+
* - Wraps command logic in try-catch
|
|
39
|
+
* - Handles IPC connection errors (ENOENT, ECONNREFUSED)
|
|
40
|
+
* - Formats output as JSON or human-readable based on --json flag
|
|
41
|
+
* - Calls process.exit() with appropriate exit code
|
|
42
|
+
*
|
|
43
|
+
* @param handler - Command logic that returns CommandResult or throws
|
|
44
|
+
* @param options - Command options (must include json flag)
|
|
45
|
+
* @param formatter - Optional human-readable formatter (if not provided, outputs raw JSON)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* await runCommand(
|
|
50
|
+
* async (opts) => {
|
|
51
|
+
* const data = await fetchData(opts.url);
|
|
52
|
+
* return { success: true, data };
|
|
53
|
+
* },
|
|
54
|
+
* options,
|
|
55
|
+
* formatData
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function runCommand<TOptions extends BaseCommandOptions, TResult = unknown>(handler: CommandHandler<TOptions, TResult>, options: TOptions, formatter?: CommandFormatter<TResult>): Promise<void>;
|
|
60
|
+
//# sourceMappingURL=CommandRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandRunner.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/CommandRunner.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,QAAQ,SAAS,kBAAkB,EAAE,OAAO,GAAG,OAAO,IAAI,CACnF,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,UAAU,CAAC,QAAQ,SAAS,kBAAkB,EAAE,OAAO,GAAG,OAAO,EACrF,OAAO,EAAE,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC1C,OAAO,EAAE,QAAQ,EACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { OutputBuilder } from '../../commands/shared/OutputBuilder.js';
|
|
2
|
+
import { daemonNotRunningError, unknownError, genericError } from '../../ui/messages/errors.js';
|
|
3
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
4
|
+
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
5
|
+
/**
|
|
6
|
+
* Run a command with consistent error handling, output formatting, and exit codes.
|
|
7
|
+
* Eliminates boilerplate try-catch and JSON output logic from command handlers.
|
|
8
|
+
*
|
|
9
|
+
* This helper:
|
|
10
|
+
* - Wraps command logic in try-catch
|
|
11
|
+
* - Handles IPC connection errors (ENOENT, ECONNREFUSED)
|
|
12
|
+
* - Formats output as JSON or human-readable based on --json flag
|
|
13
|
+
* - Calls process.exit() with appropriate exit code
|
|
14
|
+
*
|
|
15
|
+
* @param handler - Command logic that returns CommandResult or throws
|
|
16
|
+
* @param options - Command options (must include json flag)
|
|
17
|
+
* @param formatter - Optional human-readable formatter (if not provided, outputs raw JSON)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* await runCommand(
|
|
22
|
+
* async (opts) => {
|
|
23
|
+
* const data = await fetchData(opts.url);
|
|
24
|
+
* return { success: true, data };
|
|
25
|
+
* },
|
|
26
|
+
* options,
|
|
27
|
+
* formatData
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export async function runCommand(handler, options, formatter) {
|
|
32
|
+
try {
|
|
33
|
+
const result = await handler(options);
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
// Error result from handler
|
|
36
|
+
if (options.json) {
|
|
37
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(result.error ?? 'Unknown error'), null, 2));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.error(result.error ? genericError(result.error) : unknownError());
|
|
41
|
+
}
|
|
42
|
+
process.exit(result.exitCode ?? EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
43
|
+
}
|
|
44
|
+
// Success - output data
|
|
45
|
+
if (options.json) {
|
|
46
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
47
|
+
}
|
|
48
|
+
else if (formatter) {
|
|
49
|
+
formatter(result.data);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Fallback: JSON output if no formatter provided
|
|
53
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
54
|
+
}
|
|
55
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const errorMessage = getErrorMessage(error);
|
|
59
|
+
// Detect daemon connection errors
|
|
60
|
+
if (errorMessage.includes('ENOENT') || errorMessage.includes('ECONNREFUSED')) {
|
|
61
|
+
if (options.json) {
|
|
62
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError('Daemon not running', {
|
|
63
|
+
suggestion: 'Start it with: bdg <url>',
|
|
64
|
+
}), null, 2));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.error(daemonNotRunningError());
|
|
68
|
+
}
|
|
69
|
+
process.exit(EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
70
|
+
}
|
|
71
|
+
// Generic error
|
|
72
|
+
if (options.json) {
|
|
73
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMessage), null, 2));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
console.error(genericError(errorMessage));
|
|
77
|
+
}
|
|
78
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=CommandRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandRunner.js","sourceRoot":"","sources":["../../../src/commands/shared/CommandRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,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ACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAE5C,kCAAkC;QAClC,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC7E,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE;oBACjD,UAAU,EAAE,0BAA0B;iBACvC,CAAC,EACF,IAAI,EACJ,CAAC,CACF,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAC9C,CAAC;QAED,gBAAgB;QAChB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BdgOutput, CDPTarget, NetworkRequest, ConsoleMessage, DOMData, TelemetryType } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Output mode determines what data is included and how partial flag is set
|
|
4
|
+
*/
|
|
5
|
+
export type OutputMode = 'preview' | 'full' | 'final';
|
|
6
|
+
/**
|
|
7
|
+
* Options for building output payloads
|
|
8
|
+
*/
|
|
9
|
+
export interface OutputBuilderOptions {
|
|
10
|
+
mode: OutputMode;
|
|
11
|
+
target: CDPTarget;
|
|
12
|
+
startTime: number;
|
|
13
|
+
networkRequests: NetworkRequest[];
|
|
14
|
+
consoleLogs: ConsoleMessage[];
|
|
15
|
+
domData?: DOMData;
|
|
16
|
+
activeTelemetry: TelemetryType[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper: build output payloads for different modes with consistent metadata.
|
|
20
|
+
* Modes: preview (metadata only), full (with bodies), final (complete with DOM).
|
|
21
|
+
*/
|
|
22
|
+
export declare class OutputBuilder {
|
|
23
|
+
/**
|
|
24
|
+
* Build session output with consistent metadata.
|
|
25
|
+
*
|
|
26
|
+
* @param options - Configuration for output construction
|
|
27
|
+
* @returns BdgOutput payload
|
|
28
|
+
*/
|
|
29
|
+
static build(options: OutputBuilderOptions): BdgOutput;
|
|
30
|
+
/**
|
|
31
|
+
* Build error output with consistent structure.
|
|
32
|
+
*
|
|
33
|
+
* @param error - Error object or string
|
|
34
|
+
* @param startTime - Session start timestamp
|
|
35
|
+
* @param target - Optional target information
|
|
36
|
+
* @returns BdgOutput payload with error
|
|
37
|
+
*/
|
|
38
|
+
static buildError(error: unknown, startTime: number, target?: CDPTarget): BdgOutput;
|
|
39
|
+
/**
|
|
40
|
+
* Build a simple JSON error response for commands.
|
|
41
|
+
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
42
|
+
*
|
|
43
|
+
* @param error - Error message or Error object
|
|
44
|
+
* @param options - Optional fields (exitCode, additional data)
|
|
45
|
+
* @returns JSON-serializable error object
|
|
46
|
+
*/
|
|
47
|
+
static buildJsonError(error: string | Error, options?: {
|
|
48
|
+
exitCode?: number;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}): Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Build a simple JSON success response for commands.
|
|
53
|
+
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
54
|
+
*
|
|
55
|
+
* @param data - Response data
|
|
56
|
+
* @returns JSON-serializable success object
|
|
57
|
+
*/
|
|
58
|
+
static buildJsonSuccess(data: Record<string, unknown>): Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=OutputBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutputBuilder.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/OutputBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,cAAc,EACd,OAAO,EACP,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,aAAa,EAAE,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS;IA4FtD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAYnF;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CACnB,KAAK,EAAE,MAAM,GAAG,KAAK,EACrB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACtD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAS1B;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOhF"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
2
|
+
import { VERSION } from '../../utils/version.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helper: build output payloads for different modes with consistent metadata.
|
|
5
|
+
* Modes: preview (metadata only), full (with bodies), final (complete with DOM).
|
|
6
|
+
*/
|
|
7
|
+
export class OutputBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Build session output with consistent metadata.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Configuration for output construction
|
|
12
|
+
* @returns BdgOutput payload
|
|
13
|
+
*/
|
|
14
|
+
static build(options) {
|
|
15
|
+
const { mode, target, startTime, networkRequests, consoleLogs, domData, activeTelemetry } = options;
|
|
16
|
+
const baseOutput = {
|
|
17
|
+
version: VERSION,
|
|
18
|
+
success: true,
|
|
19
|
+
timestamp: new Date().toISOString(),
|
|
20
|
+
duration: Date.now() - startTime,
|
|
21
|
+
target: {
|
|
22
|
+
url: target.url,
|
|
23
|
+
title: target.title,
|
|
24
|
+
},
|
|
25
|
+
// Only final outputs are complete (partial=false)
|
|
26
|
+
partial: mode !== 'final',
|
|
27
|
+
};
|
|
28
|
+
if (mode === 'preview') {
|
|
29
|
+
// Lightweight preview: metadata only, last 1000 items
|
|
30
|
+
const previewData = {};
|
|
31
|
+
if (activeTelemetry.includes('network')) {
|
|
32
|
+
previewData['network'] = networkRequests.slice(-1000).map((req) => ({
|
|
33
|
+
requestId: req.requestId,
|
|
34
|
+
url: req.url,
|
|
35
|
+
method: req.method,
|
|
36
|
+
timestamp: req.timestamp,
|
|
37
|
+
status: req.status,
|
|
38
|
+
mimeType: req.mimeType,
|
|
39
|
+
// Exclude requestBody, responseBody, headers for lightweight preview
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
if (activeTelemetry.includes('console')) {
|
|
43
|
+
previewData['console'] = consoleLogs.slice(-1000).map((msg) => ({
|
|
44
|
+
type: msg.type,
|
|
45
|
+
text: msg.text,
|
|
46
|
+
timestamp: msg.timestamp,
|
|
47
|
+
// Exclude args for lightweight preview
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
// DOM omitted in preview (only captured on stop)
|
|
51
|
+
return {
|
|
52
|
+
...baseOutput,
|
|
53
|
+
data: previewData,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (mode === 'full') {
|
|
57
|
+
// Full mode: complete data with bodies
|
|
58
|
+
const fullData = {};
|
|
59
|
+
if (activeTelemetry.includes('network')) {
|
|
60
|
+
fullData['network'] = networkRequests; // All data with bodies
|
|
61
|
+
}
|
|
62
|
+
if (activeTelemetry.includes('console')) {
|
|
63
|
+
fullData['console'] = consoleLogs; // All data with args
|
|
64
|
+
}
|
|
65
|
+
// DOM omitted (only captured on stop)
|
|
66
|
+
return {
|
|
67
|
+
...baseOutput,
|
|
68
|
+
data: fullData,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Final mode - includes DOM, partial=false
|
|
72
|
+
const finalData = {};
|
|
73
|
+
if (activeTelemetry.includes('network')) {
|
|
74
|
+
finalData['network'] = networkRequests;
|
|
75
|
+
}
|
|
76
|
+
if (activeTelemetry.includes('console')) {
|
|
77
|
+
finalData['console'] = consoleLogs;
|
|
78
|
+
}
|
|
79
|
+
if (activeTelemetry.includes('dom') && domData) {
|
|
80
|
+
finalData['dom'] = domData;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...baseOutput,
|
|
84
|
+
partial: false,
|
|
85
|
+
data: finalData,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Build error output with consistent structure.
|
|
90
|
+
*
|
|
91
|
+
* @param error - Error object or string
|
|
92
|
+
* @param startTime - Session start timestamp
|
|
93
|
+
* @param target - Optional target information
|
|
94
|
+
* @returns BdgOutput payload with error
|
|
95
|
+
*/
|
|
96
|
+
static buildError(error, startTime, target) {
|
|
97
|
+
return {
|
|
98
|
+
version: VERSION,
|
|
99
|
+
success: false,
|
|
100
|
+
timestamp: new Date().toISOString(),
|
|
101
|
+
duration: Date.now() - startTime,
|
|
102
|
+
target: target ? { url: target.url, title: target.title } : { url: '', title: '' },
|
|
103
|
+
data: {},
|
|
104
|
+
error: getErrorMessage(error),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Build a simple JSON error response for commands.
|
|
109
|
+
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
110
|
+
*
|
|
111
|
+
* @param error - Error message or Error object
|
|
112
|
+
* @param options - Optional fields (exitCode, additional data)
|
|
113
|
+
* @returns JSON-serializable error object
|
|
114
|
+
*/
|
|
115
|
+
static buildJsonError(error, options) {
|
|
116
|
+
return {
|
|
117
|
+
version: VERSION,
|
|
118
|
+
success: false,
|
|
119
|
+
error: error instanceof Error ? error.message : error,
|
|
120
|
+
...options,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Build a simple JSON success response for commands.
|
|
125
|
+
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
126
|
+
*
|
|
127
|
+
* @param data - Response data
|
|
128
|
+
* @returns JSON-serializable success object
|
|
129
|
+
*/
|
|
130
|
+
static buildJsonSuccess(data) {
|
|
131
|
+
return {
|
|
132
|
+
version: VERSION,
|
|
133
|
+
success: true,
|
|
134
|
+
...data,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=OutputBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutputBuilder.js","sourceRoot":"","sources":["../../../src/commands/shared/OutputBuilder.ts"],"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|
|
3
|
+
* Shared --json flag for all commands that support JSON output.
|
|
4
|
+
* Standard option for machine-readable output.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* program
|
|
9
|
+
* .command('status')
|
|
10
|
+
* .addOption(jsonOption)
|
|
11
|
+
* .action((options) => {
|
|
12
|
+
* if (options.json) {
|
|
13
|
+
* console.log(JSON.stringify(data));
|
|
14
|
+
* }
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const jsonOption: Option;
|
|
19
|
+
/**
|
|
20
|
+
* Shared --last <n> option for pagination.
|
|
21
|
+
* Includes built-in validation for sensible limits.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* program
|
|
26
|
+
* .command('console')
|
|
27
|
+
* .addOption(lastOption)
|
|
28
|
+
* .action((options) => {
|
|
29
|
+
* const logs = allLogs.slice(-options.last);
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const lastOption: Option;
|
|
34
|
+
/**
|
|
35
|
+
* Create a --filter option with specified valid choices.
|
|
36
|
+
* Includes built-in validation using Commander's .choices() method.
|
|
37
|
+
*
|
|
38
|
+
* @param validTypes - Array of valid filter values
|
|
39
|
+
* @returns Commander Option instance
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* program
|
|
44
|
+
* .command('console')
|
|
45
|
+
* .addOption(filterOption(['log', 'error', 'warning', 'info']))
|
|
46
|
+
* .action((options) => {
|
|
47
|
+
* if (options.filter) {
|
|
48
|
+
* filtered = logs.filter(log => log.type === options.filter);
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function filterOption(validTypes: string[]): Option;
|
|
54
|
+
//# sourceMappingURL=commonOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonOptions.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/commonOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,QAA6C,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,QAQnB,CAAC;AAEL;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAIzD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Shared --json flag for all commands that support JSON output.
|
|
4
|
+
* Standard option for machine-readable output.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* program
|
|
9
|
+
* .command('status')
|
|
10
|
+
* .addOption(jsonOption)
|
|
11
|
+
* .action((options) => {
|
|
12
|
+
* if (options.json) {
|
|
13
|
+
* console.log(JSON.stringify(data));
|
|
14
|
+
* }
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const jsonOption = new Option('-j, --json', 'Output as JSON');
|
|
19
|
+
/**
|
|
20
|
+
* Shared --last <n> option for pagination.
|
|
21
|
+
* Includes built-in validation for sensible limits.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* program
|
|
26
|
+
* .command('console')
|
|
27
|
+
* .addOption(lastOption)
|
|
28
|
+
* .action((options) => {
|
|
29
|
+
* const logs = allLogs.slice(-options.last);
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const lastOption = new Option('--last <n>', 'Show last N items')
|
|
34
|
+
.default(0)
|
|
35
|
+
.argParser((val) => {
|
|
36
|
+
const n = parseInt(val, 10);
|
|
37
|
+
if (isNaN(n) || n < 0 || n > 10000) {
|
|
38
|
+
throw new Error('--last must be between 0 and 10000');
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Create a --filter option with specified valid choices.
|
|
44
|
+
* Includes built-in validation using Commander's .choices() method.
|
|
45
|
+
*
|
|
46
|
+
* @param validTypes - Array of valid filter values
|
|
47
|
+
* @returns Commander Option instance
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* program
|
|
52
|
+
* .command('console')
|
|
53
|
+
* .addOption(filterOption(['log', 'error', 'warning', 'info']))
|
|
54
|
+
* .action((options) => {
|
|
55
|
+
* if (options.filter) {
|
|
56
|
+
* filtered = logs.filter(log => log.type === options.filter);
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function filterOption(validTypes) {
|
|
62
|
+
return new Option('--filter <type>', `Filter by type (${validTypes.join(', ')})`).choices(validTypes);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=commonOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonOptions.js","sourceRoot":"","sources":["../../../src/commands/shared/commonOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC;KACpE,OAAO,CAAC,CAAC,CAAC;KACV,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5B,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC,CAAC;AAEL;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,YAAY,CAAC,UAAoB;IAC/C,OAAO,IAAI,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CACvF,UAAU,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TelemetryType } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Start a session via the daemon using IPC.
|
|
4
|
+
*
|
|
5
|
+
* This replaces the in-process sessionController.startSession() by:
|
|
6
|
+
* 1. Sending a start_session_request to the daemon
|
|
7
|
+
* 2. Waiting for the worker to launch and report readiness
|
|
8
|
+
* 3. Outputting metadata about the running session
|
|
9
|
+
* 4. Keeping the process alive while the session runs
|
|
10
|
+
*
|
|
11
|
+
* @param url - Target URL to navigate to
|
|
12
|
+
* @param options - Session configuration options
|
|
13
|
+
* @param telemetry - Array of telemetry types to enable
|
|
14
|
+
*/
|
|
15
|
+
export declare function startSessionViaDaemon(url: string, options: {
|
|
16
|
+
port: number;
|
|
17
|
+
timeout: number | undefined;
|
|
18
|
+
userDataDir: string | undefined;
|
|
19
|
+
includeAll: boolean;
|
|
20
|
+
maxBodySize: number | undefined;
|
|
21
|
+
compact: boolean;
|
|
22
|
+
}, telemetry: TelemetryType[]): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=daemonSessionController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonSessionController.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/daemonSessionController.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAahD;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;CAClB,EACD,SAAS,EAAE,aAAa,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CAiEf"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { landingPage } from '../../commands/shared/landingPage.js';
|
|
2
|
+
import { startSession as sendStartSessionRequest } from '../../ipc/client.js';
|
|
3
|
+
import { IPCErrorCode } from '../../ipc/types.js';
|
|
4
|
+
import { sessionAlreadyRunningError, daemonConnectionFailedError, invalidResponseError, genericError, } from '../../ui/messages/errors.js';
|
|
5
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
6
|
+
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
7
|
+
import { createLogger } from '../../utils/logger.js';
|
|
8
|
+
const log = createLogger('bdg');
|
|
9
|
+
/**
|
|
10
|
+
* Start a session via the daemon using IPC.
|
|
11
|
+
*
|
|
12
|
+
* This replaces the in-process sessionController.startSession() by:
|
|
13
|
+
* 1. Sending a start_session_request to the daemon
|
|
14
|
+
* 2. Waiting for the worker to launch and report readiness
|
|
15
|
+
* 3. Outputting metadata about the running session
|
|
16
|
+
* 4. Keeping the process alive while the session runs
|
|
17
|
+
*
|
|
18
|
+
* @param url - Target URL to navigate to
|
|
19
|
+
* @param options - Session configuration options
|
|
20
|
+
* @param telemetry - Array of telemetry types to enable
|
|
21
|
+
*/
|
|
22
|
+
export async function startSessionViaDaemon(url, options, telemetry) {
|
|
23
|
+
try {
|
|
24
|
+
log.debug('Connecting to daemon...');
|
|
25
|
+
// Send start_session_request to daemon
|
|
26
|
+
const requestOptions = {};
|
|
27
|
+
if (options.port !== undefined)
|
|
28
|
+
requestOptions.port = options.port;
|
|
29
|
+
if (options.timeout !== undefined)
|
|
30
|
+
requestOptions.timeout = options.timeout;
|
|
31
|
+
if (telemetry.length > 0)
|
|
32
|
+
requestOptions.telemetry = telemetry;
|
|
33
|
+
if (options.includeAll !== undefined)
|
|
34
|
+
requestOptions.includeAll = options.includeAll;
|
|
35
|
+
if (options.userDataDir !== undefined)
|
|
36
|
+
requestOptions.userDataDir = options.userDataDir;
|
|
37
|
+
if (options.maxBodySize !== undefined)
|
|
38
|
+
requestOptions.maxBodySize = options.maxBodySize;
|
|
39
|
+
const response = await sendStartSessionRequest(url, requestOptions);
|
|
40
|
+
// Check for errors
|
|
41
|
+
if (response.status === 'error') {
|
|
42
|
+
// Special handling for SESSION_ALREADY_RUNNING with helpful context
|
|
43
|
+
if (response.errorCode === IPCErrorCode.SESSION_ALREADY_RUNNING && response.existingSession) {
|
|
44
|
+
const { pid, targetUrl, duration } = response.existingSession;
|
|
45
|
+
const durationMs = duration ? duration * 1000 : 0;
|
|
46
|
+
console.error(sessionAlreadyRunningError(pid, durationMs, targetUrl));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.error(genericError(`Daemon error: ${response.message ?? 'Unknown error'}`));
|
|
50
|
+
}
|
|
51
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
52
|
+
}
|
|
53
|
+
// Extract metadata from response
|
|
54
|
+
const { data } = response;
|
|
55
|
+
if (!data) {
|
|
56
|
+
console.error(invalidResponseError('missing data'));
|
|
57
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
58
|
+
}
|
|
59
|
+
// Display landing page with session information
|
|
60
|
+
const landing = landingPage({
|
|
61
|
+
url: data.targetUrl,
|
|
62
|
+
});
|
|
63
|
+
console.error(landing);
|
|
64
|
+
// Session runs in background worker - CLI exits immediately
|
|
65
|
+
// This allows user to run other commands in the same terminal
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
// Handle connection errors
|
|
70
|
+
const errorMessage = getErrorMessage(error);
|
|
71
|
+
if (errorMessage.includes('ENOENT') || errorMessage.includes('ECONNREFUSED')) {
|
|
72
|
+
console.error(daemonConnectionFailedError());
|
|
73
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
74
|
+
}
|
|
75
|
+
console.error(genericError(errorMessage));
|
|
76
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=daemonSessionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonSessionController.js","sourceRoot":"","sources":["../../../src/commands/shared/daemonSessionController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,YAAY,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAEhC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAW,EACX,OAOC,EACD,SAA0B;IAE1B,IAAI,CAAC;QACH,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAErC,uCA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message from \@/ui/messages.
|
|
5
|
+
* All message formatting is now centralized in the UI layer.
|
|
6
|
+
*/
|
|
7
|
+
export { landingPage, type LandingPageOptions } from '../../ui/messages/session.js';
|
|
8
|
+
//# sourceMappingURL=landingPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landingPage.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/landingPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Landing page display for session start.
|
|
3
|
+
*
|
|
4
|
+
* This handler re-exports the centralized landing page message from \@/ui/messages.
|
|
5
|
+
* All message formatting is now centralized in the UI layer.
|
|
6
|
+
*/
|
|
7
|
+
export { landingPage } from '../../ui/messages/session.js';
|
|
8
|
+
//# sourceMappingURL=landingPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landingPage.js","sourceRoot":"","sources":["../../../src/commands/shared/landingPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAA2B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggressively cleanup stale Chrome processes launched by bdg.
|
|
3
|
+
*
|
|
4
|
+
* This function kills Chrome instances that were launched by bdg by:
|
|
5
|
+
* 1. Reading the Chrome PID from persistent cache (~/.bdg/chrome.pid)
|
|
6
|
+
* 2. Killing that specific Chrome process using cross-platform kill logic
|
|
7
|
+
*
|
|
8
|
+
* The cache survives session cleanup, so this works even after a normal session end.
|
|
9
|
+
*
|
|
10
|
+
* Cross-platform killing:
|
|
11
|
+
* - Windows: Uses `taskkill /pid <pid> /T /F` to kill process tree
|
|
12
|
+
* - Unix/macOS: Uses `process.kill(-pid, 'SIGKILL')` to kill process group
|
|
13
|
+
*
|
|
14
|
+
* Note: We can't use chromeLauncher.killAll() because it only tracks instances
|
|
15
|
+
* created via chromeLauncher.launch(), but we use new chromeLauncher.Launcher()
|
|
16
|
+
* which doesn't register in that tracking set.
|
|
17
|
+
*
|
|
18
|
+
* @returns Number of errors encountered during cleanup
|
|
19
|
+
*/
|
|
20
|
+
export declare function cleanupStaleChrome(): Promise<number>;
|
|
21
|
+
//# sourceMappingURL=sessionController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionController.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/sessionController.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAuC1D"}
|