@xbrowser/cli 1.34.0 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{browser-GXL6V2JW.js → browser-KY7AIRAB.js} +3 -2
- package/dist/{browser-ZWEJ663M.js → browser-MLKP72XP.js} +3 -3
- package/dist/{browser-X7LO42UI.js → browser-RZ7DPBI3.js} +3 -3
- package/dist/cdp-driver-CCG3OJUQ.js +49 -0
- package/dist/{cdp-driver-GCFEMRFJ.js → cdp-driver-HBMCD7NU.js} +2 -2
- package/dist/{cdp-driver-QOUSRPR2.js → cdp-driver-MJD7YIQI.js} +2 -2
- package/dist/{cdp-driver-4MNHDU2J.js → cdp-driver-YJU4GRSV.js} +196 -95
- package/dist/chunk-3SZTCI33.js +147 -0
- package/dist/{chunk-DZ6XEPAH.js → chunk-43U5VDLB.js} +8 -2
- package/dist/chunk-53VZHESL.js +150 -0
- package/dist/{chunk-NAIHOVDZ.js → chunk-63526WET.js} +2 -8
- package/dist/{chunk-YIL44YDX.js → chunk-6DS3T6UK.js} +196 -95
- package/dist/{chunk-N7DFS4V7.js → chunk-BLCBCESM.js} +8 -2
- package/dist/{chunk-SH6OTPXN.js → chunk-C5ZPXPD7.js} +31 -7
- package/dist/chunk-EGOWDZXP.js +149 -0
- package/dist/chunk-GNLZWHSP.js +1380 -0
- package/dist/{chunk-3E6VVMK2.js → chunk-GYGVHWG3.js} +272 -1460
- package/dist/{chunk-2KPI5GKP.js → chunk-IYCB2KJL.js} +2 -8
- package/dist/chunk-JYYKMSFH.js +39 -0
- package/dist/{chunk-TBJUSUKF.js → chunk-NBT2CE3H.js} +140 -96
- package/dist/{chunk-J4NOL5XX.js → chunk-QRFM4NOV.js} +1025 -202
- package/dist/chunk-RGL2YTWQ.js +64 -0
- package/dist/{chunk-BND5O5KC.js → chunk-SQLICOPZ.js} +177 -240
- package/dist/{chunk-O5PASNI7.js → chunk-UUW5EGES.js} +139 -237
- package/dist/{chunk-43TEMG4U.js → chunk-WGS3Y6ZV.js} +3 -1
- package/dist/{chunk-R57Z5KZX.js → chunk-Y2GRCINH.js} +1004 -183
- package/dist/{chunk-R7AG7ONI.js → chunk-ZCZELQCS.js} +196 -95
- package/dist/cli.js +2237 -278
- package/dist/{daemon-client-7D6EZNOE.js → daemon-client-OXKRGLPQ.js} +32 -8
- package/dist/{daemon-client-HEGAXWGK.js → daemon-client-Z3NKNZRL.js} +5 -1
- package/dist/daemon-main.js +2214 -159
- package/dist/human-interaction-BGAZC3JR.js +12 -0
- package/dist/human-interaction-TPKPEE7A.js +11 -0
- package/dist/human-interaction-ZSD3IX6Q.js +12 -0
- package/dist/index.d.ts +225 -94
- package/dist/index.js +2880 -267
- package/dist/{launcher-TOLF23ET.js → launcher-AUJK5QQM.js} +1 -1
- package/dist/{launcher-ZYB32LSZ.js → launcher-QBAZ6F5L.js} +1 -1
- package/dist/mistake-ledger-2B4N54CO.js +29 -0
- package/dist/{recovery-ORHJSBDN.js → recovery-5AGY7CV3.js} +4 -5
- package/dist/{recovery-JFGV3DBX.js → recovery-7NRRHLS4.js} +4 -4
- package/dist/{recovery-XDKN63O5.js → recovery-TIBRFGRP.js} +4 -4
- package/dist/run-routes-SJKVZ34L.js +26 -0
- package/dist/run-routes-TFNV5BBR.js +24 -0
- package/dist/{server-5U56MQD2.js → server-HUSX7EFE.js} +5 -4
- package/dist/{server-R4OYD7ZC.js → server-KSP5H4HD.js} +5 -3
- package/dist/{session-replayer-GHEFFNGV.js → session-replayer-4TCLQI76.js} +1 -1
- package/dist/viewer-routes-YOS5GTCV.js +11 -0
- package/package.json +1 -1
- package/dist/chunk-QCV2PI7U.js +0 -184
- package/dist/human-interaction-ISMMOJOK.js +0 -8
- package/dist/human-interaction-STTZZZ5N.js +0 -8
- package/dist/human-interaction-UXFYV7DU.js +0 -8
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MISTAKE_LEDGER_PATH,
|
|
3
|
+
MISTAKE_THRESHOLD,
|
|
4
|
+
clearMistakes,
|
|
5
|
+
constrainedMistakes,
|
|
6
|
+
isConstrainedMistake,
|
|
7
|
+
listMistakes,
|
|
8
|
+
mistakeFingerprint,
|
|
9
|
+
normalizeMistakeText,
|
|
10
|
+
persistentMistakesPath,
|
|
11
|
+
readMistakeLedger,
|
|
12
|
+
recordMistake,
|
|
13
|
+
writeMistakeLedger
|
|
14
|
+
} from "./chunk-3SZTCI33.js";
|
|
15
|
+
import "./chunk-KFQGP6VL.js";
|
|
16
|
+
export {
|
|
17
|
+
MISTAKE_LEDGER_PATH,
|
|
18
|
+
MISTAKE_THRESHOLD,
|
|
19
|
+
clearMistakes,
|
|
20
|
+
constrainedMistakes,
|
|
21
|
+
isConstrainedMistake,
|
|
22
|
+
listMistakes,
|
|
23
|
+
mistakeFingerprint,
|
|
24
|
+
normalizeMistakeText,
|
|
25
|
+
persistentMistakesPath,
|
|
26
|
+
readMistakeLedger,
|
|
27
|
+
recordMistake,
|
|
28
|
+
writeMistakeLedger
|
|
29
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HumanInteractionManager
|
|
3
|
-
} from "./chunk-TBJUSUKF.js";
|
|
4
1
|
import {
|
|
5
2
|
buildViewerUrl
|
|
6
3
|
} from "./chunk-TZPKFUBT.js";
|
|
7
|
-
import
|
|
4
|
+
import {
|
|
5
|
+
HumanInteractionManager
|
|
6
|
+
} from "./chunk-SQLICOPZ.js";
|
|
8
7
|
import "./chunk-CG3D3CHY.js";
|
|
9
8
|
import "./chunk-KFQGP6VL.js";
|
|
10
9
|
|
|
@@ -26,7 +25,7 @@ async function attemptRecovery(page, sessionName, commandName, errorMessage, pre
|
|
|
26
25
|
if (previewWS) {
|
|
27
26
|
try {
|
|
28
27
|
previewWS.registerSession(sessionName, page);
|
|
29
|
-
const manager = new HumanInteractionManager(previewWS, page);
|
|
28
|
+
const manager = new HumanInteractionManager(previewWS, page, sessionName);
|
|
30
29
|
const result = await manager.waitForHuman({
|
|
31
30
|
reason: `Command "${commandName}" failed: ${errorMessage}. Fix the issue and confirm via viewer.`,
|
|
32
31
|
timeout: cfg.timeout,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HumanInteractionManager
|
|
3
|
-
} from "./chunk-BND5O5KC.js";
|
|
4
1
|
import {
|
|
5
2
|
buildViewerUrl
|
|
6
3
|
} from "./chunk-3OD76SUE.js";
|
|
4
|
+
import {
|
|
5
|
+
HumanInteractionManager
|
|
6
|
+
} from "./chunk-UUW5EGES.js";
|
|
7
7
|
import "./chunk-ZTHE5RBZ.js";
|
|
8
8
|
import "./chunk-Q2DFJQGS.js";
|
|
9
9
|
import "./chunk-KFQGP6VL.js";
|
|
@@ -26,7 +26,7 @@ async function attemptRecovery(page, sessionName, commandName, errorMessage, pre
|
|
|
26
26
|
if (previewWS) {
|
|
27
27
|
try {
|
|
28
28
|
previewWS.registerSession(sessionName, page);
|
|
29
|
-
const manager = new HumanInteractionManager(previewWS, page);
|
|
29
|
+
const manager = new HumanInteractionManager(previewWS, page, sessionName);
|
|
30
30
|
const result = await manager.waitForHuman({
|
|
31
31
|
reason: `Command "${commandName}" failed: ${errorMessage}. Fix the issue and confirm via viewer.`,
|
|
32
32
|
timeout: cfg.timeout,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HumanInteractionManager
|
|
3
|
+
} from "./chunk-NBT2CE3H.js";
|
|
1
4
|
import {
|
|
2
5
|
buildViewerUrl
|
|
3
6
|
} from "./chunk-3OD76SUE.js";
|
|
4
|
-
import {
|
|
5
|
-
HumanInteractionManager
|
|
6
|
-
} from "./chunk-O5PASNI7.js";
|
|
7
7
|
import "./chunk-ZTHE5RBZ.js";
|
|
8
8
|
import "./chunk-Q2DFJQGS.js";
|
|
9
9
|
import "./chunk-KFQGP6VL.js";
|
|
@@ -26,7 +26,7 @@ async function attemptRecovery(page, sessionName, commandName, errorMessage, pre
|
|
|
26
26
|
if (previewWS) {
|
|
27
27
|
try {
|
|
28
28
|
previewWS.registerSession(sessionName, page);
|
|
29
|
-
const manager = new HumanInteractionManager(previewWS, page);
|
|
29
|
+
const manager = new HumanInteractionManager(previewWS, page, sessionName);
|
|
30
30
|
const result = await manager.waitForHuman({
|
|
31
31
|
reason: `Command "${commandName}" failed: ${errorMessage}. Fix the issue and confirm via viewer.`,
|
|
32
32
|
timeout: cfg.timeout,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleManagedRunFile,
|
|
3
|
+
handleRun,
|
|
4
|
+
runNamedJobs
|
|
5
|
+
} from "./chunk-53VZHESL.js";
|
|
6
|
+
import "./chunk-RGL2YTWQ.js";
|
|
7
|
+
import "./chunk-Y2GRCINH.js";
|
|
8
|
+
import "./chunk-BLCBCESM.js";
|
|
9
|
+
import "./chunk-JKVUFP3G.js";
|
|
10
|
+
import "./chunk-3SZTCI33.js";
|
|
11
|
+
import "./chunk-C5ZPXPD7.js";
|
|
12
|
+
import "./chunk-3OD76SUE.js";
|
|
13
|
+
import "./chunk-ZTHE5RBZ.js";
|
|
14
|
+
import "./chunk-Q2DFJQGS.js";
|
|
15
|
+
import "./chunk-6DS3T6UK.js";
|
|
16
|
+
import "./chunk-SMYSNO4M.js";
|
|
17
|
+
import "./chunk-IYCB2KJL.js";
|
|
18
|
+
import "./chunk-GDKLH7ZY.js";
|
|
19
|
+
import "./chunk-NEE6EMYA.js";
|
|
20
|
+
import "./chunk-6UJU2FJK.js";
|
|
21
|
+
import "./chunk-KFQGP6VL.js";
|
|
22
|
+
export {
|
|
23
|
+
handleManagedRunFile,
|
|
24
|
+
handleRun,
|
|
25
|
+
runNamedJobs
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleManagedRunFile,
|
|
3
|
+
handleRun,
|
|
4
|
+
runNamedJobs
|
|
5
|
+
} from "./chunk-EGOWDZXP.js";
|
|
6
|
+
import "./chunk-QRFM4NOV.js";
|
|
7
|
+
import "./chunk-GNLZWHSP.js";
|
|
8
|
+
import "./chunk-JKVUFP3G.js";
|
|
9
|
+
import "./chunk-3SZTCI33.js";
|
|
10
|
+
import "./chunk-3OD76SUE.js";
|
|
11
|
+
import "./chunk-ZTHE5RBZ.js";
|
|
12
|
+
import "./chunk-RGL2YTWQ.js";
|
|
13
|
+
import "./chunk-C5ZPXPD7.js";
|
|
14
|
+
import "./chunk-Q2DFJQGS.js";
|
|
15
|
+
import "./chunk-GYGVHWG3.js";
|
|
16
|
+
import "./chunk-SMYSNO4M.js";
|
|
17
|
+
import "./chunk-IYCB2KJL.js";
|
|
18
|
+
import "./chunk-GDKLH7ZY.js";
|
|
19
|
+
import "./chunk-KFQGP6VL.js";
|
|
20
|
+
export {
|
|
21
|
+
handleManagedRunFile,
|
|
22
|
+
handleRun,
|
|
23
|
+
runNamedJobs
|
|
24
|
+
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeChain,
|
|
3
3
|
executeCommand
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-Y2GRCINH.js";
|
|
5
|
+
import "./chunk-BLCBCESM.js";
|
|
6
6
|
import "./chunk-JKVUFP3G.js";
|
|
7
|
+
import "./chunk-3SZTCI33.js";
|
|
7
8
|
import "./chunk-3OD76SUE.js";
|
|
8
9
|
import "./chunk-ZTHE5RBZ.js";
|
|
9
10
|
import "./chunk-Q2DFJQGS.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-6DS3T6UK.js";
|
|
11
12
|
import "./chunk-SMYSNO4M.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-IYCB2KJL.js";
|
|
13
14
|
import "./chunk-GDKLH7ZY.js";
|
|
14
15
|
import "./chunk-NEE6EMYA.js";
|
|
15
16
|
import "./chunk-6UJU2FJK.js";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeChain,
|
|
3
3
|
executeCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QRFM4NOV.js";
|
|
5
|
+
import "./chunk-GNLZWHSP.js";
|
|
5
6
|
import "./chunk-JKVUFP3G.js";
|
|
7
|
+
import "./chunk-3SZTCI33.js";
|
|
6
8
|
import "./chunk-3OD76SUE.js";
|
|
7
9
|
import "./chunk-ZTHE5RBZ.js";
|
|
8
10
|
import "./chunk-Q2DFJQGS.js";
|
|
9
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GYGVHWG3.js";
|
|
10
12
|
import "./chunk-SMYSNO4M.js";
|
|
11
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-IYCB2KJL.js";
|
|
12
14
|
import "./chunk-GDKLH7ZY.js";
|
|
13
15
|
import "./chunk-KFQGP6VL.js";
|
|
14
16
|
|
|
@@ -142,7 +142,7 @@ var SessionReplayer = class {
|
|
|
142
142
|
if (this.opts.page) {
|
|
143
143
|
this.page = this.opts.page;
|
|
144
144
|
} else if (this.opts.cdpUrl) {
|
|
145
|
-
const { launch } = await import("./cdp-driver-
|
|
145
|
+
const { launch } = await import("./cdp-driver-HBMCD7NU.js");
|
|
146
146
|
const { browser } = await launch({ cdpEndpoint: this.opts.cdpUrl });
|
|
147
147
|
let contexts = browser.contexts();
|
|
148
148
|
for (let i = 0; i < 10 && contexts.length === 0; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/dist/chunk-QCV2PI7U.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
// src/config.ts
|
|
2
|
-
import { homedir, tmpdir } from "os";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { loadConfig as coreLoadConfig, saveConfig as coreSaveConfig } from "@dyyz1993/xcli-core";
|
|
5
|
-
function getConfigSource() {
|
|
6
|
-
return { configDir: join(homedir() || tmpdir(), ".xbrowser") };
|
|
7
|
-
}
|
|
8
|
-
function loadConfig() {
|
|
9
|
-
return coreLoadConfig(getConfigSource());
|
|
10
|
-
}
|
|
11
|
-
function getConfigValue(key) {
|
|
12
|
-
const parts = key.split(".");
|
|
13
|
-
let obj = loadConfig();
|
|
14
|
-
for (const part of parts) {
|
|
15
|
-
if (obj && typeof obj === "object") {
|
|
16
|
-
obj = obj[part];
|
|
17
|
-
} else {
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return obj;
|
|
22
|
-
}
|
|
23
|
-
function getCaptchaConfig() {
|
|
24
|
-
const config = loadConfig();
|
|
25
|
-
return {
|
|
26
|
-
notifyUrl: process.env.XBROWSER_NOTIFY_URL || config.captcha?.notifyUrl,
|
|
27
|
-
autoOpen: process.env.XBROWSER_AUTO_OPEN === "true" || config.captcha?.autoOpen === true,
|
|
28
|
-
timeout: parseInt(process.env.XBROWSER_CAPTCHA_TIMEOUT || "") || config.captcha?.timeout || 120,
|
|
29
|
-
previewPort: parseInt(process.env.XBROWSER_PREVIEW_PORT || "") || config.preview?.port || 9223
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function resolveScreenshotsDir() {
|
|
33
|
-
const configured = getConfigValue("screenshots.dir");
|
|
34
|
-
if (typeof configured === "string" && configured.trim()) return configured.trim();
|
|
35
|
-
return join(tmpdir(), "xbrowser", "screenshots");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// src/screencast.ts
|
|
39
|
-
var ScreencastCapturer = class {
|
|
40
|
-
interval;
|
|
41
|
-
quality;
|
|
42
|
-
type;
|
|
43
|
-
maxWidth;
|
|
44
|
-
maxHeight;
|
|
45
|
-
isCapturing = false;
|
|
46
|
-
frameCallback = null;
|
|
47
|
-
// CDP Cast state
|
|
48
|
-
cdpSession = null;
|
|
49
|
-
sessionId = "";
|
|
50
|
-
// Fallback polling state
|
|
51
|
-
fallbackTimer = null;
|
|
52
|
-
constructor(options = {}) {
|
|
53
|
-
this.interval = options.interval || 100;
|
|
54
|
-
this.quality = options.quality || 60;
|
|
55
|
-
this.type = options.type || "jpeg";
|
|
56
|
-
this.maxWidth = options.width || 1920;
|
|
57
|
-
this.maxHeight = options.height || 1080;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Start screencast capture using CDP Page.startScreencast.
|
|
61
|
-
*
|
|
62
|
-
* If CDP session creation fails (non-Chromium, restricted access),
|
|
63
|
-
* automatically falls back to `page.screenshot()` polling.
|
|
64
|
-
*/
|
|
65
|
-
async startCapture(page, sessionId, onFrame) {
|
|
66
|
-
if (this.isCapturing) {
|
|
67
|
-
throw new Error("Screencast is already capturing");
|
|
68
|
-
}
|
|
69
|
-
this.isCapturing = true;
|
|
70
|
-
this.frameCallback = onFrame;
|
|
71
|
-
this.sessionId = sessionId;
|
|
72
|
-
try {
|
|
73
|
-
const cdp = await page.context().newCDPSession(page);
|
|
74
|
-
this.cdpSession = cdp;
|
|
75
|
-
cdp.on("Page.screencastFrame", async (params) => {
|
|
76
|
-
const cb = this.frameCallback;
|
|
77
|
-
if (!cb) return;
|
|
78
|
-
cdp.send("Page.screencastFrameAck", { sessionId: params.sessionId }).catch(() => {
|
|
79
|
-
});
|
|
80
|
-
const logicalViewport = page.viewportSize();
|
|
81
|
-
const viewport = logicalViewport ?? {
|
|
82
|
-
width: params.metadata?.deviceWidth || this.maxWidth,
|
|
83
|
-
height: params.metadata?.deviceHeight || this.maxHeight
|
|
84
|
-
};
|
|
85
|
-
cb({
|
|
86
|
-
id: crypto.randomUUID(),
|
|
87
|
-
sessionId: this.sessionId,
|
|
88
|
-
timestamp: Date.now(),
|
|
89
|
-
data: Buffer.from(params.data, "base64"),
|
|
90
|
-
url: page.url(),
|
|
91
|
-
viewport
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
await cdp.send("Page.startScreencast", {
|
|
95
|
-
format: this.type === "png" ? "png" : "jpeg",
|
|
96
|
-
quality: this.type === "jpeg" ? this.quality : void 0,
|
|
97
|
-
maxWidth: this.maxWidth,
|
|
98
|
-
maxHeight: this.maxHeight
|
|
99
|
-
});
|
|
100
|
-
} catch {
|
|
101
|
-
this.cdpSession = null;
|
|
102
|
-
this.startFallbackPolling(page, sessionId);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Fallback: periodic page.screenshot() polling when CDP Cast is unavailable.
|
|
107
|
-
*/
|
|
108
|
-
startFallbackPolling(page, sessionId) {
|
|
109
|
-
const captureLoop = async () => {
|
|
110
|
-
if (!this.frameCallback) return;
|
|
111
|
-
try {
|
|
112
|
-
const frame = await this.captureFrame(page, sessionId);
|
|
113
|
-
this.frameCallback(frame);
|
|
114
|
-
} catch {
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
captureLoop();
|
|
118
|
-
this.fallbackTimer = setInterval(captureLoop, this.interval);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Capture a single screenshot frame from the page (fallback mode).
|
|
122
|
-
*/
|
|
123
|
-
async captureFrame(page, sessionId) {
|
|
124
|
-
let viewport = page.viewportSize();
|
|
125
|
-
if (!viewport) {
|
|
126
|
-
try {
|
|
127
|
-
viewport = await page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight }));
|
|
128
|
-
} catch {
|
|
129
|
-
viewport = { width: 1920, height: 1080 };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const screenshot = await page.screenshot({
|
|
133
|
-
type: this.type,
|
|
134
|
-
quality: this.type === "jpeg" ? this.quality : void 0
|
|
135
|
-
});
|
|
136
|
-
return {
|
|
137
|
-
id: crypto.randomUUID(),
|
|
138
|
-
sessionId,
|
|
139
|
-
timestamp: Date.now(),
|
|
140
|
-
data: screenshot,
|
|
141
|
-
url: page.url(),
|
|
142
|
-
viewport: viewport || { width: 0, height: 0 }
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Stop the current screencast capture.
|
|
147
|
-
*/
|
|
148
|
-
async stopCapture() {
|
|
149
|
-
if (this.cdpSession) {
|
|
150
|
-
try {
|
|
151
|
-
this.cdpSession.off("Page.screencastFrame", () => {
|
|
152
|
-
});
|
|
153
|
-
await this.cdpSession.send("Page.stopScreencast");
|
|
154
|
-
} catch {
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
await this.cdpSession.detach();
|
|
158
|
-
} catch {
|
|
159
|
-
}
|
|
160
|
-
this.cdpSession = null;
|
|
161
|
-
}
|
|
162
|
-
if (this.fallbackTimer) {
|
|
163
|
-
clearInterval(this.fallbackTimer);
|
|
164
|
-
this.fallbackTimer = null;
|
|
165
|
-
}
|
|
166
|
-
this.isCapturing = false;
|
|
167
|
-
this.frameCallback = null;
|
|
168
|
-
}
|
|
169
|
-
isActive() {
|
|
170
|
-
return this.isCapturing;
|
|
171
|
-
}
|
|
172
|
-
setInterval(interval) {
|
|
173
|
-
this.interval = interval;
|
|
174
|
-
}
|
|
175
|
-
setQuality(quality) {
|
|
176
|
-
this.quality = quality;
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export {
|
|
181
|
-
getCaptchaConfig,
|
|
182
|
-
resolveScreenshotsDir,
|
|
183
|
-
ScreencastCapturer
|
|
184
|
-
};
|