@vforsh/argus-watcher 0.1.2 → 0.1.3
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 +66 -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 +24 -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 +64 -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 +82 -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 +16 -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 +17 -0
- package/dist/cdp/dom.d.ts.map +1 -0
- package/dist/cdp/dom.js +10 -0
- package/dist/cdp/dom.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 +10 -0
- package/dist/cdp/eval.d.ts.map +1 -0
- package/dist/cdp/eval.js +34 -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 +199 -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 +87 -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 +19 -0
- package/dist/cdp/text-filter.d.ts.map +1 -0
- package/dist/cdp/text-filter.js +54 -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 +14 -0
- package/dist/cdp/tracing.d.ts.map +1 -0
- package/dist/cdp/tracing.js +115 -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 +81 -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 +23 -0
- package/dist/http/routes/postAttach.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 +23 -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 +67 -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 +26 -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 +40 -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 +330 -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 +105 -0
- package/dist/native-messaging/session-manager.d.ts.map +1 -0
- package/dist/native-messaging/session-manager.js +259 -0
- package/dist/native-messaging/session-manager.js.map +1 -0
- package/dist/native-messaging/types.d.ts +79 -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 +48 -0
- package/dist/sources/cdp-source.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 +256 -0
- package/dist/sources/extension-source.js.map +1 -0
- package/dist/sources/types.d.ts +92 -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,189 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Install/uninstall Native Messaging host manifest for the Argus extension.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node dist/scripts/install-host.js install <EXTENSION_ID>
|
|
7
|
+
* node dist/scripts/install-host.js uninstall
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
import { execSync } from 'node:child_process';
|
|
13
|
+
const __dirname = import.meta.dirname;
|
|
14
|
+
const HOST_NAME = 'com.vforsh.argus.bridge';
|
|
15
|
+
const getManifestDir = (platform) => {
|
|
16
|
+
switch (platform) {
|
|
17
|
+
case 'darwin':
|
|
18
|
+
return path.join(os.homedir(), 'Library/Application Support/Google/Chrome/NativeMessagingHosts');
|
|
19
|
+
case 'linux':
|
|
20
|
+
return path.join(os.homedir(), '.config/google-chrome/NativeMessagingHosts');
|
|
21
|
+
case 'win32':
|
|
22
|
+
return path.join(process.env.LOCALAPPDATA ?? os.homedir(), 'Google/Chrome/User Data/NativeMessagingHosts');
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const getManifestPath = (platform) => {
|
|
28
|
+
return path.join(getManifestDir(platform), `${HOST_NAME}.json`);
|
|
29
|
+
};
|
|
30
|
+
const findArgusExecutable = () => {
|
|
31
|
+
// Try to find the argus CLI executable
|
|
32
|
+
// First, check if we're in a development environment
|
|
33
|
+
const devPath = path.resolve(__dirname, '../../../argus/dist/bin.js');
|
|
34
|
+
if (fs.existsSync(devPath)) {
|
|
35
|
+
return devPath;
|
|
36
|
+
}
|
|
37
|
+
// Check for globally installed argus
|
|
38
|
+
try {
|
|
39
|
+
const npmGlobalPrefix = execSync('npm config get prefix', { encoding: 'utf8' }).trim();
|
|
40
|
+
const globalBinPath = path.join(npmGlobalPrefix, 'bin', 'argus');
|
|
41
|
+
if (fs.existsSync(globalBinPath)) {
|
|
42
|
+
return globalBinPath;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Ignore
|
|
47
|
+
}
|
|
48
|
+
// Check if argus is in PATH
|
|
49
|
+
try {
|
|
50
|
+
const whichPath = execSync('which argus', { encoding: 'utf8' }).trim();
|
|
51
|
+
if (whichPath) {
|
|
52
|
+
return whichPath;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Ignore
|
|
57
|
+
}
|
|
58
|
+
throw new Error('Could not find argus executable. Please install argus globally (npm install -g @vforsh/argus) or run from the development directory.');
|
|
59
|
+
};
|
|
60
|
+
const createManifest = (extensionId, executablePath) => {
|
|
61
|
+
return {
|
|
62
|
+
name: HOST_NAME,
|
|
63
|
+
description: 'Argus Watcher Native Messaging Host',
|
|
64
|
+
path: executablePath,
|
|
65
|
+
type: 'stdio',
|
|
66
|
+
allowed_origins: [`chrome-extension://${extensionId}/`],
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const findNodePath = () => {
|
|
70
|
+
// Get the current node executable path and resolve any symlinks
|
|
71
|
+
// This is important for fnm/nvm which use symlinks in temporary directories
|
|
72
|
+
return fs.realpathSync(process.execPath);
|
|
73
|
+
};
|
|
74
|
+
const createWrapperScript = (platform, executablePath) => {
|
|
75
|
+
const wrapperDir = getManifestDir(platform);
|
|
76
|
+
const wrapperPath = path.join(wrapperDir, 'argus-native-host.sh');
|
|
77
|
+
const nodePath = findNodePath();
|
|
78
|
+
// Create a wrapper script that launches argus in native-host mode
|
|
79
|
+
// Use absolute path to node since Chrome spawns without shell profile
|
|
80
|
+
const script = `#!/bin/bash
|
|
81
|
+
exec "${nodePath}" "${executablePath}" watcher native-host
|
|
82
|
+
`;
|
|
83
|
+
fs.writeFileSync(wrapperPath, script, { mode: 0o755 });
|
|
84
|
+
return wrapperPath;
|
|
85
|
+
};
|
|
86
|
+
const install = (extensionId) => {
|
|
87
|
+
const platform = os.platform();
|
|
88
|
+
if (!['darwin', 'linux', 'win32'].includes(platform)) {
|
|
89
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
const manifestDir = getManifestDir(platform);
|
|
93
|
+
const manifestPath = getManifestPath(platform);
|
|
94
|
+
// Ensure directory exists
|
|
95
|
+
fs.mkdirSync(manifestDir, { recursive: true });
|
|
96
|
+
// Find argus executable
|
|
97
|
+
let executablePath;
|
|
98
|
+
try {
|
|
99
|
+
executablePath = findArgusExecutable();
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.error(err.message);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
// Create wrapper script (Native Messaging requires a native executable, not node)
|
|
106
|
+
const wrapperPath = createWrapperScript(platform, executablePath);
|
|
107
|
+
console.log(`Created wrapper script: ${wrapperPath}`);
|
|
108
|
+
// Create manifest
|
|
109
|
+
const manifest = createManifest(extensionId, wrapperPath);
|
|
110
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
111
|
+
console.log(`Created manifest: ${manifestPath}`);
|
|
112
|
+
// Windows: Add registry key
|
|
113
|
+
if (platform === 'win32') {
|
|
114
|
+
const regKey = `HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\${HOST_NAME}`;
|
|
115
|
+
try {
|
|
116
|
+
execSync(`reg add "${regKey}" /ve /t REG_SZ /d "${manifestPath}" /f`, { stdio: 'inherit' });
|
|
117
|
+
console.log(`Added registry key: ${regKey}`);
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
console.error('Failed to add registry key:', err);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
console.log('\nNative Messaging host installed successfully!');
|
|
125
|
+
console.log(`Host name: ${HOST_NAME}`);
|
|
126
|
+
console.log(`Extension ID: ${extensionId}`);
|
|
127
|
+
};
|
|
128
|
+
const uninstall = () => {
|
|
129
|
+
const platform = os.platform();
|
|
130
|
+
if (!['darwin', 'linux', 'win32'].includes(platform)) {
|
|
131
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
const manifestPath = getManifestPath(platform);
|
|
135
|
+
const wrapperPath = path.join(getManifestDir(platform), 'argus-native-host.sh');
|
|
136
|
+
// Remove manifest
|
|
137
|
+
if (fs.existsSync(manifestPath)) {
|
|
138
|
+
fs.unlinkSync(manifestPath);
|
|
139
|
+
console.log(`Removed manifest: ${manifestPath}`);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log(`Manifest not found: ${manifestPath}`);
|
|
143
|
+
}
|
|
144
|
+
// Remove wrapper script
|
|
145
|
+
if (fs.existsSync(wrapperPath)) {
|
|
146
|
+
fs.unlinkSync(wrapperPath);
|
|
147
|
+
console.log(`Removed wrapper script: ${wrapperPath}`);
|
|
148
|
+
}
|
|
149
|
+
// Windows: Remove registry key
|
|
150
|
+
if (platform === 'win32') {
|
|
151
|
+
const regKey = `HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\${HOST_NAME}`;
|
|
152
|
+
try {
|
|
153
|
+
execSync(`reg delete "${regKey}" /f`, { stdio: 'inherit' });
|
|
154
|
+
console.log(`Removed registry key: ${regKey}`);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// Key might not exist
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
console.log('\nNative Messaging host uninstalled.');
|
|
161
|
+
};
|
|
162
|
+
const main = () => {
|
|
163
|
+
const args = process.argv.slice(2);
|
|
164
|
+
const command = args[0];
|
|
165
|
+
if (command === 'install') {
|
|
166
|
+
const extensionId = args[1];
|
|
167
|
+
if (!extensionId) {
|
|
168
|
+
console.error('Usage: install-host install <EXTENSION_ID>');
|
|
169
|
+
console.error('\nTo get your extension ID:');
|
|
170
|
+
console.error('1. Open chrome://extensions');
|
|
171
|
+
console.error('2. Enable Developer mode');
|
|
172
|
+
console.error('3. Load the argus-extension package as unpacked extension');
|
|
173
|
+
console.error('4. Copy the ID shown on the extension card');
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
install(extensionId);
|
|
177
|
+
}
|
|
178
|
+
else if (command === 'uninstall') {
|
|
179
|
+
uninstall();
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
console.error('Usage:');
|
|
183
|
+
console.error(' install-host install <EXTENSION_ID>');
|
|
184
|
+
console.error(' install-host uninstall');
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
main();
|
|
189
|
+
//# sourceMappingURL=install-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-host.js","sourceRoot":"","sources":["../../src/scripts/install-host.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAQ,CAAA;AAEtC,MAAM,SAAS,GAAG,yBAAyB,CAAA;AAI3C,MAAM,cAAc,GAAG,CAAC,QAAkB,EAAU,EAAE;IACrD,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,gEAAgE,CAAC,CAAA;QACjG,KAAK,OAAO;YACX,OAAO,IAAI,CAAC,IA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AC,IAAI,CAAC,CAAC,CAAC,CAAA;QAChB,CAAC;QACD,OAAO,CAAC,WAAW,CAAC,CAAA;IACrB,CAAC;SAAM,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QACpC,SAAS,EAAE,CAAA;IACZ,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACvB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA;QACtD,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC,CAAA;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDP source for direct Chrome DevTools Protocol connection via WebSocket.
|
|
3
|
+
* Wraps the existing CDP watcher with the unified source interface.
|
|
4
|
+
*/
|
|
5
|
+
import type { WatcherMatch, WatcherChrome } from '@vforsh/argus-core';
|
|
6
|
+
import { type CdpSessionController } from '../cdp/connection.js';
|
|
7
|
+
import type { CdpSourceHandle, CdpSourceBaseOptions } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a CDP source.
|
|
10
|
+
*/
|
|
11
|
+
export type CdpSourceOptions = CdpSourceBaseOptions & {
|
|
12
|
+
/** Chrome DevTools Protocol connection settings. */
|
|
13
|
+
chrome: WatcherChrome;
|
|
14
|
+
/** Criteria for which Chrome target(s) to attach to. */
|
|
15
|
+
match?: WatcherMatch;
|
|
16
|
+
/** Optional session controller (for sharing session handle with other components). */
|
|
17
|
+
sessionHandle?: CdpSessionController;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create a CDP source that connects to Chrome via WebSocket.
|
|
21
|
+
* Returns a handle that can be used to control the source and access CDP session.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createCdpSource: (options: CdpSourceOptions) => CdpSourceHandle;
|
|
24
|
+
//# sourceMappingURL=cdp-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdp-source.d.ts","sourceRoot":"","sources":["../../src/sources/cdp-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAErE,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAExF,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG;IACrD,oDAAoD;IACpD,MAAM,EAAE,aAAa,CAAA;IACrB,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,sFAAsF;IACtF,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,eA0C3D,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDP source for direct Chrome DevTools Protocol connection via WebSocket.
|
|
3
|
+
* Wraps the existing CDP watcher with the unified source interface.
|
|
4
|
+
*/
|
|
5
|
+
import { startCdpWatcher } from '../cdp/watcher.js';
|
|
6
|
+
import { createCdpSessionHandle } from '../cdp/connection.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create a CDP source that connects to Chrome via WebSocket.
|
|
9
|
+
* Returns a handle that can be used to control the source and access CDP session.
|
|
10
|
+
*/
|
|
11
|
+
export const createCdpSource = (options) => {
|
|
12
|
+
const { events, ignoreMatcher, stripUrlPrefixes, chrome, match, sessionHandle } = options;
|
|
13
|
+
// Create session handle if not provided
|
|
14
|
+
const controller = sessionHandle ?? createCdpSessionHandle();
|
|
15
|
+
// Convert ignoreMatcher function to IgnoreMatcher object if needed
|
|
16
|
+
const ignoreMatcherObj = ignoreMatcher ? { matches: ignoreMatcher } : null;
|
|
17
|
+
// Map source events to watcher events
|
|
18
|
+
const watcherOptions = {
|
|
19
|
+
chrome,
|
|
20
|
+
match,
|
|
21
|
+
sessionHandle: controller,
|
|
22
|
+
ignoreMatcher: ignoreMatcherObj,
|
|
23
|
+
stripUrlPrefixes,
|
|
24
|
+
onLog: events.onLog,
|
|
25
|
+
onStatus: events.onStatus,
|
|
26
|
+
onPageNavigation: events.onPageNavigation,
|
|
27
|
+
onPageLoad: events.onPageLoad,
|
|
28
|
+
onPageIntl: events.onPageIntl,
|
|
29
|
+
onAttach: events.onAttach
|
|
30
|
+
? (session, target) => events.onAttach(session, {
|
|
31
|
+
id: target.id,
|
|
32
|
+
title: target.title,
|
|
33
|
+
url: target.url,
|
|
34
|
+
type: target.type,
|
|
35
|
+
parentId: target.parentId,
|
|
36
|
+
})
|
|
37
|
+
: undefined,
|
|
38
|
+
onDetach: events.onDetach,
|
|
39
|
+
};
|
|
40
|
+
const watcher = startCdpWatcher(watcherOptions);
|
|
41
|
+
return {
|
|
42
|
+
session: watcher.session,
|
|
43
|
+
stop: watcher.stop,
|
|
44
|
+
// CDP mode doesn't support listTargets/attachTarget/detachTarget
|
|
45
|
+
// (auto-attaches based on match criteria)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=cdp-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdp-source.js","sourceRoot":"","sources":["../../src/sources/cdp-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAA0B,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAA6B,MAAM,sBAAsB,CAAA;AAgBxF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAyB,EAAmB,EAAE;IAC7E,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,G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
|
+
* Wraps SessionManager and provides a unified source interface.
|
|
4
|
+
*/
|
|
5
|
+
import type { CdpSourceHandle, CdpSourceBaseOptions } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating an extension source.
|
|
8
|
+
*/
|
|
9
|
+
export type ExtensionSourceOptions = CdpSourceBaseOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Create an extension source that connects to Chrome via Native Messaging.
|
|
12
|
+
* Returns a handle that can be used to control the source and access CDP session.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createExtensionSource: (options: ExtensionSourceOptions) => CdpSourceHandle;
|
|
15
|
+
//# sourceMappingURL=extension-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-source.d.ts","sourceRoot":"","sources":["../../src/sources/extension-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAGxF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,sBAAsB,KAAG,eAyIvE,CAAA"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension source for CDP access via Chrome extension Native Messaging.
|
|
3
|
+
* Wraps SessionManager and provides a unified source interface.
|
|
4
|
+
*/
|
|
5
|
+
import { previewStringify } from '@vforsh/argus-core';
|
|
6
|
+
import { createNativeMessaging } from '../native-messaging/messaging.js';
|
|
7
|
+
import { SessionManager } from '../native-messaging/session-manager.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create an extension source that connects to Chrome via Native Messaging.
|
|
10
|
+
* Returns a handle that can be used to control the source and access CDP session.
|
|
11
|
+
*/
|
|
12
|
+
export const createExtensionSource = (options) => {
|
|
13
|
+
const { events, ignoreMatcher, stripUrlPrefixes } = options;
|
|
14
|
+
const messaging = createNativeMessaging();
|
|
15
|
+
let currentSession = null;
|
|
16
|
+
let stopping = false;
|
|
17
|
+
// Create session manager with event handlers
|
|
18
|
+
const sessionManager = new SessionManager(messaging, {
|
|
19
|
+
onAttach: (session) => {
|
|
20
|
+
console.error(`[ExtensionSource] Tab attached: ${session.tabId} - ${session.url}`);
|
|
21
|
+
currentSession = session;
|
|
22
|
+
sessionManager.enableDomain(session.tabId, 'Page');
|
|
23
|
+
// Subscribe to console events
|
|
24
|
+
session.handle.onEvent('Runtime.consoleAPICalled', (params) => {
|
|
25
|
+
const logEvent = toConsoleEvent(params, session, { ignoreMatcher, stripUrlPrefixes });
|
|
26
|
+
events.onLog(logEvent);
|
|
27
|
+
});
|
|
28
|
+
// Subscribe to exception events
|
|
29
|
+
session.handle.onEvent('Runtime.exceptionThrown', (params) => {
|
|
30
|
+
const logEvent = toExceptionEvent(params, session, { ignoreMatcher, stripUrlPrefixes });
|
|
31
|
+
events.onLog(logEvent);
|
|
32
|
+
});
|
|
33
|
+
// Notify status change
|
|
34
|
+
const target = {
|
|
35
|
+
id: String(session.tabId),
|
|
36
|
+
title: session.title,
|
|
37
|
+
url: session.url,
|
|
38
|
+
type: 'page',
|
|
39
|
+
faviconUrl: session.faviconUrl,
|
|
40
|
+
attached: true,
|
|
41
|
+
};
|
|
42
|
+
events.onStatus({
|
|
43
|
+
attached: true,
|
|
44
|
+
target: {
|
|
45
|
+
title: session.title,
|
|
46
|
+
url: session.url,
|
|
47
|
+
type: 'page',
|
|
48
|
+
parentId: null,
|
|
49
|
+
},
|
|
50
|
+
reason: null,
|
|
51
|
+
});
|
|
52
|
+
void events.onAttach?.(session.handle, target);
|
|
53
|
+
},
|
|
54
|
+
onDetach: (tabId, reason) => {
|
|
55
|
+
console.error(`[ExtensionSource] Tab detached: ${tabId} - ${reason}`);
|
|
56
|
+
if (currentSession?.tabId === tabId) {
|
|
57
|
+
currentSession = null;
|
|
58
|
+
}
|
|
59
|
+
events.onStatus({
|
|
60
|
+
attached: false,
|
|
61
|
+
target: null,
|
|
62
|
+
reason,
|
|
63
|
+
});
|
|
64
|
+
events.onDetach?.(reason);
|
|
65
|
+
},
|
|
66
|
+
onTabsUpdated: () => {
|
|
67
|
+
// Tabs list updated - no action needed
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
// Create a proxy session handle that delegates to the current session
|
|
71
|
+
const proxySession = {
|
|
72
|
+
isAttached: () => currentSession?.handle.isAttached() ?? false,
|
|
73
|
+
sendAndWait: async (method, params, options) => {
|
|
74
|
+
const session = currentSession;
|
|
75
|
+
if (!session) {
|
|
76
|
+
const error = new Error('No tab attached via extension');
|
|
77
|
+
error.code = 'cdp_not_attached';
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
return session.handle.sendAndWait(method, params, options);
|
|
81
|
+
},
|
|
82
|
+
onEvent: (method, handler) => {
|
|
83
|
+
// For proxy session, we need to track all handlers and replay them
|
|
84
|
+
// when a new session is attached. For now, just use the current session.
|
|
85
|
+
if (!currentSession) {
|
|
86
|
+
// Return a no-op unsubscribe function
|
|
87
|
+
return () => { };
|
|
88
|
+
}
|
|
89
|
+
return currentSession.handle.onEvent(method, handler);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
// Start Native Messaging
|
|
93
|
+
messaging.start();
|
|
94
|
+
messaging.onDisconnect(() => {
|
|
95
|
+
console.error('[ExtensionSource] Extension disconnected');
|
|
96
|
+
if (!stopping) {
|
|
97
|
+
events.onStatus({
|
|
98
|
+
attached: false,
|
|
99
|
+
target: null,
|
|
100
|
+
reason: 'extension_disconnected',
|
|
101
|
+
});
|
|
102
|
+
events.onDetach?.('extension_disconnected');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const stop = async () => {
|
|
106
|
+
stopping = true;
|
|
107
|
+
messaging.stop();
|
|
108
|
+
};
|
|
109
|
+
const listTargets = async () => {
|
|
110
|
+
const tabs = await sessionManager.listTabs();
|
|
111
|
+
return tabs.map(tabToTarget);
|
|
112
|
+
};
|
|
113
|
+
const attachTarget = (targetId) => {
|
|
114
|
+
sessionManager.attachTab(targetId);
|
|
115
|
+
};
|
|
116
|
+
const detachTarget = (targetId) => {
|
|
117
|
+
sessionManager.detachTab(targetId);
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
session: proxySession,
|
|
121
|
+
stop,
|
|
122
|
+
listTargets,
|
|
123
|
+
attachTarget,
|
|
124
|
+
detachTarget,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Convert TabInfo to CdpSourceTarget.
|
|
129
|
+
*/
|
|
130
|
+
const tabToTarget = (tab) => ({
|
|
131
|
+
id: String(tab.tabId),
|
|
132
|
+
title: tab.title,
|
|
133
|
+
url: tab.url,
|
|
134
|
+
type: 'page',
|
|
135
|
+
faviconUrl: tab.faviconUrl,
|
|
136
|
+
attached: tab.attached,
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* Convert Runtime.consoleAPICalled event to LogEvent.
|
|
140
|
+
*/
|
|
141
|
+
const toConsoleEvent = (params, session, config) => {
|
|
142
|
+
const record = params;
|
|
143
|
+
const args = record.args?.map((a) => a.value) ?? [];
|
|
144
|
+
const text = formatArgs(record.args ?? []);
|
|
145
|
+
const frame = selectBestFrame(record.stackTrace?.callFrames, config.ignoreMatcher);
|
|
146
|
+
return {
|
|
147
|
+
ts: record.timestamp ?? Date.now(),
|
|
148
|
+
level: normalizeLevel(record.type ?? 'log'),
|
|
149
|
+
text,
|
|
150
|
+
args,
|
|
151
|
+
source: 'console',
|
|
152
|
+
file: applyStripPrefixes(frame?.url ?? null, config.stripUrlPrefixes),
|
|
153
|
+
line: frame?.lineNumber != null ? frame.lineNumber + 1 : null,
|
|
154
|
+
column: frame?.columnNumber != null ? frame.columnNumber + 1 : null,
|
|
155
|
+
pageUrl: session.url,
|
|
156
|
+
pageTitle: session.title,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Convert Runtime.exceptionThrown event to LogEvent.
|
|
161
|
+
*/
|
|
162
|
+
const toExceptionEvent = (params, session, config) => {
|
|
163
|
+
const record = params;
|
|
164
|
+
const details = record.exceptionDetails;
|
|
165
|
+
const text = details?.exception?.description ?? details?.text ?? 'Exception';
|
|
166
|
+
const args = details?.exception ? [details.exception.value ?? details.exception.description] : [];
|
|
167
|
+
const frame = selectBestFrame(details?.stackTrace?.callFrames, config.ignoreMatcher);
|
|
168
|
+
return {
|
|
169
|
+
ts: record.timestamp ?? Date.now(),
|
|
170
|
+
level: 'exception',
|
|
171
|
+
text,
|
|
172
|
+
args,
|
|
173
|
+
source: 'exception',
|
|
174
|
+
file: applyStripPrefixes(frame?.url ?? null, config.stripUrlPrefixes),
|
|
175
|
+
line: frame?.lineNumber != null ? frame.lineNumber + 1 : null,
|
|
176
|
+
column: frame?.columnNumber != null ? frame.columnNumber + 1 : null,
|
|
177
|
+
pageUrl: session.url,
|
|
178
|
+
pageTitle: session.title,
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Format console args for display.
|
|
183
|
+
*/
|
|
184
|
+
const formatArgs = (args) => {
|
|
185
|
+
if (args.length === 0) {
|
|
186
|
+
return '';
|
|
187
|
+
}
|
|
188
|
+
return args
|
|
189
|
+
.map((arg) => {
|
|
190
|
+
if (arg.value !== undefined) {
|
|
191
|
+
return typeof arg.value === 'string' ? arg.value : previewStringify(arg.value);
|
|
192
|
+
}
|
|
193
|
+
return arg.description ?? `[${arg.type}]`;
|
|
194
|
+
})
|
|
195
|
+
.join(' ');
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Normalize console log type to LogLevel.
|
|
199
|
+
*/
|
|
200
|
+
const normalizeLevel = (type) => {
|
|
201
|
+
switch (type) {
|
|
202
|
+
case 'log':
|
|
203
|
+
case 'info':
|
|
204
|
+
case 'debug':
|
|
205
|
+
case 'dir':
|
|
206
|
+
case 'dirxml':
|
|
207
|
+
case 'table':
|
|
208
|
+
case 'trace':
|
|
209
|
+
case 'count':
|
|
210
|
+
case 'timeEnd':
|
|
211
|
+
case 'timeLog':
|
|
212
|
+
return type === 'debug' ? 'debug' : type === 'info' ? 'info' : 'log';
|
|
213
|
+
case 'warn':
|
|
214
|
+
case 'warning':
|
|
215
|
+
return 'warning';
|
|
216
|
+
case 'error':
|
|
217
|
+
case 'assert':
|
|
218
|
+
case 'exception':
|
|
219
|
+
return type === 'exception' ? 'exception' : 'error';
|
|
220
|
+
default:
|
|
221
|
+
return 'log';
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Select the best frame from the stack trace (first non-ignored frame).
|
|
226
|
+
*/
|
|
227
|
+
const selectBestFrame = (frames, ignoreMatcher) => {
|
|
228
|
+
if (!frames || frames.length === 0) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
if (!ignoreMatcher) {
|
|
232
|
+
return frames[0] ?? null;
|
|
233
|
+
}
|
|
234
|
+
for (const frame of frames) {
|
|
235
|
+
if (frame.url && !ignoreMatcher(frame.url)) {
|
|
236
|
+
return frame;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Fall back to first frame if all are ignored
|
|
240
|
+
return frames[0] ?? null;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Apply strip prefixes to a file URL.
|
|
244
|
+
*/
|
|
245
|
+
const applyStripPrefixes = (file, prefixes) => {
|
|
246
|
+
if (!file || !prefixes || prefixes.length === 0) {
|
|
247
|
+
return file;
|
|
248
|
+
}
|
|
249
|
+
for (const prefix of prefixes) {
|
|
250
|
+
if (file.startsWith(prefix)) {
|
|
251
|
+
return file.slice(prefix.length);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return file;
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=extension-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-source.js","sourceRoot":"","sources":["../../src/sources/extension-source.ts"],"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I,IAAI,CAAA;AACzB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,IAAmB,EAAE,QAA8B,EAAiB,EAAE;IACjG,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACjC,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source abstraction types for unified CDP and Extension modes.
|
|
3
|
+
* Both sources implement the same interface, allowing the watcher
|
|
4
|
+
* to work with either CDP WebSocket or Extension Native Messaging.
|
|
5
|
+
*/
|
|
6
|
+
import type { LogEvent } from '@vforsh/argus-core';
|
|
7
|
+
import type { CdpSessionHandle } from '../cdp/connection.js';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a CDP target (either from Chrome /json or extension tabs).
|
|
10
|
+
*/
|
|
11
|
+
export type CdpSourceTarget = {
|
|
12
|
+
/** Target/tab ID (string for CDP, number for extension). */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Page title. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** Page URL. */
|
|
17
|
+
url: string;
|
|
18
|
+
/** Target type (e.g., 'page', 'iframe'). */
|
|
19
|
+
type?: string;
|
|
20
|
+
/** Parent target ID for nested targets. */
|
|
21
|
+
parentId?: string | null;
|
|
22
|
+
/** Favicon URL (extension mode only). */
|
|
23
|
+
faviconUrl?: string;
|
|
24
|
+
/** Whether the target is currently attached. */
|
|
25
|
+
attached?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* CDP attachment status.
|
|
29
|
+
*/
|
|
30
|
+
export type CdpSourceStatus = {
|
|
31
|
+
attached: boolean;
|
|
32
|
+
target: {
|
|
33
|
+
title: string | null;
|
|
34
|
+
url: string | null;
|
|
35
|
+
type: string | null;
|
|
36
|
+
parentId: string | null;
|
|
37
|
+
} | null;
|
|
38
|
+
/** Best-effort reason for detachment. Null when attached. */
|
|
39
|
+
reason?: string | null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Events emitted by a CDP source.
|
|
43
|
+
*/
|
|
44
|
+
export type CdpSourceEvents = {
|
|
45
|
+
/** Called when a log event is captured. */
|
|
46
|
+
onLog: (event: Omit<LogEvent, 'id'>) => void;
|
|
47
|
+
/** Called when CDP status changes (attached/detached). */
|
|
48
|
+
onStatus: (status: CdpSourceStatus) => void;
|
|
49
|
+
/** Called when a session is attached to a target. */
|
|
50
|
+
onAttach?: (session: CdpSessionHandle, target: CdpSourceTarget) => Promise<void> | void;
|
|
51
|
+
/** Called when a session is detached from a target. */
|
|
52
|
+
onDetach?: (reason: string) => void;
|
|
53
|
+
/** Called on page navigation (for file log rotation). */
|
|
54
|
+
onPageNavigation?: (info: {
|
|
55
|
+
url: string;
|
|
56
|
+
title: string | null;
|
|
57
|
+
}) => void;
|
|
58
|
+
/** Called when the page DOM is ready after navigation. */
|
|
59
|
+
onPageLoad?: () => void;
|
|
60
|
+
/** Called when page intl info is available. */
|
|
61
|
+
onPageIntl?: (info: {
|
|
62
|
+
timezone: string | null;
|
|
63
|
+
locale: string | null;
|
|
64
|
+
}) => void;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Handle for a running CDP source.
|
|
68
|
+
*/
|
|
69
|
+
export type CdpSourceHandle = {
|
|
70
|
+
/** The CDP session handle for sending commands and subscribing to events. */
|
|
71
|
+
session: CdpSessionHandle;
|
|
72
|
+
/** Stop the source and clean up resources. */
|
|
73
|
+
stop: () => Promise<void>;
|
|
74
|
+
/** List available targets (extension mode only). */
|
|
75
|
+
listTargets?: () => Promise<CdpSourceTarget[]>;
|
|
76
|
+
/** Attach to a specific target by ID (extension mode only). */
|
|
77
|
+
attachTarget?: (targetId: number) => void;
|
|
78
|
+
/** Detach from a specific target by ID (extension mode only). */
|
|
79
|
+
detachTarget?: (targetId: number) => void;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Options common to all CDP sources.
|
|
83
|
+
*/
|
|
84
|
+
export type CdpSourceBaseOptions = {
|
|
85
|
+
/** Event handlers for the source. */
|
|
86
|
+
events: CdpSourceEvents;
|
|
87
|
+
/** Optional ignore list filtering for log/exception locations. */
|
|
88
|
+
ignoreMatcher?: ((url: string) => boolean) | null;
|
|
89
|
+
/** Strip these literal prefixes from event.file for display/logging. */
|
|
90
|
+
stripUrlPrefixes?: string[];
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=types.d.ts.map
|