@liforma/client 0.4.2 → 0.4.3
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 +681 -573
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/react/ExperienceWidget.d.ts +4 -0
- package/dist/next/react/ExperienceWidget.d.ts.map +1 -1
- package/dist/next/thumbnail/index.d.ts +1 -0
- package/dist/next/thumbnail/index.d.ts.map +1 -1
- package/dist/next/thumbnail/styles.d.ts.map +1 -1
- package/dist/next/thumbnail/types.d.ts +3 -2
- package/dist/next/thumbnail/types.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +27 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +61 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +16 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +25 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/next/widget/types.d.ts +7 -0
- package/dist/next/widget/types.d.ts.map +1 -1
- package/dist/npm/index.js +542 -440
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.d.ts +1 -0
- package/dist/npm/thumbnail/index.d.ts.map +1 -1
- package/dist/npm/thumbnail/styles.d.ts.map +1 -1
- package/dist/npm/thumbnail/types.d.ts +3 -2
- package/dist/npm/thumbnail/types.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +27 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +61 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +16 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +25 -0
- package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/widget/types.d.ts +7 -0
- package/dist/npm/widget/types.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +4 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +17 -1
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +761 -636
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/react/ExperienceWidget.d.ts +4 -0
- package/dist/react/react/ExperienceWidget.d.ts.map +1 -1
- package/dist/react/thumbnail/index.d.ts +1 -0
- package/dist/react/thumbnail/index.d.ts.map +1 -1
- package/dist/react/thumbnail/styles.d.ts.map +1 -1
- package/dist/react/thumbnail/types.d.ts +3 -2
- package/dist/react/thumbnail/types.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +27 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +61 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +16 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +25 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/react/widget/types.d.ts +7 -0
- package/dist/react/widget/types.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +30 -5
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +29 -0
- package/dist/svelte/Experience.svelte.d.ts +2 -0
- package/dist/svelte/ExperienceThumbnail.svelte +3 -2
- package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -1
- package/dist/svelte/ExperienceWidget.svelte +12 -1
- package/dist/svelte/ExperienceWidget.svelte.d.ts +3 -0
- package/package.json +14 -2
package/dist/npm/index.js
CHANGED
|
@@ -29,28 +29,33 @@ function n(n, r = "/meet") {
|
|
|
29
29
|
i?.protocol.startsWith("http") && window.location.assign(i.toString());
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
|
+
//#region src/thumbnail/types.ts
|
|
33
|
+
function r(e) {
|
|
34
|
+
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
32
37
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
33
|
-
var
|
|
34
|
-
function
|
|
38
|
+
var i = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, a = /_CH(\.webp)/i, o = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
39
|
+
function s(e) {
|
|
35
40
|
let t = e.trim();
|
|
36
41
|
if (!t) return t;
|
|
37
|
-
let n = t.replace(
|
|
38
|
-
return n = n.replace(
|
|
42
|
+
let n = t.replace(i, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
43
|
+
return n = n.replace(a, "_neutral$1"), n = n.replace(o, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
39
44
|
}
|
|
40
|
-
function
|
|
45
|
+
function c(e) {
|
|
41
46
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
42
47
|
if (!t) return null;
|
|
43
48
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
44
49
|
return {
|
|
45
|
-
avatarImage:
|
|
46
|
-
...n ? { backgroundImage:
|
|
47
|
-
...r ? { foregroundImage:
|
|
48
|
-
...i ? { fallbackImage:
|
|
50
|
+
avatarImage: s(t),
|
|
51
|
+
...n ? { backgroundImage: s(n) } : {},
|
|
52
|
+
...r ? { foregroundImage: s(r) } : {},
|
|
53
|
+
...i ? { fallbackImage: s(i) } : {}
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
56
|
//#endregion
|
|
52
57
|
//#region src/shims/localStack.ts
|
|
53
|
-
function
|
|
58
|
+
function l() {
|
|
54
59
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
55
60
|
if (typeof location > "u") return !1;
|
|
56
61
|
try {
|
|
@@ -61,83 +66,83 @@ function c() {
|
|
|
61
66
|
}
|
|
62
67
|
//#endregion
|
|
63
68
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
64
|
-
var
|
|
65
|
-
function
|
|
69
|
+
var u = "https://player.liforma.ai", d = "http://localhost:3002";
|
|
70
|
+
function f(e) {
|
|
66
71
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
67
72
|
}
|
|
68
|
-
function
|
|
73
|
+
function p(e) {
|
|
69
74
|
let t = e?.trim();
|
|
70
|
-
return t ? t.replace(/\/$/, "") :
|
|
75
|
+
return t ? t.replace(/\/$/, "") : l() ? d : u;
|
|
71
76
|
}
|
|
72
|
-
function
|
|
73
|
-
let t = e.experienceId.trim(), n =
|
|
77
|
+
function m(e) {
|
|
78
|
+
let t = e.experienceId.trim(), n = p(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
74
79
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
75
80
|
}
|
|
76
|
-
function
|
|
81
|
+
function h(e) {
|
|
77
82
|
let t = e.href?.trim();
|
|
78
83
|
if (t) return t;
|
|
79
84
|
let n = e.experienceId?.trim();
|
|
80
85
|
if (!n) return;
|
|
81
86
|
let r = e.returnUrl?.trim();
|
|
82
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
87
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), m({
|
|
83
88
|
experienceId: n,
|
|
84
89
|
...r ? { returnUrl: r } : {},
|
|
85
90
|
playerBaseUrl: e.playerBaseUrl
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
|
-
function
|
|
93
|
+
function g() {
|
|
89
94
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
90
95
|
}
|
|
91
|
-
var
|
|
92
|
-
function
|
|
93
|
-
return
|
|
96
|
+
var _ = 0, v = [];
|
|
97
|
+
function y() {
|
|
98
|
+
return g() ? 4 : Infinity;
|
|
94
99
|
}
|
|
95
|
-
function
|
|
96
|
-
return
|
|
100
|
+
function b() {
|
|
101
|
+
return g() ? 160 : 0;
|
|
97
102
|
}
|
|
98
|
-
function
|
|
99
|
-
let e =
|
|
100
|
-
for (;
|
|
101
|
-
let e =
|
|
103
|
+
function x() {
|
|
104
|
+
let e = y();
|
|
105
|
+
for (; _ < e && v.length > 0;) {
|
|
106
|
+
let e = v.shift();
|
|
102
107
|
if (!e || e.cancelled) continue;
|
|
103
|
-
|
|
104
|
-
let t =
|
|
108
|
+
_ += 1, e.start();
|
|
109
|
+
let t = b();
|
|
105
110
|
if (t <= 0) {
|
|
106
|
-
|
|
111
|
+
_ = Math.max(0, _ - 1);
|
|
107
112
|
continue;
|
|
108
113
|
}
|
|
109
114
|
window.setTimeout(() => {
|
|
110
|
-
|
|
115
|
+
_ = Math.max(0, _ - 1), x();
|
|
111
116
|
}, t);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
|
-
function
|
|
115
|
-
if (!
|
|
119
|
+
function S(e) {
|
|
120
|
+
if (!g()) return e(), () => {};
|
|
116
121
|
let t = {
|
|
117
122
|
start: e,
|
|
118
123
|
cancelled: !1
|
|
119
124
|
};
|
|
120
|
-
return
|
|
125
|
+
return v.push(t), x(), () => {
|
|
121
126
|
t.cancelled = !0;
|
|
122
127
|
};
|
|
123
128
|
}
|
|
124
129
|
//#endregion
|
|
125
130
|
//#region src/thumbnail/lazyLoad.ts
|
|
126
|
-
function
|
|
127
|
-
return
|
|
131
|
+
function ee() {
|
|
132
|
+
return g() ? "96px 0px" : "280px 0px";
|
|
128
133
|
}
|
|
129
|
-
function
|
|
134
|
+
function C(e) {
|
|
130
135
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
131
136
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
132
137
|
}
|
|
133
|
-
function
|
|
138
|
+
function w(e, t) {
|
|
134
139
|
if (typeof window > "u") return !1;
|
|
135
140
|
let n = e.getBoundingClientRect();
|
|
136
141
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
137
142
|
}
|
|
138
|
-
function
|
|
139
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
140
|
-
o || (s?.(), s =
|
|
143
|
+
function T(e, t) {
|
|
144
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? ee(), i = C(r), a = !1, o = !1, s = null, c = () => {
|
|
145
|
+
o || (s?.(), s = S(() => {
|
|
141
146
|
s = null, o = !0, n(!0);
|
|
142
147
|
}));
|
|
143
148
|
}, l = (e) => {
|
|
@@ -159,11 +164,11 @@ function C(e, t) {
|
|
|
159
164
|
rootMargin: r,
|
|
160
165
|
threshold: 0
|
|
161
166
|
});
|
|
162
|
-
return u.observe(e),
|
|
167
|
+
return u.observe(e), w(e, i) && l(!0), () => {
|
|
163
168
|
s?.(), s = null, u.disconnect();
|
|
164
169
|
};
|
|
165
170
|
}
|
|
166
|
-
function
|
|
171
|
+
function E(e, t) {
|
|
167
172
|
let n = () => t();
|
|
168
173
|
return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
|
|
169
174
|
e.removeEventListener("load", n), e.removeEventListener("error", n);
|
|
@@ -171,40 +176,40 @@ function w(e, t) {
|
|
|
171
176
|
}
|
|
172
177
|
//#endregion
|
|
173
178
|
//#region src/thumbnail/scrollParallax.ts
|
|
174
|
-
function
|
|
179
|
+
function D() {
|
|
175
180
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
176
181
|
}
|
|
177
|
-
function
|
|
182
|
+
function O(e, t) {
|
|
178
183
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
179
184
|
}
|
|
180
|
-
var
|
|
181
|
-
function
|
|
182
|
-
if (
|
|
185
|
+
var k = /* @__PURE__ */ new Set(), A = !1, j = 0;
|
|
186
|
+
function M() {
|
|
187
|
+
if (j = 0, k.size === 0 || typeof window > "u") return;
|
|
183
188
|
let e = window.innerHeight;
|
|
184
|
-
for (let t of
|
|
189
|
+
for (let t of k) {
|
|
185
190
|
if (t.pointerActive?.()) continue;
|
|
186
191
|
let n = t.element.getBoundingClientRect();
|
|
187
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
192
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(O(n, e));
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
195
|
+
function N() {
|
|
196
|
+
j === 0 && (j = requestAnimationFrame(M));
|
|
192
197
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
198
|
+
function P() {
|
|
199
|
+
A || typeof window > "u" || (A = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
|
|
195
200
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
201
|
+
function F() {
|
|
202
|
+
k.size > 0 || !A || typeof window > "u" || (A = !1, j !== 0 && (cancelAnimationFrame(j), j = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
|
|
198
203
|
}
|
|
199
|
-
function
|
|
200
|
-
if (!
|
|
204
|
+
function te(e, t) {
|
|
205
|
+
if (!D()) return () => {};
|
|
201
206
|
let n = {
|
|
202
207
|
element: e,
|
|
203
208
|
onParallax: t.onParallax,
|
|
204
209
|
pointerActive: t.pointerActive
|
|
205
210
|
};
|
|
206
|
-
return
|
|
207
|
-
|
|
211
|
+
return k.add(n), P(), n.pointerActive?.() || t.onParallax(O(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
212
|
+
k.delete(n), F();
|
|
208
213
|
};
|
|
209
214
|
}
|
|
210
215
|
//#endregion
|
|
@@ -213,7 +218,7 @@ function ne(e) {
|
|
|
213
218
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
214
219
|
let a = r || i;
|
|
215
220
|
e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
|
|
216
|
-
}, s =
|
|
221
|
+
}, s = te(e, {
|
|
217
222
|
onParallax: (e) => {
|
|
218
223
|
i = !0, a || (t = e, n = 0, o());
|
|
219
224
|
},
|
|
@@ -226,7 +231,7 @@ function ne(e) {
|
|
|
226
231
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
227
232
|
}, u = () => {
|
|
228
233
|
let s = a;
|
|
229
|
-
a = !1, r = !1, i && s ? (t =
|
|
234
|
+
a = !1, r = !1, i && s ? (t = O(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
230
235
|
}, d = (e) => {
|
|
231
236
|
e.pointerType === "mouse" && (r = !0, o());
|
|
232
237
|
}, f = () => {
|
|
@@ -238,15 +243,15 @@ function ne(e) {
|
|
|
238
243
|
}
|
|
239
244
|
//#endregion
|
|
240
245
|
//#region src/thumbnail/styles.ts
|
|
241
|
-
var
|
|
242
|
-
function
|
|
243
|
-
if (typeof document > "u" ||
|
|
246
|
+
var I = ".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.65rem;\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}", L = !1;
|
|
247
|
+
function re(e) {
|
|
248
|
+
if (typeof document > "u" || L) return;
|
|
244
249
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
245
|
-
|
|
250
|
+
L = !0;
|
|
246
251
|
return;
|
|
247
252
|
}
|
|
248
253
|
let t = document.createElement("style");
|
|
249
|
-
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t),
|
|
254
|
+
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), L = !0;
|
|
250
255
|
}
|
|
251
256
|
//#endregion
|
|
252
257
|
//#region src/widget/styles.ts
|
|
@@ -263,8 +268,8 @@ function oe(e = ie) {
|
|
|
263
268
|
}
|
|
264
269
|
//#endregion
|
|
265
270
|
//#region src/shims/apiBaseUrl.ts
|
|
266
|
-
var
|
|
267
|
-
function
|
|
271
|
+
var R = "https://api.liforma.ai", z = "http://localhost:3001";
|
|
272
|
+
function se() {
|
|
268
273
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
269
274
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
270
275
|
if (typeof document > "u") return null;
|
|
@@ -272,7 +277,7 @@ function R() {
|
|
|
272
277
|
return t ? t.replace(/\/$/, "") : null;
|
|
273
278
|
}
|
|
274
279
|
function ce() {
|
|
275
|
-
return
|
|
280
|
+
return se() || (l() ? z : R);
|
|
276
281
|
}
|
|
277
282
|
//#endregion
|
|
278
283
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
@@ -318,7 +323,7 @@ async function ue(e, t) {
|
|
|
318
323
|
}
|
|
319
324
|
//#endregion
|
|
320
325
|
//#region src/v2/errors/LiformaError.ts
|
|
321
|
-
var
|
|
326
|
+
var B = class extends Error {
|
|
322
327
|
code;
|
|
323
328
|
requestId;
|
|
324
329
|
status;
|
|
@@ -336,7 +341,7 @@ function fe(e, t, n) {
|
|
|
336
341
|
i = JSON.parse(t);
|
|
337
342
|
} catch {}
|
|
338
343
|
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = de(a) ?? de(i) ?? {};
|
|
339
|
-
return new
|
|
344
|
+
return new B(u, {
|
|
340
345
|
code: l,
|
|
341
346
|
requestId: d,
|
|
342
347
|
status: e,
|
|
@@ -345,14 +350,14 @@ function fe(e, t, n) {
|
|
|
345
350
|
}
|
|
346
351
|
//#endregion
|
|
347
352
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
348
|
-
function
|
|
353
|
+
function V(e) {
|
|
349
354
|
let t = e.locale?.trim();
|
|
350
355
|
if (t) return t;
|
|
351
356
|
let n = e.language?.trim();
|
|
352
357
|
if (n) return n;
|
|
353
358
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
354
359
|
}
|
|
355
|
-
function
|
|
360
|
+
function pe(e) {
|
|
356
361
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
357
362
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
358
363
|
return t || n || void 0;
|
|
@@ -365,7 +370,7 @@ function me(e, t) {
|
|
|
365
370
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
366
371
|
let i = t.experienceId.trim();
|
|
367
372
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
368
|
-
let a =
|
|
373
|
+
let a = V(t), o = pe(t), s = t.idempotencyKey?.trim();
|
|
369
374
|
return {
|
|
370
375
|
url: r.toString(),
|
|
371
376
|
init: {
|
|
@@ -389,16 +394,16 @@ function me(e, t) {
|
|
|
389
394
|
}
|
|
390
395
|
//#endregion
|
|
391
396
|
//#region src/v2/types/sessionLaunch.ts
|
|
392
|
-
function
|
|
397
|
+
function H(e) {
|
|
393
398
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
394
399
|
}
|
|
395
|
-
function
|
|
400
|
+
function U(e) {
|
|
396
401
|
return typeof e == "boolean";
|
|
397
402
|
}
|
|
398
|
-
function
|
|
399
|
-
if (!
|
|
403
|
+
function W(e) {
|
|
404
|
+
if (!H(e)) return null;
|
|
400
405
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
401
|
-
return !
|
|
406
|
+
return !H(t) || !H(n) || !H(r) || !H(i) || !U(t.input) || !U(t.output) || !U(t.externalAudio) || !U(n.managed) || !U(r.enabled) || !U(i.enabled) ? null : {
|
|
402
407
|
speech: {
|
|
403
408
|
input: t.input,
|
|
404
409
|
output: t.output,
|
|
@@ -409,8 +414,8 @@ function he(e) {
|
|
|
409
414
|
tools: { enabled: i.enabled }
|
|
410
415
|
};
|
|
411
416
|
}
|
|
412
|
-
function
|
|
413
|
-
return !
|
|
417
|
+
function he(e) {
|
|
418
|
+
return !H(e) || !U(e.avatar) || !U(e.speechInput) || !U(e.speechOutput) || !U(e.tools) || !U(e.externalAudio) ? null : {
|
|
414
419
|
speech: {
|
|
415
420
|
input: e.speechInput,
|
|
416
421
|
output: e.speechOutput,
|
|
@@ -422,10 +427,10 @@ function U(e) {
|
|
|
422
427
|
};
|
|
423
428
|
}
|
|
424
429
|
function ge(e) {
|
|
425
|
-
return
|
|
430
|
+
return W(e) ?? he(e);
|
|
426
431
|
}
|
|
427
432
|
function _e(e) {
|
|
428
|
-
if (!
|
|
433
|
+
if (!H(e)) throw Error("Session Launch response is missing session.");
|
|
429
434
|
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 = ge(e.capabilities), l = ve(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;
|
|
430
435
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
431
436
|
return {
|
|
@@ -446,7 +451,7 @@ function ve(e) {
|
|
|
446
451
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
447
452
|
let t = [];
|
|
448
453
|
for (let n of e) {
|
|
449
|
-
if (!
|
|
454
|
+
if (!H(n)) continue;
|
|
450
455
|
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() : "";
|
|
451
456
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
452
457
|
axis: e,
|
|
@@ -464,8 +469,8 @@ function ye(e) {
|
|
|
464
469
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
465
470
|
}
|
|
466
471
|
}
|
|
467
|
-
function
|
|
468
|
-
if (!
|
|
472
|
+
function G(e) {
|
|
473
|
+
if (!H(e)) throw Error("Session Launch response must be a JSON object.");
|
|
469
474
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
470
475
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
471
476
|
let n = _e(e.session);
|
|
@@ -476,7 +481,7 @@ function be(e) {
|
|
|
476
481
|
}
|
|
477
482
|
//#endregion
|
|
478
483
|
//#region src/v2/api/mintPublicSession.ts
|
|
479
|
-
function
|
|
484
|
+
function be() {
|
|
480
485
|
try {
|
|
481
486
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
482
487
|
} catch {}
|
|
@@ -485,23 +490,23 @@ function xe(e) {
|
|
|
485
490
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
486
491
|
}
|
|
487
492
|
function Se(e, t) {
|
|
488
|
-
let n =
|
|
493
|
+
let n = be(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
489
494
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
490
495
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
491
496
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
492
|
-
return new
|
|
497
|
+
return new B(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
|
|
493
498
|
code: "ORIGIN_NOT_ALLOWED",
|
|
494
499
|
requestId: t.requestId,
|
|
495
500
|
status: t.status,
|
|
496
501
|
details: a
|
|
497
502
|
});
|
|
498
503
|
}
|
|
499
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
504
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new B(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
|
|
500
505
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
501
506
|
requestId: t.requestId,
|
|
502
507
|
status: t.status,
|
|
503
508
|
details: a
|
|
504
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
509
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new B(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
|
|
505
510
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
506
511
|
requestId: t.requestId,
|
|
507
512
|
status: t.status,
|
|
@@ -517,7 +522,7 @@ function Ce(e) {
|
|
|
517
522
|
}
|
|
518
523
|
function we(e) {
|
|
519
524
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
520
|
-
if (t && n && t !== n) throw new
|
|
525
|
+
if (t && n && t !== n) throw new B("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
521
526
|
return t || n || void 0;
|
|
522
527
|
}
|
|
523
528
|
function Te(e, t) {
|
|
@@ -543,15 +548,15 @@ async function Ee(e, t) {
|
|
|
543
548
|
try {
|
|
544
549
|
a = await i.json();
|
|
545
550
|
} catch {
|
|
546
|
-
throw new
|
|
551
|
+
throw new B("Browser session mint returned invalid JSON.", {
|
|
547
552
|
code: "INVALID_RESPONSE",
|
|
548
553
|
status: i.status,
|
|
549
554
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
550
555
|
});
|
|
551
556
|
}
|
|
552
|
-
return
|
|
557
|
+
return G(a);
|
|
553
558
|
}
|
|
554
|
-
async function
|
|
559
|
+
async function K(e, t) {
|
|
555
560
|
let n = me(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
556
561
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
557
562
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
@@ -567,7 +572,7 @@ async function De(e, t) {
|
|
|
567
572
|
let e = await o.text();
|
|
568
573
|
throw fe(o.status, e, o.headers);
|
|
569
574
|
}
|
|
570
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
575
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new B("Session endpoint must return a JSON Session Launch response.", {
|
|
571
576
|
code: "INVALID_RESPONSE",
|
|
572
577
|
status: o.status,
|
|
573
578
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -576,17 +581,17 @@ async function De(e, t) {
|
|
|
576
581
|
try {
|
|
577
582
|
s = await o.json();
|
|
578
583
|
} catch {
|
|
579
|
-
throw new
|
|
584
|
+
throw new B("Session endpoint returned invalid JSON.", {
|
|
580
585
|
code: "INVALID_RESPONSE",
|
|
581
586
|
status: o.status,
|
|
582
587
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
583
588
|
});
|
|
584
589
|
}
|
|
585
|
-
return
|
|
590
|
+
return G(s);
|
|
586
591
|
}
|
|
587
592
|
//#endregion
|
|
588
593
|
//#region src/v2/conversationProcessor.ts
|
|
589
|
-
function
|
|
594
|
+
function De(e) {
|
|
590
595
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
591
596
|
}
|
|
592
597
|
function Oe(e) {
|
|
@@ -605,7 +610,7 @@ function Oe(e) {
|
|
|
605
610
|
}
|
|
606
611
|
async function ke(e, t) {
|
|
607
612
|
let n = await e(t);
|
|
608
|
-
return
|
|
613
|
+
return De(n) ? {
|
|
609
614
|
kind: "stream",
|
|
610
615
|
stream: n
|
|
611
616
|
} : {
|
|
@@ -616,11 +621,11 @@ async function ke(e, t) {
|
|
|
616
621
|
//#endregion
|
|
617
622
|
//#region src/v2/embed/playerReachability.ts
|
|
618
623
|
var Ae = "3002";
|
|
619
|
-
function
|
|
624
|
+
function q(e) {
|
|
620
625
|
let t = new URL(e);
|
|
621
626
|
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 || Ae}. 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.`;
|
|
622
627
|
}
|
|
623
|
-
async function
|
|
628
|
+
async function je(e, t) {
|
|
624
629
|
try {
|
|
625
630
|
await fetch(e, {
|
|
626
631
|
method: "GET",
|
|
@@ -628,14 +633,14 @@ async function q(e, t) {
|
|
|
628
633
|
signal: AbortSignal.timeout(8e3)
|
|
629
634
|
});
|
|
630
635
|
} catch {
|
|
631
|
-
throw Error(
|
|
636
|
+
throw Error(q(t));
|
|
632
637
|
}
|
|
633
638
|
}
|
|
634
|
-
function
|
|
639
|
+
function J(e, t, n, r) {
|
|
635
640
|
try {
|
|
636
641
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
637
642
|
} catch (e) {
|
|
638
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
643
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(q(n), { cause: e }) : e;
|
|
639
644
|
}
|
|
640
645
|
}
|
|
641
646
|
var Me = new Set([1, 2]);
|
|
@@ -649,14 +654,18 @@ var Pe = new Set([
|
|
|
649
654
|
"userTranscript",
|
|
650
655
|
"characterSpeechStarted",
|
|
651
656
|
"characterSpeechEnded",
|
|
657
|
+
"characterFocusChanged",
|
|
652
658
|
"conversationUpdate",
|
|
653
659
|
"listeningState",
|
|
654
660
|
"userSpeechStarted",
|
|
655
661
|
"userSpeechEnded",
|
|
656
662
|
"modeChange",
|
|
657
663
|
"activityChange",
|
|
664
|
+
"feedback",
|
|
665
|
+
"feedbackFailed",
|
|
658
666
|
"message",
|
|
659
667
|
"started",
|
|
668
|
+
"embedReady",
|
|
660
669
|
"widgetReady",
|
|
661
670
|
"widgetExpand",
|
|
662
671
|
"widgetCollapse",
|
|
@@ -669,7 +678,7 @@ function Fe(e) {
|
|
|
669
678
|
if (!e || typeof e != "object") return null;
|
|
670
679
|
let t = e;
|
|
671
680
|
if (!Ne(t.schemaVersion) || !t.type || !Pe.has(t.type)) return null;
|
|
672
|
-
if (t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
681
|
+
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
673
682
|
if (t.type === "widgetAudioSettings") {
|
|
674
683
|
let e = t.payload;
|
|
675
684
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -684,18 +693,21 @@ function Fe(e) {
|
|
|
684
693
|
let { pointerId: n, dx: r, dy: i } = e;
|
|
685
694
|
return typeof n != "number" || !Number.isFinite(n) || typeof r != "number" || !Number.isFinite(r) || typeof i != "number" || !Number.isFinite(i) ? null : t;
|
|
686
695
|
}
|
|
687
|
-
|
|
696
|
+
let n = t.payload;
|
|
697
|
+
return !n || typeof n != "object" ? null : t;
|
|
688
698
|
}
|
|
689
699
|
function Ie(e, t, n) {
|
|
690
700
|
let r = e.trim();
|
|
691
701
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
702
|
+
let i = n?.startButton, a = n?.showFeedback;
|
|
692
703
|
return {
|
|
693
704
|
type: "launch",
|
|
694
705
|
schemaVersion: 2,
|
|
695
706
|
payload: {
|
|
696
707
|
launch: r,
|
|
697
708
|
...t === void 0 ? {} : { session: t },
|
|
698
|
-
...
|
|
709
|
+
...i ? { startButton: i } : {},
|
|
710
|
+
...a === void 0 ? {} : { showFeedback: a }
|
|
699
711
|
}
|
|
700
712
|
};
|
|
701
713
|
}
|
|
@@ -724,7 +736,7 @@ function ze() {
|
|
|
724
736
|
function Be(e) {
|
|
725
737
|
return e;
|
|
726
738
|
}
|
|
727
|
-
function
|
|
739
|
+
function Y() {
|
|
728
740
|
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)}`;
|
|
729
741
|
}
|
|
730
742
|
var Ve = 3e4;
|
|
@@ -733,16 +745,36 @@ function He(e) {
|
|
|
733
745
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
734
746
|
let n = document.createElement("iframe");
|
|
735
747
|
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");
|
|
736
|
-
let r = !1, i = /* @__PURE__ */ new Map(), a = new Promise((
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
748
|
+
let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
|
|
749
|
+
l = e, u = t;
|
|
750
|
+
}), f = () => {
|
|
751
|
+
for (let e of c) window.clearTimeout(e);
|
|
752
|
+
c.length = 0;
|
|
753
|
+
}, p = (t) => {
|
|
754
|
+
if (r) return;
|
|
755
|
+
let i = Date.now();
|
|
756
|
+
if (s > 0 && i - s < 250) return;
|
|
757
|
+
s = i, f();
|
|
758
|
+
let a = Ie(t.launch, t.session, t.chrome), o = () => {
|
|
759
|
+
if (r) return;
|
|
760
|
+
let t = n.contentWindow;
|
|
761
|
+
t && J(t, a, e.playerOrigin);
|
|
743
762
|
};
|
|
744
|
-
|
|
745
|
-
|
|
763
|
+
o();
|
|
764
|
+
for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
|
|
765
|
+
}, m = () => {
|
|
766
|
+
r || !a || p(a);
|
|
767
|
+
}, h = () => {
|
|
768
|
+
if (o += 1, o === 1) {
|
|
769
|
+
je(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
s = 0, m();
|
|
773
|
+
}, g = () => {
|
|
774
|
+
o > 0 || u?.(Error(q(e.playerOrigin)));
|
|
775
|
+
};
|
|
776
|
+
n.addEventListener("load", h), n.addEventListener("error", g);
|
|
777
|
+
let _ = (t) => {
|
|
746
778
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
747
779
|
let a = Fe(t.data);
|
|
748
780
|
if (a) switch (a.type) {
|
|
@@ -767,6 +799,9 @@ function He(e) {
|
|
|
767
799
|
case "characterSpeechEnded":
|
|
768
800
|
e.onCharacterSpeechEnded?.(a.payload);
|
|
769
801
|
break;
|
|
802
|
+
case "characterFocusChanged":
|
|
803
|
+
e.onCharacterFocusChanged?.(a.payload);
|
|
804
|
+
break;
|
|
770
805
|
case "conversationUpdate":
|
|
771
806
|
e.onConversationUpdate?.(a.payload.conversation);
|
|
772
807
|
break;
|
|
@@ -785,12 +820,21 @@ function He(e) {
|
|
|
785
820
|
case "activityChange":
|
|
786
821
|
e.onActivityChange?.(a.payload.activity);
|
|
787
822
|
break;
|
|
823
|
+
case "feedback":
|
|
824
|
+
e.onFeedback?.(a.payload);
|
|
825
|
+
break;
|
|
826
|
+
case "feedbackFailed":
|
|
827
|
+
e.onFeedbackFailed?.(a.payload);
|
|
828
|
+
break;
|
|
788
829
|
case "message":
|
|
789
830
|
e.onMessage?.(a.payload);
|
|
790
831
|
break;
|
|
791
832
|
case "started":
|
|
792
833
|
e.onStarted?.(a.payload);
|
|
793
834
|
break;
|
|
835
|
+
case "embedReady":
|
|
836
|
+
m();
|
|
837
|
+
break;
|
|
794
838
|
case "widgetReady":
|
|
795
839
|
e.onWidgetReady?.();
|
|
796
840
|
break;
|
|
@@ -814,42 +858,39 @@ function He(e) {
|
|
|
814
858
|
break;
|
|
815
859
|
}
|
|
816
860
|
};
|
|
817
|
-
if (window.addEventListener("message",
|
|
861
|
+
if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
818
862
|
let e = getComputedStyle(t).minHeight;
|
|
819
863
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
820
864
|
}
|
|
821
|
-
let
|
|
865
|
+
let v = (t, i) => {
|
|
822
866
|
if (r) return;
|
|
823
867
|
let a = n.contentWindow;
|
|
824
|
-
if (!a) throw Error(
|
|
825
|
-
|
|
826
|
-
},
|
|
827
|
-
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId :
|
|
868
|
+
if (!a) throw Error(q(e.playerOrigin));
|
|
869
|
+
J(a, t, e.playerOrigin, i);
|
|
870
|
+
}, y = (e, t = 12e4, n) => {
|
|
871
|
+
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Y();
|
|
828
872
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
|
|
829
873
|
i.set(r, {
|
|
830
874
|
resolve: (e) => a(e),
|
|
831
875
|
reject: o
|
|
832
|
-
}),
|
|
876
|
+
}), v(e, n), setTimeout(() => {
|
|
833
877
|
i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
834
878
|
}, t);
|
|
835
879
|
});
|
|
836
880
|
};
|
|
837
881
|
return {
|
|
838
882
|
waitForLoad() {
|
|
839
|
-
return
|
|
883
|
+
return d;
|
|
840
884
|
},
|
|
841
885
|
postParentHello() {
|
|
842
|
-
|
|
886
|
+
v(Le());
|
|
843
887
|
},
|
|
844
|
-
postLaunch(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
};
|
|
851
|
-
c();
|
|
852
|
-
for (let e = 1; e <= 12; e += 1) window.setTimeout(c, e * 75);
|
|
888
|
+
postLaunch(e, t, n) {
|
|
889
|
+
r || (a = {
|
|
890
|
+
launch: e,
|
|
891
|
+
session: t,
|
|
892
|
+
chrome: n
|
|
893
|
+
}, s = 0, p(a));
|
|
853
894
|
},
|
|
854
895
|
postManifest(e) {
|
|
855
896
|
if (typeof e == "string") {
|
|
@@ -864,17 +905,17 @@ function He(e) {
|
|
|
864
905
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
865
906
|
},
|
|
866
907
|
postWidgetSetChrome(e) {
|
|
867
|
-
|
|
908
|
+
v(Re(e));
|
|
868
909
|
},
|
|
869
910
|
postWidgetToggleAudioSettings() {
|
|
870
|
-
|
|
911
|
+
v(ze());
|
|
871
912
|
},
|
|
872
913
|
speak(e) {
|
|
873
|
-
return
|
|
914
|
+
return y({
|
|
874
915
|
type: "speak",
|
|
875
916
|
schemaVersion: 2,
|
|
876
917
|
payload: {
|
|
877
|
-
correlationId:
|
|
918
|
+
correlationId: Y(),
|
|
878
919
|
text: e.text,
|
|
879
920
|
...e.characterId ? { characterId: e.characterId } : {},
|
|
880
921
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
@@ -882,31 +923,31 @@ function He(e) {
|
|
|
882
923
|
});
|
|
883
924
|
},
|
|
884
925
|
startListening() {
|
|
885
|
-
return
|
|
926
|
+
return y({
|
|
886
927
|
type: "startListening",
|
|
887
928
|
schemaVersion: 2,
|
|
888
|
-
payload: { correlationId:
|
|
929
|
+
payload: { correlationId: Y() }
|
|
889
930
|
});
|
|
890
931
|
},
|
|
891
932
|
stopListening() {
|
|
892
|
-
return
|
|
933
|
+
return y({
|
|
893
934
|
type: "stopListening",
|
|
894
935
|
schemaVersion: 2,
|
|
895
|
-
payload: { correlationId:
|
|
936
|
+
payload: { correlationId: Y() }
|
|
896
937
|
});
|
|
897
938
|
},
|
|
898
939
|
listenOnce(e) {
|
|
899
|
-
return
|
|
940
|
+
return y({
|
|
900
941
|
type: "listenOnce",
|
|
901
942
|
schemaVersion: 2,
|
|
902
943
|
payload: {
|
|
903
|
-
correlationId:
|
|
944
|
+
correlationId: Y(),
|
|
904
945
|
...e?.timeoutMs === void 0 ? {} : { timeoutMs: e.timeoutMs }
|
|
905
946
|
}
|
|
906
947
|
});
|
|
907
948
|
},
|
|
908
949
|
async speakProcessorStream(e, t) {
|
|
909
|
-
let n =
|
|
950
|
+
let n = Y(), r = Y(), i = (await y({
|
|
910
951
|
type: "speakStreamStart",
|
|
911
952
|
schemaVersion: 2,
|
|
912
953
|
payload: {
|
|
@@ -918,7 +959,7 @@ function He(e) {
|
|
|
918
959
|
try {
|
|
919
960
|
for await (let n of e) {
|
|
920
961
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
921
|
-
n &&
|
|
962
|
+
n && v({
|
|
922
963
|
type: "speakStreamChunk",
|
|
923
964
|
schemaVersion: 2,
|
|
924
965
|
payload: {
|
|
@@ -928,7 +969,7 @@ function He(e) {
|
|
|
928
969
|
});
|
|
929
970
|
}
|
|
930
971
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
931
|
-
return await
|
|
972
|
+
return await y({
|
|
932
973
|
type: "speakStreamEnd",
|
|
933
974
|
schemaVersion: 2,
|
|
934
975
|
payload: {
|
|
@@ -938,7 +979,7 @@ function He(e) {
|
|
|
938
979
|
});
|
|
939
980
|
} catch (e) {
|
|
940
981
|
try {
|
|
941
|
-
await
|
|
982
|
+
await y({
|
|
942
983
|
type: "speakStreamEnd",
|
|
943
984
|
schemaVersion: 2,
|
|
944
985
|
payload: {
|
|
@@ -951,8 +992,8 @@ function He(e) {
|
|
|
951
992
|
}
|
|
952
993
|
},
|
|
953
994
|
speechPlay(e) {
|
|
954
|
-
let t =
|
|
955
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
995
|
+
let t = Y(), n = [];
|
|
996
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
|
|
956
997
|
type: "speechPlay",
|
|
957
998
|
schemaVersion: 2,
|
|
958
999
|
payload: {
|
|
@@ -966,11 +1007,11 @@ function He(e) {
|
|
|
966
1007
|
}, 12e4, n);
|
|
967
1008
|
},
|
|
968
1009
|
speechUtteranceBegin(e) {
|
|
969
|
-
return
|
|
1010
|
+
return y({
|
|
970
1011
|
type: "speechUtteranceBegin",
|
|
971
1012
|
schemaVersion: 2,
|
|
972
1013
|
payload: {
|
|
973
|
-
correlationId:
|
|
1014
|
+
correlationId: Y(),
|
|
974
1015
|
utteranceId: e.utteranceId,
|
|
975
1016
|
format: e.format,
|
|
976
1017
|
queue: e.queue,
|
|
@@ -980,11 +1021,11 @@ function He(e) {
|
|
|
980
1021
|
});
|
|
981
1022
|
},
|
|
982
1023
|
speechUtteranceWrite(e) {
|
|
983
|
-
return
|
|
1024
|
+
return y({
|
|
984
1025
|
type: "speechUtteranceWrite",
|
|
985
1026
|
schemaVersion: 2,
|
|
986
1027
|
payload: {
|
|
987
|
-
correlationId:
|
|
1028
|
+
correlationId: Y(),
|
|
988
1029
|
utteranceId: e.utteranceId,
|
|
989
1030
|
audio: e.audio,
|
|
990
1031
|
byteLength: e.byteLength
|
|
@@ -992,22 +1033,22 @@ function He(e) {
|
|
|
992
1033
|
}, Ve, [e.audio]);
|
|
993
1034
|
},
|
|
994
1035
|
speechUtteranceSetTranscript(e) {
|
|
995
|
-
return
|
|
1036
|
+
return y({
|
|
996
1037
|
type: "speechUtteranceSetTranscript",
|
|
997
1038
|
schemaVersion: 2,
|
|
998
1039
|
payload: {
|
|
999
|
-
correlationId:
|
|
1040
|
+
correlationId: Y(),
|
|
1000
1041
|
utteranceId: e.utteranceId,
|
|
1001
1042
|
transcript: e.transcript
|
|
1002
1043
|
}
|
|
1003
1044
|
});
|
|
1004
1045
|
},
|
|
1005
1046
|
speechUtteranceClose(e) {
|
|
1006
|
-
return
|
|
1047
|
+
return y({
|
|
1007
1048
|
type: "speechUtteranceClose",
|
|
1008
1049
|
schemaVersion: 2,
|
|
1009
1050
|
payload: {
|
|
1010
|
-
correlationId:
|
|
1051
|
+
correlationId: Y(),
|
|
1011
1052
|
utteranceId: e.utteranceId,
|
|
1012
1053
|
...e.transcript === void 0 ? {} : { transcript: e.transcript },
|
|
1013
1054
|
...e.history ? { history: e.history } : {}
|
|
@@ -1015,37 +1056,57 @@ function He(e) {
|
|
|
1015
1056
|
});
|
|
1016
1057
|
},
|
|
1017
1058
|
speechUtteranceCancel(e) {
|
|
1018
|
-
return
|
|
1059
|
+
return y({
|
|
1019
1060
|
type: "speechUtteranceCancel",
|
|
1020
1061
|
schemaVersion: 2,
|
|
1021
1062
|
payload: {
|
|
1022
|
-
correlationId:
|
|
1063
|
+
correlationId: Y(),
|
|
1023
1064
|
utteranceId: e.utteranceId
|
|
1024
1065
|
}
|
|
1025
1066
|
});
|
|
1026
1067
|
},
|
|
1027
1068
|
speechInterrupt(e) {
|
|
1028
|
-
return
|
|
1069
|
+
return y({
|
|
1029
1070
|
type: "speechInterrupt",
|
|
1030
1071
|
schemaVersion: 2,
|
|
1031
1072
|
payload: {
|
|
1032
|
-
correlationId:
|
|
1073
|
+
correlationId: Y(),
|
|
1033
1074
|
...e
|
|
1034
1075
|
}
|
|
1035
1076
|
});
|
|
1036
1077
|
},
|
|
1037
1078
|
getConversation() {
|
|
1038
|
-
return
|
|
1079
|
+
return y({
|
|
1039
1080
|
type: "getConversation",
|
|
1040
1081
|
schemaVersion: 2,
|
|
1041
|
-
payload: { correlationId:
|
|
1082
|
+
payload: { correlationId: Y() }
|
|
1083
|
+
});
|
|
1084
|
+
},
|
|
1085
|
+
focusCharacter(e) {
|
|
1086
|
+
return y({
|
|
1087
|
+
type: "focusCharacter",
|
|
1088
|
+
schemaVersion: 2,
|
|
1089
|
+
payload: {
|
|
1090
|
+
correlationId: Y(),
|
|
1091
|
+
characterId: e
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
},
|
|
1095
|
+
setFit(e) {
|
|
1096
|
+
return y({
|
|
1097
|
+
type: "setFit",
|
|
1098
|
+
schemaVersion: 2,
|
|
1099
|
+
payload: {
|
|
1100
|
+
correlationId: Y(),
|
|
1101
|
+
fit: e
|
|
1102
|
+
}
|
|
1042
1103
|
});
|
|
1043
1104
|
},
|
|
1044
1105
|
destroy() {
|
|
1045
1106
|
if (!r) {
|
|
1046
1107
|
r = !0;
|
|
1047
1108
|
for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1048
|
-
i.clear(), window.removeEventListener("message",
|
|
1109
|
+
i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
|
|
1049
1110
|
}
|
|
1050
1111
|
}
|
|
1051
1112
|
};
|
|
@@ -1077,13 +1138,13 @@ function Ke() {
|
|
|
1077
1138
|
}
|
|
1078
1139
|
function qe() {
|
|
1079
1140
|
let e = Ke();
|
|
1080
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1141
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? Ge : We;
|
|
1081
1142
|
}
|
|
1082
|
-
function Je(e, t, n, r, i, a, o) {
|
|
1083
|
-
let
|
|
1084
|
-
|
|
1085
|
-
let
|
|
1086
|
-
return
|
|
1143
|
+
function Je(e, t, n, r, i, a, o, s) {
|
|
1144
|
+
let c = (e ?? qe()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1145
|
+
d && u.searchParams.set("locationId", d);
|
|
1146
|
+
let f = r?.trim();
|
|
1147
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Ye(u.toString());
|
|
1087
1148
|
}
|
|
1088
1149
|
function Ye(e) {
|
|
1089
1150
|
if (typeof location > "u") return e;
|
|
@@ -1116,10 +1177,13 @@ function $e() {
|
|
|
1116
1177
|
userSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1117
1178
|
characterSpeechStarted: /* @__PURE__ */ new Set(),
|
|
1118
1179
|
characterSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1180
|
+
characterFocusChanged: /* @__PURE__ */ new Set(),
|
|
1119
1181
|
conversationUpdate: /* @__PURE__ */ new Set(),
|
|
1120
1182
|
message: /* @__PURE__ */ new Set(),
|
|
1121
1183
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1122
1184
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1185
|
+
feedback: /* @__PURE__ */ new Set(),
|
|
1186
|
+
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1123
1187
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1124
1188
|
};
|
|
1125
1189
|
}
|
|
@@ -1155,7 +1219,7 @@ var st = [
|
|
|
1155
1219
|
24e3,
|
|
1156
1220
|
44100,
|
|
1157
1221
|
48e3
|
|
1158
|
-
],
|
|
1222
|
+
], X = {
|
|
1159
1223
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1160
1224
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1161
1225
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1178,7 +1242,7 @@ var st = [
|
|
|
1178
1242
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1179
1243
|
super(e);
|
|
1180
1244
|
}
|
|
1181
|
-
},
|
|
1245
|
+
}, Z = class extends Error {
|
|
1182
1246
|
name = "SpeechRuntimeError";
|
|
1183
1247
|
constructor(e, t) {
|
|
1184
1248
|
super(e, t);
|
|
@@ -1200,9 +1264,9 @@ function ft(e) {
|
|
|
1200
1264
|
return st.includes(e);
|
|
1201
1265
|
}
|
|
1202
1266
|
function pt(e) {
|
|
1203
|
-
if (e.encoding !== "pcm_s16le") throw new
|
|
1204
|
-
if (e.channels !== 1) throw new
|
|
1205
|
-
if (!ft(e.sampleRate)) throw new
|
|
1267
|
+
if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
|
|
1268
|
+
if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
|
|
1269
|
+
if (!ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1206
1270
|
}
|
|
1207
1271
|
function mt(e) {
|
|
1208
1272
|
if (rt(e)) {
|
|
@@ -1210,23 +1274,23 @@ function mt(e) {
|
|
|
1210
1274
|
return;
|
|
1211
1275
|
}
|
|
1212
1276
|
if (it(e)) {
|
|
1213
|
-
if (!e.url.trim()) throw new
|
|
1214
|
-
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new
|
|
1277
|
+
if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
|
|
1278
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1215
1279
|
return;
|
|
1216
1280
|
}
|
|
1217
1281
|
if (at(e)) {
|
|
1218
|
-
if (e.track.kind !== "audio") throw new
|
|
1219
|
-
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new
|
|
1282
|
+
if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
1283
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1220
1284
|
return;
|
|
1221
1285
|
}
|
|
1222
1286
|
if (ot(e)) {
|
|
1223
1287
|
let t = e.encoding.trim().toLowerCase();
|
|
1224
|
-
if (!t) throw new
|
|
1225
|
-
if (t === "pcm_s16le") throw new
|
|
1226
|
-
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new
|
|
1288
|
+
if (!t) throw new Z("Encoded audio MIME type is required.");
|
|
1289
|
+
if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1290
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1227
1291
|
return;
|
|
1228
1292
|
}
|
|
1229
|
-
throw new
|
|
1293
|
+
throw new Z("Unsupported speech.play audio shape.");
|
|
1230
1294
|
}
|
|
1231
1295
|
function ht(e) {
|
|
1232
1296
|
if (e.format) return pt(e.format), e.format;
|
|
@@ -1238,7 +1302,7 @@ function ht(e) {
|
|
|
1238
1302
|
};
|
|
1239
1303
|
return pt(t), t;
|
|
1240
1304
|
}
|
|
1241
|
-
throw new
|
|
1305
|
+
throw new Z("createUtterance requires format or track.");
|
|
1242
1306
|
}
|
|
1243
1307
|
function gt(e) {
|
|
1244
1308
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
@@ -1383,8 +1447,8 @@ async function Et(e) {
|
|
|
1383
1447
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1384
1448
|
async function Dt(e) {
|
|
1385
1449
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1386
|
-
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new
|
|
1387
|
-
if (t.kind !== "audio") throw new
|
|
1450
|
+
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
|
|
1451
|
+
if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
1388
1452
|
if (t.readyState === "ended" || i?.aborted) return;
|
|
1389
1453
|
let a = new MediaStream([t]), o = Promise.resolve(), s = !1, c = null, l = () => {
|
|
1390
1454
|
s || (s = !0, c?.stop(), c = null);
|
|
@@ -1401,7 +1465,7 @@ async function Dt(e) {
|
|
|
1401
1465
|
if (s || i?.aborted) return;
|
|
1402
1466
|
let e = 0;
|
|
1403
1467
|
for (; e < t.byteLength;) {
|
|
1404
|
-
let r = Math.min(e +
|
|
1468
|
+
let r = Math.min(e + X.MAX_CHUNK_BYTES, t.byteLength);
|
|
1405
1469
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1406
1470
|
let i = t.subarray(e, r);
|
|
1407
1471
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1412,7 +1476,7 @@ async function Dt(e) {
|
|
|
1412
1476
|
}
|
|
1413
1477
|
});
|
|
1414
1478
|
} catch (e) {
|
|
1415
|
-
throw l(), new
|
|
1479
|
+
throw l(), new Z(`MediaStreamTrack capture failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1416
1480
|
}
|
|
1417
1481
|
await new Promise((e) => {
|
|
1418
1482
|
let r = () => {
|
|
@@ -1426,10 +1490,10 @@ async function Dt(e) {
|
|
|
1426
1490
|
//#endregion
|
|
1427
1491
|
//#region src/v2/speech/speechController.ts
|
|
1428
1492
|
async function Ot(e, t) {
|
|
1429
|
-
if (at(e)) throw new
|
|
1493
|
+
if (at(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
|
|
1430
1494
|
if (rt(e)) {
|
|
1431
1495
|
let t = gt(e.data);
|
|
1432
|
-
if (t.byteLength & 1) throw new
|
|
1496
|
+
if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
|
|
1433
1497
|
return {
|
|
1434
1498
|
kind: "pcm",
|
|
1435
1499
|
data: t.slice().buffer,
|
|
@@ -1441,7 +1505,7 @@ async function Ot(e, t) {
|
|
|
1441
1505
|
url: e.url.trim(),
|
|
1442
1506
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1443
1507
|
};
|
|
1444
|
-
if (!ot(e)) throw new
|
|
1508
|
+
if (!ot(e)) throw new Z("Unsupported speech.play audio shape.");
|
|
1445
1509
|
let n;
|
|
1446
1510
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1447
1511
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
@@ -1471,13 +1535,13 @@ function At(e, t = "completed") {
|
|
|
1471
1535
|
}
|
|
1472
1536
|
};
|
|
1473
1537
|
}
|
|
1474
|
-
function Z(e) {
|
|
1475
|
-
return e instanceof Error ? e : new X(String(e));
|
|
1476
|
-
}
|
|
1477
1538
|
function jt(e) {
|
|
1539
|
+
return e instanceof Error ? e : new Z(String(e));
|
|
1540
|
+
}
|
|
1541
|
+
function Mt(e) {
|
|
1478
1542
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1479
1543
|
}
|
|
1480
|
-
var
|
|
1544
|
+
var Nt = class {
|
|
1481
1545
|
id;
|
|
1482
1546
|
characterId;
|
|
1483
1547
|
result;
|
|
@@ -1506,7 +1570,7 @@ var Mt = class {
|
|
|
1506
1570
|
queue: e.queue,
|
|
1507
1571
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1508
1572
|
}).catch((e) => {
|
|
1509
|
-
throw this.fail(
|
|
1573
|
+
throw this.fail(jt(e)), jt(e);
|
|
1510
1574
|
}), this.signal?.addEventListener("abort", () => {
|
|
1511
1575
|
this.cancel();
|
|
1512
1576
|
}, { once: !0 });
|
|
@@ -1514,13 +1578,13 @@ var Mt = class {
|
|
|
1514
1578
|
async write(e, t) {
|
|
1515
1579
|
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
|
|
1516
1580
|
let n = gt(e);
|
|
1517
|
-
if (n.byteLength & 1) throw new
|
|
1518
|
-
if (n.byteLength >
|
|
1581
|
+
if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
|
|
1582
|
+
if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
|
|
1519
1583
|
if (n.byteLength === 0) return;
|
|
1520
|
-
let r = t?.timeoutMs ??
|
|
1584
|
+
let r = t?.timeoutMs ?? X.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1521
1585
|
await this.acquireWriteSlot(r);
|
|
1522
1586
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1523
|
-
if (this.bufferedMs + i >
|
|
1587
|
+
if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1524
1588
|
let a = async () => {
|
|
1525
1589
|
if (this.closed || this.settled) throw new lt();
|
|
1526
1590
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
@@ -1557,7 +1621,7 @@ var Mt = class {
|
|
|
1557
1621
|
});
|
|
1558
1622
|
return this.resolve(t), t;
|
|
1559
1623
|
} catch (e) {
|
|
1560
|
-
let t =
|
|
1624
|
+
let t = jt(e);
|
|
1561
1625
|
throw this.fail(t), t;
|
|
1562
1626
|
}
|
|
1563
1627
|
}
|
|
@@ -1579,7 +1643,7 @@ var Mt = class {
|
|
|
1579
1643
|
};
|
|
1580
1644
|
return this.resolve(t), t;
|
|
1581
1645
|
} catch (e) {
|
|
1582
|
-
let t =
|
|
1646
|
+
let t = jt(e);
|
|
1583
1647
|
throw this.fail(t), t;
|
|
1584
1648
|
}
|
|
1585
1649
|
}
|
|
@@ -1588,7 +1652,7 @@ var Mt = class {
|
|
|
1588
1652
|
}
|
|
1589
1653
|
requireHost() {
|
|
1590
1654
|
let e = this.host.getIframeHost();
|
|
1591
|
-
if (!e) throw new
|
|
1655
|
+
if (!e) throw new Z("Speech session is not attached.");
|
|
1592
1656
|
return e;
|
|
1593
1657
|
}
|
|
1594
1658
|
resolve(e) {
|
|
@@ -1598,7 +1662,7 @@ var Mt = class {
|
|
|
1598
1662
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1599
1663
|
}
|
|
1600
1664
|
async acquireWriteSlot(e) {
|
|
1601
|
-
if (this.pendingWriteCount <
|
|
1665
|
+
if (this.pendingWriteCount < X.MAX_PENDING_WRITES) {
|
|
1602
1666
|
this.pendingWriteCount += 1;
|
|
1603
1667
|
return;
|
|
1604
1668
|
}
|
|
@@ -1623,7 +1687,7 @@ var Mt = class {
|
|
|
1623
1687
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1624
1688
|
}
|
|
1625
1689
|
};
|
|
1626
|
-
function
|
|
1690
|
+
function Pt(e) {
|
|
1627
1691
|
let t = null, n = (t, n) => {
|
|
1628
1692
|
if (!e.getCapabilities()[n]) throw new ct(t, n);
|
|
1629
1693
|
}, r = {
|
|
@@ -1632,7 +1696,7 @@ function Nt(e) {
|
|
|
1632
1696
|
let i = _t(r.queue ?? "append");
|
|
1633
1697
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1634
1698
|
let a = e.getIframeHost();
|
|
1635
|
-
if (!a) throw new
|
|
1699
|
+
if (!a) throw new Z("Speech session is not attached.");
|
|
1636
1700
|
let o = a.speak({
|
|
1637
1701
|
text: r.text,
|
|
1638
1702
|
characterId: r.characterId,
|
|
@@ -1651,7 +1715,7 @@ function Nt(e) {
|
|
|
1651
1715
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1652
1716
|
t.removeEventListener("abort", s), n(At(e, "completed"));
|
|
1653
1717
|
}, (a) => {
|
|
1654
|
-
if (t.removeEventListener("abort", s),
|
|
1718
|
+
if (t.removeEventListener("abort", s), Mt(a)) {
|
|
1655
1719
|
n({
|
|
1656
1720
|
utteranceId: "utt_interrupted",
|
|
1657
1721
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
@@ -1662,14 +1726,14 @@ function Nt(e) {
|
|
|
1662
1726
|
});
|
|
1663
1727
|
return;
|
|
1664
1728
|
}
|
|
1665
|
-
i(
|
|
1729
|
+
i(jt(a));
|
|
1666
1730
|
});
|
|
1667
1731
|
});
|
|
1668
1732
|
}
|
|
1669
1733
|
try {
|
|
1670
1734
|
return At(await o, "completed");
|
|
1671
1735
|
} catch (t) {
|
|
1672
|
-
if (
|
|
1736
|
+
if (Mt(t)) return {
|
|
1673
1737
|
utteranceId: "utt_interrupted",
|
|
1674
1738
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1675
1739
|
status: "interrupted",
|
|
@@ -1677,7 +1741,7 @@ function Nt(e) {
|
|
|
1677
1741
|
transcript: r.text,
|
|
1678
1742
|
animation: dt("none")
|
|
1679
1743
|
};
|
|
1680
|
-
throw
|
|
1744
|
+
throw jt(t);
|
|
1681
1745
|
}
|
|
1682
1746
|
},
|
|
1683
1747
|
async play(i) {
|
|
@@ -1698,7 +1762,7 @@ function Nt(e) {
|
|
|
1698
1762
|
}).result;
|
|
1699
1763
|
}
|
|
1700
1764
|
let o = e.getIframeHost();
|
|
1701
|
-
if (!o) throw new
|
|
1765
|
+
if (!o) throw new Z("Speech session is not attached.");
|
|
1702
1766
|
let s = await Ot(i.audio, i.signal);
|
|
1703
1767
|
return o.speechPlay({
|
|
1704
1768
|
source: s,
|
|
@@ -1712,11 +1776,11 @@ function Nt(e) {
|
|
|
1712
1776
|
createUtterance(r) {
|
|
1713
1777
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
1714
1778
|
let i = ht(r);
|
|
1715
|
-
if (r.track && r.track.kind !== "audio") throw new
|
|
1779
|
+
if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
|
|
1716
1780
|
let a = r.queue ?? "replace-active";
|
|
1717
|
-
if (a !== "replace-active" && a !== "replace-all") throw new
|
|
1781
|
+
if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
|
|
1718
1782
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
1719
|
-
let o = new
|
|
1783
|
+
let o = new Nt({
|
|
1720
1784
|
id: kt(),
|
|
1721
1785
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1722
1786
|
format: i,
|
|
@@ -1756,11 +1820,17 @@ function Nt(e) {
|
|
|
1756
1820
|
return r;
|
|
1757
1821
|
}
|
|
1758
1822
|
//#endregion
|
|
1823
|
+
//#region src/v2/types/sessionInteraction.ts
|
|
1824
|
+
function Ft(e) {
|
|
1825
|
+
let t = e?.trim();
|
|
1826
|
+
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
1827
|
+
}
|
|
1828
|
+
//#endregion
|
|
1759
1829
|
//#region src/v2/experience.ts
|
|
1760
|
-
function
|
|
1830
|
+
function It(e) {
|
|
1761
1831
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
1762
1832
|
}
|
|
1763
|
-
var
|
|
1833
|
+
var Lt = class e {
|
|
1764
1834
|
bootstrap;
|
|
1765
1835
|
conversationProcessor;
|
|
1766
1836
|
iframeHost = null;
|
|
@@ -1773,6 +1843,7 @@ var Ft = class e {
|
|
|
1773
1843
|
attachReturnUrl = null;
|
|
1774
1844
|
closed = !1;
|
|
1775
1845
|
attached = !1;
|
|
1846
|
+
pendingFit = null;
|
|
1776
1847
|
closeHandlers = [];
|
|
1777
1848
|
eventRegistry = $e();
|
|
1778
1849
|
readyEnvelope = null;
|
|
@@ -1780,10 +1851,10 @@ var Ft = class e {
|
|
|
1780
1851
|
conversationCache = [];
|
|
1781
1852
|
speech;
|
|
1782
1853
|
constructor(e) {
|
|
1783
|
-
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 =
|
|
1854
|
+
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 = Pt({
|
|
1784
1855
|
getIframeHost: () => this.iframeHost,
|
|
1785
1856
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
1786
|
-
getCapabilities: () =>
|
|
1857
|
+
getCapabilities: () => Rt(this.resolvedSession),
|
|
1787
1858
|
getActiveCharacterId: () => "character_unknown",
|
|
1788
1859
|
onProcessorInterrupt: () => {
|
|
1789
1860
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -1817,6 +1888,7 @@ var Ft = class e {
|
|
|
1817
1888
|
language: t.language,
|
|
1818
1889
|
locationId: t.locationId,
|
|
1819
1890
|
avatarId: t.avatarId,
|
|
1891
|
+
castSize: t.castSize,
|
|
1820
1892
|
embedBaseUrl: t.embedBaseUrl,
|
|
1821
1893
|
debug: t.debug,
|
|
1822
1894
|
mode: t.mode,
|
|
@@ -1836,6 +1908,7 @@ var Ft = class e {
|
|
|
1836
1908
|
language: t.language,
|
|
1837
1909
|
locationId: t.locationId,
|
|
1838
1910
|
avatarId: t.avatarId,
|
|
1911
|
+
castSize: t.castSize,
|
|
1839
1912
|
embedBaseUrl: t.embedBaseUrl,
|
|
1840
1913
|
debug: t.debug,
|
|
1841
1914
|
mode: t.mode,
|
|
@@ -1869,7 +1942,7 @@ var Ft = class e {
|
|
|
1869
1942
|
if (this.closed) throw Error("Session has ended.");
|
|
1870
1943
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
1871
1944
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
1872
|
-
let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Je(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui,
|
|
1945
|
+
let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Je(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, It(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Xe(i), o = null, s = new Promise((e) => {
|
|
1873
1946
|
o = e;
|
|
1874
1947
|
}), c = null, l = new Promise((e) => {
|
|
1875
1948
|
c = e;
|
|
@@ -1905,12 +1978,21 @@ var Ft = class e {
|
|
|
1905
1978
|
onCharacterSpeechEnded: (e) => {
|
|
1906
1979
|
this.emitWrapped("characterSpeechEnded", e);
|
|
1907
1980
|
},
|
|
1981
|
+
onCharacterFocusChanged: (e) => {
|
|
1982
|
+
this.emitWrapped("characterFocusChanged", e);
|
|
1983
|
+
},
|
|
1908
1984
|
onListeningState: (e) => {
|
|
1909
1985
|
this.emitWrapped("listeningState", e);
|
|
1910
1986
|
},
|
|
1911
1987
|
onActivityChange: (e) => {
|
|
1912
1988
|
this.emitWrapped("activityChange", e);
|
|
1913
1989
|
},
|
|
1990
|
+
onFeedback: (e) => {
|
|
1991
|
+
this.emitWrapped("feedback", e);
|
|
1992
|
+
},
|
|
1993
|
+
onFeedbackFailed: (e) => {
|
|
1994
|
+
this.emitWrapped("feedbackFailed", e);
|
|
1995
|
+
},
|
|
1914
1996
|
onMessage: (e) => {
|
|
1915
1997
|
this.emitWrapped("message", e);
|
|
1916
1998
|
},
|
|
@@ -1929,7 +2011,7 @@ var Ft = class e {
|
|
|
1929
2011
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
1930
2012
|
});
|
|
1931
2013
|
this.iframeHost = f;
|
|
1932
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2014
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), K(this.bootstrap.sessionEndpoint, {
|
|
1933
2015
|
experienceId: this.bootstrap.experienceId,
|
|
1934
2016
|
locale: this.bootstrap.locale,
|
|
1935
2017
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -1961,11 +2043,17 @@ var Ft = class e {
|
|
|
1961
2043
|
f.postParentHello();
|
|
1962
2044
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
1963
2045
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
1964
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _,
|
|
2046
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, {
|
|
2047
|
+
startButton: e.startButton,
|
|
2048
|
+
showFeedback: e.showFeedback
|
|
2049
|
+
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2050
|
+
startButton: e.startButton,
|
|
2051
|
+
showFeedback: e.showFeedback
|
|
2052
|
+
}), await Promise.race([s, new Promise((e, t) => {
|
|
1965
2053
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
1966
2054
|
})]), await Promise.race([l, new Promise((e, t) => {
|
|
1967
2055
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
1968
|
-
})]), this.attached = !0, this.createPlayerFacade();
|
|
2056
|
+
})]), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
1969
2057
|
}
|
|
1970
2058
|
async startListening() {
|
|
1971
2059
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -1985,6 +2073,15 @@ var Ft = class e {
|
|
|
1985
2073
|
toggleAudioSettings() {
|
|
1986
2074
|
this.iframeHost?.postWidgetToggleAudioSettings();
|
|
1987
2075
|
}
|
|
2076
|
+
async focusCharacter(e) {
|
|
2077
|
+
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2078
|
+
}
|
|
2079
|
+
async setFit(e) {
|
|
2080
|
+
let t = Ft(e);
|
|
2081
|
+
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2082
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2083
|
+
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2084
|
+
}
|
|
1988
2085
|
getLastTurn() {
|
|
1989
2086
|
if (this.conversationCache.length === 0) return [];
|
|
1990
2087
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2066,7 +2163,7 @@ var Ft = class e {
|
|
|
2066
2163
|
};
|
|
2067
2164
|
}
|
|
2068
2165
|
};
|
|
2069
|
-
function
|
|
2166
|
+
function Rt(e) {
|
|
2070
2167
|
return e ? {
|
|
2071
2168
|
textSpeech: e.capabilities.speech.output,
|
|
2072
2169
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2077,26 +2174,26 @@ function It(e) {
|
|
|
2077
2174
|
}
|
|
2078
2175
|
//#endregion
|
|
2079
2176
|
//#region src/widget/dockGeometry.ts
|
|
2080
|
-
var
|
|
2081
|
-
function
|
|
2177
|
+
var zt = "(min-width: 768px)", Bt = 24, Vt = .5, Ht = 1200, Ut = .85, Wt = 9 / 16;
|
|
2178
|
+
function Gt() {
|
|
2082
2179
|
if (typeof window > "u") return 800;
|
|
2083
2180
|
let e = window.screen?.availHeight;
|
|
2084
2181
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2085
2182
|
}
|
|
2086
|
-
function
|
|
2087
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2088
|
-
return s > a && (s = a, o = s /
|
|
2183
|
+
function Kt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Bt, r = typeof window < "u" ? Gt() : 800) {
|
|
2184
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Ut)), a = Math.max(120, e - n * 2), o = Math.min(r * Vt, Ht, i), s = o * Wt;
|
|
2185
|
+
return s > a && (s = a, o = s / Wt, o > i && (o = i, s = o * Wt)), {
|
|
2089
2186
|
width: Math.round(s),
|
|
2090
2187
|
height: Math.round(o)
|
|
2091
2188
|
};
|
|
2092
2189
|
}
|
|
2093
|
-
function
|
|
2190
|
+
function qt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Bt) {
|
|
2094
2191
|
return {
|
|
2095
2192
|
left: Math.max(r, t - e.width - r),
|
|
2096
2193
|
top: Math.max(r, n - e.height - r)
|
|
2097
2194
|
};
|
|
2098
2195
|
}
|
|
2099
|
-
function
|
|
2196
|
+
function Jt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Bt) {
|
|
2100
2197
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2101
2198
|
return {
|
|
2102
2199
|
left: Math.min(Math.max(a, e), o),
|
|
@@ -2104,14 +2201,14 @@ function Kt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
|
|
|
2104
2201
|
};
|
|
2105
2202
|
}
|
|
2106
2203
|
function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2107
|
-
return e(
|
|
2204
|
+
return e(zt).matches;
|
|
2108
2205
|
}
|
|
2109
2206
|
//#endregion
|
|
2110
2207
|
//#region src/widget/mountExperienceWidget.ts
|
|
2111
|
-
function
|
|
2208
|
+
function Yt(e) {
|
|
2112
2209
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2113
2210
|
}
|
|
2114
|
-
function
|
|
2211
|
+
function Xt(e) {
|
|
2115
2212
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2116
2213
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2117
2214
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2119,10 +2216,10 @@ function Jt(e) {
|
|
|
2119
2216
|
function $(e) {
|
|
2120
2217
|
return e === "expanded" || e === "docked";
|
|
2121
2218
|
}
|
|
2122
|
-
var
|
|
2123
|
-
function
|
|
2124
|
-
I
|
|
2125
|
-
let r =
|
|
2219
|
+
var Zt = "<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>", Qt = "<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>", $t = "<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>", en = "<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>";
|
|
2220
|
+
function tn(e, t, n) {
|
|
2221
|
+
re(I);
|
|
2222
|
+
let r = c({
|
|
2126
2223
|
galleryThumb: t.galleryThumb,
|
|
2127
2224
|
avatarImage: t.avatarImage,
|
|
2128
2225
|
backgroundImage: t.backgroundImage,
|
|
@@ -2141,16 +2238,16 @@ function $t(e, t, n) {
|
|
|
2141
2238
|
let e = document.createElement("img");
|
|
2142
2239
|
e.className = "liforma-et__background liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.backgroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2143
2240
|
}
|
|
2144
|
-
let
|
|
2145
|
-
if (
|
|
2146
|
-
r.fallbackImage && (
|
|
2147
|
-
}, { once: !0 }), i.append(
|
|
2241
|
+
let s = document.createElement("img");
|
|
2242
|
+
if (s.className = "liforma-et__avatar liforma-et__media", s.alt = "", s.decoding = "async", s.src = r.avatarImage, s.addEventListener("load", () => o(s), { once: !0 }), s.addEventListener("error", () => {
|
|
2243
|
+
r.fallbackImage && (s.src = r.fallbackImage);
|
|
2244
|
+
}, { once: !0 }), i.append(s), r.foregroundImage) {
|
|
2148
2245
|
let e = document.createElement("img");
|
|
2149
2246
|
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2150
2247
|
}
|
|
2151
2248
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
|
|
2152
2249
|
}
|
|
2153
|
-
function
|
|
2250
|
+
function nn(e) {
|
|
2154
2251
|
return e.startButton ? {
|
|
2155
2252
|
...e.startButton,
|
|
2156
2253
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2162,7 +2259,7 @@ function en(e) {
|
|
|
2162
2259
|
variant: "primary"
|
|
2163
2260
|
};
|
|
2164
2261
|
}
|
|
2165
|
-
function
|
|
2262
|
+
function rn(e) {
|
|
2166
2263
|
let t = !1, n = () => {
|
|
2167
2264
|
t || e();
|
|
2168
2265
|
}, r = () => {
|
|
@@ -2182,12 +2279,12 @@ function tn(e) {
|
|
|
2182
2279
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2183
2280
|
};
|
|
2184
2281
|
}
|
|
2185
|
-
function
|
|
2282
|
+
function an(e, t) {
|
|
2186
2283
|
oe(ie);
|
|
2187
2284
|
let n = t.experienceId?.trim();
|
|
2188
2285
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2189
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2190
|
-
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",
|
|
2286
|
+
let r = t.prefetch ?? "onExpand", i = Yt(t.position), a = document.createElement("div");
|
|
2287
|
+
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", Xt(t.offset));
|
|
2191
2288
|
let o = document.createElement("button");
|
|
2192
2289
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2193
2290
|
let s = document.createElement("div");
|
|
@@ -2207,138 +2304,138 @@ function nn(e, t) {
|
|
|
2207
2304
|
let m = document.createElement("span");
|
|
2208
2305
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2209
2306
|
let h = document.createElement("button");
|
|
2210
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2307
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = $t, h.setAttribute("aria-label", "Reduce");
|
|
2211
2308
|
let g = document.createElement("button");
|
|
2212
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2309
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Zt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2213
2310
|
let _ = document.createElement("button");
|
|
2214
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2215
|
-
let ee = document.createElement("div");
|
|
2216
|
-
ee.className = "liforma-ew__stage";
|
|
2311
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Qt, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2217
2312
|
let v = document.createElement("div");
|
|
2218
|
-
v.className = "liforma-
|
|
2219
|
-
let y =
|
|
2313
|
+
v.className = "liforma-ew__stage";
|
|
2314
|
+
let y = document.createElement("div");
|
|
2315
|
+
y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
|
|
2316
|
+
let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
|
|
2220
2317
|
let e = a.dataset.state;
|
|
2221
2318
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2222
|
-
},
|
|
2223
|
-
|
|
2319
|
+
}, z = () => {
|
|
2320
|
+
j !== null && (clearTimeout(j), j = null);
|
|
2321
|
+
}, se = () => {
|
|
2322
|
+
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2224
2323
|
}, ce = () => {
|
|
2225
|
-
j !== null && (clearTimeout(j), j = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2226
|
-
}, le = () => {
|
|
2227
2324
|
for (let e of [
|
|
2228
2325
|
f,
|
|
2229
2326
|
l,
|
|
2230
2327
|
p
|
|
2231
2328
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2232
2329
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2233
|
-
},
|
|
2330
|
+
}, le = (e, t, n, r) => {
|
|
2234
2331
|
let i = (i) => {
|
|
2235
2332
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
2236
2333
|
};
|
|
2237
2334
|
i(f), i(l);
|
|
2238
2335
|
let a = p.offsetWidth || 120;
|
|
2239
2336
|
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";
|
|
2337
|
+
}, B = (e, t) => {
|
|
2338
|
+
if (R() !== "docked") return;
|
|
2339
|
+
let n = Kt(), r = Jt(e - te, t - ne, n);
|
|
2340
|
+
N = r.left, P = r.top, le(r.left, r.top, n.width, n.height);
|
|
2240
2341
|
}, de = (e, t) => {
|
|
2241
|
-
if (
|
|
2242
|
-
let n =
|
|
2243
|
-
|
|
2244
|
-
}, fe = (e
|
|
2245
|
-
|
|
2246
|
-
let n = Wt(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = Kt(r + e, i + t, n);
|
|
2247
|
-
M = a.left, N = a.top, z(a.left, a.top, n.width, n.height);
|
|
2248
|
-
}, pe = (e) => {
|
|
2249
|
-
F === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), de(e.clientX, e.clientY)));
|
|
2250
|
-
}, B = (e) => {
|
|
2251
|
-
if (P === null || e && e.pointerId !== P) return;
|
|
2252
|
-
let t = F;
|
|
2253
|
-
P = null, F = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && I && (I = !1, window.removeEventListener("pointermove", pe), window.removeEventListener("pointerup", B), window.removeEventListener("pointercancel", B));
|
|
2254
|
-
}, me = (e, t, n) => {
|
|
2255
|
-
if (x || L() !== "docked" || !Q() || P !== null) return;
|
|
2256
|
-
P = n, F = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2257
|
-
let r = f.getBoundingClientRect();
|
|
2258
|
-
ne = e - r.left, re = t - r.top, I || (I = !0, window.addEventListener("pointermove", pe), window.addEventListener("pointerup", B), window.addEventListener("pointercancel", B));
|
|
2342
|
+
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2343
|
+
let n = Kt(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Jt(r + e, i + t, n);
|
|
2344
|
+
N = a.left, P = a.top, le(a.left, a.top, n.width, n.height);
|
|
2345
|
+
}, fe = (e) => {
|
|
2346
|
+
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), B(e.clientX, e.clientY)));
|
|
2259
2347
|
}, V = (e) => {
|
|
2260
|
-
if (
|
|
2261
|
-
|
|
2348
|
+
if (F === null || e && e.pointerId !== F) return;
|
|
2349
|
+
let t = I;
|
|
2350
|
+
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", fe), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
2351
|
+
}, pe = (e, t, n) => {
|
|
2352
|
+
if (S || R() !== "docked" || !Q() || F !== null) return;
|
|
2353
|
+
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2354
|
+
let r = f.getBoundingClientRect();
|
|
2355
|
+
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", fe), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
2356
|
+
}, me = (e) => {
|
|
2357
|
+
if (S || R() !== "docked" || !Q() || F !== null) return;
|
|
2358
|
+
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2262
2359
|
let t = f.getBoundingClientRect();
|
|
2263
|
-
|
|
2360
|
+
N = t.left, P = t.top;
|
|
2264
2361
|
}, H = (e) => {
|
|
2265
|
-
|
|
2266
|
-
},
|
|
2267
|
-
|
|
2268
|
-
},
|
|
2269
|
-
let e = Q(), t =
|
|
2362
|
+
I === "player" && (F === null || e.pointerId !== F || de(e.dx, e.dy));
|
|
2363
|
+
}, U = (e) => {
|
|
2364
|
+
I === "player" && (F === null || e.pointerId !== F || V());
|
|
2365
|
+
}, W = () => {
|
|
2366
|
+
let e = Q(), t = R();
|
|
2270
2367
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2271
2368
|
h.hidden = !0;
|
|
2272
2369
|
return;
|
|
2273
2370
|
}
|
|
2274
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2275
|
-
},
|
|
2276
|
-
let t =
|
|
2277
|
-
n =
|
|
2278
|
-
},
|
|
2371
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = en, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = $t, h.setAttribute("aria-label", "Reduce"));
|
|
2372
|
+
}, he = (e) => {
|
|
2373
|
+
let t = Kt(), n = e && N !== null && P !== null ? Jt(N, P, t) : qt(t);
|
|
2374
|
+
n = Jt(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), W();
|
|
2375
|
+
}, ge = () => {
|
|
2279
2376
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2280
2377
|
requestAnimationFrame(() => {
|
|
2281
|
-
|
|
2378
|
+
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2282
2379
|
});
|
|
2283
2380
|
});
|
|
2284
|
-
},
|
|
2285
|
-
if (
|
|
2381
|
+
}, _e = (e) => {
|
|
2382
|
+
if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
|
|
2286
2383
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2287
2384
|
return;
|
|
2288
2385
|
}
|
|
2289
|
-
|
|
2290
|
-
if (
|
|
2386
|
+
M = setTimeout(() => {
|
|
2387
|
+
if (M = null, S || !$(a.dataset.state)) {
|
|
2291
2388
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2292
2389
|
return;
|
|
2293
2390
|
}
|
|
2294
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2391
|
+
a.classList.remove("liforma-ew--layout-settling"), ge();
|
|
2295
2392
|
}, 220);
|
|
2296
|
-
},
|
|
2297
|
-
|
|
2298
|
-
|
|
2393
|
+
}, ve = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2394
|
+
z(), j = setTimeout(() => {
|
|
2395
|
+
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2299
2396
|
}, 280);
|
|
2300
|
-
})),
|
|
2397
|
+
})), ye = {
|
|
2301
2398
|
galleryThumb: t.galleryThumb,
|
|
2302
2399
|
avatarImage: t.avatarImage,
|
|
2303
2400
|
backgroundImage: t.backgroundImage,
|
|
2304
2401
|
foregroundImage: t.foregroundImage,
|
|
2305
2402
|
fallbackImage: t.fallbackImage
|
|
2306
|
-
},
|
|
2403
|
+
}, G = (e) => {
|
|
2307
2404
|
if (!e) {
|
|
2308
|
-
|
|
2405
|
+
y.hidden = !0, y.textContent = "";
|
|
2309
2406
|
return;
|
|
2310
2407
|
}
|
|
2311
|
-
|
|
2312
|
-
},
|
|
2408
|
+
y.hidden = !1, y.textContent = e;
|
|
2409
|
+
}, be = (e) => {
|
|
2313
2410
|
if (!e) {
|
|
2314
2411
|
c.hidden = !0, c.textContent = "";
|
|
2315
2412
|
return;
|
|
2316
2413
|
}
|
|
2317
2414
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
2415
|
+
}, xe = () => {
|
|
2416
|
+
ee = !0, o.disabled = !1, be(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2318
2417
|
}, Se = () => {
|
|
2319
|
-
|
|
2320
|
-
}, Ce = () => {
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
if (we(be)) {
|
|
2328
|
-
Se();
|
|
2418
|
+
C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2419
|
+
}, Ce = (e) => {
|
|
2420
|
+
k?.(), k = null;
|
|
2421
|
+
let t = tn(s, e, { parallax: ae });
|
|
2422
|
+
return t ? (k = t, !0) : !1;
|
|
2423
|
+
}, we = () => {
|
|
2424
|
+
if (Ce(ye)) {
|
|
2425
|
+
xe();
|
|
2329
2426
|
return;
|
|
2330
2427
|
}
|
|
2331
|
-
|
|
2332
|
-
if (!
|
|
2333
|
-
if (!
|
|
2334
|
-
|
|
2428
|
+
be("Loading…"), ue(n, { signal: re.signal }).then((e) => {
|
|
2429
|
+
if (!S) {
|
|
2430
|
+
if (!Ce({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
2431
|
+
xe();
|
|
2335
2432
|
}
|
|
2336
2433
|
}).catch((e) => {
|
|
2337
|
-
if (
|
|
2434
|
+
if (S || re.signal.aborted) return;
|
|
2338
2435
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2339
|
-
|
|
2436
|
+
be("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2340
2437
|
});
|
|
2341
|
-
},
|
|
2438
|
+
}, Te = () => ({
|
|
2342
2439
|
experienceId: n,
|
|
2343
2440
|
ui: "widget",
|
|
2344
2441
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -2348,231 +2445,236 @@ function nn(e, t) {
|
|
|
2348
2445
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2349
2446
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
2350
2447
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2351
|
-
}),
|
|
2448
|
+
}), Ee = () => ({
|
|
2352
2449
|
...t.fit ? { fit: t.fit } : {},
|
|
2353
|
-
startButton:
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2450
|
+
startButton: nn(t),
|
|
2451
|
+
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2452
|
+
}), K = (e = !0) => {
|
|
2453
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", G(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
2454
|
+
}, De = () => {
|
|
2455
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = O), he(!0), W(), b?.setWidgetChrome("docked");
|
|
2456
|
+
}, Oe = (e) => {
|
|
2359
2457
|
e.on("started", () => {
|
|
2360
|
-
|
|
2458
|
+
S || (E = !0, a.dataset.live = "true", G(null), t.onStarted?.(), $(a.dataset.state) && ge());
|
|
2459
|
+
}), e.on("feedback", (e) => {
|
|
2460
|
+
S || t.onFeedback?.(e);
|
|
2461
|
+
}), e.on("feedbackFailed", (e) => {
|
|
2462
|
+
S || t.onFeedbackFailed?.(e);
|
|
2361
2463
|
});
|
|
2464
|
+
}, ke = () => {
|
|
2465
|
+
se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), ee && (o.disabled = !1), G(null), typeof document < "u" && (document.body.style.overflow = O), W();
|
|
2362
2466
|
}, Ae = () => {
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
let e = y;
|
|
2367
|
-
y = null, e?.destroy(), ee.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
2467
|
+
z(), se(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
|
|
2468
|
+
let e = b;
|
|
2469
|
+
b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
2368
2470
|
}, q = () => {
|
|
2369
|
-
if (!
|
|
2370
|
-
if (
|
|
2371
|
-
let e =
|
|
2471
|
+
if (!S && $(a.dataset.state)) {
|
|
2472
|
+
if (V(), x = !1, b && T) {
|
|
2473
|
+
let e = b;
|
|
2372
2474
|
(async () => {
|
|
2373
|
-
|
|
2475
|
+
E && (await ve(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), ke(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && Se(), t.onCollapsed?.(), t.onClose?.());
|
|
2374
2476
|
})();
|
|
2375
2477
|
return;
|
|
2376
2478
|
}
|
|
2377
|
-
|
|
2479
|
+
Ae(), ke(), t.onCollapsed?.(), t.onClose?.();
|
|
2378
2480
|
}
|
|
2379
2481
|
}, je = () => {
|
|
2380
|
-
|
|
2381
|
-
|
|
2482
|
+
S || Q() && R() === "expanded" && _e(() => {
|
|
2483
|
+
De();
|
|
2382
2484
|
});
|
|
2383
|
-
},
|
|
2384
|
-
|
|
2385
|
-
|
|
2485
|
+
}, J = () => {
|
|
2486
|
+
S || R() === "docked" && (V(), _e(() => {
|
|
2487
|
+
ce(), K(!1), b?.setWidgetChrome("expanded");
|
|
2386
2488
|
}));
|
|
2489
|
+
}, Me = () => {
|
|
2490
|
+
!b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), b.setWidgetChrome("expanded"), x = !1, ge());
|
|
2387
2491
|
}, Ne = () => {
|
|
2388
|
-
!
|
|
2389
|
-
}, Pe = () => {
|
|
2390
|
-
|
|
2391
|
-
}, Fe = (
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
C = !0;
|
|
2396
|
-
let e = E;
|
|
2492
|
+
!b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, C || b.setWidgetChrome("expanded"));
|
|
2493
|
+
}, Pe = (e) => {
|
|
2494
|
+
S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, E && ge());
|
|
2495
|
+
}, Fe = () => {
|
|
2496
|
+
if (S || w || C || b || $(a.dataset.state)) return;
|
|
2497
|
+
w = !0;
|
|
2498
|
+
let e = D;
|
|
2397
2499
|
l.hidden = !1, (async () => {
|
|
2398
2500
|
try {
|
|
2399
|
-
let t = await
|
|
2400
|
-
if (
|
|
2501
|
+
let t = await Lt.startSession(Te());
|
|
2502
|
+
if (S || e !== D) {
|
|
2401
2503
|
t.destroy();
|
|
2402
2504
|
return;
|
|
2403
2505
|
}
|
|
2404
|
-
|
|
2506
|
+
b = t, Oe(t);
|
|
2405
2507
|
let n = await t.attach({
|
|
2406
2508
|
container: l,
|
|
2407
|
-
...
|
|
2509
|
+
...Ee(),
|
|
2408
2510
|
onWidgetReady: () => {
|
|
2409
|
-
|
|
2511
|
+
S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Se());
|
|
2410
2512
|
},
|
|
2411
2513
|
onWidgetExpand: () => {
|
|
2412
|
-
|
|
2514
|
+
Pe(e);
|
|
2413
2515
|
},
|
|
2414
2516
|
onWidgetAudioSettings: (e) => {
|
|
2415
|
-
|
|
2517
|
+
S || ze(e);
|
|
2416
2518
|
},
|
|
2417
2519
|
onWidgetDragStart: (e) => {
|
|
2418
|
-
|
|
2520
|
+
S || me(e);
|
|
2419
2521
|
},
|
|
2420
2522
|
onWidgetDragMove: (e) => {
|
|
2421
|
-
|
|
2523
|
+
S || H(e);
|
|
2422
2524
|
},
|
|
2423
2525
|
onWidgetDragEnd: (e) => {
|
|
2424
|
-
|
|
2526
|
+
S || U(e);
|
|
2425
2527
|
},
|
|
2426
2528
|
onPlayerStatusChange: (e) => {
|
|
2427
|
-
|
|
2529
|
+
S || e === "error" && $(a.dataset.state) && G("Could not load the experience.");
|
|
2428
2530
|
}
|
|
2429
2531
|
});
|
|
2430
|
-
if (
|
|
2431
|
-
t.destroy(),
|
|
2532
|
+
if (S || e !== D) {
|
|
2533
|
+
t.destroy(), b === t && (b = null);
|
|
2432
2534
|
return;
|
|
2433
2535
|
}
|
|
2434
2536
|
n.on("close", () => {
|
|
2435
|
-
|
|
2537
|
+
S || q();
|
|
2436
2538
|
});
|
|
2437
2539
|
} catch (n) {
|
|
2438
|
-
if (
|
|
2439
|
-
|
|
2540
|
+
if (S || e !== D) return;
|
|
2541
|
+
w = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
2440
2542
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2441
2543
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
2442
2544
|
}
|
|
2443
2545
|
})();
|
|
2444
|
-
},
|
|
2445
|
-
if (
|
|
2446
|
-
if (
|
|
2447
|
-
|
|
2546
|
+
}, Ie = () => {
|
|
2547
|
+
if (S || x || !ee || $(a.dataset.state)) return;
|
|
2548
|
+
if (b && E) {
|
|
2549
|
+
Me();
|
|
2448
2550
|
return;
|
|
2449
2551
|
}
|
|
2450
|
-
if (
|
|
2451
|
-
|
|
2552
|
+
if (b && T) {
|
|
2553
|
+
Ne();
|
|
2452
2554
|
return;
|
|
2453
2555
|
}
|
|
2454
|
-
let e = ++
|
|
2455
|
-
|
|
2556
|
+
let e = ++D;
|
|
2557
|
+
x = !0, C = !1, w = !1, T = !1, E = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
2456
2558
|
try {
|
|
2457
|
-
|
|
2458
|
-
let t = await
|
|
2459
|
-
if (
|
|
2559
|
+
K();
|
|
2560
|
+
let t = await Lt.startSession(Te());
|
|
2561
|
+
if (S || e !== D) {
|
|
2460
2562
|
t.destroy();
|
|
2461
2563
|
return;
|
|
2462
2564
|
}
|
|
2463
|
-
|
|
2565
|
+
b = t, Oe(t);
|
|
2464
2566
|
let n = await t.attach({
|
|
2465
|
-
container:
|
|
2466
|
-
...
|
|
2567
|
+
container: v,
|
|
2568
|
+
...Ee(),
|
|
2467
2569
|
onWidgetAudioSettings: (e) => {
|
|
2468
|
-
|
|
2570
|
+
S || ze(e);
|
|
2469
2571
|
},
|
|
2470
2572
|
onWidgetDragStart: (e) => {
|
|
2471
|
-
|
|
2573
|
+
S || me(e);
|
|
2472
2574
|
},
|
|
2473
2575
|
onWidgetDragMove: (e) => {
|
|
2474
|
-
|
|
2576
|
+
S || H(e);
|
|
2475
2577
|
},
|
|
2476
2578
|
onWidgetDragEnd: (e) => {
|
|
2477
|
-
|
|
2579
|
+
S || U(e);
|
|
2478
2580
|
},
|
|
2479
2581
|
onPlayerStatusChange: (e) => {
|
|
2480
|
-
|
|
2582
|
+
S || (e === "error" ? G("Could not load the experience.") : $(a.dataset.state) && G(null));
|
|
2481
2583
|
}
|
|
2482
2584
|
});
|
|
2483
|
-
if (
|
|
2484
|
-
t.destroy(),
|
|
2585
|
+
if (S || e !== D) {
|
|
2586
|
+
t.destroy(), b === t && (b = null);
|
|
2485
2587
|
return;
|
|
2486
2588
|
}
|
|
2487
|
-
|
|
2488
|
-
|
|
2589
|
+
T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2590
|
+
S || q();
|
|
2489
2591
|
});
|
|
2490
2592
|
} catch (n) {
|
|
2491
|
-
if (
|
|
2593
|
+
if (S || e !== D) return;
|
|
2492
2594
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2493
|
-
|
|
2595
|
+
G(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
2494
2596
|
} finally {
|
|
2495
|
-
e ===
|
|
2597
|
+
e === D && (x = !1);
|
|
2496
2598
|
}
|
|
2497
2599
|
})();
|
|
2498
|
-
},
|
|
2499
|
-
if (!(
|
|
2500
|
-
if (
|
|
2501
|
-
|
|
2600
|
+
}, Le = () => {
|
|
2601
|
+
if (!(S || $(a.dataset.state))) {
|
|
2602
|
+
if (b && E) {
|
|
2603
|
+
Me();
|
|
2502
2604
|
return;
|
|
2503
2605
|
}
|
|
2504
|
-
if (
|
|
2505
|
-
|
|
2606
|
+
if (b && T) {
|
|
2607
|
+
Ne();
|
|
2506
2608
|
return;
|
|
2507
2609
|
}
|
|
2508
|
-
if (
|
|
2509
|
-
|
|
2610
|
+
if (w || b) {
|
|
2611
|
+
K();
|
|
2510
2612
|
return;
|
|
2511
2613
|
}
|
|
2512
|
-
|
|
2614
|
+
Ie();
|
|
2513
2615
|
}
|
|
2514
|
-
},
|
|
2515
|
-
if (e.stopPropagation(),
|
|
2616
|
+
}, Re = (e) => {
|
|
2617
|
+
if (e.stopPropagation(), R() === "expanded") {
|
|
2516
2618
|
je();
|
|
2517
2619
|
return;
|
|
2518
2620
|
}
|
|
2519
|
-
|
|
2520
|
-
},
|
|
2621
|
+
R() === "docked" && J();
|
|
2622
|
+
}, ze = (e) => {
|
|
2521
2623
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
2522
|
-
},
|
|
2523
|
-
e.stopPropagation(), $(a.dataset.state) &&
|
|
2624
|
+
}, Be = (e) => {
|
|
2625
|
+
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2626
|
+
}, Y = (e) => {
|
|
2627
|
+
R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
|
|
2524
2628
|
}, Ve = (e) => {
|
|
2525
|
-
L() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), me(e.clientX, e.clientY, e.pointerId)));
|
|
2526
|
-
}, He = (e) => {
|
|
2527
2629
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
|
|
2528
|
-
},
|
|
2529
|
-
if (!
|
|
2530
|
-
if (
|
|
2630
|
+
}, He = () => {
|
|
2631
|
+
if (!S) {
|
|
2632
|
+
if (R() === "docked") {
|
|
2531
2633
|
if (!Q()) {
|
|
2532
|
-
|
|
2634
|
+
J();
|
|
2533
2635
|
return;
|
|
2534
2636
|
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
}) :
|
|
2637
|
+
E ? _e(() => {
|
|
2638
|
+
he(!0);
|
|
2639
|
+
}) : he(!0);
|
|
2538
2640
|
return;
|
|
2539
2641
|
}
|
|
2540
|
-
|
|
2642
|
+
W();
|
|
2541
2643
|
}
|
|
2542
|
-
},
|
|
2543
|
-
if (!
|
|
2544
|
-
if (
|
|
2545
|
-
|
|
2644
|
+
}, Ue = typeof window < "u" ? window.matchMedia(zt) : null, We = () => {
|
|
2645
|
+
if (!S) {
|
|
2646
|
+
if (R() === "docked" && !Q()) {
|
|
2647
|
+
J();
|
|
2546
2648
|
return;
|
|
2547
2649
|
}
|
|
2548
|
-
|
|
2650
|
+
W();
|
|
2549
2651
|
}
|
|
2550
2652
|
};
|
|
2551
|
-
return o.addEventListener("click",
|
|
2653
|
+
return o.addEventListener("click", Le), d.addEventListener("click", q), _.addEventListener("click", (e) => {
|
|
2552
2654
|
e.stopPropagation(), q();
|
|
2553
|
-
}), h.addEventListener("click",
|
|
2554
|
-
|
|
2555
|
-
}) : r === "idle" && (
|
|
2556
|
-
|
|
2655
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Y), window.addEventListener("keydown", Ve), window.addEventListener("resize", He), Ue?.addEventListener("change", We), we(), W(), r === "eager" ? queueMicrotask(() => {
|
|
2656
|
+
S || Fe();
|
|
2657
|
+
}) : r === "idle" && (A = rn(() => {
|
|
2658
|
+
S || Fe();
|
|
2557
2659
|
})), {
|
|
2558
2660
|
root: a,
|
|
2559
|
-
expand:
|
|
2661
|
+
expand: Le,
|
|
2560
2662
|
collapse: q,
|
|
2561
2663
|
dock: je,
|
|
2562
|
-
maximize:
|
|
2664
|
+
maximize: J,
|
|
2563
2665
|
prefetch() {
|
|
2564
2666
|
if (r === "onExpand") {
|
|
2565
|
-
|
|
2667
|
+
Fe();
|
|
2566
2668
|
return;
|
|
2567
2669
|
}
|
|
2568
|
-
|
|
2670
|
+
Fe();
|
|
2569
2671
|
},
|
|
2570
2672
|
destroy() {
|
|
2571
|
-
|
|
2673
|
+
S || (S = !0, V(), A?.(), A = null, re.abort(), k?.(), k = null, window.removeEventListener("keydown", Ve), window.removeEventListener("resize", He), Ue?.removeEventListener("change", We), Ae(), ke(), e.replaceChildren());
|
|
2572
2674
|
}
|
|
2573
2675
|
};
|
|
2574
2676
|
}
|
|
2575
2677
|
//#endregion
|
|
2576
|
-
export {
|
|
2678
|
+
export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Lt as Experience, B as LiformaError, X as SPEECH_LIMITS, ut as SpeechBufferTimeoutError, Z as SpeechRuntimeError, lt as SpeechUtteranceClosedError, ct as UnsupportedSpeechOperationError, E as attachImageReady, T as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, ee as getDefaultLazyRootMargin, O as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, an as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
|
|
2577
2679
|
|
|
2578
2680
|
//# sourceMappingURL=index.js.map
|