@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/dist/index.cjs CHANGED
@@ -714,27 +714,39 @@ var Browser = class _Browser {
714
714
  this._sendRaw(msg);
715
715
  });
716
716
  }
717
- async navigate(url, timeout = 3e4) {
718
- if (this._humanizer) await this._humanizer.before("navigate");
717
+ // task 427 — per-call kill-switch. human=false bypasses humanizer timings
718
+ // AND tells the extension to skip mouse-jitter via the `_ceki_raw` marker
719
+ // (see cdp.ts). human=true forces humanizer; human undefined = session
720
+ // default. Global env CEKI_HUMAN_DISABLE=1 nulls this._humanizer in the
721
+ // constructor so all paths become raw.
722
+ _humanizeForCall(human) {
723
+ if (human === false) return null;
724
+ return this._humanizer;
725
+ }
726
+ async navigate(url, timeout = 3e4, opts) {
727
+ const h = this._humanizeForCall(opts?.human);
728
+ if (h) await h.before("navigate");
719
729
  const result = await this.send({ method: "Page.navigate", params: { url } }, timeout);
720
- if (this._humanizer) await this._humanizer.after("navigate");
730
+ if (h) await h.after("navigate");
721
731
  return {
722
732
  url: String(result?.url ?? url),
723
733
  frameId: result?.frameId ? String(result.frameId) : void 0
724
734
  };
725
735
  }
726
- async click(x, y) {
727
- if (this._humanizer) await this._humanizer.before("click");
736
+ async click(x, y, opts) {
737
+ const h = this._humanizeForCall(opts?.human);
738
+ if (h) await h.before("click");
739
+ const rawFlag = h === null ? { _ceki_raw: true } : {};
728
740
  await this.send({
729
741
  method: "Input.dispatchMouseEvent",
730
- params: { type: "mousePressed", x, y, button: "left", clickCount: 1 }
742
+ params: { type: "mousePressed", x, y, button: "left", clickCount: 1, ...rawFlag }
731
743
  });
732
744
  await this.send({
733
745
  method: "Input.dispatchMouseEvent",
734
746
  params: { type: "mouseReleased", x, y, button: "left", clickCount: 1 }
735
747
  });
736
748
  this._lastPointer = [x, y];
737
- if (this._humanizer) await this._humanizer.after("click");
749
+ if (h) await h.after("click");
738
750
  }
739
751
  async _sendKeystroke(char) {
740
752
  const mapping = keymapForChar(char);
@@ -780,9 +792,10 @@ var Browser = class _Browser {
780
792
  });
781
793
  }
782
794
  }
783
- async type(text) {
784
- if (this._humanizer) {
785
- await this._humanizer.before("type");
795
+ async type(text, opts) {
796
+ const h = this._humanizeForCall(opts?.human);
797
+ if (h) {
798
+ await h.before("type");
786
799
  if (this._lastPointer) {
787
800
  const [px, py] = this._lastPointer;
788
801
  await this.send({
@@ -794,18 +807,11 @@ var Browser = class _Browser {
794
807
  params: { type: "mouseReleased", x: px, y: py, button: "left", clickCount: 1 }
795
808
  });
796
809
  }
797
- for (const char of text) {
798
- await this._sendKeystroke(char);
799
- const delay = this._humanizer.typeDelay();
800
- if (delay > 0) {
801
- await new Promise((r) => setTimeout(r, delay));
802
- }
803
- }
804
- await this._humanizer.after("type");
805
- } else {
806
- for (const char of text) {
807
- await this._sendKeystroke(char);
808
- }
810
+ }
811
+ const human = h ? ["natural", "careful"].includes(h.profile.name) ? h.profile.name : "natural" : null;
812
+ await this.send({ method: "Ceki.typeText", params: { text, human } });
813
+ if (h) {
814
+ await h.after("type");
809
815
  }
810
816
  }
811
817
  async scroll(opts) {
@@ -813,13 +819,14 @@ var Browser = class _Browser {
813
819
  const y = opts?.y ?? 0;
814
820
  const deltaX = opts?.deltaX ?? 0;
815
821
  const deltaY = opts?.deltaY ?? -300;
816
- if (this._humanizer) await this._humanizer.before("scroll");
822
+ const h = this._humanizeForCall(opts?.human);
823
+ if (h) await h.before("scroll");
817
824
  await this.send({
818
825
  method: "Input.dispatchMouseEvent",
819
826
  params: { type: "mouseWheel", x, y, deltaX, deltaY }
820
827
  });
821
828
  this._lastPointer = [x, y];
822
- if (this._humanizer) await this._humanizer.after("scroll");
829
+ if (h) await h.after("scroll");
823
830
  }
824
831
  async screenshot(opts) {
825
832
  const format = opts?.format ?? "base64";