@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.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({
@@ -795,10 +808,10 @@ var Browser = class _Browser {
795
808
  });
796
809
  }
797
810
  }
798
- const human = this._humanizer ? ["natural", "careful"].includes(this._humanizer.profile.name) ? this._humanizer.profile.name : "natural" : null;
811
+ const human = h ? ["natural", "careful"].includes(h.profile.name) ? h.profile.name : "natural" : null;
799
812
  await this.send({ method: "Ceki.typeText", params: { text, human } });
800
- if (this._humanizer) {
801
- await this._humanizer.after("type");
813
+ if (h) {
814
+ await h.after("type");
802
815
  }
803
816
  }
804
817
  async scroll(opts) {
@@ -806,13 +819,14 @@ var Browser = class _Browser {
806
819
  const y = opts?.y ?? 0;
807
820
  const deltaX = opts?.deltaX ?? 0;
808
821
  const deltaY = opts?.deltaY ?? -300;
809
- if (this._humanizer) await this._humanizer.before("scroll");
822
+ const h = this._humanizeForCall(opts?.human);
823
+ if (h) await h.before("scroll");
810
824
  await this.send({
811
825
  method: "Input.dispatchMouseEvent",
812
826
  params: { type: "mouseWheel", x, y, deltaX, deltaY }
813
827
  });
814
828
  this._lastPointer = [x, y];
815
- if (this._humanizer) await this._humanizer.after("scroll");
829
+ if (h) await h.after("scroll");
816
830
  }
817
831
  async screenshot(opts) {
818
832
  const format = opts?.format ?? "base64";