@ceki/sdk 1.12.0 → 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/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
- navigate(url: string, timeout?: number): Promise<{
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): Promise<void>;
252
+ click(x: number, y: number, opts?: {
253
+ human?: boolean;
254
+ }): Promise<void>;
250
255
  private _sendKeystroke;
251
- type(text: string): Promise<void>;
252
- scroll(opts?: ScrollOptions): Promise<void>;
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
- navigate(url: string, timeout?: number): Promise<{
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): Promise<void>;
252
+ click(x: number, y: number, opts?: {
253
+ human?: boolean;
254
+ }): Promise<void>;
250
255
  private _sendKeystroke;
251
- type(text: string): Promise<void>;
252
- scroll(opts?: ScrollOptions): Promise<void>;
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
- async navigate(url, timeout = 3e4) {
659
- if (this._humanizer) await this._humanizer.before("navigate");
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 (this._humanizer) await this._humanizer.after("navigate");
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
- if (this._humanizer) await this._humanizer.before("click");
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 (this._humanizer) await this._humanizer.after("click");
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
- if (this._humanizer) {
726
- await this._humanizer.before("type");
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({
@@ -736,10 +749,10 @@ var Browser = class _Browser {
736
749
  });
737
750
  }
738
751
  }
739
- const human = this._humanizer ? ["natural", "careful"].includes(this._humanizer.profile.name) ? this._humanizer.profile.name : "natural" : null;
752
+ const human = h ? ["natural", "careful"].includes(h.profile.name) ? h.profile.name : "natural" : null;
740
753
  await this.send({ method: "Ceki.typeText", params: { text, human } });
741
- if (this._humanizer) {
742
- await this._humanizer.after("type");
754
+ if (h) {
755
+ await h.after("type");
743
756
  }
744
757
  }
745
758
  async scroll(opts) {
@@ -747,13 +760,14 @@ var Browser = class _Browser {
747
760
  const y = opts?.y ?? 0;
748
761
  const deltaX = opts?.deltaX ?? 0;
749
762
  const deltaY = opts?.deltaY ?? -300;
750
- if (this._humanizer) await this._humanizer.before("scroll");
763
+ const h = this._humanizeForCall(opts?.human);
764
+ if (h) await h.before("scroll");
751
765
  await this.send({
752
766
  method: "Input.dispatchMouseEvent",
753
767
  params: { type: "mouseWheel", x, y, deltaX, deltaY }
754
768
  });
755
769
  this._lastPointer = [x, y];
756
- if (this._humanizer) await this._humanizer.after("scroll");
770
+ if (h) await h.after("scroll");
757
771
  }
758
772
  async screenshot(opts) {
759
773
  const format = opts?.format ?? "base64";