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
package/dist/utils/errors.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom error classes for bdg CLI.
|
|
3
|
-
*
|
|
4
|
-
* Provides structured error handling with error codes and categorization
|
|
5
|
-
* for better debugging and user-friendly error messages.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Base error class for all bdg errors.
|
|
9
|
-
*
|
|
10
|
-
* Extends native Error with:
|
|
11
|
-
* - Error codes for programmatic handling
|
|
12
|
-
* - Category for filtering (system/user/external)
|
|
13
|
-
* - Exit code for semantic exit codes (80-99 user errors, 100-119 software errors)
|
|
14
|
-
* - Cause chaining for nested errors
|
|
15
|
-
*/
|
|
16
|
-
export class BdgError extends Error {
|
|
17
|
-
constructor(message, cause) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.name = this.constructor.name;
|
|
20
|
-
this.cause = cause;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* CDP connection failed (network/protocol issues).
|
|
25
|
-
*
|
|
26
|
-
* Examples:
|
|
27
|
-
* - WebSocket connection refused
|
|
28
|
-
* - Chrome not running on specified port
|
|
29
|
-
* - Protocol version mismatch
|
|
30
|
-
*/
|
|
31
|
-
export class CDPConnectionError extends BdgError {
|
|
32
|
-
code = 'CDP_CONNECTION_ERROR';
|
|
33
|
-
category = 'external';
|
|
34
|
-
exitCode = 101; // CDP_CONNECTION_FAILURE
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Chrome launch failed.
|
|
38
|
-
*
|
|
39
|
-
* Examples:
|
|
40
|
-
* - Chrome binary not found
|
|
41
|
-
* - Insufficient permissions
|
|
42
|
-
* - Port already in use
|
|
43
|
-
*/
|
|
44
|
-
export class ChromeLaunchError extends BdgError {
|
|
45
|
-
code = 'CHROME_LAUNCH_ERROR';
|
|
46
|
-
category = 'system';
|
|
47
|
-
exitCode = 100; // CHROME_LAUNCH_FAILURE
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* CDP command timed out.
|
|
51
|
-
*
|
|
52
|
-
* Examples:
|
|
53
|
-
* - Command took longer than 30s
|
|
54
|
-
* - Browser became unresponsive
|
|
55
|
-
*/
|
|
56
|
-
export class CDPTimeoutError extends BdgError {
|
|
57
|
-
code = 'CDP_TIMEOUT_ERROR';
|
|
58
|
-
category = 'external';
|
|
59
|
-
exitCode = 102; // CDP_TIMEOUT
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Extract error message from unknown error type.
|
|
63
|
-
*
|
|
64
|
-
* Safely extracts error messages from various error types:
|
|
65
|
-
* - Error instances → error.message
|
|
66
|
-
* - Unknown types → String(error)
|
|
67
|
-
*
|
|
68
|
-
* Useful for error handling when error type is unknown.
|
|
69
|
-
*
|
|
70
|
-
* @param error - Error of unknown type
|
|
71
|
-
* @returns Error message string
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* try {
|
|
76
|
-
* await someOperation();
|
|
77
|
-
* } catch (error) {
|
|
78
|
-
* throw new ChromeLaunchError(`Failed: ${getErrorMessage(error)}`, error);
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export function getErrorMessage(error) {
|
|
83
|
-
if (error instanceof Error) {
|
|
84
|
-
return error.message;
|
|
85
|
-
}
|
|
86
|
-
return String(error);
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/utils/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,OAAgB,QAAS,SAAQ,KAAK;IAK1C,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,QAAQ;IACrC,IAAI,GAAG,sBAAsB,CAAC;IAC9B,QAAQ,GAAG,UAAmB,CAAC;IAC/B,QAAQ,GAAG,GAAG,CAAC,CAAC,yBAAyB;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IACpC,IAAI,GAAG,qBAAqB,CAAC;IAC7B,QAAQ,GAAG,QAAiB,CAAC;IAC7B,QAAQ,GAAG,GAAG,CAAC,CAAC,wBAAwB;CAClD;AAED;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAClC,IAAI,GAAG,mBAAmB,CAAC;IAC3B,QAAQ,GAAG,UAAmB,CAAC;IAC/B,QAAQ,GAAG,GAAG,CAAC,CAAC,cAAc;CACxC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/utils/filters.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default filters for reducing noise in collected data
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Decision object for whether to fetch a response body.
|
|
6
|
-
*/
|
|
7
|
-
export interface BodyFetchDecision {
|
|
8
|
-
/** Whether the body should be fetched */
|
|
9
|
-
should: boolean;
|
|
10
|
-
/** Reason why the body was skipped (if should is false) */
|
|
11
|
-
reason?: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Domains to exclude by default (common tracking/analytics)
|
|
15
|
-
* These generate high volume but are rarely useful for debugging
|
|
16
|
-
*/
|
|
17
|
-
export declare const DEFAULT_EXCLUDED_DOMAINS: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Console message types to exclude by default (Redux/React DevTools noise)
|
|
20
|
-
*/
|
|
21
|
-
export declare const DEFAULT_EXCLUDED_CONSOLE_TYPES: string[];
|
|
22
|
-
/**
|
|
23
|
-
* Console message patterns to exclude by default (dev server noise)
|
|
24
|
-
*/
|
|
25
|
-
export declare const DEFAULT_EXCLUDED_CONSOLE_PATTERNS: string[];
|
|
26
|
-
/**
|
|
27
|
-
* File patterns to skip body fetching by default (assets unlikely to be useful for debugging)
|
|
28
|
-
* These reduce data volume significantly without losing critical debugging information.
|
|
29
|
-
*/
|
|
30
|
-
export declare const DEFAULT_SKIP_BODY_PATTERNS: string[];
|
|
31
|
-
/**
|
|
32
|
-
* MIME types to skip body fetching by default
|
|
33
|
-
* This catches resources that may not have obvious file extensions (e.g., CSS with query params)
|
|
34
|
-
*/
|
|
35
|
-
export declare const DEFAULT_SKIP_BODY_MIME_TYPES: string[];
|
|
36
|
-
/**
|
|
37
|
-
* Check if a URL should be excluded based on domain filtering.
|
|
38
|
-
*
|
|
39
|
-
* @param url - URL to check against exclusion list
|
|
40
|
-
* @param includeAll - If true, disables all filtering
|
|
41
|
-
* @returns True if the URL's domain matches an excluded domain
|
|
42
|
-
*/
|
|
43
|
-
export declare function shouldExcludeDomain(url: string, includeAll?: boolean): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Check if a console message should be excluded based on type and pattern filtering
|
|
46
|
-
*/
|
|
47
|
-
export declare function shouldExcludeConsoleMessage(text: string, type: string, includeAll?: boolean): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Simple wildcard pattern matcher.
|
|
50
|
-
* Supports only the * wildcard character.
|
|
51
|
-
*
|
|
52
|
-
* Examples:
|
|
53
|
-
* matchesWildcard("api.json", "*.json") → true
|
|
54
|
-
* matchesWildcard("api/users", "*api*") → true
|
|
55
|
-
* matchesWildcard("index.html", "*.js") → false
|
|
56
|
-
*
|
|
57
|
-
* @param str - The string to test
|
|
58
|
-
* @param pattern - The pattern with * wildcards
|
|
59
|
-
* @returns True if the string matches the pattern
|
|
60
|
-
*/
|
|
61
|
-
export declare function matchesWildcard(str: string, pattern: string): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Check if a URL matches any pattern in a list.
|
|
64
|
-
*
|
|
65
|
-
* Matches against both bare hostname and hostname+pathname to support:
|
|
66
|
-
* - Bare hostname patterns: `api.example.com` matches all requests to that host
|
|
67
|
-
* - Hostname wildcard patterns: `*analytics*` matches "analytics.google.com/collect"
|
|
68
|
-
* - Path patterns: `*\/api\/*` matches "example.com/api/users"
|
|
69
|
-
* - Combined patterns: `api.example.com\/users` matches specific endpoint
|
|
70
|
-
*
|
|
71
|
-
* @param url - The URL to check
|
|
72
|
-
* @param patterns - Array of wildcard patterns
|
|
73
|
-
* @returns True if URL matches any pattern
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* Determine if a response body should be fetched based on URL, MIME type, and patterns.
|
|
77
|
-
*
|
|
78
|
-
* Pattern precedence (follows include-trumps-exclude rule):
|
|
79
|
-
* 1. If URL matches includePatterns → FETCH (even if it also matches excludePatterns)
|
|
80
|
-
* 2. If includePatterns specified but URL doesn't match → SKIP (whitelist mode)
|
|
81
|
-
* 3. If URL matches excludePatterns → SKIP
|
|
82
|
-
* 4. If fetchAllBodies flag is true → FETCH
|
|
83
|
-
* 5. If MIME type matches DEFAULT_SKIP_BODY_MIME_TYPES → SKIP
|
|
84
|
-
* 6. If URL matches DEFAULT_SKIP_BODY_PATTERNS → SKIP
|
|
85
|
-
* 7. Otherwise → FETCH (default behavior)
|
|
86
|
-
*
|
|
87
|
-
* @param url - The request URL
|
|
88
|
-
* @param mimeType - The response MIME type (for MIME-based skipping)
|
|
89
|
-
* @param options - Configuration options
|
|
90
|
-
* @returns True if the body should be fetched
|
|
91
|
-
*/
|
|
92
|
-
export declare function shouldFetchBody(url: string, mimeType: string | undefined, options?: {
|
|
93
|
-
fetchAllBodies?: boolean;
|
|
94
|
-
includePatterns?: string[];
|
|
95
|
-
excludePatterns?: string[];
|
|
96
|
-
}): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Determine if a response body should be fetched with detailed reason.
|
|
99
|
-
*
|
|
100
|
-
* Combines all decision logic: MIME type, size limits, smart defaults, and fetch flags.
|
|
101
|
-
* Returns a decision object with reason string for logging/debugging.
|
|
102
|
-
*
|
|
103
|
-
* @param url - Request URL
|
|
104
|
-
* @param mimeType - Response MIME type
|
|
105
|
-
* @param encodedDataLength - Response size in bytes
|
|
106
|
-
* @param options - Configuration options
|
|
107
|
-
* @returns Decision object with should boolean and optional reason
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* const decision = shouldFetchBodyWithReason(
|
|
112
|
-
* 'https://api.example.com/data',
|
|
113
|
-
* 'application/json',
|
|
114
|
-
* 1024,
|
|
115
|
-
* { maxBodySize: 5 * 1024 * 1024 }
|
|
116
|
-
* );
|
|
117
|
-
* if (!decision.should) {
|
|
118
|
-
* console.log(`Skipped: ${decision.reason}`);
|
|
119
|
-
* }
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export declare function shouldFetchBodyWithReason(url: string, mimeType: string | undefined, encodedDataLength: number, options?: {
|
|
123
|
-
fetchAllBodies?: boolean;
|
|
124
|
-
includePatterns?: string[];
|
|
125
|
-
excludePatterns?: string[];
|
|
126
|
-
maxBodySize?: number;
|
|
127
|
-
}): BodyFetchDecision;
|
|
128
|
-
/**
|
|
129
|
-
* Determine if a network request should be excluded based on URL patterns.
|
|
130
|
-
*
|
|
131
|
-
* Pattern precedence (follows include-trumps-exclude rule):
|
|
132
|
-
* 1. If URL matches includePatterns → CAPTURE (even if it also matches excludePatterns)
|
|
133
|
-
* 2. If includePatterns specified but URL doesn't match → EXCLUDE (whitelist mode)
|
|
134
|
-
* 3. If URL matches excludePatterns → EXCLUDE
|
|
135
|
-
* 4. Otherwise → CAPTURE (default behavior)
|
|
136
|
-
*
|
|
137
|
-
* Note: This function is separate from domain filtering (shouldExcludeDomain).
|
|
138
|
-
* Both filters can be applied: domain filtering happens first, then URL pattern filtering.
|
|
139
|
-
*
|
|
140
|
-
* @param url - The request URL
|
|
141
|
-
* @param options - Configuration options
|
|
142
|
-
* @returns True if the request should be excluded
|
|
143
|
-
*/
|
|
144
|
-
export declare function shouldExcludeUrl(url: string, options?: {
|
|
145
|
-
includePatterns?: string[];
|
|
146
|
-
excludePatterns?: string[];
|
|
147
|
-
}): boolean;
|
|
148
|
-
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":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,EAAE,MAAM,EACzB,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACjB,GACL,iBAAiB,CAmCnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,GACL,OAAO,CAST"}
|
package/dist/utils/filters.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default filters for reducing noise in collected data
|
|
3
|
-
*/
|
|
4
|
-
import { extractHostname, extractHostnameWithPath } from './url.js';
|
|
5
|
-
/**
|
|
6
|
-
* Domains to exclude by default (common tracking/analytics)
|
|
7
|
-
* These generate high volume but are rarely useful for debugging
|
|
8
|
-
*/
|
|
9
|
-
export const DEFAULT_EXCLUDED_DOMAINS = [
|
|
10
|
-
// Google Analytics & Ads
|
|
11
|
-
'analytics.google.com',
|
|
12
|
-
'googletagmanager.com',
|
|
13
|
-
'googleadservices.com',
|
|
14
|
-
'doubleclick.net',
|
|
15
|
-
'google-analytics.com',
|
|
16
|
-
// Microsoft/Bing
|
|
17
|
-
'clarity.ms',
|
|
18
|
-
'bat.bing.com',
|
|
19
|
-
// Social Media Tracking
|
|
20
|
-
'facebook.com',
|
|
21
|
-
'connect.facebook.net',
|
|
22
|
-
'tiktok.com',
|
|
23
|
-
'linkedin.com',
|
|
24
|
-
'twitter.com',
|
|
25
|
-
'snapchat.com',
|
|
26
|
-
// Product Analytics
|
|
27
|
-
'mixpanel.com',
|
|
28
|
-
'segment.com',
|
|
29
|
-
'segment.io',
|
|
30
|
-
'amplitude.com',
|
|
31
|
-
'heap.io',
|
|
32
|
-
// Session Recording & Heatmaps
|
|
33
|
-
'fullstory.com',
|
|
34
|
-
'hotjar.com',
|
|
35
|
-
'logrocket.com',
|
|
36
|
-
'smartlook.com',
|
|
37
|
-
// Ad Networks & Attribution
|
|
38
|
-
'exactag.com',
|
|
39
|
-
'criteo.com',
|
|
40
|
-
'adroll.com',
|
|
41
|
-
'outbrain.com',
|
|
42
|
-
'taboola.com',
|
|
43
|
-
// Other Analytics
|
|
44
|
-
'confirmit.com',
|
|
45
|
-
'newrelic.com',
|
|
46
|
-
'datadoghq.com',
|
|
47
|
-
'sentry.io',
|
|
48
|
-
];
|
|
49
|
-
/**
|
|
50
|
-
* Console message types to exclude by default (Redux/React DevTools noise)
|
|
51
|
-
*/
|
|
52
|
-
export const DEFAULT_EXCLUDED_CONSOLE_TYPES = ['startGroup', 'startGroupCollapsed', 'endGroup'];
|
|
53
|
-
/**
|
|
54
|
-
* Console message patterns to exclude by default (dev server noise)
|
|
55
|
-
*/
|
|
56
|
-
export const DEFAULT_EXCLUDED_CONSOLE_PATTERNS = [
|
|
57
|
-
'webpack-dev-server',
|
|
58
|
-
'[HMR]',
|
|
59
|
-
'[WDS]',
|
|
60
|
-
'Download the React DevTools',
|
|
61
|
-
'@@redux', // Redux actions
|
|
62
|
-
'%c prev state', // Redux logger
|
|
63
|
-
'%c action', // Redux logger
|
|
64
|
-
'%c next state', // Redux logger
|
|
65
|
-
];
|
|
66
|
-
/**
|
|
67
|
-
* File patterns to skip body fetching by default (assets unlikely to be useful for debugging)
|
|
68
|
-
* These reduce data volume significantly without losing critical debugging information.
|
|
69
|
-
*/
|
|
70
|
-
export const DEFAULT_SKIP_BODY_PATTERNS = [
|
|
71
|
-
// Images
|
|
72
|
-
'*.png',
|
|
73
|
-
'*.jpg',
|
|
74
|
-
'*.jpeg',
|
|
75
|
-
'*.gif',
|
|
76
|
-
'*.svg',
|
|
77
|
-
'*.ico',
|
|
78
|
-
'*.webp',
|
|
79
|
-
'*.bmp',
|
|
80
|
-
'*.tiff',
|
|
81
|
-
// Fonts
|
|
82
|
-
'*.woff',
|
|
83
|
-
'*.woff2',
|
|
84
|
-
'*.ttf',
|
|
85
|
-
'*.eot',
|
|
86
|
-
'*.otf',
|
|
87
|
-
// Stylesheets
|
|
88
|
-
'*.css',
|
|
89
|
-
// Source maps (can be large and rarely needed)
|
|
90
|
-
'*.map',
|
|
91
|
-
'*.js.map',
|
|
92
|
-
'*.css.map',
|
|
93
|
-
// Videos
|
|
94
|
-
'*.mp4',
|
|
95
|
-
'*.webm',
|
|
96
|
-
'*.ogg',
|
|
97
|
-
'*.avi',
|
|
98
|
-
'*.mov',
|
|
99
|
-
// Audio
|
|
100
|
-
'*.mp3',
|
|
101
|
-
'*.wav',
|
|
102
|
-
'*.flac',
|
|
103
|
-
'*.aac',
|
|
104
|
-
];
|
|
105
|
-
/**
|
|
106
|
-
* MIME types to skip body fetching by default
|
|
107
|
-
* This catches resources that may not have obvious file extensions (e.g., CSS with query params)
|
|
108
|
-
*/
|
|
109
|
-
export const DEFAULT_SKIP_BODY_MIME_TYPES = [
|
|
110
|
-
'text/css',
|
|
111
|
-
'image/svg+xml',
|
|
112
|
-
'image/png',
|
|
113
|
-
'image/jpeg',
|
|
114
|
-
'image/gif',
|
|
115
|
-
'image/webp',
|
|
116
|
-
'image/avif',
|
|
117
|
-
'image/bmp',
|
|
118
|
-
'image/tiff',
|
|
119
|
-
'font/woff',
|
|
120
|
-
'font/woff2',
|
|
121
|
-
'font/ttf',
|
|
122
|
-
'font/eot',
|
|
123
|
-
'font/otf',
|
|
124
|
-
'application/font-woff',
|
|
125
|
-
'application/font-woff2',
|
|
126
|
-
'video/mp4',
|
|
127
|
-
'video/webm',
|
|
128
|
-
'audio/mpeg',
|
|
129
|
-
'audio/wav',
|
|
130
|
-
];
|
|
131
|
-
/**
|
|
132
|
-
* Check if a URL should be excluded based on domain filtering.
|
|
133
|
-
*
|
|
134
|
-
* @param url - URL to check against exclusion list
|
|
135
|
-
* @param includeAll - If true, disables all filtering
|
|
136
|
-
* @returns True if the URL's domain matches an excluded domain
|
|
137
|
-
*/
|
|
138
|
-
export function shouldExcludeDomain(url, includeAll = false) {
|
|
139
|
-
if (includeAll) {
|
|
140
|
-
return false; // Don't filter anything if --include-all flag is set
|
|
141
|
-
}
|
|
142
|
-
const hostname = extractHostname(url).toLowerCase();
|
|
143
|
-
return DEFAULT_EXCLUDED_DOMAINS.some((domain) => hostname.includes(domain.toLowerCase()));
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Check if a console message should be excluded based on type and pattern filtering
|
|
147
|
-
*/
|
|
148
|
-
export function shouldExcludeConsoleMessage(text, type, includeAll = false) {
|
|
149
|
-
if (includeAll) {
|
|
150
|
-
return false; // Don't filter anything if --include-all flag is set
|
|
151
|
-
}
|
|
152
|
-
// Check if message type should be excluded (e.g., group messages)
|
|
153
|
-
if (DEFAULT_EXCLUDED_CONSOLE_TYPES.includes(type)) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
const lowerText = text.toLowerCase();
|
|
157
|
-
return DEFAULT_EXCLUDED_CONSOLE_PATTERNS.some((pattern) => lowerText.includes(pattern.toLowerCase()));
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Evaluate whether a URL matches pattern rules using include-trumps-exclude logic.
|
|
161
|
-
*
|
|
162
|
-
* Provides centralized pattern matching with consistent precedence rules:
|
|
163
|
-
* 1. If URL matches includePatterns → true (even if it also matches excludePatterns)
|
|
164
|
-
* 2. If includePatterns specified but URL doesn't match → false (whitelist mode)
|
|
165
|
-
* 3. If URL matches excludePatterns → false
|
|
166
|
-
* 4. Otherwise → use defaultBehavior
|
|
167
|
-
*
|
|
168
|
-
* This function consolidates the URL parsing and wildcard matching logic that was
|
|
169
|
-
* previously duplicated across multiple filter functions.
|
|
170
|
-
*
|
|
171
|
-
* @param url - The URL to check against patterns
|
|
172
|
-
* @param config - Pattern matching configuration with include/exclude patterns
|
|
173
|
-
* @returns True if the URL should be included based on pattern rules
|
|
174
|
-
*/
|
|
175
|
-
function evaluatePatternMatch(url, config) {
|
|
176
|
-
const { includePatterns = [], excludePatterns = [], defaultBehavior = 'include' } = config;
|
|
177
|
-
// Parse URL once for all pattern checks
|
|
178
|
-
const hostname = extractHostname(url);
|
|
179
|
-
const hostnameWithPath = extractHostnameWithPath(url);
|
|
180
|
-
// Helper: check if any pattern matches hostname or hostname+path
|
|
181
|
-
const matchesAny = (patterns) => patterns.some((pattern) => matchesWildcard(hostname, pattern) || matchesWildcard(hostnameWithPath, pattern));
|
|
182
|
-
// Compute match states
|
|
183
|
-
const includeSpecified = includePatterns.length > 0;
|
|
184
|
-
const includeMatch = includeSpecified && matchesAny(includePatterns);
|
|
185
|
-
const excludeMatch = excludePatterns.length > 0 && matchesAny(excludePatterns);
|
|
186
|
-
// Decision logic: include trumps exclude, then whitelist mode, then exclude, then default
|
|
187
|
-
return includeMatch || (!includeSpecified && !excludeMatch && defaultBehavior === 'include');
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Simple wildcard pattern matcher.
|
|
191
|
-
* Supports only the * wildcard character.
|
|
192
|
-
*
|
|
193
|
-
* Examples:
|
|
194
|
-
* matchesWildcard("api.json", "*.json") → true
|
|
195
|
-
* matchesWildcard("api/users", "*api*") → true
|
|
196
|
-
* matchesWildcard("index.html", "*.js") → false
|
|
197
|
-
*
|
|
198
|
-
* @param str - The string to test
|
|
199
|
-
* @param pattern - The pattern with * wildcards
|
|
200
|
-
* @returns True if the string matches the pattern
|
|
201
|
-
*/
|
|
202
|
-
export function matchesWildcard(str, pattern) {
|
|
203
|
-
// Escape special regex characters except *
|
|
204
|
-
const regexPattern = pattern
|
|
205
|
-
.replace(/[.+?^${}()|[\]\\]/g, '\\$&') // Escape special chars
|
|
206
|
-
.replace(/\*/g, '.*'); // Replace * with .*
|
|
207
|
-
const regex = new RegExp(`^${regexPattern}$`, 'i'); // Case-insensitive
|
|
208
|
-
return regex.test(str);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Check if a URL matches any pattern in a list.
|
|
212
|
-
*
|
|
213
|
-
* Matches against both bare hostname and hostname+pathname to support:
|
|
214
|
-
* - Bare hostname patterns: `api.example.com` matches all requests to that host
|
|
215
|
-
* - Hostname wildcard patterns: `*analytics*` matches "analytics.google.com/collect"
|
|
216
|
-
* - Path patterns: `*\/api\/*` matches "example.com/api/users"
|
|
217
|
-
* - Combined patterns: `api.example.com\/users` matches specific endpoint
|
|
218
|
-
*
|
|
219
|
-
* @param url - The URL to check
|
|
220
|
-
* @param patterns - Array of wildcard patterns
|
|
221
|
-
* @returns True if URL matches any pattern
|
|
222
|
-
*/
|
|
223
|
-
/**
|
|
224
|
-
* Determine if a response body should be fetched based on URL, MIME type, and patterns.
|
|
225
|
-
*
|
|
226
|
-
* Pattern precedence (follows include-trumps-exclude rule):
|
|
227
|
-
* 1. If URL matches includePatterns → FETCH (even if it also matches excludePatterns)
|
|
228
|
-
* 2. If includePatterns specified but URL doesn't match → SKIP (whitelist mode)
|
|
229
|
-
* 3. If URL matches excludePatterns → SKIP
|
|
230
|
-
* 4. If fetchAllBodies flag is true → FETCH
|
|
231
|
-
* 5. If MIME type matches DEFAULT_SKIP_BODY_MIME_TYPES → SKIP
|
|
232
|
-
* 6. If URL matches DEFAULT_SKIP_BODY_PATTERNS → SKIP
|
|
233
|
-
* 7. Otherwise → FETCH (default behavior)
|
|
234
|
-
*
|
|
235
|
-
* @param url - The request URL
|
|
236
|
-
* @param mimeType - The response MIME type (for MIME-based skipping)
|
|
237
|
-
* @param options - Configuration options
|
|
238
|
-
* @returns True if the body should be fetched
|
|
239
|
-
*/
|
|
240
|
-
export function shouldFetchBody(url, mimeType, options = {}) {
|
|
241
|
-
const { fetchAllBodies = false, includePatterns = [], excludePatterns = [] } = options;
|
|
242
|
-
// If includePatterns specified, act as whitelist (trumps everything else)
|
|
243
|
-
if (includePatterns.length > 0) {
|
|
244
|
-
return evaluatePatternMatch(url, {
|
|
245
|
-
includePatterns,
|
|
246
|
-
defaultBehavior: 'exclude',
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// If excludePatterns specified and URL matches → skip (trumps fetchAllBodies)
|
|
250
|
-
if (excludePatterns.length > 0) {
|
|
251
|
-
const matchesExclude = evaluatePatternMatch(url, {
|
|
252
|
-
includePatterns: excludePatterns,
|
|
253
|
-
defaultBehavior: 'exclude',
|
|
254
|
-
});
|
|
255
|
-
if (matchesExclude) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
// If fetchAllBodies flag is set → fetch everything
|
|
260
|
-
if (fetchAllBodies) {
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
// Check MIME type against default skip list (case-insensitive)
|
|
264
|
-
if (mimeType) {
|
|
265
|
-
const normalizedMimeType = mimeType.toLowerCase().split(';')[0]?.trim() ?? ''; // Remove charset etc.
|
|
266
|
-
if (normalizedMimeType &&
|
|
267
|
-
DEFAULT_SKIP_BODY_MIME_TYPES.some((skipType) => normalizedMimeType === skipType.toLowerCase())) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Apply default auto-skip URL patterns
|
|
272
|
-
const matchesDefaultSkip = evaluatePatternMatch(url, {
|
|
273
|
-
includePatterns: DEFAULT_SKIP_BODY_PATTERNS,
|
|
274
|
-
defaultBehavior: 'exclude',
|
|
275
|
-
});
|
|
276
|
-
// Default: fetch the body unless it matches default skip patterns
|
|
277
|
-
return !matchesDefaultSkip;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Determine if a response body should be fetched with detailed reason.
|
|
281
|
-
*
|
|
282
|
-
* Combines all decision logic: MIME type, size limits, smart defaults, and fetch flags.
|
|
283
|
-
* Returns a decision object with reason string for logging/debugging.
|
|
284
|
-
*
|
|
285
|
-
* @param url - Request URL
|
|
286
|
-
* @param mimeType - Response MIME type
|
|
287
|
-
* @param encodedDataLength - Response size in bytes
|
|
288
|
-
* @param options - Configuration options
|
|
289
|
-
* @returns Decision object with should boolean and optional reason
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```typescript
|
|
293
|
-
* const decision = shouldFetchBodyWithReason(
|
|
294
|
-
* 'https://api.example.com/data',
|
|
295
|
-
* 'application/json',
|
|
296
|
-
* 1024,
|
|
297
|
-
* { maxBodySize: 5 * 1024 * 1024 }
|
|
298
|
-
* );
|
|
299
|
-
* if (!decision.should) {
|
|
300
|
-
* console.log(`Skipped: ${decision.reason}`);
|
|
301
|
-
* }
|
|
302
|
-
* ```
|
|
303
|
-
*/
|
|
304
|
-
export function shouldFetchBodyWithReason(url, mimeType, encodedDataLength, options = {}) {
|
|
305
|
-
const { maxBodySize = 5 * 1024 * 1024 } = options;
|
|
306
|
-
// Check if response is text-based
|
|
307
|
-
const isTextResponse = (mimeType?.includes('json') ?? false) ||
|
|
308
|
-
(mimeType?.includes('javascript') ?? false) ||
|
|
309
|
-
(mimeType?.includes('text') ?? false) ||
|
|
310
|
-
(mimeType?.includes('html') ?? false);
|
|
311
|
-
if (!isTextResponse) {
|
|
312
|
-
return { should: false, reason: 'Non-text response type' };
|
|
313
|
-
}
|
|
314
|
-
// Check size limits
|
|
315
|
-
if (encodedDataLength > maxBodySize) {
|
|
316
|
-
const sizeStr = `${(encodedDataLength / 1024 / 1024).toFixed(2)}MB`;
|
|
317
|
-
const limitStr = `${(maxBodySize / 1024 / 1024).toFixed(2)}MB`;
|
|
318
|
-
return {
|
|
319
|
-
should: false,
|
|
320
|
-
reason: `Response too large (${sizeStr} > ${limitStr})`,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
// Use existing shouldFetchBody for pattern matching
|
|
324
|
-
const shouldFetch = shouldFetchBody(url, mimeType, options);
|
|
325
|
-
if (!shouldFetch) {
|
|
326
|
-
return {
|
|
327
|
-
should: false,
|
|
328
|
-
reason: 'Auto-optimization (see DEFAULT_SKIP_BODY_PATTERNS)',
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
return { should: true };
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Determine if a network request should be excluded based on URL patterns.
|
|
335
|
-
*
|
|
336
|
-
* Pattern precedence (follows include-trumps-exclude rule):
|
|
337
|
-
* 1. If URL matches includePatterns → CAPTURE (even if it also matches excludePatterns)
|
|
338
|
-
* 2. If includePatterns specified but URL doesn't match → EXCLUDE (whitelist mode)
|
|
339
|
-
* 3. If URL matches excludePatterns → EXCLUDE
|
|
340
|
-
* 4. Otherwise → CAPTURE (default behavior)
|
|
341
|
-
*
|
|
342
|
-
* Note: This function is separate from domain filtering (shouldExcludeDomain).
|
|
343
|
-
* Both filters can be applied: domain filtering happens first, then URL pattern filtering.
|
|
344
|
-
*
|
|
345
|
-
* @param url - The request URL
|
|
346
|
-
* @param options - Configuration options
|
|
347
|
-
* @returns True if the request should be excluded
|
|
348
|
-
*/
|
|
349
|
-
export function shouldExcludeUrl(url, options = {}) {
|
|
350
|
-
const { includePatterns = [], excludePatterns = [] } = options;
|
|
351
|
-
// Use unified pattern matching - invert result since we want exclusion logic
|
|
352
|
-
return !evaluatePatternMatch(url, {
|
|
353
|
-
includePatterns,
|
|
354
|
-
excludePatterns,
|
|
355
|
-
defaultBehavior: 'include',
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
//# sourceMappingURL=filters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAYpE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,yBAAyB;IACzB,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,sBAAsB;IAEtB,iBAAiB;IACjB,YAAY;IACZ,cAAc;IAEd,wBAAwB;IACxB,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