browser-debugger-cli 0.0.1-alpha.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 +85 -0
- package/dist/collectors/console.d.ts +17 -0
- package/dist/collectors/console.d.ts.map +1 -0
- package/dist/collectors/console.js +65 -0
- package/dist/collectors/console.js.map +1 -0
- package/dist/collectors/dom.d.ts +21 -0
- package/dist/collectors/dom.d.ts.map +1 -0
- package/dist/collectors/dom.js +88 -0
- package/dist/collectors/dom.js.map +1 -0
- package/dist/collectors/network.d.ts +19 -0
- package/dist/collectors/network.d.ts.map +1 -0
- package/dist/collectors/network.js +114 -0
- package/dist/collectors/network.js.map +1 -0
- package/dist/connection/cdp.d.ts +99 -0
- package/dist/connection/cdp.d.ts.map +1 -0
- package/dist/connection/cdp.js +317 -0
- package/dist/connection/cdp.js.map +1 -0
- package/dist/connection/finder.d.ts +11 -0
- package/dist/connection/finder.d.ts.map +1 -0
- package/dist/connection/finder.js +23 -0
- package/dist/connection/finder.js.map +1 -0
- package/dist/connection/launcher.d.ts +30 -0
- package/dist/connection/launcher.d.ts.map +1 -0
- package/dist/connection/launcher.js +134 -0
- package/dist/connection/launcher.js.map +1 -0
- package/dist/connection/tabs.d.ts +49 -0
- package/dist/connection/tabs.d.ts.map +1 -0
- package/dist/connection/tabs.js +216 -0
- package/dist/connection/tabs.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +431 -0
- package/dist/index.js.map +1 -0
- package/dist/session/BdgSession.d.ts +62 -0
- package/dist/session/BdgSession.d.ts.map +1 -0
- package/dist/session/BdgSession.js +172 -0
- package/dist/session/BdgSession.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/pageLoad.d.ts +21 -0
- package/dist/utils/pageLoad.d.ts.map +1 -0
- package/dist/utils/pageLoad.js +85 -0
- package/dist/utils/pageLoad.js.map +1 -0
- package/dist/utils/session.d.ts +104 -0
- package/dist/utils/session.d.ts.map +1 -0
- package/dist/utils/session.js +244 -0
- package/dist/utils/session.js.map +1 -0
- package/dist/utils/url.d.ts +6 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +11 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/validation.d.ts +12 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +20 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BdgOutput } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the session directory path (~/.bdg)
|
|
4
|
+
*/
|
|
5
|
+
export declare function getSessionDir(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Ensure the session directory exists
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureSessionDir(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the path to the PID file
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPidFilePath(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get the path to the output JSON file
|
|
16
|
+
*/
|
|
17
|
+
export declare function getOutputFilePath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the path to the session lock file
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLockFilePath(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get the path to the session metadata file
|
|
24
|
+
*/
|
|
25
|
+
export declare function getMetadataFilePath(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Session metadata stored alongside PID
|
|
28
|
+
*/
|
|
29
|
+
export interface SessionMetadata {
|
|
30
|
+
bdgPid: number;
|
|
31
|
+
chromePid?: number;
|
|
32
|
+
startTime: number;
|
|
33
|
+
port: number;
|
|
34
|
+
targetId?: string;
|
|
35
|
+
webSocketDebuggerUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Write the current process PID to the session file atomically
|
|
39
|
+
*
|
|
40
|
+
* @param pid - Process ID to write
|
|
41
|
+
*/
|
|
42
|
+
export declare function writePid(pid: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Read the PID from the session file
|
|
45
|
+
*
|
|
46
|
+
* @returns The PID if file exists and is valid, null otherwise
|
|
47
|
+
*/
|
|
48
|
+
export declare function readPid(): number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a process with the given PID is alive
|
|
51
|
+
*
|
|
52
|
+
* @param pid - Process ID to check
|
|
53
|
+
* @returns True if process is running, false otherwise
|
|
54
|
+
*/
|
|
55
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Remove the PID file
|
|
58
|
+
*/
|
|
59
|
+
export declare function cleanupPidFile(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Write session output to the JSON file
|
|
62
|
+
*
|
|
63
|
+
* @param output - The BdgOutput data to write
|
|
64
|
+
*/
|
|
65
|
+
export declare function writeSessionOutput(output: BdgOutput): void;
|
|
66
|
+
/**
|
|
67
|
+
* Read session output from the JSON file
|
|
68
|
+
*
|
|
69
|
+
* @returns The BdgOutput data if file exists and is valid, null otherwise
|
|
70
|
+
*/
|
|
71
|
+
export declare function readSessionOutput(): BdgOutput | null;
|
|
72
|
+
/**
|
|
73
|
+
* Acquire session lock atomically.
|
|
74
|
+
*
|
|
75
|
+
* Uses exclusive file creation (wx flag) to ensure only one session can run.
|
|
76
|
+
*
|
|
77
|
+
* @returns True if lock was acquired, false if another session is running
|
|
78
|
+
*/
|
|
79
|
+
export declare function acquireSessionLock(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Release session lock.
|
|
82
|
+
*
|
|
83
|
+
* Removes the lock file to allow other sessions to start.
|
|
84
|
+
*/
|
|
85
|
+
export declare function releaseSessionLock(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Write session metadata.
|
|
88
|
+
*
|
|
89
|
+
* @param metadata - Session metadata to write
|
|
90
|
+
*/
|
|
91
|
+
export declare function writeSessionMetadata(metadata: SessionMetadata): void;
|
|
92
|
+
/**
|
|
93
|
+
* Read session metadata.
|
|
94
|
+
*
|
|
95
|
+
* @returns Session metadata if file exists and is valid, null otherwise
|
|
96
|
+
*/
|
|
97
|
+
export declare function readSessionMetadata(): SessionMetadata | null;
|
|
98
|
+
/**
|
|
99
|
+
* Cleanup all session files.
|
|
100
|
+
*
|
|
101
|
+
* Removes PID, lock, metadata, and output files.
|
|
102
|
+
*/
|
|
103
|
+
export declare function cleanupSession(): void;
|
|
104
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ1C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,IAAI,MAAM,GAAG,IAAI,CAmBvC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASnD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAUrC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,GAAG,IAAI,CAapD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAmC5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAIpE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,eAAe,GAAG,IAAI,CAa5D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAYrC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
/**
|
|
5
|
+
* Get the session directory path (~/.bdg)
|
|
6
|
+
*/
|
|
7
|
+
export function getSessionDir() {
|
|
8
|
+
return path.join(os.homedir(), '.bdg');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Ensure the session directory exists
|
|
12
|
+
*/
|
|
13
|
+
export function ensureSessionDir() {
|
|
14
|
+
const dir = getSessionDir();
|
|
15
|
+
if (!fs.existsSync(dir)) {
|
|
16
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the path to the PID file
|
|
21
|
+
*/
|
|
22
|
+
export function getPidFilePath() {
|
|
23
|
+
return path.join(getSessionDir(), 'session.pid');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the path to the output JSON file
|
|
27
|
+
*/
|
|
28
|
+
export function getOutputFilePath() {
|
|
29
|
+
return path.join(getSessionDir(), 'session.json');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the path to the session lock file
|
|
33
|
+
*/
|
|
34
|
+
export function getLockFilePath() {
|
|
35
|
+
return path.join(getSessionDir(), 'session.lock');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the path to the session metadata file
|
|
39
|
+
*/
|
|
40
|
+
export function getMetadataFilePath() {
|
|
41
|
+
return path.join(getSessionDir(), 'session.meta.json');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Write the current process PID to the session file atomically
|
|
45
|
+
*
|
|
46
|
+
* @param pid - Process ID to write
|
|
47
|
+
*/
|
|
48
|
+
export function writePid(pid) {
|
|
49
|
+
ensureSessionDir();
|
|
50
|
+
const pidPath = getPidFilePath();
|
|
51
|
+
const tmpPath = pidPath + '.tmp';
|
|
52
|
+
// Write to temp file first, then rename for atomicity
|
|
53
|
+
fs.writeFileSync(tmpPath, pid.toString(), 'utf-8');
|
|
54
|
+
fs.renameSync(tmpPath, pidPath);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read the PID from the session file
|
|
58
|
+
*
|
|
59
|
+
* @returns The PID if file exists and is valid, null otherwise
|
|
60
|
+
*/
|
|
61
|
+
export function readPid() {
|
|
62
|
+
const pidPath = getPidFilePath();
|
|
63
|
+
if (!fs.existsSync(pidPath)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const pidStr = fs.readFileSync(pidPath, 'utf-8').trim();
|
|
68
|
+
const pid = parseInt(pidStr, 10);
|
|
69
|
+
if (isNaN(pid)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return pid;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if a process with the given PID is alive
|
|
80
|
+
*
|
|
81
|
+
* @param pid - Process ID to check
|
|
82
|
+
* @returns True if process is running, false otherwise
|
|
83
|
+
*/
|
|
84
|
+
export function isProcessAlive(pid) {
|
|
85
|
+
try {
|
|
86
|
+
// Sending signal 0 checks if process exists without actually sending a signal
|
|
87
|
+
process.kill(pid, 0);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// ESRCH error means process doesn't exist
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Remove the PID file
|
|
97
|
+
*/
|
|
98
|
+
export function cleanupPidFile() {
|
|
99
|
+
const pidPath = getPidFilePath();
|
|
100
|
+
if (fs.existsSync(pidPath)) {
|
|
101
|
+
try {
|
|
102
|
+
fs.unlinkSync(pidPath);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
// Ignore errors during cleanup
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Write session output to the JSON file
|
|
111
|
+
*
|
|
112
|
+
* @param output - The BdgOutput data to write
|
|
113
|
+
*/
|
|
114
|
+
export function writeSessionOutput(output) {
|
|
115
|
+
ensureSessionDir();
|
|
116
|
+
const outputPath = getOutputFilePath();
|
|
117
|
+
fs.writeFileSync(outputPath, JSON.stringify(output, null, 2), 'utf-8');
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Read session output from the JSON file
|
|
121
|
+
*
|
|
122
|
+
* @returns The BdgOutput data if file exists and is valid, null otherwise
|
|
123
|
+
*/
|
|
124
|
+
export function readSessionOutput() {
|
|
125
|
+
const outputPath = getOutputFilePath();
|
|
126
|
+
if (!fs.existsSync(outputPath)) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const content = fs.readFileSync(outputPath, 'utf-8');
|
|
131
|
+
return JSON.parse(content);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Acquire session lock atomically.
|
|
139
|
+
*
|
|
140
|
+
* Uses exclusive file creation (wx flag) to ensure only one session can run.
|
|
141
|
+
*
|
|
142
|
+
* @returns True if lock was acquired, false if another session is running
|
|
143
|
+
*/
|
|
144
|
+
export function acquireSessionLock() {
|
|
145
|
+
ensureSessionDir();
|
|
146
|
+
const lockPath = getLockFilePath();
|
|
147
|
+
try {
|
|
148
|
+
// 'wx' flag creates file exclusively - fails if exists
|
|
149
|
+
fs.writeFileSync(lockPath, process.pid.toString(), { flag: 'wx' });
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error.code === 'EEXIST') {
|
|
154
|
+
// Lock file exists - check if process is still alive
|
|
155
|
+
try {
|
|
156
|
+
const lockPidStr = fs.readFileSync(lockPath, 'utf-8').trim();
|
|
157
|
+
const lockPid = parseInt(lockPidStr, 10);
|
|
158
|
+
if (!isNaN(lockPid) && isProcessAlive(lockPid)) {
|
|
159
|
+
// Lock is held by active process
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// Stale lock file - remove it and try again
|
|
164
|
+
fs.unlinkSync(lockPath);
|
|
165
|
+
return acquireSessionLock();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// Can't read lock file - assume it's stale
|
|
170
|
+
try {
|
|
171
|
+
fs.unlinkSync(lockPath);
|
|
172
|
+
return acquireSessionLock();
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Release session lock.
|
|
184
|
+
*
|
|
185
|
+
* Removes the lock file to allow other sessions to start.
|
|
186
|
+
*/
|
|
187
|
+
export function releaseSessionLock() {
|
|
188
|
+
const lockPath = getLockFilePath();
|
|
189
|
+
try {
|
|
190
|
+
if (fs.existsSync(lockPath)) {
|
|
191
|
+
fs.unlinkSync(lockPath);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
// Ignore errors during cleanup
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Write session metadata.
|
|
200
|
+
*
|
|
201
|
+
* @param metadata - Session metadata to write
|
|
202
|
+
*/
|
|
203
|
+
export function writeSessionMetadata(metadata) {
|
|
204
|
+
ensureSessionDir();
|
|
205
|
+
const metaPath = getMetadataFilePath();
|
|
206
|
+
fs.writeFileSync(metaPath, JSON.stringify(metadata, null, 2), 'utf-8');
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Read session metadata.
|
|
210
|
+
*
|
|
211
|
+
* @returns Session metadata if file exists and is valid, null otherwise
|
|
212
|
+
*/
|
|
213
|
+
export function readSessionMetadata() {
|
|
214
|
+
const metaPath = getMetadataFilePath();
|
|
215
|
+
if (!fs.existsSync(metaPath)) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const content = fs.readFileSync(metaPath, 'utf-8');
|
|
220
|
+
return JSON.parse(content);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Cleanup all session files.
|
|
228
|
+
*
|
|
229
|
+
* Removes PID, lock, metadata, and output files.
|
|
230
|
+
*/
|
|
231
|
+
export function cleanupSession() {
|
|
232
|
+
cleanupPidFile();
|
|
233
|
+
releaseSessionLock();
|
|
234
|
+
const metaPath = getMetadataFilePath();
|
|
235
|
+
if (fs.existsSync(metaPath)) {
|
|
236
|
+
try {
|
|
237
|
+
fs.unlinkSync(metaPath);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
// Ignore errors
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,cAAc,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,cAAc,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,mBAAmB,CAAC,CAAC;AACzD,CAAC;AAcD;;;;GAIG;AACH,MAAM,UA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;IACvC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IAEvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,cAAc,EAAE,CAAC;IACjB,kBAAkB,EAAE,CAAC;IAErB,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IACvC,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAgB;QAClB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKhD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a URL by adding http:// protocol if missing
|
|
3
|
+
* Supports: localhost:3000, example.com, http://localhost, file:// URLs
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeUrl(url) {
|
|
6
|
+
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('file://')) {
|
|
7
|
+
return url;
|
|
8
|
+
}
|
|
9
|
+
return `http://${url}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACzF,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,UAAU,GAAG,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollectorType } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate that a collector type is valid
|
|
4
|
+
* @throws Error if collector type is invalid
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateCollectorType(type: string): asserts type is CollectorType;
|
|
7
|
+
/**
|
|
8
|
+
* Validate an array of collector types
|
|
9
|
+
* @throws Error if any collector type is invalid
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateCollectorTypes(types: string[]): asserts types is CollectorType[];
|
|
12
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,IAAI,aAAa,CAMjF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,EAAE,CAIxF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const VALID_COLLECTORS = ['dom', 'network', 'console'];
|
|
2
|
+
/**
|
|
3
|
+
* Validate that a collector type is valid
|
|
4
|
+
* @throws Error if collector type is invalid
|
|
5
|
+
*/
|
|
6
|
+
export function validateCollectorType(type) {
|
|
7
|
+
if (!VALID_COLLECTORS.includes(type)) {
|
|
8
|
+
throw new Error(`Invalid collector type: "${type}". Valid types are: ${VALID_COLLECTORS.join(', ')}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate an array of collector types
|
|
13
|
+
* @throws Error if any collector type is invalid
|
|
14
|
+
*/
|
|
15
|
+
export function validateCollectorTypes(types) {
|
|
16
|
+
for (const type of types) {
|
|
17
|
+
validateCollectorType(type);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAqB,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,4BAA4B,IAAI,uBAAuB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAe;IACpD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "browser-debugger-cli",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Browser telemetry via Chrome DevTools Protocol",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bdg": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsc && node dist/index.js",
|
|
12
|
+
"watch": "tsc --watch",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cdp",
|
|
17
|
+
"chrome-devtools-protocol",
|
|
18
|
+
"browser",
|
|
19
|
+
"telemetry",
|
|
20
|
+
"cli",
|
|
21
|
+
"devtools"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"chrome-launcher": "^1.2.1",
|
|
26
|
+
"commander": "^12.1.0",
|
|
27
|
+
"ws": "^8.18.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"@types/ws": "^8.5.10",
|
|
32
|
+
"typescript": "^5.6.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"author": {
|
|
38
|
+
"name": "Kumak",
|
|
39
|
+
"email": "szymon@kumak.dev"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/szymdzum/browser-debugger-cli.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/szymdzum/browser-debugger-cli#readme",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/szymdzum/browser-debugger-cli/issues"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"tag": "alpha"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"dist",
|
|
54
|
+
"README.md"
|
|
55
|
+
]
|
|
56
|
+
}
|