@liforma/client 0.4.14 → 0.4.15
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 +6 -0
- package/dist/next/index.js +275 -263
- package/dist/next/index.js.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +7 -7
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +8 -5
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/next/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/npm/index.js +475 -463
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +7 -7
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +8 -5
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +1 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/types/index.d.ts +1 -1
- package/dist/npm/v2/types/index.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/npm/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -1
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +6 -4
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +486 -468
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +7 -7
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +8 -5
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/react/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +3 -3
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +4 -0
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -839,16 +839,19 @@ function Je(e, t) {
|
|
|
839
839
|
}
|
|
840
840
|
//#endregion
|
|
841
841
|
//#region src/v2/types/sessionLaunch.ts
|
|
842
|
-
function Ye(e) {
|
|
842
|
+
function Ye(e, t) {
|
|
843
|
+
return t === void 0 ? {} : { [e]: t };
|
|
844
|
+
}
|
|
845
|
+
function Xe(e) {
|
|
843
846
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
844
847
|
}
|
|
845
848
|
function X(e) {
|
|
846
849
|
return typeof e == "boolean";
|
|
847
850
|
}
|
|
848
|
-
function
|
|
849
|
-
if (!
|
|
851
|
+
function Ze(e) {
|
|
852
|
+
if (!Xe(e)) return null;
|
|
850
853
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
851
|
-
return !
|
|
854
|
+
return !Xe(t) || !Xe(n) || !Xe(r) || !Xe(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
852
855
|
speech: {
|
|
853
856
|
input: t.input,
|
|
854
857
|
output: t.output,
|
|
@@ -859,8 +862,8 @@ function Xe(e) {
|
|
|
859
862
|
tools: { enabled: i.enabled }
|
|
860
863
|
};
|
|
861
864
|
}
|
|
862
|
-
function
|
|
863
|
-
return !
|
|
865
|
+
function Qe(e) {
|
|
866
|
+
return !Xe(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
864
867
|
speech: {
|
|
865
868
|
input: e.speechInput,
|
|
866
869
|
output: e.speechOutput,
|
|
@@ -871,12 +874,12 @@ function Ze(e) {
|
|
|
871
874
|
tools: { enabled: e.tools }
|
|
872
875
|
};
|
|
873
876
|
}
|
|
874
|
-
function Qe(e) {
|
|
875
|
-
return Xe(e) ?? Ze(e);
|
|
876
|
-
}
|
|
877
877
|
function $e(e) {
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
return Ze(e) ?? Qe(e);
|
|
879
|
+
}
|
|
880
|
+
function et(e) {
|
|
881
|
+
if (!Xe(e)) throw Error("Session Launch response is missing session.");
|
|
882
|
+
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = $e(e.capabilities), l = tt(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
|
|
880
883
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
881
884
|
return {
|
|
882
885
|
id: t,
|
|
@@ -892,11 +895,11 @@ function $e(e) {
|
|
|
892
895
|
...d ? { createdAt: d } : {}
|
|
893
896
|
};
|
|
894
897
|
}
|
|
895
|
-
function
|
|
898
|
+
function tt(e) {
|
|
896
899
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
897
900
|
let t = [];
|
|
898
901
|
for (let n of e) {
|
|
899
|
-
if (!
|
|
902
|
+
if (!Xe(n)) continue;
|
|
900
903
|
let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
|
|
901
904
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
902
905
|
axis: e,
|
|
@@ -907,35 +910,35 @@ function et(e) {
|
|
|
907
910
|
}
|
|
908
911
|
return t.length > 0 ? t : void 0;
|
|
909
912
|
}
|
|
910
|
-
function
|
|
913
|
+
function nt(e) {
|
|
911
914
|
let t = e.localeVoiceFallbacks;
|
|
912
915
|
if (t?.length) for (let e of t) {
|
|
913
916
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
914
917
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
915
918
|
}
|
|
916
919
|
}
|
|
917
|
-
function
|
|
918
|
-
if (!
|
|
920
|
+
function rt(e) {
|
|
921
|
+
if (!Xe(e)) throw Error("Session Launch response must be a JSON object.");
|
|
919
922
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
920
923
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
921
|
-
let n =
|
|
922
|
-
return
|
|
924
|
+
let n = et(e.session);
|
|
925
|
+
return nt(n), {
|
|
923
926
|
session: n,
|
|
924
927
|
launch: t
|
|
925
928
|
};
|
|
926
929
|
}
|
|
927
930
|
//#endregion
|
|
928
931
|
//#region src/v2/api/mintPublicSession.ts
|
|
929
|
-
function
|
|
932
|
+
function it() {
|
|
930
933
|
try {
|
|
931
934
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
932
935
|
} catch {}
|
|
933
936
|
}
|
|
934
|
-
function
|
|
937
|
+
function at(e) {
|
|
935
938
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
936
939
|
}
|
|
937
|
-
function
|
|
938
|
-
let n =
|
|
940
|
+
function ot(e, t) {
|
|
941
|
+
let n = it(), r = at(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
939
942
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
940
943
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
941
944
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
@@ -958,38 +961,38 @@ function at(e, t) {
|
|
|
958
961
|
details: a
|
|
959
962
|
}) : t;
|
|
960
963
|
}
|
|
961
|
-
function
|
|
964
|
+
function st(e) {
|
|
962
965
|
let t = e?.locale?.trim();
|
|
963
966
|
if (t) return t;
|
|
964
967
|
let n = e?.language?.trim();
|
|
965
968
|
if (n) return n;
|
|
966
969
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
967
970
|
}
|
|
968
|
-
function
|
|
971
|
+
function ct(e) {
|
|
969
972
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
970
973
|
if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
971
974
|
return t || n || void 0;
|
|
972
975
|
}
|
|
973
|
-
function
|
|
974
|
-
let n = { experienceId: e }, r =
|
|
976
|
+
function lt(e, t) {
|
|
977
|
+
let n = { experienceId: e }, r = st(t);
|
|
975
978
|
r && (n.locale = r);
|
|
976
|
-
let i =
|
|
979
|
+
let i = ct(t);
|
|
977
980
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
978
981
|
let a = Ge(t?.attribution);
|
|
979
982
|
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
980
983
|
}
|
|
981
|
-
async function
|
|
984
|
+
async function ut(e, t) {
|
|
982
985
|
let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
983
986
|
method: "POST",
|
|
984
987
|
headers: {
|
|
985
988
|
"Content-Type": "application/json",
|
|
986
989
|
...r ? { "Idempotency-Key": r } : {}
|
|
987
990
|
},
|
|
988
|
-
body: JSON.stringify(
|
|
991
|
+
body: JSON.stringify(lt(e, t))
|
|
989
992
|
});
|
|
990
993
|
if (!i.ok) {
|
|
991
994
|
let t = await i.text();
|
|
992
|
-
throw
|
|
995
|
+
throw ot(e, Ve(i.status, t, i.headers));
|
|
993
996
|
}
|
|
994
997
|
let a;
|
|
995
998
|
try {
|
|
@@ -1001,9 +1004,9 @@ async function lt(e, t) {
|
|
|
1001
1004
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1002
1005
|
});
|
|
1003
1006
|
}
|
|
1004
|
-
return
|
|
1007
|
+
return rt(a);
|
|
1005
1008
|
}
|
|
1006
|
-
async function
|
|
1009
|
+
async function dt(e, t) {
|
|
1007
1010
|
let n = Je(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1008
1011
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1009
1012
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
@@ -1034,14 +1037,14 @@ async function ut(e, t) {
|
|
|
1034
1037
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1035
1038
|
});
|
|
1036
1039
|
}
|
|
1037
|
-
return
|
|
1040
|
+
return rt(s);
|
|
1038
1041
|
}
|
|
1039
1042
|
//#endregion
|
|
1040
1043
|
//#region src/v2/conversationProcessor.ts
|
|
1041
|
-
function
|
|
1044
|
+
function ft(e) {
|
|
1042
1045
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1043
1046
|
}
|
|
1044
|
-
function
|
|
1047
|
+
function pt(e) {
|
|
1045
1048
|
if (typeof e == "string") {
|
|
1046
1049
|
let t = e.trim();
|
|
1047
1050
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1055,24 +1058,24 @@ function ft(e) {
|
|
|
1055
1058
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1056
1059
|
};
|
|
1057
1060
|
}
|
|
1058
|
-
async function
|
|
1061
|
+
async function mt(e, t) {
|
|
1059
1062
|
let n = await e(t);
|
|
1060
|
-
return
|
|
1063
|
+
return ft(n) ? {
|
|
1061
1064
|
kind: "stream",
|
|
1062
1065
|
stream: n
|
|
1063
1066
|
} : {
|
|
1064
1067
|
kind: "complete",
|
|
1065
|
-
speech:
|
|
1068
|
+
speech: pt(n)
|
|
1066
1069
|
};
|
|
1067
1070
|
}
|
|
1068
1071
|
//#endregion
|
|
1069
1072
|
//#region src/v2/embed/playerReachability.ts
|
|
1070
|
-
var
|
|
1071
|
-
function
|
|
1073
|
+
var ht = "3002";
|
|
1074
|
+
function gt(e) {
|
|
1072
1075
|
let t = new URL(e);
|
|
1073
|
-
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port ||
|
|
1076
|
+
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || ht}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
|
|
1074
1077
|
}
|
|
1075
|
-
async function
|
|
1078
|
+
async function _t(e, t) {
|
|
1076
1079
|
try {
|
|
1077
1080
|
await fetch(e, {
|
|
1078
1081
|
method: "GET",
|
|
@@ -1080,25 +1083,25 @@ async function gt(e, t) {
|
|
|
1080
1083
|
signal: AbortSignal.timeout(8e3)
|
|
1081
1084
|
});
|
|
1082
1085
|
} catch {
|
|
1083
|
-
throw Error(
|
|
1086
|
+
throw Error(gt(t));
|
|
1084
1087
|
}
|
|
1085
1088
|
}
|
|
1086
|
-
function
|
|
1089
|
+
function vt(e, t, n, r) {
|
|
1087
1090
|
try {
|
|
1088
1091
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1089
1092
|
} catch (e) {
|
|
1090
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1093
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(gt(n), { cause: e }) : e;
|
|
1091
1094
|
}
|
|
1092
1095
|
}
|
|
1093
|
-
var
|
|
1094
|
-
function
|
|
1095
|
-
return typeof e == "number" &&
|
|
1096
|
+
var yt = new Set([1, 2]);
|
|
1097
|
+
function bt(e) {
|
|
1098
|
+
return typeof e == "number" && yt.has(e);
|
|
1096
1099
|
}
|
|
1097
|
-
var
|
|
1098
|
-
function
|
|
1100
|
+
var xt = 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("."));
|
|
1101
|
+
function St(e) {
|
|
1099
1102
|
if (!e || typeof e != "object") return null;
|
|
1100
1103
|
let t = e;
|
|
1101
|
-
if (!
|
|
1104
|
+
if (!bt(t.schemaVersion) || !t.type || !xt.has(t.type)) return null;
|
|
1102
1105
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1103
1106
|
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1104
1107
|
let e = t.payload;
|
|
@@ -1121,10 +1124,13 @@ function xt(e) {
|
|
|
1121
1124
|
let n = t.payload;
|
|
1122
1125
|
return !n || typeof n != "object" ? null : t;
|
|
1123
1126
|
}
|
|
1124
|
-
function
|
|
1127
|
+
function Ct(e, t) {
|
|
1128
|
+
return t === void 0 ? {} : { [e]: t };
|
|
1129
|
+
}
|
|
1130
|
+
function wt(e, t, n) {
|
|
1125
1131
|
let r = e.trim();
|
|
1126
1132
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1127
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.
|
|
1133
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatre;
|
|
1128
1134
|
return {
|
|
1129
1135
|
type: "launch",
|
|
1130
1136
|
schemaVersion: 2,
|
|
@@ -1135,32 +1141,34 @@ function St(e, t, n) {
|
|
|
1135
1141
|
...a ? { theme: a } : {},
|
|
1136
1142
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1137
1143
|
...s ? { interaction: s } : {},
|
|
1138
|
-
...
|
|
1139
|
-
...
|
|
1144
|
+
...Ct("settingsButton", n?.settingsButton),
|
|
1145
|
+
...Ct("theatreButton", n?.theatreButton),
|
|
1146
|
+
...Ct("fullscreenButton", n?.fullscreenButton),
|
|
1147
|
+
...c === void 0 ? {} : { theatre: c }
|
|
1140
1148
|
}
|
|
1141
1149
|
};
|
|
1142
1150
|
}
|
|
1143
|
-
function
|
|
1151
|
+
function Tt() {
|
|
1144
1152
|
return {
|
|
1145
1153
|
type: "parentHello",
|
|
1146
1154
|
schemaVersion: 2
|
|
1147
1155
|
};
|
|
1148
1156
|
}
|
|
1149
|
-
function
|
|
1157
|
+
function Et(e) {
|
|
1150
1158
|
return {
|
|
1151
1159
|
type: "widgetSetChrome",
|
|
1152
1160
|
schemaVersion: 2,
|
|
1153
1161
|
payload: { mode: e }
|
|
1154
1162
|
};
|
|
1155
1163
|
}
|
|
1156
|
-
function
|
|
1164
|
+
function Dt() {
|
|
1157
1165
|
return {
|
|
1158
1166
|
type: "widgetToggleAudioSettings",
|
|
1159
1167
|
schemaVersion: 2,
|
|
1160
1168
|
payload: {}
|
|
1161
1169
|
};
|
|
1162
1170
|
}
|
|
1163
|
-
function
|
|
1171
|
+
function Ot(e) {
|
|
1164
1172
|
return {
|
|
1165
1173
|
type: "setTheatre",
|
|
1166
1174
|
schemaVersion: 2,
|
|
@@ -1169,8 +1177,8 @@ function Et(e) {
|
|
|
1169
1177
|
}
|
|
1170
1178
|
//#endregion
|
|
1171
1179
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1172
|
-
var
|
|
1173
|
-
function
|
|
1180
|
+
var kt = "2147483000";
|
|
1181
|
+
function At(e) {
|
|
1174
1182
|
let { style: t } = e;
|
|
1175
1183
|
return {
|
|
1176
1184
|
position: t.position,
|
|
@@ -1188,11 +1196,11 @@ function Ot(e) {
|
|
|
1188
1196
|
maxHeight: t.maxHeight
|
|
1189
1197
|
};
|
|
1190
1198
|
}
|
|
1191
|
-
function
|
|
1199
|
+
function jt(e) {
|
|
1192
1200
|
let { style: t } = e;
|
|
1193
|
-
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 =
|
|
1201
|
+
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 = kt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1194
1202
|
}
|
|
1195
|
-
function
|
|
1203
|
+
function Mt(e, t) {
|
|
1196
1204
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1197
1205
|
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 = "";
|
|
1198
1206
|
return;
|
|
@@ -1202,20 +1210,20 @@ function At(e, t) {
|
|
|
1202
1210
|
}
|
|
1203
1211
|
//#endregion
|
|
1204
1212
|
//#region src/v2/embed/iframeHost.ts
|
|
1205
|
-
function
|
|
1213
|
+
function Nt(e) {
|
|
1206
1214
|
return e;
|
|
1207
1215
|
}
|
|
1208
1216
|
function Z() {
|
|
1209
1217
|
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)}`;
|
|
1210
1218
|
}
|
|
1211
|
-
var
|
|
1212
|
-
function
|
|
1219
|
+
var Pt = 3e4;
|
|
1220
|
+
function Ft(e) {
|
|
1213
1221
|
let t = e.container;
|
|
1214
1222
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1215
1223
|
let n = document.createElement("iframe");
|
|
1216
1224
|
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");
|
|
1217
1225
|
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1218
|
-
i !== r && (i = r, r ? (a =
|
|
1226
|
+
i !== r && (i = r, r ? (a = At(n), o = document.body.style.overflow, document.body.append(n), jt(n), document.body.style.overflow = "hidden") : (t.append(n), Mt(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1219
1227
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1220
1228
|
p = e, m = t;
|
|
1221
1229
|
}), g = () => {
|
|
@@ -1226,10 +1234,10 @@ function Nt(e) {
|
|
|
1226
1234
|
let i = Date.now();
|
|
1227
1235
|
if (d > 0 && i - d < 250) return;
|
|
1228
1236
|
d = i, g();
|
|
1229
|
-
let a =
|
|
1237
|
+
let a = wt(t.launch, t.session, t.chrome), o = () => {
|
|
1230
1238
|
if (r) return;
|
|
1231
1239
|
let t = n.contentWindow;
|
|
1232
|
-
t &&
|
|
1240
|
+
t && vt(t, a, e.playerOrigin);
|
|
1233
1241
|
};
|
|
1234
1242
|
o();
|
|
1235
1243
|
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
@@ -1237,17 +1245,17 @@ function Nt(e) {
|
|
|
1237
1245
|
r || !l || _(l);
|
|
1238
1246
|
}, y = () => {
|
|
1239
1247
|
if (u += 1, u === 1) {
|
|
1240
|
-
|
|
1248
|
+
_t(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1241
1249
|
return;
|
|
1242
1250
|
}
|
|
1243
1251
|
d = 0, v();
|
|
1244
1252
|
}, b = () => {
|
|
1245
|
-
u > 0 || m?.(Error(
|
|
1253
|
+
u > 0 || m?.(Error(gt(e.playerOrigin)));
|
|
1246
1254
|
};
|
|
1247
1255
|
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1248
1256
|
let x = (t) => {
|
|
1249
1257
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1250
|
-
let i =
|
|
1258
|
+
let i = St(t.data);
|
|
1251
1259
|
if (i) switch (i.type) {
|
|
1252
1260
|
case "close":
|
|
1253
1261
|
e.onClose?.(i.payload);
|
|
@@ -1286,7 +1294,7 @@ function Nt(e) {
|
|
|
1286
1294
|
e.onUserSpeechEnded?.(i.payload);
|
|
1287
1295
|
break;
|
|
1288
1296
|
case "modeChange":
|
|
1289
|
-
e.onActivityChange?.(
|
|
1297
|
+
e.onActivityChange?.(Nt(i.payload.mode));
|
|
1290
1298
|
break;
|
|
1291
1299
|
case "activityChange":
|
|
1292
1300
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1345,8 +1353,8 @@ function Nt(e) {
|
|
|
1345
1353
|
let S = (t, i) => {
|
|
1346
1354
|
if (r) return;
|
|
1347
1355
|
let a = n.contentWindow;
|
|
1348
|
-
if (!a) throw Error(
|
|
1349
|
-
|
|
1356
|
+
if (!a) throw Error(gt(e.playerOrigin));
|
|
1357
|
+
vt(a, t, e.playerOrigin, i);
|
|
1350
1358
|
}, C = (e, t = 12e4, n) => {
|
|
1351
1359
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1352
1360
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
@@ -1363,7 +1371,7 @@ function Nt(e) {
|
|
|
1363
1371
|
return h;
|
|
1364
1372
|
},
|
|
1365
1373
|
postParentHello() {
|
|
1366
|
-
S(
|
|
1374
|
+
S(Tt());
|
|
1367
1375
|
},
|
|
1368
1376
|
postLaunch(e, t, n) {
|
|
1369
1377
|
r || (l = {
|
|
@@ -1385,13 +1393,13 @@ function Nt(e) {
|
|
|
1385
1393
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1386
1394
|
},
|
|
1387
1395
|
postWidgetSetChrome(e) {
|
|
1388
|
-
S(
|
|
1396
|
+
S(Et(e));
|
|
1389
1397
|
},
|
|
1390
1398
|
postWidgetToggleAudioSettings() {
|
|
1391
|
-
S(
|
|
1399
|
+
S(Dt());
|
|
1392
1400
|
},
|
|
1393
1401
|
postSetTheatre(e) {
|
|
1394
|
-
S(
|
|
1402
|
+
S(Ot(e));
|
|
1395
1403
|
},
|
|
1396
1404
|
speak(e) {
|
|
1397
1405
|
return C({
|
|
@@ -1513,7 +1521,7 @@ function Nt(e) {
|
|
|
1513
1521
|
audio: e.audio,
|
|
1514
1522
|
byteLength: e.byteLength
|
|
1515
1523
|
}
|
|
1516
|
-
},
|
|
1524
|
+
}, Pt, [e.audio]);
|
|
1517
1525
|
},
|
|
1518
1526
|
speechUtteranceSetTranscript(e) {
|
|
1519
1527
|
return C({
|
|
@@ -1675,7 +1683,7 @@ function Nt(e) {
|
|
|
1675
1683
|
}
|
|
1676
1684
|
//#endregion
|
|
1677
1685
|
//#region src/v2/embed/readyGate.ts
|
|
1678
|
-
function
|
|
1686
|
+
function It(e) {
|
|
1679
1687
|
let t, n = !1, r = !1, i = () => {
|
|
1680
1688
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1681
1689
|
};
|
|
@@ -1690,9 +1698,9 @@ function Pt(e) {
|
|
|
1690
1698
|
}
|
|
1691
1699
|
//#endregion
|
|
1692
1700
|
//#region src/v2/sdkRelease.ts
|
|
1693
|
-
var
|
|
1701
|
+
var Lt = `sdk@${{
|
|
1694
1702
|
name: "@liforma/client",
|
|
1695
|
-
version: "0.4.
|
|
1703
|
+
version: "0.4.15",
|
|
1696
1704
|
type: "module",
|
|
1697
1705
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1698
1706
|
license: "MIT",
|
|
@@ -1914,54 +1922,54 @@ var Ft = `sdk@${{
|
|
|
1914
1922
|
vitest: "^4.1.10",
|
|
1915
1923
|
wrangler: "^4.101.0"
|
|
1916
1924
|
}
|
|
1917
|
-
}.version}`,
|
|
1918
|
-
function
|
|
1925
|
+
}.version}`, Rt = "https://player.liforma.ai/embed", zt = "http://localhost:3002/embed";
|
|
1926
|
+
function Bt() {
|
|
1919
1927
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1920
1928
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1921
1929
|
if (typeof document > "u") return null;
|
|
1922
1930
|
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();
|
|
1923
1931
|
return t ? t.replace(/\/$/, "") : null;
|
|
1924
1932
|
}
|
|
1925
|
-
function
|
|
1926
|
-
let e =
|
|
1927
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : te() ?
|
|
1933
|
+
function Vt() {
|
|
1934
|
+
let e = Bt();
|
|
1935
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : te() ? zt : Rt;
|
|
1928
1936
|
}
|
|
1929
|
-
function
|
|
1937
|
+
function Ht(e, t) {
|
|
1930
1938
|
return e?.trim() || t?.trim() || void 0;
|
|
1931
1939
|
}
|
|
1932
|
-
function
|
|
1933
|
-
let p = (e ??
|
|
1940
|
+
function Ut(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
1941
|
+
let p = (e ?? Vt()).replace(/\/$/, ""), m = p.endsWith("/embed") ? p : `${p}/embed`, h = new URL(m), g = n?.trim();
|
|
1934
1942
|
g && h.searchParams.set("backdropId", g);
|
|
1935
1943
|
let _ = r?.trim();
|
|
1936
1944
|
_ && h.searchParams.set("avatarId", _);
|
|
1937
1945
|
let v = d?.trim();
|
|
1938
1946
|
v && h.searchParams.set("previewBg", v);
|
|
1939
1947
|
let y = f?.trim();
|
|
1940
|
-
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)),
|
|
1948
|
+
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)), Wt(h.toString());
|
|
1941
1949
|
}
|
|
1942
|
-
function
|
|
1950
|
+
function Wt(e) {
|
|
1943
1951
|
if (typeof location > "u") return e;
|
|
1944
1952
|
let t = new URL(e);
|
|
1945
1953
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1946
1954
|
}
|
|
1947
|
-
function
|
|
1955
|
+
function Gt(e) {
|
|
1948
1956
|
return new URL(e).origin;
|
|
1949
1957
|
}
|
|
1950
1958
|
//#endregion
|
|
1951
1959
|
//#region src/v2/experienceEvents.ts
|
|
1952
|
-
function
|
|
1960
|
+
function Kt() {
|
|
1953
1961
|
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)}`;
|
|
1954
1962
|
}
|
|
1955
|
-
function
|
|
1963
|
+
function qt(e, t, n) {
|
|
1956
1964
|
return {
|
|
1957
|
-
id:
|
|
1965
|
+
id: Kt(),
|
|
1958
1966
|
type: e,
|
|
1959
1967
|
sessionId: t,
|
|
1960
1968
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1961
1969
|
data: n
|
|
1962
1970
|
};
|
|
1963
1971
|
}
|
|
1964
|
-
function
|
|
1972
|
+
function Jt() {
|
|
1965
1973
|
return {
|
|
1966
1974
|
ready: /* @__PURE__ */ new Set(),
|
|
1967
1975
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1982,39 +1990,39 @@ function Kt() {
|
|
|
1982
1990
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1983
1991
|
};
|
|
1984
1992
|
}
|
|
1985
|
-
function
|
|
1993
|
+
function Yt(e, t, n) {
|
|
1986
1994
|
return e[t].add(n), () => e[t].delete(n);
|
|
1987
1995
|
}
|
|
1988
|
-
function
|
|
1996
|
+
function Xt(e, t, n) {
|
|
1989
1997
|
for (let r of e[t]) r(n);
|
|
1990
1998
|
}
|
|
1991
|
-
function
|
|
1999
|
+
function Zt(e) {
|
|
1992
2000
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1993
2001
|
}
|
|
1994
2002
|
//#endregion
|
|
1995
2003
|
//#region src/v2/speech/types.ts
|
|
1996
|
-
function
|
|
2004
|
+
function Qt(e) {
|
|
1997
2005
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1998
2006
|
}
|
|
1999
|
-
function
|
|
2007
|
+
function $t(e) {
|
|
2000
2008
|
return "url" in e && typeof e.url == "string";
|
|
2001
2009
|
}
|
|
2002
|
-
function
|
|
2010
|
+
function en(e) {
|
|
2003
2011
|
if (!("track" in e)) return !1;
|
|
2004
2012
|
let t = e.track;
|
|
2005
2013
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
2006
2014
|
}
|
|
2007
|
-
function
|
|
2008
|
-
return !
|
|
2015
|
+
function tn(e) {
|
|
2016
|
+
return !Qt(e) && !$t(e) && !en(e) && "encoding" in e && typeof e.encoding == "string";
|
|
2009
2017
|
}
|
|
2010
|
-
var
|
|
2018
|
+
var nn = [
|
|
2011
2019
|
8e3,
|
|
2012
2020
|
16e3,
|
|
2013
2021
|
22050,
|
|
2014
2022
|
24e3,
|
|
2015
2023
|
44100,
|
|
2016
2024
|
48e3
|
|
2017
|
-
],
|
|
2025
|
+
], rn = {
|
|
2018
2026
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
2019
2027
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
2020
2028
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -2025,14 +2033,14 @@ var en = [
|
|
|
2025
2033
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
2026
2034
|
MAX_PENDING_WRITES: 8,
|
|
2027
2035
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
2028
|
-
},
|
|
2036
|
+
}, an = class extends Error {
|
|
2029
2037
|
operation;
|
|
2030
2038
|
requiredCapability;
|
|
2031
2039
|
name = "UnsupportedSpeechOperationError";
|
|
2032
2040
|
constructor(e, t) {
|
|
2033
2041
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
2034
2042
|
}
|
|
2035
|
-
},
|
|
2043
|
+
}, on = class extends Error {
|
|
2036
2044
|
name = "SpeechUtteranceClosedError";
|
|
2037
2045
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
2038
2046
|
super(e);
|
|
@@ -2042,72 +2050,72 @@ var en = [
|
|
|
2042
2050
|
constructor(e, t) {
|
|
2043
2051
|
super(e, t);
|
|
2044
2052
|
}
|
|
2045
|
-
},
|
|
2053
|
+
}, sn = class extends Error {
|
|
2046
2054
|
name = "SpeechBufferTimeoutError";
|
|
2047
2055
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
2048
2056
|
super(e);
|
|
2049
2057
|
}
|
|
2050
2058
|
};
|
|
2051
|
-
function
|
|
2059
|
+
function cn(e = "none") {
|
|
2052
2060
|
return {
|
|
2053
2061
|
mode: e,
|
|
2054
2062
|
trackedDurationMs: 0,
|
|
2055
2063
|
fallbackDurationMs: 0
|
|
2056
2064
|
};
|
|
2057
2065
|
}
|
|
2058
|
-
function
|
|
2059
|
-
return
|
|
2066
|
+
function ln(e) {
|
|
2067
|
+
return nn.includes(e);
|
|
2060
2068
|
}
|
|
2061
|
-
function
|
|
2069
|
+
function un(e) {
|
|
2062
2070
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
2063
2071
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
2064
|
-
if (!
|
|
2072
|
+
if (!ln(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2065
2073
|
}
|
|
2066
|
-
function
|
|
2067
|
-
if (
|
|
2068
|
-
|
|
2074
|
+
function dn(e) {
|
|
2075
|
+
if (Qt(e)) {
|
|
2076
|
+
un(e.format);
|
|
2069
2077
|
return;
|
|
2070
2078
|
}
|
|
2071
|
-
if (
|
|
2079
|
+
if ($t(e)) {
|
|
2072
2080
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
2073
|
-
if (e.sampleRate !== void 0 && !
|
|
2081
|
+
if (e.sampleRate !== void 0 && !ln(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2074
2082
|
return;
|
|
2075
2083
|
}
|
|
2076
|
-
if (
|
|
2084
|
+
if (en(e)) {
|
|
2077
2085
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2078
|
-
if (e.sampleRate !== void 0 && !
|
|
2086
|
+
if (e.sampleRate !== void 0 && !ln(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2079
2087
|
return;
|
|
2080
2088
|
}
|
|
2081
|
-
if (
|
|
2089
|
+
if (tn(e)) {
|
|
2082
2090
|
let t = e.encoding.trim().toLowerCase();
|
|
2083
2091
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2084
2092
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2085
|
-
if (e.sampleRate !== void 0 && !
|
|
2093
|
+
if (e.sampleRate !== void 0 && !ln(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2086
2094
|
return;
|
|
2087
2095
|
}
|
|
2088
2096
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2089
2097
|
}
|
|
2090
|
-
function
|
|
2091
|
-
if (e.format) return
|
|
2098
|
+
function fn(e) {
|
|
2099
|
+
if (e.format) return un(e.format), e.format;
|
|
2092
2100
|
if (e.track) {
|
|
2093
2101
|
let t = {
|
|
2094
2102
|
encoding: "pcm_s16le",
|
|
2095
2103
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2096
2104
|
channels: 1
|
|
2097
2105
|
};
|
|
2098
|
-
return
|
|
2106
|
+
return un(t), t;
|
|
2099
2107
|
}
|
|
2100
2108
|
throw new Q("createUtterance requires format or track.");
|
|
2101
2109
|
}
|
|
2102
|
-
function
|
|
2110
|
+
function pn(e) {
|
|
2103
2111
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2104
2112
|
}
|
|
2105
|
-
function
|
|
2113
|
+
function mn(e) {
|
|
2106
2114
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2107
2115
|
}
|
|
2108
2116
|
//#endregion
|
|
2109
2117
|
//#region src/byo/pcm.ts
|
|
2110
|
-
function
|
|
2118
|
+
function hn(e) {
|
|
2111
2119
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2112
2120
|
for (let t = 0; t < e.length; t++) {
|
|
2113
2121
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2117,11 +2125,11 @@ function pn(e) {
|
|
|
2117
2125
|
}
|
|
2118
2126
|
//#endregion
|
|
2119
2127
|
//#region src/byo/resample.ts
|
|
2120
|
-
function
|
|
2128
|
+
function gn(e, t, n, r, i) {
|
|
2121
2129
|
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;
|
|
2122
2130
|
return ((a * i + o) * i + s) * i + c;
|
|
2123
2131
|
}
|
|
2124
|
-
function
|
|
2132
|
+
function _n(e, t) {
|
|
2125
2133
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2126
2134
|
if (e === t) return {
|
|
2127
2135
|
fromRate: e,
|
|
@@ -2144,7 +2152,7 @@ function hn(e, t) {
|
|
|
2144
2152
|
let a = [];
|
|
2145
2153
|
for (; i + 2 < r.length - 1;) {
|
|
2146
2154
|
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);
|
|
2147
|
-
a.push(
|
|
2155
|
+
a.push(gn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2148
2156
|
}
|
|
2149
2157
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2150
2158
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2156,7 +2164,7 @@ function hn(e, t) {
|
|
|
2156
2164
|
}
|
|
2157
2165
|
//#endregion
|
|
2158
2166
|
//#region src/byo/audioCapture.ts
|
|
2159
|
-
var
|
|
2167
|
+
var vn = "liforma-pcm-capture", yn = `
|
|
2160
2168
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2161
2169
|
process(inputs) {
|
|
2162
2170
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2168,29 +2176,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2168
2176
|
return true;
|
|
2169
2177
|
}
|
|
2170
2178
|
}
|
|
2171
|
-
registerProcessor('${
|
|
2172
|
-
`,
|
|
2173
|
-
function
|
|
2174
|
-
return
|
|
2179
|
+
registerProcessor('${vn}', LiformaPcmCaptureProcessor);
|
|
2180
|
+
`, bn = null;
|
|
2181
|
+
function xn() {
|
|
2182
|
+
return bn ||= URL.createObjectURL(new Blob([yn], { type: "application/javascript" })), bn;
|
|
2175
2183
|
}
|
|
2176
|
-
function
|
|
2184
|
+
function Sn() {
|
|
2177
2185
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2178
2186
|
}
|
|
2179
|
-
async function
|
|
2180
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2187
|
+
async function Cn(e) {
|
|
2188
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Sn();
|
|
2181
2189
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2182
2190
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2183
2191
|
l.gain.value = 0;
|
|
2184
|
-
let u = s.sampleRate, d =
|
|
2192
|
+
let u = s.sampleRate, d = _n(u, n), f = !1, p = !1, m = (e) => {
|
|
2185
2193
|
if (f || i && !i()) return;
|
|
2186
2194
|
let t = d.push(e);
|
|
2187
|
-
t.length !== 0 && r(
|
|
2195
|
+
t.length !== 0 && r(hn(t));
|
|
2188
2196
|
}, h = () => void 0;
|
|
2189
2197
|
return await (async () => {
|
|
2190
2198
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2191
2199
|
try {
|
|
2192
|
-
await s.audioWorklet.addModule(
|
|
2193
|
-
let e = new AudioWorkletNode(s,
|
|
2200
|
+
await s.audioWorklet.addModule(xn());
|
|
2201
|
+
let e = new AudioWorkletNode(s, vn, {
|
|
2194
2202
|
numberOfInputs: 1,
|
|
2195
2203
|
numberOfOutputs: 1,
|
|
2196
2204
|
outputChannelCount: [1]
|
|
@@ -2240,7 +2248,7 @@ async function xn(e) {
|
|
|
2240
2248
|
}
|
|
2241
2249
|
//#endregion
|
|
2242
2250
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2243
|
-
async function
|
|
2251
|
+
async function wn(e) {
|
|
2244
2252
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2245
2253
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2246
2254
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2249,18 +2257,18 @@ async function Sn(e) {
|
|
|
2249
2257
|
s || (s = !0, c?.stop(), c = null);
|
|
2250
2258
|
};
|
|
2251
2259
|
try {
|
|
2252
|
-
c = await
|
|
2260
|
+
c = await Cn({
|
|
2253
2261
|
mediaStream: a,
|
|
2254
2262
|
targetSampleRate: r,
|
|
2255
2263
|
shouldSend: () => !s && !i?.aborted,
|
|
2256
2264
|
onPcm: (e) => {
|
|
2257
2265
|
if (s || i?.aborted) return;
|
|
2258
|
-
let t =
|
|
2266
|
+
let t = pn(e);
|
|
2259
2267
|
o = o.then(async () => {
|
|
2260
2268
|
if (s || i?.aborted) return;
|
|
2261
2269
|
let e = 0;
|
|
2262
2270
|
for (; e < t.byteLength;) {
|
|
2263
|
-
let r = Math.min(e +
|
|
2271
|
+
let r = Math.min(e + rn.MAX_CHUNK_BYTES, t.byteLength);
|
|
2264
2272
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2265
2273
|
let i = t.subarray(e, r);
|
|
2266
2274
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2284,10 +2292,10 @@ async function Sn(e) {
|
|
|
2284
2292
|
}
|
|
2285
2293
|
//#endregion
|
|
2286
2294
|
//#region src/v2/speech/speechController.ts
|
|
2287
|
-
async function
|
|
2288
|
-
if (
|
|
2289
|
-
if (
|
|
2290
|
-
let t =
|
|
2295
|
+
async function Tn(e, t) {
|
|
2296
|
+
if (en(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2297
|
+
if (Qt(e)) {
|
|
2298
|
+
let t = pn(e.data);
|
|
2291
2299
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2292
2300
|
return {
|
|
2293
2301
|
kind: "pcm",
|
|
@@ -2295,17 +2303,17 @@ async function Cn(e, t) {
|
|
|
2295
2303
|
format: e.format
|
|
2296
2304
|
};
|
|
2297
2305
|
}
|
|
2298
|
-
if (
|
|
2306
|
+
if ($t(e)) return {
|
|
2299
2307
|
kind: "url",
|
|
2300
2308
|
url: e.url.trim(),
|
|
2301
2309
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2302
2310
|
};
|
|
2303
|
-
if (
|
|
2311
|
+
if (!tn(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2304
2312
|
let n;
|
|
2305
2313
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2306
2314
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2307
2315
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2308
|
-
} else n =
|
|
2316
|
+
} else n = pn(e.data);
|
|
2309
2317
|
return {
|
|
2310
2318
|
kind: "encoded",
|
|
2311
2319
|
data: n.slice().buffer,
|
|
@@ -2313,10 +2321,10 @@ async function Cn(e, t) {
|
|
|
2313
2321
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2314
2322
|
};
|
|
2315
2323
|
}
|
|
2316
|
-
function
|
|
2324
|
+
function En() {
|
|
2317
2325
|
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)}`;
|
|
2318
2326
|
}
|
|
2319
|
-
function
|
|
2327
|
+
function Dn(e, t = "completed") {
|
|
2320
2328
|
return {
|
|
2321
2329
|
utteranceId: e.speechId,
|
|
2322
2330
|
characterId: e.characterId,
|
|
@@ -2330,13 +2338,13 @@ function Tn(e, t = "completed") {
|
|
|
2330
2338
|
}
|
|
2331
2339
|
};
|
|
2332
2340
|
}
|
|
2333
|
-
function
|
|
2341
|
+
function On(e) {
|
|
2334
2342
|
return e instanceof Error ? e : new Q(String(e));
|
|
2335
2343
|
}
|
|
2336
|
-
function
|
|
2344
|
+
function kn(e) {
|
|
2337
2345
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2338
2346
|
}
|
|
2339
|
-
var
|
|
2347
|
+
var An = class {
|
|
2340
2348
|
id;
|
|
2341
2349
|
characterId;
|
|
2342
2350
|
result;
|
|
@@ -2365,29 +2373,29 @@ var On = class {
|
|
|
2365
2373
|
queue: e.queue,
|
|
2366
2374
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2367
2375
|
}).catch((e) => {
|
|
2368
|
-
throw this.fail(
|
|
2376
|
+
throw this.fail(On(e)), On(e);
|
|
2369
2377
|
}), this.signal?.addEventListener("abort", () => {
|
|
2370
2378
|
this.cancel();
|
|
2371
2379
|
}, { once: !0 });
|
|
2372
2380
|
}
|
|
2373
2381
|
async write(e, t) {
|
|
2374
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2375
|
-
let n =
|
|
2382
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new on();
|
|
2383
|
+
let n = pn(e);
|
|
2376
2384
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2377
|
-
if (n.byteLength >
|
|
2385
|
+
if (n.byteLength > rn.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${rn.MAX_CHUNK_BYTES}).`);
|
|
2378
2386
|
if (n.byteLength === 0) return;
|
|
2379
|
-
let r = t?.timeoutMs ??
|
|
2387
|
+
let r = t?.timeoutMs ?? rn.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2380
2388
|
await this.acquireWriteSlot(r);
|
|
2381
2389
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2382
|
-
if (this.bufferedMs + i >
|
|
2390
|
+
if (this.bufferedMs + i > rn.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2383
2391
|
let a = async () => {
|
|
2384
|
-
if (this.closed || this.settled) throw new
|
|
2392
|
+
if (this.closed || this.settled) throw new on();
|
|
2385
2393
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2386
2394
|
utteranceId: this.id,
|
|
2387
2395
|
audio: t.buffer,
|
|
2388
2396
|
byteLength: t.byteLength
|
|
2389
2397
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2390
|
-
setTimeout(() => t(new
|
|
2398
|
+
setTimeout(() => t(new sn()), r);
|
|
2391
2399
|
})]);
|
|
2392
2400
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2393
2401
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2399,7 +2407,7 @@ var On = class {
|
|
|
2399
2407
|
}
|
|
2400
2408
|
}
|
|
2401
2409
|
async setTranscript(e) {
|
|
2402
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2410
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new on();
|
|
2403
2411
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2404
2412
|
utteranceId: this.id,
|
|
2405
2413
|
transcript: e
|
|
@@ -2416,7 +2424,7 @@ var On = class {
|
|
|
2416
2424
|
});
|
|
2417
2425
|
return this.resolve(t), t;
|
|
2418
2426
|
} catch (e) {
|
|
2419
|
-
let t =
|
|
2427
|
+
let t = On(e);
|
|
2420
2428
|
throw this.fail(t), t;
|
|
2421
2429
|
}
|
|
2422
2430
|
}
|
|
@@ -2434,11 +2442,11 @@ var On = class {
|
|
|
2434
2442
|
characterId: this.characterId,
|
|
2435
2443
|
status: "cancelled",
|
|
2436
2444
|
durationMs: 0,
|
|
2437
|
-
animation:
|
|
2445
|
+
animation: cn("none")
|
|
2438
2446
|
};
|
|
2439
2447
|
return this.resolve(t), t;
|
|
2440
2448
|
} catch (e) {
|
|
2441
|
-
let t =
|
|
2449
|
+
let t = On(e);
|
|
2442
2450
|
throw this.fail(t), t;
|
|
2443
2451
|
}
|
|
2444
2452
|
}
|
|
@@ -2451,19 +2459,19 @@ var On = class {
|
|
|
2451
2459
|
return e;
|
|
2452
2460
|
}
|
|
2453
2461
|
resolve(e) {
|
|
2454
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2462
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new on()));
|
|
2455
2463
|
}
|
|
2456
2464
|
fail(e) {
|
|
2457
2465
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2458
2466
|
}
|
|
2459
2467
|
async acquireWriteSlot(e) {
|
|
2460
|
-
if (this.pendingWriteCount <
|
|
2468
|
+
if (this.pendingWriteCount < rn.MAX_PENDING_WRITES) {
|
|
2461
2469
|
this.pendingWriteCount += 1;
|
|
2462
2470
|
return;
|
|
2463
2471
|
}
|
|
2464
2472
|
await new Promise((t, n) => {
|
|
2465
2473
|
let r = setTimeout(() => {
|
|
2466
|
-
n(new
|
|
2474
|
+
n(new sn());
|
|
2467
2475
|
}, e);
|
|
2468
2476
|
this.pendingWriteWaiters.push({
|
|
2469
2477
|
resolve: () => {
|
|
@@ -2482,13 +2490,13 @@ var On = class {
|
|
|
2482
2490
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2483
2491
|
}
|
|
2484
2492
|
};
|
|
2485
|
-
function
|
|
2493
|
+
function jn(e) {
|
|
2486
2494
|
let t = null, n = (t, n) => {
|
|
2487
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2495
|
+
if (!e.getCapabilities()[n]) throw new an(t, n);
|
|
2488
2496
|
}, r = {
|
|
2489
2497
|
async speak(r) {
|
|
2490
2498
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2491
|
-
let i =
|
|
2499
|
+
let i = mn(r.queue ?? "append");
|
|
2492
2500
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2493
2501
|
let a = e.getIframeHost();
|
|
2494
2502
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2508,41 +2516,41 @@ function kn(e) {
|
|
|
2508
2516
|
return;
|
|
2509
2517
|
}
|
|
2510
2518
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2511
|
-
t.removeEventListener("abort", s), n(
|
|
2519
|
+
t.removeEventListener("abort", s), n(Dn(e, "completed"));
|
|
2512
2520
|
}, (a) => {
|
|
2513
|
-
if (t.removeEventListener("abort", s),
|
|
2521
|
+
if (t.removeEventListener("abort", s), kn(a)) {
|
|
2514
2522
|
n({
|
|
2515
2523
|
utteranceId: "utt_interrupted",
|
|
2516
2524
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2517
2525
|
status: "interrupted",
|
|
2518
2526
|
durationMs: 0,
|
|
2519
2527
|
transcript: r.text,
|
|
2520
|
-
animation:
|
|
2528
|
+
animation: cn("none")
|
|
2521
2529
|
});
|
|
2522
2530
|
return;
|
|
2523
2531
|
}
|
|
2524
|
-
i(
|
|
2532
|
+
i(On(a));
|
|
2525
2533
|
});
|
|
2526
2534
|
});
|
|
2527
2535
|
}
|
|
2528
2536
|
try {
|
|
2529
|
-
return
|
|
2537
|
+
return Dn(await o, "completed");
|
|
2530
2538
|
} catch (t) {
|
|
2531
|
-
if (
|
|
2539
|
+
if (kn(t)) return {
|
|
2532
2540
|
utteranceId: "utt_interrupted",
|
|
2533
2541
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2534
2542
|
status: "interrupted",
|
|
2535
2543
|
durationMs: 0,
|
|
2536
2544
|
transcript: r.text,
|
|
2537
|
-
animation:
|
|
2545
|
+
animation: cn("none")
|
|
2538
2546
|
};
|
|
2539
|
-
throw
|
|
2547
|
+
throw On(t);
|
|
2540
2548
|
}
|
|
2541
2549
|
},
|
|
2542
2550
|
async play(i) {
|
|
2543
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2551
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), dn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2544
2552
|
let a = i.queue ?? "append";
|
|
2545
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2553
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), en(i.audio)) {
|
|
2546
2554
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2547
2555
|
return r.createUtterance({
|
|
2548
2556
|
format: {
|
|
@@ -2558,7 +2566,7 @@ function kn(e) {
|
|
|
2558
2566
|
}
|
|
2559
2567
|
let o = e.getIframeHost();
|
|
2560
2568
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2561
|
-
let s = await
|
|
2569
|
+
let s = await Tn(i.audio, i.signal);
|
|
2562
2570
|
return o.speechPlay({
|
|
2563
2571
|
source: s,
|
|
2564
2572
|
characterId: i.characterId,
|
|
@@ -2570,13 +2578,13 @@ function kn(e) {
|
|
|
2570
2578
|
},
|
|
2571
2579
|
createUtterance(r) {
|
|
2572
2580
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2573
|
-
let i =
|
|
2581
|
+
let i = fn(r);
|
|
2574
2582
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2575
2583
|
let a = r.queue ?? "replace-active";
|
|
2576
2584
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2577
2585
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2578
|
-
let o = new
|
|
2579
|
-
id:
|
|
2586
|
+
let o = new An({
|
|
2587
|
+
id: En(),
|
|
2580
2588
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2581
2589
|
format: i,
|
|
2582
2590
|
queue: a,
|
|
@@ -2588,7 +2596,7 @@ function kn(e) {
|
|
|
2588
2596
|
t === o && (t = null);
|
|
2589
2597
|
}), r.track && (async () => {
|
|
2590
2598
|
try {
|
|
2591
|
-
if (await
|
|
2599
|
+
if (await wn({
|
|
2592
2600
|
track: r.track,
|
|
2593
2601
|
utterance: o,
|
|
2594
2602
|
sampleRate: i.sampleRate,
|
|
@@ -2616,16 +2624,16 @@ function kn(e) {
|
|
|
2616
2624
|
}
|
|
2617
2625
|
//#endregion
|
|
2618
2626
|
//#region src/v2/types/sessionInteraction.ts
|
|
2619
|
-
function
|
|
2627
|
+
function Mn(e) {
|
|
2620
2628
|
let t = e?.trim();
|
|
2621
2629
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2622
2630
|
}
|
|
2623
2631
|
//#endregion
|
|
2624
2632
|
//#region src/v2/experience.ts
|
|
2625
|
-
function
|
|
2633
|
+
function Nn(e) {
|
|
2626
2634
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2627
2635
|
}
|
|
2628
|
-
var
|
|
2636
|
+
var Pn = class e {
|
|
2629
2637
|
bootstrap;
|
|
2630
2638
|
conversationProcessor;
|
|
2631
2639
|
iframeHost = null;
|
|
@@ -2645,17 +2653,17 @@ var Mn = class e {
|
|
|
2645
2653
|
pendingTheatre = null;
|
|
2646
2654
|
lastInteraction = null;
|
|
2647
2655
|
closeHandlers = [];
|
|
2648
|
-
eventRegistry =
|
|
2656
|
+
eventRegistry = Jt();
|
|
2649
2657
|
readyEnvelope = null;
|
|
2650
2658
|
startedEnvelope = null;
|
|
2651
2659
|
sessionMintedEnvelope = null;
|
|
2652
2660
|
conversationCache = [];
|
|
2653
2661
|
speech;
|
|
2654
2662
|
constructor(e) {
|
|
2655
|
-
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 =
|
|
2663
|
+
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 = jn({
|
|
2656
2664
|
getIframeHost: () => this.iframeHost,
|
|
2657
2665
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2658
|
-
getCapabilities: () =>
|
|
2666
|
+
getCapabilities: () => Fn(this.resolvedSession),
|
|
2659
2667
|
getActiveCharacterId: () => "character_unknown",
|
|
2660
2668
|
onProcessorInterrupt: () => {
|
|
2661
2669
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2744,7 +2752,7 @@ var Mn = class e {
|
|
|
2744
2752
|
return null;
|
|
2745
2753
|
}
|
|
2746
2754
|
on(e, t) {
|
|
2747
|
-
let n =
|
|
2755
|
+
let n = Yt(this.eventRegistry, e, t);
|
|
2748
2756
|
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;
|
|
2749
2757
|
}
|
|
2750
2758
|
async attach(e) {
|
|
@@ -2758,13 +2766,13 @@ var Mn = class e {
|
|
|
2758
2766
|
if (this.closed) throw Error("Session has ended.");
|
|
2759
2767
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2760
2768
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2761
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2769
|
+
let t = this.bootstrap.embedBaseUrl ?? Vt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Ut(t, n, r ? void 0 : Ht(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Nn(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 = Gt(i), o = null, s = new Promise((e) => {
|
|
2762
2770
|
o = e;
|
|
2763
2771
|
}), c = null, l = new Promise((e) => {
|
|
2764
2772
|
c = e;
|
|
2765
|
-
}), u =
|
|
2773
|
+
}), u = It((e) => {
|
|
2766
2774
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2767
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2775
|
+
}), d = this.bootstrap.onUserTranscript, f = Ft({
|
|
2768
2776
|
container: e.container,
|
|
2769
2777
|
src: i,
|
|
2770
2778
|
playerOrigin: a,
|
|
@@ -2831,7 +2839,7 @@ var Mn = class e {
|
|
|
2831
2839
|
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
2832
2840
|
});
|
|
2833
2841
|
this.iframeHost = f;
|
|
2834
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2842
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), dt(this.bootstrap.sessionEndpoint, {
|
|
2835
2843
|
experienceId: this.bootstrap.experienceId,
|
|
2836
2844
|
locale: this.bootstrap.locale,
|
|
2837
2845
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2843,7 +2851,7 @@ var Mn = class e {
|
|
|
2843
2851
|
attribution: this.bootstrap.attribution,
|
|
2844
2852
|
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
2845
2853
|
signal: this.endpointAbortController.signal
|
|
2846
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2854
|
+
})) : this.bootstrap.kind === "public" ? ut(this.bootstrap.experienceId, {
|
|
2847
2855
|
locale: this.bootstrap.locale,
|
|
2848
2856
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2849
2857
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2867,7 +2875,7 @@ var Mn = class e {
|
|
|
2867
2875
|
operation: "attach",
|
|
2868
2876
|
message: e instanceof Error ? e.message : String(e),
|
|
2869
2877
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2870
|
-
release:
|
|
2878
|
+
release: Lt
|
|
2871
2879
|
});
|
|
2872
2880
|
} catch {}
|
|
2873
2881
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -2879,19 +2887,23 @@ var Mn = class e {
|
|
|
2879
2887
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2880
2888
|
this.launchToken = g;
|
|
2881
2889
|
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2882
|
-
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2890
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && nt(_), f.postLaunch(g, _, {
|
|
2883
2891
|
startButton: e.startButton,
|
|
2884
2892
|
theme: e.theme,
|
|
2885
2893
|
showFeedback: e.showFeedback,
|
|
2886
2894
|
interaction: e.interaction,
|
|
2887
|
-
...e.
|
|
2895
|
+
...Ye("settingsButton", e.settingsButton),
|
|
2896
|
+
...Ye("theatreButton", e.theatreButton),
|
|
2897
|
+
...Ye("fullscreenButton", e.fullscreenButton),
|
|
2888
2898
|
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2889
2899
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2890
2900
|
startButton: e.startButton,
|
|
2891
2901
|
theme: e.theme,
|
|
2892
2902
|
showFeedback: e.showFeedback,
|
|
2893
2903
|
interaction: e.interaction,
|
|
2894
|
-
...e.
|
|
2904
|
+
...Ye("settingsButton", e.settingsButton),
|
|
2905
|
+
...Ye("theatreButton", e.theatreButton),
|
|
2906
|
+
...Ye("fullscreenButton", e.fullscreenButton),
|
|
2895
2907
|
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2896
2908
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2897
2909
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
@@ -2903,7 +2915,7 @@ var Mn = class e {
|
|
|
2903
2915
|
operation: "attach",
|
|
2904
2916
|
message: e instanceof Error ? e.message : String(e),
|
|
2905
2917
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2906
|
-
release:
|
|
2918
|
+
release: Lt
|
|
2907
2919
|
});
|
|
2908
2920
|
} catch {}
|
|
2909
2921
|
throw e;
|
|
@@ -2917,7 +2929,7 @@ var Mn = class e {
|
|
|
2917
2929
|
operation: "attach",
|
|
2918
2930
|
message: e instanceof Error ? e.message : String(e),
|
|
2919
2931
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2920
|
-
release:
|
|
2932
|
+
release: Lt
|
|
2921
2933
|
});
|
|
2922
2934
|
} catch {}
|
|
2923
2935
|
throw e;
|
|
@@ -2949,7 +2961,7 @@ var Mn = class e {
|
|
|
2949
2961
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2950
2962
|
}
|
|
2951
2963
|
async setFit(e) {
|
|
2952
|
-
let t =
|
|
2964
|
+
let t = Mn(e);
|
|
2953
2965
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2954
2966
|
if (this.closed) throw Error("Session has ended.");
|
|
2955
2967
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2999,7 +3011,7 @@ var Mn = class e {
|
|
|
2999
3011
|
this.close();
|
|
3000
3012
|
}
|
|
3001
3013
|
destroy() {
|
|
3002
|
-
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,
|
|
3014
|
+
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, Zt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
3003
3015
|
}
|
|
3004
3016
|
resolveMintInteraction() {
|
|
3005
3017
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -3011,8 +3023,8 @@ var Mn = class e {
|
|
|
3011
3023
|
return this.resolvedSession?.id ?? "";
|
|
3012
3024
|
}
|
|
3013
3025
|
emitWrapped(e, t) {
|
|
3014
|
-
let n =
|
|
3015
|
-
return
|
|
3026
|
+
let n = qt(e, this.getSessionId(), t);
|
|
3027
|
+
return Xt(this.eventRegistry, e, n), n;
|
|
3016
3028
|
}
|
|
3017
3029
|
queueProcessorTurn(e) {
|
|
3018
3030
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -3021,7 +3033,7 @@ var Mn = class e {
|
|
|
3021
3033
|
let n = this.processorAbortController.signal;
|
|
3022
3034
|
this.processorChain = this.processorChain.then(async () => {
|
|
3023
3035
|
if (!n.aborted) try {
|
|
3024
|
-
let r = await
|
|
3036
|
+
let r = await mt(t, {
|
|
3025
3037
|
utteranceId: e.utteranceId,
|
|
3026
3038
|
text: e.text,
|
|
3027
3039
|
conversation: this.conversationCache,
|
|
@@ -3071,7 +3083,7 @@ var Mn = class e {
|
|
|
3071
3083
|
};
|
|
3072
3084
|
}
|
|
3073
3085
|
};
|
|
3074
|
-
function
|
|
3086
|
+
function Fn(e) {
|
|
3075
3087
|
return e ? {
|
|
3076
3088
|
textSpeech: e.capabilities.speech.output,
|
|
3077
3089
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -3082,41 +3094,41 @@ function Nn(e) {
|
|
|
3082
3094
|
}
|
|
3083
3095
|
//#endregion
|
|
3084
3096
|
//#region src/widget/dockGeometry.ts
|
|
3085
|
-
var
|
|
3086
|
-
function
|
|
3097
|
+
var In = "(min-width: 768px)", Ln = 24, Rn = .5, zn = 1200, Bn = .85, Vn = 9 / 16;
|
|
3098
|
+
function Hn() {
|
|
3087
3099
|
if (typeof window > "u") return 800;
|
|
3088
3100
|
let e = window.screen?.availHeight;
|
|
3089
3101
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
3090
3102
|
}
|
|
3091
|
-
function
|
|
3092
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
3093
|
-
return s > a && (s = a, o = s /
|
|
3103
|
+
function Un(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Ln, r = typeof window < "u" ? Hn() : 800) {
|
|
3104
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Bn)), a = Math.max(120, e - n * 2), o = Math.min(r * Rn, zn, i), s = o * Vn;
|
|
3105
|
+
return s > a && (s = a, o = s / Vn, o > i && (o = i, s = o * Vn)), {
|
|
3094
3106
|
width: Math.round(s),
|
|
3095
3107
|
height: Math.round(o)
|
|
3096
3108
|
};
|
|
3097
3109
|
}
|
|
3098
|
-
function
|
|
3110
|
+
function Wn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Ln) {
|
|
3099
3111
|
return {
|
|
3100
3112
|
left: Math.max(r, t - e.width - r),
|
|
3101
3113
|
top: Math.max(r, n - e.height - r)
|
|
3102
3114
|
};
|
|
3103
3115
|
}
|
|
3104
|
-
function
|
|
3116
|
+
function Gn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Ln) {
|
|
3105
3117
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3106
3118
|
return {
|
|
3107
3119
|
left: Math.min(Math.max(a, e), o),
|
|
3108
3120
|
top: Math.min(Math.max(a, t), s)
|
|
3109
3121
|
};
|
|
3110
3122
|
}
|
|
3111
|
-
function
|
|
3112
|
-
return e(
|
|
3123
|
+
function Kn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3124
|
+
return e(In).matches;
|
|
3113
3125
|
}
|
|
3114
3126
|
//#endregion
|
|
3115
3127
|
//#region src/widget/mountExperienceWidget.ts
|
|
3116
|
-
function
|
|
3128
|
+
function qn(e) {
|
|
3117
3129
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3118
3130
|
}
|
|
3119
|
-
function
|
|
3131
|
+
function Jn(e) {
|
|
3120
3132
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3121
3133
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3122
3134
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3124,8 +3136,8 @@ function Kn(e) {
|
|
|
3124
3136
|
function $(e) {
|
|
3125
3137
|
return e === "expanded" || e === "docked";
|
|
3126
3138
|
}
|
|
3127
|
-
var
|
|
3128
|
-
function
|
|
3139
|
+
var Yn = "<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>", Zn = "<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>", Qn = "<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>";
|
|
3140
|
+
function $n(e, t, n) {
|
|
3129
3141
|
xe(ye);
|
|
3130
3142
|
let r = F({
|
|
3131
3143
|
galleryThumb: t.galleryThumb,
|
|
@@ -3155,7 +3167,7 @@ function Zn(e, t, n) {
|
|
|
3155
3167
|
}
|
|
3156
3168
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ve(i);
|
|
3157
3169
|
}
|
|
3158
|
-
function
|
|
3170
|
+
function er(e) {
|
|
3159
3171
|
return e.startButton ? {
|
|
3160
3172
|
...e.startButton,
|
|
3161
3173
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3167,7 +3179,7 @@ function Qn(e) {
|
|
|
3167
3179
|
variant: "primary"
|
|
3168
3180
|
};
|
|
3169
3181
|
}
|
|
3170
|
-
function
|
|
3182
|
+
function tr(e) {
|
|
3171
3183
|
let t = !1, n = () => {
|
|
3172
3184
|
t || e();
|
|
3173
3185
|
}, r = () => {
|
|
@@ -3187,12 +3199,12 @@ function $n(e) {
|
|
|
3187
3199
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3188
3200
|
};
|
|
3189
3201
|
}
|
|
3190
|
-
function
|
|
3202
|
+
function nr(e, t) {
|
|
3191
3203
|
Pe(Me);
|
|
3192
3204
|
let n = t.experienceId?.trim();
|
|
3193
3205
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3194
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3195
|
-
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",
|
|
3206
|
+
let r = t.prefetch ?? "onExpand", i = qn(t.position), a = document.createElement("div");
|
|
3207
|
+
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", Jn(t.offset));
|
|
3196
3208
|
let o = document.createElement("button");
|
|
3197
3209
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3198
3210
|
let s = document.createElement("div");
|
|
@@ -3212,11 +3224,11 @@ function er(e, t) {
|
|
|
3212
3224
|
let m = document.createElement("span");
|
|
3213
3225
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3214
3226
|
let h = document.createElement("button");
|
|
3215
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3227
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Zn, h.setAttribute("aria-label", "Reduce");
|
|
3216
3228
|
let g = document.createElement("button");
|
|
3217
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3229
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Yn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3218
3230
|
let _ = document.createElement("button");
|
|
3219
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3231
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Xn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3220
3232
|
let v = document.createElement("div");
|
|
3221
3233
|
v.className = "liforma-ew__stage";
|
|
3222
3234
|
let y = document.createElement("div");
|
|
@@ -3244,11 +3256,11 @@ function er(e, t) {
|
|
|
3244
3256
|
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";
|
|
3245
3257
|
}, se = (e, t) => {
|
|
3246
3258
|
if (R() !== "docked") return;
|
|
3247
|
-
let n =
|
|
3259
|
+
let n = Un(), r = Gn(e - te, t - I, n);
|
|
3248
3260
|
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
3249
3261
|
}, ce = (e, t) => {
|
|
3250
3262
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3251
|
-
let n =
|
|
3263
|
+
let n = Un(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Gn(r + e, i + t, n);
|
|
3252
3264
|
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
3253
3265
|
}, le = (e) => {
|
|
3254
3266
|
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
@@ -3257,12 +3269,12 @@ function er(e, t) {
|
|
|
3257
3269
|
let t = L;
|
|
3258
3270
|
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && ne && (ne = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
3259
3271
|
}, ue = (e, t, n) => {
|
|
3260
|
-
if (S || R() !== "docked" || !
|
|
3272
|
+
if (S || R() !== "docked" || !Kn() || F !== null) return;
|
|
3261
3273
|
F = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3262
3274
|
let r = f.getBoundingClientRect();
|
|
3263
3275
|
te = e - r.left, I = t - r.top, ne || (ne = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3264
3276
|
}, de = (e) => {
|
|
3265
|
-
if (S || R() !== "docked" || !
|
|
3277
|
+
if (S || R() !== "docked" || !Kn() || F !== null) return;
|
|
3266
3278
|
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3267
3279
|
let t = f.getBoundingClientRect();
|
|
3268
3280
|
N = t.left, P = t.top;
|
|
@@ -3271,15 +3283,15 @@ function er(e, t) {
|
|
|
3271
3283
|
}, pe = (e) => {
|
|
3272
3284
|
L === "player" && (F === null || e.pointerId !== F || V());
|
|
3273
3285
|
}, H = () => {
|
|
3274
|
-
let e =
|
|
3286
|
+
let e = Kn(), t = R();
|
|
3275
3287
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3276
3288
|
h.hidden = !0;
|
|
3277
3289
|
return;
|
|
3278
3290
|
}
|
|
3279
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3291
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Qn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Zn, h.setAttribute("aria-label", "Reduce"));
|
|
3280
3292
|
}, me = (e) => {
|
|
3281
|
-
let t =
|
|
3282
|
-
n =
|
|
3293
|
+
let t = Un(), n = e && N !== null && P !== null ? Gn(N, P, t) : Wn(t);
|
|
3294
|
+
n = Gn(n.left, n.top, t), N = n.left, P = n.top, oe(n.left, n.top, t.width, t.height), H();
|
|
3283
3295
|
}, U = () => {
|
|
3284
3296
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3285
3297
|
requestAnimationFrame(() => {
|
|
@@ -3326,7 +3338,7 @@ function er(e, t) {
|
|
|
3326
3338
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3327
3339
|
}, ye = (e) => {
|
|
3328
3340
|
A?.(), A = null;
|
|
3329
|
-
let t =
|
|
3341
|
+
let t = $n(s, e, { parallax: ie });
|
|
3330
3342
|
return t ? (A = t, !0) : !1;
|
|
3331
3343
|
}, be = () => {
|
|
3332
3344
|
if (ye(G)) {
|
|
@@ -3358,7 +3370,7 @@ function er(e, t) {
|
|
|
3358
3370
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3359
3371
|
}), Se = () => ({
|
|
3360
3372
|
...t.fit ? { fit: t.fit } : {},
|
|
3361
|
-
startButton:
|
|
3373
|
+
startButton: er(t),
|
|
3362
3374
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3363
3375
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3364
3376
|
}), Ce = (e = !0) => {
|
|
@@ -3391,7 +3403,7 @@ function er(e, t) {
|
|
|
3391
3403
|
De(), Ee(), t.onCollapsed?.(), t.onClose?.();
|
|
3392
3404
|
}
|
|
3393
3405
|
}, ke = () => {
|
|
3394
|
-
S ||
|
|
3406
|
+
S || Kn() && R() === "expanded" && W(() => {
|
|
3395
3407
|
we();
|
|
3396
3408
|
});
|
|
3397
3409
|
}, Ae = () => {
|
|
@@ -3410,7 +3422,7 @@ function er(e, t) {
|
|
|
3410
3422
|
let e = O;
|
|
3411
3423
|
l.hidden = !1, (async () => {
|
|
3412
3424
|
try {
|
|
3413
|
-
let t = await
|
|
3425
|
+
let t = await Pn.startSession(xe());
|
|
3414
3426
|
if (S || e !== O) {
|
|
3415
3427
|
t.destroy();
|
|
3416
3428
|
return;
|
|
@@ -3469,7 +3481,7 @@ function er(e, t) {
|
|
|
3469
3481
|
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 () => {
|
|
3470
3482
|
try {
|
|
3471
3483
|
Ce();
|
|
3472
|
-
let t = await
|
|
3484
|
+
let t = await Pn.startSession(xe());
|
|
3473
3485
|
if (S || e !== O) {
|
|
3474
3486
|
t.destroy();
|
|
3475
3487
|
return;
|
|
@@ -3536,13 +3548,13 @@ function er(e, t) {
|
|
|
3536
3548
|
}, Be = (e) => {
|
|
3537
3549
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3538
3550
|
}, Ve = (e) => {
|
|
3539
|
-
R() === "docked" &&
|
|
3551
|
+
R() === "docked" && Kn() && (e.target?.closest("button") || (e.preventDefault(), ue(e.clientX, e.clientY, e.pointerId)));
|
|
3540
3552
|
}, He = (e) => {
|
|
3541
3553
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), Oe());
|
|
3542
3554
|
}, Ue = () => {
|
|
3543
3555
|
if (!S) {
|
|
3544
3556
|
if (R() === "docked") {
|
|
3545
|
-
if (!
|
|
3557
|
+
if (!Kn()) {
|
|
3546
3558
|
Ae();
|
|
3547
3559
|
return;
|
|
3548
3560
|
}
|
|
@@ -3553,9 +3565,9 @@ function er(e, t) {
|
|
|
3553
3565
|
}
|
|
3554
3566
|
H();
|
|
3555
3567
|
}
|
|
3556
|
-
}, Y = typeof window < "u" ? window.matchMedia(
|
|
3568
|
+
}, Y = typeof window < "u" ? window.matchMedia(In) : null, We = () => {
|
|
3557
3569
|
if (!S) {
|
|
3558
|
-
if (R() === "docked" && !
|
|
3570
|
+
if (R() === "docked" && !Kn()) {
|
|
3559
3571
|
Ae();
|
|
3560
3572
|
return;
|
|
3561
3573
|
}
|
|
@@ -3566,7 +3578,7 @@ function er(e, t) {
|
|
|
3566
3578
|
e.stopPropagation(), Oe();
|
|
3567
3579
|
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), Y?.addEventListener("change", We), be(), H(), r === "eager" ? queueMicrotask(() => {
|
|
3568
3580
|
S || q();
|
|
3569
|
-
}) : r === "idle" && (j =
|
|
3581
|
+
}) : r === "idle" && (j = tr(() => {
|
|
3570
3582
|
S || q();
|
|
3571
3583
|
})), {
|
|
3572
3584
|
root: a,
|
|
@@ -3588,12 +3600,12 @@ function er(e, t) {
|
|
|
3588
3600
|
}
|
|
3589
3601
|
//#endregion
|
|
3590
3602
|
//#region src/react/ExperienceWidget.tsx
|
|
3591
|
-
function
|
|
3603
|
+
function rr(t) {
|
|
3592
3604
|
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: j = "", onExpanded: M, onCollapsed: ee, onStarted: N, onClose: P, onError: F, onPrefetchReady: te, onFeedback: I, onFeedbackFailed: L } = t, ne = m === "bottom-right" || m === "bottom-left";
|
|
3593
3605
|
return e(() => {
|
|
3594
3606
|
let e = r.current;
|
|
3595
3607
|
if (!e || !i.trim()) return;
|
|
3596
|
-
let t =
|
|
3608
|
+
let t = nr(e, {
|
|
3597
3609
|
experienceId: i,
|
|
3598
3610
|
alt: o,
|
|
3599
3611
|
galleryThumb: s,
|
|
@@ -3677,11 +3689,11 @@ function tr(t) {
|
|
|
3677
3689
|
}
|
|
3678
3690
|
//#endregion
|
|
3679
3691
|
//#region src/next/index.ts
|
|
3680
|
-
function
|
|
3692
|
+
function ir(e = {}) {
|
|
3681
3693
|
let t = v(e);
|
|
3682
3694
|
return { POST: ({ request: e }) => t(e) };
|
|
3683
3695
|
}
|
|
3684
3696
|
//#endregion
|
|
3685
|
-
export { je as ExperienceThumbnail,
|
|
3697
|
+
export { je as ExperienceThumbnail, rr as ExperienceWidget, v as createLiformaSessionRouteHandler, ir as createLiformaSvelteKitSessionHandler };
|
|
3686
3698
|
|
|
3687
3699
|
//# sourceMappingURL=index.js.map
|