browser-debugger-cli 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/fixtures/schema-v0.2.1.golden.json +47 -0
- package/dist/__tests__/schema.contract.test.d.ts +19 -0
- package/dist/__tests__/schema.contract.test.d.ts.map +1 -0
- package/dist/__tests__/schema.contract.test.js +236 -0
- package/dist/__tests__/schema.contract.test.js.map +1 -0
- package/dist/commands/__tests__/cdp.contract.test.d.ts.map +1 -1
- package/dist/commands/__tests__/cdp.contract.test.js +0 -1
- package/dist/commands/__tests__/cdp.contract.test.js.map +1 -1
- package/dist/commands/__tests__/domEval.contract.test.d.ts +17 -0
- package/dist/commands/__tests__/domEval.contract.test.d.ts.map +1 -0
- package/dist/commands/__tests__/domEval.contract.test.js +231 -0
- package/dist/commands/__tests__/domEval.contract.test.js.map +1 -0
- package/dist/commands/cleanup.d.ts.map +1 -1
- package/dist/commands/cleanup.js +46 -5
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +8 -8
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/details.js +2 -2
- package/dist/commands/details.js.map +1 -1
- package/dist/commands/dom.d.ts.map +1 -1
- package/dist/commands/dom.js +101 -109
- package/dist/commands/dom.js.map +1 -1
- package/dist/commands/domEvalHelpers.d.ts +6 -10
- package/dist/commands/domEvalHelpers.d.ts.map +1 -1
- package/dist/commands/domEvalHelpers.js +12 -16
- package/dist/commands/domEvalHelpers.js.map +1 -1
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +2 -4
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +3 -2
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/shared/CommandRunner.d.ts +4 -2
- package/dist/commands/shared/CommandRunner.d.ts.map +1 -1
- package/dist/commands/shared/CommandRunner.js +17 -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 -1
- package/dist/commands/shared/commonOptions.js.map +1 -1
- package/dist/commands/shared/sessionController.d.ts.map +1 -1
- package/dist/commands/shared/sessionController.js +7 -8
- package/dist/commands/shared/sessionController.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/stop.d.ts.map +1 -1
- package/dist/commands/stop.js +5 -3
- package/dist/commands/stop.js.map +1 -1
- package/dist/connection/__tests__/cdp.contract.test.d.ts.map +1 -1
- package/dist/connection/__tests__/cdp.contract.test.js +0 -1
- package/dist/connection/__tests__/cdp.contract.test.js.map +1 -1
- package/dist/connection/launcher.d.ts.map +1 -1
- package/dist/connection/launcher.js +32 -22
- package/dist/connection/launcher.js.map +1 -1
- package/dist/daemon/startSession.d.ts.map +1 -1
- package/dist/daemon/startSession.js +6 -4
- package/dist/daemon/startSession.js.map +1 -1
- package/dist/daemon/worker.js +116 -45
- package/dist/daemon/worker.js.map +1 -1
- package/dist/ipc/client.d.ts +13 -0
- package/dist/ipc/client.d.ts.map +1 -1
- package/dist/ipc/client.js +16 -0
- package/dist/ipc/client.js.map +1 -1
- package/dist/ipc/commands.d.ts +19 -0
- package/dist/ipc/commands.d.ts.map +1 -1
- package/dist/ipc/commands.js +4 -0
- package/dist/ipc/commands.js.map +1 -1
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/errors.d.ts +39 -0
- package/dist/ui/errors.d.ts.map +1 -0
- package/dist/ui/errors.js +48 -0
- package/dist/ui/errors.js.map +1 -0
- package/dist/ui/formatters/cookies.d.ts.map +1 -1
- package/dist/ui/formatters/cookies.js +18 -21
- package/dist/ui/formatters/cookies.js.map +1 -1
- package/dist/ui/formatters/details.d.ts.map +1 -1
- package/dist/ui/formatters/details.js +34 -36
- package/dist/ui/formatters/details.js.map +1 -1
- package/dist/ui/formatters/dom.d.ts +135 -0
- package/dist/ui/formatters/dom.d.ts.map +1 -0
- package/dist/ui/formatters/dom.js +193 -0
- package/dist/ui/formatters/dom.js.map +1 -0
- package/dist/ui/formatters/index.d.ts +1 -0
- package/dist/ui/formatters/index.d.ts.map +1 -1
- package/dist/ui/formatters/index.js +1 -0
- package/dist/ui/formatters/index.js.map +1 -1
- package/dist/ui/formatters/preview.js +43 -38
- package/dist/ui/formatters/preview.js.map +1 -1
- package/dist/ui/formatters/status.d.ts.map +1 -1
- package/dist/ui/formatters/status.js +44 -44
- package/dist/ui/formatters/status.js.map +1 -1
- package/dist/ui/formatting.d.ts +104 -1
- package/dist/ui/formatting.d.ts.map +1 -1
- package/dist/ui/formatting.js +138 -2
- package/dist/ui/formatting.js.map +1 -1
- package/dist/ui/messages/chrome.d.ts +70 -0
- package/dist/ui/messages/chrome.d.ts.map +1 -1
- package/dist/ui/messages/chrome.js +91 -0
- package/dist/ui/messages/chrome.js.map +1 -1
- package/dist/ui/messages/debug.d.ts +4 -2
- package/dist/ui/messages/debug.d.ts.map +1 -1
- package/dist/ui/messages/debug.js +31 -29
- package/dist/ui/messages/debug.js.map +1 -1
- package/dist/ui/messages/errors.d.ts +11 -0
- package/dist/ui/messages/errors.d.ts.map +1 -1
- package/dist/ui/messages/errors.js +13 -0
- package/dist/ui/messages/errors.js.map +1 -1
- package/dist/ui/messages/preview.d.ts +24 -0
- package/dist/ui/messages/preview.d.ts.map +1 -1
- package/dist/ui/messages/preview.js +31 -0
- package/dist/ui/messages/preview.js.map +1 -1
- package/dist/ui/messages/validation.d.ts +14 -0
- package/dist/ui/messages/validation.d.ts.map +1 -1
- package/dist/ui/messages/validation.js +16 -0
- package/dist/ui/messages/validation.js.map +1 -1
- package/dist/utils/filters.js +1 -1
- package/dist/utils/filters.js.map +1 -1
- package/dist/utils/pageReadiness.d.ts +9 -14
- package/dist/utils/pageReadiness.d.ts.map +1 -1
- package/dist/utils/pageReadiness.js +16 -16
- package/dist/utils/pageReadiness.js.map +1 -1
- package/dist/utils/url.d.ts +58 -6
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +127 -20
- package/dist/utils/url.js.map +1 -1
- package/package.json +2 -5
|
@@ -77,4 +77,15 @@ export declare function invalidResponseError(reason: string): string;
|
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
export declare function noPreviewDataError(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Generate "invalid CDP response" error message.
|
|
82
|
+
*
|
|
83
|
+
* @returns Formatted error message
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* throw new Error(invalidCDPResponseError());
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function invalidCDPResponseError(): string;
|
|
80
91
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAkBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAK9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAKpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAkBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAK9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAKpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
|
|
@@ -119,4 +119,17 @@ No preview data available
|
|
|
119
119
|
Start a session with: bdg <url>
|
|
120
120
|
Check session status: bdg status`;
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Generate "invalid CDP response" error message.
|
|
124
|
+
*
|
|
125
|
+
* @returns Formatted error message
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* throw new Error(invalidCDPResponseError());
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function invalidCDPResponseError() {
|
|
133
|
+
return 'Invalid response from CDP';
|
|
134
|
+
}
|
|
122
135
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot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AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,uCAAuC,MAAM,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;iCAIwB,CAAC;AAClC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,2BAA2B,CAAC;AACrC,CAAC"}
|
|
@@ -24,4 +24,28 @@ export declare function compactTipsMessage(): string;
|
|
|
24
24
|
* @returns Multi-line commands help for verbose mode
|
|
25
25
|
*/
|
|
26
26
|
export declare function verboseCommandsMessage(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generate message for following preview mode.
|
|
29
|
+
*
|
|
30
|
+
* @returns Formatted message indicating follow mode is active
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* console.error(followingPreviewMessage());
|
|
35
|
+
* // Output: "Following live preview (Ctrl+C to stop)...\n"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function followingPreviewMessage(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Generate message for stopped following preview.
|
|
41
|
+
*
|
|
42
|
+
* @returns Formatted message indicating follow mode stopped
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* console.error(stoppedFollowingPreviewMessage());
|
|
47
|
+
* // Output: "\nStopped following preview"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function stoppedFollowingPreviewMessage(): string;
|
|
27
51
|
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAMX,eAAO,MAAM,eAAe;;CAElB,CAAC;AAMX;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAO/C"}
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAMX,eAAO,MAAM,eAAe;;CAElB,CAAC;AAMX;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAO/C;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CAEvD"}
|
|
@@ -42,4 +42,35 @@ export function verboseCommandsMessage() {
|
|
|
42
42
|
lines.push(' Watch live: bdg peek --follow');
|
|
43
43
|
return lines.join('\n');
|
|
44
44
|
}
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Follow Mode Messages
|
|
47
|
+
// ============================================================================
|
|
48
|
+
/**
|
|
49
|
+
* Generate message for following preview mode.
|
|
50
|
+
*
|
|
51
|
+
* @returns Formatted message indicating follow mode is active
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* console.error(followingPreviewMessage());
|
|
56
|
+
* // Output: "Following live preview (Ctrl+C to stop)...\n"
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function followingPreviewMessage() {
|
|
60
|
+
return 'Following live preview (Ctrl+C to stop)...\n';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate message for stopped following preview.
|
|
64
|
+
*
|
|
65
|
+
* @returns Formatted message indicating follow mode stopped
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* console.error(stoppedFollowingPreviewMessage());
|
|
70
|
+
* // Output: "\nStopped following preview"
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function stoppedFollowingPreviewMessage() {
|
|
74
|
+
return '\nStopped following preview';
|
|
75
|
+
}
|
|
45
76
|
//# sourceMappingURL=preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/ui/messages/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,QAAQ;IACjB,mBAAmB,EAAE,yBAAyB;IAC9C,mBAAmB,EAAE,yBAAyB;CACtC,CAAC;AAEX,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE,6BAA6B;CACnC,CAAC;AAEX,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,yDAAyD,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxB,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/ui/messages/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,QAAQ;IACjB,mBAAmB,EAAE,yBAAyB;IAC9C,mBAAmB,EAAE,yBAAyB;CACtC,CAAC;AAEX,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE,6BAA6B;CACnC,CAAC;AAEX,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,yDAAyD,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxB,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,8CAA8C,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO,6BAA6B,CAAC;AACvC,CAAC"}
|
|
@@ -17,4 +17,18 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export declare function invalidIntegerError(fieldName: string, value: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate invalid range error message for --last option.
|
|
22
|
+
*
|
|
23
|
+
* @param min - Minimum allowed value
|
|
24
|
+
* @param max - Maximum allowed value
|
|
25
|
+
* @returns Formatted error message
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* throw new Error(invalidLastRangeError(0, 10000));
|
|
30
|
+
* // "--last must be between 0 and 10000"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function invalidLastRangeError(min?: number, max?: number): string;
|
|
20
34
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5E"}
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/ui/messages/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAAc,GAAG,MAAM,CAElF"}
|
|
@@ -19,4 +19,20 @@
|
|
|
19
19
|
export function invalidIntegerError(fieldName, value) {
|
|
20
20
|
return `Invalid ${fieldName}: "${value}" is not a valid integer`;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate invalid range error message for --last option.
|
|
24
|
+
*
|
|
25
|
+
* @param min - Minimum allowed value
|
|
26
|
+
* @param max - Maximum allowed value
|
|
27
|
+
* @returns Formatted error message
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* throw new Error(invalidLastRangeError(0, 10000));
|
|
32
|
+
* // "--last must be between 0 and 10000"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function invalidLastRangeError(min = 0, max = 10000) {
|
|
36
|
+
return `--last must be between ${min} and ${max}`;
|
|
37
|
+
}
|
|
22
38
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/ui/messages/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,KAAa;IAClE,OAAO,WAAW,SAAS,MAAM,KAAK,0BAA0B,CAAC;AACnE,CAAC"}
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/ui/messages/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,KAAa;IAClE,OAAO,WAAW,SAAS,MAAM,KAAK,0BAA0B,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc,CAAC,EAAE,MAAc,KAAK;IACxE,OAAO,0BAA0B,GAAG,QAAQ,GAAG,EAAE,CAAC;AACpD,CAAC"}
|
package/dist/utils/filters.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Default filters for reducing noise in collected data
|
|
3
3
|
*/
|
|
4
|
-
import { extractHostname, extractHostnameWithPath } from './url
|
|
4
|
+
import { extractHostname, extractHostnameWithPath } from './url.js';
|
|
5
5
|
/**
|
|
6
6
|
* Domains to exclude by default (common tracking/analytics)
|
|
7
7
|
* These generate high volume but are rarely useful for debugging
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":"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AAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,uCAAuC;IACvC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,EAAE;QACnD,eAAe,EAAE,0BAA0B;QAC3C,eAAe,EAAE,SAAS;KAC3B,CAAC,CAAC;IAEH,kEAAkE;IAClE,OAAO,CAAC,kBAAkB,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,UAGI,EAAE;IAEN,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAE/D,6EAA6E;IAC7E,OAAO,CAAC,oBAAoB,CAAC,GAAG,EAAE;QAChC,eAAe;QACf,eAAe;QACf,eAAe,EAAE,SAAS;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -14,37 +14,32 @@ import type { CDPConnection } from '../connection/cdp.js';
|
|
|
14
14
|
export interface PageReadinessOptions {
|
|
15
15
|
/**
|
|
16
16
|
* Maximum wait time before proceeding anyway
|
|
17
|
-
* Default:
|
|
17
|
+
* Default: 5000ms (5 seconds)
|
|
18
18
|
*/
|
|
19
19
|
maxWaitMs?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Wait for network and DOM stability after load event
|
|
22
|
-
* Default: false (load event is sufficient for most pages)
|
|
23
|
-
* Enable for SPAs with heavy post-load hydration
|
|
24
|
-
*/
|
|
25
|
-
waitForStability?: boolean;
|
|
26
20
|
}
|
|
27
21
|
/**
|
|
28
22
|
* Wait for page to be ready using self-tuning detection
|
|
29
23
|
*
|
|
30
|
-
* Strategy:
|
|
31
|
-
* 1. Wait for load event (baseline)
|
|
32
|
-
* 2. Wait for network to stabilize (adaptive)
|
|
33
|
-
* 3. Wait for DOM to stabilize (adaptive)
|
|
24
|
+
* Strategy (always applied):
|
|
25
|
+
* 1. Wait for load event (baseline readiness)
|
|
26
|
+
* 2. Wait for network to stabilize (adaptive 200ms idle)
|
|
27
|
+
* 3. Wait for DOM to stabilize (adaptive 300ms idle)
|
|
34
28
|
*
|
|
35
29
|
* All thresholds adapt to observed page behavior.
|
|
36
30
|
* No framework detection, no configuration needed.
|
|
31
|
+
* Works for static HTML, SPAs, and everything in between.
|
|
37
32
|
*
|
|
38
33
|
* @param cdp - CDP connection
|
|
39
34
|
* @param options - Optional configuration
|
|
40
35
|
*
|
|
41
36
|
* @example
|
|
42
37
|
* ```typescript
|
|
43
|
-
* // Default:
|
|
38
|
+
* // Default: Wait up to 5s for full stability
|
|
44
39
|
* await waitForPageReady(cdp);
|
|
45
40
|
*
|
|
46
|
-
* // Custom timeout for slow apps
|
|
47
|
-
* await waitForPageReady(cdp, { maxWaitMs:
|
|
41
|
+
* // Custom timeout for very slow apps
|
|
42
|
+
* await waitForPageReady(cdp, { maxWaitMs: 15000 });
|
|
48
43
|
* ```
|
|
49
44
|
*/
|
|
50
45
|
export declare function waitForPageReady(cdp: CDPConnection, options?: PageReadinessOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageReadiness.d.ts","sourceRoot":"","sources":["../../src/utils/pageReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"pageReadiness.d.ts","sourceRoot":"","sources":["../../src/utils/pageReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
|
@@ -10,40 +10,40 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Wait for page to be ready using self-tuning detection
|
|
12
12
|
*
|
|
13
|
-
* Strategy:
|
|
14
|
-
* 1. Wait for load event (baseline)
|
|
15
|
-
* 2. Wait for network to stabilize (adaptive)
|
|
16
|
-
* 3. Wait for DOM to stabilize (adaptive)
|
|
13
|
+
* Strategy (always applied):
|
|
14
|
+
* 1. Wait for load event (baseline readiness)
|
|
15
|
+
* 2. Wait for network to stabilize (adaptive 200ms idle)
|
|
16
|
+
* 3. Wait for DOM to stabilize (adaptive 300ms idle)
|
|
17
17
|
*
|
|
18
18
|
* All thresholds adapt to observed page behavior.
|
|
19
19
|
* No framework detection, no configuration needed.
|
|
20
|
+
* Works for static HTML, SPAs, and everything in between.
|
|
20
21
|
*
|
|
21
22
|
* @param cdp - CDP connection
|
|
22
23
|
* @param options - Optional configuration
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
26
|
* ```typescript
|
|
26
|
-
* // Default:
|
|
27
|
+
* // Default: Wait up to 5s for full stability
|
|
27
28
|
* await waitForPageReady(cdp);
|
|
28
29
|
*
|
|
29
|
-
* // Custom timeout for slow apps
|
|
30
|
-
* await waitForPageReady(cdp, { maxWaitMs:
|
|
30
|
+
* // Custom timeout for very slow apps
|
|
31
|
+
* await waitForPageReady(cdp, { maxWaitMs: 15000 });
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
34
|
export async function waitForPageReady(cdp, options = {}) {
|
|
34
|
-
const maxWaitMs = options.maxWaitMs ??
|
|
35
|
+
const maxWaitMs = options.maxWaitMs ?? 5000;
|
|
35
36
|
const deadline = Date.now() + maxWaitMs;
|
|
36
37
|
try {
|
|
37
|
-
// Phase 1: Wait for load event (
|
|
38
|
+
// Phase 1: Wait for load event (baseline)
|
|
38
39
|
await waitForLoadEvent(cdp, deadline);
|
|
39
40
|
console.error('[readiness] ✓ Load event');
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
41
|
+
// Phase 2: Wait for network stability (always - modern web is async)
|
|
42
|
+
const networkIdleMs = await waitForNetworkStable(cdp, deadline);
|
|
43
|
+
console.error(`[readiness] ✓ Network stable (${networkIdleMs}ms idle)`);
|
|
44
|
+
// Phase 3: Wait for DOM stability (always - SPAs mutate after load)
|
|
45
|
+
const domIdleMs = await waitForDOMStable(cdp, deadline);
|
|
46
|
+
console.error(`[readiness] ✓ DOM stable (${domIdleMs}ms idle)`);
|
|
47
47
|
console.error('[readiness] ✓ Page ready');
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageReadiness.js","sourceRoot":"","sources":["../../src/utils/pageReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"pageReadiness.js","sourceRoot":"","sources":["../../src/utils/pageReadiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAeH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAkB,EAClB,UAAgC,EAAE;IAElC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IAExC,IAAI,CAAC;QACH,0CAA0C;QAC1C,MAAM,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAE1C,qEAAqE;QACrE,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAChE,OAAO,CAAC,KAAK,CAAC,iCAAi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 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* URL normalization and
|
|
3
|
-
*
|
|
4
|
-
* Note: Display formatting functions (truncateUrl, truncateText) have been
|
|
5
|
-
* moved to \@/ui/formatting.js as part of UI centralization.
|
|
2
|
+
* URL normalization, validation, and parsing utilities.
|
|
6
3
|
*/
|
|
7
4
|
/**
|
|
8
5
|
* Normalize a URL by adding http:// protocol if missing.
|
|
@@ -21,13 +18,15 @@
|
|
|
21
18
|
* normalizeUrl('about:blank') // → 'about:blank' (unchanged)
|
|
22
19
|
* normalizeUrl('chrome://settings') // → 'chrome://settings' (unchanged)
|
|
23
20
|
* ```
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* javascript: protocol is preserved for compatibility with browser automation,
|
|
24
|
+
* though it's generally not recommended for direct navigation.
|
|
24
25
|
*/
|
|
25
26
|
export declare function normalizeUrl(url: string): string;
|
|
26
27
|
/**
|
|
27
28
|
* Validate that a URL is valid and usable for Chrome navigation.
|
|
28
29
|
*
|
|
29
|
-
* WHY: Provides clear error messages before attempting to launch Chrome.
|
|
30
|
-
*
|
|
31
30
|
* @param url - URL string to validate
|
|
32
31
|
* @returns Object with valid flag and error message if invalid
|
|
33
32
|
*
|
|
@@ -41,10 +40,63 @@ export declare function normalizeUrl(url: string): string;
|
|
|
41
40
|
* // → "URLs must include a valid protocol (http:// or https://)"
|
|
42
41
|
* }
|
|
43
42
|
* ```
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Validation is strict to prevent common errors like spaces or invalid protocols.
|
|
46
|
+
* All URLs are normalized before validation to support convenient formats like
|
|
47
|
+
* 'localhost:3000' or 'example.com'.
|
|
44
48
|
*/
|
|
45
49
|
export declare function validateUrl(url: string): {
|
|
46
50
|
valid: boolean;
|
|
47
51
|
error?: string;
|
|
48
52
|
suggestion?: string;
|
|
49
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Safely parse a URL string with automatic protocol detection.
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* @param input - URL string to parse (may lack protocol)
|
|
59
|
+
* @returns Parsed URL object, or null if parsing fails both attempts
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* safeParseUrl('https://example.com') // → URL { ... }
|
|
64
|
+
* safeParseUrl('localhost:3000') // → URL { protocol: 'http:', ... }
|
|
65
|
+
* safeParseUrl('example.com/path') // → URL { protocol: 'http:', ... }
|
|
66
|
+
* safeParseUrl('not a url') // → null
|
|
67
|
+
* safeParseUrl('file:///path/to/file.html') // → URL { protocol: 'file:', ... }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function safeParseUrl(input: string): URL | null;
|
|
71
|
+
/**
|
|
72
|
+
* Extract hostname from a URL string safely.
|
|
73
|
+
*
|
|
74
|
+
* @param input - URL string to extract hostname from
|
|
75
|
+
* @returns Hostname (e.g., 'example.com'), or original input if parsing fails
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* extractHostname('https://example.com/path') // → 'example.com'
|
|
80
|
+
* extractHostname('localhost:3000') // → 'localhost'
|
|
81
|
+
* extractHostname('invalid') // → 'invalid'
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function extractHostname(input: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Extract hostname with pathname from a URL string safely.
|
|
87
|
+
*
|
|
88
|
+
* Useful for pattern matching that needs both hostname and path segments.
|
|
89
|
+
*
|
|
90
|
+
* @param input - URL string to extract hostname+pathname from
|
|
91
|
+
* @returns Hostname with pathname (e.g., 'example.com/api/users'), or original input if parsing fails
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* extractHostnameWithPath('https://api.example.com/v1/users?id=123')
|
|
96
|
+
* // → 'api.example.com/v1/users'
|
|
97
|
+
* extractHostnameWithPath('localhost:3000/dashboard')
|
|
98
|
+
* // → 'localhost/dashboard'
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function extractHostnameWithPath(input: string): string;
|
|
50
102
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/utils/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwCH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhD;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAgDA;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAYtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG7D"}
|
package/dist/utils/url.js
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* URL normalization and
|
|
2
|
+
* URL normalization, validation, and parsing utilities.
|
|
3
|
+
*/
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Constants
|
|
6
|
+
// ============================================================================
|
|
7
|
+
/**
|
|
8
|
+
* Valid URL protocols for Chrome navigation.
|
|
3
9
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
10
|
+
* Excludes legacy protocols (vbscript) and limits to protocols
|
|
11
|
+
* actually useful for modern web debugging scenarios.
|
|
12
|
+
*/
|
|
13
|
+
const VALID_PROTOCOLS = [
|
|
14
|
+
'http:',
|
|
15
|
+
'https:',
|
|
16
|
+
'file:',
|
|
17
|
+
'about:',
|
|
18
|
+
'chrome:',
|
|
19
|
+
'data:',
|
|
20
|
+
'blob:',
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Protocol prefixes that should be preserved as-is during normalization.
|
|
6
24
|
*/
|
|
25
|
+
const PRESERVED_PROTOCOL_PREFIXES = [
|
|
26
|
+
'http://',
|
|
27
|
+
'https://',
|
|
28
|
+
'file://',
|
|
29
|
+
'about:',
|
|
30
|
+
'chrome:',
|
|
31
|
+
'data:',
|
|
32
|
+
'javascript:',
|
|
33
|
+
'blob:',
|
|
34
|
+
];
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// URL Normalization
|
|
37
|
+
// ============================================================================
|
|
7
38
|
/**
|
|
8
39
|
* Normalize a URL by adding http:// protocol if missing.
|
|
9
40
|
*
|
|
@@ -21,27 +52,24 @@
|
|
|
21
52
|
* normalizeUrl('about:blank') // → 'about:blank' (unchanged)
|
|
22
53
|
* normalizeUrl('chrome://settings') // → 'chrome://settings' (unchanged)
|
|
23
54
|
* ```
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* javascript: protocol is preserved for compatibility with browser automation,
|
|
58
|
+
* though it's generally not recommended for direct navigation.
|
|
24
59
|
*/
|
|
25
60
|
export function normalizeUrl(url) {
|
|
26
61
|
// Check for protocols that should not be modified
|
|
27
|
-
if (url.startsWith(
|
|
28
|
-
url.startsWith('https://') ||
|
|
29
|
-
url.startsWith('file://') ||
|
|
30
|
-
url.startsWith('about:') ||
|
|
31
|
-
url.startsWith('chrome:') ||
|
|
32
|
-
url.startsWith('data:') ||
|
|
33
|
-
url.startsWith('javascript:') ||
|
|
34
|
-
url.startsWith('vbscript:') ||
|
|
35
|
-
url.startsWith('blob:')) {
|
|
62
|
+
if (PRESERVED_PROTOCOL_PREFIXES.some((prefix) => url.startsWith(prefix))) {
|
|
36
63
|
return url;
|
|
37
64
|
}
|
|
38
65
|
return `http://${url}`;
|
|
39
66
|
}
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// URL Validation
|
|
69
|
+
// ============================================================================
|
|
40
70
|
/**
|
|
41
71
|
* Validate that a URL is valid and usable for Chrome navigation.
|
|
42
72
|
*
|
|
43
|
-
* WHY: Provides clear error messages before attempting to launch Chrome.
|
|
44
|
-
*
|
|
45
73
|
* @param url - URL string to validate
|
|
46
74
|
* @returns Object with valid flag and error message if invalid
|
|
47
75
|
*
|
|
@@ -55,6 +83,11 @@ export function normalizeUrl(url) {
|
|
|
55
83
|
* // → "URLs must include a valid protocol (http:// or https://)"
|
|
56
84
|
* }
|
|
57
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* Validation is strict to prevent common errors like spaces or invalid protocols.
|
|
89
|
+
* All URLs are normalized before validation to support convenient formats like
|
|
90
|
+
* 'localhost:3000' or 'example.com'.
|
|
58
91
|
*/
|
|
59
92
|
export function validateUrl(url) {
|
|
60
93
|
// Empty URL
|
|
@@ -65,21 +98,24 @@ export function validateUrl(url) {
|
|
|
65
98
|
suggestion: 'Provide a valid URL, e.g.: http://localhost:3000',
|
|
66
99
|
};
|
|
67
100
|
}
|
|
68
|
-
//
|
|
101
|
+
// Check for spaces (common error)
|
|
102
|
+
if (url.includes(' ')) {
|
|
103
|
+
return {
|
|
104
|
+
valid: false,
|
|
105
|
+
error: `Invalid URL format: '${url}' (contains spaces)`,
|
|
106
|
+
suggestion: 'URLs cannot contain spaces',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
69
109
|
const normalized = normalizeUrl(url);
|
|
70
|
-
// Try to parse as URL
|
|
71
110
|
try {
|
|
72
111
|
const parsed = new URL(normalized);
|
|
73
|
-
|
|
74
|
-
const validProtocols = ['http:', 'https:', 'file:', 'about:', 'chrome:', 'data:'];
|
|
75
|
-
if (!validProtocols.includes(parsed.protocol)) {
|
|
112
|
+
if (!VALID_PROTOCOLS.includes(parsed.protocol)) {
|
|
76
113
|
return {
|
|
77
114
|
valid: false,
|
|
78
115
|
error: `Invalid protocol: '${parsed.protocol}'`,
|
|
79
116
|
suggestion: 'URLs must use http://, https://, or other valid protocols',
|
|
80
117
|
};
|
|
81
118
|
}
|
|
82
|
-
// Check for valid hostname (for http/https)
|
|
83
119
|
if ((parsed.protocol === 'http:' || parsed.protocol === 'https:') && !parsed.hostname) {
|
|
84
120
|
return {
|
|
85
121
|
valid: false,
|
|
@@ -97,4 +133,75 @@ export function validateUrl(url) {
|
|
|
97
133
|
};
|
|
98
134
|
}
|
|
99
135
|
}
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// Safe URL Parsing
|
|
138
|
+
// ============================================================================
|
|
139
|
+
/**
|
|
140
|
+
* Safely parse a URL string with automatic protocol detection.
|
|
141
|
+
*
|
|
142
|
+
*
|
|
143
|
+
* @param input - URL string to parse (may lack protocol)
|
|
144
|
+
* @returns Parsed URL object, or null if parsing fails both attempts
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* safeParseUrl('https://example.com') // → URL { ... }
|
|
149
|
+
* safeParseUrl('localhost:3000') // → URL { protocol: 'http:', ... }
|
|
150
|
+
* safeParseUrl('example.com/path') // → URL { protocol: 'http:', ... }
|
|
151
|
+
* safeParseUrl('not a url') // → null
|
|
152
|
+
* safeParseUrl('file:///path/to/file.html') // → URL { protocol: 'file:', ... }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export function safeParseUrl(input) {
|
|
156
|
+
try {
|
|
157
|
+
return new URL(input);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Second attempt: add http:// prefix for protocol-less URLs
|
|
161
|
+
try {
|
|
162
|
+
return new URL(`http://${input}`);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Both attempts failed - invalid URL
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Extract hostname from a URL string safely.
|
|
172
|
+
*
|
|
173
|
+
* @param input - URL string to extract hostname from
|
|
174
|
+
* @returns Hostname (e.g., 'example.com'), or original input if parsing fails
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* extractHostname('https://example.com/path') // → 'example.com'
|
|
179
|
+
* extractHostname('localhost:3000') // → 'localhost'
|
|
180
|
+
* extractHostname('invalid') // → 'invalid'
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export function extractHostname(input) {
|
|
184
|
+
const parsed = safeParseUrl(input);
|
|
185
|
+
return parsed?.hostname ?? input;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Extract hostname with pathname from a URL string safely.
|
|
189
|
+
*
|
|
190
|
+
* Useful for pattern matching that needs both hostname and path segments.
|
|
191
|
+
*
|
|
192
|
+
* @param input - URL string to extract hostname+pathname from
|
|
193
|
+
* @returns Hostname with pathname (e.g., 'example.com/api/users'), or original input if parsing fails
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* extractHostnameWithPath('https://api.example.com/v1/users?id=123')
|
|
198
|
+
* // → 'api.example.com/v1/users'
|
|
199
|
+
* extractHostnameWithPath('localhost:3000/dashboard')
|
|
200
|
+
* // → 'localhost/dashboard'
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export function extractHostnameWithPath(input) {
|
|
204
|
+
const parsed = safeParseUrl(input);
|
|
205
|
+
return parsed ? parsed.hostname + parsed.pathname : input;
|
|
206
|
+
}
|
|
100
207
|
//# sourceMappingURL=url.js.map
|