browser-debugger-cli 0.1.0 → 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/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 +1 -1
- 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,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse argument as either CSS selector or index
|
|
3
|
+
*
|
|
4
|
+
* @param arg - Argument to parse (e.g., ".error" or "1")
|
|
5
|
+
* @returns Parsed result indicating type and value
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* parseSelectorOrIndex(".error") // \{ type: 'selector', value: '.error' \}
|
|
9
|
+
* parseSelectorOrIndex("1") // \{ type: 'index', value: 1 \}
|
|
10
|
+
* parseSelectorOrIndex("42") // \{ type: 'index', value: 42 \}
|
|
11
|
+
*/
|
|
12
|
+
export function parseSelectorOrIndex(arg) {
|
|
13
|
+
// If arg is a positive integer, treat as index
|
|
14
|
+
if (/^\d+$/.test(arg)) {
|
|
15
|
+
return { type: 'index', value: parseInt(arg, 10) };
|
|
16
|
+
}
|
|
17
|
+
// Otherwise treat as CSS selector
|
|
18
|
+
return { type: 'selector', value: arg };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=domSelectorParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domSelectorParser.js","sourceRoot":"","sources":["../../src/commands/domSelectorParser.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,+CAA+C;IAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,kCAAkC;IAClC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Register network commands.
|
|
4
|
+
*
|
|
5
|
+
* @param program - Commander.js Command instance to register commands on
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerNetworkCommands(program: Command): void;
|
|
8
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/commands/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBzC;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuC9D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { runCommand } from '../commands/shared/CommandRunner.js';
|
|
2
|
+
import { jsonOption } from '../commands/shared/commonOptions.js';
|
|
3
|
+
import { callCDP } from '../ipc/client.js';
|
|
4
|
+
import { validateIPCResponse } from '../ipc/responseValidator.js';
|
|
5
|
+
import { formatCookies } from '../ui/formatters/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Register network commands.
|
|
8
|
+
*
|
|
9
|
+
* @param program - Commander.js Command instance to register commands on
|
|
10
|
+
*/
|
|
11
|
+
export function registerNetworkCommands(program) {
|
|
12
|
+
const networkCmd = program.command('network').description('Inspect network state and resources');
|
|
13
|
+
// bdg network getCookies
|
|
14
|
+
networkCmd
|
|
15
|
+
.command('getCookies')
|
|
16
|
+
.description('List cookies from the current page')
|
|
17
|
+
.option('--url <url>', 'Filter cookies by URL')
|
|
18
|
+
.addOption(jsonOption)
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
await runCommand(async (opts) => {
|
|
21
|
+
// Build CDP method parameters
|
|
22
|
+
const params = {};
|
|
23
|
+
if (opts.url) {
|
|
24
|
+
params['urls'] = [opts.url];
|
|
25
|
+
}
|
|
26
|
+
// Call CDP Network.getCookies
|
|
27
|
+
const response = await callCDP('Network.getCookies', params);
|
|
28
|
+
// Validate IPC response (throws on error)
|
|
29
|
+
validateIPCResponse(response);
|
|
30
|
+
// Extract cookies from CDP response
|
|
31
|
+
const cookies = response.data?.result?.cookies ?? [];
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
data: cookies,
|
|
35
|
+
};
|
|
36
|
+
}, options,
|
|
37
|
+
// Human-readable formatter (returns formatted string)
|
|
38
|
+
(cookies) => {
|
|
39
|
+
console.log(formatCookies(cookies));
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/commands/network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,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AAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Register peek command.
|
|
4
|
+
*
|
|
5
|
+
* @param program - Commander.js Command instance to register commands on
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerPeekCommand(program: Command): void;
|
|
8
|
+
//# sourceMappingURL=peek.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peek.d.ts","sourceRoot":"","sources":["../../src/commands/peek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+BzC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoG1D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { OutputBuilder } from '../commands/shared/OutputBuilder.js';
|
|
2
|
+
import { jsonOption } from '../commands/shared/commonOptions.js';
|
|
3
|
+
import { getPeek } from '../ipc/client.js';
|
|
4
|
+
import { validateIPCResponse } from '../ipc/responseValidator.js';
|
|
5
|
+
import { formatPreview } from '../ui/formatters/preview.js';
|
|
6
|
+
import { invalidLastArgumentError } from '../ui/messages/commands.js';
|
|
7
|
+
import { daemonNotRunningError, noPreviewDataError } from '../ui/messages/errors.js';
|
|
8
|
+
import { EXIT_CODES } from '../utils/exitCodes.js';
|
|
9
|
+
/**
|
|
10
|
+
* Handle errors in a consistent way for both follow and one-time modes.
|
|
11
|
+
*
|
|
12
|
+
* @param error - Error message
|
|
13
|
+
* @param options - Preview options
|
|
14
|
+
* @param exitCode - Exit code to use if not in follow mode
|
|
15
|
+
*/
|
|
16
|
+
function handlePreviewError(error, options, exitCode) {
|
|
17
|
+
if (options.json) {
|
|
18
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(error), null, 2));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error(noPreviewDataError());
|
|
22
|
+
}
|
|
23
|
+
if (!options.follow) {
|
|
24
|
+
process.exit(exitCode);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Register peek command.
|
|
29
|
+
*
|
|
30
|
+
* @param program - Commander.js Command instance to register commands on
|
|
31
|
+
*/
|
|
32
|
+
export function registerPeekCommand(program) {
|
|
33
|
+
program
|
|
34
|
+
.command('peek')
|
|
35
|
+
.description('Preview collected data without stopping the session')
|
|
36
|
+
.addOption(jsonOption)
|
|
37
|
+
.option('-v, --verbose', 'Use verbose output with full URLs and formatting')
|
|
38
|
+
.option('-n, --network', 'Show only network requests')
|
|
39
|
+
.option('-c, --console', 'Show only console messages')
|
|
40
|
+
.option('-f, --follow', 'Watch for updates (like tail -f)')
|
|
41
|
+
.option('--last <count>', 'Show last N items', '10')
|
|
42
|
+
.action(async (options) => {
|
|
43
|
+
// Validate --last parameter
|
|
44
|
+
const lastN = parseInt(options.last ?? '10', 10);
|
|
45
|
+
if (isNaN(lastN) || lastN < 1 || lastN > 1000) {
|
|
46
|
+
console.error(invalidLastArgumentError(options.last));
|
|
47
|
+
process.exit(EXIT_CODES.INVALID_ARGUMENTS);
|
|
48
|
+
}
|
|
49
|
+
options.last = lastN.toString();
|
|
50
|
+
const showPreview = async () => {
|
|
51
|
+
try {
|
|
52
|
+
// Fetch preview data via IPC from daemon
|
|
53
|
+
const response = await getPeek();
|
|
54
|
+
// Validate IPC response (will throw on error)
|
|
55
|
+
try {
|
|
56
|
+
validateIPCResponse(response);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
handlePreviewError(response.error ?? 'Unknown error', options, EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// Extract preview data from response
|
|
63
|
+
const output = response.data?.preview;
|
|
64
|
+
if (!output) {
|
|
65
|
+
handlePreviewError('No preview data in response', options, EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Clear screen before rendering to prevent stacked outputs in follow mode
|
|
69
|
+
if (options.follow) {
|
|
70
|
+
console.clear();
|
|
71
|
+
}
|
|
72
|
+
// Add current view timestamp for follow mode to show refresh time
|
|
73
|
+
const previewOptions = options.follow
|
|
74
|
+
? { ...options, viewedAt: new Date() }
|
|
75
|
+
: options;
|
|
76
|
+
console.log(formatPreview(output, previewOptions));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Handle IPC connection errors (daemon not running, etc.)
|
|
80
|
+
// Note: validateIPCResponse errors are caught above
|
|
81
|
+
if (options.json) {
|
|
82
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError('Daemon not running', {
|
|
83
|
+
suggestion: 'Start it with: bdg <url>',
|
|
84
|
+
}), null, 2));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
console.error(daemonNotRunningError());
|
|
88
|
+
}
|
|
89
|
+
if (!options.follow) {
|
|
90
|
+
process.exit(EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (options.follow) {
|
|
95
|
+
// Follow mode: update every second
|
|
96
|
+
console.error('Following live preview (Ctrl+C to stop)...\n');
|
|
97
|
+
await showPreview();
|
|
98
|
+
const followInterval = setInterval(() => {
|
|
99
|
+
void showPreview();
|
|
100
|
+
}, 1000);
|
|
101
|
+
// Handle Ctrl+C gracefully
|
|
102
|
+
process.on('SIGINT', () => {
|
|
103
|
+
clearInterval(followInterval);
|
|
104
|
+
console.error('\nStopped following preview');
|
|
105
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// One-time preview
|
|
110
|
+
await showPreview();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=peek.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AC,CAAC;gBAC7C,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,mBAAmB;YACnB,MAAM,WAAW,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -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,CAAC;AAwClD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA0C,EAC1C,OAAiB,EACjB,SAAqC;IAErC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,4BAA4B;YAC5B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CACvF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,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,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"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAoB7C;;;GAGG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAA6B;QACxC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,GACvF,OAAO,CAAC;QAEV,MAAM,UAAU,GAAG;YACjB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAChC,MAAM,EAAE;gBACN,GAAG,EAAE,MAA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EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAClF,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;SAC9B,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CACnB,KAAqB,EACrB,OAAuD;QAEvD,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;YACrD,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAA6B;QACnD,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,IAAI;YACb,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 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"}
|