@firstlook-uat/sdk 0.3.2 → 0.4.0
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/firstlook.es.js +88 -115
- package/dist/firstlook.es.js.map +1 -1
- package/dist/firstlook.umd.js +3 -3
- package/dist/firstlook.umd.js.map +1 -1
- package/package.json +14 -13
package/dist/firstlook.es.js
CHANGED
|
@@ -4,8 +4,8 @@ const T = [
|
|
|
4
4
|
"[data-mask]",
|
|
5
5
|
".uat-mask"
|
|
6
6
|
];
|
|
7
|
-
function
|
|
8
|
-
var t, e, s, i, n, o, l, c,
|
|
7
|
+
function q(a) {
|
|
8
|
+
var t, e, s, i, n, o, l, c, h, d;
|
|
9
9
|
if (!a.endpoint)
|
|
10
10
|
throw new Error("[FirstLook] 'endpoint' is required. Set your Supabase ingest-session URL.");
|
|
11
11
|
return {
|
|
@@ -18,19 +18,18 @@ function C(a) {
|
|
|
18
18
|
triggers: {
|
|
19
19
|
tapCount: ((t = a.triggers) == null ? void 0 : t.tapCount) ?? 5,
|
|
20
20
|
deepLink: ((e = a.triggers) == null ? void 0 : e.deepLink) ?? !0,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
customCheck: (n = a.triggers) == null ? void 0 : n.customCheck
|
|
21
|
+
keyboard: ((s = a.triggers) == null ? void 0 : s.keyboard) ?? !0,
|
|
22
|
+
customCheck: (i = a.triggers) == null ? void 0 : i.customCheck
|
|
24
23
|
},
|
|
25
24
|
security: {
|
|
26
|
-
watermark: ((
|
|
27
|
-
maskSelectors: ((
|
|
25
|
+
watermark: ((n = a.security) == null ? void 0 : n.watermark) ?? !0,
|
|
26
|
+
maskSelectors: ((o = a.security) == null ? void 0 : o.maskSelectors) ?? T
|
|
28
27
|
},
|
|
29
28
|
recording: {
|
|
30
|
-
domSnapshot: ((
|
|
31
|
-
voice: ((
|
|
29
|
+
domSnapshot: ((l = a.recording) == null ? void 0 : l.domSnapshot) ?? !0,
|
|
30
|
+
voice: ((c = a.recording) == null ? void 0 : c.voice) ?? !0,
|
|
32
31
|
maxDuration: ((h = a.recording) == null ? void 0 : h.maxDuration) ?? 600,
|
|
33
|
-
snapshotInterval: ((
|
|
32
|
+
snapshotInterval: ((d = a.recording) == null ? void 0 : d.snapshotInterval) ?? 1e3
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
35
|
}
|
|
@@ -45,7 +44,7 @@ function w() {
|
|
|
45
44
|
touchSupport: "ontouchstart" in window || navigator.maxTouchPoints > 0
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
class
|
|
47
|
+
class C {
|
|
49
48
|
constructor() {
|
|
50
49
|
this.listeners = /* @__PURE__ */ new Map();
|
|
51
50
|
}
|
|
@@ -164,13 +163,13 @@ function r(a, t, e) {
|
|
|
164
163
|
function M() {
|
|
165
164
|
return `fl_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
166
165
|
}
|
|
167
|
-
function
|
|
166
|
+
function R(a) {
|
|
168
167
|
const t = Math.floor(a / 60), e = a % 60;
|
|
169
168
|
return `${t.toString().padStart(2, "0")}:${e.toString().padStart(2, "0")}`;
|
|
170
169
|
}
|
|
171
|
-
class
|
|
170
|
+
class E {
|
|
172
171
|
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";
|
|
172
|
+
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
173
|
for (const s of ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"])
|
|
175
174
|
this.root.addEventListener(s, (i) => i.stopPropagation());
|
|
176
175
|
this.shadowRoot.appendChild(this.root);
|
|
@@ -186,8 +185,8 @@ class R {
|
|
|
186
185
|
]);
|
|
187
186
|
this.root.appendChild(n);
|
|
188
187
|
const o = r("div", { className: "fl-quest-content" }), l = r("div", { className: "fl-quest-progress" });
|
|
189
|
-
for (const
|
|
190
|
-
const g =
|
|
188
|
+
for (const f of e) {
|
|
189
|
+
const g = f === "COMPLETED" ? "fl-completed" : f === "FAILED" ? "fl-failed" : f === "ACTIVE" ? "fl-active" : "";
|
|
191
190
|
l.appendChild(r("div", { className: `fl-quest-progress-dot ${g}` }));
|
|
192
191
|
}
|
|
193
192
|
const c = r("div", { className: "fl-quest-body" }, [
|
|
@@ -208,16 +207,16 @@ class R {
|
|
|
208
207
|
"Recording..."
|
|
209
208
|
])
|
|
210
209
|
);
|
|
211
|
-
const
|
|
212
|
-
s &&
|
|
210
|
+
const h = r("div", { className: "fl-status-bar" });
|
|
211
|
+
s && h.appendChild(
|
|
213
212
|
r("span", { className: "fl-status-recording" }, [
|
|
214
213
|
r("span", { className: "fl-voice-dot" }),
|
|
215
214
|
"REC"
|
|
216
215
|
])
|
|
217
216
|
);
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
this.minimized && (this.minimized = !1, this.root.className = "fl-quest-overlay", this.root.innerHTML = "", this.root.appendChild(n), this.root.appendChild(o), this.startTimer(
|
|
217
|
+
const d = r("span", { className: "fl-status-timer" }, ["00:00"]);
|
|
218
|
+
h.appendChild(d), o.appendChild(h), this.root.appendChild(o), this.startTimer(d), this.root.onclick = () => {
|
|
219
|
+
this.minimized && (this.minimized = !1, this.root.className = "fl-quest-overlay", this.root.innerHTML = "", this.root.appendChild(n), this.root.appendChild(o), this.startTimer(d));
|
|
221
220
|
};
|
|
222
221
|
}
|
|
223
222
|
renderFeedbackModal(t, e = "memo") {
|
|
@@ -243,19 +242,19 @@ class R {
|
|
|
243
242
|
])
|
|
244
243
|
]);
|
|
245
244
|
s.appendChild(l);
|
|
246
|
-
const c = r("div", { className: "fl-quest-content" }),
|
|
245
|
+
const c = r("div", { className: "fl-quest-content" }), h = {
|
|
247
246
|
ng: "何がうまくいかなかったか教えてください...",
|
|
248
247
|
ok: "コメント(任意)",
|
|
249
248
|
concern: "気になった点を教えてください...",
|
|
250
249
|
memo: "気づいたことをメモ...📝"
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
const
|
|
250
|
+
}, d = document.createElement("textarea");
|
|
251
|
+
d.className = "fl-feedback-textarea fl-feedback-textarea-modal", d.placeholder = h[e], d.rows = 3, c.appendChild(d);
|
|
252
|
+
const f = "送信", g = e === "ok" ? "スキップ" : "キャンセル", p = r("div", { className: "fl-quest-actions fl-feedback-modal-actions" }, [
|
|
254
253
|
this.createButton("fl-btn fl-btn-skip", g, () => {
|
|
255
254
|
e === "ng" ? this.callbacks.onNgWithFeedback("") : e === "ok" && this.callbacks.onOkWithFeedback(""), s.remove();
|
|
256
255
|
}),
|
|
257
|
-
this.createButton("fl-btn fl-btn-finish",
|
|
258
|
-
const m =
|
|
256
|
+
this.createButton("fl-btn fl-btn-finish", f, () => {
|
|
257
|
+
const m = d.value.trim();
|
|
259
258
|
if (e === "ng")
|
|
260
259
|
this.callbacks.onNgWithFeedback(m);
|
|
261
260
|
else if (e === "ok")
|
|
@@ -273,7 +272,7 @@ class R {
|
|
|
273
272
|
s.remove();
|
|
274
273
|
})
|
|
275
274
|
]);
|
|
276
|
-
c.appendChild(
|
|
275
|
+
c.appendChild(p), s.appendChild(c), this.root.appendChild(s), d.focus();
|
|
277
276
|
}
|
|
278
277
|
renderSummary(t, e, s) {
|
|
279
278
|
this.stopTimer(), this.root.className = "fl-quest-overlay", this.root.innerHTML = "";
|
|
@@ -331,7 +330,7 @@ class R {
|
|
|
331
330
|
startTimer(t) {
|
|
332
331
|
this.stopTimer(), this.startTime || (this.startTime = Date.now()), this.timerInterval = setInterval(() => {
|
|
333
332
|
const e = Math.floor((Date.now() - this.startTime) / 1e3);
|
|
334
|
-
t.textContent =
|
|
333
|
+
t.textContent = R(e);
|
|
335
334
|
}, 1e3);
|
|
336
335
|
}
|
|
337
336
|
stopTimer() {
|
|
@@ -371,7 +370,7 @@ class D {
|
|
|
371
370
|
const e = t.target;
|
|
372
371
|
this.addLog({
|
|
373
372
|
type: "click",
|
|
374
|
-
target:
|
|
373
|
+
target: x(e)
|
|
375
374
|
});
|
|
376
375
|
}
|
|
377
376
|
onScroll() {
|
|
@@ -383,12 +382,12 @@ class D {
|
|
|
383
382
|
onInput(t) {
|
|
384
383
|
const e = t.target;
|
|
385
384
|
if (e.hasAttribute("data-fl-masked"))
|
|
386
|
-
this.addLog({ type: "input", target:
|
|
385
|
+
this.addLog({ type: "input", target: x(e), value: "[MASKED]" });
|
|
387
386
|
else {
|
|
388
387
|
const s = e.value;
|
|
389
388
|
this.addLog({
|
|
390
389
|
type: "input",
|
|
391
|
-
target:
|
|
390
|
+
target: x(e),
|
|
392
391
|
value: s == null ? void 0 : s.slice(0, 100)
|
|
393
392
|
});
|
|
394
393
|
}
|
|
@@ -423,7 +422,7 @@ class D {
|
|
|
423
422
|
};
|
|
424
423
|
}
|
|
425
424
|
}
|
|
426
|
-
function
|
|
425
|
+
function x(a) {
|
|
427
426
|
var n;
|
|
428
427
|
const t = a.tagName.toLowerCase(), e = a.id ? `#${a.id}` : "", s = a.className && typeof a.className == "string" ? `.${a.className.trim().split(/\s+/).slice(0, 2).join(".")}` : "", i = ((n = a.textContent) == null ? void 0 : n.trim().slice(0, 30)) || "";
|
|
429
428
|
return `${t}${e}${s}${i ? ` "${i}"` : ""}`;
|
|
@@ -511,9 +510,9 @@ class F {
|
|
|
511
510
|
this.container.innerHTML = "";
|
|
512
511
|
const t = this.cachedIp ?? "", e = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19), s = t ? `${this.config.userId} | ${e} | ${t}` : `${this.config.userId} | ${e}`, i = 320, n = 80, o = Math.ceil(window.innerWidth / i) + 1, l = Math.ceil(window.innerHeight / n) + 1;
|
|
513
512
|
for (let c = 0; c < l; c++)
|
|
514
|
-
for (let
|
|
515
|
-
const
|
|
516
|
-
|
|
513
|
+
for (let h = 0; h < o; h++) {
|
|
514
|
+
const d = document.createElement("span");
|
|
515
|
+
d.className = "fl-watermark-tile", d.textContent = s, d.style.left = `${h * i}px`, d.style.top = `${c * n}px`, this.container.appendChild(d);
|
|
517
516
|
}
|
|
518
517
|
}
|
|
519
518
|
}
|
|
@@ -673,8 +672,8 @@ class Q {
|
|
|
673
672
|
async getAllByIndex(t, e, s) {
|
|
674
673
|
const i = this.ensureDb();
|
|
675
674
|
return new Promise((n, o) => {
|
|
676
|
-
const
|
|
677
|
-
|
|
675
|
+
const h = i.transaction(t, "readonly").objectStore(t).index(e).getAll(s);
|
|
676
|
+
h.onsuccess = () => n(h.result), h.onerror = () => o(h.error);
|
|
678
677
|
});
|
|
679
678
|
}
|
|
680
679
|
}
|
|
@@ -694,10 +693,10 @@ class B {
|
|
|
694
693
|
placeholder: "Add a comment..."
|
|
695
694
|
}), i = r("div", { className: "fl-color-picker" });
|
|
696
695
|
for (const c of y) {
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
this.selectedColor = c, i.querySelectorAll(".fl-color-swatch").forEach((
|
|
700
|
-
}, i.appendChild(
|
|
696
|
+
const h = r("div", { className: `fl-color-swatch ${c === this.selectedColor ? "fl-selected" : ""}` });
|
|
697
|
+
h.style.background = c, h.onclick = () => {
|
|
698
|
+
this.selectedColor = c, i.querySelectorAll(".fl-color-swatch").forEach((d) => d.classList.remove("fl-selected")), h.classList.add("fl-selected");
|
|
699
|
+
}, i.appendChild(h);
|
|
701
700
|
}
|
|
702
701
|
const n = r("button", { className: "fl-btn fl-btn-ok" }, ["Submit"]);
|
|
703
702
|
n.onclick = () => {
|
|
@@ -731,28 +730,28 @@ class B {
|
|
|
731
730
|
const t = window.innerWidth, e = window.innerHeight, s = document.documentElement.cloneNode(!0), i = s.querySelector("#firstlook-sdk-root");
|
|
732
731
|
i == null || i.remove();
|
|
733
732
|
const n = s.querySelectorAll('[data-fl-masked], input[type="password"]');
|
|
734
|
-
for (const
|
|
735
|
-
(
|
|
736
|
-
for (const
|
|
733
|
+
for (const p of n)
|
|
734
|
+
(p instanceof HTMLInputElement || p instanceof HTMLTextAreaElement) && (p.value = "[MASKED]"), p.textContent = "[MASKED]";
|
|
735
|
+
for (const p of s.querySelectorAll("script")) p.remove();
|
|
737
736
|
const o = s.querySelector("body");
|
|
738
737
|
if (o) {
|
|
739
|
-
const
|
|
740
|
-
o.style.backgroundColor =
|
|
738
|
+
const p = window.getComputedStyle(document.body);
|
|
739
|
+
o.style.backgroundColor = p.backgroundColor, o.style.color = p.color, o.style.fontFamily = p.fontFamily, o.style.margin = "0", o.style.overflow = "hidden";
|
|
741
740
|
}
|
|
742
741
|
const l = new XMLSerializer().serializeToString(s), c = `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}">
|
|
743
742
|
<foreignObject width="100%" height="100%">
|
|
744
743
|
${l}
|
|
745
744
|
</foreignObject>
|
|
746
|
-
</svg>`,
|
|
747
|
-
|
|
748
|
-
const g =
|
|
749
|
-
return g.scale(window.devicePixelRatio, window.devicePixelRatio), new Promise((
|
|
745
|
+
</svg>`, h = new Blob([c], { type: "image/svg+xml;charset=utf-8" }), d = URL.createObjectURL(h), f = document.createElement("canvas");
|
|
746
|
+
f.width = t * window.devicePixelRatio, f.height = e * window.devicePixelRatio;
|
|
747
|
+
const g = f.getContext("2d");
|
|
748
|
+
return g.scale(window.devicePixelRatio, window.devicePixelRatio), new Promise((p) => {
|
|
750
749
|
const m = new Image();
|
|
751
750
|
m.onload = () => {
|
|
752
|
-
g.drawImage(m, 0, 0, t, e), URL.revokeObjectURL(
|
|
751
|
+
g.drawImage(m, 0, 0, t, e), URL.revokeObjectURL(d), p(f.toDataURL("image/png"));
|
|
753
752
|
}, m.onerror = () => {
|
|
754
|
-
URL.revokeObjectURL(
|
|
755
|
-
}, m.src =
|
|
753
|
+
URL.revokeObjectURL(d), p(this.captureScreenshotFallback(t, e));
|
|
754
|
+
}, m.src = d;
|
|
756
755
|
});
|
|
757
756
|
} catch {
|
|
758
757
|
return this.captureScreenshotFallback(window.innerWidth, window.innerHeight);
|
|
@@ -798,43 +797,16 @@ class B {
|
|
|
798
797
|
}
|
|
799
798
|
}
|
|
800
799
|
class U {
|
|
801
|
-
constructor(t) {
|
|
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
|
-
}
|
|
804
|
-
async start() {
|
|
805
|
-
if (typeof DeviceMotionEvent.requestPermission == "function")
|
|
806
|
-
try {
|
|
807
|
-
if (await DeviceMotionEvent.requestPermission() !== "granted") return;
|
|
808
|
-
} catch {
|
|
809
|
-
return;
|
|
810
|
-
}
|
|
811
|
-
this.handler = this.onMotion.bind(this), window.addEventListener("devicemotion", this.handler, { passive: !0 });
|
|
812
|
-
}
|
|
813
|
-
stop() {
|
|
814
|
-
this.handler && (window.removeEventListener("devicemotion", this.handler), this.handler = null);
|
|
815
|
-
}
|
|
816
|
-
onMotion(t) {
|
|
817
|
-
const e = t.accelerationIncludingGravity;
|
|
818
|
-
if (!e || e.x == null || e.y == null || e.z == null) return;
|
|
819
|
-
const s = Math.abs(e.x - this.lastX), i = Math.abs(e.y - this.lastY), n = Math.abs(e.z - this.lastZ);
|
|
820
|
-
if (s + i + n > this.THRESHOLD) {
|
|
821
|
-
const o = Date.now();
|
|
822
|
-
o - this.lastShakeTime < this.SHAKE_INTERVAL ? (this.shakeCount++, this.shakeCount >= this.REQUIRED_SHAKES && (this.shakeCount = 0, this.onShake())) : this.shakeCount = 1, this.lastShakeTime = o;
|
|
823
|
-
}
|
|
824
|
-
this.lastX = e.x, this.lastY = e.y, this.lastZ = e.z;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
class j {
|
|
828
800
|
constructor(t, e) {
|
|
829
801
|
this.shadowRoot = t, this.events = e, this.annotations = [], this.active = !1, this.onKeydown = (s) => {
|
|
830
802
|
s.ctrlKey && s.shiftKey && s.key === "R" && (s.preventDefault(), this.trigger());
|
|
831
|
-
}, this.annotationCanvas = new B(t)
|
|
803
|
+
}, this.annotationCanvas = new B(t);
|
|
832
804
|
}
|
|
833
|
-
|
|
834
|
-
|
|
805
|
+
start() {
|
|
806
|
+
document.addEventListener("keydown", this.onKeydown);
|
|
835
807
|
}
|
|
836
808
|
stop() {
|
|
837
|
-
|
|
809
|
+
document.removeEventListener("keydown", this.onKeydown);
|
|
838
810
|
}
|
|
839
811
|
getAnnotations() {
|
|
840
812
|
return [...this.annotations];
|
|
@@ -851,7 +823,7 @@ class j {
|
|
|
851
823
|
}
|
|
852
824
|
}
|
|
853
825
|
}
|
|
854
|
-
class
|
|
826
|
+
class j {
|
|
855
827
|
constructor(t, e) {
|
|
856
828
|
this.requiredTaps = t, this.onActivate = e, this.tapCount = 0, this.tapTimer = null, this.handler = null;
|
|
857
829
|
}
|
|
@@ -868,7 +840,7 @@ class $ {
|
|
|
868
840
|
this.tapCount = 0, this.tapTimer && (clearTimeout(this.tapTimer), this.tapTimer = null);
|
|
869
841
|
}
|
|
870
842
|
}
|
|
871
|
-
const
|
|
843
|
+
const k = "firstlook:uat-active";
|
|
872
844
|
class S {
|
|
873
845
|
constructor(t) {
|
|
874
846
|
this.onActivate = t, this.handlers = [];
|
|
@@ -894,7 +866,7 @@ class S {
|
|
|
894
866
|
}
|
|
895
867
|
static clearPersisted() {
|
|
896
868
|
try {
|
|
897
|
-
sessionStorage.removeItem(
|
|
869
|
+
sessionStorage.removeItem(k);
|
|
898
870
|
} catch {
|
|
899
871
|
}
|
|
900
872
|
}
|
|
@@ -912,19 +884,19 @@ class S {
|
|
|
912
884
|
}
|
|
913
885
|
persist() {
|
|
914
886
|
try {
|
|
915
|
-
sessionStorage.setItem(
|
|
887
|
+
sessionStorage.setItem(k, "1");
|
|
916
888
|
} catch {
|
|
917
889
|
}
|
|
918
890
|
}
|
|
919
891
|
hasPersisted() {
|
|
920
892
|
try {
|
|
921
|
-
return sessionStorage.getItem(
|
|
893
|
+
return sessionStorage.getItem(k) === "1";
|
|
922
894
|
} catch {
|
|
923
895
|
return !1;
|
|
924
896
|
}
|
|
925
897
|
}
|
|
926
898
|
}
|
|
927
|
-
class
|
|
899
|
+
class $ {
|
|
928
900
|
constructor(t) {
|
|
929
901
|
this.onActivate = t, this.handler = null;
|
|
930
902
|
}
|
|
@@ -937,13 +909,13 @@ class K {
|
|
|
937
909
|
this.handler && (window.removeEventListener("keydown", this.handler), this.handler = null);
|
|
938
910
|
}
|
|
939
911
|
}
|
|
940
|
-
class
|
|
912
|
+
class K {
|
|
941
913
|
constructor(t, e) {
|
|
942
914
|
this.shadowRoot = t, this.callbacks = e, this.root = null, this.outsideClickHandler = null;
|
|
943
915
|
}
|
|
944
916
|
show() {
|
|
945
917
|
if (this.root) return;
|
|
946
|
-
this.root = r("div", { className: "fl-debug-menu" });
|
|
918
|
+
this.root = r("div", { className: "fl-debug-menu" }), this.root.style.pointerEvents = "auto";
|
|
947
919
|
for (const e of ["click", "mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"])
|
|
948
920
|
this.root.addEventListener(e, (s) => s.stopPropagation());
|
|
949
921
|
const t = [
|
|
@@ -974,7 +946,7 @@ class H {
|
|
|
974
946
|
return this.root !== null;
|
|
975
947
|
}
|
|
976
948
|
}
|
|
977
|
-
const
|
|
949
|
+
const H = (
|
|
978
950
|
/* css */
|
|
979
951
|
`
|
|
980
952
|
:host {
|
|
@@ -1430,10 +1402,10 @@ const _ = (
|
|
|
1430
1402
|
}
|
|
1431
1403
|
.fl-feedback-modal-actions { padding: 0 16px 16px; }
|
|
1432
1404
|
`
|
|
1433
|
-
),
|
|
1434
|
-
class
|
|
1405
|
+
), _ = 5;
|
|
1406
|
+
class W {
|
|
1435
1407
|
constructor() {
|
|
1436
|
-
this.config = null, this.events = new
|
|
1408
|
+
this.config = null, this.events = new C(), 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;
|
|
1437
1409
|
}
|
|
1438
1410
|
// ----------------------------------------------------------------
|
|
1439
1411
|
// Public API
|
|
@@ -1447,7 +1419,7 @@ class X {
|
|
|
1447
1419
|
console.warn("[FirstLook] SDK already initialized.");
|
|
1448
1420
|
return;
|
|
1449
1421
|
}
|
|
1450
|
-
this.config =
|
|
1422
|
+
this.config = q(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);
|
|
1451
1423
|
}
|
|
1452
1424
|
/**
|
|
1453
1425
|
* Manually activate the SDK UI (bypassing triggers).
|
|
@@ -1470,7 +1442,7 @@ class X {
|
|
|
1470
1442
|
this.config,
|
|
1471
1443
|
this.events,
|
|
1472
1444
|
this.fieldMasker.getCombinedSelector()
|
|
1473
|
-
), this.voiceRecorder = new N(this.events), this.
|
|
1445
|
+
), this.voiceRecorder = new N(this.events), this.issueReporter = new U(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 F(this.shadowRoot, this.config), this.watermark.show()), this.questOverlay = new E(this.shadowRoot, {
|
|
1474
1446
|
onOkWithFeedback: (i) => this.handleQuestOk(i),
|
|
1475
1447
|
onConcern: (i) => this.handleConcern(i),
|
|
1476
1448
|
onNg: () => this.handleQuestNg(),
|
|
@@ -1503,9 +1475,9 @@ class X {
|
|
|
1503
1475
|
* End the current session, persist data, and trigger upload.
|
|
1504
1476
|
*/
|
|
1505
1477
|
async endSession() {
|
|
1506
|
-
var i, n, o, l, c,
|
|
1478
|
+
var i, n, o, l, c, h, d, f, g, p, m;
|
|
1507
1479
|
if (this.state !== "recording" || !this.sessionId) return null;
|
|
1508
|
-
this.maxDurationTimer && (clearTimeout(this.maxDurationTimer), this.maxDurationTimer = null), this.backupTimer && (clearInterval(this.backupTimer), this.backupTimer = null), (i = this.sessionRecorder) == null || i.stop(), await ((n = this.voiceRecorder) == null ? void 0 : n.stopAsync()), (o = this.
|
|
1480
|
+
this.maxDurationTimer && (clearTimeout(this.maxDurationTimer), this.maxDurationTimer = null), this.backupTimer && (clearInterval(this.backupTimer), this.backupTimer = null), (i = this.sessionRecorder) == null || i.stop(), await ((n = this.voiceRecorder) == null ? void 0 : n.stopAsync()), (o = this.issueReporter) == null || o.stop(), (l = this.fieldMasker) == null || l.stop(), (c = this.watermark) == null || c.hide();
|
|
1509
1481
|
const t = this.questManager.getResults();
|
|
1510
1482
|
await Promise.allSettled(
|
|
1511
1483
|
t.map(async (b) => {
|
|
@@ -1539,13 +1511,13 @@ class X {
|
|
|
1539
1511
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1540
1512
|
duration: Math.floor((Date.now() - this.sessionStartTime) / 1e3),
|
|
1541
1513
|
quests: t,
|
|
1542
|
-
recordings: ((
|
|
1514
|
+
recordings: ((h = this.sessionRecorder) == null ? void 0 : h.getSnapshots()) ?? []
|
|
1543
1515
|
};
|
|
1544
|
-
await ((
|
|
1545
|
-
const s = ((
|
|
1516
|
+
await ((d = this.storage) == null ? void 0 : d.saveSession(e));
|
|
1517
|
+
const s = ((f = this.issueReporter) == null ? void 0 : f.getAnnotations()) ?? [];
|
|
1546
1518
|
for (const b of s)
|
|
1547
1519
|
await ((g = this.storage) == null ? void 0 : g.saveAnnotation(this.sessionId, b));
|
|
1548
|
-
return await ((
|
|
1520
|
+
return await ((p = this.storage) == null ? void 0 : p.enqueueUpload({ session: e, annotations: s })), (m = this.questOverlay) == null || m.destroy(), this.questOverlay = null, this.state = "finished", this.events.emit({ type: "session:ended", sessionId: this.sessionId }), this.flushUploadQueue(!1), e;
|
|
1549
1521
|
}
|
|
1550
1522
|
/**
|
|
1551
1523
|
* Subscribe to SDK events.
|
|
@@ -1563,31 +1535,32 @@ class X {
|
|
|
1563
1535
|
* Completely destroy the SDK instance and clean up all resources.
|
|
1564
1536
|
*/
|
|
1565
1537
|
destroy() {
|
|
1566
|
-
var t, e, s, i, n, o, l, c,
|
|
1538
|
+
var t, e, s, i, n, o, l, c, h, d, f, g;
|
|
1567
1539
|
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.
|
|
1540
|
+
}), (o = this.issueReporter) == null || o.stop(), (l = this.fieldMasker) == null || l.stop(), (c = this.watermark) == null || c.hide(), (h = this.questOverlay) == null || h.destroy(), (d = this.debugMenu) == null || d.hide(), (f = this.hostElement) == null || f.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.issueReporter = 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";
|
|
1569
1541
|
}
|
|
1570
1542
|
// ----------------------------------------------------------------
|
|
1571
1543
|
// Private methods
|
|
1572
1544
|
// ----------------------------------------------------------------
|
|
1573
1545
|
createShadowHost() {
|
|
1574
|
-
|
|
1546
|
+
var e;
|
|
1547
|
+
(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" });
|
|
1575
1548
|
const t = document.createElement("style");
|
|
1576
|
-
t.textContent =
|
|
1549
|
+
t.textContent = H, this.shadowRoot.appendChild(t);
|
|
1577
1550
|
}
|
|
1578
1551
|
setupTriggers() {
|
|
1579
1552
|
const t = this.config.triggers;
|
|
1580
|
-
this.tapTrigger = new
|
|
1553
|
+
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
1554
|
}
|
|
1582
1555
|
onActivate() {
|
|
1583
1556
|
var t, e, s;
|
|
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
|
|
1557
|
+
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
1558
|
onStartSession: () => {
|
|
1586
1559
|
this.events.emit({ type: "sdk:activated" });
|
|
1587
1560
|
},
|
|
1588
1561
|
onReportIssue: () => {
|
|
1589
|
-
var i
|
|
1590
|
-
(
|
|
1562
|
+
var i;
|
|
1563
|
+
(i = this.issueReporter) == null || i.trigger();
|
|
1591
1564
|
},
|
|
1592
1565
|
onClose: () => {
|
|
1593
1566
|
this.destroy();
|
|
@@ -1659,7 +1632,7 @@ class X {
|
|
|
1659
1632
|
}
|
|
1660
1633
|
const e = await this.storage.getPendingUploads();
|
|
1661
1634
|
for (const s of e) {
|
|
1662
|
-
if (s.attempts >=
|
|
1635
|
+
if (s.attempts >= _) {
|
|
1663
1636
|
await this.storage.removeFromQueue(s.key);
|
|
1664
1637
|
continue;
|
|
1665
1638
|
}
|
|
@@ -1713,6 +1686,6 @@ class X {
|
|
|
1713
1686
|
}
|
|
1714
1687
|
}
|
|
1715
1688
|
export {
|
|
1716
|
-
|
|
1689
|
+
W as FirstLookSDK
|
|
1717
1690
|
};
|
|
1718
1691
|
//# sourceMappingURL=firstlook.es.js.map
|