@vforsh/argus-watcher 0.1.2 → 0.1.4
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 +67 -14
- package/dist/.tsbuildinfo +1 -1
- package/dist/artifacts.d.ts +13 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +27 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/buffer/LogBuffer.d.ts +8 -3
- package/dist/buffer/LogBuffer.d.ts.map +1 -1
- package/dist/buffer/LogBuffer.js +9 -1
- package/dist/buffer/LogBuffer.js.map +1 -1
- package/dist/buffer/NetBuffer.d.ts +29 -0
- package/dist/buffer/NetBuffer.d.ts.map +1 -0
- package/dist/buffer/NetBuffer.js +85 -0
- package/dist/buffer/NetBuffer.js.map +1 -0
- package/dist/cdp/accessibility.d.ts +18 -0
- package/dist/cdp/accessibility.d.ts.map +1 -0
- package/dist/cdp/accessibility.js +300 -0
- package/dist/cdp/accessibility.js.map +1 -0
- package/dist/cdp/connection.d.ts +39 -0
- package/dist/cdp/connection.d.ts.map +1 -0
- package/dist/cdp/connection.js +131 -0
- package/dist/cdp/connection.js.map +1 -0
- package/dist/cdp/dom/fill.d.ts +22 -0
- package/dist/cdp/dom/fill.d.ts.map +1 -0
- package/dist/cdp/dom/fill.js +59 -0
- package/dist/cdp/dom/fill.js.map +1 -0
- package/dist/cdp/dom/info.d.ts +14 -0
- package/dist/cdp/dom/info.d.ts.map +1 -0
- package/dist/cdp/dom/info.js +52 -0
- package/dist/cdp/dom/info.js.map +1 -0
- package/dist/cdp/dom/insert.d.ts +19 -0
- package/dist/cdp/dom/insert.d.ts.map +1 -0
- package/dist/cdp/dom/insert.js +30 -0
- package/dist/cdp/dom/insert.js.map +1 -0
- package/dist/cdp/dom/modify.d.ts +50 -0
- package/dist/cdp/dom/modify.d.ts.map +1 -0
- package/dist/cdp/dom/modify.js +100 -0
- package/dist/cdp/dom/modify.js.map +1 -0
- package/dist/cdp/dom/remove.d.ts +17 -0
- package/dist/cdp/dom/remove.d.ts.map +1 -0
- package/dist/cdp/dom/remove.js +27 -0
- package/dist/cdp/dom/remove.js.map +1 -0
- package/dist/cdp/dom/selector.d.ts +19 -0
- package/dist/cdp/dom/selector.d.ts.map +1 -0
- package/dist/cdp/dom/selector.js +86 -0
- package/dist/cdp/dom/selector.js.map +1 -0
- package/dist/cdp/dom/setFile.d.ts +21 -0
- package/dist/cdp/dom/setFile.d.ts.map +1 -0
- package/dist/cdp/dom/setFile.js +25 -0
- package/dist/cdp/dom/setFile.js.map +1 -0
- package/dist/cdp/dom/submit.d.ts +15 -0
- package/dist/cdp/dom/submit.d.ts.map +1 -0
- package/dist/cdp/dom/submit.js +130 -0
- package/dist/cdp/dom/submit.js.map +1 -0
- package/dist/cdp/dom/tree.d.ts +16 -0
- package/dist/cdp/dom/tree.d.ts.map +1 -0
- package/dist/cdp/dom/tree.js +100 -0
- package/dist/cdp/dom/tree.js.map +1 -0
- package/dist/cdp/dom/types.d.ts +15 -0
- package/dist/cdp/dom/types.d.ts.map +1 -0
- package/dist/cdp/dom/types.js +2 -0
- package/dist/cdp/dom/types.js.map +1 -0
- package/dist/cdp/dom.d.ts +15 -0
- package/dist/cdp/dom.d.ts.map +1 -0
- package/dist/cdp/dom.js +9 -0
- package/dist/cdp/dom.js.map +1 -0
- package/dist/cdp/editor.d.ts +23 -0
- package/dist/cdp/editor.d.ts.map +1 -0
- package/dist/cdp/editor.js +266 -0
- package/dist/cdp/editor.js.map +1 -0
- package/dist/cdp/emulation.d.ts +16 -0
- package/dist/cdp/emulation.d.ts.map +1 -0
- package/dist/cdp/emulation.js +40 -0
- package/dist/cdp/emulation.js.map +1 -0
- package/dist/cdp/eval.d.ts +11 -0
- package/dist/cdp/eval.d.ts.map +1 -0
- package/dist/cdp/eval.js +79 -0
- package/dist/cdp/eval.js.map +1 -0
- package/dist/cdp/keyboard.d.ts +38 -0
- package/dist/cdp/keyboard.d.ts.map +1 -0
- package/dist/cdp/keyboard.js +148 -0
- package/dist/cdp/keyboard.js.map +1 -0
- package/dist/cdp/mouse.d.ts +49 -0
- package/dist/cdp/mouse.d.ts.map +1 -0
- package/dist/cdp/mouse.js +203 -0
- package/dist/cdp/mouse.js.map +1 -0
- package/dist/cdp/networkCapture.d.ts +11 -0
- package/dist/cdp/networkCapture.d.ts.map +1 -0
- package/dist/cdp/networkCapture.js +99 -0
- package/dist/cdp/networkCapture.js.map +1 -0
- package/dist/cdp/pageIndicator.d.ts +41 -0
- package/dist/cdp/pageIndicator.d.ts.map +1 -0
- package/dist/cdp/pageIndicator.js +395 -0
- package/dist/cdp/pageIndicator.js.map +1 -0
- package/dist/cdp/redaction.d.ts +3 -0
- package/dist/cdp/redaction.d.ts.map +1 -0
- package/dist/cdp/redaction.js +35 -0
- package/dist/cdp/redaction.js.map +1 -0
- package/dist/cdp/remoteObject.d.ts +6 -0
- package/dist/cdp/remoteObject.d.ts.map +1 -0
- package/dist/cdp/remoteObject.js +94 -0
- package/dist/cdp/remoteObject.js.map +1 -0
- package/dist/cdp/screenshot.d.ts +10 -0
- package/dist/cdp/screenshot.d.ts.map +1 -0
- package/dist/cdp/screenshot.js +83 -0
- package/dist/cdp/screenshot.js.map +1 -0
- package/dist/cdp/storageLocal.d.ts +8 -0
- package/dist/cdp/storageLocal.d.ts.map +1 -0
- package/dist/cdp/storageLocal.js +70 -0
- package/dist/cdp/storageLocal.js.map +1 -0
- package/dist/cdp/text-filter.d.ts +6 -0
- package/dist/cdp/text-filter.d.ts.map +1 -0
- package/dist/cdp/text-filter.js +36 -0
- package/dist/cdp/text-filter.js.map +1 -0
- package/dist/cdp/throttle.d.ts +6 -0
- package/dist/cdp/throttle.d.ts.map +1 -0
- package/dist/cdp/throttle.js +9 -0
- package/dist/cdp/throttle.js.map +1 -0
- package/dist/cdp/tracing.d.ts +15 -0
- package/dist/cdp/tracing.d.ts.map +1 -0
- package/dist/cdp/tracing.js +159 -0
- package/dist/cdp/tracing.js.map +1 -0
- package/dist/cdp/watcher.d.ts +17 -2
- package/dist/cdp/watcher.d.ts.map +1 -1
- package/dist/cdp/watcher.js +124 -175
- package/dist/cdp/watcher.js.map +1 -1
- package/dist/emulation/EmulationController.d.ts +12 -0
- package/dist/emulation/EmulationController.d.ts.map +1 -0
- package/dist/emulation/EmulationController.js +83 -0
- package/dist/emulation/EmulationController.js.map +1 -0
- package/dist/events.d.ts +86 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/fileLogs/WatcherFileLogger.d.ts +5 -2
- package/dist/fileLogs/WatcherFileLogger.d.ts.map +1 -1
- package/dist/fileLogs/WatcherFileLogger.js +30 -12
- package/dist/fileLogs/WatcherFileLogger.js.map +1 -1
- package/dist/http/httpUtils.d.ts +25 -0
- package/dist/http/httpUtils.d.ts.map +1 -0
- package/dist/http/httpUtils.js +170 -0
- package/dist/http/httpUtils.js.map +1 -0
- package/dist/http/router.d.ts +5 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +85 -0
- package/dist/http/router.js.map +1 -0
- package/dist/http/routes/getEmulation.d.ts +3 -0
- package/dist/http/routes/getEmulation.d.ts.map +1 -0
- package/dist/http/routes/getEmulation.js +8 -0
- package/dist/http/routes/getEmulation.js.map +1 -0
- package/dist/http/routes/getLogs.d.ts +3 -0
- package/dist/http/routes/getLogs.d.ts.map +1 -0
- package/dist/http/routes/getLogs.js +28 -0
- package/dist/http/routes/getLogs.js.map +1 -0
- package/dist/http/routes/getNet.d.ts +3 -0
- package/dist/http/routes/getNet.d.ts.map +1 -0
- package/dist/http/routes/getNet.js +17 -0
- package/dist/http/routes/getNet.js.map +1 -0
- package/dist/http/routes/getNetTail.d.ts +3 -0
- package/dist/http/routes/getNetTail.d.ts.map +1 -0
- package/dist/http/routes/getNetTail.js +18 -0
- package/dist/http/routes/getNetTail.js.map +1 -0
- package/dist/http/routes/getStatus.d.ts +3 -0
- package/dist/http/routes/getStatus.d.ts.map +1 -0
- package/dist/http/routes/getStatus.js +21 -0
- package/dist/http/routes/getStatus.js.map +1 -0
- package/dist/http/routes/getTail.d.ts +3 -0
- package/dist/http/routes/getTail.d.ts.map +1 -0
- package/dist/http/routes/getTail.js +28 -0
- package/dist/http/routes/getTail.js.map +1 -0
- package/dist/http/routes/getTargets.d.ts +3 -0
- package/dist/http/routes/getTargets.d.ts.map +1 -0
- package/dist/http/routes/getTargets.js +16 -0
- package/dist/http/routes/getTargets.js.map +1 -0
- package/dist/http/routes/getThrottle.d.ts +3 -0
- package/dist/http/routes/getThrottle.d.ts.map +1 -0
- package/dist/http/routes/getThrottle.js +8 -0
- package/dist/http/routes/getThrottle.js.map +1 -0
- package/dist/http/routes/postAttach.d.ts +3 -0
- package/dist/http/routes/postAttach.d.ts.map +1 -0
- package/dist/http/routes/postAttach.js +24 -0
- package/dist/http/routes/postAttach.js.map +1 -0
- package/dist/http/routes/postCodeEdit.d.ts +3 -0
- package/dist/http/routes/postCodeEdit.d.ts.map +1 -0
- package/dist/http/routes/postCodeEdit.js +32 -0
- package/dist/http/routes/postCodeEdit.js.map +1 -0
- package/dist/http/routes/postCodeGrep.d.ts +3 -0
- package/dist/http/routes/postCodeGrep.d.ts.map +1 -0
- package/dist/http/routes/postCodeGrep.js +26 -0
- package/dist/http/routes/postCodeGrep.js.map +1 -0
- package/dist/http/routes/postCodeList.d.ts +3 -0
- package/dist/http/routes/postCodeList.d.ts.map +1 -0
- package/dist/http/routes/postCodeList.js +20 -0
- package/dist/http/routes/postCodeList.js.map +1 -0
- package/dist/http/routes/postCodeRead.d.ts +3 -0
- package/dist/http/routes/postCodeRead.d.ts.map +1 -0
- package/dist/http/routes/postCodeRead.js +30 -0
- package/dist/http/routes/postCodeRead.js.map +1 -0
- package/dist/http/routes/postDetach.d.ts +3 -0
- package/dist/http/routes/postDetach.d.ts.map +1 -0
- package/dist/http/routes/postDetach.js +24 -0
- package/dist/http/routes/postDetach.js.map +1 -0
- package/dist/http/routes/postDomAdd.d.ts +7 -0
- package/dist/http/routes/postDomAdd.d.ts.map +1 -0
- package/dist/http/routes/postDomAdd.js +97 -0
- package/dist/http/routes/postDomAdd.js.map +1 -0
- package/dist/http/routes/postDomClick.d.ts +3 -0
- package/dist/http/routes/postDomClick.d.ts.map +1 -0
- package/dist/http/routes/postDomClick.js +85 -0
- package/dist/http/routes/postDomClick.js.map +1 -0
- package/dist/http/routes/postDomFill.d.ts +3 -0
- package/dist/http/routes/postDomFill.d.ts.map +1 -0
- package/dist/http/routes/postDomFill.js +58 -0
- package/dist/http/routes/postDomFill.js.map +1 -0
- package/dist/http/routes/postDomFocus.d.ts +3 -0
- package/dist/http/routes/postDomFocus.d.ts.map +1 -0
- package/dist/http/routes/postDomFocus.js +40 -0
- package/dist/http/routes/postDomFocus.js.map +1 -0
- package/dist/http/routes/postDomHover.d.ts +3 -0
- package/dist/http/routes/postDomHover.d.ts.map +1 -0
- package/dist/http/routes/postDomHover.js +40 -0
- package/dist/http/routes/postDomHover.js.map +1 -0
- package/dist/http/routes/postDomInfo.d.ts +3 -0
- package/dist/http/routes/postDomInfo.d.ts.map +1 -0
- package/dist/http/routes/postDomInfo.js +40 -0
- package/dist/http/routes/postDomInfo.js.map +1 -0
- package/dist/http/routes/postDomKeydown.d.ts +3 -0
- package/dist/http/routes/postDomKeydown.d.ts.map +1 -0
- package/dist/http/routes/postDomKeydown.js +36 -0
- package/dist/http/routes/postDomKeydown.js.map +1 -0
- package/dist/http/routes/postDomModify.d.ts +3 -0
- package/dist/http/routes/postDomModify.d.ts.map +1 -0
- package/dist/http/routes/postDomModify.js +45 -0
- package/dist/http/routes/postDomModify.js.map +1 -0
- package/dist/http/routes/postDomRemove.d.ts +3 -0
- package/dist/http/routes/postDomRemove.d.ts.map +1 -0
- package/dist/http/routes/postDomRemove.js +39 -0
- package/dist/http/routes/postDomRemove.js.map +1 -0
- package/dist/http/routes/postDomScroll.d.ts +3 -0
- package/dist/http/routes/postDomScroll.d.ts.map +1 -0
- package/dist/http/routes/postDomScroll.js +75 -0
- package/dist/http/routes/postDomScroll.js.map +1 -0
- package/dist/http/routes/postDomScrollTo.d.ts +3 -0
- package/dist/http/routes/postDomScrollTo.d.ts.map +1 -0
- package/dist/http/routes/postDomScrollTo.js +69 -0
- package/dist/http/routes/postDomScrollTo.js.map +1 -0
- package/dist/http/routes/postDomSetFile.d.ts +3 -0
- package/dist/http/routes/postDomSetFile.d.ts.map +1 -0
- package/dist/http/routes/postDomSetFile.js +58 -0
- package/dist/http/routes/postDomSetFile.js.map +1 -0
- package/dist/http/routes/postDomSubmit.d.ts +3 -0
- package/dist/http/routes/postDomSubmit.d.ts.map +1 -0
- package/dist/http/routes/postDomSubmit.js +49 -0
- package/dist/http/routes/postDomSubmit.js.map +1 -0
- package/dist/http/routes/postDomTree.d.ts +3 -0
- package/dist/http/routes/postDomTree.d.ts.map +1 -0
- package/dist/http/routes/postDomTree.js +41 -0
- package/dist/http/routes/postDomTree.js.map +1 -0
- package/dist/http/routes/postEmulation.d.ts +3 -0
- package/dist/http/routes/postEmulation.d.ts.map +1 -0
- package/dist/http/routes/postEmulation.js +70 -0
- package/dist/http/routes/postEmulation.js.map +1 -0
- package/dist/http/routes/postEval.d.ts +3 -0
- package/dist/http/routes/postEval.d.ts.map +1 -0
- package/dist/http/routes/postEval.js +27 -0
- package/dist/http/routes/postEval.js.map +1 -0
- package/dist/http/routes/postReload.d.ts +3 -0
- package/dist/http/routes/postReload.d.ts.map +1 -0
- package/dist/http/routes/postReload.js +20 -0
- package/dist/http/routes/postReload.js.map +1 -0
- package/dist/http/routes/postScreenshot.d.ts +3 -0
- package/dist/http/routes/postScreenshot.d.ts.map +1 -0
- package/dist/http/routes/postScreenshot.js +17 -0
- package/dist/http/routes/postScreenshot.js.map +1 -0
- package/dist/http/routes/postShutdown.d.ts +3 -0
- package/dist/http/routes/postShutdown.d.ts.map +1 -0
- package/dist/http/routes/postShutdown.js +13 -0
- package/dist/http/routes/postShutdown.js.map +1 -0
- package/dist/http/routes/postSnapshot.d.ts +3 -0
- package/dist/http/routes/postSnapshot.d.ts.map +1 -0
- package/dist/http/routes/postSnapshot.js +28 -0
- package/dist/http/routes/postSnapshot.js.map +1 -0
- package/dist/http/routes/postStorageLocal.d.ts +3 -0
- package/dist/http/routes/postStorageLocal.d.ts.map +1 -0
- package/dist/http/routes/postStorageLocal.js +31 -0
- package/dist/http/routes/postStorageLocal.js.map +1 -0
- package/dist/http/routes/postThrottle.d.ts +3 -0
- package/dist/http/routes/postThrottle.d.ts.map +1 -0
- package/dist/http/routes/postThrottle.js +38 -0
- package/dist/http/routes/postThrottle.js.map +1 -0
- package/dist/http/routes/postTraceStart.d.ts +3 -0
- package/dist/http/routes/postTraceStart.d.ts.map +1 -0
- package/dist/http/routes/postTraceStart.js +17 -0
- package/dist/http/routes/postTraceStart.js.map +1 -0
- package/dist/http/routes/postTraceStop.d.ts +3 -0
- package/dist/http/routes/postTraceStop.d.ts.map +1 -0
- package/dist/http/routes/postTraceStop.js +17 -0
- package/dist/http/routes/postTraceStop.js.map +1 -0
- package/dist/http/routes/types.d.ts +9 -0
- package/dist/http/routes/types.d.ts.map +1 -0
- package/dist/http/routes/types.js +10 -0
- package/dist/http/routes/types.js.map +1 -0
- package/dist/http/server.d.ts +42 -1
- package/dist/http/server.d.ts.map +1 -1
- package/dist/http/server.js +3 -82
- package/dist/http/server.js.map +1 -1
- package/dist/index.d.ts +117 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +349 -44
- package/dist/index.js.map +1 -1
- package/dist/native-messaging/messaging.d.ts +18 -0
- package/dist/native-messaging/messaging.d.ts.map +1 -0
- package/dist/native-messaging/messaging.js +94 -0
- package/dist/native-messaging/messaging.js.map +1 -0
- package/dist/native-messaging/session-manager.d.ts +108 -0
- package/dist/native-messaging/session-manager.d.ts.map +1 -0
- package/dist/native-messaging/session-manager.js +267 -0
- package/dist/native-messaging/session-manager.js.map +1 -0
- package/dist/native-messaging/types.d.ts +112 -0
- package/dist/native-messaging/types.d.ts.map +1 -0
- package/dist/native-messaging/types.js +6 -0
- package/dist/native-messaging/types.js.map +1 -0
- package/dist/registry/registry.d.ts +9 -2
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +53 -9
- package/dist/registry/registry.js.map +1 -1
- package/dist/scripts/install-host.d.ts +10 -0
- package/dist/scripts/install-host.d.ts.map +1 -0
- package/dist/scripts/install-host.js +189 -0
- package/dist/scripts/install-host.js.map +1 -0
- package/dist/sources/cdp-source.d.ts +24 -0
- package/dist/sources/cdp-source.d.ts.map +1 -0
- package/dist/sources/cdp-source.js +49 -0
- package/dist/sources/cdp-source.js.map +1 -0
- package/dist/sources/extension-frame-state.d.ts +64 -0
- package/dist/sources/extension-frame-state.d.ts.map +1 -0
- package/dist/sources/extension-frame-state.js +117 -0
- package/dist/sources/extension-frame-state.js.map +1 -0
- package/dist/sources/extension-log-events.d.ts +15 -0
- package/dist/sources/extension-log-events.d.ts.map +1 -0
- package/dist/sources/extension-log-events.js +101 -0
- package/dist/sources/extension-log-events.js.map +1 -0
- package/dist/sources/extension-source.d.ts +15 -0
- package/dist/sources/extension-source.d.ts.map +1 -0
- package/dist/sources/extension-source.js +487 -0
- package/dist/sources/extension-source.js.map +1 -0
- package/dist/sources/types.d.ts +109 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +7 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/throttle/ThrottleController.d.ts +12 -0
- package/dist/throttle/ThrottleController.d.ts.map +1 -0
- package/dist/throttle/ThrottleController.js +67 -0
- package/dist/throttle/ThrottleController.js.map +1 -0
- package/package.json +3 -2
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { LogLevel } from '@vforsh/argus-core';
|
|
2
|
+
/**
|
|
3
|
+
* Event payload for when the watcher attaches to a CDP target.
|
|
4
|
+
*/
|
|
5
|
+
export type CdpAttachedEvent = {
|
|
6
|
+
/** ISO timestamp of the event. */
|
|
7
|
+
ts: number;
|
|
8
|
+
/** Unique watcher identifier. */
|
|
9
|
+
watcherId: string;
|
|
10
|
+
/** CDP target metadata. */
|
|
11
|
+
target: {
|
|
12
|
+
/** Human-readable page title for the target. */
|
|
13
|
+
title: string | null;
|
|
14
|
+
/** Page URL for the target. */
|
|
15
|
+
url: string | null;
|
|
16
|
+
/** Target type (e.g., 'page', 'iframe', 'worker'). */
|
|
17
|
+
type: string | null;
|
|
18
|
+
/** Parent target ID for nested targets (e.g., iframes). Null for top-level pages. */
|
|
19
|
+
parentId: string | null;
|
|
20
|
+
} | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Event payload for when the watcher detaches from a CDP target.
|
|
24
|
+
*/
|
|
25
|
+
export type CdpDetachedEvent = {
|
|
26
|
+
/** ISO timestamp of the event. */
|
|
27
|
+
ts: number;
|
|
28
|
+
/** Unique watcher identifier. */
|
|
29
|
+
watcherId: string;
|
|
30
|
+
/** Best-effort reason for detachment. */
|
|
31
|
+
reason: string;
|
|
32
|
+
/** Last known CDP target metadata. */
|
|
33
|
+
target: {
|
|
34
|
+
/** Human-readable page title for the target. */
|
|
35
|
+
title: string | null;
|
|
36
|
+
/** Page URL for the target. */
|
|
37
|
+
url: string | null;
|
|
38
|
+
} | null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Query parameters for log/tail requests.
|
|
42
|
+
*/
|
|
43
|
+
export type LogRequestQuery = {
|
|
44
|
+
after?: number;
|
|
45
|
+
limit?: number;
|
|
46
|
+
levels?: LogLevel[];
|
|
47
|
+
match?: string[];
|
|
48
|
+
matchCase?: 'sensitive' | 'insensitive';
|
|
49
|
+
source?: string;
|
|
50
|
+
sinceTs?: number;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Query parameters for network/tail requests.
|
|
55
|
+
*/
|
|
56
|
+
export type NetRequestQuery = {
|
|
57
|
+
after?: number;
|
|
58
|
+
limit?: number;
|
|
59
|
+
sinceTs?: number;
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
grep?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Event payload for when a client requests logs or tail via HTTP.
|
|
65
|
+
*/
|
|
66
|
+
export type HttpRequestEvent = {
|
|
67
|
+
/** ISO timestamp of the event. */
|
|
68
|
+
ts: number;
|
|
69
|
+
/** Unique watcher identifier. */
|
|
70
|
+
watcherId: string;
|
|
71
|
+
/** The requested endpoint. */
|
|
72
|
+
endpoint: 'logs' | 'tail' | 'net' | 'net/tail' | 'eval' | 'trace/start' | 'trace/stop' | 'screenshot' | 'snapshot' | 'code/list' | 'code/read' | 'code/grep' | 'dom/tree' | 'dom/info' | 'dom/hover' | 'dom/click' | 'dom/keydown' | 'dom/add' | 'dom/remove' | 'dom/modify' | 'dom/set-file' | 'dom/focus' | 'dom/fill' | 'dom/scroll' | 'dom/scroll-to' | 'emulation' | 'throttle' | 'storage/local' | 'reload' | 'shutdown' | 'targets' | 'attach' | 'detach';
|
|
73
|
+
/** IP address of the requester (best-effort). */
|
|
74
|
+
remoteAddress: string | null;
|
|
75
|
+
/** Parsed query parameters. */
|
|
76
|
+
query?: LogRequestQuery | NetRequestQuery;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Map of events emitted by the Argus watcher.
|
|
80
|
+
*/
|
|
81
|
+
export type ArgusWatcherEventMap = {
|
|
82
|
+
cdpAttached: CdpAttachedEvent;
|
|
83
|
+
cdpDetached: CdpDetachedEvent;
|
|
84
|
+
httpRequested: HttpRequestEvent;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC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EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,QAAQ,EACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,UAAU,GACV,MAAM,GACN,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,WAAW,GACX,WAAW,GACX,WAAW,GACX,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,aAAa,GACb,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,WAAW,GACX,UAAU,GACV,YAAY,GACZ,eAAe,GACf,WAAW,GACX,UAAU,GACV,eAAe,GACf,QAAQ,GACR,UAAU,GACV,SAAS,GACT,QAAQ,GACR,QAAQ,CAAA;IACX,iDAAiD;IACjD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,eAAe,GAAG,eAAe,CAAA;CACzC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,gBAAgB,CAAA;IAC7B,WAAW,EAAE,gBAAgB,CAAA;IAC7B,aAAa,EAAE,gBAAgB,CAAA;CAC/B,CAAA"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LogEvent, WatcherChrome, WatcherMatch } from '@vforsh/argus-core';
|
|
2
|
+
import type { BuildFilenameContext } from '../index.js';
|
|
2
3
|
type PageInfo = {
|
|
3
4
|
url: string;
|
|
4
5
|
title: string | null;
|
|
@@ -11,20 +12,22 @@ export type WatcherFileLoggerOptions = {
|
|
|
11
12
|
watcherId: string;
|
|
12
13
|
startedAt: number;
|
|
13
14
|
logsDir: string;
|
|
14
|
-
chrome
|
|
15
|
+
chrome?: WatcherChrome;
|
|
15
16
|
match?: WatcherMatch;
|
|
16
17
|
maxFiles: number;
|
|
17
18
|
includeTimestamps: boolean;
|
|
19
|
+
buildFilename?: (context: BuildFilenameContext) => string | undefined | null;
|
|
18
20
|
};
|
|
19
21
|
export declare class WatcherFileLogger {
|
|
20
22
|
private readonly watcherId;
|
|
21
23
|
private readonly startedAt;
|
|
22
24
|
private readonly startedAtIso;
|
|
23
25
|
private readonly logsDir;
|
|
24
|
-
private readonly chrome
|
|
26
|
+
private readonly chrome?;
|
|
25
27
|
private readonly match?;
|
|
26
28
|
private readonly maxFiles;
|
|
27
29
|
private readonly includeTimestamps;
|
|
30
|
+
private readonly customBuildFilename?;
|
|
28
31
|
private currentStream;
|
|
29
32
|
private writePromise;
|
|
30
33
|
private fileIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatcherFileLogger.d.ts","sourceRoot":"","sources":["../../src/fileLogs/WatcherFileLogger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"WatcherFileLogger.d.ts","sourceRoot":"","sources":["../../src/fileLogs/WatcherFileLogger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,KAAK,QAAQ,GAAG;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB,CAAA;AAED,KAAK,YAAY,GAAG;IACnB,QAAQ,EAAE,MAAM,GA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WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IASrC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI;IAkB7C,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAe5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAWR,YAAY;IA4B1B,OAAO,CAAC,aAAa;YAiCP,kBAAkB;YAWlB,aAAa;IAe3B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,WAAW;YAQL,aAAa;CA2C3B"}
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import fsPromises from 'node:fs/promises';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { formatLogLevelTag } from '@vforsh/argus-core';
|
|
5
|
+
import { formatLogLevelTag, previewStringify } from '@vforsh/argus-core';
|
|
6
6
|
export class WatcherFileLogger {
|
|
7
7
|
watcherId;
|
|
8
8
|
startedAt;
|
|
@@ -12,6 +12,7 @@ export class WatcherFileLogger {
|
|
|
12
12
|
match;
|
|
13
13
|
maxFiles;
|
|
14
14
|
includeTimestamps;
|
|
15
|
+
customBuildFilename;
|
|
15
16
|
currentStream = null;
|
|
16
17
|
writePromise = Promise.resolve();
|
|
17
18
|
fileIndex = 1;
|
|
@@ -31,6 +32,7 @@ export class WatcherFileLogger {
|
|
|
31
32
|
this.match = options.match;
|
|
32
33
|
this.maxFiles = options.maxFiles;
|
|
33
34
|
this.includeTimestamps = options.includeTimestamps;
|
|
35
|
+
this.customBuildFilename = options.buildFilename;
|
|
34
36
|
}
|
|
35
37
|
setPageIntl(info) {
|
|
36
38
|
if (this.closed || this.failed) {
|
|
@@ -106,7 +108,31 @@ export class WatcherFileLogger {
|
|
|
106
108
|
await this.pruneOldFiles();
|
|
107
109
|
}
|
|
108
110
|
buildFilename() {
|
|
109
|
-
|
|
111
|
+
const defaultFilename = `watcher-${this.watcherId}-${this.startedAtIso}-${this.fileIndex}.log`;
|
|
112
|
+
if (!this.customBuildFilename) {
|
|
113
|
+
return defaultFilename;
|
|
114
|
+
}
|
|
115
|
+
const context = {
|
|
116
|
+
watcherId: this.watcherId,
|
|
117
|
+
startedAt: this.startedAt,
|
|
118
|
+
startedAtSafe: this.startedAtIso,
|
|
119
|
+
fileIndex: this.fileIndex,
|
|
120
|
+
};
|
|
121
|
+
let filename;
|
|
122
|
+
try {
|
|
123
|
+
filename = this.customBuildFilename(context);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error('Error in custom log filename builder:', error);
|
|
127
|
+
return defaultFilename;
|
|
128
|
+
}
|
|
129
|
+
if (!filename) {
|
|
130
|
+
return defaultFilename;
|
|
131
|
+
}
|
|
132
|
+
if (!filename.toLowerCase().endsWith('.log')) {
|
|
133
|
+
return `${filename}.log`;
|
|
134
|
+
}
|
|
135
|
+
return filename;
|
|
110
136
|
}
|
|
111
137
|
async closeCurrentStream() {
|
|
112
138
|
if (!this.currentStream) {
|
|
@@ -191,7 +217,7 @@ export class WatcherFileLogger {
|
|
|
191
217
|
}
|
|
192
218
|
}
|
|
193
219
|
const renderHeader = (context) => {
|
|
194
|
-
const matchText = context.match ?
|
|
220
|
+
const matchText = context.match ? previewStringify(context.match) : '(none)';
|
|
195
221
|
const pageUrl = context.pageUrl ?? '(unknown)';
|
|
196
222
|
const pageSearchParams = formatPageSearchParams(context.pageUrl);
|
|
197
223
|
const pageTitle = context.pageTitle ?? '(unknown)';
|
|
@@ -206,7 +232,7 @@ const renderHeader = (context) => {
|
|
|
206
232
|
`arch: ${os.arch()}`,
|
|
207
233
|
`cwd: ${process.cwd()}`,
|
|
208
234
|
`logsPath: ${context.logsPath}`,
|
|
209
|
-
`chrome: ${context.chrome.host}:${context.chrome.port}`,
|
|
235
|
+
`chrome: ${context.chrome ? `${context.chrome.host}:${context.chrome.port}` : '(extension mode)'}`,
|
|
210
236
|
`match: ${matchText}`,
|
|
211
237
|
`pageUrl: ${pageUrl}`,
|
|
212
238
|
`pageSearchParams: ${pageSearchParams}`,
|
|
@@ -243,14 +269,6 @@ const formatLocation = (event) => {
|
|
|
243
269
|
return location;
|
|
244
270
|
};
|
|
245
271
|
const toSafeTimestamp = (ts) => new Date(ts).toISOString().replace(/:/g, '-');
|
|
246
|
-
const safeStringify = (value) => {
|
|
247
|
-
try {
|
|
248
|
-
return JSON.stringify(value);
|
|
249
|
-
}
|
|
250
|
-
catch {
|
|
251
|
-
return String(value);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
272
|
const formatPageSearchParams = (pageUrl) => {
|
|
255
273
|
if (!pageUrl || pageUrl === '(unknown)') {
|
|
256
274
|
return '(unknown)';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatcherFileLogger.js","sourceRoot":"","sources":["../../src/fileLogs/WatcherFileLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,UAAU,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"WatcherFileLogger.js","sourceRoot":"","sources":["../../src/fileLogs/WatcherFileLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,UAAU,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAwBxE,MAAM,OAAO,iBAAiB;IACZ,SAAS,CAAQ;IACjB,SAAS,CAAQ;IACjB,YAAY,CAAQ;IACpB,OAAO,CAAQ;IACf,MAAM,CAAgB;IACt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E,CAAC;QACvB,OAAO,QAAQ,CAAA;IAChB,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAA;AACvF,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import type { LogLevel } from '@vforsh/argus-core';
|
|
3
|
+
export declare const respondJson: <T extends object>(res: http.ServerResponse, body: T, status?: number) => void;
|
|
4
|
+
export declare const respondInvalidMatch: (res: http.ServerResponse, message: string) => void;
|
|
5
|
+
export declare const respondInvalidMatchCase: (res: http.ServerResponse) => void;
|
|
6
|
+
export declare const respondInvalidBody: (res: http.ServerResponse, message: string) => void;
|
|
7
|
+
export declare const respondInvalidJson: (res: http.ServerResponse) => void;
|
|
8
|
+
export declare const respondPayloadTooLarge: (res: http.ServerResponse) => void;
|
|
9
|
+
export declare const respondError: (res: http.ServerResponse, error: unknown) => void;
|
|
10
|
+
export declare const readJsonBody: <T>(req: http.IncomingMessage, res: http.ServerResponse) => Promise<T | null>;
|
|
11
|
+
export declare const clampNumber: (value: string | null, fallback?: number, min?: number, max?: number) => number;
|
|
12
|
+
export declare const parseLevels: (value: string | null) => LogLevel[] | undefined;
|
|
13
|
+
export declare const resolveMatchCase: (value: string | null) => "sensitive" | "insensitive" | null;
|
|
14
|
+
export declare const normalizeMatchPatterns: (match: string[]) => {
|
|
15
|
+
patterns: string[];
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const compileMatchPatterns: (patterns: string[], matchCase: "sensitive" | "insensitive") => {
|
|
19
|
+
match?: RegExp[];
|
|
20
|
+
error?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const normalizeQueryValue: (value: string | null) => string | undefined;
|
|
23
|
+
export declare const normalizeBoolean: (value: unknown, fallback: boolean) => boolean;
|
|
24
|
+
export declare const normalizeTimeout: (value: unknown) => number | undefined;
|
|
25
|
+
//# sourceMappingURL=httpUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../src/http/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAEjE,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,eAAY,KAAG,IAK/F,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,SAAS,MAAM,KAAG,IAE/E,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,KAAK,IAAI,CAAC,cAAc,KAAG,IAElE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,SAAS,MAAM,KAAG,IAE9E,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,KAAK,IAAI,CAAC,cAAc,KAAG,IAE7D,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,KAAK,IAAI,CAAC,cAAc,KAAG,IAEjE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,OAAO,OAAO,KAAG,IAIvE,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,cAAc,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAkC3G,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,GAAG,IAAI,EAAE,WAAW,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAmBjG,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,QAAQ,EAAE,GAAG,SAe/D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,WAAW,GAAG,aAAa,GAAG,IAUrF,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,EAAE,KAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAW5F,CAAA;AAED,eAAO,MAAM,oBAAoB,GAChC,UAAU,MAAM,EAAE,EAClB,WAAW,WAAW,GAAG,aAAa,KACpC;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAiBpC,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,SAWnE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,UAAU,OAAO,KAAG,OAKpE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAS1D,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
export const respondJson = (res, body, status = 200) => {
|
|
3
|
+
const payload = JSON.stringify(body);
|
|
4
|
+
res.statusCode = status;
|
|
5
|
+
res.setHeader('Content-Type', 'application/json');
|
|
6
|
+
res.end(payload);
|
|
7
|
+
};
|
|
8
|
+
export const respondInvalidMatch = (res, message) => {
|
|
9
|
+
respondJson(res, { ok: false, error: { message, code: 'invalid_match' } }, 400);
|
|
10
|
+
};
|
|
11
|
+
export const respondInvalidMatchCase = (res) => {
|
|
12
|
+
respondJson(res, { ok: false, error: { message: 'Invalid matchCase value', code: 'invalid_match_case' } }, 400);
|
|
13
|
+
};
|
|
14
|
+
export const respondInvalidBody = (res, message) => {
|
|
15
|
+
respondJson(res, { ok: false, error: { message, code: 'invalid_request' } }, 400);
|
|
16
|
+
};
|
|
17
|
+
export const respondInvalidJson = (res) => {
|
|
18
|
+
respondJson(res, { ok: false, error: { message: 'Invalid JSON body', code: 'invalid_json' } }, 400);
|
|
19
|
+
};
|
|
20
|
+
export const respondPayloadTooLarge = (res) => {
|
|
21
|
+
respondJson(res, { ok: false, error: { message: 'Request body too large', code: 'payload_too_large' } }, 413);
|
|
22
|
+
};
|
|
23
|
+
export const respondError = (res, error) => {
|
|
24
|
+
const message = formatError(error);
|
|
25
|
+
const code = resolveErrorCode(error);
|
|
26
|
+
respondJson(res, { ok: false, error: { message, code } }, 500);
|
|
27
|
+
};
|
|
28
|
+
export const readJsonBody = async (req, res) => {
|
|
29
|
+
const chunks = [];
|
|
30
|
+
let size = 0;
|
|
31
|
+
const maxBytes = 1_000_000;
|
|
32
|
+
try {
|
|
33
|
+
for await (const chunk of req) {
|
|
34
|
+
size += chunk.length;
|
|
35
|
+
if (size > maxBytes) {
|
|
36
|
+
respondPayloadTooLarge(res);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
chunks.push(Buffer.from(chunk));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
respondInvalidJson(res);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (chunks.length === 0) {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
const raw = Buffer.concat(chunks).toString('utf8');
|
|
50
|
+
if (!raw.trim()) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(raw);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
respondInvalidJson(res);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const clampNumber = (value, fallback, min, max) => {
|
|
62
|
+
if (value == null) {
|
|
63
|
+
return fallback ?? 0;
|
|
64
|
+
}
|
|
65
|
+
const parsed = Number(value);
|
|
66
|
+
if (!Number.isFinite(parsed)) {
|
|
67
|
+
return fallback ?? 0;
|
|
68
|
+
}
|
|
69
|
+
if (min != null && parsed < min) {
|
|
70
|
+
return min;
|
|
71
|
+
}
|
|
72
|
+
if (max != null && parsed > max) {
|
|
73
|
+
return max;
|
|
74
|
+
}
|
|
75
|
+
return parsed;
|
|
76
|
+
};
|
|
77
|
+
export const parseLevels = (value) => {
|
|
78
|
+
if (!value) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const levels = value
|
|
82
|
+
.split(',')
|
|
83
|
+
.map((item) => item.trim())
|
|
84
|
+
.filter(Boolean);
|
|
85
|
+
if (levels.length === 0) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return levels;
|
|
89
|
+
};
|
|
90
|
+
export const resolveMatchCase = (value) => {
|
|
91
|
+
if (!value) {
|
|
92
|
+
return 'insensitive';
|
|
93
|
+
}
|
|
94
|
+
if (value === 'sensitive' || value === 'insensitive') {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
};
|
|
99
|
+
export const normalizeMatchPatterns = (match) => {
|
|
100
|
+
const patterns = [];
|
|
101
|
+
for (const pattern of match) {
|
|
102
|
+
const trimmed = pattern.trim();
|
|
103
|
+
if (!trimmed) {
|
|
104
|
+
return { patterns: [], error: 'Invalid match pattern "(empty)"' };
|
|
105
|
+
}
|
|
106
|
+
patterns.push(trimmed);
|
|
107
|
+
}
|
|
108
|
+
return { patterns };
|
|
109
|
+
};
|
|
110
|
+
export const compileMatchPatterns = (patterns, matchCase) => {
|
|
111
|
+
if (patterns.length === 0) {
|
|
112
|
+
return {};
|
|
113
|
+
}
|
|
114
|
+
const flags = matchCase === 'sensitive' ? '' : 'i';
|
|
115
|
+
const compiled = [];
|
|
116
|
+
for (const pattern of patterns) {
|
|
117
|
+
try {
|
|
118
|
+
compiled.push(new RegExp(pattern, flags));
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { error: `Invalid match pattern "${pattern}": ${formatError(error)}` };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { match: compiled };
|
|
125
|
+
};
|
|
126
|
+
export const normalizeQueryValue = (value) => {
|
|
127
|
+
if (value == null) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const trimmed = value.trim();
|
|
131
|
+
if (!trimmed) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
return trimmed;
|
|
135
|
+
};
|
|
136
|
+
export const normalizeBoolean = (value, fallback) => {
|
|
137
|
+
if (value == null) {
|
|
138
|
+
return fallback;
|
|
139
|
+
}
|
|
140
|
+
return Boolean(value);
|
|
141
|
+
};
|
|
142
|
+
export const normalizeTimeout = (value) => {
|
|
143
|
+
if (value == null) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
const parsed = Number(value);
|
|
147
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
return parsed;
|
|
151
|
+
};
|
|
152
|
+
const resolveErrorCode = (error) => {
|
|
153
|
+
if (!error || typeof error !== 'object') {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
if ('code' in error && typeof error.code === 'string') {
|
|
157
|
+
return error.code;
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
};
|
|
161
|
+
const formatError = (error) => {
|
|
162
|
+
if (!error) {
|
|
163
|
+
return 'unknown error';
|
|
164
|
+
}
|
|
165
|
+
if (error instanceof Error) {
|
|
166
|
+
return error.message;
|
|
167
|
+
}
|
|
168
|
+
return String(error);
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=httpUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpUtils.js","sourceRoot":"","sources":["../../src/http/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW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AI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAC7C,OAAO,SAAS,CAAA;IACjB,CAAC;IACD,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAsB,EAAE;IAC/D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,SAAS,CAAA;IACjB,CAAC;IACD,IAAI,MAAM,IAAI,KAAK,IAAI,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/E,OAAQ,KAA0B,CAAC,IAAI,CAAA;IACxC,CAAC;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,KAAc,EAAU,EAAE;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,eAAe,CAAA;IACvB,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import type { RouteContext } from './routes/types.js';
|
|
3
|
+
/** Dispatch an incoming request to the matching route handler, or respond 404. */
|
|
4
|
+
export declare const dispatch: (req: http.IncomingMessage, res: http.ServerResponse, url: URL, ctx: RouteContext) => void;
|
|
5
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/http/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAiFnE,kFAAkF;AAClF,eAAO,MAAM,QAAQ,GAAI,KAAK,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,KAAG,IAO3G,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { respondJson } from './httpUtils.js';
|
|
2
|
+
import { handle as getStatus } from './routes/getStatus.js';
|
|
3
|
+
import { handle as getLogs } from './routes/getLogs.js';
|
|
4
|
+
import { handle as getTail } from './routes/getTail.js';
|
|
5
|
+
import { handle as getNet } from './routes/getNet.js';
|
|
6
|
+
import { handle as getNetTail } from './routes/getNetTail.js';
|
|
7
|
+
import { handle as postEval } from './routes/postEval.js';
|
|
8
|
+
import { handle as postTraceStart } from './routes/postTraceStart.js';
|
|
9
|
+
import { handle as postTraceStop } from './routes/postTraceStop.js';
|
|
10
|
+
import { handle as postScreenshot } from './routes/postScreenshot.js';
|
|
11
|
+
import { handle as postSnapshot } from './routes/postSnapshot.js';
|
|
12
|
+
import { handle as postCodeList } from './routes/postCodeList.js';
|
|
13
|
+
import { handle as postCodeRead } from './routes/postCodeRead.js';
|
|
14
|
+
import { handle as postCodeGrep } from './routes/postCodeGrep.js';
|
|
15
|
+
import { handle as postDomTree } from './routes/postDomTree.js';
|
|
16
|
+
import { handle as postDomInfo } from './routes/postDomInfo.js';
|
|
17
|
+
import { handle as postDomHover } from './routes/postDomHover.js';
|
|
18
|
+
import { handle as postDomClick } from './routes/postDomClick.js';
|
|
19
|
+
import { handle as postDomKeydown } from './routes/postDomKeydown.js';
|
|
20
|
+
import { handle as postDomAdd } from './routes/postDomAdd.js';
|
|
21
|
+
import { handle as postDomRemove } from './routes/postDomRemove.js';
|
|
22
|
+
import { handle as postDomModify } from './routes/postDomModify.js';
|
|
23
|
+
import { handle as postDomSetFile } from './routes/postDomSetFile.js';
|
|
24
|
+
import { handle as postDomFocus } from './routes/postDomFocus.js';
|
|
25
|
+
import { handle as postDomFill } from './routes/postDomFill.js';
|
|
26
|
+
import { handle as postDomScroll } from './routes/postDomScroll.js';
|
|
27
|
+
import { handle as postDomScrollTo } from './routes/postDomScrollTo.js';
|
|
28
|
+
import { handle as getEmulation } from './routes/getEmulation.js';
|
|
29
|
+
import { handle as postEmulation } from './routes/postEmulation.js';
|
|
30
|
+
import { handle as getThrottle } from './routes/getThrottle.js';
|
|
31
|
+
import { handle as postThrottle } from './routes/postThrottle.js';
|
|
32
|
+
import { handle as postStorageLocal } from './routes/postStorageLocal.js';
|
|
33
|
+
import { handle as postReload } from './routes/postReload.js';
|
|
34
|
+
import { handle as postShutdown } from './routes/postShutdown.js';
|
|
35
|
+
import { handle as getTargets } from './routes/getTargets.js';
|
|
36
|
+
import { handle as postAttach } from './routes/postAttach.js';
|
|
37
|
+
import { handle as postDetach } from './routes/postDetach.js';
|
|
38
|
+
const routes = {
|
|
39
|
+
'GET /status': { handler: getStatus },
|
|
40
|
+
'GET /logs': { handler: getLogs },
|
|
41
|
+
'GET /tail': { handler: getTail },
|
|
42
|
+
'GET /net': { handler: getNet },
|
|
43
|
+
'GET /net/tail': { handler: getNetTail },
|
|
44
|
+
'POST /eval': { handler: postEval },
|
|
45
|
+
'POST /trace/start': { handler: postTraceStart },
|
|
46
|
+
'POST /trace/stop': { handler: postTraceStop },
|
|
47
|
+
'POST /screenshot': { handler: postScreenshot },
|
|
48
|
+
'POST /snapshot': { handler: postSnapshot },
|
|
49
|
+
'POST /code/list': { handler: postCodeList },
|
|
50
|
+
'POST /code/read': { handler: postCodeRead },
|
|
51
|
+
'POST /code/grep': { handler: postCodeGrep },
|
|
52
|
+
'POST /dom/tree': { handler: postDomTree },
|
|
53
|
+
'POST /dom/info': { handler: postDomInfo },
|
|
54
|
+
'POST /dom/hover': { handler: postDomHover },
|
|
55
|
+
'POST /dom/click': { handler: postDomClick },
|
|
56
|
+
'POST /dom/keydown': { handler: postDomKeydown },
|
|
57
|
+
'POST /dom/add': { handler: postDomAdd },
|
|
58
|
+
'POST /dom/remove': { handler: postDomRemove },
|
|
59
|
+
'POST /dom/modify': { handler: postDomModify },
|
|
60
|
+
'POST /dom/set-file': { handler: postDomSetFile },
|
|
61
|
+
'POST /dom/focus': { handler: postDomFocus },
|
|
62
|
+
'POST /dom/fill': { handler: postDomFill },
|
|
63
|
+
'POST /dom/scroll': { handler: postDomScroll },
|
|
64
|
+
'POST /dom/scroll-to': { handler: postDomScrollTo },
|
|
65
|
+
'GET /emulation': { handler: getEmulation },
|
|
66
|
+
'POST /emulation': { handler: postEmulation },
|
|
67
|
+
'GET /throttle': { handler: getThrottle },
|
|
68
|
+
'POST /throttle': { handler: postThrottle },
|
|
69
|
+
'POST /storage/local': { handler: postStorageLocal },
|
|
70
|
+
'POST /reload': { handler: postReload },
|
|
71
|
+
'POST /shutdown': { handler: postShutdown },
|
|
72
|
+
'GET /targets': { handler: getTargets, extensionOnly: true },
|
|
73
|
+
'POST /attach': { handler: postAttach, extensionOnly: true },
|
|
74
|
+
'POST /detach': { handler: postDetach, extensionOnly: true },
|
|
75
|
+
};
|
|
76
|
+
/** Dispatch an incoming request to the matching route handler, or respond 404. */
|
|
77
|
+
export const dispatch = (req, res, url, ctx) => {
|
|
78
|
+
const entry = routes[`${req.method} ${url.pathname}`];
|
|
79
|
+
if (!entry || (entry.extensionOnly && !ctx.sourceHandle)) {
|
|
80
|
+
respondJson(res, { ok: false, error: { message: 'Not found', code: 'not_found' } }, 404);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
void entry.handler(req, res, url, ctx);
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/http/router.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,M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@ -0,0 +1,8 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson } from '../httpUtils.js';
|
|
3
|
+
export const handle = (_req, res, _url, ctx) => {
|
|
4
|
+
emitRequest(ctx, res, 'emulation');
|
|
5
|
+
const status = ctx.emulationController.getStatus({ attached: ctx.getCdpStatus().attached });
|
|
6
|
+
respondJson(res, status);
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=getEmulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEmulation.js","sourceRoot":"","sources":["../../../src/http/routes/getEmulation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAC5D,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,GAAG,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3F,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACzB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLogs.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getLogs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAc9C,eAAO,MAAM,MAAM,EAAE,YA2BpB,CAAA"}
|