@qaiddev/thumbs-embed 1.2.1 → 1.2.2

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/embed.d.ts CHANGED
@@ -134,6 +134,10 @@ export declare class QaidFeedback {
134
134
  private removeTargetingOverlay;
135
135
  private showSelectedMarker;
136
136
  private hideSelectedMarker;
137
+ /** Whether to capture the screenshot with the DOM/canvas method (html2canvas)
138
+ * instead of the permission-based Screen Capture API. Explicit "dom" wins;
139
+ * otherwise DOM is used on touch devices to avoid the getDisplayMedia prompt. */
140
+ private shouldCaptureViaDom;
137
141
  private submitFeedback;
138
142
  /**
139
143
  * Quest id linked to `type`, or "" when quest launching is disabled
package/dist/qaid.js CHANGED
@@ -249,7 +249,7 @@ function Ot(e) {
249
249
  stop: b
250
250
  };
251
251
  }
252
- const F = "data-qaid-a11y-live", $t = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;", Nt = [
252
+ const V = "data-qaid-a11y-live", $t = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;", Nt = [
253
253
  "a[href]",
254
254
  "button",
255
255
  "input",
@@ -257,19 +257,19 @@ const F = "data-qaid-a11y-live", $t = "position:absolute;width:1px;height:1px;ma
257
257
  "select",
258
258
  "[tabindex]"
259
259
  ].join(",");
260
- function Ft(e) {
260
+ function Vt(e) {
261
261
  return e.ownerDocument || document;
262
262
  }
263
- function Vt(e, t) {
263
+ function Ft(e, t) {
264
264
  const i = t ? "assertive" : "polite", o = e.querySelector(
265
- `[${F}="${i}"]`
265
+ `[${V}="${i}"]`
266
266
  );
267
267
  if (o) return o;
268
- const s = Ft(e).createElement("div");
269
- return s.setAttribute(F, i), s.setAttribute("role", t ? "alert" : "status"), s.setAttribute("aria-live", t ? "assertive" : "polite"), s.setAttribute("aria-atomic", "true"), s.style.cssText = $t, e.appendChild(s), s;
268
+ const s = Vt(e).createElement("div");
269
+ return s.setAttribute(V, i), s.setAttribute("role", t ? "alert" : "status"), s.setAttribute("aria-live", t ? "assertive" : "polite"), s.setAttribute("aria-atomic", "true"), s.style.cssText = $t, e.appendChild(s), s;
270
270
  }
271
271
  function Ut(e, t, i = {}) {
272
- const o = Vt(e, !!i.assertive);
272
+ const o = Ft(e, !!i.assertive);
273
273
  o.textContent = "", o.textContent = t;
274
274
  }
275
275
  function _t(e) {
@@ -286,7 +286,7 @@ function Kt(e) {
286
286
  }
287
287
  return !1;
288
288
  }
289
- function V(e) {
289
+ function F(e) {
290
290
  return Array.from(
291
291
  e.querySelectorAll(Nt)
292
292
  ).filter((i) => !(i.getAttribute("tabindex") === "-1" || i instanceof HTMLInputElement && i.type === "hidden" || i instanceof HTMLAnchorElement && !i.getAttribute("href") || _t(i) || Kt(i)));
@@ -302,7 +302,7 @@ function jt(e) {
302
302
  let i = !1;
303
303
  const o = (s) => {
304
304
  if (s.key !== "Tab") return;
305
- const a = V(e);
305
+ const a = F(e);
306
306
  if (a.length === 0) {
307
307
  s.preventDefault(), e.focus();
308
308
  return;
@@ -311,7 +311,7 @@ function jt(e) {
311
311
  s.shiftKey ? (!c || r === d) && (s.preventDefault(), l.focus()) : (!c || r === l) && (s.preventDefault(), d.focus());
312
312
  };
313
313
  e.addEventListener("keydown", o);
314
- const n = V(e);
314
+ const n = F(e);
315
315
  return n.length > 0 ? n[0].focus() : (e.hasAttribute("tabindex") || (e.setAttribute("tabindex", "-1"), i = !0), e.focus()), {
316
316
  release() {
317
317
  e.removeEventListener("keydown", o), i && (e.removeAttribute("tabindex"), i = !1);
@@ -711,7 +711,7 @@ async function we(e = {}) {
711
711
  }
712
712
  const X = "https://qaid.dev/lib/html2canvas.min.js", xe = 1e4, qe = 50;
713
713
  let x = null;
714
- function Pe() {
714
+ function ze() {
715
715
  if (typeof document > "u" || typeof window > "u")
716
716
  return !1;
717
717
  const e = document.createElement("canvas");
@@ -797,10 +797,13 @@ async function Ie(e) {
797
797
  });
798
798
  }
799
799
  const W = "qaid_visitor_id", Y = "qaid_hide_feedback", Ae = 12;
800
+ function De() {
801
+ return typeof window.matchMedia == "function" && window.matchMedia("(pointer: coarse)").matches;
802
+ }
800
803
  function H(e) {
801
804
  return e ? `${Y}_${e}` : Y;
802
805
  }
803
- function De(e) {
806
+ function Me(e) {
804
807
  try {
805
808
  return localStorage.getItem(H(e)) === "1";
806
809
  } catch {
@@ -813,7 +816,7 @@ function Q(e, t = !0) {
813
816
  } catch {
814
817
  }
815
818
  }
816
- function Me() {
819
+ function Re() {
817
820
  try {
818
821
  let e = localStorage.getItem(W);
819
822
  return e || (e = crypto.randomUUID(), localStorage.setItem(W, e)), e;
@@ -821,7 +824,7 @@ function Me() {
821
824
  return crypto.randomUUID();
822
825
  }
823
826
  }
824
- class Re {
827
+ class He {
825
828
  config;
826
829
  state = "IDLE";
827
830
  feedbackData = {
@@ -969,7 +972,7 @@ class Re {
969
972
  apiKey: t.quests?.apiKey ?? t.apiKey ?? "",
970
973
  moduleUrl: t.quests?.moduleUrl ?? Se
971
974
  }
972
- }, this.boundKeyDown = this.handleKeyDown.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundClick = this.handleClick.bind(this), this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundResize = this.handleResize.bind(this), this.visitorId = Me(), this.init();
975
+ }, this.boundKeyDown = this.handleKeyDown.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundClick = this.handleClick.bind(this), this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundResize = this.handleResize.bind(this), this.visitorId = Re(), this.init();
973
976
  }
974
977
  applyVars(t) {
975
978
  Et(t, this.cssVars);
@@ -1008,7 +1011,7 @@ class Re {
1008
1011
  backdropOpacity: this.config.backdropOpacity,
1009
1012
  fontFamily: this.config.fontFamily,
1010
1013
  fontSize: this.config.fontSize
1011
- }), !this.config.hideDismiss && De(this.config.apiKey) && (this._startDismissed = !0), this.checkMobile(), window.addEventListener("resize", this.boundResize), this.createEmbed(), this.consoleCapture = se((t) => {
1014
+ }), !this.config.hideDismiss && Me(this.config.apiKey) && (this._startDismissed = !0), this.checkMobile(), window.addEventListener("resize", this.boundResize), this.createEmbed(), this.consoleCapture = se((t) => {
1012
1015
  this.feedbackData.consoleErrors = this.consoleCapture?.errors ?? [];
1013
1016
  }), this.feedbackData.consoleErrors = this.consoleCapture.errors, this.observeDom();
1014
1017
  }
@@ -1249,9 +1252,15 @@ class Re {
1249
1252
  hideSelectedMarker() {
1250
1253
  this.marker && (this.marker.remove(), this.marker = null);
1251
1254
  }
1255
+ /** Whether to capture the screenshot with the DOM/canvas method (html2canvas)
1256
+ * instead of the permission-based Screen Capture API. Explicit "dom" wins;
1257
+ * otherwise DOM is used on touch devices to avoid the getDisplayMedia prompt. */
1258
+ shouldCaptureViaDom() {
1259
+ return this.config.screenshotMethod === "dom" || De();
1260
+ }
1252
1261
  async submitFeedback() {
1253
1262
  let t = null;
1254
- this.config.captureScreenshot && (this.config.screenshotMethod === "dom" ? t = await Ce(this.config.screenshotOptions) : t = await we(this.config.screenshotOptions), t && this.announceMsg("Screenshot captured"));
1263
+ this.config.captureScreenshot && (t = this.shouldCaptureViaDom() ? await Ce(this.config.screenshotOptions) : await we(this.config.screenshotOptions), t && this.announceMsg("Screenshot captured"));
1255
1264
  const i = this.feedbackData.elementSelector ? {
1256
1265
  x: this.selectedBounds.x,
1257
1266
  y: this.selectedBounds.y,
@@ -1561,7 +1570,7 @@ class Re {
1561
1570
  function et(e) {
1562
1571
  return document.querySelector(e)?.textContent?.trim() ?? "";
1563
1572
  }
1564
- function He() {
1573
+ function Be() {
1565
1574
  const e = document.querySelector(
1566
1575
  'script[type="application/json"][data-feedback-config]'
1567
1576
  );
@@ -1575,7 +1584,7 @@ function He() {
1575
1584
  return null;
1576
1585
  }
1577
1586
  }
1578
- function Be(e) {
1587
+ function Pe(e) {
1579
1588
  const t = e.getAttribute("data-endpoint");
1580
1589
  if (!t) return null;
1581
1590
  const i = e.getAttribute("data-position"), o = e.getAttribute("data-zindex"), n = e.getAttribute("data-positive-color"), s = e.getAttribute("data-negative-color"), a = e.getAttribute("data-marker-color"), d = e.getAttribute("data-container"), l = e.getAttribute("data-button-class"), r = e.getAttribute("data-skip-targeting"), c = e.getAttribute("data-incognito"), p = e.getAttribute("data-button-size"), u = e.getAttribute("data-offset-x"), m = e.getAttribute("data-offset-y"), b = e.getAttribute("data-modal-width"), v = e.getAttribute("data-backdrop-opacity"), y = e.getAttribute("data-font-family"), f = e.getAttribute("data-font-size"), h = e.getAttribute("data-tooltip"), w = e.getAttribute("data-modal-title"), g = e.getAttribute("data-modal-subtitle"), C = e.getAttribute("data-placeholder"), B = e.getAttribute("data-submit-button"), P = e.getAttribute("data-skip-button"), it = e.getAttribute("data-positive-icon"), ot = e.getAttribute("data-negative-icon"), nt = e.getAttribute("data-api-key"), st = e.getAttribute("data-capture-screenshot"), E = e.getAttribute("data-screenshot-quality"), T = e.getAttribute("data-screenshot-max-width"), L = e.getAttribute("data-screenshot-max-height"), at = e.getAttribute("data-capture-video"), rt = e.getAttribute("data-hide-thumbs"), dt = e.getAttribute("data-hide-dismiss"), z = e.getAttribute("data-video-max-duration"), ct = e.getAttribute("data-screenshot-method"), lt = e.getAttribute("data-direction"), O = e.getAttribute("data-css-selector"), $ = e.getAttribute("data-quest-base"), ht = e.getAttribute("data-quest-up"), ut = e.getAttribute("data-quest-down"), pt = e.getAttribute("data-quest-video"), mt = e.getAttribute("data-quest-api-key"), ft = e.getAttribute("data-quest-module-url");
@@ -1639,18 +1648,18 @@ function Be(e) {
1639
1648
  }
1640
1649
  if (typeof document < "u") {
1641
1650
  const e = () => {
1642
- const t = document.currentScript, i = He(), o = t ? Be(t) : null, n = i ?? o;
1643
- n?.endpoint && new Re(n);
1651
+ const t = document.currentScript, i = Be(), o = t ? Pe(t) : null, n = i ?? o;
1652
+ n?.endpoint && new He(n);
1644
1653
  };
1645
1654
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
1646
1655
  }
1647
1656
  export {
1648
- Re as QaidFeedback,
1657
+ He as QaidFeedback,
1649
1658
  Ce as captureDomScreenshot,
1650
1659
  de as captureNetworkErrors,
1651
1660
  ve as createVideoRecorder,
1652
1661
  ge as getSupportedMimeType,
1653
- Pe as isDomScreenshotSupported,
1662
+ ze as isDomScreenshotSupported,
1654
1663
  be as isVideoRecordingSupported
1655
1664
  };
1656
1665
  //# sourceMappingURL=qaid.js.map