@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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson, respondInvalidBody, respondError, readJsonBody } from '../httpUtils.js';
|
|
3
|
+
export const handle = async (req, res, _url, ctx) => {
|
|
4
|
+
const payload = await readJsonBody(req, res);
|
|
5
|
+
if (!payload) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const validActions = ['set', 'clear'];
|
|
9
|
+
const action = payload.action;
|
|
10
|
+
if (!action || !validActions.includes(action)) {
|
|
11
|
+
return respondInvalidBody(res, `action must be one of: ${validActions.join(', ')}`);
|
|
12
|
+
}
|
|
13
|
+
emitRequest(ctx, res, 'throttle');
|
|
14
|
+
const session = ctx.cdpSession.isAttached() ? ctx.cdpSession : null;
|
|
15
|
+
if (action === 'clear') {
|
|
16
|
+
try {
|
|
17
|
+
const response = await ctx.throttleController.clearDesired(session);
|
|
18
|
+
respondJson(res, response);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
respondError(res, error);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// action === 'set'
|
|
26
|
+
const setPayload = payload;
|
|
27
|
+
if (typeof setPayload.rate !== 'number' || !Number.isFinite(setPayload.rate) || setPayload.rate < 1) {
|
|
28
|
+
return respondInvalidBody(res, 'rate must be a finite number >= 1');
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const response = await ctx.throttleController.setDesired(setPayload.rate, session);
|
|
32
|
+
respondJson(res, response);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
respondError(res, error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=postThrottle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postThrottle.js","sourceRoot":"","sources":["../../../src/http/routes/postThrottle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE7F,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,MAAM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QAAQ,GAAG,MAAM,GAAG,CAAC,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAClF,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postTraceStart.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postTraceStart.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YAcpB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson, respondError, readJsonBody } from '../httpUtils.js';
|
|
3
|
+
export const handle = async (req, res, _url, ctx) => {
|
|
4
|
+
const payload = await readJsonBody(req, res);
|
|
5
|
+
if (!payload) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
emitRequest(ctx, res, 'trace/start');
|
|
9
|
+
try {
|
|
10
|
+
const response = await ctx.traceRecorder.start(payload);
|
|
11
|
+
respondJson(res, response);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
respondError(res, error);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=postTraceStart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postTraceStart.js","sourceRoot":"","sources":["../../../src/http/routes/postTraceStart.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAoB,GAAG,EAAE,GAAG,CAAC,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAM;IACP,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,CAAC,CAAA;IAEpC,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAuB,MAAM,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC3E,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postTraceStop.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postTraceStop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YAcpB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson, respondError, readJsonBody } from '../httpUtils.js';
|
|
3
|
+
export const handle = async (req, res, _url, ctx) => {
|
|
4
|
+
const payload = await readJsonBody(req, res);
|
|
5
|
+
if (!payload) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
emitRequest(ctx, res, 'trace/stop');
|
|
9
|
+
try {
|
|
10
|
+
const response = await ctx.traceRecorder.stop(payload);
|
|
11
|
+
respondJson(res, response);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
respondError(res, error);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=postTraceStop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postTraceStop.js","sourceRoot":"","sources":["../../../src/http/routes/postTraceStop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAmB,GAAG,EAAE,GAAG,CAAC,CAAA;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAM;IACP,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAA;IAEnC,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAsB,MAAM,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzE,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import type { HttpRequestEventMetadata, HttpServerOptions } from '../server.js';
|
|
3
|
+
/** Uniform handler signature for all route modules. */
|
|
4
|
+
export type RouteHandler = (req: http.IncomingMessage, res: http.ServerResponse, url: URL, ctx: RouteContext) => Promise<void> | void;
|
|
5
|
+
/** Context passed to every route handler (alias for HttpServerOptions). */
|
|
6
|
+
export type RouteContext = HttpServerOptions;
|
|
7
|
+
/** Emit an HTTP request event via `ctx.onRequest`. Replaces per-handler boilerplate. */
|
|
8
|
+
export declare const emitRequest: (ctx: RouteContext, res: http.ServerResponse, endpoint: HttpRequestEventMetadata["endpoint"], query?: HttpRequestEventMetadata["query"]) => void;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/http/routes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE/E,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAErI,2EAA2E;AAC3E,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAE5C,wFAAwF;AACxF,eAAO,MAAM,WAAW,GACvB,KAAK,YAAY,EACjB,KAAK,IAAI,CAAC,cAAc,EACxB,UAAU,wBAAwB,CAAC,UAAU,CAAC,EAC9C,QAAQ,wBAAwB,CAAC,OAAO,CAAC,KACvC,IAOF,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Emit an HTTP request event via `ctx.onRequest`. Replaces per-handler boilerplate. */
|
|
2
|
+
export const emitRequest = (ctx, res, endpoint, query) => {
|
|
3
|
+
ctx.onRequest?.({
|
|
4
|
+
endpoint,
|
|
5
|
+
remoteAddress: res.req.socket.remoteAddress ?? null,
|
|
6
|
+
query,
|
|
7
|
+
ts: Date.now(),
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/http/routes/types.ts"],"names":[],"mappings":"AASA,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,CAC1B,GAAiB,EACjB,GAAwB,EACxB,QAA8C,EAC9C,KAAyC,EAClC,EAAE;IACT,GAAG,CAAC,SAAS,EAAE,CAAC;QACf,QAAQ;QACR,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,IAAI;QACnD,KAAK;QACL,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;KACd,CAAC,CAAA;AACH,CAAC,CAAA"}
|
package/dist/http/server.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import type { WatcherRecord } from '@vforsh/argus-core';
|
|
1
|
+
import type { LogLevel, WatcherRecord } from '@vforsh/argus-core';
|
|
2
2
|
import type { LogBuffer } from '../buffer/LogBuffer.js';
|
|
3
|
+
import type { NetBuffer } from '../buffer/NetBuffer.js';
|
|
4
|
+
import type { CdpSessionHandle } from '../cdp/connection.js';
|
|
5
|
+
import type { RuntimeEditor } from '../cdp/editor.js';
|
|
6
|
+
import type { TraceRecorder } from '../cdp/tracing.js';
|
|
7
|
+
import type { Screenshotter } from '../cdp/screenshot.js';
|
|
8
|
+
import type { CdpSourceHandle } from '../sources/types.js';
|
|
9
|
+
import type { EmulationController } from '../emulation/EmulationController.js';
|
|
10
|
+
import type { ThrottleController } from '../throttle/ThrottleController.js';
|
|
11
|
+
/** Optional metadata for the HTTP request event. */
|
|
12
|
+
export type HttpRequestEventMetadata = {
|
|
13
|
+
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';
|
|
14
|
+
remoteAddress: string | null;
|
|
15
|
+
query?: {
|
|
16
|
+
after?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
levels?: LogLevel[];
|
|
19
|
+
match?: string[];
|
|
20
|
+
matchCase?: 'sensitive' | 'insensitive';
|
|
21
|
+
source?: string;
|
|
22
|
+
sinceTs?: number;
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
grep?: string;
|
|
25
|
+
};
|
|
26
|
+
ts: number;
|
|
27
|
+
};
|
|
3
28
|
/** Options for the watcher HTTP server. */
|
|
4
29
|
export type HttpServerOptions = {
|
|
5
30
|
host: string;
|
|
6
31
|
port: number;
|
|
7
32
|
buffer: LogBuffer;
|
|
33
|
+
/** Network buffer for /net endpoints. Null when net capture is disabled. */
|
|
34
|
+
netBuffer: NetBuffer | null;
|
|
8
35
|
getWatcher: () => WatcherRecord;
|
|
9
36
|
getCdpStatus: () => {
|
|
10
37
|
attached: boolean;
|
|
@@ -13,6 +40,20 @@ export type HttpServerOptions = {
|
|
|
13
40
|
url: string | null;
|
|
14
41
|
} | null;
|
|
15
42
|
};
|
|
43
|
+
cdpSession: CdpSessionHandle;
|
|
44
|
+
traceRecorder: TraceRecorder;
|
|
45
|
+
screenshotter: Screenshotter;
|
|
46
|
+
runtimeEditor: RuntimeEditor;
|
|
47
|
+
/** Emulation controller for GET/POST /emulation endpoints. */
|
|
48
|
+
emulationController: EmulationController;
|
|
49
|
+
/** Throttle controller for GET/POST /throttle endpoints. */
|
|
50
|
+
throttleController: ThrottleController;
|
|
51
|
+
/** Source handle for extension mode (enables /targets, /attach, /detach endpoints). */
|
|
52
|
+
sourceHandle?: CdpSourceHandle;
|
|
53
|
+
/** Optional callback invoked when logs or tail are requested. */
|
|
54
|
+
onRequest?: (event: HttpRequestEventMetadata) => void;
|
|
55
|
+
/** Optional callback invoked when a shutdown request is received. */
|
|
56
|
+
onShutdown?: () => void | Promise<void>;
|
|
16
57
|
};
|
|
17
58
|
/** Handle for the running HTTP server. */
|
|
18
59
|
export type HttpServerHandle = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAC9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAG3E,oDAAoD;AACpD,MAAM,MAAM,wBAAwB,GAAG;IACtC,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,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;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,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvC,CAAA;AAED,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B,CAAA;AAED,4DAA4D;AAC5D,eAAO,MAAM,eAAe,GAAU,SAAS,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CA2B1F,CAAA"}
|
package/dist/http/server.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
+
import { dispatch } from './router.js';
|
|
2
3
|
/** Start HTTP server bound to localhost for watcher API. */
|
|
3
4
|
export const startHttpServer = async (options) => {
|
|
4
|
-
const server = http.createServer(
|
|
5
|
+
const server = http.createServer((req, res) => {
|
|
5
6
|
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? options.host}`);
|
|
6
|
-
|
|
7
|
-
return respondJson(res, buildStatus(options));
|
|
8
|
-
}
|
|
9
|
-
if (req.method === 'GET' && url.pathname === '/logs') {
|
|
10
|
-
return handleLogs(url, res, options);
|
|
11
|
-
}
|
|
12
|
-
if (req.method === 'GET' && url.pathname === '/tail') {
|
|
13
|
-
return handleTail(url, res, options);
|
|
14
|
-
}
|
|
15
|
-
respondJson(res, { ok: false, error: { message: 'Not found', code: 'not_found' } }, 404);
|
|
7
|
+
dispatch(req, res, url, options);
|
|
16
8
|
});
|
|
17
9
|
await new Promise((resolve, reject) => {
|
|
18
10
|
server.once('error', reject);
|
|
@@ -33,75 +25,4 @@ export const startHttpServer = async (options) => {
|
|
|
33
25
|
}),
|
|
34
26
|
};
|
|
35
27
|
};
|
|
36
|
-
const handleLogs = (url, res, options) => {
|
|
37
|
-
const after = clampNumber(url.searchParams.get('after'), 0);
|
|
38
|
-
const limit = clampNumber(url.searchParams.get('limit'), 500, 1, 5000);
|
|
39
|
-
const levels = parseLevels(url.searchParams.get('levels'));
|
|
40
|
-
const grep = url.searchParams.get('grep') ?? undefined;
|
|
41
|
-
const sinceTs = clampNumber(url.searchParams.get('sinceTs'), undefined);
|
|
42
|
-
const events = options.buffer.listAfter(after, { levels, grep, sinceTs }, limit);
|
|
43
|
-
const nextAfter = events.length > 0 ? (events[events.length - 1]?.id ?? after) : after;
|
|
44
|
-
const response = { ok: true, events, nextAfter };
|
|
45
|
-
respondJson(res, response);
|
|
46
|
-
};
|
|
47
|
-
const handleTail = async (url, res, options) => {
|
|
48
|
-
const after = clampNumber(url.searchParams.get('after'), 0);
|
|
49
|
-
const limit = clampNumber(url.searchParams.get('limit'), 500, 1, 5000);
|
|
50
|
-
const timeoutMs = clampNumber(url.searchParams.get('timeoutMs'), 25_000, 1000, 120_000);
|
|
51
|
-
const levels = parseLevels(url.searchParams.get('levels'));
|
|
52
|
-
const grep = url.searchParams.get('grep') ?? undefined;
|
|
53
|
-
const events = await options.buffer.waitForAfter(after, { levels, grep }, limit, timeoutMs);
|
|
54
|
-
const nextAfter = events.length > 0 ? (events[events.length - 1]?.id ?? after) : after;
|
|
55
|
-
const response = { ok: true, events, nextAfter, timedOut: events.length === 0 };
|
|
56
|
-
respondJson(res, response);
|
|
57
|
-
};
|
|
58
|
-
const buildStatus = (options) => {
|
|
59
|
-
const watcher = options.getWatcher();
|
|
60
|
-
const buffer = options.buffer.getStats();
|
|
61
|
-
const cdpStatus = options.getCdpStatus();
|
|
62
|
-
return {
|
|
63
|
-
ok: true,
|
|
64
|
-
id: watcher.id,
|
|
65
|
-
pid: watcher.pid,
|
|
66
|
-
attached: cdpStatus.attached,
|
|
67
|
-
target: cdpStatus.target,
|
|
68
|
-
buffer,
|
|
69
|
-
watcher,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
const respondJson = (res, body, status = 200) => {
|
|
73
|
-
const payload = JSON.stringify(body);
|
|
74
|
-
res.statusCode = status;
|
|
75
|
-
res.setHeader('Content-Type', 'application/json');
|
|
76
|
-
res.end(payload);
|
|
77
|
-
};
|
|
78
|
-
const clampNumber = (value, fallback, min, max) => {
|
|
79
|
-
if (value == null) {
|
|
80
|
-
return fallback ?? 0;
|
|
81
|
-
}
|
|
82
|
-
const parsed = Number(value);
|
|
83
|
-
if (!Number.isFinite(parsed)) {
|
|
84
|
-
return fallback ?? 0;
|
|
85
|
-
}
|
|
86
|
-
if (min != null && parsed < min) {
|
|
87
|
-
return min;
|
|
88
|
-
}
|
|
89
|
-
if (max != null && parsed > max) {
|
|
90
|
-
return max;
|
|
91
|
-
}
|
|
92
|
-
return parsed;
|
|
93
|
-
};
|
|
94
|
-
const parseLevels = (value) => {
|
|
95
|
-
if (!value) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
const levels = value
|
|
99
|
-
.split(',')
|
|
100
|
-
.map((item) => item.trim())
|
|
101
|
-
.filter(Boolean);
|
|
102
|
-
if (levels.length === 0) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
return levels;
|
|
106
|
-
};
|
|
107
28
|
//# sourceMappingURL=server.js.map
|
package/dist/http/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAW5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAoFtC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,OAA0B,EAA6B,EAAE;IAC9F,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,UAAU,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QACjF,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;IAEF,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC5B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IAChC,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;IAEjF,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,GAAG,EAAE,CACX,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC/B,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,IAAI,KAAK,EAAE,CAAC;oBACX,MAAM,CAAC,KAAK,CAAC,CAAA;oBACb,OAAM;gBACP,CAAC;gBACD,OAAO,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;QACH,CAAC,CAAC;KACH,CAAA;AACF,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,84 @@
|
|
|
1
1
|
import type { WatcherMatch, WatcherChrome, WatcherRecord, LogEvent } from '@vforsh/argus-core';
|
|
2
|
+
import Emittery from 'emittery';
|
|
3
|
+
import { type PageIndicatorOptions } from './cdp/pageIndicator.js';
|
|
4
|
+
import type { ArgusWatcherEventMap } from './events.js';
|
|
5
|
+
/** Context for the optional log filename builder callback. */
|
|
6
|
+
export type BuildFilenameContext = {
|
|
7
|
+
/** Unique watcher identifier. */
|
|
8
|
+
watcherId: string;
|
|
9
|
+
/** Watcher start time as milliseconds since Unix epoch. */
|
|
10
|
+
startedAt: number;
|
|
11
|
+
/** Watcher start time formatted for use in a filename (ISO but with ":" replaced by "-"). */
|
|
12
|
+
startedAtSafe: string;
|
|
13
|
+
/** Sequence number of the log file within the current watcher session (starts at 1). */
|
|
14
|
+
fileIndex: number;
|
|
15
|
+
};
|
|
16
|
+
/** Configuration for artifacts storage (logs, traces, screenshots). */
|
|
17
|
+
export type ArtifactsOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Base directory for all artifacts.
|
|
20
|
+
* Defaults to `$TMPDIR/argus/<watcherId>`.
|
|
21
|
+
*/
|
|
22
|
+
base?: string;
|
|
23
|
+
/** Optional file log persistence settings. Disabled by default. */
|
|
24
|
+
logs?: {
|
|
25
|
+
/** Enable file logging. Defaults to `false`. */
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
/** Whether to include ISO timestamps in log records. Defaults to `false`. */
|
|
28
|
+
includeTimestamps?: boolean;
|
|
29
|
+
/** Max number of log files to keep for this watcher. Defaults to `5`. */
|
|
30
|
+
maxFiles?: number;
|
|
31
|
+
/** Optional callback to customize the log filename. Return null/undefined to use default. */
|
|
32
|
+
buildFilename?: (context: BuildFilenameContext) => string | undefined | null;
|
|
33
|
+
};
|
|
34
|
+
/** Trace recording settings. Enabled by default. */
|
|
35
|
+
traces?: {
|
|
36
|
+
/** Enable trace recording. Defaults to `true`. */
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Screenshot capture settings. Enabled by default. */
|
|
40
|
+
screenshots?: {
|
|
41
|
+
/** Enable screenshot capture. Defaults to `true`. */
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** Configuration for network request capture. */
|
|
46
|
+
export type NetOptions = {
|
|
47
|
+
/** Enable network request capture. Defaults to `false`. */
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** Page console logging level for watcher lifecycle and request logs. */
|
|
51
|
+
export type PageConsoleLogging = 'none' | 'minimal' | 'full';
|
|
52
|
+
/** Source mode for CDP connection. */
|
|
53
|
+
export type WatcherSourceMode = 'cdp' | 'extension';
|
|
2
54
|
/** Options to start a watcher server. */
|
|
3
55
|
export type StartWatcherOptions = {
|
|
4
56
|
/** Unique watcher identifier (used for registry presence and removal on shutdown). */
|
|
5
57
|
id: string;
|
|
58
|
+
/**
|
|
59
|
+
* Source mode for CDP connection.
|
|
60
|
+
* - `cdp` (default): Connect directly to Chrome via WebSocket.
|
|
61
|
+
* - `extension`: Connect via Chrome extension Native Messaging.
|
|
62
|
+
*/
|
|
63
|
+
source?: WatcherSourceMode;
|
|
6
64
|
/** Host/interface to bind the watcher HTTP server to. Defaults to `127.0.0.1`. */
|
|
7
65
|
host?: string;
|
|
8
66
|
/** Port to bind the watcher HTTP server to. Defaults to `0` (ephemeral). */
|
|
9
67
|
port?: number;
|
|
10
|
-
/** Criteria for which Chrome target(s) to attach to. */
|
|
68
|
+
/** Criteria for which Chrome target(s) to attach to. Only used in CDP mode. */
|
|
11
69
|
match?: WatcherMatch;
|
|
12
|
-
/** Chrome DevTools Protocol (CDP) connection settings. Defaults to `127.0.0.1:9222`. */
|
|
70
|
+
/** Chrome DevTools Protocol (CDP) connection settings. Defaults to `127.0.0.1:9222`. Only used in CDP mode. */
|
|
13
71
|
chrome?: WatcherChrome;
|
|
14
72
|
/** Max buffered log events before older entries are dropped. Defaults to `50_000`. */
|
|
15
73
|
bufferSize?: number;
|
|
16
74
|
/** How often (in ms) to refresh the watcher record in the registry. Defaults to `15_000`. */
|
|
17
75
|
heartbeatMs?: number;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
76
|
+
/**
|
|
77
|
+
* Artifacts storage configuration for logs, traces, and screenshots.
|
|
78
|
+
* All artifacts are stored under `artifacts.base` (default: `$TMPDIR/argus`).
|
|
79
|
+
* Subdirectories: `logs/`, `traces/`, `screenshots/`.
|
|
80
|
+
*/
|
|
81
|
+
artifacts?: ArtifactsOptions;
|
|
25
82
|
/** Optional ignore list filtering when selecting log/exception locations. */
|
|
26
83
|
ignoreList?: {
|
|
27
84
|
/** Enable ignore list filtering for log/exception locations. */
|
|
@@ -29,8 +86,6 @@ export type StartWatcherOptions = {
|
|
|
29
86
|
/** Regex patterns (as strings) to ignore when selecting a stack frame. */
|
|
30
87
|
rules?: string[];
|
|
31
88
|
};
|
|
32
|
-
/** Whether to include ISO timestamps in log records. Defaults to `false`. */
|
|
33
|
-
includeTimestamps?: boolean;
|
|
34
89
|
location?: {
|
|
35
90
|
/**
|
|
36
91
|
* Strip these literal prefixes from event.file for display/logging.
|
|
@@ -38,18 +93,66 @@ export type StartWatcherOptions = {
|
|
|
38
93
|
*/
|
|
39
94
|
stripUrlPrefixes?: string[];
|
|
40
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Optional in-page indicator showing that the watcher is attached.
|
|
98
|
+
* When enabled, a small badge is injected into the page. Clicking it shows watcher info.
|
|
99
|
+
* The indicator auto-removes via TTL if the watcher dies without cleanup.
|
|
100
|
+
* Supported in both direct CDP and Chrome extension modes.
|
|
101
|
+
*/
|
|
102
|
+
pageIndicator?: PageIndicatorOptions;
|
|
103
|
+
/**
|
|
104
|
+
* Network request capture configuration.
|
|
105
|
+
* When enabled, captures HTTP requests and exposes them via `/net` and `/net/tail` endpoints.
|
|
106
|
+
* Disabled by default. Only supported in CDP mode.
|
|
107
|
+
*/
|
|
108
|
+
net?: NetOptions;
|
|
109
|
+
/**
|
|
110
|
+
* Write watcher lifecycle and request logs into the attached page's DevTools console.
|
|
111
|
+
* - `none`: Do not write anything.
|
|
112
|
+
* - `minimal` (default): Write attach/detach lifecycle messages.
|
|
113
|
+
* - `full`: Same as minimal, plus log every HTTP request to the watcher API.
|
|
114
|
+
*/
|
|
115
|
+
pageConsoleLogging?: PageConsoleLogging;
|
|
116
|
+
/**
|
|
117
|
+
* Optional JavaScript to inject on attach and document start.
|
|
118
|
+
* The script is provided as raw text to keep watcher package filesystem-agnostic.
|
|
119
|
+
*/
|
|
120
|
+
inject?: {
|
|
121
|
+
script: string;
|
|
122
|
+
exposeArgus?: boolean;
|
|
123
|
+
};
|
|
41
124
|
};
|
|
42
125
|
/** Handle returned by startWatcher. */
|
|
43
126
|
export type WatcherHandle = {
|
|
44
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The current watcher record (including id/bind address/port and CDP match settings).
|
|
129
|
+
*
|
|
130
|
+
* This is the shape announced in the local registry and the same metadata served via the HTTP API.
|
|
131
|
+
*/
|
|
45
132
|
watcher: WatcherRecord;
|
|
133
|
+
/**
|
|
134
|
+
* Event emitter for watcher lifecycle and request events.
|
|
135
|
+
* Subscribe to 'cdpAttached', 'cdpDetached', and 'httpRequested'.
|
|
136
|
+
*/
|
|
137
|
+
events: Emittery<ArgusWatcherEventMap>;
|
|
138
|
+
/**
|
|
139
|
+
* Stop the watcher and release resources.
|
|
140
|
+
*
|
|
141
|
+
* Shuts down CDP attachment, stops the HTTP server, closes any artifact writers (file logs),
|
|
142
|
+
* clears event listeners, and removes the watcher from the local registry.
|
|
143
|
+
*
|
|
144
|
+
* Safe to call multiple times.
|
|
145
|
+
*/
|
|
146
|
+
close: () => Promise<void>;
|
|
46
147
|
};
|
|
47
148
|
/**
|
|
48
|
-
* Start a watcher that connects to Chrome CDP, buffers console logs, and exposes the HTTP API.
|
|
49
|
-
* @param options - Configuration for binding,
|
|
149
|
+
* Start a watcher that connects to Chrome (via CDP or extension), buffers console logs, and exposes the HTTP API.
|
|
150
|
+
* @param options - Configuration for binding, source mode, and buffering.
|
|
50
151
|
* @returns A handle that can be closed to stop the watcher and clean up registry state.
|
|
51
152
|
*/
|
|
52
153
|
export declare const startWatcher: (options: StartWatcherOptions) => Promise<WatcherHandle>;
|
|
53
154
|
/** Log event shape emitted by watchers. */
|
|
54
155
|
export type { LogEvent };
|
|
156
|
+
export type { ArgusWatcherEventMap, CdpAttachedEvent, CdpDetachedEvent, HttpRequestEvent, LogRequestQuery, NetRequestQuery } from './events.js';
|
|
157
|
+
export type { PageIndicatorOptions, PageIndicatorPosition } from './cdp/pageIndicator.js';
|
|
55
158
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG9F,OAAO,QAAQ,MAAM,UAAU,CAAA;AAY/B,OAAO,EAGN,KAAK,oBAAoB,EAEzB,MAAM,wBAAwB,CAAA;AAM/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGvD,8DAA8D;AAC9D,MAAM,MAAM,oBAAoB,GAAG;IAClC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAA;IACjB,6FAA6F;IAC7F,aAAa,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,SAAS,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mEAAmE;IACnE,IAAI,CAAC,EAAE;QACN,gDAAg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