@liforma/client 0.4.3 → 0.4.5
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/CHANGELOG.md +24 -0
- package/dist/next/index.js +470 -377
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/next/index.d.ts +8 -1
- package/dist/next/next/index.d.ts.map +1 -1
- package/dist/next/v2/api/captureAttribution.d.ts +10 -0
- package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/next/v2/embed/iframeHost.d.ts +2 -0
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +14 -0
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +16 -1
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +5 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/next/v2/types/sessionManifest.d.ts +12 -0
- package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/index.js +562 -475
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
- package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/npm/v2/embed/iframeHost.d.ts +2 -0
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +14 -0
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +16 -1
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +5 -0
- package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/v2/speechOnlyManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifest.d.ts +12 -0
- package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +28 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +4 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +689 -592
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/v2/api/captureAttribution.d.ts +10 -0
- package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/react/v2/embed/iframeHost.d.ts +2 -0
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +14 -0
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +16 -1
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +5 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/react/v2/types/sessionManifest.d.ts +12 -0
- package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +15 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -57,7 +57,7 @@ function v(e = {}) {
|
|
|
57
57
|
if (t instanceof Response) return t;
|
|
58
58
|
}
|
|
59
59
|
let v = { experienceId: u }, y = l?.locale?.trim() || l?.language?.trim();
|
|
60
|
-
y && (v.locale = y), l?.mode && (v.mode = l.mode), l?.speechInputMode && (v.speechInputMode = l.speechInputMode), l?.speechOnly === !0 && (v.speechOnly = !0), l?.speechOnly === !1 && (v.speechOnly = !1), l?.processorId?.trim() && (v.processorId = l.processorId.trim());
|
|
60
|
+
y && (v.locale = y), l?.mode && (v.mode = l.mode), l?.speechInputMode && (v.speechInputMode = l.speechInputMode), l?.speechOnly === !0 && (v.speechOnly = !0), l?.speechOnly === !1 && (v.speechOnly = !1), l?.processorId?.trim() && (v.processorId = l.processorId.trim()), l?.attribution && typeof l.attribution == "object" && (v.attribution = l.attribution);
|
|
61
61
|
let b = i.headers.get("Idempotency-Key")?.trim(), x = await r(`${o}/v1/sessions`, {
|
|
62
62
|
method: "POST",
|
|
63
63
|
headers: {
|
|
@@ -470,11 +470,11 @@ function pe(s) {
|
|
|
470
470
|
onPointerLeave: () => {
|
|
471
471
|
P.current || (I(!1), L || (B(0), V(0)));
|
|
472
472
|
}
|
|
473
|
-
},
|
|
473
|
+
}, Te = (e) => {
|
|
474
474
|
N.current = e;
|
|
475
475
|
};
|
|
476
476
|
return k === "anchor" && G ? /* @__PURE__ */ a("a", {
|
|
477
|
-
ref:
|
|
477
|
+
ref: Te,
|
|
478
478
|
className: xe,
|
|
479
479
|
style: Se,
|
|
480
480
|
href: G,
|
|
@@ -486,7 +486,7 @@ function pe(s) {
|
|
|
486
486
|
children: we
|
|
487
487
|
}) : k === "button" ? /* @__PURE__ */ a("button", {
|
|
488
488
|
type: "button",
|
|
489
|
-
ref:
|
|
489
|
+
ref: Te,
|
|
490
490
|
className: xe,
|
|
491
491
|
style: Se,
|
|
492
492
|
"aria-label": f,
|
|
@@ -494,7 +494,7 @@ function pe(s) {
|
|
|
494
494
|
...J,
|
|
495
495
|
children: we
|
|
496
496
|
}) : /* @__PURE__ */ a("div", {
|
|
497
|
-
ref:
|
|
497
|
+
ref: Te,
|
|
498
498
|
className: xe,
|
|
499
499
|
style: Se,
|
|
500
500
|
role: f ? "img" : void 0,
|
|
@@ -600,20 +600,58 @@ function Se(e, t, n) {
|
|
|
600
600
|
});
|
|
601
601
|
}
|
|
602
602
|
//#endregion
|
|
603
|
+
//#region src/v2/api/captureAttribution.ts
|
|
604
|
+
var Ce = 128, we = /[\u0000-\u001f\u007f]/g;
|
|
605
|
+
function J(e) {
|
|
606
|
+
if (!e) return;
|
|
607
|
+
let t = e.replace(we, "").trim();
|
|
608
|
+
if (t) return t.slice(0, Ce);
|
|
609
|
+
}
|
|
610
|
+
function Te(e) {
|
|
611
|
+
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
612
|
+
return {
|
|
613
|
+
...J(t.get("utm_source")) ? { utmSource: J(t.get("utm_source")) } : {},
|
|
614
|
+
...J(t.get("utm_medium")) ? { utmMedium: J(t.get("utm_medium")) } : {},
|
|
615
|
+
...J(t.get("utm_campaign")) ? { utmCampaign: J(t.get("utm_campaign")) } : {},
|
|
616
|
+
...J(t.get("utm_content")) ? { utmContent: J(t.get("utm_content")) } : {},
|
|
617
|
+
...J(t.get("utm_term")) ? { utmTerm: J(t.get("utm_term")) } : {}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function Ee(e) {
|
|
621
|
+
if (e === !1) return;
|
|
622
|
+
if (e && typeof e == "object") {
|
|
623
|
+
let t = {
|
|
624
|
+
...J(e.utmSource) ? { utmSource: J(e.utmSource) } : {},
|
|
625
|
+
...J(e.utmMedium) ? { utmMedium: J(e.utmMedium) } : {},
|
|
626
|
+
...J(e.utmCampaign) ? { utmCampaign: J(e.utmCampaign) } : {},
|
|
627
|
+
...J(e.utmContent) ? { utmContent: J(e.utmContent) } : {},
|
|
628
|
+
...J(e.utmTerm) ? { utmTerm: J(e.utmTerm) } : {},
|
|
629
|
+
...J(e.referrer) ? { referrer: J(e.referrer) } : {}
|
|
630
|
+
};
|
|
631
|
+
return Object.keys(t).length ? t : void 0;
|
|
632
|
+
}
|
|
633
|
+
if (typeof window > "u") return;
|
|
634
|
+
let t = Te(window.location?.search), n = J(document.referrer || void 0), r = {
|
|
635
|
+
...t,
|
|
636
|
+
...n ? { referrer: n } : {}
|
|
637
|
+
};
|
|
638
|
+
return Object.keys(r).length ? r : void 0;
|
|
639
|
+
}
|
|
640
|
+
//#endregion
|
|
603
641
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
604
|
-
function
|
|
642
|
+
function De(e) {
|
|
605
643
|
let t = e.locale?.trim();
|
|
606
644
|
if (t) return t;
|
|
607
645
|
let n = e.language?.trim();
|
|
608
646
|
if (n) return n;
|
|
609
647
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
610
648
|
}
|
|
611
|
-
function
|
|
649
|
+
function Oe(e) {
|
|
612
650
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
613
651
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
614
652
|
return t || n || void 0;
|
|
615
653
|
}
|
|
616
|
-
function
|
|
654
|
+
function ke(e, t) {
|
|
617
655
|
let n = e.trim();
|
|
618
656
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
619
657
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -621,7 +659,7 @@ function J(e, t) {
|
|
|
621
659
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
622
660
|
let i = t.experienceId.trim();
|
|
623
661
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
624
|
-
let a =
|
|
662
|
+
let a = De(t), o = Oe(t), s = t.idempotencyKey?.trim();
|
|
625
663
|
return {
|
|
626
664
|
url: r.toString(),
|
|
627
665
|
init: {
|
|
@@ -638,7 +676,11 @@ function J(e, t) {
|
|
|
638
676
|
...o ? { secondaryLocale: o } : {},
|
|
639
677
|
...t.mode ? { mode: t.mode } : {},
|
|
640
678
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
641
|
-
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
|
|
679
|
+
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
680
|
+
...(() => {
|
|
681
|
+
let e = Ee(t.attribution);
|
|
682
|
+
return e ? { attribution: e } : {};
|
|
683
|
+
})()
|
|
642
684
|
})
|
|
643
685
|
}
|
|
644
686
|
};
|
|
@@ -651,7 +693,7 @@ function Y(e) {
|
|
|
651
693
|
function X(e) {
|
|
652
694
|
return typeof e == "boolean";
|
|
653
695
|
}
|
|
654
|
-
function
|
|
696
|
+
function Ae(e) {
|
|
655
697
|
if (!Y(e)) return null;
|
|
656
698
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
657
699
|
return !Y(t) || !Y(n) || !Y(r) || !Y(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
@@ -665,7 +707,7 @@ function Te(e) {
|
|
|
665
707
|
tools: { enabled: i.enabled }
|
|
666
708
|
};
|
|
667
709
|
}
|
|
668
|
-
function
|
|
710
|
+
function je(e) {
|
|
669
711
|
return !Y(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
670
712
|
speech: {
|
|
671
713
|
input: e.speechInput,
|
|
@@ -677,12 +719,12 @@ function Ee(e) {
|
|
|
677
719
|
tools: { enabled: e.tools }
|
|
678
720
|
};
|
|
679
721
|
}
|
|
680
|
-
function
|
|
681
|
-
return
|
|
722
|
+
function Me(e) {
|
|
723
|
+
return Ae(e) ?? je(e);
|
|
682
724
|
}
|
|
683
|
-
function
|
|
725
|
+
function Ne(e) {
|
|
684
726
|
if (!Y(e)) throw Error("Session Launch response is missing session.");
|
|
685
|
-
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c =
|
|
727
|
+
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = Me(e.capabilities), l = Pe(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
|
|
686
728
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
687
729
|
return {
|
|
688
730
|
id: t,
|
|
@@ -698,7 +740,7 @@ function Oe(e) {
|
|
|
698
740
|
...d ? { createdAt: d } : {}
|
|
699
741
|
};
|
|
700
742
|
}
|
|
701
|
-
function
|
|
743
|
+
function Pe(e) {
|
|
702
744
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
703
745
|
let t = [];
|
|
704
746
|
for (let n of e) {
|
|
@@ -713,35 +755,35 @@ function ke(e) {
|
|
|
713
755
|
}
|
|
714
756
|
return t.length > 0 ? t : void 0;
|
|
715
757
|
}
|
|
716
|
-
function
|
|
758
|
+
function Fe(e) {
|
|
717
759
|
let t = e.localeVoiceFallbacks;
|
|
718
760
|
if (t?.length) for (let e of t) {
|
|
719
761
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
720
762
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
721
763
|
}
|
|
722
764
|
}
|
|
723
|
-
function
|
|
765
|
+
function Ie(e) {
|
|
724
766
|
if (!Y(e)) throw Error("Session Launch response must be a JSON object.");
|
|
725
767
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
726
768
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
727
|
-
let n =
|
|
728
|
-
return
|
|
769
|
+
let n = Ne(e.session);
|
|
770
|
+
return Fe(n), {
|
|
729
771
|
session: n,
|
|
730
772
|
launch: t
|
|
731
773
|
};
|
|
732
774
|
}
|
|
733
775
|
//#endregion
|
|
734
776
|
//#region src/v2/api/mintPublicSession.ts
|
|
735
|
-
function
|
|
777
|
+
function Le() {
|
|
736
778
|
try {
|
|
737
779
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
738
780
|
} catch {}
|
|
739
781
|
}
|
|
740
|
-
function
|
|
782
|
+
function Re(e) {
|
|
741
783
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
742
784
|
}
|
|
743
|
-
function
|
|
744
|
-
let n =
|
|
785
|
+
function ze(e, t) {
|
|
786
|
+
let n = Le(), r = Re(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
745
787
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
746
788
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
747
789
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
@@ -764,36 +806,38 @@ function Pe(e, t) {
|
|
|
764
806
|
details: a
|
|
765
807
|
}) : t;
|
|
766
808
|
}
|
|
767
|
-
function
|
|
809
|
+
function Be(e) {
|
|
768
810
|
let t = e?.locale?.trim();
|
|
769
811
|
if (t) return t;
|
|
770
812
|
let n = e?.language?.trim();
|
|
771
813
|
if (n) return n;
|
|
772
814
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
773
815
|
}
|
|
774
|
-
function
|
|
816
|
+
function Ve(e) {
|
|
775
817
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
776
818
|
if (t && n && t !== n) throw new q("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
777
819
|
return t || n || void 0;
|
|
778
820
|
}
|
|
779
|
-
function
|
|
780
|
-
let n = { experienceId: e }, r =
|
|
821
|
+
function He(e, t) {
|
|
822
|
+
let n = { experienceId: e }, r = Be(t);
|
|
781
823
|
r && (n.locale = r);
|
|
782
|
-
let i =
|
|
783
|
-
|
|
824
|
+
let i = Ve(t);
|
|
825
|
+
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
826
|
+
let a = Ee(t?.attribution);
|
|
827
|
+
return a && (n.attribution = a), n;
|
|
784
828
|
}
|
|
785
|
-
async function
|
|
829
|
+
async function Ue(e, t) {
|
|
786
830
|
let n = ve(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
787
831
|
method: "POST",
|
|
788
832
|
headers: {
|
|
789
833
|
"Content-Type": "application/json",
|
|
790
834
|
...r ? { "Idempotency-Key": r } : {}
|
|
791
835
|
},
|
|
792
|
-
body: JSON.stringify(
|
|
836
|
+
body: JSON.stringify(He(e, t))
|
|
793
837
|
});
|
|
794
838
|
if (!i.ok) {
|
|
795
839
|
let t = await i.text();
|
|
796
|
-
throw
|
|
840
|
+
throw ze(e, Se(i.status, t, i.headers));
|
|
797
841
|
}
|
|
798
842
|
let a;
|
|
799
843
|
try {
|
|
@@ -805,10 +849,10 @@ async function Re(e, t) {
|
|
|
805
849
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
806
850
|
});
|
|
807
851
|
}
|
|
808
|
-
return
|
|
852
|
+
return Ie(a);
|
|
809
853
|
}
|
|
810
|
-
async function
|
|
811
|
-
let n =
|
|
854
|
+
async function We(e, t) {
|
|
855
|
+
let n = ke(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
812
856
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
813
857
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
814
858
|
try {
|
|
@@ -838,14 +882,14 @@ async function ze(e, t) {
|
|
|
838
882
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
839
883
|
});
|
|
840
884
|
}
|
|
841
|
-
return
|
|
885
|
+
return Ie(s);
|
|
842
886
|
}
|
|
843
887
|
//#endregion
|
|
844
888
|
//#region src/v2/conversationProcessor.ts
|
|
845
|
-
function
|
|
889
|
+
function Ge(e) {
|
|
846
890
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
847
891
|
}
|
|
848
|
-
function
|
|
892
|
+
function Ke(e) {
|
|
849
893
|
if (typeof e == "string") {
|
|
850
894
|
let t = e.trim();
|
|
851
895
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -859,24 +903,24 @@ function Ve(e) {
|
|
|
859
903
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
860
904
|
};
|
|
861
905
|
}
|
|
862
|
-
async function
|
|
906
|
+
async function qe(e, t) {
|
|
863
907
|
let n = await e(t);
|
|
864
|
-
return
|
|
908
|
+
return Ge(n) ? {
|
|
865
909
|
kind: "stream",
|
|
866
910
|
stream: n
|
|
867
911
|
} : {
|
|
868
912
|
kind: "complete",
|
|
869
|
-
speech:
|
|
913
|
+
speech: Ke(n)
|
|
870
914
|
};
|
|
871
915
|
}
|
|
872
916
|
//#endregion
|
|
873
917
|
//#region src/v2/embed/playerReachability.ts
|
|
874
|
-
var
|
|
875
|
-
function
|
|
918
|
+
var Je = "3002";
|
|
919
|
+
function Ye(e) {
|
|
876
920
|
let t = new URL(e);
|
|
877
|
-
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port ||
|
|
921
|
+
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Je}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
|
|
878
922
|
}
|
|
879
|
-
async function
|
|
923
|
+
async function Xe(e, t) {
|
|
880
924
|
try {
|
|
881
925
|
await fetch(e, {
|
|
882
926
|
method: "GET",
|
|
@@ -884,52 +928,30 @@ async function Ge(e, t) {
|
|
|
884
928
|
signal: AbortSignal.timeout(8e3)
|
|
885
929
|
});
|
|
886
930
|
} catch {
|
|
887
|
-
throw Error(
|
|
931
|
+
throw Error(Ye(t));
|
|
888
932
|
}
|
|
889
933
|
}
|
|
890
|
-
function
|
|
934
|
+
function Ze(e, t, n, r) {
|
|
891
935
|
try {
|
|
892
936
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
893
937
|
} catch (e) {
|
|
894
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
var
|
|
898
|
-
function
|
|
899
|
-
return typeof e == "number" &&
|
|
900
|
-
}
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
"stateUpdate",
|
|
904
|
-
"commandResult",
|
|
905
|
-
"userTranscript",
|
|
906
|
-
"characterSpeechStarted",
|
|
907
|
-
"characterSpeechEnded",
|
|
908
|
-
"characterFocusChanged",
|
|
909
|
-
"conversationUpdate",
|
|
910
|
-
"listeningState",
|
|
911
|
-
"userSpeechStarted",
|
|
912
|
-
"userSpeechEnded",
|
|
913
|
-
"modeChange",
|
|
914
|
-
"activityChange",
|
|
915
|
-
"feedback",
|
|
916
|
-
"feedbackFailed",
|
|
917
|
-
"message",
|
|
918
|
-
"started",
|
|
919
|
-
"embedReady",
|
|
920
|
-
"widgetReady",
|
|
921
|
-
"widgetExpand",
|
|
922
|
-
"widgetCollapse",
|
|
923
|
-
"widgetAudioSettings",
|
|
924
|
-
"widgetDragStart",
|
|
925
|
-
"widgetDragMove",
|
|
926
|
-
"widgetDragEnd"
|
|
927
|
-
]);
|
|
928
|
-
function Xe(e) {
|
|
938
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(Ye(n), { cause: e }) : e;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
var Qe = new Set([1, 2]);
|
|
942
|
+
function $e(e) {
|
|
943
|
+
return typeof e == "number" && Qe.has(e);
|
|
944
|
+
}
|
|
945
|
+
var et = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
|
|
946
|
+
function tt(e) {
|
|
929
947
|
if (!e || typeof e != "object") return null;
|
|
930
948
|
let t = e;
|
|
931
|
-
if (
|
|
949
|
+
if (!$e(t.schemaVersion) || !t.type || !et.has(t.type)) return null;
|
|
932
950
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
951
|
+
if (t.type === "fullWindow") {
|
|
952
|
+
let e = t.payload;
|
|
953
|
+
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
954
|
+
}
|
|
933
955
|
if (t.type === "widgetAudioSettings") {
|
|
934
956
|
let e = t.payload;
|
|
935
957
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -947,7 +969,7 @@ function Xe(e) {
|
|
|
947
969
|
let n = t.payload;
|
|
948
970
|
return !n || typeof n != "object" ? null : t;
|
|
949
971
|
}
|
|
950
|
-
function
|
|
972
|
+
function nt(e, t, n) {
|
|
951
973
|
let r = e.trim();
|
|
952
974
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
953
975
|
let i = n?.startButton, a = n?.showFeedback;
|
|
@@ -962,20 +984,20 @@ function Ze(e, t, n) {
|
|
|
962
984
|
}
|
|
963
985
|
};
|
|
964
986
|
}
|
|
965
|
-
function
|
|
987
|
+
function rt() {
|
|
966
988
|
return {
|
|
967
989
|
type: "parentHello",
|
|
968
990
|
schemaVersion: 2
|
|
969
991
|
};
|
|
970
992
|
}
|
|
971
|
-
function
|
|
993
|
+
function it(e) {
|
|
972
994
|
return {
|
|
973
995
|
type: "widgetSetChrome",
|
|
974
996
|
schemaVersion: 2,
|
|
975
997
|
payload: { mode: e }
|
|
976
998
|
};
|
|
977
999
|
}
|
|
978
|
-
function
|
|
1000
|
+
function at() {
|
|
979
1001
|
return {
|
|
980
1002
|
type: "widgetToggleAudioSettings",
|
|
981
1003
|
schemaVersion: 2,
|
|
@@ -983,108 +1005,143 @@ function et() {
|
|
|
983
1005
|
};
|
|
984
1006
|
}
|
|
985
1007
|
//#endregion
|
|
1008
|
+
//#region src/v2/embed/fullWindowHost.ts
|
|
1009
|
+
var ot = "2147483000";
|
|
1010
|
+
function st(e) {
|
|
1011
|
+
let { style: t } = e;
|
|
1012
|
+
return {
|
|
1013
|
+
position: t.position,
|
|
1014
|
+
top: t.top,
|
|
1015
|
+
right: t.right,
|
|
1016
|
+
bottom: t.bottom,
|
|
1017
|
+
left: t.left,
|
|
1018
|
+
inset: t.inset,
|
|
1019
|
+
width: t.width,
|
|
1020
|
+
height: t.height,
|
|
1021
|
+
zIndex: t.zIndex,
|
|
1022
|
+
margin: t.margin,
|
|
1023
|
+
borderRadius: t.borderRadius,
|
|
1024
|
+
maxWidth: t.maxWidth,
|
|
1025
|
+
maxHeight: t.maxHeight
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
function ct(e) {
|
|
1029
|
+
let { style: t } = e;
|
|
1030
|
+
t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex = ot, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1031
|
+
}
|
|
1032
|
+
function lt(e, t) {
|
|
1033
|
+
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1034
|
+
e.style.position = "", e.style.top = "", e.style.right = "", e.style.bottom = "", e.style.left = "", e.style.inset = "", e.style.width = "", e.style.height = "", e.style.zIndex = "", e.style.margin = "", e.style.borderRadius = "", e.style.maxWidth = "", e.style.maxHeight = "";
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
let { style: n } = e;
|
|
1038
|
+
n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
|
|
1039
|
+
}
|
|
1040
|
+
//#endregion
|
|
986
1041
|
//#region src/v2/embed/iframeHost.ts
|
|
987
|
-
function
|
|
1042
|
+
function ut(e) {
|
|
988
1043
|
return e;
|
|
989
1044
|
}
|
|
990
1045
|
function Z() {
|
|
991
1046
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `cmd_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `cmd_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
992
1047
|
}
|
|
993
|
-
var
|
|
994
|
-
function
|
|
1048
|
+
var dt = 3e4;
|
|
1049
|
+
function ft(e) {
|
|
995
1050
|
let t = e.container;
|
|
996
1051
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
997
1052
|
let n = document.createElement("iframe");
|
|
998
1053
|
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write"), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
999
|
-
let r = !1, i =
|
|
1000
|
-
|
|
1001
|
-
}), f = () => {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1054
|
+
let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
|
|
1055
|
+
i !== t && (i = t, t ? (a = st(o), ct(o)) : (lt(o, a), a = null), e.onFullWindowChange?.(t));
|
|
1056
|
+
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1057
|
+
p = e, m = t;
|
|
1058
|
+
}), g = () => {
|
|
1059
|
+
for (let e of f) window.clearTimeout(e);
|
|
1060
|
+
f.length = 0;
|
|
1061
|
+
}, _ = (t) => {
|
|
1005
1062
|
if (r) return;
|
|
1006
1063
|
let i = Date.now();
|
|
1007
|
-
if (
|
|
1008
|
-
|
|
1009
|
-
let a =
|
|
1064
|
+
if (d > 0 && i - d < 250) return;
|
|
1065
|
+
d = i, g();
|
|
1066
|
+
let a = nt(t.launch, t.session, t.chrome), o = () => {
|
|
1010
1067
|
if (r) return;
|
|
1011
1068
|
let t = n.contentWindow;
|
|
1012
|
-
t &&
|
|
1069
|
+
t && Ze(t, a, e.playerOrigin);
|
|
1013
1070
|
};
|
|
1014
1071
|
o();
|
|
1015
|
-
for (let e = 1; e <= 12; e += 1)
|
|
1016
|
-
},
|
|
1017
|
-
r || !
|
|
1018
|
-
},
|
|
1019
|
-
if (
|
|
1020
|
-
|
|
1072
|
+
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
1073
|
+
}, v = () => {
|
|
1074
|
+
r || !l || _(l);
|
|
1075
|
+
}, y = () => {
|
|
1076
|
+
if (u += 1, u === 1) {
|
|
1077
|
+
Xe(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1021
1078
|
return;
|
|
1022
1079
|
}
|
|
1023
|
-
|
|
1024
|
-
},
|
|
1025
|
-
|
|
1080
|
+
d = 0, v();
|
|
1081
|
+
}, b = () => {
|
|
1082
|
+
u > 0 || m?.(Error(Ye(e.playerOrigin)));
|
|
1026
1083
|
};
|
|
1027
|
-
n.addEventListener("load",
|
|
1028
|
-
let
|
|
1084
|
+
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1085
|
+
let x = (t) => {
|
|
1029
1086
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1030
|
-
let
|
|
1031
|
-
if (
|
|
1087
|
+
let i = tt(t.data);
|
|
1088
|
+
if (i) switch (i.type) {
|
|
1032
1089
|
case "close":
|
|
1033
|
-
e.onClose?.(
|
|
1090
|
+
e.onClose?.(i.payload);
|
|
1034
1091
|
break;
|
|
1035
1092
|
case "stateUpdate":
|
|
1036
|
-
e.onPlayerStatusChange?.(
|
|
1093
|
+
e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
|
|
1037
1094
|
break;
|
|
1038
1095
|
case "commandResult": {
|
|
1039
|
-
let e =
|
|
1096
|
+
let e = c.get(i.payload.correlationId);
|
|
1040
1097
|
if (!e) return;
|
|
1041
|
-
|
|
1098
|
+
c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
|
|
1042
1099
|
break;
|
|
1043
1100
|
}
|
|
1044
1101
|
case "userTranscript":
|
|
1045
|
-
e.onUserTranscript?.(
|
|
1102
|
+
e.onUserTranscript?.(i.payload);
|
|
1046
1103
|
break;
|
|
1047
1104
|
case "characterSpeechStarted":
|
|
1048
|
-
e.onCharacterSpeechStarted?.(
|
|
1105
|
+
e.onCharacterSpeechStarted?.(i.payload);
|
|
1049
1106
|
break;
|
|
1050
1107
|
case "characterSpeechEnded":
|
|
1051
|
-
e.onCharacterSpeechEnded?.(
|
|
1108
|
+
e.onCharacterSpeechEnded?.(i.payload);
|
|
1052
1109
|
break;
|
|
1053
1110
|
case "characterFocusChanged":
|
|
1054
|
-
e.onCharacterFocusChanged?.(
|
|
1111
|
+
e.onCharacterFocusChanged?.(i.payload);
|
|
1055
1112
|
break;
|
|
1056
1113
|
case "conversationUpdate":
|
|
1057
|
-
e.onConversationUpdate?.(
|
|
1114
|
+
e.onConversationUpdate?.(i.payload.conversation);
|
|
1058
1115
|
break;
|
|
1059
1116
|
case "listeningState":
|
|
1060
|
-
e.onListeningState?.(
|
|
1117
|
+
e.onListeningState?.(i.payload.listening);
|
|
1061
1118
|
break;
|
|
1062
1119
|
case "userSpeechStarted":
|
|
1063
|
-
e.onUserSpeechStarted?.(
|
|
1120
|
+
e.onUserSpeechStarted?.(i.payload);
|
|
1064
1121
|
break;
|
|
1065
1122
|
case "userSpeechEnded":
|
|
1066
|
-
e.onUserSpeechEnded?.(
|
|
1123
|
+
e.onUserSpeechEnded?.(i.payload);
|
|
1067
1124
|
break;
|
|
1068
1125
|
case "modeChange":
|
|
1069
|
-
e.onActivityChange?.(
|
|
1126
|
+
e.onActivityChange?.(ut(i.payload.mode));
|
|
1070
1127
|
break;
|
|
1071
1128
|
case "activityChange":
|
|
1072
|
-
e.onActivityChange?.(
|
|
1129
|
+
e.onActivityChange?.(i.payload.activity);
|
|
1073
1130
|
break;
|
|
1074
1131
|
case "feedback":
|
|
1075
|
-
e.onFeedback?.(
|
|
1132
|
+
e.onFeedback?.(i.payload);
|
|
1076
1133
|
break;
|
|
1077
1134
|
case "feedbackFailed":
|
|
1078
|
-
e.onFeedbackFailed?.(
|
|
1135
|
+
e.onFeedbackFailed?.(i.payload);
|
|
1079
1136
|
break;
|
|
1080
1137
|
case "message":
|
|
1081
|
-
e.onMessage?.(
|
|
1138
|
+
e.onMessage?.(i.payload);
|
|
1082
1139
|
break;
|
|
1083
1140
|
case "started":
|
|
1084
|
-
e.onStarted?.(
|
|
1141
|
+
e.onStarted?.(i.payload);
|
|
1085
1142
|
break;
|
|
1086
1143
|
case "embedReady":
|
|
1087
|
-
|
|
1144
|
+
v();
|
|
1088
1145
|
break;
|
|
1089
1146
|
case "widgetReady":
|
|
1090
1147
|
e.onWidgetReady?.();
|
|
@@ -1096,52 +1153,55 @@ function rt(e) {
|
|
|
1096
1153
|
e.onWidgetCollapse?.();
|
|
1097
1154
|
break;
|
|
1098
1155
|
case "widgetAudioSettings":
|
|
1099
|
-
e.onWidgetAudioSettings?.(
|
|
1156
|
+
e.onWidgetAudioSettings?.(i.payload.open);
|
|
1100
1157
|
break;
|
|
1101
1158
|
case "widgetDragStart":
|
|
1102
|
-
e.onWidgetDragStart?.(
|
|
1159
|
+
e.onWidgetDragStart?.(i.payload);
|
|
1103
1160
|
break;
|
|
1104
1161
|
case "widgetDragMove":
|
|
1105
|
-
e.onWidgetDragMove?.(
|
|
1162
|
+
e.onWidgetDragMove?.(i.payload);
|
|
1106
1163
|
break;
|
|
1107
1164
|
case "widgetDragEnd":
|
|
1108
|
-
e.onWidgetDragEnd?.(
|
|
1165
|
+
e.onWidgetDragEnd?.(i.payload);
|
|
1166
|
+
break;
|
|
1167
|
+
case "fullWindow":
|
|
1168
|
+
s(i.payload.active);
|
|
1109
1169
|
break;
|
|
1110
1170
|
}
|
|
1111
1171
|
};
|
|
1112
|
-
if (window.addEventListener("message",
|
|
1172
|
+
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
1113
1173
|
let e = getComputedStyle(t).minHeight;
|
|
1114
1174
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
1115
1175
|
}
|
|
1116
|
-
let
|
|
1176
|
+
let S = (t, i) => {
|
|
1117
1177
|
if (r) return;
|
|
1118
1178
|
let a = n.contentWindow;
|
|
1119
|
-
if (!a) throw Error(
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1179
|
+
if (!a) throw Error(Ye(e.playerOrigin));
|
|
1180
|
+
Ze(a, t, e.playerOrigin, i);
|
|
1181
|
+
}, C = (e, t = 12e4, n) => {
|
|
1122
1182
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1123
|
-
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((
|
|
1124
|
-
|
|
1125
|
-
resolve: (e) =>
|
|
1126
|
-
reject:
|
|
1127
|
-
}),
|
|
1128
|
-
|
|
1183
|
+
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
1184
|
+
c.set(r, {
|
|
1185
|
+
resolve: (e) => i(e),
|
|
1186
|
+
reject: a
|
|
1187
|
+
}), S(e, n), setTimeout(() => {
|
|
1188
|
+
c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
1129
1189
|
}, t);
|
|
1130
1190
|
});
|
|
1131
1191
|
};
|
|
1132
1192
|
return {
|
|
1133
1193
|
waitForLoad() {
|
|
1134
|
-
return
|
|
1194
|
+
return h;
|
|
1135
1195
|
},
|
|
1136
1196
|
postParentHello() {
|
|
1137
|
-
|
|
1197
|
+
S(rt());
|
|
1138
1198
|
},
|
|
1139
1199
|
postLaunch(e, t, n) {
|
|
1140
|
-
r || (
|
|
1200
|
+
r || (l = {
|
|
1141
1201
|
launch: e,
|
|
1142
1202
|
session: t,
|
|
1143
1203
|
chrome: n
|
|
1144
|
-
},
|
|
1204
|
+
}, d = 0, _(l));
|
|
1145
1205
|
},
|
|
1146
1206
|
postManifest(e) {
|
|
1147
1207
|
if (typeof e == "string") {
|
|
@@ -1156,13 +1216,13 @@ function rt(e) {
|
|
|
1156
1216
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1157
1217
|
},
|
|
1158
1218
|
postWidgetSetChrome(e) {
|
|
1159
|
-
|
|
1219
|
+
S(it(e));
|
|
1160
1220
|
},
|
|
1161
1221
|
postWidgetToggleAudioSettings() {
|
|
1162
|
-
|
|
1222
|
+
S(at());
|
|
1163
1223
|
},
|
|
1164
1224
|
speak(e) {
|
|
1165
|
-
return
|
|
1225
|
+
return C({
|
|
1166
1226
|
type: "speak",
|
|
1167
1227
|
schemaVersion: 2,
|
|
1168
1228
|
payload: {
|
|
@@ -1174,21 +1234,21 @@ function rt(e) {
|
|
|
1174
1234
|
});
|
|
1175
1235
|
},
|
|
1176
1236
|
startListening() {
|
|
1177
|
-
return
|
|
1237
|
+
return C({
|
|
1178
1238
|
type: "startListening",
|
|
1179
1239
|
schemaVersion: 2,
|
|
1180
1240
|
payload: { correlationId: Z() }
|
|
1181
1241
|
});
|
|
1182
1242
|
},
|
|
1183
1243
|
stopListening() {
|
|
1184
|
-
return
|
|
1244
|
+
return C({
|
|
1185
1245
|
type: "stopListening",
|
|
1186
1246
|
schemaVersion: 2,
|
|
1187
1247
|
payload: { correlationId: Z() }
|
|
1188
1248
|
});
|
|
1189
1249
|
},
|
|
1190
1250
|
listenOnce(e) {
|
|
1191
|
-
return
|
|
1251
|
+
return C({
|
|
1192
1252
|
type: "listenOnce",
|
|
1193
1253
|
schemaVersion: 2,
|
|
1194
1254
|
payload: {
|
|
@@ -1198,7 +1258,7 @@ function rt(e) {
|
|
|
1198
1258
|
});
|
|
1199
1259
|
},
|
|
1200
1260
|
async speakProcessorStream(e, t) {
|
|
1201
|
-
let n = Z(), r = Z(), i = (await
|
|
1261
|
+
let n = Z(), r = Z(), i = (await C({
|
|
1202
1262
|
type: "speakStreamStart",
|
|
1203
1263
|
schemaVersion: 2,
|
|
1204
1264
|
payload: {
|
|
@@ -1210,7 +1270,7 @@ function rt(e) {
|
|
|
1210
1270
|
try {
|
|
1211
1271
|
for await (let n of e) {
|
|
1212
1272
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1213
|
-
n &&
|
|
1273
|
+
n && S({
|
|
1214
1274
|
type: "speakStreamChunk",
|
|
1215
1275
|
schemaVersion: 2,
|
|
1216
1276
|
payload: {
|
|
@@ -1220,7 +1280,7 @@ function rt(e) {
|
|
|
1220
1280
|
});
|
|
1221
1281
|
}
|
|
1222
1282
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1223
|
-
return await
|
|
1283
|
+
return await C({
|
|
1224
1284
|
type: "speakStreamEnd",
|
|
1225
1285
|
schemaVersion: 2,
|
|
1226
1286
|
payload: {
|
|
@@ -1230,7 +1290,7 @@ function rt(e) {
|
|
|
1230
1290
|
});
|
|
1231
1291
|
} catch (e) {
|
|
1232
1292
|
try {
|
|
1233
|
-
await
|
|
1293
|
+
await C({
|
|
1234
1294
|
type: "speakStreamEnd",
|
|
1235
1295
|
schemaVersion: 2,
|
|
1236
1296
|
payload: {
|
|
@@ -1244,7 +1304,7 @@ function rt(e) {
|
|
|
1244
1304
|
},
|
|
1245
1305
|
speechPlay(e) {
|
|
1246
1306
|
let t = Z(), n = [];
|
|
1247
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1307
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
|
|
1248
1308
|
type: "speechPlay",
|
|
1249
1309
|
schemaVersion: 2,
|
|
1250
1310
|
payload: {
|
|
@@ -1258,7 +1318,7 @@ function rt(e) {
|
|
|
1258
1318
|
}, 12e4, n);
|
|
1259
1319
|
},
|
|
1260
1320
|
speechUtteranceBegin(e) {
|
|
1261
|
-
return
|
|
1321
|
+
return C({
|
|
1262
1322
|
type: "speechUtteranceBegin",
|
|
1263
1323
|
schemaVersion: 2,
|
|
1264
1324
|
payload: {
|
|
@@ -1272,7 +1332,7 @@ function rt(e) {
|
|
|
1272
1332
|
});
|
|
1273
1333
|
},
|
|
1274
1334
|
speechUtteranceWrite(e) {
|
|
1275
|
-
return
|
|
1335
|
+
return C({
|
|
1276
1336
|
type: "speechUtteranceWrite",
|
|
1277
1337
|
schemaVersion: 2,
|
|
1278
1338
|
payload: {
|
|
@@ -1281,10 +1341,10 @@ function rt(e) {
|
|
|
1281
1341
|
audio: e.audio,
|
|
1282
1342
|
byteLength: e.byteLength
|
|
1283
1343
|
}
|
|
1284
|
-
},
|
|
1344
|
+
}, dt, [e.audio]);
|
|
1285
1345
|
},
|
|
1286
1346
|
speechUtteranceSetTranscript(e) {
|
|
1287
|
-
return
|
|
1347
|
+
return C({
|
|
1288
1348
|
type: "speechUtteranceSetTranscript",
|
|
1289
1349
|
schemaVersion: 2,
|
|
1290
1350
|
payload: {
|
|
@@ -1295,7 +1355,7 @@ function rt(e) {
|
|
|
1295
1355
|
});
|
|
1296
1356
|
},
|
|
1297
1357
|
speechUtteranceClose(e) {
|
|
1298
|
-
return
|
|
1358
|
+
return C({
|
|
1299
1359
|
type: "speechUtteranceClose",
|
|
1300
1360
|
schemaVersion: 2,
|
|
1301
1361
|
payload: {
|
|
@@ -1307,7 +1367,7 @@ function rt(e) {
|
|
|
1307
1367
|
});
|
|
1308
1368
|
},
|
|
1309
1369
|
speechUtteranceCancel(e) {
|
|
1310
|
-
return
|
|
1370
|
+
return C({
|
|
1311
1371
|
type: "speechUtteranceCancel",
|
|
1312
1372
|
schemaVersion: 2,
|
|
1313
1373
|
payload: {
|
|
@@ -1317,7 +1377,7 @@ function rt(e) {
|
|
|
1317
1377
|
});
|
|
1318
1378
|
},
|
|
1319
1379
|
speechInterrupt(e) {
|
|
1320
|
-
return
|
|
1380
|
+
return C({
|
|
1321
1381
|
type: "speechInterrupt",
|
|
1322
1382
|
schemaVersion: 2,
|
|
1323
1383
|
payload: {
|
|
@@ -1327,14 +1387,14 @@ function rt(e) {
|
|
|
1327
1387
|
});
|
|
1328
1388
|
},
|
|
1329
1389
|
getConversation() {
|
|
1330
|
-
return
|
|
1390
|
+
return C({
|
|
1331
1391
|
type: "getConversation",
|
|
1332
1392
|
schemaVersion: 2,
|
|
1333
1393
|
payload: { correlationId: Z() }
|
|
1334
1394
|
});
|
|
1335
1395
|
},
|
|
1336
1396
|
focusCharacter(e) {
|
|
1337
|
-
return
|
|
1397
|
+
return C({
|
|
1338
1398
|
type: "focusCharacter",
|
|
1339
1399
|
schemaVersion: 2,
|
|
1340
1400
|
payload: {
|
|
@@ -1344,7 +1404,7 @@ function rt(e) {
|
|
|
1344
1404
|
});
|
|
1345
1405
|
},
|
|
1346
1406
|
setFit(e) {
|
|
1347
|
-
return
|
|
1407
|
+
return C({
|
|
1348
1408
|
type: "setFit",
|
|
1349
1409
|
schemaVersion: 2,
|
|
1350
1410
|
payload: {
|
|
@@ -1353,18 +1413,28 @@ function rt(e) {
|
|
|
1353
1413
|
}
|
|
1354
1414
|
});
|
|
1355
1415
|
},
|
|
1416
|
+
conversion(e) {
|
|
1417
|
+
return C({
|
|
1418
|
+
type: "conversion",
|
|
1419
|
+
schemaVersion: 2,
|
|
1420
|
+
payload: {
|
|
1421
|
+
correlationId: Z(),
|
|
1422
|
+
key: e
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
},
|
|
1356
1426
|
destroy() {
|
|
1357
1427
|
if (!r) {
|
|
1358
|
-
r = !0;
|
|
1359
|
-
for (let e of
|
|
1360
|
-
|
|
1428
|
+
r = !0, i && s(!1);
|
|
1429
|
+
for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1430
|
+
c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
|
|
1361
1431
|
}
|
|
1362
1432
|
}
|
|
1363
1433
|
};
|
|
1364
1434
|
}
|
|
1365
1435
|
//#endregion
|
|
1366
1436
|
//#region src/v2/embed/readyGate.ts
|
|
1367
|
-
function
|
|
1437
|
+
function pt(e) {
|
|
1368
1438
|
let t, n = !1, r = !1, i = () => {
|
|
1369
1439
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1370
1440
|
};
|
|
@@ -1379,47 +1449,50 @@ function it(e) {
|
|
|
1379
1449
|
}
|
|
1380
1450
|
//#endregion
|
|
1381
1451
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1382
|
-
var
|
|
1383
|
-
function
|
|
1452
|
+
var mt = "https://player.liforma.ai/embed", ht = "http://localhost:3002/embed";
|
|
1453
|
+
function gt() {
|
|
1384
1454
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1385
1455
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1386
1456
|
if (typeof document > "u") return null;
|
|
1387
1457
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-player-embed-url")?.trim();
|
|
1388
1458
|
return t ? t.replace(/\/$/, "") : null;
|
|
1389
1459
|
}
|
|
1390
|
-
function
|
|
1391
|
-
let e =
|
|
1392
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : T() ?
|
|
1460
|
+
function _t() {
|
|
1461
|
+
let e = gt();
|
|
1462
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : T() ? ht : mt;
|
|
1463
|
+
}
|
|
1464
|
+
function vt(e, t) {
|
|
1465
|
+
return e?.trim() || t?.trim() || void 0;
|
|
1393
1466
|
}
|
|
1394
|
-
function
|
|
1395
|
-
let c = (e ??
|
|
1396
|
-
d && u.searchParams.set("locationId", d);
|
|
1467
|
+
function yt(e, t, n, r, i, a, o, s) {
|
|
1468
|
+
let c = (e ?? _t()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1469
|
+
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1397
1470
|
let f = r?.trim();
|
|
1398
|
-
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)),
|
|
1471
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), bt(u.toString());
|
|
1399
1472
|
}
|
|
1400
|
-
function
|
|
1473
|
+
function bt(e) {
|
|
1401
1474
|
if (typeof location > "u") return e;
|
|
1402
1475
|
let t = new URL(e);
|
|
1403
1476
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1404
1477
|
}
|
|
1405
|
-
function
|
|
1478
|
+
function xt(e) {
|
|
1406
1479
|
return new URL(e).origin;
|
|
1407
1480
|
}
|
|
1408
1481
|
//#endregion
|
|
1409
1482
|
//#region src/v2/experienceEvents.ts
|
|
1410
|
-
function
|
|
1483
|
+
function St() {
|
|
1411
1484
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
1412
1485
|
}
|
|
1413
|
-
function
|
|
1486
|
+
function Ct(e, t, n) {
|
|
1414
1487
|
return {
|
|
1415
|
-
id:
|
|
1488
|
+
id: St(),
|
|
1416
1489
|
type: e,
|
|
1417
1490
|
sessionId: t,
|
|
1418
1491
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1419
1492
|
data: n
|
|
1420
1493
|
};
|
|
1421
1494
|
}
|
|
1422
|
-
function
|
|
1495
|
+
function wt() {
|
|
1423
1496
|
return {
|
|
1424
1497
|
ready: /* @__PURE__ */ new Set(),
|
|
1425
1498
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1438,39 +1511,39 @@ function mt() {
|
|
|
1438
1511
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1439
1512
|
};
|
|
1440
1513
|
}
|
|
1441
|
-
function
|
|
1514
|
+
function Tt(e, t, n) {
|
|
1442
1515
|
return e[t].add(n), () => e[t].delete(n);
|
|
1443
1516
|
}
|
|
1444
|
-
function
|
|
1517
|
+
function Et(e, t, n) {
|
|
1445
1518
|
for (let r of e[t]) r(n);
|
|
1446
1519
|
}
|
|
1447
|
-
function
|
|
1520
|
+
function Dt(e) {
|
|
1448
1521
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1449
1522
|
}
|
|
1450
1523
|
//#endregion
|
|
1451
1524
|
//#region src/v2/speech/types.ts
|
|
1452
|
-
function
|
|
1525
|
+
function Ot(e) {
|
|
1453
1526
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1454
1527
|
}
|
|
1455
|
-
function
|
|
1528
|
+
function kt(e) {
|
|
1456
1529
|
return "url" in e && typeof e.url == "string";
|
|
1457
1530
|
}
|
|
1458
|
-
function
|
|
1531
|
+
function At(e) {
|
|
1459
1532
|
if (!("track" in e)) return !1;
|
|
1460
1533
|
let t = e.track;
|
|
1461
1534
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1462
1535
|
}
|
|
1463
|
-
function
|
|
1464
|
-
return !
|
|
1536
|
+
function jt(e) {
|
|
1537
|
+
return !Ot(e) && !kt(e) && !At(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1465
1538
|
}
|
|
1466
|
-
var
|
|
1539
|
+
var Mt = [
|
|
1467
1540
|
8e3,
|
|
1468
1541
|
16e3,
|
|
1469
1542
|
22050,
|
|
1470
1543
|
24e3,
|
|
1471
1544
|
44100,
|
|
1472
1545
|
48e3
|
|
1473
|
-
],
|
|
1546
|
+
], Nt = {
|
|
1474
1547
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1475
1548
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1476
1549
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1481,14 +1554,14 @@ var St = [
|
|
|
1481
1554
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1482
1555
|
MAX_PENDING_WRITES: 8,
|
|
1483
1556
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1484
|
-
},
|
|
1557
|
+
}, Pt = class extends Error {
|
|
1485
1558
|
operation;
|
|
1486
1559
|
requiredCapability;
|
|
1487
1560
|
name = "UnsupportedSpeechOperationError";
|
|
1488
1561
|
constructor(e, t) {
|
|
1489
1562
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1490
1563
|
}
|
|
1491
|
-
},
|
|
1564
|
+
}, Ft = class extends Error {
|
|
1492
1565
|
name = "SpeechUtteranceClosedError";
|
|
1493
1566
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1494
1567
|
super(e);
|
|
@@ -1498,72 +1571,72 @@ var St = [
|
|
|
1498
1571
|
constructor(e, t) {
|
|
1499
1572
|
super(e, t);
|
|
1500
1573
|
}
|
|
1501
|
-
},
|
|
1574
|
+
}, It = class extends Error {
|
|
1502
1575
|
name = "SpeechBufferTimeoutError";
|
|
1503
1576
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1504
1577
|
super(e);
|
|
1505
1578
|
}
|
|
1506
1579
|
};
|
|
1507
|
-
function
|
|
1580
|
+
function Lt(e = "none") {
|
|
1508
1581
|
return {
|
|
1509
1582
|
mode: e,
|
|
1510
1583
|
trackedDurationMs: 0,
|
|
1511
1584
|
fallbackDurationMs: 0
|
|
1512
1585
|
};
|
|
1513
1586
|
}
|
|
1514
|
-
function
|
|
1515
|
-
return
|
|
1587
|
+
function Rt(e) {
|
|
1588
|
+
return Mt.includes(e);
|
|
1516
1589
|
}
|
|
1517
|
-
function
|
|
1590
|
+
function zt(e) {
|
|
1518
1591
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1519
1592
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1520
|
-
if (!
|
|
1593
|
+
if (!Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1521
1594
|
}
|
|
1522
|
-
function
|
|
1523
|
-
if (
|
|
1524
|
-
|
|
1595
|
+
function Bt(e) {
|
|
1596
|
+
if (Ot(e)) {
|
|
1597
|
+
zt(e.format);
|
|
1525
1598
|
return;
|
|
1526
1599
|
}
|
|
1527
|
-
if (
|
|
1600
|
+
if (kt(e)) {
|
|
1528
1601
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1529
|
-
if (e.sampleRate !== void 0 && !
|
|
1602
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1530
1603
|
return;
|
|
1531
1604
|
}
|
|
1532
|
-
if (
|
|
1605
|
+
if (At(e)) {
|
|
1533
1606
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1534
|
-
if (e.sampleRate !== void 0 && !
|
|
1607
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1535
1608
|
return;
|
|
1536
1609
|
}
|
|
1537
|
-
if (
|
|
1610
|
+
if (jt(e)) {
|
|
1538
1611
|
let t = e.encoding.trim().toLowerCase();
|
|
1539
1612
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1540
1613
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1541
|
-
if (e.sampleRate !== void 0 && !
|
|
1614
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1542
1615
|
return;
|
|
1543
1616
|
}
|
|
1544
1617
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1545
1618
|
}
|
|
1546
|
-
function
|
|
1547
|
-
if (e.format) return
|
|
1619
|
+
function Vt(e) {
|
|
1620
|
+
if (e.format) return zt(e.format), e.format;
|
|
1548
1621
|
if (e.track) {
|
|
1549
1622
|
let t = {
|
|
1550
1623
|
encoding: "pcm_s16le",
|
|
1551
1624
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1552
1625
|
channels: 1
|
|
1553
1626
|
};
|
|
1554
|
-
return
|
|
1627
|
+
return zt(t), t;
|
|
1555
1628
|
}
|
|
1556
1629
|
throw new Q("createUtterance requires format or track.");
|
|
1557
1630
|
}
|
|
1558
|
-
function
|
|
1631
|
+
function Ht(e) {
|
|
1559
1632
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1560
1633
|
}
|
|
1561
|
-
function
|
|
1634
|
+
function Ut(e) {
|
|
1562
1635
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1563
1636
|
}
|
|
1564
1637
|
//#endregion
|
|
1565
1638
|
//#region src/byo/pcm.ts
|
|
1566
|
-
function
|
|
1639
|
+
function Wt(e) {
|
|
1567
1640
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1568
1641
|
for (let t = 0; t < e.length; t++) {
|
|
1569
1642
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1573,11 +1646,11 @@ function Pt(e) {
|
|
|
1573
1646
|
}
|
|
1574
1647
|
//#endregion
|
|
1575
1648
|
//#region src/byo/resample.ts
|
|
1576
|
-
function
|
|
1649
|
+
function Gt(e, t, n, r, i) {
|
|
1577
1650
|
let a = -.5 * e + 1.5 * t - 1.5 * n + .5 * r, o = e - 2.5 * t + 2 * n - .5 * r, s = -.5 * e + .5 * n, c = t;
|
|
1578
1651
|
return ((a * i + o) * i + s) * i + c;
|
|
1579
1652
|
}
|
|
1580
|
-
function
|
|
1653
|
+
function Kt(e, t) {
|
|
1581
1654
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1582
1655
|
if (e === t) return {
|
|
1583
1656
|
fromRate: e,
|
|
@@ -1600,7 +1673,7 @@ function It(e, t) {
|
|
|
1600
1673
|
let a = [];
|
|
1601
1674
|
for (; i + 2 < r.length - 1;) {
|
|
1602
1675
|
let e = Math.floor(i), t = i - e, o = Math.max(0, e - 1), s = Math.min(r.length - 1, e + 1), c = Math.min(r.length - 1, e + 2);
|
|
1603
|
-
a.push(
|
|
1676
|
+
a.push(Gt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1604
1677
|
}
|
|
1605
1678
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1606
1679
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1612,7 +1685,7 @@ function It(e, t) {
|
|
|
1612
1685
|
}
|
|
1613
1686
|
//#endregion
|
|
1614
1687
|
//#region src/byo/audioCapture.ts
|
|
1615
|
-
var
|
|
1688
|
+
var qt = "liforma-pcm-capture", Jt = `
|
|
1616
1689
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1617
1690
|
process(inputs) {
|
|
1618
1691
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1624,29 +1697,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1624
1697
|
return true;
|
|
1625
1698
|
}
|
|
1626
1699
|
}
|
|
1627
|
-
registerProcessor('${
|
|
1628
|
-
`,
|
|
1629
|
-
function
|
|
1630
|
-
return
|
|
1700
|
+
registerProcessor('${qt}', LiformaPcmCaptureProcessor);
|
|
1701
|
+
`, Yt = null;
|
|
1702
|
+
function Xt() {
|
|
1703
|
+
return Yt ||= URL.createObjectURL(new Blob([Jt], { type: "application/javascript" })), Yt;
|
|
1631
1704
|
}
|
|
1632
|
-
function
|
|
1705
|
+
function Zt() {
|
|
1633
1706
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1634
1707
|
}
|
|
1635
|
-
async function
|
|
1636
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1708
|
+
async function Qt(e) {
|
|
1709
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Zt();
|
|
1637
1710
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1638
1711
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1639
1712
|
l.gain.value = 0;
|
|
1640
|
-
let u = s.sampleRate, d =
|
|
1713
|
+
let u = s.sampleRate, d = Kt(u, n), f = !1, p = !1, m = (e) => {
|
|
1641
1714
|
if (f || i && !i()) return;
|
|
1642
1715
|
let t = d.push(e);
|
|
1643
|
-
t.length !== 0 && r(
|
|
1716
|
+
t.length !== 0 && r(Wt(t));
|
|
1644
1717
|
}, h = () => void 0;
|
|
1645
1718
|
return await (async () => {
|
|
1646
1719
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1647
1720
|
try {
|
|
1648
|
-
await s.audioWorklet.addModule(
|
|
1649
|
-
let e = new AudioWorkletNode(s,
|
|
1721
|
+
await s.audioWorklet.addModule(Xt());
|
|
1722
|
+
let e = new AudioWorkletNode(s, qt, {
|
|
1650
1723
|
numberOfInputs: 1,
|
|
1651
1724
|
numberOfOutputs: 1,
|
|
1652
1725
|
outputChannelCount: [1]
|
|
@@ -1696,7 +1769,7 @@ async function Ht(e) {
|
|
|
1696
1769
|
}
|
|
1697
1770
|
//#endregion
|
|
1698
1771
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1699
|
-
async function
|
|
1772
|
+
async function $t(e) {
|
|
1700
1773
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1701
1774
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1702
1775
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1705,18 +1778,18 @@ async function Ut(e) {
|
|
|
1705
1778
|
s || (s = !0, c?.stop(), c = null);
|
|
1706
1779
|
};
|
|
1707
1780
|
try {
|
|
1708
|
-
c = await
|
|
1781
|
+
c = await Qt({
|
|
1709
1782
|
mediaStream: a,
|
|
1710
1783
|
targetSampleRate: r,
|
|
1711
1784
|
shouldSend: () => !s && !i?.aborted,
|
|
1712
1785
|
onPcm: (e) => {
|
|
1713
1786
|
if (s || i?.aborted) return;
|
|
1714
|
-
let t =
|
|
1787
|
+
let t = Ht(e);
|
|
1715
1788
|
o = o.then(async () => {
|
|
1716
1789
|
if (s || i?.aborted) return;
|
|
1717
1790
|
let e = 0;
|
|
1718
1791
|
for (; e < t.byteLength;) {
|
|
1719
|
-
let r = Math.min(e +
|
|
1792
|
+
let r = Math.min(e + Nt.MAX_CHUNK_BYTES, t.byteLength);
|
|
1720
1793
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1721
1794
|
let i = t.subarray(e, r);
|
|
1722
1795
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1740,10 +1813,10 @@ async function Ut(e) {
|
|
|
1740
1813
|
}
|
|
1741
1814
|
//#endregion
|
|
1742
1815
|
//#region src/v2/speech/speechController.ts
|
|
1743
|
-
async function
|
|
1744
|
-
if (
|
|
1745
|
-
if (
|
|
1746
|
-
let t =
|
|
1816
|
+
async function en(e, t) {
|
|
1817
|
+
if (At(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
1818
|
+
if (Ot(e)) {
|
|
1819
|
+
let t = Ht(e.data);
|
|
1747
1820
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1748
1821
|
return {
|
|
1749
1822
|
kind: "pcm",
|
|
@@ -1751,17 +1824,17 @@ async function Wt(e, t) {
|
|
|
1751
1824
|
format: e.format
|
|
1752
1825
|
};
|
|
1753
1826
|
}
|
|
1754
|
-
if (
|
|
1827
|
+
if (kt(e)) return {
|
|
1755
1828
|
kind: "url",
|
|
1756
1829
|
url: e.url.trim(),
|
|
1757
1830
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1758
1831
|
};
|
|
1759
|
-
if (!
|
|
1832
|
+
if (!jt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1760
1833
|
let n;
|
|
1761
1834
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1762
1835
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1763
1836
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1764
|
-
} else n =
|
|
1837
|
+
} else n = Ht(e.data);
|
|
1765
1838
|
return {
|
|
1766
1839
|
kind: "encoded",
|
|
1767
1840
|
data: n.slice().buffer,
|
|
@@ -1769,10 +1842,10 @@ async function Wt(e, t) {
|
|
|
1769
1842
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1770
1843
|
};
|
|
1771
1844
|
}
|
|
1772
|
-
function
|
|
1845
|
+
function tn() {
|
|
1773
1846
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `utt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
1774
1847
|
}
|
|
1775
|
-
function
|
|
1848
|
+
function nn(e, t = "completed") {
|
|
1776
1849
|
return {
|
|
1777
1850
|
utteranceId: e.speechId,
|
|
1778
1851
|
characterId: e.characterId,
|
|
@@ -1786,13 +1859,13 @@ function Kt(e, t = "completed") {
|
|
|
1786
1859
|
}
|
|
1787
1860
|
};
|
|
1788
1861
|
}
|
|
1789
|
-
function
|
|
1862
|
+
function rn(e) {
|
|
1790
1863
|
return e instanceof Error ? e : new Q(String(e));
|
|
1791
1864
|
}
|
|
1792
|
-
function
|
|
1865
|
+
function an(e) {
|
|
1793
1866
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1794
1867
|
}
|
|
1795
|
-
var
|
|
1868
|
+
var on = class {
|
|
1796
1869
|
id;
|
|
1797
1870
|
characterId;
|
|
1798
1871
|
result;
|
|
@@ -1821,29 +1894,29 @@ var Yt = class {
|
|
|
1821
1894
|
queue: e.queue,
|
|
1822
1895
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1823
1896
|
}).catch((e) => {
|
|
1824
|
-
throw this.fail(
|
|
1897
|
+
throw this.fail(rn(e)), rn(e);
|
|
1825
1898
|
}), this.signal?.addEventListener("abort", () => {
|
|
1826
1899
|
this.cancel();
|
|
1827
1900
|
}, { once: !0 });
|
|
1828
1901
|
}
|
|
1829
1902
|
async write(e, t) {
|
|
1830
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1831
|
-
let n =
|
|
1903
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Ft();
|
|
1904
|
+
let n = Ht(e);
|
|
1832
1905
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1833
|
-
if (n.byteLength >
|
|
1906
|
+
if (n.byteLength > Nt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Nt.MAX_CHUNK_BYTES}).`);
|
|
1834
1907
|
if (n.byteLength === 0) return;
|
|
1835
|
-
let r = t?.timeoutMs ??
|
|
1908
|
+
let r = t?.timeoutMs ?? Nt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1836
1909
|
await this.acquireWriteSlot(r);
|
|
1837
1910
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1838
|
-
if (this.bufferedMs + i >
|
|
1911
|
+
if (this.bufferedMs + i > Nt.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1839
1912
|
let a = async () => {
|
|
1840
|
-
if (this.closed || this.settled) throw new
|
|
1913
|
+
if (this.closed || this.settled) throw new Ft();
|
|
1841
1914
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1842
1915
|
utteranceId: this.id,
|
|
1843
1916
|
audio: t.buffer,
|
|
1844
1917
|
byteLength: t.byteLength
|
|
1845
1918
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1846
|
-
setTimeout(() => t(new
|
|
1919
|
+
setTimeout(() => t(new It()), r);
|
|
1847
1920
|
})]);
|
|
1848
1921
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1849
1922
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1855,7 +1928,7 @@ var Yt = class {
|
|
|
1855
1928
|
}
|
|
1856
1929
|
}
|
|
1857
1930
|
async setTranscript(e) {
|
|
1858
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1931
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Ft();
|
|
1859
1932
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1860
1933
|
utteranceId: this.id,
|
|
1861
1934
|
transcript: e
|
|
@@ -1872,7 +1945,7 @@ var Yt = class {
|
|
|
1872
1945
|
});
|
|
1873
1946
|
return this.resolve(t), t;
|
|
1874
1947
|
} catch (e) {
|
|
1875
|
-
let t =
|
|
1948
|
+
let t = rn(e);
|
|
1876
1949
|
throw this.fail(t), t;
|
|
1877
1950
|
}
|
|
1878
1951
|
}
|
|
@@ -1890,11 +1963,11 @@ var Yt = class {
|
|
|
1890
1963
|
characterId: this.characterId,
|
|
1891
1964
|
status: "cancelled",
|
|
1892
1965
|
durationMs: 0,
|
|
1893
|
-
animation:
|
|
1966
|
+
animation: Lt("none")
|
|
1894
1967
|
};
|
|
1895
1968
|
return this.resolve(t), t;
|
|
1896
1969
|
} catch (e) {
|
|
1897
|
-
let t =
|
|
1970
|
+
let t = rn(e);
|
|
1898
1971
|
throw this.fail(t), t;
|
|
1899
1972
|
}
|
|
1900
1973
|
}
|
|
@@ -1907,19 +1980,19 @@ var Yt = class {
|
|
|
1907
1980
|
return e;
|
|
1908
1981
|
}
|
|
1909
1982
|
resolve(e) {
|
|
1910
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
1983
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Ft()));
|
|
1911
1984
|
}
|
|
1912
1985
|
fail(e) {
|
|
1913
1986
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1914
1987
|
}
|
|
1915
1988
|
async acquireWriteSlot(e) {
|
|
1916
|
-
if (this.pendingWriteCount <
|
|
1989
|
+
if (this.pendingWriteCount < Nt.MAX_PENDING_WRITES) {
|
|
1917
1990
|
this.pendingWriteCount += 1;
|
|
1918
1991
|
return;
|
|
1919
1992
|
}
|
|
1920
1993
|
await new Promise((t, n) => {
|
|
1921
1994
|
let r = setTimeout(() => {
|
|
1922
|
-
n(new
|
|
1995
|
+
n(new It());
|
|
1923
1996
|
}, e);
|
|
1924
1997
|
this.pendingWriteWaiters.push({
|
|
1925
1998
|
resolve: () => {
|
|
@@ -1938,13 +2011,13 @@ var Yt = class {
|
|
|
1938
2011
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1939
2012
|
}
|
|
1940
2013
|
};
|
|
1941
|
-
function
|
|
2014
|
+
function sn(e) {
|
|
1942
2015
|
let t = null, n = (t, n) => {
|
|
1943
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2016
|
+
if (!e.getCapabilities()[n]) throw new Pt(t, n);
|
|
1944
2017
|
}, r = {
|
|
1945
2018
|
async speak(r) {
|
|
1946
2019
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1947
|
-
let i =
|
|
2020
|
+
let i = Ut(r.queue ?? "append");
|
|
1948
2021
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1949
2022
|
let a = e.getIframeHost();
|
|
1950
2023
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -1964,41 +2037,41 @@ function Xt(e) {
|
|
|
1964
2037
|
return;
|
|
1965
2038
|
}
|
|
1966
2039
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1967
|
-
t.removeEventListener("abort", s), n(
|
|
2040
|
+
t.removeEventListener("abort", s), n(nn(e, "completed"));
|
|
1968
2041
|
}, (a) => {
|
|
1969
|
-
if (t.removeEventListener("abort", s),
|
|
2042
|
+
if (t.removeEventListener("abort", s), an(a)) {
|
|
1970
2043
|
n({
|
|
1971
2044
|
utteranceId: "utt_interrupted",
|
|
1972
2045
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1973
2046
|
status: "interrupted",
|
|
1974
2047
|
durationMs: 0,
|
|
1975
2048
|
transcript: r.text,
|
|
1976
|
-
animation:
|
|
2049
|
+
animation: Lt("none")
|
|
1977
2050
|
});
|
|
1978
2051
|
return;
|
|
1979
2052
|
}
|
|
1980
|
-
i(
|
|
2053
|
+
i(rn(a));
|
|
1981
2054
|
});
|
|
1982
2055
|
});
|
|
1983
2056
|
}
|
|
1984
2057
|
try {
|
|
1985
|
-
return
|
|
2058
|
+
return nn(await o, "completed");
|
|
1986
2059
|
} catch (t) {
|
|
1987
|
-
if (
|
|
2060
|
+
if (an(t)) return {
|
|
1988
2061
|
utteranceId: "utt_interrupted",
|
|
1989
2062
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1990
2063
|
status: "interrupted",
|
|
1991
2064
|
durationMs: 0,
|
|
1992
2065
|
transcript: r.text,
|
|
1993
|
-
animation:
|
|
2066
|
+
animation: Lt("none")
|
|
1994
2067
|
};
|
|
1995
|
-
throw
|
|
2068
|
+
throw rn(t);
|
|
1996
2069
|
}
|
|
1997
2070
|
},
|
|
1998
2071
|
async play(i) {
|
|
1999
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2072
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Bt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2000
2073
|
let a = i.queue ?? "append";
|
|
2001
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2074
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), At(i.audio)) {
|
|
2002
2075
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2003
2076
|
return r.createUtterance({
|
|
2004
2077
|
format: {
|
|
@@ -2014,7 +2087,7 @@ function Xt(e) {
|
|
|
2014
2087
|
}
|
|
2015
2088
|
let o = e.getIframeHost();
|
|
2016
2089
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2017
|
-
let s = await
|
|
2090
|
+
let s = await en(i.audio, i.signal);
|
|
2018
2091
|
return o.speechPlay({
|
|
2019
2092
|
source: s,
|
|
2020
2093
|
characterId: i.characterId,
|
|
@@ -2026,13 +2099,13 @@ function Xt(e) {
|
|
|
2026
2099
|
},
|
|
2027
2100
|
createUtterance(r) {
|
|
2028
2101
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2029
|
-
let i =
|
|
2102
|
+
let i = Vt(r);
|
|
2030
2103
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2031
2104
|
let a = r.queue ?? "replace-active";
|
|
2032
2105
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2033
2106
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2034
|
-
let o = new
|
|
2035
|
-
id:
|
|
2107
|
+
let o = new on({
|
|
2108
|
+
id: tn(),
|
|
2036
2109
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2037
2110
|
format: i,
|
|
2038
2111
|
queue: a,
|
|
@@ -2044,7 +2117,7 @@ function Xt(e) {
|
|
|
2044
2117
|
t === o && (t = null);
|
|
2045
2118
|
}), r.track && (async () => {
|
|
2046
2119
|
try {
|
|
2047
|
-
if (await
|
|
2120
|
+
if (await $t({
|
|
2048
2121
|
track: r.track,
|
|
2049
2122
|
utterance: o,
|
|
2050
2123
|
sampleRate: i.sampleRate,
|
|
@@ -2072,16 +2145,16 @@ function Xt(e) {
|
|
|
2072
2145
|
}
|
|
2073
2146
|
//#endregion
|
|
2074
2147
|
//#region src/v2/types/sessionInteraction.ts
|
|
2075
|
-
function
|
|
2148
|
+
function cn(e) {
|
|
2076
2149
|
let t = e?.trim();
|
|
2077
2150
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2078
2151
|
}
|
|
2079
2152
|
//#endregion
|
|
2080
2153
|
//#region src/v2/experience.ts
|
|
2081
|
-
function
|
|
2154
|
+
function ln(e) {
|
|
2082
2155
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2083
2156
|
}
|
|
2084
|
-
var
|
|
2157
|
+
var un = class e {
|
|
2085
2158
|
bootstrap;
|
|
2086
2159
|
conversationProcessor;
|
|
2087
2160
|
iframeHost = null;
|
|
@@ -2096,16 +2169,16 @@ var $t = class e {
|
|
|
2096
2169
|
attached = !1;
|
|
2097
2170
|
pendingFit = null;
|
|
2098
2171
|
closeHandlers = [];
|
|
2099
|
-
eventRegistry =
|
|
2172
|
+
eventRegistry = wt();
|
|
2100
2173
|
readyEnvelope = null;
|
|
2101
2174
|
startedEnvelope = null;
|
|
2102
2175
|
conversationCache = [];
|
|
2103
2176
|
speech;
|
|
2104
2177
|
constructor(e) {
|
|
2105
|
-
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech =
|
|
2178
|
+
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = sn({
|
|
2106
2179
|
getIframeHost: () => this.iframeHost,
|
|
2107
2180
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2108
|
-
getCapabilities: () =>
|
|
2181
|
+
getCapabilities: () => dn(this.resolvedSession),
|
|
2109
2182
|
getActiveCharacterId: () => "character_unknown",
|
|
2110
2183
|
onProcessorInterrupt: () => {
|
|
2111
2184
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2120,6 +2193,9 @@ var $t = class e {
|
|
|
2120
2193
|
kind: "launch",
|
|
2121
2194
|
launch: n,
|
|
2122
2195
|
session: t.session,
|
|
2196
|
+
backdropId: t.backdropId,
|
|
2197
|
+
locationId: t.locationId,
|
|
2198
|
+
avatarId: t.avatarId,
|
|
2123
2199
|
embedBaseUrl: t.embedBaseUrl,
|
|
2124
2200
|
debug: t.debug,
|
|
2125
2201
|
speechOnly: t.speechOnly,
|
|
@@ -2137,6 +2213,7 @@ var $t = class e {
|
|
|
2137
2213
|
secondaryLocale: t.secondaryLocale,
|
|
2138
2214
|
learningLocale: t.learningLocale,
|
|
2139
2215
|
language: t.language,
|
|
2216
|
+
backdropId: t.backdropId,
|
|
2140
2217
|
locationId: t.locationId,
|
|
2141
2218
|
avatarId: t.avatarId,
|
|
2142
2219
|
castSize: t.castSize,
|
|
@@ -2145,6 +2222,7 @@ var $t = class e {
|
|
|
2145
2222
|
mode: t.mode,
|
|
2146
2223
|
speechInputMode: t.speechInputMode,
|
|
2147
2224
|
speechOnly: t.speechOnly,
|
|
2225
|
+
attribution: t.attribution,
|
|
2148
2226
|
ui: t.ui,
|
|
2149
2227
|
onStart: t.onStart,
|
|
2150
2228
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2157,6 +2235,7 @@ var $t = class e {
|
|
|
2157
2235
|
secondaryLocale: t.secondaryLocale,
|
|
2158
2236
|
learningLocale: t.learningLocale,
|
|
2159
2237
|
language: t.language,
|
|
2238
|
+
backdropId: t.backdropId,
|
|
2160
2239
|
locationId: t.locationId,
|
|
2161
2240
|
avatarId: t.avatarId,
|
|
2162
2241
|
castSize: t.castSize,
|
|
@@ -2165,6 +2244,7 @@ var $t = class e {
|
|
|
2165
2244
|
mode: t.mode,
|
|
2166
2245
|
speechInputMode: t.speechInputMode,
|
|
2167
2246
|
speechOnly: t.speechOnly,
|
|
2247
|
+
attribution: t.attribution,
|
|
2168
2248
|
ui: t.ui,
|
|
2169
2249
|
onStart: t.onStart,
|
|
2170
2250
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2179,7 +2259,7 @@ var $t = class e {
|
|
|
2179
2259
|
return null;
|
|
2180
2260
|
}
|
|
2181
2261
|
on(e, t) {
|
|
2182
|
-
let n =
|
|
2262
|
+
let n = Tt(this.eventRegistry, e, t);
|
|
2183
2263
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2184
2264
|
}
|
|
2185
2265
|
async attach(e) {
|
|
@@ -2193,13 +2273,13 @@ var $t = class e {
|
|
|
2193
2273
|
if (this.closed) throw Error("Session has ended.");
|
|
2194
2274
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2195
2275
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2196
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2276
|
+
let t = this.bootstrap.embedBaseUrl ?? _t(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = yt(t, n, r ? void 0 : vt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, ln(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = xt(i), o = null, s = new Promise((e) => {
|
|
2197
2277
|
o = e;
|
|
2198
2278
|
}), c = null, l = new Promise((e) => {
|
|
2199
2279
|
c = e;
|
|
2200
|
-
}), u =
|
|
2280
|
+
}), u = pt((e) => {
|
|
2201
2281
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2202
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2282
|
+
}), d = this.bootstrap.onUserTranscript, f = ft({
|
|
2203
2283
|
container: e.container,
|
|
2204
2284
|
src: i,
|
|
2205
2285
|
playerOrigin: a,
|
|
@@ -2262,7 +2342,7 @@ var $t = class e {
|
|
|
2262
2342
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2263
2343
|
});
|
|
2264
2344
|
this.iframeHost = f;
|
|
2265
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2345
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), We(this.bootstrap.sessionEndpoint, {
|
|
2266
2346
|
experienceId: this.bootstrap.experienceId,
|
|
2267
2347
|
locale: this.bootstrap.locale,
|
|
2268
2348
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2271,15 +2351,17 @@ var $t = class e {
|
|
|
2271
2351
|
mode: p.mode,
|
|
2272
2352
|
speechInputMode: p.speechInputMode,
|
|
2273
2353
|
speechOnly: this.bootstrap.speechOnly,
|
|
2354
|
+
attribution: this.bootstrap.attribution,
|
|
2274
2355
|
signal: this.endpointAbortController.signal
|
|
2275
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2356
|
+
})) : this.bootstrap.kind === "public" ? Ue(this.bootstrap.experienceId, {
|
|
2276
2357
|
locale: this.bootstrap.locale,
|
|
2277
2358
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2278
2359
|
learningLocale: this.bootstrap.learningLocale,
|
|
2279
2360
|
language: this.bootstrap.language,
|
|
2280
2361
|
mode: p.mode,
|
|
2281
2362
|
speechInputMode: p.speechInputMode,
|
|
2282
|
-
speechOnly: this.bootstrap.speechOnly
|
|
2363
|
+
speechOnly: this.bootstrap.speechOnly,
|
|
2364
|
+
attribution: this.bootstrap.attribution
|
|
2283
2365
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2284
2366
|
session: this.bootstrap.session,
|
|
2285
2367
|
launch: this.bootstrap.launch
|
|
@@ -2294,7 +2376,7 @@ var $t = class e {
|
|
|
2294
2376
|
f.postParentHello();
|
|
2295
2377
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2296
2378
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2297
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2379
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Fe(_), f.postLaunch(g, _, {
|
|
2298
2380
|
startButton: e.startButton,
|
|
2299
2381
|
showFeedback: e.showFeedback
|
|
2300
2382
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
@@ -2328,11 +2410,16 @@ var $t = class e {
|
|
|
2328
2410
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2329
2411
|
}
|
|
2330
2412
|
async setFit(e) {
|
|
2331
|
-
let t =
|
|
2413
|
+
let t = cn(e);
|
|
2332
2414
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2333
2415
|
if (this.closed) throw Error("Session has ended.");
|
|
2334
2416
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2335
2417
|
}
|
|
2418
|
+
async conversion(e) {
|
|
2419
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2420
|
+
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
2421
|
+
await this.iframeHost.conversion(e);
|
|
2422
|
+
}
|
|
2336
2423
|
getLastTurn() {
|
|
2337
2424
|
if (this.conversationCache.length === 0) return [];
|
|
2338
2425
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2342,7 +2429,7 @@ var $t = class e {
|
|
|
2342
2429
|
this.close();
|
|
2343
2430
|
}
|
|
2344
2431
|
destroy() {
|
|
2345
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
2432
|
+
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, Dt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2346
2433
|
}
|
|
2347
2434
|
resolveMintInteraction() {
|
|
2348
2435
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2354,8 +2441,8 @@ var $t = class e {
|
|
|
2354
2441
|
return this.resolvedSession?.id ?? "";
|
|
2355
2442
|
}
|
|
2356
2443
|
emitWrapped(e, t) {
|
|
2357
|
-
let n =
|
|
2358
|
-
return
|
|
2444
|
+
let n = Ct(e, this.getSessionId(), t);
|
|
2445
|
+
return Et(this.eventRegistry, e, n), n;
|
|
2359
2446
|
}
|
|
2360
2447
|
queueProcessorTurn(e) {
|
|
2361
2448
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2364,7 +2451,7 @@ var $t = class e {
|
|
|
2364
2451
|
let n = this.processorAbortController.signal;
|
|
2365
2452
|
this.processorChain = this.processorChain.then(async () => {
|
|
2366
2453
|
if (!n.aborted) try {
|
|
2367
|
-
let r = await
|
|
2454
|
+
let r = await qe(t, {
|
|
2368
2455
|
utteranceId: e.utteranceId,
|
|
2369
2456
|
text: e.text,
|
|
2370
2457
|
conversation: this.conversationCache,
|
|
@@ -2414,7 +2501,7 @@ var $t = class e {
|
|
|
2414
2501
|
};
|
|
2415
2502
|
}
|
|
2416
2503
|
};
|
|
2417
|
-
function
|
|
2504
|
+
function dn(e) {
|
|
2418
2505
|
return e ? {
|
|
2419
2506
|
textSpeech: e.capabilities.speech.output,
|
|
2420
2507
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2425,41 +2512,41 @@ function en(e) {
|
|
|
2425
2512
|
}
|
|
2426
2513
|
//#endregion
|
|
2427
2514
|
//#region src/widget/dockGeometry.ts
|
|
2428
|
-
var
|
|
2429
|
-
function
|
|
2515
|
+
var fn = "(min-width: 768px)", pn = 24, mn = .5, hn = 1200, gn = .85, _n = 9 / 16;
|
|
2516
|
+
function vn() {
|
|
2430
2517
|
if (typeof window > "u") return 800;
|
|
2431
2518
|
let e = window.screen?.availHeight;
|
|
2432
2519
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2433
2520
|
}
|
|
2434
|
-
function
|
|
2435
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2436
|
-
return s > a && (s = a, o = s /
|
|
2521
|
+
function yn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = pn, r = typeof window < "u" ? vn() : 800) {
|
|
2522
|
+
let i = Math.max(160, Math.min(t - n * 2, t * gn)), a = Math.max(120, e - n * 2), o = Math.min(r * mn, hn, i), s = o * _n;
|
|
2523
|
+
return s > a && (s = a, o = s / _n, o > i && (o = i, s = o * _n)), {
|
|
2437
2524
|
width: Math.round(s),
|
|
2438
2525
|
height: Math.round(o)
|
|
2439
2526
|
};
|
|
2440
2527
|
}
|
|
2441
|
-
function
|
|
2528
|
+
function bn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = pn) {
|
|
2442
2529
|
return {
|
|
2443
2530
|
left: Math.max(r, t - e.width - r),
|
|
2444
2531
|
top: Math.max(r, n - e.height - r)
|
|
2445
2532
|
};
|
|
2446
2533
|
}
|
|
2447
|
-
function
|
|
2534
|
+
function xn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = pn) {
|
|
2448
2535
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2449
2536
|
return {
|
|
2450
2537
|
left: Math.min(Math.max(a, e), o),
|
|
2451
2538
|
top: Math.min(Math.max(a, t), s)
|
|
2452
2539
|
};
|
|
2453
2540
|
}
|
|
2454
|
-
function
|
|
2455
|
-
return e(
|
|
2541
|
+
function Sn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2542
|
+
return e(fn).matches;
|
|
2456
2543
|
}
|
|
2457
2544
|
//#endregion
|
|
2458
2545
|
//#region src/widget/mountExperienceWidget.ts
|
|
2459
|
-
function
|
|
2546
|
+
function Cn(e) {
|
|
2460
2547
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2461
2548
|
}
|
|
2462
|
-
function
|
|
2549
|
+
function wn(e) {
|
|
2463
2550
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2464
2551
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2465
2552
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2467,8 +2554,8 @@ function mn(e) {
|
|
|
2467
2554
|
function $(e) {
|
|
2468
2555
|
return e === "expanded" || e === "docked";
|
|
2469
2556
|
}
|
|
2470
|
-
var
|
|
2471
|
-
function
|
|
2557
|
+
var Tn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", En = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", Dn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", On = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
|
|
2558
|
+
function kn(e, t, n) {
|
|
2472
2559
|
W(de);
|
|
2473
2560
|
let r = w({
|
|
2474
2561
|
galleryThumb: t.galleryThumb,
|
|
@@ -2498,7 +2585,7 @@ function yn(e, t, n) {
|
|
|
2498
2585
|
}
|
|
2499
2586
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2500
2587
|
}
|
|
2501
|
-
function
|
|
2588
|
+
function An(e) {
|
|
2502
2589
|
return e.startButton ? {
|
|
2503
2590
|
...e.startButton,
|
|
2504
2591
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2510,7 +2597,7 @@ function bn(e) {
|
|
|
2510
2597
|
variant: "primary"
|
|
2511
2598
|
};
|
|
2512
2599
|
}
|
|
2513
|
-
function
|
|
2600
|
+
function jn(e) {
|
|
2514
2601
|
let t = !1, n = () => {
|
|
2515
2602
|
t || e();
|
|
2516
2603
|
}, r = () => {
|
|
@@ -2530,12 +2617,12 @@ function xn(e) {
|
|
|
2530
2617
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2531
2618
|
};
|
|
2532
2619
|
}
|
|
2533
|
-
function
|
|
2620
|
+
function Mn(e, t) {
|
|
2534
2621
|
he(me);
|
|
2535
2622
|
let n = t.experienceId?.trim();
|
|
2536
2623
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2537
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2538
|
-
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset",
|
|
2624
|
+
let r = t.prefetch ?? "onExpand", i = Cn(t.position), a = document.createElement("div");
|
|
2625
|
+
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", wn(t.offset));
|
|
2539
2626
|
let o = document.createElement("button");
|
|
2540
2627
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2541
2628
|
let s = document.createElement("div");
|
|
@@ -2555,11 +2642,11 @@ function Sn(e, t) {
|
|
|
2555
2642
|
let m = document.createElement("span");
|
|
2556
2643
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2557
2644
|
let h = document.createElement("button");
|
|
2558
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2645
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Dn, h.setAttribute("aria-label", "Reduce");
|
|
2559
2646
|
let g = document.createElement("button");
|
|
2560
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2647
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Tn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2561
2648
|
let _ = document.createElement("button");
|
|
2562
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2649
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = En, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2563
2650
|
let v = document.createElement("div");
|
|
2564
2651
|
v.className = "liforma-ew__stage";
|
|
2565
2652
|
let y = document.createElement("div");
|
|
@@ -2587,11 +2674,11 @@ function Sn(e, t) {
|
|
|
2587
2674
|
p.style.left = `${e + n - a - 10}px`, p.style.top = `${t + 10}px`, p.style.right = "auto", p.style.bottom = "auto", p.style.width = "auto", p.style.height = "auto";
|
|
2588
2675
|
}, oe = (e, t) => {
|
|
2589
2676
|
if (R() !== "docked") return;
|
|
2590
|
-
let n =
|
|
2677
|
+
let n = yn(), r = xn(e - te, t - ne, n);
|
|
2591
2678
|
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2592
2679
|
}, se = (e, t) => {
|
|
2593
2680
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2594
|
-
let n =
|
|
2681
|
+
let n = yn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = xn(r + e, i + t, n);
|
|
2595
2682
|
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2596
2683
|
}, ce = (e) => {
|
|
2597
2684
|
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
@@ -2600,12 +2687,12 @@ function Sn(e, t) {
|
|
|
2600
2687
|
let t = I;
|
|
2601
2688
|
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
2602
2689
|
}, le = (e, t, n) => {
|
|
2603
|
-
if (S || R() !== "docked" || !
|
|
2690
|
+
if (S || R() !== "docked" || !Sn() || F !== null) return;
|
|
2604
2691
|
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2605
2692
|
let r = f.getBoundingClientRect();
|
|
2606
2693
|
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2607
2694
|
}, ue = (e) => {
|
|
2608
|
-
if (S || R() !== "docked" || !
|
|
2695
|
+
if (S || R() !== "docked" || !Sn() || F !== null) return;
|
|
2609
2696
|
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2610
2697
|
let t = f.getBoundingClientRect();
|
|
2611
2698
|
N = t.left, P = t.top;
|
|
@@ -2614,15 +2701,15 @@ function Sn(e, t) {
|
|
|
2614
2701
|
}, U = (e) => {
|
|
2615
2702
|
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2616
2703
|
}, W = () => {
|
|
2617
|
-
let e =
|
|
2704
|
+
let e = Sn(), t = R();
|
|
2618
2705
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2619
2706
|
h.hidden = !0;
|
|
2620
2707
|
return;
|
|
2621
2708
|
}
|
|
2622
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2709
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = On, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Dn, h.setAttribute("aria-label", "Reduce"));
|
|
2623
2710
|
}, fe = (e) => {
|
|
2624
|
-
let t =
|
|
2625
|
-
n =
|
|
2711
|
+
let t = yn(), n = e && N !== null && P !== null ? xn(N, P, t) : bn(t);
|
|
2712
|
+
n = xn(n.left, n.top, t), N = n.left, P = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2626
2713
|
}, pe = () => {
|
|
2627
2714
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2628
2715
|
requestAnimationFrame(() => {
|
|
@@ -2669,7 +2756,7 @@ function Sn(e, t) {
|
|
|
2669
2756
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2670
2757
|
}, xe = (e) => {
|
|
2671
2758
|
A?.(), A = null;
|
|
2672
|
-
let t =
|
|
2759
|
+
let t = kn(s, e, { parallax: ie });
|
|
2673
2760
|
return t ? (A = t, !0) : !1;
|
|
2674
2761
|
}, Se = () => {
|
|
2675
2762
|
if (xe(_e)) {
|
|
@@ -2698,13 +2785,13 @@ function Sn(e, t) {
|
|
|
2698
2785
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2699
2786
|
}), we = () => ({
|
|
2700
2787
|
...t.fit ? { fit: t.fit } : {},
|
|
2701
|
-
startButton:
|
|
2788
|
+
startButton: An(t),
|
|
2702
2789
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2703
2790
|
}), J = (e = !0) => {
|
|
2704
2791
|
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
2705
|
-
},
|
|
2792
|
+
}, Te = () => {
|
|
2706
2793
|
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
2707
|
-
},
|
|
2794
|
+
}, Ee = (e) => {
|
|
2708
2795
|
e.on("started", () => {
|
|
2709
2796
|
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
2710
2797
|
}), e.on("feedback", (e) => {
|
|
@@ -2712,28 +2799,28 @@ function Sn(e, t) {
|
|
|
2712
2799
|
}), e.on("feedbackFailed", (e) => {
|
|
2713
2800
|
S || t.onFeedbackFailed?.(e);
|
|
2714
2801
|
});
|
|
2715
|
-
},
|
|
2802
|
+
}, De = () => {
|
|
2716
2803
|
B(), u.hidden = !0, p.hidden = !0, ae(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
2717
|
-
},
|
|
2804
|
+
}, Oe = () => {
|
|
2718
2805
|
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
2719
2806
|
let e = b;
|
|
2720
2807
|
b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
2721
|
-
},
|
|
2808
|
+
}, ke = () => {
|
|
2722
2809
|
if (!S && $(a.dataset.state)) {
|
|
2723
2810
|
if (H(), x = !1, b && E) {
|
|
2724
2811
|
let e = b;
|
|
2725
2812
|
(async () => {
|
|
2726
|
-
D && (await ge(), S || b !== e) || (w && e.setWidgetChrome("collapsed"),
|
|
2813
|
+
D && (await ge(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), De(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && q(), t.onCollapsed?.(), t.onClose?.());
|
|
2727
2814
|
})();
|
|
2728
2815
|
return;
|
|
2729
2816
|
}
|
|
2730
|
-
|
|
2817
|
+
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
2731
2818
|
}
|
|
2732
|
-
},
|
|
2733
|
-
S ||
|
|
2734
|
-
|
|
2819
|
+
}, Y = () => {
|
|
2820
|
+
S || Sn() && R() === "expanded" && G(() => {
|
|
2821
|
+
Te();
|
|
2735
2822
|
});
|
|
2736
|
-
},
|
|
2823
|
+
}, X = () => {
|
|
2737
2824
|
S || R() === "docked" && (H(), G(() => {
|
|
2738
2825
|
ae(), J(!1), b?.setWidgetChrome("expanded");
|
|
2739
2826
|
}));
|
|
@@ -2749,12 +2836,12 @@ function Sn(e, t) {
|
|
|
2749
2836
|
let e = O;
|
|
2750
2837
|
l.hidden = !1, (async () => {
|
|
2751
2838
|
try {
|
|
2752
|
-
let t = await
|
|
2839
|
+
let t = await un.startSession(Ce());
|
|
2753
2840
|
if (S || e !== O) {
|
|
2754
2841
|
t.destroy();
|
|
2755
2842
|
return;
|
|
2756
2843
|
}
|
|
2757
|
-
b = t,
|
|
2844
|
+
b = t, Ee(t);
|
|
2758
2845
|
let n = await t.attach({
|
|
2759
2846
|
container: l,
|
|
2760
2847
|
...we(),
|
|
@@ -2785,7 +2872,7 @@ function Sn(e, t) {
|
|
|
2785
2872
|
return;
|
|
2786
2873
|
}
|
|
2787
2874
|
n.on("close", () => {
|
|
2788
|
-
S ||
|
|
2875
|
+
S || ke();
|
|
2789
2876
|
});
|
|
2790
2877
|
} catch (n) {
|
|
2791
2878
|
if (S || e !== O) return;
|
|
@@ -2808,12 +2895,12 @@ function Sn(e, t) {
|
|
|
2808
2895
|
x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
2809
2896
|
try {
|
|
2810
2897
|
J();
|
|
2811
|
-
let t = await
|
|
2898
|
+
let t = await un.startSession(Ce());
|
|
2812
2899
|
if (S || e !== O) {
|
|
2813
2900
|
t.destroy();
|
|
2814
2901
|
return;
|
|
2815
2902
|
}
|
|
2816
|
-
b = t,
|
|
2903
|
+
b = t, Ee(t);
|
|
2817
2904
|
let n = await t.attach({
|
|
2818
2905
|
container: v,
|
|
2819
2906
|
...we(),
|
|
@@ -2838,7 +2925,7 @@ function Sn(e, t) {
|
|
|
2838
2925
|
return;
|
|
2839
2926
|
}
|
|
2840
2927
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2841
|
-
S ||
|
|
2928
|
+
S || ke();
|
|
2842
2929
|
});
|
|
2843
2930
|
} catch (n) {
|
|
2844
2931
|
if (S || e !== O) return;
|
|
@@ -2866,23 +2953,23 @@ function Sn(e, t) {
|
|
|
2866
2953
|
}
|
|
2867
2954
|
}, Ie = (e) => {
|
|
2868
2955
|
if (e.stopPropagation(), R() === "expanded") {
|
|
2869
|
-
|
|
2956
|
+
Y();
|
|
2870
2957
|
return;
|
|
2871
2958
|
}
|
|
2872
|
-
R() === "docked" &&
|
|
2959
|
+
R() === "docked" && X();
|
|
2873
2960
|
}, Le = (e) => {
|
|
2874
2961
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
2875
2962
|
}, Re = (e) => {
|
|
2876
2963
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2877
2964
|
}, ze = (e) => {
|
|
2878
|
-
R() === "docked" &&
|
|
2965
|
+
R() === "docked" && Sn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2879
2966
|
}, Be = (e) => {
|
|
2880
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
2967
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), ke());
|
|
2881
2968
|
}, Ve = () => {
|
|
2882
2969
|
if (!S) {
|
|
2883
2970
|
if (R() === "docked") {
|
|
2884
|
-
if (!
|
|
2885
|
-
|
|
2971
|
+
if (!Sn()) {
|
|
2972
|
+
X();
|
|
2886
2973
|
return;
|
|
2887
2974
|
}
|
|
2888
2975
|
D ? G(() => {
|
|
@@ -2892,27 +2979,27 @@ function Sn(e, t) {
|
|
|
2892
2979
|
}
|
|
2893
2980
|
W();
|
|
2894
2981
|
}
|
|
2895
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
2982
|
+
}, He = typeof window < "u" ? window.matchMedia(fn) : null, Ue = () => {
|
|
2896
2983
|
if (!S) {
|
|
2897
|
-
if (R() === "docked" && !
|
|
2898
|
-
|
|
2984
|
+
if (R() === "docked" && !Sn()) {
|
|
2985
|
+
X();
|
|
2899
2986
|
return;
|
|
2900
2987
|
}
|
|
2901
2988
|
W();
|
|
2902
2989
|
}
|
|
2903
2990
|
};
|
|
2904
|
-
return o.addEventListener("click", Fe), d.addEventListener("click",
|
|
2905
|
-
e.stopPropagation(),
|
|
2991
|
+
return o.addEventListener("click", Fe), d.addEventListener("click", ke), _.addEventListener("click", (e) => {
|
|
2992
|
+
e.stopPropagation(), ke();
|
|
2906
2993
|
}), h.addEventListener("click", Ie), g.addEventListener("click", Re), p.addEventListener("pointerdown", ze), window.addEventListener("keydown", Be), window.addEventListener("resize", Ve), He?.addEventListener("change", Ue), Se(), W(), r === "eager" ? queueMicrotask(() => {
|
|
2907
2994
|
S || Ne();
|
|
2908
|
-
}) : r === "idle" && (ee =
|
|
2995
|
+
}) : r === "idle" && (ee = jn(() => {
|
|
2909
2996
|
S || Ne();
|
|
2910
2997
|
})), {
|
|
2911
2998
|
root: a,
|
|
2912
2999
|
expand: Fe,
|
|
2913
|
-
collapse:
|
|
2914
|
-
dock:
|
|
2915
|
-
maximize:
|
|
3000
|
+
collapse: ke,
|
|
3001
|
+
dock: Y,
|
|
3002
|
+
maximize: X,
|
|
2916
3003
|
prefetch() {
|
|
2917
3004
|
if (r === "onExpand") {
|
|
2918
3005
|
Ne();
|
|
@@ -2921,18 +3008,18 @@ function Sn(e, t) {
|
|
|
2921
3008
|
Ne();
|
|
2922
3009
|
},
|
|
2923
3010
|
destroy() {
|
|
2924
|
-
S || (S = !0, H(), ee?.(), ee = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", Be), window.removeEventListener("resize", Ve), He?.removeEventListener("change", Ue),
|
|
3011
|
+
S || (S = !0, H(), ee?.(), ee = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", Be), window.removeEventListener("resize", Ve), He?.removeEventListener("change", Ue), Oe(), De(), e.replaceChildren());
|
|
2925
3012
|
}
|
|
2926
3013
|
};
|
|
2927
3014
|
}
|
|
2928
3015
|
//#endregion
|
|
2929
3016
|
//#region src/react/ExperienceWidget.tsx
|
|
2930
|
-
function
|
|
3017
|
+
function Nn(t) {
|
|
2931
3018
|
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: ee, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = t, te = m === "bottom-right" || m === "bottom-left";
|
|
2932
3019
|
return e(() => {
|
|
2933
3020
|
let e = r.current;
|
|
2934
3021
|
if (!e || !i.trim()) return;
|
|
2935
|
-
let t =
|
|
3022
|
+
let t = Mn(e, {
|
|
2936
3023
|
experienceId: i,
|
|
2937
3024
|
alt: o,
|
|
2938
3025
|
galleryThumb: s,
|
|
@@ -3009,6 +3096,12 @@ function Cn(t) {
|
|
|
3009
3096
|
});
|
|
3010
3097
|
}
|
|
3011
3098
|
//#endregion
|
|
3012
|
-
|
|
3099
|
+
//#region src/next/index.ts
|
|
3100
|
+
function Pn(e = {}) {
|
|
3101
|
+
let t = v(e);
|
|
3102
|
+
return { POST: ({ request: e }) => t(e) };
|
|
3103
|
+
}
|
|
3104
|
+
//#endregion
|
|
3105
|
+
export { pe as ExperienceThumbnail, Nn as ExperienceWidget, v as createLiformaSessionRouteHandler, Pn as createLiformaSvelteKitSessionHandler };
|
|
3013
3106
|
|
|
3014
3107
|
//# sourceMappingURL=index.js.map
|