@loupekit/sdk 0.9.0 → 0.9.1-next.33

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.
@@ -2487,6 +2487,9 @@ var Loupe = (() => {
2487
2487
  this.floatResize = null;
2488
2488
  this.raf = 0;
2489
2489
  // ---- inspector ------------------------------------------------------------
2490
+ // Pointer Events, not mouse events: a touch drag on a phone never fires
2491
+ // mousemove/mouseup, so Region/Record selection was impossible on touch devices.
2492
+ // Pointer events cover mouse, touch and pen with one handler each.
2490
2493
  this.onMove = (e) => {
2491
2494
  if (this.mode !== "inspect") return;
2492
2495
  const target = this.pick(e.clientX, e.clientY);
@@ -2527,14 +2530,16 @@ var Loupe = (() => {
2527
2530
  };
2528
2531
  // ---- region ("free-size screenshot") selection ----------------------------
2529
2532
  this.onRegionDown = (e) => {
2530
- if (this.mode !== "region" && this.mode !== "record" || e.button !== 0) return;
2533
+ if (this.mode !== "region" && this.mode !== "record") return;
2534
+ if (e.pointerType !== "touch" && e.pointerType !== "pen" && e.button !== 0) return;
2531
2535
  const t = e.target;
2532
2536
  if (t && (t.id === "loupe-root" || t.closest?.("#loupe-root"))) return;
2533
2537
  e.preventDefault();
2534
2538
  e.stopPropagation();
2535
2539
  this.dragStart = { x: e.clientX, y: e.clientY };
2536
- document.addEventListener("mousemove", this.onRegionMove, true);
2537
- document.addEventListener("mouseup", this.onRegionUp, true);
2540
+ document.addEventListener("pointermove", this.onRegionMove, true);
2541
+ document.addEventListener("pointerup", this.onRegionUp, true);
2542
+ document.addEventListener("pointercancel", this.onRegionCancel, true);
2538
2543
  this.drawSelection(e.clientX, e.clientY);
2539
2544
  };
2540
2545
  this.onRegionMove = (e) => {
@@ -2563,6 +2568,11 @@ var Loupe = (() => {
2563
2568
  if (wasRecord) void this.finishRecording(vp);
2564
2569
  else this.finishRegion(vp);
2565
2570
  };
2571
+ /** The OS took over the gesture (e.g. a system swipe): drop the selection. */
2572
+ this.onRegionCancel = () => {
2573
+ this.cancelDrag();
2574
+ this.selbox.style.display = "none";
2575
+ };
2566
2576
  // ---- free note (drop a comment anywhere, no element / no screenshot) -------
2567
2577
  this.onFreeClick = (e) => {
2568
2578
  if (this.mode !== "free") return;
@@ -2816,7 +2826,8 @@ var Loupe = (() => {
2816
2826
  const recordBtn = this.toolBtn(RECORD_ICON, "Record", "record");
2817
2827
  recordBtn.title = "Drag a box, record a screen video of it, and comment";
2818
2828
  recordBtn.onclick = () => this.setMode(this.mode === "record" ? "off" : "record");
2819
- tools.append(inspectBtn, freeBtn, regionBtn, recordBtn);
2829
+ const canRecord = typeof navigator.mediaDevices?.getDisplayMedia === "function";
2830
+ tools.append(inspectBtn, freeBtn, regionBtn, ...canRecord ? [recordBtn] : []);
2820
2831
  const listHead = el("div", "listhead");
2821
2832
  listHead.append(document.createTextNode("Comments"));
2822
2833
  this.countEl = el("span", "count", "0");
@@ -2937,8 +2948,9 @@ var Loupe = (() => {
2937
2948
  }
2938
2949
  cancelDrag() {
2939
2950
  this.dragStart = null;
2940
- document.removeEventListener("mousemove", this.onRegionMove, true);
2941
- document.removeEventListener("mouseup", this.onRegionUp, true);
2951
+ document.removeEventListener("pointermove", this.onRegionMove, true);
2952
+ document.removeEventListener("pointerup", this.onRegionUp, true);
2953
+ document.removeEventListener("pointercancel", this.onRegionCancel, true);
2942
2954
  }
2943
2955
  /**
2944
2956
  * Anchor a dragged viewport rect to the element under its center so it survives
@@ -3040,20 +3052,23 @@ var Loupe = (() => {
3040
3052
  this.dock.querySelector('[data-role="region"]')?.classList.toggle("on", mode === "region");
3041
3053
  this.dock.querySelector('[data-role="record"]')?.classList.toggle("on", mode === "record");
3042
3054
  this.dock.classList.toggle("inspecting", mode !== "off");
3043
- document.removeEventListener("mousemove", this.onMove, true);
3055
+ document.removeEventListener("pointermove", this.onMove, true);
3056
+ document.removeEventListener("pointerdown", this.onMove, true);
3044
3057
  document.removeEventListener("click", this.onClick, true);
3045
3058
  document.removeEventListener("click", this.onFreeClick, true);
3046
- document.removeEventListener("mousedown", this.onRegionDown, true);
3059
+ document.removeEventListener("pointerdown", this.onRegionDown, true);
3060
+ document.documentElement.style.touchAction = mode === "region" || mode === "record" ? "none" : "";
3047
3061
  if (mode === "off") return;
3048
3062
  document.addEventListener("keydown", this.onKey, true);
3049
3063
  this.closeComposer();
3050
3064
  if (mode === "inspect") {
3051
- document.addEventListener("mousemove", this.onMove, true);
3065
+ document.addEventListener("pointermove", this.onMove, true);
3066
+ document.addEventListener("pointerdown", this.onMove, true);
3052
3067
  document.addEventListener("click", this.onClick, true);
3053
3068
  } else if (mode === "free") {
3054
3069
  document.addEventListener("click", this.onFreeClick, true);
3055
3070
  } else if (mode === "region" || mode === "record") {
3056
- document.addEventListener("mousedown", this.onRegionDown, true);
3071
+ document.addEventListener("pointerdown", this.onRegionDown, true);
3057
3072
  }
3058
3073
  }
3059
3074
  // ---- composer -------------------------------------------------------------