@ceki/sdk 1.11.2 → 1.13.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/README.md +26 -9
- package/dist/cli.js +60 -46
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +31 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +31 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -242,14 +242,23 @@ declare class Browser {
|
|
|
242
242
|
method: string;
|
|
243
243
|
params?: Record<string, unknown>;
|
|
244
244
|
}, timeout?: number): Promise<unknown>;
|
|
245
|
-
|
|
245
|
+
private _humanizeForCall;
|
|
246
|
+
navigate(url: string, timeout?: number, opts?: {
|
|
247
|
+
human?: boolean;
|
|
248
|
+
}): Promise<{
|
|
246
249
|
url: string;
|
|
247
250
|
frameId?: string;
|
|
248
251
|
}>;
|
|
249
|
-
click(x: number, y: number
|
|
252
|
+
click(x: number, y: number, opts?: {
|
|
253
|
+
human?: boolean;
|
|
254
|
+
}): Promise<void>;
|
|
250
255
|
private _sendKeystroke;
|
|
251
|
-
type(text: string
|
|
252
|
-
|
|
256
|
+
type(text: string, opts?: {
|
|
257
|
+
human?: boolean;
|
|
258
|
+
}): Promise<void>;
|
|
259
|
+
scroll(opts?: ScrollOptions & {
|
|
260
|
+
human?: boolean;
|
|
261
|
+
}): Promise<void>;
|
|
253
262
|
screenshot(opts?: ScreenshotOptions): Promise<{
|
|
254
263
|
data: string;
|
|
255
264
|
} | Buffer>;
|
package/dist/index.d.ts
CHANGED
|
@@ -242,14 +242,23 @@ declare class Browser {
|
|
|
242
242
|
method: string;
|
|
243
243
|
params?: Record<string, unknown>;
|
|
244
244
|
}, timeout?: number): Promise<unknown>;
|
|
245
|
-
|
|
245
|
+
private _humanizeForCall;
|
|
246
|
+
navigate(url: string, timeout?: number, opts?: {
|
|
247
|
+
human?: boolean;
|
|
248
|
+
}): Promise<{
|
|
246
249
|
url: string;
|
|
247
250
|
frameId?: string;
|
|
248
251
|
}>;
|
|
249
|
-
click(x: number, y: number
|
|
252
|
+
click(x: number, y: number, opts?: {
|
|
253
|
+
human?: boolean;
|
|
254
|
+
}): Promise<void>;
|
|
250
255
|
private _sendKeystroke;
|
|
251
|
-
type(text: string
|
|
252
|
-
|
|
256
|
+
type(text: string, opts?: {
|
|
257
|
+
human?: boolean;
|
|
258
|
+
}): Promise<void>;
|
|
259
|
+
scroll(opts?: ScrollOptions & {
|
|
260
|
+
human?: boolean;
|
|
261
|
+
}): Promise<void>;
|
|
253
262
|
screenshot(opts?: ScreenshotOptions): Promise<{
|
|
254
263
|
data: string;
|
|
255
264
|
} | Buffer>;
|
package/dist/index.js
CHANGED
|
@@ -655,27 +655,39 @@ var Browser = class _Browser {
|
|
|
655
655
|
this._sendRaw(msg);
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
// task 427 — per-call kill-switch. human=false bypasses humanizer timings
|
|
659
|
+
// AND tells the extension to skip mouse-jitter via the `_ceki_raw` marker
|
|
660
|
+
// (see cdp.ts). human=true forces humanizer; human undefined = session
|
|
661
|
+
// default. Global env CEKI_HUMAN_DISABLE=1 nulls this._humanizer in the
|
|
662
|
+
// constructor so all paths become raw.
|
|
663
|
+
_humanizeForCall(human) {
|
|
664
|
+
if (human === false) return null;
|
|
665
|
+
return this._humanizer;
|
|
666
|
+
}
|
|
667
|
+
async navigate(url, timeout = 3e4, opts) {
|
|
668
|
+
const h = this._humanizeForCall(opts?.human);
|
|
669
|
+
if (h) await h.before("navigate");
|
|
660
670
|
const result = await this.send({ method: "Page.navigate", params: { url } }, timeout);
|
|
661
|
-
if (
|
|
671
|
+
if (h) await h.after("navigate");
|
|
662
672
|
return {
|
|
663
673
|
url: String(result?.url ?? url),
|
|
664
674
|
frameId: result?.frameId ? String(result.frameId) : void 0
|
|
665
675
|
};
|
|
666
676
|
}
|
|
667
|
-
async click(x, y) {
|
|
668
|
-
|
|
677
|
+
async click(x, y, opts) {
|
|
678
|
+
const h = this._humanizeForCall(opts?.human);
|
|
679
|
+
if (h) await h.before("click");
|
|
680
|
+
const rawFlag = h === null ? { _ceki_raw: true } : {};
|
|
669
681
|
await this.send({
|
|
670
682
|
method: "Input.dispatchMouseEvent",
|
|
671
|
-
params: { type: "mousePressed", x, y, button: "left", clickCount: 1 }
|
|
683
|
+
params: { type: "mousePressed", x, y, button: "left", clickCount: 1, ...rawFlag }
|
|
672
684
|
});
|
|
673
685
|
await this.send({
|
|
674
686
|
method: "Input.dispatchMouseEvent",
|
|
675
687
|
params: { type: "mouseReleased", x, y, button: "left", clickCount: 1 }
|
|
676
688
|
});
|
|
677
689
|
this._lastPointer = [x, y];
|
|
678
|
-
if (
|
|
690
|
+
if (h) await h.after("click");
|
|
679
691
|
}
|
|
680
692
|
async _sendKeystroke(char) {
|
|
681
693
|
const mapping = keymapForChar(char);
|
|
@@ -721,9 +733,10 @@ var Browser = class _Browser {
|
|
|
721
733
|
});
|
|
722
734
|
}
|
|
723
735
|
}
|
|
724
|
-
async type(text) {
|
|
725
|
-
|
|
726
|
-
|
|
736
|
+
async type(text, opts) {
|
|
737
|
+
const h = this._humanizeForCall(opts?.human);
|
|
738
|
+
if (h) {
|
|
739
|
+
await h.before("type");
|
|
727
740
|
if (this._lastPointer) {
|
|
728
741
|
const [px, py] = this._lastPointer;
|
|
729
742
|
await this.send({
|
|
@@ -735,18 +748,11 @@ var Browser = class _Browser {
|
|
|
735
748
|
params: { type: "mouseReleased", x: px, y: py, button: "left", clickCount: 1 }
|
|
736
749
|
});
|
|
737
750
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
await this._humanizer.after("type");
|
|
746
|
-
} else {
|
|
747
|
-
for (const char of text) {
|
|
748
|
-
await this._sendKeystroke(char);
|
|
749
|
-
}
|
|
751
|
+
}
|
|
752
|
+
const human = h ? ["natural", "careful"].includes(h.profile.name) ? h.profile.name : "natural" : null;
|
|
753
|
+
await this.send({ method: "Ceki.typeText", params: { text, human } });
|
|
754
|
+
if (h) {
|
|
755
|
+
await h.after("type");
|
|
750
756
|
}
|
|
751
757
|
}
|
|
752
758
|
async scroll(opts) {
|
|
@@ -754,13 +760,14 @@ var Browser = class _Browser {
|
|
|
754
760
|
const y = opts?.y ?? 0;
|
|
755
761
|
const deltaX = opts?.deltaX ?? 0;
|
|
756
762
|
const deltaY = opts?.deltaY ?? -300;
|
|
757
|
-
|
|
763
|
+
const h = this._humanizeForCall(opts?.human);
|
|
764
|
+
if (h) await h.before("scroll");
|
|
758
765
|
await this.send({
|
|
759
766
|
method: "Input.dispatchMouseEvent",
|
|
760
767
|
params: { type: "mouseWheel", x, y, deltaX, deltaY }
|
|
761
768
|
});
|
|
762
769
|
this._lastPointer = [x, y];
|
|
763
|
-
if (
|
|
770
|
+
if (h) await h.after("scroll");
|
|
764
771
|
}
|
|
765
772
|
async screenshot(opts) {
|
|
766
773
|
const format = opts?.format ?? "base64";
|