@liforma/client 0.4.4 → 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 +12 -0
- package/dist/next/index.js +462 -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 +8 -1
- package/dist/next/v2/experience.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/npm/index.js +554 -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 +8 -1
- package/dist/npm/v2/experience.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/types/sessionInteraction.d.ts +19 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +9 -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 +2 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +671 -588
- 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 +8 -1
- package/dist/react/v2/experience.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/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +8 -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,50 +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;
|
|
1393
1463
|
}
|
|
1394
|
-
function
|
|
1464
|
+
function vt(e, t) {
|
|
1395
1465
|
return e?.trim() || t?.trim() || void 0;
|
|
1396
1466
|
}
|
|
1397
|
-
function
|
|
1398
|
-
let c = (e ??
|
|
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();
|
|
1399
1469
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1400
1470
|
let f = r?.trim();
|
|
1401
|
-
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());
|
|
1402
1472
|
}
|
|
1403
|
-
function
|
|
1473
|
+
function bt(e) {
|
|
1404
1474
|
if (typeof location > "u") return e;
|
|
1405
1475
|
let t = new URL(e);
|
|
1406
1476
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1407
1477
|
}
|
|
1408
|
-
function
|
|
1478
|
+
function xt(e) {
|
|
1409
1479
|
return new URL(e).origin;
|
|
1410
1480
|
}
|
|
1411
1481
|
//#endregion
|
|
1412
1482
|
//#region src/v2/experienceEvents.ts
|
|
1413
|
-
function
|
|
1483
|
+
function St() {
|
|
1414
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)}`;
|
|
1415
1485
|
}
|
|
1416
|
-
function
|
|
1486
|
+
function Ct(e, t, n) {
|
|
1417
1487
|
return {
|
|
1418
|
-
id:
|
|
1488
|
+
id: St(),
|
|
1419
1489
|
type: e,
|
|
1420
1490
|
sessionId: t,
|
|
1421
1491
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1422
1492
|
data: n
|
|
1423
1493
|
};
|
|
1424
1494
|
}
|
|
1425
|
-
function
|
|
1495
|
+
function wt() {
|
|
1426
1496
|
return {
|
|
1427
1497
|
ready: /* @__PURE__ */ new Set(),
|
|
1428
1498
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1441,39 +1511,39 @@ function ht() {
|
|
|
1441
1511
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1442
1512
|
};
|
|
1443
1513
|
}
|
|
1444
|
-
function
|
|
1514
|
+
function Tt(e, t, n) {
|
|
1445
1515
|
return e[t].add(n), () => e[t].delete(n);
|
|
1446
1516
|
}
|
|
1447
|
-
function
|
|
1517
|
+
function Et(e, t, n) {
|
|
1448
1518
|
for (let r of e[t]) r(n);
|
|
1449
1519
|
}
|
|
1450
|
-
function
|
|
1520
|
+
function Dt(e) {
|
|
1451
1521
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1452
1522
|
}
|
|
1453
1523
|
//#endregion
|
|
1454
1524
|
//#region src/v2/speech/types.ts
|
|
1455
|
-
function
|
|
1525
|
+
function Ot(e) {
|
|
1456
1526
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1457
1527
|
}
|
|
1458
|
-
function
|
|
1528
|
+
function kt(e) {
|
|
1459
1529
|
return "url" in e && typeof e.url == "string";
|
|
1460
1530
|
}
|
|
1461
|
-
function
|
|
1531
|
+
function At(e) {
|
|
1462
1532
|
if (!("track" in e)) return !1;
|
|
1463
1533
|
let t = e.track;
|
|
1464
1534
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1465
1535
|
}
|
|
1466
|
-
function
|
|
1467
|
-
return !
|
|
1536
|
+
function jt(e) {
|
|
1537
|
+
return !Ot(e) && !kt(e) && !At(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1468
1538
|
}
|
|
1469
|
-
var
|
|
1539
|
+
var Mt = [
|
|
1470
1540
|
8e3,
|
|
1471
1541
|
16e3,
|
|
1472
1542
|
22050,
|
|
1473
1543
|
24e3,
|
|
1474
1544
|
44100,
|
|
1475
1545
|
48e3
|
|
1476
|
-
],
|
|
1546
|
+
], Nt = {
|
|
1477
1547
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1478
1548
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1479
1549
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1484,14 +1554,14 @@ var Ct = [
|
|
|
1484
1554
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1485
1555
|
MAX_PENDING_WRITES: 8,
|
|
1486
1556
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1487
|
-
},
|
|
1557
|
+
}, Pt = class extends Error {
|
|
1488
1558
|
operation;
|
|
1489
1559
|
requiredCapability;
|
|
1490
1560
|
name = "UnsupportedSpeechOperationError";
|
|
1491
1561
|
constructor(e, t) {
|
|
1492
1562
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1493
1563
|
}
|
|
1494
|
-
},
|
|
1564
|
+
}, Ft = class extends Error {
|
|
1495
1565
|
name = "SpeechUtteranceClosedError";
|
|
1496
1566
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1497
1567
|
super(e);
|
|
@@ -1501,72 +1571,72 @@ var Ct = [
|
|
|
1501
1571
|
constructor(e, t) {
|
|
1502
1572
|
super(e, t);
|
|
1503
1573
|
}
|
|
1504
|
-
},
|
|
1574
|
+
}, It = class extends Error {
|
|
1505
1575
|
name = "SpeechBufferTimeoutError";
|
|
1506
1576
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1507
1577
|
super(e);
|
|
1508
1578
|
}
|
|
1509
1579
|
};
|
|
1510
|
-
function
|
|
1580
|
+
function Lt(e = "none") {
|
|
1511
1581
|
return {
|
|
1512
1582
|
mode: e,
|
|
1513
1583
|
trackedDurationMs: 0,
|
|
1514
1584
|
fallbackDurationMs: 0
|
|
1515
1585
|
};
|
|
1516
1586
|
}
|
|
1517
|
-
function
|
|
1518
|
-
return
|
|
1587
|
+
function Rt(e) {
|
|
1588
|
+
return Mt.includes(e);
|
|
1519
1589
|
}
|
|
1520
|
-
function
|
|
1590
|
+
function zt(e) {
|
|
1521
1591
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1522
1592
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1523
|
-
if (!
|
|
1593
|
+
if (!Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1524
1594
|
}
|
|
1525
|
-
function
|
|
1526
|
-
if (
|
|
1527
|
-
|
|
1595
|
+
function Bt(e) {
|
|
1596
|
+
if (Ot(e)) {
|
|
1597
|
+
zt(e.format);
|
|
1528
1598
|
return;
|
|
1529
1599
|
}
|
|
1530
|
-
if (
|
|
1600
|
+
if (kt(e)) {
|
|
1531
1601
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1532
|
-
if (e.sampleRate !== void 0 && !
|
|
1602
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1533
1603
|
return;
|
|
1534
1604
|
}
|
|
1535
|
-
if (
|
|
1605
|
+
if (At(e)) {
|
|
1536
1606
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1537
|
-
if (e.sampleRate !== void 0 && !
|
|
1607
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1538
1608
|
return;
|
|
1539
1609
|
}
|
|
1540
|
-
if (
|
|
1610
|
+
if (jt(e)) {
|
|
1541
1611
|
let t = e.encoding.trim().toLowerCase();
|
|
1542
1612
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1543
1613
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1544
|
-
if (e.sampleRate !== void 0 && !
|
|
1614
|
+
if (e.sampleRate !== void 0 && !Rt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1545
1615
|
return;
|
|
1546
1616
|
}
|
|
1547
1617
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1548
1618
|
}
|
|
1549
|
-
function
|
|
1550
|
-
if (e.format) return
|
|
1619
|
+
function Vt(e) {
|
|
1620
|
+
if (e.format) return zt(e.format), e.format;
|
|
1551
1621
|
if (e.track) {
|
|
1552
1622
|
let t = {
|
|
1553
1623
|
encoding: "pcm_s16le",
|
|
1554
1624
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1555
1625
|
channels: 1
|
|
1556
1626
|
};
|
|
1557
|
-
return
|
|
1627
|
+
return zt(t), t;
|
|
1558
1628
|
}
|
|
1559
1629
|
throw new Q("createUtterance requires format or track.");
|
|
1560
1630
|
}
|
|
1561
|
-
function
|
|
1631
|
+
function Ht(e) {
|
|
1562
1632
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1563
1633
|
}
|
|
1564
|
-
function
|
|
1634
|
+
function Ut(e) {
|
|
1565
1635
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1566
1636
|
}
|
|
1567
1637
|
//#endregion
|
|
1568
1638
|
//#region src/byo/pcm.ts
|
|
1569
|
-
function
|
|
1639
|
+
function Wt(e) {
|
|
1570
1640
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1571
1641
|
for (let t = 0; t < e.length; t++) {
|
|
1572
1642
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1576,11 +1646,11 @@ function Ft(e) {
|
|
|
1576
1646
|
}
|
|
1577
1647
|
//#endregion
|
|
1578
1648
|
//#region src/byo/resample.ts
|
|
1579
|
-
function
|
|
1649
|
+
function Gt(e, t, n, r, i) {
|
|
1580
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;
|
|
1581
1651
|
return ((a * i + o) * i + s) * i + c;
|
|
1582
1652
|
}
|
|
1583
|
-
function
|
|
1653
|
+
function Kt(e, t) {
|
|
1584
1654
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1585
1655
|
if (e === t) return {
|
|
1586
1656
|
fromRate: e,
|
|
@@ -1603,7 +1673,7 @@ function Lt(e, t) {
|
|
|
1603
1673
|
let a = [];
|
|
1604
1674
|
for (; i + 2 < r.length - 1;) {
|
|
1605
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);
|
|
1606
|
-
a.push(
|
|
1676
|
+
a.push(Gt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1607
1677
|
}
|
|
1608
1678
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1609
1679
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1615,7 +1685,7 @@ function Lt(e, t) {
|
|
|
1615
1685
|
}
|
|
1616
1686
|
//#endregion
|
|
1617
1687
|
//#region src/byo/audioCapture.ts
|
|
1618
|
-
var
|
|
1688
|
+
var qt = "liforma-pcm-capture", Jt = `
|
|
1619
1689
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1620
1690
|
process(inputs) {
|
|
1621
1691
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1627,29 +1697,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1627
1697
|
return true;
|
|
1628
1698
|
}
|
|
1629
1699
|
}
|
|
1630
|
-
registerProcessor('${
|
|
1631
|
-
`,
|
|
1632
|
-
function
|
|
1633
|
-
return
|
|
1700
|
+
registerProcessor('${qt}', LiformaPcmCaptureProcessor);
|
|
1701
|
+
`, Yt = null;
|
|
1702
|
+
function Xt() {
|
|
1703
|
+
return Yt ||= URL.createObjectURL(new Blob([Jt], { type: "application/javascript" })), Yt;
|
|
1634
1704
|
}
|
|
1635
|
-
function
|
|
1705
|
+
function Zt() {
|
|
1636
1706
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1637
1707
|
}
|
|
1638
|
-
async function
|
|
1639
|
-
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();
|
|
1640
1710
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1641
1711
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1642
1712
|
l.gain.value = 0;
|
|
1643
|
-
let u = s.sampleRate, d =
|
|
1713
|
+
let u = s.sampleRate, d = Kt(u, n), f = !1, p = !1, m = (e) => {
|
|
1644
1714
|
if (f || i && !i()) return;
|
|
1645
1715
|
let t = d.push(e);
|
|
1646
|
-
t.length !== 0 && r(
|
|
1716
|
+
t.length !== 0 && r(Wt(t));
|
|
1647
1717
|
}, h = () => void 0;
|
|
1648
1718
|
return await (async () => {
|
|
1649
1719
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1650
1720
|
try {
|
|
1651
|
-
await s.audioWorklet.addModule(
|
|
1652
|
-
let e = new AudioWorkletNode(s,
|
|
1721
|
+
await s.audioWorklet.addModule(Xt());
|
|
1722
|
+
let e = new AudioWorkletNode(s, qt, {
|
|
1653
1723
|
numberOfInputs: 1,
|
|
1654
1724
|
numberOfOutputs: 1,
|
|
1655
1725
|
outputChannelCount: [1]
|
|
@@ -1699,7 +1769,7 @@ async function Ut(e) {
|
|
|
1699
1769
|
}
|
|
1700
1770
|
//#endregion
|
|
1701
1771
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1702
|
-
async function
|
|
1772
|
+
async function $t(e) {
|
|
1703
1773
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1704
1774
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1705
1775
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1708,18 +1778,18 @@ async function Wt(e) {
|
|
|
1708
1778
|
s || (s = !0, c?.stop(), c = null);
|
|
1709
1779
|
};
|
|
1710
1780
|
try {
|
|
1711
|
-
c = await
|
|
1781
|
+
c = await Qt({
|
|
1712
1782
|
mediaStream: a,
|
|
1713
1783
|
targetSampleRate: r,
|
|
1714
1784
|
shouldSend: () => !s && !i?.aborted,
|
|
1715
1785
|
onPcm: (e) => {
|
|
1716
1786
|
if (s || i?.aborted) return;
|
|
1717
|
-
let t =
|
|
1787
|
+
let t = Ht(e);
|
|
1718
1788
|
o = o.then(async () => {
|
|
1719
1789
|
if (s || i?.aborted) return;
|
|
1720
1790
|
let e = 0;
|
|
1721
1791
|
for (; e < t.byteLength;) {
|
|
1722
|
-
let r = Math.min(e +
|
|
1792
|
+
let r = Math.min(e + Nt.MAX_CHUNK_BYTES, t.byteLength);
|
|
1723
1793
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1724
1794
|
let i = t.subarray(e, r);
|
|
1725
1795
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1743,10 +1813,10 @@ async function Wt(e) {
|
|
|
1743
1813
|
}
|
|
1744
1814
|
//#endregion
|
|
1745
1815
|
//#region src/v2/speech/speechController.ts
|
|
1746
|
-
async function
|
|
1747
|
-
if (
|
|
1748
|
-
if (
|
|
1749
|
-
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);
|
|
1750
1820
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1751
1821
|
return {
|
|
1752
1822
|
kind: "pcm",
|
|
@@ -1754,17 +1824,17 @@ async function Gt(e, t) {
|
|
|
1754
1824
|
format: e.format
|
|
1755
1825
|
};
|
|
1756
1826
|
}
|
|
1757
|
-
if (
|
|
1827
|
+
if (kt(e)) return {
|
|
1758
1828
|
kind: "url",
|
|
1759
1829
|
url: e.url.trim(),
|
|
1760
1830
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1761
1831
|
};
|
|
1762
|
-
if (!
|
|
1832
|
+
if (!jt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1763
1833
|
let n;
|
|
1764
1834
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1765
1835
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1766
1836
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1767
|
-
} else n =
|
|
1837
|
+
} else n = Ht(e.data);
|
|
1768
1838
|
return {
|
|
1769
1839
|
kind: "encoded",
|
|
1770
1840
|
data: n.slice().buffer,
|
|
@@ -1772,10 +1842,10 @@ async function Gt(e, t) {
|
|
|
1772
1842
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1773
1843
|
};
|
|
1774
1844
|
}
|
|
1775
|
-
function
|
|
1845
|
+
function tn() {
|
|
1776
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)}`;
|
|
1777
1847
|
}
|
|
1778
|
-
function
|
|
1848
|
+
function nn(e, t = "completed") {
|
|
1779
1849
|
return {
|
|
1780
1850
|
utteranceId: e.speechId,
|
|
1781
1851
|
characterId: e.characterId,
|
|
@@ -1789,13 +1859,13 @@ function qt(e, t = "completed") {
|
|
|
1789
1859
|
}
|
|
1790
1860
|
};
|
|
1791
1861
|
}
|
|
1792
|
-
function
|
|
1862
|
+
function rn(e) {
|
|
1793
1863
|
return e instanceof Error ? e : new Q(String(e));
|
|
1794
1864
|
}
|
|
1795
|
-
function
|
|
1865
|
+
function an(e) {
|
|
1796
1866
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1797
1867
|
}
|
|
1798
|
-
var
|
|
1868
|
+
var on = class {
|
|
1799
1869
|
id;
|
|
1800
1870
|
characterId;
|
|
1801
1871
|
result;
|
|
@@ -1824,29 +1894,29 @@ var Xt = class {
|
|
|
1824
1894
|
queue: e.queue,
|
|
1825
1895
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1826
1896
|
}).catch((e) => {
|
|
1827
|
-
throw this.fail(
|
|
1897
|
+
throw this.fail(rn(e)), rn(e);
|
|
1828
1898
|
}), this.signal?.addEventListener("abort", () => {
|
|
1829
1899
|
this.cancel();
|
|
1830
1900
|
}, { once: !0 });
|
|
1831
1901
|
}
|
|
1832
1902
|
async write(e, t) {
|
|
1833
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1834
|
-
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);
|
|
1835
1905
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1836
|
-
if (n.byteLength >
|
|
1906
|
+
if (n.byteLength > Nt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Nt.MAX_CHUNK_BYTES}).`);
|
|
1837
1907
|
if (n.byteLength === 0) return;
|
|
1838
|
-
let r = t?.timeoutMs ??
|
|
1908
|
+
let r = t?.timeoutMs ?? Nt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1839
1909
|
await this.acquireWriteSlot(r);
|
|
1840
1910
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1841
|
-
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.");
|
|
1842
1912
|
let a = async () => {
|
|
1843
|
-
if (this.closed || this.settled) throw new
|
|
1913
|
+
if (this.closed || this.settled) throw new Ft();
|
|
1844
1914
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1845
1915
|
utteranceId: this.id,
|
|
1846
1916
|
audio: t.buffer,
|
|
1847
1917
|
byteLength: t.byteLength
|
|
1848
1918
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1849
|
-
setTimeout(() => t(new
|
|
1919
|
+
setTimeout(() => t(new It()), r);
|
|
1850
1920
|
})]);
|
|
1851
1921
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1852
1922
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1858,7 +1928,7 @@ var Xt = class {
|
|
|
1858
1928
|
}
|
|
1859
1929
|
}
|
|
1860
1930
|
async setTranscript(e) {
|
|
1861
|
-
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();
|
|
1862
1932
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1863
1933
|
utteranceId: this.id,
|
|
1864
1934
|
transcript: e
|
|
@@ -1875,7 +1945,7 @@ var Xt = class {
|
|
|
1875
1945
|
});
|
|
1876
1946
|
return this.resolve(t), t;
|
|
1877
1947
|
} catch (e) {
|
|
1878
|
-
let t =
|
|
1948
|
+
let t = rn(e);
|
|
1879
1949
|
throw this.fail(t), t;
|
|
1880
1950
|
}
|
|
1881
1951
|
}
|
|
@@ -1893,11 +1963,11 @@ var Xt = class {
|
|
|
1893
1963
|
characterId: this.characterId,
|
|
1894
1964
|
status: "cancelled",
|
|
1895
1965
|
durationMs: 0,
|
|
1896
|
-
animation:
|
|
1966
|
+
animation: Lt("none")
|
|
1897
1967
|
};
|
|
1898
1968
|
return this.resolve(t), t;
|
|
1899
1969
|
} catch (e) {
|
|
1900
|
-
let t =
|
|
1970
|
+
let t = rn(e);
|
|
1901
1971
|
throw this.fail(t), t;
|
|
1902
1972
|
}
|
|
1903
1973
|
}
|
|
@@ -1910,19 +1980,19 @@ var Xt = class {
|
|
|
1910
1980
|
return e;
|
|
1911
1981
|
}
|
|
1912
1982
|
resolve(e) {
|
|
1913
|
-
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()));
|
|
1914
1984
|
}
|
|
1915
1985
|
fail(e) {
|
|
1916
1986
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1917
1987
|
}
|
|
1918
1988
|
async acquireWriteSlot(e) {
|
|
1919
|
-
if (this.pendingWriteCount <
|
|
1989
|
+
if (this.pendingWriteCount < Nt.MAX_PENDING_WRITES) {
|
|
1920
1990
|
this.pendingWriteCount += 1;
|
|
1921
1991
|
return;
|
|
1922
1992
|
}
|
|
1923
1993
|
await new Promise((t, n) => {
|
|
1924
1994
|
let r = setTimeout(() => {
|
|
1925
|
-
n(new
|
|
1995
|
+
n(new It());
|
|
1926
1996
|
}, e);
|
|
1927
1997
|
this.pendingWriteWaiters.push({
|
|
1928
1998
|
resolve: () => {
|
|
@@ -1941,13 +2011,13 @@ var Xt = class {
|
|
|
1941
2011
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1942
2012
|
}
|
|
1943
2013
|
};
|
|
1944
|
-
function
|
|
2014
|
+
function sn(e) {
|
|
1945
2015
|
let t = null, n = (t, n) => {
|
|
1946
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2016
|
+
if (!e.getCapabilities()[n]) throw new Pt(t, n);
|
|
1947
2017
|
}, r = {
|
|
1948
2018
|
async speak(r) {
|
|
1949
2019
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1950
|
-
let i =
|
|
2020
|
+
let i = Ut(r.queue ?? "append");
|
|
1951
2021
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1952
2022
|
let a = e.getIframeHost();
|
|
1953
2023
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -1967,41 +2037,41 @@ function Zt(e) {
|
|
|
1967
2037
|
return;
|
|
1968
2038
|
}
|
|
1969
2039
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1970
|
-
t.removeEventListener("abort", s), n(
|
|
2040
|
+
t.removeEventListener("abort", s), n(nn(e, "completed"));
|
|
1971
2041
|
}, (a) => {
|
|
1972
|
-
if (t.removeEventListener("abort", s),
|
|
2042
|
+
if (t.removeEventListener("abort", s), an(a)) {
|
|
1973
2043
|
n({
|
|
1974
2044
|
utteranceId: "utt_interrupted",
|
|
1975
2045
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1976
2046
|
status: "interrupted",
|
|
1977
2047
|
durationMs: 0,
|
|
1978
2048
|
transcript: r.text,
|
|
1979
|
-
animation:
|
|
2049
|
+
animation: Lt("none")
|
|
1980
2050
|
});
|
|
1981
2051
|
return;
|
|
1982
2052
|
}
|
|
1983
|
-
i(
|
|
2053
|
+
i(rn(a));
|
|
1984
2054
|
});
|
|
1985
2055
|
});
|
|
1986
2056
|
}
|
|
1987
2057
|
try {
|
|
1988
|
-
return
|
|
2058
|
+
return nn(await o, "completed");
|
|
1989
2059
|
} catch (t) {
|
|
1990
|
-
if (
|
|
2060
|
+
if (an(t)) return {
|
|
1991
2061
|
utteranceId: "utt_interrupted",
|
|
1992
2062
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1993
2063
|
status: "interrupted",
|
|
1994
2064
|
durationMs: 0,
|
|
1995
2065
|
transcript: r.text,
|
|
1996
|
-
animation:
|
|
2066
|
+
animation: Lt("none")
|
|
1997
2067
|
};
|
|
1998
|
-
throw
|
|
2068
|
+
throw rn(t);
|
|
1999
2069
|
}
|
|
2000
2070
|
},
|
|
2001
2071
|
async play(i) {
|
|
2002
|
-
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");
|
|
2003
2073
|
let a = i.queue ?? "append";
|
|
2004
|
-
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)) {
|
|
2005
2075
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2006
2076
|
return r.createUtterance({
|
|
2007
2077
|
format: {
|
|
@@ -2017,7 +2087,7 @@ function Zt(e) {
|
|
|
2017
2087
|
}
|
|
2018
2088
|
let o = e.getIframeHost();
|
|
2019
2089
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2020
|
-
let s = await
|
|
2090
|
+
let s = await en(i.audio, i.signal);
|
|
2021
2091
|
return o.speechPlay({
|
|
2022
2092
|
source: s,
|
|
2023
2093
|
characterId: i.characterId,
|
|
@@ -2029,13 +2099,13 @@ function Zt(e) {
|
|
|
2029
2099
|
},
|
|
2030
2100
|
createUtterance(r) {
|
|
2031
2101
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2032
|
-
let i =
|
|
2102
|
+
let i = Vt(r);
|
|
2033
2103
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2034
2104
|
let a = r.queue ?? "replace-active";
|
|
2035
2105
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2036
2106
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2037
|
-
let o = new
|
|
2038
|
-
id:
|
|
2107
|
+
let o = new on({
|
|
2108
|
+
id: tn(),
|
|
2039
2109
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2040
2110
|
format: i,
|
|
2041
2111
|
queue: a,
|
|
@@ -2047,7 +2117,7 @@ function Zt(e) {
|
|
|
2047
2117
|
t === o && (t = null);
|
|
2048
2118
|
}), r.track && (async () => {
|
|
2049
2119
|
try {
|
|
2050
|
-
if (await
|
|
2120
|
+
if (await $t({
|
|
2051
2121
|
track: r.track,
|
|
2052
2122
|
utterance: o,
|
|
2053
2123
|
sampleRate: i.sampleRate,
|
|
@@ -2075,16 +2145,16 @@ function Zt(e) {
|
|
|
2075
2145
|
}
|
|
2076
2146
|
//#endregion
|
|
2077
2147
|
//#region src/v2/types/sessionInteraction.ts
|
|
2078
|
-
function
|
|
2148
|
+
function cn(e) {
|
|
2079
2149
|
let t = e?.trim();
|
|
2080
2150
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2081
2151
|
}
|
|
2082
2152
|
//#endregion
|
|
2083
2153
|
//#region src/v2/experience.ts
|
|
2084
|
-
function
|
|
2154
|
+
function ln(e) {
|
|
2085
2155
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2086
2156
|
}
|
|
2087
|
-
var
|
|
2157
|
+
var un = class e {
|
|
2088
2158
|
bootstrap;
|
|
2089
2159
|
conversationProcessor;
|
|
2090
2160
|
iframeHost = null;
|
|
@@ -2099,16 +2169,16 @@ var en = class e {
|
|
|
2099
2169
|
attached = !1;
|
|
2100
2170
|
pendingFit = null;
|
|
2101
2171
|
closeHandlers = [];
|
|
2102
|
-
eventRegistry =
|
|
2172
|
+
eventRegistry = wt();
|
|
2103
2173
|
readyEnvelope = null;
|
|
2104
2174
|
startedEnvelope = null;
|
|
2105
2175
|
conversationCache = [];
|
|
2106
2176
|
speech;
|
|
2107
2177
|
constructor(e) {
|
|
2108
|
-
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({
|
|
2109
2179
|
getIframeHost: () => this.iframeHost,
|
|
2110
2180
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2111
|
-
getCapabilities: () =>
|
|
2181
|
+
getCapabilities: () => dn(this.resolvedSession),
|
|
2112
2182
|
getActiveCharacterId: () => "character_unknown",
|
|
2113
2183
|
onProcessorInterrupt: () => {
|
|
2114
2184
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2152,6 +2222,7 @@ var en = class e {
|
|
|
2152
2222
|
mode: t.mode,
|
|
2153
2223
|
speechInputMode: t.speechInputMode,
|
|
2154
2224
|
speechOnly: t.speechOnly,
|
|
2225
|
+
attribution: t.attribution,
|
|
2155
2226
|
ui: t.ui,
|
|
2156
2227
|
onStart: t.onStart,
|
|
2157
2228
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2173,6 +2244,7 @@ var en = class e {
|
|
|
2173
2244
|
mode: t.mode,
|
|
2174
2245
|
speechInputMode: t.speechInputMode,
|
|
2175
2246
|
speechOnly: t.speechOnly,
|
|
2247
|
+
attribution: t.attribution,
|
|
2176
2248
|
ui: t.ui,
|
|
2177
2249
|
onStart: t.onStart,
|
|
2178
2250
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2187,7 +2259,7 @@ var en = class e {
|
|
|
2187
2259
|
return null;
|
|
2188
2260
|
}
|
|
2189
2261
|
on(e, t) {
|
|
2190
|
-
let n =
|
|
2262
|
+
let n = Tt(this.eventRegistry, e, t);
|
|
2191
2263
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2192
2264
|
}
|
|
2193
2265
|
async attach(e) {
|
|
@@ -2201,13 +2273,13 @@ var en = class e {
|
|
|
2201
2273
|
if (this.closed) throw Error("Session has ended.");
|
|
2202
2274
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2203
2275
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2204
|
-
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) => {
|
|
2205
2277
|
o = e;
|
|
2206
2278
|
}), c = null, l = new Promise((e) => {
|
|
2207
2279
|
c = e;
|
|
2208
|
-
}), u =
|
|
2280
|
+
}), u = pt((e) => {
|
|
2209
2281
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2210
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2282
|
+
}), d = this.bootstrap.onUserTranscript, f = ft({
|
|
2211
2283
|
container: e.container,
|
|
2212
2284
|
src: i,
|
|
2213
2285
|
playerOrigin: a,
|
|
@@ -2270,7 +2342,7 @@ var en = class e {
|
|
|
2270
2342
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2271
2343
|
});
|
|
2272
2344
|
this.iframeHost = f;
|
|
2273
|
-
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, {
|
|
2274
2346
|
experienceId: this.bootstrap.experienceId,
|
|
2275
2347
|
locale: this.bootstrap.locale,
|
|
2276
2348
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2279,15 +2351,17 @@ var en = class e {
|
|
|
2279
2351
|
mode: p.mode,
|
|
2280
2352
|
speechInputMode: p.speechInputMode,
|
|
2281
2353
|
speechOnly: this.bootstrap.speechOnly,
|
|
2354
|
+
attribution: this.bootstrap.attribution,
|
|
2282
2355
|
signal: this.endpointAbortController.signal
|
|
2283
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2356
|
+
})) : this.bootstrap.kind === "public" ? Ue(this.bootstrap.experienceId, {
|
|
2284
2357
|
locale: this.bootstrap.locale,
|
|
2285
2358
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2286
2359
|
learningLocale: this.bootstrap.learningLocale,
|
|
2287
2360
|
language: this.bootstrap.language,
|
|
2288
2361
|
mode: p.mode,
|
|
2289
2362
|
speechInputMode: p.speechInputMode,
|
|
2290
|
-
speechOnly: this.bootstrap.speechOnly
|
|
2363
|
+
speechOnly: this.bootstrap.speechOnly,
|
|
2364
|
+
attribution: this.bootstrap.attribution
|
|
2291
2365
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2292
2366
|
session: this.bootstrap.session,
|
|
2293
2367
|
launch: this.bootstrap.launch
|
|
@@ -2302,7 +2376,7 @@ var en = class e {
|
|
|
2302
2376
|
f.postParentHello();
|
|
2303
2377
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2304
2378
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2305
|
-
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, _, {
|
|
2306
2380
|
startButton: e.startButton,
|
|
2307
2381
|
showFeedback: e.showFeedback
|
|
2308
2382
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
@@ -2336,11 +2410,16 @@ var en = class e {
|
|
|
2336
2410
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2337
2411
|
}
|
|
2338
2412
|
async setFit(e) {
|
|
2339
|
-
let t =
|
|
2413
|
+
let t = cn(e);
|
|
2340
2414
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2341
2415
|
if (this.closed) throw Error("Session has ended.");
|
|
2342
2416
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2343
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
|
+
}
|
|
2344
2423
|
getLastTurn() {
|
|
2345
2424
|
if (this.conversationCache.length === 0) return [];
|
|
2346
2425
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2350,7 +2429,7 @@ var en = class e {
|
|
|
2350
2429
|
this.close();
|
|
2351
2430
|
}
|
|
2352
2431
|
destroy() {
|
|
2353
|
-
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);
|
|
2354
2433
|
}
|
|
2355
2434
|
resolveMintInteraction() {
|
|
2356
2435
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2362,8 +2441,8 @@ var en = class e {
|
|
|
2362
2441
|
return this.resolvedSession?.id ?? "";
|
|
2363
2442
|
}
|
|
2364
2443
|
emitWrapped(e, t) {
|
|
2365
|
-
let n =
|
|
2366
|
-
return
|
|
2444
|
+
let n = Ct(e, this.getSessionId(), t);
|
|
2445
|
+
return Et(this.eventRegistry, e, n), n;
|
|
2367
2446
|
}
|
|
2368
2447
|
queueProcessorTurn(e) {
|
|
2369
2448
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2372,7 +2451,7 @@ var en = class e {
|
|
|
2372
2451
|
let n = this.processorAbortController.signal;
|
|
2373
2452
|
this.processorChain = this.processorChain.then(async () => {
|
|
2374
2453
|
if (!n.aborted) try {
|
|
2375
|
-
let r = await
|
|
2454
|
+
let r = await qe(t, {
|
|
2376
2455
|
utteranceId: e.utteranceId,
|
|
2377
2456
|
text: e.text,
|
|
2378
2457
|
conversation: this.conversationCache,
|
|
@@ -2422,7 +2501,7 @@ var en = class e {
|
|
|
2422
2501
|
};
|
|
2423
2502
|
}
|
|
2424
2503
|
};
|
|
2425
|
-
function
|
|
2504
|
+
function dn(e) {
|
|
2426
2505
|
return e ? {
|
|
2427
2506
|
textSpeech: e.capabilities.speech.output,
|
|
2428
2507
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2433,41 +2512,41 @@ function tn(e) {
|
|
|
2433
2512
|
}
|
|
2434
2513
|
//#endregion
|
|
2435
2514
|
//#region src/widget/dockGeometry.ts
|
|
2436
|
-
var
|
|
2437
|
-
function
|
|
2515
|
+
var fn = "(min-width: 768px)", pn = 24, mn = .5, hn = 1200, gn = .85, _n = 9 / 16;
|
|
2516
|
+
function vn() {
|
|
2438
2517
|
if (typeof window > "u") return 800;
|
|
2439
2518
|
let e = window.screen?.availHeight;
|
|
2440
2519
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2441
2520
|
}
|
|
2442
|
-
function
|
|
2443
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2444
|
-
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)), {
|
|
2445
2524
|
width: Math.round(s),
|
|
2446
2525
|
height: Math.round(o)
|
|
2447
2526
|
};
|
|
2448
2527
|
}
|
|
2449
|
-
function
|
|
2528
|
+
function bn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = pn) {
|
|
2450
2529
|
return {
|
|
2451
2530
|
left: Math.max(r, t - e.width - r),
|
|
2452
2531
|
top: Math.max(r, n - e.height - r)
|
|
2453
2532
|
};
|
|
2454
2533
|
}
|
|
2455
|
-
function
|
|
2534
|
+
function xn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = pn) {
|
|
2456
2535
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2457
2536
|
return {
|
|
2458
2537
|
left: Math.min(Math.max(a, e), o),
|
|
2459
2538
|
top: Math.min(Math.max(a, t), s)
|
|
2460
2539
|
};
|
|
2461
2540
|
}
|
|
2462
|
-
function
|
|
2463
|
-
return e(
|
|
2541
|
+
function Sn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2542
|
+
return e(fn).matches;
|
|
2464
2543
|
}
|
|
2465
2544
|
//#endregion
|
|
2466
2545
|
//#region src/widget/mountExperienceWidget.ts
|
|
2467
|
-
function
|
|
2546
|
+
function Cn(e) {
|
|
2468
2547
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2469
2548
|
}
|
|
2470
|
-
function
|
|
2549
|
+
function wn(e) {
|
|
2471
2550
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2472
2551
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2473
2552
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2475,8 +2554,8 @@ function hn(e) {
|
|
|
2475
2554
|
function $(e) {
|
|
2476
2555
|
return e === "expanded" || e === "docked";
|
|
2477
2556
|
}
|
|
2478
|
-
var
|
|
2479
|
-
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) {
|
|
2480
2559
|
W(de);
|
|
2481
2560
|
let r = w({
|
|
2482
2561
|
galleryThumb: t.galleryThumb,
|
|
@@ -2506,7 +2585,7 @@ function bn(e, t, n) {
|
|
|
2506
2585
|
}
|
|
2507
2586
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2508
2587
|
}
|
|
2509
|
-
function
|
|
2588
|
+
function An(e) {
|
|
2510
2589
|
return e.startButton ? {
|
|
2511
2590
|
...e.startButton,
|
|
2512
2591
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2518,7 +2597,7 @@ function xn(e) {
|
|
|
2518
2597
|
variant: "primary"
|
|
2519
2598
|
};
|
|
2520
2599
|
}
|
|
2521
|
-
function
|
|
2600
|
+
function jn(e) {
|
|
2522
2601
|
let t = !1, n = () => {
|
|
2523
2602
|
t || e();
|
|
2524
2603
|
}, r = () => {
|
|
@@ -2538,12 +2617,12 @@ function Sn(e) {
|
|
|
2538
2617
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2539
2618
|
};
|
|
2540
2619
|
}
|
|
2541
|
-
function
|
|
2620
|
+
function Mn(e, t) {
|
|
2542
2621
|
he(me);
|
|
2543
2622
|
let n = t.experienceId?.trim();
|
|
2544
2623
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2545
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2546
|
-
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));
|
|
2547
2626
|
let o = document.createElement("button");
|
|
2548
2627
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2549
2628
|
let s = document.createElement("div");
|
|
@@ -2563,11 +2642,11 @@ function Cn(e, t) {
|
|
|
2563
2642
|
let m = document.createElement("span");
|
|
2564
2643
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2565
2644
|
let h = document.createElement("button");
|
|
2566
|
-
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");
|
|
2567
2646
|
let g = document.createElement("button");
|
|
2568
|
-
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");
|
|
2569
2648
|
let _ = document.createElement("button");
|
|
2570
|
-
_.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, _);
|
|
2571
2650
|
let v = document.createElement("div");
|
|
2572
2651
|
v.className = "liforma-ew__stage";
|
|
2573
2652
|
let y = document.createElement("div");
|
|
@@ -2595,11 +2674,11 @@ function Cn(e, t) {
|
|
|
2595
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";
|
|
2596
2675
|
}, oe = (e, t) => {
|
|
2597
2676
|
if (R() !== "docked") return;
|
|
2598
|
-
let n =
|
|
2677
|
+
let n = yn(), r = xn(e - te, t - ne, n);
|
|
2599
2678
|
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2600
2679
|
}, se = (e, t) => {
|
|
2601
2680
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2602
|
-
let n =
|
|
2681
|
+
let n = yn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = xn(r + e, i + t, n);
|
|
2603
2682
|
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2604
2683
|
}, ce = (e) => {
|
|
2605
2684
|
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
@@ -2608,12 +2687,12 @@ function Cn(e, t) {
|
|
|
2608
2687
|
let t = I;
|
|
2609
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));
|
|
2610
2689
|
}, le = (e, t, n) => {
|
|
2611
|
-
if (S || R() !== "docked" || !
|
|
2690
|
+
if (S || R() !== "docked" || !Sn() || F !== null) return;
|
|
2612
2691
|
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2613
2692
|
let r = f.getBoundingClientRect();
|
|
2614
2693
|
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2615
2694
|
}, ue = (e) => {
|
|
2616
|
-
if (S || R() !== "docked" || !
|
|
2695
|
+
if (S || R() !== "docked" || !Sn() || F !== null) return;
|
|
2617
2696
|
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2618
2697
|
let t = f.getBoundingClientRect();
|
|
2619
2698
|
N = t.left, P = t.top;
|
|
@@ -2622,15 +2701,15 @@ function Cn(e, t) {
|
|
|
2622
2701
|
}, U = (e) => {
|
|
2623
2702
|
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2624
2703
|
}, W = () => {
|
|
2625
|
-
let e =
|
|
2704
|
+
let e = Sn(), t = R();
|
|
2626
2705
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2627
2706
|
h.hidden = !0;
|
|
2628
2707
|
return;
|
|
2629
2708
|
}
|
|
2630
|
-
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"));
|
|
2631
2710
|
}, fe = (e) => {
|
|
2632
|
-
let t =
|
|
2633
|
-
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();
|
|
2634
2713
|
}, pe = () => {
|
|
2635
2714
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2636
2715
|
requestAnimationFrame(() => {
|
|
@@ -2677,7 +2756,7 @@ function Cn(e, t) {
|
|
|
2677
2756
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2678
2757
|
}, xe = (e) => {
|
|
2679
2758
|
A?.(), A = null;
|
|
2680
|
-
let t =
|
|
2759
|
+
let t = kn(s, e, { parallax: ie });
|
|
2681
2760
|
return t ? (A = t, !0) : !1;
|
|
2682
2761
|
}, Se = () => {
|
|
2683
2762
|
if (xe(_e)) {
|
|
@@ -2706,13 +2785,13 @@ function Cn(e, t) {
|
|
|
2706
2785
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2707
2786
|
}), we = () => ({
|
|
2708
2787
|
...t.fit ? { fit: t.fit } : {},
|
|
2709
|
-
startButton:
|
|
2788
|
+
startButton: An(t),
|
|
2710
2789
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2711
2790
|
}), J = (e = !0) => {
|
|
2712
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?.();
|
|
2713
|
-
},
|
|
2792
|
+
}, Te = () => {
|
|
2714
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");
|
|
2715
|
-
},
|
|
2794
|
+
}, Ee = (e) => {
|
|
2716
2795
|
e.on("started", () => {
|
|
2717
2796
|
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
2718
2797
|
}), e.on("feedback", (e) => {
|
|
@@ -2720,28 +2799,28 @@ function Cn(e, t) {
|
|
|
2720
2799
|
}), e.on("feedbackFailed", (e) => {
|
|
2721
2800
|
S || t.onFeedbackFailed?.(e);
|
|
2722
2801
|
});
|
|
2723
|
-
},
|
|
2802
|
+
}, De = () => {
|
|
2724
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();
|
|
2725
|
-
},
|
|
2804
|
+
}, Oe = () => {
|
|
2726
2805
|
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
2727
2806
|
let e = b;
|
|
2728
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");
|
|
2729
|
-
},
|
|
2808
|
+
}, ke = () => {
|
|
2730
2809
|
if (!S && $(a.dataset.state)) {
|
|
2731
2810
|
if (H(), x = !1, b && E) {
|
|
2732
2811
|
let e = b;
|
|
2733
2812
|
(async () => {
|
|
2734
|
-
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?.());
|
|
2735
2814
|
})();
|
|
2736
2815
|
return;
|
|
2737
2816
|
}
|
|
2738
|
-
|
|
2817
|
+
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
2739
2818
|
}
|
|
2740
|
-
},
|
|
2741
|
-
S ||
|
|
2742
|
-
|
|
2819
|
+
}, Y = () => {
|
|
2820
|
+
S || Sn() && R() === "expanded" && G(() => {
|
|
2821
|
+
Te();
|
|
2743
2822
|
});
|
|
2744
|
-
},
|
|
2823
|
+
}, X = () => {
|
|
2745
2824
|
S || R() === "docked" && (H(), G(() => {
|
|
2746
2825
|
ae(), J(!1), b?.setWidgetChrome("expanded");
|
|
2747
2826
|
}));
|
|
@@ -2757,12 +2836,12 @@ function Cn(e, t) {
|
|
|
2757
2836
|
let e = O;
|
|
2758
2837
|
l.hidden = !1, (async () => {
|
|
2759
2838
|
try {
|
|
2760
|
-
let t = await
|
|
2839
|
+
let t = await un.startSession(Ce());
|
|
2761
2840
|
if (S || e !== O) {
|
|
2762
2841
|
t.destroy();
|
|
2763
2842
|
return;
|
|
2764
2843
|
}
|
|
2765
|
-
b = t,
|
|
2844
|
+
b = t, Ee(t);
|
|
2766
2845
|
let n = await t.attach({
|
|
2767
2846
|
container: l,
|
|
2768
2847
|
...we(),
|
|
@@ -2793,7 +2872,7 @@ function Cn(e, t) {
|
|
|
2793
2872
|
return;
|
|
2794
2873
|
}
|
|
2795
2874
|
n.on("close", () => {
|
|
2796
|
-
S ||
|
|
2875
|
+
S || ke();
|
|
2797
2876
|
});
|
|
2798
2877
|
} catch (n) {
|
|
2799
2878
|
if (S || e !== O) return;
|
|
@@ -2816,12 +2895,12 @@ function Cn(e, t) {
|
|
|
2816
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 () => {
|
|
2817
2896
|
try {
|
|
2818
2897
|
J();
|
|
2819
|
-
let t = await
|
|
2898
|
+
let t = await un.startSession(Ce());
|
|
2820
2899
|
if (S || e !== O) {
|
|
2821
2900
|
t.destroy();
|
|
2822
2901
|
return;
|
|
2823
2902
|
}
|
|
2824
|
-
b = t,
|
|
2903
|
+
b = t, Ee(t);
|
|
2825
2904
|
let n = await t.attach({
|
|
2826
2905
|
container: v,
|
|
2827
2906
|
...we(),
|
|
@@ -2846,7 +2925,7 @@ function Cn(e, t) {
|
|
|
2846
2925
|
return;
|
|
2847
2926
|
}
|
|
2848
2927
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2849
|
-
S ||
|
|
2928
|
+
S || ke();
|
|
2850
2929
|
});
|
|
2851
2930
|
} catch (n) {
|
|
2852
2931
|
if (S || e !== O) return;
|
|
@@ -2874,23 +2953,23 @@ function Cn(e, t) {
|
|
|
2874
2953
|
}
|
|
2875
2954
|
}, Ie = (e) => {
|
|
2876
2955
|
if (e.stopPropagation(), R() === "expanded") {
|
|
2877
|
-
|
|
2956
|
+
Y();
|
|
2878
2957
|
return;
|
|
2879
2958
|
}
|
|
2880
|
-
R() === "docked" &&
|
|
2959
|
+
R() === "docked" && X();
|
|
2881
2960
|
}, Le = (e) => {
|
|
2882
2961
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
2883
2962
|
}, Re = (e) => {
|
|
2884
2963
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2885
2964
|
}, ze = (e) => {
|
|
2886
|
-
R() === "docked" &&
|
|
2965
|
+
R() === "docked" && Sn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2887
2966
|
}, Be = (e) => {
|
|
2888
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
2967
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), ke());
|
|
2889
2968
|
}, Ve = () => {
|
|
2890
2969
|
if (!S) {
|
|
2891
2970
|
if (R() === "docked") {
|
|
2892
|
-
if (!
|
|
2893
|
-
|
|
2971
|
+
if (!Sn()) {
|
|
2972
|
+
X();
|
|
2894
2973
|
return;
|
|
2895
2974
|
}
|
|
2896
2975
|
D ? G(() => {
|
|
@@ -2900,27 +2979,27 @@ function Cn(e, t) {
|
|
|
2900
2979
|
}
|
|
2901
2980
|
W();
|
|
2902
2981
|
}
|
|
2903
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
2982
|
+
}, He = typeof window < "u" ? window.matchMedia(fn) : null, Ue = () => {
|
|
2904
2983
|
if (!S) {
|
|
2905
|
-
if (R() === "docked" && !
|
|
2906
|
-
|
|
2984
|
+
if (R() === "docked" && !Sn()) {
|
|
2985
|
+
X();
|
|
2907
2986
|
return;
|
|
2908
2987
|
}
|
|
2909
2988
|
W();
|
|
2910
2989
|
}
|
|
2911
2990
|
};
|
|
2912
|
-
return o.addEventListener("click", Fe), d.addEventListener("click",
|
|
2913
|
-
e.stopPropagation(),
|
|
2991
|
+
return o.addEventListener("click", Fe), d.addEventListener("click", ke), _.addEventListener("click", (e) => {
|
|
2992
|
+
e.stopPropagation(), ke();
|
|
2914
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(() => {
|
|
2915
2994
|
S || Ne();
|
|
2916
|
-
}) : r === "idle" && (ee =
|
|
2995
|
+
}) : r === "idle" && (ee = jn(() => {
|
|
2917
2996
|
S || Ne();
|
|
2918
2997
|
})), {
|
|
2919
2998
|
root: a,
|
|
2920
2999
|
expand: Fe,
|
|
2921
|
-
collapse:
|
|
2922
|
-
dock:
|
|
2923
|
-
maximize:
|
|
3000
|
+
collapse: ke,
|
|
3001
|
+
dock: Y,
|
|
3002
|
+
maximize: X,
|
|
2924
3003
|
prefetch() {
|
|
2925
3004
|
if (r === "onExpand") {
|
|
2926
3005
|
Ne();
|
|
@@ -2929,18 +3008,18 @@ function Cn(e, t) {
|
|
|
2929
3008
|
Ne();
|
|
2930
3009
|
},
|
|
2931
3010
|
destroy() {
|
|
2932
|
-
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());
|
|
2933
3012
|
}
|
|
2934
3013
|
};
|
|
2935
3014
|
}
|
|
2936
3015
|
//#endregion
|
|
2937
3016
|
//#region src/react/ExperienceWidget.tsx
|
|
2938
|
-
function
|
|
3017
|
+
function Nn(t) {
|
|
2939
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";
|
|
2940
3019
|
return e(() => {
|
|
2941
3020
|
let e = r.current;
|
|
2942
3021
|
if (!e || !i.trim()) return;
|
|
2943
|
-
let t =
|
|
3022
|
+
let t = Mn(e, {
|
|
2944
3023
|
experienceId: i,
|
|
2945
3024
|
alt: o,
|
|
2946
3025
|
galleryThumb: s,
|
|
@@ -3017,6 +3096,12 @@ function wn(t) {
|
|
|
3017
3096
|
});
|
|
3018
3097
|
}
|
|
3019
3098
|
//#endregion
|
|
3020
|
-
|
|
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 };
|
|
3021
3106
|
|
|
3022
3107
|
//# sourceMappingURL=index.js.map
|