browser-debugger-cli 0.0.1-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +167 -52
- package/dist/__testfixtures__/cdpMessages.d.ts +43 -0
- package/dist/__testfixtures__/cdpMessages.d.ts.map +1 -0
- package/dist/__testfixtures__/cdpMessages.js +118 -0
- package/dist/__testfixtures__/cdpMessages.js.map +1 -0
- package/dist/__testfixtures__/connectionTargets.d.ts +21 -0
- package/dist/__testfixtures__/connectionTargets.d.ts.map +1 -0
- package/dist/__testfixtures__/connectionTargets.js +59 -0
- package/dist/__testfixtures__/connectionTargets.js.map +1 -0
- package/dist/__tests__/integration/session-files.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/session-files.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/session-files.integration.test.js +66 -0
- package/dist/__tests__/integration/session-files.integration.test.js.map +1 -0
- package/dist/__testutils__/FakeClock.d.ts +67 -0
- package/dist/__testutils__/FakeClock.d.ts.map +1 -0
- package/dist/__testutils__/FakeClock.js +132 -0
- package/dist/__testutils__/FakeClock.js.map +1 -0
- package/dist/__testutils__/FakeWebSocket.d.ts +106 -0
- package/dist/__testutils__/FakeWebSocket.d.ts.map +1 -0
- package/dist/__testutils__/FakeWebSocket.js +213 -0
- package/dist/__testutils__/FakeWebSocket.js.map +1 -0
- package/dist/__testutils__/assertions.d.ts +33 -0
- package/dist/__testutils__/assertions.d.ts.map +1 -0
- package/dist/__testutils__/assertions.js +57 -0
- package/dist/__testutils__/assertions.js.map +1 -0
- package/dist/__testutils__/index.d.ts +15 -0
- package/dist/__testutils__/index.d.ts.map +1 -0
- package/dist/__testutils__/index.js +15 -0
- package/dist/__testutils__/index.js.map +1 -0
- package/dist/__testutils__/testClock.d.ts +28 -0
- package/dist/__testutils__/testClock.d.ts.map +1 -0
- package/dist/__testutils__/testClock.js +81 -0
- package/dist/__testutils__/testClock.js.map +1 -0
- package/dist/__testutils__/testFixtures.d.ts +15 -0
- package/dist/__testutils__/testFixtures.d.ts.map +1 -0
- package/dist/__testutils__/testFixtures.js +23 -0
- package/dist/__testutils__/testFixtures.js.map +1 -0
- package/dist/__testutils__/testProcess.d.ts +46 -0
- package/dist/__testutils__/testProcess.d.ts.map +1 -0
- package/dist/__testutils__/testProcess.js +77 -0
- package/dist/__testutils__/testProcess.js.map +1 -0
- package/dist/cli/collectors/dom.d.ts +8 -0
- package/dist/cli/collectors/dom.d.ts.map +1 -0
- package/dist/cli/collectors/dom.js +361 -0
- package/dist/cli/collectors/dom.js.map +1 -0
- package/dist/cli/collectors/helpers/domCache.d.ts +40 -0
- package/dist/cli/collectors/helpers/domCache.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/domCache.js +79 -0
- package/dist/cli/collectors/helpers/domCache.js.map +1 -0
- package/dist/cli/collectors/helpers/domQuery.d.ts +45 -0
- package/dist/cli/collectors/helpers/domQuery.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/domQuery.js +100 -0
- package/dist/cli/collectors/helpers/domQuery.js.map +1 -0
- package/dist/cli/collectors/helpers/selectorParser.d.ts +20 -0
- package/dist/cli/collectors/helpers/selectorParser.d.ts.map +1 -0
- package/dist/cli/collectors/helpers/selectorParser.js +20 -0
- package/dist/cli/collectors/helpers/selectorParser.js.map +1 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.d.ts +24 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.js +467 -0
- package/dist/cli/commands/__tests__/cdp.contract.test.js.map +1 -0
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts +2 -0
- package/dist/cli/commands/__tests__/ipcTest.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/ipcTest.test.js +37 -0
- package/dist/cli/commands/__tests__/ipcTest.test.js.map +1 -0
- package/dist/cli/commands/cdp.d.ts +8 -0
- package/dist/cli/commands/cdp.d.ts.map +1 -0
- package/dist/cli/commands/cdp.js +45 -0
- package/dist/cli/commands/cdp.js.map +1 -0
- package/dist/cli/commands/cleanup.d.ts +8 -0
- package/dist/cli/commands/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/cleanup.js +130 -0
- package/dist/cli/commands/cleanup.js.map +1 -0
- package/dist/cli/commands/console.d.ts +8 -0
- package/dist/cli/commands/console.d.ts.map +1 -0
- package/dist/cli/commands/console.js +97 -0
- package/dist/cli/commands/console.js.map +1 -0
- package/dist/cli/commands/details.d.ts +8 -0
- package/dist/cli/commands/details.d.ts.map +1 -0
- package/dist/cli/commands/details.js +68 -0
- package/dist/cli/commands/details.js.map +1 -0
- package/dist/cli/commands/dom/helpers/domCache.d.ts +36 -0
- package/dist/cli/commands/dom/helpers/domCache.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/domCache.js +65 -0
- package/dist/cli/commands/dom/helpers/domCache.js.map +1 -0
- package/dist/cli/commands/dom/helpers/domQuery.d.ts +48 -0
- package/dist/cli/commands/dom/helpers/domQuery.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/domQuery.js +104 -0
- package/dist/cli/commands/dom/helpers/domQuery.js.map +1 -0
- package/dist/cli/commands/dom/helpers/errorHandler.d.ts +45 -0
- package/dist/cli/commands/dom/helpers/errorHandler.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/errorHandler.js +70 -0
- package/dist/cli/commands/dom/helpers/errorHandler.js.map +1 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.d.ts +52 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.js +75 -0
- package/dist/cli/commands/dom/helpers/evalHelpers.js.map +1 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts +35 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.js +51 -0
- package/dist/cli/commands/dom/helpers/optionsBuilder.js.map +1 -0
- package/dist/cli/commands/dom/helpers/selectorParser.d.ts +20 -0
- package/dist/cli/commands/dom/helpers/selectorParser.d.ts.map +1 -0
- package/dist/cli/commands/dom/helpers/selectorParser.js +20 -0
- package/dist/cli/commands/dom/helpers/selectorParser.js.map +1 -0
- package/dist/cli/commands/dom/index.d.ts +8 -0
- package/dist/cli/commands/dom/index.d.ts.map +1 -0
- package/dist/cli/commands/dom/index.js +257 -0
- package/dist/cli/commands/dom/index.js.map +1 -0
- package/dist/cli/commands/ipcTest.d.ts +23 -0
- package/dist/cli/commands/ipcTest.d.ts.map +1 -0
- package/dist/cli/commands/ipcTest.js +181 -0
- package/dist/cli/commands/ipcTest.js.map +1 -0
- package/dist/cli/commands/network.d.ts +8 -0
- package/dist/cli/commands/network.d.ts.map +1 -0
- package/dist/cli/commands/network.js +40 -0
- package/dist/cli/commands/network.js.map +1 -0
- package/dist/cli/commands/peek.d.ts +8 -0
- package/dist/cli/commands/peek.d.ts.map +1 -0
- package/dist/cli/commands/peek.js +109 -0
- package/dist/cli/commands/peek.js.map +1 -0
- package/dist/cli/commands/query.d.ts +9 -0
- package/dist/cli/commands/query.d.ts.map +1 -0
- package/dist/cli/commands/query.js +127 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/start.d.ts +9 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +78 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +9 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +84 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +8 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +146 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/formatters/detailsFormatter.d.ts +10 -0
- package/dist/cli/formatters/detailsFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/detailsFormatter.js +63 -0
- package/dist/cli/formatters/detailsFormatter.js.map +1 -0
- package/dist/cli/formatters/previewFormatter.d.ts +27 -0
- package/dist/cli/formatters/previewFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/previewFormatter.js +160 -0
- package/dist/cli/formatters/previewFormatter.js.map +1 -0
- package/dist/cli/formatters/statusFormatter.d.ts +34 -0
- package/dist/cli/formatters/statusFormatter.d.ts.map +1 -0
- package/dist/cli/formatters/statusFormatter.js +108 -0
- package/dist/cli/formatters/statusFormatter.js.map +1 -0
- package/dist/cli/handlers/ChromeBootstrap.d.ts +24 -0
- package/dist/cli/handlers/ChromeBootstrap.d.ts.map +1 -0
- package/dist/cli/handlers/ChromeBootstrap.js +50 -0
- package/dist/cli/handlers/ChromeBootstrap.js.map +1 -0
- package/dist/cli/handlers/CommandRunner.d.ts +60 -0
- package/dist/cli/handlers/CommandRunner.d.ts.map +1 -0
- package/dist/cli/handlers/CommandRunner.js +81 -0
- package/dist/cli/handlers/CommandRunner.js.map +1 -0
- package/dist/cli/handlers/OutputBuilder.d.ts +60 -0
- package/dist/cli/handlers/OutputBuilder.d.ts.map +1 -0
- package/dist/cli/handlers/OutputBuilder.js +138 -0
- package/dist/cli/handlers/OutputBuilder.js.map +1 -0
- package/dist/cli/handlers/OutputWriter.d.ts +15 -0
- package/dist/cli/handlers/OutputWriter.d.ts.map +1 -0
- package/dist/cli/handlers/OutputWriter.js +34 -0
- package/dist/cli/handlers/OutputWriter.js.map +1 -0
- package/dist/cli/handlers/PreviewWriter.d.ts +52 -0
- package/dist/cli/handlers/PreviewWriter.d.ts.map +1 -0
- package/dist/cli/handlers/PreviewWriter.js +119 -0
- package/dist/cli/handlers/PreviewWriter.js.map +1 -0
- package/dist/cli/handlers/SessionLock.d.ts +16 -0
- package/dist/cli/handlers/SessionLock.d.ts.map +1 -0
- package/dist/cli/handlers/SessionLock.js +38 -0
- package/dist/cli/handlers/SessionLock.js.map +1 -0
- package/dist/cli/handlers/SessionLoop.d.ts +19 -0
- package/dist/cli/handlers/SessionLoop.d.ts.map +1 -0
- package/dist/cli/handlers/SessionLoop.js +47 -0
- package/dist/cli/handlers/SessionLoop.js.map +1 -0
- package/dist/cli/handlers/ShutdownController.d.ts +38 -0
- package/dist/cli/handlers/ShutdownController.d.ts.map +1 -0
- package/dist/cli/handlers/ShutdownController.js +83 -0
- package/dist/cli/handlers/ShutdownController.js.map +1 -0
- package/dist/cli/handlers/SignalHandler.d.ts +35 -0
- package/dist/cli/handlers/SignalHandler.d.ts.map +1 -0
- package/dist/cli/handlers/SignalHandler.js +81 -0
- package/dist/cli/handlers/SignalHandler.js.map +1 -0
- package/dist/cli/handlers/TargetSetup.d.ts +42 -0
- package/dist/cli/handlers/TargetSetup.d.ts.map +1 -0
- package/dist/cli/handlers/TargetSetup.js +87 -0
- package/dist/cli/handlers/TargetSetup.js.map +1 -0
- package/dist/cli/handlers/commonOptions.d.ts +54 -0
- package/dist/cli/handlers/commonOptions.d.ts.map +1 -0
- package/dist/cli/handlers/commonOptions.js +64 -0
- package/dist/cli/handlers/commonOptions.js.map +1 -0
- package/dist/cli/handlers/daemonSessionController.d.ts +23 -0
- package/dist/cli/handlers/daemonSessionController.d.ts.map +1 -0
- package/dist/cli/handlers/daemonSessionController.js +108 -0
- package/dist/cli/handlers/daemonSessionController.js.map +1 -0
- package/dist/cli/handlers/sessionController.d.ts +21 -0
- package/dist/cli/handlers/sessionController.d.ts.map +1 -0
- package/dist/cli/handlers/sessionController.js +55 -0
- package/dist/cli/handlers/sessionController.js.map +1 -0
- package/dist/cli/registry.d.ts +11 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +46 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/collectors/__tests__/network.contract.test.d.ts +28 -0
- package/dist/collectors/__tests__/network.contract.test.d.ts.map +1 -0
- package/dist/collectors/__tests__/network.contract.test.js +525 -0
- package/dist/collectors/__tests__/network.contract.test.js.map +1 -0
- package/dist/collectors/console.d.ts +5 -3
- package/dist/collectors/console.d.ts.map +1 -1
- package/dist/collectors/console.js +48 -26
- package/dist/collectors/console.js.map +1 -1
- package/dist/collectors/dom.d.ts +2 -2
- package/dist/collectors/dom.d.ts.map +1 -1
- package/dist/collectors/dom.js +23 -12
- package/dist/collectors/dom.js.map +1 -1
- package/dist/collectors/network.d.ts +18 -4
- package/dist/collectors/network.d.ts.map +1 -1
- package/dist/collectors/network.js +111 -34
- package/dist/collectors/network.js.map +1 -1
- package/dist/connection/__tests__/cdp.contract.test.d.ts +16 -0
- package/dist/connection/__tests__/cdp.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/cdp.contract.test.js +378 -0
- package/dist/connection/__tests__/cdp.contract.test.js.map +1 -0
- package/dist/connection/__tests__/finder.contract.test.d.ts +2 -0
- package/dist/connection/__tests__/finder.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/finder.contract.test.js +239 -0
- package/dist/connection/__tests__/finder.contract.test.js.map +1 -0
- package/dist/connection/__tests__/tabs.contract.test.d.ts +2 -0
- package/dist/connection/__tests__/tabs.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/tabs.contract.test.js +137 -0
- package/dist/connection/__tests__/tabs.contract.test.js.map +1 -0
- package/dist/connection/cdp.d.ts +165 -16
- package/dist/connection/cdp.d.ts.map +1 -1
- package/dist/connection/cdp.js +342 -122
- package/dist/connection/cdp.js.map +1 -1
- package/dist/connection/finder.d.ts +5 -4
- package/dist/connection/finder.d.ts.map +1 -1
- package/dist/connection/finder.js +10 -16
- package/dist/connection/finder.js.map +1 -1
- package/dist/connection/launcher.d.ts +18 -11
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +148 -82
- package/dist/connection/launcher.js.map +1 -1
- package/dist/connection/tabs.d.ts +47 -14
- package/dist/connection/tabs.d.ts.map +1 -1
- package/dist/connection/tabs.js +493 -132
- package/dist/connection/tabs.js.map +1 -1
- package/dist/constants.d.ts +209 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +232 -0
- package/dist/constants.js.map +1 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.d.ts +23 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.js +401 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.js.map +1 -0
- package/dist/daemon/__tests__/launcher.unit.test.d.ts +8 -0
- package/dist/daemon/__tests__/launcher.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/launcher.unit.test.js +20 -0
- package/dist/daemon/__tests__/launcher.unit.test.js.map +1 -0
- package/dist/daemon/ipcServer.d.ts +83 -0
- package/dist/daemon/ipcServer.d.ts.map +1 -0
- package/dist/daemon/ipcServer.js +670 -0
- package/dist/daemon/ipcServer.js.map +1 -0
- package/dist/daemon/launcher.d.ts +31 -0
- package/dist/daemon/launcher.d.ts.map +1 -0
- package/dist/daemon/launcher.js +137 -0
- package/dist/daemon/launcher.js.map +1 -0
- package/dist/daemon/startSession.d.ts +51 -0
- package/dist/daemon/startSession.d.ts.map +1 -0
- package/dist/daemon/startSession.js +149 -0
- package/dist/daemon/startSession.js.map +1 -0
- package/dist/daemon/worker.d.ts +18 -0
- package/dist/daemon/worker.d.ts.map +1 -0
- package/dist/daemon/worker.js +623 -0
- package/dist/daemon/worker.js.map +1 -0
- package/dist/daemon/workerIpc.d.ts +33 -0
- package/dist/daemon/workerIpc.d.ts.map +1 -0
- package/dist/daemon/workerIpc.js +8 -0
- package/dist/daemon/workerIpc.js.map +1 -0
- package/dist/daemon.d.ts +10 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +32 -0
- package/dist/daemon.js.map +1 -0
- package/dist/index.js +41 -420
- package/dist/index.js.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.d.ts +23 -0
- package/dist/ipc/__tests__/client.contract.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/client.contract.test.js +466 -0
- package/dist/ipc/__tests__/client.contract.test.js.map +1 -0
- package/dist/ipc/client.d.ts +109 -0
- package/dist/ipc/client.d.ts.map +1 -0
- package/dist/ipc/client.js +220 -0
- package/dist/ipc/client.js.map +1 -0
- package/dist/ipc/commands.d.ts +208 -0
- package/dist/ipc/commands.d.ts.map +1 -0
- package/dist/ipc/commands.js +69 -0
- package/dist/ipc/commands.js.map +1 -0
- package/dist/ipc/responseValidator.d.ts +40 -0
- package/dist/ipc/responseValidator.d.ts.map +1 -0
- package/dist/ipc/responseValidator.js +28 -0
- package/dist/ipc/responseValidator.js.map +1 -0
- package/dist/ipc/types.d.ts +193 -0
- package/dist/ipc/types.d.ts.map +1 -0
- package/dist/ipc/types.js +21 -0
- package/dist/ipc/types.js.map +1 -0
- package/dist/session/BdgSession.d.ts +71 -4
- package/dist/session/BdgSession.d.ts.map +1 -1
- package/dist/session/BdgSession.js +173 -75
- package/dist/session/BdgSession.js.map +1 -1
- package/dist/session/chrome.d.ts +46 -0
- package/dist/session/chrome.d.ts.map +1 -0
- package/dist/session/chrome.js +92 -0
- package/dist/session/chrome.js.map +1 -0
- package/dist/session/cleanup.d.ts +45 -0
- package/dist/session/cleanup.d.ts.map +1 -0
- package/dist/session/cleanup.js +230 -0
- package/dist/session/cleanup.js.map +1 -0
- package/dist/session/index.d.ts +15 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +23 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/lock.d.ts +57 -0
- package/dist/session/lock.d.ts.map +1 -0
- package/dist/session/lock.js +154 -0
- package/dist/session/lock.js.map +1 -0
- package/dist/session/metadata.d.ts +59 -0
- package/dist/session/metadata.d.ts.map +1 -0
- package/dist/session/metadata.js +71 -0
- package/dist/session/metadata.js.map +1 -0
- package/dist/session/output.d.ts +18 -0
- package/dist/session/output.d.ts.map +1 -0
- package/dist/session/output.js +24 -0
- package/dist/session/output.js.map +1 -0
- package/dist/session/paths.d.ts +73 -0
- package/dist/session/paths.d.ts.map +1 -0
- package/dist/session/paths.js +84 -0
- package/dist/session/paths.js.map +1 -0
- package/dist/session/pid.d.ts +40 -0
- package/dist/session/pid.d.ts.map +1 -0
- package/dist/session/pid.js +73 -0
- package/dist/session/pid.js.map +1 -0
- package/dist/session/process.d.ts +45 -0
- package/dist/session/process.d.ts.map +1 -0
- package/dist/session/process.js +88 -0
- package/dist/session/process.js.map +1 -0
- package/dist/types.d.ts +114 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/__tests__/filters.unit.test.d.ts +2 -0
- package/dist/utils/__tests__/filters.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/filters.unit.test.js +239 -0
- package/dist/utils/__tests__/filters.unit.test.js.map +1 -0
- package/dist/utils/__tests__/session.contract.test.d.ts +2 -0
- package/dist/utils/__tests__/session.contract.test.d.ts.map +1 -0
- package/dist/utils/__tests__/session.contract.test.js +234 -0
- package/dist/utils/__tests__/session.contract.test.js.map +1 -0
- package/dist/utils/atomicFile.d.ts +38 -0
- package/dist/utils/atomicFile.d.ts.map +1 -0
- package/dist/utils/atomicFile.js +71 -0
- package/dist/utils/atomicFile.js.map +1 -0
- package/dist/utils/cdpHandlers.d.ts +31 -0
- package/dist/utils/cdpHandlers.d.ts.map +1 -0
- package/dist/utils/cdpHandlers.js +38 -0
- package/dist/utils/cdpHandlers.js.map +1 -0
- package/dist/utils/chromeDiagnostics.d.ts +28 -0
- package/dist/utils/chromeDiagnostics.d.ts.map +1 -0
- package/dist/utils/chromeDiagnostics.js +88 -0
- package/dist/utils/chromeDiagnostics.js.map +1 -0
- package/dist/utils/errors.d.ts +82 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +88 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exitCodes.d.ts +32 -0
- package/dist/utils/exitCodes.d.ts.map +1 -0
- package/dist/utils/exitCodes.js +36 -0
- package/dist/utils/exitCodes.js.map +1 -0
- package/dist/utils/filters.d.ts +108 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +304 -0
- package/dist/utils/filters.js.map +1 -0
- package/dist/utils/formatters/network.d.ts +23 -0
- package/dist/utils/formatters/network.d.ts.map +1 -0
- package/dist/utils/formatters/network.js +35 -0
- package/dist/utils/formatters/network.js.map +1 -0
- package/dist/utils/http.d.ts +34 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +48 -0
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/logger.d.ts +42 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +43 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/objects.d.ts +23 -0
- package/dist/utils/objects.d.ts.map +1 -0
- package/dist/utils/objects.js +25 -0
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/url/safeParseUrl.d.ts +63 -0
- package/dist/utils/url/safeParseUrl.d.ts.map +1 -0
- package/dist/utils/url/safeParseUrl.js +84 -0
- package/dist/utils/url/safeParseUrl.js.map +1 -0
- package/dist/utils/url.d.ts +63 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +152 -2
- package/dist/utils/url.js.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/version.d.ts +3 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +27 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +57 -10
- package/dist/utils/pageLoad.d.ts +0 -21
- package/dist/utils/pageLoad.d.ts.map +0 -1
- package/dist/utils/pageLoad.js +0 -85
- package/dist/utils/pageLoad.js.map +0 -1
- package/dist/utils/session.d.ts +0 -104
- package/dist/utils/session.d.ts.map +0 -1
- package/dist/utils/session.js +0 -244
- package/dist/utils/session.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/__testutils__/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testClock - Clock helper wrapper with async/await-friendly API
|
|
3
|
+
*
|
|
4
|
+
* Wraps FakeClock to provide ergonomic async helpers for test code.
|
|
5
|
+
* Use this in tests instead of raw FakeClock for better DX.
|
|
6
|
+
*/
|
|
7
|
+
import { FakeClock } from './FakeClock.js';
|
|
8
|
+
export interface ClockHelper {
|
|
9
|
+
clock: FakeClock;
|
|
10
|
+
tick: (ms: number) => void;
|
|
11
|
+
flush: () => void;
|
|
12
|
+
tickAndFlush: (ms: number) => Promise<void>;
|
|
13
|
+
restore: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a fake clock for deterministic timer control
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { clock, tickAndFlush } = useFakeClock();
|
|
21
|
+
*
|
|
22
|
+
* const promise = cdp.send('Target.getTargets'); // Starts 30s timeout
|
|
23
|
+
* await tickAndFlush(30000); // Advances timer + drains all microtasks
|
|
24
|
+
* await assert.rejects(promise, /timeout/);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useFakeClock(): ClockHelper;
|
|
28
|
+
//# sourceMappingURL=testClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testClock.d.ts","sourceRoot":"","sources":["../../src/__testutils__/testClock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,IAAI,WAAW,CAuE1C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testClock - Clock helper wrapper with async/await-friendly API
|
|
3
|
+
*
|
|
4
|
+
* Wraps FakeClock to provide ergonomic async helpers for test code.
|
|
5
|
+
* Use this in tests instead of raw FakeClock for better DX.
|
|
6
|
+
*/
|
|
7
|
+
import { FakeClock } from './FakeClock.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a fake clock for deterministic timer control
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const { clock, tickAndFlush } = useFakeClock();
|
|
14
|
+
*
|
|
15
|
+
* const promise = cdp.send('Target.getTargets'); // Starts 30s timeout
|
|
16
|
+
* await tickAndFlush(30000); // Advances timer + drains all microtasks
|
|
17
|
+
* await assert.rejects(promise, /timeout/);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function useFakeClock() {
|
|
21
|
+
const clock = new FakeClock();
|
|
22
|
+
// Store original timer functions
|
|
23
|
+
const originalSetTimeout = global.setTimeout;
|
|
24
|
+
const originalClearTimeout = global.clearTimeout;
|
|
25
|
+
const originalSetInterval = global.setInterval;
|
|
26
|
+
const originalClearInterval = global.clearInterval;
|
|
27
|
+
const originalQueueMicrotask = global.queueMicrotask;
|
|
28
|
+
// Replace global timers with fake clock
|
|
29
|
+
global.setTimeout = ((callback, delay) => {
|
|
30
|
+
return clock.setTimeout(callback, delay);
|
|
31
|
+
});
|
|
32
|
+
global.clearTimeout = ((id) => {
|
|
33
|
+
return clock.clearTimer(id);
|
|
34
|
+
});
|
|
35
|
+
global.setInterval = ((callback, interval) => {
|
|
36
|
+
return clock.setInterval(callback, interval);
|
|
37
|
+
});
|
|
38
|
+
global.clearInterval = ((id) => {
|
|
39
|
+
return clock.clearTimer(id);
|
|
40
|
+
});
|
|
41
|
+
global.queueMicrotask = (callback) => {
|
|
42
|
+
clock.queueMicrotask(callback);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
clock,
|
|
46
|
+
/**
|
|
47
|
+
* Advance time and execute timers (macrotasks only)
|
|
48
|
+
* Does NOT drain microtasks
|
|
49
|
+
*/
|
|
50
|
+
tick(ms) {
|
|
51
|
+
clock.tick(ms);
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Drain microtask queue completely
|
|
55
|
+
* Loops until queue is empty (handles cascading microtasks)
|
|
56
|
+
*/
|
|
57
|
+
flush() {
|
|
58
|
+
clock.flush();
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Advance time AND drain all microtasks
|
|
62
|
+
* Use this for timeout tests where rejections propagate via microtasks
|
|
63
|
+
*/
|
|
64
|
+
async tickAndFlush(ms) {
|
|
65
|
+
await clock.tickAsync(ms);
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Restore original timer functions
|
|
69
|
+
* IMPORTANT: Call this in afterEach() to avoid polluting other tests
|
|
70
|
+
*/
|
|
71
|
+
restore() {
|
|
72
|
+
global.setTimeout = originalSetTimeout;
|
|
73
|
+
global.clearTimeout = originalClearTimeout;
|
|
74
|
+
global.setInterval = originalSetInterval;
|
|
75
|
+
global.clearInterval = originalClearInterval;
|
|
76
|
+
global.queueMicrotask = originalQueueMicrotask;
|
|
77
|
+
clock.reset();
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=testClock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testClock.js","sourceRoot":"","sources":["../../src/__testutils__/testClock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;IAE9B,iCAAiC;IACjC,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC;IAC7C,MAAM,oBAAoB,GAAG,MAAM,CAAC,YAAY,CAAC;IACjD,MAAM,mBAAmB,GAAG,MAAM,CAAC,WAAW,CAAC;IAC/C,MAAM,qBAAqB,GAAG,MAAM,CAAC,aAAa,CAAC;IACnD,MAAM,sBAAsB,GAAG,MAAM,CAAC,cAAc,CAAC;IAErD,wCAAwC;IACxC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,QAAoB,EAAE,KAAa,EAAE,EAAE;QAC3D,OAAO,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAsB,CAAC;IAExB,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC,EAAkB,EAAE,EAAE;QAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAwB,CAAC;IAE1B,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,QAAoB,EAAE,QAAgB,EAAE,EAAE;QAC/D,OAAO,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAuB,CAAC;IAEzB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,EAAkB,EAAE,EAAE;QAC7C,OAAO,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAyB,CAAC;IAE3B,MAAM,CAAC,cAAc,GAAG,CAAC,QAAoB,EAAE,EAAE;QAC/C,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO;QACL,KAAK;QAEL;;;WAGG;QACH,IAAI,CAAC,EAAU;YACb,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QAED;;;WAGG;QACH,KAAK;YACH,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,YAAY,CAAC,EAAU;YAC3B,MAAM,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED;;;WAGG;QACH,OAAO;YACL,MAAM,CAAC,UAAU,GAAG,kBAAkB,CAAC;YACvC,MAAM,CAAC,YAAY,GAAG,oBAAoB,CAAC;YAC3C,MAAM,CAAC,WAAW,GAAG,mBAAmB,CAAC;YACzC,MAAM,CAAC,aAAa,GAAG,qBAAqB,CAAC;YAC7C,MAAM,CAAC,cAAc,GAAG,sBAAsB,CAAC;YAC/C,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testFixtures - Factory functions for test data
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient factories for creating test objects with sensible defaults.
|
|
5
|
+
*/
|
|
6
|
+
import type { CDPMessage } from '@/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create a mock CDP message with optional overrides
|
|
9
|
+
*/
|
|
10
|
+
export declare function createMockCDPMessage(overrides?: Partial<CDPMessage>): CDPMessage;
|
|
11
|
+
/**
|
|
12
|
+
* Create a WebSocket URL for testing
|
|
13
|
+
*/
|
|
14
|
+
export declare function createMockWebSocketUrl(port?: number): string;
|
|
15
|
+
//# sourceMappingURL=testFixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testFixtures.d.ts","sourceRoot":"","sources":["../../src/__testutils__/testFixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAOhF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,SAAO,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testFixtures - Factory functions for test data
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient factories for creating test objects with sensible defaults.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create a mock CDP message with optional overrides
|
|
8
|
+
*/
|
|
9
|
+
export function createMockCDPMessage(overrides) {
|
|
10
|
+
return {
|
|
11
|
+
id: 1,
|
|
12
|
+
method: 'Target.getTargets',
|
|
13
|
+
params: {},
|
|
14
|
+
...overrides,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a WebSocket URL for testing
|
|
19
|
+
*/
|
|
20
|
+
export function createMockWebSocketUrl(port = 9222) {
|
|
21
|
+
return `ws://localhost:${port}/devtools/browser`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=testFixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testFixtures.js","sourceRoot":"","sources":["../../src/__testutils__/testFixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA+B;IAClE,OAAO;QACL,EAAE,EAAE,CAAC;QACL,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,EAAE;QACV,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAI,GAAG,IAAI;IAChD,OAAO,kBAAkB,IAAI,mBAAmB,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testProcess - Helpers for stubbing process-related operations in tests
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to mock process.kill for testing process alive checks
|
|
5
|
+
* without actually sending signals.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ CRITICAL: Always call restoreProcessAlive() in afterEach() to prevent
|
|
8
|
+
* cross-suite pollution.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* describe('my test', () => {
|
|
13
|
+
* afterEach(() => {
|
|
14
|
+
* restoreProcessAlive(); // REQUIRED
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* it('should check if process is alive', () => {
|
|
18
|
+
* mockProcessAlive([1234, 5678]);
|
|
19
|
+
* // Now process.kill(1234, 0) returns true
|
|
20
|
+
* // And process.kill(9999, 0) returns false
|
|
21
|
+
* });
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Mock process.kill to simulate alive/dead processes
|
|
27
|
+
*
|
|
28
|
+
* When signal is 0 (alive check), returns true if PID is in alivePids array,
|
|
29
|
+
* or throws ESRCH error if PID is dead.
|
|
30
|
+
* For other signals, delegates to original process.kill.
|
|
31
|
+
*
|
|
32
|
+
* @param alivePids - Array of PIDs that should be considered "alive"
|
|
33
|
+
*/
|
|
34
|
+
export declare function mockProcessAlive(alivePids: number[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Restore original process.kill implementation
|
|
37
|
+
*
|
|
38
|
+
* ⚠️ CRITICAL: Always call this in afterEach() to prevent test pollution
|
|
39
|
+
*/
|
|
40
|
+
export declare function restoreProcessAlive(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Check if process.kill is currently mocked
|
|
43
|
+
* (Useful for debugging test cleanup issues)
|
|
44
|
+
*/
|
|
45
|
+
export declare function isProcessMocked(): boolean;
|
|
46
|
+
//# sourceMappingURL=testProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testProcess.d.ts","sourceRoot":"","sources":["../../src/__testutils__/testProcess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAwB1D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testProcess - Helpers for stubbing process-related operations in tests
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to mock process.kill for testing process alive checks
|
|
5
|
+
* without actually sending signals.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ CRITICAL: Always call restoreProcessAlive() in afterEach() to prevent
|
|
8
|
+
* cross-suite pollution.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* describe('my test', () => {
|
|
13
|
+
* afterEach(() => {
|
|
14
|
+
* restoreProcessAlive(); // REQUIRED
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* it('should check if process is alive', () => {
|
|
18
|
+
* mockProcessAlive([1234, 5678]);
|
|
19
|
+
* // Now process.kill(1234, 0) returns true
|
|
20
|
+
* // And process.kill(9999, 0) returns false
|
|
21
|
+
* });
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
let originalKill = null;
|
|
26
|
+
/**
|
|
27
|
+
* Mock process.kill to simulate alive/dead processes
|
|
28
|
+
*
|
|
29
|
+
* When signal is 0 (alive check), returns true if PID is in alivePids array,
|
|
30
|
+
* or throws ESRCH error if PID is dead.
|
|
31
|
+
* For other signals, delegates to original process.kill.
|
|
32
|
+
*
|
|
33
|
+
* @param alivePids - Array of PIDs that should be considered "alive"
|
|
34
|
+
*/
|
|
35
|
+
export function mockProcessAlive(alivePids) {
|
|
36
|
+
// Capture original process.kill if not already saved (bind to avoid unbound-method)
|
|
37
|
+
originalKill ??= process.kill.bind(process);
|
|
38
|
+
const alivePidSet = new Set(alivePids);
|
|
39
|
+
process.kill = ((pid, signal) => {
|
|
40
|
+
// Signal 0 is used to check if process exists (doesn't actually send signal)
|
|
41
|
+
if (signal === 0 || signal === undefined) {
|
|
42
|
+
if (alivePidSet.has(pid)) {
|
|
43
|
+
// Process is alive - return true
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Process is dead - throw ESRCH error (like real process.kill)
|
|
48
|
+
const err = new Error(`kill ESRCH`);
|
|
49
|
+
err.code = 'ESRCH';
|
|
50
|
+
err.errno = -3;
|
|
51
|
+
err.syscall = 'kill';
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// For other signals, delegate to original implementation
|
|
56
|
+
return originalKill(pid, signal);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Restore original process.kill implementation
|
|
61
|
+
*
|
|
62
|
+
* ⚠️ CRITICAL: Always call this in afterEach() to prevent test pollution
|
|
63
|
+
*/
|
|
64
|
+
export function restoreProcessAlive() {
|
|
65
|
+
if (originalKill !== null) {
|
|
66
|
+
process.kill = originalKill;
|
|
67
|
+
originalKill = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if process.kill is currently mocked
|
|
72
|
+
* (Useful for debugging test cleanup issues)
|
|
73
|
+
*/
|
|
74
|
+
export function isProcessMocked() {
|
|
75
|
+
return originalKill !== null;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=testProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testProcess.js","sourceRoot":"","sources":["../../src/__testutils__/testProcess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,IAAI,YAAY,GAA+B,IAAI,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAmB;IAClD,oFAAoF;IACpF,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,GAAW,EAAE,MAAgC,EAAE,EAAE;QAChE,6EAA6E;QAC7E,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,iCAAiC;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,+DAA+D;gBAC/D,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,YAAY,CAA0B,CAAC;gBAC7D,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;gBACnB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACf,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;gBACrB,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QACD,yDAAyD;QACzD,OAAQ,YAAoC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC,CAAwB,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;QAC5B,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,KAAK,IAAI,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/cli/collectors/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsZzC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmD1D"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { OutputBuilder } from '../handlers/OutputBuilder.js';
|
|
2
|
+
import { queryDOM, highlightDOM, getDOM } from '../../ipc/client.js';
|
|
3
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
4
|
+
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
5
|
+
import { getNodeIdByIndex } from './helpers/domCache.js';
|
|
6
|
+
import { parseSelectorOrIndex } from './helpers/selectorParser.js';
|
|
7
|
+
/**
|
|
8
|
+
* Handle bdg dom query \<selector|index\> command
|
|
9
|
+
* @param selector - CSS selector to query
|
|
10
|
+
* @param options - Command options
|
|
11
|
+
*/
|
|
12
|
+
async function handleDomQuery(selector, options) {
|
|
13
|
+
try {
|
|
14
|
+
// Send query request via IPC to daemon/worker
|
|
15
|
+
const response = await queryDOM(selector);
|
|
16
|
+
if (response.status === 'error') {
|
|
17
|
+
throw new Error(response.error ?? 'Unknown error');
|
|
18
|
+
}
|
|
19
|
+
if (!response.data) {
|
|
20
|
+
throw new Error('No data in response');
|
|
21
|
+
}
|
|
22
|
+
const { count, nodes } = response.data;
|
|
23
|
+
if (count === 0) {
|
|
24
|
+
if (options.json) {
|
|
25
|
+
console.log(JSON.stringify({
|
|
26
|
+
selector,
|
|
27
|
+
count: 0,
|
|
28
|
+
nodes: [],
|
|
29
|
+
}, null, 2));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log(`No elements found matching "${selector}"`);
|
|
33
|
+
}
|
|
34
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
35
|
+
}
|
|
36
|
+
// Output results
|
|
37
|
+
if (options.json) {
|
|
38
|
+
console.log(JSON.stringify(response.data, null, 2));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log(`Found ${count} element${count === 1 ? '' : 's'} matching "${selector}":`);
|
|
42
|
+
for (const node of nodes) {
|
|
43
|
+
const classInfo = node.classes && node.classes.length > 0 ? ` class="${node.classes.join(' ')}"` : '';
|
|
44
|
+
console.log(` [${node.index}] <${node.tag}${classInfo}> ${node.preview}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const errorMsg = getErrorMessage(error);
|
|
51
|
+
if (options.json) {
|
|
52
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.error(`Error: ${errorMsg}`);
|
|
56
|
+
}
|
|
57
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle bdg dom highlight \<selector|index\> command
|
|
62
|
+
* @param selectorOrIndex - CSS selector or index from last query
|
|
63
|
+
* @param options - Command options
|
|
64
|
+
*/
|
|
65
|
+
async function handleDomHighlight(selectorOrIndex, options) {
|
|
66
|
+
try {
|
|
67
|
+
// Build IPC request options
|
|
68
|
+
const ipcOptions = {
|
|
69
|
+
...(options.color !== undefined && { color: options.color }),
|
|
70
|
+
...(options.opacity !== undefined && { opacity: options.opacity }),
|
|
71
|
+
...(options.first !== undefined && { first: options.first }),
|
|
72
|
+
...(options.nth !== undefined && { nth: options.nth }),
|
|
73
|
+
};
|
|
74
|
+
// Handle direct nodeId (advanced users)
|
|
75
|
+
if (options.nodeId !== undefined) {
|
|
76
|
+
ipcOptions.nodeId = options.nodeId;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const parsed = parseSelectorOrIndex(selectorOrIndex);
|
|
80
|
+
if (parsed.type === 'index') {
|
|
81
|
+
// Look up nodeId from cache
|
|
82
|
+
const nodeId = getNodeIdByIndex(parsed.value);
|
|
83
|
+
if (!nodeId) {
|
|
84
|
+
throw new Error(`No cached element at index ${parsed.value}. Run 'bdg dom query <selector>' first.`);
|
|
85
|
+
}
|
|
86
|
+
ipcOptions.index = parsed.value;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Query by selector
|
|
90
|
+
ipcOptions.selector = parsed.value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Send highlight request via IPC to daemon/worker
|
|
94
|
+
const response = await highlightDOM(ipcOptions);
|
|
95
|
+
if (response.status === 'error') {
|
|
96
|
+
throw new Error(response.error ?? 'Unknown error');
|
|
97
|
+
}
|
|
98
|
+
if (!response.data) {
|
|
99
|
+
throw new Error('No data in response');
|
|
100
|
+
}
|
|
101
|
+
// Output result
|
|
102
|
+
if (options.json) {
|
|
103
|
+
console.log(JSON.stringify(response.data, null, 2));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(`✓ Highlighted ${response.data.highlighted} element${response.data.highlighted === 1 ? '' : 's'}`);
|
|
107
|
+
}
|
|
108
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const errorMsg = getErrorMessage(error);
|
|
112
|
+
if (options.json) {
|
|
113
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.error(`Error: ${errorMsg}`);
|
|
117
|
+
}
|
|
118
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Handle bdg dom get \<selector|index\> command
|
|
123
|
+
* @param selectorOrIndex - CSS selector or index from last query
|
|
124
|
+
* @param options - Command options
|
|
125
|
+
*/
|
|
126
|
+
async function handleDomGet(selectorOrIndex, options) {
|
|
127
|
+
try {
|
|
128
|
+
// Build IPC request options
|
|
129
|
+
const ipcOptions = {
|
|
130
|
+
...(options.all !== undefined && { all: options.all }),
|
|
131
|
+
...(options.nth !== undefined && { nth: options.nth }),
|
|
132
|
+
};
|
|
133
|
+
// Handle direct nodeId (advanced users)
|
|
134
|
+
if (options.nodeId !== undefined) {
|
|
135
|
+
ipcOptions.nodeId = options.nodeId;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const parsed = parseSelectorOrIndex(selectorOrIndex);
|
|
139
|
+
if (parsed.type === 'index') {
|
|
140
|
+
// Look up nodeId from cache
|
|
141
|
+
const nodeId = getNodeIdByIndex(parsed.value);
|
|
142
|
+
if (!nodeId) {
|
|
143
|
+
throw new Error(`No cached element at index ${parsed.value}. Run 'bdg dom query <selector>' first.`);
|
|
144
|
+
}
|
|
145
|
+
ipcOptions.index = parsed.value;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Query by selector
|
|
149
|
+
ipcOptions.selector = parsed.value;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Send get request via IPC to daemon/worker
|
|
153
|
+
const response = await getDOM(ipcOptions);
|
|
154
|
+
if (response.status === 'error') {
|
|
155
|
+
throw new Error(response.error ?? 'Unknown error');
|
|
156
|
+
}
|
|
157
|
+
if (!response.data) {
|
|
158
|
+
throw new Error('No data in response');
|
|
159
|
+
}
|
|
160
|
+
const { nodes } = response.data;
|
|
161
|
+
// Output results
|
|
162
|
+
if (options.json) {
|
|
163
|
+
console.log(JSON.stringify(nodes.length === 1 ? nodes[0] : nodes, null, 2));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
if (nodes.length === 1) {
|
|
167
|
+
const firstNode = nodes[0];
|
|
168
|
+
if (firstNode) {
|
|
169
|
+
console.log(firstNode.outerHTML);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
174
|
+
const node = nodes[i];
|
|
175
|
+
if (node) {
|
|
176
|
+
console.log(`[${i + 1}] ${node.outerHTML}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const errorMsg = getErrorMessage(error);
|
|
185
|
+
if (options.json) {
|
|
186
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.error(`Error: ${errorMsg}`);
|
|
190
|
+
}
|
|
191
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Handle bdg dom eval \<script\> command
|
|
196
|
+
* @param script - JavaScript expression to evaluate
|
|
197
|
+
* @param options - Command options
|
|
198
|
+
*/
|
|
199
|
+
async function handleDomEval(script, options) {
|
|
200
|
+
try {
|
|
201
|
+
// Import the query command handler
|
|
202
|
+
const { readPid } = await import('../../session/pid.js');
|
|
203
|
+
const { isProcessAlive } = await import('../../session/process.js');
|
|
204
|
+
const { readSessionMetadata } = await import('../../session/metadata.js');
|
|
205
|
+
const { CDPConnection } = await import('../../connection/cdp.js');
|
|
206
|
+
// Check if session is running
|
|
207
|
+
const pid = readPid();
|
|
208
|
+
if (!pid || !isProcessAlive(pid)) {
|
|
209
|
+
const errorMsg = 'No active session running';
|
|
210
|
+
if (options.json) {
|
|
211
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg, {
|
|
212
|
+
suggestion: 'Start a session with: bdg <url>',
|
|
213
|
+
}), null, 2));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
console.error(`Error: ${errorMsg}`);
|
|
217
|
+
console.error('Start a session with: bdg <url>');
|
|
218
|
+
}
|
|
219
|
+
process.exit(EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
220
|
+
}
|
|
221
|
+
// Read session metadata to get the target ID
|
|
222
|
+
const metadata = readSessionMetadata();
|
|
223
|
+
if (!metadata?.targetId || !metadata.webSocketDebuggerUrl) {
|
|
224
|
+
const errorMsg = 'No target information in session metadata';
|
|
225
|
+
if (options.json) {
|
|
226
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg, {
|
|
227
|
+
note: 'Session may have been started with an older version',
|
|
228
|
+
}), null, 2));
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
console.error(`Error: ${errorMsg}`);
|
|
232
|
+
console.error('Session may have been started with an older version');
|
|
233
|
+
}
|
|
234
|
+
process.exit(EXIT_CODES.SESSION_FILE_ERROR);
|
|
235
|
+
}
|
|
236
|
+
// Verify the target still exists
|
|
237
|
+
const port = parseInt(options.port ?? '9222', 10);
|
|
238
|
+
const response = await fetch(`http://127.0.0.1:${port}/json/list`);
|
|
239
|
+
const targetsData = await response.json();
|
|
240
|
+
if (!Array.isArray(targetsData)) {
|
|
241
|
+
const errorMsg = 'Invalid response from CDP';
|
|
242
|
+
if (options.json) {
|
|
243
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
console.error(`Error: ${errorMsg}`);
|
|
247
|
+
}
|
|
248
|
+
process.exit(EXIT_CODES.CDP_CONNECTION_FAILURE);
|
|
249
|
+
}
|
|
250
|
+
const target = targetsData.find((t) => t.id === metadata.targetId);
|
|
251
|
+
if (!target) {
|
|
252
|
+
const errorMsg = 'Session target not found (tab may have been closed)';
|
|
253
|
+
if (options.json) {
|
|
254
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg, {
|
|
255
|
+
suggestion: 'Start a new session with: bdg <url>',
|
|
256
|
+
}), null, 2));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
console.error(`Error: ${errorMsg}`);
|
|
260
|
+
console.error('Start a new session with: bdg <url>');
|
|
261
|
+
}
|
|
262
|
+
process.exit(EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
263
|
+
}
|
|
264
|
+
// Create temporary CDP connection using stored webSocketDebuggerUrl
|
|
265
|
+
const cdp = new CDPConnection();
|
|
266
|
+
await cdp.connect(metadata.webSocketDebuggerUrl);
|
|
267
|
+
// Execute JavaScript
|
|
268
|
+
const result = (await cdp.send('Runtime.evaluate', {
|
|
269
|
+
expression: script,
|
|
270
|
+
returnByValue: true,
|
|
271
|
+
awaitPromise: true,
|
|
272
|
+
}));
|
|
273
|
+
cdp.close();
|
|
274
|
+
// Output result
|
|
275
|
+
if (result.exceptionDetails) {
|
|
276
|
+
const errorMsg = result.exceptionDetails.exception?.description ?? 'Unknown error executing script';
|
|
277
|
+
if (options.json) {
|
|
278
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
console.error('Error executing script:');
|
|
282
|
+
console.error(errorMsg);
|
|
283
|
+
}
|
|
284
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
285
|
+
}
|
|
286
|
+
// Output result (wrapped if --json, raw otherwise)
|
|
287
|
+
if (options.json) {
|
|
288
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonSuccess({
|
|
289
|
+
result: result.result?.value,
|
|
290
|
+
}), null, 2));
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
console.log(JSON.stringify(result.result?.value, null, 2));
|
|
294
|
+
}
|
|
295
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
const errorMsg = getErrorMessage(error);
|
|
299
|
+
if (options.json) {
|
|
300
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(errorMsg), null, 2));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
console.error(`Error: ${errorMsg}`);
|
|
304
|
+
}
|
|
305
|
+
process.exit(EXIT_CODES.UNHANDLED_EXCEPTION);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Register DOM collector commands
|
|
310
|
+
*
|
|
311
|
+
* @param program - Commander.js Command instance
|
|
312
|
+
*/
|
|
313
|
+
export function registerDomCommands(program) {
|
|
314
|
+
const dom = program.command('dom').description('DOM inspection and manipulation');
|
|
315
|
+
// bdg dom query <selector>
|
|
316
|
+
dom
|
|
317
|
+
.command('query')
|
|
318
|
+
.description('Find elements by CSS selector')
|
|
319
|
+
.argument('<selector>', 'CSS selector (e.g., ".error", "#app", "button")')
|
|
320
|
+
.option('-j, --json', 'Output as JSON')
|
|
321
|
+
.action(async (selector, options) => {
|
|
322
|
+
await handleDomQuery(selector, options);
|
|
323
|
+
});
|
|
324
|
+
// bdg dom eval <script>
|
|
325
|
+
dom
|
|
326
|
+
.command('eval')
|
|
327
|
+
.description('Evaluate JavaScript expression in the page context')
|
|
328
|
+
.argument('<script>', 'JavaScript to execute (e.g., "document.title", "window.location.href")')
|
|
329
|
+
.option('-p, --port <number>', 'Chrome debugging port (default: 9222)')
|
|
330
|
+
.option('-j, --json', 'Wrap result in version/success format')
|
|
331
|
+
.action(async (script, options) => {
|
|
332
|
+
await handleDomEval(script, options);
|
|
333
|
+
});
|
|
334
|
+
// bdg dom highlight <selector|index>
|
|
335
|
+
dom
|
|
336
|
+
.command('highlight')
|
|
337
|
+
.description('Highlight elements in browser')
|
|
338
|
+
.argument('<selector|index>', 'CSS selector or index from last query')
|
|
339
|
+
.option('--first', 'Target first match only')
|
|
340
|
+
.option('--nth <n>', 'Target nth match', parseInt)
|
|
341
|
+
.option('--node-id <id>', 'Use nodeId directly (advanced)', parseInt)
|
|
342
|
+
.option('--color <color>', 'Highlight color (red, blue, green, yellow, orange, purple)')
|
|
343
|
+
.option('--opacity <value>', 'Highlight opacity (0.0 - 1.0)', parseFloat)
|
|
344
|
+
.option('-j, --json', 'Output as JSON')
|
|
345
|
+
.action(async (selectorOrIndex, options) => {
|
|
346
|
+
await handleDomHighlight(selectorOrIndex, options);
|
|
347
|
+
});
|
|
348
|
+
// bdg dom get <selector|index>
|
|
349
|
+
dom
|
|
350
|
+
.command('get')
|
|
351
|
+
.description('Get full HTML and attributes for elements')
|
|
352
|
+
.argument('<selector|index>', 'CSS selector or index from last query')
|
|
353
|
+
.option('--all', 'Target all matches')
|
|
354
|
+
.option('--nth <n>', 'Target nth match', parseInt)
|
|
355
|
+
.option('--node-id <id>', 'Use nodeId directly (advanced)', parseInt)
|
|
356
|
+
.option('-j, --json', 'Output as JSON')
|
|
357
|
+
.action(async (selectorOrIndex, options) => {
|
|
358
|
+
await handleDomGet(selectorOrIndex, options);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=dom.js.map
|