@firstlook-uat/sdk 0.3.1 → 0.3.3

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.
@@ -170,7 +170,7 @@ function E(a) {
170
170
  }
171
171
  class R {
172
172
  constructor(t, e) {
173
- this.shadowRoot = t, this.callbacks = e, this.minimized = !1, this.timerInterval = null, this.startTime = 0, this.root = document.createElement("div"), this.root.className = "fl-quest-overlay";
173
+ this.shadowRoot = t, this.callbacks = e, this.minimized = !1, this.timerInterval = null, this.startTime = 0, this.root = document.createElement("div"), this.root.className = "fl-quest-overlay", this.root.style.pointerEvents = "auto";
174
174
  for (const s of ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"])
175
175
  this.root.addEventListener(s, (i) => i.stopPropagation());
176
176
  this.shadowRoot.appendChild(this.root);
@@ -517,7 +517,7 @@ class F {
517
517
  }
518
518
  }
519
519
  }
520
- class z {
520
+ class P {
521
521
  constructor(t) {
522
522
  this.selectors = t, this.observer = null, this.maskedElements = /* @__PURE__ */ new Set();
523
523
  }
@@ -555,7 +555,7 @@ class z {
555
555
  }
556
556
  }
557
557
  }
558
- const P = "firstlook_uat", O = 1, u = {
558
+ const z = "firstlook_uat", O = 1, u = {
559
559
  sessions: "sessions",
560
560
  recordings: "recordings",
561
561
  annotations: "annotations",
@@ -568,7 +568,7 @@ class Q {
568
568
  async open() {
569
569
  if (!this.db)
570
570
  return new Promise((t, e) => {
571
- const s = indexedDB.open(P, O);
571
+ const s = indexedDB.open(z, O);
572
572
  s.onupgradeneeded = () => {
573
573
  const i = s.result;
574
574
  i.objectStoreNames.contains(u.sessions) || i.createObjectStore(u.sessions, { keyPath: "sessionId" }), i.objectStoreNames.contains(u.recordings) || i.createObjectStore(u.recordings, { autoIncrement: !0 }).createIndex("sessionId", "sessionId", { unique: !1 }), i.objectStoreNames.contains(u.annotations) || i.createObjectStore(u.annotations, { autoIncrement: !0 }).createIndex("sessionId", "sessionId", { unique: !1 }), i.objectStoreNames.contains(u.uploadQueue) || i.createObjectStore(u.uploadQueue, { autoIncrement: !0 });
@@ -797,7 +797,7 @@ class B {
797
797
  return ((t = this.canvas) == null ? void 0 : t.toDataURL("image/png")) || this.screenshotDataUrl;
798
798
  }
799
799
  }
800
- class H {
800
+ class U {
801
801
  constructor(t) {
802
802
  this.onShake = t, this.lastX = 0, this.lastY = 0, this.lastZ = 0, this.shakeCount = 0, this.lastShakeTime = 0, this.handler = null, this.THRESHOLD = 15, this.SHAKE_INTERVAL = 400, this.REQUIRED_SHAKES = 2;
803
803
  }
@@ -824,11 +824,11 @@ class H {
824
824
  this.lastX = e.x, this.lastY = e.y, this.lastZ = e.z;
825
825
  }
826
826
  }
827
- class U {
827
+ class j {
828
828
  constructor(t, e) {
829
829
  this.shadowRoot = t, this.events = e, this.annotations = [], this.active = !1, this.onKeydown = (s) => {
830
830
  s.ctrlKey && s.shiftKey && s.key === "R" && (s.preventDefault(), this.trigger());
831
- }, this.annotationCanvas = new B(t), this.shakeTrigger = new H(() => this.trigger());
831
+ }, this.annotationCanvas = new B(t), this.shakeTrigger = new U(() => this.trigger());
832
832
  }
833
833
  async start() {
834
834
  await this.shakeTrigger.start(), document.addEventListener("keydown", this.onKeydown);
@@ -851,7 +851,7 @@ class U {
851
851
  }
852
852
  }
853
853
  }
854
- class j {
854
+ class $ {
855
855
  constructor(t, e) {
856
856
  this.requiredTaps = t, this.onActivate = e, this.tapCount = 0, this.tapTimer = null, this.handler = null;
857
857
  }
@@ -871,7 +871,7 @@ class j {
871
871
  const x = "firstlook:uat-active";
872
872
  class S {
873
873
  constructor(t) {
874
- this.onActivate = t, this.hashHandler = null;
874
+ this.onActivate = t, this.handlers = [];
875
875
  }
876
876
  start() {
877
877
  if (this.checkUrl()) {
@@ -882,14 +882,16 @@ class S {
882
882
  this.onActivate();
883
883
  return;
884
884
  }
885
- this.hashHandler = () => {
885
+ const t = () => {
886
886
  this.checkUrl() && (this.persist(), this.onActivate());
887
- }, window.addEventListener("hashchange", this.hashHandler);
887
+ };
888
+ window.addEventListener("hashchange", t), this.handlers.push(["hashchange", t]), window.addEventListener("popstate", t), this.handlers.push(["popstate", t]);
888
889
  }
889
890
  stop() {
890
- this.hashHandler && (window.removeEventListener("hashchange", this.hashHandler), this.hashHandler = null);
891
+ for (const [t, e] of this.handlers)
892
+ window.removeEventListener(t, e);
893
+ this.handlers = [];
891
894
  }
892
- /** Clear the persisted flag (call on session end / destroy). */
893
895
  static clearPersisted() {
894
896
  try {
895
897
  sessionStorage.removeItem(x);
@@ -898,7 +900,15 @@ class S {
898
900
  }
899
901
  checkUrl() {
900
902
  const t = new URLSearchParams(window.location.search);
901
- return t.has("firstlook") || t.has("uat-mode") || t.get("uat") === "1";
903
+ if (t.has("firstlook") || t.has("uat-mode") || t.get("uat") === "1")
904
+ return !0;
905
+ const e = window.location.hash, s = e.indexOf("?");
906
+ if (s !== -1) {
907
+ const i = new URLSearchParams(e.substring(s));
908
+ if (i.has("firstlook") || i.has("uat-mode") || i.get("uat") === "1")
909
+ return !0;
910
+ }
911
+ return !1;
902
912
  }
903
913
  persist() {
904
914
  try {
@@ -914,26 +924,26 @@ class S {
914
924
  }
915
925
  }
916
926
  }
917
- class $ {
927
+ class K {
918
928
  constructor(t) {
919
929
  this.onActivate = t, this.handler = null;
920
930
  }
921
931
  start() {
922
932
  this.handler = (t) => {
923
- t.key === "U" && t.shiftKey && (t.ctrlKey || t.metaKey) && (t.preventDefault(), this.onActivate());
933
+ t.code === "KeyU" && t.shiftKey && (t.ctrlKey || t.metaKey) && (t.preventDefault(), this.onActivate());
924
934
  }, window.addEventListener("keydown", this.handler);
925
935
  }
926
936
  stop() {
927
937
  this.handler && (window.removeEventListener("keydown", this.handler), this.handler = null);
928
938
  }
929
939
  }
930
- class K {
940
+ class H {
931
941
  constructor(t, e) {
932
942
  this.shadowRoot = t, this.callbacks = e, this.root = null, this.outsideClickHandler = null;
933
943
  }
934
944
  show() {
935
945
  if (this.root) return;
936
- this.root = r("div", { className: "fl-debug-menu" });
946
+ this.root = r("div", { className: "fl-debug-menu" }), this.root.style.pointerEvents = "auto";
937
947
  for (const e of ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"])
938
948
  this.root.addEventListener(e, (s) => s.stopPropagation());
939
949
  const t = [
@@ -1437,7 +1447,7 @@ class X {
1437
1447
  console.warn("[FirstLook] SDK already initialized.");
1438
1448
  return;
1439
1449
  }
1440
- this.config = C(t), this.storage = new Q(), await this.storage.open(), this.createShadowHost(), this.setupTriggers(), this.fieldMasker = new z(this.config.security.maskSelectors), this.state = "initialized", this.events.emit({ type: "sdk:initialized" }), this.flushUploadQueue(!0);
1450
+ this.config = C(t), this.storage = new Q(), await this.storage.open(), this.createShadowHost(), this.setupTriggers(), this.fieldMasker = new P(this.config.security.maskSelectors), this.state = "initialized", this.events.emit({ type: "sdk:initialized" }), this.flushUploadQueue(!0);
1441
1451
  }
1442
1452
  /**
1443
1453
  * Manually activate the SDK UI (bypassing triggers).
@@ -1460,7 +1470,7 @@ class X {
1460
1470
  this.config,
1461
1471
  this.events,
1462
1472
  this.fieldMasker.getCombinedSelector()
1463
- ), this.voiceRecorder = new N(this.events), this.shakeReporter = new U(this.shadowRoot, this.events), await this.shakeReporter.start(), this.sessionRecorder.start(), this.fieldMasker.start(), this.config.recording.voice && await this.voiceRecorder.start(), this.config.security.watermark && (this.watermark = new F(this.shadowRoot, this.config), this.watermark.show()), this.questOverlay = new R(this.shadowRoot, {
1473
+ ), this.voiceRecorder = new N(this.events), this.shakeReporter = new j(this.shadowRoot, this.events), await this.shakeReporter.start(), this.sessionRecorder.start(), this.fieldMasker.start(), this.config.recording.voice && await this.voiceRecorder.start(), this.config.security.watermark && (this.watermark = new F(this.shadowRoot, this.config), this.watermark.show()), this.questOverlay = new R(this.shadowRoot, {
1464
1474
  onOkWithFeedback: (i) => this.handleQuestOk(i),
1465
1475
  onConcern: (i) => this.handleConcern(i),
1466
1476
  onNg: () => this.handleQuestNg(),
@@ -1553,24 +1563,26 @@ class X {
1553
1563
  * Completely destroy the SDK instance and clean up all resources.
1554
1564
  */
1555
1565
  destroy() {
1556
- var t, e, s, i, n, o, l, c, d, h, p;
1557
- this.maxDurationTimer && (clearTimeout(this.maxDurationTimer), this.maxDurationTimer = null), this.backupTimer && (clearInterval(this.backupTimer), this.backupTimer = null), (t = this.tapTrigger) == null || t.stop(), (e = this.deepLinkTrigger) == null || e.stop(), (s = this.keyboardTrigger) == null || s.stop(), S.clearPersisted(), (i = this.sessionRecorder) == null || i.stop(), (n = this.shakeReporter) == null || n.stop(), (o = this.fieldMasker) == null || o.stop(), (l = this.watermark) == null || l.hide(), (c = this.questOverlay) == null || c.destroy(), (d = this.debugMenu) == null || d.hide(), (h = this.hostElement) == null || h.remove(), (p = this.storage) == null || p.close(), this.events.removeAll(), this.state = "idle";
1566
+ var t, e, s, i, n, o, l, c, d, h, p, g;
1567
+ this.maxDurationTimer && (clearTimeout(this.maxDurationTimer), this.maxDurationTimer = null), this.backupTimer && (clearInterval(this.backupTimer), this.backupTimer = null), (t = this.tapTrigger) == null || t.stop(), (e = this.deepLinkTrigger) == null || e.stop(), (s = this.keyboardTrigger) == null || s.stop(), S.clearPersisted(), (i = this.sessionRecorder) == null || i.stop(), (n = this.voiceRecorder) == null || n.stopAsync().catch(() => {
1568
+ }), (o = this.shakeReporter) == null || o.stop(), (l = this.fieldMasker) == null || l.stop(), (c = this.watermark) == null || c.hide(), (d = this.questOverlay) == null || d.destroy(), (h = this.debugMenu) == null || h.hide(), (p = this.hostElement) == null || p.remove(), (g = this.storage) == null || g.close(), this.events.removeAll(), this.config = null, this.questManager = null, this.questOverlay = null, this.sessionRecorder = null, this.voiceRecorder = null, this.shakeReporter = null, this.fieldMasker = null, this.debugMenu = null, this.tapTrigger = null, this.deepLinkTrigger = null, this.keyboardTrigger = null, this.storage = null, this.hostElement = null, this.shadowRoot = null, this.sessionId = null, this.state = "idle";
1558
1569
  }
1559
1570
  // ----------------------------------------------------------------
1560
1571
  // Private methods
1561
1572
  // ----------------------------------------------------------------
1562
1573
  createShadowHost() {
1563
- 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" });
1574
+ var e;
1575
+ (e = document.getElementById("firstlook-sdk-root")) == null || e.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" });
1564
1576
  const t = document.createElement("style");
1565
1577
  t.textContent = _, this.shadowRoot.appendChild(t);
1566
1578
  }
1567
1579
  setupTriggers() {
1568
1580
  const t = this.config.triggers;
1569
- this.tapTrigger = new j(t.tapCount, () => this.onActivate()), this.tapTrigger.start(), t.deepLink && (this.deepLinkTrigger = new S(() => this.onActivate()), this.deepLinkTrigger.start()), t.keyboard && (this.keyboardTrigger = new $(() => this.onActivate()), this.keyboardTrigger.start()), t.customCheck && t.customCheck() && this.onActivate();
1581
+ this.tapTrigger = new $(t.tapCount, () => this.onActivate()), this.tapTrigger.start(), t.deepLink && (this.deepLinkTrigger = new S(() => this.onActivate()), this.deepLinkTrigger.start()), t.keyboard && (this.keyboardTrigger = new K(() => this.onActivate()), this.keyboardTrigger.start()), t.customCheck && t.customCheck() && this.onActivate();
1570
1582
  }
1571
1583
  onActivate() {
1572
1584
  var t, e, s;
1573
- this.state === "initialized" && (this.state = "active", (t = this.tapTrigger) == null || t.stop(), (e = this.deepLinkTrigger) == null || e.stop(), (s = this.keyboardTrigger) == null || s.stop(), this.events.emit({ type: "sdk:activated" }), this.debugMenu = new K(this.shadowRoot, {
1585
+ this.state === "initialized" && (this.state = "active", (t = this.tapTrigger) == null || t.stop(), (e = this.deepLinkTrigger) == null || e.stop(), (s = this.keyboardTrigger) == null || s.stop(), this.events.emit({ type: "sdk:activated" }), this.debugMenu = new H(this.shadowRoot, {
1574
1586
  onStartSession: () => {
1575
1587
  this.events.emit({ type: "sdk:activated" });
1576
1588
  },