@firstlook-uat/sdk 0.4.3 → 0.4.4

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.
@@ -33,7 +33,7 @@ function R(c) {
33
33
  }
34
34
  };
35
35
  }
36
- function q() {
36
+ function T() {
37
37
  return {
38
38
  userAgent: navigator.userAgent,
39
39
  platform: navigator.platform,
@@ -187,7 +187,7 @@ function F(c) {
187
187
  items: s
188
188
  };
189
189
  }
190
- class P {
190
+ class O {
191
191
  constructor(e, t) {
192
192
  this.shadowRoot = e, this.callbacks = t, this.minimized = !1, this.timerInterval = null, this.startTime = 0, this.checklist = [], this.root = document.createElement("div"), this.root.className = "fl-quest-overlay", this.root.style.pointerEvents = "auto";
193
193
  for (const s of ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"])
@@ -376,8 +376,8 @@ class P {
376
376
  this.timerInterval && (clearInterval(this.timerInterval), this.timerInterval = null);
377
377
  }
378
378
  }
379
- const z = 100, O = 2 * 1024 * 1024;
380
- class Q {
379
+ const P = 100, z = 2 * 1024 * 1024;
380
+ class B {
381
381
  constructor(e, t, s) {
382
382
  this.config = e, this.events = t, this.maskSelector = s, this.actionLogs = [], this.snapshots = [], this.snapshotTimer = null, this.startTime = 0, this.running = !1, this.handleClick = this.onClick.bind(this), this.handleScroll = this.throttle(this.onScroll.bind(this), 500), this.handleInput = this.onInput.bind(this);
383
383
  }
@@ -444,8 +444,8 @@ class Q {
444
444
  const s = e.querySelector("#firstlook-sdk-root");
445
445
  s == null || s.remove();
446
446
  const i = e.outerHTML;
447
- if (i.length > O) return;
448
- this.snapshots.length >= z && this.snapshots.shift(), this.snapshots.push({
447
+ if (i.length > z) return;
448
+ this.snapshots.length >= P && this.snapshots.shift(), this.snapshots.push({
449
449
  type: "dom-snapshot",
450
450
  timestamp: Date.now() - this.startTime,
451
451
  data: i
@@ -466,7 +466,7 @@ function w(c) {
466
466
  const e = c.tagName.toLowerCase(), t = c.id ? `#${c.id}` : "", s = c.className && typeof c.className == "string" ? `.${c.className.trim().split(/\s+/).slice(0, 2).join(".")}` : "", i = ((n = c.textContent) == null ? void 0 : n.trim().slice(0, 30)) || "";
467
467
  return `${e}${t}${s}${i ? ` "${i}"` : ""}`;
468
468
  }
469
- class B {
469
+ class Q {
470
470
  constructor(e) {
471
471
  this.events = e, this.mediaRecorder = null, this.stream = null, this.chunks = [], this._recording = !1;
472
472
  }
@@ -716,10 +716,10 @@ class H {
716
716
  });
717
717
  }
718
718
  }
719
- const T = ["#e17055", "#6c5ce7", "#00b894", "#fdcb6e", "#ffffff"];
720
- class _ {
719
+ const q = ["#e17055", "#6c5ce7", "#00b894", "#fdcb6e", "#ffffff"];
720
+ class W {
721
721
  constructor(e) {
722
- this.shadowRoot = e, this.overlay = null, this.canvas = null, this.ctx = null, this.drawing = !1, this.currentPath = [], this.paths = [], this.selectedColor = T[0], this.screenshotDataUrl = "";
722
+ this.shadowRoot = e, this.overlay = null, this.canvas = null, this.ctx = null, this.drawing = !1, this.currentPath = [], this.paths = [], this.selectedColor = q[0], this.screenshotDataUrl = "";
723
723
  }
724
724
  async open() {
725
725
  return this.screenshotDataUrl = await this.captureScreenshot(), new Promise((e) => {
@@ -731,7 +731,7 @@ class _ {
731
731
  type: "text",
732
732
  placeholder: "Add a comment..."
733
733
  }), i = r("div", { className: "fl-color-picker" });
734
- for (const a of T) {
734
+ for (const a of q) {
735
735
  const h = r("div", { className: `fl-color-swatch ${a === this.selectedColor ? "fl-selected" : ""}` });
736
736
  h.style.background = a, h.onclick = () => {
737
737
  this.selectedColor = a, i.querySelectorAll(".fl-color-swatch").forEach((d) => d.classList.remove("fl-selected")), h.classList.add("fl-selected");
@@ -835,11 +835,11 @@ class _ {
835
835
  return ((e = this.canvas) == null ? void 0 : e.toDataURL("image/png")) || this.screenshotDataUrl;
836
836
  }
837
837
  }
838
- class W {
838
+ class _ {
839
839
  constructor(e, t) {
840
840
  this.shadowRoot = e, this.events = t, this.annotations = [], this.active = !1, this.onKeydown = (s) => {
841
841
  s.ctrlKey && s.shiftKey && s.key === "R" && (s.preventDefault(), this.trigger());
842
- }, this.annotationCanvas = new _(e);
842
+ }, this.annotationCanvas = new W(e);
843
843
  }
844
844
  start() {
845
845
  document.addEventListener("keydown", this.onKeydown);
@@ -937,7 +937,7 @@ class C {
937
937
  }
938
938
  const x = class x {
939
939
  constructor(e) {
940
- this.onActivate = e, this.handler = null, this.sequence = [], this.sequenceTimer = null;
940
+ this.onActivate = e, this.handler = null, this.sequence = [], this.typeBuffer = "", this.sequenceTimer = null, this.typeTimer = null;
941
941
  }
942
942
  start() {
943
943
  this.handler = (e) => {
@@ -945,6 +945,15 @@ const x = class x {
945
945
  e.preventDefault(), this.onActivate();
946
946
  return;
947
947
  }
948
+ if (e.key.length === 1) {
949
+ if (this.typeBuffer += e.key, this.typeTimer && clearTimeout(this.typeTimer), this.typeTimer = setTimeout(() => {
950
+ this.typeBuffer = "";
951
+ }, 3e3), this.typeBuffer.endsWith(x.MAGIC_WORD)) {
952
+ this.typeBuffer = "", this.onActivate();
953
+ return;
954
+ }
955
+ this.typeBuffer.length > 20 && (this.typeBuffer = this.typeBuffer.slice(-12));
956
+ }
948
957
  if (e.key.startsWith("Arrow")) {
949
958
  this.sequence.push(e.key), this.sequenceTimer && clearTimeout(this.sequenceTimer), this.sequenceTimer = setTimeout(() => {
950
959
  this.sequence = [];
@@ -955,7 +964,7 @@ const x = class x {
955
964
  }, window.addEventListener("keydown", this.handler);
956
965
  }
957
966
  stop() {
958
- this.handler && (window.removeEventListener("keydown", this.handler), this.handler = null), this.sequenceTimer && (clearTimeout(this.sequenceTimer), this.sequenceTimer = null);
967
+ this.handler && (window.removeEventListener("keydown", this.handler), this.handler = null), this.sequenceTimer && (clearTimeout(this.sequenceTimer), this.sequenceTimer = null), this.typeTimer && (clearTimeout(this.typeTimer), this.typeTimer = null);
959
968
  }
960
969
  };
961
970
  x.KONAMI = [
@@ -967,7 +976,7 @@ x.KONAMI = [
967
976
  "ArrowRight",
968
977
  "ArrowLeft",
969
978
  "ArrowRight"
970
- ];
979
+ ], x.MAGIC_WORD = "1st/look.";
971
980
  let S = x;
972
981
  class X {
973
982
  constructor(e, t) {
@@ -1006,7 +1015,7 @@ class X {
1006
1015
  return this.root !== null;
1007
1016
  }
1008
1017
  }
1009
- const Y = (
1018
+ const G = (
1010
1019
  /* css */
1011
1020
  `
1012
1021
  :host {
@@ -1507,7 +1516,7 @@ const Y = (
1507
1516
  }
1508
1517
  .fl-feedback-modal-actions { padding: 0 16px 16px; }
1509
1518
  `
1510
- ), G = 5;
1519
+ ), Y = 5;
1511
1520
  class J {
1512
1521
  constructor() {
1513
1522
  this.config = null, this.events = new L(), this.state = "idle", this.hostElement = null, this.shadowRoot = null, this.questManager = null, this.questOverlay = null, this.sessionRecorder = null, this.voiceRecorder = null, this.watermark = null, this.fieldMasker = null, this.storage = null, this.issueReporter = null, this.debugMenu = null, this.tapTrigger = null, this.deepLinkTrigger = null, this.keyboardTrigger = null, this.sessionId = null, this.sessionStartTime = 0, this.maxDurationTimer = null, this.backupTimer = null, this.isFlushing = !1;
@@ -1543,11 +1552,11 @@ class J {
1543
1552
  var s;
1544
1553
  if (this.state !== "active")
1545
1554
  throw new Error("[FirstLook] Cannot start session: SDK not active. Call activate() first.");
1546
- (s = this.debugMenu) == null || s.hide(), this.sessionId = D(), this.sessionStartTime = Date.now(), this.questManager = new E(this.events), this.questManager.loadQuests(e), this.sessionRecorder = new Q(
1555
+ (s = this.debugMenu) == null || s.hide(), this.sessionId = D(), this.sessionStartTime = Date.now(), this.questManager = new E(this.events), this.questManager.loadQuests(e), this.sessionRecorder = new B(
1547
1556
  this.config,
1548
1557
  this.events,
1549
1558
  this.fieldMasker.getCombinedSelector()
1550
- ), this.voiceRecorder = new B(this.events), this.issueReporter = new W(this.shadowRoot, this.events), this.issueReporter.start(), this.sessionRecorder.start(), this.fieldMasker.start(), this.config.recording.voice && await this.voiceRecorder.start(), this.config.security.watermark && (this.watermark = new U(this.shadowRoot, this.config), this.watermark.show()), this.questOverlay = new P(this.shadowRoot, {
1559
+ ), this.voiceRecorder = new Q(this.events), this.issueReporter = new _(this.shadowRoot, this.events), this.issueReporter.start(), this.sessionRecorder.start(), this.fieldMasker.start(), this.config.recording.voice && await this.voiceRecorder.start(), this.config.security.watermark && (this.watermark = new U(this.shadowRoot, this.config), this.watermark.show()), this.questOverlay = new O(this.shadowRoot, {
1551
1560
  onOkWithFeedback: (i) => this.handleQuestOk(i),
1552
1561
  onConcern: (i) => this.handleConcern(i),
1553
1562
  onNg: () => this.handleQuestNg(),
@@ -1611,7 +1620,7 @@ class J {
1611
1620
  projectId: this.config.projectId,
1612
1621
  userId: this.config.userId,
1613
1622
  role: this.config.role,
1614
- deviceInfo: q(),
1623
+ deviceInfo: T(),
1615
1624
  startedAt: new Date(this.sessionStartTime).toISOString(),
1616
1625
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
1617
1626
  duration: Math.floor((Date.now() - this.sessionStartTime) / 1e3),
@@ -1651,7 +1660,7 @@ class J {
1651
1660
  var t;
1652
1661
  (t = document.getElementById("firstlook-sdk-root")) == null || t.remove(), this.hostElement = document.createElement("div"), this.hostElement.id = "firstlook-sdk-root", this.hostElement.style.cssText = "position:fixed;inset:0;z-index:2147483647;pointer-events:none;", document.body.appendChild(this.hostElement), this.shadowRoot = this.hostElement.attachShadow({ mode: "closed" });
1653
1662
  const e = document.createElement("style");
1654
- e.textContent = Y, this.shadowRoot.appendChild(e);
1663
+ e.textContent = G, this.shadowRoot.appendChild(e);
1655
1664
  }
1656
1665
  setupTriggers() {
1657
1666
  const e = this.config.triggers;
@@ -1742,7 +1751,7 @@ class J {
1742
1751
  }
1743
1752
  const t = await this.storage.getPendingUploads();
1744
1753
  for (const s of t) {
1745
- if (s.attempts >= G) {
1754
+ if (s.attempts >= Y) {
1746
1755
  await this.storage.removeFromQueue(s.key);
1747
1756
  continue;
1748
1757
  }
@@ -1778,7 +1787,7 @@ class J {
1778
1787
  projectId: this.config.projectId,
1779
1788
  userId: this.config.userId,
1780
1789
  role: this.config.role,
1781
- deviceInfo: q(),
1790
+ deviceInfo: T(),
1782
1791
  startedAt: new Date(this.sessionStartTime).toISOString(),
1783
1792
  duration: Math.floor((Date.now() - this.sessionStartTime) / 1e3),
1784
1793
  quests: ((e = this.questManager) == null ? void 0 : e.getResults()) ?? [],