@firstlook-uat/sdk 0.3.0 → 0.3.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.
@@ -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,20 +924,20 @@ 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
  }
@@ -987,6 +997,7 @@ const _ = (
987
997
  bottom: 24px;
988
998
  right: 24px;
989
999
  z-index: 2147483647;
1000
+ pointer-events: auto;
990
1001
  width: 360px;
991
1002
  max-width: calc(100vw - 48px);
992
1003
  background: #ffffff;
@@ -1179,6 +1190,7 @@ const _ = (
1179
1190
  position: fixed;
1180
1191
  inset: 0;
1181
1192
  z-index: 2147483647;
1193
+ pointer-events: auto;
1182
1194
  background: rgba(0, 0, 0, 0.7);
1183
1195
  display: flex;
1184
1196
  flex-direction: column;
@@ -1276,6 +1288,7 @@ const _ = (
1276
1288
  bottom: 100px;
1277
1289
  right: 24px;
1278
1290
  z-index: 2147483646;
1291
+ pointer-events: auto;
1279
1292
  background: #fff;
1280
1293
  border-radius: 12px;
1281
1294
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
@@ -1434,7 +1447,7 @@ class X {
1434
1447
  console.warn("[FirstLook] SDK already initialized.");
1435
1448
  return;
1436
1449
  }
1437
- 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);
1438
1451
  }
1439
1452
  /**
1440
1453
  * Manually activate the SDK UI (bypassing triggers).
@@ -1457,7 +1470,7 @@ class X {
1457
1470
  this.config,
1458
1471
  this.events,
1459
1472
  this.fieldMasker.getCombinedSelector()
1460
- ), 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, {
1461
1474
  onOkWithFeedback: (i) => this.handleQuestOk(i),
1462
1475
  onConcern: (i) => this.handleConcern(i),
1463
1476
  onNg: () => this.handleQuestNg(),
@@ -1550,24 +1563,25 @@ class X {
1550
1563
  * Completely destroy the SDK instance and clean up all resources.
1551
1564
  */
1552
1565
  destroy() {
1553
- var t, e, s, i, n, o, l, c, d, h, p;
1554
- 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";
1555
1569
  }
1556
1570
  // ----------------------------------------------------------------
1557
1571
  // Private methods
1558
1572
  // ----------------------------------------------------------------
1559
1573
  createShadowHost() {
1560
- this.hostElement = document.createElement("div"), this.hostElement.id = "firstlook-sdk-root", this.hostElement.style.cssText = "position:fixed;top:0;left:0;width:0;height:0;z-index:2147483647;", document.body.appendChild(this.hostElement), this.shadowRoot = this.hostElement.attachShadow({ mode: "closed" });
1574
+ 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" });
1561
1575
  const t = document.createElement("style");
1562
1576
  t.textContent = _, this.shadowRoot.appendChild(t);
1563
1577
  }
1564
1578
  setupTriggers() {
1565
1579
  const t = this.config.triggers;
1566
- 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();
1580
+ 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();
1567
1581
  }
1568
1582
  onActivate() {
1569
1583
  var t, e, s;
1570
- 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, {
1584
+ 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, {
1571
1585
  onStartSession: () => {
1572
1586
  this.events.emit({ type: "sdk:activated" });
1573
1587
  },