@liforma/client 0.4.6 → 0.4.9
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 +36 -0
- package/README.md +23 -0
- package/dist/next/index.js +525 -182
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +4 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/next/thumbnail.d.ts +5 -0
- package/dist/next/next/thumbnail.d.ts.map +1 -0
- package/dist/next/react/thumbnail.d.ts +4 -0
- package/dist/next/react/thumbnail.d.ts.map +1 -0
- package/dist/next/thumbnail.js +396 -0
- package/dist/next/thumbnail.js.map +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +4 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +13 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +39 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +18 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +5 -1
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/sdkRelease.d.ts +3 -0
- package/dist/next/v2/sdkRelease.d.ts.map +1 -0
- package/dist/next/v2/types/sessionInteraction.d.ts +17 -0
- 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 +4 -0
- package/dist/next/widget/types.d.ts.map +1 -1
- package/dist/npm/index.js +551 -222
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/svelte/experienceLoadError.d.ts.map +1 -1
- package/dist/npm/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/npm/svelte/experienceLoadErrorStyles.d.ts.map +1 -1
- package/dist/npm/thumbnail/index.js +231 -0
- package/dist/npm/thumbnail/index.js.map +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +4 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +13 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +39 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +18 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +5 -1
- 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/npm.d.ts +1 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/sdkRelease.d.ts +3 -0
- package/dist/npm/v2/sdkRelease.d.ts.map +1 -0
- package/dist/npm/v2/thumbnail-cdn.d.ts +17 -0
- package/dist/npm/v2/thumbnail-cdn.d.ts.map +1 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts +17 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/widget/types.d.ts +4 -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/experienceComponentTypes.d.ts +8 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +991 -646
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/thumbnail.d.ts +4 -0
- package/dist/react/react/thumbnail.d.ts.map +1 -0
- package/dist/react/svelte/experienceLoadError.d.ts.map +1 -1
- package/dist/react/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/react/svelte/experienceLoadErrorStyles.d.ts.map +1 -1
- package/dist/react/thumbnail.js +396 -0
- package/dist/react/thumbnail.js.map +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +4 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +13 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +39 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +18 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +5 -1
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/sdkRelease.d.ts +3 -0
- package/dist/react/v2/sdkRelease.d.ts.map +1 -0
- package/dist/react/v2/types/sessionInteraction.d.ts +17 -0
- 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 +4 -0
- package/dist/react/widget/types.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +3 -810
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +222 -0
- package/dist/sdk/v2/thumbnail.js.map +1 -0
- package/dist/svelte/Experience.svelte +13 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/dist/svelte/ExperienceThumbnail.svelte +1 -1
- package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -1
- package/dist/svelte/experienceLoadError.js +37 -15
- package/dist/svelte/experienceLoadError.test.js +8 -0
- package/dist/svelte/experienceLoadErrorOverlay.js +1 -1
- package/dist/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/svelte/experienceLoadErrorStyles.js +1 -0
- package/dist/svelte/thumbnail.d.ts +2 -0
- package/dist/svelte/thumbnail.js +1 -0
- package/package.json +24 -6
package/dist/next/index.js
CHANGED
|
@@ -57,7 +57,10 @@ function v(e = {}) {
|
|
|
57
57
|
if (t instanceof Response) return t;
|
|
58
58
|
}
|
|
59
59
|
let v = { experienceId: u }, y = l?.locale?.trim() || l?.language?.trim();
|
|
60
|
-
y && (v.locale = y), l?.mode && (v.mode = l.mode), l?.speechInputMode && (v.speechInputMode = l.speechInputMode), l?.speechOnly === !0 && (v.speechOnly = !0), l?.speechOnly === !1 && (v.speechOnly = !1), l?.processorId?.trim() && (v.processorId = l.processorId.trim()), l?.attribution && typeof l.attribution == "object" && (v.attribution = l.attribution)
|
|
60
|
+
if (y && (v.locale = y), l?.mode && (v.mode = l.mode), l?.speechInputMode && (v.speechInputMode = l.speechInputMode), l?.speechOnly === !0 && (v.speechOnly = !0), l?.speechOnly === !1 && (v.speechOnly = !1), l?.processorId?.trim() && (v.processorId = l.processorId.trim()), l?.attribution && typeof l.attribution == "object" && (v.attribution = l.attribution), l?.alreadyConverted !== void 0) {
|
|
61
|
+
if (!Array.isArray(l.alreadyConverted) || l.alreadyConverted.some((e) => typeof e != "string")) return c({ message: "Invalid alreadyConverted." }, 400);
|
|
62
|
+
l.alreadyConverted.length && (v.alreadyConverted = l.alreadyConverted);
|
|
63
|
+
}
|
|
61
64
|
let b = i.headers.get("Idempotency-Key")?.trim(), x = await r(`${o}/v1/sessions`, {
|
|
62
65
|
method: "POST",
|
|
63
66
|
headers: {
|
|
@@ -69,12 +72,23 @@ function v(e = {}) {
|
|
|
69
72
|
body: JSON.stringify(v)
|
|
70
73
|
});
|
|
71
74
|
if (!x.ok) {
|
|
72
|
-
let e = _(x.status), t = "Could not start session.";
|
|
75
|
+
let e = _(x.status), t = "Could not start session.", n = "MINT_FAILED", r = x.headers.get("Liforma-Request-Id")?.trim() || void 0;
|
|
73
76
|
try {
|
|
74
|
-
let e = await x.json();
|
|
75
|
-
typeof
|
|
77
|
+
let e = await x.json(), i = e.error && typeof e.error == "object" ? e.error : void 0, a = i?.message ?? e.message;
|
|
78
|
+
typeof a == "string" && a.trim() && (t = a.trim());
|
|
79
|
+
let o = i?.code ?? e.code;
|
|
80
|
+
typeof o == "string" && o.trim() && (n = o.trim());
|
|
81
|
+
let s = i?.requestId ?? e.requestId;
|
|
82
|
+
typeof s == "string" && s.trim() && (r = s.trim());
|
|
76
83
|
} catch {}
|
|
77
|
-
return c({
|
|
84
|
+
return c({
|
|
85
|
+
message: t,
|
|
86
|
+
error: {
|
|
87
|
+
code: n,
|
|
88
|
+
message: t,
|
|
89
|
+
...r ? { requestId: r } : {}
|
|
90
|
+
}
|
|
91
|
+
}, e);
|
|
78
92
|
}
|
|
79
93
|
let S = await x.json();
|
|
80
94
|
return new Response(JSON.stringify(S), {
|
|
@@ -680,7 +694,8 @@ function ke(e, t) {
|
|
|
680
694
|
...(() => {
|
|
681
695
|
let e = Ee(t.attribution);
|
|
682
696
|
return e ? { attribution: e } : {};
|
|
683
|
-
})()
|
|
697
|
+
})(),
|
|
698
|
+
...t.alreadyConverted?.length ? { alreadyConverted: [...t.alreadyConverted] } : {}
|
|
684
699
|
})
|
|
685
700
|
}
|
|
686
701
|
};
|
|
@@ -824,7 +839,7 @@ function He(e, t) {
|
|
|
824
839
|
let i = Ve(t);
|
|
825
840
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
826
841
|
let a = Ee(t?.attribution);
|
|
827
|
-
return a && (n.attribution = a), n;
|
|
842
|
+
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
828
843
|
}
|
|
829
844
|
async function Ue(e, t) {
|
|
830
845
|
let n = ve(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
@@ -942,7 +957,7 @@ var Qe = new Set([1, 2]);
|
|
|
942
957
|
function $e(e) {
|
|
943
958
|
return typeof e == "number" && Qe.has(e);
|
|
944
959
|
}
|
|
945
|
-
var et = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
|
|
960
|
+
var et = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow.interactionChange".split("."));
|
|
946
961
|
function tt(e) {
|
|
947
962
|
if (!e || typeof e != "object") return null;
|
|
948
963
|
let t = e;
|
|
@@ -1168,6 +1183,9 @@ function ft(e) {
|
|
|
1168
1183
|
case "fullWindow":
|
|
1169
1184
|
s(i.payload.active);
|
|
1170
1185
|
break;
|
|
1186
|
+
case "interactionChange":
|
|
1187
|
+
e.onInteractionChange?.(i.payload.interaction);
|
|
1188
|
+
break;
|
|
1171
1189
|
}
|
|
1172
1190
|
};
|
|
1173
1191
|
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
@@ -1414,6 +1432,23 @@ function ft(e) {
|
|
|
1414
1432
|
}
|
|
1415
1433
|
});
|
|
1416
1434
|
},
|
|
1435
|
+
setInteraction(e) {
|
|
1436
|
+
return C({
|
|
1437
|
+
type: "setInteraction",
|
|
1438
|
+
schemaVersion: 2,
|
|
1439
|
+
payload: {
|
|
1440
|
+
correlationId: Z(),
|
|
1441
|
+
interaction: e
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
},
|
|
1445
|
+
getInteraction() {
|
|
1446
|
+
return C({
|
|
1447
|
+
type: "getInteraction",
|
|
1448
|
+
schemaVersion: 2,
|
|
1449
|
+
payload: { correlationId: Z() }
|
|
1450
|
+
});
|
|
1451
|
+
},
|
|
1417
1452
|
conversion(e) {
|
|
1418
1453
|
return C({
|
|
1419
1454
|
type: "conversion",
|
|
@@ -1424,6 +1459,28 @@ function ft(e) {
|
|
|
1424
1459
|
}
|
|
1425
1460
|
});
|
|
1426
1461
|
},
|
|
1462
|
+
engage() {
|
|
1463
|
+
return C({
|
|
1464
|
+
type: "engage",
|
|
1465
|
+
schemaVersion: 2,
|
|
1466
|
+
payload: { correlationId: Z() }
|
|
1467
|
+
});
|
|
1468
|
+
},
|
|
1469
|
+
reportSdkError(e) {
|
|
1470
|
+
return C({
|
|
1471
|
+
type: "reportSdkError",
|
|
1472
|
+
schemaVersion: 2,
|
|
1473
|
+
payload: {
|
|
1474
|
+
correlationId: Z(),
|
|
1475
|
+
errorCode: e.errorCode,
|
|
1476
|
+
message: e.message,
|
|
1477
|
+
stack: e.stack,
|
|
1478
|
+
severity: e.severity,
|
|
1479
|
+
operation: e.operation,
|
|
1480
|
+
release: e.release
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
},
|
|
1427
1484
|
destroy() {
|
|
1428
1485
|
if (!r) {
|
|
1429
1486
|
r = !0, i && s(!1);
|
|
@@ -1449,54 +1506,276 @@ function pt(e) {
|
|
|
1449
1506
|
};
|
|
1450
1507
|
}
|
|
1451
1508
|
//#endregion
|
|
1452
|
-
//#region src/v2/
|
|
1453
|
-
var mt =
|
|
1454
|
-
|
|
1509
|
+
//#region src/v2/sdkRelease.ts
|
|
1510
|
+
var mt = `sdk@${{
|
|
1511
|
+
name: "@liforma/client",
|
|
1512
|
+
version: "0.4.9",
|
|
1513
|
+
type: "module",
|
|
1514
|
+
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1515
|
+
license: "MIT",
|
|
1516
|
+
homepage: "https://docs.liforma.ai",
|
|
1517
|
+
repository: {
|
|
1518
|
+
type: "git",
|
|
1519
|
+
url: "git+https://github.com/LiformaLtd/cdn.liforma.ai.git"
|
|
1520
|
+
},
|
|
1521
|
+
bugs: { url: "https://github.com/LiformaLtd/cdn.liforma.ai/issues" },
|
|
1522
|
+
publishConfig: { access: "public" },
|
|
1523
|
+
sideEffects: !1,
|
|
1524
|
+
exports: {
|
|
1525
|
+
".": {
|
|
1526
|
+
types: "./dist/npm/v2/npm.d.ts",
|
|
1527
|
+
import: "./dist/npm/index.js"
|
|
1528
|
+
},
|
|
1529
|
+
"./svelte": {
|
|
1530
|
+
types: "./dist/svelte/index.d.ts",
|
|
1531
|
+
import: "./dist/svelte/index.js",
|
|
1532
|
+
svelte: "./dist/svelte/index.js"
|
|
1533
|
+
},
|
|
1534
|
+
"./svelte/thumbnail": {
|
|
1535
|
+
types: "./dist/svelte/thumbnail.d.ts",
|
|
1536
|
+
import: "./dist/svelte/thumbnail.js",
|
|
1537
|
+
svelte: "./dist/svelte/thumbnail.js"
|
|
1538
|
+
},
|
|
1539
|
+
"./thumbnail": {
|
|
1540
|
+
types: "./dist/npm/thumbnail/index.d.ts",
|
|
1541
|
+
import: "./dist/npm/thumbnail/index.js"
|
|
1542
|
+
},
|
|
1543
|
+
"./react": {
|
|
1544
|
+
types: "./dist/react/react/index.d.ts",
|
|
1545
|
+
import: "./dist/react/index.js"
|
|
1546
|
+
},
|
|
1547
|
+
"./react/thumbnail": {
|
|
1548
|
+
types: "./dist/react/react/thumbnail.d.ts",
|
|
1549
|
+
import: "./dist/react/thumbnail.js"
|
|
1550
|
+
},
|
|
1551
|
+
"./next": {
|
|
1552
|
+
types: "./dist/next/next/index.d.ts",
|
|
1553
|
+
import: "./dist/next/index.js"
|
|
1554
|
+
},
|
|
1555
|
+
"./next/thumbnail": {
|
|
1556
|
+
types: "./dist/next/next/thumbnail.d.ts",
|
|
1557
|
+
import: "./dist/next/thumbnail.js"
|
|
1558
|
+
},
|
|
1559
|
+
"./byo": {
|
|
1560
|
+
types: "./dist/byo/index.d.ts",
|
|
1561
|
+
import: "./dist/byo/index.js"
|
|
1562
|
+
},
|
|
1563
|
+
"./elevenlabs": {
|
|
1564
|
+
types: "./dist/elevenlabs/index.d.ts",
|
|
1565
|
+
import: "./dist/elevenlabs/index.js"
|
|
1566
|
+
},
|
|
1567
|
+
"./openai": {
|
|
1568
|
+
types: "./dist/openai/index.d.ts",
|
|
1569
|
+
import: "./dist/openai/index.js"
|
|
1570
|
+
},
|
|
1571
|
+
"./deepgram": {
|
|
1572
|
+
types: "./dist/deepgram/index.d.ts",
|
|
1573
|
+
import: "./dist/deepgram/index.js"
|
|
1574
|
+
},
|
|
1575
|
+
"./google": {
|
|
1576
|
+
types: "./dist/google/index.d.ts",
|
|
1577
|
+
import: "./dist/google/index.js"
|
|
1578
|
+
},
|
|
1579
|
+
"./livekit": {
|
|
1580
|
+
types: "./dist/livekit/index.d.ts",
|
|
1581
|
+
import: "./dist/livekit/index.js"
|
|
1582
|
+
}
|
|
1583
|
+
},
|
|
1584
|
+
files: [
|
|
1585
|
+
"dist/npm",
|
|
1586
|
+
"dist/svelte",
|
|
1587
|
+
"dist/react",
|
|
1588
|
+
"dist/next",
|
|
1589
|
+
"dist/byo",
|
|
1590
|
+
"dist/elevenlabs",
|
|
1591
|
+
"dist/openai",
|
|
1592
|
+
"dist/deepgram",
|
|
1593
|
+
"dist/google",
|
|
1594
|
+
"dist/livekit",
|
|
1595
|
+
"dist/sdk",
|
|
1596
|
+
"README.md",
|
|
1597
|
+
"CHANGELOG.md",
|
|
1598
|
+
"LICENSE"
|
|
1599
|
+
],
|
|
1600
|
+
peerDependencies: {
|
|
1601
|
+
"@elevenlabs/client": ">=1.0.0",
|
|
1602
|
+
"livekit-client": ">=2.0.0",
|
|
1603
|
+
react: "^18.0.0 || ^19.0.0",
|
|
1604
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
1605
|
+
svelte: "^5.0.0"
|
|
1606
|
+
},
|
|
1607
|
+
peerDependenciesMeta: {
|
|
1608
|
+
svelte: { optional: !0 },
|
|
1609
|
+
react: { optional: !0 },
|
|
1610
|
+
"react-dom": { optional: !0 },
|
|
1611
|
+
"@elevenlabs/client": { optional: !0 },
|
|
1612
|
+
"livekit-client": { optional: !0 }
|
|
1613
|
+
},
|
|
1614
|
+
scripts: {
|
|
1615
|
+
build: "npm run build:v2 && npm run build:npm && npm run build:svelte && npm run build:react && npm run build:next && npm run build:byo && npm run build:elevenlabs && npm run build:openai && npm run build:deepgram && npm run build:google && npm run build:livekit && npm run copy:preview",
|
|
1616
|
+
"build:react": "vite build --config vite.config.react.ts && vite build --config vite.config.react-thumbnail.ts && tsc -p tsconfig.react.json",
|
|
1617
|
+
"build:next": "vite build --config vite.config.next.ts && vite build --config vite.config.next-thumbnail.ts && tsc -p tsconfig.next.json",
|
|
1618
|
+
"build:byo": "vite build --config vite.config.byo.ts && tsc -p tsconfig.byo.json",
|
|
1619
|
+
"build:elevenlabs": "vite build --config vite.config.elevenlabs.ts && tsc -p tsconfig.elevenlabs.json",
|
|
1620
|
+
"build:openai": "vite build --config vite.config.openai.ts && tsc -p tsconfig.openai.json",
|
|
1621
|
+
"build:deepgram": "vite build --config vite.config.deepgram.ts && tsc -p tsconfig.deepgram.json",
|
|
1622
|
+
"build:google": "vite build --config vite.config.google.ts && tsc -p tsconfig.google.json",
|
|
1623
|
+
"build:livekit": "vite build --config vite.config.livekit.ts && tsc -p tsconfig.livekit.json",
|
|
1624
|
+
"copy:preview": "mkdir -p dist/preview && cp preview/v2-embed-test.html dist/preview/ && cp preview/v2-embed-test-redirect.html dist/preview/",
|
|
1625
|
+
"build:v2": "vite build --config vite.config.v2.ts && vite build --config vite.config.v2-thumbnail.ts",
|
|
1626
|
+
"build:npm": "vite build --config vite.config.npm.ts && vite build --config vite.config.thumbnail.ts && tsc -p tsconfig.npm.json",
|
|
1627
|
+
"build:svelte": "svelte-package -i src/svelte -o dist/svelte && vite build --config vite.config.svelte.ts",
|
|
1628
|
+
"check:consumer": "svelte-check --workspace test/consumer --tsconfig ./tsconfig.json",
|
|
1629
|
+
test: "vitest run",
|
|
1630
|
+
preview: "node scripts/preview-local.mjs",
|
|
1631
|
+
"dev:sdk": "npm run build:v2 && npm run copy:preview && npm run preview",
|
|
1632
|
+
dev: "npm run build && npm run preview",
|
|
1633
|
+
"publish:sdk": "node scripts/publish-sdk.mjs",
|
|
1634
|
+
"publish:npm": "node scripts/publish-npm.mjs",
|
|
1635
|
+
"publish:avatar": "node scripts/publish-avatar.mjs",
|
|
1636
|
+
"publish:avatars-dist": "node scripts/publish-avatars.mjs",
|
|
1637
|
+
"publish:avatars": "node scripts/republish-avatars.mjs",
|
|
1638
|
+
"build:avatars": "node scripts/build-avatars.mjs",
|
|
1639
|
+
"republish:avatars": "node scripts/republish-avatars.mjs",
|
|
1640
|
+
"catalogue:avatars": "node ../labs.liforma.ai/scripts/generate-avatar-index.mjs",
|
|
1641
|
+
"verify:avatars-dist": "node scripts/verify-avatars-dist.mjs",
|
|
1642
|
+
"verify:avatar-pack": "node scripts/verify-avatar-pack.mjs",
|
|
1643
|
+
"repair:render-plate-metadata": "node scripts/repair-render-plate-metadata.mjs",
|
|
1644
|
+
"verify:render-plate-crop": "node scripts/verify-render-plate-crop.mjs",
|
|
1645
|
+
"migrate:avatar-render-prep": "npm run migrate:avatar-render-prep --prefix ../labs.liforma.ai --",
|
|
1646
|
+
"convert:avatar-teeth": "node scripts/convert-avatar-teeth-webp.mjs",
|
|
1647
|
+
"warm:avatar-composites": "node scripts/warm-avatar-composites.mjs",
|
|
1648
|
+
"test:compose-costume": "node scripts/test-compose-costume-layers.mjs",
|
|
1649
|
+
"test:compose-costume-wasm": "node scripts/test-compose-costume-wasm.mjs",
|
|
1650
|
+
"test:parse-composite-filename": "node scripts/test-parse-composite-filename.mjs",
|
|
1651
|
+
"test:avatar-composite-rendered-path": "node scripts/test-avatar-composite-rendered-path.mjs",
|
|
1652
|
+
"test:avatar-compose-worker-cors": "node scripts/test-avatar-compose-worker-cors.mjs",
|
|
1653
|
+
"test:experience-thumb-url": "node scripts/test-experience-thumb-url.mjs",
|
|
1654
|
+
"test:compose-experience-thumb": "node scripts/test-compose-experience-thumb.mjs",
|
|
1655
|
+
"test:location-depth-paths": "node scripts/test-location-depth-paths.mjs",
|
|
1656
|
+
"test:location-binary-assets": "node scripts/test-location-binary-assets.mjs",
|
|
1657
|
+
"test:location-da3-depth": "node scripts/test-location-da3-depth.mjs",
|
|
1658
|
+
"test:location-interactions": "node scripts/test-location-interactions.mjs",
|
|
1659
|
+
"test:render-plate-chroma-key": "node scripts/test-render-plate-chroma-key.mjs",
|
|
1660
|
+
"test:sparse-plate": "node scripts/test-sparse-plate.mjs",
|
|
1661
|
+
"test:face-meshes-publish-depth": "node scripts/test-face-meshes-publish-depth.mjs",
|
|
1662
|
+
"test:avatar-avif-sibling": "node scripts/test-avatar-avif-sibling.mjs",
|
|
1663
|
+
"test:screen-chroma-key": "node scripts/test-screen-chroma-key.mjs",
|
|
1664
|
+
"pull:sources": "node scripts/sync-authoring-sources.mjs",
|
|
1665
|
+
"push:sources": "node scripts/sync-authoring-sources.mjs",
|
|
1666
|
+
"catalogue:locations": "node scripts/catalogue-locations.mjs",
|
|
1667
|
+
"generate:location-interactions": "node scripts/generate-location-interactions.mjs",
|
|
1668
|
+
"generate:location-depth": "node scripts/generate-location-depth.mjs",
|
|
1669
|
+
"generate:location-depth16-da3": "node scripts/generate-location-depth16-da3.mjs",
|
|
1670
|
+
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
1671
|
+
"build:locations": "node scripts/build-locations.mjs",
|
|
1672
|
+
"publish:locations": "node scripts/publish-locations.mjs",
|
|
1673
|
+
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
1674
|
+
"publish:models": "node scripts/publish-models.mjs",
|
|
1675
|
+
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
1676
|
+
"publish:models:ltx-int8": "node scripts/_upload-model-prefix.mjs text-to-video/lf-t2v-distill-int8",
|
|
1677
|
+
"publish:models:video-omni": "node scripts/_upload-model-prefix.mjs text-to-video/lf-video-omni-v1",
|
|
1678
|
+
"fetch:depth-anything-v2": "node scripts/fetch-depth-anything-v2.mjs",
|
|
1679
|
+
"fetch:video-depth-anything": "node scripts/fetch-video-depth-anything.mjs",
|
|
1680
|
+
"fetch:depth-pro": "node scripts/fetch-depth-pro.mjs",
|
|
1681
|
+
"fetch:face-landmarker": "node scripts/fetch-face-landmarker.mjs",
|
|
1682
|
+
"fetch:anime-face-detector": "node scripts/fetch-anime-face-detector.mjs",
|
|
1683
|
+
"fetch:face-parsing": "node scripts/fetch-face-parsing.mjs",
|
|
1684
|
+
"fetch:vitmatte": "node scripts/fetch-vitmatte.mjs",
|
|
1685
|
+
"fetch:liveportrait-mlx": "node scripts/fetch-liveportrait-mlx.mjs",
|
|
1686
|
+
"fetch:wav2vec-phoneme-ctc": "node scripts/fetch-wav2vec-phoneme-ctc.mjs",
|
|
1687
|
+
"fetch:lf-sta": "node scripts/fetch-wav2vec-phoneme-ctc.mjs",
|
|
1688
|
+
"fetch:supertonic-3": "node scripts/fetch-supertonic-3.mjs",
|
|
1689
|
+
"fetch:lf-tts": "node scripts/fetch-supertonic-3.mjs",
|
|
1690
|
+
"fetch:lf-t2i-turbo": "python3 ../tools/krea-2-salad/scripts/fetch_cdn_snapshot.py",
|
|
1691
|
+
"fetch:models": "npm run fetch:depth-anything-v2 && npm run fetch:video-depth-anything && npm run fetch:depth-pro && npm run fetch:face-landmarker && npm run fetch:anime-face-detector && npm run fetch:face-parsing && npm run fetch:vitmatte && npm run fetch:lf-sta && npm run fetch:lf-tts",
|
|
1692
|
+
locations: "npm run catalogue:locations && npm run build:locations",
|
|
1693
|
+
"configure:cors": "node scripts/configure-r2-cors.mjs",
|
|
1694
|
+
"verify:cors": "node scripts/verify-cdn-cors.mjs",
|
|
1695
|
+
"deploy:worker:avatar-compose": "node scripts/deploy-avatar-compose-worker.mjs",
|
|
1696
|
+
"deploy:worker:experience-thumb": "node scripts/deploy-experience-thumb-worker.mjs",
|
|
1697
|
+
deploy: "npm run build && npm run publish:sdk",
|
|
1698
|
+
verify: "npm run build && node scripts/check-sdk-size.mjs && node scripts/verify-thumbnail-light.mjs && node scripts/test-embed-protocol.mjs && node scripts/test-manifest-embed-url.mjs && node scripts/test-player-reachability.mjs && node scripts/test-session-endpoint.mjs && node scripts/verify-package.mjs",
|
|
1699
|
+
"preview:test": "npm run build && npm run preview"
|
|
1700
|
+
},
|
|
1701
|
+
dependencies: {
|
|
1702
|
+
"@jsquash/webp": "^1.5.0",
|
|
1703
|
+
zod: "^4.4.3"
|
|
1704
|
+
},
|
|
1705
|
+
devDependencies: {
|
|
1706
|
+
"@aws-sdk/client-s3": "^3.1000.0",
|
|
1707
|
+
"@aws-sdk/lib-storage": "^3.1110.0",
|
|
1708
|
+
"@elevenlabs/client": "^1.17.0",
|
|
1709
|
+
"@sveltejs/package": "^2.5.8",
|
|
1710
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
1711
|
+
"@testing-library/react": "^16.3.0",
|
|
1712
|
+
"@testing-library/svelte": "^5.4.2",
|
|
1713
|
+
"@types/node": "^25.9.3",
|
|
1714
|
+
"@types/react": "^19.1.12",
|
|
1715
|
+
"@types/react-dom": "^19.1.9",
|
|
1716
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
1717
|
+
"@webgpu/types": "^0.1.70",
|
|
1718
|
+
dotenv: "^17.2.3",
|
|
1719
|
+
jsdom: "^30.0.1",
|
|
1720
|
+
"livekit-client": "^2.21.0",
|
|
1721
|
+
react: "^19.1.1",
|
|
1722
|
+
"react-dom": "^19.1.1",
|
|
1723
|
+
sharp: "^0.34.2",
|
|
1724
|
+
svelte: "^5.55.2",
|
|
1725
|
+
"svelte-check": "^4.7.4",
|
|
1726
|
+
typescript: "^6.0.3",
|
|
1727
|
+
vite: "^8.0.16",
|
|
1728
|
+
vitest: "^4.1.10",
|
|
1729
|
+
wrangler: "^4.101.0"
|
|
1730
|
+
}
|
|
1731
|
+
}.version}`, ht = "https://player.liforma.ai/embed", gt = "http://localhost:3002/embed";
|
|
1732
|
+
function _t() {
|
|
1455
1733
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1456
1734
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1457
1735
|
if (typeof document > "u") return null;
|
|
1458
1736
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-player-embed-url")?.trim();
|
|
1459
1737
|
return t ? t.replace(/\/$/, "") : null;
|
|
1460
1738
|
}
|
|
1461
|
-
function
|
|
1462
|
-
let e =
|
|
1463
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : T() ?
|
|
1739
|
+
function vt() {
|
|
1740
|
+
let e = _t();
|
|
1741
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : T() ? gt : ht;
|
|
1464
1742
|
}
|
|
1465
|
-
function
|
|
1743
|
+
function yt(e, t) {
|
|
1466
1744
|
return e?.trim() || t?.trim() || void 0;
|
|
1467
1745
|
}
|
|
1468
|
-
function
|
|
1469
|
-
let c = (e ??
|
|
1746
|
+
function bt(e, t, n, r, i, a, o, s) {
|
|
1747
|
+
let c = (e ?? vt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1470
1748
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1471
1749
|
let f = r?.trim();
|
|
1472
|
-
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)),
|
|
1750
|
+
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)), xt(u.toString());
|
|
1473
1751
|
}
|
|
1474
|
-
function
|
|
1752
|
+
function xt(e) {
|
|
1475
1753
|
if (typeof location > "u") return e;
|
|
1476
1754
|
let t = new URL(e);
|
|
1477
1755
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1478
1756
|
}
|
|
1479
|
-
function
|
|
1757
|
+
function St(e) {
|
|
1480
1758
|
return new URL(e).origin;
|
|
1481
1759
|
}
|
|
1482
1760
|
//#endregion
|
|
1483
1761
|
//#region src/v2/experienceEvents.ts
|
|
1484
|
-
function
|
|
1762
|
+
function Ct() {
|
|
1485
1763
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
1486
1764
|
}
|
|
1487
|
-
function
|
|
1765
|
+
function wt(e, t, n) {
|
|
1488
1766
|
return {
|
|
1489
|
-
id:
|
|
1767
|
+
id: Ct(),
|
|
1490
1768
|
type: e,
|
|
1491
1769
|
sessionId: t,
|
|
1492
1770
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1493
1771
|
data: n
|
|
1494
1772
|
};
|
|
1495
1773
|
}
|
|
1496
|
-
function
|
|
1774
|
+
function Tt() {
|
|
1497
1775
|
return {
|
|
1498
1776
|
ready: /* @__PURE__ */ new Set(),
|
|
1499
1777
|
started: /* @__PURE__ */ new Set(),
|
|
1778
|
+
sessionMinted: /* @__PURE__ */ new Set(),
|
|
1500
1779
|
userTranscript: /* @__PURE__ */ new Set(),
|
|
1501
1780
|
userSpeechStarted: /* @__PURE__ */ new Set(),
|
|
1502
1781
|
userSpeechEnded: /* @__PURE__ */ new Set(),
|
|
@@ -1507,44 +1786,45 @@ function wt() {
|
|
|
1507
1786
|
message: /* @__PURE__ */ new Set(),
|
|
1508
1787
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1509
1788
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1789
|
+
interactionChange: /* @__PURE__ */ new Set(),
|
|
1510
1790
|
feedback: /* @__PURE__ */ new Set(),
|
|
1511
1791
|
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1512
1792
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1513
1793
|
};
|
|
1514
1794
|
}
|
|
1515
|
-
function
|
|
1795
|
+
function Et(e, t, n) {
|
|
1516
1796
|
return e[t].add(n), () => e[t].delete(n);
|
|
1517
1797
|
}
|
|
1518
|
-
function
|
|
1798
|
+
function Dt(e, t, n) {
|
|
1519
1799
|
for (let r of e[t]) r(n);
|
|
1520
1800
|
}
|
|
1521
|
-
function
|
|
1801
|
+
function Ot(e) {
|
|
1522
1802
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1523
1803
|
}
|
|
1524
1804
|
//#endregion
|
|
1525
1805
|
//#region src/v2/speech/types.ts
|
|
1526
|
-
function
|
|
1806
|
+
function kt(e) {
|
|
1527
1807
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1528
1808
|
}
|
|
1529
|
-
function
|
|
1809
|
+
function At(e) {
|
|
1530
1810
|
return "url" in e && typeof e.url == "string";
|
|
1531
1811
|
}
|
|
1532
|
-
function
|
|
1812
|
+
function jt(e) {
|
|
1533
1813
|
if (!("track" in e)) return !1;
|
|
1534
1814
|
let t = e.track;
|
|
1535
1815
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1536
1816
|
}
|
|
1537
|
-
function
|
|
1538
|
-
return !
|
|
1817
|
+
function Mt(e) {
|
|
1818
|
+
return !kt(e) && !At(e) && !jt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1539
1819
|
}
|
|
1540
|
-
var
|
|
1820
|
+
var Nt = [
|
|
1541
1821
|
8e3,
|
|
1542
1822
|
16e3,
|
|
1543
1823
|
22050,
|
|
1544
1824
|
24e3,
|
|
1545
1825
|
44100,
|
|
1546
1826
|
48e3
|
|
1547
|
-
],
|
|
1827
|
+
], Pt = {
|
|
1548
1828
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1549
1829
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1550
1830
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1555,14 +1835,14 @@ var Mt = [
|
|
|
1555
1835
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1556
1836
|
MAX_PENDING_WRITES: 8,
|
|
1557
1837
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1558
|
-
},
|
|
1838
|
+
}, Ft = class extends Error {
|
|
1559
1839
|
operation;
|
|
1560
1840
|
requiredCapability;
|
|
1561
1841
|
name = "UnsupportedSpeechOperationError";
|
|
1562
1842
|
constructor(e, t) {
|
|
1563
1843
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1564
1844
|
}
|
|
1565
|
-
},
|
|
1845
|
+
}, It = class extends Error {
|
|
1566
1846
|
name = "SpeechUtteranceClosedError";
|
|
1567
1847
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1568
1848
|
super(e);
|
|
@@ -1572,72 +1852,72 @@ var Mt = [
|
|
|
1572
1852
|
constructor(e, t) {
|
|
1573
1853
|
super(e, t);
|
|
1574
1854
|
}
|
|
1575
|
-
},
|
|
1855
|
+
}, Lt = class extends Error {
|
|
1576
1856
|
name = "SpeechBufferTimeoutError";
|
|
1577
1857
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1578
1858
|
super(e);
|
|
1579
1859
|
}
|
|
1580
1860
|
};
|
|
1581
|
-
function
|
|
1861
|
+
function Rt(e = "none") {
|
|
1582
1862
|
return {
|
|
1583
1863
|
mode: e,
|
|
1584
1864
|
trackedDurationMs: 0,
|
|
1585
1865
|
fallbackDurationMs: 0
|
|
1586
1866
|
};
|
|
1587
1867
|
}
|
|
1588
|
-
function Rt(e) {
|
|
1589
|
-
return Mt.includes(e);
|
|
1590
|
-
}
|
|
1591
1868
|
function zt(e) {
|
|
1869
|
+
return Nt.includes(e);
|
|
1870
|
+
}
|
|
1871
|
+
function Bt(e) {
|
|
1592
1872
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1593
1873
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1594
|
-
if (!
|
|
1874
|
+
if (!zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1595
1875
|
}
|
|
1596
|
-
function
|
|
1597
|
-
if (
|
|
1598
|
-
|
|
1876
|
+
function Vt(e) {
|
|
1877
|
+
if (kt(e)) {
|
|
1878
|
+
Bt(e.format);
|
|
1599
1879
|
return;
|
|
1600
1880
|
}
|
|
1601
|
-
if (
|
|
1881
|
+
if (At(e)) {
|
|
1602
1882
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1603
|
-
if (e.sampleRate !== void 0 && !
|
|
1883
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1604
1884
|
return;
|
|
1605
1885
|
}
|
|
1606
|
-
if (
|
|
1886
|
+
if (jt(e)) {
|
|
1607
1887
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1608
|
-
if (e.sampleRate !== void 0 && !
|
|
1888
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1609
1889
|
return;
|
|
1610
1890
|
}
|
|
1611
|
-
if (
|
|
1891
|
+
if (Mt(e)) {
|
|
1612
1892
|
let t = e.encoding.trim().toLowerCase();
|
|
1613
1893
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1614
1894
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1615
|
-
if (e.sampleRate !== void 0 && !
|
|
1895
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1616
1896
|
return;
|
|
1617
1897
|
}
|
|
1618
1898
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1619
1899
|
}
|
|
1620
|
-
function
|
|
1621
|
-
if (e.format) return
|
|
1900
|
+
function Ht(e) {
|
|
1901
|
+
if (e.format) return Bt(e.format), e.format;
|
|
1622
1902
|
if (e.track) {
|
|
1623
1903
|
let t = {
|
|
1624
1904
|
encoding: "pcm_s16le",
|
|
1625
1905
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1626
1906
|
channels: 1
|
|
1627
1907
|
};
|
|
1628
|
-
return
|
|
1908
|
+
return Bt(t), t;
|
|
1629
1909
|
}
|
|
1630
1910
|
throw new Q("createUtterance requires format or track.");
|
|
1631
1911
|
}
|
|
1632
|
-
function
|
|
1912
|
+
function Ut(e) {
|
|
1633
1913
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1634
1914
|
}
|
|
1635
|
-
function
|
|
1915
|
+
function Wt(e) {
|
|
1636
1916
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1637
1917
|
}
|
|
1638
1918
|
//#endregion
|
|
1639
1919
|
//#region src/byo/pcm.ts
|
|
1640
|
-
function
|
|
1920
|
+
function Gt(e) {
|
|
1641
1921
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1642
1922
|
for (let t = 0; t < e.length; t++) {
|
|
1643
1923
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1647,11 +1927,11 @@ function Wt(e) {
|
|
|
1647
1927
|
}
|
|
1648
1928
|
//#endregion
|
|
1649
1929
|
//#region src/byo/resample.ts
|
|
1650
|
-
function
|
|
1930
|
+
function Kt(e, t, n, r, i) {
|
|
1651
1931
|
let a = -.5 * e + 1.5 * t - 1.5 * n + .5 * r, o = e - 2.5 * t + 2 * n - .5 * r, s = -.5 * e + .5 * n, c = t;
|
|
1652
1932
|
return ((a * i + o) * i + s) * i + c;
|
|
1653
1933
|
}
|
|
1654
|
-
function
|
|
1934
|
+
function qt(e, t) {
|
|
1655
1935
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1656
1936
|
if (e === t) return {
|
|
1657
1937
|
fromRate: e,
|
|
@@ -1674,7 +1954,7 @@ function Kt(e, t) {
|
|
|
1674
1954
|
let a = [];
|
|
1675
1955
|
for (; i + 2 < r.length - 1;) {
|
|
1676
1956
|
let e = Math.floor(i), t = i - e, o = Math.max(0, e - 1), s = Math.min(r.length - 1, e + 1), c = Math.min(r.length - 1, e + 2);
|
|
1677
|
-
a.push(
|
|
1957
|
+
a.push(Kt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1678
1958
|
}
|
|
1679
1959
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1680
1960
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1686,7 +1966,7 @@ function Kt(e, t) {
|
|
|
1686
1966
|
}
|
|
1687
1967
|
//#endregion
|
|
1688
1968
|
//#region src/byo/audioCapture.ts
|
|
1689
|
-
var
|
|
1969
|
+
var Jt = "liforma-pcm-capture", Yt = `
|
|
1690
1970
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1691
1971
|
process(inputs) {
|
|
1692
1972
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1698,29 +1978,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1698
1978
|
return true;
|
|
1699
1979
|
}
|
|
1700
1980
|
}
|
|
1701
|
-
registerProcessor('${
|
|
1702
|
-
`,
|
|
1703
|
-
function Xt() {
|
|
1704
|
-
return Yt ||= URL.createObjectURL(new Blob([Jt], { type: "application/javascript" })), Yt;
|
|
1705
|
-
}
|
|
1981
|
+
registerProcessor('${Jt}', LiformaPcmCaptureProcessor);
|
|
1982
|
+
`, Xt = null;
|
|
1706
1983
|
function Zt() {
|
|
1984
|
+
return Xt ||= URL.createObjectURL(new Blob([Yt], { type: "application/javascript" })), Xt;
|
|
1985
|
+
}
|
|
1986
|
+
function Qt() {
|
|
1707
1987
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1708
1988
|
}
|
|
1709
|
-
async function
|
|
1710
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1989
|
+
async function $t(e) {
|
|
1990
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Qt();
|
|
1711
1991
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1712
1992
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1713
1993
|
l.gain.value = 0;
|
|
1714
|
-
let u = s.sampleRate, d =
|
|
1994
|
+
let u = s.sampleRate, d = qt(u, n), f = !1, p = !1, m = (e) => {
|
|
1715
1995
|
if (f || i && !i()) return;
|
|
1716
1996
|
let t = d.push(e);
|
|
1717
|
-
t.length !== 0 && r(
|
|
1997
|
+
t.length !== 0 && r(Gt(t));
|
|
1718
1998
|
}, h = () => void 0;
|
|
1719
1999
|
return await (async () => {
|
|
1720
2000
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1721
2001
|
try {
|
|
1722
|
-
await s.audioWorklet.addModule(
|
|
1723
|
-
let e = new AudioWorkletNode(s,
|
|
2002
|
+
await s.audioWorklet.addModule(Zt());
|
|
2003
|
+
let e = new AudioWorkletNode(s, Jt, {
|
|
1724
2004
|
numberOfInputs: 1,
|
|
1725
2005
|
numberOfOutputs: 1,
|
|
1726
2006
|
outputChannelCount: [1]
|
|
@@ -1770,7 +2050,7 @@ async function Qt(e) {
|
|
|
1770
2050
|
}
|
|
1771
2051
|
//#endregion
|
|
1772
2052
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1773
|
-
async function
|
|
2053
|
+
async function en(e) {
|
|
1774
2054
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1775
2055
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1776
2056
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1779,18 +2059,18 @@ async function $t(e) {
|
|
|
1779
2059
|
s || (s = !0, c?.stop(), c = null);
|
|
1780
2060
|
};
|
|
1781
2061
|
try {
|
|
1782
|
-
c = await
|
|
2062
|
+
c = await $t({
|
|
1783
2063
|
mediaStream: a,
|
|
1784
2064
|
targetSampleRate: r,
|
|
1785
2065
|
shouldSend: () => !s && !i?.aborted,
|
|
1786
2066
|
onPcm: (e) => {
|
|
1787
2067
|
if (s || i?.aborted) return;
|
|
1788
|
-
let t =
|
|
2068
|
+
let t = Ut(e);
|
|
1789
2069
|
o = o.then(async () => {
|
|
1790
2070
|
if (s || i?.aborted) return;
|
|
1791
2071
|
let e = 0;
|
|
1792
2072
|
for (; e < t.byteLength;) {
|
|
1793
|
-
let r = Math.min(e +
|
|
2073
|
+
let r = Math.min(e + Pt.MAX_CHUNK_BYTES, t.byteLength);
|
|
1794
2074
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1795
2075
|
let i = t.subarray(e, r);
|
|
1796
2076
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1814,10 +2094,10 @@ async function $t(e) {
|
|
|
1814
2094
|
}
|
|
1815
2095
|
//#endregion
|
|
1816
2096
|
//#region src/v2/speech/speechController.ts
|
|
1817
|
-
async function
|
|
1818
|
-
if (
|
|
1819
|
-
if (
|
|
1820
|
-
let t =
|
|
2097
|
+
async function tn(e, t) {
|
|
2098
|
+
if (jt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2099
|
+
if (kt(e)) {
|
|
2100
|
+
let t = Ut(e.data);
|
|
1821
2101
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1822
2102
|
return {
|
|
1823
2103
|
kind: "pcm",
|
|
@@ -1825,17 +2105,17 @@ async function en(e, t) {
|
|
|
1825
2105
|
format: e.format
|
|
1826
2106
|
};
|
|
1827
2107
|
}
|
|
1828
|
-
if (
|
|
2108
|
+
if (At(e)) return {
|
|
1829
2109
|
kind: "url",
|
|
1830
2110
|
url: e.url.trim(),
|
|
1831
2111
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1832
2112
|
};
|
|
1833
|
-
if (!
|
|
2113
|
+
if (!Mt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1834
2114
|
let n;
|
|
1835
2115
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1836
2116
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1837
2117
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1838
|
-
} else n =
|
|
2118
|
+
} else n = Ut(e.data);
|
|
1839
2119
|
return {
|
|
1840
2120
|
kind: "encoded",
|
|
1841
2121
|
data: n.slice().buffer,
|
|
@@ -1843,10 +2123,10 @@ async function en(e, t) {
|
|
|
1843
2123
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1844
2124
|
};
|
|
1845
2125
|
}
|
|
1846
|
-
function
|
|
2126
|
+
function nn() {
|
|
1847
2127
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `utt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
1848
2128
|
}
|
|
1849
|
-
function
|
|
2129
|
+
function rn(e, t = "completed") {
|
|
1850
2130
|
return {
|
|
1851
2131
|
utteranceId: e.speechId,
|
|
1852
2132
|
characterId: e.characterId,
|
|
@@ -1860,13 +2140,13 @@ function nn(e, t = "completed") {
|
|
|
1860
2140
|
}
|
|
1861
2141
|
};
|
|
1862
2142
|
}
|
|
1863
|
-
function
|
|
2143
|
+
function an(e) {
|
|
1864
2144
|
return e instanceof Error ? e : new Q(String(e));
|
|
1865
2145
|
}
|
|
1866
|
-
function
|
|
2146
|
+
function on(e) {
|
|
1867
2147
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1868
2148
|
}
|
|
1869
|
-
var
|
|
2149
|
+
var sn = class {
|
|
1870
2150
|
id;
|
|
1871
2151
|
characterId;
|
|
1872
2152
|
result;
|
|
@@ -1895,29 +2175,29 @@ var on = class {
|
|
|
1895
2175
|
queue: e.queue,
|
|
1896
2176
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1897
2177
|
}).catch((e) => {
|
|
1898
|
-
throw this.fail(
|
|
2178
|
+
throw this.fail(an(e)), an(e);
|
|
1899
2179
|
}), this.signal?.addEventListener("abort", () => {
|
|
1900
2180
|
this.cancel();
|
|
1901
2181
|
}, { once: !0 });
|
|
1902
2182
|
}
|
|
1903
2183
|
async write(e, t) {
|
|
1904
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1905
|
-
let n =
|
|
2184
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new It();
|
|
2185
|
+
let n = Ut(e);
|
|
1906
2186
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1907
|
-
if (n.byteLength >
|
|
2187
|
+
if (n.byteLength > Pt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Pt.MAX_CHUNK_BYTES}).`);
|
|
1908
2188
|
if (n.byteLength === 0) return;
|
|
1909
|
-
let r = t?.timeoutMs ??
|
|
2189
|
+
let r = t?.timeoutMs ?? Pt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1910
2190
|
await this.acquireWriteSlot(r);
|
|
1911
2191
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1912
|
-
if (this.bufferedMs + i >
|
|
2192
|
+
if (this.bufferedMs + i > Pt.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1913
2193
|
let a = async () => {
|
|
1914
|
-
if (this.closed || this.settled) throw new
|
|
2194
|
+
if (this.closed || this.settled) throw new It();
|
|
1915
2195
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1916
2196
|
utteranceId: this.id,
|
|
1917
2197
|
audio: t.buffer,
|
|
1918
2198
|
byteLength: t.byteLength
|
|
1919
2199
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1920
|
-
setTimeout(() => t(new
|
|
2200
|
+
setTimeout(() => t(new Lt()), r);
|
|
1921
2201
|
})]);
|
|
1922
2202
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1923
2203
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1929,7 +2209,7 @@ var on = class {
|
|
|
1929
2209
|
}
|
|
1930
2210
|
}
|
|
1931
2211
|
async setTranscript(e) {
|
|
1932
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2212
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new It();
|
|
1933
2213
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1934
2214
|
utteranceId: this.id,
|
|
1935
2215
|
transcript: e
|
|
@@ -1946,7 +2226,7 @@ var on = class {
|
|
|
1946
2226
|
});
|
|
1947
2227
|
return this.resolve(t), t;
|
|
1948
2228
|
} catch (e) {
|
|
1949
|
-
let t =
|
|
2229
|
+
let t = an(e);
|
|
1950
2230
|
throw this.fail(t), t;
|
|
1951
2231
|
}
|
|
1952
2232
|
}
|
|
@@ -1964,11 +2244,11 @@ var on = class {
|
|
|
1964
2244
|
characterId: this.characterId,
|
|
1965
2245
|
status: "cancelled",
|
|
1966
2246
|
durationMs: 0,
|
|
1967
|
-
animation:
|
|
2247
|
+
animation: Rt("none")
|
|
1968
2248
|
};
|
|
1969
2249
|
return this.resolve(t), t;
|
|
1970
2250
|
} catch (e) {
|
|
1971
|
-
let t =
|
|
2251
|
+
let t = an(e);
|
|
1972
2252
|
throw this.fail(t), t;
|
|
1973
2253
|
}
|
|
1974
2254
|
}
|
|
@@ -1981,19 +2261,19 @@ var on = class {
|
|
|
1981
2261
|
return e;
|
|
1982
2262
|
}
|
|
1983
2263
|
resolve(e) {
|
|
1984
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2264
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new It()));
|
|
1985
2265
|
}
|
|
1986
2266
|
fail(e) {
|
|
1987
2267
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1988
2268
|
}
|
|
1989
2269
|
async acquireWriteSlot(e) {
|
|
1990
|
-
if (this.pendingWriteCount <
|
|
2270
|
+
if (this.pendingWriteCount < Pt.MAX_PENDING_WRITES) {
|
|
1991
2271
|
this.pendingWriteCount += 1;
|
|
1992
2272
|
return;
|
|
1993
2273
|
}
|
|
1994
2274
|
await new Promise((t, n) => {
|
|
1995
2275
|
let r = setTimeout(() => {
|
|
1996
|
-
n(new
|
|
2276
|
+
n(new Lt());
|
|
1997
2277
|
}, e);
|
|
1998
2278
|
this.pendingWriteWaiters.push({
|
|
1999
2279
|
resolve: () => {
|
|
@@ -2012,13 +2292,13 @@ var on = class {
|
|
|
2012
2292
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2013
2293
|
}
|
|
2014
2294
|
};
|
|
2015
|
-
function
|
|
2295
|
+
function cn(e) {
|
|
2016
2296
|
let t = null, n = (t, n) => {
|
|
2017
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2297
|
+
if (!e.getCapabilities()[n]) throw new Ft(t, n);
|
|
2018
2298
|
}, r = {
|
|
2019
2299
|
async speak(r) {
|
|
2020
2300
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2021
|
-
let i =
|
|
2301
|
+
let i = Wt(r.queue ?? "append");
|
|
2022
2302
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2023
2303
|
let a = e.getIframeHost();
|
|
2024
2304
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2038,41 +2318,41 @@ function sn(e) {
|
|
|
2038
2318
|
return;
|
|
2039
2319
|
}
|
|
2040
2320
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2041
|
-
t.removeEventListener("abort", s), n(
|
|
2321
|
+
t.removeEventListener("abort", s), n(rn(e, "completed"));
|
|
2042
2322
|
}, (a) => {
|
|
2043
|
-
if (t.removeEventListener("abort", s),
|
|
2323
|
+
if (t.removeEventListener("abort", s), on(a)) {
|
|
2044
2324
|
n({
|
|
2045
2325
|
utteranceId: "utt_interrupted",
|
|
2046
2326
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2047
2327
|
status: "interrupted",
|
|
2048
2328
|
durationMs: 0,
|
|
2049
2329
|
transcript: r.text,
|
|
2050
|
-
animation:
|
|
2330
|
+
animation: Rt("none")
|
|
2051
2331
|
});
|
|
2052
2332
|
return;
|
|
2053
2333
|
}
|
|
2054
|
-
i(
|
|
2334
|
+
i(an(a));
|
|
2055
2335
|
});
|
|
2056
2336
|
});
|
|
2057
2337
|
}
|
|
2058
2338
|
try {
|
|
2059
|
-
return
|
|
2339
|
+
return rn(await o, "completed");
|
|
2060
2340
|
} catch (t) {
|
|
2061
|
-
if (
|
|
2341
|
+
if (on(t)) return {
|
|
2062
2342
|
utteranceId: "utt_interrupted",
|
|
2063
2343
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2064
2344
|
status: "interrupted",
|
|
2065
2345
|
durationMs: 0,
|
|
2066
2346
|
transcript: r.text,
|
|
2067
|
-
animation:
|
|
2347
|
+
animation: Rt("none")
|
|
2068
2348
|
};
|
|
2069
|
-
throw
|
|
2349
|
+
throw an(t);
|
|
2070
2350
|
}
|
|
2071
2351
|
},
|
|
2072
2352
|
async play(i) {
|
|
2073
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2353
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Vt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2074
2354
|
let a = i.queue ?? "append";
|
|
2075
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2355
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), jt(i.audio)) {
|
|
2076
2356
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2077
2357
|
return r.createUtterance({
|
|
2078
2358
|
format: {
|
|
@@ -2088,7 +2368,7 @@ function sn(e) {
|
|
|
2088
2368
|
}
|
|
2089
2369
|
let o = e.getIframeHost();
|
|
2090
2370
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2091
|
-
let s = await
|
|
2371
|
+
let s = await tn(i.audio, i.signal);
|
|
2092
2372
|
return o.speechPlay({
|
|
2093
2373
|
source: s,
|
|
2094
2374
|
characterId: i.characterId,
|
|
@@ -2100,13 +2380,13 @@ function sn(e) {
|
|
|
2100
2380
|
},
|
|
2101
2381
|
createUtterance(r) {
|
|
2102
2382
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2103
|
-
let i =
|
|
2383
|
+
let i = Ht(r);
|
|
2104
2384
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2105
2385
|
let a = r.queue ?? "replace-active";
|
|
2106
2386
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2107
2387
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2108
|
-
let o = new
|
|
2109
|
-
id:
|
|
2388
|
+
let o = new sn({
|
|
2389
|
+
id: nn(),
|
|
2110
2390
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2111
2391
|
format: i,
|
|
2112
2392
|
queue: a,
|
|
@@ -2118,7 +2398,7 @@ function sn(e) {
|
|
|
2118
2398
|
t === o && (t = null);
|
|
2119
2399
|
}), r.track && (async () => {
|
|
2120
2400
|
try {
|
|
2121
|
-
if (await
|
|
2401
|
+
if (await en({
|
|
2122
2402
|
track: r.track,
|
|
2123
2403
|
utterance: o,
|
|
2124
2404
|
sampleRate: i.sampleRate,
|
|
@@ -2146,16 +2426,16 @@ function sn(e) {
|
|
|
2146
2426
|
}
|
|
2147
2427
|
//#endregion
|
|
2148
2428
|
//#region src/v2/types/sessionInteraction.ts
|
|
2149
|
-
function
|
|
2429
|
+
function ln(e) {
|
|
2150
2430
|
let t = e?.trim();
|
|
2151
2431
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2152
2432
|
}
|
|
2153
2433
|
//#endregion
|
|
2154
2434
|
//#region src/v2/experience.ts
|
|
2155
|
-
function
|
|
2435
|
+
function un(e) {
|
|
2156
2436
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2157
2437
|
}
|
|
2158
|
-
var
|
|
2438
|
+
var dn = class e {
|
|
2159
2439
|
bootstrap;
|
|
2160
2440
|
conversationProcessor;
|
|
2161
2441
|
iframeHost = null;
|
|
@@ -2169,17 +2449,19 @@ var un = class e {
|
|
|
2169
2449
|
closed = !1;
|
|
2170
2450
|
attached = !1;
|
|
2171
2451
|
pendingFit = null;
|
|
2452
|
+
lastInteraction = null;
|
|
2172
2453
|
closeHandlers = [];
|
|
2173
|
-
eventRegistry =
|
|
2454
|
+
eventRegistry = Tt();
|
|
2174
2455
|
readyEnvelope = null;
|
|
2175
2456
|
startedEnvelope = null;
|
|
2457
|
+
sessionMintedEnvelope = null;
|
|
2176
2458
|
conversationCache = [];
|
|
2177
2459
|
speech;
|
|
2178
2460
|
constructor(e) {
|
|
2179
|
-
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 =
|
|
2461
|
+
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 = cn({
|
|
2180
2462
|
getIframeHost: () => this.iframeHost,
|
|
2181
2463
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2182
|
-
getCapabilities: () =>
|
|
2464
|
+
getCapabilities: () => fn(this.resolvedSession),
|
|
2183
2465
|
getActiveCharacterId: () => "character_unknown",
|
|
2184
2466
|
onProcessorInterrupt: () => {
|
|
2185
2467
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2224,6 +2506,7 @@ var un = class e {
|
|
|
2224
2506
|
speechInputMode: t.speechInputMode,
|
|
2225
2507
|
speechOnly: t.speechOnly,
|
|
2226
2508
|
attribution: t.attribution,
|
|
2509
|
+
alreadyConverted: t.alreadyConverted,
|
|
2227
2510
|
ui: t.ui,
|
|
2228
2511
|
onStart: t.onStart,
|
|
2229
2512
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2246,6 +2529,7 @@ var un = class e {
|
|
|
2246
2529
|
speechInputMode: t.speechInputMode,
|
|
2247
2530
|
speechOnly: t.speechOnly,
|
|
2248
2531
|
attribution: t.attribution,
|
|
2532
|
+
alreadyConverted: t.alreadyConverted,
|
|
2249
2533
|
ui: t.ui,
|
|
2250
2534
|
onStart: t.onStart,
|
|
2251
2535
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2260,8 +2544,8 @@ var un = class e {
|
|
|
2260
2544
|
return null;
|
|
2261
2545
|
}
|
|
2262
2546
|
on(e, t) {
|
|
2263
|
-
let n =
|
|
2264
|
-
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2547
|
+
let n = Et(this.eventRegistry, e, t);
|
|
2548
|
+
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
2265
2549
|
}
|
|
2266
2550
|
async attach(e) {
|
|
2267
2551
|
if (this.closed) throw Error("Session has ended.");
|
|
@@ -2274,7 +2558,7 @@ var un = class e {
|
|
|
2274
2558
|
if (this.closed) throw Error("Session has ended.");
|
|
2275
2559
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2276
2560
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2277
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2561
|
+
let t = this.bootstrap.embedBaseUrl ?? vt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = bt(t, n, r ? void 0 : yt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, un(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = St(i), o = null, s = new Promise((e) => {
|
|
2278
2562
|
o = e;
|
|
2279
2563
|
}), c = null, l = new Promise((e) => {
|
|
2280
2564
|
c = e;
|
|
@@ -2319,6 +2603,9 @@ var un = class e {
|
|
|
2319
2603
|
onActivityChange: (e) => {
|
|
2320
2604
|
this.emitWrapped("activityChange", e);
|
|
2321
2605
|
},
|
|
2606
|
+
onInteractionChange: (e) => {
|
|
2607
|
+
this.lastInteraction = e, this.emitWrapped("interactionChange", e);
|
|
2608
|
+
},
|
|
2322
2609
|
onFeedback: (e) => {
|
|
2323
2610
|
this.emitWrapped("feedback", e);
|
|
2324
2611
|
},
|
|
@@ -2353,6 +2640,7 @@ var un = class e {
|
|
|
2353
2640
|
speechInputMode: p.speechInputMode,
|
|
2354
2641
|
speechOnly: this.bootstrap.speechOnly,
|
|
2355
2642
|
attribution: this.bootstrap.attribution,
|
|
2643
|
+
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
2356
2644
|
signal: this.endpointAbortController.signal
|
|
2357
2645
|
})) : this.bootstrap.kind === "public" ? Ue(this.bootstrap.experienceId, {
|
|
2358
2646
|
locale: this.bootstrap.locale,
|
|
@@ -2362,7 +2650,8 @@ var un = class e {
|
|
|
2362
2650
|
mode: p.mode,
|
|
2363
2651
|
speechInputMode: p.speechInputMode,
|
|
2364
2652
|
speechOnly: this.bootstrap.speechOnly,
|
|
2365
|
-
attribution: this.bootstrap.attribution
|
|
2653
|
+
attribution: this.bootstrap.attribution,
|
|
2654
|
+
alreadyConverted: this.bootstrap.alreadyConverted
|
|
2366
2655
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2367
2656
|
session: this.bootstrap.session,
|
|
2368
2657
|
launch: this.bootstrap.launch
|
|
@@ -2370,6 +2659,16 @@ var un = class e {
|
|
|
2370
2659
|
try {
|
|
2371
2660
|
[, h] = await Promise.all([f.waitForLoad(), m]);
|
|
2372
2661
|
} catch (e) {
|
|
2662
|
+
try {
|
|
2663
|
+
f.reportSdkError({
|
|
2664
|
+
errorCode: "sdk.session.attach_failed",
|
|
2665
|
+
severity: "error",
|
|
2666
|
+
operation: "attach",
|
|
2667
|
+
message: e instanceof Error ? e.message : String(e),
|
|
2668
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
2669
|
+
release: mt
|
|
2670
|
+
});
|
|
2671
|
+
} catch {}
|
|
2373
2672
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
2374
2673
|
} finally {
|
|
2375
2674
|
this.endpointAbortController = null;
|
|
@@ -2377,7 +2676,9 @@ var un = class e {
|
|
|
2377
2676
|
f.postParentHello();
|
|
2378
2677
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2379
2678
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2380
|
-
|
|
2679
|
+
this.launchToken = g;
|
|
2680
|
+
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2681
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Fe(_), f.postLaunch(g, _, {
|
|
2381
2682
|
startButton: e.startButton,
|
|
2382
2683
|
theme: e.theme,
|
|
2383
2684
|
showFeedback: e.showFeedback
|
|
@@ -2387,9 +2688,33 @@ var un = class e {
|
|
|
2387
2688
|
showFeedback: e.showFeedback
|
|
2388
2689
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2389
2690
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2390
|
-
})])
|
|
2691
|
+
})]).catch((e) => {
|
|
2692
|
+
try {
|
|
2693
|
+
f.reportSdkError({
|
|
2694
|
+
errorCode: "sdk.session.attach_failed",
|
|
2695
|
+
severity: "error",
|
|
2696
|
+
operation: "attach",
|
|
2697
|
+
message: e instanceof Error ? e.message : String(e),
|
|
2698
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
2699
|
+
release: mt
|
|
2700
|
+
});
|
|
2701
|
+
} catch {}
|
|
2702
|
+
throw e;
|
|
2703
|
+
}), await Promise.race([l, new Promise((e, t) => {
|
|
2391
2704
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2392
|
-
})])
|
|
2705
|
+
})]).catch((e) => {
|
|
2706
|
+
try {
|
|
2707
|
+
f.reportSdkError({
|
|
2708
|
+
errorCode: "sdk.session.attach_failed",
|
|
2709
|
+
severity: "error",
|
|
2710
|
+
operation: "attach",
|
|
2711
|
+
message: e instanceof Error ? e.message : String(e),
|
|
2712
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
2713
|
+
release: mt
|
|
2714
|
+
});
|
|
2715
|
+
} catch {}
|
|
2716
|
+
throw e;
|
|
2717
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
2393
2718
|
}
|
|
2394
2719
|
async startListening() {
|
|
2395
2720
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2413,16 +2738,33 @@ var un = class e {
|
|
|
2413
2738
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2414
2739
|
}
|
|
2415
2740
|
async setFit(e) {
|
|
2416
|
-
let t =
|
|
2741
|
+
let t = ln(e);
|
|
2417
2742
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2418
2743
|
if (this.closed) throw Error("Session has ended.");
|
|
2419
2744
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2420
2745
|
}
|
|
2746
|
+
async setInteraction(e) {
|
|
2747
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2748
|
+
if (!this.iframeHost) throw Error("setInteraction() requires attach() first.");
|
|
2749
|
+
let t = await this.iframeHost.setInteraction(e);
|
|
2750
|
+
return this.lastInteraction = t, t;
|
|
2751
|
+
}
|
|
2752
|
+
async getInteraction() {
|
|
2753
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2754
|
+
if (!this.iframeHost) throw Error("getInteraction() requires attach() first.");
|
|
2755
|
+
let e = await this.iframeHost.getInteraction();
|
|
2756
|
+
return this.lastInteraction = e, e;
|
|
2757
|
+
}
|
|
2421
2758
|
async conversion(e) {
|
|
2422
2759
|
if (this.closed) throw Error("Session has ended.");
|
|
2423
2760
|
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
2424
2761
|
await this.iframeHost.conversion(e);
|
|
2425
2762
|
}
|
|
2763
|
+
async engage() {
|
|
2764
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2765
|
+
if (!this.iframeHost) throw Error("engage() requires attach() first.");
|
|
2766
|
+
await this.iframeHost.engage();
|
|
2767
|
+
}
|
|
2426
2768
|
getLastTurn() {
|
|
2427
2769
|
if (this.conversationCache.length === 0) return [];
|
|
2428
2770
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2432,7 +2774,7 @@ var un = class e {
|
|
|
2432
2774
|
this.close();
|
|
2433
2775
|
}
|
|
2434
2776
|
destroy() {
|
|
2435
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
2777
|
+
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, Ot(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
2436
2778
|
}
|
|
2437
2779
|
resolveMintInteraction() {
|
|
2438
2780
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2444,8 +2786,8 @@ var un = class e {
|
|
|
2444
2786
|
return this.resolvedSession?.id ?? "";
|
|
2445
2787
|
}
|
|
2446
2788
|
emitWrapped(e, t) {
|
|
2447
|
-
let n =
|
|
2448
|
-
return
|
|
2789
|
+
let n = wt(e, this.getSessionId(), t);
|
|
2790
|
+
return Dt(this.eventRegistry, e, n), n;
|
|
2449
2791
|
}
|
|
2450
2792
|
queueProcessorTurn(e) {
|
|
2451
2793
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2504,7 +2846,7 @@ var un = class e {
|
|
|
2504
2846
|
};
|
|
2505
2847
|
}
|
|
2506
2848
|
};
|
|
2507
|
-
function
|
|
2849
|
+
function fn(e) {
|
|
2508
2850
|
return e ? {
|
|
2509
2851
|
textSpeech: e.capabilities.speech.output,
|
|
2510
2852
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2515,41 +2857,41 @@ function dn(e) {
|
|
|
2515
2857
|
}
|
|
2516
2858
|
//#endregion
|
|
2517
2859
|
//#region src/widget/dockGeometry.ts
|
|
2518
|
-
var
|
|
2519
|
-
function
|
|
2860
|
+
var pn = "(min-width: 768px)", mn = 24, hn = .5, gn = 1200, _n = .85, vn = 9 / 16;
|
|
2861
|
+
function yn() {
|
|
2520
2862
|
if (typeof window > "u") return 800;
|
|
2521
2863
|
let e = window.screen?.availHeight;
|
|
2522
2864
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2523
2865
|
}
|
|
2524
|
-
function
|
|
2525
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2526
|
-
return s > a && (s = a, o = s /
|
|
2866
|
+
function bn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = mn, r = typeof window < "u" ? yn() : 800) {
|
|
2867
|
+
let i = Math.max(160, Math.min(t - n * 2, t * _n)), a = Math.max(120, e - n * 2), o = Math.min(r * hn, gn, i), s = o * vn;
|
|
2868
|
+
return s > a && (s = a, o = s / vn, o > i && (o = i, s = o * vn)), {
|
|
2527
2869
|
width: Math.round(s),
|
|
2528
2870
|
height: Math.round(o)
|
|
2529
2871
|
};
|
|
2530
2872
|
}
|
|
2531
|
-
function
|
|
2873
|
+
function xn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = mn) {
|
|
2532
2874
|
return {
|
|
2533
2875
|
left: Math.max(r, t - e.width - r),
|
|
2534
2876
|
top: Math.max(r, n - e.height - r)
|
|
2535
2877
|
};
|
|
2536
2878
|
}
|
|
2537
|
-
function
|
|
2879
|
+
function Sn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = mn) {
|
|
2538
2880
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2539
2881
|
return {
|
|
2540
2882
|
left: Math.min(Math.max(a, e), o),
|
|
2541
2883
|
top: Math.min(Math.max(a, t), s)
|
|
2542
2884
|
};
|
|
2543
2885
|
}
|
|
2544
|
-
function
|
|
2545
|
-
return e(
|
|
2886
|
+
function Cn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2887
|
+
return e(pn).matches;
|
|
2546
2888
|
}
|
|
2547
2889
|
//#endregion
|
|
2548
2890
|
//#region src/widget/mountExperienceWidget.ts
|
|
2549
|
-
function
|
|
2891
|
+
function wn(e) {
|
|
2550
2892
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2551
2893
|
}
|
|
2552
|
-
function
|
|
2894
|
+
function Tn(e) {
|
|
2553
2895
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2554
2896
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2555
2897
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2557,8 +2899,8 @@ function wn(e) {
|
|
|
2557
2899
|
function $(e) {
|
|
2558
2900
|
return e === "expanded" || e === "docked";
|
|
2559
2901
|
}
|
|
2560
|
-
var
|
|
2561
|
-
function
|
|
2902
|
+
var 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=\"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>", Dn = "<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>", On = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", kn = "<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>";
|
|
2903
|
+
function An(e, t, n) {
|
|
2562
2904
|
W(de);
|
|
2563
2905
|
let r = w({
|
|
2564
2906
|
galleryThumb: t.galleryThumb,
|
|
@@ -2588,7 +2930,7 @@ function kn(e, t, n) {
|
|
|
2588
2930
|
}
|
|
2589
2931
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2590
2932
|
}
|
|
2591
|
-
function
|
|
2933
|
+
function jn(e) {
|
|
2592
2934
|
return e.startButton ? {
|
|
2593
2935
|
...e.startButton,
|
|
2594
2936
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2600,7 +2942,7 @@ function An(e) {
|
|
|
2600
2942
|
variant: "primary"
|
|
2601
2943
|
};
|
|
2602
2944
|
}
|
|
2603
|
-
function
|
|
2945
|
+
function Mn(e) {
|
|
2604
2946
|
let t = !1, n = () => {
|
|
2605
2947
|
t || e();
|
|
2606
2948
|
}, r = () => {
|
|
@@ -2620,12 +2962,12 @@ function jn(e) {
|
|
|
2620
2962
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2621
2963
|
};
|
|
2622
2964
|
}
|
|
2623
|
-
function
|
|
2965
|
+
function Nn(e, t) {
|
|
2624
2966
|
he(me);
|
|
2625
2967
|
let n = t.experienceId?.trim();
|
|
2626
2968
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2627
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2628
|
-
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",
|
|
2969
|
+
let r = t.prefetch ?? "onExpand", i = wn(t.position), a = document.createElement("div");
|
|
2970
|
+
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", Tn(t.offset));
|
|
2629
2971
|
let o = document.createElement("button");
|
|
2630
2972
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2631
2973
|
let s = document.createElement("div");
|
|
@@ -2645,11 +2987,11 @@ function Mn(e, t) {
|
|
|
2645
2987
|
let m = document.createElement("span");
|
|
2646
2988
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2647
2989
|
let h = document.createElement("button");
|
|
2648
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2990
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = On, h.setAttribute("aria-label", "Reduce");
|
|
2649
2991
|
let g = document.createElement("button");
|
|
2650
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2992
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = En, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2651
2993
|
let _ = document.createElement("button");
|
|
2652
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2994
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Dn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2653
2995
|
let v = document.createElement("div");
|
|
2654
2996
|
v.className = "liforma-ew__stage";
|
|
2655
2997
|
let y = document.createElement("div");
|
|
@@ -2677,11 +3019,11 @@ function Mn(e, t) {
|
|
|
2677
3019
|
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";
|
|
2678
3020
|
}, oe = (e, t) => {
|
|
2679
3021
|
if (R() !== "docked") return;
|
|
2680
|
-
let n =
|
|
3022
|
+
let n = bn(), r = Sn(e - te, t - ne, n);
|
|
2681
3023
|
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2682
3024
|
}, se = (e, t) => {
|
|
2683
3025
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2684
|
-
let n =
|
|
3026
|
+
let n = bn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Sn(r + e, i + t, n);
|
|
2685
3027
|
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2686
3028
|
}, ce = (e) => {
|
|
2687
3029
|
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
@@ -2690,12 +3032,12 @@ function Mn(e, t) {
|
|
|
2690
3032
|
let t = I;
|
|
2691
3033
|
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
2692
3034
|
}, le = (e, t, n) => {
|
|
2693
|
-
if (S || R() !== "docked" || !
|
|
3035
|
+
if (S || R() !== "docked" || !Cn() || F !== null) return;
|
|
2694
3036
|
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2695
3037
|
let r = f.getBoundingClientRect();
|
|
2696
3038
|
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2697
3039
|
}, ue = (e) => {
|
|
2698
|
-
if (S || R() !== "docked" || !
|
|
3040
|
+
if (S || R() !== "docked" || !Cn() || F !== null) return;
|
|
2699
3041
|
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2700
3042
|
let t = f.getBoundingClientRect();
|
|
2701
3043
|
N = t.left, P = t.top;
|
|
@@ -2704,15 +3046,15 @@ function Mn(e, t) {
|
|
|
2704
3046
|
}, U = (e) => {
|
|
2705
3047
|
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2706
3048
|
}, W = () => {
|
|
2707
|
-
let e =
|
|
3049
|
+
let e = Cn(), t = R();
|
|
2708
3050
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2709
3051
|
h.hidden = !0;
|
|
2710
3052
|
return;
|
|
2711
3053
|
}
|
|
2712
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3054
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = kn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = On, h.setAttribute("aria-label", "Reduce"));
|
|
2713
3055
|
}, fe = (e) => {
|
|
2714
|
-
let t =
|
|
2715
|
-
n =
|
|
3056
|
+
let t = bn(), n = e && N !== null && P !== null ? Sn(N, P, t) : xn(t);
|
|
3057
|
+
n = Sn(n.left, n.top, t), N = n.left, P = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2716
3058
|
}, pe = () => {
|
|
2717
3059
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2718
3060
|
requestAnimationFrame(() => {
|
|
@@ -2759,7 +3101,7 @@ function Mn(e, t) {
|
|
|
2759
3101
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2760
3102
|
}, xe = (e) => {
|
|
2761
3103
|
A?.(), A = null;
|
|
2762
|
-
let t =
|
|
3104
|
+
let t = An(s, e, { parallax: ie });
|
|
2763
3105
|
return t ? (A = t, !0) : !1;
|
|
2764
3106
|
}, Se = () => {
|
|
2765
3107
|
if (xe(_e)) {
|
|
@@ -2785,10 +3127,11 @@ function Mn(e, t) {
|
|
|
2785
3127
|
...t.mode ? { mode: t.mode } : {},
|
|
2786
3128
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2787
3129
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3130
|
+
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
2788
3131
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2789
3132
|
}), we = () => ({
|
|
2790
3133
|
...t.fit ? { fit: t.fit } : {},
|
|
2791
|
-
startButton:
|
|
3134
|
+
startButton: jn(t),
|
|
2792
3135
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2793
3136
|
}), J = (e = !0) => {
|
|
2794
3137
|
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
@@ -2820,7 +3163,7 @@ function Mn(e, t) {
|
|
|
2820
3163
|
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
2821
3164
|
}
|
|
2822
3165
|
}, Y = () => {
|
|
2823
|
-
S ||
|
|
3166
|
+
S || Cn() && R() === "expanded" && G(() => {
|
|
2824
3167
|
Te();
|
|
2825
3168
|
});
|
|
2826
3169
|
}, X = () => {
|
|
@@ -2839,7 +3182,7 @@ function Mn(e, t) {
|
|
|
2839
3182
|
let e = O;
|
|
2840
3183
|
l.hidden = !1, (async () => {
|
|
2841
3184
|
try {
|
|
2842
|
-
let t = await
|
|
3185
|
+
let t = await dn.startSession(Ce());
|
|
2843
3186
|
if (S || e !== O) {
|
|
2844
3187
|
t.destroy();
|
|
2845
3188
|
return;
|
|
@@ -2898,7 +3241,7 @@ function Mn(e, t) {
|
|
|
2898
3241
|
x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
2899
3242
|
try {
|
|
2900
3243
|
J();
|
|
2901
|
-
let t = await
|
|
3244
|
+
let t = await dn.startSession(Ce());
|
|
2902
3245
|
if (S || e !== O) {
|
|
2903
3246
|
t.destroy();
|
|
2904
3247
|
return;
|
|
@@ -2965,13 +3308,13 @@ function Mn(e, t) {
|
|
|
2965
3308
|
}, Re = (e) => {
|
|
2966
3309
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2967
3310
|
}, ze = (e) => {
|
|
2968
|
-
R() === "docked" &&
|
|
3311
|
+
R() === "docked" && Cn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2969
3312
|
}, Be = (e) => {
|
|
2970
3313
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), ke());
|
|
2971
3314
|
}, Ve = () => {
|
|
2972
3315
|
if (!S) {
|
|
2973
3316
|
if (R() === "docked") {
|
|
2974
|
-
if (!
|
|
3317
|
+
if (!Cn()) {
|
|
2975
3318
|
X();
|
|
2976
3319
|
return;
|
|
2977
3320
|
}
|
|
@@ -2982,9 +3325,9 @@ function Mn(e, t) {
|
|
|
2982
3325
|
}
|
|
2983
3326
|
W();
|
|
2984
3327
|
}
|
|
2985
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
3328
|
+
}, He = typeof window < "u" ? window.matchMedia(pn) : null, Ue = () => {
|
|
2986
3329
|
if (!S) {
|
|
2987
|
-
if (R() === "docked" && !
|
|
3330
|
+
if (R() === "docked" && !Cn()) {
|
|
2988
3331
|
X();
|
|
2989
3332
|
return;
|
|
2990
3333
|
}
|
|
@@ -2995,7 +3338,7 @@ function Mn(e, t) {
|
|
|
2995
3338
|
e.stopPropagation(), ke();
|
|
2996
3339
|
}), h.addEventListener("click", Ie), g.addEventListener("click", Re), p.addEventListener("pointerdown", ze), window.addEventListener("keydown", Be), window.addEventListener("resize", Ve), He?.addEventListener("change", Ue), Se(), W(), r === "eager" ? queueMicrotask(() => {
|
|
2997
3340
|
S || Ne();
|
|
2998
|
-
}) : r === "idle" && (ee =
|
|
3341
|
+
}) : r === "idle" && (ee = Mn(() => {
|
|
2999
3342
|
S || Ne();
|
|
3000
3343
|
})), {
|
|
3001
3344
|
root: a,
|
|
@@ -3017,12 +3360,12 @@ function Mn(e, t) {
|
|
|
3017
3360
|
}
|
|
3018
3361
|
//#endregion
|
|
3019
3362
|
//#region src/react/ExperienceWidget.tsx
|
|
3020
|
-
function
|
|
3363
|
+
function Pn(t) {
|
|
3021
3364
|
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: ee, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = t, te = m === "bottom-right" || m === "bottom-left";
|
|
3022
3365
|
return e(() => {
|
|
3023
3366
|
let e = r.current;
|
|
3024
3367
|
if (!e || !i.trim()) return;
|
|
3025
|
-
let t =
|
|
3368
|
+
let t = Nn(e, {
|
|
3026
3369
|
experienceId: i,
|
|
3027
3370
|
alt: o,
|
|
3028
3371
|
galleryThumb: s,
|
|
@@ -3100,11 +3443,11 @@ function Nn(t) {
|
|
|
3100
3443
|
}
|
|
3101
3444
|
//#endregion
|
|
3102
3445
|
//#region src/next/index.ts
|
|
3103
|
-
function
|
|
3446
|
+
function Fn(e = {}) {
|
|
3104
3447
|
let t = v(e);
|
|
3105
3448
|
return { POST: ({ request: e }) => t(e) };
|
|
3106
3449
|
}
|
|
3107
3450
|
//#endregion
|
|
3108
|
-
export { pe as ExperienceThumbnail,
|
|
3451
|
+
export { pe as ExperienceThumbnail, Pn as ExperienceWidget, v as createLiformaSessionRouteHandler, Fn as createLiformaSvelteKitSessionHandler };
|
|
3109
3452
|
|
|
3110
3453
|
//# sourceMappingURL=index.js.map
|