browserclaw 0.9.3 → 0.9.5
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/index.cjs +61 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +61 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -717,6 +717,25 @@ declare class CrawlPage {
|
|
|
717
717
|
clickCount?: number;
|
|
718
718
|
delayMs?: number;
|
|
719
719
|
}): Promise<void>;
|
|
720
|
+
/**
|
|
721
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
722
|
+
*
|
|
723
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
724
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
725
|
+
* that detect automated clicks.
|
|
726
|
+
*
|
|
727
|
+
* @param x - X coordinate in CSS pixels
|
|
728
|
+
* @param y - Y coordinate in CSS pixels
|
|
729
|
+
* @param opts - Options (holdMs: hold duration, default 1000, max 30000)
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* ```ts
|
|
733
|
+
* await page.pressAndHold(400, 300, { holdMs: 5000 });
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
736
|
+
pressAndHold(x: number, y: number, opts?: {
|
|
737
|
+
holdMs?: number;
|
|
738
|
+
}): Promise<void>;
|
|
720
739
|
/**
|
|
721
740
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
722
741
|
*
|
|
@@ -1717,6 +1736,14 @@ declare function getRestoredPageForTarget(opts: {
|
|
|
1717
1736
|
targetId?: string;
|
|
1718
1737
|
}): Promise<Page>;
|
|
1719
1738
|
|
|
1739
|
+
declare function pressAndHoldViaCdp(opts: {
|
|
1740
|
+
cdpUrl: string;
|
|
1741
|
+
targetId?: string;
|
|
1742
|
+
x: number;
|
|
1743
|
+
y: number;
|
|
1744
|
+
holdMs?: number;
|
|
1745
|
+
}): Promise<void>;
|
|
1746
|
+
|
|
1720
1747
|
/**
|
|
1721
1748
|
* Comprehensive browser stealth evasions.
|
|
1722
1749
|
*
|
|
@@ -1755,4 +1782,4 @@ declare function waitForChallengeViaPlaywright(opts: {
|
|
|
1755
1782
|
pollMs?: number;
|
|
1756
1783
|
}): Promise<ChallengeWaitResult>;
|
|
1757
1784
|
|
|
1758
|
-
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
1785
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, pressAndHoldViaCdp, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -717,6 +717,25 @@ declare class CrawlPage {
|
|
|
717
717
|
clickCount?: number;
|
|
718
718
|
delayMs?: number;
|
|
719
719
|
}): Promise<void>;
|
|
720
|
+
/**
|
|
721
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
722
|
+
*
|
|
723
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
724
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
725
|
+
* that detect automated clicks.
|
|
726
|
+
*
|
|
727
|
+
* @param x - X coordinate in CSS pixels
|
|
728
|
+
* @param y - Y coordinate in CSS pixels
|
|
729
|
+
* @param opts - Options (holdMs: hold duration, default 1000, max 30000)
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* ```ts
|
|
733
|
+
* await page.pressAndHold(400, 300, { holdMs: 5000 });
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
736
|
+
pressAndHold(x: number, y: number, opts?: {
|
|
737
|
+
holdMs?: number;
|
|
738
|
+
}): Promise<void>;
|
|
720
739
|
/**
|
|
721
740
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
722
741
|
*
|
|
@@ -1717,6 +1736,14 @@ declare function getRestoredPageForTarget(opts: {
|
|
|
1717
1736
|
targetId?: string;
|
|
1718
1737
|
}): Promise<Page>;
|
|
1719
1738
|
|
|
1739
|
+
declare function pressAndHoldViaCdp(opts: {
|
|
1740
|
+
cdpUrl: string;
|
|
1741
|
+
targetId?: string;
|
|
1742
|
+
x: number;
|
|
1743
|
+
y: number;
|
|
1744
|
+
holdMs?: number;
|
|
1745
|
+
}): Promise<void>;
|
|
1746
|
+
|
|
1720
1747
|
/**
|
|
1721
1748
|
* Comprehensive browser stealth evasions.
|
|
1722
1749
|
*
|
|
@@ -1755,4 +1782,4 @@ declare function waitForChallengeViaPlaywright(opts: {
|
|
|
1755
1782
|
pollMs?: number;
|
|
1756
1783
|
}): Promise<ChallengeWaitResult>;
|
|
1757
1784
|
|
|
1758
|
-
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
1785
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChallengeInfo, type ChallengeKind, type ChallengeWaitResult, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogEvent, type DialogHandler, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, STEALTH_SCRIPT, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, pressAndHoldViaCdp, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
package/dist/index.js
CHANGED
|
@@ -37,9 +37,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
mod
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// node_modules/ipaddr.js/lib/ipaddr.js
|
|
41
41
|
var require_ipaddr = __commonJS({
|
|
42
|
-
"
|
|
42
|
+
"node_modules/ipaddr.js/lib/ipaddr.js"(exports$1, module) {
|
|
43
43
|
(function(root) {
|
|
44
44
|
const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
|
|
45
45
|
const ipv4Regexes = {
|
|
@@ -1377,6 +1377,7 @@ async function launchChrome(opts = {}) {
|
|
|
1377
1377
|
const spawnChrome = () => {
|
|
1378
1378
|
const args = [
|
|
1379
1379
|
`--remote-debugging-port=${String(cdpPort)}`,
|
|
1380
|
+
"--remote-debugging-address=127.0.0.1",
|
|
1380
1381
|
`--user-data-dir=${userDataDir}`,
|
|
1381
1382
|
"--no-first-run",
|
|
1382
1383
|
"--no-default-browser-check",
|
|
@@ -1715,7 +1716,13 @@ function appendCdpPath2(cdpUrl, cdpPath) {
|
|
|
1715
1716
|
}
|
|
1716
1717
|
}
|
|
1717
1718
|
async function withPlaywrightPageCdpSession(page, fn) {
|
|
1718
|
-
const
|
|
1719
|
+
const CDP_SESSION_TIMEOUT_MS = 1e4;
|
|
1720
|
+
const session = await Promise.race([
|
|
1721
|
+
page.context().newCDPSession(page),
|
|
1722
|
+
new Promise(
|
|
1723
|
+
(_, reject) => setTimeout(() => reject(new Error("newCDPSession timed out after 10s")), CDP_SESSION_TIMEOUT_MS)
|
|
1724
|
+
)
|
|
1725
|
+
]);
|
|
1719
1726
|
try {
|
|
1720
1727
|
return await fn(session);
|
|
1721
1728
|
} finally {
|
|
@@ -3067,6 +3074,25 @@ async function mouseClickViaPlaywright(opts) {
|
|
|
3067
3074
|
delay: opts.delayMs
|
|
3068
3075
|
});
|
|
3069
3076
|
}
|
|
3077
|
+
var MAX_HOLD_MS = 3e4;
|
|
3078
|
+
async function pressAndHoldViaCdp(opts) {
|
|
3079
|
+
const holdMs = resolveBoundedDelayMs(opts.holdMs ?? 1e3, "holdMs", MAX_HOLD_MS);
|
|
3080
|
+
const page = await getPageForTargetId({ cdpUrl: opts.cdpUrl, targetId: opts.targetId });
|
|
3081
|
+
ensurePageState(page);
|
|
3082
|
+
const pos = { x: opts.x, y: opts.y };
|
|
3083
|
+
const btn = { button: "left", clickCount: 1 };
|
|
3084
|
+
await withPageScopedCdpClient({
|
|
3085
|
+
cdpUrl: opts.cdpUrl,
|
|
3086
|
+
page,
|
|
3087
|
+
targetId: opts.targetId,
|
|
3088
|
+
fn: async (send) => {
|
|
3089
|
+
await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...pos });
|
|
3090
|
+
await send("Input.dispatchMouseEvent", { type: "mousePressed", ...pos, ...btn });
|
|
3091
|
+
await new Promise((r) => setTimeout(r, holdMs));
|
|
3092
|
+
await send("Input.dispatchMouseEvent", { type: "mouseReleased", ...pos, ...btn });
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3070
3096
|
async function clickByTextViaPlaywright(opts) {
|
|
3071
3097
|
const page = await getRestoredPageForTarget(opts);
|
|
3072
3098
|
const timeout = resolveInteractionTimeoutMs(opts.timeoutMs);
|
|
@@ -3437,7 +3463,12 @@ async function closePageViaPlaywright(opts) {
|
|
|
3437
3463
|
await page.close();
|
|
3438
3464
|
}
|
|
3439
3465
|
async function closePageByTargetIdViaPlaywright(opts) {
|
|
3440
|
-
|
|
3466
|
+
try {
|
|
3467
|
+
await (await resolvePageByTargetIdOrThrow(opts)).close();
|
|
3468
|
+
} catch (err) {
|
|
3469
|
+
if (err instanceof BrowserTabNotFoundError) return;
|
|
3470
|
+
throw err;
|
|
3471
|
+
}
|
|
3441
3472
|
}
|
|
3442
3473
|
async function focusPageByTargetIdViaPlaywright(opts) {
|
|
3443
3474
|
const page = await resolvePageByTargetIdOrThrow(opts);
|
|
@@ -4915,6 +4946,31 @@ var CrawlPage = class {
|
|
|
4915
4946
|
delayMs: opts?.delayMs
|
|
4916
4947
|
});
|
|
4917
4948
|
}
|
|
4949
|
+
/**
|
|
4950
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
4951
|
+
*
|
|
4952
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
4953
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
4954
|
+
* that detect automated clicks.
|
|
4955
|
+
*
|
|
4956
|
+
* @param x - X coordinate in CSS pixels
|
|
4957
|
+
* @param y - Y coordinate in CSS pixels
|
|
4958
|
+
* @param opts - Options (holdMs: hold duration, default 1000, max 30000)
|
|
4959
|
+
*
|
|
4960
|
+
* @example
|
|
4961
|
+
* ```ts
|
|
4962
|
+
* await page.pressAndHold(400, 300, { holdMs: 5000 });
|
|
4963
|
+
* ```
|
|
4964
|
+
*/
|
|
4965
|
+
async pressAndHold(x, y, opts) {
|
|
4966
|
+
return pressAndHoldViaCdp({
|
|
4967
|
+
cdpUrl: this.cdpUrl,
|
|
4968
|
+
targetId: this.targetId,
|
|
4969
|
+
x,
|
|
4970
|
+
y,
|
|
4971
|
+
holdMs: opts?.holdMs
|
|
4972
|
+
});
|
|
4973
|
+
}
|
|
4918
4974
|
/**
|
|
4919
4975
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
4920
4976
|
*
|
|
@@ -6055,6 +6111,6 @@ var BrowserClaw = class _BrowserClaw {
|
|
|
6055
6111
|
}
|
|
6056
6112
|
};
|
|
6057
6113
|
|
|
6058
|
-
export { BrowserClaw, BrowserTabNotFoundError, CrawlPage, InvalidBrowserNavigationUrlError, STEALTH_SCRIPT, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
6114
|
+
export { BrowserClaw, BrowserTabNotFoundError, CrawlPage, InvalidBrowserNavigationUrlError, STEALTH_SCRIPT, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, detectChallengeViaPlaywright, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, pressAndHoldViaCdp, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, setDialogHandler, waitForChallengeViaPlaywright, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
|
6059
6115
|
//# sourceMappingURL=index.js.map
|
|
6060
6116
|
//# sourceMappingURL=index.js.map
|