browser-debugger-cli 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -4
- package/dist/__tests__/smoke/error-handling.smoke.test.js +0 -11
- package/dist/__tests__/smoke/error-handling.smoke.test.js.map +1 -1
- package/dist/cdp/protocol.d.ts +121 -0
- package/dist/cdp/protocol.d.ts.map +1 -0
- package/dist/cdp/protocol.js +215 -0
- package/dist/cdp/protocol.js.map +1 -0
- package/dist/cdp/schema.d.ts +159 -0
- package/dist/cdp/schema.d.ts.map +1 -0
- package/dist/cdp/schema.js +256 -0
- package/dist/cdp/schema.js.map +1 -0
- package/dist/cdp/types.d.ts +139 -0
- package/dist/cdp/types.d.ts.map +1 -0
- package/dist/cdp/types.js +7 -0
- package/dist/cdp/types.js.map +1 -0
- package/dist/commands/cdp.d.ts +10 -1
- package/dist/commands/cdp.d.ts.map +1 -1
- package/dist/commands/cdp.js +363 -26
- package/dist/commands/cdp.js.map +1 -1
- package/dist/commands/cleanup.js +3 -3
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/dom.d.ts.map +1 -1
- package/dist/commands/dom.js +1 -0
- package/dist/commands/dom.js.map +1 -1
- package/dist/commands/domEvalHelpers.d.ts +2 -15
- package/dist/commands/domEvalHelpers.d.ts.map +1 -1
- package/dist/commands/domEvalHelpers.js +1 -1
- package/dist/commands/domEvalHelpers.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +12 -6
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/shared/CommandRunner.d.ts +2 -0
- package/dist/commands/shared/CommandRunner.d.ts.map +1 -1
- package/dist/commands/shared/CommandRunner.js +13 -1
- 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 +2 -2
- package/dist/commands/shared/commonOptions.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +21 -12
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/stop.js +2 -2
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/tail.d.ts.map +1 -1
- package/dist/commands/tail.js +9 -6
- package/dist/commands/tail.js.map +1 -1
- package/dist/connection/cdp.d.ts.map +1 -1
- package/dist/connection/cdp.js +15 -2
- package/dist/connection/cdp.js.map +1 -1
- package/dist/connection/domOperations.d.ts.map +1 -1
- package/dist/connection/domOperations.js +3 -1
- package/dist/connection/domOperations.js.map +1 -1
- package/dist/connection/handlers.d.ts +34 -2
- package/dist/connection/handlers.d.ts.map +1 -1
- package/dist/connection/handlers.js +28 -2
- package/dist/connection/handlers.js.map +1 -1
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +14 -2
- package/dist/connection/launcher.js.map +1 -1
- package/dist/connection/pageReadiness.d.ts.map +1 -1
- package/dist/connection/pageReadiness.js +6 -6
- package/dist/connection/pageReadiness.js.map +1 -1
- package/dist/connection/typed-cdp.d.ts +144 -0
- package/dist/connection/typed-cdp.d.ts.map +1 -0
- package/dist/connection/typed-cdp.js +120 -0
- package/dist/connection/typed-cdp.js.map +1 -0
- package/dist/daemon/worker/commandRegistry.d.ts.map +1 -1
- package/dist/daemon/worker/commandRegistry.js.map +1 -1
- package/dist/telemetry/__tests__/network.contract.test.js +124 -93
- package/dist/telemetry/__tests__/network.contract.test.js.map +1 -1
- package/dist/telemetry/console.d.ts.map +1 -1
- package/dist/telemetry/console.js +3 -2
- package/dist/telemetry/console.js.map +1 -1
- package/dist/telemetry/dialogs.d.ts.map +1 -1
- package/dist/telemetry/dialogs.js.map +1 -1
- package/dist/telemetry/dom.d.ts.map +1 -1
- package/dist/telemetry/dom.js +3 -1
- package/dist/telemetry/dom.js.map +1 -1
- package/dist/telemetry/navigation.d.ts.map +1 -1
- package/dist/telemetry/navigation.js.map +1 -1
- package/dist/telemetry/network.d.ts.map +1 -1
- package/dist/telemetry/network.js.map +1 -1
- package/dist/types.d.ts +0 -141
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/messages/commands.d.ts +1 -0
- package/dist/ui/messages/commands.d.ts.map +1 -1
- package/dist/ui/messages/commands.js +1 -0
- package/dist/ui/messages/commands.js.map +1 -1
- package/dist/ui/messages/errors.d.ts +30 -3
- package/dist/ui/messages/errors.d.ts.map +1 -1
- package/dist/ui/messages/errors.js +36 -8
- package/dist/ui/messages/errors.js.map +1 -1
- package/dist/ui/messages/session.d.ts.map +1 -1
- package/dist/ui/messages/session.js +5 -4
- package/dist/ui/messages/session.js.map +1 -1
- package/dist/ui/messages/validation.d.ts +22 -4
- package/dist/ui/messages/validation.d.ts.map +1 -1
- package/dist/ui/messages/validation.js +26 -5
- package/dist/ui/messages/validation.js.map +1 -1
- package/package.json +2 -1
- package/dist/cli/commands/__tests__/start.unit.test.d.ts +0 -2
- package/dist/cli/commands/__tests__/start.unit.test.d.ts.map +0 -1
- package/dist/cli/commands/__tests__/start.unit.test.js +0 -131
- package/dist/cli/commands/__tests__/start.unit.test.js.map +0 -1
- package/dist/cli/commands/cleanup.d.ts +0 -9
- package/dist/cli/commands/cleanup.d.ts.map +0 -1
- package/dist/cli/commands/cleanup.js +0 -148
- package/dist/cli/commands/cleanup.js.map +0 -1
- package/dist/cli/commands/details.d.ts +0 -9
- package/dist/cli/commands/details.d.ts.map +0 -1
- package/dist/cli/commands/details.js +0 -120
- package/dist/cli/commands/details.js.map +0 -1
- package/dist/cli/commands/peek.d.ts +0 -9
- package/dist/cli/commands/peek.d.ts.map +0 -1
- package/dist/cli/commands/peek.js +0 -64
- package/dist/cli/commands/peek.js.map +0 -1
- package/dist/cli/commands/query.d.ts +0 -9
- package/dist/cli/commands/query.d.ts.map +0 -1
- package/dist/cli/commands/query.js +0 -125
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/start.d.ts +0 -83
- package/dist/cli/commands/start.d.ts.map +0 -1
- package/dist/cli/commands/start.js +0 -204
- package/dist/cli/commands/start.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -9
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -75
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/stop.d.ts +0 -9
- package/dist/cli/commands/stop.d.ts.map +0 -1
- package/dist/cli/commands/stop.js +0 -133
- package/dist/cli/commands/stop.js.map +0 -1
- package/dist/cli/formatters/detailsFormatter.d.ts +0 -10
- package/dist/cli/formatters/detailsFormatter.d.ts.map +0 -1
- package/dist/cli/formatters/detailsFormatter.js +0 -63
- package/dist/cli/formatters/detailsFormatter.js.map +0 -1
- package/dist/cli/formatters/previewFormatter.d.ts +0 -27
- package/dist/cli/formatters/previewFormatter.d.ts.map +0 -1
- package/dist/cli/formatters/previewFormatter.js +0 -155
- package/dist/cli/formatters/previewFormatter.js.map +0 -1
- package/dist/cli/formatters/statusFormatter.d.ts +0 -42
- package/dist/cli/formatters/statusFormatter.d.ts.map +0 -1
- package/dist/cli/formatters/statusFormatter.js +0 -126
- package/dist/cli/formatters/statusFormatter.js.map +0 -1
- package/dist/cli/handlers/ChromeBootstrap.d.ts +0 -24
- package/dist/cli/handlers/ChromeBootstrap.d.ts.map +0 -1
- package/dist/cli/handlers/ChromeBootstrap.js +0 -50
- package/dist/cli/handlers/ChromeBootstrap.js.map +0 -1
- package/dist/cli/handlers/OutputBuilder.d.ts +0 -59
- package/dist/cli/handlers/OutputBuilder.d.ts.map +0 -1
- package/dist/cli/handlers/OutputBuilder.js +0 -136
- package/dist/cli/handlers/OutputBuilder.js.map +0 -1
- package/dist/cli/handlers/OutputWriter.d.ts +0 -15
- package/dist/cli/handlers/OutputWriter.d.ts.map +0 -1
- package/dist/cli/handlers/OutputWriter.js +0 -34
- package/dist/cli/handlers/OutputWriter.js.map +0 -1
- package/dist/cli/handlers/PreviewWriter.d.ts +0 -52
- package/dist/cli/handlers/PreviewWriter.d.ts.map +0 -1
- package/dist/cli/handlers/PreviewWriter.js +0 -118
- package/dist/cli/handlers/PreviewWriter.js.map +0 -1
- package/dist/cli/handlers/SessionLock.d.ts +0 -16
- package/dist/cli/handlers/SessionLock.d.ts.map +0 -1
- package/dist/cli/handlers/SessionLock.js +0 -35
- package/dist/cli/handlers/SessionLock.js.map +0 -1
- package/dist/cli/handlers/SessionLoop.d.ts +0 -19
- package/dist/cli/handlers/SessionLoop.d.ts.map +0 -1
- package/dist/cli/handlers/SessionLoop.js +0 -47
- package/dist/cli/handlers/SessionLoop.js.map +0 -1
- package/dist/cli/handlers/ShutdownController.d.ts +0 -41
- package/dist/cli/handlers/ShutdownController.d.ts.map +0 -1
- package/dist/cli/handlers/ShutdownController.js +0 -94
- package/dist/cli/handlers/ShutdownController.js.map +0 -1
- package/dist/cli/handlers/SignalHandler.d.ts +0 -35
- package/dist/cli/handlers/SignalHandler.d.ts.map +0 -1
- package/dist/cli/handlers/SignalHandler.js +0 -81
- package/dist/cli/handlers/SignalHandler.js.map +0 -1
- package/dist/cli/handlers/TargetSetup.d.ts +0 -42
- package/dist/cli/handlers/TargetSetup.d.ts.map +0 -1
- package/dist/cli/handlers/TargetSetup.js +0 -87
- package/dist/cli/handlers/TargetSetup.js.map +0 -1
- package/dist/cli/handlers/sessionController.d.ts +0 -62
- package/dist/cli/handlers/sessionController.d.ts.map +0 -1
- package/dist/cli/handlers/sessionController.js +0 -316
- package/dist/cli/handlers/sessionController.js.map +0 -1
- package/dist/cli/registry.d.ts +0 -11
- package/dist/cli/registry.d.ts.map +0 -1
- package/dist/cli/registry.js +0 -21
- package/dist/cli/registry.js.map +0 -1
- package/dist/collectors/console.d.ts +0 -19
- package/dist/collectors/console.d.ts.map +0 -1
- package/dist/collectors/console.js +0 -87
- package/dist/collectors/console.js.map +0 -1
- package/dist/collectors/dom.d.ts +0 -21
- package/dist/collectors/dom.d.ts.map +0 -1
- package/dist/collectors/dom.js +0 -99
- package/dist/collectors/dom.js.map +0 -1
- package/dist/collectors/network.d.ts +0 -32
- package/dist/collectors/network.d.ts.map +0 -1
- package/dist/collectors/network.js +0 -191
- package/dist/collectors/network.js.map +0 -1
- package/dist/connection/tabs.d.ts +0 -52
- package/dist/connection/tabs.d.ts.map +0 -1
- package/dist/connection/tabs.js +0 -227
- package/dist/connection/tabs.js.map +0 -1
- package/dist/help/machineReadableHelp.d.ts +0 -100
- package/dist/help/machineReadableHelp.d.ts.map +0 -1
- package/dist/help/machineReadableHelp.js +0 -139
- package/dist/help/machineReadableHelp.js.map +0 -1
- package/dist/session/BdgSession.d.ts +0 -91
- package/dist/session/BdgSession.d.ts.map +0 -1
- package/dist/session/BdgSession.js +0 -230
- package/dist/session/BdgSession.js.map +0 -1
- package/dist/ui/errors/SystemErrors.d.ts +0 -22
- package/dist/ui/errors/SystemErrors.d.ts.map +0 -1
- package/dist/ui/errors/SystemErrors.js +0 -23
- package/dist/ui/errors/SystemErrors.js.map +0 -1
- package/dist/ui/errors.d.ts +0 -39
- package/dist/ui/errors.d.ts.map +0 -1
- package/dist/ui/errors.js +0 -48
- package/dist/ui/errors.js.map +0 -1
- package/dist/ui/messages/deprecation.d.ts +0 -30
- package/dist/ui/messages/deprecation.d.ts.map +0 -1
- package/dist/ui/messages/deprecation.js +0 -49
- package/dist/ui/messages/deprecation.js.map +0 -1
- package/dist/ui/messages/index.d.ts +0 -12
- package/dist/ui/messages/index.d.ts.map +0 -1
- package/dist/ui/messages/index.js +0 -12
- package/dist/ui/messages/index.js.map +0 -1
- package/dist/utils/__tests__/filters.unit.test.d.ts +0 -2
- package/dist/utils/__tests__/filters.unit.test.d.ts.map +0 -1
- package/dist/utils/__tests__/filters.unit.test.js +0 -239
- package/dist/utils/__tests__/filters.unit.test.js.map +0 -1
- package/dist/utils/cdpHandlers.d.ts +0 -31
- package/dist/utils/cdpHandlers.d.ts.map +0 -1
- package/dist/utils/cdpHandlers.js +0 -38
- package/dist/utils/cdpHandlers.js.map +0 -1
- package/dist/utils/chromeDiagnostics.d.ts +0 -16
- package/dist/utils/chromeDiagnostics.d.ts.map +0 -1
- package/dist/utils/chromeDiagnostics.js +0 -37
- package/dist/utils/chromeDiagnostics.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -82
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -88
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/filters.d.ts +0 -148
- package/dist/utils/filters.d.ts.map +0 -1
- package/dist/utils/filters.js +0 -358
- package/dist/utils/filters.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -98
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -93
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/pageReadiness.d.ts +0 -46
- package/dist/utils/pageReadiness.d.ts.map +0 -1
- package/dist/utils/pageReadiness.js +0 -270
- package/dist/utils/pageReadiness.js.map +0 -1
- package/dist/utils/session.d.ts +0 -200
- package/dist/utils/session.d.ts.map +0 -1
- package/dist/utils/session.js +0 -498
- package/dist/utils/session.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -12
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -20
- package/dist/utils/validation.js.map +0 -1
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { VERSION } from '../../utils/version.js';
|
|
2
|
-
/**
|
|
3
|
-
* Helper: build output payloads for preview/full/final modes with consistent metadata.
|
|
4
|
-
*/
|
|
5
|
-
export class OutputBuilder {
|
|
6
|
-
/**
|
|
7
|
-
* Build session output with consistent metadata.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Configuration for output construction
|
|
10
|
-
* @returns BdgOutput payload
|
|
11
|
-
*/
|
|
12
|
-
static build(options) {
|
|
13
|
-
const { mode, target, startTime, networkRequests, consoleLogs, domData, activeCollectors } = options;
|
|
14
|
-
const baseOutput = {
|
|
15
|
-
version: VERSION,
|
|
16
|
-
success: true,
|
|
17
|
-
timestamp: new Date().toISOString(),
|
|
18
|
-
duration: Date.now() - startTime,
|
|
19
|
-
target: {
|
|
20
|
-
url: target.url,
|
|
21
|
-
title: target.title,
|
|
22
|
-
},
|
|
23
|
-
// Only final outputs are complete (partial=false)
|
|
24
|
-
partial: mode !== 'final',
|
|
25
|
-
};
|
|
26
|
-
if (mode === 'preview') {
|
|
27
|
-
// Lightweight preview: metadata only, last 1000 items
|
|
28
|
-
const previewData = {};
|
|
29
|
-
if (activeCollectors.includes('network')) {
|
|
30
|
-
previewData['network'] = networkRequests.slice(-1000).map((req) => ({
|
|
31
|
-
requestId: req.requestId,
|
|
32
|
-
url: req.url,
|
|
33
|
-
method: req.method,
|
|
34
|
-
timestamp: req.timestamp,
|
|
35
|
-
status: req.status,
|
|
36
|
-
mimeType: req.mimeType,
|
|
37
|
-
// Exclude requestBody, responseBody, headers for lightweight preview
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
if (activeCollectors.includes('console')) {
|
|
41
|
-
previewData['console'] = consoleLogs.slice(-1000).map((msg) => ({
|
|
42
|
-
type: msg.type,
|
|
43
|
-
text: msg.text,
|
|
44
|
-
timestamp: msg.timestamp,
|
|
45
|
-
// Exclude args for lightweight preview
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
// DOM omitted in preview (only captured on stop)
|
|
49
|
-
return {
|
|
50
|
-
...baseOutput,
|
|
51
|
-
data: previewData,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (mode === 'full') {
|
|
55
|
-
// Full mode: complete data with bodies
|
|
56
|
-
const fullData = {};
|
|
57
|
-
if (activeCollectors.includes('network')) {
|
|
58
|
-
fullData['network'] = networkRequests; // All data with bodies
|
|
59
|
-
}
|
|
60
|
-
if (activeCollectors.includes('console')) {
|
|
61
|
-
fullData['console'] = consoleLogs; // All data with args
|
|
62
|
-
}
|
|
63
|
-
// DOM omitted (only captured on stop)
|
|
64
|
-
return {
|
|
65
|
-
...baseOutput,
|
|
66
|
-
data: fullData,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
// Final mode - includes DOM, partial=false
|
|
70
|
-
const finalData = {};
|
|
71
|
-
if (activeCollectors.includes('network')) {
|
|
72
|
-
finalData['network'] = networkRequests;
|
|
73
|
-
}
|
|
74
|
-
if (activeCollectors.includes('console')) {
|
|
75
|
-
finalData['console'] = consoleLogs;
|
|
76
|
-
}
|
|
77
|
-
if (activeCollectors.includes('dom') && domData) {
|
|
78
|
-
finalData['dom'] = domData;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
...baseOutput,
|
|
82
|
-
partial: false,
|
|
83
|
-
data: finalData,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Build error output with consistent structure.
|
|
88
|
-
*
|
|
89
|
-
* @param error - Error object or string
|
|
90
|
-
* @param startTime - Session start timestamp
|
|
91
|
-
* @param target - Optional target information
|
|
92
|
-
* @returns BdgOutput payload with error
|
|
93
|
-
*/
|
|
94
|
-
static buildError(error, startTime, target) {
|
|
95
|
-
return {
|
|
96
|
-
version: VERSION,
|
|
97
|
-
success: false,
|
|
98
|
-
timestamp: new Date().toISOString(),
|
|
99
|
-
duration: Date.now() - startTime,
|
|
100
|
-
target: target ? { url: target.url, title: target.title } : { url: '', title: '' },
|
|
101
|
-
data: {},
|
|
102
|
-
error: error instanceof Error ? error.message : String(error),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Build a simple JSON error response for commands.
|
|
107
|
-
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
108
|
-
*
|
|
109
|
-
* @param error - Error message or Error object
|
|
110
|
-
* @param options - Optional fields (exitCode, additional data)
|
|
111
|
-
* @returns JSON-serializable error object
|
|
112
|
-
*/
|
|
113
|
-
static buildJsonError(error, options) {
|
|
114
|
-
return {
|
|
115
|
-
version: VERSION,
|
|
116
|
-
success: false,
|
|
117
|
-
error: error instanceof Error ? error.message : error,
|
|
118
|
-
...options,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Build a simple JSON success response for commands.
|
|
123
|
-
* Used by commands that don't follow the full BdgOutput structure (stop, cleanup, query).
|
|
124
|
-
*
|
|
125
|
-
* @param data - Response data
|
|
126
|
-
* @returns JSON-serializable success object
|
|
127
|
-
*/
|
|
128
|
-
static buildJsonSuccess(data) {
|
|
129
|
-
return {
|
|
130
|
-
version: VERSION,
|
|
131
|
-
success: true,
|
|
132
|
-
...data,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=OutputBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OutputBuilder.js","sourceRoot":"","sources":["../../../src/cli/handlers/OutputBuilder.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAoB7C;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAA6B;QACxC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,GACxF,OAAO,CAAC;QAEV,MAAM,UAAU,GAAG;YACjB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAChC,MAAM,EAAE;gBACN,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;YACD,kDAAkD;YAClD,OAAO,EAAE,IAAI,KAAK,OAAO;SAC1B,CAAC;QAEF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,sDAAsD;YACtD,MAAM,WAAW,GAA4B,EAAE,CAAC;YAEhD,IAAI,gBAAgB,C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,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CACnB,KAAqB,EACrB,OAAuD;QAEvD,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;YACrD,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAA6B;QACnD,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,IAAI;YACb,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { BdgOutput } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles writing session output to files and console
|
|
4
|
-
*/
|
|
5
|
-
export declare class OutputWriter {
|
|
6
|
-
/**
|
|
7
|
-
* Write session output to file and stdout.
|
|
8
|
-
*
|
|
9
|
-
* @param output - The output payload to write
|
|
10
|
-
* @param exitCode - 0 for success, 1 for error
|
|
11
|
-
* @param compact - If true, use compact JSON format (no indentation)
|
|
12
|
-
*/
|
|
13
|
-
writeSessionOutput(output: BdgOutput, exitCode: 0 | 1, compact?: boolean): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=OutputWriter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OutputWriter.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/OutputWriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI;CAsBvF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { writeSessionOutput } from '../../utils/session.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles writing session output to files and console
|
|
4
|
-
*/
|
|
5
|
-
export class OutputWriter {
|
|
6
|
-
/**
|
|
7
|
-
* Write session output to file and stdout.
|
|
8
|
-
*
|
|
9
|
-
* @param output - The output payload to write
|
|
10
|
-
* @param exitCode - 0 for success, 1 for error
|
|
11
|
-
* @param compact - If true, use compact JSON format (no indentation)
|
|
12
|
-
*/
|
|
13
|
-
writeSessionOutput(output, exitCode, compact = false) {
|
|
14
|
-
// Write output to file for 'bdg stop' to read
|
|
15
|
-
try {
|
|
16
|
-
const message = exitCode === 0 ? 'Writing session output...' : 'Writing error output...';
|
|
17
|
-
console.error(message);
|
|
18
|
-
writeSessionOutput(output, compact);
|
|
19
|
-
const successMessage = exitCode === 0
|
|
20
|
-
? 'Session output written successfully'
|
|
21
|
-
: 'Error output written successfully';
|
|
22
|
-
console.error(successMessage);
|
|
23
|
-
}
|
|
24
|
-
catch (writeError) {
|
|
25
|
-
const errorMessage = exitCode === 0 ? 'Failed to write session output:' : 'Failed to write error output:';
|
|
26
|
-
console.error(errorMessage, writeError);
|
|
27
|
-
console.error('Write error details:', writeError);
|
|
28
|
-
}
|
|
29
|
-
// Output to stdout (for foreground use)
|
|
30
|
-
const jsonString = compact ? JSON.stringify(output) : JSON.stringify(output, null, 2);
|
|
31
|
-
console.log(jsonString);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=OutputWriter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OutputWriter.js","sourceRoot":"","sources":["../../../src/cli/handlers/OutputWriter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAiB,EAAE,QAAe,EAAE,UAAmB,KAAK;QAC7E,8CAA8C;QAC9C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,yBAAyB,CAAC;YACzF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACpC,MAAM,cAAc,GAClB,QAAQ,KAAK,CAAC;gBACZ,CAAC,CAAC,qCAAqC;gBACvC,CAAC,CAAC,mCAAmC,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,MAAM,YAAY,GAChB,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,+BAA+B,CAAC;YACvF,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC;QAED,wCAAwC;QACxC,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CDPTarget, NetworkRequest, ConsoleMessage, CollectorType } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for accessing session data without direct coupling
|
|
4
|
-
*/
|
|
5
|
-
export interface PreviewDataSource {
|
|
6
|
-
getTarget: () => CDPTarget;
|
|
7
|
-
getNetworkRequests: () => NetworkRequest[];
|
|
8
|
-
getConsoleLogs: () => ConsoleMessage[];
|
|
9
|
-
getActiveCollectors: () => CollectorType[];
|
|
10
|
-
isConnected: () => boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Manages two-tier preview system with async I/O and mutex
|
|
14
|
-
*
|
|
15
|
-
* Periodically writes both lightweight preview and full data files
|
|
16
|
-
* to enable efficient monitoring without stopping collection.
|
|
17
|
-
*/
|
|
18
|
-
export declare class PreviewWriter {
|
|
19
|
-
private dataSource;
|
|
20
|
-
private startTime;
|
|
21
|
-
private intervalMs;
|
|
22
|
-
private compact;
|
|
23
|
-
private interval;
|
|
24
|
-
private pendingWrite;
|
|
25
|
-
private isWriting;
|
|
26
|
-
constructor(dataSource: PreviewDataSource, startTime: number, intervalMs?: number, compact?: boolean);
|
|
27
|
-
/**
|
|
28
|
-
* Start periodic preview writes.
|
|
29
|
-
*/
|
|
30
|
-
start(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Stop preview writes and clear interval.
|
|
33
|
-
*/
|
|
34
|
-
stop(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Wait for any in-flight write to complete.
|
|
37
|
-
* Called during shutdown to prevent race conditions.
|
|
38
|
-
*/
|
|
39
|
-
waitForPendingWrite(): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Execute a single preview write cycle (internal)
|
|
42
|
-
*/
|
|
43
|
-
private writePreview;
|
|
44
|
-
/**
|
|
45
|
-
* Perform the actual write operation (internal)
|
|
46
|
-
*
|
|
47
|
-
* Passes original arrays for active collectors, empty arrays for inactive ones.
|
|
48
|
-
* No cloning needed - OutputBuilder serializes immediately, avoiding unnecessary copies.
|
|
49
|
-
*/
|
|
50
|
-
private doWrite;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=PreviewWriter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewWriter.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/PreviewWriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKxF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,SAAS,CAAC;IAC3B,kBAAkB,EAAE,MAAM,cAAc,EAAE,CAAC;IAC3C,cAAc,EAAE,MAAM,cAAc,EAAE,CAAC;IACvC,mBAAmB,EAAE,MAAM,aAAa,EAAE,CAAC;IAC3C,WAAW,EAAE,MAAM,OAAO,CAAC;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IAMtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,SAAS,CAAS;gBAGhB,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAAa,EACzB,OAAO,GAAE,OAAe;IAGlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAY1C;;OAEG;IACH,OAAO,CAAC,YAAY;IAyBpB;;;;;OAKG;YACW,OAAO;CAqCtB"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { writePartialOutputAsync, writeFullOutputAsync } from '../../utils/session.js';
|
|
2
|
-
import { OutputBuilder } from './OutputBuilder.js';
|
|
3
|
-
/**
|
|
4
|
-
* Manages two-tier preview system with async I/O and mutex
|
|
5
|
-
*
|
|
6
|
-
* Periodically writes both lightweight preview and full data files
|
|
7
|
-
* to enable efficient monitoring without stopping collection.
|
|
8
|
-
*/
|
|
9
|
-
export class PreviewWriter {
|
|
10
|
-
dataSource;
|
|
11
|
-
startTime;
|
|
12
|
-
intervalMs;
|
|
13
|
-
compact;
|
|
14
|
-
interval = null;
|
|
15
|
-
pendingWrite = null;
|
|
16
|
-
isWriting = false;
|
|
17
|
-
constructor(dataSource, startTime, intervalMs = 5000, compact = false) {
|
|
18
|
-
this.dataSource = dataSource;
|
|
19
|
-
this.startTime = startTime;
|
|
20
|
-
this.intervalMs = intervalMs;
|
|
21
|
-
this.compact = compact;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Start periodic preview writes.
|
|
25
|
-
*/
|
|
26
|
-
start() {
|
|
27
|
-
this.interval = setInterval(() => {
|
|
28
|
-
this.writePreview();
|
|
29
|
-
}, this.intervalMs);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Stop preview writes and clear interval.
|
|
33
|
-
*/
|
|
34
|
-
stop() {
|
|
35
|
-
if (this.interval) {
|
|
36
|
-
clearInterval(this.interval);
|
|
37
|
-
this.interval = null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Wait for any in-flight write to complete.
|
|
42
|
-
* Called during shutdown to prevent race conditions.
|
|
43
|
-
*/
|
|
44
|
-
async waitForPendingWrite() {
|
|
45
|
-
if (this.pendingWrite) {
|
|
46
|
-
console.error('Waiting for in-flight write to complete...');
|
|
47
|
-
try {
|
|
48
|
-
await this.pendingWrite;
|
|
49
|
-
console.error('In-flight write completed');
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error('Error in pending write (ignoring):', error);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Execute a single preview write cycle (internal)
|
|
58
|
-
*/
|
|
59
|
-
writePreview() {
|
|
60
|
-
// Skip if previous write in progress or disconnected
|
|
61
|
-
if (this.isWriting || !this.dataSource.isConnected()) {
|
|
62
|
-
if (this.isWriting) {
|
|
63
|
-
console.error('[PERF] Skipping preview write (previous write still in progress)');
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this.isWriting = true;
|
|
68
|
-
// Create and track the write promise so shutdown can await it
|
|
69
|
-
this.pendingWrite = this.doWrite()
|
|
70
|
-
.catch((error) => {
|
|
71
|
-
console.error('Warning: Failed to write preview data:', error instanceof Error ? error.message : String(error));
|
|
72
|
-
})
|
|
73
|
-
.finally(() => {
|
|
74
|
-
this.isWriting = false;
|
|
75
|
-
this.pendingWrite = null;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Perform the actual write operation (internal)
|
|
80
|
-
*
|
|
81
|
-
* Passes original arrays for active collectors, empty arrays for inactive ones.
|
|
82
|
-
* No cloning needed - OutputBuilder serializes immediately, avoiding unnecessary copies.
|
|
83
|
-
*/
|
|
84
|
-
async doWrite() {
|
|
85
|
-
const target = this.dataSource.getTarget();
|
|
86
|
-
const activeCollectors = this.dataSource.getActiveCollectors();
|
|
87
|
-
// Pass original arrays when active, empty arrays when inactive (no cloning needed)
|
|
88
|
-
const networkRequests = activeCollectors.includes('network')
|
|
89
|
-
? this.dataSource.getNetworkRequests()
|
|
90
|
-
: [];
|
|
91
|
-
const consoleLogs = activeCollectors.includes('console')
|
|
92
|
-
? this.dataSource.getConsoleLogs()
|
|
93
|
-
: [];
|
|
94
|
-
// Build both preview and full outputs
|
|
95
|
-
const previewOutput = OutputBuilder.build({
|
|
96
|
-
mode: 'preview',
|
|
97
|
-
target,
|
|
98
|
-
startTime: this.startTime,
|
|
99
|
-
networkRequests,
|
|
100
|
-
consoleLogs,
|
|
101
|
-
activeCollectors,
|
|
102
|
-
});
|
|
103
|
-
const fullOutput = OutputBuilder.build({
|
|
104
|
-
mode: 'full',
|
|
105
|
-
target,
|
|
106
|
-
startTime: this.startTime,
|
|
107
|
-
networkRequests,
|
|
108
|
-
consoleLogs,
|
|
109
|
-
activeCollectors,
|
|
110
|
-
});
|
|
111
|
-
// Write both files in parallel (async, non-blocking)
|
|
112
|
-
await Promise.all([
|
|
113
|
-
writePartialOutputAsync(previewOutput, this.compact), // ~500KB - for 'bdg peek'
|
|
114
|
-
writeFullOutputAsync(fullOutput, this.compact), // ~87MB - for 'bdg details'
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=PreviewWriter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewWriter.js","sourceRoot":"","sources":["../../../src/cli/handlers/PreviewWriter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAMd;IACA;IACA;IACA;IARF,QAAQ,GAA0B,IAAI,CAAC;IACvC,YAAY,GAAyB,IAAI,CAAC;IAC1C,SAAS,GAAG,KAAK,CAAC;IAE1B,YACU,UAA6B,EAC7B,SAAiB,EACjB,aAAqB,IAAI,EACzB,UAAmB,KAAK;QAHxB,eAAU,GAAV,UAAU,CAAmB;QAC7B,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAe;QACzB,YAAO,GAAP,OAAO,CAAiB;IAC/B,CAAC;IAEJ;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;YAC/B,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,mBAAmB;QACvB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OA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G,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC1D,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE;YACtC,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,WAAW,GAAG,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC;YACtD,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;YAClC,CAAC,CAAC,EAAE,CAAC;QAEP,sCAAsC;QACtC,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC;YACxC,IAAI,EAAE,SAAS;YACf,MAAM;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe;YACf,WAAW;YACX,gBAAgB;SACjB,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC;YACrC,IAAI,EAAE,MAAM;YACZ,MAAM;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe;YACf,WAAW;YACX,gBAAgB;SACjB,CAAC,CAAC;QAEH,qDAAqD;QACrD,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,uBAAuB,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,0BAA0B;YAChF,oBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,4BAA4B;SAC7E,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CollectorType } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles session lock acquisition and validation
|
|
4
|
-
*/
|
|
5
|
-
export declare class SessionLock {
|
|
6
|
-
/**
|
|
7
|
-
* Acquire session lock and validate inputs
|
|
8
|
-
*
|
|
9
|
-
* @param url - Target URL to monitor
|
|
10
|
-
* @param collectors - Collector types to enable
|
|
11
|
-
* @returns Normalized URL
|
|
12
|
-
* @throws Error if session already running or validation fails
|
|
13
|
-
*/
|
|
14
|
-
static acquire(url: string, collectors: CollectorType[]): string;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=SessionLock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionLock.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,MAAM;CAsBjE"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { readPid, isProcessAlive, cleanupSession, acquireSessionLock } from '../../utils/session.js';
|
|
2
|
-
import { normalizeUrl } from '../../utils/url.js';
|
|
3
|
-
import { validateCollectorTypes } from '../../utils/validation.js';
|
|
4
|
-
/**
|
|
5
|
-
* Handles session lock acquisition and validation
|
|
6
|
-
*/
|
|
7
|
-
export class SessionLock {
|
|
8
|
-
/**
|
|
9
|
-
* Acquire session lock and validate inputs
|
|
10
|
-
*
|
|
11
|
-
* @param url - Target URL to monitor
|
|
12
|
-
* @param collectors - Collector types to enable
|
|
13
|
-
* @returns Normalized URL
|
|
14
|
-
* @throws Error if session already running or validation fails
|
|
15
|
-
*/
|
|
16
|
-
static acquire(url, collectors) {
|
|
17
|
-
const existingPid = readPid();
|
|
18
|
-
// Check for stale session before trying to acquire lock
|
|
19
|
-
if (existingPid && !isProcessAlive(existingPid)) {
|
|
20
|
-
console.error(`Found stale session (PID ${existingPid} not running)`);
|
|
21
|
-
console.error('Cleaning up stale session files...');
|
|
22
|
-
cleanupSession();
|
|
23
|
-
console.error('Stale session cleaned up');
|
|
24
|
-
}
|
|
25
|
-
if (!acquireSessionLock()) {
|
|
26
|
-
const currentPid = readPid();
|
|
27
|
-
throw new Error(`Session already running (PID ${currentPid}). Stop it with: bdg stop`);
|
|
28
|
-
}
|
|
29
|
-
// Validate collector types
|
|
30
|
-
validateCollectorTypes(collectors);
|
|
31
|
-
// Normalize URL - add http:// if no protocol specified
|
|
32
|
-
return normalizeUrl(url);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=SessionLock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionLock.js","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,UAA2B;QACrD,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;QAE9B,wDAAwD;QACxD,IAAI,WAAW,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,4BAA4B,WAAW,eAAe,CAAC,CAAC;YACtE,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACpD,cAAc,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC1B,MAAM,UAAU,GAAG,OAAO,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,gCAAgC,UAAU,2BAA2B,CAAC,CAAC;QACzF,CAAC;QAED,2BAA2B;QAC3B,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAEnC,uDAAuD;QACvD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BdgSession } from '../../session/BdgSession.js';
|
|
2
|
-
import type { CDPTarget } from '../../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Manages the session monitoring loop
|
|
5
|
-
*/
|
|
6
|
-
export declare class SessionLoop {
|
|
7
|
-
/**
|
|
8
|
-
* Run session loop until stopped or error
|
|
9
|
-
*
|
|
10
|
-
* Monitors WebSocket connection and target lifecycle.
|
|
11
|
-
* Throws error if connection lost or tab closed.
|
|
12
|
-
*
|
|
13
|
-
* @param session - Active BDG session instance
|
|
14
|
-
* @param target - CDP target being monitored
|
|
15
|
-
* @throws Error if WebSocket connection lost or browser tab closed
|
|
16
|
-
*/
|
|
17
|
-
static run(session: BdgSession, target: CDPTarget): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=SessionLoop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionLoop.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLoop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAA4B,MAAM,SAAS,CAAC;AAEnE;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;OASG;WACU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CxE"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages the session monitoring loop
|
|
3
|
-
*/
|
|
4
|
-
export class SessionLoop {
|
|
5
|
-
/**
|
|
6
|
-
* Run session loop until stopped or error
|
|
7
|
-
*
|
|
8
|
-
* Monitors WebSocket connection and target lifecycle.
|
|
9
|
-
* Throws error if connection lost or tab closed.
|
|
10
|
-
*
|
|
11
|
-
* @param session - Active BDG session instance
|
|
12
|
-
* @param target - CDP target being monitored
|
|
13
|
-
* @throws Error if WebSocket connection lost or browser tab closed
|
|
14
|
-
*/
|
|
15
|
-
static async run(session, target) {
|
|
16
|
-
if (!session) {
|
|
17
|
-
throw new Error('Session not initialized');
|
|
18
|
-
}
|
|
19
|
-
const cdp = session.getCDP();
|
|
20
|
-
const waitForNextCheck = () => new Promise((resolve) => {
|
|
21
|
-
let timer;
|
|
22
|
-
let handlerId;
|
|
23
|
-
const handleTargetDestroyed = (params) => {
|
|
24
|
-
if (params.targetId === target.id) {
|
|
25
|
-
clearTimeout(timer);
|
|
26
|
-
cdp.off('Target.targetDestroyed', handlerId);
|
|
27
|
-
resolve('destroyed');
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
handlerId = cdp.on('Target.targetDestroyed', handleTargetDestroyed);
|
|
31
|
-
timer = setTimeout(() => {
|
|
32
|
-
cdp.off('Target.targetDestroyed', handlerId);
|
|
33
|
-
resolve('continue');
|
|
34
|
-
}, 2000);
|
|
35
|
-
});
|
|
36
|
-
for (;;) {
|
|
37
|
-
const result = await waitForNextCheck();
|
|
38
|
-
if (!session.isConnected()) {
|
|
39
|
-
throw new Error('WebSocket connection lost');
|
|
40
|
-
}
|
|
41
|
-
if (result === 'destroyed') {
|
|
42
|
-
throw new Error('Browser tab was closed');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=SessionLoop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionLoop.js","sourceRoot":"","sources":["../../../src/cli/handlers/SessionLoop.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAmB,EAAE,MAAiB;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAE7B,MAAM,gBAAgB,GAAG,GAAsC,EAAE,CAC/D,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtB,IAAI,KAAoC,CAAC;YACzC,IAAI,SAAiB,CAAC;YAEtB,MAAM,qBAAqB,GAAG,CAAC,MAAgC,EAAQ,EAAE;gBACvE,IAAI,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;oBAClC,YAAY,CAAC,KAAK,CAAC,CAAC;oBACpB,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;oBAC7C,OAAO,CAAC,WAAW,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,CAAC;YAEF,SAAS,GAAG,GAAG,CAAC,EAAE,CAChB,wBAAwB,EACxB,qBAAqB,CACtB,CAAC;YAEF,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBACtB,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;gBAC7C,OAAO,CAAC,UAAU,CAAC,CAAC;YACtB,CAAC,EAAE,IAAI,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QAEL,SAAS,CAAC;YACR,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;YAExC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,CAAC;YAED,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { PreviewWriter } from './PreviewWriter.js';
|
|
2
|
-
import type { BdgSession } from '../../session/BdgSession.js';
|
|
3
|
-
import type { CDPTarget, LaunchedChrome } from '../../types.js';
|
|
4
|
-
import { OutputWriter } from './OutputWriter.js';
|
|
5
|
-
/**
|
|
6
|
-
* Minimal session state interface
|
|
7
|
-
*/
|
|
8
|
-
export interface SessionState {
|
|
9
|
-
session: BdgSession | null;
|
|
10
|
-
launchedChrome: LaunchedChrome | null;
|
|
11
|
-
isShuttingDown: boolean;
|
|
12
|
-
previewWriter: PreviewWriter | null;
|
|
13
|
-
startTime: number;
|
|
14
|
-
target: CDPTarget | null;
|
|
15
|
-
compact: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Orchestrates shutdown sequence and cleanup operations
|
|
19
|
-
*/
|
|
20
|
-
export declare class ShutdownController {
|
|
21
|
-
private state;
|
|
22
|
-
private shutdownKeepalive;
|
|
23
|
-
private outputWriter;
|
|
24
|
-
constructor(state: SessionState, outputWriter?: OutputWriter);
|
|
25
|
-
/**
|
|
26
|
-
* Execute graceful shutdown sequence.
|
|
27
|
-
* Stops session, writes output, and exits process.
|
|
28
|
-
*/
|
|
29
|
-
shutdown(): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Cleanup without stopping session (error path).
|
|
32
|
-
* Clears timers, tears down Chrome if launched, and removes session files.
|
|
33
|
-
*/
|
|
34
|
-
cleanup(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Finalize shutdown: write output, cleanup, and exit
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
private finalize;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=ShutdownController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShutdownController.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/ShutdownController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAa,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAK3B,OAAO,CAAC,KAAK;IAJf,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,YAAY,CAAe;gBAGzB,KAAK,EAAE,YAAY,EAC3B,YAAY,CAAC,EAAE,YAAY;IAK7B;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B/B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB9B;;;OAGG;IACH,OAAO,CAAC,QAAQ;CA8BjB"}
|