@liforma/client 0.4.11 → 0.4.13
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 +17 -0
- package/dist/next/index.js +394 -369
- package/dist/next/index.js.map +1 -1
- package/dist/next/thumbnail.js +1 -1
- 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 +11 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/npm/index.js +206 -181
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.js +1 -1
- package/dist/npm/thumbnail/index.js.map +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 +11 -0
- package/dist/npm/v2/experience.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 +9 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +514 -473
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/thumbnail.js +1 -1
- 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 +11 -0
- package/dist/react/v2/experience.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 +1 -1
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +22 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/npm/index.js
CHANGED
|
@@ -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");
|
|
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.13",
|
|
1338
1353
|
type: "module",
|
|
1339
1354
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1340
1355
|
license: "MIT",
|
|
@@ -1553,50 +1568,50 @@ var lt = `sdk@${{
|
|
|
1553
1568
|
vitest: "^4.1.10",
|
|
1554
1569
|
wrangler: "^4.101.0"
|
|
1555
1570
|
}
|
|
1556
|
-
}.version}`,
|
|
1557
|
-
function
|
|
1571
|
+
}.version}`, dt = "https://player.liforma.ai/embed", ft = "http://localhost:3002/embed";
|
|
1572
|
+
function pt() {
|
|
1558
1573
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1559
1574
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1560
1575
|
if (typeof document > "u") return null;
|
|
1561
1576
|
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
1577
|
return t ? t.replace(/\/$/, "") : null;
|
|
1563
1578
|
}
|
|
1564
|
-
function
|
|
1565
|
-
let e =
|
|
1566
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : y() ?
|
|
1579
|
+
function mt() {
|
|
1580
|
+
let e = pt();
|
|
1581
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : y() ? ft : dt;
|
|
1567
1582
|
}
|
|
1568
|
-
function
|
|
1583
|
+
function ht(e, t) {
|
|
1569
1584
|
return e?.trim() || t?.trim() || void 0;
|
|
1570
1585
|
}
|
|
1571
|
-
function
|
|
1572
|
-
let d = (e ??
|
|
1586
|
+
function gt(e, t, n, r, i, a, o, s, c, l, u) {
|
|
1587
|
+
let d = (e ?? mt()).replace(/\/$/, ""), f = d.endsWith("/embed") ? d : `${d}/embed`, p = new URL(f), m = n?.trim();
|
|
1573
1588
|
m && p.searchParams.set("backdropId", m);
|
|
1574
1589
|
let h = r?.trim();
|
|
1575
|
-
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)),
|
|
1590
|
+
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)), _t(p.toString());
|
|
1576
1591
|
}
|
|
1577
|
-
function
|
|
1592
|
+
function _t(e) {
|
|
1578
1593
|
if (typeof location > "u") return e;
|
|
1579
1594
|
let t = new URL(e);
|
|
1580
1595
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1581
1596
|
}
|
|
1582
|
-
function
|
|
1597
|
+
function vt(e) {
|
|
1583
1598
|
return new URL(e).origin;
|
|
1584
1599
|
}
|
|
1585
1600
|
//#endregion
|
|
1586
1601
|
//#region src/v2/experienceEvents.ts
|
|
1587
|
-
function
|
|
1602
|
+
function yt() {
|
|
1588
1603
|
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
1604
|
}
|
|
1590
|
-
function
|
|
1605
|
+
function bt(e, t, n) {
|
|
1591
1606
|
return {
|
|
1592
|
-
id:
|
|
1607
|
+
id: yt(),
|
|
1593
1608
|
type: e,
|
|
1594
1609
|
sessionId: t,
|
|
1595
1610
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1596
1611
|
data: n
|
|
1597
1612
|
};
|
|
1598
1613
|
}
|
|
1599
|
-
function
|
|
1614
|
+
function xt() {
|
|
1600
1615
|
return {
|
|
1601
1616
|
ready: /* @__PURE__ */ new Set(),
|
|
1602
1617
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1617,32 +1632,32 @@ function bt() {
|
|
|
1617
1632
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1618
1633
|
};
|
|
1619
1634
|
}
|
|
1620
|
-
function
|
|
1635
|
+
function St(e, t, n) {
|
|
1621
1636
|
return e[t].add(n), () => e[t].delete(n);
|
|
1622
1637
|
}
|
|
1623
|
-
function
|
|
1638
|
+
function Ct(e, t, n) {
|
|
1624
1639
|
for (let r of e[t]) r(n);
|
|
1625
1640
|
}
|
|
1626
|
-
function
|
|
1641
|
+
function wt(e) {
|
|
1627
1642
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1628
1643
|
}
|
|
1629
1644
|
//#endregion
|
|
1630
1645
|
//#region src/v2/speech/types.ts
|
|
1631
|
-
function
|
|
1646
|
+
function Tt(e) {
|
|
1632
1647
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1633
1648
|
}
|
|
1634
|
-
function
|
|
1649
|
+
function Et(e) {
|
|
1635
1650
|
return "url" in e && typeof e.url == "string";
|
|
1636
1651
|
}
|
|
1637
|
-
function
|
|
1652
|
+
function Dt(e) {
|
|
1638
1653
|
if (!("track" in e)) return !1;
|
|
1639
1654
|
let t = e.track;
|
|
1640
1655
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1641
1656
|
}
|
|
1642
|
-
function
|
|
1643
|
-
return !
|
|
1657
|
+
function Ot(e) {
|
|
1658
|
+
return !Tt(e) && !Et(e) && !Dt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1644
1659
|
}
|
|
1645
|
-
var
|
|
1660
|
+
var kt = [
|
|
1646
1661
|
8e3,
|
|
1647
1662
|
16e3,
|
|
1648
1663
|
22050,
|
|
@@ -1660,14 +1675,14 @@ var Ot = [
|
|
|
1660
1675
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1661
1676
|
MAX_PENDING_WRITES: 8,
|
|
1662
1677
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1663
|
-
},
|
|
1678
|
+
}, At = class extends Error {
|
|
1664
1679
|
operation;
|
|
1665
1680
|
requiredCapability;
|
|
1666
1681
|
name = "UnsupportedSpeechOperationError";
|
|
1667
1682
|
constructor(e, t) {
|
|
1668
1683
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1669
1684
|
}
|
|
1670
|
-
},
|
|
1685
|
+
}, jt = class extends Error {
|
|
1671
1686
|
name = "SpeechUtteranceClosedError";
|
|
1672
1687
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1673
1688
|
super(e);
|
|
@@ -1677,72 +1692,72 @@ var Ot = [
|
|
|
1677
1692
|
constructor(e, t) {
|
|
1678
1693
|
super(e, t);
|
|
1679
1694
|
}
|
|
1680
|
-
},
|
|
1695
|
+
}, Mt = class extends Error {
|
|
1681
1696
|
name = "SpeechBufferTimeoutError";
|
|
1682
1697
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1683
1698
|
super(e);
|
|
1684
1699
|
}
|
|
1685
1700
|
};
|
|
1686
|
-
function
|
|
1701
|
+
function Nt(e = "none") {
|
|
1687
1702
|
return {
|
|
1688
1703
|
mode: e,
|
|
1689
1704
|
trackedDurationMs: 0,
|
|
1690
1705
|
fallbackDurationMs: 0
|
|
1691
1706
|
};
|
|
1692
1707
|
}
|
|
1693
|
-
function Nt(e) {
|
|
1694
|
-
return Ot.includes(e);
|
|
1695
|
-
}
|
|
1696
1708
|
function Pt(e) {
|
|
1709
|
+
return kt.includes(e);
|
|
1710
|
+
}
|
|
1711
|
+
function Ft(e) {
|
|
1697
1712
|
if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
|
|
1698
1713
|
if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
|
|
1699
|
-
if (!
|
|
1714
|
+
if (!Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1700
1715
|
}
|
|
1701
|
-
function
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1716
|
+
function It(e) {
|
|
1717
|
+
if (Tt(e)) {
|
|
1718
|
+
Ft(e.format);
|
|
1704
1719
|
return;
|
|
1705
1720
|
}
|
|
1706
|
-
if (
|
|
1721
|
+
if (Et(e)) {
|
|
1707
1722
|
if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
|
|
1708
|
-
if (e.sampleRate !== void 0 && !
|
|
1723
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1709
1724
|
return;
|
|
1710
1725
|
}
|
|
1711
|
-
if (
|
|
1726
|
+
if (Dt(e)) {
|
|
1712
1727
|
if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
1713
|
-
if (e.sampleRate !== void 0 && !
|
|
1728
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1714
1729
|
return;
|
|
1715
1730
|
}
|
|
1716
|
-
if (
|
|
1731
|
+
if (Ot(e)) {
|
|
1717
1732
|
let t = e.encoding.trim().toLowerCase();
|
|
1718
1733
|
if (!t) throw new Z("Encoded audio MIME type is required.");
|
|
1719
1734
|
if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1720
|
-
if (e.sampleRate !== void 0 && !
|
|
1735
|
+
if (e.sampleRate !== void 0 && !Pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1721
1736
|
return;
|
|
1722
1737
|
}
|
|
1723
1738
|
throw new Z("Unsupported speech.play audio shape.");
|
|
1724
1739
|
}
|
|
1725
|
-
function
|
|
1726
|
-
if (e.format) return
|
|
1740
|
+
function Lt(e) {
|
|
1741
|
+
if (e.format) return Ft(e.format), e.format;
|
|
1727
1742
|
if (e.track) {
|
|
1728
1743
|
let t = {
|
|
1729
1744
|
encoding: "pcm_s16le",
|
|
1730
1745
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1731
1746
|
channels: 1
|
|
1732
1747
|
};
|
|
1733
|
-
return
|
|
1748
|
+
return Ft(t), t;
|
|
1734
1749
|
}
|
|
1735
1750
|
throw new Z("createUtterance requires format or track.");
|
|
1736
1751
|
}
|
|
1737
|
-
function
|
|
1752
|
+
function Rt(e) {
|
|
1738
1753
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1739
1754
|
}
|
|
1740
|
-
function
|
|
1755
|
+
function zt(e) {
|
|
1741
1756
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1742
1757
|
}
|
|
1743
1758
|
//#endregion
|
|
1744
1759
|
//#region src/byo/pcm.ts
|
|
1745
|
-
function
|
|
1760
|
+
function Bt(e) {
|
|
1746
1761
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1747
1762
|
for (let t = 0; t < e.length; t++) {
|
|
1748
1763
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1752,11 +1767,11 @@ function zt(e) {
|
|
|
1752
1767
|
}
|
|
1753
1768
|
//#endregion
|
|
1754
1769
|
//#region src/byo/resample.ts
|
|
1755
|
-
function
|
|
1770
|
+
function Vt(e, t, n, r, i) {
|
|
1756
1771
|
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
1772
|
return ((a * i + o) * i + s) * i + c;
|
|
1758
1773
|
}
|
|
1759
|
-
function
|
|
1774
|
+
function Ht(e, t) {
|
|
1760
1775
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1761
1776
|
if (e === t) return {
|
|
1762
1777
|
fromRate: e,
|
|
@@ -1779,7 +1794,7 @@ function Vt(e, t) {
|
|
|
1779
1794
|
let a = [];
|
|
1780
1795
|
for (; i + 2 < r.length - 1;) {
|
|
1781
1796
|
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(
|
|
1797
|
+
a.push(Vt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1783
1798
|
}
|
|
1784
1799
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1785
1800
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1791,7 +1806,7 @@ function Vt(e, t) {
|
|
|
1791
1806
|
}
|
|
1792
1807
|
//#endregion
|
|
1793
1808
|
//#region src/byo/audioCapture.ts
|
|
1794
|
-
var
|
|
1809
|
+
var Ut = "liforma-pcm-capture", Wt = `
|
|
1795
1810
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1796
1811
|
process(inputs) {
|
|
1797
1812
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1803,29 +1818,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1803
1818
|
return true;
|
|
1804
1819
|
}
|
|
1805
1820
|
}
|
|
1806
|
-
registerProcessor('${
|
|
1807
|
-
`,
|
|
1808
|
-
function Gt() {
|
|
1809
|
-
return Wt ||= URL.createObjectURL(new Blob([Ut], { type: "application/javascript" })), Wt;
|
|
1810
|
-
}
|
|
1821
|
+
registerProcessor('${Ut}', LiformaPcmCaptureProcessor);
|
|
1822
|
+
`, Gt = null;
|
|
1811
1823
|
function Kt() {
|
|
1824
|
+
return Gt ||= URL.createObjectURL(new Blob([Wt], { type: "application/javascript" })), Gt;
|
|
1825
|
+
}
|
|
1826
|
+
function qt() {
|
|
1812
1827
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1813
1828
|
}
|
|
1814
|
-
async function
|
|
1815
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1829
|
+
async function Jt(e) {
|
|
1830
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = qt();
|
|
1816
1831
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1817
1832
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1818
1833
|
l.gain.value = 0;
|
|
1819
|
-
let u = s.sampleRate, d =
|
|
1834
|
+
let u = s.sampleRate, d = Ht(u, n), f = !1, p = !1, m = (e) => {
|
|
1820
1835
|
if (f || i && !i()) return;
|
|
1821
1836
|
let t = d.push(e);
|
|
1822
|
-
t.length !== 0 && r(
|
|
1837
|
+
t.length !== 0 && r(Bt(t));
|
|
1823
1838
|
}, h = () => void 0;
|
|
1824
1839
|
return await (async () => {
|
|
1825
1840
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1826
1841
|
try {
|
|
1827
|
-
await s.audioWorklet.addModule(
|
|
1828
|
-
let e = new AudioWorkletNode(s,
|
|
1842
|
+
await s.audioWorklet.addModule(Kt());
|
|
1843
|
+
let e = new AudioWorkletNode(s, Ut, {
|
|
1829
1844
|
numberOfInputs: 1,
|
|
1830
1845
|
numberOfOutputs: 1,
|
|
1831
1846
|
outputChannelCount: [1]
|
|
@@ -1875,7 +1890,7 @@ async function qt(e) {
|
|
|
1875
1890
|
}
|
|
1876
1891
|
//#endregion
|
|
1877
1892
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1878
|
-
async function
|
|
1893
|
+
async function Yt(e) {
|
|
1879
1894
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1880
1895
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
|
|
1881
1896
|
if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1884,13 +1899,13 @@ async function Jt(e) {
|
|
|
1884
1899
|
s || (s = !0, c?.stop(), c = null);
|
|
1885
1900
|
};
|
|
1886
1901
|
try {
|
|
1887
|
-
c = await
|
|
1902
|
+
c = await Jt({
|
|
1888
1903
|
mediaStream: a,
|
|
1889
1904
|
targetSampleRate: r,
|
|
1890
1905
|
shouldSend: () => !s && !i?.aborted,
|
|
1891
1906
|
onPcm: (e) => {
|
|
1892
1907
|
if (s || i?.aborted) return;
|
|
1893
|
-
let t =
|
|
1908
|
+
let t = Rt(e);
|
|
1894
1909
|
o = o.then(async () => {
|
|
1895
1910
|
if (s || i?.aborted) return;
|
|
1896
1911
|
let e = 0;
|
|
@@ -1919,10 +1934,10 @@ async function Jt(e) {
|
|
|
1919
1934
|
}
|
|
1920
1935
|
//#endregion
|
|
1921
1936
|
//#region src/v2/speech/speechController.ts
|
|
1922
|
-
async function
|
|
1923
|
-
if (
|
|
1924
|
-
if (
|
|
1925
|
-
let t =
|
|
1937
|
+
async function Xt(e, t) {
|
|
1938
|
+
if (Dt(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
|
|
1939
|
+
if (Tt(e)) {
|
|
1940
|
+
let t = Rt(e.data);
|
|
1926
1941
|
if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
|
|
1927
1942
|
return {
|
|
1928
1943
|
kind: "pcm",
|
|
@@ -1930,17 +1945,17 @@ async function Yt(e, t) {
|
|
|
1930
1945
|
format: e.format
|
|
1931
1946
|
};
|
|
1932
1947
|
}
|
|
1933
|
-
if (
|
|
1948
|
+
if (Et(e)) return {
|
|
1934
1949
|
kind: "url",
|
|
1935
1950
|
url: e.url.trim(),
|
|
1936
1951
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1937
1952
|
};
|
|
1938
|
-
if (!
|
|
1953
|
+
if (!Ot(e)) throw new Z("Unsupported speech.play audio shape.");
|
|
1939
1954
|
let n;
|
|
1940
1955
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1941
1956
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1942
1957
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1943
|
-
} else n =
|
|
1958
|
+
} else n = Rt(e.data);
|
|
1944
1959
|
return {
|
|
1945
1960
|
kind: "encoded",
|
|
1946
1961
|
data: n.slice().buffer,
|
|
@@ -1948,10 +1963,10 @@ async function Yt(e, t) {
|
|
|
1948
1963
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1949
1964
|
};
|
|
1950
1965
|
}
|
|
1951
|
-
function
|
|
1966
|
+
function Zt() {
|
|
1952
1967
|
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
1968
|
}
|
|
1954
|
-
function
|
|
1969
|
+
function Qt(e, t = "completed") {
|
|
1955
1970
|
return {
|
|
1956
1971
|
utteranceId: e.speechId,
|
|
1957
1972
|
characterId: e.characterId,
|
|
@@ -1965,13 +1980,13 @@ function Zt(e, t = "completed") {
|
|
|
1965
1980
|
}
|
|
1966
1981
|
};
|
|
1967
1982
|
}
|
|
1968
|
-
function
|
|
1983
|
+
function $t(e) {
|
|
1969
1984
|
return e instanceof Error ? e : new Z(String(e));
|
|
1970
1985
|
}
|
|
1971
|
-
function
|
|
1986
|
+
function en(e) {
|
|
1972
1987
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1973
1988
|
}
|
|
1974
|
-
var
|
|
1989
|
+
var tn = class {
|
|
1975
1990
|
id;
|
|
1976
1991
|
characterId;
|
|
1977
1992
|
result;
|
|
@@ -2000,14 +2015,14 @@ var en = class {
|
|
|
2000
2015
|
queue: e.queue,
|
|
2001
2016
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2002
2017
|
}).catch((e) => {
|
|
2003
|
-
throw this.fail(
|
|
2018
|
+
throw this.fail($t(e)), $t(e);
|
|
2004
2019
|
}), this.signal?.addEventListener("abort", () => {
|
|
2005
2020
|
this.cancel();
|
|
2006
2021
|
}, { once: !0 });
|
|
2007
2022
|
}
|
|
2008
2023
|
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 =
|
|
2024
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new jt();
|
|
2025
|
+
let n = Rt(e);
|
|
2011
2026
|
if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
|
|
2012
2027
|
if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
|
|
2013
2028
|
if (n.byteLength === 0) return;
|
|
@@ -2016,13 +2031,13 @@ var en = class {
|
|
|
2016
2031
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2017
2032
|
if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2018
2033
|
let a = async () => {
|
|
2019
|
-
if (this.closed || this.settled) throw new
|
|
2034
|
+
if (this.closed || this.settled) throw new jt();
|
|
2020
2035
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2021
2036
|
utteranceId: this.id,
|
|
2022
2037
|
audio: t.buffer,
|
|
2023
2038
|
byteLength: t.byteLength
|
|
2024
2039
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2025
|
-
setTimeout(() => t(new
|
|
2040
|
+
setTimeout(() => t(new Mt()), r);
|
|
2026
2041
|
})]);
|
|
2027
2042
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2028
2043
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2034,7 +2049,7 @@ var en = class {
|
|
|
2034
2049
|
}
|
|
2035
2050
|
}
|
|
2036
2051
|
async setTranscript(e) {
|
|
2037
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2052
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new jt();
|
|
2038
2053
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2039
2054
|
utteranceId: this.id,
|
|
2040
2055
|
transcript: e
|
|
@@ -2051,7 +2066,7 @@ var en = class {
|
|
|
2051
2066
|
});
|
|
2052
2067
|
return this.resolve(t), t;
|
|
2053
2068
|
} catch (e) {
|
|
2054
|
-
let t =
|
|
2069
|
+
let t = $t(e);
|
|
2055
2070
|
throw this.fail(t), t;
|
|
2056
2071
|
}
|
|
2057
2072
|
}
|
|
@@ -2069,11 +2084,11 @@ var en = class {
|
|
|
2069
2084
|
characterId: this.characterId,
|
|
2070
2085
|
status: "cancelled",
|
|
2071
2086
|
durationMs: 0,
|
|
2072
|
-
animation:
|
|
2087
|
+
animation: Nt("none")
|
|
2073
2088
|
};
|
|
2074
2089
|
return this.resolve(t), t;
|
|
2075
2090
|
} catch (e) {
|
|
2076
|
-
let t =
|
|
2091
|
+
let t = $t(e);
|
|
2077
2092
|
throw this.fail(t), t;
|
|
2078
2093
|
}
|
|
2079
2094
|
}
|
|
@@ -2086,7 +2101,7 @@ var en = class {
|
|
|
2086
2101
|
return e;
|
|
2087
2102
|
}
|
|
2088
2103
|
resolve(e) {
|
|
2089
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2104
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new jt()));
|
|
2090
2105
|
}
|
|
2091
2106
|
fail(e) {
|
|
2092
2107
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
@@ -2098,7 +2113,7 @@ var en = class {
|
|
|
2098
2113
|
}
|
|
2099
2114
|
await new Promise((t, n) => {
|
|
2100
2115
|
let r = setTimeout(() => {
|
|
2101
|
-
n(new
|
|
2116
|
+
n(new Mt());
|
|
2102
2117
|
}, e);
|
|
2103
2118
|
this.pendingWriteWaiters.push({
|
|
2104
2119
|
resolve: () => {
|
|
@@ -2117,13 +2132,13 @@ var en = class {
|
|
|
2117
2132
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2118
2133
|
}
|
|
2119
2134
|
};
|
|
2120
|
-
function
|
|
2135
|
+
function nn(e) {
|
|
2121
2136
|
let t = null, n = (t, n) => {
|
|
2122
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2137
|
+
if (!e.getCapabilities()[n]) throw new At(t, n);
|
|
2123
2138
|
}, r = {
|
|
2124
2139
|
async speak(r) {
|
|
2125
2140
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2126
|
-
let i =
|
|
2141
|
+
let i = zt(r.queue ?? "append");
|
|
2127
2142
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2128
2143
|
let a = e.getIframeHost();
|
|
2129
2144
|
if (!a) throw new Z("Speech session is not attached.");
|
|
@@ -2143,41 +2158,41 @@ function tn(e) {
|
|
|
2143
2158
|
return;
|
|
2144
2159
|
}
|
|
2145
2160
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2146
|
-
t.removeEventListener("abort", s), n(
|
|
2161
|
+
t.removeEventListener("abort", s), n(Qt(e, "completed"));
|
|
2147
2162
|
}, (a) => {
|
|
2148
|
-
if (t.removeEventListener("abort", s),
|
|
2163
|
+
if (t.removeEventListener("abort", s), en(a)) {
|
|
2149
2164
|
n({
|
|
2150
2165
|
utteranceId: "utt_interrupted",
|
|
2151
2166
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2152
2167
|
status: "interrupted",
|
|
2153
2168
|
durationMs: 0,
|
|
2154
2169
|
transcript: r.text,
|
|
2155
|
-
animation:
|
|
2170
|
+
animation: Nt("none")
|
|
2156
2171
|
});
|
|
2157
2172
|
return;
|
|
2158
2173
|
}
|
|
2159
|
-
i(
|
|
2174
|
+
i($t(a));
|
|
2160
2175
|
});
|
|
2161
2176
|
});
|
|
2162
2177
|
}
|
|
2163
2178
|
try {
|
|
2164
|
-
return
|
|
2179
|
+
return Qt(await o, "completed");
|
|
2165
2180
|
} catch (t) {
|
|
2166
|
-
if (
|
|
2181
|
+
if (en(t)) return {
|
|
2167
2182
|
utteranceId: "utt_interrupted",
|
|
2168
2183
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2169
2184
|
status: "interrupted",
|
|
2170
2185
|
durationMs: 0,
|
|
2171
2186
|
transcript: r.text,
|
|
2172
|
-
animation:
|
|
2187
|
+
animation: Nt("none")
|
|
2173
2188
|
};
|
|
2174
|
-
throw
|
|
2189
|
+
throw $t(t);
|
|
2175
2190
|
}
|
|
2176
2191
|
},
|
|
2177
2192
|
async play(i) {
|
|
2178
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2193
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), It(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2179
2194
|
let a = i.queue ?? "append";
|
|
2180
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2195
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Dt(i.audio)) {
|
|
2181
2196
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2182
2197
|
return r.createUtterance({
|
|
2183
2198
|
format: {
|
|
@@ -2193,7 +2208,7 @@ function tn(e) {
|
|
|
2193
2208
|
}
|
|
2194
2209
|
let o = e.getIframeHost();
|
|
2195
2210
|
if (!o) throw new Z("Speech session is not attached.");
|
|
2196
|
-
let s = await
|
|
2211
|
+
let s = await Xt(i.audio, i.signal);
|
|
2197
2212
|
return o.speechPlay({
|
|
2198
2213
|
source: s,
|
|
2199
2214
|
characterId: i.characterId,
|
|
@@ -2205,13 +2220,13 @@ function tn(e) {
|
|
|
2205
2220
|
},
|
|
2206
2221
|
createUtterance(r) {
|
|
2207
2222
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2208
|
-
let i =
|
|
2223
|
+
let i = Lt(r);
|
|
2209
2224
|
if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
|
|
2210
2225
|
let a = r.queue ?? "replace-active";
|
|
2211
2226
|
if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
|
|
2212
2227
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2213
|
-
let o = new
|
|
2214
|
-
id:
|
|
2228
|
+
let o = new tn({
|
|
2229
|
+
id: Zt(),
|
|
2215
2230
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2216
2231
|
format: i,
|
|
2217
2232
|
queue: a,
|
|
@@ -2223,7 +2238,7 @@ function tn(e) {
|
|
|
2223
2238
|
t === o && (t = null);
|
|
2224
2239
|
}), r.track && (async () => {
|
|
2225
2240
|
try {
|
|
2226
|
-
if (await
|
|
2241
|
+
if (await Yt({
|
|
2227
2242
|
track: r.track,
|
|
2228
2243
|
utterance: o,
|
|
2229
2244
|
sampleRate: i.sampleRate,
|
|
@@ -2251,16 +2266,16 @@ function tn(e) {
|
|
|
2251
2266
|
}
|
|
2252
2267
|
//#endregion
|
|
2253
2268
|
//#region src/v2/types/sessionInteraction.ts
|
|
2254
|
-
function
|
|
2269
|
+
function rn(e) {
|
|
2255
2270
|
let t = e?.trim();
|
|
2256
2271
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2257
2272
|
}
|
|
2258
2273
|
//#endregion
|
|
2259
2274
|
//#region src/v2/experience.ts
|
|
2260
|
-
function
|
|
2275
|
+
function an(e) {
|
|
2261
2276
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2262
2277
|
}
|
|
2263
|
-
var
|
|
2278
|
+
var on = class e {
|
|
2264
2279
|
bootstrap;
|
|
2265
2280
|
conversationProcessor;
|
|
2266
2281
|
iframeHost = null;
|
|
@@ -2277,19 +2292,20 @@ var an = class e {
|
|
|
2277
2292
|
pendingStage = null;
|
|
2278
2293
|
pendingPipBackground = null;
|
|
2279
2294
|
pendingPipShadow = null;
|
|
2295
|
+
pendingTheatre = null;
|
|
2280
2296
|
lastInteraction = null;
|
|
2281
2297
|
closeHandlers = [];
|
|
2282
|
-
eventRegistry =
|
|
2298
|
+
eventRegistry = xt();
|
|
2283
2299
|
readyEnvelope = null;
|
|
2284
2300
|
startedEnvelope = null;
|
|
2285
2301
|
sessionMintedEnvelope = null;
|
|
2286
2302
|
conversationCache = [];
|
|
2287
2303
|
speech;
|
|
2288
2304
|
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 =
|
|
2305
|
+
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
2306
|
getIframeHost: () => this.iframeHost,
|
|
2291
2307
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2292
|
-
getCapabilities: () =>
|
|
2308
|
+
getCapabilities: () => sn(this.resolvedSession),
|
|
2293
2309
|
getActiveCharacterId: () => "character_unknown",
|
|
2294
2310
|
onProcessorInterrupt: () => {
|
|
2295
2311
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2372,7 +2388,7 @@ var an = class e {
|
|
|
2372
2388
|
return null;
|
|
2373
2389
|
}
|
|
2374
2390
|
on(e, t) {
|
|
2375
|
-
let n =
|
|
2391
|
+
let n = St(this.eventRegistry, e, t);
|
|
2376
2392
|
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
2393
|
}
|
|
2378
2394
|
async attach(e) {
|
|
@@ -2386,13 +2402,13 @@ var an = class e {
|
|
|
2386
2402
|
if (this.closed) throw Error("Session has ended.");
|
|
2387
2403
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2388
2404
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2389
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2405
|
+
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), a = vt(i), o = null, s = new Promise((e) => {
|
|
2390
2406
|
o = e;
|
|
2391
2407
|
}), c = null, l = new Promise((e) => {
|
|
2392
2408
|
c = e;
|
|
2393
|
-
}), u =
|
|
2409
|
+
}), u = lt((e) => {
|
|
2394
2410
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2395
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2411
|
+
}), d = this.bootstrap.onUserTranscript, f = ct({
|
|
2396
2412
|
container: e.container,
|
|
2397
2413
|
src: i,
|
|
2398
2414
|
playerOrigin: a,
|
|
@@ -2455,7 +2471,8 @@ var an = class e {
|
|
|
2455
2471
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
2456
2472
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
2457
2473
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
2458
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2474
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
2475
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
2459
2476
|
});
|
|
2460
2477
|
this.iframeHost = f;
|
|
2461
2478
|
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ze(this.bootstrap.sessionEndpoint, {
|
|
@@ -2494,7 +2511,7 @@ var an = class e {
|
|
|
2494
2511
|
operation: "attach",
|
|
2495
2512
|
message: e instanceof Error ? e.message : String(e),
|
|
2496
2513
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2497
|
-
release:
|
|
2514
|
+
release: ut
|
|
2498
2515
|
});
|
|
2499
2516
|
} catch {}
|
|
2500
2517
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -2510,12 +2527,16 @@ var an = class e {
|
|
|
2510
2527
|
startButton: e.startButton,
|
|
2511
2528
|
theme: e.theme,
|
|
2512
2529
|
showFeedback: e.showFeedback,
|
|
2513
|
-
interaction: e.interaction
|
|
2530
|
+
interaction: e.interaction,
|
|
2531
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2532
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2514
2533
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2515
2534
|
startButton: e.startButton,
|
|
2516
2535
|
theme: e.theme,
|
|
2517
2536
|
showFeedback: e.showFeedback,
|
|
2518
|
-
interaction: e.interaction
|
|
2537
|
+
interaction: e.interaction,
|
|
2538
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2539
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2519
2540
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2520
2541
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2521
2542
|
})]).catch((e) => {
|
|
@@ -2526,7 +2547,7 @@ var an = class e {
|
|
|
2526
2547
|
operation: "attach",
|
|
2527
2548
|
message: e instanceof Error ? e.message : String(e),
|
|
2528
2549
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2529
|
-
release:
|
|
2550
|
+
release: ut
|
|
2530
2551
|
});
|
|
2531
2552
|
} catch {}
|
|
2532
2553
|
throw e;
|
|
@@ -2540,11 +2561,11 @@ var an = class e {
|
|
|
2540
2561
|
operation: "attach",
|
|
2541
2562
|
message: e instanceof Error ? e.message : String(e),
|
|
2542
2563
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2543
|
-
release:
|
|
2564
|
+
release: ut
|
|
2544
2565
|
});
|
|
2545
2566
|
} catch {}
|
|
2546
2567
|
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();
|
|
2568
|
+
}), 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
2569
|
}
|
|
2549
2570
|
async startListening() {
|
|
2550
2571
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2558,6 +2579,10 @@ var an = class e {
|
|
|
2558
2579
|
getConversation() {
|
|
2559
2580
|
return this.conversationCache;
|
|
2560
2581
|
}
|
|
2582
|
+
setTheatre(e) {
|
|
2583
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2584
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
2585
|
+
}
|
|
2561
2586
|
setWidgetChrome(e) {
|
|
2562
2587
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
2563
2588
|
}
|
|
@@ -2568,7 +2593,7 @@ var an = class e {
|
|
|
2568
2593
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2569
2594
|
}
|
|
2570
2595
|
async setFit(e) {
|
|
2571
|
-
let t =
|
|
2596
|
+
let t = rn(e);
|
|
2572
2597
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2573
2598
|
if (this.closed) throw Error("Session has ended.");
|
|
2574
2599
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2618,7 +2643,7 @@ var an = class e {
|
|
|
2618
2643
|
this.close();
|
|
2619
2644
|
}
|
|
2620
2645
|
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,
|
|
2646
|
+
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
2647
|
}
|
|
2623
2648
|
resolveMintInteraction() {
|
|
2624
2649
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2630,8 +2655,8 @@ var an = class e {
|
|
|
2630
2655
|
return this.resolvedSession?.id ?? "";
|
|
2631
2656
|
}
|
|
2632
2657
|
emitWrapped(e, t) {
|
|
2633
|
-
let n =
|
|
2634
|
-
return
|
|
2658
|
+
let n = bt(e, this.getSessionId(), t);
|
|
2659
|
+
return Ct(this.eventRegistry, e, n), n;
|
|
2635
2660
|
}
|
|
2636
2661
|
queueProcessorTurn(e) {
|
|
2637
2662
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2690,7 +2715,7 @@ var an = class e {
|
|
|
2690
2715
|
};
|
|
2691
2716
|
}
|
|
2692
2717
|
};
|
|
2693
|
-
function
|
|
2718
|
+
function sn(e) {
|
|
2694
2719
|
return e ? {
|
|
2695
2720
|
textSpeech: e.capabilities.speech.output,
|
|
2696
2721
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2701,26 +2726,26 @@ function on(e) {
|
|
|
2701
2726
|
}
|
|
2702
2727
|
//#endregion
|
|
2703
2728
|
//#region src/widget/dockGeometry.ts
|
|
2704
|
-
var
|
|
2705
|
-
function
|
|
2729
|
+
var cn = "(min-width: 768px)", ln = 24, un = .5, dn = 1200, fn = .85, pn = 9 / 16;
|
|
2730
|
+
function mn() {
|
|
2706
2731
|
if (typeof window > "u") return 800;
|
|
2707
2732
|
let e = window.screen?.availHeight;
|
|
2708
2733
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2709
2734
|
}
|
|
2710
|
-
function
|
|
2711
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2712
|
-
return s > a && (s = a, o = s /
|
|
2735
|
+
function hn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = ln, r = typeof window < "u" ? mn() : 800) {
|
|
2736
|
+
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;
|
|
2737
|
+
return s > a && (s = a, o = s / pn, o > i && (o = i, s = o * pn)), {
|
|
2713
2738
|
width: Math.round(s),
|
|
2714
2739
|
height: Math.round(o)
|
|
2715
2740
|
};
|
|
2716
2741
|
}
|
|
2717
|
-
function
|
|
2742
|
+
function gn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = ln) {
|
|
2718
2743
|
return {
|
|
2719
2744
|
left: Math.max(r, t - e.width - r),
|
|
2720
2745
|
top: Math.max(r, n - e.height - r)
|
|
2721
2746
|
};
|
|
2722
2747
|
}
|
|
2723
|
-
function
|
|
2748
|
+
function _n(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = ln) {
|
|
2724
2749
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2725
2750
|
return {
|
|
2726
2751
|
left: Math.min(Math.max(a, e), o),
|
|
@@ -2728,14 +2753,14 @@ function gn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
|
|
|
2728
2753
|
};
|
|
2729
2754
|
}
|
|
2730
2755
|
function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2731
|
-
return e(
|
|
2756
|
+
return e(cn).matches;
|
|
2732
2757
|
}
|
|
2733
2758
|
//#endregion
|
|
2734
2759
|
//#region src/widget/mountExperienceWidget.ts
|
|
2735
|
-
function
|
|
2760
|
+
function vn(e) {
|
|
2736
2761
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2737
2762
|
}
|
|
2738
|
-
function
|
|
2763
|
+
function yn(e) {
|
|
2739
2764
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2740
2765
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2741
2766
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2743,8 +2768,8 @@ function vn(e) {
|
|
|
2743
2768
|
function $(e) {
|
|
2744
2769
|
return e === "expanded" || e === "docked";
|
|
2745
2770
|
}
|
|
2746
|
-
var
|
|
2747
|
-
function
|
|
2771
|
+
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>";
|
|
2772
|
+
function wn(e, t, n) {
|
|
2748
2773
|
V(ce);
|
|
2749
2774
|
let r = v({
|
|
2750
2775
|
galleryThumb: t.galleryThumb,
|
|
@@ -2774,7 +2799,7 @@ function Cn(e, t, n) {
|
|
|
2774
2799
|
}
|
|
2775
2800
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : se(i);
|
|
2776
2801
|
}
|
|
2777
|
-
function
|
|
2802
|
+
function Tn(e) {
|
|
2778
2803
|
return e.startButton ? {
|
|
2779
2804
|
...e.startButton,
|
|
2780
2805
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2786,7 +2811,7 @@ function wn(e) {
|
|
|
2786
2811
|
variant: "primary"
|
|
2787
2812
|
};
|
|
2788
2813
|
}
|
|
2789
|
-
function
|
|
2814
|
+
function En(e) {
|
|
2790
2815
|
let t = !1, n = () => {
|
|
2791
2816
|
t || e();
|
|
2792
2817
|
}, r = () => {
|
|
@@ -2806,12 +2831,12 @@ function Tn(e) {
|
|
|
2806
2831
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2807
2832
|
};
|
|
2808
2833
|
}
|
|
2809
|
-
function
|
|
2834
|
+
function Dn(e, t) {
|
|
2810
2835
|
fe(ue);
|
|
2811
2836
|
let n = t.experienceId?.trim();
|
|
2812
2837
|
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",
|
|
2838
|
+
let r = t.prefetch ?? "onExpand", i = vn(t.position), a = document.createElement("div");
|
|
2839
|
+
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
2840
|
let o = document.createElement("button");
|
|
2816
2841
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2817
2842
|
let s = document.createElement("div");
|
|
@@ -2831,11 +2856,11 @@ function En(e, t) {
|
|
|
2831
2856
|
let m = document.createElement("span");
|
|
2832
2857
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2833
2858
|
let h = document.createElement("button");
|
|
2834
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2859
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Sn, h.setAttribute("aria-label", "Reduce");
|
|
2835
2860
|
let g = document.createElement("button");
|
|
2836
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2861
|
+
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
2862
|
let _ = document.createElement("button");
|
|
2838
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2863
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = xn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2839
2864
|
let v = document.createElement("div");
|
|
2840
2865
|
v.className = "liforma-ew__stage";
|
|
2841
2866
|
let y = document.createElement("div");
|
|
@@ -2863,11 +2888,11 @@ function En(e, t) {
|
|
|
2863
2888
|
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
2889
|
}, se = (e, t) => {
|
|
2865
2890
|
if (z() !== "docked") return;
|
|
2866
|
-
let n =
|
|
2891
|
+
let n = hn(), r = _n(e - ne, t - re, n);
|
|
2867
2892
|
M = r.left, N = r.top, oe(r.left, r.top, n.width, n.height);
|
|
2868
2893
|
}, ce = (e, t) => {
|
|
2869
2894
|
if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2870
|
-
let n =
|
|
2895
|
+
let n = hn(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = _n(r + e, i + t, n);
|
|
2871
2896
|
M = a.left, N = a.top, oe(a.left, a.top, n.width, n.height);
|
|
2872
2897
|
}, le = (e) => {
|
|
2873
2898
|
F === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
@@ -2895,10 +2920,10 @@ function En(e, t) {
|
|
|
2895
2920
|
h.hidden = !0;
|
|
2896
2921
|
return;
|
|
2897
2922
|
}
|
|
2898
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2923
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Cn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Sn, h.setAttribute("aria-label", "Reduce"));
|
|
2899
2924
|
}, ge = (e) => {
|
|
2900
|
-
let t =
|
|
2901
|
-
n =
|
|
2925
|
+
let t = hn(), n = e && M !== null && N !== null ? _n(M, N, t) : gn(t);
|
|
2926
|
+
n = _n(n.left, n.top, t), M = n.left, N = n.top, oe(n.left, n.top, t.width, t.height), H();
|
|
2902
2927
|
}, U = () => {
|
|
2903
2928
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2904
2929
|
requestAnimationFrame(() => {
|
|
@@ -2945,7 +2970,7 @@ function En(e, t) {
|
|
|
2945
2970
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2946
2971
|
}, Ce = (e) => {
|
|
2947
2972
|
k?.(), k = null;
|
|
2948
|
-
let t =
|
|
2973
|
+
let t = wn(s, e, { parallax: R });
|
|
2949
2974
|
return t ? (k = t, !0) : !1;
|
|
2950
2975
|
}, we = () => {
|
|
2951
2976
|
if (Ce(be)) {
|
|
@@ -2977,7 +3002,7 @@ function En(e, t) {
|
|
|
2977
3002
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2978
3003
|
}), K = () => ({
|
|
2979
3004
|
...t.fit ? { fit: t.fit } : {},
|
|
2980
|
-
startButton:
|
|
3005
|
+
startButton: Tn(t),
|
|
2981
3006
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
2982
3007
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
2983
3008
|
}), q = (e = !0) => {
|
|
@@ -3029,7 +3054,7 @@ function En(e, t) {
|
|
|
3029
3054
|
let e = O;
|
|
3030
3055
|
l.hidden = !1, (async () => {
|
|
3031
3056
|
try {
|
|
3032
|
-
let t = await
|
|
3057
|
+
let t = await on.startSession(Te());
|
|
3033
3058
|
if (S || e !== O) {
|
|
3034
3059
|
t.destroy();
|
|
3035
3060
|
return;
|
|
@@ -3088,7 +3113,7 @@ function En(e, t) {
|
|
|
3088
3113
|
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
3114
|
try {
|
|
3090
3115
|
q();
|
|
3091
|
-
let t = await
|
|
3116
|
+
let t = await on.startSession(Te());
|
|
3092
3117
|
if (S || e !== O) {
|
|
3093
3118
|
t.destroy();
|
|
3094
3119
|
return;
|
|
@@ -3172,7 +3197,7 @@ function En(e, t) {
|
|
|
3172
3197
|
}
|
|
3173
3198
|
H();
|
|
3174
3199
|
}
|
|
3175
|
-
}, We = typeof window < "u" ? window.matchMedia(
|
|
3200
|
+
}, We = typeof window < "u" ? window.matchMedia(cn) : null, Ge = () => {
|
|
3176
3201
|
if (!S) {
|
|
3177
3202
|
if (z() === "docked" && !Q()) {
|
|
3178
3203
|
je();
|
|
@@ -3185,7 +3210,7 @@ function En(e, t) {
|
|
|
3185
3210
|
e.stopPropagation(), J();
|
|
3186
3211
|
}), 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
3212
|
S || Fe();
|
|
3188
|
-
}) : r === "idle" && (te =
|
|
3213
|
+
}) : r === "idle" && (te = En(() => {
|
|
3189
3214
|
S || Fe();
|
|
3190
3215
|
})), {
|
|
3191
3216
|
root: a,
|
|
@@ -3206,6 +3231,6 @@ function En(e, t) {
|
|
|
3206
3231
|
};
|
|
3207
3232
|
}
|
|
3208
3233
|
//#endregion
|
|
3209
|
-
export { ce as EXPERIENCE_THUMBNAIL_CSS, ue as EXPERIENCE_WIDGET_CSS,
|
|
3234
|
+
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
3235
|
|
|
3211
3236
|
//# sourceMappingURL=index.js.map
|