browser-debugger-cli 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -6
- package/dist/__tests__/smoke/error-handling.smoke.test.js +23 -52
- package/dist/__tests__/smoke/error-handling.smoke.test.js.map +1 -1
- package/dist/__tests__/smoke/session-lifecycle.smoke.test.js +27 -24
- package/dist/__tests__/smoke/session-lifecycle.smoke.test.js.map +1 -1
- package/dist/__testutils__/daemonHelpers.d.ts +13 -1
- package/dist/__testutils__/daemonHelpers.d.ts.map +1 -1
- package/dist/__testutils__/daemonHelpers.js +54 -5
- package/dist/__testutils__/daemonHelpers.js.map +1 -1
- package/dist/__testutils__/testCleanup.js +1 -1
- package/dist/__testutils__/testCleanup.js.map +1 -1
- package/dist/cdp/protocol.d.ts +0 -48
- package/dist/cdp/protocol.d.ts.map +1 -1
- package/dist/cdp/protocol.js +9 -101
- package/dist/cdp/protocol.js.map +1 -1
- package/dist/commands/__tests__/cdp.contract.test.js +2 -2
- package/dist/commands/__tests__/cdp.contract.test.js.map +1 -1
- package/dist/commands/__tests__/domEval.contract.test.js +8 -4
- package/dist/commands/__tests__/domEval.contract.test.js.map +1 -1
- package/dist/commands/cdp.d.ts.map +1 -1
- package/dist/commands/cdp.js +4 -37
- package/dist/commands/cdp.js.map +1 -1
- package/dist/commands/cleanup.d.ts.map +1 -1
- package/dist/commands/cleanup.js +25 -23
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +3 -8
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/details.d.ts.map +1 -1
- package/dist/commands/details.js +1 -1
- package/dist/commands/details.js.map +1 -1
- package/dist/commands/dom/a11y.d.ts +18 -0
- package/dist/commands/dom/a11y.d.ts.map +1 -0
- package/dist/commands/dom/a11y.js +134 -0
- package/dist/commands/dom/a11y.js.map +1 -0
- package/dist/commands/{domEvalHelpers.d.ts → dom/evalHelpers.d.ts} +8 -5
- package/dist/commands/dom/evalHelpers.d.ts.map +1 -0
- package/dist/commands/{domEvalHelpers.js → dom/evalHelpers.js} +14 -13
- package/dist/commands/dom/evalHelpers.js.map +1 -0
- package/dist/commands/dom/formFillHelpers.d.ts +47 -0
- package/dist/commands/dom/formFillHelpers.d.ts.map +1 -0
- package/dist/commands/dom/formFillHelpers.js +185 -0
- package/dist/commands/dom/formFillHelpers.js.map +1 -0
- package/dist/commands/dom/formInteraction.d.ts +17 -0
- package/dist/commands/dom/formInteraction.d.ts.map +1 -0
- package/dist/commands/dom/formInteraction.js +239 -0
- package/dist/commands/dom/formInteraction.js.map +1 -0
- package/dist/commands/dom/formSubmitHelpers.d.ts +58 -0
- package/dist/commands/dom/formSubmitHelpers.d.ts.map +1 -0
- package/dist/commands/dom/formSubmitHelpers.js +176 -0
- package/dist/commands/dom/formSubmitHelpers.js.map +1 -0
- package/dist/commands/dom/helpers.d.ts +34 -0
- package/dist/commands/dom/helpers.d.ts.map +1 -0
- package/dist/commands/dom/helpers.js +244 -0
- package/dist/commands/dom/helpers.js.map +1 -0
- package/dist/commands/{dom.d.ts → dom/index.d.ts} +1 -1
- package/dist/commands/dom/index.d.ts.map +1 -0
- package/dist/commands/dom/index.js +175 -0
- package/dist/commands/dom/index.js.map +1 -0
- package/dist/commands/dom/reactEventHelpers.d.ts +80 -0
- package/dist/commands/dom/reactEventHelpers.d.ts.map +1 -0
- package/dist/commands/dom/reactEventHelpers.js +274 -0
- package/dist/commands/dom/reactEventHelpers.js.map +1 -0
- package/dist/commands/network.js +1 -1
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +49 -52
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/shared/CommandRunner.d.ts.map +1 -1
- package/dist/commands/shared/CommandRunner.js +3 -2
- package/dist/commands/shared/CommandRunner.js.map +1 -1
- package/dist/commands/shared/commonOptions.d.ts.map +1 -1
- package/dist/commands/shared/commonOptions.js +3 -1
- package/dist/commands/shared/commonOptions.js.map +1 -1
- package/dist/commands/shared/daemonErrorHandler.d.ts +30 -0
- package/dist/commands/shared/daemonErrorHandler.d.ts.map +1 -0
- package/dist/commands/shared/daemonErrorHandler.js +32 -0
- package/dist/commands/shared/daemonErrorHandler.js.map +1 -0
- package/dist/commands/shared/{daemonSessionController.d.ts → startHelpers.d.ts} +7 -1
- package/dist/commands/shared/startHelpers.d.ts.map +1 -0
- package/dist/commands/shared/{daemonSessionController.js → startHelpers.js} +13 -5
- package/dist/commands/shared/startHelpers.js.map +1 -0
- package/dist/commands/shared/validation.d.ts +44 -0
- package/dist/commands/shared/validation.d.ts.map +1 -0
- package/dist/commands/shared/validation.js +68 -0
- package/dist/commands/shared/validation.js.map +1 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +9 -25
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +6 -4
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/stop.d.ts.map +1 -1
- package/dist/commands/stop.js +16 -19
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/tail.d.ts.map +1 -1
- package/dist/commands/tail.js +49 -44
- package/dist/commands/tail.js.map +1 -1
- package/dist/commands/types.d.ts +46 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +8 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +3 -1
- package/dist/commands.js.map +1 -1
- package/dist/connection/__tests__/cdp.contract.test.js +7 -7
- package/dist/connection/__tests__/cdp.contract.test.js.map +1 -1
- package/dist/connection/__tests__/handlers.unit.test.d.ts +11 -0
- package/dist/connection/__tests__/handlers.unit.test.d.ts.map +1 -0
- package/dist/connection/__tests__/handlers.unit.test.js +220 -0
- package/dist/connection/__tests__/handlers.unit.test.js.map +1 -0
- package/dist/connection/__tests__/pageReadiness.contract.test.d.ts +14 -0
- package/dist/connection/__tests__/pageReadiness.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/pageReadiness.contract.test.js +382 -0
- package/dist/connection/__tests__/pageReadiness.contract.test.js.map +1 -0
- package/dist/connection/__tests__/portReservation.contract.test.d.ts +14 -0
- package/dist/connection/__tests__/portReservation.contract.test.d.ts.map +1 -0
- package/dist/connection/__tests__/portReservation.contract.test.js +250 -0
- package/dist/connection/__tests__/portReservation.contract.test.js.map +1 -0
- package/dist/connection/cdp.d.ts +34 -11
- package/dist/connection/cdp.d.ts.map +1 -1
- package/dist/connection/cdp.js +61 -45
- package/dist/connection/cdp.js.map +1 -1
- package/dist/connection/config.d.ts +63 -0
- package/dist/connection/config.d.ts.map +1 -0
- package/dist/connection/config.js +46 -0
- package/dist/connection/config.js.map +1 -0
- package/dist/connection/errors.d.ts +6 -21
- package/dist/connection/errors.d.ts.map +1 -1
- package/dist/connection/errors.js +7 -26
- package/dist/connection/errors.js.map +1 -1
- package/dist/connection/events.d.ts +30 -0
- package/dist/connection/events.d.ts.map +1 -0
- package/dist/connection/events.js +8 -0
- package/dist/connection/events.js.map +1 -0
- package/dist/connection/handlers.d.ts +3 -5
- package/dist/connection/handlers.d.ts.map +1 -1
- package/dist/connection/handlers.js +10 -12
- package/dist/connection/handlers.js.map +1 -1
- package/dist/connection/launcher/binaryResolver.d.ts +40 -0
- package/dist/connection/launcher/binaryResolver.d.ts.map +1 -0
- package/dist/connection/launcher/binaryResolver.js +78 -0
- package/dist/connection/launcher/binaryResolver.js.map +1 -0
- package/dist/connection/launcher/flagsBuilder.d.ts +64 -0
- package/dist/connection/launcher/flagsBuilder.d.ts.map +1 -0
- package/dist/connection/launcher/flagsBuilder.js +84 -0
- package/dist/connection/launcher/flagsBuilder.js.map +1 -0
- package/dist/connection/launcher/preferencesLoader.d.ts +74 -0
- package/dist/connection/launcher/preferencesLoader.d.ts.map +1 -0
- package/dist/connection/launcher/preferencesLoader.js +89 -0
- package/dist/connection/launcher/preferencesLoader.js.map +1 -0
- package/dist/connection/launcher.d.ts +24 -1
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +30 -205
- package/dist/connection/launcher.js.map +1 -1
- package/dist/connection/pageReadiness.d.ts +8 -8
- package/dist/connection/pageReadiness.d.ts.map +1 -1
- package/dist/connection/pageReadiness.js +36 -52
- package/dist/connection/pageReadiness.js.map +1 -1
- package/dist/connection/portReservation.d.ts +40 -0
- package/dist/connection/portReservation.d.ts.map +1 -0
- package/dist/connection/portReservation.js +55 -0
- package/dist/connection/portReservation.js.map +1 -0
- package/dist/connection/typed-cdp.d.ts +2 -1
- package/dist/connection/typed-cdp.d.ts.map +1 -1
- package/dist/connection/typed-cdp.js.map +1 -1
- package/dist/connection/types.d.ts +103 -0
- package/dist/connection/types.d.ts.map +1 -0
- package/dist/connection/types.js +8 -0
- package/dist/connection/types.js.map +1 -0
- package/dist/constants.d.ts +6 -83
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -83
- package/dist/constants.js.map +1 -1
- package/dist/daemon/__tests__/JsonlParser.unit.test.d.ts +8 -0
- package/dist/daemon/__tests__/JsonlParser.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/JsonlParser.unit.test.js +140 -0
- package/dist/daemon/__tests__/JsonlParser.unit.test.js.map +1 -0
- package/dist/daemon/__tests__/PendingRequestManager.unit.test.d.ts +8 -0
- package/dist/daemon/__tests__/PendingRequestManager.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/PendingRequestManager.unit.test.js +276 -0
- package/dist/daemon/__tests__/PendingRequestManager.unit.test.js.map +1 -0
- package/dist/daemon/__tests__/TelemetryStore.unit.test.d.ts +8 -0
- package/dist/daemon/__tests__/TelemetryStore.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/TelemetryStore.unit.test.js +290 -0
- package/dist/daemon/__tests__/TelemetryStore.unit.test.js.map +1 -0
- package/dist/daemon/__tests__/commandRegistry.contract.test.d.ts +8 -0
- package/dist/daemon/__tests__/commandRegistry.contract.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/commandRegistry.contract.test.js +384 -0
- package/dist/daemon/__tests__/commandRegistry.contract.test.js.map +1 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts +19 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js +212 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js.map +1 -0
- package/dist/daemon/__tests__/ipcServer.contract.test.js +2 -1
- package/dist/daemon/__tests__/ipcServer.contract.test.js.map +1 -1
- package/dist/daemon/errors.d.ts +65 -0
- package/dist/daemon/errors.d.ts.map +1 -0
- package/dist/daemon/errors.js +82 -0
- package/dist/daemon/errors.js.map +1 -0
- package/dist/daemon/handlers/CommandHandlers.d.ts +32 -0
- package/dist/daemon/handlers/CommandHandlers.d.ts.map +1 -0
- package/dist/daemon/handlers/CommandHandlers.js +93 -0
- package/dist/daemon/handlers/CommandHandlers.js.map +1 -0
- package/dist/daemon/handlers/QueryHandlers.d.ts +35 -0
- package/dist/daemon/handlers/QueryHandlers.d.ts.map +1 -0
- package/dist/daemon/handlers/QueryHandlers.js +176 -0
- package/dist/daemon/handlers/QueryHandlers.js.map +1 -0
- package/dist/daemon/handlers/SessionHandlers.d.ts +32 -0
- package/dist/daemon/handlers/SessionHandlers.d.ts.map +1 -0
- package/dist/daemon/handlers/SessionHandlers.js +227 -0
- package/dist/daemon/handlers/SessionHandlers.js.map +1 -0
- package/dist/daemon/handlers/pendingRequests.d.ts +50 -0
- package/dist/daemon/handlers/pendingRequests.d.ts.map +1 -0
- package/dist/daemon/handlers/pendingRequests.js +57 -0
- package/dist/daemon/handlers/pendingRequests.js.map +1 -0
- package/dist/daemon/handlers/requestHandlers.d.ts +51 -0
- package/dist/daemon/handlers/requestHandlers.d.ts.map +1 -0
- package/dist/daemon/handlers/requestHandlers.js +61 -0
- package/dist/daemon/handlers/requestHandlers.js.map +1 -0
- package/dist/daemon/handlers/responseHandler.d.ts +42 -0
- package/dist/daemon/handlers/responseHandler.d.ts.map +1 -0
- package/dist/daemon/handlers/responseHandler.js +195 -0
- package/dist/daemon/handlers/responseHandler.js.map +1 -0
- package/dist/daemon/ipcServer.d.ts +19 -41
- package/dist/daemon/ipcServer.d.ts.map +1 -1
- package/dist/daemon/ipcServer.js +83 -655
- package/dist/daemon/ipcServer.js.map +1 -1
- package/dist/daemon/launcher.d.ts.map +1 -1
- package/dist/daemon/launcher.js +10 -6
- package/dist/daemon/launcher.js.map +1 -1
- package/dist/daemon/lifecycle/cdpSetup.d.ts +24 -0
- package/dist/daemon/lifecycle/cdpSetup.d.ts.map +1 -0
- package/dist/daemon/lifecycle/cdpSetup.js +59 -0
- package/dist/daemon/lifecycle/cdpSetup.js.map +1 -0
- package/dist/daemon/lifecycle/chromeConnection.d.ts +17 -0
- package/dist/daemon/lifecycle/chromeConnection.d.ts.map +1 -0
- package/dist/daemon/lifecycle/chromeConnection.js +80 -0
- package/dist/daemon/lifecycle/chromeConnection.js.map +1 -0
- package/dist/daemon/lifecycle/signalHandlers.d.ts +14 -0
- package/dist/daemon/lifecycle/signalHandlers.d.ts.map +1 -0
- package/dist/daemon/lifecycle/signalHandlers.js +35 -0
- package/dist/daemon/lifecycle/signalHandlers.js.map +1 -0
- package/dist/daemon/lifecycle/workerCleanup.d.ts +27 -0
- package/dist/daemon/lifecycle/workerCleanup.d.ts.map +1 -0
- package/dist/daemon/lifecycle/workerCleanup.js +144 -0
- package/dist/daemon/lifecycle/workerCleanup.js.map +1 -0
- package/dist/daemon/lifecycle/workerConfig.d.ts +14 -0
- package/dist/daemon/lifecycle/workerConfig.d.ts.map +1 -0
- package/dist/daemon/lifecycle/workerConfig.js +66 -0
- package/dist/daemon/lifecycle/workerConfig.js.map +1 -0
- package/dist/daemon/lifecycle/workerIpc.d.ts +14 -0
- package/dist/daemon/lifecycle/workerIpc.d.ts.map +1 -0
- package/dist/daemon/lifecycle/workerIpc.js +87 -0
- package/dist/daemon/lifecycle/workerIpc.js.map +1 -0
- package/dist/daemon/server/JsonlParser.d.ts +31 -0
- package/dist/daemon/server/JsonlParser.d.ts.map +1 -0
- package/dist/daemon/server/JsonlParser.js +57 -0
- package/dist/daemon/server/JsonlParser.js.map +1 -0
- package/dist/daemon/server/SocketServer.d.ts.map +1 -1
- package/dist/daemon/server/SocketServer.js +2 -2
- package/dist/daemon/server/SocketServer.js.map +1 -1
- package/dist/daemon/server/WorkerManager.d.ts +3 -3
- package/dist/daemon/server/WorkerManager.d.ts.map +1 -1
- package/dist/daemon/server/WorkerManager.js +10 -19
- package/dist/daemon/server/WorkerManager.js.map +1 -1
- package/dist/daemon/services/SessionService.d.ts +87 -0
- package/dist/daemon/services/SessionService.d.ts.map +1 -0
- package/dist/daemon/services/SessionService.js +45 -0
- package/dist/daemon/services/SessionService.js.map +1 -0
- package/dist/daemon/startSession.d.ts.map +1 -1
- package/dist/daemon/startSession.js +54 -31
- package/dist/daemon/startSession.js.map +1 -1
- package/dist/daemon/worker/commandRegistry.d.ts +1 -1
- package/dist/daemon/worker/commandRegistry.d.ts.map +1 -1
- package/dist/daemon/worker/commandRegistry.js +20 -215
- package/dist/daemon/worker/commandRegistry.js.map +1 -1
- package/dist/daemon/worker.d.ts +3 -12
- package/dist/daemon/worker.d.ts.map +1 -1
- package/dist/daemon/worker.js +47 -367
- package/dist/daemon/worker.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.d.ts +0 -15
- package/dist/ipc/__tests__/client.contract.test.d.ts.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.js +259 -42
- package/dist/ipc/__tests__/client.contract.test.js.map +1 -1
- package/dist/ipc/__tests__/errors.unit.test.d.ts +7 -0
- package/dist/ipc/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/errors.unit.test.js +77 -0
- package/dist/ipc/__tests__/errors.unit.test.js.map +1 -0
- package/dist/ipc/__tests__/guards.unit.test.d.ts +7 -0
- package/dist/ipc/__tests__/guards.unit.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/guards.unit.test.js +73 -0
- package/dist/ipc/__tests__/guards.unit.test.js.map +1 -0
- package/dist/ipc/__tests__/jsonl.unit.test.d.ts +7 -0
- package/dist/ipc/__tests__/jsonl.unit.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/jsonl.unit.test.js +103 -0
- package/dist/ipc/__tests__/jsonl.unit.test.js.map +1 -0
- package/dist/ipc/__tests__/validation.unit.test.d.ts +7 -0
- package/dist/ipc/__tests__/validation.unit.test.d.ts.map +1 -0
- package/dist/ipc/__tests__/validation.unit.test.js +60 -0
- package/dist/ipc/__tests__/validation.unit.test.js.map +1 -0
- package/dist/ipc/client.d.ts +93 -84
- package/dist/ipc/client.d.ts.map +1 -1
- package/dist/ipc/client.js +121 -192
- package/dist/ipc/client.js.map +1 -1
- package/dist/ipc/index.d.ts +17 -0
- package/dist/ipc/index.d.ts.map +1 -0
- package/dist/ipc/index.js +23 -0
- package/dist/ipc/index.js.map +1 -0
- package/dist/ipc/protocol/commands.d.ts +144 -0
- package/dist/ipc/protocol/commands.d.ts.map +1 -0
- package/dist/ipc/protocol/commands.js +23 -0
- package/dist/ipc/protocol/commands.js.map +1 -0
- package/dist/ipc/protocol/guards.d.ts +47 -0
- package/dist/ipc/protocol/guards.d.ts.map +1 -0
- package/dist/ipc/protocol/guards.js +62 -0
- package/dist/ipc/protocol/guards.js.map +1 -0
- package/dist/ipc/protocol/index.d.ts +9 -0
- package/dist/ipc/protocol/index.d.ts.map +1 -0
- package/dist/ipc/protocol/index.js +8 -0
- package/dist/ipc/protocol/index.js.map +1 -0
- package/dist/ipc/protocol/messages.d.ts +64 -0
- package/dist/ipc/protocol/messages.d.ts.map +1 -0
- package/dist/ipc/protocol/messages.js +8 -0
- package/dist/ipc/protocol/messages.js.map +1 -0
- package/dist/ipc/session/errors.d.ts +25 -0
- package/dist/ipc/session/errors.d.ts.map +1 -0
- package/dist/ipc/{types.js → session/errors.js} +11 -6
- package/dist/ipc/session/errors.js.map +1 -0
- package/dist/ipc/session/index.d.ts +16 -0
- package/dist/ipc/session/index.d.ts.map +1 -0
- package/dist/ipc/session/index.js +7 -0
- package/dist/ipc/session/index.js.map +1 -0
- package/dist/ipc/session/lifecycle.d.ts +125 -0
- package/dist/ipc/session/lifecycle.d.ts.map +1 -0
- package/dist/ipc/session/lifecycle.js +7 -0
- package/dist/ipc/session/lifecycle.js.map +1 -0
- package/dist/ipc/session/queries.d.ts +94 -0
- package/dist/ipc/session/queries.d.ts.map +1 -0
- package/dist/ipc/session/queries.js +7 -0
- package/dist/ipc/session/queries.js.map +1 -0
- package/dist/ipc/session/types.d.ts +28 -0
- package/dist/ipc/session/types.d.ts.map +1 -0
- package/dist/ipc/session/types.js +7 -0
- package/dist/ipc/session/types.js.map +1 -0
- package/dist/ipc/transport/IPCError.d.ts +82 -0
- package/dist/ipc/transport/IPCError.d.ts.map +1 -0
- package/dist/ipc/transport/IPCError.js +109 -0
- package/dist/ipc/transport/IPCError.js.map +1 -0
- package/dist/ipc/transport/errors.d.ts +11 -0
- package/dist/ipc/transport/errors.d.ts.map +1 -0
- package/dist/ipc/transport/errors.js +28 -0
- package/dist/ipc/transport/errors.js.map +1 -0
- package/dist/ipc/transport/index.d.ts +16 -0
- package/dist/ipc/transport/index.d.ts.map +1 -0
- package/dist/ipc/transport/index.js +77 -0
- package/dist/ipc/transport/index.js.map +1 -0
- package/dist/ipc/transport/jsonl.d.ts +39 -0
- package/dist/ipc/transport/jsonl.d.ts.map +1 -0
- package/dist/ipc/transport/jsonl.js +61 -0
- package/dist/ipc/transport/jsonl.js.map +1 -0
- package/dist/ipc/transport/socket.d.ts +27 -0
- package/dist/ipc/transport/socket.d.ts.map +1 -0
- package/dist/ipc/transport/socket.js +49 -0
- package/dist/ipc/transport/socket.js.map +1 -0
- package/dist/ipc/transport/validation.d.ts +21 -0
- package/dist/ipc/transport/validation.d.ts.map +1 -0
- package/dist/ipc/transport/validation.js +23 -0
- package/dist/ipc/transport/validation.js.map +1 -0
- package/dist/ipc/utils/errors.d.ts +25 -0
- package/dist/ipc/utils/errors.d.ts.map +1 -0
- package/dist/ipc/utils/errors.js +29 -0
- package/dist/ipc/utils/errors.js.map +1 -0
- package/dist/ipc/utils/index.d.ts +12 -0
- package/dist/ipc/utils/index.d.ts.map +1 -0
- package/dist/ipc/utils/index.js +11 -0
- package/dist/ipc/utils/index.js.map +1 -0
- package/dist/ipc/utils/requestId.d.ts +23 -0
- package/dist/ipc/utils/requestId.d.ts.map +1 -0
- package/dist/ipc/utils/requestId.js +27 -0
- package/dist/ipc/utils/requestId.js.map +1 -0
- package/dist/ipc/utils/responseValidator.d.ts.map +1 -0
- package/dist/ipc/{responseValidator.js → utils/responseValidator.js} +2 -1
- package/dist/ipc/utils/responseValidator.js.map +1 -0
- package/dist/ipc/utils/session.d.ts +36 -0
- package/dist/ipc/utils/session.d.ts.map +1 -0
- package/dist/ipc/utils/session.js +37 -0
- package/dist/ipc/utils/session.js.map +1 -0
- package/dist/ipc/utils/types.d.ts +17 -0
- package/dist/ipc/utils/types.d.ts.map +1 -0
- package/dist/ipc/utils/types.js +7 -0
- package/dist/ipc/utils/types.js.map +1 -0
- package/dist/session/__tests__/chrome-cache.contract.test.d.ts +7 -0
- package/dist/session/__tests__/chrome-cache.contract.test.d.ts.map +1 -0
- package/dist/session/__tests__/chrome-cache.contract.test.js +77 -0
- package/dist/session/__tests__/chrome-cache.contract.test.js.map +1 -0
- package/dist/session/__tests__/cleanup.contract.test.d.ts +7 -0
- package/dist/session/__tests__/cleanup.contract.test.d.ts.map +1 -0
- package/dist/session/__tests__/cleanup.contract.test.js +84 -0
- package/dist/session/__tests__/cleanup.contract.test.js.map +1 -0
- package/dist/session/__tests__/lock.contract.test.d.ts +7 -0
- package/dist/session/__tests__/lock.contract.test.d.ts.map +1 -0
- package/dist/session/__tests__/lock.contract.test.js +77 -0
- package/dist/session/__tests__/lock.contract.test.js.map +1 -0
- package/dist/session/__tests__/metadata.contract.test.d.ts +7 -0
- package/dist/session/__tests__/metadata.contract.test.d.ts.map +1 -0
- package/dist/session/__tests__/metadata.contract.test.js +87 -0
- package/dist/session/__tests__/metadata.contract.test.js.map +1 -0
- package/dist/session/chrome.d.ts +20 -0
- package/dist/session/chrome.d.ts.map +1 -1
- package/dist/session/chrome.js +81 -17
- package/dist/session/chrome.js.map +1 -1
- package/dist/session/cleanup.d.ts +36 -2
- package/dist/session/cleanup.d.ts.map +1 -1
- package/dist/session/cleanup.js +201 -73
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/lock.d.ts.map +1 -1
- package/dist/session/lock.js +102 -91
- package/dist/session/lock.js.map +1 -1
- package/dist/session/metadata.d.ts +10 -3
- package/dist/session/metadata.d.ts.map +1 -1
- package/dist/session/metadata.js +24 -6
- package/dist/session/metadata.js.map +1 -1
- package/dist/session/paths.d.ts +0 -9
- package/dist/session/paths.d.ts.map +1 -1
- package/dist/session/paths.js +0 -11
- package/dist/session/paths.js.map +1 -1
- package/dist/session/pid.d.ts +15 -0
- package/dist/session/pid.d.ts.map +1 -1
- package/dist/session/pid.js +39 -21
- package/dist/session/pid.js.map +1 -1
- package/dist/session/process.d.ts +4 -41
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +4 -85
- package/dist/session/process.js.map +1 -1
- package/dist/session/statusData.d.ts +50 -0
- package/dist/session/statusData.d.ts.map +1 -0
- package/dist/session/statusData.js +51 -0
- package/dist/session/statusData.js.map +1 -0
- package/dist/telemetry/__tests__/a11y.unit.test.d.ts +10 -0
- package/dist/telemetry/__tests__/a11y.unit.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/a11y.unit.test.js +265 -0
- package/dist/telemetry/__tests__/a11y.unit.test.js.map +1 -0
- package/dist/telemetry/__tests__/navigation.contract.test.d.ts +8 -0
- package/dist/telemetry/__tests__/navigation.contract.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/navigation.contract.test.js +211 -0
- package/dist/telemetry/__tests__/navigation.contract.test.js.map +1 -0
- package/dist/telemetry/__tests__/network.contract.test.d.ts +0 -20
- package/dist/telemetry/__tests__/network.contract.test.d.ts.map +1 -1
- package/dist/telemetry/__tests__/network.contract.test.js +2 -64
- package/dist/telemetry/__tests__/network.contract.test.js.map +1 -1
- package/dist/telemetry/__tests__/utils.unit.test.d.ts +7 -0
- package/dist/telemetry/__tests__/utils.unit.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/utils.unit.test.js +91 -0
- package/dist/telemetry/__tests__/utils.unit.test.js.map +1 -0
- package/dist/telemetry/a11y.d.ts +78 -0
- package/dist/telemetry/a11y.d.ts.map +1 -0
- package/dist/telemetry/a11y.js +280 -0
- package/dist/telemetry/a11y.js.map +1 -0
- package/dist/telemetry/console.d.ts.map +1 -1
- package/dist/telemetry/console.js +19 -28
- package/dist/telemetry/console.js.map +1 -1
- package/dist/telemetry/dialogs.d.ts.map +1 -1
- package/dist/telemetry/dialogs.js +4 -8
- package/dist/telemetry/dialogs.js.map +1 -1
- package/dist/telemetry/dom.d.ts +1 -1
- package/dist/telemetry/dom.d.ts.map +1 -1
- package/dist/telemetry/dom.js +83 -60
- package/dist/telemetry/dom.js.map +1 -1
- package/dist/telemetry/filters.d.ts +5 -18
- package/dist/telemetry/filters.d.ts.map +1 -1
- package/dist/telemetry/filters.js +36 -56
- package/dist/telemetry/filters.js.map +1 -1
- package/dist/telemetry/navigation.d.ts.map +1 -1
- package/dist/telemetry/navigation.js +5 -8
- package/dist/telemetry/navigation.js.map +1 -1
- package/dist/telemetry/network.d.ts.map +1 -1
- package/dist/telemetry/network.js +105 -104
- package/dist/telemetry/network.js.map +1 -1
- package/dist/telemetry/utils.d.ts +85 -0
- package/dist/telemetry/utils.d.ts.map +1 -0
- package/dist/telemetry/utils.js +138 -0
- package/dist/telemetry/utils.js.map +1 -0
- package/dist/types/dom.d.ts +66 -0
- package/dist/types/dom.d.ts.map +1 -0
- package/dist/types/dom.js +8 -0
- package/dist/types/dom.js.map +1 -0
- package/dist/types.d.ts +86 -77
- package/dist/types.d.ts.map +1 -1
- package/dist/{commands/shared → ui}/OutputBuilder.d.ts +10 -2
- package/dist/ui/OutputBuilder.d.ts.map +1 -0
- package/dist/{commands/shared → ui}/OutputBuilder.js +8 -2
- package/dist/ui/OutputBuilder.js.map +1 -0
- package/dist/ui/errors/CommandError.d.ts +16 -2
- package/dist/ui/errors/CommandError.d.ts.map +1 -1
- package/dist/ui/errors/CommandError.js +2 -1
- package/dist/ui/errors/CommandError.js.map +1 -1
- package/dist/ui/errors/index.d.ts +2 -3
- package/dist/ui/errors/index.d.ts.map +1 -1
- package/dist/ui/errors/index.js +1 -3
- package/dist/ui/errors/index.js.map +1 -1
- package/dist/ui/errors/utils.d.ts +6 -0
- package/dist/ui/errors/utils.d.ts.map +1 -1
- package/dist/ui/errors/utils.js +8 -3
- package/dist/ui/errors/utils.js.map +1 -1
- package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts +2 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts.map +1 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.js +111 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.js.map +1 -0
- package/dist/ui/formatters/a11y.d.ts +30 -0
- package/dist/ui/formatters/a11y.d.ts.map +1 -0
- package/dist/ui/formatters/a11y.js +178 -0
- package/dist/ui/formatters/a11y.js.map +1 -0
- package/dist/ui/formatters/dom.d.ts +3 -18
- package/dist/ui/formatters/dom.d.ts.map +1 -1
- package/dist/ui/formatters/dom.js +4 -27
- package/dist/ui/formatters/dom.js.map +1 -1
- package/dist/ui/formatters/preview.d.ts +10 -8
- package/dist/ui/formatters/preview.d.ts.map +1 -1
- package/dist/ui/formatters/preview.js +45 -17
- package/dist/ui/formatters/preview.js.map +1 -1
- package/dist/ui/formatters/semantic.d.ts +36 -0
- package/dist/ui/formatters/semantic.d.ts.map +1 -0
- package/dist/ui/formatters/semantic.js +98 -0
- package/dist/ui/formatters/semantic.js.map +1 -0
- package/dist/ui/formatters/status.d.ts +1 -1
- package/dist/ui/formatters/status.d.ts.map +1 -1
- package/dist/ui/formatters/status.js +9 -31
- package/dist/ui/formatters/status.js.map +1 -1
- package/dist/ui/formatting.d.ts +2 -270
- package/dist/ui/formatting.d.ts.map +1 -1
- package/dist/ui/formatting.js +8 -331
- package/dist/ui/formatting.js.map +1 -1
- package/dist/ui/logging/index.d.ts +1 -1
- package/dist/ui/logging/index.d.ts.map +1 -1
- package/dist/ui/logging/index.js +1 -1
- package/dist/ui/logging/index.js.map +1 -1
- package/dist/ui/logging/logger.d.ts +3 -23
- package/dist/ui/logging/logger.d.ts.map +1 -1
- package/dist/ui/logging/logger.js +2 -27
- package/dist/ui/logging/logger.js.map +1 -1
- package/dist/ui/messages/chrome.d.ts +15 -7
- package/dist/ui/messages/chrome.d.ts.map +1 -1
- package/dist/ui/messages/chrome.js +23 -32
- package/dist/ui/messages/chrome.js.map +1 -1
- package/dist/ui/messages/commands.d.ts +9 -19
- package/dist/ui/messages/commands.d.ts.map +1 -1
- package/dist/ui/messages/commands.js +14 -51
- package/dist/ui/messages/commands.js.map +1 -1
- package/dist/ui/messages/consoleMessages.d.ts +1 -1
- package/dist/ui/messages/consoleMessages.d.ts.map +1 -1
- package/dist/ui/messages/consoleMessages.js +3 -6
- package/dist/ui/messages/consoleMessages.js.map +1 -1
- package/dist/ui/messages/debug.d.ts +0 -14
- package/dist/ui/messages/debug.d.ts.map +1 -1
- package/dist/ui/messages/debug.js +0 -18
- package/dist/ui/messages/debug.js.map +1 -1
- package/dist/ui/messages/errors.d.ts +0 -34
- package/dist/ui/messages/errors.d.ts.map +1 -1
- package/dist/ui/messages/errors.js +3 -81
- package/dist/ui/messages/errors.js.map +1 -1
- package/dist/ui/messages/internal.d.ts +0 -7
- package/dist/ui/messages/internal.d.ts.map +1 -1
- package/dist/ui/messages/internal.js +0 -12
- package/dist/ui/messages/internal.js.map +1 -1
- package/dist/ui/messages/preview.d.ts +14 -1
- package/dist/ui/messages/preview.d.ts.map +1 -1
- package/dist/ui/messages/preview.js +24 -7
- package/dist/ui/messages/preview.js.map +1 -1
- package/dist/ui/messages/session.d.ts.map +1 -1
- package/dist/ui/messages/session.js +7 -23
- package/dist/ui/messages/session.js.map +1 -1
- package/dist/ui/messages/validation.d.ts.map +1 -1
- package/dist/ui/messages/validation.js +7 -8
- package/dist/ui/messages/validation.js.map +1 -1
- package/dist/utils/__tests__/atomicFile.test.d.ts +2 -0
- package/dist/utils/__tests__/atomicFile.test.d.ts.map +1 -0
- package/dist/utils/__tests__/atomicFile.test.js +43 -0
- package/dist/utils/__tests__/atomicFile.test.js.map +1 -0
- package/dist/utils/__tests__/errors.unit.test.d.ts +12 -0
- package/dist/utils/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/errors.unit.test.js +255 -0
- package/dist/utils/__tests__/errors.unit.test.js.map +1 -0
- package/dist/utils/__tests__/http.unit.test.d.ts +12 -0
- package/dist/utils/__tests__/http.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/http.unit.test.js +218 -0
- package/dist/utils/__tests__/http.unit.test.js.map +1 -0
- package/dist/utils/__tests__/objects.test.d.ts +2 -0
- package/dist/utils/__tests__/objects.test.d.ts.map +1 -0
- package/dist/utils/__tests__/objects.test.js +50 -0
- package/dist/utils/__tests__/objects.test.js.map +1 -0
- package/dist/utils/__tests__/process.unit.test.d.ts +14 -0
- package/dist/utils/__tests__/process.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/process.unit.test.js +124 -0
- package/dist/utils/__tests__/process.unit.test.js.map +1 -0
- package/dist/utils/__tests__/session.contract.test.js +14 -4
- package/dist/utils/__tests__/session.contract.test.js.map +1 -1
- package/dist/utils/__tests__/url.test.d.ts +2 -0
- package/dist/utils/__tests__/url.test.d.ts.map +1 -0
- package/dist/utils/__tests__/url.test.js +42 -0
- package/dist/utils/__tests__/url.test.js.map +1 -0
- package/dist/utils/atomicFile.d.ts +31 -5
- package/dist/utils/atomicFile.d.ts.map +1 -1
- package/dist/utils/atomicFile.js +52 -13
- package/dist/utils/atomicFile.js.map +1 -1
- package/dist/utils/concurrency.d.ts +54 -0
- package/dist/utils/concurrency.d.ts.map +1 -0
- package/dist/utils/concurrency.js +78 -0
- package/dist/utils/concurrency.js.map +1 -0
- package/dist/utils/daemonErrors.d.ts +60 -0
- package/dist/utils/daemonErrors.d.ts.map +1 -0
- package/dist/utils/daemonErrors.js +58 -0
- package/dist/utils/daemonErrors.js.map +1 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +33 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exitCodes.d.ts +41 -5
- package/dist/utils/exitCodes.d.ts.map +1 -1
- package/dist/utils/exitCodes.js +43 -9
- package/dist/utils/exitCodes.js.map +1 -1
- package/dist/utils/http.d.ts +9 -4
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/http.js +44 -10
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/levenshtein.d.ts +45 -0
- package/dist/utils/levenshtein.d.ts.map +1 -0
- package/dist/utils/levenshtein.js +85 -0
- package/dist/utils/levenshtein.js.map +1 -0
- package/dist/utils/objects.d.ts +16 -1
- package/dist/utils/objects.d.ts.map +1 -1
- package/dist/utils/objects.js +16 -1
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/process.d.ts +45 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +91 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/url.d.ts +10 -3
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +42 -29
- package/dist/utils/url.js.map +1 -1
- package/dist/utils/validation.d.ts +101 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +131 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +22 -1
- package/dist/commands/dom.d.ts.map +0 -1
- package/dist/commands/dom.js +0 -244
- package/dist/commands/dom.js.map +0 -1
- package/dist/commands/domEvalHelpers.d.ts.map +0 -1
- package/dist/commands/domEvalHelpers.js.map +0 -1
- package/dist/commands/domOptionsBuilder.d.ts +0 -67
- package/dist/commands/domOptionsBuilder.d.ts.map +0 -1
- package/dist/commands/domOptionsBuilder.js +0 -86
- package/dist/commands/domOptionsBuilder.js.map +0 -1
- package/dist/commands/domSelectorParser.d.ts +0 -20
- package/dist/commands/domSelectorParser.d.ts.map +0 -1
- package/dist/commands/domSelectorParser.js +0 -20
- package/dist/commands/domSelectorParser.js.map +0 -1
- package/dist/commands/shared/OutputBuilder.d.ts.map +0 -1
- package/dist/commands/shared/OutputBuilder.js.map +0 -1
- package/dist/commands/shared/daemonSessionController.d.ts.map +0 -1
- package/dist/commands/shared/daemonSessionController.js.map +0 -1
- package/dist/commands/shared/sessionController.d.ts +0 -21
- package/dist/commands/shared/sessionController.d.ts.map +0 -1
- package/dist/commands/shared/sessionController.js +0 -54
- package/dist/commands/shared/sessionController.js.map +0 -1
- package/dist/connection/__tests__/finder.contract.test.d.ts +0 -2
- package/dist/connection/__tests__/finder.contract.test.d.ts.map +0 -1
- package/dist/connection/__tests__/finder.contract.test.js +0 -239
- package/dist/connection/__tests__/finder.contract.test.js.map +0 -1
- package/dist/connection/domOperations.d.ts +0 -48
- package/dist/connection/domOperations.d.ts.map +0 -1
- package/dist/connection/domOperations.js +0 -106
- package/dist/connection/domOperations.js.map +0 -1
- package/dist/connection/finder.d.ts +0 -12
- package/dist/connection/finder.d.ts.map +0 -1
- package/dist/connection/finder.js +0 -17
- package/dist/connection/finder.js.map +0 -1
- package/dist/ipc/commands.d.ts +0 -260
- package/dist/ipc/commands.d.ts.map +0 -1
- package/dist/ipc/commands.js +0 -77
- package/dist/ipc/commands.js.map +0 -1
- package/dist/ipc/responseValidator.d.ts.map +0 -1
- package/dist/ipc/responseValidator.js.map +0 -1
- package/dist/ipc/types.d.ts +0 -226
- package/dist/ipc/types.d.ts.map +0 -1
- package/dist/ipc/types.js.map +0 -1
- package/dist/session/fileOps.d.ts +0 -25
- package/dist/session/fileOps.d.ts.map +0 -1
- package/dist/session/fileOps.js +0 -39
- package/dist/session/fileOps.js.map +0 -1
- package/dist/session/queryCache.d.ts +0 -36
- package/dist/session/queryCache.d.ts.map +0 -1
- package/dist/session/queryCache.js +0 -66
- package/dist/session/queryCache.js.map +0 -1
- /package/dist/ipc/{responseValidator.d.ts → utils/responseValidator.d.ts} +0 -0
|
@@ -2,14 +2,24 @@
|
|
|
2
2
|
* Atomic file operations using tmp-file-then-rename pattern.
|
|
3
3
|
*
|
|
4
4
|
* Provides safe file writing that prevents corruption from interrupted writes
|
|
5
|
-
* or concurrent access by using
|
|
5
|
+
* or concurrent access by using unique temporary files and atomic rename operation.
|
|
6
6
|
*/
|
|
7
7
|
export declare class AtomicFileWriter {
|
|
8
|
+
/**
|
|
9
|
+
* Generate a unique temporary file path.
|
|
10
|
+
*
|
|
11
|
+
* Uses process PID and random UUID to ensure uniqueness across concurrent processes.
|
|
12
|
+
*
|
|
13
|
+
* @param filePath - Target file path
|
|
14
|
+
* @returns Unique temporary file path
|
|
15
|
+
*/
|
|
16
|
+
private static getTempPath;
|
|
8
17
|
/**
|
|
9
18
|
* Write data to a file atomically (synchronous).
|
|
10
19
|
*
|
|
11
|
-
* Creates a temporary file, writes the data, then atomically renames it to the target path.
|
|
12
|
-
* This ensures the target file is never in a partially written state
|
|
20
|
+
* Creates a unique temporary file, writes the data, then atomically renames it to the target path.
|
|
21
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
22
|
+
* from concurrent writes by different processes.
|
|
13
23
|
*
|
|
14
24
|
* @param filePath - Target file path
|
|
15
25
|
* @param data - Data to write
|
|
@@ -22,8 +32,9 @@ export declare class AtomicFileWriter {
|
|
|
22
32
|
/**
|
|
23
33
|
* Write data to a file atomically (asynchronous).
|
|
24
34
|
*
|
|
25
|
-
* Creates a temporary file, writes the data, then atomically renames it to the target path.
|
|
26
|
-
* This ensures the target file is never in a partially written state
|
|
35
|
+
* Creates a unique temporary file, writes the data, then atomically renames it to the target path.
|
|
36
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
37
|
+
* from concurrent writes by different processes.
|
|
27
38
|
*
|
|
28
39
|
* @param filePath - Target file path
|
|
29
40
|
* @param data - Data to write
|
|
@@ -34,5 +45,20 @@ export declare class AtomicFileWriter {
|
|
|
34
45
|
static writeAsync(filePath: string, data: string, options?: {
|
|
35
46
|
encoding?: BufferEncoding;
|
|
36
47
|
}): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Write binary data (Buffer) to a file atomically (asynchronous).
|
|
50
|
+
*
|
|
51
|
+
* Creates a unique temporary file, writes the binary data, then atomically renames it to the target path.
|
|
52
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
53
|
+
* from concurrent writes by different processes.
|
|
54
|
+
*
|
|
55
|
+
* Useful for screenshots, images, and other binary file exports.
|
|
56
|
+
*
|
|
57
|
+
* @param filePath - Target file path
|
|
58
|
+
* @param buffer - Binary data to write
|
|
59
|
+
* @returns Promise that resolves when write completes
|
|
60
|
+
* @throws Error if write operation fails
|
|
61
|
+
*/
|
|
62
|
+
static writeBufferAsync(filePath: string, buffer: Buffer): Promise<void>;
|
|
37
63
|
}
|
|
38
64
|
//# sourceMappingURL=atomicFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomicFile.d.ts","sourceRoot":"","sources":["../../src/utils/atomicFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"atomicFile.d.ts","sourceRoot":"","sources":["../../src/utils/atomicFile.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAK1B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,SAAS,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAO,GAC1C,IAAI;IAgBP;;;;;;;;;;;;OAYG;WACU,UAAU,CACrB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAO,GAC1C,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;;;;;;;;OAaG;WACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAe/E"}
|
package/dist/utils/atomicFile.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
+
import * as crypto from 'crypto';
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
/**
|
|
3
4
|
* Atomic file operations using tmp-file-then-rename pattern.
|
|
4
5
|
*
|
|
5
6
|
* Provides safe file writing that prevents corruption from interrupted writes
|
|
6
|
-
* or concurrent access by using
|
|
7
|
+
* or concurrent access by using unique temporary files and atomic rename operation.
|
|
7
8
|
*/
|
|
8
9
|
export class AtomicFileWriter {
|
|
10
|
+
/**
|
|
11
|
+
* Generate a unique temporary file path.
|
|
12
|
+
*
|
|
13
|
+
* Uses process PID and random UUID to ensure uniqueness across concurrent processes.
|
|
14
|
+
*
|
|
15
|
+
* @param filePath - Target file path
|
|
16
|
+
* @returns Unique temporary file path
|
|
17
|
+
*/
|
|
18
|
+
static getTempPath(filePath) {
|
|
19
|
+
const uuid = crypto.randomUUID();
|
|
20
|
+
return `${filePath}.${process.pid}.${uuid}.tmp`;
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Write data to a file atomically (synchronous).
|
|
11
24
|
*
|
|
12
|
-
* Creates a temporary file, writes the data, then atomically renames it to the target path.
|
|
13
|
-
* This ensures the target file is never in a partially written state
|
|
25
|
+
* Creates a unique temporary file, writes the data, then atomically renames it to the target path.
|
|
26
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
27
|
+
* from concurrent writes by different processes.
|
|
14
28
|
*
|
|
15
29
|
* @param filePath - Target file path
|
|
16
30
|
* @param data - Data to write
|
|
@@ -18,15 +32,12 @@ export class AtomicFileWriter {
|
|
|
18
32
|
* @throws Error if write operation fails
|
|
19
33
|
*/
|
|
20
34
|
static writeSync(filePath, data, options = {}) {
|
|
21
|
-
const tmpPath = filePath
|
|
35
|
+
const tmpPath = this.getTempPath(filePath);
|
|
22
36
|
try {
|
|
23
|
-
// Write to temporary file first
|
|
24
37
|
fs.writeFileSync(tmpPath, data, { encoding: options.encoding ?? 'utf-8' });
|
|
25
|
-
// Atomically rename to target path
|
|
26
38
|
fs.renameSync(tmpPath, filePath);
|
|
27
39
|
}
|
|
28
40
|
catch (error) {
|
|
29
|
-
// Clean up temporary file on error
|
|
30
41
|
try {
|
|
31
42
|
fs.unlinkSync(tmpPath);
|
|
32
43
|
}
|
|
@@ -39,8 +50,9 @@ export class AtomicFileWriter {
|
|
|
39
50
|
/**
|
|
40
51
|
* Write data to a file atomically (asynchronous).
|
|
41
52
|
*
|
|
42
|
-
* Creates a temporary file, writes the data, then atomically renames it to the target path.
|
|
43
|
-
* This ensures the target file is never in a partially written state
|
|
53
|
+
* Creates a unique temporary file, writes the data, then atomically renames it to the target path.
|
|
54
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
55
|
+
* from concurrent writes by different processes.
|
|
44
56
|
*
|
|
45
57
|
* @param filePath - Target file path
|
|
46
58
|
* @param data - Data to write
|
|
@@ -49,15 +61,42 @@ export class AtomicFileWriter {
|
|
|
49
61
|
* @throws Error if write operation fails
|
|
50
62
|
*/
|
|
51
63
|
static async writeAsync(filePath, data, options = {}) {
|
|
52
|
-
const tmpPath = filePath
|
|
64
|
+
const tmpPath = this.getTempPath(filePath);
|
|
53
65
|
try {
|
|
54
|
-
// Write to temporary file first
|
|
55
66
|
await fs.promises.writeFile(tmpPath, data, { encoding: options.encoding ?? 'utf-8' });
|
|
56
|
-
// Atomically rename to target path
|
|
57
67
|
await fs.promises.rename(tmpPath, filePath);
|
|
58
68
|
}
|
|
59
69
|
catch (error) {
|
|
60
|
-
|
|
70
|
+
try {
|
|
71
|
+
await fs.promises.unlink(tmpPath);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Ignore cleanup errors
|
|
75
|
+
}
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Write binary data (Buffer) to a file atomically (asynchronous).
|
|
81
|
+
*
|
|
82
|
+
* Creates a unique temporary file, writes the binary data, then atomically renames it to the target path.
|
|
83
|
+
* This ensures the target file is never in a partially written state and prevents corruption
|
|
84
|
+
* from concurrent writes by different processes.
|
|
85
|
+
*
|
|
86
|
+
* Useful for screenshots, images, and other binary file exports.
|
|
87
|
+
*
|
|
88
|
+
* @param filePath - Target file path
|
|
89
|
+
* @param buffer - Binary data to write
|
|
90
|
+
* @returns Promise that resolves when write completes
|
|
91
|
+
* @throws Error if write operation fails
|
|
92
|
+
*/
|
|
93
|
+
static async writeBufferAsync(filePath, buffer) {
|
|
94
|
+
const tmpPath = this.getTempPath(filePath);
|
|
95
|
+
try {
|
|
96
|
+
await fs.promises.writeFile(tmpPath, buffer);
|
|
97
|
+
await fs.promises.rename(tmpPath, filePath);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
61
100
|
try {
|
|
62
101
|
await fs.promises.unlink(tmpPath);
|
|
63
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomicFile.js","sourceRoot":"","sources":["../../src/utils/atomicFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAC3B
|
|
1
|
+
{"version":3,"file":"atomicFile.js","sourceRoot":"","sources":["../../src/utils/atomicFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;OAOG;IACK,MAAM,CAAC,WAAW,CAAC,QAAgB;QACzC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,SAAS,CACd,QAAgB,EAChB,IAAY,EACZ,UAAyC,EAAE;QAE3C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,CAAC;YAC3E,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,QAAgB,EAChB,IAAY,EACZ,UAAyC,EAAE;QAE3C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,CAAC;YACtF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAgB,EAAE,MAAc;QAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC7C,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom concurrency limiter for controlling parallel async operations.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Limits the number of concurrent async operations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const limiter = new ConcurrencyLimiter(5);
|
|
10
|
+
* const results = await Promise.all(
|
|
11
|
+
* tasks.map(task => limiter.run(() => performTask(task)))
|
|
12
|
+
* );
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConcurrencyLimiter {
|
|
16
|
+
private readonly limit;
|
|
17
|
+
private running;
|
|
18
|
+
private queue;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new concurrency limiter.
|
|
21
|
+
*
|
|
22
|
+
* @param limit - Maximum number of concurrent operations
|
|
23
|
+
*/
|
|
24
|
+
constructor(limit: number);
|
|
25
|
+
/**
|
|
26
|
+
* Executes an async function with concurrency control.
|
|
27
|
+
*
|
|
28
|
+
* @param fn - Async function to execute
|
|
29
|
+
* @returns Promise resolving to the function's result
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const limiter = new ConcurrencyLimiter(3);
|
|
34
|
+
* const result = await limiter.run(async () => {
|
|
35
|
+
* const response = await fetch(url);
|
|
36
|
+
* return response.json();
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
run<T>(fn: () => Promise<T>): Promise<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the current number of running operations.
|
|
43
|
+
*
|
|
44
|
+
* @returns Number of currently executing operations
|
|
45
|
+
*/
|
|
46
|
+
getRunningCount(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the current queue size.
|
|
49
|
+
*
|
|
50
|
+
* @returns Number of operations waiting to execute
|
|
51
|
+
*/
|
|
52
|
+
getQueueSize(): number;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=concurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../../src/utils/concurrency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;GAUG;AACH,qBAAa,kBAAkB;IASjB,OAAO,CAAC,QAAQ,CAAC,KAAK;IARlC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAAyB;IAEtC;;;;OAIG;gBAC0B,KAAK,EAAE,MAAM;IAM1C;;;;;;;;;;;;;;OAcG;IACG,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAiB9C;;;;OAIG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACH,YAAY,IAAI,MAAM;CAGvB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom concurrency limiter for controlling parallel async operations.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Limits the number of concurrent async operations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const limiter = new ConcurrencyLimiter(5);
|
|
10
|
+
* const results = await Promise.all(
|
|
11
|
+
* tasks.map(task => limiter.run(() => performTask(task)))
|
|
12
|
+
* );
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class ConcurrencyLimiter {
|
|
16
|
+
limit;
|
|
17
|
+
running = 0;
|
|
18
|
+
queue = [];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new concurrency limiter.
|
|
21
|
+
*
|
|
22
|
+
* @param limit - Maximum number of concurrent operations
|
|
23
|
+
*/
|
|
24
|
+
constructor(limit) {
|
|
25
|
+
this.limit = limit;
|
|
26
|
+
if (limit < 1) {
|
|
27
|
+
throw new Error('Concurrency limit must be at least 1');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Executes an async function with concurrency control.
|
|
32
|
+
*
|
|
33
|
+
* @param fn - Async function to execute
|
|
34
|
+
* @returns Promise resolving to the function's result
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const limiter = new ConcurrencyLimiter(3);
|
|
39
|
+
* const result = await limiter.run(async () => {
|
|
40
|
+
* const response = await fetch(url);
|
|
41
|
+
* return response.json();
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
async run(fn) {
|
|
46
|
+
while (this.running >= this.limit) {
|
|
47
|
+
await new Promise((resolve) => this.queue.push(resolve));
|
|
48
|
+
}
|
|
49
|
+
this.running++;
|
|
50
|
+
try {
|
|
51
|
+
return await fn();
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
this.running--;
|
|
55
|
+
const next = this.queue.shift();
|
|
56
|
+
if (next) {
|
|
57
|
+
next();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets the current number of running operations.
|
|
63
|
+
*
|
|
64
|
+
* @returns Number of currently executing operations
|
|
65
|
+
*/
|
|
66
|
+
getRunningCount() {
|
|
67
|
+
return this.running;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets the current queue size.
|
|
71
|
+
*
|
|
72
|
+
* @returns Number of operations waiting to execute
|
|
73
|
+
*/
|
|
74
|
+
getQueueSize() {
|
|
75
|
+
return this.queue.length;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.js","sourceRoot":"","sources":["../../src/utils/concurrency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IASA;IARrB,OAAO,GAAG,CAAC,CAAC;IACZ,KAAK,GAAsB,EAAE,CAAC;IAEtC;;;;OAIG;IACH,YAA6B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QACxC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,GAAG,CAAI,EAAoB;QAC/B,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAClC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,EAAE,CAAC;YACT,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for handling daemon connection errors in commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling for peek, tail, and other commands
|
|
5
|
+
* that communicate with the daemon via IPC.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Options for daemon connection error handling.
|
|
9
|
+
*/
|
|
10
|
+
export interface DaemonErrorOptions {
|
|
11
|
+
/** Use JSON output format */
|
|
12
|
+
json?: boolean | undefined;
|
|
13
|
+
/** Follow/watch mode (don't exit, show retry message) */
|
|
14
|
+
follow?: boolean | undefined;
|
|
15
|
+
/** Retry interval in milliseconds (for display message) */
|
|
16
|
+
retryIntervalMs?: number | undefined;
|
|
17
|
+
/** Custom exit code (defaults to RESOURCE_NOT_FOUND) */
|
|
18
|
+
exitCode?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of handling a daemon connection error.
|
|
22
|
+
*/
|
|
23
|
+
export interface DaemonErrorResult {
|
|
24
|
+
/** Whether the process should exit */
|
|
25
|
+
shouldExit: boolean;
|
|
26
|
+
/** Exit code to use if exiting */
|
|
27
|
+
exitCode?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handle daemon connection errors with consistent formatting and behavior.
|
|
31
|
+
*
|
|
32
|
+
* Formats and logs the error appropriately based on output mode.
|
|
33
|
+
* Returns whether the caller should exit and with what code.
|
|
34
|
+
*
|
|
35
|
+
* @param error - Error message to display
|
|
36
|
+
* @param options - Error handling options
|
|
37
|
+
* @returns Result indicating whether to exit
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // One-time command
|
|
42
|
+
* const result = handleDaemonConnectionError('Daemon not running', {
|
|
43
|
+
* json: options.json,
|
|
44
|
+
* exitCode: EXIT_CODES.RESOURCE_NOT_FOUND
|
|
45
|
+
* });
|
|
46
|
+
* if (result.shouldExit) {
|
|
47
|
+
* process.exit(result.exitCode);
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* // Follow mode (retries)
|
|
51
|
+
* handleDaemonConnectionError('Connection lost', {
|
|
52
|
+
* json: options.json,
|
|
53
|
+
* follow: true,
|
|
54
|
+
* retryIntervalMs: 1000
|
|
55
|
+
* });
|
|
56
|
+
* // Returns { shouldExit: false }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function handleDaemonConnectionError(error: string, options: DaemonErrorOptions): DaemonErrorResult;
|
|
60
|
+
//# sourceMappingURL=daemonErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonErrors.d.ts","sourceRoot":"","sources":["../../src/utils/daemonErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CA0BnB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for handling daemon connection errors in commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling for peek, tail, and other commands
|
|
5
|
+
* that communicate with the daemon via IPC.
|
|
6
|
+
*/
|
|
7
|
+
import { OutputBuilder } from '../ui/OutputBuilder.js';
|
|
8
|
+
import { genericError } from '../ui/messages/errors.js';
|
|
9
|
+
import { connectionLostRetryMessage, connectionLostStopHintMessage, } from '../ui/messages/preview.js';
|
|
10
|
+
import { EXIT_CODES } from '../utils/exitCodes.js';
|
|
11
|
+
/**
|
|
12
|
+
* Handle daemon connection errors with consistent formatting and behavior.
|
|
13
|
+
*
|
|
14
|
+
* Formats and logs the error appropriately based on output mode.
|
|
15
|
+
* Returns whether the caller should exit and with what code.
|
|
16
|
+
*
|
|
17
|
+
* @param error - Error message to display
|
|
18
|
+
* @param options - Error handling options
|
|
19
|
+
* @returns Result indicating whether to exit
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // One-time command
|
|
24
|
+
* const result = handleDaemonConnectionError('Daemon not running', {
|
|
25
|
+
* json: options.json,
|
|
26
|
+
* exitCode: EXIT_CODES.RESOURCE_NOT_FOUND
|
|
27
|
+
* });
|
|
28
|
+
* if (result.shouldExit) {
|
|
29
|
+
* process.exit(result.exitCode);
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* // Follow mode (retries)
|
|
33
|
+
* handleDaemonConnectionError('Connection lost', {
|
|
34
|
+
* json: options.json,
|
|
35
|
+
* follow: true,
|
|
36
|
+
* retryIntervalMs: 1000
|
|
37
|
+
* });
|
|
38
|
+
* // Returns { shouldExit: false }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function handleDaemonConnectionError(error, options) {
|
|
42
|
+
const { json = false, follow = false, retryIntervalMs = 1000, exitCode = EXIT_CODES.RESOURCE_NOT_FOUND, } = options;
|
|
43
|
+
const retryMessage = retryIntervalMs >= 1000 ? `${retryIntervalMs / 1000}s` : `${retryIntervalMs}ms`;
|
|
44
|
+
const timestamp = new Date().toISOString();
|
|
45
|
+
if (json) {
|
|
46
|
+
console.log(JSON.stringify(OutputBuilder.buildJsonError(error, { exitCode }), null, 2));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.error(genericError(error));
|
|
50
|
+
}
|
|
51
|
+
if (!follow) {
|
|
52
|
+
return { shouldExit: true, exitCode };
|
|
53
|
+
}
|
|
54
|
+
console.error(connectionLostRetryMessage(timestamp, retryMessage));
|
|
55
|
+
console.error(connectionLostStopHintMessage());
|
|
56
|
+
return { shouldExit: false };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=daemonErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonErrors.js","sourceRoot":"","sources":["../../src/utils/daemonErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AA0BlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAa,EACb,OAA2B;IAE3B,MAAM,EACJ,IAAI,GAAG,KAAK,EACZ,MAAM,GAAG,KAAK,EACd,eAAe,GAAG,IAAI,EACtB,QAAQ,GAAG,UAAU,CAAC,kBAAkB,GACzC,GAAG,OAAO,CAAC;IAEZ,MAAM,YAAY,GAChB,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,eAAe,IAAI,CAAC;IAElF,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE3C,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities.
|
|
3
|
+
*
|
|
4
|
+
* Pure utility functions for error message extraction.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Extract error message from unknown error type.
|
|
8
|
+
*
|
|
9
|
+
* Safely extracts error messages from various error types:
|
|
10
|
+
* - Error instances → error.message
|
|
11
|
+
* - Unknown types → String(error)
|
|
12
|
+
*
|
|
13
|
+
* Useful for error handling when error type is unknown.
|
|
14
|
+
*
|
|
15
|
+
* @param error - Error of unknown type
|
|
16
|
+
* @returns Error message string
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* try {
|
|
21
|
+
* await someOperation();
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* console.error(`Failed: ${getErrorMessage(error)}`);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKtD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities.
|
|
3
|
+
*
|
|
4
|
+
* Pure utility functions for error message extraction.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Extract error message from unknown error type.
|
|
8
|
+
*
|
|
9
|
+
* Safely extracts error messages from various error types:
|
|
10
|
+
* - Error instances → error.message
|
|
11
|
+
* - Unknown types → String(error)
|
|
12
|
+
*
|
|
13
|
+
* Useful for error handling when error type is unknown.
|
|
14
|
+
*
|
|
15
|
+
* @param error - Error of unknown type
|
|
16
|
+
* @returns Error message string
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* try {
|
|
21
|
+
* await someOperation();
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* console.error(`Failed: ${getErrorMessage(error)}`);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function getErrorMessage(error) {
|
|
28
|
+
if (error instanceof Error) {
|
|
29
|
+
return error.message;
|
|
30
|
+
}
|
|
31
|
+
return String(error);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,32 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Semantic exit codes for agent-friendly error handling.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
4
|
+
* **STABILITY: These exit codes are part of bdg's stable public API.**
|
|
5
|
+
*
|
|
6
|
+
* Exit codes follow semantic ranges for predictable automation:
|
|
7
|
+
* - **0**: Success (command completed successfully)
|
|
8
|
+
* - **1**: Generic failure (backward compatibility, avoid in new code)
|
|
9
|
+
* - **80-99**: User errors (invalid input, permissions, resource issues)
|
|
10
|
+
* - **100-119**: Software errors (bugs, integration failures, timeouts)
|
|
11
|
+
*
|
|
12
|
+
* **Versioning guarantees:**
|
|
13
|
+
* - Exit code values are **stable** and will not change in minor versions
|
|
14
|
+
* - New exit codes may be added in minor versions (within existing ranges)
|
|
15
|
+
* - Existing codes will only be removed in major versions with deprecation notice
|
|
16
|
+
* - Exit code semantics (meaning) will remain consistent across versions
|
|
17
|
+
*
|
|
18
|
+
* **For automation users:**
|
|
19
|
+
* - Check specific exit codes (e.g., 83 for "resource not found")
|
|
20
|
+
* - Use ranges for category detection (80-99 = user error, 100-119 = software error)
|
|
21
|
+
* - Exit code 0 guarantees success, non-zero indicates failure
|
|
22
|
+
*
|
|
23
|
+
* **Migration policy:**
|
|
24
|
+
* - Deprecated codes will be documented in CHANGELOG.md with migration path
|
|
25
|
+
* - Deprecated codes will remain functional for at least one major version
|
|
9
26
|
*
|
|
10
27
|
* Reference: https://developer.squareup.com/blog/command-line-observability-with-semantic-exit-codes/
|
|
11
28
|
*/
|
|
12
29
|
/**
|
|
13
30
|
* Exit code constants following semantic ranges.
|
|
31
|
+
*
|
|
32
|
+
* **These values are stable API** - use confidently in automation scripts.
|
|
14
33
|
*/
|
|
15
34
|
export declare const EXIT_CODES: {
|
|
35
|
+
/** Command completed successfully */
|
|
16
36
|
readonly SUCCESS: 0;
|
|
37
|
+
/** Generic failure (use specific codes when possible) */
|
|
17
38
|
readonly GENERIC_FAILURE: 1;
|
|
39
|
+
/** Invalid URL format or unreachable URL */
|
|
18
40
|
readonly INVALID_URL: 80;
|
|
41
|
+
/** Invalid command-line arguments or options */
|
|
19
42
|
readonly INVALID_ARGUMENTS: 81;
|
|
43
|
+
/** Insufficient permissions for operation */
|
|
20
44
|
readonly PERMISSION_DENIED: 82;
|
|
45
|
+
/** Requested resource not found (session, file, etc.) */
|
|
21
46
|
readonly RESOURCE_NOT_FOUND: 83;
|
|
47
|
+
/** Resource already exists (duplicate session, etc.) */
|
|
22
48
|
readonly RESOURCE_ALREADY_EXISTS: 84;
|
|
49
|
+
/** Resource is locked or busy */
|
|
23
50
|
readonly RESOURCE_BUSY: 85;
|
|
51
|
+
/** Daemon already running when trying to start */
|
|
24
52
|
readonly DAEMON_ALREADY_RUNNING: 86;
|
|
53
|
+
/** Chrome browser failed to launch */
|
|
25
54
|
readonly CHROME_LAUNCH_FAILURE: 100;
|
|
55
|
+
/** CDP connection failed */
|
|
26
56
|
readonly CDP_CONNECTION_FAILURE: 101;
|
|
57
|
+
/** CDP operation timed out */
|
|
27
58
|
readonly CDP_TIMEOUT: 102;
|
|
59
|
+
/** Session file read/write error */
|
|
28
60
|
readonly SESSION_FILE_ERROR: 103;
|
|
61
|
+
/** Unhandled exception in code */
|
|
29
62
|
readonly UNHANDLED_EXCEPTION: 104;
|
|
63
|
+
/** Signal handler error */
|
|
30
64
|
readonly SIGNAL_HANDLER_ERROR: 105;
|
|
65
|
+
/** Generic software error (use specific codes when possible) */
|
|
66
|
+
readonly SOFTWARE_ERROR: 110;
|
|
31
67
|
};
|
|
32
68
|
//# sourceMappingURL=exitCodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitCodes.d.ts","sourceRoot":"","sources":["../../src/utils/exitCodes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"exitCodes.d.ts","sourceRoot":"","sources":["../../src/utils/exitCodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU;IACrB,qCAAqC;;IAGrC,yDAAyD;;IAKzD,4CAA4C;;IAG5C,gDAAgD;;IAGhD,6CAA6C;;IAG7C,yDAAyD;;IAGzD,wDAAwD;;IAGxD,iCAAiC;;IAGjC,kDAAkD;;IAKlD,sCAAsC;;IAGtC,4BAA4B;;IAG5B,8BAA8B;;IAG9B,oCAAoC;;IAGpC,kCAAkC;;IAGlC,2BAA2B;;IAG3B,gEAAgE;;CAExD,CAAC"}
|