@liforma/client 0.4.8 → 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 +12 -0
- package/dist/next/index.js +507 -180
- 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/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 +12 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +33 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +15 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +3 -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 +533 -220
- 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/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 +12 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +33 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +15 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +3 -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/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 +5 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +974 -646
- package/dist/react/index.js.map +1 -1
- 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/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 +12 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +33 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +15 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +3 -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 +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +4 -0
- 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/package.json +1 -1
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",
|
|
@@ -1431,6 +1466,21 @@ function ft(e) {
|
|
|
1431
1466
|
payload: { correlationId: Z() }
|
|
1432
1467
|
});
|
|
1433
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
|
+
},
|
|
1434
1484
|
destroy() {
|
|
1435
1485
|
if (!r) {
|
|
1436
1486
|
r = !0, i && s(!1);
|
|
@@ -1456,51 +1506,272 @@ function pt(e) {
|
|
|
1456
1506
|
};
|
|
1457
1507
|
}
|
|
1458
1508
|
//#endregion
|
|
1459
|
-
//#region src/v2/
|
|
1460
|
-
var mt =
|
|
1461
|
-
|
|
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() {
|
|
1462
1733
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1463
1734
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1464
1735
|
if (typeof document > "u") return null;
|
|
1465
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();
|
|
1466
1737
|
return t ? t.replace(/\/$/, "") : null;
|
|
1467
1738
|
}
|
|
1468
|
-
function
|
|
1469
|
-
let e =
|
|
1470
|
-
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;
|
|
1471
1742
|
}
|
|
1472
|
-
function
|
|
1743
|
+
function yt(e, t) {
|
|
1473
1744
|
return e?.trim() || t?.trim() || void 0;
|
|
1474
1745
|
}
|
|
1475
|
-
function
|
|
1476
|
-
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();
|
|
1477
1748
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1478
1749
|
let f = r?.trim();
|
|
1479
|
-
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());
|
|
1480
1751
|
}
|
|
1481
|
-
function
|
|
1752
|
+
function xt(e) {
|
|
1482
1753
|
if (typeof location > "u") return e;
|
|
1483
1754
|
let t = new URL(e);
|
|
1484
1755
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1485
1756
|
}
|
|
1486
|
-
function
|
|
1757
|
+
function St(e) {
|
|
1487
1758
|
return new URL(e).origin;
|
|
1488
1759
|
}
|
|
1489
1760
|
//#endregion
|
|
1490
1761
|
//#region src/v2/experienceEvents.ts
|
|
1491
|
-
function
|
|
1762
|
+
function Ct() {
|
|
1492
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)}`;
|
|
1493
1764
|
}
|
|
1494
|
-
function
|
|
1765
|
+
function wt(e, t, n) {
|
|
1495
1766
|
return {
|
|
1496
|
-
id:
|
|
1767
|
+
id: Ct(),
|
|
1497
1768
|
type: e,
|
|
1498
1769
|
sessionId: t,
|
|
1499
1770
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1500
1771
|
data: n
|
|
1501
1772
|
};
|
|
1502
1773
|
}
|
|
1503
|
-
function
|
|
1774
|
+
function Tt() {
|
|
1504
1775
|
return {
|
|
1505
1776
|
ready: /* @__PURE__ */ new Set(),
|
|
1506
1777
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1515,44 +1786,45 @@ function wt() {
|
|
|
1515
1786
|
message: /* @__PURE__ */ new Set(),
|
|
1516
1787
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1517
1788
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1789
|
+
interactionChange: /* @__PURE__ */ new Set(),
|
|
1518
1790
|
feedback: /* @__PURE__ */ new Set(),
|
|
1519
1791
|
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1520
1792
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1521
1793
|
};
|
|
1522
1794
|
}
|
|
1523
|
-
function
|
|
1795
|
+
function Et(e, t, n) {
|
|
1524
1796
|
return e[t].add(n), () => e[t].delete(n);
|
|
1525
1797
|
}
|
|
1526
|
-
function
|
|
1798
|
+
function Dt(e, t, n) {
|
|
1527
1799
|
for (let r of e[t]) r(n);
|
|
1528
1800
|
}
|
|
1529
|
-
function
|
|
1801
|
+
function Ot(e) {
|
|
1530
1802
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1531
1803
|
}
|
|
1532
1804
|
//#endregion
|
|
1533
1805
|
//#region src/v2/speech/types.ts
|
|
1534
|
-
function
|
|
1806
|
+
function kt(e) {
|
|
1535
1807
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1536
1808
|
}
|
|
1537
|
-
function
|
|
1809
|
+
function At(e) {
|
|
1538
1810
|
return "url" in e && typeof e.url == "string";
|
|
1539
1811
|
}
|
|
1540
|
-
function
|
|
1812
|
+
function jt(e) {
|
|
1541
1813
|
if (!("track" in e)) return !1;
|
|
1542
1814
|
let t = e.track;
|
|
1543
1815
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1544
1816
|
}
|
|
1545
|
-
function
|
|
1546
|
-
return !
|
|
1817
|
+
function Mt(e) {
|
|
1818
|
+
return !kt(e) && !At(e) && !jt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1547
1819
|
}
|
|
1548
|
-
var
|
|
1820
|
+
var Nt = [
|
|
1549
1821
|
8e3,
|
|
1550
1822
|
16e3,
|
|
1551
1823
|
22050,
|
|
1552
1824
|
24e3,
|
|
1553
1825
|
44100,
|
|
1554
1826
|
48e3
|
|
1555
|
-
],
|
|
1827
|
+
], Pt = {
|
|
1556
1828
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1557
1829
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1558
1830
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1563,14 +1835,14 @@ var Mt = [
|
|
|
1563
1835
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1564
1836
|
MAX_PENDING_WRITES: 8,
|
|
1565
1837
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1566
|
-
},
|
|
1838
|
+
}, Ft = class extends Error {
|
|
1567
1839
|
operation;
|
|
1568
1840
|
requiredCapability;
|
|
1569
1841
|
name = "UnsupportedSpeechOperationError";
|
|
1570
1842
|
constructor(e, t) {
|
|
1571
1843
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1572
1844
|
}
|
|
1573
|
-
},
|
|
1845
|
+
}, It = class extends Error {
|
|
1574
1846
|
name = "SpeechUtteranceClosedError";
|
|
1575
1847
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1576
1848
|
super(e);
|
|
@@ -1580,72 +1852,72 @@ var Mt = [
|
|
|
1580
1852
|
constructor(e, t) {
|
|
1581
1853
|
super(e, t);
|
|
1582
1854
|
}
|
|
1583
|
-
},
|
|
1855
|
+
}, Lt = class extends Error {
|
|
1584
1856
|
name = "SpeechBufferTimeoutError";
|
|
1585
1857
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1586
1858
|
super(e);
|
|
1587
1859
|
}
|
|
1588
1860
|
};
|
|
1589
|
-
function
|
|
1861
|
+
function Rt(e = "none") {
|
|
1590
1862
|
return {
|
|
1591
1863
|
mode: e,
|
|
1592
1864
|
trackedDurationMs: 0,
|
|
1593
1865
|
fallbackDurationMs: 0
|
|
1594
1866
|
};
|
|
1595
1867
|
}
|
|
1596
|
-
function Rt(e) {
|
|
1597
|
-
return Mt.includes(e);
|
|
1598
|
-
}
|
|
1599
1868
|
function zt(e) {
|
|
1869
|
+
return Nt.includes(e);
|
|
1870
|
+
}
|
|
1871
|
+
function Bt(e) {
|
|
1600
1872
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1601
1873
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1602
|
-
if (!
|
|
1874
|
+
if (!zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1603
1875
|
}
|
|
1604
|
-
function
|
|
1605
|
-
if (
|
|
1606
|
-
|
|
1876
|
+
function Vt(e) {
|
|
1877
|
+
if (kt(e)) {
|
|
1878
|
+
Bt(e.format);
|
|
1607
1879
|
return;
|
|
1608
1880
|
}
|
|
1609
|
-
if (
|
|
1881
|
+
if (At(e)) {
|
|
1610
1882
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1611
|
-
if (e.sampleRate !== void 0 && !
|
|
1883
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1612
1884
|
return;
|
|
1613
1885
|
}
|
|
1614
|
-
if (
|
|
1886
|
+
if (jt(e)) {
|
|
1615
1887
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1616
|
-
if (e.sampleRate !== void 0 && !
|
|
1888
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1617
1889
|
return;
|
|
1618
1890
|
}
|
|
1619
|
-
if (
|
|
1891
|
+
if (Mt(e)) {
|
|
1620
1892
|
let t = e.encoding.trim().toLowerCase();
|
|
1621
1893
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1622
1894
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1623
|
-
if (e.sampleRate !== void 0 && !
|
|
1895
|
+
if (e.sampleRate !== void 0 && !zt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1624
1896
|
return;
|
|
1625
1897
|
}
|
|
1626
1898
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1627
1899
|
}
|
|
1628
|
-
function
|
|
1629
|
-
if (e.format) return
|
|
1900
|
+
function Ht(e) {
|
|
1901
|
+
if (e.format) return Bt(e.format), e.format;
|
|
1630
1902
|
if (e.track) {
|
|
1631
1903
|
let t = {
|
|
1632
1904
|
encoding: "pcm_s16le",
|
|
1633
1905
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1634
1906
|
channels: 1
|
|
1635
1907
|
};
|
|
1636
|
-
return
|
|
1908
|
+
return Bt(t), t;
|
|
1637
1909
|
}
|
|
1638
1910
|
throw new Q("createUtterance requires format or track.");
|
|
1639
1911
|
}
|
|
1640
|
-
function
|
|
1912
|
+
function Ut(e) {
|
|
1641
1913
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1642
1914
|
}
|
|
1643
|
-
function
|
|
1915
|
+
function Wt(e) {
|
|
1644
1916
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1645
1917
|
}
|
|
1646
1918
|
//#endregion
|
|
1647
1919
|
//#region src/byo/pcm.ts
|
|
1648
|
-
function
|
|
1920
|
+
function Gt(e) {
|
|
1649
1921
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1650
1922
|
for (let t = 0; t < e.length; t++) {
|
|
1651
1923
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1655,11 +1927,11 @@ function Wt(e) {
|
|
|
1655
1927
|
}
|
|
1656
1928
|
//#endregion
|
|
1657
1929
|
//#region src/byo/resample.ts
|
|
1658
|
-
function
|
|
1930
|
+
function Kt(e, t, n, r, i) {
|
|
1659
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;
|
|
1660
1932
|
return ((a * i + o) * i + s) * i + c;
|
|
1661
1933
|
}
|
|
1662
|
-
function
|
|
1934
|
+
function qt(e, t) {
|
|
1663
1935
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1664
1936
|
if (e === t) return {
|
|
1665
1937
|
fromRate: e,
|
|
@@ -1682,7 +1954,7 @@ function Kt(e, t) {
|
|
|
1682
1954
|
let a = [];
|
|
1683
1955
|
for (; i + 2 < r.length - 1;) {
|
|
1684
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);
|
|
1685
|
-
a.push(
|
|
1957
|
+
a.push(Kt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1686
1958
|
}
|
|
1687
1959
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1688
1960
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1694,7 +1966,7 @@ function Kt(e, t) {
|
|
|
1694
1966
|
}
|
|
1695
1967
|
//#endregion
|
|
1696
1968
|
//#region src/byo/audioCapture.ts
|
|
1697
|
-
var
|
|
1969
|
+
var Jt = "liforma-pcm-capture", Yt = `
|
|
1698
1970
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1699
1971
|
process(inputs) {
|
|
1700
1972
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1706,29 +1978,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1706
1978
|
return true;
|
|
1707
1979
|
}
|
|
1708
1980
|
}
|
|
1709
|
-
registerProcessor('${
|
|
1710
|
-
`,
|
|
1711
|
-
function Xt() {
|
|
1712
|
-
return Yt ||= URL.createObjectURL(new Blob([Jt], { type: "application/javascript" })), Yt;
|
|
1713
|
-
}
|
|
1981
|
+
registerProcessor('${Jt}', LiformaPcmCaptureProcessor);
|
|
1982
|
+
`, Xt = null;
|
|
1714
1983
|
function Zt() {
|
|
1984
|
+
return Xt ||= URL.createObjectURL(new Blob([Yt], { type: "application/javascript" })), Xt;
|
|
1985
|
+
}
|
|
1986
|
+
function Qt() {
|
|
1715
1987
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1716
1988
|
}
|
|
1717
|
-
async function
|
|
1718
|
-
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();
|
|
1719
1991
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1720
1992
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1721
1993
|
l.gain.value = 0;
|
|
1722
|
-
let u = s.sampleRate, d =
|
|
1994
|
+
let u = s.sampleRate, d = qt(u, n), f = !1, p = !1, m = (e) => {
|
|
1723
1995
|
if (f || i && !i()) return;
|
|
1724
1996
|
let t = d.push(e);
|
|
1725
|
-
t.length !== 0 && r(
|
|
1997
|
+
t.length !== 0 && r(Gt(t));
|
|
1726
1998
|
}, h = () => void 0;
|
|
1727
1999
|
return await (async () => {
|
|
1728
2000
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1729
2001
|
try {
|
|
1730
|
-
await s.audioWorklet.addModule(
|
|
1731
|
-
let e = new AudioWorkletNode(s,
|
|
2002
|
+
await s.audioWorklet.addModule(Zt());
|
|
2003
|
+
let e = new AudioWorkletNode(s, Jt, {
|
|
1732
2004
|
numberOfInputs: 1,
|
|
1733
2005
|
numberOfOutputs: 1,
|
|
1734
2006
|
outputChannelCount: [1]
|
|
@@ -1778,7 +2050,7 @@ async function Qt(e) {
|
|
|
1778
2050
|
}
|
|
1779
2051
|
//#endregion
|
|
1780
2052
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1781
|
-
async function
|
|
2053
|
+
async function en(e) {
|
|
1782
2054
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1783
2055
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1784
2056
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1787,18 +2059,18 @@ async function $t(e) {
|
|
|
1787
2059
|
s || (s = !0, c?.stop(), c = null);
|
|
1788
2060
|
};
|
|
1789
2061
|
try {
|
|
1790
|
-
c = await
|
|
2062
|
+
c = await $t({
|
|
1791
2063
|
mediaStream: a,
|
|
1792
2064
|
targetSampleRate: r,
|
|
1793
2065
|
shouldSend: () => !s && !i?.aborted,
|
|
1794
2066
|
onPcm: (e) => {
|
|
1795
2067
|
if (s || i?.aborted) return;
|
|
1796
|
-
let t =
|
|
2068
|
+
let t = Ut(e);
|
|
1797
2069
|
o = o.then(async () => {
|
|
1798
2070
|
if (s || i?.aborted) return;
|
|
1799
2071
|
let e = 0;
|
|
1800
2072
|
for (; e < t.byteLength;) {
|
|
1801
|
-
let r = Math.min(e +
|
|
2073
|
+
let r = Math.min(e + Pt.MAX_CHUNK_BYTES, t.byteLength);
|
|
1802
2074
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1803
2075
|
let i = t.subarray(e, r);
|
|
1804
2076
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1822,10 +2094,10 @@ async function $t(e) {
|
|
|
1822
2094
|
}
|
|
1823
2095
|
//#endregion
|
|
1824
2096
|
//#region src/v2/speech/speechController.ts
|
|
1825
|
-
async function
|
|
1826
|
-
if (
|
|
1827
|
-
if (
|
|
1828
|
-
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);
|
|
1829
2101
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1830
2102
|
return {
|
|
1831
2103
|
kind: "pcm",
|
|
@@ -1833,17 +2105,17 @@ async function en(e, t) {
|
|
|
1833
2105
|
format: e.format
|
|
1834
2106
|
};
|
|
1835
2107
|
}
|
|
1836
|
-
if (
|
|
2108
|
+
if (At(e)) return {
|
|
1837
2109
|
kind: "url",
|
|
1838
2110
|
url: e.url.trim(),
|
|
1839
2111
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1840
2112
|
};
|
|
1841
|
-
if (!
|
|
2113
|
+
if (!Mt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1842
2114
|
let n;
|
|
1843
2115
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1844
2116
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1845
2117
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1846
|
-
} else n =
|
|
2118
|
+
} else n = Ut(e.data);
|
|
1847
2119
|
return {
|
|
1848
2120
|
kind: "encoded",
|
|
1849
2121
|
data: n.slice().buffer,
|
|
@@ -1851,10 +2123,10 @@ async function en(e, t) {
|
|
|
1851
2123
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1852
2124
|
};
|
|
1853
2125
|
}
|
|
1854
|
-
function
|
|
2126
|
+
function nn() {
|
|
1855
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)}`;
|
|
1856
2128
|
}
|
|
1857
|
-
function
|
|
2129
|
+
function rn(e, t = "completed") {
|
|
1858
2130
|
return {
|
|
1859
2131
|
utteranceId: e.speechId,
|
|
1860
2132
|
characterId: e.characterId,
|
|
@@ -1868,13 +2140,13 @@ function nn(e, t = "completed") {
|
|
|
1868
2140
|
}
|
|
1869
2141
|
};
|
|
1870
2142
|
}
|
|
1871
|
-
function
|
|
2143
|
+
function an(e) {
|
|
1872
2144
|
return e instanceof Error ? e : new Q(String(e));
|
|
1873
2145
|
}
|
|
1874
|
-
function
|
|
2146
|
+
function on(e) {
|
|
1875
2147
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1876
2148
|
}
|
|
1877
|
-
var
|
|
2149
|
+
var sn = class {
|
|
1878
2150
|
id;
|
|
1879
2151
|
characterId;
|
|
1880
2152
|
result;
|
|
@@ -1903,29 +2175,29 @@ var on = class {
|
|
|
1903
2175
|
queue: e.queue,
|
|
1904
2176
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1905
2177
|
}).catch((e) => {
|
|
1906
|
-
throw this.fail(
|
|
2178
|
+
throw this.fail(an(e)), an(e);
|
|
1907
2179
|
}), this.signal?.addEventListener("abort", () => {
|
|
1908
2180
|
this.cancel();
|
|
1909
2181
|
}, { once: !0 });
|
|
1910
2182
|
}
|
|
1911
2183
|
async write(e, t) {
|
|
1912
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1913
|
-
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);
|
|
1914
2186
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1915
|
-
if (n.byteLength >
|
|
2187
|
+
if (n.byteLength > Pt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Pt.MAX_CHUNK_BYTES}).`);
|
|
1916
2188
|
if (n.byteLength === 0) return;
|
|
1917
|
-
let r = t?.timeoutMs ??
|
|
2189
|
+
let r = t?.timeoutMs ?? Pt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1918
2190
|
await this.acquireWriteSlot(r);
|
|
1919
2191
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1920
|
-
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.");
|
|
1921
2193
|
let a = async () => {
|
|
1922
|
-
if (this.closed || this.settled) throw new
|
|
2194
|
+
if (this.closed || this.settled) throw new It();
|
|
1923
2195
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1924
2196
|
utteranceId: this.id,
|
|
1925
2197
|
audio: t.buffer,
|
|
1926
2198
|
byteLength: t.byteLength
|
|
1927
2199
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1928
|
-
setTimeout(() => t(new
|
|
2200
|
+
setTimeout(() => t(new Lt()), r);
|
|
1929
2201
|
})]);
|
|
1930
2202
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1931
2203
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1937,7 +2209,7 @@ var on = class {
|
|
|
1937
2209
|
}
|
|
1938
2210
|
}
|
|
1939
2211
|
async setTranscript(e) {
|
|
1940
|
-
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();
|
|
1941
2213
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1942
2214
|
utteranceId: this.id,
|
|
1943
2215
|
transcript: e
|
|
@@ -1954,7 +2226,7 @@ var on = class {
|
|
|
1954
2226
|
});
|
|
1955
2227
|
return this.resolve(t), t;
|
|
1956
2228
|
} catch (e) {
|
|
1957
|
-
let t =
|
|
2229
|
+
let t = an(e);
|
|
1958
2230
|
throw this.fail(t), t;
|
|
1959
2231
|
}
|
|
1960
2232
|
}
|
|
@@ -1972,11 +2244,11 @@ var on = class {
|
|
|
1972
2244
|
characterId: this.characterId,
|
|
1973
2245
|
status: "cancelled",
|
|
1974
2246
|
durationMs: 0,
|
|
1975
|
-
animation:
|
|
2247
|
+
animation: Rt("none")
|
|
1976
2248
|
};
|
|
1977
2249
|
return this.resolve(t), t;
|
|
1978
2250
|
} catch (e) {
|
|
1979
|
-
let t =
|
|
2251
|
+
let t = an(e);
|
|
1980
2252
|
throw this.fail(t), t;
|
|
1981
2253
|
}
|
|
1982
2254
|
}
|
|
@@ -1989,19 +2261,19 @@ var on = class {
|
|
|
1989
2261
|
return e;
|
|
1990
2262
|
}
|
|
1991
2263
|
resolve(e) {
|
|
1992
|
-
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()));
|
|
1993
2265
|
}
|
|
1994
2266
|
fail(e) {
|
|
1995
2267
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1996
2268
|
}
|
|
1997
2269
|
async acquireWriteSlot(e) {
|
|
1998
|
-
if (this.pendingWriteCount <
|
|
2270
|
+
if (this.pendingWriteCount < Pt.MAX_PENDING_WRITES) {
|
|
1999
2271
|
this.pendingWriteCount += 1;
|
|
2000
2272
|
return;
|
|
2001
2273
|
}
|
|
2002
2274
|
await new Promise((t, n) => {
|
|
2003
2275
|
let r = setTimeout(() => {
|
|
2004
|
-
n(new
|
|
2276
|
+
n(new Lt());
|
|
2005
2277
|
}, e);
|
|
2006
2278
|
this.pendingWriteWaiters.push({
|
|
2007
2279
|
resolve: () => {
|
|
@@ -2020,13 +2292,13 @@ var on = class {
|
|
|
2020
2292
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2021
2293
|
}
|
|
2022
2294
|
};
|
|
2023
|
-
function
|
|
2295
|
+
function cn(e) {
|
|
2024
2296
|
let t = null, n = (t, n) => {
|
|
2025
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2297
|
+
if (!e.getCapabilities()[n]) throw new Ft(t, n);
|
|
2026
2298
|
}, r = {
|
|
2027
2299
|
async speak(r) {
|
|
2028
2300
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2029
|
-
let i =
|
|
2301
|
+
let i = Wt(r.queue ?? "append");
|
|
2030
2302
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2031
2303
|
let a = e.getIframeHost();
|
|
2032
2304
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2046,41 +2318,41 @@ function sn(e) {
|
|
|
2046
2318
|
return;
|
|
2047
2319
|
}
|
|
2048
2320
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2049
|
-
t.removeEventListener("abort", s), n(
|
|
2321
|
+
t.removeEventListener("abort", s), n(rn(e, "completed"));
|
|
2050
2322
|
}, (a) => {
|
|
2051
|
-
if (t.removeEventListener("abort", s),
|
|
2323
|
+
if (t.removeEventListener("abort", s), on(a)) {
|
|
2052
2324
|
n({
|
|
2053
2325
|
utteranceId: "utt_interrupted",
|
|
2054
2326
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2055
2327
|
status: "interrupted",
|
|
2056
2328
|
durationMs: 0,
|
|
2057
2329
|
transcript: r.text,
|
|
2058
|
-
animation:
|
|
2330
|
+
animation: Rt("none")
|
|
2059
2331
|
});
|
|
2060
2332
|
return;
|
|
2061
2333
|
}
|
|
2062
|
-
i(
|
|
2334
|
+
i(an(a));
|
|
2063
2335
|
});
|
|
2064
2336
|
});
|
|
2065
2337
|
}
|
|
2066
2338
|
try {
|
|
2067
|
-
return
|
|
2339
|
+
return rn(await o, "completed");
|
|
2068
2340
|
} catch (t) {
|
|
2069
|
-
if (
|
|
2341
|
+
if (on(t)) return {
|
|
2070
2342
|
utteranceId: "utt_interrupted",
|
|
2071
2343
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2072
2344
|
status: "interrupted",
|
|
2073
2345
|
durationMs: 0,
|
|
2074
2346
|
transcript: r.text,
|
|
2075
|
-
animation:
|
|
2347
|
+
animation: Rt("none")
|
|
2076
2348
|
};
|
|
2077
|
-
throw
|
|
2349
|
+
throw an(t);
|
|
2078
2350
|
}
|
|
2079
2351
|
},
|
|
2080
2352
|
async play(i) {
|
|
2081
|
-
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");
|
|
2082
2354
|
let a = i.queue ?? "append";
|
|
2083
|
-
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)) {
|
|
2084
2356
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2085
2357
|
return r.createUtterance({
|
|
2086
2358
|
format: {
|
|
@@ -2096,7 +2368,7 @@ function sn(e) {
|
|
|
2096
2368
|
}
|
|
2097
2369
|
let o = e.getIframeHost();
|
|
2098
2370
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2099
|
-
let s = await
|
|
2371
|
+
let s = await tn(i.audio, i.signal);
|
|
2100
2372
|
return o.speechPlay({
|
|
2101
2373
|
source: s,
|
|
2102
2374
|
characterId: i.characterId,
|
|
@@ -2108,13 +2380,13 @@ function sn(e) {
|
|
|
2108
2380
|
},
|
|
2109
2381
|
createUtterance(r) {
|
|
2110
2382
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2111
|
-
let i =
|
|
2383
|
+
let i = Ht(r);
|
|
2112
2384
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2113
2385
|
let a = r.queue ?? "replace-active";
|
|
2114
2386
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2115
2387
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2116
|
-
let o = new
|
|
2117
|
-
id:
|
|
2388
|
+
let o = new sn({
|
|
2389
|
+
id: nn(),
|
|
2118
2390
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2119
2391
|
format: i,
|
|
2120
2392
|
queue: a,
|
|
@@ -2126,7 +2398,7 @@ function sn(e) {
|
|
|
2126
2398
|
t === o && (t = null);
|
|
2127
2399
|
}), r.track && (async () => {
|
|
2128
2400
|
try {
|
|
2129
|
-
if (await
|
|
2401
|
+
if (await en({
|
|
2130
2402
|
track: r.track,
|
|
2131
2403
|
utterance: o,
|
|
2132
2404
|
sampleRate: i.sampleRate,
|
|
@@ -2154,16 +2426,16 @@ function sn(e) {
|
|
|
2154
2426
|
}
|
|
2155
2427
|
//#endregion
|
|
2156
2428
|
//#region src/v2/types/sessionInteraction.ts
|
|
2157
|
-
function
|
|
2429
|
+
function ln(e) {
|
|
2158
2430
|
let t = e?.trim();
|
|
2159
2431
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2160
2432
|
}
|
|
2161
2433
|
//#endregion
|
|
2162
2434
|
//#region src/v2/experience.ts
|
|
2163
|
-
function
|
|
2435
|
+
function un(e) {
|
|
2164
2436
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2165
2437
|
}
|
|
2166
|
-
var
|
|
2438
|
+
var dn = class e {
|
|
2167
2439
|
bootstrap;
|
|
2168
2440
|
conversationProcessor;
|
|
2169
2441
|
iframeHost = null;
|
|
@@ -2177,18 +2449,19 @@ var un = class e {
|
|
|
2177
2449
|
closed = !1;
|
|
2178
2450
|
attached = !1;
|
|
2179
2451
|
pendingFit = null;
|
|
2452
|
+
lastInteraction = null;
|
|
2180
2453
|
closeHandlers = [];
|
|
2181
|
-
eventRegistry =
|
|
2454
|
+
eventRegistry = Tt();
|
|
2182
2455
|
readyEnvelope = null;
|
|
2183
2456
|
startedEnvelope = null;
|
|
2184
2457
|
sessionMintedEnvelope = null;
|
|
2185
2458
|
conversationCache = [];
|
|
2186
2459
|
speech;
|
|
2187
2460
|
constructor(e) {
|
|
2188
|
-
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({
|
|
2189
2462
|
getIframeHost: () => this.iframeHost,
|
|
2190
2463
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2191
|
-
getCapabilities: () =>
|
|
2464
|
+
getCapabilities: () => fn(this.resolvedSession),
|
|
2192
2465
|
getActiveCharacterId: () => "character_unknown",
|
|
2193
2466
|
onProcessorInterrupt: () => {
|
|
2194
2467
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2233,6 +2506,7 @@ var un = class e {
|
|
|
2233
2506
|
speechInputMode: t.speechInputMode,
|
|
2234
2507
|
speechOnly: t.speechOnly,
|
|
2235
2508
|
attribution: t.attribution,
|
|
2509
|
+
alreadyConverted: t.alreadyConverted,
|
|
2236
2510
|
ui: t.ui,
|
|
2237
2511
|
onStart: t.onStart,
|
|
2238
2512
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2255,6 +2529,7 @@ var un = class e {
|
|
|
2255
2529
|
speechInputMode: t.speechInputMode,
|
|
2256
2530
|
speechOnly: t.speechOnly,
|
|
2257
2531
|
attribution: t.attribution,
|
|
2532
|
+
alreadyConverted: t.alreadyConverted,
|
|
2258
2533
|
ui: t.ui,
|
|
2259
2534
|
onStart: t.onStart,
|
|
2260
2535
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2269,7 +2544,7 @@ var un = class e {
|
|
|
2269
2544
|
return null;
|
|
2270
2545
|
}
|
|
2271
2546
|
on(e, t) {
|
|
2272
|
-
let n =
|
|
2547
|
+
let n = Et(this.eventRegistry, e, t);
|
|
2273
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;
|
|
2274
2549
|
}
|
|
2275
2550
|
async attach(e) {
|
|
@@ -2283,7 +2558,7 @@ var un = class e {
|
|
|
2283
2558
|
if (this.closed) throw Error("Session has ended.");
|
|
2284
2559
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2285
2560
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2286
|
-
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) => {
|
|
2287
2562
|
o = e;
|
|
2288
2563
|
}), c = null, l = new Promise((e) => {
|
|
2289
2564
|
c = e;
|
|
@@ -2328,6 +2603,9 @@ var un = class e {
|
|
|
2328
2603
|
onActivityChange: (e) => {
|
|
2329
2604
|
this.emitWrapped("activityChange", e);
|
|
2330
2605
|
},
|
|
2606
|
+
onInteractionChange: (e) => {
|
|
2607
|
+
this.lastInteraction = e, this.emitWrapped("interactionChange", e);
|
|
2608
|
+
},
|
|
2331
2609
|
onFeedback: (e) => {
|
|
2332
2610
|
this.emitWrapped("feedback", e);
|
|
2333
2611
|
},
|
|
@@ -2362,6 +2640,7 @@ var un = class e {
|
|
|
2362
2640
|
speechInputMode: p.speechInputMode,
|
|
2363
2641
|
speechOnly: this.bootstrap.speechOnly,
|
|
2364
2642
|
attribution: this.bootstrap.attribution,
|
|
2643
|
+
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
2365
2644
|
signal: this.endpointAbortController.signal
|
|
2366
2645
|
})) : this.bootstrap.kind === "public" ? Ue(this.bootstrap.experienceId, {
|
|
2367
2646
|
locale: this.bootstrap.locale,
|
|
@@ -2371,7 +2650,8 @@ var un = class e {
|
|
|
2371
2650
|
mode: p.mode,
|
|
2372
2651
|
speechInputMode: p.speechInputMode,
|
|
2373
2652
|
speechOnly: this.bootstrap.speechOnly,
|
|
2374
|
-
attribution: this.bootstrap.attribution
|
|
2653
|
+
attribution: this.bootstrap.attribution,
|
|
2654
|
+
alreadyConverted: this.bootstrap.alreadyConverted
|
|
2375
2655
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2376
2656
|
session: this.bootstrap.session,
|
|
2377
2657
|
launch: this.bootstrap.launch
|
|
@@ -2379,6 +2659,16 @@ var un = class e {
|
|
|
2379
2659
|
try {
|
|
2380
2660
|
[, h] = await Promise.all([f.waitForLoad(), m]);
|
|
2381
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 {}
|
|
2382
2672
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
2383
2673
|
} finally {
|
|
2384
2674
|
this.endpointAbortController = null;
|
|
@@ -2398,9 +2688,33 @@ var un = class e {
|
|
|
2398
2688
|
showFeedback: e.showFeedback
|
|
2399
2689
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2400
2690
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2401
|
-
})])
|
|
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) => {
|
|
2402
2704
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2403
|
-
})])
|
|
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();
|
|
2404
2718
|
}
|
|
2405
2719
|
async startListening() {
|
|
2406
2720
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2424,11 +2738,23 @@ var un = class e {
|
|
|
2424
2738
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2425
2739
|
}
|
|
2426
2740
|
async setFit(e) {
|
|
2427
|
-
let t =
|
|
2741
|
+
let t = ln(e);
|
|
2428
2742
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2429
2743
|
if (this.closed) throw Error("Session has ended.");
|
|
2430
2744
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2431
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
|
+
}
|
|
2432
2758
|
async conversion(e) {
|
|
2433
2759
|
if (this.closed) throw Error("Session has ended.");
|
|
2434
2760
|
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
@@ -2448,7 +2774,7 @@ var un = class e {
|
|
|
2448
2774
|
this.close();
|
|
2449
2775
|
}
|
|
2450
2776
|
destroy() {
|
|
2451
|
-
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);
|
|
2452
2778
|
}
|
|
2453
2779
|
resolveMintInteraction() {
|
|
2454
2780
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2460,8 +2786,8 @@ var un = class e {
|
|
|
2460
2786
|
return this.resolvedSession?.id ?? "";
|
|
2461
2787
|
}
|
|
2462
2788
|
emitWrapped(e, t) {
|
|
2463
|
-
let n =
|
|
2464
|
-
return
|
|
2789
|
+
let n = wt(e, this.getSessionId(), t);
|
|
2790
|
+
return Dt(this.eventRegistry, e, n), n;
|
|
2465
2791
|
}
|
|
2466
2792
|
queueProcessorTurn(e) {
|
|
2467
2793
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2520,7 +2846,7 @@ var un = class e {
|
|
|
2520
2846
|
};
|
|
2521
2847
|
}
|
|
2522
2848
|
};
|
|
2523
|
-
function
|
|
2849
|
+
function fn(e) {
|
|
2524
2850
|
return e ? {
|
|
2525
2851
|
textSpeech: e.capabilities.speech.output,
|
|
2526
2852
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2531,41 +2857,41 @@ function dn(e) {
|
|
|
2531
2857
|
}
|
|
2532
2858
|
//#endregion
|
|
2533
2859
|
//#region src/widget/dockGeometry.ts
|
|
2534
|
-
var
|
|
2535
|
-
function
|
|
2860
|
+
var pn = "(min-width: 768px)", mn = 24, hn = .5, gn = 1200, _n = .85, vn = 9 / 16;
|
|
2861
|
+
function yn() {
|
|
2536
2862
|
if (typeof window > "u") return 800;
|
|
2537
2863
|
let e = window.screen?.availHeight;
|
|
2538
2864
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2539
2865
|
}
|
|
2540
|
-
function
|
|
2541
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2542
|
-
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)), {
|
|
2543
2869
|
width: Math.round(s),
|
|
2544
2870
|
height: Math.round(o)
|
|
2545
2871
|
};
|
|
2546
2872
|
}
|
|
2547
|
-
function
|
|
2873
|
+
function xn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = mn) {
|
|
2548
2874
|
return {
|
|
2549
2875
|
left: Math.max(r, t - e.width - r),
|
|
2550
2876
|
top: Math.max(r, n - e.height - r)
|
|
2551
2877
|
};
|
|
2552
2878
|
}
|
|
2553
|
-
function
|
|
2879
|
+
function Sn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = mn) {
|
|
2554
2880
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2555
2881
|
return {
|
|
2556
2882
|
left: Math.min(Math.max(a, e), o),
|
|
2557
2883
|
top: Math.min(Math.max(a, t), s)
|
|
2558
2884
|
};
|
|
2559
2885
|
}
|
|
2560
|
-
function
|
|
2561
|
-
return e(
|
|
2886
|
+
function Cn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2887
|
+
return e(pn).matches;
|
|
2562
2888
|
}
|
|
2563
2889
|
//#endregion
|
|
2564
2890
|
//#region src/widget/mountExperienceWidget.ts
|
|
2565
|
-
function
|
|
2891
|
+
function wn(e) {
|
|
2566
2892
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2567
2893
|
}
|
|
2568
|
-
function
|
|
2894
|
+
function Tn(e) {
|
|
2569
2895
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2570
2896
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2571
2897
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2573,8 +2899,8 @@ function wn(e) {
|
|
|
2573
2899
|
function $(e) {
|
|
2574
2900
|
return e === "expanded" || e === "docked";
|
|
2575
2901
|
}
|
|
2576
|
-
var
|
|
2577
|
-
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) {
|
|
2578
2904
|
W(de);
|
|
2579
2905
|
let r = w({
|
|
2580
2906
|
galleryThumb: t.galleryThumb,
|
|
@@ -2604,7 +2930,7 @@ function kn(e, t, n) {
|
|
|
2604
2930
|
}
|
|
2605
2931
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2606
2932
|
}
|
|
2607
|
-
function
|
|
2933
|
+
function jn(e) {
|
|
2608
2934
|
return e.startButton ? {
|
|
2609
2935
|
...e.startButton,
|
|
2610
2936
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2616,7 +2942,7 @@ function An(e) {
|
|
|
2616
2942
|
variant: "primary"
|
|
2617
2943
|
};
|
|
2618
2944
|
}
|
|
2619
|
-
function
|
|
2945
|
+
function Mn(e) {
|
|
2620
2946
|
let t = !1, n = () => {
|
|
2621
2947
|
t || e();
|
|
2622
2948
|
}, r = () => {
|
|
@@ -2636,12 +2962,12 @@ function jn(e) {
|
|
|
2636
2962
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2637
2963
|
};
|
|
2638
2964
|
}
|
|
2639
|
-
function
|
|
2965
|
+
function Nn(e, t) {
|
|
2640
2966
|
he(me);
|
|
2641
2967
|
let n = t.experienceId?.trim();
|
|
2642
2968
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2643
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2644
|
-
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));
|
|
2645
2971
|
let o = document.createElement("button");
|
|
2646
2972
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2647
2973
|
let s = document.createElement("div");
|
|
@@ -2661,11 +2987,11 @@ function Mn(e, t) {
|
|
|
2661
2987
|
let m = document.createElement("span");
|
|
2662
2988
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2663
2989
|
let h = document.createElement("button");
|
|
2664
|
-
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");
|
|
2665
2991
|
let g = document.createElement("button");
|
|
2666
|
-
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");
|
|
2667
2993
|
let _ = document.createElement("button");
|
|
2668
|
-
_.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, _);
|
|
2669
2995
|
let v = document.createElement("div");
|
|
2670
2996
|
v.className = "liforma-ew__stage";
|
|
2671
2997
|
let y = document.createElement("div");
|
|
@@ -2693,11 +3019,11 @@ function Mn(e, t) {
|
|
|
2693
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";
|
|
2694
3020
|
}, oe = (e, t) => {
|
|
2695
3021
|
if (R() !== "docked") return;
|
|
2696
|
-
let n =
|
|
3022
|
+
let n = bn(), r = Sn(e - te, t - ne, n);
|
|
2697
3023
|
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2698
3024
|
}, se = (e, t) => {
|
|
2699
3025
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2700
|
-
let n =
|
|
3026
|
+
let n = bn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Sn(r + e, i + t, n);
|
|
2701
3027
|
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2702
3028
|
}, ce = (e) => {
|
|
2703
3029
|
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
@@ -2706,12 +3032,12 @@ function Mn(e, t) {
|
|
|
2706
3032
|
let t = I;
|
|
2707
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));
|
|
2708
3034
|
}, le = (e, t, n) => {
|
|
2709
|
-
if (S || R() !== "docked" || !
|
|
3035
|
+
if (S || R() !== "docked" || !Cn() || F !== null) return;
|
|
2710
3036
|
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2711
3037
|
let r = f.getBoundingClientRect();
|
|
2712
3038
|
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2713
3039
|
}, ue = (e) => {
|
|
2714
|
-
if (S || R() !== "docked" || !
|
|
3040
|
+
if (S || R() !== "docked" || !Cn() || F !== null) return;
|
|
2715
3041
|
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2716
3042
|
let t = f.getBoundingClientRect();
|
|
2717
3043
|
N = t.left, P = t.top;
|
|
@@ -2720,15 +3046,15 @@ function Mn(e, t) {
|
|
|
2720
3046
|
}, U = (e) => {
|
|
2721
3047
|
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2722
3048
|
}, W = () => {
|
|
2723
|
-
let e =
|
|
3049
|
+
let e = Cn(), t = R();
|
|
2724
3050
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2725
3051
|
h.hidden = !0;
|
|
2726
3052
|
return;
|
|
2727
3053
|
}
|
|
2728
|
-
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"));
|
|
2729
3055
|
}, fe = (e) => {
|
|
2730
|
-
let t =
|
|
2731
|
-
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();
|
|
2732
3058
|
}, pe = () => {
|
|
2733
3059
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2734
3060
|
requestAnimationFrame(() => {
|
|
@@ -2775,7 +3101,7 @@ function Mn(e, t) {
|
|
|
2775
3101
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2776
3102
|
}, xe = (e) => {
|
|
2777
3103
|
A?.(), A = null;
|
|
2778
|
-
let t =
|
|
3104
|
+
let t = An(s, e, { parallax: ie });
|
|
2779
3105
|
return t ? (A = t, !0) : !1;
|
|
2780
3106
|
}, Se = () => {
|
|
2781
3107
|
if (xe(_e)) {
|
|
@@ -2801,10 +3127,11 @@ function Mn(e, t) {
|
|
|
2801
3127
|
...t.mode ? { mode: t.mode } : {},
|
|
2802
3128
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2803
3129
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3130
|
+
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
2804
3131
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2805
3132
|
}), we = () => ({
|
|
2806
3133
|
...t.fit ? { fit: t.fit } : {},
|
|
2807
|
-
startButton:
|
|
3134
|
+
startButton: jn(t),
|
|
2808
3135
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2809
3136
|
}), J = (e = !0) => {
|
|
2810
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?.();
|
|
@@ -2836,7 +3163,7 @@ function Mn(e, t) {
|
|
|
2836
3163
|
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
2837
3164
|
}
|
|
2838
3165
|
}, Y = () => {
|
|
2839
|
-
S ||
|
|
3166
|
+
S || Cn() && R() === "expanded" && G(() => {
|
|
2840
3167
|
Te();
|
|
2841
3168
|
});
|
|
2842
3169
|
}, X = () => {
|
|
@@ -2855,7 +3182,7 @@ function Mn(e, t) {
|
|
|
2855
3182
|
let e = O;
|
|
2856
3183
|
l.hidden = !1, (async () => {
|
|
2857
3184
|
try {
|
|
2858
|
-
let t = await
|
|
3185
|
+
let t = await dn.startSession(Ce());
|
|
2859
3186
|
if (S || e !== O) {
|
|
2860
3187
|
t.destroy();
|
|
2861
3188
|
return;
|
|
@@ -2914,7 +3241,7 @@ function Mn(e, t) {
|
|
|
2914
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 () => {
|
|
2915
3242
|
try {
|
|
2916
3243
|
J();
|
|
2917
|
-
let t = await
|
|
3244
|
+
let t = await dn.startSession(Ce());
|
|
2918
3245
|
if (S || e !== O) {
|
|
2919
3246
|
t.destroy();
|
|
2920
3247
|
return;
|
|
@@ -2981,13 +3308,13 @@ function Mn(e, t) {
|
|
|
2981
3308
|
}, Re = (e) => {
|
|
2982
3309
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2983
3310
|
}, ze = (e) => {
|
|
2984
|
-
R() === "docked" &&
|
|
3311
|
+
R() === "docked" && Cn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2985
3312
|
}, Be = (e) => {
|
|
2986
3313
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), ke());
|
|
2987
3314
|
}, Ve = () => {
|
|
2988
3315
|
if (!S) {
|
|
2989
3316
|
if (R() === "docked") {
|
|
2990
|
-
if (!
|
|
3317
|
+
if (!Cn()) {
|
|
2991
3318
|
X();
|
|
2992
3319
|
return;
|
|
2993
3320
|
}
|
|
@@ -2998,9 +3325,9 @@ function Mn(e, t) {
|
|
|
2998
3325
|
}
|
|
2999
3326
|
W();
|
|
3000
3327
|
}
|
|
3001
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
3328
|
+
}, He = typeof window < "u" ? window.matchMedia(pn) : null, Ue = () => {
|
|
3002
3329
|
if (!S) {
|
|
3003
|
-
if (R() === "docked" && !
|
|
3330
|
+
if (R() === "docked" && !Cn()) {
|
|
3004
3331
|
X();
|
|
3005
3332
|
return;
|
|
3006
3333
|
}
|
|
@@ -3011,7 +3338,7 @@ function Mn(e, t) {
|
|
|
3011
3338
|
e.stopPropagation(), ke();
|
|
3012
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(() => {
|
|
3013
3340
|
S || Ne();
|
|
3014
|
-
}) : r === "idle" && (ee =
|
|
3341
|
+
}) : r === "idle" && (ee = Mn(() => {
|
|
3015
3342
|
S || Ne();
|
|
3016
3343
|
})), {
|
|
3017
3344
|
root: a,
|
|
@@ -3033,12 +3360,12 @@ function Mn(e, t) {
|
|
|
3033
3360
|
}
|
|
3034
3361
|
//#endregion
|
|
3035
3362
|
//#region src/react/ExperienceWidget.tsx
|
|
3036
|
-
function
|
|
3363
|
+
function Pn(t) {
|
|
3037
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";
|
|
3038
3365
|
return e(() => {
|
|
3039
3366
|
let e = r.current;
|
|
3040
3367
|
if (!e || !i.trim()) return;
|
|
3041
|
-
let t =
|
|
3368
|
+
let t = Nn(e, {
|
|
3042
3369
|
experienceId: i,
|
|
3043
3370
|
alt: o,
|
|
3044
3371
|
galleryThumb: s,
|
|
@@ -3116,11 +3443,11 @@ function Nn(t) {
|
|
|
3116
3443
|
}
|
|
3117
3444
|
//#endregion
|
|
3118
3445
|
//#region src/next/index.ts
|
|
3119
|
-
function
|
|
3446
|
+
function Fn(e = {}) {
|
|
3120
3447
|
let t = v(e);
|
|
3121
3448
|
return { POST: ({ request: e }) => t(e) };
|
|
3122
3449
|
}
|
|
3123
3450
|
//#endregion
|
|
3124
|
-
export { pe as ExperienceThumbnail,
|
|
3451
|
+
export { pe as ExperienceThumbnail, Pn as ExperienceWidget, v as createLiformaSessionRouteHandler, Fn as createLiformaSvelteKitSessionHandler };
|
|
3125
3452
|
|
|
3126
3453
|
//# sourceMappingURL=index.js.map
|