@liforma/client 0.4.12 → 0.4.14
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 +23 -0
- package/README.md +4 -4
- package/dist/next/index.js +585 -491
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/thumbnail/index.d.ts +1 -0
- package/dist/next/thumbnail/index.d.ts.map +1 -1
- package/dist/next/thumbnail/locationPlate.d.ts +3 -3
- package/dist/next/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/next/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/next/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/next/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/next/thumbnail.js +147 -91
- package/dist/next/thumbnail.js.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +4 -8
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +29 -2
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +14 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/index.js +223 -185
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.d.ts +1 -0
- package/dist/npm/thumbnail/index.d.ts.map +1 -1
- package/dist/npm/thumbnail/index.js +106 -70
- package/dist/npm/thumbnail/index.js.map +1 -1
- package/dist/npm/thumbnail/locationPlate.d.ts +3 -3
- package/dist/npm/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/npm/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/npm/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/npm/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -8
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +29 -2
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +14 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +12 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +689 -573
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/thumbnail/index.d.ts +1 -0
- package/dist/react/thumbnail/index.d.ts.map +1 -1
- package/dist/react/thumbnail/locationPlate.d.ts +3 -3
- package/dist/react/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/react/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/react/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/react/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/react/thumbnail.js +147 -91
- package/dist/react/thumbnail.js.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +4 -8
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +29 -2
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +14 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +3 -3
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +30 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/dist/svelte/ExperienceThumbnail.svelte +49 -8
- package/package.json +4 -1
package/dist/npm/index.js
CHANGED
|
@@ -35,12 +35,12 @@ function r(e) {
|
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/thumbnail/locationPlate.ts
|
|
38
|
-
var i = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
38
|
+
var i = /(-)(\d+x\d+)(\.(?:webp|avif))(\?|$)/i;
|
|
39
39
|
function a(e, t) {
|
|
40
40
|
let n = e.trim();
|
|
41
41
|
return n && n.replace(i, (e, n, r, i, a) => `${n}${t}${i}${a}`);
|
|
42
42
|
}
|
|
43
|
-
var o = /-(256x256|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
43
|
+
var o = /-(256x256|400x225|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
44
44
|
function s(e) {
|
|
45
45
|
return e?.trim().replace(/\/$/, "") || "https://cdn.liforma.ai";
|
|
46
46
|
}
|
|
@@ -302,7 +302,7 @@ function se(e) {
|
|
|
302
302
|
}
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region src/thumbnail/styles.ts
|
|
305
|
-
var ce = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0
|
|
305
|
+
var ce = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", le = !1;
|
|
306
306
|
function V(e) {
|
|
307
307
|
if (typeof document > "u" || le) return;
|
|
308
308
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
@@ -751,13 +751,13 @@ var qe = new Set([1, 2]);
|
|
|
751
751
|
function Je(e) {
|
|
752
752
|
return typeof e == "number" && qe.has(e);
|
|
753
753
|
}
|
|
754
|
-
var Ye = 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.interactionChange".split("."));
|
|
754
|
+
var Ye = 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.theatre.interactionChange".split("."));
|
|
755
755
|
function Xe(e) {
|
|
756
756
|
if (!e || typeof e != "object") return null;
|
|
757
757
|
let t = e;
|
|
758
758
|
if (!Je(t.schemaVersion) || !t.type || !Ye.has(t.type)) return null;
|
|
759
759
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
760
|
-
if (t.type === "fullWindow") {
|
|
760
|
+
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
761
761
|
let e = t.payload;
|
|
762
762
|
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
763
763
|
}
|
|
@@ -781,7 +781,7 @@ function Xe(e) {
|
|
|
781
781
|
function Ze(e, t, n) {
|
|
782
782
|
let r = e.trim();
|
|
783
783
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
784
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction;
|
|
784
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatreButton, l = n?.theatre;
|
|
785
785
|
return {
|
|
786
786
|
type: "launch",
|
|
787
787
|
schemaVersion: 2,
|
|
@@ -791,7 +791,9 @@ function Ze(e, t, n) {
|
|
|
791
791
|
...i ? { startButton: i } : {},
|
|
792
792
|
...a ? { theme: a } : {},
|
|
793
793
|
...o === void 0 ? {} : { showFeedback: o },
|
|
794
|
-
...s ? { interaction: s } : {}
|
|
794
|
+
...s ? { interaction: s } : {},
|
|
795
|
+
...c ? { theatreButton: !0 } : {},
|
|
796
|
+
...l === void 0 ? {} : { theatre: l }
|
|
795
797
|
}
|
|
796
798
|
};
|
|
797
799
|
}
|
|
@@ -815,10 +817,17 @@ function et() {
|
|
|
815
817
|
payload: {}
|
|
816
818
|
};
|
|
817
819
|
}
|
|
820
|
+
function tt(e) {
|
|
821
|
+
return {
|
|
822
|
+
type: "setTheatre",
|
|
823
|
+
schemaVersion: 2,
|
|
824
|
+
payload: { active: e }
|
|
825
|
+
};
|
|
826
|
+
}
|
|
818
827
|
//#endregion
|
|
819
828
|
//#region src/v2/embed/fullWindowHost.ts
|
|
820
|
-
var
|
|
821
|
-
function
|
|
829
|
+
var nt = "2147483000";
|
|
830
|
+
function rt(e) {
|
|
822
831
|
let { style: t } = e;
|
|
823
832
|
return {
|
|
824
833
|
position: t.position,
|
|
@@ -836,11 +845,11 @@ function nt(e) {
|
|
|
836
845
|
maxHeight: t.maxHeight
|
|
837
846
|
};
|
|
838
847
|
}
|
|
839
|
-
function
|
|
848
|
+
function it(e) {
|
|
840
849
|
let { style: t } = e;
|
|
841
|
-
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 =
|
|
850
|
+
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 = nt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
842
851
|
}
|
|
843
|
-
function
|
|
852
|
+
function at(e, t) {
|
|
844
853
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
845
854
|
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 = "";
|
|
846
855
|
return;
|
|
@@ -850,20 +859,20 @@ function it(e, t) {
|
|
|
850
859
|
}
|
|
851
860
|
//#endregion
|
|
852
861
|
//#region src/v2/embed/iframeHost.ts
|
|
853
|
-
function
|
|
862
|
+
function ot(e) {
|
|
854
863
|
return e;
|
|
855
864
|
}
|
|
856
865
|
function Y() {
|
|
857
866
|
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)}`;
|
|
858
867
|
}
|
|
859
|
-
var
|
|
860
|
-
function
|
|
868
|
+
var st = 3e4;
|
|
869
|
+
function ct(e) {
|
|
861
870
|
let t = e.container;
|
|
862
871
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
863
872
|
let n = document.createElement("iframe");
|
|
864
|
-
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");
|
|
865
|
-
let r = !1, i = !1, a = null, o =
|
|
866
|
-
i !==
|
|
873
|
+
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write; fullscreen"), n.setAttribute("allowfullscreen", ""), 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"), n.setAttribute("fetchpriority", "high"), "fetchPriority" in n && (n.fetchPriority = "high");
|
|
874
|
+
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
875
|
+
i !== r && (i = r, r ? (a = rt(n), o = document.body.style.overflow, document.body.append(n), it(n), document.body.style.overflow = "hidden") : (t.append(n), at(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
867
876
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
868
877
|
p = e, m = t;
|
|
869
878
|
}), g = () => {
|
|
@@ -934,7 +943,7 @@ function st(e) {
|
|
|
934
943
|
e.onUserSpeechEnded?.(i.payload);
|
|
935
944
|
break;
|
|
936
945
|
case "modeChange":
|
|
937
|
-
e.onActivityChange?.(
|
|
946
|
+
e.onActivityChange?.(ot(i.payload.mode));
|
|
938
947
|
break;
|
|
939
948
|
case "activityChange":
|
|
940
949
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -978,6 +987,9 @@ function st(e) {
|
|
|
978
987
|
case "fullWindow":
|
|
979
988
|
s(i.payload.active);
|
|
980
989
|
break;
|
|
990
|
+
case "theatre":
|
|
991
|
+
e.onTheatreChange?.(i.payload.active);
|
|
992
|
+
break;
|
|
981
993
|
case "interactionChange":
|
|
982
994
|
e.onInteractionChange?.(i.payload.interaction);
|
|
983
995
|
break;
|
|
@@ -1035,6 +1047,9 @@ function st(e) {
|
|
|
1035
1047
|
postWidgetToggleAudioSettings() {
|
|
1036
1048
|
S(et());
|
|
1037
1049
|
},
|
|
1050
|
+
postSetTheatre(e) {
|
|
1051
|
+
S(tt(e));
|
|
1052
|
+
},
|
|
1038
1053
|
speak(e) {
|
|
1039
1054
|
return C({
|
|
1040
1055
|
type: "speak",
|
|
@@ -1155,7 +1170,7 @@ function st(e) {
|
|
|
1155
1170
|
audio: e.audio,
|
|
1156
1171
|
byteLength: e.byteLength
|
|
1157
1172
|
}
|
|
1158
|
-
},
|
|
1173
|
+
}, st, [e.audio]);
|
|
1159
1174
|
},
|
|
1160
1175
|
speechUtteranceSetTranscript(e) {
|
|
1161
1176
|
return C({
|
|
@@ -1317,7 +1332,7 @@ function st(e) {
|
|
|
1317
1332
|
}
|
|
1318
1333
|
//#endregion
|
|
1319
1334
|
//#region src/v2/embed/readyGate.ts
|
|
1320
|
-
function
|
|
1335
|
+
function lt(e) {
|
|
1321
1336
|
let t, n = !1, r = !1, i = () => {
|
|
1322
1337
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1323
1338
|
};
|
|
@@ -1332,9 +1347,9 @@ function ct(e) {
|
|
|
1332
1347
|
}
|
|
1333
1348
|
//#endregion
|
|
1334
1349
|
//#region src/v2/sdkRelease.ts
|
|
1335
|
-
var
|
|
1350
|
+
var ut = `sdk@${{
|
|
1336
1351
|
name: "@liforma/client",
|
|
1337
|
-
version: "0.4.
|
|
1352
|
+
version: "0.4.14",
|
|
1338
1353
|
type: "module",
|
|
1339
1354
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1340
1355
|
license: "MIT",
|
|
@@ -1495,6 +1510,8 @@ var lt = `sdk@${{
|
|
|
1495
1510
|
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
1496
1511
|
"build:locations": "node scripts/build-locations.mjs",
|
|
1497
1512
|
"publish:locations": "node scripts/publish-locations.mjs",
|
|
1513
|
+
"publish:location-400x225": "node scripts/build-location-400x225.mjs",
|
|
1514
|
+
"test:location-400x225": "node scripts/test-location-400x225.mjs",
|
|
1498
1515
|
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
1499
1516
|
"publish:models": "node scripts/publish-models.mjs",
|
|
1500
1517
|
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
@@ -1524,6 +1541,7 @@ var lt = `sdk@${{
|
|
|
1524
1541
|
"preview:test": "npm run build && npm run preview"
|
|
1525
1542
|
},
|
|
1526
1543
|
dependencies: {
|
|
1544
|
+
"@jsquash/avif": "^1.3.0",
|
|
1527
1545
|
"@jsquash/webp": "^1.5.0",
|
|
1528
1546
|
zod: "^4.4.3"
|
|
1529
1547
|
},
|
|
@@ -1553,50 +1571,54 @@ var lt = `sdk@${{
|
|
|
1553
1571
|
vitest: "^4.1.10",
|
|
1554
1572
|
wrangler: "^4.101.0"
|
|
1555
1573
|
}
|
|
1556
|
-
}.version}`,
|
|
1557
|
-
function
|
|
1574
|
+
}.version}`, dt = "https://player.liforma.ai/embed", ft = "http://localhost:3002/embed";
|
|
1575
|
+
function pt() {
|
|
1558
1576
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1559
1577
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1560
1578
|
if (typeof document > "u") return null;
|
|
1561
1579
|
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();
|
|
1562
1580
|
return t ? t.replace(/\/$/, "") : null;
|
|
1563
1581
|
}
|
|
1564
|
-
function
|
|
1565
|
-
let e =
|
|
1566
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : y() ?
|
|
1582
|
+
function mt() {
|
|
1583
|
+
let e = pt();
|
|
1584
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : y() ? ft : dt;
|
|
1567
1585
|
}
|
|
1568
|
-
function
|
|
1586
|
+
function ht(e, t) {
|
|
1569
1587
|
return e?.trim() || t?.trim() || void 0;
|
|
1570
1588
|
}
|
|
1571
|
-
function
|
|
1572
|
-
let
|
|
1573
|
-
|
|
1574
|
-
let
|
|
1575
|
-
|
|
1589
|
+
function gt(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
1590
|
+
let p = (e ?? mt()).replace(/\/$/, ""), m = p.endsWith("/embed") ? p : `${p}/embed`, h = new URL(m), g = n?.trim();
|
|
1591
|
+
g && h.searchParams.set("backdropId", g);
|
|
1592
|
+
let _ = r?.trim();
|
|
1593
|
+
_ && h.searchParams.set("avatarId", _);
|
|
1594
|
+
let v = d?.trim();
|
|
1595
|
+
v && h.searchParams.set("previewBg", v);
|
|
1596
|
+
let y = f?.trim();
|
|
1597
|
+
return y && h.searchParams.set("previewFg", y), (i === "face" || i === "medium") && h.searchParams.set("fit", i), c === "pip" && h.searchParams.set("stage", "pip"), l === "set" && h.searchParams.set("pipBackground", "set"), u === !1 && h.searchParams.set("pipShadow", "0"), a === "widget" && h.searchParams.set("ui", "widget"), o && h.searchParams.set("close", "1"), t && h.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && h.searchParams.set("cast", String(s)), _t(h.toString());
|
|
1576
1598
|
}
|
|
1577
|
-
function
|
|
1599
|
+
function _t(e) {
|
|
1578
1600
|
if (typeof location > "u") return e;
|
|
1579
1601
|
let t = new URL(e);
|
|
1580
1602
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1581
1603
|
}
|
|
1582
|
-
function
|
|
1604
|
+
function vt(e) {
|
|
1583
1605
|
return new URL(e).origin;
|
|
1584
1606
|
}
|
|
1585
1607
|
//#endregion
|
|
1586
1608
|
//#region src/v2/experienceEvents.ts
|
|
1587
|
-
function
|
|
1609
|
+
function yt() {
|
|
1588
1610
|
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)}`;
|
|
1589
1611
|
}
|
|
1590
|
-
function
|
|
1612
|
+
function bt(e, t, n) {
|
|
1591
1613
|
return {
|
|
1592
|
-
id:
|
|
1614
|
+
id: yt(),
|
|
1593
1615
|
type: e,
|
|
1594
1616
|
sessionId: t,
|
|
1595
1617
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1596
1618
|
data: n
|
|
1597
1619
|
};
|
|
1598
1620
|
}
|
|
1599
|
-
function
|
|
1621
|
+
function xt() {
|
|
1600
1622
|
return {
|
|
1601
1623
|
ready: /* @__PURE__ */ new Set(),
|
|
1602
1624
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1617,32 +1639,32 @@ function bt() {
|
|
|
1617
1639
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1618
1640
|
};
|
|
1619
1641
|
}
|
|
1620
|
-
function
|
|
1642
|
+
function St(e, t, n) {
|
|
1621
1643
|
return e[t].add(n), () => e[t].delete(n);
|
|
1622
1644
|
}
|
|
1623
|
-
function
|
|
1645
|
+
function Ct(e, t, n) {
|
|
1624
1646
|
for (let r of e[t]) r(n);
|
|
1625
1647
|
}
|
|
1626
|
-
function
|
|
1648
|
+
function wt(e) {
|
|
1627
1649
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1628
1650
|
}
|
|
1629
1651
|
//#endregion
|
|
1630
1652
|
//#region src/v2/speech/types.ts
|
|
1631
|
-
function
|
|
1653
|
+
function Tt(e) {
|
|
1632
1654
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1633
1655
|
}
|
|
1634
|
-
function
|
|
1656
|
+
function Et(e) {
|
|
1635
1657
|
return "url" in e && typeof e.url == "string";
|
|
1636
1658
|
}
|
|
1637
|
-
function
|
|
1659
|
+
function Dt(e) {
|
|
1638
1660
|
if (!("track" in e)) return !1;
|
|
1639
1661
|
let t = e.track;
|
|
1640
1662
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1641
1663
|
}
|
|
1642
|
-
function
|
|
1643
|
-
return !
|
|
1664
|
+
function Ot(e) {
|
|
1665
|
+
return !Tt(e) && !Et(e) && !Dt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1644
1666
|
}
|
|
1645
|
-
var
|
|
1667
|
+
var kt = [
|
|
1646
1668
|
8e3,
|
|
1647
1669
|
16e3,
|
|
1648
1670
|
22050,
|
|
@@ -1660,14 +1682,14 @@ var Ot = [
|
|
|
1660
1682
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1661
1683
|
MAX_PENDING_WRITES: 8,
|
|
1662
1684
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1663
|
-
},
|
|
1685
|
+
}, At = class extends Error {
|
|
1664
1686
|
operation;
|
|
1665
1687
|
requiredCapability;
|
|
1666
1688
|
name = "UnsupportedSpeechOperationError";
|
|
1667
1689
|
constructor(e, t) {
|
|
1668
1690
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1669
1691
|
}
|
|
1670
|
-
},
|
|
1692
|
+
}, jt = class extends Error {
|
|
1671
1693
|
name = "SpeechUtteranceClosedError";
|
|
1672
1694
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1673
1695
|
super(e);
|
|
@@ -1677,72 +1699,72 @@ var Ot = [
|
|
|
1677
1699
|
constructor(e, t) {
|
|
1678
1700
|
super(e, t);
|
|
1679
1701
|
}
|
|
1680
|
-
},
|
|
1702
|
+
}, Mt = class extends Error {
|
|
1681
1703
|
name = "SpeechBufferTimeoutError";
|
|
1682
1704
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1683
1705
|
super(e);
|
|
1684
1706
|
}
|
|
1685
1707
|
};
|
|
1686
|
-
function
|
|
1708
|
+
function Nt(e = "none") {
|
|
1687
1709
|
return {
|
|
1688
1710
|
mode: e,
|
|
1689
1711
|
trackedDurationMs: 0,
|
|
1690
1712
|
fallbackDurationMs: 0
|
|
1691
1713
|
};
|
|
1692
1714
|
}
|
|
1693
|
-
function Nt(e) {
|
|
1694
|
-
return Ot.includes(e);
|
|
1695
|
-
}
|
|
1696
1715
|
function Pt(e) {
|
|
1716
|
+
return kt.includes(e);
|
|
1717
|
+
}
|
|
1718
|
+
function Ft(e) {
|
|
1697
1719
|
if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
|
|
1698
1720
|
if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
|
|
1699
|
-
if (!
|
|
1721
|
+
if (!Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1700
1722
|
}
|
|
1701
|
-
function
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1723
|
+
function It(e) {
|
|
1724
|
+
if (Tt(e)) {
|
|
1725
|
+
Ft(e.format);
|
|
1704
1726
|
return;
|
|
1705
1727
|
}
|
|
1706
|
-
if (
|
|
1728
|
+
if (Et(e)) {
|
|
1707
1729
|
if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
|
|
1708
|
-
if (e.sampleRate !== void 0 && !
|
|
1730
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1709
1731
|
return;
|
|
1710
1732
|
}
|
|
1711
|
-
if (
|
|
1733
|
+
if (Dt(e)) {
|
|
1712
1734
|
if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
1713
|
-
if (e.sampleRate !== void 0 && !
|
|
1735
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1714
1736
|
return;
|
|
1715
1737
|
}
|
|
1716
|
-
if (
|
|
1738
|
+
if (Ot(e)) {
|
|
1717
1739
|
let t = e.encoding.trim().toLowerCase();
|
|
1718
1740
|
if (!t) throw new Z("Encoded audio MIME type is required.");
|
|
1719
1741
|
if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1720
|
-
if (e.sampleRate !== void 0 && !
|
|
1742
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1721
1743
|
return;
|
|
1722
1744
|
}
|
|
1723
1745
|
throw new Z("Unsupported speech.play audio shape.");
|
|
1724
1746
|
}
|
|
1725
|
-
function
|
|
1726
|
-
if (e.format) return
|
|
1747
|
+
function Lt(e) {
|
|
1748
|
+
if (e.format) return Ft(e.format), e.format;
|
|
1727
1749
|
if (e.track) {
|
|
1728
1750
|
let t = {
|
|
1729
1751
|
encoding: "pcm_s16le",
|
|
1730
1752
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1731
1753
|
channels: 1
|
|
1732
1754
|
};
|
|
1733
|
-
return
|
|
1755
|
+
return Ft(t), t;
|
|
1734
1756
|
}
|
|
1735
1757
|
throw new Z("createUtterance requires format or track.");
|
|
1736
1758
|
}
|
|
1737
|
-
function
|
|
1759
|
+
function Rt(e) {
|
|
1738
1760
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1739
1761
|
}
|
|
1740
|
-
function
|
|
1762
|
+
function zt(e) {
|
|
1741
1763
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1742
1764
|
}
|
|
1743
1765
|
//#endregion
|
|
1744
1766
|
//#region src/byo/pcm.ts
|
|
1745
|
-
function
|
|
1767
|
+
function Bt(e) {
|
|
1746
1768
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1747
1769
|
for (let t = 0; t < e.length; t++) {
|
|
1748
1770
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1752,11 +1774,11 @@ function zt(e) {
|
|
|
1752
1774
|
}
|
|
1753
1775
|
//#endregion
|
|
1754
1776
|
//#region src/byo/resample.ts
|
|
1755
|
-
function
|
|
1777
|
+
function Vt(e, t, n, r, i) {
|
|
1756
1778
|
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;
|
|
1757
1779
|
return ((a * i + o) * i + s) * i + c;
|
|
1758
1780
|
}
|
|
1759
|
-
function
|
|
1781
|
+
function Ht(e, t) {
|
|
1760
1782
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1761
1783
|
if (e === t) return {
|
|
1762
1784
|
fromRate: e,
|
|
@@ -1779,7 +1801,7 @@ function Vt(e, t) {
|
|
|
1779
1801
|
let a = [];
|
|
1780
1802
|
for (; i + 2 < r.length - 1;) {
|
|
1781
1803
|
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);
|
|
1782
|
-
a.push(
|
|
1804
|
+
a.push(Vt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1783
1805
|
}
|
|
1784
1806
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1785
1807
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1791,7 +1813,7 @@ function Vt(e, t) {
|
|
|
1791
1813
|
}
|
|
1792
1814
|
//#endregion
|
|
1793
1815
|
//#region src/byo/audioCapture.ts
|
|
1794
|
-
var
|
|
1816
|
+
var Ut = "liforma-pcm-capture", Wt = `
|
|
1795
1817
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1796
1818
|
process(inputs) {
|
|
1797
1819
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1803,29 +1825,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1803
1825
|
return true;
|
|
1804
1826
|
}
|
|
1805
1827
|
}
|
|
1806
|
-
registerProcessor('${
|
|
1807
|
-
`,
|
|
1808
|
-
function Gt() {
|
|
1809
|
-
return Wt ||= URL.createObjectURL(new Blob([Ut], { type: "application/javascript" })), Wt;
|
|
1810
|
-
}
|
|
1828
|
+
registerProcessor('${Ut}', LiformaPcmCaptureProcessor);
|
|
1829
|
+
`, Gt = null;
|
|
1811
1830
|
function Kt() {
|
|
1831
|
+
return Gt ||= URL.createObjectURL(new Blob([Wt], { type: "application/javascript" })), Gt;
|
|
1832
|
+
}
|
|
1833
|
+
function qt() {
|
|
1812
1834
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1813
1835
|
}
|
|
1814
|
-
async function
|
|
1815
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1836
|
+
async function Jt(e) {
|
|
1837
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = qt();
|
|
1816
1838
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1817
1839
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1818
1840
|
l.gain.value = 0;
|
|
1819
|
-
let u = s.sampleRate, d =
|
|
1841
|
+
let u = s.sampleRate, d = Ht(u, n), f = !1, p = !1, m = (e) => {
|
|
1820
1842
|
if (f || i && !i()) return;
|
|
1821
1843
|
let t = d.push(e);
|
|
1822
|
-
t.length !== 0 && r(
|
|
1844
|
+
t.length !== 0 && r(Bt(t));
|
|
1823
1845
|
}, h = () => void 0;
|
|
1824
1846
|
return await (async () => {
|
|
1825
1847
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1826
1848
|
try {
|
|
1827
|
-
await s.audioWorklet.addModule(
|
|
1828
|
-
let e = new AudioWorkletNode(s,
|
|
1849
|
+
await s.audioWorklet.addModule(Kt());
|
|
1850
|
+
let e = new AudioWorkletNode(s, Ut, {
|
|
1829
1851
|
numberOfInputs: 1,
|
|
1830
1852
|
numberOfOutputs: 1,
|
|
1831
1853
|
outputChannelCount: [1]
|
|
@@ -1875,7 +1897,7 @@ async function qt(e) {
|
|
|
1875
1897
|
}
|
|
1876
1898
|
//#endregion
|
|
1877
1899
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1878
|
-
async function
|
|
1900
|
+
async function Yt(e) {
|
|
1879
1901
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1880
1902
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
|
|
1881
1903
|
if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1884,13 +1906,13 @@ async function Jt(e) {
|
|
|
1884
1906
|
s || (s = !0, c?.stop(), c = null);
|
|
1885
1907
|
};
|
|
1886
1908
|
try {
|
|
1887
|
-
c = await
|
|
1909
|
+
c = await Jt({
|
|
1888
1910
|
mediaStream: a,
|
|
1889
1911
|
targetSampleRate: r,
|
|
1890
1912
|
shouldSend: () => !s && !i?.aborted,
|
|
1891
1913
|
onPcm: (e) => {
|
|
1892
1914
|
if (s || i?.aborted) return;
|
|
1893
|
-
let t =
|
|
1915
|
+
let t = Rt(e);
|
|
1894
1916
|
o = o.then(async () => {
|
|
1895
1917
|
if (s || i?.aborted) return;
|
|
1896
1918
|
let e = 0;
|
|
@@ -1919,10 +1941,10 @@ async function Jt(e) {
|
|
|
1919
1941
|
}
|
|
1920
1942
|
//#endregion
|
|
1921
1943
|
//#region src/v2/speech/speechController.ts
|
|
1922
|
-
async function
|
|
1923
|
-
if (
|
|
1924
|
-
if (
|
|
1925
|
-
let t =
|
|
1944
|
+
async function Xt(e, t) {
|
|
1945
|
+
if (Dt(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
|
|
1946
|
+
if (Tt(e)) {
|
|
1947
|
+
let t = Rt(e.data);
|
|
1926
1948
|
if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
|
|
1927
1949
|
return {
|
|
1928
1950
|
kind: "pcm",
|
|
@@ -1930,17 +1952,17 @@ async function Yt(e, t) {
|
|
|
1930
1952
|
format: e.format
|
|
1931
1953
|
};
|
|
1932
1954
|
}
|
|
1933
|
-
if (
|
|
1955
|
+
if (Et(e)) return {
|
|
1934
1956
|
kind: "url",
|
|
1935
1957
|
url: e.url.trim(),
|
|
1936
1958
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1937
1959
|
};
|
|
1938
|
-
if (!
|
|
1960
|
+
if (!Ot(e)) throw new Z("Unsupported speech.play audio shape.");
|
|
1939
1961
|
let n;
|
|
1940
1962
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1941
1963
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1942
1964
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1943
|
-
} else n =
|
|
1965
|
+
} else n = Rt(e.data);
|
|
1944
1966
|
return {
|
|
1945
1967
|
kind: "encoded",
|
|
1946
1968
|
data: n.slice().buffer,
|
|
@@ -1948,10 +1970,10 @@ async function Yt(e, t) {
|
|
|
1948
1970
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1949
1971
|
};
|
|
1950
1972
|
}
|
|
1951
|
-
function
|
|
1973
|
+
function Zt() {
|
|
1952
1974
|
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)}`;
|
|
1953
1975
|
}
|
|
1954
|
-
function
|
|
1976
|
+
function Qt(e, t = "completed") {
|
|
1955
1977
|
return {
|
|
1956
1978
|
utteranceId: e.speechId,
|
|
1957
1979
|
characterId: e.characterId,
|
|
@@ -1965,13 +1987,13 @@ function Zt(e, t = "completed") {
|
|
|
1965
1987
|
}
|
|
1966
1988
|
};
|
|
1967
1989
|
}
|
|
1968
|
-
function
|
|
1990
|
+
function $t(e) {
|
|
1969
1991
|
return e instanceof Error ? e : new Z(String(e));
|
|
1970
1992
|
}
|
|
1971
|
-
function
|
|
1993
|
+
function en(e) {
|
|
1972
1994
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1973
1995
|
}
|
|
1974
|
-
var
|
|
1996
|
+
var tn = class {
|
|
1975
1997
|
id;
|
|
1976
1998
|
characterId;
|
|
1977
1999
|
result;
|
|
@@ -2000,14 +2022,14 @@ var en = class {
|
|
|
2000
2022
|
queue: e.queue,
|
|
2001
2023
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2002
2024
|
}).catch((e) => {
|
|
2003
|
-
throw this.fail(
|
|
2025
|
+
throw this.fail($t(e)), $t(e);
|
|
2004
2026
|
}), this.signal?.addEventListener("abort", () => {
|
|
2005
2027
|
this.cancel();
|
|
2006
2028
|
}, { once: !0 });
|
|
2007
2029
|
}
|
|
2008
2030
|
async write(e, t) {
|
|
2009
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2010
|
-
let n =
|
|
2031
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new jt();
|
|
2032
|
+
let n = Rt(e);
|
|
2011
2033
|
if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
|
|
2012
2034
|
if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
|
|
2013
2035
|
if (n.byteLength === 0) return;
|
|
@@ -2016,13 +2038,13 @@ var en = class {
|
|
|
2016
2038
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2017
2039
|
if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2018
2040
|
let a = async () => {
|
|
2019
|
-
if (this.closed || this.settled) throw new
|
|
2041
|
+
if (this.closed || this.settled) throw new jt();
|
|
2020
2042
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2021
2043
|
utteranceId: this.id,
|
|
2022
2044
|
audio: t.buffer,
|
|
2023
2045
|
byteLength: t.byteLength
|
|
2024
2046
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2025
|
-
setTimeout(() => t(new
|
|
2047
|
+
setTimeout(() => t(new Mt()), r);
|
|
2026
2048
|
})]);
|
|
2027
2049
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2028
2050
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2034,7 +2056,7 @@ var en = class {
|
|
|
2034
2056
|
}
|
|
2035
2057
|
}
|
|
2036
2058
|
async setTranscript(e) {
|
|
2037
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2059
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new jt();
|
|
2038
2060
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2039
2061
|
utteranceId: this.id,
|
|
2040
2062
|
transcript: e
|
|
@@ -2051,7 +2073,7 @@ var en = class {
|
|
|
2051
2073
|
});
|
|
2052
2074
|
return this.resolve(t), t;
|
|
2053
2075
|
} catch (e) {
|
|
2054
|
-
let t =
|
|
2076
|
+
let t = $t(e);
|
|
2055
2077
|
throw this.fail(t), t;
|
|
2056
2078
|
}
|
|
2057
2079
|
}
|
|
@@ -2069,11 +2091,11 @@ var en = class {
|
|
|
2069
2091
|
characterId: this.characterId,
|
|
2070
2092
|
status: "cancelled",
|
|
2071
2093
|
durationMs: 0,
|
|
2072
|
-
animation:
|
|
2094
|
+
animation: Nt("none")
|
|
2073
2095
|
};
|
|
2074
2096
|
return this.resolve(t), t;
|
|
2075
2097
|
} catch (e) {
|
|
2076
|
-
let t =
|
|
2098
|
+
let t = $t(e);
|
|
2077
2099
|
throw this.fail(t), t;
|
|
2078
2100
|
}
|
|
2079
2101
|
}
|
|
@@ -2086,7 +2108,7 @@ var en = class {
|
|
|
2086
2108
|
return e;
|
|
2087
2109
|
}
|
|
2088
2110
|
resolve(e) {
|
|
2089
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2111
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new jt()));
|
|
2090
2112
|
}
|
|
2091
2113
|
fail(e) {
|
|
2092
2114
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
@@ -2098,7 +2120,7 @@ var en = class {
|
|
|
2098
2120
|
}
|
|
2099
2121
|
await new Promise((t, n) => {
|
|
2100
2122
|
let r = setTimeout(() => {
|
|
2101
|
-
n(new
|
|
2123
|
+
n(new Mt());
|
|
2102
2124
|
}, e);
|
|
2103
2125
|
this.pendingWriteWaiters.push({
|
|
2104
2126
|
resolve: () => {
|
|
@@ -2117,13 +2139,13 @@ var en = class {
|
|
|
2117
2139
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2118
2140
|
}
|
|
2119
2141
|
};
|
|
2120
|
-
function
|
|
2142
|
+
function nn(e) {
|
|
2121
2143
|
let t = null, n = (t, n) => {
|
|
2122
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2144
|
+
if (!e.getCapabilities()[n]) throw new At(t, n);
|
|
2123
2145
|
}, r = {
|
|
2124
2146
|
async speak(r) {
|
|
2125
2147
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2126
|
-
let i =
|
|
2148
|
+
let i = zt(r.queue ?? "append");
|
|
2127
2149
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2128
2150
|
let a = e.getIframeHost();
|
|
2129
2151
|
if (!a) throw new Z("Speech session is not attached.");
|
|
@@ -2143,41 +2165,41 @@ function tn(e) {
|
|
|
2143
2165
|
return;
|
|
2144
2166
|
}
|
|
2145
2167
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2146
|
-
t.removeEventListener("abort", s), n(
|
|
2168
|
+
t.removeEventListener("abort", s), n(Qt(e, "completed"));
|
|
2147
2169
|
}, (a) => {
|
|
2148
|
-
if (t.removeEventListener("abort", s),
|
|
2170
|
+
if (t.removeEventListener("abort", s), en(a)) {
|
|
2149
2171
|
n({
|
|
2150
2172
|
utteranceId: "utt_interrupted",
|
|
2151
2173
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2152
2174
|
status: "interrupted",
|
|
2153
2175
|
durationMs: 0,
|
|
2154
2176
|
transcript: r.text,
|
|
2155
|
-
animation:
|
|
2177
|
+
animation: Nt("none")
|
|
2156
2178
|
});
|
|
2157
2179
|
return;
|
|
2158
2180
|
}
|
|
2159
|
-
i(
|
|
2181
|
+
i($t(a));
|
|
2160
2182
|
});
|
|
2161
2183
|
});
|
|
2162
2184
|
}
|
|
2163
2185
|
try {
|
|
2164
|
-
return
|
|
2186
|
+
return Qt(await o, "completed");
|
|
2165
2187
|
} catch (t) {
|
|
2166
|
-
if (
|
|
2188
|
+
if (en(t)) return {
|
|
2167
2189
|
utteranceId: "utt_interrupted",
|
|
2168
2190
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2169
2191
|
status: "interrupted",
|
|
2170
2192
|
durationMs: 0,
|
|
2171
2193
|
transcript: r.text,
|
|
2172
|
-
animation:
|
|
2194
|
+
animation: Nt("none")
|
|
2173
2195
|
};
|
|
2174
|
-
throw
|
|
2196
|
+
throw $t(t);
|
|
2175
2197
|
}
|
|
2176
2198
|
},
|
|
2177
2199
|
async play(i) {
|
|
2178
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2200
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), It(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2179
2201
|
let a = i.queue ?? "append";
|
|
2180
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2202
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Dt(i.audio)) {
|
|
2181
2203
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2182
2204
|
return r.createUtterance({
|
|
2183
2205
|
format: {
|
|
@@ -2193,7 +2215,7 @@ function tn(e) {
|
|
|
2193
2215
|
}
|
|
2194
2216
|
let o = e.getIframeHost();
|
|
2195
2217
|
if (!o) throw new Z("Speech session is not attached.");
|
|
2196
|
-
let s = await
|
|
2218
|
+
let s = await Xt(i.audio, i.signal);
|
|
2197
2219
|
return o.speechPlay({
|
|
2198
2220
|
source: s,
|
|
2199
2221
|
characterId: i.characterId,
|
|
@@ -2205,13 +2227,13 @@ function tn(e) {
|
|
|
2205
2227
|
},
|
|
2206
2228
|
createUtterance(r) {
|
|
2207
2229
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2208
|
-
let i =
|
|
2230
|
+
let i = Lt(r);
|
|
2209
2231
|
if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
|
|
2210
2232
|
let a = r.queue ?? "replace-active";
|
|
2211
2233
|
if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
|
|
2212
2234
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2213
|
-
let o = new
|
|
2214
|
-
id:
|
|
2235
|
+
let o = new tn({
|
|
2236
|
+
id: Zt(),
|
|
2215
2237
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2216
2238
|
format: i,
|
|
2217
2239
|
queue: a,
|
|
@@ -2223,7 +2245,7 @@ function tn(e) {
|
|
|
2223
2245
|
t === o && (t = null);
|
|
2224
2246
|
}), r.track && (async () => {
|
|
2225
2247
|
try {
|
|
2226
|
-
if (await
|
|
2248
|
+
if (await Yt({
|
|
2227
2249
|
track: r.track,
|
|
2228
2250
|
utterance: o,
|
|
2229
2251
|
sampleRate: i.sampleRate,
|
|
@@ -2251,16 +2273,16 @@ function tn(e) {
|
|
|
2251
2273
|
}
|
|
2252
2274
|
//#endregion
|
|
2253
2275
|
//#region src/v2/types/sessionInteraction.ts
|
|
2254
|
-
function
|
|
2276
|
+
function rn(e) {
|
|
2255
2277
|
let t = e?.trim();
|
|
2256
2278
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2257
2279
|
}
|
|
2258
2280
|
//#endregion
|
|
2259
2281
|
//#region src/v2/experience.ts
|
|
2260
|
-
function
|
|
2282
|
+
function an(e) {
|
|
2261
2283
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2262
2284
|
}
|
|
2263
|
-
var
|
|
2285
|
+
var on = class e {
|
|
2264
2286
|
bootstrap;
|
|
2265
2287
|
conversationProcessor;
|
|
2266
2288
|
iframeHost = null;
|
|
@@ -2277,19 +2299,20 @@ var an = class e {
|
|
|
2277
2299
|
pendingStage = null;
|
|
2278
2300
|
pendingPipBackground = null;
|
|
2279
2301
|
pendingPipShadow = null;
|
|
2302
|
+
pendingTheatre = null;
|
|
2280
2303
|
lastInteraction = null;
|
|
2281
2304
|
closeHandlers = [];
|
|
2282
|
-
eventRegistry =
|
|
2305
|
+
eventRegistry = xt();
|
|
2283
2306
|
readyEnvelope = null;
|
|
2284
2307
|
startedEnvelope = null;
|
|
2285
2308
|
sessionMintedEnvelope = null;
|
|
2286
2309
|
conversationCache = [];
|
|
2287
2310
|
speech;
|
|
2288
2311
|
constructor(e) {
|
|
2289
|
-
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 =
|
|
2312
|
+
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 = nn({
|
|
2290
2313
|
getIframeHost: () => this.iframeHost,
|
|
2291
2314
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2292
|
-
getCapabilities: () =>
|
|
2315
|
+
getCapabilities: () => sn(this.resolvedSession),
|
|
2293
2316
|
getActiveCharacterId: () => "character_unknown",
|
|
2294
2317
|
onProcessorInterrupt: () => {
|
|
2295
2318
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2310,6 +2333,8 @@ var an = class e {
|
|
|
2310
2333
|
embedBaseUrl: t.embedBaseUrl,
|
|
2311
2334
|
debug: t.debug,
|
|
2312
2335
|
speechOnly: t.speechOnly,
|
|
2336
|
+
previewBackground: t.previewBackground,
|
|
2337
|
+
previewForeground: t.previewForeground,
|
|
2313
2338
|
ui: t.ui,
|
|
2314
2339
|
onStart: t.onStart,
|
|
2315
2340
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2333,6 +2358,8 @@ var an = class e {
|
|
|
2333
2358
|
mode: t.mode,
|
|
2334
2359
|
speechInputMode: t.speechInputMode,
|
|
2335
2360
|
speechOnly: t.speechOnly,
|
|
2361
|
+
previewBackground: t.previewBackground,
|
|
2362
|
+
previewForeground: t.previewForeground,
|
|
2336
2363
|
attribution: t.attribution,
|
|
2337
2364
|
alreadyConverted: t.alreadyConverted,
|
|
2338
2365
|
ui: t.ui,
|
|
@@ -2356,6 +2383,8 @@ var an = class e {
|
|
|
2356
2383
|
mode: t.mode,
|
|
2357
2384
|
speechInputMode: t.speechInputMode,
|
|
2358
2385
|
speechOnly: t.speechOnly,
|
|
2386
|
+
previewBackground: t.previewBackground,
|
|
2387
|
+
previewForeground: t.previewForeground,
|
|
2359
2388
|
attribution: t.attribution,
|
|
2360
2389
|
alreadyConverted: t.alreadyConverted,
|
|
2361
2390
|
ui: t.ui,
|
|
@@ -2372,7 +2401,7 @@ var an = class e {
|
|
|
2372
2401
|
return null;
|
|
2373
2402
|
}
|
|
2374
2403
|
on(e, t) {
|
|
2375
|
-
let n =
|
|
2404
|
+
let n = St(this.eventRegistry, e, t);
|
|
2376
2405
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
2377
2406
|
}
|
|
2378
2407
|
async attach(e) {
|
|
@@ -2386,13 +2415,13 @@ var an = class e {
|
|
|
2386
2415
|
if (this.closed) throw Error("Session has ended.");
|
|
2387
2416
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2388
2417
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2389
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2418
|
+
let t = this.bootstrap.embedBaseUrl ?? mt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = gt(t, n, r ? void 0 : ht(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, an(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize, e.stage, e.pipBackground, e.pipShadow, r ? void 0 : this.bootstrap.previewBackground, r ? void 0 : this.bootstrap.previewForeground), a = vt(i), o = null, s = new Promise((e) => {
|
|
2390
2419
|
o = e;
|
|
2391
2420
|
}), c = null, l = new Promise((e) => {
|
|
2392
2421
|
c = e;
|
|
2393
|
-
}), u =
|
|
2422
|
+
}), u = lt((e) => {
|
|
2394
2423
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2395
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2424
|
+
}), d = this.bootstrap.onUserTranscript, f = ct({
|
|
2396
2425
|
container: e.container,
|
|
2397
2426
|
src: i,
|
|
2398
2427
|
playerOrigin: a,
|
|
@@ -2455,7 +2484,8 @@ var an = class e {
|
|
|
2455
2484
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
2456
2485
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
2457
2486
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
2458
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2487
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
2488
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
2459
2489
|
});
|
|
2460
2490
|
this.iframeHost = f;
|
|
2461
2491
|
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ze(this.bootstrap.sessionEndpoint, {
|
|
@@ -2494,7 +2524,7 @@ var an = class e {
|
|
|
2494
2524
|
operation: "attach",
|
|
2495
2525
|
message: e instanceof Error ? e.message : String(e),
|
|
2496
2526
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2497
|
-
release:
|
|
2527
|
+
release: ut
|
|
2498
2528
|
});
|
|
2499
2529
|
} catch {}
|
|
2500
2530
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -2510,12 +2540,16 @@ var an = class e {
|
|
|
2510
2540
|
startButton: e.startButton,
|
|
2511
2541
|
theme: e.theme,
|
|
2512
2542
|
showFeedback: e.showFeedback,
|
|
2513
|
-
interaction: e.interaction
|
|
2543
|
+
interaction: e.interaction,
|
|
2544
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2545
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2514
2546
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2515
2547
|
startButton: e.startButton,
|
|
2516
2548
|
theme: e.theme,
|
|
2517
2549
|
showFeedback: e.showFeedback,
|
|
2518
|
-
interaction: e.interaction
|
|
2550
|
+
interaction: e.interaction,
|
|
2551
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2552
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2519
2553
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2520
2554
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2521
2555
|
})]).catch((e) => {
|
|
@@ -2526,7 +2560,7 @@ var an = class e {
|
|
|
2526
2560
|
operation: "attach",
|
|
2527
2561
|
message: e instanceof Error ? e.message : String(e),
|
|
2528
2562
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2529
|
-
release:
|
|
2563
|
+
release: ut
|
|
2530
2564
|
});
|
|
2531
2565
|
} catch {}
|
|
2532
2566
|
throw e;
|
|
@@ -2540,11 +2574,11 @@ var an = class e {
|
|
|
2540
2574
|
operation: "attach",
|
|
2541
2575
|
message: e instanceof Error ? e.message : String(e),
|
|
2542
2576
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2543
|
-
release:
|
|
2577
|
+
release: ut
|
|
2544
2578
|
});
|
|
2545
2579
|
} catch {}
|
|
2546
2580
|
throw e;
|
|
2547
|
-
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.createPlayerFacade();
|
|
2581
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.pendingTheatre !== null && f.postSetTheatre(this.pendingTheatre), this.createPlayerFacade();
|
|
2548
2582
|
}
|
|
2549
2583
|
async startListening() {
|
|
2550
2584
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2558,6 +2592,10 @@ var an = class e {
|
|
|
2558
2592
|
getConversation() {
|
|
2559
2593
|
return this.conversationCache;
|
|
2560
2594
|
}
|
|
2595
|
+
setTheatre(e) {
|
|
2596
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2597
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
2598
|
+
}
|
|
2561
2599
|
setWidgetChrome(e) {
|
|
2562
2600
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
2563
2601
|
}
|
|
@@ -2568,7 +2606,7 @@ var an = class e {
|
|
|
2568
2606
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2569
2607
|
}
|
|
2570
2608
|
async setFit(e) {
|
|
2571
|
-
let t =
|
|
2609
|
+
let t = rn(e);
|
|
2572
2610
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2573
2611
|
if (this.closed) throw Error("Session has ended.");
|
|
2574
2612
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2618,7 +2656,7 @@ var an = class e {
|
|
|
2618
2656
|
this.close();
|
|
2619
2657
|
}
|
|
2620
2658
|
destroy() {
|
|
2621
|
-
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,
|
|
2659
|
+
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, wt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
2622
2660
|
}
|
|
2623
2661
|
resolveMintInteraction() {
|
|
2624
2662
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2630,8 +2668,8 @@ var an = class e {
|
|
|
2630
2668
|
return this.resolvedSession?.id ?? "";
|
|
2631
2669
|
}
|
|
2632
2670
|
emitWrapped(e, t) {
|
|
2633
|
-
let n =
|
|
2634
|
-
return
|
|
2671
|
+
let n = bt(e, this.getSessionId(), t);
|
|
2672
|
+
return Ct(this.eventRegistry, e, n), n;
|
|
2635
2673
|
}
|
|
2636
2674
|
queueProcessorTurn(e) {
|
|
2637
2675
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2690,7 +2728,7 @@ var an = class e {
|
|
|
2690
2728
|
};
|
|
2691
2729
|
}
|
|
2692
2730
|
};
|
|
2693
|
-
function
|
|
2731
|
+
function sn(e) {
|
|
2694
2732
|
return e ? {
|
|
2695
2733
|
textSpeech: e.capabilities.speech.output,
|
|
2696
2734
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2701,26 +2739,26 @@ function on(e) {
|
|
|
2701
2739
|
}
|
|
2702
2740
|
//#endregion
|
|
2703
2741
|
//#region src/widget/dockGeometry.ts
|
|
2704
|
-
var
|
|
2705
|
-
function
|
|
2742
|
+
var cn = "(min-width: 768px)", ln = 24, un = .5, dn = 1200, fn = .85, pn = 9 / 16;
|
|
2743
|
+
function mn() {
|
|
2706
2744
|
if (typeof window > "u") return 800;
|
|
2707
2745
|
let e = window.screen?.availHeight;
|
|
2708
2746
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2709
2747
|
}
|
|
2710
|
-
function
|
|
2711
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2712
|
-
return s > a && (s = a, o = s /
|
|
2748
|
+
function hn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = ln, r = typeof window < "u" ? mn() : 800) {
|
|
2749
|
+
let i = Math.max(160, Math.min(t - n * 2, t * fn)), a = Math.max(120, e - n * 2), o = Math.min(r * un, dn, i), s = o * pn;
|
|
2750
|
+
return s > a && (s = a, o = s / pn, o > i && (o = i, s = o * pn)), {
|
|
2713
2751
|
width: Math.round(s),
|
|
2714
2752
|
height: Math.round(o)
|
|
2715
2753
|
};
|
|
2716
2754
|
}
|
|
2717
|
-
function
|
|
2755
|
+
function gn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = ln) {
|
|
2718
2756
|
return {
|
|
2719
2757
|
left: Math.max(r, t - e.width - r),
|
|
2720
2758
|
top: Math.max(r, n - e.height - r)
|
|
2721
2759
|
};
|
|
2722
2760
|
}
|
|
2723
|
-
function
|
|
2761
|
+
function _n(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = ln) {
|
|
2724
2762
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2725
2763
|
return {
|
|
2726
2764
|
left: Math.min(Math.max(a, e), o),
|
|
@@ -2728,14 +2766,14 @@ function gn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
|
|
|
2728
2766
|
};
|
|
2729
2767
|
}
|
|
2730
2768
|
function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2731
|
-
return e(
|
|
2769
|
+
return e(cn).matches;
|
|
2732
2770
|
}
|
|
2733
2771
|
//#endregion
|
|
2734
2772
|
//#region src/widget/mountExperienceWidget.ts
|
|
2735
|
-
function
|
|
2773
|
+
function vn(e) {
|
|
2736
2774
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2737
2775
|
}
|
|
2738
|
-
function
|
|
2776
|
+
function yn(e) {
|
|
2739
2777
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2740
2778
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2741
2779
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2743,8 +2781,8 @@ function vn(e) {
|
|
|
2743
2781
|
function $(e) {
|
|
2744
2782
|
return e === "expanded" || e === "docked";
|
|
2745
2783
|
}
|
|
2746
|
-
var
|
|
2747
|
-
function
|
|
2784
|
+
var bn = "<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>", xn = "<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>", Sn = "<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>", Cn = "<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>";
|
|
2785
|
+
function wn(e, t, n) {
|
|
2748
2786
|
V(ce);
|
|
2749
2787
|
let r = v({
|
|
2750
2788
|
galleryThumb: t.galleryThumb,
|
|
@@ -2774,7 +2812,7 @@ function Cn(e, t, n) {
|
|
|
2774
2812
|
}
|
|
2775
2813
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : se(i);
|
|
2776
2814
|
}
|
|
2777
|
-
function
|
|
2815
|
+
function Tn(e) {
|
|
2778
2816
|
return e.startButton ? {
|
|
2779
2817
|
...e.startButton,
|
|
2780
2818
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2786,7 +2824,7 @@ function wn(e) {
|
|
|
2786
2824
|
variant: "primary"
|
|
2787
2825
|
};
|
|
2788
2826
|
}
|
|
2789
|
-
function
|
|
2827
|
+
function En(e) {
|
|
2790
2828
|
let t = !1, n = () => {
|
|
2791
2829
|
t || e();
|
|
2792
2830
|
}, r = () => {
|
|
@@ -2806,12 +2844,12 @@ function Tn(e) {
|
|
|
2806
2844
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2807
2845
|
};
|
|
2808
2846
|
}
|
|
2809
|
-
function
|
|
2847
|
+
function Dn(e, t) {
|
|
2810
2848
|
fe(ue);
|
|
2811
2849
|
let n = t.experienceId?.trim();
|
|
2812
2850
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2813
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2814
|
-
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",
|
|
2851
|
+
let r = t.prefetch ?? "onExpand", i = vn(t.position), a = document.createElement("div");
|
|
2852
|
+
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", yn(t.offset));
|
|
2815
2853
|
let o = document.createElement("button");
|
|
2816
2854
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2817
2855
|
let s = document.createElement("div");
|
|
@@ -2831,11 +2869,11 @@ function En(e, t) {
|
|
|
2831
2869
|
let m = document.createElement("span");
|
|
2832
2870
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2833
2871
|
let h = document.createElement("button");
|
|
2834
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2872
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Sn, h.setAttribute("aria-label", "Reduce");
|
|
2835
2873
|
let g = document.createElement("button");
|
|
2836
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2874
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = bn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2837
2875
|
let _ = document.createElement("button");
|
|
2838
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2876
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = xn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2839
2877
|
let v = document.createElement("div");
|
|
2840
2878
|
v.className = "liforma-ew__stage";
|
|
2841
2879
|
let y = document.createElement("div");
|
|
@@ -2863,11 +2901,11 @@ function En(e, t) {
|
|
|
2863
2901
|
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";
|
|
2864
2902
|
}, se = (e, t) => {
|
|
2865
2903
|
if (z() !== "docked") return;
|
|
2866
|
-
let n =
|
|
2904
|
+
let n = hn(), r = _n(e - ne, t - re, n);
|
|
2867
2905
|
M = r.left, N = r.top, oe(r.left, r.top, n.width, n.height);
|
|
2868
2906
|
}, ce = (e, t) => {
|
|
2869
2907
|
if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2870
|
-
let n =
|
|
2908
|
+
let n = hn(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = _n(r + e, i + t, n);
|
|
2871
2909
|
M = a.left, N = a.top, oe(a.left, a.top, n.width, n.height);
|
|
2872
2910
|
}, le = (e) => {
|
|
2873
2911
|
F === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
@@ -2895,10 +2933,10 @@ function En(e, t) {
|
|
|
2895
2933
|
h.hidden = !0;
|
|
2896
2934
|
return;
|
|
2897
2935
|
}
|
|
2898
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2936
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Cn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Sn, h.setAttribute("aria-label", "Reduce"));
|
|
2899
2937
|
}, ge = (e) => {
|
|
2900
|
-
let t =
|
|
2901
|
-
n =
|
|
2938
|
+
let t = hn(), n = e && M !== null && N !== null ? _n(M, N, t) : gn(t);
|
|
2939
|
+
n = _n(n.left, n.top, t), M = n.left, N = n.top, oe(n.left, n.top, t.width, t.height), H();
|
|
2902
2940
|
}, U = () => {
|
|
2903
2941
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2904
2942
|
requestAnimationFrame(() => {
|
|
@@ -2945,7 +2983,7 @@ function En(e, t) {
|
|
|
2945
2983
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2946
2984
|
}, Ce = (e) => {
|
|
2947
2985
|
k?.(), k = null;
|
|
2948
|
-
let t =
|
|
2986
|
+
let t = wn(s, e, { parallax: R });
|
|
2949
2987
|
return t ? (k = t, !0) : !1;
|
|
2950
2988
|
}, we = () => {
|
|
2951
2989
|
if (Ce(be)) {
|
|
@@ -2977,7 +3015,7 @@ function En(e, t) {
|
|
|
2977
3015
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2978
3016
|
}), K = () => ({
|
|
2979
3017
|
...t.fit ? { fit: t.fit } : {},
|
|
2980
|
-
startButton:
|
|
3018
|
+
startButton: Tn(t),
|
|
2981
3019
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
2982
3020
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
2983
3021
|
}), q = (e = !0) => {
|
|
@@ -3029,7 +3067,7 @@ function En(e, t) {
|
|
|
3029
3067
|
let e = O;
|
|
3030
3068
|
l.hidden = !1, (async () => {
|
|
3031
3069
|
try {
|
|
3032
|
-
let t = await
|
|
3070
|
+
let t = await on.startSession(Te());
|
|
3033
3071
|
if (S || e !== O) {
|
|
3034
3072
|
t.destroy();
|
|
3035
3073
|
return;
|
|
@@ -3088,7 +3126,7 @@ function En(e, t) {
|
|
|
3088
3126
|
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 () => {
|
|
3089
3127
|
try {
|
|
3090
3128
|
q();
|
|
3091
|
-
let t = await
|
|
3129
|
+
let t = await on.startSession(Te());
|
|
3092
3130
|
if (S || e !== O) {
|
|
3093
3131
|
t.destroy();
|
|
3094
3132
|
return;
|
|
@@ -3172,7 +3210,7 @@ function En(e, t) {
|
|
|
3172
3210
|
}
|
|
3173
3211
|
H();
|
|
3174
3212
|
}
|
|
3175
|
-
}, We = typeof window < "u" ? window.matchMedia(
|
|
3213
|
+
}, We = typeof window < "u" ? window.matchMedia(cn) : null, Ge = () => {
|
|
3176
3214
|
if (!S) {
|
|
3177
3215
|
if (z() === "docked" && !Q()) {
|
|
3178
3216
|
je();
|
|
@@ -3185,7 +3223,7 @@ function En(e, t) {
|
|
|
3185
3223
|
e.stopPropagation(), J();
|
|
3186
3224
|
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), we(), H(), r === "eager" ? queueMicrotask(() => {
|
|
3187
3225
|
S || Fe();
|
|
3188
|
-
}) : r === "idle" && (te =
|
|
3226
|
+
}) : r === "idle" && (te = En(() => {
|
|
3189
3227
|
S || Fe();
|
|
3190
3228
|
})), {
|
|
3191
3229
|
root: a,
|
|
@@ -3206,6 +3244,6 @@ function En(e, t) {
|
|
|
3206
3244
|
};
|
|
3207
3245
|
}
|
|
3208
3246
|
//#endregion
|
|
3209
|
-
export { ce as EXPERIENCE_THUMBNAIL_CSS, ue as EXPERIENCE_WIDGET_CSS,
|
|
3247
|
+
export { ce as EXPERIENCE_THUMBNAIL_CSS, ue as EXPERIENCE_WIDGET_CSS, on as Experience, U as LiformaError, X as SPEECH_LIMITS, Mt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, jt as SpeechUtteranceClosedError, At as UnsupportedSpeechOperationError, ne as attachImageReady, P as attachLazyThumb, oe as attachScrollLinkedParallax, w as buildHostedLaunchUrl, V as ensureExperienceThumbnailStyles, fe as ensureExperienceWidgetStyles, _e as fetchExperiencePreview, j as getDefaultLazyRootMargin, F as horizontalParallaxFromViewportY, ye as liformaErrorFromResponse, Dn as mountExperienceWidget, n as navigateOnExperienceClose, T as resolveThumbnailHref, S as resolveThumbnailInteraction, v as resolveThumbnailLayers, r as thumbnailFitClass, _ as toGalleryThumbUrl, Ae as warnLocaleVoiceFallbacks };
|
|
3210
3248
|
|
|
3211
3249
|
//# sourceMappingURL=index.js.map
|